/**
 * myaccount dashboard, recent video comments widget
 * 
 * @global object $userquery
 * @param array $widget
 * @return string
 */
function account_dashboard_recent_video_comments($widget)
{
    global $userquery;
    if (!userid()) {
        return false;
    }
    $configs = get_dashboard_widget_configs($widget['id']);
    $no_of_comments = $configs['number_of_comments'] ? $configs['number_of_comments'] : 15;
    $no_of_days = $configs['number_of_days'] ? $configs['number_of_days'] : 8;
    if ($userquery->udetails['total_videos'] > 0) {
        $fields = array('video' => array('videoid', 'videokey', 'title', 'description', 'views'), 'users' => get_user_fields(), 'comments' => array('comment_id', 'type', 'comment', 'userid', 'type_id', 'type_owner_id', 'date_added'));
        $fields = tbl_fields($fields);
        $query = "SELECT {$fields}  FROM " . tbl('comments') . " AS comments ";
        $query .= "LEFT JOIN " . tbl('video') . " AS video ON " . 'comments.type_id' . " = " . 'video.videoid' . " ";
        $query .= "LEFT JOIN " . tbl('users') . " AS users ON " . 'comments.userid' . " = " . 'users.userid' . " ";
        start_where();
        add_where(" " . 'comments.type_owner_id' . " = " . userid());
        add_where(" " . 'comments.type' . " = 'v' ");
        add_where(" " . 'comments.userid' . " <> " . userid());
        add_where(" " . 'comments.date_added' . " BETWEEN SYSDATE() - INTERVAL {$no_of_days} DAY AND SYSDATE() ");
        if (get_where()) {
            $query .= " WHERE " . get_where();
        }
        end_where();
        $query .= " ORDER BY " . 'comments.date_added' . " DESC LIMIT {$no_of_comments}";
        $comments = db_select($query);
    }
    // Comment Template
    $params['file'] = 'blocks/account/dashboard_comments.html';
    $params['widget'] = $widget;
    $params['comments'] = $comments;
    $params['configs'] = $configs;
    return fetch_template_file($params);
}
Exemple #2
0
         echo json_encode(array('error' => error()));
     }
     if (msg()) {
         $output = subscription_buttons($to);
         echo json_encode(array('success' => msg(), 'output' => $output));
     }
     break;
 case "subscription_options":
     $position = post('position') ? post('position') : "bottom";
     $list = subscriptions_types_list(post('user'));
     $params['file'] = 'subscriptions/options_list.html';
     $params['classes'] = 'subscriptions-options options-list ' . post('id') . ' option-position-' . $position;
     $params['id'] = post('user') . '-' . post('subscription') . '-list';
     $params['subscribed_content_list'] = $list;
     $params['name'] = post('name');
     $output = fetch_template_file($params);
     $return['output'] = $output;
     $return['success'] = true;
     $return['position'] = $position;
     echo json_encode($return);
     break;
 case "update_subscription_option":
     do_user_content_subscriptions(post('type'), post('owner'), post('action'), post('user'));
     if (error()) {
         echo json_encode(array('error' => error()));
     }
     if (msg()) {
         echo json_encode(array('msg' => msg()));
     }
     break;
 default:
/**
 * Display template changer for users if it is
 * allowed by administrator
 * 
 * @author Fawaz Tahir <*****@*****.**>
 * @global $cbtpl;
 */
