Naming convention, more usage of EL, new wrapper function introduced:
[mailer.git] / inc / mysql-manager.php
index 51e24c8eded41fdbbf2e3cf17bb56d1479ac8a14..43de04889b35120e41da8ec646ba78a606b41453 100644 (file)
@@ -994,7 +994,7 @@ function getReferalLevelPercents ($level) {
  * add_mode    = Add points only to $userid or also refs? (WARNING! Changing 'ref' to 'direct'
  *               for default value will cause no referal will get points ever!!!)
  */
-function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $locked = false, $add_mode = 'ref') {
+function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $add_mode = 'ref') {
        //* DEBUG: */ debugOutput('----------------------- <font color="#00aa00">' . __FUNCTION__ . ' - ENTRY</font> ------------------------<ul><li>');
        // Convert mode to lower-case
        $add_mode = strtolower($add_mode);
@@ -1006,21 +1006,6 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                return;
        } // END - if
 
-       // Prepare data for the filter
-       $filterData = array(
-               'subject'  => $subject,
-               'userid'   => $userid,
-               'points'   => $points,
-               'notify'   => $sendNotify,
-               'refid'    => $refid,
-               'locked'   => $locked,
-               'mode'     => 'add',
-               'sub_mode' => $add_mode,
-       );
-
-       // Filter it now
-       runFilterChain('add_points', $filterData);
-
        // Count up referal depth
        if (!isset($GLOBALS['ref_level'])) {
                // Initialialize referal system
@@ -1074,6 +1059,25 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):data='.$data.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$add_mode.' - INSERTED! ('.SQL_AFFECTEDROWS().')');
                        } // END - if
 
+                       // Determine wether the user has some mails to click before he/she gets the points
+                       $locked = false;
+                       if ((getUserData('ref_payout') > 0) && (!isDirectPaymentAllowed())) $locked = true;
+
+                       // Prepare data for the filter
+                       $filterData = array(
+                               'subject'  => $subject,
+                               'userid'   => $userid,
+                               'points'   => $points,
+                               'notify'   => $sendNotify,
+                               'refid'    => $refid,
+                               'locked'   => $locked,
+                               'mode'     => 'add',
+                               'sub_mode' => $add_mode,
+                       );
+
+                       // Filter it now
+                       runFilterChain('add_points', $filterData);
+
                        // Points updated, maybe I shall send him an email?
                        if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) {
                                // Prepare content
@@ -1107,7 +1111,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                        if ((isValidUserId(getUserData('refid'))) && ($points > 0) && (getUserData('refid') != $userid) && ($add_mode == 'ref')) {
                                // Then let's credit him here...
                                //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):userid='.$userid.',ref='.getUserData('refid').',points='.$points.' - ADVANCE!');
-                               addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid'), $locked);
+                               addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid'));
                        } // END - if
                } // END - if
        } // END - if