Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

Conflicts:
	python_apps/pypo/pypopush.py
This commit is contained in:
Martin Konecny 2012-03-28 22:49:57 -04:00
commit 29afb6e191
29 changed files with 496 additions and 266 deletions

View File

@ -34,7 +34,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
$ccAcl->allow('G', 'index')
->allow('G', 'login')
->allow('G', 'error')
->allow('G', 'nowplaying')
->allow('G', 'showbuilder')
->allow('G', 'api')
->allow('G', 'auth')
->allow('G', 'recorder')
@ -45,7 +45,6 @@ $ccAcl->allow('G', 'index')
->allow('H', 'library')
->allow('H', 'search')
->allow('H', 'playlist')
->allow('H', 'showbuilder')
->allow('A', 'playouthistory')
->allow('A', 'user')
->allow('A', 'systemstatus')

View File

@ -29,46 +29,16 @@ class LibraryController extends Zend_Controller_Action
public function indexAction() {
global $CC_CONFIG;
$this->_helper->layout->setLayout('library');
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'),'text/javascript');
$this->_helper->actionStack('library', 'library');
$this->_helper->actionStack('index', 'playlist');
}
public function libraryAction()
{
global $CC_CONFIG;
$this->_helper->viewRenderer->setResponseSegment('library');
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->_helper->viewRenderer->setResponseSegment('library');
}
public function contextMenuAction()

View File

@ -113,6 +113,26 @@ class PlaylistController extends Zend_Controller_Action
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'),'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);

View File

