// 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
*/
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">
</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">
</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);
--- /dev/null
+<?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
+ );
+
+ }
+
+
+}
* @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
require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php');
/**
- * GlmMembersAdmin_management_packaging
+ * GlmMembersAdmin_management_events
*
* PHP version 5
*
break;
case 'eventFilesImport':
-
+
break;
'%d',
);
}
-
- echo '<pre>$eventData: ' . print_r($event_data, true) . '</pre>';
echo '</pre>';
$this->wpdb->insert(
GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
} else {
$this->oldCatMap = $this->getOldCatMap();
}
-
- $yearly_events =
+
+ $yearly_events =
$daily_events =
- $weekly_events =
+ $weekly_events =
$interval_events =
$monthly_events =
$custom_date_events = 0;
$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 );
++$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 );
$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'] );
'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,
);
$start_time_only =
$recurring_event = 0;
- $weekly =
+ $weekly =
$daily = false;
$day_of_week = 127;
}
$serialized_custom_times = serialize($interval_dates);
}
-
+
break;
case "YEARLY":
$yearly_events++;
}
} 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);
// $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>';
}
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 {
}
}
}
- }
+ }
if(!empty($custom_times)){
date_default_timezone_set('UTC');
$serialized_custom_times = serialize($custom_times);
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;
}
*
* 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 ) {
+
+
+
+ });