ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 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...
 

Protected Member Functions

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

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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilLoggerCronCleanErrorFiles::__construct ( )

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

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

16  {
17  global $lng;
18 
19  $this->lng = $lng;
20  $this->lng->loadLanguageModule("logging");
21  $this->settings = new ilSetting('log');
22  $this->error_settings = ilLoggingErrorSettings::getInstance();
23  }
settings()
Definition: settings.php:2
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilLoggerCronCleanErrorFiles::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

References ilPropertyFormGUI\addItem(), settings(), and ilTextInputGUI\setValue().

142  {
143  $clear_older_then = new ilTextInputGUI($this->lng->txt('frm_clear_older_then'), 'clear_older_then');
144  $clear_older_then->setValue($this->settings->get('clear_older_then'));
145  $clear_older_then->setInfo($this->lng->txt('frm_clear_older_then_info'));
146 
147  $a_form->addItem($clear_older_then);
148  }
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a text property in a property form.
settings()
Definition: settings.php:2
setValue($a_value)
Set Value.
+ Here is the call graph for this function:

◆ deleteFile()

ilLoggerCronCleanErrorFiles::deleteFile (   $path)
protected

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

References $path.

Referenced by run().

134  {
135  unlink($path);
136  }
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLoggerCronCleanErrorFiles::getDefaultScheduleType ( )

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

53  {
54  return self::SCHEDULE_TYPE_IN_DAYS;
55  }

◆ getDefaultScheduleValue()

ilLoggerCronCleanErrorFiles::getDefaultScheduleValue ( )

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

61  {
62  return 10;
63  }

◆ getDescription()

ilLoggerCronCleanErrorFiles::getDescription ( )

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

45  {
46  return $this->lng->txt("log_error_file_cleanup_info");
47  }

◆ getId()

ilLoggerCronCleanErrorFiles::getId ( )

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

29  {
30  return "log_error_file_cleanup";
31  }

◆ getTitle()

ilLoggerCronCleanErrorFiles::getTitle ( )

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

37  {
38  return $this->lng->txt("log_error_file_cleanup_title");
39  }

◆ hasAutoActivation()

ilLoggerCronCleanErrorFiles::hasAutoActivation ( )

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

69  {
70  return false;
71  }

◆ hasCustomSettings()

ilLoggerCronCleanErrorFiles::hasCustomSettings ( )

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

85  {
86  return true;
87  }

◆ hasFlexibleSchedule()

ilLoggerCronCleanErrorFiles::hasFlexibleSchedule ( )

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

77  {
78  return true;
79  }

◆ readLogDir()

ilLoggerCronCleanErrorFiles::readLogDir (   $path)
protected

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

References $path, $ret, and array.

Referenced by run().

119  {
120  $ret = array();
121 
122  $folder = dir($path);
123  while ($file_name = $folder->read()) {
124  if (filetype($path . "/" . $file_name) != "dir") {
125  $ret[] = $file_name;
126  }
127  }
128  $folder->close();
129 
130  return $ret;
131  }
Create styles array
The data for the language used.
$ret
Definition: parser.php:6
+ Here is the caller graph for this function:

◆ run()

ilLoggerCronCleanErrorFiles::run ( )

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

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

93  {
94  $result = new ilCronJobResult();
95  $folder = $this->error_settings->folder();
96  if (!is_dir($folder)) {
98  $result->setMessage($this->lng->txt("log_error_path_not_configured_or_wrong"));
99  return $result;
100  }
101 
102  $files = $this->readLogDir($folder);
103  $delete_date = new ilDateTime(date("Y-m-d"), IL_CAL_DATE);
104  $delete_date->increment(ilDateTime::DAY, (-1 * $this->settings->get('clear_older_then')));
105 
106  foreach ($files as $file) {
107  $file_date = date("Y-m-d", filemtime($this->error_settings->folder() . "/" . $file));
108 
109  if ($file_date <= $delete_date->get(IL_CAL_DATE)) {
110  $this->deleteFile($this->error_settings->folder() . "/" . $file);
111  }
112  }
113 
115  return $result;
116  }
$files
Definition: add-vimline.php:18
$result
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Date and time handling
const IL_CAL_DATE
settings()
Definition: settings.php:2
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
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 154 of file class.ilLoggerCronCleanErrorFiles.php.

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

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

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