]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/Smarty/plugins/function.sugar_fetch.php
Release 6.5.0
[Github/sugarcrm.git] / include / Smarty / plugins / function.sugar_fetch.php
1 <?php
2
3 /*
4
5 Modification information for LGPL compliance
6
7 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
8
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
10
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
12
13 r53409 - 2010-01-03 19:31:15 -0800 (Sun, 03 Jan 2010) - roger - merge -r50376:HEAD from fuji_newtag_tmp
14
15
16 */
17
18
19 /**
20  * Smarty plugin
21  * @package Smarty
22  * @subpackage plugins
23  */
24
25
26 /**
27  * Smarty {sugar_fetch} function plugin
28  *
29  * Type:     function<br>
30  * Name:     sugar_fetch<br>
31  * Purpose:  grabs the requested index from either an object or an array
32  * 
33  * @author Rob Aagaard {rob at sugarcrm.com}
34  * @param array
35  * @param Smarty
36  */
37
38 function smarty_function_sugar_fetch($params, &$smarty)
39 {
40         if(empty($params['key']))  {
41             $smarty->trigger_error("sugar_fetch: missing 'key' parameter");
42             return;
43         }    
44     if(empty($params['object'])) {
45             $smarty->trigger_error("sugar_fetch: missing 'object' parameter");
46             return;        
47     }
48     
49     $theKey = $params['key'];
50     if(is_object($params['object'])) {
51         $theData = $params['object']->$theKey;
52     } else {
53         $theData = $params['object'][$theKey];
54     }
55
56     if(!empty($params['assign'])) {
57         $smarty->assign($params['assign'],$theData);
58     } else {
59         return $theData;
60     }
61 }