Merge branch '2.3.x' into devel

Conflicts:
	airtime_mvc/application/controllers/LibraryController.php
	airtime_mvc/application/models/StoredFile.php
This commit is contained in:
Martin Konecny 2013-02-02 21:07:34 -05:00
commit 93ec4c001b
39 changed files with 424 additions and 146 deletions

View file

@ -60,8 +60,10 @@ class AudiopreviewController extends Zend_Controller_Action
$this->view->uri = $uri;
$this->view->mime = $mime;
$this->view->audioFileID = $audioFileID;
$this->view->audioFileArtist = $audioFileArtist;
$this->view->audioFileTitle = $audioFileTitle;
// We need to decode artist and title because it gets
// encoded twice in js
$this->view->audioFileArtist = urldecode($audioFileArtist);
$this->view->audioFileTitle = urldecode($audioFileTitle);
$this->view->type = $type;
$this->_helper->viewRenderer->setRender('audio-preview');

View file

@ -412,7 +412,7 @@ class LibraryController extends Zend_Controller_Action
$formValues = $this->_getParam('data', null);
$formdata = array();
foreach ($formValues as $val) {
$formdata[$val["name"]] = $val["value"];
$formdata[$val["name"]] = htmlspecialchars($val["value"]);
}
$file->setDbColMetadata($formdata);

View file

@ -4,10 +4,6 @@ class LocaleController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper("AjaxContext");
$ajaxContext->addActionContext("general-translation-table", "json")
->addActionContext("datatables-translation-table", "json")
->initContext();
}
public function datatablesTranslationTableAction()
@ -26,7 +22,7 @@ class LocaleController extends Zend_Controller_Action
$locale.".txt")
);
}
public function generalTranslationTableAction()
{
$translations = array (

View file

@ -274,6 +274,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::setReplayGainModifier($values["replayGainModifier"]);
$md = array('schedule' => Application_Model_Schedule::getSchedule());
Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md);
//Application_Model_RabbitMq::PushSchedule();
}
if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {

View file

@ -9,6 +9,7 @@ class ScheduleController extends Zend_Controller_Action
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('event-feed', 'json')
->addActionContext('event-feed-preload', 'json')
->addActionContext('make-context-menu', 'json')
->addActionContext('add-show-dialog', 'json')
->addActionContext('add-show', 'json')
@ -89,15 +90,23 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
//End Show builder JS/CSS requirements
Application_Model_Schedule::createNewFormSections($this->view);
$user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$this->view->preloadShowForm = true;
}
$this->view->headScript()->appendScript("var weekStart = ".Application_Model_Preference::GetWeekStartDay().";");
$this->view->headScript()->appendScript(
"var calendarPref = {};\n".
"calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n".
"calendarPref.timestamp = ".time().";\n".
"calendarPref.timezoneOffset = ".date("Z").";\n".
"calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n".
"calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n".
"calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n".
"var calendarEvents = null;"
);
}
public function eventFeedAction()
@ -109,10 +118,28 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$editable = true;
$editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
$this->view->events = $events;
}
public function eventFeedPreloadAction()
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$calendar_interval = Application_Model_Preference::GetCalendarTimeScale();
Logging::info($calendar_interval);
if ($calendar_interval == "agendaDay") {
list($start, $end) = Application_Model_Show::getStartEndCurrentDayView();
} else if ($calendar_interval == "agendaWeek") {
list($start, $end) = Application_Model_Show::getStartEndCurrentWeekView();
} else if ($calendar_interval == "month") {
list($start, $end) = Application_Model_Show::getStartEndCurrentMonthView();
} else {
$editable = false;
Logging::error("Invalid Calendar Interval '$calendar_interval'");
}
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);

View file

