ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjPersonalWorkspaceSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
28 {
29  protected ilTabsGUI $tabs;
30  protected \ILIAS\DI\UIServices $ui;
31  protected ilSetting $setting;
33 
37  public function __construct(
38  $a_data,
39  int $a_id,
40  bool $a_call_by_reference = true,
41  bool $a_prepare_output = true
42  ) {
43  global $DIC;
44 
45  $this->lng = $DIC->language();
46  $this->rbacsystem = $DIC->rbac()->system();
47  $this->ctrl = $DIC->ctrl();
48  $this->request = $DIC->http()->request();
49  $this->tabs = $DIC->tabs();
50  $this->ui = $DIC->ui();
51  $this->setting = $DIC->settings();
52  $this->main_tpl = $DIC->ui()->mainTemplate();
53 
54  $this->type = 'prss';
55 
56  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
57 
58  $this->lng->loadLanguageModule("pwsp");
59  }
60 
65  public function executeCommand(): void
66  {
68  $tabs = $this->tabs;
69  $rbacsystem = $this->rbacsystem;
70 
71  $next_class = $ctrl->getNextClass($this);
72  $cmd = $ctrl->getCmd("editSettings");
73 
74  if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
75  throw new ilPermissionException($this->lng->txt('no_permission'));
76  }
77 
78  $this->prepareOutput();
79 
80  switch ($next_class) {
81  case 'ilpermissiongui':
82  $tabs->activateTab('perm_settings');
83  $perm_gui = new ilPermissionGUI($this);
84  $ctrl->forwardCommand($perm_gui);
85  break;
86 
87  default:
88  if ($cmd == "view") {
89  $cmd = "editSettings";
90  }
91  if (in_array($cmd, ["editSettings", "saveSettings"])) {
92  $this->$cmd();
93  }
94  break;
95  }
96  }
97 
98  public function getAdminTabs(): void
99  {
100  $rbacsystem = $this->rbacsystem;
101  $lng = $this->lng;
102  $tabs = $this->tabs;
103  $ctrl = $this->ctrl;
104 
105  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
106  $tabs->addTab(
107  "settings",
108  $lng->txt("settings"),
109  $ctrl->getLinkTarget($this, "editSettings")
110  );
111  }
112 
113  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
114  $tabs->addTab(
115  "perm_settings",
116  $lng->txt("perm_settings"),
117  $ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
118  );
119  }
120  }
121 
122  public function editSettings(): void
123  {
124  $form = $this->getSettingsForm();
125  $this->tpl->setContent($form->getHTML());
126  }
127 
129  {
130  $ilCtrl = $this->ctrl;
131  $lng = $this->lng;
133  $tabs = $this->tabs;
134 
135  $tabs->activateTab("settings");
136 
137  $form = new ilPropertyFormGUI();
138  $form->setFormAction($ilCtrl->getFormAction($this, "saveWsp"));
139  $form->setTitle($lng->txt("obj_prss"));
140 
141  // Enable 'Personal Workspace'
142  $wsp_prop = new ilCheckboxInputGUI($lng->txt('pwsp_enable_personal_resources'), 'wsp');
143  $wsp_prop->setValue('1');
144  $wsp_prop->setChecked(!$ilSetting->get('disable_personal_workspace'));
145  $form->addItem($wsp_prop);
146 
147  // Enable 'Blogs'
148  $blog_prop = new ilCheckboxInputGUI($lng->txt('pwsp_enable_wsp_blogs'), 'blog');
149  $blog_prop->setValue('1');
150  $blog_prop->setChecked(!$ilSetting->get('disable_wsp_blogs'));
151  $wsp_prop->addSubItem($blog_prop);
152 
153  // Enable 'Files'
154  $file_prop = new ilCheckboxInputGUI($lng->txt('pwsp_enable_wsp_files'), 'file');
155  $file_prop->setValue('1');
156  $file_prop->setChecked(!$ilSetting->get('disable_wsp_files'));
157  $wsp_prop->addSubItem($file_prop);
158 
159  // Enable 'Links'
160  $link_prop = new ilCheckboxInputGUI($lng->txt('pwsp_enable_wsp_links'), 'link');
161  $link_prop->setValue('1');
162  $link_prop->setChecked(!$ilSetting->get('disable_wsp_links'));
163  $wsp_prop->addSubItem($link_prop);
164 
165  if ($this->rbacsystem->checkAccess('write', $this->object->getRefId())) {
166  // command buttons
167  $form->addCommandButton("saveSettings", $lng->txt("save"));
168  $form->addCommandButton("editSettings", $lng->txt("cancel"));
169  }
170  return $form;
171  }
172 
173  public function saveSettings(): void
174  {
175  $ilCtrl = $this->ctrl;
177  $ilAccess = $this->access;
178 
179  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
180  $ilCtrl->redirect($this, "view");
181  }
182 
183  $form = $this->getSettingsForm();
184  if ($form->checkInput()) {
185  $wsp = $form->getInput("wsp");
186  $blog = $form->getInput("blog");
187  $file = $form->getInput("file");
188  $link = $form->getInput("link");
189 
190  // without personal workspace we have to disable to sub-items
191  if (!$wsp) {
192  $blog = 0;
193  $file = 0;
194  $link = 0;
195  }
196 
197  $ilSetting->set('disable_personal_workspace', (string) !$wsp);
198  $ilSetting->set('disable_wsp_blogs', (string) !$blog);
199  $ilSetting->set('disable_wsp_files', (string) !$file);
200  $ilSetting->set('disable_wsp_links', (string) !$link);
201  }
202 
203  $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
204  $ilCtrl->redirect($this, "editSettings");
205  }
206 }
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getCmd(string $fallback_command=null)
prepareOutput(bool $show_sub_objects=true)
This class represents a checkbox property in a property form.
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
forwardCommand(object $a_gui_object)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getNextClass($a_gui_class=null)
Class ilObjectGUI Basic methods of all Output classes.
activateTab(string $a_id)
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
global $ilSetting
Definition: privfeed.php:17
__construct(Container $dic, ilPlugin $plugin)
ilAccessHandler $access
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
ilSetting $settings
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.