From: Steve Sutton Date: Fri, 6 Sep 2019 14:16:47 +0000 (-0400) Subject: Add member search field. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=e3c61f949db8bd5578ce90097f8aa66f8d3be798;p=WP-Plugins%2Fglm-member-db.git Add member search field. Adds members attribute to the shortcode. --- diff --git a/css/admin.css b/css/admin.css index ae7aa9f9..27d0c681 100755 --- a/css/admin.css +++ b/css/admin.css @@ -489,7 +489,7 @@ td.glm-nowrap { } #reset-shortcode{ background: #DE5D60; - + } .shortcode-button:hover{ cursor: pointer; @@ -512,7 +512,7 @@ td.glm-nowrap { .shortcode-confirmation.confirmed{ top: -50px; z-index: 1; - + } .delete-shortcode-tile{ margin-left: 10px; @@ -812,10 +812,10 @@ td.glm-nowrap { width:50%;*/ display: block; } -#categoryTitle > span, #groupsTitle > span, #regionsTitle > span { +#categoryTitle > span, #memberTitle > span, #groupsTitle > span, #regionsTitle > span { font-weight: bold; } -#categoryTitle, #shortcodesTitle, #groupsTitle, #regionsTitle { +#categoryTitle, #memberTitle, #shortcodesTitle, #groupsTitle, #regionsTitle { font-weight: bold; font-size: 16px; /* border-bottom: 2px #ddd solid; */ diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index 85cd4aae..1f6b289e 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -42,6 +42,7 @@ jQuery(function ($) { $(".shortcode-tile-container").empty(); shortcodeAttributes = { categories : {list:[], isList: true}, + members : {list:[], isList: true}, regions : {list:[], isList: true}, groups : {list:[], isList: true}, views : {list:[], isList: false}, @@ -79,10 +80,43 @@ jQuery(function ($) { generateShortCodeAttribute(shortcodeData); } setupAttributes(); + var cache = {}; + var memberNames = [ + { label: 'Steve', value: 1 }, + { label: 'George', value: 2 }, + { label: 'Dave', value: 3 }, + { label: 'Banner', value: 4 } + ]; + $('#shortcode-members').autocomplete({ + minLength: 2, + source: function( request, response ){ + var term = request.term; + if ( term in cache ) { + response( cache[ term ] ); + return; + } + + $.getJSON( memberNameJsonUrl, request, function( data, status, xhr ){ + cache[ term ] = data; + response( data ); + } ); + }, + select: function( event, ui ){ + var id = $(this).val(); + var type = 'members'; + let record = {id: ui.item.value, name: ui.item.label, type: 'members'}; + $('#shortcode-members').val(''); + shortcodeAttributes['members'].list.push(record); + updateShortcode({list: shortcodeAttributes[type].list, type: type, isList: shortcodeAttributes[type].isList}); + }, + close: function( event, ui ) { + $('#shortcode-members').val(''); + } + }); $(document).on("change", ".shortcode-selection",function(){ var id = $(this).val(); var name = $(this).find("option:selected").text(); - var type = $(this).find("option:selected").data("type"); + var type = $(this).find("option:selected").data("type"); let record = {id: id, name: name, type: type}; if(shortcodeAttributes[type].list.length == 0 || !checkDuplicates(record, shortcodeAttributes[type].list) && shortcodeAttributes[type].isList ){ shortcodeAttributes[type].list.push(record); @@ -154,4 +188,4 @@ jQuery(function ($) { tile.remove(); updateShortcode({list: shortcodeAttributes[type].list, type: type}); }); -}); \ No newline at end of file +}); diff --git a/models/admin/ajax/memberNameJson.php b/models/admin/ajax/memberNameJson.php new file mode 100644 index 00000000..5948582f --- /dev/null +++ b/models/admin/ajax/memberNameJson.php @@ -0,0 +1,92 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + + +/** + * + * This class exports the currently selected members list + * to a printable HTML file, to a CSV file, or otherwise. + */ +class GlmMembersAdmin_ajax_memberNameJson +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /** + * Constructor + * + * This constructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ( $wpdb, $config ) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + public function modelAction( $actionData = false ) { + + // Create json export of active members. + $members = array(); + + $whereParts = array( 'true' ); + + $whereParts[] = " ( + 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'] . " + ) + AND T.status = " . $this->config['status_numb']['Active']; + + $where = implode( ' AND ', $whereParts ); + + $members = $this->wpdb->get_results( + "SELECT T.member as value,T.member_name as name,T.member_name as label + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info T + WHERE true + AND $where", + ARRAY_A + ); + + header( 'Content-Type: application/json' ); + echo json_encode( $members ); + } + +} diff --git a/setup/validActions.php b/setup/validActions.php index 53467cec..95a966c0 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -52,6 +52,7 @@ $glmMembersValidActions = array( 'membersListJson' => 'glm-member-db', 'verifyLatLon' => 'glm-member-db', 'memberCountCheck' => 'glm-member-db', + 'memberNameJson' => 'glm-member-db', ), 'dashboard' => array( 'index' => 'glm-member-db', diff --git a/views/admin/pages/shortcode.html b/views/admin/pages/shortcode.html index f6028457..248f5a13 100644 --- a/views/admin/pages/shortcode.html +++ b/views/admin/pages/shortcode.html @@ -1,3 +1,6 @@ +
@@ -39,21 +42,26 @@ {/foreach} -
+ +
Reset Shortcode
Shortcode Reset
-
- Copy To Clipboard +
+ Copy To Clipboard
Shortcode Copied
- +
Categories
+
+
Members
+
+
Amenity Groups
@@ -76,4 +84,4 @@ .glma-category-child::before{ content: "-"; } - \ No newline at end of file +