ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSoapUtils Class Reference

Soap utitliy functions. More...

+ Inheritance diagram for ilSoapUtils:
+ Collaboration diagram for ilSoapUtils:

Public Member Functions

 ignoreUserAbort ()
 
 disableSOAPCheck ()
 
 distributeMails (string $sid, string $a_mail_xml)
 
 saveTempFileAsMediaObject (string $sid, string $name, string $tmp_name)
 
 getMobsOfObject (string $sid, string $a_type, int $a_id)
 
 ilCloneDependencies (string $sid, int $copy_identifier, bool $is_initialized=false)
 
 ilClone (string $sid, int $copy_identifier)
 
 deleteExpiredDualOptInUserObjects (string $sid, int $usr_id)
 Method for soap webservice: deleteExpiredDualOptInUserObjects This service will run in background. More...
 
- Public Member Functions inherited from ilSoapAdministration
 __construct (bool $use_nusoap=true)
 
 getMessage ()
 
 appendMessage (string $a_str)
 
 setMessageCode (string $a_code)
 
 getMessageCode ()
 
 reInitUser ()
 
 isFault ($object)
 
 getInstallationInfoXML ()
 
 getClientInfoXML (string $clientid)
 

Protected Member Functions

 rewriteActionForNode (ilCopyWizardOptions $cpo, array $node, array $options)
 
 findMappedReferenceForNode (\ilCopyWizardOptions $cpo, array $node)
 
