You are here

function og_ui_user_admin_roles_submit in Organic groups 7

1 string reference to 'og_ui_user_admin_roles_submit'
og_ui_user_admin_roles in og_ui/og_ui.admin.inc
Menu callback: administer roles.

File

og_ui/og_ui.admin.inc, line 424
Admin settings for Organic groups module.

Code

function og_ui_user_admin_roles_submit($form, &$form_state) {
  $gid = $form_state['values']['gid'];
  if ($gid) {
    $group = og_load($gid);
  }
  $role = new stdClass();
  $role->gid = $gid;
  $role->name = $form_state['values']['name'];
  if (!empty($form_state['values']['rid'])) {
    $role->rid = $form_state['values']['rid'];
  }

  // Indicates if we need to save role.
  $save = FALSE;
  if ($form_state['values']['op'] == t('Save role')) {
    og_role_save($role);
    drupal_set_message(t('The role has been renamed.'));
  }
  elseif ($form_state['values']['op'] == t('Add role')) {
    og_role_save($role);
    drupal_set_message(t('The role has been added.'));
  }
  elseif ($form_state['values']['op'] == t('Delete role')) {
    og_role_delete($form_state['values']['rid']);
    drupal_set_message(t('The role has been deleted.'));
  }
  $form_state['redirect'] = $gid ? 'group/' . $group->entity_type . '/' . $group->etid . '/admin/people/roles' : 'admin/config/group/roles';
  return;
}