]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Better this way...
[mailer.git] / inc / mysql-manager.php
index c74bf46c3c002136db1c27d6aa9008a0e244306d..1c20fbe7269a23df9c607a41f5c44888fff6c369 100644 (file)
@@ -406,7 +406,7 @@ function addMenu ($mode, $action, $what) {
        } // END - if
 
        // Load SQL data and add the menu to the output stream...
-       $result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$ADD." ORDER BY `sort` ASC",
+       $result_main = SQL_QUERY_ESC("SELECT `title`, `action`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$ADD." ORDER BY `sort` ASC",
                array($mode), __FUNCTION__, __LINE__);
 
        //* DEBUG: */ print(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
@@ -415,22 +415,19 @@ function addMenu ($mode, $action, $what) {
                $GLOBALS['rows'] = '';
                while ($content = SQL_FETCHARRAY($result_main)) {
                        //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].':'.getWhat()."*<br />");
-                       // Init variables
+                       // Init/"translate" variables
                        enableBlockMode(false);
-                       $action = $content['action'];
+                       $content = translateMenuVisibleLocked($content);
 
                        // Load menu header template
                        $GLOBALS['rows'] .= loadTemplate($mode . '_menu_title', true, $content);
 
                        // Sub menu
-                       $result_sub = SQL_QUERY_ESC("SELECT `title` AS sub_title, `what` AS sub_what FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$ADD." ORDER BY `sort`",
+                       $result_sub = SQL_QUERY_ESC("SELECT `title` AS sub_title, `what` AS sub_what, `visible` AS sub_visible, `locked` AS sub_locked FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$ADD." ORDER BY `sort` ASC",
                                array($mode, $content['action']), __FUNCTION__, __LINE__);
 
-                       // Get number of rows
-                       $totalWhats = SQL_NUMROWS($result_sub);
-
                        // Do we have some entries?
-                       if ($totalWhats > 0) {
+                       if (SQL_NUMROWS($result_sub) > 0) {
                                // Init counter
                                $cnt = '0';
 
@@ -439,11 +436,14 @@ function addMenu ($mode, $action, $what) {
                                        // Merge both arrays in one
                                        $content = merge_array($content, $content2);
 
+                                       // Translate visible/locked again
+                                       $content = translateMenuVisibleLocked($content, 'sub_');
+
                                        // Init content
                                        $OUT = '';
 
                                        // Full file name for checking menu
-                                       //* DEBUG: */ print(__LINE__.":!!!!".$content['sub_what']."!!!<br />");
+                                       //* DEBUG: */ print(__LINE__ . ':!!!!' . $content['sub_what'] . '!!!<br />');
                                        $inc = sprintf("inc/modules/%s/what-%s.php", $mode, $content['sub_what']);
                                        if (isIncludeReadable($inc)) {
                                                // Mark currently selected menu - open
@@ -478,17 +478,19 @@ function addMenu ($mode, $action, $what) {
 
                                        // Rewrite array
                                        $content =  array(
-                                               'menu' => $OUT,
-                                               'what' => $content['sub_what']
+                                               'menu'        => $OUT,
+                                               'what'        => $content['sub_what'],
+                                               'visible_css' => $content['sub_visible_css'],
+                                               'locked_css'  => $content['sub_locked_css']
                                        );
 
                                        // Add regular menu row or bottom row?
-                                       if ($cnt < $totalWhats) {
+                                       if ($cnt < SQL_NUMROWS($result_sub)) {
                                                $GLOBALS['rows'] .= loadTemplate($mode . '_menu_row', true, $content);
                                        } else {
                                                $GLOBALS['rows'] .= loadTemplate($mode . '_menu_bottom', true, $content);
                                        }
-                               }
+                               } // END - while
                        } else {
                                // This is a menu block... ;-)
                                enableBlockMode();
@@ -506,6 +508,10 @@ function addMenu ($mode, $action, $what) {
                                //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*<br />");
                        }
 
+                       // Free result
+                       SQL_FREERESULT($result_sub);
+
+                       // Count one up
                        $main_cnt++;
 
                        //* DEBUG: */ print(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
@@ -814,7 +820,7 @@ function addMaxReceiveList ($mode, $default = '', $return = false) {
 // Checks wether the given email address is used.
 function isEmailTaken ($email) {
        // Query the database
-       $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email` LIKE '{PER}%s{PER}' OR `email` LIKE '{PER}%s{PER}' LIMIT 1",
+       $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email` LIKE '%%%s%%' OR `email` LIKE '%%%s%%' LIMIT 1",
                array($email, str_replace('.', '{DOT}', $email)), __FUNCTION__, __LINE__);
 
        // Is the email there?