From: Chuck Scott Date: Tue, 9 Jun 2015 18:00:09 +0000 (-0400) Subject: Added test for glm_members_info capability to display dashboard widget. Work in progr... X-Git-Tag: v1.0.0~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=42624ba30e3edf51056d9468b50b0ab0581a7317;p=WP-Plugins%2Fglm-member-db.git Added test for glm_members_info capability to display dashboard widget. Work in progress on restructuring settings. --- diff --git a/classes/data/dataAccommodationTypes.php b/classes/data/dataAccommodationTypes.php index 9c6f81a4..c87ab977 100644 --- a/classes/data/dataAccommodationTypes.php +++ b/classes/data/dataAccommodationTypes.php @@ -24,7 +24,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataAccommodationTypes extends GlmDataAbstract { diff --git a/classes/data/dataAmenities.php b/classes/data/dataAmenities.php index 4f2ba294..ee49098c 100644 --- a/classes/data/dataAmenities.php +++ b/classes/data/dataAmenities.php @@ -24,7 +24,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataAmenities extends GlmDataAbstract { diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index dca59b47..5f1062e3 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -24,7 +24,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataCategories extends GlmDataAbstract { diff --git a/classes/data/dataCategoryMemberInfo.php b/classes/data/dataCategoryMemberInfo.php index b2d25479..447d0ee4 100644 --- a/classes/data/dataCategoryMemberInfo.php +++ b/classes/data/dataCategoryMemberInfo.php @@ -24,7 +24,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataCategoryMemberInfo extends GlmDataAbstract { diff --git a/classes/data/dataCities.php b/classes/data/dataCities.php index 8ff06514..35396aaf 100644 --- a/classes/data/dataCities.php +++ b/classes/data/dataCities.php @@ -24,7 +24,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataCities extends GlmDataAbstract { diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index 893725cd..ced7e2ec 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -23,7 +23,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataMemberInfo extends GlmDataAbstract { diff --git a/classes/data/dataMemberTypes.php b/classes/data/dataMemberTypes.php index def4de57..92cd7976 100644 --- a/classes/data/dataMemberTypes.php +++ b/classes/data/dataMemberTypes.php @@ -24,7 +24,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataMemberTypes extends GlmDataAbstract { diff --git a/classes/data/dataMembers.php b/classes/data/dataMembers.php index 6929d50f..753c5728 100644 --- a/classes/data/dataMembers.php +++ b/classes/data/dataMembers.php @@ -23,7 +23,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataMembers extends GlmDataAbstract { diff --git a/classes/data/dataRegions.php b/classes/data/dataRegions.php index be26b2c1..571df300 100644 --- a/classes/data/dataRegions.php +++ b/classes/data/dataRegions.php @@ -24,7 +24,6 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ - * @link http://www.visitgreatlakesbay.org/ */ class GlmDataRegions extends GlmDataAbstract { diff --git a/classes/data/settings/dataSettingsGeneral.php b/classes/data/settings/dataSettingsGeneral.php new file mode 100644 index 00000000..37100b18 --- /dev/null +++ b/classes/data/settings/dataSettingsGeneral.php @@ -0,0 +1,391 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataSettingsGeneral.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * EventManagementDataSettingsGeneral class + * + * PHP version 5 + * + * @category Data + * @package EventManagement + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataSettingsGeneral 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_PLUGIN_DB_PREFIX . 'settings_general'; + + /* + * Table Data Fields + */ + $this->fields = array( + + 'id' => array( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + /* + * Debug Options + */ + + // Adming Debug + 'admin_debug' => array( + 'field' => 'admin_debug', + 'type' => 'boolean', + 'use' => 'a' + ), + + // Adming Debug Verbose + 'admin_debug_verbose' => array( + 'field' => 'admin_debug_verbose', + 'type' => 'boolean', + 'use' => 'a' + ), + + // Front-end Debug + 'front_debug' => array( + 'field' => 'front_debug', + 'type' => 'boolean', + 'use' => 'a' + ), + + // Front-end Debug Verbose + 'front_debug_verbose' => array( + 'field' => 'front_debug_verbose', + 'type' => 'checkbox', + 'use' => 'a' + ), + + /* + * Google Maps + */ + + // Google Maps API Key + 'google_maps_api_key' => array( + 'field' => 'google_maps_api_key', + 'type' => 'text', + 'use' => 'lg' + ), + + // Google Maps Default Latitude + 'maps_default_lat' => array( + 'field' => 'maps_default_lat', + 'type' => 'float', + 'use' => 'a' + ), + + // Google Maps Default Longitude + 'maps_default_lon' => array( + 'field' => 'maps_default_lon', + 'type' => 'float', + 'use' => 'a' + ), + + /* + * Misc Settings + */ + + // Time Zone + 'time_zone' => array( + 'field' => 'time_zone', + 'type' => 'text', + 'use' => 'lg' + ), + + /* + * Front-end Member Search Options + */ + + // Front-end Listings - Show Map + 'list_show_map' => array( + 'field' => 'list_show_map', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show List + 'list_show_list' => array( + 'field' => 'list_show_list', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Search Form + 'list_show_search' => array( + 'field' => 'list_show_search', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Search Text + 'list_show_search_text' => array( + 'field' => 'list_show_search_text', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Search Category + 'list_show_search_category' => array( + 'field' => 'list_show_search_category', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Search Amenities + 'list_show_search_amenities' => array( + 'field' => 'list_show_search_amenities', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'lg' + ), + + // Front-end Listings - Show Search Alpha + 'list_show_search_alpha' => array( + 'field' => 'list_show_search_alpha', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + /* + * Front-end Member Listing Options + */ + + // Front-end Listings - Show Detail Link + 'list_show_detail_link' => array( + 'field' => 'list_show_detail_link', + 'type' => 'checkbox', + 'use' => 'lg' + ), + + // Front-end Listings - Show Logo + 'list_show_logo' => array( + 'field' => 'list_show_logo', + 'type' => 'checkbox', + 'use' => 'lg' + ), + + // Front-end Listings - Logo Size + 'list_logo_size' => array( + 'field' => 'list_logo_size', + 'type' => 'list', + 'list' => $this->config['image_sizes'], + 'required' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Address + 'list_show_address' => array( + 'field' => 'list_show_address', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Street + 'list_show_street' => array( + 'field' => 'list_show_Street', + 'type' => 'checkbox', + 'use' => 'lg' + ), + + // Front-end Listings - Show City, State, ZIP + 'list_show_citystatezip' => array( + 'field' => 'list_show_citystatezip', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show country + 'list_show_country' => array( + 'field' => 'list_show_country', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Region + 'list_show_region' => array( + 'field' => 'list_show_region', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Description + 'list_show_descr' => array( + 'field' => 'list_show_descr', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'lg' + ), + + // Front-end Listings - Show Short Description + 'list_show_short_descr' => array( + 'field' => 'list_show_short_descr', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show phone + 'list_show_phone' => array( + 'field' => 'list_show_phone', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Toll Free + 'list_show_tollfree' => array( + 'field' => 'list_show_tollfree', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show URL + 'list_show_url' => array( + 'field' => 'list_show_url', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Categories + 'list_show_categories' => array( + 'field' => 'list_show_categories', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Credit Cards + 'list_show_logo' => array( + 'field' => 'list_show_creditcards', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'lg' + ), + + // Front-end Listings - Show Amenities + 'list_show_amenities' => array( + 'field' => 'list_show_amenities', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'lg' + ), + + + + + + + + ); + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table); + } + + } +} + +?> \ No newline at end of file diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 71e599e3..43b1775c 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -89,6 +89,7 @@ class GlmPluginSupport default; $notices = get_option('glmMembersAdminNotices'); $notices[] = $message; +//$notices = array(); update_option('glmMembersAdminNotices', $notices); break; diff --git a/config/plugin.ini b/config/plugin.ini index cb379d64..328ded26 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -34,6 +34,11 @@ thumb['crop'] = null [common] +image_sizes['large'] = 'Large' +image_sizes['medium'] = 'Medium' +image_sizes['small'] = 'Small' +image_sizes['thumb'] = 'Thumbnail' + ; ; Site Configuration Options ; diff --git a/controllers/admin.php b/controllers/admin.php index f1c9e93a..1868820b 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -30,13 +30,13 @@ $GLOBALS['glmMembersAdminValidActions'] = array( 'index' ), 'members' => array( - 'index', // member list + 'index', // member list 'list', 'reports', 'other' ), 'member' => array( - 'index', // Member Dashboard + 'index', // Member Dashboard 'memberInfo', 'locations', 'facilities', @@ -45,13 +45,15 @@ $GLOBALS['glmMembersAdminValidActions'] = array( ) , 'configure' => array( - 'index', - 'memberTypes', + 'index', // Member Types 'categories', 'cities', 'regions', 'accommodationTypes', 'amenities', + ), + 'settings' => array( + 'index', // General Options 'development' ), 'shortcodes' => array( @@ -66,6 +68,9 @@ $GLOBALS['glmMembersAdminValidActions'] = array( // Load glmPluginSupport class require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php'); +// Load Smarty Template Support +require (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php'); + /** * Admin Controller Class * @@ -214,6 +219,13 @@ class glmMembersAdmin extends GlmPluginSupport )); +/* + add_action( 'admin_init', + array( + $this, + 'glmMembersAdminSettingsInit' + )); +*/ } /** @@ -325,6 +337,15 @@ class glmMembersAdmin extends GlmPluginSupport 'glmMembersAdminMenuConfigure' )); + // Add a submenu for the "Settings" section + add_submenu_page('glm-members-admin-menu-members', + 'Member DB Settings', 'Settings', + 'glm_members_settings', 'glm-members-admin-menu-settings', + array( + $this, + 'glmMembersAdminMenuSettings' + )); + // Add a submenu for the "Shortcode Reference" section add_submenu_page('glm-members-admin-menu-members', 'Shortcode Reference', 'Shortcodes', @@ -349,15 +370,18 @@ class glmMembersAdmin extends GlmPluginSupport public function glmMembersAdminDashboardWidget () { - wp_add_dashboard_widget( - 'glm_members_admin_dashboard_widget', - 'Member DB Summary', - array( - $this, - 'glmMembersAdminDashboardContent' - ) - ); + if ( current_user_can( 'glm_members_info' ) ) { + wp_add_dashboard_widget( + 'glm_members_admin_dashboard_widget', + 'Member DB Summary', + array( + $this, + 'glmMembersAdminDashboardContent' + ) + ); + + } } /** @@ -412,6 +436,11 @@ class glmMembersAdmin extends GlmPluginSupport $this->controller('configure'); } + public function glmMembersAdminMenuSettings () + { + $this->controller('settings'); + } + public function glmMembersAdminMenuShortcodes () { $this->controller('shortcodes'); @@ -679,7 +708,6 @@ class glmMembersAdmin extends GlmPluginSupport */ // Load Smarty Template support - require (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php'); $smarty = new smartyTemplateSupport(); // Add standard template parameters @@ -723,9 +751,11 @@ class glmMembersAdmin extends GlmPluginSupport $templateVars = '
' . print_r($x, 1) . '
'; 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 diff --git a/glm-member-db.php b/glm-member-db.php index 1faa4713..c89d96d9 100644 --- a/glm-member-db.php +++ b/glm-member-db.php @@ -336,6 +336,7 @@ function glmMembersAdminNotices($windowed = true) $output .= '
  • '.$d['title'].'
  • '; } } + $output .= '
    '; if (is_array($dataBlocks)) { reset($dataBlocks); @@ -350,6 +351,7 @@ function glmMembersAdminNotices($windowed = true) '; } } + delete_option('glmMembersAdminNoticeDataBlocks'); echo $output.' diff --git a/misc/databaseScripts/create_database_V0.1.sql b/misc/databaseScripts/create_database_V0.1.sql index cef9e18f..85dd1b12 100644 --- a/misc/databaseScripts/create_database_V0.1.sql +++ b/misc/databaseScripts/create_database_V0.1.sql @@ -473,6 +473,51 @@ CREATE TABLE {prefix}restaurants ( ---- +CREATE TABLE {prefix}settings_general ( + id INT NOT NULL AUTO_INCREMENT, + admin_debug BOOLEAN NULL, + admin_debug_verbose BOOLEAN NULL, + front_debug BOOLEAN NULL, + front_debug_verbose BOOLEAN NULL, + google_maps_api_key TINYTEXT NULL, + maps_default_lat FLOAT NULL, + maps_default_lon FLOAT NULL, + time_zone TINYTEXT NULL, + list_show_map BOOLEAN NULL, + list_show_list BOOLEAN NULL, + list_show_search BOOLEAN NULL, + list_show_search_category BOOLEAN NULL, + list_show_search_amenities BOOLEAN NULL, + list_show_search_alphja BOOLEAN NULL, + list_show_detail_link BOOLEAN NULL, + list_show_logo BOOLEAN NULL, + list_logo_size TINYTEXT NULL, + list_show_address BOOLEAN NULL, + list_show_street BOOLEAN NULL, + list_show_citystatezip BOOLEAN NULL, + list_show_country BOOLEAN NULL, + list_show_region BOOLEAN NULL, + list_show_descr BOOLEAN NULL, + list_show_short_descr BOOLEAN NULL, + list_show_phone BOOLEAN NULL, + list_show_tollfree BOOLEAN NULL, + list_show_url BOOLEAN NULL, + list_show_categories BOOLEAN NULL, + list_show_creditcards BOOLEAN NULL, + list_show_amenities BOOLEAN NULL, + + PRIMARY KEY (id) +); + +---- + +CREATE TABLE {prefix}settings_terms ( + id INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) +); + +---- + CREATE TABLE {prefix}social_media ( id INT NOT NULL AUTO_INCREMENT, name TINYTEXT NULL, diff --git a/misc/databaseScripts/drop_database_V0.1.sql b/misc/databaseScripts/drop_database_V0.1.sql index 45cbfe3c..2c792d88 100644 --- a/misc/databaseScripts/drop_database_V0.1.sql +++ b/misc/databaseScripts/drop_database_V0.1.sql @@ -27,6 +27,8 @@ DROP TABLE {prefix}regions, {prefix}restaurant_types, {prefix}restaurants, + {prefix}settings_general, + {prefix}settings_terms, {prefix}social_media, {prefix}social_media_ref ; diff --git a/misc/smarty/templates_c/3ec5bcbe581d6335e06bc6c9474f73121a83d59b.file.header.html.php b/misc/smarty/templates_c/3ec5bcbe581d6335e06bc6c9474f73121a83d59b.file.header.html.php index fb4f3655..ed517532 100644 --- a/misc/smarty/templates_c/3ec5bcbe581d6335e06bc6c9474f73121a83d59b.file.header.html.php +++ b/misc/smarty/templates_c/3ec5bcbe581d6335e06bc6c9474f73121a83d59b.file.header.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '3ec5bcbe581d6335e06bc6c9474f73121a83d59b' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/configure/header.html', - 1 => 1422326142, + 1 => 1433353557, 2 => 'file', ), ), @@ -34,28 +34,22 @@ $_valid = $_smarty_tpl->decodeProperties(array (
    diff --git a/misc/smarty/templates_c/47fb9b803e7138d215645f3c977b0b1dc2a9e718.file.index.html.php b/misc/smarty/templates_c/47fb9b803e7138d215645f3c977b0b1dc2a9e718.file.index.html.php index 04744489..8c5bfbf3 100644 --- a/misc/smarty/templates_c/47fb9b803e7138d215645f3c977b0b1dc2a9e718.file.index.html.php +++ b/misc/smarty/templates_c/47fb9b803e7138d215645f3c977b0b1dc2a9e718.file.index.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '47fb9b803e7138d215645f3c977b0b1dc2a9e718' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/configure/index.html', - 1 => 1421691086, + 1 => 1433354735, 2 => 'file', ), ), @@ -15,17 +15,193 @@ $_valid = $_smarty_tpl->decodeProperties(array ( 'function' => array ( ), - 'has_nocache_code' => false, 'version' => 'Smarty-3.1.21-dev', 'unifunc' => 'content_54c0496da75c57_83289225', + 'variables' => + array ( + 'thisURL' => 0, + 'thisPage' => 0, + 'haveMemberTypes' => 0, + 'memberTypes' => 0, + 'i' => 0, + 't' => 0, + ), + 'has_nocache_code' => false, ),false); /*/%%SmartyHeaderCode%%*/?> getSubTemplate ('admin/configure/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> + + +
    Add a Member Type
    +
    +
    + + + + + + + + + + + + +
    Member Type Name: + +
    Description: + +
    +

    * Required

    + Cancel + +
    +
    + + +
    +
    +

    Are you sure you want to delete this member type?

    +

    Yes, delete this member type

    +

    Cancel

    +
    +
    + + +
    +
    + + + + + + + + + + + + +
    Member Type Name: + +
    Description: + +
    +

    * Required

    + Cancel + +
    +
    -

    General Configuration

    - -

    General configuration options go here.

    - +

    Member Types

    + + + + + + + + + + +tpl_vars['haveMemberTypes']->value) {?> + tpl_vars["i"])) {$_smarty_tpl->tpl_vars["i"] = clone $_smarty_tpl->tpl_vars["i"]; +$_smarty_tpl->tpl_vars["i"]->value = "0"; $_smarty_tpl->tpl_vars["i"]->nocache = null; $_smarty_tpl->tpl_vars["i"]->scope = 0; +} else $_smarty_tpl->tpl_vars["i"] = new Smarty_variable("0", null, 0);?> + tpl_vars['t'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['t']->_loop = false; + $_from = $_smarty_tpl->tpl_vars['memberTypes']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');} +foreach ($_from as $_smarty_tpl->tpl_vars['t']->key => $_smarty_tpl->tpl_vars['t']->value) { +$_smarty_tpl->tpl_vars['t']->_loop = true; +?> + tpl_vars['i']->value++ / 1)) {?> + + + + + + + + + + + + + +
    Member TypeDescription 
    + tpl_vars['t']->value['name'];?> + + + tpl_vars['t']->value['descr'];?> + + +
    Delete
    +
    (no member types listed)
    + + + type="text/javascript"> + jQuery(document).ready(function($) { + + $("#newMemberTypeDialog").dialog({ + autoOpen: false, + minWidth: 400, + dialogClass: "glm-dialog-no-close" + }); + $("#editMemberTypeDialog").dialog({ + autoOpen: false, + minWidth: 400, + dialogClass: "glm-dialog-no-close" + }); + $("#deleteMemberTypeDialog").dialog({ + autoOpen: false, + minWidth: 400, + dialogClass: "glm-dialog-no-close" + }); + + $('#newMemberTypeButton').click( function() { + $("#newMemberTypeDialog").dialog("open"); + }); + $('.editMemberType').click( function() { + var typeID = $(this).attr('data-memberTypeID'); + var typeName = $(this).text(); + var typeDescr = $('#editMemberTypeDescr_' + typeID).html(); + $('#editMemberTypeID').val(typeID); + $('#editMemberTypeName').val(typeName.trim()); + $('#editMemberTypeDescr').val(typeDescr.trim()); + $("#editMemberTypeDialog").dialog("open"); + }); + $('#editMemberTypeCancel').click( function() { + $("#editMemberTypeDialog").dialog("close"); + }); + $('#newMemberTypeCancel').click( function() { + $("#newMemberTypeDialog").dialog("close"); + }); + + var id = false; + $('.deleteMemberTypeButton').click( function() { + id = $(this).attr('data-memberTypeID'); + $("#deleteMemberTypeDialog").dialog("open"); + }); + $('#deleteMemberTypeConfirm').click( function() { + $("#deleteMemberTypeDialog").dialog("close"); + window.location.href = "tpl_vars['thisURL']->value;?> +?page=tpl_vars['thisPage']->value;?> +&glm_action=index&option=delete&id=" + id; + }); + $('#deleteMemberTypeCancel').click( function() { + $("#deleteMemberTypeDialog").dialog("close"); + }); + + }); + +> + getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> diff --git a/models/admin/configure/development.php b/models/admin/configure/development.php deleted file mode 100644 index bcf34310..00000000 --- a/models/admin/configure/development.php +++ /dev/null @@ -1,345 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 0.1 - */ - -/* - * This class performs the work for the default action of the "Members" menu - * option, which is to display the members dashboard. - * - */ -class GlmMembersAdmin_configure_development -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - - /* - * Constructor - * - * This contructor sets up this model. At this time that only includes - * storing away the WordPress data object. - * - * @return object Class object - * - */ - public function __construct ($wpdb, $config) - { - - // Save WordPress Database object - $this->wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - } - - /* - * Perform Model Action - * - * This method does the work for this model and returns any resulting data - * - * @return array Status and data array - * - * '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. - * - */ - public function modelAction ($actionData = false) - { - - // Get current database version - $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION; - settype($dbVersion, 'string'); - - $templateData['resultMessage'] = ''; - $templateData['success'] = false; - $templateData['haveNotices'] = false; - $notices = array(); - $templateData['haveMembers'] = false; - $templateData['import'] = false; - $templateData['importNotice'] = false; - $templateData['haveDatabaseTableList'] = false; - - // Load database activation class to get access to database version information - require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php'); - $activate = new glmMembersPluginActivate($this->wpdb, $this->config, true); - - $option = ''; - if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') { - $option = $_REQUEST['option']; - } - - switch($option) { - - case 'import_connections': - - // Load Member Info Data Class and get info data for later use - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/glmMemberImportFromConnections.php'); - $Connections = new GlmMemberImportFromConnections($this->wpdb, $this->config); - - if (isset($_REQUEST['import']) && $_REQUEST['import'] == 'now') { - - // Reset the database - if (!$this->deleteDataTables($dbVersion)) { - glmMembersAdmin::addNotice('Unable to delete the database tables while resetting the database.
    ', 'AdminError'); - break; - } - if (!$this->createDataTables($dbVersion)) { - glmMembersAdmin::addNotice('Unable to create the database tables while resetting the database.
    ', 'AdminError'); - break; - } - glmMembersAdmin::addNotice('Database tables have been reset in preparation importing members.
    ', 'AdminNotice'); - - // Delete Images - foreach( new RecursiveIteratorIterator( - new RecursiveDirectoryIterator( GLM_MEMBERS_PLUGIN_IMAGES_PATH, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS ), - RecursiveIteratorIterator::CHILD_FIRST ) as $value ) { - if ($value->isFile()) { - unlink( $value ); - } - } - - $templateData['import'] = true; - $templateData['membersImported'] = $Connections->doImport(); - - } else { - - // Check if Connections is not installed or not active. If active, gets count of entries. - $c = $Connections->checkConnections(); - if ($c === false) { - glmMembersAdmin::addNotice('Connections Business Directory plugin is not installed or not active!
    '.print_r($c,1), 'AdminError'); - break; - } - $templateData['numbEntries'] = $c; - $importNotice = 'Connections Business Directory plugin is active.
    Number of businesses listed: '.$c.'
    '; - - // Get the basic business data for review. - $templateData['members'] = $Connections->getList(); - if ($templateData['members'] === false) { - $importNotice = 'No businesses were retieved.'; - break; - } - - $templateData['haveMembers'] = true; - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice($templateData['members'], 'DataBlock', 'Base Members Data'); - } - - } - - break; - - case 'drop': - case 'reset': - - $del = $this->deleteDataTables($dbVersion); - - if ($del) { - glmMembersAdmin::addNotice('New database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin have been deleted.', 'AdminNotice'); - - } - - if ($option != 'reset') { - break; - } - - case 'create': - - $create = $this->createDataTables($dbVersion); - - // If there were no errors - if ($create) { - - // Notify the user that the database has been installed - glmMembersAdmin::addNotice('New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.', 'AdminNotice'); - - // Save the version of the installed database - update_option('glmMembersDatabaseDbVersion', $dbVersion); - - } - - break; - - case 'list': - - // Check if the database version set for this plugin is invalid. - if (!isset($activate->dbVersions[$dbVersion])) { - $resultMessage .= "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.
    "; - break; - } - - // Get the number of tables for this plugin database version that should exist. - $tables = $activate->dbVersions[$dbVersion]['tables']; - - // Get the number of tables for this plugin that do currently exist. - $existingTables = $this->wpdb->get_results(" - SELECT table_name - FROM information_schema.tables - WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%'; - ", ARRAY_A); - - if (is_array($existingTables)) { - - $ - - - $resultMessage .= 'Current database tables
      '; - foreach($existingTables as $t){ - $resultMessage .= "
    • ".$t['table_name'].'

    • '; - } - $resultMessage .= '
    '; - } else { - $resultMessage .= 'No tables currently exist
    '; - } - - break; - - default: - - break; - - } - - // Return status, suggested view, and data to controller - return array( - 'status' => true, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/configure/development.html', - 'data' => $templateData - ); - - } - - /* - * Delete Members Database Tables - * - * @param string $dbVersion Current version of Members Database - * - * @return boolean - * @access public - */ - public function deleteDataTables($dbVersion) - { - - // Read in Database deletion script - assumes the current db version. - $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/drop_database_V'.$dbVersion.'.sql'; - $sql = file_get_contents($sqlFile); - - // Replace {prefix} with table name prefix - $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql); - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice('Dropping all database tables', 'Process'); - glmMembersAdmin::addNotice($sql, 'DataBlock', 'Drop Tables SQL'); - } - - // Removing the tables using the script - $this->wpdb->query($sql); - - // If there's been an error, display in debug Alert - $queryError = $this->wpdb->last_error; - if ($queryError) { - glmMembersAdmin::addNotice('Error when deleting database: Database tables may not have existed.
    Check following message.
    '.$queryError, 'AdminError'); - return false; - } - - return true; - - } - - /* - * Create Members Database Tables - * - * @param string $dbVersion Current version of Members Database - * - * @return boolean - * @access public - */ - public function createDataTables($dbVersion) - { - - // Read in Database creation script - $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/create_database_V'.$dbVersion.'.sql'; - $sql = file_get_contents($sqlFile); - - // Replace {prefix} with table name prefix - $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql); - - // Split script into separate queries by looking for lines with only "---" - $queries = preg_split('/^----$/m', $sql); - - // Try executing all queries to build database - $qForDebug = ''; - do { - $q = current($queries); - $this->wpdb->query($q); - $queryError = $this->wpdb->last_error; - - if ($queryError) { - glmMembersAdmin::addNotice('Error when creating database: Database tables may already exist.
    Check following message.
    '.$queryError, 'AdminError'); - return false; - } - $qForDebug .= $queryError.$q; - - } while ($queryError == '' && next($queries)); - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice('Creating database tables', 'Process'); - glmMembersAdmin::addNotice($qForDebug, 'DataBlock', 'Create Tables SQL'); - } - - return true; - - } - -} - -?> \ No newline at end of file diff --git a/models/admin/configure/index.php b/models/admin/configure/index.php index 3d236634..4b42f0da 100644 --- a/models/admin/configure/index.php +++ b/models/admin/configure/index.php @@ -2,7 +2,7 @@ /** * Gaslight Media Members Database - * Admin Configure + * Admin Member Type List * * PHP version 5.5 * @@ -13,12 +13,15 @@ * @version 0.1 */ +// Load Member Types data abstract +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberTypes.php'); + /* * This class performs the work for the default action of the "Members" menu * option, which is to display the members dashboard. * */ -class GlmMembersAdmin_configure_index +class GlmMembersAdmin_configure_index extends GlmDataMemberTypes { /** @@ -54,6 +57,9 @@ class GlmMembersAdmin_configure_index // Save plugin configuration object $this->config = $config; + // Run constructor for members data class + parent::__construct(false, false); + } /* @@ -93,17 +99,86 @@ class GlmMembersAdmin_configure_index public function modelAction ($actionData = false) { - // Determine if current user can add, edit, delete member data - $canEdit = current_user_can('glm_members_edit'); + $success = true; + $haveMemberTypes = false; + $memberTypes = false; + $error = false; + + // Check for member type id + $id = 0; + if (isset($_REQUEST['id'])) { + $id = $_REQUEST['id']-0; + } + + // If there's an action option + if (isset($_REQUEST['option'])) { + + switch($_REQUEST['option']) { + + case 'addNew': + $this->insertEntry(); + break; + + case 'update': + if ($id > 0) { + $this->updateEntry($id); + } + break; + + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); + } + break; + + } + + } + + // Get a current list of member types + $memberTypes = $this->getList(); + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Type Data'); + } + + // If we have list entries - even if it's an empty list + $success = true; + $haveMemberTypes = false; + if ($memberTypes !== false) { + + $success = true; + + // If we have any entries + if (count($memberTypes) > 0) { + $haveMemberTypes = true; + } + } + + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); + } // Compile template data $templateData = array( - 'canEdit' => $canEdit + 'haveMemberTypes' => $haveMemberTypes, + 'memberTypes' => $memberTypes ); // Return status, suggested view, and data to controller return array( - 'status' => true, + 'status' => $success, 'menuItemRedirect' => false, 'modelRedirect' => false, 'view' => 'admin/configure/index.html', @@ -112,6 +187,7 @@ class GlmMembersAdmin_configure_index } + } ?> \ No newline at end of file diff --git a/models/admin/configure/memberTypes.php b/models/admin/configure/memberTypes.php deleted file mode 100644 index 524fa468..00000000 --- a/models/admin/configure/memberTypes.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 0.1 - */ - -// Load Member Types data abstract -require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberTypes.php'); - -/* - * This class performs the work for the default action of the "Members" menu - * option, which is to display the members dashboard. - * - */ -class GlmMembersAdmin_configure_memberTypes extends GlmDataMemberTypes -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - - /* - * Constructor - * - * This contructor sets up this model. At this time that only includes - * storing away the WordPress data object. - * - * @return object Class object - * - */ - 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); - - } - - /* - * Perform Model Action - * - * This method does the work for this model and returns any resulting data - * - * @return array Status and data array - * - * '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. - * - */ - public function modelAction ($actionData = false) - { - - $success = true; - $haveMemberTypes = false; - $memberTypes = false; - $error = false; - - // Check for member type id - $id = 0; - if (isset($_REQUEST['id'])) { - $id = $_REQUEST['id']-0; - } - - // If there's an action option - if (isset($_REQUEST['option'])) { - - switch($_REQUEST['option']) { - - case 'addNew': - $this->insertEntry(); - break; - - case 'update': - if ($id > 0) { - $this->updateEntry($id); - } - break; - - case 'delete': - if ($id > 0) { - $this->deleteEntry($id, true); - } - break; - - } - - } - - // Get a current list of member types - $memberTypes = $this->getList(); - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { - glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Type Data'); - } - - // If we have list entries - even if it's an empty list - $success = true; - $haveMemberTypes = false; - if ($memberTypes !== false) { - - $success = true; - - // If we have any entries - if (count($memberTypes) > 0) { - $haveMemberTypes = true; - } - } - - // If we had a fatal error, redirect to the error page - if ($error) { - return array( - 'status' => $success, - 'menuItemRedirect' => 'error', - 'modelRedirect' => 'index', - 'view' => 'admin/error/index.html', - 'data' => false - ); - } - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { - glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); - } - - // Compile template data - $templateData = array( - 'haveMemberTypes' => $haveMemberTypes, - 'memberTypes' => $memberTypes - ); - - // Return status, suggested view, and data to controller - return array( - 'status' => $success, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/configure/memberTypes.html', - 'data' => $templateData - ); - - } - - -} - -?> \ No newline at end of file diff --git a/models/admin/settings/development.php b/models/admin/settings/development.php new file mode 100644 index 00000000..bded5bda --- /dev/null +++ b/models/admin/settings/development.php @@ -0,0 +1,345 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_settings_development +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * '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. + * + */ + public function modelAction ($actionData = false) + { + + // Get current database version + $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION; + settype($dbVersion, 'string'); + + $templateData['resultMessage'] = ''; + $templateData['success'] = false; + $templateData['haveNotices'] = false; + $notices = array(); + $templateData['haveMembers'] = false; + $templateData['import'] = false; + $templateData['importNotice'] = false; + $templateData['haveDatabaseTableList'] = false; + + // Load database activation class to get access to database version information + require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php'); + $activate = new glmMembersPluginActivate($this->wpdb, $this->config, true); + + $option = ''; + if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') { + $option = $_REQUEST['option']; + } + + switch($option) { + + case 'import_connections': + + // Load Member Info Data Class and get info data for later use + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/glmMemberImportFromConnections.php'); + $Connections = new GlmMemberImportFromConnections($this->wpdb, $this->config); + + if (isset($_REQUEST['import']) && $_REQUEST['import'] == 'now') { + + // Reset the database + if (!$this->deleteDataTables($dbVersion)) { + glmMembersAdmin::addNotice('Unable to delete the database tables while resetting the database.
    ', 'AdminError'); + break; + } + if (!$this->createDataTables($dbVersion)) { + glmMembersAdmin::addNotice('Unable to create the database tables while resetting the database.
    ', 'AdminError'); + break; + } + glmMembersAdmin::addNotice('Database tables have been reset in preparation importing members.
    ', 'AdminNotice'); + + // Delete Images + foreach( new RecursiveIteratorIterator( + new RecursiveDirectoryIterator( GLM_MEMBERS_PLUGIN_IMAGES_PATH, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS ), + RecursiveIteratorIterator::CHILD_FIRST ) as $value ) { + if ($value->isFile()) { + unlink( $value ); + } + } + + $templateData['import'] = true; + $templateData['membersImported'] = $Connections->doImport(); + + } else { + + // Check if Connections is not installed or not active. If active, gets count of entries. + $c = $Connections->checkConnections(); + if ($c === false) { + glmMembersAdmin::addNotice('Connections Business Directory plugin is not installed or not active!
    '.print_r($c,1), 'AdminError'); + break; + } + $templateData['numbEntries'] = $c; + $importNotice = 'Connections Business Directory plugin is active.
    Number of businesses listed: '.$c.'
    '; + + // Get the basic business data for review. + $templateData['members'] = $Connections->getList(); + if ($templateData['members'] === false) { + $importNotice = 'No businesses were retieved.'; + break; + } + + $templateData['haveMembers'] = true; + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + glmMembersAdmin::addNotice($templateData['members'], 'DataBlock', 'Base Members Data'); + } + + } + + break; + + case 'drop': + case 'reset': + + $del = $this->deleteDataTables($dbVersion); + + if ($del) { + glmMembersAdmin::addNotice('New database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin have been deleted.', 'AdminNotice'); + + } + + if ($option != 'reset') { + break; + } + + case 'create': + + $create = $this->createDataTables($dbVersion); + + // If there were no errors + if ($create) { + + // Notify the user that the database has been installed + glmMembersAdmin::addNotice('New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.', 'AdminNotice'); + + // Save the version of the installed database + update_option('glmMembersDatabaseDbVersion', $dbVersion); + + } + + break; + + case 'list': + + // Check if the database version set for this plugin is invalid. + if (!isset($activate->dbVersions[$dbVersion])) { + $templateData['resultMessage'] .= "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.
    "; + break; + } + + // Get the number of tables for this plugin database version that should exist. + $tables = $activate->dbVersions[$dbVersion]['tables']; + + // Get the number of tables for this plugin that do currently exist. + $existingTables = $this->wpdb->get_results(" + SELECT table_name + FROM information_schema.tables + WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%'; + ", ARRAY_A); + + if (is_array($existingTables)) { + + + + + $templateData['resultMessage'] .= 'Current database tables
      '; + foreach($existingTables as $t){ + $templateData['resultMessage'] .= "
    • ".$t['table_name'].'

    • '; + } + $templateData['resultMessage'] .= '
    '; + } else { + $templateData['resultMessage'] .= 'No tables currently exist
    '; + } + + break; + + default: + + break; + + } + + // Return status, suggested view, and data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/development.html', + 'data' => $templateData + ); + + } + + /* + * Delete Members Database Tables + * + * @param string $dbVersion Current version of Members Database + * + * @return boolean + * @access public + */ + public function deleteDataTables($dbVersion) + { + + // Read in Database deletion script - assumes the current db version. + $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/drop_database_V'.$dbVersion.'.sql'; + $sql = file_get_contents($sqlFile); + + // Replace {prefix} with table name prefix + $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql); + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + glmMembersAdmin::addNotice('Dropping all database tables', 'Process'); + glmMembersAdmin::addNotice($sql, 'DataBlock', 'Drop Tables SQL'); + } + + // Removing the tables using the script + $this->wpdb->query($sql); + + // If there's been an error, display in debug Alert + $queryError = $this->wpdb->last_error; + if ($queryError) { + glmMembersAdmin::addNotice('Error when deleting database: Database tables may not have existed.
    Check following message.
    '.$queryError, 'AdminError'); + return false; + } + + return true; + + } + + /* + * Create Members Database Tables + * + * @param string $dbVersion Current version of Members Database + * + * @return boolean + * @access public + */ + public function createDataTables($dbVersion) + { + + // Read in Database creation script + $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/create_database_V'.$dbVersion.'.sql'; + $sql = file_get_contents($sqlFile); + + // Replace {prefix} with table name prefix + $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql); + + // Split script into separate queries by looking for lines with only "---" + $queries = preg_split('/^----$/m', $sql); + + // Try executing all queries to build database + $qForDebug = ''; + do { + $q = current($queries); + $this->wpdb->query($q); + $queryError = $this->wpdb->last_error; + + if ($queryError) { + glmMembersAdmin::addNotice('Error when creating database: Database tables may already exist.
    Check following message.
    '.$queryError, 'AdminError'); + return false; + } + $qForDebug .= $queryError.$q; + + } while ($queryError == '' && next($queries)); + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + glmMembersAdmin::addNotice('Creating database tables', 'Process'); + glmMembersAdmin::addNotice($qForDebug, 'DataBlock', 'Create Tables SQL'); + } + + return true; + + } + +} + +?> \ No newline at end of file diff --git a/models/admin/settings/index.php b/models/admin/settings/index.php new file mode 100644 index 00000000..e5645f52 --- /dev/null +++ b/models/admin/settings/index.php @@ -0,0 +1,117 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_settings_index +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * '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. + * + */ + public function modelAction ($actionData = false) + { + + // Determine if current user can add, edit, delete member data + $canEdit = current_user_can('glm_members_edit'); + + // Compile template data + $templateData = array( + 'canEdit' => $canEdit + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/index.html', + 'data' => $templateData + ); + + } + +} + +?> \ No newline at end of file diff --git a/views/admin/configure/development.html b/views/admin/configure/development.html deleted file mode 100644 index 75e64211..00000000 --- a/views/admin/configure/development.html +++ /dev/null @@ -1,135 +0,0 @@ -{include file='admin/configure/header.html'} - -

    Note: Customers will not have access to this tab.

    - -

    Development Activities

    - -
      -
    • -

      Import

      -
        -
      • -

        - Import data from "Connections" business directory - - {if $importNotice} -

        {$importNotice}
        - {/if} -

        - - {if $import} - -

        Members imported: {$membersImported}

        - - {else} - {if $haveMembers} -
        -
        - Default data to use when importing members. - - - -
        Default member type:
        Default region name:
        -
        -

        - - Skip All   - Import All -

        -
        -
          -
        • *** THIS ACTION WILL FULLY RESET YOUR MEMBERS DATABASE ***
        • -
        • This action does not check for duplicate members!
        • -
        -
        - - - - - - - - - - - - - - - - - - {foreach $members as $m} - - - - {assign var="i" value="0"} - {foreach $m.addresses as $a} - {if $i++ gt 1} - - - - {/if} - - - - - - - - - - {/foreach} - {/foreach} - -
        SkipNameAddr Line 1Addr Line 2Addr Line 3CityStateZIPCountryLat/Lon
        {$m.id}{$m.organization}
          {$a.line_1}{$a.line_2}{$a.line_3}{$a.city}{$a.state}{$a.zipcode}{$a.country}{$a.latitude|number_format:3:".":","}/{$a.longitude|number_format:3:".":","}
        -
        - {/if} - {/if} -
      • -
      -

      Database

      - -
    • -
    - -
    -

    Docuemtation and References

    -

    Data Abstract Class Documentation

    -
    -{if $resultMessage} -
    -

    Results

    - {$resultMessage} -
    -{/if} - -{if $haveMembers} - -{/if} - - -{include file='admin/footer.html'} diff --git a/views/admin/configure/header.html b/views/admin/configure/header.html index be5e15a1..5ce2e0c2 100644 --- a/views/admin/configure/header.html +++ b/views/admin/configure/header.html @@ -3,14 +3,12 @@

    {$glmPluginName} Configuration

    \ No newline at end of file diff --git a/views/admin/configure/index.html b/views/admin/configure/index.html index 6ac1fe55..0cbedb6d 100644 --- a/views/admin/configure/index.html +++ b/views/admin/configure/index.html @@ -1,7 +1,155 @@ {include file='admin/configure/header.html'} + + +
    Add a Member Type
    +
    +
    + + + + + + + + + + + + +
    Member Type Name: + +
    Description: + +
    +

    * Required

    + Cancel + +
    +
    + + +
    +
    +

    Are you sure you want to delete this member type?

    +

    Yes, delete this member type

    +

    Cancel

    +
    +
    + + +
    +
    + + + + + + + + + + + + +
    Member Type Name: + +
    Description: + +
    +

    * Required

    + Cancel + +
    +
    -

    General Configuration

    - -

    General configuration options go here.

    - +

    Member Types

    + + + + + + + + + + +{if $haveMemberTypes} + {assign var="i" value="0"} + {foreach $memberTypes as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + {/foreach} +{else} + +{/if} + +
    Member TypeDescription 
    + {$t.name} + + {$t.descr} + +
    Delete
    +
    (no member types listed)
    + + + {include file='admin/footer.html'} diff --git a/views/admin/configure/memberTypes.html b/views/admin/configure/memberTypes.html deleted file mode 100644 index 1756e4d9..00000000 --- a/views/admin/configure/memberTypes.html +++ /dev/null @@ -1,155 +0,0 @@ -{include file='admin/configure/header.html'} - - -
    Add a Member Type
    -
    -
    - - - - - - - - - - - - -
    Member Type Name: - -
    Description: - -
    -

    * Required

    - Cancel - -
    -
    - - -
    -
    -

    Are you sure you want to delete this member type?

    -

    Yes, delete this member type

    -

    Cancel

    -
    -
    - - -
    -
    - - - - - - - - - - - - -
    Member Type Name: - -
    Description: - -
    -

    * Required

    - Cancel - -
    -
    - -

    Member Types

    - - - - - - - - - - -{if $haveMemberTypes} - {assign var="i" value="0"} - {foreach $memberTypes as $t} - {if $i++ is odd by 1} - - {else} - - {/if} - - - - - {/foreach} -{else} - -{/if} - -
    Member TypeDescription 
    - {$t.name} - - {$t.descr} - -
    Delete
    -
    (no member types listed)
    - - - -{include file='admin/footer.html'} diff --git a/views/admin/settings/development.html b/views/admin/settings/development.html new file mode 100644 index 00000000..87ef9dd5 --- /dev/null +++ b/views/admin/settings/development.html @@ -0,0 +1,135 @@ +{include file='admin/settings/header.html'} + +

    Note: Customers will not have access to this tab.

    + +

    Development Activities

    + +
      +
    • +

      Import

      +
        +
      • +

        + Import data from "Connections" business directory + + {if $importNotice} +

        {$importNotice}
        + {/if} +

        + + {if $import} + +

        Members imported: {$membersImported}

        + + {else} + {if $haveMembers} +
        +
        + Default data to use when importing members. + + + +
        Default member type:
        Default region name:
        +
        +

        + + Skip All   + Import All +

        +
        +
          +
        • *** THIS ACTION WILL FULLY RESET YOUR MEMBERS DATABASE ***
        • +
        • This action does not check for duplicate members!
        • +
        +
        + + + + + + + + + + + + + + + + + + {foreach $members as $m} + + + + {assign var="i" value="0"} + {foreach $m.addresses as $a} + {if $i++ gt 1} + + + + {/if} + + + + + + + + + + {/foreach} + {/foreach} + +
        SkipNameAddr Line 1Addr Line 2Addr Line 3CityStateZIPCountryLat/Lon
        {$m.id}{$m.organization}
          {$a.line_1}{$a.line_2}{$a.line_3}{$a.city}{$a.state}{$a.zipcode}{$a.country}{$a.latitude|number_format:3:".":","}/{$a.longitude|number_format:3:".":","}
        +
        + {/if} + {/if} +
      • +
      +

      Database

      + +
    • +
    + +
    +

    Docuemtation and References

    +

    Data Abstract Class Documentation

    +
    +{if $resultMessage} +
    +
    + {$resultMessage} +
    +{/if} + +{if $haveMembers} + +{/if} + + +{include file='admin/footer.html'} diff --git a/views/admin/settings/header.html b/views/admin/settings/header.html new file mode 100644 index 00000000..a2ac3396 --- /dev/null +++ b/views/admin/settings/header.html @@ -0,0 +1,10 @@ +
    + +

    {$glmPluginName} Configuration

    + + +
    + \ No newline at end of file diff --git a/views/admin/settings/index.html b/views/admin/settings/index.html new file mode 100644 index 00000000..27995976 --- /dev/null +++ b/views/admin/settings/index.html @@ -0,0 +1,7 @@ +{include file='admin/settings/header.html'} + +

    General Settings

    + +

    General settings go here.

    + +{include file='admin/footer.html'} diff --git a/views/admin/settingsPage/index.html b/views/admin/settingsPage/index.html new file mode 100644 index 00000000..de804cf0 --- /dev/null +++ b/views/admin/settingsPage/index.html @@ -0,0 +1,14 @@ + +

    + +
    +

    My Plugin Options

    +
    + {php} settings_fields( 'glm-member-db-settings-group' ); {/php} + {php} do_settings_sections( 'glm-member-db-settings' ); {/php} + {php} submit_button(); {/php} +
    +