ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 getSource ()
 Get 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 282 of file class.ilObjectCopyGUI.php.

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

283  {
284  $GLOBALS['ilCtrl']->setParameter($this, 'smode', self::SUBMODE_CONTENT_ONLY);
285  $GLOBALS['ilCtrl']->setParameter($this, 'selectMode', self::SOURCE_SELECTION);
286 
287 
288  $this->setSubMode(self::SUBMODE_CONTENT_ONLY);
289  $this->setMode(self::SOURCE_SELECTION);
290  $this->setTarget((int) $_GET['ref_id']);
291 
292 
293  return $this->initSourceSelection();
294  }
setMode($a_mode)
set copy mode
initSourceSelection()
Init source selection.
$_GET["client_id"]
setTarget($a_ref_id)
Set single object target.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:

◆ cancel()

ilObjectCopyGUI::cancel ( )
protected

Cancel workflow.

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

References $ctrl, and $ilCtrl.

736  {
738  $ilCtrl->setReturnByClass(get_class($this->parent_obj), 'cancel');
739  $ilCtrl->returnToParent($this);
740  }
global $ilCtrl
Definition: ilias.php:18

◆ copyContainer()

ilObjectCopyGUI::copyContainer (   $a_target)
protected

Copy a container.

Returns

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

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

Referenced by copyContainerToTargets().

1142  {
1143  $ilLog = $this->log;
1144  $ilCtrl = $this->ctrl;
1145 
1146  include_once('./Services/Link/classes/class.ilLink.php');
1147  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1148 
1149  $ilAccess = $this->access;
1150  $ilErr = $this->error;
1152  $tree = $this->tree;
1153  $ilUser = $this->user;
1154  $ilCtrl = $this->ctrl;
1155 
1156  // Workaround for course in course copy
1157 
1160 
1161  if ($this->getSubMode() != self::SUBMODE_CONTENT_ONLY) {
1162  if (!$rbacsystem->checkAccess('create', $a_target, $this->getType())) {
1163  $this->log->notice('Permission denied for target: ' . $a_target . ' type: ' . $this->getType() . ' CREATE');
1164  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
1165  $ilCtrl->returnToParent($this);
1166  }
1167  }
1168  if (!$this->getFirstSource()) {
1169  ilUtil::sendFailure($this->lng->txt('select_one'), true);
1170  $ilCtrl->returnToParent($this);
1171  return false;
1172  }
1173 
1174  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1175 
1176 
1177  ilLoggerFactory::getLogger('obj')->debug('Copy container (sources): ' . print_r($this->getSources(), true));
1178 
1180  $result = $orig->cloneAllObject(
1181  $_COOKIE['PHPSESSID'],
1182  $_COOKIE['ilClientId'],
1183  $this->getType(),
1184  $a_target,
1185  $this->getFirstSource(),
1186  $options,
1187  false,
1188  $this->getSubMode()
1189  );
1190 
1191  $this->targets_copy_id[$a_target] = $result['copy_id'];
1192 
1193  return $result;
1194  }
global $ilErr
Definition: raiseError.php:16
getSources()
Get sources.
$_COOKIE['client_id']
Definition: server.php:9
$target_type
Definition: goto.php:48
$result
getType()
Returns $type.
global $ilCtrl
Definition: ilias.php:18
static _lookupObjId($a_id)
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
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"]
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 1065 of file class.ilObjectCopyGUI.php.

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

