ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjectCopyGUI Class Reference

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

+ Collaboration diagram for ilObjectCopyGUI:

Public Member Functions

 executeCommand ()
 
 setMode (int $mode)
 
 getMode ()
 
 setSubMode (int $mode)
 
 getSubMode ()
 
 getParentObject ()
 Get parent gui object. More...
 
 getType ()
 
 setType (string $type)
 
 setSource (array $source_ids)
 
 getSources ()
 
 getFirstSource ()
 
 setTarget (int $ref_id)
 
 setTargets (array $targets)
 
 getTargets ()
 
 getFirstTarget ()
 
 keepObjectsInClipboard ()
 
 copyMultipleNonContainer (array $sources)
 Copy multiple non container. More...
 
 showSourceSearch (?string $tpl_var)
 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 ()
 
 initTabs ()
 
 setTabs (int $tab_group, int $active_tab)
 
 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 ()
 
 showSourceSelectionMembership ()
 show target selection membership More...
 
 showTargetSelectionTree ()
 
 showSourceSelectionTree ()
 
 saveTarget ()
 
 cancel ()
 
 searchSource ()
 
 saveSource ()
 
 saveSourceMembership ()
 Save selected source from membership screen. More...
 
 showCopyPageSelection ()
 
 saveCopyPage ()
 
 showItemSelection (bool $copy_page=false)
 
 copySingleObject ()
 Start cloning a single (not container) object. More...
 
 copyContainerToTargets ()
 
 showCopyProgress ()
 
 updateProgress ()
 
 copyContainer (int $target_ref_id)
 
 initFormSearch ()
 
 unsetSession ()
 Unset session variables. More...
 

Protected Attributes

ilCtrl $ctrl
 
ilTree $tree
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilObjectDefinition $obj_definition
 
ilObjectDataCache $obj_data_cache
 
ilAccessHandler $access
 
ilErrorHandling $error
 
ilRbacSystem $rbacsystem
 
ilObjUser $user
 
ilRbacReview $rbacreview
 
ilLogger $log
 
ilLanguage $lng
 
RequestWrapper $request_wrapper
 
ArrayBasedRequestWrapper $post_wrapper
 
Refinery $refinery
 
ServerRequestInterface $request
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
ContainerDBRepository $container_repo
 
ImplementsCreationCallback $parent_obj = null
 
ClipboardManager $clipboard
 
int $mode = 0
 
int $sub_mode = self::SUBMODE_COMPLETE
 
string $type = ''
 
array $sources = []
 
array $targets = []
 
array $targets_copy_id = []
 
ilPropertyFormGUI $form
 

Private Member Functions

 getPrimaryButtonLabel ()
 
 getOnLoadCode (string $cmd)
 
 getErrorMessageOnDisallowedObjectTypeForTarget (int $ref_id)
 
 executeNextStepAfterSourceSelection ()
 
 buildCopyPageSelectionForm ()
 
 isCopyingParentPageNeeded ()
 
 copyParentPage ()
 

Private Attributes

ilObjectRequestRetriever $retriever
 

Detailed Description

Member Function Documentation

◆ adoptContent()

ilObjectCopyGUI::adoptContent ( )
protected

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

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

References ILIAS\Repository\ctrl(), initSourceSelection(), setMode(), setSubMode(), and setTarget().

239  : void
240  {
241  $this->ctrl->setParameter($this, 'smode', self::SUBMODE_CONTENT_ONLY);
242  $this->ctrl->setParameter($this, 'selectMode', self::SOURCE_SELECTION);
243 
244  $this->setSubMode(self::SUBMODE_CONTENT_ONLY);
245  $this->setMode(self::SOURCE_SELECTION);
246  $this->setTarget($this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int()));
247 
248  $this->initSourceSelection();
249  }
+ Here is the call graph for this function:

◆ buildCopyPageSelectionForm()

ilObjectCopyGUI::buildCopyPageSelectionForm ( )
private

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

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by saveCopyPage(), and showCopyPageSelection().

780  : Standard
781  {
782  $form_action = $this->ctrl->getFormAction($this, 'saveCopyPage');
783 
784  $input = [
785  'copy_page' => $this->ui_factory->input()->field()
786  ->radio(
787  $this->lng->txt('cntr_adopt_content')
788  )
789  ->withOption('1', $this->lng->txt('copy_container_page_yes_label'), $this->lng->txt('copy_container_page_yes_byline'))
790  ->withOption('0', $this->lng->txt('copy_container_page_no_label'))
791  ->withValue('1')
792  ->withAdditionalTransformation($this->refinery->kindlyTo()->bool())
793  ];
794 
795  return $this->ui_factory->input()->container()->form()
796  ->standard($form_action, $input)
797  ->withSubmitLabel($this->lng->txt('next'));
798  }
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
This describes a standard form.
Definition: Standard.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

ilObjectCopyGUI::cancel ( )
protected

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

References $ctrl, and ilCtrl\setReturnByClass().

614  : void
615  {
616  $ilCtrl = $this->ctrl;
617  $ilCtrl->setReturnByClass(get_class($this->parent_obj), 'cancel');
618  $ilCtrl->returnToParent($this);
619  }
setReturnByClass(string $a_class, ?string $a_cmd=null)
+ Here is the call graph for this function:

◆ copyContainer()

ilObjectCopyGUI::copyContainer ( int  $target_ref_id)
protected

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

