]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - service/core/SoapHelperWebService.php
Release 6.1.4
[Github/sugarcrm.git] / service / core / SoapHelperWebService.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 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
39 global $disable_date_format;
40 $disable_date_format = true;
41
42 class SoapHelperWebServices {
43
44         function get_field_list($value,$fields,  $translate=true) {
45                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_field_list');
46                 $module_fields = array();
47                 $link_fields = array();
48                 if(!empty($value->field_defs)){
49
50                         foreach($value->field_defs as $var){
51                                 if(!empty($fields) && !in_array( $var['name'], $fields))continue;
52                                 if(isset($var['source']) && ($var['source'] != 'db' && $var['source'] != 'non-db' &&$var['source'] != 'custom_fields') && $var['name'] != 'email1' && $var['name'] != 'email2' && (!isset($var['type'])|| $var['type'] != 'relate'))continue;
53                                 if ($var['source'] == 'non_db' && (isset($var['type']) && $var['type'] != 'link')) {
54                                         continue;
55                                 }
56                                 $required = 0;
57                                 $options_dom = array();
58                                 $options_ret = array();
59                                 // Apparently the only purpose of this check is to make sure we only return fields
60                                 //   when we've read a record.  Otherwise this function is identical to get_module_field_list
61                                 if( isset($var['required']) && $var['required'] && $var['required'] !== 'false' ){
62                                         $required = 1;
63                                 }
64                                 if(isset($var['options'])){
65                                         $options_dom = translate($var['options'], $value->module_dir);
66                                         if(!is_array($options_dom)) $options_dom = array();
67                                         foreach($options_dom as $key=>$oneOption)
68                                                 $options_ret[$key] = $this->get_name_value($key,$oneOption);
69                                 }
70
71                     if(!empty($var['dbType']) && $var['type'] == 'bool') {
72                         $options_ret['type'] = $this->get_name_value('type', $var['dbType']);
73                     }
74
75                     $entry = array();
76                     $entry['name'] = $var['name'];
77                     $entry['type'] = $var['type'];
78                     if ($var['type'] == 'link') {
79                             $entry['relationship'] = (isset($var['relationship']) ? $var['relationship'] : '');
80                             $entry['module'] = (isset($var['module']) ? $var['module'] : '');
81                             $entry['bean_name'] = (isset($var['bean_name']) ? $var['bean_name'] : '');
82                                         $link_fields[$var['name']] = $entry;
83                     } else {
84                             if($translate) {
85                                 $entry['label'] = isset($var['vname']) ? translate($var['vname'], $value->module_dir) : $var['name'];
86                             } else {
87                                 $entry['label'] = isset($var['vname']) ? $var['vname'] : $var['name'];
88                             }
89                             $entry['required'] = $required;
90                             $entry['options'] = $options_ret;
91                                         if(isset($var['default'])) {
92                                            $entry['default_value'] = $var['default'];
93                                         }
94                                         $module_fields[$var['name']] = $entry;
95                     } // else
96                         } //foreach
97                 } //if
98
99                 if($value->module_dir == 'Bugs'){
100                         require_once('modules/Releases/Release.php');
101                         $seedRelease = new Release();
102                         $options = $seedRelease->get_releases(TRUE, "Active");
103                         $options_ret = array();
104                         foreach($options as $name=>$value){
105                                 $options_ret[] =  array('name'=> $name , 'value'=>$value);
106                         }
107                         if(isset($module_fields['fixed_in_release'])){
108                                 $module_fields['fixed_in_release']['type'] = 'enum';
109                                 $module_fields['fixed_in_release']['options'] = $options_ret;
110                         }
111                         if(isset($module_fields['release'])){
112                                 $module_fields['release']['type'] = 'enum';
113                                 $module_fields['release']['options'] = $options_ret;
114                         }
115                         if(isset($module_fields['release_name'])){
116                                 $module_fields['release_name']['type'] = 'enum';
117                                 $module_fields['release_name']['options'] = $options_ret;
118                         }
119                 }
120
121                 if(isset($value->assigned_user_name) && isset($module_fields['assigned_user_id'])) {
122                         $module_fields['assigned_user_name'] = $module_fields['assigned_user_id'];
123                         $module_fields['assigned_user_name']['name'] = 'assigned_user_name';
124                 }
125                 if(isset($module_fields['modified_user_id'])) {
126                         $module_fields['modified_by_name'] = $module_fields['modified_user_id'];
127                         $module_fields['modified_by_name']['name'] = 'modified_by_name';
128                 }
129                 if(isset($module_fields['created_by'])) {
130                         $module_fields['created_by_name'] = $module_fields['created_by'];
131                         $module_fields['created_by_name']['name'] = 'created_by_name';
132                 }
133
134                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_field_list');
135                 return array('module_fields' => $module_fields, 'link_fields' => $link_fields);
136         } // fn
137
138         function setFaultObject($errorObject) {
139                 if ($this->isLogLevelDebug()) {
140                         $GLOBALS['log']->debug('SoapHelperWebServices->setFaultObject - ' . var_export($errorObject, true));
141                 }
142                 global $service_object;
143                 $service_object->error($errorObject);
144         } // fn
145
146 /**
147  * Validate the user session based on user name and password hash.
148  *
149  * @param string $user_name -- The user name to create a session for
150  * @param string $password -- The MD5 sum of the user's password
151  * @return true -- If the session is created
152  * @return false -- If the session is not created
153  */
154 function validate_user($user_name, $password){
155         $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_user');
156         global $server, $current_user, $sugar_config, $system_config;
157         $user = new User();
158         $user->user_name = $user_name;
159         $system_config = new Administration();
160         $system_config->retrieveSettings('system');
161         $authController = new AuthenticationController((!empty($sugar_config['authenticationClass'])? $sugar_config['authenticationClass'] : 'SugarAuthenticate'));
162         // Check to see if the user name and password are consistent.
163         if($user->authenticate_user($password)){
164                 // we also need to set the current_user.
165                 $user->retrieve($user->id);
166                 $current_user = $user;
167
168                 $GLOBALS['log']->info('End: SoapHelperWebServices->validate_user - validation passed');
169                 return true;
170         }else if(function_exists('mcrypt_cbc')){
171                 $password = $this->decrypt_string($password);
172                 if($authController->login($user_name, $password) && isset($_SESSION['authenticated_user_id'])){
173                         $user->retrieve($_SESSION['authenticated_user_id']);
174                         $current_user = $user;
175                         $GLOBALS['log']->info('End: SoapHelperWebServices->validate_user - validation passed');
176                         return true;
177                 }
178         }else{
179                 $GLOBALS['log']->fatal("SECURITY: failed attempted login for $user_name using SOAP api");
180                 $server->setError("Invalid username and/or password");
181                 return false;
182         }
183
184 }
185
186         /**
187          * Validate the provided session information is correct and current.  Load the session.
188          *
189          * @param String $session_id -- The session ID that was returned by a call to login.
190          * @return true -- If the session is valid and loaded.
191          * @return false -- if the session is not valid.
192          */
193         function validate_authenticated($session_id){
194                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated');
195                 if(!empty($session_id)){
196                         session_id($session_id);
197                         session_start();
198                         if(!empty($_SESSION['is_valid_session']) && $this->is_valid_ip_address('ip_address') && $_SESSION['type'] == 'user'){
199
200                                 global $current_user;
201                                 require_once('modules/Users/User.php');
202                                 $current_user = new User();
203                                 $current_user->retrieve($_SESSION['user_id']);
204                                 $this->login_success();
205                                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated - passed');
206                                 $GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated');
207                                 return true;
208                         }
209
210                         $GLOBALS['log']->debug("calling destroy");
211                         session_destroy();
212                 }
213                 LogicHook::initialize();
214                 $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
215                 $GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated - validation failed');
216                 return false;
217         }
218
219         /**
220          * Use the same logic as in SugarAuthenticate to validate the ip address
221          *
222          * @param string $session_var
223          * @return bool - true if the ip address is valid, false otherwise.
224          */
225         function is_valid_ip_address($session_var){
226                 global $sugar_config;
227                 // grab client ip address
228                 $clientIP = query_client_ip();
229                 $classCheck = 0;
230                 // check to see if config entry is present, if not, verify client ip
231                 if (!isset ($sugar_config['verify_client_ip']) || $sugar_config['verify_client_ip'] == true) {
232                         // check to see if we've got a current ip address in $_SESSION
233                         // and check to see if the session has been hijacked by a foreign ip
234                         if (isset ($_SESSION[$session_var])) {
235                                 $session_parts = explode(".", $_SESSION[$session_var]);
236                                 $client_parts = explode(".", $clientIP);
237                     if(count($session_parts) < 4) {
238                         $classCheck = 0;
239                     }else {
240                                 // match class C IP addresses
241                                 for ($i = 0; $i < 3; $i ++) {
242                                         if ($session_parts[$i] == $client_parts[$i]) {
243                                                 $classCheck = 1;
244                                                         continue;
245                                         } else {
246                                                 $classCheck = 0;
247                                                 break;
248                                                 }
249                                         }
250                         }
251                                         // we have a different IP address
252                                         if ($_SESSION[$session_var] != $clientIP && empty ($classCheck)) {
253                                                 $GLOBALS['log']->fatal("IP Address mismatch: SESSION IP: {$_SESSION[$session_var]} CLIENT IP: {$clientIP}");
254                                                 return false;
255                                         }
256                                 } else {
257                                         return false;
258                                 }
259                 }
260                 return true;
261         }
262
263         function checkSessionAndModuleAccess($session, $login_error_key, $module_name, $access_level, $module_access_level_error_key, $errorObject) {
264                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->checkSessionAndModuleAccess');
265                 if(!$this->validate_authenticated($session)){
266                         $GLOBALS['log']->info('SoapHelperWebServices->checkSessionAndModuleAccess - validate_authenticated failed');
267                         $errorObject->set_error('invalid_session');
268                         $this->setFaultObject($errorObject);
269                         $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
270                         return false;
271                 } // if
272
273                 global  $beanList, $beanFiles;
274                 if (!empty($module_name)) {
275                         if(empty($beanList[$module_name])){
276                                 $GLOBALS['log']->info('SoapHelperWebServices->checkSessionAndModuleAccess - module does not exists - ' . $module_name);
277                                 $errorObject->set_error('no_module');
278                                 $this->setFaultObject($errorObject);
279                                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
280                                 return false;
281                         } // if
282                         global $current_user;
283                         if(!$this->check_modules_access($current_user, $module_name, $access_level)){
284                                 $GLOBALS['log']->info('SoapHelperWebServices->checkSessionAndModuleAccess - no module access - ' . $module_name);
285                                 $errorObject->set_error('no_access');
286                                 $this->setFaultObject($errorObject);
287                                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
288                                 return false;
289                         }
290                 } // if
291                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
292                 return true;
293         } // fn
294
295         function checkACLAccess($bean, $viewType, $errorObject, $error_key) {
296                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->checkACLAccess');
297                 if(!$bean->ACLAccess($viewType)) {
298                         $GLOBALS['log']->info('SoapHelperWebServices->checkACLAccess - no ACLAccess');
299                         $errorObject->set_error($error_key);
300                         $this->setFaultObject($errorObject);
301                         $GLOBALS['log']->info('End: SoapHelperWebServices->checkACLAccess');
302                         return false;
303                 } // if
304                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkACLAccess');
305                 return true;
306         } // fn
307
308         function get_name_value($field,$value){
309                 return array('name'=>$field, 'value'=>$value);
310         }
311
312         function get_user_module_list($user){
313                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_user_module_list');
314                 global $app_list_strings, $current_language;
315                 $app_list_strings = return_app_list_strings_language($current_language);
316                 $modules = query_module_access_list($user);
317                 ACLController :: filterModuleList($modules, false);
318                 global $modInvisList, $modInvisListActivities;
319
320                 foreach($modInvisList as $invis){
321                         $modules[$invis] = 'read_only';
322                 }
323
324                 if(isset($modules['Calendar']) || $modules['Activities']){
325                         foreach($modInvisListActivities as $invis){
326                                         $modules[$invis] = $invis;
327                         }
328                 }
329                 $actions = ACLAction::getUserActions($user->id,true);
330                 foreach($actions as $key=>$value){
331                         if(isset($value['module']) && $value['module']['access']['aclaccess'] < ACL_ALLOW_ENABLED){
332                                 if ($value['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED) {
333                                         unset($modules[$key]);
334                                 } else {
335                                         $modules[$key] = 'read_only';
336                                 } // else
337                         } else {
338                                 $modules[$key] = '';
339                         } // else
340                 } // foreach
341                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_user_module_list');
342                 return $modules;
343
344         }
345
346         function check_modules_access($user, $module_name, $action='write'){
347                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->check_modules_access');
348                 if(!isset($_SESSION['avail_modules'])){
349                         $_SESSION['avail_modules'] = $this->get_user_module_list($user);
350                 }
351                 if(isset($_SESSION['avail_modules'][$module_name])){
352                         if($action == 'write' && $_SESSION['avail_modules'][$module_name] == 'read_only'){
353                                 if(is_admin($user)) {
354                                         $GLOBALS['log']->info('End: SoapHelperWebServices->check_modules_access');
355                                         return true;
356                                 } // if
357                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_modules_access');
358                                 return false;
359                         }
360                         $GLOBALS['log']->info('End: SoapHelperWebServices->check_modules_access');
361                         return true;
362                 }
363                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_modules_access');
364                 return false;
365
366         }
367
368         function get_name_value_list(&$value){
369                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_name_value_list');
370                 global $app_list_strings;
371                 $list = array();
372                 if(!empty($value->field_defs)){
373                         if(isset($value->assigned_user_name)) {
374                                 $list['assigned_user_name'] = $this->get_name_value('assigned_user_name', $value->assigned_user_name);
375                         }
376                         if(isset($value->modified_by_name)) {
377                                 $list['modified_by_name'] = $this->get_name_value('modified_by_name', $value->modified_by_name);
378                         }
379                         if(isset($value->created_by_name)) {
380                                 $list['created_by_name'] = $this->get_name_value('created_by_name', $value->created_by_name);
381                         }
382                         foreach($value->field_defs as $var){
383                                 if(isset($var['source']) && ($var['source'] != 'db' && $var['source'] != 'custom_fields') && $var['name'] != 'email1' && $var['name'] != 'email2' && (!isset($var['type'])|| $var['type'] != 'relate'))continue;
384
385                                 if(isset($value->$var['name'])){
386                                         $val = $value->$var['name'];
387                                         $type = $var['type'];
388
389                                         if(strcmp($type, 'date') == 0){
390                                                 $val = substr($val, 0, 10);
391                                         }elseif(strcmp($type, 'enum') == 0 && !empty($var['options'])){
392                                                 //$val = $app_list_strings[$var['options']][$val];
393                                         }
394
395                                         $list[$var['name']] = $this->get_name_value($var['name'], $val);
396                                 }
397                         }
398                 }
399                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_name_value_list');
400                 return $list;
401
402         }
403
404         function filter_fields($value, $fields) {
405                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->filter_fields');
406                 global $invalid_contact_fields;
407                 $filterFields = array();
408                 foreach($fields as $field){
409                         if (is_array($invalid_contact_fields)) {
410                                 if (in_array($field, $invalid_contact_fields)) {
411                                         continue;
412                                 } // if
413                         } // if
414                         if (isset($value->field_defs[$field])) {
415                                 $var = $value->field_defs[$field];
416                                 if(isset($var['source']) && ($var['source'] != 'db' && $var['source'] != 'custom_fields') && $var['name'] != 'email1' && $var['name'] != 'email2' && (!isset($var['type'])|| $var['type'] != 'relate')) {
417
418                                         if($value->module_dir == 'Emails' && (($var['name'] == 'description') || ($var['name'] == 'description_html') || ($var['name'] == 'from_addr_name') || ($var['name'] == 'reply_to_addr') || ($var['name'] == 'to_addrs_names') || ($var['name'] == 'cc_addrs_names') || ($var['name'] == 'bcc_addrs_names') || ($var['name'] == 'raw_source'))) {
419
420                                         } else {
421                                                 continue;
422                                         }
423                                 }
424                         } // if
425                         $filterFields[] = $field;
426                 } // foreach
427                 $GLOBALS['log']->info('End: SoapHelperWebServices->filter_fields');
428                 return $filterFields;
429         } // fn
430
431         function get_name_value_list_for_fields($value, $fields) {
432                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_name_value_list_for_fields');
433                 global $app_list_strings;
434                 global $invalid_contact_fields;
435
436                 $list = array();
437                 if(!empty($value->field_defs)){
438                         if(empty($fields))$fields = array_keys($value->field_defs);
439                         if(isset($value->assigned_user_name) && in_array('assigned_user_name', $fields)) {
440                                 $list['assigned_user_name'] = $this->get_name_value('assigned_user_name', $value->assigned_user_name);
441                         }
442                         if(isset($value->modified_by_name) && in_array('modified_by_name', $fields)) {
443                                 $list['modified_by_name'] = $this->get_name_value('modified_by_name', $value->modified_by_name);
444                         }
445                         if(isset($value->created_by_name) && in_array('created_by_name', $fields)) {
446                                 $list['created_by_name'] = $this->get_name_value('created_by_name', $value->created_by_name);
447                         }
448
449                         $filterFields = $this->filter_fields($value, $fields);
450                         foreach($filterFields as $field){
451                                 $var = $value->field_defs[$field];
452                                 if(isset($value->$var['name'])){
453                                         $val = $value->$var['name'];
454                                         $type = $var['type'];
455
456                                         if(strcmp($type, 'date') == 0){
457                                                 $val = substr($val, 0, 10);
458                                         }elseif(strcmp($type, 'enum') == 0 && !empty($var['options'])){
459                                                 //$val = $app_list_strings[$var['options']][$val];
460                                         }
461
462                                         $list[$var['name']] = $this->get_name_value($var['name'], $val);
463                                 } // if
464                         } // foreach
465                 } // if
466                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_name_value_list_for_fields');
467                 if ($this->isLogLevelDebug()) {
468                         $GLOBALS['log']->debug('SoapHelperWebServices->get_name_value_list_for_fields - return data = ' . var_export($list, true));
469                 } // if
470                 return $list;
471
472         } // fn
473         
474         function array_get_name_value_list($array){
475                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->array_get_name_value_list');
476                 $list = array();
477                 foreach($array as $name=>$value){
478                         $list[$name] = $this->get_name_value($name, $value);
479                 }
480                 $GLOBALS['log']->info('End: SoapHelperWebServices->array_get_name_value_list');
481                 return $list;
482
483         }
484
485         function array_get_name_value_lists($array){
486                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->array_get_name_value_lists');
487             $list = array();
488             foreach($array as $name=>$value){
489                 $tmp_value=$value;
490                 if(is_array($value)){
491                     $tmp_value = array();
492                     foreach($value as $k=>$v){
493                         $tmp_value[$k] = $this->get_name_value($k, $v);
494                     }
495                 }
496                 $list[$name] = $this->get_name_value($name, $tmp_value);
497             }
498                 $GLOBALS['log']->info('End: SoapHelperWebServices->array_get_name_value_lists');
499             return $list;
500         }
501
502         function name_value_lists_get_array($list){
503                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->name_value_lists_get_array');
504             $array = array();
505             foreach($list as $key=>$value){
506                 if(isset($value['value']) && isset($value['name'])){
507                     if(is_array($value['value'])){
508                         $array[$value['name']]=array();
509                         foreach($value['value'] as $v){
510                             $array[$value['name']][$v['name']]=$v['value'];
511                         }
512                     }else{
513                         $array[$value['name']]=$value['value'];
514                     }
515                 }
516             }
517                 $GLOBALS['log']->info('End: SoapHelperWebServices->name_value_lists_get_array');
518             return $array;
519         }
520
521         function array_get_return_value($array, $module){
522
523                 $GLOBALS['log']->info('Begin/End: SoapHelperWebServices->array_get_return_value');
524                 return Array('id'=>$array['id'],
525                                         'module_name'=> $module,
526                                         'name_value_list'=>$this->array_get_name_value_list($array)
527                                         );
528         }
529
530         function get_return_value_for_fields($value, $module, $fields) {
531                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_return_value_for_fields');
532                 global $module_name, $current_user;
533                 $module_name = $module;
534                 if($module == 'Users' && $value->id != $current_user->id){
535                         $value->user_hash = '';
536                 }
537                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_return_value_for_fields');
538                 return Array('id'=>$value->id,
539                                         'module_name'=> $module,
540                                         'name_value_list'=>$this->get_name_value_list_for_fields($value, $fields)
541                                         );
542         }
543
544         function getRelationshipResults($bean, $link_field_name, $link_module_fields, $optional_where = '') {
545                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->getRelationshipResults');
546                 require_once('include/TimeDate.php');
547                 global  $beanList, $beanFiles, $current_user;
548                 global $disable_date_format;
549
550                 $bean->load_relationship($link_field_name);
551                 if (isset($bean->$link_field_name)) {
552                         // get the query object for this link field
553                         $query_array = $bean->$link_field_name->getQuery(true,array(),0,'',true);
554                         if (isset($query_array['where'])) {
555                                 $query_array['where'] = str_ireplace("where", "", $query_array['where']);
556                                 if (!empty($optional_where)) {
557                                         $optional_where = $query_array['where'] . " and " . $optional_where;
558                                 } else {
559                                         $optional_where = $query_array['where'];
560                                 } // else
561                         } // if
562
563                         $params = array();
564                         $params['joined_tables'] = $query_array['join_tables'];
565
566                         // get the related module name and instantiate a bean for that.
567                         $submodulename = $bean->$link_field_name->getRelatedModuleName();
568                         $submoduleclass = $beanList[$submodulename];
569                         require_once($beanFiles[$submoduleclass]);
570                         $submodule = new $submoduleclass();
571                         $filterFields = $this->filter_fields($submodule, $link_module_fields);
572                         $relFields = $bean->$link_field_name->getRelatedFields();
573                         $roleSelect = '';
574
575                         $idSetInSubModule = false;
576                         if($submodulename == 'Users' && !in_array('id', $link_module_fields)){
577                                 $link_module_fields[] = 'id';
578                                 $idSetInSubModule = true;
579                         }
580
581                         if(!empty($relFields)){
582                                 foreach($link_module_fields as $field){
583                                         if(!empty($relFields[$field])){
584                                                 $roleSelect .= ', ' . $query_array['join_tables'][0] . '.'. $field;
585                                         }
586                                 }
587                         }
588                         // create a query
589                         $subquery = $submodule->create_new_list_query('',$optional_where ,$filterFields,$params, 0,'', true,$bean);
590                         $query =  $subquery['select'].$roleSelect .   $subquery['from'].$query_array['join']. $subquery['where'];
591                         $GLOBALS['log']->info('SoapHelperWebServices->getRelationshipResults query = ' . $query);
592
593                         $result = $submodule->db->query($query, true);
594                         $list = array();
595                         while($row = $submodule->db->fetchByAssoc($result)) {
596                                 if (!$disable_date_format) {
597                                         foreach ($filterFields as $field) {
598                                                 if (isset($submodule->field_defs[$field]) &&
599                                                         isset($submodule->field_defs[$field]['type']) &&
600                                                         isset($row[$field])) {
601
602                                                                 if ($submodule->field_defs[$field]['type'] == 'date') {
603                                                                         global $timedate;
604                                                                         $row[$field] = $timedate->to_display_date_time($row[$field]);
605                                                                 }
606                                                                 if ($submodule->field_defs[$field]['type'] == 'currency') {
607                                                                         // TODO: convert data from db to user preferred format absed on the community input
608                                                                 } // if
609                                                 } // if
610
611                                         } // foreach
612                                 }
613                                 if($submodulename == 'Users' && $current_user->id != $row['id']) {
614                                         $row['user_hash'] = "";
615                                 } // if
616                                 if ($idSetInSubModule) {
617                                         unset($row['id']);
618                                 } // if
619                                 $list[] = $row;
620                         }
621                         $GLOBALS['log']->info('End: SoapHelperWebServices->getRelationshipResults');
622                         return array('rows' => $list, 'fields_set_on_rows' => $filterFields);
623                 } else {
624                         $GLOBALS['log']->info('End: SoapHelperWebServices->getRelationshipResults - ' . $link_field_name . ' relationship does not exists');
625                         return false;
626                 } // else
627
628         } // fn
629
630         function get_return_value_for_link_fields($bean, $module, $link_name_to_value_fields_array) {
631                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_return_value_for_link_fields');
632                 global $module_name, $current_user;
633                 $module_name = $module;
634                 if($module == 'Users' && $bean->id != $current_user->id){
635                         $bean->user_hash = '';
636                 }
637
638                 if (empty($link_name_to_value_fields_array) || !is_array($link_name_to_value_fields_array)) {
639                         $GLOBALS['log']->debug('End: SoapHelperWebServices->get_return_value_for_link_fields - Invalid link information passed ');
640                         return array();
641                 }
642
643                 if ($this->isLogLevelDebug()) {
644                         $GLOBALS['log']->debug('SoapHelperWebServices->get_return_value_for_link_fields - link info = ' . var_export($link_name_to_value_fields_array, true));
645                 } // if
646                 $link_output = array();
647                 foreach($link_name_to_value_fields_array as $link_name_value_fields) {
648                         if (!is_array($link_name_value_fields) || !isset($link_name_value_fields['name']) || !isset($link_name_value_fields['value'])) {
649                                 continue;
650                         }
651                         $link_field_name = $link_name_value_fields['name'];
652                         $link_module_fields = $link_name_value_fields['value'];
653                         if (is_array($link_module_fields) && !empty($link_module_fields)) {
654                                 $result = $this->getRelationshipResults($bean, $link_field_name, $link_module_fields);
655                                 if (!$result) {
656                                         $link_output[] = array('name' => $link_field_name, 'records' => array());
657                                         continue;
658                                 }
659                                 $list = $result['rows'];
660                                 $filterFields = $result['fields_set_on_rows'];
661                                 if ($list) {
662                                         $rowArray = array();
663                                         foreach($list as $row) {
664                                                 $nameValueArray = array();
665                                                 foreach ($filterFields as $field) {
666                                                         $nameValue = array();
667                                                         if (isset($row[$field])) {
668                                                                 $nameValueArray[$field] = $this->get_name_value($field, $row[$field]);
669                                                         } // if
670                                                 } // foreach
671                                                 $rowArray[] = $nameValueArray;
672                                         } // foreach
673                                         $link_output[] = array('name' => $link_field_name, 'records' => $rowArray);
674                                 } // if
675                         } // if
676                 } // foreach
677                 $GLOBALS['log']->debug('End: SoapHelperWebServices->get_return_value_for_link_fields');
678                 if ($this->isLogLevelDebug()) {
679                         $GLOBALS['log']->debug('SoapHelperWebServices->get_return_value_for_link_fields - output = ' . var_export($link_output, true));
680                 } // if
681                 return $link_output;
682         } // fn
683
684         /**
685          *
686          * @param String $module_name -- The name of the module that the primary record is from.  This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).
687          * @param String $module_id -- The ID of the bean in the specified module
688          * @param String $link_field_name - The relationship name for which to create realtionships.
689          * @param Array $related_ids -- The array of ids for which we want to create relationships
690          * @param Array $name_value_list -- The array of name value pair of additional attributes to be set when adding this relationship
691          * @param int delete -- If 0 then add relationship else delete this relationship data
692          * @return true on success, false on failure
693          */
694         function new_handle_set_relationship($module_name, $module_id, $link_field_name, $related_ids, $name_value_list, $delete) {
695                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->new_handle_set_relationship');
696             global  $beanList, $beanFiles;
697
698             if(empty($beanList[$module_name])) {
699                         $GLOBALS['log']->debug('SoapHelperWebServices->new_handle_set_relationship - module ' . $module_name . ' does not exists' );
700                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_relationship');
701                 return false;
702             } // if
703             $class_name = $beanList[$module_name];
704             require_once($beanFiles[$class_name]);
705             $mod = new $class_name();
706             $mod->retrieve($module_id);
707                 if(!$mod->ACLAccess('DetailView')){
708                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_relationship');
709                         return false;
710                 }
711
712                 if ($mod->load_relationship($link_field_name)) {
713                         if (!$delete) {
714                                 $name_value_pair = array();
715                                 if (!empty($name_value_list)) {
716                                         $relFields = $mod->$link_field_name->getRelatedFields();
717                                         if(!empty($relFields)){
718                                                 $relFieldsKeys = array_keys($relFields);
719                                                 foreach($name_value_list as $key => $value) {
720                                                         if (in_array($value['name'], $relFieldsKeys)) {
721                                                                 $name_value_pair[$value['name']] = $value['value'];
722                                                         } // if
723                                                 } // foreach
724                                         } // if
725                                 }
726                                 $mod->$link_field_name->add($related_ids, $name_value_pair);
727                         } else {
728                                 foreach($related_ids as $id) {
729                                         $mod->$link_field_name->delete($module_id, $id);
730                                 } // foreach
731                         } // else
732                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_relationship');
733                         return true;
734                 } else {
735                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_relationship');
736                         return false;
737                 }
738         }
739
740         function new_handle_set_entries($module_name, $name_value_lists, $select_fields = FALSE) {
741                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->new_handle_set_entries');
742                 global $beanList, $beanFiles, $current_user;
743
744                 $ret_values = array();
745
746                 global $current_user;
747                 $class_name = $beanList[$module_name];
748                 require_once($beanFiles[$class_name]);
749                 $ids = array();
750                 $count = 1;
751                 $total = sizeof($name_value_lists);
752                 foreach($name_value_lists as $name_value_list){
753                         $seed = new $class_name();
754
755                         $seed->update_vcal = false;
756                         foreach($name_value_list as $value){
757                                 if($value['name'] == 'id'){
758                                         $seed->retrieve($value['value']);
759                                         break;
760                                 }
761                         }
762
763                         foreach($name_value_list as $value) {
764                                 $val = $value['value'];
765                                 if($seed->field_name_map[$value['name']]['type'] == 'enum'){
766                                         $vardef = $seed->field_name_map[$value['name']];
767                                         if(isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value]) ) {
768                                                 if ( in_array($val,$app_list_strings[$vardef['options']]) ){
769                                                         $val = array_search($val,$app_list_strings[$vardef['options']]);
770                                                 }
771                                         }
772                                 }
773                                 if($module_name == 'Users' && !empty($seed->id) && ($seed->id != $current_user->id) && $value['name'] == 'user_hash'){
774                                         continue;
775                                 }
776
777                                 $seed->$value['name'] = $val;
778                         }
779
780                         if($count == $total){
781                                 $seed->update_vcal = false;
782                         }
783                         $count++;
784
785                         //Add the account to a contact
786                         if($module_name == 'Contacts'){
787                                 $GLOBALS['log']->debug('Creating Contact Account');
788                                 $this->add_create_account($seed);
789                                 $duplicate_id = $this->check_for_duplicate_contacts($seed);
790                                 if($duplicate_id == null){
791                                         if($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))){
792                                                 $seed->save();
793                                                 if($seed->deleted == 1){
794                                                         $seed->mark_deleted($seed->id);
795                                                 }
796                                                 $ids[] = $seed->id;
797                                         }
798                                 }
799                                 else{
800                                         //since we found a duplicate we should set the sync flag
801                                         if( $seed->ACLAccess('Save')){
802                                                 $seed = new $class_name();
803                                                 $seed->id = $duplicate_id;
804                                                 $seed->contacts_users_id = $current_user->id;
805                                                 $seed->save();
806                                                 $ids[] = $duplicate_id;//we have a conflict
807                                         }
808                                 }
809                         }
810                         else if($module_name == 'Meetings' || $module_name == 'Calls'){
811                                 //we are going to check if we have a meeting in the system
812                                 //with the same outlook_id. If we do find one then we will grab that
813                                 //id and save it
814                                 if( $seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))){
815                                         if(empty($seed->id) && !isset($seed->id)){
816                                                 if(!empty($seed->outlook_id) && isset($seed->outlook_id)){
817                                                         //at this point we have an object that does not have
818                                                         //the id set, but does have the outlook_id set
819                                                         //so we need to query the db to find if we already
820                                                         //have an object with this outlook_id, if we do
821                                                         //then we can set the id, otherwise this is a new object
822                                                         $order_by = "";
823                                                         $query = $seed->table_name.".outlook_id = '".$seed->outlook_id."'";
824                                                         $response = $seed->get_list($order_by, $query, 0,-1,-1,0);
825                                                         $list = $response['list'];
826                                                         if(count($list) > 0){
827                                                                 foreach($list as $value)
828                                                                 {
829                                                                         $seed->id = $value->id;
830                                                                         break;
831                                                                 }
832                                                         }//fi
833                                                 }//fi
834                                         }//fi
835                                     if (empty($seed->reminder_time)) {
836                         $seed->reminder_time = -1;
837                     }
838                     if($seed->reminder_time == -1){
839                         $defaultRemindrTime = $current_user->getPreference('reminder_time');
840                         if ($defaultRemindrTime != -1){
841                             $seed->reminder_checked = '1';
842                             $seed->reminder_time = $defaultRemindrTime;
843                         }
844                     }
845                                         $seed->save();
846                                         $ids[] = $seed->id;
847                                 }//fi
848                         }
849                         else
850                         {
851                                 if( $seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))){
852                                         $seed->save();
853                                         $ids[] = $seed->id;
854                                 }
855                         }
856
857                         // if somebody is calling set_entries_detail() and wants fields returned...
858                         if ($select_fields !== FALSE) {
859                                 $ret_values[$count] = array();
860
861                                 foreach ($select_fields as $select_field) {
862                                         if (isset($seed->$select_field)) {
863                                                 $ret_values[$count][$select_field] = $this->get_name_value($select_field, $seed->$select_field);
864                                         }
865                                 }
866                         }
867                 }
868
869                 // handle returns for set_entries_detail() and set_entries()
870                 if ($select_fields !== FALSE) {
871                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_entries');
872                         return array(
873                                 'name_value_lists' => $ret_values,
874                         );
875                 }
876                 else {
877                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_entries');
878                         return array(
879                                 'ids' => $ids,
880                         );
881                 }
882         }
883
884         function get_return_value(&$value, $module){
885                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_return_value');
886                 global $module_name, $current_user;
887                 $module_name = $module;
888                 if($module == 'Users' && $value->id != $current_user->id){
889                         $value->user_hash = '';
890                 }
891                 $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_entries');
892                 return Array('id'=>$value->id,
893                                         'module_name'=> $module,
894                                         'name_value_list'=>$this->get_name_value_list($value)
895                                         );
896         }
897
898
899         function get_return_module_fields($value, $module,$fields, $translate=true){
900                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_return_module_fields');
901                 global $module_name;
902                 $module_name = $module;
903                 $result = $this->get_field_list($value,$fields,  $translate);
904                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_return_module_fields');
905                 return Array('module_name'=>$module,
906                                         'module_fields'=> $result['module_fields'],
907                                         'link_fields'=> $result['link_fields'],
908                                         );
909         } // fn
910
911         function login_success($name_value_list = array()){
912                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->login_success');
913                 global $current_language, $sugar_config, $app_strings, $app_list_strings;
914                 $current_language = $sugar_config['default_language'];
915                 if (is_array($name_value_list) && !empty($name_value_list)) {
916                         foreach($name_value_list as $key => $value) {
917                                 if (isset($value['name']) && ($value['name'] == 'language')) {
918                                         $language = $value['value'];
919                                         $supportedLanguages = $sugar_config['languages'];
920                                         if (array_key_exists($language, $supportedLanguages)) {
921                                                 $current_language = $language;
922                                         } // if
923                                 } // if
924                                 if (isset($value['name']) && ($value['name'] == 'notifyonsave')) {
925                                         if ($value['value']) {
926                                                 $_SESSION['notifyonsave'] = true;
927                                         }
928                                 } // if
929                         } // foreach
930                 } else {
931                         if (isset($_SESSION['user_language'])) {
932                                 $current_language = $_SESSION['user_language'];
933                         } // if
934                 }
935                 $GLOBALS['log']->info("Users language is = " . $current_language);
936                 $app_strings = return_application_language($current_language);
937                 $app_list_strings = return_app_list_strings_language($current_language);
938                 $GLOBALS['log']->info('End: SoapHelperWebServices->login_success');
939         } // fn
940
941
942         function checkSaveOnNotify() {
943             $notifyonsave = false;
944             if (isset($_SESSION['notifyonsave']) && $_SESSION['notifyonsave'] == true) {
945                 $notifyonsave = true;
946             } // if
947                 return $notifyonsave;
948         }
949         /*
950          *      Given an account_name, either create the account or assign to a contact.
951          */
952         function add_create_account($seed) {
953                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->add_create_account');
954                 global $current_user;
955                 $account_name = $seed->account_name;
956                 $account_id = $seed->account_id;
957                 $assigned_user_id = $current_user->id;
958
959                 // check if it already exists
960             $focus = new Account();
961             if($focus->ACLAccess('Save')) {
962                         $class = get_class($seed);
963                         $temp = new $class();
964                         $temp->retrieve($seed->id);
965                         if ((!isset($account_name) || $account_name == '')) {
966                                 return;
967                         } // if
968                         if (!isset($seed->accounts)){
969                             $seed->load_relationship('accounts');
970                         } // if
971
972                         if($seed->account_name = '' && isset($temp->account_id)){
973                                 $seed->accounts->delete($seed->id, $temp->account_id);
974                                 $GLOBALS['log']->info('End: SoapHelperWebServices->add_create_account');
975                                 return;
976                         }
977                     $arr = array();
978
979                     $query = "select id, deleted from {$focus->table_name} WHERE name='".$seed->db->quote($account_name)."'";
980                     $result = $seed->db->query($query) or sugar_die("Error selecting sugarbean: ".mysql_error());
981
982                     $row = $seed->db->fetchByAssoc($result, -1, false);
983
984                         // we found a row with that id
985                     if (isset($row['id']) && $row['id'] != -1)
986                     {
987                         // if it exists but was deleted, just remove it entirely
988                         if ( isset($row['deleted']) && $row['deleted'] == 1)
989                         {
990                             $query2 = "delete from {$focus->table_name} WHERE id='". $seed->db->quote($row['id'])."'";
991                             $result2 = $seed->db->query($query2) or sugar_die("Error deleting existing sugarbean: ".mysql_error());
992                                 }
993                                 // else just use this id to link the contact to the account
994                         else
995                         {
996                                 $focus->id = $row['id'];
997                         }
998                     }
999
1000                         // if we didnt find the account, so create it
1001                     if (! isset($focus->id) || $focus->id == '')
1002                     {
1003                         $focus->name = $account_name;
1004
1005                                 if ( isset($assigned_user_id))
1006                                 {
1007                            $focus->assigned_user_id = $assigned_user_id;
1008                            $focus->modified_user_id = $assigned_user_id;
1009                                 }
1010                         $focus->save();
1011                     }
1012
1013                     if($seed->accounts != null && $temp->account_id != null && $temp->account_id != $focus->id){
1014                         $seed->accounts->delete($seed->id, $temp->account_id);
1015                     }
1016
1017                     if(isset($focus->id) && $focus->id != ''){
1018                                 $seed->account_id = $focus->id;
1019                         } // if
1020                         $GLOBALS['log']->info('End: SoapHelperWebServices->add_create_account');
1021
1022             } else {
1023                         $GLOBALS['log']->info('End: SoapHelperWebServices->add_create_account - Insufficient ACLAccess');
1024             } // else
1025         } // fn
1026
1027         function check_for_duplicate_contacts(&$seed){
1028                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->check_for_duplicate_contacts');
1029                 require_once('modules/Contacts/Contact.php');
1030
1031                 if(isset($seed->id)){
1032                         $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1033                         return null;
1034                 }
1035
1036                 $query = '';
1037
1038                 $trimmed_email = trim($seed->email1);
1039                 $trimmed_last = trim($seed->last_name);
1040                 $trimmed_first = trim($seed->first_name);
1041                 if(!empty($trimmed_email)){
1042
1043                         //obtain a list of contacts which contain the same email address
1044                         $contacts = $seed->emailAddress->getBeansByEmailAddress($trimmed_email);
1045                         if(count($contacts) == 0){
1046                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1047                                 return null;
1048                         }else{
1049                                 foreach($contacts as $contact){
1050                                         if(!empty($trimmed_last) && strcmp($trimmed_last, $contact->last_name) == 0){
1051                                                 if(!empty($trimmed_email) && strcmp($trimmed_email, $contact->email1) == 0){
1052                                                         if(!empty($trimmed_email)){
1053                                                                 if(strcmp($trimmed_email, $contact->email1) == 0){
1054                                                                         //bug: 39234 - check if the account names are the same
1055                                                                         //if the incoming contact's account_name is empty OR it is not empty and is the same
1056                                                                         //as an existing contact's account name, then find the match.
1057                                                                         $contact->load_relationship('accounts');
1058                                                                         if(empty($seed->account_name) || strcmp($seed->account_name, $contact->account_name) == 0){
1059                                                                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - duplicte found ' . $contact->id);
1060                                                                                 return $contact->id;
1061                                                                         }
1062                                                                 }
1063                                                         }else{
1064                                                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - duplicte found' . $contact->id);
1065                                                                 return $contact->id;
1066                                                         }
1067                                                 }
1068                                         }
1069                                 }
1070                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1071                                 return null;
1072                         }
1073                 }else
1074                         $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1075                         return null;
1076         }
1077
1078
1079         /**
1080          * decrypt a string use the TripleDES algorithm. This meant to be
1081          * modified if the end user chooses a different algorithm
1082          *
1083          * @param $string - the string to decrypt
1084          *
1085          * @return a decrypted string if we can decrypt, the original string otherwise
1086          */
1087         function decrypt_string($string){
1088                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->decrypt_string');
1089                 if(function_exists('mcrypt_cbc')){
1090                         require_once('modules/Administration/Administration.php');
1091                         $focus = new Administration();
1092                         $focus->retrieveSettings();
1093                         $key = '';
1094                         if(!empty($focus->settings['ldap_enc_key'])){
1095                                 $key = $focus->settings['ldap_enc_key'];
1096                         }
1097                         if(empty($key)) {
1098                                 $GLOBALS['log']->info('End: SoapHelperWebServices->decrypt_string - empty key');
1099                                 return $string;
1100                         } // if
1101                         $buffer = $string;
1102                         $key = substr(md5($key),0,24);
1103                     $iv = "password";
1104                         $GLOBALS['log']->info('End: SoapHelperWebServices->decrypt_string');
1105                     return mcrypt_cbc(MCRYPT_3DES, $key, pack("H*", $buffer), MCRYPT_DECRYPT, $iv);
1106                 }else{
1107                         $GLOBALS['log']->info('End: SoapHelperWebServices->decrypt_string');
1108                         return $string;
1109                 }
1110         } // fn
1111
1112         function isLogLevelDebug() {
1113                 if (isset($GLOBALS['sugar_config']['logger'])) {
1114                         if (isset($GLOBALS['sugar_config']['logger']['level'])) {
1115                                 return ($GLOBALS['sugar_config']['logger']['level'] == 'debug');
1116                         } // if
1117                 }
1118                 return false;
1119         } // fn
1120 } // clazz
1121
1122 ?>