]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
A lot more nice improvements!
[mailer.git] / inc / mysql-manager.php
index 9524124961ccf2dba68518fb007a2f45bb4d1183..02eeb4f87c6a07152a723363ad7dd903672be6c9 100644 (file)
@@ -1151,6 +1151,7 @@ function GET_REF_LEVEL_PERCENTS ($level) {
  *
  * Dynamic referal system, can also send mails!
  *
  *
  * Dynamic referal system, can also send mails!
  *
+ * subject     = Subject line, write in lower-case letters and underscore is allowed
  * uid         = Referal ID wich should receive...
  * points      = ... xxx points
  * send_notify = shall I send the referal an email or not?
  * uid         = Referal ID wich should receive...
  * points      = ... xxx points
  * send_notify = shall I send the referal an email or not?
@@ -1159,7 +1160,7 @@ function GET_REF_LEVEL_PERCENTS ($level) {
  * add_mode    = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
  *               for default value will cause no referal will get points ever!!!)
  */
  * add_mode    = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
  *               for default value will cause no referal will get points ever!!!)
  */
-function ADD_POINTS_REFSYSTEM ($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
+function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
        //* DEBUG: */ print "----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n";
        global $DEPTH, $_CONFIG, $DATA, $cacheArray;
 
        //* DEBUG: */ print "----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n";
        global $DEPTH, $_CONFIG, $DATA, $cacheArray;
 
@@ -1173,6 +1174,12 @@ function ADD_POINTS_REFSYSTEM ($uid, $points, $send_notify=false, $rid="0", $loc
                return;
        } // END - if
 
                return;
        } // END - if
 
+       // Add booking record if extension is installed
+       if (EXT_IS_ACTIVE("booking")) {
+               // Add record
+               ADD_BOOKING_RECORD($subject, $uid, $points, "add");
+       } // END - if
+
        // Count up referal depth
        if (!isset($DEPTH)) {
                // Initialialize referal system
        // Count up referal depth
        if (!isset($DEPTH)) {
                // Initialialize referal system
@@ -1271,7 +1278,7 @@ function ADD_POINTS_REFSYSTEM ($uid, $points, $send_notify=false, $rid="0", $loc
                        if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) {
                                // Then let's credit him here...
                                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},points={$points} - ADVANCE!<br />\n";
                        if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) {
                                // Then let's credit him here...
                                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},points={$points} - ADVANCE!<br />\n";
-                               ADD_POINTS_REFSYSTEM($ref, $points, $send_notify, $ref, $locked);
+                               ADD_POINTS_REFSYSTEM(sprintf("%s_ref:%s", $subject, $DEPTH), $ref, $points, $send_notify, $ref, $locked);
                        } // END - if
                } // END - if
        } // END - if
                        } // END - if
                } // END - if
        } // END - if
@@ -1831,18 +1838,26 @@ function MODULE_HAS_MENU($mod, $forceDb = false)
        // Return status
        return $ret;
 }
        // Return status
        return $ret;
 }
+
 // Subtract points from database and mediadata cache
 // Subtract points from database and mediadata cache
-function SUB_POINTS ($uid, $points) {
+function SUB_POINTS ($subject, $uid, $points) {
        // Add points to used points
        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `used_points`=`used_points`+%s WHERE userid=%s LIMIT 1",
         array($points, bigintval($uid)), __FILE__, __LINE__);
 
        // Add points to used points
        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `used_points`=`used_points`+%s WHERE userid=%s LIMIT 1",
         array($points, bigintval($uid)), __FILE__, __LINE__);
 
+       // Insert booking record
+       if (EXT_IS_ACTIVE("booking")) {
+               // Add record
+               ADD_BOOKING_RECORD($subject, $uid, $points, "sub");
+       } // END - if
+
        // Update mediadata as well
        if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
                // Update database
                MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
        } // END - if
 }
        // Update mediadata as well
        if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
                // Update database
                MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
        } // END - if
 }
+
 // Update config entries
 function UPDATE_CONFIG ($entries, $values, $updateMode="") {
        // Do we have multiple entries?
 // Update config entries
 function UPDATE_CONFIG ($entries, $values, $updateMode="") {
        // Do we have multiple entries?
@@ -1887,6 +1902,7 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") {
        // Rebuild cache
        REBUILD_CACHE("config", "config");
 }
        // Rebuild cache
        REBUILD_CACHE("config", "config");
 }
+
 // Creates a new task for updated extension
 function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $subject, $notes) {
        // Check if task is not there
 // Creates a new task for updated extension
 function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $subject, $notes) {
        // Check if task is not there
@@ -1901,6 +1917,7 @@ function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $subject, $notes) {
        // Free memory
        SQL_FREERESULT($result);
 }
        // Free memory
        SQL_FREERESULT($result);
 }
+
 // Creates a new task for newly installed extension
 function CREATE_NEW_EXTENSION_TASK ($admin_id, $subject, $ext) {
        // Not installed and do we have created a task for the admin?
 // Creates a new task for newly installed extension
 function CREATE_NEW_EXTENSION_TASK ($admin_id, $subject, $ext) {
        // Not installed and do we have created a task for the admin?