コード例 #1
0
ファイル: sfUTCCASUser.class.php プロジェクト: TheoJD/portail
 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;
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: TheoJD/portail
 public function executeCotisation(sfWebRequest $request)
 {
     if ($login = $request->getParameter("login")) {
         if ($request->getParameter("type") == "Cotiser") {
             $debut = date("Y-m-d");
             $yearend = date("Y");
             if (date("m") > 8) {
                 $yearend++;
             }
             $fin = "{$yearend}-08-31";
             $montant = intval($request->getParameter("montant"));
             try {
                 $ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
                 $ginger->addCotisation($login, $debut, $fin, $montant);
             } catch (\Ginger\Client\ApiException $ex) {
                 $this->getUser()->setFlash('error', "Impossible d'enregistrer la cotisation : " . ($this->error = $ex->getCode() . " - " . $ex->getMessage()));
             }
         } else {
             if ($request->getParameter("type") == "Radier") {
                 //TODO
                 $this->getUser()->setFlash('error', "Fonctionnalité indisponible");
             }
         }
     }
     $this->redirect('cotisants/edit?login=' . $login);
 }
コード例 #3
0
ファイル: actions.class.php プロジェクト: TheoJD/portail
 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;
     }
 }