@ -17,17 +17,38 @@ class ShowbuilderController extends Zend_Controller_Action
}
public function indexAction() {
$this->_helper->layout->setLayout('builder');
$this->_helper->viewRenderer->setResponseSegment('dialog');
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript');
$this->_helper->layout->setLayout('builder');
$this->_helper->viewRenderer->setResponseSegment('dialog');
$user = Application_Model_User::GetCurrentUser();
$refer_sses = new Zend_Session_Namespace('referrer');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
@ -92,7 +113,19 @@ class ShowbuilderController extends Zend_Controller_Action
}
}
$this->_helper->actionStack('library', 'library');
$data = Application_Model_Preference::GetValue("nowplaying_screen", true);
if ($data != "") {
$settings = unserialize($data);
if ($settings["library"] == "true") {
$this->view->headScript()->appendScript("AIRTIME.showLib = true;");
}
}
if (!$user->isGuest()) {
$this->_helper->actionStack('library', 'library');
}
$this->_helper->actionStack('builder', 'showbuilder');
}
@ -161,6 +194,14 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
$user = Application_Model_User::GetCurrentUser();
if (!$user->isGuest()) {
$this->view->toggleLib = true;
}
else {
$this->view->toggleLib = false;
}
}
public function builderDialogAction() {
@ -206,9 +247,6 @@ class ShowbuilderController extends Zend_Controller_Action
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
Logging::log("showbuilder starts {$startsDT->format("Y-m-d H:i:s")}");
Logging::log("showbuilder ends {$endsDT->format("Y-m-d H:i:s")}");
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
@ -251,11 +289,11 @@ class ShowbuilderController extends Zend_Controller_Action
$request = $this->getRequest();
$mediaItems = $request->getParam("mediaIds", array());
$scheduledIds = $request->getParam("schedIds", array());
$scheduledItems = $request->getParam("schedIds", array());
try {
$scheduler = new Application_Model_Scheduler();
$scheduler->scheduleAfter($scheduledIds, $mediaItems);
$scheduler->scheduleAfter($scheduledItems, $mediaItems);
}
catch (OutDatedScheduleException $e) {
$this->view->error = $e->getMessage();
@ -297,12 +335,12 @@ class ShowbuilderController extends Zend_Controller_Action
public function scheduleMoveAction() {
$request = $this->getRequest();
$selectedItem = $request->getParam("selectedItem");
$selectedItems = $request->getParam("selectedItem");
$afterItem = $request->getParam("afterItem");
try {
$scheduler = new Application_Model_Scheduler();
$scheduler->moveItem($selectedItem, $afterItem);
$scheduler->moveItem($selectedItems, $afterItem);
}
catch (OutDatedScheduleException $e) {
$this->view->error = $e->getMessage();
@ -324,46 +362,4 @@ class ShowbuilderController extends Zend_Controller_Action
$showInstance = $request->getParam("instanceId");
}
/*
* make sure any incoming requests for scheduling are ligit.
*
* @param array $items, an array containing pks of cc_schedule items.
*/
private function filterSelected($items) {
$allowed = array();
$user = Application_Model_User::GetCurrentUser();
$type = $user->getType();
//item must be within the host's show.
if ($type === UTYPE_HOST) {
$hosted = CcShowHostsQuery::create()
->filterByDbHost($user->getId())
->find();
$allowed_shows = array();
foreach ($hosted as $host) {
$allowed_shows[] = $host->getDbShow();
}
for ($i = 0; $i < count($items); $i++) {
$instance = $items[$i]["instance"];
if (in_array($instance, $allowed_shows)) {
$allowed[] = $items[$i];
}
}
$this->view->shows = $res;
}
//they can schedule anything.
else if ($type === UTYPE_ADMIN || $type === UTYPE_PROGRAM_MANAGER) {
$allowed = $items;
}
return $allowed;
}
}

View File

@ -6,12 +6,31 @@ class UsersettingsController extends Zend_Controller_Action
{
/* Initialize action controller here */
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('get-library-datatable', 'json')
$ajaxContext->addActionContext('get-now-playing-screen-settings', 'json')
->addActionContext('set-now-playing-screen-settings', 'json')
->addActionContext('get-library-datatable', 'json')
->addActionContext('set-library-datatable', 'json')
->addActionContext('get-timeline-datatable', 'json')
->addActionContext('set-timeline-datatable', 'json')
->initContext();
}
public function setNowPlayingScreenSettingsAction() {
$request = $this->getRequest();
$settings = $request->getParam("settings");
$data = serialize($settings);
Application_Model_Preference::SetValue("nowplaying_screen", $data, true);
}
public function getNowPlayingScreenSettingsAction() {
$data = Application_Model_Preference::GetValue("nowplaying_screen", true);
if ($data != "") {
$this->view->settings = unserialize($data);
}
}
public function setLibraryDatatableAction() {

View File

@ -44,7 +44,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
//liquidsoap harbor.input port
$m_port = Application_Model_StreamSetting::GetMasterLiveSteamPort();
$master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
$master_dj_port->setLabel("Master DJ Port")
$master_dj_port->setLabel("Master Source Port")
->setValue($m_port)
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
@ -53,7 +53,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$m_mount = Application_Model_StreamSetting::GetMasterLiveSteamMountPoint();
$master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
$master_dj_mount->setLabel("Master DJ Mount Point")
$master_dj_mount->setLabel("Master Source Mount Point")
->setValue($m_mount)
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
@ -63,7 +63,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
//liquidsoap harbor.input port
$l_port = Application_Model_StreamSetting::GetDJLiveSteamPort();
$live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port');
$live_dj_port->setLabel("DJ Port")
$live_dj_port->setLabel("Show Source Port")
->setValue($l_port)
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
@ -72,7 +72,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$l_mount = Application_Model_StreamSetting::GetDJLiveSteamMountPoint();
$live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
$live_dj_mount->setLabel("DJ Mount Point")
$live_dj_mount->setLabel("Show Source Mount Point")
->setValue($l_mount)
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
@ -127,7 +127,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$master_harbor_input_port = $data['master_harbor_input_port'];
$dj_harbor_input_port = $data['dj_harbor_input_port'];
if($master_harbor_input_port == $dj_harbor_input_port){
if($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != ""){
$element = $this->getElement("dj_harbor_input_port");
$element->addError("You cannot use same port as Master DJ port.");
}

View File

@ -15,9 +15,6 @@ class Application_Form_Preferences extends Zend_Form
$general_pref = new Application_Form_GeneralPreferences();
$this->addSubForm($general_pref, 'preferences_general');
$livestream_pref = new Application_Form_LiveStreamingPreferences();
$this->addSubForm($livestream_pref, 'preferences_livestream');
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');

View File

@ -633,11 +633,28 @@ class Application_Model_Schedule {
$data["status"] = array();
$data["media"] = array();
$data["harbor"] = array();
$kick_time = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ();
$temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade());
// we round down transition time since PHP cannot handle millisecond. We need to
// handle this better in the future
$transition_time = intval($temp[0]);
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
$data["harbor"]['next_live_dj_show_end'] = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ();
$data["harbor"]['transition_fade'] = Application_Model_Preference::GetDefaultTransitionFade();
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
$data["media"][$kick_start]['start'] = $kick_start;
$data["media"][$kick_start]['end'] = $kick_start;
$data["media"][$kick_start]['event_type'] = "kick_out";
$data["media"][$kick_start]['type'] = "event";
if($kick_time !== $switch_off_time){
$data["media"][$switch_start]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
$data["media"][$switch_start]['end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
$data["media"][$switch_start]['event_type'] = "switch_off";
$data["media"][$switch_start]['type'] = "event";
}
foreach ($items as $item){
@ -662,6 +679,7 @@ class Application_Model_Schedule {
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
$data["media"][$start] = array(
'id' => $storedFile->getGunid(),
'type' => "file",
'row_id' => $item["id"],
'uri' => $uri,
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),

View File

@ -12,10 +12,90 @@ class Application_Model_Scheduler {
"fadeout" => "00:00:00",
"sched_id" => null,
);
private $nowDT;
private $user;
public function __construct($id = null) {
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->nowDT = new DateTime("now", new DateTimeZone("UTC"));
$this->user = Application_Model_User::GetCurrentUser();
}
/*
* make sure any incoming requests for scheduling are ligit.
*
* @param array $items, an array containing pks of cc_schedule items.
*/
private function validateRequest($items) {
$nowEpoch = intval($this->nowDT->format("U"));
for ($i = 0; $i < count($items); $i++) {
$id = $items[$i]["id"];
//could be added to the beginning of a show, which sends id = 0;
if ($id > 0) {
$schedInfo[$id] = $items[$i]["instance"];
}
$instanceInfo[$items[$i]["instance"]] = $items[$i]["timestamp"];
}
if (count($instanceInfo) === 0) {
throw new Exception("Invalid Request.");
}
$schedIds = array();
if (isset($schedInfo)) {
$schedIds = array_keys($schedInfo);
}
$schedItems = CcScheduleQuery::create()->findPKs($schedIds, $this->con);
$instanceIds = array_keys($instanceInfo);
$showInstances = CcShowInstancesQuery::create()->findPKs($instanceIds, $this->con);
//an item has been deleted
if (count($schedIds) !== count($schedItems)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (sched mismatch)");
}
//a show has been deleted
if (count($instanceIds) !== count($showInstances)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (instance mismatch)");
}
foreach ($schedItems as $schedItem) {
$id = $schedItem->getDbId();
$instance = $schedItem->getCcShowInstances($this->con);
if (intval($schedInfo[$id]["instance"]) !== $instance->getDbId()) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
}
foreach ($showInstances as $instance) {
$id = $instance->getDbId();
$show = $instance->getCcShow($this->con);
if ($this->user->canSchedule($show->getDbId()) === false) {
throw new Exception("You are not allowed to schedule show {$show->getDbName()}.");
}
$showEndEpoch = intval($instance->getDbEnds("U"));
if ($showEndEpoch < $nowEpoch) {
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
}
$origTs = intval($instanceInfo[$id]);
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($origTs !== $currTs) {
Logging::log("orig {$origTs} current {$currTs}");
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
}
}
/*
@ -112,25 +192,22 @@ class Application_Model_Scheduler {
private function findNextStartTime($DT, $instance) {
//check to see if the show has started.
$nowDT = new DateTime("now", new DateTimeZone("UTC"));
$sEpoch = intval($DT->format("U"));
$nEpoch = intval($nowDT->format("U"));
$nowEpoch = intval($this->nowDT->format("U"));
//check for if the show has started.
if ($nEpoch > $sEpoch) {
if ($nowEpoch > $sEpoch) {
//need some kind of placeholder for cc_schedule.
//playout_status will be -1.
$nextDT = $nowDT;
$nextDT = $this->nowDT;
$length = $nEpoch - $sEpoch;
$length = $nowEpoch - $sEpoch;
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
//fillers are for only storing a chunk of time space that has already passed.
$filler = new CcSchedule();
$filler->setDbStarts($DT)
->setDbEnds($nowDT)
->setDbEnds($this->nowDT)
->setDbClipLength($cliplength)
->setDbPlayoutStatus(-1)
->setDbInstanceId($instance->getDbId())
@ -164,45 +241,27 @@ class Application_Model_Scheduler {
foreach ($scheduleItems as $schedule) {
$id = intval($schedule["id"]);
$ts = intval($schedule["timestamp"]);
Logging::log("scheduling after scheduled item: ".$id);
Logging::log("in show: ".intval($schedule["instance"]));
if ($id !== 0) {
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
if (is_null($schedItem)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$instance = $schedItem->getCcShowInstances($this->con);
if (intval($schedule["instance"]) !== $instance->getDbId()) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$schedItemEndDT = $schedItem->getDbEnds(null);
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
}
//selected empty row to add after
else {
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
//check to see if the show has started.
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
$showStartDT = $instance->getDbStarts(null);
$nextStartDT = $this->findNextStartTime($showStartDT, $instance);
}
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
//user has an old copy of the time line opened.
if ($ts !== $currTs) {
Logging::log("currTs {$currTs}, ts {$ts}");
$show = $instance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
if (!in_array($instance->getDbId(), $affectedShowInstances)) {
$affectedShowInstances[] = $instance->getDbId();
}
Logging::log("finding items >= {$nextStartDT->format("Y-m-d H:i:s.u")}");
if ($adjustSched === true) {
$followingSchedItems = CcScheduleQuery::create()
->filterByDBStarts($nextStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL)
@ -210,16 +269,10 @@ class Application_Model_Scheduler {
->filterByDbId($excludeIds, Criteria::NOT_IN)
->orderByDbStarts()
->find($this->con);
foreach ($excludeIds as $id) {
Logging::log("Excluding id {$id}");
}
}
foreach($schedFiles as $file) {
Logging::log("adding file with id: ".$file["id"]);
$endTimeDT = self::findEndTime($nextStartDT, $file['cliplength']);
//item existed previously and is being moved.
@ -230,10 +283,7 @@ class Application_Model_Scheduler {
else {
$sched = new CcSchedule();
}
Logging::log("id {$sched->getDbId()}");
Logging::log("start time {$nextStartDT->format("Y-m-d H:i:s.u")}");
Logging::log("end time {$endTimeDT->format("Y-m-d H:i:s.u")}");
$sched->setDbStarts($nextStartDT);
$sched->setDbEnds($endTimeDT);
$sched->setDbFileId($file['id']);
@ -251,9 +301,7 @@ class Application_Model_Scheduler {
if ($adjustSched === true) {
//recalculate the start/end times after the inserted items.
foreach($followingSchedItems as $item) {
Logging::log("adjusting iterm {$item->getDbId()}");
foreach ($followingSchedItems as $item) {
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
@ -297,11 +345,10 @@ class Application_Model_Scheduler {
$schedFiles = array();
try {
$this->validateRequest($scheduleItems);
foreach ($mediaItems as $media) {
Logging::log("Media Id ".$media["id"]);
Logging::log("Type ".$media["type"]);
$schedFiles = array_merge($schedFiles, $this->retrieveMediaFiles($media["id"], $media["type"]));
}
$this->insertAfter($scheduleItems, $schedFiles, $adjustSched);
@ -326,27 +373,11 @@ class Application_Model_Scheduler {
try {
//checks on whether the item to move after is ok.
Logging::log("Moving after item: {$afterItems[0]["id"]}");
$origAfterTs = intval($afterItems[0]["timestamp"]);
if (intval($afterItems[0]["id"]) === 0) {
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
}
else {
$after = CcScheduleQuery::create()->findPk($afterItems[0]["id"], $this->con);
if (is_null($after)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$afterInstance = $after->getCcShowInstances($this->con);
}
$currTs = intval($afterInstance->getDbLastScheduled("U")) ? : 0;
if ($origAfterTs !== $currTs) {
$show = $afterInstance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
$this->validateRequest($selectedItems);
$this->validateRequest($afterItems);
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
//map show instances to cc_schedule primary keys.
$modifiedMap = array();
$movedData = array();
@ -354,24 +385,8 @@ class Application_Model_Scheduler {
//prepare each of the selected items.
for ($i = 0; $i < count($selectedItems); $i++) {
Logging::log("Moving item {$selectedItems[$i]["id"]}");
$origSelTs = intval($selectedItems[$i]["timestamp"]);
$selected = CcScheduleQuery::create()->findPk($selectedItems[$i]["id"], $this->con);
if (is_null($selected)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$selectedInstance = $selected->getCcShowInstances($this->con);
if (is_null($selectedInstance) || is_null($afterInstance)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$currTs = intval($selectedInstance->getDbLastScheduled("U")) ? : 0;
if ($origSelTs !== $currTs) {
$show = $selectedInstance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
$data = $this->fileInfo;
$data["id"] = $selected->getDbFileId();
@ -417,29 +432,20 @@ class Application_Model_Scheduler {
$this->con->beginTransaction();
try {
$this->validateRequest($scheduledItems);
$scheduledIds = array();
foreach ($scheduledItems as $item) {
$scheduledIds[$item["id"]] = intval($item["timestamp"]);
$scheduledIds[] = $item["id"];
}
$removedItems = CcScheduleQuery::create()->findPks(array_keys($scheduledIds));
$removedItems = CcScheduleQuery::create()->findPks($scheduledIds);
//check to see if the current item is being deleted so we can truncate the record.
$currentItem = null;
//check to make sure all items selected are up to date
foreach ($removedItems as $removedItem) {
$ts = $scheduledIds[$removedItem->getDbId()];
$instance = $removedItem->getCcShowInstances($this->con);
if (is_null($instance)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($ts !== $currTs) {
$show = $instance->getCcShow($this->con);
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
//check to truncate the currently playing item instead of deleting it.
if ($removedItem->isCurrentItem()) {

View File

@ -1481,7 +1481,7 @@ class Application_Model_Show {
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name,
color, background_color, file_id, cc_show_instances.id AS instance_id,
last_scheduled, time_filled
created, last_scheduled, time_filled
FROM cc_show_instances
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id
WHERE cc_show_instances.modified_instance = FALSE";

View File

@ -275,12 +275,15 @@ class Application_Model_ShowBuilder {
if (isset($show["last_scheduled"])) {
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
//check if any of the shows have a more recent timestamp.
if ($timestamp < intval($dt->format("U"))) {
$outdated = true;
break;
}
}
else {
$dt = new DateTime($show["created"], new DateTimeZone("UTC"));
}
//check if any of the shows have a more recent timestamp.
if ($timestamp < intval($dt->format("U"))) {
$outdated = true;
break;
}
}

View File

@ -26,6 +26,10 @@ class Application_Model_User {
public function getId() {
return $this->_userInstance->getDbId();
}
public function isGuest() {
return $this->getType() == UTYPE_GUEST;
}
public function isHost($showId) {
return $this->isUserType(UTYPE_HOST, $showId);

View File

@ -140,5 +140,11 @@ class CcShowInstances extends BaseCcShowInstances {
->update(array('DbPlayoutStatus' => 0), $con);
}
public function preInsert(PropelPDO $con = null) {
$now = new DateTime("now", new DateTimeZone("UTC"));
$this->setDbCreated($now);
return true;
}
} // CcShowInstances

View File

@ -47,6 +47,7 @@ class CcShowInstancesTableMap extends TableMap {
$this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
$this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null);
$this->addColumn('TIME_FILLED', 'DbTimeFilled', 'VARCHAR', false, null, '00:00:00');
$this->addColumn('CREATED', 'DbCreated', 'TIMESTAMP', true, null, null);
$this->addColumn('LAST_SCHEDULED', 'DbLastScheduled', 'TIMESTAMP', false, null, null);
$this->addColumn('MODIFIED_INSTANCE', 'DbModifiedInstance', 'BOOLEAN', true, null, false);
// validators

View File

@ -726,9 +726,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
if ($v !== null) {
$v = (int) $v;
}
Logging::log('$v status is '.$v);
if ($this->playout_status !== $v || $this->isNew()) {
$this->playout_status = $v;
$this->modifiedColumns[] = CcSchedulePeer::PLAYOUT_STATUS;

View File

@ -81,6 +81,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
*/
protected $time_filled;
/**
* The value for the created field.
* @var string
*/
protected $created;
/**
* The value for the last_scheduled field.
* @var string
@ -293,6 +299,39 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this->time_filled;
}
/**
* Get the [optionally formatted] temporal [created] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbCreated($format = 'Y-m-d H:i:s')
{
if ($this->created === null) {
return null;
}
try {
$dt = new DateTime($this->created);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
/**
* Get the [optionally formatted] temporal [last_scheduled] column value.
*
@ -586,6 +625,55 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this;
} // setDbTimeFilled()
/**
* Sets the value of [created] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcShowInstances The current object (for fluent API support)
*/
public function setDbCreated($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
if ($v === null || $v === '') {
$dt = null;
} elseif ($v instanceof DateTime) {
$dt = $v;
} else {
// some string/numeric value passed; we normalize that so that we can
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
// We have to explicitly specify and then change the time zone because of a
// DateTime bug: http://bugs.php.net/bug.php?id=43003
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
} else {
$dt = new DateTime($v);
}
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ( $this->created !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->created = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
$this->modifiedColumns[] = CcShowInstancesPeer::CREATED;
}
} // if either are not null
return $this;
} // setDbCreated()
/**
* Sets the value of [last_scheduled] column to a normalized version of the date/time value specified.
*
@ -712,8 +800,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->last_scheduled = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->modified_instance = ($row[$startcol + 10] !== null) ? (boolean) $row[$startcol + 10] : null;
$this->created = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->last_scheduled = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
$this->modified_instance = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null;
$this->resetModified();
$this->setNew(false);
@ -722,7 +811,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 11; // 11 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 12; // 12 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShowInstances object", $e);
@ -1147,9 +1236,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this->getDbTimeFilled();
break;
case 9:
return $this->getDbLastScheduled();
return $this->getDbCreated();
break;
case 10:
return $this->getDbLastScheduled();
break;
case 11:
return $this->getDbModifiedInstance();
break;
default:
@ -1185,8 +1277,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$keys[6] => $this->getDbOriginalShow(),
$keys[7] => $this->getDbRecordedFile(),
$keys[8] => $this->getDbTimeFilled(),
$keys[9] => $this->getDbLastScheduled(),
$keys[10] => $this->getDbModifiedInstance(),
$keys[9] => $this->getDbCreated(),
$keys[10] => $this->getDbLastScheduled(),
$keys[11] => $this->getDbModifiedInstance(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcShow) {
@ -1257,9 +1350,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->setDbTimeFilled($value);
break;
case 9:
$this->setDbLastScheduled($value);
$this->setDbCreated($value);
break;
case 10:
$this->setDbLastScheduled($value);
break;
case 11:
$this->setDbModifiedInstance($value);
break;
} // switch()
@ -1295,8 +1391,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbLastScheduled($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setDbModifiedInstance($arr[$keys[10]]);
if (array_key_exists($keys[9], $arr)) $this->setDbCreated($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setDbLastScheduled($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setDbModifiedInstance($arr[$keys[11]]);
}
/**
@ -1317,6 +1414,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id);
if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id);
if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled);
if ($this->isColumnModified(CcShowInstancesPeer::CREATED)) $criteria->add(CcShowInstancesPeer::CREATED, $this->created);
if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) $criteria->add(CcShowInstancesPeer::LAST_SCHEDULED, $this->last_scheduled);
if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) $criteria->add(CcShowInstancesPeer::MODIFIED_INSTANCE, $this->modified_instance);
@ -1388,6 +1486,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$copyObj->setDbOriginalShow($this->instance_id);
$copyObj->setDbRecordedFile($this->file_id);
$copyObj->setDbTimeFilled($this->time_filled);
$copyObj->setDbCreated($this->created);
$copyObj->setDbLastScheduled($this->last_scheduled);
$copyObj->setDbModifiedInstance($this->modified_instance);
@ -1907,6 +2006,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->instance_id = null;
$this->file_id = null;
$this->time_filled = null;
$this->created = null;
$this->last_scheduled = null;
$this->modified_instance = null;
$this->alreadyInSave = false;

View File

@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer {
const TM_CLASS = 'CcShowInstancesTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 11;
const NUM_COLUMNS = 12;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -58,6 +58,9 @@ abstract class BaseCcShowInstancesPeer {
/** the column name for the TIME_FILLED field */
const TIME_FILLED = 'cc_show_instances.TIME_FILLED';
/** the column name for the CREATED field */
const CREATED = 'cc_show_instances.CREATED';
/** the column name for the LAST_SCHEDULED field */
const LAST_SCHEDULED = 'cc_show_instances.LAST_SCHEDULED';
@ -80,12 +83,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbLastScheduled', 'DbModifiedInstance', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbLastScheduled', 'dbModifiedInstance', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::LAST_SCHEDULED, self::MODIFIED_INSTANCE, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'last_scheduled', 'modified_instance', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbCreated', 'DbLastScheduled', 'DbModifiedInstance', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbCreated', 'dbLastScheduled', 'dbModifiedInstance', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::CREATED, self::LAST_SCHEDULED, self::MODIFIED_INSTANCE, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'CREATED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'created', 'last_scheduled', 'modified_instance', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
/**
@ -95,12 +98,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbLastScheduled' => 9, 'DbModifiedInstance' => 10, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbLastScheduled' => 9, 'dbModifiedInstance' => 10, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::LAST_SCHEDULED => 9, self::MODIFIED_INSTANCE => 10, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'LAST_SCHEDULED' => 9, 'MODIFIED_INSTANCE' => 10, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'last_scheduled' => 9, 'modified_instance' => 10, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbCreated' => 9, 'DbLastScheduled' => 10, 'DbModifiedInstance' => 11, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbCreated' => 9, 'dbLastScheduled' => 10, 'dbModifiedInstance' => 11, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::CREATED => 9, self::LAST_SCHEDULED => 10, self::MODIFIED_INSTANCE => 11, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'CREATED' => 9, 'LAST_SCHEDULED' => 10, 'MODIFIED_INSTANCE' => 11, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'created' => 9, 'last_scheduled' => 10, 'modified_instance' => 11, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
/**
@ -181,6 +184,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED);
$criteria->addSelectColumn(CcShowInstancesPeer::CREATED);
$criteria->addSelectColumn(CcShowInstancesPeer::LAST_SCHEDULED);
$criteria->addSelectColumn(CcShowInstancesPeer::MODIFIED_INSTANCE);
} else {
@ -193,6 +197,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn($alias . '.INSTANCE_ID');
$criteria->addSelectColumn($alias . '.FILE_ID');
$criteria->addSelectColumn($alias . '.TIME_FILLED');
$criteria->addSelectColumn($alias . '.CREATED');
$criteria->addSelectColumn($alias . '.LAST_SCHEDULED');
$criteria->addSelectColumn($alias . '.MODIFIED_INSTANCE');
}

View File

@ -15,6 +15,7 @@
* @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column
* @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column
* @method CcShowInstancesQuery orderByDbTimeFilled($order = Criteria::ASC) Order by the time_filled column
* @method CcShowInstancesQuery orderByDbCreated($order = Criteria::ASC) Order by the created column
* @method CcShowInstancesQuery orderByDbLastScheduled($order = Criteria::ASC) Order by the last_scheduled column
* @method CcShowInstancesQuery orderByDbModifiedInstance($order = Criteria::ASC) Order by the modified_instance column
*
@ -27,6 +28,7 @@
* @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column
* @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column
* @method CcShowInstancesQuery groupByDbTimeFilled() Group by the time_filled column
* @method CcShowInstancesQuery groupByDbCreated() Group by the created column
* @method CcShowInstancesQuery groupByDbLastScheduled() Group by the last_scheduled column
* @method CcShowInstancesQuery groupByDbModifiedInstance() Group by the modified_instance column
*
@ -66,6 +68,7 @@
* @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column
* @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column
* @method CcShowInstances findOneByDbTimeFilled(string $time_filled) Return the first CcShowInstances filtered by the time_filled column
* @method CcShowInstances findOneByDbCreated(string $created) Return the first CcShowInstances filtered by the created column
* @method CcShowInstances findOneByDbLastScheduled(string $last_scheduled) Return the first CcShowInstances filtered by the last_scheduled column
* @method CcShowInstances findOneByDbModifiedInstance(boolean $modified_instance) Return the first CcShowInstances filtered by the modified_instance column
*
@ -78,6 +81,7 @@
* @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column
* @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column
* @method array findByDbTimeFilled(string $time_filled) Return CcShowInstances objects filtered by the time_filled column
* @method array findByDbCreated(string $created) Return CcShowInstances objects filtered by the created column
* @method array findByDbLastScheduled(string $last_scheduled) Return CcShowInstances objects filtered by the last_scheduled column
* @method array findByDbModifiedInstance(boolean $modified_instance) Return CcShowInstances objects filtered by the modified_instance column
*
@ -445,6 +449,37 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria
return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison);
}
/**
* Filter the query on the created column
*
* @param string|array $dbCreated The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbCreated($dbCreated = null, $comparison = null)
{
if (is_array($dbCreated)) {
$useMinMax = false;
if (isset($dbCreated['min'])) {
$this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbCreated['max'])) {
$this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated, $comparison);
}
/**
* Filter the query on the last_scheduled column
*

View File

@ -72,7 +72,7 @@
<?php endif; ?>
</dd>
<dt id="master_dj_connection_url-label">
<label class="optional" for="master_dj_connection_url">Master DJ Connection URL:
<label class="optional" for="master_dj_connection_url">Master Source Connection URL:
</label>
</dt>
<dd id="master_dj_connection_url-element">
@ -108,7 +108,7 @@
<?php endif; ?>
</dd>
<dt id="live_dj_connection_url-label">
<label class="optional" for="live_dj_connection_url">Live DJ Connection URL:
<label class="optional" for="live_dj_connection_url">Show Source Connection URL:
</label>
</dt>
<dd id="live_dj_connection_url-element">

View File

@ -5,7 +5,6 @@
<?php echo $this->element->getElement('sb_date_end') ?>
<?php echo $this->element->getElement('sb_time_end') ?>
<input type="button" id="sb_submit" class="ui-button ui-state-default" value="GO"></input>
<input type="button" id="sb_edit" class="ui-button ui-state-default sb-edit" value="Add Files"></input>
</div>
<div class="sb-advanced-options">
<fieldset class="padded display_field toggle push-down-8 closed">

View File

@ -1,2 +1,8 @@
<?php if ($this->toggleLib): ?>
<div id="sb_edit" class="ui-state-default" title="open the library to schedule files.">
<span class="ui-icon ui-icon-arrowthick-1-nw"></span>
</div>
<?php endif; ?>
<?php echo $this->sb_form; ?>
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>

View File

@ -161,6 +161,7 @@
<column name="instance_id" phpName="DbOriginalShow" type="INTEGER" required="false"/>
<column name="file_id" phpName="DbRecordedFile" type="INTEGER" required="false"/>
<column name="time_filled" phpName="DbTimeFilled" type="VARCHAR" sqlType="interval" defaultValue="00:00:00" />
<column name="created" phpName="DbCreated" type="TIMESTAMP" required="true"/>
<column name="last_scheduled" phpName="DbLastScheduled" type="TIMESTAMP" required="false"/>
<!-- The purpose of the modified_instance column is to mark a show instance that was
deleted when it was part of repeating show. This is useful because the way shows work,

View File

@ -1,5 +1,9 @@
INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'));
-- added in 2.1
INSERT INTO cc_pref("keystr", "valstr") VALUES('scheduled_play_switch', 'on');
-- end of added in 2.1
-- added in 2.0.0
INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_type', 'ogg, mp3');
INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_bitrate', '24, 32, 48, 64, 96, 128, 160, 192, 224, 256, 320');

View File

@ -207,6 +207,7 @@ CREATE TABLE "cc_show_instances"
"instance_id" INTEGER,
"file_id" INTEGER,
"time_filled" interval default '00:00:00',
"created" TIMESTAMP NOT NULL,
"last_scheduled" TIMESTAMP,
"modified_instance" BOOLEAN default 'f' NOT NULL,
PRIMARY KEY ("id")

View File

@ -12,6 +12,15 @@
margin-left: -16px;
}
#sb_edit {
position: relative;
top: 2px;
float: left;
margin-right: 5px;
padding: 1px 2px;
cursor: pointer;
}
.sb-content .fg-toolbar ul {
float: left;
padding: 0;

View File

@ -828,7 +828,7 @@ var AIRTIME = (function(AIRTIME){
if (oItems.del !== undefined) {
callback = function() {
if (confirm("")) {
if (confirm("Delete selected Items?")) {
AIRTIME.showbuilder.fnRemove([{
id: data.id,
timestamp: data.timestamp,

View File

@ -13,12 +13,7 @@ $(document).ready(function(){
timeStartId = "#sb_time_start",
dateEndId = "#sb_date_end",
timeEndId = "#sb_time_end",
$toggleLib = $('<input />', {
"class": "ui-button ui-state-default sb-edit",
"id": "sb_edit",
"type": "button",
"value": "Add Files"
}),
$toggleLib = $('<div id="sb_edit" class="ui-state-default" title="open the library to schedule files."><span class="ui-icon ui-icon-arrowthick-1-nw"></span></div>'),
$libClose = $('<a />', {
"class": "close-round",
"href": "#",
@ -55,6 +50,16 @@ $(document).ready(function(){
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
AIRTIME.showbuilder.fnServerData.start = oRange.start;
AIRTIME.showbuilder.fnServerData.end = oRange.end;
if (AIRTIME.showLib === true) {
$lib.show()
.width(Math.floor(screenWidth * 0.5));
$builder.width(Math.floor(screenWidth * 0.5))
.find("#sb_edit")
.remove()
.end();
}
AIRTIME.library.libraryInit();
AIRTIME.showbuilder.builderDataTable();
@ -91,8 +96,8 @@ $(document).ready(function(){
oTable.fnDraw();
});
$builder.on("click","#sb_edit", function(ev){
$builder.on("click","#sb_edit", function () {
var schedTable = $("#show_builder_table").dataTable();
//reset timestamp to redraw the cursors.
@ -106,10 +111,18 @@ $(document).ready(function(){
.remove()
.end();
schedTable.fnDraw();
schedTable.fnDraw();
$.ajax({
url: "/usersettings/set-now-playing-screen-settings",
type: "POST",
data: {settings : {library : true}, format: "json"},
dataType: "json",
success: function(){}
});
});
$lib.on("click", "#sb_lib_close", function(ev) {
$lib.on("click", "#sb_lib_close", function() {
var schedTable = $("#show_builder_table").dataTable();
$lib.hide();
@ -119,6 +132,14 @@ $(document).ready(function(){
.end();
schedTable.fnDraw();
$.ajax({
url: "/usersettings/set-now-playing-screen-settings",
type: "POST",
data: {settings : {library : false}, format: "json"},
dataType: "json",
success: function(){}
});
});
$builder.find('legend').click(function(ev, item){

View File

@ -87,10 +87,10 @@ class PypoFetch(Thread):
self.update_liquidsoap_transition_fade(m['transition_fade'])
elif command == 'switch_source':
self.logger.info("switch_on_source show command received...")
self.switch_source(m['sourcename'], m['status'])
self.switch_source(self.logger, self.telnet_lock, m['sourcename'], m['status'])
elif command == 'disconnect_source':
self.logger.info("disconnect_on_source show command received...")
self.disconnect_source(m['sourcename'])
self.disconnect_source(self.logger, self.telnet.lock, m['sourcename'])
except Exception, e:
import traceback
top = traceback.format_exc()
@ -98,27 +98,29 @@ class PypoFetch(Thread):
self.logger.error("traceback: %s", top)
self.logger.error("Exception in handling Message Handler message: %s", e)
def disconnect_source(self,sourcename):
self.logger.debug('Disconnecting source: %s', sourcename)
@staticmethod
def disconnect_source(logger, lock, sourcename):
logger.debug('Disconnecting source: %s', sourcename)
command = ""
if(sourcename == "master_dj"):
command += "master_harbor.kick\n"
elif(sourcename == "live_dj"):
command += "live_dj_harbor.kick\n"
self.telnet_lock.acquire()
lock.acquire()
try:
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
tn.write(command)
tn.write('exit\n')
tn.read_all()
except Exception, e:
self.logger.error(str(e))
logger.error(str(e))
finally:
self.telnet_lock.release()
def switch_source(self, sourcename, status):
self.logger.debug('Switching source: %s to "%s" status', sourcename, status)
lock.release()
@staticmethod
def switch_source(logger, lock, sourcename, status):
logger.debug('Switching source: %s to "%s" status', sourcename, status)
command = "streams."
if(sourcename == "master_dj"):
command += "master_dj_"
@ -132,16 +134,16 @@ class PypoFetch(Thread):
else:
command += "stop\n"
self.telnet_lock.acquire()
lock.acquire()
try:
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
tn.write(command)
tn.write('exit\n')
tn.read_all()
except Exception, e:
self.logger.error(str(e))
logger.error(str(e))
finally:
self.telnet_lock.release()
lock.release()
"""
grabs some information that are needed to be set on bootstrap time
@ -156,7 +158,7 @@ class PypoFetch(Thread):
else:
self.logger.debug('info:%s',info)
for k, v in info['switch_status'].iteritems():
self.switch_source(k, v)
self.switch_source(self.logger, self.telnet_lock, k, v)
self.update_liquidsoap_stream_format(info['stream_label'])
self.update_liquidsoap_station_name(info['station_name'])
self.update_liquidsoap_transition_fade(info['transition_fade'])
@ -374,6 +376,7 @@ class PypoFetch(Thread):
def process_schedule(self, schedule_data):
self.logger.debug(schedule_data)
media = schedule_data["media"]
media_filtered = {}
# Download all the media and put playlists in liquidsoap "annotate" format
try:
@ -389,13 +392,14 @@ class PypoFetch(Thread):
for key in media:
media_item = media[key]
fileExt = os.path.splitext(media_item['uri'])[1]
dst = os.path.join(download_dir, media_item['id']+fileExt)
media_item['dst'] = dst
if(media_item['type'] == 'file'):
fileExt = os.path.splitext(media_item['uri'])[1]
dst = os.path.join(download_dir, media_item['id']+fileExt)
media_item['dst'] = dst
media_filtered[key] = media_item
self.media_prepare_queue.put(copy.copy(media))
self.prepare_media(media)
self.media_prepare_queue.put(copy.copy(media_filtered))
self.prepare_media(media_filtered)
except Exception, e: self.logger.error("%s", e)
# Send the data to pypo-push

View File

@ -9,6 +9,7 @@ import telnetlib
import calendar
import json
import math
from pypofetch import PypoFetch
from Queue import Empty
@ -204,7 +205,9 @@ class PypoPush(Thread):
for mkey in sorted_keys:
media_item = media_schedule[mkey]
if len(current_chain) == 0:
if media_item['type'] == "event":
chains.append([media_item])
elif len(current_chain) == 0:
current_chain.append(media_item)
elif media_item['start'] == current_chain[-1]['end']:
current_chain.append(media_item)
@ -240,7 +243,6 @@ class PypoPush(Thread):
tnow = datetime.utcnow()
current_chain = []
for chain in chains:
iteration = 0
for link in chain:
@ -284,7 +286,13 @@ class PypoPush(Thread):
try:
for media_item in media_item_chain:
self.telnet_to_liquidsoap(media_item)
if media_item['type'] == "file":
self.telnet_to_liquidsoap(media_item)
elif media_item['type'] == "event":
if media_item['event_type'] == "kick_out":
PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj")
elif media_item['event_type'] == "switch_off":
PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off")
except Exception, e:
self.logger.error('Pypo Push Exception: %s', e)