ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 setSubMode ($a_mode)
 
 getSubMode ()
 
 getParentObject ()
 Get parent gui object. More...
 
 getType ()
 Returns $type. More...
 
 setType ($type)
 Sets $type. More...
 
 setSource (array $a_source_ids)
 Set source id. More...
 
 getSources ()
 Get sources. More...
 
 getFirstSource ()
 
 setTarget ($a_ref_id)
 Set single object target. More...
 
 setTargets (array $a_target)
 Set target id. More...
 
 getTargets ()
 Get copy target. More...
 
 getFirstTarget ()
 Get first 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
 
const SUBMODE_COMPLETE = 1
 
const SUBMODE_CONTENT_ONLY = 2
 
const TAB_SELECTION_TARGET_TREE = 1
 
const TAB_SELECTION_SOURCE_TREE = 2
 
const TAB_SELECTION_MEMBERSHIP = 3
 
const TAB_GROUP_SC_SELECTION = 1
 

Protected Member Functions

 init ()
 Init return, mode. More...
 
 initTabs ()
 Init tabs General. More...
 
 setTabs ($a_tab_group, $a_active_tab)
 Set tabs. More...
 
 adoptContent ()
 Adopt content (crs in crs, grp in grp, crs in grp or grp in crs) More...
 
 initTargetSelection ()
 Init copy from repository/search list commands. More...
 
 initSourceSelection ()
 Init source selection. More...
 
 showSourceSelectionMembership ()
 show target selection membership More...
 
 saveTarget ()
 Save target selection. More...
 
 cancel ()
 Cancel workflow. More...
 
 searchSource ()
 Search source. More...
 
 saveSource ()
 select source object More...
 
 saveSourceMembership ()
 Save selected source from membership screen. More...
 
 showItemSelection ()
 
 copySingleObject ()
 Start cloning a single (not container) object. More...
 
 copyContainerToTargets ()
 Copy to multiple targets. More...
 
 showCopyProgress ()
 Show progress for copying. More...
 
 updateProgress ()
 Update progress. More...
 
 copyContainer ($a_target)
 Copy a container. More...
 
 sourceExists ()
 Check if there is any source object. More...
 
 initFormSearch ()
 Init search form. More...
 
 unsetSession ()
 Unset session variables. More...
 

Protected Attributes

 $ctrl
 
 $tree
 
 $tabs
 
 $toolbar
 
 $tpl
 
 $obj_definition
 
 $obj_data_cache
 
 $access
 
 $error
 
 $rbacsystem
 
 $user
 
 $rbacreview
 

Private Attributes

 $mode = 0
 
 $sub_mode = self::SUBMODE_COMPLETE
 
 $lng
 
 $parent_obj = null
 
 $type = ''
 
 $sources = array()
 
 $targets = array()
 
 $targets_copy_id = array()
 
 $log = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjectCopyGUI::__construct (   $a_parent_gui)

Constructor.

Returns

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

References $DIC, $ilCtrl, $lng, ilLoggerFactory\getLogger(), and user().

