ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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($this->lng->txt('file_upload_allowed_fora'), 'file_upload_allowed_fora');
186  $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_allow'), ilForumProperties::FILE_UPLOAD_GLOBALLY_ALLOWED));
187  $file_upload->addOption(new ilRadioOption($this->lng->txt('file_upload_option_disallow'), ilForumProperties::FILE_UPLOAD_INDIVIDUAL));
188  $file_upload->setInfo($this->lng->txt('file_upload_allowed_fora_desc'));
189  $form->addItem($file_upload);
190 
191  if (ilCronManager::isJobActive('frm_notification')) {
194  $form,
195  $this
196  );
197  } else {
198  $notifications = new ilCheckboxInputGui($this->lng->txt('cron_forum_notification'), 'forum_notification');
199  $notifications->setInfo($this->lng->txt('cron_forum_notification_desc'));
200  $notifications->setValue(1);
201  $form->addItem($notifications);
202  }
203 
204  $check = new ilCheckboxInputGui($this->lng->txt('enable_send_attachments'), 'send_attachments_by_mail');
205  $check->setInfo($this->lng->txt('enable_send_attachments_desc'));
206  $check->setValue(1);
207  $form->addItem($check);
208 
209  $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
210  $cap->setInfo($this->lng->txt('adm_captcha_anonymous_frm'));
211  $cap->setValue(1);
213  $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
214  }
215  $form->addItem($cap);
216 
217  $drafts = new ilCheckboxInputGUI($this->lng->txt('adm_save_drafts'), 'save_post_drafts');
218  $drafts->setInfo($this->lng->txt('adm_save_drafts_desc'));
219  $drafts->setValue(1);
220 
221  $autosave_drafts = new ilCheckboxInputGUI($this->lng->txt('adm_autosave_drafts'), 'autosave_drafts');
222  $autosave_drafts->setInfo($this->lng->txt('adm_autosave_drafts_desc'));
223  $autosave_drafts->setValue(1);
224 
225  $autosave_interval = new ilNumberInputGUI($this->lng->txt('adm_autosave_ival'), 'autosave_drafts_ival');
226  $autosave_interval->allowDecimals(false);
227  $autosave_interval->setMinValue(30);
228  $autosave_interval->setMaxValue(60 * 60);
229  $autosave_interval->setSize(10);
230  $autosave_interval->setSuffix($this->lng->txt('seconds'));
231  $autosave_drafts->addSubItem($autosave_interval);
232  $drafts->addSubItem($autosave_drafts);
233  $form->addItem($drafts);
234 
235  if ($this->checkPermissionBool("write")) {
236  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
237  }
238 
239  return $form;
240  }
241 
246  public function addToExternalSettingsForm($a_form_id)
247  {
248  switch ($a_form_id) {
250 
251  $fields = array(
252  'enable_fora_statistics' => array($this->settings->get('enable_fora_statistics', false), ilAdministrationSettingsFormHandler::VALUE_BOOL),
253  'enable_anonymous_fora' => array($this->settings->get('enable_anonymous_fora', false), ilAdministrationSettingsFormHandler::VALUE_BOOL)
254  );
255 
256  return array(array("editSettings", $fields));
257 
259  $fields = array(
260  'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForForum(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
261  );
262 
263  return array('obj_frma' => array('editSettings', $fields));
264  }
265  }
266 }
This class represents an option in a radio group.
settings()
Definition: settings.php:2
This class represents a property form user interface.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor public.
static checkFreetype()
Check whether captcha support is active.
This class represents a checkbox property in a property form.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
allowDecimals($a_value)
Toggle Decimals.
setInfo($a_info)
Set Information Text.
prepareOutput($a_show_subobjects=true)
prepare output
This class represents a property in a property form.
addOption($a_option)
Add Option.
editSettings(ilPropertyFormGUI $form=null)
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static isJobActive($a_job_id)
Check if given job is currently active.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.