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