X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodule-functions.php;h=ebb5f2fb8329208f2bce744d663b450a29c18690;hb=e17685c65d1a48c061b7c4f64c7a23c165430460;hp=a5659b906fac960cbb662fe2721a208ea89c0ebf;hpb=d92913f593b52777762672503eb88d7567355ad3;p=mailer.git diff --git a/inc/module-functions.php b/inc/module-functions.php index a5659b906f..ebb5f2fb83 100644 --- a/inc/module-functions.php +++ b/inc/module-functions.php @@ -6,9 +6,9 @@ * -------------------------------------------------------------------- * * File : module-functions.php * * -------------------------------------------------------------------- * - * Short description : All MySQL-related functions * + * Short description : Module functions * * -------------------------------------------------------------------- * - * Kurzbeschreibung : Alle MySQL-Relevanten Funktionen * + * Kurzbeschreibung : Modulfunktionen * * -------------------------------------------------------------------- * * $Revision:: $ * * $Date:: $ * @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * + * Copyright (c) 2009 - 2011 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -61,7 +61,7 @@ function getModuleTitle ($module) { array($module), __FUNCTION__, __LINE__); // Is the entry there? - if (SQL_NUMROWS($result)) { + if (SQL_NUMROWS($result) == 1) { // Get the title from database $data = SQL_FETCHARRAY($result); } // END - if @@ -143,12 +143,18 @@ function isModuleRegistered ($module) { array($module), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Read data - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Entry found.'); - $GLOBALS['cache_array']['modules'][$module] = SQL_FETCHARRAY($result); + $data = SQL_FETCHARRAY($result); + + // Set all entries + foreach ($data as $key=>$value) { + $GLOBALS['cache_array']['modules'][$key][$module] = $value; + } // END - foreach + + // Mark as found $found = true; } elseif (isDebugModeEnabled()) { // Debug message only in debug-mode... - logDebugMessage(__FUNCTION__, __LINE__, 'Module ' . $module . ' not found!'); + logDebugMessage(__FUNCTION__, __LINE__, 'Module ' . $module . ' not found.'); } // Free result @@ -159,6 +165,42 @@ function isModuleRegistered ($module) { return $found; } +// Checks wether the given module is locked by just checking the cache +function isModuleLocked ($module) { + // Determine if there a cache entry and is it set + $return = ((isset($GLOBALS['cache_array']['modules']['locked'][$module])) && ($GLOBALS['cache_array']['modules']['locked'][$module] == 'Y')); + + // Return determined value + return $return; +} + +// Checks wether the given module is hidden by just checking the cache +function isModuleHidden ($module) { + // Determine if there a cache entry and is it set + $return = ((isset($GLOBALS['cache_array']['modules']['hidden'][$module])) && ($GLOBALS['cache_array']['modules']['hidden'][$module] == 'Y')); + + // Return determined value + return $return; +} + +// Checks wether the given module is mem_only by just checking the cache +function isModuleMemberOnly ($module) { + // Determine if there a cache entry and is it set + $return = ((isset($GLOBALS['cache_array']['modules']['mem_only'][$module])) && ($GLOBALS['cache_array']['modules']['mem_only'][$module] == 'Y')); + + // Return determined value + return $return; +} + +// Checks wether the given module is admin_only by just checking the cache +function isModuleAdminOnly ($module) { + // Determine if there a cache entry and is it set + $return = ((isset($GLOBALS['cache_array']['modules']['admin_only'][$module])) && ($GLOBALS['cache_array']['modules']['admin_only'][$module] == 'Y')); + + // Return determined value + return $return; +} + // Check validity of a given module name (no file extension) function checkModulePermissions ($module = '') { // Is it empty (default), then take the current one @@ -209,26 +251,26 @@ function checkModulePermissions ($module = '') { // Check returned values against current access permissions // // Admin access ----- Guest access ----- --- Guest or member? --- - if ((isAdmin()) || (($GLOBALS['cache_array']['modules']['locked'][$module_chk] != 'Y') && ($GLOBALS['cache_array']['modules']['admin_only'][$module_chk] != 'Y') && (($GLOBALS['cache_array']['modules']['mem_only'][$module_chk] != 'Y') || (isMember())))) { + if ((isAdmin()) || ((!isModuleLocked($module_chk)) && (!isModuleAdminOnly($module_chk)) && ((!isModuleMemberOnly($module_chk)) || (isMember())))) { // If you are admin you are welcome for everything! setModuleStatus($module_chk, 'done'); - } elseif ($GLOBALS['cache_array']['modules']['locked'][$module_chk] == 'Y') { + } elseif (isModuleLocked($module_chk)) { // Module is locked setModuleStatus($module_chk, 'locked'); - } elseif (($GLOBALS['cache_array']['modules']['mem_only'][$module_chk] == 'Y') && (!isMember())) { + } elseif ((isModuleMemberOnly($module_chk)) && (!isMember())) { // You have to login first! setModuleStatus($module_chk, 'mem_only'); - } elseif (($GLOBALS['cache_array']['modules']['admin_only'][$module_chk] == 'Y') && (!isAdmin())) { + } elseif ((isModuleAdminOnly($module_chk)) && (!isAdmin())) { // Only the Admin is allowed to enter this module! setModuleStatus($module_chk, 'admin_only'); } else { // @TODO Nothing helped??? - logDebugMessage(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,hidden=%s,admin=%s,mem=%s", + logDebugMessage(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%d,hidden=%d,mem=%d,admin=%d", getModuleStatus($module_chk), - $GLOBALS['cache_array']['modules']['locked'][$module_chk], - $GLOBALS['cache_array']['modules']['hidden'][$module_chk], - $GLOBALS['cache_array']['modules']['admin_only'][$module_chk], - $GLOBALS['cache_array']['modules']['mem_only'][$module_chk] + intval(isModuleLocked($module_chk)), + intval(isModuleHidden($module_chk)), + intval(isModuleMemberOnly($module_chk)), + intval(isModuleAdminOnly($module_chk)) )); } } // END - if @@ -256,7 +298,7 @@ VALUES } // Everthing is fine? - if (SQL_AFFECTEDROWS() < 1) { + if (SQL_HASZEROAFFECTED()) { // Something bad happend! setModuleStatus($module_chk, 'major'); return 'major'; @@ -280,13 +322,13 @@ VALUES rebuildCache('modules', 'modules'); } 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", + logDebugMessage(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. getModuleStatus()=%s,locked=%d,hidden=%d,mem=%d,admin=%d,output_mode=%s", $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], - $GLOBALS['cache_array']['modules']['admin_only'][$module_chk], + intval(isModuleLocked($module_chk)), + intval(isModuleHidden($module_chk)), + intval(isModuleMemberOnly($module_chk)), + intval(isModuleAdminOnly($module_chk)), getScriptOutputMode() )); }