@ -110,7 +110,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
{
$controller = strtolower($request->getControllerName());
if (in_array($controller, array("api", "auth"))) {
if (in_array($controller, array("api", "auth", "locale"))) {
$this->setRoleName("G");
} elseif (!Zend_Auth::getInstance()->hasIdentity()) {

View file

@ -7,7 +7,7 @@ class Application_Form_RegisterAirtime extends Zend_Form
public function init()
{
$this->setAction(Application_Common_OsPath::getBaseDir().'/Showbuilder');
$this->setAction(Application_Common_OsPath::getBaseDir().'Showbuilder');
$this->setMethod('post');
$country_list = Application_Model_Preference::GetCountryList();

View file

@ -24,7 +24,7 @@
<div class="personal-block solo">
<ul>
<li>
<a id="current-user" href=<?php echo $baseUrl . "User/edit-user"?>><span class="name"><?php echo $this->loggedInAs()?></span></a> | <a href=<?php echo $baseUrl . "Login/logout"?>><?php echo _("Logout")?></a>
<a id="current-user" href=<?php echo $baseUrl . "User/edit-user"?>><span class="name"><?php echo $this->escape($this->loggedInAs()); ?></span></a> | <a href=<?php echo $baseUrl . "Login/logout"?>><?php echo _("Logout")?></a>
</li>
</ul>
</div>

View file

@ -32,6 +32,8 @@ class Logging {
{
if (is_array($p_msg) || is_object($p_msg)) {
return print_r($p_msg, true);
} else if (is_bool($p_msg)) {
return $p_msg ? "true" : "false";
} else {
return $p_msg;
}

View file

@ -731,6 +731,10 @@ SQL;
'replay_gain' => $replay_gain,
'independent_event' => $independent_event,
);
if ($schedule_item['cue_in'] > $schedule_item['cue_out']) {
$schedule_item['cue_in'] = $schedule_item['cue_out'];
}
self::appendScheduleItem($data, $start, $schedule_item);
}
@ -941,7 +945,6 @@ SQL;
self::createScheduledEvents($data, $range_start, $range_end);
self::foldData($data["media"]);
return $data;
}

View file

@ -136,13 +136,17 @@ class Application_Model_Scheduler
if ($type === "audioclip") {
$file = CcFilesQuery::create()->findPK($id, $this->con);
$storedFile = new Application_Model_StoredFile($file->getDbId());
if (is_null($file) || !$file->visible()) {
throw new Exception(_("A selected File does not exist!"));
} else {
$data = $this->fileInfo;
$data["id"] = $id;
$data["cliplength"] = $file->getDbLength();
$data["cliplength"] = $storedFile->getRealClipLength(
$file->getDbCuein(),
$file->getDbCueout());
$data["cuein"] = $file->getDbCuein();
$data["cueout"] = $file->getDbCueout();
@ -438,7 +442,6 @@ class Application_Model_Scheduler
}
foreach ($schedFiles as $file) {
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
//item existed previously and is being moved.

View file

@ -1750,14 +1750,15 @@ SQL;
$interval = $p_start->diff($p_end);
$days = $interval->format('%a');
$shows = Application_Model_Show::getShows($p_start, $p_end);
$nowEpoch = time();
$content_count = Application_Model_ShowInstance::getContentCount(
$p_start, $p_end);
$isFull = Application_Model_ShowInstance::getIsFull($p_start, $p_end);
$timezone = date_default_timezone_get();
$current_timezone = new DateTimeZone($timezone);
$utc = new DateTimeZone("UTC");
$now = new DateTime("now", $utc);
foreach ($shows as $show) {
foreach ($shows as &$show) {
$options = array();
//only bother calculating percent for week or day view.
@ -1767,7 +1768,6 @@ SQL;
if (isset($show["parent_starts"])) {
$parentStartsDT = new DateTime($show["parent_starts"], $utc);
$parentStartsEpoch = intval($parentStartsDT->format("U"));
}
$startsDT = DateTime::createFromFormat("Y-m-d G:i:s",
@ -1775,35 +1775,53 @@ SQL;
$endsDT = DateTime::createFromFormat("Y-m-d G:i:s",
$show["ends"], $utc);
$startsEpochStr = $startsDT->format("U");
$endsEpochStr = $endsDT->format("U");
$startsEpoch = intval($startsEpochStr);
$endsEpoch = intval($endsEpochStr);
$startsDT->setTimezone(new DateTimeZone($timezone));
$endsDT->setTimezone(new DateTimeZone($timezone));
if( $p_editable ) {
if ($show["record"] && $nowEpoch > $startsEpoch) {
if ($show["record"] && $now > $startsDT) {
$options["editable"] = false;
} elseif ($show["rebroadcast"] &&
$nowEpoch > $parentStartsEpoch) {
$now > $parentStartsDT) {
$options["editable"] = false;
} elseif ($nowEpoch < $endsEpoch) {
} elseif ($now < $endsDT) {
$options["editable"] = true;
}
}
$startsDT->setTimezone($current_timezone);
$endsDT->setTimezone($current_timezone);
$options["show_empty"] = (array_key_exists($show['instance_id'],
$content_count)) ? 0 : 1;
$options["show_partial_filled"] = !$isFull[$show['instance_id']];
$events[] = &self::makeFullCalendarEvent($show, $options,
$startsDT, $endsDT, $startsEpochStr, $endsEpochStr);
}
$event = array();
$event["id"] = intval($show["instance_id"]);
$event["title"] = $show["name"];
$event["start"] = $startsDT->format("Y-m-d H:i:s");
$event["end"] = $endsDT->format("Y-m-d H:i:s");
$event["allDay"] = false;
$event["showId"] = intval($show["show_id"]);
$event["record"] = intval($show["record"]);
$event["rebroadcast"] = intval($show["rebroadcast"]);
$event["soundcloud_id"] = is_null($show["soundcloud_id"])
? -1 : $show["soundcloud_id"];
//event colouring
if ($show["color"] != "") {
$event["textColor"] = "#".$show["color"];
}
if ($show["background_color"] != "") {
$event["color"] = "#".$show["background_color"];
}
foreach ($options as $key => $value) {
$event[$key] = $value;
}
$events[] = $event;
}
return $events;
}
@ -1820,7 +1838,7 @@ SQL;
return $percent;
}
private static function &makeFullCalendarEvent(&$show, $options=array(), $startDateTime, $endDateTime, $startsEpoch, $endsEpoch)
/* private static function &makeFullCalendarEvent(&$show, $options=array(), $startDateTime, $endDateTime, $startsEpoch, $endsEpoch)
{
$event = array();
@ -1851,7 +1869,7 @@ SQL;
}
return $event;
}
}*/
/* Takes in a UTC DateTime object.
* Converts this to local time, since cc_show days
@ -2158,4 +2176,42 @@ SQL;
}
return $assocArray;
}
public static function getStartEndCurrentMonthView() {
$first_day_of_calendar_month_view = mktime(0, 0, 0, date("n"), 1);
$weekStart = Application_Model_Preference::GetWeekStartDay();
while (date('w', $first_day_of_calendar_month_view) != $weekStart) {
$first_day_of_calendar_month_view -= 60*60*24;
}
$last_day_of_calendar_view = $first_day_of_calendar_month_view + 3600*24*42;
$start = new DateTime("@".$first_day_of_calendar_month_view);
$end = new DateTime("@".$last_day_of_calendar_view);
return array($start, $end);
}
public static function getStartEndCurrentWeekView() {
$first_day_of_calendar_week_view = mktime(0, 0, 0, date("n"), date("j"));
$weekStart = Application_Model_Preference::GetWeekStartDay();
while (date('w', $first_day_of_calendar_week_view) != $weekStart) {
$first_day_of_calendar_week_view -= 60*60*24;
}
$last_day_of_calendar_view = $first_day_of_calendar_week_view + 3600*24*7;
$start = new DateTime("@".$first_day_of_calendar_week_view);
$end = new DateTime("@".$last_day_of_calendar_view);
return array($start, $end);
}
public static function getStartEndCurrentDayView() {
$today = mktime(0, 0, 0, date("n"), date("j"));
$tomorrow = $today + 3600*24;
$start = new DateTime("@".$today);
$end = new DateTime("@".$tomorrow);
return array($start, $end);
}
}

View file

@ -227,7 +227,7 @@ class Application_Model_ShowBuilder
$row["endDate"] = $showEndDT->format("Y-m-d");
$row["endTime"] = $showEndDT->format("H:i");
$row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u"));
$row["title"] = $p_item["show_name"];
$row["title"] = htmlspecialchars($p_item["show_name"]);
$row["instance"] = intval($p_item["si_id"]);
$row["image"] = '';

View file

@ -1310,6 +1310,14 @@ SQL;
return $updateIsScheduled;
}
public function getRealClipLength($p_cuein, $p_cueout) {
$sql = "SELECT :cueout::INTERVAL - :cuein::INTERVAL";
return Application_Common_Database::prepareAndExecute($sql, array(
':cueout' => $p_cueout,
':cuein' => $p_cuein), 'column');
}
}
class DeleteScheduledFileException extends Exception {}

View file

@ -214,35 +214,22 @@ class Application_Model_Systemstatus
{
$partions = array();
if (isset($_SERVER['AIRTIME_SRV'])) {
//connect to DB and find how much total space user has allocated.
$totalSpace = Application_Model_Preference::GetDiskQuota();
/* First lets get all the watched directories. Then we can group them
* into the same partitions by comparing the partition sizes. */
$musicDirs = Application_Model_MusicDir::getWatchedDirs();
$musicDirs[] = Application_Model_MusicDir::getStorDir();
$storPath = Application_Model_MusicDir::getStorDir()->getDirectory();
foreach ($musicDirs as $md) {
$totalSpace = disk_total_space($md->getDirectory());
list($usedSpace,) = preg_split("/[\s]+/", exec("du -bs $storPath"));
if (!isset($partitions[$totalSpace])) {
$partitions[$totalSpace] = new StdClass;
$partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
$partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = $totalSpace - $usedSpace;
Logging::info($partitions[$totalSpace]->totalFreeSpace);
} else {
/* First lets get all the watched directories. Then we can group them
* into the same partitions by comparing the partition sizes. */
$musicDirs = Application_Model_MusicDir::getWatchedDirs();
$musicDirs[] = Application_Model_MusicDir::getStorDir();
foreach ($musicDirs as $md) {
$totalSpace = disk_total_space($md->getDirectory());
if (!isset($partitions[$totalSpace])) {
$partitions[$totalSpace] = new StdClass;
$partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
}
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
}
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
}
return array_values($partitions);

View file

@ -335,6 +335,8 @@ class Application_Model_User
} else {
$record['delete'] = "";
}
$record = array_map('htmlspecialchars', $record);
}
return $res;

View file

@ -1,4 +1,4 @@
<h2><? echo sprintf(_("%s's Settings"), $this->currentUser) ?></h2>
<h2><? echo sprintf(_("%s's Settings"), $this->escape($this->currentUser)) ?></h2>
<div id="current-user-container">
<form id="current-user-form" class="edit-user-global" method="post" enctype="application/x-www-form-urlencoded">
<dl class="zend_form">
@ -160,4 +160,4 @@
<button type="submit" id="cu_save_user" class="btn btn-small right-floated"><?php echo _("Save")?></button>
</dl>
</form>
</div>
</div>

View file

@ -11,7 +11,7 @@
<?php if($this->element->getElement('storageFolder')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('storageFolder')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<li><?php echo $this->escape($error); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
@ -29,7 +29,7 @@
<?php if($this->element->getElement('watchedFolder')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('watchedFolder')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<li><?php echo $this->escape($error); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

View file

@ -42,7 +42,7 @@ if (isset($this->obj)) {
<input id='obj_type' type='hidden' value='playlist'></input>
<div class="playlist_title">
<h3 id="obj_name">
<a id="playlist_name_display" contenteditable="true"><?php echo $this->obj->getName(); ?></a>
<a id="playlist_name_display" contenteditable="true"><?php echo $this->escape($this->obj->getName()); ?></a>
</h3>
<h4 id="obj_length"><?php echo $this->length; ?></h4>
</div>

View file

@ -1,6 +1,6 @@
$(window).load(function(){
$("#username").focus();
$("#locale").val($.cookie("airtime_locale")!== null?$.cookie("airtime_locale"):'en_CA');
$("#locale").val($.cookie("airtime_locale")!== null?$.cookie("airtime_locale"):$.cookie("default_airtime_locale"));
});
$(document).ready(function() {

View file

@ -111,6 +111,7 @@ $(document).ready(function() {
$.post(url, {format: "json", data: data}, function(data){
var json = $.parseJSON(data);
$('#content').empty().append(json.html);
$.cookie("default_airtime_locale", $('#locale').val(), {path: '/'});
setTimeout(removeSuccessMsg, 5000);
showErrorSections();
});

View file

@ -28,7 +28,7 @@ function rebuildStreamURL(ele){
}else{
streamurl = "http://"+host+":"+port+"/"
}
div.find("#stream_url").html(streamurl)
div.find("#stream_url").text(streamurl)
}
function restrictOggBitrate(ele, on){
var div = ele.closest("div")

View file

@ -37,7 +37,7 @@ function createDateInput(el, onSelect) {
dayNamesMin: i18n_days_short,
closeText: $.i18n._('Close'),
//showButtonPanel: true,
firstDay: weekStart
firstDay: calendarPref.weekStart
});
}
@ -324,7 +324,7 @@ function setAddShowEvents() {
dayNamesMin: i18n_days_short,
closeText: 'Close',
showButtonPanel: true,
firstDay: weekStart
firstDay: calendarPref.weekStart
});
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({
amPmText: ['', ''],

View file

@ -326,21 +326,36 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
});
}
function getFullCalendarEvents(start, end, callback) {
var url, start_date, end_date;
start_date = makeTimeStamp(start);
end_date = makeTimeStamp(end);
url = baseUrl+'Schedule/event-feed';
function preloadEventFeed () {
var url = baseUrl+'Schedule/event-feed-preload';
var d = new Date();
$.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){
callback(json.events);
$.post(url, {format: "json", cachep: d.getTime()}, function(json){
calendarEvents = json.events;
createFullCalendar({calendarInit: calendarPref});
});
}
var initialLoad = true;
function getFullCalendarEvents(start, end, callback) {
if (initialLoad) {
initialLoad = false;
callback(calendarEvents);
} else {
var url, start_date, end_date;
start_date = makeTimeStamp(start);
end_date = makeTimeStamp(end);
url = baseUrl+'Schedule/event-feed';
var d = new Date();
$.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){
callback(json.events);
});
}
}
function checkSCUploadStatus(){
var url = baseUrl+'Library/get-upload-to-soundcloud-status/format/json';
$("span[class*=progress]").each(function(){
@ -541,6 +556,7 @@ function alertShowErrorAndReload(){
window.location.reload();
}
preloadEventFeed();
$(document).ready(function(){
setInterval( "checkSCUploadStatus()", 5000 );
setInterval( "getCurrentShow()", 5000 );

View file

@ -328,9 +328,6 @@ function alertShowErrorAndReload(){
}
$(document).ready(function() {
$.ajax({ url: baseUrl+"Api/calendar-init/format/json", dataType:"json", success:createFullCalendar
, error:function(jqXHR, textStatus, errorThrown){}});
setInterval(checkCalendarSCUploadStatus, 5000);
$.contextMenu({