ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjectGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
14{
18 protected $ilErr;
19
23 protected $locator;
24
28 protected $user;
29
33 protected $access;
34
38 protected $rbacsystem;
39
43 protected $settings;
44
48 protected $rbacreview;
49
53 protected $toolbar;
54
56
57
64
70 public $tpl;
71
77 public $tree;
78
84 public $lng;
85
91 public $data;
92
98 public $object;
99 public $ref_id;
100 public $obj_id;
101 public $maxcount; // contains number of child objects
102 public $formaction; // special formation (array "cmd" => "formaction")
103 public $return_location; // special return location (array "cmd" => "location")
104 public $target_frame; // special target frame (array "cmd" => "location")
105 protected $tmp_import_dir; // directory used during import
106
108 public $actions;
110 public $omit_locator = false;
111
115 protected $tabs_gui = null;
116
120 protected $ctrl;
121
126
127 const CFORM_NEW = 1;
128 const CFORM_IMPORT = 2;
129 const CFORM_CLONE = 3;
130
134 protected $favourites;
135
143 public function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
144 {
145 global $DIC;
146
147 $this->locator = $DIC["ilLocator"];
148 $this->user = $DIC->user();
149 $this->access = $DIC->access();
150 $this->settings = $DIC->settings();
151 $this->rbacreview = $DIC->rbac()->review();
152 $this->toolbar = $DIC->toolbar();
153 $this->rbacsystem = $DIC->rbac()->system();
154 $this->object_service = $DIC->object();
155 $objDefinition = $DIC["objDefinition"];
156 $tpl = $DIC["tpl"];
157 $tree = $DIC->repositoryTree();
158 $ilCtrl = $DIC->ctrl();
159 $ilErr = $DIC["ilErr"];
160 $lng = $DIC->language();
161 $ilTabs = $DIC->tabs();
162
163 $this->favourites = new ilFavouritesManager();
164
165 $this->ilias = $DIC["ilias"];
166
170 $this->tabs_gui = $ilTabs;
171
172 if (!isset($ilErr)) {
173 $ilErr = new ilErrorHandling();
174 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,'errorHandler'));
175 } else {
176 $this->ilErr = $ilErr;
177 }
178
179 $this->objDefinition = $objDefinition;
180 $this->tpl = $tpl;
181 $this->html = "";
182 $this->ctrl = $ilCtrl;
183
184 $params = array("ref_id");
185
186 if (!$a_call_by_reference) {
187 $params = array("ref_id","obj_id");
188 }
189
190 $this->ctrl->saveParameter($this, $params);
191
192 $this->lng = $lng;
193 $this->tree = $tree;
194 $this->formaction = array();
195 $this->return_location = array();
196 $this->target_frame = array();
197 $this->actions = "";
198 $this->sub_objects = "";
199
200 $this->data = $a_data;
201 $this->id = $a_id;
202 $this->call_by_reference = $a_call_by_reference;
203 $this->prepare_output = $a_prepare_output;
204 $this->creation_mode = false;
205
206 $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
207 $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
208
209 if ($this->id != 0) {
210 $this->link_params = "ref_id=" . $this->ref_id;
211 }
212
213 // get the object
214 $this->assignObject();
215
216 // set context
217 if (is_object($this->object)) {
218 if ($this->call_by_reference && $this->ref_id == $_GET["ref_id"]) {
219 $this->ctrl->setContext(
220 $this->object->getId(),
221 $this->object->getType()
222 );
223 }
224 }
225
226 //prepare output
227 if ($a_prepare_output) {
228 $this->prepareOutput();
229 }
230 }
231
237 protected function getObjectService()
238 {
240 }
241
245 public function executeCommand()
246 {
247 $next_class = $this->ctrl->getNextClass($this);
248 $cmd = $this->ctrl->getCmd();
249
250 switch ($next_class) {
251 default:
252 $this->prepareOutput();
253 if (!$cmd) {
254 $cmd = "view";
255 }
256 $cmd .= "Object";
257 $this->$cmd();
258
259 break;
260 }
261
262 return true;
263 }
264
265
269 public function withReferences()
270 {
271 return $this->call_by_reference;
272 }
273
280 public function setCreationMode($a_mode = true)
281 {
282 $this->creation_mode = $a_mode;
283 }
284
288 public function getCreationMode()
289 {
290 return $this->creation_mode;
291 }
292
293 protected function assignObject()
294 {
295 // TODO: it seems that we always have to pass only the ref_id
296 //echo "<br>ilObjectGUIassign:".get_class($this).":".$this->id.":<br>";
297 if ($this->id != 0) {
298 if ($this->call_by_reference) {
299 $this->object = ilObjectFactory::getInstanceByRefId($this->id);
300 } else {
301 $this->object = ilObjectFactory::getInstanceByObjId($this->id);
302 }
303 }
304 }
305
309 public function prepareOutput($a_show_subobjects = true)
310 {
311 $ilLocator = $this->locator;
314
315 $this->tpl->loadStandardTemplate();
316 // administration prepare output
317 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
318 $this->addAdminLocatorItems();
319 $tpl->setLocator();
320
321 // ilUtil::sendInfo();
323
324 $this->setTitleAndDescription();
325
326 if ($this->getCreationMode() != true) {
327 $this->setAdminTabs();
328 }
329
330 return false;
331 }
332 // set locator
333 $this->setLocator();
334 // catch feedback message
335 // ilUtil::sendInfo();
337
338 // in creation mode (parent) object and gui object
339 // do not fit
340 if ($this->getCreationMode() == true) {
341 // repository vs. workspace
342 if ($this->call_by_reference) {
343 // get gui class of parent and call their title and description method
344 $obj_type = ilObject::_lookupType($_GET["ref_id"], true);
345 $class_name = $this->objDefinition->getClassName($obj_type);
346 $class = strtolower("ilObj" . $class_name . "GUI");
347 $class_path = $this->ctrl->lookupClassPath($class);
348 include_once($class_path);
349 $class_name = $this->ctrl->getClassForClasspath($class_path);
350 //echo "<br>instantiating parent for title and description";
351 $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
352 // the next line prevents the header action menu being shown
353 $this->parent_gui_obj->setCreationMode(true);
354 $this->parent_gui_obj->setTitleAndDescription();
355 }
356 } else {
357 // set title and description and title icon
358 $this->setTitleAndDescription();
359
360 // set tabs
361 $this->setTabs();
362
363
364 // fileupload support
365 require_once './Services/FileUpload/classes/class.ilFileUploadUtil.php';
366 if (ilFileUploadUtil::isUploadAllowed($this->ref_id, $this->object->getType())) {
368 }
369 }
370
371 return true;
372 }
373
377 protected function setTitleAndDescription()
378 {
379 if (!is_object($this->object)) {
380 if ((int) $_REQUEST["crtptrefid"] > 0) {
381 $cr_obj_id = ilObject::_lookupObjId((int) $_REQUEST["crtcb"]);
382 $this->tpl->setTitle(ilObject::_lookupTitle($cr_obj_id));
383 $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
384 }
385 return;
386 }
387 $this->tpl->setTitle($this->object->getPresentationTitle());
388 $this->tpl->setDescription($this->object->getLongDescription());
389
390 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
391 // alt text would be same as heading -> empty alt text
392 $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", $this->object->getType()));
393 } else {
394 $this->tpl->setTitleIcon(
395 ilObject::_getIcon("", "big", $this->object->getType()),
396 $this->lng->txt("obj_" . $this->object->getType())
397 );
398 }
399
400 include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
401 $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
402 $lgui->initItem($this->object->getRefId(), $this->object->getId(), $this->object->getType());
403 $this->tpl->setAlertProperties($lgui->getAlertProperties());
404 }
405
413 protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
414 {
415 $ilAccess = $this->access;
416
417 if (!$this->creation_mode && $this->object) {
418 include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
419 $dispatcher = new ilCommonActionDispatcherGUI(
421 $ilAccess,
422 $this->object->getType(),
423 $this->ref_id,
424 $this->object->getId()
425 );
426
427 $dispatcher->setSubObject($a_sub_type, $a_sub_id);
428
429 include_once "Services/Object/classes/class.ilObjectListGUI.php";
430 ilObjectListGUI::prepareJSLinks(
431 $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
432 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
433 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
434 );
435
436 $lg = $dispatcher->initHeaderAction();
437
438 if (is_object($lg)) {
439 // to enable add to desktop / remove from desktop
440 if ($this instanceof ilDesktopItemHandling) {
441 $lg->setContainerObject($this);
442 }
443
444 // enable multi download
445 $lg->enableMultiDownload(true);
446
447 // comments settings are always on (for the repository)
448 // should only be shown if active or permission to toggle
449 include_once "Services/Notes/classes/class.ilNote.php";
450 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
451 $ilAccess->checkAccess("edit_permissions", "", $this->ref_id) ||
452 ilNote::commentsActivated($this->object->getId(), 0, $this->object->getType())) {
453 $lg->enableComments(true);
454 }
455
456 $lg->enableNotes(true);
457 $lg->enableTags(true);
458 }
459
460 return $lg;
461 }
462 }
463
469 protected function insertHeaderAction($a_list_gui)
470 {
471 if (!is_object($this->object) || ilContainer::_lookupContainerSetting($this->object->getId(), "hide_top_actions")) {
472 return;
473 }
474
475 if (is_object($a_list_gui)) {
476 $this->tpl->setHeaderActionMenu($a_list_gui->getHeaderAction());
477 }
478 }
479
483 protected function addHeaderAction()
484 {
485 $this->insertHeaderAction($this->initHeaderAction());
486 }
487
491 protected function redrawHeaderActionObject()
492 {
494
495 $lg = $this->initHeaderAction();
496 echo $lg->getHeaderAction();
497
498 // we need to add onload code manually (rating, comments, etc.)
499 echo $tpl->getOnLoadCodeForAsynch();
500
501 exit;
502 }
503
504
505
510 protected function setTabs()
511 {
512 $this->getTabs();
513 }
514
519 final protected function setAdminTabs()
520 {
521 $this->getAdminTabs();
522 }
523
527 public function getAdminTabs()
528 {
530
531 if ($this->checkPermissionBool("visible,read")) {
532 $this->tabs_gui->addTarget(
533 "view",
534 $this->ctrl->getLinkTarget($this, "view"),
535 array("", "view"),
536 get_class($this)
537 );
538 }
539
540 if ($this->checkPermissionBool("edit_permission")) {
541 $this->tabs_gui->addTarget(
542 "perm_settings",
543 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
544 "",
545 "ilpermissiongui"
546 );
547 }
548 }
549
550
551 public function getHTML()
552 {
553 return $this->html;
554 }
555
556
563 private function setActions($a_actions = "")
564 {
565 if (is_array($a_actions)) {
566 foreach ($a_actions as $name => $lng) {
567 $this->actions[$name] = array("name" => $name, "lng" => $lng);
568 }
569 } else {
570 $this->actions = "";
571 }
572 }
573
580 private function setSubObjects($a_sub_objects = "")
581 {
582 if (is_array($a_sub_objects)) {
583 foreach ($a_sub_objects as $name => $options) {
584 $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
585 }
586 } else {
587 $this->sub_objects = "";
588 }
589 }
590
599 protected function setLocator()
600 {
601 $ilLocator = $this->locator;
603
604 if ($this->omit_locator) {
605 return;
606 }
607
608 // repository vs. workspace
609 if ($this->call_by_reference) {
610 // todo: admin workaround
611 // in the future, objectgui classes should not be called in
612 // admin section anymore (rbac/trash handling in own classes)
613 $ref_id = ($_GET["ref_id"] != "")
614 ? $_GET["ref_id"]
615 : $this->object->getRefId();
616 $ilLocator->addRepositoryItems($ref_id);
617 }
618
619 if (!$this->creation_mode) {
620 $this->addLocatorItems();
621 }
622
623 $tpl->setLocator();
624 }
625
630 protected function addLocatorItems()
631 {
632 }
633
634 protected function omitLocator($a_omit = true)
635 {
636 $this->omit_locator = $a_omit;
637 }
638
645 protected function addAdminLocatorItems($a_do_not_add_object = false)
646 {
647 $ilLocator = $this->locator;
648
649 if ($_GET["admin_mode"] == "settings") { // system settings
650 $this->ctrl->setParameterByClass(
651 "ilobjsystemfoldergui",
652 "ref_id",
653 SYSTEM_FOLDER_ID
654 );
655 $ilLocator->addItem(
656 $this->lng->txt("administration"),
657 $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), "")
658 );
659 if ($this->object && ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$a_do_not_add_object)) {
660 $ilLocator->addItem(
661 $this->object->getTitle(),
662 $this->ctrl->getLinkTarget($this, "view")
663 );
664 }
665 } else { // repository administration
666 $this->ctrl->setParameterByClass(
667 "iladministrationgui",
668 "ref_id",
669 ""
670 );
671 $this->ctrl->setParameterByClass(
672 "iladministrationgui",
673 "admin_mode",
674 "settings"
675 );
676 //$ilLocator->addItem($this->lng->txt("administration"),
677 // $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
678 // ilFrameTargetInfo::_getFrame("MainContent"));
679 $this->ctrl->clearParametersByClass("iladministrationgui");
680 $ilLocator->addAdministrationItems();
681 }
682 }
683
688 public function confirmedDeleteObject()
689 {
690 if (isset($_POST["mref_id"])) {
691 $_SESSION["saved_post"] = array_unique(array_merge($_SESSION["saved_post"], $_POST["mref_id"]));
692 }
693
694 include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
695 $ru = new ilRepUtilGUI($this);
696 $ru->deleteObjects($_GET["ref_id"], ilSession::get("saved_post"));
697 ilSession::clear("saved_post");
698 $this->ctrl->returnToParent($this);
699 }
700
706 public function cancelDeleteObject()
707 {
708 ilSession::clear("saved_post");
709 $this->ctrl->returnToParent($this);
710 }
711
712
718 public function cancelObject()
719 {
720 ilSession::clear("saved_post");
721 $this->ctrl->returnToParent($this);
722 }
723
729 public function createObject()
730 {
733
734 $new_type = $_REQUEST["new_type"];
735
736
737 // add new object to custom parent container
738 $this->ctrl->saveParameter($this, "crtptrefid");
739 // use forced callback after object creation
740 $this->ctrl->saveParameter($this, "crtcb");
741
742 if (!$this->checkPermissionBool("create", "", $new_type)) {
743 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
744 } else {
745 $this->lng->loadLanguageModule($new_type);
746 $this->ctrl->setParameter($this, "new_type", $new_type);
747
748 $forms = $this->initCreationForms($new_type);
749
750 // copy form validation error: do not show other creation forms
751 if ($_GET["cpfl"] && isset($forms[self::CFORM_CLONE])) {
752 $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
753 }
754 $tpl->setContent($this->getCreationFormsHTML($forms));
755 }
756 }
757
766 protected function initCreationForms($a_new_type)
767 {
768 $forms = array(
769 self::CFORM_NEW => $this->initCreateForm($a_new_type),
770 self::CFORM_IMPORT => $this->initImportForm($a_new_type),
771 self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type)
772 );
773
774 return $forms;
775 }
776
782 final protected function getCreationFormsHTML(array $a_forms)
783 {
785
786 // #13168- sanity check
787 foreach ($a_forms as $id => $form) {
788 if (!$form instanceof ilPropertyFormGUI) {
789 unset($a_forms[$id]);
790 }
791 }
792
793 // no accordion if there is just one form
794 if (sizeof($a_forms) == 1) {
795 $form_type = key($a_forms);
796 $a_forms = array_shift($a_forms);
797
798 // see bug #0016217
799 if (method_exists($this, "getCreationFormTitle")) {
800 $form_title = $this->getCreationFormTitle($form_type);
801 if ($form_title != "") {
802 $a_forms->setTitle($form_title);
803 }
804 }
805 return $a_forms->getHTML();
806 } else {
807 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
808
809 $acc = new ilAccordionGUI();
810 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
811 $cnt = 1;
812 foreach ($a_forms as $form_type => $cf) {
813 $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
814
815 // using custom form titles (used for repository plugins)
816 $form_title = "";
817 if (method_exists($this, "getCreationFormTitle")) {
818 $form_title = $this->getCreationFormTitle($form_type);
819 }
820 if (!$form_title) {
821 $form_title = $cf->getTitle();
822 }
823
824 // move title from form to accordion
825 $htpl->setVariable("TITLE", $this->lng->txt("option") . " " . $cnt . ": " .
826 $form_title);
827 $cf->setTitle(null);
828 $cf->setTitleIcon(null);
829 $cf->setTableWidth("100%");
830
831 $acc->addItem($htpl->get(), $cf->getHTML());
832
833 $cnt++;
834 }
835
836 return "<div class='ilCreationFormSection'>" . $acc->getHTML() . "</div>";
837 }
838 }
839
846 protected function initCreateForm($a_new_type)
847 {
848 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
849 $form = new ilPropertyFormGUI();
850 $form->setTarget("_top");
851 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
852 $form->setTitle($this->lng->txt($a_new_type . "_new"));
853
854 // title
855 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
856 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
857 $ti->setMaxLength(ilObject::TITLE_LENGTH);
858 $ti->setRequired(true);
859 $form->addItem($ti);
860
861 // description
862 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
863 $ta->setCols(40);
864 $ta->setRows(2);
865 $form->addItem($ta);
866
867 $form = $this->initDidacticTemplate($form);
868
869 $form->addCommandButton("save", $this->lng->txt($a_new_type . "_add"));
870 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
871
872 return $form;
873 }
874
880 protected function initDidacticTemplate(ilPropertyFormGUI $form)
881 {
883
884 $lng->loadLanguageModule('didactic');
885 $existing_exclusive = false;
886 $options = [];
887 $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'),
888 sprintf(
889 $this->lng->txt('didactic_default_type_info'),
890 $this->lng->txt('objs_' . $this->type)
891 ));
892
893 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
894 $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
895 if ($templates) {
896 foreach ($templates as $template) {
897 if ($template->isEffective($_GET["ref_id"])) {
898 $options["dtpl_" . $template->getId()] = array(
899 $template->getPresentationTitle(),
900 $template->getPresentationDescription()
901 );
902
903 if ($template->isExclusive()) {
904 $existing_exclusive = true;
905 }
906 }
907 }
908 }
909
910 $this->addDidacticTemplateOptions($options);
911
912 if (sizeof($options) > 1) {
914 $this->lng->txt('type'),
915 'didactic_type'
916 );
917 // workaround for containers in edit mode
918 if (!$this->getCreationMode()) {
919 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
920 $value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
921
922 $type->setValue($value);
923
924 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
925 //add or rename actual value to not avaiable
926 $options[$value] = array($this->lng->txt('not_available'));
927 }
928 } else {
929 if ($existing_exclusive) {
930 //if an exclusive template exists use the second template as default value
931 $keys = array_keys($options);
932 $type->setValue($keys[1]);
933 } else {
934 $type->setValue('dtpl_0');
935 }
936 }
937 $form->addItem($type);
938
939 foreach ($options as $id => $data) {
940 $option = new ilRadioOption($data[0], $id, $data[1]);
941
942 if ($existing_exclusive && $id == 'dtpl_0') {
943 //set default disabled if an exclusive template exists
944 $option->setDisabled(true);
945 }
946
947 $type->addOption($option);
948 }
949 }
950
951 return $form;
952 }
953
959 protected function addDidacticTemplateOptions(array &$a_options)
960 {
961 }
962
966 public function cancelCreation()
967 {
969
970 $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
971 }
972
978 public function saveObject()
979 {
983
984 $new_type = $_REQUEST["new_type"];
985
986 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
987 if (!$this->checkPermissionBool("create", "", $new_type)) {
988 $ilErr->raiseError($this->lng->txt("no_create_permission"), $ilErr->MESSAGE);
989 }
990
991 $this->lng->loadLanguageModule($new_type);
992 $this->ctrl->setParameter($this, "new_type", $new_type);
993
994 $form = $this->initCreateForm($new_type);
995 if ($form->checkInput()) {
996 $this->ctrl->setParameter($this, "new_type", "");
997
998 // create instance
999 $class_name = "ilObj" . $objDefinition->getClassName($new_type);
1000 $location = $objDefinition->getLocation($new_type);
1001 include_once($location . "/class." . $class_name . ".php");
1002 $newObj = new $class_name();
1003 $newObj->setType($new_type);
1004 $newObj->setTitle($form->getInput("title"));
1005 $newObj->setDescription($form->getInput("desc"));
1006 $newObj->create();
1007
1008 $this->putObjectInTree($newObj);
1009
1010 // apply didactic template?
1011 $dtpl = $this->getDidacticTemplateVar("dtpl");
1012 if ($dtpl) {
1013 $newObj->applyDidacticTemplate($dtpl);
1014 }
1015
1016 // auto rating
1017 $this->handleAutoRating($newObj);
1018
1019 // additional paramters are added to afterSave()
1020 $args = func_get_args();
1021 if ($args) {
1022 $this->afterSave($newObj, $args);
1023 } else {
1024 $this->afterSave($newObj);
1025 }
1026 return;
1027 }
1028
1029 // display only this form to correct input
1030 $form->setValuesByPost();
1031 $tpl->setContent($form->getHtml());
1032 }
1033
1041 {
1042 $tpl = $_POST["didactic_type"];
1043 if ($tpl && substr($tpl, 0, strlen($a_type) + 1) == $a_type . "_") {
1044 return (int) substr($tpl, strlen($a_type) + 1);
1045 }
1046 return 0;
1047 }
1048
1055 public function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
1056 {
1060
1061 if (!$a_parent_node_id) {
1062 $a_parent_node_id = $_GET["ref_id"];
1063 }
1064
1065 // add new object to custom parent container
1066 if ((int) $_REQUEST["crtptrefid"]) {
1067 $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
1068 }
1069
1070 $a_obj->createReference();
1071 $a_obj->putInTree($a_parent_node_id);
1072 $a_obj->setPermissions($a_parent_node_id);
1073
1074 $this->obj_id = $a_obj->getId();
1075 $this->ref_id = $a_obj->getRefId();
1076
1077 // BEGIN ChangeEvent: Record save object.
1078 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1079 ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
1080 // END ChangeEvent: Record save object.
1081
1082 // rbac log
1083 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1084 $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
1085 $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1086 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1087
1088 // use forced callback after object creation
1089 if ($_REQUEST["crtcb"]) {
1090 $callback_type = ilObject::_lookupType((int) $_REQUEST["crtcb"], true);
1091 $class_name = "ilObj" . $objDefinition->getClassName($callback_type) . "GUI";
1092 $location = $objDefinition->getLocation($callback_type);
1093 include_once($location . "/class." . $class_name . ".php");
1094 if (in_array(strtolower($class_name), array("ilobjitemgroupgui"))) {
1095 $callback_obj = new $class_name((int) $_REQUEST["crtcb"]);
1096 } else {
1097 // #10368
1098 $callback_obj = new $class_name(null, (int) $_REQUEST["crtcb"], true, false);
1099 }
1100 $callback_obj->afterSaveCallback($a_obj);
1101 }
1102 }
1103
1109 protected function afterSave(ilObject $a_new_object)
1110 {
1111 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1112 $this->ctrl->returnToParent($this);
1113 }
1114
1120 public function editObject()
1121 {
1122 $tpl = $this->tpl;
1123 $ilTabs = $this->tabs_gui;
1125
1126 if (!$this->checkPermissionBool("write")) {
1127 $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
1128 }
1129
1130 $ilTabs->activateTab("settings");
1131
1132 $form = $this->initEditForm();
1133 $values = $this->getEditFormValues();
1134 if ($values) {
1135 $form->setValuesByArray($values);
1136 }
1137
1138 $this->addExternalEditFormCustom($form);
1139
1140 $tpl->setContent($form->getHTML());
1141 }
1142
1144 {
1145 // has to be done AFTER setValuesByArray() ...
1146 }
1147
1153 protected function initEditForm()
1154 {
1155 $lng = $this->lng;
1157
1158 $lng->loadLanguageModule($this->object->getType());
1159
1160 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1161 $form = new ilPropertyFormGUI();
1162 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1163 $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
1164
1165 // title
1166 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1167 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
1168 $ti->setMaxLength(ilObject::TITLE_LENGTH);
1169 $ti->setRequired(true);
1170 $form->addItem($ti);
1171
1172 // description
1173 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1174 $ta->setCols(40);
1175 $ta->setRows(2);
1176 $form->addItem($ta);
1177
1178 $this->initEditCustomForm($form);
1179
1180 $form->addCommandButton("update", $this->lng->txt("save"));
1181 //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
1182
1183 return $form;
1184 }
1185
1191 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
1192 {
1193 }
1194
1200 protected function getEditFormValues()
1201 {
1202 $values["title"] = $this->object->getTitle();
1203 $values["desc"] = $this->object->getLongDescription();
1204 $this->getEditFormCustomValues($values);
1205 return $values;
1206 }
1207
1213 protected function getEditFormCustomValues(array &$a_values)
1214 {
1215 }
1216
1220 public function updateObject()
1221 {
1222 $ilTabs = $this->tabs_gui;
1223 $tpl = $this->tpl;
1225
1226 if (!$this->checkPermissionBool("write")) {
1227 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
1228 }
1229
1230 $form = $this->initEditForm();
1231 if ($form->checkInput() &&
1232 $this->validateCustom($form)) {
1233 $this->object->setTitle($form->getInput("title"));
1234 $this->object->setDescription($form->getInput("desc"));
1235 $this->updateCustom($form);
1236 $this->object->update();
1237
1238 $this->afterUpdate();
1239 return;
1240 }
1241
1242 // display form again to correct errors
1243 $ilTabs->activateTab("settings");
1244 $form->setValuesByPost();
1245 $tpl->setContent($form->getHtml());
1246 }
1247
1254 protected function validateCustom(ilPropertyFormGUI $a_form)
1255 {
1256 return true;
1257 }
1258
1264 protected function updateCustom(ilPropertyFormGUI $a_form)
1265 {
1266 }
1267
1271 protected function afterUpdate()
1272 {
1273 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1274 $this->ctrl->redirect($this, "edit");
1275 }
1276
1283 protected function initImportForm($a_new_type)
1284 {
1285 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1286 $form = new ilPropertyFormGUI();
1287 $form->setTarget("_top");
1288 $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1289 $form->setTitle($this->lng->txt($a_new_type . "_import"));
1290
1291 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1292 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1293 $fi->setSuffixes(array("zip"));
1294 $fi->setRequired(true);
1295 $form->addItem($fi);
1296
1297 $form->addCommandButton("importFile", $this->lng->txt("import"));
1298 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1299
1300 return $form;
1301 }
1302
1306 protected function importFileObject($parent_id = null, $a_catch_errors = true)
1307 {
1309 $tpl = $this->tpl;
1311
1312 if (!$parent_id) {
1313 $parent_id = $_GET["ref_id"];
1314 }
1315 $new_type = $_REQUEST["new_type"];
1316
1317 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1318 if (!$this->checkPermissionBool("create", "", $new_type)) {
1319 $ilErr->raiseError($this->lng->txt("no_create_permission"));
1320 }
1321
1322 $this->lng->loadLanguageModule($new_type);
1323 $this->ctrl->setParameter($this, "new_type", $new_type);
1324
1325 $form = $this->initImportForm($new_type);
1326 if ($form->checkInput()) {
1327 // :todo: make some check on manifest file
1328
1329 if ($objDefinition->isContainer($new_type)) {
1330 include_once './Services/Export/classes/class.ilImportContainer.php';
1331 $imp = new ilImportContainer((int) $parent_id);
1332 } else {
1333 include_once("./Services/Export/classes/class.ilImport.php");
1334 $imp = new ilImport((int) $parent_id);
1335 }
1336
1337 try {
1338 $new_id = $imp->importObject(
1339 null,
1340 $_FILES["importfile"]["tmp_name"],
1341 $_FILES["importfile"]["name"],
1342 $new_type
1343 );
1344 } catch (ilException $e) {
1345 $this->tmp_import_dir = $imp->getTemporaryImportDir();
1346 if (!$a_catch_errors) {
1347 throw $e;
1348 }
1349 // display message and form again
1350 ilUtil::sendFailure($this->lng->txt("obj_import_file_error") . " <br />" . $e->getMessage());
1351 $form->setValuesByPost();
1352 $tpl->setContent($form->getHtml());
1353 return;
1354 }
1355
1356 if ($new_id > 0) {
1357 $this->ctrl->setParameter($this, "new_type", "");
1358
1359 $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1360
1361 // put new object id into tree - already done in import for containers
1362 if (!$objDefinition->isContainer($new_type)) {
1363 $this->putObjectInTree($newObj);
1364 }
1365
1366 $this->afterImport($newObj);
1367 }
1368 // import failed
1369 else {
1370 if ($objDefinition->isContainer($new_type)) {
1371 ilUtil::sendFailure($this->lng->txt("container_import_zip_file_invalid"));
1372 } else {
1373 // not enough information here...
1374 return;
1375 }
1376 }
1377 }
1378
1379 // display form to correct errors
1380 $form->setValuesByPost();
1381 $tpl->setContent($form->getHtml());
1382 }
1383
1389 protected function afterImport(ilObject $a_new_object)
1390 {
1391 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1392 $this->ctrl->returnToParent($this);
1393 }
1394
1403 public function getFormAction($a_cmd, $a_formaction = "")
1404 {
1405 if ($this->formaction[$a_cmd] != "") {
1406 return $this->formaction[$a_cmd];
1407 } else {
1408 return $a_formaction;
1409 }
1410 }
1411
1420 protected function setFormAction($a_cmd, $a_formaction)
1421 {
1422 $this->formaction[$a_cmd] = $a_formaction;
1423 }
1424
1432 protected function getReturnLocation($a_cmd, $a_location = "")
1433 {
1434 if ($this->return_location[$a_cmd] != "") {
1435 return $this->return_location[$a_cmd];
1436 } else {
1437 return $a_location;
1438 }
1439 }
1440
1448 protected function setReturnLocation($a_cmd, $a_location)
1449 {
1450 //echo "-".$a_cmd."-".$a_location."-";
1451 $this->return_location[$a_cmd] = $a_location;
1452 }
1453
1461 protected function getTargetFrame($a_cmd, $a_target_frame = "")
1462 {
1463 if ($this->target_frame[$a_cmd] != "") {
1464 return $this->target_frame[$a_cmd];
1465 } elseif (!empty($a_target_frame)) {
1466 return "target=\"" . $a_target_frame . "\"";
1467 } else {
1468 return;
1469 }
1470 }
1471
1479 protected function setTargetFrame($a_cmd, $a_target_frame)
1480 {
1481 $this->target_frame[$a_cmd] = "target=\"" . $a_target_frame . "\"";
1482 }
1483
1484 // BEGIN Security: Hide objects which aren't accessible by the user.
1485 public function isVisible($a_ref_id, $a_type)
1486 {
1487 $visible = $this->checkPermissionBool("visible,read", "", "", $a_ref_id);
1488
1489 if ($visible && $a_type == 'crs') {
1491 if ($crs_id = $tree->checkForParentType($a_ref_id, 'crs')) {
1492 if (!$this->checkPermissionBool("write", "", "", $crs_id)) {
1493 // Show only activated courses
1494 $tmp_obj = &ilObjectFactory::getInstanceByRefId($crs_id, false);
1495
1496 if (!$tmp_obj->isActivated()) {
1497 unset($tmp_obj);
1498 $visible = false;
1499 }
1500 }
1501 }
1502 }
1503
1504 return $visible;
1505 }
1506 // END Security: Hide objects which aren't accessible by the user.
1507
1512 public function viewObject()
1513 {
1514 global $DIC;
1515
1516 $tpl = $DIC->ui()->mainTemplate();
1517 $user = $DIC->user();
1518
1519 $this->checkPermission('visible') && $this->checkPermission('read');
1520
1521 $this->tabs_gui->activateTab('view');
1522
1524 $this->object->getType(),
1525 $this->object->getRefId(),
1526 $this->object->getId(),
1527 $user->getId()
1528 );
1529
1530 if (!$this->withReferences()) {
1531 $this->ctrl->setParameter($this, 'obj_id', $this->obj_id);
1532 }
1533 $itab = new ilAdminSubItemsTableGUI(
1534 $this,
1535 "view",
1536 $_GET["ref_id"],
1537 $this->checkPermissionBool('write')
1538 );
1539
1540 $tpl->setContent($itab->getHTML());
1541 }
1542
1550 public function deleteObject($a_error = false)
1551 {
1553
1554 if ($_GET["item_ref_id"] != "") {
1555 $_POST["id"] = array($_GET["item_ref_id"]);
1556 }
1557
1558 if (is_array($_POST["id"])) {
1559 foreach ($_POST["id"] as $idx => $id) {
1560 $_POST["id"][$idx] = (int) $id;
1561 }
1562 }
1563
1564 // SAVE POST VALUES (get rid of this
1565 ilSession::set("saved_post", $_POST["id"]);
1566
1567 include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1568 $ru = new ilRepUtilGUI($this);
1569 if (!$ru->showDeleteConfirmation($_POST["id"], $a_error)) {
1570 $ilCtrl->returnToParent($this);
1571 }
1572 }
1573
1579 protected function showPossibleSubObjects()
1580 {
1581 if ($this->sub_objects == "") {
1582 $d = $this->objDefinition->getCreatableSubObjects($this->object->getType(), ilObjectDefinition::MODE_REPOSITORY, $this->ref_id);
1583 } else {
1585 }
1586
1587 $import = false;
1588
1589 if (count($d) > 0) {
1590 foreach ($d as $row) {
1591 $count = 0;
1592
1593 if ($row["max"] > 0) {
1594 //how many elements are present?
1595 for ($i = 0; $i < count($this->data["ctrl"]); $i++) {
1596 if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
1597 $count++;
1598 }
1599 }
1600 }
1601
1602 if ($row["max"] == "" || $count < $row["max"]) {
1603 $subobj[] = $row["name"];
1604 }
1605 }
1606 }
1607
1608 if (is_array($subobj)) {
1609
1610 //build form
1611 $opts = ilUtil::formSelect(12, "new_type", $subobj);
1612 $this->tpl->setCurrentBlock("add_object");
1613 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1614 $this->tpl->setVariable("BTN_NAME", "create");
1615 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1616 $this->tpl->parseCurrentBlock();
1617 }
1618 }
1619
1628 final protected function getTemplateFile($a_cmd, $a_type = "")
1629 {
1630 mk();
1631 die("ilObjectGUI::getTemplateFile() is deprecated.");
1632 }
1633
1641 protected function getTabs()
1642 {
1643 // please define your tabs here
1644 }
1645
1646 // PROTECTED
1647 protected function __showButton($a_cmd, $a_text, $a_target = '')
1648 {
1649 $ilToolbar = $this->toolbar;
1650
1651 $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
1652 }
1653
1654 protected function hitsperpageObject()
1655 {
1656 ilSession::set("tbl_limit", $_POST["hitsperpage"]);
1657 $_GET["limit"] = $_POST["hitsperpage"];
1658 }
1659
1660
1661 protected function &__initTableGUI()
1662 {
1663 include_once "./Services/Table/classes/class.ilTableGUI.php";
1664
1665 return new ilTableGUI(0, false);
1666 }
1667
1673 protected function __setTableGUIBasicData(&$tbl, &$result_set, $a_from = "")
1674 {
1675 switch ($a_from) {
1676 case "clipboardObject":
1677 $offset = $_GET["offset"];
1678 $order = $_GET["sort_by"];
1679 $direction = $_GET["sort_order"];
1680 $tbl->disable("footer");
1681 break;
1682
1683 default:
1684 $offset = $_GET["offset"];
1685 $order = $_GET["sort_by"];
1686 $direction = $_GET["sort_order"];
1687 break;
1688 }
1689
1690 $tbl->setOrderColumn($order);
1691 $tbl->setOrderDirection($direction);
1692 $tbl->setOffset($offset);
1693 $tbl->setLimit($_GET["limit"]);
1694 $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1695 $tbl->setData($result_set);
1696 }
1697
1707 protected function redirectToRefId($a_ref_id, $a_cmd = "")
1708 {
1709 $obj_type = ilObject::_lookupType($a_ref_id, true);
1710 $class_name = $this->objDefinition->getClassName($obj_type);
1711 $class = strtolower("ilObj" . $class_name . "GUI");
1712 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id);
1713 $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
1714 }
1715
1716 // Object Cloning
1726 protected function fillCloneTemplate($a_tpl_varname, $a_type)
1727 {
1728 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
1729 $cp = new ilObjectCopyGUI($this);
1730 $cp->setType($a_type);
1731 $cp->setTarget($_GET['ref_id']);
1732 if ($a_tpl_varname) {
1733 $cp->showSourceSearch($a_tpl_varname);
1734 } else {
1735 return $cp->showSourceSearch(null);
1736 }
1737 }
1738
1745 public function cloneAllObject()
1746 {
1747 include_once('./Services/Link/classes/class.ilLink.php');
1748 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1749
1752
1753 $new_type = $_REQUEST['new_type'];
1754 if (!$this->checkPermissionBool("create", "", $new_type)) {
1755 $ilErr->raiseError($this->lng->txt('permission_denied'));
1756 }
1757 if (!(int) $_REQUEST['clone_source']) {
1758 ilUtil::sendFailure($this->lng->txt('select_one'));
1759 $this->createObject();
1760 return false;
1761 }
1762 if (!$this->checkPermissionBool("write", "", $new_type, (int) $_REQUEST['clone_source'])) {
1763 $ilErr->raiseError($this->lng->txt('permission_denied'));
1764 }
1765
1766 // Save wizard options
1768 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1769 $wizard_options->saveOwner($ilUser->getId());
1770 $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
1771
1772 $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1773 foreach ($options as $source_id => $option) {
1774 $wizard_options->addEntry($source_id, $option);
1775 }
1776 $wizard_options->read();
1777
1778 $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
1779 $new_obj = $orig->cloneObject((int) $_GET['ref_id'], $copy_id);
1780
1781 // Delete wizard options
1782 $wizard_options->deleteAll();
1783
1784 ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
1785 ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1786 }
1787
1788
1792 protected function getCenterColumnHTML()
1793 {
1795
1796 include_once("Services/Block/classes/class.ilColumnGUI.php");
1797
1798 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1799 $obj_type = ilObject::_lookupType($obj_id);
1800
1801 if ($ilCtrl->getNextClass() != "ilcolumngui") {
1802 // normal command processing
1803 return $this->getContent();
1804 } else {
1805 if (!$ilCtrl->isAsynch()) {
1806 //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1808 // right column wants center
1810 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1811 $this->setColumnSettings($column_gui);
1812 $this->html = $ilCtrl->forwardCommand($column_gui);
1813 }
1814 // left column wants center
1816 $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1817 $this->setColumnSettings($column_gui);
1818 $this->html = $ilCtrl->forwardCommand($column_gui);
1819 }
1820 } else {
1821 // normal command processing
1822 return $this->getContent();
1823 }
1824 }
1825 }
1826 }
1827
1831 protected function getRightColumnHTML()
1832 {
1834 $lng = $this->lng;
1836
1837 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1838 $obj_type = ilObject::_lookupType($obj_id);
1839
1840 include_once("Services/Block/classes/class.ilColumnGUI.php");
1841 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1842
1843 if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
1844 return "";
1845 }
1846
1847 $this->setColumnSettings($column_gui);
1848
1849 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
1850 $column_gui->getCmdSide() == IL_COL_RIGHT &&
1851 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
1852 $html = $ilCtrl->forwardCommand($column_gui);
1853 } else {
1854 if (!$ilCtrl->isAsynch()) {
1855 $html = $ilCtrl->getHTML($column_gui);
1856 }
1857 }
1858
1859 return $html;
1860 }
1861
1865 protected function setColumnSettings(ilColumnGUI $column_gui)
1866 {
1867 $column_gui->setRepositoryMode(true);
1868 $column_gui->setEnableEdit(false);
1869 if ($this->checkPermissionBool("write")) {
1870 $column_gui->setEnableEdit(true);
1871 }
1872 }
1873
1884 protected function checkPermission($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1885 {
1886 if (!$this->checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id)) {
1887 if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php"))) {
1888 // create: redirect to parent
1889 if ($a_perm == "create") {
1890 if (!$a_ref_id) {
1891 $a_ref_id = $_GET["ref_id"];
1892 }
1893 $type = ilObject::_lookupType($a_ref_id, true);
1894 } else {
1895 // does this make sense?
1896 if (!is_object($this->object)) {
1897 return;
1898 }
1899 if (!$a_ref_id) {
1900 $a_ref_id = $this->object->getRefId();
1901 }
1902 $type = $this->object->getType();
1903 }
1904
1905 ilSession::clear("il_rep_ref_id");
1906
1907 include_once "Services/Object/exceptions/class.ilObjectException.php";
1908 throw new ilObjectException($this->lng->txt("permission_denied"));
1909
1910 /*
1911 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
1912 ilUtil::redirect("goto.php?target=".$type."_".$a_ref_id);
1913 */
1914 }
1915 // we should never be here
1916 else {
1917 die("Permission Denied.");
1918 }
1919 }
1920 }
1921
1931 protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1932 {
1933 $ilAccess = $this->access;
1934
1935 if ($a_perm == "create") {
1936 if (!$a_ref_id) {
1937 $a_ref_id = $_GET["ref_id"];
1938 }
1939 return $ilAccess->checkAccess($a_perm . "_" . $a_type, $a_cmd, $a_ref_id);
1940 } else {
1941 // does this make sense?
1942 if (!is_object($this->object)) {
1943 return false;
1944 }
1945 if (!$a_ref_id) {
1946 $a_ref_id = $this->object->getRefId();
1947 }
1948 return $ilAccess->checkAccess($a_perm, $a_cmd, $a_ref_id);
1949 }
1950 }
1951
1958 public static function _gotoRepositoryRoot($a_raise_error = false)
1959 {
1960 global $DIC;
1961
1962 $ilAccess = $DIC->access();
1963 $ilErr = $DIC["ilErr"];
1964 $lng = $DIC->language();
1965
1966 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1967 $_GET["cmd"] = "frameset";
1968 $_GET["target"] = "";
1969 $_GET["ref_id"] = ROOT_FOLDER_ID;
1970 $_GET["baseClass"] = "ilRepositoryGUI";
1971 include("ilias.php");
1972 exit;
1973 }
1974
1975 if ($a_raise_error) {
1976 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1977 }
1978 }
1979
1986 public static function _gotoRepositoryNode($a_ref_id, $a_cmd = "frameset")
1987 {
1988 global $DIC;
1989
1990 $ilAccess = $DIC->access();
1991 $ilErr = $DIC["ilErr"];
1992
1993 $_GET["cmd"] = $a_cmd;
1994 $_GET["target"] = "";
1995 $_GET["ref_id"] = $a_ref_id;
1996 $_GET["baseClass"] = "ilRepositoryGUI";
1997 include("ilias.php");
1998 exit;
1999 }
2000
2004 protected function enableDragDropFileUpload()
2005 {
2006 include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
2008
2009 $this->tpl->enableDragDropFileUpload($this->ref_id);
2010 }
2011
2017 protected function handleAutoRating(ilObject $a_new_obj)
2018 {
2019 if (ilObject::hasAutoRating($a_new_obj->getType(), $a_new_obj->getRefId()) &&
2020 method_exists($a_new_obj, "setRating")) {
2021 $a_new_obj->setRating(true);
2022 $a_new_obj->update();
2023 }
2024 }
2025
2030 protected function showCustomIconsEditing($a_input_colspan = 1, ilPropertyFormGUI $a_form = null, $a_as_section = true)
2031 {
2032 if ($this->settings->get("custom_icons")) {
2033 if ($a_form) {
2034 global $DIC;
2036 $customIconFactory = $DIC['object.customicons.factory'];
2037
2038 $customIcon = $customIconFactory->getByObjId($this->object->getId(), $this->object->getType());
2039
2040 if ($a_as_section) {
2041 $title = new ilFormSectionHeaderGUI();
2042 $title->setTitle($this->lng->txt("icon_settings"));
2043 } else {
2044 $title = new ilCustomInputGUI($this->lng->txt("icon_settings"), "");
2045 }
2046 $a_form->addItem($title);
2047
2048 $caption = $this->lng->txt("cont_custom_icon");
2049 $icon = new ilImageFileInputGUI($caption, "cont_icon");
2050
2051 $icon->setSuffixes($customIcon->getSupportedFileExtensions());
2052 $icon->setUseCache(false);
2053 if ($customIcon->exists()) {
2054 $icon->setImage($customIcon->getFullPath());
2055 } else {
2056 $icon->setImage('');
2057 }
2058 if ($a_as_section) {
2059 $a_form->addItem($icon);
2060 } else {
2061 $title->addSubItem($icon);
2062 }
2063 }
2064 }
2065 }
2066
2072 public function redirectAfterCreation()
2073 {
2075 $link = ilLink::_getLink($this->object->getRefId());
2076 $ctrl->redirectToURL($link);
2077 }
2078
2082 public function addToDeskObject()
2083 {
2084 $lng = $this->lng;
2087 $this->favourites->add($user->getId(), (int) $_GET["item_ref_id"]);
2088 $lng->loadLanguageModule("rep");
2089 ilUtil::sendSuccess($lng->txt("rep_added_to_favourites"), true);
2090 $ctrl->redirectToURL(ilLink::_getLink((int) $_GET["ref_id"]));
2091 }
2092
2096 public function removeFromDeskObject()
2097 {
2098 $lng = $this->lng;
2101 $lng->loadLanguageModule("rep");
2102 $this->favourites->remove($user->getId(), (int) $_GET["item_ref_id"]);
2103 ilUtil::sendSuccess($lng->txt("rep_removed_from_favourites"), true);
2104 $ctrl->redirectToURL(ilLink::_getLink((int) $_GET["ref_id"]));
2105 }
2106}
user()
Definition: user.php:4
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
const IL_COL_RIGHT
const IL_SCREEN_FULL
const IL_COL_LEFT
Accordion user interface class.
TableGUI class for sub items listed in repository administration.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
Column user interface class.
static getScreenMode()
Get Screen Mode for current command.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
setEnableEdit($a_enableedit)
Set EnableEdit.
static getCmdSide()
Get Column Side of Current Command.
Class ilCommonActionDispatcherGUI.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
This class represents a custom property in a property form.
static lookupTemplateId($a_ref_id)
Lookup template id @global ilDB $ilDB.
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
Base class for ILIAS Exception handling.
Manages favourites, currently the interface for other components, needs discussion.
This class represents a file property in a property form.
static initFileUpload()
Initializes the file upload and loads the needed javascripts and styles.
static isUploadAllowed($a_ref_id, $a_type="")
Determines whether files can be uploaded to the object with the specified reference id.
This class represents a section header in a property form.
This class represents an image file property in a property form.
Import class.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
GUI class for the workflow of copying objects.
Base exception class for object service.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
addDidacticTemplateOptions(array &$a_options)
Add custom templates.
__showButton($a_cmd, $a_text, $a_target='')
confirmedDeleteObject()
confirmed deletion of object -> objects are moved to trash or deleted immediately,...
validateCustom(ilPropertyFormGUI $a_form)
Validate custom values (if not possible with checkInput())
cancelCreation()
cancel create action and go back to repository parent
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
initImportForm($a_new_type)
Init object import form.
afterImport(ilObject $a_new_object)
Post (successful) object import hook.
withReferences()
determines wether objects are referenced or not (got ref ids or not)
redirectAfterCreation()
Redirect after creation, see https://docu.ilias.de/goto_docu_wiki_wpage_5035_1357....
addToDeskObject()
@inheritDoc
importFileObject($parent_id=null, $a_catch_errors=true)
Import.
handleAutoRating(ilObject $a_new_obj)
Activate rating automatically if parent container setting.
getTabs()
get tabs abstract method.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
prepareOutput($a_show_subobjects=true)
prepare output
initCreateForm($a_new_type)
Init object creation form.
getFormAction($a_cmd, $a_formaction="")
get form action for command (command is method name without "Object", e.g.
afterUpdate()
Post (successful) object update hook.
isVisible($a_ref_id, $a_type)
setColumnSettings(ilColumnGUI $column_gui)
May be overwritten in subclasses.
getRightColumnHTML()
Display right column.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
omitLocator($a_omit=true)
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
removeFromDeskObject()
@inheritDoc
setSubObjects($a_sub_objects="")
set possible subobjects for this object.
enableDragDropFileUpload()
Enables the file upload into this object by dropping files.
const COPY_WIZARD_NEEDS_PAGE
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
getAdminTabs()
administration tabs show only permissions and trash folder
getTemplateFile($a_cmd, $a_type="")
get a template blockfile format: tpl.
setAdminTabs()
set admin tabs @access public
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
cancelObject()
cancel action and go back to previous page @access public
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
getCenterColumnHTML()
Get center column.
editObject()
edit object
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
fillCloneTemplate($a_tpl_varname, $a_type)
Fill object clone template This method can be called from any object GUI class that wants to offer ob...
getCreationMode()
get creation mode
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
insertHeaderAction($a_list_gui)
Insert header action into main template.
getEditFormValues()
Get values for edit form.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
saveObject()
save object
setTargetFrame($a_cmd, $a_target_frame)
set specific target frame for command
initDidacticTemplate(ilPropertyFormGUI $form)
Show didactic template types.
addHeaderAction()
Add header action menu.
__setTableGUIBasicData(&$tbl, &$result_set, $a_from="")
standard implementation for tables use 'from' variable use different initial setting of table
createObject()
create new object form
getCreationFormsHTML(array $a_forms)
Get HTML for creation forms (accordion)
setFormAction($a_cmd, $a_formaction)
set specific form action for command
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
setTabs()
set admin tabs @access public
initEditForm()
Init object edit form.
setLocator()
set Locator
addAdminLocatorItems($a_do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
addExternalEditFormCustom(ilPropertyFormGUI $a_form)
setTitleAndDescription()
called by prepare output
executeCommand()
execute command
getObjectService()
Get object service.
cancelDeleteObject()
cancel deletion of object
getTargetFrame($a_cmd, $a_target_frame="")
get target frame for command (command is method name without "Object", e.g.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
setReturnLocation($a_cmd, $a_location)
set specific return location for command
showPossibleSubObjects()
show possible subobjects (pulldown menu)
updateObject()
updates object entry in object_data
redirectToRefId($a_ref_id, $a_cmd="")
redirects to (repository) view per ref id usually to a container and usually used at the end of a sav...
setActions($a_actions="")
set possible actions for objects in list.
redrawHeaderActionObject()
Ajax call: redraw action header only.
setCreationMode($a_mode=true)
if true, a creation screen is displayed the current $_GET[ref_id] don't belong to the current class!...
initCreationForms($a_new_type)
Init creation froms.
deleteObject($a_error=false)
Display deletion confirmation screen.
cloneAllObject()
Clone single (not container object) Method is overwritten in ilContainerGUI.
initHeaderAction($a_sub_type=null, $a_sub_id=null)
Add header action menu.
static _getListGUIByType($a_type, $a_context=ilObjectListGUI::CONTEXT_REPOSITORY)
Class ilObject Basic functions for all objects.
getType()
get object type @access public
static hasAutoRating($a_type, $a_ref_id)
Check if auto rating is active for parent group/course.
static _lookupObjId($a_id)
createReference()
creates reference for object
const TITLE_LENGTH
max length of object title
update()
update object in db
static _lookupTitle($a_id)
lookup object title
setPermissions($a_parent_ref)
set permissions of object
getRefId()
get reference id @access public
getId()
get object id @access public
putInTree($a_parent_ref)
maybe this method should be in tree object!?
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a property in a property form.
This class represents an option in a radio group.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
const CREATE_OBJECT
Repository GUI Utilities.
static set($a_var, $a_val)
Set a value.
static clear($a_var)
Unset a value.
static get($a_var)
Get a value.
Class ilTableGUI.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static infoPanel($a_keep=true)
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $ilCtrl
Definition: ilias.php:18
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
exit
Definition: login.php:29
if($format !==null) $name
Definition: metadata.php:230
$i
Definition: metadata.php:24
$keys
Definition: metadata.php:187
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46