]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-adminedit.php
A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / admin / what-adminedit.php
index 66f53c33210d4733106bd39643fe1dee4b5849c3..bda8f3adac3164845cbdf5f985cb11fa579fc493 100644 (file)
@@ -50,10 +50,10 @@ if (REQUEST_ISSET_GET(('sub')))
 
 // Get count of (maybe) selected menu points
 $chk = 0;
-if (REQUEST_ISSET_POST(('sel'))) $chk = SELECTION_COUNT(REQUEST_POST('sel'));
+if (REQUEST_ISSET_POST('sel')) $chk = SELECTION_COUNT(REQUEST_POST('sel'));
 
 // List all menu points and make them editable
-if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO())) {
+if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO())) {
        // Edit menu entries
        define('__SUB_VALUE', $SUB);
        define('__CHK_VALUE', $chk);
@@ -101,7 +101,7 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO())) {
        // Load template
        LOAD_TEMPLATE("admin_amenu_edit_form");
 }
- elseif ((REQUEST_ISSET_POST(('del'))) && (!IS_DEMO()))
+ elseif ((REQUEST_ISSET_POST('del')) && (!IS_DEMO()))
 {
        define('__SUB_VALUE', $SUB);
        define('__CHK_VALUE', $chk);
@@ -242,43 +242,48 @@ WHERE ".$AND." AND id=%s LIMIT 1",
 
        $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&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$act."&amp;w=".$wht."&amp;tid=".($sort+1)."&amp;fid=".$sort."\">{--LOWER--}</a>";
+                               $content['navi'] = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$content['action']."&amp;w=".$content['what']."&amp;tid=".($content['sort']+1)."&amp;fid=".$content['sort']."\">{--LOWER--}</a>";
                        } elseif ($cnt == $max) {
                                // Is lowest position
-                               $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$act."&amp;w=".$wht."&amp;tid=".($sort-1)."&amp;fid=".$sort."\">{--HIGHER--}</a>";
-                       } elseif ($sort > 0) {
+                               $content['navi'] = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$content['action']."&amp;w=".$content['what']."&amp;tid=".($content['sort']-1)."&amp;fid=".$content['sort']."\">{--HIGHER--}</a>";
+                       } elseif ($content['sort'] > 0) {
                                // Anything else between highest and lowest
-                               $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$act."&amp;w=".$wht."&amp;tid=".($sort-1)."&amp;fid=".$sort."\">{--HIGHER--}</a>/<a href=\"{!URL!}/modules.php?module=admin&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$act."&amp;w=".$wht."&amp;tid=".($sort+1)."&amp;fid=".$sort."\">{--LOWER--}</a>";
+                               $content['navi'] = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$content['action']."&amp;w=".$content['what']."&amp;tid=".($content['sort']-1)."&amp;fid=".$content['sort']."\">{--HIGHER--}</a>/<a href=\"{!URL!}/modules.php?module=admin&amp;what=adminedit&amp;sub={!__SUB_VALUE!}&amp;act=".$content['action']."&amp;w=".$content['what']."&amp;tid=".($content['sort']+1)."&amp;fid=".$content['sort']."\">{--LOWER--}</a>";
                        }
 
-                       if (empty($act))   $act   = "&nbsp;";
-                       if (empty($wht))   $wht   = "&nbsp;";
-                       if (empty($title)) $title = "&nbsp;";
+                       // Fix empty elements for constant (fixes display bugs in Firefox)
+                       if (empty($content['action'])) $content['action'] = "&nbsp;";
+                       if (empty($content['what']))   $content['what']   = "&nbsp;";
+                       if (empty($content['title']))  $content['title']  = "&nbsp;";
 
-                       $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