Apparently we do need the StationPrefs group. Since the group name was

hard-coded in everywhere, I didnt detect that this value was used in the app.
I changed the hard-coded values to use the value from the config file instead.

Fixed the Transport.php::xmlrpcCall() function, an object was not being
created before it was used.

Fixed the archive server URLs in the default config files.
This commit is contained in:
paul.baranowski 2010-09-10 15:49:35 -04:00
parent 73d672b552
commit e537255e27
13 changed files with 115 additions and 105 deletions

View file

@ -311,17 +311,18 @@ class uiBase
*/ */
public function loadStationPrefs(&$mask, $reload=FALSE) public function loadStationPrefs(&$mask, $reload=FALSE)
{ {
global $CC_CONFIG;
if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) { if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) {
$this->STATIONPREFS = array(); $this->STATIONPREFS = array();
foreach ($mask as $key => $val) { foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
$setting = $this->gb->loadGroupPref(NULL, 'StationPrefs', $val['element']); $setting = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $val['element']);
if (is_string($setting)) { if (is_string($setting)) {
$this->STATIONPREFS[$val['element']] = $setting; $this->STATIONPREFS[$val['element']] = $setting;
} elseif ($val['required']) { } elseif ($val['required']) {
// set default values on first login // set default values on first login
$default = isset($val['default'])?$val['default']:null; $default = isset($val['default'])?$val['default']:null;
$this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $default); $this->gb->saveGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $default);
$this->STATIONPREFS[$val['element']] = $default; $this->STATIONPREFS[$val['element']] = $default;
} }
} }

View file

