ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 

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 21 of file class.ilRepUtilGUI.php.

22  {
23  $this->parent_gui = $a_parent_gui;
24  $this->parent_cmd = $a_parent_cmd;
25  }

Member Function Documentation

◆ buildPath()

ilRepUtilGUI::buildPath (   $ref_ids)
protected

Build path with deep-link.

Parameters
array$ref_ids
Returns
array

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

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

Referenced by handleMultiReferences().

335  {
336  global $tree;
337 
338  include_once 'Services/Link/classes/class.ilLink.php';
339 
340  if(!count($ref_ids))
341  {
342  return false;
343  }
344 
345  $result = array();
346  foreach($ref_ids as $ref_id)
347  {
348  $path = "";
349  $path_full = $tree->getPathFull($ref_id);
350  foreach($path_full as $idx => $data)
351  {
352  if($idx)
353  {
354  $path .= " » ";
355  }
356  if($ref_id != $data['ref_id'])
357  {
358  $path .= $data['title'];
359  }
360  else
361  {
362  $path .= ('<a target="_top" href="'.
363  ilLink::_getLink($data['ref_id'],$data['type']).'">'.
364  $data['title'].'</a>');
365  }
366 
367  }
368 
369  $result[] = $path;
370  }
371  return $result;
372  }
$path
Definition: aliased.php:25
$result
Create styles array
The data for the language used.
$ref_id
Definition: sahs_server.php:39
+ 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 379 of file class.ilRepUtilGUI.php.

References $ilCtrl, $lng, $title, $tpl, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupType(), array, ilObjectFactory\getClassByType(), and ilObjectPlugin\lookupTxtById().

380  {
381  global $ilCtrl, $lng, $objDefinition, $tpl;
382  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
383 
384  if(!is_array($a_ids))
385  {
386  $a_ids = array($a_ids);
387  }
388 
389  $cgui = new ilConfirmationGUI();
390  $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
391  $cgui->setCancel($lng->txt("cancel"), "trash");
392  $cgui->setConfirm($lng->txt("confirm"), "removeFromSystem");
393  $cgui->setFormName("trash_confirmation");
394  $cgui->setHeaderText($lng->txt("info_delete_sure"));
395 
396  foreach($a_ids as $id)
397  {
398  $obj_id = ilObject::_lookupObjId($id);
399  $type = ilObject::_lookupType($obj_id);
400  $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
401  $alt = ($objDefinition->isPlugin($type))
402  ? $lng->txt("icon")." ".ilObjectPlugin::lookupTxtById($type, "obj_".$type)
403  : $lng->txt("icon")." ".$lng->txt("obj_".$type);
404 
405  $cgui->addItem("trash_id[]", $id, $title,
406  ilObject::_getIcon($obj_id, "small", $type),
407  $alt);
408  }
409 
410  $tpl->setContent($cgui->getHTML());
411  }
static getClassByType($a_obj_type)
Get class by type.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static lookupTxtById($plugin_id, $lang_var)
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static _lookupObjId($a_id)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $lng
Definition: privfeed.php:17
Confirmation screen class.
+ Here is the call graph for this function:

◆ deleteObjects()

ilRepUtilGUI::deleteObjects (   $a_cur_ref_id,
  $a_ref_ids 
)

Delete objects.

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

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

