introduced isSqlResult() which encapsulates checking MySQL/i results
[mailer.git] / inc / module-functions.php
index f7779d051a753df268060d7f378ae2ae5d2203b7..41c45b648c6c39a751aff54cb80cf6a9f8633b2c 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Modulfunktionen                                  *
  * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2016 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -85,7 +80,7 @@ function getModuleTitle ($module) {
                        }  else {
                                // No name found
                                $data['title'] = '{%message,UNKNOWN_MODULE_DETECTED_TITLE=' . $module . '%}';
-                               if ((is_resource($result)) && (ifSqlHasZeroNums($result))) {
+                               if ((isSqlResult($result)) && (ifSqlHasZeroNumRows($result))) {
                                        // Add module to database and ignore return value
                                        checkModulePermissions($module);
                                } // END - if
@@ -145,7 +140,15 @@ function isModuleRegistered ($module) {
        } elseif (!isExtensionActive('cache')) {
                // Check for module in database
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using database.');
-               $result = sqlQueryEscaped("SELECT `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
+               $result = sqlQueryEscaped("SELECT
+       `locked`,
+       `admin_only`,
+       `mem_only`
+FROM
+       `{?_MYSQL_PREFIX?}_mod_reg`
+WHERE
+       `module`='%s'
+LIMIT 1",
                        array($module), __FUNCTION__, __LINE__);
                if (sqlNumRows($result) == 1) {
                        // Read data
@@ -180,15 +183,6 @@ function isModuleLocked ($module) {
        return $return;
 }
 
-// Checks whether 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 whether the given module is mem_only by just checking the cache
 function isModuleMemberOnly ($module) {
        // Determine if there a cache entry and is it set
@@ -271,10 +265,9 @@ function checkModulePermissions ($module = '') {
                        setModuleStatus($module_chk, 'admin_only');
                } else {
                        // @TODO Nothing helped???
-                       logDebugMessage(__FUNCTION__, __LINE__, sprintf('ret=%s,locked=%d,hidden=%d,mem=%d,admin=%d',
+                       logDebugMessage(__FUNCTION__, __LINE__, sprintf('ret=%s,locked=%d,mem=%d,admin=%d',
                                getModuleStatus($module_chk),
                                intval(isModuleLocked($module_chk)),
-                               intval(isModuleHidden($module_chk)),
                                intval(isModuleMemberOnly($module_chk)),
                                intval(isModuleAdminOnly($module_chk))
                        ));
@@ -292,15 +285,15 @@ function checkModulePermissions ($module = '') {
                                 * hour to find a loop here... *sigh*
                                 */
                                sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg`
-(`module`, `locked`, `hidden`, `mem_only`, `admin_only`, `has_menu`)
+(`module`, `locked`, `mem_only`, `admin_only`, `has_menu`)
 VALUES
-('%s','Y','N','N','N','N')", array($module_chk), __FUNCTION__, __LINE__);
+('%s','Y'','N','N','N')", array($module_chk), __FUNCTION__, __LINE__);
                        } else {
                                // Wrong/missing sql_patches!
                                sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg`
-(`module`, `locked`, `hidden`, `mem_only`, `admin_only`)
+(`module`, `locked`, `mem_only`, `admin_only`)
 VALUES
-('%s','Y','N','N','N')", array($module_chk), __FUNCTION__, __LINE__);
+('%s','Y','N','N')", array($module_chk), __FUNCTION__, __LINE__);
                        }
 
                        // Everthing is fine?
@@ -328,11 +321,10 @@ VALUES
                rebuildCache('modules', 'modules');
        } elseif ($found === FALSE) {
                // Problem with module detected
-               logDebugMessage(__FUNCTION__, __LINE__, sprintf('Problem in module %s detected. getModuleStatus()=%s,locked=%d,hidden=%d,mem=%d,admin=%d,output_mode=%s',
+               logDebugMessage(__FUNCTION__, __LINE__, sprintf('Problem in module %s detected. getModuleStatus()=%s,isModuleLocked()=%d,mem=%d,admin=%d,output_mode=%s',
                        $module_chk,
                        getModuleStatus($module_chk),
                        intval(isModuleLocked($module_chk)),
-                       intval(isModuleHidden($module_chk)),
                        intval(isModuleMemberOnly($module_chk)),
                        intval(isModuleAdminOnly($module_chk)),
                        getScriptOutputMode()
@@ -402,13 +394,12 @@ function addModuleSql ($module, $title, $locked, $hidden, $adminOnly, $memOnly)
        // Is the module already registered?
        if (!isModuleRegistered($module)) {
                // Add it
-               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` (`module`, `title`, `locked`, `hidden`, `admin_only`, `mem_only`) VALUES ('" . $module . "', '" . $title . "', '" . $locked . "', '" . $hidden . "', '" . $adminOnly . "', '" . $memOnly . "')");
+               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` (`module`, `title`, `locked`, `admin_only`, `mem_only`) VALUES ('" . $module . "', '" . $title . "', '" . $locked . "', '" . $adminOnly . "', '" . $memOnly . "')");
        } else {
                // Already registered
-               logDebugMessage(__FUNCTION__, __LINE__, sprintf('Already registered: module=%s,locked=%s,hidden=%s,admin=%s,mem=%s',
+               logDebugMessage(__FUNCTION__, __LINE__, sprintf('Already registered: module=%s,locked=%s,admin=%s,mem=%s',
                        $module,
                        $locked,
-                       $hidden,
                        $adminOnly,
                        $memOnly
                ));
@@ -488,8 +479,8 @@ function doIncludeModule () {
        // Set content type
        setContentType('text/html');
 
-       // The header file
-       loadIncludeOnce('inc/header.php');
+       // Load page header
+       loadPageHeader();
 
        // Modules are by default not valid!
        $isModuleValid = FALSE;
@@ -522,7 +513,7 @@ function doIncludeModule () {
        } // END - if
 
        // Add the footer (this will call doShutdown())
-       loadIncludeOnce('inc/footer.php');
+       loadPageFooter();
 }
 
 // "Getter" for menu mode from given module