ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjFileAccessSettings.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 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
37include_once "./Services/Object/classes/class.ilObject.php";
38
40{
41
57
58
65 public function __construct($a_id = 0, $a_call_by_reference = true)
66 {
67 $this->type = "facs";
68 parent::__construct($a_id, $a_call_by_reference);
69 }
70
71
79 public function setInlineFileExtensions($newValue)
80 {
81 $this->inlineFileExtensions = $newValue;
82 }
83
84
90 public function getInlineFileExtensions()
91 {
93 }
94
95
103 public function setDownloadWithUploadedFilename($newValue)
104 {
105 $this->downloadWithUploadedFilename = $newValue;
106 }
107
108
115 {
117 }
118
119
127 public function create()
128 {
129 parent::create();
130 $this->write();
131 }
132
133
139 public function update()
140 {
141 parent::update();
142 $this->write();
143 }
144
145
151 private function write()
152 {
153 global $DIC;
154 $ilClientIniFile = $DIC['ilClientIniFile'];
155 $settings = new ilSetting('file_access');
156
157 // Clear any old error messages
158 $ilClientIniFile->error(null);
159
160 if (!$ilClientIniFile->groupExists('file_access')) {
161 $ilClientIniFile->addGroup('file_access');
162 }
163 $ilClientIniFile->setVariable('file_access', 'download_with_uploaded_filename', $this->downloadWithUploadedFilename ? '1' : '0');
164 $ilClientIniFile->write();
165
166 if ($ilClientIniFile->getError()) {
167 global $DIC;
168 $ilErr = $DIC['ilErr'];
169 $ilErr->raiseError($ilClientIniFile->getError(), $ilErr->WARNING);
170 }
171
172 require_once 'Services/Administration/classes/class.ilSetting.php';
173 $settings->set('inline_file_extensions', $this->inlineFileExtensions);
174 }
175
176
180 public function read()
181 {
182 parent::read();
183
184 global $DIC;
185 $settings = new ilSetting('file_access');
186 $ilClientIniFile = $DIC['ilClientIniFile'];
187 $this->downloadWithUploadedFilename = $ilClientIniFile->readVariable('file_access', 'download_with_uploaded_filename') == '1';
188 $ilClientIniFile->ERROR = false;
189
190 require_once 'Services/Administration/classes/class.ilSetting.php';
191 $this->inlineFileExtensions = $settings->get('inline_file_extensions', '');
192 }
193
194
202 private function getUploadMaxFilesize()
203 {
204 $val = ini_get('upload_max_filesize');
205
206 $val = trim($val);
207 $last = strtolower($val[strlen($val) - 1]);
208 switch ($last) {
209 // The 'G' modifier is available since PHP 5.1.0
210 case 'g':
211 $val *= 1024;
212 // no break
213 case 'm':
214 $val *= 1024;
215 // no break
216 case 'k':
217 $val *= 1024;
218 }
219
220 return $val;
221 }
222} // END class.ilObjFileAccessSettings
An exception for terminatinating execution or to throw for unit testing.
Class ilObjFileAccessSettings*.
getUploadMaxFilesize()
TODO: Check if needed and refactor.
getInlineFileExtensions()
Gets the inlineFileExtensions property.
write()
write object data into db
isDownloadWithUploadedFilename()
Gets the downloadWithUploadedFilename property.
setInlineFileExtensions($newValue)
Sets the inlineFileExtensions property.
read()
read object data from db into object
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
setDownloadWithUploadedFilename($newValue)
Sets the downloadWithUploadedFilename property.
Class ilObject Basic functions for all objects.
ILIAS Setting Class.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:18