Skip to content
Snippets Groups Projects
Commit 6325b7cb authored by llaffont's avatar llaffont
Browse files

SSO CVS: ajout informations abonnés

parent a0ef2824
Branches
Tags 7.5.19
No related merge requests found
......@@ -66,17 +66,41 @@ class Class_CVSLink extends Class_WebService_Abstract {
return $this->getCvsSearchNotices($query,$page,$nb_par_page);
}
public function formatXML($xml) {
$dom = new DOMDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML($xml);
$dom->formatOutput = TRUE;
return $dom->saveXml();
}
function callCVS($action,$body=array(),&$infos){
// paramètres d'authentification
if ($this->_user) {
$adhid = $this->_user->getIdabon();
$adh='<adhid>'.$adhid.'</adhid>';
$user = $this->_user ? $this->_user : new Class_Users();
$user_infos = array_filter([
'nom' => $user->getNom(),
'prenom' => $user->getPrenom(),
'pseudo' => $user->getPseudo(),
'password' => $user->getPassword(),
'email' => $user->getMail(),
'dnaiss' => (($naissance = $user->getNaissance())
? implode('-', array_reverse(explode('/', $naissance)))
: ''),
'datout' => (($finabo = $user->getDateFin())
? implode('-', array_reverse(explode('/', $finabo)))
: ''),
'bibliotheque' => $user->getLibelleBib()]);
$xml_user_infos = '';
foreach($user_infos as $key => $value) {
$xml_user_infos .= "<$key>$value</$key>";
}
else $adh='';
$time = $this->getCurrentTime();
$key = md5($adhid
$key = md5($user->getIdabon()
.$this->bmid
.$this->bmkey
.$this->sourceName
......@@ -93,7 +117,7 @@ class Class_CVSLink extends Class_WebService_Abstract {
<sourceid>".$this->sourceId."</sourceid>
<key>{$key}</key>
<time>{$time}</time>
".$adh."
".($user->getIdabon() ? ("<adhid>".$user->getIdabon()."</adhid>") : "")."
<action>{$action}</action>
</header>";
if($action == "acces_site"){
......@@ -108,11 +132,12 @@ class Class_CVSLink extends Class_WebService_Abstract {
<classement><![CDATA[".$body['classement']."]]></classement>
<page><![CDATA[".$body['page']."]]></page>
<nombre_par_page><![CDATA[".$body['nombre_par_page']."]]></nombre_par_page>
$xml_user_infos
</body>";
}
$xml .= "</albums>";
$xml = base64_encode($xml);
$xml = base64_encode($this->formatXML($xml));
$xml = strtr($xml,'+/','-_');
// envoi du XML à cvs
......
......@@ -35,10 +35,14 @@ abstract class CVSLinkTestCase extends Storm_Test_ModelTestCase {
->newInstanceWithId(4)
->setIdabon(34)
->setLogin(34)
->setPseudo('JKhan')
->setPrenom('Jerry')
->setNom('Khan')
->setMail('feu@essence.fr')
->setDateFin('2023-09-02');
->setPassword('secret')
->setDateFin('2023-09-02')
->setNaissance('1977-06-27')
->setBib(Class_Bib::newInstanceWithId(34, ['libelle' => 'Annecy']));
$this->_cvs = Class_CVSLink::forUser($this->_jerry);
......@@ -63,24 +67,33 @@ class CVSLinkSearchTest extends CVSLinkTestCase {
protected function _expectedXML() {
return <<<EOXML
<?xml version="1.0" encoding="utf-8"?>
<albums>
<header>
<bmid>22223</bmid>
<sourceid>22225</sourceid>
<key>d0a1b72e8e6d7af27d400e2009c1a873</key>
<time>1369640315</time>
<adhid>34</adhid>
<action>search_document</action>
</header><body>
<q><![CDATA[ecole]]></q>
<espace><![CDATA[]]></espace>
<classement><![CDATA[consultes]]></classement>
<page><![CDATA[1]]></page>
<nombre_par_page><![CDATA[5]]></nombre_par_page>
</body></albums>
EOXML;
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<albums>
<header>
<bmid>22223</bmid>
<sourceid>22225</sourceid>
<key>d0a1b72e8e6d7af27d400e2009c1a873</key>
<time>1369640315</time>
<adhid>34</adhid>
<action>search_document</action>
</header>
<body>
<q><![CDATA[ecole]]></q>
<espace><![CDATA[]]></espace>
<classement><![CDATA[consultes]]></classement>
<page><![CDATA[1]]></page>
<nombre_par_page><![CDATA[5]]></nombre_par_page>
<nom>Khan</nom>
<prenom>Jerry</prenom>
<pseudo>JKhan</pseudo>
<password>secret</password>
<email>feu@essence.fr</email>
<dnaiss>1977-06-27</dnaiss>
<datout>2023-09-02</datout>
<bibliotheque>Annecy</bibliotheque>
</body>
</albums>";
return $this->_cvs->formatXML($xml);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment