More cleanup of member information pages.
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Mar 2015 17:56:37 +0000 (13:56 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Mar 2015 17:56:37 +0000 (13:56 -0400)
classes/data/dataMemberInfo.php
config/plugin.ini
models/admin/member/index.php
models/admin/member/memberInfo.php
views/admin/member/memberInfo.html

index 6259dc1..813ebcc 100644 (file)
@@ -225,7 +225,7 @@ class GlmDataMemberInfo extends GlmDataAbstract {
                        'lat' => array(
                                'field'    => 'lat',
                                'type'     => 'float',
-                               'default'  => 45,
+                               'default'  => $this->config['map_default_lat'],
                                'use'      => 'a'
                        ),
 
@@ -233,7 +233,7 @@ class GlmDataMemberInfo extends GlmDataAbstract {
                        'lon' => array(
                                'field'    => 'lon',
                                'type'     => 'float',
-                               'default'  => -84,
+                               'default'  => $this->config['map_default_lon'],
                                'use'      => 'a'
                        ),
 
index 7d7e7e8..67480c5 100644 (file)
@@ -47,11 +47,13 @@ front_debug_verbose = false
 ; for the project should be the customer's Web site.
 ; https://accounts.google.com/ServiceLogin
 ;
-;googleMapsApiKey = 'AIzaSyDWgyf8MeYdxZRHaN73O37vFbkhvPjjNhU'
-googleMapsApiKey = ''
+googleMapsApiKey = 'AIzaSyDWgyf8MeYdxZRHaN73O37vFbkhvPjjNhU'
 
 ; General Settings
 timezone = America/Detroit
+; Default map location is Gaslight Media office
+map_default_lat = 45.3749
+map_default_lon = -84.9592
 
 ;
 ; Entry Status Types
@@ -242,6 +244,7 @@ phrase['phrase_test'] = 'test'
 
 
 [chuck:common]
-;admin_debug = true
+admin_debug = true
+googleMapsApiKey = ''
 
 
index 9218d4f..2179547 100644 (file)
@@ -120,13 +120,22 @@ class GlmMembersAdmin_member_index extends GlmDataMembers
 
         // Otherwise check if one was supplied by the user or passed from somewhere else
         } elseif (isset($_REQUEST['id'])) {
+
             // Make sure it's a number
             $memberID = $_REQUEST['id']-0;
+
+        // Not sure why I have this. Need to look for it.
         } elseif (isset($_REQUEST['member'])) {
+
             $memberID = $_REQUEST['member']-0;
+
         }
 
-        // If we don't have a member ID, setup to add a new member
+        /*
+         *
+         * Setup to add a new member
+         *
+         */
         if ($memberID <= 0) {
 
             // If this is a new member submission
@@ -137,6 +146,18 @@ class GlmMembersAdmin_member_index extends GlmDataMembers
                 if($memberData['status']) {
                     $memberID = $memberData['fieldData']['id'];
                     $haveMember = true;
+
+                    // Go directly to the member information entry page
+                    return array(
+                        'status' => true,
+                        'menuItemRedirect' => 'member',
+                        'modelRedirect' => 'memberInfo',
+                        'view' => 'admin/member/memberInfo.html',
+                        'data' => array(
+                            'member' => $memberID
+                        )
+                    );
+
                 }
 
                 if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
@@ -154,9 +175,14 @@ class GlmMembersAdmin_member_index extends GlmDataMembers
 
                 // Setup to add a new member
                 $memberData = $this->newEntry();
+
             }
 
-        // Otherwise if this is a member update
+        /*
+         *
+         * Member update
+         *
+         */
         } elseif (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') {
 
             $memberData = $this->updateEntry($memberID);
@@ -173,7 +199,11 @@ class GlmMembersAdmin_member_index extends GlmDataMembers
 
             $haveMember = true;
 
-        // Otherwise, have a member, get the base member data
+        /*
+         *
+         *  Get existing base member data
+         *
+         */
         } else {
 
             if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
@@ -190,6 +220,12 @@ class GlmMembersAdmin_member_index extends GlmDataMembers
             glmMembersAdmin::addNotice($memberData, 'DataBlock', 'Member Data');
         }
 
+        /*
+         *
+         * Other actions that may be required
+         *
+         */
+
         // Check if there's a request to delete a specific member information record
         if (isset($_REQUEST['deleteID']) && $_REQUEST['deleteID'] != '') {
 
@@ -249,7 +285,6 @@ class GlmMembersAdmin_member_index extends GlmDataMembers
             }
         }
 
-
         // If we have a member then also get a list of member info records
         $haveInfoRecords = false;
         $memberInfoRecords = false;
index 3fb971d..2876eb9 100644 (file)
@@ -151,9 +151,40 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
             $option = $_REQUEST['option'];
         }
 
