ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilRepUtilGUI Class Reference

Repository GUI Utilities. More...

+ Collaboration diagram for ilRepUtilGUI:

Public Member Functions

 __construct ($a_parent_gui, $a_parent_cmd="")
 Constructor. More...
 
 showDeleteConfirmation ($a_ids, $a_supress_message=false)
 Show delete confirmation table. More...
 
 handleMultiReferences ($a_obj_id, $a_ref_id, $a_form_name)
 Build subitem list for multiple references. More...
 
 showTrashTable ($a_ref_id)
 Get trashed objects for a container. More...
 
 restoreObjects ($a_cur_ref_id, $a_ref_ids)
 Restore objects from trash. More...
 
 deleteObjects ($a_cur_ref_id, $a_ref_ids)
 Delete objects. More...
 
 removeObjectsFromSystem ($a_ref_ids, $a_from_recovery_folder=false)
 Remove objects from system. More...
 
 confirmRemoveFromSystemObject ($a_ids)
 Confirmation for trash. More...
 

Protected Member Functions

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

Protected Attributes

 $lng
 
 $settings
 
 $ctrl
 
 $tpl
 
 $obj_definition
 
 $access
 
 $tree
 

Detailed Description

Repository GUI Utilities.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilRepUtilGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilRepUtilGUI::__construct (   $a_parent_gui,
  $a_parent_cmd = "" 
)

Constructor.

Parameters
objectparent gui object
stringcurrent parent command (like in table2gui)

Definition at line 56 of file class.ilRepUtilGUI.php.

57 {
58 global $DIC;
59
60 $this->lng = $DIC->language();
61 $this->settings = $DIC->settings();
62 $this->ctrl = $DIC->ctrl();
63 $this->tpl = $DIC["tpl"];
64 $this->obj_definition = $DIC["objDefinition"];
65 $this->access = $DIC->access();
66 $this->tree = $DIC->repositoryTree();
67 $this->parent_gui = $a_parent_gui;
68 $this->parent_cmd = $a_parent_cmd;
69 }
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2

References $DIC, and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildPath()

ilRepUtilGUI::buildPath (   $ref_ids)
protected

Build path with deep-link.

Parameters
array$ref_ids
Returns
array

Definition at line 351 of file class.ilRepUtilGUI.php.

352 {
354
355 include_once 'Services/Link/classes/class.ilLink.php';
356
357 if (!count($ref_ids)) {
358 return false;
359 }
360
361 $result = array();
362 foreach ($ref_ids as $ref_id) {
363 $path = "";
364 $path_full = $tree->getPathFull($ref_id);
365 foreach ($path_full as $idx => $data) {
366 if ($idx) {
367 $path .= " » ";
368 }
369 if ($ref_id != $data['ref_id']) {
370 $path .= $data['title'];
371 } else {
372 $path .= ('<a target="_top" href="' .
373 ilLink::_getLink($data['ref_id'], $data['type']) . '">' .
374 $data['title'] . '</a>');
375 }
376 }
377
378 $result[] = $path;
379 }
380 return $result;
381 }
$result
$path
Definition: aliased.php:25
$data
Definition: bench.php:6

References $data, $path, $result, $tree, and ilLink\_getLink().

Referenced by handleMultiReferences().

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

◆ confirmRemoveFromSystemObject()

ilRepUtilGUI::confirmRemoveFromSystemObject (   $a_ids)

Confirmation for trash.

Parameters
array$a_idsref_ids

Definition at line 388 of file class.ilRepUtilGUI.php.

389 {
392 $objDefinition = $this->obj_definition;
394 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
395
396 if (!is_array($a_ids)) {
397 $a_ids = array($a_ids);
398 }
399
400 $cgui = new ilConfirmationGUI();
401 $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
402 $cgui->setCancel($lng->txt("cancel"), "trash");
403 $cgui->setConfirm($lng->txt("confirm"), "removeFromSystem");
404 $cgui->setFormName("trash_confirmation");
405 $cgui->setHeaderText($lng->txt("info_delete_sure"));
406
407 foreach ($a_ids as $id) {
408 $obj_id = ilObject::_lookupObjId($id);
409 $type = ilObject::_lookupType($obj_id);
410 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id);
411 $alt = ($objDefinition->isPlugin($type))
412 ? $lng->txt("icon") . " " . ilObjectPlugin::lookupTxtById($type, "obj_" . $type)
413 : $lng->txt("icon") . " " . $lng->txt("obj_" . $type);
414
415 $cgui->addItem(
416 "trash_id[]",
417 $id,
418 $title,
419 ilObject::_getIcon($obj_id, "small", $type),
420 $alt
421 );
422 }
423
424 $tpl->setContent($cgui->getHTML());
425 }
Confirmation screen class.
static getClassByType($a_obj_type)
Get class by type.
static lookupTxtById($plugin_id, $lang_var)
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
$type

