+<?php
+/**
+ * Plugin Name: Gaslight Media Event Management and Ticketing Add-On
+ * Plugin URI: http://www.gaslightmedia.com/
+ * Description: This add-on provides the ticketing features of the legacy Gaslight Media Event Management system V3.
+ * Version: 0.0.1
+ * Author: Gaslight Media
+ * Author URI: http://www.gaslightmedia.com/
+ * License: GPL2
+ */
+
+/**
+ * Gaslight Media Event Management and Ticketing Add-On
+ * Index
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPluginChild
+ * @package glmMembersEventManagementAddOn
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.0.1
+ */
+
+/*
+ * Plugin and Database Versions
+ *
+ * Note that the database version matches the version of the last
+ * plugin version where there was a change in the database.
+ *
+ * Updates to checkDatabase() in glmPluginSupport.php must be
+ * made together with the DB_VERSION below. ONLY bump the DB
+ * version when there's a change in the database!! Use the
+ * version nunmber of that release for the DB version.
+ *
+ * We check the plugin version stored in the WordPress option below
+ * so that we're sure the other add-ons see an up to date
+ * version from this plugin.
+ */
+define('GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_VERSION', '0.0.1');
+define('GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_VERSION', '0.0.1');
+
+// This is the minimum version of the GLM Members DB plugin require for this plugin.
+define('GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0');
+
+// Check if plugin version is not current in WordPress option and if needed updated it
+if (GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_VERSION != get_option('glmMembersEventManagementPluginVersion')) {
+ update_option('glmMembersEventManagementPluginVersion', GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_VERSION);
+}
+
+/*
+ * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+ die("Please do not call this code directly!");
+}
+
+/*
+* Some initial setup and tests
+*/
+
+$startupNotices = '';
+
+// Get standard defined parameters
+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
+ */
+
+// Check if database version should be defined and it isn't - This would be a plugin/add-on setup issue
+if (is_file(GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_PATH.'/setup/databaseScripts/dbVersions.php') && !defined('GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_VERSION')) {
+ die('You have database scripts but have not defined a current database version at the top of index.php for this plugin/add-on!');
+}
+
+/*
+ * Check installation, activation, and version of main Member DB plugin
+ */
+
+// Check for main plugin and that it's active
+function glmMembersEventManagementPluginRequired() {
+ echo '
+ <div class="error">
+ <p>The '.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!</p>
+ <p>The '.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+$plugin_name = 'glm-member-db/index.php';
+$is_active = is_plugin_active($plugin_name);
+if ($is_active != '1') {
+ add_action( 'admin_notices', 'glmMembersEventManagementPluginRequired' );
+ deactivate_plugins('/'.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG.'/index.php');
+}
+
+// Check for Minimum DB version for main Member DB
+function glmMembersEventManagementMinVerRequired() {
+ echo '
+ <div class="error">
+ <p>The '.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than '
+ .GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!<br>
+ '.GLM_MEMBERS_EVENTMANAGEMENT_MIN_VERSION_NOTE.'</p>
+ <p>The '.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
+if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) {
+ define('GLM_MEMBERS_EVENTMANAGEMENT_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, Ticketing Requires: ".GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION);
+ add_action( 'admin_notices', 'glmMembersEventManagementMinVerRequired');
+ deactivate_plugins('/'.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG.'/'.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG.'.php');
+}
+
+/*
+ * Register this add-on with the main GLM Member DB plugin and get information on all add-ons loaded.
+ */
+require_once GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SETUP_PATH.'/validActions.php';
+require_once GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SETUP_PATH.'/shortcodes.php';
+if (is_file(GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) {
+ require_once GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_SCRIPTS.'/dbVersions.php';
+}
+
+// Load Add-On Management Settings data
+/* None - Need to figure out a smooth way to do this.
+$glmMembersEventManagementManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
+unset($glmMembersEventManagementManagementSettings['id']);
+*/
+
+function glmMembersEventManagementRegisterAddOn($addOns) {
+
+ // Add this add-on to the add-ons array
+ $addOns[GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG] = array(
+ 'dir' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_PATH,
+ 'name' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_NAME,
+ 'short_name' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SHORT_NAME,
+ 'slug' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG,
+ 'actions' => $GLOBALS['glmMembersEventManagementAddOnValidActions'],
+ 'config' => array(
+ ),
+ 'shortcodes' => $GLOBALS['glmMembersEventManagementShortcodes'],
+ 'shortcodesDescription' => $GLOBALS['glmMembersEventManagementShortcodesDescription']
+ );
+
+ // If we have database tables for this plugin/addon, provide that data also
+ if (isset($GLOBALS['glmMembersEventManagementDbVersions'])) {
+ $addOns[GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG]['database'] = array(
+ 'dbPrefix' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_PREFIX,
+ 'dbCurrentVersion' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_VERSION,
+ 'dbActiveVersionOption' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_ACTIVE_DB_OPTION,
+ 'dbScriptPath' => GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_DB_SCRIPTS,
+ 'dbVersions' => $GLOBALS['glmMembersEventManagementDbVersions']
+ );
+ } else {
+ $addOns[GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG]['database'] = false;
+ }
+
+ // Return the array with our data added
+ return $addOns;
+}
+add_filter('glm-member-db-register-addon','glmMembersEventManagementRegisterAddOn', 10, 1);
+
+/*
+ * Plugin Update Support - uses Gaslight Media update server
+ */
+/* Not functional yet - Need to resolve JavaScript conflicts with this feature in other plugins
+require GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php';
+${GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker(
+ 'http://www.gaslightmedia.com/update_server/?action=get_metadata&slug='.GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG,
+ __FILE__,
+ GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SLUG
+);
+
+${GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array(
+ 'license_key' => __('License Key:')
+));
+*/
+
+/*
+ *
+ * Activate and Deactivate hooks
+ *
+ */
+
+ // Activate
+ function glmMembersEventManagementPluginActivate ()
+ {
+ global $wpdb, $config;
+ require_once GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_PATH . '/activate.php';
+ new glmMembersEventManagementPluginActivate($wpdb, $config);
+ }
+ register_activation_hook(__FILE__, 'glmMembersEventManagementPluginActivate');
+
+ // Deactivate
+ function glmMembersEventManagementPluginDeactivate ()
+ {
+ global $wpdb, $config;
+ require_once GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_PATH . '/deactivate.php';
+ $x = new glmMembersEventManagementPluginDeactivate($wpdb, $config);
+ return false;
+ }
+ register_deactivation_hook(__FILE__, 'glmMembersEventManagementPluginDeactivate');
+
+/*
+ * Hooks for testing capabilities provided by this add-on
+ */
+require_once GLM_MEMBERS_EVENTMANAGEMENT_PLUGIN_SETUP_PATH.'/permissions.php';
+