You are here

function contact_preprocess_author_pane in Author Pane 6.2

Same name and namespace in other branches
  1. 5 modules/contact.author-pane.inc \contact_preprocess_author_pane()
  2. 6 modules/contact.author-pane.inc \contact_preprocess_author_pane()
  3. 7.2 modules/contact.author-pane.inc \contact_preprocess_author_pane()

Implementation of hook_preprocess_author_pane().

File

modules/contact.author-pane.inc, line 11
This file provides a preprocess function on behalf of the contact module.

Code

function contact_preprocess_author_pane(&$variables) {

  // Check if this preprocess needs to be run given who's calling it.
  if (!author_pane_run_preprocess('contact', $variables['caller'])) {
    return;
  }
  global $user;
  $account = $variables['account'];
  $account_id = $account->uid;

  // If the viewer isn't anonymous and
  // the author isn't anonymous and
  // the viewer isn't the author and
  // either the author has contact enabled or the viewer has admin users access
  // then show the link.
  $variables['contact'] = '';
  if ($user->uid != 0 && $account_id != 0 && $account_id != $user->uid && (!empty($account->contact) || user_access('administer users'))) {
    $variables['contact'] = l('<span>' . t('Email') . '</span>', "user/{$account_id}/contact", array(
      'attributes' => array(
        'class' => 'author-pane-link',
      ),
      'html' => TRUE,
    ));
  }
}