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

This commit is contained in:
denise 2012-09-11 17:19:12 -04:00
commit c6ab540120
6 changed files with 36 additions and 27 deletions

View file

@ -454,6 +454,8 @@ class ApiController extends Zend_Controller_Action
$showCanceled = true;
}
// TODO : the following is inefficient because it calls save on both
// fields
$file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder");
$file->setMetadataValue('MDATA_KEY_TRACKNUMBER', $show_instance_id);
@ -513,11 +515,11 @@ class ApiController extends Zend_Controller_Action
$file->setMetadata($md);
}
} elseif ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5'];
$file = Application_Model_StoredFile::RecallByMd5($md5);
$file = Application_Model_StoredFile::RecallByFilepath(
$md['MDATA_KEY_ORIGINAL_PATH']);
if (is_null($file)) {
return "File doesn't exist in Airtime.";
$return_hash['error'] = 'File does not exist in Airtime';
} else {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
@ -661,6 +663,7 @@ class ApiController extends Zend_Controller_Action
}
} elseif ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5'];
Logging::info("Original path: {$md['MDATA_KEY_ORIGINAL_PATH']}");
$file = Application_Model_StoredFile::RecallByMd5($md5);
if (is_null($file)) {

View file

@ -226,6 +226,7 @@ class Application_Model_StoredFile
return;
}
if (isset($this->_dbMD[$p_category])) {
// TODO : fix this crust -- RG
$propelColumn = $this->_dbMD[$p_category];
$method = "set$propelColumn";
$this->_file->$method($p_value);
@ -315,12 +316,13 @@ class Application_Model_StoredFile
*/
public function getPlaylists()
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = "SELECT playlist_id "
." FROM cc_playlist"
." WHERE file_id = :file_id";
$sql = <<<SQL
SELECT playlist_id
FROM cc_playlist
WHERE file_id = :file_id
SQL;
$stmt = $con->prepare($sql);
$stmt->bindParam(':file_id', $this->id, PDO::PARAM_INT);
@ -332,14 +334,13 @@ class Application_Model_StoredFile
throw new Exception("Error: $msg");
}
$playlists = array();
if (is_array($ids) && count($ids) > 0) {
foreach ($ids as $id) {
$playlists[] = Application_Model_Playlist::Recall($id);
}
return array_map( function ($id) {
return Application_Model_Playlist::Recall($id);
}, $ids);
} else {
return array();
}
return $playlists;
}
/**
@ -593,7 +594,6 @@ class Application_Model_StoredFile
public function getName()
{
$info = pathinfo($this->getFilePath());
return $info['filename'];
}
@ -1024,11 +1024,8 @@ class Application_Model_StoredFile
public static function getFileCount()
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = "SELECT count(*) as cnt FROM cc_files WHERE file_exists";
return $con->query($sql)->fetchColumn(0);
}
@ -1101,10 +1098,14 @@ class Application_Model_StoredFile
try {
$con = Propel::getConnection();
$sql = "SELECT soundcloud_id as id, soundcloud_upload_time"
." FROM CC_FILES"
." WHERE (id != -2 and id != -3) and"
." (soundcloud_upload_time >= (now() - (INTERVAL '1 day')))";
$sql = <<<SQL
SELECT soundcloud_id AS id,
soundcloud_upload_time
FROM CC_FILES
WHERE (id != -2
AND id != -3)
AND (soundcloud_upload_time >= (now() - (INTERVAL '1 day')))
SQL;
$rows = $con->query($sql)->fetchAll();

View file

@ -46,7 +46,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
$di = new DateInterval("PT{$hours}H{$min}M{$sec}S");
return $di->format("%Hh %Im");
}
}
return "";
}