ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLearningModuleCronLinkCheck.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "Services/Cron/classes/class.ilCronJob.php";
5 
15 {
19  protected $lng;
20 
24  protected $log;
25 
29  protected $db;
30 
31 
35  public function __construct()
36  {
37  global $DIC;
38 
39  $this->lng = $DIC->language();
40  $this->log = $DIC["ilLog"];
41  $this->db = $DIC->database();
42  }
43 
44  public function getId()
45  {
46  return "lm_link_check";
47  }
48 
49  public function getTitle()
50  {
51  $lng = $this->lng;
52 
53  return $lng->txt("check_link");
54  }
55 
56  public function getDescription()
57  {
58  $lng = $this->lng;
59 
60  return $lng->txt("check_link_desc");
61  }
62 
63  public function getDefaultScheduleType()
64  {
65  return self::SCHEDULE_TYPE_DAILY;
66  }
67 
68  public function getDefaultScheduleValue()
69  {
70  return;
71  }
72 
73  public function hasAutoActivation()
74  {
75  return false;
76  }
77 
78  public function hasFlexibleSchedule()
79  {
80  return false;
81  }
82 
83  public function run()
84  {
86  $ilDB = $this->db;
87 
89 
90  include_once'./Services/LinkChecker/classes/class.ilLinkChecker.php';
91 
92  $link_checker = new ilLinkChecker($ilDB);
93  $link_checker->setMailStatus(true);
94 
95  $link_checker->checkLinks();
96 
97  $counter = 0;
98  foreach ($link_checker->getLogMessages() as $message) {
99  $ilLog->write($message);
100  $counter++;
101  }
102 
103  if ($counter) {
104  $status = ilCronJobResult::STATUS_OK;
105  }
106  $result = new ilCronJobResult();
107  $result->setStatus($status);
108  return $result;
109  }
110 }
$result
global $DIC
Definition: saml.php:7
Cron job application base class.
class for checking external links in page objects Normally used in Cron jobs, but should be extensibl...
$counter
catch(Exception $e) $message
global $ilDB
Cron job result data container.