function fonderAction() { $this->view->unite = $u = $this->_helper->Unite(); $this->metas(array('DC.Title' => "Fonder le journal de " . $u->getFullName(), 'DC.Subject' => 'journaux,journal,gazette,blog')); $tu = $u->findParentTypesUnite(); if ($tu->isTerminale() && $tu->age_min && $tu->age_min < 12) { throw new Strass_Controller_Action_Exception("Impossible de créer un journal d'unité " . "pour " . $u->getFullName()); } $this->assert(null, $u, 'fonder-journal', "Vous n'avez pas le droit de fonder le journal de cette unité"); $this->view->model = $m = new Wtk_Form_Model('fonder-journal'); $i = $m->addString('nom', "Nom"); $m->addConstraintRequired($i); $m->addNewSubmission('fonder', "Fonder"); if ($m->validate()) { $t = new Journaux(); $db = $t->getAdapter(); $db->beginTransaction(); try { $data = array('nom' => $m->get('nom'), 'slug' => $t->createSlug(wtk_strtoid($m->get('nom'))), 'unite' => $u->id); $k = $t->insert($data); $j = $t->findOne($k); $this->logger->info("Nouveau journal d'unité", $this->_helper->Url('index', 'journaux', array('journal' => $j->slug))); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->redirectSimple('index', 'journaux', null, array('journal' => $j->slug)); } }