References $ctrl, $id, $ilCtrl, $lng, $obj_definition, $title, $tpl, $type, ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getClassByType(), and ilObjectPlugin\lookupTxtById().

+ Here is the call graph for this function:

◆ deleteObjects()

ilRepUtilGUI::deleteObjects (   $a_cur_ref_id,
  $a_ref_ids 
)

Delete objects.

Definition at line 297 of file class.ilRepUtilGUI.php.

298 {
301
302 if (!is_array($a_ref_ids) || count($a_ref_ids) == 0) {
303 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
304 return false;
305 } else {
306 include_once("./Services/Repository/classes/class.ilRepUtil.php");
307 try {
308 ilRepUtil::deleteObjects($a_cur_ref_id, $a_ref_ids);
309 if ($ilSetting->get('enable_trash')) {
310 ilUtil::sendSuccess($lng->txt("info_deleted"), true);
311 } else {
312 ilUtil::sendSuccess($lng->txt("msg_removed"), true);
313 }
314 } catch (Exception $e) {
315 ilUtil::sendFailure($e->getMessage(), true);
316 return false;
317 }
318 }
319 }
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilSetting
Definition: privfeed.php:17

References $ilSetting, $lng, $settings, ilRepUtil\deleteObjects(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ handleMultiReferences()

ilRepUtilGUI::handleMultiReferences (   $a_obj_id,
  $a_ref_id,
  $a_form_name 
)

Build subitem list for multiple references.

Parameters
int$a_obj_id
int$a_ref_id
string$a_form_name
Returns
string

Definition at line 151 of file class.ilRepUtilGUI.php.

152 {
154 $ilAccess = $this->access;
156
157 // process
158
159 $all_refs = ilObject::_getAllReferences($a_obj_id);
160 if (sizeof($all_refs) > 1) {
161 $lng->loadLanguageModule("rep");
162
163 $may_delete_any = 0;
164 $counter = 0;
165 $items = array();
166 foreach ($all_refs as $mref_id) {
167 // not the already selected reference, no refs from trash
168 if ($mref_id != $a_ref_id && !$tree->isDeleted($mref_id)) {
169 if ($ilAccess->checkAccess("read", "", $mref_id)) {
170 $may_delete = false;
171 if ($ilAccess->checkAccess("delete", "", $mref_id)) {
172 $may_delete = true;
173 $may_delete_any++;
174 }
175
176 $items[] = array("id" => $mref_id,
177 "path" => array_shift($this->buildPath(array($mref_id))),
178 "delete" => $may_delete);
179 } else {
180 $counter++;
181 }
182 }
183 }
184
185
186 // render
187
188 $tpl = new ilTemplate("tpl.rep_multi_ref.html", true, true, "Services/Repository");
189
190 $tpl->setVariable("TXT_INTRO", $lng->txt("rep_multiple_reference_deletion_intro"));
191
192 if ($may_delete_any) {
193 $tpl->setVariable("TXT_INSTRUCTION", $lng->txt("rep_multiple_reference_deletion_instruction"));
194 }
195
196 if ($items) {
197 $var_name = "mref_id[]";
198
199 foreach ($items as $item) {
200 if ($item["delete"]) {
201 $tpl->setCurrentBlock("cbox");
202 $tpl->setVariable("ITEM_NAME", $var_name);
203 $tpl->setVariable("ITEM_VALUE", $item["id"]);
204 $tpl->parseCurrentBlock();
205 } else {
206 $tpl->setCurrentBlock("item_info");
207 $tpl->setVariable("TXT_ITEM_INFO", $lng->txt("rep_no_permission_to_delete"));
208 $tpl->parseCurrentBlock();
209 }
210
211 $tpl->setCurrentBlock("item");
212 $tpl->setVariable("ITEM_TITLE", $item["path"]);
213 $tpl->parseCurrentBlock();
214 }
215
216 if ($may_delete_any > 1) {
217 $tpl->setCurrentBlock("cbox");
218 $tpl->setVariable("ITEM_NAME", "sall_" . $a_ref_id);
219 $tpl->setVariable("ITEM_VALUE", "");
220 $tpl->setVariable("ITEM_ADD", " onclick=\"il.Util.setChecked('" .
221 $a_form_name . "', '" . $var_name . "', document." . $a_form_name .
222 ".sall_" . $a_ref_id . ".checked)\"");
223 $tpl->parseCurrentBlock();
224
225 $tpl->setCurrentBlock("item");
226 $tpl->setVariable("ITEM_TITLE", $lng->txt("select_all"));
227 $tpl->parseCurrentBlock();
228 }
229 }
230
231 if ($counter) {
232 $tpl->setCurrentBlock("add_info");
233 $tpl->setVariable(
234 "TXT_ADDITIONAL_INFO",
235 sprintf($lng->txt("rep_object_references_cannot_be_read"), $counter)
236 );
237 $tpl->parseCurrentBlock();
238 }
239
240 return $tpl->get();
241 }
242 }
static _getAllReferences($a_id)
get all reference ids of object
buildPath($ref_ids)
Build path with deep-link.
special template class to simplify handling of ITX/PEAR

References $access, $lng, $tpl, $tree, ilObject\_getAllReferences(), and buildPath().

Referenced by showDeleteConfirmation().

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

◆ removeObjectsFromSystem()

ilRepUtilGUI::removeObjectsFromSystem (   $a_ref_ids,
  $a_from_recovery_folder = false 
)

Remove objects from system.

Definition at line 324 of file class.ilRepUtilGUI.php.

325 {
327
328 if (!is_array($a_ref_ids) || count($a_ref_ids) == 0) {
329 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
330 return false;
331 } else {
332 include_once("./Services/Repository/classes/class.ilRepUtil.php");
333 try {
334 ilRepUtil::removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder);
335 ilUtil::sendSuccess($lng->txt("msg_removed"), true);
336 } catch (Exception $e) {
337 ilUtil::sendFailure($e->getMessage(), true);
338 return false;
339 }
340 }
341
342 return true;
343 }
static removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder=false)
remove objects from trash bin and all entries therefore every object needs a specific deleteObject() ...

