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