-        // If a member ID is supplied, get that and make sure it's a valid integer
-        if (isset($_REQUEST['member'])) {
+        // Check for redirection - Should be from creating a new member
+        if ($redirectData) {
+
+            if (!isset($redirectData['member'])) {
+                $memberID = $redirectData['member']-0;
+            }
+
+            $memberID = $redirectData['member']-0;
+            $option = 'create';
+
+        // Otherwise it should be a user submission
+        } elseif (isset($_REQUEST['member'])) {
             $memberID = $_REQUEST['member']-0;
+
+            // If a member info record ID is supplied, get that and make sure it's an integer
+            if (isset($_REQUEST['id'])) {
+                $memberInfoID = $_REQUEST['id']-0;
+                $haveMemberInfo = true;
+
+                // Determine if this is the active record
+                $sql = "
+                SELECT status
+                  FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info
+                              WHERE id = $memberInfoID
+                              ;";
+                $activeTest = $this->wpdb->get_row($sql, ARRAY_A);
+
+                // If it is, then save that
+                if ($activeTest['status'] == $this->config['status_numb']['Active']) {
+                    $isActive = true;
+                }
+
+            }
+
         }
 
         // If member ID not supplied - we shouldn't be here, so redirect to an error page
@@ -171,34 +202,14 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
                     'data' => false
             );
 
-        // Otherwise get member base data
-        } else {
-            require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php');
-            $Members = new GlmDataMembers($this->wpdb, $this->config);
-            $memberData = $Members->getEntry($memberID);
-            $this->fields['logo']['i_prefix'] = 'memb_'.$memberID.'_';
-            $haveMember = true;
         }
 
-        // If a member info record ID is supplied, get that and make sure it's an integer
-        if (isset($_REQUEST['id'])) {
-            $memberInfoID = $_REQUEST['id']-0;
-            $haveMemberInfo = true;
-
-            // Determine if this is the active record
-            $sql = "
-                SELECT status
-                  FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info
-                 WHERE id = $memberInfoID
-            ;";
-            $activeTest = $this->wpdb->get_row($sql, ARRAY_A);
-
-            // If it is, then save that
-            if ($activeTest['status'] == $this->config['status_numb']['Active']) {
-                $isActive = true;
-            }
-
-        }
+        // Get member base data
+        require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php');
+        $Members = new GlmDataMembers($this->wpdb, $this->config);
+        $memberData = $Members->getEntry($memberID);
+        $this->fields['logo']['i_prefix'] = 'memb_'.$memberID.'_';
+        $haveMember = true;
 
         // If no member info record, assume that we need to create a new one
         if ($memberInfoID <= 0 && $option != 'addNew') {
@@ -214,7 +225,7 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
          */
         switch ($option) {
 
-            // Setup to input a nnew member information record
+            // Setup to input a new member information record
             case 'create':
 
                 $MemberInfo = $this->newEntry();
index 7d97fcb..3567d72 100644 (file)
                 <td>
                     <input id="glmLat" name="lat" type="hidden" value="{$memberInfo.fieldData.lat}">
                     <input id="glmLng" name="lon" type="hidden" value="{$memberInfo.fieldData.lon}">
-                    <div>
-                        <input type="hidden" name="lat" id="lat" value="{$memberInfo.fieldData.lat}" class="emTextInputShort">
-                        <input type="hidden" name="lon" id="lon" value="{$memberInfo.fieldData.lon}" class="emTextInputShort">
-                    </div>
                     <p>
                         MAP USE: Drag the pointer to the desired location for this member.
                         Use + and - buttons or the mouse wheel to zoom in or out.
              */
             
             // Set default - Need to make this configurable
-            var location = new google.maps.LatLng(45, -85)
+            var startLat = $('#glmLat').val();
+            var startLon = $('#glmLng').val();
+            var location = new google.maps.LatLng(startLat, startLon);
                var map = new google.maps.Map(document.getElementById('locationMap'), {  
-                zoom: 14,  
+                zoom: 15,  
                 disableDefaultUI: false,   
                 mapTypeId: google.maps.MapTypeId.MAP,  
             });  
                 
                // Send to Google Geocoder
                geocoder.geocode( { 'address': geoAddress }, function(results, status) {
-                       
+
                        // If we have a geocode solution
                        if (status == google.maps.GeocoderStatus.OK) {
-                           map.setCenter(results[0].geometry.location);
+
+                               // Center the map and locate the marger to the new location
+                               map.setCenter(results[0].geometry.location);
                            marker.setPosition( results[0].geometry.location );
+                           
+                           // Assign the new position to the hidden fields for submission
+                        $('#glmLat').val(results[0].geometry.location.lat());
+                        $('#glmLng').val(results[0].geometry.location.lng());
 
                        // Otherwise tell the user. 
                    } else {