]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Now CSS classes are being inserted by EL
[mailer.git] / inc / mysql-manager.php
index 52091822ef70e9ee72822dab64d76700d9b83a44..e0f783715494dc0af63df3f176d6c82a936926f4 100644 (file)
@@ -79,7 +79,7 @@ function getModuleTitle ($module) {
        // Still no luck or empty title?
        if (empty($data['title'])) {
                // No name found
-               $data['title'] = sprintf("%s (%s)", getMessage('LANG_UNKNOWN_MODULE'), $module);
+               $data['title'] = getMaskedMessage('UNKNOWN_MODULE_DETECTED', $module);
                if ((is_resource($result)) && (SQL_HASZERONUMS($result))) {
                        // Add module to database
                        $dummy = checkModulePermissions($module);
@@ -406,7 +406,15 @@ 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`, `what`, `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 />");
@@ -414,23 +422,32 @@ function addMenu ($mode, $action, $what) {
                // There are menus available, so we simply display them... :)
                $GLOBALS['rows'] = '';
                while ($content = SQL_FETCHARRAY($result_main)) {
-                       //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].':'.getWhat()."*<br />");
-                       // Init variables
+                       //* DEBUG: */ print(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . ':' . getWhat() . '*<br />');
+                       // Init/"translate" variables
                        enableBlockMode(false);
-                       $action = $content['action'];
 
                        // 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';
 
@@ -443,7 +460,7 @@ function addMenu ($mode, $action, $what) {
                                        $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
@@ -477,18 +494,20 @@ function addMenu ($mode, $action, $what) {
                                        $cnt++;
 
                                        // Rewrite array
-                                       $content =  array(
-                                               'menu' => $OUT,
-                                               'what' => $content['sub_what']
+                                       $content = array(
+                                               'menu'    => $OUT,
+                                               'what'    => $content['sub_what'],
+                                               'visible' => $content['sub_visible'],
+                                               'locked'  => $content['locked'],
                                        );
 
                                        // 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 +525,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 />");
@@ -631,7 +654,7 @@ function fetchUserData ($userid, $column = 'userid') {
                // Don't look for invalid userids...
                if ($userid < 1) {
                        // Invalid, so abort here
-                       debug_report_bug('User id ' . $userid . ' is invalid.');
+                       debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $userid . ' is invalid.');
                } elseif (isUserDataValid()) {
                        // Use cache, so it is fine
                        return true;
@@ -702,6 +725,11 @@ function fetchUserData ($userid, $column = 'userid') {
 
 // This patched function will reduce many SELECT queries for the specified or current admin login
 function isAdmin ($adminLogin = '') {
+       // No admin in installation phase!
+       if ((isInstallationPhase()) || (!isAdminRegistered())) {
+               return false;
+       } // END - if
+
        // Init variables
        $ret = false;
        $passCookie = '';
@@ -791,7 +819,7 @@ function addMaxReceiveList ($mode, $default = '', $return = false) {
                $OUT = loadTemplate(($mode . '_receive_table'), true, $OUT);
        } else {
                // Maybe the admin has to setup some maximum values?
-               debug_report_bug('Nothing is being done here?');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Nothing is being done here?');
        }
 
        // Free result
@@ -809,7 +837,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?
@@ -1258,7 +1286,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                // Prepare content
                                $content = array(
                                        'text'   => getMessage('REASON_DIRECT_PAYMENT'),
-                                       'points' => translateComma($ref_points)
+                                       'points' => $ref_points
                                );
 
                                // Load message
@@ -1557,7 +1585,7 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher
                        } // END - foreach
                } else {
                        // Problem in request
-                       debug_report_bug('Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name));
+                       debug_report_bug(__FUNCTION__, __LINE__, 'Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name));
                }
        } else {
                // Data from database
@@ -1645,7 +1673,8 @@ LEFT JOIN
 ON
        p.userid=d.userid
 WHERE
-       p.userid=%s",
+       p.userid=%s
+LIMIT 1",
                array(bigintval($userid)), __FUNCTION__, __LINE__);
 
        // Do we have an entry?
@@ -1654,7 +1683,8 @@ WHERE
                $data = SQL_FETCHARRAY($result);
 
                // Delete points entries as well
-               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s", array(bigintval($userid)), __FUNCTION__, __LINE__);
+               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s",
+                       array(bigintval($userid)), __FUNCTION__, __LINE__);
 
                // Update mediadata as well
                if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) {