ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjWebDAVGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
29 {
30  protected const SETTING_COMMANDS = [
31  'edit' => 'editSettings',
32  'save' => 'saveSettings'];
33 
34  protected ilWebDAVDIC $webdav_dic;
36 
37  public function __construct(?array $a_data, int $a_id, bool $a_call_by_reference)
38  {
39  global $DIC;
40  $this->webdav_dic = new ilWebDAVDIC();
41  $this->webdav_dic->init($DIC);
42 
43  $this->type = "wbdv";
44  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
45  }
46 
47  public function executeCommand(): void
48  {
49  $next_class = $this->ctrl->getNextClass($this);
50  $cmd = $this->ctrl->getCmd();
51 
52  $this->prepareOutput();
53 
54  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
55  $this->error_handling->raiseError(
56  $this->lng->txt('no_permission'),
57  $this->error_handling->MESSAGE
58  );
59  }
60 
61  switch ($next_class) {
62  case strtolower(ilWebDAVMountInstructionsUploadGUI::class):
63  $document_gui = $this->webdav_dic->mountinstructions_upload();
64  $document_gui->setRefId($this->object->getRefId());
65  $this->tabs_gui->activateTab('webdav_upload_instructions');
66  $this->ctrl->forwardCommand($document_gui);
67  break;
68 
69  default:
70  if (!$cmd || $cmd === 'view' || !in_array($cmd, self::SETTING_COMMANDS)) {
71  $cmd = self::SETTING_COMMANDS['edit'];
72  }
73  $this->$cmd();
74  break;
75  }
76  }
77 
78  public function getAdminTabs(): void
79  {
80  if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
81  $this->tabs_gui->addTab(
82  'webdav_general_settings',
83  $this->lng->txt("webdav_general_settings"),
84  $this->ctrl->getLinkTarget($this, self::SETTING_COMMANDS['edit'])
85  );
86  $this->tabs_gui->addTab(
87  'webdav_upload_instructions',
88  $this->lng->txt("webdav_upload_instructions"),
89  $this->ctrl->getLinkTargetByClass(ilWebDAVMountInstructionsUploadGUI::class)
90  );
91  }
92  }
93 
94  public function setTitleAndDescription(): void
95  {
96  parent::setTitleAndDescription();
97  $this->tpl->setDescription($this->object->getDescription());
98  }
99 
100 
101  protected function initSettingsForm(): ilPropertyFormGUI
102  {
103  $form = new ilPropertyFormGUI();
104  $form->setFormAction($this->ctrl->getFormAction($this));
105  $form->setTitle($this->lng->txt("settings"));
106 
107  $cb_prop = new ilCheckboxInputGUI($this->lng->txt("enable_webdav"), "enable_webdav");
108  $cb_prop->setValue('1');
109  $cb_prop->setChecked($this->object->isWebdavEnabled());
110  $form->addItem($cb_prop);
111 
112  $cb_prop = new ilCheckboxInputGUI($this->lng->txt("webdav_enable_versioning"), "enable_versioning_webdav");
113  $cb_prop->setValue('1');
114  $cb_prop->setInfo($this->lng->txt("webdav_versioning_info"));
115  $cb_prop->setChecked($this->object->isWebdavVersioningEnabled());
116  $form->addItem($cb_prop);
117 
118  $form->addCommandButton(self::SETTING_COMMANDS['save'], $this->lng->txt('save'));
119 
120  return $form;
121  }
122 
123  public function editSettings(): void
124  {
125  $this->tabs_gui->activateTab('webdav_general_settings');
126 
127  if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
128  $this->error_handling->raiseError(
129  $this->lng->txt("no_permission"),
130  $this->error_handling->WARNING
131  );
132  }
133 
134  $form = $this->initSettingsForm();
135 
136  $this->tpl->setContent($form->getHTML());
137  }
138 
139  public function saveSettings(): void
140  {
141  if (!$this->rbac_system->checkAccess("write", $this->object->getRefId())) {
142  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'), true);
143  $this->ctrl->redirect($this, self::SETTING_COMMANDS['edit']);
144  }
145 
146  $form = $this->initSettingsForm();
147  if ($form->checkInput()) {
148  $this->object->setWebdavEnabled(($form->getInput('enable_webdav') === '1'));
149  $this->object->setWebdavVersioningEnabled(($form->getInput('enable_versioning_webdav') === '1'));
150  $this->object->update();
151  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
152  $this->ctrl->redirect($this, self::SETTING_COMMANDS['edit']);
153  } else {
154  $form->setValuesByPost();
155  $this->tpl->setContent($form->getHTML());
156  }
157  }
158 }
ilErrorHandling $error_handling
const ilWebDAVDIC $webdav_dic
prepareOutput(bool $show_sub_objects=true)
This class represents a checkbox property in a property form.
global $DIC
Definition: feed.php:28
Class ilObjectGUI Basic methods of all Output classes.
Error Handling & global info handling uses PEAR error class.
__construct(Container $dic, ilPlugin $plugin)
__construct(?array $a_data, int $a_id, bool $a_call_by_reference)