From: Chuck Scott Date: Thu, 21 Apr 2016 13:43:59 +0000 (-0400) Subject: Removed old main file for this plugin. Moved to index.php X-Git-Tag: v1.0.8^2~14 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d5b5d8d65f92e0897fd0d6164630e966b95e7579;p=WP-Plugins%2Fglm-member-db-contacts.git Removed old main file for this plugin. Moved to index.php --- diff --git a/glm-member-db-contacts.php b/glm-member-db-contacts.php deleted file mode 100644 index c9c2ee3..0000000 --- a/glm-member-db-contacts.php +++ /dev/null @@ -1,251 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0.4 - */ - -/* - * 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. - */ -define('GLM_MEMBERS_CONTACTS_PLUGIN_VERSION', '1.0.7'); -define('GLM_MEMBERS_CONTACTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.44'); -define('REQUIRED_GLM_MEMBERS_PLUGIN_MIN_DB_VERSION', '1.0.41'); - -/* - * 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'); - -/* - * 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 ' -
-

The '.GLM_MEMBERS_CONTACTS_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!

-

The '.GLM_MEMBERS_CONTACTS_PLUGIN_NAME.' plugin has been de-activated.

-
- '; -} - -/* - * Check installation, activation, and version of main Member DB plugin - */ -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 glmMembersContactsMembersMinVerRequired() { - $curVer = get_option('glmMembersDatabasePluginVersion'); - echo ' -
-

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.' but the current verssion is '.$curVer.'!

-

The '.GLM_MEMBERS_CONTACTS_PLUGIN_NAME.' plugin has been de-activated.

-
- '; -} - -/* - * Check for Minimum DB version for main Member DB - */ -$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion'); -if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_CONTACTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) { - add_action( 'admin_notices', 'glmMembersContactsMembersMinVerRequired'); - 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. - */ -require_once(GLM_MEMBERS_CONTACTS_PLUGIN_SETUP_PATH.'/validActions.php'); -// require_once(GLM_MEMBERS_CONTACTS_PLUGIN_DB_SCRIPTS.'/dbVersions.php'); -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, - 'actions' => $GLOBALS['glmMembersContactsAddOnValidActions'], - 'database' => false - ); - - // 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'); - -/* - * Hooks for testing capabilities provided by this add-on - */ -require_once(GLM_MEMBERS_CONTACTS_PLUGIN_SETUP_PATH.'/permissions.php'); - -/* - * Login Checks and Messages - */ - -$wpUserID = get_current_user_id(); - -// Message to display on Login page after a forced logout detection -function glmMembersContactsNoLoginMessage( $message ) { - $message .= " -
-

NOTE: You are trying to log into a contact account that is for informational purposes only - or has been temporarily dissabled.

-

You are not permitted to log in with that contact account at this time.

-
- "; - return $message; -} - -// If login is from user who was logged out due to restriction or being flagged inactive - Display login message -if (isset($_COOKIE['glmMembersForcedLogout'])) { - add_filter('login_message', 'glmMembersContactsNoLoginMessage'); - setcookie ("glmMembersForcedLogout", "", time() - 3600); -} - -if ($wpUserID) { - - // Check if user's only role is as a restricted contact - $userRoles = get_userdata($wpUserID)->roles; - if (in_array('glm_members_restricted_contact', $userRoles) && count($userRoles) == 1) { - setcookie ("glmMembersForcedLogout", "Forced Logout", time() + 3600, '/'); - wp_logout(); - } - - // Check for a contact user that's inactive and send them back to login also - $contactUser = get_user_meta($wpUserID, 'glmMembersContactID', true); - $contactActive = get_user_meta($wpUserID, 'glmMembersContactActive', true); - if ($contactUser && !$contactActive) { - setcookie ("glmMembersForcedLogout", "Forced Logout", time() + 3600, '/'); - wp_logout(); - } - -} - -/* - * Add filter to redirect user to a particular destination on - * login based on their roles. - */ - -function my_login_redirect( $redirect_to, $request, $user ) { - - global $user; - - // Do we have a logged in user - if ( isset( $user->roles ) && is_array( $user->roles ) ) { - - // If this is a non-contact user or one with a pre-existing non-contact login - foreach ($user->roles as $r) { - if (substr($r,0,12) != 'glm_members_') { - // Go to normal destination for this user - return $redirect_to; - } - } - - // If we get here, this is a pure contact user, start them at their profile - - return '/wp-admin/admin.php?page=glm-members-admin-menu-member'; - - } - - // No logged in user - So why is the "login_redirect" filter triggered anyway? - return $redirect_to; - -} -add_filter( 'login_redirect', 'my_login_redirect', 10, 3 ); - - -?> \ No newline at end of file