ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $settings;
39
43 protected $rbacreview;
44
48 protected $toolbar;
49
53 protected $rbacsystem;
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
122 const CFORM_NEW = 1;
123 const CFORM_IMPORT = 2;
124 const CFORM_CLONE = 3;
125
133 public function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
134 {
135 global $DIC;
136
137 $this->locator = $DIC["ilLocator"];
138 $this->user = $DIC->user();
139 $this->access = $DIC->access();
140 $this->settings = $DIC->settings();
141 $this->rbacreview = $DIC->rbac()->review();
142 $this->toolbar = $DIC->toolbar();
143 $this->rbacsystem = $DIC->rbac()->system();
144 $objDefinition = $DIC["objDefinition"];
145 $tpl = $DIC["tpl"];
146 $tree = $DIC->repositoryTree();
147 $ilCtrl = $DIC->ctrl();
148 $ilErr = $DIC["ilErr"];
149 $lng = $DIC->language();
150 $ilTabs = $DIC->tabs();
151
152 $this->ilias = $DIC["ilias"];
153
157 $this->tabs_gui = $ilTabs;
158
159 if (!isset($ilErr)) {
160 $ilErr = new ilErrorHandling();
161 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,'errorHandler'));
162 } else {
163 $this->ilErr = $ilErr;
164 }
165
166 $this->objDefinition = $objDefinition;
167 $this->tpl = $tpl;
168 $this->html = "";
169 $this->ctrl = $ilCtrl;
170
171 $params = array("ref_id");
172
173 if (!$a_call_by_reference) {
174 $params = array("ref_id","obj_id");
175 }
176
177 $this->ctrl->saveParameter($this, $params);
178
179 $this->lng = $lng;
180 $this->tree = $tree;
181 $this->formaction = array();
182 $this->return_location = array();
183 $this->target_frame = array();
184 $this->actions = "";
185 $this->sub_objects = "";
186
187 $this->data = $a_data;
188 $this->id = $a_id;
189 $this->call_by_reference = $a_call_by_reference;
190 $this->prepare_output = $a_prepare_output;
191 $this->creation_mode = false;
192
193 $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
194 $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
195
196 if ($this->id != 0) {
197 $this->link_params = "ref_id=" . $this->ref_id;
198 }
199
200 // get the object
201 $this->assignObject();
202
203 // set context
204 if (is_object($this->object)) {
205 if ($this->call_by_reference && $this->ref_id == $_GET["ref_id"]) {
206 $this->ctrl->setContext(
207 $this->object->getId(),
208 $this->object->getType()
209 );
210 }
211 }
212
213 // use global $lng instead, when creating new objects object is not available
214 //$this->lng =& $this->object->lng;
215
216 //prepare output
217 if ($a_prepare_output) {
218 $this->prepareOutput();
219 }
220 }
221
222
226 public function executeCommand()
227 {
228 $next_class = $this->ctrl->getNextClass($this);
229 $cmd = $this->ctrl->getCmd();
230
231 switch ($next_class) {
232 default:
233 $this->prepareOutput();
234 if (!$cmd) {
235 $cmd = "view";
236 }
237 $cmd .= "Object";
238 $this->$cmd();
239
240 break;
241 }
242
243 return true;
244 }
245
246
250 public function withReferences()
251 {
252 return $this->call_by_reference;
253 }
254
261 public function setCreationMode($a_mode = true)
262 {
263 $this->creation_mode = $a_mode;
264 }
265
269 public function getCreationMode()
270 {
271 return $this->creation_mode;
272 }
273
274 protected function assignObject()
275 {
276 // TODO: it seems that we always have to pass only the ref_id
277 //echo "<br>ilObjectGUIassign:".get_class($this).":".$this->id.":<br>";
278 if ($this->id != 0) {
279 if ($this->call_by_reference) {
280 $this->object = ilObjectFactory::getInstanceByRefId($this->id);
281 } else {
282 $this->object = ilObjectFactory::getInstanceByObjId($this->id);
283 }
284 }
285 }
286
290 public function prepareOutput($a_show_subobjects = true)
291 {
292 $ilLocator = $this->locator;
295
296 $this->tpl->getStandardTemplate();
297 // administration prepare output
298 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
299 $this->addAdminLocatorItems();
300 $tpl->setLocator();
301
302 // ilUtil::sendInfo();
304
305 $this->setTitleAndDescription();
306
307 if ($this->getCreationMode() != true) {
308 $this->setAdminTabs();
309 }
310
311 return false;
312 }
313 // set locator
314 $this->setLocator();
315 // catch feedback message
316 // ilUtil::sendInfo();
318
319 // in creation mode (parent) object and gui object
320 // do not fit
321 if ($this->getCreationMode() == true) {
322 // repository vs. workspace
323 if ($this->call_by_reference) {
324 // get gui class of parent and call their title and description method
325 $obj_type = ilObject::_lookupType($_GET["ref_id"], true);
326 $class_name = $this->objDefinition->getClassName($obj_type);
327 $class = strtolower("ilObj" . $class_name . "GUI");
328 $class_path = $this->ctrl->lookupClassPath($class);
329 include_once($class_path);
330 $class_name = $this->ctrl->getClassForClasspath($class_path);
331 //echo "<br>instantiating parent for title and description";
332 $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
333 // the next line prevents the header action menu being shown
334 $this->parent_gui_obj->setCreationMode(true);
335 $this->parent_gui_obj->setTitleAndDescription();
336 }
337 } else {
338 // set title and description and title icon
339 $this->setTitleAndDescription();
340
341 // set tabs
342 $this->setTabs();
343
344 // BEGIN WebDAV: Display Mount Webfolder icon.
345 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
346 require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
348 $this->showMountWebfolderIcon();
349 }
350 }
351 // END WebDAV: Display Mount Webfolder icon.
352
353 // fileupload support
354 require_once './Services/FileUpload/classes/class.ilFileUploadUtil.php';
355 if (ilFileUploadUtil::isUploadAllowed($this->ref_id, $this->object->getType())) {
357 }
358 }
359
360 return true;
361 }
362
366 protected function setTitleAndDescription()
367 {
368 if (!is_object($this->object)) {
369 if ((int) $_REQUEST["crtptrefid"] > 0) {
370 $cr_obj_id = ilObject::_lookupObjId((int) $_REQUEST["crtcb"]);
371 $this->tpl->setTitle(ilObject::_lookupTitle($cr_obj_id));
372 $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
373 }
374 return;
375 }
376 $this->tpl->setTitle($this->object->getPresentationTitle());
377 $this->tpl->setDescription($this->object->getLongDescription());
378
379 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
380 // alt text would be same as heading -> empty alt text
381 $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", $this->object->getType()));
382 } else {
383 $this->tpl->setTitleIcon(
384 ilObject::_getIcon("", "big", $this->object->getType()),
385 $this->lng->txt("obj_" . $this->object->getType())
386 );
387 }
388
389 include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
390 $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
391 $lgui->initItem($this->object->getRefId(), $this->object->getId());
392 $this->tpl->setAlertProperties($lgui->getAlertProperties());
393 }
394
402 protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
403 {
404 $ilAccess = $this->access;
405
406 if (!$this->creation_mode && $this->object) {
407 include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
408 $dispatcher = new ilCommonActionDispatcherGUI(
410 $ilAccess,
411 $this->object->getType(),
412 $this->ref_id,
413 $this->object->getId()
414 );
415
416 $dispatcher->setSubObject($a_sub_type, $a_sub_id);
417
418 include_once "Services/Object/classes/class.ilObjectListGUI.php";
419 ilObjectListGUI::prepareJSLinks(
420 $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
421 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
422 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
423 );
424
425 $lg = $dispatcher->initHeaderAction();
426
427 if (is_object($lg)) {
428 // to enable add to desktop / remove from desktop
429 if ($this instanceof ilDesktopItemHandling) {
430 $lg->setContainerObject($this);
431 }
432
433 // enable multi download
434 $lg->enableMultiDownload(true);
435
436 // comments settings are always on (for the repository)
437 // should only be shown if active or permission to toggle
438 include_once "Services/Notes/classes/class.ilNote.php";
439 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
440 $ilAccess->checkAccess("edit_permissions", "", $this->ref_id) ||
441 ilNote::commentsActivated($this->object->getId(), 0, $this->object->getType())) {
442 $lg->enableComments(true);
443 }
444
445 $lg->enableNotes(true);
446 $lg->enableTags(true);
447 }
448
449 return $lg;
450 }
451 }
452
458 protected function insertHeaderAction($a_list_gui)
459 {
460 if (is_object($a_list_gui)) {
461 $this->tpl->setHeaderActionMenu($a_list_gui->getHeaderAction());
462 }
463 }
464
468 protected function addHeaderAction()
469 {
470 $this->insertHeaderAction($this->initHeaderAction());
471 }
472
476 protected function redrawHeaderActionObject()
477 {
479
480 $lg = $this->initHeaderAction();
481 echo $lg->getHeaderAction();
482
483 // we need to add onload code manually (rating, comments, etc.)
484 echo $tpl->getOnLoadCodeForAsynch();
485
486 exit;
487 }
488
489 // BEGIN WebDAV: Show Mount Webfolder Icon.
490 protected function showMountWebfolderIcon()
491 {
495
496 if ($this->object->getRefId() == "") {
497 return;
498 }
499
500 $tpl->setMountWebfolderIcon($this->object->getRefId());
501 }
502 // END WebDAV: Show Mount Webfolder Icon.
503
504
509 protected function setTabs()
510 {
511 $this->getTabs();
512 }
513
518 final protected function setAdminTabs()
519 {
520 $this->getAdminTabs();
521 }
522
526 public function getAdminTabs()
527 {
529
530 /* if ($_GET["admin_mode"] == "repository")
531 {
532 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
533 $this->tabs_gui->setBackTarget($this->lng->txt("administration"),
534 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
535 ilFrameTargetInfo::_getFrame("MainContent"));
536 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
537 }*/
538
539 if ($this->checkPermissionBool("visible,read")) {
540 $this->tabs_gui->addTarget(
541 "view",
542 $this->ctrl->getLinkTarget($this, "view"),
543 array("", "view"),
544 get_class($this)
545 );
546 }
547
548 if ($this->checkPermissionBool("edit_permission")) {
549 $this->tabs_gui->addTarget(
550 "perm_settings",
551 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
552 "",
553 "ilpermissiongui"
554 );
555 }
556
557 if ($tree->getSavedNodeData($this->object->getRefId())) {
558 $this->tabs_gui->addTarget(
559 "trash",
560 $this->ctrl->getLinkTarget($this, "trash"),
561 "trash",
562 get_class($this)
563 );
564 }
565 }
566
567
568 public function getHTML()
569 {
570 return $this->html;
571 }
572
573
580 final private function setActions($a_actions = "")
581 {
582 if (is_array($a_actions)) {
583 foreach ($a_actions as $name => $lng) {
584 $this->actions[$name] = array("name" => $name, "lng" => $lng);
585 }
586 } else {
587 $this->actions = "";
588 }
589 }
590
597 final private function setSubObjects($a_sub_objects = "")
598 {
599 if (is_array($a_sub_objects)) {
600 foreach ($a_sub_objects as $name => $options) {
601 $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
602 }
603 } else {
604 $this->sub_objects = "";
605 }
606 }
607
616 protected function setLocator()
617 {
618 $ilLocator = $this->locator;
620
621 if ($this->omit_locator) {
622 return;
623 }
624
625 // repository vs. workspace
626 if ($this->call_by_reference) {
627 // todo: admin workaround
628 // in the future, objectgui classes should not be called in
629 // admin section anymore (rbac/trash handling in own classes)
630 $ref_id = ($_GET["ref_id"] != "")
631 ? $_GET["ref_id"]
632 : $this->object->getRefId();
633 $ilLocator->addRepositoryItems($ref_id);
634 }
635
636 if (!$this->creation_mode) {
637 $this->addLocatorItems();
638 }
639
640 $tpl->setLocator();
641 }
642
647 protected function addLocatorItems()
648 {
649 }
650
651 protected function omitLocator($a_omit = true)
652 {
653 $this->omit_locator = $a_omit;
654 }
655
662 protected function addAdminLocatorItems($a_do_not_add_object = false)
663 {
664 $ilLocator = $this->locator;
665
666 if ($_GET["admin_mode"] == "settings") { // system settings
667 $this->ctrl->setParameterByClass(
668 "ilobjsystemfoldergui",
669 "ref_id",
670 SYSTEM_FOLDER_ID
671 );
672 $ilLocator->addItem(
673 $this->lng->txt("administration"),
674 $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), "")
675 );
676 if ($this->object && ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$a_do_not_add_object)) {
677 $ilLocator->addItem(
678 $this->object->getTitle(),
679 $this->ctrl->getLinkTarget($this, "view")
680 );
681 }
682 } else { // repository administration
683 $this->ctrl->setParameterByClass(
684 "iladministrationgui",
685 "ref_id",
686 ""
687 );
688 $this->ctrl->setParameterByClass(
689 "iladministrationgui",
690 "admin_mode",
691 "settings"
692 );
693 //$ilLocator->addItem($this->lng->txt("administration"),
694 // $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
695 // ilFrameTargetInfo::_getFrame("MainContent"));
696 $this->ctrl->clearParametersByClass("iladministrationgui");
697 $ilLocator->addAdministrationItems();
698 }
699 }
700
705 public function confirmedDeleteObject()
706 {
707 if (isset($_POST["mref_id"])) {
708 $_SESSION["saved_post"] = array_unique(array_merge($_SESSION["saved_post"], $_POST["mref_id"]));
709 }
710
711 include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
712 $ru = new ilRepUtilGUI($this);
713 $ru->deleteObjects($_GET["ref_id"], ilSession::get("saved_post"));
714 ilSession::clear("saved_post");
715 $this->ctrl->returnToParent($this);
716 }
717
723 public function cancelDeleteObject()
724 {
725 ilSession::clear("saved_post");
726 $this->ctrl->returnToParent($this);
727 }
728
729
735 public function cancelObject()
736 {
737 ilSession::clear("saved_post");
738 $this->ctrl->returnToParent($this);
739 }
740
746 public function createObject()
747 {
750
751 $new_type = $_REQUEST["new_type"];
752
753
754 // add new object to custom parent container
755 $this->ctrl->saveParameter($this, "crtptrefid");
756 // use forced callback after object creation
757 $this->ctrl->saveParameter($this, "crtcb");
758
759 if (!$this->checkPermissionBool("create", "", $new_type)) {
760 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
761 } else {
762 $this->lng->loadLanguageModule($new_type);
763 $this->ctrl->setParameter($this, "new_type", $new_type);
764
765 $forms = $this->initCreationForms($new_type);
766
767 // copy form validation error: do not show other creation forms
768 if ($_GET["cpfl"] && isset($forms[self::CFORM_CLONE])) {
769 $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
770 }
771 $tpl->setContent($this->getCreationFormsHTML($forms));
772 }
773 }
774
783 protected function initCreationForms($a_new_type)
784 {
785 $forms = array(
786 self::CFORM_NEW => $this->initCreateForm($a_new_type),
787 self::CFORM_IMPORT => $this->initImportForm($a_new_type),
788 self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type)
789 );
790
791 return $forms;
792 }
793
799 final protected function getCreationFormsHTML(array $a_forms)
800 {
802
803 // #13168- sanity check
804 foreach ($a_forms as $id => $form) {
805 if (!$form instanceof ilPropertyFormGUI) {
806 unset($a_forms[$id]);
807 }
808 }
809
810 // no accordion if there is just one form
811 if (sizeof($a_forms) == 1) {
812 $form_type = key($a_forms);
813 $a_forms = array_shift($a_forms);
814
815 // see bug #0016217
816 if (method_exists($this, "getCreationFormTitle")) {
817 $form_title = $this->getCreationFormTitle($form_type);
818 if ($form_title != "") {
819 $a_forms->setTitle($form_title);
820 }
821 }
822 return $a_forms->getHTML();
823 } else {
824 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
825
826 $acc = new ilAccordionGUI();
827 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
828 $cnt = 1;
829 foreach ($a_forms as $form_type => $cf) {
830 $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
831
832 // using custom form titles (used for repository plugins)
833 $form_title = "";
834 if (method_exists($this, "getCreationFormTitle")) {
835 $form_title = $this->getCreationFormTitle($form_type);
836 }
837 if (!$form_title) {
838 $form_title = $cf->getTitle();
839 }
840
841 // move title from form to accordion
842 $htpl->setVariable("TITLE", $this->lng->txt("option") . " " . $cnt . ": " .
843 $form_title);
844 $cf->setTitle(null);
845 $cf->setTitleIcon(null);
846 $cf->setTableWidth("100%");
847
848 $acc->addItem($htpl->get(), $cf->getHTML());
849
850 $cnt++;
851 }
852
853 return "<div class='ilCreationFormSection'>" . $acc->getHTML() . "</div>";
854 }
855 }
856
863 protected function initCreateForm($a_new_type)
864 {
865 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
866 $form = new ilPropertyFormGUI();
867 $form->setTarget("_top");
868 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
869 $form->setTitle($this->lng->txt($a_new_type . "_new"));
870
871 // title
872 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
873 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
874 $ti->setMaxLength(ilObject::TITLE_LENGTH);
875 $ti->setRequired(true);
876 $form->addItem($ti);
877
878 // description
879 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
880 $ta->setCols(40);
881 $ta->setRows(2);
882 $form->addItem($ta);
883
885
886 $form->addCommandButton("save", $this->lng->txt($a_new_type . "_add"));
887 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
888
889 return $form;
890 }
891
898 {
900
901 $lng->loadLanguageModule('didactic');
902 $existing_exclusive = false;
903 $options = array();
904 $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'),
905 sprintf(
906 $this->lng->txt('didactic_default_type_info'),
907 $this->lng->txt('objs_' . $this->type)
908 ));
909
910 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
911 $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
912 if ($templates) {
913 foreach ($templates as $template) {
914 if ($template->isEffective($_GET["ref_id"])) {
915 $options["dtpl_" . $template->getId()] = array(
916 $template->getPresentationTitle(),
917 $template->getPresentationDescription()
918 );
919
920 if ($template->isExclusive()) {
921 $existing_exclusive = true;
922 }
923 }
924 }
925 }
926
928
929 if (sizeof($options) > 1) {
931 $this->lng->txt('type'),
932 'didactic_type'
933 );
934 // workaround for containers in edit mode
935 if (!$this->getCreationMode()) {
936 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
937 $value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
938
939 $type->setValue($value);
940
941 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
942 //add or rename actual value to not avaiable
943 $options[$value] = array($this->lng->txt('not_available'));
944 }
945 } else {
946 if ($existing_exclusive) {
947 //if an exclusive template exists use the second template as default value
948 $keys = array_keys($options);
949 $type->setValue($keys[1]);
950 } else {
951 $type->setValue('dtpl_0');
952 }
953 }
954 $form->addItem($type);
955
956 foreach ($options as $id => $data) {
957 $option = new ilRadioOption($data[0], $id, $data[1]);
958
959 if ($existing_exclusive && $id == "dtpl_0" && $this->getCreationMode()) {
960 //set default disabled if an exclusive template exists but just in creation screen
961 $option->setDisabled(true);
962 }
963
964 $type->addOption($option);
965 }
966 }
967
968 return $form;
969 }
970
976 protected function addDidacticTemplateOptions(array &$a_options)
977 {
978 }
979
983 public function cancelCreation()
984 {
986
987 $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
988 }
989
995 public function saveObject()
996 {
1000
1001 $new_type = $_REQUEST["new_type"];
1002
1003 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1004 if (!$this->checkPermissionBool("create", "", $new_type)) {
1005 $ilErr->raiseError($this->lng->txt("no_create_permission"), $ilErr->MESSAGE);
1006 }
1007
1008 $this->lng->loadLanguageModule($new_type);
1009 $this->ctrl->setParameter($this, "new_type", $new_type);
1010
1011 $form = $this->initCreateForm($new_type);
1012 if ($form->checkInput()) {
1013 $this->ctrl->setParameter($this, "new_type", "");
1014
1015 // create instance
1016 $class_name = "ilObj" . $objDefinition->getClassName($new_type);
1017 $location = $objDefinition->getLocation($new_type);
1018 include_once($location . "/class." . $class_name . ".php");
1019 $newObj = new $class_name();
1020 $newObj->setType($new_type);
1021 $newObj->setTitle($form->getInput("title"));
1022 $newObj->setDescription($form->getInput("desc"));
1023 $newObj->create();
1024
1025 $this->putObjectInTree($newObj);
1026
1027 // apply didactic template?
1028 $dtpl = $this->getDidacticTemplateVar("dtpl");
1029 if ($dtpl) {
1030 $newObj->applyDidacticTemplate($dtpl);
1031 }
1032
1033 // auto rating
1034 $this->handleAutoRating($newObj);
1035
1036 // additional paramters are added to afterSave()
1037 $args = func_get_args();
1038 if ($args) {
1039 $this->afterSave($newObj, $args);
1040 } else {
1041 $this->afterSave($newObj);
1042 }
1043 return;
1044 }
1045
1046 // display only this form to correct input
1047 $form->setValuesByPost();
1048 $tpl->setContent($form->getHtml());
1049 }
1050
1058 {
1059 $tpl = $_POST["didactic_type"];
1060 if ($tpl && substr($tpl, 0, strlen($a_type)+1) == $a_type . "_") {
1061 return (int) substr($tpl, strlen($a_type)+1);
1062 }
1063 return 0;
1064 }
1065
1072 public function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
1073 {
1077
1078 if (!$a_parent_node_id) {
1079 $a_parent_node_id = $_GET["ref_id"];
1080 }
1081
1082 // add new object to custom parent container
1083 if ((int) $_REQUEST["crtptrefid"]) {
1084 $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
1085 }
1086
1087 $a_obj->createReference();
1088 $a_obj->putInTree($a_parent_node_id);
1089 $a_obj->setPermissions($a_parent_node_id);
1090
1091 $this->obj_id = $a_obj->getId();
1092 $this->ref_id = $a_obj->getRefId();
1093
1094 // BEGIN ChangeEvent: Record save object.
1095 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1096 ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
1097 // END ChangeEvent: Record save object.
1098
1099 // rbac log
1100 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1101 $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
1102 $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1103 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1104
1105 // use forced callback after object creation
1106 if ($_REQUEST["crtcb"]) {
1107 $callback_type = ilObject::_lookupType((int) $_REQUEST["crtcb"], true);
1108 $class_name = "ilObj" . $objDefinition->getClassName($callback_type) . "GUI";
1109 $location = $objDefinition->getLocation($callback_type);
1110 include_once($location . "/class." . $class_name . ".php");
1111 if (in_array(strtolower($class_name), array("ilobjitemgroupgui"))) {
1112 $callback_obj = new $class_name((int) $_REQUEST["crtcb"]);
1113 } else {
1114 // #10368
1115 $callback_obj = new $class_name(null, (int) $_REQUEST["crtcb"], true, false);
1116 }
1117 $callback_obj->afterSaveCallback($a_obj);
1118 }
1119 }
1120
1126 protected function afterSave(ilObject $a_new_object)
1127 {
1128 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1129 $this->ctrl->returnToParent($this);
1130 }
1131
1137 public function editObject()
1138 {
1139 $tpl = $this->tpl;
1140 $ilTabs = $this->tabs_gui;
1142
1143 if (!$this->checkPermissionBool("write")) {
1144 $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
1145 }
1146
1147 $ilTabs->activateTab("settings");
1148
1149 $form = $this->initEditForm();
1150 $values = $this->getEditFormValues();
1151 if ($values) {
1152 $form->setValuesByArray($values);
1153 }
1154
1156
1157 $tpl->setContent($form->getHTML());
1158 }
1159
1161 {
1162 // has to be done AFTER setValuesByArray() ...
1163 }
1164
1170 protected function initEditForm()
1171 {
1172 $lng = $this->lng;
1174
1175 $lng->loadLanguageModule($this->object->getType());
1176
1177 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1178 $form = new ilPropertyFormGUI();
1179 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1180 $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
1181
1182 // title
1183 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1184 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
1185 $ti->setMaxLength(ilObject::TITLE_LENGTH);
1186 $ti->setRequired(true);
1187 $form->addItem($ti);
1188
1189 // description
1190 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1191 $ta->setCols(40);
1192 $ta->setRows(2);
1193 $form->addItem($ta);
1194
1195 $this->initEditCustomForm($form);
1196
1197 $form->addCommandButton("update", $this->lng->txt("save"));
1198 //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
1199
1200 return $form;
1201 }
1202
1208 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
1209 {
1210 }
1211
1217 protected function getEditFormValues()
1218 {
1219 $values["title"] = $this->object->getTitle();
1220 $values["desc"] = $this->object->getLongDescription();
1221 $this->getEditFormCustomValues($values);
1222 return $values;
1223 }
1224
1230 protected function getEditFormCustomValues(array &$a_values)
1231 {
1232 }
1233
1237 public function updateObject()
1238 {
1239 $ilTabs = $this->tabs_gui;
1240 $tpl = $this->tpl;
1242
1243 if (!$this->checkPermissionBool("write")) {
1244 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
1245 }
1246
1247 $form = $this->initEditForm();
1248 if ($form->checkInput() &&
1249 $this->validateCustom($form)) {
1250 $this->object->setTitle($form->getInput("title"));
1251 $this->object->setDescription($form->getInput("desc"));
1252 $this->updateCustom($form);
1253 $this->object->update();
1254
1255 $this->afterUpdate();
1256 return;
1257 }
1258
1259 // display form again to correct errors
1260 $ilTabs->activateTab("settings");
1261 $form->setValuesByPost();
1262 $tpl->setContent($form->getHtml());
1263 }
1264
1271 protected function validateCustom(ilPropertyFormGUI $a_form)
1272 {
1273 return true;
1274 }
1275
1281 protected function updateCustom(ilPropertyFormGUI $a_form)
1282 {
1283 }
1284
1288 protected function afterUpdate()
1289 {
1290 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1291 $this->ctrl->redirect($this, "edit");
1292 }
1293
1300 protected function initImportForm($a_new_type)
1301 {
1302 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1303 $form = new ilPropertyFormGUI();
1304 $form->setTarget("_top");
1305 $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1306 $form->setTitle($this->lng->txt($a_new_type . "_import"));
1307
1308 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1309 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1310 $fi->setSuffixes(array("zip"));
1311 $fi->setRequired(true);
1312 $form->addItem($fi);
1313
1314 $form->addCommandButton("importFile", $this->lng->txt("import"));
1315 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1316
1317 return $form;
1318 }
1319
1323 protected function importFileObject($parent_id = null, $a_catch_errors = true)
1324 {
1326 $tpl = $this->tpl;
1328
1329 if (!$parent_id) {
1330 $parent_id = $_GET["ref_id"];
1331 }
1332 $new_type = $_REQUEST["new_type"];
1333
1334 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1335 if (!$this->checkPermissionBool("create", "", $new_type)) {
1336 $ilErr->raiseError($this->lng->txt("no_create_permission"));
1337 }
1338
1339 $this->lng->loadLanguageModule($new_type);
1340 $this->ctrl->setParameter($this, "new_type", $new_type);
1341
1342 $form = $this->initImportForm($new_type);
1343 if ($form->checkInput()) {
1344 // :todo: make some check on manifest file
1345
1346 if ($objDefinition->isContainer($new_type)) {
1347 include_once './Services/Export/classes/class.ilImportContainer.php';
1348 $imp = new ilImportContainer((int) $parent_id);
1349 } else {
1350 include_once("./Services/Export/classes/class.ilImport.php");
1351 $imp = new ilImport((int) $parent_id);
1352 }
1353
1354 try {
1355 $new_id = $imp->importObject(
1356 null,
1357 $_FILES["importfile"]["tmp_name"],
1358 $_FILES["importfile"]["name"],
1359 $new_type
1360 );
1361 } catch (ilException $e) {
1362 $this->tmp_import_dir = $imp->getTemporaryImportDir();
1363 if (!$a_catch_errors) {
1364 throw $e;
1365 }
1366 // display message and form again
1367 ilUtil::sendFailure($this->lng->txt("obj_import_file_error") . " <br />" . $e->getMessage());
1368 $form->setValuesByPost();
1369 $tpl->setContent($form->getHtml());
1370 return;
1371 }
1372
1373 if ($new_id > 0) {
1374 $this->ctrl->setParameter($this, "new_type", "");
1375
1376 $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1377
1378 // put new object id into tree - already done in import for containers
1379 if (!$objDefinition->isContainer($new_type)) {
1380 $this->putObjectInTree($newObj);
1381 }
1382
1383 $this->afterImport($newObj);
1384 }
1385 // import failed
1386 else {
1387 if ($objDefinition->isContainer($new_type)) {
1388 ilUtil::sendFailure($this->lng->txt("container_import_zip_file_invalid"));
1389 } else {
1390 // not enough information here...
1391 return;
1392 }
1393 }
1394 }
1395
1396 // display form to correct errors
1397 $form->setValuesByPost();
1398 $tpl->setContent($form->getHtml());
1399 }
1400
1406 protected function afterImport(ilObject $a_new_object)
1407 {
1408 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1409 $this->ctrl->returnToParent($this);
1410 }
1411
1420 public function getFormAction($a_cmd, $a_formaction = "")
1421 {
1422 if ($this->formaction[$a_cmd] != "") {
1423 return $this->formaction[$a_cmd];
1424 } else {
1425 return $a_formaction;
1426 }
1427 }
1428
1437 protected function setFormAction($a_cmd, $a_formaction)
1438 {
1439 $this->formaction[$a_cmd] = $a_formaction;
1440 }
1441
1449 protected function getReturnLocation($a_cmd, $a_location ="")
1450 {
1451 if ($this->return_location[$a_cmd] != "") {
1452 return $this->return_location[$a_cmd];
1453 } else {
1454 return $a_location;
1455 }
1456 }
1457
1465 protected function setReturnLocation($a_cmd, $a_location)
1466 {
1467 //echo "-".$a_cmd."-".$a_location."-";
1468 $this->return_location[$a_cmd] = $a_location;
1469 }
1470
1478 protected function getTargetFrame($a_cmd, $a_target_frame = "")
1479 {
1480 if ($this->target_frame[$a_cmd] != "") {
1481 return $this->target_frame[$a_cmd];
1482 } elseif (!empty($a_target_frame)) {
1483 return "target=\"" . $a_target_frame . "\"";
1484 } else {
1485 return;
1486 }
1487 }
1488
1496 protected function setTargetFrame($a_cmd, $a_target_frame)
1497 {
1498 $this->target_frame[$a_cmd] = "target=\"" . $a_target_frame . "\"";
1499 }
1500
1501 // BEGIN Security: Hide objects which aren't accessible by the user.
1502 public function isVisible($a_ref_id, $a_type)
1503 {
1504 $visible = $this->checkPermissionBool("visible,read", "", "", $a_ref_id);
1505
1506 if ($visible && $a_type == 'crs') {
1508 if ($crs_id = $tree->checkForParentType($a_ref_id, 'crs')) {
1509 if (!$this->checkPermissionBool("write", "", "", $crs_id)) {
1510 // Show only activated courses
1511 $tmp_obj =&ilObjectFactory::getInstanceByRefId($crs_id, false);
1512
1513 if (!$tmp_obj->isActivated()) {
1514 unset($tmp_obj);
1515 $visible = false;
1516 }
1517 }
1518 }
1519 }
1520
1521 return $visible;
1522 }
1523 // END Security: Hide objects which aren't accessible by the user.
1524
1530 public function viewObject()
1531 {
1532 $tpl = $this->tpl;
1534
1535 if (!$this->checkPermissionBool("visible,read")) {
1536 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
1537 }
1538
1539 // BEGIN ChangeEvent: record read event.
1540 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1543 $this->object->getType(),
1544 $this->object->getRefId(),
1545 $this->object->getId(),
1546 $ilUser->getId()
1547 );
1548 // END ChangeEvent: record read event.
1549
1550 include_once("./Services/Repository/classes/class.ilAdminSubItemsTableGUI.php");
1551 if (!$this->call_by_reference) {
1552 $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
1553 }
1554 $itab = new ilAdminSubItemsTableGUI(
1555 $this,
1556 "view",
1557 $_GET["ref_id"],
1558 $this->checkPermissionBool('write')
1559 );
1560
1561 $tpl->setContent($itab->getHTML());
1562 }
1563
1571 public function deleteObject($a_error = false)
1572 {
1574
1575 if ($_GET["item_ref_id"] != "") {
1576 $_POST["id"] = array($_GET["item_ref_id"]);
1577 }
1578
1579 if (is_array($_POST["id"])) {
1580 foreach ($_POST["id"] as $idx => $id) {
1581 $_POST["id"][$idx] = (int) $id;
1582 }
1583 }
1584
1585 // SAVE POST VALUES (get rid of this
1586 ilSession::set("saved_post", $_POST["id"]);
1587
1588 include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1589 $ru = new ilRepUtilGUI($this);
1590 if (!$ru->showDeleteConfirmation($_POST["id"], $a_error)) {
1591 $ilCtrl->returnToParent($this);
1592 }
1593 }
1594
1600 protected function showPossibleSubObjects()
1601 {
1602 if ($this->sub_objects == "") {
1603 $d = $this->objDefinition->getCreatableSubObjects($this->object->getType(), ilObjectDefinition::MODE_REPOSITORY, $this->ref_id);
1604 } else {
1606 }
1607
1608 $import = false;
1609
1610 if (count($d) > 0) {
1611 foreach ($d as $row) {
1612 $count = 0;
1613
1614 if ($row["max"] > 0) {
1615 //how many elements are present?
1616 for ($i=0; $i<count($this->data["ctrl"]); $i++) {
1617 if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
1618 $count++;
1619 }
1620 }
1621 }
1622
1623 if ($row["max"] == "" || $count < $row["max"]) {
1624 $subobj[] = $row["name"];
1625 }
1626 }
1627 }
1628
1629 if (is_array($subobj)) {
1630
1631 //build form
1632 $opts = ilUtil::formSelect(12, "new_type", $subobj);
1633 $this->tpl->setCurrentBlock("add_object");
1634 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1635 $this->tpl->setVariable("BTN_NAME", "create");
1636 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1637 $this->tpl->parseCurrentBlock();
1638 }
1639 }
1640
1649 final protected function getTemplateFile($a_cmd, $a_type = "")
1650 {
1651 mk();
1652 die("ilObjectGUI::getTemplateFile() is deprecated.");
1653 }
1654
1662 protected function getTabs()
1663 {
1664 // please define your tabs here
1665 }
1666
1667 // PROTECTED
1668 protected function __showButton($a_cmd, $a_text, $a_target = '')
1669 {
1670 $ilToolbar = $this->toolbar;
1671
1672 $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
1673 }
1674
1675 protected function hitsperpageObject()
1676 {
1677 ilSession::set("tbl_limit", $_POST["hitsperpage"]);
1678 $_GET["limit"] = $_POST["hitsperpage"];
1679 }
1680
1681
1682 protected function &__initTableGUI()
1683 {
1684 include_once "./Services/Table/classes/class.ilTableGUI.php";
1685
1686 return new ilTableGUI(0, false);
1687 }
1688
1694 protected function __setTableGUIBasicData(&$tbl, &$result_set, $a_from = "")
1695 {
1696 switch ($a_from) {
1697 case "clipboardObject":
1698 $offset = $_GET["offset"];
1699 $order = $_GET["sort_by"];
1700 $direction = $_GET["sort_order"];
1701 $tbl->disable("footer");
1702 break;
1703
1704 default:
1705 $offset = $_GET["offset"];
1706 $order = $_GET["sort_by"];
1707 $direction = $_GET["sort_order"];
1708 break;
1709 }
1710
1711 $tbl->setOrderColumn($order);
1712 $tbl->setOrderDirection($direction);
1713 $tbl->setOffset($offset);
1714 $tbl->setLimit($_GET["limit"]);
1715 $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1716 $tbl->setData($result_set);
1717 }
1718
1728 protected function redirectToRefId($a_ref_id, $a_cmd = "")
1729 {
1730 $obj_type = ilObject::_lookupType($a_ref_id, true);
1731 $class_name = $this->objDefinition->getClassName($obj_type);
1732 $class = strtolower("ilObj" . $class_name . "GUI");
1733 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id);
1734 $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
1735 }
1736
1737 // Object Cloning
1747 protected function fillCloneTemplate($a_tpl_varname, $a_type)
1748 {
1749 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
1750 $cp = new ilObjectCopyGUI($this);
1751 $cp->setType($a_type);
1752 $cp->setTarget($_GET['ref_id']);
1753 if ($a_tpl_varname) {
1754 $cp->showSourceSearch($a_tpl_varname);
1755 } else {
1756 return $cp->showSourceSearch(null);
1757 }
1758 }
1759
1766 public function cloneAllObject()
1767 {
1768 include_once('./Services/Link/classes/class.ilLink.php');
1769 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1770
1773
1774 $new_type = $_REQUEST['new_type'];
1775 if (!$this->checkPermissionBool("create", "", $new_type)) {
1776 $ilErr->raiseError($this->lng->txt('permission_denied'));
1777 }
1778 if (!(int) $_REQUEST['clone_source']) {
1779 ilUtil::sendFailure($this->lng->txt('select_one'));
1780 $this->createObject();
1781 return false;
1782 }
1783 if (!$this->checkPermissionBool("write", "", $new_type, (int) $_REQUEST['clone_source'])) {
1784 $ilErr->raiseError($this->lng->txt('permission_denied'));
1785 }
1786
1787 // Save wizard options
1789 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1790 $wizard_options->saveOwner($ilUser->getId());
1791 $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
1792
1793 $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1794 foreach ($options as $source_id => $option) {
1795 $wizard_options->addEntry($source_id, $option);
1796 }
1797 $wizard_options->read();
1798
1799 $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
1800 $new_obj = $orig->cloneObject((int) $_GET['ref_id'], $copy_id);
1801
1802 // Delete wizard options
1803 $wizard_options->deleteAll();
1804
1805 ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
1806 ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1807 }
1808
1809
1813 protected function getCenterColumnHTML()
1814 {
1816
1817 include_once("Services/Block/classes/class.ilColumnGUI.php");
1818
1819 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1820 $obj_type = ilObject::_lookupType($obj_id);
1821
1822 if ($ilCtrl->getNextClass() != "ilcolumngui") {
1823 // normal command processing
1824 return $this->getContent();
1825 } else {
1826 if (!$ilCtrl->isAsynch()) {
1827 //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1829 // right column wants center
1831 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1832 $this->setColumnSettings($column_gui);
1833 $this->html = $ilCtrl->forwardCommand($column_gui);
1834 }
1835 // left column wants center
1837 $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1838 $this->setColumnSettings($column_gui);
1839 $this->html = $ilCtrl->forwardCommand($column_gui);
1840 }
1841 } else {
1842 // normal command processing
1843 return $this->getContent();
1844 }
1845 }
1846 }
1847 }
1848
1852 protected function getRightColumnHTML()
1853 {
1855 $lng = $this->lng;
1857
1858 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1859 $obj_type = ilObject::_lookupType($obj_id);
1860
1861 include_once("Services/Block/classes/class.ilColumnGUI.php");
1862 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1863
1864 if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
1865 return "";
1866 }
1867
1868 $this->setColumnSettings($column_gui);
1869
1870 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
1871 $column_gui->getCmdSide() == IL_COL_RIGHT &&
1872 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
1873 $html = $ilCtrl->forwardCommand($column_gui);
1874 } else {
1875 if (!$ilCtrl->isAsynch()) {
1876 $html = $ilCtrl->getHTML($column_gui);
1877 }
1878 }
1879
1880 return $html;
1881 }
1882
1886 protected function setColumnSettings(ilColumnGUI $column_gui)
1887 {
1888 $column_gui->setRepositoryMode(true);
1889 $column_gui->setEnableEdit(false);
1890 if ($this->checkPermissionBool("write")) {
1891 $column_gui->setEnableEdit(true);
1892 }
1893 }
1894
1905 protected function checkPermission($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1906 {
1907 if (!$this->checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id)) {
1908 if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php"))) {
1909 // create: redirect to parent
1910 if ($a_perm == "create") {
1911 if (!$a_ref_id) {
1912 $a_ref_id = $_GET["ref_id"];
1913 }
1914 $type = ilObject::_lookupType($a_ref_id, true);
1915 } else {
1916 // does this make sense?
1917 if (!is_object($this->object)) {
1918 return;
1919 }
1920 if (!$a_ref_id) {
1921 $a_ref_id = $this->object->getRefId();
1922 }
1923 $type = $this->object->getType();
1924 }
1925
1926 ilSession::clear("il_rep_ref_id");
1927
1928 include_once "Services/Object/exceptions/class.ilObjectException.php";
1929 throw new ilObjectException($this->lng->txt("permission_denied"));
1930
1931 /*
1932 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
1933 ilUtil::redirect("goto.php?target=".$type."_".$a_ref_id);
1934 */
1935 }
1936 // we should never be here
1937 else {
1938 die("Permission Denied.");
1939 }
1940 }
1941 }
1942
1952 protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1953 {
1954 $ilAccess = $this->access;
1955
1956 if ($a_perm == "create") {
1957 if (!$a_ref_id) {
1958 $a_ref_id = $_GET["ref_id"];
1959 }
1960 return $ilAccess->checkAccess($a_perm . "_" . $a_type, $a_cmd, $a_ref_id);
1961 } else {
1962 // does this make sense?
1963 if (!is_object($this->object)) {
1964 return false;
1965 }
1966 if (!$a_ref_id) {
1967 $a_ref_id = $this->object->getRefId();
1968 }
1969 return $ilAccess->checkAccess($a_perm, $a_cmd, $a_ref_id);
1970 }
1971 }
1972
1979 public static function _gotoRepositoryRoot($a_raise_error = false)
1980 {
1981 global $DIC;
1982
1983 $ilAccess = $DIC->access();
1984 $ilErr = $DIC["ilErr"];
1985 $lng = $DIC->language();
1986
1987 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1988 $_GET["cmd"] = "frameset";
1989 $_GET["target"] = "";
1990 $_GET["ref_id"] = ROOT_FOLDER_ID;
1991 $_GET["baseClass"] = "ilRepositoryGUI";
1992 include("ilias.php");
1993 exit;
1994 }
1995
1996 if ($a_raise_error) {
1997 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1998 }
1999 }
2000
2007 public static function _gotoRepositoryNode($a_ref_id, $a_cmd = "frameset")
2008 {
2009 global $DIC;
2010
2011 $ilAccess = $DIC->access();
2012 $ilErr = $DIC["ilErr"];
2013
2014 $_GET["cmd"] = $a_cmd;
2015 $_GET["target"] = "";
2016 $_GET["ref_id"] = $a_ref_id;
2017 $_GET["baseClass"] = "ilRepositoryGUI";
2018 include("ilias.php");
2019 exit;
2020 }
2021
2025 protected function enableDragDropFileUpload()
2026 {
2027 include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
2029
2030 $this->tpl->enableDragDropFileUpload($this->ref_id);
2031 }
2032
2038 protected function handleAutoRating(ilObject $a_new_obj)
2039 {
2040 if (ilObject::hasAutoRating($a_new_obj->getType(), $a_new_obj->getRefId()) &&
2041 method_exists($a_new_obj, "setRating")) {
2042 $a_new_obj->setRating(true);
2043 $a_new_obj->update();
2044 }
2045 }
2046} // END class.ilObjectGUI (3.10: 2896 loc)
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
html()
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$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 _allocateCopyId()
Allocate a copy for further entries.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
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.
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.
Import class.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
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)
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)
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()
list childs of current object
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
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
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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)
$template
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
$lg
Definition: example_018.php:62
$tbl
Definition: example_048.php:81
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
if($format !==null) $name
Definition: metadata.php:146
$keys
redirection script todo: (a better solution should control the processing via a xml file)
$type
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$this data['403_header']
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$params
Definition: disable.php:11