You are here

function revisioning_scheduler_revisionapi in Revisioning 6.3

Same name and namespace in other branches
  1. 8 revisioning_scheduler/revisioning_scheduler.module \revisioning_scheduler_revisionapi()
  2. 7 revisioning_scheduler/revisioning_scheduler.module \revisioning_scheduler_revisionapi()

Implementation of hook_revisionapi Makes sure article is able to be published according to its timestamp.

@author Adam Bramley <adam@catalyst.net.nz>

File

revisioning_scheduler/revisioning_scheduler.module, line 82
Allows for revisions to be published at a specified time and date.

Code

function revisioning_scheduler_revisionapi($op, $node) {
  switch ($op) {
    case 'pre publish':
    case 'post revert':
      $vid = $node->vid;
      $nid = $node->nid;
      $uid = $node->uid;
      $date = $_POST['revisioning_scheduler_date'];
      $time = $_POST['revisioning_scheduler_time'];
      $timeofday = strtotime($date . $time);
      revisioning_scheduler_check($vid, $nid);
      if ($timeofday > time()) {
        $data = array(
          'revision_vid' => $vid,
          'revision_nid' => $nid,
          'revision_uid' => $uid,
          'revision_date' => strtotime($date . $time),
        );
        drupal_write_record('revisioning_scheduler', $data);
        drupal_set_message(t('Revision has been set to be published at %time on %date', array(
          '%time' => $time,
          '%date' => $date,
        )));
        return FALSE;
      }
      break;

    // Node revision is being deleted. If it is scheduled for publishing,
    // remove the scheduler entry.
    case 'pre delete':
      revisioning_scheduler_check($node->vid, $node->nid);
      break;
  }
}