ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
5 include_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  {
39  return self::SCHEDULE_TYPE_DAILY;
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 
78  $result = new ilCronJobResult();
79  $result->setStatus($status);
80 
81  return $result;
82  }
83 }
const IL_CAL_DATETIME
$result
global $DIC
Definition: saml.php:7
Cron job application base class.
const IL_CAL_UNIX
Date and time handling
global $lng
Definition: privfeed.php:17
global $ilDB
Cron job result data container.
$handler