ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 clear(): void
271 {
272 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_clear_clipboard"), true);
273 $this->session_repo->clearClipboard();
274 $this->ctrl->redirect($this);
275 }
276
277 public function cut(): void
278 {
279 $item_ids = $this->std_request->getItemIds();
280 if (count($item_ids) == 0) {
281 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
282 $this->ctrl->redirect($this);
283 }
284
285 // check permission
286 $no_cut = array();
287 $repo_switch_allowed = true;
288 foreach ($item_ids as $item_id) {
289 foreach ($this->tree->getSubTree($this->tree->getNodeData($item_id)) as $node) {
290 if (ilObject::_lookupType($node["obj_id"]) != "file") {
291 $repo_switch_allowed = false;
292 }
293 if (!$this->checkPermissionBool("delete", "", "", $node["wsp_id"])) {
294 $obj = ilObjectFactory::getInstanceByObjId($node["obj_id"]);
295 $no_cut[$node["wsp_id"]] = $obj->getTitle();
296 unset($obj);
297 }
298 }
299 }
300 if (count($no_cut)) {
301 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_perm_cut") . " " . implode(',', $no_cut), true);
302 $this->ctrl->redirect($this);
303 }
304
305 // remember source node
306 $this->session_repo->setClipboardSourceIds($item_ids);
307 $this->session_repo->setClipboardCmd('cut');
308
309 $this->showMoveIntoObjectTree($repo_switch_allowed);
310 }
311
312 public function cut_for_repository(): void
313 {
314 $this->session_repo->setClipboardWsp2Repo(true);
315 $this->cut();
316 }
317
318 public function cut_for_workspace(): void
319 {
320 $this->session_repo->setClipboardWsp2Repo(false);
321 $this->cut();
322 }
323
324 public function copy(): void
325 {
326 $ilUser = $this->user;
327
328 $item_ids = $this->std_request->getItemIds();
329 if (count($item_ids) == 0) {
330 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
331 $this->ctrl->redirect($this);
332 }
333
334 // on cancel or fail we return to parent node
335 $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
336
337 $repo_switch_allowed = true;
338 foreach ($item_ids as $item_id) {
339 $node = $this->tree->getNodeData($item_id);
340 if (ilObject::_lookupType($node["obj_id"]) != "file") {
341 $repo_switch_allowed = false;
342 }
343 $current_node = $item_id;
344 $owner = $this->tree->lookupOwner($current_node);
345 if ($owner != $ilUser->getId()) {
346 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
347 $this->ctrl->redirect($this);
348 }
349 if (!$this->obj_definition->allowCopy($node["type"])) {
350 $this->tpl->setOnScreenMessage(
351 'failure',
352 str_replace(
353 "%s",
354 $this->lng->txt("obj_" . $node["type"]),
355 $this->lng->txt("pwsp_type_cannot_be_copied")
356 ),
357 true
358 );
359 $this->ctrl->redirect($this);
360 }
361 }
362
363 // remember source node
364 $this->session_repo->setClipboardSourceIds($item_ids);
365 $this->session_repo->setClipboardCmd('copy');
366
367 $this->showMoveIntoObjectTree($repo_switch_allowed);
368 }
369
370 public function copyShared(): void
371 {
372 $ids = $this->std_request->getItemIds();
373 if (count($ids) != 1) {
374 $this->ctrl->redirect($this, "share");
375 }
376
377 $current_node = current($ids);
378 $handler = $this->getAccessHandler();
379 // see ilSharedRessourceGUI::hasAccess()
380 if ($handler->checkAccess("read", "", $current_node)) {
381 // remember source node
382 $this->session_repo->setClipboardSourceIds([$current_node]);
383 $this->session_repo->setClipboardCmd('copy');
384 $this->session_repo->setClipboardShared(true);
385 $this->showMoveIntoObjectTree();
386 return;
387 } else {
388 $perms = $handler->getPermissions($current_node);
389 if (in_array(ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, $perms)) {
390 $this->passwordForm($current_node);
391 return;
392 }
393 }
394
395 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
396 $this->ctrl->redirect($this, "share");
397 }
398
399 public function copy_to_repository(): void
400 {
401 $this->session_repo->setClipboardWsp2Repo(true);
402 $this->copy();
403 }
404
405 public function copy_to_workspace(): void
406 {
407 $this->session_repo->setClipboardWsp2Repo(false);
408 $this->copy();
409 }
410
411 public function showMoveIntoObjectTree(bool $repo_switch_allowed = false): void
412 {
413 $ilTabs = $this->tabs;
415
416 $ilTabs->clearTargets();
417
418 if (!$this->session_repo->getClipboardShared()) {
419 $ilTabs->setBackTarget(
420 $this->lng->txt('back'),
421 $this->ctrl->getLinkTarget($this)
422 );
423 } else {
424 $ilTabs->setBackTarget(
425 $this->lng->txt('back'),
426 $this->ctrl->getLinkTarget($this, 'share')
427 );
428 }
429
430 $mode = $this->session_repo->getClipboardCmd();
431
432 $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_' . $mode . '_clipboard'));
433
434 $this->tpl->addBlockFile(
435 'ADM_CONTENT',
436 'adm_content',
437 'tpl.paste_into_multiple_objects.html',
438 "components/ILIAS/WorkspaceFolder"
439 );
440
441 // move/copy in personal workspace
442 if (!$this->session_repo->getClipboardWsp2Repo()) {
443 $exp = new ilWorkspaceExplorerGUI($this->user->getId(), $this, "showMoveIntoObjectTree", $this, "");
444 $exp->setTypeWhiteList(array("wsrt", "wfld"));
445 $exp->setSelectableTypes(array("wsrt", "wfld"));
446 $exp->setSelectMode("node", false);
447 if ($exp->handleCommand()) {
448 return;
449 }
450 $this->tpl->setVariable('OBJECT_TREE', $exp->getHTML());
451
452 // switch to repo?
453 if ($repo_switch_allowed) {
454 $switch_cmd = ($mode == "cut")
455 ? "cut_for_repository"
456 : "copy_to_repository";
457 $this->tpl->setCurrentBlock("switch_button");
458 $this->tpl->setVariable('CMD_SWITCH', $switch_cmd);
459 $this->tpl->setVariable('TXT_SWITCH', $this->lng->txt('wsp_switch_to_repo_tree'));
460 $this->tpl->parseCurrentBlock();
461
462 foreach ($this->std_request->getItemIds() as $id) {
463 $this->tpl->setCurrentBlock("hidden");
464 $this->tpl->setVariable('VALUE', (string) $id);
465 $this->tpl->parseCurrentBlock();
466 }
467 }
468 }
469 // move/copy to repository
470 else {
473 '',
474 'paste_' . $mode . '_repexpand'
475 );
476 $exp->setTargetGet('ref_id');
477
478 if ($this->std_request->getPasteExpand($mode) == '') {
479 $expanded = $tree->readRootId();
480 } else {
481 $expanded = $this->std_request->getPasteExpand($mode);
482 }
483 $exp->setCheckedItems(array($this->std_request->getNode()));
484 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showMoveIntoObjectTree'));
485 $exp->setPostVar('node');
486 $exp->setExpand($expanded);
487 $exp->setOutput(0);
488 $this->tpl->setVariable('OBJECT_TREE', $exp->getOutput());
489
490 if (in_array($mode, ["copy", "cut"])) {
491 $switch_cmd = ($mode == "cut")
492 ? "cut_for_workspace"
493 : "copy_to_workspace";
494 $this->tpl->setCurrentBlock("switch_button");
495 $this->tpl->setVariable('CMD_SWITCH', $switch_cmd);
496 $this->tpl->setVariable('TXT_SWITCH', $this->lng->txt('wsp_switch_to_wsp_tree'));
497 $this->tpl->parseCurrentBlock();
498
499 foreach ($this->std_request->getItemIds() as $id) {
500 $this->tpl->setCurrentBlock("hidden");
501 $this->tpl->setVariable('VALUE', (string) $id);
502 $this->tpl->parseCurrentBlock();
503 }
504 }
505 }
506
507
508 unset($exp);
509
510 $this->tpl->setVariable('FORM_TARGET', '_top');
511 $this->tpl->setVariable(
512 'FORM_ACTION',
513 $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects')
514 );
515
516 $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
517 $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
518 }
519
520 public function performPasteIntoMultipleObjects(): void
521 {
522 $ilUser = $this->user;
523 $owner = 0;
524 $mode = $this->session_repo->getClipboardCmd();
525 $source_node_ids = $this->session_repo->getClipboardSourceIds();
526 $target_node_id = $this->std_request->getNode();
527
528 if (!is_array($source_node_ids) || count($source_node_ids) == 0) {
529 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_at_least_one_object'), true);
530 $this->ctrl->redirect($this);
531 }
532 if (!$target_node_id) {
533 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_at_least_one_object'), true);
534 $this->ctrl->redirect($this, "showMoveIntoObjectTree");
535 }
536
537 if (!$this->session_repo->getClipboardWsp2Repo()) {
538 $target_obj_id = $this->tree->lookupObjectId($target_node_id);
539 } else {
540 $target_obj_id = ilObject::_lookupObjId($target_node_id);
541 }
542 $target_object = ilObjectFactory::getInstanceByObjId($target_obj_id);
543
544 $fail = array();
545 foreach ($source_node_ids as $source_node_id) {
546 // object instances
547 $source_obj_id = $this->tree->lookupObjectId($source_node_id);
548 $source_object = ilObjectFactory::getInstanceByObjId($source_obj_id);
549
550
551 // sanity checks
552 if ($source_node_id == $target_node_id) {
553 $fail[] = sprintf(
554 $this->lng->txt('msg_obj_exists_in_folder'),
555 $source_object->getTitle(),
556 $target_object->getTitle()
557 );
558 }
559
560 if (!in_array($source_object->getType(), array_keys($target_object->getPossibleSubObjects()))) {
561 $fail[] = sprintf(
562 $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
563 $target_object->getTitle(),
564 $source_object->getType()
565 );
566 }
567
568 // if object is shared permission to copy has been checked above
569 $owner = $this->tree->lookupOwner($source_node_id);
570 if ($mode == "copy" && $ilUser->getId() == $owner && !$this->checkPermissionBool('copy', '', '', $source_node_id)) {
571 $fail[] = $this->lng->txt('permission_denied');
572 }
573
574 if (!$this->session_repo->getClipboardWsp2Repo()) {
575 if ($mode == "cut" && $this->tree->isGrandChild($source_node_id, $target_node_id)) {
576 $fail[] = sprintf(
577 $this->lng->txt('msg_paste_object_not_in_itself'),
578 $source_object->getTitle()
579 );
580 }
581 }
582
583 if ($this->session_repo->getClipboardWsp2Repo() == true) { // see #22959
584 global $ilAccess;
585 if (!$ilAccess->checkAccess("create", "", $target_node_id, $source_object->getType())) {
586 $fail[] = sprintf(
587 $this->lng->txt('msg_no_perm_paste_object_in_folder'),
588 $source_object->getTitle(),
589 $target_object->getTitle()
590 );
591 }
592 } else {
593 if (!$this->checkPermissionBool('create', '', $source_object->getType(), $target_node_id)) {
594 $fail[] = sprintf(
595 $this->lng->txt('msg_no_perm_paste_object_in_folder'),
596 $source_object->getTitle(),
597 $target_object->getTitle()
598 );
599 }
600 }
601 }
602
603 if (sizeof($fail)) {
604 $this->tpl->setOnScreenMessage('failure', implode("<br />", $fail), true);
605 $this->ctrl->redirect($this);
606 }
607
608 foreach ($source_node_ids as $source_node_id) {
609 $source_tree = $this->tree;
610 if ($ilUser->getId() != $owner && $mode == "copy") {
611 $source_tree = new ilWorkspaceTree($owner);
612 }
613 $node_data = $source_tree->getNodeData($source_node_id);
614 $source_object = ilObjectFactory::getInstanceByObjId($node_data["obj_id"]);
615
616 // move the node
617 if ($mode == "cut") {
618 if (!$this->session_repo->getClipboardWsp2Repo()) {
619 $this->tree->moveTree($source_node_id, $target_node_id);
620 } else {
621 $parent_id = $this->tree->getParentId($source_node_id);
622
623 // remove from personal workspace
624 $this->getAccessHandler()->removePermission($source_node_id);
625 $this->tree->deleteReference($source_node_id);
626 $source_node = $this->tree->getNodeData($source_node_id);
627 $this->tree->deleteTree($source_node);
628
629 // add to repository
630 $source_object->createReference();
631 $source_object->putInTree($target_node_id);
632 $source_object->setPermissions($target_node_id);
633
634 $source_node_id = $parent_id;
635 }
636 } // copy the node
637 elseif ($mode == "copy") {
639 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
640 $this->wsp_log->debug("Copy ID: " . $copy_id . ", Source Node: " . $source_node_id
641 . ", source object: " . $source_object->getId());
642 if (!$this->session_repo->getClipboardWsp2Repo()) {
643 $wizard_options->disableTreeCopy();
644 }
645 $wizard_options->saveOwner($ilUser->getId());
646 $wizard_options->saveRoot($source_node_id);
647 $wizard_options->read();
648
649 $new_obj = $source_object->cloneObject($target_node_id, $copy_id);
650 // insert into workspace tree
651 if ($new_obj && !$this->session_repo->getClipboardWsp2Repo()) {
652 $this->wsp_log->debug("New Obj ID: " . $new_obj->getId());
653 $new_obj_node_id = $this->tree->insertObject($target_node_id, $new_obj->getId());
654 $this->getAccessHandler()->setPermissions($target_node_id, $new_obj_node_id);
655 }
656
657 $wizard_options->deleteAll();
658 }
659 }
660
661 // redirect to target if not repository
662 if (!$this->session_repo->getClipboardWsp2Repo()) {
663 //$redirect_node = $target_node_id;
664 $redirect_node = $this->node_id; // see bug 34459
665 } else {
666 // reload current folder
667 $redirect_node = $this->node_id;
668 }
669
670 $this->session_repo->clearClipboard();
671
672 // #17746
673 if ($mode == 'cut') {
674 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_cut_copied'), true);
675 } else {
676 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_cloned'), true);
677 }
678
679 $this->ctrl->setParameter($this, "wsp_id", $redirect_node);
680 $this->ctrl->redirect($this);
681 }
682
683 public function shareFilter(): void
684 {
685 $this->share(false);
686 }
687
688 public function share(bool $a_load_data = true): void
689 {
691
692 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id, $a_load_data);
693 $tpl->setContent($tbl->getHTML());
694 }
695
696 public function applyShareFilter(): void
697 {
698 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
699 $tbl->resetOffset();
700 $tbl->writeFilterToSession();
701
702 $this->share();
703 }
704
705 public function resetShareFilter(): void
706 {
707 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
708 $tbl->resetOffset();
709 $tbl->resetFilter();
710
711 $this->shareFilter();
712 }
713
714 protected function passwordForm(int $a_node_id, ?ilPropertyFormGUI $form = null): void
715 {
718 $ilTabs = $this->tabs;
719
720 $tpl->setTitle($lng->txt("wsp_password_protected_resource"));
721 $tpl->setDescription($lng->txt("wsp_password_protected_resource_info"));
722
723 $ilTabs->clearTargets();
724 $ilTabs->setBackTarget(
725 $lng->txt("back"),
726 $this->ctrl->getLinkTarget($this, "share")
727 );
728
729 if (!$form) {
730 $form = $this->initPasswordForm($a_node_id);
731 }
732
733 $tpl->setContent($form->getHTML());
734 }
735
736 protected function initPasswordForm(int $a_node_id): ilPropertyFormGUI
737 {
738 $ilCtrl = $this->ctrl;
740
741 $this->ctrl->setParameter($this, "item_ref_id", $a_node_id);
742
743 $object_data = $this->getAccessHandler()->getObjectDataFromNode($a_node_id);
744
745 $form = new ilPropertyFormGUI();
746 $form->setFormAction($ilCtrl->getFormAction($this, "checkPassword"));
747 $form->setTitle($lng->txt("wsp_password_for") . ": " . $object_data["title"]);
748
749 $password = new ilPasswordInputGUI($lng->txt("password"), "password");
750 $password->setRetype(false);
751 $password->setRequired(true);
752 $password->setSkipSyntaxCheck(true);
753 $form->addItem($password);
754
755 $form->addCommandButton("checkPassword", $lng->txt("submit"));
756 $form->addCommandButton("share", $lng->txt("cancel"));
757
758 return $form;
759 }
760
761 protected function checkPassword(): void
762 {
764
765 $ids = $this->std_request->getItemIds();
766 if (count($ids) != 1) {
767 $this->ctrl->redirect($this, "share");
768 }
769 $node_id = current($ids);
770
771 $form = $this->initPasswordForm($node_id);
772 if ($form->checkInput()) {
774 $input = md5($form->getInput("password"));
775 if ($input == $password) {
776 // we save password and start over
778
779 $this->ctrl->setParameter($this, "item_ref_id", $node_id);
780 $this->ctrl->redirect($this, "copyShared");
781 } else {
782 $item = $form->getItemByPostVar("password");
783 $item->setAlert($lng->txt("wsp_invalid_password"));
784 $this->tpl->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
785 }
786 }
787
788 $form->setValuesByPost();
789 $this->passwordForm($node_id, $form);
790 }
791
792 public static function _goto(string $a_target): void
793 {
794 global $DIC;
795 $ctrl = $DIC->ctrl();
796 $id = explode("_", $a_target);
798 "ilsharedresourceGUI",
799 "wsp_id",
800 $id[0]
801 );
802 $ctrl->redirectByClass("ilsharedresourceGUI");
803 }
804
805 public function listSharedResourcesOfOtherUser(): void
806 {
807 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
808 $tbl->resetOffset();
809 $tbl->resetFilter();
810 $tbl->writeFilterToSession();
811 $this->share();
812 }
813
814 protected function deleteConfirmation(): void
815 {
816 global $DIC;
817
818 $tpl = $DIC["tpl"];
819 $lng = $DIC["lng"];
820
821 $item_ids = $this->std_request->getItemIds();
822
823 if (count($item_ids) == 0) {
824 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
825 $this->ctrl->redirect($this, "");
826 }
827
828 // on cancel or fail we return to parent node
829 //$parent_node = $this->tree->getParentId($node_id);
830 //$this->ctrl->setParameter($this, "wsp_id", $parent_node);
831
832 $cgui = new ilConfirmationGUI();
833 $cgui->setHeaderText($lng->txt("info_delete_sure") . "<br/>" .
834 $lng->txt("info_delete_warning_no_trash"));
835
836 $cgui->setFormAction($this->ctrl->getFormAction($this));
837 $cgui->setCancel($lng->txt("cancel"), "cancelDeletion");
838 $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
839
840 foreach ($item_ids as $node_id) {
841 $children = $this->tree->getSubTree($this->tree->getNodeData($node_id));
842 foreach ($children as $child) {
843 $node_id = $child["wsp_id"];
844 $obj_id = $this->tree->lookupObjectId($node_id);
846 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id);
847
848 // if anything fails, abort the whole process
849 if (!$this->checkPermissionBool("delete", "", "", $node_id)) {
850 $this->tpl->setOnScreenMessage('failure', $lng->txt("msg_no_perm_delete") . " " . $title, true);
851 $this->ctrl->redirect($this);
852 }
853
854 $cgui->addItem(
855 "id[]",
856 $node_id,
857 $title,
859 $lng->txt("icon") . " " . $lng->txt("obj_" . $type)
860 );
861 }
862 }
863
864 $tpl->setContent($cgui->getHTML());
865 }
866
867 public function cancelDeletion(): void
868 {
869 $this->session_repo->clearClipboard();
870 parent::cancelDelete();
871 }
872
873
874 //
875 // admin panel
876 //
877
878 public function showAdministrationPanel(): void
879 {
880 global $DIC;
881
883
884 $main_tpl = $DIC->ui()->mainTemplate();
885
886 $lng->loadLanguageModule('cntr');
887
888 if (!$this->session_repo->isClipboardEmpty()) {
889 // #11545
890 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
891
892 $toolbar = new ilToolbarGUI();
893 $this->ctrl->setParameter($this, "type", "");
894 $this->ctrl->setParameter($this, "item_ref_id", "");
895
897 $this->lng->txt('paste_clipboard_items'),
898 'paste'
899 );
900
902 $this->lng->txt('clear_clipboard'),
903 'clear'
904 );
905
906 $main_tpl->addAdminPanelToolbar($toolbar, true, false);
907 } elseif ($this->isActiveAdministrationPanel()) {
908 // #11545
909 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
910
911 $toolbar = new ilToolbarGUI();
912 $this->ctrl->setParameter($this, "type", "");
913 $this->ctrl->setParameter($this, "item_ref_id", "");
914
915 if ($this->object->gotItems($this->node_id)) {
917 ilUtil::getImagePath("nav/arrow_upright.svg"),
918 $lng->txt("actions")
919 );
921 $this->lng->txt('delete_selected_items'),
922 'delete'
923 );
925 $this->lng->txt('move_selected_items'),
926 'cut'
927 );
929 $this->lng->txt('copy_selected_items'),
930 'copy'
931 );
933 $this->lng->txt('download_selected_items'),
934 'download'
935 );
936 // add download button if multi download enabled
937 }
938
939 $main_tpl->addAdminPanelToolbar(
940 $toolbar,
941 $this->object->gotItems($this->node_id) && $this->session_repo->isClipboardEmpty(),
942 ($this->object->gotItems($this->node_id) && $this->session_repo->isClipboardEmpty())
943 );
944
945 // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
946 if ($this->object->gotItems($this->node_id)) {
947 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
948 }
949 }
950 }
951
952
956 protected function setSortation(): void
957 {
958 $this->user_folder_settings->updateSortation($this->object->getId(), $this->requested_sortation);
959 $this->ctrl->redirect($this, "");
960 }
961
962 public function download(): void
963 {
964 // This variable determines whether the task has been initiated by a folder's action drop-down to prevent a folder
965 // duplicate inside the zip.
966 $initiated_by_folder_action = false;
967
968 $ids = $this->std_request->getItemIds();
969
970 if (count($ids) == 0) {
971 $this->ctrl->redirect($this, "");
972 }
973
974 $download_job = new ilDownloadWorkspaceFolderBackgroundTask($GLOBALS['DIC']->user()->getId(), $ids, $initiated_by_folder_action);
975
976 $download_job->setBucketTitle($this->getBucketTitle());
977 if ($download_job->run()) {
978 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_bt_download_started'), true);
979 }
980 $this->ctrl->redirect($this);
981 }
982
983 public function getBucketTitle(): string
984 {
985 $title = ilFileUtils::getASCIIFilename($this->object->getTitle());
986 if ($title === '') { // $this->>object->getTitle() is empty in root of personal and shared resources
987 $title = $this->lng->txt('personal_resources');
988 }
989 return $title;
990 }
991
992 protected function buildAvailableObjectTypes(): array
993 {
994 $settings_map = [
995 'blog' => 'blogs',
996 'file' => 'files',
997 'webr' => 'links',
998 ];
999
1000 $object_types = $this->obj_definition->getCreatableSubObjects("wfld", ilObjectDefinition::MODE_WORKSPACE);
1001 $filtered_object_types = [];
1002 foreach (array_keys($object_types) as $type) {
1003 if (isset($settings_map[$type])
1004 && $this->settings->get("disable_wsp_" . $settings_map[$type])) {
1005 continue;
1006 }
1007
1008 $filtered_object_types[] = $this->buildObjectType($type);
1009 }
1010
1011 return $filtered_object_types;
1012 }
1013
1014 protected function buildObjectType(string $type): AddNewItemElement
1015 {
1016 $icon = $this->ui_factory->symbol()->icon()->custom(
1017 \ilObject::_getIcon(0, 'tiny', $type),
1018 ''
1019 );
1020
1021 $this->ctrl->setParameterByClass(self::class, 'new_type', $type);
1022 $element = new AddNewItemElement(
1023 AddNewItemElementTypes::Object,
1024 $this->lng->txt('wsp_type_' . $type),
1025 $icon,
1026 new \ILIAS\Data\URI(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(self::class, 'create'))
1027 );
1028 $this->ctrl->clearParameterByClass(self::class, 'new_type', $type);
1029 return $element;
1030 }
1031}
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:31
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54