]> git.mxchange.org Git - mailer.git/blobdiff - inc/filter/coupon_filter.php
Large code cleanups:
[mailer.git] / inc / filter / coupon_filter.php
index cafe31b95ee302a2dc0259658909a68fe902a78b..6d6a5485fea6208f397cc8a2a469adf808c0e56c 100644 (file)
@@ -17,7 +17,7 @@
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -41,23 +41,39 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Filter to change column name for the right "points account"
-function FILTER_COUPON_CHANGE_POINTS_COLUMN_NAME ($data) {
+function FILTER_COUPON_CHANGE_POINTS_COLUMN_NAME ($filterData) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
-       // Are the points locked?
-       if (($data['locked'] === true) && (getConfig('coupon_locked_points_mode') == 'LOCKED')) {
-               // Locked points may be routed to special account
-               $data['column'] = 'locked_order_points';
-       } elseif (getConfig('coupon_points_account') == 'ORDER') {
-               // These points should be routed to 'order' account
-               $data['column'] = 'order_points';
-       } else {
-               // Else all went to general account
-               $data['column'] = 'points';
-       }
+       // Get the column name from extension's name and 'locked'
+       $filterData['column'] = getPointsColumnNameFromSubjectLocked($filterData['subject'], $filterData['locked']);
 
        // Return data
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
-       return $data;
+       return $filterData;
+}
+
+// Filter to do generic post-coupon-cash things
+function FILTER_POST_CASH_COUPON ($filterData) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+       // Now we just need to book that points on the user's account
+       initReferralSystem();
+       addPointsThroughReferralSystem('coupon_cashed', $filterData['userid'], $filterData['points']);
+
+       // Subtract points from member account if the admin has selected one
+       if (isValidUserId(getCouponUserid())) {
+               // Subtract from this account and ignore return status
+               subtractPoints('cashed_coupon', getCouponUserid(), $filterData['points']);
+       } // END - if
+
+       // Translate some data
+       $filterData['coupon_expired'] = generateDateTime($filterData['coupon_expired'], '0');
+       $filterData['coupon_created'] = generateDateTime($filterData['coupon_created'], '0');
+
+       // Send admin notification
+       sendAdminNotification('{--ADMIN_COUPON_CASHED_SUBJECT--}', 'admin_coupon_cashed', $filterData, $filterData['userid']);
+
+       // Return data
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+       return $filterData;
 }
 
 // [EOF]