References $_COOKIE, CLIENT_ID, ILIAS\Repository\ctrl(), getFirstSource(), ilObjectFactory\getInstanceByRefId(), getSources(), getSubMode(), getType(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by copyContainerToTargets().

1050  : array
1051  {
1052  if ($this->getSubMode() != self::SUBMODE_CONTENT_ONLY) {
1053  if (!$this->rbacsystem->checkAccess('create', $target_ref_id, $this->getType())) {
1054  $this->log->notice(
1055  'Permission denied for target: ' .
1056  $target_ref_id .
1057  ' type: ' .
1058  $this->getType() .
1059  ' CREATE'
1060  );
1061  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
1062  $this->ctrl->returnToParent($this);
1063  }
1064  }
1065 
1066  if (!$this->getFirstSource()) {
1067  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
1068  $this->ctrl->returnToParent($this);
1069  }
1070 
1071  $options = [];
1072  if ($this->post_wrapper->has("cp_options")) {
1073  $options = $this->post_wrapper->retrieve(
1074  "cp_options",
1075  $this->refinery->kindlyTo()->dictOf(
1076  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
1077  )
1078  );
1079  }
1080 
1081  $this->log->debug('Copy container (sources): ' . print_r($this->getSources(), true));
1082 
1084  $result = $orig->cloneAllObject(
1085  $_COOKIE[session_name()],
1086  CLIENT_ID,
1087  $this->getType(),
1088  $target_ref_id,
1089  $this->getFirstSource(),
1090  $options,
1091  false,
1092  $this->getSubMode()
1093  );
1094 
1095  $this->targets_copy_id[$target_ref_id] = $result['copy_id'];
1096 
1097  $new_ref_id = (int) $result['ref_id'];
1098  if ($new_ref_id > 0) {
1099  $new_obj = ilObjectFactory::getInstanceByRefId((int) $result['ref_id'], false);
1100  if ($new_obj instanceof ilObject) {
1101  $this->parent_obj->callCreationCallback(
1102  $new_obj,
1103  $this->obj_definition,
1104  $this->retriever->getMaybeInt('crtcb', 0)
1105  );
1106  }
1107  }
1108  return $result;
1109  }
const CLIENT_ID
Definition: constants.php:41
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
$_COOKIE[session_name()]
Definition: xapitoken.php:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyContainerToTargets()

ilObjectCopyGUI::copyContainerToTargets ( )
protected

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

References ilCopyWizardOptions\_isFinished(), copyContainer(), copyParentPage(), ILIAS\Repository\ctrl(), getSources(), getSubMode(), getTargets(), isCopyingParentPageNeeded(), ILIAS\Repository\lng(), and showCopyProgress().

929  : void
930  {
931  $this->log->debug('Copy container to targets: ' . print_r($_REQUEST, true));
932  $this->log->debug('Source(s): ' . print_r($this->getSources(), true));
933  $this->log->debug('Target(s): ' . print_r($this->getTargets(), true));
934 
935  if ($this->isCopyingParentPageNeeded()) {
936  $this->copyParentPage();
937  }
938 
939  $result = 1;
940  foreach ($this->getTargets() as $target_ref_id) {
941  $result = $this->copyContainer((int) $target_ref_id);
942  }
943 
944  $this->clipboard->clear();
945 
946  if (ilCopyWizardOptions::_isFinished($result['copy_id'])) {
947  $this->log->info('Object copy completed.');
948  $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_duplicated"), true);
949  if ($this->getSubMode() == self::SUBMODE_CONTENT_ONLY) {
950  $this->ctrl->returnToParent($this);
951  }
952  $link = ilLink::_getLink($result['ref_id']);
953  $this->ctrl->redirectToURL($link);
954  } else {
955  $this->log->debug('Object copy in progress.');
956  $this->showCopyProgress();
957  }
958  }
static _isFinished(int $a_copy_id)
copyContainer(int $target_ref_id)
+ Here is the call graph for this function:

◆ copyMultipleNonContainer()

ilObjectCopyGUI::copyMultipleNonContainer ( array  $sources)

Copy multiple non container.

Parameters
array$sourcesarray of source ref ids

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

References $ref_id, ilCopyWizardOptions\_allocateCopyId(), ilCopyWizardOptions\_getInstance(), ilObject\_lookupType(), ILIAS\Repository\access(), ilRbacLog\add(), ilRbacLog\COPY_OBJECT, ILIAS\Repository\ctrl(), ilRbacLog\gatherFaPa(), getFirstTarget(), ilObjectFactory\getInstanceByRefId(), ilLoggerFactory\getLogger(), getSubMode(), getTargets(), ilRbacLog\isActive(), ILIAS\Repository\lng(), null, ilUtil\redirect(), and ILIAS\Repository\user().

Referenced by copySingleObject(), and saveTarget().

840  : void
841  {
842  // check permissions
843  foreach ($sources as $source_ref_id) {
844  $source_type = ilObject::_lookupType($source_ref_id, true);
845 
846  // Create permission
847  // begin-patch mc
848  foreach ($this->getTargets() as $target_ref_id) {
849  if (!$this->rbacsystem->checkAccess('create', $target_ref_id, $source_type)) {
850  $this->log->notice(
851  'Permission denied for target_id: ' .
852  $target_ref_id .
853  ' source_type: ' .
854  $source_type .
855  ' CREATE'
856  );
857  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
858  $this->ctrl->returnToParent($this);
859  }
860  }
861 
862  // Copy permission
863  if (!$this->access->checkAccess('copy', '', $source_ref_id)) {
864  $this->log->notice('Permission denied for source_ref_id: ' . $source_ref_id . ' COPY');
865  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
866  $this->ctrl->returnToParent($this);
867  }
868 
869  // check that these objects are really not containers
870  if ($this->obj_definition->isContainer($source_type) and $this->getSubMode() != self::SUBMODE_CONTENT_ONLY) {
871  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('cntr_container_only_on_their_own'), true);
872  $this->ctrl->returnToParent($this);
873  }
874  }
875 
876  reset($sources);
877 
878 
879  ilLoggerFactory::getLogger('obj')->debug('Copy multiple non containers. Sources: ' . print_r($sources, true));
880 
881  $new_obj = null;
882  // clone
883  foreach ($sources as $source_ref_id) {
884  ilLoggerFactory::getLogger('obj')->debug('Copying source ref_id : ' . $source_ref_id);
885 
886  // begin-patch mc
887  foreach ($this->getTargets() as $target_ref_id) {
888  // Save wizard options
890  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
891  $wizard_options->saveOwner($this->user->getId());
892  $wizard_options->saveRoot((int) $source_ref_id);
893  $wizard_options->read();
894 
895  $orig = ilObjectFactory::getInstanceByRefId((int) $source_ref_id);
896  $new_obj = $orig->cloneObject($target_ref_id, $copy_id);
897 
898  // Delete wizard options
899  $wizard_options->deleteAll();
900  $this->parent_obj->callCreationCallback(
901  $new_obj,
902  $this->obj_definition,
903  $this->retriever->getMaybeInt('crtcb', 0)
904  );
905 
906  // rbac log
907  if (ilRbacLog::isActive()) {
908  $rbac_log_roles = $this->rbacreview->getParentRoleIds($new_obj->getRefId());
909  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
910  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (bool) $source_ref_id);
911  }
912  }
913  }
914 
915  $this->clipboard->clear();
916  $this->log->info('Object copy completed.');
917  if (count($sources) == 1) {
918  $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_duplicated"), true);
919  $ref_id = $new_obj->getRefId();
920  } else {
921  $this->tpl->setOnScreenMessage('success', $this->lng->txt("objects_duplicated"), true);
922  $ref_id = $this->getFirstTarget();
923  }
924 
925  $this->tpl->setOnScreenMessage('success', $this->lng->txt("objects_duplicated"), true);
926  ilUtil::redirect(ilLink::_getLink($ref_id));
927  }
static getLogger(string $a_component_id)
Get component logger.
static isActive()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static gatherFaPa(int $ref_id, array $role_ids, bool $add_action=false)
$ref_id
Definition: ltiauth.php:65
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
const COPY_OBJECT
static _allocateCopyId()
Allocate a copy for further entries.
static redirect(string $a_script)
static add(int $action, int $ref_id, array $diff, bool $source_ref_id=false)
static _getInstance(int $a_copy_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyParentPage()

ilObjectCopyGUI::copyParentPage ( )
private

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

References ilPageObject\_exists(), ilObjStyleSheet\_lookupStandard(), ilPageObject\copy(), getFirstSource(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), getParentObject(), ilObjStyleSheet\lookupObjectStyle(), ilObjStyleSheet\writeOwner(), and ilObjStyleSheet\writeStyleUsage().

Referenced by copyContainerToTargets().

966  : void
967  {
968  $source_object = ilObjectFactory::getInstanceByRefId($this->getFirstSource());
969  $target_object = $this->getParentObject()->getObject();
971  "cont",
972  $source_object->getId()
973  )) {
974  $orig_page = new ilContainerPage($source_object->getId());
975  $orig_page->copy($target_object->getId(), "cont", $target_object->getId());
976  }
977 
978  $style_id = ilObjStyleSheet::lookupObjectStyle($source_object->getId());
979  if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
980  $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
981  $new_id = $style_obj->ilClone();
982  ilObjStyleSheet::writeStyleUsage($target_object->getId(), $new_id);
983  ilObjStyleSheet::writeOwner($target_object->getId(), $new_id);
984  $reuse = $this->container_repo->readReuse($source_object->getRefId());
985  $this->container_repo->updateReuse($target_object->getRefId(), $reuse);
986  }
987  }
static writeOwner($obj_id, $style_id)
getParentObject()
Get parent gui object.
Container page object.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupStandard(int $a_id)
Lookup standard flag.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static writeStyleUsage(int $a_obj_id, int $a_style_id)
Write style usage.
static lookupObjectStyle(int $a_obj_id)
Lookup object style.
copy(int $a_id, string $a_parent_type="", int $a_new_parent_id=0, bool $a_clone_mobs=false, int $obj_copy_id=0, bool $overwrite_existing=true)
Copy page.
+ 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.

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

