ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilObjectCopyGUI Class Reference

GUI class for the workflow of copying objects. More...

+ Collaboration diagram for ilObjectCopyGUI:

Public Member Functions

 __construct ($a_parent_gui)
 Constructor. More...
 
 executeCommand ()
 Control class handling. More...
 
 showTargetSelectionTree ()
 Show target selection. More...
 
 showSourceSelectionTree ()
 Show target selection. More...
 
 setMode ($a_mode)
 set copy mode More...
 
 getMode ()
 get copy mode More...
 
 getParentObject ()
 Get parent gui object. More...
 
 getType ()
 Returns $type. More...
 
 setType ($type)
 Sets $type. More...
 
 setSource ($a_source_id)
 Set source id. More...
 
 getSource ()
 Get source id. More...
 
 setTarget ($a_target)
 Set target id. More...
 
 getTarget ()
 Get copy target. More...
 
 keepObjectsInClipboard ()
 Keep objects in clipboard. More...
 
 copyMultipleNonContainer ($a_sources)
 Copy multiple non container. More...
 
 showSourceSearch ($a_tplvar)
 Show init screen Normally shown below the create and import form when creating a new object. More...
 

Data Fields

const SOURCE_SELECTION = 1
 
const TARGET_SELECTION = 2
 
const SEARCH_SOURCE = 3
 

Protected Member Functions

 init ()
 Init return, mode. More...
 
 initTargetSelection ()
 Init copy from repository/search list commands. More...
 
 initSourceSelection ()
 Init source selection. More...
 
 saveTarget ()
 Save target selection. More...
 
 cancel ()
 Cancel workflow. More...
 
 searchSource ()
 Search source. More...
 
 saveSource ()
 select source object More...
 
 showItemSelection ()
 
 copySingleObject ()
 Start cloning a single (not container) object. More...
 
 copyContainer ()
 Copy a container. More...
 
 sourceExists ()
 Check if there is any source object. More...
 
 initFormSearch ()
 Init search form. More...
 
 unsetSession ()
 Unset session variables. More...
 

Private Attributes

 $mode = 0
 
 $lng
 
 $parent_obj = null
 
 $type = ''
 
 $source = 0
 
 $target = 0
 

Detailed Description

GUI class for the workflow of copying objects.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

@ilCtrl_Calls ilObjectCopyGUI:

Definition at line 14 of file class.ilObjectCopyGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectCopyGUI::__construct (   $a_parent_gui)

Constructor.

Returns

Definition at line 35 of file class.ilObjectCopyGUI.php.

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 }
global $ilCtrl
Definition: ilias.php:18

References $ilCtrl, and $lng.

Member Function Documentation

◆ cancel()

ilObjectCopyGUI::cancel ( )
protected

Cancel workflow.

Definition at line 527 of file class.ilObjectCopyGUI.php.

528 {
529 global $ilCtrl;
530 $ilCtrl->returnToParent($this);
531 }

References $ilCtrl.

◆ copyContainer()

ilObjectCopyGUI::copyContainer ( )
protected

Copy a container.

Returns

Definition at line 855 of file class.ilObjectCopyGUI.php.

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 }
$result
getTarget()
Get copy target.
getType()
Returns $type.
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 _lookupType($a_id, $a_reference=false)
lookup object type
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_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
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15

References $_COOKIE, $_POST, $_SESSION, $ilCtrl, $ilErr, $ilLog, $ilUser, $options, $result, $target_type, ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getInstanceByRefId(), getSource(), getTarget(), getType(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ copyMultipleNonContainer()

ilObjectCopyGUI::copyMultipleNonContainer (   $a_sources)

Copy multiple non container.

Parameters
array$a_sourcesarray of source ref ids

Definition at line 770 of file class.ilObjectCopyGUI.php.

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 }
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
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()
static redirect($a_script)
http redirect to other script

References $_SESSION, $ilCtrl, $ilUser, ilCopyWizardOptions\_allocateCopyId(), ilCopyWizardOptions\_getInstance(), ilLink\_getLink(), ilObject\_lookupType(), ilRbacLog\add(), ilRbacLog\COPY_OBJECT, ilRbacLog\gatherFaPa(), ilObjectFactory\getInstanceByRefId(), getTarget(), ilRbacLog\isActive(), ilUtil\redirect(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

Referenced by copySingleObject(), and saveTarget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copySingleObject()

ilObjectCopyGUI::copySingleObject ( )
protected

Start cloning a single (not container) object.

Returns

Definition at line 689 of file class.ilObjectCopyGUI.php.

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 }
copyMultipleNonContainer($a_sources)
Copy multiple non container.

