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