A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / admin / what-memedit.php
index 4d86acd..b65af84 100644 (file)
@@ -247,42 +247,46 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO())) {
        $max = SQL_NUMROWS($result);
        if ($max > 0) {
                // Set sub value
+               // @TODO Rewrite this constant
                define('__SUB_VALUE', $SUB);
 
                $SW = 2; $cnt = 0; $OUT = "";
-               while (list($id, $act, $wht, $title, $sort) = SQL_FETCHROW($result)) {
+               while ($content = SQL_FETCHARRAY($result)) {
+                       // Init navigation
+                       $content['navi'] = "";
                        $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=memedit&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=memedit&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=memedit&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=memedit&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=memedit&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=memedit&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=memedit&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=memedit&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 values for 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'   => "mem",
-                       );
+                       // Add more entries
+                       $content['sw']   = $SW;
+                       $content['mode'] = "mem";
+
+                       // Load row template and switch color
                        $OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
                        $SW = 3 - $SW;
                }
 
                // Free memory
                SQL_FREERESULT($result);
+
+               // @TODO Rewrite this constant
                define('__MENU_ROWS', $OUT);
+
+               // Load main template
                LOAD_TEMPLATE("admin_mmenu_overview");
        } else {
                // Menu entries are missing... (???)