Thread: [CS-Project-svn_notify] SF.net SVN: cs-project:[900] trunk/1.2
Brought to you by:
crazedsanity
From: <cra...@us...> - 2008-07-21 03:20:30
|
Revision: 900 http://cs-project.svn.sourceforge.net/cs-project/?rev=900&view=rev Author: crazedsanity Date: 2008-07-21 03:20:21 +0000 (Mon, 21 Jul 2008) Log Message: ----------- Drop consolidation attempts from last few commits. SVN COMMAND::: merge -r898:896 https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/1.2 Modified Paths: -------------- trunk/1.2/includes/setup/1.inc trunk/1.2/includes/setup/2.inc trunk/1.2/includes/setup/3.inc trunk/1.2/includes/setup/5.inc trunk/1.2/includes/setup.inc Removed Paths: ------------- trunk/1.2/lib/setup.class.php Modified: trunk/1.2/includes/setup/1.inc =================================================================== --- trunk/1.2/includes/setup/1.inc 2008-07-21 02:17:54 UTC (rev 899) +++ trunk/1.2/includes/setup/1.inc 2008-07-21 03:20:21 UTC (rev 900) @@ -10,14 +10,14 @@ if($_POST) { reset_all_steps(FALSE); - $setupObj->store_setup_data(1, $_POST['fields']); - $dbTestRes = $setupObj->test_db_stuff(); + store_setup_data(1, $_POST['fields']); + $dbTestRes = test_db_stuff(); if($dbTestRes === TRUE) { - $setupObj->store_setup_data(1, 1, 'result'); - $setupObj->store_setup_data(1, 'Values stored successfully', 'text'); + store_setup_data(1, 1, 'result'); + store_setup_data(1, 'Values stored successfully', 'text'); //set the next step as accessible. - $setupObj->store_setup_data(2, 1, 'accessible'); + store_setup_data(2, 1, 'accessible'); //TODO: consider moving the database connectivity tests into this step (and alter the status message below accordingly). $page->set_message_wrapper(array( @@ -29,8 +29,8 @@ } else { //oops... - $setupObj->store_setup_data(1, 0, 'result'); - $setupObj->store_setup_data(1, $dbTestRes, 'text'); + store_setup_data(1, 0, 'result'); + store_setup_data(1, $dbTestRes, 'text'); $page->set_message_wrapper(array( 'title' => "Failure", @@ -52,7 +52,7 @@ )); } - $setupData = $setupObj->get_setup_data(1,'data'); + $setupData = get_setup_data(1,'data'); if(!is_array($setupData) || !count($setupData)) { //provide some defaults. $setupData = array( Modified: trunk/1.2/includes/setup/2.inc =================================================================== --- trunk/1.2/includes/setup/2.inc 2008-07-21 02:17:54 UTC (rev 899) +++ trunk/1.2/includes/setup/2.inc 2008-07-21 03:20:21 UTC (rev 900) @@ -7,21 +7,22 @@ if($_POST) { //check that step 1 was successful. - $setupObj->reset_all_steps(FALSE, 2); - $stepOneData = $setupObj->get_setup_data(1, 'data'); - if($setupObj->get_setup_data(1, 'result')) { + reset_all_steps(FALSE, 2); + $stepOneData = get_setup_data(1, 'data'); + if(get_setup_data(1, 'result')) { //first, check to see if we can connect to the host's "template1" database. $db = new cs_phpDB; - $setupObj->store_setup_data(2, 0, 'result'); - $result = $setupObj->test_db_stuff($db); + store_setup_data(2, 0, 'result'); + $result = test_db_stuff($db); if($result === TRUE) { //Good to go: load the schema! - $obj = new setup($page, $db); - $finalResult = $obj->handle_step(2); + //now create a temporary local class that does the rest. + $obj = new __tmpSetupClass($db, $page); + $finalResult = $obj->go(); $page->set_message_wrapper( array( @@ -34,7 +35,7 @@ } else { //not so good. Go back to step 1, so they can make changes. - $params = $setupObj->get_setup_data(1, 'data'); + $params = get_setup_data(1, 'data'); $page->set_message_wrapper( array( 'title' => "Test Failed", @@ -55,4 +56,191 @@ + +class __tmpSetupClass { + + + private $db; + private $fs; + private $page; + private $url = "/setup/1"; + + //========================================================================= + public function __construct(cs_phpDB &$db, cs_genericPage &$page) { + $this->db = $db; + $this->fsObj = new cs_fileSystemClass(dirname(__FILE__) .'/../../docs/sql/setup'); + $this->gfObj = new cs_globalFunctions; + $this->page = $page; + + store_setup_data(2, 0, 'result'); + store_setup_data(2, 'Initializing...', 'text'); + }//end __construct() + //========================================================================= + + + //========================================================================= + public function go() { + $retval = "Nothing done... something went horribly wrong."; + if($this->create_database()) { + $retval = $this->handle_plpgsql(); + + if($retval === TRUE) { + $retval = $this->load_schema(); + if($retval === TRUE) { + $this->page->set_message_wrapper( + array( + 'title' => "Step Successful", + 'message' => "Finished step two with result:::<BR>\n". get_setup_data(2,'text'), + 'type' => "status" + ) + ); + $this->page->conditional_header('/setup/3', TRUE); + } + else { + $retval = "There was an error while testing PL/PGSQL functionality: ". $retval; + store_setup_data(2, $retval, 'text'); + } + } + } + else { + store_setup_data(2, 0, 'result'); + store_setup_data(2, 'Failed to create database', 'text'); + $setupData = get_setup_data(1, 'data'); + $retval = "Unable to create database... check that ". $setupData['host'] . + " does not already have a database named '". $setupData['dbname'] ."'. " . + "Also, make sure no other user is connected to template1."; + } + + return($retval); + }//end go() + //========================================================================= + + + + //========================================================================= + private function create_database() { + $params = get_db_params(); + + //okay, let's try to create the database. + $numrows = $this->db->exec("CREATE DATABASE ". $params['dbname'] ." WITH ENCODING='SQL_ASCII'"); + $dberror = $this->db->errorMsg(); + + if(strlen($dberror)) { + $retval = FALSE; + } + else { + $retval = TRUE; + + //okay. Now destroy our database handle & create a new one, connected to the proper database. + unset($this->db); + $this->db = new cs_phpDb; + $this->db->connect(get_db_params()); + } + + return($retval); + }//end create_database() + //========================================================================= + + + //========================================================================= + private function load_schema() { + + store_setup_data(2, "Schema not loaded... ", 'text'); + store_setup_data(2, 0, 'result'); + + $fileData = $this->fsObj->read("01__storedprocs.sql"); + + //now we'll try to push that into the database. + $this->db->beginTrans(); + + $this->gfObj->debug_print("Loading stored procedures... "); + + $this->db->exec($fileData); + $dberror = $this->db->errorMsg(); + + if(strlen($dberror)) { + $this->db->rollbackTrans(); + $retval = $dberror; + } + else { + //keep going + $retval = "Successfully loaded stored procedures! Loading tables...."; + $this->gfObj->debug_print($retval); + + $fileData = $this->fsObj->read("02__tables.sql"); + $this->db->exec($fileData); + $dberror = $this->db->errorMsg(); + + if(strlen($dberror)) { + $this->db->rollbackTrans(); + $retval = $dberror; + } + else { + $retval = "Done loading tables!!! Creating indexes and miscellaneous other things..."; + $this->gfObj->debug_print($retval); + + $fileData = $this->fsObj->read("03__indexes_etc.sql"); + $this->db->exec($fileData); + $dberror = $this->db->errorMsg(); + + if(strlen($dberror)) { + $this->db->rollbackTrans(); + $retval = $dberror; + } + else { + $retval = "All stored procedures, tables, and indexes have been created!"; + $this->gfObj->debug_print($retval); + + $this->db->commitTrans(); + store_setup_data(2, array(), 'data'); + store_setup_data(2, 1, 'result'); + store_setup_data(2, $retval, 'text'); + store_setup_data(3, 1, 'accessible'); + + $retval = TRUE; + } + } + } + + return($retval); + }//end load_schema() + //========================================================================= + + + + //========================================================================= + /** + * Try to load PL/pgsql functions... + * + * NOTE: this is a terrible requirement, which requires PostgreSQL to be + * compiled with certain options... + */ + private function handle_plpgsql() { + $this->db->beginTrans(); + $fileData = $this->fsObj->read("plpgsql.sql"); + + $numrows = $this->db->exec($fileData); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror)) { + $this->db->commitTrans(); + $retval = TRUE; + } + else { + //figure out WHY this failed: if they're already loaded it's okay, otherwise it's bad. + $this->db->rollbackTrans(); + + if(preg_match('/"plpgsql_call_handler" already exists/', $dberror)) { + $retval = TRUE; + } + else { + $retval = $dberror; + } + } + + return($retval); + }//end handle_plpgsql() + //========================================================================= +} + ?> \ No newline at end of file Modified: trunk/1.2/includes/setup/3.inc =================================================================== --- trunk/1.2/includes/setup/3.inc 2008-07-21 02:17:54 UTC (rev 899) +++ trunk/1.2/includes/setup/3.inc 2008-07-21 03:20:21 UTC (rev 900) @@ -7,8 +7,10 @@ if($_POST) { $validSubmission = test_submitted_data($page, $_POST['users']); - if($validSubmission === TRUE) { - $setupObj->store_setup_data(3, $setupObj->handle_step(3), 'text'); + if($validSubmission === TRUE) { + $obj = new __setupDefaultValues(); + store_setup_data(3, $obj->go(), 'text'); + $obj->finish($page); } else { store_setup_data(3, $_POST['users'], 'post_info'); @@ -25,7 +27,7 @@ $page->conditional_header("/setup/3", TRUE); } else { - $myData = $setupObj->get_setup_data(3, 'post_info'); + $myData = get_setup_data(3, 'post_info'); if(is_array($myData)) { foreach($myData as $num=>$userArr) { foreach($userArr as $userField => $userValue) { @@ -120,4 +122,1046 @@ +class __setupDefaultValues extends upgrade { + + + protected $db; + private $gfObj; + private $totalRecords=0; + + private $data=array(); + + private $lastNumrows=NULL; + private $lastDberror=NULL; + + //========================================================================= + public function __construct() { + $this->db = new cs_phpDB; + $this->gfObj = new cs_globalFunctions; + }//end __construct() + //========================================================================= + + + + //========================================================================= + public function go() { + store_setup_data(3, 0, 'result'); + try { + $params = get_db_params(); + $this->db->connect($params); + $this->db->beginTrans(__METHOD__); + $retval = "Connected successfully to the database."; + + //now that we've connected, start doing stuff. + $retval = $this->set_version(); + $retval .= "<BR>\n". $this->create_log_categories_and_classes(); + $retval .= "<BR>\n". $this->create_record_type_data(); + $retval .= "<BR>\n". $this->create_attributes(); + $retval .= "<BR>\n". $this->create_anonymous_contact_data(); + $retval .= "<BR>\n". $this->create_status_records(); + $retval .= "<BR>\n". $this->create_tag_names(); + $retval .= "<BR>\n". $this->build_preferences(); + $retval .= "<BR>\n". $this->create_users(); + $retval .= "<BR>\n". $this->create_user_group_records(); + + $commitRes = $this->db->commitTrans(); + if($commitRes == 1) { + $retval .= "<BR>\n ----------- Created (". $this->totalRecords ."), result of commit: (". $commitRes .")."; + store_setup_data(3, 1, 'result'); + store_setup_data(4, 1, 'accessible'); + } + else { + $this->db->rollbackTrans(); + store_setup_data(3, 0, 'result'); + throw new exception(__METHOD__ .": failed to commit the transaction (". $commitRes .")"); + } + + } + catch(exception $e) { + //TODO: rollback the transaction + $retval = "An error occurred: ". $e->getMessage(); + } + + return($retval); + + }//end go() + //========================================================================= + + + + //========================================================================= + /** + * Set version information into the database for future upgradeability. + */ + private function set_version() { + //get the version string. + $fullVersionString = read_version_file(); + + $suffixData = explode('-', $fullVersionString); + if(count($suffixData) == 2 && preg_match('/\./', $suffixData[0]) && !preg_match('/\./', $suffixData[1])) { + //there's a suffix, and it doesn't contain periods (i.e. "1.0.0-ALPHA1") + $suffix = $suffixData[1]; + } + elseif(count($suffixData) == 1) { + //no suffix. + $suffix = ""; + } + else { + //there's a dash in the name, but it's invalid or contains periods (i.e. "BETA-1.0.0" or "1.0.0-ALPHA1.0") + throw new exception(__METHOD__ .": version string is invalid (". $fullVersionString ."), suffix contains dashes, or there is a prefix"); + } + + //remove the suffix & parse it. + $versionString = $suffixData[0]; + $versionData = $this->parse_version_string($fullVersionString); + $sqlData = $versionData; + + + #$sqlData = array( + # 'version_string' => $fullVersionString, + # 'version_major' => $versionData[0], + # 'version_minor' => $versionData[1], + # 'version_maintenance' => $versionData[2], + # 'version_suffix' => $suffix + #); + + $retval = 0; + foreach($sqlData as $name => $value) { + $sql = "SELECT internal_data_set_value('". $name ."', '". $value ."')"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to set (". $name .") as (". $value .")::: ". $dberror); + } + } + + if($retval == count($sqlData)) { + //okay, the final test: run a query that straps everything together, to ensure it all has the same version. + $sql = "SELECT internal_data_get_value('version_major') || '.' || internal_data_get_value('version_minor') " . + " || '.' || internal_data_get_value('version_maintenance') as text, " . + "internal_data_get_value('version_suffix') as version_suffix;"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $data = $this->db->farray(); + $dbVersionString = $data['text']; + if(strlen($data['version_suffix'])) { + $dbVersionString .= "-". $data['version_suffix']; + } + + if($dbVersionString === $fullVersionString) { + //okay, one final test: check that the "version_string" in the database matches ours. + $sql = "SELECT internal_data_get_value('version_string')"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $data = $this->db->farray(); + $dbVersionString = $data[0]; + + if($dbVersionString === $fullVersionString) { + $this->data['version_string'] = $fullVersionString; + $retval = "Successfully set version string"; + } + else { + throw new exception(__METHOD__ .": derived database version string (". $dbVersionString .") doesn't match our version (". $fullVersionString .")"); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve full version_string from database::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": derived database version string (". $dbVersionString .") doesn't match our version (". $fullVersionString .")"); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve derived database version string::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + //it's cryptic, but what should it really say??? + throw new exception(__METHOD__ .": internal error, checksum didn't match"); + } + + return($retval); + + }//end set_version() + //========================================================================= + + + + //========================================================================= + private function create_log_categories_and_classes() { + + $counter = 0; + + $classes = array( + 1 => 'Error', + 2 => 'Information', + 3 => 'Create', + 4 => 'Update', + 5 => 'Delete', + 6 => 'REPORT', + 7 => 'DEBUG' + ); + + + foreach($classes as $num=>$name) { + $insertArr = array( + 'log_class_id' => $num, + 'name' => $name + ); + $sql = "INSERT INTO log_class_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + //good. + $counter++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to create class record for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + + //Reset sequence, so new records can be created. + $sql = "SELECT setval('log_class_table_log_class_id_seq', (SELECT max(log_class_id) FROM log_class_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $categories = array( + 1 => 'Database', + 2 => 'Authentication', + 3 => 'Users', + 4 => 'General', + 5 => 'Project', + 6 => 'Helpdesk', + 7 => 'Task', + 8 => 'Tags', + 9 => 'Estimates', + 10 => 'Navigation', + 11 => 'Preferences' + ); + + + foreach($categories as $num=>$name) { + $insertArr = array( + 'log_category_id' => $num, + 'name' => $name + ); + $sql = "INSERT INTO log_category_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + //good. + $counter++; + $this->totalRecords++; + $this->data['logcat__'. strtolower($name)] = $num; + } + else { + throw new exception(__METHOD__ .": failed to create category record for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + //Reset sequence, so new records can be created. + $sql = "SELECT setval('log_category_table_log_category_id_seq', (SELECT max(log_category_id) FROM log_category_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + + //format (primary index is log_event_id): log_class_id, log_category_id, description + $logEvents = array( + // * log_event_id | log_class_id | log_category_id | description + 1 => array(3, 5, 'Project: created record'), + 2 => array(5, 5, 'Project: deleted record'), + 3 => array(4, 5, 'Project: updated record'), + 4 => array(1, 5, 'Project: ERROR'), + 5 => array(3, 6, 'Helpdesk: Created record'), + 6 => array(4, 6, 'Helpdesk: Updated record'), + 7 => array(2, 6, 'Helpdesk: Information'), + 8 => array(1, 6, 'Helpdesk: ERROR'), + 9 => array(6, 6, 'Helpdesk: Report'), + 10 => array(3, 7, 'Task: created record'), + 11 => array(5, 7, 'Task: deleted record'), + 12 => array(4, 7, 'Task: updated record'), + 13 => array(1, 1, 'Database Error'), + 14 => array(6, 5, 'Project: Activity Report'), + 15 => array(6, 7, 'Task: Activity Report'), + 16 => array(3, 2, 'User logged-in'), + 17 => array(5, 2, 'User logged-out'), + 18 => array(6, 2, 'Login/Logout Report'), + 19 => array(3, 8, 'Tags: created record'), + 20 => array(5, 8, 'Tags: deleted record'), + 21 => array(4, 8, 'Tags: updated record'), + 22 => array(6, 8, 'Tags: Activity Report'), + 23 => array(1, 2, 'Authentication: ERROR'), + 24 => array(2, 10, 'Navigation: Viewed page'), + 25 => array(4, 9, 'Update: Estimates'), + 26 => array(1, 9, 'Error: Estimates'), + 27 => array(2, 5, 'Information: Project'), + 28 => array(4, 3, 'Update: Users'), + 29 => array(1, 7, 'Error: Task'), + 30 => array(3, 3, 'Create: Users') + ); + + foreach($logEvents as $logEventId => $subArr) { + $insertArr = array( + 'log_event_id' => $logEventId, + 'log_class_id' => $subArr[0], + 'log_category_id' => $subArr[1], + 'description' => $subArr[2] + ); + $sql = "INSERT INTO log_event_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $counter++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to create log_event_id #". $insertArr['log_event_id'] + .", description: ". $insertArr['description'] ."<BR>\nERROR::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + //FINAL SANITY CHECKS!!! + if($counter == (count($classes) + count($categories) + count($logEvents))) { + + //reset the sequence. + $sql = "SELECT setval('log_event_table_log_event_id_seq', (SELECT max(log_event_id) FROM log_event_table))"; + if($this->run_sql($sql) === TRUE) { + $retval = "Successfully created all category, class, and log event records (". $counter .")"; + } + else { + throw new exception(__METHOD__ .": failed to reset sequence for log_event table::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": Internal error, failed to create all category and class records"); + } + } + else { + throw new exception(__METHOD__ .": failed to reset sequence for log_category_table::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": failed to reset sequence for log_class_table::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + + return($retval); + + }//end create_log_categories_and_classes() + //========================================================================= + + + + //========================================================================= + private function create_record_type_data() { + //format: + // {record_type_id} => array({name}, {module}) + $recordTypes = array( + 1 => array('Project', 'project'), + 2 => array('Task', 'task'), + 3 => array('Helpdesk', 'helpdesk') + ); + + $retval = 0; + foreach($recordTypes as $recTypeId => $subData) { + $insertArr = array( + 'record_type_id' => $recTypeId, + 'name' => $subData[0], + 'module' => $subData[1] + ); + $sql = "INSERT INTO record_type_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $this->totalRecords++; + $retval++; + $this->data['rectype__'. $insertArr['module']] = $recTypeId; + } + else { + throw new exception(__METHOD__ .": failed to create record for ". $insertArr['name'] + .", dberror::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + if(count($recordTypes) == $retval) { + + $sql = "SELECT setval('record_type_table_record_type_id_seq'::text, (SELECT max(record_type_id) FROM record_type_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + if($retval == count($recordTypes)) { + $retval = "Created all record types (". $retval .")"; + } + else { + throw new exception(__METHOD__ .": internal error (sanity check failed)"); + } + } + else { + throw new exception(__METHOD__ .": failed to reset sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": internal error"); + } + + return($retval); + }//end create_record_type_data() + //========================================================================= + + + + //========================================================================= + private function create_attributes() { + $attributes = array( + 3 => array('phone', 'phone', 'Phone'), + 4 => array('fax', 'phone', 'Fax'), + 5 => array('cell', 'phone', 'Cell'), + 6 => array('im_yahoo', 'alphanumeric', 'IM: Yahoo'), + 7 => array('im_skype', 'alphanumeric', 'IM: Skype'), + 8 => array('im_aol', 'alphanumeric', 'IM: AOL'), + 9 => array('im_msn', 'alphanumeric', 'IM: MSN'), + 10 => array('im_icq', 'alphanumeric', 'IM: ICQ'), + 11 => array('address', 'sql', 'Address'), + 12 => array('city', 'alphanumeric', 'City'), + 13 => array('state', 'alphanumeric', 'State'), + 14 => array('zip', 'alphanumeric', 'Zip') + ); + + $retval = 0; + foreach($attributes as $attributeId => $subData) { + $insertArr = array( + 'attribute_id' => $attributeId, + 'name' => $subData[0], + 'clean_as' => $subData[1], + 'display_name' => $subData[2] + ); + $sql = "INSERT INTO attribute_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to insert data for attribute (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + if($retval == count($attributes)) { + $sql = "SELECT setval('attribute_table_attribute_id_seq'::text, (SELECT max(attribute_id) FROM attribute_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval = "Successfully created all attributes (". $retval .")!"; + } + else { + throw new exception(__METHOD__ .": failed to reset sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": internal error (sanity check failed)"); + } + + return($retval); + }//end create_attributes() + //========================================================================= + + + + //========================================================================= + /** + * Create the anonymous user. This includes their contact data and the + * default group. + * + * TODO: change "short_name" into "display_name". + */ + private function create_anonymous_contact_data() { + $allRecords = array( + 'disabled group' => array( + 'name' => 'group_table', + 'data' => array( + 'group_id' => 0, + 'name' => 'disabled', + 'short_name' => 'DISABLED', + 'leader_uid' => 0 + ), + ), + 'anonymous record in user table' => array( + 'name' => 'user_table', + 'data' => array( + 'uid' => 0, + 'username' => 'Anonymous', + 'password' => 'disabled', //this is PURPOSELY an invalid password (passwords should be 32-char md5's + 'is_admin' => 'f', + 'is_active' => 'f', + 'group_id' => 0, + 'contact_id' => 0 + ), + ), + 'default group' => array( + 'name' => 'group_table', + 'data' => array( + 'group_id' => 1, + 'name' => 'default', + 'short_name' => '-DEFAULT-', + 'leader_uid' => 0 + ), + ), + 'anonymous contact record' => array( + 'name' => 'contact_table', + 'data' => array( + 'contact_id' => 0, + 'company' => '', + 'fname' => 'Anonymous', + 'lname' => '', + 'contact_email_id' => '-1' + ) + ), + 'anonymous email record' => array( + 'name' => 'contact_email_table', + 'data' => array( + 'contact_id' => 0, + 'email' => 'ano...@nu...' + ) + ) + ); + + $retval = 0; + foreach($allRecords as $operationName => $subData) { + $tableName = $subData['name']; + $insertArr = $subData['data']; + + $sql = "INSERT INTO ". $tableName ." ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $this->totalRecords++; + $retval++; + } else { + throw new exception(__METHOD__. ": failed perform operation (". $operationName .") for table (". $tableName .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + $sql = "SELECT currval('contact_email_table_contact_email_id_seq'::text)"; + if($this->run_sql($sql)) { + $data = $this->db->farray(); + $sql = "UPDATE contact_table SET contact_email_id=". $data[0] ." WHERE contact_id=0"; + if($this->run_sql($sql)) { + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to set contact_email_id for anonymous"); + } + } + else { + throw new exception(__METHOD__ .": failed to get sequence for contact_email_table"); + } + + if($retval == count($allRecords)) { + //reset the sequence for the group table... + $sql = "SELECT setval('group_table_group_id_seq'::text, (SELECT max(group_id) FROM group_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + //good to go. + $retval = "Successfully created anonymous user, anonymous contact record, and the two default groups (". $retval .")!"; + } + else { + throw new exception(__METHOD__ .": failed to reset group sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": internal error (failed sanity check)"); + } + + return($retval); + }//end create_anonymous_contact_data() + //========================================================================= + + + //========================================================================= + private function create_status_records() { + //format: {status_id} => array({name}, {description}) + $statuses = array( + 0 => array('New/Offered', 'New record'), + 1 => array('Pending', 'Not new: pending review, or nearly complete.'), + 2 => array('Running/Accepted', 'Work is underway'), + 3 => array('Stalled', 'Unable to complete, or dependent on other things.'), + 4 => array('Ended/Solved', 'Work is complete!'), + 5 => array('Rejected', 'Denied.'), + 6 => array('Re-opened', 'Was solved, but is once again open.'), + ); + + $retval = 0; + foreach($statuses as $statusId => $subData) { + $insertArr = array( + 'status_id' => $statusId, + 'name' => $subData[0], + 'description' => $subData[1] + ); + $sql = "INSERT INTO status_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to create status (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + if($retval == count($statuses)) { + //reset the status_table.status_id sequence... + $sql = "SELECT setval('status_table_status_id_seq'::text, (SELECT max(status_id) FROM status_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + //good to go. + $retval = "Successfully created all status records (". $retval .")!"; + } + else { + throw new exception(__METHOD__ .": failed to reset status sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": internal error (failed sanity check)"); + } + + return($retval); + + }//end create_status_records() + //========================================================================= + + + + //========================================================================= + private function create_tag_names() { + $tags = array( + 1 => 'bug', + 2 => 'feature request', + 3 => 'information', + 4 => 'network related', + 5 => 'critical', + 6 => 'exception' + ); + + $retval = 0; + foreach($tags as $id=>$name) { + $insertArr = array( + 'tag_name_id' => $id, + 'name' => $name + ); + $sql = "INSERT INTO tag_name_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to insert data for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + if($retval == count($tags)) { + //reset sequence for tag_name_table.tag_name_id + $sql = "SELECT setval('tag_name_table_tag_name_id_seq'::text, (SELECT max(tag_name_id) FROM tag_name_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + //good to go. + $retval = "Successfully created all tags (". $retval .")!"; + } + else { + throw new exception(__METHOD__ .": failed to reset tag_name sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": internal error (sanity check failed)"); + } + + return($retval); + }//end create_tag_names() + //========================================================================= + + + + //========================================================================= + private function build_preferences() { + //format: {pref_type_id} => array({name}, {default_value}, {display_name}, {description}) + $prefTypes = array( + 1 => array('startModule', 'helpdesk', 'Starting on Module', 'Defines which section will be loaded upon login if nothing was selected.'), + 5 => array('sorting_helpdesk', 'public_id|DESC', 'Helpdesk Sorting', 'Define the type of sorting for the helpdesk page.'), + 6 => array('sorting_project', 'priority|ASC', 'Project Sorting', 'Define the type of sorting for the helpdesk page.'), + 7 => array('projectDetails_taskDisplayOnlyMine', 'all', 'Project Details: Task display', 'Define what tasks are displayed on a project\'s details page.'), + 8 => array('projectDetails_showCompletedIssues', '1', 'Project Details: Display completed issues', 'Should completed issues display in the details of a project?') + ); + + $retval = 0; + foreach($prefTypes as $prefTypeId => $subData) { + $insertArr = array( + 'pref_type_id' => $prefTypeId, + 'name' => $subData[0], + 'default_value' => $subData[1], + 'display_name' => $subData[2], + 'description' => $subData[3] + ); + + $sql = "INSERT INTO pref_type_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to insert data for (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + if($retval == count($prefTypes)) { + //format: {pref_option_id} => array({pref_type_id}, {name}, {effective_value}) + $prefOptions = array( + 1 =>array(1, 'Helpdesk', 'helpdesk'), + 2 =>array(1, 'Projects', 'project'), + 3 =>array(1, 'Summary ', 'summary'), + 8 =>array(5, 'ID - Descending', 'public_id|DESC'), + 9 =>array(5, 'ID - Ascending', 'public_id|ASC'), + 10 =>array(5, 'Priority - Descending', 'priority|DESC'), + 11 =>array(5, 'Priority - Ascending', 'priority|ASC'), + 12 =>array(5, 'Submit - Descending', 'start_date|DESC'), + 13 =>array(5, 'Submit - Ascending', 'start_date|ASC'), + 14 =>array(5, 'Title - Descending', 'name|DESC'), + 15 =>array(5, 'Title - Ascending', 'name|DESC'), + 16 =>array(5, 'Status ID - Descending', 'status_id|DESC'), + 17 =>array(5, 'Status ID - Ascending', 'status_id|DESC'), + 18 =>array(5, 'Assigned - Descending', 'assigned|DESC'), + 19 =>array(5, 'Assigned - Ascending', 'assigned|DESC'), + 20 =>array(6, 'Priority - Ascending', 'priority|ASC'), + 21 =>array(6, 'Priority - Descending', 'priority|DESC'), + 22 =>array(6, 'Name of Project - Ascending', 'name|ASC'), + 23 =>array(6, 'Name of Project - Descending', 'name|DESC'), + 24 =>array(6, 'Begin - Ascending', 'start_date|ASC'), + 25 =>array(6, 'Begin - Descending', 'start_date|DESC'), + 26 =>array(6, 'End - Ascending', 'end|ASC'), + 27 =>array(6, 'End - Descending', 'end|DESC'), + 28 =>array(6, 'Status ID - Ascending', 'status_id|ASC'), + 29 =>array(6, 'Status ID - Descending', 'status_id|DESC'), + 30 =>array(6, 'Progress - Ascending', 'progress|ASC'), + 31 =>array(6, 'Progress - Descending', 'progress|DESC'), + 32 =>array(6, 'Leader - Ascending', 'leader_contact_id|ASC'), + 33 =>array(6, 'Leader - Descending', 'leader_contact_id|DESC'), + 34 =>array(7, 'Show everything', 'all'), + 35 =>array(7, 'All of mine (created & assigned)', 'mine'), + 36 =>array(7, 'Only my assigned items', 'assigned'), + 37 =>array(8, 'Yes', '1'), + 38 =>array(8, 'No', '0'), + ); + + foreach($prefOptions as $prefOptionId => $subData) { + $insertArr = array( + 'pref_option_id' => $prefOptionId, + 'pref_type_id' => $subData[0], + 'name' => $subData[1], + 'effective_value' => $subData[2] + ); + $sql = "INSERT INTO pref_option_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to insert data for pref option (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + if($retval == (count($prefTypes) + count($prefOptions))) { + //reset the pref_type_table.pref_type_id sequence. + $sql = "SELECT setval('pref_type_table_pref_type_id_seq'::text, (SELECT max(pref_type_id) FROM pref_type_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + if($retval == (count($prefTypes) + count($prefOptions))) { + //reset the pref_option_table.pref_option_id sequence. + $sql = "SELECT setval('pref_option_table_pref_option_id_seq'::text, (SELECT max(pref_option_id) FROM pref_option_table))"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval = "Successfully created all preferences and options (". $retval .")!"; + } + else { + throw new exception(__METHOD__ .": failed to reset the pref_option sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": internal error (sanity check #2 failed)"); + } + } + else { + throw new exception(__METHOD__ .": failed to reset pref_type sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": internal error (sanity check #2 failed): (". $retval ." != ". (count($prefTypes) + count($prefOptions)) .")"); + } + } + else { + throw new exception(__METHOD__ .": internal error (sanity check #1 failed)"); + } + + return($retval); + + }//end build_preferences() + //========================================================================= + + + + //========================================================================= + private function create_users() { + + //retrieve the user information. + $userData = get_setup_data(3, 'post_info'); + if(!is_array($userData) || count($userData) != 2) { + throw new exception(__METHOD__ .": no user data...?". $this->gfObj->debug_print($userData,0)); + } + + $counter = 0; + $retval = "Successfully created records for::: "; + foreach($userData as $num => $subData) { + + //split their name up, based upon spaces. + $nameData = explode(' ', $subData['name']); + $insertArr = array(); + if(count($nameData) == 1) { + $insertArr['fname'] = $nameData[0]; + $insertArr['lname'] = ""; + } + elseif(count($nameData) == 2) { + $insertArr['fname'] = $nameData[0]; + $insertArr['lname'] = $nameData[1]; + } + else { + $insertArr['fname'] = $nameData[0]; + $insertArr['lname'] = preg_replace('/^'. $insertArr['fname'] .' /', '', $subData['name']); + } + $insertArr['contact_email_id'] = '-1'; + + //create their contact record. + $sql = "INSERT INTO contact_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $sql = "SELECT currval('contact_table_contact_id_seq'::text)"; + if($this->run_sql($sql, 1) === TRUE) { + $this->totalRecords++; + + $data = $this->db->farray(); + $contactId = $data[0]; + + //now create the user. + $xUser = $subData['username']; + $insertArr = array( + 'username' => $subData['username'], + 'password' => md5($subData['password'] .'_'. $contactId), + 'is_admin' => interpret_bool($subData['is_admin'], array('f', 't')), + 'contact_id' => $contactId + ); + $sql = "INSERT INTO user_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + + if($this->run_sql($sql, 1) === TRUE) { + $sql = "SELECT currval('user_table_uid_seq'::text)"; + if($this->run_sql($sql,1) === TRUE) { + $data = $this->db->farray(); + $lastUid = $data[0]; + + //create an email address for them. + $sql = "INSERT INTO contact_email_table (contact_id, email) VALUES (". $contactId .", '". strtolower($subData['email']) ."')"; + if($this->run_sql($sql,1) === TRUE) { + $counter++; + //get the newly inserted id, so we can update the contact table. + if($this->run_sql("SELECT currval('contact_email_table_contact_email_id_seq'::text)")) { + $data = $this->db->farray(); + $contactEmailId = $data[0]; + + $sql = "UPDATE contact_table SET contact_email_id=". $contactEmailId ." WHERE contact_id=". $contactId; + if($this->run_sql($sql)) { + $retval = $this->gfObj->create_list($retval, " --- Created record for ". $subData['username'] ." (". $lastUid .")", "<BR>\n"); + } + else { + throw new exception(__METHOD__ .": unable to update contact table with new contact_email_id..."); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve contact_email_id"); + } + } + else { + throw new exception(__METHOD__ .": failed to create email for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve uid for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": failed to create user record for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": unable to retrieve contact_id for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": failed to create contact record for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + + if($counter == 2) { + $retval = $this->gfObj->create_list($retval, " --->>> done, created (". $counter .") records", "<BR>\n"); + } + else { + throw new exception(__METHOD__ .": failed to create users (". $counter .")::: ". $this->gfObj->debug_print($userData,0)); + } + + return($retval); + }//end create_users() + //========================================================================= + + + + //========================================================================= + public function finish(cs_genericPage &$page) { + + $stepRes = get_setup_data(3, 'result'); + if($stepRes == 1) { + $page->set_message_wrapper(array( + 'title' => "Successfully Setup Data", + 'message' => "All default data was stored in the new database successfully!", + 'type' => "status" + )); + store_setup_data(3, $this->data, 'data'); + $page->conditional_header("/setup/4", TRUE); + } + else { + $page->set_message_wrapper(array( + 'title' => "Step Failed", + 'message' => "Please review the errors below and proceed accordingly.", + 'type' => "error" + )); + $page->conditional_header("/setup/3", TRUE); + } + + }//end finish() + //========================================================================= + + + + //========================================================================= + protected function run_sql($sql, $expectedNumrows=NULL) { + if(strlen($sql)) { + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + $this->lastNumrows = $numrows; + $this->lastDberror = $dberror; + + if(!strlen($dberror) && $numrows >= 0) { + if(is_numeric($expectedNumrows)) { + if($expectedNumrows == $numrows) { + $retval = TRUE; + } + else { + $retval = FALSE; + } + } + else { + //don't care if it's numeric. + $retval = TRUE; + } + } + else { + throw new exception(__METHOD__ .": failed to run SQL, got numrows=(". $numrows ."), dberror::: ". $dberror ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": no SQL to run..."); + } + + return($retval); + }//end run_sql() + //========================================================================= + + + + //========================================================================= + private function create_user_group_records() { + $sql = "INSERT INTO user_group_table (uid, group_id) SELECT uid, group_id FROM user_table"; + if($this->run_sql($sql, 3) === TRUE) { + $retval = "Successfully created user_group linkage."; + } + else { + throw new exception(__METHOD__ .": unable to create user group records::: ". $this->lastDberror ."<BR>\nSQL::: ". $sql); + } + return($retval); + }//end create_user_group_records() + //========================================================================= + + +}//end __setupDefaultValues{} + + + +class _setupUpgrade extends upgrade { + + public function __construct(cs_phpDB $db) { + $this->db = $db; + parent::__construct(); + }//end __construct() + + public function finalize_conversion() { + $myVersion = parent::read_version_file(); + $setDataResult = parent::run_sql("SELECT internal_data_set_value('converted_from_version', '". parent::read_version_file() ."')"); + parent::update_num_users_to_convert(); + $retval = parent::update_database_version($myVersion); + debug_print(__METHOD__ .": myVersion=(". $myVersion ."), setDataResult=(". $setDataResult ."), retval=(". $retval .")"); + + return($myVersion); + }//end finalize_conversion() +}//end _setupUpgrade{} + ?> Modified: trunk/1.2/includes/setup/5.inc =================================================================== --- trunk/1.2/includes/setup/5.inc 2008-07-21 02:17:54 UTC (rev 899) +++ trunk/1.2/includes/setup/5.inc 2008-07-21 03:20:21 UTC (rev 900) @@ -6,10 +6,8 @@ if($_POST) { - #$obj = new __finalStep($page, $stepNames); - #$writeConfigResult = $obj->write_config($page); - $obj = new setup($page); - $writeConfigResult = $obj->handle_step(5, $stepNames); + $obj = new __finalStep($page, $stepNames); + $writeConfigResult = $obj->write_config($page); $page->set_message_wrapper(array( 'title' => "Reloaded... ", @@ -39,4 +37,121 @@ } +class __finalStep { + + + private $page; + private $gfObj; + + + //========================================================================= + public function __construct(cs_genericPage $page, array $stepData) { + $this->page = $page; + $this->stepData = $stepData; + unset($this->stepData[5]); + + $this->gfObj = new cs_globalFunctions; + $this->fsObj = new cs_fileSystemClass(dirname(__FILE__) ."/../../". CONFIG_DIRECTORY); + }//end __construct() + //========================================================================= + + + + //========================================================================= + function write_config() { + if($this->fsObj->is_writable(NULL)) { + $lsData = $this->fsObj->ls(); + if(!is_array($lsData[CONFIG_FILENAME])) { + $myData = array(); + foreach($this->stepData as $stepNum=>$garbage) { + $tempStepData = get_setup_data($stepNum, 'data'); + if(is_array($tempStepData)) { + $myData = array_merge($tempStepData, $myData); + } + else { + throw new exception(__METHOD__ .": step #". $stepNum ." has no valid data... ". $this->gfObj->debug_print($tempStepData,0)); + } + } + + //now that we've built the array successfully, now let's turn it into XML. + $xmlCreator = new xmlCreator('config'); + foreach($myData as $index=>$value) { + $xmlCreator->add_tag($index, $value); + } + $extraAttributes = array( + 'generated' => date('Y-m-d H:m:s'), + 'version' => $myData['version_string'] + ); + $xmlCreator->add_attribute('/config', $extraAttributes); + + //now, create an XML string... + $xmlString = $xmlCreator->create_xml_string(); + + $this->fsObj->create_file(CONFIG_FILENAME, TRUE); + $writeRes = $this->fsObj->write($xmlString, CONFIG_FILENAME); + + if($writeRes > 0) { + $retval = "Successfully created the XML config file"; + store_setup_data(5, 1, 'result'); + store_setup_data(5, $retval, 'text'); + } + else { + throw new exception(__METHOD__ .": failed to write any data to the config file"); + } + } + else { + throw new exception(__METHOD__ .": ". CONFIG_FILE_LOCATION ." already exists!"); + } + } + else { + throw new exception(__METHOD__ .": the config directory is not writable!"); + } + + $configObj = new config(CONFIG_FILE_LOCATION); + $configObj->remove_setup_config(); + + return($retval); + }//end write_config() + //========================================================================= +} + + +//####################################################################################### +/** + * Built to avoid always printing-out the results (so we can retrieve result data separately. + */ +class MyDisplay extends SimpleReporter { + + function paintHeader($test_name) { + } + + function paintFooter($test_name) { + } + + function paintStart($test_name, $size) { + parent::paintStart($test_name, $size); + } + + function paintEnd($test_name, $size) { + parent::paintEnd($test_name, $size); + } + + function paintPass($message) { + parent::paintPass($message); + } + + function paintFail($message) { + parent::paintFail($message); + } +} +//####################################################################################### + + +class unitTest extends UnitTestCase { + + function testOfTester () { + $this->assertTrue(FALSE); + } +} + ?> Modified: trunk/1.2/includes/setup.inc =================================================================== --- trunk/1.2/includes/setup.inc 2008-07-21 02:17:54 UTC (rev 899) +++ trunk/1.2/includes/setup.inc 2008-07-21 03:20:21 UTC (rev 900) @@ -18,13 +18,10 @@ //create the setup object. require_once(dirname(__FILE__) .'/../lib/simpletest/unit_tester.php'); require_once(dirname(__FILE__) .'/../lib/simpletest/reporter.php'); -require_once(dirname(__FILE__) .'/../lib/setup.class.php'); $configObj = new config(NULL, FALSE); $configData = $configObj->read_config_file(FALSE); -$setupObj = new setup($page); - if(strlen($configData['DATABASE__DBNAME'])) { //setup already complete. Stop 'em. $page->set_message_wrapper(array( @@ -61,7 +58,7 @@ $page->conditional_header("/setup/". $_SESSION['setup']['lastStep'], TRUE); } elseif(count($sectionArr) == 2 && is_numeric($sectionArr[1]) && $sectionArr[1] != 1) { - if(!is_numeric($setupObj->get_setup_data($sectionArr[1], 'accessible'))) { + if(!is_numeric(get_setup_data($sectionArr[1], 'accessible'))) { $page->set_message_wrapper( array( 'title' => "Incomplete Step", @@ -74,7 +71,7 @@ } - $page->add_template_var("VERSION_STRING", $setupObj->read_version_file()); + $page->add_template_var("VERSION_STRING", read_version_file()); $page->rip_all_block_rows('stepData'); $page->clear_content('infobar'); @@ -85,12 +82,12 @@ $tmplStepTitle = "Main Setup Screen"; foreach($stepNames as $num=>$name) { - $stepResult = $setupObj->get_setup_data($num, 'result'); + $stepResult = get_setup_data($num, 'result'); if(!is_numeric($stepResult)) { $passFail = "Incomplete"; $bgColor = "yellow"; - if(strlen($setupObj->get_setup_data($num, 'text'))) { - $stepText = $setupObj->get_setup_data($num, 'text'); + if(strlen(get_setup_data($num, 'text'))) { + $stepText = get_setup_data($num, 'text'); } else { $stepText = "Step incomplete..."; @@ -100,14 +97,14 @@ $passFail = interpret_bool($stepResult, array('FAIL', 'Pass')); $bgColor = interpret_bool($stepResult, array('red', 'green')); - if(strlen($setupObj->get_setup_data($num, 'text'))) { - $stepText = $setupObj->get_setup_data($num, 'text'); + if(strlen(get_setup_data($num, 'text'))) { + $stepText = get_setup_data($num, 'text'); } else { $stepText = " "; } - $setupObj->store_setup_data($num, 1, 'accessible'); + store_setup_data($num, 1, 'accessible'); if($passFail == 'Pass') { $_SESSION['setup']['lastStep'] = $num; } @@ -134,4 +131,144 @@ $page->add_template_var('step_data_row', $myRows); } +//============================================================================= +function store_setup_data($step, $data, $type='data') { + $_SESSION['setup'][$type][$step] = $data; +}//end store_setup_data() +//============================================================================= + + + +//============================================================================= +function get_setup_data($step, $type='data') { + return($_SESSION['setup'][$type][$step]); +}//end get_setup_data() +//============================================================================= + + + +//============================================================================= +function read_version_file() { + $retval = NULL; + $fsObj = new cs_fileSystemClass(dirname(__FILE__) .'/..'); + + //okay, all files present: check the version in the VERSION file. + $lines = $fsObj->read('VERSION', TRUE); + $versionLine = $lines[2]; + if(preg_match('/^VERSION: /', $versionLine)) { + + $retval = trim(preg_replace('/VERSION: /', '', $versionLine)); + } + else { + throw new exception(__METHOD__ .": could not find VERSION data"); + } + + return($retval); +}//end read_version_file() +//============================================================================= + + + +//============================================================================= +function get_db_params() { + + $stepOneData = get_setup_data(1, 'data'); + if(is_array($stepOneData)) { + $params = array(); + foreach($stepOneData as $name=>$value) { + $index = preg_replace('/^database__/', '', $name); + $params[$index] = $value; + } + } + else { + throw new exception(__FUNCTION__ .": unable to retrieve step one data..."); + } + + return($params); +}//end get_db_params() +//============================================================================= + + + +//============================================================================= +function reset_all_steps($leaveText=TRUE, $afterStep=NULL) { + $retval=0; + if(is_array($_SESSION['setup'])) { + if(is_numeric($afterStep)) { + $_SESSION['setup']['lastStep'] = $afterStep; + } + else { + $_SESSION['setup']['lastStep'] = 1; + } + $unsetThis = array('data', 'result', 'accessible'); + + if($leaveText !== TRUE) { + $unsetThis[] = 'text'; + } + foreach($unsetThis as $indexName) { + if(isset($_SESSION['setup'][$indexName])) { + if(is_numeric($afterStep)) { + foreach($_SESSION['setup'][$indexName] as $stepNum=>$stepData) { + if(is_numeric($stepNum) && $stepNum > $afterStep) { + unset($_SESSION['setup'][$indexName][$stepNum]); + $retval++; + } + } + } + else { + unset($_SESSION['setup'][$indexName]); + $retval++; + } + } + } + } + else { + throw new exception(__FUNCTION__ .": no step data found in session"); + } + + return($retval); +}//end reset_all_steps() +//============================================================================= + + + +//============================================================================= +function test_db_stuff(cs_phpDB &$db=NULL) { + if(is_null($db) || !is_object($db)) { + $db = new cs_phpDB; + } + $stepOneData = get_setup_data(1); + $params = get_db_params(); + $originalParams = $params; + + + + $params['dbname'] = 'template1'; + $retval = "Failed to connect to ". $params['host'] .":". $params['dbname'] ." (host connection failed)"; + + $gf = new cs_globalFunctions; + + try { + $db->connect($params); + $result = "Connected successfully to ". $params['host'] .":". $params['dbname'] ." (host connection good)"; + try { + $newParams = $originalParams; + $db2 = new cs_phpDB; + $db2->connect($originalParams ); + $retval = "Connected successfully to ". $newParams['host'] .":". $newParams['dbname'] ." (host connection good, DATABASE EXISTS)"; + } + catch(exception $e) { + //no database! + //TODO: do a preg_match() on $e->getMessage() to see if it says something about the database not existing + $retval = TRUE; + } + } + catch(exception $e) { + $retval = $e->getMessage(); + } + + return($retval); +}//end test_db_stuff() +//============================================================================= + ?> \ No newline at end of file Deleted: trunk/1.2/lib/setup.class.php =================================================================== --- trunk/1.2/lib/setup.class.php 2008-07-21 02:17:54 UTC (rev 899) +++ trunk/1.2/lib/setup.class.php 2008-07-21 03:20:21 UTC (rev 900) @@ -1,1637 +0,0 @@ -<?php -/* - * SVN INFORMATION::: - * ------------------ - * SVN Signature::::::: $Id$ - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - */ - - -require_once(dirname(__FILE__) .'/../lib/simpletest/unit_tester.php'); -require_once(dirname(__FILE__) .'/../lib/simpletest/reporter.php'); - - -class setup { - - private $pageObj; - private $dbObj; - - //============================================================================= - function __construct(cs_genericPage $page, cs_phpDB $db=NULL) { - $this->pageObj = $page; - - //TODO: determine what step we're on (if > 1, can connect db) - try { - $connectionParams = $this->get_db_params(); - - //TODO: make this a setup parameter (so we can integrate with mysql). - $this->dbObj = new cs_phpDB('pgsql'); - $this->dbObj->connect($connectionParams); - } - catch(exception $e) { - } - }//end __construct() - //============================================================================= - - - - //============================================================================= - function store_setup_data($step, $data, $type='data') { - $_SESSION['setup'][$type][$step] = $data; - }//end store_setup_data() - //============================================================================= - - - - //============================================================================= - function get_setup_data($step, $type='data') { - return($_SESSION['setup'][$type][$step]); - }//end get_setup_data() - //============================================================================= - - - - //============================================================================= - function read_version_file() { - $retval = NULL... [truncated message content] |
From: <cra...@us...> - 2008-08-26 03:28:38
|
Revision: 906 http://cs-project.svn.sourceforge.net/cs-project/?rev=906&view=rev Author: crazedsanity Date: 2008-08-26 03:28:35 +0000 (Tue, 26 Aug 2008) Log Message: ----------- Display username on contact details (where applicable). /includes/content/contacts.inc: * when displaying contact information, display the username. /lib/userClass.php: * get_user_info(): -- updated to allow an array as criteria for fine-grained searching. -- NOTE: allowable fields should be limited to avoid database errors. /templates/content/contacts/view.contact.tmpl: * new block row in static display to show username. Modified Paths: -------------- trunk/1.2/includes/content/contacts.inc trunk/1.2/lib/userClass.php trunk/1.2/templates/content/contacts/view.content.tmpl Modified: trunk/1.2/includes/content/contacts.inc =================================================================== --- trunk/1.2/includes/content/contacts.inc 2008-08-26 00:43:08 UTC (rev 905) +++ trunk/1.2/includes/content/contacts.inc 2008-08-26 03:28:35 UTC (rev 906) @@ -141,10 +141,19 @@ if(is_numeric($contactId)) { try{ + $page->rip_all_block_rows(); + + $contactObj->set_contact_id($contactId); $contactDetails = $contactObj->get_contact(); - $page->rip_all_block_rows(); + $userDetails = $user->get_user_info(array('contact_id'=>$contactId)); + if(is_array($userDetails)) { + $contactDetails['username'] = $userDetails['username']; + $page->add_template_var('display_username', $page->templateRows['display_username']); + } + + //set the main details. foreach($contactDetails as $name=>$value) { $page->add_template_var($name, $value); Modified: trunk/1.2/lib/userClass.php =================================================================== --- trunk/1.2/lib/userClass.php 2008-08-26 00:43:08 UTC (rev 905) +++ trunk/1.2/lib/userClass.php 2008-08-26 03:28:35 UTC (rev 906) @@ -155,17 +155,20 @@ function get_user_info($findThis) { $retval = 0; - if(isset($findThis) && strlen($findThis)) { - $findThis = strtolower($findThis); + if(isset($findThis) && (strlen($findThis) || is_array($findThis))) { if(is_numeric($findThis)) { $criteria = "uid = $findThis"; } + elseif(is_array($findThis)) { + $criteria = $this->gfObj->string_from_array($findThis, 'select', NULL, 'sql'); + } else { + $findThis = strtolower($findThis); $criteria = "lower(username) = '$findThis'"; } - $query = "SELECT * from user_table WHERE $criteria"; + $query = "SELECT * from user_table WHERE ". $criteria; $numrows = $this->db->exec($query); $dberror = $this->db->errorMsg(); Modified: trunk/1.2/templates/content/contacts/view.content.tmpl =================================================================== --- trunk/1.2/templates/content/contacts/view.content.tmpl 2008-08-26 00:43:08 UTC (rev 905) +++ trunk/1.2/templates/content/contacts/view.content.tmpl 2008-08-26 03:28:35 UTC (rev 906) @@ -1,4 +1,3 @@ - <form method="POST" onSubmit="new Effect.DropOut(submitButton);" name="updateContactForm"> <input type="HIDDEN" name="contact_id" value="{contact_id}"> <div id="mainContact_static" style="display:inline;"> @@ -7,6 +6,9 @@ <td style="border:solid #000 1px; "> <h1 style="display:inline">{company}</h1><BR> <center><div style="display:inline;text-align:center;">{fname} {lname} (<i>{email}</i>)</div></center> + <!-- BEGIN display_username --> + <center><div style="display:inline;text-align:center;">Username: {username}</div></center> + <!-- END display_username --> </td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-04 19:10:01
|
Revision: 922 http://cs-project.svn.sourceforge.net/cs-project/?rev=922&view=rev Author: crazedsanity Date: 2009-02-04 19:09:54 +0000 (Wed, 04 Feb 2009) Log Message: ----------- Fix tabs to not have spaces under corners, change admin link to a new tab. /includes/content.inc: * move "tags" so it is the last tab in the list. * remove code that adds link to "settings" tab. * code to create admin tab (and select it as needed) if they're an admin. /public_html/css/common.css: * remove vertical alignment setting for table cells (was set to "top") /templates/infobar.shared.tmpl: * remove some extra lines so things are separated nicely * add spacing to left and right of tabs (like tabs.shared.tmpl) * valign=middle on cells containing text/url * remove " " from corner cells to remove spacing beneath image /templates/tabs.shared.tmpl: * add spacing to left and right of tabs * valign=middle on cells containing text/url * remove " " from corner cells to remove spacing beneath image Modified Paths: -------------- trunk/1.2/includes/content.inc trunk/1.2/public_html/css/common.css trunk/1.2/templates/infobar.shared.tmpl trunk/1.2/templates/tabs.shared.tmpl Modified: trunk/1.2/includes/content.inc =================================================================== --- trunk/1.2/includes/content.inc 2009-02-04 18:37:17 UTC (rev 921) +++ trunk/1.2/includes/content.inc 2009-02-04 19:09:54 UTC (rev 922) @@ -127,16 +127,11 @@ 'summary' => "Summary", 'project' => "Projects", 'helpdesk' => "Helpdesk", - 'tags' => "Tags", 'contacts' => "Contacts", 'settings' => "Settings", + 'tags' => "Tags", ); -if($user->is_admin()) { - $tabNames['settings'] = "Settings</a><BR>\n<a href=\"/content/settings/admin\"><b>[Admin]</b>"; -} - -#$page->add_template_var('tabs', $page->file_to_string('tabs.shared.tmpl')); $tabObj = new cs_tabs($page); foreach($tabNames as $moduleName=>$name) { $tabUrl = "/content/". $moduleName; @@ -146,6 +141,14 @@ } $tabObj->add_tab($name, $tabUrl); } + +if($user->is_admin()) { + $name = "Admin"; + $tabObj->add_tab($name, "/content/settings/admin"); + if(count($page->ftsSections) == 3 && $page->ftsSections[2] == 'admin') { + $tabObj->select_tab($name); + } +} $tabObj->display_tabs(); Modified: trunk/1.2/public_html/css/common.css =================================================================== --- trunk/1.2/public_html/css/common.css 2009-02-04 18:37:17 UTC (rev 921) +++ trunk/1.2/public_html/css/common.css 2009-02-04 19:09:54 UTC (rev 922) @@ -1,6 +1,6 @@ body, a, li { font-size: 8pt; font-family: helvetica, sans-serif; text-decoration:none; } a:visited {color: #0000FF; } -td {font-size: 8pt; font-family: helvetica, sans-serif; text-decoration:none; vertical-align:top; } +td {font-size: 8pt; font-family: helvetica, sans-serif; text-decoration:none; } form {margin:0; padding:0;} input, textarea { background-color: #F5F5F5; font-family: courier, sans-serif; font-size: 8pt; } Modified: trunk/1.2/templates/infobar.shared.tmpl =================================================================== --- trunk/1.2/templates/infobar.shared.tmpl 2009-02-04 18:37:17 UTC (rev 921) +++ trunk/1.2/templates/infobar.shared.tmpl 2009-02-04 19:09:54 UTC (rev 922) @@ -22,16 +22,12 @@ <table border="0" cellpadding=0 cellspacing=0> <tr> {tabs} + <td valign=top align="right" style="padding-left:1px;"><img src='/images/tab_left_inactive.gif' border='0' height="100%"></td> + <td id='notselected' valign="middle"><a id='notselected' href='/login.php?logout=1' target='_top'>Logout</a></td> + <td valign=top style="padding-right:1px;"><img src='/images/tab_right_inactive.gif' border='0' height="100%"></td> - <td valign=top align="right"><img src='/images/tab_left_inactive.gif' border='0' height="100%"></td> - - <td id='notselected' valign=top><a id='notselected' href='/login.php?logout=1' target='_top'>Logout</a></td> - - <td valign=top><img src='/images/tab_right_inactive.gif' border='0' height="100%"> </td> - - <td valign=top align="right"><img src='/images/tab_left_inactive.gif' border='0' height="100%"></td> - - <td id='notselected' valign=top><input type=hidden name='module' value='projects'> + <td valign=top align="right" style="padding-left:1px;"><img src='/images/tab_left_inactive.gif' border='0' height="100%"></td> + <td id='notselected' valign="middle"><input type=hidden name='module' value='projects'> <form action="/content" method=get> <input type="hidden" name="version" value="{cs-project_version}"> <select name=changeGroup onchange='document.forms[0].submit()'> @@ -39,8 +35,7 @@ </select> </form> </td> - - <td valign=top><img src='/images/tab_right_inactive.gif' border='0' height="100%"> </td> + <td valign=top style="padding-right:1px;"><img src='/images/tab_right_inactive.gif' border='0' height="100%"></td> </tr> </table> </td> Modified: trunk/1.2/templates/tabs.shared.tmpl =================================================================== --- trunk/1.2/templates/tabs.shared.tmpl 2009-02-04 18:37:17 UTC (rev 921) +++ trunk/1.2/templates/tabs.shared.tmpl 2009-02-04 19:09:54 UTC (rev 922) @@ -1,11 +1,11 @@ <!-- BEGIN selected_tab --> - <td valign=top align="right"><img src='/images/tab_left_active.gif' border='0' height="100%"></td> - <td id='selected' valign=top><a id='selected' href='%%url%%' target='_top'>%%title%%</a></td> - <td valign=top><img src='/images/tab_right_active.gif' border='0' height="100%"> </td> + <td valign=top align="right" style="padding-left:1px;"><img src='/images/tab_left_active.gif' border='0' height="100%"></td> + <td id='selected' valign="middle"><a id='selected' href='%%url%%' target='_top'>%%title%%</a></td> + <td valign=top style="padding-right:1px;"><img src='/images/tab_right_active.gif' border='0' height="100%"></td> <!-- END selected_tab --> <!-- BEGIN unselected_tab --> <td valign=top align="right"><img src='/images/tab_left_inactive.gif' border='0' height="100%"></td> - <td id='notselected' valign=top><a id='notselected' href='%%url%%' target='_top'>%%title%%</a></td> - <td valign=top><img src='/images/tab_right_inactive.gif' border='0' height="100%"> </td> + <td id='notselected'><div style="text:align=middle"><a id='notselected' href='%%url%%' target='_top'>%%title%%</a></td> + <td valign=top style="padding-right:1px;"><img src='/images/tab_right_inactive.gif' border='0' height="100%"></td> <!-- END unselected_tab --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-05 17:41:53
|
Revision: 925 http://cs-project.svn.sourceforge.net/cs-project/?rev=925&view=rev Author: crazedsanity Date: 2009-02-05 17:41:48 +0000 (Thu, 05 Feb 2009) Log Message: ----------- Partial implementation for single action button on issues (#99). NOTE: there are still some display issues to work out, but the code properly handles updates, remarks, solving, or any combination thereof. A future commit will fix the display issue (shows a remark box when the issue is solved). NOTE2: there is currently no handling of whether the person looking at the issue has any authority to do anything to it; I believe at one point only the owner could make modifications or solve it... this make come back in the future... /includes/content/helpdesk.inc: * "submit" action (for $_POST) handles updates, remarks, and solutions. * there was a segment involving change of ancestry, but it doesn't seem to have ever been called. * the updates, remarks, solving, etc all happen in a big transaction: if one part fails, the whole thing fails. Not sure about sending emails; that is probably out of the scope of this fix... * updated one comment so it's easier to tell what it is supposed to do. /templates/content/helpdesk/view.content.tmpl: * dropped the solution row * replaced the remark/modify/solve buttons with a single "submit" button. * added a checkbox for "isSolution". Modified Paths: -------------- trunk/1.2/includes/content/helpdesk.inc trunk/1.2/templates/content/helpdesk/view.content.tmpl Modified: trunk/1.2/includes/content/helpdesk.inc =================================================================== --- trunk/1.2/includes/content/helpdesk.inc 2009-02-05 16:36:30 UTC (rev 924) +++ trunk/1.2/includes/content/helpdesk.inc 2009-02-05 17:41:48 UTC (rev 925) @@ -22,23 +22,36 @@ ); } $byPassUrlExtras = FALSE; - if($action) { + if(strlen($action)) { - if($action == "modify") { - //update the ancestry... - $_POST['updates']['parentRecordId'] = $_POST['updates']['project_id']; - unset($_POST['updates']['project_id']); + if($action == "submit") { + $proj->helpdeskObj->db->beginTrans(); + //SETUP THE MESSAGE THEY'LL SEE... + $setMessage = array( + "title" => "", + "message" => "... SET ME!!! ...", + "type" => "error" + ); + $success = false; + $remarks = array(); + + $oldData = $proj->helpdeskObj->get_record($helpdeskId); + + + ################################# + # ---------> BEGIN "update" + ################################# + + //if they've changed the name, we gotta log it. //TODO: probably log this within helpdeskClass::update(). - if(isset($_POST['updates']['name'])) { - //retrieve the old info. - $oldData = $proj->helpdeskObj->get_record($_POST['id']); - - if($oldData['name'] !== $_POST['updates']['name']) { - $addRemark = 'Updated [b]name[/b] from ([b][i]'. $oldData['name'] .'[/i][/b])'; - } + if(isset($_POST['updates']['name']) && $oldData['name'] !== $_POST['updates']['name']) { + $remarks[] = array( + "remark" => 'Updated [b]name[/b] from ([b][i]'. $oldData['name'] .'[/i][/b])', + false + ); } $doNotAcceptFields = array("solution", "remark"); @@ -47,72 +60,107 @@ } $result = $proj->helpdeskObj->update_record($helpdeskId, $_POST['updates']); - if(strlen($addRemark)) { - $proj->helpdeskObj->remark($_POST['id'], $addRemark); - } - - //tell them what happened. + //SET/UPDATE THE TYPE OF MESSAGE THAT WILL DISPLAY... if($result == 1) { - set_message_wrapper(array( - "title" => "Update Successful", - "message" => "Your issue was updated successfully.", - "type" => "status" - )); + $success = true; + $messageTitle[] = "Updated"; + $messageText[] = "Your issue was updated successfully."; } else { - set_message_wrapper(array( - "title" => "Update FAILURE", - "message" => "Update returned [$result]. Last error was [". $proj->helpdeskObj->lastError ."]", - "type" => "error" - )); + #$setMessage['type'] = "error"; + $success = false; } - $urlSection = "view"; - } - elseif($action == "remark") { - $helpdeskData = $proj->helpdeskObj->get_record($helpdeskId); - //only care about the remark data... if they changed something, well... they're stupid. - $useRespondLink = FALSE; - if($helpdeskData['email'] != $_SESSION['email']) { - $useRespondLink = $proj->helpdeskObj->create_md5($helpdeskId); - } - $result = $proj->helpdeskObj->remark($helpdeskId, $_POST['remark'], FALSE, $useRespondLink); - if($result > 0) { - set_message_wrapper(array( - "title" => "Remark Added Successfully", - "message" => "Your thoughts have been dually noted in the database... or at least singly. :D", - "type" => "status" - )); + ################################# + # ---------> BEGIN "remark/solve" + ################################# + if($success === true && strlen($_POST['remark'])) { + //now check remark stuff. + $useRespondLink = FALSE; + if($_POST['isSolution']) { + //IT'S A SOLUTION + //solve it & make sure they know if it was good or not. + #$result = $proj->helpdeskObj->solve($helpdeskId, $_POST['solution']); + $remarks[] = array( + 'remark' => $_POST['remark'], + 'isSolution' => true + ); + $extra = NULL; + + if($result == 1 && $success === true) { + $messageTitle[] = "Solved"; + $messageText[] = "Your solution was logged, and the issue was updated accordingly. Confirmation emails have been sent."; + } + } + else { + //JUST A REMARK... + if($oldData['email'] != $_SESSION['email']) { + $useRespondLink = $proj->helpdeskObj->create_md5($helpdeskId); + } + $remarks[] = array( + 'remark' => $_POST['remark'], + 'isSolution' => false, + 'link' => $useRespondLink + ); + + if($result > 0) { + $success = true; + $messageTitle[] = "Remarked Upon"; + $messageText[] = "Your thoughts have been dually noted in the database... or at least singly. :D"; + } + }//end REMARK } + + if($success) { + //TODO: this is where a queued email system would be good; if the first remark succeeds but the second fails, this will generate an erroneous email. + if(count($remarks)) { + foreach($remarks as $num=>$remarkData) { + $result = $proj->helpdeskObj->remark($helpdeskId, $remarkData['remark'], $remarkData['isSolution'], $remarkData['link']); + if($result <= 0) { + $success = false; + break; + } + } + } + + if($success === true) { + $proj->helpdeskObj->db->commitTrans(); + //format the message so it looks nice... + $setMessage['message'] = ""; + if(count($messageTitle) > 2) { + $lastMessage = array_pop($setMessage); + $setMessage['title'] = $page->gfObj->string_from_array($messageTitle, null, ", "); + $setMessage['title'] .= " and ". $lastMessage; + } + else { + $setMessage['title'] = $page->gfObj->string_from_array($messageTitle, null, " and "); + } + $setMessage['message'] = $page->gfObj->string_from_array($messageText, null, "<BR>\n"); + $setMessage['type'] = "status"; + } + else { + $proj->helpdeskObj->db->rollbackTrans(); + $setMessage = array( + 'title' => "Update FAILED", + 'message' => "The update would have worked, but you didn't put enough information into your remark.", + 'type' => "error" + ); + } + } else { - set_message_wrapper(array( - "title" => "Unable to Add Remark", - "message" => "Dually noted, summarily denied. Beotch.", - "type" => "error" - )); + $proj->helpdeskObj->db->rollbackTrans(); + $setMessage = array( + 'title' => "Update FAILED", + 'message' => "Update returned [". $result ."]. Last error was [". $proj->helpdeskObj->lastError ."]", + 'type' => "error" + ); } - } - elseif($action == "solve") { - //solve it & make sure they know if it was good or not. - $result = $proj->helpdeskObj->solve($helpdeskId, $_POST['solution']); - $extra = NULL; - if($result == 1) { - set_message_wrapper(array( - "title" => "Solved Successfully", - "message" => "Your solution was logged, and the issue was updated accordingly. Confirmation emails " . - "have been sent.", - "type" => "status" - )); - } - else { - set_message_wrapper(array( - "title" => "Unable to Solve", - "message" => "Try using a longer explanation... or check the error log.", - "type" => "error" - )); - } + #$page->gfObj->debug_print($_POST,1); + #$page->gfObj->debug_print($setMessage,1); + #exit; + $page->set_message_wrapper($setMessage); } elseif($action == "filter") { if($_POST['reset_filter']) { @@ -410,6 +458,7 @@ } else { + //DISPLAY ALL AVAILABLE HELPDESK ISSUES. //change the content of the page properly. $page->set_all_block_rows("content", array("helpdesk_search")); Modified: trunk/1.2/templates/content/helpdesk/view.content.tmpl =================================================================== --- trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-02-05 16:36:30 UTC (rev 924) +++ trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-02-05 17:41:48 UTC (rev 925) @@ -213,13 +213,6 @@ </td> </tr> <!-- END remark_row --> -<!-- BEGIN solution_row --> -<tr> - <td colspan="3">Solution: <br> - <textarea name="solution" rows="10" cols="80" {solution_readonly}></textarea> - </td> -</tr> -<!-- END solution_row --> <!-- BEGIN reopen_button --> <tr> <td> </td> @@ -228,21 +221,16 @@ <!-- END reopen_button --> <!-- BEGIN buttons_row --> <tr> - <td colspan="3"><i>(Changes only take effect when clicking "modify", while "solve" only cares about the solution field, and "remark" only cares about the remarks field.)</i></td> -</tr> -<tr> - <td colspan="3"> - <input name="action" value="Remark" type="submit"> -<!-- BEGIN update_button --> - <input name="action" value="Modify" type="submit"> -<!-- END update_button --> -<!-- BEGIN owner_options --> - <input name="action" value="solve" type="submit"> -<!-- END owner_options --> + <td colspan="3" align="center"> + <input name="action" value="Submit" type="submit"> <a href="/help/helpdesk/submit_buttons" target="_blank"> <img src="/images/icon-help.png" border="0"></a> + + <BR> + Is this a <b>Solution</b>? + <input name="isSolution" type="checkbox"> </td> </tr> <!-- END buttons_row --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-05 18:08:04
|
Revision: 926 http://cs-project.svn.sourceforge.net/cs-project/?rev=926&view=rev Author: crazedsanity Date: 2009-02-05 18:07:59 +0000 (Thu, 05 Feb 2009) Log Message: ----------- Minor layout changes. /includes/login.inc: * updates new "MAINTABLE_EXTRA" so it is center-aligned. /templates/header.shared.tmpl: * set the table holding the infobar & MAIN_error_message to have padding. /templates/main.shared.tmpl: * put content into a table with left padding (and a "MAINTABLE_EXTRA" var in the table declaration, so it can be changed on a per-page basis). Modified Paths: -------------- trunk/1.2/includes/login.inc trunk/1.2/templates/header.shared.tmpl trunk/1.2/templates/main.shared.tmpl Modified: trunk/1.2/includes/login.inc =================================================================== --- trunk/1.2/includes/login.inc 2009-02-05 17:41:48 UTC (rev 925) +++ trunk/1.2/includes/login.inc 2009-02-05 18:07:59 UTC (rev 926) @@ -16,6 +16,7 @@ $page->db = &$db; $page->add_template_var('cs-project_version', VERSION_STRING); +$page->add_template_var('MAINTABLE_EXTRA', 'align="center"'); if(isset($_GET['loginDestination']) && strlen($_GET['loginDestination'])) { $_SESSION['loginDestination'] = $_GET['loginDestination']; Modified: trunk/1.2/templates/header.shared.tmpl =================================================================== --- trunk/1.2/templates/header.shared.tmpl 2009-02-05 17:41:48 UTC (rev 925) +++ trunk/1.2/templates/header.shared.tmpl 2009-02-05 18:07:59 UTC (rev 926) @@ -10,7 +10,7 @@ <body bgcolor="#e0e0e0" style="margin:1px" {HTMLBODY_EXTRA}> -<table> +<table style="padding-left:2em"> <tr> <td> {infobar} Modified: trunk/1.2/templates/main.shared.tmpl =================================================================== --- trunk/1.2/templates/main.shared.tmpl 2009-02-05 17:41:48 UTC (rev 925) +++ trunk/1.2/templates/main.shared.tmpl 2009-02-05 18:07:59 UTC (rev 926) @@ -1,3 +1,9 @@ {header} -{content} +<table border="0" cellpadding="0" cellspacing="0" style="padding-left:1em" {MAINTABLE_EXTRA}> + <tr> + <td> + {content} + </td> + </tr> +</table> {footer} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-06 19:20:13
|
Revision: 934 http://cs-project.svn.sourceforge.net/cs-project/?rev=934&view=rev Author: crazedsanity Date: 2009-02-06 19:20:09 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Fix display issue with notes deforming the page layout (#249). /public_html/css/common.css: * added helpdesk_comment_header and helpdesk_comment_body styles. /templates/content/helpdesk/view.content.tmpl: * widen the issue title to 750 from 650 (works fine on 1024x768 or better) * give comment header new CSS class (helpdesk_comment_header) * give comment body new CSS class (helpdesk_comment_body) -- the old style was setting the width to be 100%, which is what deformed the page. Modified Paths: -------------- trunk/1.2/public_html/css/common.css trunk/1.2/templates/content/helpdesk/view.content.tmpl Modified: trunk/1.2/public_html/css/common.css =================================================================== --- trunk/1.2/public_html/css/common.css 2009-02-06 18:25:22 UTC (rev 933) +++ trunk/1.2/public_html/css/common.css 2009-02-06 19:20:09 UTC (rev 934) @@ -56,4 +56,18 @@ padding-left:20px; background-color: white; border: dashed #000 1px; +} + +/* Helpdesk Styles */ +.helpdesk_comment_header { + border-top:dashed #000 1px; + padding-bottom:1em; + border-left:solid #000 1px; +} +.helpdesk_comment_body { + width:750; + overflow:auto; + padding-bottom:1em; + border-left:solid #000 1px; + padding-left:1em; } \ No newline at end of file Modified: trunk/1.2/templates/content/helpdesk/view.content.tmpl =================================================================== --- trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-02-06 18:25:22 UTC (rev 933) +++ trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-02-06 19:20:09 UTC (rev 934) @@ -184,7 +184,7 @@ <th style="border-bottom:solid #000 1px;" align="right">Issue Text:</th> - <td style="border-bottom:solid #000 1px;" width="650" colspan="2" nowrap><code>{subject}</code></td> + <td style="border-bottom:solid #000 1px;" width="750" colspan="2" nowrap><font size="+1">{subject}</font></td> </tr> <tr> <th>Tasks:</th> @@ -197,10 +197,10 @@ <th style="border-bottom:solid #000 1px;" align="right">Comments:<BR><font size="-3"><i>(Includes previous/current<BR>solution(s), if available)</i></font></th> <td style="border-bottom:solid #000 1px;" colspan="2"> <!-- BEGIN issueNotes --> - <div style="border-top:dashed #000 1px;"> + <div class="helpdesk_comment_header"> %%solutionIndicator%% <u> [#%%note_id%%] <b>%%subject%%</b> (%%fname%%@%%created%%)</u> - </div><br> - <div style="width:100%; overflow:auto"><code style="font-size:10px;">%%body%%</code></div> + </div> + <div class="helpdesk_comment_body">%%body%%</div> <!-- END issueNotes --> </td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-06 19:48:33
|
Revision: 936 http://cs-project.svn.sourceforge.net/cs-project/?rev=936&view=rev Author: crazedsanity Date: 2009-02-06 19:48:26 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Remove more test files... Removed Paths: ------------- trunk/1.2/includes/test.inc trunk/1.2/templates/test/ Deleted: trunk/1.2/includes/test.inc =================================================================== --- trunk/1.2/includes/test.inc 2009-02-06 19:41:34 UTC (rev 935) +++ trunk/1.2/includes/test.inc 2009-02-06 19:48:26 UTC (rev 936) @@ -1,79 +0,0 @@ -<?php -/* - * Created on Dec 13, 2007 - * - * SVN INFORMATION::: - * ------------------ - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - - */ - - -$invoiceData = array( - 'invoice_id' => '10015', - 'poc' => 'Johnny Jackson', - 'company' => 'Llama Soft, Inc.', - 'address1' => '1555 North Georgia Ave.', - 'address2' => 'Suite 1411', - 'phone' => '(701) 555-3389 ext. 1911', - 'fax' => '(701) 555-9193', - 'city' => 'St. Louis', - 'state' => 'Missouri', - 'zip' => '55454' -); - -$invoiceItemData = array( - 91 => array( - 'invoice_item_id' => 91, - 'invoice_id' => 10015, - 'description' => 'Contract Downpayment', - 'unit_price' => 3000, - 'quantity' => 1 - ), - 93 => array( - 'invoice_item_id' => 93, - 'invoice_id' => 10015, - 'description' => 'Remote Software Development', - 'unit_price' => 75, - 'quantity' => 40 - ), - 94 => array( - 'invoice_item_id' => 94, - 'invoice_id' => 10015, - 'description' => 'Remote Software Development (overtime hours)', - 'unit_price' => 112.5, - 'quantity' => 12 - ) -); - - -$gf = new cs_globalFunctions; -$gf->debugPrintOpt = 1; - -$gf->debug_print("Here is the main invoice data::: ". $gf->debug_print($invoiceData,0)); - -$blockRows = $page->rip_all_block_rows(); - -if(!count($blockRows)) { - $gf->debug_print("Here's what I could find for block rows (should be more than just an empty array)::: ". $gf->debug_print($page->get_block_row_defs('content'),0)); - throw new exception("You forgot to give me valid block rows for parsing invoice items!"); -} -else { - $gf->debug_print("Here's the items that will be parsed into the rows::: ". $gf->debug_print($invoiceItemData,0)); - foreach($invoiceData as $index=>$value) { - $page->add_template_var($index, $value); - } - - //I have no idea how this will work when I don't know what the name of the block row is. - $tmplRow = array_pop($blockRows); - $allParsedRows = ""; - - foreach($invoiceItemData as $itemId=>$subData) { - $allParsedRows .= $page->gfObj->mini_parser($tmplRow, $subData, '{', '}'); - } -} - -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-09 15:54:31
|
Revision: 950 http://cs-project.svn.sourceforge.net/cs-project/?rev=950&view=rev Author: crazedsanity Date: 2009-02-09 15:54:29 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Fix problem where issues unable to be solved (#250) & remove unneeded code. /includes/content/helpdesk/view.inc: * removed some commented-out code that was unnecessary when solving. * removed debugging code for consolidating submit button & setting message... * removed the "action==create" section; that's a different include altogether * removed code regarding "owner" code (the block rows within the check don't even exist anymore, so it doesn't make any difference) * remove code for updating project associations (commented-out) /lib/helpdeskClass.php: * remark(): -- set $this->helpdeskId for solve(). -- only check $isSolution to determine if solve() should be called -- remove solve() from email check. -- remove debug_print() before return statement. Modified Paths: -------------- trunk/1.2/includes/content/helpdesk/view.inc trunk/1.2/lib/helpdeskClass.php Modified: trunk/1.2/includes/content/helpdesk/view.inc =================================================================== --- trunk/1.2/includes/content/helpdesk/view.inc 2009-02-07 19:54:15 UTC (rev 949) +++ trunk/1.2/includes/content/helpdesk/view.inc 2009-02-09 15:54:29 UTC (rev 950) @@ -78,8 +78,6 @@ $useRespondLink = FALSE; if($_POST['isSolution']) { //IT'S A SOLUTION - //solve it & make sure they know if it was good or not. - #$result = $proj->helpdeskObj->solve($helpdeskId, $_POST['solution']); $remarks[] = array( 'remark' => $_POST['remark'], 'isSolution' => true @@ -155,9 +153,6 @@ ); } - #$page->gfObj->debug_print($_POST,1); - #$page->gfObj->debug_print($setMessage,1); - #exit; $page->set_message_wrapper($setMessage); } elseif($action == "re-open") { @@ -197,20 +192,7 @@ unset($_SESSION['goBackLink']); } - if($action == "create") { - create_page_title($page, array('title' => "Create a Helpdesk Issue")); - $page->set_all_block_rows("content"); - - //show the "category" selection. - $categoryList = $proj->helpdeskObj->get_category_list('bug', TRUE); - $page->add_template_var("select_tags", $categoryList); - - // - $page->add_template_var("email", $_SESSION['email']); - $page->add_template_var("linked_proj", cleanString($_GET['proj']),"numeric"); - - } - elseif($action == "view" && !is_numeric($helpdeskId)) { + if($action == "view" && !is_numeric($helpdeskId)) { //missing ID: throw a message & send 'em packin'. set_message_wrapper(array( "title" => "Invalid ID Specified", @@ -269,20 +251,6 @@ $doNotRipRows[] = "assigned_optionList"; $doNotRipRows[] = "priority_optionList"; $doNotRipRows[] = "editable_tags"; - if(($assignedStr == $_SESSION['contact_id']) || ($assignedStr == "" || is_null($assignedStr))) { - //well, we can show 'em the update/modify button. - $doNotRipRows[] = "update_button"; - if($_SESSION['contact_id'] == $assignedStr) { - //they're the owner... show 'em more options. - $doNotRipRows[] = "solution_row"; - $doNotRipRows[] = "owner_options"; - } - //if they're the owner, show 'em more options... - } - elseif($_SESSION['isGroupOwner']) { - //we got an OWNER!!! - $doNotRipRows[] = "owner_options"; - } $doNotRipRows[] = "remark_row"; $doNotRipRows[] = "buttons_row"; $doNotRipRows[] = 'accessBlock__modifyButton'; @@ -295,9 +263,6 @@ //keep the set of data allows it to be linked to a project. $doNotRipRows[] = "edit_project_selection"; - - //TODO: implement a link for updating project associations. - #$page->add_template_var("select_project_list", $proj->create_project_option_list($helpdeskData['ancestry'], NULL)); } $doNotRipRows[] = 'update_button'; Modified: trunk/1.2/lib/helpdeskClass.php =================================================================== --- trunk/1.2/lib/helpdeskClass.php 2009-02-07 19:54:15 UTC (rev 949) +++ trunk/1.2/lib/helpdeskClass.php 2009-02-09 15:54:29 UTC (rev 950) @@ -156,6 +156,7 @@ //start a transaction so if one part fails, they all fail. $this->db->beginTrans(); + $this->helpdeskId = $helpdeskId; $tmp = $this->get_record($helpdeskId); $noteObj = new noteClass($this->db); $noteData = array( @@ -209,6 +210,9 @@ $details = 'Sent notification(s) of for [helpdesk_id='. $helpdeskId .'] remark to: '. $sendEmailRes; $this->logsObj->log_by_class($details, 'information', NULL, $this->recordTypeId, $helpdeskId); + if($isSolution) { + $this->solve(); + } if($isSolution && strlen(constant('HELPDESK_ISSUE_ANNOUNCE_EMAIL'))) { $subject = '[ALERT] Helpdesk Issue #'. $helpdeskId .' was SOLVED'; if(strlen($_SESSION['login_username'])) { @@ -218,8 +222,6 @@ $sendEmailRes = send_email(HELPDESK_ISSUE_ANNOUNCE_EMAIL, $subject, $emailTemplate, $parseArr); $details = 'Sent notifications of SOLUTION for [helpdesk_id='. $helpdeskId .'] to: '. $sendEmailRes; $this->logsObj->log_by_class($details, 'information'); - - $this->solve(); } $this->db->commitTrans(); } @@ -230,8 +232,6 @@ } } - $this->gfObj->debug_print(__METHOD__ .": result=(". $retval .")",1); - return($retval); }//end remark() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-09 20:38:44
|
Revision: 955 http://cs-project.svn.sourceforge.net/cs-project/?rev=955&view=rev Author: crazedsanity Date: 2009-02-09 20:38:40 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Fix missing template issue (#253), remove old commented code, cs-content v1.0A8 /includes/content/project/index.inc: * remove call to html_file_to_string() for grep's sake. /includes/extern/helpdesk.inc: * remove call to html_file_to_string() for grep's sake. /lib/config.class.php: * convert_to_sections(): -- remove leading slashes from config vars (#253) /lib/globalFunctions.php: * get_required_external_lib_versions(): -- update to cs-content v1.0-ALPHA8 * html_file_to_string(): -- throw an exception about missing template files instead of setting a message (it can cause misleading messages)(#253). Modified Paths: -------------- trunk/1.2/includes/content/project/index.inc trunk/1.2/includes/extern/helpdesk.inc trunk/1.2/lib/config.class.php trunk/1.2/lib/globalFunctions.php Modified: trunk/1.2/includes/content/project/index.inc =================================================================== --- trunk/1.2/includes/content/project/index.inc 2009-02-09 19:13:13 UTC (rev 954) +++ trunk/1.2/includes/content/project/index.inc 2009-02-09 20:38:40 UTC (rev 955) @@ -29,7 +29,6 @@ } $page->ui->set_cache("expandArr", $expandArr); - #$page->change_content(html_file_to_string("modules/project/project_main.tmpl")); $page->set_all_block_rows("content"); //set some template vars for the filtering. Modified: trunk/1.2/includes/extern/helpdesk.inc =================================================================== --- trunk/1.2/includes/extern/helpdesk.inc 2009-02-09 19:13:13 UTC (rev 954) +++ trunk/1.2/includes/extern/helpdesk.inc 2009-02-09 20:38:40 UTC (rev 955) @@ -211,7 +211,6 @@ //================================================================================================================ $titleSub = "Show All"; //change the content of the page properly. - #$page->change_content(html_file_to_string("modules/helpdesk/helpdesk_main.tmpl")); $page->set_all_block_rows("content", array("helpdesk_search")); $filterData = $page->ui->get_cache("filter"); Modified: trunk/1.2/lib/config.class.php =================================================================== --- trunk/1.2/lib/config.class.php 2009-02-09 19:13:13 UTC (rev 954) +++ trunk/1.2/lib/config.class.php 2009-02-09 20:38:40 UTC (rev 955) @@ -346,11 +346,11 @@ $dataArray['SITE_ROOT']['value'] = '{_DIRNAMEOFFILE_}/..'; $dataArray['SITE_ROOT']['attributes']['cleanpath'] = 1; - //Set some other special values... - { - $dataArray['DOCUMENT_ROOT']['value'] = '{/MAIN/SITE_ROOT}'; - $dataArray['LIBDIR']['value'] = '{/MAIN/SITE_ROOT}/lib'; - $dataArray['TMPLDIR']['value'] = '{/MAIN/SITE_ROOT}/templates'; + + {//Set some other special values... + $dataArray['DOCUMENT_ROOT']['value'] = '{MAIN/SITE_ROOT}'; + $dataArray['LIBDIR']['value'] = '{MAIN/SITE_ROOT}/lib'; + $dataArray['TMPLDIR']['value'] = '{MAIN/SITE_ROOT}/templates'; $dataArray['SEQ_HELPDESK']['value'] = 'special__helpdesk_public_id_seq'; $dataArray['SEQ_PROJECT']['value'] = 'special__project_public_id_seq'; $dataArray['SEQ_MAIN']['value'] = 'record_table_record_id_seq'; Modified: trunk/1.2/lib/globalFunctions.php =================================================================== --- trunk/1.2/lib/globalFunctions.php 2009-02-09 19:13:13 UTC (rev 954) +++ trunk/1.2/lib/globalFunctions.php 2009-02-09 20:38:40 UTC (rev 955) @@ -17,7 +17,7 @@ function get_required_external_lib_versions($projectName=NULL) { //format: {className} => array({projectName} => {exactVersion}) $requirements = array( - 'contentSystem' => array('cs-content', '1.0.0-ALPHA7'), + 'contentSystem' => array('cs-content', '1.0.0-ALPHA8'), 'cs_phpxmlParser' => array('cs-phpxml', '1.0.0-ALPHA4'), 'cs_arrayToPath' => array('cs-arrayToPath', '1.0.0') ); @@ -110,12 +110,8 @@ cs_debug_backtrace(1); //Could not find the file requested to stringify. //Sending warning to user and logging it. - - set_message( - "Warning!", - "Could not find all files necessary to create this page.<br>Please call technical support.<BR>\nfile=[". $file ."]", - "","status" - ); + + throw new exception(__FUNCTION__ .": template file does not exist (". $file ."), output from template_file_exists=(". $filename .")"); return(NULL); } @@ -1356,7 +1352,13 @@ if(file_exists($filename)) { $retval = $filename; - } + } + else { + + $gf = new cs_globalFunctions; + $gf->debug_print(__FUNCTION__ .": TMPLDIR=(". $GLOBALS['TMPLDIR'] ."), filename=(". $filename .")"); + exit; + } return($retval); }//end template_file_exists() //================================================================================================================ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-10 16:04:53
|
Revision: 958 http://cs-project.svn.sourceforge.net/cs-project/?rev=958&view=rev Author: crazedsanity Date: 2009-02-10 16:04:50 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Update class names. Modified Paths: -------------- trunk/1.2/lib/_unitTests_/cs-content_tests.php trunk/1.2/lib/abstractClasses/dbAbstract.class.php trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA4.php Modified: trunk/1.2/lib/_unitTests_/cs-content_tests.php =================================================================== --- trunk/1.2/lib/_unitTests_/cs-content_tests.php 2009-02-10 15:59:16 UTC (rev 957) +++ trunk/1.2/lib/_unitTests_/cs-content_tests.php 2009-02-10 16:04:50 UTC (rev 958) @@ -10,7 +10,7 @@ function setUp() { $this->gfObj = new cs_globalFunctions; - $this->fsObj = new cs_fileSystemClass; + $this->fsObj = new cs_fileSystem; $this->contentObj = new contentSystem; }//end setUp() @@ -32,7 +32,7 @@ function testFileReading() { unset($this->fsObj); - $this->fsObj = new cs_fileSystemClass(dirname(__FILE__)); + $this->fsObj = new cs_fileSystem(dirname(__FILE__)); $dirData = $this->fsObj->ls(); if($this->assertTrue(is_array($dirData)) && $this->assertTrue(isset($dirData['data'])) && $this->assertTrue($dirData['data']['type'] == 'dir')) { Modified: trunk/1.2/lib/abstractClasses/dbAbstract.class.php =================================================================== --- trunk/1.2/lib/abstractClasses/dbAbstract.class.php 2009-02-10 15:59:16 UTC (rev 957) +++ trunk/1.2/lib/abstractClasses/dbAbstract.class.php 2009-02-10 16:04:50 UTC (rev 958) @@ -65,7 +65,7 @@ //========================================================================= final public function run_sql_file($filename) { if(!is_object($this->fsObj)) { - $this->fsObj = new cs_fileSystemClass; + $this->fsObj = new cs_fileSystem; } $this->lastSQLFile = $filename; Modified: trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA4.php =================================================================== --- trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA4.php 2009-02-10 15:59:16 UTC (rev 957) +++ trunk/1.2/upgrade/upgradeTo1.2.0-ALPHA4.php 2009-02-10 16:04:50 UTC (rev 958) @@ -104,7 +104,7 @@ //========================================================================= public function update_config_file() { - $fs = new cs_fileSystemClass(dirname(__FILE__) .'/../'); + $fs = new cs_fileSystem(dirname(__FILE__) .'/../'); $sampleXmlObj = new cs_phpxmlParser($fs->read('docs/samples/sample_config.xml')); $siteXmlObj = new cs_phpxmlParser($fs->read(CONFIG_FILE_LOCATION)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-10 17:14:45
|
Revision: 962 http://cs-project.svn.sourceforge.net/cs-project/?rev=962&view=rev Author: crazedsanity Date: 2009-02-10 17:14:40 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Update setup to handle new config, fix accidental redirection after setup. /includes/setup.inc: * only redirect if DATABASE__DBNAME is set AND there's no "setup" array under $_SESSION. /includes/setup/5.inc: * Change message contents when POST is discovered * remove commented-out code * log unit test results. * __finalStep::write_config(): -- add tags for SITE_ROOT & such (from the config::convert_to_sections()) -- add attributes for setting things to global/constant as needed. -- move all config settings to /config/main instead of being directly under /config. -- add attribute "usecssiteconfig" to the root tag. /lib/config.class.php: * move call to get_config_contents() into the "if" tag that runs only when the config file exists. /lib/_unitTests_/cs-content_tests.php: * remove extra space from expected value to avoid test failure. Modified Paths: -------------- trunk/1.2/includes/setup/5.inc trunk/1.2/includes/setup.inc trunk/1.2/lib/_unitTests_/cs-content_tests.php trunk/1.2/lib/config.class.php Modified: trunk/1.2/includes/setup/5.inc =================================================================== --- trunk/1.2/includes/setup/5.inc 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/includes/setup/5.inc 2009-02-10 17:14:40 UTC (rev 962) @@ -10,29 +10,45 @@ $writeConfigResult = $obj->write_config($page); $page->set_message_wrapper(array( - 'title' => "Reloaded... ", + 'title' => "Setup Complete", 'message' => $writeConfigResult, 'type' => "status", - 'linkURL' => '/login' + 'linkText' => "Proceed To Login", + 'linkURL' => '/setup/5?removeData=1' )); $page->conditional_header("/setup/5", TRUE); } +elseif($_GET['removeData'] == 1) { + unset($_SESSION['setup']); + $page->conditional_header('/login.php'); +} else { if(get_setup_data(5, 'result')) { $page->clear_content(); - #$page->set_block_row('content', 'submitButton'); $test = &new TestSuite("All Tests"); $test->addTestFile(dirname(__FILE__) .'/../../lib/_unitTests_/cs-content_tests.php'); - #$test->addTestFile(dirname(__FILE__) .'/../../lib/_unitTests_/cs-arrayToPath_tests.php'); - #$test->addTestFile(dirname(__FILE__) .'/../../lib/_unitTests_/cs-phpxml_tests.php'); $display = new HtmlReporter(); $test->run($display); $page->gfObj->debug_print("Passes: (". $display->getPassCount() .")"); - } - else { + //log our result into the database. + $db = new cs_phpDB; + $db->connect(get_config_db_params()); + + $log = new logsClass($db, 'SETUP'); + $log->log_by_class('UNIT TEST DATA::: passes='. $display->getPassCount() .', fails='. $display->getFailCount() .', exceptions='. $display->getExceptionCount(), 'Information'); + + if(!is_array($_SESSION['message'])) { + $page->set_message_wrapper(array( + 'title' => "Setup Complete", + 'message' => "Setup has been completed successfully. If you would like to remove setup data and proceed to login, click the link below.", + 'type' => 'status', + 'linkText' => "Proceed to Login", + 'linkURL' => "/setup/5?removeData=1" + )); + } } } @@ -74,15 +90,49 @@ } //now that we've built the array successfully, now let's turn it into XML. - $xmlCreator = new cs_phpxmlCreator('config/main'); + $xmlCreator = new cs_phpxmlCreator('config'); + $tagPath = "/config/main"; + $xmlCreator->add_tag($tagPath); + $xmlCreator->add_attribute($tagPath, array('fix'=>"sanitizeDirs")); + $xmlCreator->set_tag_as_multiple($tagPath); + + //Special values (including vars that cs_siteConfig{} handles) + $specialValues = array( + 'site_root' => '{_DIRNAMEOFFILE_}/..', + 'document_root' => '{MAIN/SITE_ROOT}', + 'libdir' => '{MAIN/SITE_ROOT}/lib', + 'tmpldir' => '{MAIN/SITE_ROOT}/templates', + 'seq_helpdesk' => 'special__helpdesk_public_id_seq', + 'seq_project' => 'special__project_public_id_seq', + 'seq_main' => 'record_table_record_id_seq', + 'table_todocomment' => 'task_comment_table', + 'format_wordwrap' => '90' + ); + $defineAsGlobal=array('site_root', 'libdir', 'tmpldir'); + foreach($specialValues as $index=>$value) { + $xmlCreator->add_tag($tagPath .'/'. $index, $value); + $attributes = array('setconstant'=>1); + if(array_search($index, $defineAsGlobal)) { + $attributes['setglobal']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); + } + + $skipSetConstant = array('version_string', 'workingonit'); foreach($myData as $index=>$value) { - $xmlCreator->add_tag($index, $value); + $xmlCreator->add_tag($tagPath ."/". $index, $value); + $attributes=array(); + if(!strlen(array_search($index, $skipSetConstant))) { + $attributes['setconstant']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); } $extraAttributes = array( - 'generated' => date('Y-m-d H:m:s'), - 'version' => $myData['version_string'] + 'generated' => date('Y-m-d H:m:s'), + 'version' => $myData['version_string'], + 'usecssiteconfig' => 1 ); - $xmlCreator->add_attribute('/config/main', $extraAttributes); + $xmlCreator->add_attribute('/config', $extraAttributes); //now, create an XML string... $xmlString = $xmlCreator->create_xml_string(); Modified: trunk/1.2/includes/setup.inc =================================================================== --- trunk/1.2/includes/setup.inc 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/includes/setup.inc 2009-02-10 17:14:40 UTC (rev 962) @@ -22,7 +22,7 @@ $configObj = new config(NULL, FALSE); $configData = $configObj->read_config_file(FALSE); -if(strlen($configData['DATABASE__DBNAME'])) { +if(strlen($configData['DATABASE__DBNAME']) && !is_array($_SESSION['setup'])) { //setup already complete. Stop 'em. $page->set_message_wrapper(array( 'title' => "Setup Unavailable", Modified: trunk/1.2/lib/_unitTests_/cs-content_tests.php =================================================================== --- trunk/1.2/lib/_unitTests_/cs-content_tests.php 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/lib/_unitTests_/cs-content_tests.php 2009-02-10 17:14:40 UTC (rev 962) @@ -95,7 +95,7 @@ ), 'styles' => array( 'select' => "field1='value1' AND field2='value2'", - 'insert' => "(field1, field2) VALUES ('value1', 'value2')", + 'insert' => "(field1, field2) VALUES ('value1','value2')", 'update' => "field1='value1', field2='value2'" ) ), @@ -113,7 +113,7 @@ foreach($testData as $name=>$data) { foreach($data['styles'] as $styleName => $expectedOutput) { $realOutput = $this->gfObj->string_from_array($data['input'], $styleName, NULL, 'sql'); - $this->assertEqual($realOutput, $expectedOutput, "invalid output for style (".$styleName ."): ". $realOutput); + $this->assertEqual($realOutput, $expectedOutput); } } }//end testSQLCreation() Modified: trunk/1.2/lib/config.class.php =================================================================== --- trunk/1.2/lib/config.class.php 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/lib/config.class.php 2009-02-10 17:14:40 UTC (rev 962) @@ -48,11 +48,9 @@ $this->gf->debug_print(__METHOD__ .": converting to use sections..."); $this->convert_to_sections(); } - parent::__construct($this->fs->realcwd .'/'. $this->fileName); + $this->config = $this->get_config_contents(TRUE); } - - $this->config = $this->get_config_contents(TRUE); }//end __construct() //------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-12 16:39:28
|
Revision: 965 http://cs-project.svn.sourceforge.net/cs-project/?rev=965&view=rev Author: crazedsanity Date: 2009-02-12 16:39:25 +0000 (Thu, 12 Feb 2009) Log Message: ----------- Formatting, set assigned user when solving (#252), minor wording fix (#195). /lib/helpdeskClass.php: * solve(): -- set the assigned user to be the current user (#252). /templates/content/project/view/index.content.tmpl: * valign=top for related tasks/notes and issues. /templates/content/project/view/related_issue.content.tmpl: * change "preferences" to "issues" (typo)(#195) Modified Paths: -------------- trunk/1.2/lib/helpdeskClass.php trunk/1.2/templates/content/project/view/index.content.tmpl trunk/1.2/templates/content/project/view/related_issue.content.tmpl Modified: trunk/1.2/lib/helpdeskClass.php =================================================================== --- trunk/1.2/lib/helpdeskClass.php 2009-02-10 17:52:09 UTC (rev 964) +++ trunk/1.2/lib/helpdeskClass.php 2009-02-12 16:39:25 UTC (rev 965) @@ -263,6 +263,12 @@ "status_id" => 4 ); + //If it's not assigned, assign it to the current user. + $oldData = $this->get_record($this->helpdeskId); + if(is_null($oldData['leader_contact_id']) && is_numeric($_SESSION['contact_id'])) { + $updatesArr['leader_contact_id'] = $_SESSION['contact_id']; + } + $retval = $this->update_record($this->helpdeskId, $updatesArr); //log the action. Modified: trunk/1.2/templates/content/project/view/index.content.tmpl =================================================================== --- trunk/1.2/templates/content/project/view/index.content.tmpl 2009-02-10 17:52:09 UTC (rev 964) +++ trunk/1.2/templates/content/project/view/index.content.tmpl 2009-02-12 16:39:25 UTC (rev 965) @@ -118,12 +118,12 @@ </td> </tr> <tr> - <td width="50%"> + <td width="50%" valign="top"> <div id="related_task" width="100%">{related_task}</div> <div id="related_note" style="padding-top:1em;">{related_note}</div> </td> - <td width="50%"> + <td width="50%" valign="top"> <div id="related_issue">{related_issue}</div> </td> </tr> Modified: trunk/1.2/templates/content/project/view/related_issue.content.tmpl =================================================================== --- trunk/1.2/templates/content/project/view/related_issue.content.tmpl 2009-02-10 17:52:09 UTC (rev 964) +++ trunk/1.2/templates/content/project/view/related_issue.content.tmpl 2009-02-12 16:39:25 UTC (rev 965) @@ -2,7 +2,7 @@ <tr> <td colspan="6"><b>Related Helpdesk Issues</b> (<a href="/content/helpdesk/create?proj={public_id}&goBack=1">Create</a>): <!-- BEGIN helpdeskPrefWarning --> - <BR><font color="red"><b>Warning:</b></font> Not all preferences will be displayed, due to your <a href="/content/settings">Preferences</a>. + <BR><font color="red"><b>Warning:</b></font> Not all issues will be displayed, due to your <a href="/content/settings">Preferences</a>. <!-- END helpdeskPrefWarning --> <hr></td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-30 14:24:03
|
Revision: 966 http://cs-project.svn.sourceforge.net/cs-project/?rev=966&view=rev Author: crazedsanity Date: 2009-07-30 14:23:57 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Converted a couple of *.png files to *.gif & updated templates to reflect it. Modified Paths: -------------- trunk/1.2/templates/content/helpdesk/view.content.tmpl trunk/1.2/templates/content/related_task.shared.tmpl trunk/1.2/templates/content/tags/index.content.tmpl Added Paths: ----------- trunk/1.2/public_html/images/bullet-round.gif trunk/1.2/public_html/images/icon-help.gif Removed Paths: ------------- trunk/1.2/public_html/images/bullet-round.png trunk/1.2/public_html/images/icon-help.png Added: trunk/1.2/public_html/images/bullet-round.gif =================================================================== (Binary files differ) Property changes on: trunk/1.2/public_html/images/bullet-round.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/1.2/public_html/images/bullet-round.png =================================================================== (Binary files differ) Added: trunk/1.2/public_html/images/icon-help.gif =================================================================== (Binary files differ) Property changes on: trunk/1.2/public_html/images/icon-help.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/1.2/public_html/images/icon-help.png =================================================================== (Binary files differ) Modified: trunk/1.2/templates/content/helpdesk/view.content.tmpl =================================================================== --- trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-02-12 16:39:25 UTC (rev 965) +++ trunk/1.2/templates/content/helpdesk/view.content.tmpl 2009-07-30 14:23:57 UTC (rev 966) @@ -20,7 +20,7 @@ <td>{public_id} [<b><a href="/extern/helpdesk/view?ID={public_id}">External Link</a></b>] <a href="/help/helpdesk/external_link" target="_blank"> - <img src="/images/icon-help.png" border="0"></a></td> + <img src="/images/icon-help.gif" border="0"></a></td> <td rowspan="4" align="left" nowrap> <!-- BEGIN access_block --> @@ -30,7 +30,7 @@ <td style="border-left:solid #000 1px;border-top:solid #000 1px;">Assigned: <a href="/help/helpdesk/assigned" target="_blank"> - <img src="/images/icon-help.png" border="0"></a> + <img src="/images/icon-help.gif" border="0"></a> </td> <td style="border-right:solid #000 1px;border-top:solid #000 1px;" nowrap> @@ -47,7 +47,7 @@ <tr> <td style="border-left:solid #000 1px;">Priority: <a href="/help/helpdesk/priority" target="_blank"> - <img src="/images/icon-help.png" border="0"></a> + <img src="/images/icon-help.gif" border="0"></a> </td> <td style="border-right:solid #000 1px"> @@ -65,7 +65,7 @@ Attached to project: <a href="/help/helpdesk/project_linkage" target="_blank"> - <img src="/images/icon-help.png" border="0"></a> + <img src="/images/icon-help.gif" border="0"></a> <br>[ <b>{ancestryLinkList}</b> ] </td> @@ -97,7 +97,7 @@ <tr> <th colspan="2" style="background-color:#FFF"> Notified Users <a href="/help/helpdesk/notified_users" target="_blank"> - <img src="/images/icon-help.png" border="0"></a> + <img src="/images/icon-help.gif" border="0"></a> </th> </tr> <tr> @@ -149,7 +149,7 @@ <tr> <th align="right">Tags: <a href="/help/tag" target="_blank"> - <img src="/images/icon-help.png" border="0"></a> + <img src="/images/icon-help.gif" border="0"></a> </th> <td colspan="2"> @@ -226,7 +226,7 @@ <a href="/help/helpdesk/submit_buttons" target="_blank"> - <img src="/images/icon-help.png" border="0"></a> + <img src="/images/icon-help.gif" border="0"></a> <BR> Is this a <b>Solution</b>? Modified: trunk/1.2/templates/content/related_task.shared.tmpl =================================================================== --- trunk/1.2/templates/content/related_task.shared.tmpl 2009-02-12 16:39:25 UTC (rev 965) +++ trunk/1.2/templates/content/related_task.shared.tmpl 2009-07-30 14:23:57 UTC (rev 966) @@ -4,7 +4,7 @@ <b>Related Tasks: </b> (<a href='/content/task/create?parentPublicId={public_id}&module={module}' target=_top>Create</a>): <a href="/help/task" target="_blank"> - <img src="/images/icon-help.png" border="0"></a> + <img src="/images/icon-help.gif" border="0"></a> <!-- BEGIN taskPrefWarning --> <BR><font color="red"><b>Warning:</b></font> Not all issues will be displayed, due to your <a href="/content/settings">preferences</a>. <!-- END taskPrefWarning --> @@ -36,4 +36,4 @@ </tr> <!-- END related_task_row --> -</table> \ No newline at end of file +</table> Modified: trunk/1.2/templates/content/tags/index.content.tmpl =================================================================== --- trunk/1.2/templates/content/tags/index.content.tmpl 2009-02-12 16:39:25 UTC (rev 965) +++ trunk/1.2/templates/content/tags/index.content.tmpl 2009-07-30 14:23:57 UTC (rev 966) @@ -10,7 +10,7 @@ <td> <!-- BEGIN availableTagsList --> <div id="listedTag_%%tagNameId%%" style="padding-left:5px;"> - <img src="/images/bullet-round.png" border="0"> + <img src="/images/bullet-round.gif" border="0"> <a href="javascript:void(xajax_ajax__showtagrecords(%%tagNameId%%));"> %%tagName%%</a> <!-- BEGIN availableTagsList__tagIcon --> <img src="/images/tags/%%icon_name%%.gif" border="0"> @@ -19,7 +19,7 @@ <!-- END availableTagsList --> <!-- BEGIN availableTagsList_noLink --> <div id="noListedTags" style="padding-left:5px;"> - <img src="/images/bullet-round.png" border="0"> + <img src="/images/bullet-round.gif" border="0"> <font size="+1"><b>%%tagName%%</b></font> {availableTagsList__tagIcon} </div> @@ -60,7 +60,7 @@ </tr> <tr> <td><b>Modifier:</b> - <a href="/help/tag/modifier" target="_blank"><img src="/images/icon-help.png" border="0"></a></td> + <a href="/help/tag/modifier" target="_blank"><img src="/images/icon-help.gif" border="0"></a></td> <td> <select name="modifier" onChange="this.form.submit();"> {modifier_option_list} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-09-17 15:40:37
|
Revision: 980 http://cs-project.svn.sourceforge.net/cs-project/?rev=980&view=rev Author: crazedsanity Date: 2009-09-17 15:40:28 +0000 (Thu, 17 Sep 2009) Log Message: ----------- Move temporary class names in setup step includes into their own class files in lib, so they can be __autoload()ed. Modified Paths: -------------- trunk/1.2/includes/setup/2.inc trunk/1.2/includes/setup/3.inc trunk/1.2/includes/setup/5.inc Added Paths: ----------- trunk/1.2/lib/_setup/ trunk/1.2/lib/_setup/MyDisplay.class.php trunk/1.2/lib/_setup/__finalStep.class.php trunk/1.2/lib/_setup/__setupDefaultValues.class.php trunk/1.2/lib/_setup/__tmpSetupClass.class.php trunk/1.2/lib/_setup/_setupUpgrade.class.php trunk/1.2/lib/_setup/unitTest.class.php Modified: trunk/1.2/includes/setup/2.inc =================================================================== --- trunk/1.2/includes/setup/2.inc 2009-08-18 14:22:50 UTC (rev 979) +++ trunk/1.2/includes/setup/2.inc 2009-09-17 15:40:28 UTC (rev 980) @@ -56,191 +56,4 @@ - -class __tmpSetupClass { - - - private $db; - private $fs; - private $page; - private $url = "/setup/1"; - - //========================================================================= - public function __construct(cs_phpDB &$db, cs_genericPage &$page) { - $this->db = $db; - $this->fsObj = new cs_fileSystem(dirname(__FILE__) .'/../../docs/sql/setup'); - $this->gfObj = new cs_globalFunctions; - $this->page = $page; - - store_setup_data(2, 0, 'result'); - store_setup_data(2, 'Initializing...', 'text'); - }//end __construct() - //========================================================================= - - - //========================================================================= - public function go() { - $retval = "Nothing done... something went horribly wrong."; - if($this->create_database()) { - $retval = $this->handle_plpgsql(); - - if($retval === TRUE) { - $retval = $this->load_schema(); - if($retval === TRUE) { - $this->page->set_message_wrapper( - array( - 'title' => "Step Successful", - 'message' => "Finished step two with result:::<BR>\n". get_setup_data(2,'text'), - 'type' => "status" - ) - ); - $this->page->conditional_header('/setup/3', TRUE); - } - else { - $retval = "There was an error while testing PL/PGSQL functionality: ". $retval; - store_setup_data(2, $retval, 'text'); - } - } - } - else { - store_setup_data(2, 0, 'result'); - store_setup_data(2, 'Failed to create database', 'text'); - $setupData = get_setup_data(1, 'data'); - $retval = "Unable to create database... check that ". $setupData['host'] . - " does not already have a database named '". $setupData['dbname'] ."'. " . - "Also, make sure no other user is connected to template1."; - } - - return($retval); - }//end go() - //========================================================================= - - - - //========================================================================= - private function create_database() { - $params = get_db_params(); - - //okay, let's try to create the database. - $numrows = $this->db->exec("CREATE DATABASE ". $params['dbname'] ." WITH ENCODING='SQL_ASCII'"); - $dberror = $this->db->errorMsg(); - - if(strlen($dberror)) { - $retval = FALSE; - } - else { - $retval = TRUE; - - //okay. Now destroy our database handle & create a new one, connected to the proper database. - unset($this->db); - $this->db = new cs_phpDb; - $this->db->connect(get_db_params()); - } - - return($retval); - }//end create_database() - //========================================================================= - - - //========================================================================= - private function load_schema() { - - store_setup_data(2, "Schema not loaded... ", 'text'); - store_setup_data(2, 0, 'result'); - - $fileData = $this->fsObj->read("01__storedprocs.sql"); - - //now we'll try to push that into the database. - $this->db->beginTrans(); - - $this->gfObj->debug_print("Loading stored procedures... "); - - $this->db->exec($fileData); - $dberror = $this->db->errorMsg(); - - if(strlen($dberror)) { - $this->db->rollbackTrans(); - $retval = $dberror; - } - else { - //keep going - $retval = "Successfully loaded stored procedures! Loading tables...."; - $this->gfObj->debug_print($retval); - - $fileData = $this->fsObj->read("02__tables.sql"); - $this->db->exec($fileData); - $dberror = $this->db->errorMsg(); - - if(strlen($dberror)) { - $this->db->rollbackTrans(); - $retval = $dberror; - } - else { - $retval = "Done loading tables!!! Creating indexes and miscellaneous other things..."; - $this->gfObj->debug_print($retval); - - $fileData = $this->fsObj->read("03__indexes_etc.sql"); - $this->db->exec($fileData); - $dberror = $this->db->errorMsg(); - - if(strlen($dberror)) { - $this->db->rollbackTrans(); - $retval = $dberror; - } - else { - $retval = "All stored procedures, tables, and indexes have been created!"; - $this->gfObj->debug_print($retval); - - $this->db->commitTrans(); - store_setup_data(2, array(), 'data'); - store_setup_data(2, 1, 'result'); - store_setup_data(2, $retval, 'text'); - store_setup_data(3, 1, 'accessible'); - - $retval = TRUE; - } - } - } - - return($retval); - }//end load_schema() - //========================================================================= - - - - //========================================================================= - /** - * Try to load PL/pgsql functions... - * - * NOTE: this is a terrible requirement, which requires PostgreSQL to be - * compiled with certain options... - */ - private function handle_plpgsql() { - $this->db->beginTrans(); - $fileData = $this->fsObj->read("plpgsql.sql"); - - $numrows = $this->db->exec($fileData); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror)) { - $this->db->commitTrans(); - $retval = TRUE; - } - else { - //figure out WHY this failed: if they're already loaded it's okay, otherwise it's bad. - $this->db->rollbackTrans(); - - if(preg_match('/"plpgsql_call_handler" already exists/', $dberror)) { - $retval = TRUE; - } - else { - $retval = $dberror; - } - } - - return($retval); - }//end handle_plpgsql() - //========================================================================= -} - ?> \ No newline at end of file Modified: trunk/1.2/includes/setup/3.inc =================================================================== --- trunk/1.2/includes/setup/3.inc 2009-08-18 14:22:50 UTC (rev 979) +++ trunk/1.2/includes/setup/3.inc 2009-09-17 15:40:28 UTC (rev 980) @@ -7,9 +7,15 @@ if($_POST) { $validSubmission = test_submitted_data($page, $_POST['users']); - if($validSubmission === TRUE) { - $obj = new __setupDefaultValues(); - store_setup_data(3, $obj->go(), 'text'); + if($validSubmission === TRUE) { + try { + $obj = new __setupDefaultValues(); + $storeThis = $obj->go(); + } + catch(exception $e) { + $storeThis = "An error occurred::: ". $e->getMessage(); + } + store_setup_data(3, $storeThis, 'text'); $obj->finish($page); } else { @@ -117,989 +123,4 @@ - - - - - -class __setupDefaultValues extends upgrade { - - - protected $db; - private $gfObj; - private $totalRecords=0; - - private $data=array(); - - private $lastNumrows=NULL; - private $lastDberror=NULL; - - //========================================================================= - public function __construct() { - $this->db = new cs_phpDB; - $this->gfObj = new cs_globalFunctions; - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function go() { - store_setup_data(3, 0, 'result'); - try { - $params = get_db_params(); - $this->db->connect($params); - $this->db->beginTrans(__METHOD__); - $retval = "Connected successfully to the database."; - - //now that we've connected, start doing stuff. - $retval = $this->set_version(); - $retval .= "<BR>\n". $this->create_log_categories_and_classes(); - $retval .= "<BR>\n". $this->create_attributes(); - $retval .= "<BR>\n". $this->create_anonymous_contact_data(); - $retval .= "<BR>\n". $this->create_status_records(); - $retval .= "<BR>\n". $this->create_tag_names(); - $retval .= "<BR>\n". $this->build_preferences(); - $retval .= "<BR>\n". $this->create_users(); - $retval .= "<BR>\n". $this->create_user_group_records(); - - $commitRes = $this->db->commitTrans(); - if($commitRes == 1) { - $retval .= "<BR>\n ----------- Created (". $this->totalRecords ."), result of commit: (". $commitRes .")."; - store_setup_data(3, 1, 'result'); - store_setup_data(4, 1, 'accessible'); - } - else { - $this->db->rollbackTrans(); - store_setup_data(3, 0, 'result'); - throw new exception(__METHOD__ .": failed to commit the transaction (". $commitRes .")"); - } - - } - catch(exception $e) { - //TODO: rollback the transaction - $retval = "An error occurred: ". $e->getMessage(); - } - - return($retval); - - }//end go() - //========================================================================= - - - - //========================================================================= - /** - * Set version information into the database for future upgradeability. - */ - private function set_version() { - //get the version string. - $fullVersionString = read_version_file(); - - $suffixData = explode('-', $fullVersionString); - if(count($suffixData) == 2 && preg_match('/\./', $suffixData[0]) && !preg_match('/\./', $suffixData[1])) { - //there's a suffix, and it doesn't contain periods (i.e. "1.0.0-ALPHA1") - $suffix = $suffixData[1]; - } - elseif(count($suffixData) == 1) { - //no suffix. - $suffix = ""; - } - else { - //there's a dash in the name, but it's invalid or contains periods (i.e. "BETA-1.0.0" or "1.0.0-ALPHA1.0") - throw new exception(__METHOD__ .": version string is invalid (". $fullVersionString ."), suffix contains dashes, or there is a prefix"); - } - - //remove the suffix & parse it. - $versionString = $suffixData[0]; - $versionData = $this->parse_version_string($fullVersionString); - $sqlData = $versionData; - - - #$sqlData = array( - # 'version_string' => $fullVersionString, - # 'version_major' => $versionData[0], - # 'version_minor' => $versionData[1], - # 'version_maintenance' => $versionData[2], - # 'version_suffix' => $suffix - #); - - $retval = 0; - foreach($sqlData as $name => $value) { - $sql = "SELECT internal_data_set_value('". $name ."', '". $value ."')"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to set (". $name .") as (". $value .")::: ". $dberror); - } - } - - if($retval == count($sqlData)) { - //okay, the final test: run a query that straps everything together, to ensure it all has the same version. - $sql = "SELECT internal_data_get_value('version_major') || '.' || internal_data_get_value('version_minor') " . - " || '.' || internal_data_get_value('version_maintenance') as text, " . - "internal_data_get_value('version_suffix') as version_suffix;"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $data = $this->db->farray(); - $dbVersionString = $data['text']; - if(strlen($data['version_suffix'])) { - $dbVersionString .= "-". $data['version_suffix']; - } - - if($dbVersionString === $fullVersionString) { - //okay, one final test: check that the "version_string" in the database matches ours. - $sql = "SELECT internal_data_get_value('version_string')"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $data = $this->db->farray(); - $dbVersionString = $data[0]; - - if($dbVersionString === $fullVersionString) { - $this->data['version_string'] = $fullVersionString; - $retval = "Successfully set version string"; - } - else { - throw new exception(__METHOD__ .": derived database version string (". $dbVersionString .") doesn't match our version (". $fullVersionString .")"); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve full version_string from database::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": derived database version string (". $dbVersionString .") doesn't match our version (". $fullVersionString .")"); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve derived database version string::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - //it's cryptic, but what should it really say??? - throw new exception(__METHOD__ .": internal error, checksum didn't match"); - } - - return($retval); - - }//end set_version() - //========================================================================= - - - - //========================================================================= - private function create_log_categories_and_classes() { - - $counter = 0; - - $classes = array( - 1 => 'Error', - 2 => 'Information', - 3 => 'Create', - 4 => 'Update', - 5 => 'Delete', - 6 => 'REPORT', - 7 => 'DEBUG' - ); - - - foreach($classes as $num=>$name) { - $insertArr = array( - 'log_class_id' => $num, - 'name' => $name - ); - $sql = "INSERT INTO log_class_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good. - $counter++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create class record for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - - //Reset sequence, so new records can be created. - $sql = "SELECT setval('log_class_table_log_class_id_seq', (SELECT max(log_class_id) FROM log_class_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $categories = array( - 1 => 'Database', - 2 => 'Authentication', - 3 => 'Users', - 4 => 'General', - 5 => 'Project', - 6 => 'Helpdesk', - 7 => 'Task', - 8 => 'Tags', - 9 => 'Estimates', - 10 => 'Navigation', - 11 => 'Preferences' - ); - - - foreach($categories as $num=>$name) { - $insertArr = array( - 'log_category_id' => $num, - 'name' => $name - ); - $sql = "INSERT INTO log_category_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good. - $counter++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create category record for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - //Reset sequence, so new records can be created. - $sql = "SELECT setval('log_category_table_log_category_id_seq', (SELECT max(log_category_id) FROM log_category_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - - //format (primary index is log_event_id): log_class_id, log_category_id, description - $logEvents = array( - // * log_event_id | log_class_id | log_category_id | description - 1 => array(3, 5, 'Project: created record'), - 2 => array(5, 5, 'Project: deleted record'), - 3 => array(4, 5, 'Project: updated record'), - 4 => array(1, 5, 'Project: ERROR'), - 5 => array(3, 6, 'Helpdesk: Created record'), - 6 => array(4, 6, 'Helpdesk: Updated record'), - 7 => array(2, 6, 'Helpdesk: Information'), - 8 => array(1, 6, 'Helpdesk: ERROR'), - 9 => array(6, 6, 'Helpdesk: Report'), - 10 => array(3, 7, 'Task: created record'), - 11 => array(5, 7, 'Task: deleted record'), - 12 => array(4, 7, 'Task: updated record'), - 13 => array(1, 1, 'Database Error'), - 14 => array(6, 5, 'Project: Activity Report'), - 15 => array(6, 7, 'Task: Activity Report'), - 16 => array(3, 2, 'User logged-in'), - 17 => array(5, 2, 'User logged-out'), - 18 => array(6, 2, 'Login/Logout Report'), - 19 => array(3, 8, 'Tags: created record'), - 20 => array(5, 8, 'Tags: deleted record'), - 21 => array(4, 8, 'Tags: updated record'), - 22 => array(6, 8, 'Tags: Activity Report'), - 23 => array(1, 2, 'Authentication: ERROR'), - 24 => array(2, 10, 'Navigation: Viewed page'), - 25 => array(4, 9, 'Update: Estimates'), - 26 => array(1, 9, 'Error: Estimates'), - 27 => array(2, 5, 'Information: Project'), - 28 => array(4, 3, 'Update: Users'), - 29 => array(1, 7, 'Error: Task'), - 30 => array(3, 3, 'Create: Users') - ); - - foreach($logEvents as $logEventId => $subArr) { - $insertArr = array( - 'log_event_id' => $logEventId, - 'log_class_id' => $subArr[0], - 'log_category_id' => $subArr[1], - 'description' => $subArr[2] - ); - $sql = "INSERT INTO log_event_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $counter++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create log_event_id #". $insertArr['log_event_id'] - .", description: ". $insertArr['description'] ."<BR>\nERROR::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - //FINAL SANITY CHECKS!!! - if($counter == (count($classes) + count($categories) + count($logEvents))) { - - //reset the sequence. - $sql = "SELECT setval('log_event_table_log_event_id_seq', (SELECT max(log_event_id) FROM log_event_table))"; - if($this->run_sql($sql) === TRUE) { - $retval = "Successfully created all category, class, and log event records (". $counter .")"; - } - else { - throw new exception(__METHOD__ .": failed to reset sequence for log_event table::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": Internal error, failed to create all category and class records"); - } - } - else { - throw new exception(__METHOD__ .": failed to reset sequence for log_category_table::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to reset sequence for log_class_table::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - - return($retval); - - }//end create_log_categories_and_classes() - //========================================================================= - - - - //========================================================================= - private function create_attributes() { - $attributes = array( - 3 => array('phone', 'phone', 'Phone'), - 4 => array('fax', 'phone', 'Fax'), - 5 => array('cell', 'phone', 'Cell'), - 6 => array('im_yahoo', 'alphanumeric', 'IM: Yahoo'), - 7 => array('im_skype', 'alphanumeric', 'IM: Skype'), - 8 => array('im_aol', 'alphanumeric', 'IM: AOL'), - 9 => array('im_msn', 'alphanumeric', 'IM: MSN'), - 10 => array('im_icq', 'alphanumeric', 'IM: ICQ'), - 11 => array('address', 'sql', 'Address'), - 12 => array('city', 'alphanumeric', 'City'), - 13 => array('state', 'alphanumeric', 'State'), - 14 => array('zip', 'alphanumeric', 'Zip') - ); - - $retval = 0; - foreach($attributes as $attributeId => $subData) { - $insertArr = array( - 'attribute_id' => $attributeId, - 'name' => $subData[0], - 'clean_as' => $subData[1], - 'display_name' => $subData[2] - ); - $sql = "INSERT INTO attribute_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for attribute (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($attributes)) { - $sql = "SELECT setval('attribute_table_attribute_id_seq'::text, (SELECT max(attribute_id) FROM attribute_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval = "Successfully created all attributes (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check failed)"); - } - - return($retval); - }//end create_attributes() - //========================================================================= - - - - //========================================================================= - /** - * Create the anonymous user. This includes their contact data and the - * default group. - * - * TODO: change "short_name" into "display_name". - */ - private function create_anonymous_contact_data() { - $allRecords = array( - 'disabled group' => array( - 'name' => 'group_table', - 'data' => array( - 'group_id' => 0, - 'name' => 'disabled', - 'short_name' => 'DISABLED', - 'leader_uid' => 0 - ), - ), - 'anonymous record in user table' => array( - 'name' => 'user_table', - 'data' => array( - 'uid' => 0, - 'username' => 'Anonymous', - 'password' => 'disabled', //this is PURPOSELY an invalid password (passwords should be 32-char md5's - 'is_admin' => 'f', - 'is_active' => 'f', - 'group_id' => 0, - 'contact_id' => 0 - ), - ), - 'default group' => array( - 'name' => 'group_table', - 'data' => array( - 'group_id' => 1, - 'name' => 'default', - 'short_name' => '-DEFAULT-', - 'leader_uid' => 0 - ), - ), - 'anonymous contact record' => array( - 'name' => 'contact_table', - 'data' => array( - 'contact_id' => 0, - 'company' => '', - 'fname' => 'Anonymous', - 'lname' => '', - 'contact_email_id' => '-1' - ) - ), - 'anonymous email record' => array( - 'name' => 'contact_email_table', - 'data' => array( - 'contact_id' => 0, - 'email' => 'ano...@nu...' - ) - ) - ); - - $retval = 0; - foreach($allRecords as $operationName => $subData) { - $tableName = $subData['name']; - $insertArr = $subData['data']; - - $sql = "INSERT INTO ". $tableName ." ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $this->totalRecords++; - $retval++; - } else { - throw new exception(__METHOD__. ": failed perform operation (". $operationName .") for table (". $tableName .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - $sql = "SELECT currval('contact_email_table_contact_email_id_seq'::text)"; - if($this->run_sql($sql)) { - $data = $this->db->farray(); - $sql = "UPDATE contact_table SET contact_email_id=". $data[0] ." WHERE contact_id=0"; - if($this->run_sql($sql)) { - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to set contact_email_id for anonymous"); - } - } - else { - throw new exception(__METHOD__ .": failed to get sequence for contact_email_table"); - } - - if($retval == count($allRecords)) { - //reset the sequence for the group table... - $sql = "SELECT setval('group_table_group_id_seq'::text, (SELECT max(group_id) FROM group_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good to go. - $retval = "Successfully created anonymous user, anonymous contact record, and the two default groups (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset group sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (failed sanity check)"); - } - - return($retval); - }//end create_anonymous_contact_data() - //========================================================================= - - - //========================================================================= - private function create_status_records() { - //format: {status_id} => array({name}, {description}) - $statuses = array( - 0 => array('New/Offered', 'New record'), - 1 => array('Pending', 'Not new: pending review, or nearly complete.'), - 2 => array('Running/Accepted', 'Work is underway'), - 3 => array('Stalled', 'Unable to complete, or dependent on other things.'), - 4 => array('Ended/Solved', 'Work is complete!'), - 5 => array('Rejected', 'Denied.'), - 6 => array('Re-opened', 'Was solved, but is once again open.'), - ); - - $retval = 0; - foreach($statuses as $statusId => $subData) { - $insertArr = array( - 'status_id' => $statusId, - 'name' => $subData[0], - 'description' => $subData[1] - ); - $sql = "INSERT INTO status_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create status (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($statuses)) { - //reset the status_table.status_id sequence... - $sql = "SELECT setval('status_table_status_id_seq'::text, (SELECT max(status_id) FROM status_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good to go. - $retval = "Successfully created all status records (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset status sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (failed sanity check)"); - } - - return($retval); - - }//end create_status_records() - //========================================================================= - - - - //========================================================================= - private function create_tag_names() { - $tags = array( - 1 => 'bug', - 2 => 'feature request', - 3 => 'information', - 4 => 'network related', - 5 => 'critical', - 6 => 'exception' - ); - - $retval = 0; - foreach($tags as $id=>$name) { - $insertArr = array( - 'tag_name_id' => $id, - 'name' => $name - ); - $sql = "INSERT INTO tag_name_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($tags)) { - //reset sequence for tag_name_table.tag_name_id - $sql = "SELECT setval('tag_name_table_tag_name_id_seq'::text, (SELECT max(tag_name_id) FROM tag_name_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good to go. - $retval = "Successfully created all tags (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset tag_name sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check failed)"); - } - - return($retval); - }//end create_tag_names() - //========================================================================= - - - - //========================================================================= - private function build_preferences() { - //format: {pref_type_id} => array({name}, {default_value}, {display_name}, {description}) - $prefTypes = array( - 1 => array('startModule', 'helpdesk', 'Starting on Module', 'Defines which section will be loaded upon login if nothing was selected.'), - 5 => array('sorting_helpdesk', 'public_id|DESC', 'Helpdesk Sorting', 'Define the type of sorting for the helpdesk page.'), - 6 => array('sorting_project', 'priority|ASC', 'Project Sorting', 'Define the type of sorting for the helpdesk page.'), - 7 => array('projectDetails_taskDisplayOnlyMine', 'all', 'Project Details: Task display', 'Define what tasks are displayed on a project\\\'s details page.'), - 8 => array('projectDetails_showCompletedIssues', '1', 'Project Details: Display completed issues', 'Should completed issues display in the details of a project?') - ); - - $retval = 0; - foreach($prefTypes as $prefTypeId => $subData) { - $insertArr = array( - 'pref_type_id' => $prefTypeId, - 'name' => $subData[0], - 'default_value' => $subData[1], - 'display_name' => $subData[2], - 'description' => $subData[3] - ); - - $sql = "INSERT INTO pref_type_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql_insert'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($prefTypes)) { - //format: {pref_option_id} => array({pref_type_id}, {name}, {effective_value}) - $prefOptions = array( - 1 =>array(1, 'Helpdesk', 'helpdesk'), - 2 =>array(1, 'Projects', 'project'), - 3 =>array(1, 'Summary ', 'summary'), - 8 =>array(5, 'ID - Descending', 'public_id|DESC'), - 9 =>array(5, 'ID - Ascending', 'public_id|ASC'), - 10 =>array(5, 'Priority - Descending', 'priority|DESC'), - 11 =>array(5, 'Priority - Ascending', 'priority|ASC'), - 12 =>array(5, 'Submit - Descending', 'start_date|DESC'), - 13 =>array(5, 'Submit - Ascending', 'start_date|ASC'), - 14 =>array(5, 'Title - Descending', 'name|DESC'), - 15 =>array(5, 'Title - Ascending', 'name|DESC'), - 16 =>array(5, 'Status ID - Descending', 'status_id|DESC'), - 17 =>array(5, 'Status ID - Ascending', 'status_id|DESC'), - 18 =>array(5, 'Assigned - Descending', 'assigned|DESC'), - 19 =>array(5, 'Assigned - Ascending', 'assigned|DESC'), - 20 =>array(6, 'Priority - Ascending', 'priority|ASC'), - 21 =>array(6, 'Priority - Descending', 'priority|DESC'), - 22 =>array(6, 'Name of Project - Ascending', 'name|ASC'), - 23 =>array(6, 'Name of Project - Descending', 'name|DESC'), - 24 =>array(6, 'Begin - Ascending', 'start_date|ASC'), - 25 =>array(6, 'Begin - Descending', 'start_date|DESC'), - 26 =>array(6, 'End - Ascending', 'end|ASC'), - 27 =>array(6, 'End - Descending', 'end|DESC'), - 28 =>array(6, 'Status ID - Ascending', 'status_id|ASC'), - 29 =>array(6, 'Status ID - Descending', 'status_id|DESC'), - 30 =>array(6, 'Progress - Ascending', 'progress|ASC'), - 31 =>array(6, 'Progress - Descending', 'progress|DESC'), - 32 =>array(6, 'Leader - Ascending', 'leader_contact_id|ASC'), - 33 =>array(6, 'Leader - Descending', 'leader_contact_id|DESC'), - 34 =>array(7, 'Show everything', 'all'), - 35 =>array(7, 'All of mine (created & assigned)', 'mine'), - 36 =>array(7, 'Only my assigned items', 'assigned'), - 37 =>array(8, 'Yes', '1'), - 38 =>array(8, 'No', '0'), - ); - - foreach($prefOptions as $prefOptionId => $subData) { - $insertArr = array( - 'pref_option_id' => $prefOptionId, - 'pref_type_id' => $subData[0], - 'name' => $subData[1], - 'effective_value' => $subData[2] - ); - $sql = "INSERT INTO pref_option_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for pref option (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == (count($prefTypes) + count($prefOptions))) { - //reset the pref_type_table.pref_type_id sequence. - $sql = "SELECT setval('pref_type_table_pref_type_id_seq'::text, (SELECT max(pref_type_id) FROM pref_type_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - if($retval == (count($prefTypes) + count($prefOptions))) { - //reset the pref_option_table.pref_option_id sequence. - $sql = "SELECT setval('pref_option_table_pref_option_id_seq'::text, (SELECT max(pref_option_id) FROM pref_option_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval = "Successfully created all preferences and options (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset the pref_option sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check #2 failed)"); - } - } - else { - throw new exception(__METHOD__ .": failed to reset pref_type sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check #2 failed): (". $retval ." != ". (count($prefTypes) + count($prefOptions)) .")"); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check #1 failed)"); - } - - return($retval); - - }//end build_preferences() - //========================================================================= - - - - //========================================================================= - private function create_users() { - - //retrieve the user information. - $userData = get_setup_data(3, 'post_info'); - if(!is_array($userData) || count($userData) != 2) { - throw new exception(__METHOD__ .": no user data...?". $this->gfObj->debug_print($userData,0)); - } - - $counter = 0; - $retval = "Successfully created records for::: "; - foreach($userData as $num => $subData) { - - //split their name up, based upon spaces. - $nameData = explode(' ', $subData['name']); - $insertArr = array(); - if(count($nameData) == 1) { - $insertArr['fname'] = $nameData[0]; - $insertArr['lname'] = ""; - } - elseif(count($nameData) == 2) { - $insertArr['fname'] = $nameData[0]; - $insertArr['lname'] = $nameData[1]; - } - else { - $insertArr['fname'] = $nameData[0]; - $insertArr['lname'] = preg_replace('/^'. $insertArr['fname'] .' /', '', $subData['name']); - } - $insertArr['contact_email_id'] = '-1'; - - //create their contact record. - $sql = "INSERT INTO contact_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $sql = "SELECT currval('contact_table_contact_id_seq'::text)"; - if($this->run_sql($sql, 1) === TRUE) { - $this->totalRecords++; - - $data = $this->db->farray(); - $contactId = $data[0]; - - //now create the user. - $xUser = $subData['username']; - $insertArr = array( - 'username' => $subData['username'], - 'password' => md5($subData['password'] .'_'. $contactId), - 'is_admin' => interpret_bool($subData['is_admin'], array('f', 't')), - 'contact_id' => $contactId - ); - $sql = "INSERT INTO user_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - - if($this->run_sql($sql, 1) === TRUE) { - $sql = "SELECT currval('user_table_uid_seq'::text)"; - if($this->run_sql($sql,1) === TRUE) { - $data = $this->db->farray(); - $lastUid = $data[0]; - - //create an email address for them. - $sql = "INSERT INTO contact_email_table (contact_id, email) VALUES (". $contactId .", '". strtolower($subData['email']) ."')"; - if($this->run_sql($sql,1) === TRUE) { - $counter++; - //get the newly inserted id, so we can update the contact table. - if($this->run_sql("SELECT currval('contact_email_table_contact_email_id_seq'::text)")) { - $data = $this->db->farray(); - $contactEmailId = $data[0]; - - $sql = "UPDATE contact_table SET contact_email_id=". $contactEmailId ." WHERE contact_id=". $contactId; - if($this->run_sql($sql)) { - $retval = $this->gfObj->create_list($retval, " --- Created record for ". $subData['username'] ." (". $lastUid .")", "<BR>\n"); - } - else { - throw new exception(__METHOD__ .": unable to update contact table with new contact_email_id..."); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve contact_email_id"); - } - } - else { - throw new exception(__METHOD__ .": failed to create email for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve uid for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to create user record for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": unable to retrieve contact_id for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to create contact record for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($counter == 2) { - $retval = $this->gfObj->create_list($retval, " --->>> done, created (". $counter .") records", "<BR>\n"); - } - else { - throw new exception(__METHOD__ .": failed to create users (". $counter .")::: ". $this->gfObj->debug_print($userData,0)); - } - - return($retval); - }//end create_users() - //========================================================================= - - - - //========================================================================= - public function finish(cs_genericPage &$page) { - - $stepRes = get_setup_data(3, 'result'); - if($stepRes == 1) { - $page->set_message_wrapper(array( - 'title' => "Successfully Setup Data", - 'message' => "All default data was stored in the new database successfully!", - 'type' => "status" - )); - store_setup_data(3, $this->data, 'data'); - $page->conditional_header("/setup/4", TRUE); - } - else { - $page->set_message_wrapper(array( - 'title' => "Step Failed", - 'message' => "Please review the errors below and proceed accordingly.", - 'type' => "error" - )); - $page->conditional_header("/setup/3", TRUE); - } - - }//end finish() - //========================================================================= - - - - //========================================================================= - protected function run_sql($sql, $expectedNumrows=NULL) { - if(strlen($sql)) { - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - $this->lastNumrows = $numrows; - $this->lastDberror = $dberror; - - if(!strlen($dberror) && $numrows >= 0) { - if(is_numeric($expectedNumrows)) { - if($expectedNumrows == $numrows) { - $retval = TRUE; - } - else { - $retval = FALSE; - } - } - else { - //don't care if it's numeric. - $retval = TRUE; - } - } - else { - throw new exception(__METHOD__ .": failed to run SQL, got numrows=(". $numrows ."), dberror::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": no SQL to run..."); - } - - return($retval); - }//end run_sql() - //========================================================================= - - - - //========================================================================= - private function create_user_group_records() { - $sql = "INSERT INTO user_group_table (uid, group_id) SELECT uid, group_id FROM user_table"; - if($this->run_sql($sql, 3) === TRUE) { - $retval = "Successfully created user_group linkage."; - } - else { - throw new exception(__METHOD__ .": unable to create user group records::: ". $this->lastDberror ."<BR>\nSQL::: ". $sql); - } - return($retval); - }//end create_user_group_records() - //========================================================================= - - -}//end __setupDefaultValues{} - - - -class _setupUpgrade extends upgrade { - - public function __construct(cs_phpDB $db) { - $this->db = $db; - parent::__construct(); - }//end __construct() - - public function finalize_conversion() { - $myVersion = parent::read_version_file(); - $setDataResult = parent::run_sql("SELECT internal_data_set_value('converted_from_version', '". parent::read_version_file() ."')"); - parent::update_num_users_to_convert(); - $retval = parent::update_database_version($myVersion); - debug_print(__METHOD__ .": myVersion=(". $myVersion ."), setDataResult=(". $setDataResult ."), retval=(". $retval .")"); - - return($myVersion); - }//end finalize_conversion() -}//end _setupUpgrade{} - ?> Modified: trunk/1.2/includes/setup/5.inc =================================================================== --- trunk/1.2/includes/setup/5.inc 2009-08-18 14:22:50 UTC (rev 979) +++ trunk/1.2/includes/setup/5.inc 2009-09-17 15:40:28 UTC (rev 980) @@ -27,10 +27,13 @@ $page->clear_content(); $test = &new TestSuite("All Tests"); - $test->addTestFile(dirname(__FILE__) .'/../../lib/_unitTests_/cs-content_tests.php'); - $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-arrayToPath/tests/testOfA2P.php'); $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-content/tests/testOfCSContent.php'); + $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-content/tests/testOfCSFileSystem.php'); + $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-content/tests/testOfCSGlobalFunctions.php'); + $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-content/tests/testOfCSVersionAbstract.php'); + $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-phpxml/tests/testOfA2P.php'); $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-phpxml/tests/testOfCSPHPXML.php'); + $test->addTestFile(dirname(__FILE__) .'/../../lib/cs-webapplibs/tests/testOfCSWebAppLibs.php'); $display = new HtmlReporter(); $test->run($display); @@ -56,155 +59,4 @@ } -class __finalStep { - - - private $page; - private $gfObj; - - - //========================================================================= - public function __construct(cs_genericPage $page, array $stepData) { - $this->page = $page; - $this->stepData = $stepData; - unset($this->stepData[5]); - - $this->gfObj = new cs_globalFunctions; - $this->fsObj = new cs_fileSystem(dirname(__FILE__) ."/../../". CONFIG_DIRECTORY); - }//end __construct() - //========================================================================= - - - - //========================================================================= - function write_config() { - if($this->fsObj->is_writable(NULL)) { - $lsData = $this->fsObj->ls(); - if(!is_array($lsData[CONFIG_FILENAME])) { - $myData = array(); - foreach($this->stepData as $stepNum=>$garbage) { - $tempStepData = get_setup_data($stepNum, 'data'); - if(is_array($tempStepData)) { - $myData = array_merge($tempStepData, $myData); - } - else { - throw new exception(__METHOD__ .": step #". $stepNum ." has no valid data... ". $this->gfObj->debug_print($tempStepData,0)); - } - } - - //now that we've built the array successfully, now let's turn it into XML. - $xmlCreator = new cs_phpxmlCreator('config'); - $tagPath = "/config/main"; - $xmlCreator->add_tag($tagPath); - $xmlCreator->add_attribute($tagPath, array('fix'=>"sanitizeDirs")); - $xmlCreator->set_tag_as_multiple($tagPath); - - //Special values (including vars that cs_siteConfig{} handles) - $specialValues = array( - 'site_root' => '{_DIRNAMEOFFILE_}/..', - 'document_root' => '{MAIN/SITE_ROOT}', - 'libdir' => '{MAIN/SITE_ROOT}/lib', - 'tmpldir' => '{MAIN/SITE_ROOT}/templates', - 'seq_helpdesk' => 'special__helpdesk_public_id_seq', - 'seq_project' => 'special__project_public_id_seq', - 'seq_main' => 'record_table_record_id_seq', - 'table_todocomment' => 'task_comment_table', - 'format_wordwrap' => '90' - ); - $defineAsGlobal=array('site_root', 'libdir', 'tmpldir'); - foreach($specialValues as $index=>$value) { - $xmlCreator->add_tag($tagPath .'/'. $index, $value); - $attributes = array('setconstant'=>1); - if(array_search($index, $defineAsGlobal)) { - $attributes['setglobal']=1; - } - $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); - } - - $skipSetConstant = array('version_string', 'workingonit'); - foreach($myData as $index=>$value) { - $xmlCreator->add_tag($tagPath ."/". $index, $value); - $attributes=array(); - if(!strlen(array_search($index, $skipSetConstant))) { - $attributes['setconstant']=1; - } - $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); - } - $extraAttributes = array( - 'generated' => date('Y-m-d H:m:s'), - 'version' => $myData['version_string'], - 'usecssiteconfig' => 1 - ); - $xmlCreator->add_attribute('/config', $extraAttributes); - - //now, create an XML string... - $xmlString = $xmlCreator->create_xml_string(); - - $this->fsObj->create_file(CONFIG_FILENAME, TRUE); - $writeRes = $this->fsObj->write($xmlString, CONFIG_FILENAME); - - if($writeRes > 0) { - $retval = "Successfully created the XML config file"; - store_setup_data(5, 1, 'result'); - store_setup_data(5, $retval, 'text'); - } - else { - throw new exception(__METHOD__ .": failed to write any data to the config file"); - } - } - else { - throw new exception(__METHOD__ .": ". CONFIG_FILE_LOCATION ." already exists!"); - } - } - else { - throw new exception(__METHOD__ .": the config directory is not writable!"); - } - - $configObj = new config(CONFIG_FILE_LOCATION); - $configObj->remove_setup_config(); - - return($retval); - }//end write_config() - //========================================================================= -} - - -//####################################################################################### -/** - * Built to avoid always printing-out the results (so we can retrieve result data separately. - */ -class MyDisplay extends SimpleReporter { - - function paintHeader($test_name) { - } - - function paintFooter($test_name) { - } - - function paintStart($test_name, $size) { - parent::paintStart($test_name, $size); - } - - function paintEnd($test_name, $size) { - parent::paintEnd($test_name, $size); - } - - function paintPass($message) { - parent::paintPass($message); - } - - function paintFail($message) { - parent::paintFail($message); - } -} -//####################################################################################### - - -class unitTest extends UnitTestCase { - - function testOfTester () { - $this->assertTrue(FALSE); - } -} - ?> Copied: trunk/1.2/lib/_setup/MyDisplay.class.php (from rev 979, trunk/1.2/includes/setup/5.inc) =================================================================== --- trunk/1.2/lib/_setup/MyDisplay.class.php (rev 0) +++ trunk/1.2/lib/_setup/MyDisplay.class.php 2009-09-17 15:40:28 UTC (rev 980) @@ -0,0 +1,46 @@ +<?php +/* + * Created on Aug 23, 2007 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + + + + +//####################################################################################### +/** + * Built to avoid always printing-out the results (so we can retrieve result data separately. + */ +class MyDisplay extends SimpleReporter { + + function paintHeader($test_name) { + } + + function paintFooter($test_name) { + } + + function paintStart($test_name, $size) { + parent::paintStart($test_name, $size); + } + + function paintEnd($test_name, $size) { + parent::paintEnd($test_name, $size); + } + + function paintPass($message) { + parent::paintPass($message); + } + + function paintFail($message) { + parent::paintFail($message); + } +} +//####################################################################################### + +?> Copied: trunk/1.2/lib/_setup/__finalStep.class.php (from rev 979, trunk/1.2/includes/setup/5.inc) =================================================================== --- trunk/1.2/lib/_setup/__finalStep.class.php (rev 0) +++ trunk/1.2/lib/_setup/__finalStep.class.php 2009-09-17 15:40:28 UTC (rev 980) @@ -0,0 +1,129 @@ +<?php +/* + * Created on Aug 23, 2007 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + + + +class __finalStep { + + + private $page; + private $gfObj; + + + //========================================================================= + public function __construct(cs_genericPage $page, array $stepData) { + $this->page = $page; + $this->stepData = $stepData; + unset($this->stepData[5]); + + $this->gfObj = new cs_globalFunctions; + $this->fsObj = new cs_fileSystem(dirname(__FILE__) ."/../../". CONFIG_DIRECTORY); + }//end __construct() + //========================================================================= + + + + //========================================================================= + function write_config() { + if($this->fsObj->is_writable(NULL)) { + $lsData = $this->fsObj->ls(); + if(!is_array($lsData[CONFIG_FILENAME])) { + $myData = array(); + foreach($this->stepData as $stepNum=>$garbage) { + $tempStepData = get_setup_data($stepNum, 'data'); + if(is_array($tempStepData)) { + $myData = array_merge($tempStepData, $myData); + } + else { + throw new exception(__METHOD__ .": step #". $stepNum ." has no valid data... ". $this->gfObj->debug_print($tempStepData,0)); + } + } + + //now that we've built the array successfully, now let's turn it into XML. + $xmlCreator = new cs_phpxmlCreator('config'); + $tagPath = "/config/main"; + $xmlCreator->add_tag($tagPath); + $xmlCreator->add_attribute($tagPath, array('fix'=>"sanitizeDirs")); + $xmlCreator->set_tag_as_multiple($tagPath); + + //Special values (including vars that cs_siteConfig{} handles) + $specialValues = array( + 'site_root' => '{_DIRNAMEOFFILE_}/..', + 'document_root' => '{MAIN/SITE_ROOT}', + 'libdir' => '{MAIN/SITE_ROOT}/lib', + 'tmpldir' => '{MAIN/SITE_ROOT}/templates', + 'seq_helpdesk' => 'special__helpdesk_public_id_seq', + 'seq_project' => 'special__project_public_id_seq', + 'seq_main' => 'record_table_record_id_seq', + 'table_todocomment' => 'task_comment_table', + 'rwdir' => '{MAIN/SITE_ROOT}/rw', + 'format_wordwrap' => '90' + ); + $defineAsGlobal=array('site_root', 'libdir', 'tmpldir'); + foreach($specialValues as $index=>$value) { + $xmlCreator->add_tag($tagPath .'/'. $index, $value); + $attributes = array('setconstant'=>1); + if(array_search($index, $defineAsGlobal)) { + $attributes['setglobal']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); + } + + $skipSetConstant = array('version_string', 'workingonit'); + foreach($myData as $index=>$value) { + $xmlCreator->add_tag($tagPath ."/". $index, $value); + $attributes=array(); + if(!strlen(array_search($index, $skipSetConstant))) { + $attributes['setconstant']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); + } + $extraAttributes = array( + 'generated' => date('Y-m-d H:m:s'), + 'version' => $myData['version_string'], + 'usecssiteconfig' => 1 + ); + $xmlCreator->add_attribute('/config', $extraAttributes); + + //now, create an XML string... + $xmlString = $xmlCreator->create_xml_string(); + + $this->fsObj->create_file(CONFIG_FILENAME, TRUE); + $writeRes = $this->fsObj->write($xmlString, CONFIG_FILENAME); + + if($writeRes > 0) { + $retval = "Successfully created the XML config file"; + store_setup_data(5, 1, 'result'); + store_setup_data(5, $retval, 'text'); + } + else { + throw new exception(__METHOD__ .": failed to write any data to the config file"); + } + } + else { + throw new exception(__METHOD__ .": ". CONFIG_FILE_LOCATION ." already exists!"); + } + } + else { + throw new exception(__METHOD__ .": the config directory is not writable!"); + } + + $configObj = new config(CONFIG_FILE_LOCATION); + $configObj->remove_setup_config(); + + return($retval); + }//end write_config() + //========================================================================= +} + + +?> Copied: trunk/1.2/lib/_setup/__setupDefaultValues.class.php (from rev 979, trunk/1.2/includes/setup/3.inc) =================================================================== --- trunk/1.2/lib/_setup/__setupDefaultValues.class.php (rev 0) +++ trunk/1.2/lib/_setup/__setupDefaultValues.class.php 2009-09-17 15:40:28 UTC (rev 980) @@ -0,0 +1,974 @@ +<?php +/* + * Created on Aug 23, 2007 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + +class __setupDefaultValues extends cs_webdbupgrade { + + + protected $db; + private $totalRecords=0; + + private $data=array(); + + private $lastNumrows=NULL; + private $lastDberror=NULL; + + //========================================================================= + public function __construct() { + $this->db = new cs_phpDB; + $this->gfObj = new cs_globalFunctions; + }//end __construct() + //========================================================================= + + + + //========================================================================= + public function go() { + store_setup_data(3, 0, 'result'); + try { + $params = get_db_params(); + $this->db->connect($params); + $this->db->beginTrans(__METHOD__); + $retval = "Connected successfully to the database."; + + //now that we've connected, start doing stuff. + $retval = $this->set_version(); + $retval .= "<BR>\n". $this->create_log_categories_and_classes(); + $retval .= "<BR>\n". $this->create_attributes(); + $retval .= "<BR>\n". $this->create_anonymous_contact_data(); + $retval .= "<BR>\n". $this->create_status_records(); + $retval .= "<BR>\n". $this->create_tag_names(); + $retval .= "<BR>\n". $this->build_preferences(); + $retval .= "<BR>\n". $this->create_users(); + $retval .= "<BR>\n". $this->create_user_group_records(); + + $commitRes = $this->db->commitTrans(); + if($commitRes == 1) { + $retval .= "<BR>\n ----------- Created (". $this->totalRecords ."), result of commit: (". $commitRes .")."; + store_setup_data(3, 1, 'result'); + store_setup_data(4, 1, 'accessible'); + } + else { + $this->db->rollbackTrans(); + store_setup_data(3, 0, 'result'); + throw new exception(__METHOD__ .": failed to commit the transaction (". $commitRes .")"); + } + + } + catch(exception $e) { + //TODO: rollback the transaction + $retval = "An error occurred: ". $e->getMessage(); + } + + return($retval); + + }//end go() + //========================================================================= + + + + //========================================================================= + /** + * Set version information into the database for future upgradeability. + */ + private function set_version() { + //get the version string. + $fullVersionString = read_version_file(); + + $suffixData = explode('-', $fullVersionString); + if(count($suffixData) == 2 && preg_match('/\./', $suffixData[0]) && !preg_match('/\./', $suffixData[1])) { + //there's a suffix, and it doesn't contain periods (i.e. "1.0.0-ALPHA1") + $suffix = $suffixData[1]; + } + elseif(count($suffixData) == 1) { + //no suffix. + $suffix = ""; + } + else { + //there's a dash in the name, but it's invalid or contains periods (i.e. "BETA-1.0.0" or "1.0.0-ALPHA1.0") + throw new exception(__METHOD__ .": version string is invalid (". $fullVersionString ."), suffix contains dashes, or there is a prefix"); + } + + //remove the suffix & parse it. + $versionString = $suffixData[0]; + $versionData = $this->parse_version_string($fullVersionString); + $sqlData = $versionData; + + + #$sqlData = array( + # 'version_string' => $fullVersionString, + # 'version_major' => $versionData[0], + # 'version_minor' => $versionData[1], + # 'version_maintenance' => $versionData[2], + # 'version_suffix' => $suffix + #); + + $retval = 0; + foreach($sqlData as $name => $value) { + $sql = "SELECT internal_data_set_value('". $name ."', '". $value ."')"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to set (". $name .") as (". $value .")::: ". $dberror); + } + } + + if($retval == count($sqlData)) { + //okay, the final test: run a query that straps everything together, to ensure it all has the same version. + $sql = "SELECT internal_data_get_value('version_major') || '.' || internal_data_get_value('version_minor') " . + " || '.' || internal_data_get_value('version_maintenance') as text, " . + "internal_data_get_value('version_suffix') as version_suffix;"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $data = $this->db->farray(); + $dbVersionString = $data['text']; + if(strlen($data['version_suffix'])) { + $dbVersionString .= "-". $data['version_suffix']; + } + + if($dbVersionString === $fullVersionString) { + //okay, one final test: check that the "version_string" in the database matches ours. + $sql = "SELECT internal_data_get_value('version_string')"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $data = $this->db->farray(); + $dbVersionString = $data[0]; + + if($dbVersionString === $fullVersionString) { + $this->data[... [truncated message content] |
From: <cra...@us...> - 2009-09-21 02:55:24
|
Revision: 983 http://cs-project.svn.sourceforge.net/cs-project/?rev=983&view=rev Author: crazedsanity Date: 2009-09-21 02:55:16 +0000 (Mon, 21 Sep 2009) Log Message: ----------- Remove require_once(): handled by cs-content's __autoload.php. /includes/content.inc /includes/content/contacts/index.inc /includes/content/contacts/view.inc /lib/bbCodeParser.class.php Modified Paths: -------------- trunk/1.2/includes/content/contacts/index.inc trunk/1.2/includes/content/contacts/view.inc trunk/1.2/includes/content.inc trunk/1.2/lib/bbCodeParser.class.php Modified: trunk/1.2/includes/content/contacts/index.inc =================================================================== --- trunk/1.2/includes/content/contacts/index.inc 2009-09-21 02:47:34 UTC (rev 982) +++ trunk/1.2/includes/content/contacts/index.inc 2009-09-21 02:55:16 UTC (rev 983) @@ -10,8 +10,6 @@ * Last Updated: $Date$ */ -require_once(dirname(__FILE__) .'/../../../lib/contactClass.php'); - $contactObj = new contactClass($page->db); $page->allow_invalid_urls(TRUE); Modified: trunk/1.2/includes/content/contacts/view.inc =================================================================== --- trunk/1.2/includes/content/contacts/view.inc 2009-09-21 02:47:34 UTC (rev 982) +++ trunk/1.2/includes/content/contacts/view.inc 2009-09-21 02:55:16 UTC (rev 983) @@ -10,8 +10,6 @@ * Last Updated: $Date$ */ -require_once(dirname(__FILE__) .'/../../../lib/contactClass.php'); - $contactObj = new contactClass($page->db); $page->allow_invalid_urls(TRUE); Modified: trunk/1.2/includes/content.inc =================================================================== --- trunk/1.2/includes/content.inc 2009-09-21 02:47:34 UTC (rev 982) +++ trunk/1.2/includes/content.inc 2009-09-21 02:55:16 UTC (rev 983) @@ -8,9 +8,7 @@ * Last Updated:::::::: $Date$ */ -require_once(dirname(__FILE__) ."/../lib/cs-content/cs_tabs.class.php"); - $db = new cs_phpDB; $db->connect(get_config_db_params()); $page->db = $db; Modified: trunk/1.2/lib/bbCodeParser.class.php =================================================================== --- trunk/1.2/lib/bbCodeParser.class.php 2009-09-21 02:47:34 UTC (rev 982) +++ trunk/1.2/lib/bbCodeParser.class.php 2009-09-21 02:55:16 UTC (rev 983) @@ -18,8 +18,6 @@ * been converted. */ -require_once(dirname(__FILE__) .'/cs-content/cs_bbCodeParser.class.php'); - class bbCodeParser extends cs_bbCodeParser { /** Array containing all the codes & how to parse them. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-10-25 18:37:08
|
Revision: 992 http://cs-project.svn.sourceforge.net/cs-project/?rev=992&view=rev Author: crazedsanity Date: 2009-10-25 18:37:02 +0000 (Sun, 25 Oct 2009) Log Message: ----------- Fix a pass-by-reference error, require captcha when using external interface. Fixes issue #304 ("Spam Blocking Measures") /includes/extern.inc: * don't pass $db by reference (causes an error) /includes/extern/helpdesk.inc: * store POSTed remark in the session in case they failed the captcha. * give a special error if they failed the captcha * remove the stored data if they passed the captcha. * put POSTed remark back on the page as a template var.. /includes/extern/shared.inc [NEW]: * handles the captcha stuff /lib/recaptchalib.php [NEW]: * library for the captcha stuff. /templates/header.shared.tmpl: * add "SCRIPT_EXTRA" var for extra scripts. /templates/extern/helpdesk/SCRIPT_EXTRA.shared.tmpl [NEW]: * sets some javascript stuff so the captcha displays the simple version. /templates/extern/helpdesk/view.content.tmpl: * add placeholder for captcha & a template var for stored remark. Modified Paths: -------------- trunk/1.2/includes/extern/helpdesk.inc trunk/1.2/includes/extern.inc trunk/1.2/templates/extern/helpdesk/view.content.tmpl trunk/1.2/templates/header.shared.tmpl Added Paths: ----------- trunk/1.2/includes/extern/shared.inc trunk/1.2/lib/recaptchalib.php trunk/1.2/templates/extern/helpdesk/SCRIPT_EXTRA.shared.tmpl Modified: trunk/1.2/includes/extern/helpdesk.inc =================================================================== --- trunk/1.2/includes/extern/helpdesk.inc 2009-09-21 14:53:33 UTC (rev 991) +++ trunk/1.2/includes/extern/helpdesk.inc 2009-10-25 18:37:02 UTC (rev 992) @@ -19,6 +19,9 @@ if($postAction == "remark") { $helpdeskId = $_POST['ID']; + $_SESSION['POST_remark'] = $_POST['remark']; + + if($captchaResult === true) { if(is_numeric($helpdeskId)) { //now check to make sure they can actually remark on it... $helpdeskData = $proj->helpdeskObj->get_record($helpdeskId); @@ -45,6 +48,7 @@ "message" => "Your remark has been added to the database. Thank you for your feedback.", "type" => "status" )); + unset($_SESSION['POST_remark']); } else { set_message_wrapper(array( @@ -76,32 +80,17 @@ conditional_header("/extern/helpdesk/"); exit; } - } - elseif($_POST && strtolower($_POST['submit']) == "go" && !isset($_POST['action'])) { - //they're CREATING an issue. - $result = $proj->helpdeskObj->create_record($_POST['data']); - - //first, determine what happened from the result... - if($result > 0) { - //everything worked. - set_message_wrapper(array( - "title" => "Issue Successfully Created", - "message" => "Your issue has been added to the helpdesk. You should receive an email shortly with confirmation.", - "type" => "notice" - )); } else { - //something failed. + //didn't give me the proper captcha data... set_message_wrapper(array( - "title" => "Unable to Create Issue", - "message" => "Something broke. Sorry.", - "type" => "notice" + 'title' => "Captcha Failed", + 'message' => "You didn't answer the CAPTCHA correctly. Are you really a person?", + 'type' => "error" )); + conditional_header("/extern/helpdesk/view?ID=". $helpdeskId); + exit; } - - //send 'em packing. - conditional_header("/extern/helpdesk/view?ID=$result"); - exit; } elseif($_POST['action'] == "filter") { if($_POST['reset_filter']) { @@ -118,6 +107,7 @@ } } else { + $page->add_template_var('POST_remark', $_SESSION['POST_remark']); $action = $page->ftsSections[2]; $helpdeskId = $_GET['ID']; $page->add_template_var("id", $helpdeskId); Added: trunk/1.2/includes/extern/shared.inc =================================================================== --- trunk/1.2/includes/extern/shared.inc (rev 0) +++ trunk/1.2/includes/extern/shared.inc 2009-10-25 18:37:02 UTC (rev 992) @@ -0,0 +1,40 @@ +<?php +/* + * Created on Oct 23, 2009 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + +require_once(constant('LIBDIR') .'/recaptchalib.php'); + +//TODO: put these into the site config and make 'em constants. +// Get a key from http://recaptcha.net/api/getkey + +$error = null; +$resp = null; + +$captchaResult = false; + +if($_POST && isset($_POST["recaptcha_challenge_field"])) { + $resp = recaptcha_check_answer (constant('RECAPTCHA_PRIVATEKEY'), + $_SERVER["REMOTE_ADDR"], + $_POST["recaptcha_challenge_field"], + $_POST["recaptcha_response_field"] + ); + if($resp->is_valid) { + $captchaResult = true; + } + else { + $error = $resp->error; + } +} + + +$page->add_template_var('captcha', recaptcha_get_html(constant('RECAPTCHA_PUBLICKEY'), $error)); + +?> Property changes on: trunk/1.2/includes/extern/shared.inc ___________________________________________________________________ Added: svn:keywords + Author Revision HeadURL Date Modified: trunk/1.2/includes/extern.inc =================================================================== --- trunk/1.2/includes/extern.inc 2009-09-21 14:53:33 UTC (rev 991) +++ trunk/1.2/includes/extern.inc 2009-10-25 18:37:02 UTC (rev 992) @@ -15,7 +15,7 @@ $db = new cs_phpDB; $db->connect(get_config_db_params()); -$page->db = &$db; +$page->db = $db; //The "sectionArr" is provided from contentSystem::finish() as a local var, and ftsSections is a leftover from fast_templating. $page->ftsSections = $sectionArr; Added: trunk/1.2/lib/recaptchalib.php =================================================================== --- trunk/1.2/lib/recaptchalib.php (rev 0) +++ trunk/1.2/lib/recaptchalib.php 2009-10-25 18:37:02 UTC (rev 992) @@ -0,0 +1,277 @@ +<?php +/* + * This is a PHP library that handles calling reCAPTCHA. + * - Documentation and latest version + * http://recaptcha.net/plugins/php/ + * - Get a reCAPTCHA API Key + * http://recaptcha.net/api/getkey + * - Discussion group + * http://groups.google.com/group/recaptcha + * + * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net + * AUTHORS: + * Mike Crawford + * Ben Maurer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * The reCAPTCHA server URL's + */ +define("RECAPTCHA_API_SERVER", "http://api.recaptcha.net"); +define("RECAPTCHA_API_SECURE_SERVER", "https://api-secure.recaptcha.net"); +define("RECAPTCHA_VERIFY_SERVER", "api-verify.recaptcha.net"); + +/** + * Encodes the given data into a query string format + * @param $data - array of string elements to be encoded + * @return string - encoded request + */ +function _recaptcha_qsencode ($data) { + $req = ""; + foreach ( $data as $key => $value ) + $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + + // Cut the last '&' + $req=substr($req,0,strlen($req)-1); + return $req; +} + + + +/** + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ +function _recaptcha_http_post($host, $path, $data, $port = 80) { + + $req = _recaptcha_qsencode ($data); + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($req) . "\r\n"; + $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; + $http_request .= "\r\n"; + $http_request .= $req; + + $response = ''; + if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + + return $response; +} + + + +/** + * Gets the challenge HTML (javascript and non-javascript version). + * This is called from the browser, and the resulting reCAPTCHA HTML widget + * is embedded within the HTML form it was called from. + * @param string $pubkey A public key for reCAPTCHA + * @param string $error The error given by reCAPTCHA (optional, default is null) + * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) + + * @return string - The HTML to be embedded in the user's form. + */ +function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) +{ + if ($pubkey == null || $pubkey == '') { + die ("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>"); + } + + if ($use_ssl) { + $server = RECAPTCHA_API_SECURE_SERVER; + } else { + $server = RECAPTCHA_API_SERVER; + } + + $errorpart = ""; + if ($error) { + $errorpart = "&error=" . $error; + } + return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> + + <noscript> + <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> + <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> + <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> + </noscript>'; +} + + + + +/** + * A ReCaptchaResponse is returned from recaptcha_check_answer() + */ +class ReCaptchaResponse { + var $is_valid; + var $error; +} + + +/** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param string $privkey + * @param string $remoteip + * @param string $challenge + * @param string $response + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ +function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) +{ + if ($privkey == null || $privkey == '') { + die ("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>"); + } + + if ($remoteip == null || $remoteip == '') { + die ("For security reasons, you must pass the remote ip to reCAPTCHA"); + } + + + + //discard spam submissions + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { + $recaptcha_response = new ReCaptchaResponse(); + $recaptcha_response->is_valid = false; + $recaptcha_response->error = 'incorrect-captcha-sol'; + return $recaptcha_response; + } + + $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/verify", + array ( + 'privatekey' => $privkey, + 'remoteip' => $remoteip, + 'challenge' => $challenge, + 'response' => $response + ) + $extra_params + ); + + $answers = explode ("\n", $response [1]); + $recaptcha_response = new ReCaptchaResponse(); + + if (trim ($answers [0]) == 'true') { + $recaptcha_response->is_valid = true; + } + else { + $recaptcha_response->is_valid = false; + $recaptcha_response->error = $answers [1]; + } + return $recaptcha_response; + +} + +/** + * gets a URL where the user can sign up for reCAPTCHA. If your application + * has a configuration page where you enter a key, you should provide a link + * using this function. + * @param string $domain The domain where the page is hosted + * @param string $appname The name of your application + */ +function recaptcha_get_signup_url ($domain = null, $appname = null) { + return "http://recaptcha.net/api/getkey?" . _recaptcha_qsencode (array ('domain' => $domain, 'app' => $appname)); +} + +function _recaptcha_aes_pad($val) { + $block_size = 16; + $numpad = $block_size - (strlen ($val) % $block_size); + return str_pad($val, strlen ($val) + $numpad, chr($numpad)); +} + +/* Mailhide related code */ + +function _recaptcha_aes_encrypt($val,$ky) { + if (! function_exists ("mcrypt_encrypt")) { + die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); + } + $mode=MCRYPT_MODE_CBC; + $enc=MCRYPT_RIJNDAEL_128; + $val=_recaptcha_aes_pad($val); + return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); +} + + +function _recaptcha_mailhide_urlbase64 ($x) { + return strtr(base64_encode ($x), '+/', '-_'); +} + +/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ +function recaptcha_mailhide_url($pubkey, $privkey, $email) { + if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { + die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . + "you can do so at <a href='http://mailhide.recaptcha.net/apikey'>http://mailhide.recaptcha.net/apikey</a>"); + } + + + $ky = pack('H*', $privkey); + $cryptmail = _recaptcha_aes_encrypt ($email, $ky); + + return "http://mailhide.recaptcha.net/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); +} + +/** + * gets the parts of the email to expose to the user. + * eg, given johndoe@example,com return ["john", "example.com"]. + * the email is then displayed as john...@example.com + */ +function _recaptcha_mailhide_email_parts ($email) { + $arr = preg_split("/@/", $email ); + + if (strlen ($arr[0]) <= 4) { + $arr[0] = substr ($arr[0], 0, 1); + } else if (strlen ($arr[0]) <= 6) { + $arr[0] = substr ($arr[0], 0, 3); + } else { + $arr[0] = substr ($arr[0], 0, 4); + } + return $arr; +} + +/** + * Gets html to display an email address given a public an private key. + * to get a key, go to: + * + * http://mailhide.recaptcha.net/apikey + */ +function recaptcha_mailhide_html($pubkey, $privkey, $email) { + $emailparts = _recaptcha_mailhide_email_parts ($email); + $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); + + return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) . + "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]); + +} + + +?> Added: trunk/1.2/templates/extern/helpdesk/SCRIPT_EXTRA.shared.tmpl =================================================================== --- trunk/1.2/templates/extern/helpdesk/SCRIPT_EXTRA.shared.tmpl (rev 0) +++ trunk/1.2/templates/extern/helpdesk/SCRIPT_EXTRA.shared.tmpl 2009-10-25 18:37:02 UTC (rev 992) @@ -0,0 +1,5 @@ +<script type= "text/javascript"> +var RecaptchaOptions = { +theme: 'clean' +}; +</script> \ No newline at end of file Modified: trunk/1.2/templates/extern/helpdesk/view.content.tmpl =================================================================== --- trunk/1.2/templates/extern/helpdesk/view.content.tmpl 2009-09-21 14:53:33 UTC (rev 991) +++ trunk/1.2/templates/extern/helpdesk/view.content.tmpl 2009-10-25 18:37:02 UTC (rev 992) @@ -63,14 +63,14 @@ <td></td> <td colspan="2">Remark: <br> - <textarea name="remark" rows="8" cols="80"></textarea> + <textarea name="remark" rows="8" cols="80">{POST_remark}</textarea> </td> </tr> <tr> <td></td> - <td colspan="2"> - <input name="action" value="Remark" type="submit"> + <td colspan="2">{captcha} + <input name="action" value="Remark" type="submit"> </td> </tr> Modified: trunk/1.2/templates/header.shared.tmpl =================================================================== --- trunk/1.2/templates/header.shared.tmpl 2009-09-21 14:53:33 UTC (rev 991) +++ trunk/1.2/templates/header.shared.tmpl 2009-10-25 18:37:02 UTC (rev 992) @@ -3,6 +3,7 @@ <title>{html_title}</title> <link rel=stylesheet type='text/css' href='/css/common.css'> {XAJAX_HEADERS} + {SCRIPT_EXTRA} <script language="javascript" src="/js/prototype.js" type="text/javascript"></script> <script language="javascript" src="/js/scriptaculous.js" type="text/javascript"></script> <script language="javascript" src="/js/cs-project.js" type="text/javascript"></script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-10-26 14:53:18
|
Revision: 1001 http://cs-project.svn.sourceforge.net/cs-project/?rev=1001&view=rev Author: crazedsanity Date: 2009-10-26 14:53:07 +0000 (Mon, 26 Oct 2009) Log Message: ----------- Version string now pulled from main VERSION file. /includes/content.inc: * Moved creation of $db, connection of database handle, and setting of the "VERSION_STRING" or "cs-version_string" template vars into a shared include file so it reports the proper version string. /includes/help.inc: * same as content.inc * removed some commented-out code. /includes/login.inc: * same as content.inc * remove setting of cs-project_version template var /includes/setup.inc: * set VERSION_STRING using config::get_version(). /includes/shared.inc [NEW]: * create $db var * connect $db * set VERSION_STRING and cs-version_string template vars using projectClass::get_version() instead of reading from main config file. /lib/config.class.php: * __construct(): -- call set_version_file_location() so code calling it's get_version() or get_project() method (from cs_versionAbstract{}) will get the proper strings returned. /lib/mainRecordClass.php: * MAIN::: -- extends cs_versionAbstract * __construct(): -- call set_version_file_location(). Modified Paths: -------------- trunk/1.2/includes/content.inc trunk/1.2/includes/help.inc trunk/1.2/includes/login.inc trunk/1.2/includes/setup.inc trunk/1.2/lib/config.class.php trunk/1.2/lib/mainRecordClass.php Added Paths: ----------- trunk/1.2/includes/shared.inc Modified: trunk/1.2/includes/content.inc =================================================================== --- trunk/1.2/includes/content.inc 2009-10-26 12:29:02 UTC (rev 1000) +++ trunk/1.2/includes/content.inc 2009-10-26 14:53:07 UTC (rev 1001) @@ -9,10 +9,6 @@ */ -$db = new cs_phpDB; -$db->connect(get_config_db_params()); -$page->db = $db; - $page->session = new Session($page->db); //initialize everything we need to display the page & remember stuff in the session. @@ -22,9 +18,7 @@ $page->ftsSections = $sectionArr; -$page->add_template_var('cs-project_version', VERSION_STRING); - //done with redirection. Here's where we define if they have to be logged-in, and then run the fast_templating engine. //TODO: update this to be "cs-content friendly". :) $mustBeLoggedIn = 1; Modified: trunk/1.2/includes/help.inc =================================================================== --- trunk/1.2/includes/help.inc 2009-10-26 12:29:02 UTC (rev 1000) +++ trunk/1.2/includes/help.inc 2009-10-26 14:53:07 UTC (rev 1001) @@ -4,15 +4,6 @@ */ -$page->add_template_var('cs-project_version', VERSION_STRING); - - -$db = new cs_phpDB; -$db->connect(get_config_db_params()); -$page->db = $db; - - -#$titlePart = NULL; $titlePart = "Help"; if(ISDEVSITE) { Modified: trunk/1.2/includes/login.inc =================================================================== --- trunk/1.2/includes/login.inc 2009-10-26 12:29:02 UTC (rev 1000) +++ trunk/1.2/includes/login.inc 2009-10-26 14:53:07 UTC (rev 1001) @@ -11,11 +11,7 @@ $page->clear_content("header"); -$db = new cs_phpDB; -$db->connect(get_config_db_params()); -$page->db = $db; -$page->add_template_var('cs-project_version', VERSION_STRING); $page->add_template_var('MAINTABLE_EXTRA', 'align="center"'); if(isset($_GET['loginDestination']) && strlen($_GET['loginDestination'])) { Modified: trunk/1.2/includes/setup.inc =================================================================== --- trunk/1.2/includes/setup.inc 2009-10-26 12:29:02 UTC (rev 1000) +++ trunk/1.2/includes/setup.inc 2009-10-26 14:53:07 UTC (rev 1001) @@ -71,7 +71,7 @@ } - $page->add_template_var("VERSION_STRING", read_version_file()); + $page->add_template_var("VERSION_STRING", $configObj->get_version()); $page->rip_all_block_rows('stepData'); $page->clear_content('infobar'); Added: trunk/1.2/includes/shared.inc =================================================================== --- trunk/1.2/includes/shared.inc (rev 0) +++ trunk/1.2/includes/shared.inc 2009-10-26 14:53:07 UTC (rev 1001) @@ -0,0 +1,27 @@ +<?php +/* + * Created on Oct 26, 2009 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + + +try { + $db = new cs_phpDB; + $db->connect(get_config_db_params()); + $page->db = $db; + + $tProj = new projectClass($db); + $page->add_template_var('cs-project_version', $tProj->get_version()); + $page->add_template_var('VERSION_STRING', $tProj->get_version()); + unset($tProj); +} +catch(exception $e) { + //nothing to see here, move along (probably not setup yet). +} +?> Property changes on: trunk/1.2/includes/shared.inc ___________________________________________________________________ Added: svn:keywords + Author Revision HeadURL Date Modified: trunk/1.2/lib/config.class.php =================================================================== --- trunk/1.2/lib/config.class.php 2009-10-26 12:29:02 UTC (rev 1000) +++ trunk/1.2/lib/config.class.php 2009-10-26 14:53:07 UTC (rev 1001) @@ -20,6 +20,8 @@ $this->gf = new cs_globalFunctions(); $this->fs = new cs_fileSystem(dirname(__FILE__) .'/..'); + $this->set_version_file_location(dirname(__FILE__) .'/../VERSION'); + $this->fileName = dirname(__FILE__) .'/'. CONFIG_FILENAME; if(!is_null($fileName) && strlen($fileName)) { $this->fileName = $fileName; Modified: trunk/1.2/lib/mainRecordClass.php =================================================================== --- trunk/1.2/lib/mainRecordClass.php 2009-10-26 12:29:02 UTC (rev 1000) +++ trunk/1.2/lib/mainRecordClass.php 2009-10-26 14:53:07 UTC (rev 1001) @@ -12,7 +12,7 @@ */ -class mainRecord { +class mainRecord extends cs_versionAbstract { public $db; public $isHelpdeskIssue = FALSE; @@ -31,6 +31,8 @@ //========================================================================= function __construct() { + $this->set_version_file_location(dirname(__FILE__) .'/../VERSION'); + //these are fairly generic, & can be updated easily. $this->updateableFieldsArr = array( 'group_id' => 'numeric', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |