Browse Source

Wanted to add the SquirrelMail versioning functions we'd talked about before
we split the streams to the new RC for 1.4.

check_sm_version performs similar function to check_php_version, and
will return true if version is >= what is specified.

For Thijs/Jonathan - the check_sm_version will return false if the
constant it checks against is not defined, making the function itself
safe for previous levels, should you want to roll it back to stable
to allow plugin developers to use the check_sm_version function to
test for 'new' elements like SM_PATH, etc. that are present in 1.3.x
and up.

More info (though not a ton, I'll admit) is in the sm2-planning module
in cvs: cvs co sm2-planning, then pull up sm2-planning/index.php in your
browser.

Erin Schnabel 22 years ago
parent
commit
415b302b6f
2 changed files with 35 additions and 2 deletions
  1. 27 2
      functions/global.php
  2. 8 0
      functions/strings.php

+ 27 - 2
functions/global.php

@@ -53,17 +53,42 @@ if (get_magic_quotes_gpc()) {
 
 $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
 
-/* returns true if current php version is at mimimum a.b.c */
+/** 
+ * returns true if current php version is at mimimum a.b.c 
+ * 
+ * Called: check_php_version(4,1)
+ */
 function check_php_version ($a = '0', $b = '0', $c = '0')             
 {
     global $SQ_PHP_VERSION;
-
+ 
     if(!isset($SQ_PHP_VERSION))
         $SQ_PHP_VERSION = substr( str_pad( preg_replace('/\D/','', PHP_VERSION), 3, '0'), 0, 3);
 
     return $SQ_PHP_VERSION >= ($a.$b.$c);
 }
 
+/**
+ * returns true if the current internal SM version is at minimum a.b.c 
+ * These are plain integer comparisons, as our internal version is 
+ * constructed by us, as an array of 3 ints.
+ *
+ * Called: check_sm_version(1,3,3)
+ */
+function check_sm_version($a = 0, $b = 0, $c = 0)
+{
+    global $SQM_INTERNAL_VERSION;
+    if ( !isset($SQM_INTERNAL_VERSION) ||
+         $SQM_INTERNAL_VERSION[0] < $a ||
+	 $SQM_INTERNAL_VERSION[1] < $b ||
+	 ( $SQM_INTERNAL_VERSION[1] == $b &&
+           $SQM_INTERNAL_VERSION[2] < $c ) ) {
+        return FALSE;
+    } 
+    return TRUE;  
+}
+
+
 /* recursively strip slashes from the values of an array */
 function sqstripslashes(&$array) {
     if(count($array) > 0) {

+ 8 - 0
functions/strings.php

@@ -18,6 +18,14 @@
 global $version;
 $version = '1.3.3 [CVS-DEVEL]';
 
+/** 
+ * SquirrelMail internal version number -- DO NOT CHANGE
+ * $sm_internal_version = array (release, major, minor)
+ */
+//global $SQM_INTERNAL_VERSION;
+//$SQM_INTERNAL_VERSION = array(1,3,3);
+
+
 /**
  * Wraps text at $wrap characters
  *