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

@ -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;