From: Chuck Scott Date: Sun, 15 Mar 2015 22:05:33 +0000 (-0400) Subject: Front end now working with [glm-member-list] and [glm-member-detail] short codes. X-Git-Tag: v1.0.0~51 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=5c138908a715c0f4a14bd19cdd682be2df7f233d;p=WP-Plugins%2Fglm-member-db.git Front end now working with [glm-member-list] and [glm-member-detail] short codes. --- diff --git a/classes/data/dataAccommodationTypes.php b/classes/data/dataAccommodationTypes.php index 38fd3794..9c6f81a4 100644 --- a/classes/data/dataAccommodationTypes.php +++ b/classes/data/dataAccommodationTypes.php @@ -88,11 +88,16 @@ class GlmDataAccommodationTypes extends GlmDataAbstract function __construct ($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name diff --git a/classes/data/dataAmenities.php b/classes/data/dataAmenities.php index f4277295..4f2ba294 100644 --- a/classes/data/dataAmenities.php +++ b/classes/data/dataAmenities.php @@ -88,11 +88,16 @@ class GlmDataAmenities extends GlmDataAbstract function __construct ($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index 3455e715..83629fa4 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -88,11 +88,16 @@ class GlmDataCategories extends GlmDataAbstract function __construct ($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name diff --git a/classes/data/dataCategoryMemberInfo.php b/classes/data/dataCategoryMemberInfo.php index 5e64e7a0..caceaed3 100644 --- a/classes/data/dataCategoryMemberInfo.php +++ b/classes/data/dataCategoryMemberInfo.php @@ -88,11 +88,16 @@ class GlmDataCategoryMemberInfo extends GlmDataAbstract function __construct ($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name diff --git a/classes/data/dataCities.php b/classes/data/dataCities.php index ac3679ef..1c9381c7 100644 --- a/classes/data/dataCities.php +++ b/classes/data/dataCities.php @@ -88,11 +88,16 @@ class GlmDataCities extends GlmDataAbstract function __construct ($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index e05a91c7..5cd019dc 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -86,11 +86,16 @@ class GlmDataMemberInfo extends GlmDataAbstract { function __construct($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name @@ -308,6 +313,33 @@ class GlmDataMemberInfo extends GlmDataAbstract { } + /* + * Find the active member info record for a specific member ID + * + * @param integer $member ID of the member + * + * @return integer Member info record ID or false if not found + */ + public function getActiveInfoForMember($member) { + + $memberID = $member - 0; + + $sql = " + SELECT id + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info + WHERE member = $memberID + AND status = ".$this->config['status_numb']['Active']." + ;"; + $memberInfo = $this->wpdb->get_row($sql, ARRAY_A); + + if ($memberInfo) { + return $memberInfo['id']; + } + + return false; + + } + /* * Entry Post Processing Call-Back Method * @@ -325,8 +357,8 @@ class GlmDataMemberInfo extends GlmDataAbstract { public function entryPostProcessing($r, $a) { - // Only run these tests for 'l' (getList) - if ($a != 'l') { + // Only run these tests for 'l' (getList) or 'g' (getEntry) + if ($a != 'l' && $a != 'g') { return $r; } diff --git a/classes/data/dataMemberTypes.php b/classes/data/dataMemberTypes.php index 224e0ea1..def4de57 100644 --- a/classes/data/dataMemberTypes.php +++ b/classes/data/dataMemberTypes.php @@ -88,11 +88,16 @@ class GlmDataMemberTypes extends GlmDataAbstract function __construct ($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name diff --git a/classes/data/dataMembers.php b/classes/data/dataMembers.php index 04d97dbb..39a56560 100644 --- a/classes/data/dataMembers.php +++ b/classes/data/dataMembers.php @@ -86,11 +86,15 @@ class GlmDataMembers extends GlmDataAbstract { function __construct($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + } /* * Table Name diff --git a/classes/data/dataRegions.php b/classes/data/dataRegions.php index 92fc5937..be26b2c1 100644 --- a/classes/data/dataRegions.php +++ b/classes/data/dataRegions.php @@ -88,11 +88,16 @@ class GlmDataRegions extends GlmDataAbstract function __construct ($wpdb, $config) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { - // Save plugin configuration object - $this->config = $config; + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } /* * Table Name diff --git a/controllers/admin.php b/controllers/admin.php index 68138baa..a0583baf 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -51,6 +51,9 @@ $GLOBALS['glmMembersAdminValidActions'] = array( 'amenities', 'development' ), + 'shortcodes' => array( + 'index' + ), 'error' => array( 'index', 'badAction' @@ -305,6 +308,16 @@ class glmMembersAdmin extends GlmPluginSupport $this, 'glmMembersAdminMenuConfigure' )); + + // Add a submenu for the "Shortcode Reference" section + add_submenu_page('glm-members-admin-menu-members', + 'Shortcode Reference', 'Shortcodes', + 'glm_members_shortcodes', 'glm-members-admin-menu-shortcodes', + array( + $this, + 'glmMembersAdminMenuShortcodes' + )); + } /* @@ -343,6 +356,11 @@ class glmMembersAdmin extends GlmPluginSupport $this->controller('configure'); } + public function glmMembersAdminMenuShortcodes () + { + $this->controller('shortcodes'); + } + /** * Admin controller * @@ -451,7 +469,7 @@ class glmMembersAdmin extends GlmPluginSupport // Loop till we have a final action $loopCheck = 0; - $redirectData = false; + $actionData = false; do { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { @@ -533,7 +551,7 @@ class glmMembersAdmin extends GlmPluginSupport // Instantiate the model and ask it to perform the work $model = new $className($this->wpdb, $this->config); - $results = $model->modelAction($redirectData); + $results = $model->modelAction($actionData); // Check if there's been a model redirect request if ($results['modelRedirect']) { @@ -548,7 +566,7 @@ class glmMembersAdmin extends GlmPluginSupport // Check if there's data to pass to the new model if (isset($results['data']) && count($results['data']) > 0) { - $redirectData = $results['data']; + $actionData = $results['data']; } $modelRedirect = true; diff --git a/controllers/front.php b/controllers/front.php index 2d737cba..bffee328 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -28,8 +28,14 @@ $GLOBALS['glmMembersFrontValidActions'] = array( 'members' => array( - 'list' + 'list', + 'detail' + ), + 'error' => array( + 'index', + 'badAction' ) + ); // Load glmPluginSupport class @@ -74,7 +80,13 @@ class glmMembersFront extends GlmPluginSupport 'glmMembersFrontScripts' )); - add_shortcode('glm-members', + add_shortcode('glm-members-list', + array( + $this, + 'controller' + )); + + add_shortcode('glm-member-detail', array( $this, 'controller' @@ -171,18 +183,41 @@ class glmMembersFront extends GlmPluginSupport * @return void * @access public */ - public function controller ($atts, $content = null) + public function controller ($atts, $content = null, $shortcode) { - // Shortcode Attributes defaults - $request = shortcode_atts( - array( - 'action' => 'index', - 'option' => false - ), - $atts, - 'glm-members' - ); + // Set shortcode attribute defaults + switch ($shortcode) { + + case 'glm-members-list': + $action = 'list'; + $request = shortcode_atts( + array( + 'map' => true, + 'category' => false, + 'alpha' => false, + 'search' => false, + 'amenities' => false, + 'detail-page' => false + ), + $atts, + 'glm-members' + ); + break; + + case 'glm-member-detail': + $action = 'detail'; + $request = shortcode_atts( + array( + 'map' => true, + 'id' => false + ), + $atts, + 'glm-members' + ); + break; + + } /* * Because WordPress insists on forcing the timezone to UTC @@ -213,16 +248,6 @@ class glmMembersFront extends GlmPluginSupport // Default action is "index" $menuItem = 'members'; - $action = 'list'; - $option = false; - - // First check shortcode attributes - if ($request['action']) { - $action = $request['action']; - } - if ($request['option']) { - $action = $request['option']; - } // Get any requested "action" from a form submission - Overrides shortcode attributes if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') { @@ -234,7 +259,10 @@ class glmMembersFront extends GlmPluginSupport // Loop till we have a final action $loopCheck = 0; - $redirectData = false; + $actionData = array( + 'request' => $request + ); + do { if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { @@ -245,7 +273,6 @@ class glmMembersFront extends GlmPluginSupport // Verify that we have the requested menu item in the valid actions if (! isset($GLOBALS['glmMembersFrontValidActions'][$menuItem])) { - $modelRedirect = true; $menuItem = 'error'; $action = 'index'; @@ -270,7 +297,7 @@ class glmMembersFront extends GlmPluginSupport $className = 'GlmMembersFront_' . $menuItem . '_' . $action; // If model file doesn't exist - we have an error - if (! file_exists($modelName)) { + if (!file_exists($modelName)) { $modelRedirect = true; $menuItem = 'error'; @@ -285,7 +312,6 @@ class glmMembersFront extends GlmPluginSupport // check for an invalid model class name if (! class_exists($className)) { - $modelRedirect = true; $menuItem = 'error'; $action = 'index'; @@ -298,7 +324,7 @@ class glmMembersFront extends GlmPluginSupport // Instantiate the model and ask it to perform the work $model = new $className($this->wpdb, $this->config); - $results = $model->modelAction($redirectData); + $results = $model->modelAction($actionData); // Check if there's been a model redirect request if ($results['modelRedirect']) { @@ -314,7 +340,7 @@ class glmMembersFront extends GlmPluginSupport // Check if there's data to pass to the new model if (isset($results['data']) && count($results['data']) > 0) { - $redirectData = $results['data']; + $actionData = $results['data']; } $modelRedirect = true; @@ -339,9 +365,8 @@ class glmMembersFront extends GlmPluginSupport // This is just a sanity check on this loop to keep it from getting // out of control - if (++ $loopCheck > 10) { - die( - '

Serious failure looping on model load in "controllers/front.php".

'); + if (++$loopCheck > 10) { + die('

Serious failure looping on model load in "controllers/front.php".

'); } if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG && $modelRedirect) { @@ -372,6 +397,7 @@ class glmMembersFront extends GlmPluginSupport $smarty = new smartyTemplateSupport(); // Add standard parameters + $smarty->templateAssign ( 'errorMsg', $errorMsg); $smarty->templateAssign ( 'frontDebug', GLM_MEMBERS_PLUGIN_FRONT_DEBUG); $smarty->templateAssign ( 'baseURL', GLM_MEMBERS_PLUGIN_BASE_URL); $smarty->templateAssign ( 'thisURL', GLM_MEMBERS_PLUGIN_CURRENT_URL ); @@ -395,11 +421,6 @@ class glmMembersFront extends GlmPluginSupport $smarty->templateAssign('thisAction', $action); - // If there's an error message, add that also - if ($errorMsg != '') { - $smarty->templateAssign('errorMsg', $errorMsg); - } - // If view debug has been requested if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { diff --git a/css/admin.css b/css/admin.css index fda3410f..f2938f4d 100644 --- a/css/admin.css +++ b/css/admin.css @@ -32,6 +32,9 @@ text-align: center; margin: 2em; } +.glm-clear { + clear: both; +} .glm-button { margin-left: 4px !important; diff --git a/css/front.css b/css/front.css index 9f9f4ab7..a57a51df 100644 --- a/css/front.css +++ b/css/front.css @@ -27,7 +27,7 @@ .glm-member-list-info { clear: both; } -.glm-member-list-categories { +.glm-member-list-items { margin-top: .5em; } @@ -42,3 +42,8 @@ .glm-map img { max-width: none !important; } +.glm-map-member-name { + width: 100%; + font-weight: bold; + border-bottom: 2px #ccc solid; +} \ No newline at end of file diff --git a/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php b/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php index e1e67c27..d9d4e4dd 100644 --- a/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php +++ b/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '1be35689c5d30d774f40ebc45e387f5f95c45e90' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html', - 1 => 1425940975, + 1 => 1426429308, 2 => 'file', ), ), @@ -54,7 +54,6 @@ $_valid = $_smarty_tpl->decodeProperties(array ( Add New Member -
+ IDtpl_vars['member']->value['fieldData']['id'];?> + tpl_vars['member']->value['fieldRequired']['name']) {?>class="glm-required">Member Name: tpl_vars['member']->value['fieldFail']['name']) {?>class="glm-form-bad-input"> diff --git a/misc/smarty/templates_c/4c287ca0e4946b3d644e61950c851e98e8906d49.file.list.html.php b/misc/smarty/templates_c/4c287ca0e4946b3d644e61950c851e98e8906d49.file.list.html.php index 2bee9838..92fce188 100644 --- a/misc/smarty/templates_c/4c287ca0e4946b3d644e61950c851e98e8906d49.file.list.html.php +++ b/misc/smarty/templates_c/4c287ca0e4946b3d644e61950c851e98e8906d49.file.list.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '4c287ca0e4946b3d644e61950c851e98e8906d49' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/list.html', - 1 => 1426001563, + 1 => 1426428835, 2 => 'file', ), ), @@ -48,8 +48,9 @@ $_valid = $_smarty_tpl->decodeProperties(array ( - + + @@ -70,7 +71,7 @@ $_smarty_tpl->tpl_vars['m']->_loop = true; +
AccessID Member NameAccess Member Type Date Created Pending
- tpl_vars['m']->value['access']['name'];?> + tpl_vars['m']->value['id'];?> @@ -78,6 +79,10 @@ $_smarty_tpl->tpl_vars['m']->_loop = true; ?page=glm-members-admin-menu-member&glm_action=index&member=tpl_vars['m']->value['id'];?> ">tpl_vars['m']->value['name'];?> + + tpl_vars['m']->value['access']['name'];?> + tpl_vars['m']->value['member_type']['name'];?> diff --git a/models/admin/configure/accommodationTypes.php b/models/admin/configure/accommodationTypes.php index 2a5b437d..0eb9ddf3 100644 --- a/models/admin/configure/accommodationTypes.php +++ b/models/admin/configure/accommodationTypes.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_configure_accommodationTypes extends GlmDataAccommodationT $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_configure_accommodationTypes extends GlmDataAccommodationT * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; diff --git a/models/admin/configure/amenities.php b/models/admin/configure/amenities.php index 090ff011..0d0cacf5 100644 --- a/models/admin/configure/amenities.php +++ b/models/admin/configure/amenities.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_configure_amenities extends GlmDataAmenities $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_configure_amenities extends GlmDataAmenities * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; diff --git a/models/admin/configure/categories.php b/models/admin/configure/categories.php index fe224262..e5828153 100644 --- a/models/admin/configure/categories.php +++ b/models/admin/configure/categories.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_configure_categories extends GlmDataCategories $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_configure_categories extends GlmDataCategories * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; diff --git a/models/admin/configure/cities.php b/models/admin/configure/cities.php index 3d17b65b..d7217088 100644 --- a/models/admin/configure/cities.php +++ b/models/admin/configure/cities.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_configure_cities extends GlmDataCities $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_configure_cities extends GlmDataCities * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; diff --git a/models/admin/configure/development.php b/models/admin/configure/development.php index 6f518312..9f9b2428 100644 --- a/models/admin/configure/development.php +++ b/models/admin/configure/development.php @@ -90,7 +90,7 @@ class GlmMembersAdmin_configure_development * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { // Get current database version diff --git a/models/admin/configure/index.php b/models/admin/configure/index.php index 99139bc3..3d236634 100644 --- a/models/admin/configure/index.php +++ b/models/admin/configure/index.php @@ -90,7 +90,7 @@ class GlmMembersAdmin_configure_index * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { // Determine if current user can add, edit, delete member data diff --git a/models/admin/configure/memberTypes.php b/models/admin/configure/memberTypes.php index 338c952b..524fa468 100644 --- a/models/admin/configure/memberTypes.php +++ b/models/admin/configure/memberTypes.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_configure_memberTypes extends GlmDataMemberTypes $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_configure_memberTypes extends GlmDataMemberTypes * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; diff --git a/models/admin/configure/regions.php b/models/admin/configure/regions.php index a29e6e21..f2f6fbee 100644 --- a/models/admin/configure/regions.php +++ b/models/admin/configure/regions.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_configure_regions extends GlmDataRegions $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_configure_regions extends GlmDataRegions * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; diff --git a/models/admin/error/badAction.php b/models/admin/error/badAction.php index 2868efaa..6d2e5936 100644 --- a/models/admin/error/badAction.php +++ b/models/admin/error/badAction.php @@ -99,7 +99,7 @@ class glmMembersAdmin_error_badAction * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { // No work to perform here so just return status diff --git a/models/admin/error/index.php b/models/admin/error/index.php index 38ca2cfc..20456e32 100644 --- a/models/admin/error/index.php +++ b/models/admin/error/index.php @@ -65,7 +65,7 @@ class GlmMembersAdmin_error_index } - public function modelAction($redirectData = false) { + public function modelAction($actionData = false) { // Return status, any suggested view, and any data to controller return array( diff --git a/models/admin/member/index.php b/models/admin/member/index.php index 21795475..b7ed4c0b 100644 --- a/models/admin/member/index.php +++ b/models/admin/member/index.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_member_index extends GlmDataMembers $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_member_index extends GlmDataMembers * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; @@ -114,9 +114,9 @@ class GlmMembersAdmin_member_index extends GlmDataMembers $haveMemberTypes = ($memberTypesStats > 0); // Check if a redirecting model supplied the member ID - if (isset($redirectData['memberID'])) { + if (isset($actionData['memberID'])) { - $memberID = $redirectData['memberID']; + $memberID = $actionData['memberID']; // Otherwise check if one was supplied by the user or passed from somewhere else } elseif (isset($_REQUEST['id'])) { diff --git a/models/admin/member/memberInfo.php b/models/admin/member/memberInfo.php index b78846c7..76f2d004 100644 --- a/models/admin/member/memberInfo.php +++ b/models/admin/member/memberInfo.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); // Add scrips and css add_action('glm_members_memberInfo_enqueue_scripts', @@ -129,7 +129,7 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { // Set some default values $success = true; @@ -152,13 +152,13 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo } // Check for redirection - Should be from creating a new member - if ($redirectData) { + if ($actionData) { - if (!isset($redirectData['member'])) { - $memberID = $redirectData['member']-0; + if (!isset($actionData['member'])) { + $memberID = $actionData['member']-0; } - $memberID = $redirectData['member']-0; + $memberID = $actionData['member']-0; $option = 'create'; // Otherwise it should be a user submission diff --git a/models/admin/members/index.php b/models/admin/members/index.php index af8b219b..807302eb 100644 --- a/models/admin/members/index.php +++ b/models/admin/members/index.php @@ -58,7 +58,7 @@ class GlmMembersAdmin_members_index extends GlmDataMembers $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersAdmin_members_index extends GlmDataMembers * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $success = true; diff --git a/models/admin/members/list.php b/models/admin/members/list.php index da0c6fe3..01acdcf7 100644 --- a/models/admin/members/list.php +++ b/models/admin/members/list.php @@ -57,8 +57,13 @@ class GlmMembersAdmin_members_list extends GlmDataMembers // Save plugin configuration object $this->config = $config; - // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + /* + * Run constructor for members data class to setup table and fields array + * + * Since this class is extending GlmDataMembers, it does not need to pass + * $wpdb and $config to it in the constructor. + */ + parent::__construct(false, false); } @@ -96,7 +101,7 @@ class GlmMembersAdmin_members_list extends GlmDataMembers * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $where = ''; $filterPending = false; diff --git a/models/admin/shortcodes/index.php b/models/admin/shortcodes/index.php new file mode 100644 index 00000000..86154a61 --- /dev/null +++ b/models/admin/shortcodes/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_shortcodes_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/shortcodes/index.html', + 'data' => false + ); + + } +} + +?> \ No newline at end of file diff --git a/models/front/error/badAction.php b/models/front/error/badAction.php new file mode 100644 index 00000000..00a95459 --- /dev/null +++ b/models/front/error/badAction.php @@ -0,0 +1,118 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release front.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +/* + * This model is called if a bad action has been requested. + * + */ +class glmMembersFront_error_badAction +{ + + /** + * 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; + + } + + /* + * 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) + { + + // No work to perform here so just return status + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/error/badAction.html', + 'data' => false + ); + } +} + +?> \ No newline at end of file diff --git a/models/front/error/index.php b/models/front/error/index.php new file mode 100644 index 00000000..85628596 --- /dev/null +++ b/models/front/error/index.php @@ -0,0 +1,81 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release front.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +/* + * This model is called if there is a generic/unknown error + * + */ +class GlmMembersFront_error_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' => 'front/error/index.html', + 'data' => false + ); + + } +} + +?> \ No newline at end of file diff --git a/models/front/members/detail.php b/models/front/members/detail.php new file mode 100644 index 00000000..2a3b5615 --- /dev/null +++ b/models/front/members/detail.php @@ -0,0 +1,173 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Members data abstract +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersFront_members_detail extends GlmDataMemberInfo +{ + + /** + * 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) + { + + $where = ''; + $haveMember = false; + + // If member ID submitted in the URL + if (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) { + + $id = ($_REQUEST['id'] - 0); + + // Otherwise if ID from the short-code + } elseif (isset($actionData['request']) && isset($actionData['request']['id'])) { + + $id = ($actionData['request']['id'] - 0); + + } + + // Check that ID is a positive value + if ($id <= 0) { + + return array( + 'status' => true, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'front/error/index.html', + 'data' => false + ); + + } + + // Find the active member info record + $memberInfoID = $this->getActiveInfoForMember($id); + + /* + * Get data on the specified member + */ + $memberData = $this->getEntry($memberInfoID); + + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + glmMembersFront::addNotice($memberData, 'DataBlock', 'Member Data'); + } + + // If we have member data + $success = true; + $haveMember = false; + if ($memberData !== false) { + + $success = true; + $haveMember = true; + + } + + // Compile template data + $templateData = array( + 'haveMember' => $haveMember, + 'member' => $memberData, + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/members/detail.html', + 'data' => $templateData + ); + + } + + +} + +?> \ No newline at end of file diff --git a/models/front/members/list.php b/models/front/members/list.php index 4ee3ddfe..3ae629db 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -58,7 +58,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $this->config = $config; // Run constructor for members data class - parent::__construct($this->wpdb, $this->config); + parent::__construct(false, false); } @@ -96,7 +96,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo * produce output. * */ - public function modelAction ($redirectData = false) + public function modelAction ($actionData = false) { $where = ''; @@ -105,6 +105,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $filterName = false; $haveFilter = false; + // Apply any specified category filter + $where .= " T.status = ".$this->config['status_numb']['Active']; /* diff --git a/views/admin/configure/categories.html b/views/admin/configure/categories.html index 83325d08..c816db0d 100644 --- a/views/admin/configure/categories.html +++ b/views/admin/configure/categories.html @@ -109,6 +109,7 @@ + @@ -124,6 +125,7 @@ {else} {/if} +
ID Category Description Short Description
{$t.id} {$t.name} diff --git a/views/admin/member/index.html b/views/admin/member/index.html index 67ad2477..afe52b9f 100644 --- a/views/admin/member/index.html +++ b/views/admin/member/index.html @@ -13,7 +13,6 @@ Add New Member {/if} - @@ -27,6 +26,7 @@ {/if} +
ID{$member.fieldData.id}
Member Name: diff --git a/views/admin/members/list.html b/views/admin/members/list.html index 5781ad21..18b953ba 100644 --- a/views/admin/members/list.html +++ b/views/admin/members/list.html @@ -12,8 +12,9 @@ - + + @@ -30,11 +31,14 @@ {/if} + diff --git a/views/admin/shortcodes/header.html b/views/admin/shortcodes/header.html new file mode 100644 index 00000000..f9fdb916 --- /dev/null +++ b/views/admin/shortcodes/header.html @@ -0,0 +1,5 @@ +
+ +

{$glmPluginName}

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

Shortcodes Reference

+ +

+ Listed below are the shortcodes that may be used in this Web site to display + member lists, member detail information, maps of members, and other related + information. Simply paste these codes into a the text content editor for a page + in this Web site. You may also include other text along with the shortcode. + Some shortcodes allow for additional "attributes" you can use to more specifically + direct what will be displayed on the page. +

+ When using a Shortcode in a page, be sure to include the "[" and "]" characters. + The attributes show below each Shortcode in the table below may be included in the + Shortcode to modify behavior of the Shortcode. One or more of these attributes may be + inserted into the shortcode. When including multiple attributes in a Shortcode, + be sure to leave a space between the attributes. An example is shown below. +

+

[glm-members action="list" category="Accommodations"]

+ +
AccessID Member NameAccess Member Type Date Created Pending
- {$m.access.name} + {$m.id} {$m.name} + {$m.access.name} + {$m.member_type.name}
+ + + + + + + + + + + + + + + + + + + +
ShortcodeAttributeAttribute ValueDescription
[glm-member-list] + Displays a list of members and a map with markers for each member. Optionally, + the attributes below may used to modify the display of this page. +
  + category="{ category ID(s) }" + + The "category" attribute is used display only members in a specific category or + ctegories. To select multiple categories, separate the categories with a ",". + Categories are specified by ID number. The ID for each category is + shown in the Member Categories list. +
[glm-member-detail] + Displays details for a speicif member along with a map showing their location. The + "id" attribute below is required to specify which member to display. +
  + id="{ member ID }" + + This is a required attribute for [glm-member-detail] that specifies the ID of + the desired member. The ID for a member is displayed both in the left column + of the member list and at the top of the Member Dashboard. Only one ID may + be specified. +
+ +{include file='admin/footer.html'} diff --git a/views/front/error/badAction.html b/views/front/error/badAction.html index 7165a075..a19e0f9a 100644 --- a/views/front/error/badAction.html +++ b/views/front/error/badAction.html @@ -2,10 +2,8 @@

Sorry, we've had an error.

-

Error: : An invalid action has been specified.

+

Error: : An invalid action or Shortcode attribute has been specified.

- {if $errorMsg}

{$errorMsg}

{/if} -

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

{include file='front/footer.html'} diff --git a/views/front/error/header.html b/views/front/error/header.html index f9fdb916..2b17b0e1 100644 --- a/views/front/error/header.html +++ b/views/front/error/header.html @@ -1,5 +1,4 @@
-

{$glmPluginName}

\ No newline at end of file diff --git a/views/front/error/index.html b/views/front/error/index.html index ece4c866..16f771fd 100644 --- a/views/front/error/index.html +++ b/views/front/error/index.html @@ -4,6 +4,8 @@

Sorry, we've had some type of fatal error.

+ {if $errorMsg}

{$errorMsg}

{/if} +

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

diff --git a/views/front/members/detail.html b/views/front/members/detail.html new file mode 100644 index 00000000..ae632931 --- /dev/null +++ b/views/front/members/detail.html @@ -0,0 +1,105 @@ +{include file='front/members/header.html'} + +{if $haveMember} + + + +
(map loads here)
+ + +

Member Detail

+ +
+
+
+

{$member.member}

+

+ {if $member.addr1}{$member.addr1}
{/if} + {if $member.addr2}{$member.addr2}
{/if} + {if $member.city.name}{$member.city.name}{if $member.state.name}, {/if}{/if}{if $member.state.name}{$member.state.name}{/if}{if $member.zip} {$member.zip}{/if} + {if $member.country.name}
{$member.country.name}{/if} + {if $member.region.value}

Region: {$member.region.name}

{/if} +

+
+
+ {if $member.descr} +

{$member.descr}

+ {else if $member.short_descr} +

{$member.short_descr}

+ {/if} + {if $member.phone}Phone: {$member.phone}
{/if} + {if $member.toll_free}Toll Free: {$member.toll_free}
{/if} + {if $member.url}Web site: {$member.url}
{/if} + {if $member.categories} +
+ Member Categories +
    + {foreach $member.categories as $c} +
  • + {if $c.parent_name}{$c.parent_name}: {/if}{$c.name} +
  • + {/foreach} +
+
+ {/if} + {if $member.cc_type} +
+ Credit Cards Accepted: +
    + {foreach $member.cc_type.names as $c} +
  • {$c}
  • + {/foreach} +
+
+ {/if} +
+
+ + + +{else} +

For some reason the specified member was not found. Please try again.

+{/if} + + +{include file='front/footer.html'} diff --git a/views/front/members/list.html b/views/front/members/list.html index 085f367e..420075c1 100644 --- a/views/front/members/list.html +++ b/views/front/members/list.html @@ -13,13 +13,13 @@
-

{$m.member}

+

{$m.member}

{if $m.addr1}{$m.addr1}
{/if} {if $m.addr2}{$m.addr2}
{/if} {if $m.city.name}{$m.city.name}{if $m.state.name}, {/if}{/if}{if $m.state.name}{$m.state.name}{/if}{if $m.zip} {$m.zip}{/if} {if $m.country.name}
{$m.country.name}{/if} - {if $m.region.value}

Region: {$m.region.name}

{/if} + {if $m.region.value}

Region: {$m.region.name}

{/if}

@@ -28,12 +28,12 @@ {else if $m.short_descr}

{$m.short_descr}

{/if} - {if $m.phone}Phone: {$m.phone}
{/if} - {if $m.toll_free}Toll Free: {$m.toll_free}
{/if} - {if $m.url}Web site: {$m.url}
{/if} + {if $m.phone}Phone: {$m.phone}
{/if} + {if $m.toll_free}Toll Free: {$m.toll_free}
{/if} + {if $m.url}Web site: {$m.url}
{/if} {if $m.categories} -
- Member Categories +
+ Member Categories
    {foreach $m.categories as $c}
  • @@ -42,6 +42,16 @@ {/foreach}
+ {/if} + {if $m.cc_type} +
+ Credit Cards Accepted: +
    + {foreach $m.cc_type.names as $c} +
  • {$c}
  • + {/foreach} +
+
{/if}
@@ -50,15 +60,13 @@ {else}
(no members listed)
{/if} - {if $m.toll_free}

{$m.toll_free}

{/if}