/** * @Created By : Mahipal Singh Adhikari * @Created On : 2-Nov-2010 * @Description: Sumbit comment by blog owner */ public function addCommentAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $userNs = new Zend_Session_Namespace('members'); $this->view->userId = $userNs->userId; if (is_null($userNs->userId) && !numeric($userNs->userId)) { $response = "<span style='color:#ff0000;'>Please login to submit your comment on this blog.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); echo Zend_Json::encode($JsonResultArray); exit; } if ($this->_getParam('comment') == "" || $this->_getParam('comment') == "Comment...") { $response = "<span style='color:#ff0000;'>Please enter your comment.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); echo Zend_Json::encode($JsonResultArray); exit; } //save comment $commentM = new Application_Model_Comment(); $commentM->setComment($this->_getParam('comment')); $commentM->setItemId($this->_getParam('item_id')); $commentM->setItemType($this->_getParam('item_type')); $commentM->setParentId(0); $commentM->setPublish(1); $commentM->setUserId($userNs->userId); $id = $commentM->save(); //set and display response if ($id > 0) { //get total number of comments $total_comments = $commentM->numComments('blog', $this->_getParam('item_id')); $total_comments = $total_comments . " Comments"; //get comment information to display in comment listings $comment = $commentM->find($id); //$this->view->comment = $objComment; $date = new Base_Date(); $objModelUser = new Application_Model_User(); $objUser = $objModelUser->find($comment->userId); $username = $objUser->getUsername(); $firstname = $objUser->getFirstName(); $lastname = $objUser->getLastName(); $image = $objUser->getThumbnail(); $response = "<div class='my-journal-view-comment-row' id='comment-detail-" . $id . "'>"; $response .= "<div class='my-journal-view-comment-row-l'>"; $response .= "<a href='/" . $username . "'><img width='37px' height='43px' border='0' src='" . $image . "' alt='' /></a>"; $response .= "</div>"; $response .= "<div class='my-journal-view-comment-row-r'>"; $response .= "<p><span><a href='/" . $username . "'>" . $firstname . " " . $lastname . "</a></span> " . $comment->comment . "</p>"; $response .= "<div class='jposted'>Posted " . $date->timeAgo($comment->getAddedon()) . " | "; $response .= "<a href='#add_comment_form' title='Add Comment'>Comment</a> | "; $like_link = "<a href='javascript://' title='Like Comment' onclick='likeComment(" . $id . ", 1)'>Like</a>"; $response .= "<label id='like-comment-label-" . $id . "'>" . $like_link . "</label> | "; $response .= "<a href='javascript://' title='Remove Comment' onclick='removeComment(" . $id . "," . $this->_getParam('item_id') . ")'>Remove</a>"; $response .= "</div></div></div>"; $JsonResultArray = array('error' => 0, 'total_comments' => $total_comments, 'response' => $response); } else { $response = "<span style='color:#ff0000;'>Error occured, Please try again later.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); } echo Zend_Json::encode($JsonResultArray); exit; }
public function getVideosCommentsUser($id, $limit = null, $user_id = null, $sort = null) { //$id = picture id $arrayVId = array(); $order = "id desc"; $commentM = new Application_Model_Comment(); $where = "item_id ='{$id}' and item_type='movie_user_video' and parent_id='0'"; if (!is_null($user_id)) { $where .= " and user_id='{$user_id}'"; } if (!is_null($sort)) { if ($sort != "recent") { $comments = $commentM->fetchAll($where, $order); foreach ($comments as $row) { $arrayVId[] = $row->getId(); } } else { $comments = $commentM->fetchAll($where, $order, $limit); } //$strPicId=implode(",",$arrayPicId); $voteM = new Application_Model_Vote(); $res = array(); if ($sort == "up") { $res = $voteM->getTotalVotesGroup($arrayVId, 'movie', 'user_movie_videos_comments', 1, null); } else { if ($sort == "down") { $res = $voteM->getTotalVotesGroup($arrayVId, 'movie', 'user_movie_videos_comments', -1, null); } else { if ($sort == "sum") { $res = $voteM->getTotalVotesSum($arrayVId, 'movie', 'user_movie_videos_comments'); } } } if (count($res) > 0 && $sort != "recent") { unset($comments); $ctr = 0; foreach ($res as $row) { $ctr++; if (!is_null($limit)) { if ($limit < $ctr) { break; } } $comments[] = $commentM->find($row->item_id); $usedIds[] = $row->item_id; } $remain = array_diff($arrayVId, $usedIds); foreach ($remain as $comment_id) { $ctr++; if (!is_null($limit)) { if ($limit < $ctr) { break; } } $comments[] = $commentM->find($comment_id); } } } else { $comments = $commentM->fetchAll($where, $order, $limit); } return $comments; }
public function userLikeThisAction() { $this->_helper->layout->setLayout('journal-layout-2column'); //$item_id = $this->_getParam("blog_id"); $item_id = $this->_getParam("item_id"); $item_type = $this->_getParam("type"); //$userNs = new Zend_Session_Namespace('members'); //$this->view->userId = $userNs->userId; $item = false; $itemTypeText = ""; if ($item_type != "") { if ($item_type == 'blog') { $blogM = new Application_Model_Blog(); $this->view->blog = $item = $blogM->find($item_id); $itemTypeText = "Journal Post"; } if ($item_type == 'status_comment' || $item_type == 'blog_comment') { $commentM = new Application_Model_Comment(); $item = $commentM->find($item_id); $itemTypeText = "Comment"; $item_type = "comment"; } if ($item_type == 'status') { $wallM = new Application_Model_Wall(); $item = $wallM->find($item_id); $itemTypeText = "Wall Post"; } $this->view->itemTypeText = $itemTypeText; } //if item is not exists then redirect to Journal home page if (false === $item) { $this->_helper->redirector()->gotoUrl('/journal/index/'); exit; } //Now get all positive votes of item //$where = "item_id = $item_id AND vote=1 AND item_type='blog'"; $where = "item_id = {$item_id} AND vote=1"; if ($item_type == 'comment') { $where .= " AND (item_type='status_comment' OR item_type='blog_comment')"; } else { $where .= " AND item_type='{$item_type}'"; } $voteM = new Application_Model_Vote(); $rawdata = $voteM->fetchAll($where); //Get all users ID voted on an item if (false !== $rawdata) { $user_array = array(); foreach ($rawdata as $row) { $user_array[] = $row->getUserId(); } } //get all users information from above User Ids $this->view->totalUsers = 0; if (count($user_array) > 0) { $usrstr = implode(",", $user_array); $userM = new Application_Model_User(); $whereuser = "******"; $userData = $userM->fetchAll($whereuser, "first_name ASC"); $this->view->userData = $userData; $settings = new Admin_Model_GlobalSettings(); $page_size = $settings->settingValue('pagination_size'); //$page_size = 1; $page = $this->_getParam('page', 1); $pageObj = new Base_Paginator(); $paginator = $pageObj->fetchPageData($userM, $page, $page_size, $whereuser); $this->view->totalUsers = $pageObj->getTotalCount(); $this->view->paginator = $paginator; } }