]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/refback_functions.php
Some language strings fixed, renamed. Copyright notice updated
[mailer.git] / inc / libs / refback_functions.php
index 69f7fe73ca8b7c1f71dee5aca3284d8aa9349969..bb42f8f11d2d0bc649e96c1be4dbb284e4ce79ba 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -144,9 +142,9 @@ function getRefbackPercents ($userid, $ref) {
 }
 
 // "Getter" for userid array which will return only one entry
-function getArrayFromRefbackLevel ($rid, $level) {
+function getArrayFromRefbackLevel ($refid, $level) {
        //* DEBUG: */ print("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
-       //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):rid={$rid},level={$level}<br />");
+       //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):refid={$refid},level={$level}<br />");
        // Init userids
        $userIds = array();
 
@@ -159,14 +157,14 @@ WHERE
        `refid`=%s AND `level`=%s
 ORDER BY
        `userid` ASC",
-               array($rid, $level), __FUNCTION__, __LINE__);
+               array($refid, $level), __FUNCTION__, __LINE__);
 
        // Entries found?
        //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):numRows=".SQL_NUMROWS($result)."<br />");
        if (!SQL_HASZERONUMS($result)) {
                // Add all
                while ($content = SQL_FETCHARRAY($result)) {
-                       //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):rid={$rid},level={$level},userid={$content['userid']}<br />");
+                       //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):refid={$refid},level={$level},userid={$content['userid']}<br />");
                        $userIds[] = $content['userid'];
                } // END - while
        } // END - if
@@ -175,7 +173,7 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Return array
-       //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):rid={$rid},count()=".count($userIds)."<br />");
+       //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):refid={$refid},count()=".count($userIds)."<br />");
        //* DEBUG: */ print("</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />");
        return $userIds;
 }
@@ -197,7 +195,7 @@ function updateRefbackTable ($userid) {
 
        // When no entry was updated then we have to create it here
        //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):found=".SQL_NUMROWS($result_refid)."<br />");
-       if (SQL_NUMROWS($result_refid) > 0) {
+       if (!SQL_HASZERONUMS($result_refid)) {
                // Load all refids
                while (list($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) = SQL_FETCHROW($result_refid)) {
                        // Remmber userid
@@ -228,7 +226,8 @@ function updateRefbackTable ($userid) {
                                                array(bigintval($userid), $GLOBALS['refback_level'], bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']])), __FUNCTION__, __LINE__);
 
                                        // Move to next referal level and count his counter one up!
-                                       $GLOBALS['refback_level']++; updateRefbackTable($GLOBALS['refback_refid'][($GLOBALS['refback_level'] - 1)]);
+                                       $GLOBALS['refback_level']++;
+                                       updateRefbackTable($GLOBALS['refback_refid'][($GLOBALS['refback_level'] - 1)]);
                                } // END - if
 
                                // Do we have another level here?
@@ -390,7 +389,7 @@ function updateMemberRefbackPercents ($id, $percents) {
                array($percents, $id, getMemberId()), __FUNCTION__, __LINE__);
 
        // Entry updated?
-       if (SQL_AFFECTEDROWS() < 1) {
+       if (SQL_HASZEROAFFECTED()) {
                // Entry not updated!
                $status['message'] = '{--MEMBER_REFBACK_ERROR_NOT_UPDATED--}';
                return $status;
@@ -416,5 +415,17 @@ function updateMemberRefbackPercents ($id, $percents) {
        return $status;
 }
 
+// Checks wether refback is enabled
+function isRefbackEnabled () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getConfig('refback_enabled') == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
 // [EOF]
 ?>