$confirm) {
if ($confirm == 1) {
$count++;
$result = SQL_QUERY_ESC("SELECT `title`, `action`, `what`, `descr` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Entry found so we load the stuff...
$data = SQL_FETCHARRAY($result);
// Prepare data for the row template
$data = array(
'action' => adminAddMenuSelectionBox('admin', 'action', 'sel_action[' . $sel . ']', $data['action']),
'what' => adminAddMenuSelectionBox('admin', 'what' , 'sel_what[' . $sel . ']', $data['what']),
'sel' => $sel,
'menu' => $data['title'],
'descr' => $data['descr'],
'cnt' => $count,
);
// Load row template
$OUT .= loadTemplate('admin_edit_admin_menu_row', true, $data);
} else {
// Entry not found?
$data = array(
'sel' => $sel
);
// Load row template
$OUT .= loadTemplate('admin_menu_404_row', true, $data);
}
// Free result and switch color
SQL_FREERESULT($result);
} // END - if
} // END - foreach
$content['rows'] = $OUT;
$content['cnt'] = $count;
// Load template
loadTemplate('admin_edit_admin_menu_form', false, $content);
} elseif ((isFormSent('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
// Prepare misc content
$content['sub'] = $SUB;
$content['chk'] = countPostSelection();
// Del menu entries with or without confirmation
$count = '0'; $OUT = '';
foreach (postRequestParameter('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
$result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Entry found so we load the stuff...
$data = SQL_FETCHARRAY($result);
// Prepare data for the row template
$data = array(
'menu' => $data['title'],
'cnt' => $count,
'sel' => $sel,
);
$OUT .= loadTemplate('admin_delete_admin_menu_row', true, $data);
} else {
// Entry not found?
$data = array(
'sel' => $sel
);
$OUT .= loadTemplate('admin_menu_404_row', true, $data);
}
SQL_FREERESULT($result);
} // END - if
} // END - switch
$content['rows'] = $OUT;
$content['cnt'] = $count;
// Load template
loadTemplate('admin_delete_admin_menu', false, $content);
} elseif ((isFormSent()) && (!isDemoModeActive())) {
// An action is done...
switch (postRequestParameter('ok')) {
case 'edit': // Edit menu
foreach (postRequestParameter('sel') as $sel => $menu) {
// Secure id
$sel = bigintval($sel);
// Update entry
SQL_QUERY_ESC("UPDATE
`{?_MYSQL_PREFIX?}_admin_menu`
SET
`title`='%s',
`action`='%s',
`what`='%s',
`descr`='%s'
WHERE
".$AND." AND
`id`=%s
LIMIT 1",
array(
$menu,
postRequestParameter('sel_action', $sel),
postRequestParameter('sel_what', $sel),
postRequestParameter('sel_desc', $sel),
$sel,
), __FILE__, __LINE__);
}
// Load template
displayMessage('{--SETTINGS_SAVED--}');
break;
case 'delete': // Delete menu
foreach (postRequestParameter('sel') as $sel => $menu) {
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
} // END - foreach
// Load template
displayMessage('{--SETTINGS_SAVED--}');
break;
default: // Unexpected action
logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
displayMessage('{%message,ADMIN_UNKNOWN_OKAY=' . postRequestParameter('ok') . '%}');
break;
} // END - switch
} else {
// Handle weightning
doAdminProcessMenuWeightning('admin', $AND);
// Run SQL
$result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." ORDER BY `sort` ASC", __FILE__, __LINE__);
// Do we have entries?
if (!SQL_HASZERONUMS($result)) {
// Remember sub value
$content['sub'] = $SUB;
// Init variables
$OUT = '';
$count = '0';
// Process all entries
while ($data = SQL_FETCHARRAY($result)) {
// Count this entry
$count++;
// Init navigation variable
$data['navi'] = '';
if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($SUB)))) {
// Is highest position
$data['navi'] = '{--LOWER--}';
} elseif ($count == SQL_NUMROWS($result)) {
// Is lowest position
$data['navi'] = '{--HIGHER--}';
} elseif ($data['sort'] > 0) {
// Anything else between highest and lowest
$data['navi'] = '{--HIGHER--}|{--LOWER--}';
}
// Add more data to $data
$data['mode'] = 'admin';
// Load row template and switch colors
$OUT .= loadTemplate('admin_menu_overview_row', true, $data);
} // END - switch
// Remember all rows
$content['rows'] = $OUT;
// Free memory
SQL_FREERESULT($result);
// Load template
loadTemplate('admin_edit_admin_menu', false, $content);
} else {
// Menu entries are missing... (???)
displayMessage('{--ADMIN_NO_MENUS_FOUND--}');
}
}
//
?>