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

This commit is contained in:
Martin Konecny 2012-09-17 22:48:16 -04:00
commit aa3bf3941b
4 changed files with 94 additions and 83 deletions

View File

@ -23,26 +23,26 @@ class Application_Model_ShowBuilder
private $showInstances = array(); private $showInstances = array();
private $defaultRowArray = array( private $defaultRowArray = array(
"header" => false, "header" => false,
"footer" => false, "footer" => false,
"empty" => false, "empty" => false,
"allowed" => false, "allowed" => false,
"id" => 0, "id" => 0,
"instance" => "", "instance" => "",
"starts" => "", "starts" => "",
"ends" => "", "ends" => "",
"runtime" => "", "runtime" => "",
"title" => "", "title" => "",
"creator" => "", "creator" => "",
"album" => "", "album" => "",
"timestamp" => null, "timestamp" => null,
"cuein" => "", "cuein" => "",
"cueout" => "", "cueout" => "",
"fadein" => "", "fadein" => "",
"fadeout" => "", "fadeout" => "",
"image" => false, "image" => false,
"color" => "", //in hex without the '#' sign. "color" => "", //in hex without the '#' sign.
"backgroundColor"=> "", //in hex without the '#' sign. "backgroundColor" => "", //in hex without the '#' sign.
); );
/* /*
@ -51,12 +51,12 @@ class Application_Model_ShowBuilder
*/ */
public function __construct($p_startDT, $p_endDT, $p_opts) public function __construct($p_startDT, $p_endDT, $p_opts)
{ {
$this->startDT = $p_startDT; $this->startDT = $p_startDT;
$this->endDT = $p_endDT; $this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get(); $this->timezone = date_default_timezone_get();
$this->user = Application_Model_User::getCurrentUser(); $this->user = Application_Model_User::getCurrentUser();
$this->opts = $p_opts; $this->opts = $p_opts;
$this->epoch_now = floatval(microtime(true)); $this->epoch_now = floatval(microtime(true));
$this->currentShow = false; $this->currentShow = false;
} }
@ -91,7 +91,7 @@ class Application_Model_ShowBuilder
private function getItemColor($p_item, &$row) private function getItemColor($p_item, &$row)
{ {
$defaultColor = "ffffff"; $defaultColor = "ffffff";
$defaultBackground = "3366cc"; $defaultBackground = "3366cc";
$color = $p_item["show_color"]; $color = $p_item["show_color"];
@ -103,7 +103,7 @@ class Application_Model_ShowBuilder
$backgroundColor = $defaultBackground; $backgroundColor = $defaultBackground;
} }
$row["color"] = $color; $row["color"] = $color;
$row["backgroundColor"] = $backgroundColor; $row["backgroundColor"] = $backgroundColor;
} }
@ -129,6 +129,7 @@ class Application_Model_ShowBuilder
* 0 = past * 0 = past
* 1 = current * 1 = current
* 2 = future * 2 = future
* TODO : change all of the above to real constants -- RG
*/ */
private function getScheduledStatus($p_epochItemStart, $p_epochItemEnd, &$row) private function getScheduledStatus($p_epochItemStart, $p_epochItemEnd, &$row)
{ {
@ -157,6 +158,14 @@ class Application_Model_ShowBuilder
//item is in the future. //item is in the future.
else if ($this->epoch_now < $p_epochItemStart) { else if ($this->epoch_now < $p_epochItemStart) {
$row["scheduled"] = 2; $row["scheduled"] = 2;
} else {
Logging::warn("No-op? is this what should happen...printing
debug just in case");
$d = array(
'$p_epochItemStart' => $p_epochItemStart,
'$p_epochItemEnd' => $p_epochItemEnd,
'$row' => $row);
Logging::warn($d);
} }
} }
@ -241,50 +250,50 @@ class Application_Model_ShowBuilder
$this->getItemStatus($p_item, $row); $this->getItemStatus($p_item, $row);
$startsEpoch = floatval($schedStartDT->format("U.u")); $startsEpoch = floatval($schedStartDT->format("U.u"));
$endsEpoch = floatval($schedEndDT->format("U.u")); $endsEpoch = floatval($schedEndDT->format("U.u"));
$showEndEpoch = floatval($showEndDT->format("U.u")); $showEndEpoch = floatval($showEndDT->format("U.u"));
//don't want an overbooked item to stay marked as current. //don't want an overbooked item to stay marked as current.
$this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row); $this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row);
$row["id"] = intval($p_item["sched_id"]); $row["id"] = intval($p_item["sched_id"]);
$row["image"] = $p_item["file_exists"]; $row["image"] = $p_item["file_exists"];
$row["instance"] = intval($p_item["si_id"]); $row["instance"] = intval($p_item["si_id"]);
$row["starts"] = $schedStartDT->format("H:i:s"); $row["starts"] = $schedStartDT->format("H:i:s");
$row["ends"] = $schedEndDT->format("H:i:s"); $row["ends"] = $schedEndDT->format("H:i:s");
$formatter = new LengthFormatter($p_item['file_length']); $formatter = new LengthFormatter($p_item['file_length']);
$row['runtime'] = $formatter->format(); $row['runtime'] = $formatter->format();
$row["title"] = $p_item["file_track_title"]; $row["title"] = $p_item["file_track_title"];
$row["creator"] = $p_item["file_artist_name"]; $row["creator"] = $p_item["file_artist_name"];
$row["album"] = $p_item["file_album_title"]; $row["album"] = $p_item["file_album_title"];
$row["cuein"] = $p_item["cue_in"]; $row["cuein"] = $p_item["cue_in"];
$row["cueout"] = $p_item["cue_out"]; $row["cueout"] = $p_item["cue_out"];
$row["fadein"] = round(substr($p_item["fade_in"], 6), 6); $row["fadein"] = round(substr($p_item["fade_in"], 6), 6);
$row["fadeout"] = round(substr($p_item["fade_out"], 6), 6); $row["fadeout"] = round(substr($p_item["fade_out"], 6), 6);
$row["pos"] = $this->pos++; $row["pos"] = $this->pos++;
$this->contentDT = $schedEndDT; $this->contentDT = $schedEndDT;
} }
//show is empty or is a special kind of show (recording etc) //show is empty or is a special kind of show (recording etc)
else if (intval($p_item["si_record"]) === 1) { else if (intval($p_item["si_record"]) === 1) {
$row["record"] = true; $row["record"] = true;
$row["instance"] = intval($p_item["si_id"]); $row["instance"] = intval($p_item["si_id"]);
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$startsEpoch = floatval($showStartDT->format("U.u")); $startsEpoch = floatval($showStartDT->format("U.u"));
$endsEpoch = floatval($showEndDT->format("U.u")); $endsEpoch = floatval($showEndDT->format("U.u"));
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row); $this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
} else { } else {
$row["empty"] = true; $row["empty"] = true;
$row["id"] = 0 ; $row["id"] = 0 ;
$row["instance"] = intval($p_item["si_id"]); $row["instance"] = intval($p_item["si_id"]);
} }
@ -335,6 +344,10 @@ class Application_Model_ShowBuilder
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row); $this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
$this->isAllowed($p_item, $row); $this->isAllowed($p_item, $row);
if (intval($p_item["si_record"]) === 1) {
$row["record"] = true;
}
return $row; return $row;
} }

