Started adding data conversion from Connections to GLM Member Database
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 5 May 2015 22:22:28 +0000 (18:22 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 5 May 2015 22:22:28 +0000 (18:22 -0400)
classes/data/dataCities.php
classes/glmMemberImportFromConnections.php [new file with mode: 0644]
classes/glmMemberInfoClone.php
defines.php
lib/GlmDataAbstract/.~lock.documentation.odt# [deleted file]
lib/GlmDataAbstract/documentation.txt [deleted file]
misc/databaseScripts/create_database_V0.1.sql
misc/databaseScripts/drop_database_V0.1.sql
models/admin/configure/development.php
views/admin/configure/development.html
views/admin/members/list.html

index 1c9381c..8ff0651 100644 (file)
@@ -147,8 +147,6 @@ class GlmDataCities extends GlmDataAbstract
 
     public function addCity($cityName) {
 
-echo "addCity()<br>";
-
         // Check that we have a good name
         $cName = trim($cityName);
         if ($cName == '') {
diff --git a/classes/glmMemberImportFromConnections.php b/classes/glmMemberImportFromConnections.php
new file mode 100644 (file)
index 0000000..0fa9d87
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Import from Connections Business Directory Plugin
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  glmMemberImportFromConnections.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+/*
+ * This class imports all data from the Connection Business Directory Plugin.
+ *
+ */
+class GlmMemberImportFromConnections
+{
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+
+    /**
+     * Constructor
+     *
+     * @param object $wpdb Word Press database object
+     * @param array $config Configuration data
+     *
+     * @return integer ID of the new cloned member information record
+     * @access public
+     **/
+    function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    /*
+     * Check if Connections plugin is installed and active
+     *
+     * @return boolean
+     * @access public
+     */
+    public function checkConnections()
+    {
+        // Check if Connections plugin is installed
+        if (!is_plugin_active('connections/connections.php')) {
+            return false;
+        }
+
+        // Check if there's any data
+        $sql = "
+            SELECT count(id) AS count
+              FROM ".$this->wpdb->prefix."connections
+                      ;";
+        $c = $this->wpdb->get_row($sql, ARRAY_A);
+        $queryError = $this->wpdb->last_error;
+        if ($queryError) {
+            return false;
+        }
+
+        return $c['count'];
+
+
+    }
+
+    /*
+     * Get list of base entries
+     *
+     * @return array
+     * @access public
+     */
+    public function getList()
+    {
+
+
+        // Get6 List
+        $sql = "
+            SELECT *
+              FROM ".$this->wpdb->prefix."connections
+                      ;";
+        $list = $this->wpdb->get_results($sql, ARRAY_A);
+
+        $queryError = $this->wpdb->last_error;
+        if ($queryError) {
+            return false;
+        }
+
+        // Post process list adata
+        while (list($k, $v) = each($list)) {
+
+            // Addresses
+            $addrArray = unserialize($v['addresses']);
+            $list[$k]['addresses'] = $addrArray;
+
+        }
+        return $list;
+
+
+    }
+
+}
+
+?>
\ No newline at end of file
index e7223ca..5531ba0 100644 (file)
@@ -63,14 +63,9 @@ class GlmMemberInfoClone
     }
 
     /*
-     * Check if this is a second call to the activation hook by WordPress to activate this plugin.
+     * Clone Member Info
      *
-     * (Yea, I know that's stupid behavior, but there's nothing I can do about it.)
-     * It tells us this is happening by setting the 'action' GET parameter to 'error_scrape',
-     * which is also stupid.
-     *
-     * In this case, we don't want to try again, so output any saved notices from the first pass
-     * and then exit to tell WordPress the plugin didn't install.
+     * @param integer $id ID of member to clone
      *
      * @return void
      * @access public
@@ -107,7 +102,7 @@ class GlmMemberInfoClone
                   FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info
                  WHERE member_info = $id
             ;";
-echo $sql;
+
             $this->wpdb->query($sql);
 
         }
index f89b042..63dbfcc 100644 (file)
@@ -35,7 +35,6 @@ define('GLM_MEMBERS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_PLUGIN_DIR);
 define('GLM_MEMBERS_PLUGIN_CURRENT_URL', $pageProtocol.'://'.$_SERVER['SERVER_NAME'].$pageUri[0]);
 define('GLM_MEMBERS_PLUGIN_MEDIA_URL', WP_CONTENT_URL.'/plugins/'.GLM_MEMBERS_PLUGIN_DIR.'/media');
 
-
 // Directories
 define('GLM_MEMBERS_PLUGIN_PATH', dirname(__FILE__));
 define('GLM_MEMBERS_PLUGIN_DB_SCRIPTS', dirname(__FILE__).'/misc/databaseScripts');
@@ -44,7 +43,6 @@ define('GLM_MEMBERS_PLUGIN_LIB_PATH', GLM_MEMBERS_PLUGIN_PATH.'/lib');
 define('GLM_MEMBERS_PLUGIN_IMAGES_PATH', GLM_MEMBERS_PLUGIN_PATH.'/media/images');
 define('GLM_MEMBERS_PLUGIN_CONFIG_PATH', GLM_MEMBERS_PLUGIN_PATH.'/config');
 
-
 // Database table prefixes
 global $wpdb;
 define('GLM_MEMBERS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_');
diff --git a/lib/GlmDataAbstract/.~lock.documentation.odt# b/lib/GlmDataAbstract/.~lock.documentation.odt#
deleted file mode 100644 (file)
index 49fed26..0000000
+++ /dev/null
@@ -1 +0,0 @@
-,cscott,Ubuntu-1404,23.03.2015 14:45,file:///home/cscott/.config/libreoffice/4;
\ No newline at end of file
diff --git a/lib/GlmDataAbstract/documentation.txt b/lib/GlmDataAbstract/documentation.txt
deleted file mode 100644 (file)
index ae0828d..0000000
+++ /dev/null
@@ -1,467 +0,0 @@
-GlmDataAbstract.php Documentation
--------------------------------------------
-
-
-**** Need to add 'PreDelete" and "PostDelete" capability for things like images and other related stuff ****
-
-
-
-This file is an abstract layer for all standard database operations. It 
-provides the following.
-
-* Standardized method for database use definition
-* Standardized methods for database access
-* Standardized data input and output processing
-* Standardized response data structure for use with applications or directly with templates 
-
-This abstraction layer is primarily driven by a dabase field definitions 
-array. The array defines both real and virtual database fields, the type
-of those fields, how input to those fields is filtered and validated, 
-whether the fields are required, if those fields must be unique, and 
-for which database access methods the fields should be used. A specification
-of that array is defined below under "Field Definitions Array Specification".
-
-Virtual fields are either modified copies of a real database field using
-an alternative name and alternative parameters, or are the result of more
-complex operations related to a single or multiple specific real database 
-fields (such as pointer field options, possibly with selection criteria).
-
-
-Summary of Standard Database Access Methods
--------------------------------------------
-
-getStats()      Collects and returns statistics from the database according 
-                to the field definitions array.
-
-getList()       Builds and returns a list of database entries according to 
-                the field definitions array.
-                
-                Parameters:
-                    $where          Optional SQL "WHERE" clause
-                    $order          Optional SQL "ORDER BY" clause
-                
-getEntry()      Builds and returns a single simple database table entry or 
-                optionally a single instance of a composite of multiple
-                related table entries.  
-                
-newEntry()      Prepairs for the creation of a new simple or composite database
-                entry and returns information sufficient to create the 
-                necessary user input requests through a template.
-                
-insertEntry()   Checks for and compiles input data from the $_REQUEST array,
-                tests for all requirements to be met, and if possible inserts
-                the data into a single database table or if a composite into
-                multiple related tables. 
-                
-cloneEntry()    Makes a copy of the entry with the specified ID and if
-                successful returns the ID of the cloned copy. Also makes
-                duplicates of any images and updates the image names.                
-                
-editEntry()     Builds and returns a single simple database table entry or 
-                optionally a single instance of a composite of multiple
-                related table entries and includes the information necessary
-                to build a user input request through a template.
-                
-updateEntry()   Checks for and compiles input data from the $_REQUEST array,
-                tests for all requirements to be met, if possible updates
-                the specified database table entry/entries, and returns the
-                stored data for display back to the user (similar to the 
-                getEntry method). If the update fails, it returns the data
-                submitted and flags/information indicating the field(s)
-                and nature of the failure so that the user input form can
-                be redisplayed with such notices. 
-                
-deleteEntry()   Checks for the deletion of a simple or composite database 
-                entry, deletes that entry if possible, and returns information
-                on the success or failure of that operation.                
-                
-checkOther()    Permits other checks before submission of data with insert
-                and update. This is a hook back into DataAbstract.php that
-                can be used to intercept the insert and update process, run
-                checks on data that was submitted, alter data, add fieldFail 
-                data, and chage the result status. The function is passed the
-                entire result array ($r) and the action character ($a)
-                and should return the same when done
-                performing checks and updates. This is not required when calling
-                DataAbstract since there is a stub checkOther() method there.  
-                
-                An example follows showing how to hook into checkOther() in 
-                DataAbstract and make additional checks ...
-                
-                    function checkOther($r, $a)
-                    {
-                        // Required
-                        parent::checkOther($r, $a);
-                
-                        // ---- Perform test and changes ----
-                
-                        // Sample field checks and status updates
-                        if ($r['fieldData']['date_specific']['value'] && $r['fieldData']['cart_sticky']['value']) {
-                            $r['status'] = false;
-                            $r['fieldFail']['cart_sticky'] = 'Sticky may not be used when "Specified Dates" is checked.';
-                            $r['fieldFail']['date_specific'] = 'Specified dates may not be used when "Sticky" is checked.';
-                        }
-                
-                        // ---- End tests and changes ----
-                        
-                        // Required
-                        return $r;
-                    }
-
-
-Summary of Additional Methods Supporing the Methods Above
----------------------------------------------------------
-
-{fieldtype}Field()      Returns a field name as needed for use in an SQL query
-                        for an individual field.
-
-{fieldtype}Options()    Returns an SQL query segment needed to implement specific
-                        field options for an individual field.
-                        
-{fieldtype}Output()     Returns data for an individual real or virtual field.                       
-                
-{fieldtype}Input()      Processes input for an individual real or composite field
-                        and returns a copy of the field information.
-
-{fieldtype}Store()      Returns and SQL query segment representing the "VALUE" 
-                        parameter for an individual field.
-
-buildFieldsList()       Parses the definitions array and builds a list of fields
-                        and fields parameters that need to be processed for the
-                        current operation.
-                        
-processOutputData()     Processes a fields list and returns a set of output data
-                        for all fields used for the current operation.  
-                        
-processInputData()      Processes a fields list and collects input data
-                        for all fields used for the current operation.  
-                        
-f2LatLon()              Performs various types of Latitude/Longitude conversions.                               
-                        
-
-Summary of Available Field Types
---------------------------------
-
-integer             Standard integer value.
-
-Float               Standard float value.
-
-money               A float value processed for monitary input or display stripping
-                    any supplied "$" or "," characters and properly formatting for output.
-
-percent             A float value processed for percentile input and display stripping
-                    any supplied "%" characters and properly formatting for output.
-
-pointer             An integer field being used as a pointer to other table entries.
-                    NOTE: Pointer processing is performed after the table data is 
-                    queried. Because of this, it's not possible to use a 'where' option
-                    to select those results. The 'where' option would only operate
-                    on the value of the pointer, not what it's pointing to.
-                    
-list                An integer field being used as a pointer to a list of possible
-                    values useable for radio buttons and picklists. 
-                    
-text                A standard text field.
-
-checkbox            A boolean field represented in any standard boolean form (i.e.
-                    Yes/No, 0/1, true/false).
-
-email               A text field expecting and returning text formatted as an E-Mail 
-                    address.
-
-date                A timestamp field represented as a date, timestamp, or date list.
-
-time                A timestamp field represented as a time value.
-
-datetime            A timestamp filed represented as a date AND time value.
-
-phone               A text field expecting and returning text formatted as a Phone
-                    number.
-
-image               A field expecting and returning an image file to be stored and
-                    retrieved from the Image Server and represented in a text field
-                    as the Image Server file name.
-                    
-latitude            A float field expecting and returning text formatted as a 
-                    latitude.
-
-longitude           A float field expecting and returning text formatted as a 
-                    longitude.
-
-password            A string field that uses crypt() to generate the stored value.
-                    Consider using the 'no_update_when_blank' option with this type of field.
-                
-
-Field Definitions Array Specification
--------------------------------------
-
-Fields are specified using an array of field specification arrays.
-
-Sample:
-
-        $this->fields = array(
-
-            // Record ID
-            'id' => array(
-                'field'    => 'id',
-                'as'       => false,
-                'type'     => 'integer',
-                'filter'   => 'int',
-                'required' => true,
-                'unique'   => true,
-                'default'  => false,
-                'use'      => 'a'
-            ),
-
-             // Name of event
-            'name' => array(
-                'field'    => 'name',
-                'as'       => false,
-                'type'     => 'text',
-                'filter'   => 'string',
-                'required' => true,
-                'unique'   => true,
-                'default'  => false,
-                'use'      => 'a'
-            )
-
-        );
-
-
-The index for fields must be unique, but three may be multiple entries for a
-single field ('field') in the database table.
-
-
-Field Specifications:
-
-(array index)           The array index is only used to permit multiple entries for the
-                        same database field. This permits including the field several
-                        times so it can be processed differently based on the operation
-                        being performed or can be displayed multiple time but each in a
-                        different way.
-
-'field'                 Name of field in database table
-
-'as'                    Name to use for this field for all operations other than for talking
-                        with the database. Doing this keeps any possible multiple instances
-                        of use of a single database field separate. (see array index above)
-
-                        If this is not specified, then the actual database field name is
-                        used for these purposes.
-
-
-'type'                  Type of field - Possible field types are...
-
-                            'integer',
-                            'float',
-                            'money',
-                            'percent',
-                            'pointer',
-                            'list',
-                            'text',
-                            'password',
-                            'checkbox',
-                            'email',
-                            'date',
-                            'time',
-                            'phone',
-                            'image',
-                            'latitude',        Data is an array of (dir,deg,min,sec);
-                            'longitude'            "            "            "
-                                               "dir" is - for West and South
-
-'filter'                Optional filter - See PHP filter_input() "filter" parameter.
-                            Currently only for type "text"
-                            FILTER_SANITIZE_FULL_SPECIAL_CHARS does not seem to be defined at this time.
-                            FILTER_SANITIZE_MAGIC_QUOTES seems to be good for permitting HTML
-
-'filter_options'        Optional filter options -  See PHP filter_input() "options" parameter.
-                            Currently only for type "text".
-
-'required'              If set and true, field data must be supplied
-
-'unique'                If set and true, must be a unique value
-
-'default'               If set and true use this value as the default for input fields.
-                            Dates/times are expected to be timestamps
-                            There is no default image capability
-
-'use'                   Character(s) that indicate which operations to use this field with.
-
-                            l = Listing records
-                            g = Get - Displaying a record
-                            n = Setup input for a new record
-                            i = Insert new record
-                            e = Edit an existing record
-                            u = Update an edited record
-                            d = Ask for verification of deletion of a record
-                            c = Confirm delete and delete record.
-                            a = All above operations
-
-'minValue'              Minimum acceptable value (numeric)
-                            Dates are specified as timestamp
-
-'maxValue'              Maximum acceptable value (numeric)
-                            Dates are specified as timestamp
-                        
-'minLength'             Minimum length for an input field                        
-'maxLength'             Maximum length for an input field
-
-'force_list'            Always provide the picklist tables (p_static overrides)
-
-'p_table'               Table to get related data from for pointer types
-
-'p_field'               Field to get related data from for pointer types
-
-'p_id'                  name of ID field in related data table
-
-'p_where'               Additional WHERE clause for getting possible values from related table.
-                            "T." refers to the primary table
-
-'p_from'                Additional FROM tables for getting possible values from related table.
-                            See example in dataMembers.php
-
-'p_blank'               If set or true provide a "blank" option for pointer input
-
-'p_blank_text'          If set, use this as the text for the 'p_blank' option
-
-'p_sort'                Optional ORDER BY sort clause (i.e. "name, age DESC") - May not be functional yet.
-
-'p_orderby'             Optional "ORDER BY" clause for results from table pointed to by pointer
-
-'p_autoadd'             Option to permit the addition of a new entry using a text input field
-
-'p_sum'                 If true causes a numeric sum of all returned values from the target table/column
-
-'p_static'              A static pointer that does not do a lookup for a list of values, only a single value reference
-
-'output_type'           Optional type to use for output. Useful with pointers.
-
-'latlon_type'           Optional specification for lat/lon output (DMS, DM, or D)
-
-'view_only'             View only field, do not check for input or store, only provide data from record.
-
-'list'                  Required with field type 'list' - includes simple array where...
-                            array key is value for option
-                            array value is name for option
-                        
-'l_blank]               Provide a blank entry for type 'list'.                        
-
-'list_keytype'          Type of key field (default is 'text')
-                            'text'        A Text key - expects a text field in the database
-                            'int'        An Integer key - expects a numeric field in the database
-
-'output_format'         Optional output format specification as would be used in printf()
-                        Use only the actual format and not the type identifier (i.e. "02.2" rather than "%f02.2")
-
-'no_stripslashes'       Don't strip slashes when recalling this field from the database.
-
-'quicktip'              Text description of this field and its use.
-
-'no_update_when_blank'  Do not store a new value if the submitted data is blank
-                        Used particularly for password fields where you only want them updated when the user puts something in 
-
-'pw_type'               Type of password to require for password fields. (default is normal, 'strong' is for strong passwords with a mix of character types)
-
-'i_prefix'              Optional string prefix to be attached to the beginning of a stored image. May be used to categorize images
-                        or associate an image with a particular entity. Note that no delimiter is added, so if you want want (i.e. '_'), you need to include that.
-
-Data specification for various types
-------------------------------------
-
-Type 'list'
-
-    Return data
-
-        array(
-            'list' => array(
-                    array('name' => {name}, 'value' => {value}, 'default' => {true if default or selected},
-                    ....
-                ),
-            'value' => {value of selected option},
-            'name' => {name of selected option}
-        )
-
-Type 'date'
-
-    Input data fields
-
-        When using single input text field, input field is name of field
-
-        When using separate M, D, Y picklist or input fields
-
-            '{field}_month'
-            '{field}_day'
-            '{field}_year'
-
-    Return data
-
-        array(
-            'date' => {text date},
-            'timestamp' => {timestamp},
-            'date_list' => array(
-                'month' => {picklist array},
-                'day'   => {picklist array},
-                'year'  => {picklist array}
-            ),
-        )
-
-Type 'time'
-
-    Input data fields
-
-        When using single input text field, input field is name of field
-
-        When using separate H, M picklist or input fields
-
-            '{field}_hour'
-            '{field}_min'
-            '{field}_ampm'
-
-
-    Return data
-
-        array(
-            'time' => {text time},
-            'time_list' => array(
-                'hour' => {picklist array},
-                'min'   => {picklist array},
-                'ampm'   => {picklist array}
-            ),
-        )
-
-
-Types 'lat' & 'lon'
-
-    Return data
-
-        array(
-            'dir' => {direction: -1 = S or W, +1 = N or E},
-            'dir_list' => array(
-                        array('name' => 'N', 'value' => 1, 'default' => {true if default or selected}),
-                        array('name' => 'S', 'value' => -1, 'default' => {true if default or selected})
-                    ),
-            'deg' => {degrees},
-            'min' => {minutes},
-            'sec' => {seconds}
-        )
-
-
-Type 'image'
-
-    Input fields
-
-        '{field}_delete'        Name of checkbox field to delete image
-        '{field}_new'            Name of file input field to save new image
-
-
-Type 'picklist'
-
-    Parameters for {picklist array}
-
-        'name'            Name to use for this option
-        'value'            Value to return when this option is selected
-        'default'        True if this option is currently selected
-
-
-
index b54b8b7..cef9e18 100644 (file)
@@ -120,7 +120,7 @@ CREATE TABLE {prefix}category_member_info (
   category INT NULL,
   member_info INT NULL,
   PRIMARY KEY (id),
-  CONSTRAINT categories_fk_1
+  CONSTRAINT {prefix}categories_fk_1
     FOREIGN KEY (category)
     REFERENCES {prefix}categories (id)
     ON DELETE CASCADE,
index 518b3c4..45cbfe3 100644 (file)
@@ -2,6 +2,7 @@
 -- File Created: 12/09/14 15:27:15
 -- Database Version: 0.1 
 -- Database Deletion Script
+-- Note: Tables with DELETE CASCADE must appear before referenced table
 
 DROP TABLE
     {prefix}accommodation_types,
@@ -10,8 +11,8 @@ DROP TABLE
     {prefix}activties,
     {prefix}amenities,
     {prefix}amenity_ref,
-    {prefix}categories,
     {prefix}category_member_info,
+    {prefix}categories,
     {prefix}cities,
     {prefix}contacts,
     {prefix}facilities,
index 9f9b242..a338fa7 100644 (file)
@@ -98,6 +98,13 @@ class GlmMembersAdmin_configure_development
         settype($dbVersion, 'string');
 
         $resultMessage = '';
+        $importData = array(
+            'success' => false,
+            'haveNotices' => false,
+            'notices' => array(),
+            'haveMembers' => false,
+            'members' => false
+        );
 
         // Load database activation class to get access to database version information
         require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php');
@@ -110,6 +117,37 @@ class GlmMembersAdmin_configure_development
 
         switch($option) {
 
+            case 'import_connections':
+
+                // Load Member Info Data Class and get info data for later use
+                require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/glmMemberImportFromConnections.php');
+                $Connections = new GlmMemberImportFromConnections($this->wpdb, $this->config);
+
+                // Check if Connections is not installed or not active. If active, gets count of entries.
+                $c = $Connections->checkConnections();
+                if ($c === false) {
+                    $importaData['notices'][] = 'Connections Business Directory plugin is not installed or not active!<br>'.print_r($c,1);
+                    break;
+                }
+                $importData['numbEntries'] = $c;
+                $importData['notices'][] = 'Connections Business Directory plugin is active.<br>Number of businesses listed: '.$c.'<br>';
+
+                // Get the basic business data for review.
+                $importData['members'] = $Connections->getList();
+                if ($importData['members'] === false) {
+                    $importaData['notices'][] = 'No businesses were retieved.';
+                    break;
+                }
+
+                $importData['haveMembers'] = true;
+
+                if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+                    glmMembersAdmin::addNotice($importData['members'], 'DataBlock', 'Base Members Data');
+                }
+
+
+                break;
+
             case 'drop':
             case 'reset':
 
@@ -120,9 +158,22 @@ class GlmMembersAdmin_configure_development
                 // Replace {prefix} with table name prefix
                 $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
 
+                if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+                    glmMembersAdmin::addNotice('Dropping all database tables', 'Process');
+                    glmMembersAdmin::addNotice($sql, 'DataBlock', 'Drop Tables SQL');
+                }
+
                 // Removing the tables using the script
                 $this->wpdb->query($sql);
 
+                // If there's been an error, display in debug Alert
+                $queryError = $this->wpdb->last_error;
+                if ($queryError) {
+                    if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+                        glmMembersAdmin::addNotice('<b>Error when deleting database:</b><br>'.$queryError, 'Alert');
+                    }
+                }
+
                 $resultMessage .= 'Database deleted<br>';
 
                 if ($option != 'reset') {
@@ -142,12 +193,24 @@ class GlmMembersAdmin_configure_development
                 $queries = preg_split('/^----$/m', $sql);
 
                 // Try executing all queries to build database
+                $qForDebug = '';
                 do {
                     $q = current($queries);
                     $this->wpdb->query($q);
                     $queryError = $this->wpdb->last_error;
+
+                    if ($queryError) {
+                        glmMembersAdmin::addNotice('<b>Error when creating database:</b> <br>'.$queryError, 'Alert');
+                    }
+                    $qForDebug .= $queryError.$q;
+
                 } while ($queryError == '' && next($queries));
 
+                if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+                    glmMembersAdmin::addNotice('Creating database tables', 'Process');
+                    glmMembersAdmin::addNotice($qForDebug, 'DataBlock', 'Create Tables SQL');
+                }
+
                 // If there were no errors
                 if (trim($queryError) == '') {
 
@@ -160,7 +223,7 @@ class GlmMembersAdmin_configure_development
 
                 } else {
                     $resultMessage .= 'Failure installing database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.<br>';
-                    $resultMessage .= '<b>Database Installation Error:</b> <br>';
+                    $resultMessage .= '<b>Database Installation Error:</b> '.$queryError.'<br>';
                 }
 
                 break;
@@ -202,8 +265,13 @@ class GlmMembersAdmin_configure_development
         }
 
 
+        if (count($importData['notices'] > 0)) {
+            $importData['haveNotices'] = true;
+        }
+
         $templateData = array(
-            'resultMessage' => $resultMessage
+            'resultMessage' => $resultMessage,
+            'importData' => $importData
         );
 
         // Return status, suggested view, and data to controller
index 8de2cfe..60bbcd3 100644 (file)
@@ -6,6 +6,56 @@
     
     <ul>
         <li>
+            <H3>Import</H3>
+            <ul>
+                <li>
+                    <a href="{$thisURL}?page={$thisPage}&glm_action=development&option=import_connections">Import data from "Connections" business directory</a>
+{if $importData.haveNotices} 
+    {foreach $importData.notices as $n}
+                    <p style="color: red; margin-left: 2em;">{$n}</p>
+    {/foreach}
+{/if}
+{if $importData.haveMembers}
+                    <table class="wp-list-table widefat fixed posts glm-admin-table">
+                        <thead>
+                            <tr>
+                                <th>Name</th>
+                                <th>Addr Line 1</th>
+                                <th>Addr Line 2</th>
+                                <th>Addr Line 3</th>
+                                <th>City</th>
+                                <th>State</th>
+                                <th>ZIP</th>
+                                <th>Country</th>
+                                <th>Lat/Lon</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+    {foreach $importData.members as $m}
+                            <tr class="alternate">
+                                <td>{$m.organization}</td>
+        {assign var="i" value="0"}                        
+        {foreach $m.addresses as $a}
+            {if $i++ gt 1}
+                            <tr>
+                                <td>&nbsp;</td>
+            {/if}                                
+                                <td>{$a.line_1}</td>
+                                <td>{$a.line_2}</td>
+                                <td>{$a.line_3}</td>
+                                <td>{$a.city}</td>
+                                <td>{$a.state}</td>
+                                <td>{$a.zipcode}</td>
+                                <td>{$a.country}</td>
+                                <td>{$a.latitude|number_format:3:".":","}/{$a.longitude|number_format:3:".":","}</td>
+                            </tr>
+        {/foreach}
+    {/foreach}               
+                        </tbody>         
+                    </table>
+{/if}
+                </li>
+            </ul>
             <H3>Database</H3>
             <ul>
                 <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=drop">Drop database tables</a> (WARNING: Destroys all current data)</li>
index 18b953b..7c64ec1 100644 (file)
@@ -9,7 +9,7 @@
     
     <h2>List of Members</h2>
     
-    <table class="wp-list-table widefat fixed posts glm-admin-table"">
+    <table class="wp-list-table widefat fixed posts glm-admin-table">
         <thead>
             <tr>
                 <th>ID</th>