ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjItemGroupGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Object/classes/class.ilObject2GUI.php");
6 include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php");
7 
21 {
25  protected function afterConstructor()
26  {
27  global $lng;
28 
29  $lng->loadLanguageModule("itgr");
30 
31  $this->ctrl->saveParameter($this, array("ref_id"));
32  }
33 
37  final function getType()
38  {
39  return "itgr";
40  }
41 
45  function executeCommand()
46  {
47  global $ilTabs, $lng, $ilAccess, $tpl, $ilCtrl, $ilLocator;
48 
49  $next_class = $this->ctrl->getNextClass($this);
50  $cmd = $this->ctrl->getCmd();
51 
52  switch($next_class)
53  {
54  case 'ilinfoscreengui':
55  $this->prepareOutput();
56  $this->addHeaderAction();
57  $this->infoScreen();
58  break;
59 
60  case 'ilpermissiongui':
61  $this->prepareOutput();
62  $ilTabs->activateTab("perm_settings");
63  $this->addHeaderAction();
64  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
65  $perm_gui =& new ilPermissionGUI($this);
66  $ret = $this->ctrl->forwardCommand($perm_gui);
67  break;
68 
69  case "ilcommonactiondispatchergui":
70  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
72  $this->ctrl->forwardCommand($gui);
73  break;
74 
75  default:
76  $cmd = $this->ctrl->getCmd("listMaterials");
77  $this->prepareOutput();
78  $this->addHeaderAction();
79  $this->$cmd();
80  break;
81  }
82  }
83 
90  public function addLocatorItems()
91  {
92  global $ilLocator, $ilAccess;
93 
94  if (is_object($this->object) && $ilAccess->checkAccess("write", "", $this->object->getRefId()))
95  {
96  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "listMaterials"), "", $_GET["ref_id"]);
97  }
98  }
99 
100  protected function initCreationForms($a_new_type)
101  {
102  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type)
103  );
104 
105  return $forms;
106  }
107 
111  protected function afterSave(ilObject $a_new_object)
112  {
113  global $ilCtrl;
114 
115  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
116  $ilCtrl->redirect($this, "listMaterials");
117  }
118 
126  public function listMaterials()
127  {
128  global $tree, $ilTabs, $tpl;
129 
130  $this->checkPermission("write");
131 
132  $ilTabs->activateTab("materials");
133 
134  $parent_ref_id = $tree->getParentId($this->object->getRefId());
135 
136  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
137  $gui = new ilObjectAddNewItemGUI($parent_ref_id);
138  $gui->setDisabledObjectTypes(array("itgr", "sess"));
139  $gui->setAfterCreationCallback($this->object->getRefId());
140  $gui->render();
141 
142  include_once("./Modules/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php");
143  $tab = new ilItemGroupItemsTableGUI($this, "listMaterials");
144  $tpl->setContent($tab->getHTML());
145  }
146 
150  public function saveItemAssignment()
151  {
152  global $ilCtrl;
153 
154  $this->checkPermission("write");
155 
156  include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
157 
158  $item_group_items = new ilItemGroupItems($this->object->getRefId());
159  $items = is_array($_POST['items'])
160  ? $_POST['items']
161  : array();
162  $items = ilUtil::stripSlashesArray($items);
163  $item_group_items->setItems($items);
164  $item_group_items->update();
165 
166  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
167  $ilCtrl->redirect($this, "listMaterials");
168  }
169 
170 
174  function getTemplate()
175  {
176  $this->tpl->getStandardTemplate();
177  }
178 
179 
183  function setTabs()
184  {
185  global $ilAccess, $ilTabs, $ilCtrl, $ilHelp, $lng, $tree;
186 
187  $ilHelp->setScreenIdComponent("itgr");
188 
189  $parent_ref_id = $tree->getParentId($this->object->getRefId());
190  $parent_obj_id = ilObject::_lookupObjId($parent_ref_id);
191  $parent_type = ilObject::_lookupType($parent_obj_id);
192 
193  include_once("./Services/Link/classes/class.ilLink.php");
194  $ilTabs->setBackTarget(
195  $lng->txt('obj_'.$parent_type),
196  ilLink::_getLink($parent_ref_id), "_top");
197 
198  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
199  {
200  $ilTabs->addTab('materials',
201  $lng->txt('itgr_materials'),
202  $this->ctrl->getLinkTarget($this, 'listMaterials'));
203 
204  $ilTabs->addTab('settings',
205  $lng->txt('settings'),
206  $this->ctrl->getLinkTarget($this, 'edit'));
207  }
208 
209  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
210  {
211  $ilTabs->addTab("perm_settings",
212  $lng->txt('perm_settings'),
213  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
214  );
215  }
216  }
217 
218 
222  function _goto($a_target)
223  {
224  global $ilAccess, $ilErr, $lng, $tree;
225 
226  $targets = explode('_',$a_target);
227  $ref_id = $targets[0];
228  $par_id = $tree->getParentId($ref_id);
229 
230  if ($ilAccess->checkAccess("read", "", $par_id))
231  {
232  include_once("./Services/Link/classes/class.ilLink.php");
234  exit;
235  }
236  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
237  {
238  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
241  }
242 
243  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
244  }
245 
249  function gotoParent()
250  {
251  global $ilAccess, $ilErr, $lng, $tree;
252 
253  $ref_id = $this->object->getRefId();
254  $par_id = $tree->getParentId($ref_id);
255 
256  if ($ilAccess->checkAccess("read", "", $par_id))
257  {
258  include_once("./Services/Link/classes/class.ilLink.php");
260  exit;
261  }
262  }
263 
269  public function afterSaveCallback(ilObject $a_obj)
270  {
271  // add new object to materials
272  include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
273  $items = new ilItemGroupItems($this->object->getRefId());
274  $items->addItem($a_obj->getRefId());
275  $items->update();
276  }
277 
278 }
279 ?>