Later should be extended to add hooks in the plugins
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
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
+}
+
+
?>