ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSoapUtils Class Reference
+ Inheritance diagram for ilSoapUtils:
+ Collaboration diagram for ilSoapUtils:

Public Member Functions

 ignoreUserAbort ()
 
 disableSOAPCheck ()
 
 distributeMails ($sid, $a_mail_xml)
 mail via soap More...
 
 saveTempFileAsMediaObject ($sid, $name, $tmp_name)
 
 getMobsOfObject ($sid, $a_type, $a_id)
 
 ilCloneDependencies ($sid, $copy_identifier, $is_initialized=false)
 clone object dependencies (e.g. More...
 
 ilClone ($sid, $copy_identifier)
 Clone object. More...
 
 handleECSTasks ($sid, $a_server_id)
 
 deleteExpiredDualOptInUserObjects ($sid, $usr_id)
 Method for soap webservice: deleteExpiredDualOptInUserObjects. More...
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Static Public Member Functions

static validateXML ($xml)
 validates an xml file, if dtd is attached More...
 
- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 

Protected Member Functions

 rewriteActionForNode (ilCopyWizardOptions $cpo, array $node, array $options)
 
 findMappedReferenceForNode (\ilCopyWizardOptions $cpo, array $node)
 

Private Member Functions

 callNextNode ($sid, $cp_options)
 Call next node using soap. More...
 
 callNextDependency ($sid, $cp_options)
 
 cloneNode ($node, $cp_options)
 Clone node. More...
 
 cloneDependencies ($node, $cp_options)
 cloneDependencies More...
 
 internalLinkNode ($node, $cp_options)
 Link node private. More...
 
 linkNode ($node, $cp_options)
 Link node. More...
 

Additional Inherited Members

- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

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

Member Function Documentation

◆ callNextDependency()

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

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

References $DIC, $res, ilLoggerFactory\getLogger(), and ilSoapFunctions\ilCloneDependencies().

Referenced by ilCloneDependencies().

404  {
405  global $DIC;
406 
407  $ilLog = $DIC['ilLog'];
408 
409  $cp_options->dropFirstDependenciesNode();
410 
411  if ($cp_options->isSOAPEnabled()) {
412  // Start next soap call
413  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
414  $soap_client = new ilSoapClient();
415  $soap_client->setResponseTimeout(1);
416  $soap_client->enableWSDL(true);
417  $soap_client->init();
418  $soap_client->call('ilCloneDependencies', array($sid,$cp_options->getCopyId()));
419  } else {
420  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
421  $cp_options->read();
422  include_once('./webservice/soap/include/inc.soap_functions.php');
423  $res = ilSoapFunctions::ilCloneDependencies($sid, $cp_options->getCopyId());
424  }
425  return true;
426  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
static ilCloneDependencies($sid, $copy_identifier)
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ callNextNode()

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

Call next node using soap.

Parameters
objectcopx wizard options instance private

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

References $DIC, $res, ilLoggerFactory\getLogger(), and ilSoapFunctions\ilClone().

Referenced by ilClone().

379  {
380  global $DIC;
381 
382  $ilLog = $DIC['ilLog'];
383 
384  $cp_options->dropFirstNode();
385 
386  if ($cp_options->isSOAPEnabled()) {
387  // Start next soap call
388  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
389  $soap_client = new ilSoapClient();
390  $soap_client->setResponseTimeout(1);
391  $soap_client->enableWSDL(true);
392  $soap_client->init();
393  $soap_client->call('ilClone', array($sid,$cp_options->getCopyId()));
394  } else {
395  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
396  $cp_options->read();
397  include_once('./webservice/soap/include/inc.soap_functions.php');
398  $res = ilSoapFunctions::ilClone($sid, $cp_options->getCopyId());
399  }
400  return true;
401  }
static ilClone($sid, $copy_identifier)
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneDependencies()

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

cloneDependencies

private

Parameters

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

References $DIC, $target_id, ilObjectFactory\getInstanceByRefId(), and ilLoggerFactory\getLogger().

Referenced by ilCloneDependencies().

493  {
494  global $DIC;
495 
496  $ilLog = $DIC['ilLog'];
497 
498  $source_id = $node['child'];
499  $mappings = $cp_options->getMappings();
500 
501  if (!isset($mappings[$source_id])) {
502  ilLoggerFactory::getLogger('obj')->debug('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No mapping found.');
503  return true;
504  }
505  $target_id = $mappings[$source_id];
506 
507  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
508  $orig->cloneDependencies($target_id, $cp_options->getCopyId());
509  return true;
510  }
$target_id
Definition: goto.php:51
global $DIC
Definition: goto.php:24
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneNode()

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

Clone node.

private

Parameters

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

References $DIC, $target_id, ilRbacLog\add(), ilRbacLog\COPY_OBJECT, ilRbacLog\gatherFaPa(), ilObjectFactory\getInstanceByRefId(), and ilLoggerFactory\getLogger().

Referenced by ilClone().

436  {
437  global $DIC;
438 
439  $ilLog = $DIC['ilLog'];
440  $tree = $DIC['tree'];
441  $ilAccess = $DIC['ilAccess'];
442  $rbacreview = $DIC['rbacreview'];
443 
444  #sleep(20);
445 
446  $source_id = $node['child'];
447  $parent_id = $node['parent'];
448  $options = $cp_options->getOptions($node['child']);
449  $mappings = $cp_options->getMappings();
450 
451  if (!$ilAccess->checkAccess('copy', '', $node['child'])) {
452  ilLoggerFactory::getLogger('obj')->error('No copy permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
453  return false;
454  }
455  if (!isset($mappings[$parent_id])) {
456  ilLoggerFactory::getLogger('obj')->info('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
457  return true;
458  }
459  $target_id = $mappings[$parent_id];
460 
461  if (!$tree->isInTree($target_id)) {
462  ilLoggerFactory::getLogger('obj')->notice('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. Object has been deleted.');
463  return false;
464  }
465 
466  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
467  $new_obj = $orig->cloneObject((int) $target_id, $cp_options->getCopyId());
468 
469  if (!is_object($new_obj)) {
470  ilLoggerFactory::getLogger('obj')->error('Error copying ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
471  return false;
472  }
473 
474  // rbac log
475  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
476  $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
477  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
478  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int) $source_id);
479 
480  // Finally add new mapping entry
481  $cp_options->appendMapping($source_id, $new_obj->getRefId());
482  return $new_obj->getRefId();
483  }
$target_id
Definition: goto.php:51
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
global $DIC
Definition: goto.php:24
const COPY_OBJECT
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteExpiredDualOptInUserObjects()

ilSoapUtils::deleteExpiredDualOptInUserObjects (   $sid,
  $usr_id 
)

Method for soap webservice: deleteExpiredDualOptInUserObjects.

This service will run in background. The client has not to wait for response.

Parameters
string$sidSession id + client id, separated by ::
integer$usr_idUser id of the actuator
Returns
boolean true or false public

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

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

686  {
687  $this->initAuth($sid);
688  $this->initIlias();
689 
690  // Session check not possible -> anonymous user is the trigger
691 
692  global $DIC;
693 
694  $ilDB = $DIC['ilDB'];
695  $ilLog = $DIC['ilLog'];
696 
697  $ilLog->write(__METHOD__ . ': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
698 
699  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
700  $oRegSettigs = new ilRegistrationSettings();
701 
702  $query = '';
703 
704  /*
705  * Fetch the current actuator user object first, because this user will try to perform very probably
706  * a new registration with the same login name in a few seconds ;-)
707  *
708  */
709  if ((int) $usr_id > 0) {
710  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
711  . 'WHERE active = 0 '
712  . 'AND reg_hash IS NOT NULL '
713  . 'AND usr_id = ' . $ilDB->quote($usr_id, 'integer') . ' ';
714  $query .= 'UNION ';
715  }
716 
717  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
718  . 'WHERE active = 0 '
719  . 'AND reg_hash IS NOT NULL '
720  . 'AND usr_id != ' . $ilDB->quote($usr_id, 'integer') . ' ';
721 
722  $res = $ilDB->query($query);
723 
724  $ilLog->write(__METHOD__ . ': ' . $ilDB->numRows($res) . ' inactive user objects with confirmation hash values (dual opt in) found ...');
725 
726  /*
727  * mjansen: 15.12.2010:
728  * I perform the expiration check in php because of multi database support (mysql, postgresql).
729  * I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP()
730  */
731 
732  $num_deleted_users = 0;
733  while ($row = $ilDB->fetchAssoc($res)) {
734  if ($row['usr_id'] == ANONYMOUS_USER_ID || $row['usr_id'] == SYSTEM_USER_ID) {
735  continue;
736  }
737  if (!strlen($row['reg_hash'])) {
738  continue;
739  }
740 
741  if ((int) $oRegSettigs->getRegistrationHashLifetime() > 0 &&
742  $row['create_date'] != '' &&
743  time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
744  $user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false);
745  if ($user instanceof ilObjUser) {
746  $ilLog->write(__METHOD__ . ': User ' . $user->getLogin() . ' (obj_id: ' . $user->getId() . ') will be deleted due to an expired registration hash ...');
747  $user->delete();
748  ++$num_deleted_users;
749  }
750  }
751  }
752 
753  $ilLog->write(__METHOD__ . ': ' . $num_deleted_users . ' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
754 
755  $ilLog->write(__METHOD__ . ': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
756 
757  return true;
758  }
const ANONYMOUS_USER_ID
Definition: constants.php:25
const SYSTEM_USER_ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: constants.php:24
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjAuthSettingsGUI.
initAuth($sid)
Init authentication.
global $ilDB
+ Here is the call graph for this function:

◆ disableSOAPCheck()

ilSoapUtils::disableSOAPCheck ( )

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

43  {
44  $this->soap_check = false;
45  }

◆ distributeMails()

ilSoapUtils::distributeMails (   $sid,
  $a_mail_xml 
)

mail via soap

Parameters
object$sid
object$a_mail_xml
Returns

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

References $DIC, Vendor\Package\$e, $GLOBALS, $ilUser, $ok, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilUtil\_sanitizeFilemame(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilMail\setSaveInSentbox(), and ilFileDataMail\storeAsAttachment().

54  {
55  $this->initAuth($sid);
56  $this->initIlias();
57 
58  if (!$this->__checkSession($sid)) {
59  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
60  }
61 
62  include_once 'Services/Mail/classes/class.ilMail.php';
63  include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
64 
65  $parser = new ilSoapMailXmlParser($a_mail_xml);
66  try {
67  // Check if wellformed
68  libxml_use_internal_errors(true);
69  $ok = simplexml_load_string($a_mail_xml);
70  if (!$ok) {
71  foreach (libxml_get_errors() as $err) {
72  $error .= ($err->message . ' ');
73  }
74  return $this->__raiseError($error, 'CLIENT');
75  }
76  $parser->start();
77  } catch (InvalidArgumentException $e) {
78  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
79  return $this->__raiseError($e->getMessage(), 'CLIENT');
80  } catch (ilSaxParserException $e) {
81  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
82  return $this->__raiseError($e->getMessage(), 'CLIENT');
83  }
84 
85  $mails = $parser->getMails();
86 
87  global $DIC;
88 
89  $ilUser = $DIC['ilUser'];
90 
91  foreach ($mails as $mail) {
92  // Prepare attachments
93  include_once './Services/Mail/classes/class.ilFileDataMail.php';
94  $file = new ilFileDataMail($ilUser->getId());
95  foreach ((array) $mail['attachments'] as $attachment) {
96  // TODO: Error handling
97  $file->storeAsAttachment($attachment['name'], $attachment['content']);
98  $attachments[] = ilUtil::_sanitizeFilemame($attachment['name']);
99  }
100 
101  $mail_obj = new ilMail($ilUser->getId());
102  $mail_obj->setSaveInSentbox(true);
103  $mail_obj->saveAttachments((array) $attachments);
104  $mail_obj->enqueue(
105  implode(',', (array) $mail['to']),
106  implode(',', (array) $mail['cc']),
107  implode(',', (array) $mail['bcc']),
108  $mail['subject'],
109  implode("\n", (array) $mail['body']),
110  (array) $attachments,
111  array($mail['type']),
112  (bool) $mail['usePlaceholders']
113  );
114 
115  // Finally unlink attachments
116  foreach ((array) $attachments as $att) {
117  $file->unlinkFile($att);
118  }
119  $mail_obj->savePostData(
120  $ilUser->getId(),
121  array(),
122  '',
123  '',
124  '',
125  '',
126  '',
127  '',
128  '',
129  ''
130  );
131  }
132  return true;
133  }
setSaveInSentbox(bool $saveInSentbox)
Class ilFileDataMail.
SaxParserException thrown by ilSaxParser if property throwException is set.
storeAsAttachment($a_filename, $a_content)
Store content as attachment.
static _sanitizeFilemame($a_filename)
XML parser for soap mails.
__raiseError($a_message, $a_code)
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
initAuth($sid)
Init authentication.
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

◆ findMappedReferenceForNode()

ilSoapUtils::findMappedReferenceForNode ( \ilCopyWizardOptions  $cpo,
array  $node 
)
protected
Parameters
ilCopyWizardOptions$cpo
array$node
Returns
int | null

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

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

Referenced by internalLinkNode(), and rewriteActionForNode().

341  {
342  global $DIC;
343 
344  $logger = $DIC->logger()->obj();
345  $tree = $DIC->repositoryTree();
346  $root = $cpo->getRootNode();
347  $obj_id = $node['obj_id'];
348 
349  $mappings = $cpo->getMappings();
350  foreach (\ilObject::_getAllReferences($obj_id) as $ref_id => $also_ref_id) {
351 
352  $logger->debug('Validating node: ' . $ref_id . ' and root ' . $root );
353  $logger->dump($DIC->repositoryTree()->getRelation($ref_id , $root));
354 
355  if($DIC->repositoryTree()->getRelation($ref_id , $root) != \ilTree::RELATION_CHILD) {
356  $logger->debug('Ignoring non child relation');
357  continue;
358  }
359  // check if mapping is already available
360  $logger->dump($mappings);
361  if (array_key_exists($ref_id, $mappings)) {
362  $logger->debug('Found existing mapping for linked node.');
363  return $mappings[$ref_id];
364  }
365  }
366  $logger->info('Nothing found');
367  return null;
368  }
static _getAllReferences($a_id)
get all reference ids of object
global $DIC
Definition: goto.php:24
const RELATION_CHILD
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMobsOfObject()

ilSoapUtils::getMobsOfObject (   $sid,
  $a_type,
  $a_id 
)

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

References ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjMediaObject\_getMobsOfObject(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

149  {
150  $this->initAuth($sid);
151  $this->initIlias();
152 
153  if (!$this->__checkSession($sid)) {
154  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
155  }
156 
157  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
158  return ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
159  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ handleECSTasks()

ilSoapUtils::handleECSTasks (   $sid,
  $a_server_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilECSTaskScheduler\_getInstanceByServerId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

652  {
653  $this->initAuth($sid);
654  $this->initIlias();
655 
656  if (!$this->__checkSession($sid)) {
657  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
658  }
659 
660  include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
661 
662  global $DIC;
663 
664  $ilLog = $DIC['ilLog'];
665 
666  $ilLog->write(__METHOD__ . ': Starting task execution...');
667  $scheduler = ilECSTaskScheduler::_getInstanceByServerId($a_server_id);
668  $scheduler->startTaskExecution();
669 
670  return true;
671  }
__raiseError($a_message, $a_code)
global $DIC
Definition: goto.php:24
static _getInstanceByServerId($a_server_id)
get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTas...
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ ignoreUserAbort()

ilSoapUtils::ignoreUserAbort ( )

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

38  {
39  return ignore_user_abort(true);
40  }

◆ ilClone()

ilSoapUtils::ilClone (   $sid,
  $copy_identifier 
)

Clone object.

public

Parameters
stringsoap session id
intcopy identifier (ilCopyWizarardOptions)

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

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

239  {
240  $this->initAuth($sid);
241  $this->initIlias();
242 
243  if (!$this->__checkSession($sid)) {
244  ilLoggerFactory::getLogger('obj')->error('Object cloning failed. Invalid session given: ' . $this->__getMessage());
245  }
246 
247  global $DIC;
248 
249  $ilUser = $DIC->user();
250 
251  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
252  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
253 
254  // Check owner of copy procedure
255  if (!$cp_options->checkOwner($ilUser->getId())) {
256  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
257  return false;
258  }
259 
260 
261  // Fetch first node
262  if (($node = $cp_options->fetchFirstNode()) === false) {
263  ilLoggerFactory::getLogger('obj')->info('Finished copy step 1. Starting copying of object dependencies...');
264  return $this->ilCloneDependencies($sid, $copy_identifier, true);
265  }
266 
267  // Check options of this node
268  $options = $cp_options->getOptions($node['child']);
269 
270  $action = $this->rewriteActionForNode($cp_options, $node, $options);
271 
272  $new_ref_id = 0;
273  switch ($action) {
275  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
276  // set mapping to zero
277  $cp_options->appendMapping($node['child'], 0);
278  $this->callNextNode($sid, $cp_options);
279  break;
280 
282 
283  ilLoggerFactory::getLogger('obj')->debug('Start cloning node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
284  $new_ref_id = $this->cloneNode($node, $cp_options);
285  $this->callNextNode($sid, $cp_options);
286  break;
287 
289  ilLoggerFactory::getLogger('obj')->debug('Start linking node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
290  $new_ref_id = $this->linkNode($node, $cp_options);
291  $this->callNextNode($sid, $cp_options);
292  break;
293 
294  case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
295  ilLoggerFactory::getLogger('obj')->debug('Start creating internal link for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
296  $new_ref_id = $this->internalLinkNode($node, $cp_options);
297  $this->callNextNode($sid, $cp_options);
298  break;
299 
300  default:
301  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
302  $this->callNextNode($sid, $cp_options);
303  break;
304 
305  }
306  return $new_ref_id;
307  }
internalLinkNode($node, $cp_options)
Link node private.
callNextNode($sid, $cp_options)
Call next node using soap.
rewriteActionForNode(ilCopyWizardOptions $cpo, array $node, array $options)
static _getInstance($a_copy_id)
Get instance of copy wizard options.
global $DIC
Definition: goto.php:24
initAuth($sid)
Init authentication.
ilCloneDependencies($sid, $copy_identifier, $is_initialized=false)
clone object dependencies (e.g.
static getLogger($a_component_id)
Get component logger.
$ilUser
Definition: imgupload.php:18
linkNode($node, $cp_options)
Link node.
cloneNode($node, $cp_options)
Clone node.
+ Here is the call graph for this function:

◆ ilCloneDependencies()

ilSoapUtils::ilCloneDependencies (   $sid,
  $copy_identifier,
  $is_initialized = false 
)

clone object dependencies (e.g.

course start objects, preconditions ...)

public

Parameters

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

References $DIC, $ilUser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilCopyWizardOptions\_getInstance(), callNextDependency(), cloneDependencies(), ilCopyWizardOptions\COPY_WIZARD_COPY, ilCopyWizardOptions\COPY_WIZARD_LINK, ilCopyWizardOptions\COPY_WIZARD_OMIT, ilLoggerFactory\getLogger(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

Referenced by ilClone().

169  {
170  if(!$is_initialized) {
171 
172  $this->initAuth($sid);
173  $this->initIlias();
174 
175  if (!$this->__checkSession($sid)) {
176  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
177  }
178  }
179 
180  global $DIC;
181 
182  $ilLog = $DIC['ilLog'];
183  $ilUser = $DIC['ilUser'];
184 
185  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
186  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
187 
188  // Check owner of copy procedure
189  if (!$cp_options->checkOwner($ilUser->getId())) {
190  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
191  return false;
192  }
193 
194  // Fetch first node
195  if (($node = $cp_options->fetchFirstDependenciesNode()) === false) {
196  $cp_options->deleteAll();
197  ilLoggerFactory::getLogger('obj')->info('Finished copy step 2. Copy completed');
198  return true;
199  }
200 
201  // Check options of this node
202  $options = $cp_options->getOptions($node['child']);
203  $new_ref_id = 0;
204  switch ($options['type']) {
206  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
207  $this->callNextDependency($sid, $cp_options);
208  break;
209 
211  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
212  $this->cloneDependencies($node, $cp_options);
213  $this->callNextDependency($sid, $cp_options);
214  break;
215 
217  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
218  $this->cloneDependencies($node, $cp_options);
219  $this->callNextDependency($sid, $cp_options);
220  break;
221 
222  default:
223  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
224  $this->callNextDependency($sid, $cp_options);
225  break;
226  }
227  return true;
228  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
__raiseError($a_message, $a_code)
global $DIC
Definition: goto.php:24
callNextDependency($sid, $cp_options)
initAuth($sid)
Init authentication.
static getLogger($a_component_id)
Get component logger.
cloneDependencies($node, $cp_options)
cloneDependencies
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ internalLinkNode()

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

Link node private.

Parameters
$node
$cp_options
Returns
bool|int
Exceptions
ilDatabaseException

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

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

Referenced by ilClone().

521  {
522  global $DIC;
523 
524  $ilAccess = $DIC->access();
525  $logger = $DIC->logger()->obj();
526  $rbacreview = $DIC->rbac()->review();
527  $tree = $DIC->repositoryTree();
528  $mappings = $cp_options->getMappings();
529 
530  $source_id = $this->findMappedReferenceForNode($cp_options, $node);
531  try {
532  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
533  if(!$orig instanceof \ilObject) {
534  $logger->error('Cannot create object instance.');
535  return false;
536  }
537  }
538  catch (\ilObjectNotFoundException $e) {
539  $logger->error('Cannot create object instance for ref_id: ' . $source_id);
540  $logger->error($e->getMessage());
541  return false;
542  }
543 
544  // target (parent id) is the mapped parent id of the current node
545  $node_parent = $node['parent'];
546  if (!array_key_exists($node_parent, $mappings)) {
547  $logger->error('Cannot new parent id for node: ' . $node['parent']);
548  return false;
549  }
550  $parent_id = $mappings[$node_parent];
551 
552  $new_ref_id = $orig->createReference();
553  $orig->putInTree($parent_id);
554  $orig->setPermissions($parent_id);
555 
556  if (!($new_ref_id)) {
557  $logger->warning('Creating internal link failed.');
558  return false;
559  }
560 
561  // rbac log
562  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
563  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
564  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int) $source_id);
565 
566  // Finally add new mapping entry
567  $cp_options->appendMapping($node['child'], $new_ref_id);
568 
569  $logger->notice('Added mapping for ' . $node['child'] . ' ' . $new_ref_id);
570 
571 
572  return $new_ref_id;
573  }
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
global $DIC
Definition: goto.php:24
const LINK_OBJECT
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static getInstanceByRefId($a_ref_id, $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:

◆ linkNode()

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

Link node.

private

Parameters

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

References $DIC, $target_id, ilRbacLog\add(), ilRbacLog\gatherFaPa(), ilObjectFactory\getInstanceByRefId(), ilLoggerFactory\getLogger(), and ilRbacLog\LINK_OBJECT.

Referenced by ilClone().

583  {
584  global $DIC;
585 
586  $ilLog = $DIC['ilLog'];
587  $ilAccess = $DIC['ilAccess'];
588  $rbacreview = $DIC['rbacreview'];
589 
590  $source_id = $node['child'];
591  $parent_id = $node['parent'];
592  $options = $cp_options->getOptions($node['child']);
593  $mappings = $cp_options->getMappings();
594 
595  if (!$ilAccess->checkAccess('delete', '', $node['child'])) {
596  ilLoggerFactory::getLogger('obj')->warning('No delete permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
597  return false;
598  }
599  if (!isset($mappings[$parent_id])) {
600  ilLoggerFactory::getLogger('obj')->warning('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
601  return true;
602  }
603  $target_id = $mappings[$parent_id];
604 
605  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
606  $new_ref_id = $orig->createReference();
607  $orig->putInTree($target_id);
608  $orig->setPermissions($target_id);
609 
610  if (!($new_ref_id)) {
611  ilLoggerFactory::getLogger('obj')->error('Error linking ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
612  return false;
613  }
614 
615  // rbac log
616  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
617  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
618  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
619  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int) $source_id);
620 
621  // Finally add new mapping entry
622  $cp_options->appendMapping($source_id, $new_ref_id);
623  return $new_ref_id;
624  }
$target_id
Definition: goto.php:51
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
global $DIC
Definition: goto.php:24
const LINK_OBJECT
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getLogger($a_component_id)
Get component logger.
+ 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
Parameters
array$options
Returns
int

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

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

Referenced by ilClone().

314  {
316  if (array_key_exists('type', $options)) {
317  $default_mode = $options['type'];
318  }
319  if (
320  array_key_exists('child', $node) &&
321  $cpo->isRootNode($node)
322  ) {
323  return $default_mode;
324  }
325 
326  if ($this->findMappedReferenceForNode($cpo, $node)) {
327 
328  if ($default_mode == \ilCopyWizardOptions::COPY_WIZARD_COPY) {
329  return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
330  }
331  }
332  return $default_mode;
333  }
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
isRootNode($a_root)
Is root node.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveTempFileAsMediaObject()

ilSoapUtils::saveTempFileAsMediaObject (   $sid,
  $name,
  $tmp_name 
)

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

References $name, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

136  {
137  $this->initAuth($sid);
138  $this->initIlias();
139 
140  if (!$this->__checkSession($sid)) {
141  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
142  }
143 
144  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
146  }
static _saveTempFileAsMediaObject($name, $tmp_name, $upload=true)
Create new media object and update page in db and return new media object.
if($format !==null) $name
Definition: metadata.php:230
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ validateXML()

static ilSoapUtils::validateXML (   $xml)
static

validates an xml file, if dtd is attached

Parameters
$xmlcurrent xml stream
Returns
true, if correct, or String with error messages

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

References $xml, and domxml_open_mem().

633  {
634  // validate to prevent wrong XMLs
635  $dom = @domxml_open_mem($xml, DOMXML_LOAD_VALIDATING, $error);
636  if ($error) {
637  $msg = array();
638  if (is_array($error)) {
639  foreach ($error as $err) {
640  $msg []= "(" . $err["line"] . "," . $err["col"] . "): " . $err["errormessage"];
641  }
642  } else {
643  $msg[] = $error;
644  }
645  $msg = join("\n", $msg);
646  return $msg;
647  }
648  return true;
649  }
domxml_open_mem($str, $mode=0, &$error=null)
$xml
Definition: metadata.php:332
+ Here is the call graph for this function:

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