References copyMultipleNonContainer(), ILIAS\Repository\ctrl(), getSources(), and ILIAS\Repository\lng().

Referenced by executeNextStepAfterSourceSelection(), and saveTarget().

824  : void
825  {
826  // Source defined
827  if ($this->getSources() === []) {
828  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
829  $this->ctrl->returnToParent($this);
830  }
831 
832  $this->copyMultipleNonContainer($this->getSources());
833  }
copyMultipleNonContainer(array $sources)
Copy multiple non container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilObjectCopyGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl(), init(), and initTabs().

133  : void
134  {
135  $this->init();
136  $this->initTabs();
137 
138  $this->ctrl->getNextClass($this);
139  $cmd = $this->ctrl->getCmd();
140 
141  $this->$cmd();
142  }
+ Here is the call graph for this function:

◆ executeNextStepAfterSourceSelection()

ilObjectCopyGUI::executeNextStepAfterSourceSelection ( )
private

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

References ilPageObject\_exists(), ilObject\_lookupObjId(), copySingleObject(), getFirstSource(), getSources(), showCopyPageSelection(), and showItemSelection().

Referenced by saveSource(), and saveSourceMembership().

746  : void
747  {
748  if (!$this->obj_definition->isContainer($this->getType())) {
749  $this->copySingleObject();
750  return;
751  }
752 
753  if (count($this->getSources()) === 1
755  'cont',
757  )
758  ) {
759  $this->showCopyPageSelection();
760  return;
761  }
762 
763  $this->showItemSelection();
764  }
static _lookupObjId(int $ref_id)
showItemSelection(bool $copy_page=false)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
copySingleObject()
Start cloning a single (not container) object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorMessageOnDisallowedObjectTypeForTarget()

ilObjectCopyGUI::getErrorMessageOnDisallowedObjectTypeForTarget ( int  $ref_id)
private

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

References ilObject\_lookupType(), ilObjectFactory\getClassByType(), getSubMode(), getTargets(), and ILIAS\Repository\lng().

Referenced by saveSource().

702  : string
703  {
704  foreach ($this->getTargets() as $target_ref_id) {
705  $target_type = ilObject::_lookupType($target_ref_id, true);
706  $target_class_name = ilObjectFactory::getClassByType($target_type);
707  $target_object = new $target_class_name($target_ref_id);
708  $possible_subtypes = $target_object->getPossibleSubObjects();
709 
710  $source_type = ilObject::_lookupType($ref_id, true);
711 
712  if (!array_key_exists($source_type, $possible_subtypes)
713  && $this->getSubMode() != self::SUBMODE_CONTENT_ONLY
714  && ($source_type !== 'crs' || $target_type !== 'crs')
715  ) {
716  return sprintf(
717  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
718  $this->lng->txt('obj_' . $target_type),
719  $this->lng->txt('obj_' . $source_type)
720  );
721  }
722  }
723 
724  return '';
725  }
$ref_id
Definition: ltiauth.php:65
static getClassByType(string $obj_type)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFirstSource()

ilObjectCopyGUI::getFirstSource ( )

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

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

578  : int
579  {
580  if (count($this->sources)) {
581  return (int) $this->sources[0];
582  }
583  return 0;
584  }
+ Here is the caller graph for this function:

◆ getFirstTarget()

ilObjectCopyGUI::getFirstTarget ( )

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

References getTargets().

Referenced by copyMultipleNonContainer(), init(), and showSourceSelectionTree().