120  {
121  global $DIC;
122 
123  $this->ctrl = $DIC->ctrl();
124  $this->tree = $DIC->repositoryTree();
125  $this->tabs = $DIC->tabs();
126  $this->toolbar = $DIC->toolbar();
127  $this->tpl = $DIC["tpl"];
128  $this->obj_definition = $DIC["objDefinition"];
129  $this->obj_data_cache = $DIC["ilObjDataCache"];
130  $this->access = $DIC->access();
131  $this->error = $DIC["ilErr"];
132  $this->rbacsystem = $DIC->rbac()->system();
133  $this->user = $DIC->user();
134  $this->rbacreview = $DIC->rbac()->review();
135  $this->log = $DIC["ilLog"];
136  $ilCtrl = $DIC->ctrl();
137  $lng = $DIC->language();
138 
139  $this->lng = $lng;
140  $this->lng->loadLanguageModule('search');
141  $this->lng->loadLanguageModule('obj');
142 
143  $this->parent_obj = $a_parent_gui;
144 
145  $this->log = ilLoggerFactory::getLogger('obj');
146  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ adoptContent()

ilObjectCopyGUI::adoptContent ( )
protected

Adopt content (crs in crs, grp in grp, crs in grp or grp in crs)

Returns
type

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

References $_GET, $ctrl, $ilCtrl, initSourceSelection(), setMode(), setSubMode(), and setTarget().

291  {
293 
294  $ilCtrl->setParameter($this, 'smode', self::SUBMODE_CONTENT_ONLY);
295  $ilCtrl->setParameter($this, 'selectMode', self::SOURCE_SELECTION);
296 
297 
298  $this->setSubMode(self::SUBMODE_CONTENT_ONLY);
299  $this->setMode(self::SOURCE_SELECTION);
300  $this->setTarget((int) $_GET['ref_id']);
301 
302 
303  return $this->initSourceSelection();
304  }
setMode($a_mode)
set copy mode
initSourceSelection()
Init source selection.
$_GET["client_id"]
setTarget($a_ref_id)
Set single object target.
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ cancel()

ilObjectCopyGUI::cancel ( )
protected

Cancel workflow.

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

References $ctrl, and $ilCtrl.

751  {
753  $ilCtrl->setReturnByClass(get_class($this->parent_obj), 'cancel');
754  $ilCtrl->returnToParent($this);
755  }
global $ilCtrl
Definition: ilias.php:18

◆ copyContainer()

ilObjectCopyGUI::copyContainer (   $a_target)
protected

Copy a container.

Returns

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

References $_COOKIE, $_POST, $access, $ctrl, $error, $ilCtrl, $ilErr, $ilLog, $ilUser, $log, PHPMailer\PHPMailer\$options, $rbacsystem, $result, $target_type, $tree, $user, ilObject\_lookupObjId(), ilObject\_lookupType(), getFirstSource(), ilObjectFactory\getInstanceByRefId(), ilLoggerFactory\getLogger(), getSources(), getSubMode(), getType(), and ilUtil\sendFailure().

Referenced by copyContainerToTargets().

1177  {
1178  $ilLog = $this->log;
1179  $ilCtrl = $this->ctrl;
1180 
1181  include_once('./Services/Link/classes/class.ilLink.php');
1182  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1183 
1184  $ilAccess = $this->access;
1185  $ilErr = $this->error;
1187  $tree = $this->tree;
1188  $ilUser = $this->user;
1189  $ilCtrl = $this->ctrl;
1190 
1191  // Workaround for course in course copy
1192 
1195 
1196  if ($this->getSubMode() != self::SUBMODE_CONTENT_ONLY) {
1197  if (!$rbacsystem->checkAccess('create', $a_target, $this->getType())) {
1198  $this->log->notice('Permission denied for target: ' . $a_target . ' type: ' . $this->getType() . ' CREATE');
1199  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
1200  $ilCtrl->returnToParent($this);
1201  }
1202  }
1203  if (!$this->getFirstSource()) {
1204  ilUtil::sendFailure($this->lng->txt('select_one'), true);
1205  $ilCtrl->returnToParent($this);
1206  return false;
1207  }
1208 
1209  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1210 
1211 
1212  ilLoggerFactory::getLogger('obj')->debug('Copy container (sources): ' . print_r($this->getSources(), true));
1213 
1215  $result = $orig->cloneAllObject(
1216  $_COOKIE[session_name()],
1217  $_COOKIE['ilClientId'],
1218  $this->getType(),
1219  $a_target,
1220  $this->getFirstSource(),
1221  $options,
1222  false,
1223  $this->getSubMode()
1224  );
1225 
1226  $this->targets_copy_id[$a_target] = $result['copy_id'];
1227 
1228  return $result;
1229  }
getSources()
Get sources.
$_COOKIE['client_id']
Definition: server.php:9
$target_type
Definition: goto.php:48
$result
getType()
Returns $type.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
static _lookupObjId($a_id)
$ilUser
Definition: imgupload.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getLogger($a_component_id)
Get component logger.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyContainerToTargets()

ilObjectCopyGUI::copyContainerToTargets ( )
protected

Copy to multiple targets.

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

References $_SESSION, $ctrl, $ilCtrl, $result, ilLink\_getLink(), ilCopyWizardOptions\_isFinished(), copyContainer(), ilLoggerFactory\getLogger(), getSources(), getSubMode(), getTargets(), and showCopyProgress().

1093  {
1094  $ilCtrl = $this->ctrl;
1095 
1096  ilLoggerFactory::getLogger('obj')->debug('Copy container to targets: ' . print_r($_REQUEST, true));
1097  ilLoggerFactory::getLogger('obj')->debug('Source(s): ' . print_r($this->getSources(), true));
1098  ilLoggerFactory::getLogger('obj')->debug('Target(s): ' . print_r($this->getTargets(), true));
1099 
1100 
1101  $last_target = 0;
1102  $result = 1;
1103  foreach ($this->getTargets() as $target_ref_id) {
1104  $result = $this->copyContainer($target_ref_id);
1105  $last_target = $target_ref_id;
1106  }
1107 
1108  unset($_SESSION["clipboard"]["ref_ids"]);
1109  unset($_SESSION["clipboard"]["cmd"]);
1110 
1111  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1112  if (ilCopyWizardOptions::_isFinished($result['copy_id'])) {
1113  ilLoggerFactory::getLogger('obj')->info('Object copy completed.');
1114  ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
1115  if ($this->getSubMode() == self::SUBMODE_CONTENT_ONLY) {
1116  // return to parent container
1117  return $this->ctrl->returnToParent($this);
1118  }
1119  // return to last target
1120  $link = ilLink::_getLink($result['ref_id']);
1121  $ilCtrl->redirectToUrl($link);
1122  } else {
1123  // show progress
1124  ilLoggerFactory::getLogger('obj')->debug('Object copy in progress.');
1125  return $this->showCopyProgress();
1126  }
1127  }
getSources()
Get sources.
$_SESSION["AccountId"]
$result
showCopyProgress()
Show progress for copying.
copyContainer($a_target)
Copy a container.
global $ilCtrl
Definition: ilias.php:18
static _isFinished($a_copy_id)
check if copy is finished
getTargets()
Get copy target.
static getLogger($a_component_id)
Get component logger.
+ 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 990 of file class.ilObjectCopyGUI.php.

References $_SESSION, $access, $ctrl, $ilCtrl, $ilUser, $obj_definition, $rbacreview, $rbacsystem, $user, ilCopyWizardOptions\_allocateCopyId(), ilCopyWizardOptions\_getInstance(), ilLink\_getLink(), ilObject\_lookupType(), ilRbacLog\add(), ilRbacLog\COPY_OBJECT, ilRbacLog\gatherFaPa(), getFirstTarget(), ilObjectFactory\getInstanceByRefId(), ilLoggerFactory\getLogger(), getSubMode(), getTargets(), ilRbacLog\isActive(), ilUtil\redirect(), and ilUtil\sendFailure().

Referenced by copySingleObject(), and saveTarget().

991  {
992  $ilAccess = $this->access;
993  $objDefinition = $this->obj_definition;
998 
999 
1000  include_once('./Services/Link/classes/class.ilLink.php');
1001  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1002 
1003  // check permissions
1004  foreach ($a_sources as $source_ref_id) {
1005  $source_type = ilObject::_lookupType($source_ref_id, true);
1006 
1007  // Create permission
1008  // begin-patch mc
1009  foreach ($this->getTargets() as $target_ref_id) {
1010  if (!$rbacsystem->checkAccess('create', $target_ref_id, $source_type)) {
1011  $this->log->notice('Permission denied for target_id: ' . $target_ref_id . ' source_type: ' . $source_type . ' CREATE');
1012  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
1013  $ilCtrl->returnToParent($this);
1014  }
1015  }
1016 
1017  // Copy permission
1018  if (!$ilAccess->checkAccess('copy', '', $source_ref_id)) {
1019  $this->log->notice('Permission denied for source_ref_id: ' . $source_ref_id . ' COPY');
1020  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
1021  $ilCtrl->returnToParent($this);
1022  }
1023 
1024  // check that these objects are really not containers
1025  if ($objDefinition->isContainer($source_type) and $this->getSubMode() != self::SUBMODE_CONTENT_ONLY) {
1026  ilUtil::sendFailure($this->lng->txt('cntr_container_only_on_their_own'), true);
1027  $ilCtrl->returnToParent($this);
1028  }
1029  }
1030 
1031  reset($a_sources);
1032 
1033 
1034  ilLoggerFactory::getLogger('obj')->debug('Copy multiple non containers. Sources: ' . print_r($a_sources, true));
1035 
1036  // clone
1037  foreach ($a_sources as $source_ref_id) {
1038  ilLoggerFactory::getLogger('obj')->debug('Copying source ref_id : ' . $source_ref_id);
1039 
1040  // begin-patch mc
1041  foreach ($this->getTargets() as $target_ref_id) {
1042  // Save wizard options
1044  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1045  $wizard_options->saveOwner($ilUser->getId());
1046  $wizard_options->saveRoot((int) $source_ref_id);
1047  $wizard_options->read();
1048 
1049  $orig = ilObjectFactory::getInstanceByRefId((int) $source_ref_id);
1050  $new_obj = $orig->cloneObject($target_ref_id, $copy_id);
1051 
1052  // Delete wizard options
1053  $wizard_options->deleteAll();
1054 
1055  // rbac log
1056  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1057  if (ilRbacLog::isActive()) {
1058  $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
1059  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
1060  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int) $source_ref_id);
1061  }
1062  }
1063  }
1064 
1065  unset($_SESSION["clipboard"]["ref_ids"]);
1066  unset($_SESSION["clipboard"]["cmd"]);
1067 
1068  if (count($a_sources) == 1) {
1069  ilLoggerFactory::getLogger('obj')->info('Object copy completed.');
1070  ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
1071  $ref_id = $new_obj->getRefId();
1072  } else {
1073  ilLoggerFactory::getLogger('obj')->info('Object copy completed.');
1074  ilUtil::sendSuccess($this->lng->txt("objects_duplicated"), true);
1075  $ref_id = $this->getFirstTarget();
1076  }
1077 
1078  ilUtil::sendSuccess($this->lng->txt("objects_duplicated"), true);
1080 
1081  // see bug discussion 24472
1082  /*
1083  $gui_fac = new ilObjectGUIFactory();
1084  $obj_gui = $gui_fac->getInstanceByRefId($ref_id);
1085  $obj_gui->redirectAfterCreation();
1086  */
1087  }
$_SESSION["AccountId"]
static isActive()
getFirstTarget()
Get first target.
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
global $ilCtrl
Definition: ilias.php:18
static _getInstance($a_copy_id)
Get instance of copy wizard options.
const COPY_OBJECT
$ilUser
Definition: imgupload.php:18
static _allocateCopyId()
Allocate a copy for further entries.
getTargets()
Get copy target.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getLogger($a_component_id)
Get component logger.
static redirect($a_script)
+ 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 963 of file class.ilObjectCopyGUI.php.

