]> git.mxchange.org Git - mailer.git/commitdiff
Rewritten handling of menu weightning and updating/deleting menu entries except admin...
authorRoland Häder <roland@mxchange.org>
Fri, 5 Nov 2010 01:18:28 +0000 (01:18 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 5 Nov 2010 01:18:28 +0000 (01:18 +0000)
DOCS/TODOs.txt
inc/functions.php
inc/language/de.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-adminedit.php
inc/modules/admin/what-guestedit.php
inc/modules/admin/what-memedit.php

index 5db8e464b9af12fe53e7507473046f0c5c07e126..4e5d82b8501beed661eab1129af05da11830a6fe 100644 (file)
 ./inc/functions.php:1593:                      // @TODO Are these convertions still required?
 ./inc/functions.php:1611:// @TODO Rewrite this function to use readFromFile() and writeToFile()
 ./inc/functions.php:181:// @TODO Rewrite this to an extension 'smtp'
-./inc/functions.php:2277:      // @TODO This is still very static, rewrite it somehow
+./inc/functions.php:2271:      // @TODO This is still very static, rewrite it somehow
 ./inc/gen_sql_patches.php:94:// @TODO Rewrite this to a filter
 ./inc/install-functions.php:57:        // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
 ./inc/language/de.php:1091:// @TODO Rewrite these two constants
 ./inc/language/de.php:1106:// @TODO Rewrite these three constants
 ./inc/language/de.php:286:     // @TODO Following two are unused?
-./inc/language/de.php:789:// @TODO Are these constants longer used?
+./inc/language/de.php:790:// @TODO Are these constants longer used?
 ./inc/language-functions.php:243:      // @TODO These are all valid languages, again hard-coded
 ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function.
 ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no       *
index 8394f5f98c3e62932c4a10c59e4a06283368c0ad..4cd8715360a4e2215763538d547bc3198d3abe2b 100644 (file)
@@ -2142,19 +2142,13 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
                                // Remove both for extension name
                                $extName = substr($baseFile, strlen($prefix), -4);
 
-                               // Is the extension valid and active?
-                               if (isExtensionNameValid($extName)) {
-                                       // Then add this file
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Extension entry ' . $baseFile . ' added.');
+                               // Add file with or without base path
+                               if ($addBaseDir === true) {
+                                       // With base path
                                        $files[] = $fileName;
                                } else {
-                                       // Add non-extension files as well
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Regular entry ' . $baseFile . ' added.');
-                                       if ($addBaseDir === true) {
-                                               $files[] = $fileName;
-                                       } else {
-                                               $files[] = $baseFile;
-                                       }
+                                       // No base path
+                                       $files[] = $baseFile;
                                }
                        } else {
                                // We found .php file but should not search for them, why?
index e321cf5acf60594e3b1ea1f31e7b66647432e195..7c60b04d45266f523cb18d4bf1c8b15b4bc01e8b 100644 (file)
@@ -646,7 +646,8 @@ addMessages(array(
        'GUEST_STATS_YREGISTER' => "Gestrige Anmeldungen",
        'GUEST_STATS_INACTIVE' => "Mitgliederstatistik deaktiviert",
        'ADMIN_CHANGE_MENUS' => "&Auml;ndern",
-       'ADMIN_CHANGE_MEMBER_MENU' => "Verdecken, anzeigen, deaktivieren, aktivieren des Mitgliedsmen&uuml;s",
+       'ADMIN_CHANGE_MEMBER_MENU_TITLE' => "Verdecken, anzeigen, deaktivieren, aktivieren des Mitgliedsmen&uuml;s",
+       'ADMIN_CHANGE_GUEST_MENU_TITLE' => "Verdecken, anzeigen, deaktivieren, aktivieren des Gastmen&uuml;s",
        'ADMIN_CHANGE_MENU' => "&Auml;ndern von <span class=\"data\">%s</span> Men&uuml;eintr&auml;gen",
        'ADMIN_IS_VISIBLE' => "Wird angezeigt",
        'ADMIN_IS_ACTIVE' => "Aktiviert",
@@ -856,7 +857,6 @@ addMessages(array(
        'CLICK_NOW' => "Hier best&auml;tigen",
        'MAILID_LINK' => "Best.-Link",
        'UNKNOWN_MAILID_CODE' => "Unbekannter Fehler-Code <span class=\"data\">%s</span> erkannt.",
-       'ADMIN_CHANGE_GUEST_MENU_TITLE' => "Verdecken, anzeigen, deaktivieren, aktivieren des Gastmen&uuml;s",
        'ADMIN_MENU_IS_LOCKED' => "Ist gesperrt",
        'ADMIN_REMOVE_STATS_ENTRY' => "Hier klicken, um Mitgliederstatistik zu entfernen.",
        'ADMIN_USER_STATS_REMOVED' => "Mitgliederstatistiken entfernt.",
index cf76c3b12c0d4daee8bd01f4ef451f511a4abb1b..0f7b4897f77c582b048c75ed197ccc9bc61d519e 100644 (file)
@@ -587,7 +587,7 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement
 // Generate a selection box
 function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
        // Open the requested menu directory
-       $menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), '', false, false);
+       $menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), $type . '-', false, false);
 
        // Init the selection box
        $OUT = '<select name="' . $name . '" class="form_select" size="1"><option value="">{--ADMIN_IS_TOP_MENU--}</option>';
@@ -1429,5 +1429,124 @@ function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=f
        }
 }
 
