function _og_role_watchdog_add_role in Role Watchdog 7.2
Same name and namespace in other branches
- 7 modules/og_role_watchdog/og_role_watchdog.module \_og_role_watchdog_add_role()
3 calls to _og_role_watchdog_add_role()
- og_role_watchdog_og_membership_insert in modules/
og_role_watchdog/ og_role_watchdog.module - Implements hook_og_membership_insert().
- og_role_watchdog_og_membership_update in modules/
og_role_watchdog/ og_role_watchdog.module - Implements hook_og_membership_update().
- _og_role_watchdog_process_role_changes in modules/
og_role_watchdog/ og_role_watchdog.module - Internal function
File
- modules/
og_role_watchdog/ og_role_watchdog.module, line 206 - Logs changes to user roles.
Code
function _og_role_watchdog_add_role($rid, $account, $gid, $action = ROLE_WATCHDOG_ROLE_ADD) {
global $user;
$group_entity = entity_load_single('node', $gid);
//@todo: not sure we need the next line? If it was the case that these were just the defaults for this particular
// group only those roles would be set when the og_roles is called. That could be incorrect though.
//$query_gid = og_is_group_default_access('node', $gid) ? 0 : $gid;
$roles = og_roles('node', $group_entity->type, $gid);
$record = array(
'aid' => $account->uid,
'rid' => ROLE_WATCHDOG_NO_ROLE,
'action' => $action,
'uid' => $user->uid,
'stamp' => REQUEST_TIME,
);
if (drupal_write_record('role_watchdog', $record)) {
$vars = array(
'body' => 'Role !role in group "!group" added to !account by !user',
'!role' => check_plain($roles[$rid]),
'!group' => check_plain($group_entity->title),
'!user' => check_plain($user->name),
'!user_id' => $user->uid,
'!account' => check_plain($account->name),
'!account_id' => $account->uid,
);
_og_role_watchdog_write_group_information($record, $gid, $rid);
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 _og_role_watchdog_add_role()', array(), WATCHDOG_ERROR, l(t('view'), 'user/' . $account->uid . '/track/role_history'));
return ROLE_WATCHDOG_ROLE_NOCHANGE;
}
}