function display_template_changer()
{
    if (ALLOW_STYLE_SELECT) {
        global $cbtpl;
        $templates = $cbtpl->get_templates(true);
        // Arrange templates according to name
        // A - Z
        if ($templates) {
            ksort($templates);
            $list = '';
            $fields = get_template_fields();
            $active_template = get_active_template();
            foreach ($templates as $template) {
                // Only get commonly used fields
                foreach ($fields as $field) {
                    if ($template[$field]) {
                        $tem[$field] = $template[$field];
                    }
                }
                $tem = apply_filters($tem, 'template_selection');
                if (!$tem['name'] or !$template['dir']) {
                    continue;
                }
                $params_item['file'] = 'blocks/template_changer/item.html';
                $params_item['template'] = $tem;
                $active = $active_template == $template['dir'] ? ' active' : '';
                $list .= '<li class="template-item' . $active . '" id="template-' . $template['dir'] . '" data-template="' . $template['dir'] . '">';
                $list .= '<a href="' . queryString('set_the_template=' . $template['dir'] . '', array('set_the_template')) . '">';
                $list .= fetch_template_file($params_item);
                $list .= '</a>';
                $list .= '</li>';
            }
        }
        $params['file'] = 'blocks/template_changer/template_changer.html';
        $params['templates_list'] = $list;
        return fetch_template_file($params);
    }
    return false;
}
function cb_get_user_channel_comments()
{
    global $usercontent;
    $user = $usercontent->get_current_user();
    $params['file'] = 'blocks/view_channel/channel_comments.html';
    $params['the_title'] = $params['heading'] = sprintf(lang("Comments on %s's channel"), name($user));
    $params['user'] = $user;
    return fetch_template_file($params);
}
/**
 * Show profile item
 * @global object $cbphoto
 * @param int $id
 * @return boolean
 */
function show_profile_item_photo($id)
{
    global $cbphoto;
    $photo = $cbphoto->get_photo($id, true);
    if ($photo) {
        $params['file'] = 'blocks/view_channel/photo_item.html';
        $params['photo'] = $photo;
        return fetch_template_file($params);
    } else {
        return false;
    }
}
/**
 * Show profile item
 * @global object $cbvid
 * @param int $id
 * @return boolean
 */
function show_profile_item_video($id)
{
    global $cbvid;
    $video = $cbvid->get_video_details($id);
    if ($video) {
        $params['file'] = 'blocks/view_channel/video_item.html';
        $params['video'] = $video;
        return fetch_template_file($params);
    } else {
        return false;
    }
}
function show_template_preview($template)
{
    //    global $cbtpl;
    //    $name = $template['name'];
    //    $preview = $cbtpl->get_preview_thumb( $template['dir'] );
    //
    //    if ( $preview ) {
    //        $name = "<span class='template-name'>$name</span>";
    //        $preview = "<img src='$preview' class='template-thumb' />";
    //        $author = "<span class='template-author'>".$template['author']."</span>";
    //
    //        $template['name'] = $preview.$name.$author;
    //    }
    //
    //    return $template;
    $params['file'] = 'blocks/template_changer/item.html';
    $params['template'] = $template;
    return fetch_template_file($params);
}
/**
 * This display the list of subscriptions of user.
 * Uses "subscriptions/user.html" for output.
 * 
 * Following things are assigned:
 * {$classes} - List classes
 * {$attributes} - List attributes
 * 
 * @author Fawaz Tahir <*****@*****.**>
 * @global object $userquery
 * @param int $userid
 * @return string
 */
function display_subscriptions_list($userid = null)
{
    global $userquery;
    if (is_null($userid)) {
        $userid = $userquery->udetails ? $userquery->udetails : userid();
    }
    if ($userid) {
        if (is_numeric($userid)) {
            $user = get_user_details($userid);
        } else {
            $user = $userid;
        }
    }
    if (!$user) {
        return false;
    }
    if (!has_subscriptions($user)) {
        return false;
    }
    $subscriptions = get_user_subscriptions($userid);
    if ($subscriptions) {
        end($subscriptions);
        $last_index = key($subscriptions);
        reset($subscriptions);
        $first_index = key($subscriptions);
        foreach ($subscriptions as $key => $subscription) {
            $params['file'] = 'subscriptions/user.html';
            $params['user'] = $subscription;
            $params['classes'] = 'subscription-user' . ($key == $first_index ? " subscription-user-first" : "") . ($key == $last_index ? " subscription-user-last" : "");
            $params['attributes'] = ' data-subscription-id="' . $subscription['subscription_id'] . '" data-userid="' . $subscription['subscribed_to'] . '" ';
            if (is_active_subscription($subscription)) {
                $params['classes'] .= " active active-subscription ";
            }
            $output .= fetch_template_file($params);
        }
        return $output;
    } else {
        return false;
    }
}