| Server IP : 195.134.90.114 / Your IP : 216.73.216.86 Web Server : Apache/2.4.58 System : Linux nepub 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/public_html/lib/pkp/classes/scheduledTask/ |
Upload File : |
<?php
/**
* @defgroup scheduledTask Scheduled Tasks
* Implements a scheduled task mechanism allowing for the periodic execution
* of maintenance tasks, notification, etc.
*/
/**
* @file classes/scheduledTask/ScheduledTaskDAO.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ScheduledTaskDAO
* @ingroup scheduledTask
* @see ScheduledTask
*
* @brief Operations for retrieving and modifying Scheduled Task data.
*/
import('lib.pkp.classes.scheduledTask.ScheduledTask');
class ScheduledTaskDAO extends DAO {
/**
* Get the last time a scheduled task was executed.
* @param $className string
* @return int
*/
function getLastRunTime($className) {
$result = $this->retrieve(
'SELECT last_run FROM scheduled_tasks WHERE class_name = ?',
[$className]
);
$row = $result->current();
return $row && $row->last_run ? strtotime($this->datetimeFromDB($row->last_run)) : 0;
}
/**
* Update a scheduled task's last run time.
* @param $className string
* @param $timestamp int optional, if omitted the current time is used.
* @return int
*/
function updateLastRunTime($className, $timestamp = null) {
$result = $this->retrieve('SELECT COUNT(*) AS row_count FROM scheduled_tasks WHERE class_name = ?', [$className]);
$row = $result->current();
if ($row && $row->row_count != 0) {
if (isset($timestamp)) return $this->update('UPDATE scheduled_tasks SET last_run = ' . $this->datetimeToDB($timestamp) . ' WHERE class_name = ?', [$className]);
return $this->update( 'UPDATE scheduled_tasks SET last_run = NOW() WHERE class_name = ?', [$className]);
} else {
if (isset($timestamp)) return $this->update(
sprintf('INSERT INTO scheduled_tasks (class_name, last_run) VALUES (?, %s)', $this->datetimeToDB($timestamp)),
[$className]
);
return $this->update('INSERT INTO scheduled_tasks (class_name, last_run) VALUES (?, NOW())', [$className]);
}
}
}