ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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 ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

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 25 of file class.ilLoggerCronCleanErrorFiles.php.

Constructor & Destructor Documentation

◆ __construct()

ilLoggerCronCleanErrorFiles::__construct ( )

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

34 {
35 global $DIC;
36
37 $this->lng = $DIC->language();
38 $this->lng->loadLanguageModule("logging");
39 $this->settings = new ilSetting('log');
40 $this->error_settings = ilLoggingErrorSettings::getInstance();
41 }
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26

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)

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

136 : void
137 {
138 $offset = $this->settings->get('clear_older_then', '');
139 if (!$offset) {
140 $offset = (string) self::DEFAULT_VALUE_OLDER_THAN;
141 }
142
143 $clear_older_then = new ilNumberInputGUI($this->lng->txt('frm_clear_older_then'), 'clear_older_then');
144 $clear_older_then->allowDecimals(false);
145 $clear_older_then->setMinValue(1, true);
146 $clear_older_then->setValue($offset);
147 $clear_older_then->setInfo($this->lng->txt('frm_clear_older_then_info'));
148
149 $a_form->addItem($clear_older_then);
150 }
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 131 of file class.ilLoggerCronCleanErrorFiles.php.

131 : void
132 {
133 unlink($path);
134 }
$path
Definition: ltiservices.php:30

References $path.

Referenced by run().

+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLoggerCronCleanErrorFiles::getDefaultScheduleType ( )

Reimplemented from ILIAS\Cron\CronJob.

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

59 {
60 return JobScheduleType::IN_DAYS;
61 }

◆ getDefaultScheduleValue()

ilLoggerCronCleanErrorFiles::getDefaultScheduleValue ( )

Reimplemented from ILIAS\Cron\CronJob.

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

63 : int
64 {
65 return 10;
66 }

◆ getDescription()

ilLoggerCronCleanErrorFiles::getDescription ( )

Reimplemented from ILIAS\Cron\CronJob.

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

53 : string
54 {
55 return $this->lng->txt("log_error_file_cleanup_info");
56 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilLoggerCronCleanErrorFiles::getId ( )

Reimplemented from ILIAS\Cron\CronJob.

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

43 : string
44 {
45 return "log_error_file_cleanup";
46 }

◆ getTitle()

ilLoggerCronCleanErrorFiles::getTitle ( )

Reimplemented from ILIAS\Cron\CronJob.

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

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

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 ILIAS\Cron\CronJob.

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

68 : bool
69 {
70 return false;
71 }

◆ hasCustomSettings()

ilLoggerCronCleanErrorFiles::hasCustomSettings ( )

Reimplemented from ILIAS\Cron\CronJob.

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

78 : bool
79 {
80 return true;
81 }

◆ hasFlexibleSchedule()

ilLoggerCronCleanErrorFiles::hasFlexibleSchedule ( )

Reimplemented from ILIAS\Cron\CronJob.

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

73 : bool
74 {
75 return true;
76 }

◆ readLogDir()

ilLoggerCronCleanErrorFiles::readLogDir ( string  $path)
protected

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

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

References $path.

Referenced by run().

+ Here is the caller graph for this function:

◆ run()

ilLoggerCronCleanErrorFiles::run ( )

Reimplemented from ILIAS\Cron\CronJob.

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

83 : JobResult
84 {
85 $result = new JobResult();
86 $folder = $this->error_settings->folder();
87 if (!is_dir($folder)) {
88 $result->setStatus(JobResult::STATUS_OK);
89 $result->setMessage($this->lng->txt("log_error_path_not_configured_or_wrong"));
90 return $result;
91 }
92
93 $offset = $this->settings->get('clear_older_then', '');
94 if ($offset) {
95 $offset = (int) $offset;
96 } else {
98 }
99
100 $files = $this->readLogDir($folder);
101 $delete_date = new ilDateTime(date("Y-m-d"), IL_CAL_DATE);
102 $delete_date->increment(ilDateTime::DAY, (-1 * $offset));
103
104 foreach ($files as $file) {
105 $file_date = date("Y-m-d", filemtime($this->error_settings->folder() . "/" . $file));
106
107 if ($file_date <= $delete_date->get(IL_CAL_DATE)) {
108 $this->deleteFile($this->error_settings->folder() . "/" . $file);
109 }
110 }
111
112 $result->setStatus(JobResult::STATUS_OK);
113 return $result;
114 }
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(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilLoggerCronCleanErrorFiles::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

152 : bool
153 {
154 $threshold = $a_form->getInput('clear_older_then');
155 if ((string) $threshold === '') {
156 $this->settings->delete('clear_older_then');
157 } else {
158 $this->settings->set('clear_older_then', (string) ((int) $a_form->getInput('clear_older_then')));
159 }
160
161 return true;
162 }
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 31 of file class.ilLoggerCronCleanErrorFiles.php.

◆ $lng

ilLanguage ilLoggerCronCleanErrorFiles::$lng
protected

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

◆ $settings

ilSetting ilLoggerCronCleanErrorFiles::$settings
protected

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

◆ DEFAULT_VALUE_OLDER_THAN

const ilLoggerCronCleanErrorFiles::DEFAULT_VALUE_OLDER_THAN = 31
protected

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

Referenced by run().


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