function editerAction() { $t = new Liens(); $this->assert(null, $t, 'editer', "Vous n'avez pas le droit d'éditer de liens"); $this->metas(array('DC.Title' => 'Éditer les liens')); $this->view->model = $m = new Wtk_Form_Model('liens'); $i = $m->addTable('liens', "Liens", array('url' => array('String', "URL"), 'nom' => array('String', 'Nom'), 'description' => array('String', 'Description'))); $lns = $t->fetchAll(); foreach ($lns as $lien) { $i->addRow($lien->toArray()); } $i->addRow(); $m->addNewSubmission('enregistrer', "Enregistrer"); if ($m->validate()) { $db = $t->getAdapter(); $db->beginTransaction(); try { $listes = $m->get('liens'); $db->query('DELETE FROM `lien`;'); foreach ($listes as $data) { if ($data['url']) { $t->insert($data); } } $this->logger->info("Liens édités"); $db->commit(); $this->redirectSimple('index', 'liens'); } catch (Exception $e) { $db->rollBack(); throw $e; } } }
function supprimerAction() { $p = $this->_helper->Photo(false); $this->metas(array('DC.Title' => 'Supprimer un commentaire')); $this->view->commentaire = $c = $this->_helper->Commentaire(); $this->assert(null, $c, 'editer', "Vous n'avez pas le droit de supprimer ce commentaire !"); $this->view->model = $m = new Wtk_Form_Model('supprimer'); $m->addNewSubmission('continuer', 'Continuer'); $m->addBool('confirmer', "Je confirmer la suppression", false); if ($m->validate()) { if ($m->get('confirmer')) { if ($p) { $url = $this->_helper->Url('voir', 'photos', null, array('message' => null)); } else { $url; } $db = $c->getTable()->getAdapter(); $db->beginTransaction(); try { $c->delete(); $this->_helper->Flash->info("Commentaire supprimé"); $this->logger->info('Commentaire supprimé', $url); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } } if ($p) { $this->redirectSimple('voir', 'photos', null, array('message' => null)); } } }
function supprimerAction() { $tc = new Citation(); $this->assert(null, $tc, 'supprimer', "Vous n'avez pas le droit de supprimer les citations."); $this->view->citation = $citation = $tc->find($this->_getParam('citation'))->current(); $this->metas(array('DC.Title' => 'Supprimer une citation')); $this->view->model = $m = new Wtk_Form_Model('citation'); $m->addBool('confirmer', "Je confirme vouloir supprimer cette citation."); $m->addNewSubmission('continuer', 'continuer'); if ($m->validate()) { if ($m->get('confirmer')) { $db = $tc->getAdapter(); $db->beginTransaction(); try { $this->logger->warn("Citation de " . $citation->auteur . " supprimée", array('controller' => 'citation')); $citation->delete(); $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } } $this->redirectSimple('index', null, null, null, true); } }
function createModel($annee) { $u = $this->unite; $a = $annee; $m = new Wtk_Form_Model('inscrire'); /* Pagination dans la pagination :-) */ $pm = new Wtk_Pages_Model_Form($m); /* Sélection de l'individu à inscrire */ $g = $m->addGroup('inscription'); $candidats = $u->findCandidats($a); $enum = array(); $enum['$$nouveau$$'] = 'Inscrire un nouveau'; foreach ($candidats as $candidat) { $enum[$candidat->id] = $candidat->getFullname(false, false); } $i = $g->addEnum('individu', 'Individu', null, $enum); $m->addConstraintRequired($i); $roles = $u->findParentTypesUnite()->findRoles(); $enum = array(); foreach ($roles as $role) { $enum[$role->id . '__'] = $role->titre; foreach ($role->findTitres() as $titre) { $enum[$role->id . '__' . $titre->nom] = $titre->nom; } } $default = $u->findRolesCandidats($a)->current(); $g->addEnum('role', 'Rôle', $default ? $default->id . '__' : end(array_keys($enum)), $enum); list($debut, $fin) = $this->calculerDates($annee); $g->addDate('debut', 'Début', $debut); $i0 = $g->addBool('clore', 'Se termine le', false); $i1 = $g->addDate('fin', 'Fin', $fin); $m->addConstraintDepends($i1, $i0); $g->addBool('continuer', "J'ai d'autres inscriptions à enregistrer", false); /* Enregistrement d'un nouvel individu */ $g = $m->addGroup('fiche'); $m->addConstraintRequired($g->addString('prenom', 'Prénom')); $m->addConstraintRequired($g->addString('nom', 'Nom')); $tu = $u->findParentTypesUnite(); if ($tu->sexe == 'm') { $g->addEnum('sexe', 'Sexe', null, array('h' => 'Masculin', 'f' => 'Féminin')); } else { $g->addString('sexe', null, $tu->sexe)->setReadonly(); } $g->addString('portable', "Mobile"); $g->addString('adelec', "Adélec"); /* Clore une inscription active */ $g = $m->addGroup('cloture'); $g->addBool('clore', "Ne l'est plus depuis", true); $g->addDate('fin', "Fin", $debut); /* Proposer la succession pour les chefs d'unité et les titres */ $g = $m->addGroup('succession'); $g->addBool('succeder', "a passé le flambeau le", false); $g->addDate('date', "Succession", $debut); return $pm; }
function fetch($annee = NULL) { if (!$this->activite) { return array('activites' => $this->unite->findActivites($annee)); } else { $this->controller->assert(null, $this->activite, 'envoyer-photo', "Vous n'avez pas le droit d'envoyer de photo de " . $this->activite->getIntituleComplet() . "."); } $m = new Wtk_Form_Model('envoyer'); $i = $m->addString('titre', 'Titre'); $m->addConstraintRequired($i); $m->addFile('photo', "Photo"); $m->addString('commentaire', 'Votre commentaire'); $m->addBool('envoyer', "J'ai d'autres photos à envoyer", true); $m->addNewSubmission('envoyer', "Envoyer"); $t = new Photos(); if ($m->validate()) { $p = new Photo(); $p->titre = $m->titre; $p->slug = $t->createSlug(wtk_strtoid($m->titre)); $p->activite = $this->activite->id; $action = $m->envoyer ? 'envoyer' : 'consulter'; $c = new Commentaire(); $c->auteur = Zend_Registry::get('individu')->id; $c->message = $m->commentaire; $db = $t->getAdapter(); $db->beginTransaction(); try { $c->save(); $p->commentaires = $c->id; $p->save(); $i = $m->getInstance('photo'); if ($i->isUploaded()) { $tmp = $i->getTempFilename(); $p->storeFile($tmp); } $url = $this->controller->_helper->Url('voir', 'photos', null, array('photo' => $p->slug), true); $this->controller->logger->info("Photo envoyée", $url); foreach ($this->activite->findUnitesParticipantesExplicites() as $u) { $ident = new Identification(); $ident->photo = $p->id; $ident->unite = $u->id; $ident->save(); $this->controller->logger->info("Unité identifiée sur une photo", $url); } $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->controller->_helper->Flash->info("Photo envoyée"); $this->controller->redirectSimple($action, null, null, array('album' => $this->activite->slug)); } $photos = $this->activite->findPhotos($t->select()->order('date')); return array('unite' => $this->unite, 'annee' => $annee, 'model' => $m, 'activite' => $this->activite, 'photos' => $photos); }
function fetch($annee = NULL) { $ta = new Activites(); $as = $ta->findByAnnee($annee); $activite = null; if ($as->count() == 1) { $activite = $as->current(); $this->controller->_helper->Album->setBranche($activite); } $m = new Wtk_Form_Model('editer'); $i = $m->addString('titre', 'Titre', $this->photo->titre); $m->addConstraintRequired($i); $enum = array(); foreach ($as as $a) { if ($this->controller->assert(null, $a, 'editer-photo')) { $enum[$a->id] = $a->getIntituleComplet(); } } if ($enum) { $m->addEnum('activite', "Activité", $this->photo->activite, $enum); } $m->addFile('photo', "Photo"); $m->addBool('promouvoir', "Promouvoir en page d'accueil", $this->photo->promotion); $m->addNewSubmission('enregistrer', "Enregistrer"); if ($m->validate()) { $t = $this->photo->getTable(); $db = $t->getAdapter(); $db->beginTransaction(); try { $i = $m->getInstance('photo'); if ($i->isUploaded()) { $tmp = $i->getTempFilename(); $this->photo->storeFile($tmp); } try { $this->photo->activite = $m->activite; } catch (Exception $e) { } $this->photo->titre = $m->titre; $this->photo->slug = $t->createSlug($m->titre, $this->photo->slug); $this->photo->promotion = (int) $m->promouvoir; $this->photo->save(); $this->controller->_helper->Flash->info("Photo éditée"); $this->controller->logger->info("Photo éditée", $this->controller->_helper->Url('voir', null, null, array('photo' => $this->photo->slug))); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->controller->redirectSimple('voir', null, null, array('photo' => $this->photo->slug)); } return array('unite' => $this->unite, 'annee' => $annee, 'form_model' => $m, 'activite' => $activite, 'photo' => $this->photo); }
function editerAction() { $page = $this->_getParam('page'); if (!$page) { throw new Strass_Controller_Action_Exception("Aucune page à éditer"); } $this->view->statique = $page = new Statique($page); $this->metas(array('DC.Title' => "Éditer " . $page->getTitle())); $this->branche->append($page->getTitle(), array('action' => 'index')); $this->branche->append('Éditer'); $this->assert(null, $page, 'editer', "Vous n'avez pas le droit d'éditer cette page"); $this->view->model = $m = new Wtk_Form_Model('editer'); $m->addNewSubmission('enregistrer', 'Enregistrer'); $m->addString('wiki', 'Texte', $page->read()); if ($m->validate()) { $page->write($m->get('wiki')); $this->redirectSimple('index'); } }
public function routeStartup() { $this->initAcl(); $config = Zend_Registry::get('config'); try { $lifetime = $config->system->duree_connexion; Zend_Session::setOptions(array('cookie_path' => '/', 'cookie_lifetime' => $lifetime, 'cache_expire' => $lifetime)); } catch (Exception $e) { error_log((string) $e); } // models formulaire $m = new Wtk_Form_Model('login'); $i = $m->addString('username', "Courriel"); $m->addConstraintRequired($i); $i = $m->addString('password', "Mot de passe"); $m->addConstraintRequired($i); $m->addNewSubmission('login', "Identifier"); Zend_Registry::set('login_model', $m); $m = new Wtk_Form_Model('logout'); $m->addNewSubmission('logout', "Déconnecter"); Zend_Registry::set('logout_model', $m); $db = Zend_Registry::get('db'); // initialise les méthodes d'authentifications. $auth = Zend_Auth::getInstance(); // DB AUTH $this->db = new Strass_Auth_Adapter_DbTable($db, 'user', 'username', 'password'); // HTTP_AUTH $config = array('accept_schemes' => 'digest', 'realm' => $config->system->realm, 'digest_domains' => '/', 'nonce_timeout' => $config->system->duree_connexion); $this->http = new Zend_Auth_Adapter_Http($config); $resolver = new Strass_Auth_Adapter_Http_Resolver_DbTable($db, 'user', 'username', 'password'); $this->http->setDigestResolver($resolver); // SUDO AUTH $this->sudo = new Strass_Auth_Adapter_Sudo(); $this->sudo(); $this->form(); $this->getUser(); }
function supprimerAction() { $this->view->doc = $d = $this->_helper->Document(); $this->assert(null, $d, 'supprimer', "Vous n'avez pas le droit de supprimer ce document."); try { $this->view->unite = $u = $d->findUnite(); $urlArgs = array('index', 'documents', null, array('unite' => $u->slug), true); } catch (Strass_Db_Table_NotFound $e) { $urlArgs = array('index', 'documents', null, null, true); } $this->view->model = $m = new Wtk_Form_Model('supprimer'); $m->addBool('confirmer', "Je confirme la suppression de ce document", false); $m->addNewSubmission('supprimer', 'Supprimer'); if ($m->validate()) { $db = $d->getTable()->getAdapter(); $db->beginTransaction(); try { $message = $d->titre . " supprimé"; $d->delete(); $this->logger->warn($message, call_user_func_array(array($this->_helper, 'Url'), $urlArgs)); $this->_helper->Flash->info($message); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } call_user_func_array(array($this, 'redirectSimple'), $urlArgs); } }
function supprimerAction() { $this->view->article = $a = $this->_helper->Article(); $this->assert(null, $a, 'supprimer', "Vous n'avez pas le droit de supprimer cet article"); $this->metas(array('DC.Title' => "Supprimer " . $a->titre)); $j = $a->findParentJournaux(); $this->view->model = $m = new Wtk_Form_Model('supprimer'); $m->addBool('confirmer', "Je confirme la suppression de l'article " . $a->titre . ".", false); $m->addNewSubmission('continuer', "Continuer"); if ($m->validate()) { if ($m->confirmer) { $action = $a->public ? 'index' : 'brouillons'; $db = $a->getTable()->getAdapter(); $db->beginTransaction(); try { $a->delete(); $this->logger->info("Article supprimé", $this->_helper->Url('index', 'journaux', null, array('journal' => $j->slug), true)); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple($action, 'journaux', null, array('journal' => $j->slug), true); } else { $this->redirectSimple('consulter'); } } }
function indexAction() { $m = new Wtk_Form_Model('installation'); $g = $m->addGroup('site', "Le site"); $i = $g->addEnum('association', "Association", null, self::$associations); $m->addConstraintRequired($i); $g = $m->addGroup('admin', "Votre compte"); $i = $g->addString('prenom', "Votre prénom"); $m->addConstraintRequired($i); $i = $g->addString('nom', "Votre nom"); $m->addConstraintRequired($i); $i = $g->addEnum('sexe', "Sexe", null, array('h' => 'Masculin', 'f' => 'Féminin')); $m->addConstraintRequired($i); $i = $g->addDate('naissance', "Date de naissance", 0); $m->addConstraintRequired($i); $i = $g->addString('adelec', "Adélec"); $m->addConstraintRequired($i); $i = $i0 = $g->addString('motdepasse', "Mot de passe"); $m->addConstraintRequired($i); $i = $i1 = $g->addString('confirmation', "Confirmation"); $m->addConstraintEqual($i1, $i0); $this->view->model = $pm = new Wtk_Pages_Model_Form($m); if ($pm->validate()) { $installer = new Strass_Installer($m->get()); $installer->run(); /* Autologin. Écrire dans la session l'identité de l'admin */ $t = new Users(); $admin = $t->findByUsername($m->get('admin/adelec')); $auth = Zend_Auth::getInstance(); $auth->getStorage()->write($admin->getIdentity()); $this->_redirect('/', array('prependBase' => false, 'exit' => true)); } }
function annulerAction() { $this->view->activite = $a = $this->_helper->Activite(); $this->metas(array('DC.Title' => 'Annuler ' . $a->getIntitule())); $this->assert(null, $a, 'annuler', "Vous n'avez pas le droit d'annuler cette activité"); $this->view->model = $m = new Wtk_Form_Model('annuler'); $m->addBool('confirmer', "Je confirme la destruction de toutes informations relative à " . "cette activité.", false); $m->addNewSubmission('continuer', 'Continuer'); if ($m->validate()) { if ($m->confirmer) { $db = $a->getTable()->getAdapter(); $db->beginTransaction(); try { $unite = $a->findUnitesParticipantesExplicites()->current(); $intitule = $a->getIntituleComplet(); $a->delete(); $this->logger->warn("Activité annulée", $this->_helper->Url('calendrier', 'activites', null, array('unite' => $unite->slug))); $this->_helper->Flash->info("Activité annulée"); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('calendrier', 'activites', null, array('unite' => $unite->slug)); } else { $this->redirectSimple('consulter', 'activites', null, array('activite' => $a->slug)); } } }
function supprimerAction() { $this->view->photo = $p = $this->_helper->Photo(); $a = $p->findParentActivites(); $this->assert(null, $p, 'supprimer', "Vous n'avez pas le droit de supprimer la photo " . $p->titre . "."); $this->metas(array('DC.Title' => "Supprimer " . $p->titre, 'DC.Subject' => 'photo,image', 'DC.Date.created' => $p->date)); $this->view->model = $m = new Wtk_Form_Model('supprimer'); $m->addBool('confirmer', "Je confirme la suppression de cette photo.", false); $m->addNewSubmission('continuer', 'Continuer'); if ($m->validate()) { if ($m->get('confirmer')) { $db = $p->getTable()->getAdapter(); $db->beginTransaction(); try { $p->delete(); $this->logger->warn("Photo supprimée", $this->_helper->Url('consulter', 'photos', null, array('album' => $a->slug), true)); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('consulter', null, null, array('album' => $a->slug, 'photo' => null)); } else { $this->redirectSimple('voir'); } } }
function parametresAction() { $moi = Zend_Registry::get('user'); $this->view->user = $user = $this->_helper->Membre($moi); $this->view->individu = $individu = $user->findParentIndividus(); $this->assert($moi, $user, 'parametres', "Vous n'avez pas le droit de modifier les paramètres de cet utilisateur."); $this->metas(array('DC.Title' => "Éditer l'utilisateur " . $user->username)); $autoedit = $moi->id == $user->id; $db = Zend_Registry::get('db'); /* Migration de l'identifiant */ if ($autoedit && $user->username != $individu->adelec) { $this->view->migrate = $m = new Wtk_Form_Model('migrate'); $m->addConstraintRequired($m->addString('motdepasse', 'Mot de passe')); $m->addNewSubmission('migrer', 'Migrer'); if ($m->validate()) { $db->beginTransaction(); try { if (!$user->testPassword($m->get('motdepasse'))) { throw new Wtk_Form_Model_Exception('Mot de passe erroné', $m->getInstance('motdepasse')); } $user->username = $individu->adelec; $user->setPassword($m->get('motdepasse')); $user->save(); $this->logger->info("Migration du compte", $this->_helper->Url('fiche', 'individus', null, array('individu' => $individu->slug))); $db->commit(); $auth = Zend_Auth::getInstance(); $id = $auth->getIdentity(); $id['username'] = $user->username; $auth->getStorage()->write($id); } catch (Wtk_Form_Model_Exception $e) { $db->rollBack(); $m->errors[] = $e; } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('fiche', 'individus', null, array('individu' => $individu->slug), true); } } /* Changement d'adélec */ if ($autoedit) { $this->view->adelec = $m = new Wtk_Form_Model('adelec'); $i = $m->addString('adelec', 'Adelec', $individu->adelec); $m->addConstraintRequired($i); $m->addConstraintEMail($i); $m->addConstraintRequired($m->addString('motdepasse', 'Mot de passe')); $m->addNewSubmission('enregistrer', 'Enregistrer'); if ($m->validate()) { $db->beginTransaction(); try { if (!$user->testPassword($m->get('motdepasse'))) { throw new Wtk_Form_Model_Exception('Mot de passe erroné', $m->getInstance('motdepasse')); } if ($user->username == $individu->adelec) { $user->username = $m->get('adelec'); $user->setPassword($m->get('motdepasse')); $user->save(); $auth = Zend_Auth::getInstance(); $id = $auth->getIdentity(); $id['username'] = $user->username; $auth->getStorage()->write($id); } $individu->adelec = $m->get('adelec'); $individu->save(); $this->logger->info("Changement d'adélec", $this->_helper->Url('fiche', 'individus', null, array('individu' => $individu->slug))); $db->commit(); } catch (Wtk_Form_Model_Exception $e) { $db->rollBack(); $m->errors[] = $e; } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('fiche', 'individus', null, array('individu' => $individu->slug), true); } } /* Changement de mot de passe */ $this->view->change = $m = new Wtk_Form_Model('chpass'); $g = $m->addGroup('mdp', "Change le mot de passe"); if (!$this->assert(null) || $autoedit) { $m->addConstraintRequired($g->addString('ancien', 'Ancien')); } $m->addConstraintRequired($g->addString('nouveau', 'Nouveau')); $m->addConstraintRequired($g->addString('confirmation', "Confirmation")); $m->addNewSubmission('valider', 'Valider'); if ($m->validate()) { $db->beginTransaction(); try { $mdp = $m->get('mdp'); if (array_key_exists('ancien', $mdp)) { if (!$user->testPassword($mdp['ancien'])) { throw new Wtk_Form_Model_Exception("Ancien mot de passe erroné.", $m->getInstance('mdp/ancien')); } } if ($mdp['nouveau'] != $mdp['confirmation']) { throw new Wtk_Form_Model_Exception("Le mot de passe de confirmation n'est pas identique " . "au nouveau."); } $user->setPassword($mdp['nouveau']); $user->save(); $this->logger->info("Mot de passe changé", $this->_helper->Url('fiche', 'individus', null, array('individu' => $individu->slug))); $db->commit(); } catch (Wtk_Form_Model_Exception $e) { $db->rollBack(); $m->errors[] = $e; } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('fiche', 'individus', null, array('individu' => $individu->slug), true); } /* Notifications */ $this->view->notifications = $m = new Wtk_Form_Model('notifications'); $m->addBool('send_mail', "Recevoir des notifications par mail", $user->send_mail); $m->addNewSubmission('valider', 'Valider'); if ($m->validate()) { $db->beginTransaction(); try { $user->send_mail = (bool) $m->get('send_mail'); $user->save(); $db->commit(); if ($user->send_mail) { $msg = "Notifications activées"; } else { $msg = "Notifications désactivées"; } $this->logger->info($msg, $this->_helper->Url('fiche', 'individus', null, array('individu' => $individu->slug))); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('fiche', 'individus', null, array('individu' => $individu->slug), true); } /* Promotion à l'administration */ if ($this->assert($moi, $user, 'admin') && !$autoedit) { $this->view->admin = $m = new Wtk_Form_Model('admin'); $m->addBool('admin', "Accorder tous les privilèges sur le site à " . $user->findParentIndividus()->getFullName(), $user->admin); $m->addNewSubmission('valider', 'Valider'); if ($m->validate()) { $db->beginTransaction(); try { $user->admin = $m->get('admin'); $user->save(); $db->commit(); $msg = $user->admin ? "Privilèges accordés" : "Privilèges refusés"; $this->logger->warn($msg, $this->_helper->Url('fiche', 'individus', null, array('individu' => $individu->slug))); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('fiche', 'individus', null, array('individu' => $individu->slug), true); } } }
function fetch($annee = NULL) { $u = $this->unite; $a = $annee; $m = new Wtk_Form_Model('prevoir'); $t = new Unites(); $enum = array(); foreach ($t->fetchAll() as $unite) { if ($this->controller->assert(null, $unite, 'prevoir')) { $enum[$unite->id] = $unite->getFullname(); } } if (!$enum) { throw new Strass_Controller_Action_Exception_Notice("Vous ne pouvez pas enregistrer une activité"); } $i = $m->addEnum('unites', 'Unités participantes', $u->id, $enum, true); // multiple $m->addConstraintRequired($i); $annee = $this->controller->_helper->Annee(false); /* On cherche la date probable de l'activité qu'on veut prévoir. Soit * aucune activité n'est prévue cette année, alors on propose une date * près de la rentrée. Soit le calendrier est déjà remplis, alors on * propose comme date 4 semaines après la dernière activité * prévue. Comme ça on enchaîne l'enregistrement des activités. */ $repere = $u->findLastDate($annee); if (!$repere) { $repere = Strass_Controller_Action_Helper_Annee::dateDebut($annee); } else { $debut = strftime('%Y-%m-%d', strtotime($repere . ' next saturday +4 weeks')); $fin = strftime('%Y-%m-%d', strtotime($repere . ' next sunday +4 weeks')); } $m->addDate('debut', 'Début', $debut . ' 14:30', '%Y-%m-%d %H:%M'); $m->addDate('fin', 'Fin', $fin . '17:00', '%Y-%m-%d %H:%M'); $m->addString('intitule', 'Intitulé explicite', ""); $m->addBool('prevoir', "J'ai d'autres activités à prévoir", true); $m->addNewSubmission('ajouter', 'Ajouter'); $m->addConstraintRequired($m->getInstance('unites')); if ($m->validate()) { $t = new Activites(); $tu = new Unites(); $td = new Documents(); $a = new Activite(); $a->debut = $m->debut; $a->fin = $m->fin; $unites = call_user_func(array($tu, 'find'), (array) $m->unites); // génération de l'intitulé $type = $unites->current()->findParentTypesUnite(); $a->intitule = $m->intitule; $intitule = $type->getIntituleCompletActivite($a); $a->slug = $slug = $t->createSlug($intitule); $db = $t->getAdapter(); $db->beginTransaction(); try { $a->save(); $a->updateUnites($unites); $this->controller->_helper->Flash->info("Activité enregistrée"); $this->controller->logger->info("Nouvelle activite", $this->controller->_helper->Url('consulter', null, null, array('activite' => $a->slug))); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } if ($m->get('prevoir')) { $this->controller->redirectSimple('prevoir'); } else { $this->controller->redirectSimple('consulter', null, null, array('activite' => $slug)); } } return array('model' => $m, 'calendrier' => $u->findActivites($this->current)); }
function supprimerAction() { $this->view->individu = $i = $this->_helper->Individu(); $this->assert(null, $i, 'supprimer', "Vous n'avez pas le droit de supprime cette fiche."); $this->metas(array('DC.Title' => 'Supprimer ' . $i->getFullname())); $this->view->model = $m = new Wtk_Form_Model('desinscrire'); $m->addBool('confirmer', "Je confirme la destruction de cette fiche.", false); $m->addNewSubmission('continuer', 'Continuer'); if ($m->validate()) { if ($m->get('confirmer')) { $db = $i->getTable()->getAdapter(); $db->beginTransaction(); try { $this->logger->warn("Suppression de " . $i->getFullname(), $this->_helper->Url('individus', 'admin')); $i->delete(); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->_helper->Flash->info("Fiche supprimée"); $this->redirectSimple('individus', 'admin'); } else { $this->redirectSimple('fiche', 'individus', null, array('individu' => $i->slug)); } } }
function parametresAction() { $this->metas(array('DC.Title' => 'Paramètres')); $this->branche->append(); $config = Zend_Registry::get('config'); $this->view->model = $m = new Wtk_Form_Model('parametres'); $g = $m->addGroup('metas', "Informations"); $g->addString('title', 'Titre', $config->metas->title); $g->addString('short_title', 'Titre court', $config->system->short_title); $g->addString('subject', 'Mots clefs', $config->metas->subject); $g->addString('author', 'Créateur du site', $config->metas->author); $g->addInteger('creation', 'Date de création du site', $config->metas->creation); $g = $m->addGroup('system', 'Système'); $enum = array(); foreach (Wtk_Document_Style::listAvailables() as $style) { $enum[$style->id] = $style->title; } $g->addEnum('style', 'Style', $config->system->style, $enum); $g->addString('admin', 'E-mail système', $config->system->admin); $g = $g->addGroup('mail'); $i0 = $g->addBool('enable', 'Envoyer les mails', $config->system->mail->enable); $i1 = $g->addString('smtp', 'Serveur SMTP', $config->system->mail->smtp); $m->addConstraintDepends($i1, $i0); $m->addNewSubmission('enregistrer', 'Enregistrer'); if ($m->validate()) { $new = new Strass_Config_Php('strass', $m->get()); /* Migration en douceur de mouvement vers association. */ if ($config->system->mouvement) { $new->system->association = $config->system->mouvement; unset($new->system->mouvement); } $new->system->short_title = $new->metas->short_title; unset($new->metas->short_title); $config->merge($new); $config->write(); $this->logger->warn("Configuration mise-à-jour"); $this->redirectSimple('index'); } }
function supprimerAction() { $this->view->unite = $u = $this->_helper->Unite(); $this->assert(null, $u, null, "Vous n'avez pas le droit de supprimer cette unité."); $this->metas(array('DC.Title' => 'Supprimer ' . $u->getFullname())); $this->view->model = $m = new Wtk_Form_Model('supprimer'); $m->addBool('confirmer', "Je confirme la suppression de l'unité et de toutes ses données.", false); $m->addNewSubmission('continuer', 'Continuer'); if ($m->validate()) { if ($m->get('confirmer')) { $db = $u->getTable()->getAdapter(); $db->beginTransaction(); try { $u->delete(); $message = $u . " supprimé"; $this->logger->warn($message, $this->_helper->Url('index', 'unites')); $this->_helper->Flash->info($message); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('unites', 'admin', null, null, true); } else { $this->redirectSimple('index', null, null, array('unite' => $u->slug)); } } }