]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - service/core/SoapHelperWebService.php
Release 6.2.2
[Github/sugarcrm.git] / service / core / SoapHelperWebService.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-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         {
46                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_field_list');
47                 $module_fields = array();
48                 $link_fields = array();
49                 if(!empty($value->field_defs)){
50
51                         foreach($value->field_defs as $var){
52                                 if(!empty($fields) && !in_array( $var['name'], $fields))continue;
53                                 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;
54                                 if ($var['source'] == 'non_db' && (isset($var['type']) && $var['type'] != 'link')) {
55                                         continue;
56                                 }
57                                 $required = 0;
58                                 $options_dom = array();
59                                 $options_ret = array();
60                                 // Apparently the only purpose of this check is to make sure we only return fields
61                                 //   when we've read a record.  Otherwise this function is identical to get_module_field_list
62
63                                 if( isset($var['required']) && $var['required'] && $var['required'] !== 'false' ){
64                                         $required = 1;
65                                 }
66                                 if(isset($var['options'])){
67                                         $options_dom = translate($var['options'], $value->module_dir);
68                                         if(!is_array($options_dom)) $options_dom = array();
69                                         foreach($options_dom as $key=>$oneOption)
70                                                 $options_ret[$key] = $this->get_name_value($key,$oneOption);
71                                 }
72
73                     if(!empty($var['dbType']) && $var['type'] == 'bool') {
74                         $options_ret['type'] = $this->get_name_value('type', $var['dbType']);
75                     }
76
77                     $entry = array();
78                     $entry['name'] = $var['name'];
79                     $entry['type'] = $var['type'];
80                     if ($var['type'] == 'link') {
81                             $entry['relationship'] = (isset($var['relationship']) ? $var['relationship'] : '');
82                             $entry['module'] = (isset($var['module']) ? $var['module'] : '');
83                             $entry['bean_name'] = (isset($var['bean_name']) ? $var['bean_name'] : '');
84                                         $link_fields[$var['name']] = $entry;
85                     } else {
86                             if($translate) {
87                                 $entry['label'] = isset($var['vname']) ? translate($var['vname'], $value->module_dir) : $var['name'];
88                             } else {
89                                 $entry['label'] = isset($var['vname']) ? $var['vname'] : $var['name'];
90                             }
91                             $entry['required'] = $required;
92                             $entry['options'] = $options_ret;
93                                         if(isset($var['default'])) {
94                                            $entry['default_value'] = $var['default'];
95                                         }
96                                         $module_fields[$var['name']] = $entry;
97                     } // else
98                         } //foreach
99                 } //if
100
101                 if($value->module_dir == 'Bugs'){
102                         require_once('modules/Releases/Release.php');
103                         $seedRelease = new Release();
104                         $options = $seedRelease->get_releases(TRUE, "Active");
105                         $options_ret = array();
106                         foreach($options as $name=>$value){
107                                 $options_ret[] =  array('name'=> $name , 'value'=>$value);
108                         }
109                         if(isset($module_fields['fixed_in_release'])){
110                                 $module_fields['fixed_in_release']['type'] = 'enum';
111                                 $module_fields['fixed_in_release']['options'] = $options_ret;
112                         }
113                         if(isset($module_fields['release'])){
114                                 $module_fields['release']['type'] = 'enum';
115                                 $module_fields['release']['options'] = $options_ret;
116                         }
117                         if(isset($module_fields['release_name'])){
118                                 $module_fields['release_name']['type'] = 'enum';
119                                 $module_fields['release_name']['options'] = $options_ret;
120                         }
121                 }
122
123                 if(isset($value->assigned_user_name) && isset($module_fields['assigned_user_id'])) {
124                         $module_fields['assigned_user_name'] = $module_fields['assigned_user_id'];
125                         $module_fields['assigned_user_name']['name'] = 'assigned_user_name';
126                 }
127                 if(isset($module_fields['modified_user_id'])) {
128                         $module_fields['modified_by_name'] = $module_fields['modified_user_id'];
129                         $module_fields['modified_by_name']['name'] = 'modified_by_name';
130                 }
131                 if(isset($module_fields['created_by'])) {
132                         $module_fields['created_by_name'] = $module_fields['created_by'];
133                         $module_fields['created_by_name']['name'] = 'created_by_name';
134                 }
135
136                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_field_list');
137                 return array('module_fields' => $module_fields, 'link_fields' => $link_fields);
138         } // fn
139
140         function setFaultObject($errorObject) {
141                 if ($this->isLogLevelDebug()) {
142                         $GLOBALS['log']->debug('SoapHelperWebServices->setFaultObject - ' . var_export($errorObject, true));
143                 }
144                 global $service_object;
145                 $service_object->error($errorObject);
146         } // fn
147
148 /**
149  * Validate the user session based on user name and password hash.
150  *
151  * @param string $user_name -- The user name to create a session for
152  * @param string $password -- The MD5 sum of the user's password
153  * @return true -- If the session is created
154  * @return false -- If the session is not created
155  */
156 function validate_user($user_name, $password){
157         $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_user');
158         global $server, $current_user, $sugar_config, $system_config;
159         $user = new User();
160         $user->user_name = $user_name;
161         $system_config = new Administration();
162         $system_config->retrieveSettings('system');
163         $authController = new AuthenticationController((!empty($sugar_config['authenticationClass'])? $sugar_config['authenticationClass'] : 'SugarAuthenticate'));
164         // Check to see if the user name and password are consistent.
165         if($user->authenticate_user($password)){
166                 // we also need to set the current_user.
167                 $user->retrieve($user->id);
168                 $current_user = $user;
169
170                 $GLOBALS['log']->info('End: SoapHelperWebServices->validate_user - validation passed');
171                 return true;
172         }else if(function_exists('mcrypt_cbc')){
173                 $password = $this->decrypt_string($password);
174                 if($authController->login($user_name, $password) && isset($_SESSION['authenticated_user_id'])){
175                         $user->retrieve($_SESSION['authenticated_user_id']);
176                         $current_user = $user;
177                         $GLOBALS['log']->info('End: SoapHelperWebServices->validate_user - validation passed');
178                         return true;
179                 }
180         }else{
181                 $GLOBALS['log']->fatal("SECURITY: failed attempted login for $user_name using SOAP api");
182                 $server->setError("Invalid username and/or password");
183                 return false;
184         }
185
186 }
187
188         /**
189          * Validate the provided session information is correct and current.  Load the session.
190          *
191          * @param String $session_id -- The session ID that was returned by a call to login.
192          * @return true -- If the session is valid and loaded.
193          * @return false -- if the session is not valid.
194          */
195         function validate_authenticated($session_id){
196                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated');
197                 if(!empty($session_id)){
198                         session_id($session_id);
199                         session_start();
200                         if(!empty($_SESSION['is_valid_session']) && $this->is_valid_ip_address('ip_address') && $_SESSION['type'] == 'user'){
201
202                                 global $current_user;
203                                 require_once('modules/Users/User.php');
204                                 $current_user = new User();
205                                 $current_user->retrieve($_SESSION['user_id']);
206                                 $this->login_success();
207                                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated - passed');
208                                 $GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated');
209                                 return true;
210                         }
211
212                         $GLOBALS['log']->debug("calling destroy");
213                         session_destroy();
214                 }
215                 LogicHook::initialize();
216                 $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
217                 $GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated - validation failed');
218                 return false;
219         }
220
221         /**
222          * Use the same logic as in SugarAuthenticate to validate the ip address
223          *
224          * @param string $session_var
225          * @return bool - true if the ip address is valid, false otherwise.
226          */
227         function is_valid_ip_address($session_var){
228                 global $sugar_config;
229                 // grab client ip address
230                 $clientIP = query_client_ip();
231                 $classCheck = 0;
232                 // check to see if config entry is present, if not, verify client ip
233                 if (!isset ($sugar_config['verify_client_ip']) || $sugar_config['verify_client_ip'] == true) {
234                         // check to see if we've got a current ip address in $_SESSION
235                         // and check to see if the session has been hijacked by a foreign ip
236                         if (isset ($_SESSION[$session_var])) {
237                                 $session_parts = explode(".", $_SESSION[$session_var]);
238                                 $client_parts = explode(".", $clientIP);
239                     if(count($session_parts) < 4) {
240                         $classCheck = 0;
241                     }else {
242                                 // match class C IP addresses
243                                 for ($i = 0; $i < 3; $i ++) {
244                                         if ($session_parts[$i] == $client_parts[$i]) {
245                                                 $classCheck = 1;
246                                                         continue;
247                                         } else {
248                                                 $classCheck = 0;
249                                                 break;
250                                                 }
251                                         }
252                         }
253                                         // we have a different IP address
254                                         if ($_SESSION[$session_var] != $clientIP && empty ($classCheck)) {
255                                                 $GLOBALS['log']->fatal("IP Address mismatch: SESSION IP: {$_SESSION[$session_var]} CLIENT IP: {$clientIP}");
256                                                 return false;
257                                         }
258                                 } else {
259                                         return false;
260                                 }
261                 }
262                 return true;
263         }
264
265         function checkSessionAndModuleAccess($session, $login_error_key, $module_name, $access_level, $module_access_level_error_key, $errorObject) {
266                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->checkSessionAndModuleAccess');
267                 if(!$this->validate_authenticated($session)){
268                         $GLOBALS['log']->info('SoapHelperWebServices->checkSessionAndModuleAccess - validate_authenticated failed');
269                         $errorObject->set_error('invalid_session');
270                         $this->setFaultObject($errorObject);
271                         $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
272                         return false;
273                 } // if
274
275                 global  $beanList, $beanFiles;
276                 if (!empty($module_name)) {
277                         if(empty($beanList[$module_name])){
278                                 $GLOBALS['log']->info('SoapHelperWebServices->checkSessionAndModuleAccess - module does not exists - ' . $module_name);
279                                 $errorObject->set_error('no_module');
280                                 $this->setFaultObject($errorObject);
281                                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
282                                 return false;
283                         } // if
284                         global $current_user;
285                         if(!$this->check_modules_access($current_user, $module_name, $access_level)){
286                                 $GLOBALS['log']->info('SoapHelperWebServices->checkSessionAndModuleAccess - no module access - ' . $module_name);
287                                 $errorObject->set_error('no_access');
288                                 $this->setFaultObject($errorObject);
289                                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
290                                 return false;
291                         }
292                 } // if
293                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkSessionAndModuleAccess');
294                 return true;
295         } // fn
296
297         function checkACLAccess($bean, $viewType, $errorObject, $error_key) {
298                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->checkACLAccess');
299                 if(!$bean->ACLAccess($viewType)) {
300                         $GLOBALS['log']->info('SoapHelperWebServices->checkACLAccess - no ACLAccess');
301                         $errorObject->set_error($error_key);
302                         $this->setFaultObject($errorObject);
303                         $GLOBALS['log']->info('End: SoapHelperWebServices->checkACLAccess');
304                         return false;
305                 } // if
306                 $GLOBALS['log']->info('End: SoapHelperWebServices->checkACLAccess');
307                 return true;
308         } // fn
309
310         function get_name_value($field,$value){
311                 return array('name'=>$field, 'value'=>$value);
312         }
313
314         function get_user_module_list($user){
315                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_user_module_list');
316                 global $app_list_strings, $current_language;
317                 $app_list_strings = return_app_list_strings_language($current_language);
318                 $modules = query_module_access_list($user);
319                 ACLController :: filterModuleList($modules, false);
320                 global $modInvisList;
321
322                 foreach($modInvisList as $invis){
323                         $modules[$invis] = 'read_only';
324                 }
325
326                 $actions = ACLAction::getUserActions($user->id,true);
327                 foreach($actions as $key=>$value){
328                         if(isset($value['module']) && $value['module']['access']['aclaccess'] < ACL_ALLOW_ENABLED){
329                                 if ($value['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED) {
330                                         unset($modules[$key]);
331                                 } else {
332                                         $modules[$key] = 'read_only';
333                                 } // else
334                         } else {
335                                 $modules[$key] = '';
336                         } // else
337                 } // foreach
338                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_user_module_list');
339                 return $modules;
340
341         }
342
343         function check_modules_access($user, $module_name, $action='write'){
344                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->check_modules_access');
345                 if(!isset($_SESSION['avail_modules'])){
346                         $_SESSION['avail_modules'] = $this->get_user_module_list($user);
347                 }
348                 if(isset($_SESSION['avail_modules'][$module_name])){
349                         if($action == 'write' && $_SESSION['avail_modules'][$module_name] == 'read_only'){
350                                 if(is_admin($user)) {
351                                         $GLOBALS['log']->info('End: SoapHelperWebServices->check_modules_access');
352                                         return true;
353                                 } // if
354                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_modules_access');
355                                 return false;
356                         }elseif($action == 'write' && strcmp(strtolower($module_name), 'users') == 0 && !$user->isAdminForModule($module_name)){
357                  //rrs bug: 46000 - If the client is trying to write to the Users module and is not an admin then we need to stop them
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, $app_list_strings;
743
744                 $ret_values = array();
745
746                 $class_name = $beanList[$module_name];
747                 require_once($beanFiles[$class_name]);
748                 $ids = array();
749                 $count = 1;
750                 $total = sizeof($name_value_lists);
751                 foreach($name_value_lists as $name_value_list){
752                         $seed = new $class_name();
753
754                         $seed->update_vcal = false;
755                         foreach($name_value_list as $value){
756                                 if($value['name'] == 'id'){
757                                         $seed->retrieve($value['value']);
758                                         break;
759                                 }
760                         }
761
762                         foreach($name_value_list as $value) {
763                                 $val = $value['value'];
764                                 if($seed->field_name_map[$value['name']]['type'] == 'enum'){
765                                         $vardef = $seed->field_name_map[$value['name']];
766                                         if(isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value]) ) {
767                                                 if ( in_array($val,$app_list_strings[$vardef['options']]) ){
768                                                         $val = array_search($val,$app_list_strings[$vardef['options']]);
769                                                 }
770                                         }
771                                 }
772                                 if($module_name == 'Users' && !empty($seed->id) && ($seed->id != $current_user->id) && $value['name'] == 'user_hash'){
773                                         continue;
774                                 }
775
776                                 $seed->$value['name'] = $val;
777                         }
778
779                         if($count == $total){
780                                 $seed->update_vcal = false;
781                         }
782                         $count++;
783
784                         //Add the account to a contact
785                         if($module_name == 'Contacts'){
786                                 $GLOBALS['log']->debug('Creating Contact Account');
787                                 $this->add_create_account($seed);
788                                 $duplicate_id = $this->check_for_duplicate_contacts($seed);
789                                 if($duplicate_id == null){
790                                         if($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))){
791                                                 $seed->save();
792                                                 if($seed->deleted == 1){
793                                                         $seed->mark_deleted($seed->id);
794                                                 }
795                                                 $ids[] = $seed->id;
796                                         }
797                                 }
798                                 else{
799                                         //since we found a duplicate we should set the sync flag
800                                         if( $seed->ACLAccess('Save')){
801                                                 $seed = new $class_name();
802                                                 $seed->id = $duplicate_id;
803                                                 $seed->contacts_users_id = $current_user->id;
804                                                 $seed->save();
805                                                 $ids[] = $duplicate_id;//we have a conflict
806                                         }
807                                 }
808                         }
809                         else if($module_name == 'Meetings' || $module_name == 'Calls'){
810                                 //we are going to check if we have a meeting in the system
811                                 //with the same outlook_id. If we do find one then we will grab that
812                                 //id and save it
813                                 if( $seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))){
814                                         if(empty($seed->id) && !isset($seed->id)){
815                                                 if(!empty($seed->outlook_id) && isset($seed->outlook_id)){
816                                                         //at this point we have an object that does not have
817                                                         //the id set, but does have the outlook_id set
818                                                         //so we need to query the db to find if we already
819                                                         //have an object with this outlook_id, if we do
820                                                         //then we can set the id, otherwise this is a new object
821                                                         $order_by = "";
822                                                         $query = $seed->table_name.".outlook_id = '".$seed->outlook_id."'";
823                                                         $response = $seed->get_list($order_by, $query, 0,-1,-1,0);
824                                                         $list = $response['list'];
825                                                         if(count($list) > 0){
826                                                                 foreach($list as $value)
827                                                                 {
828                                                                         $seed->id = $value->id;
829                                                                         break;
830                                                                 }
831                                                         }//fi
832                                                 }//fi
833                                         }//fi
834                                     if (empty($seed->reminder_time)) {
835                         $seed->reminder_time = -1;
836                     }
837                     if($seed->reminder_time == -1){
838                         $defaultRemindrTime = $current_user->getPreference('reminder_time');
839                         if ($defaultRemindrTime != -1){
840                             $seed->reminder_checked = '1';
841                             $seed->reminder_time = $defaultRemindrTime;
842                         }
843                     }
844                                         $seed->save();
845                                         $ids[] = $seed->id;
846                                 }//fi
847                         }
848                         else
849                         {
850                                 if( $seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))){
851                                         $seed->save();
852                                         $ids[] = $seed->id;
853                                 }
854                         }
855
856                         // if somebody is calling set_entries_detail() and wants fields returned...
857                         if ($select_fields !== FALSE) {
858                                 $ret_values[$count] = array();
859
860                                 foreach ($select_fields as $select_field) {
861                                         if (isset($seed->$select_field)) {
862                                                 $ret_values[$count][$select_field] = $this->get_name_value($select_field, $seed->$select_field);
863                                         }
864                                 }
865                         }
866                 }
867
868                 // handle returns for set_entries_detail() and set_entries()
869                 if ($select_fields !== FALSE) {
870                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_entries');
871                         return array(
872                                 'name_value_lists' => $ret_values,
873                         );
874                 }
875                 else {
876                         $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_entries');
877                         return array(
878                                 'ids' => $ids,
879                         );
880                 }
881         }
882
883         function get_return_value($value, $module){
884                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_return_value');
885                 global $module_name, $current_user;
886                 $module_name = $module;
887                 if($module == 'Users' && $value->id != $current_user->id){
888                         $value->user_hash = '';
889                 }
890                 $GLOBALS['log']->info('End: SoapHelperWebServices->new_handle_set_entries');
891                 return Array('id'=>$value->id,
892                                         'module_name'=> $module,
893                                         'name_value_list'=>$this->get_name_value_list($value)
894                                         );
895         }
896
897
898         function get_return_module_fields($value, $module,$fields, $translate=true){
899                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_return_module_fields');
900                 global $module_name;
901                 $module_name = $module;
902                 $result = $this->get_field_list($value,$fields,  $translate);
903                 $GLOBALS['log']->info('End: SoapHelperWebServices->get_return_module_fields');
904                 return Array('module_name'=>$module,
905                                         'module_fields'=> $result['module_fields'],
906                                         'link_fields'=> $result['link_fields'],
907                                         );
908         } // fn
909
910         function login_success($name_value_list = array()){
911                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->login_success');
912                 global $current_language, $sugar_config, $app_strings, $app_list_strings;
913                 $current_language = $sugar_config['default_language'];
914                 if (is_array($name_value_list) && !empty($name_value_list)) {
915                         foreach($name_value_list as $key => $value) {
916                                 if (isset($value['name']) && ($value['name'] == 'language')) {
917                                         $language = $value['value'];
918                                         $supportedLanguages = $sugar_config['languages'];
919                                         if (array_key_exists($language, $supportedLanguages)) {
920                                                 $current_language = $language;
921                                         } // if
922                                 } // if
923                                 if (isset($value['name']) && ($value['name'] == 'notifyonsave')) {
924                                         if ($value['value']) {
925                                                 $_SESSION['notifyonsave'] = true;
926                                         }
927                                 } // if
928                         } // foreach
929                 } else {
930                         if (isset($_SESSION['user_language'])) {
931                                 $current_language = $_SESSION['user_language'];
932                         } // if
933                 }
934                 $GLOBALS['log']->info("Users language is = " . $current_language);
935                 $app_strings = return_application_language($current_language);
936                 $app_list_strings = return_app_list_strings_language($current_language);
937                 $GLOBALS['log']->info('End: SoapHelperWebServices->login_success');
938         } // fn
939
940
941         function checkSaveOnNotify() {
942             $notifyonsave = false;
943             if (isset($_SESSION['notifyonsave']) && $_SESSION['notifyonsave'] == true) {
944                 $notifyonsave = true;
945             } // if
946                 return $notifyonsave;
947         }
948         /*
949          *      Given an account_name, either create the account or assign to a contact.
950          */
951         function add_create_account($seed) {
952                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->add_create_account');
953                 global $current_user;
954                 $account_name = $seed->account_name;
955                 $account_id = $seed->account_id;
956                 $assigned_user_id = $current_user->id;
957
958                 // check if it already exists
959             $focus = new Account();
960             if($focus->ACLAccess('Save')) {
961                         $class = get_class($seed);
962                         $temp = new $class();
963                         $temp->retrieve($seed->id);
964                         if ( empty($account_name) && empty($account_id)) {
965                                 return;
966                         } // if
967                         if (!isset($seed->accounts)){
968                             $seed->load_relationship('accounts');
969                         } // if
970
971                         if($seed->account_name == '' && isset($temp->account_id)){
972                                 $seed->accounts->delete($seed->id, $temp->account_id);
973                                 $GLOBALS['log']->info('End: SoapHelperWebServices->add_create_account');
974                                 return;
975                         }
976                     $arr = array();
977
978             if(!empty($account_id))  // bug # 44280
979             {
980                $query = "select id, deleted from {$focus->table_name} WHERE id='".$seed->db->quote($account_id)."'";
981             }
982             else
983             {
984                $query = "select id, deleted from {$focus->table_name} WHERE name='".$seed->db->quote($account_name)."'";
985             }
986             $result = $seed->db->query($query) or sugar_die("Error selecting sugarbean: ".mysql_error());
987
988                     $row = $seed->db->fetchByAssoc($result, -1, false);
989
990                         // we found a row with that id
991                     if (isset($row['id']) && $row['id'] != -1)
992                     {
993                         // if it exists but was deleted, just remove it entirely
994                         if ( isset($row['deleted']) && $row['deleted'] == 1)
995                         {
996                             $query2 = "delete from {$focus->table_name} WHERE id='". $seed->db->quote($row['id'])."'";
997                             $result2 = $seed->db->query($query2) or sugar_die("Error deleting existing sugarbean: ".mysql_error());
998                                 }
999                                 // else just use this id to link the contact to the account
1000                         else
1001                         {
1002                                 $focus->id = $row['id'];
1003                         }
1004                     }
1005
1006                         // if we didnt find the account, so create it
1007                     if (! isset($focus->id) || $focus->id == '')
1008                     {
1009                         $focus->name = $account_name;
1010
1011                                 if ( isset($assigned_user_id))
1012                                 {
1013                            $focus->assigned_user_id = $assigned_user_id;
1014                            $focus->modified_user_id = $assigned_user_id;
1015                                 }
1016                         $focus->save();
1017                     }
1018
1019                     if($seed->accounts != null && $temp->account_id != null && $temp->account_id != $focus->id){
1020                         $seed->accounts->delete($seed->id, $temp->account_id);
1021                     }
1022
1023                     if(isset($focus->id) && $focus->id != ''){
1024                                 $seed->account_id = $focus->id;
1025                         } // if
1026                         $GLOBALS['log']->info('End: SoapHelperWebServices->add_create_account');
1027
1028             } else {
1029                         $GLOBALS['log']->info('End: SoapHelperWebServices->add_create_account - Insufficient ACLAccess');
1030             } // else
1031         } // fn
1032
1033         function check_for_duplicate_contacts($seed){
1034                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->check_for_duplicate_contacts');
1035                 require_once('modules/Contacts/Contact.php');
1036
1037                 if(isset($seed->id)){
1038                         $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1039                         return null;
1040                 }
1041
1042                 $query = '';
1043
1044                 $trimmed_email = trim($seed->email1);
1045         $trimmed_email2 = trim($seed->email2);
1046             $trimmed_last = trim($seed->last_name);
1047             $trimmed_first = trim($seed->first_name);
1048                 if(!empty($trimmed_email) || !empty($trimmed_email2)){
1049
1050                         //obtain a list of contacts which contain the same email address
1051                         $contacts = $seed->emailAddress->getBeansByEmailAddress($trimmed_email);
1052             $contacts2 = $seed->emailAddress->getBeansByEmailAddress($trimmed_email2);
1053             $contacts = array_merge($contacts, $contacts2);
1054                         if(count($contacts) == 0){
1055                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1056                                 return null;
1057                         }else{
1058                                 foreach($contacts as $contact){
1059                                         if(!empty($trimmed_last) && strcmp($trimmed_last, $contact->last_name) == 0){
1060                                                 if((!empty($trimmed_email) || !empty($trimmed_email2)) && (strcmp($trimmed_email, $contact->email1) == 0 || strcmp($trimmed_email, $contact->email2) == 0 || strcmp($trimmed_email2, $contact->email) == 0 || strcmp($trimmed_email2, $contact->email2) == 0)){
1061                                                         $contact->load_relationship('accounts');
1062                                                         if(empty($seed->account_name) || strcmp($seed->account_name, $contact->account_name) == 0){
1063                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - duplicte found ' . $contact->id);
1064                                                                 return $contact->id;
1065                                                         }
1066                                                 }
1067                                         }
1068                                 }
1069                                 $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1070                                 return null;
1071                         }
1072                 }else
1073                         $GLOBALS['log']->info('End: SoapHelperWebServices->check_for_duplicate_contacts - no duplicte found');
1074                         return null;
1075         }
1076
1077
1078         /**
1079          * decrypt a string use the TripleDES algorithm. This meant to be
1080          * modified if the end user chooses a different algorithm
1081          *
1082          * @param $string - the string to decrypt
1083          *
1084          * @return a decrypted string if we can decrypt, the original string otherwise
1085          */
1086         function decrypt_string($string){
1087                 $GLOBALS['log']->info('Begin: SoapHelperWebServices->decrypt_string');
1088                 if(function_exists('mcrypt_cbc')){
1089                         require_once('modules/Administration/Administration.php');
1090                         $focus = new Administration();
1091                         $focus->retrieveSettings();
1092                         $key = '';
1093                         if(!empty($focus->settings['ldap_enc_key'])){
1094                                 $key = $focus->settings['ldap_enc_key'];
1095                         }
1096                         if(empty($key)) {
1097                                 $GLOBALS['log']->info('End: SoapHelperWebServices->decrypt_string - empty key');
1098                                 return $string;
1099                         } // if
1100                         $buffer = $string;
1101                         $key = substr(md5($key),0,24);
1102                     $iv = "password";
1103                         $GLOBALS['log']->info('End: SoapHelperWebServices->decrypt_string');
1104                     return mcrypt_cbc(MCRYPT_3DES, $key, pack("H*", $buffer), MCRYPT_DECRYPT, $iv);
1105                 }else{
1106                         $GLOBALS['log']->info('End: SoapHelperWebServices->decrypt_string');
1107                         return $string;
1108                 }
1109         } // fn
1110
1111         function isLogLevelDebug() {
1112                 if (isset($GLOBALS['sugar_config']['logger'])) {
1113                         if (isset($GLOBALS['sugar_config']['logger']['level'])) {
1114                                 return ($GLOBALS['sugar_config']['logger']['level'] == 'debug');
1115                         } // if
1116                 }
1117                 return false;
1118         } // fn
1119 } // clazz
1120
1121 ?>