function user_multiple_role_edit

cis7 user.module user_multiple_role_edit($accounts, $operation, $rid)
cle7 user.module user_multiple_role_edit($accounts, $operation, $rid)
elmsmedia7 user.module user_multiple_role_edit($accounts, $operation, $rid)
icor7 user.module user_multiple_role_edit($accounts, $operation, $rid)
meedjum_blog7 user.module user_multiple_role_edit($accounts, $operation, $rid)
mooc7 user.module user_multiple_role_edit($accounts, $operation, $rid)

Callback function for admin mass adding/deleting a user role.

5 calls to user_multiple_role_edit()
cis_service_activation_codes_form_submit in sites/all/modules/elmsln_contrib/cis_connector/modules/cis_service_activation_codes/cis_service_activation_codes.module
Activation code entry form submission.
lti_tool_provider_assign_global_roles_to_user in sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.module
Map a user to a drupal Global role based on his/her role in the LTI context.
lti_tool_provider_create_dummy_account in sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.module
Create a dummy account for a domain.
lti_tool_provider_unassign_global_roles_from_user in sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.module
Remove a user from drupal Global roles based on LTI roles.
_cis_service_connection_expire_roles in sites/all/modules/elmsln_contrib/cis_connector/modules/cis_service_connection/cis_service_connection.module
Handle Role expiration.
1 string reference to 'user_multiple_role_edit'
user_user_operations in modules/user/user.module
Implements hook_user_operations().

File

modules/user/user.module, line 3244
Enables the user registration and login system.

Code

function user_multiple_role_edit($accounts, $operation, $rid) {
  // The role name is not necessary as user_save() will reload the user
  // object, but some modules' hook_user() may look at this first.
  $role_name = db_query('SELECT name FROM {role} WHERE rid = :rid', array(':rid' => $rid))->fetchField();

  switch ($operation) {
    case 'add_role':
      $accounts = user_load_multiple($accounts);
      foreach ($accounts as $account) {
        // Skip adding the role to the user if they already have it.
        if ($account !== FALSE && !isset($account->roles[$rid])) {
          $roles = $account->roles + array($rid => $role_name);
          // For efficiency manually save the original account before applying
          // any changes.
          $account->original = clone $account;
          user_save($account, array('roles' => $roles));
        }
      }
      break;
    case 'remove_role':
      $accounts = user_load_multiple($accounts);
      foreach ($accounts as $account) {
        // Skip removing the role from the user if they already don't have it.
        if ($account !== FALSE && isset($account->roles[$rid])) {
          $roles = array_diff($account->roles, array($rid => $role_name));
          // For efficiency manually save the original account before applying
          // any changes.
          $account->original = clone $account;
          user_save($account, array('roles' => $roles));
        }
      }
      break;
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.