ILIAS  release_8 Revision v8.24
ilLoggerCronCleanErrorFiles Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilLoggerCronCleanErrorFiles:
+ Collaboration diagram for ilLoggerCronCleanErrorFiles:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 run ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?int $a_type, ?int $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...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Protected Member Functions

 readLogDir (string $path)
 
 deleteFile (string $path)
 

Protected Attributes

const DEFAULT_VALUE_OLDER_THAN = 31
 
ilLanguage $lng
 
ilSetting $settings
 
ilLoggingErrorSettings $error_settings
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Constructor & Destructor Documentation

◆ __construct()

ilLoggerCronCleanErrorFiles::__construct ( )

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

30 {
31 global $DIC;
32
33 $this->lng = $DIC->language();
34 $this->lng->loadLanguageModule("logging");
35 $this->settings = new ilSetting('log');
36 $this->error_settings = ilLoggingErrorSettings::getInstance();
37 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilLoggerCronCleanErrorFiles::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Reimplemented from ilCronJob.

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

132 : void
133 {
134 $offset = $this->settings->get('clear_older_then', '');
135 if (!$offset) {
136 $offset = (string) self::DEFAULT_VALUE_OLDER_THAN;
137 }
138
139 $clear_older_then = new ilNumberInputGUI($this->lng->txt('frm_clear_older_then'), 'clear_older_then');
140 $clear_older_then->allowDecimals(false);
141 $clear_older_then->setMinValue(1, true);
142 $clear_older_then->setValue($offset);
143 $clear_older_then->setInfo($this->lng->txt('frm_clear_older_then_info'));
144
145 $a_form->addItem($clear_older_then);
146 }
This class represents a number property in a property form.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ deleteFile()

ilLoggerCronCleanErrorFiles::deleteFile ( string  $path)
protected

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

127 : void
128 {
129 unlink($path);
130 }
$path
Definition: ltiservices.php:32

References $path.

Referenced by run().

+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLoggerCronCleanErrorFiles::getDefaultScheduleType ( )

Reimplemented from ilCronJob.

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

54 : int
55 {
57 }
const SCHEDULE_TYPE_IN_DAYS
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_IN_DAYS.

◆ getDefaultScheduleValue()

ilLoggerCronCleanErrorFiles::getDefaultScheduleValue ( )

Reimplemented from ilCronJob.

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

59 : int
60 {
61 return 10;
62 }

◆ getDescription()

ilLoggerCronCleanErrorFiles::getDescription ( )

Reimplemented from ilCronJob.

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilLoggerCronCleanErrorFiles::getId ( )

Reimplemented from ilCronJob.

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

39 : string
40 {
41 return "log_error_file_cleanup";
42 }

◆ getTitle()

ilLoggerCronCleanErrorFiles::getTitle ( )

Reimplemented from ilCronJob.

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

44 : string
45 {
46 return $this->lng->txt("log_error_file_cleanup_title");
47 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ hasAutoActivation()

ilLoggerCronCleanErrorFiles::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ilCronJob.

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

64 : bool
65 {
66 return false;
67 }

◆ hasCustomSettings()

ilLoggerCronCleanErrorFiles::hasCustomSettings ( )

Reimplemented from ilCronJob.

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

74 : bool
75 {
76 return true;
77 }

◆ hasFlexibleSchedule()

ilLoggerCronCleanErrorFiles::hasFlexibleSchedule ( )

Reimplemented from ilCronJob.

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

69 : bool
70 {
71 return true;
72 }

◆ readLogDir()

ilLoggerCronCleanErrorFiles::readLogDir ( string  $path)
protected

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

112 : array
113 {
114 $ret = [];
115
116 $folder = dir($path);
117 while ($file_name = $folder->read()) {
118 if (filetype($path . "/" . $file_name) != "dir") {
119 $ret[] = $file_name;
120 }
121 }
122 $folder->close();
123
124 return $ret;
125 }

References $path.

Referenced by run().

+ Here is the caller graph for this function:

◆ run()

ilLoggerCronCleanErrorFiles::run ( )

Reimplemented from ilCronJob.

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

80 {
81 $result = new ilCronJobResult();
82 $folder = $this->error_settings->folder();
83 if (!is_dir($folder)) {
84 $result->setStatus(ilCronJobResult::STATUS_OK);
85 $result->setMessage($this->lng->txt("log_error_path_not_configured_or_wrong"));
86 return $result;
87 }
88
89 $offset = $this->settings->get('clear_older_then', '');
90 if ($offset) {
91 $offset = (int) $offset;
92 } else {
94 }
95
96 $files = $this->readLogDir($folder);
97 $delete_date = new ilDateTime(date("Y-m-d"), IL_CAL_DATE);
98 $delete_date->increment(ilDateTime::DAY, (-1 * $offset));
99
100 foreach ($files as $file) {
101 $file_date = date("Y-m-d", filemtime($this->error_settings->folder() . "/" . $file));
102
103 if ($file_date <= $delete_date->get(IL_CAL_DATE)) {
104 $this->deleteFile($this->error_settings->folder() . "/" . $file);
105 }
106 }
107
108 $result->setStatus(ilCronJobResult::STATUS_OK);
109 return $result;
110 }
const IL_CAL_DATE
@classDescription Date and time handling

References ilDateTime\DAY, DEFAULT_VALUE_OLDER_THAN, deleteFile(), IL_CAL_DATE, ILIAS\Repository\int(), ILIAS\Repository\lng(), readLogDir(), ILIAS\Repository\settings(), and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilLoggerCronCleanErrorFiles::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Reimplemented from ilCronJob.

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

148 : bool
149 {
150 $threshold = $a_form->getInput('clear_older_then');
151 if ((string) $threshold === '') {
152 $this->settings->delete('clear_older_then');
153 } else {
154 $this->settings->set('clear_older_then', (string) ((int) $a_form->getInput('clear_older_then')));
155 }
156
157 return true;
158 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

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

+ Here is the call graph for this function:

Field Documentation

◆ $error_settings

ilLoggingErrorSettings ilLoggerCronCleanErrorFiles::$error_settings
protected

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

◆ $lng

ilLanguage ilLoggerCronCleanErrorFiles::$lng
protected

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

◆ $settings

ilSetting ilLoggerCronCleanErrorFiles::$settings
protected

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

◆ DEFAULT_VALUE_OLDER_THAN

const ilLoggerCronCleanErrorFiles::DEFAULT_VALUE_OLDER_THAN = 31
protected

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

Referenced by run().


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