]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
'Fixed' installation of depending extensions, other minor improvements
[mailer.git] / inc / mysql-manager.php
index bb31db5bdf8fb718021f3ee35fdd1519659ed79b..027f3a2b6c52b6509fa0da8dcce644d1b5993e40 100644 (file)
@@ -87,7 +87,7 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) {
        $file = basename($FQFN);
 
        // Init variables
-       $LINK_ADD = '';
+       $linkAdd = '';
        $OUT = '';
        $ADD = '';
        $prefix = '';
@@ -125,13 +125,11 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) {
                $type     = 'what';
                $search   = $file;
                $modCheck = getModule();
-               $ADD      = '';
        } else {
                // Other
                $type     = 'menu';
                $search   = $file;
                $modCheck = getModule();
-               $ADD      = '';
        }
 
        // Begin the navigation line
@@ -140,18 +138,19 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) {
                $GLOBALS['nav_depth'] = '0';
 
                // Run the pre-filter chain
-               $ret = runFilterChain('pre_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $LINK_ADD, 'content' => '', 'add' => $ADD));
+               $ret = runFilterChain('pre_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $linkAdd, 'content' => '', 'add' => $ADD));
 
                // Add pre-content
                $prefix = $ret['content'];
 
                // Add default content
-               $prefix .= '<div class="you_are_here">{--YOU_ARE_HERE--}&nbsp;<strong><a class="you_are_here" href="{%url=modules.php?module=' . getModule() . $LINK_ADD . '%}">Home</a></strong>';
+               $prefix .= '<div class="you_are_here">{--YOU_ARE_HERE--}&nbsp;<strong><a class="you_are_here" href="{%url=modules.php?module=' . getModule() . $linkAdd . '%}">Home</a></strong>';
        } elseif ($return === false) {
                // Count depth
                $GLOBALS['nav_depth']++;
        }
 
+       // Add arrow
        $prefix .= '&nbsp;-&gt;&nbsp;';
 
        // We need to remove .php and the end
@@ -160,19 +159,21 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) {
                $search = substr($search, 0, -4);
        } // END - if
 
+       // Is ext-sql_patches installed?
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isExtensionInstalledAndNewer()=' . intval(isExtensionInstalledAndNewer('sql_patches', '0.2.3')) . ',youre_here=' . getConfig('youre_here') . ',isAdmin()=' . intval(isAdmin()) . ',modCheck=' . $modCheck);
        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>';
+               $OUT = $prefix . '<strong><a class="you_are_here" href="{%url=modules.php?module=' . $modCheck . '&amp;' . $type . '=' . $search . $linkAdd . '%}">' . getTitleFromMenu($accessLevel, $search, $type, $ADD) . '</a></strong>';
 
                // Can we close the you-are-here navigation?
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type . 'getWhat()=' . getWhat());
-               if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'welcome')))) {
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type . ',getWhat()=' . getWhat() . ',accessLevel=' . $accessLevel . ',isWhatSet()=' . intval(isWhatSet()));
+               if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (($accessLevel == 'admin') && (getWhat() == 'welcome'))))) {
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type);
                        // Add closing div and br-tag
                        $GLOBALS['nav_depth'] = '0';
 
                        // Run the post-filter chain
-                       $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $LINK_ADD, 'content' => $OUT, 'add' => $ADD));
+                       $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'search' => $search, 'prefix' => $prefix, 'link_add' => $linkAdd, 'content' => $OUT, 'add' => $ADD));
 
                        // Get content from filter back
                        $OUT = $ret['content'];
@@ -211,7 +212,11 @@ function addMenu ($mode, $action, $what) {
 
        // Load SQL data and add the menu to the output stream...
        $result_main = SQL_QUERY_ESC("SELECT
-       `title`,`what`,`action`,`visible`,`locked`
+       `title`,
+       `what`,
+       `action`,
+       `visible`,
+       `locked`
 FROM
        `{?_MYSQL_PREFIX?}_%s_menu`
 WHERE
@@ -245,10 +250,13 @@ WHERE
        `action`='%s' AND
        `what` != '' AND
        `what` IS NOT NULL
-       ".$ADD."
+       " . $ADD . "
 ORDER BY
        `sort` ASC",
-                               array($mode, $content['action']), __FUNCTION__, __LINE__);
+                               array(
+                                       $mode,
+                                       $content['action']
+                               ), __FUNCTION__, __LINE__);
 
                        // Do we have some entries?
                        if (!SQL_HASZERONUMS($result_sub)) {
@@ -464,9 +472,6 @@ function fetchUserData ($value, $column = 'userid') {
                // Secure userid
                $value = bigintval($value);
 
-               // Set it here
-               setCurrentUserId($value);
-
                // Don't look for invalid userids...
                if (!isValidUserId($value)) {
                        // Invalid, so abort here
@@ -1794,14 +1799,21 @@ function registerExtensionPointsData ($subject, $columnName, $lockedMode, $payme
        $add = '';
 
        // Is the extension equal or newer 0.8.9?
-       if ((getExtensionMode() == 'register') || (getExtensionMode() == 'update') || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) {
+       if (((isInstallationPhase()) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) {
                // Then add provider
                $add = " AND `account_provider`='EXTENSION'";
        } // END - if
 
        // Is the 'subject' there?
-       if (((!ifSqlTableExist('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) {
-               // Not found so add an SQL query
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ifSqlTableExists(points_data)=' . ifSqlTableExists('points_data') . ',getExtensionMode()=' . getExtensionMode() . ',add=' . $add);
+       if (((!ifSqlTableExists('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) {
+               // Not found so:
+               if ((isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) && (!ifSqlTableExists('points_data'))) {
+                       $dummy = $GLOBALS['previous_extension'][getCurrentExtensionName()];
+                       reportBug(__FUNCTION__, __LINE__, 'previous_extension[' . gettype($dummy) . ']=' . $dummy . ',getCurrentExtensionName()=' . getCurrentExtensionName() . ' - Under development, please report this!');
+               } // END - if
+
+               // ... add an SQL query
                addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('%s','%s','%s','%s')",
                        $subject,
                        $columnName,