You are here

function og_access_alter_group_form in Organic groups 6

Same name and namespace in other branches
  1. 5.8 og_access.module \og_access_alter_group_form()
  2. 5 og_access.module \og_access_alter_group_form()
  3. 5.3 og_access.module \og_access_alter_group_form()
  4. 5.7 og_access.module \og_access_alter_group_form()
  5. 6.2 modules/og_access/og_access.module \og_access_alter_group_form()
1 call to og_access_alter_group_form()
og_access_form_alter in modules/og_access/og_access.module
Implementation of hook_form_alter().

File

modules/og_access/og_access.module, line 75

Code

function og_access_alter_group_form(&$form, $node) {

  // private groups
  $visibility = variable_get('og_private_groups', OG_PRIVATE_GROUPS_CHOOSE_FALSE);

  // override setting for admins - get right default
  if (user_access('administer nodes')) {
    $not = array(
      OG_PRIVATE_GROUPS_NEVER,
      OG_PRIVATE_GROUPS_CHOOSE_FALSE,
    );
    $visibility = in_array($visibility, $not) ? OG_PRIVATE_GROUPS_CHOOSE_FALSE : OG_PRIVATE_GROUPS_CHOOSE_TRUE;
  }
  $default = FALSE;
  switch ($visibility) {
    case OG_PRIVATE_GROUPS_NEVER:
      $form['og_private'] = array(
        '#type' => 'value',
        '#value' => 0,
      );
      break;
    case OG_PRIVATE_GROUPS_ALWAYS:
      $form['og_private'] = array(
        '#type' => 'value',
        '#value' => 1,
      );
      break;
    case OG_PRIVATE_GROUPS_CHOOSE_TRUE:
      $default = TRUE;

    // fall through
    case OG_PRIVATE_GROUPS_CHOOSE_FALSE:
      $form['og_private'] = array(
        '#type' => 'checkbox',
        '#title' => t('Private group'),
        '#default_value' => isset($node->nid) ? $node->og_private : $default,
        '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'og_private') : 0,
        '#description' => t('Should this group be visible only to its members? Disabled if the group is set to <em>List in Directory</em> or <em>Membership requests: open</em>.'),
      );
      break;
  }
}