adding write_log to the support class
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 3 Jan 2019 16:12:19 +0000 (11:12 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 3 Jan 2019 16:12:19 +0000 (11:12 -0500)
classes/glmPluginSupport.php
models/admin/ajax/memberManagement.php
views/admin/manageDashboard/index.html
views/admin/member/memberInfo.html

index 8c40d80..25c422e 100755 (executable)
@@ -307,7 +307,16 @@ return; // Off for now ** Need to make this switchable in management
     public function nicePrint($array){
         echo '<pre>', print_r($array), '</pre>';
     }
-
+    
+    public function write_log ( $log )  {
+        if ( true === WP_DEBUG ) {
+            if ( is_array( $log ) || is_object( $log ) ) {
+                error_log( print_r( $log, true ) );
+            } else {
+                error_log( $log );
+            }
+        }
+    }
 }
 
 /*
index e80f5ed..6be45cc 100644 (file)
@@ -13,6 +13,7 @@
  * @version  0.1
  */
 require_once GLM_MEMBERS_PLUGIN_PATH . '/controllers/admin.php';
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/glmPluginSupport.php';
 /**
  *
  * This class exports the currently selected members list
@@ -74,6 +75,7 @@ class GlmMembersAdmin_ajax_memberManagement extends glmMembersAdmin
     {
         global $wpdb;
         
+        $support = new glmPluginSupport();
         foreach ($this->config['addOns'] as $a) {
             if (is_file(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php')) {
                 require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php';
@@ -82,7 +84,7 @@ class GlmMembersAdmin_ajax_memberManagement extends glmMembersAdmin
                 require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminTabs.php';
             }
         }
-
+        
         if( $_REQUEST['option'] == 'manage'){
             $memberID = $_REQUEST['memberID'];
             $data = $this->controller( 'member', 'index', array("memberID" => $memberID), true, true);
@@ -104,8 +106,11 @@ class GlmMembersAdmin_ajax_memberManagement extends glmMembersAdmin
             $data  = $this->controller( 'member', 'memberInfo',  false, true, true);
         }
 
+        if($_REQUEST['option'] == 'submit'){
+            $support->write_log($_REQUEST);
+            $data = "test";
+        }
         $return = array(
-            "test"          => [$memberID, $memberInfo],
             'searchData'    => $data,       // Where our events list will go
         );
 
index aa49add..3d8e896 100644 (file)
 
 <script>
     jQuery(function($){
-        var defaultData = {
-            action          : 'glm_members_admin_ajax',
-            glm_action      : 'memberManagement',
-        }
-        let listData = {
-            action          : defaultData.action,
-            glm_action      : defaultData.glm_action,
-        }
-        var editData = {
-            action      : defaultData.action,
-            glm_action  : defaultData.glm_action,
-        }
-
         window.Glma = (function() {  
             var xhr = function(data, complete, success, error, type){
                 $.ajax({
             }
         })();
 
+        window.Glma['defaultData'] = {
+            action          : 'glm_members_admin_ajax',
+            glm_action      : 'memberManagement',
+        }
+        let listData = {
+            action          : Glma.defaultData.action,
+            glm_action      : Glma.defaultData.glm_action,
+        }
+        var editData = {
+            action      : Glma.defaultData.action,
+            glm_action  : Glma.defaultData.glm_action,
+        }
+
         /*
         *  Init Materialize collapsible
         */
index 4795cf0..fc96699 100755 (executable)
@@ -74,7 +74,7 @@
   {/if}
 
 
-    <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+    <form id="member-info-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}">
       {if $memberInfoID && $memberInfo}
 
     <script >
         jQuery(function($) {
+            var memberInfoData = {
+                action      : window.Glma.defaultData.action,
+                glm_action  : window.Glma.defaultData.glm_action,
+            }
             $('select').formSelect();
             /*
              * Edit area tabs
                 $('.updateMemberProfile').addClass('glm-bad-input-area');
                 glmSubmitRequired = true;
             }
+
+            
             // When submit button is clicked, disable the beforeunload message
             $('.updateMemberProfile').on('click', function(e) {
                 e.preventDefault();
-                window.Glma()
-                glmSubmitRequired = false;
-                return true;
+                var form = $("#member-info-form");
+                memberInfoData.option = "submit";
+                memberInfoData.form = form.serialize();
+                console.log(memberInfoData);
+                window.Glma.memberEdit(
+                    memberInfoData,
+                    function(complete) {},
+                    function(success) {
+                        console.log(success);
+                    },
+                    function(error) {
+                        console.log(error);
+                    },
+                    "POST"
+                );
+                // glmSubmitRequired = false;
+                // return true;
             });
 
+
+
             // If submit is required and we're laving the page, alert the user
             $(window).bind('beforeunload', function() {
                 if (glmSubmitRequired) {