Added text to member info pages to warn user when update could not be completed.
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 25 Jan 2017 18:26:02 +0000 (13:26 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 25 Jan 2017 18:26:02 +0000 (13:26 -0500)
Fixed use of views in the theme to override views in the plugin/addons.
Added defines for theme name and path.

controllers/front.php
defines.php
views/admin/member/memberEdit.html
views/admin/member/memberInfo.html
views/front/members/header.html

index 43ff11d..c3b3b74 100644 (file)
@@ -267,9 +267,6 @@ class glmMembersFront extends GlmPluginSupport
         // Enqueue all css here so that only happens when we're doing something
         $this->glmMembersFrontCSS();
 
-        // Get the current theme directory to check for modified views
-        $theme = get_template_directory();
-
         /*
          * Because WordPress insists on forcing the timezone to UTC
          * we need to save the current timezone setting, set the one
@@ -463,10 +460,12 @@ class glmMembersFront extends GlmPluginSupport
                         if ($view) {
 
                             // Get the specified view file - check theme first
-                            $viewPath = "$theme/$plugIn/views";
+                            $viewPath = GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR."/$plugIn/views";
+                            $viewPath2 = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views";       // Save default
                             $viewFile = $view;
-                            if (!is_file($viewPath.'/'.$viewFile)) {
 
+                            // If the view is not found in the theme, fall back to views in the plugin
+                            if (!is_file($viewPath.'/'.$viewFile)) {
                                 // Next try the plugin/add-on
                                 $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views";
                                 $viewFile = $view;
@@ -476,7 +475,6 @@ class glmMembersFront extends GlmPluginSupport
                                     $errorMsg .= "<b>Bad or missing view file:</b> $viewPath/$viewFile";
 
                                 }
-
                             }
 
                         }
@@ -535,8 +533,8 @@ Request Data: ".print_r($_REQUEST,1)."
                 'Front-End GLM Associate Error',
                 $mailMsg
             );
-            $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/views';
-            $viewFile = 'front/error/index.html';
+//            $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/views';
+//            $viewFile = 'front/error/index.html';
             require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/models/front/error/index.php';
             $model = new GlmMembersFront_error_index($this->wpdb, $this->config);
             $results = $model->modelAction($actionData);
@@ -571,7 +569,12 @@ Request Data: ".print_r($_REQUEST,1)."
         }
 
         // Update the Smarty view path
-        $smarty->template->addTemplateDir($viewPath);
+        $smarty->template->setTemplateDir($viewPath);
+
+        // If the view path doesn't match the default, add the default (using theme view)
+        if ($viewPath2 != $viewPath) {
+            $smarty->template->addTemplateDir($viewPath2);
+        }
 
         // Generate output from model data and view
         $out = $smarty->template->fetch($viewFile);
index 03e774b..e631529 100644 (file)
@@ -83,3 +83,7 @@ global $wpdb;
 define('GLM_MEMBERS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_');
 define('GLM_MEMBERS_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersDatabaseDbVersion');
 
+// Current Theme Information
+$glmCurrentTheme = wp_get_theme();
+define('GLM_MEMBERS_PLUGIN_CURRENT_THEME', $glmCurrentTheme->get_template());
+define('GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR', $glmCurrentTheme->get_template_directory());
index d4defc4..3e23976 100644 (file)
@@ -12,8 +12,6 @@
   {/if}
         {if $memberUpdated}<span class="glm-notice glm-flash-updated glm-right">{$terms.term_member_cap} Updated</span>{/if}
         {if $memberUpdateError}<span class="glm-error glm-flash-updated glm-right">{$terms.term_member_cap} Update Error</span>{/if}
-        
-        
     </h2>
 
   {if apply_filters('glm_members_permit_admin_member_index_edit_member', true)}
index bc25253..7a9884d 100644 (file)
         <h2>Add New {$terms.term_member_cap} Profile</h2>
     {/if} <!-- memberInfoID && memberInfo -->
 
+  {if $memberUpdateError}
+    <h1 class="glm-error">NOTICE: Your {$terms.term_member} information has not yet been submitted.<br>Please select the tabs indicating a problem, correct the indicated fields and resubmit.</h1>
+  {/if}
+
+
     <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
         <input type="hidden" name="glm_action" value="memberInfo">
         <input type="hidden" name="member" value="{$member.id}">
index 4eaacea..76baa1c 100644 (file)
@@ -1,3 +1,3 @@
 <div class="wrap">
     <div id="glm-member-db-front-container" class="glm-member-front-container">
-    
\ No newline at end of file
+    blablabla
\ No newline at end of file