| @@ 581-621 (lines=41) @@ | ||
| 578 | return $viewModel; |
|
| 579 | } |
|
| 580 | ||
| 581 | public function ajaxVoteAction() |
|
| 582 | { |
|
| 583 | // Call this for the session lock to be released (other ajax calls can then be made) |
|
| 584 | session_write_close(); |
|
| 585 | $postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
|
| 586 | $request = $this->getRequest(); |
|
| 587 | $response = $this->getResponse(); |
|
| 588 | ||
| 589 | if (! $this->game) { |
|
| 590 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 591 | 'success' => 0 |
|
| 592 | ))); |
|
| 593 | ||
| 594 | return $response; |
|
| 595 | } |
|
| 596 | ||
| 597 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 598 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 599 | 'success' => 0 |
|
| 600 | ))); |
|
| 601 | } else { |
|
| 602 | if ($request->isPost()) { |
|
| 603 | $post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
|
| 604 | if ($this->getGameService()->addVote( |
|
| 605 | $this->user, |
|
| 606 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 607 | $post |
|
| 608 | )) { |
|
| 609 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 610 | 'success' => 1 |
|
| 611 | ))); |
|
| 612 | } else { |
|
| 613 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 614 | 'success' => 0 |
|
| 615 | ))); |
|
| 616 | } |
|
| 617 | } |
|
| 618 | } |
|
| 619 | ||
| 620 | return $response; |
|
| 621 | } |
|
| 622 | ||
| 623 | public function ajaxCommentAction() |
|
| 624 | { |
|
| @@ 623-664 (lines=42) @@ | ||
| 620 | return $response; |
|
| 621 | } |
|
| 622 | ||
| 623 | public function ajaxCommentAction() |
|
| 624 | { |
|
| 625 | // Call this for the session lock to be released (other ajax calls can then be made) |
|
| 626 | session_write_close(); |
|
| 627 | $postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
|
| 628 | $request = $this->getRequest(); |
|
| 629 | $response = $this->getResponse(); |
|
| 630 | ||
| 631 | if (! $this->game) { |
|
| 632 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 633 | 'success' => 0 |
|
| 634 | ))); |
|
| 635 | ||
| 636 | return $response; |
|
| 637 | } |
|
| 638 | ||
| 639 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 640 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 641 | 'success' => 0 |
|
| 642 | ))); |
|
| 643 | } else { |
|
| 644 | if ($request->isPost()) { |
|
| 645 | $post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
|
| 646 | if ($this->getGameService()->addComment( |
|
| 647 | $this->user, |
|
| 648 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 649 | $post, |
|
| 650 | $this->params()->fromPost('comment') |
|
| 651 | )) { |
|
| 652 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 653 | 'success' => 1 |
|
| 654 | ))); |
|
| 655 | } else { |
|
| 656 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 657 | 'success' => 0 |
|
| 658 | ))); |
|
| 659 | } |
|
| 660 | } |
|
| 661 | } |
|
| 662 | ||
| 663 | return $response; |
|
| 664 | } |
|
| 665 | ||
| 666 | public function captchaAction() |
|
| 667 | { |
|