You are here

public function ultimate_cron_job_ctools_export_ui::access in Ultimate Cron 7.2

Access handler for an operation on a specific item.

Parameters

string $op: The operation in question.

UltimateCronJob $item: The cron job.

Return value

bool TRUE if access FALSE if not.

Overrides ctools_export_ui::access

1 call to ultimate_cron_job_ctools_export_ui::access()
ultimate_cron_job_ctools_export_ui::build_operations in plugins/ctools/export_ui/ultimate_cron_job_ctools_export_ui.class.php
Ensure that we cannot clone from the operations link list.

File

plugins/ctools/export_ui/ultimate_cron_job_ctools_export_ui.class.php, line 29
Export-ui handler for the Ultimate Cron jobs.

Class

ultimate_cron_job_ctools_export_ui
Class for cTools Export UI.

Code

public function access($op, $item) {
  switch ($op) {
    case 'list':
      return user_access('administer ultimate cron') || user_access($this->plugin['access']);
  }

  // More fine-grained access control:
  $key = $op . ' access';
  if (!empty($this->plugin[$key])) {
    if (!user_access($this->plugin[$key])) {
      return FALSE;
    }
  }

  // If we need to do a token test, do it here.
  if (empty($this->notoken) && !empty($this->plugin['allowed operations'][$op]['token']) && (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $op))) {
    return FALSE;
  }
  switch ($op) {
    case 'import':
      return user_access('use PHP for settings');
    case 'revert':
      return $item->export_type & EXPORT_IN_DATABASE && $item->export_type & EXPORT_IN_CODE;
    case 'delete':
      return $item->export_type & EXPORT_IN_DATABASE && !($item->export_type & EXPORT_IN_CODE);
    case 'disable':
      return empty($item->disabled);
    case 'enable':
      return !empty($item->disabled);
    case 'configure':
      if (!empty($item->hook['configure'])) {
        $cache = cache_get($item->hook['configure'], 'cache_menu');
        if ($cache) {
          $router_item = menu_get_item($item->hook['configure'], $cache->data);
        }
        else {
          $router_item = menu_get_item($item->hook['configure']);
          cache_set($item->hook['configure'], $router_item, 'cache_menu');
        }
        return $router_item['access'];
      }
      return TRUE;
    default:
      return TRUE;
  }
}