]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - TreeData.php
Release 6.5.16
[Github/sugarcrm.git] / TreeData.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38  //Request object must have these property values:
39  //             Module: module name, this module should have a file called TreeData.php
40  //             Function: name of the function to be called in TreeData.php, the function will be called statically.
41  //             PARAM prefixed properties: array of these property/values will be passed to the function as parameter.
42
43 $ret=array();
44 $params1=array();
45 $nodes=array();
46
47 $GLOBALS['log']->debug("TreeData:session started");
48 $current_language = $GLOBALS['current_language'];
49
50 //process request parameters. consider following parameters.
51 //function, and all parameters prefixed with PARAM.
52 //PARAMT_ are tree level parameters.
53 //PARAMN_ are node level parameters.
54 //module  name and function name parameters are the only ones consumed
55 //by this file..
56 foreach ($_REQUEST as $key=>$value) {
57
58         switch ($key) {
59         
60                 case "function":
61                 case "call_back_function":
62                         $func_name=$value;
63                         $params1['TREE']['function']=$value;
64                         break;
65                         
66                 default:
67                         $pssplit=explode('_',$key);
68                         if ($pssplit[0] =='PARAMT') {
69                                 unset($pssplit[0]);
70                                 $params1['TREE'][implode('_',$pssplit)]=$value;                         
71                         } else {
72                                 if ($pssplit[0] =='PARAMN') {
73                                         $depth=$pssplit[count($pssplit)-1];
74                                         //parmeter is surrounded  by PARAMN_ and depth info.
75                                         unset($pssplit[count($pssplit)-1]);unset($pssplit[0]);  
76                                         $params1['NODES'][$depth][implode('_',$pssplit)]=$value;
77                                 } else {
78                                         if ($key=='module') {
79                                                 if (!isset($params1['TREE']['module'])) {
80                                                         $params1['TREE'][$key]=$value;  
81                                                 }
82                                         } else {        
83                                                 $params1['REQUEST'][$key]=$value;
84                                         }                                       
85                                 }
86                         }
87         }       
88 }       
89 $modulename=$params1['TREE']['module']; ///module is a required parameter for the tree.
90 require('include/modules.php');
91 if (!empty($modulename) && !empty($func_name) && isset($beanList[$modulename]) ) {
92     require_once('modules/'.$modulename.'/TreeData.php');
93     $TreeDataFunctions = array(
94         'ProductTemplates' => array('get_node_data'=>'','get_categories_and_products'=>''),
95         'ProductCategories' => array('get_node_data'=>'','get_product_categories'=>''),
96         'KBTags' => array(
97             'get_node_data'=>'',
98             'get_tags_nodes'=>'',
99             'get_tags_nodes_cached'=>'',
100             'childNodes'=>'',
101             'get_searched_tags_nodes'=>'',
102             'find_peers'=>'',
103             'getRootNode'=>'',
104             'getParentNode'=>'',
105             'get_tags_modal_nodes'=>'',
106             'get_admin_browse_articles'=>'',
107             'tagged_documents_count'=>'',
108             'tag_count'=>'',
109             'get_browse_documents'=>'',
110             'get_tag_nodes_for_browsing'=>'',
111             'create_browse_node'=>'',
112             'untagged_documents_count'=>'',
113             'check_tag_child_tags_for_articles'=>'',
114             'childTagsHaveArticles'=>'',
115             ),
116         'KBDocuments' => array(
117             'get_node_data'=>'',
118             'get_category_nodes'=>'',
119             'get_documents'=>'',
120             ),
121         'Forecasts' => array(
122             'get_node_data'=>'',
123             'get_worksheet'=>'',
124             'commit_forecast'=>'',
125             'save_worksheet'=>'',
126             'list_nav'=>'',
127             'reset_worksheet'=>'',
128             'get_chart'=>'',
129             ),
130         'Documents' => array(
131             'get_node_data'=>'',
132             'get_category_nodes'=>'',
133             'get_documents'=>'',
134             ),
135         );
136         
137         if (isset($TreeDataFunctions[$modulename][$func_name])) {
138                 $ret=call_user_func($func_name,$params1);
139     }
140 }
141
142 if (!empty($ret)) {
143         echo $ret;
144 }
145
146 ?>