/** * */ private function loadImage() { $socialData = []; $images = new GalleryImages(); $albums = new GalleryAlbums(); $result = $images->getImageData($this->id); $view = new View(true); if ($result !== null) { $result = $result[0]; $albumData = $albums->getAlbumData($result['albumid']); $likeTable = new Likes(); $socialData['likes'] = $likeTable->getLikes($this->id, "image"); $socialData['dislikes'] = $likeTable->getLikes($this->id, "image", 1); if ($result['commentcount'] > 0) { $comments = new Comments(); $socialData['comments'] = $comments->get($this->id, "image", false, 13); } else { $socialData['comments'] = []; } $view->addData(array_merge($socialData, $result, ["album" => $albumData])); } else { $view->setStatus(false); } $view->sendResponse(); }
/** * */ private function get() { $res = $this->table->getLikes($_POST['ref_id'], $_POST['ref_name'], $_POST['dislike']); $this->view->setStatus($res !== false); $this->view->addData(["likes" => $res]); }
/** * @param $postid * @return array */ public function loadPost($postid) { $refid = null; $query = $this->getAdapter()->select()->from(["p" => $this->getTableName()])->join(["u" => $this->_dbprefix . "users"], "u.userid=p.userid", ["name", "username"])->join(["w" => $this->_dbprefix . "walls"], "w.wall_id=p.wall_id")->joinLeft(["img" => $this->_dbprefix . "gallery_images"], "img.id=p.content AND p.type = 'image'", ["filename", "caption"])->joinLeft(["co" => $this->_dbprefix . "comments"], "CASE WHEN p.type = 'post' THEN co.ref_id = p.id ELSE co.ref_id = p.content END AND co.ref_name = p.type", "COUNT(DISTINCT co.id) AS commentcount")->joinLeft(["rus" => $this->_dbprefix . "users"], "rus.userid=w.owner_id AND p.userid != w.owner_id", ["name AS receivername", "username AS receiverusername"])->joinLeft(["pi" => $this->_dbprefix . "gallery_images"], "pi.id = u.profileImage", "filename AS pimg")->where("p.userid = ? OR (w.owner_id=? AND w.owner_type = 'profile') OR p.privacy = 0 OR (p.privacy = 1 AND p.userid IN (" . new \Zend_Db_Expr($this->friendslistQuery) . "))", $_SESSION['user']->userid)->where("p.id=?", $postid); $post = $this->getAdapter()->fetchRow($query); if ($post['type'] != "image") { $refid = $post['id']; } elseif ($post['type'] == "image") { $refid = $post['content']; } $likeTable = new Likes(); $commentTable = new Comments(); $likes = $likeTable->getLikes($refid, $post['type']); $dislikes = $likeTable->getLikes($refid, $post['type'], 1); $comments = $commentTable->get($refid, $post['type'], false, 5); return ["post" => $post, "dislikes" => $dislikes, "likes" => $likes, "comments" => $comments]; }