function _multiple_email_access in Multiple E-mail Addresses 2.x
Same name and namespace in other branches
- 6 multiple_email.module \_multiple_email_access()
- 7 multiple_email.module \_multiple_email_access()
2 calls to _multiple_email_access()
- multiple_email_confirm_page in ./
multiple_email_confirm_page.inc - Renders the page to confirm an e-mail address.
- theme_multiple_email_manage in ./
multiple_email_manage.inc - Theme multiple_email_manage form.
2 string references to '_multiple_email_access'
- multiple_email_menu in ./
multiple_email.module - Implements hook_menu().
- multiple_email_menu_alter in ./
multiple_email.module - Implements hook_menu_alter().
File
- ./
multiple_email.module, line 89 - multiple_email module file
Code
function _multiple_email_access($op, $account, $email = NULL) {
global $user;
$administer_user = user_access('administer multiple emails');
// Basic permission check to access any page.
// If the account does not have access to 'use multiple emails', return false.
// If the account does not belong to the current user and the user does not
// have 'administer multiple emails' permission, return false.
if (!user_access('use multiple emails', $account) || $account->uid != $user->uid && !$administer_user) {
return FALSE;
}
// If we have been given an e-mail address, make sure it belongs to the loaded
// account. Since Drupal will fail earlier if multiple_email_load fails, this
// is sufficient.
if (!empty($email) && $email->uid != $account->uid) {
return FALSE;
}
switch ($op) {
case 'pages':
case 'confirm':
// The above checks are sufficent for these operations.
return TRUE;
case 'primary':
// This page only makes sense if the e-mail isn't already the primary
// address and the e-mail is confirmed(or this is an admin).
if ($email->primary_address == 0 && ($email->confirmed == 1 || $administer_user)) {
return TRUE;
}
break;
case 'edit':
// Make sure this isn't the primary e-mail and the edit emails flag is
// enabled.
if ($email->primary_address == 0 && variable_get('multiple_email_edit_emails', 0) || $administer_user) {
return TRUE;
}
break;
case 'delete':
if (is_object($email) && $email->primary_address == 0) {
return TRUE;
}
break;
}
return FALSE;
}