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

This commit is contained in:
Naomi Aro 2012-04-25 12:51:00 +02:00
commit 7aeddf5bb0
15 changed files with 122 additions and 60 deletions

View file

@ -140,18 +140,26 @@ class Application_Model_Playlist {
/**
* Get the entire playlist as a two dimentional array, sorted in order of play.
* @param boolean $filterFiles if this is true, it will only return files that has
* file_exists flag set to true
* @return array
*/
public function getContents() {
public function getContents($filterFiles=false) {
Logging::log("Getting contents for playlist {$this->id}");
$files = array();
$rows = CcPlaylistcontentsQuery::create()
->joinWith('CcFiles')
->orderByDbPosition()
->filterByDbPlaylistId($this->id)
->find($this->con);
$query = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id);
if($filterFiles){
$query->useCcFilesQuery()
->filterByDbFileExists(true)
->endUse();
}
$query->orderByDbPosition()
->leftJoinWith('CcFiles');
$rows = $query->find($this->con);
$i = 0;
$offset = 0;

View file

@ -557,15 +557,15 @@ class Application_Model_Show {
$con->exec($sql);
}
/**
* Get the start date of the current show in UTC timezone.
*
* @return string
* The start date in the format YYYY-MM-DD
*/
public function getStartDate(){
$con = Propel::getConnection();
public function getStartDateAndTime(){
$con = Propel::getConnection();
$showId = $this->getId();
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
@ -583,10 +583,21 @@ class Application_Model_Show {
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
$dt->setTimezone(new DateTimeZone("UTC"));
return $dt->format("Y-m-d");
return $dt->format("Y-m-d H:i");
}
}
/**
* Get the start date of the current show in UTC timezone.
*
* @return string
* The start date in the format YYYY-MM-DD
*/
public function getStartDate(){
list($date,) = explode(" ", $this->getStartDateAndTime());
return $date;
}
/**
* Get the start time of the current show in UTC timezone.
*
@ -595,25 +606,8 @@ class Application_Model_Show {
*/
public function getStartTime(){
$con = Propel::getConnection();
$showId = $this->getId();
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
." WHERE show_id = $showId"
." ORDER BY first_show"
." LIMIT 1";
$query = $con->query($sql);
if ($query->rowCount() == 0){
return "";
} else {
$rows = $query->fetchAll();
$row = $rows[0];
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
$dt->setTimezone(new DateTimeZone("UTC"));
return $dt->format("H:i");
}
list(,$time) = explode(" ", $this->getStartDateAndTime());
return $time;
}
/**
@ -856,8 +850,8 @@ class Application_Model_Show {
." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
." AND show_id = $showId";
$query = $con->query();
$row = $query ? $query->fetchColumn(0) : null;
$query = $con->query($sql);
$row = ($query !== false) ? $query->fetchColumn(0) : null;
return CcShowInstancesQuery::create()
->findPk($row);
}

View file

@ -224,7 +224,7 @@ class Application_Model_ShowBuilder {
$this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row);
$row["id"] = intval($p_item["sched_id"]);
$row["image"] = $p_item["file_exists"] == "t" ? true : false;
$row["image"] = $p_item["file_exists"];
$row["instance"] = intval($p_item["si_id"]);
$row["starts"] = $schedStartDT->format("H:i:s");
$row["ends"] = $schedEndDT->format("H:i:s");

View file

@ -841,8 +841,7 @@ Logging::log("getting media! - 2");
//check to see if there is enough space in $stor to continue.
$enough_space = Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file);
if ($enough_space){
$stor .= "/organize";
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
$audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
Logging::log("copyFileToStor: moving file $audio_file to $audio_stor");
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation