ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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{
21 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
22 {
23 $this->type = 'frma';
24 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
25 $this->lng->loadLanguageModule('forum');
26 }
27
31 public function executeCommand()
32 {
33 $next_class = $this->ctrl->getNextClass($this);
34 $cmd = $this->ctrl->getCmd();
35
36 $this->prepareOutput();
37
38 switch($next_class)
39 {
40 case 'ilpermissiongui':
41 $this->tabs_gui->setTabActive('perm_settings');
42 require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
43 $this->ctrl->forwardCommand(new ilPermissionGUI($this));
44 break;
45
46 default:
47 if(!$cmd || $cmd == 'view')
48 {
49 $cmd = 'editSettings';
50 }
51
52 $this->$cmd();
53 break;
54 }
55 return true;
56 }
57
61 public function getAdminTabs()
62 {
66 global $rbacsystem;
67
68 if($rbacsystem->checkAccess('visible,read', $this->object->getRefId()))
69 {
70 $this->tabs_gui->addTarget('settings',
71 $this->ctrl->getLinkTarget($this, 'editSettings'),
72 array('editSettings', 'view'));
73 }
74
75 if($rbacsystem->checkAccess('edit_permission', $this->object->getRefId()))
76 {
77 $this->tabs_gui->addTarget('perm_settings',
78 $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm'),
79 array(), 'ilpermissiongui');
80 }
81 }
82
86 public function editSettings(ilPropertyFormGUI $form = null)
87 {
88 $this->tabs_gui->setTabActive('settings');
89
90 if(!$form)
91 {
92 $form = $this->getSettingsForm();
93 $this->populateForm($form);
94 }
95
96 $this->tpl->setContent($form->getHtml());
97 }
98
102 public function saveSettings()
103 {
107 global $ilSetting;
108
109 $this->checkPermission("write");
110
111 $form = $this->getSettingsForm();
112 if(!$form->checkInput())
113 {
114 $form->setValuesByPost();
115 $this->editSettings($form);
116 return;
117 }
118
119 $frma_set = new ilSetting('frma');
120 $frma_set->set('forum_overview', $form->getInput('forum_overview'));
121 $ilSetting->set('file_upload_allowed_fora', (int)$form->getInput('file_upload_allowed_fora'));
122 $ilSetting->set('send_attachments_by_mail', (int)$form->getInput('send_attachments_by_mail'));
123 $ilSetting->set('enable_fora_statistics', (int)$form->getInput('fora_statistics'));
124 $ilSetting->set('enable_anonymous_fora', (int)$form->getInput('anonymous_fora'));
125
126 require_once 'Services/Cron/classes/class.ilCronManager.php';
127 if(!ilCronManager::isJobActive('frm_notification'))
128 {
129 $ilSetting->set('forum_notification', (int)$form->getInput('forum_notification'));
130 }
131
132 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
133 ilCaptchaUtil::setActiveForForum((bool)$form->getInput('activate_captcha_anonym'));
134
135 $ilSetting->set('save_post_drafts', (int)$form->getInput('save_post_drafts'));
136 $ilSetting->set('autosave_drafts', (int)$form->getInput('autosave_drafts'));
137 $ilSetting->set('autosave_drafts_ival', (int)$form->getInput('autosave_drafts_ival'));
138
139 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
140 $form->setValuesByPost();
141 $this->editSettings($form);
142 }
143
147 protected function populateForm(ilPropertyFormGUI $form)
148 {
152 global $ilSetting;
153
154 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
155
156 $frma_set = new ilSetting('frma');
157
158 $form->setValuesByArray(array(
159 'forum_overview' => (bool)$frma_set->get('forum_overview', false),
160 'fora_statistics' => (bool)$ilSetting->get('enable_fora_statistics', false),
161 'anonymous_fora' => (bool)$ilSetting->get('enable_anonymous_fora', false),
162 'forum_notification' => (int)$ilSetting->get('forum_notification') === 1 ? true : false,
163 'activate_captcha_anonym' => ilCaptchaUtil::isActiveForForum(),
164 'file_upload_allowed_fora' => (int)$ilSetting->get('file_upload_allowed_fora', ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED),
165 'save_post_drafts' => (int)$ilSetting->get('save_post_drafts', 0),
166 'autosave_drafts' => (int)$ilSetting->get('autosave_drafts', 0),
167 'autosave_drafts_ival' => (int)$ilSetting->get('autosave_drafts_ival', 30),
168 'send_attachments_by_mail' => (bool)$ilSetting->get('send_attachments_by_mail', false)
169 ));
170 }
171
175 protected function getSettingsForm()
176 {
177 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
178 $form = new ilPropertyFormGUI();
179 $form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
180 $form->setTitle($this->lng->txt('settings'));
181
182 $frm_radio = new ilRadioGroupInputGUI($this->lng->txt('frm_displayed_infos'), 'forum_overview');
183 $frm_radio->addOption(new ilRadioOption($this->lng->txt('new') . ', ' . $this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '0'));
184 $frm_radio->addOption(new ilRadioOption($this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '1'));
185 $frm_radio->setInfo($this->lng->txt('frm_disp_info_desc'));
186 $form->addItem($frm_radio);
187
188 $check = new ilCheckboxInputGui($this->lng->txt('enable_fora_statistics'), 'fora_statistics');
189 $check->setInfo($this->lng->txt('enable_fora_statistics_desc'));
190 $form->addItem($check);
191
192 $check = new ilCheckboxInputGui($this->lng->txt('enable_anonymous_fora'), 'anonymous_fora');
193 $check->setInfo($this->lng->txt('enable_anonymous_fora_desc'));
194 $form->addItem($check);
195
196 $file_upload = new ilRadioGroupInputGUI($this->lng->txt('file_upload_allowed_fora'), 'file_upload_allowed_fora');
197 $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_allow'), ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED));
198 $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_disallow'), ilForumProperties::FILE_UPLOAD_INDIVIDUAL));
199 $file_upload->setInfo($this->lng->txt('file_upload_allowed_fora_desc'));
200 $form->addItem($file_upload);
201
202 require_once 'Services/Cron/classes/class.ilCronManager.php';
203 if(ilCronManager::isJobActive('frm_notification'))
204 {
205 require_once 'Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php';
208 $form,
209 $this
210 );
211 }
212 else
213 {
214 $notifications = new ilCheckboxInputGui($this->lng->txt('cron_forum_notification'), 'forum_notification');
215 $notifications->setInfo($this->lng->txt('cron_forum_notification_desc'));
216 $notifications->setValue(1);
217 $form->addItem($notifications);
218 }
219
220 $check = new ilCheckboxInputGui($this->lng->txt('enable_send_attachments'), 'send_attachments_by_mail');
221 $check->setInfo($this->lng->txt('enable_send_attachments_desc'));
222 $check->setValue(1);
223 $form->addItem($check);
224
225 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
226 $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
227 $cap->setInfo($this->lng->txt('adm_captcha_anonymous_frm'));
228 $cap->setValue(1);
230 {
231 $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
232 }
233 $form->addItem($cap);
234
235 $drafts = new ilCheckboxInputGUI($this->lng->txt('adm_save_drafts'), 'save_post_drafts');
236 $drafts->setInfo($this->lng->txt('adm_save_drafts_desc'));
237 $drafts->setValue(1);
238
239 $autosave_drafts = new ilCheckboxInputGUI($this->lng->txt('adm_autosave_drafts'), 'autosave_drafts');
240 $autosave_drafts->setInfo($this->lng->txt('adm_autosave_drafts_desc'));
241 $autosave_drafts->setValue(1);
242
243 $autosave_interval = new ilNumberInputGUI($this->lng->txt('adm_autosave_ival'), 'autosave_drafts_ival');
244 $autosave_interval->allowDecimals(false);
245 $autosave_interval->setMinValue(30);
246 $autosave_interval->setMaxValue(60 * 60);
247 $autosave_interval->setSize(10);
248 $autosave_interval->setSuffix($this->lng->txt('seconds'));
249 $autosave_drafts->addSubItem($autosave_interval);
250 $drafts->addSubItem($autosave_drafts);
251 $form->addItem($drafts);
252
253 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
254 $form->addCommandButton('editSettings', $this->lng->txt('cancel'));
255
256 return $form;
257 }
258
263 public function addToExternalSettingsForm($a_form_id)
264 {
268 global $ilSetting;
269
270 switch($a_form_id)
271 {
273
274 $fields = array(
275 'enable_fora_statistics' => array($ilSetting->get('enable_fora_statistics', false), ilAdministrationSettingsFormHandler::VALUE_BOOL),
276 'enable_anonymous_fora' => array($ilSetting->get('enable_anonymous_fora', false), ilAdministrationSettingsFormHandler::VALUE_BOOL)
277 );
278
279 return array(array("editSettings", $fields));
280
282 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
283 $fields = array(
284 'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForForum(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
285 );
286
287 return array('obj_frma' => array('editSettings', $fields));
288 }
289 }
290}
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.
setFormAction($a_formaction)
Set FormAction.
This class represents a number property in a property form.
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
getAdminTabs()
administration tabs show only permissions and trash folder
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
setTitle($a_title)
Set Title.
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.
global $ilSetting
Definition: privfeed.php:17
$cmd
Definition: sahs_server.php:35