From e7988503f790bfa136f25cd4ae6e23fdcfaee322 Mon Sep 17 00:00:00 2001 From: Alan Jack Pippin Date: Sun, 13 Jan 2008 21:47:52 -0700 Subject: [PATCH] Numerous bug fixes from Brett's turn-on experience. --- bin/import_ward_data | 23 +++++++++-------------- bin/parse_ward_data | 11 +++++++---- doc/install.txt | 13 ++++++++++--- inc/class.eq.inc.php | 34 +++++++++++++++++++++------------- sql/eq.sql | 1 + templates/default/admin.tpl | 3 ++- 6 files changed, 50 insertions(+), 35 deletions(-) diff --git a/bin/import_ward_data b/bin/import_ward_data index bd707b4..ef6d62b 100755 --- a/bin/import_ward_data +++ b/bin/import_ward_data @@ -2,13 +2,16 @@ use DBI; use Getopt::Std; + ################################################### # GLOBALS $dbname = "phpgroupware"; -$dbhost = "192.168.0.2"; +$dbhost = "192.168.0.2"; # This can be an IP address or name $dbport = 3306; -$dbuser = "phpgroupware"; -$dbpass = "phpgroupware"; +$dbuser = "phpgroupware"; # This may require an additional '\@localhost' +$dbpass = "phpgroupware"; +################################################### + %hometeaching_data = (); %membership_data = (); getopts('vsn:o:'); @@ -664,7 +667,7 @@ sub check_for_changed_ids ################################################### # Open a connection to the database -$dbh=DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost port=$dbport",$dbuser,$dbpass,{ +$dbh=DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost;port=$dbport",$dbuser,$dbpass,{ AutoCommit=>0, PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2; @@ -726,6 +729,8 @@ if($opt_s) { $dbh->disconnect(); exit; } &update_eq_parent_table(); &update_eq_child_table(); +print "\n-> Import Successful! DONE...\n"; + ################################################### # Disconnect from the database $dbh->disconnect(); @@ -733,13 +738,3 @@ $dbh->disconnect(); ###################################################################### - - - - - - - - - - diff --git a/bin/parse_ward_data b/bin/parse_ward_data index 82a1730..c2397cf 100755 --- a/bin/parse_ward_data +++ b/bin/parse_ward_data @@ -2,13 +2,16 @@ use DBI; use Getopt::Std; + ################################################### # GLOBALS $dbname = "phpgroupware"; -$dbhost = "192.168.0.2"; +$dbhost = "192.168.0.2"; # This can be an IP address or a name $dbport = 3306; -$dbuser = "phpgroupware"; -$dbpass = "phpgroupware"; +$dbuser = "phpgroupware"; # This may require an additional '\@localhost' +$dbpass = "phpgroupware"; +################################################### + %hometeaching_data = (); %membership_data = (); getopts('vsn:o:b'); @@ -91,7 +94,7 @@ sub print_birthdays ################################################### # Open a connection to the database -$dbh=DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost port=$dbport",$dbuser,$dbpass,{ +$dbh=DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost;port=$dbport",$dbuser,$dbpass,{ AutoCommit=>0, PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2; diff --git a/doc/install.txt b/doc/install.txt index c8c5d6b..d1df207 100644 --- a/doc/install.txt +++ b/doc/install.txt @@ -32,13 +32,20 @@ Installing 4) Edit the LOCAL CONFIGURATION section of eq/inc/class.eq.inc.php Make sure you update the path locations for your specific: upload_target_path & script_path - 5) A graphical representation of the mysql schema used by this application can + 5) Edit the GLOBALS section of the eq/bin/import_ward_data script + 6) Edit the GLOBALS section of the eq/bin/parse_ward_data script + 7) Try to run eq/bin/import_ward_data & parse_ward_data scripts from the commandline + to check for any missing perl library dependencies and mysql connection. + Just run them without command line args. + Install the right perl modules until the scripts run without any errors. + 8) A graphical representation of the mysql schema used by this application can be found here: eq/sql/eq.jpg - 6) Click on the Admin tool in the EQ app to import your initial set of ward data + 9) Click on the Admin tool in the EQ app to import your initial set of ward data obtained from MLS into the EQ application. - 7) Click on the Admin tool and update the EQ Presidency Table appropriately. + 10) Click on the Admin tool and update the EQ Presidency Table appropriately. The most important thing at this point is to get your district leaders added for each district you have in your quorum. + 11) I highly recommend installing phpmyadmin to view/edit/debug mysql tables related to this tool. Requirements diff --git a/inc/class.eq.inc.php b/inc/class.eq.inc.php index 84f234f..74c79ed 100644 --- a/inc/class.eq.inc.php +++ b/inc/class.eq.inc.php @@ -68,8 +68,8 @@ class eq function eq() { // LOCAL CONFIGURATION. PLEASE UPDATE AS APPROPRIATE. - $this->upload_target_path = "/home/users/eqpres/eq_data/"; - $this->script_path = "/usr/share/phpgroupware/eq/bin/"; + $this->upload_target_path = "/home/users/eqpres/eq_data"; + $this->script_path = "/usr/share/phpgroupware/eq/bin"; $this->default_ht_num_months = 3; $this->default_ppi_num_months = 3; $this->default_ppi_num_years = 0; @@ -3834,13 +3834,21 @@ class eq if($action == 'upload') { - $target_path = $this->upload_target_path . basename( $_FILES['uploadedfile']['name']); + $target_path = $this->upload_target_path . '/' . basename( $_FILES['uploadedfile']['name']); - if((($_FILES['uploadedfile']['type'] == "application/zip") || - ($_FILES['uploadedfile']['type'] == "application/x-zip-compressed") || - ($_FILES['uploadedfile']['type'] == "application/x-zip") || - ($_FILES['uploadedfile']['type'] == "application/octet-stream")) && - (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))) { + if(($_FILES['uploadedfile']['type'] == "application/zip") || + ($_FILES['uploadedfile']['type'] == "application/x-zip-compressed") || + ($_FILES['uploadedfile']['type'] == "application/x-zip") || + ($_FILES['uploadedfile']['type'] == "application/octet-stream")) { + + if(!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { + $uploadstatus = " -E- Unable to move the uploaded file to "; + $uploadstatus.= "the target path (check the path and permissions) of: $target_path"; + $this->t->set_var('uploadstatus',$uploadstatus); + $this->t->pfp('uploadhandle','upload',True); + return 0; + } + $uploadstatus = "The following file was uploaded successfully:

