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)
{
global $CC_CONFIG;
if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) {
$this->STATIONPREFS = array();
foreach ($mask as $key => $val) {
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)) {
$this->STATIONPREFS[$val['element']] = $setting;
} elseif ($val['required']) {
// set default values on first login
$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;
}
}

View File

@ -296,10 +296,11 @@ class uiBrowser extends uiBase {
function changeStationPrefs(&$mask)
{
global $CC_CONFIG;
$form = new HTML_QuickForm('changeStationPrefs', UI_STANDARD_FORM_METHOD, UI_HANDLER);
foreach($mask as $key => $val) {
$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)) {
$mask[$key]['default'] = $p;
}

View File

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

View File

@ -214,12 +214,13 @@ class uiTwitter {
private function loadSettings()
{
global $CC_CONFIG;
$mask = uiTwitter::getSettingFormMask();
foreach($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) {
$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)) {
$this->settings[$element] = $p;
}
@ -249,6 +250,7 @@ class uiTwitter {
public function saveSettings()
{
global $CC_CONFIG;
if ($this->Base->_validateForm($_REQUEST, uiTwitter::getSettingFormMask()) !== TRUE) {
$this->Base->_retMsg('An error has occured on validating the form.');
return FALSE;
@ -262,11 +264,11 @@ class uiTwitter {
foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) {
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))
$this->Base->_retMsg('Error while saving twitter settings.');
} 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)
{
global $CC_CONFIG;
$twitter = new twitter();
$twitter->username = $this->settings['login'];
$twitter->password = $this->settings['password'];
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 false;
@ -385,7 +388,7 @@ class uiTwitter {
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 false;

View File

@ -1385,10 +1385,10 @@ class BasicStor {
if (PEAR::isError($res)) {
return $res;
}
// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']);
// if (PEAR::isError($res)) {
// return $res;
// }
$res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']);
if (PEAR::isError($res)) {
return $res;
}
// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']);
// if (PEAR::isError($res)) {
// return $res;
@ -1926,19 +1926,19 @@ class BasicStor {
// }
// Add the "Station Preferences" group
// if (!empty($CC_CONFIG['StationPrefsGr'])) {
// if (!Subjects::GetSubjId('scheduler')) {
// echo " * Creating group '".$CC_CONFIG['StationPrefsGr']."'...";
// $stPrefGr = Subjects::AddSubj($CC_CONFIG['StationPrefsGr']);
// if (PEAR::isError($stPrefGr)) {
// return $stPrefGr;
// }
// Subjects::AddSubjectToGroup('root', $CC_CONFIG['StationPrefsGr']);
// echo "done.\n";
// } else {
// echo " * Skipping: group already exists: '".$CC_CONFIG['StationPrefsGr']."'\n";
// }
// }
if (!empty($CC_CONFIG['StationPrefsGr'])) {
if (!Subjects::GetSubjId('scheduler')) {
echo " * Creating group '".$CC_CONFIG['StationPrefsGr']."'...";
$stPrefGr = Subjects::AddSubj($CC_CONFIG['StationPrefsGr']);
if (PEAR::isError($stPrefGr)) {
return $stPrefGr;
}
Subjects::AddSubjectToGroup('root', $CC_CONFIG['StationPrefsGr']);
echo "done.\n";
} else {
echo " * Skipping: group already exists: '".$CC_CONFIG['StationPrefsGr']."'\n";
}
}
// Add the root user if it doesnt exist yet.
$rootUid = Subjects::GetSubjId('root');
@ -1974,7 +1974,7 @@ class BasicStor {
}
// 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
* preference value
*/
public function loadGroupPref($sessid, $group, $key)
public function loadGroupPref($group, $key)
{
$pr = new Prefs($this);
$res = $pr->loadGroupPref($sessid, $group, $key);
$res = $pr->loadGroupPref($group, $key);
return $res;
} // fn loadGroupPref

View File

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

View File

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

View File

@ -47,7 +47,7 @@ $CC_CONFIG = array(
/* ================================================ storage configuration */
'authCookieName'=> 'campcaster_session_id',
//'AdminsGr' => 'Admins',
//'StationPrefsGr'=> 'StationPrefs',
'StationPrefsGr'=> 'StationPrefs',
//'AllGr' => 'All',
'TrashName' => 'trash_',
'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['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();
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,
/* ================================================ archive configuration */
'archiveUrlPath' => 'ls_archiveUrlPath',
'archiveXMLRPC' => 'xmlrpc/xrArchive.php',
'archiveUrlPath' => 'ls_storageUrlPath',
'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
'archiveUrlHost' => 'ls_php_host',
'archiveUrlPort' => ls_php_port,
'archiveAccountLogin' => 'root',

View File

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

View File

@ -412,7 +412,7 @@ if (!camp_db_table_exists($CC_CONFIG['prefTable'])) {
camp_install_query($sql);
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");
$genres = file_get_contents( dirname(__FILE__).'/../genres.xml');
Prefs::Insert($CC_CONFIG["systemPrefId"], 'genres', $genres);

View File

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