+// 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')));
+                               loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok')));
+                               break;
+               } // END - switch
+       } // END - foreach
+
+       // Load template
+       loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
+}
+
+// Handle weightning
+function doAdminProcessMenuWeightning ($type) {
+       // 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
+}
+
 // [EOF]
 ?>
index 023110a00f83f95e4a97d549dbb73d6b3f206353..3e7c9680cc2b57ef806f3e724b3493c84ab874aa 100644 (file)
@@ -185,57 +185,8 @@ LIMIT 1",
                        break;
        }
 } else {
-       if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
-               // Get ids
-               if (isGetRequestParameterSet('w')) {
-                       // Sub menus selected
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `what` != '%s' AND `sort`=%s LIMIT 1",
-                               array(
-                                       getRequestParameter('w'),
-                                       bigintval(getRequestParameter('tid'))
-                               ), __FILE__, __LINE__);
-                       list($tid) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `what`='%s' AND `sort`=%s LIMIT 1",
-                               array(
-                                       getRequestParameter('w'),
-                                       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?}_admin_menu` WHERE `action` != %s AND ".$AND." AND `sort`=%s LIMIT 1",
-                               array(
-                                       getRequestParameter('act'),
-                                       bigintval(getRequestParameter('tid'))
-                               ), __FILE__, __LINE__);
-                       list($tid) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`=%s AND ".$AND." AND `sort`=%s LIMIT 1",
-                               array(
-                                       getRequestParameter('act'),
-                                       bigintval(getRequestParameter('fid'))
-                               ), __FILE__, __LINE__);
-                       list($fid) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-               }
-
-               // Do we have entries found?
-               if ((!empty($tid)) && (!empty($fid))) {
-                       // Sort menu
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
-                               array(
-                                       bigintval(getRequestParameter('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(getRequestParameter('fid')),
-                                       bigintval($tid)
-                               ), __FILE__, __LINE__);
-               } // END - if
-       } // END - if
+       // Handle weightning
+       doAdminProcessMenuWeightning('guest');
 
        // Run SQL
        $result = SQL_QUERY("SELECT id, action, what, title, sort FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." ORDER BY `sort` ASC", __FILE__, __LINE__);
index bbc77d0572be3ba90c6eae937d184468915980f0..2a9d15f2773e51d475a77ba120c33113312a8c09 100644 (file)
@@ -44,17 +44,17 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 addMenuDescription('admin', __FILE__);
 
 // Do we edit/delete/change main menus or sub menus?
-$AND = "(`what` = '' OR `what` IS NULL)"; $SUB = '';
+$AND = "(`what` = '' OR `what` IS NULL)"; $subMenu = '';
 
 if (isGetRequestParameterSet('sub')) {
        $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", getRequestParameter('sub'));
-       $SUB = getRequestParameter('sub');
+       $subMenu = getRequestParameter('sub');
 } // END - if
 
 // List all menu points and make them editable
 if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
        // Edit menu entries
-       $content['sub'] = $SUB;
+       $content['sub'] = $subMenu;
        $content['chk'] = countPostSelection();
 
        $cnt = '0'; $OUT = '';
@@ -98,7 +98,7 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
        loadTemplate('admin_edit_guest_menu_form', false, $content);
 } elseif ((isFormSent('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
        // Del menu entries with or without confirmation
-       $content['sub'] = $SUB;
+       $content['sub'] = $subMenu;
        $content['chk'] = countPostSelection();
 
        $cnt = '0';
@@ -133,50 +133,9 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
 
        // Load template
        loadTemplate('admin_delete_guest_menu', false, $content);
-} elseif ((isFormSent()) && (!isDemoModeActive())) {
-       // An action is done...
-       switch (postRequestParameter('ok')) {
-               case 'edit': // Edit menu
-                       foreach (postRequestParameter('sel') as $sel => $menu) {
-                               // Secure selector
-                               $sel = bigintval($sel);
-
-                               // Update entry
-                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
-                                       array($menu, postRequestParameter('sel_action', $sel), postRequestParameter('sel_what', $sel), $sel),__FILE__, __LINE__);
-                       } // END - foreach
-                       loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
-                       break;
-
-               case 'delete': // Delete menu
-                       foreach (postRequestParameter('sel') as $sel => $menu) {
-                               // Delete enty
-                               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
-                                       array(bigintval($sel)), __FILE__, __LINE__);
-                       } // END - foreach
-                       loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
-                       break;
-
-               case 'status': // Change access levels
-                       foreach (postRequestParameter('sel') as $sel => $menu) {
-                               // Secure selector
-                               $sel = bigintval($sel);
-
-                               // Update entry
-                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
-                                       array(postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__);
-                       } // END - foreach
-                       loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
-                       break;
-
-               default: // Unexpected action
-                       logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
-                       loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok')));
-                       break;
-       } // END - switch
 } elseif ((isPostRequestParameterSet('status')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
        // Change status (visible / locked)
-       $content['sub'] = $SUB;
+       $content['sub'] = $subMenu;
        $content['chk'] = countPostSelection();
 
        // Load template
@@ -215,54 +174,27 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
 
        // Load template
        loadTemplate('admin_guest_menu_status', false, $content);
+} elseif ((isFormSent()) && (!isDemoModeActive())) {
+       // An action is done...
+       adminProcessMenuEditForm('guest', $subMenu);
 } else {
-       if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
-               // Get ids
-               if (isGetRequestParameterSet('w')) {
-                       // Sub menus selected
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
-                               array(getRequestParameter('act'), bigintval(getRequestParameter('tid'))), __FILE__, __LINE__);
-                       list($tid) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
-                               array(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?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('tid'))), __FILE__, __LINE__);
-                       list($tid) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
-                               array(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?}_guest_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('tid')), bigintval($fid)), __FILE__, __LINE__);
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('fid')), bigintval($tid)), __FILE__, __LINE__);
-               } // END - if
-       } // END - if
+       // Handle weightning
+       doAdminProcessMenuWeightning('guest');
 
        // By default list menus
