ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilRepositoryTrashGUI Class Reference

Repository GUI Utilities. More...

+ Collaboration diagram for ilRepositoryTrashGUI:

Public Member Functions

 executeCommand ()
 
 restoreToNewLocation (?ilPropertyFormGUI $form=null)
 
 doRestoreToNewLocation ()
 
 showDeleteConfirmation (?array $a_ids, bool $a_supress_message=false)
 
 handleMultiReferences (int $a_obj_id, int $a_ref_id, string $a_form_name)
 
 showTrashTable (int $a_ref_id)
 
 restoreObjects (int $a_cur_ref_id, array $a_ref_ids)
 Restore objects from trash. More...
 
 deleteObjects (int $a_cur_ref_id, array $a_ref_ids)
 
 removeObjectsFromSystem (array $a_ref_ids, bool $a_from_recovery_folder=false)
 
 confirmRemoveFromSystemObject (array $a_ids)
 Confirmation for trash. More...
 

Protected Member Functions

 cancel ()
 
 initFormTrashTargetLocation ()
 
 buildPath (array $ref_ids)
 Build path with deep-link. More...
 

Protected Attributes

ILIAS Repository Deletion Deletion $deletion
 
ilLanguage $lng
 
ilSetting $settings
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilObjectDefinition $obj_definition
 
ilAccessHandler $access
 
ilTree $tree
 
ilLogger $logger = null
 
TrashGUIRequest $request
 
object $parent_gui
 
string $parent_cmd
 

Detailed Description

Repository GUI Utilities.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de @ilCtrl_Calls ilRepositoryTrashGUI: ilPropertyFormGUI

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

Member Function Documentation

◆ buildPath()

ilRepositoryTrashGUI::buildPath ( array  $ref_ids)
protected

Build path with deep-link.

Definition at line 457 of file class.ilRepositoryTrashGUI.php.

457 : array
458 {
460
461 if (!count($ref_ids)) {
462 return [];
463 }
464
465 $result = [];
466 foreach ($ref_ids as $ref_id) {
467 $path = "";
468 $path_full = $tree->getPathFull($ref_id);
469 foreach ($path_full as $idx => $data) {
470 if ($idx) {
471 $path .= " » ";
472 }
473 if ((int) $ref_id !== (int) $data['ref_id']) {
474 $path .= ilUtil::stripSlashes($data['title']);
475 } else {
476 $path .= ('<a target="_top" href="' .
477 ilLink::_getLink($data['ref_id'], $data['type']) . '">' .
478 ilUtil::stripSlashes($data['title']) . '</a>');
479 }
480 }
481
482 $result[] = $path;
483 }
484 return $result;
485 }
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30