"; $uploadstatus.= "Filename : " . $_FILES['uploadedfile']['name'] . "
"; $uploadstatus.= "Type : " . $_FILES['uploadedfile']['type'] . "
"; @@ -3852,9 +3860,9 @@ class eq # make a directory for this data to be stored in $date="data_" . date("Y_m_d"); - $data_dir = $this->upload_target_path . $date; + $data_dir = $this->upload_target_path . '/' . $date; print "-> Making the data directory: $date
\n"; - exec('mkdir ' . $data_dir . ' 2>&1', $result, $return_code); + exec('mkdir -p ' . $data_dir . ' 2>&1', $result, $return_code); if($return_code != 0) { print implode('\n',$result) . "
"; print ""; @@ -3889,7 +3897,7 @@ class eq # update the data_latest link to point to this new directory print "-> Updating the latest data dir link
\n"; - $data_latest = $this->upload_target_path . 'data_latest'; + $data_latest = $this->upload_target_path . '/data_latest'; exec('rm ' . $data_latest. '; ln -s ' . $data_dir .' '. $data_latest .' 2>&1', $result, $return_code); if($return_code != 0) { print implode('\n',$result) . "
"; @@ -3905,8 +3913,8 @@ class eq ob_flush(); flush(); sleep(1); $import_log = $this->upload_target_path . '/import.log'; $data_log = $this->upload_target_path . '/data.log'; - $import_cmd = $this->script_path . 'import_ward_data ' . $data_latest . ' | tee ' . $import_log; - $parse_cmd = $this->script_path . 'parse_ward_data -v ' . $data_latest . ' > ' . $data_log; + $import_cmd = $this->script_path . '/import_ward_data ' . $data_latest . ' 2>&1 | tee ' . $import_log; + $parse_cmd = $this->script_path . '/parse_ward_data -v ' . $data_latest . ' > ' . $data_log . '2>&1'; #print "import_cmd: $import_cmd
"; #print "parse_cmd: $parse_cmd
"; ob_start('ob_logstdout', 2); diff --git a/sql/eq.sql b/sql/eq.sql index 664cdb8..277ab8b 100644 --- a/sql/eq.sql +++ b/sql/eq.sql @@ -222,6 +222,7 @@ CREATE TABLE `eq_presidency` ( `president` tinyint(1) default '0', `counselor` tinyint(1) default '0', `secretary` tinyint(1) default '0', + `eqpres` tinyint(1) default '0', `valid` tinyint(1) default '1', KEY `presidency` (`presidency`), KEY `elder` (`elder`) diff --git a/templates/default/admin.tpl b/templates/default/admin.tpl index 560dadf..a8a3cdf 100644 --- a/templates/default/admin.tpl +++ b/templates/default/admin.tpl @@ -55,11 +55,12 @@ {table_data} Notes: +
- The District is a drop-down list. Please assign a unique district number per district supervisor.
- The President, Counselor, Secretary, and EQ Presidency fields are boolean value (true|false) flags.
- If a member of the presidency is not a District Leader, make sure to set their "District=0".
- If a district leader is not a member of the presidency, add them without setting any other flags except the district.
- You can only add 1 new presidency member at a time (1 per each update request to the table). -
- Make sure you have at least 1 EQ Presidency member that is marked as EQ Presidency=1 with no Elder selected. +
- Make sure you have 1 EQ Presidency member that is marked as EQ Presidency=1 with no Elder selected.
This entry is used to email the entire presidency, and its email address should cause that to happen.

-- 2.34.1