public function getListAction()
 {
     $request = $_GET;
     $token = isset($request['TOKEN']) ? trim($request['TOKEN']) : null;
     $lastDate = isset($request['lastDate']) ? $request['lastDate'] : 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.')];
     }
     $stream = BuckysPost::getUserPostsStream($userID, $lastDate);
     //Format Result Data
     $result = [];
     foreach ($stream as $post) {
         if ($post['pageID'] != BuckysPost::INDEPENDENT_POST_PAGE_ID) {
             $pageIns = new BuckysPage();
             $pageData = $pageIns->getPageByID($post['pageID']);
         }
         $pagePostFlag = false;
         if (isset($pageData)) {
             $pagePostFlag = true;
         }
         $item = [];
         $item['articleId'] = $post['postID'];
         $item['posterId'] = $post['poster'];
         $item['articleImage'] = "";
         $item['articleVideo'] = "";
         $item['articleVideoId'] = "";
         if ($pagePostFlag) {
             $item['posterName'] = $pageData['title'];
             $item['posterThumbnail'] = buckys_not_null($pageData['logo']) ? THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . "users/" . $pageData['userID'] . "/resized/" . $pageData['logo'] : THENEWBOSTON_SITE_URL . DIR_WS_IMAGE . "newPagePlaceholder.jpg";
         } else {
             $item['posterName'] = $post['posterFullName'];
             $item['posterThumbnail'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($post['poster']);
         }
         $item['postedDate'] = buckys_api_format_date($userID, $post['post_date']);
         $item['purePostedDate'] = $post['post_date'];
         $item['articleContent'] = $post['content'];
         if ($post['type'] == 'video') {
             $item['articleVideo'] = $post['youtube_url'];
             $item['articleVideoId'] = buckys_get_youtube_video_id($post['youtube_url']);
         } else {
             if ($post['type'] == 'image') {
                 $item['articleImage'] = THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . 'users/' . $post['poster'] . '/resized/' . $post['image'];
             }
         }
         $item['articleLikes'] = $post['likes'];
         $item['articleComments'] = $post['comments'];
         $item['isLiked'] = !$post['likeID'] ? "no" : "yes";
         $result[] = $item;
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $result]];
 }
 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]];
 }
 /**
  * Check relations if it has already followed the page
  *
  * @param integer $pageID
  * @param integer $userID
  * @return bool
  */
 public function hasRelationInFollow($pageID, $userID)
 {
     global $db;
     $pageIns = new BuckysPage();
     if (!is_numeric($pageID) || !is_numeric($userID)) {
         return false;
     }
     // failed
     $pageData = $pageIns->getPageByID($pageID);
     if ($pageData['userID'] == $userID) {
         //It means you are the owner of this page.
         //            return true;
     }
     $query = sprintf("SELECT * FROM %s WHERE pageID=%d AND userID=%d", TABLE_PAGE_FOLLOWERS, $pageID, $userID);
     if ($db->getRow($query)) {
         return true;
     } else {
         return false;
     }
 }
示例#4
0
<?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');
示例#5
0
                                    <a href="<?php 
            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;
            ?>
示例#6
0
function buckys_get_single_post_html($post, $userID, $isPostPage = false, $pageData = null)
{
    ob_start();
    if ($post['pageID'] != BuckysPost::INDEPENDENT_POST_PAGE_ID) {
        $pageIns = new BuckysPage();
        $pageData = $pageIns->getPageByID($post['pageID']);
    }
    $pagePostFlag = false;
    if (isset($pageData)) {
        $pagePostFlag = true;
    }
    ?>
    <div class="post-item" id=<?php 
    echo $post['postID'];
    ?>
>
            
                <?php 
    if ($pagePostFlag) {
        ?>
                    <?php 
        render_pagethumb_link($pageData, 'postIcons');
        ?>
                <?php 
    } else {
        ?>
                    <a href="/profile.php?user=<?php 
        echo $post['poster'];
        ?>
" class="poster-thumb"><img src="<?php 
        echo BuckysUser::getProfileIcon($post['poster']);
        ?>
" class="postIcons" /></a>
                <?php 
    }
    ?>
            
            <div class="post-content">
                
                <?php 
    if ($pagePostFlag) {
        ?>
                    <div class="post-author"><a href="page.php?pid=<?php 
        echo $pageData['pageID'];
        ?>
"><b><?php 
        echo $pageData['title'];
        ?>
</b></a></div>
                <?php 
    } else {
        ?>
                    <div class="post-author"><a href="profile.php?user=<?php 
        echo $post['poster'];
        ?>
"><b><?php 
        echo $post['posterFullName'];
        ?>
</b></a></div>
                <?php 
    }
    ?>
                
                
                <?php 
    echo buckys_process_post_content($post, $pageData);
    ?>
                <div class="post-date">
                    <span class="lft">
                        <?php 
    if (buckys_not_null($userID) && $post['poster'] != $userID) {
        ?>
                        <a href='/manage_post.php?action=<?php 
        echo buckys_not_null($post['likeID']) ? 'unlikePost' : 'likePost';
        ?>
&postID=<?php 
        echo $post['postID'];
        ?>
' class="like-post-link"><?php 
        echo buckys_not_null($post['likeID']) ? 'Unlike' : 'Like';
        ?>
</a> &middot;
                        <?php 
    }
    ?>
                        <?php 
    if (buckys_not_null($userID) && $post['poster'] == $userID) {
        ?>
                        <a href='/manage_post.php?action=delete-post&userID=<?php 
        echo $userID;
        ?>
&postID=<?php 
        echo $post['postID'];
        ?>
' class="remove-post-link">Delete</a> &middot;
                        <?php 
    }
    ?>
                        <span><?php 
    echo buckys_format_date($post['post_date']);
    ?>
</span>
                        <?php 
    if (buckys_not_null($userID) && $post['poster'] != $userID && !$post['reportID']) {
        ?>
                        &middot; <a href="/report_object.php" data-type="post" data-id="<?php 
        echo $post['postID'];
        ?>
" data-idHash="<?php 
        echo buckys_encrypt_id($post['postID']);
        ?>
" class="report-link">Report</a>
                        <?php 
    }
    ?>
                    </span>
                    <span class="rgt">
                        <?php 
    echo $post['visibility'] ? 'Public' : 'Private';
    ?>
                    </span>
                    <div class="clear"></div>
                </div>
                <div class="post-like-comment"> 
                    <?php 
    if ($pagePostFlag) {
        ?>
                        
                        <a href="/page.php?pid=<?php 
        echo $pageData['pageID'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked likes-link"><?php 
        echo $post['likes'] > 1 ? $post['likes'] . " likes" : $post['likes'] . " like";
        ?>
 </a>
                        &middot;
                        <a href="/page.php?pid=<?php 
        echo $pageData['pageID'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked"><?php 
        echo $post['comments'] > 1 ? $post['comments'] . " comments" : $post['comments'] . " comment";
        ?>
 </a>
                        
                    <?php 
    } else {
        ?>
                        <a href="/posts.php?user=<?php 
        echo $post['poster'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked likes-link"><?php 
        echo $post['likes'] > 1 ? $post['likes'] . " likes" : $post['likes'] . " like";
        ?>
 </a>
                        &middot;
                        <a href="/posts.php?user=<?php 
        echo $post['poster'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked"><?php 
        echo $post['comments'] > 1 ? $post['comments'] . " comments" : $post['comments'] . " comment";
        ?>
 </a>
                    <?php 
    }
    ?>
                </div>
                <?php 
    if ($post['likes'] > 0) {
        $likedUsers = BuckysPost::getLikedUsers($post['postID']);
        ?>
                <div class="liked-users">
                    <ul>
                        <?php 
        foreach ($likedUsers as $l) {
            ?>
                        <li><a href="/profile.php?user=<?php 
            echo $l['userID'];
            ?>
"><img src="<?php 
            echo BuckysUser::getProfileIcon($l);
            ?>
"> <span><?php 
            echo $l['firstName'] . " " . $l['lastName'];
            ?>
</span></a></li>
                        <?php 
        }
        ?>
                        <?php 
        if ($post['likes'] > 30) {
            ?>
                        <li class="more-likes">+ <?php 
            echo $post['likes'] - count($likedUsers);
            ?>
 more</li>
                        <?php 
        }
        ?>
                    </ul>                    
                </div>
                <?php 
    }
    ?>
                <?php 
    if (buckys_not_null($userID)) {
        ?>
                <div class="post-new-comment"> 
                    <a href="/profile.php?user=<?php 
        echo $userID;
        ?>
"><img src="<?php 
        echo BuckysUser::getProfileIcon($userID);
        ?>
" class="replyToPostIcons" /></a>
                    <form method="post" class="postcommentform" name="postcommentform" action="">
                        <input type="text" class="input" name="comment" placeholder="Write a comment...">
                        <input type="hidden" name="postID" value="<?php 
        echo $post['postID'];
        ?>
" />
                        <input type="submit" value="Post Comment" id="submit_post_reply" class="redButton" />
                        <?php 
        render_loading_wrapper();
        ?>
                    </form>
                </div>
                <?php 
    }
    ?>
                <?php 
    $comments = BuckysComment::getPostComments($post['postID']);
    echo render_post_comments($comments, $userID);
    if (count($comments) > 0 && BuckysComment::hasMoreComments($post['postID'], $comments[count($comments) - 1]['posted_date'])) {
        ?>
                                
                <a href="#" class="show-more-comments" data-last-date="<?php 
        echo $comments[count($comments) - 1]['posted_date'];
        ?>
" data-post-id="<?php 
        echo $post['postID'];
        ?>
">view more</a>
                <?php 
    }
    ?>
            </div>
            <input type="hidden" class="post-created-date" value="<?php 
    echo $post['post_date'];
    ?>
" />
        </div>    
    <?php 
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}
$userID = buckys_is_logged_in();
//Read Parameters (common)
$paramAction = 'view';
if (isset($_REQUEST['action'])) {
    $paramAction = get_secure_string($_REQUEST['action']);
}
$pageIns = new BuckysPage();
$pageFollowerIns = new BuckysPageFollower();
//Capture Ajax requests (such as save title, ... here)
if (is_numeric($userID)) {
    switch ($paramAction) {
        //============ Update About Content By Ajax =================//
        case 'updateAbout':
            $paramPageID = get_secure_integer($_REQUEST['pageID']);
            $paramContent = get_secure_string($_REQUEST['content']);
            $pageData = $pageIns->getPageByID($paramPageID);
            if ($pageData && $pageData['userID'] == $userID) {
                $data['about'] = $paramContent;
                $pageIns->updateData($paramPageID, $data);
                echo json_encode(['success' => 1, 'msg' => MSG_CONTENT_UPDATED_SUCCESS, 'content' => $paramContent, 'content_display' => render_enter_to_br($paramContent)]);
            } else {
                if (empty($pageData)) {
                    //No such page exists
                    echo json_encode(['success' => 0, 'msg' => MSG_NO_SUCH_PAGE]);
                } else {
                    //You don't have permission to update content
                    echo json_encode(['success' => 0, 'msg' => MSG_NO_PERMISSION_TO_EDIT_PAGE]);
                }
            }
            exit;
            //=============== Update Page Title by Ajax ===================//
    /**
     * @param $row
     * @param $userID
     * @return string
     */
    public static function getActivityHTML($row, $userID)
    {
        ob_start();
        $user = BuckysUser::getUserBasicInfo($row['userID']);
        $owner = BuckysUser::getUserBasicInfo($row['poster']);
        $pagePostFlag = false;
        if ($row['pageID'] != BuckysPost::INDEPENDENT_POST_PAGE_ID) {
            $pageIns = new BuckysPage();
            $pageData = $pageIns->getPageByID($row['pageID']);
        }
        if (isset($pageData)) {
            $pagePostFlag = true;
        }
        if ($pagePostFlag) {
            $objectLink = "/page.php?pid=" . $row['pageID'] . "&post=" . $row['objectID'];
            $authorLink = '/page.php?pid=' . $row['pageID'];
        } else {
            $objectLink = "/posts.php?user="******"&post=" . $row['objectID'];
            $authorLink = '/profile.php?user='******'poster'];
        }
        if ($row['activityType'] == 'like') {
            ?>
            <div class="activityComment">
                <?php 
            render_profile_link($user, 'replyToPostIcons');
            ?>
                <span>
                    <a href="/profile.php?user=<?php 
            echo $row['userID'];
            ?>
"
                        class="userName"><?php 
            echo $user['firstName'] . " " . $user['lastName'];
            ?>
</a>
                    liked <?php 
            echo $row['poster'] == $userID ? 'your' : "<a href='/profile.php?user="******"' class=\"userName\">" . $owner['firstName'] . " " . $owner['lastName'] . "'s</a>";
            ?>
                    <?php 
            switch ($row['type']) {
                case "image":
                    echo "<a href='" . $objectLink . "'>photo</a>";
                    break;
                case "video":
                    echo "<a href='" . $objectLink . "'>video</a>";
                    break;
                case "text":
                default:
                    echo "<a href='" . $objectLink . "'>post</a> ";
                    if (strlen(buckys_trunc_content($row['content'], 60)) > 0) {
                        echo '&#8220;' . buckys_trunc_content($row['content'], 60) . '&#8221;';
                    }
                    break;
            }
            ?>
                </span>
            </div>
            
            <?php 
        } else {
            if ($row['activityType'] == 'comment') {
                ?>
            <div class="activityComment">                
                <?php 
                render_profile_link($user, 'replyToPostIcons');
                ?>
                <span>
                    <a href="/profile.php?user=<?php 
                echo $row['userID'];
                ?>
"
                        class="userName"><?php 
                echo $user['firstName'] . " " . $user['lastName'];
                ?>
</a>
                    left a comment on 
                    <?php 
                if ($row['poster'] == $userID) {
                    echo 'your';
                } else {
                    if ($row['poster'] == $row['userID']) {
                        //Getting User Data
                        $tUinfo = BuckysUser::getUserBasicInfo($row['userID']);
                        switch (strtolower($tUinfo['gender'])) {
                            case 'male':
                                echo 'his';
                                break;
                            case 'female':
                                echo 'her';
                                break;
                                break;
                                echo 'their';
                                break;
                        }
                    } else {
                        echo "<a href='/profile.php?user="******"' class=\"userName\">" . $owner['firstName'] . " " . $owner['lastName'] . "'s</a>";
                    }
                }
                ?>
 
                    <?php 
                switch ($row['type']) {
                    case "image":
                        echo "<a href='" . $objectLink . "'>photo</a>";
                        break;
                    case "video":
                        echo "<a href='" . $objectLink . "'>video</a>";
                        break;
                    case "text":
                    default:
                        echo "<a href='" . $objectLink . "'>post</a> ";
                        break;
                }
                if (strlen(buckys_trunc_content($row['comment_content'], 25)) > 0) {
                    echo ': &#8220;' . buckys_trunc_content($row['comment_content'], 25) . '&#8221;';
                }
                ?>
                    
                </span>
            </div>
            <?php 
            }
        }
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }