From: Chuck Scott Date: Fri, 19 Feb 2016 19:52:21 +0000 (-0500) Subject: Reorganized again X-Git-Tag: v2.0.0^2~76 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=3912768278c3f4a0889b44440de7fa37ca78567f;p=WP-Plugins%2Fglm-member-db.git Reorganized again --- diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index c04b98d3..cd290c4c 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -178,6 +178,127 @@ class GlmDataMemberInfo extends GlmDataAbstract 'use' => 'a' ), + // Address Line 1 + 'addr1' => array ( + 'field' => 'addr1', + 'type' => 'text', + 'use' => 'a' + ), + + // Address Line 2 + 'addr2' => array ( + 'field' => 'addr2', + 'type' => 'text', + 'use' => 'a' + ), + + // City + 'city' => array ( + 'field' => 'city', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'use' => 'a' + ), + + // State + 'state' => array ( + 'field' => 'state', + 'type' => 'list', + 'list' => $this->config['states'], + 'default' => 'MI', + 'use' => 'a' + ), + + // ZIP / Postal Code + 'zip' => array ( + 'field' => 'zip', + 'type' => 'text', + 'use' => 'a' + ), + + // Country + 'country' => array ( + 'field' => 'country', + 'type' => 'list', + 'list' => $this->config['countries'], + 'default' => 'US', + 'use' => 'a' + ), + + // Latitude + 'lat' => array( + 'field' => 'lat', + 'type' => 'float', + 'default' => $this->config['settings']['maps_default_lat'], + 'use' => 'a' + ), + + // Longitude + 'lon' => array( + 'field' => 'lon', + 'type' => 'float', + 'default' => $this->config['settings']['maps_default_lon'], + 'use' => 'a' + ), + + // Region + 'region' => array ( + 'field' => 'region', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'regions', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + // 'force_list' => true, + 'use' => 'a' + ), + + // Phone + 'phone' => array( + 'field' => 'phone', + 'type' => 'phone', + 'use' => 'a' + ), + + // Toll Free + 'toll_free' => array( + 'field' => 'toll_free', + 'type' => 'phone', + 'use' => 'a' + ), + + // E-Mail Address + 'email' => array( + 'field' => 'email', + 'type' => 'email', + 'use' => 'a' + ), + + // URL + 'url' => array( + 'field' => 'url', + 'type' => 'text', + 'use' => 'a' + ), + + // Logo + 'logo' => array( + 'field' => 'logo', + 'type' => 'image', + 'use' => 'a' + ), + + // Credit Cards Accepted - multi-pick + 'cc_type' => array( + 'field' => 'cc_type', + 'type' => 'bitmap', + 'bitmap' => $this->config['credit_card'], + 'default' => 0, // no cards selected + 'use' => 'a' + ), + // Description 'descr' => array( 'field' => 'descr', @@ -238,6 +359,12 @@ class GlmDataMemberInfo extends GlmDataAbstract public function entryPostProcessing($r, $a) { + // Set flag if Lat or Lon are 0 + $r['bad_lat_lon'] = false; + if ($r['lat'] == 0 || $r['lon'] == 0) { + $r['bad_lat_lon'] = true; + } + // Only run these tests for 'l' (getList), 'g' (getEntry), 'e' (editEntry) if (!$this->doPostProcessing || ($a != 'l' && $a != 'g' && $a != 'e')) { return $r; @@ -255,18 +382,35 @@ class GlmDataMemberInfo extends GlmDataAbstract $r['amenities'] = $this->wpdb->get_results($sql, ARRAY_A); + // Get Member Category data for this entry + $sql = " + SELECT CMI.member_info AS member_info_id, C.id, C.name, C.descr, C.short_descr, + COALESCE ( + ( + SELECT name + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories + WHERE id = C.parent + ), '' + ) AS parent_name + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories AS C, + ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "category_member_info AS CMI + WHERE C.id = CMI.category + AND CMI.member_info = ".$r['id']." + ;"; + $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A); + return $r; } /* - * Find the active member info record for a specific member ID + * Find the active member info record ID for a specific member ID * * @param integer $member ID of the member name * @param string $where Optional WHERE clause for query * * @return integer Member info record ID or false if not found */ - public function getActiveInfoForMember($member, $where = 'true') { + public function getActiveInfoIdForMember($member, $where = 'true') { $memberID = $member - 0; @@ -276,7 +420,16 @@ class GlmDataMemberInfo extends GlmDataAbstract WHERE $where AND member = $memberID AND status = ".$this->config['status_numb']['Active']." - ;"; + AND ( + SELECT access + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members + WHERE id = T.member + ) IN ( + ".$this->config['access_numb']['NoAccess'].", + ".$this->config['access_numb']['Moderated'].", + ".$this->config['access_numb']['Full']." + ) + "; $memberInfo = $this->wpdb->get_row($sql, ARRAY_A); if ($memberInfo) { @@ -297,9 +450,8 @@ class GlmDataMemberInfo extends GlmDataAbstract */ public function getActiveInfoSimplified($member) { -echo "******************* CHECK ON THIS getActiveInfoSimplified() *******************";exit; // Get the ID for the current info record for this member - $mInfoID = $this->getActiveInfoForMember($member); + $mInfoID = $this->getActiveInfoIdForMember($member); if (!$mInfoID) { return false; } @@ -332,6 +484,7 @@ echo "******************* CHECK ON THIS getActiveInfoSimplified() ************** } + /* * Get Apha list of first characters in member name * for those members that have active info. @@ -378,6 +531,8 @@ echo "******************* CHECK ON THIS getActiveInfoSimplified() ************** public function getSimpleMemberInfoList($where = '') { + $this->doPostProcessing = false; + // Save current list of fields $f = $this->fields; @@ -391,7 +546,9 @@ echo "******************* CHECK ON THIS getActiveInfoSimplified() ************** 'reference_name' => $f['reference_name'], 'status' => $f['status'], 'create_time' => $f['create_time'], - 'modify_time' => $f['modify_time'] + 'modify_time' => $f['modify_time'], + 'lat' => $f['lat'], + 'lon' => $f['lon'] ); // Get the simplified list @@ -404,55 +561,7 @@ echo "******************* CHECK ON THIS getActiveInfoSimplified() ************** } /* - * Get Member Info List with Member Data - * - * @param string $where Where clause - * @param string $sort Sort field - * - * @return object Class object - * - */ - public function getListWithMemberData($where = '', $sort = '') - { - - // Member data - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'); - $Members = new GlmDataMembers($this->wpdb, $this->config); - - // Get list of memberInfo data - $list = $this->getList($where, $sort); - - // For each member info record bet base member data - while (list($key, $val) = each($list)) { - - $mData = $Members->getEntry($val['member_pointer']); - - $list[$key] = array_merge($val, array( - 'logo' => $mData['logo'], - 'addr1' => $mData['addr1'], - 'addr2' => $mData['addr2'], - 'city' => $mData['city'], - 'state' => $mData['state'], - 'zip' => $mData['zip'], - 'country' => $mData['country'], - 'phone' => $mData['phone'], - 'toll_free' => $mData['toll_free'], - 'region' => $mData['region'], - 'url' => $mData['url'], - 'email' => $mData['email'], - 'categories' => $mData['categories'], - 'cc_type' => $mData['cc_type'], - 'lat' => $mData['lat'], - 'lon' => $mData['lon'] - )); - - } - - return $list; - } - - /* - * Get Member Info For a Member with Member Data + * Get Member Info For a Member * * @param integer $member Member ID * @param string $where Where clause @@ -460,46 +569,21 @@ echo "******************* CHECK ON THIS getActiveInfoSimplified() ************** * @return object Class object * */ - public function getActiveInfoForMemberWithMemberData($member, $where = 'true') + public function getActiveInfoForMember($member) { - // Member data - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'); - $Members = new GlmDataMembers($this->wpdb, $this->config); - - $memberInfoID = $this->getActiveInfoForMember($member, $where); + // Get the active member info id for an active member + $memberInfoID = $this->getActiveInfoIdForMember($member); - $memberInfo = $this->getEntry($memberInfoID); - - if ($memberInfo) { - - $mData = $Members->getEntry($member); - - $memberInfo = array_merge($memberInfo, array( - 'logo' => $mData['logo'], - 'addr1' => $mData['addr1'], - 'addr2' => $mData['addr2'], - 'city' => $mData['city'], - 'state' => $mData['state'], - 'zip' => $mData['zip'], - 'country' => $mData['country'], - 'phone' => $mData['phone'], - 'toll_free' => $mData['toll_free'], - 'region' => $mData['region'], - 'url' => $mData['url'], - 'email' => $mData['email'], - 'categories' => $mData['categories'], - 'cc_type' => $mData['cc_type'], - 'lat' => $mData['lat'], - 'lon' => $mData['lon'] - )); - - } else { + // If not found then return failure + if ($memberInfoID == false) { return false; } + // Get the member info data + $memberInfo = $this->getEntry($memberInfoID); + return $memberInfo; } - } diff --git a/classes/data/dataMembers.php b/classes/data/dataMembers.php index 45757709..6a73c1d6 100644 --- a/classes/data/dataMembers.php +++ b/classes/data/dataMembers.php @@ -192,127 +192,6 @@ class GlmDataMembers extends GlmDataAbstract { 'use' => 'gle' ), - // Address Line 1 - 'addr1' => array ( - 'field' => 'addr1', - 'type' => 'text', - 'use' => 'a' - ), - - // Address Line 2 - 'addr2' => array ( - 'field' => 'addr2', - 'type' => 'text', - 'use' => 'a' - ), - - // City - 'city' => array ( - 'field' => 'city', - 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities', - 'p_field' => 'name', - 'p_orderby' => 'name', - 'use' => 'a' - ), - - // State - 'state' => array ( - 'field' => 'state', - 'type' => 'list', - 'list' => $this->config['states'], - 'default' => 'MI', - 'use' => 'a' - ), - - // ZIP / Postal Code - 'zip' => array ( - 'field' => 'zip', - 'type' => 'text', - 'use' => 'a' - ), - - // Country - 'country' => array ( - 'field' => 'country', - 'type' => 'list', - 'list' => $this->config['countries'], - 'default' => 'US', - 'use' => 'a' - ), - - // Latitude - 'lat' => array( - 'field' => 'lat', - 'type' => 'float', - 'default' => $this->config['settings']['maps_default_lat'], - 'use' => 'a' - ), - - // Longitude - 'lon' => array( - 'field' => 'lon', - 'type' => 'float', - 'default' => $this->config['settings']['maps_default_lon'], - 'use' => 'a' - ), - - // Region - 'region' => array ( - 'field' => 'region', - 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'regions', - 'p_field' => 'name', - 'p_orderby' => 'name', - 'p_blank' => true, - // 'force_list' => true, - 'use' => 'a' - ), - - // Phone - 'phone' => array( - 'field' => 'phone', - 'type' => 'phone', - 'use' => 'a' - ), - - // Toll Free - 'toll_free' => array( - 'field' => 'toll_free', - 'type' => 'phone', - 'use' => 'a' - ), - - // E-Mail Address - 'email' => array( - 'field' => 'email', - 'type' => 'email', - 'use' => 'a' - ), - - // URL - 'url' => array( - 'field' => 'url', - 'type' => 'text', - 'use' => 'a' - ), - - // Logo - 'logo' => array( - 'field' => 'logo', - 'type' => 'image', - 'use' => 'a' - ), - - // Credit Cards Accepted - multi-pick - 'cc_type' => array( - 'field' => 'cc_type', - 'type' => 'bitmap', - 'bitmap' => $this->config['credit_card'], - 'default' => 0, // no cards selected - 'use' => 'a' - ), - // Notes 'notes' => array ( 'field' => 'notes', @@ -370,9 +249,6 @@ class GlmDataMembers extends GlmDataAbstract { * * Perform post-processing for all result entries. * - * In this case we're using it to append an array of category - * data to each member result and also sort by member name. - * * @param array $r Array of field result data for a single entry * @param string $a Action being performed (l, i, g, ...) * @@ -381,29 +257,6 @@ class GlmDataMembers extends GlmDataAbstract { */ public function entryPostProcessing($r, $a) { - - // Only run these tests for 'l' (getList), 'g' (getEntry), 'e' (editEntry) - if (!$this->doPostProcessing || ($a != 'l' && $a != 'g' && $a != 'e')) { - return $r; - } - - // Get Member Category data for this entry - $sql = " - SELECT CMI.member_info AS member_info_id, C.id, C.name, C.descr, C.short_descr, - COALESCE ( - ( - SELECT name - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories - WHERE id = C.parent - ), '' - ) AS parent_name - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories AS C, - ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "category_member_info AS CMI - WHERE C.id = CMI.category - AND CMI.member_info = ".$r['id']." - ;"; - $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A); - return $r; } diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index c06d73fe..545d8f67 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -42,6 +42,8 @@ class GlmPluginSupport public static function addNotice ($message, $type = false, $title = false) { + update_option('glmMembersAdminHaveNotices', true); + switch($type) { case 'Alert'; @@ -182,6 +184,23 @@ class GlmPluginSupport $dbVersion = get_option($a['database']['dbActiveVersionOption']); +/* + // Do a sanity check on the database version + if (!preg_match('^(\d+\.)?(\d+\.)?(\*|\d+)$', $dbVersion)) { + + // If there's a current version then try to set that in the WordPress option + if (isset($a['database']['dbCurrentVersion']) && $a['database']['dbCurrentVersion'] != '') { + update_option($a['database']['dbActiveVersionOption'], $a['database']['dbCurrentVersion']); + $dbVersion = $a['database']['dbCurrentVersion']; + + // Not much we can do here.... + } else { + return false; + } + + } +*/ + // Do a quick check for there being a database version but not all the required tables for that version if ($dbVersion) { @@ -240,7 +259,7 @@ class GlmPluginSupport // Replace {prefix} with table name prefix $sql = str_replace('{prefix}', $a['database']['dbPrefix'], $sql); - // Split script into separate queries by looking for lines with only "---" + // Split script into separate queries by looking for lines with only "----" $queries = preg_split('/^----$/m', $sql); // Try executing all queries to build database @@ -379,3 +398,124 @@ class GlmPluginSupport } } + +/* + * Stand alone functions that are needed globally for these plugins/add-ons + */ + +/* + * Function to display admin notices. + * + * This function is only called using the add_action('admin_notices','...') function + * in the code below this function. + * + * @return void + * @access public + */ +function glmMembersAdminNotices($windowed = true) +{ + + $output = ''; + + // If windowed for debug, also include HTML header and stylesheet + if ($windowed) { + + $output .= ' + + + + + + +
'.date('m/d/Y G:i:s A').'
+
'.GLM_MEMBERS_PLUGIN_NAME.' - Debug Data
+ '; + + // Display alerts + $alerts = get_option('glmMembersAdminNoticeAlerts'); + if(is_array($alerts)) { + $output .= '

