+// Adds an admin menu to the SQL queue of the menu entry is not found
+function addAdminMenuSql ($action, $what, $title, $descr, $sort) {
+ // Now check if this menu is there
+ if (!isMenuActionValid('admin', $action, $what)) {
+ // 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);
+ } elseif (isDebugModeEnabled()) {
+ // Double menus should be located and fixed!
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double admin menu action=%s, what=%s detected.", $action, $what));
+ }
+}
+
+// Adds a guest menu to the SQL queue if the menu entry is not found
+function addGuestMenuSql ($action, $what, $title, $visible, $locked, $sort) {
+ // Now check if this menu is there
+ if (!isMenuActionValid('guest', $action, $what)) {
+ // 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);
+ } elseif (isDebugModeEnabled()) {
+ // Double menus should be located and fixed!
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double guest menu action=%s, what=%s detected.", $action, $what));
+ }
+}
+
+// Adds a member menu to the SQL queue if the menu entry is not found
+function addMemberMenuSql ($action, $what, $title, $visible, $locked, $sort) {
+ // Now check if this menu is there
+ if (!isMenuActionValid('member', $action, $what)) {
+ // 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);
+ } elseif (isDebugModeEnabled()) {
+ // Double menus should be located and fixed!
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double member menu action=%s, what=%s detected.", $action, $what));
+ }
+}
+
+// Adds a sponsor menu to the SQL queue if the menu entry is not found
+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))) {
+ // 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);
+ } elseif (isDebugModeEnabled()) {
+ // Double menus should be located and fixed!
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double sponsor menu action=%s, what=%s detected.", $action, $what));
+ }
+}
+
+// Enables/disables productive mode for current extension (used only while
+// registration).
+function enableExtensionProductive ($isProductive = true) {
+ $GLOBALS['ext_productive'][getCurrentExtensionName()] = (bool) $isProductive;
+}
+
+// Checks wether the extension is in productive phase. If not set, development
+// phase (=false) is assumed.
+function isExtensionProductive () {
+ return ((isset($GLOBALS['ext_productive'][getCurrentExtensionName()])) && ($GLOBALS['ext_productive'][getCurrentExtensionName()] === true));
+}
+