ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSCTreeTasksGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/SystemCheck/classes/class.ilSCComponentTaskGUI.php';
5
14{
15 const TYPE_DUPLICATES = 'duplicates';
16 const TYPE_DUMP = 'dump';
17 const TYPE_MISSING = 'missing_reference';
18 const TYPE_MISSING_TREE = 'missing_tree';
19 const TYPE_STRUCTURE = 'structure';
20
21
22 public function getGroupTitle()
23 {
24 return $this->getLang()->txt('sysc_grp_tree');
25 }
26
27 public function getGroupDescription()
28 {
29 return $this->getLang()->txt('sysc_grp_tree_desc');
30 }
31
35 public function getTitle()
36 {
37 switch ($this->getTask()->getIdentifier()) {
38 case self::TYPE_DUMP:
39 return $this->getLang()->txt('sysc_task_tree_dump');
40
42 return $this->getLang()->txt('sysc_task_tree_duplicates');
43
45 return $this->getLang()->txt('sysc_task_tree_missing_reference');
46
48 return $this->getLang()->txt('sysc_task_tree_missing_tree');
49
51 return $this->getLang()->txt('sysc_task_structure');
52 }
53 }
54
58 public function getDescription()
59 {
60 switch ($this->getTask()->getIdentifier()) {
61 case self::TYPE_DUMP:
62 return $this->getLang()->txt('sysc_task_tree_dump_desc');
63
65 return $this->getLang()->txt('sysc_task_tree_duplicates_desc');
66
68 return $this->getLang()->txt('sysc_task_tree_missing_reference_desc');
69
71 return $this->getLang()->txt('sysc_task_tree_missing_tree_desc');
72
74 return $this->getLang()->txt('sysc_task_structure_desc');
75 }
76 }
77
81 public function getActions()
82 {
83 $repair = false;
84 if ($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED) {
85 $repair = true;
86 }
87
88 $actions = array();
89 switch ($this->getTask()->getIdentifier()) {
91
92 $actions[] = array(
93 'txt' => $this->getLang()->txt('sysc_action_validate'),
94 'command' => 'validateDuplicates'
95 );
96
97 if ($repair) {
98 $actions[] = array(
99 'txt' => $this->getLang()->txt('sysc_action_repair'),
100 'command' => 'repairDuplicates'
101 );
102 }
103 break;
104
105 case self::TYPE_DUMP:
106
107 include_once './Services/Repository/classes/class.ilValidator.php';
108 $validator = new ilValidator();
109 if ($validator->hasScanLog()) {
110 $actions[] = array(
111 'txt' => $this->getLang()->txt('sysc_action_show_tree'),
112 'command' => 'showTree'
113 );
114 }
115
116 $actions[] = array(
117 'txt' => $this->getLang()->txt('sysc_action_list_tree'),
118 'command' => 'listTree'
119 );
120 break;
121
123
124 $actions[] = array(
125 'txt' => $this->getLang()->txt('sysc_action_validate'),
126 'command' => 'findMissing'
127 );
128
129 if ($repair) {
130 $actions[] = array(
131 'txt' => $this->getLang()->txt('sysc_action_repair'),
132 'command' => 'confirmRepairMissing'
133 );
134 }
135 break;
136
138
139 $actions[] = array(
140 'txt' => $this->getLang()->txt('sysc_action_validate'),
141 'command' => 'findMissingTreeEntries'
142 );
143
144 if ($repair) {
145 $actions[] = array(
146 'txt' => $this->getLang()->txt('sysc_action_repair'),
147 'command' => 'confirmRepairMissingTreeEntries'
148 );
149 }
150 break;
151
153
154 $actions[] = array(
155 'txt' => $this->getLang()->txt('sysc_action_validate'),
156 'command' => 'analyzeStructure'
157 );
158
159 if ($repair) {
160 $actions[] = array(
161 'txt' => $this->getLang()->txt('sysc_action_repair'),
162 'command' => 'confirmRepairStructure'
163 );
164 }
165 break;
166
167 }
168 return $actions;
169 }
170
174 public function analyzeStructure()
175 {
176 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
177 $tasks = new ilSCTreeTasks($this->getTask());
178 $num_failures = $tasks->validateStructure();
179
180 if ($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED) {
181 // error message
182 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_structure_failures') . ' ' . $num_failures, true);
183 } else {
184 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'), true);
185 }
186 $this->getCtrl()->returnToParent($this);
187 }
188
189
194 protected function confirmRepairStructure()
195 {
196 return $this->showSimpleConfirmation(
197 $this->getLang()->txt('sysc_message_tree_structure_confirm'),
198 $this->getLang()->txt('sysc_btn_tree_structure'),
199 'repairStructure'
200 );
201 }
202
206 protected function repairStructure()
207 {
208 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
209 $tasks = new ilSCTreeTasks($this->getTask());
210
211
212 if ($GLOBALS['DIC']['tree']->getTreeImplementation() instanceof ilMaterializedPathTree) {
214 } elseif ($GLOBALS['DIC']['tree']->getTreeImplementation() instanceof ilNestedSetTree) {
215 $GLOBALS['DIC']['tree']->renumber(ROOT_FOLDER_ID);
216 }
217
218 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
219 $this->getTask()->setLastUpdate(new ilDateTime(time(), IL_CAL_UNIX));
220 $this->getTask()->update();
221
222 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'), true);
223 $this->getCtrl()->returnToParent($this);
224 }
225
226
227
228
229
233 public function listTree()
234 {
235 include_once './Services/Repository/classes/class.ilValidator.php';
236 $validator = new ilValidator(true);
237 $errors_count = $validator->dumpTree();
238
239
240 $GLOBALS['DIC']['ilLog']->write(print_r($this->getTask(), true));
241
242 if ($errors_count) {
243 $this->getTask()->setStatus(ilSCTask::STATUS_FAILED);
244 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_list_failures') . ' ' . $errors_count, true);
245 } else {
246 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
247 ilUtil::sendFailure($this->getLang()->txt('sysc_message_success'), true);
248 }
249
250 $this->getTask()->setLastUpdate(new ilDateTime(time(), IL_CAL_UNIX));
251 $this->getTask()->update();
252
253 $this->getCtrl()->returnToParent($this);
254 }
255
259 public function showTree()
260 {
261 include_once "./Services/Repository/classes/class.ilValidator.php";
262 $validator = new ilValidator();
263 $scan_log = $validator->readScanLog();
264
265 if (is_array($scan_log)) {
266 $scan_log = '<pre>' . implode("", $scan_log) . '</pre>';
267 $GLOBALS['DIC']['tpl']->setContent($scan_log);
268 }
269 }
270
271
276 public function validateDuplicates()
277 {
278 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
279 $tasks = new ilSCTreeTasks($this->getTask());
280 $num_failures = $tasks->validateDuplicates();
281
282 if ($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED) {
283 // error message
284 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_duplicate_failures') . ' ' . $num_failures, true);
285 } else {
286 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'), true);
287 }
288 $this->getCtrl()->returnToParent($this);
289 }
290
291
292
297 protected function repairDuplicates()
298 {
299 // repair duplicates
300 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
301 $deepest_duplicate = ilSCTreeTasks::findDeepestDuplicate();
302
303 include_once './Services/Tree/classes/class.ilSCTreeDuplicatesTableGUI.php';
304 $table = new ilSCTreeDuplicatesTableGUI($this, 'repairTask');
305 $table->init();
306 $table->parse($deepest_duplicate);
307
308 $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
309 }
310
312 {
313 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Removing from repository: ' . $_REQUEST['duplicate_id']);
314 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
315 ilSCTreeTasks::deleteDuplicateFromTree((int) $_REQUEST['duplicate_id'], false);
316
317 $tasks = new ilSCTreeTasks($this->getTask());
318 if ($tasks->checkDuplicates()) {
320 }
321
322 ilUtil::sendSuccess($this->getLang()->txt('sysc_deleted_duplicate'), true);
323 $this->getCtrl()->returnToParent($this);
324 }
325
326 protected function deleteDuplicatesFromTrash()
327 {
328 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Removing from repository: ' . $_REQUEST['duplicate_id']);
329 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
330 ilSCTreeTasks::deleteDuplicateFromTree((int) $_REQUEST['duplicate_id'], true);
331
332
333 $tasks = new ilSCTreeTasks($this->getTask());
334 if ($tasks->checkDuplicates()) {
336 }
337
338 ilUtil::sendSuccess($this->getLang()->txt('sysc_deleted_duplicate'), true);
339 $this->getCtrl()->returnToParent($this);
340 }
341
345 protected function findMissing()
346 {
347 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
348 $tasks = new ilSCTreeTasks($this->getTask());
349 $num_failures = $tasks->findMissing();
350
351 if ($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED) {
352 // error message
353 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_missing_failures') . ' ' . $num_failures, true);
354 } else {
355 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'), true);
356 }
357 $this->getCtrl()->returnToParent($this);
358 }
359
360
361
366 protected function confirmRepairMissing()
367 {
368 return $this->showSimpleConfirmation(
369 $this->getLang()->txt('sysc_message_tree_missing_confirm'),
370 $this->getLang()->txt('sysc_btn_tree_missing'),
371 'repairMissing'
372 );
373 }
374
378 protected function repairMissing()
379 {
380 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
381 $tasks = new ilSCTreeTasks($this->getTask());
382 $tasks->repairMissing();
383
384
385 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
386 $this->getTask()->setLastUpdate(new ilDateTime(time(), IL_CAL_UNIX));
387 $this->getTask()->update();
388
389 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'), true);
390 $this->getCtrl()->returnToParent($this);
391 }
392
396 protected function findMissingTreeEntries()
397 {
398 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
399 $tasks = new ilSCTreeTasks($this->getTask());
400 $num_failures = $tasks->findMissingTreeEntries();
401
402 if ($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED) {
403 // error message
404 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_missing_tree_failures') . ' ' . $num_failures, true);
405 } else {
406 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'), true);
407 }
408 $this->getCtrl()->returnToParent($this);
409 }
410
416 {
417 return $this->showSimpleConfirmation(
418 $this->getLang()->txt('sysc_message_tree_missing_confirm'),
419 $this->getLang()->txt('sysc_btn_tree_missing'),
420 'repairMissingTreeEntries'
421 );
422 }
423
427 protected function repairMissingTreeEntries()
428 {
429 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
430 $tasks = new ilSCTreeTasks($this->getTask());
431 $tasks->repairMissingTreeEntries();
432
433 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
434 $this->getTask()->setLastUpdate(new ilDateTime(time(), IL_CAL_UNIX));
435 $this->getTask()->update();
436
437 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'), true);
438 $this->getCtrl()->returnToParent($this);
439 }
440}
$tasks
Definition: build.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
@classDescription Date and time handling
Base class for materialize path based trees Based on implementation of Werner Randelshofer.
Base class for nested set path based trees.
Abstract class for component tasks.
showSimpleConfirmation($a_text, $a_btn_text, $a_cmd)
Show simple confirmation.
const STATUS_COMPLETED
const STATUS_FAILED
Handles tree tasks.
confirmRepairMissing()
Show repair missing confirmation.
confirmRepairMissingTreeEntries()
Show repair missing confirmation.
getActions()
get actions for table gui
findMissingTreeEntries()
find missing objects
repairMissingTreeEntries()
Repair missing objects.
getGroupTitle()
Get title of group.
getGroupDescription()
Get description of group.
findMissing()
find missing objects
getDescription()
Get title of task.
repairStructure()
Repair structure.
getTitle()
Get title of task.
showTree()
Show already scanned tree.
analyzeStructure()
Analyze tree structure.
confirmRepairStructure()
Show repair missing confirmation.
repairMissing()
Repair missing objects.
Defines a system check task.
static findDeepestDuplicate()
find duplicates @global type $ilDB
static deleteDuplicateFromTree($a_duplicate_id, $a_delete_trash)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
ILIAS Data Validator & Recovery Tool.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
if(empty($password)) $table
Definition: pwgen.php:24