Merge branch 'master' of dev.sourcefabric.org:campcaster
This commit is contained in:
commit
e902d3b3d4
|
@ -397,8 +397,8 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
if($user->isAdmin()) {
|
if ($user->isAdmin()) {
|
||||||
Show::addShow($data);
|
Show::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//send back a new form for the user.
|
//send back a new form for the user.
|
||||||
|
|
|
@ -102,27 +102,9 @@ class Playlist {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function Insert($p_values)
|
|
||||||
|
public static function Delete($id)
|
||||||
{
|
{
|
||||||
// Create the StoredPlaylist object
|
|
||||||
$storedPlaylist = new Playlist();
|
|
||||||
$storedPlaylist->name = isset($p_values['filename']) ? $p_values['filename'] : date("H:i:s");
|
|
||||||
$storedPlaylist->mtime = new DateTime("now");
|
|
||||||
|
|
||||||
$pl = new CcPlaylist();
|
|
||||||
$pl->setDbName($storedPlaylist->name);
|
|
||||||
$pl->setDbState("incomplete");
|
|
||||||
$pl->setDbMtime($storedPlaylist->mtime);
|
|
||||||
$pl->save();
|
|
||||||
|
|
||||||
$storedPlaylist->id = $pl->getDbId();
|
|
||||||
$storedPlaylist->setState('ready');
|
|
||||||
|
|
||||||
return $storedPlaylist->id;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function Delete($id) {
|
|
||||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||||
if($pl === NULL)
|
if($pl === NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -207,7 +189,7 @@ class Playlist {
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||||
if($pl === NULL)
|
if ($pl === NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return $pl->getDbName();
|
return $pl->getDbName();
|
||||||
|
@ -395,18 +377,27 @@ class Playlist {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of Playlist object and insert empty file
|
* Create instance of a Playlist object.
|
||||||
*
|
*
|
||||||
* @param string $fname
|
* @param string $p_fname
|
||||||
* name of new file
|
* Name of the playlist
|
||||||
* @return instance of Playlist object
|
* @return Playlist
|
||||||
*/
|
*/
|
||||||
public function create($fname=NULL)
|
public function create($p_fname=NULL)
|
||||||
{
|
{
|
||||||
$values = array("filename" => $fname);
|
$this->name = !empty($p_fname) ? $p_fname : date("H:i:s");
|
||||||
$pl_id = Playlist::Insert($values);
|
$this->mtime = new DateTime("now");
|
||||||
$this->id = $pl_id;
|
|
||||||
return $this->id;
|
$pl = new CcPlaylist();
|
||||||
|
$pl->setDbName($this->name);
|
||||||
|
$pl->setDbState("incomplete");
|
||||||
|
$pl->setDbMtime($this->mtime);
|
||||||
|
$pl->save();
|
||||||
|
|
||||||
|
$this->id = $pl->getDbId();
|
||||||
|
$this->setState('ready');
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,8 @@ class ScheduleGroup {
|
||||||
/**
|
/**
|
||||||
* Add a music clip or playlist to the schedule.
|
* Add a music clip or playlist to the schedule.
|
||||||
*
|
*
|
||||||
|
* @param int $p_showInstance
|
||||||
|
* ID of the show.
|
||||||
* @param $p_datetime
|
* @param $p_datetime
|
||||||
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
|
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
|
||||||
* @param $p_audioFileId
|
* @param $p_audioFileId
|
||||||
|
@ -40,7 +42,7 @@ class ScheduleGroup {
|
||||||
* Return PEAR_Error if the item could not be added.
|
* Return PEAR_Error if the item could not be added.
|
||||||
* Error code 555 is a scheduling conflict.
|
* Error code 555 is a scheduling conflict.
|
||||||
*/
|
*/
|
||||||
public function add($show_instance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
|
public function add($p_showInstance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
if (!is_null($p_audioFileId)) {
|
if (!is_null($p_audioFileId)) {
|
||||||
|
@ -64,7 +66,7 @@ class ScheduleGroup {
|
||||||
|
|
||||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||||
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
|
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
|
||||||
." VALUES ($show_instance, TIMESTAMP '$p_datetime', "
|
." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', "
|
||||||
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
|
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
|
||||||
." '$length',"
|
." '$length',"
|
||||||
." {$this->groupId}, $p_audioFileId, '$length')";
|
." {$this->groupId}, $p_audioFileId, '$length')";
|
||||||
|
@ -103,7 +105,7 @@ class ScheduleGroup {
|
||||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||||
." (instance_id, playlist_id, starts, ends, group_id, file_id,"
|
." (instance_id, playlist_id, starts, ends, group_id, file_id,"
|
||||||
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
||||||
." VALUES ($show_instance, $p_playlistId, TIMESTAMP '$itemStartTime', "
|
." VALUES ($p_showInstance, $p_playlistId, TIMESTAMP '$itemStartTime', "
|
||||||
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
|
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
|
||||||
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
|
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
|
||||||
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
||||||
|
|
|
@ -58,6 +58,11 @@ class Show {
|
||||||
$show->setDbBackgroundColor($backgroundColor);
|
$show->setDbBackgroundColor($backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->_showId;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHosts()
|
public function getHosts()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
@ -93,8 +98,17 @@ class Show {
|
||||||
RabbitMq::PushSchedule();
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
//end dates are non inclusive.
|
|
||||||
public static function addShow($data)
|
/**
|
||||||
|
* Create a show.
|
||||||
|
*
|
||||||
|
* Note: end dates are non inclusive.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return int
|
||||||
|
* Show ID
|
||||||
|
*/
|
||||||
|
public static function create($data)
|
||||||
{
|
{
|
||||||
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
|
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
|
||||||
|
|
||||||
|
@ -106,11 +120,11 @@ class Show {
|
||||||
$r = $con->query($sql);
|
$r = $con->query($sql);
|
||||||
$startDow = $r->fetchColumn(0);
|
$startDow = $r->fetchColumn(0);
|
||||||
|
|
||||||
if($data['add_show_no_end']) {
|
if ($data['add_show_no_end']) {
|
||||||
$endDate = NULL;
|
$endDate = NULL;
|
||||||
$data['add_show_repeats'] = 1;
|
$data['add_show_repeats'] = 1;
|
||||||
}
|
}
|
||||||
else if($data['add_show_repeats']) {
|
else if ($data['add_show_repeats']) {
|
||||||
$sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' ";
|
$sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' ";
|
||||||
$r = $con->query($sql);
|
$r = $con->query($sql);
|
||||||
$endDate = $r->fetchColumn(0);
|
$endDate = $r->fetchColumn(0);
|
||||||
|
@ -122,15 +136,15 @@ class Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
//only want the day of the week from the start date.
|
//only want the day of the week from the start date.
|
||||||
if(!$data['add_show_repeats']) {
|
if (!$data['add_show_repeats']) {
|
||||||
$data['add_show_day_check'] = array($startDow);
|
$data['add_show_day_check'] = array($startDow);
|
||||||
}
|
}
|
||||||
else if($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||||
$data['add_show_day_check'] = array($startDow);
|
$data['add_show_day_check'] = array($startDow);
|
||||||
}
|
}
|
||||||
|
|
||||||
//find repeat type or set to a non repeating show.
|
//find repeat type or set to a non repeating show.
|
||||||
if($data['add_show_repeats']) {
|
if ($data['add_show_repeats']) {
|
||||||
$repeat_type = $data["add_show_repeat_type"];
|
$repeat_type = $data["add_show_repeat_type"];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -147,7 +161,7 @@ class Show {
|
||||||
|
|
||||||
$showId = $show->getDbId();
|
$showId = $show->getDbId();
|
||||||
|
|
||||||
if($data['add_show_record']){
|
if ($data['add_show_record']){
|
||||||
$isRecorded = 1;
|
$isRecorded = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -155,7 +169,7 @@ class Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
//don't set day for monthly repeat type, it's invalid.
|
//don't set day for monthly repeat type, it's invalid.
|
||||||
if($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
|
if ($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
|
||||||
$showDay = new CcShowDays();
|
$showDay = new CcShowDays();
|
||||||
$showDay->setDbFirstShow($data['add_show_start_date']);
|
$showDay->setDbFirstShow($data['add_show_start_date']);
|
||||||
$showDay->setDbLastShow($endDate);
|
$showDay->setDbLastShow($endDate);
|
||||||
|
@ -168,7 +182,7 @@ class Show {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach ($data['add_show_day_check'] as $day) {
|
foreach ($data['add_show_day_check'] as $day) {
|
||||||
if($startDow !== $day){
|
if ($startDow !== $day){
|
||||||
|
|
||||||
if ($startDow > $day)
|
if ($startDow > $day)
|
||||||
$daysAdd = 6 - $startDow + 1 + $day;
|
$daysAdd = 6 - $startDow + 1 + $day;
|
||||||
|
@ -183,7 +197,7 @@ class Show {
|
||||||
$start = $data['add_show_start_date'];
|
$start = $data['add_show_start_date'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strtotime($start) < strtotime($endDate) || is_null($endDate)) {
|
if (strtotime($start) < strtotime($endDate) || is_null($endDate)) {
|
||||||
$showDay = new CcShowDays();
|
$showDay = new CcShowDays();
|
||||||
$showDay->setDbFirstShow($start);
|
$showDay->setDbFirstShow($start);
|
||||||
$showDay->setDbLastShow($endDate);
|
$showDay->setDbLastShow($endDate);
|
||||||
|
@ -199,11 +213,11 @@ class Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
//adding rows to cc_show_rebroadcast
|
//adding rows to cc_show_rebroadcast
|
||||||
if($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type != -1) {
|
if ($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type != -1) {
|
||||||
|
|
||||||
for($i=1; $i<=5; $i++) {
|
for ($i=1; $i<=5; $i++) {
|
||||||
|
|
||||||
if($data['add_show_rebroadcast_date_'.$i]) {
|
if ($data['add_show_rebroadcast_date_'.$i]) {
|
||||||
$showRebroad = new CcShowRebroadcast();
|
$showRebroad = new CcShowRebroadcast();
|
||||||
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
|
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
|
||||||
$showRebroad->setDbStartTime($data['add_show_rebroadcast_time_'.$i]);
|
$showRebroad->setDbStartTime($data['add_show_rebroadcast_time_'.$i]);
|
||||||
|
@ -212,11 +226,11 @@ class Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type == -1){
|
else if ($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type == -1){
|
||||||
|
|
||||||
for($i=1; $i<=5; $i++) {
|
for ($i=1; $i<=5; $i++) {
|
||||||
|
|
||||||
if($data['add_show_rebroadcast_absolute_date_'.$i]) {
|
if ($data['add_show_rebroadcast_absolute_date_'.$i]) {
|
||||||
$sql = "SELECT date '{$data['add_show_rebroadcast_absolute_date_'.$i]}' - date '{$data['add_show_start_date']}' ";
|
$sql = "SELECT date '{$data['add_show_rebroadcast_absolute_date_'.$i]}' - date '{$data['add_show_start_date']}' ";
|
||||||
$r = $con->query($sql);
|
$r = $con->query($sql);
|
||||||
$offset_days = $r->fetchColumn(0);
|
$offset_days = $r->fetchColumn(0);
|
||||||
|
@ -230,7 +244,7 @@ class Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_array($data['add_show_hosts'])) {
|
if (is_array($data['add_show_hosts'])) {
|
||||||
//add selected hosts to cc_show_hosts table.
|
//add selected hosts to cc_show_hosts table.
|
||||||
foreach ($data['add_show_hosts'] as $host) {
|
foreach ($data['add_show_hosts'] as $host) {
|
||||||
$showHost = new CcShowHosts();
|
$showHost = new CcShowHosts();
|
||||||
|
@ -240,10 +254,19 @@ class Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Show::populateShowUntilLastGeneratedDate($showId);
|
Show::populateShowUntil($showId);
|
||||||
RabbitMq::PushSchedule();
|
RabbitMq::PushSchedule();
|
||||||
|
return $showId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $start_timestamp
|
||||||
|
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||||
|
* @param string $end_timestamp
|
||||||
|
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||||
|
* @param unknown_type $excludeInstance
|
||||||
|
* @param boolean $onlyRecord
|
||||||
|
*/
|
||||||
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
|
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
@ -301,7 +324,7 @@ class Show {
|
||||||
|
|
||||||
$next_date = $first_show." ".$start_time;
|
$next_date = $first_show." ".$start_time;
|
||||||
|
|
||||||
if(strtotime($next_date) < strtotime($end_timestamp)) {
|
if (strtotime($next_date) < strtotime($end_timestamp)) {
|
||||||
|
|
||||||
$start = $next_date;
|
$start = $next_date;
|
||||||
|
|
||||||
|
@ -345,7 +368,8 @@ class Show {
|
||||||
|
|
||||||
//for a show with repeat_type == 0,1,2
|
//for a show with repeat_type == 0,1,2
|
||||||
private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||||
$start_time, $duration, $day, $record, $end_timestamp, $interval) {
|
$start_time, $duration, $day, $record, $end_timestamp, $interval)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
if(isset($next_pop_date)) {
|
if(isset($next_pop_date)) {
|
||||||
|
@ -422,53 +446,81 @@ class Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//used to catch up a newly added show
|
|
||||||
private static function populateShowUntilLastGeneratedDate($show_id) {
|
|
||||||
global $CC_DBC;
|
|
||||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$show_id}";
|
/**
|
||||||
|
* Generate repeating show instances for a single show up to the given date.
|
||||||
|
* If no date is given, use the one in the user's preferences, which is stored
|
||||||
|
* automatically by FullCalendar as the furthest date in the future the user
|
||||||
|
* has looked at.
|
||||||
|
*
|
||||||
|
* @param int $p_showId
|
||||||
|
* @param string $p_date
|
||||||
|
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||||
|
*/
|
||||||
|
public static function populateShowUntil($p_showId, $p_date = NULL)
|
||||||
|
{
|
||||||
|
global $CC_DBC;
|
||||||
|
if (is_null($p_date)) {
|
||||||
|
$p_date = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$p_showId}";
|
||||||
$res = $CC_DBC->GetAll($sql);
|
$res = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
foreach($res as $row) {
|
foreach ($res as $row) {
|
||||||
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
||||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $showsPopUntil);
|
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function populateShowsUntil($pop_timestamp, $end_timestamp) {
|
/**
|
||||||
|
* Generate all the repeating shows in the given range.
|
||||||
|
*
|
||||||
|
* @param string $p_startTimestamp
|
||||||
|
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||||
|
* @param string $p_endTimestamp
|
||||||
|
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||||
|
*/
|
||||||
|
public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
if($pop_timestamp != "") {
|
if ($pop_timestamp != "") {
|
||||||
$sql = "SELECT * FROM cc_show_days
|
$sql = "SELECT * FROM cc_show_days
|
||||||
WHERE last_show IS NULL
|
WHERE last_show IS NULL
|
||||||
OR first_show < '{$end_timestamp}' AND last_show > '{$pop_timestamp}'";
|
OR first_show < '{$p_endTimestamp}' AND last_show > '{$p_startTimestamp}'";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$today_timestamp = date("Y-m-d");
|
$today_timestamp = date("Y-m-d");
|
||||||
|
|
||||||
$sql = "SELECT * FROM cc_show_days
|
$sql = "SELECT * FROM cc_show_days
|
||||||
WHERE last_show IS NULL
|
WHERE last_show IS NULL
|
||||||
OR first_show < '{$end_timestamp}' AND last_show > '{$today_timestamp}'";
|
OR first_show < '{$p_endTimestamp}' AND last_show > '{$today_timestamp}'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $CC_DBC->GetAll($sql);
|
$res = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
foreach($res as $row) {
|
foreach ($res as $row) {
|
||||||
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
||||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $end_timestamp);
|
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_endTimestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFullCalendarEvents($start, $end, $editable=false) {
|
/**
|
||||||
|
*
|
||||||
|
* @param string $start
|
||||||
|
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||||
|
* @param string $end
|
||||||
|
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||||
|
* @param boolean $editable
|
||||||
|
*/
|
||||||
|
public static function getFullCalendarEvents($start, $end, $editable=false)
|
||||||
|
{
|
||||||
$events = array();
|
$events = array();
|
||||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||||
|
|
||||||
//if fullcalendar is requesting shows past our previous populated until date, generate shows up until this point.
|
//if fullcalendar is requesting shows past our previous populated until date, generate shows up until this point.
|
||||||
if($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
|
if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
|
||||||
|
Show::populateAllShowsInRange($showsPopUntil, $end);
|
||||||
Show::populateShowsUntil($showsPopUntil, $end);
|
|
||||||
Application_Model_Preference::SetShowsPopulatedUntil($end);
|
Application_Model_Preference::SetShowsPopulatedUntil($end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +528,7 @@ class Show {
|
||||||
|
|
||||||
$today_timestamp = date("Y-m-d H:i:s");
|
$today_timestamp = date("Y-m-d H:i:s");
|
||||||
foreach ($shows as $show) {
|
foreach ($shows as $show) {
|
||||||
if($editable && strtotime($today_timestamp) < strtotime($show["starts"]))
|
if ($editable && strtotime($today_timestamp) < strtotime($show["starts"]))
|
||||||
$events[] = Show::makeFullCalendarEvent($show, array("editable" => true));
|
$events[] = Show::makeFullCalendarEvent($show, array("editable" => true));
|
||||||
else
|
else
|
||||||
$events[] = Show::makeFullCalendarEvent($show);
|
$events[] = Show::makeFullCalendarEvent($show);
|
||||||
|
@ -696,6 +748,10 @@ class ShowInstance {
|
||||||
RabbitMq::PushSchedule();
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the group ID for this show.
|
||||||
|
*
|
||||||
|
*/
|
||||||
private function getLastGroupId()
|
private function getLastGroupId()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
@ -704,13 +760,18 @@ class ShowInstance {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a playlist as the last item of the current show.
|
||||||
|
*
|
||||||
|
* @param int $plId
|
||||||
|
* Playlist ID.
|
||||||
|
*/
|
||||||
public function addPlaylistToShow($plId)
|
public function addPlaylistToShow($plId)
|
||||||
{
|
{
|
||||||
$sched = new ScheduleGroup();
|
$sched = new ScheduleGroup();
|
||||||
$lastGroupId = $this->getLastGroupId();
|
$lastGroupId = $this->getLastGroupId();
|
||||||
|
|
||||||
if(is_null($lastGroupId)) {
|
if (is_null($lastGroupId)) {
|
||||||
|
|
||||||
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId);
|
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -719,13 +780,17 @@ class ShowInstance {
|
||||||
RabbitMq::PushSchedule();
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a media file as the last item in the show.
|
||||||
|
*
|
||||||
|
* @param int $file_id
|
||||||
|
*/
|
||||||
public function addFileToShow($file_id)
|
public function addFileToShow($file_id)
|
||||||
{
|
{
|
||||||
$sched = new ScheduleGroup();
|
$sched = new ScheduleGroup();
|
||||||
$lastGroupId = $this->getLastGroupId();
|
$lastGroupId = $this->getLastGroupId();
|
||||||
|
|
||||||
if(is_null($lastGroupId)) {
|
if (is_null($lastGroupId)) {
|
||||||
|
|
||||||
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id);
|
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -734,12 +799,18 @@ class ShowInstance {
|
||||||
RabbitMq::PushSchedule();
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scheduleShow($plIds) {
|
/**
|
||||||
|
* Add the given playlists to the show.
|
||||||
foreach($plIds as $plId) {
|
*
|
||||||
$this->addPlaylistToShow($plId);
|
* @param array $plIds
|
||||||
}
|
* An array of playlist IDs.
|
||||||
}
|
*/
|
||||||
|
public function scheduleShow($plIds)
|
||||||
|
{
|
||||||
|
foreach ($plIds as $plId) {
|
||||||
|
$this->addPlaylistToShow($plId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function removeGroupFromShow($group_id)
|
public function removeGroupFromShow($group_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
<?php
|
||||||
|
set_include_path(__DIR__.'/..' . PATH_SEPARATOR . get_include_path());
|
||||||
|
set_include_path(__DIR__.'/../../../library' . PATH_SEPARATOR . get_include_path());
|
||||||
|
require_once __DIR__.'/../Shows.php';
|
||||||
|
require_once __DIR__.'/../StoredFile.php';
|
||||||
|
require_once __DIR__.'/../Playlist.php';
|
||||||
|
require_once __DIR__.'/../Schedule.php';
|
||||||
|
require_once __DIR__.'/../Preference.php';
|
||||||
|
require_once __DIR__.'/../RabbitMq.php';
|
||||||
|
require_once __DIR__.'/../../configs/conf.php';
|
||||||
|
require_once __DIR__.'/../../../install/include/AirtimeIni.php';
|
||||||
|
require_once __DIR__.'/../../../install/include/AirtimeInstall.php';
|
||||||
|
require_once __DIR__.'/../../../library/propel/runtime/lib/Propel.php';
|
||||||
|
|
||||||
|
Propel::init(__DIR__.'/../../configs/airtime-conf.php');
|
||||||
|
|
||||||
|
|
||||||
|
AirtimeInstall::DbConnect(true);
|
||||||
|
|
||||||
|
// Create a playlist
|
||||||
|
$playlist = new Playlist();
|
||||||
|
$playlist->create("Calendar Load test playlist ".uniqid());
|
||||||
|
|
||||||
|
// Add a file
|
||||||
|
$values = array("filepath" => __DIR__."/test10001.mp3");
|
||||||
|
$storedFile = StoredFile::Insert($values, false);
|
||||||
|
$result = $playlist->addAudioClip($storedFile->getId());
|
||||||
|
|
||||||
|
// Add a file
|
||||||
|
$values = array("filepath" => __DIR__."/test10002.mp3");
|
||||||
|
$storedFile2 = StoredFile::Insert($values, false);
|
||||||
|
|
||||||
|
$result = $playlist->addAudioClip($storedFile2->getId());
|
||||||
|
$result = $playlist->addAudioClip($storedFile2->getId());
|
||||||
|
|
||||||
|
echo "Created playlist ".$playlist->getName()." with ID ".$playlist->getId()."\n";
|
||||||
|
|
||||||
|
// Create the shows
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
$currentDate = date("Y\\-m\\-d");
|
||||||
|
|
||||||
|
$year = date("Y");
|
||||||
|
$month = date("m");
|
||||||
|
$day = date("d");
|
||||||
|
|
||||||
|
$nextDay = $currentDate;
|
||||||
|
|
||||||
|
#echo $currentDate;
|
||||||
|
$currentHour = date("H");
|
||||||
|
$setHour = $currentHour + 1;
|
||||||
|
|
||||||
|
$showNumber = 1;
|
||||||
|
for ($days=1; $days<100; $days=$days+1)
|
||||||
|
{
|
||||||
|
// Adding shows until the end of the day
|
||||||
|
while ($setHour < 24)
|
||||||
|
{
|
||||||
|
echo 'Adding show: '.$nextDay. ' '.$setHour.":00\n";
|
||||||
|
$data['add_show_name'] = 'automated show '.$showNumber;
|
||||||
|
$data['add_show_start_date'] = $nextDay;
|
||||||
|
$data['add_show_start_time'] = $setHour.':00';
|
||||||
|
$showNumber = $showNumber + 1;
|
||||||
|
$data['add_show_duration'] = '1:00';
|
||||||
|
$data['add_show_no_end'] = 0;
|
||||||
|
$data['add_show_repeats'] = 0;
|
||||||
|
$data['add_show_description'] = 'automated show';
|
||||||
|
$data['add_show_url'] = 'http://www.OfirGal.com';
|
||||||
|
$data['add_show_color'] = "";
|
||||||
|
$data['add_show_background_color'] = "";
|
||||||
|
$data['add_show_record'] = 0;
|
||||||
|
$data['add_show_hosts'] ="";
|
||||||
|
$showId = Show::create($data);
|
||||||
|
Show::populateShowUntil($showId, "2012-01-01 00:00:00");
|
||||||
|
|
||||||
|
// populating the show with a playlist
|
||||||
|
$show = new ShowInstance($showId);
|
||||||
|
$show->scheduleShow(array($playlist->getId()));
|
||||||
|
|
||||||
|
$setHour = $setHour + 1;
|
||||||
|
}
|
||||||
|
// set the next day
|
||||||
|
$setHour = 0;
|
||||||
|
if ($day<30) {
|
||||||
|
$day = $day + 1;
|
||||||
|
} else {
|
||||||
|
$day = 1;
|
||||||
|
if ($month<12)
|
||||||
|
{
|
||||||
|
$month = $month + 1;
|
||||||
|
} else {
|
||||||
|
$month = 1;
|
||||||
|
$year = $year + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$nextDay = $year."-".$month."-".$day;
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
var defaults = {
|
var defaults = {
|
||||||
updatePeriod: 20, //seconds
|
updatePeriod: 20, //seconds
|
||||||
sourceDomain: "http://localhost/", //where to get show status from
|
sourceDomain: "http://localhost/", //where to get show status from
|
||||||
|
text: {onAirToday:"On air today"}
|
||||||
};
|
};
|
||||||
var options = $.extend(defaults, options);
|
var options = $.extend(defaults, options);
|
||||||
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
||||||
|
@ -30,7 +31,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
tableString = "";
|
tableString = "";
|
||||||
tableString += "<h3>On air today</h3>";
|
tableString += "<h3>"+options.text.onAirToday+"</h3>";
|
||||||
tableString += "<table width='100%' border='0' cellspacing='0' cellpadding='0' class='widget widget no-playing-list small'>"+
|
tableString += "<table width='100%' border='0' cellspacing='0' cellpadding='0' class='widget widget no-playing-list small'>"+
|
||||||
"<tbody>";
|
"<tbody>";
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
tableString +=
|
tableString +=
|
||||||
"<tr>" +
|
"<tr>" +
|
||||||
"<td class='time'>"+shows[i].getRange()+"</td>" +
|
"<td class='time'>"+shows[i].getRange()+"</td>" +
|
||||||
"<td><a href='#'>"+shows[i].getName()+"</a> <a href='#' class='listen'>Listen</a></td>" +
|
"<td><a href='#'>"+shows[i].getName()+"</a></td>" +
|
||||||
"</tr>";
|
"</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +56,13 @@
|
||||||
updateWidget();
|
updateWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||||
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
}, error:airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -72,7 +76,8 @@
|
||||||
var defaults = {
|
var defaults = {
|
||||||
updatePeriod: 5, //seconds
|
updatePeriod: 5, //seconds
|
||||||
sourceDomain: "http://localhost/", //where to get show status from
|
sourceDomain: "http://localhost/", //where to get show status from
|
||||||
audioStreamSource: "http://localhost:8000/airtime.mp3" //where to get audio stream from
|
audioStreamSource: "http://localhost:8000/airtime.mp3", //where to get audio stream from
|
||||||
|
text: {listenLive:"Listen WADR Live", onAirNow:"On Air Now", offline:"Offline", current:"Current", next:"Next"}
|
||||||
};
|
};
|
||||||
var options = $.extend(defaults, options);
|
var options = $.extend(defaults, options);
|
||||||
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
||||||
|
@ -86,7 +91,7 @@
|
||||||
var currentShow = sd.getCurrentShow();
|
var currentShow = sd.getCurrentShow();
|
||||||
var nextShows = sd.getNextShows();
|
var nextShows = sd.getNextShows();
|
||||||
|
|
||||||
var showStatus = "Offline";
|
var showStatus = options.text.offline;
|
||||||
var currentShowName = "";
|
var currentShowName = "";
|
||||||
var timeElapsed = "";
|
var timeElapsed = "";
|
||||||
var timeRemaining = "";
|
var timeRemaining = "";
|
||||||
|
@ -95,7 +100,7 @@
|
||||||
var nextShowRange = "";
|
var nextShowRange = "";
|
||||||
|
|
||||||
if (currentShow.length > 0){
|
if (currentShow.length > 0){
|
||||||
showStatus = "On Air Now";
|
showStatus = options.text.onAirNow;
|
||||||
currentShowName = currentShow[0].getName();
|
currentShowName = currentShow[0].getName();
|
||||||
|
|
||||||
timeElapsed = sd.getShowTimeElapsed(currentShow[0]);
|
timeElapsed = sd.getShowTimeElapsed(currentShow[0]);
|
||||||
|
@ -108,14 +113,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.empty();
|
obj.empty();
|
||||||
obj.append("<a id='listenWadrLive' href='"+options.audioStreamSource+"'><span>Listen WADR Live</span></a>");
|
obj.append("<a id='listenWadrLive' href='"+options.audioStreamSource+"'><span>"+options.text.listenLive+"</span></a>");
|
||||||
obj.append("<h4>"+showStatus+" >></h4>");
|
obj.append("<h4>"+showStatus+" >></h4>");
|
||||||
obj.append("<ul class='widget no-playing-bar'>" +
|
obj.append("<ul class='widget no-playing-bar'>" +
|
||||||
"<li class='current'>Current: "+currentShowName+
|
"<li class='current'>"+options.text.current+": "+currentShowName+
|
||||||
"<span id='time-elapsed' class='time-elapsed'>"+timeElapsed+"</span>" +
|
"<span id='time-elapsed' class='time-elapsed'>"+timeElapsed+"</span>" +
|
||||||
"<span id='time-remaining' class='time-remaining'>"+timeRemaining+"</span>"+
|
"<span id='time-remaining' class='time-remaining'>"+timeRemaining+"</span>"+
|
||||||
"</li>" +
|
"</li>" +
|
||||||
"<li class='next'>Next: "+nextShowName+"<span>"+nextShowRange+"</span></li>" +
|
"<li class='next'>"+options.text.next+": "+nextShowName+"<span>"+nextShowRange+"</span></li>" +
|
||||||
"</ul>");
|
"</ul>");
|
||||||
|
|
||||||
//refresh the UI to update the elapsed/remaining time
|
//refresh the UI to update the elapsed/remaining time
|
||||||
|
@ -127,10 +132,13 @@
|
||||||
updateWidget();
|
updateWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||||
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
}, error:airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -220,10 +228,13 @@
|
||||||
updateWidget(data);
|
updateWidget(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||||
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/week-info/", dataType:"jsonp", success:function(data){
|
$.ajax({ url: options.sourceDomain + "api/week-info/", dataType:"jsonp", success:function(data){
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
}, error:airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<?php
|
|
||||||
DROP TABLE cc_backup;
|
|
||||||
DROP TABLE cc_trans;
|
|
Loading…
Reference in New Issue