ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjStudyProgrammeGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once("./Services/Container/classes/class.ilContainerGUI.php");
6require_once("./Services/AccessControl/classes/class.ilObjRole.php");
7require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
8require_once("./Services/AccessControl/classes/class.ilPermissionGUI.php");
9require_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
10require_once("./Services/Object/classes/class.ilObjectAddNewItemGUI.php");
11require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeTreeGUI.php");
12require_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
13require_once("./Modules/StudyProgramme/classes/types/class.ilStudyProgrammeTypeGUI.php");
14require_once("./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeAdvancedMetadataRecord.php");
15require_once("./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php");
16require_once("./Services/Object/classes/class.ilObjectCopyGUI.php");
17require_once("./Services/Repository/classes/class.ilRepUtil.php");
18
38 public $ctrl;
39
43 public $tpl;
44
48 public $tabs_gui;
49
53 protected $ilAccess;
54
58 protected $toolbar;
59
63 protected $ilLocator;
64
68 public $tree;
69
73 public $object;
74
78 protected $ilLog;
79
83 public $ilias;
84
88 protected $help;
89
90
91 public function __construct() {
92 global $tpl, $ilCtrl, $ilAccess, $ilToolbar, $ilLocator, $tree, $lng, $ilLog, $ilias, $ilHelp;
93
94 parent::ilContainerGUI(array(), (int) $_GET['ref_id'], true, false);
95
96 $this->tpl = $tpl;
97 $this->ctrl = $ilCtrl;
98 $this->ilAccess = $ilAccess;
99 $this->ilLocator = $ilLocator;
100 $this->tree = $tree;
101 $this->toolbar = $ilToolbar;
102 $this->ilLog = $ilLog;
103 $this->ilias = $ilias;
104 $this->type = "prg";
105 $this->help = $ilHelp;
106
107 $lng->loadLanguageModule("prg");
108 }
109
110
111 public function executeCommand() {
112 $cmd = $this->ctrl->getCmd();
113 $next_class = $this->ctrl->getNextClass($this);
114
115 if ($cmd == "") {
116 $cmd = "view";
117 }
118
119 $this->addToNavigationHistory();
120
121 parent::prepareOutput();
122
123 // show repository tree
124 $this->showRepTree();
125
126 switch ($next_class) {
127 case "ilinfoscreengui":
128 $this->tabs_gui->setTabActive(self::TAB_INFO);
129 $this->denyAccessIfNotAnyOf(array("read", "visible"));
130 $info = new ilInfoScreenGUI($this);
131 $this->fillInfoScreen($info);
132 $this->ctrl->forwardCommand($info);
133
134 // I guess this is how it was supposed to work, but it doesn't... it won't respect our sub-id and sub-type when creating the objects!
135 // So we reimplemented the stuff in the method parseInfoScreen()
136 // $info = new ilInfoScreenGUI($this);
137 // $amd_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'orgu', $this->object->getId(), 'orgu_type', $this->object->getOrgUnitTypeId());
138 // $amd_gui->setInfoObject($info);
139 // $amd_gui->setSelectedOnly(true);
140 // $amd_gui->parse();
141 // $this->ctrl->forwardCommand($info);
142 break;
143 case 'ilpermissiongui':
144 $this->tabs_gui->setTabActive('perm_settings');
145 $ilPermissionGUI = new ilPermissionGUI($this);
146 $this->ctrl->forwardCommand($ilPermissionGUI);
147 break;
148 case "ilcommonactiondispatchergui":
149 require_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
151 $this->ctrl->forwardCommand($gui);
152 break;
153 case "ilobjstudyprogrammesettingsgui":
154 $this->denyAccessIfNot("write");
155
156 $this->getSubTabs('settings');
157 $this->tabs_gui->setTabActive(self::TAB_SETTINGS);
158 $this->tabs_gui->setSubTabActive('settings');
159
160 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgrammeSettingsGUI.php");
161 $gui = new ilObjStudyProgrammeSettingsGUI($this, $this->ref_id);
162 $this->ctrl->forwardCommand($gui);
163 break;
164 /*case 'iltranslationgui':
165 $this->denyAccessIfNot("write");
166
167 $this->getSubTabs('settings');
168 $this->tabs_gui->setTabActive("settings");
169 $this->tabs_gui->setSubTabActive('edit_translations');
170
171 $ilTranslationGui = new ilTranslationGUI($this);
172 $this->ctrl->forwardCommand($ilTranslationGui);
173 break;*/
174 case "ilobjstudyprogrammemembersgui":
175 $this->denyAccessIfNot("write");
176 $this->tabs_gui->setTabActive(self::TAB_MEMBERS);
177 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgrammeMembersGUI.php");
178 $gui = new ilObjStudyProgrammeMembersGUI($this, $this->ref_id);
179 $this->ctrl->forwardCommand($gui);
180 break;
181 case "ilobjstudyprogrammetreegui":
182 $this->denyAccessIfNot("write");
183
184 $this->getSubTabs($cmd);
185 $this->setContentSubTabs();
186 $this->tabs_gui->setTabActive(self::TAB_VIEW_CONTENT);
187 $this->tabs_gui->setSubTabActive(self::SUBTAB_VIEW_TREE);
188
189 // disable admin panel
190 $_SESSION["il_cont_admin_panel"] = false;
191
192 $gui = new ilObjStudyProgrammeTreeGUI($this->id);
193 $this->ctrl->forwardCommand($gui);
194 break;
195 case 'ilstudyprogrammetypegui':
196 $this->tabs_gui->setTabActive('subtypes');
197
198 $types_gui = new ilStudyProgrammeTypeGUI($this);
199 $this->ctrl->forwardCommand($types_gui);
200 break;
201 case 'ilobjectcopygui':
202 $gui = new ilobjectcopygui($this);
203 $this->ctrl->forwardCommand($gui);
204 break;
205 case false:
206 $this->getSubTabs($cmd);
207 switch ($cmd) {
208 case "cancelDelete":
209 $cmd = "view";
210 case "create":
211 case "save":
212 case "view":
213 case "cancel":
214 case "edit":
215 $this->$cmd();
216 break;
217 case "delete":
218 $this->tabs_gui->clearTargets();
219 $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this));
220 parent::deleteObject();
221 break;
222 case 'confirmedDelete':
223 parent::confirmedDeleteObject();
224 break;
225 case 'editAdvancedSettings':
226 $this->tabs_gui->setTabActive("settings");
227 $this->tabs_gui->setSubTabActive('edit_advanced_settings');
228 //$this->setSubTabsSettings('edit_advanced_settings');
229 $this->editAdvancedSettings();
230 break;
231 case 'updateAdvancedSettings':
232 $this->tabs_gui->setTabActive("settings");
233 $this->tabs_gui->setSubTabActive('edit_advanced_settings');
234 //$this->setSubTabsSettings('edit_advanced_settings');
235 $this->updateAdvancedSettings();
236 break;
237 case "infoScreen":
238 $this->ctrl->redirectByClass("ilInfoScreenGUI", "showSummary");
239 break;
240 case 'getAsynchItemList':
241 parent::getAsynchItemListObject();
242 break;
243 case 'trash':
244 case 'undelete':
245 case 'confirmRemoveFromSystem':
246 case 'removeFromSystem':
247 $cmd .= "Object";
248 $this->$cmd();
249 break;
250 /*case 'editSettings':
251 $this->tabs_gui->setTabActive("settings");
252 $this->setSubTabsSettings('edit_settings');
253 $this->editSettings();
254 break;
255 case '':
256 case 'view':
257 case 'render':
258 case 'cancel':
259 case 'cancelDelete':
260 $this->view();
261 break;
262 case 'create':
263
264 parent::createObject();
265 break;
266 case 'save':
267 parent::saveObject();
268 break;
269 case 'delete':
270 $this->tabs_gui->clearTargets();
271 $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this));
272 parent::deleteObject();
273 break;
274 case 'confirmedDelete':
275 parent::confirmedDeleteObject();
276 break;
277 case 'cut':
278 $this->tabs_gui->clearTargets();
279 $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this));
280 parent::cutObject();
281 break;
282 case 'clear':
283 parent::clearObject();
284 break;
285 case 'enableAdministrationPanel':
286 parent::enableAdministrationPanelObject();
287 break;
288 case 'disableAdministrationPanel':
289 parent::disableAdministrationPanelObject();
290 break;
291 case 'editSettings':
292 $this->tabs_gui->setTabActive("settings");
293 $this->setSubTabsSettings('edit_settings');
294 $this->editSettings();
295 break;
296 case 'updateSettings':
297 $this->tabs_gui->setTabActive("settings");
298 $this->setSubTabsSettings('edit_settings');
299 $this->updateSettings();
300 break;
301 case 'editAdvancedSettings':
302 $this->tabs_gui->setTabActive("settings");
303 $this->setSubTabsSettings('edit_advanced_settings');
304 $this->editAdvancedSettings();
305 break;
306 case 'updateAdvancedSettings':
307 $this->tabs_gui->setTabActive("settings");
308 $this->setSubTabsSettings('edit_advanced_settings');
309 $this->updateAdvancedSettings();
310 break;*/
311 default:
312 throw new ilException("ilObjStudyProgrammeGUI: Command not supported: $cmd");
313 }
314 break;
315 default:
316 throw new ilException("ilObjStudyProgrammeGUI: Can't forward to next class $next_class");
317 }
318 }
319
320
324 protected function create() {
325 parent::createObject();
326 }
327
328
334 protected function save() {
335 parent::saveObject();
336
337 if($this->ctrl->isAsynch()) {
338 $form = $this->getAsyncCreationForm();
339 $form->setValuesByPost();
340 echo ilAsyncOutputHandler::encodeAsyncResponse(array("cmd" =>$this->ctrl->getCmd(), "success"=>false, "errors"=>$form->getErrors()));
341 exit();
342 }
343 }
344
345
351 protected function cancel() {
352 $async_response = ilAsyncOutputHandler::encodeAsyncResponse(array("cmd" =>"cancel", "success"=>false));
353
354 ilAsyncOutputHandler::handleAsyncOutput("", $async_response, false);
355
356 parent::cancelCreation();
357 }
358
359
366 protected function afterSave(ilObject $a_new_object)
367 {
368 // set default sort to manual
369 $settings = new ilContainerSortingSettings($a_new_object->getId());
370 $settings->setSortMode(ilContainer::SORT_MANUAL);
371 $settings->setSortDirection(ilContainer::SORT_DIRECTION_ASC);
372 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_CREATION);
373 $settings->setSortNewItemsPosition(ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM);
374 $settings->save();
375
376 $async_response = ilAsyncOutputHandler::encodeAsyncResponse(array("cmd" =>"cancel", "success"=>true, "message"=>$this->lng->txt("object_added")));
377
378 ilAsyncOutputHandler::handleAsyncOutput("", $async_response, false);
379
380 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
381
382 $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
384 $this->ctrl->getLinkTarget($this, "edit", "", false, false)));
385 }
386
387
391 protected function view() {
392 $this->denyAccessIfNot("read");
393 $this->tabs_gui->setTabActive(self::TAB_VIEW_CONTENT);
394
395 parent::renderObject();
396 }
397
403 protected function initAdvancedSettingsForm() {
404 $form = new ilPropertyFormGUI();
405 $form->setFormAction($this->ctrl->getFormAction($this));
406 $form->addCommandButton('updateAdvancedSettings', $this->lng->txt('save'));
407 $form->addCommandButton('editAdvancedSettings', $this->lng->txt('cancel'));
408
409 return $form;
410 }
411
415 protected function editAdvancedSettings() {
416 if (!$this->ilAccess->checkAccess("write", "", $this->ref_id)) {
417 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
418 $this->ctrl->redirect($this);
419 }
420 $form = $this->initAdvancedSettingsForm();
421 $gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR, 'prg', $this->object->getId(), 'prg_type', $this->object->getSubtypeId());
422 $gui->setPropertyForm($form);
423 $gui->parse();
424 $this->tpl->setContent($form->getHTML());
425 }
426
427
431 protected function updateAdvancedSettings() {
432 if (!$this->ilAccess->checkAccess("write", "", $this->ref_id)) {
433 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
434 $this->ctrl->redirect($this);
435 }
436
437 $form = $this->initAdvancedSettingsForm();
438 $gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR, 'prg', $this->object->getId(), 'prg_type', $this->object->getSubtypeId());
439 $gui->setPropertyForm($form);
440 $form->checkInput();
441 $gui->parse();
442 if ($gui->importEditFormPostValues()) {
443 $gui->writeEditForm();
444 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
445 $this->ctrl->redirect($this, 'editAdvancedSettings');
446 } else {
447 $this->tpl->setContent($form->getHTML());
448 }
449 }
450
451
459 protected function initCreationForms($a_new_type) {
460 return array( self::CFORM_NEW => $this->initCreateForm($a_new_type));
461 }
462
463
470 public function getAsyncCreationForm() {
471 $asyncForm = new ilAsyncPropertyFormGUI();
472
473 $tmp_forms = $this->initCreationForms('prg');
474 $asyncForm->cloneForm($tmp_forms[self::CFORM_NEW]);
475 $asyncForm->setAsync(true);
476
477 return $asyncForm;
478 }
479
481 // HELPERS
483
484 protected function checkAccess($a_which) {
485 return $this->ilAccess->checkAccess($a_which, "", $this->ref_id);
486 }
487
488 protected function denyAccessIfNot($a_perm) {
489 return $this->denyAccessIfNotAnyOf(array($a_perm));
490 }
491
492 protected function denyAccessIfNotAnyOf($a_perms) {
493 foreach ($a_perms as $perm) {
494 if ($this->checkAccess($perm)) {
495 return;
496 }
497 }
498
499 if ($this->checkAccess("visible")) {
500 ilUtil::sendFailure($this->lng->txt("msg_no_perm_write"));
501 $this->ctrl->redirectByClass('ilinfoscreengui', '');
502 }
503
504 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->WARNING);
505 }
506
507 const TAB_VIEW_CONTENT = "view_content";
508 const SUBTAB_VIEW_TREE = "view_tree";
509 const TAB_INFO = "info_short";
510 const TAB_SETTINGS = "settings";
511 const TAB_MEMBERS = "members";
512 const TAB_SUBTYPES = "subtypes";
513
517 public function getTabs() {
518 $this->help->setScreenIdComponent("prg");
519 if ($this->checkAccess("read")) {
520 $this->tabs_gui->addTab( self::TAB_VIEW_CONTENT
521 , $this->lng->txt("content")
522 , $this->getLinkTarget("view"));
523 }
524
525 if ($this->checkAccess("visible")) {
526 $this->tabs_gui->addTab( self::TAB_INFO
527 , $this->lng->txt("info_short")
528 , $this->getLinkTarget("info_short")
529 );
530 }
531
532 if ($this->checkAccess("write")) {
533 $this->tabs_gui->addTab( self::TAB_SETTINGS
534 , $this->lng->txt("settings")
535 , $this->getLinkTarget("settings")
536 );
537 //Maybe some time this will be: if ($this->checkAccess("manage_members")) {
538 $this->tabs_gui->addTab( self::TAB_MEMBERS
539 , $this->lng->txt("members")
540 , $this->getLinkTarget("members")
541 );
542 }
543
544 parent::getTabs($this->tabs_gui);
545 }
546
552 public function getSubTabs($a_parent_tab) {
553 switch($a_parent_tab) {
556 case 'view':
557 if($this->checkAccess("read")) {
558 $this->tabs_gui->addSubTab(self::TAB_VIEW_CONTENT, $this->lng->txt("view"), $this->getLinkTarget("view"));
559 }
560
561 if($this->checkAccess("write")) {
562 $this->tabs_gui->addSubTab(self::SUBTAB_VIEW_TREE, $this->lng->txt("cntr_manage"), $this->getLinkTarget(self::SUBTAB_VIEW_TREE));
563 }
564 break;
565 case 'settings':
566 case 'editAdvancedSettings':
567 $this->tabs_gui->addSubTab('settings', $this->lng->txt('settings'), $this->getLinkTarget('settings'));
568 //$this->tabs_gui->addSubTab("edit_translations", $this->lng->txt("obj_multilinguality"), $this->ctrl->getLinkTargetByClass("iltranslationgui", "editTranslations"));
569
570 $type = ilStudyProgrammeType::find($this->object->getSubtypeId());
571
572 if (!is_null($type) && count($type->getAssignedAdvancedMDRecords(true))) {
573 $this->tabs_gui->addSubTab('edit_advanced_settings', $this->lng->txt('prg_adv_settings'), $this->ctrl->getLinkTarget($this, 'editAdvancedSettings'));
574 }
575 break;
576 }
577
578 }
579
580
584 public function setContentSubTabs() {
585 return;
586 }
587
588
596 protected function getLinkTarget($a_cmd) {
597 if ($a_cmd == "info_short") {
598 return $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary");
599 }
600 if ($a_cmd == "settings") {
601 return $this->ctrl->getLinkTargetByClass("ilobjstudyprogrammesettingsgui", "view");
602 }
603 if($a_cmd == self::SUBTAB_VIEW_TREE) {
604 return $this->ctrl->getLinkTargetByClass("ilobjstudyprogrammetreegui", "view");
605 }
606 if ($a_cmd == "members") {
607 return $this->ctrl->getLinkTargetByClass("ilobjstudyprogrammemembersgui", "view");
608 }
609 if($a_cmd == "subtypes") {
610 return $this->ctrl->getLinkTargetByClass("ilstudyprogrammetypegui", "listTypes");
611 }
612
613 return $this->ctrl->getLinkTarget($this, $a_cmd);
614 }
615
616
622 protected function fillInfoScreen($a_info_screen) {
623 require_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
624 require_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
625 require_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
626 require_once('./Services/ADT/classes/class.ilADTFactory.php');
627
628 $type = ilStudyProgrammeType::find($this->object->getSubtypeId());
629 if (!$type) {
630 return;
631 }
632
633 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'prg', $this->object->getId(), 'prg_type', $this->object->getSubtypeId());
634 $record_gui->setInfoObject($a_info_screen);
635 $record_gui->parse();
636 }
637
638 protected function edit(){
639 $this->denyAccessIfNot("write");
640
641 $this->getSubTabs('settings');
642 $this->tabs_gui->setTabActive(self::TAB_SETTINGS);
643 $this->tabs_gui->setSubTabActive('settings');
644
645 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgrammeSettingsGUI.php");
646 $gui = new ilObjStudyProgrammeSettingsGUI($this, $this->ref_id);
647 $this->ctrl->setCmd("view");
648 $this->ctrl->forwardCommand($gui);
649 }
650
657 public static function _goto($a_target) {
658 global $ilAccess, $ilErr, $ilCtrl;
659 $id = explode("_", $a_target);
660 $ilCtrl->setTargetScript("ilias.php");
661 $ilCtrl->initBaseClass("ilRepositoryGUI");
662 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $id[0]);
663
664 $ilCtrl->redirectByClass(array( "ilRepositoryGUI", "ilobjstudyprogrammegui" ), "view");
665 }
666
667 public function addToNavigationHistory(){
668 global $ilNavigationHistory;
669
670 if(!$this->getCreationMode() &&
671 $this->ilAccess->checkAccess('read', '', $_GET['ref_id']))
672 {
673 $link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", "frameset");
674
675 $ilNavigationHistory->addItem($_GET['ref_id'],
676 $link, 'prg');
677 }
678 }
679}
680
681?>
$_GET["client_id"]
$_SESSION["AccountId"]
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
Class ilAsyncPropertyFormGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Class ilContainerGUI.
const SORT_NEW_ITEMS_ORDER_CREATION
const SORT_NEW_ITEMS_POSITION_BOTTOM
const SORT_DIRECTION_ASC
Base class for ILIAS Exception handling.
Class ilInfoScreenGUI.
logging
Definition: class.ilLog.php:19
Class ilObjStudyProgrammeGUI class.
initAdvancedSettingsForm()
Initialize the form for editing advanced meta data.
getSubTabs($a_parent_tab)
Adds subtabs based on the parent tab.
cancel()
Cancel the object generation.
updateAdvancedSettings()
Update Advanced Metadata.
executeCommand()
execute command note: this method is overwritten in all container objects
fillInfoScreen($a_info_screen)
Adding meta-data to the info-screen.
getLinkTarget($a_cmd)
Generates a link based on a cmd.
editAdvancedSettings()
Edit Advanced Metadata.
getAsyncCreationForm()
Method for implementing async windows-output Should be moved into core to enable async requests on cr...
getTabs()
Adds the default tabs to the gui.
static _goto($a_target)
_goto Deep link
setContentSubTabs()
Disable default content subtabs.
initCreationForms($a_new_type)
Overwritten from ilObjectGUI since copy and import are not implemented.
afterSave(ilObject $a_new_object)
After save hook Sets the sorting of the container correctly.
Class ilObjStudyProgrammeMembersGUI.
Class ilObjStudyProgrammeSettingsGUI.
Class ilObjStudyProgrammeTreeGUI Generates the manage view for ilTrainingProgramme-Repository objects...
initCreateForm($a_new_type)
Init object creation form.
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
getCreationMode()
get creation mode
Class ilObject Basic functions for all objects.
getRefId()
get reference id @access public
getId()
get object id @access public
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
Class ilStudyProgrammeTypeGUI.
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.
$info
Definition: example_052.php:80
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
$cmd
Definition: sahs_server.php:35