ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjWorkspaceFolderGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "./Services/Object/classes/class.ilObject2GUI.php";
6
19{
23 protected $help;
24
28 protected $tabs;
29
33 protected $ui;
34
39
44
48 protected $wsp_log;
49
53 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
54 {
55 global $DIC;
56 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
57
58 $this->lng = $DIC->language();
59 $this->help = $DIC["ilHelp"];
60 $this->tpl = $DIC["tpl"];
61 $this->user = $DIC->user();
62 $this->tabs = $DIC->tabs();
63 $this->ctrl = $DIC->ctrl();
64 $this->ui = $DIC->ui();
65
66 $this->wsp_log = ilLoggerFactory::getLogger("pwsp");
67
68 $this->user_folder_settings = new ilWorkspaceFolderUserSettings(
69 $this->user->getId(),
71 );
72
73 $this->requested_sortation = (int) $_GET["sortation"];
74
75 $this->lng->loadLanguageModule("cntr");
76 }
77
78 public function getType()
79 {
80 return "wfld";
81 }
82
83 public function setTabs($a_show_settings = true)
84 {
86 $ilHelp = $this->help;
87
88 $ilHelp->setScreenIdComponent("wfld");
89
90 $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
91
92 $this->tabs_gui->addTab(
93 "wsp",
94 $lng->txt("wsp_tab_personal"),
95 $this->ctrl->getLinkTarget($this, "")
96 );
97
98 $this->ctrl->setParameterByClass(
99 "ilObjWorkspaceRootFolderGUI",
100 "wsp_id",
101 $this->getAccessHandler()->getTree()->getRootId()
102 );
103
104 $this->tabs_gui->addTab(
105 "share",
106 $lng->txt("wsp_tab_shared"),
107 $this->ctrl->getLinkTargetByClass("ilObjWorkspaceRootFolderGUI", "shareFilter")
108 );
109
110 $this->tabs_gui->addTab(
111 "ownership",
112 $lng->txt("wsp_tab_ownership"),
113 $this->ctrl->getLinkTargetByClass(array("ilObjWorkspaceRootFolderGUI", "ilObjectOwnershipManagementGUI"), "listObjects")
114 );
115
116 if (!$this->ctrl->getNextClass($this)) {
117 if (stristr($this->ctrl->getCmd(), "share")) {
118 $this->tabs_gui->activateTab("share");
119 } else {
120 $this->tabs_gui->activateTab("wsp");
121 $this->addContentSubTabs($a_show_settings);
122 }
123 }
124 }
125
130 {
131 return (bool) $_SESSION["il_wsp_admin_panel"];
132 }
133
138 public function setAdministrationPanel(bool $active)
139 {
140 return $_SESSION["il_wsp_admin_panel"] = $active;
141 }
142
146 protected function addContentSubTabs($a_show_settings)
147 {
151
152 if ($this->checkPermissionBool("read")) {
153 $tabs->addSubTab("content", $lng->txt("view"), $ctrl->getLinkTarget($this, "disableAdminPanel"));
154 $tabs->addSubTab("manage", $lng->txt("cntr_manage"), $ctrl->getLinkTarget($this, "enableAdminPanel"));
155 }
156
157 if ($this->checkPermissionBool("write") && $a_show_settings) {
158 $this->tabs_gui->addSubTab(
159 "settings",
160 $lng->txt("settings"),
161 $this->ctrl->getLinkTarget($this, "edit")
162 );
163 }
164
165 if ($this->isActiveAdministrationPanel()) {
166 $tabs->activateSubTab("manage");
167 } else {
168 $tabs->activateSubTab("content");
169 }
170 }
171
175 protected function enableAdminPanel()
176 {
177 $this->setAdministrationPanel(true);
178 $this->ctrl->redirect($this, "");
179 }
180
184 protected function disableAdminPanel()
185 {
186 $this->setAdministrationPanel(false);
187 $this->ctrl->redirect($this, "");
188 }
189
190 public function executeCommand()
191 {
192 $next_class = $this->ctrl->getNextClass($this);
193 $cmd = $this->ctrl->getCmd();
194
195 switch ($next_class) {
196 case "ilcommonactiondispatchergui":
197 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
199 $this->ctrl->forwardCommand($gui);
200 break;
201
202 case "ilobjectownershipmanagementgui":
203 $this->prepareOutput();
204 $this->tabs_gui->activateTab("ownership");
205 include_once("Services/Object/classes/class.ilObjectOwnershipManagementGUI.php");
207 $this->ctrl->forwardCommand($gui);
208 break;
209
210 default:
211 $this->prepareOutput();
212 if ($this->type != "wsrt") {
213 $this->addHeaderAction();
214 }
215 if (!$cmd) {
216 $cmd = "render";
217 }
218 $this->$cmd();
219 break;
220 }
221
222 return true;
223 }
224
225 protected function initCreationForms($a_new_type)
226 {
227 $forms = array(
228 self::CFORM_NEW => $this->initCreateForm($a_new_type)
229 );
230
231 return $forms;
232 }
233
237 public function render()
238 {
241 $ilTabs = $this->tabs;
242 $ilCtrl = $this->ctrl;
243
244 //$this->addContentSubTabs();
246
247 unset($_SESSION['clipboard']['wsp2repo']);
248
249 // add new item
250 include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
251 $gui = new ilObjectAddNewItemGUI($this->node_id);
253 $gui->setCreationUrl($ilCtrl->getLinkTarget($this, "create"));
254 $gui->render();
255
256 include_once "Services/Object/classes/class.ilObjectListGUI.php";
258 "",
259 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
260 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
261 );
262
263 include_once "Modules/WorkspaceFolder/classes/class.ilWorkspaceContentGUI.php";
264 $gui = new ilWorkspaceContentGUI(
265 $this,
266 $this->node_id,
268 $this->getAccessHandler(),
269 $this->ui,
270 $this->lng,
271 $this->user,
272 $this->objDefinition,
273 $this->ctrl,
274 $this->user_folder_settings
275 );
276 $tpl->setContent($gui->render());
277
278 include_once("./Services/PersonalWorkspace/classes/class.ilWorkspaceExplorerGUI.php");
279 $exp = new ilWorkspaceExplorerGUI($ilUser->getId(), $this, "render", $this, "", "wsp_id");
280 $exp->setTypeWhiteList(array("wsrt", "wfld"));
281 $exp->setSelectableTypes(array("wsrt", "wfld"));
282 $exp->setLinkToNodeClass(true);
283 $exp->setActivateHighlighting(true);
284 if ($exp->handleCommand()) {
285 return;
286 }
287 $left = $exp->getHTML();
288
289 $tpl->setLeftNavContent($left);
290 }
291
292 public function edit()
293 {
294 parent::edit();
295
296 $this->tabs_gui->activateTab("wsp");
297 $this->tabs_gui->activateSubTab("settings");
298 }
299
300 public function update()
301 {
302 parent::update();
303
304 $this->tabs_gui->activateTab("wsp");
305 $this->tabs_gui->activateSubTab("settings");
306 }
307
313 protected function getRequestItemIds()
314 {
315 if (is_string($_REQUEST["item_ref_id"]) && $_REQUEST["item_ref_id"] != "") {
316 return [(int) $_REQUEST["item_ref_id"]];
317 } elseif (is_array($_POST["id"])) {
318 return array_map(function ($i) {
319 return (int) $i;
320 }, $_POST["id"]);
321 }
322 return [];
323 }
324
325
326
332 public function cut()
333 {
334 $item_ids = $this->getRequestItemIds();
335 if (count($item_ids) == 0) {
336 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
337 $this->ctrl->redirect($this);
338 }
339
340 //$current_node = $_REQUEST["item_ref_id"];
341 //$parent_node = $this->tree->getParentId($current_node);
342
343 // on cancel or fail we return to parent node
344 //$this->ctrl->setParameter($this, "wsp_id", $parent_node);
345
346 // check permission
347 $no_cut = array();
348 $repo_switch_allowed = true;
349 foreach ($item_ids as $item_id) {
350 foreach ($this->tree->getSubTree($this->tree->getNodeData($item_id)) as $node) {
351 if (ilObject::_lookupType($node["obj_id"]) != "file") {
352 $repo_switch_allowed = false;
353 }
354 if (!$this->checkPermissionBool("delete", "", "", $node["wsp_id"])) {
355 $obj = ilObjectFactory::getInstanceByObjId($node["obj_id"]);
356 $no_cut[$node["wsp_id"]] = $obj->getTitle();
357 unset($obj);
358 }
359 }
360 }
361 if (count($no_cut)) {
362 ilUtil::sendFailure($this->lng->txt("msg_no_perm_cut") . " " . implode(',', $no_cut), true);
363 $this->ctrl->redirect($this);
364 }
365
366 // open current position
367 // using the explorer session storage directly is basically a hack
368 // as we do not use setExpanded() [see below]
369 $_SESSION['paste_cut_wspexpand'] = array();
370 foreach ((array) $this->tree->getPathId($this->node_id) as $node_id) {
371 $_SESSION['paste_cut_wspexpand'][] = $node_id;
372 }
373
374 // remember source node
375 $_SESSION['clipboard']['source_ids'] = $item_ids;
376 $_SESSION['clipboard']['cmd'] = 'cut';
377
378 return $this->showMoveIntoObjectTree($repo_switch_allowed);
379 }
380
386 public function cut_for_repository()
387 {
388 $_SESSION['clipboard']['wsp2repo'] = true;
389 $this->cut();
390 }
391
397 public function cut_for_workspace()
398 {
399 $_SESSION['clipboard']['wsp2repo'] = false;
400 $this->cut();
401 }
402
408 public function copy()
409 {
411
412 $item_ids = $this->getRequestItemIds();
413 if (count($item_ids) == 0) {
414 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
415 $this->ctrl->redirect($this);
416 }
417
418 // on cancel or fail we return to parent node
419 $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
420
421 $repo_switch_allowed = true;
422 foreach ($item_ids as $item_id) {
423 $node = $this->tree->getNodeData($item_id);
424 if (ilObject::_lookupType($node["obj_id"]) != "file") {
425 $repo_switch_allowed = false;
426 }
427 $current_node = $item_id;
428 $owner = $this->tree->lookupOwner($current_node);
429 if ($owner == $ilUser->getId()) {
430 // open current position
431 // using the explorer session storage directly is basically a hack
432 // as we do not use setExpanded() [see below]
433 $_SESSION['paste_copy_wspexpand'] = array();
434 foreach ((array) $this->tree->getPathId($item_id) as $node_id) {
435 $_SESSION['paste_copy_wspexpand'][] = $node_id;
436 }
437 } else {
438 // see copyShared()
439 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
440 $this->ctrl->redirect($this);
441 }
442 }
443
444 // remember source node
445 $_SESSION['clipboard']['source_ids'] = $item_ids;
446 $_SESSION['clipboard']['cmd'] = 'copy';
447
448 return $this->showMoveIntoObjectTree($repo_switch_allowed);
449 }
450
451 public function copyShared()
452 {
453 if (!$_REQUEST["item_ref_id"]) {
454 $this->ctrl->redirect($this, "share");
455 }
456
457 $current_node = $_REQUEST["item_ref_id"];
458 $handler = $this->getAccessHandler();
459 // see ilSharedRessourceGUI::hasAccess()
460 if ($handler->checkAccess("read", "", $current_node)) {
461 // remember source node
462 $_SESSION['clipboard']['source_ids'] = [$current_node];
463 $_SESSION['clipboard']['cmd'] = 'copy';
464 $_SESSION['clipboard']['shared'] = true;
465
466 return $this->showMoveIntoObjectTree();
467 } else {
468 $perms = $handler->getPermissions($current_node);
469 if (in_array(ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, $perms)) {
470 return $this->passwordForm($current_node);
471 }
472 }
473
474 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
475 $this->ctrl->redirect($this, "share");
476 }
477
483 public function copy_to_repository()
484 {
485 $_SESSION['clipboard']['wsp2repo'] = true;
486 $this->copy();
487 }
488
494 public function copy_to_workspace()
495 {
496 $_SESSION['clipboard']['wsp2repo'] = false;
497 $this->copy();
498 }
499
503 public function showMoveIntoObjectTree($repo_switch_allowed = false)
504 {
505 $ilTabs = $this->tabs;
507
508 $ilTabs->clearTargets();
509
510 if (!$_SESSION['clipboard']['shared']) {
511 $ilTabs->setBackTarget(
512 $this->lng->txt('back'),
513 $this->ctrl->getLinkTarget($this)
514 );
515 } else {
516 $ilTabs->setBackTarget(
517 $this->lng->txt('back'),
518 $this->ctrl->getLinkTarget($this, 'share')
519 );
520 }
521
522 $mode = $_SESSION['clipboard']['cmd'];
523
524 ilUtil::sendInfo($this->lng->txt('msg_' . $mode . '_clipboard'));
525
526 $this->tpl->addBlockfile(
527 'ADM_CONTENT',
528 'adm_content',
529 'tpl.paste_into_multiple_objects.html',
530 "Services/Object"
531 );
532
533 // move/copy in personal workspace
534 if (!$_SESSION['clipboard']['wsp2repo']) {
535 include_once("./Services/PersonalWorkspace/classes/class.ilWorkspaceExplorerGUI.php");
536 $exp = new ilWorkspaceExplorerGUI($this->user->getId(), $this, "showMoveIntoObjectTree", $this, "");
537 $exp->setTypeWhiteList(array("wsrt", "wfld"));
538 $exp->setSelectableTypes(array("wsrt", "wfld"));
539 $exp->setSelectMode("node", false);
540 if ($exp->handleCommand()) {
541 return;
542 }
543 $this->tpl->setVariable('OBJECT_TREE', $exp->getHTML());
544
545 // switch to repo?
546 if ($repo_switch_allowed) {
547 $switch_cmd = ($mode == "cut")
548 ? "cut_for_repository"
549 : "copy_to_repository";
550 $this->tpl->setCurrentBlock("switch_button");
551 $this->tpl->setVariable('CMD_SWITCH', $switch_cmd);
552 $this->tpl->setVariable('TXT_SWITCH', $this->lng->txt('wsp_switch_to_repo_tree'));
553 $this->tpl->parseCurrentBlock();
554
555 foreach ($this->getRequestItemIds() as $id) {
556 $this->tpl->setCurrentBlock("hidden");
557 $this->tpl->setVariable('VALUE', $id);
558 $this->tpl->parseCurrentBlock();
559 }
560 }
561 }
562 // move/copy to repository
563 else {
564 require_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
567 '',
568 'paste_' . $mode . '_repexpand'
569 );
570 $exp->setTargetGet('ref_id');
571
572 if ($_GET['paste_' . $mode . '_repexpand'] == '') {
573 $expanded = $tree->readRootId();
574 } else {
575 $expanded = $_GET['paste_' . $mode . '_repexpand'];
576 }
577 $exp->setCheckedItems(array((int) $_POST['node']));
578 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showMoveIntoObjectTree'));
579 $exp->setPostVar('node');
580 $exp->setExpand($expanded);
581 $exp->setOutput(0);
582 $this->tpl->setVariable('OBJECT_TREE', $exp->getOutput());
583
584 if (in_array($mode, ["copy", "cut"])) {
585 $switch_cmd = ($mode == "cut")
586 ? "cut_for_workspace"
587 : "copy_to_workspace";
588 $this->tpl->setCurrentBlock("switch_button");
589 $this->tpl->setVariable('CMD_SWITCH', $switch_cmd);
590 $this->tpl->setVariable('TXT_SWITCH', $this->lng->txt('wsp_switch_to_wsp_tree'));
591 $this->tpl->parseCurrentBlock();
592
593 foreach ($this->getRequestItemIds() as $id) {
594 $this->tpl->setCurrentBlock("hidden");
595 $this->tpl->setVariable('VALUE', $id);
596 $this->tpl->parseCurrentBlock();
597 }
598 }
599 }
600
601
602 unset($exp);
603
604 $this->tpl->setVariable('FORM_TARGET', '_top');
605 $this->tpl->setVariable(
606 'FORM_ACTION',
607 $this->ctrl->getFormAction($this, 'performPasteIntoMultipleObjects')
608 );
609
610 $this->tpl->setVariable('CMD_SUBMIT', 'performPasteIntoMultipleObjects');
611 $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('paste'));
612 }
613
618 {
620
621 $mode = $_SESSION['clipboard']['cmd'];
622 $source_node_ids = $_SESSION['clipboard']['source_ids'];
623 $target_node_id = $_REQUEST['node'];
624
625 if (!is_array($source_node_ids) || count($source_node_ids) == 0) {
626 ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'), true);
627 $this->ctrl->redirect($this);
628 }
629 if (!$target_node_id) {
630 ilUtil::sendFailure($this->lng->txt('select_at_least_one_object'), true);
631 $this->ctrl->redirect($this, "showMoveIntoObjectTree");
632 }
633
634 if (!$_SESSION['clipboard']['wsp2repo']) {
635 $target_obj_id = $this->tree->lookupObjectId($target_node_id);
636 } else {
637 $target_obj_id = ilObject::_lookupObjId($target_node_id);
638 }
639 $target_object = ilObjectFactory::getInstanceByObjId($target_obj_id);
640
641 $fail = array();
642 foreach ($source_node_ids as $source_node_id) {
643 // object instances
644 $source_obj_id = $this->tree->lookupObjectId($source_node_id);
645 $source_object = ilObjectFactory::getInstanceByObjId($source_obj_id);
646
647
648 // sanity checks
649 if ($source_node_id == $target_node_id) {
650 $fail[] = sprintf(
651 $this->lng->txt('msg_obj_exists_in_folder'),
652 $source_object->getTitle(),
653 $target_object->getTitle()
654 );
655 }
656
657 if (!in_array($source_object->getType(), array_keys($target_object->getPossibleSubObjects()))) {
658 $fail[] = sprintf(
659 $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
660 $target_object->getTitle(),
661 $source_object->getType()
662 );
663 }
664
665 // if object is shared permission to copy has been checked above
666 $owner = $this->tree->lookupOwner($source_node_id);
667 if ($mode == "copy" && $ilUser->getId() == $owner && !$this->checkPermissionBool('copy', '', '', $source_node_id)) {
668 $fail[] = $this->lng->txt('permission_denied');
669 }
670
671 if (!$_SESSION['clipboard']['wsp2repo']) {
672 if ($mode == "cut" && $this->tree->isGrandChild($source_node_id, $target_node_id)) {
673 $fail[] = sprintf(
674 $this->lng->txt('msg_paste_object_not_in_itself'),
675 $source_object->getTitle()
676 );
677 }
678 }
679
680 if ($_SESSION['clipboard']['wsp2repo'] == true) { // see #22959
681 global $ilAccess;
682 if (!$ilAccess->checkAccess("create", "", $target_node_id, $source_object->getType())) {
683 $fail[] = sprintf(
684 $this->lng->txt('msg_no_perm_paste_object_in_folder'),
685 $source_object->getTitle(),
686 $target_object->getTitle()
687 );
688 }
689 } else {
690 if (!$this->checkPermissionBool('create', '', $source_object->getType(), $target_node_id)) {
691 $fail[] = sprintf(
692 $this->lng->txt('msg_no_perm_paste_object_in_folder'),
693 $source_object->getTitle(),
694 $target_object->getTitle()
695 );
696 }
697 }
698 }
699
700 if (sizeof($fail)) {
701 ilUtil::sendFailure(implode("<br />", $fail), true);
702 $this->ctrl->redirect($this);
703 }
704
705 foreach ($source_node_ids as $source_node_id) {
706 $source_tree = $this->tree;
707 if ($ilUser->getId() != $owner && $mode == "copy") {
708 $source_tree = new ilWorkspaceTree($owner);
709 }
710 $node_data = $source_tree->getNodeData($source_node_id);
711 $source_object = ilObjectFactory::getInstanceByObjId($node_data["obj_id"]);
712
713 // move the node
714 if ($mode == "cut") {
715 if (!$_SESSION['clipboard']['wsp2repo']) {
716 $this->tree->moveTree($source_node_id, $target_node_id);
717 } else {
718 $parent_id = $this->tree->getParentId($source_node_id);
719
720 // remove from personal workspace
721 $this->getAccessHandler()->removePermission($source_node_id);
722 $this->tree->deleteReference($source_node_id);
723 $source_node = $this->tree->getNodeData($source_node_id);
724 $this->tree->deleteTree($source_node);
725
726 // add to repository
727 $source_object->createReference();
728 $source_object->putInTree($target_node_id);
729 $source_object->setPermissions($target_node_id);
730
731 $source_node_id = $parent_id;
732 }
733 } // copy the node
734 elseif ($mode == "copy") {
735 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
737 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
738 $this->wsp_log->debug("Copy ID: " . $copy_id . ", Source Node: " . $source_node_id
739 . ", source object: " . $source_object->getId());
740 if (!$_SESSION['clipboard']['wsp2repo']) {
741 $wizard_options->disableTreeCopy();
742 }
743 $wizard_options->saveOwner($ilUser->getId());
744 $wizard_options->saveRoot($source_node_id);
745 $wizard_options->read();
746
747 $new_obj = $source_object->cloneObject($target_node_id, $copy_id);
748 // insert into workspace tree
749 if ($new_obj && !$_SESSION['clipboard']['wsp2repo']) {
750 $this->wsp_log->debug("New Obj ID: " . $new_obj->getId());
751 $new_obj_node_id = $this->tree->insertObject($target_node_id, $new_obj->getId());
752 $this->getAccessHandler()->setPermissions($target_node_id, $new_obj_node_id);
753 }
754
755 $wizard_options->deleteAll();
756 }
757 }
758
759 // redirect to target if not repository
760 if (!$_SESSION['clipboard']['wsp2repo']) {
761 $redirect_node = $target_node_id;
762 } else {
763 // reload current folder
764 $redirect_node = $this->node_id;
765 }
766
767 unset($_SESSION['clipboard']['cmd']);
768 unset($_SESSION['clipboard']['source_ids']);
769 unset($_SESSION['clipboard']['wsp2repo']);
770 unset($_SESSION['clipboard']['shared']);
771
772 // #17746
773 if ($mode == 'cut') {
774 ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true);
775 } else {
776 ilUtil::sendSuccess($this->lng->txt('msg_cloned'), true);
777 }
778
779 $this->ctrl->setParameter($this, "wsp_id", $redirect_node);
780 $this->ctrl->redirect($this);
781 }
782
783 public function shareFilter()
784 {
785 $this->share(false);
786 }
787
788 public function share($a_load_data = true)
789 {
791
792 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
793 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id, $a_load_data);
794 $tpl->setContent($tbl->getHTML());
795 }
796
797 public function applyShareFilter()
798 {
799 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
800 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
801 $tbl->resetOffset();
802 $tbl->writeFilterToSession();
803
804 $this->share();
805 }
806
807 public function resetShareFilter()
808 {
809 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
810 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
811 $tbl->resetOffset();
812 $tbl->resetFilter();
813
814 $this->shareFilter();
815 }
816
817 protected function passwordForm($a_node_id, $form = null)
818 {
821 $ilTabs = $this->tabs;
822
823 $tpl->setTitle($lng->txt("wsp_password_protected_resource"));
824 $tpl->setDescription($lng->txt("wsp_password_protected_resource_info"));
825
826 $ilTabs->clearTargets();
827 $ilTabs->setBackTarget(
828 $lng->txt("back"),
829 $this->ctrl->getLinkTarget($this, "share")
830 );
831
832 if (!$form) {
833 $form = $this->initPasswordForm($a_node_id);
834 }
835
836 $tpl->setContent($form->getHTML());
837 }
838
839 protected function initPasswordForm($a_node_id)
840 {
841 $ilCtrl = $this->ctrl;
843
844 $this->ctrl->setParameter($this, "item_ref_id", $a_node_id);
845
846 $object_data = $this->getAccessHandler()->getObjectDataFromNode($a_node_id);
847
848 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
849 $form = new ilPropertyFormGUI();
850 $form->setFormAction($ilCtrl->getFormAction($this, "checkPassword"));
851 $form->setTitle($lng->txt("wsp_password_for") . ": " . $object_data["title"]);
852
853 $password = new ilPasswordInputGUI($lng->txt("password"), "password");
854 $password->setRetype(false);
855 $password->setRequired(true);
856 $password->setSkipSyntaxCheck(true);
857 $form->addItem($password);
858
859 $form->addCommandButton("checkPassword", $lng->txt("submit"));
860 $form->addCommandButton("share", $lng->txt("cancel"));
861
862 return $form;
863 }
864
865 protected function checkPassword()
866 {
868
869 $node_id = $_REQUEST["item_ref_id"];
870 if (!$node_id) {
871 $this->ctrl->redirect($this, "share");
872 }
873
874 $form = $this->initPasswordForm($node_id);
875 if ($form->checkInput()) {
876 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
878 $input = md5($form->getInput("password"));
879 if ($input == $password) {
880 // we save password and start over
882
883 $this->ctrl->setParameter($this, "item_ref_id", $node_id);
884 $this->ctrl->redirect($this, "copyShared");
885 } else {
886 $item = $form->getItemByPostVar("password");
887 $item->setAlert($lng->txt("wsp_invalid_password"));
888 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
889 }
890 }
891
892 $form->setValuesByPost();
893 $this->passwordForm($node_id, $form);
894 }
895
901 public static function _goto($a_target)
902 {
903 $id = explode("_", $a_target);
904
905 $_GET["baseClass"] = "ilsharedresourceGUI";
906 $_GET["wsp_id"] = $id[0];
907 include("ilias.php");
908 exit;
909 }
910
915 {
916 $ilCtrl = $this->ctrl;
917
918 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
919 $tbl = new ilWorkspaceShareTableGUI($this, "share", $this->getAccessHandler(), $this->node_id);
920 $tbl->resetOffset();
921 $tbl->resetFilter();
922 $_POST["user"] = $_GET["user"];
923 $tbl->writeFilterToSession();
924 $this->share();
925 }
926
932 protected function deleteConfirmation()
933 {
934 global $DIC;
935
936 $tpl = $DIC["tpl"];
937 $lng = $DIC["lng"];
938
939 $item_ids = $this->getRequestItemIds();
940
941 if (count($item_ids) == 0) {
942 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
943 $this->ctrl->redirect($this, "");
944 }
945
946 // on cancel or fail we return to parent node
947 //$parent_node = $this->tree->getParentId($node_id);
948 //$this->ctrl->setParameter($this, "wsp_id", $parent_node);
949
950 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
951 $cgui = new ilConfirmationGUI();
952 $cgui->setHeaderText($lng->txt("info_delete_sure") . "<br/>" .
953 $lng->txt("info_delete_warning_no_trash"));
954
955 $cgui->setFormAction($this->ctrl->getFormAction($this));
956 $cgui->setCancel($lng->txt("cancel"), "cancelDeletion");
957 $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
958
959 foreach ($item_ids as $node_id) {
960 $children = $this->tree->getSubTree($this->tree->getNodeData($node_id));
961 foreach ($children as $child) {
962 $node_id = $child["wsp_id"];
963 $obj_id = $this->tree->lookupObjectId($node_id);
965 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id);
966
967 // if anything fails, abort the whole process
968 if (!$this->checkPermissionBool("delete", "", "", $node_id)) {
969 ilUtil::sendFailure($lng->txt("msg_no_perm_delete") . " " . $title, true);
970 $this->ctrl->redirect($this);
971 }
972
973 $cgui->addItem(
974 "id[]",
975 $node_id,
976 $title,
978 $lng->txt("icon") . " " . $lng->txt("obj_" . $type)
979 );
980 }
981 }
982
983 $tpl->setContent($cgui->getHTML());
984 }
985
992 public function cancelDeletion()
993 {
994 unset($_SESSION['clipboard']['cmd']);
995 unset($_SESSION['clipboard']['source_ids']);
996 unset($_SESSION['clipboard']['wsp2repo']);
997 unset($_SESSION['clipboard']['shared']);
998 parent::cancelDelete();
999 }
1000
1001
1002 //
1003 // admin panel
1004 //
1005
1009 public function showAdministrationPanel()
1010 {
1011 global $DIC;
1012
1013 $ilAccess = $this->access;
1014 $lng = $this->lng;
1015
1016 $main_tpl = $DIC->ui()->mainTemplate();
1017
1018 $lng->loadLanguageModule('cntr');
1019
1020 if ($_SESSION["wsp_clipboard"]) {
1021 // #11545
1022 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
1023
1024 include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1025 $toolbar = new ilToolbarGUI();
1026 $this->ctrl->setParameter($this, "type", "");
1027 $this->ctrl->setParameter($this, "item_ref_id", "");
1028
1029 $toolbar->addFormButton(
1030 $this->lng->txt('paste_clipboard_items'),
1031 'paste'
1032 );
1033
1034 $toolbar->addFormButton(
1035 $this->lng->txt('clear_clipboard'),
1036 'clear'
1037 );
1038
1039 $main_tpl->addAdminPanelToolbar($toolbar, true, false);
1040 } elseif ($this->isActiveAdministrationPanel()) {
1041 // #11545
1042 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
1043
1044 include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1045 $toolbar = new ilToolbarGUI();
1046 $this->ctrl->setParameter($this, "type", "");
1047 $this->ctrl->setParameter($this, "item_ref_id", "");
1048
1049 // if (!$_SESSION["clipboard"])
1050 // {
1051 if ($this->object->gotItems($this->node_id)) {
1052 $toolbar->setLeadingImage(
1053 ilUtil::getImagePath("arrow_upright.svg"),
1054 $lng->txt("actions")
1055 );
1056 $toolbar->addFormButton(
1057 $this->lng->txt('delete_selected_items'),
1058 'delete'
1059 );
1060 $toolbar->addFormButton(
1061 $this->lng->txt('move_selected_items'),
1062 'cut'
1063 );
1064 $toolbar->addFormButton(
1065 $this->lng->txt('copy_selected_items'),
1066 'copy'
1067 );
1068 $toolbar->addFormButton(
1069 $this->lng->txt('download_selected_items'),
1070 'download'
1071 );
1072 // add download button if multi download enabled
1073
1074 //@todo download
1075 /*
1076 $folder_set = new ilSetting("fold");
1077 if ($folder_set->get("enable_multi_download") == true)
1078 {
1079 $toolbar->addSeparator();
1080
1081 if(!$folder_set->get("bgtask_download", 0))
1082 {
1083 $toolbar->addFormButton(
1084 $this->lng->txt('download_selected_items'),
1085 'download'
1086 );
1087 }
1088 else
1089 {
1090
1091 $url = $this->ctrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjfoldergui", "ilbackgroundtaskhub"), "", "", true, false);
1092 $main_tpl->addJavaScript("Services/BackgroundTask/js/BgTask.js");
1093 $main_tpl->addOnLoadCode("il.BgTask.initMultiForm('ilFolderDownloadBackgroundTaskHandler');");
1094 $main_tpl->addOnLoadCode('il.BgTask.setAjax("'.$url.'");');
1095
1096 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
1097 $button = ilSubmitButton::getInstance();
1098 $button->setCaption("download_selected_items");
1099 $button->addCSSClass("ilbgtasksubmit");
1100 $button->setCommand("download");
1101 $toolbar->addButtonInstance($button);
1102 }
1103 }*/
1104 }
1105
1106 $main_tpl->addAdminPanelToolbar(
1107 $toolbar,
1108 ($this->object->gotItems($this->node_id) && !$_SESSION["wsp_clipboard"]) ? true : false,
1109 ($this->object->gotItems($this->node_id) && !$_SESSION["wsp_clipboard"]) ? true : false
1110 );
1111
1112 // form action needed, see http://www.ilias.de/mantis/view.php?id=9630
1113 if ($this->object->gotItems($this->node_id)) {
1114 $main_tpl->setPageFormAction($this->ctrl->getFormAction($this));
1115 }
1116 }
1117 }
1118
1119
1123 protected function setSortation()
1124 {
1125 $this->user_folder_settings->updateSortation($this->object->getId(), $this->requested_sortation);
1126 $this->ctrl->redirect($this, "");
1127 }
1128
1129 public function download()
1130 {
1131 // This variable determines whether the task has been initiated by a folder's action drop-down to prevent a folder
1132 // duplicate inside the zip.
1133 $initiated_by_folder_action = false;
1134
1135 if ($_GET["item_ref_id"] != "") {
1136 $_POST["id"] = array($_GET["item_ref_id"]);
1137 }
1138
1139 if (!isset($_POST["id"])) {
1140 /*$object = ilObjectFactory::getInstanceByRefId($_GET['ref_id']);
1141 $object_type = $object->getType();
1142 if($object_type == "fold")
1143 {
1144 $_POST["id"] = array($_GET['ref_id']);
1145 $initiated_by_folder_action = true;
1146 }
1147 else
1148 {
1149 $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1150 }
1151 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);*/
1152 $this->ctrl->redirect($this, "");
1153 }
1154
1155 $download_job = new ilDownloadWorkspaceFolderBackgroundTask($GLOBALS['DIC']->user()->getId(), $_POST["id"], $initiated_by_folder_action);
1156
1157 $download_job->setBucketTitle($this->getBucketTitle());
1158 if ($download_job->run()) {
1159 ilUtil::sendSuccess($this->lng->txt('msg_bt_download_started'), true);
1160 }
1161 $this->ctrl->redirect($this);
1162 }
1163
1164 public function getBucketTitle()
1165 {
1166 return $bucket_title = ilUtil::getAsciiFilename($this->object->getTitle());
1167 }
1168}
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static getLogger($a_component_id)
Get component logger.
Class ilObjWorkspaceFolderGUI.
getType()
Functions that must be overwritten.
showMoveIntoObjectTree($repo_switch_allowed=false)
Move node: select target (via explorer)
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
getRequestItemIds()
Get requested item ids.
initCreationForms($a_new_type)
Init creation froms.
cut_for_workspace()
Move node preparation (to workspace)
performPasteIntoMultipleObjects()
Move node: target has been selected, execute.
copy_to_repository()
Copy node preparation (to repository)
cut_for_repository()
Move node preparation (to workspace)
deleteConfirmation()
Display delete confirmation form (workspace specific)
addContentSubTabs($a_show_settings)
Add content subtabs.
listSharedResourcesOfOtherUser()
Entry point for awareness tool.
static _goto($a_target)
Deep link.
showAdministrationPanel()
show administration panel
copy_to_workspace()
Copy node preparation (to repository)
New implementation of ilObjectGUI.
getAccessHandler()
Get access handler.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
Render add new item selector.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getClassByType($a_obj_type)
Get class by type.
initCreateForm($a_new_type)
Init object creation form.
addHeaderAction()
Add header action menu.
static prepareJsLinks($a_redraw_url, $a_notes_url, $a_tags_url, $a_tpl=null)
Insert js/ajax links into template.
Class ilObjectOwnershipManagementGUI.
static _lookupObjId($a_id)
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a password property in a property form.
This class represents a property form user interface.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static keepSharedSessionPassword($a_node_id, $a_password)
Workspace content renderer.
Explorer for selecting a personal workspace item.
Stores user settings per workspace folder Table: wfld_user_setting (rw)
User settings for workspace folders.
Workspace share handler table GUI class.
Tree handler for personal workspace.
$password
Definition: cron.php:14
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
ui()
Definition: ui.php:5