Example #1
0
 /**
  * Function used to get playlists
  */
 function get_playlists($params = array())
 {
     global $cb_columns, $db;
     $fields = array('playlists' => $cb_columns->object('playlists')->get_columns());
     $order = $params['order'];
     $limit = $params['limit'];
     $main_query = $query = "SELECT " . table_fields($fields) . " FROM " . table('playlists');
     $condition = "playlists.playlist_type = 'v'";
     if (!has_access('admin_access')) {
         $condition .= $condition ? " AND " : "";
         $condition .= "playlists.privacy = 'public'";
     } else {
         if ($params['privacy']) {
             $condition .= $condition ? " AND " : "";
             $condition .= " playlists.privacy = '" . mysql_clean($params['privacy']) . "' ";
         }
     }
     if ($params['category']) {
         $condition .= $condition ? " AND " : "";
         $condition .= " playlists.category = '" . $params['category'] . "' ";
     }
     if ($params['include']) {
         $ids = is_array($params['include']) ? $params['include'] : explode(',', $params['include']);
         if (is_array($ids) and !empty($ids)) {
             $condition .= $condition ? " AND " : "";
             $ids = implode(",", array_map('trim', $ids));
             $condition .= " playlists.playlist_id IN ({$ids}) ";
         }
     }
     if ($params['exclude']) {
         $ids = is_array($params['exclude']) ? $params['exclude'] : explode(',', $params['exclude']);
         if (is_array($ids) and !empty($ids)) {
             $condition .= $condition ? " AND " : "";
             $ids = implode(",", array_map('trim', $ids));
             $condition .= " playlists.playlist_id NOT IN ({$ids}) ";
         }
     }
     if ($params['date_span']) {
         $condition .= $condition ? " AND " : "";
         $column = $params['date_span_column'] ? trim($params['date_span_column']) : 'playlists.date_added';
         $condition .= cbsearch::date_margin($column, $params['date_span']);
     }
     if ($params['last_update']) {
         $condition .= $condition ? " AND " : "";
         $condition .= cbsearch::date_margin('playlists.last_update', $params['last_update']);
     }
     if ($params['user']) {
         $condition .= $condition ? " AND " : "";
         $condition .= " playlists.userid = '" . $params['user'] . "' ";
     }
     if ($params['has_items']) {
         $condition .= $condition ? " AND " : "";
         $condition .= " playlists.total_items > '0' ";
     }
     if ($params['count_only']) {
         $result = $db->count(cb_sql_table('playlists'), 'playlist_id');
         return $result;
     }
     if ($condition) {
         $query .= " WHERE " . $condition;
     }
     $order = " ORDER BY " . ($order ? trim($order) : "playlists.date_added DESC");
     $limit = $limit ? " LIMIT {$limit} " : "";
     $query .= $order . $limit;
     $query_id = cb_query_id($query);
     $action_array = array('query_id' => $query_id);
     $data = cb_do_action('select_playlists', array_merge($action_array, $params));
     if ($data) {
         return $data;
     }
     $results = select($query);
     if (!empty($results)) {
         cb_do_action('return_playlists', array('query_id' => $query_id, 'results' => $results));
         return $results;
     }
     return false;
 }
Example #2
0
function view_playlist($playlist_id)
{
    $playlist_link = BASEURL;
    if (is_array($playlist_id) and isset($playlist_id['playlist_id'])) {
        $playlist = $playlist_id;
    } else {
        $playlist = get_playlist($playlist_id);
    }
    if (empty($playlist)) {
        return BASEURL;
    }
    $is_seo = SEO;
    $data = cb_do_action('view_playlist_link', array('playlist' => $playlist, 'seo_enabled' => $is_seo));
    if ($is_seo) {
        $playlist_link .= '/list/' . $playlist['playlist_id'] . '/' . SEO($playlist['playlist_name']);
    } else {
        $playlist_link .= '/view_playlist.php?list=' . $playlist_id;
    }
    $data = cb_do_action('view_playlist_link', array('playlist' => $playlist, 'seo_enabled' => $is_seo, 'playlist_link' => $playlist_link));
    if ($data) {
        return $data;
    }
    return $playlist_link;
}
Example #3
0
 /**
  * Function used to get playlist items
  */
 function get_playlist_items($playlist_id, $order = null, $limit = -1)
 {
     global $db, $cb_columns;
     $fields = array('playlist_items' => $cb_columns->object('playlist_items')->temp_change('date_added', 'item_added')->get_columns(), 'playlists' => $cb_columns->object('playlists')->temp_remove('first_item,cover')->temp_change('date_added,description,tags,category', 'playlist_added,playlist_description,playlist_tags,playlist_category')->get_columns(), 'video' => $cb_columns->object('videos')->get_columns());
     $query = "SELECT " . table_fields($fields) . " FROM " . table('playlist_items');
     $query .= " LEFT JOIN " . table('playlists') . " ON playlist_items.playlist_id = playlists.playlist_id";
     $query .= " LEFT JOIN " . table('video') . " ON playlist_items.object_id = video.videoid";
     $query .= " WHERE playlist_items.playlist_id = '" . $playlist_id . "' ";
     if (!is_null($order)) {
         $query .= "ORDER BY " . $order;
     }
     if ($limit > 0) {
         $query .= " LIMIT " . $limit;
     }
     $query_id = cb_query_id($query);
     $data = cb_do_action('select_playlist_items', array('query_id' => $query_id, 'playlist_id' => $playlist_id));
     if ($data) {
         return $data;
     }
     $data = select($query);
     if ($data) {
         cb_do_action('return_playlist_items', array('query_id' => $query_id, 'results' => $data));
         return $data;
     }
     return false;
 }
Example #4
0
<?php

/*
 ******************************************************************
 | Copyright (c) 2007-2009 Clip-Bucket.com. All rights reserved.
 | @ Author : ArslanHassan
 | @ Software : ClipBucket , © PHPBucket.com
 *******************************************************************
*/
define('THIS_PAGE', 'view_playlist');
define('PARENT_PAGE', 'videos');
require 'includes/config.inc.php';
$pages->page_redir();
$list_id = mysql_clean($_GET['list_id']);
$playlist = get_playlist($list_id);
if (is_playlist_viewable($playlist) and isset($playlist)) {
    $items = get_playlist_items($list_id);
    if (!empty($items)) {
        $playlist['videos'] = $items;
    }
    cb_do_action('view_playlist', array('playlist' => $playlist));
    assign('playlist', $playlist);
    subtitle($playlist['playlist_name']);
} else {
    $Cbucket->show_page = false;
}
//Displaying The Template
template_files('view_playlist.html');
display_it();