Alexandros Vellis | 2 Dec 2002 15:35
X-Face
Picon

Updating plugins to work with 1.3.x: How to check for the version?

I am trying to get avelsieve (SIEVE mail filters) and ldapuserdata (LDAP
prefs backend) to work with 1.3.x (latest CVS). I've figured out the
SM_PATH stuff and the changes in the include directories. Also the LDAP
prefs backend needs a bit more work to make it look and work nice with
the new changes.

Now to my question. I'd like the plugin to work with 1.2.x as well as
1.3.x. Is checking for the $version defined in functions/strings.php
enough? In other words, does this look good to you? :

if (strstr($version, "1.3")) {  /* or something to that effect */
	/* new way */
	include_once (SM_PATH . "include/....");
	
} elseif (strstr($version, "1.2")) {
	/* old way */
	chdir (..);
	include_once ("../functions/....");
}

Any comments or suggestions would be appreciated!

Cheers,

--

-- 
Alexandros Vellis       University of Athens
avel <at> noc.uoa.gr         Network Operations Centre
        http://www.noc.uoa.gr/~avel/
Public Key: http://www.noc.uoa.gr/~avel/gpgkey.asc

(Continue reading)

p dont think | 3 Dec 2002 07:14

RE: [SM-PLUGINS] Updating plugins to work with 1.3.x: How to check for the version?

OK, here is a function I think will work for detecting the difference
between not only 1.2.x and 1.3.x but any SM versions at all.  Because of
the fact that the 10 in 1.2.10 is two digits, the scheme used for SM's
check_php_version() doesn't work.  

I would actually propose that the DEVEL team integrate this into
global.php so it doesn't have to be replicated for every plugin...
thoughts anyone?

Here it is - obviously, you'll want to replace "xx" as appropriate:

   // returns true if current SquirrelMail version is at mimimum a.b.c
   //
   function xx_check_SM_version ($a = '0', $b = '0', $c = '0')
   {
      global $version;

      list($aa, $bb, $cc) = preg_split('/\./', $version, 3);

      return ($aa > $a)
          || (($aa == $a) && ($bb > $b))
          || (($aa == $a) && ($bb == $b) && ($cc >= $c));
   }

Test with:

if (fm_check_SM_version(1,2,7)) echo "<hr>good for 1.2.7<hr>";
if (fm_check_SM_version(1,2,8)) echo "<hr>good for 1.2.8<hr>";
if (fm_check_SM_version(1,2,9)) echo "<hr>good for 1.2.9<hr>";
if (fm_check_SM_version(1,2,10)) echo "<hr>good for 1.2.10<hr>";
(Continue reading)

Alexandros Vellis | 3 Dec 2002 18:46
X-Face
Picon

Re: RE: [SM-PLUGINS] Updating plugins to work with 1.3.x: How to check for the version?

[Dropped squirrelmail-plugins from Cc:]

On Mon, 2 Dec 2002 22:14:45 -0800
"p dont think" <pdontthink <at> angrynerds.com> wrote:

In the function, after this line:
>       list($aa, $bb, $cc) = preg_split('/\./', $version, 3);

one can also add something like

      if(!is_numeric($cc)) {
           list($cc, $info) = explode(" ", $cc, 2);
       }

to take into account the case where it might actually be $version =
"1.3.6 [CVS-DEVEL]" or "1.4.8 [CUSTOMIZED-BLAH-BLAH]".

And then, why not, implement some checking with the string in the
brackets [] for some customized installations probably...

Cheers,
Alex

-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET 
comprehensive development tool, built to increase your 
productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
--
squirrelmail-devel mailing list
(Continue reading)

Erin Schnabel | 4 Dec 2002 01:22
Favicon

Re: RE: [SM-PLUGINS] Updating plugins to work with 1.3.x: How to check for the version?

> [Dropped squirrelmail-plugins from Cc:]
>
> On Mon, 2 Dec 2002 22:14:45 -0800
> "p dont think" <pdontthink <at> angrynerds.com> wrote:
>
> In the function, after this line:
>>       list($aa, $bb, $cc) = preg_split('/\./', $version, 3);
>
> one can also add something like
>
>       if(!is_numeric($cc)) {
>            list($cc, $info) = explode(" ", $cc, 2);
>        }
>
> to take into account the case where it might actually be $version =
> "1.3.6 [CVS-DEVEL]" or "1.4.8 [CUSTOMIZED-BLAH-BLAH]".
>
> And then, why not, implement some checking with the string in the
> brackets [] for some customized installations probably...
>
> Cheers,
> Alex

