ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjMediaCastSettingsGUI.php
Go to the documentation of this file.
1<?php
2
20
28{
31
35 public function __construct(
36 $a_data,
37 int $a_id,
38 bool $a_call_by_reference = true,
39 bool $a_prepare_output = true
40 ) {
41 global $DIC;
42 $this->access = $DIC->access();
43 $this->ctrl = $DIC->ctrl();
44 $this->lng = $DIC->language();
45 $this->type = 'mcts';
46 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
47
48 $this->lng->loadLanguageModule('mcst');
49 $this->mc_settings = ilMediaCastSettings::_getInstance();
50 $this->mc_request = $DIC->mediaCast()
51 ->internal()
52 ->gui()
53 ->standardRequest();
54 }
55
56 public function executeCommand(): void
57 {
58 $next_class = $this->ctrl->getNextClass($this);
59 $cmd = $this->ctrl->getCmd();
60
61 $this->prepareOutput();
62
63 if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
64 throw new ilPermissionException($this->lng->txt('no_permission'));
65 }
66
67 switch ($next_class) {
68 case 'ilpermissiongui':
69 $this->tabs_gui->setTabActive('perm_settings');
70 $perm_gui = new ilPermissionGUI($this);
71 $this->ctrl->forwardCommand($perm_gui);
72 break;
73
74 default:
75 if (!$cmd || $cmd == 'view') {
76 $cmd = "editSettings";
77 }
78
79 $this->$cmd();
80 break;
81 }
82 }
83
84 public function getAdminTabs(): void
85 {
87
88 if ($rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
89 $this->tabs_gui->addTarget(
90 "mcst_edit_settings",
91 $this->ctrl->getLinkTarget($this, "editSettings"),
92 array("editSettings", "view")
93 );
94 }
95
96 if ($rbac_system->checkAccess('edit_permission', $this->object->getRefId())) {
97 $this->tabs_gui->addTarget(
98 "perm_settings",
99 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
100 array(),
101 'ilpermissiongui'
102 );
103 }
104 }
105
106 public function editSettings(): void
107 {
108 $this->tabs_gui->setTabActive('mcst_edit_settings');
109 $this->initFormSettings();
110 }
111
112 public function saveSettings(): void
113 {
114 $ilCtrl = $this->ctrl;
115 $ilAccess = $this->access;
116 $purposeSuffixes = [];
117 $form = $this->getForm();
118
119 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
120 /*
121 foreach ($this->mc_settings->getPurposeSuffixes() as $purpose => $filetypes) {
122 $purposeSuffixes[$purpose] = explode(",", preg_replace("/[^\w,]/", "", strtolower($this->mc_request->getSettingsPurpose($purpose))));
123 }*/
124
125 if ($form->checkInput()) {
126 //$this->mc_settings->setPurposeSuffixes($purposeSuffixes);
127 $this->mc_settings->setDefaultAccess($form->getInput("defaultaccess"));
128 //$this->mc_settings->setMimeTypes(explode(",", $form->getInput("mimetypes")));
129 $this->mc_settings->setVideoCompletionThreshold((int) $form->getInput("video_completion_threshold"));
130
131 $this->mc_settings->save();
132
133 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
134 } else {
135 $form->setValuesByPost();
136 $this->initFormSettings($form);
137 return;
138 }
139 }
140 $this->initMediaCastSettings();
141 $ilCtrl->redirect($this, "view");
142 }
143
144 public function cancel(): void
145 {
146 $ilCtrl = $this->ctrl;
147 $ilCtrl->redirect($this, "view");
148 }
149
150 protected function initMediaCastSettings(): void
151 {
152 $this->mc_settings = ilMediaCastSettings::_getInstance();
153 }
154
155 protected function getForm(): ilPropertyFormGUI
156 {
158 $ilAccess = $this->access;
159
160 $form = new ilPropertyFormGUI();
161 $form->setFormAction($this->ctrl->getFormAction($this));
162 $form->setTitle($this->lng->txt('settings'));
163
164 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
165 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
166 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
167 }
168
169 //Default Visibility
170 $radio_group = new ilRadioGroupInputGUI($lng->txt("mcst_default_visibility"), "defaultaccess");
171 $radio_option = new ilRadioOption($lng->txt("mcst_visibility_users"), "users");
172 $radio_group->addOption($radio_option);
173 $radio_option = new ilRadioOption($lng->txt("mcst_visibility_public"), "public");
174 $radio_group->addOption($radio_option);
175 $radio_group->setInfo($lng->txt("mcst_news_item_visibility_info"));
176 $radio_group->setRequired(false);
177 $radio_group->setValue($this->mc_settings->getDefaultAccess());
178 #$ch->addSubItem($radio_group);
179 $form->addItem($radio_group);
180
181 // video completion threshold
182 $ti = new ilNumberInputGUI($lng->txt("mcst_video_completion_threshold"), "video_completion_threshold");
183 $ti->setMaxLength(3);
184 $ti->setSize(3);
185 $ti->setSuffix("%");
186 $ti->setMaxValue(100);
187 $ti->setMinValue(0);
188 $ti->setInfo($lng->txt("mcst_video_completion_threshold_info"));
189 $ti->setValue($this->mc_settings->getVideoCompletionThreshold());
190 $form->addItem($ti);
191
192 /*
193 foreach ($this->mc_settings->getPurposeSuffixes() as $purpose => $filetypes) {
194 if ($purpose !== "VideoAlternative") {
195 $text = new ilTextInputGUI($lng->txt("mcst_" . strtolower($purpose) . "_settings_title"), $purpose);
196 $text->setValue(implode(",", $filetypes));
197 $text->setInfo($lng->txt("mcst_" . strtolower($purpose) . "_settings_info"));
198 $form->addItem($text);
199 }
200 }
201
202 $text = new ilTextAreaInputGUI($lng->txt("mcst_mimetypes"), "mimetypes");
203 $text->setInfo($lng->txt("mcst_mimetypes_info"));
204 $text->setCols(120);
205 $text->setRows(10);
206 if (is_array($this->mc_settings->getMimeTypes())) {
207 $text->setValue(implode(",", $this->mc_settings->getMimeTypes()));
208 }
209 $form->addItem($text);*/
210
211 return $form;
212 }
213
214 protected function initFormSettings(?ilPropertyFormGUI $form = null): void
215 {
216 if (!$form) {
217 $form = $this->getForm();
218 }
219 $this->tpl->setContent($form->getHTML());
220 }
221}
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Stores all mediacast relevant settings.
This class represents a number property in a property form.
getAdminTabs()
administration tabs show only permissions and trash folder
initFormSettings(?ilPropertyFormGUI $form=null)
__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
ilRbacSystem $rbac_system
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
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.
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26