ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
39 case self::TYPE_DUMP:
40 return $this->getLang()->txt('sysc_task_tree_dump');
41
43 return $this->getLang()->txt('sysc_task_tree_duplicates');
44
46 return $this->getLang()->txt('sysc_task_tree_missing_reference');
47
49 return $this->getLang()->txt('sysc_task_tree_missing_tree');
50
52 return $this->getLang()->txt('sysc_task_structure');
53 }
54 }
55
59 public function getDescription()
60 {
61 switch($this->getTask()->getIdentifier())
62 {
63 case self::TYPE_DUMP:
64 return $this->getLang()->txt('sysc_task_tree_dump_desc');
65
67 return $this->getLang()->txt('sysc_task_tree_duplicates_desc');
68
70 return $this->getLang()->txt('sysc_task_tree_missing_reference_desc');
71
73 return $this->getLang()->txt('sysc_task_tree_missing_tree_desc');
74
76 return $this->getLang()->txt('sysc_task_structure_desc');
77 }
78 }
79
83 public function getActions()
84 {
85 $repair = FALSE;
86 if($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED)
87 {
88 $repair = TRUE;
89 }
90
91 $actions = array();
92 switch($this->getTask()->getIdentifier())
93 {
95
96 $actions[] = array(
97 'txt' => $this->getLang()->txt('sysc_action_validate'),
98 'command' => 'validateDuplicates'
99 );
100
101 if($repair)
102 {
103 $actions[] = array(
104 'txt' => $this->getLang()->txt('sysc_action_repair'),
105 'command' => 'repairDuplicates'
106 );
107 }
108 break;
109
110 case self::TYPE_DUMP:
111
112 include_once './Services/Repository/classes/class.ilValidator.php';
113 $validator = new ilValidator();
114 if($validator->hasScanLog())
115 {
116 $actions[] = array(
117 'txt' => $this->getLang()->txt('sysc_action_show_tree'),
118 'command' => 'showTree'
119 );
120 }
121
122 $actions[] = array(
123 'txt' => $this->getLang()->txt('sysc_action_list_tree'),
124 'command' => 'listTree'
125 );
126 break;
127
129
130 $actions[] = array(
131 'txt' => $this->getLang()->txt('sysc_action_validate'),
132 'command' => 'findMissing'
133 );
134
135 if($repair)
136 {
137 $actions[] = array(
138 'txt' => $this->getLang()->txt('sysc_action_repair'),
139 'command' => 'confirmRepairMissing'
140 );
141 }
142 break;
143
145
146 $actions[] = array(
147 'txt' => $this->getLang()->txt('sysc_action_validate'),
148 'command' => 'findMissingTreeEntries'
149 );
150
151 if($repair)
152 {
153 $actions[] = array(
154 'txt' => $this->getLang()->txt('sysc_action_repair'),
155 'command' => 'confirmRepairMissingTreeEntries'
156 );
157 }
158 break;
159
161
162 $actions[] = array(
163 'txt' => $this->getLang()->txt('sysc_action_validate'),
164 'command' => 'analyzeStructure'
165 );
166
167 if($repair)
168 {
169 $actions[] = array(
170 'txt' => $this->getLang()->txt('sysc_action_repair'),
171 'command' => 'confirmRepairStructure'
172 );
173 }
174 break;
175
176 }
177 return $actions;
178 }
179
183 public function analyzeStructure()
184 {
185 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
186 $tasks = new ilSCTreeTasks($this->getTask());
187 $num_failures = $tasks->validateStructure();
188
189 if($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED)
190 {
191 // error message
192 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_structure_failures').' '.$num_failures,TRUE);
193 }
194 else
195 {
196 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'),TRUE);
197 }
198 $this->getCtrl()->returnToParent($this);
199 }
200
201
206 protected function confirmRepairStructure()
207 {
208 return $this->showSimpleConfirmation(
209 $this->getLang()->txt('sysc_message_tree_structure_confirm'),
210 $this->getLang()->txt('sysc_btn_tree_structure'),
211 'repairStructure'
212 );
213 }
214
218 protected function repairStructure()
219 {
220 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
221 $tasks = new ilSCTreeTasks($this->getTask());
222
223
224 if($GLOBALS['tree']->getTreeImplementation() instanceof ilMaterializedPathTree)
225 {
227 }
228 elseif($GLOBALS['tree']->getTreeImplementation() instanceof ilNestedSetTree)
229 {
230 $GLOBALS['tree']->renumber(ROOT_FOLDER_ID);
231 }
232
233 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
234 $this->getTask()->setLastUpdate(new ilDateTime(time(),IL_CAL_UNIX));
235 $this->getTask()->update();
236
237 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'),TRUE);
238 $this->getCtrl()->returnToParent($this);
239 }
240
241
242
243
244
248 public function listTree()
249 {
250 include_once './Services/Repository/classes/class.ilValidator.php';
251 $validator = new ilValidator(TRUE);
252 $errors_count = $validator->dumpTree();
253
254
255 $GLOBALS['ilLog']->write(print_r($this->getTask(),TRUE));
256
257 if($errors_count)
258 {
259 $this->getTask()->setStatus(ilSCTask::STATUS_FAILED);
260 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_list_failures').' '.$errors_count,TRUE);
261 }
262 else
263 {
264 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
265 ilUtil::sendFailure($this->getLang()->txt('sysc_message_success'),TRUE);
266 }
267
268 $this->getTask()->setLastUpdate(new ilDateTime(time(),IL_CAL_UNIX));
269 $this->getTask()->update();
270
271 $this->getCtrl()->returnToParent($this);
272 }
273
277 public function showTree()
278 {
279 include_once "./Services/Repository/classes/class.ilValidator.php";
280 $validator = new ilValidator();
281 $scan_log = $validator->readScanLog();
282
283 if (is_array($scan_log))
284 {
285 $scan_log = '<pre>'.implode("",$scan_log).'</pre>';
286 $GLOBALS['tpl']->setContent($scan_log);
287 }
288 }
289
290
295 public function validateDuplicates()
296 {
297 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
298 $tasks = new ilSCTreeTasks($this->getTask());
299 $num_failures = $tasks->validateDuplicates();
300
301 if($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED)
302 {
303 // error message
304 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_duplicate_failures').' '.$num_failures,TRUE);
305 }
306 else
307 {
308 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'),TRUE);
309 }
310 $this->getCtrl()->returnToParent($this);
311 }
312
313
314
319 protected function repairDuplicates()
320 {
321 // repair duplicates
322 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
323 $deepest_duplicate = ilSCTreeTasks::findDeepestDuplicate();
324
325 include_once './Services/Tree/classes/class.ilSCTreeDuplicatesTableGUI.php';
326 $table = new ilSCTreeDuplicatesTableGUI($this,'repairTask');
327 $table->init();
328 $table->parse($deepest_duplicate);
329
330 $GLOBALS['tpl']->setContent($table->getHTML());
331 }
332
334 {
335 $GLOBALS['ilLog']->write(__METHOD__.': Removing from repository: '.$_REQUEST['duplicate_id']);
336 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
337 ilSCTreeTasks::deleteDuplicateFromTree((int) $_REQUEST['duplicate_id'], FALSE);
338
339 $tasks = new ilSCTreeTasks($this->getTask());
340 if($tasks->checkDuplicates())
341 {
343 }
344
345 ilUtil::sendSuccess($this->getLang()->txt('sysc_deleted_duplicate'),TRUE);
346 $this->getCtrl()->returnToParent($this);
347
348 }
349
350 protected function deleteDuplicatesFromTrash()
351 {
352 $GLOBALS['ilLog']->write(__METHOD__.': Removing from repository: '.$_REQUEST['duplicate_id']);
353 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
354 ilSCTreeTasks::deleteDuplicateFromTree((int) $_REQUEST['duplicate_id'], TRUE);
355
356
357 $tasks = new ilSCTreeTasks($this->getTask());
358 if($tasks->checkDuplicates())
359 {
361 }
362
363 ilUtil::sendSuccess($this->getLang()->txt('sysc_deleted_duplicate'),TRUE);
364 $this->getCtrl()->returnToParent($this);
365 }
366
370 protected function findMissing()
371 {
372 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
373 $tasks = new ilSCTreeTasks($this->getTask());
374 $num_failures = $tasks->findMissing();
375
376 if($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED)
377 {
378 // error message
379 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_missing_failures').' '.$num_failures,TRUE);
380 }
381 else
382 {
383 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'),TRUE);
384 }
385 $this->getCtrl()->returnToParent($this);
386 }
387
388
389
394 protected function confirmRepairMissing()
395 {
396 return $this->showSimpleConfirmation(
397 $this->getLang()->txt('sysc_message_tree_missing_confirm'),
398 $this->getLang()->txt('sysc_btn_tree_missing'),
399 'repairMissing'
400 );
401 }
402
406 protected function repairMissing()
407 {
408 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
409 $tasks = new ilSCTreeTasks($this->getTask());
410 $tasks->repairMissing();
411
412
413 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
414 $this->getTask()->setLastUpdate(new ilDateTime(time(),IL_CAL_UNIX));
415 $this->getTask()->update();
416
417 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'),TRUE);
418 $this->getCtrl()->returnToParent($this);
419 }
420
424 protected function findMissingTreeEntries()
425 {
426 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
427 $tasks = new ilSCTreeTasks($this->getTask());
428 $num_failures = $tasks->findMissingTreeEntries();
429
430 if($this->getTask()->getStatus() == ilSCTask::STATUS_FAILED)
431 {
432 // error message
433 ilUtil::sendFailure($this->getLang()->txt('sysc_tree_missing_tree_failures').' '.$num_failures,TRUE);
434 }
435 else
436 {
437 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'),TRUE);
438 }
439 $this->getCtrl()->returnToParent($this);
440 }
441
447 {
448 return $this->showSimpleConfirmation(
449 $this->getLang()->txt('sysc_message_tree_missing_confirm'),
450 $this->getLang()->txt('sysc_btn_tree_missing'),
451 'repairMissingTreeEntries'
452 );
453 }
454
458 protected function repairMissingTreeEntries()
459 {
460 include_once './Services/Tree/classes/class.ilSCTreeTasks.php';
461 $tasks = new ilSCTreeTasks($this->getTask());
462 $tasks->repairMissingTreeEntries();
463
464 $this->getTask()->setStatus(ilSCTask::STATUS_COMPLETED);
465 $this->getTask()->setLastUpdate(new ilDateTime(time(),IL_CAL_UNIX));
466 $this->getTask()->update();
467
468 ilUtil::sendSuccess($this->getLang()->txt('sysc_message_success'),TRUE);
469 $this->getCtrl()->returnToParent($this);
470 }
471}
472?>
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
ILIAS Data Validator & Recovery Tool.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7