예제 #1
0
 public function articleAction()
 {
     if ($this->_getParam('id', false)) {
         $news = new News();
         $this->view->news = $news->getStory($this->_getParam('id'));
         $comments = new Comments();
         $this->view->comments = $comments->getCommentsNews($this->_getParam('id'));
         $form = new CommentFindForm();
         $form->submit->setLabel('Add a new comment');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $data = array();
                 $data['comment_findID'] = $this->_getParam('id');
                 $data['user_ip'] = $form->getValue('comment_author_IP');
                 $data['user_agent'] = $form->getValue('comment_agent');
                 $data['comment_type'] = 'newscomment';
                 $data['comment_author'] = $form->getValue('comment_author');
                 $data['comment_author_email'] = $form->getValue('comment_author_email');
                 $data['comment_content'] = $form->getValue('comment_content');
                 $data['comment_date'] = $this->getTimeForForms();
                 $data['user_id'] = $this->getIdentityForForms();
                 $config = Zend_Registry::get('config');
                 $akismetkey = $config->webservice->akismetkey;
                 $akismet = new Zend_Service_Akismet($akismetkey, 'http://www.finds.org.uk');
                 if ($akismet->isSpam($data)) {
                     $data['comment_approved'] = 'spam';
                 } else {
                     $data['comment_approved'] = 'moderation';
                 }
                 $comments = new Comments();
                 $insert = $comments->insert($data);
                 $this->_flashMessenger->addMessage('Your comment has been entered and will appear shortly!');
                 $this->_redirect('/news/stories/article/id/' . $this->_getParam('id'));
                 $this->_request->setMethod('GET');
             } else {
                 $this->_flashMessenger->addMessage('There are problems with your comment submission');
                 $form->populate($formData);
             }
         }
     } else {
         throw new Exception('No parameter on the url string');
     }
 }
예제 #2
0
 /** Display individual record
  * @todo move comment functionality to a model
  */
 public function recordAction()
 {
     if ($this->_getParam('id', false)) {
         $this->view->recordID = $this->_getParam('id');
         $id = $this->_getParam('id');
         $findsdata = $this->_finds->getIndividualFind($id, $this->getRole());
         if ($findsdata) {
             $this->view->finds = $findsdata;
         } else {
             throw new Pas_Exception_NotAuthorised('You are not authorised to view this record');
         }
         $contexts = array('xml', 'rss', 'json', 'atom', 'kml', 'georss', 'ics', 'rdf', 'xcs', 'vcf', 'csv', 'pdf');
         if (!in_array($this->_cs->getCurrentContext(), $contexts)) {
             $this->view->findsdata = $this->_finds->getFindData($id);
             $this->view->findsmaterial = $this->_finds->getFindMaterials($id);
             $this->view->temporals = $this->_finds->getFindTemporalData($id);
             $this->view->nexts = $this->_finds->getNextObject($id);
             $this->view->recordsprior = $this->_finds->getPreviousObject($id);
             $this->view->peoples = $this->_finds->getPersonalData($id);
             $this->view->findotherrefs = $this->_finds->getFindOtherRefs($id);
             $findspotsdata = new Findspots();
             $this->view->findspots = $findspotsdata->getFindSpotData($id);
             $rallyfind = new Rallies();
             $this->view->rallyfind = $rallyfind->getFindToRallyNames($id);
             $coins = new Coins();
             $this->view->coins = $coins->getCoinData($id);
             $coinrefs = new Coinclassifications();
             $this->view->coinrefs = $coinrefs->getAllClasses($id);
             $thumbs = new Slides();
             $this->view->thumbs = $thumbs->getThumbnails($id);
             $refs = new Publications();
             $this->view->refs = $refs->getReferences($id);
             $comments = new Comments();
             $this->view->comments = $comments->getFindComments($id);
             $response = $this->getResponse();
             if (in_array($this->getRole(), $this->_higherLevel) && !in_array($this->_cs->getCurrentContext(), array('xml', 'json', 'qrcode'))) {
                 $wform = new WorkflowStageForm();
                 $wform->id->setValue($id);
                 $wform->submit->setLabel('Change workflow');
                 $this->view->wform = $wform;
                 $response->insert('workflow', $this->view->render('structure/workflow.phtml'));
             } else {
                 $findspotsdata = new Findspots();
                 $this->view->findspots = $findspotsdata->getFindSpotData($id);
             }
             $form = new CommentFindForm();
             $form->submit->setLabel('Add a new comment');
             $this->view->form = $form;
             if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
                 if ($form->isValid($form->getValues())) {
                     $data = $form->getValues();
                     if ($this->getHelper->getAkismet()->isSpam($data)) {
                         $data['comment_approved'] = 'spam';
                     } else {
                         $data['comment_approved'] = 'moderation';
                     }
                     $comments = new Comments();
                     $insert = $comments->insert($data);
                     $this->_flashMessenger->addMessage('Your comment has been entered and will appear shortly!');
                     $this->_redirect(self::REDIRECT . 'record/id/' . $this->_getParam('id'));
                     $this->_request->setMethod('GET');
                 } else {
                     $this->_flashMessenger->addMessage('There are problems with your comment submission');
                     $form->populate($formData);
                 }
             }
         } else {
             $this->_helper->layout->disableLayout();
             //disable layout
             $record = $this->_finds->getAllData($id);
             if ($this->_auth->hasIdentity()) {
                 $user = $this->_auth->getIdentity();
                 if (in_array($user->role, $this->_restricted)) {
                     $record['0']['gridref'] = NULL;
                     $record['0']['easting'] = NULL;
                     $record['0']['northing'] = NULL;
                     $record['0']['lat'] = NULL;
                     $record['0']['lon'] = NULL;
                     $record['0']['finder'] = NULL;
                     $record['0']['address'] = NULL;
                     $record['0']['postcode'] = NULL;
                     $record['0']['findspotdescription'] = NULL;
                 }
             } else {
                 $record['0']['gridref'] = NULL;
                 $record['0']['easting'] = NULL;
                 $record['0']['northing'] = NULL;
                 $record['0']['lat'] = NULL;
                 $record['0']['lon'] = NULL;
                 $record['0']['finder'] = NULL;
                 $record['0']['address'] = NULL;
                 $record['0']['postcode'] = NULL;
                 $record['0']['findspotdescription'] = NULL;
                 if (!is_null($record['0']['knownas'])) {
                     $record['0']['parish'] = NULL;
                     $record['0']['fourFigure'] = NULL;
                 }
             }
             $this->view->record = $record;
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }