function indexAction() { $this->metas(array('DC.Title' => 'Administration')); $this->actions->append("Paramètres du site", array('action' => 'parametres')); $this->view->indicateurs = $m = new Wtk_Table_Model('label', 'url', 'compteur', 'level'); $config = Zend_Registry::get('config'); $m->append('Version', null, Strass_Version::PROJET, array('version-produit', 'notice')); $m->append('Version des données', null, Strass_Version::dataCurrent(), array('version-data', strass_admin_count_level(Strass_Version::DATA - Strass_Version::dataCurrent(), 1, 1))); $m->append('Association', null, strtoupper($config->system->association), 'notice'); $t = new Inscriptions(); $count = $t->countRows(); $m->append("Inscriptions à valider", $this->_helper->Url('valider', 'membres'), $count, strass_admin_count_level($count, 1, 5)); $t = new Unites(); $count = $t->countRows(); $m->append("Unités", $this->_helper->Url('unites'), $count, strass_admin_count_level(0 - $count, 0, 0)); $t = new Individus(); $count = $t->countRows(); $m->append("Fiches d'individu", $this->_helper->Url('index', 'individus'), $count, 'notice'); $t = new Users(); $count = $t->countRows(); $m->append("Membres", $this->_helper->Url('index', 'individus', null, array('filtre' => 'membres')), $count, 'notice'); $t = new Citation(); $count = $t->countRows(); $m->append("Citations", $this->_helper->Url('index', 'citation'), $count, 'notice'); $this->view->log = $m = new Wtk_Table_Model('date', 'level', 'logger', 'label', 'url', 'prenom-nom', 'fiche', 'detail-url'); $t = new Logs(); $events = $t->fetchAll($t->select()->order('date DESC')->limit(20)); foreach ($events as $e) { $url = $this->_helper->Url('event', null, null, array('id' => $e->id)); $u = $e->findParentUsers(); if ($u) { $i = $u->findParentIndividus(); $pn = $i->getFullname(); $fiche = $this->_helper->Url('fiche', 'individus', null, array('individu' => $i->slug)); } else { $pn = 'Visiteur'; $fiche = null; } $m->append($e->date, strtolower($e->level), $e->logger, $e->message, $e->url, $pn, $fiche, $url); } $this->view->connexions = $m = new Wtk_Table_Model('date', 'prenom-nom', 'fiche'); $t = new Users(); $users = $t->fetchAll($t->select()->where('last_login')->order('last_login DESC')->limit(8)); foreach ($users as $u) { $i = $u->findParentIndividus(); $m->append($u->last_login, $i->getFullname(false, false), $this->_helper->Url('fiche', 'individus', null, array('individu' => $i->slug))); } }
function direct($throw = true) { $slug = $this->getRequest()->getParam('individu'); $t = new Individus(); try { $individu = $t->findBySlug($slug); } catch (Strass_Db_Table_NotFound $e) { $adresse = $this->getRequest()->getParam('adresse'); try { $individu = $t->findByEMail($adresse); } catch (Strass_Db_Table_NotFound $e) { if ($throw) { throw new Strass_Controller_Action_Exception_NotFound("Individu " . $slug . " inconnu."); } else { return null; } } } $this->setBranche($individu); return $individu; }
function indexAction() { $this->metas(array('DC.Title' => "Annuaire")); $this->assert(null, 'membres', 'voir', "Accès réservé aux membres"); $this->view->recherche = $m = new Wtk_Form_Model('recherche'); $m->addString('recherche', 'Recherche'); $m->addNewSubmission('chercher', 'Chercher', null, Wtk_Form_Model_Submission::METHOD_GET); $t = new Individus(); if ($m->validate()) { $s = $t->selectSearch($m->recherche); } else { $s = $t->selectAll(); } $filtre = $this->_getParam('filtre'); switch ($filtre) { case 'actifs': $s->join('appartenance', 'appartenance.individu = individu.id AND appartenance.fin IS NULL', array()); break; case 'anciens': $s->joinLeft('appartenance', 'appartenance.individu = individu.id AND appartenance.fin IS NULL', array())->where('appartenance.id IS NULL'); break; case 'sachem': $s->where("coalesce(individu.totem, '') IS NOT ''"); break; case 'membres': $s->join('user', 'user.individu = individu.id', array()); break; case 'admins': $s->join('user', 'user.individu = individu.id', array())->where('user.admin'); break; default: case 'tous': $filtre = 'tous'; break; } $this->view->filtre = $filtre; $this->view->individus = new Strass_Pages_Model_Rowset($s, 20, $this->_getParam('page')); }
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'); } } }
function findCandidats($annee) { $t = new Individus(); $db = $t->getAdapter(); $s = $t->select()->setIntegrityCheck(false)->distinct()->from('individu')->join('unite_type', $db->quoteInto("unite_type.id = ?\n", intval($this->type)), array())->joinLeft('appartenance', $db->quoteInto('appartenance.individu = individu.id AND appartenance.unite = ?', $this->id) . ' AND ' . '(' . ('appartenance.fin IS NULL AND ' . $db->quoteInto("appartenance.debut < ?", Strass_Controller_Action_Helper_Annee::dateFin($annee))) . ')', array())->where('appartenance.id IS NULL')->where("unite_type.sexe IN ('m', individu.sexe)\n")->where("individu.naissance\n")->where("unite_type.age_min <= ? - individu.naissance - 1\n", $annee . '-8-01')->where("? - individu.naissance - 1 <= unite_type.age_max\n", $annee . '-8-01')->order('individu.nom', 'individu.prenom'); return $t->fetchAll($s); }
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'); } }
function findIndividus() { $t = new Individus(); $s = $t->select()->where('slug LIKE ?', wtk_strtoid($this->getFullname()) . '%'); return $t->fetchAll($s)->current(); }
function notifyChefs() { $t = new Individus(); $chefs = $t->findChefsRacines(); foreach ($chefs as $chef) { if ($chef->adelec && $chef->findUser()->send_mail) { $this->addBcc($chef->adelec, $chef->getFullName(false)); } } }
function findAuteur() { $t = new Individus(); $s = $t->select()->setIntegrityCheck(false)->from('individu')->join('commentaire', 'commentaire.auteur = individu.id', array())->join('article', 'article.commentaires = commentaire.id', array())->where('article.id = ?', $this->id); return $t->fetchOne($s); }