/**
  * Delete all expired items.
  */
 public function execute()
 {
     global $DB;
     // Check if the course bin is disabled or there is no expiry time.
     $lifetime = get_config('tool_recyclebin', 'coursebinexpiry');
     if (!\tool_recyclebin\course_bin::is_enabled() || $lifetime <= 0) {
         return true;
     }
     // Get the items we can delete.
     $items = $DB->get_recordset_select('tool_recyclebin_course', 'timecreated <= :timecreated', array('timecreated' => time() - $lifetime));
     foreach ($items as $item) {
         mtrace("[tool_recyclebin] Deleting item '{$item->id}' from the course recycle bin ...");
         $bin = new \tool_recyclebin\course_bin($item->courseid);
         $bin->delete_item($item);
     }
     $items->close();
     return true;
 }
Example #2
0
/**
 * Hook called before we delete a course module.
 *
 * @param \stdClass $cm The course module record.
 */
function tool_recyclebin_pre_course_module_delete($cm)
{
    if (\tool_recyclebin\course_bin::is_enabled()) {
        $coursebin = new \tool_recyclebin\course_bin($cm->course);
        $coursebin->store_item($cm);
    }
}
Example #3
0
/**
 * Hook called to check whether async course module deletion should be performed or not.
 *
 * @return true if background deletion is required (is the recyclebin is enabled), false otherwise.
 */
function tool_recyclebin_course_module_background_deletion_recommended()
{
    if (\tool_recyclebin\course_bin::is_enabled()) {
        return true;
    }
}