You are here

function workbench_scheduler_load_node_schedule in Workbench Scheduler 7.2

Same name and namespace in other branches
  1. 7 workbench_scheduler.module \workbench_scheduler_load_node_schedule()

Retrieves schedule data for a given node revision.

Parameters

int $nid: Node id.

int $vid: Revision id.

Return value

mixed Return an array of scheduler data for the node, or boolean TRUE if there is no schedule for this node.

3 calls to workbench_scheduler_load_node_schedule()
workbench_scheduler_admin_edit_revision_schedule in ./workbench_scheduler.admin.inc
Form to edit the schedule for an existing node revision.
workbench_scheduler_admin_manage_node_schedules in ./workbench_scheduler.admin.inc
Tableselect form for current schedules applied to a node.
workbench_scheduler_node_load in ./workbench_scheduler.module
Implements hook_node_load().

File

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

Code

function workbench_scheduler_load_node_schedule($nid, $vid = NULL) {

  // Select from the workbench_scheduler_nodes table.
  $node_schedule_query = db_select('workbench_scheduler_nodes', 'wsn');

  // Retrieve the node start and end date.
  $node_schedule_query
    ->fields('wsn', array(
    'nid',
    'vid',
    'sid',
    'date',
    'completed',
  ));

  // WHERE node id matches this node id.
  $node_schedule_query
    ->condition('wsn.nid', $nid);

  // AND node revision id matches this node revision.
  if ($vid) {
    $node_schedule_query
      ->condition('wsn.vid', $vid);
  }

  // Only return the first result.
  $node_schedule_query
    ->orderby('wsn.date', 'ASC');
  $node_schedule = $node_schedule_query
    ->execute();

  // Was data successfully retrieve?
  if ($node_schedule
    ->rowCount()) {
    $schedule = array();
    while ($data = $node_schedule
      ->fetchObject()) {
      $schedule[] = $data;
    }
    return $schedule;
  }

  // Return a boolean false if nothing is retrieved.
  return FALSE;
}