Alerts

'; + foreach($alerts as $a) { + $output .= $a.'
'; + } + } else { + $output .= '

Alerts

'; + } + $output .= '

'; + delete_option('glmMembersAdminNoticeAlerts'); + + // Display process messages + $process = get_option('glmMembersAdminNoticeProcess'); + $output .= '

Processing

'; + if(is_array($process)) { + foreach($process as $p) { + $output .= $p.'
'; + } + } + $output .= '

'; + delete_option('glmMembersAdminNoticeProcess'); + + // Display data blocks table of contents then the data blocks + $dataBlocks = get_option('glmMembersAdminNoticeDataBlocks'); + $output .= '

Data Blocks

    '; + $n = 0; + if (is_array($dataBlocks)) { + foreach($dataBlocks as $d) { + $output .= '
  • '.$d['title'].'
  • '; + } + } + + $output .= '

'; + if (is_array($dataBlocks)) { + reset($dataBlocks); + $n = 0; + foreach($dataBlocks as $d) { + $output .= ' +
+
[Top]
+ +
'.print_r($d['data'],1).'
+
+ '; + } + } + + echo $output.' + + + '; + + // Otherwise we're outputting data to the message block in the WordPress admin area + } else { + + // Start with div class to output in standard admin notice block + $output .= '

'; + + // Get the notice texts + $notices = get_option('glmMembersAdminNotices'); + + if (is_array($notices) && count($notices) > 0) { + + // For each notice retrieved + $br = ''; + foreach($notices as $n) { + + // Add the notice to the output + $output .= $br.$n; + $br = '
'; + } + + } + + echo $output.'

'; + + + } + + delete_option('glmMembersAdminNoticeAlerts'); + delete_option('glmMembersAdminNotices'); + delete_option('glmMembersAdminNoticeProcess'); + delete_option('glmMembersAdminNoticeDataBlocks'); + +} + diff --git a/controllers/admin.php b/controllers/admin.php index a6787652..216bcefe 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -13,12 +13,6 @@ * @link http://dev.gaslightmedia.com/ */ -// Load glmPluginSupport class -require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php'); - -// Load Smarty Template Support -require_once (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php'); - /** * Admin Controller Class * @@ -943,6 +937,15 @@ class glmMembersAdmin extends GlmPluginSupport // Generate output from model data and view $smarty->template->display($view); + // If debug is requested, create debug window + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + echo " + + "; + } + // Restore timezone that was set before our code was called date_default_timezone_set($defaultTimeZone); diff --git a/controllers/front.php b/controllers/front.php index d3367ce1..4d5f8757 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -14,12 +14,6 @@ * @link http://dev.gaslightmedia.com/ */ -// Load glmPluginSupport class -require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php'); - -// Load Smarty Template Support -require_once (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php'); - /* * This class controls which models are use for front-end functionality * of this plugin. @@ -485,6 +479,15 @@ class glmMembersFront extends GlmPluginSupport // Generate output from model data and view $out = $smarty->template->fetch($view); + // If debug is requested, create debug window + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + echo " + + "; + } + // Restore timezone that was set before our code was called date_default_timezone_set($defaultTimeZone); diff --git a/glm-member-db.php b/glm-member-db.php index 4fb66e22..3f000200 100644 --- a/glm-member-db.php +++ b/glm-member-db.php @@ -366,6 +366,12 @@ register_deactivation_hook(__FILE__, 'glmMembersPluginDeactivate'); // Load data abstract require_once(GLM_MEMBERS_PLUGIN_LIB_PATH.'/GlmDataAbstract/DataAbstract.php'); +// Load glmPluginSupport class +require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php'); + +// Load Smarty Template Support +require_once (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php'); + /* * Hook through which an add-on may supply additional logged in user information and * have that data stored in the config array. Typically it would be the @@ -413,154 +419,19 @@ if (isset($_REQUEST['glmDebugWindow']) && $_REQUEST['glmDebugWindow'] == true) { } /* - * Function to display admin notices. - * - * This function is only called using the add_action('admin_notices','...') function - * in the code below this function. - * - * @return void - * @access public + * Display any notices? */ -function glmMembersAdminNotices($windowed = true) -{ - - $output = ''; - - // If windowed for debug, also include HTML header and stylesheet - if ($windowed) { - - $output .= ' - - - - - - -
'.date('m/d/Y G:i:s A').'
-
'.GLM_MEMBERS_PLUGIN_NAME.' - Debug Data
- '; - - // Display alerts - $alerts = get_option('glmMembersAdminNoticeAlerts'); - if(is_array($alerts)) { - $output .= '

