<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
if (!($userID = buckys_is_logged_in())) {
    buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR);
}
//Getting Activity Stream
$stream = BuckysPost::getUserPostsStream($userID);
//Get Activities
$activities = BuckysActivity::getActivities($userID);
if (!$activities) {
    $activities = [];
}
//Get Notifications
$notifications = BuckysActivity::getNotifications($userID);
//Mark the notifications to read
BuckysActivity::markReadNotifications($userID);
if (!$notifications) {
    $notifications = [];
}
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_javascript('uploadify/jquery.uploadify.js');
buckys_enqueue_javascript('jquery.Jcrop.js');
buckys_enqueue_javascript('jquery.color.js');
buckys_enqueue_javascript('posts.js');
buckys_enqueue_javascript('add_post.js');
buckys_enqueue_javascript('account.js');
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
if (!($userID = buckys_is_logged_in())) {
    exit;
}
if ($_POST['action'] == 'activity-notification') {
    $acount = isset($_POST['acount']) ? intval($_POST['acount']) : 15;
    $rows = BuckysActivity::getActivities($userID, $acount);
    $activities = '';
    foreach ($rows as $row) {
        $activities .= BuckysActivity::getActivityHTML($row, $userID);
    }
    if (count($rows) == $acount) {
        $activities .= "<div class='clear'></div><a href='#' class='view-more'>view more</a>";
    }
    $ncount = isset($_POST['ncount']) ? intval($_POST['ncount']) : 15;
    $rows = BuckysActivity::getNotifications($userID, $ncount);
    $notifications = '';
    foreach ($rows as $row) {
        $notifications .= BuckysActivity::getActivityHTML($row, $userID);
    }
    if (count($rows) == $ncount) {
        $notifications .= "<div class='clear'></div><a href='#' class='view-more'>view more</a>";
    }
    render_result_xml(['notifications' => $notifications, 'activities' => $activities]);
    exit;
}