From: Chuck Scott Date: Wed, 20 Apr 2016 21:09:30 +0000 (-0400) Subject: Revert "Events nearly ready, menu restructure" X-Git-Tag: v1.0.8~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=38b0f00283763b7e1d4626bc225576827d07c74b;p=WP-Plugins%2Fglm-member-db-contacts.git Revert "Events nearly ready, menu restructure" This reverts commit cf7e68e3b778fd847327402d0b7711c1cad9606d. --- diff --git a/classes/data/dataContacts.php b/classes/data/dataContacts.php index a1acb0e..b46800d 100644 --- a/classes/data/dataContacts.php +++ b/classes/data/dataContacts.php @@ -528,12 +528,12 @@ class GlmDataContacts extends GlmDataAbstract } // Check Contacts - $contact = $this->wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE email = '$email';", ARRAY_A); + $contact = $this->wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "contacts WHERE email = '$email';", ARRAY_A); if ($contact !== null) { $r['contactsEmail'] = true; $r['active'] = ($r['active'] > 0); } - $contact = $this->wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE username = '$username';", ARRAY_A); + $contact = $this->wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "contacts WHERE username = '$username';", ARRAY_A); if ($contact !== null) { $r['contactsUsername'] = true; $r['active'] = ($r['active'] > 0); diff --git a/defines.php b/defines.php index 31d2f05..64e8573 100644 --- a/defines.php +++ b/defines.php @@ -13,8 +13,7 @@ define('GLM_MEMBERS_CONTACTS_PLUGIN_SLUG', 'glm-member-db-contacts'); // Database table prefixes global $wpdb; -define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_membersContacts_'); -define('GLM_MEMBERS_CONTACTS_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersContactsDbVersion'); +define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_'); // Determine which system we're running on - If not provided, assume PRODUCTION diff --git a/glm-member-db-contacts.php b/glm-member-db-contacts.php new file mode 100644 index 0000000..c9c2ee3 --- /dev/null +++ b/glm-member-db-contacts.php @@ -0,0 +1,251 @@ + + * @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 diff --git a/index.php b/index.php index eda15a1..7e91415 100644 --- a/index.php +++ b/index.php @@ -1,260 +1,2 @@ - * @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_DB_VERSION', '0.0.1'); - -// 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.58'); -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/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', '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' => array( - 'dbPrefix' => GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX, - 'dbCurrentVersion' => GLM_MEMBERS_CONTACTS_PLUGIN_DB_VERSION, - 'dbActiveVersionOption' => GLM_MEMBERS_CONTACTS_PLUGIN_ACTIVE_DB_OPTION, - 'dbScriptPath' => GLM_MEMBERS_CONTACTS_PLUGIN_DB_SCRIPTS, - 'dbVersions' => $GLOBALS['glmMembersContactsDbVersions'] - ) - ); - - // 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 +// Silence is golden. \ No newline at end of file diff --git a/models/admin/contacts/index.php b/models/admin/contacts/index.php deleted file mode 100644 index 8a02df3..0000000 --- a/models/admin/contacts/index.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @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/ - */ - -// Load Contacts data abstract -require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); - -/* - * This model is called when the "Shortcodes" menu is selected - * - */ -class GlmMembersAdmin_contacts_index extends GlmDataContacts -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - /** - * Contacts List - * - * @var $contacts - * @access public - */ - public $contacts; - - /* - * 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 contacts data class - parent::__construct(false, false); - - } - - public function modelAction($actionData = false) { - - $haveContacts = false; - $filterArchived = false; - $filterText = false; - $haveFilter = false; - - // Only list member contacts for the selected member - $where = "true"; - - // Filter by text string supplied - if (isset($_REQUEST['filterText'])) { - $filterText = esc_sql($_REQUEST['filterText']); - $where .= " AND ( - T.lname LIKE '%$filterText%' OR - T.fname LIKE '%$filterText%' OR - T.org LIKE '%$filterText%' OR - T.descr LIKE '%$filterText%' - )"; - $haveFilter = true; - } - - // Check if this is a request to show archived contacts - if (!isset($_REQUEST['filterArchived'])) { - $where .= " AND T.access != ".$this->config['access_numb']['Archived']; - $filterArchived = false; - } else { - $filterArchived = true; - $haveFilter = true; - } - - // Get list of contacts - $this->contacts = $this->getList($where); - - if ($this->contacts !== false) { - if (count($this->contacts) > 0) { - $haveContacts = true; - } - } - - // Compile template data - $templateData = array( - 'haveContacts' => $haveContacts, - 'contacts' => $this->contacts, - 'filterArchived' => $filterArchived, - 'filterText' => $filterText, - 'haveFilter' => $haveFilter - ); - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'admin/contacts/index.html', - 'data' => $templateData - ); - - } -} - -?> \ No newline at end of file diff --git a/models/admin/management/contacts.php b/models/admin/management/contacts.php deleted file mode 100644 index a9b8d13..0000000 --- a/models/admin/management/contacts.php +++ /dev/null @@ -1,709 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release contacts.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); - -/** - * GlmMembersAdmin_management_contacts - * - * PHP version 5 - * - * @category Model - * @package GLM Member DB - * @author Chuck Scott - * @license http://www.gaslightmedia.com Gaslightmedia - * @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott - * Exp $ - */ -class GlmMembersAdmin_management_contacts extends GlmDataContacts -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * dbh Postgres database connection - * - * @var mixed - * @access public - */ - public $dbh; - /** - * settings used for the schema and tablenames - * - * @var mixed - * @access public - */ - public $settings = array(); - /** - * contacts - * - * @var bool - * @access public - */ - public $contacts = array(); - - /** - * 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 members data class - parent::__construct(false, false); - - } - -/* - public function importContactImages() - { - require_once(GLM_MEMBERS_PLUGIN_PATH.'/models/admin/ajax/imageUpload.php'); - $ImageUpload = new GlmMembersAdmin_ajax_imageUpload($this->wpdb, $this->config); - // get all events with images - $sql = " - SELECT id,image,old_event_id - FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "events - WHERE image != '' AND image IS NOT NULL"; - $results = $this->wpdb->get_results($sql, ARRAY_A); - echo '
$results: ' . print_r($results, true) . '
'; - $imgUrl = 'http://is0.gaslightmedia.com/discoverkalamazoo/CKImage/'; - foreach ( $results as $event ) { - $imageFullUrl = $imgUrl . $event['image']; - $res = $ImageUpload->storeImage($imageFullUrl); - - if ( $res['newFileName'] ) { - $this->wpdb->update( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events', - array( - 'image' => $res['newFileName'] - ), - array( 'id' => $event['id'] ), - array( '%s' ), - array( '%d' ) - ); - } - } - } -*/ - - /** - * modelAction - * - * @param bool $actionData - * @access public - * @return void - */ - public function modelAction($actionData = false) - { - -/* - $option = false; - $testResult = false; - $importResult = false; - $settingsUpdated = false; - $settingsUpdateError = false; - $eventsSettings = false; - - if (isset($_REQUEST['option'])) { - $option = $_REQUEST['option']; - } - - switch ($option) { - - case 'tests': - - $test = false; - if (isset($_REQUEST['test'])) { - $test = $_REQUEST['test']; - } - - switch ($test) { - - case 'recurrence': - - $testResult = $this->testRecurrence(); - - break; - - default: - break; - } - - break; - - case 'eventImagesImport': - - $this->importEventImages(); - - break; - - case 'eventimport': - - $import = false; - if (isset($_REQUEST['import'])) { - $import = filter_var( $_REQUEST['import'], FILTER_VALIDATE_BOOLEAN ); - } - switch ($import) { - case 'true': - $importResult = '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; - $db_host = filter_var( $_REQUEST['db_host'], FILTER_SANITIZE_STRING ); - $db_name = filter_var( $_REQUEST['db_name'], FILTER_SANITIZE_STRING ); - $db_user = filter_var( $_REQUEST['db_user'], FILTER_SANITIZE_STRING ); - $db_password = filter_var( $_REQUEST['db_password'], FILTER_SANITIZE_STRING ); - $this->connectPostgresDb($db_host, $db_name, $db_user, $db_password); - - $this->settings = filter_var_array( - $_REQUEST, - array( - 'schema' => FILTER_SANITIZE_STRING, - 'cattablename' => FILTER_SANITIZE_STRING, - 'tablename' => FILTER_SANITIZE_STRING, - 'sdate' => array( - 'filter' => FILTER_VALIDATE_REGEXP, - 'options' => array( - 'regexp' => '%[0-9]{2}/[0-9]{2}/[0-9]{4}%' - ) - ) - - ) - ); - $importResult .= '
$this->settings: ' . print_r($this->settings, true) . '
'; - $this->addCategories(); - $importResult .= $this->addEvents(); - - $importResult .= '
$this->categories: ' . print_r($this->categories, true) . '
'; - - - break; - default: - break; - } - break; - - case 'settings': - - default: - - // Make sure option is set if default - $option = 'settings'; - - // Determine if current user can edit configurations - if (!current_user_can('glm_members_management')) { - return array( - 'status' => false, - 'menuItemRedirect' => 'error', - 'modelRedirect' => 'index', - 'view' => 'admin/error/index.html', - 'data' => array( - 'reason' => 'User does not have rights to make configuration changes.' - ) - ); - } - - // Check for submission option - $option2 = ''; - if (isset($_REQUEST['option2'])) { - $option2 = $_REQUEST['option2']; - } - - switch($option2) { - - // Update the settings and redisplay the form - case 'submit': - - // Update the event management settings - $eventsSettings = $this->updateEntry(1); - if ($eventsSettings['status']) { - $settingsUpdated = true; - } else { - $settingsUpdateError = true; - } - - break; - - // Default is to get the current settings and display the form - default: - - // Try to get the first (should be only) entry for general settings. - $eventsSettings = $this->editEntry(1); - - if ($eventsSettings === false) { - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice("  /models/admin/management/events.php: Unable to load events management settings.", 'Alert'); - } - - } - - break; - - } - - break; - - } -*/ - - // Compile template data - $templateData = array( -/* - 'option' => $option, - 'testResult' => $testResult, - 'importResult' => $importResult, - 'settingsUpdated' => $settingsUpdated, - 'settingsUpdateError' => $settingsUpdateError, - 'eventsSettings' => $eventsSettings -*/ - ); - - // Return status, suggested view, and data to controller - return array( - 'status' => true, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/management/contacts.html', - 'data' => $templateData - ); - - - } - - /** - * connectPostgresDb - * - * Make a connection to the given database for the site. (postgres) - * Sets the $this->dbh with the postgers database connection - * - * @param mixed $db_host - * @param mixed $db_name - * @param mixed $db_user - * @param mixed $db_password - * @access public - * @return void - */ - public function connectPostgresDb($db_host, $db_name, $db_user, $db_password) - { - $connStr = "pgsql:"; - if ( $db_host ) { - $connPart[] = "host={$db_host}"; - } - if ( $db_name ) { - $connPart[] = "dbname={$db_name}"; - } - if ( $db_user ) { - $connPart[] = "user={$db_user}"; - } - if ( $db_password ) { - $connPart[] = "password={$db_password}"; - } - if ( !empty($connPart) ) { - $connStr .= implode( " ", $connPart ); - } - $driverOptions = array( - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_BOTH, - ); - try { - $this->dbh = new PDO($connStr, null, null, $driverOptions); - $this->dbh->setAttribute( - PDO::ATTR_ERRMODE, - PDO::ERRMODE_EXCEPTION - ); - } catch(PDOException $e) { - echo '
$e: ' . print_r($e, true) . '
'; - wp_die(); - } - } - - /** - * addContacts - * - * Start with contacts tables. ( delete all contact data ) - * Grab all contacts - * Enter them into the new contact tables and as WordPress users as required. - * - * @access public - * @return void - */ - public function addContacts() - { - return false; - - // clear the contactss tables first - $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events" ); - $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "recurrences" ); - $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times" ); - $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories" ); - $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations" ); - $Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config); - $return = ''; - $sql = " - SELECT * - FROM {$this->settings['schema']}.{$this->settings['tablename']} - WHERE edate >= '{$this->settings['sdate']}'::DATE"; - //$sql .=" AND reacur "; - try { - $events = $this->dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC); - $return .= '
$events: ' . print_r($events, true) . '
'; - foreach ( $events as $event ) { - $foundMemberId = $refType = null; - if ( $event['member_id'] ) { - // get the new member id - $sql = " - SELECT id - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - WHERE old_member_id = '" . esc_sql( trim($event['member_id']) ) . "'"; - $foundMemberId = $this->wpdb->get_row($sql, ARRAY_A); - if ( $foundMemberId ) { - $foundMemberId = $foundMemberId['id']; - $refType = $this->config['ref_type_numb']['Member']; - } - } - var_dump($foundMemberId); - // see if event is in there by old_event_id - $sql = " - SELECT id - FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events - WHERE old_event_id = '" . esc_sql( trim($event['id']) ) . "'"; - $found = $this->wpdb->get_row($sql, ARRAY_A); - //echo '
$found: ' . print_r($found, true) . '
'; - $intro = substr(strip_tags($event['descr']), 0, 250); - if ( isset($found) ) { - $this->wpdb->update( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events', - array( - 'status' => (($event['visable']) - ? $this->config['status_numb']['Active'] - : $this->config['status_numb']['Inactive']), - 'created' => $event['create_date'], - 'updated' => $event['create_date'], - 'approved' => $event['approved_date'], - 'name' => $event['header'], - 'intro' => $intro, - 'descr' => $event['descr'], - 'image' => $event['img'], - 'cost' => $event['cost'], - 'url' => $event['url'], - 'ref_type' => $refType, - 'ref_dest' => $foundMemberId, - 'admin_name' => $event['admin_contact_name'], - 'admin_org' => $event['admin_org_name'], - 'admin_email' => $event['admin_email'], - 'admin_phone' => $event['admin_phone'], - 'contact_email' => $event['email'], - 'contact_name' => $event['contact'], - 'contact_phone' => $event['phone'], - 'notes' => $event['notes'], - 'hide_address' => $event['notes'], - ), - array( 'old_event_id' => $event['id'] ), - array( - '%d', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%d', - '%d', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - ), - array( '%d' ) - ); - $eventId = $found['id']; - } else { - $eventData = array( - 'status' => (($event['visable'] == '1') - ? $this->config['status_numb']['Active'] - : $this->config['status_numb']['Inactive']), - 'created' => $event['create_date'], - 'updated' => $event['create_date'], - 'approved' => $event['approved_date'], - 'name' => $event['header'], - 'intro' => $intro, - 'descr' => $event['descr'], - 'image' => $event['img'], - 'cost' => $event['cost'], - 'url' => $event['url'], - 'old_event_id' => $event['id'], - 'ref_type' => $refType, - 'ref_dest' => $foundMemberId, - 'admin_name' => $event['admin_contact_name'], - 'admin_org' => $event['admin_org_name'], - 'admin_email' => $event['admin_email'], - 'admin_phone' => $event['admin_phone'], - 'contact_email' => $event['email'], - 'contact_name' => $event['contact'], - 'contact_phone' => $event['phone'], - 'notes' => $event['notes'], - 'hide_address' => $event['notes'], - ); - echo '
$eventData: ' . print_r($eventData, true) . '
'; - echo ''; - $this->wpdb->insert( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events', - $eventData, - array( - '%d', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%d', - '%d', - '%d', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - '%s', - ) - ); - $eventId = $this->wpdb->insert_id; - //var_dump( $eventId ); - //echo '
$eventId: from insert ' . print_r($eventId, true) . '
'; - if ( !$eventId ) { - echo '
SQL Error: ' . $this->wpdb->last_error . '
'; - } - } - // checking for $eventId - //echo '
$eventId: ' . print_r($eventId, true) . '
'; - if (!$eventId) { - die('something is wrong no eventId'); - } - // generate the slug name for this new event - $eventAbstract = new GlmDataEvents($this->wpdb, $this->config); - $eventAbstract->updateSlug($eventId); - // category for event - if ( $event['topicid'] ) { - $this->wpdb->insert( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'event_categories', - array( - 'event' => $eventId, - 'category' => $this->oldCatMap[$event['topicid']] - ), - array( - '%d', - '%d' - ) - ); - } - // recurrences for the event - $allDates = $event['reacur']; - if ( $allDates && ( $event['bdate'] == $event['edate'] ) ) { - $allDates = 0; - } - $allDay = $event['all_day']; - $dayOfWeek = - $monthOfYear = - $weekOfMonth = - $byDayOfMonth = - $lastDayOfMonth = null; - if ( $allDates ) { - if ( $event['daysow'] ) { - $dayOfWeek = $event['daysow']; - } - if ( $event['weekom'] ) { - switch ($event['weekom']) { - case '1': - $weekOfMonth = 1; - break; - case '2': - $weekOfMonth = 2; - break; - case '3': - $weekOfMonth = 4; - break; - case '4': - $weekOfMonth = 8; - break; - case '5': - $weekOfMonth = 16; - break; - } - } else { - $weekOfMonth = 63; - } - $monthOfYear = 4095; - } - $btime = $this->getTime($event['btime']); - $etime = $this->getTime($event['etime']); - $recurData =array( - 'event' => $eventId, - 'start_time' => $btime, - 'end_time' => $etime, - 'from_date' => $event['bdate'], - 'to_date' => $event['edate'], - 'all_day' => $allDay, - 'recurring' => $allDates, - 'month_of_year' => $monthOfYear, - 'week_of_month' => $weekOfMonth, - 'day_of_week' => $dayOfWeek, - 'by_day_of_month' => $byDayOfMonth, - 'last_day_of_month' => $lastDayOfMonth - ); - //echo '
' . print_r( $recurData, true) . '
'; - echo '
$recurData: ' . print_r($recurData, true) . '
'; - $this->wpdb->insert( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'recurrences', - $recurData, - array( - '%d', - '%s', - '%s', - '%s', - '%s', - '%d', - '%d', - '%d', - '%d', - '%d', - '%d', - '%d', - ) - ); - $recurId = $this->wpdb->insert_id; - $Recurrences->createRecurrenceTimesEntries( $recurId, true, true ); - // location for the event - $hasLocation = ( - ($event['loc']) - || ($event['contact']) - || ($event['phone']) - || ($event['url']) - || ($event['email']) - ); - if ( $hasLocation ) { - $locationData = $locationFormat = array(); - $locationData['event'] = $eventId; - $locationFormat[] = '%d'; - if ($event['loc']) { - $locationData['name'] = $event['loc']; - $locationFormat[] = '%s'; - } - if ($event['address']) { - $locationData['address'] = $event['address']; - $locationFormat[] = '%s'; - } - if ($event['city']) { - $locationData['city'] = $this->getCityId( $event['city'] ); - $locationFormat[] = '%s'; - } - if ($event['state']) { - $locationData['state'] = $event['state']; - $locationFormat[] = '%s'; - } - if ($event['zip']) { - $locationData['zip'] = $event['zip']; - $locationFormat[] = '%s'; - } - if ($event['lat']) { - $locationData['lat'] = $event['lat']; - $locationFormat[] = '%s'; - } - if ($event['lon']) { - $locationData['lon'] = $event['lon']; - $locationFormat[] = '%s'; - } - if ($event['contact']) { - // break up the contact name db is expecting first and - // last name separately - list( $firstName, $lastName ) = explode( ' ', $event['contact'], 2 ); - $locationData['contact_fname'] = $firstName; - $locationFormat[] = '%s'; - $locationData['contact_lname'] = $lastName; - $locationFormat[] = '%s'; - } - if ($event['phone']) { - $locationData['contact_phone'] = $event['phone']; - $locationFormat[] = '%s'; - } - if ($event['email']) { - $locationData['contact_email'] = $event['email']; - $locationFormat[] = '%s'; - } - $this->wpdb->insert( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'locations', - $locationData, - $locationFormat - ); - $locationId = $this->wpdb->insert_id; - if ( !$locationId ) { - echo '
$locationData: ' . print_r($locationData, true) . '
'; - die('no return id for location'); - } - } - } - } catch(PDOException $e) { - echo '
$e: ' . print_r($e, true) . '
'; - die('end here'); - } - return $return; - } - -} - -?> diff --git a/models/admin/member/contacts.php b/models/admin/member/contacts.php index e016716..d98f99f 100644 --- a/models/admin/member/contacts.php +++ b/models/admin/member/contacts.php @@ -173,6 +173,9 @@ class GlmMembersAdmin_member_contacts extends GlmDataContacts case 'addNew': + // Check for new cities being submitted + $this->checkNewCities(); + // Check for existing contact in Wordpress and Contacts $contactCheck = $this->checkContact($_REQUEST['email'], $_REQUEST['username']); @@ -202,7 +205,7 @@ class GlmMembersAdmin_member_contacts extends GlmDataContacts // Change the contact username to match the Wordpress username $this->wpdb->query(" - UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts + UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "contacts SET username = '".$contactCheck['wpUserEmail']->data->user_login."' WHERE id = ".$this->contactInfo['fieldData']['id']."; "); @@ -245,18 +248,12 @@ class GlmMembersAdmin_member_contacts extends GlmDataContacts // Get the updated user information $this->contactInfo = $this->editEntry($this->contactInfo['fieldData']['id']); - // Save the contact ID - $this->contactID = $this->contactInfo['fieldData']['id']; - $newContactCreated = true; // Store the contact ID and active status into user meta data update_user_meta($userID, 'glmMembersContactID', $this->contactInfo['fieldData']['id']); update_user_meta($userID, 'glmMembersContactActive', $this->contactInfo['fieldData']['active']['value']); - // Check for new cities being submitted - $this->checkNewCities(); - break; } @@ -288,12 +285,12 @@ class GlmMembersAdmin_member_contacts extends GlmDataContacts case 'submit': - // Get current role set in the contacts record along with the matching WP role slug - $this->contactID = ($_REQUEST['contact']-0); - // Check for new cities being submitted $this->checkNewCities(); + // Get current role set in the contacts record along with the matching WP role slug + $this->contactID = ($_REQUEST['contact']-0); + $savedContactRole = $this->getWpRole($this->contactID); $this->contactInfo = $this->updateEntry($this->contactID); @@ -431,10 +428,6 @@ class GlmMembersAdmin_member_contacts extends GlmDataContacts } - // Also save the mmeber ID in a WordPress "option" in case someone clicks the "Member" sub-menu - update_option('glmMembersDatabaseMemberID', $this->memberID); - - } // if haveMember @@ -482,23 +475,23 @@ class GlmMembersAdmin_member_contacts extends GlmDataContacts public function checkNewCities() { - // If we have a contact ID and this was a submission with a new city (id < 0) + // If we have a member ID and this was a submission with a new city (id < 0) if ($this->contactID && isset($_REQUEST['city']) && $_REQUEST['city'] == -1 && isset($_REQUEST['newCityName']) && trim($_REQUEST['newCityName']) != '') { // Clean up city name $cName = trim(filter_var($_REQUEST['newCityName'])); // Try to add the city - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'); + require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataCities.php'); $Cities = new GlmDataCities($this->wpdb, $this->config); $cID = $Cities->addCity($cName); // If we got a city id back if (is_int($cID) && $cID > 0) { - // Update the city selected for this contact record + // Update the city selected for this memberInfo record $sql = " - UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX."contacts + UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."contacts SET city = $cID WHERE id = ".$this->contactID." ;"; diff --git a/models/admin/members/contacts.php b/models/admin/members/contacts.php new file mode 100644 index 0000000..35d82f3 --- /dev/null +++ b/models/admin/members/contacts.php @@ -0,0 +1,148 @@ + + * @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/ + */ + +// Load Contacts data abstract +require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); + +/* + * This model is called when the "Shortcodes" menu is selected + * + */ +class GlmMembersAdmin_members_contacts extends GlmDataContacts +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Contacts List + * + * @var $contacts + * @access public + */ + public $contacts; + + /* + * 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 members data class + parent::__construct(false, false); + + } + + public function modelAction($actionData = false) { + + $haveContacts = false; + $filterArchived = false; + $filterText = false; + $haveFilter = false; + + // Only list member contacts for the selected member + $where = "true"; + + // Filter by text string supplied + if (isset($_REQUEST['filterText'])) { + $filterText = esc_sql($_REQUEST['filterText']); + $where .= " AND ( + T.lname LIKE '%$filterText%' OR + T.fname LIKE '%$filterText%' OR + T.org LIKE '%$filterText%' OR + T.descr LIKE '%$filterText%' + )"; + $haveFilter = true; + } + + // Check if this is a request to show archived contacts + if (!isset($_REQUEST['filterArchived'])) { + $where .= " AND T.access != ".$this->config['access_numb']['Archived']; + $filterArchived = false; + } else { + $filterArchived = true; + $haveFilter = true; + } + + // Get list of contacts + $this->contacts = $this->getList($where); + + if ($this->contacts !== false) { + if (count($this->contacts) > 0) { + $haveContacts = true; + } + } + + // Compile template data + $templateData = array( + 'haveContacts' => $haveContacts, + 'contacts' => $this->contacts, + 'filterArchived' => $filterArchived, + 'filterText' => $filterText, + 'haveFilter' => $haveFilter + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/members/contacts.html', + 'data' => $templateData + ); + + } +} + +?> \ No newline at end of file diff --git a/models/admin/profile/index.php b/models/admin/profile/index.php index 26ab246..1564bfd 100644 --- a/models/admin/profile/index.php +++ b/models/admin/profile/index.php @@ -222,7 +222,7 @@ class GlmMembersAdmin_profile_index extends GlmDataContacts // Update the city selected for this memberInfo record $sql = " - UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX."contacts + UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."contacts SET city = $cID WHERE id = ".$this->contactID." ;"; diff --git a/models/admin/sample/index.php b/models/admin/sample/index.php new file mode 100644 index 0000000..86289ad --- /dev/null +++ b/models/admin/sample/index.php @@ -0,0 +1,81 @@ + + * @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/ + */ + +/* + * This model is called when the "Shortcodes" menu is selected + * + */ +class GlmMembersAdmin_sample_index +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + + /* + * 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; + + } + + public function modelAction($actionData = false) { + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/sample/index.html', + 'data' => false + ); + + } +} + +?> \ No newline at end of file diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 83d0a5f..358802b 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -30,15 +30,6 @@ * */ -add_submenu_page( - 'glm-members-admin-menu-members', // Parent slug - 'Contacts', // Page title - 'Contacts', // Menu Title - 'glm_members_members', // Capability required - 'glm-members-admin-menu-contacts-index', // Menu slug - function() {$this->controller('contacts');} -); - // If a contact is logged in (ownEntity isn't false), add Contact Profile menu item if ($this->config['loggedInUser']['contactUser']) { add_submenu_page( diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 8bc578f..410389f 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -33,8 +33,6 @@ * */ -// Admin Members Contacts Tab -/* add_filter('glm-member-db-add-tab-for-members', function($addOnTabs) { $newTabs = array( @@ -48,9 +46,7 @@ add_filter('glm-member-db-add-tab-for-members', return $addOnTabs; } ); -*/ -// Admin Member Contacts Tab if (apply_filters('glm_members_permit_admin_member_contacts_tab', true)) { add_filter('glm-member-db-add-tab-for-member', function($addOnTabs) { @@ -67,23 +63,4 @@ if (apply_filters('glm_members_permit_admin_member_contacts_tab', true)) { ); } -// Admin Management Contacts Tab -if (apply_filters('glm_members_permit_admin_members_contacts_tab', true)) { - add_filter('glm-member-db-add-tab-for-management', - function($addOnTabs) { - $newTabs = array( - array( - 'text' => 'Contacts', - 'menu' => 'management', - 'action' => 'contacts' - ) - ); - $addOnTabs = array_merge($addOnTabs, $newTabs); - return $addOnTabs; - } - ); -} - - - ?> \ No newline at end of file diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql deleted file mode 100644 index a80e516..0000000 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ /dev/null @@ -1,56 +0,0 @@ --- Gaslight Media Members Database --- File Created: 12/09/14 15:27:15 --- Database Version: 1.0.0 --- Database Creation Script - Contacts Add-On --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes --- --- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES **** --- - --- Contacts - used by various entities -CREATE TABLE {prefix}contacts ( - id INT NOT NULL AUTO_INCREMENT, - active BOOLEAN NULL, -- Contact is active flag - access INT NULL, -- Access type - See access table in plugin.ini - fname TINYTEXT NULL, -- First name of contact - lname TINYTEXT NULL, -- Last name of contact - contact_type INT NULL, -- Contact type - see contact_type table (individual, role, ...) - contact_role INT NULL, -- Contact WordPress user Role - org TINYTEXT NULL, -- Organization name - title TINYTEXT NULL, -- Title/Position - descr TEXT NULL, -- Description of position/responsibilities - Displayed - image TINYTEXT NULL, -- Image - addr1 TINYTEXT NULL, -- Address line 1 - Address is for contact, not necessarily for organization - addr2 TINYTEXT NULL, -- Address line 2 - city INT NULL, -- Pointer to city in cities table - state TINYTEXT NULL, -- Two character state code - matches states.ini entries - country TINYTEXT NULL, -- Two character country code - matches countries.ini entries - zip TINYTEXT NULL, -- ZIP/Postal Code - lat FLOAT NULL, -- Latitude of contact location - lon FLOAT NULL, -- Longitude of contact location - url TINYTEXT NULL, -- URL to information regarding this contact - office_phone TINYTEXT NULL, -- Office phone number - home_phone TINYTEXT NULL, -- Home phone number - or after-hours phone number - mobile_phone TINYTEXT NULL, -- Mobile phone number - alt_phone TINYTEXT NULL, -- An alternate phone number - fax TINYTEXT NULL, -- FAX number (do people still use these?) - email TINYTEXT NULL, -- E-Mail address - alt_email TINYTEXT NULL, -- Alternate E-Mail address - Also used to log-in - username TINYTEXT NULL, -- Optional username to use for login - password TINYTEXT NULL, -- Encrypted password - notes TEXT NULL, -- Notes - Not displayed on front-end - create_time TIMESTAMP NULL, -- Create date/time - modify_time TIMESTAMP NULL, -- Last modified date/time - ref_type INT NULL, -- Type of entity this contact is associated with - ref_dest INT NULL, -- Pointer to the specific entity of ref_type this contact is associated with - PRIMARY KEY (id), - INDEX(fname(20)), - INDEX(lname(20)), - INDEX(city), - INDEX(zip(10)), - INDEX(lat), - INDEX(lon), - INDEX(email(20)) -); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php deleted file mode 100644 index 7009d41..0000000 --- a/setup/databaseScripts/dbVersions.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -/** - * Database Versions - * - * *** PLEASE NOW INCLUDE A DATE FOR EACH DATABASE VERSION *** - * '1.1.2' => array('version' => '1.1.2', 'tables' => 14, 'date' => '4/11/16') - * - * An array of past and current Member Database versions. - * - * Each entry below uses a key so code can find data on - * a specific version and in the values are the version - * again and the proper number of tables that should - * exist with that version. - */ -$glmMembersContactsDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 1, 'date' => '4/15/2016'), -); - - diff --git a/setup/databaseScripts/drop_database_V0.0.1.sql b/setup/databaseScripts/drop_database_V0.0.1.sql deleted file mode 100644 index 78bacb5..0000000 --- a/setup/databaseScripts/drop_database_V0.0.1.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Gaslight Media Members Database --- File Created: 12/09/14 15:27:15 --- Database Version: 1.1.1 --- Database Deletion Script --- Note: Tables with DELETE CASCADE must appear before referenced table - -DROP TABLE IF EXISTS - {prefix}amenities, - {prefix}amenity_ref, - {prefix}category_member_info, - {prefix}cities, - {prefix}contacts, - {prefix}images, - {prefix}files, - {prefix}members, - {prefix}member_info, - {prefix}member_type, - {prefix}regions, - {prefix}settings_general, - {prefix}settings_terms, - {prefix}categories -; - diff --git a/setup/databaseScripts/readme.txt b/setup/databaseScripts/readme.txt deleted file mode 100644 index 141d8b5..0000000 --- a/setup/databaseScripts/readme.txt +++ /dev/null @@ -1,41 +0,0 @@ -This directory contains database creation and update scripts for this add-on. - -The files in this directory are checked by the checkDatabase() function in the -main plugin classes/glmPluginSupport.php file. - -This directory is optional. If there are no data tables that need to be created -for this add-on, there should be no files in this directory. The directory may -also be deleted. - -See the "examples" directory for a sample of what can go in this directory. -Procedure to update database ------------------------------ - -0) Make a backup copy of the site's database. - -1) Rename "create_database_Vx.x.x.sql" to new version number. - example: create_database_V0.0.9.sql -> create_database_V0.0.10.sql - -2) Edit renamed create database file and make desired changes - -3) Add a new "update_database_Vx.x.x.sql" named with the correct version #. - -4) Edit new update database files with SQL script to make the necessary changes - from the previous version to the new version. (i.e. to add new fields, - rename fields, insert records, ...) - -5) Optionally add an "update_database_Vx.x.x.php" file if PHP scripting is - needed to update database content. (i.e. to make changes to database content) - -6) Edit the "dbVersions.php" file and add a new line for the new version. - *** Now please be sure to add a date for each entry *** - i.e. '1.1.2' => array('version' => '1.1.2', 'tables' => 14, 'date' => '4/11/16') - -7) When this is all done, edit the index.php file for the plugin/add-on and - change "GLM_MEMBERS_{addon}_PLUGIN_DB_VERSION" defined parameter where - {addon} is the add-on name. - -8) Go to an admin menu item for the main member db plugin or any add-on. If all - goes well, the main plugin should have detected the change and updated the - database. If not, restore the database and try again. -9) Check the database to make sure the changes to fields and data are correct. diff --git a/setup/validActions.php b/setup/validActions.php index 458862c..8af4d47 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -40,12 +40,6 @@ $glmMembersContactsAddOnValidActions = array( ), 'profile' => array( 'index' => GLM_MEMBERS_CONTACTS_PLUGIN_SLUG - ), - 'contacts' => array( - 'index' => GLM_MEMBERS_CONTACTS_PLUGIN_SLUG - ), - 'management' => array( - 'contacts' => GLM_MEMBERS_CONTACTS_PLUGIN_SLUG ) ), 'frontActions' => array( diff --git a/views/admin/contacts/header.html b/views/admin/contacts/header.html deleted file mode 100644 index 3be1c2f..0000000 --- a/views/admin/contacts/header.html +++ /dev/null @@ -1,8 +0,0 @@ -
-