References $access, $ctrl, $error, $ilCtrl, $ilErr, $ilUser, $rbacreview, $rbacsystem, $user, copyMultipleNonContainer(), getSources(), and ilUtil\sendFailure().

Referenced by saveSource(), saveSourceMembership(), and saveTarget().

964  {
965  include_once('./Services/Link/classes/class.ilLink.php');
966  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
967 
968  $ilAccess = $this->access;
974 
975  // Source defined
976  if (!count($this->getSources())) {
977  ilUtil::sendFailure($this->lng->txt('select_one'), true);
978  $ilCtrl->returnToParent($this);
979  }
980 
981  $this->copyMultipleNonContainer($this->getSources());
982  return;
983  }
getSources()
Get sources.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
copyMultipleNonContainer($a_sources)
Copy multiple non container.
+ 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 152 of file class.ilObjectCopyGUI.php.

References $ctrl, $ilCtrl, init(), and initTabs().

153  {
155 
156  $this->init();
157  $this->initTabs();
158 
159  $next_class = $ilCtrl->getNextClass($this);
160  $cmd = $ilCtrl->getCmd();
161 
162  switch ($next_class) {
163  default:
164  $this->$cmd();
165  break;
166  }
167  }
init()
Init return, mode.
global $ilCtrl
Definition: ilias.php:18
initTabs()
Init tabs General.
+ Here is the call graph for this function:

◆ getFirstSource()

ilObjectCopyGUI::getFirstSource ( )

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

Referenced by copyContainer(), init(), saveSourceMembership(), saveTarget(), searchSource(), and showItemSelection().

695  {
696  if (count($this->sources)) {
697  return $this->sources[0];
698  }
699  return 0;
700  }
+ Here is the caller graph for this function:

◆ getFirstTarget()

ilObjectCopyGUI::getFirstTarget ( )

Get first target.

Returns
int

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

References $targets, and getTargets().

Referenced by copyMultipleNonContainer(), and init().

738  {
739  if (array_key_exists(0, $this->getTargets())) {
740  $targets = $this->getTargets();
741  return $targets[0];
742  }
743  return 0;
744  }
getTargets()
Get copy target.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMode()

ilObjectCopyGUI::getMode ( )

get copy mode

Returns

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

References $mode.

Referenced by setTabs(), and showItemSelection().

631  {
632  return $this->mode;
633  }
+ Here is the caller graph for this function:

◆ getParentObject()

ilObjectCopyGUI::getParentObject ( )

Get parent gui object.

Returns
object parent gui

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

References $parent_obj.

Referenced by init().

650  {
651  return $this->parent_obj;
652  }
+ Here is the caller graph for this function:

◆ getSources()

ilObjectCopyGUI::getSources ( )

Get sources.

Returns
array

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

References $sources.

Referenced by copyContainer(), copyContainerToTargets(), copySingleObject(), init(), initTargetSelection(), keepObjectsInClipboard(), saveSource(), saveTarget(), showItemSelection(), and showSourceSelectionTree().

690  {
691  return (array) $this->sources;
692  }
+ Here is the caller graph for this function:

◆ getSubMode()

ilObjectCopyGUI::getSubMode ( )

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

References $sub_mode.

Referenced by copyContainer(), copyContainerToTargets(), copyMultipleNonContainer(), init(), saveSource(), and setTabs().

641  {
642  return $this->sub_mode;
643  }
+ Here is the caller graph for this function:

◆ getTargets()

ilObjectCopyGUI::getTargets ( )

Get copy target.

Returns

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

References $targets.

Referenced by copyContainerToTargets(), copyMultipleNonContainer(), getFirstTarget(), init(), initSourceSelection(), saveSource(), saveTarget(), and showItemSelection().

729  {
730  return (array) $this->targets;
731  }
+ Here is the caller graph for this function:

◆ getType()

ilObjectCopyGUI::getType ( )

Returns $type.

See also
ilObjectCopyGUI::$type

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

References $type.

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

660  {
661  return $this->type;
662  }
+ Here is the caller graph for this function:

◆ init()

ilObjectCopyGUI::init ( )
protected

Init return, mode.

Returns

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

References $_GET, $ctrl, $ilCtrl, ilObject\_lookupObjId(), ilObject\_lookupType(), getFirstSource(), getFirstTarget(), ilLoggerFactory\getLogger(), getParentObject(), getSources(), getSubMode(), getTargets(), getType(), setMode(), setSource(), setSubMode(), setTarget(), setTargets(), and setType().

Referenced by executeCommand().

