Merge branch '2.5.x' into 2.5.x-saas

This commit is contained in:
Albert Santoni 2014-03-17 15:41:14 -04:00
commit 2a783f3825
32 changed files with 1200 additions and 378 deletions

16
README
View File

@ -24,22 +24,22 @@ Major features:
INSTALLATION INSTALLATION
------------ ------------
For the fastest, most painless installation on Ubuntu 12.04 and up, run: Please see this chapter to begin a typical installation:
http://sourcefabric.booktype.pro/airtime-25-for-broadcasters/preparing-the-server/
If you are a developer, please see this page:
http://wiki.sourcefabric.org/display/CC/Airtime+Dev+Site
For installation direct from a git checkout on Ubuntu 12.04 LTS, run:
cd install_full/ubuntu cd install_full/ubuntu
sudo ./airtime-full-install sudo ./airtime-full-install
For Debian, run: For installation from git on Debian wheezy, run:
cd install_full/debian cd install_full/debian
sudo ./airtime-full-install sudo ./airtime-full-install
For custom installation and other distributions of Linux, please see this
chapter to begin a typical installation:
http://sourcefabric.booktype.pro/airtime-24-for-broadcasters/preparing-the-server/
If you are a developer, please see this page:
http://wiki.sourcefabric.org/display/CC/Airtime+Dev+Site
Quick links to our resources Quick links to our resources
---------------------------- ----------------------------

View File

@ -65,7 +65,8 @@ class ApiController extends Zend_Controller_Action
public function versionAction() public function versionAction()
{ {
$this->_helper->json->sendJson( array( $this->_helper->json->sendJson( array(
"version" => Application_Model_Preference::GetAirtimeVersion())); "airtime_version" => Application_Model_Preference::GetAirtimeVersion(),
"api_version" => AIRTIME_API_VERSION));
} }
/** /**

View File

@ -10,6 +10,49 @@ class ListenerstatController extends Zend_Controller_Action
->initContext(); ->initContext();
} }
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function indexAction() public function indexAction()
{ {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
@ -26,25 +69,17 @@ class ListenerstatController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
//default time is the last 24 hours. list($startsDT, $endsDT) = $this->getStartEnd();
$now = time(); $userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$from = $request->getParam("from", $now - (24*60*60)); $startsDT->setTimezone($userTimezone);
$to = $request->getParam("to", $now); $endsDT->setTimezone($userTimezone);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
$form = new Application_Form_DateRange(); $form = new Application_Form_DateRange();
$form->populate(array( $form->populate(array(
'his_date_start' => $start->format("Y-m-d"), 'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $start->format("H:i"), 'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $end->format("Y-m-d"), 'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $end->format("H:i") 'his_time_end' => $endsDT->format("H:i")
)); ));
$errorStatus = Application_Model_StreamSetting::GetAllListenerStatErrors(); $errorStatus = Application_Model_StreamSetting::GetAllListenerStatErrors();
@ -63,16 +98,7 @@ class ListenerstatController extends Zend_Controller_Action
} }
public function getDataAction(){ public function getDataAction(){
$request = $this->getRequest(); list($startsDT, $endsDT) = $this->getStartEnd();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("startTimestamp", $current_time - (60*60*24));
$ends_epoch = $request->getParam("endTimestamp", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s")); $data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"));
$this->_helper->json->sendJson($data); $this->_helper->json->sendJson($data);

View File

@ -17,35 +17,68 @@ class PlayouthistoryController extends Zend_Controller_Action
->addActionContext('update-list-item', 'json') ->addActionContext('update-list-item', 'json')
->addActionContext('update-file-item', 'json') ->addActionContext('update-file-item', 'json')
->initContext(); ->initContext();
} }
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function indexAction() public function indexAction()
{ {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$request = $this->getRequest();
$baseUrl = Application_Common_OsPath::getBaseDir(); $baseUrl = Application_Common_OsPath::getBaseDir();
//default time is the last 24 hours. list($startsDT, $endsDT) = $this->getStartEnd();
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC"); $userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone()); $startsDT->setTimezone($userTimezone);
$endsDT->setTimezone($userTimezone);
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
$form = new Application_Form_DateRange(); $form = new Application_Form_DateRange();
$form->populate(array( $form->populate(array(
'his_date_start' => $start->format("Y-m-d"), 'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $start->format("H:i"), 'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $end->format("Y-m-d"), 'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $end->format("H:i") 'his_time_end' => $endsDT->format("H:i")
)); ));
$this->view->date_form = $form; $this->view->date_form = $form;
@ -87,15 +120,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{ {
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $params = $request->getParams();
$instance = $request->getParam("instance_id", null);
$params = $request->getParams(); list($startsDT, $endsDT) = $this->getStartEnd();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params); $r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
@ -114,17 +142,11 @@ class PlayouthistoryController extends Zend_Controller_Action
public function itemHistoryFeedAction() public function itemHistoryFeedAction()
{ {
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $params = $request->getParams();
$instance = $request->getParam("instance_id", null);
$params = $request->getParams(); list($startsDT, $endsDT) = $this->getStartEnd();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$instance = $request->getParam("instance_id", null);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance); $r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
@ -144,12 +166,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{ {
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24)); $instance = $request->getParam("instance_id", null);
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); list($startsDT, $endsDT) = $this->getStartEnd();
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$shows = $historyService->getShowList($startsDT, $endsDT); $shows = $historyService->getShowList($startsDT, $endsDT);

View File

@ -230,29 +230,66 @@ class ShowbuilderController extends Zend_Controller_Action
$end_time = $end->format("Y-m-d H:i:s"); $end_time = $end->format("Y-m-d H:i:s");
$this->view->title = "{$show_name}: {$start_time} - {$end_time}"; $this->view->title = "{$show_name}: {$start_time} - {$end_time}";
$this->view->start = $instance->getDbStarts("U"); $this->view->start = $start_time;
$this->view->end = $instance->getDbEnds("U"); $this->view->end = $end_time;
$this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml'); $this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
} }
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function checkBuilderFeedAction() public function checkBuilderFeedAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$show_filter = intval($request->getParam("showFilter", 0)); $show_filter = intval($request->getParam("showFilter", 0));
$my_shows = intval($request->getParam("myShows", 0)); $my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1)); $timestamp = intval($request->getParam("timestamp", -1));
$instances = $request->getParam("instances", array()); $instances = $request->getParam("instances", array());
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); list($startsDT, $endsDT) = $this->getStartEnd();
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter); $opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts); $showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
//only send the schedule back if updates have been made. //only send the schedule back if updates have been made.
@ -263,18 +300,14 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction() public function builderFeedAction()
{ {
$request = $this->getRequest(); $current_time = time();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time); $request = $this->getRequest();
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$show_filter = intval($request->getParam("showFilter", 0)); $show_filter = intval($request->getParam("showFilter", 0));
$show_instance_filter = intval($request->getParam("showInstanceFilter", 0)); $show_instance_filter = intval($request->getParam("showInstanceFilter", 0));
$my_shows = intval($request->getParam("myShows", 0)); $my_shows = intval($request->getParam("myShows", 0));
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); list($startsDT, $endsDT) = $this->getStartEnd();
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$opts = array("myShows" => $my_shows, $opts = array("myShows" => $my_shows,
"showFilter" => $show_filter, "showFilter" => $show_filter,

View File

@ -590,15 +590,14 @@ class Application_Model_Scheduler
* to that show * to that show
*/ */
if ($linked) { if ($linked) {
$instance_sql = "SELECT * FROM cc_show_instances ". $instances = CcShowInstancesQuery::create()
"WHERE show_id = ".$ccShow["id"]; ->filterByDbShowId($ccShow["id"])
$instances = Application_Common_Database::prepareAndExecute( ->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
$instance_sql); ->find();
} else { } else {
$instance_sql = "SELECT * FROM cc_show_instances ". $instances = CcShowInstancesQuery::create()
"WHERE id = ".$schedule["instance"]; ->filterByDbId($schedule["instance"])
$instances = Application_Common_Database::prepareAndExecute( ->find();
$instance_sql);
} }
$excludePositions = array(); $excludePositions = array();
@ -606,7 +605,8 @@ class Application_Model_Scheduler
//reset //reset
$this->applyCrossfades = true; $this->applyCrossfades = true;
$instanceId = $instance["id"]; //$instanceId = $instance["id"];
$instanceId = $instance->getDbId();
if ($id !== 0) { if ($id !== 0) {
/* We use the selected cursor's position to find the same /* We use the selected cursor's position to find the same
* positions in every other linked instance * positions in every other linked instance
@ -632,7 +632,7 @@ class Application_Model_Scheduler
//show instance has no scheduled tracks //show instance has no scheduled tracks
if (empty($pos)) { if (empty($pos)) {
$pos = 0; $pos = 0;
$nextStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC")); $nextStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
} else { } else {
$linkedItem_sql = "SELECT ends FROM cc_schedule ". $linkedItem_sql = "SELECT ends FROM cc_schedule ".
@ -658,7 +658,7 @@ class Application_Model_Scheduler
} }
//selected empty row to add after //selected empty row to add after
else { else {
$showStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC")); $showStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
$nextStartDT = $this->findNextStartTime($showStartDT, $instanceId); $nextStartDT = $this->findNextStartTime($showStartDT, $instanceId);
//first item in show so start position counter at 0 //first item in show so start position counter at 0
@ -706,6 +706,9 @@ class Application_Model_Scheduler
$doUpdate = false; $doUpdate = false;
$values = array(); $values = array();
//array that stores the cc_file ids so we can update the is_scheduled flag
$fileIds = array();
foreach ($filesToInsert as &$file) { foreach ($filesToInsert as &$file) {
//item existed previously and is being moved. //item existed previously and is being moved.
//need to keep same id for resources if we want REST. //need to keep same id for resources if we want REST.
@ -761,9 +764,6 @@ class Application_Model_Scheduler
$file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']); $file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']);
$file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']); $file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']);
//array that stores the cc_file ids so we can update the is_scheduled flag
$fileIds = array();
switch ($file["type"]) { switch ($file["type"]) {
case 0: case 0:
$fileId = $file["id"]; $fileId = $file["id"];

View File

@ -47,6 +47,9 @@ class CcShow extends BaseCcShow {
*/ */
public function getFirstCcShowDay($criteria = null, PropelPDO $con = null) public function getFirstCcShowDay($criteria = null, PropelPDO $con = null)
{ {
/*CcShowPeer::clearInstancePool();
CcShowPeer::clearRelatedInstancePool();*/
if(null === $this->collCcShowDayss || null !== $criteria) { if(null === $this->collCcShowDayss || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowDayss) { if ($this->isNew() && null === $this->collCcShowDayss) {
// return empty collection // return empty collection

View File

@ -304,24 +304,20 @@ class Application_Service_SchedulerService
private static function replaceInstanceContentCheck($currentShowStamp, $showStamp) private static function replaceInstanceContentCheck($currentShowStamp, $showStamp)
{ {
/*$currentShowStamp = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->orderByDbStarts()
->find();*/
$counter = 0; $counter = 0;
foreach ($showStamp as $item) { foreach ($showStamp as $item) {
if ($item["file_id"] != $currentShowStamp[$counter]["file_id"] || if ($item["file_id"] != $currentShowStamp[$counter]["file_id"] ||
$item["stream_id"] != $currentShowStamp[$counter]["stream_id"]) { $item["stream_id"] != $currentShowStamp[$counter]["stream_id"]) {
/*CcScheduleQuery::create() /*CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId()) ->filterByDbInstanceId($ccShowInstance->getDbId())
->delete();*/ ->delete();*/
$delete_sql = "DELETE FROM cc_schedule ". $delete_sql = "DELETE FROM cc_schedule ".
"WHERE instance_id = {$currentShowStamp[$counter]["instance_id"]}"; "WHERE instance_id = {$currentShowStamp[$counter]["instance_id"]}";
Application_Common_Database::prepareAndExecute( Application_Common_Database::prepareAndExecute(
$delete_sql, array(), Application_Common_Database::EXECUTE); $delete_sql, array(), Application_Common_Database::EXECUTE);
return true; return true;
} }
$counter += 1;
} }
/* If we get here, the content in the show instance is the same /* If we get here, the content in the show instance is the same

View File

@ -20,6 +20,8 @@ class Application_Service_ShowService
private $localShowStartHour; private $localShowStartHour;
private $localShowStartMin; private $localShowStartMin;
private $origCcShowDay; private $origCcShowDay;
private $origShowRepeatStatus;
private $instanceIdsForScheduleUpdates;
public function __construct($showId=null, $showData=null, $isUpdate=false) public function __construct($showId=null, $showData=null, $isUpdate=false)
{ {
@ -39,6 +41,7 @@ class Application_Service_ShowService
$this->isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0; $this->isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0;
$this->isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0; $this->isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0;
$this->isUpdate = $isUpdate; $this->isUpdate = $isUpdate;
$this->instanceIdsForScheduleUpdates = array();
} }
public function editRepeatingShowInstance($showData) { public function editRepeatingShowInstance($showData) {
@ -156,8 +159,10 @@ class Application_Service_ShowService
{ {
if ($this->ccShow->isRepeating()) { if ($this->ccShow->isRepeating()) {
$this->origCcShowDay = clone $this->ccShow->getFirstRepeatingCcShowDay(); $this->origCcShowDay = clone $this->ccShow->getFirstRepeatingCcShowDay();
$this->origShowRepeatStatus = true;
} else { } else {
$this->origCcShowDay = clone $this->ccShow->getFirstCcShowDay(); $this->origCcShowDay = clone $this->ccShow->getFirstCcShowDay();
$this->origShowRepeatStatus = false;
} }
$this->oldShowTimezone = $this->origCcShowDay->getDbTimezone(); $this->oldShowTimezone = $this->origCcShowDay->getDbTimezone();
@ -181,15 +186,18 @@ class Application_Service_ShowService
if (!$currentUser->isAdminOrPM()) { if (!$currentUser->isAdminOrPM()) {
throw new Exception("Permission denied"); throw new Exception("Permission denied");
} }
//update ccShow //update ccShow
$this->setCcShow($showData); $this->setCcShow($showData);
$daysAdded = array(); $daysAdded = array();
if ($this->isUpdate) { if ($this->isUpdate) {
$daysAdded = $this->delegateInstanceCleanup($showData); if (!$this->ccShow->getCcShowDayss()->isEmpty()) {
$this->storeOrigLocalShowInfo();
}
$this->storeOrigLocalShowInfo(); $daysAdded = $this->delegateInstanceCleanup($showData);
$this->deleteRebroadcastInstances(); $this->deleteRebroadcastInstances();
@ -199,6 +207,8 @@ class Application_Service_ShowService
//delete entry in cc_show_rebroadcast //delete entry in cc_show_rebroadcast
$this->deleteCcShowRebroadcasts(); $this->deleteCcShowRebroadcasts();
} }
$this->storeInstanceIds();
} }
//update ccShowDays //update ccShowDays
@ -214,6 +224,16 @@ class Application_Service_ShowService
$this->delegateInstanceCreation($daysAdded); $this->delegateInstanceCreation($daysAdded);
if ($this->isUpdate) { if ($this->isUpdate) {
/* If the show is repeating and the start date changes we need
* to ignore that difference when re-calculating schedule start times.
* Otherwise it might calculate a difference of a week, for example.
*/
if ($this->ccShow->isRepeating() &&
$this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d") != $showData["add_show_start_date"]) {
$showData["add_show_start_date"] = $this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d");
}
$this->adjustSchedule($showData); $this->adjustSchedule($showData);
} }
@ -227,15 +247,28 @@ class Application_Service_ShowService
} }
} }
/**
*
* Returns an array of instance ids that already exist
* We need this if a show is being updated so we can separate the
* instances that already exist and any new instances that
* get created (by adding a new repeat show day)
*/
private function storeInstanceIds()
{
$instances = $this->ccShow->getCcShowInstancess();
foreach ($instances as $instance) {
$this->instanceIdsForScheduleUpdates[] = $instance->getDbId();
}
}
private function adjustSchedule($showData) private function adjustSchedule($showData)
{ {
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$ccShowInstances = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId())
->find();
$this->updateScheduleStartEndTimes($showData); $this->updateScheduleStartEndTimes($showData);
$ccShowInstances = $this->ccShow->getCcShowInstancess();
foreach ($ccShowInstances as $instance) { foreach ($ccShowInstances as $instance) {
$instance->updateScheduleStatus($con); $instance->updateScheduleStatus($con);
} }
@ -385,6 +418,13 @@ SQL;
':timestamp' => gmdate("Y-m-d H:i:s")), 'execute'); ':timestamp' => gmdate("Y-m-d H:i:s")), 'execute');
} }
private function deleteAllShowDays($showId)
{
CcShowDaysQuery::create()
->filterByDbShowId($showId)
->delete();
}
/** /**
* TODO: This function is messy. Needs refactoring * TODO: This function is messy. Needs refactoring
* *
@ -406,8 +446,14 @@ SQL;
//CcShowDay object //CcShowDay object
if ($this->ccShow->isRepeating()) { if ($this->ccShow->isRepeating()) {
$currentShowDay = $this->ccShow->getFirstRepeatingCcShowDay(); $currentShowDay = $this->ccShow->getFirstRepeatingCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else { } else {
$currentShowDay = $this->ccShow->getFirstCcShowDay(); $currentShowDay = $this->ccShow->getFirstCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getCcShowDayss();
} }
//new end date in the show's timezone (from the select box) //new end date in the show's timezone (from the select box)
@ -416,6 +462,11 @@ SQL;
//repeat option was toggled //repeat option was toggled
if ($showData['add_show_repeats'] != $currentShowDay->isRepeating()) { if ($showData['add_show_repeats'] != $currentShowDay->isRepeating()) {
$this->deleteAllRepeatInstances($currentShowDay, $showId); $this->deleteAllRepeatInstances($currentShowDay, $showId);
if (!$showData["add_show_repeats"]) {
$this->deleteAllShowDays($showId);
}
//if repeat option was checked we need to treat the current show day //if repeat option was checked we need to treat the current show day
//as a new show day so the repeat instances get created properly //as a new show day so the repeat instances get created properly
//in createWeeklyRepeatInstances() //in createWeeklyRepeatInstances()
@ -447,17 +498,13 @@ SQL;
//and the repeat type changed //and the repeat type changed
if ($currentRepeatType != -1 && $this->repeatType != $currentRepeatType) { if ($currentRepeatType != -1 && $this->repeatType != $currentRepeatType) {
$this->deleteAllInstances($showId); $this->deleteAllInstances($showId);
$this->deleteAllShowDays($showId);
// when repeating by day of the month (1st, 2nd, etc.) we do not store the repeat week days // when repeating by day of the month (1st, 2nd, etc.) we do not store the repeat week days
} elseif ($currentRepeatType != 2) { } elseif ($currentRepeatType != 2) {
//repeat type is the same, check if the days of the week are the same //repeat type is the same, check if the days of the week are the same
$repeatingDaysChanged = false; $repeatingDaysChanged = false;
if ($this->ccShow->isRepeating()) {
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else {
$ccShowDays = $this->ccShow->getCcShowDayss();
}
$showDays = array(); $showDays = array();
foreach ($ccShowDays as $day) { foreach ($ccShowDays as $day) {
$showDays[] = $day->getDbDay(); $showDays[] = $day->getDbDay();
@ -508,12 +555,11 @@ SQL;
//check if this is null if "no end" //check if this is null if "no end"
$currentShowEndDateTime = $this->getRepeatingEndDate(); $currentShowEndDateTime = $this->getRepeatingEndDate();
if ($currentShowEndDateTime != $endDateTime) { if ($endDateTime && $currentShowEndDateTime != $endDateTime) {
$endDate = clone $endDateTime; $endDate = clone $endDateTime;
$endDate->setTimezone(new DateTimeZone("UTC")); $endDate->setTimezone(new DateTimeZone("UTC"));
//show "No End" option was toggled //show's "No End" option was toggled
//or the end date comes earlier //or the end date comes earlier
if (is_null($currentShowEndDateTime) || ($endDateTime < $currentShowEndDateTime)) { if (is_null($currentShowEndDateTime) || ($endDateTime < $currentShowEndDateTime)) {
//"No End" option was unchecked so we need to delete the //"No End" option was unchecked so we need to delete the
@ -531,11 +577,14 @@ SQL;
private function preserveLinkedShowContent() private function preserveLinkedShowContent()
{ {
/* Get show content from any linekd instance. It doesn't /* Get show content from any linked instance. It doesn't
* matter which instance since content is the same in all. * matter which instance since content is the same in all.
*/ */
$ccShowInstance = $this->ccShow->getCcShowInstancess()->getFirst(); $ccShowInstance = $this->ccShow->getCcShowInstancess()->getFirst();
if (!$ccShowInstance) {
return;
}
$ccSchedules = CcScheduleQuery::create() $ccSchedules = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId()) ->filterByDbInstanceId($ccShowInstance->getDbId())
->find(); ->find();
@ -881,7 +930,6 @@ SQL;
private function updateScheduleStartEndTimes($showData) private function updateScheduleStartEndTimes($showData)
{ {
$showId = $this->ccShow->getDbId(); $showId = $this->ccShow->getDbId();
//DateTime in show's local time //DateTime in show's local time
$newStartDateTime = new DateTime($showData["add_show_start_date"]." ". $newStartDateTime = new DateTime($showData["add_show_start_date"]." ".
$showData["add_show_start_time"], $showData["add_show_start_time"],
@ -890,12 +938,9 @@ SQL;
$diff = $this->calculateShowStartDiff($newStartDateTime, $diff = $this->calculateShowStartDiff($newStartDateTime,
$this->origCcShowDay->getLocalStartDateAndTime()); $this->origCcShowDay->getLocalStartDateAndTime());
$ccShowInstances = $this->ccShow->getFutureCcShowInstancess(); Application_Service_SchedulerService::updateScheduleStartTime(
$instanceIds = array(); $this->instanceIdsForScheduleUpdates,
foreach ($ccShowInstances as $ccShowInstance) { $diff);
array_push($instanceIds, $ccShowInstance->getDbId());
}
Application_Service_SchedulerService::updateScheduleStartTime($instanceIds, $diff);
} }
/** /**
@ -1487,8 +1532,12 @@ SQL;
if ($this->isUpdate) { if ($this->isUpdate) {
$showDay = CcShowDaysQuery::create() $showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId) ->filterByDbShowId($showId)
->filterByDbRepeatType($showData['add_show_repeat_type']) ->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->findOne(); ->findOne();
if (!$showDay) {
//repeat type changed so we have to create a new show_day rule
$showDay = new CcShowDays();
}
} else { } else {
$showDay = new CcShowDays(); $showDay = new CcShowDays();
} }
@ -1520,16 +1569,30 @@ SQL;
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) { if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
if ($this->isUpdate) { if ($this->isUpdate) {
if ($this->origCcShowDay->getDbRepeatType() == 2 ||
$this->origCcShowDay->getDbRepeatType() == 3) {
$day = null;
} else if (!$this->origShowRepeatStatus) {
//keep current show day to use for updating cc_show_day rule
$keepDay = $day;
$day = $this->origCcShowDay->getDbDay();
}
$showDay = CcShowDaysQuery::create() $showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId) ->filterByDbShowId($showId)
->filterByDbRepeatType($this->repeatType) ->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->filterByDbDay($day) ->filterByDbDay($day)
->findOne(); ->findOne();
if (!$showDay) { if (!$showDay) {
//if no show day object was found it is because a new //if no show day object was found it is because a new
//repeating day of the week was added //repeating day of the week was added OR the repeat
//type has changed
$showDay = new CcShowDays(); $showDay = new CcShowDays();
} }
if (isset($keepDay)) {
$day = $keepDay;
}
} else { } else {
$showDay = new CcShowDays(); $showDay = new CcShowDays();
} }

View File

@ -10,7 +10,7 @@ msgstr ""
"Project-Id-Version: Airtime\n" "Project-Id-Version: Airtime\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-13 12:58-0500\n" "POT-Creation-Date: 2013-12-13 12:58-0500\n"
"PO-Revision-Date: 2014-02-04 18:19+0000\n" "PO-Revision-Date: 2014-02-11 20:10+0000\n"
"Last-Translator: hoerich <hoerich@gmx.at>\n" "Last-Translator: hoerich <hoerich@gmx.at>\n"
"Language-Team: German (Austria) (http://www.transifex.com/projects/p/airtime/language/de_AT/)\n" "Language-Team: German (Austria) (http://www.transifex.com/projects/p/airtime/language/de_AT/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -2210,7 +2210,7 @@ msgstr "Das sind Admin Benutzername und Passwort, für die Hörerstatistiken von
#: airtime_mvc/application/controllers/LocaleController.php:180 #: airtime_mvc/application/controllers/LocaleController.php:180
msgid "" msgid ""
"Warning: You cannot change this field while the show is currently playing" "Warning: You cannot change this field while the show is currently playing"
msgstr "" msgstr "Warnung: Dieses Feld kann nicht geändert werden, während die Sendung wiedergegeben wird."
#: airtime_mvc/application/controllers/LocaleController.php:181 #: airtime_mvc/application/controllers/LocaleController.php:181
msgid "No result found" msgid "No result found"

View File

@ -3,6 +3,7 @@
# This file is distributed under the same license as the Airtime package. # This file is distributed under the same license as the Airtime package.
# #
# Translators: # Translators:
# danielhjames <daniel@64studio.com>, 2014
# hoerich <hoerich@gmx.at>, 2014 # hoerich <hoerich@gmx.at>, 2014
# Sourcefabric <contact@sourcefabric.org>, 2013 # Sourcefabric <contact@sourcefabric.org>, 2013
msgid "" msgid ""
@ -10,8 +11,8 @@ msgstr ""
"Project-Id-Version: Airtime\n" "Project-Id-Version: Airtime\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-13 12:58-0500\n" "POT-Creation-Date: 2013-12-13 12:58-0500\n"
"PO-Revision-Date: 2014-02-04 18:19+0000\n" "PO-Revision-Date: 2014-02-12 11:00+0000\n"
"Last-Translator: hoerich <hoerich@gmx.at>\n" "Last-Translator: danielhjames <daniel@64studio.com>\n"
"Language-Team: German (Germany) (http://www.transifex.com/projects/p/airtime/language/de_DE/)\n" "Language-Team: German (Germany) (http://www.transifex.com/projects/p/airtime/language/de_DE/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@ -2210,7 +2211,7 @@ msgstr "Admin Benutzer und Passwort, wird zur Abfrage der Zuhörerdaten in Iceca
#: airtime_mvc/application/controllers/LocaleController.php:180 #: airtime_mvc/application/controllers/LocaleController.php:180
msgid "" msgid ""
"Warning: You cannot change this field while the show is currently playing" "Warning: You cannot change this field while the show is currently playing"
msgstr "" msgstr "Warnung: Dieses Feld kann nicht geändert werden, während die Sendung wiedergegeben wird."
#: airtime_mvc/application/controllers/LocaleController.php:181 #: airtime_mvc/application/controllers/LocaleController.php:181
msgid "No result found" msgid "No result found"

View File

@ -4,13 +4,14 @@
# #
# Translators: # Translators:
# Sourcefabric <contact@sourcefabric.org>, 2012 # Sourcefabric <contact@sourcefabric.org>, 2012
# vmcarranza <victor.carranza@sourcefabric.org>, 2014
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Airtime\n" "Project-Id-Version: Airtime\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-13 12:58-0500\n" "POT-Creation-Date: 2013-12-13 12:58-0500\n"
"PO-Revision-Date: 2014-01-29 15:11+0000\n" "PO-Revision-Date: 2014-03-12 16:10+0000\n"
"Last-Translator: andrey.podshivalov\n" "Last-Translator: vmcarranza <victor.carranza@sourcefabric.org>\n"
"Language-Team: Spanish (Spain) (http://www.transifex.com/projects/p/airtime/language/es_ES/)\n" "Language-Team: Spanish (Spain) (http://www.transifex.com/projects/p/airtime/language/es_ES/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@ -120,7 +121,7 @@ msgstr "Álbum"
#: airtime_mvc/application/controllers/LocaleController.php:81 #: airtime_mvc/application/controllers/LocaleController.php:81
#: airtime_mvc/application/forms/SmartBlockCriteria.php:65 #: airtime_mvc/application/forms/SmartBlockCriteria.php:65
msgid "Length" msgid "Length"
msgstr "Duración:" msgstr "Duración"
#: airtime_mvc/application/services/HistoryService.php:1109 #: airtime_mvc/application/services/HistoryService.php:1109
#: airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml:10 #: airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml:10
@ -136,7 +137,7 @@ msgstr "Género"
#: airtime_mvc/application/controllers/LocaleController.php:83 #: airtime_mvc/application/controllers/LocaleController.php:83
#: airtime_mvc/application/forms/SmartBlockCriteria.php:67 #: airtime_mvc/application/forms/SmartBlockCriteria.php:67
msgid "Mood" msgid "Mood"
msgstr "Estado de ánimo/estilo (mood)" msgstr "Estilo (mood)"
#: airtime_mvc/application/services/HistoryService.php:1111 #: airtime_mvc/application/services/HistoryService.php:1111
#: airtime_mvc/application/models/Block.php:1353 #: airtime_mvc/application/models/Block.php:1353
@ -184,7 +185,7 @@ msgstr ""
#: airtime_mvc/application/controllers/LocaleController.php:72 #: airtime_mvc/application/controllers/LocaleController.php:72
#: airtime_mvc/application/forms/SmartBlockCriteria.php:53 #: airtime_mvc/application/forms/SmartBlockCriteria.php:53
msgid "Conductor" msgid "Conductor"
msgstr "Conductor" msgstr "Director"
#: airtime_mvc/application/services/HistoryService.php:1118 #: airtime_mvc/application/services/HistoryService.php:1118
#: airtime_mvc/application/models/Block.php:1354 #: airtime_mvc/application/models/Block.php:1354
@ -228,7 +229,7 @@ msgstr "Cargar a SoundCloud"
#: airtime_mvc/application/services/CalendarService.php:70 #: airtime_mvc/application/services/CalendarService.php:70
#: airtime_mvc/application/controllers/LibraryController.php:286 #: airtime_mvc/application/controllers/LibraryController.php:286
msgid "Re-upload to SoundCloud" msgid "Re-upload to SoundCloud"
msgstr "Recargar a SoundCloud" msgstr "Volver a cargar a SoundCloud"
#: airtime_mvc/application/services/CalendarService.php:77 #: airtime_mvc/application/services/CalendarService.php:77
#: airtime_mvc/application/services/CalendarService.php:121 #: airtime_mvc/application/services/CalendarService.php:121
@ -298,11 +299,11 @@ msgstr "No es posible arrastrar y soltar shows que se repiten"
#: airtime_mvc/application/services/CalendarService.php:263 #: airtime_mvc/application/services/CalendarService.php:263
msgid "Can't move a past show" msgid "Can't move a past show"
msgstr "No puedes mover un show pasado" msgstr "No se puede mover un show pasado"
#: airtime_mvc/application/services/CalendarService.php:281 #: airtime_mvc/application/services/CalendarService.php:281
msgid "Can't move show into past" msgid "Can't move show into past"
msgstr "No puedes mover un show al pasado" msgstr "No se puede mover un show al pasado"
#: airtime_mvc/application/services/CalendarService.php:288 #: airtime_mvc/application/services/CalendarService.php:288
#: airtime_mvc/application/forms/AddShowWhen.php:280 #: airtime_mvc/application/forms/AddShowWhen.php:280
@ -311,19 +312,19 @@ msgstr "No puedes mover un show al pasado"
#: airtime_mvc/application/forms/AddShowWhen.php:324 #: airtime_mvc/application/forms/AddShowWhen.php:324
#: airtime_mvc/application/forms/AddShowWhen.php:329 #: airtime_mvc/application/forms/AddShowWhen.php:329
msgid "Cannot schedule overlapping shows" msgid "Cannot schedule overlapping shows"
msgstr "No puedes programar shows traslapados" msgstr "No se pueden programar shows traslapados"
#: airtime_mvc/application/services/CalendarService.php:301 #: airtime_mvc/application/services/CalendarService.php:301
msgid "Can't move a recorded show less than 1 hour before its rebroadcasts." msgid "Can't move a recorded show less than 1 hour before its rebroadcasts."
msgstr "No puedes mover shows grabados menos de 1 hora antes de su retransmisión." msgstr "No se pueden mover shows grabados a menos de 1 hora antes de su retransmisión."
#: airtime_mvc/application/services/CalendarService.php:311 #: airtime_mvc/application/services/CalendarService.php:311
msgid "Show was deleted because recorded show does not exist!" msgid "Show was deleted because recorded show does not exist!"
msgstr "El show se eliminó porque el show grabado no existe." msgstr "El show se eliminó porque el show grabado no existe!"
#: airtime_mvc/application/services/CalendarService.php:318 #: airtime_mvc/application/services/CalendarService.php:318
msgid "Must wait 1 hour to rebroadcast." msgid "Must wait 1 hour to rebroadcast."
msgstr "Debes esperar 1 hora para retransmitir" msgstr "Debe esperar 1 hora para retransmitir."
#: airtime_mvc/application/views/scripts/preference/index.phtml:2 #: airtime_mvc/application/views/scripts/preference/index.phtml:2
#: airtime_mvc/application/configs/navigation.php:45 #: airtime_mvc/application/configs/navigation.php:45
@ -354,7 +355,7 @@ msgstr "Administrar las Carpetas de Medios"
#: airtime_mvc/application/views/scripts/preference/stream-setting.phtml:2 #: airtime_mvc/application/views/scripts/preference/stream-setting.phtml:2
msgid "Stream Settings" msgid "Stream Settings"
msgstr "Configuración del stream" msgstr "Configuración de stream"
#: airtime_mvc/application/views/scripts/preference/stream-setting.phtml:12 #: airtime_mvc/application/views/scripts/preference/stream-setting.phtml:12
msgid "Global Settings" msgid "Global Settings"
@ -371,11 +372,11 @@ msgstr "Configuración de los streams de salida"
#: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:9 #: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:9
#: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:27 #: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:27
msgid "Choose folder" msgid "Choose folder"
msgstr "Elige carpeta" msgstr "Elija la carpeta"
#: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:10 #: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:10
msgid "Set" msgid "Set"
msgstr "Crear" msgstr "Fijar"
#: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:19 #: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:19
msgid "Current Import Folder:" msgid "Current Import Folder:"
@ -386,13 +387,13 @@ msgstr "Carpeta actual de importación:"
#: airtime_mvc/application/views/scripts/form/add-show-rebroadcast.phtml:41 #: airtime_mvc/application/views/scripts/form/add-show-rebroadcast.phtml:41
#: airtime_mvc/application/views/scripts/playouthistorytemplate/template-contents.phtml:75 #: airtime_mvc/application/views/scripts/playouthistorytemplate/template-contents.phtml:75
msgid "Add" msgid "Add"
msgstr "Añadir:" msgstr "Añadir"
#: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:43 #: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:43
msgid "" msgid ""
"Rescan watched directory (This is useful if it is network mount and may be " "Rescan watched directory (This is useful if it is network mount and may be "
"out of sync with Airtime)" "out of sync with Airtime)"
msgstr "Re escanear el directorio monitoreado (esto es útil si está instalado en una red o si no está sincronizado con Airtime)" msgstr "Re-escanear el directorio monitoreado (esto es útil si es un directorio montado sobre una red y pudiera no estar en sincronía con Airtime)"
#: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:44 #: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:44
msgid "Remove watched directory" msgid "Remove watched directory"
@ -400,11 +401,11 @@ msgstr "Remover el directorio monitoreado"
#: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:50 #: airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml:50
msgid "You are not watching any media folders." msgid "You are not watching any media folders."
msgstr "No estás monitoreando ninguna carpeta de medios." msgstr "No está monitoreando ninguna carpeta de medios."
#: airtime_mvc/application/views/scripts/form/register-dialog.phtml:1 #: airtime_mvc/application/views/scripts/form/register-dialog.phtml:1
msgid "Register Airtime" msgid "Register Airtime"
msgstr "Registra Airtime" msgstr "Registrar Airtime"
#: airtime_mvc/application/views/scripts/form/register-dialog.phtml:6 #: airtime_mvc/application/views/scripts/form/register-dialog.phtml:6
#, php-format #, php-format
@ -413,7 +414,7 @@ msgid ""
" be collected regularly in order to enhance your user experience.%sClick " " be collected regularly in order to enhance your user experience.%sClick "
"'Yes, help Airtime' and we'll make sure the features you use are constantly " "'Yes, help Airtime' and we'll make sure the features you use are constantly "
"improving." "improving."
msgstr "Ayuda a Airtime dándonos a conocer cómo lo estas usado. Esta información se recopila con regularidad para mejorar la experiencia de los usuarios.%s Da clic a 'Sí, ayudar a Airtime' y nos aseguraremos de que las funciones que más utilizas se mantengan bajo constante mejora." msgstr "Ayúdenos a mejorar Airtime dándonos a conocer cómo lo está usando. Esta información se recopila con regularidad para mejorar la experiencia de los usuarios.%s Haga clic en 'Sí, ayudar a Airtime' y nos aseguraremos de que las funciones que más utiliza se mantengan bajo constante mejora."
#: airtime_mvc/application/views/scripts/form/register-dialog.phtml:25 #: airtime_mvc/application/views/scripts/form/register-dialog.phtml:25
#, php-format #, php-format

View File

@ -10,7 +10,7 @@ msgstr ""
"Project-Id-Version: Airtime\n" "Project-Id-Version: Airtime\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-13 12:58-0500\n" "POT-Creation-Date: 2013-12-13 12:58-0500\n"
"PO-Revision-Date: 2014-02-04 18:10+0000\n" "PO-Revision-Date: 2014-02-04 20:40+0000\n"
"Last-Translator: danse <f.occhipinti@gmail.com>\n" "Last-Translator: danse <f.occhipinti@gmail.com>\n"
"Language-Team: Italian (Italy) (http://www.transifex.com/projects/p/airtime/language/it_IT/)\n" "Language-Team: Italian (Italy) (http://www.transifex.com/projects/p/airtime/language/it_IT/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"

View File

@ -194,3 +194,7 @@
#history_content .ui-tabs .ui-tabs-panel { #history_content .ui-tabs .ui-tabs-panel {
padding-top: 10px; padding-top: 10px;
} }
div.his-timerange input.error {
background-color: rgba(255,0,0,0.2);
}

View File

@ -2,7 +2,7 @@
#history_content { #history_content {
width: 100%; width: 100%;
margin: 0px; margin: 0 0 30px 0;
height: auto; height: auto;
box-sizing: border-box; box-sizing: border-box;
} }

View File

@ -14,15 +14,17 @@ $(document).ready(function() {
getDataAndPlot(); getDataAndPlot();
listenerstat_content.find("#his_submit").click(function(){ listenerstat_content.find("#his_submit").click(function(){
startTimestamp = AIRTIME.utilities.fnGetTimestamp(dateStartId, timeStartId); var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
endTimestamp = AIRTIME.utilities.fnGetTimestamp(dateEndId, timeEndId); var start = oRange.start;
getDataAndPlot(startTimestamp, endTimestamp); var end = oRange.end;
getDataAndPlot(start, end);
}); });
}); });
function getDataAndPlot(startTimestamp, endTimestamp){ function getDataAndPlot(startTimestamp, endTimestamp){
// get data // get data
$.get(baseUrl+'Listenerstat/get-data', {startTimestamp: startTimestamp, endTimestamp: endTimestamp}, function(data){ $.get(baseUrl+'Listenerstat/get-data', {start: startTimestamp, end: endTimestamp}, function(data){
out = new Object(); out = new Object();
$.each(data, function(mpName, v){ $.each(data, function(mpName, v){
plotData = new Object(); plotData = new Object();

View File

@ -60,6 +60,30 @@ var AIRTIME = (function(AIRTIME) {
oTableShow, oTableShow,
inShowsTab = false; inShowsTab = false;
function validateTimeRange() {
var oRange,
inputs = $('.his-timerange > input'),
start, end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
start = oRange.start;
end = oRange.end;
if (end >= start) {
inputs.removeClass('error');
}
else {
inputs.addClass('error');
}
return {
start: start,
end: end,
isValid: end >= start
};
}
function getSelectedLogItems() { function getSelectedLogItems() {
var items = Object.keys(selectedLogItems); var items = Object.keys(selectedLogItems);
@ -401,13 +425,12 @@ var AIRTIME = (function(AIRTIME) {
return oTable; return oTable;
} }
function showSummaryList() { function showSummaryList(start, end) {
var url = baseUrl+"playouthistory/show-history-feed", var url = baseUrl+"playouthistory/show-history-feed",
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId),
data = { data = {
format: "json", format: "json",
start: oRange.start, start: start,
end: oRange.end end: end
}; };
$.post(url, data, function(json) { $.post(url, data, function(json) {
@ -460,7 +483,9 @@ var AIRTIME = (function(AIRTIME) {
}, },
always: function() { always: function() {
inShowsTab = true; inShowsTab = true;
showSummaryList();
var info = getStartEnd();
showSummaryList(info.start, info.end);
emptySelectedLogItems(); emptySelectedLogItems();
} }
} }
@ -544,7 +569,8 @@ var AIRTIME = (function(AIRTIME) {
dayNamesMin: i18n_days_short, dayNamesMin: i18n_days_short,
onSelect: function(sDate, oDatePicker) { onSelect: function(sDate, oDatePicker) {
$(this).datepicker( "setDate", sDate ); $(this).datepicker( "setDate", sDate );
} },
onClose: validateTimeRange
}; };
oBaseTimePickerSettings = { oBaseTimePickerSettings = {
@ -554,13 +580,25 @@ var AIRTIME = (function(AIRTIME) {
showLeadingZero: false, showLeadingZero: false,
defaultTime: '0:00', defaultTime: '0:00',
hourText: $.i18n._("Hour"), hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute") minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
}; };
$historyContentDiv.find(dateStartId).datepicker(oBaseDatePickerSettings); $historyContentDiv.find(dateStartId)
$historyContentDiv.find(timeStartId).timepicker(oBaseTimePickerSettings); .datepicker(oBaseDatePickerSettings)
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings); .blur(validateTimeRange);
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
$historyContentDiv.find(timeStartId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(dateEndId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(timeEndId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.on("click", "#his_create", function(e) { $historyContentDiv.on("click", "#his_create", function(e) {
var url = baseUrl+"playouthistory/edit-list-item/format/json" ; var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
@ -665,17 +703,16 @@ var AIRTIME = (function(AIRTIME) {
}); });
$('body').on("click", "#his_instance_retrieve", function(e) { $('body').on("click", "#his_instance_retrieve", function(e) {
var startPicker = $hisDialogEl.find('#his_item_starts_datetimepicker').data('datetimepicker'), var startPicker = $hisDialogEl.find('#his_item_starts'),
endPicker = $hisDialogEl.find('#his_item_ends_datetimepicker').data('datetimepicker'), endPicker = $hisDialogEl.find('#his_item_ends'),
url = baseUrl+"playouthistory/show-history-feed", url = baseUrl+"playouthistory/show-history-feed",
startDate = startPicker.getLocalDate(), startDate = startPicker.val(),
endDate = endPicker.getLocalDate(), endDate = endPicker.val(),
getEpochSeconds = AIRTIME.utilities.fnGetSecondsEpoch,
data; data;
data = { data = {
start: getEpochSeconds(startDate), start: startDate,
end: getEpochSeconds(endDate), end: endDate,
format: "json" format: "json"
}; };
@ -710,18 +747,23 @@ var AIRTIME = (function(AIRTIME) {
}); });
}); });
function getStartEnd() {
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
}
$historyContentDiv.find("#his_submit").click(function(ev){ $historyContentDiv.find("#his_submit").click(function(ev){
var fn, var fn,
oRange; info;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); info = getStartEnd();
fn = fnServerData; fn = fnServerData;
fn.start = oRange.start; fn.start = info.start;
fn.end = oRange.end; fn.end = info.end;
if (inShowsTab) { if (inShowsTab) {
showSummaryList(); showSummaryList(info.start, info.end);
} }
else { else {
redrawTables(); redrawTables();

View File

@ -46,7 +46,8 @@ AIRTIME = (function(AIRTIME) {
showLeadingZero: false, showLeadingZero: false,
defaultTime: '0:00', defaultTime: '0:00',
hourText: $.i18n._("Hour"), hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute") minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
}; };
function setWidgetSize() { function setWidgetSize() {

View File

@ -35,75 +35,39 @@ var AIRTIME = (function(AIRTIME){
}; };
}; };
mod.fnGetSecondsEpoch = function(oDate) {
var iTime,
iUserOffset,
iClientOffset;
iTime = oDate.getTime(); //value is in millisec.
iTime = Math.round(iTime / 1000);
iUserOffset = userTimezoneOffset;
iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
//adjust for the fact the the Date object is in client time.
iTime = iTime + iClientOffset + iUserOffset;
return iTime;
};
/*
* Get the schedule range start in unix timestamp form (in seconds).
* defaults to NOW if nothing is selected.
*
* @param String sDatePickerId
*
* @param String sTimePickerId
*
* @return Number iTime
*/
mod.fnGetTimestamp = function(sDateId, sTimeId) {
var date,
time,
temp;
temp = $(sDateId).val();
if ( temp === "") {
return 0;
}
else {
date = temp;
}
time = $(sTimeId).val();
date = date.split("-");
time = time.split(":");
//0 based month in js.
oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
return mod.fnGetSecondsEpoch(oDate);
};
/* /*
* Returns an object containing a unix timestamp in seconds for the start/end range * Returns an object containing a unix timestamp in seconds for the start/end range
* *
* @return Object {"start", "end", "range"} * @return Object {"start", "end", "range"}
*/ */
mod.fnGetScheduleRange = function(dateStart, timeStart, dateEnd, timeEnd) { mod.fnGetScheduleRange = function(dateStartId, timeStartId, dateEndId, timeEndId) {
var iStart, var start,
iEnd, end,
iRange; time;
iStart = AIRTIME.utilities.fnGetTimestamp(dateStart, timeStart); start = $(dateStartId).val();
iEnd = AIRTIME.utilities.fnGetTimestamp(dateEnd, timeEnd); start = start === "" ? null : start;
iRange = iEnd - iStart; time = $(timeStartId).val();
time = time === "" ? "00:00" : time;
if (start) {
start = start + " " + time;
}
end = $(dateEndId).val();
end = end === "" ? null : end;
time = $(timeEndId).val();
time = time === "" ? "00:00" : time;
if (end) {
end = end + " " + time;
}
return { return {
start: iStart, start: start,
end: iEnd, end: end
range: iRange
}; };
}; };

View File

@ -37,10 +37,10 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$connection = Zend_Db::factory('pdo_pgsql', $config); $connection = Zend_Db::factory('pdo_pgsql', $config);
$this->_connectionMock = $this->createZendDbConnection( $this->_connectionMock = $this->createZendDbConnection(
$connection, $connection,
'airtimeunittests' 'airtimeunittests'
); );
Zend_Db_Table_Abstract::setDefaultAdapter($connection); Zend_Db_Table_Abstract::setDefaultAdapter($connection);
} }
return $this->_connectionMock; return $this->_connectionMock;
} }
@ -51,12 +51,12 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
public function getDataSet() public function getDataSet()
{ {
$xml_dataset = $this->createXmlDataSet( $xml_dataset = $this->createXmlDataSet(
dirname(__FILE__) . '/datasets/seed_show_service.xml' dirname(__FILE__) . '/datasets/seed_show_service.xml'
); );
/*$xml_dataset_fixed = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet( /*$xml_dataset_fixed = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet(
$xml_dataset, array('SIX_WEEKS' => $this->_nowDT->add(new DateInterval("P42D"))->format("Y-m-d H:i:s"))); $xml_dataset, array('SIX_WEEKS' => $this->_nowDT->add(new DateInterval("P42D"))->format("Y-m-d H:i:s")));
return $xml_dataset_fixed;*/ return $xml_dataset_fixed;*/
return $xml_dataset; return $xml_dataset;
} }
@ -430,7 +430,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$showService->addUpdateShow($data); $showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet( $ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection() $this->getConnection()
); );
$ds->addTable('cc_show', 'select * from cc_show'); $ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days'); $ds->addTable('cc_show_days', 'select * from cc_show_days');
@ -440,7 +440,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$this->assertDataSetsEqual( $this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_createLinkedShow.xml"), $this->createXmlDataSet(dirname(__FILE__)."/datasets/test_createLinkedShow.xml"),
$ds $ds
); );
/** Test unlinking a show **/ /** Test unlinking a show **/
@ -450,7 +450,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$showService->addUpdateShow($data); $showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet( $ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection() $this->getConnection()
); );
$ds->addTable('cc_show', 'select * from cc_show'); $ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days'); $ds->addTable('cc_show_days', 'select * from cc_show_days');
@ -459,8 +459,8 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts'); $ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual( $this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_unlinkLinkedShow.xml"), $this->createXmlDataSet(dirname(__FILE__)."/datasets/test_unlinkLinkedShow.xml"),
$ds $ds
); );
} }
@ -474,7 +474,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$showService->addUpdateShow($data); $showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet( $ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection() $this->getConnection()
); );
$ds->addTable('cc_show', 'select * from cc_show'); $ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days'); $ds->addTable('cc_show_days', 'select * from cc_show_days');
@ -498,7 +498,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$showService->addUpdateShow($data); $showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet( $ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection() $this->getConnection()
); );
$ds->addTable('cc_show', 'select * from cc_show'); $ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days'); $ds->addTable('cc_show_days', 'select * from cc_show_days');
@ -529,7 +529,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$showService->addUpdateShow($data); $showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet( $ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection() $this->getConnection()
); );
$ds->addTable('cc_show', 'select * from cc_show'); $ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days'); $ds->addTable('cc_show_days', 'select * from cc_show_days');
@ -542,4 +542,188 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds $ds
); );
} }
/**
* Tests that when you remove the first repeat show day, which changes
* the show's first instance start date, updates the scheduled content
* correctly
*/
public function testRemoveFirstRepeatShowDayUpdatesScheduleCorrectly()
{
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_start_date"] = "2016-01-29";
$data["add_show_day_check"] = array(5,6);
$data["add_show_linked"] = 1;
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
//insert some fake tracks into cc_schedule table
$ccFiles = new CcFiles();
$ccFiles
->setDbCueIn("00:00:00")
->setDbCueOut("00:04:32")
->save();
$scheduleItems = array(
0 => array(
"id" => 0,
"instance" => 1,
"timestamp" => time()
)
);
$mediaItems = array(
0 => array(
"id" => 1,
"type" => "audioclip"
)
);
$scheduler = new Application_Model_Scheduler();
$scheduler->scheduleAfter($scheduleItems, $mediaItems);
//delete the first repeat day
$data["add_show_day_check"] = array(6);
$data["add_show_id"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$ds->addTable('cc_schedule', 'select id, starts, ends, file_id, clip_length, fade_in, fade_out, cue_in, cue_out, instance_id, playout_status from cc_schedule');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_removeFirstRepeatShowDayUpdatesScheduleCorrectly.xml"),
$ds
);
}
public function testChangeRepeatDayUpdatesScheduleCorrectly()
{
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_start_date"] = "2016-01-29";
$data["add_show_day_check"] = array(5, 6);
$data["add_show_linked"] = 1;
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
//insert some fake tracks into cc_schedule table
$ccFiles = new CcFiles();
$ccFiles
->setDbCueIn("00:00:00")
->setDbCueOut("00:04:32")
->save();
$scheduleItems = array(
0 => array(
"id" => 0,
"instance" => 1,
"timestamp" => time()
)
);
$mediaItems = array(
0 => array(
"id" => 1,
"type" => "audioclip"
)
);
$scheduler = new Application_Model_Scheduler();
$scheduler->scheduleAfter($scheduleItems, $mediaItems);
//delete the first repeat day
$data["add_show_day_check"] = array(6);
$data["add_show_id"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$ds->addTable('cc_schedule', 'select id, starts, ends, file_id, clip_length, fade_in, fade_out, cue_in, cue_out, instance_id, playout_status from cc_schedule');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_changeRepeatDayUpdatesScheduleCorrectly.xml"),
$ds
);
}
public function testChangeRepeatTypeFromWeeklyToNoRepeat()
{
TestHelper::loginUser();
//test change repeat type from weekly to no-repeat
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_repeats"] = 0;
$data["add_show_id"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_weeklyToNoRepeat.xml"),
$ds
);
}
public function testChangeRepeatTypeFromWeeklyToBiWeekly()
{
TestHelper::loginUser();
//test change repeat type weekly to bi-weekly
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_id"] = 1;
$data["add_show_repeat_type"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_weeklyToBiWeekly.xml"),
$ds
);
}
public function testChangeRepeatTypeFromMonthlyWeeklyToNoRepeat()
{
}
} }

