function oa_core_add_admin in Open Atrium Core 7.2
Menu callback to make user an admin
Parameters
$group_type:
$gid:
$uid:
1 string reference to 'oa_core_add_admin'
- oa_core_menu in ./
oa_core.module - Implements hook_menu().
File
- ./
oa_core.module, line 1054
Code
function oa_core_add_admin($group_type, $gid, $uid, $type = 'nojs') {
if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $group_type . '_' . $gid . '_' . $uid)) {
return MENU_ACCESS_DENIED;
}
$account = user_load($uid);
$group = entity_load_single($group_type, $gid);
$label = entity_label($group_type, $group);
$og_roles = og_roles($group_type, $group->type, $gid, FALSE, FALSE);
$rid = array_search(OG_ADMINISTRATOR_ROLE, $og_roles);
if ($rid > 0) {
og_role_grant($group_type, $gid, $uid, $rid);
og_invalidate_cache();
drupal_set_message(t('%user has been added as an Admin to the space %title.', array(
'%user' => format_username($account),
'%title' => $label,
)));
}
if ($type != 'ajax') {
drupal_goto();
}
else {
$commands = array();
$commands[] = ajax_command_append('#oa-core-messages', theme('status_messages'));
$page = array(
'#type' => 'ajax',
'#commands' => $commands,
);
ajax_deliver($page);
}
return NULL;
}