コード例 #1
0
 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]];
 }
コード例 #2
0
</span>
                            </div>
                            <div class="about">
                                <?php 
            echo substr($pageData['about'], 0, 250);
            if (strlen($pageData['about']) > 250) {
                echo " ...";
            }
            ?>
                            </div>
                            <div class="action">
                                <?php 
            if ($userID = buckys_is_logged_in()) {
                ?>
                                    <?php 
                if (BuckysPageFollower::isFollower($userID, $pageData['pageID'])) {
                    echo sprintf('<a href="/page.php?pid=%d&action=unfollow' . buckys_get_token_param() . '" data-type="buckys-ajax-link">Unfollow Page</a> <br/>', $pageData['pageID']);
                } else {
                    echo sprintf('<a href="/page.php?pid=%d&action=follow' . buckys_get_token_param() . '" data-type="buckys-ajax-link">Follow Page</a> <br/>', $pageData['pageID']);
                }
                ?>
                                <?php 
            } else {
                ?>
                                    <a href="<?php 
                echo $pageLink;
                ?>
">View Page</a>
                                <?php 
            }
            ?>