public function getListAction() { global $TNB_GLOBALS, $db; $data = $_POST; $keyword = isset($data['keyword']) ? $data['keyword'] : null; $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null; $sort = "pop"; $page = isset($data['page']) ? $data['page'] : null; if (!$token) { return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')]; } if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) { return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')]; } //Search Results $searchIns = new BuckysSearch(); $pageIns = new BuckysPage(); $pageFollowerIns = new BuckysPageFollower(); $db_results = $searchIns->search($keyword, BuckysSearch::SEARCH_TYPE_USER_AND_PAGE, $sort, $page); $results = []; foreach ($db_results as $item) { $row = []; if ($item['type'] == "user") { //User $row['type'] = "user"; //Getting Detail Information $query = $db->prepare("SELECT \n u.firstName, \n u.lastName, \n u.userID, \n u.thumbnail, \n u.current_city, \n u.current_city_visibility,\n f.friendID \n FROM \n " . TABLE_USERS . " AS u\n LEFT JOIN " . TABLE_FRIENDS . " AS f ON f.userID=%d AND f.userFriendID=u.userID AND f.status='1'\n WHERE u.userID=%d", $userID, $item['userID']); $data = $db->getRow($query); $row['id'] = $item['userID']; $row['title'] = $data['firstName'] . " " . $data['lastName']; $row['description'] = $data['current_city_visibility'] ? $data['current_city'] : ""; $row['isFriend'] = !$data['friendID'] ? 'no' : 'yes'; $row['image'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($data); } else { $row['type'] = "page"; //Page $pageData = $pageIns->getPageByID($item['pageID']); $followerCount = $pageFollowerIns->getNumberOfFollowers($item['pageID']); $row['id'] = $item['pageID']; $row['title'] = $pageData['title']; $row['description'] = number_format($followerCount) . " follower" . ($followerCount > 1 ? "s" : ""); $row['isFollowed'] = BuckysPageFollower::isFollower($userID, $pageData['pageID']) ? 'yes' : 'no'; $row['image'] = THENEWBOSTON_SITE_URL . (!$pageData['logo'] ? DIR_WS_IMAGE . "newPagePlaceholder.jpg" : DIR_WS_PHOTO . "users/" . $pageData['userID'] . "/resized/" . $pageData['logo']); } $results[] = $row; } return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $results]]; }
<?php require dirname(__FILE__) . '/includes/bootstrap.php'; //Getting Current User ID $userID = buckys_is_logged_in(); $pageIns = new BuckysPage(); $pageFollowerIns = new BuckysPageFollower(); $paramPageID = isset($_GET['pid']) ? intval($_GET['pid']) : null; $pageData = $pageIns->getPageByID($paramPageID); //If the parameter is null, goto homepage if (!buckys_not_null($pageData)) { buckys_redirect('/index.php'); } $page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1; $totalCount = $pageFollowerIns->getNumberOfFollowers($pageData['pageID']); $pagination = new Pagination($totalCount, BuckysPageFollower::COUNT_PER_PAGE, $page); $page = $pagination->getCurrentPage(); //Get Friends $view['followers'] = $pageFollowerIns->getFollowers($pageData['pageID'], $page, BuckysPageFollower::COUNT_PER_PAGE); $view['pageData'] = $pageData; buckys_enqueue_stylesheet('profile.css'); buckys_enqueue_stylesheet('friends.css'); buckys_enqueue_stylesheet('account.css'); buckys_enqueue_stylesheet('stream.css'); buckys_enqueue_stylesheet('posting.css'); buckys_enqueue_stylesheet('uploadify.css'); buckys_enqueue_stylesheet('jquery.Jcrop.css'); buckys_enqueue_stylesheet('page.css'); buckys_enqueue_javascript('uploadify/jquery.uploadify.js'); buckys_enqueue_javascript('jquery.Jcrop.js'); buckys_enqueue_javascript('jquery.color.js');
echo $profileLink; ?> ">View Profile</a> <br/> <a href="<?php echo $sendMessageLink; ?> ">Send Message</a> <br/> </div> <div class="clear"></div> </div> <?php } else { //Display Page $pageData = $pageIns->getPageByID($data['pageID']); $followerCount = $pageFollowerIns->getNumberOfFollowers($data['pageID']); if (empty($pageData)) { continue; } $pageLink = '/page.php?pid=' . $pageData['pageID']; ?> <div class="node"> <div class="img-cont"><?php render_pagethumb_link($pageData, 'thumbIcon'); ?> </div> <div class="desc"> <a href="<?php echo $pageLink; ?> "><b><?php
public function followAction() { $data = $_POST; $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null; $pageID = isset($data['pageID']) ? $data['pageID'] : null; if (!$token) { return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')]; } if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) { return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')]; } $pageFollowerIns = new BuckysPageFollower(); $result = $pageFollowerIns->addFollower($pageID, $userID); if ($result) { $count = $pageFollowerIns->getNumberOfFollowers($pageID); return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "MESSAGE" => MSG_FOLLOW_PAGE_SUCCESS, "FOLLOWERS" => $count . " follower" . ($count > 1 ? "s" : "")]]; } else { return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_FOLLOW_PAGE_FAIL)]; } }