Merge branch '2.4.x' of dev.sourcefabric.org:airtime into 2.4.x

This commit is contained in:
Martin Konecny 2013-05-30 14:02:13 -04:00
commit bc22a8a871
52 changed files with 4833 additions and 4423 deletions

View File

@ -24,7 +24,7 @@ class ErrorController extends Zend_Controller_Action
}
// Log exception, if logger available
if ($log = $this->getLog()) {
if (($log = $this->getLog())) {
$log->crit($this->view->message, $errors->exception);
}

View File

@ -167,7 +167,7 @@ class LocaleController extends Zend_Controller_Action
"Are you sure you want to remove the watched folder?" => _("Are you sure you want to remove the watched folder?"),
"This path is currently not accessible." => _("This path is currently not accessible."),
//preferences/streamsetting.js
"Some steam types require extra configuration. Details about enabling %sAAC+ Support%s or %sOpus Support%s are provided." => _("Some steam types require extra configuration. Details about enabling %sAAC+ Support%s or %sOpus Support%s are provided."),
"Some stream types require extra configuration. Details about enabling %sAAC+ Support%s or %sOpus Support%s are provided." => _("Some stream types require extra configuration. Details about enabling %sAAC+ Support%s or %sOpus Support%s are provided."),
"Connected to the streaming server" => _("Connected to the streaming server"),
"The stream is disabled" => _("The stream is disabled"),
"Getting information from the server..." => _("Getting information from the server..."),
@ -193,6 +193,7 @@ class LocaleController extends Zend_Controller_Action
"If your live streaming client does not ask for a username, this field should be 'source'." => _("If your live streaming client does not ask for a username, this field should be 'source'."),
"The show instance doesn't exist anymore!" => _("The show instance doesn't exist anymore!"),
"Warning: Shows cannot be re-linked" => _("Warning: Shows cannot be re-linked"),
"By linking your repeating shows any media items scheduled in any repeat show will also get scheduled in the other repeat shows" => _("By linking your repeating shows any media items scheduled in any repeat show will also get scheduled in the other repeat shows"),
//schedule/full-calendar-functions
//already in schedule/add-show.js
//"The show instance doesn't exist anymore!" => _("The show instance doesn't exist anymore!"),

View File

@ -32,6 +32,7 @@ class PreferenceController extends Zend_Controller_Action
$this->view->statusMsg = "";
$form = new Application_Form_Preferences();
$values = array();
if ($request->isPost()) {
$params = $request->getPost();
@ -223,6 +224,7 @@ class PreferenceController extends Zend_Controller_Action
$s1_data = array();
$s2_data = array();
$s3_data = array();
$values = array();
foreach($postData as $k=>$v) {
$v = explode('=', urldecode($v));
if (strpos($v[0], "s1_data") !== false) {

View File

@ -600,6 +600,7 @@ class ScheduleController extends Zend_Controller_Action
$baseUrl = $this->getRequest()->getBaseUrl();
$url = $file->getRelativeFileUrl($baseUrl).'download/true';
$menu = array();
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
'title' => _('Download'));

View File

@ -41,6 +41,7 @@ class UserController extends Zend_Controller_Action
if ($request->isPost()) {
$params = $request->getPost();
$postData = explode('&', $params['data']);
$formData = array();
foreach($postData as $k=>$v) {
$v = explode('=', $v);
$formData[$v[0]] = urldecode($v[1]);

View File

@ -4,6 +4,7 @@ class Application_Model_Datatables
{
private static function buildWhereClauseForAdvancedSearch($dbname2searchTerm)
{
$where = array();
$where['clause'] = array();
$where['params'] = array();
foreach ($dbname2searchTerm as $dbname=>$term) {

View File

@ -1075,8 +1075,7 @@ SQL;
$sql .= "END WHERE position IN ($currentPos) and playlist_id=:p1";
Application_Common_Database::prepareAndExecute($sql, array("p1"=>$this->id));
$result['result'] = 0;
return $result;
return array('result' => 0);
}
public static function getAllPlaylistFiles()

View File

@ -398,7 +398,7 @@ SQL;
$map = array();
for ($i = 0, $len = count($p_shows); $i < $len; $i++) {
$holder = "show_".$i;
$holder = ":show_".$i;
$params[] = $holder;
$map[$holder] = $p_shows[$i];

View File

@ -85,6 +85,9 @@ class Application_Model_Scheduler
$nowEpoch = floatval($this->nowDT->format("U.u"));
$schedInfo = array();
$instanceInfo = array();
for ($i = 0; $i < count($items); $i++) {
$id = $items[$i]["id"];
@ -103,7 +106,7 @@ class Application_Model_Scheduler
}
$schedIds = array();
if (isset($schedInfo)) {
if (count($schedInfo) > 0) {
$schedIds = array_keys($schedInfo);
}
$schedItems = CcScheduleQuery::create()->findPKs($schedIds, $this->con);
@ -609,6 +612,11 @@ class Application_Model_Scheduler
$instanceId);
$pos++;
/* Show is not empty so we need to apply crossfades
* for the first inserted item
*/
$applyCrossfades = true;
}
//selected empty row to add after
else {
@ -617,6 +625,11 @@ class Application_Model_Scheduler
//first item in show so start position counter at 0
$pos = 0;
/* Show is empty so we don't need to calculate crossfades
* for the first inserted item
*/
$applyCrossfades = false;
}
if (!in_array($instanceId, $affectedShowInstances)) {
@ -631,7 +644,12 @@ class Application_Model_Scheduler
$pstart = microtime(true);
if ($applyCrossfades) {
$initalStartDT = clone $this->findTimeDifference(
$nextStartDT, $this->crossfadeDuration);
} else {
$initalStartDT = clone $nextStartDT;
}
$pend = microtime(true);
Logging::debug("finding all following items.");
@ -693,7 +711,6 @@ class Application_Model_Scheduler
$doInsert = true;
}
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
// default fades are in seconds
// we need to convert to '00:00:00' format
$file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']);
@ -711,6 +728,18 @@ class Application_Model_Scheduler
default: break;
}
if ($applyCrossfades) {
$nextStartDT = $this->findTimeDifference($nextStartDT,
$this->crossfadeDuration);
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
$endTimeDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration);
/* Set it to false because the rest of the crossfades
* will be applied after we insert each item
*/
$applyCrossfades = false;
}
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
if ($doInsert) {
$values[] = "(".
"'{$nextStartDT->format("Y-m-d H:i:s")}', ".
@ -794,6 +823,7 @@ class Application_Model_Scheduler
//recalculate the start/end times after the inserted items.
foreach ($followingSchedItems as $item) {
$endTimeDT = $this->findEndTime($nextStartDT, $item["clip_length"]);
$endTimeDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration);
$update_sql = "UPDATE cc_schedule SET ".
"starts = '{$nextStartDT->format("Y-m-d H:i:s")}', ".
"ends = '{$endTimeDT->format("Y-m-d H:i:s")}', ".

View File

@ -388,6 +388,7 @@ class Application_Model_ShowBuilder
$outdated = false;
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
$include = array();
if ($this->opts["showFilter"] !== 0) {
$include[] = $this->opts["showFilter"];
} elseif ($this->opts["myShows"] === 1) {

View File

@ -352,10 +352,10 @@ SQL;
);
//only need to check overlap if show increased in size.
if (strtotime($new_ends) > strtotime($ends)) {
if (strtotime($now_ends) > strtotime($ends)) {
$utcStartDateTime = new DateTime($ends, new DateTimeZone("UTC"));
$utcEndDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
$utcEndDateTime = new DateTime($now_ends, new DateTimeZone("UTC"));
$overlap = Application_Model_Show::getShows($utcStartDateTime, $utcEndDateTime);
@ -381,7 +381,7 @@ SQL;
}
$this->setShowEnd($new_ends);
$this->setShowEnd($now_ends);
Application_Model_RabbitMq::PushSchedule();
}

View File

@ -893,7 +893,7 @@ SQL;
$in = fopen($_FILES['file']['tmp_name'], "rb");
if ($in) {
while ($buff = fread($in, 4096))
while (($buff = fread($in, 4096)))
fwrite($out, $buff);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": _("Failed to open input stream.")}, "id" : "id"}');
@ -912,7 +912,7 @@ SQL;
$in = fopen("php://input", "rb");
if ($in) {
while ($buff = fread($in, 4096))
while (($buff = fread($in, 4096)))
fwrite($out, $buff);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": _("Failed to open input stream.")}, "id" : "id"}');
@ -961,6 +961,7 @@ SQL;
// Check if we have enough space before copying
if (!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
$freeSpace = disk_free_space($stor);
$fileSize = filesize($audio_file);
return array("code" => 107,
"message" => sprintf(_("The file was not uploaded, there is "

View File

@ -125,6 +125,7 @@ class Application_Model_Systemstatus
public static function GetPlatformInfo()
{
$keys = array("release", "machine", "memory", "swap");
$data = array();
foreach ($keys as $key) {
$data[$key] = "UNKNOWN";
}
@ -212,7 +213,7 @@ class Application_Model_Systemstatus
public static function GetDiskInfo()
{
$partions = array();
$partitions = array();
/* First lets get all the watched directories. Then we can group them
* into the same partitions by comparing the partition sizes. */

View File

@ -226,7 +226,7 @@ class Application_Model_User
public function deleteAllFiles()
{
$my_files = $this->getOwnedFiles();
foreach ($files as $file) {
foreach ($my_files as $file) {
$file->delete();
}
}

View File

@ -57,6 +57,14 @@ class CcFiles extends BaseCcFiles {
return $this;
}
public function setDbTrackNumber($v)
{
$max = pow(2, 31)-1;
$v = ($v > $max) ? $max : $v;
return parent::setDbTrackNumber($v);
}
// returns true if the file exists and is not hidden
public function visible() {
return $this->getDbFileExists() && !$this->getDbHidden();

View File

@ -206,7 +206,8 @@ class Application_Service_SchedulerService
if (is_null($item["file_id"])) {
$item["file_id"] = "null";
} elseif (is_null($item["stream_id"])) {
}
if (is_null($item["stream_id"])) {
$item["stream_id"] = "null";
}

View File

@ -99,8 +99,9 @@ class Application_Service_ShowFormService
public function delegateShowFormPopulation($forms)
{
$this->populateFormWhat($forms["what"]);
$this->populateFormWhen($forms["when"]);
$this->populateFormRepeats($forms["repeats"]);
//local show start DT
$showStart = $this->populateFormWhen($forms["when"]);
$this->populateFormRepeats($forms["repeats"], $showStart);
$this->populateFormWho($forms["who"]);
$this->populateFormStyle($forms["style"]);
$this->populateFormLive($forms["live"]);
@ -136,6 +137,9 @@ class Application_Service_ShowFormService
$form->disableStartDateAndTime();
} else {
list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime();
if ($this->hasShowStarted($showStart)) {
$form->disableStartDateAndTime();
}
}
}
@ -147,6 +151,8 @@ class Application_Service_ShowFormService
'add_show_end_time' => $showEnd->format("H:i"),
'add_show_duration' => $ccShowDay->formatDuration(true),
'add_show_repeats' => $ccShowDay->isRepeating() ? 1 : 0));
return $showStart;
}
private function populateInstanceFormWhen($form)
@ -179,7 +185,13 @@ class Application_Service_ShowFormService
$form->getElement('add_show_repeats')->setOptions(array("disabled" => true));
}
private function populateFormRepeats($form)
/**
*
* Enter description here ...
* @param $form
* @param DateTime $nextFutureShowStart user's local timezone
*/
private function populateFormRepeats($form, $nextFutureShowStart)
{
$ccShowDays = $this->ccShow->getCcShowDays();
@ -219,6 +231,14 @@ class Application_Service_ShowFormService
if (!$this->ccShow->isLinkable() || $this->ccShow->isRecorded()) {
$form->getElement('add_show_linked')->setOptions(array('disabled' => true));
}
/* Because live editing of a linked show is disabled, we will disable
* the linking option if the current show is being edited. We don't
* want the user to suddenly not be able to edit the current show
*/
if ($this->hasShowStarted($nextFutureShowStart)) {
$form->getElement('add_show_linked')->setOptions(array('disabled' => true));
}
}
private function populateFormWho($form)
@ -295,6 +315,22 @@ class Application_Service_ShowFormService
$form->populate($formValues);
}
/**
*
* Enter description here ...
* @param DateTime $showStart user's local time
*/
private function hasShowStarted($p_showStart) {
$showStart = clone $p_showStart;
$showStart->setTimeZone(new DateTimeZone("UTC"));
if ($showStart->format("Y-m-d H:i:s") < gmdate("Y-m-d H:i:s")) {
return true;
} else {
return false;
}
}
/**
*
* Before we send the form data in for validation, there

View File

@ -999,7 +999,7 @@ SQL;
}
if ($this->isRebroadcast) {
$this->createRebroadcastInstances($showDay, $date, $ccShowInstance->getDbId());
$this->createRebroadcastInstances($showDay, $start, $ccShowInstance->getDbId());
}
}
$start = $this->getNextMonthlyMonthlyRepeatDate($start, $timezone, $showDay->getDbStartTime());

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,14 +63,6 @@ class PypoFile(Thread):
self.logger.debug("copying from %s to local cache %s" % (src, dst))
try:
"""
List file as "ready" before it starts copying because by the time
Liquidsoap is ready to play this file, it should have at least started
copying (and can continue copying while Liquidsoap reads from the beginning
of the file)
"""
media_item['file_ready'] = True
"""
copy will overwrite dst if it already exists
"""
@ -78,6 +70,8 @@ class PypoFile(Thread):
#make file world readable
os.chmod(dst, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
media_item['file_ready'] = True
except Exception, e:
self.logger.error("Could not copy from %s to %s" % (src, dst))
self.logger.error(e)