ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilRepUtilGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13 
20  function __construct($a_parent_gui, $a_parent_cmd = "")
21  {
22  $this->parent_gui = $a_parent_gui;
23  $this->parent_cmd = $a_parent_cmd;
24  }
25 
26 
30  function showDeleteConfirmation($a_ids, $a_supress_message = false)
31  {
32  global $lng, $ilSetting, $ilCtrl, $tpl, $objDefinition;
33 
34  if (!is_array($a_ids) || count($a_ids) == 0)
35  {
36  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
37  return false;
38  }
39 
40  // Remove duplicate entries
41  $a_ids = array_unique((array) $a_ids);
42 
43  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
44  $cgui = new ilConfirmationGUI();
45 
46  if(!$a_supress_message)
47  {
48  $msg = $lng->txt("info_delete_sure");
49 
50  if (!$ilSetting->get('enable_trash'))
51  {
52  $msg .= "<br/>".$lng->txt("info_delete_warning_no_trash");
53  }
54 
55  $cgui->setHeaderText($msg);
56  }
57  $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
58  $cgui->setCancel($lng->txt("cancel"), "cancelDelete");
59  $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
60 
61  $deps = array();
62  foreach ($a_ids as $ref_id)
63  {
64  $obj_id = ilObject::_lookupObjId($ref_id);
65  $type = ilObject::_lookupType($obj_id);
66  $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
67  $alt = ($objDefinition->isPlugin($type))
68  ? $lng->txt("icon")." ".ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type)
69  : $lng->txt("icon")." ".$lng->txt("obj_".$type);
70  $cgui->addItem("id[]", $ref_id, $title,
71  ilObject::_getIcon($obj_id, "small", $type),
72  $alt);
73 
74  ilObject::collectDeletionDependencies($deps, $ref_id, $obj_id, $type);
75  }
76  $deps_html = "";
77 
78  if (is_array($deps) && count($deps) > 0)
79  {
80  include_once("./Services/Repository/classes/class.ilRepDependenciesTableGUI.php");
81  $tab = new ilRepDependenciesTableGUI($deps);
82  $deps_html = "<br/><br/>".$tab->getHTML();
83  }
84 
85  $tpl->setContent($cgui->getHTML().$deps_html);
86  return true;
87  }
88 
94  function showTrashTable($a_ref_id)
95  {
96  global $tpl, $tree, $lng;
97 
98  $objects = $tree->getSavedNodeData($a_ref_id);
99 
100  if (count($objects) == 0)
101  {
102  ilUtil::sendInfo($lng->txt("msg_trash_empty"));
103  return;
104  }
105  include_once("./Services/Repository/classes/class.ilTrashTableGUI.php");
106  $ttab = new ilTrashTableGUI($this->parent_gui, "trash");
107  $ttab->setData($objects);
108 
109  $tpl->setContent($ttab->getHTML());
110  }
111 
118  function restoreObjects($a_cur_ref_id, $a_ref_ids)
119  {
120  global $lng;
121 
122  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
123  {
124  ilUtil::sendFailure($lng->txt("no_checkbox"),true);
125  return false;
126  }
127  else
128  {
129  try
130  {
131  include_once("./Services/Repository/classes/class.ilRepUtil.php");
132  ilRepUtil::restoreObjects($a_cur_ref_id, $a_ref_ids);
133  ilUtil::sendSuccess($lng->txt("msg_undeleted"),true);
134  }
135  catch (Exception $e)
136  {
137  ilUtil::sendFailure($e->getMessage(),true);
138  return false;
139  }
140  }
141  return true;
142  }
143 
147  function deleteObjects($a_cur_ref_id, $a_ref_ids)
148  {
149  global $ilSetting, $lng;
150 
151  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
152  {
153  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
154  return false;
155  }
156  else
157  {
158  include_once("./Services/Repository/classes/class.ilRepUtil.php");
159  try
160  {
161  ilRepUtil::deleteObjects($a_cur_ref_id, $a_ref_ids);
162  if ($ilSetting->get('enable_trash'))
163  {
164  ilUtil::sendSuccess($lng->txt("info_deleted"),true);
165  }
166  else
167  {
168  ilUtil::sendSuccess($lng->txt("msg_removed"),true);
169  }
170  }
171  catch (Exception $e)
172  {
173  ilUtil::sendFailure($e->getMessage(), true);
174  return false;
175  }
176  }
177  }
178 
182  function removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder = false)
183  {
184  global $lng;
185 
186  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
187  {
188  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
189  return false;
190  }
191  else
192  {
193  include_once("./Services/Repository/classes/class.ilRepUtil.php");
194  try
195  {
196  ilRepUtil::removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder);
197  ilUtil::sendSuccess($lng->txt("msg_removed"),true);
198  }
199  catch (Exception $e)
200  {
201  ilUtil::sendFailure($e->getMessage(), true);
202  return false;
203  }
204  }
205 
206  return true;
207  }
208 
209 
210 
211 }
212 ?>