--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database Contacts Child Plugin
+ * Activate Plugin Tasks
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabaseContacts
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release activate.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+ die("Please do not call this code directly!");
+}
+
+/*
+ * This class performs all necessary additional work when this
+ * plugin is activated.
+ *
+ * Currently the only actions are to add role capability to display and modify
+ * prototypes.
+ */
+class glmMembersContactsPluginActivate
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * Note that the $noDatabaseCheck is used to access the database versions
+ * without triggering a database check.
+ *
+ * Performs all the work for this model
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Make sure the current user has this capability
+ if (! current_user_can('activate_plugins')) {
+ $this->addNotice("Interesting, you don't have permission to activate plugins.");
+ die();
+ }
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Set current plugin version
+ update_option('glmMembersDatabaseContactsPluginVersion', GLM_MEMBERS_CONTACTS_PLUGIN_VERSION);
+
+ /*
+ * Add contacts roles
+ *
+ * Note that the members_manager capability is created by the main Member DB plugin
+ */
+
+ // Members Manager - Full control of all members and their data
+ add_role(
+ 'glm_members_manager',
+ 'GLM Members Manager',
+ array(
+ 'read' => true,
+ 'glm_members_management' => true
+ )
+ );
+
+ // Own Member Manager - Full control of own member, location, facility (based on with which the contact is assocated)
+ add_role(
+ 'glm_own_member_manager',
+ 'GLM Own Member Manager',
+ array(
+ 'read' => true,
+ 'glm_members_management' => true // but only allowed to manage their entity type (member, location, facility, ...)
+ )
+ );
+
+ // Member Contact - Standard contact for own member, location, facility, ... - no edit of member data
+ add_role(
+ 'glm_member_contact',
+ 'GLM Member Contact',
+ array(
+ 'read' => true
+ )
+ );
+
+ // Restricted Member Contact - No login capability
+ add_role(
+ 'glm_member_restricted_contact',
+ 'GLM Member Restricted Contact',
+ array(
+ 'read' => true
+ )
+ );
+
+ /*
+ * Add contacts capabilities
+ *
+ * Note that the glm_members_management capability is created by the main Member DB plugin
+ */
+
+ // May log in through members only area
+ $this->addRoleCapability(
+ 'glm_members_login',
+ array(
+ 'administrator' => true,
+ 'glm_members_manager' => true,
+ 'glm_own_member_manager' => true,
+ 'glm_member_contact' => true,
+ 'glm_member_restricted_contact' => false
+ )
+ );
+
+ }
+
+ /*
+ * Add a role capability to all current roles
+ *
+ * @param string $capability Name of capability to add
+ * @param array $default Whether capability should be on by default
+ * array(
+ * 'author' => false,
+ * 'contributor' => false,
+ * 'editor' => false,
+ * 'subscriber' => false
+ * )
+ *
+ * @return void
+ * @access private
+ */
+ private function addRoleCapability ($capability, $default)
+ {
+ // Get list of role objects
+ $roleObjects = $GLOBALS['wp_roles']->role_objects;
+
+ // Get list of roles we can edit
+ $roles = get_editable_roles();
+
+ // For each role object
+ foreach ($roleObjects as $key => $role) {
+
+ // Uncomment to reset capabilities
+ /*
+ if ( isset($role->capabilities[$capability])) {
+ $role->remove_cap($capability);
+ }
+ */
+
+ // Check if the role exists in list of editable roles and
+ // the capability does not exist
+ if (isset($roles[$key]) && ! isset($role->capabilities[$capability])) {
+
+ // Check if a default value has been specified in the $default array
+ $enabled = false;
+ if (isset($default[$role->name])) {
+
+ // It has, so use that
+ $enabled = $default[$role->name];
+
+ }
+
+ // Add the role
+ $role->add_cap($capability, $enabled);
+
+ }
+ }
+ }
+
+}
+
+
+/*
+// May be used to delete a capability from all roles
+add_action( 'admin_init', 'glmMembersDeleteCapabilities' );
+function glmMembersDeleteCapabilities(){
+
+ // Put capabilities to delete here
+ $delete_caps = array(
+ 'glm_members_contact_manage_members'
+ );
+
+ global $wp_roles;
+ foreach ($delete_caps as $cap) {
+ foreach (array_keys($wp_roles->roles) as $role) {
+ $wp_roles->remove_cap($role, $cap);
+ }
+ }
+}
+*/
+
+?>
--- /dev/null
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Contacts data class
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package GLM Member-DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataContacts.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataContacts class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package EventManagement
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ * Exp $
+ */
+class GlmDataContacts extends GlmDataAbstract {
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Field definitions
+ *
+ * @var $ini
+ * @access public
+ */
+ public $table;
+
+ /**
+ * Field definitions
+ *
+ * 'type' is type of field as defined by the application
+ * text Regular text field
+ * pointer Pointer to an entry in another table
+ * 'filters' is the filter name for a particular filter ID in PHP filter
+ * functions
+ * See PHP filter_id()
+ *
+ * 'use' is when to use the field
+ * l = List
+ * g = Get
+ * n = New
+ * i = Insert
+ * e = Edit
+ * u = Update
+ * d = Delete
+ * a = All
+ *
+ * @var $ini
+ * @access public
+ */
+ public $fields = false;
+
+ /**
+ * Constructor
+ *
+ * @param object $d
+ * database connection
+ *
+ * @return void
+ * @access public
+ */
+ function __construct($wpdb, $config)
+ {
+
+ // If this class is not being extended along with existing $wpdb and $config
+ if (!$this->wpdb) {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+ }
+
+ /*
+ * Table Name
+ */
+ $this->table = GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'contacts';
+
+ /*
+ * Table Data Fields
+ */
+
+/************* NOT UPDATED YET ******************/
+ $this->fields = array (
+
+ 'id' => array (
+ 'field' => 'id',
+ 'type' => 'integer',
+ 'view_only' => true,
+ 'use' => 'a'
+ ),
+
+ // Status
+ 'access' => array (
+ 'field' => 'access',
+ 'type' => 'list',
+ 'list' => $this->config['memb_access'],
+ 'l_blank' => true,
+ 'required' => true,
+ 'default' => 30,
+ 'force_list' => true,
+ 'use' => 'a'
+ ),
+
+ // Member Type
+ 'member_type' => array (
+ 'field' => 'member_type',
+ 'type' => 'pointer',
+ 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_type',
+ 'p_field' => 'name',
+ 'p_orderby' => 'name',
+ 'p_blank' => true,
+ 'required' => true,
+ 'force_list' => true,
+ 'use' => 'a'
+ ),
+
+ // Member Name
+ 'name' => array (
+ 'field' => 'name',
+ 'type' => 'text',
+ 'required' => true,
+ 'unique' => true,
+ 'use' => 'a'
+ ),
+
+ // Member Name (stored by member updates) for sorting
+ 'member_slug' => array(
+ 'field' => 'member_slug',
+ 'type' => 'text',
+ 'required' => true,
+ 'use' => 'a'
+ ),
+
+ // Date created
+ 'created' => array (
+ 'field' => 'created',
+ 'type' => 'date',
+ 'required' => true,
+ 'use' => 'a'
+ ),
+
+ // Active Version
+ 'active_id' => array (
+ 'field' => 'id',
+ 'as' => 'active_id',
+ 'type' => 'pointer',
+ 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info',
+ 'p_field' => 'id',
+ 'p_id' => 'member',
+ 'p_where' => 'status = '.$this->config['status_numb']['Active'],
+ 'p_static' => true,
+ 'use' => 'gl'
+ )
+
+ );
+
+/* - not updated for add-on yet
+ if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table);
+ }
+*/
+
+ }
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database Contacts Child Plugin
+ *
+ * Get plugin configuration
+ *
+ * Note that most of the configuration data comes from the main GLM Member DB plugin
+ * and will be passed back when registering this add-on.
+ */
+
+// Get plugin configuration
+$configData = parse_ini_file(GLM_MEMBERS_CONTACTS_PLUGIN_PATH.'/config/plugin.ini', true);
+$config = $configData['common'];
+
+// Check for config value replacements in the current theme
+$currentThemeDirectory = get_template_directory();
+if (file_exists($currentThemeDirectory.'/glm-member-db-contacts/plugin.ini')) {
+
+ // Read in the ini file from the theme
+ $themeIni = parse_ini_file($currentThemeDirectory.'/glm-member-db-contacts/plugin.ini');
+
+ // Replace parameters that are in the theme ini file
+ $config = array_replace($config, $themeIni);
+
+}
+
+?>
--- /dev/null
+;
+; Main Configuration File
+; Gaslight Media Members Database Contacts Child Plugin
+;
+
+[common]
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Contacts Add-On Admin Controller
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+/**
+ * Array of valid menu items and actions.
+ *
+ * These are the valid menu items and actions that are passed to the main
+ * GLM Members DB plugin, along with other information about this add-on,
+ * using the glm-member-db-register-addon hook.
+ */
+$glmMembersContactsValidActions = array(
+ 'admin' => array(
+ 'member' => array (
+ 'contacts'
+ )
+ ),
+ 'front' => array(
+ )
+);
+
+// Load glmPluginSupport class from main GLM Member DB plugin
+require_once (GLM_MEMBERS_CONTACTS_MAIN_PLUGIN_PATH . '/classes/glmPluginSupport.php');
+
+// Load Smarty Template Support from main GLM Member DB plugin
+require_once (GLM_MEMBERS_CONTACTS_MAIN_PLUGIN_PATH . '/lib/smartyTemplateSupport.php');
+
+/**
+ * Admin Controller Class
+ *
+ * This is one of perhaps multiple controller classes that provide
+ * controller services for a major portion of this plugin. Typically
+ * there are such classes for Admin and Front-End functionality, but
+ * there could be others.
+ *
+ * This controller class performs all admin related operations for
+ * this plugin by calling the appropriate model and merging the resulting
+ * data with the appropriate view to produce any output.
+ *
+ * All requests for this controller class come through WordPress admin
+ * menus via hooks that "call back" methods in this class for each admin
+ * menu item in this plugin. Form submissions from an admin page selected
+ * by a particular menu item are directed to WordPress using the page
+ * reference of that menu item. Because of this, the callback for a form
+ * submission is also handled by the callback target method used by that
+ * menu item.
+ *
+ * Admin form submissions must use the URI for one of this plugin's
+ * menu items. The form post parameters may also provide an "action" name
+ * in the case where the default menu item behavior is not desired. A
+ * pathname for the model to execute is then complied using the menu
+ * item name as the name of a directory under models/admin and the
+ * requested action as the file name of the model to execute. The name
+ * "index" would be the default menu item action model. In essence the
+ * controller locates the model by menu item name and action name. for
+ * example...
+ *
+ * models/admin/members/index.php
+ * models/admin/members/display.php
+ *
+ * Similarly, the view associated with the action would be in a directory
+ * named the same as the model, and the view file would be named "index"
+ * or the name of the action.
+ *
+ * These hooks are established using the WordPress add_action()
+ * function and the configureMenus() method below. Other methods in this
+ * class then recieve any request from a menu item selection or form
+ *
+ * submission associated with a menu item by WordPress calling one of the
+ * "callback" methods below.
+ *
+ * The callback methods do nothing other than to call the controller()
+ * method and passing it the name of the menu item assocaiated with the
+ * callback.
+ *
+ * The controller() method determines which model to execute, executes
+ * that model, determines which view to merge with the data returned by
+ * the model, creates output from the result of that merge, and sends
+ * that output to the user.
+ *
+ * In situations where it may be desired to output directly to the browser
+ * without being contained in the admin Dashboard, the contructor can be
+ * directed
+ * to bypass setting up the admin hooks and execute the controller() method
+ * directly then exit. This results in output from the model/view withing being
+ * contained in the normal WordPress dashboard context. To trigger this use the
+ * following two form fields.
+ *
+ * glm_display_direct = 'true'
+ * glm_menu_item = (menu item name associated with the desired model)
+ *
+ * (no prameters)
+ *
+ * @return void
+ * @access public
+ */
+class glmMembersContactsAdmin extends GlmPluginSupport
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /**
+ * Admin Controller Constructor
+ *
+ * This contructor is executed by the main plugin index file when the site
+ * Dashboard is displayed. It's responsible for setting up any needed hooks
+ * into WordPress and setting up any support classes required to do admin
+ * work.
+ *
+ * (no prameters)
+ *
+ * @return void
+ * @access public
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Hook into menu created by main GLM Member DB plugin
+ // If we don't do it this way, the member db menus may not be setup
+ add_action('glm-member-db-add-menu', array($this, 'glmMembersAddMenusContacts'));
+
+ add_filter('glm-member-db-add-tab-for-members', array($this, 'glmMembersAddTabForMembers'));
+
+ }
+
+ public function glmMembersAddTabForMembers($addOnTabs)
+ {
+
+ $newTabs = array(
+ array(
+ 'text' => 'New Tab',
+ 'action' => 'list'
+ ),
+ array(
+ 'text' => 'Another Tab',
+ 'action' => 'anotherAction'
+ )
+ );
+ $addOnTabs = array_merge($addOnTabs, $newTabs);
+
+ return $addOnTabs;
+
+ }
+
+
+ /**
+ * Called by glm-member-db-add-menu hook from main GLM Member DB plugin
+ *
+ * This adds an admin_menu action that calls the configureMenus() method to
+ * actually do the work of adding the menus.
+ *
+ * Since there needs to be an add_action() call with 'admin_menu" and have that
+ * then link in an action that can be called to do the menu pages, we need this
+ * intermediate method.
+ *
+ * @return void
+ * @access public
+ */
+ public function glmMembersAddMenusContacts()
+ {
+
+ // Add hooks to WordPress
+ add_action('admin_menu', array($this, 'configureMenus'));
+
+ }
+
+ /**
+ * Configure WordPress Menus for this Plugin
+ *
+ * This method is called by an add_action() hook setup in the contructor. We
+ * do it
+ * this way so that the menu related functions of WordPress are in scope
+ * when creating
+ * the additional menu items. WordPress will execute this call-back method
+ * when building
+ * its Dashboard menus.
+ *
+ * add menu function reference
+ * add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position)
+ * add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function)
+ *
+ * (no prameters)
+ *
+ * @return void
+ * @access public
+ */
+ public function configureMenus ()
+ {
+
+ // A main Menu Test
+ add_menu_page(
+ 'Test Page 1', // Page title
+ 'Test 1', // Menu title
+ 'glm_members_edit', // Capability
+ 'glm-members-admin-menu-test-1', // Menu slug
+ array($this, 'glmMembersAdminMenuTest'), // Function to execute page
+ false, // Icon URL
+ '91.124' // Menu position
+ );
+
+ // A Test Sub-Menu
+ add_submenu_page(
+ 'glm-members-admin-menu-members', // Parent slug
+ 'Contacts', // Page title
+ 'Contacts', // Menu Title
+ 'glm_members_edit', // Capability required
+ 'glm-members-admin-menu-contacts', // Menu slug
+ array($this, 'glmMembersAdminMenuTest') // Function to execute page
+ );
+
+ // A Test Sub-Menu
+ add_submenu_page(
+ 'glm-members-admin-menu-test-1', // Parent slug
+ 'Sub-Test', // Page title
+ ' Sub-Test', // Menu Title
+ 'glm_members_edit', // Capability required
+ 'glm-members-admin-menu-sub-test-1', // Menu slug
+ array($this, 'glmMembersAdminMenuTest') // Function to execute page
+ );
+
+ }
+
+ /*
+ * Menu item specific "Callback" methods
+ *
+ * These methods are called by WordPress when specific menu items are
+ * selected by the
+ * user or a form action is submitted associated with the menu item.
+ *
+ * These methods call the controller and pass it the menu item that was
+ * called
+ * but perform no other work.
+ *
+ */
+
+ // A test menu
+ function glmMembersAdminMenuTest() {
+// $this->controller('contacts');
+ echo "TEST";
+ }
+
+
+ /**
+ * Contacts Admin controller
+ *
+ * This method is called by a plugin menu method. It is responsible for
+ * executing the approriate model, combining model data with a view, and
+ * outputing the result. It is therefore the core of the controller.
+ *
+ * This controller is supplied a menu item name and then determines if
+ * there is an additional action related to that menu item that needs to be
+ * executed rather than the default menu action.
+ *
+ * All models should return an array containing the following.
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * '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.
+ *
+ * For a better explanation of how this all works, see the description for
+ * this class.
+ *
+ * Controller parameters
+ *
+ * @param string $menuItem
+ * Name of the menu item that is being processed
+ *
+ * @return void
+ * @access public
+ */
+ public function controller ($menuItem, $action = false)
+ {
+ $errorMsg = '';
+
+ /*
+ * Because WordPress insists on forcing the timezone to UTC
+ * we need to save the current timezone setting, set the one
+ * we want to use, and then restore it after we're all done
+ * (see bottom of this script).
+ */
+ $defaultTimeZone = date_default_timezone_get();
+ date_default_timezone_set($this->config['settings']['time_zone']);
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+
+ // Also turn on SQL error messages
+ $this->wpdb->show_errors();
+
+ // If debug is VERBOSE
+ $consts = get_defined_constants(true);
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ $this->addNotice("<pre>".print_r($_SERVER,1).'</pre>', 'DataBlock', 'Server Defines');
+ $this->addNotice('<pre>'.print_r($consts,1).'</pre>', 'DataBlock', 'Defined Parameters');
+ // Not verbose
+ } else {
+ $ourConsts = array();
+ foreach ($consts['user'] as $k => $v) {
+ if (strncmp($k, 'GLM_MEMBERS_PLUGIN', 18) == 0) {
+ $ourConsts[$k] = $v;
+ }
+ }
+ $this->addNotice('<pre>'.print_r($ourConsts,1).'</pre>', 'DataBlock', 'Defined Parameters');
+ }
+
+ $this->addNotice('<pre>'.print_r($this->config,1).'</pre>', 'DataBlock', 'Configuration Settings');
+ $this->addNotice("<pre>".print_r($_REQUEST,1)."</pre>", 'DataBlock', "Request Data");
+ if (isset($_FILES)) {
+ $this->addNotice("<pre>".print_r($_FILES,1)."</pre>", 'DataBlock', "Request Files Data");
+ }
+ } else {
+ $this->clearNotices();
+ }
+
+ /*
+ * Determine model to execute
+ */
+
+ // Default action is "index" if an action wasn't specified in the controller call
+ if (!$action) {
+ $action = 'index';
+ }
+
+ // Get any requested "action" from a form submission and modify path/name
+ // accordingly. This modifies the previously set $action.
+ if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
+ $a = sanitize_text_field($_REQUEST['glm_action']);
+ if ($a != '') {
+ $action = $a;
+ }
+ }
+
+ // Loop till we have a final action
+ $loopCheck = 0;
+ $actionData = false;
+ do {
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ $this->addNotice("<b>Requested Action:</b> Menu item = $menuItem, Action = $action", 'Process');
+ }
+
+ $modelRedirect = false;
+
+ // Verify that we have the requested menu item in the valid actions
+ if (!isset($GLOBALS['glmMembersAdminValidActions'][$menuItem])) {
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ $this->addNotice('<b>Error in Admin Controller:</b> Menu Item not specified!', 'Alert');
+ }
+
+ $modelRedirect = true;
+ $menuItem = 'error';
+ $action = 'index';
+ $errorMsg .= "<b>Model doesn't exist:</b> ".$modelName;
+
+ }
+
+ // Verify Menu item and action using array at top of this file
+ if (! isset($GLOBALS['glmMembersAdminValidActions'][$menuItem]) ||
+ ! in_array($action, $GLOBALS['glmMembersAdminValidActions'][$menuItem])) {
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ $this->addNotice('<b>Error in Admin Controller:</b> Requested Menu Item is invalid! - '.$menuItem, 'Alert');
+ }
+
+ $menuItem = 'error';
+ $action = 'badAction';
+ }
+
+ /*
+ * Execute the selected model
+ */
+
+ // Build model and path and class names
+ $modelName = GLM_MEMBERS_PLUGIN_PATH . '/models/admin/' . $menuItem .
+ '/' . $action . '.php';
+ $className = 'GlmMembersAdmin_' . $menuItem . '_' . $action;
+
+ // If model file doesn't exist - we have an error
+ if (!file_exists($modelName)) {
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ $this->addNotice("<b>Error in Admin Controller:</b> Model file doesn't exist - ".$modelName, 'Alert');
+ }
+
+ $modelRedirect = true;
+ $menuItem = 'error';
+ $action = 'index';
+ $errorMsg .= "<b>Model doesn't exist:</b> ".$modelName;
+
+ // Otherwise, load and run the model
+ } else {
+
+ // Load the model file
+ require_once ($modelName);
+
+ // check for an invalid model class name
+ if (!class_exists($className)) {
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ $this->addNotice("<b>Error in Admin Controller:</b> Invalid Model Class Name - ".$className, 'Alert');
+ }
+
+ $modelRedirect = true;
+ $menuItem = 'error';
+ $action = 'index';
+ $errorMsg .= "<b>Model class doesn't exist:</b> ".$className;
+
+ } else {
+
+ // Check if this is a re-direct with parameters
+ $args = false;
+
+ // Instantiate the model and ask it to perform the work
+ $model = new $className($this->wpdb, $this->config);
+ $results = $model->modelAction($actionData);
+
+ // Check if there's been a model redirect request
+ if ($results['modelRedirect']) {
+
+ $this->addNotice('<pre>'.print_r($results,1).'</pre>', 'DataBlock', 'Model Redirect');
+
+ // Set the new model action
+ $action = $results['modelRedirect'];
+
+ // Check if there's also a menu item change
+ if ($results['menuItemRedirect']) {
+ $menuItem = $results['menuItemRedirect'];
+ }
+
+ // Check if there's data to pass to the new model
+ if (isset($results['data']) && count($results['data']) > 0) {
+ $actionData = $results['data'];
+ }
+
+ $modelRedirect = true;
+ }
+
+ // Get the specified view file
+ $view = false;
+ if (isset($results['view'])) {
+ $view = $results['view'];
+ }
+
+ // Check for invalid or missing view file
+ if (!$view || !is_file(GLM_MEMBERS_PLUGIN_PATH . '/views/'.$view)) {
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ $this->addNotice("<b>Error in Admin Controller:</b> Requested View file doesn't exist - ".$view, 'Alert');
+ }
+
+ $modelRedirect = true;
+ $menuItem = 'error';
+ $action = 'index';
+ $errorMsg .= "<b>Bad or missing view file:</b> ".$view;
+ }
+
+ } // model class exists
+ }
+
+ // This is just a sanity check on this loop to keep it from getting out of control
+ if (++$loopCheck > 10) {
+ die('<h1>Serious failure looping on model load in "controllers/admin.php".</h1>');
+ }
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG && $modelRedirect) {
+ $this->addNotice('<b>Redirecting...</b>', 'Process');
+ }
+
+ // Loop again if there's a model redirect
+
+ } while ($modelRedirect);
+
+ /*
+ * Check model results
+ */
+
+ // Get suggested view
+ $view = $results['view'];
+
+ // If there's a general model failure use the error view
+ if (! $results['status']) {
+ $view = 'admin/error/index.html';
+ }
+
+ // Check for modified settings to save in conf
+ if (isset($results['settings'])) {
+ while (list($key, $val) = each($results['settings'])) {
+ $this->config['settings'][$key] = $val;
+ }
+ }
+
+ /*
+ * Merge data returned from the model with the selected view
+ */
+
+ // Load Smarty Template support
+ $smarty = new smartyTemplateSupport();
+
+ // Add standard template parameters
+ $smarty->templateAssign ( 'adminDebug', GLM_MEMBERS_PLUGIN_ADMIN_DEBUG);
+ $smarty->templateAssign ( 'adminURL', GLM_MEMBERS_PLUGIN_ADMIN_URL);
+ $smarty->templateAssign ( 'baseURL', GLM_MEMBERS_PLUGIN_BASE_URL);
+ $smarty->templateAssign ( 'thisURL', GLM_MEMBERS_PLUGIN_CURRENT_URL );
+ $smarty->templateAssign ( 'thisPage', (isset($_REQUEST['page']) ? $_REQUEST['page']: '') );
+ $smarty->templateAssign ( 'glmPluginName', GLM_MEMBERS_PLUGIN_NAME );
+ $smarty->templateAssign ( 'glmPluginMediaURL', GLM_MEMBERS_PLUGIN_MEDIA_URL );
+ $smarty->templateAssign ( 'thisYear', date ( 'Y' ) );
+ $smarty->templateAssign ( 'ref_type_numb', $this->config['ref_type_numb']);
+ $smarty->templateAssign ( 'settings', $this->config['settings']);
+ $smarty->templateAssign ( 'terms', $this->config['terms']);
+
+ // Add data from model to Smarty template
+ if (is_array($results['data']) && count($results['data']) > 0) {
+ foreach ($results['data'] as $k => $d) {
+ $smarty->templateAssign($k, $d);
+ }
+ }
+
+ $smarty->templateAssign ( 'thisAction', $action);
+
+
+ // If there's an error message, add that also
+ if ($errorMsg != '') {
+ $smarty->templateAssign('errorMsg', $errorMsg);
+ }
+
+ // If view debug has been requested
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+
+ glmMembersAdmin::addNotice("<b>Template File:</b> $view", 'Process');
+
+ $x = $smarty->template->getTemplateVars();
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice($x, 'DataBlock', 'Template Parameters');
+ }
+
+ $templateVars = '<pre>' . print_r($x, 1) . '</pre>';
+ glmMembersAdmin::addNotice($templateVars, 'Template Parameters', 'Process');
+
+ }
+
+ // Generate output from model data and view
+
+ $smarty->template->display($view);
+
+ // Restore timezone that was set before our code was called
+ date_default_timezone_set($defaultTimeZone);
+
+ }
+
+}
+
+
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Contacts Add-On Front-End Controller
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release front.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+/**
+ * Array of valid menu items and actions.
+ *
+ *
+ * The higher level elements are valid menu items. These correlate to
+ * actual menu or sub menu items that are hooks back to this controller
+ * class.
+ *
+ * The lower level items below each menu item are actions that may be specified
+ * by a "glmMembersAction" form field.
+ */
+$GLOBALS['glmMembersFrontValidActions'] = array(
+
+ 'members' => array(
+ 'list',
+ 'detail'
+ ),
+ 'error' => array(
+ 'index',
+ 'badAction'
+ )
+
+);
+
+// Load glmPluginSupport class
+require_once (GLM_MEMBERS_CONTACTS_MAIN_PLUGIN_PATH . '/classes/glmPluginSupport.php');
+
+/*
+ * This class controls which models are use for front-end functionality
+ * of this plugin.
+ */
+class glmMembersCOntactsFront extends GlmPluginSupport
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /**
+ * Front-End controller
+ *
+ * This method is called by a plugin menu method. It is responsible for
+ * executing the approriate model, combining model data with a view, and
+ * outputing the result. It is therefore the core of the controller.
+ *
+ * This controller is supplied a menu item name and then determines if
+ * there is an additional action related to that menu item that needs to be
+ * executed rather than the default menu action.
+ *
+ * All models should return an array containing the following.
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * '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.
+ *
+ * For a better explanation of how this all works, see the description for
+ * this class.
+ *
+ * Controller parameters
+ *
+ * @param object $atts
+ * Shortcode attributes
+ * @param string $content
+ * Content included by an Enclosing format shortcode
+ *
+ * @return void
+ * @access public
+ */
+ public function controller ($atts, $content = null, $shortcode)
+ {
+
+ // Set shortcode attribute defaults
+/*
+ switch ($shortcode) {
+
+ case 'glm-members-list':
+ $action = 'list';
+ $request = shortcode_atts(
+ array(
+ 'map' => true,
+ 'category' => false,
+ 'category-name' => false,
+ 'alpha' => false,
+ 'search' => false,
+ 'amenities' => false,
+ 'detail-page' => false,
+ 'show' => false
+ ),
+ $atts,
+ 'glm-members'
+ );
+ break;
+
+ case 'glm-member-detail':
+ $action = 'detail';
+ $request = shortcode_atts(
+ array(
+ 'map' => true,
+ 'id' => false,
+ 'show' => false
+ ),
+ $atts,
+ 'glm-members'
+ );
+ break;
+
+ }
+*/
+ /*
+ * Because WordPress insists on forcing the timezone to UTC
+ * we need to save the current timezone setting, set the one
+ * we want to use, and then restore it after we're all done
+ * (see bottom of this script).
+ */
+ $defaultTimeZone = date_default_timezone_get();
+ date_default_timezone_set($this->config['settings']['time_zone']);
+
+ // Restore timezone that was set before our code was called
+ date_default_timezone_set($defaultTimeZone);
+
+ return $out;
+
+ }
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database Contaacts Child Plugin
+ * Deactivate Plugin Tasks
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabaseContacts
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+ die("Please do not call this code directly!");
+}
+
+/*
+ * This class performs all necessary additional work when this
+ * plugin is deactivated.
+ */
+class glmMembersContactsPluginDeactivate
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * Performs all the work for this model
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ delete_option('glmMembersDatabaseContactsPluginVersion');
+ }
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database Contacts Child Plugin
+ *
+ * Set standard defined parameters
+ */
+
+// NOTE: Plugin & Database versions are defined in "/glm-member-db.php".
+
+define('GLM_MEMBERS_CONTACTS_PLUGIN_NAME', 'Gaslight Media Members Database Contacts');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_SHORT_NAME', 'Contacts');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_SLUG', 'glm-member-db-contacts');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_DIR', GLM_MEMBERS_CONTACTS_PLUGIN_SLUG);
+
+// Determine which system we're running on - If not provided, assume PRODUCTION
+$host = getenv('GLM_HOST_ID');
+if (trim($host) == '') {
+ $host = 'PRODUCTION';
+}
+define('GLM_MEMBER_CONTACTS_PLUGIN_HOST', $host);
+
+// Determine current http/https protocol
+$pageProtocol = 'http';
+if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
+ $pageProtocol = 'https';
+}
+define('GLM_MEMBERS_CONTACTS_PLUGIN_HTTP_PROTOCOL', $pageProtocol);
+
+// Get various pieces of the URL
+$urlParts = parse_url(get_bloginfo('url'));
+$pageUri = explode('?', $_SERVER['REQUEST_URI']); // Bust this up to access URL path and script name only
+
+$WPUploadDir = wp_upload_dir();
+
+// URLs
+define('GLM_MEMBERS_CONTACTS_SITE_BASE_URL', home_url('/') );
+define('GLM_MEMBERS_CONTACTS_PLUGIN_URL', plugin_dir_url(__FILE__));
+define('GLM_MEMBERS_CONTACTS_PLUGIN_ADMIN_URL', admin_url('admin.php'));
+define('GLM_MEMBERS_CONTACTS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_CONTACTS_PLUGIN_DIR);
+define('GLM_MEMBERS_CONTACTS_PLUGIN_CURRENT_URL', $urlParts['scheme'].'://'.$urlParts['host'].$pageUri[0]);
+define('GLM_MEMBERS_CONTACTS_PLUGIN_MEDIA_URL', $WPUploadDir['baseurl'].'/'.GLM_MEMBERS_CONTACTS_PLUGIN_DIR);
+
+// Directories
+define('GLM_MEMBERS_CONTACTS_PLUGIN_PATH', dirname(__FILE__));
+define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_SCRIPTS', dirname(__FILE__).'/misc/databaseScripts');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH', GLM_MEMBERS_CONTACTS_PLUGIN_PATH.'/classes');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_LIB_PATH', GLM_MEMBERS_CONTACTS_PLUGIN_PATH.'/lib');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_MEDIA_PATH', $WPUploadDir['basedir'].'/'.GLM_MEMBERS_CONTACTS_PLUGIN_DIR);
+define('GLM_MEMBERS_CONTACTS_PLUGIN_IMAGES_PATH', GLM_MEMBERS_CONTACTS_PLUGIN_MEDIA_PATH.'/images');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_CONFIG_PATH', GLM_MEMBERS_CONTACTS_PLUGIN_PATH.'/config');
+
+// Database table prefixes
+global $wpdb;
+define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_');
+
+
+// Parameters related to the Main GLM Member DB plugin - Depending on what's going on these may already defined by the main plugin
+$pluginsPath = str_replace(GLM_MEMBERS_CONTACTS_PLUGIN_SLUG, '', GLM_MEMBERS_CONTACTS_PLUGIN_PATH);
+define('GLM_MEMBERS_CONTACTS_MAIN_PLUGIN_PATH', $pluginsPath.'/glm-member-db');
+?>
* version nunmber of that release for the DB version.
*/
define('GLM_MEMBERS_CONTACTS_PLUGIN_VERSION', '1.0.0');
-define('REQUIRED_GLM_MEMBERS_PLUGIN_MIN_DB_VERSION', '1.0.41');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_VERSION', '1.0.0');
+
+// This is the minimum version of the GLM Members DB plugin require for this plugin.
+define('GLM_MEMBERS_CONTACTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.43');
/*
* Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com)
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/**
- * *******************************************************************************
- *
- * *** Directory and File Structure ***
- *
+
+// 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');
+
+// Get configuration - Getting this from main plugin
+require_once('config.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');
+
+/*
+ * Do some checks to make sure the main GLM Member DB is active and of a recceint enough version
*/
+// Function to generate message regarding main GLM Member DB plugin not installed and active
+function glmMembersPluginRequired() {
+ echo '
+ <div class="error">
+ <p>The '.GLM_MEMBERS_CONTACTS_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!</p>
+ <p>The '.GLM_MEMBERS_CONTACTS_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+
+// Find out if main GLM Member DB is intalled and active
+include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+$plugin_name = 'glm-member-db/glm-member-db.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', 'glmMembersPluginRequired' );
+ deactivate_plugins('/'.GLM_MEMBERS_CONTACTS_PLUGIN_SLUG.'/'.GLM_MEMBERS_CONTACTS_PLUGIN_SLUG.'.php');
+}
+
+// Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on
+function glmMembersPluginMinVerRequired() {
+ echo '
+ <div class="error">
+ <p>The '.GLM_MEMBERS_CONTACTS_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than '
+ .GLM_MEMBERS_CONTACTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!</p>
+ <p>The '.GLM_MEMBERS_CONTACTS_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+
+// Check for minimum GLM Member DB version that will work with this add-on
+$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
+if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_CONTACTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) {
+ add_action( 'admin_notices', 'glmMembersPluginMinVerRequired');
+ deactivate_plugins('/'.GLM_MEMBERS_CONTACTS_PLUGIN_SLUG.'/'.GLM_MEMBERS_CONTACTS_PLUGIN_SLUG.'.php');
+}
+
+/*
+ * Register this add-on with the main GLM Member DB plugin and get information on all add-ons loaded.
+ */
+
+// Register this plugin with glm-member-db
+function glmMembersRegisterContacts($addOns) {
+
+ // Add this add-on to the add-ons array
+ $addOns[GLM_MEMBERS_CONTACTS_PLUGIN_SLUG] = array(
+ 'dir' => GLM_MEMBERS_CONTACTS_PLUGIN_PATH,
+ 'name' => GLM_MEMBERS_CONTACTS_PLUGIN_NAME,
+ 'short_name' => GLM_MEMBERS_CONTACTS_PLUGIN_SHORT_NAME,
+ 'slug' => GLM_MEMBERS_CONTACTS_PLUGIN_SLUG
+ );
+
+ // Return the array with our data added
+ return $addOns;
+}
+add_filter('glm-member-db-register-addon','glmMembersRegisterContacts', 10, 1);
+
+ /*
+ *
+ * Activate and Deactivate hooks
+ *
+ */
+
+ // Activate
+ function glmMembersContactsPluginActivate ()
+ {
+ global $wpdb, $config;
+ require_once (GLM_MEMBERS_CONTACTS_PLUGIN_PATH . '/activate.php');
+ new glmMembersContactsPluginActivate($wpdb, $config);
+ }
+ register_activation_hook(__FILE__, 'glmMembersContactsPluginActivate');
+
+ // Deactivate
+ function glmMembersContactsPluginDeactivate ()
+ {
+ global $wpdb, $config;
+ require_once (GLM_MEMBERS_CONTACTS_PLUGIN_PATH . '/deactivate.php');
+ $x = new glmMembersContactsPluginDeactivate($wpdb, $config);
+ return false;
+ }
+ register_deactivation_hook(__FILE__, 'glmMembersContactsPluginDeactivate');
+
+ /*
+ *
+ * Determine which controller to load
+ *
+ * The first is for displaying notices in another window, possibly for debug output.
+ *
+ */
+if (is_admin()) {
+ require_once (GLM_MEMBERS_CONTACTS_PLUGIN_PATH . '/controllers/admin.php');
+ new glmMembersContactsAdmin($wpdb, $config);
+ } else {
+ require_once (GLM_MEMBERS_CONTACTS_PLUGIN_PATH . '/controllers/front.php');
+ new glmMembersContactsFront($wpdb, $config);
+ }
+
?>
\ No newline at end of file
--- /dev/null
+<?php
+// Silence is golden.
\ No newline at end of file
--- /dev/null
+=== Gaslight Media Member Database Contacts Child Plugin ===
+Contributors: cscott@gaslightmedia.com
+Donate link: http://www.gaslightmedia.com
+Tags: Gaslight Media,Plugin,Members Contacts
+Requires at least: 3.0.1
+Tested up to: 3.4
+Stable tag: 4.3
+License: GPLv2 or later
+License URI: http://www.gnu.org/licenses/gpl-2.0.html
+
+This is the Gaslight Media Members Database Contacts Child Plugin.
+
+== Description ==
+
+The Gaslight Media Members Database Contacts Child Plugin is an add-on to the Gaslight Media Members Database,
+which is required to install and run this plugin
+
+== Installation ==
+
+This section describes how to install the plugin and get it working.
+
+e.g.
+
+1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
+1. Activate the plugin through the 'Plugins' menu in WordPress
+
+
--- /dev/null
+<?php
+die('uninstall');
+/**
+ * Gaslight Media Members Database Contacts Child Plugin
+ * Uninstall Plugin
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabaseContacts
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+ die("Please do not call this code directly!");
+}
+
+//if uninstall not called from WordPress exit
+if (!defined('WP_UNINSTALL_PLUGIN')) {
+ die("Sorry, uninstall must be called by WordPress!");
+}
+
+
+?>