View File

@ -112,16 +112,25 @@ var AIRTIME = (function(AIRTIME){
}; };
mod.checkCancelButton = function() { mod.checkCancelButton = function() {
var $current = $sbTable.find(".sb-current-show.sb-allowed"),
var $current = $sbTable.find(".sb-current-show"),
//this user type should be refactored into a separate users module later //this user type should be refactored into a separate users module later
//when there's more time and more JS will need to know user data. //when there's more time and more JS will need to know user data.
userType = localStorage.getItem('user-type'); userType = localStorage.getItem('user-type'),
canCancel = false;
if ($current.length !== 0 && (userType === 'A' || userType === 'P')) { if ($current.length !== 0 && $current.hasClass("sb-allowed")) {
AIRTIME.button.enableButton("icon-ban-circle", true); canCancel = true;
}
else if ($current.length !== 0 && (userType === 'A' || userType === 'P')) {
canCancel = true;
}
if (canCancel === true) {
AIRTIME.button.enableButton("icon-ban-circle", true);
} }
else { else {
AIRTIME.button.disableButton("icon-ban-circle", true); AIRTIME.button.disableButton("icon-ban-circle", true);
} }
}; };

View File

@ -112,6 +112,7 @@ CREATE TABLE cc_webstream (
creator_id integer NOT NULL, creator_id integer NOT NULL,
mtime timestamp(6) without time zone NOT NULL, mtime timestamp(6) without time zone NOT NULL,
utime timestamp(6) without time zone NOT NULL, utime timestamp(6) without time zone NOT NULL,
lptime timestamp(6) without time zone,
mime character varying(255) mime character varying(255)
); );
@ -124,10 +125,13 @@ CREATE TABLE cc_webstream_metadata (
ALTER TABLE cc_files ALTER TABLE cc_files
DROP COLUMN gunid, DROP COLUMN gunid,
ADD COLUMN replay_gain character varying(16), ADD COLUMN replay_gain numeric,
ADD COLUMN owner_id integer, ADD COLUMN owner_id integer,
ALTER COLUMN bpm TYPE integer using airtime_to_int(bpm) /* TYPE change - table: cc_files original: character varying(8) new: integer */; ALTER COLUMN bpm TYPE integer using airtime_to_int(bpm) /* TYPE change - table: cc_files original: character varying(8) new: integer */;
ALTER TABLE cc_files
ADD CONSTRAINT cc_files_owner_fkey FOREIGN KEY (owner_id) REFERENCES cc_subjs(id);
ALTER TABLE cc_playlistcontents ALTER TABLE cc_playlistcontents
ADD COLUMN block_id integer, ADD COLUMN block_id integer,
ADD COLUMN stream_id integer, ADD COLUMN stream_id integer,

View File

@ -35,23 +35,21 @@ get_include_path(),
realpath($CC_CONFIG['phpDir'] . '/library') realpath($CC_CONFIG['phpDir'] . '/library')
))); )));
function __autoload($classname){ function my_autoload($classname){
global $CC_CONFIG; global $CC_CONFIG;
$info = explode('_', $classname); $info = explode('_', $classname);
if (isset($info[2])) { if (isset($info[1]) && isset($info[2])) {
$filename = $info[2].".php"; $filename = $info[2].".php";
require_once($CC_CONFIG['phpDir'].'/application/models/'.$filename); if ($info[1] == "Model") {
$folderName = "models";
} else if ($info[1] == "Common") {
$folderName = "common";
}
require_once($CC_CONFIG['phpDir'].'/application/'.$folderName.'/'.$filename);
} }
} }
require_once($CC_CONFIG['phpDir'].'/application/models/User.php');
require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php'); spl_autoload_register('my_autoload');
require_once($CC_CONFIG['phpDir'].'/application/models/Playlist.php');
require_once($CC_CONFIG['phpDir'].'/application/models/Schedule.php');
require_once($CC_CONFIG['phpDir'].'/application/models/Show.php');
require_once($CC_CONFIG['phpDir'].'/application/models/ShowInstance.php');
require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php');
require_once($CC_CONFIG['phpDir'].'/application/models/StreamSetting.php');
require_once($CC_CONFIG['phpDir'].'/application/models/LiveLog.php');
require_once 'propel/runtime/lib/Propel.php'; require_once 'propel/runtime/lib/Propel.php';
Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf-production.php"); Propel::init($CC_CONFIG['phpDir']."/application/configs/airtime-conf-production.php");
@ -64,20 +62,7 @@ if (file_exists('/usr/share/php/libzend-framework-php')){
require_once('Zend/Loader/Autoloader.php'); require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader = Zend_Loader_Autoloader::getInstance();
try { $infoArray = Application_Model_Preference::GetSystemInfo(true);
$opts = new Zend_Console_Getopt(
array(
'test|t' => "Keep broadcast log data\n"
)
);
$opts->parse();
}
catch (Zend_Console_Getopt_Exception $e) {
print $e->getMessage() .PHP_EOL;
exit(1);
}
$infoArray = Application_Model_Preference::GetSystemInfo(true, isset($opts->t));
if(Application_Model_Preference::GetSupportFeedback() == '1'){ if(Application_Model_Preference::GetSupportFeedback() == '1'){
$url = 'http://stat.sourcefabric.org/index.php?p=airtime'; $url = 'http://stat.sourcefabric.org/index.php?p=airtime';