19declare(strict_types=1);
29 return ignore_user_abort(
true);
34 $this->soap_check =
false;
72 if (!$is_initialized) {
83 $ilLog =
$DIC[
'ilLog'];
84 $ilUser =
$DIC[
'ilUser'];
89 if (!$cp_options->checkOwner($ilUser->getId())) {
90 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
95 if (($node = $cp_options->fetchFirstDependenciesNode()) ===
null) {
96 $cp_options->deleteAll();
102 $options = $cp_options->getOptions((
int) $node[
'child']);
104 switch ($options[
'type']) {
106 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
111 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
117 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
123 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
133 public function ilClone(
string $sid,
int $copy_identifier)
144 $ilUser =
$DIC->user();
149 if (!$cp_options->checkOwner($ilUser->getId())) {
150 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
155 if (($node = $cp_options->fetchFirstNode()) ===
null) {
160 $options = $cp_options->getOptions((
int) $node[
'child']);
167 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
169 $cp_options->appendMapping($node[
'child'], 0);
175 ilLoggerFactory::getLogger(
'obj')->debug(
'Start cloning node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
176 $new_ref_id = $this->
cloneNode($node, $cp_options);
181 ilLoggerFactory::getLogger(
'obj')->debug(
'Start linking node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
182 $new_ref_id = $this->
linkNode($node, $cp_options);
186 case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
187 ilLoggerFactory::getLogger(
'obj')->debug(
'Start creating internal link for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
193 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
203 if (array_key_exists(
'type', $options)) {
204 $default_mode = (
int) $options[
'type'];
207 array_key_exists(
'child', $node) &&
210 return $default_mode;
214 return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
216 return $default_mode;
223 $logger =
$DIC->logger()->obj();
224 $tree =
$DIC->repositoryTree();
226 $obj_id = (
int) $node[
'obj_id'];
230 $logger->debug(
'Validating node: ' .
$ref_id .
' and root ' . $root);
231 $logger->dump(
$DIC->repositoryTree()->getRelation(
$ref_id, $root));
234 $logger->debug(
'Ignoring non child relation');
238 $logger->dump($mappings);
239 if (array_key_exists(
$ref_id, $mappings)) {
240 $logger->debug(
'Found existing mapping for linked node.');
244 $logger->info(
'Nothing found');
252 $ilLog =
$DIC->logger()->obj();
258 $soap_client->setResponseTimeout(1);
259 $soap_client->enableWSDL(
true);
260 $soap_client->init();
261 $soap_client->call(
'ilClone', array($sid, $cp_options->
getCopyId()));
276 $soap_client->setResponseTimeout(1);
277 $soap_client->enableWSDL(
true);
278 $soap_client->init();
279 $soap_client->call(
'ilCloneDependencies', array($sid, $cp_options->
getCopyId()));
291 $ilLog =
$DIC[
'ilLog'];
292 $tree =
$DIC[
'tree'];
293 $ilAccess =
$DIC[
'ilAccess'];
294 $rbacreview =
$DIC[
'rbacreview'];
295 $source_id = (
int) $node[
'child'];
296 $parent_id = (
int) $node[
'parent'];
297 $options = $cp_options->
getOptions((
int) $node[
'child']);
300 if (!$ilAccess->checkAccess(
'copy',
'', (
int) $node[
'child'])) {
301 ilLoggerFactory::getLogger(
'obj')->error(
'No copy permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
304 if (!isset($mappings[$parent_id])) {
305 ilLoggerFactory::getLogger(
'obj')->info(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
308 $target_id = $mappings[$parent_id];
310 if (!$tree->isInTree($target_id)) {
311 ilLoggerFactory::getLogger(
'obj')->notice(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. Object has been deleted.');
316 $new_obj = $orig->cloneObject((
int) $target_id, $cp_options->
getCopyId());
318 if (!is_object($new_obj)) {
319 ilLoggerFactory::getLogger(
'obj')->error(
'Error copying ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
324 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(),
false);
329 $cp_options->
appendMapping($source_id, $new_obj->getRefId());
330 return $new_obj->getRefId();
337 $ilLog =
$DIC[
'ilLog'];
339 $source_id = (
int) $node[
'child'];
342 if (!isset($mappings[$source_id])) {
343 ilLoggerFactory::getLogger(
'obj')->debug(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No mapping found.');
346 $target_id = $mappings[$source_id];
349 $orig->cloneDependencies($target_id, $cp_options->
getCopyId());
356 $ilAccess =
$DIC->access();
357 $logger =
$DIC->logger()->obj();
358 $rbacreview =
$DIC->rbac()->review();
359 $tree =
$DIC->repositoryTree();
366 $logger->error(
'Cannot create object instance.');
370 $logger->error(
'Cannot create object instance for ref_id: ' . $source_id);
371 $logger->error(
$e->getMessage());
376 $node_parent = $node[
'parent'];
377 if (!array_key_exists($node_parent, $mappings)) {
378 $logger->error(
'Cannot new parent id for node: ' . $node[
'parent']);
381 $parent_id = $mappings[$node_parent];
383 $new_ref_id = $orig->createReference();
384 $orig->putInTree($parent_id);
385 $orig->setPermissions($parent_id);
387 if (!($new_ref_id)) {
388 $logger->warning(
'Creating internal link failed.');
393 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
400 $logger->notice(
'Added mapping for ' . $node[
'child'] .
' ' . $new_ref_id);
408 $ilLog =
$DIC[
'ilLog'];
409 $ilAccess =
$DIC[
'ilAccess'];
410 $rbacreview =
$DIC[
'rbacreview'];
412 $source_id = (
int) $node[
'child'];
413 $parent_id = (
int) $node[
'parent'];
414 $options = $cp_options->
getOptions((
int) $node[
'child']);
417 if (!$ilAccess->checkAccess(
'delete',
'', (
int) $node[
'child'])) {
418 ilLoggerFactory::getLogger(
'obj')->warning(
'No delete permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
421 if (!isset($mappings[$parent_id])) {
422 ilLoggerFactory::getLogger(
'obj')->warning(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
425 $target_id = $mappings[$parent_id];
428 $new_ref_id = $orig->createReference();
429 $orig->putInTree($target_id);
430 $orig->setPermissions($target_id);
432 if (!($new_ref_id)) {
433 ilLoggerFactory::getLogger(
'obj')->error(
'Error linking ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
438 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
460 $db =
$DIC->database();
461 $logger =
$DIC->logger()->user();
464 'Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...'
468 if ($lifetime <= 0) {
469 $logger->debug(
'Registration hash lifetime is <= 0, kipping deletion.');
473 $utc_clock = (new \ILIAS\Data\Factory())->clock()->utc();
474 $now = $utc_clock->now();
475 $cutoff = $now->sub(
new DateInterval(
'PT' . $lifetime .
'S'));
480 SELECT usr_id, create_date
483 AND reg_hash IS NOT NULL
487 ORDER BY (CASE WHEN usr_id = %s THEN 0 ELSE 1 END), create_date';
492 [$formatted_cutoff, $usr_id]
495 $logger->info(sprintf(
496 '%d inactive user objects eligible for deletion found (cutoff: %s, lifetime: %d s).',
498 $cutoff->format(DateTimeInterface::ATOM),
502 $num_deleted_users = 0;
503 while ($row = $db->fetchAssoc(
$res)) {
504 $uid = (
int) $row[
'usr_id'];
511 $created = DateTimeImmutable::createFromFormat(
513 (
string) $row[
'create_date'],
514 new DateTimeZone(
'UTC')
517 $logger->info(sprintf(
518 'Deleting user (login: %s | id: %d) – expired dual opt-in (created: %s, cutoff: %s, lifetime: %d s)',
521 $created ? $created->format(DateTimeInterface::ATOM) :
'-',
522 $cutoff->format(DateTimeInterface::ATOM),
527 ++$num_deleted_users;
530 $logger->info(sprintf(
531 '%d inactive user objects with expired confirmation hash values (dual opt-in) deleted.',
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.
const DATABASE_DATE_FORMAT
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object 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)
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...