ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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("./classes/class.ilObjectGUI.php");
24 
25 
38 {
39  private static $ERROR_MESSAGE;
45  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
46  {
47  $this->type = 'mcts';
48  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
49 
50  $this->lng->loadLanguageModule('mcst');
51  $this->initMediaCastSettings();
52  }
53 
60  public function executeCommand()
61  {
62  global $rbacsystem,$ilErr,$ilAccess;
63 
64  $next_class = $this->ctrl->getNextClass($this);
65  $cmd = $this->ctrl->getCmd();
66 
67  $this->prepareOutput();
68 
69  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
70  {
71  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
72  }
73 
74  switch($next_class)
75  {
76  case 'ilpermissiongui':
77  $this->tabs_gui->setTabActive('perm_settings');
78  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
79  $perm_gui =& new ilPermissionGUI($this);
80  $ret =& $this->ctrl->forwardCommand($perm_gui);
81  break;
82 
83  default:
84  if(!$cmd || $cmd == 'view')
85  {
86  $cmd = "editSettings";
87  }
88 
89  $this->$cmd();
90  break;
91  }
92  return true;
93  }
94 
101  public function getAdminTabs()
102  {
103  global $rbacsystem, $ilAccess;
104 
105  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
106  {
107  $this->tabs_gui->addTarget("mcst_edit_settings",
108  $this->ctrl->getLinkTarget($this, "editSettings"),
109  array("editSettings", "view"));
110  }
111 
112  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
113  {
114  $this->tabs_gui->addTarget("perm_settings",
115  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
116  array(),'ilpermissiongui');
117  }
118  }
119 
123  public function editSettings()
124  {
125  $this->tabs_gui->setTabActive('mcst_edit_settings');
126  $this->initFormSettings();
127  return true;
128  }
129 
133  public function saveSettings()
134  {
135  global $ilCtrl;
136  foreach ($this->settings->getPurposeSuffixes() as $purpose => $filetypes) {
137  $purposeSuffixes[$purpose] = explode(",", preg_replace("/[^\w,]/", "", strtolower($_POST[$purpose])));
138  }
139 
140  $this->settings->setPurposeSuffixes($purposeSuffixes);
141  $this->settings->setDefaultAccess ($_POST["defaultaccess"]);
142  $this->settings->setMimeTypes (explode(",", $_POST["mimetypes"]));
143 
144  $this->settings->save();
145 
146  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
147 
148  $ilCtrl->redirect($this, "view");
149  }
150 
154  public function cancel()
155  {
156  global $ilCtrl;
157 
158  $ilCtrl->redirect($this, "view");
159  }
160 
165  protected function initMediaCastSettings()
166  {
167  include_once('Modules/MediaCast/classes/class.ilMediaCastSettings.php');
168  $this->settings = ilMediaCastSettings::_getInstance();
169  }
170 
176  protected function initFormSettings()
177  {
178  global $lng;
179  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
180 
181  $form = new ilPropertyFormGUI();
182  $form->setFormAction($this->ctrl->getFormAction($this));
183  $form->setTitle($this->lng->txt('settings'));
184  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
185  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
186 
187  //Default Visibility
188  $radio_group = new ilRadioGroupInputGUI($lng->txt("mcst_default_visibility"), "defaultaccess");
189  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_users"), "users");
190  $radio_group->addOption($radio_option);
191  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_public"), "public");
192  $radio_group->addOption($radio_option);
193  $radio_group->setInfo($lng->txt("mcst_news_item_visibility_info"));
194  $radio_group->setRequired(false);
195  $radio_group->setValue($this->settings->getDefaultAccess());
196  #$ch->addSubItem($radio_group);
197  $form->addItem($radio_group);
198 
199 
200  foreach ($this->settings->getPurposeSuffixes() as $purpose => $filetypes)
201  {
202  $text = new ilTextInputGUI($lng->txt("mcst_".strtolower($purpose)."_settings_title"),$purpose);
203  $text->setValue(implode(",",$filetypes));
204  $text->setInfo($lng->txt("mcst_".strtolower($purpose)."_settings_info"));
205  $form->addItem($text);
206  }
207 
208  $text = new ilTextAreaInputGUI($lng->txt("mcst_mimetypes"), "mimetypes");
209  $text->setInfo($lng->txt("mcst_mimetypes_info"));
210  $text->setCols(120);
211  $text->setRows(10);
212  if (is_array($this->settings->getMimeTypes()))
213  $text->setValue(implode(",",$this->settings->getMimeTypes()));
214  $form->addItem($text);
215 
216  $this->tpl->setContent($form->getHTML());
217  }
218 }
219 ?>