X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=619b58c9ee068b839b6a038cae059c8a52f56c43;hp=da948fbee81fbe68a32abe9adba2f5357564d939;hb=4373e155854012d687fdfcae4c69d1a940883fab;hpb=1ba8d9449de1b6fea32e88d581fb7c121b0522b1 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index da948fbee8..619b58c9ee 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -10,11 +10,6 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Alle datenbank-relevanten Funktionen * * -------------------------------------------------------------------- * - * $Revision:: $ * - * $Date:: $ * - * $Tag:: 0.2.1-FINAL $ * - * $Author:: $ * - * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * @@ -273,7 +268,7 @@ ORDER BY // Full file name for checking menu //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sub_what=' . $content['sub_what']); - $inc = sprintf("inc/modules/%s/what-%s.php", $mode, $content['sub_what']); + $inc = sprintf('inc/modules/%s/what-%s.php', $mode, $content['sub_what']); if (isIncludeReadable($inc)) { // Mark currently selected menu - open if ((!empty($what)) && (($what == $content['sub_what']))) { @@ -331,7 +326,7 @@ ORDER BY enableBlockMode(); // Load menu block - $INC = sprintf("inc/modules/%s/action-%s.php", $mode, $content['action']); + $INC = sprintf('inc/modules/%s/action-%s.php', $mode, $content['action']); if (isFileReadable($INC)) { // Load include file if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_begin', TRUE, $mode); @@ -658,7 +653,7 @@ function addMaxReceiveList ($mode, $default = '') { break; default: // Invalid! - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid mode %s detected.", $mode)); + logDebugMessage(__FUNCTION__, __LINE__, sprintf('Invalid mode %s detected.', $mode)); break; } @@ -1387,8 +1382,15 @@ function getAdminMenuMode ($adminId) { } // Generates an option list from various parameters -function generateOptions ($table, $key, $value, $default = '', $extra = '', $whereStatement = '', $disabled = array(), $callback = '') { +function generateOptions ($table, $key, $value, $default = '', $extra = '', $whereStatement = '', $disabled = array(), $callback = '', $allowNone = FALSE) { $ret = ''; + + // Allow none? + if ($allowNone === TRUE) { + // Add option for none + $ret .= ''; + } // END - if + if ($table == '/ARRAY/') { // Selection from array if ((is_array($key)) && (is_array($value)) && ((count($key)) == (count($value)) || (!empty($callback)))) { @@ -1782,7 +1784,7 @@ function generateReceiverList ($categoryId, $receiver, $mode = '') { if (isValidId($categoryId)) { // Select category $extraColumns = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS `c` ON `d`.`userid`=`c`.`userid`"; - $addWhere = sprintf(" AND `c`.`cat_id`=%s", $categoryId); + $addWhere = sprintf(' AND `c`.`cat_id`=%s', $categoryId); } // END - if // Exclude users in holiday? @@ -2016,7 +2018,7 @@ function doListEntries ($sql, $tableTemplate, $noEntryMessageId, $rowTemplate, $ // Call the callback-function //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'callbackFunction=' . $callbackName . ',args=
'.print_r($args, TRUE).'
'); - // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided + // @TODO If the EL sub-system can support more than one parameter, this call_user_func_array() can be avoided $row[$columnName] = call_user_func_array($callbackName, $args); } // END - foreach @@ -2181,7 +2183,7 @@ function doGenericEditEntriesConfirm ($tableName, $columns = array(), $filterFun $content = array(); // Prepare SQL for this row - $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", + $sql = sprintf('UPDATE `{?_MYSQL_PREFIX?}_%s` SET', sqlEscapeString($tableName[0]) ); @@ -2505,5 +2507,43 @@ function addKeyValueSql ($key, $value) { return $sql; } +// "Getter" for an array from given table and columns +function getArrayFromTable ($tableName, $columns, $orderBy, $ordered = 'ASC', $whereSql = '') { + // The table must exist + assert(ifSqlTableExists($tableName)); + + // Search for it + $result = sqlQueryEscaped('SELECT + `' . implode('`, `', $columns) . '` +FROM + `{?_MYSQL_PREFIX?}_%s` +' . $whereSql . ' +ORDER BY + `%s` %S', + array( + $tableName, + $orderBy, + $ordered + ), __FUNCTION__, __LINE__ + ); + + // Init array + $rows = array(); + + // Are there entries? + if (!ifSqlHasZeroNums($result)) { + // Load all entries + while ($row = sqlFetchArray($result)) { + array_push($rows, $row); + } // END - while + } // END - if + + // Free result + sqlFreeResult($result); + + // Return all found rows + return $rows; +} + // [EOF] ?>