function _role_watchdog_add_role in Role Watchdog 7
Same name and namespace in other branches
- 5 role_watchdog.module \_role_watchdog_add_role()
- 6.2 role_watchdog.module \_role_watchdog_add_role()
- 6 role_watchdog.module \_role_watchdog_add_role()
- 7.2 role_watchdog.module \_role_watchdog_add_role()
Internal function
Handles addition of roles.
1 call to _role_watchdog_add_role()
File
- ./
role_watchdog.module, line 234 - Logs changes to user roles.
Code
function _role_watchdog_add_role($rid, $account) {
global $user;
$roles = user_roles();
$record = array(
'aid' => $account->uid,
'rid' => $rid,
'action' => ROLE_WATCHDOG_ROLE_ADD,
'uid' => $user->uid,
'stamp' => 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]),
'!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;
}
}