Merge branch 'saas-dev-publishing' into saas-dev-publishing-schema-change

Conflicts:
	airtime_mvc/application/models/airtime/Podcast.php
This commit is contained in:
drigato 2015-10-14 11:04:41 -04:00
commit c166b4f00e
37 changed files with 540 additions and 277 deletions

View file

@ -138,7 +138,13 @@ class Application_Model_Preference
$st->execute();
}
private static function getValue($key, $isUserValue = false)
/**
* @param string $key the preference key string
* @param bool|false $isUserValue select the preference for the current user
* @param bool|false $forceDefault only look for default (no user ID) values
* @return mixed the preference value
*/
private static function getValue($key, $isUserValue = false, $forceDefault = false)
{
$cache = new Cache();
@ -164,6 +170,8 @@ class Application_Model_Preference
if ($isUserValue) {
$sql .= " AND subjid = :id";
$paramMap[':id'] = $userId;
} else if ($forceDefault) {
$sql .= " AND subjid IS NULL";
}
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, Application_Common_Database::COLUMN);
@ -1478,4 +1486,20 @@ class Application_Model_Preference
{
self::setValue("lang_tz_setup_complete", $value);
}
public static function getWhatsNewDialogViewed()
{
$val = self::getValue("whats_new_dialog_viewed", true);
if (empty($val)) {
// Check the default (no user ID) value if the user value is empty
// This is so that new stations won't see the popup
$val = self::getValue("whats_new_dialog_viewed", false, true);
}
return empty($val) ? false : $val;
}
public static function setWhatsNewDialogViewed($value)
{
self::setValue("whats_new_dialog_viewed", $value, true);
}
}

View file

@ -1035,7 +1035,11 @@ SQL;
self::createStreamScheduleEvent($data, $item, $media_id, $uri);
}
else {
throw new Exception("Unknown schedule type: ".print_r($item, true));
//throw new Exception("Unknown schedule type: ".print_r($item, true));
//It's currently possible (and normal) to get cc_schedule rows without
//a file_id or stream_id. If you're using linked shows, placeholder rows can be put
//in the schedule when you cancel a track or delete stuff, so we should not throw an exception
//here and instead just ignore it.
}
}

View file

@ -80,7 +80,7 @@ class Application_Model_Scheduler
*
* @param array $items, an array containing pks of cc_schedule items.
*/
private function validateRequest($items, $addAction=false)
private function validateRequest($items, $addRemoveAction=false)
{
//$items is where tracks get inserted (they are schedule locations)
@ -164,7 +164,7 @@ class Application_Model_Scheduler
* currently playing?
* If yes, throw an exception
*/
if ($addAction) {
if ($addRemoveAction) {
$ccShow = $instance->getCcShow();
if ($ccShow->isLinked()) {
//get all the linked shows instances and check if
@ -175,7 +175,7 @@ class Application_Model_Scheduler
if ($ccShowInstance->getDbStarts() <= $timeNowUTC &&
$ccShowInstance->getDbEnds() > $timeNowUTC) {
throw new Exception(_("Content in linked shows must be scheduled before or after any one is broadcasted"));
throw new Exception(_("Content in linked shows cannot be changed while on air!"));
}
}
}
@ -1091,7 +1091,7 @@ class Application_Model_Scheduler
try {
$this->validateRequest($scheduledItems);
$this->validateRequest($scheduledItems, true);
$scheduledIds = array();
foreach ($scheduledItems as $item) {

View file

@ -1044,17 +1044,31 @@ SQL;
$event["nowPlaying"] = false;
}
//event colouring
if ($show["color"] != "") {
$event["textColor"] = "#".$show["color"];
}
if (!empty($show["background_color"])) {
$event["color"] = "#" . $show["background_color"];
} else {
$event["color"] = "#" . self::getDefaultBackgroundColor($startsDT);//DEFAULT_SHOW_COLOR;
}
//event colouring
if ($show["color"] != "") {
$event["textColor"] = "#".$show["color"];
} else {
$bg = $event["color"];
//Calculate the text colour (black or white) based on the brightness of the background.
$r = intval(substr($bg, 1, 2), 16);
$g = intval(substr($bg, 3, 2), 16);
$b = intval(substr($bg, 5, 2), 16);
$brightness = 0.299*floatval($r) + 0.587*floatval($g) + 0.114*floatval($b);
if ($brightness > 130) {
$event["textColor"] = "#000000";
} else {
$event["textColor"] = "#fcfcfc";
}
}
foreach ($options as $key => $value) {
$event[$key] = $value;
}
@ -1067,12 +1081,33 @@ SQL;
/** Get a palettized colour for the show. */
private static function getDefaultBackgroundColor($date) {
$basePalette = ['A22BE8', '2FFF8D', 'FF743C', '2ED4FF', 'E8D82B'];
// 'B23F11', 'FF7E4A', 'FF6C31'
/*
$palette = [['42d5a1', '56bd99', '65ab93', '7b938b'],
['42a4d5', '569bbd', '6594ab', '7b8b93'],
['4264d5', '566fbd', '6576ab', '7b8193']];
*/
$palette = [];
for ($baseColorIdx = 0; $baseColorIdx < count($basePalette); $baseColorIdx++) {
$dayPalette = [];
for ($shade = 0.0; $shade < 0.8; $shade += 0.1) {
$origColour = $basePalette[$baseColorIdx];
$r = intval(substr($origColour, 0, 2), 16);
$g = intval(substr($origColour, 2, 2), 16);
$b = intval(substr($origColour, 4, 2), 16);
$r = floatval($r) * (1.0 - $shade);
$g = floatval($g) * (1.0 - $shade);
$b = floatval($b) * (1.0 - $shade);
$color = sprintf("%02x%02x%02x", $r, $g, $b);
array_push($dayPalette, $color);
}
array_push($palette, $dayPalette);
}
//$hashValue = (md5($date->format('d'))[0] % $cols) + ((intval($date->format('h'))/24) % $rows);
$row = intval($date->format('d')) % sizeof($palette);
$row = intval($date->format('w')) % sizeof($palette);
$foo = $date->format('H');
$col = intval(intval($date->format('H'))/24.0 * sizeof($palette[0]));
//$color = $palette[$hashValue % sizeof($palette)];