/** * Check if a module is configured. * * @param string The name of the module to check if it's enabled. * @return boolean True if the module is configured, false if not. */ function ModuleIsConfigured($ModuleId) { $moduleBits = explode('_', $ModuleId, 2); $cachedModuleVars = $GLOBALS['ISC_CLASS_DATA_STORE']->Read(ucfirst($moduleBits[0]) . 'ModuleVars'); switch ($moduleBits[0]) { case 'accounting': case 'checkout': case 'analytics': case 'notification': case 'livechat': // Check that the method is actually enabled in the first place if (!in_array($ModuleId, explode(',', GetConfig(ucfirst($moduleBits[0]) . 'Methods')))) { return false; } break; case 'addon': // Check that the method is actually enabled in the first place if (!in_array($ModuleId, explode(',', GetConfig(ucfirst($moduleBits[0]) . 'Modules')))) { return false; } break; case 'shipping': $query = "SELECT * FROM [|PREFIX|]shipping_methods WHERE methodenabled = 1 AND methodmodule = '" . $GLOBALS['ISC_CLASS_DB']->Quote($ModuleId) . "'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // there is no real way to determine if a shipping method is configured return $GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0; } // First try to see if we can load a cached version for this type of module if ($cachedModuleVars !== false) { if (isset($cachedModuleVars[$ModuleId]) && !empty($cachedModuleVars[$ModuleId])) { return true; } else { return false; } } else { if (!isset($GLOBALS['ConfiguredModules']) || !is_array($GLOBALS['ConfiguredModules'])) { $GLOBALS['ConfiguredModules'] = GetConfiguredModules(); } return in_array($ModuleId, $GLOBALS['ConfiguredModules']); } }
/** * Check if a module is configured. * * @param string The name of the module to check if it's enabled. * @return boolean True if the module is configured, false if not. */ function ModuleIsConfigured($ModuleId) { $moduleBits = explode('_', $ModuleId, 2); $cachedModuleVars = $GLOBALS['ISC_CLASS_DATA_STORE']->Read(ucfirst($moduleBits[0]).'ModuleVars'); $checkIsSetupInCache = false; switch($moduleBits[0]) { case 'accounting': // We need this here as there are some variables in the accounting module that cannot be deleted once set $checkIsSetupInCache = true; case 'checkout': case 'analytics': case 'notification': case 'livechat': case 'comments': case 'shippingmanager': // Check that the method is actually enabled in the first place if(!in_array($ModuleId, explode(',', GetConfig(ucfirst($moduleBits[0]).'Methods')))) { return false; } break; case 'addon': // Check that the method is actually enabled in the first place if(!in_array($ModuleId, explode(',', GetConfig(ucfirst($moduleBits[0]).'Modules')))) { return false; } break; case 'shipping': $query = "SELECT * FROM [|PREFIX|]shipping_methods WHERE methodenabled = 1 AND methodmodule = '" . $GLOBALS['ISC_CLASS_DB']->Quote($ModuleId) . "'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // there is no real way to determine if a shipping method is configured return ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0); case 'optimizer': // Check that the method is actually enabled in the first place if(!in_array($ModuleId, array_keys(GetConfig('OptimizerMethods')))) { return false; } } // First try to see if we can load a cached version for this type of module if($cachedModuleVars !== false) { if(isset($cachedModuleVars[$ModuleId]) && !empty($cachedModuleVars[$ModuleId]) && (!$checkIsSetupInCache || isset($cachedModuleVars[$ModuleId]['is_setup']))) { return true; } else { return false; } } // Otherwise, fall back to loading it from the database else { if (!isset($GLOBALS['ConfiguredModules']) || !is_array($GLOBALS['ConfiguredModules'])) { $GLOBALS['ConfiguredModules'] = GetConfiguredModules(); } return in_array($ModuleId, $GLOBALS['ConfiguredModules']); } }