174  {
176 
177  if ((int) $_REQUEST['smode']) {
178  $this->setSubMode((int) $_REQUEST['smode']);
179  $ilCtrl->setParameter($this, 'smode', $this->getSubMode());
180  ilLoggerFactory::getLogger('obj')->debug('Submode is: ' . $this->getSubMode());
181  }
182 
183  // save sources
184  if ($_REQUEST['source_ids']) {
185  $this->setSource(explode('_', $_REQUEST['source_ids']));
186  $ilCtrl->setParameter($this, 'source_ids', implode('_', $this->getSources()));
187  ilLoggerFactory::getLogger('obj')->debug('Multiple sources: ' . implode('_', $this->getSources()));
188  }
189  if ($_REQUEST['source_id']) {
190  $this->setSource(array((int) $_REQUEST['source_id']));
191  $ilCtrl->setParameter($this, 'source_ids', implode('_', $this->getSources()));
192  ilLoggerFactory::getLogger('obj')->debug('source_id is set: ' . implode('_', $this->getSources()));
193  }
194  if ($this->getFirstSource()) {
195  $this->setType(
197  );
198  }
199 
200  // creation screen: copy section
201  if ($_REQUEST['new_type']) {
202  $this->setMode(self::SEARCH_SOURCE);
203  $this->setType($_REQUEST['new_type']);
204  $this->setTarget((int) $_GET['ref_id']);
205 
206  $ilCtrl->setParameter($this, 'new_type', $this->getType());
207  $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'new_type', $this->getType());
208  $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'cpfl', 1);
209  $ilCtrl->setReturnByClass(get_class($this->getParentObject()), 'create');
210 
211  ilLoggerFactory::getLogger('obj')->debug('Copy from object creation for type: ' . $this->getType());
212  return true;
213  }
214  // adopt content, and others?
215  elseif ($_REQUEST['selectMode'] == self::SOURCE_SELECTION) {
216  $this->setMode(self::SOURCE_SELECTION);
217 
218  $ilCtrl->setParameterByClass(get_class($this->parent_obj), 'selectMode', self::SOURCE_SELECTION);
219  $this->setTarget((int) $_GET['ref_id']);
220  $ilCtrl->setReturnByClass(get_class($this->parent_obj), '');
221 
222  ilLoggerFactory::getLogger('obj')->debug('Source selection mode. Target is: ' . $this->getFirstTarget());
223  } elseif ($_REQUEST['selectMode'] == self::TARGET_SELECTION) {
224  $this->setMode(self::TARGET_SELECTION);
225  $ilCtrl->setReturnByClass(get_class($this->parent_obj), '');
226  ilLoggerFactory::getLogger('obj')->debug('Target selection mode.');
227  }
228 
229 
230  // save targets
231  if ($_REQUEST['target_ids']) {
232  $this->setTargets(explode('_', $_REQUEST['target_ids']));
233  ilLoggerFactory::getLogger('obj')->debug('targets are: ' . print_r($this->getTargets(), true));
234  }
235  }
getSources()
Get sources.
setTargets(array $a_target)
Set target id.
setMode($a_mode)
set copy mode
$_GET["client_id"]
setTarget($a_ref_id)
Set single object target.
getFirstTarget()
Get first target.
getType()
Returns $type.
setSource(array $a_source_ids)
Set source id.
global $ilCtrl
Definition: ilias.php:18
getParentObject()
Get parent gui object.
static _lookupObjId($a_id)
getTargets()
Get copy target.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getLogger($a_component_id)
Get component logger.
setType($type)
Sets $type.
+ 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 1276 of file class.ilObjectCopyGUI.php.

References $ctrl, $ilCtrl, $lng, getType(), and ilTextInputGUI\setSize().

Referenced by searchSource(), and showSourceSearch().

1277  {
1278  $lng = $this->lng;
1279  $ilCtrl = $this->ctrl;
1280 
1281  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1282  $this->form = new ilPropertyFormGUI();
1283  $this->form->setTableWidth('600px');
1284 
1285  $ilCtrl->setParameter($this, 'new_type', $this->getType());
1286 
1287  #$ilCtrl->setParameter($this, 'cp_mode', self::SOURCE_SELECTION);
1288  $this->form->setFormAction($ilCtrl->getFormAction($this));
1289  $this->form->setTitle($lng->txt($this->getType() . '_copy'));
1290 
1291  $this->form->addCommandButton('searchSource', $lng->txt('btn_next'));
1292  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
1293 
1294  $tit = new ilTextInputGUI($lng->txt('title'), 'tit');
1295  $tit->setSize(40);
1296  $tit->setMaxLength(70);
1297  $tit->setRequired(true);
1298  $tit->setInfo($lng->txt('wizard_title_info'));
1299  $this->form->addItem($tit);
1300  }
This class represents a property form user interface.
getType()
Returns $type.
global $ilCtrl
Definition: ilias.php:18
setSize($a_size)
Set Size.
This class represents a text property in a property form.
+ 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 346 of file class.ilObjectCopyGUI.php.

References $_SESSION, $ctrl, $ilCtrl, $path, $tree, getTargets(), setTabs(), and showSourceSelectionTree().

Referenced by adoptContent().

347  {
349  $tree = $this->tree;
350 
351  // empty session on init
352  $_SESSION['paste_copy_repexpand'] = array();
353 
354  // copy opened nodes from repository explorer
355  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
356 
357  $this->setTabs(self::TAB_GROUP_SC_SELECTION, self::TAB_SELECTION_SOURCE_TREE);
358 
359 
360  // open current position
361  // begin-patch mc
362  foreach ($this->getTargets() as $target_ref_id) {
363  $path = $tree->getPathId($target_ref_id);
364  foreach ((array) $path as $node_id) {
365  if (!in_array($node_id, $_SESSION['paste_copy_repexpand'])) {
366  $_SESSION['paste_copy_repexpand'][] = $node_id;
367  }
368  }
369  }
370  // end-patch multi copy
371  $ilCtrl->setReturnByClass(get_class($this->parent_obj), '');
372  $this->showSourceSelectionTree();
373  }
$path
Definition: aliased.php:25
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18
setTabs($a_tab_group, $a_active_tab)
Set tabs.
getTargets()
Get copy target.
showSourceSelectionTree()
Show target selection.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTabs()

ilObjectCopyGUI::initTabs ( )
protected

Init tabs General.

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

References $ctrl, $ilCtrl, $lng, and $tabs.

Referenced by executeCommand().

