Co prawda nie może oddać już głosu jeśli głosował, lecz nie pojawia się komunikat i nie wiem co jest źle w warunku.
Akcja:
public function voteAction() { $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); if ($identity) { $votes = new Application_Model_DbTable_Votes(); $answer_id = $this->getRequest()->getParam('answer'); $identity->users_id; $vote = $votes->fetchRow($votes->select() ->where('answer = ?', $answer_id)); $answers = new Application_Model_DbTable_Answers(); $mark = $this->getRequest()->getParam('mark'); if (!$vote) { $answer = $answers->find($answer_id); if ($answer->count()) { $answer = $answer->current(); if ($mark == 'plus') { ++$answer->mark; 'answer' => $answer_id, 'author' => $identity->users_id ))->save(); } else { --$answer->mark; 'answer' => $answer_id, 'author' => $identity->users_id ))->save(); } $answer->save(); } } $this->view->vote = $vote; } $session = new Zend_Session_Namespace; $this->_helper->redirector->gotoUrl($session->redirect); }
Widok:
<?php if ($this->identity): ?> <?php if ($this->identity->users_id != $answer['author']): ?> <?php if ($this->identity->users_id != $this->vote['author'] && $this->vote['answer'] == NULL): ?> <i style="margin-right: 5px" class="icon-thumbs-up"></i> <span style="color: green;">Dobra odpowiedź</span> </a>      <i style="margin-right: 5px" class="icon-thumbs-down"></i> <span style="color: red;">Zła odpowiedź</span> </a> <?php elseif ($this->identity->users_id == $this->vote['author'] && $this->vote['answer'] != NULL): ?> Oddałeś <?php endif; ?> <?php endif; ?>      <span style="font-weight: bold;"> </span> <?php endif; ?>