ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilWebResourceCronLinkCheck Class Reference
+ Inheritance diagram for ilWebResourceCronLinkCheck:
+ Collaboration diagram for ilWebResourceCronLinkCheck:

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 run ()
 
 __getCheckPeriod ()
 
 activationWasToggled ($a_currently_active)
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Detailed Description

Definition at line 14 of file class.ilWebResourceCronLinkCheck.php.

Member Function Documentation

◆ __getCheckPeriod()

ilWebResourceCronLinkCheck::__getCheckPeriod ( )

Definition at line 105 of file class.ilWebResourceCronLinkCheck.php.

References ilCronJob\getScheduleType().

Referenced by run().

106  {
107  switch ($this->getScheduleType()) {
108  case self::SCHEDULE_TYPE_DAILY:
109  $period = 24 * 60 * 60;
110  break;
111 
112  case self::SCHEDULE_TYPE_WEEKLY:
113  $period = 7 * 24 * 60 * 60;
114  break;
115 
116  case self::SCHEDULE_TYPE_MONTHLY:
117  $period = 30 * 7 * 24 * 60 * 60;
118  break;
119 
120  case self::SCHEDULE_TYPE_QUARTERLY:
121  $period = 3 * 30 * 7 * 24 * 60 * 60;
122  break;
123 
124  default:
125  $period = 0;
126  }
127  return $period;
128  }
getScheduleType()
Get current schedule type (if flexible)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ activationWasToggled()

ilWebResourceCronLinkCheck::activationWasToggled (   $a_currently_active)

Definition at line 130 of file class.ilWebResourceCronLinkCheck.php.

References $ilSetting.

131  {
132  global $ilSetting;
133 
134  // propagate cron-job setting to object setting
135  $ilSetting->set("cron_web_resource_check", (bool) $a_currently_active);
136  }
global $ilSetting
Definition: privfeed.php:17

◆ getDefaultScheduleType()

ilWebResourceCronLinkCheck::getDefaultScheduleType ( )

Definition at line 35 of file class.ilWebResourceCronLinkCheck.php.

36  {
37  return self::SCHEDULE_TYPE_DAILY;
38  }

◆ getDefaultScheduleValue()

ilWebResourceCronLinkCheck::getDefaultScheduleValue ( )

Definition at line 40 of file class.ilWebResourceCronLinkCheck.php.

41  {
42  return;
43  }

◆ getDescription()

ilWebResourceCronLinkCheck::getDescription ( )

Definition at line 28 of file class.ilWebResourceCronLinkCheck.php.

References $lng.

29  {
30  global $lng;
31 
32  return $lng->txt("check_web_resources_desc");
33  }
global $lng
Definition: privfeed.php:17

◆ getId()

ilWebResourceCronLinkCheck::getId ( )

Definition at line 16 of file class.ilWebResourceCronLinkCheck.php.

17  {
18  return "webr_link_check";
19  }

◆ getTitle()

ilWebResourceCronLinkCheck::getTitle ( )

Definition at line 21 of file class.ilWebResourceCronLinkCheck.php.

References $lng.

22  {
23  global $lng;
24 
25  return $lng->txt("check_web_resources");
26  }
global $lng
Definition: privfeed.php:17

◆ hasAutoActivation()

ilWebResourceCronLinkCheck::hasAutoActivation ( )

Definition at line 45 of file class.ilWebResourceCronLinkCheck.php.

46  {
47  return false;
48  }

◆ hasFlexibleSchedule()

ilWebResourceCronLinkCheck::hasFlexibleSchedule ( )

Definition at line 50 of file class.ilWebResourceCronLinkCheck.php.

51  {
52  return true;
53  }

◆ run()

ilWebResourceCronLinkCheck::run ( )

Definition at line 55 of file class.ilWebResourceCronLinkCheck.php.

References $counter, $ilDB, $ilLog, $ilUser, $message, $result, __getCheckPeriod(), ilUtil\_getObjectsByOperations(), ilObjectFactory\getInstanceByRefId(), ilCronJobResult\STATUS_NO_ACTION, ilCronJobResult\STATUS_OK, and time.

56  {
57  global $ilLog, $ilUser, $ilDB;
58 
60 
61  include_once'./Services/LinkChecker/classes/class.ilLinkChecker.php';
62 
63  $counter = 0;
64  foreach (ilUtil::_getObjectsByOperations('webr', 'write', $ilUser->getId(), -1) as $node) {
65  if (!is_object($tmp_webr = ilObjectFactory::getInstanceByRefId($node, false))) {
66  continue;
67  }
68 
69  $tmp_webr->initLinkResourceItemsObject();
70 
71  // Set all link to valid. After check invalid links will be set to invalid
72 
73  $link_checker = new ilLinkChecker($ilDB);
74  $link_checker->setMailStatus(true);
75  $link_checker->setCheckPeriod($this->__getCheckPeriod());
76  $link_checker->setObjId($tmp_webr->getId());
77 
78 
79  $tmp_webr->items_obj->updateValidByCheck($this->__getCheckPeriod());
80  foreach ($link_checker->checkWebResourceLinks() as $invalid) {
81  $tmp_webr->items_obj->readItem($invalid['page_id']);
82  $tmp_webr->items_obj->setActiveStatus(false);
83  $tmp_webr->items_obj->setValidStatus(false);
84  $tmp_webr->items_obj->setDisableCheckStatus(true);
85  $tmp_webr->items_obj->setLastCheckDate(time());
86  $tmp_webr->items_obj->update(false);
87  }
88 
89  $tmp_webr->items_obj->updateLastCheck($this->__getCheckPeriod());
90 
91  foreach ($link_checker->getLogMessages() as $message) {
92  $ilLog->write($message);
93  $counter++;
94  }
95  }
96 
97  if ($counter) {
99  }
100  $result = new ilCronJobResult();
101  $result->setStatus($status);
102  return $result;
103  }
$result
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive, instead it parses the serialized rbac_pa entries.
class for checking external links in page objects Normally used in Cron jobs, but should be extensibl...
$counter
catch(Exception $e) $message
$ilUser
Definition: imgupload.php:18
global $ilDB
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Cron job result data container.
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: