- // Add SQLs to a table
- if (empty($SQLs)) $SQLs = array();
- if (empty($title)) $title = "";
- if ((!empty($ext_name)) && (GET_EXT_VERSION("sql_patches")) && ($_CONFIG['verbose_sql'] == "Y")) {
- // Add verbose SQL table
- $text .= EXTENSION_VERBOSE_TABLE($SQLs, $title, " class=\"admin_table top2 left2 right2\"", true, "100%")."<br />\n";
- }
+ // Extract extension name from subject (for testing)
+ $ext_name = substr($taskData['subject'], 1, strpos($taskData['subject'], ':') - 1);
+
+ // Update task or extension task?
+ if (($taskData['task_type'] == 'EXTENSION') && (!isExtensionInstalled($ext_name))) {
+ // Load SQL commands for registering in dry-run
+ registerExtension($ext_name, $taskId, TRUE);
+
+ // Get current extension's version
+ $ext_ver = getCurrentExtensionVersion();
+
+ // Is this non-productive?
+ if (isExtensionProductive() === FALSE) {
+ // Issue warning
+ $taskData['text'] = returnMessage('{%message,ADMIN_EXTENSION_IS_NON_PRODUCTIVE=' . $ext_name . '%}') . $taskData['text'];
+ } // END - if
+
+ // Set current extension name
+ setCurrentExtensionName($ext_name);
+
+ // Add notes to text
+ $taskData['text'] .= getExtensionNotes();
+
+ // Set title
+ $title = '{--ADMIN_SQLS_EXECUTED_ON_REGISTER--}';
+ } elseif ($taskData['task_type'] == 'EXTENSION_UPDATE') {
+ // Prepare extension name and version
+ $ext_name = substr($ext_name, 7);
+ $ext_name = substr($ext_name, 0, strpos($ext_name, '-'));
+ $test = '[UPDATE-' . $ext_name . '-';
+ $ext_ver = substr($taskData['subject'], strlen($test));
+ $ext_ver = substr($ext_ver, 0, strpos($ext_ver, ':'));
+
+ // Load SQLs from file
+ updateExtension($ext_name, $ext_ver, TRUE);
+
+ // Set current extension name
+ setCurrentExtensionName($ext_name);
+
+ // Add notes to text
+ $taskData['text'] .= getExtensionNotes();
+
+ // Set title
+ $title = '{--ADMIN_SQLS_EXECUTED_ON_UPDATE--}';