From c2baf8e3ea692fecac4d37d321368e2b85bbca06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 25 Sep 2010 03:27:52 +0000 Subject: [PATCH] userid/refid do now allow 'null' --- inc/extensions/ext-online.php | 16 +++++++++--- inc/module-functions.php | 48 ++++++++++++++++++++--------------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/inc/extensions/ext-online.php b/inc/extensions/ext-online.php index 5359cdff6e..05badce02c 100644 --- a/inc/extensions/ext-online.php +++ b/inc/extensions/ext-online.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.0.5'); +setThisExtensionVersion('0.0.6'); // Version history array (add more with , '0.1.0' and so on) -setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5')); +setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running (modules.php?module=admin is called) @@ -54,8 +54,8 @@ switch (getExtensionMode()) { `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `sid` VARCHAR(32) NOT NULL DEFAULT '', `ip` VARCHAR(15) NOT NULL DEFAULT '', -`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -`refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL, +`refid` BIGINT(20) UNSIGNED NULL DEFAULT NULL, `module` VARCHAR(255) NOT NULL DEFAULT '', `action` VARCHAR(255) NOT NULL DEFAULT '', `what` VARCHAR(255) NOT NULL DEFAULT '', @@ -122,6 +122,14 @@ INDEX `admin_member` (`is_admin`, `is_member`) // Update notes (these will be set as task text!) setExtensionUpdateNotes("Hinzufügen des Menüpunktes "Jetzt Online" wird nun von dieser Erweiterung erledigt. Filter hinzugefügt."); break; + + case '0.0.6': // SQL queries for v0.0.6 + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_online` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL, +CHANGE `refid` `refid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL'); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Spalten userid und refid erlauben nun null."); + break; } // END - switch break; diff --git a/inc/module-functions.php b/inc/module-functions.php index 1d96f5e0f8..a4f03277ee 100644 --- a/inc/module-functions.php +++ b/inc/module-functions.php @@ -162,7 +162,10 @@ function isModuleRegistered ($module) { // Check validity of a given module name (no file extension) function checkModulePermissions ($module = '') { // Is it empty (default), then take the current one - if (empty($module)) $module = getModule(); + if (empty($module)) { + // Use current module + $module = getModule(); + } // END - if // Do we have cache? if (isModuleStatusSet($module)) { @@ -192,7 +195,6 @@ function checkModulePermissions ($module = '') { // Check if script is installed if not return a 'done' to prevent some errors if ((isInstallationPhase()) || (!isAdminRegistered())) { // Not installed or no admin registered or in installation phase - // Set status setModuleStatus($module_chk, 'done'); // Return status @@ -232,19 +234,23 @@ function checkModulePermissions ($module = '') { // Still no luck or not found? if (($found === false) && (!isExtensionActive('cache')) && (getModuleStatus($module_chk) != 'done')) { - // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- + // ----- Default module ----- ---- Module in base folder ---- --- Module with extension's name --- if ((isIncludeReadable(sprintf("inc/modules/%s.php", $module))) || (isIncludeReadable(sprintf("%s.php", $module))) || (isIncludeReadable(sprintf("%s/%s.php", $extension, $module)))) { // Data is missing so we add it if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) { - // Since 0.3.6 we have a has_menu column, this took me a half hour - // to find a loop here... *sigh* + /* + * Since 0.3.6 we have a has_menu column, this took me a half + * hour 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 +(`module`, `locked`, `hidden`, `mem_only`, `admin_only`, `has_menu`) +VALUES ('%s','Y','N','N','N','N')", array($module_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 +(`module`, `locked`, `hidden`, `mem_only`, `admin_only`) +VALUES ('%s','Y','N','N','N')", array($module_chk), __FUNCTION__, __LINE__); } @@ -257,7 +263,9 @@ function checkModulePermissions ($module = '') { // Destroy cache here // @TODO Rewrite this to a filter - if ((isHtmlOutputMode()) || (isRawOutputMode())) rebuildCache('modules', 'modules'); + if ((isHtmlOutputMode()) || (isRawOutputMode())) { + rebuildCache('modules', 'modules'); + } // END - if // And reload data unset($GLOBALS['module_status'][$module_chk]); @@ -272,8 +280,8 @@ function checkModulePermissions ($module = '') { } elseif ($found === false) { // Problem with module detected logDebugMessage(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s, output_mode=%s", - $module, - getModuleStatus($module), + $module_chk, + getModuleStatus($module_chk), $GLOBALS['cache_array']['modules']['locked'][$module_chk], $GLOBALS['cache_array']['modules']['hidden'][$module_chk], $GLOBALS['cache_array']['modules']['mem_only'][$module_chk], @@ -283,36 +291,36 @@ function checkModulePermissions ($module = '') { } // Debug log - logDebugMessage(__FUNCTION__, __LINE__, sprintf("module=%s, statyus=%s", $module_chk, getModuleStatus($module_chk))); + logDebugMessage(__FUNCTION__, __LINE__, sprintf("module=%s, status=%s", $module_chk, getModuleStatus($module_chk))); // Return the value return getModuleStatus($module_chk); } // Checks if the module has a menu -function ifModuleHasMenu ($mod, $forceDb = false) { +function ifModuleHasMenu ($module, $forceDb = false) { // All is false by default $ret = false; // Extension installed and newer than or has version 0.1.2? if (isExtensionInstalledAndNewer('cache', '0.1.2')) { // Cache version is okay, so let's check the cache! - if (isset($GLOBALS['cache_array']['modules']['has_menu'][$mod])) { + if (isset($GLOBALS['cache_array']['modules']['has_menu'][$module])) { // Check module cache and count hit - $ret = ($GLOBALS['cache_array']['modules']['has_menu'][$mod] == 'Y'); + $ret = ($GLOBALS['cache_array']['modules']['has_menu'][$module] == 'Y'); incrementStatsEntry('cache_hits'); - } elseif (isset($GLOBALS['cache_array']['extension']['ext_menu'][$mod])) { + } elseif (isset($GLOBALS['cache_array']['extension']['ext_menu'][$module])) { // Check cache and count hit - $ret = ($GLOBALS['cache_array']['extension']['ext_menu'][$mod] == 'Y'); + $ret = ($GLOBALS['cache_array']['extension']['ext_menu'][$module] == 'Y'); incrementStatsEntry('cache_hits'); } else { // Admin/guest/member/sponsor modules have always a menu! - $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor')); + $ret = in_array($module, array('admin', 'index', 'login', 'sponsor')); } } elseif ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && ((!isExtensionActive('cache')) || ($forceDb === true))) { // Check database for entry $result = SQL_QUERY_ESC("SELECT `has_menu` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1", - array($mod), __FUNCTION__, __LINE__); + array($module), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -320,7 +328,7 @@ function ifModuleHasMenu ($mod, $forceDb = false) { $data = SQL_FETCHARRAY($result); // Fake cache... ;-) - $GLOBALS['cache_array']['extension']['ext_menu'][$mod] = $data['has_menu']; + $GLOBALS['cache_array']['extension']['ext_menu'][$module] = $data['has_menu']; // Does it have a menu? $ret = ($data['has_menu'] == 'Y'); @@ -330,7 +338,7 @@ function ifModuleHasMenu ($mod, $forceDb = false) { SQL_FREERESULT($result); } elseif (!isExtensionInstalled('sql_patches')) { // No sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered? - $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu! + $ret = in_array($module, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu! } else { // Unsupported state! logDebugMessage(__FUNCTION__, __LINE__, 'This should never be reached.'); -- 2.39.2