ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFileAccessSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 // BEGIN WebDAV
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23 */
24 
38 include_once "classes/class.ilObjectGUI.php";
39 
41 {
46  function ilObjFileAccessSettingsGUI($a_data,$a_id,$a_call_by_reference)
47  {
48  $this->type = "facs";
49  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
50  $this->folderSettings = new ilSetting('fold');
51 
52  }
59  public function executeCommand()
60  {
61  global $rbacsystem,$ilErr,$ilAccess;
62 
63  $next_class = $this->ctrl->getNextClass($this);
64  $cmd = $this->ctrl->getCmd();
65 
66  $this->prepareOutput();
67 
68  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
69  {
70  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
71  }
72 
73  switch($next_class)
74  {
75  case 'ilpermissiongui':
76  $this->tabs_gui->setTabActive('perm_settings');
77  include_once("./classes/class.ilPermissionGUI.php");
78  $perm_gui =& new ilPermissionGUI($this);
79  $ret =& $this->ctrl->forwardCommand($perm_gui);
80  break;
81 
82  default:
83  $this->tabs_gui->setTabActive('settings');
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("settings",
108  $this->ctrl->getLinkTarget($this, "editSettings"),
109  array("editSettings", "view"));
110  }
111  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
112  {
113  $this->tabs_gui->addTarget("perm_settings",
114  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
115  array(),'ilpermissiongui');
116  }
117  }
118 
122  public function editSettings()
123  {
124  global $rbacsystem, $ilErr;
125 
126  if (! $rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
127  {
128  $ilErr->raiseError($this->lng->txt("no_permission"),$ilErr->WARNING);
129  }
130 
131  global $tpl, $ilCtrl, $lng, $tree, $settings;
132 
133  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
134  require_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
135  require_once("./Services/Form/classes/class.ilRadioGroupInputGUI.php");
136  require_once("./Services/Form/classes/class.ilRadioOption.php");
137  require_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
138  require_once("./Services/WebDAV/classes/class.ilDAVServer.php");
139 
140  $form = new ilPropertyFormGUI();
141  $form->setFormAction($ilCtrl->getFormAction($this));
142  $form->setTitle($lng->txt("settings"));
143 
144 
145  // show download action for folder
146 
147  $ilDAVServer = new ilDAVServer();
148  $dl_prop = new ilCheckboxInputGUI($lng->txt("enable_download_folder"), "enable_download_folder");
149  $dl_prop->setValue('1');
150  // default value should reflect previous behaviour (-> 0)
151  $dl_prop->setChecked($this->folderSettings->get("enable_download_folder", 0) == 1);
152  $dl_prop->setInfo($lng->txt('enable_download_folder_info'));
153  $form->addItem($dl_prop);
154 
155 
156  // Enable webdav
157  $isPearAuthHTTPInstalled = @include_once("Auth/HTTP.php");
158  $cb_prop = new ilCheckboxInputGUI($lng->txt("enable_webdav"), "enable_webdav");
159  $cb_prop->setValue('1');
160  $cb_prop->setChecked($this->object->isWebdavEnabled() && $isPearAuthHTTPInstalled);
161  $cb_prop->setDisabled(! $isPearAuthHTTPInstalled);
162  $cb_prop->setInfo($isPearAuthHTTPInstalled ?
163  sprintf($lng->txt('enable_webdav_info'),$ilDAVServer->getMountURI($tree->getRootId(), 0, null, null, true)) :
164  $lng->txt('webdav_pear_auth_http_needed')
165  );
166  $form->addItem($cb_prop);
167 
168  // Show webdav actions next to each item
169  $cb_prop = new ilCheckboxInputGUI($lng->txt("display_webdav_actions"), "webdav_actions_visible");
170  $cb_prop->setValue('1');
171  $cb_prop->setChecked($this->object->isWebdavActionsVisible() && $isPearAuthHTTPInstalled);
172  $cb_prop->setDisabled(! $isPearAuthHTTPInstalled);
173  $cb_prop->setInfo(sprintf($lng->txt('display_webdav_actions_info')));
174  $form->addItem($cb_prop);
175 
176  // Webdav help text
177  if ($isPearAuthHTTPInstalled)
178  {
179  $rgi_prop = new ilRadioGroupInputGUI($lng->txt('webfolder_instructions'), 'custom_webfolder_instructions_choice');
180  $rgi_prop->addOption(new ilRadioOption($lng->txt('use_default_instructions'), 'default'));
181  $rgi_prop->addOption(new ilRadioOption($lng->txt('use_customized_instructions'), 'custom'));
182  $rgi_prop->setValue($this->object->isCustomWebfolderInstructionsEnabled() ? 'custom':'default');
183  $rgi_prop->setDisabled(! $isPearAuthHTTPInstalled);
184  $form->addItem($rgi_prop);
185  $tai_prop = new ilTextAreaInputGUI('', 'custom_webfolder_instructions');
186  $tai_prop->setValue($this->object->getCustomWebfolderInstructions());
187  $tai_prop->setInfo($lng->txt("webfolder_instructions_info"));
188  $tai_prop->setCols(80);
189  $tai_prop->setRows(20);
190  $tai_prop->setDisabled(! $isPearAuthHTTPInstalled);
191  $form->addItem($tai_prop);
192  }
193 
194  // Inline file extensions
195  $tai_prop = new ilTextAreaInputGUI($lng->txt('inline_file_extensions'), 'inline_file_extensions');
196  $tai_prop->setValue($this->object->getInlineFileExtensions());
197  $tai_prop->setInfo($lng->txt('inline_file_extensions_info'));
198  $tai_prop->setCols(80);
199  $tai_prop->setRows(5);
200  $form->addItem($tai_prop);
201 
202 
203  // command buttons
204  $form->addCommandButton('saveSettings', $lng->txt('save'));
205  $form->addCommandButton('view', $lng->txt('cancel'));
206 
207  $tpl->setContent($form->getHTML());
208  }
209 
213  public function saveSettings()
214  {
215  global $rbacsystem, $ilErr;
216 
217  if (! $rbacsystem->checkAccess("write",$this->object->getRefId()))
218  {
219  $ilErr->raiseError($this->lng->txt("no_permission"),$ilErr->WARNING);
220  }
221 
222  $this->object->setWebdavEnabled($_POST['enable_webdav'] == '1');
223  $this->object->setWebdavActionsVisible($_POST['webdav_actions_visible'] == '1');
224  $this->object->setCustomWebfolderInstructionsEnabled($_POST['custom_webfolder_instructions_choice']=='custom');
225  $this->object->setCustomWebfolderInstructions(ilUtil::stripSlashes($_POST['custom_webfolder_instructions']));
226  $this->object->setInlineFileExtensions(ilUtil::stripSlashes($_POST['inline_file_extensions']));
227  $this->object->update();
228 
229  $this->folderSettings->set("enable_download_folder", $_POST["enable_download_folder"] == 1);
230 
231  $this->editSettings();
232  }
233 
238  {
240  $this->tpl->setDescription($this->object->getDescription());
241  }
242 
243 }
244 // END WebDAV
245 ?>