ILIAS  Release_3_10_x_branch Revision 61812
 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-2008 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("./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 
143  $this->settings->save();
144 
145  ilUtil::sendInfo($this->lng->txt("settings_saved"),true);
146 
147  $ilCtrl->redirect($this, "view");
148  }
149 
153  public function cancel()
154  {
155  global $ilCtrl;
156 
157  $ilCtrl->redirect($this, "view");
158  }
159 
164  protected function initMediaCastSettings()
165  {
166  include_once('Modules/MediaCast/classes/class.ilMediaCastSettings.php');
167  $this->settings = ilMediaCastSettings::_getInstance();
168  }
169 
175  protected function initFormSettings()
176  {
177  global $lng;
178  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
179 
180  $form = new ilPropertyFormGUI();
181  $form->setFormAction($this->ctrl->getFormAction($this));
182  $form->setTitle($this->lng->txt('mcst_file_extension_settings'));
183  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
184  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
185  foreach ($this->settings->getPurposeSuffixes() as $purpose => $filetypes)
186  {
187  $text = new ilTextInputGUI($lng->txt("mcst_".strtolower($purpose)."_settings_title"),$purpose);
188  $text->setValue(implode(",",$filetypes));
189  $text->setInfo($lng->txt("mcst_".strtolower($purpose)."_settings_info"));
190  $form->addItem($text);
191  }
192  //Default Visibility
193  $radio_group = new ilRadioGroupInputGUI($lng->txt("mcst_default_visibility"), "defaultaccess");
194  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_users"), "users");
195  $radio_group->addOption($radio_option);
196  $radio_option = new ilRadioOption($lng->txt("mcst_visibility_public"), "public");
197  $radio_group->addOption($radio_option);
198  $radio_group->setInfo($lng->txt("mcst_news_item_visibility_info"));
199  $radio_group->setRequired(false);
200  $radio_group->setValue($this->settings->getDefaultAccess());
201  #$ch->addSubItem($radio_group);
202  $form->addItem($radio_group);
203  $this->tpl->setContent($form->getHTML());
204  }
205 }
206 ?>