You are here

function _ultimate_cron_job_delete in Ultimate Cron 7.2

CTools Export delete callback.

Revert a job and log it.

Parameters

mixed $object: Name of job or UltimateCronJob object.

2 string references to '_ultimate_cron_job_delete'
ultimate_cron_schema in ./ultimate_cron.install
Implements hook_schema().
ultimate_cron_update_7200 in ./ultimate_cron.install
Rename columns and indices to 2.x style.

File

./ultimate_cron.module, line 560

Code

function _ultimate_cron_job_delete($object) {
  $table = 'ultimate_cron_job';
  $schema = ctools_export_get_schema($table);
  $export = $schema['export'];

  // If we were sent an object, get the export key from it. Otherwise
  // assume we were sent the export key.
  if (!is_object($object)) {
    $name = $object;
    if (!($object = _ultimate_cron_job_load($name))) {
      throw new Exception(t('Unable to revert unknown job: @name', array(
        '@name' => $name,
      )));
    }
  }
  db_delete($table)
    ->condition($export['key'], $object->{$export['key']})
    ->execute();
  if (empty($object->dont_log)) {
    $log = $object
      ->startLog(uniqid($object->name, TRUE), 'modification', ULTIMATE_CRON_LOG_TYPE_ADMIN);
    $log
      ->log($object->name, 'Job reverted by ' . $log
      ->formatUser(), array(), WATCHDOG_INFO);
    $log
      ->finish();
  }
}