* -------------------------------------------------------------------- *
* Kurzbeschreibung : Das Admin-Menue editieren *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * Needs to be in all Files and every File needs "svn propset *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2008 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
// Some security stuff...
if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
require($INC);
}
// Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+ADD_DESCR('admin', __FILE__);
// Do we edit/delete/change main menus or sub menus?
-$AND = "(`what` = '' OR `what` IS NULL)"; $SUB = "";
-if (REQUEST_ISSET_GET(('sub')))
+$AND = "(`what` = '' OR `what` IS NULL)"; $SUB = '';
+if (REQUEST_ISSET_GET('sub'))
{
- $AND = sprintf("action='%s' AND `what` IS NOT NULL", REQUEST_GET(('sub')));
- $SUB = REQUEST_GET(('sub'));
+ $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", REQUEST_GET('sub'));
+ $SUB = REQUEST_GET('sub');
}
// Get count of (maybe) selected menu points
// Prepare data for the row template
$content = array(
- 'action' => ADMIN_MAKE_MENU_SELECTION("admin", "action", "sel_action[".$sel."]", $act),
- 'what' => ADMIN_MAKE_MENU_SELECTION("admin", "what", "sel_what[".$sel."]", $wht),
+ 'action' => ADMIN_MAKE_MENU_SELECTION('admin', "action", "sel_action[".$sel."]", $act),
+ 'what' => ADMIN_MAKE_MENU_SELECTION('admin', "what", "sel_what[".$sel."]", $wht),
'sw' => $SW,
'sel' => $sel,
'menu' => $menu,
define('__SUB_VALUE', $SUB);
define('__CHK_VALUE', $chk);
// Del menu entries with or without confirmation
- $SW = 2; $cnt = 0; $OUT = "";
+ $SW = 2; $cnt = 0; $OUT = '';
foreach (REQUEST_POST('sel') as $sel => $confirm)
{
if ($confirm == 1)
// Update entry
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_admin_menu` SET
title='%s',
-action='%s',
-what='%s',
+`action`='%s',
+`what`='%s',
descr='%s'
WHERE ".$AND." AND id=%s LIMIT 1",
array(
CACHE_PURGE_ADMIN_MENU(0, REQUEST_POST('sel_action', $sel), REQUEST_POST('sel_what', $sel));
// Load template
- LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_SAVED'));
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
break;
case "del": // Delete menu
foreach (REQUEST_POST('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__);
- CACHE_PURGE_ADMIN_MENU(0, "", "", $AND);
+ CACHE_PURGE_ADMIN_MENU(0, '', '', $AND);
} // END - foreach
// Load template
- LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_SAVED'));
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
break;
default: // Unexpected action
SQL_FREERESULT($result);
} else {
// Main menu selected
- $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE (what='' OR `what` IS NULL) AND `sort`='%s' LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`='%s' LIMIT 1",
array(bigintval(REQUEST_GET('tid'))), __FILE__, __LINE__);
list($tid) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
- $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE (what='' OR `what` IS NULL) AND `sort`='%s' LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`='%s' LIMIT 1",
array(bigintval(REQUEST_GET('fid'))), __FILE__, __LINE__);
list($fid) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
array(bigintval(REQUEST_GET('tid')), bigintval($fid)), __FILE__, __LINE__);
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_admin_menu` SET `sort`='%s' WHERE ".$AND." AND id=%s LIMIT 1",
array(bigintval(REQUEST_GET('fid')), bigintval($tid)), __FILE__, __LINE__);
- CACHE_PURGE_ADMIN_MENU(0, "", "", $AND);
+ CACHE_PURGE_ADMIN_MENU(0, '', '', $AND);
}
}
array($SUB), __FILE__, __LINE__);
} else {
// Main menus
- $result = SQL_QUERY("SELECT id, action, what, title, sort FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE (what='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
+ $result = SQL_QUERY("SELECT id, action, what, title, sort FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
}
$max = SQL_NUMROWS($result);
if ($max > 0) {
+ // @TODO Rewrite this constant
define('__SUB_VALUE', $SUB);
- $SW = 2;
- $cnt = 0;
- $OUT = "";
- while (list($id, $act, $wht, $title, $sort) = SQL_FETCHROW($result)) {
+
+ // Init variables
+ $OUT = ''; $SW = 2; $cnt = 0;
+
+ // Process all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Count this entry
$cnt++;
- if (($sort == 0) || (($sort == 1) && (!empty($SUB)))) {
+
+ // Init navigation variable
+ $content['navi'] = '';
+ if (($content['sort'] == 0) || (($content['sort'] == 1) && (!empty($SUB)))) {
// Is highest position
- $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$act."&w=".$wht."&tid=".($sort+1)."&fid=".$sort."\">{--LOWER--}</a>";
+ $content['navi'] = "<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$content['action']."&w=".$content['what']."&tid=".($content['sort']+1)."&fid=".$content['sort']."\">{--LOWER--}</a>";
} elseif ($cnt == $max) {
// Is lowest position
- $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$act."&w=".$wht."&tid=".($sort-1)."&fid=".$sort."\">{--HIGHER--}</a>";
- } elseif ($sort > 0) {
+ $content['navi'] = "<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$content['action']."&w=".$content['what']."&tid=".($content['sort']-1)."&fid=".$content['sort']."\">{--HIGHER--}</a>";
+ } elseif ($content['sort'] > 0) {
// Anything else between highest and lowest
- $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$act."&w=".$wht."&tid=".($sort-1)."&fid=".$sort."\">{--HIGHER--}</a>/<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$act."&w=".$wht."&tid=".($sort+1)."&fid=".$sort."\">{--LOWER--}</a>";
+ $content['navi'] = "<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$content['action']."&w=".$content['what']."&tid=".($content['sort']-1)."&fid=".$content['sort']."\">{--HIGHER--}</a>/<a href=\"{!URL!}/modules.php?module=admin&what=adminedit&sub={!__SUB_VALUE!}&act=".$content['action']."&w=".$content['what']."&tid=".($content['sort']+1)."&fid=".$content['sort']."\">{--LOWER--}</a>";
}
- if (empty($act)) $act = " ";
- if (empty($wht)) $wht = " ";
- if (empty($title)) $title = " ";
+ // Fix empty elements for constant (fixes display bugs in Firefox)
+ if (empty($content['action'])) $content['action'] = " ";
+ if (empty($content['what'])) $content['what'] = " ";
+ if (empty($content['title'])) $content['title'] = " ";
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'action' => $act,
- 'what' => $wht,
- 'title' => $title,
- 'navi' => $NAVI,
- 'mode' => "admin",
- );
+ // Add more data to $content
+ $content['sw'] = $SW;
+ $content['mode'] = 'admin';
+ // Load row template and switch colors
$OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
$SW = 3 - $SW;
- }
+ } // END - switch
// Free memory
SQL_FREERESULT($result);
+
+ // Rewrite this constant
define('__MENU_ROWS', $OUT);
// Load template
LOAD_TEMPLATE("admin_amenu_edit");
} else {
// Menu entries are missing... (???)
- LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_NO_MENUS_FOUND'));
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MENUS_FOUND'));
}
}