You are here

function _role_watchdog_add_role in Role Watchdog 5

Same name and namespace in other branches
  1. 6.2 role_watchdog.module \_role_watchdog_add_role()
  2. 6 role_watchdog.module \_role_watchdog_add_role()
  3. 7.2 role_watchdog.module \_role_watchdog_add_role()
  4. 7 role_watchdog.module \_role_watchdog_add_role()

Internal function

Handles addition of roles.

2 calls to _role_watchdog_add_role()
role_watchdog_user_admin_account_submit in ./role_watchdog.module
Implementation of hook_form_submit()
role_watchdog_user_edit_submit in ./role_watchdog.module
Implementation of hook_form_submit()

File

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

Code

function _role_watchdog_add_role($rid, $old_roles, $account) {
  if (!in_array($rid, $old_roles)) {
    global $user;
    $roles = user_roles();
    $message = t('%user added role %role to %account', array(
      '%user' => $user->name,
      '%role' => $roles[$rid],
      '%account' => $account->name,
    ));
    watchdog('user', $message);
    _role_watchdog_notification($rid, $message);
    return 1;
  }
  return 0;
}