ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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('enable_fora_statistics', (int)$form->getInput('fora_statistics'));
123 $ilSetting->set('enable_anonymous_fora', (int)$form->getInput('anonymous_fora'));
124
125 require_once 'Services/Cron/classes/class.ilCronManager.php';
126 if(!ilCronManager::isJobActive('frm_notification'))
127 {
128 $ilSetting->set('forum_notification', (int)$form->getInput('forum_notification'));
129 }
130
131 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
132 ilCaptchaUtil::setActiveForForum((bool)$form->getInput('activate_captcha_anonym'));
133
134 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
135 $form->setValuesByPost();
136 $this->editSettings($form);
137 }
138
142 protected function populateForm(ilPropertyFormGUI $form)
143 {
147 global $ilSetting;
148
149 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
150
151 $frma_set = new ilSetting('frma');
152
153 $form->setValuesByArray(array(
154 'forum_overview' => (bool)$frma_set->get('forum_overview', false),
155 'fora_statistics' => (bool)$ilSetting->get('enable_fora_statistics', false),
156 'anonymous_fora' => (bool)$ilSetting->get('enable_anonymous_fora', false),
157 'forum_notification' => (int)$ilSetting->get('forum_notification') === 1 ? true : false,
158 'activate_captcha_anonym' => ilCaptchaUtil::isActiveForForum(),
159 'file_upload_allowed_fora' => (int)$ilSetting->get('file_upload_allowed_fora', ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED)
160 ));
161 }
162
166 protected function getSettingsForm()
167 {
168 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
169 $form = new ilPropertyFormGUI();
170 $form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
171 $form->setTitle($this->lng->txt('settings'));
172
173 $frm_radio = new ilRadioGroupInputGUI($this->lng->txt('frm_displayed_infos'), 'forum_overview');
174 $frm_radio->addOption(new ilRadioOption($this->lng->txt('new') . ', ' . $this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '0'));
175 $frm_radio->addOption(new ilRadioOption($this->lng->txt('is_read') . ', ' . $this->lng->txt('unread'), '1'));
176 $frm_radio->setInfo($this->lng->txt('frm_disp_info_desc'));
177 $form->addItem($frm_radio);
178
179 $check = new ilCheckboxInputGui($this->lng->txt('enable_fora_statistics'), 'fora_statistics');
180 $check->setInfo($this->lng->txt('enable_fora_statistics_desc'));
181 $form->addItem($check);
182
183 $check = new ilCheckboxInputGui($this->lng->txt('enable_anonymous_fora'), 'anonymous_fora');
184 $check->setInfo($this->lng->txt('enable_anonymous_fora_desc'));
185 $form->addItem($check);
186
187 $file_upload = new ilRadioGroupInputGUI($this->lng->txt('file_upload_allowed_fora'), 'file_upload_allowed_fora');
188 $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_allow'), ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED));
189 $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_disallow'), ilForumProperties::FILE_UPLOAD_INDIVIDUAL));
190 $file_upload->setInfo($this->lng->txt('file_upload_allowed_fora_desc'));
191 $form->addItem($file_upload);
192
193 require_once 'Services/Cron/classes/class.ilCronManager.php';
194 if(ilCronManager::isJobActive('frm_notification'))
195 {
196 require_once 'Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php';
199 $form,
200 $this
201 );
202 }
203 else
204 {
205 $notifications = new ilCheckboxInputGui($this->lng->txt('cron_forum_notification'), 'forum_notification');
206 $notifications->setInfo($this->lng->txt('cron_forum_notification_desc'));
207 $notifications->setValue(1);
208 $form->addItem($notifications);
209 }
210
211 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
212 $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
213 $cap->setInfo($this->lng->txt('adm_captcha_anonymous_frm'));
214 $cap->setValue(1);
216 {
217 $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
218 }
219 $form->addItem($cap);
220
221 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
222 $form->addCommandButton('editSettings', $this->lng->txt('cancel'));
223
224 return $form;
225 }
226
231 public function addToExternalSettingsForm($a_form_id)
232 {
236 global $ilSetting;
237
238 switch($a_form_id)
239 {
241
242 $fields = array(
243 'enable_fora_statistics' => array($ilSetting->get('enable_fora_statistics', false), ilAdministrationSettingsFormHandler::VALUE_BOOL),
244 'enable_anonymous_fora' => array($ilSetting->get('enable_anonymous_fora', false), ilAdministrationSettingsFormHandler::VALUE_BOOL)
245 );
246
247 return array(array("editSettings", $fields));
248
250 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
251 $fields = array(
252 'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForForum(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
253 );
254
255 return array('obj_frma' => array('editSettings', $fields));
256 }
257 }
258}
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.
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()
prepare output
getAdminTabs(&$tabs_gui)
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).
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
addCommandButton($a_cmd, $a_text)
Add Command button.
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:40
$cmd
Definition: sahs_server.php:35