From: Anthony Talarico Date: Fri, 26 Oct 2018 12:15:47 +0000 (-0400) Subject: adding admin search template and model files to manage the header search X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=73875432c56566819149beb15a7a34759f8eda79;p=WP-Plugins%2Fglm-member-db.git adding admin search template and model files to manage the header search --- diff --git a/models/admin/adminSearch/index.php b/models/admin/adminSearch/index.php deleted file mode 100644 index ba4b501d..00000000 --- a/models/admin/adminSearch/index.php +++ /dev/null @@ -1,184 +0,0 @@ -wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - // Run constructor for members data class - parent::__construct(false, false); - - } - - /** - * Perform Model Action - * - * This method does the work for this model and returns any resulting data - * - * @return array Status and data array - * - * 'status' - * - * True if successful and false if there was a fatal failure. - * - * 'menuItemRedirect' - * - * If not false, provides a menu item the controller should - * execute after this one. Normally if this is used, there would also be a - * modelRedirect value supplied as well. - * - * 'modelRedirect' - * - * If not false, provides an action the controller should execute after - * this one. - * - * 'view' - * - * A suggested view name that the controller should use instead of the - * default view for this model or false to indicate that the default view - * should be used. - * - * 'data' - * - * Data that the model is returning for use in merging with the view to - * produce output. - * - */ - public function modelAction ( $actionData = false ) - { - - $success = true; - $text = 'text'; - $haveInfoRecords = false; - $memberInfoRecords = false; - $noActive = false; - $showArchived = false; - $memberID = 0; - $clickThroughCounts = array('day' => 0, 'week' => 0, 'month' => 0); - $detailViewCounts = array('day' => 0, 'week' => 0, 'month' => 0); - - // Enqueue Materialize - wp_register_script( - 'materialize', - GLM_MEMBERS_PLUGIN_URL . 'js/materialize/materialize.min.js', - array( - 'jquery' - ), - GLM_MEMBERS_PLUGIN_VERSION - ); - wp_register_script( - 'autoComplete', - GLM_MEMBERS_PLUGIN_URL . 'js/materialize/autoComplete.min.js', - array( - 'jquery' - ), - GLM_MEMBERS_PLUGIN_VERSION - ); - wp_enqueue_script('materialize', false, array('jquery'), false, true); - wp_enqueue_script('autoComplete', false, array('jquery'), false, true); - wp_enqueue_style('materialize-css', GLM_MEMBERS_PLUGIN_URL . 'css/materialize.min.css'); - wp_enqueue_style('autoComplete', GLM_MEMBERS_PLUGIN_URL . 'css/autoComplete.css'); - wp_enqueue_style('admin-css', GLM_MEMBERS_PLUGIN_URL . 'css/glma-admin-sass.css'); - wp_enqueue_style('css-icons', "https://fonts.googleapis.com/icon?family=Material+Icons"); - - // Check if there's a logged in user who is locked to their own entity. - $lockedToMember = apply_filters( 'glm_members_locked_to_member_id', false ); - $memberID = $lockedToMember; - - // Get the current date, first date of this week, and first date of this month - $today = date('Y-m-d'); - $thisWeek = date('Y-m-d', strtotime('-'.date('w').' days')); - $thisMonth = date('Y-m-d', strtotime('-'.(date('j')-1).' days')); - - - // Create a set of useful data for each registered plugin that has a filter - // Use that filter to retrieve table information, then run query for each 'list' field. - foreach ( $this->config[ 'addOns' ] as $a ) { - if ( has_filter( $a['slug'] . "-dashboard-widget") ) { - $addons[$a['slug']]['name'] = $a['short_name']; - $addons[$a['slug']]['slug'] = $a['slug']; - $addons[$a['slug']]['widgetData'] = apply_filters($a['slug'] . "-dashboard-search", ""); - // Sort the component list based on the 'order' - uasort($addons[$a['slug']]['widgetData']['components'], array($this, 'orderSort') ) ; - - } - } - - // Compile template data. - $templateData = array( - 'lockedToMember' => $lockedToMember, - 'member' => $actionData, - 'showArchived' => $showArchived, - 'statusTypeNumbers' => $this->config['status_numb'], - 'memberID' => $memberID, - 'haveInfoRecords' => $haveInfoRecords, - 'memberInfoRecords' => $memberInfoRecords, - 'statusPending' => $this->config['status_numb']['Pending'], - 'addons' => $addons, - 'baseUrl' => GLM_MEMBERS_PLUGIN_URL - ); - - // Return status, suggested view, and data to controller. - return array( - 'status' => $success, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/newDashboard/index.html', - 'data' => $templateData - ); - - } - - public function orderSort ($a, $b) { return (strcmp ($a['order'],$b['order'])); } -} diff --git a/models/admin/manageMembers/index.php b/models/admin/manageMembers/index.php new file mode 100644 index 00000000..c5014470 --- /dev/null +++ b/models/admin/manageMembers/index.php @@ -0,0 +1,413 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Members data abstract +require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'; + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_manageMembers_index extends GlmDataMembers +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor 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; + + /* + * Run constructor for members data class to setup table and fields array + * + * Since this class is extending GlmDataMembers, it does not need to pass + * $wpdb and $config to it in the constructor. + */ + parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * 'view' + * + * A suggested view name that the contoller should use instead of the + * default view for this model or false to indicate that the default view + * should be used. + * + * 'data' + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + */ + public function modelAction ($actionData = false) + { + require_once GLM_MEMBERS_PLUGIN_PATH . '/models/admin/manageMembers/search.php'; + $where = ' true '; + $alphaWhere = ' true '; + $catSearchSelected = false; + $catSelectedString = ""; + $mTypeSelected = ''; + $catSelected = ''; + $catsToUse = ''; + $filterPending = false; + $filterArchived = false; + $filterFeatured = false; + $haveFilter = false; + $numbDisplayed = false; + $lastDisplayed = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $namesList = false; + $enable_members = $this->config['settings']['enable_members']; + $textSearch = false; + + // Save all query parameters + if ( isset( $_REQUEST['glm_action'] ) && $_REQUEST['glm_action'] == 'list' ) { + $_SESSION['member_saved_search'] = $_REQUEST; + } else if ( !isset( $_REQUEST['glm_action'] ) + && (!isset( $_REQUEST['back_to_search'] ) || !filter_var( $_REQUEST['back_to_search'], FILTER_VALIDATE_BOOLEAN )) + ) { + unset( $_SESSION['member_saved_search'] ); + } + // Check for back to search flag + if ( isset( $_REQUEST['back_to_search'] ) + && filter_var( $_REQUEST['back_to_search'], FILTER_VALIDATE_BOOLEAN ) + && isset( $_SESSION['member_saved_search'] ) + ) { + $_REQUEST = $_SESSION['member_saved_search']; + } + // Check if this is a request to show archived members + if (isset($_REQUEST['filterArchived'])) { + $where .= " AND access = ".$this->config['access_numb']['Archived']; + $filterArchived = true; + $haveFilter = true; + + // If not, don't show them + } else { + $where .= " AND access != ".$this->config['access_numb']['Archived']; + } + + // Check for a text search + if (isset($_REQUEST['text_search']) && trim($_REQUEST['text_search']) != '') { + + // $textSearch = addslashes(filter_input(INPUT_POST, 'text_search', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); + $textSearch = addslashes(filter_var($_REQUEST['text_search'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); + $where .= " AND T.id in ( + SELECT DISTINCT(id) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members + WHERE name like '%$textSearch%' + )"; + + } + + // Get a list of categories for filtering + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'; + $Categories = new GlmDataCategories($this->wpdb, $this->config); + $categories = $Categories->getListSortedParentChild(false); + + // If we have categories, add "selected" element default false; + if (is_array($categories)) { + reset($categories); + while (list($k, $v) = each($categories)) { + $categories[$k]['selected'] = false; + } + } + + // Get a list of member_types for filtering + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberTypes.php'; + $MemberTypes = new GlmDataMemberTypes( $this->wpdb, $this->config ); + $member_types = $MemberTypes->getList(); + + // Check if there is a member_type filter + if ( isset( $_REQUEST['filterMemberTypes'] ) && $memberTypeFilter = filter_var( $_REQUEST['filterMemberTypes'], FILTER_VALIDATE_INT ) ) { + $where .= " AND T.member_type = $memberTypeFilter "; + $mTypeSelected = $memberTypeFilter; + } + + // Check if there is a category filter (multi-select) + if (isset($_REQUEST['categorySearch']) && $_REQUEST['categorySearch'] > 0) { + $catsToUse = explode(',',$_REQUEST['categorySearch']); + } + if (isset($_REQUEST['filterCategories']) && count($_REQUEST['filterCategories']) > 0) { + $catsToUse = $_REQUEST['filterCategories']; + } + + if ($catsToUse && $catsToUse !== '') { + $cats = ''; + $catsSep = ''; + + // For each selected category + foreach($catsToUse as $c) { + $cats .= $catsSep.$c; + $catsSep = ','; + $categories[$c]['selected'] = true; + } + + $where .= " AND T.id in ( + SELECT DISTINCT(I.member) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info I, + ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info M, + ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories C + WHERE I.id = M.member_info + AND I.status != " . $this->config['status_numb']['Archived'] ." + AND ( + M.category in ($cats) + OR (C.parent in ($cats) AND M.category = C.id) + ) + )"; + $catSelectedString = $cats; + } + + // Check for "Pending Only + if (isset($_REQUEST['filterPending'])) { + + // Refine search only to members with pending Info data + $where .= " AND ( + SELECT COUNT(id) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info I + WHERE I.status = ".$this->config['status_numb']['Pending']." + AND I.member = T.id + )"; + + $filterPending = true; + $haveFilter = true; + } + + // Check for "Featured Only + if (isset($_REQUEST['filterFeatured'])) { + + // Refine search only to members with pending Info data + $where .= " AND ( + SELECT COUNT(id) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members I + WHERE I.featured = 1 + AND I.id = T.id + + )"; + $filterFeatured = true; + $haveFilter = true; + } + + // If doing alpha list + if (isset($_REQUEST['alpha'])) { + $actionData['request']['alpha'] = $_REQUEST['alpha']; + } + + $alphaList = false; + $alphaWhere = ''; + + $alphaSelected = false; + + // If user clicked a page request then we need to check the savedAlpha value + if (isset($_REQUEST['savedAlpha']) && isset($_REQUEST['pageSelect'])) { + $actionData['request']['alpha'] = $_REQUEST['savedAlpha']; + } + + if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) { + $alphaSelected = strtoupper($actionData['request']['alpha']); + $alphaWhere .= " AND T.name LIKE '$alphaSelected%'"; + } + + // Get full list for all other filters, but not filtered by alpha (that would be silly) + $alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected); + + $whereParts = apply_filters('glm-member-db-admin-search-query', $where, 'glm-member-db'); + if ( is_array( $whereParts ) && count( $whereParts ) > 0 ) { + $where .= ' AND '.implode(" AND ", $whereParts); + $whereSep = ' AND '; + } + + // Get count of members listed + $memberCount = $this->getStats($where); + + // If the number of members is less than a page, don't do paging + if ($memberCount <= $limit) { + $paging = false; + } + + // Get full list of names matching this where clause for search box + $namesList = $this->getIdName($where); + + // Check if we're doing paging + if (isset($_REQUEST['pageSelect'])) { + + // If request is for Next + if ($_REQUEST['pageSelect'][0] == 'N') { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; + } + } + + // echo '
$where: ' . print_r( $where, true ) . '
'; + + // Get stats for number of members found matching current selection criteria (includes alpha selection) + $filteredMembersFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); + + // Get a current list of members + $listResult = $this->getSimpleMembersList($where.$alphaWhere, 'name', true, 'id', $start, $limit); + + // Get paging results + $numbDisplayed = $listResult['returned']; + $lastDisplayed = $listResult['last']; + if ($start == 1) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ($start < 1) { + $start = 1; + } + } + if ($listResult['returned'] == $limit) { + $nextStart = $start + $limit; + } + + // since we're doing paging, we have to break out just the member data + $list = $listResult['list']; + unset($listResult); + + // If we have list entries - even if it's an empty list + $success = true; + $haveMembers = false; + if ($list !== false) { + + $success = true; + + // If we have any entries + if (count($list) > 0) { + $haveMembers = true; + } + } + + // Determine if current user can add, edit, delete member data +// $canEdit = current_user_can('glm_members_edit'); + + // Add a url for each member + if ( isset( $list) && is_array( $list ) ) { + foreach ($list as $member) { + $list[$member['id']]['member_slug'] = sanitize_title($member['name']); + } + } + + // Create current month/date string to pre-populate the Month/Year field for + $monthYear = date('F Y'); + + // Update the textSearch for output into the form. + $textSearch = str_replace("\'", "'", $textSearch ); + $textSearch = str_replace('\\"', '"', $textSearch ); + $textSearch = str_replace('\\', '', $textSearch ); + + // Compile template data + $templateData = array( + 'monthYear' => $monthYear, + 'enable_members' => $enable_members, + 'haveMembers' => $haveMembers, + 'members' => $list, + 'memberCount' => $memberCount, + 'categories' => $categories, + 'member_types' => $member_types, + 'haveFilter' => $haveFilter, + 'filterArchived' => $filterArchived, + 'filterFeatured' => $filterFeatured, + 'filterPending' => $filterPending, + 'catSelected' => $catSelected, + 'catSearchSelected' => $catSelectedString, + 'mTypeSelected' => $mTypeSelected, + 'alphaList' => $alphaList, + 'alphaSelected' => $alphaSelected, + 'numbDisplayed' => $numbDisplayed, + 'lastDisplayed' => $lastDisplayed, + 'paging' => $paging, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'start' => $start, + 'limit' => $limit, + 'namesList' => $namesList, + 'textSearch' => $textSearch + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/manageMembers/index.html', + 'data' => $templateData + ); + + } + +} + +?> diff --git a/models/admin/manageMembers/manage.php b/models/admin/manageMembers/manage.php deleted file mode 100644 index 25dc34a2..00000000 --- a/models/admin/manageMembers/manage.php +++ /dev/null @@ -1,413 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 0.1 - */ - -// Load Members data abstract -require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'; - -/* - * This class performs the work for the default action of the "Members" menu - * option, which is to display the members dashboard. - * - */ -class GlmMembersAdmin_manageMembers_manage extends GlmDataMembers -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - - /* - * Constructor - * - * This contructor 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; - - /* - * Run constructor for members data class to setup table and fields array - * - * Since this class is extending GlmDataMembers, it does not need to pass - * $wpdb and $config to it in the constructor. - */ - parent::__construct(false, false); - - } - - /* - * Perform Model Action - * - * This method does the work for this model and returns any resulting data - * - * @return array Status and data array - * - * 'status' - * - * True if successfull and false if there was a fatal failure. - * - * 'menuItemRedirect' - * - * If not false, provides a menu item the controller should - * execute after this one. Normally if this is used, there would also be a - * modelRedirect value supplied as well. - * - * 'modelRedirect' - * - * If not false, provides an action the controller should execute after - * this one. - * - * 'view' - * - * A suggested view name that the contoller should use instead of the - * default view for this model or false to indicate that the default view - * should be used. - * - * 'data' - * - * Data that the model is returning for use in merging with the view to - * produce output. - * - */ - public function modelAction ($actionData = false) - { - - $where = ' true '; - $alphaWhere = ' true '; - $catSearchSelected = false; - $catSelectedString = ""; - $mTypeSelected = ''; - $catSelected = ''; - $catsToUse = ''; - $filterPending = false; - $filterArchived = false; - $filterFeatured = false; - $haveFilter = false; - $numbDisplayed = false; - $lastDisplayed = false; - $paging = true; - $prevStart = false; - $nextStart = false; - $start = 1; - $limit = 20; // Set to the number of listings per page - $namesList = false; - $enable_members = $this->config['settings']['enable_members']; - $textSearch = false; - - // Save all query parameters - if ( isset( $_REQUEST['glm_action'] ) && $_REQUEST['glm_action'] == 'list' ) { - $_SESSION['member_saved_search'] = $_REQUEST; - } else if ( !isset( $_REQUEST['glm_action'] ) - && (!isset( $_REQUEST['back_to_search'] ) || !filter_var( $_REQUEST['back_to_search'], FILTER_VALIDATE_BOOLEAN )) - ) { - unset( $_SESSION['member_saved_search'] ); - } - // Check for back to search flag - if ( isset( $_REQUEST['back_to_search'] ) - && filter_var( $_REQUEST['back_to_search'], FILTER_VALIDATE_BOOLEAN ) - && isset( $_SESSION['member_saved_search'] ) - ) { - $_REQUEST = $_SESSION['member_saved_search']; - } - // Check if this is a request to show archived members - if (isset($_REQUEST['filterArchived'])) { - $where .= " AND access = ".$this->config['access_numb']['Archived']; - $filterArchived = true; - $haveFilter = true; - - // If not, don't show them - } else { - $where .= " AND access != ".$this->config['access_numb']['Archived']; - } - - // Check for a text search - if (isset($_REQUEST['text_search']) && trim($_REQUEST['text_search']) != '') { - - // $textSearch = addslashes(filter_input(INPUT_POST, 'text_search', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); - $textSearch = addslashes(filter_var($_REQUEST['text_search'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); - $where .= " AND T.id in ( - SELECT DISTINCT(id) - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members - WHERE name like '%$textSearch%' - )"; - - } - - // Get a list of categories for filtering - require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'; - $Categories = new GlmDataCategories($this->wpdb, $this->config); - $categories = $Categories->getListSortedParentChild(false); - - // If we have categories, add "selected" element default false; - if (is_array($categories)) { - reset($categories); - while (list($k, $v) = each($categories)) { - $categories[$k]['selected'] = false; - } - } - - // Get a list of member_types for filtering - require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberTypes.php'; - $MemberTypes = new GlmDataMemberTypes( $this->wpdb, $this->config ); - $member_types = $MemberTypes->getList(); - - // Check if there is a member_type filter - if ( isset( $_REQUEST['filterMemberTypes'] ) && $memberTypeFilter = filter_var( $_REQUEST['filterMemberTypes'], FILTER_VALIDATE_INT ) ) { - $where .= " AND T.member_type = $memberTypeFilter "; - $mTypeSelected = $memberTypeFilter; - } - - // Check if there is a category filter (multi-select) - if (isset($_REQUEST['categorySearch']) && $_REQUEST['categorySearch'] > 0) { - $catsToUse = explode(',',$_REQUEST['categorySearch']); - } - if (isset($_REQUEST['filterCategories']) && count($_REQUEST['filterCategories']) > 0) { - $catsToUse = $_REQUEST['filterCategories']; - } - - if ($catsToUse && $catsToUse !== '') { - $cats = ''; - $catsSep = ''; - - // For each selected category - foreach($catsToUse as $c) { - $cats .= $catsSep.$c; - $catsSep = ','; - $categories[$c]['selected'] = true; - } - - $where .= " AND T.id in ( - SELECT DISTINCT(I.member) - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info I, - ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info M, - ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories C - WHERE I.id = M.member_info - AND I.status != " . $this->config['status_numb']['Archived'] ." - AND ( - M.category in ($cats) - OR (C.parent in ($cats) AND M.category = C.id) - ) - )"; - $catSelectedString = $cats; - } - - // Check for "Pending Only - if (isset($_REQUEST['filterPending'])) { - - // Refine search only to members with pending Info data - $where .= " AND ( - SELECT COUNT(id) - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info I - WHERE I.status = ".$this->config['status_numb']['Pending']." - AND I.member = T.id - )"; - - $filterPending = true; - $haveFilter = true; - } - - // Check for "Featured Only - if (isset($_REQUEST['filterFeatured'])) { - - // Refine search only to members with pending Info data - $where .= " AND ( - SELECT COUNT(id) - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members I - WHERE I.featured = 1 - AND I.id = T.id - - )"; - $filterFeatured = true; - $haveFilter = true; - } - - // If doing alpha list - if (isset($_REQUEST['alpha'])) { - $actionData['request']['alpha'] = $_REQUEST['alpha']; - } - - $alphaList = false; - $alphaWhere = ''; - - $alphaSelected = false; - - // If user clicked a page request then we need to check the savedAlpha value - if (isset($_REQUEST['savedAlpha']) && isset($_REQUEST['pageSelect'])) { - $actionData['request']['alpha'] = $_REQUEST['savedAlpha']; - } - - if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) { - $alphaSelected = strtoupper($actionData['request']['alpha']); - $alphaWhere .= " AND T.name LIKE '$alphaSelected%'"; - } - - // Get full list for all other filters, but not filtered by alpha (that would be silly) - $alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected); - - $whereParts = apply_filters('glm-member-db-admin-search-query', $where, 'glm-member-db'); - if ( is_array( $whereParts ) && count( $whereParts ) > 0 ) { - $where .= ' AND '.implode(" AND ", $whereParts); - $whereSep = ' AND '; - } - - // Get count of members listed - $memberCount = $this->getStats($where); - - // If the number of members is less than a page, don't do paging - if ($memberCount <= $limit) { - $paging = false; - } - - // Get full list of names matching this where clause for search box - $namesList = $this->getIdName($where); - - // Check if we're doing paging - if (isset($_REQUEST['pageSelect'])) { - - // If request is for Next - if ($_REQUEST['pageSelect'][0] == 'N') { - $newStart = $_REQUEST['nextStart'] - 0; - - // Otherwise it must be Previous - } else { - $newStart = $_REQUEST['prevStart'] - 0; - } - - if ($newStart > 0) { - $start = $newStart; - } - } - - // echo '
$where: ' . print_r( $where, true ) . '
'; - - // Get stats for number of members found matching current selection criteria (includes alpha selection) - $filteredMembersFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); - - // Get a current list of members - $listResult = $this->getSimpleMembersList($where.$alphaWhere, 'name', true, 'id', $start, $limit); - - // Get paging results - $numbDisplayed = $listResult['returned']; - $lastDisplayed = $listResult['last']; - if ($start == 1) { - $prevStart = false; - } else { - $prevStart = $start - $limit; - if ($start < 1) { - $start = 1; - } - } - if ($listResult['returned'] == $limit) { - $nextStart = $start + $limit; - } - - // since we're doing paging, we have to break out just the member data - $list = $listResult['list']; - unset($listResult); - - // If we have list entries - even if it's an empty list - $success = true; - $haveMembers = false; - if ($list !== false) { - - $success = true; - - // If we have any entries - if (count($list) > 0) { - $haveMembers = true; - } - } - - // Determine if current user can add, edit, delete member data -// $canEdit = current_user_can('glm_members_edit'); - - // Add a url for each member - if ( isset( $list) && is_array( $list ) ) { - foreach ($list as $member) { - $list[$member['id']]['member_slug'] = sanitize_title($member['name']); - } - } - - // Create current month/date string to pre-populate the Month/Year field for - $monthYear = date('F Y'); - - // Update the textSearch for output into the form. - $textSearch = str_replace("\'", "'", $textSearch ); - $textSearch = str_replace('\\"', '"', $textSearch ); - $textSearch = str_replace('\\', '', $textSearch ); - - // Compile template data - $templateData = array( - 'monthYear' => $monthYear, - 'enable_members' => $enable_members, - 'haveMembers' => $haveMembers, - 'members' => $list, - 'memberCount' => $memberCount, - 'categories' => $categories, - 'member_types' => $member_types, - 'haveFilter' => $haveFilter, - 'filterArchived' => $filterArchived, - 'filterFeatured' => $filterFeatured, - 'filterPending' => $filterPending, - 'catSelected' => $catSelected, - 'catSearchSelected' => $catSelectedString, - 'mTypeSelected' => $mTypeSelected, - 'alphaList' => $alphaList, - 'alphaSelected' => $alphaSelected, - 'numbDisplayed' => $numbDisplayed, - 'lastDisplayed' => $lastDisplayed, - 'paging' => $paging, - 'prevStart' => $prevStart, - 'nextStart' => $nextStart, - 'start' => $start, - 'limit' => $limit, - 'namesList' => $namesList, - 'textSearch' => $textSearch - ); - - // Return status, suggested view, and data to controller - return array( - 'status' => $success, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/manageMembers/manage.html', - 'data' => $templateData - ); - - } - -} - -?> diff --git a/models/admin/manageMembers/search.php b/models/admin/manageMembers/search.php new file mode 100644 index 00000000..69de6bb8 --- /dev/null +++ b/models/admin/manageMembers/search.php @@ -0,0 +1,92 @@ + link + * + */ + + $glmMemberSearch = [ + 'title' => 'Members', + 'listButtons' => [ + [ + 'id' => 'add-member', + 'content' => 'Add', + 'classes' => '', + 'styles' => '', + 'data' => '' + ], + [ + 'id' => 'export-button', + 'content' => 'Export', + 'url' => '#', + 'classes' => 'btn-small waves-effect waves-light btn modal-trigger', + 'styles' => '', + 'data' => 'membersExportModal' + ], + ], + 'components' => [ + [ + 'id' => 'membersExportModal', + 'template' => 'modal', + 'order' => 99, + 'form' => ''//$this->controller('export', 'index', false, true) + ], + [ + 'id' => 'textSearch', + 'order' => 2, + 'template' => 'textSearch', + 'entityID' => 'id', + 'fields' => "id, name", + 'where' => 'name', + ], + [ + 'id' => 'dateSearch', + 'order' => 3, + 'fromDate' => 'fromDate', + 'toDate' => 'toDate', + 'template' => 'dateSearch', + 'entityID' => 'members', + 'defaultFromDate' => date('m/d/Y'), + ], + [ + 'id' => 'categorySearch', + 'order' => 4, + 'categories' => ['cat 1', 'cat 2', 'cat 3'], + 'template' => 'category', + 'entityID' => 'members', + 'defaultFromDate' => date('m/d/Y'), + ], + [ + 'id' => 'memberTypeSearch', + 'order' => 5, + 'template' => 'dropdown', + 'entityID' => 'members', + 'defaultFromDate' => date('m/d/Y'), + ], + [ + 'id' => 'archiveSearch', + 'order' => 6, + 'template' => 'checkbox', + 'entityID' => 'members', + 'defaultFromDate' => date('m/d/Y'), + ], + [ + 'id' => 'featuredSearch', + 'order' => 7, + 'template' => 'checkbox', + 'entityID' => 'event', + 'defaultFromDate' => date('m/d/Y'), + ], + ] + ]; diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 1183b9ed..f53d57fe 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -574,141 +574,3 @@ add_filter( 13, 1 ); -add_filter( - GLM_MEMBERS_PLUGIN_SLUG .'-dashboard-search', - function ( $member = null ) { - $membersIndexPage = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-members'; - $memberIndexPage = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member'; - $membersTable = GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info"; - $membersTextTable = GLM_MEMBERS_PLUGIN_DB_PREFIX . "members"; - $membersEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=memberInfo'; - $membersSettingsPage = GLM_MEMBERS_PLUGIN_ADMIN_URL.'?page=glm-members-admin-menu-settings&settingsPage=members'; - $membersRefLink = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member&glm_action=index'; - - $MemberInfo = new GlmDataMemberInfo($this->wpdb, $this->config); - - // Set default values for using getList() later, where the custom set of fields below will be used. - $where = ''; - $order = ''; - $fieldVals = true; - $idField = 'id'; - $start = false; - $limit = false; - - // Save the current fields array and make a copy. Will be restored before the return. - $fSave = $MemberInfo->fields; - - // echo "
fsave: " . var_dump($fSave) . "

