[ Index ]
 

Code source de SugarCRM 5.0.0beta1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> TreeData.php (source)

   1  <?php
   2   if(!defined('sugarEntry'))define('sugarEntry', true);
   3  /*********************************************************************************

   4   * SugarCRM is a customer relationship management program developed by

   5   * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.

   6   * 

   7   * This program is free software; you can redistribute it and/or modify it under

   8   * the terms of the GNU General Public License version 3 as published by the

   9   * Free Software Foundation.

  10   * 

  11   * This program is distributed in the hope that it will be useful, but WITHOUT

  12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

  13   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more

  14   * details.

  15   * 

  16   * You should have received a copy of the GNU General Public License along with

  17   * this program; if not, see http://www.gnu.org/licenses or write to the Free

  18   * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

  19   * 02110-1301 USA.

  20   * 

  21   * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,

  22   * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.

  23   * 

  24   * The interactive user interfaces in modified source and object code versions

  25   * of this program must display Appropriate Legal Notices, as required under

  26   * Section 5 of the GNU General Public License version 3.

  27   * 

  28   * In accordance with Section 7(b) of the GNU General Public License version 3,

  29   * these Appropriate Legal Notices must retain the display of the "Powered by

  30   * SugarCRM" logo. If the display of the logo is not reasonably feasible for

  31   * technical reasons, the Appropriate Legal Notices must display the words

  32   * "Powered by SugarCRM".

  33   ********************************************************************************/
  34   //Request object must have these property values:

  35   //        Module: module name, this module should have a file called TreeData.php

  36   //        Function: name of the function to be called in TreeData.php, the function will be called statically.

  37   //        PARAM prefixed properties: array of these property/values will be passed to the function as parameter.

  38  require_once ('include/utils/file_utils.php');
  39  require_once ('data/SugarBean.php');
  40  require_once ('include/JSON.php');
  41  require_once ('include/entryPoint.php');
  42  
  43  session_start();
  44  $ret=array();
  45  $params1=array();
  46  $nodes=array();
  47  
  48  $GLOBALS['log']->debug("TreeData:session started");
  49  
  50  function authenticate()
  51  {
  52      global $sugar_config;
  53       $user_unique_key = (isset($_SESSION['unique_key'])) ? $_SESSION['unique_key'] : "";
  54       $server_unique_key = (isset($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : "";
  55  
  56       if ($user_unique_key != $server_unique_key) {
  57          $GLOBALS['log']->debug("JSON_SERVER: user_unique_key:".$user_unique_key."!=".$server_unique_key);
  58          session_destroy();
  59          return null;
  60       }
  61  
  62       if(!isset($_SESSION['authenticated_user_id']))
  63       {
  64           $GLOBALS['log']->debug("JSON_SERVER: authenticated_user_id NOT SET. DESTROY");
  65          session_destroy();
  66          return null;
  67       }
  68  
  69       $current_user = new User();
  70  
  71       $result = $current_user->retrieve($_SESSION['authenticated_user_id']);
  72       $GLOBALS['log']->debug("JSON_SERVER: retrieved user from SESSION");
  73  
  74       if($result == null)
  75       {
  76          $GLOBALS['log']->debug("JSON_SERVER: could get a user from SESSION. DESTROY");
  77             session_destroy();
  78             return null;
  79       }
  80      return $result;
  81  }
  82  
  83  if(!empty($sugar_config['session_dir'])) {
  84      session_save_path($sugar_config['session_dir']);
  85      $GLOBALS['log']->debug("JSON_SERVER:session_save_path:".$sugar_config['session_dir']);
  86  }
  87  
  88  //get language

  89  $current_language = $sugar_config['default_language'];
  90  // if the language is not set yet, then set it to the default language.

  91  if(isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '') {
  92      $current_language = $_SESSION['authenticated_user_language'];
  93  } 
  94  
  95  //validate user.

  96  $current_user = authenticate();
  97  
  98  global $app_strings;
  99  if (empty($app_strings)) {
 100      //set module and application string arrays based upon selected language

 101      $app_strings = return_application_language($current_language);
 102  }
 103  
 104  //get theme

 105  $theme = $sugar_config['default_theme'];
 106  if(isset($_SESSION['authenticated_user_theme']) && $_SESSION['authenticated_user_theme'] != '') {
 107      $theme = $_SESSION['authenticated_user_theme'];
 108  }
 109  //set image path

 110  $image_path = 'themes/'.$theme.'/images/';
 111  
 112  //process request parameters. consider following parameters.

 113  //function, and all parameters prefixed with PARAM.

 114  //PARAMT_ are tree level parameters.

 115  //PARAMN_ are node level parameters.

 116  //module  name and function name parameters are the only ones consumed

 117  //by this file..

 118  foreach ($_REQUEST as $key=>$value) {
 119  
 120      switch ($key) {
 121      
 122          case "function":
 123          case "call_back_function":
 124              $func_name=$value;
 125              $params1['TREE']['function']=$value;
 126              break;
 127              
 128          default:
 129              $pssplit=explode('_',$key);
 130              if ($pssplit[0] =='PARAMT') {
 131                  unset($pssplit[0]);
 132                  $params1['TREE'][implode('_',$pssplit)]=$value;                
 133              } else {
 134                  if ($pssplit[0] =='PARAMN') {
 135                      $depth=$pssplit[count($pssplit)-1];
 136                      //parmeter is surrounded  by PARAMN_ and depth info.

 137                      unset($pssplit[count($pssplit)-1]);unset($pssplit[0]);    
 138                      $params1['NODES'][$depth][implode('_',$pssplit)]=$value;
 139                  } else {
 140                      if ($key=='module') {
 141                          if (!isset($params1['TREE']['module'])) {
 142                              $params1['TREE'][$key]=$value;    
 143                          }
 144                      } else {     
 145                          $params1['REQUEST'][$key]=$value;
 146                      }                    
 147                  }
 148              }
 149      }    
 150  }    
 151  $modulename=$params1['TREE']['module']; ///module is a required parameter for the tree.

 152  if (!empty($modulename) && !empty($func_name)) {
 153      //todo add file validation...

 154      //if (file_exists('modules/'.$modulename.'/TreeData.php')) {

 155          require_once('modules/'.$modulename.'/TreeData.php');
 156          if (function_exists($func_name)) {
 157              $ret=call_user_func($func_name,$params1);
 158          }
 159      //}

 160  }
 161  
 162  if (!empty($ret)) {
 163      echo $ret;
 164  }
 165  sugar_cleanup();
 166  exit();
 167  ?>


Généré le : Tue Sep 11 10:48:47 2007 par Balluche grâce à PHPXref 0.7