Alerts

'; - foreach($alerts as $a) { - $output .= $a.'
'; - } - } else { - $output .= '

Alerts

'; - } - $output .= '

'; - delete_option('glmMembersAdminNoticeAlerts'); - - // Display process messages - $process = get_option('glmMembersAdminNoticeProcess'); - $output .= '

Processing

'; - if(is_array($process)) { - foreach($process as $p) { - $output .= $p.'
'; - } - } - $output .= '

'; - delete_option('glmMembersAdminNoticeProcess'); - - // Display data blocks table of contents then the data blocks - $dataBlocks = get_option('glmMembersAdminNoticeDataBlocks'); - $output .= '

Data Blocks

    '; - $n = 0; - if (is_array($dataBlocks)) { - foreach($dataBlocks as $d) { - $output .= '
  • '.$d['title'].'
  • '; - } - } - - $output .= '

'; - if (is_array($dataBlocks)) { - reset($dataBlocks); - $n = 0; - foreach($dataBlocks as $d) { - $output .= ' -
-
[Top]
- -
'.print_r($d['data'],1).'
-
- '; - } - } - - echo $output.' - - - '; - - // Otherwise we're outputting data to the message block in the WordPress admin area - } else { - - // Start with div class to output in standard admin notice block - $output .= '

'; - - // Get the notice texts - $notices = get_option('glmMembersAdminNotices'); - - if (is_array($notices) && count($notices) > 0) { - - // For each notice retrieved - $br = ''; - foreach($notices as $n) { - - // Add the notice to the output - $output .= $br.$n; - $br = '
'; - } - - } - - echo $output.'

'; - - } - - delete_option('glmMembersAdminNoticeAlerts'); - delete_option('glmMembersAdminNotices'); - delete_option('glmMembersAdminNoticeProcess'); - delete_option('glmMembersAdminNoticeDataBlocks'); - -} - -/* - * Check if there's any startup notices in this file. (stuff that happens before we get all setup) - * - * If there is, have the message displayed at the top of the wp-admin content area. - */ -function glmMembersStartupNotices() { +// Display any notices that need to be displayed at the top of the admin content area +function glmMembersWordpressAdminNotices() { global $startupNotices; echo '

'.GLM_MEMBERS_PLUGIN_NAME.' Plugin Warning

'.$startupNotices.'

'; } if ($startupNotices != '') { - add_action('admin_notices','glmMembersStartupNotices'); -} - -/* - * Check if there's any debug information or other notices that need to be displayed - * - * If there is, display as a separate window. - * - * NOTE: Need to break out notices that should be displayed in the wp-admin content area. To - * do that I need to modify the glmMembersAdminNotices function above and the - * addNotice() function in the classes/glmPluginSupport.php file. Should have addNotice() - * function be able to add to another option specifically for doing this. - */ - -// Check for any notices that need to display at the top of an admin screen -$notices = get_option('glmMembersAdminNotices'); -if (is_admin() && $notices) { - add_action('admin_notices','glmMembersAdminNotices'); + add_action('admin_notices','glmMembersWordpressAdminNotices'); } -/* - * If not doing debug, then just keep all of the debug messages cleared - */ +// If not doing debug, then clear all of the debug messages if (!GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { delete_option('glmMembersAdminNoticeAlerts'); delete_option('glmMembersAdminNotices'); diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index 60896c10..c04f6ec2 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -608,7 +608,7 @@ abstract class GlmDataAbstract $res = $this->wpdb->get_row($sql, ARRAY_A); if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "pointerOutput() value data query ".$f['field'].(isset($f['as']) ? ' as '.$f['as'] : '')); + $this->addDataAbstractNotice($sql, 'DataBlock', "pointerOutput() value data query ".$f['field'].(isset($f['as']) ? ' as '.$f['as'] : '')); } return $res['p_sum']; @@ -625,7 +625,7 @@ abstract class GlmDataAbstract $p_list = $this->wpdb->get_results($sql, ARRAY_A); if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "pointerOutput() value data query ".$f['field'].(isset($f['as']) ? ' as '.$f['as'] : '')); + $this->addDataAbstractNotice($sql, 'DataBlock', "pointerOutput() value data query ".$f['field'].(isset($f['as']) ? ' as '.$f['as'] : '')); } // Build pick select table @@ -699,7 +699,7 @@ abstract class GlmDataAbstract if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "pointerOutput() value data query ".$f['field'].(isset($f['as']) ? ' as '.$f['as'] : '')); + $this->addDataAbstractNotice($sql, 'DataBlock', "pointerOutput() value data query ".$f['field'].(isset($f['as']) ? ' as '.$f['as'] : '')); } return $res[$f['p_field']]; @@ -2384,7 +2384,7 @@ abstract class GlmDataAbstract } else { if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($newImage, 'DataBlock', "DataAbstract - imageInput() wp_get_image_editor($tmpFile) Error"); + $this->addDataAbstractNotice($newImage, 'DataBlock', "DataAbstract - imageInput() wp_get_image_editor($tmpFile) Error"); } } @@ -2731,7 +2731,7 @@ abstract class GlmDataAbstract } if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($this->fieldData, 'DataBlock', "buildFieldsList() data"); + $this->addDataAbstractNotice($this->fieldData, 'DataBlock', "buildFieldsList() data"); } return; @@ -2924,8 +2924,8 @@ abstract class GlmDataAbstract $stats = $this->wpdb->get_row($sql, ARRAY_A); if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - getStats() query"); - glmMembersAdmin::addNotice($stats, 'DataBlock', "Stats Data"); + $this->addDataAbstractNotice($sql, 'DataBlock', "DataAbstract - getStats() query"); + $this->addDataAbstractNotice($stats, 'DataBlock', "Stats Data"); } return $stats['count']; @@ -2971,7 +2971,7 @@ abstract class GlmDataAbstract } // echo "
".print_r($sql,1)."
"; if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - getList() query"); + $this->addDataAbstractNotice($sql, 'DataBlock', "DataAbstract - getList() query"); } $list = $this->wpdb->get_results($sql, ARRAY_A); @@ -2986,7 +2986,7 @@ abstract class GlmDataAbstract } if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($newList, 'DataBlock', "getList() data"); + $this->addDataAbstractNotice($newList, 'DataBlock', "getList() data"); } return $newList; @@ -3015,6 +3015,8 @@ abstract class GlmDataAbstract ;"; $detail = $this->wpdb->get_row($sql, ARRAY_A); + $this->addDataAbstractNotice($sql, 'DataBlock', "DataAbstract - getEntry() query"); + // If nothing was found, simply return false if ($detail == false) { return false; @@ -3023,11 +3025,7 @@ abstract class GlmDataAbstract // Process individual fields $detail = $this->processOutputData($detail, 'g', $fieldVals); - - if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - getEntry() query"); - glmMembersAdmin::addNotice($detail, 'DataBlock', "getEntry() data"); - } + $this->addDataAbstractNotice($detail, 'DataBlock', "getEntry() data"); return $detail; } @@ -3156,7 +3154,7 @@ abstract class GlmDataAbstract $r = $this->checkOther($r, 'n'); if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($r, 'DataBlock', "newEntry() data"); + $this->addDataAbstractNotice($r, 'DataBlock', "newEntry() data"); } return $r; @@ -3234,7 +3232,7 @@ abstract class GlmDataAbstract "; if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "insertEntry() Query"); + $this->addDataAbstractNotice($sql, 'DataBlock', "insertEntry() Query"); } // Now store the field data @@ -3244,7 +3242,7 @@ abstract class GlmDataAbstract if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { $queryError = $this->wpdb->last_error; if (trim($queryError) != '') { - glmMembersAdmin::addNotice( + $this->addDataAbstractNotice( 'insertEntry() Query Failure
' .'  Error Message: '.$queryError.'
' .'  Table: '.$this->table, 'Alert'); @@ -3256,18 +3254,18 @@ abstract class GlmDataAbstract } else { if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice('  insertEntry() requested to NOT store new entry!', 'Process'); + $this->addDataAbstractNotice('  insertEntry() requested to NOT store new entry!', 'Process'); } } } else { if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice('  checkOther() returned bad status.', 'Process'); + $this->addDataAbstractNotice('  checkOther() returned bad status.', 'Process'); } } if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($r, 'DataBlock', "DataAbstract - insertEntry() data"); + $this->addDataAbstractNotice($r, 'DataBlock', "DataAbstract - insertEntry() data"); } return $r; @@ -3293,7 +3291,7 @@ abstract class GlmDataAbstract if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { $queryError = $this->wpdb->last_error; if (trim($queryError) != '') { - glmMembersAdmin::addNotice( + $this->addDataAbstractNotice( 'editEntry() Query Failure
' .'  Error Message: '.$queryError.'
' .'  Table: '.$this->table, 'Alert'); @@ -3309,8 +3307,8 @@ abstract class GlmDataAbstract $detail = $this->processOutputData($detail, 'e', true, $id, $idField); if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - editEntry() query"); - glmMembersAdmin::addNotice($detail, 'DataBlock', "editEntry() data"); + $this->addDataAbstractNotice($sql, 'DataBlock', "DataAbstract - editEntry() query"); + $this->addDataAbstractNotice($detail, 'DataBlock', "editEntry() data"); } @@ -3386,7 +3384,7 @@ abstract class GlmDataAbstract if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { $queryError = $this->wpdb->last_error; if (trim($queryError) != '') { - glmMembersAdmin::addNotice( + $this->addDataAbstractNotice( 'updateEntry() Query Failure
' .'  Error Message: '.$queryError.'
' .'  Table: '.$this->table, 'Alert'); @@ -3399,7 +3397,7 @@ abstract class GlmDataAbstract } if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($r, 'DataBlock', "updateEntry() data"); + $this->addDataAbstractNotice($r, 'DataBlock', "updateEntry() data"); } return $r; @@ -3454,7 +3452,7 @@ abstract class GlmDataAbstract "; if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - deleteEntry() query"); + $this->addDataAbstractNotice($sql, 'DataBlock', "DataAbstract - deleteEntry() query"); } // Assume things will go fine @@ -3469,7 +3467,7 @@ abstract class GlmDataAbstract } if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { - glmMembersAdmin::addNotice($detail, 'DataBlock', "deleteEntry() data"); + $this->addDataAbstractNotice($detail, 'DataBlock', "deleteEntry() data"); } return $detail; @@ -3637,6 +3635,24 @@ abstract class GlmDataAbstract return $date_list; } + /* + * Send notices to Admin or Front addNotice() + * + * @param (variable) $d1 + * @param (variable) $d2 + * @param (variable) $d3 + * + * @return object Class object + * + */ + public function addDataAbstractNotice ( $d1, $d2 = false, $d3 = false) + { + if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) { + glmMembersAdmin::addNotice($d1, $d2, $d3); + } elseif (!is_admin() && GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) { + glmMembersFront::addNotice($d1, $d2, $d3); + } + } } ?> \ No newline at end of file diff --git a/models/admin/dashboardWidget/index.php b/models/admin/dashboardWidget/index.php index f80e3181..5a17e713 100644 --- a/models/admin/dashboardWidget/index.php +++ b/models/admin/dashboardWidget/index.php @@ -143,8 +143,8 @@ class GlmMembersAdmin_dashboardWidget_index extends GlmDataMembers $membersPending = $MemberInfo->getStats('status = '.$this->config['status_numb']['Pending']); // Get member records with bad or no lat/lon - $hideArchived = " T.access != ".$this->config['access_numb']['Archived']; - $badLatLonList = $this->getSimpleMembersList($hideArchived.' AND (T.lat = 0 OR T.lon = 0)'); + $hideArchived = " T.status != ".$this->config['status_numb']['Archived']; + $badLatLonList = $MemberInfo->getSimpleMemberInfoList($hideArchived.' AND (T.lat = 0 OR T.lon = 0)'); $haveBadLatLon = (is_array($badLatLonList) && count($badLatLonList) > 0); // If there's members with pending information, list them diff --git a/models/admin/member/memberEdit.php b/models/admin/member/memberEdit.php index 2dc9d82a..ec47320a 100644 --- a/models/admin/member/memberEdit.php +++ b/models/admin/member/memberEdit.php @@ -109,7 +109,6 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers $success = true; $option = false; $haveMemberTypes = false; - $categories = false; $this->memberID = false; $memberUpdated = false; $memberUpdateError = false; @@ -118,6 +117,12 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers $memberName = false; $addingMember = false; + // Check for action option - Should be one of the values in the "switch" statement below + $option = false; + if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') { + $option = $_REQUEST['option']; + } + /* * Get some data we're going to need */ @@ -128,20 +133,6 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers $memberTypesStats = $MemberTypes->getStats(); $haveMemberTypes = ($memberTypesStats > 0); - /* - * Get a sorted list of categories to use for picklists. - * These will be sorted so sub-categories fall under their - * respective category. - */ - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'); - $Categories = new GlmDataCategories($this->wpdb, $this->config); - $categories = $Categories->getListSortedParentChild(); - - // Check for action option - Should be one of the values in the "switch" statement below - if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') { - $option = $_REQUEST['option']; - } - /* * Determine member ID to use */ @@ -211,12 +202,6 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers // Submit a member update case 'submit': - // Check for new cities being submitted - $this->checkNewCities(); - - // Update submitted categories - $this->updateCategories(); - $memberData = $this->updateEntry($this->memberID); if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { @@ -252,11 +237,6 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers // Add the new member case 'addNew': - // Check for new cities being submitted - $this->checkNewCities(); - - // Update submitted categories - $this->updateCategories(); $memberData = $this->insertEntry(); // If update was successful then use editEntry() to setup for the edit again. @@ -309,7 +289,6 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers $templateData = array( 'success' => $success, 'haveMemberTypes' => $haveMemberTypes, - 'availableCategories' => $categories, 'memberID' => $this->memberID, 'haveMember' => $haveMember, 'member' => $memberData, @@ -330,133 +309,6 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers } - /* - * Check for new Cities being submitted - * - * @return void - */ - public function checkNewCities() - { - - // If we have a member ID and this was a submission with a new city (id < 0) - if ($this->memberID && isset($_REQUEST['city']) && $_REQUEST['city'] == -1 && isset($_REQUEST['newCityName']) && trim($_REQUEST['newCityName']) != '') { - - // Clean up city name - $cName = trim(filter_var($_REQUEST['newCityName'])); - - // Try to add the city - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'); - $Cities = new GlmDataCities($this->wpdb, $this->config); - $cID = $Cities->addCity($cName); - - // If we got a city id back - if (is_int($cID) && $cID > 0) { - - // Update the city selected for this member record - $sql = " - UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member - SET city = $cID - WHERE id = ".$this->memberID." - ;"; - $this->wpdb->query($sql); - - // Update submitted city value to use the new ID - $_REQUEST['city'] = $cID; - - } - } - } - - /* - * Update categories for the current submission - * - * @return void - */ - public function updateCategories() - { - - // Instatiate the dataCategories class - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'); - $Categories = new GlmDataCategories($this->wpdb, $this->config); - - // Instatiate categoryMemberInfo class - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategoryMemberInfo.php'); - $CategoryMemberInfo = new GlmDataCategoryMemberInfo($this->wpdb, $this->config); - - // Get any selected categories - $selectedCategories = array(); - $newCategory = false; - if (isset($_REQUEST['category']) && is_array($_REQUEST['category']) && count($_REQUEST['category']) > 0) { - - /* - * For each selected category - * - * Note that categories are submitted with either a positive key, which indicates - * that it represents an existing category, or a negative key, which indicates - * that the user is trying to add it to the list of categories. - * - */ - foreach ($_REQUEST['category'] as $key) { - - // Make sure key is an integer - $key = intval($key -0); - - // If negative, this is a new category that needs to be added to the category table - if ($key < 0) { - - $newCategory = true; - - // Check if a parent is specified - $parent = 0; - if ($_REQUEST['newCatParent'][$key] != '') { - $parent = $_REQUEST['newCatParent'][$key] -0; - } elseif ($_REQUEST['newCatParentName'][$key]) { - $parent = $_REQUEST['newCatParentName'][$key]; - } - - // Clean up the category name - $category = filter_var($_REQUEST['newCategory'][$key]); - - // Add it to the category table and get the new category ID - $categoryID = $Categories->addCategory($category, $parent); - - // If we got a new category ID, add it to the array of currently selected categoryMember records - if ($categoryID) { - $selectedCategories[$categoryID] = $categoryID; - } - - // Otherwise if it's positive, the category is an existing one - } else if ($key > 0) { - - $selectedCategories[$key] = $key; - - } - - // If there's selected categories - if (count($selectedCategories) > 0) { - - // Update the selected categories for this member information record, returns new list - $CategoryMemberInfo->setMemberInfoCategories($this->memberID, $selectedCategories); - - } - - // If there's been a new category - if ($newCategory) { - - // Get the full category list again - $this->categories = $Categories->getListSortedParentChild(); - - } - - } // For each category being submitted - - // Otherwise if this is a submission and there's no categories submitted, so make sure there's none stored - } elseif (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') { - $CategoryMemberInfo->clearMemberInfoCategories($this->memberID); - } - - } - } ?> \ No newline at end of file diff --git a/models/admin/member/memberInfo.php b/models/admin/member/memberInfo.php index a2524d64..f04f3e5f 100644 --- a/models/admin/member/memberInfo.php +++ b/models/admin/member/memberInfo.php @@ -200,6 +200,7 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo $this->optionIncludeSelectListData = true; $memberUpdated = false; $memberUpdateError = false; + $categories = false; // Check for action option - Should be one of the values in the "switch" statement below $option = false; @@ -266,6 +267,20 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo glmMembersAdmin::addNotice("  Option specified: $option", 'Process'); } + /* + * Get a sorted list of categories to use for picklists. + * These will be sorted so sub-categories fall under their + * respective category. + */ + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'); + $Categories = new GlmDataCategories($this->wpdb, $this->config); + $categories = $Categories->getListSortedParentChild(); + + // Check for action option - Should be one of the values in the "switch" statement below + if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') { + $option = $_REQUEST['option']; + } + /* * Perform requested action */ @@ -281,9 +296,23 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo // Process submission of a member information record update case 'submit': + // Check for new cities being submitted + $this->checkNewCities(); + + // Update submitted categories + $this->updateCategories(); + // Update submitted amenities $this->updateAmenities(); + // Load Image data class + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php'); + $Images = new GlmDataImages($this->wpdb, $this->config); + + // Update image gallery titles, descriptions, and image positions then return current image gallery + $this->imageGallery = $Images->galleryImageDataUpdate($this->config['ref_type_numb']['MemberInfo'], $this->memberInfoID, 'galleryPositionOrder'); + $this->haveImageGallery = ($this->imageGallery != false); + if ($this->haveMemberInfo) { // Update the member Info data @@ -309,6 +338,12 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo // Add the new member information record case 'addNew': + // Check for new cities being submitted + $this->checkNewCities(); + + // Update submitted categories + $this->updateCategories(); + // Insert the new member info into the database $this->memberName = $this->memberData['name']; $this->memberInfo = $this->insertEntry(); @@ -433,6 +468,7 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo // Compile template data $templateData = array( 'haveMember' => $this->haveMember, + 'availableCategories' => $categories, 'memberID' => $this->memberID, 'member' => $this->memberData, 'memberName' => $memberName, @@ -459,6 +495,132 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo } + /* + * Check for new Cities being submitted + * + * @return void + */ + public function checkNewCities() + { + + // If we have a member ID and this was a submission with a new city (id < 0) + if ($this->memberID && isset($_REQUEST['city']) && $_REQUEST['city'] == -1 && isset($_REQUEST['newCityName']) && trim($_REQUEST['newCityName']) != '') { + + // Clean up city name + $cName = trim(filter_var($_REQUEST['newCityName'])); + + // Try to add the city + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'); + $Cities = new GlmDataCities($this->wpdb, $this->config); + $cID = $Cities->addCity($cName); + + // If we got a city id back + if (is_int($cID) && $cID > 0) { + + // Update the city selected for this member record + $sql = " + UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member + SET city = $cID + WHERE id = ".$this->memberID." + ;"; + $this->wpdb->query($sql); + + // Update submitted city value to use the new ID + $_REQUEST['city'] = $cID; + + } + } + } + + /* + * Update categories for the current submission + * + * @return void + */ + public function updateCategories() + { + + // Instatiate the dataCategories class + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'); + $Categories = new GlmDataCategories($this->wpdb, $this->config); + + // Instatiate categoryMemberInfo class + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategoryMemberInfo.php'); + $CategoryMemberInfo = new GlmDataCategoryMemberInfo($this->wpdb, $this->config); + + // Get any selected categories + $selectedCategories = array(); + $newCategory = false; + if (isset($_REQUEST['category']) && is_array($_REQUEST['category']) && count($_REQUEST['category']) > 0) { + + /* + * For each selected category + * + * Note that categories are submitted with either a positive key, which indicates + * that it represents an existing category, or a negative key, which indicates + * that the user is trying to add it to the list of categories. + * + */ + foreach ($_REQUEST['category'] as $key) { + + // Make sure key is an integer + $key = intval($key -0); + + // If negative, this is a new category that needs to be added to the category table + if ($key < 0) { + + $newCategory = true; + + // Check if a parent is specified + $parent = 0; + if ($_REQUEST['newCatParent'][$key] != '') { + $parent = $_REQUEST['newCatParent'][$key] -0; + } elseif ($_REQUEST['newCatParentName'][$key]) { + $parent = $_REQUEST['newCatParentName'][$key]; + } + + // Clean up the category name + $category = filter_var($_REQUEST['newCategory'][$key]); + + // Add it to the category table and get the new category ID + $categoryID = $Categories->addCategory($category, $parent); + + // If we got a new category ID, add it to the array of currently selected categoryMember records + if ($categoryID) { + $selectedCategories[$categoryID] = $categoryID; + } + + // Otherwise if it's positive, the category is an existing one + } else if ($key > 0) { + + $selectedCategories[$key] = $key; + + } + + // If there's selected categories + if (count($selectedCategories) > 0) { + + // Update the selected categories for this member information record, returns new list + $CategoryMemberInfo->setMemberInfoCategories($this->memberInfoID, $selectedCategories); + + } + + // If there's been a new category + if ($newCategory) { + + // Get the full category list again + $this->categories = $Categories->getListSortedParentChild(); + + } + + } // For each category being submitted + + // Otherwise if this is a submission and there's no categories submitted, so make sure there's none stored + } elseif (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') { + $CategoryMemberInfo->clearMemberInfoCategories($this->memberID); + } + + } /* * Check it there's no active information record diff --git a/models/admin/members/index.php b/models/admin/members/index.php index 3d82ee31..51da3377 100644 --- a/models/admin/members/index.php +++ b/models/admin/members/index.php @@ -136,16 +136,16 @@ class GlmMembersAdmin_members_index extends GlmDataMembers $regionsStats = $Regions->getStats(); $haveRegions = ($regionsStats > 0); - // Get member records with bad or no lat/lon - $hideArchived = " T.access != ".$this->config['access_numb']['Archived']; - $badLatLonList = $this->getSimpleMembersList($hideArchived.' AND (T.lat = 0 OR T.lon = 0)'); - $haveBadLatLon = (is_array($badLatLonList) && count($badLatLonList) > 0); - // Get number of member information records with pending updates require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); $MemberInfo = new GlmDataMemberInfo($this->wpdb, $this->config); $membersPending = $MemberInfo->getStats('status = '.$this->config['status_numb']['Pending']); + // Get member information records with bad or no lat/lon + $hideArchived = " T.status != ".$this->config['status_numb']['Archived']; + $badLatLonList = $MemberInfo->getSimpleMemberInfoList($hideArchived.' AND (T.lat = 0 OR T.lon = 0)'); + $haveBadLatLon = (is_array($badLatLonList) && count($badLatLonList) > 0); + // If there's members with pending information, list them $pendingList = false; if ($membersPending > 0) { diff --git a/models/front/members/detail.php b/models/front/members/detail.php index a15dfef1..250ecc4b 100644 --- a/models/front/members/detail.php +++ b/models/front/members/detail.php @@ -139,6 +139,7 @@ class GlmMembersFront_members_detail extends GlmDataMemberInfo $where = ''; $haveMember = false; $haveImageGallery = false; + $success = false; // Check for "show" shortcode parameter $settings = array(); @@ -246,18 +247,7 @@ class GlmMembersFront_members_detail extends GlmDataMemberInfo $imageGallery = false; // Find the active member info record and get it with main member data - $where = " - ( - SELECT access - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members - WHERE id = T.member - ) IN ( - ".$this->config['access_numb']['NoAccess'].", - ".$this->config['access_numb']['Moderated'].", - ".$this->config['access_numb']['Full']." - ) - "; - $memberData = $this->getActiveInfoForMemberWithMemberData($id, $where); + $memberData = $this->getActiveInfoForMember($id); if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { glmMembersFront::addNotice($memberData, 'DataBlock', 'Member Info with Member Data'); @@ -282,9 +272,7 @@ class GlmMembersFront_members_detail extends GlmDataMemberInfo 'haveMember' => $haveMember, 'member' => $memberData, 'haveImageGallery' => $haveImageGallery, - 'imageGallery' => $imageGallery, - 'havePackages' => false, - 'packages' => false + 'imageGallery' => $imageGallery ); diff --git a/models/front/members/list.php b/models/front/members/list.php index 6b6c71f9..f42bf877 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -435,7 +435,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo */ // Get member list and sort - $list = $this->getListWithMemberData($where.$alphaWhere, 'member_name'); + $list = $this->getList($where.$alphaWhere, 'member_name'); if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { glmMembersFront::addNotice($list, 'DataBlock', 'Member Data'); diff --git a/setup/databaseScripts/create_database_V1.1.0.sql b/setup/databaseScripts/create_database_V1.1.0.sql index a14a337b..af11b7c1 100644 --- a/setup/databaseScripts/create_database_V1.1.0.sql +++ b/setup/databaseScripts/create_database_V1.1.0.sql @@ -150,21 +150,6 @@ CREATE TABLE {prefix}members ( created DATE NULL, -- Date member record was created name TINYTEXT NULL, -- Member name member_slug TINYTEXT NULL, -- Member name slug for canonical URLs (lowercase, "-" for spaces, no punctuation) - addr1 TINYTEXT NULL, -- Main member location address line 1 - addr2 TINYTEXT NULL, -- Address line 2 - city INT NULL, -- Pointer to City in cities table - state TINYTEXT NULL, -- Two character state code - matches states.ini entries - country TINYTEXT NULL, -- Two character country code - matches countries.ini entries - zip TINYTEXT NULL, -- ZIP/Postal code - lat FLOAT NULL, -- Latitude of member's location - lon FLOAT NULL, -- Longitude of member's location - region INT NULL, -- Pointer to entry in regions table - phone TINYTEXT NULL, -- Primary phone number - toll_free TINYTEXT NULL, -- Toll Free phone number - url TINYTEXT NULL, -- URL with information about this member - email TINYTEXT NULL, -- Main E-Mail address for this member - logo TINYTEXT NULL, -- Member logo - cc_type INT NULL, -- Bitmap of credit card types accepted - See credit_card array in plugin.ini notes TEXT NULL, -- General notes - Not displayed in front-end PRIMARY KEY (id), INDEX(name(20)), @@ -183,6 +168,21 @@ CREATE TABLE {prefix}member_info ( reference_name TINYTEXT NULL, -- Refernce name for this member information record - Not displayed on front-end descr TEXT NULL, -- Description short_descr TEXT NULL, -- Short description + addr1 TINYTEXT NULL, -- Main member location address line 1 + addr2 TINYTEXT NULL, -- Address line 2 + city INT NULL, -- Pointer to City in cities table + state TINYTEXT NULL, -- Two character state code - matches states.ini entries + country TINYTEXT NULL, -- Two character country code - matches countries.ini entries + zip TINYTEXT NULL, -- ZIP/Postal code + lat FLOAT NULL, -- Latitude of member's location + lon FLOAT NULL, -- Longitude of member's location + region INT NULL, -- Pointer to entry in regions table + phone TINYTEXT NULL, -- Primary phone number + toll_free TINYTEXT NULL, -- Toll Free phone number + url TINYTEXT NULL, -- URL with information about this member + email TINYTEXT NULL, -- Main E-Mail address for this member + logo TINYTEXT NULL, -- Member logo + cc_type INT NULL, -- Bitmap of credit card types accepted - See credit_card array in plugin.ini notes TEXT NULL, -- General notes - Not displayed in front-end create_time TIMESTAMP NULL, -- Create date/time modify_time TIMESTAMP NULL, -- Last update date/time diff --git a/setup/databaseScripts/update_database_V1.1.0.sql b/setup/databaseScripts/update_database_V1.1.0.sql index e6519d87..a20e7c58 100644 --- a/setup/databaseScripts/update_database_V1.1.0.sql +++ b/setup/databaseScripts/update_database_V1.1.0.sql @@ -24,180 +24,5 @@ DROP TABLE IF EXISTS ---- -ALTER TABLE {prefix}members ADD COLUMN addr1 TINYTEXT; - ----- - -UPDATE {prefix}members M SET addr1 = (SELECT addr1 FROM {prefix}member_info WHERE member = M.id AND addr1 > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN addr2 TINYTEXT; - ----- - -UPDATE {prefix}members M SET addr2 = (SELECT addr2 FROM {prefix}member_info WHERE member = M.id AND addr2 > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN city INT; - ----- - -UPDATE {prefix}members M SET city = (SELECT city FROM {prefix}member_info WHERE member = M.id AND city > 0 AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN state TINYTEXT; - ----- - -UPDATE {prefix}members M SET state = (SELECT state FROM {prefix}member_info WHERE member = M.id AND state > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN zip TINYTEXT; - ----- - -UPDATE {prefix}members M SET zip = (SELECT zip FROM {prefix}member_info WHERE member = M.id AND zip > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN country TINYTEXT; - ----- - -UPDATE {prefix}members M SET country = (SELECT country FROM {prefix}member_info WHERE member = M.id AND country > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN lat FLOAT; - ----- - -UPDATE {prefix}members M SET lat = (SELECT lat FROM {prefix}member_info WHERE member = M.id AND lat != 0 AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN lon FLOAT; - ----- - -UPDATE {prefix}members M SET lon = (SELECT lon FROM {prefix}member_info WHERE member = M.id AND lon != 0 AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN region INT; - ----- - -UPDATE {prefix}members M SET region = (SELECT region FROM {prefix}member_info WHERE member = M.id AND region > 0 AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN phone TINYTEXT; - ----- - -UPDATE {prefix}members M SET phone = (SELECT phone FROM {prefix}member_info WHERE member = M.id AND phone > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN toll_free TINYTEXT; - ----- - -UPDATE {prefix}members M SET toll_free = (SELECT toll_free FROM {prefix}member_info WHERE member = M.id AND toll_free > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN email TINYTEXT; - ----- - -UPDATE {prefix}members M SET email = (SELECT email FROM {prefix}member_info WHERE member = M.id AND email > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN url TINYTEXT; - ----- - -UPDATE {prefix}members M SET url = (SELECT url FROM {prefix}member_info WHERE member = M.id AND url > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN logo TINYTEXT; - ----- - -UPDATE {prefix}members M SET logo = (SELECT logo FROM {prefix}member_info WHERE member = M.id AND logo > '' AND status in (30, 20, 10) LIMIT 1); - ----- - -ALTER TABLE {prefix}members ADD COLUMN cc_type INT; - ----- - -UPDATE {prefix}members M SET cc_type = (SELECT cc_type FROM {prefix}member_info WHERE member = M.id AND cc_type > 0 AND status in (30, 20, 10) LIMIT 1); - ----- - ALTER TABLE {prefix}members ADD COLUMN notes TEXT; ----- - -ALTER TABLE {prefix}member_info DROP COLUMN addr1; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN addr2; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN city; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN state; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN zip; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN country; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN lat; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN lon; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN region; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN phone; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN toll_free; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN url; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN logo; - ----- - -ALTER TABLE {prefix}member_info DROP COLUMN cc_type; diff --git a/views/admin/dashboardWidget/index.html b/views/admin/dashboardWidget/index.html index 3d8d7a85..9e524dae 100644 --- a/views/admin/dashboardWidget/index.html +++ b/views/admin/dashboardWidget/index.html @@ -30,6 +30,12 @@ select: function( event, ui ) { var memberID = ui.item.id; window.location.replace("{$adminURL}?page=glm-members-admin-menu-member&glm_action=index&member=" + memberID ); + }, + response: function(event, ui) { + if (!ui.content.length) { + var noResult = { value:"",label:"No results found" }; + ui.content.push(noResult); + } } }); @@ -94,7 +100,7 @@ {/if} - {$p.name} + {$p.member}: {$p.reference_name} {/foreach} @@ -119,7 +125,7 @@ {/if} - {$p.member}: + {$p.member}: {$p.reference_name} diff --git a/views/admin/footer.html b/views/admin/footer.html index d34194cb..6029dc17 100644 --- a/views/admin/footer.html +++ b/views/admin/footer.html @@ -7,10 +7,5 @@ http://www.gaslightmedia.com
- {if $adminDebug} - - {/if}
\ No newline at end of file diff --git a/views/admin/member/index.html b/views/admin/member/index.html index 70f07bd8..6f14409e 100644 --- a/views/admin/member/index.html +++ b/views/admin/member/index.html @@ -10,29 +10,19 @@ {if $haveMember} + - +
{$member.fieldData.name}
- {$member.fieldData.name}
- {if $member.fieldData.addr1}{$member.fieldData.addr1}
{/if} - {if $member.fieldData.addr2}{$member.fieldData.addr2}
{/if} - {if $member.fieldData.city.name}{$member.fieldData.city.name}{if $member.fieldData.state.name}, {/if}{/if} - {if $member.fieldData.state.name}{$member.fieldData.state.name}{/if} - {if $member.fieldData.zip}{$member.fieldData.zip}{/if} - {if $member.fieldData.country.name}{$member.fieldData.country.name}{/if} -
- {if $member.fieldData.phone}Phone: {$member.fieldData.phone}
{/if} - {if $member.fieldData.toll_free}Toll Free: {$member.fieldData.toll_free}
{/if} - {if $member.fieldData.email}E-Mail Address: {$member.fieldData.email}
{/if} - {if $member.fieldData.url}{$member.fieldData.url}
{/if} - - -
+ +
Member Slug: {$member.fieldData.member_slug}
Date created:{$member.fieldData.created.date}
+
+ @@ -41,11 +31,10 @@ -
Member Display & Access: {$member.fieldData.access.name}Member Type: {$member.fieldData.member_type.name}
Date created:{$member.fieldData.created.date}
- Edit Base Member Information + Edit Member Name and Status
@@ -100,6 +89,7 @@ {$m.create_time.datetime} {$m.modify_time.datetime} + {if $m.bad_lat_lon}Bad Map Location{/if} {if apply_filters('glm_members_permit_admin_member_index_clone_activate_info_version', true)} Clone  {if $m.status.name != 'Active'}Activate{/if} diff --git a/views/admin/member/memberEdit.html b/views/admin/member/memberEdit.html index a0a88cfd..d3d9e76b 100644 --- a/views/admin/member/memberEdit.html +++ b/views/admin/member/memberEdit.html @@ -1,12 +1,5 @@ {include file='admin/member/header.html'} - - - - - {if $haveMember || $addingMember} {if $haveMemberTypes} @@ -15,8 +8,12 @@ {if $addingMember} Add New Member {else} - Edit Member Information + Edit Member Name and Status {/if} + {if $memberUpdated}Member Updated{/if} + {if $memberUpdateError}Member Update Error{/if} + + {if apply_filters('glm_members_permit_admin_member_index_edit_member', true)} @@ -31,14 +28,6 @@ {/if} - - @@ -94,239 +83,6 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {if $member.fieldRequired.lat} - - -
Address Line 1: - - {if $member.fieldFail.addr1}

