static function addCom($pseudo, $infos, $texte, $idNew)
 {
     $com = new Commentaires();
     $com->pseudo = $pseudo;
     $com->infos = $infos;
     $com->contenu = $texte;
     $com->id_new = $idNew;
     $com->save();
 }
Beispiel #2
0
 function direct($throw = true)
 {
     $id = $this->getRequest()->getParam('message');
     if (!$id) {
         throw new Strass_Controller_Action_Exception_Notice("Message non spécifié.");
     }
     $t = new Commentaires();
     try {
         return $t->findOne($id);
     } catch (Strass_Db_Table_NotFound $e) {
         if ($throw) {
             throw new Strass_Controller_Action_Exception_NotFound("Commentaire #" . $id . " inexistant.");
         } else {
             return null;
         }
     }
 }
Beispiel #3
0
 function voirAction()
 {
     $this->view->photo = $photo = $this->_helper->Photo();
     $this->view->activite = $a = $photo->findParentActivites();
     $this->metas(array('DC.Title' => $photo->titre, 'DC.Subject' => 'photo', 'DC.Date.created' => $photo->date));
     $this->actions->append("Identifier", array('action' => 'identifier'), array(null, $photo));
     $this->actions->append("Éditer", array('action' => 'editer'), array(null, $photo));
     $this->actions->append("Supprimer", array('action' => 'supprimer'), array(null, $photo));
     $ps = $a->findPhotos($photo->getTable()->select()->order('date'));
     $data = array();
     foreach ($ps as $p) {
         $data[$p->slug] = $p;
     }
     $this->view->model = $m = new Wtk_Pages_Model_Assoc($data, $photo->slug);
     $i = Zend_Registry::get('individu');
     if ($this->assert(null, $photo, 'commenter')) {
         /* Si l'utilisateur peut commenter mais ne l'a pas fait, lui
            présenter le formulaire */
         try {
             $photo->findCommentaire($i);
         } catch (Strass_Db_Table_NotFound $e) {
             $this->view->com_model = $m = new Wtk_Form_Model('commentaire');
             $m->addString('message', "Message");
             $m->addNewSubmission('commenter', "Commenter");
             if ($m->validate()) {
                 $t = new Commentaires();
                 $tuple = array('parent' => $photo->commentaires, 'auteur' => $i->id, 'message' => $m->get('message'));
                 $db = $t->getAdapter();
                 $db->beginTransaction();
                 try {
                     $t->insert($tuple);
                     $this->logger->info("Photo commentée");
                     unset($this->view->com_model);
                     $db->commit();
                 } catch (Exception $e) {
                     $db->rollBack();
                     throw $e;
                 }
             }
         }
     }
     /* Lister les commentaires après l'insertion  */
     $this->view->commentaires = $photo->findCommentaires();
 }
Beispiel #4
0
 function findCommentaire($individu)
 {
     $t = new Commentaires();
     $s = $t->select()->setIntegrityCheck(false)->distinct()->from('commentaire')->where('parent = ?', $this->commentaires)->where('auteur = ?', $individu->id);
     return $t->fetchOne($s);
 }