ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

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...
 
 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 408 of file class.ilSoapUtils.php.

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

Referenced by ilCloneDependencies().

409  {
410  global $ilLog;
411 
412  $cp_options->dropFirstDependenciesNode();
413 
414  if ($cp_options->isSOAPEnabled()) {
415  // Start next soap call
416  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
417  $soap_client = new ilSoapClient();
418  $soap_client->setResponseTimeout(1);
419  $soap_client->enableWSDL(true);
420  $soap_client->init();
421  $soap_client->call('ilCloneDependencies', array($sid,$cp_options->getCopyId()));
422  } else {
423  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
424  $cp_options->read();
425  include_once('./webservice/soap/include/inc.soap_functions.php');
426  $res = ilSoapFunctions::ilCloneDependencies($sid, $cp_options->getCopyId());
427  }
428  return true;
429  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
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 385 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

386  {
387  global $ilLog;
388 
389  $cp_options->dropFirstNode();
390 
391  if ($cp_options->isSOAPEnabled()) {
392  // Start next soap call
393  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
394  $soap_client = new ilSoapClient();
395  $soap_client->setResponseTimeout(1);
396  $soap_client->enableWSDL(true);
397  $soap_client->init();
398  $soap_client->call('ilClone', array($sid,$cp_options->getCopyId()));
399  } else {
400  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
401  $cp_options->read();
402  include_once('./webservice/soap/include/inc.soap_functions.php');
403  $res = ilSoapFunctions::ilClone($sid, $cp_options->getCopyId());
404  }
405  return true;
406  }
static ilClone($sid, $copy_identifier)
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
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 490 of file class.ilSoapUtils.php.

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

Referenced by ilCloneDependencies().

491  {
492  global $ilLog;
493 
494  $source_id = $node['child'];
495  $mappings = $cp_options->getMappings();
496 
497  if (!isset($mappings[$source_id])) {
498  ilLoggerFactory::getLogger('obj')->debug('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No mapping found.');
499  return true;
500  }
501  $target_id = $mappings[$source_id];
502 
503  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
504  $orig->cloneDependencies($target_id, $cp_options->getCopyId());
505  return true;
506  }
$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 438 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

439  {
440  global $ilLog,$tree,$ilAccess,$rbacreview;
441 
442  #sleep(20);
443 
444  $source_id = $node['child'];
445  $parent_id = $node['parent'];
446  $options = $cp_options->getOptions($node['child']);
447  $mappings = $cp_options->getMappings();
448 
449  if (!$ilAccess->checkAccess('copy', '', $node['child'])) {
450  ilLoggerFactory::getLogger('obj')->error('No copy permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
451  return false;
452  }
453  if (!isset($mappings[$parent_id])) {
454  ilLoggerFactory::getLogger('obj')->info('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
455  return true;
456  }
457  $target_id = $mappings[$parent_id];
458 
459  if (!$tree->isInTree($target_id)) {
460  ilLoggerFactory::getLogger('obj')->notice('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. Object has been deleted.');
461  return false;
462  }
463 
464  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
465  $new_obj = $orig->cloneObject((int) $target_id, $cp_options->getCopyId());
466 
467  if (!is_object($new_obj)) {
468  ilLoggerFactory::getLogger('obj')->error('Error copying ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
469  return false;
470  }
471 
472  // rbac log
473  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
474  $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
475  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
476  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int) $source_id);
477 
478  // Finally add new mapping entry
479  $cp_options->appendMapping($source_id, $new_obj->getRefId());
480  return $new_obj->getRefId();
481  }
$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.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 612 of file class.ilSoapUtils.php.

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

613  {
614  $this->initAuth($sid);
615  $this->initIlias();
616 
617  // Session check not possible -> anonymous user is the trigger
618 
619  global $ilDB, $ilLog;
620 
621  $ilLog->write(__METHOD__ . ': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
622 
623  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
624  $oRegSettigs = new ilRegistrationSettings();
625 
626  $query = '';
627 
628  /*
629  * Fetch the current actuator user object first, because this user will try to perform very probably
630  * a new registration with the same login name in a few seconds ;-)
631  *
632  */
633  if ((int) $usr_id > 0) {
634  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
635  . 'WHERE active = 0 '
636  . 'AND reg_hash IS NOT NULL '
637  . 'AND usr_id = ' . $ilDB->quote($usr_id, 'integer') . ' ';
638  $query .= 'UNION ';
639  }
640 
641  $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
642  . 'WHERE active = 0 '
643  . 'AND reg_hash IS NOT NULL '
644  . 'AND usr_id != ' . $ilDB->quote($usr_id, 'integer') . ' ';
645 
646  $res = $ilDB->query($query);
647 
648  $ilLog->write(__METHOD__ . ': ' . $ilDB->numRows($res) . ' inactive user objects with confirmation hash values (dual opt in) found ...');
649 
650  /*
651  * mjansen: 15.12.2010:
652  * I perform the expiration check in php because of multi database support (mysql, postgresql).
653  * I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP()
654  */
655 
656  $num_deleted_users = 0;
657  while ($row = $ilDB->fetchAssoc($res)) {
658  if ($row['usr_id'] == ANONYMOUS_USER_ID || $row['usr_id'] == SYSTEM_USER_ID) {
659  continue;
660  }
661  if (!strlen($row['reg_hash'])) {
662  continue;
663  }
664 
665  if ((int) $oRegSettigs->getRegistrationHashLifetime() > 0 &&
666  $row['create_date'] != '' &&
667  time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
668  $user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false);
669  if ($user instanceof ilObjUser) {
670  $ilLog->write(__METHOD__ . ': User ' . $user->getLogin() . ' (obj_id: ' . $user->getId() . ') will be deleted due to an expired registration hash ...');
671  $user->delete();
672  ++$num_deleted_users;
673  }
674  }
675  }
676 
677  $ilLog->write(__METHOD__ . ': ' . $num_deleted_users . ' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
678 
679  $ilLog->write(__METHOD__ . ': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
680 
681  return true;
682  }
foreach($_POST as $key=> $value) $res
$query
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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 141 of file class.ilSoapUtils.php.

References $error, $file, $GLOBALS, $ilUser, $ok, $parser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilUtil\_sanitizeFilemame(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilMail\setSaveInSentbox().

142  {
143  $this->initAuth($sid);
144  $this->initIlias();
145 
146  if (!$this->__checkSession($sid)) {
147  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
148  }
149 
150  include_once 'Services/Mail/classes/class.ilMail.php';
151  include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
152 
153  $parser = new ilSoapMailXmlParser($a_mail_xml);
154  try {
155  // Check if wellformed
156  libxml_use_internal_errors(true);
157  $ok = simplexml_load_string($a_mail_xml);
158  if (!$ok) {
159  foreach (libxml_get_errors() as $err) {
160  $error .= ($err->message . ' ');
161  }
162  return $this->__raiseError($error, 'CLIENT');
163  }
164  $parser->start();
165  } catch (InvalidArgumentException $e) {
166  $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
167  return $this->__raiseError($e->getMessage(), 'CLIENT');
168  } catch (ilSaxParserException $e) {
169  $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
170  return $this->__raiseError($e->getMessage(), 'CLIENT');
171  }
172 
173  $mails = $parser->getMails();
174 
175  global $ilUser;
176 
177  foreach ($mails as $mail) {
178  // Prepare attachments
179  include_once './Services/Mail/classes/class.ilFileDataMail.php';
180  $file = new ilFileDataMail($ilUser->getId());
181  foreach ((array) $mail['attachments'] as $attachment) {
182  // TODO: Error handling
183  $file->storeAsAttachment($attachment['name'], $attachment['content']);
184  $attachments[] = ilUtil::_sanitizeFilemame($attachment['name']);
185  }
186 
187  $mail_obj = new ilMail($ilUser->getId());
188  $mail_obj->setSaveInSentbox(true);
189  $mail_obj->saveAttachments((array) $attachments);
190  $mail_obj->sendMail(
191  implode(',', (array) $mail['to']),
192  implode(',', (array) $mail['cc']),
193  implode(',', (array) $mail['bcc']),
194  $mail['subject'],
195  implode("\n", (array) $mail['body']),
196  (array) $attachments,
197  array($mail['type']),
198  (bool) $mail['usePlaceholders']
199  );
200 
201  // Finally unlink attachments
202  foreach ((array) $attachments as $att) {
203  $file->unlinkFile($att);
204  }
205  $mail_obj->savePostData(
206  $ilUser->getId(),
207  array(),
208  '',
209  '',
210  '',
211  '',
212  '',
213  '',
214  '',
215  ''
216  );
217  }
218  return true;
219  }
This class handles all operations on files (attachments) in directory ilias_data/mail.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setSaveInSentbox($a_save_in_sentbox)
SaxParserException thrown by ilSaxParser if property throwException is set.
static _sanitizeFilemame($a_filename)
$error
Definition: Error.php:17
XML parser for soap mails.
This class handles base functions for mail handling.
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:23
initAuth($sid)
Init authentication.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:

◆ getMobsOfObject()

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

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

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

235  {
236  $this->initAuth($sid);
237  $this->initIlias();
238 
239  if (!$this->__checkSession($sid)) {
240  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
241  }
242 
243  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
245  }
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 580 of file class.ilSoapUtils.php.

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

581  {
582  $this->initAuth($sid);
583  $this->initIlias();
584 
585  if (!$this->__checkSession($sid)) {
586  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
587  }
588 
589  include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
590 
591  global $ilLog;
592 
593  $ilLog->write(__METHOD__ . ': Starting task execution...');
594  $scheduler = ilECSTaskScheduler::_getInstanceByServerId($a_server_id);
595  $scheduler->startTaskExecution();
596 
597  return true;
598  }
__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 318 of file class.ilSoapUtils.php.

References $ilLog, $ilUser, $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(), and linkNode().

319  {
320  $this->initAuth($sid);
321  $this->initIlias();
322 
323  if (!$this->__checkSession($sid)) {
324  ilLoggerFactory::getLogger('obj')->error('Object cloning failed. Invalid session given: ' . $this->__getMessage());
325  }
326 
327  global $ilLog,$ilUser;
328 
329  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
330  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
331 
332  // Check owner of copy procedure
333  if (!$cp_options->checkOwner($ilUser->getId())) {
334  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
335  return false;
336  }
337 
338 
339  // Fetch first node
340  if (($node = $cp_options->fetchFirstNode()) === false) {
341  ilLoggerFactory::getLogger('obj')->info('Finished copy step 1. Starting copying of object dependencies...');
342  return $this->ilCloneDependencies($sid, $copy_identifier);
343  }
344 
345  // Check options of this node
346  $options = $cp_options->getOptions($node['child']);
347 
348  $new_ref_id = 0;
349  switch ($options['type']) {
351  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
352  // set mapping to zero
353  $cp_options->appendMapping($node['child'], 0);
354  $this->callNextNode($sid, $cp_options);
355  break;
356 
358 
359  ilLoggerFactory::getLogger('obj')->debug('Start cloning node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
360  $new_ref_id = $this->cloneNode($node, $cp_options);
361  $this->callNextNode($sid, $cp_options);
362  break;
363 
365  ilLoggerFactory::getLogger('obj')->debug('Start linking node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
366  $new_ref_id = $this->linkNode($node, $cp_options);
367  $this->callNextNode($sid, $cp_options);
368  break;
369 
370  default:
371  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
372  $this->callNextNode($sid, $cp_options);
373  break;
374 
375  }
376  return $new_ref_id;
377  }
callNextNode($sid, $cp_options)
Call next node using soap.
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.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 254 of file class.ilSoapUtils.php.

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

255  {
256  $this->initAuth($sid);
257  $this->initIlias();
258 
259  if (!$this->__checkSession($sid)) {
260  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
261  }
262 
263  global $ilLog,$ilUser;
264 
265  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
266  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
267 
268  // Check owner of copy procedure
269  if (!$cp_options->checkOwner($ilUser->getId())) {
270  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
271  return false;
272  }
273 
274  // Fetch first node
275  if (($node = $cp_options->fetchFirstDependenciesNode()) === false) {
276  $cp_options->deleteAll();
277  ilLoggerFactory::getLogger('obj')->info('Finished copy step 2. Copy completed');
278  return true;
279  }
280 
281  // Check options of this node
282  $options = $cp_options->getOptions($node['child']);
283  $new_ref_id = 0;
284  switch ($options['type']) {
286  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
287  $this->callNextDependency($sid, $cp_options);
288  break;
289 
291  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
292  $this->cloneDependencies($node, $cp_options);
293  $this->callNextDependency($sid, $cp_options);
294  break;
295 
297  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
298  $this->cloneDependencies($node, $cp_options);
299  $this->callNextDependency($sid, $cp_options);
300  break;
301 
302  default:
303  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
304  $this->callNextDependency($sid, $cp_options);
305  break;
306  }
307  return true;
308  }
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
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 515 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

516  {
517  global $ilLog,$ilAccess,$rbacreview;
518 
519  $source_id = $node['child'];
520  $parent_id = $node['parent'];
521  $options = $cp_options->getOptions($node['child']);
522  $mappings = $cp_options->getMappings();
523 
524  if (!$ilAccess->checkAccess('delete', '', $node['child'])) {
525  ilLoggerFactory::getLogger('obj')->warning('No delete permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
526  return false;
527  }
528  if (!isset($mappings[$parent_id])) {
529  ilLoggerFactory::getLogger('obj')->warning('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
530  return true;
531  }
532  $target_id = $mappings[$parent_id];
533 
534  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
535  $new_ref_id = $orig->createReference();
536  $orig->putInTree($target_id);
537  $orig->setPermissions($target_id);
538 
539  if (!($new_ref_id)) {
540  ilLoggerFactory::getLogger('obj')->error('Error linking ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
541  return false;
542  }
543 
544  // rbac log
545  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
546  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
547  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
548  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int) $source_id);
549 
550  // Finally add new mapping entry
551  $cp_options->appendMapping($source_id, $new_ref_id);
552  return $new_ref_id;
553  }
$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.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 221 of file class.ilSoapUtils.php.

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

222  {
223  $this->initAuth($sid);
224  $this->initIlias();
225 
226  if (!$this->__checkSession($sid)) {
227  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
228  }
229 
230  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
232  }
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:146
__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 561 of file class.ilSoapUtils.php.

References $error, $xml, array, and domxml_open_mem().

562  {
563  // validate to prevent wrong XMLs
564  $dom = @domxml_open_mem($xml, DOMXML_LOAD_VALIDATING, $error);
565  if ($error) {
566  $msg = array();
567  if (is_array($error)) {
568  foreach ($error as $err) {
569  $msg []= "(" . $err["line"] . "," . $err["col"] . "): " . $err["errormessage"];
570  }
571  } else {
572  $msg[] = $error;
573  }
574  $msg = join("\n", $msg);
575  return $msg;
576  }
577  return true;
578  }
domxml_open_mem($str, $mode=0, &$error=null)
$xml
Definition: metadata.php:240
$error
Definition: Error.php:17
Create styles array
The data for the language used.
+ Here is the call graph for this function:

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