ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
153  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
154  $form = new ilPropertyFormGUI();
155  $form->setFormAction($ilCtrl->getFormAction($this));
156  $form->setTitle($lng->txt("pd_settings"));
157 
158  // Enable calendar
159  $cb_prop = new ilCheckboxInputGUI($lng->txt("enable_calendar"), "enable_calendar");
160  $cb_prop->setValue("1");
161  //$cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
162  $cb_prop->setChecked($enable_calendar);
163  $form->addItem($cb_prop);
164 
165  // Enable bookmarks
166  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_bookmarks"), "enable_bookmarks");
167  $cb_prop->setValue("1");
168  $cb_prop->setChecked(($ilSetting->get("disable_bookmarks") ? "0" : "1"));
169  $form->addItem($cb_prop);
170 
171  // Enable notes
172  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_notes"), "enable_notes");
173  $cb_prop->setValue("1");
174  $cb_prop->setChecked(($ilSetting->get("disable_notes") ? "0" : "1"));
175  $form->addItem($cb_prop);
176 
177  // Enable comments
178  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_comments"), "enable_comments");
179  $cb_prop->setValue("1");
180  $cb_prop->setChecked(($ilSetting->get("disable_comments") ? "0" : "1"));
181  $form->addItem($cb_prop);
182 
183  $comm_del_user = new ilCheckboxInputGUI($lng->txt("pd_enable_comments_del_user"), "comm_del_user");
184  $comm_del_user->setChecked($ilSetting->get("comments_del_user", 0));
185  $cb_prop->addSubItem($comm_del_user);
186 
187  $comm_del_tutor = new ilCheckboxInputGUI($lng->txt("pd_enable_comments_del_tutor"), "comm_del_tutor");
188  $comm_del_tutor->setInfo($lng->txt("pd_enable_comments_del_tutor_info"));
189  $comm_del_tutor->setChecked($ilSetting->get("comments_del_tutor", 1));
190  $cb_prop->addSubItem($comm_del_tutor);
191 
192  $ti = new ilTextInputGUI($this->lng->txt("pd_comments_notification"), "comments_noti_recip");
193  $ti->setValue($ilSetting->get("comments_noti_recip"));
194  $ti->setMaxLength(200);
195  $ti->setInfo($this->lng->txt("pd_comments_notification_info"));
196  $cb_prop->addSubItem($ti);
197 
198  // Enable learning history
199  $learn_hist = new ilCheckboxInputGUI($lng->txt("pd_enable_learning_history"), "enable_learning_history");
200  $learn_hist->setValue("1");
201  $learn_hist->setInfo($lng->txt("pd_enable_learning_history_info"));
202  $learn_hist->setChecked(($ilSetting->get("enable_learning_history") ? "1" : "0"));
203  $form->addItem($learn_hist);
204 
205  // Enable Chatviewer
206  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_chatviewer"), "block_activated_chatviewer");
207  $cb_prop->setValue("1");
208  $cb_prop->setChecked(($ilSetting->get("block_activated_chatviewer")));
209  $form->addItem($cb_prop);
210 
211  require_once 'Services/Mail/classes/class.ilObjMail.php';
212  $pd_sys_msg = new ilRadioGroupInputGUI($lng->txt('show_system_messages'), 'pd_sys_msg_mode');
213 
214  $sys_msg_own_block = new ilRadioOption($lng->txt('pd_sys_msg_own_block'), ilObjMail::PD_SYS_MSG_OWN_BLOCK);
215  $pd_sys_msg->addOption($sys_msg_own_block);
216 
217  $sys_msg_mail_block = new ilRadioOption($lng->txt('pd_sys_msg_mail_block'), ilObjMail::PD_SYS_MSG_MAIL_BLOCK);
218  $pd_sys_msg->addOption($sys_msg_mail_block);
219 
220  $sys_msg_own_block = new ilRadioOption($lng->txt('pd_sys_msg_no_block'), ilObjMail::PD_SYS_MSG_NO_BLOCK);
221  $pd_sys_msg->addOption($sys_msg_own_block);
222 
223  $pd_sys_msg->setValue((int) ($ilSetting->get('pd_sys_msg_mode')));
224  $form->addItem($pd_sys_msg);
225 
226  if ($ilSetting->get('save_post_drafts', 0)) {
227  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_pdfrmpostdraft'), 'block_activated_pdfrmpostdraft');
228  $cb_prop->setInfo($lng->txt('pd_enable_pdfrmpostdraft_info'));
229  $cb_prop->setValue(1);
230  $cb_prop->setChecked($ilSetting->get('block_activated_pdfrmpostdraft', 0));
231  $form->addItem($cb_prop);
232  }
233  // Enable block moving
234  $cb_prop = new ilCheckboxInputGUI(
235  $lng->txt("pd_enable_block_moving"),
236  "enable_block_moving"
237  );
238  $cb_prop->setValue("1");
239  $cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
240  $cb_prop->setChecked($enable_block_moving);
241  $form->addItem($cb_prop);
242 
243  // Enable 'My Offers' (default personal items)
244  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_offers'), 'enable_my_offers');
245  $cb_prop->setValue('1');
246  $cb_prop->setInfo($lng->txt('pd_enable_my_offers_info'));
247  $cb_prop->setChecked($this->viewSettings->enabledSelectedItems());
248  $form->addItem($cb_prop);
249 
250  // Enable 'My Memberships'
251  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_memberships'), 'enable_my_memberships');
252  $cb_prop->setValue('1');
253  $cb_prop->setInfo($lng->txt('pd_enable_my_memberships_info'));
254  $cb_prop->setChecked($this->viewSettings->enabledMemberships());
255  $form->addItem($cb_prop);
256 
257  $memberships_sort_defaults = new ilRadioGroupInputGUI($lng->txt('pd_my_memberships_sort_default'), 'my_memberships_sort_default');
258  $memberships_sort_defaults->addOption(new ilRadioOption($lng->txt('pd_sort_by_location'), $this->viewSettings->getSortByLocationMode()));
259  $memberships_sort_defaults->addOption(new ilRadioOption($lng->txt('pd_sort_by_type'), $this->viewSettings->getSortByTypeMode()));
260  $memberships_sort_defaults->addOption(new ilRadioOption($lng->txt('pd_sort_by_start_date'), $this->viewSettings->getSortByStartDateMode()));
261  $memberships_sort_defaults->setRequired(true);
262  $memberships_sort_defaults->setValue($this->viewSettings->getDefaultSortType());
263  $cb_prop->addSubItem($memberships_sort_defaults);
264 
265  #22357
266  $this->ctrl->setParameterByClass("iluserstartingpointgui", "ref_id", USER_FOLDER_ID);
267  $url = $this->ctrl->getLinkTargetByClass(array("iladministrationgui","ilobjuserfoldergui", "iluserstartingpointgui"), "startingpoints");
268  $this->ctrl->setParameterByClass("iluserstartingpointgui", "ref_id", $_GET['ref_id']);
269 
270  $lng->loadLanguageModule("user");
271  $starting_point_button = $this->ui_factory->button()->shy($lng->txt("starting_points"), $url);
272  $button = new ilCustomInputGUI($lng->txt('pd_personal_items_default_view'), '');
273  $button->setHtml($this->ui_renderer->render($starting_point_button));
274  $form->addItem($button);
275 
276  if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
277  // command buttons
278  $form->addCommandButton("saveSettings", $lng->txt("save"));
279  $form->addCommandButton("view", $lng->txt("cancel"));
280  }
281 
282  $this->tpl->setContent($form->getHTML());
283  }
284 
288  public function saveSettings()
289  {
292  $ilAccess = $this->access;
293 
294  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
295  $ilCtrl->redirect($this, "view");
296  }
297 
298  $pd_set = new ilSetting("pd");
299 
300  ilCalendarSettings::_getInstance()->setEnabled($_POST["enable_calendar"]);
302 
303  #$ilSetting->set("enable_calendar", $_POST["enable_calendar"]);
304  $ilSetting->set("disable_bookmarks", (int) ($_POST["enable_bookmarks"] ? 0 : 1));
305 
306  $ilSetting->set("disable_notes", (int) ($_POST["enable_notes"] ? 0 : 1));
307  $ilSetting->set("disable_comments", (int) ($_POST["enable_comments"] ? 0 : 1));
308 
309  $ilSetting->set("enable_learning_history", (int) $_POST["enable_learning_history"]);
310 
311  $ilSetting->set("comments_del_user", (int) ($_POST["comm_del_user"] ? 1 : 0));
312  $ilSetting->set("comments_del_tutor", (int) ($_POST["comm_del_tutor"] ? 1 : 0));
313  $ilSetting->set("comments_noti_recip", ilUtil::stripSlashes($_POST["comments_noti_recip"]));
314 
315  $ilSetting->set("block_activated_chatviewer", (int) ($_POST["block_activated_chatviewer"]));
316  $ilSetting->set("pd_sys_msg_mode", (int) ($_POST["pd_sys_msg_mode"]));
317  if ($ilSetting->get('save_post_drafts', 0)) {
318  $ilSetting->set("block_activated_pdfrmpostdraft", (int) $_POST["block_activated_pdfrmpostdraft"]);
319  }
320  $pd_set->set("enable_block_moving", $_POST["enable_block_moving"]);
321  // $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
322 
323  // Validate personal desktop view
324  if (!(int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
325  ilUtil::sendFailure($this->lng->txt('pd_view_select_at_least_one'), true);
326  $ilCtrl->redirect($this, 'view');
327  }
328 
329  $this->viewSettings->enableSelectedItems((int) ($_POST['enable_my_offers'] ? 1 : 0));
330  $this->viewSettings->enableMemberships((int) ($_POST['enable_my_memberships'] ? 1 : 0));
331 
332  if ((int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
333  $this->viewSettings->storeDefaultView($this->viewSettings->getSelectedItemsView());
334  } elseif (!(int) $_POST['enable_my_offers'] && (int) $_POST['enable_my_memberships']) {
335  $this->viewSettings->storeDefaultView($this->viewSettings->getMembershipsView());
336  } elseif (isset($_POST['personal_items_default_view'])) {
337  $this->viewSettings->storeDefaultView((int) $_POST['personal_items_default_view']);
338  }
339 
340  $this->viewSettings->storeDefaultSortType(ilUtil::stripSlashes($_POST['my_memberships_sort_default']));
341 
342  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
343  $ilCtrl->redirect($this, "view");
344  }
345 
349  public function editWsp()
350  {
352  $lng = $this->lng;
354  $ilAccess = $this->access;
355 
356  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
357  $form = new ilPropertyFormGUI();
358  $form->setFormAction($ilCtrl->getFormAction($this, "saveWsp"));
359  $form->setTitle($lng->txt("pd_personal_workspace"));
360 
361  // Enable 'Personal Workspace'
362  $wsp_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_personal_workspace'), 'wsp');
363  $wsp_prop->setValue('1');
364  $wsp_prop->setChecked(($ilSetting->get('disable_personal_workspace') ? '0' : '1'));
365  $form->addItem($wsp_prop);
366 
367  // Enable 'Blogs'
368  $blog_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_blogs'), 'blog');
369  $blog_prop->setValue('1');
370  $blog_prop->setChecked(($ilSetting->get('disable_wsp_blogs') ? '0' : '1'));
371  $wsp_prop->addSubItem($blog_prop);
372 
373  // Enable 'Files'
374  $file_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_files'), 'file');
375  $file_prop->setValue('1');
376  $file_prop->setChecked(($ilSetting->get('disable_wsp_files') ? '0' : '1'));
377  $wsp_prop->addSubItem($file_prop);
378 
379  // Enable 'Certificates'
380  $cert_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_certificates'), 'cert');
381  $cert_prop->setValue('1');
382  $cert_prop->setChecked(($ilSetting->get('disable_wsp_certificates') ? '0' : '1'));
383  $wsp_prop->addSubItem($cert_prop);
384 
385  // Enable 'Links'
386  $link_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_links'), 'link');
387  $link_prop->setValue('1');
388  $link_prop->setChecked(($ilSetting->get('disable_wsp_links') ? '0' : '1'));
389  $wsp_prop->addSubItem($link_prop);
390 
391  /*
392  // Enable 'Portfolios'
393  $lng->loadLanguageModule('user');
394  $prtf_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_prtf'), 'prtf');
395  $prtf_prop->setValue('1');
396  $prtf_prop->setInfo($lng->txt('user_portfolios_desc'));
397  $prtf_prop->setChecked(($ilSetting->get('user_portfolios') ? '1' : '0'));
398  $form->addItem($prtf_prop);
399  */
400 
401  // Load the disk quota settings object
402  require_once 'Services/WebDAV/classes/class.ilObjDiskQuotaSettings.php';
403  $disk_quota_obj = ilObjDiskQuotaSettings::getInstance();
404 
405  // Enable disk quota
406  $lng->loadLanguageModule("file");
407  $cb_prop = new ilCheckboxInputGUI($lng->txt("personal_workspace_disk_quota"), "enable_personal_workspace_disk_quota");
408  $cb_prop->setValue('1');
409  $cb_prop->setChecked($disk_quota_obj->isPersonalWorkspaceDiskQuotaEnabled());
410  $cb_prop->setInfo($lng->txt('enable_personal_workspace_disk_quota_info'));
411  $form->addItem($cb_prop);
412 
413  require_once 'Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php';
416  $form,
417  $this
418  );
419 
420  if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
421  // command buttons
422  $form->addCommandButton("saveWsp", $lng->txt("save"));
423  $form->addCommandButton("editWsp", $lng->txt("cancel"));
424  }
425 
426  $this->tpl->setContent($form->getHTML());
427  }
428 
432  public function saveWsp()
433  {
436  $ilAccess = $this->access;
437 
438  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
439  $ilCtrl->redirect($this, "view");
440  }
441 
442  // without personal workspace we have to disable to sub-items
443  if (!$_POST["wsp"]) {
444  $_POST["blog"] = 0;
445  $_POST["file"] = 0;
446  $_POST["cert"] = 0;
447  $_POST["link"] = 0;
448  }
449 
450  $ilSetting->set('disable_personal_workspace', (int) ($_POST['wsp'] ? 0 : 1));
451  $ilSetting->set('disable_wsp_blogs', (int) ($_POST['blog'] ? 0 : 1));
452  $ilSetting->set('disable_wsp_files', (int) ($_POST['file'] ? 0 : 1));
453  $ilSetting->set('disable_wsp_certificates', (int) ($_POST['cert'] ? 0 : 1));
454  $ilSetting->set('disable_wsp_links', (int) ($_POST['link'] ? 0 : 1));
455  // $ilSetting->set('user_portfolios', (int)($_POST['prtf'] ? 1 : 0));
456 
457  // Load the disk quota settings object
458  require_once 'Services/WebDAV/classes/class.ilObjDiskQuotaSettings.php';
459  $disk_quota_obj = ilObjDiskQuotaSettings::getInstance();
460  $disk_quota_obj->setPersonalWorkspaceDiskQuotaEnabled($_POST['enable_personal_workspace_disk_quota'] == '1');
461  $disk_quota_obj->update();
462 
463  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
464  $ilCtrl->redirect($this, "editWsp");
465  }
466 
467  public function addToExternalSettingsForm($a_form_id)
468  {
469  switch ($a_form_id) {
471 
472  require_once 'Services/WebDAV/classes/class.ilObjDiskQuotaSettings.php';
473  $disk_quota_obj = ilObjDiskQuotaSettings::getInstance();
474 
475  $fields = array('personal_workspace_disk_quota' => array($disk_quota_obj->isPersonalWorkspaceDiskQuotaEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
476 
477  return array(array("editWsp", $fields));
478  }
479  }
480 }
const PD_SYS_MSG_NO_BLOCK
This class represents an option in a radio group.
static _getInstance()
get singleton instance
settings()
Definition: settings.php:2
setHtml($a_html)
Set Html.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
__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
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a custom property in a property form.
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
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.