CC-4384: Remove annoying usage of $CC_CONFIG
- done
This commit is contained in:
parent
55fa8b8dc1
commit
dcf3526000
6 changed files with 17 additions and 58 deletions
|
@ -24,30 +24,6 @@ $CC_CONFIG = array(
|
||||||
$configFile = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
$configFile = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
||||||
Config::loadConfig($configFile);
|
Config::loadConfig($configFile);
|
||||||
|
|
||||||
// Add database table names
|
|
||||||
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
|
|
||||||
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
|
|
||||||
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
|
||||||
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
|
||||||
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
|
||||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
|
||||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
|
||||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
|
||||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
|
||||||
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
|
|
||||||
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
|
|
||||||
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
|
|
||||||
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
|
|
||||||
$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show';
|
|
||||||
$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';
|
|
||||||
|
|
||||||
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
|
|
||||||
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
|
|
||||||
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
|
|
||||||
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
|
|
||||||
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
|
|
||||||
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
|
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
public static function loadConfig($p_path) {
|
public static function loadConfig($p_path) {
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
|
@ -880,8 +880,6 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function contentContextMenuAction()
|
public function contentContextMenuAction()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
|
|
||||||
$id = $this->_getParam('id');
|
$id = $this->_getParam('id');
|
||||||
|
|
||||||
$params = '/format/json/id/#id#/';
|
$params = '/format/json/id/#id#/';
|
||||||
|
@ -923,8 +921,6 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function calculateDurationAction()
|
public function calculateDurationAction()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
|
|
||||||
$startParam = $this->_getParam('startTime');
|
$startParam = $this->_getParam('startTime');
|
||||||
$endParam = $this->_getParam('endTime');
|
$endParam = $this->_getParam('endTime');
|
||||||
|
|
||||||
|
|
|
@ -940,9 +940,8 @@ SQL;
|
||||||
|
|
||||||
public static function getBlockCount()
|
public static function getBlockCount()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = 'SELECT count(*) as cnt FROM '.$CC_CONFIG["playListTable"];
|
$sql = 'SELECT count(*) as cnt FROM cc_playlist';
|
||||||
|
|
||||||
return $con->query($sql)->fetchColumn(0);
|
return $con->query($sql)->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -869,9 +869,8 @@ SQL;
|
||||||
|
|
||||||
public static function getPlaylistCount()
|
public static function getPlaylistCount()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = 'SELECT count(*) as cnt FROM '.$CC_CONFIG["playListTable"];
|
$sql = 'SELECT count(*) as cnt FROM cc_playlist';
|
||||||
|
|
||||||
return $con->query($sql)->fetchColumn(0);
|
return $con->query($sql)->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,15 +181,14 @@ SQL;
|
||||||
|
|
||||||
public static function GetLastScheduleItem($p_timeNow)
|
public static function GetLastScheduleItem($p_timeNow)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT ft.artist_name,
|
SELECT ft.artist_name,
|
||||||
ft.track_title,
|
ft.track_title,
|
||||||
st.starts AS starts,
|
st.starts AS starts,
|
||||||
st.ends AS ends
|
st.ends AS ends
|
||||||
FROM cc_schedule st
|
FROM cc_schedule st
|
||||||
LEFT JOIN $CC_CONFIG[filesTable] ft ON st.file_id = ft.id
|
LEFT JOIN cc_files ft ON st.file_id = ft.id
|
||||||
LEFT JOIN $CC_CONFIG[showInstances] sit ON st.instance_id = sit.id
|
LEFT JOIN cc_show_instances sit ON st.instance_id = sit.id
|
||||||
-- this and the next line are necessary since we can overbook shows.
|
-- this and the next line are necessary since we can overbook shows.
|
||||||
WHERE st.ends < TIMESTAMP :timeNow
|
WHERE st.ends < TIMESTAMP :timeNow
|
||||||
|
|
||||||
|
@ -204,7 +203,6 @@ SQL;
|
||||||
|
|
||||||
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
/* Note that usually there will be one result returned. In some
|
/* Note that usually there will be one result returned. In some
|
||||||
* rare cases two songs are returned. This happens when a track
|
* rare cases two songs are returned. This happens when a track
|
||||||
* that was overbooked from a previous show appears as if it
|
* that was overbooked from a previous show appears as if it
|
||||||
|
@ -213,8 +211,8 @@ SQL;
|
||||||
* this is the *real* track that is currently playing. So this
|
* this is the *real* track that is currently playing. So this
|
||||||
* is why we are ordering by track start time. */
|
* is why we are ordering by track start time. */
|
||||||
$sql = "SELECT *"
|
$sql = "SELECT *"
|
||||||
." FROM $CC_CONFIG[scheduleTable] st"
|
." FROM cc_schedule st"
|
||||||
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
." LEFT JOIN cc_files ft"
|
||||||
." ON st.file_id = ft.id"
|
." ON st.file_id = ft.id"
|
||||||
." WHERE st.starts <= TIMESTAMP :timeNow1"
|
." WHERE st.starts <= TIMESTAMP :timeNow1"
|
||||||
." AND st.instance_id = :instanceId"
|
." AND st.instance_id = :instanceId"
|
||||||
|
@ -229,14 +227,13 @@ SQL;
|
||||||
|
|
||||||
public static function GetNextScheduleItem($p_timeNow)
|
public static function GetNextScheduleItem($p_timeNow)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$sql = "SELECT"
|
$sql = "SELECT"
|
||||||
." ft.artist_name, ft.track_title,"
|
." ft.artist_name, ft.track_title,"
|
||||||
." st.starts as starts, st.ends as ends"
|
." st.starts as starts, st.ends as ends"
|
||||||
." FROM $CC_CONFIG[scheduleTable] st"
|
." FROM cc_schedule st"
|
||||||
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
." LEFT JOIN cc_files ft"
|
||||||
." ON st.file_id = ft.id"
|
." ON st.file_id = ft.id"
|
||||||
." LEFT JOIN $CC_CONFIG[showInstances] sit"
|
." LEFT JOIN cc_show_instances sit"
|
||||||
." ON st.instance_id = sit.id"
|
." ON st.instance_id = sit.id"
|
||||||
." WHERE st.starts > TIMESTAMP :timeNow"
|
." WHERE st.starts > TIMESTAMP :timeNow"
|
||||||
." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows.
|
." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows.
|
||||||
|
@ -260,7 +257,6 @@ SQL;
|
||||||
*/
|
*/
|
||||||
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
|
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$p_start_str = $p_start->format("Y-m-d H:i:s");
|
$p_start_str = $p_start->format("Y-m-d H:i:s");
|
||||||
|
@ -386,9 +382,8 @@ SQL;
|
||||||
|
|
||||||
public static function UpdateMediaPlayedStatus($p_id)
|
public static function UpdateMediaPlayedStatus($p_id)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
$sql = "UPDATE cc_schedule"
|
||||||
." SET media_item_played=TRUE";
|
." SET media_item_played=TRUE";
|
||||||
// we need to update 'broadcasted' column as well
|
// we need to update 'broadcasted' column as well
|
||||||
// check the current switch status
|
// check the current switch status
|
||||||
|
@ -427,9 +422,8 @@ SQL;
|
||||||
|
|
||||||
public static function getSchduledPlaylistCount()
|
public static function getSchduledPlaylistCount()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['scheduleTable'];
|
$sql = "SELECT count(*) as cnt FROM cc_schedule";
|
||||||
|
|
||||||
return $con->query($sql)->fetchColumn(0);
|
return $con->query($sql)->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
@ -918,15 +912,13 @@ SQL;
|
||||||
|
|
||||||
public static function deleteAll()
|
public static function deleteAll()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$con->exec("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
$con->exec("TRUNCATE TABLE cc_schedule");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteWithFileId($fileId)
|
public static function deleteWithFileId($fileId)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
$sql = "DELETE FROM cc_schedule WHERE file_id=:file_id";
|
||||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]." WHERE file_id=:file_id";
|
|
||||||
Application_Common_Database::prepareAndExecute($sql, array(':file_id'=>$fileId), 'execute');
|
Application_Common_Database::prepareAndExecute($sql, array(':file_id'=>$fileId), 'execute');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,8 @@ class Application_Model_Subjects
|
||||||
|
|
||||||
public static function increaseLoginAttempts($login)
|
public static function increaseLoginAttempts($login)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = login_attempts+1"
|
$sql = "UPDATE cc_subjs SET login_attempts = login_attempts+1"
|
||||||
." WHERE login='$login'";
|
." WHERE login='$login'";
|
||||||
$res = $con->exec($sql);
|
$res = $con->exec($sql);
|
||||||
|
|
||||||
|
@ -31,9 +30,8 @@ class Application_Model_Subjects
|
||||||
|
|
||||||
public static function resetLoginAttempts($login)
|
public static function resetLoginAttempts($login)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'"
|
$sql = "UPDATE cc_subjs SET login_attempts = '0'"
|
||||||
." WHERE login='$login'";
|
." WHERE login='$login'";
|
||||||
$res = $con->exec($sql);
|
$res = $con->exec($sql);
|
||||||
|
|
||||||
|
@ -42,9 +40,8 @@ class Application_Model_Subjects
|
||||||
|
|
||||||
public static function getLoginAttempts($login)
|
public static function getLoginAttempts($login)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT login_attempts FROM ".$CC_CONFIG['subjTable']." WHERE login='$login'";
|
$sql = "SELECT login_attempts FROM cc_subjs WHERE login='$login'";
|
||||||
$res = $con->query($sql)->fetchColumn(0);
|
$res = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
return ($res !== false) ? $res : 0;
|
return ($res !== false) ? $res : 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue