// Init user data array
initUserData();
- // Fix "deleted" cookies first
+ // Fix "deleted" cookies
fixDeletedCookies(array('userid', 'u_hash'));
// Are cookies set and can the member data be loaded?
if (!isValidUserId($value)) {
// Invalid, so abort here
reportBug(__FUNCTION__, __LINE__, 'User id ' . $value . ' is invalid.');
+ } // END - if
+
+ // Unset cached values if found and different
+ if ((isCurrentUserIdSet()) && (getCurrentUserId() != $value)) {
+ // Unset it
+ unsetCurrentUserId();
} elseif (isUserDataValid()) {
// Use cache, so it is fine
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #1');
return true;
- }
- } elseif (isUserDataValid()) {
+ } // END - if
+ } elseif (isUserDataValid()) {
// Using cache is fine
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #2');
return true;
$found = false;
// Extra SQL statements
- $ADD = runFilterChain('convert_user_data_columns', '');
+ $ADD = runFilterChain('convert_user_data_columns', ' ');
// Query for the user
$result = SQL_QUERY_ESC("SELECT *" . $ADD . " FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1",
- array($column, $value), __FUNCTION__, __LINE__);
+ array(
+ $column,
+ $value
+ ), __FUNCTION__, __LINE__);
// Do we have a record?
if (SQL_NUMROWS($result) == 1) {
}
// Generates an option list from various parameters
-function generateOptions ($table, $id, $name, $default = '', $special = '', $whereStatement = '', $disabled = array(), $callback = '') {
+function generateOptions ($table, $key, $value, $default = '', $extra = '', $whereStatement = '', $disabled = array(), $callback = '') {
$ret = '';
if ($table == '/ARRAY/') {
// Selection from array
- if ((is_array($id)) && (is_array($name)) && ((count($id)) == (count($name)) || (!empty($callback)))) {
+ if ((is_array($key)) && (is_array($value)) && ((count($key)) == (count($value)) || (!empty($callback)))) {
// Both are arrays
- foreach ($id as $idx => $value) {
- $ret .= '<option value="' . $value . '"';
- if ($default == $value) {
+ foreach ($key as $idx => $optionValue) {
+ $ret .= '<option value="' . $optionValue . '"';
+ if ($default == $optionValue) {
// Selected by default
$ret .= ' selected="selected"';
- } elseif (isset($disabled[$value])) {
+ } elseif (isset($disabled[$optionValue])) {
// 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]));
+ $value[$idx] = call_user_func_array($callback, array($key[$idx]));
} // END - if
// Finish option tag
- $ret .= '>' . $name[$idx] . '</option>';
+ $ret .= '>' . $value[$idx] . '</option>';
} // END - foreach
} else {
// Problem in request
- reportBug(__FUNCTION__, __LINE__, 'Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name) . ',callback=' . $callback);
+ reportBug(__FUNCTION__, __LINE__, 'Not all are arrays: key[' . count($key) . ']=' . gettype($key) . ',value[' . count($value) . ']=' . gettype($value) . ',callback=' . $callback);
}
} else {
- // Data from database
- $SPEC = ',`' . $id . '`';
- if (!empty($special)) {
- $SPEC = ',`' . $special . '` AS `special`';
+ ///////////////////////
+ // Data from database /
+ ///////////////////////
+
+ // Init extra column (if requested)
+ $extraColumn = '';
+ if (!empty($extra)) {
+ $extraColumn = ',`' . $extra . '` AS `extra`';
} // END - if
- // Query the database
- $result = SQL_QUERY_ESC("SELECT `%s` AS `id`,`%s` AS `name`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$whereStatement." ORDER BY `%s` ASC",
+ // Run SQL query
+ $result = SQL_QUERY_ESC("SELECT `%s` AS `key`,`%s` AS `value`" . $extraColumn . " FROM `{?_MYSQL_PREFIX?}_%s` " . $whereStatement . " ORDER BY `%s` ASC",
array(
- $id,
- $name,
+ $key,
+ $value,
$table,
- $name
+ $value
), __FUNCTION__, __LINE__);
// Do we have rows?
if (!SQL_HASZERONUMS($result)) {
// Found data so add them as OPTION lines
while ($content = SQL_FETCHARRAY($result)) {
- // Is special set?
- if (!isset($content['special'])) {
+ // Is extra set?
+ if (!isset($content['extra'])) {
// Set it to empty
- $content['special'] = '';
+ $content['extra'] = '';
} // END - if
- $ret .= '<option value="' . $content['id'] . '"';
+ $ret .= '<option value="' . $content['key'] . '"';
- if ($default == $content['id']) {
+ if ($default == $content['key']) {
// Selected by default
$ret .= ' selected="selected"';
- } elseif (isset($disabled[$content['id']])) {
+ } elseif (isset($disabled[$content['key']])) {
// Disabled!
$ret .= ' disabled="disabled"';
}
// Add it, if set
- if (!empty($content['special'])) {
- $content['special'] = ' (' . $content['special'] . ')';
+ if (!empty($content['extra'])) {
+ $content['extra'] = ' (' . $content['extra'] . ')';
} // END - if
// Is the call-back function set?
if (!empty($callback)) {
// Call it
- $content['name'] = call_user_func_array($callback, array($content['name']));
+ $content['value'] = call_user_func_array($callback, array($content['value']));
} // END - if
// Finish option list
- $ret .= '>' . $content['name'] . $content['special'] . '</option>';
+ $ret .= '>' . $content['value'] . $content['extra'] . '</option>';
} // END - while
} else {
// No data found