Merge branch 'master' of dev.sourcefabric.org:campcaster

This commit is contained in:
Naomi 2011-01-26 14:18:18 -05:00
commit de3c95bd36
17 changed files with 188 additions and 91 deletions

View file

@ -9,7 +9,8 @@ class Application_Model_Nowplaying
$current = Schedule::GetCurrentlyPlaying($timeNow);
$next = Schedule::GetNextItems($timeNow, 10);
$columnHeaders = array(array("sTitle"=>"Date"),
$columnHeaders = array(array("sTitle"=>"type", "bVisible"=>false),
array("sTitle"=>"Date"),
array("sTitle"=>"Start"),
array("sTitle"=>"End"),
array("sTitle"=>"Duration"),
@ -21,19 +22,19 @@ class Application_Model_Nowplaying
$rows = array();
foreach ($previous as $item){
array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], "x" , "y"));
array_push($rows, array("p", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], "x" , $item["name"]));
}
foreach ($current as $item){
array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], "x" , "y"));
array_push($rows, array("c", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], "x" , $item["name"]));
}
foreach ($next as $item){
array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], "x" , "y"));
array_push($rows, array("n", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], "x" , $item["name"]));
}
return array("columnHeaders"=>$columnHeaders, "rows"=>$rows);

View file

@ -479,9 +479,13 @@ class Schedule {
public static function GetPreviousItems($timeNow, $prevCount = 1){
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT * FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft"
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, sdt.start_time, sdt.end_time"
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showSchedule] sst, $CC_CONFIG[showDays] sdt"
." WHERE (st.ends < TIMESTAMP '$timeNow')"
." AND (st.playlist_id = pt.id)"
." AND (st.file_id = ft.id)"
." AND (st.group_id = sst.group_id)"
." AND (sdt.show_id = sst.show_id)"
." ORDER BY st.starts DESC"
." LIMIT $prevCount";
$rows = $CC_DBC->GetAll($sql);
@ -491,21 +495,28 @@ class Schedule {
public static function GetCurrentlyPlaying($timeNow){
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT *, pt.name as playlistName FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt"
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, sdt.start_time, sdt.end_time"
." FROM $CC_CONFIG[scheduleTable] st,"
."$CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showSchedule] sst, $CC_CONFIG[showDays] sdt"
." WHERE (st.starts < TIMESTAMP '$timeNow')"
." AND (st.ends > TIMESTAMP '$timeNow')"
." AND (st.playlist_id = pt.id)"
." AND (st.file_id = ft.id)";
." AND (st.file_id = ft.id)"
." AND (st.group_id = sst.group_id)"
." AND (sdt.show_id = sst.show_id)";
$rows = $CC_DBC->GetAll($sql);
return $rows;
}
public static function GetNextItems($timeNow, $nextCount = 1) {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT *, pt.name as playlistName FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt"
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, sdt.start_time, sdt.end_time"
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showSchedule] sst, $CC_CONFIG[showDays] sdt"
." WHERE (st.starts > TIMESTAMP '$timeNow')"
." AND (st.file_id = ft.id)"
." AND (st.playlist_id = pt.id)"
." AND (st.file_id = ft.id)"
." AND (st.group_id = sst.group_id)"
." AND (sdt.show_id = sst.show_id)"
." ORDER BY st.starts"
." LIMIT $nextCount";
$rows = $CC_DBC->GetAll($sql);

View file

@ -416,7 +416,7 @@ class Show {
// must not delete shows in the past
if($show->getDbRepeats() && ($start_epoch < $date_epoch)) {
$sql = "DELETE FROM cc_show_days WHERE first_show >= '{$date}' ";
$sql = "DELETE FROM cc_show_days WHERE first_show >= '{$date}' AND show_id = '{$this->_showId}'";
$CC_DBC->query($sql);
//echo $sql;
@ -426,7 +426,7 @@ class Show {
$CC_DBC->query($sql);
//echo $sql;
$sql = "SELECT DISTINCT group_id FROM cc_schedule WHERE starts > '{$timestamp}' ";
$sql = "SELECT group_id FROM cc_show_schedule WHERE show_day >= '{$date}' AND show_id = '{$this->_showId}'";
$rows = $CC_DBC->GetAll($sql);
$sql_opt = array();

View file

@ -39,39 +39,37 @@ class User {
}
public static function getUsers($type=NULL, $search=NULL) {
public static function getUsers($type, $search=NULL) {
global $CC_DBC;
$sql;
$sql_gen = "SELECT id, login FROM cc_subjs ";
$sql_gen = "SELECT id AS value, login AS label FROM cc_subjs ";
$sql = $sql_gen;
if(is_array($type)) {
for($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
}
else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen ." WHERE (". $sql_type.")";
if(!is_null($type)){
if(is_array($type)) {
for($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
}
else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen ." WHERE ". $sql_type;
}
if(!is_null($search)) {
$like = "login ILIKE '{$search}'";
}
$like = "login ILIKE '%{$search}%'";
$sql = $sql . " ORDER BY login";
$sql = $sql . " AND ".$like." ORDER BY login";
}
return $CC_DBC->GetAll($sql);
}
public static function getHosts() {
return User::getUsers(array('H', 'A'));
public static function getHosts($search=NULL) {
return User::getUsers(array('H', 'A'), $search);
}
}