Merge branch '2.3.x' into 2.3.x-saas
This commit is contained in:
commit
6f5ffdc1e7
29 changed files with 7386 additions and 95 deletions
|
@ -378,10 +378,8 @@ SQL;
|
|||
$row->setDbCliplength($info["cliplength"]);
|
||||
$row->setDbCuein($info["cuein"]);
|
||||
$row->setDbCueout($info["cueout"]);
|
||||
$info["fadein"] = Application_Common_DateHelper::secondsToPlaylistTime($info["fadein"]);
|
||||
$info["fadeout"] = Application_Common_DateHelper::secondsToPlaylistTime($info["fadeout"]);
|
||||
$row->setDbFadein($info["fadein"]);
|
||||
$row->setDbFadeout($info["fadeout"]);
|
||||
$row->setDbFadein(Application_Common_DateHelper::secondsToPlaylistTime($info["fadein"]));
|
||||
$row->setDbFadeout(Application_Common_DateHelper::secondsToPlaylistTime($info["fadeout"]));
|
||||
$row->save($this->con);
|
||||
// above save result update on cc_block table on length column.
|
||||
// but $this->block doesn't get updated automatically
|
||||
|
|
|
@ -348,10 +348,8 @@ SQL;
|
|||
$row->setDbCliplength($info["cliplength"]);
|
||||
$row->setDbCuein($info["cuein"]);
|
||||
$row->setDbCueout($info["cueout"]);
|
||||
$info["fadein"] = Application_Common_DateHelper::secondsToPlaylistTime($info["fadein"]);
|
||||
$info["fadeout"] = Application_Common_DateHelper::secondsToPlaylistTime($info["fadeout"]);
|
||||
$row->setDbFadein($info["fadein"]);
|
||||
$row->setDbFadeout($info["fadeout"]);
|
||||
$row->setDbFadein(Application_Common_DateHelper::secondsToPlaylistTime($info["fadein"]));
|
||||
$row->setDbFadeout(Application_Common_DateHelper::secondsToPlaylistTime($info["fadeout"]));
|
||||
if ($info["ftype"] == "audioclip") {
|
||||
$row->setDbFileId($info["id"]);
|
||||
$type = 0;
|
||||
|
|
|
@ -1750,12 +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.
|
||||
|
@ -1763,11 +1766,8 @@ SQL;
|
|||
$options["percent"] = Application_Model_Show::getPercentScheduled($show["starts"], $show["ends"], $show["time_filled"]);
|
||||
}
|
||||
|
||||
$utc = new DateTimeZone("UTC");
|
||||
|
||||
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,39 +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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$showInstance = new Application_Model_ShowInstance(
|
||||
$show["instance_id"]);
|
||||
$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"] = $showInstance->showPartialFilled();
|
||||
|
||||
$events[] = &self::makeFullCalendarEvent($show, $options,
|
||||
$startsDT, $endsDT, $startsEpochStr, $endsEpochStr);
|
||||
$options["show_partial_filled"] = !$isFull[$show['instance_id']];
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -1824,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();
|
||||
|
||||
|
@ -1855,7 +1869,7 @@ SQL;
|
|||
}
|
||||
|
||||
return $event;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* Takes in a UTC DateTime object.
|
||||
* Converts this to local time, since cc_show days
|
||||
|
@ -2162,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -661,10 +661,8 @@ SQL;
|
|||
return $returnStr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getContentCount($p_start, $p_end)
|
||||
{
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT instance_id,
|
||||
count(*) AS instance_count
|
||||
|
@ -687,20 +685,26 @@ SQL;
|
|||
|
||||
}
|
||||
|
||||
public function showPartialFilled()
|
||||
public static function getIsFull($p_start, $p_end)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT time_filled > '00:00:00'
|
||||
AND time_filled < ends - starts
|
||||
AND file_id IS null AS partial_filled
|
||||
FROM cc_show_instances
|
||||
WHERE id = :instance_id
|
||||
SELECT id, ends-starts-'00:00:05' < time_filled as filled
|
||||
from cc_show_instances
|
||||
WHERE ends > :p_start::TIMESTAMP
|
||||
AND starts < :p_end::TIMESTAMP
|
||||
SQL;
|
||||
|
||||
$res = Application_Common_Database::prepareAndExecute($sql,
|
||||
array(':instance_id' => $this->_instanceId), 'all');
|
||||
$res = Application_Common_Database::prepareAndExecute($sql, array(
|
||||
':p_start' => $p_start->format("Y-m-d G:i:s"),
|
||||
':p_end' => $p_end->format("Y-m-d G:i:s"))
|
||||
, 'all');
|
||||
|
||||
return $res[0]["partial_filled"];
|
||||
$isFilled = array();
|
||||
foreach ($res as $r) {
|
||||
$isFilled[$r['id']] = $r['filled'];
|
||||
}
|
||||
|
||||
return $isFilled;
|
||||
}
|
||||
|
||||
public function showEmpty()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue