[CS-Project-svn_notify] SF.net SVN: cs-project: [820] trunk/1.2
Brought to you by:
crazedsanity
From: <cra...@us...> - 2008-02-09 21:30:12
|
Revision: 820 http://cs-project.svn.sourceforge.net/cs-project/?rev=820&view=rev Author: crazedsanity Date: 2008-02-09 13:30:08 -0800 (Sat, 09 Feb 2008) Log Message: ----------- Upgrade for 1.2.0-ALPHA3 (config has attributes for displaying admin update). /lib/upgradeClass.php: * update_config_file(): -- retain attributes instead of removing them. /upgrade/upgrade.xml: * update explanation to be slightly less confusing. /upgrade/upgradeTo1.2.0-ALPHA3.php: * run_upgrade(): -- no more transactions. * update_config_file(): -- backup the original config (just in case) -- updates existing config with attributes from sample config -- if the "CONFIG_EMAIL_SERVER_IP" tag exists in the current config and "PHPMAILER_HOST" isn't, use the value of the former for the latter (and remove the former). -- writes-out the updated config file. Modified Paths: -------------- trunk/1.2/lib/upgradeClass.php trunk/1.2/upgrade/upgrade.xml trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA3.php Modified: trunk/1.2/lib/upgradeClass.php =================================================================== --- trunk/1.2/lib/upgradeClass.php 2008-02-09 10:01:10 UTC (rev 819) +++ trunk/1.2/lib/upgradeClass.php 2008-02-09 21:30:08 UTC (rev 820) @@ -631,7 +631,7 @@ $xmlCreator->load_xmlparser_data($xmlParser); //update the given index. - $xmlCreator->add_tag($index, $value); + $xmlCreator->add_tag($index, $value, $xmlParser->get_attribute('/CONFIG/'. strtoupper($index))); $this->mainConfig[strtoupper($index)] = $value; $xmlString = $xmlCreator->create_xml_string(); Modified: trunk/1.2/upgrade/upgrade.xml =================================================================== --- trunk/1.2/upgrade/upgrade.xml 2008-02-09 10:01:10 UTC (rev 819) +++ trunk/1.2/upgrade/upgrade.xml 2008-02-09 21:30:08 UTC (rev 820) @@ -1,8 +1,5 @@ <upgrade> - <system_note>The database and version listed in the config.xml file should - ALWAYS match. - - To determine which section in matching to use, heed only the information + <system_note>To determine which section in matching to use, heed only the information beneath the tag that indicates the current database version (for 5.2.4, you would find information under matching for "v5.2.4"). This section indicates the version that it should upgrade the database to Modified: trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA3.php =================================================================== --- trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA3.php 2008-02-09 10:01:10 UTC (rev 819) +++ trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA3.php 2008-02-09 21:30:08 UTC (rev 820) @@ -27,13 +27,9 @@ //========================================================================= public function run_upgrade() { - $this->db->beginTrans(__METHOD__); - $this->update_config_file(); - exit; - $this->db->commitTrans(__METHOD__); - + return('Upgrade complete'); }//end run_upgrade() //========================================================================= @@ -48,25 +44,41 @@ $updateXml = new xmlCreator(); $updateXml->load_xmlparser_data($siteXmlObj); + + //BACKUP ORIGINAL XML CONFIG... + $backupFile = 'lib/__BACKUP__'. time() .'__config.xml'; + $fs->create_file($backupFile); + $fs->openFile($backupFile); + $fs->write($updateXml->create_xml_string()); + $sampleIndexes = $sampleXmlObj->get_tree(TRUE); $sampleIndexes = $sampleIndexes['CONFIG']; + $siteConfigIndexes = $siteXmlObj->get_tree(TRUE); + $siteConfigIndexes = $siteConfigIndexes['CONFIG']; foreach($sampleIndexes as $indexName=>$indexValue) { $path = '/CONFIG/'. $indexName; $attributes = $sampleXmlObj->get_attribute($path); #debug_print(__METHOD__ .": attributes from sample (/CONFIG/". $indexName ."::: ",1); #debug_print($attributes,1); + debug_print(__METHOD__ .': indexName=('. $indexName .'), indexValue=('. $indexValue .'), original config value=('. $siteConfigIndexes[$indexName] .')'); - if(is_array($attributes)) { - $updateXml->add_attribute($path, $attributes); + //add tag if it's not there, update values otherwise. + $tagValue = $attributes['DEFAULT']; + if(isset($siteConfigIndexes[$indexName])) { + $tagValue = $siteConfigIndexes[$indexName]; } + elseif($indexName == 'PHPMAILER_HOST' && isset($siteConfigIndexes['CONFIG_EMAIL_SERVER_IP'])) { + $tagValue = $siteConfigIndexes['CONFIG_EMAIL_SERVER_IP']; + $updateXml->remove_path('/CONFIG/CONFIG_EMAIL_SERVER_IP'); + } + $updateXml->add_tag($path, $tagValue, $attributes); } - $this->gfObj->debug_print($updateXml->create_xml_string()); - $fs->openFile('lib/_test_config.xml'); + $this->gfObj->debug_print($this->gfObj->cleanString($updateXml->create_xml_string(), 'htmlentity_plus_brackets')); + $fs->openFile('lib/config.xml'); $fs->write($updateXml->create_xml_string()); - exit; }//end update_config_file() //========================================================================= } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |