]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15995 - portfolio cron. currently just cleans up any orphaned transfer data
authormjollnir_ <mjollnir_>
Mon, 11 Aug 2008 12:50:26 +0000 (12:50 +0000)
committermjollnir_ <mjollnir_>
Mon, 11 Aug 2008 12:50:26 +0000 (12:50 +0000)
Later should be extended to add hooks in the plugins

admin/cron.php
lib/portfoliolib.php

index f42273da81067fe6e55560b23e78f331a7ce5107..770f158fed89a54747f426009d8dff76b3a8d70b 100644 (file)
     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 
index f21e9968c7db125cd82a7d60a93419e41c7569e8..1c2f5b99550b1ffd989386423b8a9f7e3e2d2287 100644 (file)
@@ -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
+}
+
+
 ?>