ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
42  protected $rbacsystem;
43 
47  protected $error;
48 
49  private static $ERROR_MESSAGE;
55  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
56  {
57  global $DIC;
58 
59  $this->rbacsystem = $DIC->rbac()->system();
60  $this->error = $DIC["ilErr"];
61  $this->access = $DIC->access();
62  $this->ctrl = $DIC->ctrl();
63  $this->lng = $DIC->language();
64  $this->type = 'mcts';
65  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
66 
67  $this->lng->loadLanguageModule('mcst');
68  $this->initMediaCastSettings();
69  }
70 
77  public function executeCommand()
78  {
81  $ilAccess = $this->access;
82 
83  $next_class = $this->ctrl->getNextClass($this);
84  $cmd = $this->ctrl->getCmd();
85 
86  $this->prepareOutput();
87 
88  if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
89  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
90  }
91 
92  switch ($next_class) {
93  case 'ilpermissiongui':
94  $this->tabs_gui->setTabActive('perm_settings');
95  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
96  $perm_gui = new ilPermissionGUI($this);
97  $this->ctrl->forwardCommand($perm_gui);
98  break;
99 
100  default:
101  if (!$cmd || $cmd == 'view') {
102  $cmd = "editSettings";
103  }
104 
105  $this->$cmd();
106  break;
107  }
108  return true;
109  }
110 
117  public function getAdminTabs()
118  {
120  $ilAccess = $this->access;
121 
122  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
123  $this->tabs_gui->addTarget(
124  "mcst_edit_settings",
125  $this->ctrl->getLinkTarget($this, "editSettings"),
126  array("editSettings", "view")
127  );
128  }
129 
130  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
131  $this->tabs_gui->addTarget(
132  "perm_settings",
133  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
134  array(),
135  'ilpermissiongui'
136  );
137  }
138  }
139 
143  public function editSettings()
144  {
145  $this->tabs_gui->setTabActive('mcst_edit_settings');
146  $this->initFormSettings();
147  return true;
148  }
149 
153  public function saveSettings()
154  {
156  $ilAccess = $this->access;
157 
158  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
159  foreach ($this->settings->getPurposeSuffixes() as $purpose => $filetypes) {
160  $purposeSuffixes[$purpose] = explode(",", preg_replace("/[^\w,]/", "", strtolower($_POST[$purpose])));
161  }
162 
163  $this->settings->setPurposeSuffixes($purposeSuffixes);
164  $this->settings->setDefaultAccess($_POST["defaultaccess"]);
165  $this->settings->setMimeTypes(explode(",", $_POST["mimetypes"]));
166 
167  $this->settings->save();
168 
169  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
170  }
171 
172  $ilCtrl->redirect($this, "view");
173  }
174 
178  public function cancel()
179  {
181 
182  $ilCtrl->redirect($this, "view");
183  }
184 
189  protected function initMediaCastSettings()
190  {
191  include_once('Modules/MediaCast/classes/class.ilMediaCastSettings.php');
193  }
194 
200  protected function initFormSettings()
201  {
202  $lng = $this->lng;
203  $ilAccess = $this->access;
204  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
205 
206  $form = new ilPropertyFormGUI();
207  $form->setFormAction($this->ctrl->getFormAction($this));
208  $form->setTitle($this->lng->txt('settings'));
209 
210  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
211  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
212  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
213  }
214 
215  //Default Visibility
216  $radio_group = new ilRadioGroupInputGUI($lng->txt("mcst_default_visibility"), "defaultaccess");
217  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_users"), "users");
218  $radio_group->addOption($radio_option);
219  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_public"), "public");
220  $radio_group->addOption($radio_option);
221  $radio_group->setInfo($lng->txt("mcst_news_item_visibility_info"));
222  $radio_group->setRequired(false);
223  $radio_group->setValue($this->settings->getDefaultAccess());
224  #$ch->addSubItem($radio_group);
225  $form->addItem($radio_group);
226 
227 
228  foreach ($this->settings->getPurposeSuffixes() as $purpose => $filetypes) {
229  if ($purpose != "VideoAlternative") {
230  $text = new ilTextInputGUI($lng->txt("mcst_" . strtolower($purpose) . "_settings_title"), $purpose);
231  $text->setValue(implode(",", $filetypes));
232  $text->setInfo($lng->txt("mcst_" . strtolower($purpose) . "_settings_info"));
233  $form->addItem($text);
234  }
235  }
236 
237  $text = new ilTextAreaInputGUI($lng->txt("mcst_mimetypes"), "mimetypes");
238  $text->setInfo($lng->txt("mcst_mimetypes_info"));
239  $text->setCols(120);
240  $text->setRows(10);
241  if (is_array($this->settings->getMimeTypes())) {
242  $text->setValue(implode(",", $this->settings->getMimeTypes()));
243  }
244  $form->addItem($text);
245 
246  $this->tpl->setContent($form->getHTML());
247  }
248 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents an option in a radio group.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
setInfo($a_info)
Set Info.
global $ilCtrl
Definition: ilias.php:18
initMediaCastSettings()
iniitialize settings storage for media cast
prepareOutput($a_show_subobjects=true)
prepare output
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
initFormSettings()
Init settings property form.
Class ilObjectGUI Basic methods of all Output classes.
$text
Definition: errorreport.php:18
This class represents a text property in a property form.
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
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"]