267  {
268  global $ilSetting, $lng;
269 
270  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
271  {
272  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
273  return false;
274  }
275  else
276  {
277  include_once("./Services/Repository/classes/class.ilRepUtil.php");
278  try
279  {
280  ilRepUtil::deleteObjects($a_cur_ref_id, $a_ref_ids);
281  if ($ilSetting->get('enable_trash'))
282  {
283  ilUtil::sendSuccess($lng->txt("info_deleted"),true);
284  }
285  else
286  {
287  ilUtil::sendSuccess($lng->txt("msg_removed"),true);
288  }
289  }
290  catch (Exception $e)
291  {
292  ilUtil::sendFailure($e->getMessage(), true);
293  return false;
294  }
295  }
296  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.
+ 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 104 of file class.ilRepUtilGUI.php.

References $counter, $lng, $tpl, ilObject\_getAllReferences(), array, and buildPath().

Referenced by showDeleteConfirmation().

105  {
106  global $lng, $ilAccess, $tree;
107 
108  // process
109 
110  $all_refs = ilObject::_getAllReferences($a_obj_id);
111  if(sizeof($all_refs) > 1)
112  {
113  $lng->loadLanguageModule("rep");
114 
115  $may_delete_any = 0;
116  $counter = 0;
117  $items = array();
118  foreach($all_refs as $mref_id)
119  {
120  // not the already selected reference, no refs from trash
121  if($mref_id != $a_ref_id && !$tree->isDeleted($mref_id))
122  {
123  if($ilAccess->checkAccess("read", "", $mref_id))
124  {
125  $may_delete = false;
126  if($ilAccess->checkAccess("delete", "", $mref_id))
127  {
128  $may_delete = true;
129  $may_delete_any++;
130  }
131 
132  $items[] = array("id" => $mref_id,
133  "path" => array_shift($this->buildPath(array($mref_id))),
134  "delete" => $may_delete);
135  }
136  else
137  {
138  $counter++;
139  }
140  }
141  }
142 
143 
144  // render
145 
146  $tpl = new ilTemplate("tpl.rep_multi_ref.html", true, true, "Services/Repository");
147 
148  $tpl->setVariable("TXT_INTRO", $lng->txt("rep_multiple_reference_deletion_intro"));
149 
150  if($may_delete_any)
151  {
152  $tpl->setVariable("TXT_INSTRUCTION", $lng->txt("rep_multiple_reference_deletion_instruction"));
153  }
154 
155  if($items)
156  {
157  $var_name = "mref_id[]";
158 
159  foreach($items as $item)
160  {
161  if($item["delete"])
162  {
163  $tpl->setCurrentBlock("cbox");
164  $tpl->setVariable("ITEM_NAME", $var_name);
165  $tpl->setVariable("ITEM_VALUE", $item["id"]);
166  $tpl->parseCurrentBlock();
167  }
168  else
169  {
170  $tpl->setCurrentBlock("item_info");
171  $tpl->setVariable("TXT_ITEM_INFO", $lng->txt("rep_no_permission_to_delete"));
172  $tpl->parseCurrentBlock();
173  }
174 
175  $tpl->setCurrentBlock("item");
176  $tpl->setVariable("ITEM_TITLE", $item["path"]);
177  $tpl->parseCurrentBlock();
178  }
179 
180  if($may_delete_any > 1)
181  {
182  $tpl->setCurrentBlock("cbox");
183  $tpl->setVariable("ITEM_NAME", "sall_".$a_ref_id);
184  $tpl->setVariable("ITEM_VALUE", "");
185  $tpl->setVariable("ITEM_ADD", " onclick=\"il.Util.setChecked('".
186  $a_form_name."', '".$var_name."', document.".$a_form_name.
187  ".sall_".$a_ref_id.".checked)\"");
188  $tpl->parseCurrentBlock();
189 
190  $tpl->setCurrentBlock("item");
191  $tpl->setVariable("ITEM_TITLE", $lng->txt("select_all"));
192  $tpl->parseCurrentBlock();
193  }
194  }
195 
196  if($counter)
197  {
198  $tpl->setCurrentBlock("add_info");
199  $tpl->setVariable("TXT_ADDITIONAL_INFO",
200  sprintf($lng->txt("rep_object_references_cannot_be_read"), $counter));
201  $tpl->parseCurrentBlock();
202  }
203 
204  return $tpl->get();
205  }
206  }
static _getAllReferences($a_id)
get all reference ids of object
global $tpl
Definition: ilias.php:8
$counter
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
buildPath($ref_ids)
Build path with deep-link.
+ 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 301 of file class.ilRepUtilGUI.php.

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

302  {
303  global $lng;
304 
305  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
306  {
307  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
308  return false;
309  }
310  else
311  {
312  include_once("./Services/Repository/classes/class.ilRepUtil.php");
313  try
314  {
315  ilRepUtil::removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder);
316  ilUtil::sendSuccess($lng->txt("msg_removed"),true);
317  }
318  catch (Exception $e)
319  {
320  ilUtil::sendFailure($e->getMessage(), true);
321  return false;
322  }
323  }
324 
325  return true;
326  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
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() ...
+ 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 237 of file class.ilRepUtilGUI.php.

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

238  {
239  global $lng;
240 
241  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
242  {
243  ilUtil::sendFailure($lng->txt("no_checkbox"),true);
244  return false;
245  }
246  else
247  {
248  try
249  {
250  include_once("./Services/Repository/classes/class.ilRepUtil.php");
251  ilRepUtil::restoreObjects($a_cur_ref_id, $a_ref_ids);
252  ilUtil::sendSuccess($lng->txt("msg_undeleted"),true);
253  }
254  catch (Exception $e)
255  {
256  ilUtil::sendFailure($e->getMessage(),true);
257  return false;
258  }
259  }
260  return true;
261  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static restoreObjects($a_cur_ref_id, $a_ref_ids)
Move objects from trash back to repository.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ showDeleteConfirmation()

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

Show delete confirmation table.

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

References $ilCtrl, $ilSetting, $lng, $ref_id, $tab, $title, $tpl, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupType(), array, ilObject\collectDeletionDependencies(), ilObjectFactory\getClassByType(), handleMultiReferences(), ilObjectPlugin\lookupTxtById(), and ilUtil\sendFailure().

32  {
33  global $lng, $ilSetting, $ilCtrl, $tpl, $objDefinition;
34 
35  if (!is_array($a_ids) || count($a_ids) == 0)
36  {
37  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
38  return false;
39  }
40 
41  // Remove duplicate entries
42  $a_ids = array_unique((array) $a_ids);
43 
44  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
45  $cgui = new ilConfirmationGUI();
46 
47  if(!$a_supress_message)
48  {
49  $msg = $lng->txt("info_delete_sure");
50 
51  if (!$ilSetting->get('enable_trash'))
52  {
53  $msg .= "<br/>".$lng->txt("info_delete_warning_no_trash");
54  }
55 
56  $cgui->setHeaderText($msg);
57  }
58  $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
59  $cgui->setCancel($lng->txt("cancel"), "cancelDelete");
60  $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
61 
62  $form_name = "cgui_".md5(uniqid());
63  $cgui->setFormName($form_name);
64 
65  $deps = array();
66  foreach ($a_ids as $ref_id)
67  {
68  $obj_id = ilObject::_lookupObjId($ref_id);
69  $type = ilObject::_lookupType($obj_id);
70  $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
71  $alt = ($objDefinition->isPlugin($type))
72  ? $lng->txt("icon")." ".ilObjectPlugin::lookupTxtById($type, "obj_".$type)
73  : $lng->txt("icon")." ".$lng->txt("obj_".$type);
74 
75  $title .= $this->handleMultiReferences($obj_id, $ref_id, $form_name);
76 
77  $cgui->addItem("id[]", $ref_id, $title,
78  ilObject::_getIcon($obj_id, "small", $type),
79  $alt);
80 
81  ilObject::collectDeletionDependencies($deps, $ref_id, $obj_id, $type);
82  }
83  $deps_html = "";
84 
85  if (is_array($deps) && count($deps) > 0)
86  {
87  include_once("./Services/Repository/classes/class.ilRepDependenciesTableGUI.php");
88  $tab = new ilRepDependenciesTableGUI($deps);
89  $deps_html = "<br/><br/>".$tab->getHTML();
90  }
91 
92  $tpl->setContent($cgui->getHTML().$deps_html);
93  return true;
94  }
static getClassByType($a_obj_type)
Get class by type.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static lookupTxtById($plugin_id, $lang_var)
static collectDeletionDependencies(&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
Collect deletion dependencies.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static _lookupObjId($a_id)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$ref_id
Definition: sahs_server.php:39
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
handleMultiReferences($a_obj_id, $a_ref_id, $a_form_name)
Build subitem list for multiple references.
Confirmation screen class.
+ 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 213 of file class.ilRepUtilGUI.php.

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

214  {
215  global $tpl, $tree, $lng;
216 
217  $objects = $tree->getSavedNodeData($a_ref_id);
218 
219  if (count($objects) == 0)
220  {
221  ilUtil::sendInfo($lng->txt("msg_trash_empty"));
222  return;
223  }
224  include_once("./Services/Repository/classes/class.ilTrashTableGUI.php");
225  $ttab = new ilTrashTableGUI($this->parent_gui, "trash");
226  $ttab->setData($objects);
227 
228  $tpl->setContent($ttab->getHTML());
229  }
TableGUI class for.
global $tpl
Definition: ilias.php:8
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

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