You are here

function spaces_plugin_access_spaces_feature::options_form in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 includes/spaces_plugin_access_spaces_feature.inc \spaces_plugin_access_spaces_feature::options_form()
  2. 6 includes/spaces_plugin_access_spaces_feature.inc \spaces_plugin_access_spaces_feature::options_form()
  3. 6.2 includes/spaces_plugin_access_spaces_feature.inc \spaces_plugin_access_spaces_feature::options_form()
  4. 7 includes/spaces_plugin_access_spaces_feature.inc \spaces_plugin_access_spaces_feature::options_form()

Override of options_form().

Overrides views_plugin_access::options_form

File

includes/spaces_plugin_access_spaces_feature.inc, line 61

Class

spaces_plugin_access_spaces_feature
Provides access control for views by checking against the current space's feature settings. Optionally allows a permission to be checked in addition to the first feature access control check.

Code

function options_form(&$form, &$form_state) {

  // Generate feature options.
  $options = array(
    0 => t('Autodetect'),
  );
  foreach (spaces_features() as $feature) {
    $options[$feature->name] = check_plain($feature->info['name']);
  }
  $form['spaces_feature'] = array(
    '#type' => 'select',
    '#title' => t('Feature'),
    '#default_value' => $this->options['spaces_feature'],
    '#options' => $options,
    '#description' => t('Only allow access to this view if the user has access to the selected feature.'),
  );

  // Get list of permissions.
  $perms = array(
    '' => '<' . t('No permission check') . '>',
  );
  $module_info = system_get_info('module');

  // Get list of permissions
  foreach (module_implements('permission') as $module) {
    $permissions = module_invoke($module, 'permission');
    foreach ($permissions as $name => $perm) {
      $perms[$module_info[$module]['name']][$name] = strip_tags($perm['title']);
    }
  }
  asort($perms);
  $form['perm'] = array(
    '#type' => 'select',
    '#options' => $perms,
    '#title' => t('Permission'),
    '#default_value' => $this->options['perm'],
    '#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'),
  );
}