Issue #1081286 by Berdir: Fixed url prefix user/%user/messages is broken when private...
[project/privatemsg.git] / privatemsg.author-pane.inc
1 <?php
2
3 /**
4 * @file
5 * Provides a preprocess function to integrate Privatemsg with Author Pane.
6 */
7
8 /**
9 * Implements hook_preprocess_author_pane().
10 */
11 function privatemsg_preprocess_author_pane(&$variables) {
12 global $user;
13 $account = $variables['account'];
14
15 if (function_exists('author_pane_api') && author_pane_api() == "2") {
16 // Author Pane 2.x
17
18 // Check if this preprocess needs to be run given who's calling it.
19 if (!author_pane_run_preprocess('privatemsg', $variables['caller'])) {
20 return;
21 }
22
23 $url = privatemsg_get_link($account);
24 if (!empty($url)) {
25 $variables['privatemsg'] = l('<span>' . t('Send PM') . '</span>', $url, array('attributes' => array('class' => 'author-pane-link', 'title' => t('Send @name a private message', array('@name' => privatemsg_recipient_format($account, array('plain' => TRUE))))), 'html' => TRUE));
26
27 // Early versions of the template used this variable so fill it for
28 // backwards compatability.
29 $variables['privatemsg_link'] = $variables['privatemsg'];
30 }
31 }
32 else {
33 // Author Pane 1.x
34
35 $image_path = $variables['image_path'];
36
37 // Send private message
38 if ($url = privatemsg_get_link($account)) {
39 $img = theme('image', "$image_path/private-message.png", t('Send private message'), t('Send private message'), NULL, TRUE);
40 $variables['privatemsg'] = l($img, $url, array('absolute' => TRUE, 'html' => TRUE));
41 $variables['privatemsg_link'] = l(t('Send private message'), $url, array('attributes' => array('class' => 'author-privatemsg-icon'), 'html' => TRUE));
42 }
43 }
44 }
45
46 /**
47 * Implementation of hook_author_pane_allow_preprocess_disable().
48 */
49 function privatemsg_author_pane_allow_preprocess_disable() {
50 return array('privatemsg' => 'Privatemsg');
51 }