References $data, $path, $ref_id, ilTree\getPathFull(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ cancel()

ilRepositoryTrashGUI::cancel ( )
protected

Definition at line 87 of file class.ilRepositoryTrashGUI.php.

87 : void
88 {
89 $this->ctrl->returnToParent($this);
90 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ confirmRemoveFromSystemObject()

ilRepositoryTrashGUI::confirmRemoveFromSystemObject ( array  $a_ids)

Confirmation for trash.

Parameters
array$a_idsref_ids

Definition at line 492 of file class.ilRepositoryTrashGUI.php.

494 : void {
495 $ilCtrl = $this->ctrl;
497 $objDefinition = $this->obj_definition;
499
500 if (!is_array($a_ids)) {
501 $a_ids = [$a_ids];
502 }
503
504 $cgui = new ilConfirmationGUI();
505 $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
506 $cgui->setCancel($lng->txt("cancel"), "trash");
507 $cgui->setConfirm($lng->txt("confirm"), "removeFromSystem");
508 $cgui->setFormName("trash_confirmation");
509 $cgui->setHeaderText($lng->txt("info_delete_sure"));
510
511 foreach ($a_ids as $id) {
512 $obj_id = ilObject::_lookupObjId($id);
513 $type = ilObject::_lookupType($obj_id);
514 $title = call_user_func([ilObjectFactory::getClassByType($type), '_lookupTitle'], $obj_id);
515 $alt = ($objDefinition->isPlugin($type))
516 ? $lng->txt("icon") . " " . ilObjectPlugin::lookupTxtById($type, "obj_" . $type)
517 : $lng->txt("icon") . " " . $lng->txt("obj_" . $type);
518
519 $cgui->addItem(
520 "trash_id[]",
521 $id,
522 $title,
523 ilObject::_getIcon($obj_id, "small", $type),
524 $alt
525 );
526 }
527
528 $tpl->setContent($cgui->getHTML());
529 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 getClassByType(string $obj_type)
static lookupTxtById(string $plugin_id, string $lang_var)
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
ilObjectDefinition $obj_definition
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.

◆ deleteObjects()

ilRepositoryTrashGUI::deleteObjects ( int  $a_cur_ref_id,
array  $a_ref_ids 
)

Definition at line 404 of file class.ilRepositoryTrashGUI.php.

407 : void {
410
411 if (!is_array($a_ref_ids) || count($a_ref_ids) === 0) {
412 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
413 } else {
414 try {
415 $this->deletion->deleteObjectsByRefIds($a_ref_ids);
416 if ($ilSetting->get('enable_trash')) {
417 $this->tpl->setOnScreenMessage('success', $lng->txt("info_deleted"), true);
418 } else {
419 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_removed"), true);
420 }
421 } catch (ilRepositoryException $e) {
422 // we catch ilRepositoryException, since this is usually permission related
423 // other exceptions are thrown to get call stacks
424 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
425 }
426 }
427 }
global $ilSetting
Definition: privfeed.php:31

References $lng.

◆ doRestoreToNewLocation()

ilRepositoryTrashGUI::doRestoreToNewLocation ( )
Exceptions
ilDatabaseException
ilObjectNotFoundException

Definition at line 117 of file class.ilRepositoryTrashGUI.php.

117 : void
118 {
119 $trash_ids = $this->request->getTrashIds();
120
121 $form = $this->initFormTrashTargetLocation();
122 if (!$form->checkInput() && count($trash_ids)) {
123 $this->lng->loadLanguageModule('search');
124 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('search_no_selection'), true);
125 $this->ctrl->returnToParent($this);
126 }
127
128 try {
129 ilRepUtil::restoreObjects($form->getInput('target_id'), $trash_ids);
130 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_undeleted'), true);
131 $this->ctrl->returnToParent($this);
132 } catch (ilRepositoryException $e) {
133 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
134 $this->ctrl->returnToParent($this);
135 }
136 }
static restoreObjects(int $a_cur_ref_id, array $a_ref_ids)
Move objects from trash back to repository.

References Vendor\Package\$e, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilRepUtil\restoreObjects().

+ Here is the call graph for this function:

◆ executeCommand()

ilRepositoryTrashGUI::executeCommand ( )
Exceptions
ilCtrlException

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

71 : void
72 {
73 $next_class = $this->ctrl->getNextClass($this);
74 switch ($next_class) {
75 case "ilpropertyformgui":
76 $form = $this->initFormTrashTargetLocation();
77 $this->ctrl->forwardCommand($form);
78 break;
79
80 default:
81 $cmd = $this->ctrl->getCmd('cancel');
82 $this->$cmd();
83 break;
84 }
85 }

References ILIAS\Repository\ctrl(), and initFormTrashTargetLocation().

+ Here is the call graph for this function:

◆ handleMultiReferences()

ilRepositoryTrashGUI::handleMultiReferences ( int  $a_obj_id,
int  $a_ref_id,
string  $a_form_name 
)

Definition at line 244 of file class.ilRepositoryTrashGUI.php.

248 : string {
250 $ilAccess = $this->access;
252
253 // process
254
255 $all_refs = ilObject::_getAllReferences($a_obj_id);
256 if (count($all_refs) > 1) {
257 $lng->loadLanguageModule("rep");
258
259 $may_delete_any = 0;
260 $counter = 0;
261 $items = [];
262 foreach ($all_refs as $mref_id) {
263 // not the already selected reference, no refs from trash
264 if ($mref_id != $a_ref_id && !$tree->isDeleted($mref_id)) {
265 if ($ilAccess->checkAccess("read", "", $mref_id)) {
266 $may_delete = false;
267 if ($ilAccess->checkAccess("delete", "", $mref_id)) {
268 $may_delete = true;
269 $may_delete_any++;
270 }
271
272 $path = $this->buildPath([$mref_id]);
273 $items[] = [
274 "id" => $mref_id,
275 "path" => array_shift($path),
276 "delete" => $may_delete
277 ];
278 } else {
279 $counter++;
280 }
281 }
282 }
283
284
285 // render
286
287 $tpl = new ilTemplate("tpl.rep_multi_ref.html", true, true, "components/ILIAS/Repository/Trash");
288
289 $tpl->setVariable("TXT_INTRO", $lng->txt("rep_multiple_reference_deletion_intro"));
290
291 if ($may_delete_any) {
292 $tpl->setVariable("TXT_INSTRUCTION", $lng->txt("rep_multiple_reference_deletion_instruction"));
293 }
294
295 if ($items) {
296 $var_name = "mref_id[]";
297
298 foreach ($items as $item) {
299 if ($item["delete"]) {
300 $tpl->setCurrentBlock("cbox");
301 $tpl->setVariable("ITEM_NAME", $var_name);
302 $tpl->setVariable("ITEM_VALUE", $item["id"]);
303 } else {
304 $tpl->setCurrentBlock("item_info");
305 $tpl->setVariable("TXT_ITEM_INFO", $lng->txt("rep_no_permission_to_delete"));
306 }
308
309 $tpl->setCurrentBlock("item");
310 $tpl->setVariable("ITEM_TITLE", $item["path"]);
312 }
313
314 if ($may_delete_any > 1) {
315 $tpl->setCurrentBlock("cbox");
316 $tpl->setVariable("ITEM_NAME", "sall_" . $a_ref_id);
317 $tpl->setVariable("ITEM_VALUE", "");
318 $tpl->setVariable("ITEM_ADD", " onclick=\"il.Util.setChecked('" .
319 $a_form_name . "', '" . $var_name . "', document." . $a_form_name .
320 ".sall_" . $a_ref_id . ".checked)\"");
322
323 $tpl->setCurrentBlock("item");
324 $tpl->setVariable("ITEM_TITLE", $lng->txt("select_all"));
326 }
327 }
328
329 if ($counter) {
330 $tpl->setCurrentBlock("add_info");
332 "TXT_ADDITIONAL_INFO",
333 sprintf($lng->txt("rep_object_references_cannot_be_read"), $counter)
334 );
336 }
337 return $tpl->get();
338 }
339 return "";
340 }
loadLanguageModule(string $a_module)
Load language module.
static _getAllReferences(int $id)
get all reference ids for object ID
buildPath(array $ref_ids)
Build path with deep-link.
special template class to simplify handling of ITX/PEAR
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
$counter

◆ initFormTrashTargetLocation()

ilRepositoryTrashGUI::initFormTrashTargetLocation ( )
protected

Definition at line 138 of file class.ilRepositoryTrashGUI.php.

139 {
140 $form = new ilPropertyFormGUI();
141 $form->setFormAction($this->ctrl->getFormAction($this));
142
143 $target = new ilRepositorySelector2InputGUI(
144 $this->lng->txt('rep_target_location'),
145 'target_id',
146 false
147 );
148 $target->setRequired(true);
149
150 $explorer = new ilRepositorySelectorExplorerGUI(
151 [
152 ilAdministrationGUI::class,
153 get_class($this->parent_gui),
154 self::class,
155 ilPropertyFormGUI::class,
156 ilFormPropertyDispatchGUI::class,
157 ilRepositorySelector2InputGUI::class
158 ],
159 'handleExplorerCommand',
160 $target,
161 'root_id',
162 'rep_exp_sel_' . $target->getPostVar()
163 );
164 $explorer->setSelectMode($target->getPostVar() . "_sel", false);
165 $explorer->setRootId(ROOT_FOLDER_ID);
166 $explorer->setTypeWhiteList(['root','cat','crs','grp','fold']);
167 $target->setExplorerGUI($explorer);
168
169 $form->addItem($target);
170 $form->addCommandButton('doRestoreToNewLocation', $this->lng->txt('btn_undelete'));
171 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
172
173 return $form;
174 }
This class represents a property form user interface.
Explorer for selecting repository items.
const ROOT_FOLDER_ID
Definition: constants.php:32

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ROOT_FOLDER_ID.

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeObjectsFromSystem()

ilRepositoryTrashGUI::removeObjectsFromSystem ( array  $a_ref_ids,
bool  $a_from_recovery_folder = false 
)

Definition at line 429 of file class.ilRepositoryTrashGUI.php.

432 : bool {
434
435 if (!is_array($a_ref_ids) || count($a_ref_ids) === 0) {
436 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
437 return false;
438 }
439
440 try {
441 ilRepUtil::removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder);
442 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_removed"), true);
443 } catch (Exception $e) {
444 // alex: I outcommented this, since it makes tracking down errors impossible
445 // we need a call stack at least in the logs
446 //$this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
447 throw $e;
448 return false;
449 }
450
451 return true;
452 }
static removeObjectsFromSystem(array $a_ref_ids, bool $a_from_recovery_folder=false)
remove objects from trash bin and all entries therefore every object needs a specific deleteObject() ...

