File
  - 
              plugins/access/context_exists.inc
    
   
  
    View source
  
  <?php
$plugin = array(
  'title' => t("Context exists"),
  'description' => t('Control access by whether or not a context exists and contains data.'),
  'callback' => 'ctools_context_exists_ctools_access_check',
  'settings form' => 'ctools_context_exists_ctools_access_settings',
  'summary' => 'ctools_context_exists_ctools_access_summary',
  'required context' => new ctools_context_required(t('Context'), 'any', TRUE),
  'defaults' => array(
    'exists' => TRUE,
  ),
);
function ctools_context_exists_ctools_access_settings($form, &$form_state, $conf) {
  $form['settings']['exists'] = array(
    '#type' => 'radios',
    '#description' => t("Check to see if the context exists (contains data) or does not exist (contains no data). For example, if a context is optional and the path does not contain an argument for that context, it will not exist."),
    '#options' => array(
      TRUE => t('Exists'),
      FALSE => t("Doesn't exist"),
    ),
    '#default_value' => $conf['exists'],
  );
  return $form;
}
function ctools_context_exists_ctools_access_check($conf, $context) {
  
  
  
  return empty($context->data) xor !empty($conf['exists']);
}
function ctools_context_exists_ctools_access_summary($conf, $context) {
  if (!empty($conf['exists'])) {
    return t('@identifier exists', array(
      '@identifier' => $context->identifier,
    ));
  }
  else {
    return t('@identifier does not exist', array(
      '@identifier' => $context->identifier,
    ));
  }
}
 
Functions