function og_ui_admin_roles in Organic groups 7.2
Menu callback: administer roles.
See also
theme_group_user_admin_new_role()
2 string references to 'og_ui_admin_roles'
- og_ui_forms in og_ui/
og_ui.module - Implement hook_forms().
- og_ui_menu in og_ui/
og_ui.module - Implements hook_menu().
File
- og_ui/
og_ui.admin.inc, line 478 - Admin settings for Organic groups module.
Code
function og_ui_admin_roles($form, $form_state, $group_type = '', $gid = 0, $bundle = '', $rid = 0) {
if ($gid) {
og_set_breadcrumb($group_type, $gid, array(
l(t('Group'), "{$group_type}/{$gid}/group"),
), l(t('Roles'), "group/{$group_type}/{$gid}/admin/roles"));
}
if ($rid) {
// Display the edit role form.
$role = og_role_load($rid);
// Get group type and bundle from role.
$bundle = $role->group_bundle;
$group_type = $role->group_type;
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Role name'),
'#default_value' => $role->name,
'#size' => 30,
'#required' => TRUE,
'#maxlength' => 64,
'#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
);
$form['rid'] = array(
'#type' => 'value',
'#value' => $rid,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save role'),
);
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete role'),
);
}
else {
if ($gid) {
$group = entity_load_single($group_type, $gid);
list(, , $bundle) = entity_extract_ids($group_type, $group);
}
// No role ID.
if (!$gid || $group && !og_is_group_default_access($group_type, $group)) {
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#title_display' => 'invisible',
'#size' => 32,
'#maxlength' => 64,
);
$form['add'] = array(
'#type' => 'submit',
'#value' => t('Add role'),
'#validate' => array(
'og_ui_admin_roles_validate',
),
'#submit' => array(
'og_ui_admin_roles_submit',
),
);
// Attach the CSS to the form.
$form['#attached'] = array(
'css' => array(
'type' => 'file',
'data' => drupal_get_path('module', 'og_ui') . '/css/og_ui.css',
),
);
}
}
$form['group_type'] = array(
'#type' => 'value',
'#value' => $group_type,
);
$form['bundle'] = array(
'#type' => 'value',
'#value' => $bundle,
);
$form['gid'] = array(
'#type' => 'value',
'#value' => $gid,
);
$role_names = _og_ui_get_role_names($group_type, $bundle, $gid, $rid);
$form['role_names'] = array(
'#type' => 'value',
'#value' => $role_names,
);
return $form;
}