-       if (empty($SUB)) {
+       if (empty($subMenu)) {
                // List only main menus
                $result = SQL_QUERY("SELECT `id`,`action`,`what`,`title`,`sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
        } else {
                // List sub menus
                $result = SQL_QUERY_ESC("SELECT `id`,`action`,`what`,`title`,`sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
-                       array($SUB), __FILE__, __LINE__);
+                       array($subMenu), __FILE__, __LINE__);
        }
 
        // Do we have entries?
        if (SQL_NUMROWS($result) > 0) {
                // Set sub value
-               $content['sub'] = $SUB;
+               $content['sub'] = $subMenu;
 
                // Init variables
                $cnt = '0';
@@ -271,7 +203,7 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
                // Process all menu entries
                while ($data = SQL_FETCHARRAY($result)) {
                        $cnt++;
-                       if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($SUB)))) {
+                       if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($subMenu)))) {
                                // Is highest position
                                $NAVI = '<a href="{%url=modules.php?module=admin&amp;what=guestedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']+1) . '&amp;fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
                        } elseif ($cnt == SQL_NUMROWS($result)) {
index a778d5be46b03bc83dbbe15173f81b09fdea6fd9..6e3405dc16387b85cdf88ec3adb9c609ab3b58de 100644 (file)
@@ -44,17 +44,17 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 addMenuDescription('admin', __FILE__);
 
 // Do we edit/delete/change main menus or sub menus?
-$AND = "(`what` = '' OR `what` IS NULL)"; $SUB = '';
+$AND = "(`what` = '' OR `what` IS NULL)"; $subMenu = '';
 
 if (isGetRequestParameterSet('sub')) {
        $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", getRequestParameter('sub'));
-       $SUB = getRequestParameter('sub');
+       $subMenu = getRequestParameter('sub');
 } // END - if
 
 // List all menu points and make them editable
 if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
        // Edit menu entries
-       $content['sub'] = $SUB;
+       $content['sub'] = $subMenu;
        $content['chk'] = countPostSelection();
        $cnt = '0'; $OUT = '';
        foreach (postRequestParameter('sel') as $sel => $confirm) {
@@ -69,8 +69,8 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
                                        'cnt'    => $cnt,
                                        'sel'    => $sel,
                                        'menu'   => $data['title'],
-                                       'act'    => adminAddMenuSelectionBox('member', 'act' , 'sel_act['  . $sel . ']', $data['action']),
-                                       'what'   => adminAddMenuSelectionBox('member', 'what', 'sel_what[' . $sel . ']', $data['what']),
+                                       'action' => adminAddMenuSelectionBox('member', 'action', 'sel_action[' . $sel . ']', $data['action']),
+                                       'what'   => adminAddMenuSelectionBox('member', 'what'  , 'sel_what[' . $sel . ']', $data['what']),
                                );
 
                                // Load template
@@ -96,7 +96,7 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
        loadTemplate('admin_edit_member_menu', false, $content);
 } elseif ((isFormSent('delete')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
        // Del menu entries with or without confirmation
-       $content['sub'] = $SUB;
+       $content['sub'] = $subMenu;
        $content['chk'] = countPostSelection();
        $cnt = '0'; $OUT = '';
        foreach (postRequestParameter('sel') as $sel => $confirm) {
@@ -134,7 +134,7 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
        loadTemplate('admin_delete_member_menu', false, $content);
 } elseif ((isPostRequestParameterSet('status')) && (ifPostContainsSelections()) && (!isDemoModeActive())) {
        // Change status (visible / locked)
-       $content['sub'] = $SUB;
+       $content['sub'] = $subMenu;
        $content['chk'] = countPostSelection();
        $cnt = '0'; $OUT = '';
        foreach (postRequestParameter('sel') as $sel => $confirm) {
@@ -173,75 +173,13 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
        // Load template
        loadTemplate('admin_member_menu_status', false, $content);
 } elseif ((isFormSent()) && (!isDemoModeActive())) {
-       // An act is done...
-       foreach (postRequestParameter('sel') as $sel => $menu) {
-               $AND = "(`what` = '' OR `what` IS NULL)";
-
-               $sel = bigintval($sel);
-
-               if (!empty($SUB)) $AND = "`action`='" . $SUB . "'";
-
-               switch (postRequestParameter('ok')) {
-                       case 'edit': // Edit menu
-                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
-                                       array($menu, postRequestParameter('sel_act', $sel), postRequestParameter('sel_what', $sel), $sel), __FILE__, __LINE__);
-                               break;
-
-                       case 'delete': // Delete menu
-                               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
-                                       array($sel), __FILE__, __LINE__);
-                               break;
-
-                       case 'status': // Change status of menus
-                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
-                                       array(postRequestParameter('visible', $sel), postRequestParameter('locked', $sel), $sel), __FILE__, __LINE__);
-                               break;
-
-                       default: // Unexpected action
-                               logDebugMessage(__FILE__, __LINE__, sprintf("Unsupported action %s detected.", postRequestParameter('ok')));
-                               loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNKNOWN_OKAY', postRequestParameter('ok')));
-                               break;
-               } // END - switch
-       } // END - foreach
-
-       // Load template
-       loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
+       // Process menu editing form
+       adminProcessMenuEditForm('member', $subMenu);
 } else {
-       if ((isGetRequestParameterSet('act')) && (isGetRequestParameterSet('tid')) && (isGetRequestParameterSet('fid'))) {
-               // Init
-               $tid = ''; $fid = '';
-
-               // Get ids
-               if (isGetRequestParameterSet('w')) {
-                       // Sub menus selected
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('act')), bigintval(getRequestParameter('tid'))), __FILE__, __LINE__);
-                       list($tid) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
-                               array(bigintval(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?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('tid'))), __FILE__, __LINE__);
-                       list($tid) = SQL_FETCHROW($result);
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('fid'))), __FILE__, __LINE__);
-                       list($fid) = SQL_FETCHROW($result);
-               }
-
-               if ((!empty($tid)) && (!empty($fid))) {
-                       // Sort menu
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('tid')), bigintval($fid)), __FILE__, __LINE__);
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
-                               array(bigintval(getRequestParameter('fid')), bigintval($tid)), __FILE__, __LINE__);
-               } // END - -fi
-       } // END - if
+       // Handle weightning
+       doAdminProcessMenuWeightning('guest');
 
-       if (!empty($SUB)) {
+       if (!empty($subMenu)) {
                // Edit sub menus
                $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", __FILE__, __LINE__);
        } else {
@@ -252,14 +190,14 @@ if ((isFormSent('edit')) && (ifPostContainsSelections()) && (!isDemoModeActive()
        // Some are there?
        if (SQL_NUMROWS($result) > 0) {
                // Set sub value
-               $content['sub'] = $SUB;
+               $content['sub'] = $subMenu;
 
                $cnt = '0'; $OUT = '';
                while ($data = SQL_FETCHARRAY($result)) {
                        // Init navigation
                        $data['navi'] = '';
                        $cnt++;
-                       if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($SUB)))) {
+                       if (($data['sort'] == '0') || (($data['sort'] == 1) && (!empty($subMenu)))) {
                                // Is highest position
                                $data['navi'] = '<a href="{%url=modules.php?module=admin&amp;what=adminedit&amp;sub=' . $content['sub'] . '&amp;act=' . $data['action'] . '&amp;w=' . $data['what'] . '&amp;tid=' . ($data['sort']+1) . '&amp;fid=' . $data['sort'] . '%}">{--LOWER--}</a>';
                        } elseif ($cnt == SQL_NUMROWS($result)) {