CC-2084: Integrate RabbitMQ for immediate schedule updates and commands
This is the code for the server side to push the schedule to RabbitMQ. Right now it is disabled and should cause no changes in behavior. Also added comments to functions and formatted code correctly.
This commit is contained in:
parent
d9431f95b4
commit
d38e2adb58
|
@ -19,8 +19,10 @@ require_once 'StoredFile.php';
|
||||||
require_once 'Schedule.php';
|
require_once 'Schedule.php';
|
||||||
require_once 'Shows.php';
|
require_once 'Shows.php';
|
||||||
require_once 'Users.php';
|
require_once 'Users.php';
|
||||||
|
require_once 'RabbitMq.php';
|
||||||
|
|
||||||
global $CC_CONFIG, $CC_DBC;
|
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$dsn = $CC_CONFIG['dsn'];
|
$dsn = $CC_CONFIG['dsn'];
|
||||||
|
|
||||||
$CC_DBC = DB::connect($dsn, FALSE);
|
$CC_DBC = DB::connect($dsn, FALSE);
|
||||||
|
@ -64,14 +66,14 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||||
$this->view->headScript()->appendFile('/js/playlist/helperfunctions.js','text/javascript');
|
$this->view->headScript()->appendFile('/js/playlist/helperfunctions.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript');
|
$this->view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript');
|
||||||
|
|
||||||
$view->headScript()->appendFile('/js/airtime/common/common.js','text/javascript');
|
$view->headScript()->appendFile('/js/airtime/common/common.js','text/javascript');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _initViewHelpers(){
|
protected function _initViewHelpers(){
|
||||||
$view = $this->getResource('view');
|
$view = $this->getResource('view');
|
||||||
$view->addHelperPath('../application/views/helpers', 'Airtime_View_Helper');
|
$view->addHelperPath('../application/views/helpers', 'Airtime_View_Helper');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _initTitle(){
|
protected function _initTitle(){
|
||||||
$view = $this->getResource('view');
|
$view = $this->getResource('view');
|
||||||
$view->headTitle(Application_Model_Preference::GetHeadTitle());
|
$view->headTitle(Application_Model_Preference::GetHeadTitle());
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
define('AIRTIME_VERSION', '1.7.0 alpha');
|
define('AIRTIME_VERSION', '1.7.0 alpha');
|
||||||
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
|
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
|
||||||
|
define('AIRTIME_REST_VERSION', '1.1');
|
||||||
|
|
||||||
// These are the default values for the config.
|
// These are the default values for the config.
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
$values = load_airtime_config();
|
$values = load_airtime_config();
|
||||||
|
|
||||||
// **********************************
|
// **********************************
|
||||||
// ***** START CUSTOMIZING HERE *****
|
// ***** START CUSTOMIZING HERE *****
|
||||||
// **********************************
|
// **********************************
|
||||||
|
|
||||||
// Set the location where you want to store all of your audio files.
|
// Set the location where you want to store all of your audio files.
|
||||||
//
|
//
|
||||||
|
@ -25,10 +26,16 @@ $CC_CONFIG = array(
|
||||||
// Name of the web server user
|
// Name of the web server user
|
||||||
'webServerUser' => 'www-data',
|
'webServerUser' => 'www-data',
|
||||||
|
|
||||||
// ***********************************************************************
|
'rabbitmq' => array("host" => "127.0.0.1",
|
||||||
|
"port" => "5672",
|
||||||
|
"user" => "guest",
|
||||||
|
"password" => "guest",
|
||||||
|
"vhost" => "/"),
|
||||||
|
|
||||||
|
// ***********************************************************************
|
||||||
// STOP CUSTOMIZING HERE
|
// STOP CUSTOMIZING HERE
|
||||||
//
|
//
|
||||||
// You don't need to touch anything below this point.
|
// You don't need to touch anything below this point.
|
||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
|
|
||||||
'baseFilesDir' => $baseFilesDir,
|
'baseFilesDir' => $baseFilesDir,
|
||||||
|
@ -55,26 +62,26 @@ $CC_CONFIG = array(
|
||||||
//'AdminsGr' => 'Admins',
|
//'AdminsGr' => 'Admins',
|
||||||
|
|
||||||
// name of station preferences group
|
// name of station preferences group
|
||||||
'StationPrefsGr'=> 'StationPrefs',
|
// 'StationPrefsGr'=> 'StationPrefs',
|
||||||
|
|
||||||
// name of 'all users' group
|
// name of 'all users' group
|
||||||
//'AllGr' => 'All',
|
//'AllGr' => 'All',
|
||||||
|
|
||||||
/* ==================================== application-specific configuration */
|
/* ==================================== application-specific configuration */
|
||||||
'objtypes' => array(
|
// 'objtypes' => array(
|
||||||
'Storage' => array(/*'Folder',*/ 'File' /*, 'Replica'*/),
|
// 'Storage' => array(/*'Folder',*/ 'File' /*, 'Replica'*/),
|
||||||
'File' => array(),
|
// 'File' => array(),
|
||||||
'audioclip' => array(),
|
// 'audioclip' => array(),
|
||||||
'playlist' => array(),
|
// 'playlist' => array(),
|
||||||
),
|
// ),
|
||||||
'allowedActions'=> array(
|
// 'allowedActions'=> array(
|
||||||
'File' => array('editPrivs', 'write', 'read'),
|
// 'File' => array('editPrivs', 'write', 'read'),
|
||||||
'audioclip' => array('editPrivs', 'write', 'read'),
|
// 'audioclip' => array('editPrivs', 'write', 'read'),
|
||||||
'playlist' => array('editPrivs', 'write', 'read'),
|
// 'playlist' => array('editPrivs', 'write', 'read'),
|
||||||
),
|
// ),
|
||||||
'allActions' => array(
|
// 'allActions' => array(
|
||||||
'editPrivs', 'write', 'read', 'subjects'
|
// 'editPrivs', 'write', 'read', 'subjects'
|
||||||
),
|
// ),
|
||||||
|
|
||||||
/* =================================================== cron configuration */
|
/* =================================================== cron configuration */
|
||||||
'cronUserName' => 'www-data',
|
'cronUserName' => 'www-data',
|
||||||
|
@ -82,7 +89,7 @@ $CC_CONFIG = array(
|
||||||
'lockfile' => dirname(__FILE__).'/stor/buffer/cron.lock',
|
'lockfile' => dirname(__FILE__).'/stor/buffer/cron.lock',
|
||||||
'cronfile' => dirname(__FILE__).'/cron/croncall.php',
|
'cronfile' => dirname(__FILE__).'/cron/croncall.php',
|
||||||
'paramdir' => dirname(__FILE__).'/cron/params',
|
'paramdir' => dirname(__FILE__).'/cron/params',
|
||||||
'systemPrefId' => "0", // ID for system prefs in prefs table
|
// 'systemPrefId' => "0", // ID for system prefs in prefs table
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add database table names
|
// Add database table names
|
||||||
|
@ -94,10 +101,8 @@ $CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||||
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
|
|
||||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||||
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
|
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
|
||||||
$CC_CONFIG['backupTable'] = $CC_CONFIG['tblNamePrefix'].'backup';
|
|
||||||
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
|
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
|
||||||
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
|
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
|
||||||
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
|
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
|
||||||
|
@ -106,16 +111,15 @@ $CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';
|
||||||
|
|
||||||
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
|
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
|
||||||
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
|
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
|
||||||
$CC_CONFIG['transSequence'] = $CC_CONFIG['transTable'].'_id';
|
|
||||||
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
|
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
|
||||||
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
|
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
|
||||||
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
|
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
|
||||||
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
|
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
|
||||||
|
|
||||||
// System users/groups - they cannot be deleted
|
// System users/groups - they cannot be deleted
|
||||||
$CC_CONFIG['sysSubjs'] = array(
|
//$CC_CONFIG['sysSubjs'] = array(
|
||||||
'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ $CC_CONFIG['StationPrefsGr']
|
// 'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ $CC_CONFIG['StationPrefsGr']
|
||||||
);
|
//);
|
||||||
|
|
||||||
// Add libs to the PHP path
|
// Add libs to the PHP path
|
||||||
$old_include_path = get_include_path();
|
$old_include_path = get_include_path();
|
||||||
|
@ -125,9 +129,9 @@ set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
|
||||||
|
|
||||||
function load_airtime_config(){
|
function load_airtime_config(){
|
||||||
$ini_array = parse_ini_file(dirname(__FILE__).'/../../build/airtime.conf', true);
|
$ini_array = parse_ini_file(dirname(__FILE__).'/../../build/airtime.conf', true);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'database' => array(
|
'database' => array(
|
||||||
'username' => $ini_array['database']['dbuser'],
|
'username' => $ini_array['database']['dbuser'],
|
||||||
'password' => $ini_array['database']['dbpass'],
|
'password' => $ini_array['database']['dbpass'],
|
||||||
'hostspec' => $ini_array['database']['host'],
|
'hostspec' => $ini_array['database']['host'],
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
* in application/conf.php
|
* in application/conf.php
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function versionAction()
|
public function versionAction()
|
||||||
{
|
{
|
||||||
|
@ -123,14 +123,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
$to = $this->_getParam("to");
|
$to = $this->_getParam("to");
|
||||||
if (Schedule::ValidPypoTimeFormat($from) && Schedule::ValidPypoTimeFormat($to)) {
|
if (Schedule::ValidPypoTimeFormat($from) && Schedule::ValidPypoTimeFormat($to)) {
|
||||||
$result = Schedule::ExportRangeAsJson($from, $to);
|
$result = Schedule::ExportRangeAsJson($from, $to);
|
||||||
$result['stream_metadata'] = array();
|
|
||||||
$result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat();
|
|
||||||
$result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName();
|
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function notifyMediaItemStartPlayAction()
|
public function notifyMediaItemStartPlayAction()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
|
@ -19,9 +19,9 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
->addActionContext('schedule-show-dialog', 'json')
|
->addActionContext('schedule-show-dialog', 'json')
|
||||||
->addActionContext('show-content-dialog', 'json')
|
->addActionContext('show-content-dialog', 'json')
|
||||||
->addActionContext('clear-show', 'json')
|
->addActionContext('clear-show', 'json')
|
||||||
->addActionContext('get-current-playlist', 'json')
|
->addActionContext('get-current-playlist', 'json')
|
||||||
->addActionContext('find-playlists', 'json')
|
->addActionContext('find-playlists', 'json')
|
||||||
->addActionContext('remove-group', 'json')
|
->addActionContext('remove-group', 'json')
|
||||||
->addActionContext('edit-show', 'json')
|
->addActionContext('edit-show', 'json')
|
||||||
->addActionContext('add-show', 'json')
|
->addActionContext('add-show', 'json')
|
||||||
->addActionContext('cancel-show', 'json')
|
->addActionContext('cancel-show', 'json')
|
||||||
|
@ -64,7 +64,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$formRepeats->removeDecorator('DtDdWrapper');
|
$formRepeats->removeDecorator('DtDdWrapper');
|
||||||
$formStyle->removeDecorator('DtDdWrapper');
|
$formStyle->removeDecorator('DtDdWrapper');
|
||||||
$formRecord->removeDecorator('DtDdWrapper');
|
$formRecord->removeDecorator('DtDdWrapper');
|
||||||
|
|
||||||
|
|
||||||
$this->view->what = $formWhat;
|
$this->view->what = $formWhat;
|
||||||
$this->view->when = $formWhen;
|
$this->view->when = $formWhen;
|
||||||
|
@ -84,7 +84,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$start = $this->_getParam('start', null);
|
$start = $this->_getParam('start', null);
|
||||||
$end = $this->_getParam('end', null);
|
$end = $this->_getParam('end', null);
|
||||||
|
|
||||||
$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())
|
||||||
|
@ -111,6 +111,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
if(isset($error))
|
if(isset($error))
|
||||||
$this->view->error = $error;
|
$this->view->error = $error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resizeShowAction()
|
public function resizeShowAction()
|
||||||
|
@ -134,7 +135,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
public function deleteShowAction()
|
public function deleteShowAction()
|
||||||
{
|
{
|
||||||
$showInstanceId = $this->_getParam('id');
|
$showInstanceId = $this->_getParam('id');
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
|
@ -158,41 +159,41 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
||||||
|
|
||||||
if (($user->isHost($show->getShowId()) || $user->isAdmin()) && !$show->isRecorded() && !$show->isRebroadcast()) {
|
if (($user->isHost($show->getShowId()) || $user->isAdmin()) && !$show->isRecorded() && !$show->isRebroadcast()) {
|
||||||
|
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
|
||||||
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add Content');
|
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add Content');
|
||||||
|
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params,
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params,
|
||||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content');
|
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$show->isRecorded()) {
|
if(!$show->isRecorded()) {
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog'.$params,
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog'.$params,
|
||||||
'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content');
|
'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
||||||
strtotime($today_timestamp) < strtotime($show->getShowEnd())) {
|
strtotime($today_timestamp) < strtotime($show->getShowEnd())) {
|
||||||
$menu[] = array('action' => array('type' => 'fn',
|
$menu[] = array('action' => array('type' => 'fn',
|
||||||
//'url' => '/Schedule/cancel-current-show'.$params,
|
//'url' => '/Schedule/cancel-current-show'.$params,
|
||||||
'callback' => "window['confirmCancelShow']($id)"),
|
'callback' => "window['confirmCancelShow']($id)"),
|
||||||
'title' => 'Cancel Current Show');
|
'title' => 'Cancel Current Show');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
||||||
|
|
||||||
if ($user->isAdmin()) {
|
if ($user->isAdmin()) {
|
||||||
|
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params,
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params,
|
||||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance');
|
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance');
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,
|
||||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
|
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns format jjmenu is looking for.
|
//returns format jjmenu is looking for.
|
||||||
die(json_encode($menu));
|
die(json_encode($menu));
|
||||||
}
|
}
|
||||||
|
@ -219,7 +220,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$this->view->timeFilled = $show->getTimeScheduled();
|
$this->view->timeFilled = $show->getTimeScheduled();
|
||||||
$this->view->percentFilled = $show->getPercentScheduled();
|
$this->view->percentFilled = $show->getPercentScheduled();
|
||||||
|
|
||||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||||
unset($this->view->showContent);
|
unset($this->view->showContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +243,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
public function findPlaylistsAction()
|
public function findPlaylistsAction()
|
||||||
{
|
{
|
||||||
$post = $this->getRequest()->getPost();
|
$post = $this->getRequest()->getPost();
|
||||||
|
|
||||||
$show = new ShowInstance($this->sched_sess->showInstanceId);
|
$show = new ShowInstance($this->sched_sess->showInstanceId);
|
||||||
$playlists = $show->searchPlaylistsForShow($post);
|
$playlists = $show->searchPlaylistsForShow($post);
|
||||||
|
|
||||||
|
@ -267,7 +268,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$this->view->showContent = $show->getShowContent();
|
$this->view->showContent = $show->getShowContent();
|
||||||
$this->view->timeFilled = $show->getTimeScheduled();
|
$this->view->timeFilled = $show->getTimeScheduled();
|
||||||
$this->view->percentFilled = $show->getPercentScheduled();
|
$this->view->percentFilled = $show->getPercentScheduled();
|
||||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||||
unset($this->view->showContent);
|
unset($this->view->showContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +276,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$showInstanceId = $this->_getParam('id');
|
$showInstanceId = $this->_getParam('id');
|
||||||
$this->sched_sess->showInstanceId = $showInstanceId;
|
$this->sched_sess->showInstanceId = $showInstanceId;
|
||||||
|
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
$start_timestamp = $show->getShowStart();
|
$start_timestamp = $show->getShowStart();
|
||||||
$end_timestamp = $show->getShowEnd();
|
$end_timestamp = $show->getShowEnd();
|
||||||
|
@ -285,14 +286,14 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$this->view->error = "cannot schedule an overlapping show.";
|
$this->view->error = "cannot schedule an overlapping show.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = explode(" ", $start_timestamp);
|
$start = explode(" ", $start_timestamp);
|
||||||
$end = explode(" ", $end_timestamp);
|
$end = explode(" ", $end_timestamp);
|
||||||
$startTime = explode(":", $start[1]);
|
$startTime = explode(":", $start[1]);
|
||||||
$endTime = explode(":", $end[1]);
|
$endTime = explode(":", $end[1]);
|
||||||
$dateInfo_s = getDate(strtotime($start_timestamp));
|
$dateInfo_s = getDate(strtotime($start_timestamp));
|
||||||
$dateInfo_e = getDate(strtotime($end_timestamp));
|
$dateInfo_e = getDate(strtotime($end_timestamp));
|
||||||
|
|
||||||
$this->view->showContent = $show->getShowContent();
|
$this->view->showContent = $show->getShowContent();
|
||||||
$this->view->timeFilled = $show->getTimeScheduled();
|
$this->view->timeFilled = $show->getTimeScheduled();
|
||||||
$this->view->showName = $show->getName();
|
$this->view->showName = $show->getName();
|
||||||
|
@ -308,7 +309,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$this->view->startTime = sprintf("%d:%02d", $startTime[0], $startTime[1]);
|
$this->view->startTime = sprintf("%d:%02d", $startTime[0], $startTime[1]);
|
||||||
$this->view->endTime = sprintf("%d:%02d", $endTime[0], $endTime[1]);
|
$this->view->endTime = sprintf("%d:%02d", $endTime[0], $endTime[1]);
|
||||||
|
|
||||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||||
$this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');
|
$this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');
|
||||||
unset($this->view->showContent);
|
unset($this->view->showContent);
|
||||||
}
|
}
|
||||||
|
@ -335,7 +336,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$js = $this->_getParam('data');
|
$js = $this->_getParam('data');
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
//need to convert from serialized jQuery array.
|
//need to convert from serialized jQuery array.
|
||||||
foreach($js as $j){
|
foreach($js as $j){
|
||||||
$data[$j["name"]] = $j["value"];
|
$data[$j["name"]] = $j["value"];
|
||||||
|
@ -392,8 +393,8 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$rebroadAb = $formAbsoluteRebroadcast->isValid($data);
|
$rebroadAb = $formAbsoluteRebroadcast->isValid($data);
|
||||||
$rebroad = $formRebroadcast->isValid($data);
|
$rebroad = $formRebroadcast->isValid($data);
|
||||||
|
|
||||||
if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) {
|
if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) {
|
||||||
|
|
||||||
$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()) {
|
||||||
|
@ -413,7 +414,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$formRecord->reset();
|
$formRecord->reset();
|
||||||
$formAbsoluteRebroadcast->reset();
|
$formAbsoluteRebroadcast->reset();
|
||||||
$formRebroadcast->reset();
|
$formRebroadcast->reset();
|
||||||
|
|
||||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -426,7 +427,7 @@ 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()) {
|
||||||
$showInstanceId = $this->_getParam('id');
|
$showInstanceId = $this->_getParam('id');
|
||||||
|
|
||||||
|
@ -434,14 +435,14 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$show = new Show($showInstance->getShowId());
|
$show = new Show($showInstance->getShowId());
|
||||||
|
|
||||||
$show->cancelShow($showInstance->getShowStart());
|
$show->cancelShow($showInstance->getShowStart());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancelCurrentShowAction()
|
public function cancelCurrentShowAction()
|
||||||
{
|
{
|
||||||
$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()) {
|
||||||
$showInstanceId = $this->_getParam('id');
|
$showInstanceId = $this->_getParam('id');
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
|
|
|
@ -2,61 +2,85 @@
|
||||||
|
|
||||||
class Application_Model_DateHelper
|
class Application_Model_DateHelper
|
||||||
{
|
{
|
||||||
private $_timestamp;
|
private $_timestamp;
|
||||||
|
|
||||||
function __construct() {
|
function __construct()
|
||||||
|
{
|
||||||
$this->_timestamp = date("U");
|
$this->_timestamp = date("U");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDate(){
|
/**
|
||||||
return date("Y-m-d H:i:s", $this->_timestamp);
|
* Get time of object construction in the format
|
||||||
}
|
* YYYY-MM-DD HH:mm:ss
|
||||||
|
*/
|
||||||
function getTime(){
|
function getDate()
|
||||||
return date("H:i:s", $this->_timestamp);
|
{
|
||||||
}
|
return date("Y-m-d H:i:s", $this->_timestamp);
|
||||||
|
}
|
||||||
function setDate($dateString){
|
|
||||||
|
/**
|
||||||
|
* Get time of object construction in the format
|
||||||
|
* HH:mm:ss
|
||||||
|
*/
|
||||||
|
function getTime()
|
||||||
|
{
|
||||||
|
return date("H:i:s", $this->_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the internal timestamp of the object.
|
||||||
|
*/
|
||||||
|
function setDate($dateString)
|
||||||
|
{
|
||||||
$this->_timestamp = strtotime($dateString);
|
$this->_timestamp = strtotime($dateString);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNowDayStartDiff(){
|
|
||||||
$dayStartTS = strtotime(date("Y-m-d", $this->_timestamp));
|
|
||||||
return $this->_timestamp - $dayStartTS;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNowDayEndDiff(){
|
/**
|
||||||
$dayEndTS = strtotime(date("Y-m-d", $this->_timestamp+(86400)));
|
*
|
||||||
return $dayEndTS - $this->_timestamp;
|
* Enter description here ...
|
||||||
}
|
*/
|
||||||
|
function getNowDayStartDiff()
|
||||||
|
{
|
||||||
|
$dayStartTS = strtotime(date("Y-m-d", $this->_timestamp));
|
||||||
|
return $this->_timestamp - $dayStartTS;
|
||||||
|
}
|
||||||
|
|
||||||
function getEpochTime(){
|
function getNowDayEndDiff()
|
||||||
|
{
|
||||||
|
$dayEndTS = strtotime(date("Y-m-d", $this->_timestamp+(86400)));
|
||||||
|
return $dayEndTS - $this->_timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEpochTime()
|
||||||
|
{
|
||||||
return $this->_timestamp;
|
return $this->_timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function TimeDiff($time1, $time2){
|
public static function TimeDiff($time1, $time2)
|
||||||
|
{
|
||||||
return strtotime($time2) - strtotime($time1);
|
return strtotime($time2) - strtotime($time1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ConvertMSToHHMMSSmm($time){
|
public static function ConvertMSToHHMMSSmm($time)
|
||||||
|
{
|
||||||
$hours = floor($time / 3600000);
|
$hours = floor($time / 3600000);
|
||||||
$time -= 3600000*$hours;
|
$time -= 3600000*$hours;
|
||||||
|
|
||||||
$minutes = floor($time / 60000);
|
$minutes = floor($time / 60000);
|
||||||
$time -= 60000*$minutes;
|
$time -= 60000*$minutes;
|
||||||
|
|
||||||
$seconds = floor($time / 1000);
|
$seconds = floor($time / 1000);
|
||||||
$time -= 1000*$seconds;
|
$time -= 1000*$seconds;
|
||||||
|
|
||||||
$ms = $time;
|
$ms = $time;
|
||||||
|
|
||||||
if (strlen($hours) == 1)
|
if (strlen($hours) == 1)
|
||||||
$hours = "0".$hours;
|
$hours = "0".$hours;
|
||||||
if (strlen($minutes) == 1)
|
if (strlen($minutes) == 1)
|
||||||
$minutes = "0".$minutes;
|
$minutes = "0".$minutes;
|
||||||
if (strlen($seconds) == 1)
|
if (strlen($seconds) == 1)
|
||||||
$seconds = "0".$seconds;
|
$seconds = "0".$seconds;
|
||||||
|
|
||||||
return $hours.":".$minutes.":".$seconds.".".$ms;
|
return $hours.":".$minutes.":".$seconds.".".$ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
require_once 'php-amqplib/amqp.inc';
|
||||||
|
|
||||||
|
class RabbitMq
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push the current schedule to RabbitMQ, to be picked up by Pypo.
|
||||||
|
* Will push the schedule in the range from 24 hours ago to 24 hours
|
||||||
|
* in the future.
|
||||||
|
*/
|
||||||
|
public static function PushSchedule() {
|
||||||
|
// global $CC_CONFIG;
|
||||||
|
// $conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
|
||||||
|
// $CC_CONFIG["rabbitmq"]["port"],
|
||||||
|
// $CC_CONFIG["rabbitmq"]["user"],
|
||||||
|
// $CC_CONFIG["rabbitmq"]["password"]);
|
||||||
|
// $channel = $conn->channel();
|
||||||
|
// $channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
|
||||||
|
//
|
||||||
|
// $EXCHANGE = 'airtime-schedule';
|
||||||
|
// $channel->exchange_declare($EXCHANGE, 'direct', false, false, false);
|
||||||
|
//
|
||||||
|
// $data = json_encode(Schedule::ExportRangeAsJson());
|
||||||
|
// $msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
|
||||||
|
//
|
||||||
|
// $channel->basic_publish($msg, $EXCHANGE);
|
||||||
|
// $channel->close();
|
||||||
|
// $conn->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -110,7 +110,6 @@ class ScheduleGroup {
|
||||||
//var_dump($sql);
|
//var_dump($sql);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
return $this->groupId;
|
|
||||||
|
|
||||||
} elseif (!is_null($p_playlistId)){
|
} elseif (!is_null($p_playlistId)){
|
||||||
// Schedule a whole playlist
|
// Schedule a whole playlist
|
||||||
|
@ -153,8 +152,9 @@ class ScheduleGroup {
|
||||||
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
|
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
|
||||||
$id = $this->dateToId($itemStartTime);
|
$id = $this->dateToId($itemStartTime);
|
||||||
}
|
}
|
||||||
return $this->groupId;
|
|
||||||
}
|
}
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
|
return $this->groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addAfter($show_instance, $p_groupId, $p_audioFileId) {
|
public function addAfter($show_instance, $p_groupId, $p_audioFileId) {
|
||||||
|
@ -176,10 +176,6 @@ class ScheduleGroup {
|
||||||
return $this->add($show_instance, $startTime, null, $p_playlistId);
|
return $this->add($show_instance, $startTime, null, $p_playlistId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the group from the schedule.
|
* Remove the group from the schedule.
|
||||||
* Note: does not check if it is in the past, you can remove anything.
|
* Note: does not check if it is in the past, you can remove anything.
|
||||||
|
@ -195,7 +191,9 @@ class ScheduleGroup {
|
||||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
||||||
." WHERE group_id = ".$this->groupId;
|
." WHERE group_id = ".$this->groupId;
|
||||||
//echo $sql;
|
//echo $sql;
|
||||||
return $CC_DBC->query($sql);
|
$retVal = $CC_DBC->query($sql);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
|
return $retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,17 +229,14 @@ class ScheduleGroup {
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reschedule($toDateTime) {
|
|
||||||
global $CC_CONFIG, $CC_DBC;
|
|
||||||
// $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]. " SET id=, starts=,ends="
|
|
||||||
}
|
|
||||||
|
|
||||||
public function notifyGroupStartPlay() {
|
public function notifyGroupStartPlay() {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||||
." SET schedule_group_played=TRUE"
|
." SET schedule_group_played=TRUE"
|
||||||
." WHERE group_id=".$this->groupId;
|
." WHERE group_id=".$this->groupId;
|
||||||
return $CC_DBC->query($sql);
|
$retVal = $CC_DBC->query($sql);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
|
return $retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notifyMediaItemStartPlay($p_fileId) {
|
public function notifyMediaItemStartPlay($p_fileId) {
|
||||||
|
@ -250,7 +245,9 @@ class ScheduleGroup {
|
||||||
." SET media_item_played=TRUE"
|
." SET media_item_played=TRUE"
|
||||||
." WHERE group_id=".$this->groupId
|
." WHERE group_id=".$this->groupId
|
||||||
." AND file_id=".pg_escape_string($p_fileId);
|
." AND file_id=".pg_escape_string($p_fileId);
|
||||||
return $CC_DBC->query($sql);
|
$retVal = $CC_DBC->query($sql);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
|
return $retVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,9 +331,10 @@ class Schedule {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetPercentScheduled($instance_id, $s_datetime, $e_datetime){
|
public static function GetPercentScheduled($instance_id, $s_datetime, $e_datetime)
|
||||||
|
{
|
||||||
$time = Schedule::GetTotalShowTime($instance_id);
|
$time = Schedule::GetTotalShowTime($instance_id);
|
||||||
|
|
||||||
$s_epoch = strtotime($s_datetime);
|
$s_epoch = strtotime($s_datetime);
|
||||||
$e_epoch = strtotime($e_datetime);
|
$e_epoch = strtotime($e_datetime);
|
||||||
|
|
||||||
|
@ -396,7 +394,8 @@ class Schedule {
|
||||||
* @return array
|
* @return array
|
||||||
* Returns empty array if nothing found
|
* Returns empty array if nothing found
|
||||||
*/
|
*/
|
||||||
public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true) {
|
public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true)
|
||||||
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$rows = array();
|
$rows = array();
|
||||||
if (!$p_playlistsOnly) {
|
if (!$p_playlistsOnly) {
|
||||||
|
@ -433,7 +432,7 @@ class Schedule {
|
||||||
." AND (st.ends <= TIMESTAMP '$p_toDateTime')"
|
." AND (st.ends <= TIMESTAMP '$p_toDateTime')"
|
||||||
//next line makes sure that we aren't returning items that
|
//next line makes sure that we aren't returning items that
|
||||||
//are past the show's scheduled timeslot.
|
//are past the show's scheduled timeslot.
|
||||||
." AND (st.starts < si.ends)"
|
." AND (st.starts < si.ends)"
|
||||||
." GROUP BY st.group_id"
|
." GROUP BY st.group_id"
|
||||||
." ORDER BY starts";
|
." ORDER BY starts";
|
||||||
|
|
||||||
|
@ -457,7 +456,8 @@ class Schedule {
|
||||||
* @param int $next
|
* @param int $next
|
||||||
* @return date
|
* @return date
|
||||||
*/
|
*/
|
||||||
public static function GetPlayOrderRange($prev = 1, $next = 1) {
|
public static function GetPlayOrderRange($prev = 1, $next = 1)
|
||||||
|
{
|
||||||
if (!is_int($prev) || !is_int($next)){
|
if (!is_int($prev) || !is_int($next)){
|
||||||
//must enter integers to specify ranges
|
//must enter integers to specify ranges
|
||||||
return array();
|
return array();
|
||||||
|
@ -469,9 +469,9 @@ class Schedule {
|
||||||
$timeNow = $date->getDate();
|
$timeNow = $date->getDate();
|
||||||
return array("env"=>APPLICATION_ENV,
|
return array("env"=>APPLICATION_ENV,
|
||||||
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||||
"previous"=>Schedule::Get_Scheduled_Item_Data($timeNow, -1, $prev, "24 hours"),
|
"previous"=>Schedule::GetScheduledItemData($timeNow, -1, $prev, "24 hours"),
|
||||||
"current"=>Schedule::Get_Scheduled_Item_Data($timeNow, 0),
|
"current"=>Schedule::GetScheduledItemData($timeNow, 0),
|
||||||
"next"=>Schedule::Get_Scheduled_Item_Data($timeNow, 1, $next, "48 hours"),
|
"next"=>Schedule::GetScheduledItemData($timeNow, 1, $next, "48 hours"),
|
||||||
"currentShow"=>Show_DAL::GetCurrentShow($timeNow),
|
"currentShow"=>Show_DAL::GetCurrentShow($timeNow),
|
||||||
"nextShow"=>Show_DAL::GetNextShow($timeNow),
|
"nextShow"=>Show_DAL::GetNextShow($timeNow),
|
||||||
"timezone"=> date("T"),
|
"timezone"=> date("T"),
|
||||||
|
@ -501,7 +501,8 @@ class Schedule {
|
||||||
* want to search the database. For example "5 days", "18 hours", "60 minutes",
|
* want to search the database. For example "5 days", "18 hours", "60 minutes",
|
||||||
* "30 seconds" etc.
|
* "30 seconds" etc.
|
||||||
*/
|
*/
|
||||||
public static function Get_Scheduled_Item_Data($timeStamp, $timePeriod=0, $count = 0, $interval="0 hours"){
|
public static function GetScheduledItemData($timeStamp, $timePeriod=0, $count = 0, $interval="0 hours")
|
||||||
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.media_item_played, st.group_id, show.name as show_name, st.instance_id"
|
$sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.media_item_played, st.group_id, show.name as show_name, st.instance_id"
|
||||||
|
@ -531,7 +532,8 @@ class Schedule {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetShowInstanceItems($instance_id){
|
public static function GetShowInstanceItems($instance_id)
|
||||||
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.media_item_played, st.group_id, show.name as show_name, st.instance_id"
|
$sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.media_item_played, st.group_id, show.name as show_name, st.instance_id"
|
||||||
|
@ -547,12 +549,15 @@ class Schedule {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function UpdateMediaPlayedStatus($id){
|
public static function UpdateMediaPlayedStatus($p_id)
|
||||||
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||||
." SET media_item_played=TRUE"
|
." SET media_item_played=TRUE"
|
||||||
." WHERE id=$id";
|
." WHERE id=$p_id";
|
||||||
return $CC_DBC->query($sql);
|
$retVal = $CC_DBC->query($sql);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
|
return $retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -563,7 +568,7 @@ class Schedule {
|
||||||
* @param string $p_time
|
* @param string $p_time
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function CcTimeToPypoTime($p_time)
|
private static function AirtimeTimeToPypoTime($p_time)
|
||||||
{
|
{
|
||||||
$p_time = substr($p_time, 0, 19);
|
$p_time = substr($p_time, 0, 19);
|
||||||
$p_time = str_replace(" ", "-", $p_time);
|
$p_time = str_replace(" ", "-", $p_time);
|
||||||
|
@ -578,7 +583,7 @@ class Schedule {
|
||||||
* @param string $p_time
|
* @param string $p_time
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function PypoTimeToCcTime($p_time)
|
private static function PypoTimeToAirtimeTime($p_time)
|
||||||
{
|
{
|
||||||
$t = explode("-", $p_time);
|
$t = explode("-", $p_time);
|
||||||
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
|
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
|
||||||
|
@ -658,17 +663,29 @@ class Schedule {
|
||||||
/**
|
/**
|
||||||
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
|
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
|
||||||
*
|
*
|
||||||
* @param string $range
|
* @param string $p_fromDateTime
|
||||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
* In the format "YYYY-MM-DD-HH-mm-SS"
|
||||||
* @param string $source
|
* @param string $p_toDateTime
|
||||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
* In the format "YYYY-MM-DD-HH-mm-SS"
|
||||||
*/
|
*/
|
||||||
public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime)
|
public static function ExportRangeAsJson($p_fromDateTime = null , $p_toDateTime = null)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$range_start = Schedule::PypoTimeToCcTime($p_fromDateTime);
|
if (is_null($p_fromDateTime)) {
|
||||||
$range_end = Schedule::PypoTimeToCcTime($p_toDateTime);
|
$t1 = new DateTime();
|
||||||
|
$t1->sub(new DateInterval("PT24H"));
|
||||||
|
$range_start = $t1->format("Y-m-d H:i:s");
|
||||||
|
} else {
|
||||||
|
$range_start = Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
|
||||||
|
}
|
||||||
|
if (is_null($p_fromDateTime)) {
|
||||||
|
$t2 = new DateTime();
|
||||||
|
$t2->add(new DateInterval("PT24H"));
|
||||||
|
$range_end = $t2->format("Y-m-d H:i:s");
|
||||||
|
} else {
|
||||||
|
$range_end = Schedule::PypoTimeToAirtimeTime($p_toDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
// Scheduler wants everything in a playlist
|
// Scheduler wants everything in a playlist
|
||||||
$data = Schedule::GetItems($range_start, $range_end, true);
|
$data = Schedule::GetItems($range_start, $range_end, true);
|
||||||
|
@ -684,7 +701,7 @@ class Schedule {
|
||||||
$start = substr($start, 0, 19);
|
$start = substr($start, 0, 19);
|
||||||
|
|
||||||
//Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
|
//Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
|
||||||
$pkey = Schedule::CcTimeToPypoTime($start);
|
$pkey = Schedule::AirtimeTimeToPypoTime($start);
|
||||||
$timestamp = strtotime($start);
|
$timestamp = strtotime($start);
|
||||||
$playlists[$pkey]['source'] = "PLAYLIST";
|
$playlists[$pkey]['source'] = "PLAYLIST";
|
||||||
$playlists[$pkey]['x_ident'] = $dx["playlist_id"];
|
$playlists[$pkey]['x_ident'] = $dx["playlist_id"];
|
||||||
|
@ -696,8 +713,8 @@ class Schedule {
|
||||||
$playlists[$pkey]['show_name'] = $dx['show_name'];
|
$playlists[$pkey]['show_name'] = $dx['show_name'];
|
||||||
$playlists[$pkey]['user_id'] = 0;
|
$playlists[$pkey]['user_id'] = 0;
|
||||||
$playlists[$pkey]['id'] = $dx["playlist_id"];
|
$playlists[$pkey]['id'] = $dx["playlist_id"];
|
||||||
$playlists[$pkey]['start'] = Schedule::CcTimeToPypoTime($dx["start"]);
|
$playlists[$pkey]['start'] = Schedule::AirtimeTimeToPypoTime($dx["start"]);
|
||||||
$playlists[$pkey]['end'] = Schedule::CcTimeToPypoTime($dx["end"]);
|
$playlists[$pkey]['end'] = Schedule::AirtimeTimeToPypoTime($dx["end"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,9 +751,12 @@ class Schedule {
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$result['status'] = array('range' => array('start' => $range_start, 'end' => $range_end),
|
$result['status'] = array('range' => array('start' => $range_start, 'end' => $range_end),
|
||||||
'version' => "1.1");
|
'version' => AIRTIME_REST_VERSION);
|
||||||
$result['playlists'] = $playlists;
|
$result['playlists'] = $playlists;
|
||||||
$result['check'] = 1;
|
$result['check'] = 1;
|
||||||
|
$result['stream_metadata'] = array();
|
||||||
|
$result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat();
|
||||||
|
$result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -757,6 +777,7 @@ class Schedule {
|
||||||
$scheduleGroup = new ScheduleGroup($item["group_id"]);
|
$scheduleGroup = new ScheduleGroup($item["group_id"]);
|
||||||
$scheduleGroup->remove();
|
$scheduleGroup->remove();
|
||||||
}
|
}
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,50 +6,60 @@ class Show {
|
||||||
|
|
||||||
public function __construct($showId=NULL)
|
public function __construct($showId=NULL)
|
||||||
{
|
{
|
||||||
$this->_showId = $showId;
|
$this->_showId = $showId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
return $show->getDbName();
|
return $show->getDbName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setName($name) {
|
public function setName($name)
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
$show->setDbName($name);
|
$show->setDbName($name);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
return $show->getDbDescription();
|
return $show->getDbDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDescription($description) {
|
public function setDescription($description)
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
$show->setDbDescription($description);
|
$show->setDbDescription($description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColor() {
|
public function getColor()
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
return $show->getDbColor();
|
return $show->getDbColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setColor($color) {
|
public function setColor($color)
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
$show->setDbColor($color);
|
$show->setDbColor($color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBackgroundColor() {
|
public function getBackgroundColor()
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
return $show->getDbBackgroundColor();
|
return $show->getDbBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBackgroundColor($backgroundColor) {
|
public function setBackgroundColor($backgroundColor)
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||||
$show->setDbBackgroundColor($backgroundColor);
|
$show->setDbBackgroundColor($backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancelShow($day_timestamp) {
|
public function cancelShow($day_timestamp)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$timeinfo = explode(" ", $day_timestamp);
|
$timeinfo = explode(" ", $day_timestamp);
|
||||||
|
@ -62,20 +72,21 @@ class Show {
|
||||||
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
|
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
//end dates are non inclusive.
|
//end dates are non inclusive.
|
||||||
public static function addShow($data) {
|
public static function addShow($data)
|
||||||
|
{
|
||||||
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
|
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
|
||||||
|
|
||||||
$sql = "SELECT time '{$data['add_show_start_time']}' + INTERVAL '{$data['add_show_duration']} hour' ";
|
$sql = "SELECT time '{$data['add_show_start_time']}' + INTERVAL '{$data['add_show_duration']} hour' ";
|
||||||
$r = $con->query($sql);
|
$r = $con->query($sql);
|
||||||
$endTime = $r->fetchColumn(0);
|
$endTime = $r->fetchColumn(0);
|
||||||
|
|
||||||
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$data['add_show_start_date']} {$data['add_show_start_time']}')";
|
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$data['add_show_start_date']} {$data['add_show_start_time']}')";
|
||||||
$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;
|
||||||
|
@ -84,13 +95,13 @@ class Show {
|
||||||
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);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '1 day' ";
|
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '1 day' ";
|
||||||
$r = $con->query($sql);
|
$r = $con->query($sql);
|
||||||
$endDate = $r->fetchColumn(0);
|
$endDate = $r->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//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']) {
|
||||||
|
@ -98,7 +109,7 @@ class Show {
|
||||||
}
|
}
|
||||||
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']) {
|
||||||
|
@ -114,7 +125,7 @@ class Show {
|
||||||
$show->setDbUrl($data['add_show_url']);
|
$show->setDbUrl($data['add_show_url']);
|
||||||
$show->setDbColor($data['add_show_color']);
|
$show->setDbColor($data['add_show_color']);
|
||||||
$show->setDbBackgroundColor($data['add_show_background_color']);
|
$show->setDbBackgroundColor($data['add_show_background_color']);
|
||||||
$show->save();
|
$show->save();
|
||||||
|
|
||||||
$showId = $show->getDbId();
|
$showId = $show->getDbId();
|
||||||
|
|
||||||
|
@ -127,7 +138,6 @@ 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);
|
||||||
|
@ -137,29 +147,25 @@ class Show {
|
||||||
$showDay->setDbShowId($showId);
|
$showDay->setDbShowId($showId);
|
||||||
$showDay->setDbRecord($isRecorded);
|
$showDay->setDbRecord($isRecorded);
|
||||||
$showDay->save();
|
$showDay->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
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;
|
||||||
else
|
else
|
||||||
$daysAdd = $day - $startDow;
|
$daysAdd = $day - $startDow;
|
||||||
|
|
||||||
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' ";
|
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' ";
|
||||||
$r = $con->query($sql);
|
$r = $con->query($sql);
|
||||||
$start = $r->fetchColumn(0);
|
$start = $r->fetchColumn(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$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);
|
||||||
|
@ -180,7 +186,6 @@ class Show {
|
||||||
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]);
|
||||||
|
@ -190,14 +195,13 @@ 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);
|
||||||
|
|
||||||
$showRebroad = new CcShowRebroadcast();
|
$showRebroad = new CcShowRebroadcast();
|
||||||
$showRebroad->setDbDayOffset($offset_days." days");
|
$showRebroad->setDbDayOffset($offset_days." days");
|
||||||
|
@ -207,7 +211,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) {
|
||||||
|
@ -219,18 +223,20 @@ class Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
Show::populateShowUntilLastGeneratedDate($showId);
|
Show::populateShowUntilLastGeneratedDate($showId);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description,
|
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description,
|
||||||
color, background_color, cc_show_instances.id AS instance_id
|
color, background_color, cc_show_instances.id AS instance_id
|
||||||
FROM cc_show_instances
|
FROM cc_show_instances
|
||||||
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id";
|
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id";
|
||||||
|
|
||||||
//only want shows that are starting at the time or later.
|
//only want shows that are starting at the time or later.
|
||||||
if($onlyRecord) {
|
if ($onlyRecord) {
|
||||||
|
|
||||||
$sql = $sql." WHERE (starts >= '{$start_timestamp}' AND starts < timestamp '{$start_timestamp}' + interval '2 hours')";
|
$sql = $sql." WHERE (starts >= '{$start_timestamp}' AND starts < timestamp '{$start_timestamp}' + interval '2 hours')";
|
||||||
$sql = $sql." AND (record = 1)";
|
$sql = $sql." AND (record = 1)";
|
||||||
|
@ -240,10 +246,10 @@ class Show {
|
||||||
$sql = $sql." WHERE ((starts >= '{$start_timestamp}' AND starts < '{$end_timestamp}')
|
$sql = $sql." WHERE ((starts >= '{$start_timestamp}' AND starts < '{$end_timestamp}')
|
||||||
OR (ends > '{$start_timestamp}' AND ends <= '{$end_timestamp}')
|
OR (ends > '{$start_timestamp}' AND ends <= '{$end_timestamp}')
|
||||||
OR (starts <= '{$start_timestamp}' AND ends >= '{$end_timestamp}'))";
|
OR (starts <= '{$start_timestamp}' AND ends >= '{$end_timestamp}'))";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(isset($excludeInstance)) {
|
|
||||||
|
if (isset($excludeInstance)) {
|
||||||
foreach($excludeInstance as $instance) {
|
foreach($excludeInstance as $instance) {
|
||||||
$sql_exclude[] = "cc_show_instances.id != {$instance}";
|
$sql_exclude[] = "cc_show_instances.id != {$instance}";
|
||||||
}
|
}
|
||||||
|
@ -257,8 +263,8 @@ class Show {
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function setNextPop($next_date, $show_id, $day) {
|
private static function setNextPop($next_date, $show_id, $day)
|
||||||
|
{
|
||||||
$nextInfo = explode(" ", $next_date);
|
$nextInfo = explode(" ", $next_date);
|
||||||
|
|
||||||
$repeatInfo = CcShowDaysQuery::create()
|
$repeatInfo = CcShowDaysQuery::create()
|
||||||
|
@ -271,15 +277,16 @@ class Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
//for a show with repeat_type == -1
|
//for a show with repeat_type == -1
|
||||||
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp) {
|
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$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;
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||||
$end = $CC_DBC->GetOne($sql);
|
$end = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
@ -298,10 +305,10 @@ class Show {
|
||||||
foreach($rebroadcasts as $rebroadcast) {
|
foreach($rebroadcasts as $rebroadcast) {
|
||||||
|
|
||||||
$timeinfo = explode(" ", $start);
|
$timeinfo = explode(" ", $start);
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
||||||
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
|
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
||||||
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
@ -315,12 +322,13 @@ class Show {
|
||||||
$newRebroadcastInstance->save();
|
$newRebroadcastInstance->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
//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)) {
|
||||||
$next_date = $next_pop_date." ".$start_time;
|
$next_date = $next_pop_date." ".$start_time;
|
||||||
|
@ -333,9 +341,9 @@ class Show {
|
||||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
|
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
|
||||||
|
|
||||||
$start = $next_date;
|
$start = $next_date;
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||||
$end = $CC_DBC->GetOne($sql);
|
$end = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
@ -351,10 +359,10 @@ class Show {
|
||||||
foreach($rebroadcasts as $rebroadcast) {
|
foreach($rebroadcasts as $rebroadcast) {
|
||||||
|
|
||||||
$timeinfo = explode(" ", $next_date);
|
$timeinfo = explode(" ", $next_date);
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
|
||||||
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
|
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
|
||||||
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
@ -373,64 +381,65 @@ class Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
Show::setNextPop($next_date, $show_id, $day);
|
Show::setNextPop($next_date, $show_id, $day);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function populateShow($repeat_type, $show_id, $next_pop_date,
|
private static function populateShow($repeat_type, $show_id, $next_pop_date,
|
||||||
$first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp) {
|
$first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp) {
|
||||||
|
|
||||||
if($repeat_type == -1) {
|
if($repeat_type == -1) {
|
||||||
Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp);
|
Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp);
|
||||||
}
|
}
|
||||||
else if($repeat_type == 0) {
|
else if($repeat_type == 0) {
|
||||||
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||||
$start_time, $duration, $day, $record, $end_timestamp, '7 days');
|
$start_time, $duration, $day, $record, $end_timestamp, '7 days');
|
||||||
}
|
}
|
||||||
else if($repeat_type == 1) {
|
else if($repeat_type == 1) {
|
||||||
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||||
$start_time, $duration, $day, $record, $end_timestamp, '14 days');
|
$start_time, $duration, $day, $record, $end_timestamp, '14 days');
|
||||||
}
|
}
|
||||||
else if($repeat_type == 2) {
|
else if($repeat_type == 2) {
|
||||||
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||||
$start_time, $duration, $day, $record, $end_timestamp, '1 month');
|
$start_time, $duration, $day, $record, $end_timestamp, '1 month');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//used to catch up a newly added show
|
//used to catch up a newly added show
|
||||||
private static function populateShowUntilLastGeneratedDate($show_id) {
|
private static function populateShowUntilLastGeneratedDate($show_id) {
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||||
|
|
||||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$show_id}";
|
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$show_id}";
|
||||||
$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"], $showsPopUntil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function populateShowsUntil($pop_timestamp, $end_timestamp) {
|
public static function populateShowsUntil($pop_timestamp, $end_timestamp) {
|
||||||
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 < '{$end_timestamp}' AND last_show > '{$pop_timestamp}'";
|
||||||
}
|
}
|
||||||
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 < '{$end_timestamp}' 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"], $end_timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFullCalendarEvents($start, $end, $editable=false) {
|
public static function getFullCalendarEvents($start, $end, $editable=false) {
|
||||||
|
@ -460,7 +469,7 @@ class Show {
|
||||||
|
|
||||||
private static function makeFullCalendarEvent($show, $options=array()) {
|
private static function makeFullCalendarEvent($show, $options=array()) {
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$event = array();
|
$event = array();
|
||||||
|
|
||||||
if($show["rebroadcast"]) {
|
if($show["rebroadcast"]) {
|
||||||
|
@ -500,56 +509,68 @@ class ShowInstance {
|
||||||
|
|
||||||
public function __construct($instanceId)
|
public function __construct($instanceId)
|
||||||
{
|
{
|
||||||
$this->_instanceId = $instanceId;
|
$this->_instanceId = $instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowId() {
|
public function getShowId()
|
||||||
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
return $showInstance->getDbShowId();
|
return $showInstance->getDbShowId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowInstanceId() {
|
public function getShowInstanceId()
|
||||||
|
{
|
||||||
return $this->_instanceId;
|
return $this->_instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isRebroadcast() {
|
public function isRebroadcast()
|
||||||
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
return $showInstance->getDbOriginalShow();
|
return $showInstance->getDbOriginalShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isRecorded() {
|
public function isRecorded()
|
||||||
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
return $showInstance->getDbRecord();
|
return $showInstance->getDbRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
$show = CcShowQuery::create()->findPK($this->getShowId());
|
$show = CcShowQuery::create()->findPK($this->getShowId());
|
||||||
return $show->getDbName();
|
return $show->getDbName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowStart() {
|
public function getShowStart()
|
||||||
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
return $showInstance->getDbStarts();
|
return $showInstance->getDbStarts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowEnd() {
|
public function getShowEnd()
|
||||||
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
return $showInstance->getDbEnds();
|
return $showInstance->getDbEnds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setShowStart($start) {
|
public function setShowStart($start)
|
||||||
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
$showInstance->setDbStarts($start)
|
$showInstance->setDbStarts($start)
|
||||||
->save();
|
->save();
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setShowEnd($end) {
|
public function setShowEnd($end)
|
||||||
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
$showInstance->setDbEnds($end)
|
$showInstance->setDbEnds($end)
|
||||||
->save();
|
->save();
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveScheduledShowContent($deltaDay, $deltaHours, $deltaMin) {
|
public function moveScheduledShowContent($deltaDay, $deltaHours, $deltaMin)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$sql = "UPDATE cc_schedule
|
$sql = "UPDATE cc_schedule
|
||||||
|
@ -558,9 +579,11 @@ class ShowInstance {
|
||||||
WHERE instance_id = '{$this->_instanceId}'";
|
WHERE instance_id = '{$this->_instanceId}'";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveShow($deltaDay, $deltaMin){
|
public function moveShow($deltaDay, $deltaMin)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$hours = $deltaMin/60;
|
$hours = $deltaMin/60;
|
||||||
|
@ -572,7 +595,7 @@ class ShowInstance {
|
||||||
$mins = abs($deltaMin%60);
|
$mins = abs($deltaMin%60);
|
||||||
|
|
||||||
$starts = $this->getShowStart();
|
$starts = $this->getShowStart();
|
||||||
$ends = $this->getShowEnd();
|
$ends = $this->getShowEnd();
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
$sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
||||||
$new_starts = $CC_DBC->GetOne($sql);
|
$new_starts = $CC_DBC->GetOne($sql);
|
||||||
|
@ -595,18 +618,20 @@ class ShowInstance {
|
||||||
if($rebroadcast) {
|
if($rebroadcast) {
|
||||||
$sql = "SELECT timestamp '{$new_starts}' < (SELECT starts FROM cc_show_instances WHERE id = {$rebroadcast})";
|
$sql = "SELECT timestamp '{$new_starts}' < (SELECT starts FROM cc_show_instances WHERE id = {$rebroadcast})";
|
||||||
$isBeforeRecordedOriginal = $CC_DBC->GetOne($sql);
|
$isBeforeRecordedOriginal = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if($isBeforeRecordedOriginal === 't'){
|
if($isBeforeRecordedOriginal === 't'){
|
||||||
return "Cannot move a rebroadcast show before its original";
|
return "Cannot move a rebroadcast show before its original";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->moveScheduledShowContent($deltaDay, $hours, $mins);
|
$this->moveScheduledShowContent($deltaDay, $hours, $mins);
|
||||||
$this->setShowStart($new_starts);
|
$this->setShowStart($new_starts);
|
||||||
$this->setShowEnd($new_ends);
|
$this->setShowEnd($new_ends);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resizeShow($deltaDay, $deltaMin){
|
public function resizeShow($deltaDay, $deltaMin)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$hours = $deltaMin/60;
|
$hours = $deltaMin/60;
|
||||||
|
@ -618,7 +643,7 @@ class ShowInstance {
|
||||||
$mins = abs($deltaMin%60);
|
$mins = abs($deltaMin%60);
|
||||||
|
|
||||||
$starts = $this->getShowStart();
|
$starts = $this->getShowStart();
|
||||||
$ends = $this->getShowEnd();
|
$ends = $this->getShowEnd();
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
||||||
$new_ends = $CC_DBC->GetOne($sql);
|
$new_ends = $CC_DBC->GetOne($sql);
|
||||||
|
@ -639,106 +664,109 @@ class ShowInstance {
|
||||||
WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}";
|
WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}";
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setShowEnd($new_ends);
|
$this->setShowEnd($new_ends);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLastGroupId() {
|
private function getLastGroupId()
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT group_id FROM cc_schedule WHERE instance_id = '{$this->_instanceId}' ORDER BY ends DESC LIMIT 1";
|
$sql = "SELECT group_id FROM cc_schedule WHERE instance_id = '{$this->_instanceId}' ORDER BY ends DESC LIMIT 1";
|
||||||
$res = $CC_DBC->GetOne($sql);
|
$res = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
$groupId = $sched->addPlaylistAfter($this->_instanceId, $lastGroupId, $plId);
|
$groupId = $sched->addPlaylistAfter($this->_instanceId, $lastGroupId, $plId);
|
||||||
}
|
}
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scheduleShow($plIds) {
|
public function scheduleShow($plIds)
|
||||||
|
{
|
||||||
foreach($plIds as $plId) {
|
foreach($plIds as $plId) {
|
||||||
$this->addPlaylistToShow($plId);
|
$this->addPlaylistToShow($plId);
|
||||||
}
|
}
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeGroupFromShow($group_id){
|
public function removeGroupFromShow($group_id)
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT MAX(ends) as end_timestamp, (MAX(ends) - MIN(starts)) as length
|
$sql = "SELECT MAX(ends) as end_timestamp, (MAX(ends) - MIN(starts)) as length
|
||||||
FROM cc_schedule
|
FROM cc_schedule
|
||||||
WHERE group_id = '{$group_id}'";
|
WHERE group_id = '{$group_id}'";
|
||||||
|
|
||||||
$groupBoundry = $CC_DBC->GetRow($sql);
|
$groupBoundry = $CC_DBC->GetRow($sql);
|
||||||
|
|
||||||
$group = CcScheduleQuery::create()
|
$group = CcScheduleQuery::create()
|
||||||
->filterByDbGroupId($group_id)
|
->filterByDbGroupId($group_id)
|
||||||
->delete();
|
->delete();
|
||||||
|
|
||||||
$sql = "UPDATE cc_schedule
|
$sql = "UPDATE cc_schedule
|
||||||
SET starts = (starts - INTERVAL '{$groupBoundry["length"]}'), ends = (ends - INTERVAL '{$groupBoundry["length"]}')
|
SET starts = (starts - INTERVAL '{$groupBoundry["length"]}'), ends = (ends - INTERVAL '{$groupBoundry["length"]}')
|
||||||
WHERE starts >= '{$groupBoundry["end_timestamp"]}' AND instance_id = {$this->_instanceId}";
|
WHERE starts >= '{$groupBoundry["end_timestamp"]}' AND instance_id = {$this->_instanceId}";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearShow() {
|
public function clearShow()
|
||||||
|
{
|
||||||
CcScheduleQuery::create()
|
CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($this->_instanceId)
|
->filterByDbInstanceId($this->_instanceId)
|
||||||
->delete();
|
->delete();
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteShow() {
|
public function deleteShow()
|
||||||
|
{
|
||||||
CcShowInstancesQuery::create()
|
CcShowInstancesQuery::create()
|
||||||
->findPK($this->_instanceId)
|
->findPK($this->_instanceId)
|
||||||
->delete();
|
->delete();
|
||||||
|
RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTimeScheduled() {
|
public function getTimeScheduled()
|
||||||
|
{
|
||||||
$instance_id = $this->getShowInstanceId();
|
$instance_id = $this->getShowInstanceId();
|
||||||
$time = Schedule::GetTotalShowTime($instance_id);
|
$time = Schedule::GetTotalShowTime($instance_id);
|
||||||
|
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTimeUnScheduled() {
|
public function getTimeUnScheduled()
|
||||||
|
{
|
||||||
$start_timestamp = $this->getShowStart();
|
$start_timestamp = $this->getShowStart();
|
||||||
$end_timestamp = $this->getShowEnd();
|
$end_timestamp = $this->getShowEnd();
|
||||||
$instance_id = $this->getShowInstanceId();
|
$instance_id = $this->getShowInstanceId();
|
||||||
|
|
||||||
$time = Schedule::getTimeUnScheduledInRange($instance_id, $start_timestamp, $end_timestamp);
|
$time = Schedule::getTimeUnScheduledInRange($instance_id, $start_timestamp, $end_timestamp);
|
||||||
|
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPercentScheduled() {
|
public function getPercentScheduled()
|
||||||
|
{
|
||||||
$start_timestamp = $this->getShowStart();
|
$start_timestamp = $this->getShowStart();
|
||||||
$end_timestamp = $this->getShowEnd();
|
$end_timestamp = $this->getShowEnd();
|
||||||
$instance_id = $this->getShowInstanceId();
|
$instance_id = $this->getShowInstanceId();
|
||||||
|
|
||||||
return Schedule::GetPercentScheduled($instance_id, $start_timestamp, $end_timestamp);
|
return Schedule::GetPercentScheduled($instance_id, $start_timestamp, $end_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowLength() {
|
public function getShowLength()
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$start_timestamp = $this->getShowStart();
|
$start_timestamp = $this->getShowStart();
|
||||||
$end_timestamp = $this->getShowEnd();
|
$end_timestamp = $this->getShowEnd();
|
||||||
|
|
||||||
$sql = "SELECT TIMESTAMP '{$end_timestamp}' - TIMESTAMP '{$start_timestamp}' ";
|
$sql = "SELECT TIMESTAMP '{$end_timestamp}' - TIMESTAMP '{$start_timestamp}' ";
|
||||||
|
@ -747,26 +775,27 @@ class ShowInstance {
|
||||||
return $length;
|
return $length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchPlaylistsForShow($datatables){
|
public function searchPlaylistsForShow($datatables)
|
||||||
|
{
|
||||||
$time_remaining = $this->getTimeUnScheduled();
|
$time_remaining = $this->getTimeUnScheduled();
|
||||||
|
|
||||||
return StoredFile::searchPlaylistsForSchedule($time_remaining, $datatables);
|
return StoredFile::searchPlaylistsForSchedule($time_remaining, $datatables);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowListContent() {
|
public function getShowListContent()
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id
|
FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id
|
||||||
LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id )
|
LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id )
|
||||||
|
|
||||||
WHERE s.instance_id = '{$this->_instanceId}' ORDER BY starts";
|
WHERE s.instance_id = '{$this->_instanceId}' ORDER BY starts";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowContent() {
|
public function getShowContent()
|
||||||
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$res = $this->getShowListContent();
|
$res = $this->getShowListContent();
|
||||||
|
@ -788,7 +817,7 @@ class ShowInstance {
|
||||||
$items[$pl_counter]["pl_name"] = $row["name"];
|
$items[$pl_counter]["pl_name"] = $row["name"];
|
||||||
$items[$pl_counter]["pl_creator"] = $row["creator"];
|
$items[$pl_counter]["pl_creator"] = $row["creator"];
|
||||||
$items[$pl_counter]["pl_description"] = $row["description"];
|
$items[$pl_counter]["pl_description"] = $row["description"];
|
||||||
$items[$pl_counter]["pl_group"] = $row["group_id"];
|
$items[$pl_counter]["pl_group"] = $row["group_id"];
|
||||||
|
|
||||||
$sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'";
|
$sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'";
|
||||||
$length = $CC_DBC->GetOne($sql);
|
$length = $CC_DBC->GetOne($sql);
|
||||||
|
@ -802,33 +831,35 @@ class ShowInstance {
|
||||||
$items[$pl_counter]["pl_content"][$f_counter]["f_length"] = $row["length"];
|
$items[$pl_counter]["pl_content"][$f_counter]["f_length"] = $row["length"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show Data Access Layer */
|
/* Show Data Access Layer */
|
||||||
class Show_DAL{
|
class Show_DAL {
|
||||||
|
|
||||||
public static function GetCurrentShow($timeNow) {
|
public static function GetCurrentShow($timeNow)
|
||||||
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$timestamp = explode(" ", $timeNow);
|
$timestamp = explode(" ", $timeNow);
|
||||||
$date = $timestamp[0];
|
$date = $timestamp[0];
|
||||||
$time = $timestamp[1];
|
$time = $timestamp[1];
|
||||||
|
|
||||||
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record"
|
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record"
|
||||||
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
||||||
." WHERE si.show_id = s.id"
|
." WHERE si.show_id = s.id"
|
||||||
." AND si.starts <= TIMESTAMP '$timeNow'"
|
." AND si.starts <= TIMESTAMP '$timeNow'"
|
||||||
." AND si.ends > TIMESTAMP '$timeNow'";
|
." AND si.ends > TIMESTAMP '$timeNow'";
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetNextShow($timeNow) {
|
public static function GetNextShow($timeNow)
|
||||||
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM "
|
$sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM "
|
||||||
." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
||||||
." WHERE si.show_id = s.id"
|
." WHERE si.show_id = s.id"
|
||||||
|
@ -836,12 +867,13 @@ class Show_DAL{
|
||||||
." AND si.starts < TIMESTAMP '$timeNow' + INTERVAL '48 hours'"
|
." AND si.starts < TIMESTAMP '$timeNow' + INTERVAL '48 hours'"
|
||||||
." ORDER BY si.starts"
|
." ORDER BY si.starts"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetShowsInRange($timeNow, $start, $end){
|
public static function GetShowsInRange($timeNow, $start, $end)
|
||||||
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$sql = "SELECT"
|
$sql = "SELECT"
|
||||||
." si.starts as show_starts,"
|
." si.starts as show_starts,"
|
||||||
|
@ -873,5 +905,5 @@ class Show_DAL{
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
import airtime_api_client
|
|
||||||
import obp_api_client
|
|
||||||
|
|
||||||
def create_api_client(config):
|
|
||||||
if config["api_client"] == "airtime":
|
|
||||||
return campcaster_api_client.AirtimeApiClient(config)
|
|
||||||
elif config["api_client"] == "obp":
|
|
||||||
return obp_api_client.ObpApiClient(config)
|
|
||||||
|
|
Loading…
Reference in New Issue