- Protected Member Functions inherited from ilSoapAdministration
 checkSession (string $sid)
 
 explodeSid (string $sid)
 
 setMessage (string $a_str)
 
 initAuth (string $sid)
 
 initIlias ()
 
 initAuthenticationObject ()
 
 raiseError (string $a_message, $a_code)
 
 checkObjectAccess (int $ref_id, array $expected_type, string $permission, bool $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 

Private Member Functions

 callNextNode (string $sid, ilCopyWizardOptions $cp_options)
 
 callNextDependency (string $sid, ilCopyWizardOptions $cp_options)
 
 cloneNode (array $node, ilCopyWizardOptions $cp_options)
 
 cloneDependencies (array $node, ilCopyWizardOptions $cp_options)
 
 internalLinkNode (array $node, ilCopyWizardOptions $cp_options)
 
 linkNode (array $node, ilCopyWizardOptions $cp_options)
 

Additional Inherited Members

- Data Fields inherited from ilSoapAdministration
const NUSOAP = 1
 
const PHP5 = 2
 
int $error_method
 Defines type of error handling (PHP5 || NUSOAP) More...
 
- Protected Attributes inherited from ilSoapAdministration
bool $soap_check = true
 
string $message = ''
 
string $message_code = ''
 

Detailed Description

Soap utitliy functions.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 32 of file class.ilSoapUtils.php.

Member Function Documentation

◆ callNextDependency()

ilSoapUtils::callNextDependency ( string  $sid,
ilCopyWizardOptions  $cp_options 
)
private

Definition at line 360 of file class.ilSoapUtils.php.

References $res, ilCopyWizardOptions\dropFirstDependenciesNode(), ilCopyWizardOptions\getCopyId(), ilLoggerFactory\getLogger(), ilSoapFunctions\ilCloneDependencies(), ilCopyWizardOptions\isSOAPEnabled(), and ilCopyWizardOptions\read().

Referenced by ilCloneDependencies().

360  : void
361  {
362  $cp_options->dropFirstDependenciesNode();
363 
364  if ($cp_options->isSOAPEnabled()) {
365  // Start next soap call
366  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
367  $soap_client = new ilSoapClient();
368  $soap_client->setResponseTimeout(1);
369  $soap_client->enableWSDL(true);
370  $soap_client->init();
371  $soap_client->call('ilCloneDependencies', array($sid, $cp_options->getCopyId()));
372  } else {
373  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
374  $cp_options->read();
375  include_once('./webservice/soap/include/inc.soap_functions.php');
376  $res = ilSoapFunctions::ilCloneDependencies($sid, $cp_options->getCopyId());
377  }
378  }
$res
Definition: ltiservices.php:69
static getLogger(string $a_component_id)
Get component logger.
isSOAPEnabled()
Check if SOAP calls are disabled.
static ilCloneDependencies(string $sid, int $copy_identifier)
dropFirstDependenciesNode()
Drop first node (for cloneDependencies())
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ callNextNode()

ilSoapUtils::callNextNode ( string  $sid,
ilCopyWizardOptions  $cp_options 
)
private

Definition at line 337 of file class.ilSoapUtils.php.

References $DIC, $res, ilCopyWizardOptions\dropFirstNode(), ilCopyWizardOptions\getCopyId(), ilLoggerFactory\getLogger(), ilSoapFunctions\ilClone(), ilCopyWizardOptions\isSOAPEnabled(), and ilCopyWizardOptions\read().

Referenced by ilClone().

337  : void
338  {
339  global $DIC;
340 
341  $ilLog = $DIC->logger()->obj();
342 
343  $cp_options->dropFirstNode();
344  if ($cp_options->isSOAPEnabled()) {
345  // Start next soap call
346  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
347  $soap_client = new ilSoapClient();
348  $soap_client->setResponseTimeout(1);
349  $soap_client->enableWSDL(true);
350  $soap_client->init();
351  $soap_client->call('ilClone', array($sid, $cp_options->getCopyId()));
352  } else {
353  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
354  $cp_options->read();
355  include_once('./webservice/soap/include/inc.soap_functions.php');
356  $res = ilSoapFunctions::ilClone($sid, $cp_options->getCopyId());
357  }
358  }
$res
Definition: ltiservices.php:69
static getLogger(string $a_component_id)
Get component logger.
static ilClone(string $sid, int $copy_identifier)
global $DIC
Definition: feed.php:28
isSOAPEnabled()
Check if SOAP calls are disabled.
dropFirstNode()
Drop first node (for cloneObject())
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneDependencies()

ilSoapUtils::cloneDependencies ( array  $node,
ilCopyWizardOptions  $cp_options 
)
private

Definition at line 427 of file class.ilSoapUtils.php.

References $DIC, $target_id, ilCopyWizardOptions\getCopyId(), ilObjectFactory\getInstanceByRefId(), ilLoggerFactory\getLogger(), ilCopyWizardOptions\getMappings(), and ILIAS\Repository\int().

Referenced by ilCloneDependencies().

427  : void
428  {
429  global $DIC;
430 
431  $ilLog = $DIC['ilLog'];
432 
433  $source_id = (int) $node['child'];
434  $mappings = $cp_options->getMappings();
435 
436  if (!isset($mappings[$source_id])) {
437  ilLoggerFactory::getLogger('obj')->debug('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No mapping found.');
438  return;
439  }
440  $target_id = $mappings[$source_id];
441 
442  $orig = ilObjectFactory::getInstanceByRefId($source_id);
443  $orig->cloneDependencies($target_id, $cp_options->getCopyId());
444  }
static getLogger(string $a_component_id)
Get component logger.
$target_id
Definition: goto.php:52
global $DIC
Definition: feed.php:28
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneNode()

ilSoapUtils::cloneNode ( array  $node,
ilCopyWizardOptions  $cp_options 
)
private

Definition at line 380 of file class.ilSoapUtils.php.

References $DIC, $target_id, ilRbacLog\add(), ilCopyWizardOptions\appendMapping(), ilRbacLog\COPY_OBJECT, ilRbacLog\gatherFaPa(), ilCopyWizardOptions\getCopyId(), ilObjectFactory\getInstanceByRefId(), ilLoggerFactory\getLogger(), ilCopyWizardOptions\getMappings(), ilCopyWizardOptions\getOptions(), and ILIAS\Repository\int().

Referenced by ilClone().

380  : int
381  {
382  global $DIC;
383 
384  $ilLog = $DIC['ilLog'];
385  $tree = $DIC['tree'];
386  $ilAccess = $DIC['ilAccess'];
387  $rbacreview = $DIC['rbacreview'];
388  $source_id = (int) $node['child'];
389  $parent_id = (int) $node['parent'];
390  $options = $cp_options->getOptions((int) $node['child']);
391  $mappings = $cp_options->getMappings();
392 
393  if (!$ilAccess->checkAccess('copy', '', (int) $node['child'])) {
394  ilLoggerFactory::getLogger('obj')->error('No copy permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
395  return 0;
396  }
397  if (!isset($mappings[$parent_id])) {
398  ilLoggerFactory::getLogger('obj')->info('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
399  return 0;
400  }
401  $target_id = $mappings[$parent_id];
402 
403  if (!$tree->isInTree($target_id)) {
404  ilLoggerFactory::getLogger('obj')->notice('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. Object has been deleted.');
405  return 0;
406  }
407 
408  $orig = ilObjectFactory::getInstanceByRefId($source_id);
409  $new_obj = $orig->cloneObject((int) $target_id, $cp_options->getCopyId());
410 
411  if (!is_object($new_obj)) {
412  ilLoggerFactory::getLogger('obj')->error('Error copying ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
413  return 0;
414  }
415 
416  // rbac log
417  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
418  $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
419  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
420  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, true);
421 
422  // Finally add new mapping entry
423  $cp_options->appendMapping($source_id, $new_obj->getRefId());
424  return $new_obj->getRefId();
425  }
static gatherFaPa(int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
static getLogger(string $a_component_id)
Get component logger.
$target_id
Definition: goto.php:52
getOptions(int $a_source_id)
Get entry by source public.
global $DIC
Definition: feed.php:28
appendMapping($a_source_id, $a_target_id)
Add mapping of source -> target.
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
const COPY_OBJECT
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteExpiredDualOptInUserObjects()

ilSoapUtils::deleteExpiredDualOptInUserObjects ( string  $sid,
int  $usr_id 
)

Method for soap webservice: deleteExpiredDualOptInUserObjects This service will run in background.

The client has not to wait for response.

Definition at line 546 of file class.ilSoapUtils.php.

References $DIC, $ilDB, $query, $res, ANONYMOUS_USER_ID, ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ILIAS\Repository\int(), and SYSTEM_USER_ID.

546  : bool
547  {
548  $this->initAuth($sid);
549  $this->initIlias();
550 
551  // Session check not possible -> anonymous user is the trigger
552 
553  global $DIC;
554 
555  $ilDB = $DIC->database();
556  $ilLog = $DIC->logger()->user();
557 
558  $ilLog->debug('Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
559  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
560  $oRegSettigs = new ilRegistrationSettings();
561  $query = '';
562 
563  /*
564  * Fetch the current actuator user object first, because this user will try to perform very probably
565  * a new registration with the same login name in a few seconds ;-)
566  *
567  */
568  if ($usr_id > 0) {
569  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
570  . 'WHERE active = 0 '
571  . 'AND reg_hash IS NOT NULL '
572  . 'AND usr_id = ' . $ilDB->quote($usr_id, 'integer') . ' ';
573  $query .= 'UNION ';
574  }
575 
576  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
577  . 'WHERE active = 0 '
578  . 'AND reg_hash IS NOT NULL '
579  . 'AND usr_id != ' . $ilDB->quote($usr_id, 'integer') . ' ';
580 
581  $res = $ilDB->query($query);
582 
583  $ilLog->debug($ilDB->numRows($res) . ' inactive user objects with confirmation hash values (dual opt in) found ...');
584 
585  /*
586  * mjansen: 15.12.2010:
587  * I perform the expiration check in php because of multi database support (mysql, postgresql).
588  * I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP()
589  */
590 
591  $num_deleted_users = 0;
592  while ($row = $ilDB->fetchAssoc($res)) {
593  if ((int) $row['usr_id'] === ANONYMOUS_USER_ID || (int) $row['usr_id'] === SYSTEM_USER_ID) {
594  continue;
595  }
596 
597  if (($row['reg_hash'] ?? '') === '') {
598  continue;
599  }
600 
601  if (($row['create_date'] ?? '') !== '' &&
602  $oRegSettigs->getRegistrationHashLifetime() > 0 &&
603  time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
604  $user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false);
605  if ($user instanceof ilObjUser) {
606  $ilLog->info('User ' . $user->getLogin() . ' (obj_id: ' . $user->getId() . ') will be deleted due to an expired registration hash ...');
607  $user->delete();
608  ++$num_deleted_users;
609  }
610  }
611  }
612 
613  $ilLog->info($num_deleted_users . ' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
614  $ilLog->info('Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
615 
616  return true;
617  }
$res
Definition: ltiservices.php:69
const ANONYMOUS_USER_ID
Definition: constants.php:27
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
global $DIC
Definition: feed.php:28
$query
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjAuthSettingsGUI.
+ Here is the call graph for this function:

◆ disableSOAPCheck()

ilSoapUtils::disableSOAPCheck ( )

Definition at line 39 of file class.ilSoapUtils.php.

39  : void
40  {
41  $this->soap_check = false;
42  }

◆ distributeMails()

ilSoapUtils::distributeMails ( string  $sid,
string  $a_mail_xml 
)
Deprecated:
Returns
bool|soap_fault|SoapFault|null

Definition at line 48 of file class.ilSoapUtils.php.

References $DIC, Vendor\Package\$e, $ilUser, ilFileUtils\_sanitizeFilemame(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), and ilFileDataMail\storeAsAttachment().

49  {
50  $this->initAuth($sid);
51  $this->initIlias();
52 
53  global $DIC;
54  $logger = $DIC->logger->wsrv();
55 
56  if (!$this->checkSession($sid)) {
57  return $this->raiseError($this->getMessage(), $this->getMessageCode());
58  }
59 
60  include_once 'Services/Mail/classes/class.ilMail.php';
61  include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
62 
63  $parser = new ilSoapMailXmlParser($a_mail_xml);
64  try {
65  // Check if wellformed
66  libxml_use_internal_errors(true);
67  $ok = simplexml_load_string($a_mail_xml);
68  if (!$ok) {
69  $error = '';
70  foreach (libxml_get_errors() as $err) {
71  $error .= ($err->message . ' ');
72  }
73  return $this->raiseError($error, 'CLIENT');
74  }
75  $parser->start();
77  $logger->warning($e->getMessage());
78  return $this->raiseError($e->getMessage(), 'CLIENT');
79  }
80  $mails = $parser->getMails();
81  $ilUser = $DIC->user();
82 
83  foreach ($mails as $mail) {
84  include_once './Services/Mail/classes/class.ilFileDataMail.php';
85  $file = new ilFileDataMail($ilUser->getId());
86  $attachments = [];
87  foreach ((array) $mail['attachments'] as $attachment) {
88  $file->storeAsAttachment($attachment['name'], $attachment['content']);
89  $attachments[] = ilFileUtils::_sanitizeFilemame($attachment['name']);
90  }
91 
92  $mail_obj = new ilMail($ilUser->getId());
93  $mail_obj->setSaveInSentbox(true);
94  $mail_obj->saveAttachments($attachments);
95  $mail_obj->enqueue(
96  implode(',', (array) $mail['to']),
97  implode(',', (array) $mail['cc']),
98  implode(',', (array) $mail['bcc']),
99  $mail['subject'],
100  implode("\n", (array) $mail['body']),
101  $attachments,
102  (bool) $mail['usePlaceholders']
103  );
104 
105  foreach ($attachments as $att) {
106  $file->unlinkFile($att);
107  }
108  $mail_obj->persistToStage(
109  $ilUser->getId(),
110  [],
111  '',
112  '',
113  '',
114  '',
115  ''
116  );
117  }
118  return true;
119  }
storeAsAttachment(string $a_filename, string $a_content)
This class handles all operations on files (attachments) in directory ilias_data/mail.
raiseError(string $a_message, $a_code)
SaxParserException thrown by ilSaxParser if property throwException is set.
global $DIC
Definition: feed.php:28
XML parser for soap mails.
static _sanitizeFilemame(string $a_filename)
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ findMappedReferenceForNode()

ilSoapUtils::findMappedReferenceForNode ( \ilCopyWizardOptions  $cpo,
array  $node 
)
protected

Definition at line 308 of file class.ilSoapUtils.php.

References $DIC, $ref_id, ilObject\_getAllReferences(), ilCopyWizardOptions\getMappings(), ilCopyWizardOptions\getRootNode(), ILIAS\Repository\int(), and ilTree\RELATION_CHILD.

Referenced by internalLinkNode(), and rewriteActionForNode().

308  : ?int
309  {
310  global $DIC;
311 
312  $logger = $DIC->logger()->obj();
313  $tree = $DIC->repositoryTree();
314  $root = $cpo->getRootNode();
315  $obj_id = (int) $node['obj_id'];
316 
317  $mappings = $cpo->getMappings();
318  foreach (\ilObject::_getAllReferences($obj_id) as $ref_id => $also_ref_id) {
319  $logger->debug('Validating node: ' . $ref_id . ' and root ' . $root);
320  $logger->dump($DIC->repositoryTree()->getRelation($ref_id, $root));
321 
322  if ($DIC->repositoryTree()->getRelation($ref_id, $root) !== \ilTree::RELATION_CHILD) {
323  $logger->debug('Ignoring non child relation');
324  continue;
325  }
326  // check if mapping is already available
327  $logger->dump($mappings);
328  if (array_key_exists($ref_id, $mappings)) {
329  $logger->debug('Found existing mapping for linked node.');
330  return $mappings[$ref_id];
331  }
332  }
333  $logger->info('Nothing found');
334  return null;
335  }
static _getAllReferences(int $id)
get all reference ids for object ID
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
const RELATION_CHILD
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMobsOfObject()

ilSoapUtils::getMobsOfObject ( string  $sid,
string  $a_type,
int  $a_id 
)
Returns
int[]|soap_fault|SoapFault|null

Definition at line 140 of file class.ilSoapUtils.php.

References ilObjMediaObject\_getMobsOfObject(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

141  {
142  $this->initAuth($sid);
143  $this->initIlias();
144 
145  if (!$this->checkSession($sid)) {
146  return $this->raiseError($this->getMessage(), $this->getMessageCode());
147  }
148 
149  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
150  return ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
151  }
raiseError(string $a_message, $a_code)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:

◆ ignoreUserAbort()

ilSoapUtils::ignoreUserAbort ( )

Definition at line 34 of file class.ilSoapUtils.php.

34  : int
35  {
36  return ignore_user_abort(true);
37  }

◆ ilClone()

ilSoapUtils::ilClone ( string  $sid,
int  $copy_identifier 
)
Returns
bool|int|soap_fault|SoapFault|null

Definition at line 220 of file class.ilSoapUtils.php.

References $DIC, $ilUser, ilCopyWizardOptions\_getInstance(), callNextNode(), ilSoapAdministration\checkSession(), cloneNode(), ilCopyWizardOptions\COPY_WIZARD_COPY, ilCopyWizardOptions\COPY_WIZARD_LINK, ilCopyWizardOptions\COPY_WIZARD_OMIT, ilLoggerFactory\getLogger(), ilSoapAdministration\getMessage(), ilCloneDependencies(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), internalLinkNode(), linkNode(), and rewriteActionForNode().

221  {
222  $this->initAuth($sid);
223  $this->initIlias();
224 
225  if (!$this->checkSession($sid)) {
226  ilLoggerFactory::getLogger('obj')->error('Object cloning failed. Invalid session given: ' . $this->getMessage());
227  }
228 
229  global $DIC;
230 
231  $ilUser = $DIC->user();
232 
233  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
234  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
235 
236  // Check owner of copy procedure
237  if (!$cp_options->checkOwner($ilUser->getId())) {
238  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
239  return false;
240  }
241 
242  // Fetch first node
243  if (($node = $cp_options->fetchFirstNode()) === null) {
244  ilLoggerFactory::getLogger('obj')->info('Finished copy step 1. Starting copying of object dependencies...');
245  return $this->ilCloneDependencies($sid, $copy_identifier, true);
246  }
247  // Check options of this node
248  $options = $cp_options->getOptions((int) $node['child']);
249 
250  $action = $this->rewriteActionForNode($cp_options, $node, $options);
251 
252  $new_ref_id = 0;
253  switch ($action) {
255  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
256  // set mapping to zero
257  $cp_options->appendMapping($node['child'], 0);
258  $this->callNextNode($sid, $cp_options);
259  break;
260 
262 
263  ilLoggerFactory::getLogger('obj')->debug('Start cloning node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
264  $new_ref_id = $this->cloneNode($node, $cp_options);
265  $this->callNextNode($sid, $cp_options);
266  break;
267 
269  ilLoggerFactory::getLogger('obj')->debug('Start linking node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
270  $new_ref_id = $this->linkNode($node, $cp_options);
271  $this->callNextNode($sid, $cp_options);
272  break;
273 
274  case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
275  ilLoggerFactory::getLogger('obj')->debug('Start creating internal link for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
276  $new_ref_id = $this->internalLinkNode($node, $cp_options);
277  $this->callNextNode($sid, $cp_options);
278  break;
279 
280  default:
281  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
282  $this->callNextNode($sid, $cp_options);
283  break;
284 
285  }
286  return $new_ref_id;
287  }
static getLogger(string $a_component_id)
Get component logger.
ilCloneDependencies(string $sid, int $copy_identifier, bool $is_initialized=false)
linkNode(array $node, ilCopyWizardOptions $cp_options)
cloneNode(array $node, ilCopyWizardOptions $cp_options)
rewriteActionForNode(ilCopyWizardOptions $cpo, array $node, array $options)
internalLinkNode(array $node, ilCopyWizardOptions $cp_options)
global $DIC
Definition: feed.php:28
callNextNode(string $sid, ilCopyWizardOptions $cp_options)
$ilUser
Definition: imgupload.php:34
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ ilCloneDependencies()

ilSoapUtils::ilCloneDependencies ( string  $sid,
int  $copy_identifier,
bool  $is_initialized = false 
)
Returns
bool|soap_fault|SoapFault|null

Definition at line 156 of file class.ilSoapUtils.php.

References $DIC, $ilUser, ilCopyWizardOptions\_getInstance(), callNextDependency(), ilSoapAdministration\checkSession(), cloneDependencies(), ilCopyWizardOptions\COPY_WIZARD_COPY, ilCopyWizardOptions\COPY_WIZARD_LINK, ilCopyWizardOptions\COPY_WIZARD_OMIT, ilLoggerFactory\getLogger(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

Referenced by ilClone().

157  {
158  if (!$is_initialized) {
159  $this->initAuth($sid);
160  $this->initIlias();
161 
162  if (!$this->checkSession($sid)) {
163  return $this->raiseError($this->getMessage(), $this->getMessageCode());
164  }
165  }
166 
167  global $DIC;
168 
169  $ilLog = $DIC['ilLog'];
170  $ilUser = $DIC['ilUser'];
171 
172  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
173  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
174 
175  // Check owner of copy procedure
176  if (!$cp_options->checkOwner($ilUser->getId())) {
177  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
178  return false;
179  }
180 
181  // Fetch first node
182  if (($node = $cp_options->fetchFirstDependenciesNode()) === null) {
183  $cp_options->deleteAll();
184  ilLoggerFactory::getLogger('obj')->info('Finished copy step 2. Copy completed');
185  return true;
186  }
187 
188  // Check options of this node
189  $options = $cp_options->getOptions((int) $node['child']);
190  $new_ref_id = 0;
191  switch ($options['type']) {
193  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
194  $this->callNextDependency($sid, $cp_options);
195  break;
196 
198  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
199  $this->cloneDependencies($node, $cp_options);
200  $this->callNextDependency($sid, $cp_options);
201  break;
202 
204  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
205  $this->cloneDependencies($node, $cp_options);
206  $this->callNextDependency($sid, $cp_options);
207  break;
208 
209  default:
210  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
211  $this->callNextDependency($sid, $cp_options);
212  break;
213  }
214  return true;
215  }
static getLogger(string $a_component_id)
Get component logger.
raiseError(string $a_message, $a_code)
cloneDependencies(array $node, ilCopyWizardOptions $cp_options)
global $DIC
Definition: feed.php:28
callNextDependency(string $sid, ilCopyWizardOptions $cp_options)
$ilUser
Definition: imgupload.php:34
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ internalLinkNode()

ilSoapUtils::internalLinkNode ( array  $node,
ilCopyWizardOptions  $cp_options 
)
private

Definition at line 446 of file class.ilSoapUtils.php.

References $DIC, Vendor\Package\$e, ilRbacLog\add(), ilCopyWizardOptions\appendMapping(), findMappedReferenceForNode(), ilRbacLog\gatherFaPa(), ilObjectFactory\getInstanceByRefId(), ilCopyWizardOptions\getMappings(), and ilRbacLog\LINK_OBJECT.

Referenced by ilClone().

446  : int
447  {
448  global $DIC;
449 
450  $ilAccess = $DIC->access();
451  $logger = $DIC->logger()->obj();
452  $rbacreview = $DIC->rbac()->review();
453  $tree = $DIC->repositoryTree();
454  $mappings = $cp_options->getMappings();
455 
456  $source_id = $this->findMappedReferenceForNode($cp_options, $node);
457  try {
458  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
459  if (!$orig instanceof \ilObject) {
460  $logger->error('Cannot create object instance.');
461  return 0;
462  }
463  } catch (\ilObjectNotFoundException $e) {
464  $logger->error('Cannot create object instance for ref_id: ' . $source_id);
465  $logger->error($e->getMessage());
466  return 0;
467  }
468 
469  // target (parent id) is the mapped parent id of the current node
470  $node_parent = $node['parent'];
471  if (!array_key_exists($node_parent, $mappings)) {
472  $logger->error('Cannot new parent id for node: ' . $node['parent']);
473  return 0;
474  }
475  $parent_id = $mappings[$node_parent];
476 
477  $new_ref_id = $orig->createReference();
478  $orig->putInTree($parent_id);
479  $orig->setPermissions($parent_id);
480 
481  if (!($new_ref_id)) {
482  $logger->warning('Creating internal link failed.');
483  return 0;
484  }
485 
486  // rbac log
487  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
488  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
489  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, true);
490 
491  // Finally add new mapping entry
492  $cp_options->appendMapping($node['child'], $new_ref_id);
493 
494  $logger->notice('Added mapping for ' . $node['child'] . ' ' . $new_ref_id);
495  return $new_ref_id;
496  }
static gatherFaPa(int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
appendMapping($a_source_id, $a_target_id)
Add mapping of source -> target.
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
const LINK_OBJECT
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ linkNode()

ilSoapUtils::linkNode ( array  $node,
ilCopyWizardOptions  $cp_options 
)
private

Definition at line 498 of file class.ilSoapUtils.php.

References $DIC, $target_id, ilRbacLog\add(), ilCopyWizardOptions\appendMapping(), ilRbacLog\gatherFaPa(), ilObjectFactory\getInstanceByRefId(), ilLoggerFactory\getLogger(), ilCopyWizardOptions\getMappings(), ilCopyWizardOptions\getOptions(), ILIAS\Repository\int(), and ilRbacLog\LINK_OBJECT.

Referenced by ilClone().

498  : int
499  {
500  global $DIC;
501 
502  $ilLog = $DIC['ilLog'];
503  $ilAccess = $DIC['ilAccess'];
504  $rbacreview = $DIC['rbacreview'];
505 
506  $source_id = (int) $node['child'];
507  $parent_id = (int) $node['parent'];
508  $options = $cp_options->getOptions((int) $node['child']);
509  $mappings = $cp_options->getMappings();
510 
511  if (!$ilAccess->checkAccess('delete', '', (int) $node['child'])) {
512  ilLoggerFactory::getLogger('obj')->warning('No delete permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
513  return 0;
514  }
515  if (!isset($mappings[$parent_id])) {
516  ilLoggerFactory::getLogger('obj')->warning('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
517  return 0;
518  }
519  $target_id = $mappings[$parent_id];
520 
521  $orig = ilObjectFactory::getInstanceByRefId($source_id);
522  $new_ref_id = $orig->createReference();
523  $orig->putInTree($target_id);
524  $orig->setPermissions($target_id);
525 
526  if (!($new_ref_id)) {
527  ilLoggerFactory::getLogger('obj')->error('Error linking ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
528  return 0;
529  }
530 
531  // rbac log
532  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
533  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
534  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
535  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, true);
536 
537  // Finally add new mapping entry
538  $cp_options->appendMapping($source_id, $new_ref_id);
539  return $new_ref_id;
540  }
static gatherFaPa(int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
static getLogger(string $a_component_id)
Get component logger.
$target_id
Definition: goto.php:52
getOptions(int $a_source_id)
Get entry by source public.
global $DIC
Definition: feed.php:28
appendMapping($a_source_id, $a_target_id)
Add mapping of source -> target.
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
const LINK_OBJECT
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rewriteActionForNode()

ilSoapUtils::rewriteActionForNode ( ilCopyWizardOptions  $cpo,
array  $node,
array  $options 
)
protected

Definition at line 289 of file class.ilSoapUtils.php.

References ilCopyWizardOptions\COPY_WIZARD_COPY, ilCopyWizardOptions\COPY_WIZARD_UNDEFINED, findMappedReferenceForNode(), ILIAS\Repository\int(), and ilCopyWizardOptions\isRootNode().

Referenced by ilClone().

289  : int
290  {
292  if (array_key_exists('type', $options)) {
293  $default_mode = (int) $options['type'];
294  }
295  if (
296  array_key_exists('child', $node) &&
297  $cpo->isRootNode((int) $node['child'])
298  ) {
299  return $default_mode;
300  }
301 
302  if ($this->findMappedReferenceForNode($cpo, $node) && $default_mode == \ilCopyWizardOptions::COPY_WIZARD_COPY) {
303  return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
304  }
305  return $default_mode;
306  }
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
isRootNode(int $a_root)
Is root node public.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveTempFileAsMediaObject()

ilSoapUtils::saveTempFileAsMediaObject ( string  $sid,
string  $name,
string  $tmp_name 
)
Returns
ilObjMediaObject|soap_fault|SoapFault|null

Definition at line 124 of file class.ilSoapUtils.php.

References ilObjMediaObject\_saveTempFileAsMediaObject(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

125  {
126  $this->initAuth($sid);
127  $this->initIlias();
128 
129  if (!$this->checkSession($sid)) {
130  return $this->raiseError($this->getMessage(), $this->getMessageCode());
131  }
132 
133  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
135  }
raiseError(string $a_message, $a_code)
if($format !==null) $name
Definition: metadata.php:247
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
Create new media object and update page in db and return new media object.
+ Here is the call graph for this function:

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