You are here

function _ultimate_cron_job_save in Ultimate Cron 7.2

CTools Export save callback.

Save a job and log it.

Parameters

UltimateCronJob &$object: The UltimateCronJob to save.

Return value

bool Result of drupal_write_record().

2 string references to '_ultimate_cron_job_save'
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 521

Code

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

  // Objects should have a serial primary key. If not, simply fail to write.
  if (empty($export['primary key'])) {
    return FALSE;
  }
  $key = $export['primary key'];
  if ($object->export_type & EXPORT_IN_DATABASE) {

    // Existing record.
    $update = array(
      $key,
    );
  }
  else {

    // New record.
    $update = array();
    $object->export_type = EXPORT_IN_DATABASE;
  }
  $result = drupal_write_record($table, $object, $update);
  if (empty($object->dont_log)) {
    $log = $object
      ->startLog(uniqid($object->name, TRUE), 'modification', ULTIMATE_CRON_LOG_TYPE_ADMIN);
    $log
      ->log($object->name, 'Job modified by ' . $log
      ->formatUser(), array(), WATCHDOG_INFO);
    $log
      ->finish();
  }
  return $result;
}