You are here

function role_watchdog_user_admin_account_submit in Role Watchdog 5

Implementation of hook_form_submit()

File

./role_watchdog.module, line 129
Logs changes to user roles.

Code

function role_watchdog_user_admin_account_submit($form, &$form_state) {
  list($op, $rid) = explode('-', $form_state['operation']);
  if (!in_array($op, array(
    'add_role',
    'remove_role',
  ))) {
    return;
  }
  if (!$rid) {
    return;
  }
  $accounts = array_filter($form_state['accounts']);
  foreach ($accounts as $uid) {
    $account = user_load(array(
      'uid' => $uid,
    ));
    $old_roles = array_keys($account->roles);
    if ($op == 'add_role') {
      $count += _role_watchdog_add_role($rid, $old_roles, $account);
    }
    else {

      //remove role
      $count += _role_watchdog_remove_role($rid, $old_roles, $account, IN_ARRAY);
    }
  }
  _role_watchdog_set_message($count);
}