public function executeEdit()
 {
     $this->setPage();
     $this->forward404Unless($this->page);
     $this->forward403Unless($this->canView);
     // Generate the username (this is done by the Revision model)
     $tmp_revision = new nahoWikiRevision();
     $tmp_revision->initUserName();
     $this->userName = $tmp_revision->getUserName();
     // Save changes
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         // Here we must be able to edit
         $this->forward403Unless($this->canEdit);
         if (!$this->page->isNew()) {
             $this->revision->archiveContent();
             $this->initNewRevision();
         }
         $this->revision->setContent($this->getRequestParameter('content'));
         $this->revision->setComment($this->getRequestParameter('comment'));
         if (!$this->getRequestParameter('request-preview')) {
             $this->revision->save();
         }
         $this->page->setLatestRevision($this->revision->getRevision());
         if (!$this->getRequestParameter('request-preview')) {
             $this->page->save();
             // save the object the wiki page relates to (so that it can trigger actions)
             $page_name = $this->page->getName();
             list($rel_obj_type, $rel_obj_id) = split("_", $page_name);
             switch ($rel_obj_type) {
                 case 'atto':
                     $rel_obj_model = 'OppAtto';
                     break;
                 case 'votazione':
                     $rel_obj_model = 'OppVotazione';
                     break;
                 case 'emendamento':
                     $rel_obj_model = 'OppEmendamento';
                     break;
             }
             $rel_obj = call_user_func($rel_obj_model . 'Peer::retrieveByPK', $rel_obj_id);
             $rel_obj->save();
             // $this->redirect('nahoWiki/view?page=' . $this->page->getName());
             $referer = $this->getUser()->getAttribute('referer', 'nahoWiki/view?page=' . $this->page->getName());
             $this->getUser()->getAttributeHolder()->remove('referer');
             $this->redirect($referer);
         }
     }
     return sfView::SUCCESS;
 }
 public function executeEdit()
 {
     $this->setPage();
     // Do not reject here if not canEdit, cause it then fallbacks on "view source" feature
     $this->forward403Unless($this->canView);
     // Generate the username (this is done by the Revision model)
     $tmp_revision = new nahoWikiRevision();
     $tmp_revision->initUserName();
     $this->userName = $tmp_revision->getUserName();
     // Save changes
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         // Here we must be able to edit
         $this->forward403Unless($this->canEdit);
         if (!$this->page->isNew()) {
             $this->revision->archiveContent();
             $this->initNewRevision();
         }
         $this->revision->setContent($this->getRequestParameter('content'));
         $this->revision->setComment($this->getRequestParameter('comment'));
         if (!$this->getRequestParameter('request-preview')) {
             $this->revision->save();
         }
         $this->page->setLatestRevision($this->revision->getRevision());
         if (!$this->getRequestParameter('request-preview')) {
             $this->page->save();
             $this->redirect('nahoWiki/view?page=' . $this->page->getName());
         }
     }
     return sfView::SUCCESS;
 }