ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLoggerCronCleanErrorFiles Class Reference
+ Inheritance diagram for ilLoggerCronCleanErrorFiles:
+ Collaboration diagram for ilLoggerCronCleanErrorFiles:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 run ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
- 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...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. 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...
 

Data Fields

const DEFAULT_VALUE_OLDER_THAN = 31
 
- 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

 readLogDir ($path)
 
 deleteFile ($path)
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Detailed Description

Definition at line 13 of file class.ilLoggerCronCleanErrorFiles.php.

Constructor & Destructor Documentation

◆ __construct()

ilLoggerCronCleanErrorFiles::__construct ( )

Definition at line 17 of file class.ilLoggerCronCleanErrorFiles.php.

References $DIC, $lng, ilLoggingErrorSettings\getInstance(), and settings().

18  {
19  global $DIC;
20 
21  $lng = $DIC['lng'];
22 
23  $this->lng = $lng;
24  $this->lng->loadLanguageModule("logging");
25  $this->settings = new ilSetting('log');
26  $this->error_settings = ilLoggingErrorSettings::getInstance();
27  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
$lng
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilLoggerCronCleanErrorFiles::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Definition at line 150 of file class.ilLoggerCronCleanErrorFiles.php.

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\allowDecimals(), and settings().

151  {
152  $offset = $this->settings->get('clear_older_then');
153  if (!$offset) {
154  $offset = self::DEFAULT_VALUE_OLDER_THAN;
155  }
156  $clear_older_then = new ilNumberInputGUI($this->lng->txt('frm_clear_older_then'), 'clear_older_then');
157  $clear_older_then->allowDecimals(false);
158  $clear_older_then->setMinValue(1, true);
159  $clear_older_then->setValue($offset);
160  $clear_older_then->setInfo($this->lng->txt('frm_clear_older_then_info'));
161 
162  $a_form->addItem($clear_older_then);
163  }
settings()
Definition: settings.php:2
addItem($a_item)
Add Item (Property, SectionHeader).
allowDecimals($a_value)
Toggle Decimals.
This class represents a number property in a property form.
+ Here is the call graph for this function:

◆ deleteFile()

ilLoggerCronCleanErrorFiles::deleteFile (   $path)
protected

Definition at line 142 of file class.ilLoggerCronCleanErrorFiles.php.

References $path.

Referenced by run().

143  {
144  unlink($path);
145  }
$path
Definition: aliased.php:25
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLoggerCronCleanErrorFiles::getDefaultScheduleType ( )

Definition at line 56 of file class.ilLoggerCronCleanErrorFiles.php.

57  {
58  return self::SCHEDULE_TYPE_IN_DAYS;
59  }

◆ getDefaultScheduleValue()

ilLoggerCronCleanErrorFiles::getDefaultScheduleValue ( )

Definition at line 64 of file class.ilLoggerCronCleanErrorFiles.php.

65  {
66  return 10;
67  }

◆ getDescription()

ilLoggerCronCleanErrorFiles::getDescription ( )

Definition at line 48 of file class.ilLoggerCronCleanErrorFiles.php.

49  {
50  return $this->lng->txt("log_error_file_cleanup_info");
51  }

◆ getId()

ilLoggerCronCleanErrorFiles::getId ( )

Definition at line 32 of file class.ilLoggerCronCleanErrorFiles.php.

33  {
34  return "log_error_file_cleanup";
35  }

◆ getTitle()

ilLoggerCronCleanErrorFiles::getTitle ( )

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

41  {
42  return $this->lng->txt("log_error_file_cleanup_title");
43  }

◆ hasAutoActivation()

ilLoggerCronCleanErrorFiles::hasAutoActivation ( )

Definition at line 72 of file class.ilLoggerCronCleanErrorFiles.php.

73  {
74  return false;
75  }

◆ hasCustomSettings()

ilLoggerCronCleanErrorFiles::hasCustomSettings ( )

Definition at line 88 of file class.ilLoggerCronCleanErrorFiles.php.

89  {
90  return true;
91  }

◆ hasFlexibleSchedule()

ilLoggerCronCleanErrorFiles::hasFlexibleSchedule ( )

Definition at line 80 of file class.ilLoggerCronCleanErrorFiles.php.

81  {
82  return true;
83  }

◆ readLogDir()

ilLoggerCronCleanErrorFiles::readLogDir (   $path)
protected

Definition at line 127 of file class.ilLoggerCronCleanErrorFiles.php.

References $path, and $ret.

Referenced by run().

128  {
129  $ret = array();
130 
131  $folder = dir($path);
132  while ($file_name = $folder->read()) {
133  if (filetype($path . "/" . $file_name) != "dir") {
134  $ret[] = $file_name;
135  }
136  }
137  $folder->close();
138 
139  return $ret;
140  }
$path
Definition: aliased.php:25
$ret
Definition: parser.php:6
+ Here is the caller graph for this function:

◆ run()

ilLoggerCronCleanErrorFiles::run ( )

Definition at line 96 of file class.ilLoggerCronCleanErrorFiles.php.

References $files, $result, ilDateTime\DAY, deleteFile(), IL_CAL_DATE, readLogDir(), settings(), and ilCronJobResult\STATUS_OK.

97  {
98  $result = new ilCronJobResult();
99  $folder = $this->error_settings->folder();
100  if (!is_dir($folder)) {
102  $result->setMessage($this->lng->txt("log_error_path_not_configured_or_wrong"));
103  return $result;
104  }
105 
106  $offset = $this->settings->get('clear_older_then');
107  if (!$offset) {
108  $offset = self::DEFAULT_VALUE_OLDER_THAN;
109  }
110 
111  $files = $this->readLogDir($folder);
112  $delete_date = new ilDateTime(date("Y-m-d"), IL_CAL_DATE);
113  $delete_date->increment(ilDateTime::DAY, (-1 * $offset));
114 
115  foreach ($files as $file) {
116  $file_date = date("Y-m-d", filemtime($this->error_settings->folder() . "/" . $file));
117 
118  if ($file_date <= $delete_date->get(IL_CAL_DATE)) {
119  $this->deleteFile($this->error_settings->folder() . "/" . $file);
120  }
121  }
122 
124  return $result;
125  }
settings()
Definition: settings.php:2
$files
Definition: metarefresh.php:49
$result
Date and time handling
const IL_CAL_DATE
Cron job result data container.
+ Here is the call graph for this function:

◆ saveCustomSettings()

ilLoggerCronCleanErrorFiles::saveCustomSettings ( ilPropertyFormGUI  $a_form)
Parameters
ilPropertyFormGUI$a_form
Returns
bool

Definition at line 169 of file class.ilLoggerCronCleanErrorFiles.php.

References ilPropertyFormGUI\getInput(), and settings().

170  {
171  $this->settings->set('clear_older_then', $a_form->getInput('clear_older_then'));
172  return true;
173  }
settings()
Definition: settings.php:2
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

Field Documentation

◆ DEFAULT_VALUE_OLDER_THAN

const ilLoggerCronCleanErrorFiles::DEFAULT_VALUE_OLDER_THAN = 31

Definition at line 15 of file class.ilLoggerCronCleanErrorFiles.php.


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