function ctools_access_admin_form

Administrative form for access control.

3 calls to ctools_access_admin_form()
ctools_access_ruleset_ui::edit_form_rules in ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php
ctools_context_handler_edit_criteria in includes/context-task-handler.inc
Form to choose context based selection rules for a task handler.
page_manager_page_form_access in page_manager/plugins/tasks/page.admin.inc
Form to handle menu item controls.

File

includes/context-access-admin.inc, line 116

Code

function ctools_access_admin_form($form, &$form_state) {
    ctools_include('context');
    $argument = isset($form_state['callback argument']) ? $form_state['callback argument'] : '';
    $fragment = $form_state['module'];
    if ($argument) {
        $fragment .= '-' . $argument;
    }
    $contexts = isset($form_state['contexts']) ? $form_state['contexts'] : array();
    $form['access_table'] = array(
        '#markup' => ctools_access_admin_render_table($form_state['access'], $fragment, $contexts),
    );
    $form['add-button'] = array(
        '#theme' => 'ctools_access_admin_add',
    );
    // This sets up the URL for the add access modal.
    $form['add-button']['add-url'] = array(
        '#attributes' => array(
            'class' => array(
                "ctools-access-add-url",
            ),
        ),
        '#type' => 'hidden',
        '#value' => url("ctools/context/ajax/access/add/{$fragment}", array(
            'absolute' => TRUE,
        )),
    );
    $plugins = ctools_get_relevant_access_plugins($contexts);
    $options = array();
    foreach ($plugins as $id => $plugin) {
        $options[$id] = $plugin['title'];
    }
    asort($options);
    $form['add-button']['type'] = array(
        // This ensures that the form item is added to the URL.
'#attributes' => array(
            'class' => array(
                "ctools-access-add-url",
            ),
        ),
        '#type' => 'select',
        '#options' => $options,
        '#required' => FALSE,
    );
    $form['add-button']['add'] = array(
        '#type' => 'submit',
        '#attributes' => array(
            'class' => array(
                'ctools-use-modal',
            ),
        ),
        '#id' => "ctools-access-add",
        '#value' => t('Add'),
    );
    $form['logic'] = array(
        '#type' => 'radios',
        '#options' => array(
            'and' => t('All criteria must pass.'),
            'or' => t('Only one criteria must pass.'),
        ),
        '#default_value' => isset($form_state['access']['logic']) ? $form_state['access']['logic'] : 'and',
    );
    if (empty($form_state['no buttons'])) {
        $form['buttons']['save'] = array(
            '#type' => 'submit',
            '#value' => t('Save'),
            '#submit' => array(
                'ctools_access_admin_form_submit',
            ),
        );
    }
    return $form;
}