You are here

function ed_classified_link in Classified Ads 7.2

Same name and namespace in other branches
  1. 5.2 ed_classified.module \ed_classified_link()
  2. 5 ed_classified.module \ed_classified_link()
  3. 6.2 ed_classified.module \ed_classified_link()

Implementation of hook_link().

File

./ed_classified.module, line 279
Simple text-based classified ads module. Michael Curry, Exodus Development, Inc. exodusdev@gmail.com for more information, please visit http://exodusdev.com/drupal/modules/classified.module Copyright (c) 2006, 2007 Exodus Development, Inc. All Rights…

Code

function ed_classified_link($type, $node = NULL, $teaser = FALSE) {
  module_load_include('inc', 'ed_classified', 'ed_classified_utils');
  $links = array();
  global $user;
  if (_ed_classified_node_is_classified($node)) {
    if (user_access('access user profiles') && _ed_classified_variable_get('show_contact_form_link_on_posts', TRUE) && _ed_classified_module_exists('contact')) {
      $ad_author = user_load(array(
        'uid' => $node->uid,
      ));
      if ($ad_author && $user->uid != $ad_author->uid && $ad_author->uid != 0) {
        $links['ed_classified_contact'] = array(
          'title' => t('View the advertiser\'s (@advertiser) profile.', array(
            '@advertiser' => $ad_author->name,
          )),
          'href' => 'user/' . $ad_author->uid,
          'html' => TRUE,
        );
      }
    }

    // Show contact link
    if (0 != $user->uid && module_exists('contact')) {

      // only if logged in and there's a sitewide contact form
      $links['ed_classified_suggest_new_category'] = array(
        'title' => t('Suggest a new category'),
        'href' => 'contact',
        'attributes' => array(
          'title' => t('Click here to suggest a new classified ad category'),
        ),
      );
    }
  }
  return $links;
}