You are here

function workbench_scheduler_schedules_action in Workbench Scheduler 7

Same name and namespace in other branches
  1. 7.2 actions/workbench_scheduler.action.inc \workbench_scheduler_schedules_action()

Implements the action that is applied to the revisions.

Parameters

$entity:

array $context:

File

actions/workbench_scheduler.action.inc, line 151

Code

function workbench_scheduler_schedules_action(&$entity, $context = array()) {

  // Only save schedules for content that supports them.
  $types_moderated = workbench_moderation_moderate_node_types();
  $is_moderated = in_array($entity->type, $types_moderated) ? TRUE : FALSE;
  $schedules = workbench_scheduler_load_type_schedules($entity->type);
  if ($is_moderated && !empty($schedules)) {
    $entity->workbench_schedule->sid = $context['workbench_scheduler_sid'];
    if (isset($context['workbench_scheduler_start_date'])) {
      $entity->workbench_schedule->start_date = strtotime($context['workbench_scheduler_start_date']);
    }
    if (isset($context['workbench_scheduler_end_date'])) {
      $entity->workbench_schedule->end_date = strtotime($context['workbench_scheduler_end_date']);
    }

    // Change vid to latest.
    $live_revision = workbench_moderation_node_current_load($entity);
    $entity->vid = $live_revision->vid;
  }
}