604  : int
605  {
606  if (array_key_exists(0, $this->getTargets())) {
607  $targets = $this->getTargets();
608  return (int) $targets[0];
609  }
610  return 0;
611  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMode()

ilObjectCopyGUI::getMode ( )

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

References $mode.

Referenced by setTabs().

533  : int
534  {
535  return $this->mode;
536  }
+ Here is the caller graph for this function:

◆ getOnLoadCode()

ilObjectCopyGUI::getOnLoadCode ( string  $cmd)
private

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

References $id.

Referenced by showTargetSelectionTree().

391  : Closure
392  {
393  return function ($id) use ($cmd) {
394  return "document.getElementById('$id')"
395  . '.addEventListener("click", '
396  . '(e) => {e.preventDefault();'
397  . 'e.target.setAttribute("name", "cmd[' . $cmd . ']");'
398  . 'e.target.form.requestSubmit(e.target);});';
399  };
400  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ getParentObject()

ilObjectCopyGUI::getParentObject ( )

Get parent gui object.

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

References $parent_obj.

Referenced by copyParentPage(), and init().

551  : ?ilObjectGUI
552  {
553  return $this->parent_obj;
554  }
Class ilObjectGUI Basic methods of all Output classes.
ImplementsCreationCallback $parent_obj
+ Here is the caller graph for this function:

◆ getPrimaryButtonLabel()

ilObjectCopyGUI::getPrimaryButtonLabel ( )
private

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

References ILIAS\Repository\lng().

Referenced by showTargetSelectionTree().

382  : string
383  {
384  if ($this->obj_definition->isContainer($this->getType())) {
385  return $this->lng->txt('btn_next');
386  }
387 
388  return $this->lng->txt('paste');
389  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSources()

ilObjectCopyGUI::getSources ( )

◆ getSubMode()

ilObjectCopyGUI::getSubMode ( )

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

References $sub_mode.

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

543  : int
544  {
545  return $this->sub_mode;
546  }
+ Here is the caller graph for this function:

◆ getTargets()

ilObjectCopyGUI::getTargets ( )

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

References $targets.

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

599  : array
600  {
601  return $this->targets;
602  }
+ Here is the caller graph for this function:

◆ getType()

ilObjectCopyGUI::getType ( )

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

References $type.

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

556  : string
557  {
558  return $this->type;
559  }
+ Here is the caller graph for this function:

◆ init()

ilObjectCopyGUI::init ( )
protected

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

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

Referenced by executeCommand().

144  : void
145  {
146  if ($this->retriever->has('smode')) {
147  $this->setSubMode($this->retriever->getMaybeInt('smode') ?? 0);
148  $this->ctrl->setParameter($this, 'smode', $this->getSubMode());
149  ilLoggerFactory::getLogger('obj')->debug('Submode is: ' . $this->getSubMode());
150  }
151 
152  // save sources
153  if ($this->retriever->has('source_ids')) {
154  $this->setSource(explode('_', $this->retriever->getMaybeString('source_ids')));
155  $this->ctrl->setParameter($this, 'source_ids', implode('_', $this->getSources()));
156  ilLoggerFactory::getLogger('obj')->debug('Multiple sources: ' . implode('_', $this->getSources()));
157  }
158  if ($this->retriever->has('source_id')) {
159  $this->setSource([$this->retriever->getMaybeInt('source_id')]);
160  $this->ctrl->setParameter($this, 'source_ids', implode('_', $this->getSources()));
161  ilLoggerFactory::getLogger('obj')->debug('source_id is set: ' . implode('_', $this->getSources()));
162  }
163  if ($this->getFirstSource()) {
164  $this->setType(
166  );
167  }
168 
169  // creation screen: copy section
170  if ($this->retriever->has('new_type')) {
171  $this->setMode(self::SEARCH_SOURCE);
172  $this->setType($this->retriever->getMaybeString('new_type'));
173  $this->setTarget($this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int()));
174 
175  $this->ctrl->setParameter($this, 'new_type', $this->getType());
176  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'new_type', $this->getType());
177  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'cpfl', 1);
178  $this->ctrl->setReturnByClass(get_class($this->getParentObject()), 'create');
179 
180  ilLoggerFactory::getLogger('obj')->debug('Copy from object creation for type: ' . $this->getType());
181  return;
182  }
183  // adopt content, and others?
184  elseif ($this->retriever->getMaybeInt('selectMode') === self::SOURCE_SELECTION) {
185  $this->setMode(self::SOURCE_SELECTION);
186 
187  $this->ctrl->setParameterByClass(get_class($this->parent_obj), 'selectMode', self::SOURCE_SELECTION);
188  $this->setTarget($this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int()));
189  $this->ctrl->setReturnByClass(get_class($this->parent_obj), '');
190 
191  ilLoggerFactory::getLogger('obj')->debug('Source selection mode. Target is: ' . $this->getFirstTarget());
192  } elseif ($this->retriever->getMaybeInt('selectMode') === self::TARGET_SELECTION) {
193  $this->setMode(self::TARGET_SELECTION);
194  $this->ctrl->setReturnByClass(get_class($this->parent_obj), '');
195  ilLoggerFactory::getLogger('obj')->debug('Target selection mode.');
196  }
197 
198  // save targets
199  if ($this->retriever->has('target_ids')) {
200  $this->setTargets(explode('_', $this->retriever->getMaybeString('target_ids')));
201  ilLoggerFactory::getLogger('obj')->debug('targets are: ' . print_r($this->getTargets(), true));
202  }
203  }
static getLogger(string $a_component_id)
Get component logger.
static _lookupObjId(int $ref_id)
getParentObject()
Get parent gui object.
setSource(array $source_ids)
static _lookupType(int $id, bool $reference=false)
setTargets(array $targets)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormSearch()

ilObjectCopyGUI::initFormSearch ( )
protected

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

References ILIAS\Repository\ctrl(), ILIAS\Repository\form(), getType(), and ILIAS\Repository\lng().

Referenced by searchSource(), and showSourceSearch().

