+// Process menu editing form
+function adminProcessMenuEditForm ($type, $subMenu) {
+ // An action is done...
+ foreach (postRequestParameter('sel') as $sel => $menu) {
+ $AND = "(`what` = '' OR `what` IS NULL)";
+
+ $sel = bigintval($sel);
+
+ if (!empty($subMenu)) {
+ $AND = "`action`='" . $subMenu . "'";
+ } // END - if
+
+ switch (postRequestParameter('ok')) {
+ case 'edit': // Edit menu
+ if (postRequestParameter('sel_what', $sel) == '') {
+ // Update with 'what'=null
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1",
+ array(
+ $type,
+ $menu,
+ postRequestParameter('sel_action', $sel),
+ $sel
+ ), __FILE__, __LINE__);
+ } else {
+ // Update with selected 'what'
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
+ array(
+ $type,
+ $menu,
+ postRequestParameter('sel_action', $sel),
+ postRequestParameter('sel_what', $sel),
+ $sel
+ ), __FILE__, __LINE__);
+ }
+ break;
+
+ case 'delete': // Delete menu
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ array($type, $sel), __FILE__, __LINE__);
+ break;
+
+ case 'status': // Change status of menus
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
+ array($type, postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__);
+ break;
+
+ default: // Unexpected action
+ logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
+ displayMessage('{%message,ADMIN_UNKNOWN_OKAY=' . postRequestParameter('ok') . '%}');
+ break;
+ } // END - switch
+ } // END - foreach
+
+ // Load template
+ displayMessage('{--SETTINGS_SAVED--}');
+}
+
+// Handle weightning
+function doAdminProcessMenuWeightning ($type, $AND) {
+ // Are there all required (generalized) GET parameter?
+ if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
+ // Init variables
+ $tid = ''; $fid = '';
+
+ // Get ids
+ if (isGetRequestParameterSet('w')) {
+ // Sub menus selected
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
+ array(
+ $type,
+ getRequestParameter('act'),
+ bigintval(getRequestParameter('tid'))
+ ), __FILE__, __LINE__);
+ list($tid) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
+ array(
+ $type,
+ getRequestParameter('act'),
+ bigintval(getRequestParameter('fid'))
+ ), __FILE__, __LINE__);
+ list($fid) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
+ } else {
+ // Main menu selected
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
+ array(
+ $type,
+ bigintval(getRequestParameter('tid'))
+ ), __FILE__, __LINE__);
+ list($tid) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
+ array(
+ $type,
+ bigintval(getRequestParameter('fid'))
+ ), __FILE__, __LINE__);
+ list($fid) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
+ }
+
+ if ((!empty($tid)) && (!empty($fid))) {
+ // Sort menu
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
+ array(
+ $type,
+ bigintval(getRequestParameter('tid')),
+ bigintval($fid)
+ ), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
+ array(
+ $type,
+ bigintval(getRequestParameter('fid')),
+ bigintval($tid)
+ ), __FILE__, __LINE__);
+ } // END - if
+ } // END - if
+}
+