MDL-15995 - portfolio cron. currently just cleans up any orphaned transfer data
Later should be extended to add hooks in the plugins
This commit is contained in:
@@ -252,6 +252,13 @@
|
||||
events_cron();
|
||||
mtrace('done.');
|
||||
|
||||
if ($CFG->portfolioenabled) {
|
||||
// Portfolio cron
|
||||
mtrace('Starting the portfolio cron...');
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
portfolio_cron();
|
||||
mtrace('done');
|
||||
}
|
||||
|
||||
/// Run all core cron jobs, but not every time since they aren't too important.
|
||||
/// These don't have a timer to reduce load, so we'll use a random number
|
||||
|
||||
@@ -2178,4 +2178,23 @@ function portfolio_handle_event($eventdata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* main portfolio cronjob
|
||||
*
|
||||
*/
|
||||
function portfolio_cron() {
|
||||
global $DB;
|
||||
|
||||
if ($expired = $DB->get_records_select('portfolio_tempdata', 'expirytime < ?', array(time()))) {
|
||||
foreach ($expired as $d) {
|
||||
$DB->delete_records('portfolio_tempdata', array('id' => $d->id));
|
||||
$fs = get_file_storage();
|
||||
$fs->delete_area_files(SYSCONTEXTID, 'portfolio_exporter', $d->id);
|
||||
}
|
||||
}
|
||||
|
||||
// @todo add hooks in the plugins
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user