Public Member Functions | Private Member Functions

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.

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.

Detailed Description

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


Member Function Documentation

ilSoapUtils::callNextDependency ( sid,
cp_options 
) [private]

Definition at line 295 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 = 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:
object copx wizard options instance private

Definition at line 268 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 = 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 380 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 329 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

        {
                global $ilLog,$tree,$ilAccess;
                
                #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;
                }
                
                // 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::disableSOAPCheck (  ) 

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

        {
                $this->sauth->disableSOAPCheck();
        }

ilSoapUtils::getMobsOfObject ( sid,
a_type,
a_id 
)

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

References ilSoapAdministration::__checkSession(), ilSoapAdministration::__raiseError(), and ilObjMediaObject::_getMobsOfObject().

        {
                if(!$this->__checkSession($sid))
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       

                // Include main header
                include_once './include/inc.header.php';
                include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                return ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
        }

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:
string soap session id
int copy identifier (ilCopyWizarardOptions)

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

References $ilLog, ilSoapAdministration::__checkSession(), ilSoapAdministration::__raiseError(), ilCopyWizardOptions::_getInstance(), callNextNode(), cloneNode(), ilCopyWizardOptions::COPY_WIZARD_COPY, ilCopyWizardOptions::COPY_WIZARD_LINK, ilCopyWizardOptions::COPY_WIZARD_OMIT, ilCloneDependencies(), and linkNode().

Referenced by callNextNode().

        {
                if(!$this->__checkSession($sid))
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       

                // Include main header
                include_once './include/inc.header.php';
                
                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'])
                {
                        case ilCopyWizardOptions::COPY_WIZARD_OMIT:
                                $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;
                                
                        case ilCopyWizardOptions::COPY_WIZARD_COPY:
                                $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;
                        
                        case ilCopyWizardOptions::COPY_WIZARD_LINK:
                                $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 130 of file class.ilSoapUtils.php.

References $ilLog, ilSoapAdministration::__checkSession(), ilSoapAdministration::__raiseError(), ilCopyWizardOptions::_getInstance(), callNextDependency(), cloneDependencies(), ilCopyWizardOptions::COPY_WIZARD_COPY, ilCopyWizardOptions::COPY_WIZARD_LINK, and ilCopyWizardOptions::COPY_WIZARD_OMIT.

Referenced by callNextDependency(), and ilClone().

        {
                if(!$this->__checkSession($sid))
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       

                // Include main header
                include_once './include/inc.header.php';
                
                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'])
                {
                        case ilCopyWizardOptions::COPY_WIZARD_OMIT:
                                $ilLog->write(__METHOD__.': Omitting node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
                                $this->callNextDependency($sid,$cp_options);
                                break;
                        
                        case ilCopyWizardOptions::COPY_WIZARD_LINK:
                                $ilLog->write(__METHOD__.': Nothing to do for node: '.$node['obj_id'].', '.$node['title'].', '.$node['type']);
                                $this->callNextDependency($sid,$cp_options);
                                break;
                                
                        case ilCopyWizardOptions::COPY_WIZARD_COPY:
                                $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 406 of file class.ilSoapUtils.php.

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

Referenced by ilClone().

        {
                global $ilLog,$ilAccess;
                
                $source_id = $node['child'];
                $parent_id = $node['parent'];
                $options = $cp_options->getOptions($node['child']);
                $mappings = $cp_options->getMappings();
                
                if(!$ilAccess->checkAccess('write','',$node['child']))
                {
                        $ilLog->write(__METHOD__.': No write 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);
                $orig->setRefId($new_ref_id);
                $orig->initDefaultRoles();
                
                
                if(!($new_ref_id))
                {
                        $ilLog->write(__METHOD__.': Error linking '.$source_id.', '.$node['title'].', '.$node['type'].'. No target found.');
                        return false;
                }
                
                // 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 97 of file class.ilSoapUtils.php.

References ilSoapAdministration::__checkSession(), ilSoapAdministration::__raiseError(), and ilObjMediaObject::_saveTempFileAsMediaObject().

        {
                if(!$this->__checkSession($sid))
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       

                // Include main header
                include_once './include/inc.header.php';
                include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                return ilObjMediaObject::_saveTempFileAsMediaObject($name, $tmp_name);
        }

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(), and ilSoapAdministration::__raiseError().

        {
                if(!$this->__checkSession($sid))
                {
                        return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
                }                       

                // Include main header
                include_once './include/inc.header.php';

                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)
                {
                        $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:


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