Commit c89f2c9e authored by Gábor Hojtsy's avatar Gábor Hojtsy

#525504 by gpk, Dave Reid, sun: anonymous users should not have a contact...

#525504 by gpk, Dave Reid, sun: anonymous users should not have a contact form; also with added code documentation
parent 7aa7a748
......@@ -110,19 +110,39 @@ function contact_menu() {
}
/**
* Determine if a user can access to the contact tab.
* Menu access callback for a user's personal contact form.
*
* @param $account
* A user account object.
* @return
* TRUE if the current user has access to the requested user's contact form,
* or FALSE otherwise.
*/
function _contact_user_tab_access($account) {
global $user;
if (!isset($account->contact)) {
$account->contact = FALSE;
// Anonymous users cannot use or have contact forms.
if (!$user->uid || !$account->uid) {
return FALSE;
}
return
$account && $user->uid &&
(
($user->uid != $account->uid && $account->contact) ||
user_access('administer users')
);
// User administrators should always have access to personal contact forms.
if (user_access('administer users')) {
return TRUE;
}
// Users may not contact themselves.
if ($user->uid == $account->uid) {
return FALSE;
}
// If the requested user has disabled their contact form, or this preference
// has not yet been saved, do not allow users to contact them.
if (empty($account->contact)) {
return FALSE;
}
return TRUE;
}
/**
......
......@@ -1117,12 +1117,30 @@ function user_menu() {
return $items;
}
/**
* Implementation of hook_init().
*/
function user_init() {
drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
}
function user_uid_optional_load($arg) {
return user_load(isset($arg) ? $arg : $GLOBALS['user']->uid);
/**
* Load either a specified or the current user account.
*
* @param $uid
* An optional user ID of the user to load. If not provided, the current
* user's ID will be used.
* @return
* A fully-loaded $user object upon successful user load, FALSE if user
* cannot be loaded.
*
* @see user_load()
*/
function user_uid_optional_load($uid = NULL) {
if (!isset($uid)) {
$uid = $GLOBALS['user']->uid;
}
return user_load($uid);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment