ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAdministrationCommandGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23 */
24 
35 {
39  protected $tpl;
40 
44  protected $settings;
45 
49  protected $error;
50 
54  protected $tree;
55 
59  protected $obj_definition;
60 
61  protected $ctrl = null;
62  protected $lng = null;
63  private $container = null;
64 
68  public function __construct($a_container)
69  {
70  global $DIC;
71 
72  $this->tpl = $DIC["tpl"];
73  $this->settings = $DIC->settings();
74  $this->error = $DIC["ilErr"];
75  $this->tree = $DIC->repositoryTree();
76  $this->obj_definition = $DIC["objDefinition"];
77  $ilCtrl = $DIC->ctrl();
78  $lng = $DIC->language();
79 
80  $this->container = $a_container;
81  $this->ctrl = $ilCtrl;
82  $this->lng = $lng;
83  }
84 
88  public function getContainer()
89  {
90  return $this->container;
91  }
92 
96  public function delete()
97  {
98  $tpl = $this->tpl;
101 
102  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
103 
104  $to_delete = array();
105  if ((int) $_GET['item_ref_id']) {
106  $to_delete = array(
107  (int) $_GET['item_ref_id']
108  );
109  }
110 
111  if (isset($_POST['id']) and is_array($_POST['id'])) {
112  $to_delete = $_POST['id'];
113  }
114 
115  if (!$to_delete) {
116  $ilErr->raiseError($this->lng->txt('no_checkbox'), $ilErr->MESSAGE);
117  }
118 
119  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
120  $confirm = new ilConfirmationGUI();
121  $confirm->setFormAction($this->ctrl->getFormActionByClass(get_class($this->getContainer()), 'cancel'));
122  $confirm->setHeaderText('');
123  $confirm->setCancel($this->lng->txt('cancel'), 'cancelDelete');
124  $confirm->setConfirm($this->lng->txt('delete'), 'performDelete');
125 
126  foreach ($to_delete as $delete) {
127  $obj_id = ilObject :: _lookupObjId($delete);
128  $type = ilObject :: _lookupType($obj_id);
129 
130  $confirm->addItem(
131  'id[]',
132  $delete,
133  call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id),
135  );
136  }
137 
138  $msg = $this->lng->txt("info_delete_sure");
139 
140  if (!$ilSetting->get('enable_trash')) {
141  $msg .= "<br/>" . $this->lng->txt("info_delete_warning_no_trash");
142  }
143  ilUtil::sendQuestion($msg);
144 
145  $tpl->setContent($confirm->getHTML());
146  }
147 
151  public function performDelete()
152  {
153  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
154 
155  include_once './Services/Object/classes/class.ilObjectGUI.php';
156  $_SESSION['saved_post'] = $_POST['id'];
157  $object = new ilObjectGUI(array(), 0, false, false);
158  $object->confirmedDeleteObject();
159  return true;
160  }
161 
165  public function cut()
166  {
167  $tree = $this->tree;
168 
169  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
170 
171  $_GET['ref_id'] = $tree->getParentId((int) $_GET['item_ref_id']);
172 
173  include_once './Services/Container/classes/class.ilContainerGUI.php';
174  $container = new ilContainerGUI(array(), 0, false, false);
175  $container->cutObject();
176  return true;
177  }
178 
183  public function showMoveIntoObjectTree()
184  {
185  $objDefinition = $this->obj_definition;
186 
187  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
188 
189  $obj_id = ilObject :: _lookupObjId((int) $_GET['ref_id']);
190  $type = ilObject :: _lookupType($obj_id);
191 
192  $location = $objDefinition->getLocation($type);
193  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
194 
195  // create instance
196  include_once($location . "/class." . $class_name . ".php");
197  $container = new $class_name(array(), (int) $_GET['ref_id'], true, false);
198  $container->showMoveIntoObjectTreeObject();
199  return true;
200  }
201 
207  {
208  $objDefinition = $this->obj_definition;
209 
210  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
211 
212  $obj_id = ilObject :: _lookupObjId((int) $_GET['ref_id']);
213  $type = ilObject :: _lookupType($obj_id);
214 
215  $location = $objDefinition->getLocation($type);
216  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
217 
218  // create instance
219  include_once($location . "/class." . $class_name . ".php");
220  $container = new $class_name(array(), (int) $_GET['ref_id'], true, false);
221  $container->showLinkIntoMultipleObjectsTreeObject();
222  return true;
223  }
224 
228  public function link()
229  {
230  $tree = $this->tree;
231 
232  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
233 
234  $_GET['ref_id'] = $tree->getParentId((int) $_GET['item_ref_id']);
235 
236  include_once './Services/Container/classes/class.ilContainerGUI.php';
237  $container = new ilContainerGUI(array(), 0, false, false);
238  $container->linkObject();
239  return true;
240  }
241 
245  public function paste()
246  {
247  $objDefinition = $this->obj_definition;
248 
249  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
250  $_GET['ref_id'] = (int) $_GET['item_ref_id'];
251 
252  $obj_id = ilObject :: _lookupObjId((int) $_GET['item_ref_id']);
253  $type = ilObject :: _lookupType($obj_id);
254 
255  $location = $objDefinition->getLocation($type);
256  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
257 
258  // create instance
259  include_once($location . "/class." . $class_name . ".php");
260  $container = new $class_name(array(), (int) $_GET['item_ref_id'], true, false);
261  $container->pasteObject();
262  return true;
263  }
264 
266  {
267  $objDefinition = $this->obj_definition;
268 
269  $this->ctrl->setReturnByClass(get_class($this->getContainer()), '');
270 
271  $obj_id = ilObject :: _lookupObjId((int) $_GET['ref_id']);
272  $type = ilObject :: _lookupType($obj_id);
273 
274  $location = $objDefinition->getLocation($type);
275  $class_name = "ilObj" . $objDefinition->getClassName($type) . 'GUI';
276 
277  // create instance
278  include_once($location . "/class." . $class_name . ".php");
279  $container = new $class_name(array(), (int) $_GET['ref_id'], true, false);
280  $container->performPasteIntoMultipleObjectsObject();
281  return true;
282  }
283 }
static getClassByType($a_obj_type)
Get class by type.
global $ilErr
Definition: raiseError.php:16
$_SESSION["AccountId"]
$type
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$location
Definition: buildRTE.php:44
Handles Administration commands (cut, delete paste)
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
global $ilCtrl
Definition: ilias.php:18
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
Class ilContainerGUI.
$_POST["username"]
Confirmation screen class.