A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / admin / what-guestedit.php
index df50fcd50582533110ebf5fc81235f0d34087316..2e5d3b415d2c8f19025e9b1287d87af44be7cea6 100644 (file)
@@ -59,7 +59,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
        define('__SUB_VALUE', $SUB);
        define('__CHK_VALUE', $chk);
 
-       $cnt = 0; $SW = 2; $OUT = "";
+       $cnt = 0; $OUT = ""; $SW = 2;
        foreach (REQUEST_POST('sel') as $sel => $confirm)
        {
                if ($confirm == 1)
@@ -269,13 +269,14 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
        } 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($SUB), __FILE__, __LINE__);
        }
 
        // Get number of menu entries
        $max = SQL_NUMROWS($result);
        if ($max > 0) {
                // Set sub value
+               // @TODO Rewrite this constant
                define('__SUB_VALUE', $SUB);
 
                // Init variables
@@ -283,28 +284,30 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
                $cnt = 0;
                $OUT = "";
 
-               while (list($id, $act, $wht, $title, $sort) = SQL_FETCHROW($result)) {
+               // Process all menu entries
+               while ($content = SQL_FETCHARRAY($result)) {
                        $cnt++;
-                       if (($sort == 0) || (($sort == 1) && (!empty($SUB)))) {
+                       if (($content['sort'] == 0) || (($content['sort'] == 1) && (!empty($SUB)))) {
                                // Is highest position
-                               $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=guestedit&amp;sub={!__SUB_VALUE!}&amp;act=".$act."&amp;w=".$wht."&amp;tid=".($sort+1)."&amp;fid=".$sort."\">{--LOWER--}</a>";
+                               $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=guestedit&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=guestedit&amp;sub={!__SUB_VALUE!}&amp;act=".$act."&amp;w=".$wht."&amp;tid=".($sort-1)."&amp;fid=".$sort."\">{--HIGHER--}</a>";
-                       } elseif ($sort > 0) {
+                               $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=guestedit&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=guestedit&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=guestedit&amp;sub={!__SUB_VALUE!}&amp;act=".$act."&amp;w=".$wht."&amp;tid=".($sort+1)."&amp;fid=".$sort."\">{--LOWER--}</a>";
+                               $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=guestedit&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=guestedit&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;";
+                       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,
+                               'id'     => $content['id'],
+                               'action' => $content['action'],
+                               'what'   => $content['what'],
+                               'title'  => $content['title'],
                                'navi'   => $NAVI,
                                'mode'   => "guest"
                        );