X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=0f5051ae0ce704c8a693c3a072f81f766d8dc293;hb=2e9e34b22b8354dba7c0bd699e5486e99a64bc58;hp=db512f6b59950527d42a58bb58efc1688d286809;hpb=59bd8a9805c51c895a92cc12825f4cbdfd792597;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index db512f6b59..0f5051ae0c 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -44,7 +44,7 @@ function ADD_MODULE_TITLE ($mod) { $result = false; // Is the script installed? - if (isBooleanConstantAndTrue('mxchange_installed')) { + if (isInstalled()) { // Check if cache is valid if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($mod, $GLOBALS['cache_array']['modules']['module']))) { // Load from cache @@ -54,7 +54,8 @@ function ADD_MODULE_TITLE ($mod) { incrementConfigEntry('cache_hits'); } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database - $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE module='%s' LIMIT 1", array($mod), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE module='%s' LIMIT 1", + array($mod), __FUNCTION__, __LINE__); list($name) = SQL_FETCHROW($result); SQL_FREERESULT($result); } @@ -69,7 +70,7 @@ function ADD_MODULE_TITLE ($mod) { $name = sprintf("%s (%s)", getMessage('LANG_UNKNOWN_MODULE'), $mod); if (SQL_NUMROWS($result) == 0) { // Add module to database - $dummy = CHECK_MODULE($mod); + $dummy = checkModulePermissions($mod); } // END - if } // END - if @@ -78,7 +79,7 @@ function ADD_MODULE_TITLE ($mod) { } // Check validity of a given module name (no file extension) -function CHECK_MODULE ($mod) { +function checkModulePermissions ($mod) { // Filter module name (names with low chars and underlines are fine!) $mod = preg_replace("/[^a-z_]/", "", $mod); @@ -92,18 +93,33 @@ function CHECK_MODULE ($mod) { if (EXT_IS_ACTIVE($modSplit[0])) { // The prefix is an extension's name, so let's set it $extension = $modSplit[0]; $mod = $modSplit[1]; - } - } + } // END - if + } // END - if // Major error in module registry is the default $ret = "major"; // Check if script is installed if not return a "done" to prevent some errors - if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!isBooleanConstantAndTrue('admin_registered'))) return "done"; + if ((!isInstalled()) || (isInstalling()) || (!isAdminRegistered())) { + // Not installed or no admin registered or in installation phase + return "done"; + } // END - if + + // Init variables + $locked = "Y"; + $hidden = "N"; + $admin = "N"; + $mem = "N"; + $found = false; // Check if cache is latest version - $locked = "Y"; $hidden = "N"; $admin = "N"; $mem = "N"; $found = false; if (GET_EXT_VERSION("cache") >= "0.1.2") { + // Is the cache there? + if (!isset($GLOBALS['cache_array']['modules'])) { + // This should normally not happen... + debug_report_bug("Cache 'modules' is gone."); + } // END - if + // Is the module cached? if (isset($GLOBALS['cache_array']['modules']['locked'][$mod_chk])) { // Check cache @@ -121,7 +137,8 @@ function CHECK_MODULE ($mod) { } } elseif (!EXT_IS_ACTIVE("cache")) { // Check for module in database - $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE module='%s' LIMIT 1", array($mod_chk), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE module='%s' LIMIT 1", + array($mod_chk), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Read data list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result); @@ -147,12 +164,20 @@ function CHECK_MODULE ($mod) { } elseif (($admin == "Y") && (!IS_ADMIN())) { // Only the Admin is allowed to enter this module! $ret = "admin_only"; + } else { + // @TODO Nothing helped??? + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,admin=%s,mem=%s", + $ret, + $locked, + $admin, + $mem + )); } } // END - if // Still no luck or not found? if (($ret == "cache_miss") || (!$found)) { - // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- + // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- if ((FILE_READABLE(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (FILE_READABLE(sprintf("%s%s.php", constant('PATH'), $mod))) || (FILE_READABLE(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) { // Data is missing so we add it if (GET_EXT_VERSION("sql_patches") >= "0.3.6") { @@ -160,12 +185,12 @@ function CHECK_MODULE ($mod) { // to find a loop here... *sigh* SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg` (module, locked, hidden, mem_only, admin_only, has_menu) VALUES -('%s','Y','N','N','N','N')", array($mod_chk), __FILE__, __LINE__); +('%s','Y','N','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__); } else { // Wrong/missing sql_patches! SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg` (module, locked, hidden, mem_only, admin_only) VALUES -('%s','Y','N','N','N')", array($mod_chk), __FILE__, __LINE__); +('%s','Y','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__); } // Everthing is fine? @@ -175,10 +200,10 @@ function CHECK_MODULE ($mod) { } // END - if // Destroy cache here - REBUILD_CACHE("mod_reg", "modreg"); + rebuildCacheFiles("modreg", "modreg"); // And reload data - $ret = CHECK_MODULE($mod_chk); + $ret = checkModulePermissions($mod_chk); } else { // Module not found we don't add it to the database $ret = "404"; @@ -201,8 +226,6 @@ function CHECK_MODULE ($mod) { // Add menu description pending on given file name (without path!) function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { - global $NAV_DEPTH; - // Use only filename of the FQFN... $file = basename($FQFN); @@ -263,11 +286,11 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { } // Begin the navigation line - if ((!isset($NAV_DEPTH)) && (!$return)) { - $NAV_DEPTH = 0; + if ((!isset($GLOBALS['nav_depth'])) && (!$return)) { + $GLOBALS['nav_depth'] = 0; $prefix = "