You are here

function _workbench_scheduler_process_node_schedules in Workbench Scheduler 7.2

Fetches all active schedules.

2 calls to _workbench_scheduler_process_node_schedules()
workbench_scheduler_admin_manage_node_schedules in ./workbench_scheduler.admin.inc
Tableselect form for current schedules applied to a node.
workbench_scheduler_process_dates in ./workbench_scheduler.module
Run schedules

File

./workbench_scheduler.module, line 808
Content scheduling for Workbench.

Code

function _workbench_scheduler_process_node_schedules(&$node_schedules) {

  // If scheduled nodes are returned from the query.
  if (!empty($node_schedules)) {
    foreach ($node_schedules as $node_schedule) {
      $node_schedule->active = FALSE;

      // Getting the current revision.
      $node = node_load($node_schedule->nid);

      // If node schedule vid is the same as the current revision.
      $current_revision = $node_schedule->vid == $node->workbench_moderation['current']->vid;

      // If schedule is not completed.
      $not_completed = $node_schedule->completed == 0;

      // Set node property.
      $node_schedule->node = $node;

      // Load schedule data for developers.
      $node_schedule->schedule = workbench_scheduler_schedules_load($node_schedule->sid);

      // Checking to make sure node type supports schedules.
      $schedule_check = workbench_scheduler_type_schedules_load($node->type);
      $type_supported = !empty($schedule_check);
      if ($not_completed && $current_revision && $type_supported) {
        $node_schedule->active = TRUE;
      }

      // Is 'Run schedules on published revisions' enabled?
      if (variable_get('workbench_scheduler_settings_published_revisions')) {

        // If node schedule vid is the same as the published revision.
        if ($type_supported && !empty($node->workbench_moderation['published']) && $node->workbench_moderation['published']->vid == $node_schedule->vid) {
          $node_schedule->active = TRUE;
        }
      }

      // Allow modules to alter active schedules.
      drupal_alter('workbench_scheduler_process_node_schedule', $node_schedule);
    }
  }
}