References $lng, ilRepUtil\removeObjectsFromSystem(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ restoreObjects()

ilRepUtilGUI::restoreObjects (   $a_cur_ref_id,
  $a_ref_ids 
)

Restore objects from trash.

Parameters
integercurrent ref id
arrayarray of ref ids to be restored

Definition at line 274 of file class.ilRepUtilGUI.php.

275 {
277
278 if (!is_array($a_ref_ids) || count($a_ref_ids) == 0) {
279 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
280 return false;
281 } else {
282 try {
283 include_once("./Services/Repository/classes/class.ilRepUtil.php");
284 ilRepUtil::restoreObjects($a_cur_ref_id, $a_ref_ids);
285 ilUtil::sendSuccess($lng->txt("msg_undeleted"), true);
286 } catch (Exception $e) {
287 ilUtil::sendFailure($e->getMessage(), true);
288 return false;
289 }
290 }
291 return true;
292 }
static restoreObjects($a_cur_ref_id, $a_ref_ids)
Move objects from trash back to repository.

References $lng, ilRepUtil\restoreObjects(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ showDeleteConfirmation()

ilRepUtilGUI::showDeleteConfirmation (   $a_ids,
  $a_supress_message = false 
)

Show delete confirmation table.

Definition at line 75 of file class.ilRepUtilGUI.php.

76 {
81 $objDefinition = $this->obj_definition;
82
83 if (!is_array($a_ids) || count($a_ids) == 0) {
84 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
85 return false;
86 }
87
88 // Remove duplicate entries
89 $a_ids = array_unique((array) $a_ids);
90
91 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
92 $cgui = new ilConfirmationGUI();
93
94 if (!$a_supress_message) {
95 $msg = $lng->txt("info_delete_sure");
96
97 if (!$ilSetting->get('enable_trash')) {
98 $msg .= "<br/>" . $lng->txt("info_delete_warning_no_trash");
99 }
100
101 $cgui->setHeaderText($msg);
102 }
103 $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
104 $cgui->setCancel($lng->txt("cancel"), "cancelDelete");
105 $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
106
107 $form_name = "cgui_" . md5(uniqid());
108 $cgui->setFormName($form_name);
109
110 $deps = array();
111 foreach ($a_ids as $ref_id) {
112 $obj_id = ilObject::_lookupObjId($ref_id);
113 $type = ilObject::_lookupType($obj_id);
114 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id);
115 $alt = ($objDefinition->isPlugin($type))
116 ? $lng->txt("icon") . " " . ilObjectPlugin::lookupTxtById($type, "obj_" . $type)
117 : $lng->txt("icon") . " " . $lng->txt("obj_" . $type);
118
119 $title .= $this->handleMultiReferences($obj_id, $ref_id, $form_name);
120
121 $cgui->addItem(
122 "id[]",
123 $ref_id,
124 $title,
125 ilObject::_getIcon($obj_id, "small", $type),
126 $alt
127 );
128
129 ilObject::collectDeletionDependencies($deps, $ref_id, $obj_id, $type);
130 }
131 $deps_html = "";
132
133 if (is_array($deps) && count($deps) > 0) {
134 include_once("./Services/Repository/classes/class.ilRepDependenciesTableGUI.php");
135 $tab = new ilRepDependenciesTableGUI($deps);
136 $deps_html = "<br/><br/>" . $tab->getHTML();
137 }
138
139 $tpl->setContent($cgui->getHTML() . $deps_html);
140 return true;
141 }
static collectDeletionDependencies(&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
Collect deletion dependencies.
handleMultiReferences($a_obj_id, $a_ref_id, $a_form_name)
Build subitem list for multiple references.

References $ctrl, $ilCtrl, $ilSetting, $lng, $obj_definition, $settings, $tab, $title, $tpl, $type, ilObject\_lookupObjId(), ilObject\_lookupType(), ilObject\collectDeletionDependencies(), ilObjectFactory\getClassByType(), handleMultiReferences(), ilObjectPlugin\lookupTxtById(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ showTrashTable()

ilRepUtilGUI::showTrashTable (   $a_ref_id)

Get trashed objects for a container.

Parameters
intergerref id of container

Definition at line 249 of file class.ilRepUtilGUI.php.

250 {
254
255 $objects = $tree->getSavedNodeData($a_ref_id);
256
257 if (count($objects) == 0) {
258 ilUtil::sendInfo($lng->txt("msg_trash_empty"));
259 return;
260 }
261 include_once("./Services/Repository/classes/class.ilTrashTableGUI.php");
262 $ttab = new ilTrashTableGUI($this->parent_gui, "trash");
263 $ttab->setData($objects);
264
265 $tpl->setContent($ttab->getHTML());
266 }
TableGUI class for.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $lng, $tpl, $tree, and ilUtil\sendInfo().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilRepUtilGUI::$access
protected

Definition at line 42 of file class.ilRepUtilGUI.php.

Referenced by handleMultiReferences().

◆ $ctrl

ilRepUtilGUI::$ctrl
protected

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

Referenced by confirmRemoveFromSystemObject(), and showDeleteConfirmation().

◆ $lng

◆ $obj_definition

ilRepUtilGUI::$obj_definition
protected

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

Referenced by confirmRemoveFromSystemObject(), and showDeleteConfirmation().

◆ $settings

ilRepUtilGUI::$settings
protected

Definition at line 22 of file class.ilRepUtilGUI.php.

Referenced by deleteObjects(), and showDeleteConfirmation().

◆ $tpl

ilRepUtilGUI::$tpl
protected

◆ $tree

ilRepUtilGUI::$tree
protected

Definition at line 47 of file class.ilRepUtilGUI.php.

Referenced by buildPath(), handleMultiReferences(), and showTrashTable().


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