ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjForumAdministrationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Object/classes/class.ilObjectGUI.php';
5require_once 'Modules/Forum/classes/class.ilForumProperties.php';
6
16{
17 private $rbac;
18
23 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
24 {
25 global $DIC;
26 $this->rbac = $DIC->rbac();
27
28 $this->type = 'frma';
29 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
30 $this->lng->loadLanguageModule('forum');
31 }
32
36 public function executeCommand()
37 {
38 $next_class = $this->ctrl->getNextClass($this);
39 $cmd = $this->ctrl->getCmd();
40
41 $this->prepareOutput();
42
43 switch ($next_class) {
44 case 'ilpermissiongui':
45 $this->tabs_gui->setTabActive('perm_settings');
46 require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
47 $this->ctrl->forwardCommand(new ilPermissionGUI($this));
48 break;
49
50 default:
51 if (!$cmd || $cmd == 'view') {
52 $cmd = 'editSettings';
53 }
54
55 $this->$cmd();
56 break;
57 }
58 return true;
59 }
60
64 public function getAdminTabs()
65 {
66 if ($this->rbac->system()->checkAccess('visible,read', $this->object->getRefId())) {
67 $this->tabs_gui->addTarget(
68 'settings',
69 $this->ctrl->getLinkTarget($this, 'editSettings'),
70 array('editSettings', 'view')
71 );
72 }
73
74 if ($this->rbac->system()->checkAccess('edit_permission', $this->object->getRefId())) {
75 $this->tabs_gui->addTarget(
76 'perm_settings',
77 $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm'),
78 array(),
79 'ilpermissiongui'
80 );
81 }
82 }
83
87 public function editSettings(ilPropertyFormGUI $form = null)
88 {
89 $this->tabs_gui->activateTab('settings');
90
91 if (!$form) {
92 $form = $this->getSettingsForm();
93 $this->populateForm($form);
94 }
95
96 $this->tpl->setContent($form->getHtml());
97 }
98
102 public function saveSettings()
103 {
104 $this->checkPermission("write");
105
106 $form = $this->getSettingsForm();
107 if (!$form->checkInput()) {
108 $form->setValuesByPost();
109 $this->editSettings($form);
110 return;
111 }
112
113 $frma_set = new ilSetting('frma');
114 $frma_set->set('forum_overview', $form->getInput('forum_overview'));
115 $this->settings->set('file_upload_allowed_fora', (int) $form->getInput('file_upload_allowed_fora'));
116 $this->settings->set('send_attachments_by_mail', (int) $form->getInput('send_attachments_by_mail'));
117 $this->settings->set('enable_fora_statistics', (int) $form->getInput('fora_statistics'));
118 $this->settings->set('enable_anonymous_fora', (int) $form->getInput('anonymous_fora'));
119
120 require_once 'Services/Cron/classes/class.ilCronManager.php';
121 if (!ilCronManager::isJobActive('frm_notification')) {
122 $this->settings->set('forum_notification', (int) $form->getInput('forum_notification'));
123 }
124
125 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
126 ilCaptchaUtil::setActiveForForum((bool) $form->getInput('activate_captcha_anonym'));
127
128 $this->settings->set('save_post_drafts', (int) $form->getInput('save_post_drafts'));
129 $this->settings->set('autosave_drafts', (int) $form->getInput('autosave_drafts'));
130 $this->settings->set('autosave_drafts_ival', (int) $form->getInput('autosave_drafts_ival'));
131
132 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
133 $form->setValuesByPost();
134 $this->editSettings($form);
135 }
136
141 {
142 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
143
144 $frma_set = new ilSetting('frma');
145
146 $form->setValuesByArray(array(
147 'forum_overview' => (bool) $frma_set->get('forum_overview', false),
148 'fora_statistics' => (bool) $this->settings->get('enable_fora_statistics', false),
149 'anonymous_fora' => (bool) $this->settings->get('enable_anonymous_fora', false),
150 'forum_notification' => (int) $this->settings->get('forum_notification') === 1 ? true : false,
151 'activate_captcha_anonym' => ilCaptchaUtil::isActiveForForum(),
152 'file_upload_allowed_fora' => (int) $this->settings->get('file_upload_allowed_fora', ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED),
153 'save_post_drafts' => (int) $this->settings->get('save_post_drafts', 0),
154 'autosave_drafts' => (int) $this->settings->get('autosave_drafts', 0),
155 'autosave_drafts_ival' => (int) $this->settings->get('autosave_drafts_ival', 30),
156 'send_attachments_by_mail' => (bool) $this->settings->get('send_attachments_by_mail', false)
157 ));
158 }
159
163 protected function getSettingsForm()
164 {
165 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
166 $form = new ilPropertyFormGUI();
167 $form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
168 $form->setTitle($this->lng->txt('settings'));
169
170 $frm_radio = new ilRadioGroupInputGUI($this->lng->txt('frm_displayed_infos'), 'forum_overview');
171 $frm_radio->addOption(new ilRadioOption($this->lng->txt('new') . ', ' . $this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '0'));
172 $frm_radio->addOption(new ilRadioOption($this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '1'));
173 $frm_radio->setInfo($this->lng->txt('frm_disp_info_desc'));
174 $form->addItem($frm_radio);
175
176 $check = new ilCheckboxInputGui($this->lng->txt('enable_fora_statistics'), 'fora_statistics');
177 $check->setInfo($this->lng->txt('enable_fora_statistics_desc'));
178 $form->addItem($check);
179
180 $check = new ilCheckboxInputGui($this->lng->txt('enable_anonymous_fora'), 'anonymous_fora');
181 $check->setInfo($this->lng->txt('enable_anonymous_fora_desc'));
182 $form->addItem($check);
183
184 $file_upload = new ilRadioGroupInputGUI($this->lng->txt('file_upload_allowed_fora'), 'file_upload_allowed_fora');
185 $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_allow'), ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED));
186 $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_disallow'), ilForumProperties::FILE_UPLOAD_INDIVIDUAL));
187 $file_upload->setInfo($this->lng->txt('file_upload_allowed_fora_desc'));
188 $form->addItem($file_upload);
189
190 require_once 'Services/Cron/classes/class.ilCronManager.php';
191 if (ilCronManager::isJobActive('frm_notification')) {
192 require_once 'Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php';
195 $form,
196 $this
197 );
198 } else {
199 $notifications = new ilCheckboxInputGui($this->lng->txt('cron_forum_notification'), 'forum_notification');
200 $notifications->setInfo($this->lng->txt('cron_forum_notification_desc'));
201 $notifications->setValue(1);
202 $form->addItem($notifications);
203 }
204
205 $check = new ilCheckboxInputGui($this->lng->txt('enable_send_attachments'), 'send_attachments_by_mail');
206 $check->setInfo($this->lng->txt('enable_send_attachments_desc'));
207 $check->setValue(1);
208 $form->addItem($check);
209
210 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
211 $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
212 $cap->setInfo($this->lng->txt('adm_captcha_anonymous_frm'));
213 $cap->setValue(1);
215 $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
216 }
217 $form->addItem($cap);
218
219 $drafts = new ilCheckboxInputGUI($this->lng->txt('adm_save_drafts'), 'save_post_drafts');
220 $drafts->setInfo($this->lng->txt('adm_save_drafts_desc'));
221 $drafts->setValue(1);
222
223 $autosave_drafts = new ilCheckboxInputGUI($this->lng->txt('adm_autosave_drafts'), 'autosave_drafts');
224 $autosave_drafts->setInfo($this->lng->txt('adm_autosave_drafts_desc'));
225 $autosave_drafts->setValue(1);
226
227 $autosave_interval = new ilNumberInputGUI($this->lng->txt('adm_autosave_ival'), 'autosave_drafts_ival');
228 $autosave_interval->allowDecimals(false);
229 $autosave_interval->setMinValue(30);
230 $autosave_interval->setMaxValue(60 * 60);
231 $autosave_interval->setSize(10);
232 $autosave_interval->setSuffix($this->lng->txt('seconds'));
233 $autosave_drafts->addSubItem($autosave_interval);
234 $drafts->addSubItem($autosave_drafts);
235 $form->addItem($drafts);
236
237 if ($this->checkPermissionBool("write")) {
238 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
239 }
240
241 return $form;
242 }
243
248 public function addToExternalSettingsForm($a_form_id)
249 {
250 switch ($a_form_id) {
252
253 $fields = array(
254 'enable_fora_statistics' => array($this->settings->get('enable_fora_statistics', false), ilAdministrationSettingsFormHandler::VALUE_BOOL),
255 'enable_anonymous_fora' => array($this->settings->get('enable_anonymous_fora', false), ilAdministrationSettingsFormHandler::VALUE_BOOL)
256 );
257
258 return array(array("editSettings", $fields));
259
261 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
262 $fields = array(
263 'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForForum(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
264 );
265
266 return array('obj_frma' => array('editSettings', $fields));
267 }
268 }
269}
An exception for terminatinating execution or to throw for unit testing.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
static checkFreetype()
Check whether captcha support is active.
This class represents a checkbox property in a property form.
static isJobActive($a_job_id)
Check if given job is currently active.
This class represents a number property in a property form.
getAdminTabs()
administration tabs show only permissions and trash folder
editSettings(ilPropertyFormGUI $form=null)
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor @access public.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2