You are here

function userprotect_user_edit_access in User protect 7

Same name and namespace in other branches
  1. 6 userprotect.module \userprotect_user_edit_access()

Access callback for user edit pages.

This replaces user_edit_access from user.module.

Parameters

object $account: An object representing the user to be edited.

Return value

bool TRUE if access is granted. FALSE otherwise.

1 string reference to 'userprotect_user_edit_access'
userprotect_menu_alter in ./userprotect.module
Implements hook_menu_alter().

File

./userprotect.module, line 388
Main module file for the userprotect module.

Code

function userprotect_user_edit_access($account) {

  // Perform core's access check.
  if (($GLOBALS['user']->uid == $account->uid && user_access('edit own account') || user_access('administer users')) && $account->uid > 0) {

    // Check to see if the user's roles are protecting edits, or the user
    // account itself is protected.
    if (!userprotect_check_bypass('up_edit') && userprotect_get_user_protection($account, 'up_edit')) {

      // If so, and we're at /user/X/edit, set a message.
      if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit') {
        drupal_set_message(t('%user is currently being protected from any edits.', array(
          '%user' => $account->name,
        )), 'error', FALSE);
      }
      return FALSE;
    }
    else {
      return TRUE;
    }
  }
  else {
    return FALSE;
  }
}