<?php

/**
 * @file
 * Extends Service Links with Forward module support.
 *
 * @author Fabio Mucciante (TheCrow)
 */

/**
 * Implements hook_service_links().
 */
function forward_services_service_links() {
  $links = array();

  $links['forward'] = array(
    'name' => 'Forward',
    'link' => (variable_get('clean_url', 0) == 1) ? '<front-page>forward?path=<encoded-query>' : '<front-page>forward&path=<encoded-query>',
    'description' => t('Send to a friend'),
    'preset' => 'forward_url_fix',
  );

  return $links;
}

function forward_url_fix(&$service, &$settings, $node = NULL) {
  if (isset($node->nid)) {
    $service['link'] = str_replace('<encoded-query>', 'node/<node-id>', $service['link']);
  }
}
