// 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))) {
initExtensionUpdateDependencies();
// Is the task id zero? Then we need to auto-fix it here
- if ($task_id == 0) {
+ if ($task_id == '0') {
// Try to find the task
$task_id = determineExtensionTaskId(getCurrentExtensionName());
// Still zero and not in dry-run?
- if (($task_id == 0) && (!getExtensionDryRun())) {
+ if (($task_id == '0') && (!getExtensionDryRun())) {
// Then request a bug report
debug_report_bug(sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)",
__FUNCTION__,
// 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?
} // END - for
// Is there no update?
- if (countExtensionUpdateDependencies(getCurrentExtensionName()) == 0) {
+ if (countExtensionUpdateDependencies(getCurrentExtensionName()) == '0') {
// Then test is passed!
$test = true;
} // END - if
// 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
$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
- $ret = 0;
+function getExtensionId ($ext_name) {
+ // Init id number
+ $ret = '0';
+ // Do we have cache?
if (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) {
// Load from cache
$ret = $GLOBALS['cache_array']['extension']['ext_id'][$ext_name];
// Count cache hits
incrementStatsEntry('cache_hits');
- } elseif (($forceDb === true) || (!isExtensionActive('cache'))) {
+ } else {
// Load from database
$result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
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);
- } // END - if
+ // Cache it
+ $GLOBALS['cache_array']['extension']['ext_id'][$ext_name] = $ret;
+ }
// Return value
return $ret;
// Is the extension there?
if (isExtensionInstalled($ext_name)) {
// Check if task is not there
- if (determineTaskIdBySubject($subject) == 0) {
+ if (determineTaskIdBySubject($subject) == '0') {
// Create extension update-task
createNewTask($subject, $notes, 'EXTENSION_UPDATE', 0, $adminId);
} // END - if
// Creates a new task for newly installed extension
function createNewExtensionTask ($adminId, $subject, $ext) {
// Not installed and do we have created a task for the admin?
- if ((determineTaskIdBySubject($subject) == 0) && (!isExtensionInstalled($ext))) {
+ if ((determineTaskIdBySubject($subject) == '0') && (!isExtensionInstalled($ext))) {
// Set default message if ext-foo is missing
$message = sprintf(getMessage('ADMIN_EXT_TEXT_FILE_MISSING'), $ext);
$subject = sprintf("[%s:] %s", $ext, getMessage('TASK_SUBJ_EXTENSION_DEACTIVATED'));
// Not installed and do we have created a task for the admin?
- if ((determineTaskIdBySubject($subject) == 0) && (getExtensionVersion($ext) != '')) {
+ if ((determineTaskIdBySubject($subject) == '0') && (getExtensionVersion($ext) != '')) {
// Task not created so add it
createNewTask($subject, SQL_ESCAPE(loadTemplate('task_ext_deactivated', true, $ext)), 'EXTENSION_DEACTIVATION');
} // END - if
// Determines the task id for given extension
function determineExtensionTaskId ($ext_name) {
// Default is not found
- $task_id = 0;
+ $task_id = '0';
// Search for extension task's id
$result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1",
// 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
// Determines the task id for given subject
function determineTaskIdBySubject ($subject) {
// Default is not found
- $task_id = 0;
+ $task_id = '0';
// Search for task id
$result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1",
// 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
// Init iterator for update depencies
function initExtensionUpdateIterator () {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
- $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()] = 0;
+ $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()] = '0';
}
// Getter for depency iterator
}
}
+// 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]
?>