ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBackgroundTaskCronGarbageCollection.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once "Services/Cron/classes/class.ilCronJob.php";
6
13{
14 public function getId()
15 {
16 return "bgtsk_gc";
17 }
18
19 public function getTitle()
20 {
21 global $DIC;
22 $lng = $DIC['lng'];
23
24 $lng->loadLanguageModule("bgtask");
25 return $lng->txt("bgtask_cron_gc_title");
26 }
27
28 public function getDescription()
29 {
30 global $DIC;
31 $lng = $DIC['lng'];
32
33 $lng->loadLanguageModule("bgtask");
34 return $lng->txt("bgtask_cron_gc_desc");
35 }
36
37 public function getDefaultScheduleType()
38 {
40 }
41
42 public function getDefaultScheduleValue()
43 {
44 return;
45 }
46
47 public function hasAutoActivation()
48 {
49 return false;
50 }
51
52 public function hasFlexibleSchedule()
53 {
54 return true;
55 }
56
57 public function run()
58 {
59 global $DIC;
60 $ilDB = $DIC['ilDB'];
61
63
64 $cut = new ilDateTime(strtotime("-1day"), IL_CAL_UNIX);
65
66 include_once "Services/BackgroundTask/classes/class.ilBackgroundTask.php";
67
68 $set = $ilDB->query("SELECT id FROM " . ilBackgroundTask::DB_NAME .
69 " WHERE start_date <= " . $ilDB->quote($cut->get(IL_CAL_DATETIME), "text"));
70 while ($row = $ilDB->fetchAssoc($set)) {
72
73 $task = new ilBackgroundTask($row["id"]);
74 $handler = $task->getHandlerInstance();
75 $handler->deleteTaskAndFiles();
76 }
77
79 $result->setStatus($status);
80
81 return $result;
82 }
83}
$result
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_DAILY
@classDescription Date and time handling
$row
$handler
global $DIC
Definition: saml.php:7
$lng
global $ilDB