References $lng.

◆ restoreObjects()

ilRepositoryTrashGUI::restoreObjects ( int  $a_cur_ref_id,
array  $a_ref_ids 
)

Restore objects from trash.

Parameters
int$a_cur_ref_id
int[]$a_ref_idsarray of ref ids to be restored
Returns
bool

Definition at line 367 of file class.ilRepositoryTrashGUI.php.

370 : bool {
372 $lng->loadLanguageModule('rep');
373
374 if (!is_array($a_ref_ids) || count($a_ref_ids) === 0) {
375 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
376 return false;
377 }
378
379 $tree_trash_queries = new ilTreeTrashQueries();
380 if ($tree_trash_queries->isTrashedTrash($a_ref_ids)) {
381 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('rep_failure_trashed_trash'), true);
382 return false;
383 }
384 try {
385 // find parent foreach node
386 $by_location = [];
387 foreach ($a_ref_ids as $deleted_node_id) {
388 $target_id = $tree_trash_queries->findRepositoryLocationForDeletedNode($deleted_node_id);
389 if ($target_id) {
390 $by_location[$target_id][] = $deleted_node_id;
391 }
392 }
393 foreach ($by_location as $target_id => $deleted_node_ids) {
394 ilRepUtil::restoreObjects($target_id, $deleted_node_ids);
395 }
396 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_undeleted"), true);
397 } catch (Exception $e) {
398 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
399 return false;
400 }
401 return true;
402 }

