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