From: Steve Sutton Date: Thu, 30 Mar 2017 15:38:48 +0000 (-0400) Subject: Fixing some php errors when there's no member to list. X-Git-Tag: v2.9.12^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=5180b97a4a38c4c5b2273d7b70e0f2de108858bb;p=WP-Plugins%2Fglm-member-db.git Fixing some php errors when there's no member to list. Also fix when setting up plugin capabilities to allow admin users to manage the members. --- diff --git a/index.php b/index.php index 170d88ae..0e81b132 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 2.9.11 + * Version: 2.9.12 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersDatabase * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 2.9.11 + * @version 2.9.12 */ /* @@ -38,7 +38,7 @@ * */ -define('GLM_MEMBERS_PLUGIN_VERSION', '2.9.11'); +define('GLM_MEMBERS_PLUGIN_VERSION', '2.9.12'); define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.26'); // Check if plugin version is not current in WordPress option and if needed updated it diff --git a/models/admin/members/list.php b/models/admin/members/list.php index a75496d4..9d97cc89 100644 --- a/models/admin/members/list.php +++ b/models/admin/members/list.php @@ -281,8 +281,10 @@ class GlmMembersAdmin_members_list extends GlmDataMembers // $canEdit = current_user_can('glm_members_edit'); // Add a url for each member - foreach ($list as $member) { - $list[$member['id']]['member_slug'] = sanitize_title($member['name']); + if ( isset( $list) && is_array( $list ) ) { + foreach ($list as $member) { + $list[$member['id']]['member_slug'] = sanitize_title($member['name']); + } } // Compile template data diff --git a/models/front/members/list.php b/models/front/members/list.php index be4a6322..7befc89e 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -397,16 +397,18 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $vStripped = html_entity_decode(stripslashes(trim($v))); - reset($categoryData); - foreach ($categoryData as $c) { + if ( isset( $categoryData ) && is_array( $categoryData ) ) { + reset($categoryData); + foreach ($categoryData as $c) { - $x = html_entity_decode(stripslashes(trim($c['name']))); + $x = html_entity_decode(stripslashes(trim($c['name']))); - // If this entry matches - apply html entity decode in case string is encoded - if ($x == $vStripped) { + // If this entry matches - apply html entity decode in case string is encoded + if ($x == $vStripped) { - // Update the $cats array with the ID rather than the name and mark as found - $cats[] = $c['id']; + // Update the $cats array with the ID rather than the name and mark as found + $cats[] = $c['id']; + } } } @@ -422,6 +424,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo * so $parentSelected */ $parentSelected = false; + if ( isset( $categoryData ) && is_array( $categoryData ) ) { reset($categoryData); while (list($k, $v) = each($categoryData)) { @@ -442,6 +445,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } } + } } @@ -452,8 +456,10 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo if ($this->config['settings']['list_show_search_category']) { // Add default flag as false to all entries + if ( isset( $categoryData ) && is_array( $categoryData ) ) { foreach ($categoryData as $k=>$v) { $categoryData[$k]['default'] = false; + } } // Check if a category has been submitted diff --git a/setup/rolesAndCapabilities.php b/setup/rolesAndCapabilities.php index 7eb80913..1889047d 100644 --- a/setup/rolesAndCapabilities.php +++ b/setup/rolesAndCapabilities.php @@ -41,7 +41,7 @@ $this->addRoleCapability('glm_members_main_menu', // Access to Members menu $this->addRoleCapability('glm_members_members', array( - 'administrator' => false, + 'administrator' => true, 'author' => false, 'contributor' => false, 'editor' => true, diff --git a/views/front/members/detail.html b/views/front/members/detail.html index ea983bac..8bf9c412 100644 --- a/views/front/members/detail.html +++ b/views/front/members/detail.html @@ -337,12 +337,15 @@ // change the member detail photos grid structure depending var images_container = $("#glm-member-detail-images-container"); - var foundation_version = window.Foundation.version; - - if( foundation_version.charAt(0) === "6" ){ - images_container.children('ul').removeClass('small-block-grid-1 medium-block-grid-2 large-block-grid-3'); - images_container.children('ul').addClass('row small-up-1 medium-up-2 large-up-3'); - images_container.children('ul').find('li').addClass('column'); + // Check if Foundation exists first + if ( typeof window.Foundation != 'undefined' ) { + var foundation_version = window.Foundation.version; + + if( foundation_version.charAt(0) === "6" ){ + images_container.children('ul').removeClass('small-block-grid-1 medium-block-grid-2 large-block-grid-3'); + images_container.children('ul').addClass('row small-up-1 medium-up-2 large-up-3'); + images_container.children('ul').find('li').addClass('column'); + } } // Replace all non-number special characters in a phone number with the designated infix