1061 lines
32 KiB
PHP
1061 lines
32 KiB
PHP
<?php
|
||
|
||
include_once ('CPCUser.class.php') ;
|
||
include_once ('CPCBon.class.php') ;
|
||
|
||
@ini_set ('soap.wsdl_cache_enabled', 0) ;
|
||
|
||
/**
|
||
* Classe g<>rant la connexion <20> la plate-forme de de webservices PLATOS
|
||
*
|
||
* @package PlatosClient
|
||
* @name CPCConnection
|
||
*/
|
||
class CPCConnection
|
||
{
|
||
|
||
/**
|
||
* @var string URI du WSDL de la plate-forme de webservice
|
||
* @access public
|
||
*/
|
||
public $zWsdlURI ;
|
||
|
||
/**
|
||
* @var bool Indiquant si la connexion s'effectue de mani<6E>re s<>curis<69>e (via HTTPS) au pas (Non impl<70>ment<6E>e)
|
||
* @access public
|
||
*/
|
||
public $bSecured ;
|
||
|
||
/**
|
||
* @var string Login du service sur la plate-forme
|
||
* @access public
|
||
*/
|
||
public $zServiceLogin ;
|
||
|
||
/**
|
||
* @var string Mot de passe du service sur la plate-forme
|
||
* @access public
|
||
*/
|
||
public $zServicePassword ;
|
||
|
||
/**
|
||
* @var boolean Proc<6F>der <20> des encodage / d<>codage UTF-8 lors de l'envoi
|
||
* @access public
|
||
*/
|
||
public $bEncodeData ;
|
||
|
||
/**
|
||
* @var SoapClient L'objet SoapClient qui <20>tablit la connexion
|
||
* @access private
|
||
*/
|
||
private $oSoapClient ;
|
||
|
||
/**
|
||
* Constructeur
|
||
*
|
||
* @param string $_zWsdlURI URI du WSDL
|
||
* @param string $_zServiceLogin Login (Code) du service sur la plate-forme
|
||
* @param string $_zServicePassword Mot de passe du servuce sur la plate-forme
|
||
* @param bool $_bSecured Mode s<>curis<69>e (via HTTPS) ou pas
|
||
*/
|
||
public function __construct ($_zWsdlURI, $_zServiceLogin, $_zServicePassword, $_bSecured = false, $_bEncodeData = false)
|
||
{
|
||
$this->zWsdlURI = $_zWsdlURI ;
|
||
// ---- Connexion auto au WS principal gérant les comptes FB des marques
|
||
if(isset($_SESSION["SESS_FB_USER"]) && $_SESSION["SESS_FB_USER"] == true && defined('CRM_WS_FB_USER') && defined('CRM_WS_FB_PWD') ){
|
||
$this->zServiceLogin = CRM_WS_FB_USER ;
|
||
$this->zServicePassword = CRM_WS_FB_PWD ;
|
||
}else{
|
||
$this->zServiceLogin = $_zServiceLogin ;
|
||
$this->zServicePassword = $_zServicePassword ;
|
||
}
|
||
$this->bSecured = $_bSecured ;
|
||
$this->oSoapClient = null ;
|
||
$this->bEncodeData = $_bEncodeData ;
|
||
}
|
||
|
||
/**
|
||
* Etablissement de la connexion
|
||
*
|
||
* @return bool Statut de l'<27>tablissement de connexion
|
||
*/
|
||
public function connect ()
|
||
{
|
||
|
||
$bRet = true ;
|
||
try
|
||
{
|
||
$this->oSoapClient = new SoapClient (
|
||
$this->zWsdlURI,
|
||
array (
|
||
'trace' => 1,
|
||
'soap_version' => SOAP_1_1,
|
||
'login' => $this->zServiceLogin,
|
||
'password' => $this->zServicePassword
|
||
)
|
||
) ;
|
||
$bRet = true ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
$this->oSoapClient = null ;
|
||
$bRet = false ;
|
||
@libxml_set_streams_context () ;
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
|
||
return $bRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Fermeture de la connexion
|
||
*
|
||
*/
|
||
public function disconnect ()
|
||
{
|
||
$this->oSoapClient = null ;
|
||
}
|
||
|
||
/**
|
||
* Cr<43>ation d'un utilisateur sur la plate-forme
|
||
*
|
||
* @param CPCUser $_oNewUser L'objet utilisateur <20> cr<63>er sur la plate-forme
|
||
* @param int $_iCreationMode Mode de cr<63>ation avec ou sans fiabilisation E-Mail
|
||
* @return int L'identifiant de l'utilisateur <20> cr<63>er sur la plate-forme
|
||
*/
|
||
public function createUser ($_oNewUser, $_iCreationMode = CREATION_MODE_WITHOUT_CONFIRMATION_EMAIL)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$_oNewUser->check () ;
|
||
$oNewPlatosUser = $this->castUserObjectToPlatos ($_oNewUser) ;
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("createUser", array ($oNewPlatosUser, $_iCreationMode)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
catch (Exception $_eException)
|
||
{
|
||
throw new Exception ($_eException->getMessage ()) ;
|
||
}
|
||
}
|
||
catch (Exception $_oException)
|
||
{
|
||
throw new Exception ($_oException->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Inscription au newsletter
|
||
*
|
||
* @param string $_zEmail email de l'user
|
||
* @return CPCUser L'objet utilisateur r<>cup<75>r<EFBFBD> ou FALSE si erreur
|
||
*/
|
||
public function newsletterSubscribe ($_zEmail)
|
||
{
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
return $this->oSoapClient->__soapCall ("newsletterSubscribe", array ($_zEmail)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* Description au newsletter
|
||
*
|
||
* @param string $_zEmail email de l'user
|
||
* @return CPCUser L'objet utilisateur r<>cup<75>r<EFBFBD> ou FALSE si erreur
|
||
*/
|
||
public function newsletterUnsubscribe ($_zEmail)
|
||
{
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
return $this->oSoapClient->__soapCall ("newsletterUnsubscribe", array ($_zEmail)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* Sauvegarde d'un utilisateur sur la plate-forme
|
||
*
|
||
* @param CPCUser $_oUser L'objet utilisateur <20> cr<63>er sur la plate-forme
|
||
* @return bool Statut de l'op<6F>ration de sauvegarde
|
||
*/
|
||
public function saveUser ($_oUser)
|
||
{
|
||
|
||
$bRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$_oUser->check () ;
|
||
$oPlatosUser = $this->castUserObjectToPlatos ($_oUser) ;
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("saveUser", array ($oPlatosUser)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
catch (Exception $_eException)
|
||
{
|
||
throw new Exception ($_eException->getMessage ()) ;
|
||
}
|
||
}
|
||
catch (Exception $_oException)
|
||
{
|
||
throw new Exception ($_oException->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $bRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Chargement d'un utilisateur depuis la plate-forme
|
||
*
|
||
* @param int $_iUserId Identifiant de l'utilisateur <20> charger
|
||
* @return CPCUser L'objet utilisateur r<>cup<75>r<EFBFBD> ou FALSE si erreur
|
||
*/
|
||
public function getUser ($_iUserId)
|
||
{
|
||
|
||
$oCPCUser = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$oPlatosUser = $this->oSoapClient->__soapCall ("getUser", array ($_iUserId)) ;
|
||
$oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Chargement d'un utilisateur depuis la plate-forme
|
||
*
|
||
* @param string $_zEmail email de l'utilisateur <20> charger
|
||
* @return CPCUser L'objet utilisateur r<>cup<75>r<EFBFBD> ou FALSE si erreur
|
||
*/
|
||
public function getUserByEmail ($_zEmail)
|
||
{
|
||
|
||
$oCPCUser = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$oPlatosUser = $this->oSoapClient->__soapCall ("getUserByEmail", array ($_zEmail)) ;
|
||
$oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Chargement d'un utilisateur depuis la plate-forme
|
||
*
|
||
* @param string $_zHashCode hashcode de l'utilisateur <20> charger
|
||
* @return CPCUser L'objet utilisateur r<>cup<75>r<EFBFBD> ou FALSE si erreur
|
||
*/
|
||
public function getUserByHashCode ($_zHashCode)
|
||
{
|
||
|
||
$oCPCUser = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$oPlatosUser = $this->oSoapClient->__soapCall ("getUserByHashCode", array ($_zHashCode)) ;
|
||
$oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Chargement d'un utilisateur depuis la plate-forme
|
||
*
|
||
* @param string $_zUserHashcode Hash code de l'utilisateur <20> charger
|
||
* @return CPCUser L'objet utilisateur r<>cup<75>r<EFBFBD> ou FALSE si erreur
|
||
*/
|
||
public function authenticateByHashCodeUser ($_zUserHashcode)
|
||
{
|
||
|
||
$oCPCUser = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$oPlatosUser = $this->oSoapClient->__soapCall ("authenticateByHashCodeUser", array ($_zUserHashcode)) ;
|
||
$oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Authentification d'un utilisateur sur la plate-forme
|
||
*
|
||
* @param string $_zUserLogin Login de l'utilisateur
|
||
* @param string $_zUserPassword Mot de passe de l'utilisateur
|
||
* @return CPCUser L'objet utilisateur authentifi<66> ou FALSE si erreur
|
||
*/
|
||
public function authenticateUser ($_zUserLogin, $_zUserPassword)
|
||
{
|
||
|
||
$oCPCUser = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$oPlatosUser = $this->oSoapClient->__soapCall (
|
||
"authenticateUser",
|
||
array (
|
||
$this->strEnvDecode ($_zUserLogin),
|
||
$this->strEnvDecode ($_zUserPassword)
|
||
)
|
||
) ;
|
||
//echo "<pre>" ;
|
||
//print_r ($this->oSoapClient) ;
|
||
//echo "</pre>" ;
|
||
$oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
//echo "<pre>" ;
|
||
//print_r ($this->oSoapClient) ;
|
||
//echo "</pre>" ;
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Authentification d'un utilisateur sur la plate-forme
|
||
*
|
||
* @param string $_zUserHashCode Hashcode de l'utilisateur
|
||
* @return CPCUser L'objet utilisateur authentifi<66> ou FALSE si erreur
|
||
*/
|
||
public function authenticateUserByHashCode ($_zUserHashCode)
|
||
{
|
||
|
||
$oCPCUser = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$oPlatosUser = $this->oSoapClient->__soapCall (
|
||
"authenticateByHashCodeUser",
|
||
array ($this->strEnvDecode ($_zUserHashCode))
|
||
) ;
|
||
$oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Activation d'un utilisateur sur la plate-forme
|
||
*
|
||
* @param int $_iUserId Identifiant de l'utilisateur <20> charger
|
||
* @return bool Statut de l'op<6F>ration d'activation
|
||
*/
|
||
public function activateUser ($_iUserId)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("activateUser", array ($_iUserId)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Suppression d'un utilisateur sur la plate-forme
|
||
*
|
||
* @param int $_iUserId Identifiant de l'utilisateur <20> supprimer
|
||
* @return bool Statut de l'op<6F>ration de suppresion
|
||
*/
|
||
public function deleteUser ($_iUserId)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("deleteUser", array ($_iUserId)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Changement de mot de passe d'un utilisateur sur la plate-forme
|
||
*
|
||
* @param int $_iUserId Identifiant de l'utilisateur
|
||
* @param string $_zNewPassword Nouveau mot de passe de l'utilisateur
|
||
* @return bool Statut de l'op<6F>ration de mise <20> jour
|
||
*/
|
||
public function changePassword ($_iUserId, $_zNewPassword)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall (
|
||
"changePassword",
|
||
array (
|
||
$_iUserId,
|
||
$this->strEnvDecode ($_zNewPassword)
|
||
)
|
||
) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Envoi d'un email de changement de mot de passe
|
||
*
|
||
* @param int $_iUserId Identifiant de l'utilisateur
|
||
* @return bool Statut de l'op<6F>ration
|
||
*/
|
||
public function sendChangePasswordEmail ($_iUserId)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("sendChangePasswordEmail", array ($_iUserId)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Ce service permet de r<>cup<75>rer les informations n<>c<EFBFBD>ssaire <20> la g<>n<EFBFBD>ration d'un bon de r<>duction
|
||
*
|
||
* @param int $_iUserId Utilisateur demandant le bon de reduction
|
||
* @param string $_zTypeBon Nom du type de bon
|
||
* @return CPlatosOperation Structure de couponning operation
|
||
*/
|
||
public function getBon ($_iUserId, $_zTypeBon)
|
||
{
|
||
|
||
$oPlatosOperation = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$zTypeBon = $_zTypeBon ;
|
||
if ($this->bEncodeData)
|
||
{
|
||
$zTypeBon = $this->strEnvDecode ($zTypeBon) ;
|
||
}
|
||
$oPlatosOperation = $this->oSoapClient->__soapCall ("getBon", array ($_iUserId, $zTypeBon)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $this->castBDRFromPlatos ($oPlatosOperation) ;
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* Ce service permet de fixer le statut d'un bon <20> "imprim<69>"
|
||
*
|
||
* @param int $_iUserId Utilisateur demandant l'impression du bon de reduction
|
||
* @param int $_iBonId Identifiant du bon de redution <20> imprimer
|
||
* @return int Resultat de l'impression
|
||
*/
|
||
public function printBon ($_iUserId, $_iBonId)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("printBon", array ($_iUserId, $_iBonId)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Ce service permet de cr<63>er un nouvel courrier entrant
|
||
*
|
||
* @param int $iUserId id de l'utilisateur
|
||
* @param int $iSujetId id du Sujet de courrier
|
||
* @param string $zCommentaire Commentaire
|
||
* @param int $iStatusId id du statut de courrier
|
||
*
|
||
* @return int Identifiant num<75>rique du nouveau courrier
|
||
*/
|
||
public function createInCourrier ($_iUserId, $_iSujetId, $_zCommentaire, $_iStatusId)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("createInCourrier", array ($_iUserId, $_iSujetId, $_zCommentaire, $_iStatusId)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
}
|
||
|
||
/**
|
||
* Ce service permet de cr<63>er un nouvel courrier sortant
|
||
*
|
||
* @param int $iUserId id de l'utilisateur
|
||
* @param int $iSujetId id du Sujet de courrier
|
||
* @param string $zCommentaire Commentaire
|
||
*
|
||
* @return int Identifiant num<75>rique du nouveau courrier
|
||
*/
|
||
public function createOutCourrier ($_iUserId, $_iSujetId, $_zCommentaire)
|
||
{
|
||
|
||
$iRet = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$iRet = $this->oSoapClient->__soapCall ("createOutCourrier", array ($_iUserId, $_iSujetId, $_zCommentaire)) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $iRet ;
|
||
}
|
||
|
||
/**
|
||
* Ce service permet de recup<75>rer les infos concernant l'utilisateur pour tous services confondus
|
||
*
|
||
* @param int $_iUserId Identifiant de l'utilisateur <20> charger
|
||
* @return CPCUser L'objet utilisateur r<>cup<75>r<EFBFBD> ou FALSE si erreur
|
||
*/
|
||
public function getAllToFieldsByUser ($_iUserId)
|
||
{
|
||
|
||
$oCPCUser = false ;
|
||
|
||
if (is_object ($this->oSoapClient))
|
||
{
|
||
try
|
||
{
|
||
$oPlatosUser = $this->oSoapClient->__soapCall ("getAllToFieldsByUser", array ($_iUserId)) ;
|
||
$oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ;
|
||
}
|
||
catch (SoapFault $_eSoapFault)
|
||
{
|
||
throw new Exception ($_eSoapFault->getMessage ()) ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
throw new Exception ("Connexion non <20>tablie") ;
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* Conversion d'un objet CPCUser en CPlatosUser
|
||
*
|
||
* @param CPCUser& $_oInputCPCUser Objet Utilisateur au format de l'API Client
|
||
* @return CPlatosUser Objet Utilisateur au format de PLATOS
|
||
*/
|
||
private function castUserObjectToPlatos (&$_oInputCPCUser)
|
||
{
|
||
$oPlatosUser = new CPlatosUser () ;
|
||
$oPlatosUser->iId = $_oInputCPCUser->iId ;
|
||
$oPlatosUser->zEmail = $this->strEnvEncode ($_oInputCPCUser->zEmail) ;
|
||
$oPlatosUser->zLogin = $this->strEnvEncode ($_oInputCPCUser->zLogin) ;
|
||
$oPlatosUser->zPassword = $this->strEnvEncode ($_oInputCPCUser->zPassword) ;
|
||
$oPlatosUser->zHashCode = $this->strEnvEncode ($_oInputCPCUser->zHashCode) ;
|
||
|
||
$oPlatosUser->zCivilite = $this->strEnvEncode ($_oInputCPCUser->zCivilite) ;
|
||
$oPlatosUser->zNom = $this->strEnvEncode ($_oInputCPCUser->zNom) ;
|
||
$oPlatosUser->zPrenom = $this->strEnvEncode ($_oInputCPCUser->zPrenom) ;
|
||
$oPlatosUser->zDateNaissance = $this->strEnvEncode ($_oInputCPCUser->zDateNaissance) ;
|
||
$oPlatosUser->zAdresse1 = $this->strEnvEncode ($_oInputCPCUser->zAdresse1) ;
|
||
$oPlatosUser->zAdresse2 = $this->strEnvEncode ($_oInputCPCUser->zAdresse2) ;
|
||
$oPlatosUser->zCodePostal = $this->strEnvEncode ($_oInputCPCUser->zCodePostal) ;
|
||
$oPlatosUser->zVille = $this->strEnvEncode ($_oInputCPCUser->zVille) ;
|
||
$oPlatosUser->iInscritNewLetter = $_oInputCPCUser->iInscritNewLetter ;
|
||
$oPlatosUser->zEan128 = $this->strEnvEncode ($_oInputCPCUser->zEan128) ;
|
||
|
||
$tzFieldCodes = $_oInputCPCUser->getDynamicFieldsList () ;
|
||
$toFields = $_oInputCPCUser->getFields () ;
|
||
|
||
if (count ($tzFieldCodes) > 0)
|
||
{
|
||
foreach ($tzFieldCodes as $zFieldCode)
|
||
{
|
||
if ($toFields[$zFieldCode]->iType == FIELDTYPE_CHECKBOX)
|
||
{
|
||
$zValue = $_oInputCPCUser->getField ($zFieldCode) ;
|
||
|
||
if (is_array ($zValue))
|
||
{
|
||
$zValue = serialize ($zValue) ;
|
||
}
|
||
$oPlatosUser->toFields[$zFieldCode] = $zValue ;
|
||
}
|
||
else
|
||
{
|
||
$oPlatosUser->toFields[$zFieldCode] = $this->strEnvEncode ($_oInputCPCUser->getField ($zFieldCode)) ;
|
||
}
|
||
}
|
||
}
|
||
|
||
return $oPlatosUser ;
|
||
}
|
||
|
||
/**
|
||
* Conversion d'un objet CPlatosUser en CPCUser
|
||
*
|
||
* @param CPlatosUser& $_oInputPlatosUser Objet Utilisateur au format de PLATOS
|
||
* @return CPCUser Objet Utilisateur au format de l'API Client
|
||
*/
|
||
private function castUserObjectFromPlatos (&$_oInputPlatosUser)
|
||
{
|
||
|
||
$oCPCUser = new CPCUser () ;
|
||
$oCPCUser->iId = $_oInputPlatosUser->iId ;
|
||
$oCPCUser->zEmail = $this->strEnvDecode ($_oInputPlatosUser->zEmail) ;
|
||
$oCPCUser->zLogin = $this->strEnvDecode ($_oInputPlatosUser->zLogin) ;
|
||
$oCPCUser->zPassword = $this->strEnvDecode ($_oInputPlatosUser->zPassword) ;
|
||
$oCPCUser->zHashCode = $this->strEnvDecode ($_oInputPlatosUser->zHashCode) ;
|
||
|
||
$oCPCUser->zCivilite = $this->strEnvDecode ($_oInputPlatosUser->zCivilite) ;
|
||
$oCPCUser->zNom = $this->strEnvDecode ($_oInputPlatosUser->zNom) ;
|
||
$oCPCUser->zPrenom = $this->strEnvDecode ($_oInputPlatosUser->zPrenom) ;
|
||
$oCPCUser->zDateNaissance = $this->strEnvDecode ($_oInputPlatosUser->zDateNaissance) ;
|
||
$oCPCUser->zAdresse1 = $this->strEnvDecode ($_oInputPlatosUser->zAdresse1) ;
|
||
$oCPCUser->zAdresse2 = $this->strEnvDecode ($_oInputPlatosUser->zAdresse2) ;
|
||
$oCPCUser->zCodePostal = $this->strEnvDecode ($_oInputPlatosUser->zCodePostal) ;
|
||
$oCPCUser->zVille = $this->strEnvDecode ($_oInputPlatosUser->zVille) ;
|
||
$oCPCUser->iInscritNewLetter = $_oInputPlatosUser->iInscritNewLetter ;
|
||
$oCPCUser->zEan128 = $this->strEnvDecode ($_oInputPlatosUser->zEan128) ;
|
||
|
||
if (isset ($_oInputPlatosUser->toFields))
|
||
{
|
||
foreach ($_oInputPlatosUser->toFields as $zFieldCode => $zFieldValue)
|
||
{
|
||
if (array_key_exists ($zFieldCode, $_oInputPlatosUser->toFieldsConfig))
|
||
{
|
||
if ($_oInputPlatosUser->toFieldsConfig[$zFieldCode]->iFieldType == FIELDTYPE_CHECKBOX)
|
||
{
|
||
$zFieldValue = unserialize ($zFieldValue) ;
|
||
$oCPCUser->addField ($zFieldCode, $_oInputPlatosUser->toFieldsConfig[$zFieldCode]->iFieldType, "", $zFieldValue) ;
|
||
}
|
||
else
|
||
{
|
||
$oCPCUser->addField ($zFieldCode, $_oInputPlatosUser->toFieldsConfig[$zFieldCode]->iFieldType, $_oInputPlatosUser->toFieldsConfig[$zFieldCode]->zPattern, $this->strEnvDecode ($zFieldValue)) ;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (isset ($_oInputPlatosUser->toFieldsConfig))
|
||
{
|
||
foreach ($_oInputPlatosUser->toFieldsConfig as $zFieldCode => $oFieldConfig)
|
||
{
|
||
$oCPCUser->addFieldConfig ($zFieldCode, $oFieldConfig) ;
|
||
}
|
||
}
|
||
|
||
if (isset ($_oInputPlatosUser->toServices))
|
||
{
|
||
foreach ($_oInputPlatosUser->toServices as $oServices)
|
||
{
|
||
$oCPCUser->addServiceCorresponding ($oServices) ;
|
||
}
|
||
}
|
||
|
||
return $oCPCUser ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Conversion d'un objet CPlatosOperation en CPCBon
|
||
*
|
||
* @param CPlatosOperation& $_oInputPlatosOperation Objet Operation au format de PLATOS
|
||
* @return CPCBon Objet Bon de reduction
|
||
*/
|
||
private function castBDRFromPlatos (&$_oInputPlatosOperation)
|
||
{
|
||
|
||
$oCPCBon = new CPCBon () ;
|
||
|
||
$oCPCBon->iId = $_oInputPlatosOperation->iId ;
|
||
$oCPCBon->zTypeBon = $_oInputPlatosOperation->zTypeBon ;
|
||
$oCPCBon->zMontant = $_oInputPlatosOperation->zMontant ;
|
||
$oCPCBon->zEan13 = $_oInputPlatosOperation->zEan13 ;
|
||
$oCPCBon->zDebutValidite = $_oInputPlatosOperation->zDebutValidite ;
|
||
$oCPCBon->zFinValidite = $_oInputPlatosOperation->zFinValidite ;
|
||
$oCPCBon->zNomMarque = $_oInputPlatosOperation->zNomMarque ;
|
||
$oCPCBon->zAdresseMarque = $_oInputPlatosOperation->zAdresseMarque ;
|
||
$oCPCBon->zRcsMarque = $_oInputPlatosOperation->zRcsMarque ;
|
||
$oCPCBon->zConditionValidite = $_oInputPlatosOperation->zConditionValidite ;
|
||
$oCPCBon->zListeProduits = $_oInputPlatosOperation->zListeProduits ;
|
||
$oCPCBon->zLimitationGeographique = $_oInputPlatosOperation->zLimitationGeographique ;
|
||
$oCPCBon->iNombreBons = $_oInputPlatosOperation->iNombreBons ;
|
||
$oCPCBon->zEan128 = $_oInputPlatosOperation->zEan128 ;
|
||
$oCPCBon->iBonId = $_oInputPlatosOperation->iBonId ;
|
||
|
||
return $oCPCBon ;
|
||
|
||
}
|
||
|
||
/**
|
||
* Fonction d'encodage
|
||
*/
|
||
private function strEnvEncode ($_zInputStr)
|
||
{
|
||
if ($this->bEncodeData)
|
||
{
|
||
return utf8_encode ($_zInputStr) ;
|
||
}
|
||
else
|
||
{
|
||
return $_zInputStr ;
|
||
}
|
||
}
|
||
|
||
private function strEnvDecode ($_zInputStr)
|
||
{
|
||
if ($this->bEncodeData)
|
||
{
|
||
return utf8_decode ($_zInputStr) ;
|
||
}
|
||
else
|
||
{
|
||
return $_zInputStr ;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* Classe faisant d'une valeur autoris<69> pour un champs
|
||
*/
|
||
class CPlatosFieldAttribute
|
||
{
|
||
public $iId ;
|
||
public $zLabel ;
|
||
}
|
||
|
||
/**
|
||
* Classe faisant abstraction d'une liste de valeur autoris<69> pour un champs (Type liste)
|
||
*/
|
||
class CPlatosFieldConfig
|
||
{
|
||
public $zFieldId ;
|
||
public $iFieldType ;
|
||
public $zLabel ;
|
||
public $zPattern ;
|
||
public $toAttributes = array () ;
|
||
}
|
||
|
||
/**
|
||
* Classe conventionnelle pour les <20>changes de donn<6E>es avec PLATOS
|
||
*
|
||
* @package PlatosClient
|
||
* @name CPlatosUser
|
||
* @access public
|
||
*/
|
||
class CPlatosUser
|
||
{
|
||
|
||
public $iId ;
|
||
public $zEmail ;
|
||
public $zLogin ;
|
||
public $zPassword ;
|
||
public $zHashCode ;
|
||
public $zLangageCode ;
|
||
public $toFields ;
|
||
public $toFieldsConfig ;
|
||
public $toServices ;
|
||
|
||
public $zCivilite ;
|
||
public $zNom ;
|
||
public $zPrenom ;
|
||
public $zDateNaissance ;
|
||
public $zAdresse1 ;
|
||
public $zAdresse2 ;
|
||
public $zCodePostal ;
|
||
public $zVille ;
|
||
public $iInscritNewLetter ;
|
||
public $zEan128 ;
|
||
|
||
|
||
public function __construct()
|
||
{
|
||
$this->iId = 0 ;
|
||
$this->zEmail = "" ;
|
||
$this->zLogin = "" ;
|
||
$this->zPassword = "" ;
|
||
$this->zHashCode = "" ;
|
||
|
||
$this->zCivilite = "" ;
|
||
$this->zNom = "" ;
|
||
$this->zPrenom = "" ;
|
||
$this->zDateNaissance = "" ;
|
||
$this->zAdresse1 = "" ;
|
||
$this->zAdresse2 = "" ;
|
||
$this->zVille = "" ;
|
||
$this->zCodePostal = 0 ;
|
||
$this->iInscritNewLetter = 0 ;
|
||
$this->zEan128 = "" ;
|
||
|
||
$this->toFields = array () ;
|
||
$this->toFieldsConfig = array () ;
|
||
$this->toServices = array () ;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* Classe conventionnelle pour les <20>changes de donn<6E>es avec PLATOS
|
||
*
|
||
* @package PlatosClient
|
||
* @name CPlatosOperation
|
||
* @access private
|
||
*/
|
||
class CPlatosOperation
|
||
{
|
||
|
||
public $iId ;
|
||
public $zTypeBon ;
|
||
public $zMontant ;
|
||
public $zEan13 ;
|
||
public $zDebutValidite ;
|
||
public $zFinValidite ;
|
||
public $zNomMarque ;
|
||
public $zAdresseMarque ;
|
||
public $zRcsMarque ;
|
||
public $zConditionValidite ;
|
||
public $zListeProduits ;
|
||
public $zLimitationGeographique ;
|
||
public $iNombreBons ;
|
||
public $zEan128 ;
|
||
public $iBonId ;
|
||
|
||
}
|
||
|
||
|
||
?>
|