X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fextensions-functions.php;h=f06f15b5f821b4372d7eb25543bb90833b335bbe;hb=b1cf96c4a5a63a1d334119a0681e5fbf68edf527;hp=710d154398739c4a7650de14256415e063ae11fd;hpb=a30da9ca393c9f03a7e2808f444d9a17357917fd;p=mailer.git diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 710d154398..f06f15b5f8 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -1,7 +1,7 @@ 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 @@ -515,9 +520,9 @@ function isExtensionActive ($ext_name) { } // Get version from extensions -function getExtensionVersion ($ext_name) { +function getExtensionVersion ($ext_name, $force = false) { // By default no extension is found - $ext_ver = 'invalid'; + $ext_ver = 'false'; // Empty extension name should be fixed! if (empty($ext_name)) { @@ -560,7 +565,7 @@ function getExtensionVersion ($ext_name) { } // Extension version should not be invalid - if ($ext_ver == 'invalid') { + if (($ext_ver == 'false') && ($force === false)) { // Please report this trouble debug_report_bug(sprintf("Extension %s has empty version!", $ext_name)); } // END - if @@ -760,17 +765,18 @@ function getExtensionName ($ext_id) { } // 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__); @@ -779,19 +785,14 @@ function getExtensionId ($ext_name, $forceDb = false) { 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; @@ -890,7 +891,7 @@ function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) { // 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 @@ -903,7 +904,7 @@ function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) { // 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); @@ -934,7 +935,7 @@ function createExtensionDeactivationTask ($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 @@ -992,7 +993,7 @@ function ifModuleHasMenu ($mod, $forceDb = false) { // 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", @@ -1000,7 +1001,7 @@ function determineExtensionTaskId ($ext_name) { // 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 @@ -1014,7 +1015,7 @@ function determineExtensionTaskId ($ext_name) { // 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", @@ -1022,7 +1023,7 @@ function determineTaskIdBySubject ($subject) { // 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 @@ -1140,7 +1141,7 @@ function addExtensionUpdateDependency ($updateDepends) { // Is the update depency empty? (NEED TO BE FIXED!) if (empty($updateDepends)) { // Please report this bug! - debug_report_bug("updateDepends is left empty!"); + debug_report_bug('updateDepends is left empty!'); } // END - if // Is it not yet added? @@ -1233,7 +1234,7 @@ function removeExtensionUpdateDependency ($ext_name) { // 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