예제 #1
0
 function initAdmin()
 {
     extract($this->data['admin']);
     $i = new Individu();
     $i->prenom = $prenom;
     $i->nom = $nom;
     $i->sexe = $sexe;
     $i->adelec = $adelec;
     $i->naissance = $naissance;
     $i->slug = $i->getTable()->createSlug($i->getFullname());
     $i->save();
     $u = new User();
     $u->individu = $i->id;
     $u->username = $adelec;
     $u->password = Users::hashPassword($adelec, $motdepasse);
     $u->admin = true;
     $u->save();
     Zend_Registry::set('user', $u);
 }
예제 #2
0
 function testIndividuPng()
 {
     $o = new Individu();
     $o->slug = 'imagick-png';
     $o->storeImage(dirname(__FILE__) . '/images/transparente.png');
 }
예제 #3
0
 function validerAction()
 {
     $this->metas(array('DC.Title' => "Valider une inscription"));
     $this->branche->append("Inscriptions", array('action' => 'inscriptions', 'adelec' => null));
     $t = new Inscriptions();
     $this->assert(null, $t, 'valider', "Vous n'avez pas le droit de valider les inscriptions en attente.");
     $adelec = $this->_getParam('adelec');
     if ($adelec) {
         try {
             $ins = $t->findByEMail($adelec);
         } catch (Strass_Db_Table_NotFound $e) {
             $this->view->model = null;
             return;
         }
     } else {
         if (!($ins = $t->fetchAll()->current())) {
             $this->view->model = null;
             return;
         }
     }
     $this->view->individu = $ind = $ins->findIndividus();
     $this->view->inscription = $ins;
     $this->branche->append($ins->getFullname());
     $this->view->model = $m = new Wtk_Form_Model('valider');
     $i = $m->addString('prenom', 'Prénom', $ins->prenom);
     $i->setReadonly((bool) $ind);
     $m->addConstraintRequired($i);
     $i = $m->addString('nom', 'Nom', $ins->nom);
     $i->setReadonly((bool) $ind);
     $m->addConstraintRequired($i);
     if ($ind) {
         $enum = array($ind->id => "Oui, rattacher à " . $ind->getFullname(), '$$nouveau$$' => "Non, c'est un homonyme, créer une nouvelle fiche");
         $m->addEnum('fiche', null, $ind->id, $enum);
     }
     $m->addString('message', "Message à " . $ins->getFullname());
     $m->addNewSubmission('accepter', 'Accepter');
     $m->addNewSubmission('refuser', 'Spam !');
     if ($s = $m->validate()) {
         $tu = new Users();
         $ti = new Individus();
         $db = $ti->getAdapter();
         if ($s->id == 'accepter') {
             $creer = !$ind || $m->get('fiche') == '$$nouveau$$';
             if ($creer) {
                 $ind = new Individu();
                 $ind->slug = $ti->createSlug(wtk_strtoid($ins->getFullname()));
                 $ind->prenom = $m->prenom;
                 $ind->nom = $m->nom;
                 $ind->sexe = $ins->sexe;
                 $ind->naissance = $ins->naissance;
                 $ind->adelec = $ins->adelec;
             }
             $db->beginTransaction();
             try {
                 if ($creer) {
                     $ind->save();
                 }
                 $user = $ind->findUser();
                 if (!$user->isMember()) {
                     $user = new User();
                 }
                 $user->individu = $ind->id;
                 $user->username = $ins->adelec;
                 $user->password = $ins->password;
                 $user->save();
                 $mail = new Strass_Mail_InscriptionValide($user, $m->get('message'));
                 $mail->send();
                 $this->logger->info("Inscription acceptée", $this->_helper->Url('fiche', 'individus', null, array('individu' => $ind->slug)), (string) $ind);
                 $ins->delete();
                 $db->commit();
             } catch (Exception $e) {
                 $db->rollBack();
                 throw $e;
             }
             $this->_helper->Flash->info("Inscription acceptée");
         } else {
             $db->beginTransaction();
             try {
                 $this->logger->warn("Inscription de {$ins->adelec} refusée", $this->_helper->Url('inscriptions', 'membres', null, null, true));
                 $mail = new Strass_Mail_InscriptionRefus($ins, $m->get('message'));
                 $mail->send();
                 $ins->delete();
                 $db->commit();
             } catch (Exception $e) {
                 $db->rollBack();
                 throw $e;
             }
             $this->_helper->Flash->info("Inscription refusée");
         }
         if ($this->_getParam('adelec')) {
             $this->redirectSimple('inscriptions', 'membres', null, null, true);
         } else {
             $this->redirectSimple('valider');
         }
     }
 }
예제 #4
0
 function validate($annee, $pm, $data)
 {
     extract($data);
     $m = $pm->data;
     $u = $this->unite;
     $a = $annee;
     $t = new Appartenances();
     $tr = new Roles();
     $ti = new Individus();
     $db = $t->getAdapter();
     $db->beginTransaction();
     $tu = $u->findParentTypesUnite();
     try {
         if ($m->get('inscription/individu') == '$$nouveau$$') {
             $i = new Individu();
             $i->prenom = $m->get('fiche/prenom');
             $i->nom = $m->get('fiche/nom');
             $i->sexe = $m->get('fiche/sexe');
             $i->naissance = $a - $tu->age_min . '-01-01';
             $i->portable = $m->get('fiche/portable');
             $i->adelec = $m->get('fiche/adelec');
             $i->slug = $i->getTable()->createSlug(wtk_strtoid($i->getFullname(false, false)));
             $i->save();
         } else {
             $i = $ti->findOne($m->get('inscription/individu'));
             $app_active = $i->findInscriptionsActives()->current();
             if ($app_active) {
                 if ($m->get('cloture/clore')) {
                     $app_active->fin = $m->get('cloture/fin');
                     $app_active->save();
                 }
             }
         }
         if ($m->get('succession/succeder')) {
             $role = $m->get('inscription/role');
             list($role, $titre) = explode('__', $role);
             $r = $tr->findOne($role);
             $apps = $u->findFuturPredecesseurs($r, $titre);
             $app_predecesseur = $apps->current();
             if ($apps->count()) {
                 $app_predecesseur = $apps->current();
                 $app_predecesseur->fin = $m->get('succession/date');
                 $app_predecesseur->save();
             }
         }
         $app = new Appartient();
         $app->unite = $u->id;
         $app->individu = $i->id;
         $app->debut = $m->get('inscription/debut');
         list($role, $titre) = explode('__', $m->get('inscription/role'));
         $app->role = intval($role);
         $app->titre = $titre;
         if ($m->get('inscription/clore')) {
             $app->fin = $m->get('inscription/fin');
         }
         $app->save();
         $message = $i->getFullname(false, false) . " inscrit.";
         $this->controller->logger->info($message);
         $this->controller->_helper->Flash->info($message);
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
     if ($m->get('inscription/continuer')) {
         $this->controller->redirectSimple();
     } else {
         $this->controller->redirectSimple('effectifs');
     }
 }