ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5include_once("./Services/Object/classes/class.ilObject2GUI.php");
6include_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
114 function initEditCustomForm($a_form)
115 {
116 $a_form->removeItemByPostVar("desc");
117
118 // description
119 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
120 $ta->setRows(2);
121 $ta->setInfo($this->lng->txt("itgr_desc_info"));
122 $a_form->addItem($ta);
123
124 // hide title
125 $cb = new ilCheckboxInputGUI($this->lng->txt("itgr_hide_title"), "hide_title");
126 $cb->setInfo($this->lng->txt("itgr_hide_title_info"));
127 $a_form->addItem($cb);
128
129 }
130
131
135 protected function afterSave(ilObject $a_new_object)
136 {
137 global $ilCtrl;
138
139 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
140 $ilCtrl->redirect($this, "listMaterials");
141 }
142
150 public function listMaterials()
151 {
152 global $tree, $ilTabs, $tpl;
153
154 $this->checkPermission("write");
155
156 $ilTabs->activateTab("materials");
157
158 $parent_ref_id = $tree->getParentId($this->object->getRefId());
159
160 include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
161 $gui = new ilObjectAddNewItemGUI($parent_ref_id);
162 $gui->setDisabledObjectTypes(array("itgr", "sess"));
163 $gui->setAfterCreationCallback($this->object->getRefId());
164 $gui->render();
165
166 include_once("./Modules/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php");
167 $tab = new ilItemGroupItemsTableGUI($this, "listMaterials");
168 $tpl->setContent($tab->getHTML());
169 }
170
174 public function saveItemAssignment()
175 {
176 global $ilCtrl;
177
178 $this->checkPermission("write");
179
180 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
181
182 $item_group_items = new ilItemGroupItems($this->object->getRefId());
183 $items = is_array($_POST['items'])
184 ? $_POST['items']
185 : array();
186 $items = ilUtil::stripSlashesArray($items);
187 $item_group_items->setItems($items);
188 $item_group_items->update();
189
190 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
191 $ilCtrl->redirect($this, "listMaterials");
192 }
193
194
198 function getTemplate()
199 {
200 $this->tpl->getStandardTemplate();
201 }
202
203
207 function setTabs()
208 {
209 global $ilAccess, $ilTabs, $ilCtrl, $ilHelp, $lng, $tree;
210
211 $ilHelp->setScreenIdComponent("itgr");
212
213 $parent_ref_id = $tree->getParentId($this->object->getRefId());
214 $parent_obj_id = ilObject::_lookupObjId($parent_ref_id);
215 $parent_type = ilObject::_lookupType($parent_obj_id);
216
217 include_once("./Services/Link/classes/class.ilLink.php");
218 $ilTabs->setBackTarget(
219 $lng->txt('obj_'.$parent_type),
220 ilLink::_getLink($parent_ref_id), "_top");
221
222 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
223 {
224 $ilTabs->addTab('materials',
225 $lng->txt('itgr_materials'),
226 $this->ctrl->getLinkTarget($this, 'listMaterials'));
227
228 $ilTabs->addTab('settings',
229 $lng->txt('settings'),
230 $this->ctrl->getLinkTarget($this, 'edit'));
231 }
232
233 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
234 {
235 $ilTabs->addTab("perm_settings",
236 $lng->txt('perm_settings'),
237 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
238 );
239 }
240 }
241
242
246 public static function _goto($a_target)
247 {
248 global $ilAccess, $ilErr, $lng, $tree;
249
250 $targets = explode('_',$a_target);
251 $ref_id = $targets[0];
252 $par_id = $tree->getParentId($ref_id);
253
254 if ($ilAccess->checkAccess("read", "", $par_id))
255 {
256 include_once("./Services/Link/classes/class.ilLink.php");
258 exit;
259 }
260 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
261 {
262 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
265 }
266
267 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
268 }
269
273 function gotoParent()
274 {
275 global $ilAccess, $ilErr, $lng, $tree;
276
277 $ref_id = $this->object->getRefId();
278 $par_id = $tree->getParentId($ref_id);
279
280 if ($ilAccess->checkAccess("read", "", $par_id))
281 {
282 include_once("./Services/Link/classes/class.ilLink.php");
284 exit;
285 }
286 }
287
293 public function afterSaveCallback(ilObject $a_obj)
294 {
295 // add new object to materials
296 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
297 $items = new ilItemGroupItems($this->object->getRefId());
298 $items->addItem($a_obj->getRefId());
299 $items->update();
300 }
301
307 function getEditFormCustomValues(&$a_values)
308 {
309 $a_values["hide_title"] = $this->object->getHideTitle();
310 }
311
318 {
319 $this->object->setHideTitle($a_form->getInput("hide_title"));
320 }
321
328 protected function initCreateForm($a_new_type)
329 {
330 $form = parent::initCreateForm($a_new_type);
331 $ta = $form->getItemByPostVar("desc");
332 $ta->setInfo($this->lng->txt("itgr_desc_info"));
333 return $form;
334 }
335
336
337}
338?>
$_GET["client_id"]
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
User Interface class for item groups.
getTemplate()
Get standard template.
updateCustom(ilPropertyFormGUI $a_form)
Update (custom part)
afterConstructor()
Initialisation.
initCreationForms($a_new_type)
Init creation froms.
afterSave(ilObject $a_new_object)
After save.
addLocatorItems()
Add session locator.
static _goto($a_target)
Goto item group.
initCreateForm($a_new_type)
Init object creation form.
getEditFormCustomValues(&$a_values)
Get edit form values (custom part)
executeCommand()
execute command
saveItemAssignment()
Save material assignment.
afterSaveCallback(ilObject $a_obj)
Custom callback after object is created (in parent containert.
gotoParent()
Goto item group.
listMaterials()
show material assignment
initEditCustomForm($a_form)
Init edit form, custom part.
New implementation of ilObjectGUI.
prepareOutput()
prepare output
checkPermission($a_perm, $a_cmd="")
Render add new item selector.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
addHeaderAction()
Add header action menu.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
This class represents a text area property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
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.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
$cmd
Definition: sahs_server.php:35