View File

@ -0,0 +1,137 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value>1</value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>2</value>
<value>2016-01-30</value>
<null />
<value>00:00:00</value>
<value>UTC</value>
<value>01:00</value>
<value>6</value>
<value>0</value>
<value>2016-02-13</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>modified_instance</column>
<row>
<value>3</value>
<value>2016-01-30 00:00:00</value>
<value>2016-01-30 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>4</value>
<value>2016-02-06 00:00:00</value>
<value>2016-02-06 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
<table name="cc_schedule">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>file_id</column>
<column>clip_length</column>
<column>fade_in</column>
<column>fade_out</column>
<column>cue_in</column>
<column>cue_out</column>
<column>instance_id</column>
<column>playout_status</column>
<row>
<value>3</value>
<value>2016-01-30 00:00:00</value>
<value>2016-01-30 00:04:32</value>
<value>1</value>
<value>00:04:32</value>
<value>00:00:00.5</value>
<value>00:00:00.5</value>
<value>00:00:00</value>
<value>00:04:32</value>
<value>3</value>
<value>1</value>
</row>
<row>
<value>4</value>
<value>2016-02-06 00:00:00</value>
<value>2016-02-06 00:04:32</value>
<value>1</value>
<value>00:04:32</value>
<value>00:00:00.5</value>
<value>00:00:00.5</value>
<value>00:00:00</value>
<value>00:04:32</value>
<value>4</value>
<value>1</value>
</row>
</table>
</dataset>

