ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
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(array &$a_values)
308  {
309  $a_values["hide_title"] = $this->object->getHideTitle();
310  }
311 
317  function updateCustom(ilPropertyFormGUI $a_form)
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 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
gotoParent()
Goto item group.
addItem($a_item_ref_id)
Add one item.
global $ilErr
Definition: raiseError.php:16
addLocatorItems()
Add session locator.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
removeItemByPostVar($a_post_var)
Remove Item.
static _goto($a_target)
Goto item group.
executeCommand()
execute command
This class represents a property form user interface.
New implementation of ilObjectGUI.
$_GET["client_id"]
afterSave(ilObject $a_new_object)
After save.
Class ilObject Basic functions for all objects.
$cmd
Definition: sahs_server.php:35
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).
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.
afterConstructor()
Initialisation.
static _lookupObjId($a_id)
getTemplate()
Get standard template.
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.
Create styles array
The data for the language used.
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.
User Interface class for item groups.
Create new PHPExcel object
obj_idprivate
Render add new item selector.
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)
http redirect to other 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