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 getAllAlbumComment($albumId, $item_type) { $objModelComment = new Application_Model_Comment(); $objModelAlbum = new Album_Model_Album(); $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $objModelUser = new Application_Model_User(); /*------------------- LoggedIn User -----------------*/ $userNs = new Zend_Session_Namespace("members"); $loggedInUserId = $userNs->userId; /*-------------- GET Item Posted User ---------------*/ if ($item_type == 'photo_comment') { $valItem = $objModelAlbumPhoto->find($albumId); } else { if ($item_type == 'album_comment') { $valItem = $objModelAlbum->find($albumId); } } $itemCreatedUserId = $valItem->userId; /*---------------------------------------------------*/ $arrAllComment = array(); $whereComment = "parent_id='0' AND item_type='{$item_type}' AND item_id='{$albumId}' AND publish='1'"; $orderComment = "addedon DESC"; $arrComment = $objModelComment->fetchAll($whereComment, $orderComment); $i = 0; foreach ($arrComment as $com) { $userId = $com->userId; $permission = $this->checkCommentRemovePermission($loggedInUserId, $itemCreatedUserId, $userId); $valUser = $objModelUser->find($userId); $arrAllComment[$i]['commenterName'] = $valUser->getFirstName() . ' ' . $valUser->getLastName(); $arrAllComment[$i]['imageName'] = $valUser->getImage(); $arrAllComment[$i]['comment'] = nl2br(stripslashes($com->comment)); $arrAllComment[$i]['commentId'] = stripslashes($com->id); $arrAllComment[$i]['addedon'] = $com->addedon; $arrAllComment[$i]['permission'] = $permission; $i++; } return $arrAllComment; }
function infoAction() { $this->view->title = "Vehicle info"; $id = ''; $id = (int) $this->_request->getParam('id', 0); $vehicle = new Application_Model_Vehicle(); $vehicleRow = $vehicle->fetchRow($vehicle->select()->where('id = ?', $id)); $this->view->vehicleArray = $vehicleRow->toArray(); $this->view->id = $id; $page_id = "vehicle_" . $id; $where = "page_id=" . "'" . $page_id . "'"; $auth = Zend_Auth::getInstance(); $user = $auth->getIdentity(); $this->view->name = $user->name; $comment = new Application_Model_Comment(); $commentRow = $comment->fetchAll($where); //$commentRow = $comment->fetchAll($comment->select()->order('comment DESC')); $commentArray = $commentRow->toArray(); $this->view->countComment = count($commentArray); $this->view->commentArray = $commentArray; }
public function commentAction() { $this->view->layout()->disableLayout(); // $this->_helper->viewRenderer->setNoRender(true); $id = $this->_getParam('blogId'); $objModelComment = new Application_Model_Comment(); $objComment = $objModelComment->fetchAll("item_id= {$id}", "addedon ASC"); $this->view->comment = $objComment; }
public function removeTravelWallPostAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $params = $this->getRequest()->getParams(); $postId = $params['postId']; $objModelWall = new Application_Model_Wall(); $objModelVote = new Application_Model_Vote(); $objModelComment = new Application_Model_Comment(); $whereWall = "id='{$postId}'"; $whereVote = "item_id='{$postId}' AND item_type='status'"; $whereComment = "item_id='{$postId}' AND item_type='status'"; $arrComment = $objModelComment->fetchAll($whereComment); if (!empty($arrComment)) { foreach ($arrComment as $cmt) { $whereVt = "item_id='{$cmt->id}' AND item_type='status_comment'"; $objModelVote->delete($whereVt); } } $objModelVote->delete($whereVote); $objModelComment->delete($whereComment); $objModelWall->delete($whereWall); exit; }
public function commentAction() { $this->view->layout()->disableLayout(); // $this->_helper->viewRenderer->setNoRender(true); $id = $this->_getParam('blogId'); $objModelComment = new Application_Model_Comment(); $condition = "item_id= {$id} AND publish='1'"; $objComment = $objModelComment->fetchAll($condition, "addedon ASC"); $this->view->blog_id = $id; $this->view->comment = $objComment; //get blog information $objModelBlog = new Application_Model_Blog(); $objModelBlog = $objModelBlog->find($id); $this->view->enable_comment = $objModelBlog->getComment(); $userNs = new Zend_Session_Namespace('members'); $this->view->user_id = $userNs->userId; }
public function getAllAlbumComment($albumId, $item_type) { $objModelComment = new Application_Model_Comment(); $objModelUser = new Application_Model_User(); $arrAllComment = array(); $whereComment = "parent_id='0' AND item_type='{$item_type}' AND item_id='{$albumId}' AND publish='1'"; $orderComment = "addedon DESC"; $arrComment = $objModelComment->fetchAll($whereComment, $orderComment); $i = 0; foreach ($arrComment as $com) { $userId = $com->userId; $valUser = $objModelUser->find($userId); $arrAllComment[$i]['commenterName'] = $valUser->getFirstName() . ' ' . $valUser->getLastName(); $arrAllComment[$i]['imageName'] = $valUser->getImage(); $arrAllComment[$i]['comment'] = nl2br(stripslashes($com->comment)); $arrAllComment[$i]['commentId'] = stripslashes($com->id); $arrAllComment[$i]['addedon'] = date("D, M j, Y", $com->addedon); $i++; } return $arrAllComment; }