View File

@ -0,0 +1,137 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value>1</value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>2</value>
<value>2016-01-30</value>
<null />
<value>00:00:00</value>
<value>UTC</value>
<value>01:00</value>
<value>6</value>
<value>0</value>
<value>2016-02-13</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>modified_instance</column>
<row>
<value>3</value>
<value>2016-01-30 00:00:00</value>
<value>2016-01-30 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>4</value>
<value>2016-02-06 00:00:00</value>
<value>2016-02-06 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
<table name="cc_schedule">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>file_id</column>
<column>clip_length</column>
<column>fade_in</column>
<column>fade_out</column>
<column>cue_in</column>
<column>cue_out</column>
<column>instance_id</column>
<column>playout_status</column>
<row>
<value>3</value>
<value>2016-01-30 00:00:00</value>
<value>2016-01-30 00:04:32</value>
<value>1</value>
<value>00:04:32</value>
<value>00:00:00.5</value>
<value>00:00:00.5</value>
<value>00:00:00</value>
<value>00:04:32</value>
<value>3</value>
<value>1</value>
</row>
<row>
<value>4</value>
<value>2016-02-06 00:00:00</value>
<value>2016-02-06 00:04:32</value>
<value>1</value>
<value>00:04:32</value>
<value>00:00:00.5</value>
<value>00:00:00.5</value>
<value>00:00:00</value>
<value>00:04:32</value>
<value>4</value>
<value>1</value>
</row>
</table>
</dataset>

