* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
* Copyright (c) 2009 - 2011 by Mailer Developer Team *
- * For more information visit: http://www.mxchange.org *
+ * For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
// Fix empty 'what'
if (empty($what)) {
$what = getIndexHome();
- } elseif ((isGetRequestParameterSet('action')) && ($column == 'what')) {
+ } elseif ((isGetRequestElementSet('action')) && ($column == 'what')) {
// Get it from action
return getTitleFromMenu($mode, getAction(), 'action', $ADD);
} elseif ($what == 'overview') {
}
} else {
// Not found - open
- $OUT .= '<em style="cursor:help" class="notice" title="{%message,ADMIN_MENU_WHAT_404_TITLE=' . $content['sub_what'] . '%}">';
+ $OUT .= '<span class="bad" style="cursor:help" title="{%message,ADMIN_MENU_WHAT_404_TITLE=' . $content['sub_what'] . '%}">';
}
// Menu title
} // END - if
} else {
// Not found - close
- $OUT .= '</em>';
+ $OUT .= '</span>';
}
// Cunt it up
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat());
if (SQL_NUMROWS($result_main) > $main_cnt) {
- // Add seperator
- $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode);
+ // Add separator
+ $GLOBALS['rows'] .= loadTemplate('menu_separator', true, $mode);
// Should we display adverts in this menu?
if ((isExtensionInstalledAndNewer('menu', '0.0.1')) && (getConfig($mode . '_menu_advert_enabled') == 'Y') && ($action != 'admin')) {
// Display advert template
$GLOBALS['rows'] .= loadTemplate('menu_' . $mode . '_advert_' . $action, true);
- // Add seperator again
- $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode);
+ // Add separator again
+ $GLOBALS['rows'] .= loadTemplate('menu_separator', true, $mode);
} // END - if
} // END - if
} // END - while
// Should we display adverts in this menu?
if ((isExtensionInstalledAndNewer('menu', '0.0.1')) && (getConfig($mode . '_menu_advert_enabled') == 'Y')) {
- // Add seperator again
- $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode);
+ // Add separator again
+ $GLOBALS['rows'] .= loadTemplate('menu_separator', true, $mode);
// Display advert template
$GLOBALS['rows'] .= loadTemplate('menu_' . $mode . '_advert_end', true);
// Prepare data
$content = array(
- 'rows' => $GLOBALS['rows'],
- 'mode' => $mode
+ 'rows' => $GLOBALS['rows'],
+ 'menu_mode' => $mode
);
// Load main template
$OUT = '';
while ($content = SQL_FETCHARRAY($result)) {
$OUT .= ' <option value="' . $content['value'] . '"';
- if (postRequestParameter('max_mails') == $content['value']) $OUT .= ' selected="selected"';
+ if (postRequestElement('max_mails') == $content['value']) $OUT .= ' selected="selected"';
$OUT .= '>' . $content['value'] . ' {--PER_DAY--}';
if (!empty($content['comment'])) $OUT .= '(' . $content['comment'] . ')';
$OUT .= '</option>';
// Checks wether the given email address is used.
function isEmailTaken ($email) {
+ // Default is no userid
+ $useridSql = ' IS NOT NULL';
+
+ // Is a member logged in?
+ if (isMember()) {
+ // Get userid
+ $useridSql = '!= ' . bigintval(getMemberId());
+ } // END - if
+
// Replace dot with {DOT}
$email = str_replace('.', '{DOT}', $email);
// Query the database
- $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email` LIKE '%%%s%%' LIMIT 1",
- array($email), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ COUNT(`userid`) AS `cnt`
+FROM
+ `{?_MYSQL_PREFIX?}_user_data`
+WHERE
+ '%s' REGEXP `email` AND
+ `userid` %s
+LIMIT 1",
+ array(
+ $email,
+ $useridSql
+ ), __FUNCTION__, __LINE__);
// Is the email there?
- $isTaken = (SQL_NUMROWS($result) == 1);
+ list($count) = SQL_FETCHROW($result);
// Free the result
SQL_FREERESULT($result);
// Return result
- return $isTaken;
+ return ($count == 1);
}
// Validate the given menu action
-function isMenuActionValid ($mode, $action, $what, $updateEntry=false) {
+function isMenuActionValid ($mode, $action, $what, $updateEntry = false) {
// Is the cache entry there and we shall not update?
if ((isset($GLOBALS['action_valid'][$mode][$action][$what])) && ($updateEntry === false)) {
// Count cache hit
if ($module == 'admin') {
// Action value for admin area
- if (isGetRequestParameterSet('action')) {
+ if (isGetRequestElementSet('action')) {
// Use from request!
- return getRequestParameter('action');
+ return getRequestElement('action');
} elseif (isActionSet()) {
// Get it directly from URL
return getAction();
$module = mapModuleToTable($module);
// Guest and member menu is 'main' as the default
- if (empty($data['action'])) $data['action'] = 'main';
+ if (empty($data['action'])) {
+ $data['action'] = 'main';
+ } // END - if
// Load from database
$result = SQL_QUERY_ESC("SELECT `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `what`='%s' LIMIT 1",
- array($module, $what), __FUNCTION__, __LINE__);
+ array(
+ $module,
+ $what
+ ), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load action value and pray that this one is the right you want... ;-)
$data = SQL_FETCHARRAY($result);
}
// Remove a receiver's id from $receivers and add a link for him to confirm
-function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $isBonusMail = false) {
+function removeReceiver (&$receivers, $key, $userid, $poolId, $statsId = 0, $isBonusMail = false) {
// Default is not removed
$ret = 'failed';
unset($receivers[$key]);
// Is there already a line for this user available?
- if ($stats_id > 0) {
+ if ($statsId > 0) {
// Default is 'normal' mail
$type = 'NORMAL';
$rowName = 'stats_id';
} // END - if
// Try to look the entry up
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE %s='%s' AND `userid`=%s AND link_type='%s' LIMIT 1",
- array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s AND `userid`=%s AND link_type='%s' LIMIT 1",
+ array(
+ $rowName,
+ bigintval($statsId),
+ bigintval($userid),
+ $type
+ ), __FUNCTION__, __LINE__);
// Was it *not* found?
if (SQL_HASZERONUMS($result)) {
// So we add one!
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`,`userid`,`link_type`) VALUES ('%s','%s','%s')",
- array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
+ array(
+ $rowName,
+ bigintval($statsId),
+ bigintval($userid),
+ $type
+ ), __FUNCTION__, __LINE__);
// Update 'mails_sent' if sql_patches is updated
if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) {
// Update the pool
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1",
- array(bigintval($pool_id)), __FUNCTION__, __LINE__);
+ array(bigintval($poolId)), __FUNCTION__, __LINE__);
} // END - if
$ret = 'done';
} else {
// Count or sum whole table?
if ($countRows === true) {
// Count whole table
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
+ $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName
), __FUNCTION__, __LINE__);
} else {
// Sum whole table
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
+ $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName
} elseif (($countRows === true) || ($lookFor == 'userid')) {
// Count rows
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT!');
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+ $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
} else {
// Add all rows
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM!');
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+ $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
return $data['email'];
}
-// Get default ACL of admin id
+// Get default ACL of admin id
function getAdminDefaultAcl ($adminId) {
// By default an invalid ACL value is returned
$data['default_acl'] = 'NO-ACL';
if (!isExtensionActive('sql_patches')) {
// Not found, which is bad, so we need to allow all
$data['default_acl'] = 'allow';
- } elseif (isset($GLOBALS['cache_array']['admin']['def_acl'][$adminId])) {
+ } elseif (isset($GLOBALS['cache_array']['admin']['default_acl'][$adminId])) {
// Use cache
- $data['default_acl'] = $GLOBALS['cache_array']['admin']['def_acl'][$adminId];
+ $data['default_acl'] = $GLOBALS['cache_array']['admin']['default_acl'][$adminId];
// Update cache hits
incrementStatsEntry('cache_hits');
$data = SQL_FETCHARRAY($result_admin_id);
// Set cache
- $GLOBALS['cache_array']['admin']['def_acl'][$adminId] = $data['default_acl'];
+ $GLOBALS['cache_array']['admin']['default_acl'][$adminId] = $data['default_acl'];
}
// Free result
return $data['default_acl'];
}
+// Get menu mode (la_mode) of admin id
+function getAdminMenuMode ($adminId) {
+ // By default an invalid mode
+ $data['la_mode'] = 'INVALID';
+
+ // Is sql_patches there and was it found in cache?
+ if (!isExtensionActive('sql_patches')) {
+ // Not found, which is bad, so we need to allow all
+ $data['la_mode'] = 'global';
+ } elseif (isset($GLOBALS['cache_array']['admin']['la_mode'][$adminId])) {
+ // Use cache
+ $data['la_mode'] = $GLOBALS['cache_array']['admin']['la_mode'][$adminId];
+
+ // Update cache hits
+ incrementStatsEntry('cache_hits');
+ } elseif (!isExtensionActive('cache')) {
+ // Load from database
+ $result_admin_id = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ array(bigintval($adminId)), __FUNCTION__, __LINE__);
+
+ // Do we have an entry?
+ if (SQL_NUMROWS($result_admin_id) == 1) {
+ // Fetch data
+ $data = SQL_FETCHARRAY($result_admin_id);
+
+ // Set cache
+ $GLOBALS['cache_array']['admin']['la_mode'][$adminId] = $data['la_mode'];
+ }
+
+ // Free result
+ SQL_FREERESULT($result_admin_id);
+ }
+
+ // Return default ACL
+ return $data['la_mode'];
+}
+
// Generates an option list from various parameters
-function generateOptionList ($table, $id, $name, $default = '', $special = '', $where = '', $disabled = array(), $callback = '') {
+function generateOptionList ($table, $id, $name, $default = '', $special = '', $whereStatement = '', $disabled = array(), $callback = '') {
$ret = '';
if ($table == '/ARRAY/') {
// Selection from array
}
} else {
// Data from database
- $SPEC = ', `' . $id . '`';
+ $SPEC = ',`' . $id . '`';
if (!empty($special)) {
- $SPEC = ', `' . $special . '`';
+ $SPEC = ',`' . $special . '` AS `special`';
} // END - if
// Query the database
- $result = SQL_QUERY_ESC("SELECT `%s`,`%s`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$where." ORDER BY `%s` ASC",
+ $result = SQL_QUERY_ESC("SELECT `%s` AS `id`,`%s` AS `name`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$whereStatement." ORDER BY `%s` ASC",
array(
$id,
$name,
// Do we have rows?
if (!SQL_HASZERONUMS($result)) {
- // Found data so add them as OPTION lines: $id is the value and $name is the "name" of the option
- // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
- while (list($value, $title, $add) = SQL_FETCHROW($result)) {
- if (empty($special)) $add = '';
- $ret .= '<option value="' . $value . '"';
- if ($default == $value) {
+ // Found data so add them as OPTION lines
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Is special set?
+ if (!isset($content['special'])) {
+ // Set it to empty
+ $content['special'] = '';
+ } // END - if
+
+ $ret .= '<option value="' . $content['id'] . '"';
+
+ if ($default == $content['id']) {
// Selected by default
$ret .= ' selected="selected"';
- } elseif (isset($disabled[$value])) {
+ } elseif (isset($disabled[$content['id']])) {
// Disabled!
$ret .= ' disabled="disabled"';
}
// Add it, if set
- if (!empty($add)) {
- $add = ' ('.$add.')';
+ if (!empty($content['special'])) {
+ $content['special'] = ' (' . $content['special'] . ')';
} // END - if
// Is the call-back function set?
if (!empty($callback)) {
// Call it
- $title = call_user_func_array($callback, array($title));
+ $content['name'] = call_user_func_array($callback, array($content['name']));
} // END - if
// Finish option list
- $ret .= '>' . $title . $add . '</option>';
+ $ret .= '>' . $content['name'] . $content['special'] . '</option>';
} // END - while
} else {
// No data found
// Gets the matching what name from module
function getWhatFromModule ($modCheck) {
// Is the request element set?
- if (isGetRequestParameterSet('what')) {
+ if (isGetRequestElementSet('what')) {
// Then return this!
- return getRequestParameter('what');
+ return getRequestElement('what');
} // END - if
// Default is empty
} // END - foreach
} else {
// No cateogries are defined yet
- $OUT = '<option class="notice">{--MEMBER_NO_CATEGORIES--}</option>';
+ $OUT = '<option class="bad">{--MEMBER_NO_CATEGORIES--}</option>';
}
// Return HTML code
}
// Creates a new task
-function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = '0', $strip = true) {
+function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = NULL, $strip = true) {
// Insert the task data into the database
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`,`userid`,`status`,`task_type`,`subject`,`text`,`task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())",
array(
- $adminId,
- $userid,
+ convertZeroToNull($adminId),
+ convertZeroToNull($userid),
$taskType,
$subject,
$notes