ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjWorkspaceFolderGUI.php
Go to the documentation of this file.
1<?php
2
23
33{
34 protected \ILIAS\Repository\ExternalGUIService $repo_gui_service;
35 protected ilHelpGUI $help;
36 protected ilTabsGUI $tabs;
37 protected \ILIAS\DI\UIServices $ui;
39 protected int $requested_sortation;
40 protected ilLogger $wsp_log;
43
44 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
45 {
46 global $DIC;
47 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
48
49 $this->lng = $DIC->language();
50 $this->lng->loadLanguageModule("pwsp");
51 $this->help = $DIC["ilHelp"];
52 $this->tpl = $DIC->ui()->mainTemplate();
53 $this->user = $DIC->user();
54 $this->tabs = $DIC->tabs();
55 $this->ctrl = $DIC->ctrl();
56 $this->ui = $DIC->ui();
57 $this->session_repo = new WorkspaceSessionRepository();
58 $this->repo_gui_service = $DIC->repository()->gui();
59
60 $this->std_request = new StandardGUIRequest(
61 $DIC->http(),
62 $DIC->refinery()
63 );
64
65 $this->wsp_log = ilLoggerFactory::getLogger("pwsp");
66
67 $this->user_folder_settings = new ilWorkspaceFolderUserSettings(
68 $this->user->getId(),
70 );
71
72 $this->requested_sortation = $this->std_request->getSortation();
73
74 $this->lng->loadLanguageModule("cntr");
75 }
76
77 public function getType(): string
78 {
79 return "wfld";
80 }
81
82 protected function setTabs(bool $a_show_settings = true): void
83 {
85 $ilHelp = $this->help;
86
87 $ilHelp->setScreenIdComponent("wfld");
88
89 $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
90
91 $this->tabs_gui->addTab(
92 "wsp",
93 $lng->txt("wsp_tab_personal"),
94 $this->ctrl->getLinkTarget($this, "")
95 );
96
97 $this->ctrl->setParameterByClass(
98 "ilObjWorkspaceRootFolderGUI",
99 "wsp_id",
100 $this->getAccessHandler()->getTree()->getRootId()
101 );
102
103 $this->tabs_gui->addTab(
104 "share",
105 $lng->txt("wsp_tab_shared"),
106 $this->ctrl->getLinkTargetByClass("ilObjWorkspaceRootFolderGUI", "shareFilter")
107 );
108
109 $this->tabs_gui->addTab(
110 "ownership",
111 $lng->txt("wsp_tab_ownership"),
112 $this->ctrl->getLinkTargetByClass(array("ilObjWorkspaceRootFolderGUI", "ilObjectOwnershipManagementGUI"), "listObjects")
113 );
114
115 if (!$this->ctrl->getNextClass($this)) {
116 if (stristr($this->ctrl->getCmd(), "share")) {
117 $this->tabs_gui->activateTab("share");
118 } else {
119 $this->tabs_gui->activateTab("wsp");
120 $this->addContentSubTabs($a_show_settings);
121 }
122 }
123 }
124
125 public function isActiveAdministrationPanel(): bool
126 {
127 return (bool) ilSession::get("il_wsp_admin_panel");
128 }
129
130 public function setAdministrationPanel(bool $active): void
131 {
132 ilSession::set("il_wsp_admin_panel", $active);
133 }
134
135 protected function addContentSubTabs(bool $a_show_settings): void
136 {
140
141 if ($this->checkPermissionBool("read")) {
142 $tabs->addSubTab("content", $lng->txt("view"), $ctrl->getLinkTarget($this, "disableAdminPanel"));
143 $tabs->addSubTab("manage", $lng->txt("cntr_manage"), $ctrl->getLinkTarget($this, "enableAdminPanel"));
144 }
145
146 if ($this->checkPermissionBool("write") && $a_show_settings) {
147 $this->tabs_gui->addSubTab(
148 "settings",
149 $lng->txt("settings"),
150 $this->ctrl->getLinkTarget($this, "edit")
151 );
152 }
153
154 if ($this->isActiveAdministrationPanel()) {
155 $tabs->activateSubTab("manage");
156 } else {
157 $tabs->activateSubTab("content");
158 }
159 }
160
161 protected function enableAdminPanel(): void
162 {
163 $this->setAdministrationPanel(true);
164 $this->ctrl->redirect($this, "");
165 }
166
167 protected function disableAdminPanel(): void
168 {
169 $this->setAdministrationPanel(false);
170 $this->ctrl->redirect($this, "");
171 }
172
173 public function executeCommand(): void
174 {
175 $next_class = $this->ctrl->getNextClass($this);
176 $cmd = $this->ctrl->getCmd();
177
178 switch ($next_class) {
179 case "ilcommonactiondispatchergui":
181 $this->ctrl->forwardCommand($gui);
182 break;
183
184 case "ilobjectownershipmanagementgui":
185 $this->prepareOutput();
186 $this->tabs_gui->activateTab("ownership");
187 $gui = $this->repo_gui_service->ownershipManagementGUI();
188 $this->ctrl->forwardCommand($gui);
189 break;
190
191 default:
192 $this->prepareOutput();
193 if ($this->type != "wsrt") {
194 $this->addHeaderAction();
195 }
196 if (!$cmd) {
197 $cmd = "render";
198 }
199 $this->$cmd();
200 break;
201 }
202 }
203
204 public function render(): void
205 {
207 $ilUser = $this->user;
208 $ilCtrl = $this->ctrl;
209
210 //$this->addContentSubTabs();
212
213 $this->session_repo->clearClipboard();
214
215 // add new item
218 );
219 $gui->render();
220
222 "",
223 "",
224 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
225 );
226
227 $gui = new ilWorkspaceContentGUI(
228 $this,
229 $this->node_id,
231 $this->getAccessHandler(),
232 $this->ui,
233 $this->lng,
234 $this->user,
235 $this->obj_definition,
236 $this->ctrl,
237 $this->user_folder_settings
238 );
239 $tpl->setContent($gui->render());
240
241 $exp = new ilWorkspaceExplorerGUI($ilUser->getId(), $this, "render", $this, "", "wsp_id");
242 $exp->setTypeWhiteList(array("wsrt", "wfld"));
243 $exp->setSelectableTypes(array("wsrt", "wfld"));
244 $exp->setLinkToNodeClass(true);
245 $exp->setActivateHighlighting(true);
246 if ($exp->handleCommand()) {
247 return;
248 }
249 $left = $exp->getHTML();
250
251 $tpl->setLeftNavContent($left);
252 }
253
254 public function edit(): void
255 {
256 parent::edit();
257
258 $this->tabs_gui->activateTab("wsp");
259 $this->tabs_gui->activateSubTab("settings");
260 }
261
262 public function update(): void
263 {
264 parent::update();
265
266 $this->tabs_gui->activateTab("wsp");
267 $this->tabs_gui->activateSubTab("settings");
268 }
269
270 public function cut(): void
271 {
272 $item_ids = $this->std_request->getItemIds();
273 if (count($item_ids) == 0) {
274 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
275 $this->ctrl->redirect($this);
276 }
277
278 // check permission
279 $no_cut = array();
280 $repo_switch_allowed = true;
281 foreach ($item_ids as $item_id) {
282 foreach ($this->tree->getSubTree($this->tree->getNodeData($item_id)) as $node) {
283 if (ilObject::_lookupType($node["obj_id"]) != "file") {
284 $repo_switch_allowed = false;
285 }
286 if (!$this->checkPermissionBool("delete", "", "", $node["wsp_id"])) {
287 $obj = ilObjectFactory::getInstanceByObjId($node["obj_id"]);
288 $no_cut[$node["wsp_id"]] = $obj->getTitle();
289 unset($obj);
290 }
291 }
292 }
293 if (count($no_cut)) {
294 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_perm_cut") . " " . implode(',', $no_cut), true);
295 $this->ctrl->redirect($this);
296 }
297
298 // remember source node
299 $this->session_repo->setClipboardSourceIds($item_ids);
300 $this->session_repo->setClipboardCmd('cut');
301
302 $this->showMoveIntoObjectTree($repo_switch_allowed);
303 }
304
305 public function cut_for_repository(): void
306 {
307 $this->session_repo->setClipboardWsp2Repo(true);
308 $this->cut();
309 }
310
311 public function cut_for_workspace(): void
312 {
313 $this->session_repo->setClipboardWsp2Repo(false);
314 $this->cut();
315 }
316
317 public function copy(): void
318 {
319 $ilUser = $this->user;
320
321 $item_ids = $this->std_request->getItemIds();
322 if (count($item_ids) == 0) {
323 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
324 $this->ctrl->redirect($this);
325 }
326
327 // on cancel or fail we return to parent node
328 $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
329
330 $repo_switch_allowed = true;
331 foreach ($item_ids as $item_id) {
332 $node = $this->tree->getNodeData($item_id);
333 if (ilObject::_lookupType($node["obj_id"]) != "file") {
334 $repo_switch_allowed = false;
335 }
336 $current_node = $item_id;
337 $owner = $this->tree->lookupOwner($current_node);
338 if ($owner != $ilUser->getId()) {
339 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
340 $this->ctrl->redirect($this);
341 }
342 if (!$this->obj_definition->allowCopy($node["type"])) {
343 $this->tpl->setOnScreenMessage(
344 'failure',
345 str_replace(
346 "%s",
347 $this->lng->txt("obj_" . $node["type"]),
348 $this->lng->txt("pwsp_type_cannot_be_copied")
349 ),
350 true
351 );
352 $this->ctrl->redirect($this);
353 }
354 }
355
356 // remember source node
357 $this->session_repo->setClipboardSourceIds($item_ids);
358 $this->session_repo->setClipboardCmd('copy');
359
360 $this->showMoveIntoObjectTree($repo_switch_allowed);
361 }
362
363 public function copyShared(): void
364 {
365 $ids = $this->std_request->getItemIds();
366 if (count($ids) != 1) {
367 $this->ctrl->redirect($this, "share");
368 }
369
370 $current_node = current($ids);
371 $handler = $this->getAccessHandler();
372 // see ilSharedRessourceGUI::hasAccess()
373 if ($handler->checkAccess("read", "", $current_node)) {
374 // remember source node
375 $this->session_repo->setClipboardSourceIds([$current_node]);
376 $this->session_repo->setClipboardCmd('copy');
377 $this->session_repo->setClipboardShared(true);
378 $this->showMoveIntoObjectTree();
379 return;
380 } else {
381 $perms = $handler->getPermissions($current_node);
382 if (in_array(ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, $perms)) {
383 $this->passwordForm($current_node);
384 return;
385 }
386 }
387
388 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
389 $this->ctrl->redirect($this, "share");
390 }
391
392 public function copy_to_repository(): void
393 {
394 $this->session_repo->setClipboardWsp2Repo(true);
395 $this->copy();
396 }
397
398 public function copy_to_workspace(): void
399 {
400 $this->session_repo->setClipboardWsp2Repo(false);
401 $this->copy();
402 }
403
404 public function showMoveIntoObjectTree(bool $repo_switch_allowed = false): void
405 {
406 $ilTabs = $this->tabs;
408
409 $ilTabs->clearTargets();
410
411 if (!$this->session_repo->getClipboardShared()) {
412 $ilTabs->setBackTarget(
413 $this->lng->txt('back'),
414 $this->ctrl->getLinkTarget($this)
415 );
416 } else {
417 $ilTabs->setBackTarget(
418 $this->lng->txt('back'),
419 $this->ctrl->getLinkTarget($this, 'share')
420 );
421 }
422
423 $mode = $this->session_repo->getClipboardCmd();
424
425 $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_' . $mode . '_clipboard'));
426
427 $this->tpl->addBlockFile(
428 'ADM_CONTENT',
429 'adm_content',
430 'tpl.paste_into_multiple_objects.html',
431 "components/ILIAS/WorkspaceFolder"
432 );
433
434 // move/copy in personal workspace
435 if (!$this->session_repo->getClipboardWsp2Repo()) {
436 $exp = new ilWorkspaceExplorerGUI($this->user->getId(), $this, "showMoveIntoObjectTree", $this, "");
437 $exp->setTypeWhiteList(array("wsrt", "wfld"));
438 $exp->setSelectableTypes(array("wsrt", "wfld"));
439 $exp->setSelectMode("node", false);
440 if ($exp->handleCommand()) {
441 return;
442 }
443 $this->tpl->setVariable('OBJECT_TREE', $exp->getHTML());
444
445 // switch to repo?
446 if ($repo_switch_allowed) {
447 $switch_cmd = ($mode == "cut")
448 ? "cut_for_repository"
449 : "copy_to_repository";
450 $this->tpl->setCurrentBlock("switch_button");
451 $this->tpl->setVariable('CMD_SWITCH', $switch_cmd);
452 $this->tpl->setVariable('TXT_SWITCH', $this->lng->txt('wsp_switch_to_repo_tree'));
453 $this->tpl->parseCurrentBlock();
454
455 foreach ($this->std_request->getItemIds() as $id) {
456 $this->tpl->setCurrentBlock("hidden");
457 $this->tpl->setVariable('VALUE', (string) $id);
458 $this->tpl->parseCurrentBlock();
459 }
460 }
461 }
462 // move/copy to repository
463 else {
466 '',
467 'paste_' . $mode . '_repexpand'
468 );
469 $exp->setTargetGet('ref_id');
470
471 if ($this->std_request->getPasteExpand($mode) == '') {
472 $expanded = $tree->readRootId();
473 } else {
474 $expanded = $this->std_request->getPasteExpand($mode);
475 }
476 $exp->setCheckedItems(array($this->std_request->getNode()));
477 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showMoveIntoObjectTree'));
478 $exp->setPostVar('node');
479 $exp->setExpand($expanded);
480 $exp->setOutput(0);
481 $this->tpl->setVariable('OBJECT_TREE', $exp->getOutput());
482
483 if (in_array($mode, ["copy", "cut"])) {
484 $switch_cmd = ($mode == "cut")
485 ? "cut_for_workspace"
486 : "copy_to_workspace";
487 $this->tpl->setCurrentBlock("switch_button");
488 $this->tpl->setVariable('CMD_SWITCH', $switch_cmd);
489 $this->tpl->setVariable('TXT_SWITCH', $this->lng->txt('wsp_switch_to_wsp_tree'));
490 $this->tpl->parseCurrentBlock();
491
492 foreach ($this->std_request->getItemIds() as $id) {
493 $this->tpl->setCurrentBlock("hidden");
494 $this->tpl->setVariable('VALUE', (string) $id);
495 $this->tpl->parseCurrentBlock();
496 }
497 }
498 }
499
500
501 unset($exp);
502
503 $this->tpl->setVariable('FORM_TARGET', '_top');
504 $this->tpl->setVariable(
505 'FORM_ACTION',
506 $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects')
507 );
508
509 $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
510 $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
511 }
512
513 public function performPasteIntoMultipleObjects(): void
514 {
515 $ilUser = $this->user;
516 $owner = 0;
517 $mode = $this->session_repo->getClipboardCmd();
518 $source_node_ids = $this->session_repo->getClipboardSourceIds();
519 $target_node_id = $this->std_request->getNode();
520
521 if (!is_array($source_node_ids) || count($source_node_ids) == 0) {
522 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_at_least_one_object'), true);
523 $this->ctrl->redirect($this);
524 }
525 if (!$target_node_id) {
526 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_at_least_one_object'), true);
527 $this->ctrl->redirect($this, "showMoveIntoObjectTree");
528 }
529
530 if (!$this->session_repo->getClipboardWsp2Repo()) {
531 $target_obj_id = $this->tree->lookupObjectId($target_node_id);
532 } else {
533 $target_obj_id = ilObject::_lookupObjId($target_node_id);
534 }
535 $target_object = ilObjectFactory::getInstanceByObjId($target_obj_id);
536
537 $fail = array();
538 foreach ($source_node_ids as $source_node_id) {
539 // object instances
540 $source_obj_id = $this->tree->lookupObjectId($source_node_id);
541 $source_object = ilObjectFactory::getInstanceByObjId($source_obj_id);
542
543
544 // sanity checks
545 if ($source_node_id == $target_node_id) {
546 $fail[] = sprintf(
547 $this->lng->txt('msg_obj_exists_in_folder'),
548 $source_object->getTitle(),
549 $target_object->getTitle()
550 );
551 }
552
553 if (!in_array($source_object->getType(), array_keys($target_object->getPossibleSubObjects()))) {
554 $fail[] = sprintf(
555 $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
556 $target_object->getTitle(),
557 $source_object->getType()
558 );
559 }
560
561 // if object is shared permission to copy has been checked above
562 $owner = $this->tree->lookupOwner($source_node_id);
563 if ($mode == "copy" && $ilUser->getId() == $owner && !$this->checkPermissionBool('copy', '', '', $source_node_id)) {
564 $fail[] = $this->lng->txt('permission_denied');
565 }
566
567 if (!$this->session_repo->getClipboardWsp2Repo()) {
568 if ($mode == "cut" && $this->tree->isGrandChild($source_node_id, $target_node_id)) {
569 $fail[] = sprintf(
570 $this->lng->txt('msg_paste_object_not_in_itself'),
571 $source_object->getTitle()
572 );
573 }
574 }
575
576 if ($this->session_repo->getClipboardWsp2Repo() == true) { // see #22959
577 global $ilAccess;
578 if (!$ilAccess->checkAccess("create", "", $target_node_id, $source_object->getType())) {
579 $fail[] = sprintf(
580 $this->lng->txt('msg_no_perm_paste_object_in_folder'),
581 $source_object->getTitle(),
582 $target_object->getTitle()
583 );
584 }
585 } else {
586 if (!$this->checkPermissionBool('create', '', $source_object->getType(), $target_node_id)) {
587 $fail[] = sprintf(
588 $this->lng->txt('msg_no_perm_paste_object_in_folder'),
589 $source_object->getTitle(),
590 $target_object->getTitle()
591 );
592 }
593 }
594 }
595
596 if (sizeof($fail)) {
597 $this->tpl->setOnScreenMessage('failure', implode("<br />", $fail), true);
598 $this->ctrl->redirect($this);
599 }
600
601 foreach ($source_node_ids as $source_node_id) {
602 $source_tree = $this->tree;
603 if ($ilUser->getId() != $owner && $mode == "copy") {
604 $source_tree = new ilWorkspaceTree($owner);
605 }
606 $node_data = $source_tree->getNodeData($source_node_id);
607 $source_object = ilObjectFactory::getInstanceByObjId($node_data["obj_id"]);
608
609 // move the node
610 if ($mode == "cut") {
611 if (!$this->session_repo->getClipboardWsp2Repo()) {
612 $this->tree->moveTree($source_node_id, $target_node_id);
613 } else {
614 $parent_id = $this->tree->getParentId($source_node_id);
615
616 // remove from personal workspace
617 $this->getAccessHandler()->removePermission($source_node_id);
618 $this->tree->deleteReference($source_node_id);
619 $source_node = $this->tree->getNodeData($source_node_id);
620 $this->tree->deleteTree($source_node);
621
622 // add to repository
623 $source_object->createReference();
624 $source_object->putInTree($target_node_id);
625 $source_object->setPermissions($target_node_id);
626
627 $source_node_id = $parent_id;
628 }
629 } // copy the node
630 elseif ($mode == "copy") {
632 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
633 $this->wsp_log->debug("Copy ID: " . $copy_id . ", Source Node: " . $source_node_id
634 . ", source object: " . $source_object->getId());
635 if (!$this->session_repo->getClipboardWsp2Repo()) {
636 $wizard_options->disableTreeCopy();
637 }
638 $wizard_options->saveOwner($ilUser->getId());
639 $wizard_options->saveRoot($source_node_id);
640 $wizard_options->read();
641
642 $new_obj = $source_object->cloneObject($target_node_id, $copy_id);
643 // insert into workspace tree
644 if ($new_obj && !$this->session_repo->getClipboardWsp2Repo()) {
645 $this->wsp_log->debug("New Obj ID: " . $new_obj->getId());
646 $new_obj_node_id = $this->tree->insertObject($target_node_id, $new_obj->getId());
647 $this->getAccessHandler()->setPermissions($target_node_id, $new_obj_node_id);
648 }
649
650 $wizard_options->deleteAll();
651 }
652 }
653
654 // redirect to target if not repository
655 if (!$this->session_repo->getClipboardWsp2Repo()) {
656 //$redirect_node = $target_node_id;
657 $redirect_node = $this->node_id; // see bug 34459
658 } else {
659 // reload current folder
660 $redirect_node = $this->node_id;
661 }
662
663 $this->session_repo->clearClipboard();
664
665 // #17746
666 if ($mode == 'cut') {
667 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_cut_copied'), true);
668 } else {
669 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_cloned'), true);
670 }
671
672 $this->ctrl->setParameter($this, "wsp_id", $redirect_node);
673 $this->ctrl->redirect($this);
674 }
675
676 public function shareFilter(): void
677 {
678 $this->share(false);
679 }
680
681 public function share(bool $a_load_data = true): void
682 {
684
685 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id, $a_load_data);
686 $tpl->setContent($tbl->getHTML());
687 }
688
689 public function applyShareFilter(): void
690 {
691 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
692 $tbl->resetOffset();
693 $tbl->writeFilterToSession();
694
695 $this->share();
696 }
697
698 public function resetShareFilter(): void
699 {
700 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
701 $tbl->resetOffset();
702 $tbl->resetFilter();
703
704 $this->shareFilter();
705 }
706
707 protected function passwordForm(int $a_node_id, ?ilPropertyFormGUI $form = null): void
708 {
711 $ilTabs = $this->tabs;
712
713 $tpl->setTitle($lng->txt("wsp_password_protected_resource"));
714 $tpl->setDescription($lng->txt("wsp_password_protected_resource_info"));
715
716 $ilTabs->clearTargets();
717 $ilTabs->setBackTarget(
718 $lng->txt("back"),
719 $this->ctrl->getLinkTarget($this, "share")
720 );
721
722 if (!$form) {
723 $form = $this->initPasswordForm($a_node_id);
724 }
725
726 $tpl->setContent($form->getHTML());
727 }
728
729 protected function initPasswordForm(int $a_node_id): ilPropertyFormGUI
730 {
731 $ilCtrl = $this->ctrl;
733
734 $this->ctrl->setParameter($this, "item_ref_id", $a_node_id);
735
736 $object_data = $this->getAccessHandler()->getObjectDataFromNode($a_node_id);
737
738 $form = new ilPropertyFormGUI();
739 $form->setFormAction($ilCtrl->getFormAction($this, "checkPassword"));
740 $form->setTitle($lng->txt("wsp_password_for") . ": " . $object_data["title"]);
741
742 $password = new ilPasswordInputGUI($lng->txt("password"), "password");
743 $password->setRetype(false);
744 $password->setRequired(true);
745 $password->setSkipSyntaxCheck(true);
746 $form->addItem($password);
747
748 $form->addCommandButton("checkPassword", $lng->txt("submit"));
749 $form->addCommandButton("share", $lng->txt("cancel"));
750
751 return $form;
752 }
753
754 protected function checkPassword(): void
755 {
757
758 $ids = $this->std_request->getItemIds();
759 if (count($ids) != 1) {
760 $this->ctrl->redirect($this, "share");
761 }
762 $node_id = current($ids);
763
764 $form = $this->initPasswordForm($node_id);
765 if ($form->checkInput()) {
767 $input = md5($form->getInput("password"));
768 if ($input == $password) {
769 // we save password and start over
771
772 $this->ctrl->setParameter($this, "item_ref_id", $node_id);
773 $this->ctrl->redirect($this, "copyShared");
774 } else {
775 $item = $form->getItemByPostVar("password");
776 $item->setAlert($lng->txt("wsp_invalid_password"));
777 $this->tpl->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
778 }
779 }
780
781 $form->setValuesByPost();
782 $this->passwordForm($node_id, $form);
783 }
784
785 public static function _goto(string $a_target): void
786 {
787 global $DIC;
788 $ctrl = $DIC->ctrl();
789 $id = explode("_", $a_target);
791 "ilsharedresourceGUI",
792 "wsp_id",
793 $id[0]
794 );
795 $ctrl->redirectByClass("ilsharedresourceGUI");
796 }
797
798 public function listSharedResourcesOfOtherUser(): void
799 {
800 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
801 $tbl->resetOffset();
802 $tbl->resetFilter();
803 $tbl->writeFilterToSession();
804 $this->share();
805 }
806
807 protected function deleteConfirmation(): void
808 {
809 global $DIC;
810
811 $tpl = $DIC["tpl"];
812 $lng = $DIC["lng"];
813
814 $item_ids = $this->std_request->getItemIds();
815
816 if (count($item_ids) == 0) {
817 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
818 $this->ctrl->redirect($this, "");
819 }
820
821 // on cancel or fail we return to parent node
822 //$parent_node = $this->tree->getParentId($node_id);
823 //$this->ctrl->setParameter($this, "wsp_id", $parent_node);
824
825 $cgui = new ilConfirmationGUI();
826 $cgui->setHeaderText($lng->txt("info_delete_sure") . "<br/>" .
827 $lng->txt("info_delete_warning_no_trash"));
828
829 $cgui->setFormAction($this->ctrl->getFormAction($this));
830 $cgui->setCancel($lng->txt("cancel"), "cancelDeletion");
831 $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
832
833 foreach ($item_ids as $node_id) {
834 $children = $this->tree->getSubTree($this->tree->getNodeData($node_id));
835 foreach ($children as $child) {
836 $node_id = $child["wsp_id"];
837 $obj_id = $this->tree->lookupObjectId($node_id);
839 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id);
840
841 // if anything fails, abort the whole process
842 if (!$this->checkPermissionBool("delete", "", "", $node_id)) {
843 $this->tpl->setOnScreenMessage('failure', $lng->txt("msg_no_perm_delete") . " " . $title, true);
844 $this->ctrl->redirect($this);
845 }
846
847 $cgui->addItem(
848 "id[]",
849 $node_id,
850 $title,
852 $lng->txt("icon") . " " . $lng->txt("obj_" . $type)
853 );
854 }
855 }
856
857 $tpl->setContent($cgui->getHTML());
858 }
859
860 public function cancelDeletion()
861 {
862 $this->session_repo->clearClipboard();
863 parent::cancelDelete();
864 }
865
866
867 //
868 // admin panel
869 //
870
871 public function showAdministrationPanel(): void
872 {
873 global $DIC;
874
876
877 $main_tpl = $DIC->ui()->mainTemplate();
878
879 $lng->loadLanguageModule('cntr');
880
881 if (!$this->session_repo->isClipboardEmpty()) {
882 // #11545
883 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
884
885 $toolbar = new ilToolbarGUI();
886 $this->ctrl->setParameter($this, "type", "");
887 $this->ctrl->setParameter($this, "item_ref_id", "");
888
890 $this->lng->txt('paste_clipboard_items'),
891 'paste'
892 );
893
895 $this->lng->txt('clear_clipboard'),
896 'clear'
897 );
898
899 $main_tpl->addAdminPanelToolbar($toolbar, true, false);
900 } elseif ($this->isActiveAdministrationPanel()) {
901 // #11545
902 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
903
904 $toolbar = new ilToolbarGUI();
905 $this->ctrl->setParameter($this, "type", "");
906 $this->ctrl->setParameter($this, "item_ref_id", "");
907
908 if ($this->object->gotItems($this->node_id)) {
910 ilUtil::getImagePath("nav/arrow_upright.svg"),
911 $lng->txt("actions")
912 );
914 $this->lng->txt('delete_selected_items'),
915 'delete'
916 );
918 $this->lng->txt('move_selected_items'),
919 'cut'
920 );
922 $this->lng->txt('copy_selected_items'),
923 'copy'
924 );
926 $this->lng->txt('download_selected_items'),
927 'download'
928 );
929 // add download button if multi download enabled
930 }
931
932 $main_tpl->addAdminPanelToolbar(
933 $toolbar,
934 $this->object->gotItems($this->node_id) && $this->session_repo->isClipboardEmpty(),
935 ($this->object->gotItems($this->node_id) && $this->session_repo->isClipboardEmpty())
936 );
937
938 // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
939 if ($this->object->gotItems($this->node_id)) {
940 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
941 }
942 }
943 }
944
945
949 protected function setSortation(): void
950 {
951 $this->user_folder_settings->updateSortation($this->object->getId(), $this->requested_sortation);
952 $this->ctrl->redirect($this, "");
953 }
954
955 public function download(): void
956 {
957 // This variable determines whether the task has been initiated by a folder's action drop-down to prevent a folder
958 // duplicate inside the zip.
959 $initiated_by_folder_action = false;
960
961 $ids = $this->std_request->getItemIds();
962
963 if (count($ids) == 0) {
964 $this->ctrl->redirect($this, "");
965 }
966
967 $download_job = new ilDownloadWorkspaceFolderBackgroundTask($GLOBALS['DIC']->user()->getId(), $ids, $initiated_by_folder_action);
968
969 $download_job->setBucketTitle($this->getBucketTitle());
970 if ($download_job->run()) {
971 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_bt_download_started'), true);
972 }
973 $this->ctrl->redirect($this);
974 }
975
976 public function getBucketTitle(): string
977 {
978 $title = ilFileUtils::getASCIIFilename($this->object->getTitle());
979 if ($title === '') { // $this->>object->getTitle() is empty in root of personal and shared resources
980 $title = $this->lng->txt('personal_resources');
981 }
982 return $title;
983 }
984
985 protected function buildAvailableObjectTypes(): array
986 {
987 $settings_map = [
988 'blog' => 'blogs',
989 'file' => 'files',
990 'webr' => 'links',
991 ];
992
993 $object_types = $this->obj_definition->getCreatableSubObjects("wfld", ilObjectDefinition::MODE_WORKSPACE);
994 $filtered_object_types = [];
995 foreach (array_keys($object_types) as $type) {
996 if (isset($settings_map[$type])
997 && $this->settings->get("disable_wsp_" . $settings_map[$type])) {
998 continue;
999 }
1000
1001 $filtered_object_types[] = $this->buildObjectType($type);
1002 }
1003
1004 return $filtered_object_types;
1005 }
1006
1007 protected function buildObjectType(string $type): AddNewItemElement
1008 {
1009 $icon = $this->ui_factory->symbol()->icon()->custom(
1010 \ilObject::_getIcon(0, 'tiny', $type),
1011 ''
1012 );
1013
1014 $this->ctrl->setParameterByClass(self::class, 'new_type', $type);
1015 $element = new AddNewItemElement(
1016 AddNewItemElementTypes::Object,
1017 $this->lng->txt('wsp_type_' . $type),
1018 $icon,
1019 new \ILIAS\Data\URI(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(self::class, 'create'))
1020 );
1021 $this->ctrl->clearParameterByClass(self::class, 'new_type', $type);
1022 return $element;
1023 }
1024}
Render add new item selector.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance(int $a_copy_id)
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static getASCIIFilename(string $a_filename)
Help GUI class.
setScreenIdComponent(string $a_comp)
loadLanguageModule(string $a_module)
Load language module.
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...
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
Class ilObjWorkspaceFolderGUI.
getType()
Functions that must be overwritten.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
setTabs(bool $a_show_settings=true)
ilWorkspaceFolderUserSettings $user_folder_settings
showMoveIntoObjectTree(bool $repo_switch_allowed=false)
ILIAS Repository ExternalGUIService $repo_gui_service
WorkspaceSessionRepository $session_repo
addContentSubTabs(bool $a_show_settings)
passwordForm(int $a_node_id, ?ilPropertyFormGUI $form=null)
New implementation of ilObjectGUI.
ilGlobalTemplateInterface $tpl
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
prepareOutput(bool $show_sub_objects=true)
ilToolbarGUI $toolbar
static getClassByType(string $obj_type)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
addHeaderAction()
Add header action menu.
static prepareJsLinks(string $redraw_url, string $notes_url, string $tags_url, ?ilGlobalTemplateInterface $tpl=null)
Insert js/ajax links into template.
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
This class represents a password property in a property form.
ilPasteIntoMultipleItemsExplorer Explorer
This class represents a property form user interface.
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateSubTab(string $a_id)
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLeadingImage(string $a_img, string $a_alt)
addFormButton(string $a_txt, string $a_cmd, ?int $a_acc_key=null, bool $a_primary=false, ?string $a_class=null)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getSharedNodePassword(int $a_node_id)
static keepSharedSessionPassword(int $a_node_id, string $a_password)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Explorer for selecting a personal workspace item.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Workspace share handler table GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDescription(string $a_descr)
Sets description below title in standard template.
setLeftNavContent(string $a_content)
Sets content of left navigation column.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$handler
Definition: oai.php:29
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54