Cleaned up the widgetDashboard model
authorLaury GvR <laury@gaslightmedia.com>
Thu, 25 Oct 2018 18:02:27 +0000 (14:02 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 25 Oct 2018 18:02:27 +0000 (14:02 -0400)
models/admin/newDashboard/index.php

index c2b4d2b..512f3af 100644 (file)
@@ -97,16 +97,7 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
      */
     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(
@@ -132,73 +123,12 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
         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_CLASS_PATH . '/data/dataMemberInfo.php';
+
         // 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'));
-
-        // $clickThroughCounts = $this->wpdb->get_row("
-        //     SELECT COALESCE ((
-        //                 SELECT clicks
-        //                   FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats
-        //                  WHERE member = $memberID
-        //                    AND stat_type = 1
-        //                    AND stat_date = '$today'
-        //            ), 0) AS day,
-        //            COALESCE ((
-        //                 SELECT clicks
-        //                   FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats
-        //                  WHERE member = $memberID
-        //                    AND stat_type = 2
-        //                    AND stat_date = '$thisWeek'
-        //            ), 0) AS week,
-        //            COALESCE ((
-        //                 SELECT clicks
-        //                   FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats
-        //                  WHERE member = $memberID
-        //                    AND stat_type = 3
-        //                    AND stat_date = '$thisMonth'
-        //            ), 0) AS month
-        // ", ARRAY_A);
-
-        // $detailViewCounts = $this->wpdb->get_row("
-        //     SELECT COALESCE ((
-        //                 SELECT clicks
-        //                   FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats
-        //                  WHERE member = $memberID
-        //                    AND stat_type = 1
-        //                    AND stat_date = '$today'
-        //            ), 0) AS day,
-        //            COALESCE ((
-        //                 SELECT clicks
-        //                   FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats
-        //                  WHERE member = $memberID
-        //                    AND stat_type = 2
-        //                    AND stat_date = '$thisWeek'
-        //            ), 0) AS week,
-        //            COALESCE ((
-        //                 SELECT clicks
-        //                   FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats
-        //                  WHERE member = $memberID
-        //                    AND stat_type = 3
-        //                    AND stat_date = '$thisMonth'
-        //            ), 0) AS month
-        // ", ARRAY_A);
-
-        // Setup the data Abstract class for member info.
-        require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
-        $MemberInfo        = new GlmDataMemberInfo($this->wpdb, $this->config);
-        $hideArchived      = " && T.status != ".$this->config['status_numb']['Archived'];
-
-        // Check if there's any member information records.
-        if (is_array($memberInfoRecords) && count($memberInfoRecords) > 0) {
-            $haveInfoRecords = true;
-        }
-
         // 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 ) {
@@ -215,14 +145,7 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
         $templateData = array(
             'lockedToMember'        => $lockedToMember,
             'member'                => $actionData,
-            'showArchived'          => $showArchived,
-            'statusTypeNumbers'     => $this->config['status_numb'],
             'memberID'              => $memberID,
-            'haveInfoRecords'       => $haveInfoRecords,
-            'memberInfoRecords'     => $memberInfoRecords,
-            'clickThroughCounts'    => $clickThroughCounts,
-            'detailViewCounts'      => $detailViewCounts,
-            'statusPending'         => $this->config['status_numb']['Pending'],
             'addons'                => $addons,
             'baseUrl'               => GLM_MEMBERS_PLUGIN_URL 
         );
@@ -240,50 +163,4 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
 
     public function orderSort ($a, $b) { return (strcmp ($a['order'],$b['order']));    }
 
-    public function queryWidgetLists( &$widgetData = false ) {
-        
-        // foreach ( $widgetData['components'] as &$widgetComponent ) {
-            // $where = " TRUE ";
-            // $order = "";
-            // $limit = "5";
-            // if ( isset($widgetComponent['where']) && $widgetComponent['where'] !== "" ) {
-            //     $where .= " AND " . $widgetComponent['where'];
-            // }
-            // if ( isset($widgetComponent['orderBy']) && $widgetComponent['orderBy'] !== "" ) {
-            //     $order .= " ORDER BY " . $widgetComponent['orderBy'];
-            // }
-            // echo "<br>Result:" . var_dump( $widgetComponent['result'] );
-
-            // if ( $widgetComponent['template'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) {
-                // $table = $widgetComponent['table'];
-                // $fields = $widgetComponent['fields'];
-                // $resultsQuery = "SELECT " . $fields . " FROM " . $table . " WHERE" .  $where . $order . " LIMIT " . $limit . ";";
-                // //echo "<br>" .$resultsQuery;
-                // $widgetComponent['sql'] = $resultsQuery;
-                // $widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery);
-
-                // if ( isset($widgetComponent['listItems']) ) {
-                //     foreach ( $widgetComponent['listItems'] as &$listItem ) {
-                //         if ( isset($listItem->ref_type) ) {
-                //             // Get the ref type from the config array - has to be forced lowercase due to inconsistency 
-                //             // in url vs config array reference to ref_type (e.g. member vs Member, and member vs members)
-                //             $listItem->ref_type = strtolower($this->config['ref_type'][$listItem->ref_type]);
-                //         }
-                //     }
-                // }
-                // $countQuery = "SELECT COUNT(" . $widgetComponent['entityID'] . ") FROM " . $widgetComponent['table'] . " WHERE " . $where . ";";
-                // $widgetComponent['count'] = $this->wpdb->get_var($countQuery);
-
-            // } 
-            // if ( isset($widgetComponent['table']) && ($widgetComponent['template'] == 'list' || $widgetComponent['template'] == 'entityAmount') ) {
-                //$table = $widgetComponent['table'];
-                //$countQuery = "SELECT COUNT(id) FROM " . $widgetComponent['table'] . " WHERE " . $where . ";";
-                //echo "<br>" .$countQuery;
-                //$widgetComponent['count'] = $this->wpdb->get_var($countQuery);
-                //echo "<pre>" . var_dump($widgetComponent['count']) . "</pre>";
-            // }
-        // }
-        return $widgetData;
-    }
-
 }