]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions-functions.php
Several fixes for broken actions (sorry for lame text)
[mailer.git] / inc / extensions-functions.php
index d1db294f1d097927d2b1925a5de3585e6e45db46..bed7a9c3ce66c1e0186c4284a981d8a6154ca9e4 100644 (file)
@@ -1580,18 +1580,29 @@ function isExtensionFunctionFileReadable ($ext_name) {
 function addAdminMenuSql ($action, $what, $title, $descr, $sort) {
        // Now check if this menu is there
        if (!isMenuActionValid('admin', $action, $what)) {
-               // Not found, so construct it
-               $sql = sprintf("INSERT INTO {?_MYSQL_PREFIX?}_admin_menu` (`action`,`what`,`title`,`descr',`sort`) VALUES('%s','%s','%s','%s',%s)",
-                       $action,
-                       $what,
-                       $title,
-                       $descr,
-                       bigintval($sort)
-               );
+               // Is what null?
+               if (is_null($what)) {
+                       // Add main menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES('%s',NULL,'%s','%s',%s)",
+                               $action,
+                               $title,
+                               $descr,
+                               bigintval($sort)
+                       );
+               } else {
+                       // Add sub menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES('%s','%s','%s','%s',%s)",
+                               $action,
+                               $what,
+                               $title,
+                               $descr,
+                               bigintval($sort)
+                       );
+               }
 
                // Add it to the queue
                addExtensionSql($sql);
-       } else {
+       } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
                logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double admin menu action=%s, what=%s detected.", $action, $what));
        }
@@ -1601,19 +1612,31 @@ function addAdminMenuSql ($action, $what, $title, $descr, $sort) {
 function addGuestMenuSql ($action, $what, $title, $visible, $locked, $sort) {
        // Now check if this menu is there
        if (!isMenuActionValid('guest', $action, $what)) {
-               // Not found, so construct it
-               $sql = sprintf("INSERT INTO {?_MYSQL_PREFIX?}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s','%s','%s','%s','%s',%s)",
-                       $action,
-                       $what,
-                       $title,
-                       $visible,
-                       $locked,
-                       bigintval($sort)
-               );
+               // Is what null?
+               if (is_null($what)) {
+                       // Add main menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s',NULL,'%s','%s','%s',%s)",
+                               $action,
+                               $title,
+                               $visible,
+                               $locked,
+                               bigintval($sort)
+                       );
+               } else {
+                       // Add sub menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s','%s','%s','%s','%s',%s)",
+                               $action,
+                               $what,
+                               $title,
+                               $visible,
+                               $locked,
+                               bigintval($sort)
+                       );
+               }
 
                // Add it to the queue
                addExtensionSql($sql);
-       } else {
+       } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
                logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double guest menu action=%s, what=%s detected.", $action, $what));
        }
@@ -1623,19 +1646,31 @@ function addGuestMenuSql ($action, $what, $title, $visible, $locked, $sort) {
 function addMemberMenuSql ($action, $what, $title, $visible, $locked, $sort) {
        // Now check if this menu is there
        if (!isMenuActionValid('member', $action, $what)) {
-               // Not found, so construct it
-               $sql = sprintf("INSERT INTO {?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s','%s','%s','%s','%s',%s)",
-                       $action,
-                       $what,
-                       $title,
-                       $visible,
-                       $locked,
-                       bigintval($sort)
-               );
+               // Is what null?
+               if (is_null($what)) {
+                       // Add main menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s',NULL,'%s','%s','%s',%s)",
+                               $action,
+                               $title,
+                               $visible,
+                               $locked,
+                               bigintval($sort)
+                       );
+               } else {
+                       // Add sub menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s','%s','%s','%s','%s',%s)",
+                               $action,
+                               $what,
+                               $title,
+                               $visible,
+                               $locked,
+                               bigintval($sort)
+                       );
+               }
 
                // Add it to the queue
                addExtensionSql($sql);
-       } else {
+       } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
                logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double member menu action=%s, what=%s detected.", $action, $what));
        }
@@ -1645,18 +1680,29 @@ function addMemberMenuSql ($action, $what, $title, $visible, $locked, $sort) {
 function addSponsorMenuSql ($action, $what, $title, $active, $sort) {
        // Now check if this menu is there, if no ext-sponsor is installed all is not yet added
        if ((!isExtensionInstalled('sponsor')) || (!isMenuActionValid('sponsor', $action, $what))) {
-               // Not found, so construct it
-               $sql = sprintf("INSERT INTO {?_MYSQL_PREFIX?}_sponsor_menu` (`action`,`what`,`title`,`active`,`sort`) VALUES('%s','%s','%s','%s',%s)",
-                       $action,
-                       $what,
-                       $title,
-                       $active,
-                       bigintval($sort)
-               );
+               // Is what null?
+               if (is_null($what)) {
+                       // Add main menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_menu` (`action`,`what`,`title`,`active`,`sort`) VALUES('%s',NULL,'%s','%s',%s)",
+                               $action,
+                               $title,
+                               $active,
+                               bigintval($sort)
+                       );
+               } else {
+                       // Add sub menu
+                       $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_menu` (`action`,`what`,`title`,`active`,`sort`) VALUES('%s','%s','%s','%s',%s)",
+                               $action,
+                               $what,
+                               $title,
+                               $active,
+                               bigintval($sort)
+                       );
+               }
 
                // Add it to the queue
                addExtensionSql($sql);
-       } else {
+       } elseif (isDebugModeEnabled()) {
                // Double menus should be located and fixed!
                logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double sponsor menu action=%s, what=%s detected.", $action, $what));
        }