* $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 *
$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="admin_note" title="{%message,MENU_WHAT_404=' . $content['sub_what'] . '%}">';
+ $OUT .= '<em style="cursor:help" class="notice" title="{%message,MENU_WHAT_404=' . $content['sub_what'] . '%}">';
}
// Menu title
if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) $GLOBALS['last_online'] = array();
// is the cache entry there?
- if (isset($GLOBALS['is_member'])) {
+ if (isset($GLOBALS[__FUNCTION__])) {
// Then return it
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHED! (' . intval($GLOBALS['is_member']) . ')');
- return $GLOBALS['is_member'];
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHED! (' . intval($GLOBALS[__FUNCTION__]) . ')');
+ return $GLOBALS[__FUNCTION__];
} elseif ((!isSessionVariableSet('userid')) || (!isSessionVariableSet('u_hash'))) {
// No member
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'No member set in cookie/session.');
}
// Cache status
- $GLOBALS['is_member'] = $ret;
+ $GLOBALS[__FUNCTION__] = $ret;
// Return status
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . intval($ret));
setCurrentUserId($userid);
// Don't look for invalid userids...
- if ($userid < 1) {
+ if (!isValidUserId($userid)) {
// Invalid, so abort here
debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $userid . ' is invalid.');
} elseif (isUserDataValid()) {
} // END - if
// Do we have cache?
- if (!isset($GLOBALS['is_admin'][$adminId])) {
+ if (!isset($GLOBALS[__FUNCTION__][$adminId])) {
// Init it with failed
- $GLOBALS['is_admin'][$adminId] = false;
+ $GLOBALS[__FUNCTION__][$adminId] = false;
// Search in array for entry
if (isset($GLOBALS['admin_hash'])) {
if (!empty($valPass)) {
// Check if password is valid
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '(' . $valPass . '==' . $passCookie . ')='.intval($valPass == $passCookie));
- $GLOBALS['is_admin'][$adminId] = (($GLOBALS['admin_hash'] == $passCookie) || ((strlen($GLOBALS['admin_hash']) == 32) && ($GLOBALS['admin_hash'] == md5($passCookie))) || (($GLOBALS['admin_hash'] == '*FAILED*') && (!isExtensionActive('cache'))));
+ $GLOBALS[__FUNCTION__][$adminId] = (($GLOBALS['admin_hash'] == $passCookie) || ((strlen($GLOBALS['admin_hash']) == 32) && ($GLOBALS['admin_hash'] == md5($passCookie))) || (($GLOBALS['admin_hash'] == '*FAILED*') && (!isExtensionActive('cache'))));
} // END - if
} // END - if
// Return result of comparision
- return $GLOBALS['is_admin'][$adminId];
+ return $GLOBALS[__FUNCTION__][$adminId];
}
// Generates a list of "max receiveable emails per day"
// Should we look for affected rows (only update) or found rows?
if ($updateEntry === true) {
// Check updated/affected rows
- $ret = (SQL_AFFECTEDROWS() == 1);
+ $ret = (!SQL_HASZEROAFFECTED());
} else {
// Check found rows
- $ret = (SQL_NUMROWS($result) == 1);
+ $ret = (!SQL_HASZERONUMS($result));
}
// Free memory
// Init status
$data['action'] = '';
- //* DEBUG: */ debugOutput(__LINE__.'='.$module.'/'.$what.'/'.getAction().'=');
+ //* DEBUG: */ debugOutput(__LINE__ . '=' . $module . '/'.$what . '/' . getAction() . '=');
if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
// sql_patches is missing so choose depending on mode
if (isWhatSet()) {
if ($full === false) {
$ret = $data['mail_title'];
} else {
- $ret = $data['mail_title'] . ' / ' . translateComma($data['price']) . ' {?POINTS?}';
+ $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price'] . '%} {?POINTS?}';
}
}
$ret = 'failed';
// Is the userid valid?
- if ($userid > 0) {
+ if (isValidUserId($userid)) {
// Remove entry from array
unset($receivers[$key]);
* Dynamic referal system, can also send mails!
*
* subject = Subject line, write in lower-case letters and underscore is allowed
- * userid = Referal id wich should receive...
+ * userid = Referal id wich should receive...
* points = ... xxx points
* sendNotify = shall I send the referal an email or not?
* refid = inc/modules/guest/what-confirm.php need this
* for default value will cause no referal will get points ever!!!)
*/
function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $add_mode = 'ref') {
+ // By default nothing has been added
+ $added = false;
+
//* DEBUG: */ debugOutput('----------------------- <font color="#00aa00">' . __FUNCTION__ . ' - ENTRY</font> ------------------------<ul><li>');
// Convert mode to lower-case
$add_mode = strtolower($add_mode);
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>): Referal level increased. DEPTH='.$GLOBALS['ref_level']);
}
- // Default is 'normal' points
- $data = 'points';
-
- // Which points, locked or normal?
- if ($locked === true) $data = 'locked_points';
-
// Check user account
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):userid='.$userid.',points='.$points);
if (fetchUserData($userid)) {
+ // Determine wether the user has some mails to click before he/she gets the points
+ $locked = ifUserPointsLocked($userid);
+
+ // Default is 'normal' points
+ $data = 'points';
+
+ // Which points, locked or normal?
+ if ($locked === true) {
+ $data = 'locked_points';
+ } // END - if
+
// This is the user and his ref
$GLOBALS['cache_array']['add_userid'][getUserData('refid')] = $userid;
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):data='.$data.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$add_mode.' - UPDATE! ('.SQL_AFFECTEDROWS().')');
// No entry updated?
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// First ref in this level! :-)
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`,`ref_depth`,`%s`) VALUES (%s,%s,%s)",
array($data, bigintval($userid), bigintval($GLOBALS['ref_level']), $ref_points), __FUNCTION__, __LINE__);
//* 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;
+ // Check affected rows
+ $added = SQL_AFFECTEDROWS();
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
// Prepare data for the filter
$filterData = array(
'locked' => $locked,
'mode' => 'add',
'sub_mode' => $add_mode,
+ 'added' => $added
);
// Filter it now
- runFilterChain('add_points', $filterData);
+ $filterData = runFilterChain('add_points', $filterData);
+
+ // Extract $added
+ $added = $filterData['added'];
+ //* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):added='.intval($added));
// Points updated, maybe I shall send him an email?
if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) {
// Send email
sendEmail($userid, '{--THANX_REFERAL_ONE_SUBJECT--}', $message);
- } elseif (($sendNotify === true) && (getUserData('refid') == '0') && ($locked === false) && ($add_mode == 'direct')) {
+ } elseif (($sendNotify === true) && (!isValidUserId(getUserData('refid'))) && ($locked === false) && ($add_mode == 'direct')) {
// Prepare content
$content = array(
- 'text' => '{--REASON_DIRECT_PAYMENT--}',
+ 'reason' => '{--REASON_DIRECT_PAYMENT--}',
'points' => $ref_points
);
// And sent it away
sendEmail($userid, '{--DIRECT_PAYMENT_SUBJECT--}', $message);
- if (!isGetRequestParameterSet('mid')) loadTemplate('admin_settings_saved', false, '{--ADMIN_POINTS_ADDED--}');
+ if (!isGetRequestParameterSet('mid')) {
+ // Output message to admin
+ loadTemplate('admin_settings_saved', false, '{--ADMIN_POINTS_ADDED--}');
+ } // END - if
}
// Maybe there's another ref?
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'));
+ $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid')));
} // END - if
} // END - if
} // END - if
- //* DEBUG: */ debugOutput('</li></ul>----------------------- <font color="#aa0000">'.__FUNCTION__.' - EXIT</font> ------------------------<br />');
+ //* DEBUG: */ debugOutput('</li></ul>----------------------- <font color="#aa0000">'.__FUNCTION__.': added=' . intval($added) . ' - EXIT</font> ------------------------<br />');
+ return $added;
}
// Updates the referal counter
// When no entry was updated then we have to create it here
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):updated=' . SQL_AFFECTEDROWS());
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// First count!
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
- array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__);
+ array(
+ bigintval($userid),
+ $GLOBALS['cache_array']['ref_level'][$userid]
+ ), __FUNCTION__, __LINE__);
//* DEBUG: */ debugOutput(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>):userid='.$userid);
} // END - if
}
// Generates an option list from various parameters
-function generateOptionList ($table, $id, $name, $default='', $special='', $where='', $disabled=array()) {
+function generateOptionList ($table, $id, $name, $default = '', $special = '', $where = '', $disabled = array(), $callback = '') {
$ret = '';
if ($table == '/ARRAY/') {
// Selection from array
- if ((is_array($id)) && (is_array($name)) && (count($id)) == (count($name))) {
+ if ((is_array($id)) && (is_array($name)) && ((count($id)) == (count($name)) || (!empty($callback)))) {
// Both are arrays
foreach ($id as $idx => $value) {
$ret .= '<option value="' . $value . '"';
// Disabled!
$ret .= ' disabled="disabled"';
}
+
+ // Is the call-back function set?
+ if (!empty($callback)) {
+ // Call it
+ $name[$idx] = call_user_func_array($callback, array($id[$idx]));
+ } // END - if
+
+ // Finish option tag
$ret .= '>' . $name[$idx] . '</option>';
} // END - foreach
} else {
// Problem in request
- debug_report_bug(__FUNCTION__, __LINE__, 'Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name));
+ debug_report_bug(__FUNCTION__, __LINE__, 'Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name) . ',callback=' . $callback);
}
} else {
// Data from database
// Disabled!
$ret .= ' disabled="disabled"';
}
+
+ // Add it, if set
if (!empty($add)) $add = ' ('.$add.')';
+
+ // Is the call-back function set?
+ if (!empty($callback)) {
+ // Call it
+ $title = call_user_func_array($callback, array($title));
+ } // END - if
+
+ // Finish option list
$ret .= '>' . $title . $add . '</option>';
} // END - while
} else {
'subject' => $subject,
'userid' => $userid,
'points' => $points,
- 'mode' => 'sub'
+ 'mode' => 'sub',
+ 'added' => (!SQL_HASZEROAFFECTED())
);
// Insert booking record
- runFilterChain('sub_points', $filterData);
+ $filterData = runFilterChain('sub_points', $filterData);
+
+ // Return result
+ return $filterData['added'];
}
// "Getter" for total available receivers
} // END - foreach
} else {
// No cateogries are defined yet
- $OUT = '<option class="member_failed">{--MEMBER_NO_CATEGORIES--}</option>';
+ $OUT = '<option class="notice">{--MEMBER_NO_CATEGORIES--}</option>';
}
// Return HTML code