| @@ 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 commentsAction() |
|
| 624 | { |
|
| @@ 640-681 (lines=42) @@ | ||
| 637 | return $viewModel; |
|
| 638 | } |
|
| 639 | ||
| 640 | public function ajaxCommentAction() |
|
| 641 | { |
|
| 642 | // Call this for the session lock to be released (other ajax calls can then be made) |
|
| 643 | session_write_close(); |
|
| 644 | $postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
|
| 645 | $request = $this->getRequest(); |
|
| 646 | $response = $this->getResponse(); |
|
| 647 | ||
| 648 | if (! $this->game) { |
|
| 649 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 650 | 'success' => 0 |
|
| 651 | ))); |
|
| 652 | ||
| 653 | return $response; |
|
| 654 | } |
|
| 655 | ||
| 656 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 657 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 658 | 'success' => 0 |
|
| 659 | ))); |
|
| 660 | } else { |
|
| 661 | if ($request->isPost()) { |
|
| 662 | $post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
|
| 663 | if ($this->getGameService()->addComment( |
|
| 664 | $this->user, |
|
| 665 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 666 | $post, |
|
| 667 | $this->params()->fromPost('comment') |
|
| 668 | )) { |
|
| 669 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 670 | 'success' => 1 |
|
| 671 | ))); |
|
| 672 | } else { |
|
| 673 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 674 | 'success' => 0 |
|
| 675 | ))); |
|
| 676 | } |
|
| 677 | } |
|
| 678 | } |
|
| 679 | ||
| 680 | return $response; |
|
| 681 | } |
|
| 682 | ||
| 683 | public function ajaxRemoveCommentAction() |
|
| 684 | { |
|