All Contacts

- -
- - \ No newline at end of file diff --git a/views/admin/contacts/index.html b/views/admin/contacts/index.html deleted file mode 100644 index 78058f7..0000000 --- a/views/admin/contacts/index.html +++ /dev/null @@ -1,75 +0,0 @@ -{include file='admin/contacts/header.html'} - -
- List Filters:   - Show Archived   -    - Search - -

Contacts

- - - - - - - - - - - - - - - -{if $haveContacts} - {foreach $contacts as $c} - - - - - - - - - - - {/foreach} -{else} - -{/if} - -
NameActiveTypeAccessUserEntityOrganizationLocation
{$c.lname}, {$c.fname}{$c.active.name}{$c.contact_type.name}{$c.access.name}{$c.contact_role_short.name} - {$c.ref_type.name}: - {$c.ref_dest_name} - {$c.org}{$c.city.name}, {$c.state.name}
(no contacts listed)
- - - - - -{include file='admin/footer.html'} diff --git a/views/admin/management/contacts.html b/views/admin/management/contacts.html deleted file mode 100644 index 7b9146f..0000000 --- a/views/admin/management/contacts.html +++ /dev/null @@ -1,71 +0,0 @@ -{include file='admin/management/header.html'} - - - - - - - {if $importResult} - - - - - {else} - - - - {/if} -
Return to Import Events
- {$importResult} -
-
- - - - -
-
- Database to import from: - - - - - - - - -
- -
-
-
- - diff --git a/views/admin/member/contacts.html b/views/admin/member/contacts.html index 4de1f63..f1550ce 100644 --- a/views/admin/member/contacts.html +++ b/views/admin/member/contacts.html @@ -15,7 +15,7 @@ {if $option == 'list'} {if apply_filters('glm_members_permit_admin_member_contacts_add_contact', true)} - Add New Member Contact + Add New Member Contact {/if}
List Filters:   @@ -44,7 +44,7 @@ {if apply_filters('glm_members_permit_admin_member_contacts_view_contact', true)} - {$c.lname}, {$c.fname} + {$c.lname}, {$c.fname} {else} {$c.lname}, {$c.fname} {/if} @@ -108,7 +108,7 @@ {if $option == 'create' || $option == 'edit'} - Return to Contact List + Return to Contact List {if $option == 'create'}

