From: mjollnir_ <mjollnir_> Date: Mon, 11 Aug 2008 12:50:26 +0000 (+0000) Subject: MDL-15995 - portfolio cron. currently just cleans up any orphaned transfer data X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7e51bbcee9f6ba4e258a247c0b143835c65a5dcb;p=moodle.git MDL-15995 - portfolio cron. currently just cleans up any orphaned transfer data Later should be extended to add hooks in the plugins --- diff --git a/admin/cron.php b/admin/cron.php index f42273da81..770f158fed 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -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 diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index f21e9968c7..1c2f5b9955 100644 --- a/lib/portfoliolib.php +++ b/lib/portfoliolib.php @@ -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 +} + + ?>