phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc common_functions.inc.php,1.2,1.3


From: Mark A Peters <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc common_functions.inc.php,1.2,1.3
Date: Fri, 15 Mar 2002 21:57:02 -0500

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv4098/phpgwapi/inc

Modified Files:
        common_functions.inc.php 
Log Message:
Interim step in moving a a<less|more>thanb to some sommon functions to use it 
for app_registry functions.

Index: common_functions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/common_functions.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** common_functions.inc.php    2 Mar 2002 04:08:20 -0000       1.2
--- common_functions.inc.php    16 Mar 2002 02:56:57 -0000      1.3
***************
*** 641,643 ****
--- 641,813 ----
                }
        }
+ 
+       /*
+       @function alessthanb
+       @abstract phpgw version checking, is param 1 < param 2 in phpgw 
versionspeak?
+       @param  $a      phpgw version number to check if less than $b
+       @param  $b      phpgw version number to check $a against
+       #return True if $a < $b
+       */
+       function alessthanb($a,$b,$DEBUG=False)
+       {
+               $num = array('1st','2nd','3rd','4th');
+ 
+               if ($DEBUG)
+               {
+                       echo'<br>Input values: '
+                               . 'A="'.$a.'", B="'.$b.'"';
+               }
+               $newa = ereg_replace('pre','.',$a);
+               $newb = ereg_replace('pre','.',$b);
+               $testa = explode('.',$newa);
+               if(@$testa[1] == '')
+               {
+                       $testa[1] = 0;
+               }
+               if(@$testa[3] == '')
+               {
+                       $testa[3] = 0;
+               }
+               $testb = explode('.',$newb);
+               if(@$testb[1] == '')
+               {
+                       $testb[1] = 0;
+               }
+               if(@$testb[3] == '')
+               {
+                       $testb[3] = 0;
+               }
+               $less = 0;
+ 
+               for ($i=0;$i<count($testa);$i++)
+               {
+                       if ($DEBUG) { echo'<br>Checking if '. 
intval($testa[$i]) . ' is less than ' . intval($testb[$i]) . ' ...'; }
+                       if (intval($testa[$i]) < intval($testb[$i]))
+                       {
+                               if ($DEBUG) { echo ' yes.'; }
+                               $less++;
+                               if ($i<3)
+                               {
+                                       /* Ensure that this is definitely 
smaller */
+                                       if ($DEBUG) { echo"  This is the 
$num[$i] octet, so A is definitely less than B."; }
+                                       $less = 5;
+                                       break;
+                               }
+                       }
+                       elseif(intval($testa[$i]) > intval($testb[$i]))
+                       {
+                               if ($DEBUG) { echo ' no.'; }
+                               $less--;
+                               if ($i<2)
+                               {
+                                       /* Ensure that this is definitely 
greater */
+                                       if ($DEBUG) { echo"  This is the 
$num[$i] octet, so A is definitely greater than B."; }
+                                       $less = -5;
+                                       break;
+                               }
+                       }
+                       else
+                       {
+                               if ($DEBUG) { echo ' no, they are equal.'; }
+                               $less = 0;
+                       }
+               }
+               if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
+               if ($less>0)
+               {
+                       if ($DEBUG) { echo '<br>A is less than B'; }
+                       return True;
+               }
+               elseif($less<0)
+               {
+                       if ($DEBUG) { echo '<br>A is greater than B'; }
+                       return False;
+               }
+               else
+               {
+                       if ($DEBUG) { echo '<br>A is equal to B'; }
+                       return False;
+               }
+       }
+ 
+       /*!
+       @function amorethanb
+       @abstract phpgw version checking, is param 1 > param 2 in phpgw 
versionspeak?
+       @param  $a      phpgw version number to check if more than $b
+       @param  $b      phpgw version number to check $a against
+       #return True if $a < $b
+       */
+       function amorethanb($a,$b,$DEBUG=False)
+       {
+               $num = array('1st','2nd','3rd','4th');
+ 
+               if ($DEBUG)
+               {
+                       echo'<br>Input values: '
+                               . 'A="'.$a.'", B="'.$b.'"';
+               }
+               $newa = ereg_replace('pre','.',$a);
+               $newb = ereg_replace('pre','.',$b);
+               $testa = explode('.',$newa);
+               if($testa[3] == '')
+               {
+                       $testa[3] = 0;
+               }
+               $testb = explode('.',$newb);
+               if($testb[3] == '')
+               {
+                       $testb[3] = 0;
+               }
+               $less = 0;
+ 
+               for ($i=0;$i<count($testa);$i++)
+               {
+                       if ($DEBUG) { echo'<br>Checking if '. 
intval($testa[$i]) . ' is more than ' . intval($testb[$i]) . ' ...'; }
+                       if (intval($testa[$i]) > intval($testb[$i]))
+                       {
+                               if ($DEBUG) { echo ' yes.'; }
+                               $less++;
+                               if ($i<3)
+                               {
+                                       /* Ensure that this is definitely 
greater */
+                                       if ($DEBUG) { echo"  This is the 
$num[$i] octet, so A is definitely greater than B."; }
+                                       $less = 5;
+                                       break;
+                               }
+                       }
+                       elseif(intval($testa[$i]) < intval($testb[$i]))
+                       {
+                               if ($DEBUG) { echo ' no.'; }
+                               $less--;
+                               if ($i<2)
+                               {
+                                       /* Ensure that this is definitely 
smaller */
+                                       if ($DEBUG) { echo"  This is the 
$num[$i] octet, so A is definitely less than B."; }
+                                       $less = -5;
+                                       break;
+                               }
+                       }
+                       else
+                       {
+                               if ($DEBUG) { echo ' no, they are equal.'; }
+                               $less = 0;
+                       }
+               }
+               if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
+               if ($less>0)
+               {
+                       if ($DEBUG) { echo '<br>A is greater than B'; }
+                       return True;
+               }
+               elseif($less<0)
+               {
+                       if ($DEBUG) { echo '<br>A is less than B'; }
+                       return False;
+               }
+               else
+               {
+                       if ($DEBUG) { echo '<br>A is equal to B'; }
+                       return False;
+               }
+       }
  ?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]