$OUT .= '<ul class="admin_menu_main">';
// @TODO Rewrite this to $content = SQL_FETCHARRAY()
while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
- if ((isExtensionActive('admins')) && (getExtensionVersion('admins') > '0.2.0')) {
+ if (isExtensionInstalledAndNewer('admins', '0.2.0')) {
$ACL = adminsCheckAdminAcl($menu, '');
} else {
// @TODO ACL is 'allow'... hmmm
// @TODO Rewrite this to $content = SQL_FETCHARRAY()
while (list($what_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what)) {
// Check for access level
- if ((isExtensionActive('admins')) && (getExtensionVersion('admins') > '0.2.0')) {
+ if (isExtensionInstalledAndNewer('admins', '0.2.0')) {
$ACL = adminsCheckAdminAcl('', $what_sub);
} else {
// @TODO ACL is 'allow'... hmmm
}
// Create member selection box
-function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=false, $field='userid') {
+function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
// Output selection form with all confirmed user accounts listed
$result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
elseif ($none === true) $OUT = ' <option value="0">{--SELECT_NONE--}</option>';
while ($content = SQL_FETCHARRAY($result)) {
- $OUT .= ' <option value="' . bigintval($content['userid']) . '"';
+ $OUT .= '<option value="' . bigintval($content['userid']) . '"';
if ($def == $content['userid']) $OUT .= ' selected="selected"';
$OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
} // END - while
loadTemplate('admin_member_selection_box', false, $content);
} else {
// Return content in selection frame
- return '<select class="admin_select" name="' . $field . '" size="1">' . $OUT . '</select>';
+ return '<select class="admin_select" name="' . handleFieldWithBraces($field) . '" size="1">' . $OUT . '</select>';
}
}
$what = "`what` != ''";
if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` !='login'";
- $result = SQL_QUERY_ESC("SELECT %s, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
+ $result = SQL_QUERY_ESC("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
array($mode), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) > 0) {
// Load menu as selection
- $OUT = "<select name=\"".$mode."_menu";
- if ((!empty($defid)) || ($defid == '0')) $OUT .= "[".$defid."]";
- $OUT .= "\" size=\"1\" class=\"admin_select\">
- <option value=\"\">{--SELECT_NONE--}</option>\n";
- // @TODO Try to rewrite this to $content = SQL_FETCHARRAY(). Please look some lines above for the dynamic query
- while (list($menu, $title) = SQL_FETCHROW($result)) {
- $OUT .= " <option value=\"".$menu."\"";
- if ((!empty($default)) && ($default == $menu)) $OUT .= ' selected="selected"';
- $OUT .= ">".$title."</option>\n";
+ $OUT = '<select name="' . $mode . '_menu';
+ if ((!empty($defid)) || ($defid == '0')) $OUT .= '[' . $defid . ']';
+ $OUT .= '" size="1" class="admin_select">
+ <option value="">{--SELECT_NONE--}</option>';
+ // Load all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ $OUT .= '<option value="' . $content['menu'] . '"';
+ if ((!empty($default)) && ($default == $content['menu'])) $OUT .= ' selected="selected"';
+ $OUT .= '>' . $content['title'] . '</option>';
} // END - while
// Free memory
SQL_FREERESULT($result);
- $OUT .= "</select>\n";
+
+ // Add closing select-tag
+ $OUT .= '</select>';
} else {
// No menus???
$OUT = getMessage('ADMIN_PROBLEM_NO_MENU');
$menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), '', false, false);
// Init the selection box
- $OUT = "<select name=\"".$name."\" class=\"admin_select\" size=\"1\">
- <option value=\"\">{--IS_TOP_MENU--}</option>\n";
+ $OUT = '<select name="' . $name . '" class="admin_select" size="1"><option value="">{--IS_TOP_MENU--}</option>';
// Walk through all files
foreach ($menuArray as $file) {
// Is this a PHP script?
- if ((!isDirectory($file)) && (strpos($file, "".$type.'-') > -1) && (strpos($file, '.php') > 0)) {
+ if ((!isDirectory($file)) && (strpos($file, '' . $type . '-') > -1) && (strpos($file, '.php') > 0)) {
// Then test if the file is readable
$test = sprintf("inc/modules/%s/%s", $menu, $file);
// Is that part different from the overview?
if ($part != 'overview') {
- $OUT .= " <option value=\"".$part."\"";
+ $OUT .= '<option value="' . $part . '"';
if ($part == $default) $OUT .= ' selected="selected"';
- $OUT .= ">".$part."</option>\n";
+ $OUT .= '>' . $part . '</option>';
} // END - if
} // END - if
} // END - if
} // END - foreach
// Close selection box
- $OUT .= "</select>\n";
+ $OUT .= '</select>';
// Return contents
return $OUT;
}
// Send mails for del/edit/lock build modes
-function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '') {
+function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $userid = 'userid') {
// Default subject is the subject part
$subject = $subjectPart;
} // END - if
// Is the raw userid set?
- if (postRequestParameter('userid_raw', $id) > 0) {
+ if (postRequestParameter($userid, $id) > 0) {
// Generate subject
$subjectLine = getMessage('MEMBER_'.strtoupper($subject).'_'.strtoupper($table).'_SUBJECT');
}
// Send email out
- sendEmail(postRequestParameter('userid_raw', $id), $subjectLine, $mail);
+ sendEmail(postRequestParameter($userid, $id), $subjectLine, $mail);
} // END - if
// Generate subject
// Send admin notification out
if (!empty($subjectPart)) {
- sendAdminNotification($subjectLine, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter('userid_raw', $id));
+ sendAdminNotification($subjectLine, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter($userid, $id));
} else {
- sendAdminNotification($subjectLine, 'admin_' . $mode . '_' . $table, $content, postRequestParameter('userid_raw', $id));
+ sendAdminNotification($subjectLine, 'admin_' . $mode . '_' . $table, $content, postRequestParameter($userid, $id));
}
}
// Build a special template list
-function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn) {
+function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') {
$OUT = ''; $SW = 2;
// "Walk" through all entries
$idx = array_search($key, $columns, true);
// Do we have a userid?
- if ($key == 'userid') {
+ if ($key == $userIdColumn) {
// Add it again as raw id
- $content['userid'] = bigintval($value);
+ $content[$userIdColumn] = bigintval($value);
+ $content[$userIdColumn . '_raw'] = $content[$userIdColumn];
+ } // END - if
+
+ // If the key matches the idColumn variable, we need to temporary remember it
+ //* DEBUG: */ print 'key=' . $key . ',idColumn=' . $idColumn . ',value=' . $value . '<br />';
+ if ($key == $idColumn) {
+ // Found, so remember it
+ $GLOBALS['admin_list_builder_id_value'] = $value;
} // END - if
// Handle the call in external function
+ //* DEBUG: */ print 'key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value . '<br />';
$content[$key] = handleExtraValues($filterFunctions[$idx], $value, $extraValues[$idx]);
} // END - foreach
// Then list it
$OUT .= loadTemplate(sprintf("admin_%s_%s_row",
- $listType,
- $table
- ), true, $content
+ $listType,
+ $table
+ ), true, $content
);
// Switch color
}
// Change status of "build" list
-function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray) {
+function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray, $userid = 'userid') {
// All valid entries? (We hope so here!)
if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (count($statusArray) > 0)) {
// "Walk" through all entries
$sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", SQL_ESCAPE($table));
// Load data of entry
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
array($table, $idColumn, $id), __FUNCTION__, __LINE__);
// Fetch the data
} // END - if
} elseif (isset($content[$column])) {
// Unfinished!
- app_die(__FUNCTION__, __LINE__, ":UNFINISHED: id={$id}/{$column}[".gettype($statusInfo)."] = {$content[$column]}");
+ debug_report_bug(__FUNCTION__, __LINE__, ":UNFINISHED: id={$id}/{$column}[".gettype($statusInfo)."] = {$content[$column]}");
}
} // END - foreach
// Add other columns as well
foreach (postRequestArray() as $key => $entries) {
+ // Debug message
+ logDebugMessage(__FUNCTION__, __LINE__, 'Found entry: ' . $key);
+
// Skip id, raw userid and 'do_$mode'
- if (!in_array($key, array($idColumn, 'userid_raw', ('do_'.$mode)))) {
+ if (!in_array($key, array($idColumn, $userid, ('do_' . $mode)))) {
// Are there brackets () at the end?
- if (substr($entries[$id], -2, 2) == "()") {
+ if (substr($entries[$id], -2, 2) == '()') {
// Direct SQL command found
$sql .= sprintf(" %s=%s,", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
} else {
// Add entry
$content[$key] = $entries[$id];
}
- } // END - if
+ } else {
+ // Skipped entry
+ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $key);
+ }
} // END - foreach
// Finish SQL statement
}
// Delete rows by given id numbers
-function adminDeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $deleteNow=false, $idColumn='id', $userIdColumn='userid') {
+function adminDeleteEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $deleteNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
// All valid entries? (We hope so here!)
if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
// Shall we delete here or list for deletion?
if ($deleteNow === true) {
// The base SQL command:
- $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s IN (%s)";
+ $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s` IN (%s)";
// Delete them all
$idList = '';
foreach ($IDs as $id => $sel) {
// Is there a userid?
- if (isPostRequestParameterSet('userid_raw', $id)) {
+ if (isPostRequestParameterSet($userid, $id)) {
// Load all data from that id
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
- array($table, $idColumn, $id), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
+ array(
+ $table,
+ $idColumn,
+ $id
+ ), __FUNCTION__, __LINE__);
// Fetch the data
$content = SQL_FETCHARRAY($result);
} // END - foreach
// Run the query
- SQL_QUERY($sql, array($table, $idColumn, substr($idList, 0, -1)), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC($sql, array($table, $idColumn, substr($idList, 0, -1)), __FUNCTION__, __LINE__);
// Was this fine?
if (SQL_AFFECTEDROWS() == count($IDs)) {
}
// Edit rows by given id numbers
-function adminEditEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $editNow=false, $idColumn='id', $userIdColumn='userid') {
+function adminEditEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $editNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
// All valid entries? (We hope so here!)
if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
// Shall we change here or list for editing?
);
foreach (postRequestArray() as $key => $entries) {
// Skip raw userid which is always invalid
- if ($key == 'userid_raw') {
+ if ($key == $userid) {
// Continue with next field
continue;
} // END - if
// Then add this value
$sql .= sprintf(" `%s`='%s',",
- SQL_ESCAPE($key),
- SQL_ESCAPE($entries[$id])
+ SQL_ESCAPE($key),
+ SQL_ESCAPE($entries[$id])
);
} elseif (($key != $idColumn) && (!is_array($entries))) {
// Add normal entries as well!
// Is the id not set, then we need a backtrace here... :(
if ($id <= 0) {
// Initiate backtrace
- debug_report_bug(sprintf("id is invalid: %s. row=%s, data=%s",
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf("id is invalid: %s. row=%s, data=%s",
$id,
$row,
$data
$adminLink = '<a href="' . generateEmailLink(getAdminEmail($adminId), 'admins') . '" title="{--ADMIN_CONTACT_LINK_TITLE--}">' . $login . '</a>';
} else {
// Extension not found
- $adminLink = getMaskedMessage('EXTENSION_PROBLEM_NOT_INSTALLED', 'admins');
+ $adminLink = getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', 'admins');
}
} else {
// Maybe deleted?