Add New Contact

@@ -141,7 +141,7 @@ {/if} - + {if $option == 'create'} @@ -310,12 +310,12 @@ {if $contactInfo.fieldData.image}
- + Close
- +
Delete Image
{$contactInfo.fieldData.image}
@@ -471,7 +471,7 @@

* Required

- + {/if} @@ -495,7 +495,7 @@ Image: {if $contactInfo.fieldData.image} - + {/if} @@ -547,7 +547,7 @@ filter += '&filterText=' + encodeURIComponent(filterText).replace(/%20/g,'+'); } - window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}" + filter; + window.location.href = "{$thisURL}?page={$thisPage}&glm_action=contacts&member={$memberID}" + filter; return false; }); @@ -654,7 +654,7 @@ $("#deleteContactDialog").dialog("close"); }); $('#deleteContactSubmit').click( function() { - window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=delete&contact={$contactID}"); + window.location.replace("{$thisURL}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=delete&contact={$contactID}"); }); // Flash certain elements for a short time after display diff --git a/views/admin/members/contacts.html b/views/admin/members/contacts.html new file mode 100644 index 0000000..ae8d06c --- /dev/null +++ b/views/admin/members/contacts.html @@ -0,0 +1,75 @@ +{include file='admin/members/header.html'} + +
+ List Filters:   + Show Archived   +    + Search + +

