function _role_watchdog_add_role in Role Watchdog 6
Same name and namespace in other branches
- 5 role_watchdog.module \_role_watchdog_add_role()
- 6.2 role_watchdog.module \_role_watchdog_add_role()
- 7.2 role_watchdog.module \_role_watchdog_add_role()
- 7 role_watchdog.module \_role_watchdog_add_role()
Internal function
Handles addition of roles.
3 calls to _role_watchdog_add_role()
- _og_role_watchdog_approve_role in modules/
og_role_watchdog/ og_role_watchdog.module - Internal function
- _og_role_watchdog_request_role in modules/
og_role_watchdog/ og_role_watchdog.module - Internal function
- _role_watchdog_process_role_changes in ./
role_watchdog.module
File
- ./
role_watchdog.module, line 221 - Logs changes to user roles.
Code
function _role_watchdog_add_role($rid, $old_roles = array(), $account, $action = ROLE_WATCHDOG_ROLE_ADD, $vars = array()) {
if (!in_array($rid, $old_roles)) {
global $user;
$roles = user_roles();
$record = array(
'aid' => $account->uid,
'rid' => $rid,
'action' => $action,
'uid' => $user->uid,
'stamp' => $_SERVER['REQUEST_TIME'],
);
if (drupal_write_record('role_watchdog', $record)) {
$vars += array(
'body' => 'Role !role!role_modifier added to !account by !user',
'!role' => check_plain($roles[$rid]),
'!role_modifier' => '',
'!user' => check_plain($user->name),
'!user_id' => $user->uid,
'!account' => check_plain($account->name),
'!account_id' => $account->uid,
);
watchdog('role_watchdog', $vars['body'], $vars, WATCHDOG_NOTICE, l(t('view'), 'user/' . $account->uid . '/track/role_history'));
_role_watchdog_notification($rid, $vars);
return $record;
}
else {
watchdog('role_watchdog', 'Unable to save record in _role_watchdog_add_role()', array(), WATCHDOG_ERROR, l(t('view'), 'user/' . $account->uid . '/track/role_history'));
return ROLE_WATCHDOG_ROLE_NOCHANGE;
}
}
return ROLE_WATCHDOG_ROLE_NOCHANGE;
}