ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 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 501 of file class.ilSoapUtils.php.

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

Referenced by ilCloneDependencies().

502  {
503  global $DIC;
504 
505  $ilLog = $DIC['ilLog'];
506 
507  $cp_options->dropFirstDependenciesNode();
508 
509  if ($cp_options->isSOAPEnabled()) {
510  // Start next soap call
511  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
512  $soap_client = new ilSoapClient();
513  $soap_client->setResponseTimeout(1);
514  $soap_client->enableWSDL(true);
515  $soap_client->init();
516  $soap_client->call('ilCloneDependencies', array($sid,$cp_options->getCopyId()));
517  } else {
518  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
519  $cp_options->read();
520  include_once('./webservice/soap/include/inc.soap_functions.php');
521  $res = ilSoapFunctions::ilCloneDependencies($sid, $cp_options->getCopyId());
522  }
523  return true;
524  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
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 476 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

477  {
478  global $DIC;
479 
480  $ilLog = $DIC['ilLog'];
481 
482  $cp_options->dropFirstNode();
483 
484  if ($cp_options->isSOAPEnabled()) {
485  // Start next soap call
486  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
487  $soap_client = new ilSoapClient();
488  $soap_client->setResponseTimeout(1);
489  $soap_client->enableWSDL(true);
490  $soap_client->init();
491  $soap_client->call('ilClone', array($sid,$cp_options->getCopyId()));
492  } else {
493  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
494  $cp_options->read();
495  include_once('./webservice/soap/include/inc.soap_functions.php');
496  $res = ilSoapFunctions::ilClone($sid, $cp_options->getCopyId());
497  }
498  return true;
499  }
global $DIC
Definition: saml.php:7
static ilClone($sid, $copy_identifier)
foreach($_POST as $key=> $value) $res
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 590 of file class.ilSoapUtils.php.

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

Referenced by ilCloneDependencies().

591  {
592  global $DIC;
593 
594  $ilLog = $DIC['ilLog'];
595 
596  $source_id = $node['child'];
597  $mappings = $cp_options->getMappings();
598 
599  if (!isset($mappings[$source_id])) {
600  ilLoggerFactory::getLogger('obj')->debug('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No mapping found.');
601  return true;
602  }
603  $target_id = $mappings[$source_id];
604 
605  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
606  $orig->cloneDependencies($target_id, $cp_options->getCopyId());
607  return true;
608  }
global $DIC
Definition: saml.php:7
$target_id
Definition: goto.php:49
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 533 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

534  {
535  global $DIC;
536 
537  $ilLog = $DIC['ilLog'];
538  $tree = $DIC['tree'];
539  $ilAccess = $DIC['ilAccess'];
540  $rbacreview = $DIC['rbacreview'];
541 
542  #sleep(20);
543 
544  $source_id = $node['child'];
545  $parent_id = $node['parent'];
546  $options = $cp_options->getOptions($node['child']);
547  $mappings = $cp_options->getMappings();
548 
549  if (!$ilAccess->checkAccess('copy', '', $node['child'])) {
550  ilLoggerFactory::getLogger('obj')->error('No copy permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
551  return false;
552  }
553  if (!isset($mappings[$parent_id])) {
554  ilLoggerFactory::getLogger('obj')->info('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
555  return true;
556  }
557  $target_id = $mappings[$parent_id];
558 
559  if (!$tree->isInTree($target_id)) {
560  ilLoggerFactory::getLogger('obj')->notice('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. Object has been deleted.');
561  return false;
562  }
563 
564  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
565  $new_obj = $orig->cloneObject((int) $target_id, $cp_options->getCopyId());
566 
567  if (!is_object($new_obj)) {
568  ilLoggerFactory::getLogger('obj')->error('Error copying ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
569  return false;
570  }
571 
572  // rbac log
573  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
574  $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
575  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
576  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int) $source_id);
577 
578  // Finally add new mapping entry
579  $cp_options->appendMapping($source_id, $new_obj->getRefId());
580  return $new_obj->getRefId();
581  }
global $DIC
Definition: saml.php:7
$target_id
Definition: goto.php:49
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
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 783 of file class.ilSoapUtils.php.

References $DIC, $ilDB, $ilLog, $query, $res, $row, $user, ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

784  {
785  $this->initAuth($sid);
786  $this->initIlias();
787 
788  // Session check not possible -> anonymous user is the trigger
789 
790  global $DIC;
791 
792  $ilDB = $DIC['ilDB'];
793  $ilLog = $DIC['ilLog'];
794 
795  $ilLog->write(__METHOD__ . ': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
796 
797  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
798  $oRegSettigs = new ilRegistrationSettings();
799 
800  $query = '';
801 
802  /*
803  * Fetch the current actuator user object first, because this user will try to perform very probably
804  * a new registration with the same login name in a few seconds ;-)
805  *
806  */
807  if ((int) $usr_id > 0) {
808  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
809  . 'WHERE active = 0 '
810  . 'AND reg_hash IS NOT NULL '
811  . 'AND usr_id = ' . $ilDB->quote($usr_id, 'integer') . ' ';
812  $query .= 'UNION ';
813  }
814 
815  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
816  . 'WHERE active = 0 '
817  . 'AND reg_hash IS NOT NULL '
818  . 'AND usr_id != ' . $ilDB->quote($usr_id, 'integer') . ' ';
819 
820  $res = $ilDB->query($query);
821 
822  $ilLog->write(__METHOD__ . ': ' . $ilDB->numRows($res) . ' inactive user objects with confirmation hash values (dual opt in) found ...');
823 
824  /*
825  * mjansen: 15.12.2010:
826  * I perform the expiration check in php because of multi database support (mysql, postgresql).
827  * I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP()
828  */
829 
830  $num_deleted_users = 0;
831  while ($row = $ilDB->fetchAssoc($res)) {
832  if ($row['usr_id'] == ANONYMOUS_USER_ID || $row['usr_id'] == SYSTEM_USER_ID) {
833  continue;
834  }
835  if (!strlen($row['reg_hash'])) {
836  continue;
837  }
838 
839  if ((int) $oRegSettigs->getRegistrationHashLifetime() > 0 &&
840  $row['create_date'] != '' &&
841  time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
842  $user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false);
843  if ($user instanceof ilObjUser) {
844  $ilLog->write(__METHOD__ . ': User ' . $user->getLogin() . ' (obj_id: ' . $user->getId() . ') will be deleted due to an expired registration hash ...');
845  $user->delete();
846  ++$num_deleted_users;
847  }
848  }
849  }
850 
851  $ilLog->write(__METHOD__ . ': ' . $num_deleted_users . ' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
852 
853  $ilLog->write(__METHOD__ . ': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
854 
855  return true;
856  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$user
Definition: migrateto20.php:57
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$row
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.

References $DIC, $filename, $GLOBALS, $message, $path, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

43  {
44  $this->soap_check = false;
45  }
+ Here is the call graph for this function:

◆ distributeMails()

ilSoapUtils::distributeMails (   $sid,
  $a_mail_xml 
)

mail via soap

Parameters
object$sid
object$a_mail_xml
Returns

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

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

155  {
156  $this->initAuth($sid);
157  $this->initIlias();
158 
159  if (!$this->__checkSession($sid)) {
160  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
161  }
162 
163  include_once 'Services/Mail/classes/class.ilMail.php';
164  include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
165 
166  $parser = new ilSoapMailXmlParser($a_mail_xml);
167  try {
168  // Check if wellformed
169  libxml_use_internal_errors(true);
170  $ok = simplexml_load_string($a_mail_xml);
171  if (!$ok) {
172  foreach (libxml_get_errors() as $err) {
173  $error .= ($err->message . ' ');
174  }
175  return $this->__raiseError($error, 'CLIENT');
176  }
177  $parser->start();
178  } catch (InvalidArgumentException $e) {
179  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
180  return $this->__raiseError($e->getMessage(), 'CLIENT');
181  } catch (ilSaxParserException $e) {
182  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
183  return $this->__raiseError($e->getMessage(), 'CLIENT');
184  }
185 
186  $mails = $parser->getMails();
187 
188  global $DIC;
189 
190  $ilUser = $DIC['ilUser'];
191 
192  foreach ($mails as $mail) {
193  // Prepare attachments
194  include_once './Services/Mail/classes/class.ilFileDataMail.php';
195  $file = new ilFileDataMail($ilUser->getId());
196  foreach ((array) $mail['attachments'] as $attachment) {
197  // TODO: Error handling
198  $file->storeAsAttachment($attachment['name'], $attachment['content']);
199  $attachments[] = ilUtil::_sanitizeFilemame($attachment['name']);
200  }
201 
202  $mail_obj = new ilMail($ilUser->getId());
203  $mail_obj->setSaveInSentbox(true);
204  $mail_obj->saveAttachments((array) $attachments);
205  $mail_obj->sendMail(
206  implode(',', (array) $mail['to']),
207  implode(',', (array) $mail['cc']),
208  implode(',', (array) $mail['bcc']),
209  $mail['subject'],
210  implode("\n", (array) $mail['body']),
211  (array) $attachments,
212  array($mail['type']),
213  (bool) $mail['usePlaceholders']
214  );
215 
216  // Finally unlink attachments
217  foreach ((array) $attachments as $att) {
218  $file->unlinkFile($att);
219  }
220  $mail_obj->savePostData(
221  $ilUser->getId(),
222  array(),
223  '',
224  '',
225  '',
226  '',
227  '',
228  '',
229  '',
230  ''
231  );
232  }
233  return true;
234  }
global $DIC
Definition: saml.php:7
Class ilFileDataMail.
setSaveInSentbox($a_save_in_sentbox)
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)
$ilUser
Definition: imgupload.php:18
$parser
Definition: BPMN2Parser.php:23
initAuth($sid)
Init authentication.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ 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 438 of file class.ilSoapUtils.php.

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

Referenced by internalLinkNode(), and rewriteActionForNode().

439  {
440  global $DIC;
441 
442  $logger = $DIC->logger()->obj();
443  $tree = $DIC->repositoryTree();
444  $root = $cpo->getRootNode();
445  $obj_id = $node['obj_id'];
446 
447  $mappings = $cpo->getMappings();
448  foreach (\ilObject::_getAllReferences($obj_id) as $ref_id => $also_ref_id) {
449 
450  $logger->debug('Validating node: ' . $ref_id . ' and root ' . $root );
451  $logger->dump($DIC->repositoryTree()->getRelation($ref_id , $root));
452 
453  if($DIC->repositoryTree()->getRelation($ref_id , $root) != \ilTree::RELATION_CHILD) {
454  $logger->debug('Ignoring non child relation');
455  continue;
456  }
457  // check if mapping is already available
458  $logger->dump($mappings);
459  if (array_key_exists($ref_id, $mappings)) {
460  $logger->debug('Found existing mapping for linked node.');
461  return $mappings[$ref_id];
462  }
463  }
464  $logger->info('Nothing found');
465  return null;
466  }
global $DIC
Definition: saml.php:7
static _getAllReferences($a_id)
get all reference ids of object
$root
Definition: sabredav.php:45
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 249 of file class.ilSoapUtils.php.

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

250  {
251  $this->initAuth($sid);
252  $this->initIlias();
253 
254  if (!$this->__checkSession($sid)) {
255  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
256  }
257 
258  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
260  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$a_type
Definition: workflow.php:92
__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 749 of file class.ilSoapUtils.php.

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

750  {
751  $this->initAuth($sid);
752  $this->initIlias();
753 
754  if (!$this->__checkSession($sid)) {
755  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
756  }
757 
758  include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
759 
760  global $DIC;
761 
762  $ilLog = $DIC['ilLog'];
763 
764  $ilLog->write(__METHOD__ . ': Starting task execution...');
765  $scheduler = ilECSTaskScheduler::_getInstanceByServerId($a_server_id);
766  $scheduler->startTaskExecution();
767 
768  return true;
769  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
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 336 of file class.ilSoapUtils.php.

References $action, $DIC, $ilUser, PHPMailer\PHPMailer\$options, 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().

337  {
338  $this->initAuth($sid);
339  $this->initIlias();
340 
341  if (!$this->__checkSession($sid)) {
342  ilLoggerFactory::getLogger('obj')->error('Object cloning failed. Invalid session given: ' . $this->__getMessage());
343  }
344 
345  global $DIC;
346 
347  $ilUser = $DIC->user();
348 
349  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
350  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
351 
352  // Check owner of copy procedure
353  if (!$cp_options->checkOwner($ilUser->getId())) {
354  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
355  return false;
356  }
357 
358 
359  // Fetch first node
360  if (($node = $cp_options->fetchFirstNode()) === false) {
361  ilLoggerFactory::getLogger('obj')->info('Finished copy step 1. Starting copying of object dependencies...');
362  return $this->ilCloneDependencies($sid, $copy_identifier);
363  }
364 
365  // Check options of this node
366  $options = $cp_options->getOptions($node['child']);
367 
368  $action = $this->rewriteActionForNode($cp_options, $node, $options);
369 
370  $new_ref_id = 0;
371  switch ($action) {
373  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
374  // set mapping to zero
375  $cp_options->appendMapping($node['child'], 0);
376  $this->callNextNode($sid, $cp_options);
377  break;
378 
380 
381  ilLoggerFactory::getLogger('obj')->debug('Start cloning node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
382  $new_ref_id = $this->cloneNode($node, $cp_options);
383  $this->callNextNode($sid, $cp_options);
384  break;
385 
387  ilLoggerFactory::getLogger('obj')->debug('Start linking node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
388  $new_ref_id = $this->linkNode($node, $cp_options);
389  $this->callNextNode($sid, $cp_options);
390  break;
391 
392  case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
393  ilLoggerFactory::getLogger('obj')->debug('Start creating internal link for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
394  $new_ref_id = $this->internalLinkNode($node, $cp_options);
395  $this->callNextNode($sid, $cp_options);
396  break;
397 
398  default:
399  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
400  $this->callNextNode($sid, $cp_options);
401  break;
402 
403  }
404  return $new_ref_id;
405  }
internalLinkNode($node, $cp_options)
Link node private.
callNextNode($sid, $cp_options)
Call next node using soap.
$action
global $DIC
Definition: saml.php:7
rewriteActionForNode(ilCopyWizardOptions $cpo, array $node, array $options)
static _getInstance($a_copy_id)
Get instance of copy wizard options.
$ilUser
Definition: imgupload.php:18
ilCloneDependencies($sid, $copy_identifier)
clone object dependencies (e.g.
initAuth($sid)
Init authentication.
static getLogger($a_component_id)
Get component logger.
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 
)

clone object dependencies (e.g.

course start objects, preconditions ...)

public

Parameters

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

References $DIC, $ilLog, $ilUser, PHPMailer\PHPMailer\$options, 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().

270  {
271  $this->initAuth($sid);
272  $this->initIlias();
273 
274  if (!$this->__checkSession($sid)) {
275  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
276  }
277 
278  global $DIC;
279 
280  $ilLog = $DIC['ilLog'];
281  $ilUser = $DIC['ilUser'];
282 
283  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
284  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
285 
286  // Check owner of copy procedure
287  if (!$cp_options->checkOwner($ilUser->getId())) {
288  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
289  return false;
290  }
291 
292  // Fetch first node
293  if (($node = $cp_options->fetchFirstDependenciesNode()) === false) {
294  $cp_options->deleteAll();
295  ilLoggerFactory::getLogger('obj')->info('Finished copy step 2. Copy completed');
296  return true;
297  }
298 
299  // Check options of this node
300  $options = $cp_options->getOptions($node['child']);
301  $new_ref_id = 0;
302  switch ($options['type']) {
304  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
305  $this->callNextDependency($sid, $cp_options);
306  break;
307 
309  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
310  $this->cloneDependencies($node, $cp_options);
311  $this->callNextDependency($sid, $cp_options);
312  break;
313 
315  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
316  $this->cloneDependencies($node, $cp_options);
317  $this->callNextDependency($sid, $cp_options);
318  break;
319 
320  default:
321  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
322  $this->callNextDependency($sid, $cp_options);
323  break;
324  }
325  return true;
326  }
global $DIC
Definition: saml.php:7
static _getInstance($a_copy_id)
Get instance of copy wizard options.
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
callNextDependency($sid, $cp_options)
initAuth($sid)
Init authentication.
static getLogger($a_component_id)
Get component logger.
cloneDependencies($node, $cp_options)
cloneDependencies
+ 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 618 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

619  {
620  global $DIC;
621 
622  $ilAccess = $DIC->access();
623  $logger = $DIC->logger()->obj();
624  $rbacreview = $DIC->rbac()->review();
625  $tree = $DIC->repositoryTree();
626  $mappings = $cp_options->getMappings();
627 
628  $source_id = $this->findMappedReferenceForNode($cp_options, $node);
629  try {
630  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
631  if(!$orig instanceof \ilObject) {
632  $logger->error('Cannot create object instance.');
633  return false;
634  }
635  }
636  catch (\ilObjectNotFoundException $e) {
637  $logger->error('Cannot create object instance for ref_id: ' . $source_id);
638  $logger->error($e->getMessage());
639  return false;
640  }
641 
642  // target (parent id) is the mapped parent id of the current node
643  $node_parent = $node['parent'];
644  if (!array_key_exists($node_parent, $mappings)) {
645  $logger->error('Cannot new parent id for node: ' . $node['parent']);
646  return false;
647  }
648  $parent_id = $mappings[$node_parent];
649 
650  $new_ref_id = $orig->createReference();
651  $orig->putInTree($parent_id);
652  $orig->setPermissions($parent_id);
653 
654  if (!($new_ref_id)) {
655  $logger->warning('Creating internal link failed.');
656  return false;
657  }
658 
659  // rbac log
660  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
661  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
662  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int) $source_id);
663 
664  // Finally add new mapping entry
665  $cp_options->appendMapping($node['child'], $new_ref_id);
666 
667  $logger->notice('Added mapping for ' . $node['child'] . ' ' . $new_ref_id);
668 
669 
670  return $new_ref_id;
671  }
global $DIC
Definition: saml.php:7
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
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 680 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

681  {
682  global $DIC;
683 
684  $ilLog = $DIC['ilLog'];
685  $ilAccess = $DIC['ilAccess'];
686  $rbacreview = $DIC['rbacreview'];
687 
688  $source_id = $node['child'];
689  $parent_id = $node['parent'];
690  $options = $cp_options->getOptions($node['child']);
691  $mappings = $cp_options->getMappings();
692 
693  if (!$ilAccess->checkAccess('delete', '', $node['child'])) {
694  ilLoggerFactory::getLogger('obj')->warning('No delete permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
695  return false;
696  }
697  if (!isset($mappings[$parent_id])) {
698  ilLoggerFactory::getLogger('obj')->warning('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
699  return true;
700  }
701  $target_id = $mappings[$parent_id];
702 
703  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
704  $new_ref_id = $orig->createReference();
705  $orig->putInTree($target_id);
706  $orig->setPermissions($target_id);
707 
708  if (!($new_ref_id)) {
709  ilLoggerFactory::getLogger('obj')->error('Error linking ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
710  return false;
711  }
712 
713  // rbac log
714  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
715  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
716  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
717  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int) $source_id);
718 
719  // Finally add new mapping entry
720  $cp_options->appendMapping($source_id, $new_ref_id);
721  return $new_ref_id;
722  }
global $DIC
Definition: saml.php:7
$target_id
Definition: goto.php:49
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
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 411 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

412  {
414  if (array_key_exists('type', $options)) {
415  $default_mode = $options['type'];
416  }
417  if (
418  array_key_exists('child', $node) &&
419  $cpo->isRootNode($node)
420  ) {
421  return $default_mode;
422  }
423 
424  if ($this->findMappedReferenceForNode($cpo, $node)) {
425 
426  if ($default_mode == \ilCopyWizardOptions::COPY_WIZARD_COPY) {
427  return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
428  }
429  }
430  return $default_mode;
431  }
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 236 of file class.ilSoapUtils.php.

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

237  {
238  $this->initAuth($sid);
239  $this->initIlias();
240 
241  if (!$this->__checkSession($sid)) {
242  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
243  }
244 
245  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
247  }
static _saveTempFileAsMediaObject($name, $tmp_name, $upload=true)
Create new media object and update page in db and return new media object.
__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 730 of file class.ilSoapUtils.php.

References $xml, and domxml_open_mem().

731  {
732  // validate to prevent wrong XMLs
733  $dom = @domxml_open_mem($xml, DOMXML_LOAD_VALIDATING, $error);
734  if ($error) {
735  $msg = array();
736  if (is_array($error)) {
737  foreach ($error as $err) {
738  $msg []= "(" . $err["line"] . "," . $err["col"] . "): " . $err["errormessage"];
739  }
740  } else {
741  $msg[] = $error;
742  }
743  $msg = join("\n", $msg);
744  return $msg;
745  }
746  return true;
747  }
domxml_open_mem($str, $mode=0, &$error=null)
+ Here is the call graph for this function:

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