Example #1
0
 private function registerUser($username, $data = NULL)
 {
     try {
         $gingerKey = sfConfig::get('app_portail_ginger_key');
         if ($gingerKey != "abc") {
             $ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
             $cotisants = $ginger->getUser($username);
         } else {
             $cotisants = new stdClass();
             $cotisants->mail = $username . "@etu.utc.fr";
             $cotisants->prenom = "Le";
             $cotisants->nom = "Testeur";
             $cotisants->type = "etu";
         }
         if (!$data) {
             $data = new sfGuardUser();
         }
         $data->setUsername($username);
         $data->setEmailAddress($cotisants->mail);
         $data->setFirstName($cotisants->prenom);
         $data->setLastName($cotisants->nom);
         $data->setIsActive(true);
         $data->save();
         $profile = new Profile();
         $profile->setUser($data);
         $profile->setDomain($cotisants->type);
         $profile->save();
         return $data;
     } catch (\Ginger\Client\ApiException $ex) {
         $this->setFlash('error', "Il n'a pas été possible de vous identifier. Merci de contacter simde@assos.utc.fr en précisant votre login et le code d'erreur " . $ex->getCode() . ".");
     }
     return false;
 }
Example #2
0
 public function executeEdit(sfWebRequest $request)
 {
     if ($login = $request->getParameter("login")) {
         try {
             $ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
             $this->cotisant = $ginger->getUser($login);
             $this->cotisations = $ginger->getCotisations($login);
         } catch (\Ginger\Client\ApiException $ex) {
             if ($ex->getCode() == 404) {
                 $this->error = "Utilisateur non trouvé";
             } else {
                 $this->error = $ex->getCode() . " - " . $ex->getMessage();
             }
         }
         $this->formcotisation = new CotisantsCotiserForm();
         $this->formcotisation->setDefault('login', $login);
         if ($this->cotisant->is_cotisant) {
             $this->cotisant->is_cotisant_texte = "Oui";
             // On retire le champ montant
             $this->formcotisation->hideMontant();
         } else {
             $this->cotisant->is_cotisant_texte = "Non";
         }
     }
 }
Example #3
0
 private function isCotisant()
 {
     try {
         $ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
         $cotisant = $ginger->getUser($this->getUser()->getUsername());
         return $cotisant->is_cotisant;
     } catch (\Ginger\Client\ApiException $ex) {
         if ($ex->getCode() == 404) {
             $error = "Utilisateur non trouvé";
         } else {
             $error = $ex->getCode() . " - " . $ex->getMessage();
         }
         return false;
     }
 }