Fixing some php errors when there's no member to list.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 30 Mar 2017 15:38:48 +0000 (11:38 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 30 Mar 2017 15:38:48 +0000 (11:38 -0400)
Also fix when setting up plugin capabilities to allow admin users to
manage the members.

index.php
models/admin/members/list.php
models/front/members/list.php
setup/rolesAndCapabilities.php
views/front/members/detail.html

index 170d88a..0e81b13 100644 (file)
--- 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 <cscott@gaslightmedia.com>
  * @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
index a75496d..9d97cc8 100644 (file)
@@ -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
index be4a632..7befc89 100644 (file)
@@ -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
index 7eb8091..1889047 100644 (file)
@@ -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,
index ea983ba..8bf9c41 100644 (file)
 
             // 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