{$member.fieldFail.addr1}

{/if} -
Address Line 2: - - {if $member.fieldFail.addr2}

{$member.fieldFail.addr2}

{/if} -
City - -
Add a new City
-
- - - - - -
City Name: - -
-
-

* Required

- Cancel - -
- - - -
State: - - {if $member.fieldFail.state}

{$member.fieldFail.state}

{/if} -
ZIP / Postal Code: - - {if $member.fieldFail.zip}

{$member.fieldFail.zip}

{/if} -
Country: - - {if $member.fieldFail.country}

{$member.fieldFail.country}

{/if} -
{else}{/if}Location: - - -
Map Location Using Above Address
-

- MAP USE: Drag the pointer to the desired location for this member. - Use + and - buttons or the mouse wheel to zoom in or out. - Click and drag anywhere else on the map to move to another area. -

-
(map loads here)
- Selected Position: Lat {$member.fieldData.lat}, Lon {$member.fieldData.lon} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Categories - -
Add a new Category
-
- - - - - - - - - -
Category Name: - -
-
Parent Category: - -
OR
- -
-

* Required

- Cancel - -
- -    Select a category to add to box below.
-
- - {if isset($member.fieldData.categories) && $member.fieldData.categories} - {foreach from=$member.fieldData.categories item=c} -
- {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name} - X - -
- {/foreach} - {/if} -
-
Region: - - {if $member.fieldFail.region}

