public function getPendingAction()
 {
     $request = $_GET;
     $token = isset($request['TOKEN']) ? trim($request['TOKEN']) : 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.')];
     }
     $friends = BuckysFriend::getPendingRequests($userID);
     $results = [];
     foreach ($friends as $row) {
         $item = [];
         $item['id'] = $row['userID'];
         $item['name'] = $row['fullName'];
         $item['thumbnail'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($row['userID']);
         $item['description'] = $row['city'];
         $item['friendType'] = $row['status'];
         $results[] = $item;
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $results]];
 }
    $totalCount = BuckysFriend::getNumberOfFriends($userID);
} else {
    if ($type == 'pending') {
        $totalCount = BuckysFriend::getNumberOfPendingRequests($userID);
    } else {
        if ($type == 'requested') {
            $totalCount = BuckysFriend::getNumberOfReceivedRequests($userID);
        }
    }
}
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysFriend::$COUNT_PER_PAGE, $page);
$page = $pagination->getCurrentPage();
if ($type == 'all') {
    $friends = BuckysFriend::getAllFriends($userID, $page, BuckysFriend::$COUNT_PER_PAGE);
} else {
    if ($type == 'pending') {
        $friends = BuckysFriend::getPendingRequests($userID, $page, BuckysFriend::$COUNT_PER_PAGE);
    } else {
        if ($type == 'requested') {
            $friends = BuckysFriend::getReceivedRequests($userID, $page, BuckysFriend::$COUNT_PER_PAGE);
        }
    }
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('friends.css');
buckys_enqueue_javascript('friends.js');
$TNB_GLOBALS['content'] = 'myfriends';
$TNB_GLOBALS['title'] = "My Friends - " . TNB_SITE_NAME;
//if logged user can see all resources of the current user
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";