ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjWebDAVGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 {
30  protected const SETTING_COMMANDS = [
31  'edit' => 'editSettings',
32  'save' => 'saveSettings'
33  ];
34 
35  protected ilWebDAVDIC $webdav_dic;
37 
38  public function __construct(?array $a_data, int $a_id, bool $a_call_by_reference)
39  {
40  global $DIC;
41  $this->webdav_dic = new ilWebDAVDIC();
42  $this->webdav_dic->init($DIC);
43 
44  $this->type = "wbdv";
45  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
46  }
47 
48  public function executeCommand(): void
49  {
50  $next_class = $this->ctrl->getNextClass($this);
51  $cmd = $this->ctrl->getCmd();
52 
53  $this->prepareOutput();
54 
55  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
56  $this->error_handling->raiseError(
57  $this->lng->txt('no_permission'),
58  $this->error_handling->MESSAGE
59  );
60  }
61 
62  switch ($next_class) {
63  case strtolower(ilWebDAVMountInstructionsUploadGUI::class):
64  $document_gui = $this->webdav_dic->mountinstructions_upload();
65  $document_gui->setRefId($this->object->getRefId());
66  $this->tabs_gui->activateTab('webdav_upload_instructions');
67  $this->ctrl->forwardCommand($document_gui);
68  break;
69 
70  default:
71  if (!$cmd || $cmd === 'view' || !in_array($cmd, self::SETTING_COMMANDS)) {
72  $cmd = self::SETTING_COMMANDS['edit'];
73  }
74  $this->$cmd();
75  break;
76  }
77  }
78 
79  public function getAdminTabs(): void
80  {
81  if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
82  $this->tabs_gui->addTab(
83  'webdav_general_settings',
84  $this->lng->txt("webdav_general_settings"),
85  $this->ctrl->getLinkTarget($this, self::SETTING_COMMANDS['edit'])
86  );
87  $this->tabs_gui->addTab(
88  'webdav_upload_instructions',
89  $this->lng->txt("webdav_upload_instructions"),
90  $this->ctrl->getLinkTargetByClass(ilWebDAVMountInstructionsUploadGUI::class)
91  );
92  }
93  }
94 
95  public function setTitleAndDescription(): void
96  {
97  parent::setTitleAndDescription();
98  $this->tpl->setDescription($this->object->getDescription());
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)
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
Class ilObjectGUI Basic methods of all Output classes.
Error Handling & global info handling.
__construct(?array $a_data, int $a_id, bool $a_call_by_reference)