ILIAS  Release_4_0_x_branch Revision 61816
 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  foreach ($a_ids as $ref_id)
62  {
63  $obj_id = ilObject::_lookupObjId($ref_id);
64  $type = ilObject::_lookupType($obj_id);
65  $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
66  $alt = ($objDefinition->isPlugin($type))
67  ? $lng->txt("icon")." ".ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type)
68  : $lng->txt("icon")." ".$lng->txt("obj_".$type);
69  $cgui->addItem("id[]", $ref_id, $title,
70  ilObject::_getIcon($obj_id, "small", $type),
71  $alt);
72  }
73 
74  $tpl->setContent($cgui->getHTML());
75  return true;
76  }
77 
83  function showTrashTable($a_ref_id)
84  {
85  global $tpl, $tree, $lng;
86 
87  $objects = $tree->getSavedNodeData($a_ref_id);
88 
89  if (count($objects) == 0)
90  {
91  ilUtil::sendInfo($lng->txt("msg_trash_empty"));
92  return;
93  }
94  include_once("./Services/Repository/classes/class.ilTrashTableGUI.php");
95  $ttab = new ilTrashTableGUI($this->parent_gui, "trash");
96  $ttab->setData($objects);
97 
98  $tpl->setContent($ttab->getHTML());
99  }
100 
107  function restoreObjects($a_cur_ref_id, $a_ref_ids)
108  {
109  global $lng;
110 
111  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
112  {
113  ilUtil::sendFailure($lng->txt("no_checkbox"),true);
114  return false;
115  }
116  else
117  {
118  try
119  {
120  include_once("./Services/Repository/classes/class.ilRepUtil.php");
121  ilRepUtil::restoreObjects($a_cur_ref_id, $a_ref_ids);
122  ilUtil::sendSuccess($lng->txt("msg_undeleted"),true);
123  }
124  catch (Exception $e)
125  {
126  ilUtil::sendFailure($e->getMessage(),true);
127  return false;
128  }
129  }
130  return true;
131  }
132 
136  function deleteObjects($a_cur_ref_id, $a_ref_ids)
137  {
138  global $ilSetting, $lng;
139 
140  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
141  {
142  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
143  return false;
144  }
145  else
146  {
147  include_once("./Services/Repository/classes/class.ilRepUtil.php");
148  try
149  {
150  ilRepUtil::deleteObjects($a_cur_ref_id, $a_ref_ids);
151  if ($ilSetting->get('enable_trash'))
152  {
153  ilUtil::sendSuccess($lng->txt("info_deleted"),true);
154  }
155  else
156  {
157  ilUtil::sendSuccess($lng->txt("msg_removed"),true);
158  }
159  }
160  catch (Exception $e)
161  {
162  ilUtil::sendFailure($e->getMessage(), true);
163  return false;
164  }
165  }
166  }
167 
171  function removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder = false)
172  {
173  global $lng;
174 
175  if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
176  {
177  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
178  return false;
179  }
180  else
181  {
182  include_once("./Services/Repository/classes/class.ilRepUtil.php");
183  try
184  {
185  ilRepUtil::removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder);
186  ilUtil::sendSuccess($lng->txt("msg_removed"),true);
187  }
188  catch (Exception $e)
189  {
190  ilUtil::sendFailure($e->getMessage(), true);
191  return false;
192  }
193  }
194 
195  return true;
196  }
197 
198 
199 
200 }
201 ?>