| @@ 635-656 (lines=22) @@ | ||
| 632 | return $response; |
|
| 633 | } |
|
| 634 | ||
| 635 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 636 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 637 | 'success' => 0 |
|
| 638 | ))); |
|
| 639 | } else { |
|
| 640 | if ($request->isPost()) { |
|
| 641 | $post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
|
| 642 | if ($this->getGameService()->addVote( |
|
| 643 | $this->user, |
|
| 644 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 645 | $post |
|
| 646 | )) { |
|
| 647 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 648 | 'success' => 1 |
|
| 649 | ))); |
|
| 650 | } else { |
|
| 651 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 652 | 'success' => 0 |
|
| 653 | ))); |
|
| 654 | } |
|
| 655 | } |
|
| 656 | } |
|
| 657 | ||
| 658 | return $response; |
|
| 659 | } |
|
| @@ 697-718 (lines=22) @@ | ||
| 694 | $response = $this->getResponse(); |
|
| 695 | $post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
|
| 696 | ||
| 697 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 698 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 699 | 'success' => 0 |
|
| 700 | ))); |
|
| 701 | } else { |
|
| 702 | if ($request->isPost()) { |
|
| 703 | if ($this->getGameService()->addComment( |
|
| 704 | $this->user, |
|
| 705 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 706 | $post, |
|
| 707 | $this->params()->fromPost('comment') |
|
| 708 | )) { |
|
| 709 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 710 | 'success' => 1 |
|
| 711 | ))); |
|
| 712 | } else { |
|
| 713 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 714 | 'success' => 0 |
|
| 715 | ))); |
|
| 716 | } |
|
| 717 | } |
|
| 718 | } |
|
| 719 | ||
| 720 | //ajax call ? |
|
| 721 | if ($this->getRequest()->isXmlHttpRequest()) { |
|
| @@ 754-774 (lines=21) @@ | ||
| 751 | return $response; |
|
| 752 | } |
|
| 753 | ||
| 754 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 755 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 756 | 'success' => 0 |
|
| 757 | ))); |
|
| 758 | } else { |
|
| 759 | if ($request->isPost()) { |
|
| 760 | if ($this->getGameService()->removeComment( |
|
| 761 | $this->user, |
|
| 762 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 763 | $commentId |
|
| 764 | )) { |
|
| 765 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 766 | 'success' => 1 |
|
| 767 | ))); |
|
| 768 | } else { |
|
| 769 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 770 | 'success' => 0 |
|
| 771 | ))); |
|
| 772 | } |
|
| 773 | } |
|
| 774 | } |
|
| 775 | ||
| 776 | return $response; |
|
| 777 | } |
|