ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSoapUtils Class Reference
+ Inheritance diagram for ilSoapUtils:
+ Collaboration diagram for ilSoapUtils:

Public Member Functions

 ilSoapUtils ()
 ignoreUserAbort ()
 disableSOAPCheck ()
 sendMail ($sid, $to, $cc, $bcc, $sender, $subject, $message, $attach)
 saveTempFileAsMediaObject ($sid, $name, $tmp_name)
 getMobsOfObject ($sid, $a_type, $a_id)
 ilCloneDependencies ($sid, $copy_identifier)
 clone object dependencies (e.g.
 ilClone ($sid, $copy_identifier)
 Clone object.
 handleECSTasks ($sid)
 deleteExpiredDualOptInUserObjects ($sid, $usr_id)
 Method for soap webservice: deleteExpiredDualOptInUserObjects.
- Public Member Functions inherited from ilSoapAdministration
 ilSoapAdministration ($use_nusoap=true)
 __checkSession ($sid)
 initErrorWriter ()
 Overwrite error handler.
 __explodeSid ($sid)
 __setMessage ($a_str)
 __getMessage ()
 __appendMessage ($a_str)
 __setMessageCode ($a_code)
 __getMessageCode ()
 initAuth ($sid)
 initIlias ()
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 __raiseError ($a_message, $a_code)
 getNIC ($sid)
 get client information from current as xml result set
 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
 getInstallationInfoXML ()
 getClientInfoXML ($clientid)

Static Public Member Functions

static validateXML ($xml)
 validates an xml file, if dtd is attached
- 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

Private Member Functions

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

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

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

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

References $ilLog, $res, and ilCloneDependencies().

Referenced by ilCloneDependencies().

{
global $ilLog;
$cp_options->dropFirstDependenciesNode();
if($cp_options->isSOAPEnabled())
{
// Start next soap call
include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
$soap_client = new ilSoapClient();
$soap_client->setTimeout(1);
$soap_client->setResponseTimeout(1);
$soap_client->enableWSDL(true);
$soap_client->init();
$soap_client->call('ilCloneDependencies',array($sid,$cp_options->getCopyId()));
}
else
{
$ilLog->write(__METHOD__.': Cannot call SOAP server');
$cp_options->read();
include_once('./webservice/soap/include/inc.soap_functions.php');
$res = ilSoapFunctions::ilCloneDependencies($sid,$cp_options->getCopyId());
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Call next node using soap.

Parameters
objectcopx wizard options instance private

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

References $ilLog, $res, and ilClone().

Referenced by ilClone().

{
global $ilLog;
$cp_options->dropFirstNode();
if($cp_options->isSOAPEnabled())
{
// Start next soap call
include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
$soap_client = new ilSoapClient();
$soap_client->setTimeout(1);
$soap_client->setResponseTimeout(1);
$soap_client->enableWSDL(true);
$soap_client->init();
$soap_client->call('ilClone',array($sid,$cp_options->getCopyId()));
}
else
{
$ilLog->write(__METHOD__.': Cannot call SOAP server');
$cp_options->read();
include_once('./webservice/soap/include/inc.soap_functions.php');
$res = ilSoapFunctions::ilClone($sid,$cp_options->getCopyId());
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

cloneDependencies

private

Parameters

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

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

Referenced by ilCloneDependencies().

{
global $ilLog;
$source_id = $node['child'];
$mappings = $cp_options->getMappings();
if(!isset($mappings[$source_id]))
{
$ilLog->write(__METHOD__.': Omitting node '.$source_id.', '.$node['title'].', '.$node['type']. '. No mapping found.');
return true;
}
$target_id = $mappings[$source_id];
$orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
$orig->cloneDependencies($target_id,$cp_options->getCopyId());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Clone node.

private

Parameters

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

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

Referenced by ilClone().

{
global $ilLog,$tree,$ilAccess,$rbacreview;
#sleep(20);
$source_id = $node['child'];
$parent_id = $node['parent'];
$options = $cp_options->getOptions($node['child']);
$mappings = $cp_options->getMappings();
if(!$ilAccess->checkAccess('copy','',$node['child']))
{
$ilLog->write(__METHOD__.': No copy permission granted: '.$source_id.', '.$node['title'].', '.$node['type']);
return false;
}
if(!isset($mappings[$parent_id]))
{
$ilLog->write(__METHOD__.': Omitting node '.$source_id.', '.$node['title'].', '.$node['type']. '. No target found.');
return true;
}
$target_id = $mappings[$parent_id];
if(!$tree->isInTree($target_id))
{
$ilLog->write(__METHOD__.': Omitting node '.$source_id.', '.$node['title'].', '.$node['type']. '. Object has been deleted.');
return false;
}
$orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
$new_obj = $orig->cloneObject((int) $target_id,$cp_options->getCopyId());
if(!is_object($new_obj))
{
$ilLog->write(__METHOD__.': Error copying '.$source_id.', '.$node['title'].', '.$node['type'].'. No target found.');
return false;
}
// rbac log
include_once "Services/AccessControl/classes/class.ilRbacLog.php";
$rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
$rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles));
ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int)$source_id);
// Finally add new mapping entry
$cp_options->appendMapping($source_id,$new_obj->getRefId());
return $new_obj->getRefId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
$this->initAuth($sid);
$this->initIlias();
// Session check not possible -> anonymous user is the trigger
global $ilDB, $ilLog;
$ilLog->write(__METHOD__.': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
$oRegSettigs = new ilRegistrationSettings();
$query = '';
/*
* Fetch the current actuator user object first, because this user will try to perform very probably
* a new registration with the same login name in a few seconds ;-)
*
*/
if((int)$usr_id > 0)
{
$query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
. 'WHERE active = 0 '
. 'AND reg_hash IS NOT NULL '
. 'AND usr_id = '.$ilDB->quote($usr_id, 'integer').' ';
$query .= 'UNION ';
}
$query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data '
. 'WHERE active = 0 '
. 'AND reg_hash IS NOT NULL '
. 'AND usr_id != '.$ilDB->quote($usr_id, 'integer').' ';
$res = $ilDB->query($query);
$ilLog->write(__METHOD__.': '.$ilDB->numRows($res).' inactive user objects with confirmation hash values (dual opt in) found ...');
/*
* mjansen: 15.12.2010:
* I perform the expiration check in php because of multi database support (mysql, postgresql).
* I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP()
*/
$num_deleted_users = 0;
while($row = $ilDB->fetchAssoc($res))
{
if($row['usr_id'] == ANONYMOUS_USER_ID || $row['usr_id'] == SYSTEM_USER_ID) continue;
if(!strlen($row['reg_hash'])) continue;
if((int)$oRegSettigs->getRegistrationHashLifetime() > 0 &&
$row['create_date'] != '' &&
time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date']))
{
$user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false);
if($user instanceof ilObjUser)
{
$ilLog->write(__METHOD__.': User '.$user->getLogin().' (obj_id: '.$user->getId().') will be deleted due to an expired registration hash ...');
$user->delete();
++$num_deleted_users;
}
}
}
$ilLog->write(__METHOD__.': '.$num_deleted_users.' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
$ilLog->write(__METHOD__.': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
return true;
}

+ Here is the call graph for this function:

ilSoapUtils::disableSOAPCheck ( )

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

{
$this->soap_check = false;
}
ilSoapUtils::getMobsOfObject (   $sid,
  $a_type,
  $a_id 
)

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

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

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
return ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
}

+ Here is the call graph for this function:

ilSoapUtils::handleECSTasks (   $sid)

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

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

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
global $ilLog;
$ilLog->write(__METHOD__.': Starting task execution...');
$scheduler->startTaskExecution();
return true;
}

+ Here is the call graph for this function:

ilSoapUtils::ignoreUserAbort ( )

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

{
ignore_user_abort();
}
ilSoapUtils::ilClone (   $sid,
  $copy_identifier 
)

Clone object.

public

Parameters
stringsoap session id
intcopy identifier (ilCopyWizarardOptions)

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

References $ilLog, ilSoapAdministration\__checkSession(), ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilCopyWizardOptions\_getInstance(), callNextNode(), cloneNode(), ilCopyWizardOptions\COPY_WIZARD_COPY, ilCopyWizardOptions\COPY_WIZARD_LINK, ilCopyWizardOptions\COPY_WIZARD_OMIT, ilCloneDependencies(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and linkNode().

Referenced by callNextNode().

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
global $ilLog,$ilUser;
include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
$cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
// Check owner of copy procedure
if(!$cp_options->checkOwner($ilUser->getId()))
{
$ilLog->write(__METHOD__.': Permission check failed for user id: '.$ilUser->getId().', copy id: '.$copy_identifier);
return false;
}
// Fetch first node
if(($node = $cp_options->fetchFirstNode()) === false)
{
$ilLog->write(__METHOD__.': Finished copy step 1. Starting copying of object dependencies...');
return $this->ilCloneDependencies($sid,$copy_identifier);
}
// Check options of this node
$options = $cp_options->getOptions($node['child']);
$new_ref_id = 0;
switch($options['type'])
{
$ilLog->write(__METHOD__.': Omitting node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
// set mapping to zero
$cp_options->appendMapping($node['child'],0);
$this->callNextNode($sid,$cp_options);
break;
$ilLog->write(__METHOD__.': Start cloning node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
$new_ref_id = $this->cloneNode($node,$cp_options);
$this->callNextNode($sid,$cp_options);
break;
$ilLog->write(__METHOD__.': Start linking node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
$new_ref_id = $this->linkNode($node,$cp_options);
$this->callNextNode($sid,$cp_options);
break;
default:
$ilLog->write(__METHOD__.': No valid action type given for node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
$this->callNextNode($sid,$cp_options);
break;
}
return $new_ref_id;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSoapUtils::ilCloneDependencies (   $sid,
  $copy_identifier 
)

clone object dependencies (e.g.

course start objects, preconditions ...)

public

Parameters

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

References $ilLog, ilSoapAdministration\__checkSession(), ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilCopyWizardOptions\_getInstance(), callNextDependency(), cloneDependencies(), ilCopyWizardOptions\COPY_WIZARD_COPY, ilCopyWizardOptions\COPY_WIZARD_LINK, ilCopyWizardOptions\COPY_WIZARD_OMIT, ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

Referenced by callNextDependency(), and ilClone().

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
global $ilLog,$ilUser;
include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
$cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
// Check owner of copy procedure
if(!$cp_options->checkOwner($ilUser->getId()))
{
$ilLog->write(__METHOD__.': Permission check failed for user id: '.$ilUser->getId().', copy id: '.$copy_identifier);
return false;
}
// Fetch first node
if(($node = $cp_options->fetchFirstDependenciesNode()) === false)
{
$cp_options->deleteAll();
$ilLog->write(__METHOD__.': Finished copy step 2. Copy completed');
return true;
}
// Check options of this node
$options = $cp_options->getOptions($node['child']);
$new_ref_id = 0;
switch($options['type'])
{
$ilLog->write(__METHOD__.': Omitting node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
$this->callNextDependency($sid,$cp_options);
break;
$ilLog->write(__METHOD__.': Nothing to do for node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
$this->callNextDependency($sid,$cp_options);
break;
$ilLog->write(__METHOD__.': Start cloning dependencies: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
$this->cloneDependencies($node,$cp_options);
$this->callNextDependency($sid,$cp_options);
break;
default:
$ilLog->write(__METHOD__.': No valid action type given for node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
$this->callNextDependency($sid,$cp_options);
break;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSoapUtils::ilSoapUtils ( )

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

References ilSoapAdministration\ilSoapAdministration().

+ Here is the call graph for this function:

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

Link node.

private

Parameters

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

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

Referenced by ilClone().

{
global $ilLog,$ilAccess,$rbacreview;
$source_id = $node['child'];
$parent_id = $node['parent'];
$options = $cp_options->getOptions($node['child']);
$mappings = $cp_options->getMappings();
if(!$ilAccess->checkAccess('delete','',$node['child']))
{
$ilLog->write(__METHOD__.': No delete permission granted: '.$source_id.', '.$node['title'].', '.$node['type']);
return false;
}
if(!isset($mappings[$parent_id]))
{
$ilLog->write(__METHOD__.': Omitting node '.$source_id.', '.$node['title'].', '.$node['type']. '. No target found.');
return true;
}
$target_id = $mappings[$parent_id];
$orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
$new_ref_id = $orig->createReference();
$orig->putInTree($target_id);
$orig->setPermissions($target_id);
if(!($new_ref_id))
{
$ilLog->write(__METHOD__.': Error linking '.$source_id.', '.$node['title'].', '.$node['type'].'. No target found.');
return false;
}
// rbac log
include_once "Services/AccessControl/classes/class.ilRbacLog.php";
$rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
$rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles));
ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int)$source_id);
// Finally add new mapping entry
$cp_options->appendMapping($source_id,$new_ref_id);
return $new_ref_id;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
}

+ Here is the call graph for this function:

ilSoapUtils::sendMail (   $sid,
  $to,
  $cc,
  $bcc,
  $sender,
  $subject,
  $message,
  $attach 
)

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

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

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
global $ilLog;
include_once 'Services/Mail/classes/class.ilMimeMail.php';
$mmail = new ilMimeMail();
$mmail->autoCheck(false);
$mmail->From($sender);
$mmail->To(explode(',',$to));
$mmail->Subject($subject);
$mmail->Body($message);
if($cc)
{
$mmail->Cc(explode(',',$cc));
}
if($bcc)
{
$mmail->Bcc(explode(',',$bcc));
}
if($attach)
{
// mjansen: switched separator from "," to "#:#" because of mantis bug #6039
// for backward compatibility we have to check if the substring "#:#" exists as leading separator
// otherwise we should use ";"
if(strpos($attach, '#:#') === 0)
{
$attach = substr($attach, strlen('#:#'));
$attachments = explode('#:#', $attach);
}
else
{
$attachments = explode(',', $attach);
}
foreach ($attachments as $attachment)
{
$mmail->Attach($attachment);
}
}
$mmail->Send();
$ilLog->write('SOAP: sendMail(): '.$to.', '.$cc.', '.$bcc);
return true;
}

+ Here is the call graph for this function:

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

References $error, DOMXML_LOAD_VALIDATING, and domxml_open_mem().

{
// validate to prevent wrong XMLs
if ($error)
{
$msg = array();
if (is_array($error))
{
foreach ($error as $err) {
$msg []= "(".$err["line"].",".$err["col"]."): ".$err["errormessage"];
}
}
else
{
$msg[] = $error;
}
$msg = join("\n",$msg);
return $msg;
}
return true;
}

+ Here is the call graph for this function:


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