References $ilCtrl, $ilErr, $ilUser, ilCopyWizardOptions\_allocateCopyId(), ilCopyWizardOptions\_getInstance(), ilLink\_getLink(), ilRbacLog\add(), ilRbacLog\COPY_OBJECT, copyMultipleNonContainer(), ilRbacLog\gatherFaPa(), ilObjectFactory\getInstanceByRefId(), getSource(), getTarget(), ilRbacLog\isActive(), ilUtil\redirect(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

Referenced by saveSource(), and saveTarget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilObjectCopyGUI::executeCommand ( )

Control class handling.

Returns

Definition at line 53 of file class.ilObjectCopyGUI.php.

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 }
init()
Init return, mode.
$cmd
Definition: sahs_server.php:35

References $cmd, $ilCtrl, and init().

+ Here is the call graph for this function:

◆ getMode()

ilObjectCopyGUI::getMode ( )

get copy mode

Returns

Definition at line 447 of file class.ilObjectCopyGUI.php.

448 {
449 return $this->mode;
450 }

References $mode.

Referenced by showItemSelection().

+ Here is the caller graph for this function:

◆ getParentObject()

ilObjectCopyGUI::getParentObject ( )

Get parent gui object.

Returns
object parent gui

Definition at line 456 of file class.ilObjectCopyGUI.php.

457 {
458 return $this->parent_obj;
459 }

References $parent_obj.

◆ getSource()

ilObjectCopyGUI::getSource ( )

Get source id.

Returns

Definition at line 496 of file class.ilObjectCopyGUI.php.

497 {
498 if ($_GET["source_ids"] != "")
499 {
500 return "";
501 }
502 return $_SESSION['copy_source'];
503 }
$_GET["client_id"]

References $_GET, and $_SESSION.

Referenced by copyContainer(), copySingleObject(), init(), initTargetSelection(), keepObjectsInClipboard(), saveTarget(), searchSource(), showItemSelection(), showSourceSelectionTree(), and showTargetSelectionTree().

+ Here is the caller graph for this function:

◆ getTarget()

ilObjectCopyGUI::getTarget ( )

Get copy target.

Returns

Definition at line 519 of file class.ilObjectCopyGUI.php.

520 {
521 return $_SESSION['copy_target'];
522 }

References $_SESSION.

Referenced by copyContainer(), copyMultipleNonContainer(), copySingleObject(), initSourceSelection(), and saveTarget().

+ Here is the caller graph for this function:

◆ getType()

ilObjectCopyGUI::getType ( )

Returns $type.

See also
ilObjectCopyGUI::$type

Definition at line 466 of file class.ilObjectCopyGUI.php.

467 {
468 return $this->type;
469 }

References $type.

Referenced by copyContainer(), init(), initFormSearch(), showItemSelection(), showTargetSelectionTree(), and sourceExists().

+ Here is the caller graph for this function:

◆ init()

ilObjectCopyGUI::init ( )
protected

Init return, mode.

Returns

Definition at line 75 of file class.ilObjectCopyGUI.php.

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 }
setMode($a_mode)
set copy mode
setTarget($a_target)
Set target id.
setType($type)
Sets $type.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_GET, $_REQUEST, $ilCtrl, ilObject\_lookupObjId(), ilObject\_lookupType(), getSource(), getType(), setMode(), setTarget(), and setType().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormSearch()

ilObjectCopyGUI::initFormSearch ( )
protected

Init search form.

Returns

Definition at line 957 of file class.ilObjectCopyGUI.php.

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 }
This class represents a property form user interface.
This class represents a text property in a property form.

References $ilCtrl, $lng, and getType().

Referenced by searchSource(), and showSourceSearch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSourceSelection()

ilObjectCopyGUI::initSourceSelection ( )
protected

Init source selection.

Returns

Definition at line 155 of file class.ilObjectCopyGUI.php.

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 }
setSource($a_source_id)
Set source id.
showSourceSelectionTree()
Show target selection.
$path
Definition: index.php:22

