// This is a 'what file'!
$type = 'what';
$search = substr($file, 5);
- $ADD = " AND `visible`='Y' AND `locked`='N'";
// Get access level from it
$modCheck = getModuleFromFileName($file, $accessLevel);
// Do we have admin? Then display all
- if (isAdmin()) $ADD = '';
+ $ADD = " AND `visible`='Y' AND `locked`='N'";
+ if (isAdmin()) {
+ // Display all!
+ $ADD = '';
+ } // END - if
$dummy = substr($search, 0, -4);
$ADD .= sprintf(" AND `action`='%s'", getActionFromModuleWhat($accessLevel, $dummy));
$OUT .= '<a name="menu" class="menu_blur" href="{%url=modules.php?module=' . getModule() . '&what=' . $content['sub_what'] . '%}" target="_self">';
} else {
// Not found - open
- $OUT .= '<em style="cursor:help" class="notice" title="{%message,ADMIN_MENU_WHAT_404=' . $content['sub_what'] . '%}">';
+ $OUT .= '<em style="cursor:help" class="notice" title="{%message,ADMIN_MENU_WHAT_404_TITLE=' . $content['sub_what'] . '%}">';
}
// Menu title
}
// Calculate sum (default) or count records of given criteria
-function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') {
+function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '', $mode = '=') {
// Init count/sum
$data['res'] = '0';
if ($countRows === true) {
// Count whole table
$result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
- array($lookFor, $tableName), __FUNCTION__, __LINE__);
+ array(
+ $lookFor,
+ $tableName
+ ), __FUNCTION__, __LINE__);
} else {
// Sum whole table
$result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
- array($lookFor, $tableName), __FUNCTION__, __LINE__);
+ array(
+ $lookFor,
+ $tableName
+ ), __FUNCTION__, __LINE__);
}
} elseif (($countRows === true) || ($lookFor == 'userid')) {
// Count rows
//* DEBUG: */ debugOutput('COUNT!');
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s'".$add,
- array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+ array(
+ $lookFor,
+ $tableName,
+ $whereStatement,
+ $mode,
+ $search
+ ), __FUNCTION__, __LINE__);
} else {
// Add all rows
//* DEBUG: */ debugOutput('SUM!');
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s'".$add,
- array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+ array(
+ $lookFor,
+ $tableName,
+ $whereStatement,
+ $mode,
+ $search
+ ), __FUNCTION__, __LINE__);
}
// Load row
} // END - if
} elseif (!isExtensionActive('cache')) {
// Get referal data
- $result_level = SQL_QUERY_ESC("SELECT `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level`='%s' LIMIT 1",
+ $result_level = SQL_QUERY_ESC("SELECT `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level`=%s LIMIT 1",
array(bigintval($level)), __FUNCTION__, __LINE__);
// Entry found?
if (!isset($GLOBALS['ref_level'])) {
// Initialialize referal system
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal system initialized!');
- $GLOBALS['ref_level'] = '0';
+ $GLOBALS['ref_level'] = NULL;
} else {
// Increase referal level
$GLOBALS['ref_level']++;
$pointsColumn,
$ref_points,
bigintval($userid),
- bigintval($GLOBALS['ref_level'])
+ makeZeroToNull($GLOBALS['ref_level'])
), __FUNCTION__, __LINE__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'pointsColumn='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - UPDATE! ('.SQL_AFFECTEDROWS().')');
array(
$pointsColumn,
bigintval($userid),
- bigintval($GLOBALS['ref_level']),
+ makeZeroToNull($GLOBALS['ref_level']),
$ref_points
), __FUNCTION__, __LINE__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'data='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - INSERTED! ('.SQL_AFFECTEDROWS().')');
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',level='.$GLOBALS['cache_array']['ref_level'][$userid]);
// Update counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`='%s' LIMIT 1",
- array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`=%s LIMIT 1",
+ array(
+ bigintval($userid),
+ bigintval($GLOBALS['cache_array']['ref_level'][$userid])
+ ), __FUNCTION__, __LINE__);
// When no entry was updated then we have to create it here
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'updated=' . SQL_AFFECTEDROWS());
function getUserReferalPoints ($userid, $level) {
//* DEBUG: */ debugOutput('----------------------- <font color="#00aa00">'.__FUNCTION__.' - ENTRY</font> ------------------------<ul><li>');
// Default is no refs and no nickname
- $add = '';
$refs = array();
- // Do we have nickname extension installed?
- if (isExtensionActive('nickname')) {
- $add = ', ud.nickname';
- } // END - if
-
// Get refs from database
$result = SQL_QUERY_ESC("SELECT
- ur.id, ur.refid, ud.status, ud.last_online, ud.mails_confirmed, ud.emails_received".$add."
+ ur.`id`, ur.`refid`, ud.`status`, ud.`last_online`, ud.`mails_confirmed`, ud.`emails_received`
FROM
`{?_MYSQL_PREFIX?}_user_refs` AS ur
LEFT JOIN
`{?_MYSQL_PREFIX?}_user_points` AS up
ON
- ur.refid=up.userid AND ur.level=0
+ ur.refid=up.userid AND
+ (ur.level=0 OR ur.level IS NULL)
LEFT JOIN
`{?_MYSQL_PREFIX?}_user_data` AS ud
ON
- ur.refid=ud.userid
+ ur.`refid`=ud.`userid`
WHERE
- ur.userid=%s AND ur.level=%s
+ ur.`userid`=%s AND
+ ur.`level`=%s
ORDER BY
- ur.refid ASC",
+ ur.`refid` ASC",
array(
bigintval($userid),
bigintval($level)
array(implode(',', $userids), count($userids)), __FUNCTION__, __LINE__);
} else {
// Nothing deleted
- displayMessage(getMaskedMessage('ADMIN_MAIL_NOTHING_DELETED', $id));
+ displayMessage('{%message,ADMIN_MAIL_NOTHING_DELETED=' . $id . '%}');
}
} // END - if
// Get points data for given extension's name
function getPointsDataArrayFromExtensionName ($ext_name) {
// If we have cache, shortcut it here
- if (isset($GLOBALS['cache_array']['points_data'])) {
+ if (isset($GLOBALS['cache_array']['points_data'][$ext_name])) {
// Return it
- return $GLOBALS['cache_array']['points_data'];
+ return $GLOBALS['cache_array']['points_data'][$ext_name];
} // END - if
// Now checkout the entry in database table
// Add all remaining entries
foreach ($pointsData as $key=>$value) {
- $GLOBALS['cache_array']['points_data'][$key][$ext_name][$isLocked] = $value;
+ $GLOBALS['cache_array']['points_data'][$ext_name][$key] = $value;
} // END - foreach
} else {
/*
* Having no entry is not bad but it means that all points will go to
* the general account which the user can let payout.
*/
- logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',isLocked=' . intval($isLocked) . ' - No entry found, switching to general points account.');
+ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - No entry found, switching to general points account.');
}
// Free result
SQL_FREERESULT($result);
// Return it
- return $GLOBALS['cache_array']['points_data'];
+ return $GLOBALS['cache_array']['points_data'][$ext_name];
}
// Determines the right points column name for given extension and 'locked'
} // END - if
// Return the result
- return $columName;
+ return $columnName;
}
// Determines the payment method for given extension and 'locked'
$paymentMethod = $pointsData['payment_method'];
// Return the result
- return $columName;
+ return $paymentMethod;
}
// [EOF]