View File

@ -0,0 +1,107 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value></value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>2</value>
<value>2016-01-01</value>
<null />
<value>00:00:00</value>
<value>UTC</value>
<value>01:00</value>
<value>5</value>
<value>1</value>
<value>2016-02-12</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>modified_instance</column>
<row>
<value>7</value>
<value>2016-01-01 00:00:00</value>
<value>2016-01-01 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>8</value>
<value>2016-01-15 00:00:00</value>
<value>2016-01-15 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>9</value>
<value>2016-01-29 00:00:00</value>
<value>2016-01-29 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
</dataset>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value></value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>2</value>
<value>2016-01-01</value>
<null />
<value>00:00:00</value>
<value>UTC</value>
<value>01:00</value>
<value>5</value>
<value>-1</value>
<value>2016-01-01</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>modified_instance</column>
<row>
<value>1</value>
<value>2016-01-01 00:00:00</value>
<value>2016-01-01 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
</dataset>

View File

@ -27,5 +27,11 @@ export RABBITMQ_PASSWORD
export RABBITMQ_VHOST export RABBITMQ_VHOST
export AIRTIME_UNIT_TEST="1" export AIRTIME_UNIT_TEST="1"
#Change the working directory to this script's directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
#Run the unit tests
phpunit --log-junit test_results.xml phpunit --log-junit test_results.xml

