/**
     * [Put your description here]
     */
    function main($content, $conf)
    {
        $this->conf = $conf;
        $this->pi_setPiVarDefaults();
        $this->pi_USER_INT_obj = 1;
        // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
        $this->pi_loadLL();
        session_start();
        $this->typeExecution = "prod";
        $urlCas = "none";
        $portCas = "none";
        if ($this->typeExecution == "dev") {
            $urlCas = "xinf-devlinux.intranet.haras-nationaux.fr";
            $portCas = 7777;
        } else {
            if ($this->typeExecution == "prod") {
                $urlCas = "cerbere.haras-nationaux.fr";
                $portCas = 443;
            }
        }
        if (isset($_GET["userdebug"])) {
            include_once "typo3conf/ext/dlcube_hn_01/class.WebservicesCompte.php";
            include_once "typo3conf/ext/dlcube_hn_01/class.WebservicesAccess.php";
            $param[] = array("login" => $_GET["userdebug"], "ctx" => null);
            $ws = new WebservicesCompte();
            if (!$ws->connectIdent()) {
                $content = "ERROR:" . $ws->getErrorMessage();
                return $content;
            }
            $result = $ws->getPersonneByLogin($param);
            debug($result);
            print_r($result);
        }
        if (isset($_GET["action"]) && $_GET["action"] == "auth" && !isset($_GET["ticket"])) {
            phpCAS::setDebug();
            phpCAS::client(CAS_VERSION_2_0, $urlCas, $portCas, 'cas', 'true');
            $ur = phpCAS::getServerLoginURL(false);
            $content .= '<IFRAME src="' . $ur . '" frameborder="no" height="600" width="670"></IFRAME>';
            return $this->pi_wrapInBaseClass($content);
        }
        phpCAS::client(CAS_VERSION_2_0, $urlCas, $portCas, 'cas', 'true');
        phpCAS::checkAuthentication();
        $_SESSION["portalId"] = phpCAS::getUser();
        echo '<html><body><script type="text/javascript">
		    window.open( "' . $this->pi_getPageLink($_SESSION["service_id_auth"]) . '", "_top");
		</script></body>';
        exit;
    }
 /**
  * Plug-in pour creation de comptes CAS
  */
 function main($content, $conf)
 {
     $this->conf = $conf;
     $this->pi_setPiVarDefaults();
     $this->pi_USER_INT_obj = 1;
     // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
     $this->pi_loadLL();
     session_start();
     if (!isset($_SESSION["portalId"]) || $_SESSION["portalId"] == "") {
         header("Location: index.php?id=2822");
     }
     $type = "dev_ext";
     $url = null;
     if ($type == "prod") {
         $url = "www4.haras-nationaux.fr:8080";
     } else {
         if ($type == "dev") {
             $url = "xinf-devlinux:8080";
         } else {
             if ($type == "dev_ext") {
                 $url = "80.124.158.237:8080";
             }
         }
     }
     /**
      * declaration des urls de redirection iframe
      */
     $this->urlPassageIdentFort = $this->pi_getPageLink("3684");
     $this->urlAchatPoint = $this->pi_getPageLink("3675");
     $this->urlGererConsulterCheval = $this->pi_getPageLink("3674");
     $this->urlDeclarerCheval = $this->pi_getPageLink("3673");
     $this->urlModifSosPoulain = $this->pi_getPageLink("3672");
     $this->urlAjoutSosPoulain = $this->pi_getPageLink("3671");
     $this->urlModifCompte = $this->pi_getPageLink("3670");
     /**
      * Declaration des URL pour accéder aux services externes
      */
     $this->urlDeclaNovelleNaissance = "http://" . $url . "/cid-internet-web/declaration-naissance/ReferenceDeSaillieAction.do?dispatch=initDataBeforeLoad&typeDeclaration=POS";
     $this->urlDeclaResultNeg = "http://" . $url . "/cid-internet-web/declaration-naissance/ReferenceDeSaillieAction.do?dispatch=initDataBeforeLoad&typeDeclaration=NEG";
     $userId = $_SESSION["portalId"];
     $userId = "faible";
     $param[] = array("login" => $userId, "ctx" => null);
     $ws = new WebservicesCompte("dev_ext");
     if (!$ws->connectIdent()) {
         $content = "ERROR:" . $ws->getErrorMessage();
         $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
         return $content;
     }
     $this->personne = $ws->getPersonneByLogin($param);
     print_r($this->personne);
     /**
      * recuperation du nombre de naissance, de lieux de detention
      */
     $paramCid[] = array("login" => $_SESSION["portalId"], "ctx" => null);
     $wsCid = new WebservicesCompte("dev_ext");
     if (!$wsCid->connectCid()) {
         //$content="ERROR:".$wsCid->getErrorMessage();
         $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
         return $content;
     }
     $this->nbreNaissance = $wsCid->getNbrNaissanceAnneeEnCours4User($paramCid);
     $this->nbreLieudetention = $wsCid->getNbrLieuDetention4User($paramCid);
     $this->nbreChevaux = $wsCid->getNbrChevaux4User($paramCid);
     /**
      * recuperation du nombre de factures et le montant total
      */
     if ($this->personne["findPersonneByLoginReturn"]["key"]["numeroPersonne"] != "") {
         $paramPsi[] = $this->personne["findPersonneByLoginReturn"]["key"]["numeroPersonne"];
         $paramPsi[] = $this->personne["findPersonneByLoginReturn"]["key"]["numeroOrdreAdresse"];
         $wsPsi = new WebservicesCompte();
         if (!$wsPsi->connectPsi()) {
             //$content="ERROR:".$wsPsi->getErrorMessage();
             $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
             return $content;
         } else {
             //Nombre de factures
             $this->nbreFactures = $wsPsi->getNbrFactureARegler4User($paramPsi);
             $this->montantFactures = $wsPsi->getMontantFactureARegler4User($paramPsi);
         }
     }
     /**
      * Recup des centres tech du departement
      */
     if ($this->personne["findPersonneByLoginReturn"]["adresse"]["commune"]["codePostal"] != "" && $this->personne["findPersonneByLoginReturn"]["adresse"]["commune"]["codePostal"] > 0) {
         $ws = new WebservicesAccess();
         if ($ws->connect()) {
             $objTransfert = new ObjectTransfertWS();
             $objTransfert->setKey("codeDepartement");
             $objTransfert->setValue(substr($this->personne["findPersonneByLoginReturn"]["adresse"]["commune"]["codePostal"], 0, 2));
             $paramCT[] = $objTransfert;
             $result = $ws->getCentresTEchniques($paramCT);
             //if(!$result && $ws->getErrorMessage()!="") echo "[error resultat:]".$ws->getErrorMessage();
             /**
              * Calcul du centre le plus proche
              */
             $precTot = 10000000000;
             foreach ($result as $centre) {
                 if ($centre["codePostal"] > $this->personne["findPersonneByLoginReturn"]["adresse"]["commune"]["codePostal"]) {
                     $result = $centre["codePostal"] - $this->personne["findPersonneByLoginReturn"]["adresse"]["commune"]["codePostal"];
                 } else {
                     $result = $this->personne["findPersonneByLoginReturn"]["adresse"]["commune"]["codePostal"] - $centre["codePostal"];
                 }
                 if ($result < $precTot) {
                     $precTot = $result;
                     $this->ct = $centre;
                 }
             }
         }
     }
     /**
      * On regarde si l'utilisateur est abonn� aux news et alertes
      */
     if ($this->personne["findPersonneByLoginReturn"]["coordonnees"]["email"] != "") {
         $query = "SELECT * FROM tx_fabformmail_abonne where email='" . $this->personne["findPersonneByLoginReturn"]["coordonnees"]["email"] . "'";
         $res = mysql(TYPO3_db, $query) or die("req invalide : {$query}");
         if (mysql_num_rows($res) > 0) {
             $row = mysql_fetch_array($res);
             if ($row['newsletter'] == "1") {
                 $this->isAbonNews = true;
             }
             if ($row['hidden'] == "0") {
                 $this->isAbonAlert = true;
             }
         }
     }
     $content = $this->getEspacePerso();
     if ($_GET["debug"]) {
         $this->getDebug();
     }
     return $this->pi_wrapInBaseClass($content);
 }
 /**
  * Plug-in pour modification du mot de passe pour CAS
  */
 function main($content, $conf)
 {
     $this->conf = $conf;
     $this->pi_setPiVarDefaults();
     $this->pi_USER_INT_obj = 1;
     // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
     $this->pi_loadLL();
     session_start();
     $content = '';
     if (!isset($this->piVars["action"])) {
         $content = $this->getFormulaireVide();
     } else {
         if (isset($this->piVars["action"]) && $this->piVars["action"] == "insert") {
             if ($this->piVars["passwd_old"] == "" || $this->piVars["login"] == "" || $this->piVars["passwd1"] == "" || $this->piVars["passwd2"] == "") {
                 $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_missing_field")) . '<br/></h3>';
                 $content .= $this->getFormulaireVide();
             } else {
                 if (strlen($this->piVars["passwd1"]) < 6 || strlen($this->piVars["login"]) < 6) {
                     $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_min_field")) . '<br/></h3>';
                     $content .= $this->getFormulaireVide();
                 } else {
                     if ($this->piVars["passwd1"] != $this->piVars["passwd2"]) {
                         $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_passwd_not_match")) . '<br/></h3>';
                         $content .= $this->getFormulaireVide();
                     } else {
                         $param = array("in0" => $this->piVars["login"], "in1" => null);
                         $ws = new WebservicesCompte($this->typeExecution);
                         if (!$ws->connectIdent()) {
                             $content = "ERROR:" . $ws->getErrorMessage();
                             return $content;
                         }
                         $personne = $ws->getPersonneByLogin($param)->out;
                         /**
                          * Si ancien mot de passe saisi == mot de passe BDD alors on traite la demande
                          */
                         //print_r($personne);
                         $old_md5 = "{MD5}" . base64_encode(mhash(MHASH_MD5, $this->piVars["passwd_old"]));
                         $new_md5 = "{MD5}" . base64_encode(mhash(MHASH_MD5, $this->piVars["passwd1"]));
                         //echo "CID:".$personne["findPersonneByLoginReturn"]["password"]."<br/>";
                         //echo "portail:".$old_md5."<br/>";
                         if ($personne->password == $old_md5) {
                             $paramUpdate = array("in0" => $this->piVars["login"], "in1" => $new_md5, "in2" => null);
                             $wsUpdate = new WebservicesCompte($this->typeExecution);
                             if (!$wsUpdate->connectServices()) {
                                 $content = "ERROR:" . $ws->getErrorMessage();
                             } else {
                                 $result = $wsUpdate->updateCompte($paramUpdate)->out;
                                 if ($result == "0" || $result == "") {
                                     $this->sendMail($personne->coordonnees->email, $personne, $this->piVars["passwd1"]);
                                     $content = $this->success();
                                 } else {
                                     if ($result == "1947") {
                                         $content = $this->errorLoginExiste();
                                     } else {
                                         if ($result == "1946") {
                                             $content = "ERREUR SERVEUR<br/>";
                                             /*$content.="--------TRACE-------<br/>";
                                             		$content.="login:"******"login"]."<br/>";
                                             		$content.="passwd:".$this->piVars["passwd1"]."<br/>";
                                             		$content.="md5".$new_md5."<br/>";
                                             		$content.="resultat du WS:".$result["createCompteCasForPortailReturn"];*/
                                         }
                                     }
                                 }
                             }
                         } else {
                             $content = $this->errorLoginExiste();
                         }
                     }
                 }
             }
         } else {
             $content = "<h1>error</h1>";
         }
     }
     return $this->pi_wrapInBaseClass($content);
 }
 /** recupere les infos de la personne par WS */
 function getPersInfos()
 {
     if (isset($_SESSION["portalId"]) && $_SESSION["portalId"] != "" && !$this->modtestPID) {
         //$userId ="etalonnier";//pignol";//"etalonnier";//"faible";
         //debug($this->typeExecution);
         //debug($_SESSION["portalId"]);
         $param = array("in0" => $_SESSION["portalId"], "in1" => "");
         $ws = new WebservicesCompte($this->typeExecution);
         if (!$ws->connectIdent()) {
             $content = "ERROR:" . $ws->getErrorMessage();
             $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
             return $content;
         } else {
             $this->personne = $ws->getPersonneByLogin($param)->out;
             /*				$error=$ws->getErrorMessage();
             				debug ($error);
             				debug ($this->personne);*/
         }
     } else {
         $this->personne = new personneBidon();
         if ($this->modtestPID) {
             $_SESSION["portalId"] = "vmaury";
             $this->personne->prenom = "Vincent";
             $this->personne->nom = "MAURY";
             /*				$this->personne["adresse"]["adresse"]="7 rue de l'abbatiale";
             				$this->personne["adresse"]["complementAdresse"]="Le bourg d'arnac";
             				$this->personne["adresse"]["commune"]["codePostal"]="19230";
             				$this->personne["adresse"]["commune"]["libelle"]="POMPADOUR";
             				$this->personne["coordonnees"]["email"]="*****@*****.**";*/
         }
     }
 }
 /**
  * Plug-in pour creation de comptes CAS
  */
 function main($content, $conf)
 {
     $this->conf = $conf;
     $this->pi_setPiVarDefaults();
     $this->pi_USER_INT_obj = 1;
     // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
     $this->pi_loadLL();
     $this->ldapParam = array('server' => "10.211.162.20", 'port' => "10389", 'basedn' => "ou=utilisateurs,dc=haras-nationaux-dev,dc=fr");
     session_start();
     $content = '';
     if (!isset($this->piVars["action"])) {
         $content = $this->getFormulaireVide();
     } else {
         if (isset($this->piVars["action"]) && $this->piVars["action"] == "insert") {
             if (!$this->checkLogin($this->piVars["login"])) {
                 $content = '<h3>' . nl2br(htmlspecialchars($this->pi_getLL("error_login_format"))) . '<br/></h3>';
                 $content .= $this->getFormulaireVide();
                 return $this->pi_wrapInBaseClass($content);
             }
             if ($this->piVars["action"] == "" || $this->piVars["login"] == "" || $this->piVars["passwd1"] == "" || $this->piVars["passwd2"] == "") {
                 $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_missing_field")) . '<br/></h3>';
                 $content .= $this->getFormulaireVide();
             } else {
                 if (!$this->checkLogin($this->piVars["login"])) {
                     $content = '<h3>' . nl2br(htmlspecialchars($this->pi_getLL("error_login_format"))) . '<br/></h3>';
                     $content .= $this->getFormulaireVide();
                 } else {
                     if (strlen($this->piVars["passwd1"]) < 6 || strlen($this->piVars["login"]) < 6) {
                         $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_min_field")) . '<br/></h3>';
                         $content .= $this->getFormulaireVide();
                     } else {
                         if ($this->piVars["passwd1"] != $this->piVars["passwd2"]) {
                             $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_passwd_not_match")) . '<br/></h3>';
                             $content .= $this->getFormulaireVide();
                         } else {
                             $ws = new WebservicesCompte($this->typeExecution);
                             if (!$ws->connectServices()) {
                                 $content = "ERROR:" . $ws->getErrorMessage();
                             } else {
                                 if ($this->loginExistinLdap($this->piVars["login"])) {
                                     $content = $this->errorLoginExiste();
                                 } else {
                                     $md5 = "{MD5}" . base64_encode(mhash(MHASH_MD5, $this->piVars["passwd1"]));
                                     //$md5 = $this->piVars["passwd1"];
                                     $param = array("in0" => $this->piVars["login"], "in1" => $md5, "in2" => "");
                                     $result = $ws->createCompte($param)->out;
                                     if ($ws->getErrorMessage() != "") {
                                         $content = '<font color="red">' . $ws->getErrorMessage . '</font><br/>';
                                     }
                                     if ($result == "0" || $result == "") {
                                         $content = $this->success();
                                     } else {
                                         if ($result == "1945") {
                                             $content = $this->errorLoginExiste();
                                         } else {
                                             if ($result == "1944") {
                                                 $content = "ERREUR SERVEUR LOGIN ET OU MOT DE PASSE VIDENT<br/>";
                                                 /*$content.="--------TRACE-------<br/>";
                                                 		$content.="login:"******"login"]."<br/>";
                                                 		$content.="passwd:".$this->piVars["passwd1"]."<br/>";
                                                 		$content.="passwd_md5:".$md5."<br/>";
                                                 		$content.="resultat du WS:".$result["createCompteCasForPortailReturn"];*/
                                             } else {
                                                 $content = "ERREUR INCONNUE" . $result . ":<br/>";
                                                 /*$content.="--------TRACE-------<br/>";
                                                 		$content.="login:"******"login"]."<br/>";
                                                 		$content.="passwd:".$this->piVars["passwd1"]."<br/>";
                                                 		$content.="passwd_md5:".$md5."<br/>";
                                                 		$content.="resultat du WS:".$result["createCompteCasForPortailReturn"];*/
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $content = "<h1>error</h1>";
         }
     }
     return $this->pi_wrapInBaseClass($content);
 }
 /**
  * methode de creation de l'architecture de WebServices
  */
 function dolLaodServices()
 {
     $param = array("in0" => $this->userId, "in1" => "");
     $ws = new WebservicesCompte($this->typeExecution);
     if (!$ws->connectIdent()) {
         $content = "ERROR:" . $ws->getErrorMessage();
         $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
         return $content;
     }
     $this->personne = $ws->getPersonneByLogin($param)->out;
     //print_r($this->personne);
     if ($ws->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION PERSONNE CID (WS:findPersonneByLogin) :" . $ws->getErrorMessage() . "</font><br/>";
     }
     /**
      * recuperation du nombre de naissance, de lieux de detention
      */
     /*$paramCid = array (
     			"login" => $this->userId,
     			"ctx" => null
     		);*/
     $paramCid = array("login" => $this->userId, "ctx" => "");
     $wsCid = new WebservicesCompte($this->typeExecution);
     if (!$wsCid->connectCid()) {
         //$content="ERROR:".$wsCid->getErrorMessage();
         $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
         return $content;
     }
     $this->nbreNaissance = $wsCid->getNbrNaissanceAnneeEnCours4User($paramCid)->getNbrNaissanceAnneeEnCoursReturn;
     if ($wsCid->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION NOMBRE DE NAISSANCE CID (WS:getNbrNaissanceAnneeEnCours):" . $wsCid->getErrorMessage() . "</font><br/>";
     }
     $this->nbreLieudetention = $wsCid->getNbrLieuDetention4User($paramCid)->getNbrLieuDetentionReturn;
     if ($wsCid->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION NOMBRE LIEU DE DETENTION CID (WS:getNbrLieuDetention):" . $wsCid->getErrorMessage() . "</font><br/>";
     }
     $this->nbreChevaux = $wsCid->getNbrChevaux4User($paramCid)->getNbrChevauxReturn;
     if ($wsCid->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION NOMBRE DE CHEVAUX CID (WS:getNbrChevaux):" . $wsCid->getErrorMessage() . "</font><br/>";
     }
     /**
      * recuperation du nombre de factures et le montant total
      */
     if ($this->personne->key->numeroPersonne != "") {
         $paramPsi[] = $this->personne->key->numeroPersonne;
         $paramPsi[] = $this->personne->key->numeroOrdreAdresse;
         $wsPsi = new WebservicesCompte($this->typeExecution);
         if (!$wsPsi->connectPsi()) {
             //$content="ERROR:".$wsPsi->getErrorMessage();
             $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
             return $content;
         } else {
             //Nombre de factures
             $this->nbreFactures = $wsPsi->getNbrFactureARegler4User($paramPsi);
             $this->montantFactures = $wsPsi->getMontantFactureARegler4User($paramPsi);
         }
     }
     /**
      * Recup des centres tech du departement
      */
     if ($this->personne->adresse->commune->codePostal != "" && $this->personne->adresse->commune->codePostal > 0) {
         $ws = new WebservicesAccess($this->typeExecution);
         if ($ws->connect()) {
             $objTransfert = new ObjectTransfertWS();
             $objTransfert->setKey("codeDepartement");
             $objTransfert->setValue(substr($this->personne->adresse->commune->codePostal, 0, 2));
             $paramCT[] = $objTransfert;
             $result = $ws->getCentresTEchniques($paramCT);
             //if(!$result && $ws->getErrorMessage()!="") echo "[error resultat:]".$ws->getErrorMessage();
             /**
              * Calcul du centre le plus proche
              */
             $precTot = 10000000000;
             foreach ($result as $centre) {
                 if ($centre["codePostal"] > $this->personne->adresse->commune->codePostal) {
                     $result = $centre["codePostal"] - $this->personne->adresse->commune->codePostal;
                 } else {
                     $result = $this->personne->adresse->commune->codePostal - $centre["codePostal"];
                 }
                 if ($result < $precTot) {
                     $precTot = $result;
                     $this->ct = $centre;
                 }
             }
         }
     }
     /**
      * On regarde si l'utilisateur est abonne aux news et alertes
      */
     if ($this->personne->coordonnees->email != "") {
         $query = "SELECT * FROM tx_fabformmail_abonne where email='" . $this->personne->coordonnees->email . "'";
         $res = mysql(TYPO3_db, $query) or die("req invalide : {$query}");
         if (mysql_num_rows($res) > 0) {
             $row = mysql_fetch_array($res);
             if ($row['newsletter'] == "1") {
                 $this->isAbonNews = true;
             }
             if ($row['hidden'] == "0") {
                 $this->isAbonAlert = true;
             }
         }
     }
     /**
      * chargement des infos liees a l'etalonnier'
      */
     if ($this->personne->profil->id == 3) {
         $wsDPS = new WebservicesCompte($this->typeExecution);
         if ($wsDPS->connectDPS()) {
             $paramDPS = array();
             if ($this->typeExecution == "dev" || $this->typeExecution == "dev_ext") {
                 $paramDPS = array("serv" => "DEV", "nuPerso" => $this->personne->key->numeroPersonne, "anMonte" => date("Y"));
             } else {
                 $paramDPS = array("serv" => "PROD", "nuPerso" => $this->personne->key->numeroPersonne, "anMonte" => date("Y"));
             }
             $return = $wsDPS->getNbrSurPlace($paramDPS);
             $this->nombreEtalonSaillie = isset($return->getNbSurPlaceReturn) && $return->getNbSurPlaceReturn != "" ? $return->getNbSurPlaceReturn : 0;
             $return = $wsDPS->getNbrIA($paramDPS);
             $this->nombreEtalonSaillieIA = isset($return->getNbIAReturn) && $return->getNbIAReturn != "" ? $return->getNbIAReturn : 0;
         }
     }
 }
 /**
  * Plug-in pour modification du mot de passe pour CAS
  */
 function main($content, $conf)
 {
     $this->conf = $conf;
     $this->pi_setPiVarDefaults();
     $this->pi_USER_INT_obj = 1;
     // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
     $this->pi_loadLL();
     $content = "";
     if (!isset($this->piVars["action"])) {
         $content = $this->getFormulaireVide();
     } else {
         if (isset($this->piVars["action"]) && $this->piVars["action"] == "calcul") {
             if ($this->piVars["login"] == "") {
                 $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_missing_field")) . '<br/></h3>';
                 $content .= $this->getFormulaireVide();
             }
             if (strlen($this->piVars["login"]) < 5) {
                 $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_min_field")) . '<br/></h3>';
                 $content .= $this->getFormulaireVide();
             } else {
                 $param = array("in0" => $this->piVars["login"], "in1" => null);
                 $ws = new WebservicesCompte($this->typeExecution);
                 if (!$ws->connectIdent()) {
                     $content = "ERROR:" . $ws->getErrorMessage();
                     return $content;
                 }
                 $personne = $ws->getPersonneByLogin($param)->out;
                 if ($personne == "" || $personne == null) {
                     $content = $this->errorLoginExiste();
                 } else {
                     if ($personne->coordonnees->email == "") {
                         $content = $this->errorMailExiste();
                     } else {
                         $pwd = $this->calculPassword();
                         $md5 = "{MD5}" . base64_encode(mhash(MHASH_MD5, $pwd));
                         /**
                          * Mise a jour du compte
                          */
                         $paramUpdate = array("in0" => $personne->login, "in1" => $md5, "in2" => null);
                         $wsUpdate = new WebservicesCompte($this->typeExecution);
                         if (!$wsUpdate->connectServices()) {
                             $content = "ERROR:" . $ws->getErrorMessage();
                         } else {
                             $result = $wsUpdate->updateCompte($paramUpdate)->out;
                             if ($result == "0") {
                                 $this->sendMail($personne->coordonnees->email, $personne, $pwd);
                                 $content = $this->success();
                             } else {
                                 if ($result == "1947") {
                                     $content = $this->errorLoginExiste();
                                 } else {
                                     if ($result == "1946") {
                                         $content = "ERREUR SERVEUR<br/>";
                                         $content .= "login:"******"<br/>";
                                         $content .= "--------TRACE-------<br/>";
                                         $content .= "passwd:" . $pwd . "<br/>";
                                         $content .= "resultat du WS:" . $result;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $this->pi_wrapInBaseClass($content);
 }