ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjPersonalDesktopSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 include_once("./Services/Object/classes/class.ilObjectGUI.php");
4 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
5 require_once 'Services/PersonalDesktop/ItemsBlock/classes/class.ilPDSelectedItemsBlockViewSettings.php';
6 
18 {
22  protected $rbacsystem;
23 
27  protected $error;
28 
29  private static $ERROR_MESSAGE;
30 
34  protected $viewSettings;
40  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
41  {
42  global $DIC;
43 
44  $this->lng = $DIC->language();
45  $this->rbacsystem = $DIC->rbac()->system();
46  $this->error = $DIC["ilErr"];
47  $this->access = $DIC->access();
48  $this->ctrl = $DIC->ctrl();
49  $this->settings = $DIC->settings();
50  $lng = $DIC->language();
51  $this->ui_factory = $DIC->ui()->factory();
52  $this->ui_renderer = $DIC->ui()->renderer();
53 
54  $this->type = 'pdts';
55  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
56 
57  $lng->loadLanguageModule("pd");
58 
59  $this->viewSettings = new ilPDSelectedItemsBlockViewSettings($GLOBALS['DIC']->user());
60  }
61 
68  public function executeCommand()
69  {
72  $ilAccess = $this->access;
73 
74  $next_class = $this->ctrl->getNextClass($this);
75  $cmd = $this->ctrl->getCmd();
76 
77  $this->prepareOutput();
78 
79  if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
80  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
81  }
82 
83  switch ($next_class) {
84  case 'ilpermissiongui':
85  $this->tabs_gui->setTabActive('perm_settings');
86  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
87  $perm_gui = new ilPermissionGUI($this);
88  $ret = $this->ctrl->forwardCommand($perm_gui);
89  break;
90 
91  default:
92  if (!$cmd || $cmd == 'view') {
93  $cmd = "editSettings";
94  }
95 
96  $this->$cmd();
97  break;
98  }
99  return true;
100  }
101 
108  public function getAdminTabs()
109  {
111  $ilAccess = $this->access;
112 
113  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
114  $this->tabs_gui->addTarget(
115  "pd_settings",
116  $this->ctrl->getLinkTarget($this, "editSettings"),
117  array("editSettings", "view")
118  );
119 
120  $this->tabs_gui->addTarget(
121  "pd_personal_workspace",
122  $this->ctrl->getLinkTarget($this, "editWsp"),
123  array("editWsp")
124  );
125  }
126 
127  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
128  $this->tabs_gui->addTarget(
129  "perm_settings",
130  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
131  array(),
132  'ilpermissiongui'
133  );
134  }
135  }
136 
140  public function editSettings()
141  {
143  $lng = $this->lng;
145  $ilAccess = $this->access;
146 
147  $pd_set = new ilSetting("pd");
148 
149  $enable_calendar = ilCalendarSettings::_getInstance()->isEnabled();
150  #$enable_calendar = $ilSetting->get("enable_calendar");
151  $enable_block_moving = $pd_set->get("enable_block_moving");
152  $enable_active_users = $ilSetting->get("block_activated_pdusers");
153 
154  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
155  $form = new ilPropertyFormGUI();
156  $form->setFormAction($ilCtrl->getFormAction($this));
157  $form->setTitle($lng->txt("pd_settings"));
158 
159  // Enable calendar
160  $cb_prop = new ilCheckboxInputGUI($lng->txt("enable_calendar"), "enable_calendar");
161  $cb_prop->setValue("1");
162  //$cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
163  $cb_prop->setChecked($enable_calendar);
164  $form->addItem($cb_prop);
165 
166  // Enable bookmarks
167  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_bookmarks"), "enable_bookmarks");
168  $cb_prop->setValue("1");
169  $cb_prop->setChecked(($ilSetting->get("disable_bookmarks") ? "0" : "1"));
170  $form->addItem($cb_prop);
171 
172  // Enable notes
173  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_notes"), "enable_notes");
174  $cb_prop->setValue("1");
175  $cb_prop->setChecked(($ilSetting->get("disable_notes") ? "0" : "1"));
176  $form->addItem($cb_prop);
177 
178  // Enable notes
179  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_comments"), "enable_comments");
180  $cb_prop->setValue("1");
181  $cb_prop->setChecked(($ilSetting->get("disable_comments") ? "0" : "1"));
182  $form->addItem($cb_prop);
183 
184  $comm_del_user = new ilCheckboxInputGUI($lng->txt("pd_enable_comments_del_user"), "comm_del_user");
185  $comm_del_user->setChecked($ilSetting->get("comments_del_user", 0));
186  $cb_prop->addSubItem($comm_del_user);
187 
188  $comm_del_tutor = new ilCheckboxInputGUI($lng->txt("pd_enable_comments_del_tutor"), "comm_del_tutor");
189  $comm_del_tutor->setInfo($lng->txt("pd_enable_comments_del_tutor_info"));
190  $comm_del_tutor->setChecked($ilSetting->get("comments_del_tutor", 1));
191  $cb_prop->addSubItem($comm_del_tutor);
192 
193  $ti = new ilTextInputGUI($this->lng->txt("pd_comments_notification"), "comments_noti_recip");
194  $ti->setValue($ilSetting->get("comments_noti_recip"));
195  $ti->setMaxLength(200);
196  $ti->setInfo($this->lng->txt("pd_comments_notification_info"));
197  $cb_prop->addSubItem($ti);
198 
199  // Enable Chatviewer
200  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_chatviewer"), "block_activated_chatviewer");
201  $cb_prop->setValue("1");
202  $cb_prop->setChecked(($ilSetting->get("block_activated_chatviewer")));
203  $form->addItem($cb_prop);
204 
205  require_once 'Services/Mail/classes/class.ilObjMail.php';
206  $pd_sys_msg = new ilRadioGroupInputGUI($lng->txt('show_system_messages'), 'pd_sys_msg_mode');
207 
208  $sys_msg_own_block = new ilRadioOption($lng->txt('pd_sys_msg_own_block'), ilObjMail::PD_SYS_MSG_OWN_BLOCK);
209  $pd_sys_msg->addOption($sys_msg_own_block);
210 
211  $sys_msg_mail_block = new ilRadioOption($lng->txt('pd_sys_msg_mail_block'), ilObjMail::PD_SYS_MSG_MAIL_BLOCK);
212  $pd_sys_msg->addOption($sys_msg_mail_block);
213 
214  $sys_msg_own_block = new ilRadioOption($lng->txt('pd_sys_msg_no_block'), ilObjMail::PD_SYS_MSG_NO_BLOCK);
215  $pd_sys_msg->addOption($sys_msg_own_block);
216 
217  $pd_sys_msg->setValue((int) ($ilSetting->get('pd_sys_msg_mode')));
218  $form->addItem($pd_sys_msg);
219 
220  if ($ilSetting->get('save_post_drafts', 0)) {
221  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_pdfrmpostdraft'), 'block_activated_pdfrmpostdraft');
222  $cb_prop->setInfo($lng->txt('pd_enable_pdfrmpostdraft_info'));
223  $cb_prop->setValue(1);
224  $cb_prop->setChecked($ilSetting->get('block_activated_pdfrmpostdraft', 0));
225  $form->addItem($cb_prop);
226  }
227  // Enable block moving
228  $cb_prop = new ilCheckboxInputGUI(
229  $lng->txt("pd_enable_block_moving"),
230  "enable_block_moving"
231  );
232  $cb_prop->setValue("1");
233  $cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
234  $cb_prop->setChecked($enable_block_moving);
235  $form->addItem($cb_prop);
236 
237  // Enable active users block
238  /*
239  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_active_users"),
240  "block_activated_pdusers");
241  $cb_prop->setValue("1");
242  $cb_prop->setChecked($enable_active_users);
243 
244  // maximum inactivity time
245  $ti_prop = new ilNumberInputGUI($lng->txt("pd_time_before_removal"),
246  "time_removal");
247  $ti_prop->setValue($pd_set->get("user_activity_time"));
248  $ti_prop->setInfo($lng->txt("pd_time_before_removal_info"));
249  $ti_prop->setMaxLength(3);
250  $ti_prop->setSize(3);
251  $cb_prop->addSubItem($ti_prop);
252 
253  $form->addItem($cb_prop);
254  */
255  // Enable 'My Offers' (default personal items)
256  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_offers'), 'enable_my_offers');
257  $cb_prop->setValue('1');
258  $cb_prop->setInfo($lng->txt('pd_enable_my_offers_info'));
259  $cb_prop->setChecked($this->viewSettings->enabledSelectedItems());
260  $form->addItem($cb_prop);
261 
262  // Enable 'My Memberships'
263  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_memberships'), 'enable_my_memberships');
264  $cb_prop->setValue('1');
265  $cb_prop->setInfo($lng->txt('pd_enable_my_memberships_info'));
266  $cb_prop->setChecked($this->viewSettings->enabledMemberships());
267  $form->addItem($cb_prop);
268 
269  $memberships_sort_defaults = new ilRadioGroupInputGUI($lng->txt('pd_my_memberships_sort_default'), 'my_memberships_sort_default');
270  $memberships_sort_defaults->addOption(new ilRadioOption($lng->txt('pd_sort_by_location'), $this->viewSettings->getSortByLocationMode()));
271  $memberships_sort_defaults->addOption(new ilRadioOption($lng->txt('pd_sort_by_type'), $this->viewSettings->getSortByTypeMode()));
272  $memberships_sort_defaults->addOption(new ilRadioOption($lng->txt('pd_sort_by_start_date'), $this->viewSettings->getSortByStartDateMode()));
273  $memberships_sort_defaults->setRequired(true);
274  $memberships_sort_defaults->setValue($this->viewSettings->getDefaultSortType());
275  $cb_prop->addSubItem($memberships_sort_defaults);
276 
277  #22357
278  $this->ctrl->setParameterByClass("iluserstartingpointgui", "ref_id", USER_FOLDER_ID);
279  $url = $this->ctrl->getLinkTargetByClass(array("iladministrationgui","ilobjuserfoldergui", "iluserstartingpointgui"), "startingpoints");
280  $this->ctrl->setParameterByClass("iluserstartingpointgui", "ref_id", $_GET['ref_id']);
281 
282  $lng->loadLanguageModule("user");
283  $starting_point_button = $this->ui_factory->button()->shy($lng->txt("starting_points"), $url);
284  $button = new ilCustomInputGUI($lng->txt('pd_personal_items_default_view'), '');
285  $button->setHtml($this->ui_renderer->render($starting_point_button));
286  $form->addItem($button);
287 
288  if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
289  // command buttons
290  $form->addCommandButton("saveSettings", $lng->txt("save"));
291  $form->addCommandButton("view", $lng->txt("cancel"));
292  }
293 
294  $this->tpl->setContent($form->getHTML());
295  }
296 
300  public function saveSettings()
301  {
304  $ilAccess = $this->access;
305 
306  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
307  $ilCtrl->redirect($this, "view");
308  }
309 
310  $pd_set = new ilSetting("pd");
311 
312  ilCalendarSettings::_getInstance()->setEnabled($_POST["enable_calendar"]);
314 
315  #$ilSetting->set("enable_calendar", $_POST["enable_calendar"]);
316  $ilSetting->set("disable_bookmarks", (int) ($_POST["enable_bookmarks"] ? 0 : 1));
317 
318  $ilSetting->set("disable_notes", (int) ($_POST["enable_notes"] ? 0 : 1));
319  $ilSetting->set("disable_comments", (int) ($_POST["enable_comments"] ? 0 : 1));
320 
321  $ilSetting->set("comments_del_user", (int) ($_POST["comm_del_user"] ? 1 : 0));
322  $ilSetting->set("comments_del_tutor", (int) ($_POST["comm_del_tutor"] ? 1 : 0));
323  $ilSetting->set("comments_noti_recip", ilUtil::stripSlashes($_POST["comments_noti_recip"]));
324 
325  $ilSetting->set("block_activated_chatviewer", (int) ($_POST["block_activated_chatviewer"]));
326  $ilSetting->set("pd_sys_msg_mode", (int) ($_POST["pd_sys_msg_mode"]));
327  if ($ilSetting->get('save_post_drafts', 0)) {
328  $ilSetting->set("block_activated_pdfrmpostdraft", (int) $_POST["block_activated_pdfrmpostdraft"]);
329  }
330  // $ilSetting->set("block_activated_pdusers", $_POST["block_activated_pdusers"]);
331  $pd_set->set("enable_block_moving", $_POST["enable_block_moving"]);
332  // $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
333 
334  // Validate personal desktop view
335  if (!(int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
336  ilUtil::sendFailure($this->lng->txt('pd_view_select_at_least_one'), true);
337  $ilCtrl->redirect($this, 'view');
338  }
339 
340  $this->viewSettings->enableSelectedItems((int) ($_POST['enable_my_offers'] ? 1 : 0));
341  $this->viewSettings->enableMemberships((int) ($_POST['enable_my_memberships'] ? 1 : 0));
342 
343  if ((int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
344  $this->viewSettings->storeDefaultView($this->viewSettings->getSelectedItemsView());
345  } elseif (!(int) $_POST['enable_my_offers'] && (int) $_POST['enable_my_memberships']) {
346  $this->viewSettings->storeDefaultView($this->viewSettings->getMembershipsView());
347  } elseif (isset($_POST['personal_items_default_view'])) {
348  $this->viewSettings->storeDefaultView((int) $_POST['personal_items_default_view']);
349  }
350 
351  $this->viewSettings->storeDefaultSortType(ilUtil::stripSlashes($_POST['my_memberships_sort_default']));
352 
353  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
354  $ilCtrl->redirect($this, "view");
355  }
356 
360  public function editWsp()
361  {
363  $lng = $this->lng;
365  $ilAccess = $this->access;
366 
367  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
368  $form = new ilPropertyFormGUI();
369  $form->setFormAction($ilCtrl->getFormAction($this, "saveWsp"));
370  $form->setTitle($lng->txt("pd_personal_workspace"));
371 
372  // Enable 'Personal Workspace'
373  $wsp_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_personal_workspace'), 'wsp');
374  $wsp_prop->setValue('1');
375  $wsp_prop->setChecked(($ilSetting->get('disable_personal_workspace') ? '0' : '1'));
376  $form->addItem($wsp_prop);
377 
378  // Enable 'Blogs'
379  $blog_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_blogs'), 'blog');
380  $blog_prop->setValue('1');
381  $blog_prop->setChecked(($ilSetting->get('disable_wsp_blogs') ? '0' : '1'));
382  $wsp_prop->addSubItem($blog_prop);
383 
384  // Enable 'Files'
385  $file_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_files'), 'file');
386  $file_prop->setValue('1');
387  $file_prop->setChecked(($ilSetting->get('disable_wsp_files') ? '0' : '1'));
388  $wsp_prop->addSubItem($file_prop);
389 
390  // Enable 'Certificates'
391  $cert_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_certificates'), 'cert');
392  $cert_prop->setValue('1');
393  $cert_prop->setChecked(($ilSetting->get('disable_wsp_certificates') ? '0' : '1'));
394  $wsp_prop->addSubItem($cert_prop);
395 
396  // Enable 'Links'
397  $link_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_links'), 'link');
398  $link_prop->setValue('1');
399  $link_prop->setChecked(($ilSetting->get('disable_wsp_links') ? '0' : '1'));
400  $wsp_prop->addSubItem($link_prop);
401 
402  /*
403  // Enable 'Portfolios'
404  $lng->loadLanguageModule('user');
405  $prtf_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_prtf'), 'prtf');
406  $prtf_prop->setValue('1');
407  $prtf_prop->setInfo($lng->txt('user_portfolios_desc'));
408  $prtf_prop->setChecked(($ilSetting->get('user_portfolios') ? '1' : '0'));
409  $form->addItem($prtf_prop);
410  */
411 
412  // Load the disk quota settings object
413  require_once 'Services/WebDAV/classes/class.ilObjDiskQuotaSettings.php';
414  $disk_quota_obj = ilObjDiskQuotaSettings::getInstance();
415 
416  // Enable disk quota
417  $lng->loadLanguageModule("file");
418  $cb_prop = new ilCheckboxInputGUI($lng->txt("personal_workspace_disk_quota"), "enable_personal_workspace_disk_quota");
419  $cb_prop->setValue('1');
420  $cb_prop->setChecked($disk_quota_obj->isPersonalWorkspaceDiskQuotaEnabled());
421  $cb_prop->setInfo($lng->txt('enable_personal_workspace_disk_quota_info'));
422  $form->addItem($cb_prop);
423 
424  require_once 'Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php';
427  $form,
428  $this
429  );
430 
431  if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
432  // command buttons
433  $form->addCommandButton("saveWsp", $lng->txt("save"));
434  $form->addCommandButton("editWsp", $lng->txt("cancel"));
435  }
436 
437  $this->tpl->setContent($form->getHTML());
438  }
439 
443  public function saveWsp()
444  {
447  $ilAccess = $this->access;
448 
449  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
450  $ilCtrl->redirect($this, "view");
451  }
452 
453  // without personal workspace we have to disable to sub-items
454  if (!$_POST["wsp"]) {
455  $_POST["blog"] = 0;
456  $_POST["file"] = 0;
457  $_POST["cert"] = 0;
458  $_POST["link"] = 0;
459  }
460 
461  $ilSetting->set('disable_personal_workspace', (int) ($_POST['wsp'] ? 0 : 1));
462  $ilSetting->set('disable_wsp_blogs', (int) ($_POST['blog'] ? 0 : 1));
463  $ilSetting->set('disable_wsp_files', (int) ($_POST['file'] ? 0 : 1));
464  $ilSetting->set('disable_wsp_certificates', (int) ($_POST['cert'] ? 0 : 1));
465  $ilSetting->set('disable_wsp_links', (int) ($_POST['link'] ? 0 : 1));
466  // $ilSetting->set('user_portfolios', (int)($_POST['prtf'] ? 1 : 0));
467 
468  // Load the disk quota settings object
469  require_once 'Services/WebDAV/classes/class.ilObjDiskQuotaSettings.php';
470  $disk_quota_obj = ilObjDiskQuotaSettings::getInstance();
471  $disk_quota_obj->setPersonalWorkspaceDiskQuotaEnabled($_POST['enable_personal_workspace_disk_quota'] == '1');
472  $disk_quota_obj->update();
473 
474  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
475  $ilCtrl->redirect($this, "editWsp");
476  }
477 
478  public function addToExternalSettingsForm($a_form_id)
479  {
480  switch ($a_form_id) {
482 
483  require_once 'Services/WebDAV/classes/class.ilObjDiskQuotaSettings.php';
484  $disk_quota_obj = ilObjDiskQuotaSettings::getInstance();
485 
486  $fields = array('personal_workspace_disk_quota' => array($disk_quota_obj->isPersonalWorkspaceDiskQuotaEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
487 
488  return array(array("editWsp", $fields));
489  }
490  }
491 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
const PD_SYS_MSG_NO_BLOCK
This class represents an option in a radio group.
static _getInstance()
get singleton instance
setHtml($a_html)
Set Html.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
This class represents a checkbox property in a property form.
user()
Definition: user.php:4
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
const PD_SYS_MSG_OWN_BLOCK
setChecked($a_checked)
Set Checked.
prepareOutput($a_show_subobjects=true)
prepare output
This class represents a property in a property form.
addOption($a_option)
Add Option.
setValue($a_value)
Set Value.
if(isset($_POST['submit'])) $form
Class ilPDSelectedItemsBlockViewSettings.
Class ilObjectGUI Basic methods of all Output classes.
setValue($a_value)
Set Value.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a custom property in a property form.
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
$ret
Definition: parser.php:6
const USER_FOLDER_ID
Class ilObjUserFolder.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
$url
setValue($a_value)
Set Value.
$_POST["username"]
static getInstance()
Get settings instance.
const PD_SYS_MSG_MAIL_BLOCK