Contacts

+ + + + + + + + + + + + + + + +{if $haveContacts} + {foreach $contacts as $c} + + + + + + + + + + + {/foreach} +{else} + +{/if} + +
NameActiveTypeAccessUserEntityOrganizationLocation
{$c.lname}, {$c.fname}{$c.active.name}{$c.contact_type.name}{$c.access.name}{$c.contact_role_short.name} + {$c.ref_type.name}: + {$c.ref_dest_name} + {$c.org}{$c.city.name}, {$c.state.name}
(no contacts listed)
+ + + + + +{include file='admin/footer.html'} diff --git a/views/admin/profile/header.html b/views/admin/profile/header.html index 7717c57..1186e17 100644 --- a/views/admin/profile/header.html +++ b/views/admin/profile/header.html @@ -1,9 +1,9 @@

Your Contact and Log-in Profile

diff --git a/views/admin/profile/index.html b/views/admin/profile/index.html index 17cba20..bee564f 100644 --- a/views/admin/profile/index.html +++ b/views/admin/profile/index.html @@ -9,7 +9,7 @@

{if $contactUpdated}

Contact Updated

{/if} -
+ @@ -102,7 +102,7 @@
- +
@@ -113,7 +113,7 @@ {/if} New image: -
+
{if $contactInfo.fieldFail.image}

{$contactInfo.fieldFail.image}

{/if} @@ -271,7 +271,7 @@ Image: {if $contactInfo.fieldData.image} - + {/if}