ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
125
129 protected function afterSave(ilObject $a_new_object)
130 {
131 global $ilCtrl;
132
133 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
134 $ilCtrl->redirect($this, "listMaterials");
135 }
136
144 public function listMaterials()
145 {
146 global $tree, $ilTabs, $tpl;
147
148 $this->checkPermission("write");
149
150 $ilTabs->activateTab("materials");
151
152 $parent_ref_id = $tree->getParentId($this->object->getRefId());
153
154 include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
155 $gui = new ilObjectAddNewItemGUI($parent_ref_id);
156 $gui->setDisabledObjectTypes(array("itgr", "sess"));
157 $gui->setAfterCreationCallback($this->object->getRefId());
158 $gui->render();
159
160 include_once("./Modules/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php");
161 $tab = new ilItemGroupItemsTableGUI($this, "listMaterials");
162 $tpl->setContent($tab->getHTML());
163 }
164
168 public function saveItemAssignment()
169 {
170 global $ilCtrl;
171
172 $this->checkPermission("write");
173
174 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
175
176 $item_group_items = new ilItemGroupItems($this->object->getRefId());
177 $items = is_array($_POST['items'])
178 ? $_POST['items']
179 : array();
180 $items = ilUtil::stripSlashesArray($items);
181 $item_group_items->setItems($items);
182 $item_group_items->update();
183
184 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
185 $ilCtrl->redirect($this, "listMaterials");
186 }
187
188
192 function getTemplate()
193 {
194 $this->tpl->getStandardTemplate();
195 }
196
197
201 function setTabs()
202 {
203 global $ilAccess, $ilTabs, $ilCtrl, $ilHelp, $lng, $tree;
204
205 $ilHelp->setScreenIdComponent("itgr");
206
207 $parent_ref_id = $tree->getParentId($this->object->getRefId());
208 $parent_obj_id = ilObject::_lookupObjId($parent_ref_id);
209 $parent_type = ilObject::_lookupType($parent_obj_id);
210
211 include_once("./Services/Link/classes/class.ilLink.php");
212 $ilTabs->setBackTarget(
213 $lng->txt('obj_'.$parent_type),
214 ilLink::_getLink($parent_ref_id), "_top");
215
216 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
217 {
218 $ilTabs->addTab('materials',
219 $lng->txt('itgr_materials'),
220 $this->ctrl->getLinkTarget($this, 'listMaterials'));
221
222 $ilTabs->addTab('settings',
223 $lng->txt('settings'),
224 $this->ctrl->getLinkTarget($this, 'edit'));
225 }
226
227 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId()))
228 {
229 $ilTabs->addTab("perm_settings",
230 $lng->txt('perm_settings'),
231 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
232 );
233 }
234 }
235
236
240 public static function _goto($a_target)
241 {
242 global $ilAccess, $ilErr, $lng, $tree;
243
244 $targets = explode('_',$a_target);
245 $ref_id = $targets[0];
246 $par_id = $tree->getParentId($ref_id);
247
248 if ($ilAccess->checkAccess("read", "", $par_id))
249 {
250 include_once("./Services/Link/classes/class.ilLink.php");
252 exit;
253 }
254 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
255 {
256 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
259 }
260
261 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
262 }
263
267 function gotoParent()
268 {
269 global $ilAccess, $ilErr, $lng, $tree;
270
271 $ref_id = $this->object->getRefId();
272 $par_id = $tree->getParentId($ref_id);
273
274 if ($ilAccess->checkAccess("read", "", $par_id))
275 {
276 include_once("./Services/Link/classes/class.ilLink.php");
278 exit;
279 }
280 }
281
287 public function afterSaveCallback(ilObject $a_obj)
288 {
289 // add new object to materials
290 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
291 $items = new ilItemGroupItems($this->object->getRefId());
292 $items->addItem($a_obj->getRefId());
293 $items->update();
294 }
295
296}
297?>
$_GET["client_id"]
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
User Interface class for item groups.
getTemplate()
Get standard template.
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.
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.
initCreateForm($a_new_type)
Init object creation form.
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 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