3 declare(strict_types=1);
25 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
31 return ignore_user_abort(
true);
36 $this->soap_check =
false;
51 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
67 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
76 if (!$is_initialized) {
87 $ilLog = $DIC[
'ilLog'];
88 $ilUser = $DIC[
'ilUser'];
90 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
94 if (!$cp_options->checkOwner($ilUser->getId())) {
95 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
100 if (($node = $cp_options->fetchFirstDependenciesNode()) === null) {
101 $cp_options->deleteAll();
107 $options = $cp_options->getOptions((
int) $node[
'child']);
109 switch ($options[
'type']) {
111 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
116 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
122 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
128 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
138 public function ilClone(
string $sid,
int $copy_identifier)
149 $ilUser = $DIC->user();
151 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
155 if (!$cp_options->checkOwner($ilUser->getId())) {
156 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
161 if (($node = $cp_options->fetchFirstNode()) === null) {
166 $options = $cp_options->getOptions((
int) $node[
'child']);
173 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
175 $cp_options->appendMapping($node[
'child'], 0);
181 ilLoggerFactory::getLogger(
'obj')->debug(
'Start cloning node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
182 $new_ref_id = $this->
cloneNode($node, $cp_options);
187 ilLoggerFactory::getLogger(
'obj')->debug(
'Start linking node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
188 $new_ref_id = $this->
linkNode($node, $cp_options);
192 case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
193 ilLoggerFactory::getLogger(
'obj')->debug(
'Start creating internal link for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
199 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
209 if (array_key_exists(
'type', $options)) {
210 $default_mode = (
int) $options[
'type'];
213 array_key_exists(
'child', $node) &&
216 return $default_mode;
220 return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
222 return $default_mode;
229 $logger = $DIC->logger()->obj();
230 $tree = $DIC->repositoryTree();
232 $obj_id = (
int) $node[
'obj_id'];
236 $logger->debug(
'Validating node: ' .
$ref_id .
' and root ' . $root);
237 $logger->dump($DIC->repositoryTree()->getRelation(
$ref_id, $root));
240 $logger->debug(
'Ignoring non child relation');
244 $logger->dump($mappings);
245 if (array_key_exists(
$ref_id, $mappings)) {
246 $logger->debug(
'Found existing mapping for linked node.');
250 $logger->info(
'Nothing found');
258 $ilLog = $DIC->logger()->obj();
263 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
265 $soap_client->setResponseTimeout(1);
266 $soap_client->enableWSDL(
true);
267 $soap_client->init();
268 $soap_client->call(
'ilClone', array($sid, $cp_options->
getCopyId()));
272 include_once(
'./webservice/soap/include/inc.soap_functions.php');
283 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
285 $soap_client->setResponseTimeout(1);
286 $soap_client->enableWSDL(
true);
287 $soap_client->init();
288 $soap_client->call(
'ilCloneDependencies', array($sid, $cp_options->
getCopyId()));
292 include_once(
'./webservice/soap/include/inc.soap_functions.php');
301 $ilLog = $DIC[
'ilLog'];
302 $tree = $DIC[
'tree'];
303 $ilAccess = $DIC[
'ilAccess'];
304 $rbacreview = $DIC[
'rbacreview'];
305 $source_id = (
int) $node[
'child'];
306 $parent_id = (
int) $node[
'parent'];
307 $options = $cp_options->
getOptions((
int) $node[
'child']);
310 if (!$ilAccess->checkAccess(
'copy',
'', (
int) $node[
'child'])) {
311 ilLoggerFactory::getLogger(
'obj')->error(
'No copy permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
314 if (!isset($mappings[$parent_id])) {
315 ilLoggerFactory::getLogger(
'obj')->info(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
318 $target_id = $mappings[$parent_id];
320 if (!$tree->isInTree($target_id)) {
321 ilLoggerFactory::getLogger(
'obj')->notice(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. Object has been deleted.');
326 $new_obj = $orig->cloneObject((
int) $target_id, $cp_options->
getCopyId());
328 if (!is_object($new_obj)) {
329 ilLoggerFactory::getLogger(
'obj')->error(
'Error copying ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
334 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
335 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(),
false);
340 $cp_options->
appendMapping($source_id, $new_obj->getRefId());
341 return $new_obj->getRefId();
348 $ilLog = $DIC[
'ilLog'];
350 $source_id = (
int) $node[
'child'];
353 if (!isset($mappings[$source_id])) {
354 ilLoggerFactory::getLogger(
'obj')->debug(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No mapping found.');
357 $target_id = $mappings[$source_id];
360 $orig->cloneDependencies($target_id, $cp_options->
getCopyId());
367 $ilAccess = $DIC->access();
368 $logger = $DIC->logger()->obj();
369 $rbacreview = $DIC->rbac()->review();
370 $tree = $DIC->repositoryTree();
377 $logger->error(
'Cannot create object instance.');
381 $logger->error(
'Cannot create object instance for ref_id: ' . $source_id);
382 $logger->error($e->getMessage());
387 $node_parent = $node[
'parent'];
388 if (!array_key_exists($node_parent, $mappings)) {
389 $logger->error(
'Cannot new parent id for node: ' . $node[
'parent']);
392 $parent_id = $mappings[$node_parent];
394 $new_ref_id = $orig->createReference();
395 $orig->putInTree($parent_id);
396 $orig->setPermissions($parent_id);
398 if (!($new_ref_id)) {
399 $logger->warning(
'Creating internal link failed.');
404 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
411 $logger->notice(
'Added mapping for ' . $node[
'child'] .
' ' . $new_ref_id);
419 $ilLog = $DIC[
'ilLog'];
420 $ilAccess = $DIC[
'ilAccess'];
421 $rbacreview = $DIC[
'rbacreview'];
423 $source_id = (
int) $node[
'child'];
424 $parent_id = (
int) $node[
'parent'];
425 $options = $cp_options->
getOptions((
int) $node[
'child']);
428 if (!$ilAccess->checkAccess(
'delete',
'', (
int) $node[
'child'])) {
429 ilLoggerFactory::getLogger(
'obj')->warning(
'No delete permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
432 if (!isset($mappings[$parent_id])) {
433 ilLoggerFactory::getLogger(
'obj')->warning(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
436 $target_id = $mappings[$parent_id];
439 $new_ref_id = $orig->createReference();
440 $orig->putInTree($target_id);
441 $orig->setPermissions($target_id);
443 if (!($new_ref_id)) {
444 ilLoggerFactory::getLogger(
'obj')->error(
'Error linking ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
449 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
450 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
472 $ilDB = $DIC->database();
473 $ilLog = $DIC->logger()->user();
475 $ilLog->debug(
'Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
476 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
486 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 487 .
'WHERE active = 0 ' 488 .
'AND reg_hash IS NOT NULL ' 489 .
'AND usr_id = ' .
$ilDB->quote($usr_id,
'integer') .
' ';
493 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 494 .
'WHERE active = 0 ' 495 .
'AND reg_hash IS NOT NULL ' 496 .
'AND usr_id != ' .
$ilDB->quote($usr_id,
'integer') .
' ';
500 $ilLog->debug(
$ilDB->numRows(
$res) .
' inactive user objects with confirmation hash values (dual opt in) found ...');
508 $num_deleted_users = 0;
514 if (($row[
'reg_hash'] ??
'') ===
'') {
518 if (($row[
'create_date'] ??
'') !==
'' &&
519 $oRegSettigs->getRegistrationHashLifetime() > 0 &&
520 time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row[
'create_date'])) {
523 $ilLog->info(
'User ' . $user->getLogin() .
' (obj_id: ' . $user->getId() .
') will be deleted due to an expired registration hash ...');
525 ++$num_deleted_users;
530 $ilLog->info($num_deleted_users .
' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
531 $ilLog->info(
'Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
static gatherFaPa(int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
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.
appendMapping($a_source_id, $a_target_id)
Add mapping of source -> target.
static ilCloneDependencies(string $sid, int $copy_identifier)
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
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 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())