Exemplo n.º 1
0
 protected function queueNext()
 {
     $time = time();
     $sql = "SELECT rowid, base, send_time FROM queue WHERE send_time>0 ORDER BY send_time, rowid LIMIT 1";
     if ($data = $this->db->query($sql)->fetchAll(PDO::FETCH_ASSOC)) {
         $data = $data[0];
         if ($data['send_time'] <= $time) {
             $sql = "UPDATE queue SET send_time=0\n                        WHERE rowid={$data['rowid']} AND send_time>0";
             if ($this->db->exec($sql)) {
                 tool_url::touch("{$data['base']}queue/pMail/{$data['rowid']}/" . $this->getToken());
             }
         } else {
             pTask::schedule(new pTask(array($this, 'control')), $data['send_time']);
         }
     }
 }
Exemplo n.º 2
0
 static function setup()
 {
     $db = new pTask();
     $db = $db->getPdoConnection();
     $zcache = $db->quote(PATCHWORK_ZCACHE);
     $sql = "DELETE FROM registry WHERE level=" . PATCHWORK_PATH_LEVEL . " AND zcache={$zcache}";
     $db->exec($sql);
     foreach (self::getCrontab() as $name => $task) {
         if (is_int($name)) {
             $name = array();
             $sql = get_class($task);
             while (false !== ($sql = get_parent_class($sql))) {
                 $name[] = $sql;
             }
             $name = md5(serialize(array($task, $name)));
         }
         $name = $db->quote($name);
         $sql = "DELETE FROM registry WHERE task_name={$name} AND level>=" . PATCHWORK_PATH_LEVEL . " AND zcache={$zcache}";
         $db->exec($sql);
         $id = pTask::schedule($task, $task->getNextRun());
         $sql = "INSERT INTO registry VALUES ({$id}, {$name}, " . PATCHWORK_PATH_LEVEL . ", {$zcache})";
         $db->exec($sql);
     }
 }
Exemplo n.º 3
0
 static final function schedule(self $task, $time = 0)
 {
     return $task->doSchedule($time);
 }
Exemplo n.º 4
0
 function __construct($crontab, $callback = false, $arguments = array())
 {
     $this->setCrontab($crontab);
     parent::__construct($callback, $arguments);
 }