From: Steve Sutton Date: Mon, 19 Nov 2018 13:46:03 +0000 (-0500) Subject: WIP Show members by using ajax call to only get members. X-Git-Tag: v2.11.0^2~8^2~14 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=cba27630b8bc7fc97c374d78761ea94edd59f266;p=WP-Plugins%2Fglm-member-db.git WIP Show members by using ajax call to only get members. Setting up needed variables for the smarty view file so it can be used by ajax. --- diff --git a/models/admin/ajax/membersList.php b/models/admin/ajax/membersList.php new file mode 100644 index 00000000..0e4c6432 --- /dev/null +++ b/models/admin/ajax/membersList.php @@ -0,0 +1,89 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + + +// Load Member Info data abstract +require_once GLM_MEMBERS_PLUGIN_PATH.'/models/front/members/list.php'; +define( 'GLM_MEMBER_LIST_AJAX_LOADER', true ); +/** + * + * This class exports the currently selected members list + * to a printable HTML file, to a CSV file, or otherwise. + */ +class GlmMembersAdmin_ajax_membersList extends GlmMembersFront_members_list +{ + + /** + * 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; + + parent::__construct( $wpdb, $config ); + + } + + // public function modelAction( $actionData = false ) { + // + // if ( isset( $_REQUEST['limit'] ) && filter_var( $_REQUEST['limit'], FILTER_VALIDATE_INT ) ) { + // $limit = filter_var( $_REQUEST['limit'], FILTER_VALIDATE_INT ); + // } + // + // if ( isset( $_REQUEST['pageSelect'] ) && filter_var( $_REQUEST['pageSelect'], FILTER_SANITIZE_STRING ) ) { + // $pageSelect = filter_var( $_REQUEST['pageSelect'], FILTER_SANITIZE_STRING ); + // } + // if ( isset( $_REQUEST['nextStart'] ) && filter_var( $_REQUEST['nextStart'], FILTER_VALIDATE_INT ) ) { + // $nextStart = filter_var( $_REQUEST['nextStart'], FILTER_VALIDATE_INT ); + // } + // if ( $_SESSION['search_query'] ) { + // // $actionData = $_SESSION['actionData']; + // // $_REQUEST = $_SESSION['search_query']; + // // $_REQUEST['limit'] = $limit; + // // $_REQUEST['pageSelect'] = $pageSelect; + // // $_REQUEST['nextStart'] = $nextStart; + // } + // + // return parent::modelAction( $actionData ); + // + // } + +} diff --git a/models/front/members/list.php b/models/front/members/list.php index bcaaadfc..8f1599fd 100755 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -199,6 +199,13 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $start = 1; $limit = $this->config['settings']['list_pagination_count']; // Now this is in management + if ( isset( $_REQUEST['limit'] ) && filter_var( $_REQUEST['limit'], FILTER_VALIDATE_INT ) ) { + $limit = filter_var( $_REQUEST['limit'], FILTER_VALIDATE_INT ); + } + if ( isset( $actionData['request']['limit'] ) && filter_var( $actionData['request']['limit'], FILTER_VALIDATE_INT ) ) { + $limit = filter_var( $actionData['request']['limit'], FILTER_VALIDATE_INT ); + } + // Check if a multi-select for categories is being submitted. If so, assign that to the category selection if (isset($_REQUEST['categorySearchMultiple']) && is_array($_REQUEST['categorySearchMultiple'])) { $actionData['request']['category'] = implode(',', $_REQUEST['categorySearchMultiple']); @@ -860,6 +867,9 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo if (isset($actionData['request']['view']) && $actionData['request']['view'] != "" ) { $view = strtolower($actionData['request']['view']); } + if ( isset( $_REQUEST['view'] ) && $_REQUEST['view'] ) { + $view = $_REQUEST['view']; + } /* * Check for a blank start - No members selected, just search form @@ -931,6 +941,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo '', // prohibitListOptions $appendSelect ); + // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + // echo '
$where: ' . print_r( $where, true ) . '
'; } else { // Get member list sorted as specified switch ($this->config['settings']['list_order_list']) { @@ -1000,6 +1012,42 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $singleCategory = true; } + // Setup ajax Request + $ajaxRequest = ''; + if ( $memberType ) { + $ajaxRequest .= "&memberType=$memberType"; + } + if ( $categorySearch ) { + $ajaxRequest .= "&categorySearch=$categorySearch"; + } + if ( $citySearch ) { + $ajaxRequest .= "&citySearch=$citySearch"; + } + if ( $ajaxRequest ) { + $ajaxRequest .= "&ajaxRequest=$ajaxRequest"; + } + if ( $view ) { + $ajaxRequest .= "&view=$view"; + } + if ( $blankStart ) { + $ajaxRequest .= "&blankStart=$blankStart"; + } + if ( $catSelected ) { + $ajaxRequest .= "&catSelected=$catSelected"; + } + if (isset($_REQUEST['textSearch'])) { + $ajaxRequest .= "&textSearch=" . urlencode( stripslashes( $textSearch ) ); + } + if ( isset( $actionData['request']['category'] ) ) { + $catsRequested = explode( ',', $actionData['request']['category'] ); + if ( $catsRequested ) { + foreach ( $catsRequested as $cats ) { + $ajaxRequest .= "&categorySearchMultiple[]=" . $cats; + } + } + // echo '
$catsRequested: ' . print_r( $catsRequested, true ) . '
'; + } + // Compile template data $templateData = array( 'haveMembers' => $haveMembers, @@ -1039,6 +1087,16 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo 'start' => $start, 'limit' => $limit, + // Add for ajax + 'memberType' => $memberType, + 'categorySearch' => $categorySearch, + 'amenitySearch' => $amenitySearch, + 'citySearch' => $citySearch, + 'ajaxRequest' => $ajaxRequest, + + 'ajaxLoader' => ( defined( 'GLM_MEMBER_LIST_AJAX_LOADER' ) && GLM_MEMBER_LIST_AJAX_LOADER ) ? true : false, + 'ajaxNext' => ( isset( $_REQUEST['ajaxNext'] ) ) ? true : false, + ); if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { @@ -1047,12 +1105,18 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo trigger_error($membListTime." seconds ---", E_USER_NOTICE); } + $viewFile = 'front/members/list.html'; + + if ( defined( 'GLM_MEMBER_LIST_AJAX_LOADER' ) && GLM_MEMBER_LIST_AJAX_LOADER ) { + $viewFile = 'front/members/listContainer.html'; + } + // Return status, suggested view, and data to controller - also return any modified settings return array( 'status' => $success, 'menuItemRedirect' => false, 'modelRedirect' => false, - 'view' => "front/members/list.html", + 'view' => $viewFile, 'data' => $templateData, 'settings' => $settings ); diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 0fd861b9..1abbd1b5 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -669,3 +669,10 @@ add_filter( 10, 2 ); + +// If no session then start one. +add_action( 'init', function(){ + if ( !session_id() ) { + session_start(); + } +}); diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 350d72ab..139b1904 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -93,6 +93,7 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) { 'blank-start' => false, 'show' => false, 'view' => false, + 'limit' => false, 'map' => 'list_show_map', 'map-opened' => 'list_map_show_opened', 'map-name-link' => 'list_map_show_detaillink', diff --git a/setup/validActions.php b/setup/validActions.php index ef985fca..33cf8b92 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -48,6 +48,7 @@ $glmMembersValidActions = array( 'membersMapData' => 'glm-member-db', 'citiesMapData' => 'glm-member-db', 'countiesMapData' => 'glm-member-db', + 'membersList' => 'glm-member-db', ), 'dashboard' => array( 'index' => 'glm-member-db',