Example #1
0
 public function editAction()
 {
     if ($this->_request->getParam("id")) {
         $id = $this->_request->getParam("id");
         $body = $this->_request->getParam("body");
         $comment_model = new Application_Model_Comment();
         $comment_model->editComment($id, $body);
     }
 }
Example #2
0
 public function addAction()
 {
     $this->view->post_data = $this->_request->getParams();
     if ($this->_request->isPost()) {
         $post_data = $this->_request->getParams();
         var_dump($post_data);
         echo $post_data['commentbody'];
         if (!empty($post_data['commentbody'])) {
             var_dump($post_data);
             $comment = new Application_Model_Comment();
             $comment->addComment($post_data);
         } else {
             $post = new Application_Model_Post();
             $this->view->post_id = $post->addPost($post_data);
             $this->view->post_data = $this->_request->getParams();
         }
     }
 }
Example #3
0
 function indexAction()
 {
     if ($this->_request->isPost()) {
         Zend_Loader::loadClass('Zend_Filter_StripTags');
         $filter = new Zend_Filter_StripTags();
         $name = trim($filter->filter($this->_request->getPost('name')));
         $comment = trim($filter->filter($this->_request->getPost('comment')));
         $page_id = trim($filter->filter($this->_request->getPost('page_id')));
         if ($name != '' && $comment != '' && $page_id != '') {
             $data = array('user' => $name, 'comment' => $comment, 'page_id' => $page_id);
             $comment = new Application_Model_Comment();
             $comment->insert($data);
             $this->_redirect('/');
             return;
         } else {
             echo "all fields must be input";
         }
     }
 }
Example #4
0
 public function displayAction()
 {
     $id = $this->_request->getParam("id");
     $thread_model = new Application_Model_Thread();
     $toCategoryId = $this->_request->getParam("toCategoryId");
     if ($toCategoryId != NULL && $id != NULL) {
         $thread = $thread_model->getThreadById($toCategoryId, $id);
         if (count($thread) != 0) {
             $user_model = new Application_Model_User();
             $user = $user_model->getUserById($thread[0]['userId']);
             $this->view->user = $user[0]['userName'];
             $this->view->image = $user[0]['signature'];
             $this->view->id = $user[0]['id'];
             $emoticon_model = new Application_Model_Emoticon();
             $emoticons = $emoticon_model->listEmoticons();
             $comment_model = new Application_Model_Comment();
             $comments = $comment_model->listComments($thread[0]['id']);
             if (count($comments) != 0) {
                 $user_model = new Application_Model_User();
                 for ($i = 0; $i < count($comments); $i++) {
                     $user = $user_model->getUserById($comments[$i]['userId']);
                     $names[] = $user[0]['userName'];
                     $images[] = $user[0]['profilePicture'];
                     $ids[] = $user[0]['id'];
                 }
                 $this->view->comments = $comments;
                 $this->view->names = $names;
                 $this->view->images = $images;
                 $this->view->ids = $ids;
                 $this->view->emoticons = $emoticons;
             }
             $this->view->thread = $thread[0];
             $this->view->toCategoryId = $toCategoryId;
             //                $this->view->lock = $thread[0]['lock'];
         }
     }
 }
 public function albumPhotoCommentAction()
 {
     $this->_helper->layout()->disableLayout();
     $objModelComment = new Application_Model_Comment();
     $objModelUser = new Application_Model_User();
     $arrPostVal = $this->getRequest()->getParams();
     $usersNs = new Zend_Session_Namespace("members");
     $userFullName = $usersNs->userFullName;
     $item_id = $arrPostVal['item_id'];
     $comment = $arrPostVal['comment'];
     $item_type = $arrPostVal['item_type'];
     $userId = $usersNs->userId;
     $option['comment'] = addslashes(strip_tags($comment));
     $option['parentId'] = 0;
     $option['itemType'] = $item_type;
     $option['itemId'] = $item_id;
     $option['addedon'] = time();
     $option['updatedon'] = time();
     $option['userId'] = $userId;
     $option['publish'] = 1;
     $objModelComment->setOptions($option);
     $commentId = $objModelComment->save();
     /*-------------------------------------------------*/
     $valUser = $objModelUser->find($userId);
     $this->view->userImage = $valUser->getImage();
     $this->view->userFullName = $userFullName;
     $this->view->comment = nl2br(strip_tags($comment));
     $this->view->commentId = $commentId;
 }
 public function fetchAll()
 {
     $resultSet = $this->getDbTable()->fetchAll();
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Application_Model_Comment();
         $entry->setId($row->id)->setAccountId($row->account_id)->setNickname($row->nickname)->setPostTime($row->post_time)->setCommentId($row->comment_id)->setArticleId($row->article_id)->setContent($row->content);
         $entries[] = $entry;
     }
     return $entries;
 }