References $_GET, $_SESSION, $ilCtrl, $path, getTarget(), setMode(), setSource(), setTarget(), and showSourceSelectionTree().

+ Here is the call graph for this function:

◆ initTargetSelection()

ilObjectCopyGUI::initTargetSelection ( )
protected

Init copy from repository/search list commands.

Returns

Definition at line 114 of file class.ilObjectCopyGUI.php.

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 }
showTargetSelectionTree()
Show target selection.

References $_GET, $_SESSION, $ilCtrl, $path, ilObject\_lookupObjId(), ilObject\_lookupType(), getSource(), setMode(), setSource(), setTarget(), setType(), and showTargetSelectionTree().

+ Here is the call graph for this function:

◆ keepObjectsInClipboard()

ilObjectCopyGUI::keepObjectsInClipboard ( )

Keep objects in clipboard.

Definition at line 536 of file class.ilObjectCopyGUI.php.

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 }

References $_GET, $_SESSION, $ilCtrl, and getSource().

+ Here is the call graph for this function:

◆ saveSource()

ilObjectCopyGUI::saveSource ( )
protected

select source object

Returns

Definition at line 616 of file class.ilObjectCopyGUI.php.

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 }
searchSource()
Search source.
copySingleObject()
Start cloning a single (not container) object.

References $_POST, copySingleObject(), searchSource(), ilUtil\sendFailure(), setSource(), and showItemSelection().

+ Here is the call graph for this function:

◆ saveTarget()

ilObjectCopyGUI::saveTarget ( )
protected

Save target selection.

Returns

Definition at line 382 of file class.ilObjectCopyGUI.php.

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 }
static _lookupTitle($a_id)
lookup object title

References $_GET, $_REQUEST, ilObject\_lookupObjId(), ilObject\_lookupTitle(), copyMultipleNonContainer(), copySingleObject(), getSource(), getTarget(), ilUtil\sendFailure(), setTarget(), showItemSelection(), and showTargetSelectionTree().

+ Here is the call graph for this function:

◆ searchSource()

ilObjectCopyGUI::searchSource ( )
protected

Search source.

Returns

Definition at line 556 of file class.ilObjectCopyGUI.php.

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 }
global $tpl
Definition: ilias.php:8
const QP_COMBINATION_AND
initFormSearch()
Init search form.
$results

References $_POST, $_REQUEST, $_SESSION, $ilCtrl, $lng, $res, $results, $tpl, getSource(), initFormSearch(), QP_COMBINATION_AND, ilUtil\sendFailure(), and ilUtil\sendInfo().

Referenced by saveSource(), and showItemSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMode()

ilObjectCopyGUI::setMode (   $a_mode)

set copy mode

Parameters
int$a_mode
Returns

Definition at line 438 of file class.ilObjectCopyGUI.php.

439 {
440 $this->mode = $a_mode;
441 }

Referenced by init(), initSourceSelection(), and initTargetSelection().

+ Here is the caller graph for this function:

◆ setSource()

ilObjectCopyGUI::setSource (   $a_source_id)

Set source id.

Parameters
int$a_source_id
Returns

Definition at line 487 of file class.ilObjectCopyGUI.php.

488 {
489 $_SESSION['copy_source'] = $a_source_id;
490 }

References $_SESSION.

Referenced by initSourceSelection(), initTargetSelection(), saveSource(), and unsetSession().

+ Here is the caller graph for this function:

◆ setTarget()

ilObjectCopyGUI::setTarget (   $a_target)

Set target id.

Parameters
int$a_target
Returns

Definition at line 510 of file class.ilObjectCopyGUI.php.

511 {
512 $_SESSION['copy_target'] = $a_target;
513 }

References $_SESSION.

Referenced by init(), initSourceSelection(), initTargetSelection(), and saveTarget().

+ Here is the caller graph for this function:

◆ setType()

ilObjectCopyGUI::setType (   $type)

Sets $type.

Parameters
object$type
See also
ilObjectCopyGUI::$type

Definition at line 477 of file class.ilObjectCopyGUI.php.

478 {
479 $this->type = $type;
480 }

References $type.

Referenced by init(), and initTargetSelection().

+ Here is the caller graph for this function:

