// 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']))) {
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);
break;
default: // Invalid!
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid mode %s detected.", $mode));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('Invalid mode %s detected.', $mode));
break;
}
}
// 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 .= '<option value="0">{--SELECT_NONE--}</option>';
+ } // END - if
+
if ($table == '/ARRAY/') {
// Selection from array
if ((is_array($key)) && (is_array($value)) && ((count($key)) == (count($value)) || (!empty($callback)))) {
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?
$addWhere .= " AND `d`.`holiday_active`='N'";
} // END - if
- // Include only HTML recipients?
- if ((isExtensionActive('html_mail')) && ($mode == 'html')) {
- $addWhere .= " AND `d`.`html`='Y'";
- } // END - if
-
// Run query
$result = sqlQueryEscaped("SELECT
`d`.`userid`
// Call the callback-function
//* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'callbackFunction=' . $callbackName . ',args=<pre>'.print_r($args, TRUE).'</pre>');
- // @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
$content = array();
// Prepare SQL for this row
- $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET",
+ $sql = sprintf('UPDATE `{?_MYSQL_PREFIX?}_%s` SET',
sqlEscapeString($tableName[0])
);
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]
?>