Example #7
0
 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;
 }
Example #8
0
 public function deleteAlbumAction()
 {
     $this->_helper->layout()->disableLayout();
     $albumId = $this->_getParam('id');
     $objModelAlbum = new Album_Model_Album();
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto();
     $objModelAlbumTag = new Album_Model_AlbumTag();
     $objModelAlbumPhotoTag = new Album_Model_AlbumPhotoTag();
     $objModelPhotoTag = new Album_Model_PhotoTag();
     $objModelComment = new Application_Model_Comment();
     // Remove all comment for album
     $whereAlbumComment = "item_type='album_comment' AND item_id='{$albumId}'";
     $objModelComment->delete($whereAlbumComment);
     // Remove all album tag
     $whereAlbumTag = "album_id='{$albumId}'";
     $objModelAlbumTag->delete($whereAlbumTag);
     // Fetch all photo of album
     $whereAlbumPhoto = "album_id='{$albumId}'";
     $arrPhoto = $objModelAlbumPhoto->fetchAll($whereAlbumPhoto);
     if (count($arrPhoto) > 0) {
         foreach ($arrPhoto as $photo) {
             $photoId = $photo->id;
             $photoName = $photo->image;
             $imagePathT = PUBLIC_PATH . "/media/album/thumb/" . $photoName;
             $imagePathC = PUBLIC_PATH . "/media/album/custom/" . $photoName;
             $imagePathD = PUBLIC_PATH . "/media/album/default/" . $photoName;
             unlink($imagePathT);
             // Remove image from thumb folder
             unlink($imagePathC);
             // Remove image from custom folder
             unlink($imagePathD);
             // Remove image from default folder
             // Remove photo comment
             $wherePhotoComment = "item_type='photo_comment' AND item_id='{$photoId}'";
             $objModelComment->delete($wherePhotoComment);
             // Remove tagged photo
             $whereTaggedPhoto = "photo_id='{$photoId}'";
             $objModelPhotoTag->delete($whereTaggedPhoto);
             // Remove photo tag
             $whereAlbumPhotoTag = "photo_id='{$photoId}'";
             $objModelAlbumPhotoTag->delete($whereAlbumPhotoTag);
         }
     }
     // Remove all photo
     $whereAlbumPhoto = "album_id='{$albumId}'";
     $objModelAlbumPhoto->delete($whereAlbumPhoto);
     // Remove Album
     $whereAlbum = "id='{$albumId}'";
     $objModelAlbum->delete($whereAlbum);
     $this->_redirect('/album/my-photos');
     $this->_helper->viewRenderer->setNoRender(true);
 }
Example #9
0
 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;
 }
Example #10
0
 /**
  * @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;
 }
Example #11
0
 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;
 }
Example #12
0
 public function convertRowToObject($row)
 {
     $entry = new Application_Model_Comment();
     $entry->setId($row->id)->setDomain($row->domain)->setPath($row->path)->setCookie($row->cookie)->setNick($row->nick)->setEmail($row->email)->setIp($row->ip)->setContent($row->content)->setReplyTo($row->reply_to)->setCreated($row->created)->setUpdated($row->updated);
     return $entry;
 }
Example #13
0
 public function removeTravelWallPostCommentAction()
 {
     $this->_helper->layout->disableLayout();
     $params = $this->getRequest()->getParams();
     $postId = $params['postId'];
     $objModelVote = new Application_Model_Vote();
     $objModelComment = new Application_Model_Comment();
     $whereVote = "item_id='{$postId}' AND item_type='status_comment'";
     $whereComment = "id='{$postId}'";
     $objModelVote->delete($whereVote);
     $objModelComment->delete($whereComment);
     exit;
 }
Example #14
0
 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;
     }
 }
Example #15
0
 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;
 }