ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $tabs;
26 
30  protected $help;
31 
35  protected $error;
36 
37 
41  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
42  {
43  global $DIC;
44  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
45 
46  $this->lng = $DIC->language();
47  $this->tabs = $DIC->tabs();
48  $this->access = $DIC->access();
49  $this->tpl = $DIC["tpl"];
50  $this->ctrl = $DIC->ctrl();
51  $this->locator = $DIC["ilLocator"];
52  $this->tree = $DIC->repositoryTree();
53  $this->help = $DIC["ilHelp"];
54  $this->error = $DIC["ilErr"];
55  }
56 
60  protected function afterConstructor()
61  {
62  $lng = $this->lng;
63 
64  $lng->loadLanguageModule("itgr");
65 
66  $this->ctrl->saveParameter($this, array("ref_id"));
67  }
68 
72  final public function getType()
73  {
74  return "itgr";
75  }
76 
80  public function executeCommand()
81  {
82  $ilTabs = $this->tabs;
83  $lng = $this->lng;
84  $ilAccess = $this->access;
85  $tpl = $this->tpl;
87  $ilLocator = $this->locator;
88 
89  $next_class = $this->ctrl->getNextClass($this);
90  $cmd = $this->ctrl->getCmd();
91 
92  switch ($next_class) {
93  case 'ilinfoscreengui':
94  $this->prepareOutput();
95  $this->addHeaderAction();
96  $this->infoScreen();
97  break;
98 
99  case 'ilpermissiongui':
100  $this->prepareOutput();
101  $ilTabs->activateTab("perm_settings");
102  $this->addHeaderAction();
103  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
104  $perm_gui = new ilPermissionGUI($this);
105  $ret = $this->ctrl->forwardCommand($perm_gui);
106  break;
107 
108  case "ilcommonactiondispatchergui":
109  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
111  $this->ctrl->forwardCommand($gui);
112  break;
113 
114  default:
115  $cmd = $this->ctrl->getCmd("listMaterials");
116  $this->prepareOutput();
117  $this->addHeaderAction();
118  $this->$cmd();
119  break;
120  }
121  }
122 
129  public function addLocatorItems()
130  {
131  $ilLocator = $this->locator;
132  $ilAccess = $this->access;
133 
134  if (is_object($this->object) && $ilAccess->checkAccess("write", "", $this->object->getRefId())) {
135  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "listMaterials"), "", $_GET["ref_id"]);
136  }
137  }
138 
139  protected function initCreationForms($a_new_type)
140  {
141  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type)
142  );
143 
144  return $forms;
145  }
146 
152  public function initEditCustomForm(ilPropertyFormGUI $a_form)
153  {
154  $a_form->removeItemByPostVar("desc");
155 
156  // description
157  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
158  $ta->setRows(2);
159  $ta->setInfo($this->lng->txt("itgr_desc_info"));
160  $a_form->addItem($ta);
161 
162  // show title
163  $cb = new ilCheckboxInputGUI($this->lng->txt("itgr_show_title"), "show_title");
164  $cb->setInfo($this->lng->txt("itgr_show_title_info"));
165  $a_form->addItem($cb);
166 
167  // behaviour
168  include_once("./Modules/ItemGroup/classes/class.ilItemGroupBehaviour.php");
170  $si = new ilSelectInputGUI($this->lng->txt("itgr_behaviour"), "behaviour");
171  $si->setInfo($this->lng->txt("itgr_behaviour_info"));
172  $si->setOptions($options);
173  $cb->addSubItem($si);
174  }
175 
176 
180  protected function afterSave(ilObject $a_new_object)
181  {
183 
184  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
185  $ilCtrl->redirect($this, "listMaterials");
186  }
187 
195  public function listMaterials()
196  {
197  $tree = $this->tree;
198  $ilTabs = $this->tabs;
199  $tpl = $this->tpl;
200 
201  $this->checkPermission("write");
202 
203  $ilTabs->activateTab("materials");
204 
205  $parent_ref_id = $tree->getParentId($this->object->getRefId());
206 
207  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
208  $gui = new ilObjectAddNewItemGUI($parent_ref_id);
209  $gui->setDisabledObjectTypes(array("itgr", "sess"));
210  $gui->setAfterCreationCallback($this->object->getRefId());
211  $gui->render();
212 
213  include_once("./Modules/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php");
214  $tab = new ilItemGroupItemsTableGUI($this, "listMaterials");
215  $tpl->setContent($tab->getHTML());
216  }
217 
221  public function saveItemAssignment()
222  {
224 
225  $this->checkPermission("write");
226 
227  include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
228 
229  $item_group_items = new ilItemGroupItems($this->object->getRefId());
230  $items = is_array($_POST['items'])
231  ? $_POST['items']
232  : array();
233  $items = ilUtil::stripSlashesArray($items);
234  $item_group_items->setItems($items);
235  $item_group_items->update();
236 
237  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
238  $ilCtrl->redirect($this, "listMaterials");
239  }
240 
241 
245  public function getTemplate()
246  {
247  $this->tpl->getStandardTemplate();
248  }
249 
250 
254  public function setTabs()
255  {
256  $ilAccess = $this->access;
257  $ilTabs = $this->tabs;
259  $ilHelp = $this->help;
260  $lng = $this->lng;
261  $tree = $this->tree;
262 
263  $ilHelp->setScreenIdComponent("itgr");
264 
265  $parent_ref_id = $tree->getParentId($this->object->getRefId());
266  $parent_obj_id = ilObject::_lookupObjId($parent_ref_id);
267  $parent_type = ilObject::_lookupType($parent_obj_id);
268 
269  include_once("./Services/Link/classes/class.ilLink.php");
270  $ilTabs->setBackTarget(
271  $lng->txt('obj_' . $parent_type),
272  ilLink::_getLink($parent_ref_id),
273  "_top"
274  );
275 
276  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
277  $ilTabs->addTab(
278  'materials',
279  $lng->txt('itgr_materials'),
280  $this->ctrl->getLinkTarget($this, 'listMaterials')
281  );
282 
283  $ilTabs->addTab(
284  'settings',
285  $lng->txt('settings'),
286  $this->ctrl->getLinkTarget($this, 'edit')
287  );
288  }
289 
290  if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId())) {
291  $ilTabs->addTab(
292  "perm_settings",
293  $lng->txt('perm_settings'),
294  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
295  );
296  }
297  }
298 
299 
303  public static function _goto($a_target)
304  {
305  global $DIC;
306 
307  $ilAccess = $DIC->access();
308  $ilErr = $DIC["ilErr"];
309  $lng = $DIC->language();
310  $tree = $DIC->repositoryTree();
311 
312  $targets = explode('_', $a_target);
313  $ref_id = $targets[0];
314  $par_id = $tree->getParentId($ref_id);
315 
316  if ($ilAccess->checkAccess("read", "", $par_id)) {
317  include_once("./Services/Link/classes/class.ilLink.php");
319  exit;
320  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
321  ilUtil::sendFailure(sprintf(
322  $lng->txt("msg_no_perm_read_item"),
324  ), true);
326  }
327 
328  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
329  }
330 
334  public function gotoParent()
335  {
336  $ilAccess = $this->access;
338  $lng = $this->lng;
339  $tree = $this->tree;
340 
341  $ref_id = $this->object->getRefId();
342  $par_id = $tree->getParentId($ref_id);
343 
344  if ($ilAccess->checkAccess("read", "", $par_id)) {
345  include_once("./Services/Link/classes/class.ilLink.php");
347  exit;
348  }
349  }
350 
356  public function afterSaveCallback(ilObject $a_obj)
357  {
358  // add new object to materials
359  include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
360  $items = new ilItemGroupItems($this->object->getRefId());
361  $items->addItem($a_obj->getRefId());
362  $items->update();
363  }
364 
370  public function getEditFormCustomValues(array &$a_values)
371  {
372  $a_values["show_title"] = !$this->object->getHideTitle();
373  $a_values["behaviour"] = $this->object->getBehaviour();
374  }
375 
381  public function updateCustom(ilPropertyFormGUI $a_form)
382  {
383  $this->object->setHideTitle(!$a_form->getInput("show_title"));
384  include_once("./Modules/ItemGroup/classes/class.ilItemGroupBehaviour.php");
385  $behaviour = ($a_form->getInput("show_title"))
386  ? $a_form->getInput("behaviour")
388  $this->object->setBehaviour($behaviour);
389  }
390 
397  protected function initCreateForm($a_new_type)
398  {
399  $form = parent::initCreateForm($a_new_type);
400  $ta = $form->getItemByPostVar("desc");
401  $ta->setInfo($this->lng->txt("itgr_desc_info"));
402  return $form;
403  }
404 }
gotoParent()
Goto item group.
addItem($a_item_ref_id)
Add one item.
addLocatorItems()
Add session locator.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
static _goto($a_target)
Goto item group.
executeCommand()
execute command
This class represents a selection list property in a property form.
This class represents a property form user interface.
New implementation of ilObjectGUI.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
afterSave(ilObject $a_new_object)
After save.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
listMaterials()
show material assignment
addItem($a_item)
Add Item (Property, SectionHeader).
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
getEditFormCustomValues(array &$a_values)
Get edit form values (custom part)
initEditCustomForm(ilPropertyFormGUI $a_form)
Init edit form, custom part.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
initCreateForm($a_new_type)
Init object creation form.
if(isset($_POST['submit'])) $form
afterConstructor()
Initialisation.
static _lookupObjId($a_id)
getTemplate()
Get standard template.
static getAll()
Get all behaviours.
updateCustom(ilPropertyFormGUI $a_form)
Update (custom part)
Item group items.
saveItemAssignment()
Save material assignment.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
exit
Definition: backend.php:16
User Interface class for item groups.
Render add new item selector.
removeItemByPostVar($a_post_var, $a_remove_unused_headers=false)
Remove Item.
This class represents a text area property in a property form.
$ret
Definition: parser.php:6
getRefId()
get reference id public
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static redirect($a_script)
addHeaderAction()
Add header action menu.
afterSaveCallback(ilObject $a_obj)
Custom callback after object is created (in parent containert.
$_POST["username"]
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call