From: Laury GvR Date: Fri, 9 Nov 2018 17:24:46 +0000 (-0500) Subject: Valid actions and basic admin files added/renamed X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=7ff42ae33fa7960dc73bd19097a757c91d0907e8;p=WP-Plugins%2Fglm-member-db.git Valid actions and basic admin files added/renamed --- diff --git a/controllers/admin.php b/controllers/admin.php index 7e5bfc2a..a1ea526a 100755 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -861,6 +861,9 @@ class glmMembersAdmin extends GlmPluginSupport $plugIn = $this->config['validActions']['adminActions'][$menuItem][$action]; // Build model and path and class names + echo "menuItem: " . $menuitem . "+++
"; + echo "plugin: " . var_dump($plugIn) . "+++
"; + echo "action: " . $action . "+++

"; $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/admin/$menuItem/$action.php"; $className = 'GlmMembersAdmin_' . $menuItem . '_' . $action; $loopTracking .= "

Loop: $loopCheck
Model: $modelName
Class: $className

"; diff --git a/models/admin/manageDashboard/members.php b/models/admin/manageDashboard/members.php new file mode 100644 index 00000000..2a811fa1 --- /dev/null +++ b/models/admin/manageDashboard/members.php @@ -0,0 +1,442 @@ + + * @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_manageDashboard_members 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) + { + + + // 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"); + + require_once GLM_MEMBERS_PLUGIN_PATH . '/models/admin/manageDashboard/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, + + 'searchFields' => $glmMemberSearch + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/common/manageDashboard/index.html', + 'data' => $templateData + ); + + } + +} + +?> diff --git a/models/admin/manageDashboard/search.php b/models/admin/manageDashboard/search.php new file mode 100644 index 00000000..4b14df1f --- /dev/null +++ b/models/admin/manageDashboard/search.php @@ -0,0 +1,107 @@ + 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', + 'displayName' => 'Categories', + 'order' => 4, + 'categories' => ['cat 1', 'cat 2', 'cat 3'], + 'template' => 'category', + 'entityID' => 'members', + 'defaultFromDate' => date('m/d/Y'), + ], + [ + 'id' => 'memberTypeSearch', + 'displayName' => 'Member Type', + 'order' => 5, + 'template' => 'dropdown', + 'entityID' => 'members', + ], + [ + 'id' => 'archiveSearch', + 'displayName' => 'Archived', + 'order' => 6, + 'template' => 'checkbox', + 'entityID' => 'members', + ], + [ + 'id' => 'featuredSearch', + 'displayName' => 'Featured Search', + 'order' => 7, + 'template' => 'checkbox', + 'entityID' => 'member', + ], + [ + 'id' => 'pendingSearch', + 'displayName' => 'Pending Search', + 'order' => 7, + 'template' => 'checkbox', + 'entityID' => 'member', + ], + [ + 'id' => 'memberCount', + 'displayName' => 'Member Count', + 'order' => 7, + 'template' => 'count', + 'entityID' => 'member', + ], + ] + ]; diff --git a/models/admin/manageMembers/index.php b/models/admin/manageMembers/index.php deleted file mode 100644 index f0046e22..00000000 --- a/models/admin/manageMembers/index.php +++ /dev/null @@ -1,442 +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_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) - { - - - // 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"); - - 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, - - 'searchFields' => $glmMemberSearch - ); - - // Return status, suggested view, and data to controller - return array( - 'status' => $success, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/common/manageDashboard/index.html', - 'data' => $templateData - ); - - } - -} - -?> diff --git a/models/admin/manageMembers/search.php b/models/admin/manageMembers/search.php deleted file mode 100644 index 4b14df1f..00000000 --- a/models/admin/manageMembers/search.php +++ /dev/null @@ -1,107 +0,0 @@ - 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', - 'displayName' => 'Categories', - 'order' => 4, - 'categories' => ['cat 1', 'cat 2', 'cat 3'], - 'template' => 'category', - 'entityID' => 'members', - 'defaultFromDate' => date('m/d/Y'), - ], - [ - 'id' => 'memberTypeSearch', - 'displayName' => 'Member Type', - 'order' => 5, - 'template' => 'dropdown', - 'entityID' => 'members', - ], - [ - 'id' => 'archiveSearch', - 'displayName' => 'Archived', - 'order' => 6, - 'template' => 'checkbox', - 'entityID' => 'members', - ], - [ - 'id' => 'featuredSearch', - 'displayName' => 'Featured Search', - 'order' => 7, - 'template' => 'checkbox', - 'entityID' => 'member', - ], - [ - 'id' => 'pendingSearch', - 'displayName' => 'Pending Search', - 'order' => 7, - 'template' => 'checkbox', - 'entityID' => 'member', - ], - [ - 'id' => 'memberCount', - 'displayName' => 'Member Count', - 'order' => 7, - 'template' => 'count', - 'entityID' => 'member', - ], - ] - ]; diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 7c75ac9b..8079beba 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -83,11 +83,11 @@ if (current_user_can('glm_members_members')) { add_submenu_page( $mainMenuSlug, - $this->config['terms']['term_admin_menu_members'].'New Members', + $this->config['terms']['term_admin_menu_members'].' NewDashboard', 'Manage Members', 'glm_members_member', 'glm-members-admin-menu-members-index', - function() {$this->controller('manageMembers', 'index');} + function() {$this->controller('manageDashboard', 'members');} ); // Add a submenu for the "Member" section diff --git a/setup/validActions.php b/setup/validActions.php index a9af9678..537214f1 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -48,8 +48,8 @@ $glmMembersValidActions = array( 'glmTextSearch' => 'glm-member-db', 'adminSearch' => 'glm-member-db', ), - 'manageMembers' => array( - 'index' => 'glm-member-db' + 'manageDashboard' => array( + 'members' => 'glm-member-db', ), 'dashboard' => array( 'index' => 'glm-member-db', diff --git a/views/admin/common/manageDashboard/index.html b/views/admin/common/manageDashboard/index.html index 4aaaa755..707c1cf5 100644 --- a/views/admin/common/manageDashboard/index.html +++ b/views/admin/common/manageDashboard/index.html @@ -1,6 +1,6 @@
- {include file='admin/manageMembers/adminSearch/searchHeader.html'} + {include file='admin/manageDashboard/adminSearch/searchHeader.html'}
{foreach $searchFields.components as $component} diff --git a/views/admin/manageDashboard/adminSearch/searchHeader.html b/views/admin/manageDashboard/adminSearch/searchHeader.html new file mode 100644 index 00000000..7873714d --- /dev/null +++ b/views/admin/manageDashboard/adminSearch/searchHeader.html @@ -0,0 +1,3 @@ +
+ Search Fields pulled from file +
\ No newline at end of file diff --git a/views/admin/manageMembers/adminSearch/searchHeader.html b/views/admin/manageMembers/adminSearch/searchHeader.html deleted file mode 100644 index 7873714d..00000000 --- a/views/admin/manageMembers/adminSearch/searchHeader.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Search Fields pulled from file -
\ No newline at end of file