1066  {
1067  $ilCtrl = $this->ctrl;
1068 
1069  ilLoggerFactory::getLogger('obj')->debug('Copy container to targets: ' . print_r($_REQUEST, true));
1070  ilLoggerFactory::getLogger('obj')->debug('Source(s): ' . print_r($this->getSources(), true));
1071  ilLoggerFactory::getLogger('obj')->debug('Target(s): ' . print_r($this->getTargets(), true));
1072 
1073 
1074  $last_target = 0;
1075  $result = 1;
1076  foreach ($this->getTargets() as $target_ref_id) {
1077  $result = $this->copyContainer($target_ref_id);
1078  $last_target = $target_ref_id;
1079  }
1080 
1081  unset($_SESSION["clipboard"]["ref_ids"]);
1082  unset($_SESSION["clipboard"]["cmd"]);
1083 
1084  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1085  if (ilCopyWizardOptions::_isFinished($result['copy_id'])) {
1086  ilLoggerFactory::getLogger('obj')->info('Object copy completed.');
1087  ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
1088  $link = ilLink::_getLink($result['ref_id']);
1089  $GLOBALS['DIC']->ctrl()->redirectToUrl($link);
1090  } else {
1091  // show progress
1092  ilLoggerFactory::getLogger('obj')->debug('Object copy in progress.');
1093  return $this->showCopyProgress();
1094  }
1095  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getSources()
Get sources.
$_SESSION["AccountId"]
$result
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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 973 of file class.ilObjectCopyGUI.php.

References $_SESSION, $access, $ctrl, $ilCtrl, $ilUser, $obj_definition, $orig, $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(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

Referenced by copySingleObject(), and saveTarget().

974  {
975  $ilAccess = $this->access;
976  $objDefinition = $this->obj_definition;
981 
982 
983  include_once('./Services/Link/classes/class.ilLink.php');
984  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
985 
986  // check permissions
987  foreach ($a_sources as $source_ref_id) {
988  $source_type = ilObject::_lookupType($source_ref_id, true);
989 
990  // Create permission
991  // begin-patch mc
992  foreach ($this->getTargets() as $target_ref_id) {
993  if (!$rbacsystem->checkAccess('create', $target_ref_id, $source_type)) {
994  $this->log->notice('Permission denied for target_id: ' . $target_ref_id . ' source_type: ' . $source_type . ' CREATE');
995  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
996  $ilCtrl->returnToParent($this);
997  }
998  }
999 
1000  // Copy permission
1001  if (!$ilAccess->checkAccess('copy', '', $source_ref_id)) {
1002  $this->log->notice('Permission denied for source_ref_id: ' . $source_ref_id . ' COPY');
1003  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
1004  $ilCtrl->returnToParent($this);
1005  }
1006 
1007  // check that these objects are really not containers
1008  if ($objDefinition->isContainer($source_type) and $this->getSubMode() != self::SUBMODE_CONTENT_ONLY) {
1009  ilUtil::sendFailure($this->lng->txt('cntr_container_only_on_their_own'), true);
1010  $ilCtrl->returnToParent($this);
1011  }
1012  }
1013 
1014  reset($a_sources);
1015 
1016 
1017  ilLoggerFactory::getLogger('obj')->debug('Copy multiple non containers. Sources: ' . print_r($a_sources, true));
1018 
1019  // clone
1020  foreach ($a_sources as $source_ref_id) {
1021  ilLoggerFactory::getLogger('obj')->debug('Copying source ref_id : ' . $source_ref_id);
1022 
1023  // begin-patch mc
1024  foreach ($this->getTargets() as $target_ref_id) {
1025  // Save wizard options
1027  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1028  $wizard_options->saveOwner($ilUser->getId());
1029  $wizard_options->saveRoot((int) $source_ref_id);
1030  $wizard_options->read();
1031 
1032  $orig = ilObjectFactory::getInstanceByRefId((int) $source_ref_id);
1033  $new_obj = $orig->cloneObject($target_ref_id, $copy_id);
1034 
1035  // Delete wizard options
1036  $wizard_options->deleteAll();
1037 
1038  // rbac log
1039  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1040  if (ilRbacLog::isActive()) {
1041  $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
1042  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
1043  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int) $source_ref_id);
1044  }
1045  }
1046  }
1047 
1048  unset($_SESSION["clipboard"]["ref_ids"]);
1049  unset($_SESSION["clipboard"]["cmd"]);
1050 
1051  if (count($a_sources) == 1) {
1052  ilLoggerFactory::getLogger('obj')->info('Object copy completed.');
1053  ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
1054  ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1055  } else {
1056  ilLoggerFactory::getLogger('obj')->info('Object copy completed.');
1057  ilUtil::sendSuccess($this->lng->txt("objects_duplicated"), true);
1059  }
1060  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_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 946 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().

947  {
948  include_once('./Services/Link/classes/class.ilLink.php');
949  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
950 
951  $ilAccess = $this->access;
957 
958  // Source defined
959  if (!count($this->getSources())) {
960  ilUtil::sendFailure($this->lng->txt('select_one'), true);
961  $ilCtrl->returnToParent($this);
962  }
963 
964  $this->copyMultipleNonContainer($this->getSources());
965  return;
966  }
global $ilErr
Definition: raiseError.php:16
getSources()
Get sources.
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 679 of file class.ilObjectCopyGUI.php.

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

680  {
681  if (count($this->sources)) {
682  return $this->sources[0];
683  }
684  return 0;
685  }
+ Here is the caller graph for this function:

◆ getFirstTarget()

ilObjectCopyGUI::getFirstTarget ( )

Get first target.

Returns
int

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

References $targets, and getTargets().

Referenced by copyMultipleNonContainer(), and init().

723  {
724  if (array_key_exists(0, $this->getTargets())) {
725  $targets = $this->getTargets();
726  return $targets[0];
727  }
728  return 0;
729  }
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 605 of file class.ilObjectCopyGUI.php.

References $mode.

Referenced by setTabs(), and showItemSelection().

606  {
607  return $this->mode;
608  }
+ Here is the caller graph for this function:

◆ getParentObject()

ilObjectCopyGUI::getParentObject ( )

Get parent gui object.

Returns
object parent gui

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

References $parent_obj.

Referenced by init().

625  {
626  return $this->parent_obj;
627  }
+ Here is the caller graph for this function:

◆ getSource()

ilObjectCopyGUI::getSource ( )

Get source id.

Returns
array
Deprecated:
since version 5.1

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

References getSources().

666  {
667  return $this->getSources();
668  }
getSources()
Get sources.
+ Here is the call graph for this function:

◆ getSources()

ilObjectCopyGUI::getSources ( )

Get sources.

Returns
type

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

References $sources, and array.

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

675  {
676  return (array) $this->sources;
677  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getSubMode()

ilObjectCopyGUI::getSubMode ( )

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

References $sub_mode.

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

616  {
617  return $this->sub_mode;
618  }
+ Here is the caller graph for this function:

◆ getTargets()

ilObjectCopyGUI::getTargets ( )

Get copy target.

Returns

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

References $targets, and array.

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

714  {
715  return (array) $this->targets;
716  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getType()

ilObjectCopyGUI::getType ( )

Returns $type.

See also
ilObjectCopyGUI::$type

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

References $type.

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

635  {
636  return $this->type;
637  }
+ 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, $GLOBALS, $ilCtrl, ilObject\_lookupObjId(), ilObject\_lookupType(), array, 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  $GLOBALS['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  $GLOBALS['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  $GLOBALS['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  $GLOBALS['ilCtrl']->setParameter($this, 'new_type', $this->getType());
207  $GLOBALS['ilCtrl']->setParameterByClass(get_class($this->getParentObject()), 'new_type', $this->getType());
208  $GLOBALS['ilCtrl']->setParameterByClass(get_class($this->getParentObject()), 'cpfl', 1);
209  $GLOBALS['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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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.
Create styles array
The data for the language used.
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 1241 of file class.ilObjectCopyGUI.php.

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

Referenced by searchSource(), and showSourceSearch().

1242  {
1243  $lng = $this->lng;
1244  $ilCtrl = $this->ctrl;
1245 
1246  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1247  $this->form = new ilPropertyFormGUI();
1248  $this->form->setTableWidth('600px');
1249 
1250  $ilCtrl->setParameter($this, 'new_type', $this->getType());
1251 
1252  #$ilCtrl->setParameter($this, 'cp_mode', self::SOURCE_SELECTION);
1253  $this->form->setFormAction($ilCtrl->getFormAction($this));
1254  $this->form->setTitle($lng->txt($this->getType() . '_copy'));
1255 
1256  $this->form->addCommandButton('searchSource', $lng->txt('btn_next'));
1257  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
1258 
1259  $tit = new ilTextInputGUI($lng->txt('title'), 'tit');
1260  $tit->setSize(40);
1261  $tit->setMaxLength(70);
1262  $tit->setRequired(true);
1263  $tit->setInfo($lng->txt('wizard_title_info'));
1264  $this->form->addItem($tit);
1265  }
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 336 of file class.ilObjectCopyGUI.php.

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

Referenced by adoptContent().

337  {
339  $tree = $this->tree;
340 
341  // empty session on init
342  $_SESSION['paste_copy_repexpand'] = array();
343 
344  // copy opened nodes from repository explorer
345  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
346 
347  $this->setTabs(self::TAB_GROUP_SC_SELECTION, self::TAB_SELECTION_SOURCE_TREE);
348 
349 
350  // open current position
351  // begin-patch mc
352  foreach ($this->getTargets() as $target_ref_id) {
353  $path = $tree->getPathId($target_ref_id);
354  foreach ((array) $path as $node_id) {
355  if (!in_array($node_id, $_SESSION['paste_copy_repexpand'])) {
356  $_SESSION['paste_copy_repexpand'][] = $node_id;
357  }
358  }
359  }
360  // end-patch multi copy
361  $ilCtrl->setReturnByClass(get_class($this->parent_obj), '');
362  $this->showSourceSelectionTree();
363  }
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18
setTabs($a_tab_group, $a_active_tab)
Set tabs.
getTargets()
Get copy target.
Create styles array
The data for the language used.
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 $GLOBALS.

Referenced by executeCommand().

242  {
243  $GLOBALS['lng']->loadLanguageModule('cntr');
244  $GLOBALS['ilTabs']->clearTargets();
245  $GLOBALS['ilTabs']->setBackTarget(
246  $GLOBALS['lng']->txt('tab_back_to_repository'),
247  $GLOBALS['ilCtrl']->getParentReturn($this->parent_obj)
248  );
249  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the caller graph for this function:

◆ initTargetSelection()

ilObjectCopyGUI::initTargetSelection ( )
protected

Init copy from repository/search list commands.

Returns

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

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

301  {
303  $tree = $this->tree;
304  $ilCtrl->setParameter($this, 'selectMode', self::TARGET_SELECTION);
305  // empty session on init
306  $_SESSION['paste_copy_repexpand'] = array();
307 
308  // copy opened nodes from repository explorer
309  $_SESSION['paste_copy_repexpand'] = is_array($_SESSION['repexpand']) ? $_SESSION['repexpand'] : array();
310 
311  // begin-patch mc
312  $this->setTargets(array());
313  // cognos-blu-patch: end
314 
315  // open current position
316 
317  foreach ($this->getSources() as $source_id) {
318  if ($source_id) {
319  $path = $tree->getPathId($source_id);
320  foreach ((array) $path as $node_id) {
321  if (!in_array($node_id, $_SESSION['paste_copy_repexpand'])) {
322  $_SESSION['paste_copy_repexpand'][] = $node_id;
323  }
324  }
325  }
326  }
327 
328  $ilCtrl->setReturnByClass(get_class($this->parent_obj), '');
329  $this->showTargetSelectionTree();
330  }
getSources()
Get sources.
setTargets(array $a_target)
Set target id.
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18
Create styles array
The data for the language used.
showTargetSelectionTree()
Show target selection.
+ Here is the call graph for this function:

◆ keepObjectsInClipboard()

ilObjectCopyGUI::keepObjectsInClipboard ( )

Keep objects in clipboard.

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

References $_SESSION, $ctrl, $ilCtrl, getSources(), and ilUtil\sendSuccess().

746  {
747  ilUtil::sendSuccess($this->lng->txt("obj_inserted_clipboard"), true);
749  $_SESSION['clipboard']['cmd'] = "copy";
750  $_SESSION['clipboard']['ref_ids'] = $this->getSources();
751  $ilCtrl->returnToParent($this);
752  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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 819 of file class.ilObjectCopyGUI.php.

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

820  {
821  $objDefinition = $this->obj_definition;
822 
823  if (isset($_POST['source'])) {
824  $this->setSource(array((int) $_REQUEST['source']));
825  $this->setType(ilObject::_lookupType((int) $_REQUEST['source'], true));
826  $GLOBALS['ilCtrl']->setParameter($this, 'source_id', (int) $_REQUEST['source']);
827  } else {
828  ilUtil::sendFailure($this->lng->txt('select_one'));
829  $this->searchSource();
830  return false;
831  }
832 
833  // validate allowed subtypes
834  foreach ($this->getSources() as $source_ref_id) {
835  foreach ((array) $this->getTargets() as $target_ref_id) {
836  $target_type = ilObject::_lookupType($target_ref_id, true);
837  $target_class_name = ilObjectFactory::getClassByType($target_type);
838  $target_object = new $target_class_name($target_ref_id);
839  $possible_subtypes = $target_object->getPossibleSubObjects();
840 
841  $source_type = ilObject::_lookupType($source_ref_id, true);
842 
843  if (!array_key_exists($source_type, $possible_subtypes)) {
844  #ilLoggerFactory::getLogger('obj')->debug('Source type: '. $source_type);
845  #ilLoggerFactory::getLogger('obj')->debug('Target type: '. $target_type);
846  #ilLoggerFactory::getLogger('obj')->debug('Submode: '. $this->getSubMode());
847 
848  // adopt content mode
849  if (
850  $this->getSubMode() != self::SUBMODE_CONTENT_ONLY and
851  ($source_type != 'crs' or $target_type != 'crs')
852  ) {
854  sprintf(
855  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
856  $this->lng->txt('obj_' . $target_type),
857  $this->lng->txt('obj_' . $source_type)
858  )
859  );
860  $this->searchSource();
861  return false;
862  }
863  }
864  }
865  }
866 
867 
868  if ($objDefinition->isContainer($this->getType())) {
869  $this->showItemSelection();
870  } else {
871  $this->copySingleObject();
872  }
873  }
static getClassByType($a_obj_type)
Get class by type.
getSources()
Get sources.
$target_type
Definition: goto.php:48
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setSource(array $a_source_ids)
Set source id.
copySingleObject()
Start cloning a single (not container) object.
getTargets()
Get copy target.
Create styles array
The data for the language used.
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 878 of file class.ilObjectCopyGUI.php.

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

879  {
880  $objDefinition = $this->obj_definition;
881 
882  if (!isset($_REQUEST['source'])) {
883  ilUtil::sendFailure($this->lng->txt('select_one'));
884  $GLOBALS['ilCtrl']->redirect($this, 'showSourceSelectionMembership');
885  return false;
886  }
887 
888  $this->setSource(array((int) $_REQUEST['source']));
889  $this->setType(ilObject::_lookupType((int) $this->getFirstSource(), true));
890  $GLOBALS['ilCtrl']->setParameter($this, 'source_id', (int) $_REQUEST['source']);
891 
892  if ($objDefinition->isContainer($this->getType())) {
893  $this->showItemSelection();
894  } else {
895  $this->copySingleObject();
896  }
897  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setSource(array $a_source_ids)
Set source id.
copySingleObject()
Start cloning a single (not container) object.
Create styles array
The data for the language used.
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 513 of file class.ilObjectCopyGUI.php.

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

514  {
515  $objDefinition = $this->obj_definition;
516  $tree = $this->tree;
518 
519 
520  // begin-patch mc
521  if (is_array($_REQUEST['target']) and $_REQUEST['target']) {
522  $this->setTargets($_REQUEST['target']);
523  $GLOBALS['ilCtrl']->setParameter($this, 'target_ids', implode('_', $this->getTargets()));
524  }
525  // paste from clipboard
526  elseif ((int) $_REQUEST['target']) {
527  $this->setTarget($_REQUEST['target']);
528  $GLOBALS['ilCtrl']->setParameter($this, 'target_ids', implode('_', $this->getTargets()));
529  }
530  // end-patch multi copy
531  else {
532  $ilCtrl->setParameter($this, 'selectMode', self::TARGET_SELECTION);
533  ilUtil::sendFailure($this->lng->txt('select_one'));
534  $this->showTargetSelectionTree();
535  return false;
536  }
537 
538  // validate allowed subtypes
539  foreach ($this->getSources() as $source_ref_id) {
540  foreach ((array) $this->getTargets() as $target_ref_id) {
541  $target_type = ilObject::_lookupType($target_ref_id, true);
542  $target_class_name = ilObjectFactory::getClassByType($target_type);
543  $target_object = new $target_class_name($target_ref_id);
544  $possible_subtypes = $target_object->getPossibleSubObjects();
545 
546  $source_type = ilObject::_lookupType($source_ref_id, true);
547 
548  if (!array_key_exists($source_type, (array) $possible_subtypes)) {
550  sprintf(
551  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
552  $this->lng->txt('obj_' . $target_type),
553  $this->lng->txt('obj_' . $source_type)
554  )
555  );
556  $this->showTargetSelectionTree();
557  return false;
558  }
559  }
560  }
561 
562  if ((count($this->getSources()) == 1) && $objDefinition->isContainer($this->getType())) {
563  // check, if object should be copied into itself
564  // begin-patch mc
565  $is_child = array();
566  foreach ($this->getTargets() as $target_ref_id) {
567  if ($tree->isGrandChild($this->getFirstSource(), $target_ref_id)) {
569  }
570  if ($this->getFirstSource() == $target_ref_id) {
572  }
573  }
574  // end-patch multi copy
575  if (count($is_child) > 0) {
576  ilUtil::sendFailure($this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child));
577  $this->showTargetSelectionTree();
578  return false;
579  }
580 
581  $this->showItemSelection();
582  } else {
583  if (count($this->getSources()) == 1) {
584  $this->copySingleObject();
585  } else {
586  $this->copyMultipleNonContainer($this->getSources());
587  }
588  }
589  }
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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.
Create styles array
The data for the language used.
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 759 of file class.ilObjectCopyGUI.php.

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

Referenced by saveSource(), and showItemSelection().

760  {
761  $tree = $this->tree;
762  $ilObjDataCache = $this->obj_data_cache;
763  $lng = $this->lng;
765  $tpl = $this->tpl;
766 
767  if (isset($_POST['tit'])) {
768  ilUtil::sendInfo($this->lng->txt('wizard_search_list'));
769  $_SESSION['source_query'] = $_POST['tit'];
770  } else {
771  $_POST['tit'] = $_SESSION['source_query'];
772  }
773 
774  $this->initFormSearch();
775  $this->form->setValuesByPost();
776 
777  if (!$this->form->checkInput()) {
778  ilUtil::sendFailure($lng->txt('msg_no_search_string'), true);
779  $ilCtrl->returnToParent($this);
780  return false;
781  }
782 
783  include_once './Services/Search/classes/class.ilQueryParser.php';
784  $query_parser = new ilQueryParser($this->form->getInput('tit'));
785  $query_parser->setMinWordLength(1, true);
786  $query_parser->setCombination(QP_COMBINATION_AND);
787  $query_parser->parse();
788  if (!$query_parser->validate()) {
789  ilUtil::sendFailure($query_parser->getMessage(), true);
790  $ilCtrl->returnToParent($this);
791  }
792 
793  // only like search since fulltext does not support search with less than 3 characters
794  include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
795  $object_search = new ilLikeObjectSearch($query_parser);
796  $object_search->setFilter(array($_REQUEST['new_type']));
797  $res = $object_search->performSearch();
798  $res->setRequiredPermission('copy');
799  $res->filter(ROOT_FOLDER_ID, true);
800 
801  if (!count($results = $res->getResultsByObjId())) {
802  ilUtil::sendFailure($this->lng->txt('search_no_match'), true);
803  $ilCtrl->returnToParent($this);
804  }
805 
806 
807  include_once './Services/Object/classes/class.ilObjectCopySearchResultTableGUI.php';
808  $table = new ilObjectCopySearchResultTableGUI($this, 'searchSource', $this->getType());
809  $table->setFormAction($GLOBALS['ilCtrl']->getFormAction($this));
810  $table->setSelectedReference($this->getFirstSource());
811  $table->parseSearchResults($results);
812  $tpl->setContent($table->getHTML());
813  }
$_SESSION["AccountId"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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
Create styles array
The data for the language used.
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 596 of file class.ilObjectCopyGUI.php.

Referenced by adoptContent(), and init().

597  {
598  $this->mode = $a_mode;
599  }
+ 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 655 of file class.ilObjectCopyGUI.php.

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

656  {
657  $this->sources = $a_source_ids;
658  }
+ Here is the caller graph for this function:

◆ setSubMode()

ilObjectCopyGUI::setSubMode (   $a_mode)

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

Referenced by adoptContent(), and init().

611  {
612  $this->sub_mode = $a_mode;
613  }
+ 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 256 of file class.ilObjectCopyGUI.php.

References $GLOBALS, getMode(), and getSubMode().

Referenced by initSourceSelection(), and showSourceSelectionMembership().

257  {
258  if ($a_tab_group == self::TAB_GROUP_SC_SELECTION) {
259  if ($this->getSubMode() == self::SUBMODE_CONTENT_ONLY) {
260  if ($this->getMode() == self::SOURCE_SELECTION) {
261  $GLOBALS['ilTabs']->addTab(
262  self::TAB_SELECTION_SOURCE_TREE,
263  $GLOBALS['lng']->txt('cntr_copy_repo_tree'),
264  $GLOBALS['ilCtrl']->getLinkTarget($this, 'initSourceSelection')
265  );
266  $GLOBALS['ilTabs']->addTab(
267  self::TAB_SELECTION_MEMBERSHIP,
268  $GLOBALS['lng']->txt('cntr_copy_crs_grp'),
269  $GLOBALS['ilCtrl']->getLinkTarget($this, 'showSourceSelectionMembership')
270  );
271  }
272  }
273  }
274  $GLOBALS['ilTabs']->activateTab($a_active_tab);
275  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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 693 of file class.ilObjectCopyGUI.php.

References array, and setTargets().

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

694  {
695  $this->setTargets(array($a_ref_id));
696  }
setTargets(array $a_target)
Set target id.
Create styles array
The data for the language used.
+ 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 704 of file class.ilObjectCopyGUI.php.

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

705  {
706  $this->targets = $a_target;
707  }
+ Here is the caller graph for this function:

◆ setType()

ilObjectCopyGUI::setType (   $type)

Sets $type.

Parameters
object$type
See also
ilObjectCopyGUI::$type

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

References $type.

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

646  {
647  $this->type = $type;
648  }
+ Here is the caller graph for this function:

◆ showCopyProgress()

ilObjectCopyGUI::showCopyProgress ( )
protected

Show progress for copying.

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

References $_GET, and $GLOBALS.

Referenced by copyContainerToTargets().

1101  {
1102  include_once './Services/Object/classes/class.ilObjectCopyProgressTableGUI.php';
1103  $progress = new ilObjectCopyProgressTableGUI(
1104  $this,
1105  'showCopyProgress',
1106  (int) $_GET['ref_id']
1107  );
1108  $progress->setObjectInfo($this->targets_copy_id);
1109  $progress->parse();
1110  $progress->init();
1111  $progress->setRedirectionUrl($GLOBALS['ilCtrl']->getParentReturn($this->parent_obj));
1112 
1113  $GLOBALS['tpl']->setContent($progress->getHTML());
1114  }
$_GET["client_id"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the caller graph for this function:

◆ showItemSelection()

ilObjectCopyGUI::showItemSelection ( )
protected
Returns

Definition at line 903 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().

904  {
905  $tpl = $this->tpl;
906 
907  if (!count($this->getSources())) {
908  ilUtil::sendFailure($this->lng->txt('select_one'));
909  $this->searchSource();
910  return false;
911  }
912 
913  ilLoggerFactory::getLogger('obj')->debug('Source(s): ' . print_r($this->getSources(), true));
914  ilLoggerFactory::getLogger('obj')->debug('Target(s): ' . print_r($this->getTargets(), true));
915 
916  ilUtil::sendInfo($this->lng->txt($this->getType() . '_copy_threads_info'));
917  include_once './Services/Object/classes/class.ilObjectCopySelectionTableGUI.php';
918 
919  $tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
920  $tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
921 
922  switch ($this->getMode()) {
923  case self::SOURCE_SELECTION:
924  $back_cmd = 'showSourceSelectionTree';
925  break;
926 
927  case self::TARGET_SELECTION:
928  $back_cmd = 'showTargetSelectionTree';
929  break;
930 
931  case self::SEARCH_SOURCE:
932  $back_cmd = 'searchSource';
933  break;
934  }
935 
936  $table = new ilObjectCopySelectionTableGUI($this, 'showItemSelection', $this->getType(), $back_cmd);
937  $table->parseSource($this->getFirstSource());
938 
939  $tpl->setContent($table->getHTML());
940  }
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 1205 of file class.ilObjectCopyGUI.php.

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

1206  {
1207  $tpl = $this->tpl;
1208 
1209  // Disabled for performance
1210  #if(!$this->sourceExists())
1211  #{
1212  # return false;
1213  #}
1214 
1215  $this->unsetSession();
1216  $this->initFormSearch();
1217 
1218  if ($a_tplvar) {
1219  $tpl->setVariable($a_tplvar, $this->form->getHTML());
1220  } else {
1221  return $this->form;
1222  }
1223  }
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 369 of file class.ilObjectCopyGUI.php.

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

370  {
371  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_source'));
372  $this->setTabs(self::TAB_GROUP_SC_SELECTION, self::TAB_SELECTION_MEMBERSHIP);
373 
374  include_once './Services/Object/classes/class.ilObjectCopyCourseGroupSelectionTableGUI.php';
375  $cgs = new ilObjectCopyCourseGroupSelectionTableGUI($this, 'showSourceSelectionMembership', 'copy_selection_membership');
376  $cgs->init();
377  $cgs->setObjects(
378  array_merge(
379  ilParticipants::_getMembershipByType($GLOBALS['ilUser']->getId(), 'crs', false),
380  ilParticipants::_getMembershipByType($GLOBALS['ilUser']->getId(), 'grp', false)
381  )
382  );
383  $cgs->parse();
384 
385  $GLOBALS['tpl']->setContent($cgs->getHTML());
386  }
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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 449 of file class.ilObjectCopyGUI.php.

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

Referenced by initSourceSelection().

450  {
451  $ilTabs = $this->tabs;
452  $ilToolbar = $this->toolbar;
454  $tree = $this->tree;
455  $tpl = $this->tpl;
456  $objDefinition = $this->obj_definition;
457 
458  $this->tpl = $tpl;
459  $this->tpl->addBlockfile(
460  'ADM_CONTENT',
461  'adm_content',
462  'tpl.paste_into_multiple_objects.html',
463  "Services/Object"
464  );
465 
466  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_source'));
467  include_once './Services/Object/classes/class.ilPasteIntoMultipleItemsExplorer.php';
470  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto',
471  'paste_copy_repexpand'
472  );
473  $exp->setRequiredFormItemPermission('visible,read,copy');
474 
475  $ilCtrl->setParameter($this, 'selectMode', self::SOURCE_SELECTION);
476  $exp->setExpandTarget($ilCtrl->getLinkTarget($this, 'showSourceSelectionTree'));
477  $exp->setTargetGet('ref_id');
478  $exp->setPostVar('source');
479  $exp->setCheckedItems($this->getSources());
480 
481  // Filter to container
482  foreach (array('cat','root','fold') as $container) {
483  $exp->removeFormItemForType($container);
484  }
485 
486 
487  if ($_GET['paste_copy_repexpand'] == '') {
488  $expanded = $tree->readRootId();
489  } else {
490  $expanded = $_GET['paste_copy_repexpand'];
491  }
492 
493  $this->tpl->setVariable('FORM_TARGET', '_self');
494  $this->tpl->setVariable('FORM_ACTION', $ilCtrl->getFormAction($this, 'copySelection'));
495 
496  $exp->setExpand($expanded);
497  // build html-output
498  $exp->setOutput(0);
499  $output = $exp->getOutput();
500 
501  $this->tpl->setVariable('OBJECT_TREE', $output);
502 
503  $this->tpl->setVariable('CMD_SUBMIT', 'saveSource');
504  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('btn_next'));
505 
506  $ilToolbar->addButton($this->lng->txt('cancel'), $ilCtrl->getLinkTarget($this, 'cancel'));
507  }
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.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Create styles array
The data for the language used.
+ 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 392 of file class.ilObjectCopyGUI.php.

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

Referenced by initTargetSelection(), and saveTarget().

393  {
394  $ilTabs = $this->tabs;
395  $ilToolbar = $this->toolbar;
397  $tree = $this->tree;
398  $tpl = $this->tpl;
399  $objDefinition = $this->obj_definition;
400  $lng = $this->lng;
401 
402  $this->tpl = $tpl;
403 
404  if ($objDefinition->isContainer($this->getType())) {
405  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard_container'));
406  } else {
407  ilUtil::sendInfo($this->lng->txt('msg_copy_clipboard'));
408  }
409 
410  //
411  include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
412  $exp = new ilRepositorySelectorExplorerGUI($this, "showTargetSelectionTree");
413  $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "fold"));
414  // begin-patch mc
415  $exp->setSelectMode("target", true);
416  // end-patch multi copy
417  if ($exp->handleCommand()) {
418  return;
419  }
420  $output = $exp->getHTML();
421 
422  // toolbars
423  $t = new ilToolbarGUI();
424  $t->setFormAction($ilCtrl->getFormAction($this, "saveTarget"));
425  if ($objDefinition->isContainer($this->getType())) {
426  $t->addFormButton($lng->txt("btn_next"), "saveTarget");
427  } else {
428  $t->addFormButton($lng->txt("paste"), "saveTarget");
429  }
430  $t->addSeparator();
431  $t->addFormButton($lng->txt("obj_insert_into_clipboard"), "keepObjectsInClipboard");
432  $t->addFormButton($lng->txt("cancel"), "cancel");
433  $t->setCloseFormTag(false);
434  $t->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), " ");
435  $output = $t->getHTML() . $output;
436  $t->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), " ");
437  $t->setCloseFormTag(true);
438  $t->setOpenFormTag(false);
439  $output.= "<br />" . $t->getHTML();
440 
441  $this->tpl->setContent($output);
442 
443  return;
444  }
Explorer for selecting repository items.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Create styles array
The data for the language used.
+ 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 1230 of file class.ilObjectCopyGUI.php.

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

1231  {
1232  $ilUser = $this->user;
1233 
1234  return (bool) ilUtil::_getObjectsByOperations($this->getType(), 'copy', $ilUser->getId(), 1);
1235  }
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 1271 of file class.ilObjectCopyGUI.php.

References $_SESSION, array, and setSource().

Referenced by showSourceSearch().

1272  {
1273  unset($_SESSION['source_query']);
1274  $this->setSource(array());
1275  }
$_SESSION["AccountId"]
setSource(array $a_source_ids)
Set source id.
Create styles array
The data for the language used.
+ 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 1119 of file class.ilObjectCopyGUI.php.

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

1120  {
1121  $json = new stdClass();
1122  $json->percentage = null;
1123  $json->performed_steps = null;
1124 
1125  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1126  $options = ilCopyWizardOptions::_getInstance((int) $_REQUEST['copy_id']);
1127  $json->required_steps = $options->getRequiredSteps();
1128  $json->id = (int) $_REQUEST['copy_id'];
1129 
1130  ilLoggerFactory::getLogger('obj')->debug('Update copy progress: ' . json_encode($json));
1131 
1132  echo json_encode($json);
1133  exit;
1134  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static getLogger($a_component_id)
Get component logger.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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

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

Referenced by showSourceSelectionTree(), and showTargetSelectionTree().

◆ $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

ilObjectCopyGUI::$tpl
protected

◆ $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: