]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Extension ext-repair extended, outdated calls DEBUG_LOG() fixed:
[mailer.git] / inc / mysql-manager.php
index e691d6cf7cc8a5ea6e4fe1da19b04f9cdf7a4d65..b986d783baef83eb44ccdc717ba0f9a62040e1e0 100644 (file)
@@ -91,7 +91,7 @@ function getModuleTitle ($mod) {
 
 // "Getter" for module description
 // @TODO Can we cache this?
-function getModuleDescription ($mode, $what, $column = 'what') {
+function getTitleFromMenu ($mode, $what, $column = 'what', $ADD='') {
        // Fix empty 'what'
        if (empty($what)) {
                $what = getConfig('index_home');
@@ -101,8 +101,12 @@ function getModuleDescription ($mode, $what, $column = 'what') {
        $ret = '??? (' . $what . ')';
 
        // Look for title
-       $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE %s='%s' LIMIT 1",
-               array($mode, $column, $what), __FUNCTION__, __LINE__);
+       $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `%s`='%s'" . $ADD . " LIMIT 1",
+               array(
+                       $mode,
+                       $column,
+                       $what
+               ), __FUNCTION__, __LINE__);
 
        // Is there an entry?
        if (SQL_NUMROWS($result) == 1) {
@@ -285,14 +289,14 @@ function checkModulePermissions ($mod = '') {
 }
 
 // Add menu description pending on given file name (without path!)
-function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = true) {
+function addMenuDescription ($accessLevel, $FQFN, $return = false) {
        // Use only filename of the FQFN...
        $file = basename($FQFN);
 
        // Init variables
        $LINK_ADD = '';
        $OUT = '';
-       $AND = '';
+       $ADD = '';
 
        // First we have to do some analysis...
        if (substr($file, 0, 7) == 'action-') {
@@ -304,33 +308,33 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru
                $modCheck = getModuleFromFileName($file, $accessLevel);
 
                // Add what
-               $AND = " AND (`what`='' OR `what` IS NULL)";
+               $ADD = " AND (`what`='' OR `what` IS NULL)";
        } elseif (substr($file, 0, 5) == 'what-') {
-               // This is an admin what file!
+               // This is a 'what file'!
                $type = 'what';
                $search = substr($file, 5);
-               $AND = " AND `visible`='Y' AND `locked`='N'";
+               $ADD = " AND `visible`='Y' AND `locked`='N'";
 
                // Get access level from it
                $modCheck = getModuleFromFileName($file, $accessLevel);
 
                // Do we have admin? Then display all
-               if (isAdmin()) $AND = '';
+               if (isAdmin()) $ADD = '';
 
                $dummy = substr($search, 0, -4);
-               $AND .= " AND `action`='".getModeAction($accessLevel, $dummy)."'";
+               $ADD .= " AND `action`='".getModeAction($accessLevel, $dummy)."'";
        } elseif (($accessLevel == 'sponsor') || ($accessLevel == 'engine')) {
                // Sponsor / engine menu
                $type     = 'what';
                $search   = $file;
                $modCheck = getModule();
-               $AND      = '';
+               $ADD      = '';
        } else {
                // Other
                $type     = 'menu';
                $search   = $file;
                $modCheck = getModule();
-               $AND      = '';
+               $ADD      = '';
        }
 
        // Begin the navigation line
@@ -350,48 +354,33 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru
                $search = substr($search, 0, -4);
        } // END - i
 
-       // Get the title from menu
-       $result = SQL_QUERY_ESC("SELECT title FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE %s='%s' ".$AND." LIMIT 1",
-       array($accessLevel, $type, $search), __FUNCTION__, __LINE__);
+       if (((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (getConfig('youre_here') == 'Y')) || ((isAdmin()) && ($modCheck == 'admin'))) {
+               // Output HTML code
+               $OUT = $prefix . "<strong><a class=\"you_are_here\" href=\"{?URL?}/modules.php?module=" . $modCheck . '&amp;' . $type . '=' . $search . $LINK_ADD . "\">" . getTitleFromMenu($accessLevel, $search, $type, $ADD) . "</a></strong>\n";
 
-       // Menu found?
-       if (SQL_NUMROWS($result) == 1) {
-               // Load title
-               list($ret) = SQL_FETCHROW($result);
+               // Can we close the you-are-here navigation?
+               //* DEBUG: */ print(__LINE__."*".$type.'/'.getWhat()."*<br />");
+               if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'overview')))) {
+                       //* DEBUG: */ print(__LINE__.'+'.$type."+<br />");
+                       // Add closing div and br-tag
+                       $OUT .= "</div><br />\n";
+                       $GLOBALS['nav_depth'] = '0';
 
-               // Shall we return it?
-               if ($return === true) {
-                       // Return title
-                       return $ret;
-               } elseif (((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (getConfig('youre_here') == 'Y')) || ((isAdmin()) && ($modCheck == 'admin'))) {
-                       // Output HTML code
-                       $OUT = $prefix . "<strong><a class=\"you_are_here\" href=\"{?URL?}/modules.php?module=" . $modCheck . '&amp;' . $type . '=' . $search.$LINK_ADD . "\">" . $ret . "</a></strong>\n";
-
-                       // Can we close the you-are-here navigation?
-                       //* DEBUG: */ print(__LINE__."*".$type.'/'.getWhat()."*<br />");
-                       if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'overview')))) {
-                               //* DEBUG: */ print(__LINE__.'+'.$type."+<br />");
-                               // Add closing div and br-tag
-                               $OUT .= "</div><br />\n";
-                               $GLOBALS['nav_depth'] = '0';
-
-                               // Run the filter chain
-                               $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ""));
-                               $OUT .= $ret['content'];
-                       } // END - if
-               }
-       } // END - if
+                       // Run the filter chain
+                       $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ''));
 
