You are here

function _roleassign_user_presave in RoleAssign 7

Same name and namespace in other branches
  1. 7.2 roleassign.admin.inc \_roleassign_user_presave()

Really implements hook_user_presave().

Parameters

array $edit:

object $account:

string $category:

1 call to _roleassign_user_presave()
roleassign_user_presave in ./roleassign.module
Implements hook_user_presave().

File

./roleassign.admin.inc, line 129
Allows site administrators to further delegate the task of managing user's roles.

Code

function _roleassign_user_presave(array &$edit, $account, $category) {

  // If this isn't the account category, or there is no roleassign_roles
  // field, there isn't much to do.
  if ($category != 'account' || !isset($edit['roleassign_roles'])) {
    return;
  }

  // If someone is trying to update user's roles, it's a malicious
  // attempt to alter user's roles.
  if (!user_access('assign roles')) {
    watchdog('security', "Detected malicious attempt to alter user's roles.", array(), WATCHDOG_WARNING);
    form_set_error('category', t("Detected malicious attempt to alter user's roles."));
  }

  // On submit, copy sticky and assigned roles from 'roleassign_roles'
  // to 'roles'.
  $edit['roles'] = array_filter(_roleassign_sticky_roles() + $edit['roleassign_roles']);
  unset($edit['roleassign_roles']);
}