Valid actions and basic admin files added/renamed
authorLaury GvR <laury@gaslightmedia.com>
Fri, 9 Nov 2018 17:24:46 +0000 (12:24 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Fri, 9 Nov 2018 17:24:46 +0000 (12:24 -0500)
controllers/admin.php
models/admin/manageDashboard/members.php [new file with mode: 0644]
models/admin/manageDashboard/search.php [new file with mode: 0644]
models/admin/manageMembers/index.php [deleted file]
models/admin/manageMembers/search.php [deleted file]
setup/adminMenus.php
setup/validActions.php
views/admin/common/manageDashboard/index.html
views/admin/manageDashboard/adminSearch/searchHeader.html [new file with mode: 0644]
views/admin/manageMembers/adminSearch/searchHeader.html [deleted file]

index 7e5bfc2..a1ea526 100755 (executable)
@@ -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 . "+++<br>";
+            echo "plugin: " . var_dump($plugIn) . "+++<br>";
+            echo "action: " . $action . "+++<br><br>";
             $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/admin/$menuItem/$action.php";
             $className = 'GlmMembersAdmin_' . $menuItem . '_' . $action;
             $loopTracking .= "<p>Loop: $loopCheck<br>Model: $modelName<br>Class: $className</p>";
diff --git a/models/admin/manageDashboard/members.php b/models/admin/manageDashboard/members.php
new file mode 100644 (file)
index 0000000..2a811fa
--- /dev/null
@@ -0,0 +1,442 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin List Members
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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 '<pre>$where: ' . print_r( $where, true ) . '</pre>';
+
+        // 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('\\"', '&quot;', $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 (file)
index 0000000..4b14df1
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+
+
+    // 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;
+
+
+    /*
+    * 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 <li> 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 (file)
index f0046e2..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-<?php
-
-/**
- * Gaslight Media Members Database
- * Admin List Members
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @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 '<pre>$where: ' . print_r( $where, true ) . '</pre>';
-
-        // 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('\\"', '&quot;', $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 (file)
index 4b14df1..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-
-
-    // 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;
-
-
-    /*
-    * 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 <li> 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',
-            ],
-        ]
-    ];
index 7c75ac9..8079beb 100644 (file)
@@ -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
index a9af967..537214f 100644 (file)
@@ -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',
index 4aaaa75..707c1cf 100644 (file)
@@ -1,6 +1,6 @@
 
 <div id="glm-manage-dashboard">
-    {include file='admin/manageMembers/adminSearch/searchHeader.html'}
+    {include file='admin/manageDashboard/adminSearch/searchHeader.html'}
     <div id="glm-manage-dashboard-searchForm" class="row">
         {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 (file)
index 0000000..7873714
--- /dev/null
@@ -0,0 +1,3 @@
+<div id="glm-admin-search-header">
+    Search Fields pulled from file
+</div>
\ 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 (file)
index 7873714..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<div id="glm-admin-search-header">
-    Search Fields pulled from file
-</div>
\ No newline at end of file