Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
b4dc17f7e8
|
@ -2,9 +2,11 @@
|
||||||
class Application_Common_Database
|
class Application_Common_Database
|
||||||
{
|
{
|
||||||
public static function prepareAndExecute($sql, array $paramValueMap,
|
public static function prepareAndExecute($sql, array $paramValueMap,
|
||||||
$type='all', $fetchType=PDO::FETCH_ASSOC)
|
$type='all', $fetchType=PDO::FETCH_ASSOC, $con=null)
|
||||||
{
|
{
|
||||||
$con = Propel::getConnection();
|
if (is_null($con)) {
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
}
|
||||||
$stmt = $con->prepare($sql);
|
$stmt = $con->prepare($sql);
|
||||||
foreach ($paramValueMap as $param => $v) {
|
foreach ($paramValueMap as $param => $v) {
|
||||||
$stmt->bindValue($param, $v);
|
$stmt->bindValue($param, $v);
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Application_Model_Block implements Application_Model_LibraryEditable
|
||||||
"cueout" => "00:00:00",
|
"cueout" => "00:00:00",
|
||||||
"fadein" => "0.0",
|
"fadein" => "0.0",
|
||||||
"fadeout" => "0.0",
|
"fadeout" => "0.0",
|
||||||
|
"crossfadeDuration" => 0
|
||||||
);
|
);
|
||||||
|
|
||||||
//using propel's phpNames.
|
//using propel's phpNames.
|
||||||
|
@ -101,6 +102,7 @@ class Application_Model_Block implements Application_Model_LibraryEditable
|
||||||
|
|
||||||
$this->blockItem["fadein"] = Application_Model_Preference::GetDefaultFadeIn();
|
$this->blockItem["fadein"] = Application_Model_Preference::GetDefaultFadeIn();
|
||||||
$this->blockItem["fadeout"] = Application_Model_Preference::GetDefaultFadeOut();
|
$this->blockItem["fadeout"] = Application_Model_Preference::GetDefaultFadeOut();
|
||||||
|
$this->blockItem["crossfadeDuration"] = Application_Model_Preference::GetDefaultCrossfadeDuration();
|
||||||
|
|
||||||
$this->con = isset($con) ? $con : Propel::getConnection(CcBlockPeer::DATABASE_NAME);
|
$this->con = isset($con) ? $con : Propel::getConnection(CcBlockPeer::DATABASE_NAME);
|
||||||
$this->id = $this->block->getDbId();
|
$this->id = $this->block->getDbId();
|
||||||
|
@ -390,6 +392,7 @@ SQL;
|
||||||
$row->setDbCueout($info["cueout"]);
|
$row->setDbCueout($info["cueout"]);
|
||||||
$row->setDbFadein(Application_Common_DateHelper::secondsToPlaylistTime($info["fadein"]));
|
$row->setDbFadein(Application_Common_DateHelper::secondsToPlaylistTime($info["fadein"]));
|
||||||
$row->setDbFadeout(Application_Common_DateHelper::secondsToPlaylistTime($info["fadeout"]));
|
$row->setDbFadeout(Application_Common_DateHelper::secondsToPlaylistTime($info["fadeout"]));
|
||||||
|
$row->setDbTrackOffset($info["crossfadeDuration"]);
|
||||||
$row->save($this->con);
|
$row->save($this->con);
|
||||||
// above save result update on cc_block table on length column.
|
// above save result update on cc_block table on length column.
|
||||||
// but $this->block doesn't get updated automatically
|
// but $this->block doesn't get updated automatically
|
||||||
|
|
|
@ -11,6 +11,9 @@ class Application_Model_Preference
|
||||||
private static function setValue($key, $value, $isUserValue = false, $userId = null)
|
private static function setValue($key, $value, $isUserValue = false, $userId = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$con = Propel::getConnection(CcPrefPeer::DATABASE_NAME);
|
||||||
|
$con->beginTransaction();
|
||||||
|
|
||||||
//called from a daemon process
|
//called from a daemon process
|
||||||
if (!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
if (!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
||||||
$id = NULL;
|
$id = NULL;
|
||||||
|
@ -35,7 +38,11 @@ class Application_Model_Preference
|
||||||
$paramMap[':id'] = $userId;
|
$paramMap[':id'] = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column');
|
$result = Application_Common_Database::prepareAndExecute($sql,
|
||||||
|
$paramMap,
|
||||||
|
'column',
|
||||||
|
PDO::FETCH_ASSOC,
|
||||||
|
$con);
|
||||||
|
|
||||||
$paramMap = array();
|
$paramMap = array();
|
||||||
if ($result > 1) {
|
if ($result > 1) {
|
||||||
|
@ -80,9 +87,15 @@ class Application_Model_Preference
|
||||||
$paramMap[':key'] = $key;
|
$paramMap[':key'] = $key;
|
||||||
$paramMap[':value'] = $value;
|
$paramMap[':value'] = $value;
|
||||||
|
|
||||||
Application_Common_Database::prepareAndExecute($sql, $paramMap, 'execute');
|
Application_Common_Database::prepareAndExecute($sql,
|
||||||
|
$paramMap,
|
||||||
|
'execute',
|
||||||
|
PDO::FETCH_ASSOC,
|
||||||
|
$con);
|
||||||
|
|
||||||
|
$con->commit();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
$con->rollback();
|
||||||
header('HTTP/1.0 503 Service Unavailable');
|
header('HTTP/1.0 503 Service Unavailable');
|
||||||
Logging::info("Database error: ".$e->getMessage());
|
Logging::info("Database error: ".$e->getMessage());
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -82,7 +82,9 @@ AudioPlayout.prototype.loadData = function (audioData, cb) {
|
||||||
that.buffer = buffer;
|
that.buffer = buffer;
|
||||||
cb(buffer);
|
cb(buffer);
|
||||||
},
|
},
|
||||||
Error
|
function(err) {
|
||||||
|
console.log("err(decodeAudioData): "+err);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,57 @@ class AirtimeIni
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//stupid hack found on http://stackoverflow.com/a/1268642/276949
|
||||||
|
//with some modifications: 1) Spaces are inserted in between sections and
|
||||||
|
//2) numeric values are not quoted.
|
||||||
|
public static function write_ini_file($assoc_arr, $path, $has_sections = false) {
|
||||||
|
$content = "";
|
||||||
|
|
||||||
|
if ($has_sections) {
|
||||||
|
$first_line = true;
|
||||||
|
foreach ($assoc_arr as $key=>$elem) {
|
||||||
|
if ($first_line) {
|
||||||
|
$content .= "[".$key."]\n";
|
||||||
|
$first_line = false;
|
||||||
|
} else {
|
||||||
|
$content .= "\n[".$key."]\n";
|
||||||
|
}
|
||||||
|
foreach ($elem as $key2=>$elem2) {
|
||||||
|
if(is_array($elem2))
|
||||||
|
{
|
||||||
|
for($i=0;$i<count($elem2);$i++)
|
||||||
|
{
|
||||||
|
$content .= $key2."[] = \"".$elem2[$i]."\"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($elem2=="") $content .= $key2." = \n";
|
||||||
|
else $content .= $key2." = ".$elem2."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($assoc_arr as $key=>$elem) {
|
||||||
|
if(is_array($elem))
|
||||||
|
{
|
||||||
|
for($i=0;$i<count($elem);$i++)
|
||||||
|
{
|
||||||
|
$content .= $key."[] = \"".$elem[$i]."\"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($elem=="") $content .= $key." = \n";
|
||||||
|
else $content .= $key." = ".$elem."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$handle = fopen($path, 'w')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!fwrite($handle, $content)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After the configuration files have been copied to /etc/airtime,
|
* After the configuration files have been copied to /etc/airtime,
|
||||||
* this function will update them to values unique to this
|
* this function will update them to values unique to this
|
||||||
|
@ -223,10 +274,17 @@ class AirtimeIni
|
||||||
{
|
{
|
||||||
$api_key = AirtimeIni::GenerateRandomString();
|
$api_key = AirtimeIni::GenerateRandomString();
|
||||||
if (getenv("web") == "t"){
|
if (getenv("web") == "t"){
|
||||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'api_key', $api_key);
|
$ini = parse_ini_file(AirtimeIni::CONF_FILE_AIRTIME, true);
|
||||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'airtime_dir', AirtimeInstall::CONF_DIR_WWW);
|
|
||||||
|
$ini['general']['api_key'] = $api_key;
|
||||||
|
$ini['general']['airtime_dir'] = AirtimeInstall::CONF_DIR_WWW;
|
||||||
|
|
||||||
|
AirtimeIni::write_ini_file($ini, AirtimeIni::CONF_FILE_AIRTIME, true);
|
||||||
}
|
}
|
||||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_API_CLIENT, 'api_key', "'$api_key'");
|
|
||||||
|
$ini = parse_ini_file(AirtimeIni::CONF_FILE_API_CLIENT);
|
||||||
|
$ini['api_key'] = "'$api_key'";
|
||||||
|
AirtimeIni::write_ini_file($ini, AirtimeIni::CONF_FILE_API_CLIENT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ReadPythonConfig($p_filename)
|
public static function ReadPythonConfig($p_filename)
|
||||||
|
|
Loading…
Reference in New Issue