| 1 |
<?php |
<?php |
| 2 |
// $Id: contact.module,v 1.103 2008/01/16 12:46:52 goba Exp $ |
// $Id: contact.module,v 1.103.2.1 2008/04/09 21:11:46 goba Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
/** |
/** |
| 113 |
* Determine if a user can access to the contact tab. |
* Menu access callback for a user's personal contact form. |
| 114 |
|
* |
| 115 |
|
* @param $account |
| 116 |
|
* A user account object. |
| 117 |
|
* @return |
| 118 |
|
* TRUE if the current user has access to the requested user's contact form, |
| 119 |
|
* or FALSE otherwise. |
| 120 |
*/ |
*/ |
| 121 |
function _contact_user_tab_access($account) { |
function _contact_user_tab_access($account) { |
| 122 |
global $user; |
global $user; |
| 123 |
if (!isset($account->contact)) { |
|
| 124 |
$account->contact = FALSE; |
// Anonymous users cannot use or have contact forms. |
| 125 |
|
if (!$user->uid || !$account->uid) { |
| 126 |
|
return FALSE; |
| 127 |
} |
} |
| 128 |
return |
|
| 129 |
$account && $user->uid && |
// User administrators should always have access to personal contact forms. |
| 130 |
( |
if (user_access('administer users')) { |
| 131 |
($user->uid != $account->uid && $account->contact) || |
return TRUE; |
| 132 |
user_access('administer users') |
} |
| 133 |
); |
|
| 134 |
|
// Users may not contact themselves. |
| 135 |
|
if ($user->uid == $account->uid) { |
| 136 |
|
return FALSE; |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
// If the requested user has disabled their contact form, or this preference |
| 140 |
|
// has not yet been saved, do not allow users to contact them. |
| 141 |
|
if (empty($account->contact)) { |
| 142 |
|
return FALSE; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
return TRUE; |
| 146 |
} |
} |
| 147 |
|
|
| 148 |
/** |
/** |