ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4
14{
16 private $rbac;
18 private $error;
19
24 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
25 {
26 global $DIC;
27
28 $this->rbac = $DIC->rbac();
29 $this->error = $DIC['ilErr'];
30
31 $this->type = 'frma';
32 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
33 $this->lng->loadLanguageModule('forum');
34 }
35
39 public function executeCommand()
40 {
41 if (!$this->rbac->system()->checkAccess('visible,read', $this->object->getRefId())) {
42 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
43 }
44
45 $next_class = $this->ctrl->getNextClass($this);
46 $cmd = $this->ctrl->getCmd();
47
48 $this->prepareOutput();
49
50 switch ($next_class) {
51 case 'ilpermissiongui':
52 $this->tabs_gui->setTabActive('perm_settings');
53 $this->ctrl->forwardCommand(new ilPermissionGUI($this));
54 break;
55
56 default:
57 if (!$cmd || $cmd == 'view') {
58 $cmd = 'editSettings';
59 }
60
61 $this->$cmd();
62 break;
63 }
64 return true;
65 }
66
70 public function getAdminTabs()
71 {
72 if ($this->rbac->system()->checkAccess('visible,read', $this->object->getRefId())) {
73 $this->tabs_gui->addTarget(
74 'settings',
75 $this->ctrl->getLinkTarget($this, 'editSettings'),
76 array('editSettings', 'view')
77 );
78 }
79
80 if ($this->rbac->system()->checkAccess('edit_permission', $this->object->getRefId())) {
81 $this->tabs_gui->addTarget(
82 'perm_settings',
83 $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm'),
84 array(),
85 'ilpermissiongui'
86 );
87 }
88 }
89
93 public function editSettings(ilPropertyFormGUI $form = null)
94 {
95 $this->tabs_gui->activateTab('settings');
96
97 if (!$form) {
98 $form = $this->getSettingsForm();
99 $this->populateForm($form);
100 }
101
102 $this->tpl->setContent($form->getHtml());
103 }
104
108 public function saveSettings()
109 {
110 $this->checkPermission("write");
111
112 $form = $this->getSettingsForm();
113 if (!$form->checkInput()) {
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 $this->settings->set('file_upload_allowed_fora', (int) $form->getInput('file_upload_allowed_fora'));
122 $this->settings->set('send_attachments_by_mail', (int) $form->getInput('send_attachments_by_mail'));
123 $this->settings->set('enable_fora_statistics', (int) $form->getInput('fora_statistics'));
124 $this->settings->set('enable_anonymous_fora', (int) $form->getInput('anonymous_fora'));
125
126 if (!ilCronManager::isJobActive('frm_notification')) {
127 $this->settings->set('forum_notification', (int) $form->getInput('forum_notification'));
128 }
129
130 ilCaptchaUtil::setActiveForForum((bool) $form->getInput('activate_captcha_anonym'));
131
132 $this->settings->set('save_post_drafts', (int) $form->getInput('save_post_drafts'));
133 $this->settings->set('autosave_drafts', (int) $form->getInput('autosave_drafts'));
134 $this->settings->set('autosave_drafts_ival', (int) $form->getInput('autosave_drafts_ival'));
135
136 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
137 $form->setValuesByPost();
138 $this->editSettings($form);
139 }
140
144 protected function populateForm(ilPropertyFormGUI $form)
145 {
146 $frma_set = new ilSetting('frma');
147
148 $form->setValuesByArray(array(
149 'forum_overview' => (bool) $frma_set->get('forum_overview', false),
150 'fora_statistics' => (bool) $this->settings->get('enable_fora_statistics', false),
151 'anonymous_fora' => (bool) $this->settings->get('enable_anonymous_fora', false),
152 'forum_notification' => (int) $this->settings->get('forum_notification') === 1 ? true : false,
153 'activate_captcha_anonym' => ilCaptchaUtil::isActiveForForum(),
154 'file_upload_allowed_fora' => (int) $this->settings->get('file_upload_allowed_fora', ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED),
155 'save_post_drafts' => (int) $this->settings->get('save_post_drafts', 0),
156 'autosave_drafts' => (int) $this->settings->get('autosave_drafts', 0),
157 'autosave_drafts_ival' => (int) $this->settings->get('autosave_drafts_ival', 30),
158 'send_attachments_by_mail' => (bool) $this->settings->get('send_attachments_by_mail', false)
159 ));
160 }
161
165 protected function getSettingsForm()
166 {
167 $form = new ilPropertyFormGUI();
168 $form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
169 $form->setTitle($this->lng->txt('settings'));
170
171 $frm_radio = new ilRadioGroupInputGUI($this->lng->txt('frm_displayed_infos'), 'forum_overview');
172 $frm_radio->addOption(new ilRadioOption($this->lng->txt('new') . ', ' . $this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '0'));
173 $frm_radio->addOption(new ilRadioOption($this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '1'));
174 $frm_radio->setInfo($this->lng->txt('frm_disp_info_desc'));
175 $form->addItem($frm_radio);
176
177 $check = new ilCheckboxInputGui($this->lng->txt('enable_fora_statistics'), 'fora_statistics');
178 $check->setInfo($this->lng->txt('enable_fora_statistics_desc'));
179 $form->addItem($check);
180
181 $check = new ilCheckboxInputGui($this->lng->txt('enable_anonymous_fora'), 'anonymous_fora');
182 $check->setInfo($this->lng->txt('enable_anonymous_fora_desc'));
183 $form->addItem($check);
184
185 $file_upload = new ilRadioGroupInputGUI(
186 $this->lng->txt('file_upload_allowed_fora'),
187 'file_upload_allowed_fora'
188 );
189 $option_all_forums = new ilRadioOption(
190 $this->lng->txt('file_upload_option_allow'),
192 $this->lng->txt('file_upload_option_allow_info')
193 );
194 $file_upload->addOption($option_all_forums);
195
196 $option_per_forum = new ilRadioOption(
197 $this->lng->txt('file_upload_option_disallow'),
199 $this->lng->txt('file_upload_allowed_fora_desc')
200 );
201 $file_upload->addOption($option_per_forum);
202
203 $form->addItem($file_upload);
204
205 if (ilCronManager::isJobActive('frm_notification')) {
208 $form,
209 $this
210 );
211 } else {
212 $notifications = new ilCheckboxInputGui($this->lng->txt('cron_forum_notification'), 'forum_notification');
213 $notifications->setInfo($this->lng->txt('cron_forum_notification_desc'));
214 $notifications->setValue(1);
215 $form->addItem($notifications);
216 }
217
218 $check = new ilCheckboxInputGui($this->lng->txt('enable_send_attachments'), 'send_attachments_by_mail');
219 $check->setInfo($this->lng->txt('enable_send_attachments_desc'));
220 $check->setValue(1);
221 $form->addItem($check);
222
223 $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
224 $cap->setInfo($this->lng->txt('adm_captcha_anonymous_frm'));
225 $cap->setValue(1);
227 $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
228 }
229 $form->addItem($cap);
230
231 $drafts = new ilCheckboxInputGUI($this->lng->txt('adm_save_drafts'), 'save_post_drafts');
232 $drafts->setInfo($this->lng->txt('adm_save_drafts_desc'));
233 $drafts->setValue(1);
234
235 $autosave_drafts = new ilCheckboxInputGUI($this->lng->txt('adm_autosave_drafts'), 'autosave_drafts');
236 $autosave_drafts->setInfo($this->lng->txt('adm_autosave_drafts_desc'));
237 $autosave_drafts->setValue(1);
238
239 $autosave_interval = new ilNumberInputGUI($this->lng->txt('adm_autosave_ival'), 'autosave_drafts_ival');
240 $autosave_interval->allowDecimals(false);
241 $autosave_interval->setMinValue(30);
242 $autosave_interval->setMaxValue(60 * 60);
243 $autosave_interval->setSize(10);
244 $autosave_interval->setSuffix($this->lng->txt('seconds'));
245 $autosave_drafts->addSubItem($autosave_interval);
246 $drafts->addSubItem($autosave_drafts);
247 $form->addItem($drafts);
248
249 if ($this->checkPermissionBool("write")) {
250 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
251 }
252
253 return $form;
254 }
255
260 public function addToExternalSettingsForm($a_form_id)
261 {
262 switch ($a_form_id) {
264
265 $fields = array(
266 'enable_fora_statistics' => array($this->settings->get('enable_fora_statistics', false), ilAdministrationSettingsFormHandler::VALUE_BOOL),
267 'enable_anonymous_fora' => array($this->settings->get('enable_anonymous_fora', false), ilAdministrationSettingsFormHandler::VALUE_BOOL)
268 );
269
270 return array(array("editSettings", $fields));
271
273 $fields = array(
274 'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForForum(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
275 );
276
277 return array('obj_frma' => array('editSettings', $fields));
278 }
279 }
280}
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
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.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
settings()
Definition: settings.php:2