{$member.fieldFail.region}

{/if} -
Phone #: - - {if $member.fieldFail.phone}

{$member.fieldFail.phone}

{/if} -
Toll Free #: - - {if $member.fieldFail.toll_free}

{$member.fieldFail.toll_free}

{/if} -
Web Address (URL): - {if $member.fieldData.url} - Test Link - {/if} - - {if $member.fieldFail.url}

{$member.fieldFail.url}

{/if} -
Credit Cards Accepted: - {foreach from=$member.fieldData.cc_type.bitmap item=v} - {$v.name}
- {/foreach} - {if $member.fieldFail.cc_type}

{$member.fieldFail.cc_type}

{/if} -
Logo: - - {if $member.fieldData.logo} - - - - - {/if} - -
-
- -
-
- Delete Image
- {$member.fieldData.logo}
-
New image:
- - {if $member.fieldFail.logo}

{$member.fieldFail.logo}

{/if} -

* Required

{if $addingMember} @@ -420,383 +176,22 @@ + + @@ -88,16 +92,22 @@ - + + +
- - - + + + + +
Profile Name: + {if $memberInfo.fieldFail.reference_name}

{$memberInfo.fieldFail.reference_name}

{/if}
The "Profile Name" field is used to help identify this particular member profile. Members may have multiple profiles, @@ -118,7 +128,7 @@
Description: + {php} wp_editor('{$memberInfo.fieldData.descr|escape:quotes}', 'glm_descr', array( // 'media_buttons' => true, @@ -134,11 +144,236 @@
Short Description: + {if $memberInfo.fieldFail.short_descr}

{$memberInfo.fieldFail.short_descr}

{/if}
Notes: + + {if $memberInfo.fieldFail.notes} +

{$memberInfo.fieldFail.notes}

{/if}
This + "Notes" field is not displayed anywhere else. It is + strictly for making and keeping notes related to this + member profile. +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {if $memberInfo.fieldRequired.lat} + + +
Address Line 1: + + {if $memberInfo.fieldFail.addr1}

{$memberInfo.fieldFail.addr1}

{/if} +
Address Line 2: + + {if $memberInfo.fieldFail.addr2}

{$memberInfo.fieldFail.addr2}

{/if} +
City + +
Add a new City
+
+ + + + + +
City Name: + +
+
+

* Required

+ Cancel + +
+ + + +
State: + + {if $memberInfo.fieldFail.state}

{$memberInfo.fieldFail.state}

{/if} +
ZIP / Postal Code: + + {if $memberInfo.fieldFail.zip}

{$memberInfo.fieldFail.zip}

{/if} +
Country: + + {if $memberInfo.fieldFail.country}

{$memberInfo.fieldFail.country}

{/if} +
Region: + + {if $memberInfo.fieldFail.region}

{$memberInfo.fieldFail.region}

{/if} +
{else}{/if}Location: + + +
Map Location Using Above Address
+

+ MAP USE: Drag the pointer to the desired location for this member. + Use + and - buttons or the mouse wheel to zoom in or out. + Click and drag anywhere else on the map to move to another area. +

+
(map loads here)
+ Selected Position: Lat {$memberInfo.fieldData.lat}, Lon {$memberInfo.fieldData.lon} +
+ + + + + + + + + + + + + + + + + + + + +
Phone #: + + {if $memberInfo.fieldFail.phone}

{$memberInfo.fieldFail.phone}

{/if} +
Toll Free #: + + {if $memberInfo.fieldFail.toll_free}

{$memberInfo.fieldFail.toll_free}

{/if} +
E-Mail Address: + + {if $memberInfo.fieldFail.email}

{$memberInfo.fieldFail.email}

{/if} +
Web Address (URL): + {if $memberInfo.fieldData.url} + Test Link + {/if} + + {if $memberInfo.fieldFail.url}

{$memberInfo.fieldFail.url}

{/if} +
+ + + + + + + + +
Categories + +
Add a new Category
+
+ + + + + + + + + +
Category Name: + +
+
Parent Category: + +
OR
+ +
+

* Required

+ Cancel + +
+ +    Select a category to add to box below.
+
+ + {if isset($memberInfo.fieldData.categories) && $memberInfo.fieldData.categories} + {foreach from=$memberInfo.fieldData.categories item=c} +
+ {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name} + X + +
+ {/foreach} + {/if} +
+
Amenities @@ -168,17 +403,35 @@
+ + + + + - - + -
Notes: - - {if $memberInfo.fieldFail.notes}

{$memberInfo.fieldFail.notes}

{/if}
- This "Notes" field is not displayed anywhere else. It is strictly for making and keeping - notes related to this member profile. +
Logo: + + {if $memberInfo.fieldData.logo} + + + + + {/if} + +
+
+ +
+
+ Delete Image
+ {$memberInfo.fieldData.logo}
+
New image:
+ + {if $memberInfo.fieldFail.logo}

{$memberInfo.fieldFail.logo}

{/if}
- + + + + + + + + +
Credit Cards Accepted: + {foreach from=$memberInfo.fieldData.cc_type.bitmap item=v} + {$v.name}
+ {/foreach} + {if $memberInfo.fieldFail.cc_type}

{$memberInfo.fieldFail.cc_type}

{/if} +
+

* Required

@@ -410,6 +678,11 @@ var table = $(this).attr('data-show-table'); $('#' + table).removeClass('glm-hidden'); + + if (table == 'glm-table-address') { + initMap(); + } + }); /* @@ -471,7 +744,323 @@ window.location.replace("{$thisURL}?page={$thisPage}&glm_action=index&member={$memberID}&deleteID={$memberInfo.fieldData.id}"); }); {/if} + /* + * Category Selection + */ + + // Action to select a category + $('#categorySelect').change( function() { + + // Get the ID, name, and parent of the category + var catValue = $('#categorySelect').val(); + var catName = $('#categorySelect').find(':selected').text(); + var catParent = $('#categorySelect').find(':selected').attr('data-parent'); + + // Check if the category has already been added + var found = false; + $(".glm-members-catgegory").each( function() { + var id = $(this).attr('data-id'); + if (id == catValue) { + found = true; + } + }); + + // Check if there's a parent + parentName = ''; + if (catParent != '') { + parentName = catParent + ': '; + } + + // If not found, Add the category + if (!found) { + $('#activeCategories').append('
' + + parentName + catName.trim() + ' X' + + '
'); + } + + // Reset picklist + $('#categorySelect').val(''); + + }); + + // Action to de-select a category + $('.catDelete').live('click', function() { + $(this).parent().remove(); + }); + + /* + * New Category Dialog + */ + + var newCat = 0; // Used for new category numbering (new cats are negative numbers) + + // Setup dialog box for adding a new category + $("#newCategoryDialog").dialog({ + autoOpen: false, + minWidth: 400, + dialogClass: "glm-dialog-no-close" + }); + + // Ad a new category button action - pop-up dialog + $('#newCategoryButton').click( function() { + $("#newCategoryDialog").dialog("open"); + }); + + // Submit new category + $('#newCategorySubmit').click( function() { + + // Assign new cat number + newCat--; + + // Get new category information + var newCatName = $('#newCatName').val(); + var newCatParent = $('#newCatParent').val(); + var catParent = $('#newCatParent').find(':selected').attr('data-parent'); + var newCatParentName = $('#newCatParentName').val(); + + // If there's no name, tell the user we need one. + if (newCatName == '') { + $('#newCatNameTD').addClass('glm-form-bad-input'); + $('#newCatNameRequired').text('A catogory name is required!'); + return false; + } + + // Check if there's a parent, get the name - new parent name overrides selected parent + parentName = ''; + if (newCatParentName && newCatParentName != '') { + parentName = newCatParentName + ': '; + } else if (catParent && catParent != '') { + parentName = catParent + ': '; + } + + // Add the new category to the active categories list + $('#activeCategories').append('
' + + parentName + newCatName.trim() + ' X' + + '' + + '' + + '' + + '' + + '
'); + + // Clear the dialog input fields + $('#newCatName').val(''); + $('#newCatParent').val(''); + $('#newCatParentName').val(''); + + $("#newCategoryDialog").dialog("close"); + + }); + $('#newCategoryCancel').click( function() { + $("#newCategoryDialog").dialog("close"); + }); + + // Setup dialog box for adding a new category + $("#newCategoryDialog").dialog({ + autoOpen: false, + minWidth: 400, + dialogClass: "glm-dialog-no-close" + }); + /* + * New City Dialog + */ + + // Setup dialog box for adding a new city + $("#newCityDialog").dialog({ + autoOpen: false, + minWidth: 400, + dialogClass: "glm-dialog-no-close" + }); + $('#newCityCancel').click( function() { + $("#newCityDialog").dialog("close"); + }); + + // Ad a new city button action - pop-up dialog + $('#newCityButton').click( function() { + $("#newCityDialog").dialog("open"); + }); + + // Submit new city + var newCityAdded = false; + $('#newCitySubmit').click( function() { + + // Get new city name + var newCityName = $('#newCityName').val(); + + // If no name is supplied, notify used it's required + if (newCityName == '') { + $('#newCityNameTD').addClass('glm-form-bad-input'); + $('#newCityNameRequired').text('A city name is required!'); + return false; + } + + // Add new city name to the hidden field that will pass the new name to PHP. + $('#cityName').val(newCityName); + + // Add new city name to picklist and for storing - Only one permitted per submission + if (newCityAdded) { + + // New city already added, so just update the name and select that one + $('#city').val(-1); + $('#city option:selected').text(newCityName); + + } else { + + // Add the new city name to the city picklist + $('#city').append(''); + $('#city').val(-1); + $('#newCityNameTD').append(''); + newCityAdded = true; + + } + + // Clear new city name from form + $('#newCityName').val(''); + + $("#newCityDialog").dialog("close"); + + glmGeocode(); + + }); + + /* + * Map operations + */ + + //show error if location can't be found + function showError() { + alert("Location can't be found"); + } + + /* + * Google Maps + * API reference: https://developers.google.com/maps/documentation/javascript/reference + */ + + // Set default - Need to make this configurable + var startLat = $('#glmLat').val(); + var startLon = $('#glmLng').val(); + var location = new google.maps.LatLng(startLat, startLon); + var map; + var geocoder; + var marker; + + function initMap() { + var map = new google.maps.Map(document.getElementById('locationMap'), { + zoom: 15, + disableDefaultUI: false, + mapTypeId: google.maps.MapTypeId.MAP, + }); + var geocoder = new google.maps.Geocoder(); + var marker = new google.maps.Marker({ + map: map, + position: location, + draggable: enableDraggable, + animation: google.maps.Animation.DROP, + title: "This is your location" + }); + map.setCenter(location); + + // Listen for an end of drag event for the map marker + google.maps.event.addListener(marker,'dragend',function(event) { + + // Get the end postion + glmLat = this.position.lat(); + glmLng = this.position.lng(); + + // Assign it to the hidden fields for submission + $('#glmLat').val(glmLat); + $('#glmLng').val(glmLng); + + // Also display it to the user + $('#mapPosition').html('Lat ' + glmLat.toFixed(4) + ', Lon ' + glmLng.toFixed(4)); + }); + + // When estimate location button is clicked, geocode using address + $('#glm-estimate-location').on('click', function() { + + // Get all address parts + var geoAddr1 = $('#addr1').val().trim(); + var geoAddr2 = $('#addr2').val().trim(); + var geoCity = $('#city').find('option:selected').text().trim(); + var geoState = $('#state').find('option:selected').text().trim(); + var geoZIP = $('#zip').val().trim(); + var geoCountry = $('#country').find('option:selected').text().trim(); + + // Assemble address string for + var geoAddress = geoAddr1 + ', ' + geoAddr2 + ', ' + geoCity + ', ' + geoState + ' ' + geoZIP + ', ' + geoCountry; + + // Send to Google Geocoder + geocoder.geocode( { 'address': geoAddress }, function(results, status) { + + // If we have a geocode solution + if (status == google.maps.GeocoderStatus.OK) { + + // 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 = results[0].geometry.location.lat(); + glmLng = results[0].geometry.location.lng(); + $('#glmLat').val(glmLat); + $('#glmLng').val(glmLng); + + // Also display it to the user + $('#mapPosition').html('Lat ' + glmLat.toFixed(4) + ', Lon ' + glmLng.toFixed(4)); + + // Otherwise tell the user. + } else { + alert('Not able to estimate position from the current address.'); + } + }); + + }); + + } + + // Resubmit geocoding when map location button is clicked + function glmGeocode() { + + // Get all address parts + var geoAddr1 = $('#addr1').val().trim(); + var geoAddr2 = $('#addr2').val().trim(); + var geoCity = $('#city').find('option:selected').text().trim(); + var geoState = $('#state').find('option:selected').text().trim(); + var geoZIP = $('#zip').val().trim(); + var geoCountry = $('#country').find('option:selected').text().trim(); + + // Assemble address string for + var geoAddress = geoAddr1 + ', ' + geoAddr2 + ', ' + geoCity + ', ' + geoState + ' ' + geoZIP + ', ' + geoCountry; + + // Send to Google Geocoder + geocoder.geocode( { 'address': geoAddress }, function(results, status) { + + // If we have a geocode solution + if (status == google.maps.GeocoderStatus.OK) { + + // 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 = results[0].geometry.location.lat(); + glmLng = results[0].geometry.location.lng(); + $('#glmLat').val(glmLat); + $('#glmLng').val(glmLng); + + // Also display it to the user + $('#mapPosition').html('Lat ' + glmLat.toFixed(4) + ', Lon ' + glmLng.toFixed(4)); + + // Otherwise tell the user. + } else { + alert('Not able to estimate position from the current address.'); + } + }); + } + // Flash certain elements for a short time after display $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500); @@ -480,9 +1069,15 @@ */ // Check for any field errors and if found change related tab to error color. - if ($('.glm-form-bad-input-general').length) { - $('#glm-member-info-general').addClass('glm-bad-input-area'); - } + + $('.glm-form-bad-input').each( function(index) { + + tab = $(this).attr('data-tabid'); + + if (!$('#' + tab).hasClass('glm-bad-input-area')) { + $('#' + tab).addClass('glm-bad-input-area'); + } + }); // Check for most input changes $('input, textarea, select').on( 'change', function() { diff --git a/views/admin/members/index.html b/views/admin/members/index.html index 60eedf0a..bd6cf74e 100644 --- a/views/admin/members/index.html +++ b/views/admin/members/index.html @@ -152,6 +152,12 @@ select: function( event, ui ) { var memberID = ui.item.id; window.location.replace("{$adminURL}?page=glm-members-admin-menu-member&glm_action=index&member=" + memberID ); + }, + response: function(event, ui) { + if (!ui.content.length) { + var noResult = { value:"",label:"No results found" }; + ui.content.push(noResult); + } } }); diff --git a/views/admin/members/list.html b/views/admin/members/list.html index fbecd96a..e8b52224 100644 --- a/views/admin/members/list.html +++ b/views/admin/members/list.html @@ -1,6 +1,6 @@ {include file='admin/members/header.html'} -
+ List Filters:   Show Archived   Pending Only   @@ -110,9 +110,17 @@ select: function( event, ui ) { var memberID = ui.item.id; window.location.replace("{$adminURL}?page=glm-members-admin-menu-member&glm_action=index&member=" + memberID ); + }, + response: function(event, ui) { + if (!ui.content.length) { + var noResult = { value:"",label:"No results found" }; + ui.content.push(noResult); + } } }); + + }); diff --git a/views/front/footer.html b/views/front/footer.html index ce3a2055..75ce31ac 100644 --- a/views/front/footer.html +++ b/views/front/footer.html @@ -1,10 +1,4 @@ - - {if $frontDebug} - - {/if} \ No newline at end of file