]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-guestedit.php
Even more rewritten
[mailer.git] / inc / modules / admin / what-guestedit.php
index d5486ef469369c2dd29d156a0830576f0694d71c..27b0447d6fc8bdea54a962eba1bc1528d0ede80f 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Menue fuer die Gaeste editieren                  *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
 
 // Some security stuff...
 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
        require($INC);
 }
 
 // Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+ADD_DESCR('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)"; $SUB = '';
 
-if (REQUEST_ISSET_GET(('sub'))) {
-       $AND = sprintf("action='%s' AND `what` IS NOT NULL", REQUEST_GET(('sub')));
-       $SUB = REQUEST_GET(('sub'));
+if (REQUEST_ISSET_GET('sub')) {
+       $AND = sprintf("`action`='%s' AND `what` IS NOT NULL", REQUEST_GET('sub'));
+       $SUB = REQUEST_GET('sub');
 } // END - if
 
 // 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);
 
-       $cnt = 0; $SW = 2; $OUT = "";
+       $cnt = 0; $OUT = ''; $SW = 2;
        foreach (REQUEST_POST('sel') as $sel => $confirm)
        {
                if ($confirm == 1)
@@ -75,8 +80,8 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
                                $DATA = array(
                                        'cnt'    => $cnt,
                                        'sel'    => $sel,
-                                       'action' => ADMIN_MAKE_MENU_SELECTION("guest", "action", "sel_action[".$sel."]", $act),
-                                       'what'   => ADMIN_MAKE_MENU_SELECTION("guest", "what", "sel_what[".$sel."]", $wht),
+                                       'action' => ADMIN_MAKE_MENU_SELECTION('guest', "action", "sel_action[".$sel."]", $act),
+                                       'what'   => ADMIN_MAKE_MENU_SELECTION('guest', "what", "sel_what[".$sel."]", $wht),
                                        'menu'   => $menu,
                                        'sw'     => $SW,
                                );
@@ -99,12 +104,12 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
 
        // Load template
        LOAD_TEMPLATE("admin_gmenu_edit_form");
-} elseif ((REQUEST_ISSET_POST(('del'))) && (!IS_DEMO())) {
+} elseif ((REQUEST_ISSET_POST('del')) && (!IS_DEMO())) {
        // Del menu entries with or without confirmation
        define('__SUB_VALUE', $SUB);
        define('__CHK_VALUE', $chk);
 
-       $cnt = 0; $OUT = ""; $SW = 2;
+       $cnt = 0; $OUT = ''; $SW = 2;
        foreach (REQUEST_POST('sel') as $sel => $confirm) {
                if ($confirm == 1) {
                        $cnt++;
@@ -150,7 +155,7 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `title`='%s', `action`='%s', `what`='%s' WHERE ".$AND." AND id=%s LIMIT 1",
                                array($menu, REQUEST_POST('sel_action', $sel), REQUEST_POST('sel_what', $sel), $sel),__FILE__, __LINE__);
                }
-               LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_SAVED'));
+               LOAD_TEMPLATE('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
                break;
 
        case "del": // Delete menu
@@ -159,7 +164,7 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
                        SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_guest_menu` WHERE ".$AND." AND id=%s LIMIT 1",
                                array(bigintval($sel)), __FILE__, __LINE__);
                }
-               LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_SAVED'));
+               LOAD_TEMPLATE('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
                break;
 
        case "status": // Change access levels
@@ -171,7 +176,7 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `visible`='%s', `locked`='%s' WHERE ".$AND." AND id=%s LIMIT 1",
                                array(REQUEST_POST('visible', $sel), REQUEST_POST('locked', $sel), $sel), __FILE__, __LINE__);
                }
-               LOAD_TEMPLATE("admin_settings_saved", false, getMessage('SETTINGS_SAVED'));
+               LOAD_TEMPLATE('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
                break;
 
        default: // Unexpected action
@@ -186,7 +191,7 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
        define('__CHK_VALUE', $chk);
 
        // Load template
-       $SW = 2; $cnt = 0; $OUT = "";
+       $SW = 2; $cnt = 0; $OUT = '';
        foreach (REQUEST_POST('sel') as $sel => $confirm)
        {
                if ($confirm == 1)
@@ -204,8 +209,8 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
                                        'menu'    => $menu,
                                        'sel'     => $sel,
                                        'sw'      => $SW,
-                                       'visible' => ADD_SELECTION("yn", $vis   , "visible", $sel),
-                                       'locked'  => ADD_SELECTION("yn", $locked, "locked" , $sel),
+                                       'visible' => ADD_SELECTION('yn', $vis   , "visible", $sel),
+                                       'locked'  => ADD_SELECTION('yn', $locked, "locked" , $sel),
                                );
 
                                // Load template
@@ -243,11 +248,11 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
                        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",
+                       $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`='%s' LIMIT 1",
                         array(bigintval(REQUEST_GET('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",
+                       $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`='%s' LIMIT 1",
                         array(bigintval(REQUEST_GET('fid'))), __FILE__, __LINE__);
                        list($fid) = SQL_FETCHROW($result);
                        SQL_FREERESULT($result);
@@ -265,48 +270,51 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
        // By default list menus
        if (empty($SUB)) {
                // 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__);
+               $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__);
+               $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__);
        }
 
        // 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
                $SW = 2;
                $cnt = 0;
-               $OUT = "";
+               $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"
+                               'mode'   => 'guest'
                        );
                        $OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
                        $SW = 3 - $SW;
@@ -320,7 +328,7 @@ if ((REQUEST_ISSET_POST(('edit'))) && ($chk > 0) && (!IS_DEMO()))
                LOAD_TEMPLATE("admin_gmenu_edit");
        } else {
                // Menu entries are missing... (???)
-               LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_NO_MENUS_FOUND'));
+               LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MENUS_FOUND'));
        }
 }