242  {
243  $lng = $this->lng;
244  $ilTabs = $this->tabs;
246 
247  $lng->loadLanguageModule('cntr');
248  $ilTabs->clearTargets();
249  $ilTabs->setBackTarget(
250  $lng->txt('tab_back_to_repository'),
251  $ilCtrl->getParentReturn($this->parent_obj)
252  );
253  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ initTargetSelection()

ilObjectCopyGUI::initTargetSelection ( )
protected

Init copy from repository/search list commands.

Returns

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

References $_SESSION, $ctrl, $ilCtrl, $path, $tree, getSources(), setTargets(), and showTargetSelectionTree().

311  {
313  $tree = $this->tree;
314  $ilCtrl->setParameter($this, 'selectMode', self::TARGET_SELECTION);
315  // empty session on init
316  $_SESSION['paste_copy_repexpand'] = array();
317 
318  // copy opened nodes from repository explorer
319  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
320 
321  // begin-patch mc
322  $this->setTargets(array());
323  // cognos-blu-patch: end
324 
325  // open current position
326 
327  foreach ($this->getSources() as $source_id) {
328  if ($source_id) {
329  $path = $tree->getPathId($source_id);
330  foreach ((array) $path as $node_id) {
331  if (!in_array($node_id, $_SESSION['paste_copy_repexpand'])) {
332  $_SESSION['paste_copy_repexpand'][] = $node_id;
333  }
334  }
335  }
336  }
337 
338  $ilCtrl->setReturnByClass(get_class($this->parent_obj), '');
339  $this->showTargetSelectionTree();
340  }
getSources()
Get sources.
$path
Definition: aliased.php:25
setTargets(array $a_target)
Set target id.
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18
showTargetSelectionTree()
Show target selection.
+ Here is the call graph for this function:

◆ keepObjectsInClipboard()

ilObjectCopyGUI::keepObjectsInClipboard ( )

Keep objects in clipboard.

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

References $_SESSION, $ctrl, $ilCtrl, and getSources().

761  {
762  ilUtil::sendSuccess($this->lng->txt("obj_inserted_clipboard"), true);
764  $_SESSION['clipboard']['cmd'] = "copy";
765  $_SESSION['clipboard']['ref_ids'] = $this->getSources();
766  $ilCtrl->returnToParent($this);
767  }
getSources()
Get sources.
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ saveSource()

ilObjectCopyGUI::saveSource ( )
protected

select source object

Returns

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

References $_POST, $ctrl, $ilCtrl, $obj_definition, $target_type, ilObject\_lookupType(), copySingleObject(), ilObjectFactory\getClassByType(), getSources(), getSubMode(), getTargets(), searchSource(), ilUtil\sendFailure(), setSource(), setType(), and showItemSelection().

835  {
836  $objDefinition = $this->obj_definition;
838 
839  if (isset($_POST['source'])) {
840  $this->setSource(array((int) $_REQUEST['source']));
841  $this->setType(ilObject::_lookupType((int) $_REQUEST['source'], true));
842  $ilCtrl->setParameter($this, 'source_id', (int) $_REQUEST['source']);
843  } else {
844  ilUtil::sendFailure($this->lng->txt('select_one'));
845  $this->searchSource();
846  return false;
847  }
848 
849  // validate allowed subtypes
850  foreach ($this->getSources() as $source_ref_id) {
851  foreach ((array) $this->getTargets() as $target_ref_id) {
852  $target_type = ilObject::_lookupType($target_ref_id, true);
853  $target_class_name = ilObjectFactory::getClassByType($target_type);
854  $target_object = new $target_class_name($target_ref_id);
855  $possible_subtypes = $target_object->getPossibleSubObjects();
856 
857  $source_type = ilObject::_lookupType($source_ref_id, true);
858 
859  if (!array_key_exists($source_type, $possible_subtypes)) {
860  #ilLoggerFactory::getLogger('obj')->debug('Source type: '. $source_type);
861  #ilLoggerFactory::getLogger('obj')->debug('Target type: '. $target_type);
862  #ilLoggerFactory::getLogger('obj')->debug('Submode: '. $this->getSubMode());
863 
864  // adopt content mode
865  if (
866  $this->getSubMode() != self::SUBMODE_CONTENT_ONLY and
867  ($source_type != 'crs' or $target_type != 'crs')
868  ) {
870  sprintf(
871  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
872  $this->lng->txt('obj_' . $target_type),
873  $this->lng->txt('obj_' . $source_type)
874  )
875  );
876  $this->searchSource();
877  return false;
878  }
879  }
880  }
881  }
882 
883 
884  if ($objDefinition->isContainer($this->getType())) {
885  $this->showItemSelection();
886  } else {
887  $this->copySingleObject();
888  }
889  }
static getClassByType($a_obj_type)
Get class by type.
getSources()
Get sources.
$target_type
Definition: goto.php:48
setSource(array $a_source_ids)
Set source id.
global $ilCtrl
Definition: ilias.php:18
copySingleObject()
Start cloning a single (not container) object.
getTargets()
Get copy target.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
searchSource()
Search source.
$_POST["username"]
setType($type)
Sets $type.
+ Here is the call graph for this function:

◆ saveSourceMembership()

ilObjectCopyGUI::saveSourceMembership ( )
protected

Save selected source from membership screen.

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

References $ctrl, $ilCtrl, $obj_definition, ilObject\_lookupType(), copySingleObject(), getFirstSource(), ilUtil\sendFailure(), setSource(), setType(), and showItemSelection().

895  {
896  $objDefinition = $this->obj_definition;
898 
899  if (!isset($_REQUEST['source'])) {
900  ilUtil::sendFailure($this->lng->txt('select_one'));
901  $ilCtrl->redirect($this, 'showSourceSelectionMembership');
902  return false;
903  }
904 
905  $this->setSource(array((int) $_REQUEST['source']));
906  $this->setType(ilObject::_lookupType((int) $this->getFirstSource(), true));
907  $ilCtrl->setParameter($this, 'source_id', (int) $_REQUEST['source']);
908 
909  if ($objDefinition->isContainer($this->getType())) {
910  $this->showItemSelection();
911  } else {
912  $this->copySingleObject();
913  }
914  }
setSource(array $a_source_ids)
Set source id.
global $ilCtrl
Definition: ilias.php:18
copySingleObject()
Start cloning a single (not container) object.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setType($type)
Sets $type.
+ Here is the call graph for this function:

◆ saveTarget()

ilObjectCopyGUI::saveTarget ( )
protected

Save target selection.

Returns

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

References $ctrl, $ilCtrl, $obj_definition, $target_type, $tree, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), copyMultipleNonContainer(), copySingleObject(), ilObjectFactory\getClassByType(), getFirstSource(), getSources(), getTargets(), ilUtil\sendFailure(), setTarget(), setTargets(), showItemSelection(), and showTargetSelectionTree().

539  {
540  $objDefinition = $this->obj_definition;
541  $tree = $this->tree;
543 
544 
545  // begin-patch mc
546  if (is_array($_REQUEST['target']) and $_REQUEST['target']) {
547  $this->setTargets($_REQUEST['target']);
548  $ilCtrl->setParameter($this, 'target_ids', implode('_', $this->getTargets()));
549  }
550  // paste from clipboard
551  elseif ((int) $_REQUEST['target']) {
552  $this->setTarget($_REQUEST['target']);
553  $ilCtrl->setParameter($this, 'target_ids', implode('_', $this->getTargets()));
554  }
555  // end-patch multi copy
556  else {
557  $ilCtrl->setParameter($this, 'selectMode', self::TARGET_SELECTION);
558  ilUtil::sendFailure($this->lng->txt('select_one'));
559  $this->showTargetSelectionTree();
560  return false;
561  }
562 
563  // validate allowed subtypes
564  foreach ($this->getSources() as $source_ref_id) {
565  foreach ((array) $this->getTargets() as $target_ref_id) {
566  $target_type = ilObject::_lookupType($target_ref_id, true);
567  $target_class_name = ilObjectFactory::getClassByType($target_type);
568  $target_object = new $target_class_name($target_ref_id);
569  $possible_subtypes = $target_object->getPossibleSubObjects();
570 
571  $source_type = ilObject::_lookupType($source_ref_id, true);
572 
573  if (!array_key_exists($source_type, (array) $possible_subtypes)) {
575  sprintf(
576  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
577  $this->lng->txt('obj_' . $target_type),
578  $this->lng->txt('obj_' . $source_type)
579  )
580  );
581  $this->showTargetSelectionTree();
582  return false;
583  }
584  }
585  }
586 
587  if (count($this->getSources()) == 1 && $objDefinition->isContainer($this->getType())) {
588  // check, if object should be copied into itself
589  // begin-patch mc
590  $is_child = array();
591  foreach ($this->getTargets() as $target_ref_id) {
592  if ($tree->isGrandChild($this->getFirstSource(), $target_ref_id)) {
594  }
595  if ($this->getFirstSource() == $target_ref_id) {
597  }
598  }
599  // end-patch multi copy
600  if (count($is_child) > 0) {
601  ilUtil::sendFailure($this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child));
602  $this->showTargetSelectionTree();
603  return false;
604  }
605 
606  $this->showItemSelection();
607  } else {
608  if (count($this->getSources()) == 1) {
609  $this->copySingleObject();
610  } else {
611  $this->copyMultipleNonContainer($this->getSources());
612  }
613  }
614  }
static getClassByType($a_obj_type)
Get class by type.
getSources()
Get sources.
setTargets(array $a_target)
Set target id.
$target_type
Definition: goto.php:48
setTarget($a_ref_id)
Set single object target.
static _lookupTitle($a_id)
lookup object title
global $ilCtrl
Definition: ilias.php:18
static _lookupObjId($a_id)
copySingleObject()
Start cloning a single (not container) object.
getTargets()
Get copy target.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
showTargetSelectionTree()
Show target selection.
copyMultipleNonContainer($a_sources)
Copy multiple non container.
+ Here is the call graph for this function:

