function _role_watchdog_process_role_changes in Role Watchdog 7
Same name and namespace in other branches
- 6.2 role_watchdog.module \_role_watchdog_process_role_changes()
- 6 role_watchdog.module \_role_watchdog_process_role_changes()
- 7.2 role_watchdog.module \_role_watchdog_process_role_changes()
2 calls to _role_watchdog_process_role_changes()
- role_watchdog_user_block in ./
role_watchdog.module - Process user block / unblock
- role_watchdog_user_save in ./
role_watchdog.module - Process role add/remove.
File
- ./
role_watchdog.module, line 180 - Logs changes to user roles.
Code
function _role_watchdog_process_role_changes($account, $new_roles, $old_roles) {
$count = 0;
// Is role added?
foreach ($new_roles as $rid) {
if (!in_array($rid, $old_roles)) {
$record = _role_watchdog_add_role($rid, $account);
if (is_array($record)) {
$count = $count + 1;
}
}
}
// Is role removed?
foreach ($old_roles as $rid) {
if (!in_array($rid, $new_roles)) {
$record = _role_watchdog_remove_role($rid, $account);
if (is_array($record)) {
$count = $count + 1;
}
}
}
if ($count) {
drupal_set_message(format_plural($count, t('Role change has been logged.'), t('Role changes have been logged.')));
}
}