ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjMediaCastSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 include_once("./Services/Object/classes/class.ilObjectGUI.php");
24 
25 
38 {
39 
43  protected $error;
44 
45  private static $ERROR_MESSAGE;
51  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
52  {
53  global $DIC;
54  $this->error = $DIC["ilErr"];
55  $this->access = $DIC->access();
56  $this->ctrl = $DIC->ctrl();
57  $this->lng = $DIC->language();
58  $this->type = 'mcts';
59  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
60 
61  $this->lng->loadLanguageModule('mcst');
62  $this->initMediaCastSettings();
63  }
64 
71  public function executeCommand()
72  {
73  $next_class = $this->ctrl->getNextClass($this);
74  $cmd = $this->ctrl->getCmd();
75 
76  $this->prepareOutput();
77 
78  if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
79  $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
80  }
81 
82  switch ($next_class) {
83  case 'ilpermissiongui':
84  $this->tabs_gui->setTabActive('perm_settings');
85  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
86  $perm_gui = new ilPermissionGUI($this);
87  $this->ctrl->forwardCommand($perm_gui);
88  break;
89 
90  default:
91  if (!$cmd || $cmd == 'view') {
92  $cmd = "editSettings";
93  }
94 
95  $this->$cmd();
96  break;
97  }
98  return true;
99  }
100 
107  public function getAdminTabs()
108  {
110  $ilAccess = $this->access;
111 
112  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
113  $this->tabs_gui->addTarget(
114  "mcst_edit_settings",
115  $this->ctrl->getLinkTarget($this, "editSettings"),
116  array("editSettings", "view")
117  );
118  }
119 
120  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
121  $this->tabs_gui->addTarget(
122  "perm_settings",
123  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
124  array(),
125  'ilpermissiongui'
126  );
127  }
128  }
129 
133  public function editSettings()
134  {
135  $this->tabs_gui->setTabActive('mcst_edit_settings');
136  $this->initFormSettings();
137  return true;
138  }
139 
143  public function saveSettings()
144  {
145  $ilCtrl = $this->ctrl;
146  $ilAccess = $this->access;
147 
148  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
149  foreach ($this->settings->getPurposeSuffixes() as $purpose => $filetypes) {
150  $purposeSuffixes[$purpose] = explode(",", preg_replace("/[^\w,]/", "", strtolower($_POST[$purpose])));
151  }
152 
153  $this->settings->setPurposeSuffixes($purposeSuffixes);
154  $this->settings->setDefaultAccess($_POST["defaultaccess"]);
155  $this->settings->setMimeTypes(explode(",", $_POST["mimetypes"]));
156 
157  $this->settings->save();
158 
159  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
160  }
161 
162  $ilCtrl->redirect($this, "view");
163  }
164 
168  public function cancel()
169  {
170  $ilCtrl = $this->ctrl;
171 
172  $ilCtrl->redirect($this, "view");
173  }
174 
179  protected function initMediaCastSettings()
180  {
181  include_once('Modules/MediaCast/classes/class.ilMediaCastSettings.php');
183  }
184 
190  protected function initFormSettings()
191  {
192  $lng = $this->lng;
193  $ilAccess = $this->access;
194  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
195 
196  $form = new ilPropertyFormGUI();
197  $form->setFormAction($this->ctrl->getFormAction($this));
198  $form->setTitle($this->lng->txt('settings'));
199 
200  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
201  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
202  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
203  }
204 
205  //Default Visibility
206  $radio_group = new ilRadioGroupInputGUI($lng->txt("mcst_default_visibility"), "defaultaccess");
207  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_users"), "users");
208  $radio_group->addOption($radio_option);
209  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_public"), "public");
210  $radio_group->addOption($radio_option);
211  $radio_group->setInfo($lng->txt("mcst_news_item_visibility_info"));
212  $radio_group->setRequired(false);
213  $radio_group->setValue($this->settings->getDefaultAccess());
214  #$ch->addSubItem($radio_group);
215  $form->addItem($radio_group);
216 
217 
218  foreach ($this->settings->getPurposeSuffixes() as $purpose => $filetypes) {
219  if ($purpose != "VideoAlternative") {
220  $text = new ilTextInputGUI($lng->txt("mcst_" . strtolower($purpose) . "_settings_title"), $purpose);
221  $text->setValue(implode(",", $filetypes));
222  $text->setInfo($lng->txt("mcst_" . strtolower($purpose) . "_settings_info"));
223  $form->addItem($text);
224  }
225  }
226 
227  $text = new ilTextAreaInputGUI($lng->txt("mcst_mimetypes"), "mimetypes");
228  $text->setInfo($lng->txt("mcst_mimetypes_info"));
229  $text->setCols(120);
230  $text->setRows(10);
231  if (is_array($this->settings->getMimeTypes())) {
232  $text->setValue(implode(",", $this->settings->getMimeTypes()));
233  }
234  $form->addItem($text);
235 
236  $this->tpl->setContent($form->getHTML());
237  }
238 }
This class represents an option in a radio group.
settings()
Definition: settings.php:2
This class represents a property form user interface.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
setInfo($a_info)
Set Info.
initMediaCastSettings()
iniitialize settings storage for media cast
setInfo($a_info)
Set Information Text.
prepareOutput($a_show_subobjects=true)
prepare output
This class represents a property in a property form.
initFormSettings()
Init settings property form.
Class ilObjectGUI Basic methods of all Output classes.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static _getInstance()
get singleton instance
$_POST["username"]