◆ searchSource()

ilObjectCopyGUI::searchSource ( )
protected

Search source.

Returns

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

References $_POST, $_SESSION, $ctrl, $ilCtrl, $lng, $obj_data_cache, $res, $results, $table, $tpl, $tree, getFirstSource(), getType(), initFormSearch(), QP_COMBINATION_AND, ilUtil\sendFailure(), ilUtil\sendInfo(), and ilQueryParser\setMinWordLength().

Referenced by saveSource(), and showItemSelection().

775  {
776  $tree = $this->tree;
777  $ilObjDataCache = $this->obj_data_cache;
778  $lng = $this->lng;
780  $tpl = $this->tpl;
781 
782  if (isset($_POST['tit'])) {
783  ilUtil::sendInfo($this->lng->txt('wizard_search_list'));
784  $_SESSION['source_query'] = $_POST['tit'];
785  } else {
786  $_POST['tit'] = $_SESSION['source_query'];
787  }
788 
789  $this->initFormSearch();
790  $this->form->setValuesByPost();
791 
792  if (!$this->form->checkInput()) {
793  ilUtil::sendFailure($lng->txt('msg_no_search_string'), true);
794  $ilCtrl->returnToParent($this);
795  return false;
796  }
797 
798  include_once './Services/Search/classes/class.ilQueryParser.php';
799  $query_parser = new ilQueryParser($this->form->getInput('tit'));
800  $query_parser->setMinWordLength(1, true);
801  $query_parser->setCombination(QP_COMBINATION_AND);
802  $query_parser->parse();
803  if (!$query_parser->validate()) {
804  ilUtil::sendFailure($query_parser->getMessage(), true);
805  $ilCtrl->returnToParent($this);
806  }
807 
808  // only like search since fulltext does not support search with less than 3 characters
809  include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
810  $object_search = new ilLikeObjectSearch($query_parser);
811  $object_search->setFilter(array($_REQUEST['new_type']));
812  $res = $object_search->performSearch();
813  $res->setRequiredPermission('copy');
814  $res->filter(ROOT_FOLDER_ID, true);
815 
816  if (!count($results = $res->getResultsByObjId())) {
817  ilUtil::sendFailure($this->lng->txt('search_no_match'), true);
818  $ilCtrl->returnToParent($this);
819  }
820 
821 
822  include_once './Services/Object/classes/class.ilObjectCopySearchResultTableGUI.php';
823  $table = new ilObjectCopySearchResultTableGUI($this, 'searchSource', $this->getType());
824  $table->setFormAction($ilCtrl->getFormAction($this));
825  $table->setSelectedReference($this->getFirstSource());
826  $table->parseSearchResults($results);
827  $tpl->setContent($table->getHTML());
828  }
$_SESSION["AccountId"]
initFormSearch()
Init search form.
getType()
Returns $type.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
foreach($_POST as $key=> $value) $res
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$results
Definition: svg-scanner.php:47
const QP_COMBINATION_AND
if(empty($password)) $table
Definition: pwgen.php:24
setMinWordLength($a_length, $a_force=false)
$_POST["username"]
+ 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 621 of file class.ilObjectCopyGUI.php.

Referenced by adoptContent(), and init().

622  {
623  $this->mode = $a_mode;
624  }
+ Here is the caller graph for this function:

◆ setSource()

ilObjectCopyGUI::setSource ( array  $a_source_ids)

Set source id.

Parameters
array$a_source_id
Returns

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

Referenced by init(), saveSource(), saveSourceMembership(), and unsetSession().

681  {
682  $this->sources = $a_source_ids;
683  }
+ Here is the caller graph for this function:

◆ setSubMode()

ilObjectCopyGUI::setSubMode (   $a_mode)

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

Referenced by adoptContent(), and init().

636  {
637  $this->sub_mode = $a_mode;
638  }
+ Here is the caller graph for this function:

◆ setTabs()

ilObjectCopyGUI::setTabs (   $a_tab_group,
  $a_active_tab 
)
protected

Set tabs.

Parameters
type$a_tab_group
type$a_active_tab

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

References $ctrl, $ilCtrl, $lng, $tabs, getMode(), and getSubMode().

Referenced by initSourceSelection(), and showSourceSelectionMembership().

261  {
262  $lng = $this->lng;
263  $ilTabs = $this->tabs;
265 
266  if ($a_tab_group == self::TAB_GROUP_SC_SELECTION) {
267  if ($this->getSubMode() == self::SUBMODE_CONTENT_ONLY) {
268  if ($this->getMode() == self::SOURCE_SELECTION) {
269  $ilTabs->addTab(
270  self::TAB_SELECTION_SOURCE_TREE,
271  $lng->txt('cntr_copy_repo_tree'),
272  $ilCtrl->getLinkTarget($this, 'initSourceSelection')
273  );
274  $ilTabs->addTab(
275  self::TAB_SELECTION_MEMBERSHIP,
276  $lng->txt('cntr_copy_crs_grp'),
277  $ilCtrl->getLinkTarget($this, 'showSourceSelectionMembership')
278  );
279  }
280  }
281  }
282  $ilTabs->activateTab($a_active_tab);
283  }
global $ilCtrl
Definition: ilias.php:18
getMode()
get copy mode
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTarget()

ilObjectCopyGUI::setTarget (   $a_ref_id)

Set single object target.

Parameters
type$a_ref_id

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

References setTargets().

Referenced by adoptContent(), init(), and saveTarget().

709  {
710  $this->setTargets(array($a_ref_id));
711  }
setTargets(array $a_target)
Set target id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTargets()

ilObjectCopyGUI::setTargets ( array  $a_target)

Set target id.

Parameters
int$a_target
Returns

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

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

720  {
721  $this->targets = $a_target;
722  }
+ Here is the caller graph for this function:

◆ setType()

ilObjectCopyGUI::setType (   $type)

Sets $type.

Parameters
object$type
See also
ilObjectCopyGUI::$type

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

References $type.

Referenced by init(), saveSource(), and saveSourceMembership().

671  {
672  $this->type = $type;
673  }
+ Here is the caller graph for this function:

◆ showCopyProgress()

ilObjectCopyGUI::showCopyProgress ( )
protected

Show progress for copying.

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

References $_GET, $ctrl, $ilCtrl, and $tpl.

Referenced by copyContainerToTargets().

