Updates for notify.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 5 Dec 2016 20:50:36 +0000 (15:50 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 5 Dec 2016 20:50:36 +0000 (15:50 -0500)
Don't try the admin email if no email is set.

classes/helper/notification.php
models/admin/coupons/list.php

index 0eaebcd..33bbf05 100644 (file)
@@ -152,6 +152,9 @@ class GlmMembersAdmin_coupon_notification extends GlmDataMembers
         $notify_to      = $settings['notify_to'];
         $notify_from    = $settings['notify_from'];
         $notify_message = $settings['notify_message'];
+        if ( !$notify_to ) {
+            return false;
+        }
 
         // Setup the Smarty Engine
         $smarty   = new smartyTemplateSupport();
index 57d4b5c..a775096 100644 (file)
@@ -136,6 +136,7 @@ class GlmMembersAdmin_coupons_list extends GlmDataCoupons
         $namesList         = false;
         $enable_members    = $this->config['settings']['enable_members'];
 
+        // Load Notifications from the helper classes
         include_once GLM_MEMBERS_COUPONS_PLUGIN_CLASS_PATH . '/helper/notification.php';
         $notification = new GlmMembersAdmin_coupon_notification( $this->wpdb, $this->config );
 
@@ -227,24 +228,24 @@ class GlmMembersAdmin_coupons_list extends GlmDataCoupons
                 if ( $coupon ) {
                     $this->couponID = $coupon['fieldData']['id'];
                     $this->updateCategories();
-                    $categories = $Categories->getList(false);
+                    $categories = $Categories->getList( false );
 
-                    if ($coupon['status']) {
+                    if ( $coupon['status'] ) {
                         $haveCoupon = true;
                         $couponAdded = true;
 
                         // Update created timestamp and name slug for URLs
-                        $this->updateTimestamp('created', $this->couponID);
-                        $this->updateSlug($this->couponID);
+                        $this->updateTimestamp( 'created', $this->couponID );
+                        $this->updateSlug( $this->couponID );
 
                         // Get this again so we have the created date
-                        $coupon = $this->editEntry($this->couponID);
+                        $coupon = $this->editEntry( $this->couponID );
 
                         $option = 'edit';
                         $couponAdded = true;
                         if ( $lockedToMember ) {
-                            if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest']) ) {
-                                $notification->sendAdminNotice( $member_id, $coupon);
+                            if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
+                                $notification->sendAdminNotice( $member_id, $coupon );
                             }
                         }