View File

@ -17,7 +17,7 @@ import base64
import traceback import traceback
from configobj import ConfigObj from configobj import ConfigObj
AIRTIME_VERSION = "2.5.1" AIRTIME_API_VERSION = "1.1"
# TODO : Place these functions in some common module. Right now, media # TODO : Place these functions in some common module. Right now, media
@ -218,27 +218,30 @@ class AirtimeApiClient(object):
sys.exit(1) sys.exit(1)
def __get_airtime_version(self): def __get_airtime_version(self):
try: return self.services.version_url()[u'version'] try: return self.services.version_url()[u'airtime_version']
except Exception: return -1
def __get_api_version(self):
try: return self.services.version_url()[u'api_version']
except Exception: return -1 except Exception: return -1
def is_server_compatible(self, verbose=True): def is_server_compatible(self, verbose=True):
logger = self.logger logger = self.logger
version = self.__get_airtime_version() api_version = self.__get_api_version()
# logger.info('Airtime version found: ' + str(version)) # logger.info('Airtime version found: ' + str(version))
if version == -1: if api_version == -1:
if (verbose):
logger.info('Unable to get Airtime version number.\n')
return False
elif version[0:3] != AIRTIME_VERSION[0:3]:
if verbose: if verbose:
logger.info('Airtime version found: ' + str(version)) logger.info('Unable to get Airtime API version number.\n')
logger.info('pypo is at version ' + AIRTIME_VERSION + return False
' and is not compatible with this version of Airtime.\n') elif api_version[0:3] != AIRTIME_API_VERSION[0:3]:
if verbose:
logger.info('Airtime API version found: ' + str(api_version))
logger.info('pypo is only compatible with API version: ' + AIRTIME_API_VERSION)
return False return False
else: else:
if verbose: if verbose:
logger.info('Airtime version: ' + str(version)) logger.info('Airtime API version found: ' + str(api_version))
logger.info('pypo is at version ' + AIRTIME_VERSION + ' and is compatible with this version of Airtime.') logger.info('pypo is only compatible with API version: ' + AIRTIME_API_VERSION)
return True return True

