3 declare(strict_types=1);
30 return ignore_user_abort(
true);
35 $this->soap_check =
false;
73 if (!$is_initialized) {
84 $ilLog = $DIC[
'ilLog'];
85 $ilUser = $DIC[
'ilUser'];
90 if (!$cp_options->checkOwner($ilUser->getId())) {
91 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
96 if (($node = $cp_options->fetchFirstDependenciesNode()) === null) {
97 $cp_options->deleteAll();
103 $options = $cp_options->getOptions((
int) $node[
'child']);
105 switch ($options[
'type']) {
107 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
112 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
118 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
124 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
134 public function ilClone(
string $sid,
int $copy_identifier)
145 $ilUser = $DIC->user();
150 if (!$cp_options->checkOwner($ilUser->getId())) {
151 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
156 if (($node = $cp_options->fetchFirstNode()) === null) {
161 $options = $cp_options->getOptions((
int) $node[
'child']);
168 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
170 $cp_options->appendMapping($node[
'child'], 0);
176 ilLoggerFactory::getLogger(
'obj')->debug(
'Start cloning node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
177 $new_ref_id = $this->
cloneNode($node, $cp_options);
182 ilLoggerFactory::getLogger(
'obj')->debug(
'Start linking node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
183 $new_ref_id = $this->
linkNode($node, $cp_options);
187 case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
188 ilLoggerFactory::getLogger(
'obj')->debug(
'Start creating internal link for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
194 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
204 if (array_key_exists(
'type', $options)) {
205 $default_mode = (
int) $options[
'type'];
208 array_key_exists(
'child', $node) &&
211 return $default_mode;
215 return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
217 return $default_mode;
224 $logger = $DIC->logger()->obj();
225 $tree = $DIC->repositoryTree();
227 $obj_id = (
int) $node[
'obj_id'];
231 $logger->debug(
'Validating node: ' .
$ref_id .
' and root ' . $root);
232 $logger->dump($DIC->repositoryTree()->getRelation(
$ref_id, $root));
235 $logger->debug(
'Ignoring non child relation');
239 $logger->dump($mappings);
240 if (array_key_exists(
$ref_id, $mappings)) {
241 $logger->debug(
'Found existing mapping for linked node.');
245 $logger->info(
'Nothing found');
253 $ilLog = $DIC->logger()->obj();
259 $soap_client->setResponseTimeout(1);
260 $soap_client->enableWSDL(
true);
261 $soap_client->init();
262 $soap_client->call(
'ilClone', array($sid, $cp_options->
getCopyId()));
277 $soap_client->setResponseTimeout(1);
278 $soap_client->enableWSDL(
true);
279 $soap_client->init();
280 $soap_client->call(
'ilCloneDependencies', array($sid, $cp_options->
getCopyId()));
292 $ilLog = $DIC[
'ilLog'];
293 $tree = $DIC[
'tree'];
294 $ilAccess = $DIC[
'ilAccess'];
295 $rbacreview = $DIC[
'rbacreview'];
296 $source_id = (
int) $node[
'child'];
297 $parent_id = (
int) $node[
'parent'];
298 $options = $cp_options->
getOptions((
int) $node[
'child']);
301 if (!$ilAccess->checkAccess(
'copy',
'', (
int) $node[
'child'])) {
302 ilLoggerFactory::getLogger(
'obj')->error(
'No copy permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
305 if (!isset($mappings[$parent_id])) {
306 ilLoggerFactory::getLogger(
'obj')->info(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
309 $target_id = $mappings[$parent_id];
311 if (!$tree->isInTree($target_id)) {
312 ilLoggerFactory::getLogger(
'obj')->notice(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. Object has been deleted.');
317 $new_obj = $orig->cloneObject((
int) $target_id, $cp_options->
getCopyId());
319 if (!is_object($new_obj)) {
320 ilLoggerFactory::getLogger(
'obj')->error(
'Error copying ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
325 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(),
false);
330 $cp_options->
appendMapping($source_id, $new_obj->getRefId());
331 return $new_obj->getRefId();
338 $ilLog = $DIC[
'ilLog'];
340 $source_id = (
int) $node[
'child'];
343 if (!isset($mappings[$source_id])) {
344 ilLoggerFactory::getLogger(
'obj')->debug(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No mapping found.');
347 $target_id = $mappings[$source_id];
350 $orig->cloneDependencies($target_id, $cp_options->
getCopyId());
357 $ilAccess = $DIC->access();
358 $logger = $DIC->logger()->obj();
359 $rbacreview = $DIC->rbac()->review();
360 $tree = $DIC->repositoryTree();
367 $logger->error(
'Cannot create object instance.');
371 $logger->error(
'Cannot create object instance for ref_id: ' . $source_id);
372 $logger->error($e->getMessage());
377 $node_parent = $node[
'parent'];
378 if (!array_key_exists($node_parent, $mappings)) {
379 $logger->error(
'Cannot new parent id for node: ' . $node[
'parent']);
382 $parent_id = $mappings[$node_parent];
384 $new_ref_id = $orig->createReference();
385 $orig->putInTree($parent_id);
386 $orig->setPermissions($parent_id);
388 if (!($new_ref_id)) {
389 $logger->warning(
'Creating internal link failed.');
394 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
401 $logger->notice(
'Added mapping for ' . $node[
'child'] .
' ' . $new_ref_id);
409 $ilLog = $DIC[
'ilLog'];
410 $ilAccess = $DIC[
'ilAccess'];
411 $rbacreview = $DIC[
'rbacreview'];
413 $source_id = (
int) $node[
'child'];
414 $parent_id = (
int) $node[
'parent'];
415 $options = $cp_options->
getOptions((
int) $node[
'child']);
418 if (!$ilAccess->checkAccess(
'delete',
'', (
int) $node[
'child'])) {
419 ilLoggerFactory::getLogger(
'obj')->warning(
'No delete permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
422 if (!isset($mappings[$parent_id])) {
423 ilLoggerFactory::getLogger(
'obj')->warning(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
426 $target_id = $mappings[$parent_id];
429 $new_ref_id = $orig->createReference();
430 $orig->putInTree($target_id);
431 $orig->setPermissions($target_id);
433 if (!($new_ref_id)) {
434 ilLoggerFactory::getLogger(
'obj')->error(
'Error linking ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
439 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
461 $ilDB = $DIC->database();
462 $ilLog = $DIC->logger()->user();
464 $ilLog->debug(
'Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
474 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 475 .
'WHERE active = 0 ' 476 .
'AND reg_hash IS NOT NULL ' 477 .
'AND usr_id = ' .
$ilDB->quote($usr_id,
'integer') .
' ';
481 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 482 .
'WHERE active = 0 ' 483 .
'AND reg_hash IS NOT NULL ' 484 .
'AND usr_id != ' .
$ilDB->quote($usr_id,
'integer') .
' ';
488 $ilLog->debug(
$ilDB->numRows(
$res) .
' inactive user objects with confirmation hash values (dual opt in) found ...');
496 $num_deleted_users = 0;
502 if (($row[
'reg_hash'] ??
'') ===
'') {
506 if (($row[
'create_date'] ??
'') !==
'' &&
507 $oRegSettigs->getRegistrationHashLifetime() > 0 &&
508 time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row[
'create_date'])) {
511 $ilLog->info(
'User ' . $user->getLogin() .
' (obj_id: ' . $user->getId() .
') will be deleted due to an expired registration hash ...');
513 ++$num_deleted_users;
518 $ilLog->info($num_deleted_users .
' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
519 $ilLog->info(
'Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
static getLogger(string $a_component_id)
Get component logger.
static ilClone(string $sid, int $copy_identifier)
const COPY_WIZARD_UNDEFINED
saveTempFileAsMediaObject(string $sid, string $name, string $tmp_name)
deleteExpiredDualOptInUserObjects(string $sid, int $usr_id)
Method for soap webservice: deleteExpiredDualOptInUserObjects This service will run in background...
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
static _getAllReferences(int $id)
get all reference ids for object ID
ilClone(string $sid, int $copy_identifier)
ilCloneDependencies(string $sid, int $copy_identifier, bool $is_initialized=false)
linkNode(array $node, ilCopyWizardOptions $cp_options)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
cloneNode(array $node, ilCopyWizardOptions $cp_options)
raiseError(string $a_message, $a_code)
rewriteActionForNode(ilCopyWizardOptions $cpo, array $node, array $options)
cloneDependencies(array $node, ilCopyWizardOptions $cp_options)
internalLinkNode(array $node, ilCopyWizardOptions $cp_options)
getOptions(int $a_source_id)
Get entry by source public.
isSOAPEnabled()
Check if SOAP calls are disabled.
static gatherFaPa(int $ref_id, array $role_ids, bool $add_action=false)
appendMapping($a_source_id, $a_target_id)
Add mapping of source -> target.
static ilCloneDependencies(string $sid, int $copy_identifier)
callNextNode(string $sid, ilCopyWizardOptions $cp_options)
getMobsOfObject(string $sid, string $a_type, int $a_id)
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
checkSession(string $sid)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
dropFirstDependenciesNode()
Drop first node (for cloneDependencies())
static add(int $action, int $ref_id, array $diff, bool $source_ref_id=false)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjAuthSettingsGUI.
callNextDependency(string $sid, ilCopyWizardOptions $cp_options)
isRootNode(int $a_root)
Is root node public.
static _getInstance(int $a_copy_id)
dropFirstNode()
Drop first node (for cloneObject())