// Do we have cache?
if (isExtensionFunctionFileReadable($ext_name)) {
// Not yet loaded?
- if (($GLOBALS['cache_array']['extension']['ext_func'][$ext_name] == 'Y') && (!isset($GLOBALS['ext_loaded']['funcs'][$ext_name]))) {
+ if ((($GLOBALS['cache_array']['extension']['ext_func'][$ext_name] == 'Y') || (!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name]))) && (!isset($GLOBALS['ext_loaded']['funcs'][$ext_name]))) {
// Construct FQFN for functions file
$funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name);
// Download functions file
loadIncludeOnce($funcsInclude);
} // END - if
- } elseif ((!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name])) && (isDebugModeEnabled()) && (getOutputMode() == '0') && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme') && (getExtensionMode() == 'test')) {
+ } elseif ((!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name])) && (isDebugModeEnabled()) && (getOutputMode() == 0) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme') && (getExtensionMode() == 'test')) {
// No functions file is not so good...
logDebugMessage(__FUNCTION__, __LINE__, sprintf("NOTICE: Extension %s has no own functions file or we cannot read from it. mode=%s",
$ext_name,
// Enable dry-run
enableExtensionDryRun($dry_run);
+ // By default all extensions are in productive phase
+ enableExtensionProductive();
+
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()." - ENTERED!");
// This shall never do a non-admin user or if the extension is active (already installed)
if ((!isAdmin()) || (isExtensionInstalled($ext_name))) {
// Extension version set? If empty the extension is not registered
if (empty($ext_ver)) {
- // Extension not registered so far so first load task's ID...
+ // Extension not registered so far so first load task's id...
$task = determineExtensionTaskId($ext_update);
// Entry found?
// Remove all SQL commands
unsetSqls();
+ // Mark it as installed
+ $GLOBALS['ext_is_installed'][getCurrentExtensionName()] = true;
+
// In normal mode return a true on success
$ret = true;
} elseif (getExtensionDryRun() === true) {
$isInstalled = false;
// Check if there is a cache entry
- if (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) {
+ if (isset($GLOBALS['ext_is_installed'][$ext_name])) {
+ // Use cache built from below queries
+ $isInstalled = $GLOBALS['ext_is_installed'][$ext_name];
+ } elseif (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) {
// Found!
$isInstalled = true;
// Extensions are all inactive/not installed during installation
} else {
// Look in database
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
- array($ext_name), __FILE__, __LINE__);
+ $ext_id = getExtensionId($ext_name);
// Do we have a record?
- $isInstalled = (SQL_NUMROWS($result) == 1);
+ $isInstalled = ($ext_id > 0);
// Is it installed, then cache the entry
if ($isInstalled === true) {
- // Dummy call
+ // Dummy call (get is okay here)
getExtensionId($ext_name, true);
} // END - if
- // Free result
- SQL_FREERESULT($result);
+ // Remember the status
+ $GLOBALS['ext_is_installed'][$ext_name] = $isInstalled;
}
// Return status
// Count cache hits
incrementStatsEntry('cache_hits');
- } elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (getOutputMode() != '0')) {
+ } elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (getOutputMode() != 0)) {
// Load from database
$result = SQL_QUERY_ESC("SELECT `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
$SW = 2;
// Get all SQLs
- foreach (getExtensionSqls() as $idx => $sqls) {
+ foreach (getExtensionSqls() as $sqls) {
// New array format is recursive
- foreach ($sqls as $sql) {
+ foreach ($sqls as $idx => $sql) {
// Trim out spaces
$sql = trim($sql);
// Get extension id from name
function getExtensionId ($ext_name, $forceDb = false) {
- // Init ID number
+ // Init id number
$ret = 0;
if (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) {
if (SQL_NUMROWS($result) == 1) {
// Get the extension's id from database
list($ret) = SQL_FETCHROW($result);
-
- // Cache it
- $GLOBALS['cache_array']['extension']['ext_id'][$ext_name] = $ret;
} // END - if
// Free result
SQL_FREERESULT($result);
- }
- if ($ret == 0) {
- // We should fix these all!
- debug_report_bug(__FUNCTION__ . ': Invalid extension name found. ext_name=' . $ext_name);
+ // Cache it
+ $GLOBALS['cache_array']['extension']['ext_id'][$ext_name] = $ret;
+ } else {
+ // Caching enabled but no cache found is bad
+ debug_report_bug(__FUNCTION__ . ': Cache not found but ext-cache is active. ext_name=' . $ext_name);
} // END - if
// Return value
// Entry found?
if (SQL_NUMROWS($result) == 1) {
- // Task found so load task's ID and register extension...
+ // Task found so load task's id and register extension...
list($task_id) = SQL_FETCHROW($result);
} // END - if
// Entry found?
if (SQL_NUMROWS($result) == 1) {
- // Task found so load task's ID and register extension...
+ // Task found so load task's id and register extension...
list($task_id) = SQL_FETCHROW($result);
} // END - if
$out = ''; $content = array();
// Is do we have verbose output enabled?
- if ((getConfig('verbose_sql') == 'Y') || (!isExtensionActive('sql_patches'))) {
+ if ((!isExtensionActive('sql_patches')) || (getConfig('verbose_sql') == 'Y')) {
// Update notes found?
if (getExtensionUpdateNotes($ver) != '') {
// Update notes found
// Do we have some entries?
//* DEBUG */ print __FUNCTION__.': ENTRY!<br />';
if (isset($GLOBALS['cache_array']['extension']['ext_name'])) {
- //* DEBUG */ print __FUNCTION__.': CACHE - START!<br />';
// Load all found extensions if found
- foreach ($GLOBALS['cache_array']['extension']['ext_name'] as $key=>$ext_name) {
+ //* DEBUG */ print __FUNCTION__.': CACHE - START!<br />';
+ foreach ($GLOBALS['cache_array']['extension']['ext_name'] as $key => $ext_name) {
// Load it
//* DEBUG */ print __FUNCTION__.': '.$ext_name.' - START<br />';
loadExtension($ext_name, 'init');
return ($GLOBALS['cache_array']['extension']['ext_func'][$ext_name] == 'Y');
}
+// 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));
+}
+
// [EOF]
?>