ILIAS  release_8 Revision v8.24
class.ilCleanCOPageHistoryCronjob.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
27{
30 protected ilLanguage $lng;
31
32 public function __construct()
33 {
34 global $DIC;
35
36 $this->lng = $DIC->language();
37 $this->settings = $DIC->settings();
38 $this->history_manager = $DIC
39 ->copage()
40 ->internal()
41 ->domain()
42 ->history();
43 }
44
45 public function getId(): string
46 {
47 return "copg_history_cleanup";
48 }
49
50 public function getTitle(): string
51 {
53
54 $lng->loadLanguageModule("copg");
55 return $lng->txt("copg_history_cleanup_cron");
56 }
57
58 public function getDescription(): string
59 {
61
62 $lng->loadLanguageModule("copg");
63 return $lng->txt("copg_history_cleanup_cron_info");
64 }
65
66 public function getDefaultScheduleType(): int
67 {
69 }
70
71 public function getDefaultScheduleValue(): ?int
72 {
73 return null;
74 }
75
76 public function hasAutoActivation(): bool
77 {
78 return false;
79 }
80
81 public function hasFlexibleSchedule(): bool
82 {
83 return false;
84 }
85
86 public function hasCustomSettings(): bool
87 {
88 return true;
89 }
90
91 public function run(): ilCronJobResult
92 {
93 global $DIC;
94
96 $log->debug("----- Delete old page history entries, Start -----");
97
99 $result = new ilCronJobResult();
100
101 $x_days = $this->getCronDays();
102 $keep_entries = $this->getKeepEntries();
103 $log->debug("... $x_days days, keep $keep_entries");
104
105 if ($this->history_manager->deleteOldHistoryEntries($x_days, $keep_entries)) {
107 }
108
109 $log->debug("----- Delete old page history entries, End -----");
110
111 $result->setStatus($status);
112 return $result;
113 }
114
115 public function addCustomSettingsToForm(ilPropertyFormGUI $a_form): void
116 {
118 $lng->loadLanguageModule("copg");
119
120 $ti = new ilNumberInputGUI(
121 $lng->txt("copg_cron_days"),
122 "copg_cron_days"
123 );
124 $ti->setSize(6);
125 $ti->setSuffix($lng->txt("copg_days"));
126 $ti->setInfo($lng->txt("copg_cron_days_info"));
127 $ti->setValue((string) $this->getCronDays());
128 $a_form->addItem($ti);
129
130 $ti = new ilNumberInputGUI($lng->txt("copg_cron_keep_entries"), "copg_cron_keep_entries");
131 $ti->setSize(6);
132 $ti->setSuffix($lng->txt("copg_entries"));
133 $ti->setInfo($lng->txt("copg_cron_keep_entries_info"));
134 $ti->setValue((string) $this->getKeepEntries());
135 $a_form->addItem($ti);
136 }
137
138 public function saveCustomSettings(ilPropertyFormGUI $a_form): bool
139 {
140 $this->setCronDays((int) $a_form->getInput("copg_cron_days"));
141 $this->setKeepEntries((int) $a_form->getInput("copg_cron_keep_entries"));
142
143 return true;
144 }
145
146 protected function getCronDays(): int
147 {
149 return (int) $settings->get("copg_cron_days", "3600");
150 }
151
152 protected function setCronDays(int $days): void
153 {
155 $settings->set("copg_cron_days", (string) $days);
156 }
157
158 protected function getKeepEntries(): int
159 {
161 return (int) $settings->get("copg_cron_keep_entries", "1000");
162 }
163
164 protected function setKeepEntries(int $entries): void
165 {
167 $settings->set("copg_cron_keep_entries", (string) $entries);
168 }
169}
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getLogger(string $a_component_id)
Get component logger.
This class represents a number property in a property form.
This class represents a property form user interface.
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-...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
set(string $a_key, string $a_val)
get(string $a_keyword, ?string $a_default_value=null)
get setting
global $DIC
Definition: feed.php:28
$log
Definition: result.php:33