ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjFileAccessSettingsGUI.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
24
37{
38 const CMD_EDIT_SETTINGS = 'editSettings';
39 const CMD_SHOW_PREVIEW_RENDERERS = 'showPreviewRenderers';
40
44 protected $folderSettings;
45
46
52 public function __construct($a_data, $a_id, $a_call_by_reference)
53 {
54 $this->type = "facs";
55 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
56 $this->folderSettings = new ilSetting('fold');
57 }
58
59
66 public function executeCommand()
67 {
68 global $DIC;
69 $ilAccess = $DIC['ilAccess'];
70 $ilias = $DIC['ilias'];
71 $lng = $DIC['lng'];
72
73 $lng->loadLanguageModule("file");
74
75 $next_class = $this->ctrl->getNextClass($this);
76 $cmd = $this->ctrl->getCmd();
77
78 $this->prepareOutput();
79
80 if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
81 $ilias->raiseError($lng->txt('no_permission'), $ilias->error_obj->MESSAGE);
82 }
83
84 switch ($next_class) {
85 case 'ilpermissiongui':
86 $this->tabs_gui->setTabActive('perm_settings');
87 $perm_gui = new ilPermissionGUI($this);
88 $ret = &$this->ctrl->forwardCommand($perm_gui);
89 break;
90 default:
91 if (!$cmd || $cmd == 'view') {
93 }
94
95 $this->$cmd();
96 break;
97 }
98
99 return true;
100 }
101
102
109 public function getAdminTabs()
110 {
111 global $DIC;
112 $rbacsystem = $DIC['rbacsystem'];
113
114 $GLOBALS['DIC']['lng']->loadLanguageModule('fm');
115
116 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
117 $this->tabs_gui->addTarget(
118 'file_objects',
119 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
120 array(self::CMD_EDIT_SETTINGS, "view")
121 );
122 }
123 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
124 $this->tabs_gui->addTarget("perm_settings", $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"), array(), 'ilpermissiongui');
125 }
126 }
127
128
129 protected function addFileObjectsSubTabs()
130 {
131 $this->tabs_gui->addSubTabTarget(
132 "settings",
133 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_SETTINGS),
134 array(self::CMD_EDIT_SETTINGS, "view")
135 );
136 $this->tabs_gui->addSubTabTarget(
137 "preview_renderers",
138 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_PREVIEW_RENDERERS),
139 array(self::CMD_SHOW_PREVIEW_RENDERERS, "view")
140 );
141 }
142
143
147 protected function initSettingsForm()
148 {
149 global $DIC;
150 $ilCtrl = $DIC['ilCtrl'];
151 $lng = $DIC['lng'];
152
153 require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
154 require_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
155 require_once("./Services/Form/classes/class.ilRadioGroupInputGUI.php");
156 require_once("./Services/Form/classes/class.ilRadioOption.php");
157 require_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
158
159 $form = new ilPropertyFormGUI();
160 $form->setFormAction($ilCtrl->getFormAction($this));
161 $form->setTitle($lng->txt("settings"));
162
163 // Backwards compatibility with ILIAS 3.9: Use the name of the
164 // uploaded file as the filename for the downloaded file instead
165 // of the title of the file object.
166 $dl_prop = new ilCheckboxInputGUI($lng->txt("download_with_uploaded_filename"), "download_with_uploaded_filename");
167 $dl_prop->setValue('1');
168 // default value should reflect previous behaviour (-> 0)
169 $dl_prop->setChecked($this->object->isDownloadWithUploadedFilename() == 1);
170 $dl_prop->setInfo($lng->txt('download_with_uploaded_filename_info'));
171 $form->addItem($dl_prop);
172
173 // download limit
174 $lng->loadLanguageModule("bgtask");
175 $dl_prop = new ilNumberInputGUI($lng->txt("bgtask_setting_limit"), "bg_limit");
176 $dl_prop->setInfo($lng->txt("bgtask_setting_limit_info"));
177 $dl_prop->setRequired(true);
178 $dl_prop->setSize(10);
179 $dl_prop->setMinValue(1);
180 $dl_prop->setSuffix($lng->txt("lang_size_mb"));
181 $dl_prop->setValue($this->folderSettings->get("bgtask_download_limit", null));
182 $form->addItem($dl_prop);
183
184 // Inline file extensions
185 $tai_prop = new ilTextAreaInputGUI($lng->txt('inline_file_extensions'), 'inline_file_extensions');
186 $tai_prop->setValue($this->object->getInlineFileExtensions());
187 $tai_prop->setInfo($lng->txt('inline_file_extensions_info'));
188 $tai_prop->setCols(80);
189 $tai_prop->setRows(5);
190 $form->addItem($tai_prop);
191
192 require_once("Services/Preview/classes/class.ilPreviewSettings.php");
193
194 // enable preview
195 $chk_prop = new ilCheckboxInputGUI($lng->txt("enable_preview"), "enable_preview");
196 $chk_prop->setValue('1');
197 $chk_prop->setChecked(ilPreviewSettings::isPreviewEnabled());
198 $chk_prop->setInfo($lng->txt('enable_preview_info'));
199 $form->addItem($chk_prop);
200
201 // max preview images
202 $num_prop = new ilNumberInputGUI($lng->txt("max_previews_per_object"), "max_previews_per_object");
203 $num_prop->setDecimals(0);
204 $num_prop->setMinValue(1);
205 $num_prop->setMinvalueShouldBeGreater(false);
206 $num_prop->setMaxValue(ilPreviewSettings::MAX_PREVIEWS_MAX);
207 $num_prop->setMaxvalueShouldBeLess(false);
208 $num_prop->setMaxLength(5);
209 $num_prop->setSize(10);
210 $num_prop->setValue(ilPreviewSettings::getMaximumPreviews());
211 $num_prop->setInfo($lng->txt('max_previews_per_object_info'));
212 $form->addItem($num_prop);
213
214 // command buttons
215 $form->addCommandButton('saveSettings', $lng->txt('save'));
216 $form->addCommandButton('view', $lng->txt('cancel'));
217
218 return $form;
219 }
220
221
225 public function editSettings(ilPropertyFormGUI $a_form = null)
226 {
227 global $DIC, $ilErr;
228
229 $this->tabs_gui->setTabActive('file_objects');
230 $this->addFileObjectsSubTabs();
231 $this->tabs_gui->setSubTabActive('settings');
232
233 if (!$DIC->rbac()->system()->checkAccess("visible,read", $this->object->getRefId())) {
234 $ilErr->raiseError($DIC->language()->txt("no_permission"), $ilErr->WARNING);
235 }
236
237 if (!$a_form) {
238 $a_form = $this->initSettingsForm();
239 }
240
241 $DIC->ui()->mainTemplate()->setContent($a_form->getHTML());
242 }
243
244
248 public function saveSettings()
249 {
250 global $DIC;
251 $rbacsystem = $DIC['rbacsystem'];
252
253 if (!$rbacsystem->checkAccess("write", $this->object->getRefId())) {
254 ilUtil::sendFailure($DIC->language()->txt("no_permission"), true);
255 $DIC->ctrl()->redirect($this, self::CMD_EDIT_SETTINGS);
256 }
257
258 $form = $this->initSettingsForm();
259 if ($form->checkInput()) {
260 $this->object->setDownloadWithUploadedFilename(ilUtil::stripSlashes($_POST['download_with_uploaded_filename']));
261 $this->object->setInlineFileExtensions(ilUtil::stripSlashes($_POST['inline_file_extensions']));
262 $this->object->update();
263 $this->folderSettings->set("bgtask_download_limit", (int) $_POST["bg_limit"]);
264
265 require_once("Services/Preview/classes/class.ilPreviewSettings.php");
266 ilPreviewSettings::setPreviewEnabled($_POST["enable_preview"] == 1);
267 ilPreviewSettings::setMaximumPreviews($_POST["max_previews_per_object"]);
268
269 ilUtil::sendSuccess($DIC->language()->txt('settings_saved'), true);
270 $DIC->ctrl()->redirect($this, self::CMD_EDIT_SETTINGS);
271 }
272
273 $form->setValuesByPost();
274 $this->editSettings($form);
275 }
276
277
278 protected function showPreviewRenderers() {
279 global $DIC;
280 $rbacsystem = $DIC['rbacsystem'];
281 $ilErr = $DIC['ilErr'];
282 $tpl = $DIC['tpl'];
283 $lng = $DIC['lng'];
284
285 $this->tabs_gui->setTabActive('file_objects');
286 $this->addFileObjectsSubTabs();
287 $this->tabs_gui->setSubTabActive('preview_renderers');
288
289 if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
290 $ilErr->raiseError($lng->txt("no_permission"), $ilErr->WARNING);
291 }
292
293 // set warning if ghostscript not installed
295 ilUtil::sendInfo($lng->txt("ghostscript_not_configured"));
296 }
297
298 // build renderer HTML
299 require_once("Services/Preview/classes/class.ilRendererFactory.php");
300 require_once("Services/Preview/classes/class.ilRendererTableGUI.php");
301
302 $renderers = ilRendererFactory::getRenderers();
303
304 $table = new ilRendererTableGUI($this, array(self::CMD_SHOW_PREVIEW_RENDERERS, "view"));
305 $table->setMaxCount(sizeof($renderers));
306 $table->setData($renderers);
307
308 // set content
309 $tpl->setContent($table->getHTML());
310 }
311
312
316 public function setTitleAndDescription()
317 {
318 parent::setTitleAndDescription();
319 $this->tpl->setDescription($this->object->getDescription());
320 }
321}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
static isGhostscriptInstalled()
Determines whether Ghostscript is installed.
This class represents a number property in a property form.
Class ilObjFileAccessSettingsGUI.
setTitleAndDescription()
called by prepare output
editSettings(ilPropertyFormGUI $a_form=null)
Edit settings.
__construct($a_data, $a_id, $a_call_by_reference)
Constructor.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static isPreviewEnabled()
Gets whether the preview functionality is enabled.
static setMaximumPreviews($a_value)
Sets the maximum number of preview pictures per object.
static getMaximumPreviews()
Gets the maximum number of preview pictures per object.
static setPreviewEnabled($a_value)
Sets whether the preview functionality is enabled.
This class represents a property form user interface.
static getRenderers()
Gets an array containing all available preview renderers.
Displays an overview of all loaded preview renderers.
ILIAS Setting Class.
This class represents a text area property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6