◆ showItemSelection()

ilObjectCopyGUI::showItemSelection ( )
protected
Returns

Definition at line 647 of file class.ilObjectCopyGUI.php.

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 }

References $tpl, getMode(), getSource(), getType(), SEARCH_SOURCE, searchSource(), ilUtil\sendFailure(), ilUtil\sendInfo(), SOURCE_SELECTION, and TARGET_SELECTION.

Referenced by saveSource(), and saveTarget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSourceSearch()

ilObjectCopyGUI::showSourceSearch (   $a_tplvar)

Show init screen Normally shown below the create and import form when creating a new object.

Parameters
string$a_tplvarThe tpl variable to fill
Returns

Definition at line 918 of file class.ilObjectCopyGUI.php.

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 }
unsetSession()
Unset session variables.

References $tpl, initFormSearch(), and unsetSession().

+ Here is the call graph for this function:

◆ showSourceSelectionTree()

ilObjectCopyGUI::showSourceSelectionTree ( )

Show target selection.

Definition at line 324 of file class.ilObjectCopyGUI.php.

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 }

References $_GET, $ilCtrl, $tpl, getSource(), ilPasteIntoMultipleItemsExplorer\SEL_TYPE_RADIO, and ilUtil\sendInfo().

Referenced by initSourceSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showTargetSelectionTree()

ilObjectCopyGUI::showTargetSelectionTree ( )

Show target selection.

Definition at line 184 of file class.ilObjectCopyGUI.php.

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 }
const IL_COMP_SERVICE
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.
Explorer for selecting repository items.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)

References $_GET, $_POST, $ilCtrl, $lng, $t, $tpl, ilUtil\getImagePath(), ilPlugin\getPluginObject(), getSource(), getType(), IL_COMP_SERVICE, ilPlugin\lookupNameForId(), ilPasteIntoMultipleItemsExplorer\SEL_TYPE_RADIO, and ilUtil\sendInfo().

Referenced by initTargetSelection(), and saveTarget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sourceExists()

ilObjectCopyGUI::sourceExists ( )
protected

Check if there is any source object.

Returns
bool

Definition at line 946 of file class.ilObjectCopyGUI.php.

947 {
948 global $ilUser;
949
950 return (bool) ilUtil::_getObjectsByOperations($this->getType(),'copy',$ilUser->getId(),1);
951 }
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,...

References $ilUser, ilUtil\_getObjectsByOperations(), and getType().

+ Here is the call graph for this function:

◆ unsetSession()

ilObjectCopyGUI::unsetSession ( )
protected

Unset session variables.

Returns

Definition at line 983 of file class.ilObjectCopyGUI.php.

984 {
985 unset($_SESSION['source_query']);
986 $this->setSource(0);
987 }

References $_SESSION, and setSource().

Referenced by showSourceSearch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilObjectCopyGUI::$lng
private

◆ $mode

ilObjectCopyGUI::$mode = 0
private

Definition at line 20 of file class.ilObjectCopyGUI.php.

Referenced by getMode().

◆ $parent_obj

ilObjectCopyGUI::$parent_obj = null
private

Definition at line 24 of file class.ilObjectCopyGUI.php.

Referenced by getParentObject().

◆ $source

ilObjectCopyGUI::$source = 0
private

Definition at line 27 of file class.ilObjectCopyGUI.php.

◆ $target

ilObjectCopyGUI::$target = 0
private

Definition at line 28 of file class.ilObjectCopyGUI.php.

◆ $type

ilObjectCopyGUI::$type = ''
private

Definition at line 26 of file class.ilObjectCopyGUI.php.

Referenced by getType(), and setType().

◆ SEARCH_SOURCE

const ilObjectCopyGUI::SEARCH_SOURCE = 3

Definition at line 18 of file class.ilObjectCopyGUI.php.

Referenced by showItemSelection().

◆ SOURCE_SELECTION

const ilObjectCopyGUI::SOURCE_SELECTION = 1

Definition at line 16 of file class.ilObjectCopyGUI.php.

Referenced by showItemSelection().

◆ TARGET_SELECTION

const ilObjectCopyGUI::TARGET_SELECTION = 2

Definition at line 17 of file class.ilObjectCopyGUI.php.

Referenced by showItemSelection().


The documentation for this class was generated from the following file: