You are here

function userprotect_user_edit_access in User protect 6

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

Access callback for user edit pages.

This replaces user_edit_access from user.module.

Parameters

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

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

File

./userprotect.module, line 406

Code

function userprotect_user_edit_access($account) {
  global $user;
  if (($user->uid == $account->uid || 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');
      }
      return FALSE;
    }
    else {
      return TRUE;
    }
  }
  else {
    return FALSE;
  }
}