Additional user interface cleanup
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 13 Jun 2016 17:37:08 +0000 (13:37 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 13 Jun 2016 17:44:26 +0000 (13:44 -0400)
index.php
models/admin/dashboard/index.php [new file with mode: 0644]
models/admin/events/index.php
models/admin/management/events.php
setup/adminHooks.php

index a5c4e0f..5abe407 100644 (file)
--- a/index.php
+++ b/index.php
@@ -84,6 +84,9 @@ require_once('defines.php');
 // Required to be able to get user capabilities when being called as a filter from the main plugin
 require_once(ABSPATH . 'wp-includes/pluggable.php');
 
+// Include defines to tell if a plugin is active
+include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+
 /*
  * Do some preliminary sanity checks
  */
@@ -93,7 +96,11 @@ if (is_file(GLM_MEMBERS_EVENTS_PLUGIN_PATH.'/setup/databaseScripts/dbVersions.ph
     die('You have database scripts but have not defined a current database version at the top of index.php for this plugin/add-on!');
 }
 
-// Function to generate message regarding main GLM Member DB plugin not installed and active
+/*
+ * Check installation, activation, and version of main Member DB plugin
+ */
+
+// Check for main plugin and that it's active
 function glmMembersEventsPluginRequired() {
     echo '
         <div class="error">
@@ -102,21 +109,14 @@ function glmMembersEventsPluginRequired() {
         </div>
     ';
 }
-
-/*
- * Check installation, activation, and version of main Member DB plugin
- */
-include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
 $plugin_name = 'glm-member-db/index.php';
 $is_active = is_plugin_active($plugin_name);
-
-// If it's not active, then warn user and deactivate this add-on plugin
 if ($is_active != '1') {
     add_action( 'admin_notices', 'glmMembersEventsPluginRequired' );
     deactivate_plugins('/'.GLM_MEMBERS_EVENTS_PLUGIN_SLUG.'/'.GLM_MEMBERS_EVENTS_PLUGIN_SLUG.'.php');
 }
 
-// Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on
+// Check for Minimum DB version for main Member DB
 function glmMembersPluginEventsMinVerRequired() {
     echo '
         <div class="error">
@@ -127,10 +127,6 @@ function glmMembersPluginEventsMinVerRequired() {
         </div>
     ';
 }
-
-/*
- * Check for Minimum DB version for main Member DB
- */
 $glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
 if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_EVENTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) {
     define('GLM_MEMBERS_EVENTS_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, Events Requires: ".GLM_MEMBERS_EVENTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION);
diff --git a/models/admin/dashboard/index.php b/models/admin/dashboard/index.php
new file mode 100644 (file)
index 0000000..e151af3
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Events Dashboard
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Events data abstract
+require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php');
+
+class GlmMembersAdmin_events_index extends GlmDataEvents
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Event ID
+     *
+     * @var $eventID
+     * @access public
+     */
+    public $eventID = false;
+
+    /**
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * '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.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        /*
+         * Run constructor for the Events data class
+         *
+         * Note, the third parameter is a flag that indicates to the Contacts
+         * data class that it should flag a group of fields as 'view_only'.
+         */
+        parent::__construct(false, false, true);
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+
+        $memberID = false;
+        $lockedToMember = false;
+        $lockedWhereT = 'true';
+        $lockedWhere = 'true';
+        $numbEvents = 0;
+        $numbPending = 0;
+        $namesList = false;
+        $haveCategories = false;
+
+        // 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);
+        if ($lockedToMember) {
+            $memberID = $lockedToMember;
+            $lockedToMember = $memberID;
+            $lockedWhereT = 'T.ref_type = '.$this->config['ref_type_numb']['Member'].' AND T.ref_dest = '.$memberID;
+            $lockedWhere = 'ref_type = '.$this->config['ref_type_numb']['Member'].' AND ref_dest = '.$memberID;
+        }
+
+        // Check for required Event Categories
+        require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+        $EventCategories = new GlmDataEventsCategories($this->wpdb, $this->config);
+        $eventCategoriesStats = $EventCategories->getStats();
+        if ($eventCategoriesStats && $eventCategoriesStats > 0) {
+            $haveCategories = true;
+        }
+
+        // Get full list of names matching this where clause for search box
+        $namesList = $this->getIdName($lockedWhereT);
+
+        // Get number of events
+        $numbEvents = $this->getStats($lockedWhere);
+
+        // I know this is awkward, but we if there's anything that follows these we need " AND " appended.
+        if ($lockedWhereT != '') {
+            $lockedWhereT .= ' AND ';
+        }
+        if ($lockedWhere != '') {
+            $lockedWhere .= ' AND ';
+        }
+
+        // Get number of events pending
+        $numbPending = $this->getStats($lockedWhere.' status = '.$this->config['status_numb']['Pending']);
+
+        // Get list of Pending Events
+        $pending = $this->getIdName($lockedWhereT.' T.status = '.$this->config['status_numb']['Pending']);
+
+
+        // Compile template data
+        $templateData = array(
+            'lockedToMember' => $lockedToMember,
+            'numbEvents' => $numbEvents,
+            'pending' => $pending,
+            'namesList' => $namesList,
+            'numbPending' => $numbPending,
+            'haveCategories' => $haveCategories
+        );
+             // Return status, any suggested view, and any data to controller
+        return array(
+                'status' => true,
+                'modelRedirect' => false,
+                'view' => 'admin/events/index.html',
+                'data' => $templateData
+        );
+
+    }
+
+
+}
index fb9ac4b..e151af3 100644 (file)
@@ -13,7 +13,7 @@
  * @link     http://dev.gaslightmedia.com/
  */
 
-// Load Contacts data abstract
+// Load Events data abstract
 require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php');
 
 class GlmMembersAdmin_events_index extends GlmDataEvents
index 89a73b2..40fc536 100644 (file)
@@ -19,7 +19,7 @@ require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php');
 require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php');
 
 /**
- * GlmMembersAdmin_management_packaging
+ * GlmMembersAdmin_management_events
  *
  * PHP version 5
  *
@@ -238,7 +238,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                 break;
 
             case 'eventFilesImport':
-    
+
 
                 break;
 
@@ -847,8 +847,6 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                         '%d',
                     );
                 }
-                
-                echo '<pre>$eventData: ' . print_r($event_data, true) . '</pre>';
                 echo '</pre>';
                 $this->wpdb->insert(
                     GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
@@ -1082,10 +1080,10 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                } else {
                        $this->oldCatMap = $this->getOldCatMap();
                }
-        
-        $yearly_events = 
+
+        $yearly_events =
         $daily_events =
-        $weekly_events = 
+        $weekly_events =
         $interval_events =
         $monthly_events =
         $custom_date_events = 0;
@@ -1095,11 +1093,11 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
         $image_upload = new GlmMembersAdmin_ajax_imageUpload($this->wpdb, $this->config);
 
         $sql = "
-        SELECT * 
+        SELECT *
           FROM " . $this->wpdb->prefix . "posts
          WHERE post_type = 'ai1ec_event'
            AND post_status = 'publish'";
-               //$sql .= " AND ID IN ( SELECT post_id FROM " . $this->wpdb->prefix . "ai1ec_events 
+               //$sql .= " AND ID IN ( SELECT post_id FROM " . $this->wpdb->prefix . "ai1ec_events
                        //WHERE end >= " . time() . " )";
                $sql .= " LIMIT $limit OFFSET $start";
         $results = $this->wpdb->get_results( $sql, ARRAY_A );
@@ -1112,7 +1110,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                                ++$event_counter;
                 //echo '<pre>$post: ' . print_r($post, true) . '</pre>';
                 $sql        = "
-                SELECT * 
+                SELECT *
                   FROM " . $this->wpdb->prefix . "ai1ec_events
                  WHERE post_id = {$post['ID']}";
                 $event_data = $this->wpdb->get_row( $sql, ARRAY_A );
@@ -1121,7 +1119,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                 $cost       = $cost_data['cost'];
                 $is_free    = $cost_data['is_free'];
 
-                // use the posts table data 
+                // use the posts table data
                 $image = '';
                 if ( has_post_thumbnail( $post['ID'] ) ) {
                     $thumbnail_id = get_post_thumbnail_id( $post['ID'] );
@@ -1159,7 +1157,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                     'contact_email'          => $event_data['contact_email'],
                     'contact_name'           => $event_data['contact_name'],
                     'contact_phone'          => $event_data['contact_phone'],
-                    'notes'                  => null, 
+                    'notes'                  => null,
                     'hide_address'           => null,
                     'use_member_location'    => 0,
                 );
@@ -1240,7 +1238,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                 $start_time_only =
                 $recurring_event  = 0;
 
-                $weekly = 
+                $weekly =
                 $daily  = false;
 
                 $day_of_week   = 127;
@@ -1319,7 +1317,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                                         }
                                         $serialized_custom_times = serialize($interval_dates);
                                     }
-                                    
+
                                     break;
                                 case "YEARLY":
                                     $yearly_events++;
@@ -1385,10 +1383,10 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                             }
                         } else if ( preg_match( ';UNTIL=(.*);', $rule, $matches ) ) {
                             $to_date = date( 'Y-m-d', strtotime( $matches[1] ) );
-                            
+
                         } else if ( preg_match( ';BYMONTH=(.*);', $rule, $matches ) ) {
 //                            $monthly = $recurrence_rules[1];
-//                            
+//
 //                            $selected_from_date = substr($from_date, -2);
 //                            $selected_from_date--;
 //                            $selected_to_date = substr($to_date, -2);
@@ -1402,9 +1400,9 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
 //                                $day_sum += $day;
 //                            }
 //                           $day_of_month = pow(2,$selected_from_date ) + pow(2,$selected_to_date);
-  
+
                         }else if ( preg_match( ';BYday=(.*);', $rule, $matches ) ) {
-                            
+
                                                        if ( $debug ) {
                                                                echo '<pre>1354 $matches: ' . print_r($matches, true) . '</pre>';
                                                        }
@@ -1412,7 +1410,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                             if(strpos($matches[1], ",") == false){
                                 $week_number = substr($matches[1],0, 1);
                                 $week_number = $week_number - 1;
-                                $week_of_month = pow(2, $week_number); 
+                                $week_of_month = pow(2, $week_number);
                                 $days[] = substr($matches[1], -2);
                                 $by_day_of_month = 0;
                             } else {
@@ -1445,7 +1443,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                                 }
                             }
                         }
-                    }           
+                    }
                     if(!empty($custom_times)){
                         date_default_timezone_set('UTC');
                         $serialized_custom_times = serialize($custom_times);
@@ -1567,9 +1565,9 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                        Start: $start
                </pre>";
                $start += $limit;
-               $return_string .= "<p><a href=\"" 
-                       . GLM_MEMBERS_PLUGIN_CURRENT_URL 
-                       . "?page=glm-members-admin-menu-management&glm_action=events&option=timelyImport&import=true" 
+               $return_string .= "<p><a href=\""
+                       . GLM_MEMBERS_PLUGIN_CURRENT_URL
+                       . "?page=glm-members-admin-menu-management&glm_action=events&option=timelyImport&import=true"
                        . "&start=$start\">Next</a></p>";
                return $return_string;
     }
index 6e7ad8e..8956b48 100644 (file)
  *
  *  Also note that parameters will be in the context of the main admin controller constructor.
   */
+
+// Add events notices to main dashboard widget
+ add_filter( 'glm-member-db-dashboard-widget-notices', function( $parameter ) {
+
+
+
+ });