+<?php
+/**
+ * Plugin Name: GLM Associate Itinerary
+ * Plugin URI: http://www.gaslightmedia.com/
+ * Description: Trip Planner
+ * Version: 0.0.1
+ * Author: Gaslight Media
+ * Author URI: http://www.gaslightmedia.com/
+ * License: GPL2
+ */
+
+/**
+ * GLM Associate Itinerary
+ * Index
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPluginChild
+ * @package glmMembersItineraryAddOn
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.0.1
+ */
+
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+ header("Location: http://".$_SERVER['SERVER_NAME']."/error/404.html");
+ die();
+}
+
+/*
+ * 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_ITINERARY_PLUGIN_VERSION', '0.0.1');
+define('GLM_MEMBERS_ITINERARY_PLUGIN_DB_VERSION', '0.0.1');
+
+// This is the minimum version of the GLM Members DB plugin require for this plugin.
+define('GLM_MEMBERS_ITINERARY_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_ITINERARY_PLUGIN_VERSION != get_option('glmMembersItineraryPluginVersion')) {
+ update_option('glmMembersItineraryPluginVersion', GLM_MEMBERS_ITINERARY_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
+ */
+
+/*
+* 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_ITINERARY_PLUGIN_PATH.'/setup/databaseScripts/dbVersions.php') && !defined('GLM_MEMBERS_ITINERARY_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 glmMembersItineraryPluginRequired() {
+ echo '
+ <div class="error">
+ <p>The '.GLM_MEMBERS_ITINERARY_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!</p>
+ <p>The '.GLM_MEMBERS_ITINERARY_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', 'glmMembersItineraryPluginRequired' );
+ deactivate_plugins('/'.GLM_MEMBERS_ITINERARY_PLUGIN_SLUG.'/index.php');
+}
+
+// Check for Minimum DB version for main Member DB
+function glmMembersItineraryMinVerRequired() {
+ echo '
+ <div class="error">
+ <p>The '.GLM_MEMBERS_ITINERARY_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than '
+ .GLM_MEMBERS_ITINERARY_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!<br>
+ '.GLM_MEMBERS_ITINERARY_MIN_VERSION_NOTE.'</p>
+ <p>The '.GLM_MEMBERS_ITINERARY_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
+if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_ITINERARY_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) {
+ define('GLM_MEMBERS_ITINERARY_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, Itinerary Requires: ".GLM_MEMBERS_ITINERARY_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION);
+ add_action( 'admin_notices', 'glmMembersItineraryMinVerRequired');
+ deactivate_plugins('/'.GLM_MEMBERS_ITINERARY_PLUGIN_SLUG.'/'.GLM_MEMBERS_ITINERARY_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_ITINERARY_PLUGIN_SETUP_PATH.'/validActions.php';
+require_once GLM_MEMBERS_ITINERARY_PLUGIN_SETUP_PATH.'/shortcodes.php';
+if (is_file(GLM_MEMBERS_ITINERARY_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) {
+ require_once GLM_MEMBERS_ITINERARY_PLUGIN_DB_SCRIPTS.'/dbVersions.php';
+}
+
+/*
+ * Load Add-On Management Settings data
+ *
+ * To have management and settings data from this add-on added to the main plugin config,
+ * uncomment the two sections and fix anything that's need to be corrected.
+ *
+ * Then add the data to the "config" array under "// Add this add-on to the add-ons array" below.
+ */
+
+// Management
+// $glmMembersItineraryManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_ITINERARY_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
+// unset($glmMembersItineraryManagementSettings['id']);
+
+// Settings
+// $glmMembersItinerarySettingsTerms = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_ITINERARY_PLUGIN_DB_PREFIX."settings_terms WHERE id = 1", ARRAY_A );
+// unset($glmMembersItinerarySettingsTerms['id']);
+
+
+
+function glmMembersItineraryRegisterAddOn($addOns) {
+
+ // Add this add-on to the add-ons array
+ $addOns[GLM_MEMBERS_ITINERARY_PLUGIN_SLUG] = array(
+ 'dir' => GLM_MEMBERS_ITINERARY_PLUGIN_PATH,
+ 'name' => GLM_MEMBERS_ITINERARY_PLUGIN_NAME,
+ 'short_name' => GLM_MEMBERS_ITINERARY_PLUGIN_SHORT_NAME,
+ 'slug' => GLM_MEMBERS_ITINERARY_PLUGIN_SLUG,
+ 'actions' => $GLOBALS['glmMembersItineraryAddOnValidActions'],
+ 'config' => array(
+// 'settings' => $GLOBALS['glmMembersItineraryManagementSettings'],
+// 'terms' => $GLOBALS['glmMembersItinerarySettingsTerms']
+ ),
+ 'shortcodes' => $GLOBALS['glmMembersItineraryShortcodes'],
+ 'shortcodesDescription' => $GLOBALS['glmMembersItineraryShortcodesDescription']
+ );
+
+ // If we have database tables for this plugin/addon, provide that data also
+ if (isset($GLOBALS['glmMembersItineraryDbVersions'])) {
+ $addOns[GLM_MEMBERS_ITINERARY_PLUGIN_SLUG]['database'] = array(
+ 'dbPrefix' => GLM_MEMBERS_ITINERARY_PLUGIN_DB_PREFIX,
+ 'dbCurrentVersion' => GLM_MEMBERS_ITINERARY_PLUGIN_DB_VERSION,
+ 'dbActiveVersionOption' => GLM_MEMBERS_ITINERARY_PLUGIN_ACTIVE_DB_OPTION,
+ 'dbScriptPath' => GLM_MEMBERS_ITINERARY_PLUGIN_DB_SCRIPTS,
+ 'dbVersions' => $GLOBALS['glmMembersItineraryDbVersions']
+ );
+ } else {
+ $addOns[GLM_MEMBERS_ITINERARY_PLUGIN_SLUG]['database'] = false;
+ }
+
+ // Return the array with our data added
+ return $addOns;
+}
+add_filter('glm-member-db-register-addon','glmMembersItineraryRegisterAddOn', 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_ITINERARY_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php';
+${GLM_MEMBERS_ITINERARY_PLUGIN_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker(
+ 'http://www.gaslightmedia.com/update_server/?action=get_metadata&slug='.GLM_MEMBERS_ITINERARY_PLUGIN_SLUG,
+ __FILE__,
+ GLM_MEMBERS_ITINERARY_PLUGIN_SLUG
+);
+
+${GLM_MEMBERS_ITINERARY_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array(
+ 'license_key' => __('License Key:')
+));
+*/
+
+/*
+ *
+ * Activate and Deactivate hooks
+ *
+ */
+
+ // Activate
+ function glmMembersItineraryPluginActivate ()
+ {
+ global $wpdb, $config;
+ require_once GLM_MEMBERS_ITINERARY_PLUGIN_PATH . '/activate.php';
+ new glmMembersItineraryPluginActivate($wpdb, $config);
+ }
+ register_activation_hook(__FILE__, 'glmMembersItineraryPluginActivate');
+
+ // Deactivate
+ function glmMembersItineraryPluginDeactivate ()
+ {
+ global $wpdb, $config;
+ require_once GLM_MEMBERS_ITINERARY_PLUGIN_PATH . '/deactivate.php';
+ $x = new glmMembersItineraryPluginDeactivate($wpdb, $config);
+ return false;
+ }
+ register_deactivation_hook(__FILE__, 'glmMembersItineraryPluginDeactivate');
+
+/*
+ * Hooks for testing capabilities provided by this add-on
+ */
+require_once GLM_MEMBERS_ITINERARY_PLUGIN_SETUP_PATH.'/permissions.php';
+