1130  : void
1131  {
1132  $this->form = new ilPropertyFormGUI();
1133  $this->form->setTableWidth('600px');
1134  $this->ctrl->setParameter($this, 'new_type', $this->getType());
1135  $this->form->setFormAction($this->ctrl->getFormAction($this));
1136  $this->form->setTitle($this->lng->txt($this->getType() . '_copy'));
1137  $this->form->addCommandButton('searchSource', $this->lng->txt('search_for'));
1138  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
1139 
1140  $tit = new ilTextInputGUI($this->lng->txt('title'), 'tit');
1141  $tit->setSize(40);
1142  $tit->setMaxLength(70);
1143  $tit->setRequired(true);
1144  $tit->setInfo($this->lng->txt('wizard_title_info'));
1145  $this->form->addItem($tit);
1146  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSourceSelection()

ilObjectCopyGUI::initSourceSelection ( )
protected

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

References $path, ILIAS\Repository\ctrl(), ilSession\get(), getTargets(), ilSession\set(), setTabs(), and showSourceSelectionTree().

Referenced by adoptContent().

283  : void
284  {
285  // copy opened nodes from repository explorer
286  $node_ids = is_array(ilSession::get('repexpand')) ? ilSession::get('repexpand') : [];
287 
288  $this->setTabs(self::TAB_GROUP_SC_SELECTION, self::TAB_SELECTION_SOURCE_TREE);
289 
290  // open current position
291  // begin-patch mc
292  foreach ($this->getTargets() as $target_ref_id) {
293  $path = $this->tree->getPathId($target_ref_id);
294  foreach ($path as $node_id) {
295  if (!in_array($node_id, $node_ids)) {
296  $node_ids[] = $node_id;
297  }
298  }
299  }
300  // end-patch multi copy
301 
302  ilSession::set('paste_copy_repexpand', $node_ids);
303 
304  $this->ctrl->setReturnByClass(get_class($this->parent_obj), '');
305  $this->showSourceSelectionTree();
306  }
static get(string $a_var)
setTabs(int $tab_group, int $active_tab)
$path
Definition: ltiservices.php:29
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTabs()

ilObjectCopyGUI::initTabs ( )
protected

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

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

205  : void
206  {
207  $this->lng->loadLanguageModule('cntr');
208  $this->tabs->clearTargets();
209  $this->tabs->setBackTarget(
210  $this->lng->txt('cancel'),
211  (string) $this->ctrl->getParentReturn($this->parent_obj)
212  );
213  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTargetSelection()

ilObjectCopyGUI::initTargetSelection ( )
protected

Init copy from repository/search list commands.

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

References $path, ILIAS\Repository\ctrl(), ilSession\get(), getSources(), ilSession\set(), setTargets(), and showTargetSelectionTree().

254  : void
255  {
256  $this->ctrl->setParameter($this, 'selectMode', self::TARGET_SELECTION);
257 
258  // copy opened nodes from repository explorer
259  $node_ids = is_array(ilSession::get('repexpand')) ? ilSession::get('repexpand') : [];
260 
261  // begin-patch mc
262  $this->setTargets([]);
263  // cognos-blu-patch: end
264 
265  // open current position
266  foreach ($this->getSources() as $source_id) {
267  if ($source_id) {
268  $path = $this->tree->getPathId($source_id);
269  foreach ($path as $node_id) {
270  if (!in_array($node_id, $node_ids)) {
271  $node_ids[] = $node_id;
272  }
273  }
274  }
275  }
276 
277  ilSession::set('paste_copy_repexpand', $node_ids);
278 
279  $this->ctrl->setReturnByClass(get_class($this->parent_obj), '');
280  $this->showTargetSelectionTree();
281  }
static get(string $a_var)
$path
Definition: ltiservices.php:29
static set(string $a_var, $a_val)
Set a value.
setTargets(array $targets)
+ Here is the call graph for this function:

◆ isCopyingParentPageNeeded()

ilObjectCopyGUI::isCopyingParentPageNeeded ( )
private

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

References ILIAS\Repository\refinery().

Referenced by copyContainerToTargets().

960  : bool
961  {
962  return $this->post_wrapper->has('copy_page')
963  && $this->post_wrapper->retrieve('copy_page', $this->refinery->kindlyTo()->bool());
964  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ keepObjectsInClipboard()

ilObjectCopyGUI::keepObjectsInClipboard ( )

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

References $ctrl, getSources(), ILIAS\Repository\lng(), and ilCtrl\returnToParent().

621  : void
622  {
623  $this->tpl->setOnScreenMessage('success', $this->lng->txt("obj_inserted_clipboard"), true);
624  $ilCtrl = $this->ctrl;
625  $this->clipboard->setCmd("copy");
626  $this->clipboard->setRefIds($this->getSources());
627  $ilCtrl->returnToParent($this);
628  }
returnToParent(object $a_gui_obj, ?string $a_anchor=null)
+ Here is the call graph for this function:

◆ saveCopyPage()

ilObjectCopyGUI::saveCopyPage ( )
protected

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

References $data, buildCopyPageSelectionForm(), and showItemSelection().

772  : void
773  {
775  $data = $form->withRequest($this->request)->getData();
776 
777  $this->showItemSelection($data['copy_page']);
778  }
showItemSelection(bool $copy_page=false)
ilPropertyFormGUI $form
+ Here is the call graph for this function:

◆ saveSource()

ilObjectCopyGUI::saveSource ( )
protected

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

References $message, ilObject\_lookupType(), ILIAS\Repository\ctrl(), executeNextStepAfterSourceSelection(), getErrorMessageOnDisallowedObjectTypeForTarget(), getSources(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), searchSource(), setSource(), and setType().

678  : void
679  {
680  if (!$this->post_wrapper->has("source")) {
681  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
682  $this->searchSource();
683  return;
684  }
685 
686  $source = $this->post_wrapper->retrieve("source", $this->refinery->kindlyTo()->int());
687  $this->setSource([$source]);
688  $this->setType(ilObject::_lookupType($source, true));
689  $this->ctrl->setParameter($this, 'source_id', $source);
690 
691  foreach ($this->getSources() as $source_ref_id) {
692  if (($message = $this->getErrorMessageOnDisallowedObjectTypeForTarget($source_ref_id)) !== '') {
693  $this->tpl->setOnScreenMessage('failure', $message);
694  $this->searchSource();
695  return;
696  }
697  }
698 
700  }
getErrorMessageOnDisallowedObjectTypeForTarget(int $ref_id)
setSource(array $source_ids)
$message
Definition: xapiexit.php:31
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ saveSourceMembership()

ilObjectCopyGUI::saveSourceMembership ( )
protected

Save selected source from membership screen.

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

References ilObject\_lookupType(), ILIAS\Repository\ctrl(), executeNextStepAfterSourceSelection(), getFirstSource(), ILIAS\Repository\lng(), null, setSource(), and setType().

730  : void
731  {
732  $source = $this->retriever->getMaybeInt('source');
733  if ($source === null) {
734  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
735  $this->ctrl->redirect($this, 'showSourceSelectionMembership');
736  return;
737  }
738 
739  $this->setSource([$source]);
740  $this->setType(ilObject::_lookupType($this->getFirstSource(), true));
741  $this->ctrl->setParameter($this, 'source_id', $source);
742 
744  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setSource(array $source_ids)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ saveTarget()

ilObjectCopyGUI::saveTarget ( )
protected

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

References Vendor\Package\$e, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), copyMultipleNonContainer(), copySingleObject(), ILIAS\Repository\ctrl(), ilObjectFactory\getClassByType(), getFirstSource(), getSources(), getTargets(), ILIAS\Repository\int(), ILIAS\Repository\lng(), null, setTarget(), setTargets(), showItemSelection(), and showTargetSelectionTree().

450  : void
451  {
452  if (!$this->retriever->has('target')) {
453  $this->ctrl->setParameter($this, 'selectMode', self::TARGET_SELECTION);
454  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
455  $this->showTargetSelectionTree();
456  return;
457  }
458 
459  try {
460  $targets = $this->retriever->getArrayOfInt('target');
461  } catch (ConstraintViolationException $e) {
462  $possible_target = $this->retriever->getMaybeInt('target');
463  $targets = $possible_target === null ? [] : [$possible_target];
464  }
465 
466  if ($targets !== []) {
467  $this->setTargets($targets);
468  $this->ctrl->setParameter($this, 'target_ids', implode('_', $this->getTargets()));
469  } elseif (($target = $this->retriever->getMaybeInt('target')) !== null) {
470  $this->setTarget($target);
471  $this->ctrl->setParameter($this, 'target_ids', implode('_', $this->getTargets()));
472  }
473 
474  // validate allowed subtypes
475  foreach ($this->getSources() as $source_ref_id) {
476  foreach ($this->getTargets() as $target_ref_id) {
477  $target_type = ilObject::_lookupType((int) $target_ref_id, true);
478  $target_class_name = ilObjectFactory::getClassByType($target_type);
479  $target_object = new $target_class_name((int) $target_ref_id);
480  $possible_subtypes = $target_object->getPossibleSubObjects();
481 
482  $source_type = ilObject::_lookupType((int) $source_ref_id, true);
483 
484  if (!array_key_exists($source_type, (array) $possible_subtypes)) {
485  $this->tpl->setOnScreenMessage('failure', sprintf(
486  $this->lng->txt('msg_obj_may_not_contain_objects_of_type'),
487  $this->lng->txt('obj_' . $target_type),
488  $this->lng->txt('obj_' . $source_type)
489  ));
490  $this->showTargetSelectionTree();
491  return;
492  }
493  }
494  }
495 
496  if (count($this->getSources()) == 1 && $this->obj_definition->isContainer($this->getType())) {
497  // check, if object should be copied into itself
498  // begin-patch mc
499  $is_child = [];
500  foreach ($this->getTargets() as $target_ref_id) {
501  if ($this->tree->isGrandChild($this->getFirstSource(), (int) $target_ref_id)) {
503  }
504  if ($this->getFirstSource() == (int) $target_ref_id) {
506  }
507  }
508  // end-patch multi copy
509  if (count($is_child) > 0) {
510  $this->tpl->setOnScreenMessage(
511  'failure',
512  $this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child)
513  );
514  $this->showTargetSelectionTree();
515  return;
516  }
517 
518  $this->showItemSelection();
519  } else {
520  if (count($this->getSources()) == 1) {
521  $this->copySingleObject();
522  } else {
523  $this->copyMultipleNonContainer($this->getSources());
524  }
525  }
526  }
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
showItemSelection(bool $copy_page=false)
static _lookupTitle(int $obj_id)
copySingleObject()
Start cloning a single (not container) object.
static getClassByType(string $obj_type)
copyMultipleNonContainer(array $sources)
Copy multiple non container.
static _lookupType(int $id, bool $reference=false)
setTargets(array $targets)
+ Here is the call graph for this function:

◆ searchSource()

ilObjectCopyGUI::searchSource ( )
protected

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

References $res, $results, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilSession\get(), getFirstSource(), getType(), initFormSearch(), ILIAS\Repository\lng(), ilQueryParser\QP_COMBINATION_AND, ROOT_FOLDER_ID, and ilSession\set().

Referenced by saveSource(), and showItemSelection().

630  : void
631  {
632  if ($this->post_wrapper->has('tit')) {
633  $this->tpl->setOnScreenMessage('info', $this->lng->txt('wizard_search_list'));
634  ilSession::set('source_query', $this->post_wrapper->retrieve("tit", $this->refinery->kindlyTo()->string()));
635  }
636 
637  $this->initFormSearch();
638  $this->form->setValuesByPost();
639 
640  if (!$this->form->checkInput()) {
641  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_search_string'), true);
642  $this->ctrl->returnToParent($this);
643  return;
644  }
645 
646  $tit = $this->form->getInput('tit');
647  if ($tit === "") {
648  $tit = ilSession::get('source_query', '');
649  }
650  $query_parser = new ilQueryParser($tit);
651  $query_parser->setMinWordLength(1);
652  $query_parser->setCombination(ilQueryParser::QP_COMBINATION_AND);
653  $query_parser->parse();
654  if (!$query_parser->validate()) {
655  $this->tpl->setOnScreenMessage('failure', $query_parser->getMessage(), true);
656  $this->ctrl->returnToParent($this);
657  }
658 
659  // only like search since fulltext does not support search with less than 3 characters
660  $object_search = new ilLikeObjectSearch($query_parser);
661  $object_search->setFilter([$this->retriever->getMaybeString('new_type')]);
662  $res = $object_search->performSearch();
663  $res->setRequiredPermission('copy');
664  $res->filter(ROOT_FOLDER_ID, true);
665 
666  if (!count($results = $res->getResultsByObjId())) {
667  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('search_no_match'), true);
668  $this->ctrl->returnToParent($this);
669  }
670 
671  $table = new ilObjectCopySearchResultTableGUI($this, 'searchSource', $this->getType());
672  $table->setFormAction($this->ctrl->getFormAction($this));
673  $table->setSelectedReference($this->getFirstSource());
674  $table->parseSearchResults($results);
675  $this->tpl->setContent($table->getHTML());
676  }
static get(string $a_var)
$res
Definition: ltiservices.php:66
const ROOT_FOLDER_ID
Definition: constants.php:32
$results
form( $class_path, string $cmd, string $submit_caption="")
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMode()

ilObjectCopyGUI::setMode ( int  $mode)

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

References $mode.

Referenced by adoptContent(), and init().

528  : void
529  {
530  $this->mode = $mode;
531  }
+ Here is the caller graph for this function:

◆ setSource()

ilObjectCopyGUI::setSource ( array  $source_ids)

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

References ILIAS\Repository\refinery(), and ILIAS\Refinery\transform().

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

566  : void
567  {
568  $this->sources = $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())->transform(
569  $source_ids
570  );
571  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSubMode()

ilObjectCopyGUI::setSubMode ( int  $mode)

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

References $mode.

Referenced by adoptContent(), and init().

538  : void
539  {
540  $this->sub_mode = $mode;
541  }
+ Here is the caller graph for this function:

◆ setTabs()

ilObjectCopyGUI::setTabs ( int  $tab_group,
int  $active_tab 
)
protected

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

References ILIAS\Repository\ctrl(), getMode(), getSubMode(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by initSourceSelection(), and showSourceSelectionMembership().

215  : void
216  {
217  if ($tab_group == self::TAB_GROUP_SC_SELECTION) {
218  if ($this->getSubMode() == self::SUBMODE_CONTENT_ONLY) {
219  if ($this->getMode() == self::SOURCE_SELECTION) {
220  $this->tabs->addTab(
221  (string) self::TAB_SELECTION_SOURCE_TREE,
222  $this->lng->txt('cntr_copy_repo_tree'),
223  $this->ctrl->getLinkTarget($this, 'initSourceSelection')
224  );
225  $this->tabs->addTab(
226  (string) self::TAB_SELECTION_MEMBERSHIP,
227  $this->lng->txt('cntr_copy_crs_grp'),
228  $this->ctrl->getLinkTarget($this, 'showSourceSelectionMembership')
229  );
230  }
231  }
232  }
233  $this->tabs->activateTab((string) $active_tab);
234  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTarget()

ilObjectCopyGUI::setTarget ( int  $ref_id)

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

References setTargets().

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

587  : void
588  {
589  $this->setTargets([$ref_id]);
590  }
$ref_id
Definition: ltiauth.php:65
setTargets(array $targets)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTargets()

ilObjectCopyGUI::setTargets ( array  $targets)

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

References ILIAS\Repository\refinery(), and ILIAS\Refinery\transform().

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

592  : void
593  {
594  $this->targets = $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())->transform(
595  $targets
596  );
597  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setType()

ilObjectCopyGUI::setType ( string  $type)

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

References $type.

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

561  : void
562  {
563  $this->type = $type;
564  }
+ Here is the caller graph for this function:

◆ showCopyPageSelection()

ilObjectCopyGUI::showCopyPageSelection ( )
protected

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

References buildCopyPageSelectionForm().

Referenced by executeNextStepAfterSourceSelection().

766  : void
767  {
769  $this->tpl->setContent($this->ui_renderer->render($form));
770  }
ilPropertyFormGUI $form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showCopyProgress()

ilObjectCopyGUI::showCopyProgress ( )
protected

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

References $ref_id, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ROOT_FOLDER_ID, and ILIAS\Repository\tabs().

Referenced by copyContainerToTargets().

989  : void
990  {
992  if ($this->request_wrapper->has('ref_id')) {
993  $ref_id = $this->request_wrapper->retrieve(
994  'ref_id',
995  $this->refinery->kindlyTo()->int()
996  );
997  }
998 
999  $this->tabs->setBackTarget(
1000  $this->lng->txt('tab_back_to_repository'),
1001  (string) $this->ctrl->getParentReturn($this->parent_obj)
1002  );
1003 
1004  $progress = new ilObjectCopyProgressTableGUI(
1005  $this,
1006  'showCopyProgress',
1007  $ref_id
1008  );
1009  $progress->setObjectInfo($this->targets_copy_id);
1010  $progress->parse();
1011  $progress->init();
1012  $link = ilLink::_getLink($ref_id);
1013  $progress->setRedirectionUrl($link);
1014 
1015  $this->tpl->setContent($progress->getHTML());
1016  }
const ROOT_FOLDER_ID
Definition: constants.php:32
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showItemSelection()

ilObjectCopyGUI::showItemSelection ( bool  $copy_page = false)
protected

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

References getFirstSource(), getSources(), getTargets(), getType(), ILIAS\Repository\lng(), and searchSource().

Referenced by executeNextStepAfterSourceSelection(), saveCopyPage(), and saveTarget().

800  : void
801  {
802  if (!count($this->getSources())) {
803  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
804  $this->searchSource();
805  return;
806  }
807 
808  $this->log->debug('Source(s): ' . print_r($this->getSources(), true));
809  $this->log->debug('Target(s): ' . print_r($this->getTargets(), true));
810 
811  $this->tpl->setOnScreenMessage('info', $this->lng->txt($this->getType() . '_copy_threads_info'));
812  $this->tpl->addJavaScript('assets/js/ilContainer.js');
813  $this->tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
814 
815  $table = new ilObjectCopySelectionTableGUI($this, 'showItemSelection', $this->getType(), $copy_page);
816  $table->parseSource($this->getFirstSource());
817 
818  $this->tpl->setContent($table->getHTML());
819  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSourceSearch()

ilObjectCopyGUI::showSourceSearch ( ?string  $tpl_var)

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

Parameters
?string$tpl_var The tpl variable to fill

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

References $form, ILIAS\Repository\form(), initFormSearch(), null, and unsetSession().

1118  {
1119  $this->unsetSession();
1120  $this->initFormSearch();
1121 
1122  if ($tpl_var) {
1123  $this->tpl->setVariable($tpl_var, $this->form->getHTML());
1124  return null;
1125  }
1126 
1127  return $this->form;
1128  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
unsetSession()
Unset session variables.
form( $class_path, string $cmd, string $submit_caption="")
ilPropertyFormGUI $form
+ Here is the call graph for this function:

◆ showSourceSelectionMembership()

ilObjectCopyGUI::showSourceSelectionMembership ( )
protected

show target selection membership

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

References ilParticipants\_getMembershipByType(), ILIAS\Repository\lng(), setTabs(), and ILIAS\Repository\user().

312  : void
313  {
314  $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_copy_clipboard_source'));
315  $this->setTabs(self::TAB_GROUP_SC_SELECTION, self::TAB_SELECTION_MEMBERSHIP);
316 
318  $this,
319  'showSourceSelectionMembership',
320  'copy_selection_mmbrs'
321  );
322  $cgs->init();
323  $cgs->setObjects(
324  array_merge(
325  ilParticipants::_getMembershipByType($this->user->getId(), ['crs']),
326  ilParticipants::_getMembershipByType($this->user->getId(), ['grp'])
327  )
328  );
329  $cgs->parse();
330 
331  $this->tpl->setContent($cgs->getHTML());
332  }
setTabs(int $tab_group, int $active_tab)
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
+ Here is the call graph for this function:

◆ showSourceSelectionTree()

ilObjectCopyGUI::showSourceSelectionTree ( )
protected

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

References $container, ILIAS\Repository\ctrl(), getFirstTarget(), getSources(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ilPasteIntoMultipleItemsExplorer\SEL_TYPE_RADIO.

Referenced by initSourceSelection().

402  : void
403  {
404  $this->tpl->addBlockFile(
405  'ADM_CONTENT',
406  'adm_content',
407  'tpl.paste_into_multiple_objects.html',
408  "components/ILIAS/ILIASObject"
409  );
410 
411  $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_copy_clipboard_source'));
414  'ilias.php?baseClass=ilRepositoryGUI&cmd=goto',
415  'paste_copy_repexpand'
416  );
417  $exp->setRequiredFormItemPermission('visible,read,copy');
418 
419  $this->ctrl->setParameter($this, 'selectMode', self::SOURCE_SELECTION);
420  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showSourceSelectionTree'));
421  $exp->setTargetGet('ref_id');
422  $exp->setPostVar('source');
423  $exp->setCheckedItems($this->getSources());
424  $exp->highlightNode((string) $this->getFirstTarget());
425 
426  // Filter to container
427  foreach (['cat', 'root', 'fold'] as $container) {
428  $exp->removeFormItemForType($container);
429  }
430 
431  if (!$this->request_wrapper->has("paste_copy_repexpand")) {
432  $expanded = $this->tree->readRootId();
433  } else {
434  $expanded = $this->request_wrapper->retrieve("paste_copy_repexpand", $this->refinery->kindlyTo()->int());
435  }
436 
437  $this->tpl->setVariable('FORM_TARGET', '_self');
438  $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'copySelection'));
439 
440  $exp->setExpand($expanded);
441  // build html-output
442  $exp->setOutput(0);
443  $output = $exp->getOutput();
444 
445  $this->tpl->setVariable('OBJECT_TREE', $output);
446  $this->tpl->setVariable('CMD_SUBMIT', 'saveSource');
447  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('btn_next'));
448  }
ilPasteIntoMultipleItemsExplorer Explorer
$container
Definition: wac.php:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showTargetSelectionTree()

ilObjectCopyGUI::showTargetSelectionTree ( )
protected

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

References ILIAS\Repository\ctrl(), ilUtil\getImagePath(), getOnLoadCode(), getPrimaryButtonLabel(), ILIAS\Repository\lng(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by initTargetSelection(), and saveTarget().

334  : void
335  {
336  if ($this->obj_definition->isContainer($this->getType())) {
337  $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_copy_clipboard_container'));
338  } else {
339  $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_copy_clipboard'));
340  }
341 
342  $exp = new ilRepositorySelectorExplorerGUI($this, "showTargetSelectionTree");
343  $exp->setTypeWhiteList(["root", "cat", "grp", "crs", "fold", "lso", "prg"]);
344  $exp->setSelectMode("target", true);
345  if ($exp->handleCommand()) {
346  return;
347  }
348  $output = $exp->getHTML();
349 
350  $t = new ilToolbarGUI();
351  $t->setFormAction($this->ctrl->getFormAction($this, "saveTarget"));
352  $primary_button = $this->ui_factory->button()->primary(
353  $this->getPrimaryButtonLabel(),
354  ''
355  )->withOnLoadCode($this->getOnLoadCode('saveTarget'));
356  $t->addComponent($primary_button);
357  $t->addSeparator();
358 
359  $clipboard_btn = $this->ui_factory->button()->standard(
360  $this->lng->txt('obj_insert_into_clipboard'),
361  ''
362  )->withOnLoadCode($this->getOnLoadCode('keepObjectsInClipboard'));
363  $t->addComponent($clipboard_btn);
364 
365  $cancel_btn = $this->ui_factory->button()->standard(
366  $this->lng->txt('cancel'),
367  ''
368  )->withOnLoadCode($this->getOnLoadCode('cancel'));
369  $t->addComponent($cancel_btn);
370 
371  $t->setCloseFormTag(false);
372  $t->setLeadingImage(ilUtil::getImagePath("nav/arrow_upright.svg"), " ");
373  $output = $t->getHTML() . $output;
374  $t->setLeadingImage(ilUtil::getImagePath("nav/arrow_downright.svg"), " ");
375  $t->setCloseFormTag(true);
376  $t->setOpenFormTag(false);
377  $output .= "<br />" . $t->getHTML();
378 
379  $this->tpl->setContent($output);
380  }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $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:

◆ unsetSession()

ilObjectCopyGUI::unsetSession ( )
protected

Unset session variables.

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

References ilSession\clear(), and setSource().

Referenced by showSourceSearch().

1151  : void
1152  {
1153  ilSession::clear('source_query');
1154  $this->setSource([]);
1155  }
setSource(array $source_ids)
static clear(string $a_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateProgress()

ilObjectCopyGUI::updateProgress ( )
protected

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

References ilCopyWizardOptions\_getInstance(), exit, and null.

1018  : void
1019  {
1020  $json = new stdClass();
1021  $json->percentage = null;
1022  $json->performed_steps = null;
1023 
1024  $copy_id = $this->retriever->getMaybeInt('_copy_id');
1025  $options = ilCopyWizardOptions::_getInstance($copy_id);
1026  $node = $options->fetchFirstNode();
1027  $json->current_node_id = 0;
1028  $json->current_node_title = "";
1029  $json->in_dependencies = false;
1030  if (is_array($node)) {
1031  $json->current_node_id = $node['obj_id'];
1032  $json->current_node_title = $node['title'];
1033  } else {
1034  $node = $options->fetchFirstDependenciesNode();
1035  if (is_array($node)) {
1036  $json->current_node_id = $node['obj_id'];
1037  $json->current_node_title = $node['title'];
1038  $json->in_dependencies = true;
1039  }
1040  }
1041  $json->required_steps = $options->getRequiredSteps();
1042  $json->id = $copy_id;
1043 
1044  $this->log->debug('Update copy progress: ' . json_encode($json));
1045 
1046  echo json_encode($json);
1047  exit;
1048  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getInstance(int $a_copy_id)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilObjectCopyGUI::$access
protected

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

◆ $clipboard

ClipboardManager ilObjectCopyGUI::$clipboard
protected

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

◆ $container_repo

ContainerDBRepository ilObjectCopyGUI::$container_repo
protected

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

◆ $ctrl

ilCtrl ilObjectCopyGUI::$ctrl
protected

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

Referenced by cancel(), and keepObjectsInClipboard().

◆ $error

ilErrorHandling ilObjectCopyGUI::$error
protected

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

◆ $form

ilPropertyFormGUI ilObjectCopyGUI::$form
protected

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

Referenced by showSourceSearch().

◆ $lng

ilLanguage ilObjectCopyGUI::$lng
protected

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

◆ $log

ilLogger ilObjectCopyGUI::$log
protected

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

◆ $mode

int ilObjectCopyGUI::$mode = 0
protected

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

Referenced by getMode(), setMode(), and setSubMode().

◆ $obj_data_cache

ilObjectDataCache ilObjectCopyGUI::$obj_data_cache
protected

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

◆ $obj_definition

ilObjectDefinition ilObjectCopyGUI::$obj_definition
protected

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

◆ $parent_obj

ImplementsCreationCallback ilObjectCopyGUI::$parent_obj = null
protected

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

Referenced by getParentObject().

◆ $post_wrapper

ArrayBasedRequestWrapper ilObjectCopyGUI::$post_wrapper
protected

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

◆ $rbacreview

ilRbacReview ilObjectCopyGUI::$rbacreview
protected

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

◆ $rbacsystem

ilRbacSystem ilObjectCopyGUI::$rbacsystem
protected

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

◆ $refinery

Refinery ilObjectCopyGUI::$refinery
protected

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

◆ $request

ServerRequestInterface ilObjectCopyGUI::$request
protected

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

◆ $request_wrapper

RequestWrapper ilObjectCopyGUI::$request_wrapper
protected

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

◆ $retriever

ilObjectRequestRetriever ilObjectCopyGUI::$retriever
private

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

◆ $sources

array ilObjectCopyGUI::$sources = []
protected

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

Referenced by getSources().

◆ $sub_mode

int ilObjectCopyGUI::$sub_mode = self::SUBMODE_COMPLETE
protected

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

Referenced by getSubMode().

◆ $tabs

ilTabsGUI ilObjectCopyGUI::$tabs
protected

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

◆ $targets

array ilObjectCopyGUI::$targets = []
protected

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

Referenced by getTargets().

◆ $targets_copy_id

array ilObjectCopyGUI::$targets_copy_id = []
protected

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

◆ $tpl

ilGlobalTemplateInterface ilObjectCopyGUI::$tpl
protected

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

◆ $tree

ilTree ilObjectCopyGUI::$tree
protected

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

◆ $type

string ilObjectCopyGUI::$type = ''
protected

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

Referenced by getType(), and setType().

◆ $ui_factory

UIFactory ilObjectCopyGUI::$ui_factory
protected

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

◆ $ui_renderer

UIRenderer ilObjectCopyGUI::$ui_renderer
protected

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

◆ $user

ilObjUser ilObjectCopyGUI::$user
protected

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

◆ SEARCH_SOURCE

const ilObjectCopyGUI::SEARCH_SOURCE = 3

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

◆ SOURCE_SELECTION

const ilObjectCopyGUI::SOURCE_SELECTION = 1

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

◆ SUBMODE_COMPLETE

const ilObjectCopyGUI::SUBMODE_COMPLETE = 1

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

◆ SUBMODE_CONTENT_ONLY

const ilObjectCopyGUI::SUBMODE_CONTENT_ONLY = 2

◆ TAB_GROUP_SC_SELECTION

const ilObjectCopyGUI::TAB_GROUP_SC_SELECTION = 1

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

◆ TAB_SELECTION_MEMBERSHIP

const ilObjectCopyGUI::TAB_SELECTION_MEMBERSHIP = 3

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

◆ TAB_SELECTION_SOURCE_TREE

const ilObjectCopyGUI::TAB_SELECTION_SOURCE_TREE = 2

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

◆ TAB_SELECTION_TARGET_TREE

const ilObjectCopyGUI::TAB_SELECTION_TARGET_TREE = 1

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

◆ TARGET_SELECTION

const ilObjectCopyGUI::TARGET_SELECTION = 2

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


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