ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjFileAccessSettings.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 
39 include_once "./Services/Object/classes/class.ilObject.php";
40 
42 {
43 
47  private $webdavEnabled;
76 
77 
84  public function __construct($a_id = 0, $a_call_by_reference = true)
85  {
86  $this->type = "facs";
87  parent::__construct($a_id, $a_call_by_reference);
88  }
89 
90 
98  public function setWebdavEnabled($newValue)
99  {
100  $this->webdavEnabled = $newValue;
101  }
102 
103 
109  public function isWebdavEnabled()
110  {
111  return $this->webdavEnabled;
112  }
113 
114 
122  public function setWebdavActionsVisible($newValue)
123  {
124  $this->webdavActionsVisible = $newValue;
125  }
126 
127 
133  public function isWebdavActionsVisible()
134  {
136  }
137 
138 
150  public function setCustomWebfolderInstructions($newValue)
151  {
152  $this->customWebfolderInstructions = $newValue;
153  }
154 
155 
162  {
163  if (strlen($this->customWebfolderInstructions) == 0) {
164  $this->customWebfolderInstructions = self::_getDefaultWebfolderInstructions();
165  }
166 
168  }
169 
170 
178  {
179  return self::_getDefaultWebfolderInstructions();
180  }
181 
182 
189  {
191  }
192 
193 
201  public function setCustomWebfolderInstructionsEnabled($newValue)
202  {
203  $this->customWebfolderInstructionsEnabled = $newValue;
204  }
205 
206 
214  public function setInlineFileExtensions($newValue)
215  {
216  $this->inlineFileExtensions = $newValue;
217  }
218 
219 
225  public function getInlineFileExtensions()
226  {
228  }
229 
230 
238  public function setDownloadWithUploadedFilename($newValue)
239  {
240  $this->downloadWithUploadedFilename = $newValue;
241  }
242 
243 
250  {
252  }
253 
254 
262  public function create()
263  {
264  parent::create();
265  $this->write();
266  }
267 
268 
274  public function update()
275  {
276  parent::update();
277  $this->write();
278  }
279 
280 
286  private function write()
287  {
288  global $DIC;
289  $ilClientIniFile = $DIC['ilClientIniFile'];
290 
291  // Clear any old error messages
292  $ilClientIniFile->error(null);
293 
294  if (!$ilClientIniFile->groupExists('file_access')) {
295  $ilClientIniFile->addGroup('file_access');
296  }
297  $ilClientIniFile->setVariable('file_access', 'webdav_enabled', $this->webdavEnabled ? '1' : '0');
298  $ilClientIniFile->setVariable('file_access', 'webdav_actions_visible', $this->webdavActionsVisible ? '1' : '0');
299  $ilClientIniFile->setVariable('file_access', 'download_with_uploaded_filename', $this->downloadWithUploadedFilename ? '1' : '0');
300  $ilClientIniFile->write();
301 
302  if ($ilClientIniFile->getError()) {
303  global $DIC;
304  $ilErr = $DIC['ilErr'];
305  $ilErr->raiseError($ilClientIniFile->getError(), $ilErr->WARNING);
306  }
307 
308  require_once 'Services/Administration/classes/class.ilSetting.php';
309  $settings = new ilSetting('file_access');
310  $settings->set('inline_file_extensions', $this->inlineFileExtensions);
311  $settings->set('custom_webfolder_instructions_enabled', $this->customWebfolderInstructionsEnabled ? '1' : '0');
312  $settings->set('custom_webfolder_instructions', $this->customWebfolderInstructions);
313  }
314 
315 
319  public function read()
320  {
321  parent::read();
322 
323  global $DIC;
324  $ilClientIniFile = $DIC['ilClientIniFile'];
325  $this->webdavEnabled = $ilClientIniFile->readVariable('file_access', 'webdav_enabled') == '1';
326  $this->webdavActionsVisible = $ilClientIniFile->readVariable('file_access', 'webdav_actions_visible') == '1';
327  $this->downloadWithUploadedFilename = $ilClientIniFile->readVariable('file_access', 'download_with_uploaded_filename') == '1';
328  $ilClientIniFile->ERROR = false;
329 
330  require_once 'Services/Administration/classes/class.ilSetting.php';
331  $settings = new ilSetting('file_access');
332  $this->inlineFileExtensions = $settings->get('inline_file_extensions', '');
333  $this->customWebfolderInstructionsEnabled = $settings->get('custom_webfolder_instructions_enabled', '0') == '1';
334  //$this->webdavSpecialCharsHandling = $settings->get('');
335  $this->customWebfolderInstructions = $settings->get('custom_webfolder_instructions', '');
336  }
337 
338 
350  public static function _getDefaultWebfolderInstructions()
351  {
352  global $lng;
353 
354  return $lng->txt('webfolder_instructions_text');
355  }
356 
357 
365  private function getUploadMaxFilesize()
366  {
367  $val = ini_get('upload_max_filesize');
368 
369  $val = trim($val);
370  $last = strtolower($val[strlen($val) - 1]);
371  switch ($last) {
372  // The 'G' modifier is available since PHP 5.1.0
373  case 'g':
374  $val *= 1024;
375  // no break
376  case 'm':
377  $val *= 1024;
378  // no break
379  case 'k':
380  $val *= 1024;
381  }
382 
383  return $val;
384  }
385 }
setDownloadWithUploadedFilename($newValue)
Sets the downloadWithUploadedFilename property.
setInlineFileExtensions($newValue)
Sets the inlineFileExtensions property.
setCustomWebfolderInstructions($newValue)
Sets the customWebfolderInstructions property.
global $DIC
Definition: saml.php:7
$customWebfolderInstructionsEnabled
Boolean property.
setCustomWebfolderInstructionsEnabled($newValue)
Sets the customWebfolderInstructionsEnabled property.
getDefaultWebfolderInstructions()
Gets the defaultWebfolderInstructions property.
getUploadMaxFilesize()
TODO: Check if needed and refactor.
static _getDefaultWebfolderInstructions()
TODO: Check if needed and refactor.
isWebdavEnabled()
Gets the webdavEnabled property.
$ilErr
Definition: raiseError.php:18
setWebdavEnabled($newValue)
Sets the webdavEnabled property.
setWebdavActionsVisible($newValue)
Sets the webdavActionsVisible property.
isCustomWebfolderInstructionsEnabled()
Gets the customWebfolderInstructionsEnabled property.
getInlineFileExtensions()
Gets the inlineFileExtensions property.
getCustomWebfolderInstructions()
Gets the customWebfolderInstructions property.
isWebdavActionsVisible()
Gets the webdavActionsVisible property.
update($pash, $contents, Config $config)
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
write()
write object data into db
isDownloadWithUploadedFilename()
Gets the downloadWithUploadedFilename property.
read()
read object data from db into object