ILIAS  release_8 Revision v8.24
class.ilObjMediaObjectsSettingsGUI.php
Go to the documentation of this file.
1<?php
2
26{
29 protected ilTabsGUI $tabs;
30
31 public function __construct(
32 $a_data,
33 int $a_id,
34 bool $a_call_by_reference = true,
35 bool $a_prepare_output = true
36 ) {
37 global $DIC;
38 $this->error = $DIC["ilErr"];
39 $this->access = $DIC->access();
40 $this->tabs = $DIC->tabs();
41 $this->tpl = $DIC["tpl"];
42 $this->lng = $DIC->language();
43 $this->ctrl = $DIC->ctrl();
44 $this->type = 'mobs';
45 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
46
47 $this->lng->loadLanguageModule('mob');
48 $this->lng->loadLanguageModule('mep');
49 $this->lng->loadLanguageModule('content');
50 }
51
52 public function executeCommand(): void
53 {
54 $next_class = $this->ctrl->getNextClass($this);
55 $cmd = $this->ctrl->getCmd();
56
57 $this->prepareOutput();
58
59 if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
60 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
61 }
62
63 switch ($next_class) {
64 case 'ilpermissiongui':
65 $this->tabs_gui->setTabActive('perm_settings');
66 $perm_gui = new ilPermissionGUI($this);
67 $this->ctrl->forwardCommand($perm_gui);
68 break;
69
70 default:
71 if (!$cmd || $cmd == 'view') {
72 $cmd = "editSettings";
73 }
74 $this->$cmd();
75 break;
76 }
77 }
78
79 public function getAdminTabs(): void
80 {
81 $ilAccess = $this->access;
82 $ilTabs = $this->tabs;
83
84 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
85 $ilTabs->addTarget(
86 "settings",
87 $this->ctrl->getLinkTarget($this, "editSettings"),
88 array("editSettings", "view")
89 );
90 }
91
92 if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
93 $ilTabs->addTarget(
94 "perm_settings",
95 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
96 array(),
97 'ilpermissiongui'
98 );
99 }
100 }
101
102 public function editSettings(
103 bool $a_omit_init = false
104 ): void {
105 $tpl = $this->tpl;
106
107 if (!$a_omit_init) {
109 $this->getSettingsValues();
110 }
111 $tpl->setContent($this->form->getHTML());
112 }
113
114 public function saveSettings(): void
115 {
117 $ilCtrl = $this->ctrl;
118
119 $this->checkPermission("write");
120
121 $this->initMediaObjectsSettingsForm();
122 if ($this->form->checkInput()) {
123 // perform save
124 $mset = new ilSetting("mobs");
125 $mset->set("mep_activate_pages", $this->form->getInput("activate_pages"));
126 $mset->set("file_manager_always", $this->form->getInput("file_manager_always"));
127 $mset->set("restricted_file_types", $this->form->getInput("restricted_file_types"));
128 $mset->set("black_list_file_types", $this->form->getInput("black_list_file_types"));
129
130 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
131 $ilCtrl->redirect($this, "editSettings");
132 }
133
134 $this->form->setValuesByPost();
135 $this->editSettings(true);
136 }
137
141 public function initMediaObjectsSettingsForm(): void
142 {
144 $ilCtrl = $this->ctrl;
145 $ilAccess = $this->access;
146
147
148 $this->form = new ilPropertyFormGUI();
149
150 // activate page in media pool
151 $cb = new ilCheckboxInputGUI($lng->txt("mobs_activate_pages"), "activate_pages");
152 $cb->setInfo($lng->txt("mobs_activate_pages_info"));
153 $this->form->addItem($cb);
154
155 // activate page in media pool
156 $cb = new ilCheckboxInputGUI($lng->txt("mobs_always_show_file_manager"), "file_manager_always");
157 $cb->setInfo($lng->txt("mobs_always_show_file_manager_info"));
158 $this->form->addItem($cb);
159
160 // allowed file types
161 $ta = new ilTextAreaInputGUI($this->lng->txt("mobs_restrict_file_types"), "restricted_file_types");
162 //$ta->setCols();
163 //$ta->setRows();
164 $ta->setInfo($this->lng->txt("mobs_restrict_file_types_info"));
165 $this->form->addItem($ta);
166
167 // black lis file types
168 $ta = new ilTextAreaInputGUI($this->lng->txt("mobs_black_list_file_types"), "black_list_file_types");
169 $ta->setInfo($this->lng->txt("mobs_black_list_file_types_info"));
170 $this->form->addItem($ta);
171
172 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
173 $this->form->addCommandButton("saveSettings", $lng->txt("save"));
174 }
175
176 $this->form->setTitle($lng->txt("settings"));
177 $this->form->setFormAction($ilCtrl->getFormAction($this));
178 }
179
180 public function getSettingsValues(): void
181 {
182 $values = array();
183
184 $mset = new ilSetting("mobs");
185 $values["activate_pages"] = $mset->get("mep_activate_pages");
186 $values["file_manager_always"] = $mset->get("file_manager_always");
187 $values["restricted_file_types"] = $mset->get("restricted_file_types");
188 $values["black_list_file_types"] = $mset->get("black_list_file_types");
189
190 $this->form->setValuesByArray($values);
191 }
192}
error(string $a_errmsg)
This class represents a checkbox property in a property form.
Error Handling & global info handling uses PEAR error class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdminTabs()
administration tabs show only permissions and trash folder
initMediaObjectsSettingsForm()
Init media objects settings form.
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
Class ilObjectGUI Basic methods of all Output classes.
ilAccessHandler $access
ilGlobalTemplateInterface $tpl
prepareOutput(bool $show_sub_objects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)
This class represents a text area property in a property form.
global $DIC
Definition: feed.php:28
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd)
$lng