ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilObjectCopyGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
15{
18 const SEARCH_SOURCE = 3;
19
20 private $mode = 0;
21
22 private $lng;
23
24 private $parent_obj = null;
25
26 private $type = '';
27 private $source = 0;
28 private $target = 0;
29
30
35 public function __construct($a_parent_gui)
36 {
37 global $ilCtrl,$lng;
38
39 $this->lng = $lng;
40 $this->lng->loadLanguageModule('search');
41 $this->lng->loadLanguageModule('obj');
42
43 $this->parent_obj = $a_parent_gui;
44
45 // this parameter may be filled in "manage" view
46 $ilCtrl->saveParameter($this, array("source_ids"));
47 }
48
53 public function executeCommand()
54 {
55 global $ilCtrl;
56
57 $this->init();
58
59 $next_class = $ilCtrl->getNextClass($this);
60 $cmd = $ilCtrl->getCmd();
61
62
63 switch($next_class)
64 {
65 default:
66 $this->$cmd();
67 break;
68 }
69 }
70
75 protected function init()
76 {
77 global $ilCtrl;
78
79 if($_REQUEST['new_type'])
80 {
81 $this->setMode(self::SEARCH_SOURCE);
82
83 $ilCtrl->setParameter($this,'new_type',$this->getType());
84 $ilCtrl->setParameterByClass(get_class($this->parent_obj), 'new_type', $this->getType());
85 $ilCtrl->setParameterByClass(get_class($this->parent_obj), 'cpfl', 1);
86 $ilCtrl->setReturnByClass(get_class($this->parent_obj), 'create');
87 }
88 elseif($_REQUEST['selectMode'] == self::SOURCE_SELECTION)
89 {
90 $this->setMode(self::SOURCE_SELECTION);
91
92 $ilCtrl->setParameterByClass(get_class($this->parent_obj), 'selectMode', self::SOURCE_SELECTION);
93 $this->setTarget((int) $_GET['ref_id']);
94 $ilCtrl->setReturnByClass(get_class($this->parent_obj), '');
95 }
96 else
97 {
98 $this->setMode(self::TARGET_SELECTION);
99 $ilCtrl->setReturnByClass(get_class($this->parent_obj),'');
100
101 if ($_GET["source_ids"] == "")
102 {
103 $this->setType(
105 );
106 }
107 }
108 }
109
114 protected function initTargetSelection()
115 {
116 global $ilCtrl, $tree;
117
118 // empty session on init
119 $_SESSION['paste_copy_repexpand'] = array();
120
121 // copy opened nodes from repository explorer
122 $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
123
124
125 $this->setMode(self::TARGET_SELECTION);
126 $this->setTarget(0);
127
128 // note that source_id is empty, if source_ids are given
129 if ($_GET['source_id'] > 0)
130 {
131 // open current position
132 $path = $tree->getPathId((int)$_GET['source_id']);
133 foreach((array)$path as $node_id)
134 {
135 if(!in_array($node_id, $_SESSION['paste_copy_repexpand']))
136 $_SESSION['paste_copy_repexpand'][] = $node_id;
137 }
138
139 $this->setSource((int) $_GET['source_id']);
140
141 $this->setType(
143 );
144 }
145
146 $ilCtrl->setReturnByClass(get_class($this->parent_obj),'');
147
149 }
150
155 protected function initSourceSelection()
156 {
157 global $ilCtrl,$tree;
158
159 // empty session on init
160 $_SESSION['paste_copy_repexpand'] = array();
161
162 // copy opened nodes from repository explorer
163 $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
164
165 $this->setMode(self::SOURCE_SELECTION);
166 $this->setSource(0);
167 $this->setTarget((int) $_GET['ref_id']);
168
169 // open current position
170 $path = $tree->getPathId($this->getTarget());
171 foreach((array) $path as $node_id)
172 {
173 if(!in_array($node_id, $_SESSION['paste_copy_repexpand']))
174 $_SESSION['paste_copy_repexpand'][] = $node_id;
175 }
176
177 $ilCtrl->setReturnByClass(get_class($this->parent_obj),'');
178 $this->showSourceSelectionTree();
179 }
180
184 public function showTargetSelectionTree()
185 {
186 global $ilTabs, $ilToolbar, $ilCtrl, $tree, $tpl, $objDefinition, $lng;
187
188 $this->tpl = $tpl;
189
190 if($objDefinition->isContainer($this->getType()))
191 {
192 ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_container'));
193 }
194 else
195 {
196 ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard'));
197 }
198
199 //
200 include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
201 $exp = new ilRepositorySelectorExplorerGUI($this, "showTargetSelectionTree");
202 $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "fold"));
203 $exp->setSelectMode("target", false);
204 if ($exp->handleCommand())
205 {
206 return;
207 }
208 $output = $exp->getHTML();
209
210 // toolbars
211 $t = new ilToolbarGUI();
212 $t->setFormAction($ilCtrl->getFormAction($this, "saveTarget"));
213 if($objDefinition->isContainer($this->getType()))
214 {
215 $t->addFormButton($lng->txt("btn_next"), "saveTarget");
216 }
217 else
218 {
219 $t->addFormButton($lng->txt("paste"), "saveTarget");
220 }
221 $t->addSeparator();
222 $t->addFormButton($lng->txt("obj_insert_into_clipboard"), "keepObjectsInClipboard");
223 $t->addFormButton($lng->txt("cancel"), "cancel");
224 $t->setCloseFormTag(false);
225 $t->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), " ");
226 $output = $t->getHTML().$output;
227 $t->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), " ");
228 $t->setCloseFormTag(true);
229 $t->setOpenFormTag(false);
230 $output.= "<br />".$t->getHTML();
231
232 $this->tpl->setContent($output);
233
234 return;
235
236 // old implementation
237
238 $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
239 "Services/Object");
240
241 include_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
244 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=goto', 'paste_copy_repexpand');
245
246 // Target selection should check for create permission
247 $required_perm = 'visible';
248 $create_perm = 'create_'.ilObject::_lookupType($this->getSource(), true);
249 if($create_perm)
250 {
251 $required_perm .= (','.$create_perm);
252 }
253 $exp->setRequiredFormItemPermission($required_perm);
254 $exp->setExpandTarget($ilCtrl->getLinkTarget($this, 'showTargetSelectionTree'));
255 $exp->setTargetGet('ref_id');
256 $exp->setPostVar('target');
257 $exp->highlightNode($_GET['ref_id']);
258 $exp->setCheckedItems(array((int) $_POST['target']));
259
260 // Filter to container
261 foreach(array('cat','root','crs','grp','fold') as $container)
262 {
263 /*
264 if($this->getType() == 'crs' and $container == 'crs')
265 {
266 continue;
267 }
268 */
269 $sub = $objDefinition->getSubObjects($container);
270 if(!isset($sub[$this->getType()]))
271 {
272 $exp->removeFormItemForType($container);
273 }
274 }
275
276 if($_GET['paste_copy_repexpand'] == '')
277 {
278 $expanded = $tree->readRootId();
279 }
280 else
281 {
282 $expanded = $_GET['paste_copy_repexpand'];
283 }
284
285 $this->tpl->setVariable('FORM_TARGET', '_self');
286 $this->tpl->setVariable('FORM_ACTION', $ilCtrl->getFormAction($this, 'copySelection'));
287
288 $exp->setExpand($expanded);
289 // build html-output
290 $exp->setOutput(0);
291 $output = $exp->getOutput();
292
293 $this->tpl->setVariable('OBJECT_TREE', $output);
294
295 $this->tpl->setVariable('CMD_SUBMIT', 'saveTarget');
296
297 if($objDefinition->isContainer($this->getType()))
298 {
299 $this->tpl->setVariable('TXT_SUBMIT',$this->lng->txt('btn_next'));
300 }
301 else
302 {
303 if(!$objDefinition->isPlugin($this->getType()))
304 {
305 $submit = $this->lng->txt('obj_'.$this->getType().'_duplicate');
306 }
307 else
308 {
309 // get plugin instance
310 include_once "Services/Component/classes/class.ilPlugin.php";
311 $plugin = ilPlugin::getPluginObject(IL_COMP_SERVICE, "Repository", "robj",
312 ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $this->getType()));
313 $submit = $plugin->txt('obj_'.$this->getType().'_duplicate');
314 }
315 $this->tpl->setVariable('TXT_SUBMIT', $submit);
316 }
317
318 $ilToolbar->addButton($this->lng->txt('cancel'), $ilCtrl->getLinkTarget($this,'cancel'));
319 }
320
324 public function showSourceSelectionTree()
325 {
326 global $ilTabs, $ilToolbar, $ilCtrl, $tree, $tpl, $objDefinition;
327
328 $this->tpl = $tpl;
329 $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paste_into_multiple_objects.html',
330 "Services/Object");
331
332 ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_source'));
333 include_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
336 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=goto', 'paste_copy_repexpand');
337 $exp->setRequiredFormItemPermission('visible,read,copy');
338
339 $ilCtrl->setParameter($this, 'selectMode', self::SOURCE_SELECTION);
340 $exp->setExpandTarget($ilCtrl->getLinkTarget($this, 'showSourceSelectionTree'));
341 $exp->setTargetGet('ref_id');
342 $exp->setPostVar('source');
343 $exp->setCheckedItems(array($this->getSource()));
344 #$exp->setNotSelectableItems(array($this->getTarget()));
345
346 // Filter to container
347 foreach(array('cat','root','grp','fold') as $container)
348 {
349 $exp->removeFormItemForType($container);
350 }
351
352
353 if($_GET['paste_copy_repexpand'] == '')
354 {
355 $expanded = $tree->readRootId();
356 }
357 else
358 {
359 $expanded = $_GET['paste_copy_repexpand'];
360 }
361
362 $this->tpl->setVariable('FORM_TARGET', '_self');
363 $this->tpl->setVariable('FORM_ACTION', $ilCtrl->getFormAction($this, 'copySelection'));
364
365 $exp->setExpand($expanded);
366 // build html-output
367 $exp->setOutput(0);
368 $output = $exp->getOutput();
369
370 $this->tpl->setVariable('OBJECT_TREE', $output);
371
372 $this->tpl->setVariable('CMD_SUBMIT', 'saveSource');
373 $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('btn_next'));
374
375 $ilToolbar->addButton($this->lng->txt('cancel'), $ilCtrl->getLinkTarget($this,'cancel'));
376 }
377
382 protected function saveTarget()
383 {
384 global $objDefinition, $tree;
385
386
387 if(isset($_REQUEST['target']))
388 {
389 $this->setTarget((int) $_REQUEST['target']);
390 }
391 else
392 {
393 ilUtil::sendFailure($this->lng->txt('select_one'));
395 return false;
396 }
397
398 if($_GET["source_ids"] == "" && $objDefinition->isContainer($this->getType()))
399 {
400 // check, if object should be copied into itself
401 $is_child = array();
402 if ($tree->isGrandChild($this->getSource(), $this->getTarget()))
403 {
405 }
406 if ($this->getSource() == $this->getTarget())
407 {
409 }
410 if (count($is_child) > 0)
411 {
412 ilUtil::sendFailure($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child));
414 return false;
415 }
416
417 $this->showItemSelection();
418 }
419 else
420 {
421 if ($_GET["source_ids"] == "")
422 {
423 $this->copySingleObject();
424 }
425 else
426 {
427 $source_ids = explode("_", $_GET["source_ids"]);
428 $this->copyMultipleNonContainer($source_ids);
429 }
430 }
431 }
432
438 public function setMode($a_mode)
439 {
440 $this->mode = $a_mode;
441 }
442
447 public function getMode()
448 {
449 return $this->mode;
450 }
451
456 public function getParentObject()
457 {
458 return $this->parent_obj;
459 }
460
466 public function getType()
467 {
468 return $this->type;
469 }
470
477 public function setType($type)
478 {
479 $this->type = $type;
480 }
481
487 public function setSource($a_source_id)
488 {
489 $_SESSION['copy_source'] = $a_source_id;
490 }
491
496 public function getSource()
497 {
498 if ($_GET["source_ids"] != "")
499 {
500 return "";
501 }
502 return $_SESSION['copy_source'];
503 }
504
510 public function setTarget($a_target)
511 {
512 $_SESSION['copy_target'] = $a_target;
513 }
514
519 public function getTarget()
520 {
521 return $_SESSION['copy_target'];
522 }
523
527 protected function cancel()
528 {
529 global $ilCtrl;
530 $ilCtrl->returnToParent($this);
531 }
532
537 {
538 global $ilCtrl;
539 $_SESSION['clipboard']['cmd'] = "copy";
540 if ($_GET["source_ids"] == "")
541 {
542 $_SESSION['clipboard']['ref_ids'] = array((int) $this->getSource());
543 }
544 else
545 {
546 $_SESSION['clipboard']['ref_ids'] = explode("_", $_GET["source_ids"]);
547 }
548 $ilCtrl->returnToParent($this);
549 }
550
551
556 protected function searchSource()
557 {
558 global $tree,$ilObjDataCache,$lng,$ilCtrl,$tpl;
559
560 if(isset($_POST['tit']))
561 {
562 ilUtil::sendInfo($this->lng->txt('wizard_search_list'));
563 $_SESSION['source_query'] = $_POST['tit'];
564 }
565 else
566 {
567 $_POST['tit'] = $_SESSION['source_query'];
568 }
569
570 $this->initFormSearch();
571 $this->form->setValuesByPost();
572
573 if(!$this->form->checkInput())
574 {
575 ilUtil::sendFailure($lng->txt('msg_no_search_string'),true);
576 $ilCtrl->returnToParent($this);
577 return false;
578 }
579
580 include_once './Services/Search/classes/class.ilQueryParser.php';
581 $query_parser = new ilQueryParser($this->form->getInput('tit'));
582 $query_parser->setMinWordLength(1,true);
583 $query_parser->setCombination(QP_COMBINATION_AND);
584 $query_parser->parse();
585 if(!$query_parser->validate())
586 {
587 ilUtil::sendFailure($query_parser->getMessage(),true);
588 $ilCtrl->returnToParent($this);
589 }
590
591 // only like search since fulltext does not support search with less than 3 characters
592 include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
593 $object_search = new ilLikeObjectSearch($query_parser);
594 $object_search->setFilter(array($_REQUEST['new_type']));
595 $res = $object_search->performSearch();
596 $res->setRequiredPermission('copy');
597 $res->filter(ROOT_FOLDER_ID,true);
598
599 if(!count($results = $res->getResultsByObjId()))
600 {
601 ilUtil::sendFailure($this->lng->txt('search_no_match'),true);
602 $ilCtrl->returnToParent($this);
603 }
604
605 include_once './Services/Object/classes/class.ilObjectCopySearchResultTableGUI.php';
606 $table = new ilObjectCopySearchResultTableGUI($this,'searchSource',$_REQUEST['new_type']);
607 $table->setSelectedReference($this->getSource());
608 $table->parseSearchResults($results);
609 $tpl->setContent($table->getHTML());
610 }
611
616 protected function saveSource()
617 {
618 global $objDefinition;
619
620 if(isset($_POST['source']))
621 {
622 $this->setSource($_POST['source']);
623 }
624 else
625 {
626 ilUtil::sendFailure($this->lng->txt('select_one'));
627 $this->searchSource();
628 return false;
629 }
630
631 if($objDefinition->isContainer($this->getType()))
632 {
633 $this->showItemSelection();
634 }
635 else
636 {
637 $this->copySingleObject();
638 }
639 }
640
641
642
647 protected function showItemSelection()
648 {
649 global $tpl;
650
651 if(!$this->getSource())
652 {
653 ilUtil::sendFailure($this->lng->txt('select_one'));
654 $this->searchSource();
655 return false;
656 }
657
658 ilUtil::sendInfo($this->lng->txt($this->getType().'_copy_threads_info'));
659 include_once './Services/Object/classes/class.ilObjectCopySelectionTableGUI.php';
660
661 $tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
662 $tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
663
664 switch($this->getMode())
665 {
667 $back_cmd = 'showSourceSelectionTree';
668 break;
669
671 $back_cmd = 'showTargetSelectionTree';
672 break;
673
675 $back_cmd = 'searchSource';
676 break;
677 }
678
679 $table = new ilObjectCopySelectionTableGUI($this,'showItemSelection',$this->getType(),$back_cmd);
680 $table->parseSource($this->getSource());
681
682 $tpl->setContent($table->getHTML());
683 }
684
689 protected function copySingleObject()
690 {
691 include_once('./Services/Link/classes/class.ilLink.php');
692 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
693
694 global $ilAccess,$ilErr,$rbacsystem,$ilUser,$ilCtrl,$rbacreview;
695
696 // Source defined
697 if(!$this->getSource())
698 {
699 ilUtil::sendFailure($this->lng->txt('select_one'),true);
700 $ilCtrl->returnToParent($this);
701 }
702
703 $this->copyMultipleNonContainer(array($this->getSource()));
704
705 return;
706
707 // old implementation
708
709
710
711 // Create permission
712 if(!$rbacsystem->checkAccess('create', $this->getTarget(), $this->getType()))
713 {
714 ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
715 $ilCtrl->returnToParent($this);
716 }
717 // Source defined
718 if(!$this->getSource())
719 {
720 ilUtil::sendFailure($this->lng->txt('select_one'),true);
721 $ilCtrl->returnToParent($this);
722 }
723 // Copy permission
724 if(!$ilAccess->checkAccess('copy','',$this->getSource()))
725 {
726 ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
727 $ilCtrl->returnToParent($this);
728 }
729
730 // Save wizard options
732 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
733 $wizard_options->saveOwner($ilUser->getId());
734 $wizard_options->saveRoot((int) $this->getSource());
735
736 /*
737 $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
738 foreach($options as $source_id => $option)
739 {
740 $wizard_options->addEntry($source_id,$option);
741 }
742 */
743
744 $wizard_options->read();
745
746 $orig = ilObjectFactory::getInstanceByRefId((int) $this->getSource());
747 $new_obj = $orig->cloneObject($this->getTarget(),$copy_id);
748
749 // Delete wizard options
750 $wizard_options->deleteAll();
751
752 // rbac log
753 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
755 {
756 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
757 $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
758 ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int)$this->getSource());
759 }
760
761 ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
762 ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
763 }
764
770 function copyMultipleNonContainer($a_sources)
771 {
772 global $ilAccess,$objDefinition,$rbacsystem,$ilUser,$ilCtrl,$rbacreview;
773
774
775 include_once('./Services/Link/classes/class.ilLink.php');
776 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
777
778 // check permissions
779 foreach ($a_sources as $source_ref_id)
780 {
781 $source_type = ilObject::_lookupType($source_ref_id, true);
782
783 // Create permission
784 if(!$rbacsystem->checkAccess('create', $this->getTarget(), $source_type))
785 {
786 ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
787 $ilCtrl->returnToParent($this);
788 }
789
790 // Copy permission
791 if(!$ilAccess->checkAccess('copy','',$source_ref_id))
792 {
793 ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
794 $ilCtrl->returnToParent($this);
795 }
796
797 // check that these objects are really not containers
798 if($objDefinition->isContainer($source_type))
799 {
800 ilUtil::sendFailure($this->lng->txt('cntr_container_only_on_their_own'),true);
801 $ilCtrl->returnToParent($this);
802 }
803 }
804
805 reset($a_sources);
806
807 // clone
808 foreach ($a_sources as $source_ref_id)
809 {
810 // Save wizard options
812 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
813 $wizard_options->saveOwner($ilUser->getId());
814 $wizard_options->saveRoot((int) $source_ref_id);
815
816 $wizard_options->read();
817
818 $orig = ilObjectFactory::getInstanceByRefId((int) $source_ref_id);
819 $new_obj = $orig->cloneObject($this->getTarget(),$copy_id);
820
821 // Delete wizard options
822 $wizard_options->deleteAll();
823
824 // rbac log
825 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
827 {
828 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
829 $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
830 ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int)$source_ref_id);
831 }
832 }
833
834 unset($_SESSION["clipboard"]["ref_ids"]);
835 unset($_SESSION["clipboard"]["cmd"]);
836
837 if (count($a_sources) == 1)
838 {
839 ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
840 ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
841 }
842 else
843 {
844 ilUtil::sendSuccess($this->lng->txt("objects_duplicated"),true);
846 }
847
848 }
849
850
855 protected function copyContainer()
856 {
857 global $ilLog, $ilCtrl;
858
859 include_once('./Services/Link/classes/class.ilLink.php');
860 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
861
862 global $ilAccess,$ilErr,$rbacsystem,$tree,$ilUser,$ilCtrl;
863
864 // Workaround for course in course copy
865
868
869 if($target_type != $source_type or $target_type != 'crs')
870 {
871 if(!$rbacsystem->checkAccess('create', $this->getTarget(),$this->getType()))
872 {
873 ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
874 $ilCtrl->returnToParent($this);
875 }
876 }
877 if(!$this->getSource())
878 {
879 ilUtil::sendFailure($this->lng->txt('select_one'),true);
880 $ilCtrl->returnToParent($this);
881 return false;
882 }
883
884 $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
886 $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $this->getType(), $this->getTarget(), $this->getSource(), $options);
887
888
889 unset($_SESSION["clipboard"]["ref_ids"]);
890 unset($_SESSION["clipboard"]["cmd"]);
891
892 // Check if copy is in progress
893 if ($result == $this->getTarget())
894 {
895 ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"),true);
896 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id",
897 $this->getTarget());
898 $ilCtrl->redirectByClass("ilrepositorygui", "");
899 }
900 else
901 {
902 ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
903 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id",
904 $result);
905 $ilCtrl->redirectByClass("ilrepositorygui", "");
906 }
907 }
908
909
910
918 public function showSourceSearch($a_tplvar)
919 {
920 global $tpl;
921
922 // Disabled for performance
923 #if(!$this->sourceExists())
924 #{
925 # return false;
926 #}
927
928 $this->unsetSession();
929 $this->initFormSearch();
930
931 if($a_tplvar)
932 {
933 $tpl->setVariable($a_tplvar,$this->form->getHTML());
934 }
935 else
936 {
937 return $this->form;
938 }
939 }
940
941
946 protected function sourceExists()
947 {
948 global $ilUser;
949
950 return (bool) ilUtil::_getObjectsByOperations($this->getType(),'copy',$ilUser->getId(),1);
951 }
952
957 protected function initFormSearch()
958 {
959 global $lng,$ilCtrl;
960
961 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
962 $this->form = new ilPropertyFormGUI();
963 $this->form->setTableWidth('600px');
964 $ilCtrl->setParameter($this,'new_type',$this->getType());
965 #$ilCtrl->setParameter($this, 'cp_mode', self::SOURCE_SELECTION);
966 $this->form->setFormAction($ilCtrl->getFormAction($this));
967 $this->form->setTitle($lng->txt($this->getType().'_copy'));
968
969 $this->form->addCommandButton('searchSource', $lng->txt('btn_next'));
970
971 $tit = new ilTextInputGUI($lng->txt('title'),'tit');
972 $tit->setSize(40);
973 $tit->setMaxLength(70);
974 $tit->setRequired(true);
975 $tit->setInfo($lng->txt('wizard_title_info'));
976 $this->form->addItem($tit);
977 }
978
983 protected function unsetSession()
984 {
985 unset($_SESSION['source_query']);
986 $this->setSource(0);
987 }
988}
989?>
$result
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
const IL_COMP_SERVICE
const QP_COMBINATION_AND
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
GUI class for the workflow of copying objects.
copyContainer()
Copy a container.
sourceExists()
Check if there is any source object.
unsetSession()
Unset session variables.
copyMultipleNonContainer($a_sources)
Copy multiple non container.
setSource($a_source_id)
Set source id.
cancel()
Cancel workflow.
setMode($a_mode)
set copy mode
setTarget($a_target)
Set target id.
searchSource()
Search source.
initTargetSelection()
Init copy from repository/search list commands.
initFormSearch()
Init search form.
setType($type)
Sets $type.
getParentObject()
Get parent gui object.
copySingleObject()
Start cloning a single (not container) object.
init()
Init return, mode.
showSourceSelectionTree()
Show target selection.
saveTarget()
Save target selection.
keepObjectsInClipboard()
Keep objects in clipboard.
saveSource()
select source object
__construct($a_parent_gui)
Constructor.
getTarget()
Get copy target.
getType()
Returns $type.
executeCommand()
Control class handling.
initSourceSelection()
Init source selection.
showSourceSearch($a_tplvar)
Show init screen Normally shown below the create and import form when creating a new object.
showTargetSelectionTree()
Show target selection.
getSource()
Get source id.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
Lookup name for id.
This class represents a property form user interface.
const COPY_OBJECT
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
static isActive()
Explorer for selecting repository items.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
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)
$_POST['username']
Definition: cron.php:12
$_COOKIE["ilClientId"]
Definition: cron.php:11
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
$target_type
Definition: goto.php:87
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
$results
$path
Definition: index.php:22
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15