@ -296,10 +296,11 @@ class uiBrowser extends uiBase {
function changeStationPrefs(&$mask) function changeStationPrefs(&$mask)
{ {
global $CC_CONFIG;
$form = new HTML_QuickForm('changeStationPrefs', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('changeStationPrefs', UI_STANDARD_FORM_METHOD, UI_HANDLER);
foreach($mask as $key => $val) { foreach($mask as $key => $val) {
$element = isset($val['element']) ? $val['element'] : null; $element = isset($val['element']) ? $val['element'] : null;
$p = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', $element); $p = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $element);
if (is_string($p)) { if (is_string($p)) {
$mask[$key]['default'] = $p; $mask[$key]['default'] = $p;
} }

View file

@ -696,6 +696,7 @@ class uiHandler extends uiBase {
*/ */
function changeStationPrefs($formdata, $mask) function changeStationPrefs($formdata, $mask)
{ {
global $CC_CONFIG;
$this->redirUrl = UI_BROWSER; $this->redirUrl = UI_BROWSER;
if ($this->_validateForm($formdata, $mask) == FALSE) { if ($this->_validateForm($formdata, $mask) == FALSE) {
@ -705,18 +706,18 @@ class uiHandler extends uiBase {
foreach ($mask as $key => $val) { foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
if (!empty($formdata[$val['element']])) { if (!empty($formdata[$val['element']])) {
$result = $this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]); $result = $this->gb->saveGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $formdata[$val['element']]);
if (PEAR::isError($result)) if (PEAR::isError($result))
$this->_retMsg('Error while saving settings.'); $this->_retMsg('Error while saving settings.');
} else { } else {
$this->gb->delGroupPref($this->sessid, 'StationPrefs', $val['element']); $this->gb->delGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element']);
} }
} }
if (isset($val['type']) if (isset($val['type'])
&& ($val['type'] == 'file') && ($val['type'] == 'file')
&& ($val['element'] == "stationlogo") && ($val['element'] == "stationlogo")
&& !empty($formdata[$val['element']]['name'])) { && !empty($formdata[$val['element']]['name'])) {
$stationLogoPath = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', 'stationLogoPath'); $stationLogoPath = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], 'stationLogoPath');
$filePath = $formdata[$val['element']]['tmp_name']; $filePath = $formdata[$val['element']]['tmp_name'];
if (function_exists("getimagesize")) { if (function_exists("getimagesize")) {
$size = @getimagesize($filePath); $size = @getimagesize($filePath);

View file

@ -214,12 +214,13 @@ class uiTwitter {
private function loadSettings() private function loadSettings()
{ {
global $CC_CONFIG;
$mask = uiTwitter::getSettingFormMask(); $mask = uiTwitter::getSettingFormMask();
foreach($mask as $key => $val) { foreach($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
$element = preg_replace('/^twitter-/', '', $val['element'], 1); $element = preg_replace('/^twitter-/', '', $val['element'], 1);
$p = $this->Base->gb->loadGroupPref($this->Base->sessid, 'StationPrefs', $val['element']); $p = $this->Base->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $val['element']);
if (is_string($p)) { if (is_string($p)) {
$this->settings[$element] = $p; $this->settings[$element] = $p;
} }
@ -249,6 +250,7 @@ class uiTwitter {
public function saveSettings() public function saveSettings()
{ {
global $CC_CONFIG;
if ($this->Base->_validateForm($_REQUEST, uiTwitter::getSettingFormMask()) !== TRUE) { if ($this->Base->_validateForm($_REQUEST, uiTwitter::getSettingFormMask()) !== TRUE) {
$this->Base->_retMsg('An error has occured on validating the form.'); $this->Base->_retMsg('An error has occured on validating the form.');
return FALSE; return FALSE;
@ -262,11 +264,11 @@ class uiTwitter {
foreach ($mask as $key => $val) { foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
if (!empty($formdata[$val['element']])) { if (!empty($formdata[$val['element']])) {
$result = $this->Base->gb->saveGroupPref($this->Base->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]); $result = $this->Base->gb->saveGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $formdata[$val['element']]);
if (PEAR::isError($result)) if (PEAR::isError($result))
$this->Base->_retMsg('Error while saving twitter settings.'); $this->Base->_retMsg('Error while saving twitter settings.');
} elseif (!$val['hiddenPref']) { } elseif (!$val['hiddenPref']) {
$this->Base->gb->delGroupPref($this->Base->sessid, 'StationPrefs', $val['element']); $this->Base->gb->delGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], $val['element']);
} }
} }
} }
@ -372,12 +374,13 @@ class uiTwitter {
public function sendFeed($p_feed) public function sendFeed($p_feed)
{ {
global $CC_CONFIG;
$twitter = new twitter(); $twitter = new twitter();
$twitter->username = $this->settings['login']; $twitter->username = $this->settings['login'];
$twitter->password = $this->settings['password']; $twitter->password = $this->settings['password'];
if ($res = $twitter->update($p_feed)) { if ($res = $twitter->update($p_feed)) {
$this->Base->gb->saveGroupPref($this->Base->sessid, 'StationPrefs', 'twitter-lastupdate', time()); $this->Base->gb->saveGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], 'twitter-lastupdate', time());
return $res; return $res;
} }
return false; return false;
@ -385,7 +388,7 @@ class uiTwitter {
public function needsUpdate() public function needsUpdate()
{ {
if (time() - $this->Base->gb->loadGroupPref($this->Base->sessid, 'StationPrefs', 'twitter-lastupdate') + $this->runtime > $this->settings['interval']) { if (time() - $this->Base->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], 'twitter-lastupdate') + $this->runtime > $this->settings['interval']) {
return true; return true;
} }
return false; return false;

View file

@ -1385,10 +1385,10 @@ class BasicStor {
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']); $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']);
// if (PEAR::isError($res)) { if (PEAR::isError($res)) {
// return $res; return $res;
// } }
// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']); // $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']);
// if (PEAR::isError($res)) { // if (PEAR::isError($res)) {
// return $res; // return $res;
@ -1926,19 +1926,19 @@ class BasicStor {
// } // }
// Add the "Station Preferences" group // Add the "Station Preferences" group
// if (!empty($CC_CONFIG['StationPrefsGr'])) { if (!empty($CC_CONFIG['StationPrefsGr'])) {
// if (!Subjects::GetSubjId('scheduler')) { if (!Subjects::GetSubjId('scheduler')) {
// echo " * Creating group '".$CC_CONFIG['StationPrefsGr']."'..."; echo " * Creating group '".$CC_CONFIG['StationPrefsGr']."'...";
// $stPrefGr = Subjects::AddSubj($CC_CONFIG['StationPrefsGr']); $stPrefGr = Subjects::AddSubj($CC_CONFIG['StationPrefsGr']);
// if (PEAR::isError($stPrefGr)) { if (PEAR::isError($stPrefGr)) {
// return $stPrefGr; return $stPrefGr;
// } }
// Subjects::AddSubjectToGroup('root', $CC_CONFIG['StationPrefsGr']); Subjects::AddSubjectToGroup('root', $CC_CONFIG['StationPrefsGr']);
// echo "done.\n"; echo "done.\n";
// } else { } else {
// echo " * Skipping: group already exists: '".$CC_CONFIG['StationPrefsGr']."'\n"; echo " * Skipping: group already exists: '".$CC_CONFIG['StationPrefsGr']."'\n";
// } }
// } }
// Add the root user if it doesnt exist yet. // Add the root user if it doesnt exist yet.
$rootUid = Subjects::GetSubjId('root'); $rootUid = Subjects::GetSubjId('root');
@ -1974,7 +1974,7 @@ class BasicStor {
} }
// Need to add 'scheduler' to group StationPrefs // Need to add 'scheduler' to group StationPrefs
//Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['StationPrefsGr']); Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['StationPrefsGr']);
} }

View file

@ -1432,10 +1432,10 @@ class GreenBox extends BasicStor {
* @return string * @return string
* preference value * preference value
*/ */
public function loadGroupPref($sessid, $group, $key) public function loadGroupPref($group, $key)
{ {
$pr = new Prefs($this); $pr = new Prefs($this);
$res = $pr->loadGroupPref($sessid, $group, $key); $res = $pr->loadGroupPref($group, $key);
return $res; return $res;
} // fn loadGroupPref } // fn loadGroupPref

View file

@ -132,16 +132,16 @@ class Prefs {
/** /**
* Read group preference record * Read group preference record
* *
* @param string $sessid
* session id
* @param string $group * @param string $group
* group name * group name
* @param string $key * @param string $key
* preference key * preference key
* @param boolean $returnErrorIfKeyNotExists
* If set to true and the key doesnt exist, return a PEAR error.
* @return string * @return string
* preference value * preference value
*/ */
function loadGroupPref($sessid, $group, $key) function loadGroupPref($group, $key, $returnErrorIfKeyNotExists = true)
{ {
// if sessid is would be used here fix Transport::cronCallMethod ! // if sessid is would be used here fix Transport::cronCallMethod !
$subjid = Subjects::GetSubjId($group); $subjid = Subjects::GetSubjId($group);
@ -157,8 +157,12 @@ class Prefs {
return $val; return $val;
} }
if ($val === FALSE) { if ($val === FALSE) {
if ($returnErrorIfKeyNotExists) {
return PEAR::raiseError( return PEAR::raiseError(
"Prefs::loadGroupPref: invalid preference key", GBERR_PREF); "Prefs::loadGroupPref: invalid preference key", GBERR_PREF);
} else {
return '';
}
} }
return $val; return $val;
} }

View file

@ -199,9 +199,9 @@ class Transport
{ {
require_once('Prefs.php'); require_once('Prefs.php');
$pr = new Prefs($this->gb); $pr = new Prefs($this->gb);
$group = 'StationPrefs'; $group = $CC_CONFIG['StationPrefsGr'];
$key = 'TransportsDenied'; $key = 'TransportsDenied';
$res = $pr->loadGroupPref($sessid, $group, $key); $res = $pr->loadGroupPref($group, $key);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
if ($res->getCode() !== GBERR_PREF) { if ($res->getCode() !== GBERR_PREF) {
return $res; return $res;
@ -863,6 +863,7 @@ class Transport
*/ */
function cronCallMethod($trtok) function cronCallMethod($trtok)
{ {
global $CC_CONFIG;
$trec = TransportRecord::recall($this, $trtok); $trec = TransportRecord::recall($this, $trtok);
if (PEAR::isError($trec)) { if (PEAR::isError($trec)) {
return $trec; return $trec;
@ -903,9 +904,9 @@ class Transport
case 'waiting': case 'waiting':
require_once('Prefs.php'); require_once('Prefs.php');
$pr = new Prefs($this->gb); $pr = new Prefs($this->gb);
$group = 'StationPrefs'; $group = $CC_CONFIG['StationPrefsGr'];
$key = 'TransportsDenied'; $key = 'TransportsDenied';
$res = $pr->loadGroupPref(NULL/*sessid*/, $group, $key); $res = $pr->loadGroupPref($group, $key);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
if ($res->getCode() !== GBERR_PREF) { if ($res->getCode() !== GBERR_PREF) {
return $res; return $res;
@ -1669,22 +1670,21 @@ class Transport
global $CC_CONFIG; global $CC_CONFIG;
$xrp = XML_RPC_encode($pars); $xrp = XML_RPC_encode($pars);
$group = 'StationPrefs'; $pr = new Prefs($this->gb);
$group = $CC_CONFIG["StationPrefsGr"];
$key = 'archiveServerLocation'; $key = 'archiveServerLocation';
$archiveUrl = $pr->loadGroupPref(NULL/*sessid*/, $group, $key); $archiveUrl = $pr->loadGroupPref($group, $key, false);
if($archiveUrl){
echo "Archive URL: $archiveUrl\n";
if ($archiveUrl) {
$archiveUrlInfo = parse_url($archiveUrl); $archiveUrlInfo = parse_url($archiveUrl);
if ($archiveUrlInfo['port']) {
if($archiveUrlInfo['port']){
$port = $archiveUrlInfo['port']; $port = $archiveUrlInfo['port'];
} }
else { else {
$port = 80; $port = 80;
} }
$c = new XML_RPC_Client($archiveUrlInfo['path'], $archiveUrlInfo['host'], $port); $c = new XML_RPC_Client($archiveUrlInfo['path'], $archiveUrlInfo['host'], $port);
} }
else { else {

View file

@ -47,7 +47,7 @@ $CC_CONFIG = array(
/* ================================================ storage configuration */ /* ================================================ storage configuration */
'authCookieName'=> 'campcaster_session_id', 'authCookieName'=> 'campcaster_session_id',
//'AdminsGr' => 'Admins', //'AdminsGr' => 'Admins',
//'StationPrefsGr'=> 'StationPrefs', 'StationPrefsGr'=> 'StationPrefs',
//'AllGr' => 'All', //'AllGr' => 'All',
'TrashName' => 'trash_', 'TrashName' => 'trash_',
'storageDir' => dirname(__FILE__).'/../../storageServer/var/stor', 'storageDir' => dirname(__FILE__).'/../../storageServer/var/stor',
@ -129,7 +129,7 @@ $CC_CONFIG['backupTable'] = $CC_CONFIG['tblNamePrefix'].'backup';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['tblNamePrefix']."file_id_seq"; $CC_CONFIG['filesSequence'] = $CC_CONFIG['tblNamePrefix']."file_id_seq";
$CC_CONFIG['sysSubjs'] = array( $CC_CONFIG['sysSubjs'] = array(
'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ /*$CC_CONFIG['StationPrefsGr']*/ 'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ $CC_CONFIG['StationPrefsGr']
); );
$old_include_path = get_include_path(); $old_include_path = get_include_path();
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_include_path); set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_include_path);

View file

@ -70,8 +70,8 @@ $CC_CONFIG = array(
'storageUrlPort' => ls_php_port, 'storageUrlPort' => ls_php_port,
/* ================================================ archive configuration */ /* ================================================ archive configuration */
'archiveUrlPath' => 'ls_archiveUrlPath', 'archiveUrlPath' => 'ls_storageUrlPath',
'archiveXMLRPC' => 'xmlrpc/xrArchive.php', 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
'archiveUrlHost' => 'ls_php_host', 'archiveUrlHost' => 'ls_php_host',
'archiveUrlPort' => ls_php_port, 'archiveUrlPort' => ls_php_port,
'archiveAccountLogin' => 'root', 'archiveAccountLogin' => 'root',

View file

@ -43,8 +43,8 @@ $CC_CONFIG = array(
'storageUrlPort' => ls_php_port, 'storageUrlPort' => ls_php_port,
/* ================================================ archive configuration */ /* ================================================ archive configuration */
'archiveUrlPath' => 'ls_archiveUrlPath', 'archiveUrlPath' => 'ls_storageUrlPath',
'archiveXMLRPC' => 'xmlrpc/xrArchive.php', 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
'archiveUrlHost' => 'ls_php_host', 'archiveUrlHost' => 'ls_php_host',
'archiveUrlPort' => ls_php_port, 'archiveUrlPort' => ls_php_port,
'archiveAccountLogin' => 'root', 'archiveAccountLogin' => 'root',

View file

@ -412,7 +412,7 @@ if (!camp_db_table_exists($CC_CONFIG['prefTable'])) {
camp_install_query($sql); camp_install_query($sql);
echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."..."; echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."...";
//$stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']); $stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
Prefs::Insert($CC_CONFIG["systemPrefId"], 'stationName', "Radio Station 1"); Prefs::Insert($CC_CONFIG["systemPrefId"], 'stationName', "Radio Station 1");
$genres = file_get_contents( dirname(__FILE__).'/../genres.xml'); $genres = file_get_contents( dirname(__FILE__).'/../genres.xml');
Prefs::Insert($CC_CONFIG["systemPrefId"], 'genres', $genres); Prefs::Insert($CC_CONFIG["systemPrefId"], 'genres', $genres);

View file

@ -2742,7 +2742,7 @@ class XR_LocStor extends LocStor {
} }
require_once(dirname(__FILE__).'/../Prefs.php'); require_once(dirname(__FILE__).'/../Prefs.php');
$pr = new Prefs($this); $pr = new Prefs($this);
$res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']); $res = $pr->loadGroupPref($r['group'], $r['key']);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
$ec = ( $ec = (