"; - - // Remove what we don't want from the copy and get the list - $MemberInfo->fields = array( - 'id' => $fSave['id'], - 'reference_name'=> $fSave['reference_name'], - 'status' => $fSave['status'], - 'member_pointer'=> $fSave['member_pointer'], - 'member' => $fSave['member'], - //'ref_type' => 'ref_type', // membersInfo has no ref_type field yet - ); - - // echo "
MemberInfo: " . var_dump($MemberInfo->fields) . "

"; - - // $widgetResult = $MemberInfo->getList('status='.$MemberInfo->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit); - - // echo "
Widgetresult: " . var_dump($widgetResult) . "

"; - - /* - * For list components: pass ref_type and ref_dest as part of the 'fields' string if you want to - * make these options part of the href of each
  • link - * - */ - - $content = [ - 'title' => 'Members', - 'listButtons' => [ - [ - 'id' => 'add-member', - 'content' => 'Add', - 'url' => $memberIndexPage . "&glm_action=memberEdit&option=add", - 'classes' => '', - 'styles' => '', - 'data' => '' - ], - [ - 'id' => 'export-button', - 'content' => 'Export', - 'url' => '#', - 'classes' => 'btn-small waves-effect waves-light btn modal-trigger', - 'styles' => '', - 'data' => 'membersExportModal' - ], - ], - 'components' => [ - [ - 'id' => 'membersExportModal', - 'template' => 'modal', - 'order' => 99, - 'form' => ''//$this->controller('export', 'index', false, true) - ], - [ - 'id' => 'textSearch', - 'order' => 2, - 'template' => 'textSearch', - 'entityID' => 'id', - 'table' => $membersTextTable, - 'fields' => "id, name", - 'where' => 'name', - 'resultUrl' => $memberIndexPage . "&glm_action=index&member=", - ], - [ - 'id' => 'dateSearch', - 'order' => 3, - 'fromDate' => 'fromDate', - 'toDate' => 'toDate', - 'template' => 'dateSearch', - 'entityID' => 'members', - 'defaultFromDate' => date('m/d/Y'), - 'resultUrl' => $eventsListPage.'&event=', - ], - [ - 'id' => 'categorySearch', - 'order' => 4, - 'categories' => ['cat 1', 'cat 2', 'cat 3'], - 'template' => 'category', - 'entityID' => 'members', - 'defaultFromDate' => date('m/d/Y'), - ], - [ - 'id' => 'memberTypeSearch', - 'order' => 5, - 'template' => 'dropdown', - 'entityID' => 'members', - 'defaultFromDate' => date('m/d/Y'), - 'resultUrl' => $eventsListPage.'&event=', - ], - [ - 'id' => 'archiveSearch', - 'order' => 6, - 'template' => 'checkbox', - 'entityID' => 'members', - 'defaultFromDate' => date('m/d/Y'), - 'resultUrl' => $eventsListPage.'&event=', - ], - [ - 'id' => 'featuredSearch', - 'order' => 7, - 'template' => 'checkbox', - 'entityID' => 'event', - 'defaultFromDate' => date('m/d/Y'), - 'resultUrl' => $eventsListPage.'&event=', - ], - ] - ]; - - // Restore the fields list - $MemberInfo->fields = $fSave; - - return $content; - }, - 13, - 1 -); \ No newline at end of file diff --git a/setup/adminMenus.php b/setup/adminMenus.php index a0ca7e4d..7c75ac9b 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -86,8 +86,8 @@ if (current_user_can('glm_members_members')) { $this->config['terms']['term_admin_menu_members'].'New Members', 'Manage Members', 'glm_members_member', - 'glm-members-admin-menu-members-manage', - function() {$this->controller('manageMembers', 'manage');} + 'glm-members-admin-menu-members-index', + function() {$this->controller('manageMembers', 'index');} ); // Add a submenu for the "Member" section diff --git a/setup/validActions.php b/setup/validActions.php index 5df37f1e..a9af9678 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -49,7 +49,7 @@ $glmMembersValidActions = array( 'adminSearch' => 'glm-member-db', ), 'manageMembers' => array( - 'manage' => 'glm-member-db' + 'index' => 'glm-member-db' ), 'dashboard' => array( 'index' => 'glm-member-db', diff --git a/views/admin/manageMembers/adminSearch/searchHeader.html b/views/admin/manageMembers/adminSearch/searchHeader.html new file mode 100644 index 00000000..7873714d --- /dev/null +++ b/views/admin/manageMembers/adminSearch/searchHeader.html @@ -0,0 +1,3 @@ +
    + Search Fields pulled from file +
    \ No newline at end of file diff --git a/views/admin/manageMembers/index.html b/views/admin/manageMembers/index.html new file mode 100644 index 00000000..7dd8949a --- /dev/null +++ b/views/admin/manageMembers/index.html @@ -0,0 +1,68 @@ + +
    + {include file='admin/manageMembers/adminSearch/searchHeader.html'} +
    +
    Loading ...
    +
    +
    + + \ No newline at end of file diff --git a/views/admin/manageMembers/manage.html b/views/admin/manageMembers/manage.html deleted file mode 100644 index bdb1890b..00000000 --- a/views/admin/manageMembers/manage.html +++ /dev/null @@ -1,65 +0,0 @@ - -
    - -
    -
    Loading ...
    -
    -
    - \ No newline at end of file