ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 
 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, ?CronJobScheduleType $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 (?CronJobScheduleType $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
CronJobScheduleType $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 23 of file class.ilLoggerCronCleanErrorFiles.php.

Constructor & Destructor Documentation

◆ __construct()

ilLoggerCronCleanErrorFiles::__construct ( )

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

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

32  {
33  global $DIC;
34 
35  $this->lng = $DIC->language();
36  $this->lng->loadLanguageModule("logging");
37  $this->settings = new ilSetting('log');
38  $this->error_settings = ilLoggingErrorSettings::getInstance();
39  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilLoggerCronCleanErrorFiles::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

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

134  : void
135  {
136  $offset = $this->settings->get('clear_older_then', '');
137  if (!$offset) {
138  $offset = (string) self::DEFAULT_VALUE_OLDER_THAN;
139  }
140 
141  $clear_older_then = new ilNumberInputGUI($this->lng->txt('frm_clear_older_then'), 'clear_older_then');
142  $clear_older_then->allowDecimals(false);
143  $clear_older_then->setMinValue(1, true);
144  $clear_older_then->setValue($offset);
145  $clear_older_then->setInfo($this->lng->txt('frm_clear_older_then_info'));
146 
147  $a_form->addItem($clear_older_then);
148  }
+ Here is the call graph for this function:

◆ deleteFile()

ilLoggerCronCleanErrorFiles::deleteFile ( string  $path)
protected

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

Referenced by run().

129  : void
130  {
131  unlink($path);
132  }
$path
Definition: ltiservices.php:32
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLoggerCronCleanErrorFiles::getDefaultScheduleType ( )

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

57  {
58  return CronJobScheduleType::SCHEDULE_TYPE_IN_DAYS;
59  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilLoggerCronCleanErrorFiles::getDefaultScheduleValue ( )

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

61  : int
62  {
63  return 10;
64  }

◆ getDescription()

ilLoggerCronCleanErrorFiles::getDescription ( )

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

References ILIAS\Repository\lng().

51  : string
52  {
53  return $this->lng->txt("log_error_file_cleanup_info");
54  }
+ Here is the call graph for this function:

◆ getId()

ilLoggerCronCleanErrorFiles::getId ( )

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

41  : string
42  {
43  return "log_error_file_cleanup";
44  }

◆ getTitle()

ilLoggerCronCleanErrorFiles::getTitle ( )

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

References ILIAS\Repository\lng().

46  : string
47  {
48  return $this->lng->txt("log_error_file_cleanup_title");
49  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilLoggerCronCleanErrorFiles::hasAutoActivation ( )

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

66  : bool
67  {
68  return false;
69  }

◆ hasCustomSettings()

ilLoggerCronCleanErrorFiles::hasCustomSettings ( )

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

76  : bool
77  {
78  return true;
79  }

◆ hasFlexibleSchedule()

ilLoggerCronCleanErrorFiles::hasFlexibleSchedule ( )

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

71  : bool
72  {
73  return true;
74  }

◆ readLogDir()

ilLoggerCronCleanErrorFiles::readLogDir ( string  $path)
protected

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

Referenced by run().

114  : array
115  {
116  $ret = [];
117 
118  $folder = dir($path);
119  while ($file_name = $folder->read()) {
120  if (filetype($path . "/" . $file_name) != "dir") {
121  $ret[] = $file_name;
122  }
123  }
124  $folder->close();
125 
126  return $ret;
127  }
$path
Definition: ltiservices.php:32
+ Here is the caller graph for this function:

◆ run()

ilLoggerCronCleanErrorFiles::run ( )

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

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

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

◆ saveCustomSettings()

ilLoggerCronCleanErrorFiles::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

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

150  : bool
151  {
152  $threshold = $a_form->getInput('clear_older_then');
153  if ((string) $threshold === '') {
154  $this->settings->delete('clear_older_then');
155  } else {
156  $this->settings->set('clear_older_then', (string) ((int) $a_form->getInput('clear_older_then')));
157  }
158 
159  return true;
160  }
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-...
+ Here is the call graph for this function:

Field Documentation

◆ $error_settings

ilLoggingErrorSettings ilLoggerCronCleanErrorFiles::$error_settings
protected

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

◆ $lng

ilLanguage ilLoggerCronCleanErrorFiles::$lng
protected

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

◆ $settings

ilSetting ilLoggerCronCleanErrorFiles::$settings
protected

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

◆ DEFAULT_VALUE_OLDER_THAN

const ilLoggerCronCleanErrorFiles::DEFAULT_VALUE_OLDER_THAN = 31
protected

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


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