I have a better idea.

Since 1.2.x etc. is technically "back-level", why don't we create, for the
1.3.x -> 1.4/1.5 streams, a global variable that is some unique version
identifier. That is, global $sm_internal_version = 010030004 or something
like that.

(Continue reading)

p dont think | 4 Dec 2002 05:54

RE: RE: [SM-PLUGINS] Updating plugins to work with 1.3.x: How to check for the version?

That sounds fine to me.  It's one more number for y'all to keep track
of, but not a big deal, really.

From a plugin developer's point of view, the important thing to note is
that this number will not just be used to tell the difference between
1.2.x and newer versions, but between any versions, for example 1.3.1
and 1.3.2 or 1.3.5 and 1.4.1, etc.  So it'd be really important for you
to make it obvious to plugin developers how the "internal version
number" maps to the published version number.  And version number
changes should parallel one another, that is, there should not be more
than one internal version number per release.

It seems redundant to keep two numbers that essentially refer to the
same code release, so the only thing we'd get out of it is a way to
avoid the overhead of a function call such as has been suggested.

Either way, I'm sure all the plugin developers would thank you for
integrating something to make version checking a little easier.

Thoughts?

  - paul

> -----Original Message-----
> From: squirrelmail-devel-admin <at> lists.sourceforge.net
> [mailto:squirrelmail-devel-admin <at> lists.sourceforge.net] On Behalf Of
Erin
> Schnabel
> Sent: Tuesday, December 03, 2002 4:23 PM
> To: squirrelmail-devel <at> lists.sourceforge.net
(Continue reading)

Robin Bowes | 4 Dec 2002 11:30
Favicon

RE: RE: [SM-PLUGINS] Updating plugins to work with 1.3.x: How to check for the version?

Hi,

Here's another couple of ideas for the melting pot.

Why not split the version number into discrete items? An example is the
best way to illustrate what I mean:

Consider SM v1.2.8; define the following variables:

SM_Version_Release = 1;
SM_Version_Major = 2;
SM_Version_Minor = 8;

This would mean it wouldn't be necessary to parse a text version string to
get at the actual numbers.

Another idea, though I'm not sure about the exact syntax, how about
encoding these numbers as Hex, e.g.:

SM_Version = 0x010208;

Using this method, it would be possible to compare versions, e.g. if
(SM_Version > 0x010208) ...

