19declare(strict_types=1);
32 return ignore_user_abort(
true);
37 $this->soap_check =
false;
75 if (!$is_initialized) {
86 $ilLog =
$DIC[
'ilLog'];
87 $ilUser =
$DIC[
'ilUser'];
92 if (!$cp_options->checkOwner($ilUser->getId())) {
93 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
98 if (($node = $cp_options->fetchFirstDependenciesNode()) ===
null) {
99 $cp_options->deleteAll();
105 $options = $cp_options->getOptions((
int) $node[
'child']);
109 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
114 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
120 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
126 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
136 public function ilClone(
string $sid,
int $copy_identifier)
147 $ilUser =
$DIC->user();
152 if (!$cp_options->checkOwner($ilUser->getId())) {
153 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
158 if (($node = $cp_options->fetchFirstNode()) ===
null) {
163 $options = $cp_options->getOptions((
int) $node[
'child']);
170 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
172 $cp_options->appendMapping($node[
'child'], 0);
178 ilLoggerFactory::getLogger(
'obj')->debug(
'Start cloning node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
179 $new_ref_id = $this->
cloneNode($node, $cp_options);
184 ilLoggerFactory::getLogger(
'obj')->debug(
'Start linking node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
185 $new_ref_id = $this->
linkNode($node, $cp_options);
189 case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
190 ilLoggerFactory::getLogger(
'obj')->debug(
'Start creating internal link for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
196 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
206 if (array_key_exists(
'type',
$options)) {
210 array_key_exists(
'child', $node) &&
213 return $default_mode;
217 return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
219 return $default_mode;
226 $logger =
$DIC->logger()->obj();
227 $tree =
$DIC->repositoryTree();
229 $obj_id = (
int) $node[
'obj_id'];
233 $logger->debug(
'Validating node: ' .
$ref_id .
' and root ' . $root);
234 $logger->dump(
$DIC->repositoryTree()->getRelation(
$ref_id, $root));
237 $logger->debug(
'Ignoring non child relation');
241 $logger->dump($mappings);
242 if (array_key_exists(
$ref_id, $mappings)) {
243 $logger->debug(
'Found existing mapping for linked node.');
247 $logger->info(
'Nothing found');
255 $ilLog =
$DIC->logger()->obj();
261 $soap_client->setResponseTimeout(1);
262 $soap_client->enableWSDL(
true);
263 $soap_client->init();
264 $soap_client->call(
'ilClone', array($sid, $cp_options->
getCopyId()));
279 $soap_client->setResponseTimeout(1);
280 $soap_client->enableWSDL(
true);
281 $soap_client->init();
282 $soap_client->call(
'ilCloneDependencies', array($sid, $cp_options->
getCopyId()));
294 $ilLog =
$DIC[
'ilLog'];
295 $tree =
$DIC[
'tree'];
296 $ilAccess =
$DIC[
'ilAccess'];
297 $rbacreview =
$DIC[
'rbacreview'];
298 $source_id = (
int) $node[
'child'];
299 $parent_id = (
int) $node[
'parent'];
303 if (!$ilAccess->checkAccess(
'copy',
'', (
int) $node[
'child'])) {
304 ilLoggerFactory::getLogger(
'obj')->error(
'No copy permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
307 if (!isset($mappings[$parent_id])) {
308 ilLoggerFactory::getLogger(
'obj')->info(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
311 $target_id = $mappings[$parent_id];
313 if (!$tree->isInTree($target_id)) {
314 ilLoggerFactory::getLogger(
'obj')->notice(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. Object has been deleted.');
319 $new_obj = $orig->cloneObject((
int) $target_id, $cp_options->
getCopyId());
321 if (!is_object($new_obj)) {
322 ilLoggerFactory::getLogger(
'obj')->error(
'Error copying ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
327 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(),
false);
332 $cp_options->
appendMapping($source_id, $new_obj->getRefId());
333 return $new_obj->getRefId();
340 $ilLog =
$DIC[
'ilLog'];
342 $source_id = (
int) $node[
'child'];
345 if (!isset($mappings[$source_id])) {
346 ilLoggerFactory::getLogger(
'obj')->debug(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No mapping found.');
349 $target_id = $mappings[$source_id];
352 $orig->cloneDependencies($target_id, $cp_options->
getCopyId());
359 $ilAccess =
$DIC->access();
360 $logger =
$DIC->logger()->obj();
361 $rbacreview =
$DIC->rbac()->review();
362 $tree =
$DIC->repositoryTree();
369 $logger->error(
'Cannot create object instance.');
373 $logger->error(
'Cannot create object instance for ref_id: ' . $source_id);
374 $logger->error(
$e->getMessage());
379 $node_parent = $node[
'parent'];
380 if (!array_key_exists($node_parent, $mappings)) {
381 $logger->error(
'Cannot new parent id for node: ' . $node[
'parent']);
384 $parent_id = $mappings[$node_parent];
386 $new_ref_id = $orig->createReference();
387 $orig->putInTree($parent_id);
388 $orig->setPermissions($parent_id);
390 if (!($new_ref_id)) {
391 $logger->warning(
'Creating internal link failed.');
396 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
403 $logger->notice(
'Added mapping for ' . $node[
'child'] .
' ' . $new_ref_id);
411 $ilLog =
$DIC[
'ilLog'];
412 $ilAccess =
$DIC[
'ilAccess'];
413 $rbacreview =
$DIC[
'rbacreview'];
415 $source_id = (
int) $node[
'child'];
416 $parent_id = (
int) $node[
'parent'];
420 if (!$ilAccess->checkAccess(
'delete',
'', (
int) $node[
'child'])) {
421 ilLoggerFactory::getLogger(
'obj')->warning(
'No delete permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
424 if (!isset($mappings[$parent_id])) {
425 ilLoggerFactory::getLogger(
'obj')->warning(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
428 $target_id = $mappings[$parent_id];
431 $new_ref_id = $orig->createReference();
432 $orig->putInTree($target_id);
433 $orig->setPermissions($target_id);
435 if (!($new_ref_id)) {
436 ilLoggerFactory::getLogger(
'obj')->error(
'Error linking ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
441 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
467 $DIC->logger()->user(),
468 (
new \
ILIAS\Data\Factory())->clock()
470 $dual_opt_in_service->deleteExpiredUserObjects($usr_id);
@phpstan-type PendingRegistrationRecord array{id: string, usr_id: int, reg_hash: string,...
isRootNode(int $a_root)
Is root node @access public.
dropFirstNode()
Drop first node (for cloneObject())
appendMapping($a_source_id, $a_target_id)
Add mapping of source -> target.
dropFirstDependenciesNode()
Drop first node (for cloneDependencies())
static _getInstance(int $a_copy_id)
isSOAPEnabled()
Check if SOAP calls are disabled.
const COPY_WIZARD_UNDEFINED
getOptions(int $a_source_id)
Get entry by source @access public.
static getLogger(string $a_component_id)
Get component logger.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Object not found exception.
Class ilObject Basic functions for all objects.
static _getAllReferences(int $id)
get all reference ids for object ID
static add(int $action, int $ref_id, array $diff, bool $source_ref_id=false)
static gatherFaPa(int $ref_id, array $role_ids, bool $add_action=false)
Class ilObjAuthSettingsGUI.
raiseError(string $a_message, $a_code)
checkSession(string $sid)
static ilCloneDependencies(string $sid, int $copy_identifier)
static ilClone(string $sid, int $copy_identifier)
cloneDependencies(array $node, ilCopyWizardOptions $cp_options)
deleteExpiredDualOptInUserObjects(string $sid, int $usr_id)
Method for soap webservice: deleteExpiredDualOptInUserObjects This service will run in background.
callNextDependency(string $sid, ilCopyWizardOptions $cp_options)
internalLinkNode(array $node, ilCopyWizardOptions $cp_options)
getMobsOfObject(string $sid, string $a_type, int $a_id)
rewriteActionForNode(ilCopyWizardOptions $cpo, array $node, array $options)
saveTempFileAsMediaObject(string $sid, string $name, string $tmp_name)
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
ilClone(string $sid, int $copy_identifier)
linkNode(array $node, ilCopyWizardOptions $cp_options)
ilCloneDependencies(string $sid, int $copy_identifier, bool $is_initialized=false)
cloneNode(array $node, ilCopyWizardOptions $cp_options)
callNextNode(string $sid, ilCopyWizardOptions $cp_options)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.