phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: phpgwapi/inc functions.inc.php,1.130,1.131


From: Mark A Peters <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc functions.inc.php,1.130,1.131
Date: Wed, 27 Feb 2002 22:46:38 -0500

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

Modified Files:
        functions.inc.php 
Log Message:
Adding the new get_var().

Index: functions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/functions.inc.php,v
retrieving revision 1.130
retrieving revision 1.131
diff -C2 -r1.130 -r1.131
*** functions.inc.php   23 Feb 2002 18:07:45 -0000      1.130
--- functions.inc.php   28 Feb 2002 03:46:34 -0000      1.131
***************
*** 254,257 ****
--- 254,260 ----
                                $posttype = 'HTTP_GET_VARS';
                                break;
+                       case 'cookie':
+                               $posttype = 'HTTP_COOKIE_VARS';
+                               break;
                        default :
                                $posttype = 'HTTP_POST_VARS';
***************
*** 327,330 ****
--- 330,382 ----
        }
  
+ 
+       /*!
+        @function get_var
+        @abstract retrieve a value from either a POST, GET, COOKIE, or from a 
class variable.
+        @author skeeter
+        @discussion This function is used to retrieve a value from a user 
defined order of methods. 
+        @syntax 
get_var('id',array('HTTP_POST_VARS'||'POST','HTTP_GET_VARS'||'GET','HTTP_COOKIE_VARS'||'COOKIE','GLOBAL','DEFAULT'));
+        @example $this->id = 
get_var('id',array('HTTP_POST_VARS'||'POST','HTTP_GET_VARS'||'GET','HTTP_COOKIE_VARS'||'COOKIE','GLOBAL','DEFAULT'));
+        @param $variable name
+        @param $method ordered array of methods to search for supplied variable
+        @param $default_value (optional)
+       */
+       function get_var($variable,$method,$default_value='')
+       {
+               for($i=0;$i<count($method);$i++)
+               {
+                       switch(strtoupper($method[$i]))
+                       {
+                               case 'DEFAULT':
+                                       if($default_value)
+                                       {
+                                               $var = $default_value;
+                                       }
+                                       break;
+                               case 'GLOBAL':
+                                       if(@isset($GLOBALS[$variable]))
+                                       {
+                                               $var = $GLOBALS[$variable];
+                                       }
+                                       break;
+                               case 'POST':
+                               case 'GET':
+                               case 'COOKIE':
+                                       
if(@isset($GLOBALS['HTTP_'.strtoupper($method[$i]).'_VARS'][$variable]))
+                                       {
+                                               $var = 
$GLOBALS['HTTP_'.strtoupper($method[$i]).'_VARS'][$variable];
+                                       }
+                                       break;
+                               default:
+                                       
if(@isset($GLOBALS[strtoupper($method[$i])][$variable]))
+                                       {
+                                               $var = 
$GLOBALS[strtoupper($method[$i])][$variable];
+                                       }
+                                       break;
+                       }
+               }
+               return $var;
+       }
+       
        /*!
         @function CreateObject




reply via email to

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