1133  {
1134  $ilCtrl = $this->ctrl;
1135  $tpl = $this->tpl;
1136 
1137  include_once './Services/Object/classes/class.ilObjectCopyProgressTableGUI.php';
1138  $progress = new ilObjectCopyProgressTableGUI(
1139  $this,
1140  'showCopyProgress',
1141  (int) $_GET['ref_id']
1142  );
1143  $progress->setObjectInfo($this->targets_copy_id);
1144  $progress->parse();
1145  $progress->init();
1146  $progress->setRedirectionUrl($ilCtrl->getParentReturn($this->parent_obj));
1147 
1148  $tpl->setContent($progress->getHTML());
1149  }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ showItemSelection()

ilObjectCopyGUI::showItemSelection ( )
protected
Returns

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

References $table, $tpl, getFirstSource(), ilLoggerFactory\getLogger(), getMode(), getSources(), getTargets(), getType(), searchSource(), ilUtil\sendFailure(), and ilUtil\sendInfo().

Referenced by saveSource(), saveSourceMembership(), and saveTarget().

921  {
922  $tpl = $this->tpl;
923 
924  if (!count($this->getSources())) {
925  ilUtil::sendFailure($this->lng->txt('select_one'));
926  $this->searchSource();
927  return false;
928  }
929 
930  ilLoggerFactory::getLogger('obj')->debug('Source(s): ' . print_r($this->getSources(), true));
931  ilLoggerFactory::getLogger('obj')->debug('Target(s): ' . print_r($this->getTargets(), true));
932 
933  ilUtil::sendInfo($this->lng->txt($this->getType() . '_copy_threads_info'));
934  include_once './Services/Object/classes/class.ilObjectCopySelectionTableGUI.php';
935 
936  $tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
937  $tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
938 
939  switch ($this->getMode()) {
940  case self::SOURCE_SELECTION:
941  $back_cmd = 'showSourceSelectionTree';
942  break;
943 
944  case self::TARGET_SELECTION:
945  $back_cmd = 'showTargetSelectionTree';
946  break;
947 
948  case self::SEARCH_SOURCE:
949  $back_cmd = 'searchSource';
950  break;
951  }
952 
953  $table = new ilObjectCopySelectionTableGUI($this, 'showItemSelection', $this->getType(), $back_cmd);
954  $table->parseSource($this->getFirstSource());
955 
956  $tpl->setContent($table->getHTML());
957  }
getSources()
Get sources.
getType()
Returns $type.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getMode()
get copy mode
getTargets()
Get copy target.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getLogger($a_component_id)
Get component logger.
if(empty($password)) $table
Definition: pwgen.php:24
searchSource()
Search source.
+ 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 1240 of file class.ilObjectCopyGUI.php.

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

1241  {
1242  $tpl = $this->tpl;
1243 
1244  // Disabled for performance
1245  #if(!$this->sourceExists())
1246  #{
1247  # return false;
1248  #}
1249 
1250  $this->unsetSession();
1251  $this->initFormSearch();
1252 
1253  if ($a_tplvar) {
1254  $tpl->setVariable($a_tplvar, $this->form->getHTML());
1255  } else {
1256  return $this->form;
1257  }
1258  }
initFormSearch()
Init search form.
if(isset($_POST['submit'])) $form
unsetSession()
Unset session variables.
+ Here is the call graph for this function:

◆ showSourceSelectionMembership()

ilObjectCopyGUI::showSourceSelectionMembership ( )
protected

show target selection membership

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

References $tpl, $user, ilParticipants\_getMembershipByType(), ilUtil\sendInfo(), and setTabs().

380  {
381  $user = $this->user;
382  $tpl = $this->tpl;
383 
384  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_source'));
385  $this->setTabs(self::TAB_GROUP_SC_SELECTION, self::TAB_SELECTION_MEMBERSHIP);
386 
387  include_once './Services/Object/classes/class.ilObjectCopyCourseGroupSelectionTableGUI.php';
388  $cgs = new ilObjectCopyCourseGroupSelectionTableGUI($this, 'showSourceSelectionMembership', 'copy_selection_membership');
389  $cgs->init();
390  $cgs->setObjects(
391  array_merge(
392  ilParticipants::_getMembershipByType($user->getId(), 'crs', false),
393  ilParticipants::_getMembershipByType($user->getId(), 'grp', false)
394  )
395  );
396  $cgs->parse();
397 
398  $tpl->setContent($cgs->getHTML());
399  }
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setTabs($a_tab_group, $a_active_tab)
Set tabs.
+ Here is the call graph for this function:

◆ showSourceSelectionTree()

ilObjectCopyGUI::showSourceSelectionTree ( )

Show target selection.

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

References $_GET, $container, $ctrl, $ilCtrl, $obj_definition, Sabre\VObject\$output, $tabs, $toolbar, $tpl, $tree, getSources(), ilPasteIntoMultipleItemsExplorer\SEL_TYPE_RADIO, and ilUtil\sendInfo().

Referenced by initSourceSelection().

475  {
476  $ilTabs = $this->tabs;
477  $ilToolbar = $this->toolbar;
479  $tree = $this->tree;
480  $tpl = $this->tpl;
481  $objDefinition = $this->obj_definition;
482 
483  $this->tpl = $tpl;
484  $this->tpl->addBlockfile(
485  'ADM_CONTENT',
486  'adm_content',
487  'tpl.paste_into_multiple_objects.html',
488  "Services/Object"
489  );
490 
491  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_source'));
492  include_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
495  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto',
496  'paste_copy_repexpand'
497  );
498  $exp->setRequiredFormItemPermission('visible,read,copy');
499 
500  $ilCtrl->setParameter($this, 'selectMode', self::SOURCE_SELECTION);
501  $exp->setExpandTarget($ilCtrl->getLinkTarget($this, 'showSourceSelectionTree'));
502  $exp->setTargetGet('ref_id');
503  $exp->setPostVar('source');
504  $exp->setCheckedItems($this->getSources());
505 
506  // Filter to container
507  foreach (array('cat','root','fold') as $container) {
508  $exp->removeFormItemForType($container);
509  }
510 
511 
512  if ($_GET['paste_copy_repexpand'] == '') {
513  $expanded = $tree->readRootId();
514  } else {
515  $expanded = $_GET['paste_copy_repexpand'];
516  }
517 
518  $this->tpl->setVariable('FORM_TARGET', '_self');
519  $this->tpl->setVariable('FORM_ACTION', $ilCtrl->getFormAction($this, 'copySelection'));
520 
521  $exp->setExpand($expanded);
522  // build html-output
523  $exp->setOutput(0);
524  $output = $exp->getOutput();
525 
526  $this->tpl->setVariable('OBJECT_TREE', $output);
527 
528  $this->tpl->setVariable('CMD_SUBMIT', 'saveSource');
529  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('btn_next'));
530 
531  $ilToolbar->addButton($this->lng->txt('cancel'), $ilCtrl->getLinkTarget($this, 'cancel'));
532  }
getSources()
Get sources.
$_GET["client_id"]
$container
Definition: wac.php:13
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ 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 405 of file class.ilObjectCopyGUI.php.

References $ctrl, $ilCtrl, $lng, $obj_definition, Sabre\VObject\$output, $t, $tabs, $toolbar, $tpl, $tree, ilUtil\getImagePath(), ilSubmitButton\getInstance(), and ilUtil\sendInfo().

