[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/Webservices/ -> PreserveGlobal.php (source)

   1  <?php
   2  /*+***********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   *************************************************************************************/
  10  
  11  class VTWS_PreserveGlobal{
  12      
  13      private static $globalData = array();
  14      
  15  	static function preserveGlobal($name,$value){
  16          //$name store the name of the global.
  17          global $$name;
  18          //To not push null value . Ideally we should not push null value for any name
  19          //But current user null is dangerous so we are checking for only current user
  20          if(!empty($$name) || $name != 'current_user') {
  21              if(!is_array(VTWS_PreserveGlobal::$globalData[$name])){
  22                  VTWS_PreserveGlobal::$globalData[$name] = array();        
  23              }
  24              
  25              VTWS_PreserveGlobal::$globalData[$name][] = $$name;
  26          }
  27  
  28          $$name = $value;
  29          return $$name;
  30      }
  31      
  32  	static function restore($name){
  33          //$name store the name of the global.
  34          global $$name;
  35          
  36          if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0){
  37              $$name = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
  38          }
  39          $$name;
  40      }
  41      
  42  	static function getGlobal($name){
  43          global $$name;
  44          return VTWS_PreserveGlobal::preserveGlobal($name,$$name);
  45      }
  46      
  47  	static function flush(){
  48          foreach (VTWS_PreserveGlobal::$globalData as $name => $detail) {
  49              //$name store the name of the global.
  50              global $$name;
  51              if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0) {
  52                  $$name = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
  53              }
  54          }
  55      }
  56      
  57  }
  58  
  59  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1