]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions.php
More fixes
[mailer.git] / inc / extensions.php
index 1fd297707c9bc120267ea49e1bb350ff6d5b6714..cd182874e511a952d5c2ab6bc969304f454a2ff0 100644 (file)
@@ -130,7 +130,6 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "", $EXT_VER = "", $dry_run
 // Registeres an extension and possible update depencies
 function EXTENSION_REGISTER ($ext_name, $task_id, $dry_run = false, $logout = true) {
        global $INC_POOL;
-       global $NOTES;
 
        // This shall never do a non-admin user!
        if (!IS_ADMIN()) return false;
@@ -138,12 +137,27 @@ function EXTENSION_REGISTER ($ext_name, $task_id, $dry_run = false, $logout = tr
        // Is this extension already installed?
        if (EXT_IS_ACTIVE($ext_name)) return false;
 
-       // Init queries
+       // Is the task id zero? Then we need to auto-fix it here
+       if ($task_id == 0) {
+               // Try to find the task
+               $task_id = DETERMINE_EXTENSION_TASK_ID($ext_name);
+
+               // Still zero and not in dry-run?
+               if (($task_id == 0) && (!$dry_run)) {
+                       // Then request a bug report
+                       debug_report_bug(sprintf("%s: task_id is still zero after DETERMINE_EXTENSION_TASK_ID(%s)",
+                               __FUNCTION__,
+                               $ext_name
+                       ));
+               } // END - if
+       } // END - if
+
+       // Init queries and notes
        INIT_SQLS();
+       EXT_INIT_NOTES();
 
        // Init variables
        $ret = false;
-       $NOTES = "";
        $INC_POOL = array();
 
        // By default we have no failures
@@ -159,7 +173,7 @@ function EXTENSION_REGISTER ($ext_name, $task_id, $dry_run = false, $logout = tr
                        LOAD_EXTENSION($ext_name, "update", $ver, $dry_run);
 
                        // Add update notes to our output
-                       $NOTES .= ADD_EXTENSION_NOTES($ver);
+                       ADD_EXTENSION_NOTES($ver);
                } // END - foreach
 
                // Does this extension depends on an outstanding update of another update?
@@ -413,16 +427,13 @@ function GET_EXT_VERSION ($ext_name) {
 // Updates a given extension with current extension version to latest version
 function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) {
        // This shall never do a non-admin user!
-       global $NOTES;
        global $INC_POOL;
 
        // Init arrays
        INIT_SQLS();
+       EXT_INIT_NOTES();
        $INC_POOL = array();
 
-       // Init notes
-       $NOTES = "";
-
        // Only admins are allowed to update extensions
        if ((!IS_ADMIN()) || (empty($ext_name))) return false;
 
@@ -467,7 +478,7 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) {
                        } // END - if
 
                        // Add notes
-                       $NOTES .= ADD_EXTENSION_NOTES($GLOBALS['cache_array']['update_ver'][$ext_name]);
+                       ADD_EXTENSION_NOTES($GLOBALS['cache_array']['update_ver'][$ext_name]);
                } // END - for
 
                // In real-mode execute any existing includes
@@ -483,7 +494,7 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) {
 
                if (!$dry_run) {
                        // Create task
-                       CREATE_EXTENSION_UPDATE_TASK(GET_CURRENT_ADMIN_ID(), $ext_name, $GLOBALS['cache_array']['update_ver'][$ext_name], SQL_ESCAPE($NOTES));
+                       CREATE_EXTENSION_UPDATE_TASK(GET_CURRENT_ADMIN_ID(), $ext_name, $GLOBALS['cache_array']['update_ver'][$ext_name], SQL_ESCAPE(EXT_GET_NOTES(EXT_GET_NOTES())));
 
                        // Update extension's version
                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET ext_version='%s' WHERE ext_name='%s' LIMIT 1",
@@ -827,6 +838,8 @@ function ADD_EXTENSION_NOTES ($ver) {
                                'ver'   => $ver,
                                'notes' => EXT_GET_UPDATE_NOTES()
                        );
+
+                       // Reset them
                        EXT_SET_UPDATE_NOTES("");
                } elseif (($ver == "0.0") || ($ver == "0.0.0")) {
                        // Initial release
@@ -846,8 +859,8 @@ function ADD_EXTENSION_NOTES ($ver) {
                $out = LOAD_TEMPLATE("admin_ext_notes", true, $content);
        } // END - if
 
-       // Return the output
-       return $out;
+       // Add the notes
+       EXT_APPEND_NOTES($out);
 }
 
 // Getter for CSS files array
@@ -885,7 +898,7 @@ function EXT_ADD_CSS_FILE ($file) {
 
 // Setter for EXT_ALWAYS_ACTIVE flag
 function EXT_SET_ALWAYS_ACTIVE ($active) {
-       $GLOBALS['ext_always_active'] = $active;
+       $GLOBALS['ext_always_active'] = (string) $active;
 }
 
 // Getter for EXT_ALWAYS_ACTIVE flag
@@ -895,7 +908,7 @@ function EXT_GET_ALWAYS_ACTIVE () {
 
 // Setter for EXT_VERSION flag
 function EXT_SET_VERSION ($version) {
-       $GLOBALS['ext_version'] = $version;
+       $GLOBALS['ext_version'] = (float) $version;
 }
 
 // Getter for EXT_VERSION flag
@@ -905,7 +918,7 @@ function EXT_GET_VERSION () {
 
 // Setter for EXT_DEPRECATED flag
 function EXT_SET_DEPRECATED ($deprecated) {
-       $GLOBALS['ext_deprecated'] = $deprecated;
+       $GLOBALS['ext_deprecated'] = (string) $deprecated;
 }
 
 // Getter for EXT_DEPRECATED flag
@@ -915,7 +928,7 @@ function EXT_GET_DEPRECATED () {
 
 // Setter for EXT_UPDATE_DEPENDS flag
 function EXT_SET_UPDATE_DEPENDS ($updateDepends) {
-       $GLOBALS['ext_update_depends'] = $updateDepends;
+       $GLOBALS['ext_update_depends'] = (string) $updateDepends;
 }
 
 // Getter for EXT_UPDATE_DEPENDS flag
@@ -925,7 +938,7 @@ function EXT_GET_UPDATE_DEPENDS () {
 
 // Setter for EXT_REPORTS_FAILURE flag
 function EXT_SET_REPORTS_FAILURE ($reportsFailure) {
-       $GLOBALS['ext_reports_failure'] = $reportsFailure;
+       $GLOBALS['ext_reports_failure'] = (string) $reportsFailure;
 }
 
 // Getter for EXT_REPORTS_FAILURE flag
@@ -938,14 +951,14 @@ function EXT_SET_VER_HISTORY ($verHistory) {
        $GLOBALS['ext_ver_history'] = (array) $verHistory;
 }
 
-// Getter for EXT_VER_HISTORY flag
+// Getter for EXT_VER_HISTORY array
 function EXT_GET_VER_HISTORY () {
        return $GLOBALS['ext_ver_history'];
 }
 
 // Setter for EXT_UPDATE_NOTES flag
 function EXT_SET_UPDATE_NOTES ($updateNotes) {
-       $GLOBALS['ext_update_notes'] = (array) $updateNotes;
+       $GLOBALS['ext_update_notes'] = (string) $updateNotes;
 }
 
 // Getter for EXT_UPDATE_NOTES flag
@@ -953,5 +966,20 @@ function EXT_GET_UPDATE_NOTES () {
        return $GLOBALS['ext_update_notes'];
 }
 
+// Init extension notice
+function EXT_INIT_NOTES () {
+       $GLOBALS['ext_notes'] = "";
+}
+
+// Append extension notice
+function EXT_APPEND_NOTES ($notes) {
+       $GLOBALS['ext_notes'] .= (string) $notes;
+}
+
+// Getter for extension notes
+function EXT_GET_NOTES () {
+       return $GLOBALS['ext_notes'];
+}
+
 //
 ?>