-       // Free result
-       SQL_FREERESULT($result);
+                       // Add additional content
+                       $OUT .= $ret['content'];
+               } // END - if
+       }
 
        // Return or output HTML code?
-       if ($output) {
-               // Output HTML code here
-               outputHtml($OUT);
-       } else {
+       if ($return === true) {
                // Return HTML code
                return $OUT;
+       } else {
+               // Output HTML code here
+               outputHtml($OUT);
        }
 }
 
@@ -399,7 +388,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru
 function addMenu ($mode, $action, $what) {
        // Init some variables
        $main_cnt = '0';
-       $AND = '';
+       $ADD = '';
 
        // is the menu action valid?
        if (!isMenuActionValid($mode, $action, $what, true)) {
@@ -408,11 +397,11 @@ function addMenu ($mode, $action, $what) {
 
        // Non-admin shall not see all menus
        if (!isAdmin()) {
-               $AND = " AND `visible`='Y' AND `locked`='N'";
+               $ADD = " AND `visible`='Y' AND `locked`='N'";
        } // 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)".$AND." ORDER BY `sort` ASC",
+       $result_main = SQL_QUERY_ESC("SELECT `title`, `action` 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 />");
@@ -429,7 +418,7 @@ function addMenu ($mode, $action, $what) {
                        $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 ".$AND." ORDER BY `sort`",
+                       $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`",
                                array($mode, $content['action']), __FUNCTION__, __LINE__);
 
                        // Get number of rows
@@ -1659,7 +1648,7 @@ function generateMetaDescriptionCode ($mod, $what) {
        // Exclude admin and member's area
        if (($mod != 'admin') && ($mod != 'login')) {
                // Construct dynamic description
-               $DESCR = '{?MAIN_TITLE?} '.trim(getConfig('title_middle')) . ' ' . addMenuDescription('guest', 'what-'.$what, true);
+               $DESCR = '{?MAIN_TITLE?} '.trim(getConfig('title_middle')) . ' ' . getTitleFromMenu('guest', $what);
 
                // Output it directly
                outputHtml('<meta name="description" content="' . $DESCR . '" />');