Referenced by initTargetSelection(), and saveTarget().

406  {
407  $ilTabs = $this->tabs;
408  $ilToolbar = $this->toolbar;
410  $tree = $this->tree;
411  $tpl = $this->tpl;
412  $objDefinition = $this->obj_definition;
413  $lng = $this->lng;
414 
415  $this->tpl = $tpl;
416 
417  if ($objDefinition->isContainer($this->getType())) {
418  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_container'));
419  } else {
420  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard'));
421  }
422 
423  //
424  include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
425  $exp = new ilRepositorySelectorExplorerGUI($this, "showTargetSelectionTree");
426  $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "fold", "lso", "prg"));
427  $exp->setSelectMode("target", true);
428  if ($exp->handleCommand()) {
429  return;
430  }
431  $output = $exp->getHTML();
432 
433  // toolbars
434  $t = new ilToolbarGUI();
435  $t->setFormAction($ilCtrl->getFormAction($this, "saveTarget"));
436  if ($objDefinition->isContainer($this->getType())) {
438  $btn->setCaption('btn_next');
439  $btn->setCommand('saveTarget');
440  $btn->setPrimary(true);
441  $t->addButtonInstance($btn);
442  } else {
444  $btn->setCaption('paste');
445  $btn->setCommand('saveTarget');
446  $btn->setPrimary(true);
447  $t->addButtonInstance($btn);
448  }
449  $t->addSeparator();
450  $clipboard_btn = ilSubmitButton::getInstance();
451  $clipboard_btn->setCaption('obj_insert_into_clipboard');
452  $clipboard_btn->setCommand('keepObjectsInClipboard');
453  $t->addButtonInstance($clipboard_btn);
454  $cancel_btn = ilSubmitButton::getInstance();
455  $cancel_btn->setCaption('cancel');
456  $cancel_btn->setCommand('cancel');
457  $t->addButtonInstance($cancel_btn);
458  $t->setCloseFormTag(false);
459  $t->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), " ");
460  $output = $t->getHTML() . $output;
461  $t->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), " ");
462  $t->setCloseFormTag(true);
463  $t->setOpenFormTag(false);
464  $output.= "<br />" . $t->getHTML();
465 
466  $this->tpl->setContent($output);
467 
468  return;
469  }
Explorer for selecting repository items.
global $ilCtrl
Definition: ilias.php:18
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)
+ 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 1265 of file class.ilObjectCopyGUI.php.

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

1266  {
1267  $ilUser = $this->user;
1268 
1269  return (bool) ilUtil::_getObjectsByOperations($this->getType(), 'copy', $ilUser->getId(), 1);
1270  }
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, instead it parses the serialized rbac_pa entries.
getType()
Returns $type.
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

◆ unsetSession()

ilObjectCopyGUI::unsetSession ( )
protected

Unset session variables.

Returns

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

References $_SESSION, and setSource().

Referenced by showSourceSearch().

1307  {
1308  unset($_SESSION['source_query']);
1309  $this->setSource(array());
1310  }
$_SESSION["AccountId"]
setSource(array $a_source_ids)
Set source id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateProgress()

ilObjectCopyGUI::updateProgress ( )
protected

Update progress.

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

References PHPMailer\PHPMailer\$options, ilCopyWizardOptions\_getInstance(), exit, and ilLoggerFactory\getLogger().

1155  {
1156  $json = new stdClass();
1157  $json->percentage = null;
1158  $json->performed_steps = null;
1159 
1160  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1161  $options = ilCopyWizardOptions::_getInstance((int) $_REQUEST['copy_id']);
1162  $json->required_steps = $options->getRequiredSteps();
1163  $json->id = (int) $_REQUEST['copy_id'];
1164 
1165  ilLoggerFactory::getLogger('obj')->debug('Update copy progress: ' . json_encode($json));
1166 
1167  echo json_encode($json);
1168  exit;
1169  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
exit
Definition: backend.php:16
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilObjectCopyGUI::$access
protected

◆ $ctrl

◆ $error

ilObjectCopyGUI::$error
protected

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

Referenced by copyContainer(), and copySingleObject().

◆ $lng

ilObjectCopyGUI::$lng
private

◆ $log

ilObjectCopyGUI::$log = null
private

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

Referenced by copyContainer().

◆ $mode

ilObjectCopyGUI::$mode = 0
private

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

Referenced by getMode().

◆ $obj_data_cache

ilObjectCopyGUI::$obj_data_cache
protected

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

Referenced by searchSource().

◆ $obj_definition

ilObjectCopyGUI::$obj_definition
protected

◆ $parent_obj

ilObjectCopyGUI::$parent_obj = null
private

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

Referenced by getParentObject().

◆ $rbacreview

ilObjectCopyGUI::$rbacreview
protected

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

Referenced by copyMultipleNonContainer(), and copySingleObject().

◆ $rbacsystem

ilObjectCopyGUI::$rbacsystem
protected

◆ $sources

ilObjectCopyGUI::$sources = array()
private

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

Referenced by getSources().

◆ $sub_mode

ilObjectCopyGUI::$sub_mode = self::SUBMODE_COMPLETE
private

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

Referenced by getSubMode().

◆ $tabs

ilObjectCopyGUI::$tabs
protected

◆ $targets

ilObjectCopyGUI::$targets = array()
private

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

Referenced by getFirstTarget(), and getTargets().

◆ $targets_copy_id

ilObjectCopyGUI::$targets_copy_id = array()
private

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

◆ $toolbar

ilObjectCopyGUI::$toolbar
protected

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

Referenced by showSourceSelectionTree(), and showTargetSelectionTree().

◆ $tpl

◆ $tree

◆ $type

ilObjectCopyGUI::$type = ''
private

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

Referenced by getType(), and setType().

◆ $user

ilObjectCopyGUI::$user
protected

◆ SEARCH_SOURCE

const ilObjectCopyGUI::SEARCH_SOURCE = 3

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

◆ SOURCE_SELECTION

const ilObjectCopyGUI::SOURCE_SELECTION = 1

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

◆ SUBMODE_COMPLETE

const ilObjectCopyGUI::SUBMODE_COMPLETE = 1

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

◆ SUBMODE_CONTENT_ONLY

const ilObjectCopyGUI::SUBMODE_CONTENT_ONLY = 2

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

Referenced by ilContainer\cloneAllObject().

◆ TAB_GROUP_SC_SELECTION

const ilObjectCopyGUI::TAB_GROUP_SC_SELECTION = 1

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

◆ TAB_SELECTION_MEMBERSHIP

const ilObjectCopyGUI::TAB_SELECTION_MEMBERSHIP = 3

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

◆ TAB_SELECTION_SOURCE_TREE

const ilObjectCopyGUI::TAB_SELECTION_SOURCE_TREE = 2

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

◆ TAB_SELECTION_TARGET_TREE

const ilObjectCopyGUI::TAB_SELECTION_TARGET_TREE = 1

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

◆ TARGET_SELECTION

const ilObjectCopyGUI::TARGET_SELECTION = 2

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


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