View File

@ -117,76 +117,79 @@ class PypoLiquidsoap():
#independent_event: true #independent_event: true
#}, #},
try:
scheduled_now_files = \
filter(lambda x: x["type"] == eventtypes.FILE, scheduled_now)
scheduled_now_files = \ scheduled_now_webstream = \
filter(lambda x: x["type"] == eventtypes.FILE, scheduled_now) filter(lambda x: x["type"] == eventtypes.STREAM_OUTPUT_START, \
scheduled_now)
scheduled_now_webstream = \ schedule_ids = set(map(lambda x: x["row_id"], scheduled_now_files))
filter(lambda x: x["type"] == eventtypes.STREAM_OUTPUT_START, \
scheduled_now)
schedule_ids = set(map(lambda x: x["row_id"], scheduled_now_files)) row_id_map = {}
liq_queue_ids = set()
row_id_map = {}
liq_queue_ids = set()
for i in self.liq_queue_tracker:
mi = self.liq_queue_tracker[i]
if not self.is_media_item_finished(mi):
liq_queue_ids.add(mi["row_id"])
row_id_map[mi["row_id"]] = mi
to_be_removed = set()
to_be_added = set()
#Iterate over the new files, and compare them to currently scheduled
#tracks. If already in liquidsoap queue still need to make sure they don't
#have different attributes
#if replay gain changes, it shouldn't change the amplification of the currently playing song
for i in scheduled_now_files:
if i["row_id"] in row_id_map:
mi = row_id_map[i["row_id"]]
correct = mi['start'] == i['start'] and \
mi['end'] == i['end'] and \
mi['row_id'] == i['row_id']
if not correct:
#need to re-add
self.logger.info("Track %s found to have new attr." % i)
to_be_removed.add(i["row_id"])
to_be_added.add(i["row_id"])
to_be_removed.update(liq_queue_ids - schedule_ids)
to_be_added.update(schedule_ids - liq_queue_ids)
if to_be_removed:
self.logger.info("Need to remove items from Liquidsoap: %s" % \
to_be_removed)
#remove files from Liquidsoap's queue
for i in self.liq_queue_tracker: for i in self.liq_queue_tracker:
mi = self.liq_queue_tracker[i] mi = self.liq_queue_tracker[i]
if mi is not None and mi["row_id"] in to_be_removed: if not self.is_media_item_finished(mi):
self.stop(i) liq_queue_ids.add(mi["row_id"])
row_id_map[mi["row_id"]] = mi
if to_be_added: to_be_removed = set()
self.logger.info("Need to add items to Liquidsoap *now*: %s" % \ to_be_added = set()
to_be_added)
for i in scheduled_now: #Iterate over the new files, and compare them to currently scheduled
if i["row_id"] in to_be_added: #tracks. If already in liquidsoap queue still need to make sure they don't
self.modify_cue_point(i) #have different attributes
self.play(i) #if replay gain changes, it shouldn't change the amplification of the currently playing song
for i in scheduled_now_files:
if i["row_id"] in row_id_map:
mi = row_id_map[i["row_id"]]
correct = mi['start'] == i['start'] and \
mi['end'] == i['end'] and \
mi['row_id'] == i['row_id']
if not correct:
#need to re-add
self.logger.info("Track %s found to have new attr." % i)
to_be_removed.add(i["row_id"])
to_be_added.add(i["row_id"])
to_be_removed.update(liq_queue_ids - schedule_ids)
to_be_added.update(schedule_ids - liq_queue_ids)
if to_be_removed:
self.logger.info("Need to remove items from Liquidsoap: %s" % \
to_be_removed)
#remove files from Liquidsoap's queue
for i in self.liq_queue_tracker:
mi = self.liq_queue_tracker[i]
if mi is not None and mi["row_id"] in to_be_removed:
self.stop(i)
if to_be_added:
self.logger.info("Need to add items to Liquidsoap *now*: %s" % \
to_be_added)
for i in scheduled_now_files:
if i["row_id"] in to_be_added:
self.modify_cue_point(i)
self.play(i)
#handle webstreams
current_stream_id = self.telnet_liquidsoap.get_current_stream_id()
if scheduled_now_webstream:
if int(current_stream_id) != int(scheduled_now_webstream[0]["row_id"]):
self.play(scheduled_now_webstream[0])
elif current_stream_id != "-1":
#something is playing and it shouldn't be.
self.telnet_liquidsoap.stop_web_stream_buffer()
self.telnet_liquidsoap.stop_web_stream_output()
except KeyError as e:
self.logger.error("Error: Malformed event in schedule. " + str(e))
#handle webstreams
current_stream_id = self.telnet_liquidsoap.get_current_stream_id()
if scheduled_now_webstream:
if int(current_stream_id) != int(scheduled_now_webstream[0]["row_id"]):
self.play(scheduled_now_webstream[0])
elif current_stream_id != "-1":
#something is playing and it shouldn't be.
self.telnet_liquidsoap.stop_web_stream_buffer()
self.telnet_liquidsoap.stop_web_stream_output()
def stop(self, queue): def stop(self, queue):
self.telnet_liquidsoap.queue_remove(queue) self.telnet_liquidsoap.queue_remove(queue)
@ -200,8 +203,7 @@ class PypoLiquidsoap():
self.liq_queue_tracker[i] = None self.liq_queue_tracker[i] = None
def modify_cue_point(self, link): def modify_cue_point(self, link):
if not self.is_file(link): assert self.is_file(link)
return
tnow = datetime.utcnow() tnow = datetime.utcnow()

View File

@ -153,8 +153,10 @@ class PypoPush(Thread):
self.telnet_lock.release() self.telnet_lock.release()
def run(self): def run(self):
try: self.main() while True:
except Exception, e: try: self.main()
top = traceback.format_exc() except Exception, e:
self.logger.error('Pypo Push Exception: %s', top) top = traceback.format_exc()
self.logger.error('Pypo Push Exception: %s', top)
time.sleep(5)