X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=c2387e336dad3eaef53316d07a6f4acb002eb7eb;hb=7997d491854dad4a6a6524d8cd8229a073f7cf59;hp=1a8ebe194ab92d561001406e4dd181168fe3f145;hpb=2379934be6a196a54f4155bb8e24c49b20736969;p=mailer.git
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index 1a8ebe194a..c2387e336d 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -17,7 +17,7 @@
* -------------------------------------------------------------------- *
* 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 *
@@ -279,7 +279,7 @@ ORDER BY
}
} else {
// Not found - open
- $OUT .= '';
+ $OUT .= '';
}
// Menu title
@@ -294,7 +294,7 @@ ORDER BY
} // END - if
} else {
// Not found - close
- $OUT .= '';
+ $OUT .= '';
}
// Cunt it up
@@ -340,16 +340,16 @@ ORDER BY
//* 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
@@ -359,8 +359,8 @@ ORDER BY
// 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);
@@ -959,14 +959,14 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen
// 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
@@ -975,7 +975,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen
} 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,
@@ -986,7 +986,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen
} 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,
@@ -1186,7 +1186,7 @@ function getAdminEmail ($adminId) {
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';
@@ -1195,9 +1195,9 @@ function getAdminDefaultAcl ($adminId) {
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');
@@ -1212,7 +1212,7 @@ function getAdminDefaultAcl ($adminId) {
$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
@@ -1223,6 +1223,43 @@ function getAdminDefaultAcl ($adminId) {
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 = '', $whereStatement = '', $disabled = array(), $callback = '') {
$ret = '';
@@ -1255,13 +1292,13 @@ function generateOptionList ($table, $id, $name, $default = '', $special = '', $
}
} 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` ".$whereStatement." 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,
@@ -1271,32 +1308,37 @@ function generateOptionList ($table, $id, $name, $default = '', $special = '', $
// 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 .= '';
} // END - while
} else {
// No data found
@@ -1471,7 +1513,7 @@ function generateCategoryOptionsList ($mode) {
} // END - foreach
} else {
// No cateogries are defined yet
- $OUT = '';
+ $OUT = '';
}
// Return HTML code
@@ -1649,12 +1691,12 @@ function reduceRecipientReceivedMails ($column, $id, $count) {
}
// 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,
+ makeZeroToNull($adminId),
+ makeZeroToNull($userid),
$taskType,
$subject,
$notes