Also, it would be possible to get at the release/major/minor numbers
pretty easily using something like if (SM_Version && 0x000200) ... (again,
I'm not sure of the exact syntax).

Thoughts?

(Continue reading)

Alexandros Vellis | 3 Dec 2002 10:17
X-Face
Picon

Re: [SM-PLUGINS] Updating plugins to work with 1.3.x: How to check for the version?

On Mon, 2 Dec 2002 22:14:45 -0800
"p dont think" <pdontthink <at> angrynerds.com> wrote:

> OK, here is a function I think will work for detecting the difference
> between not only 1.2.x and 1.3.x but any SM versions at all. 

Very nice! Thanks for all the replies.

I also vote for this being available globally in SM!

Sieve Mail Filters "avelsieve" 0.9 will hopefully work with 1.3.x!

Cheers,
Alexandros

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
--
squirrelmail-devel mailing list
List Address: squirrelmail-devel <at> lists.sourceforge.net
List Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=7139
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Jason Munro | 2 Dec 2002 20:20

Re: Updating plugins to work with 1.3.x: How to check for the version?

Alexandros Vellis said:
> I am trying to get avelsieve (SIEVE mail filters) and ldapuserdata (LDAP
> prefs backend) to work with 1.3.x (latest CVS). I've figured out the
> SM_PATH stuff and the changes in the include directories. Also the LDAP
> prefs backend needs a bit more work to make it look and work nice with
> the new changes.
>
> Now to my question. I'd like the plugin to work with 1.2.x as well as
> 1.3.x. Is checking for the $version defined in functions/strings.php
> enough? In other words, does this look good to you? :
>
> if (strstr($version, "1.3")) {  /* or something to that effect */
> 	/* new way */
> 	include_once (SM_PATH . "include/....");
>
> } elseif (strstr($version, "1.2")) {
> 	/* old way */
> 	chdir (..);
> 	include_once ("../functions/....");
> }
>
> Any comments or suggestions would be appreciated!

Here is how I do it in the mini plugin:

/* include what we need */
require_once('../../functions/strings.php');

/* check for SM versions greater than 1.3 */
if (substr($version, 2,4) > 3.1) {
(Continue reading)

pdontthink | 2 Dec 2002 21:39

Re: Updating plugins to work with 1.3.x: How to check for the version?

But I think that your way will fail for people using certain locales (ala
all that trouble with the release of 1.2.9 and PHP_VERSION) wherein the
dot is not interpreted as a normal decimal point (or something like that)
and thus the comparison won't behave as expected.  If someone doesn't get
to it first, I'll try to post a replica of check_php_version() for
detecting the SM version to this list tonight...

> Alexandros Vellis said:
>> I am trying to get avelsieve (SIEVE mail filters) and ldapuserdata
>> (LDAP prefs backend) to work with 1.3.x (latest CVS). I've figured out
>> the SM_PATH stuff and the changes in the include directories. Also the
>> LDAP prefs backend needs a bit more work to make it look and work nice
>> with the new changes.
>>
>> Now to my question. I'd like the plugin to work with 1.2.x as well as
>> 1.3.x. Is checking for the $version defined in functions/strings.php
>> enough? In other words, does this look good to you? :
>>
>> if (strstr($version, "1.3")) {  /* or something to that effect */
>> 	/* new way */
>> 	include_once (SM_PATH . "include/....");
>>
>> } elseif (strstr($version, "1.2")) {
>> 	/* old way */
>> 	chdir (..);
>> 	include_once ("../functions/....");
>> }
>>
>> Any comments or suggestions would be appreciated!
>
(Continue reading)

Chris Hilts | 2 Dec 2002 18:25
Gravatar

Re: Updating plugins to work with 1.3.x: How to check for the version?

> Now to my question. I'd like the plugin to work with 1.2.x as well as
> 1.3.x. Is checking for the $version defined in functions/strings.php
> enough? In other words, does this look good to you? :

Try check_php_version(), which can be found in functions/global.php

--

-- 
Chris Hilts
chilts <at> birdbrained.org

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
--
squirrelmail-plugins mailing list
List Address: squirrelmail-plugins <at> lists.sourceforge.net
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-plugins
http://squirrelmail.org/cvs

Jonathan Angliss | 2 Dec 2002 18:49

Re: Updating plugins to work with 1.3.x: How to check for the version?

Hello Chris,
On Monday, December 02, 2002, Chris Hilts wrote...

>> Now to my question. I'd like the plugin to work with 1.2.x as well as
>> 1.3.x. Is checking for the $version defined in functions/strings.php
>> enough? In other words, does this look good to you? :

> Try check_php_version(), which can be found in functions/global.php

  That's not quite what he is after I don't think. He's trying to do a
  check in his plugin to see if the user is using SM 1.3.x or SM
  1.2.x. The check_php_version() function just checks to see if you
  are using a version of PHP greater that the version you supply... or
  am I miss-understanding his request?

--

-- 
Jonathan Angliss
(ja <at> certiflexdimension.com)

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
--
squirrelmail-plugins mailing list
List Address: squirrelmail-plugins <at> lists.sourceforge.net
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-plugins
http://squirrelmail.org/cvs

(Continue reading)

pdontthink | 2 Dec 2002 20:06

Re: Updating plugins to work with 1.3.x: How to check for the version?

Jonathan is correct.  I had been using a preg_replace to get rid of the
periods and then check if the resulting integer was greater than 127 to
figure out the difference between 1.2.7 and 1.2.8/1.2.9.  This could also
work for 1.3.x....  but it *will not* work because there is now a 1.2.10. 
I am thinking I will write a quickie function that mimicks
check_php_version() for SM version checking...  that way we could be ready
for 1.4.x too.

> Hello Chris,
> On Monday, December 02, 2002, Chris Hilts wrote...
>
>>> Now to my question. I'd like the plugin to work with 1.2.x as well as
>>> 1.3.x. Is checking for the $version defined in functions/strings.php
>>> enough? In other words, does this look good to you? :
>
>> Try check_php_version(), which can be found in functions/global.php
>
>   That's not quite what he is after I don't think. He's trying to do a
> check in his plugin to see if the user is using SM 1.3.x or SM
>   1.2.x. The check_php_version() function just checks to see if you are
> using a version of PHP greater that the version you supply... or am I
> miss-understanding his request?
>
> --
> Jonathan Angliss
> (ja <at> certiflexdimension.com)
>
>
>
> -------------------------------------------------------
(Continue reading)


Gmane