poll_cron

Versions
4.6 – 7
poll_cron()

Implementation of hook_cron().

Closes polls that have exceeded their allowed runtime.

Code

modules/poll.module, line 76

<?php
function poll_cron() {
  $result = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < '. time() .' AND p.active = 1 AND p.runtime != 0');
  while ($poll = db_fetch_object($result)) {
    db_query("UPDATE {poll} SET active = 0 WHERE nid = %d", $poll->nid);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.