Thread: [Cs-project-svn_notify] SF.net SVN: cs-project: [651] trunk/upgrade
Brought to you by:
crazedsanity
From: <cra...@us...> - 2007-11-21 16:45:48
|
Revision: 651 http://cs-project.svn.sourceforge.net/cs-project/?rev=651&view=rev Author: crazedsanity Date: 2007-11-21 08:45:44 -0800 (Wed, 21 Nov 2007) Log Message: ----------- Set special tag modifiers (if present), add upgrade script to xml file. Modified Paths: -------------- trunk/upgrade/upgrade.xml trunk/upgrade/upgradeTo1.1.0-BETA14.php Modified: trunk/upgrade/upgrade.xml =================================================================== --- trunk/upgrade/upgrade.xml 2007-11-21 16:44:46 UTC (rev 650) +++ trunk/upgrade/upgrade.xml 2007-11-21 16:45:44 UTC (rev 651) @@ -64,5 +64,11 @@ <class_name>upgrade_to_1_1_0_BETA13</class_name> <call_method>run_upgrade</call_method> </v1.1.0-BETA12> + <v1.1.0-BETA13> + <target_version>1.1.0-BETA14</target_version> + <script_name>upgradeTo1.1.0-BETA14.php</script_name> + <class_name>upgrade_to_1_1_0_BETA14</class_name> + <call_method>run_upgrade</call_method> + </v1.1.0-BETA13> </matching> </upgrade> Modified: trunk/upgrade/upgradeTo1.1.0-BETA14.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA14.php 2007-11-21 16:44:46 UTC (rev 650) +++ trunk/upgrade/upgradeTo1.1.0-BETA14.php 2007-11-21 16:45:44 UTC (rev 651) @@ -33,7 +33,6 @@ $this->run_schema_changes(); $this->update_tag_modifiers(); - $this->db->commitTrans(__METHOD__); }//end run_upgrade() @@ -52,6 +51,61 @@ $this->logsObj->log_by_class($details, 'system'); }//end run_schema_changes() //========================================================================= + + + + //========================================================================= + private function update_tag_modifiers() { + + $sql = "SELECT tag_name_id, name FROM tag_name_table ORDER BY tag_name_id"; + if($this->run_sql($sql) && $this->lastNumrows > 1) { + $allTags = $this->db->farray_nvp('tag_name_id', 'name'); + + $specialModifiers = array( + 'critical' => -5, + 'exception' => -2, + 'invalid data' => -2, + 'authentication' => -1, + 'bug' => -1, + 'cannot fix' => -1, + 'data cleaning' => -1, + 'feature request' => -1, + 'email' => 0, + 'formatting' => 0, + 'has dependencies' => 0, + 'information' => 0, + 'network related' => 0, + 'session' => 0, + 'upgrade' => 1, + 'duplicate' => 2, + 'cannot reproduce' => 3, + ); + + $updates = 0; + foreach($allTags as $id=>$name) { + if(is_numeric($specialModifiers[$name])) { + //change the modifier accordingly... + $sql = "UPDATE tag_name_table SET modifier=". $specialModifiers[$name] ." WHERE tag_name_id=". $id; + if($this->run_sql($sql) && $this->lastNumrows == 1) { + $updates++; + } + else { + throw new exception(__METHOD__ .": failed to update tag (". $name .") with special " . + "modifier (". $specialModifiers[$name] .")"); + } + + // + $details = "Changed modifier of [tag_name_id=". $id ."] to (". $specialModifiers[$name] .")"; + $this->logsObj->log_by_class($details, 'update'); + } + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve tag names"); + } + + }//end update_tag_modifiers() + //========================================================================= } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2007-12-28 01:46:48
|
Revision: 728 http://cs-project.svn.sourceforge.net/cs-project/?rev=728&view=rev Author: crazedsanity Date: 2007-12-27 17:46:46 -0800 (Thu, 27 Dec 2007) Log Message: ----------- Add upgrade to 1.2.0-ALPHA2 script & upgrade XML, remove old scripts. Modified Paths: -------------- trunk/upgrade/upgrade.xml Added Paths: ----------- trunk/upgrade/upgradeTo1.2.0-ALPHA2.php Removed Paths: ------------- trunk/upgrade/upgradeTo1.1.0-BETA10.php trunk/upgrade/upgradeTo1.1.0-BETA12.php trunk/upgrade/upgradeTo1.1.0-BETA13.php trunk/upgrade/upgradeTo1.1.0-BETA14.php trunk/upgrade/upgradeTo1.1.0-BETA2.php trunk/upgrade/upgradeTo1.1.0-BETA3.php trunk/upgrade/upgradeTo1.1.0-BETA4.php trunk/upgrade/upgradeTo1.1.0-BETA7.php Modified: trunk/upgrade/upgrade.xml =================================================================== --- trunk/upgrade/upgrade.xml 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgrade.xml 2007-12-28 01:46:46 UTC (rev 728) @@ -22,53 +22,11 @@ in an unstable state. Unstable is bad, m'kay?</system_note> <matching> - <v1.1.0-BETA1> - <target_version>1.1.0-BETA2</target_version> - <script_name>upgradeTo1.1.0-BETA2.php</script_name> - <class_name>upgrade_to_1_1_0_BETA2</class_name> + <v1.2.0-ALPHA2> + <target_version>1.2.0-ALPHA2</target_version> + <script_name>upgradeTo1.2.0-ALPHA2.php</script_name> + <class_name>upgrade_to_1_2_0_ALPHA2</class_name> <call_method>run_upgrade</call_method> - </v1.1.0-BETA1> - <v1.1.0-BETA2> - <target_version>1.1.0-BETA3</target_version> - <script_name>upgradeTo1.1.0-BETA3.php</script_name> - <class_name>upgrade_to_1_1_0_BETA3</class_name> - <call_method>run_upgrade</call_method> - </v1.1.0-BETA2> - <v1.1.0-BETA3> - <target_version>1.1.0-BETA4</target_version> - <script_name>upgradeTo1.1.0-BETA4.php</script_name> - <class_name>upgrade_to_1_1_0_BETA4</class_name> - <call_method>run_upgrade</call_method> - </v1.1.0-BETA3> - <v1.1.0-BETA6> - <target_version>1.1.0-BETA7</target_version> - <script_name>upgradeTo1.1.0-BETA7.php</script_name> - <class_name>upgrade_to_1_1_0_BETA7</class_name> - <call_method>run_upgrade</call_method> - </v1.1.0-BETA6> - <v1.1.0-BETA9> - <target_version>1.1.0-BETA10</target_version> - <script_name>upgradeTo1.1.0-BETA10.php</script_name> - <class_name>upgrade_to_1_1_0_BETA10</class_name> - <call_method>run_upgrade</call_method> - </v1.1.0-BETA9> - <v1.1.0-BETA11> - <target_version>1.1.0-BETA12</target_version> - <script_name>upgradeTo1.1.0-BETA12.php</script_name> - <class_name>upgrade_to_1_1_0_BETA12</class_name> - <call_method>run_upgrade</call_method> - </v1.1.0-BETA11> - <v1.1.0-BETA12> - <target_version>1.1.0-BETA13</target_version> - <script_name>upgradeTo1.1.0-BETA13.php</script_name> - <class_name>upgrade_to_1_1_0_BETA13</class_name> - <call_method>run_upgrade</call_method> - </v1.1.0-BETA12> - <v1.1.0-BETA13> - <target_version>1.1.0-BETA14</target_version> - <script_name>upgradeTo1.1.0-BETA14.php</script_name> - <class_name>upgrade_to_1_1_0_BETA14</class_name> - <call_method>run_upgrade</call_method> - </v1.1.0-BETA13> + </v1.2.0-ALPHA2> </matching> </upgrade> Deleted: trunk/upgrade/upgradeTo1.1.0-BETA10.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA10.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA10.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,107 +0,0 @@ -<?php -/* - * Created on Oct 29, 2007 - */ - - -class upgrade_to_1_1_0_BETA10 extends dbAbstract { - - private $logsObj; - private $gfObj; - - private $attribId2Name = array(); - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if(!$db->is_connected()) { - throw new exception(__METHOD__ .": database is not connected"); - } - $this->db = $db; - - $this->gfObj = new cs_globalFunctions; - $this->logsObj = new logsClass($this->db, 'Upgrade'); - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - - - $this->db->beginTrans(__METHOD__); - - - $this->offendingAttributes = array( - 'company', 'fname', 'lname', 'email' - ); - - $this->get_offending_attribute_ids(); - $this->destroy_offending_attributes(); - - $this->db->commitTrans(__METHOD__); - - }//end run_upgrade() - //========================================================================= - - - - //========================================================================= - private function get_offending_attribute_ids() { - $retval = NULL; - $sql = "SELECT attribute_id, name FROM attribute_table WHERE name IN " . - "('company', 'fname', 'lname', 'email')"; - if($this->run_sql($sql)) { - $retval = $this->db->farray_nvp('attribute_id', 'name'); - $this->attribId2Name = $retval; - $this->attribNameList = $this->gfObj->string_from_array(array_values($retval)); - $retval = $this->gfObj->string_from_array(array_keys($retval)); - } - else { - $this->attribNameList = "company, fname, lname, email"; - } - - return($retval); - }//end get_offending_attribute_ids() - //========================================================================= - - - - //========================================================================= - private function destroy_offending_attributes() { - $attribIdString = $this->get_offending_attribute_ids(); - if(!is_null($attribIdString)) { - $sql = "SELECT cal.*, u.uid FROM contact_attribute_link_table AS cal " . - "LEFT OUTER JOIN user_table AS u USING (contact_id) " . - "WHERE attribute_id IN (". $attribIdString .")"; - if($this->run_sql($sql)) { - $contactAttribs = $this->db->farray_fieldnames('contact_attribute_link_id'); - foreach($contactAttribs as $id=>$data) { - $logUid = 0; - if(is_numeric($data['uid'])) { - $logUid = $data['uid']; - } - $attribName = $this->attribId2Name[$data['attribute_id']]; - $details = "Removed attribute [". $attribName ."] from contact_id=[". $data['contact_id'] ."]"; - $this->logsObj->log_by_class($details, 'upgrade', $logUid); - } - - //now delete them ALL. - $this->run_sql("DELETE FROM contact_attribute_link_table WHERE attribute_id IN (". $attribIdString .")"); - $this->logsObj->log_by_class("Deleted [". $this->lastNumrows ."] attribute links", 'upgrade'); - } - - $this->run_sql("DELETE FROM attribute_table WHERE attribute_id IN (". $attribIdString .")"); - $this->logsObj->log_by_class("Deleted attributes [". $this->attribNameList ."] (". $this->lastNumrows .")", 'upgrade'); - } - else { - $this->logsObj->log_by_class("Offending attributes not present [". $this->attribNameList ."]", 'upgrade'); - } - - - - }//end destroy_offending_attributes() - //========================================================================= - -} -?> Deleted: trunk/upgrade/upgradeTo1.1.0-BETA12.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA12.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA12.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,94 +0,0 @@ -<?php -/* - * Created on Nov 07, 2007 - */ - - -class upgrade_to_1_1_0_BETA12 extends dbAbstract { - - //========================================================================= - public function __construct(cs_phpDB $db) { - $this->db = $db; - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - $this->logsObj = new logsClass($this->db, 'Upgrade'); - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - $this->db->beginTrans(__METHOD__); - - $this->convert_issues(); - - $this->db->commitTrans(__METHOD__); - - - }//end run_upgrade() - //========================================================================= - - - - //========================================================================= - private function get_contacts_from_issue_notes($recordId) { - $sql = "SELECT note_id, creator_contact_id FROM note_table WHERE record_id=". $recordId; - $retval = NULL; - if($this->run_sql($sql) && $this->lastNumrows > 0) { - $retval = $this->db->farray_nvp('note_id', 'creator_contact_id'); - } - - return($retval); - }//end get_contacts_from_issue_notes() - //========================================================================= - - - //========================================================================= - private function convert_issues() { - $linkObj = new recordContactLink($this->db); - //retrieve all the issues. - $sql = "SELECT public_id, record_id, leader_contact_id, creator_contact_id " . - "FROM record_table WHERE is_helpdesk_issue IS TRUE ORDER BY public_id"; - - if($this->run_sql($sql) && $this->lastNumrows >= 1) { - $allIssues = $this->db->farray_fieldnames('record_id', NULL, 0); - - $totalRes = 0; - foreach($allIssues as $recordId=>$data) { - $contactIds = array(); - if(is_numeric($data['creator_contact_id']) && $data['creator_contact_id'] > 0) { - $contactIds[] = $data['creator_contact_id']; - } - if(is_numeric($data['leader_contact_id']) && $data['leader_contact_id'] > 0) { - $contactIds[] = $data['leader_contact_id']; - } - - $moreIds = $this->get_contacts_from_issue_notes($recordId); - if(is_array($moreIds)) { - $contactIds = array_merge($contactIds, $moreIds); - } - - //now try adding each of the given contacts to the issue. - if(count($contactIds)) { - $contactids = array_unique($contactIds); - foreach($contactIds as $cid) { - $addRes = $linkObj->add_link($data['record_id'], $cid); - if($addRes === TRUE) { - $totalRes++; - $this->logsObj->log_by_class("Linked [contact_id=". $cid ."] " . - "to [helpdesk_id=". $data['public_id'] ."] ([record_id=" . - $data['record_id'] ."])", 'create'); - } - } - } - } - - $this->logsObj->log_by_class(__METHOD__ .": created (". $totalRes .") links", 'upgrade'); - } - }//end convert_issues() - //========================================================================= - -}//end upgrade_to_1_1_0_BETA11{} - -?> \ No newline at end of file Deleted: trunk/upgrade/upgradeTo1.1.0-BETA13.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA13.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA13.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,91 +0,0 @@ -<?php -/* - * Created on Oct 29, 2007 - */ - - -class upgrade_to_1_1_0_BETA13 extends dbAbstract { - - private $logsObj; - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if(!$db->is_connected()) { - throw new exception(__METHOD__ .": database is not connected"); - } - $this->db = $db; - - $this->logsObj = new logsClass($this->db, 'Upgrade'); - - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - - - $this->db->beginTrans(__METHOD__); - - $this->run_schema_changes(); - $this->rewrite_config_file(); - - - $this->db->commitTrans(__METHOD__); - - }//end run_upgrade() - //========================================================================= - - - - //========================================================================= - private function run_schema_changes() { - - $this->gfObj->debug_print(__METHOD__ .": running SQL file..."); - $this->run_sql_file(dirname(__FILE__) .'/../docs/sql/upgrades/upgradeTo1.1.0-BETA13.sql'); - - $details = "Executed SQL file, '". $this->lastSQLFile ."'. Encoded contents::: ". - base64_encode($this->fsObj->read($this->lastSQLFile)); - $this->logsObj->log_by_class($details, 'system'); - }//end run_schema_changes() - //========================================================================= - - - - //========================================================================= - private function rewrite_config_file() { - //okay, first, let's read-in the config file. - $fs = new cs_fileSystemClass; - $configFile = dirname(__FILE__) ."/../lib/config.xml"; - $configContents = $fs->read($configFile); - - $encodedContents = base64_encode($configContents); - $xmlObj = new XMLParser($configContents); - - $myData = $xmlObj->get_tree(TRUE); - - $xmlCreator = new XMLCreator('CONFIG', NULL); - $xmlCreator->load_xmlparser_data($xmlObj); - - $oldHost = $myData['CONFIG']['CONFIG_EMAIL_SERVER_IP']; - $xmlCreator->remove_path('/CONFIG/CONFIG_EMAIL_SERVER_IP'); - $xmlCreator->add_tag('/CONFIG/PHPMAILER_HOST', $oldHost); - $xmlCreator->add_tag('/CONFIG/PHPMAILER_METHOD', 'IsSMTP'); - - - $newXmlConfig = $xmlCreator->create_xml_string(); - - $fs->closeFile(); - $fs->create_file($configFile, TRUE); - $fs->openFile($configFile); - $retval = $fs->write($newXmlConfig, $configFile); - $this->logsObj->log_by_class("Wrote new config file (". $retval .")", 'system'); - - }//end rewrite_config_file() - //========================================================================= -} - -?> Deleted: trunk/upgrade/upgradeTo1.1.0-BETA14.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA14.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA14.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,111 +0,0 @@ -<?php -/* - * Created on Nov 20, 2007 - */ - - -class upgrade_to_1_1_0_BETA14 extends dbAbstract { - - private $logsObj; - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if(!$db->is_connected()) { - throw new exception(__METHOD__ .": database is not connected"); - } - $this->db = $db; - - $this->logsObj = new logsClass($this->db, 'Upgrade'); - - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - - - $this->db->beginTrans(__METHOD__); - - $this->run_schema_changes(); - $this->update_tag_modifiers(); - - $this->db->commitTrans(__METHOD__); - - }//end run_upgrade() - //========================================================================= - - - - //========================================================================= - private function run_schema_changes() { - - $this->gfObj->debug_print(__METHOD__ .": running SQL file..."); - $this->run_sql_file(dirname(__FILE__) .'/../docs/sql/upgrades/upgradeTo1.1.0-BETA14.sql'); - - $details = "Executed SQL file, '". $this->lastSQLFile ."'. Encoded contents::: ". - base64_encode($this->fsObj->read($this->lastSQLFile)); - $this->logsObj->log_by_class($details, 'system'); - }//end run_schema_changes() - //========================================================================= - - - - //========================================================================= - private function update_tag_modifiers() { - - $sql = "SELECT tag_name_id, name FROM tag_name_table ORDER BY tag_name_id"; - if($this->run_sql($sql) && $this->lastNumrows > 1) { - $allTags = $this->db->farray_nvp('tag_name_id', 'name'); - - $specialModifiers = array( - 'critical' => -5, - 'exception' => -2, - 'invalid data' => -2, - 'authentication' => -1, - 'bug' => -1, - 'cannot fix' => -1, - 'data cleaning' => -1, - 'feature request' => -1, - 'email' => 0, - 'formatting' => 0, - 'has dependencies' => 0, - 'information' => 0, - 'network related' => 0, - 'session' => 0, - 'upgrade' => 1, - 'duplicate' => 2, - 'cannot reproduce' => 3, - ); - - $updates = 0; - foreach($allTags as $id=>$name) { - if(is_numeric($specialModifiers[$name])) { - //change the modifier accordingly... - $sql = "UPDATE tag_name_table SET modifier=". $specialModifiers[$name] ." WHERE tag_name_id=". $id; - if($this->run_sql($sql) && $this->lastNumrows == 1) { - $updates++; - } - else { - throw new exception(__METHOD__ .": failed to update tag (". $name .") with special " . - "modifier (". $specialModifiers[$name] .")"); - } - - // - $details = "Changed modifier of [tag_name_id=". $id ."] to (". $specialModifiers[$name] .")"; - $this->logsObj->log_by_class($details, 'update'); - } - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve tag names"); - } - - }//end update_tag_modifiers() - //========================================================================= -} - -?> Deleted: trunk/upgrade/upgradeTo1.1.0-BETA2.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA2.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA2.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,145 +0,0 @@ -<?php -/* - * Created on Oct 17, 2007 - */ - -require_once(dirname(__FILE__) .'/../lib/abstractClasses/dbAbstract.class.php'); - -class upgrade_to_1_1_0_BETA2 extends dbAbstract { - - private $gfObj; - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if($db->is_connected()) { - $this->db = $db; - } - else { - throw new exception(__METHOD__ .": database isn't connected"); - } - - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - $this->gfObj->debug_print(__METHOD__ .": running SQL file..."); - $this->run_sql_file(dirname(__FILE__) .'/../docs/sql/upgrades/upgradeTo1.1.0-BETA2.sql'); - - - //convert company data. - $sql = "SELECT * FROM contact_attribute_link_table WHERE attribute_id=" . - "(SELECT attribute_id FROM attribute_table WHERE name='company');"; - - $updatedContacts = array(); - if($this->run_sql($sql)) { - $data = $this->db->farray_nvp('contact_id', 'attribute_value'); - foreach($data as $conId=>$value) { - $sql = "UPDATE contact_table SET company='". $this->gfObj->cleanString($value, 'sql') . - "' WHERE contact_id=". $conId; - - if($this->run_sql($sql)) { - $updatedContacts[$conId]['setCompany']++; - } - else { - throw new exception(__METHOD__ .": failed to updated contact!"); - } - } - } - - $this->run_sql("DELETE FROM contact_attribute_link_table WHERE attribute_id=(SELECT " . - "attribute_id FROM attribute_table WHERE name='company')"); - $this->run_sql("DELETE FROM attribute_table WHERE name='company'"); - - - //convert email data. - $sql = "SELECT * FROM contact_attribute_link_table WHERE attribute_id=(SELECT " . - "attribute_id FROM attribute_table WHERE name='email')"; - if($this->run_sql($sql)) { - $data = $this->db->farray_nvp('contact_id', 'attribute_value'); - $con2emailId = array(); - foreach($data as $conId => $value) { - $sql = "INSERT INTO contact_email_table (contact_id, email) VALUES (". $conId .", '" . - $this->gfObj->cleanString($value, 'email') ."');"; - if($this->run_sql($sql)) { - $updatedContacts[$conId]['createNewContactEmailId']++; - - //get the contact_email_id just inserted, if needs be. - if(!isset($con2emailId[$conId])) { - $sql = "SELECT currval('contact_email_table_contact_email_id_seq'::text)"; - - if($this->run_sql($sql)) { - $seqData = $this->db->farray(); - $con2emailId[$conId] = $seqData[0]; - $updatedContacts[$conId]['getNewContactEmailId']++; - } - else { - throw new exception(__METHOD__ .": failed to retrieve newly inserted contact_email_id"); - } - } - } - else { - throw new exception(__METHOD__ .": failed to insert data...??"); - } - } - - foreach($con2emailId as $conId => $emailId) { - $sql = "UPDATE contact_table SET contact_email_id=". $emailId ." WHERE contact_id=". $conId; - if($this->run_sql($sql)) { - $updatedContacts[$conId]['setContactEmailId']++; - } - else { - throw new exception(__METHOD__ .": failed to update main email address for contact_id=(". $conId .")"); - } - } - - $this->run_sql("DELETE FROM contact_attribute_link_table WHERE attribute_id=" . - "(SELECT attribute_id FROM attribute_table WHERE name='email')"); - } - - //check to ensure even ANONYMOUS has an email address... - if($this->run_sql("SELECT * FROM contact_table WHERE contact_email_id IS NULL")) { - $data = $this->db->farray_fieldnames('contact_id'); - foreach($data as $conId => $data) { - $myEmailAddr = "fix_contact_id_". $conId ."@null.com"; - $sql = "INSERT INTO contact_email_table (contact_id, email) VALUES (". $conId .", " . - "'". $myEmailAddr ."')"; - - if($this->run_sql($sql)) { - //now update the contact. - $updatedContacts[$conId]['fixNullContactEmail__inserts']++; - - if($this->run_sql("SELECT currval('contact_email_table_contact_email_id_seq'::text)")) { - $seqData = $this->db->farray(); - $sql = "UPDATE contact_table SET contact_email_id=". $seqData[0] ." WHERE contact_id=". $conId; - if($this->run_sql($sql)) { - $updatedContacts[$conId]['fixNullContactEmail__updates']++; - } - else { - throw new exception(__METHOD__ .": failed to update contact"); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve id of inserted email address"); - } - } - else { - throw new exception(__METHOD__ .": failed to insert email address"); - } - } - } - - $this->run_sql("ALTER TABLE contact_table ALTER COLUMN contact_email_id SET NOT NULL;"); - - $this->gfObj->debug_print(__METHOD__ .": updatedContacts array::: ". $this->gfObj->debug_print($updatedContacts,0)); - $this->gfObj->debug_print(__METHOD__ .": final transaction level=(". $this->db->get_transaction_level() .")"); - - }//end run_upgrade() - //========================================================================= -} - -?> Deleted: trunk/upgrade/upgradeTo1.1.0-BETA3.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA3.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA3.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,90 +0,0 @@ -<?php -/* - * Created on Oct 24, 2007 - */ - - -class upgrade_to_1_1_0_BETA3 extends dbAbstract { - - private $gfObj; - private $logsObj; - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if($db->is_connected()) { - $this->db = $db; - } - else { - throw new exception(__METHOD__ .": database isn't connected"); - } - - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - - //now create the logging object. - $this->logsObj = new logsClass($this->db, "Upgrade"); - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - $this->gfObj->debug_print(__METHOD__ .": running SQL file..."); - $this->run_sql_file(dirname(__FILE__) .'/../docs/sql/upgrades/upgradeTo1.1.0-BETA3_part1.sql'); - - $details = "Executed SQL file, '". $this->lastSQLFile ."'. Encoded contents::: ". - base64_encode($this->fsObj->read($this->lastSQLFile)); - $this->logsObj->log_by_class($details, 'system'); - - - $this->convert_data(); - - $this->run_sql_file(dirname(__FILE__) .'/../docs/sql/upgrades/upgradeTo1.1.0-BETA3_part2.sql');$this->run_sql_file(dirname(__FILE__) .'/../docs/sql/upgrades/upgradeTo1.1.0-BETA3_part1.sql'); - - $details = "Executed SQL file, '". $this->lastSQLFile ."'. Encoded contents::: ". - base64_encode($this->fsObj->read($this->lastSQLFile)); - $this->logsObj->log_by_class($details, 'system'); - - }//end run_upgrade() - //========================================================================= - - - - //========================================================================= - private function convert_data() { - - //convert data from the logs. - $sql = "SELECT l.*, rc.module, rc.name as module_name FROM log_table AS l " . - "INNER JOIN record_type_table AS rc ON (l.record_type_id=" . - "rc.record_type_id) WHERE l.record_type_id IS NOT NULL AND l.record_id " . - "IS NOT NULL"; - - $retval = 0; - if($this->run_sql($sql)) { - $logRecords = $this->db->farray_fieldnames('log_id', NULL, 0); - - foreach($logRecords as $logId => $data) { - //update each log with a link to the issue/project, then log the change. - $addThis = "\n". strtoupper($data['module_name']) ." Link: [". $data['module'] . - "_id=". $data['record_id'] ."]"; - $sql = "UPDATE log_table SET details=details || '". $addThis ."' WHERE log_id=". $logId; - $this->run_sql($sql); - - if($this->lastNumrows == 1) { - //okay, now log it. - $details = "Data added to log_id=". $logId ."::: ". $addThis; - $this->logsObj->log_by_class($details, 'update'); - } - else { - throw new exception(__METHOD__ .": updated more than one record (". $this->lastNumrows .")"); - } - } - } - - return($retval); - }//end convert_data() - //========================================================================= -} - -?> Deleted: trunk/upgrade/upgradeTo1.1.0-BETA4.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA4.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA4.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,67 +0,0 @@ -<?php -/* - * Created on Oct 29, 2007 - */ - - -class upgrade_to_1_1_0_BETA4 extends dbAbstract { - - private $logsObj; - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if(!$db->is_connected()) { - throw new exception(__METHOD__ .": database is not connected"); - } - $this->db = $db; - - $this->logsObj = new logsClass($this->db, 'Upgrade'); - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - - - $this->db->beginTrans(__METHOD__); - - $sql = "ALTER TABLE attribute_table ADD COLUMN display_name text;"; - $this->run_sql($sql); - - //okay, now convert all records to have a proper display name. - if($this->run_sql("SELECT attribute_id, name FROM attribute_table ORDER BY name")) { - $attribData = $this->db->farray_nvp('attribute_id', 'name'); - - foreach($attribData as $aId=>$name) { - $newName = ucwords($name); - if(preg_match('/^im_/', $name)) { - $tmp = split("_", $name); - $newName = "IM: ". ucwords($tmp[1]); - } - - $sql = "UPDATE attribute_table SET display_name='". $newName ."' WHERE attribute_id=". $aId; - if($this->run_sql($sql) && $this->lastNumrows == 1) { - $this->logsObj->log_by_class(__METHOD__ .": updated attribute_id=". $aId ." with " . - "name=(". $name ."): new display value is (". $newName .")"); - } - else { - $this->logsObj->log_dberror(__METHOD__ .": failed to update attribute_id=". $aId .": ". $this->lastError); - } - } - - //now set the "display_name" column as NOT NULL - $this->run_sql("ALTER TABLE attribute_table ALTER COLUMN display_name SET NOT NULL"); - } - else { - throw new exception(__METHOD__ .": failed to retrieve any attributes for updating"); - } - - $this->db->commitTrans(__METHOD__); - - }//end run_upgrade() - //========================================================================= -} - -?> Deleted: trunk/upgrade/upgradeTo1.1.0-BETA7.php =================================================================== --- trunk/upgrade/upgradeTo1.1.0-BETA7.php 2007-12-28 01:46:14 UTC (rev 727) +++ trunk/upgrade/upgradeTo1.1.0-BETA7.php 2007-12-28 01:46:46 UTC (rev 728) @@ -1,104 +0,0 @@ -<?php -/* - * Created on Oct 29, 2007 - */ - - -class upgrade_to_1_1_0_BETA7 extends dbAbstract { - - private $logsObj; - - //========================================================================= - public function __construct(cs_phpDB &$db) { - if(!$db->is_connected()) { - throw new exception(__METHOD__ .": database is not connected"); - } - $this->db = $db; - - $this->logsObj = new logsClass($this->db, 'Upgrade'); - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function run_upgrade() { - - - $this->db->beginTrans(__METHOD__); - - $this->alter_contact_table(); - $this->rewrite_config_file(); - - - $this->db->commitTrans(__METHOD__); - - }//end run_upgrade() - //========================================================================= - - - - //========================================================================= - private function alter_contact_table() { - $this->run_sql("ALTER TABLE contact_table ALTER COLUMN contact_email_id SET NOT NULL;"); - - if(!strlen($this->lastError)) { - $this->logsObj->log_by_class(__METHOD__ .": changed contact_table.contact_email_id to NOT NULL", 'system'); - } - else { - throw new exception(__METHOD__ .": failed to alter contact table: ". $this->lastError); - } - }//end alter_contact_table() - //========================================================================= - - - - //========================================================================= - private function rewrite_config_file() { - //okay, first, let's read-in the config file. - $fs = new cs_fileSystemClass; - $configFile = dirname(__FILE__) ."/../lib/config.xml"; - $configContents = $fs->read($configFile); - $xmlObj = new XMLParser($configContents); - - $myData = $xmlObj->get_tree(); - $removeIndexes = array(); - foreach($myData['CONFIG'] as $index=>$stuff) { - if(preg_match('/^LOGCAT__/', $index) || preg_match('/^RECTYPE__/', $index)) { - debug_print(__METHOD__ .": removing index (". $index .")"); - $removeIndexes[] = $index; - } - } - - if(count($removeIndexes)) { - $xmlCreator = new XMLCreator('CONFIG', NULL); - $xmlCreator->load_xmlparser_data($xmlObj); - - foreach($removeIndexes as $num=>$name) { - debug_print(__METHOD__ .": removing #". $num .", name=(". $name .")"); - $oldValue = $myData['CONFIG'][$name]['value']; - $xmlCreator->remove_path('/CONFIG/'. $name); - $this->logsObj->log_by_class(__METHOD__ .": removing index (". $name ."), old value=(". $oldValue .")", 'system'); - } - $details = "Removed ". count($removeIndexes) ." unneeded config indexes"; - $this->logsObj->log_by_class($details, 'system'); - $newXmlConfig = $xmlCreator->create_xml_string(); - debug_print(cleanString($newXmlConfig, 'htmlentity')); - - $fs->closeFile(); - $fs->create_file($configFile, TRUE); - $fs->openFile($configFile); - $retval = $fs->write($newXmlConfig, $configFile); - $this->logsObj->log_by_class("Wrote new config file (". $retval .")", 'system'); - } - else { - $details = "No indexes removed"; - $this->logsObj->log_by_class($details, 'system'); - } - debug_print(__METHOD__ .": ". $details); - - }//end rewrite_config_file() - //========================================================================= -} - -?> Copied: trunk/upgrade/upgradeTo1.2.0-ALPHA2.php (from rev 726, trunk/upgrade/upgradeTo1.1.0-BETA14.php) =================================================================== --- trunk/upgrade/upgradeTo1.2.0-ALPHA2.php (rev 0) +++ trunk/upgrade/upgradeTo1.2.0-ALPHA2.php 2007-12-28 01:46:46 UTC (rev 728) @@ -0,0 +1,95 @@ +<?php +/* + * Created on Nov 20, 2007 + */ + + +class upgrade_to_1_2_0_ALPHA2 extends dbAbstract { + + private $logsObj; + + //========================================================================= + public function __construct(cs_phpDB &$db) { + if(!$db->is_connected()) { + throw new exception(__METHOD__ .": database is not connected"); + } + $this->db = $db; + + $this->logsObj = new logsClass($this->db, 'Upgrade'); + + $this->gfObj = new cs_globalFunctions; + $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; + }//end __construct() + //========================================================================= + + + + //========================================================================= + public function run_upgrade() { + + + $this->db->beginTrans(__METHOD__); + + $this->run_schema_changes(); + $this->update_tag_icons(); + + $this->db->commitTrans(__METHOD__); + + }//end run_upgrade() + //========================================================================= + + + + //========================================================================= + private function run_schema_changes() { + + $this->gfObj->debug_print(__METHOD__ .": running SQL file..."); + $this->run_sql_file(dirname(__FILE__) .'/../docs/sql/upgrades/upgradeTo1.2.0-ALPHA2.sql'); + + $details = "Executed SQL file, '". $this->lastSQLFile ."'. Encoded contents::: ". + base64_encode($this->fsObj->read($this->lastSQLFile)); + $this->logsObj->log_by_class($details, 'system'); + }//end run_schema_changes() + //========================================================================= + + + + //========================================================================= + private function update_tag_icons() { + + $sql = "SELECT tag_name_id, name, icon_name FROM tag_name_table ORDER BY tag_name_id"; + if($this->run_sql($sql) && $this->lastNumrows > 1) { + $allTags = $this->db->farray_fieldnames('name', 'tag_name_id'); + + $iconMods = array( + 'critical' => 'red_x', + 'bug' => 'bug', + 'feature request' => 'feature_request', + 'committed' => 'check_red', + 'verified' => 'check_yellow', + 'released' => 'check_green' + ); + + $updates = 0; + foreach($iconMods as $name=>$icon) { + if(isset($allTags[$name])) { + //update. + $sql = "UPDATE tag_name_table SET icon_name='". $icon ."' WHERE id=". $allTags[$name]; + } + else { + //insert. + $sql = "INSERT INTO tag_name_table (name, icon_name) VALUES ('". $name ."', '". $icon ."');"; + } + $this->run_sql($sql); + $updates += $this->lastNumrows; + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve tag names"); + } + + }//end update_tag_modifiers() + //========================================================================= +} + +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |