You are here

public function uc_addresses_views_access::options_form in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 views/uc_addresses_views_access.inc \uc_addresses_views_access::options_form()

Implements views_plugin#options_form().

Overrides views_plugin_access::options_form

File

views/uc_addresses_views_access.inc, line 64
Contains uc_addresses_views_access class.

Class

uc_addresses_views_access
Access plugin that provides access control based on custom PHP code.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['help'] = array(
    '#type' => 'markup',
    '#value' => t('With this access control type you can restrict access to this display based on an user ID argument and/or an address ID argument.') . ' ' . t('Note that this currently only works for path based displays, such as  "!page" displays.', array(
      '!page' => t('Page'),
    )),
  );

  // Get list of Views arguments.
  $handlers = $this->display->handler
    ->get_handlers('argument');

  // User can select specific arguments to pass on.
  $options = array(
    '' => t('- None -'),
  );
  foreach ($handlers as $key => $handler) {
    $options[$key] = $handler->definition['title'];
  }
  $form['uid_argument'] = array(
    '#type' => 'select',
    '#title' => t('User argument'),
    '#description' => t('Optionally select an Views argument that represents an User ID. Only users with permission to access addresses of this user will have access to this display.'),
    '#options' => $options,
    '#default_value' => $this->options['uid_argument'],
  );
  $form['aid_argument'] = array(
    '#type' => 'select',
    '#title' => t('Address ID argument'),
    '#description' => t('Optionally select an Views argument that represents an address ID. Only users with permission to access this address will have access to this display.'),
    '#options' => $options,
    '#default_value' => $this->options['aid_argument'],
  );

  // User can choose which access operation to check: view, edit or delete.
  $form['access_type'] = array(
    '#type' => 'select',
    '#title' => t('Access type'),
    '#description' => t('Select for which type of operation permissions should be checked. Usually "!access_type".', array(
      '!access_type' => t('View'),
    )),
    '#options' => array(
      'view' => t('View'),
      'edit' => t('Edit'),
      'delete' => t('Delete'),
    ),
    '#default_value' => $this->options['access_type'],
  );
}