References $lng.

◆ restoreToNewLocation()

ilRepositoryTrashGUI::restoreToNewLocation ( ?ilPropertyFormGUI  $form = null)

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

94 : void {
95 $this->lng->loadLanguageModule('rep');
96
97 $trash_ids = $this->request->getTrashIds();
98
99 $this->ctrl->setParameter($this, 'trash_ids', implode(',', $trash_ids));
100
101 if (!count($trash_ids)) {
102 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
103 $this->ctrl->returnToParent($this);
104 }
105
106 if (!$form instanceof ilPropertyFormGUI) {
107 $form = $this->initFormTrashTargetLocation();
108 }
109 $this->tpl->setOnScreenMessage('info', $this->lng->txt('rep_target_location_info'));
110 $this->tpl->setContent($form->getHTML());
111 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ showDeleteConfirmation()

ilRepositoryTrashGUI::showDeleteConfirmation ( ?array  $a_ids,
bool  $a_supress_message = false 
)

Definition at line 176 of file class.ilRepositoryTrashGUI.php.

179 : bool {
182 $ilCtrl = $this->ctrl;
184 $objDefinition = $this->obj_definition;
185
186 if (!is_array($a_ids) || count($a_ids) === 0) {
187 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
188 return false;
189 }
190
191 // Remove duplicate entries
192 $a_ids = array_unique($a_ids);
193
194 $cgui = new ilConfirmationGUI();
195
196 if (!$a_supress_message) {
197 $msg = $lng->txt("info_delete_sure");
198
199 if (!$ilSetting->get('enable_trash')) {
200 $msg .= "<br/>" . $lng->txt("info_delete_warning_no_trash");
201 }
202
203 $cgui->setHeaderText($msg);
204 }
205 $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
206 $cgui->setCancel($lng->txt("cancel"), "cancelDelete");
207 $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
208
209 $form_name = "cgui_" . md5(uniqid('', true));
210 $cgui->setFormName($form_name);
211
212 $deps = [];
213 foreach ($a_ids as $ref_id) {
215 $type = ilObject::_lookupType($obj_id);
216 $title = call_user_func([ilObjectFactory::getClassByType($type), '_lookupTitle'], $obj_id);
217 $alt = ($objDefinition->isPlugin($type))
218 ? $lng->txt("icon") . " " . ilObjectPlugin::lookupTxtById($type, "obj_" . $type)
219 : $lng->txt("icon") . " " . $lng->txt("obj_" . $type);
220
221 $cgui->addItem(
222 "id[]",
223 $ref_id,
224 ilUtil::stripSlashes($title) .
225 $this->handleMultiReferences($obj_id, $ref_id, $form_name),
226 ilObject::_getIcon($obj_id, "small", $type),
227 $alt
228 );
229
230 ilObject::collectDeletionDependencies($deps, $ref_id, $obj_id, $type);
231 }
232 $deps_html = "";
233
234 if (is_array($deps) && count($deps) > 0) {
235 $tab = new ilRepDependenciesTableGUI($deps);
236 $deps_html = "<br/><br/>" . $tab->getHTML();
237 }
238
239 $tpl->setContent($cgui->getHTML() . $deps_html);
240 return true;
241 }
static collectDeletionDependencies(array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
Collect deletion dependencies.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handleMultiReferences(int $a_obj_id, int $a_ref_id, string $a_form_name)

References $lng, and ILIAS\UICore\GlobalTemplate\setOnScreenMessage().

+ Here is the call graph for this function:

◆ showTrashTable()

ilRepositoryTrashGUI::showTrashTable ( int  $a_ref_id)

Definition at line 342 of file class.ilRepositoryTrashGUI.php.

344 : void {
348
349 $objects = $tree->getSavedNodeData($a_ref_id);
350
351 if (count($objects) === 0) {
352 $this->tpl->setOnScreenMessage('info', $lng->txt("msg_trash_empty"));
353 return;
354 }
355 $ttab = new ilTrashTableGUI($this->parent_gui, "trash", $a_ref_id);
356 $ttab->setData($objects);
357
358 $tpl->setContent($ttab->getHTML());
359 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSavedNodeData(int $a_parent_id)
get data saved/deleted nodes

References $lng.

Field Documentation

◆ $access

ilAccessHandler ilRepositoryTrashGUI::$access
protected

Definition at line 35 of file class.ilRepositoryTrashGUI.php.

◆ $ctrl

ilCtrl ilRepositoryTrashGUI::$ctrl
protected

Definition at line 32 of file class.ilRepositoryTrashGUI.php.

◆ $deletion

ILIAS Repository Deletion Deletion ilRepositoryTrashGUI::$deletion
protected

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

◆ $lng

ilLanguage ilRepositoryTrashGUI::$lng
protected

Definition at line 30 of file class.ilRepositoryTrashGUI.php.

◆ $logger

ilLogger ilRepositoryTrashGUI::$logger = null
protected

Definition at line 37 of file class.ilRepositoryTrashGUI.php.

◆ $obj_definition

ilObjectDefinition ilRepositoryTrashGUI::$obj_definition
protected

Definition at line 34 of file class.ilRepositoryTrashGUI.php.

◆ $parent_cmd

string ilRepositoryTrashGUI::$parent_cmd
protected

Definition at line 40 of file class.ilRepositoryTrashGUI.php.

◆ $parent_gui

object ilRepositoryTrashGUI::$parent_gui
protected

Definition at line 39 of file class.ilRepositoryTrashGUI.php.

◆ $request

TrashGUIRequest ilRepositoryTrashGUI::$request
protected

Definition at line 38 of file class.ilRepositoryTrashGUI.php.

◆ $settings

ilSetting ilRepositoryTrashGUI::$settings
protected

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

◆ $tpl

ilGlobalTemplateInterface ilRepositoryTrashGUI::$tpl
protected

Definition at line 33 of file class.ilRepositoryTrashGUI.php.

◆ $tree

ilTree ilRepositoryTrashGUI::$tree
protected

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


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