ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $lng;
22 
23  $lng->loadLanguageModule("bgtask");
24  return $lng->txt("bgtask_cron_gc_title");
25  }
26 
27  public function getDescription()
28  {
29  global $lng;
30 
31  $lng->loadLanguageModule("bgtask");
32  return $lng->txt("bgtask_cron_gc_desc");
33  }
34 
35  public function getDefaultScheduleType()
36  {
37  return self::SCHEDULE_TYPE_DAILY;
38  }
39 
40  public function getDefaultScheduleValue()
41  {
42  return;
43  }
44 
45  public function hasAutoActivation()
46  {
47  return false;
48  }
49 
50  public function hasFlexibleSchedule()
51  {
52  return true;
53  }
54 
55  public function run()
56  {
57  global $ilDB;
58 
60 
61  $cut = new ilDateTime(strtotime("-1day"), IL_CAL_UNIX);
62 
63  include_once "Services/BackgroundTask/classes/class.ilBackgroundTask.php";
64 
65  $set = $ilDB->query("SELECT id FROM ".ilBackgroundTask::DB_NAME.
66  " WHERE start_date <= ".$ilDB->quote($cut->get(IL_CAL_DATETIME), "text"));
67  while($row = $ilDB->fetchAssoc($set))
68  {
70 
71  $task = new ilBackgroundTask($row["id"]);
72  $handler = $task->getHandlerInstance();
73  $handler->deleteTaskAndFiles();
74  }
75 
76  $result = new ilCronJobResult();
77  $result->setStatus($status);
78 
79  return $result;
80  }
81 }
const IL_CAL_DATETIME
$result
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.