| @@ 598-619 (lines=22) @@ | ||
| 595 | return $response; |
|
| 596 | } |
|
| 597 | ||
| 598 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 599 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 600 | 'success' => 0 |
|
| 601 | ))); |
|
| 602 | } else { |
|
| 603 | if ($request->isPost()) { |
|
| 604 | $post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
|
| 605 | if ($this->getGameService()->addVote( |
|
| 606 | $this->user, |
|
| 607 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 608 | $post |
|
| 609 | )) { |
|
| 610 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 611 | 'success' => 1 |
|
| 612 | ))); |
|
| 613 | } else { |
|
| 614 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 615 | 'success' => 0 |
|
| 616 | ))); |
|
| 617 | } |
|
| 618 | } |
|
| 619 | } |
|
| 620 | ||
| 621 | return $response; |
|
| 622 | } |
|
| @@ 660-681 (lines=22) @@ | ||
| 657 | $response = $this->getResponse(); |
|
| 658 | $post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
|
| 659 | ||
| 660 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 661 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 662 | 'success' => 0 |
|
| 663 | ))); |
|
| 664 | } else { |
|
| 665 | if ($request->isPost()) { |
|
| 666 | if ($this->getGameService()->addComment( |
|
| 667 | $this->user, |
|
| 668 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 669 | $post, |
|
| 670 | $this->params()->fromPost('comment') |
|
| 671 | )) { |
|
| 672 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 673 | 'success' => 1 |
|
| 674 | ))); |
|
| 675 | } else { |
|
| 676 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 677 | 'success' => 0 |
|
| 678 | ))); |
|
| 679 | } |
|
| 680 | } |
|
| 681 | } |
|
| 682 | ||
| 683 | //ajax call ? |
|
| 684 | if ($this->getRequest()->isXmlHttpRequest()) { |
|
| @@ 713-733 (lines=21) @@ | ||
| 710 | return $response; |
|
| 711 | } |
|
| 712 | ||
| 713 | if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
| 714 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 715 | 'success' => 0 |
|
| 716 | ))); |
|
| 717 | } else { |
|
| 718 | if ($request->isPost()) { |
|
| 719 | if ($this->getGameService()->removeComment( |
|
| 720 | $this->user, |
|
| 721 | $this->getRequest()->getServer('REMOTE_ADDR'), |
|
| 722 | $commentId |
|
| 723 | )) { |
|
| 724 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 725 | 'success' => 1 |
|
| 726 | ))); |
|
| 727 | } else { |
|
| 728 | $response->setContent(\Zend\Json\Json::encode(array( |
|
| 729 | 'success' => 0 |
|
| 730 | ))); |
|
| 731 | } |
|
| 732 | } |
|
| 733 | } |
|
| 734 | ||
| 735 | return $response; |
|
| 736 | } |
|