You are here

function og_views_plugin_argument_validate_og_group_types::validate_form in Organic groups 6.2

Same name and namespace in other branches
  1. 6 modules/og_views/includes/og_views_plugin_argument_validate_og_group_types.inc \og_views_plugin_argument_validate_og_group_types::validate_form()

File

modules/og_views/includes/og_views_plugin_argument_validate_og_group_types.inc, line 15

Class

og_views_plugin_argument_validate_og_group_types
Validate whether an argument is a group node.

Code

function validate_form(&$form, &$form_state) {
  $form['validate_argument_nid_type'] = array(
    '#type' => 'select',
    '#title' => t('Argument type'),
    '#options' => array(
      'nid' => t('Node ID'),
      'nids' => t("Node ID's separated by , or +"),
    ),
    '#default_value' => isset($this->argument->options['validate_argument_nid_type']) ? $this->argument->options['validate_argument_nid_type'] : 'nid',
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-options-validate-type' => array(
        $this->id,
      ),
    ),
  );
  $options = array(
    OG_VIEWS_DO_NOT_VALIDATE_MEMBERSHIP => t('Do not validate user\'s group membership'),
    OG_VIEWS_VALIDATE_GROUP_MEMBER => t('Validate current user is a member of a specified group'),
    OG_VIEWS_VALIDATE_GROUP_ADMIN => t('Validate current user is an admin of a specified group'),
  );
  $form['validate_argument_is_member'] = array(
    '#type' => 'select',
    '#title' => t('Group membership validation'),
    '#options' => $options,
    '#default_value' => isset($this->argument->options['validate_argument_is_member']) ? $this->argument->options['validate_argument_is_member'] : 0,
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-options-validate-type' => array(
        $this->id,
      ),
    ),
  );
  $options = array();
  $types = node_get_types();
  $group_types = og_get_types('group');
  foreach ($group_types as $type) {
    $info = $types[$type];
    $options[$type] = check_plain(t($info->name));
  }
  $default_types = $this->argument->options['validate_argument_group_node_type'];
  if (empty($default_types)) {
    $default_types = array();
  }
  $form['validate_argument_group_node_type'] = array(
    '#type' => 'checkboxes',
    '#prefix' => '<div id="edit-options-validate-argument-group-node-type-wrapper">',
    '#suffix' => '</div>',
    '#title' => t('Group node types'),
    '#options' => $options,
    '#default_value' => $default_types,
    '#description' => t('If you wish to validate for specific group node types, check them; if none are checked, all group nodes will pass.'),
    '#process' => array(
      'expand_checkboxes',
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-options-validate-type' => array(
        $this->id,
      ),
    ),
  );
}