@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('sugarEntry') || !sugarEntry) |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) { |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('sugarEntry') || !sugarEntry) |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) { |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('sugarEntry') || !sugarEntry) |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) { |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('sugarEntry') || !sugarEntry) |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) { |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -315,8 +317,9 @@ discard block |
||
315 | 317 | global $dictionary, $current_user; |
316 | 318 | static $loaded_defs = array(); |
317 | 319 | $this->db = DBManagerFactory::getInstance(); |
318 | - if (empty($this->module_name)) |
|
319 | - $this->module_name = $this->module_dir; |
|
320 | + if (empty($this->module_name)) { |
|
321 | + $this->module_name = $this->module_dir; |
|
322 | + } |
|
320 | 323 | if((false == $this->disable_vardefs && empty($loaded_defs[$this->object_name])) || !empty($GLOBALS['reload_vardefs'])) |
321 | 324 | { |
322 | 325 | VardefManager::loadVardef($this->module_dir, $this->object_name); |
@@ -339,12 +342,15 @@ discard block |
||
339 | 342 | $this->setupCustomFields($this->module_dir); |
340 | 343 | } |
341 | 344 | //load up field_arrays from CacheHandler; |
342 | - if(empty($this->list_fields)) |
|
343 | - $this->list_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'list_fields'); |
|
344 | - if(empty($this->column_fields)) |
|
345 | - $this->column_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'column_fields'); |
|
346 | - if(empty($this->required_fields)) |
|
347 | - $this->required_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'required_fields'); |
|
345 | + if(empty($this->list_fields)) { |
|
346 | + $this->list_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'list_fields'); |
|
347 | + } |
|
348 | + if(empty($this->column_fields)) { |
|
349 | + $this->column_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'column_fields'); |
|
350 | + } |
|
351 | + if(empty($this->required_fields)) { |
|
352 | + $this->required_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'required_fields'); |
|
353 | + } |
|
348 | 354 | |
349 | 355 | if(isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) |
350 | 356 | { |
@@ -361,8 +367,7 @@ discard block |
||
361 | 367 | $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields; |
362 | 368 | $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map; |
363 | 369 | $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs; |
364 | - } |
|
365 | - else |
|
370 | + } else |
|
366 | 371 | { |
367 | 372 | $this->column_fields =& $loaded_defs[$this->object_name]['column_fields'] ; |
368 | 373 | $this->list_fields =& $loaded_defs[$this->object_name]['list_fields']; |
@@ -400,8 +405,9 @@ discard block |
||
400 | 405 | */ |
401 | 406 | function getObjectName() |
402 | 407 | { |
403 | - if ($this->object_name) |
|
404 | - return $this->object_name; |
|
408 | + if ($this->object_name) { |
|
409 | + return $this->object_name; |
|
410 | + } |
|
405 | 411 | |
406 | 412 | // This is a quick way out. The generated metadata files have the table name |
407 | 413 | // as the key. The correct way to do this is to override this function |
@@ -459,8 +465,7 @@ discard block |
||
459 | 465 | if (isset($dictionary[$this->getObjectName()]['audited'])) |
460 | 466 | { |
461 | 467 | return $dictionary[$this->getObjectName()]['audited']; |
462 | - } |
|
463 | - else |
|
468 | + } else |
|
464 | 469 | { |
465 | 470 | return false; |
466 | 471 | } |
@@ -598,8 +603,9 @@ discard block |
||
598 | 603 | */ |
599 | 604 | function getFieldDefinition($name) |
600 | 605 | { |
601 | - if ( !isset($this->field_defs[$name]) ) |
|
602 | - return false; |
|
606 | + if ( !isset($this->field_defs[$name]) ) { |
|
607 | + return false; |
|
608 | + } |
|
603 | 609 | |
604 | 610 | return $this->field_defs[$name]; |
605 | 611 | } |
@@ -657,8 +663,9 @@ discard block |
||
657 | 663 | */ |
658 | 664 | public function unPopulateDefaultValues() |
659 | 665 | { |
660 | - if ( !is_array($this->field_defs) ) |
|
661 | - return; |
|
666 | + if ( !is_array($this->field_defs) ) { |
|
667 | + return; |
|
668 | + } |
|
662 | 669 | |
663 | 670 | foreach ($this->field_defs as $field => $value) { |
664 | 671 | if( !empty($this->$field) |
@@ -698,8 +705,9 @@ discard block |
||
698 | 705 | } |
699 | 706 | |
700 | 707 | function populateDefaultValues($force=false){ |
701 | - if ( !is_array($this->field_defs) ) |
|
702 | - return; |
|
708 | + if ( !is_array($this->field_defs) ) { |
|
709 | + return; |
|
710 | + } |
|
703 | 711 | foreach($this->field_defs as $field=>$value){ |
704 | 712 | if((isset($value['default']) || !empty($value['display_default'])) && ($force || empty($this->$field))){ |
705 | 713 | $type = $value['type']; |
@@ -717,10 +725,11 @@ discard block |
||
717 | 725 | } |
718 | 726 | break; |
719 | 727 | case 'multienum': |
720 | - if(empty($value['default']) && !empty($value['display_default'])) |
|
721 | - $this->$field = $value['display_default']; |
|
722 | - else |
|
723 | - $this->$field = $value['default']; |
|
728 | + if(empty($value['default']) && !empty($value['display_default'])) { |
|
729 | + $this->$field = $value['display_default']; |
|
730 | + } else { |
|
731 | + $this->$field = $value['default']; |
|
732 | + } |
|
724 | 733 | break; |
725 | 734 | case 'bool': |
726 | 735 | if(isset($this->$field)){ |
@@ -770,8 +779,7 @@ discard block |
||
770 | 779 | { |
771 | 780 | $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename. " does not exist"); |
772 | 781 | display_notice("meta data absent for table ".$tablename." keyed to $key "); |
773 | - } |
|
774 | - else |
|
782 | + } else |
|
775 | 783 | { |
776 | 784 | if (isset($dictionary[$key]['relationships'])) |
777 | 785 | { |
@@ -821,8 +829,7 @@ discard block |
||
821 | 829 | if($iscustom) |
822 | 830 | { |
823 | 831 | $filename='custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php'; |
824 | - } |
|
825 | - else |
|
832 | + } else |
|
826 | 833 | { |
827 | 834 | if ($key == 'User') |
828 | 835 | { |
@@ -830,8 +837,7 @@ discard block |
||
830 | 837 | // this must be done because the Employees/vardefs.php does an include_once on |
831 | 838 | // Users/vardefs.php |
832 | 839 | $filename='modules/Users/vardefs.php'; |
833 | - } |
|
834 | - else |
|
840 | + } else |
|
835 | 841 | { |
836 | 842 | $filename='modules/'. $module_dir . '/vardefs.php'; |
837 | 843 | } |
@@ -845,8 +851,7 @@ discard block |
||
845 | 851 | { |
846 | 852 | $dictionary = $GLOBALS['dictionary']; |
847 | 853 | } |
848 | - } |
|
849 | - else |
|
854 | + } else |
|
850 | 855 | { |
851 | 856 | $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename); |
852 | 857 | return; |
@@ -857,8 +862,7 @@ discard block |
||
857 | 862 | { |
858 | 863 | $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename. " does not exist"); |
859 | 864 | display_notice("meta data absent for table ".$tablename." keyed to $key "); |
860 | - } |
|
861 | - else |
|
865 | + } else |
|
862 | 866 | { |
863 | 867 | if (isset($dictionary[$key]['relationships'])) |
864 | 868 | { |
@@ -884,8 +888,7 @@ discard block |
||
884 | 888 | if (Relationship::exists($rel_name,$db)) |
885 | 889 | { |
886 | 890 | $GLOBALS['log']->debug('Skipping, reltionship already exists '.$rel_name); |
887 | - } |
|
888 | - else |
|
891 | + } else |
|
889 | 892 | { |
890 | 893 | $seed = BeanFactory::getBean("Relationships"); |
891 | 894 | $keys = array_keys($seed->field_defs); |
@@ -895,12 +898,10 @@ discard block |
||
895 | 898 | if ($key == "id") |
896 | 899 | { |
897 | 900 | $toInsert[$key] = create_guid(); |
898 | - } |
|
899 | - else if ($key == "relationship_name") |
|
901 | + } else if ($key == "relationship_name") |
|
900 | 902 | { |
901 | 903 | $toInsert[$key] = $rel_name; |
902 | - } |
|
903 | - else if (isset($rel_def[$key])) |
|
904 | + } else if (isset($rel_def[$key])) |
|
904 | 905 | { |
905 | 906 | $toInsert[$key] = $rel_def[$key]; |
906 | 907 | } |
@@ -916,8 +917,7 @@ discard block |
||
916 | 917 | $db->query($insert_string, true); |
917 | 918 | } |
918 | 919 | } |
919 | - } |
|
920 | - else |
|
920 | + } else |
|
921 | 921 | { |
922 | 922 | //todo |
923 | 923 | //log informational message stating no relationships meta was set for this bean. |
@@ -986,10 +986,11 @@ discard block |
||
986 | 986 | //if rel_name is provided, search the fieldef array keys by name. |
987 | 987 | if (isset($fieldDefs[$rel_name]['type']) && $fieldDefs[$rel_name]['type'] == 'link') |
988 | 988 | { |
989 | - if ($class == "Link2") |
|
990 | - $this->$rel_name = new $class($rel_name, $this); |
|
991 | - else |
|
992 | - $this->$rel_name = new $class($fieldDefs[$rel_name]['relationship'], $this, $fieldDefs[$rel_name]); |
|
989 | + if ($class == "Link2") { |
|
990 | + $this->$rel_name = new $class($rel_name, $this); |
|
991 | + } else { |
|
992 | + $this->$rel_name = new $class($fieldDefs[$rel_name]['relationship'], $this, $fieldDefs[$rel_name]); |
|
993 | + } |
|
993 | 994 | |
994 | 995 | if (empty($this->$rel_name) || |
995 | 996 | (method_exists($this->$rel_name, "loadedSuccesfully") && !$this->$rel_name->loadedSuccesfully())) |
@@ -1048,8 +1049,9 @@ discard block |
||
1048 | 1049 | function get_linked_beans($field_name,$bean_name = '', $order_by = '', $begin_index = 0, $end_index = -1, $deleted=0, $optional_where="") |
1049 | 1050 | { |
1050 | 1051 | //if bean_name is Case then use aCase |
1051 | - if($bean_name=="Case") |
|
1052 | - $bean_name = "aCase"; |
|
1052 | + if($bean_name=="Case") { |
|
1053 | + $bean_name = "aCase"; |
|
1054 | + } |
|
1053 | 1055 | |
1054 | 1056 | if($this->load_relationship($field_name)) { |
1055 | 1057 | if ($this->$field_name instanceof Link) { |
@@ -1057,19 +1059,20 @@ discard block |
||
1057 | 1059 | return array_values($this->$field_name->getBeans(new $bean_name(), $order_by, $begin_index, $end_index, $deleted, $optional_where)); |
1058 | 1060 | } else { |
1059 | 1061 | // Link2 style |
1060 | - if ($end_index != -1 || !empty($deleted) || !empty($optional_where) || !empty($order_by)) |
|
1061 | - return array_values($this->$field_name->getBeans(array( |
|
1062 | + if ($end_index != -1 || !empty($deleted) || !empty($optional_where) || !empty($order_by)) { |
|
1063 | + return array_values($this->$field_name->getBeans(array( |
|
1062 | 1064 | 'where' => $optional_where, |
1063 | 1065 | 'deleted' => $deleted, |
1064 | 1066 | 'limit' => ($end_index - $begin_index), |
1065 | 1067 | 'order_by' => $order_by |
1066 | 1068 | ))); |
1067 | - else |
|
1068 | - return array_values($this->$field_name->getBeans()); |
|
1069 | + } else { |
|
1070 | + return array_values($this->$field_name->getBeans()); |
|
1071 | + } |
|
1069 | 1072 | } |
1073 | + } else { |
|
1074 | + return array(); |
|
1070 | 1075 | } |
1071 | - else |
|
1072 | - return array(); |
|
1073 | 1076 | } |
1074 | 1077 | |
1075 | 1078 | /** |
@@ -1131,8 +1134,7 @@ discard block |
||
1131 | 1134 | || is_bool($value_array['importable']) && $value_array['importable'] == true)) { |
1132 | 1135 | $importableFields[$key]=$value_array; |
1133 | 1136 | } |
1134 | - } |
|
1135 | - else { |
|
1137 | + } else { |
|
1136 | 1138 | |
1137 | 1139 | //Expose the cooresponding id field of a relate field if it is only defined as a link so that users can relate records by id during import |
1138 | 1140 | if( isset($value_array['type']) && ($value_array['type'] == 'relate') && isset($value_array['id_name']) ) |
@@ -1217,8 +1219,7 @@ discard block |
||
1217 | 1219 | if ($this->load_relationship($name)) |
1218 | 1220 | { |
1219 | 1221 | $this->$name->delete($id); |
1220 | - } |
|
1221 | - else |
|
1222 | + } else |
|
1222 | 1223 | { |
1223 | 1224 | $GLOBALS['log']->fatal("error loading relationship $name"); |
1224 | 1225 | } |
@@ -1239,8 +1240,7 @@ discard block |
||
1239 | 1240 | { |
1240 | 1241 | $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name. " does not exist"); |
1241 | 1242 | display_notice("meta data absent for table ".$this->table_name." keyed to $key "); |
1242 | - } |
|
1243 | - else |
|
1243 | + } else |
|
1244 | 1244 | { |
1245 | 1245 | if(!$this->db->tableExists($this->table_name)) |
1246 | 1246 | { |
@@ -1248,12 +1248,11 @@ discard block |
||
1248 | 1248 | if($this->bean_implements('ACL')){ |
1249 | 1249 | if(!empty($this->acltype)){ |
1250 | 1250 | ACLAction::addActions($this->getACLCategory(), $this->acltype); |
1251 | - }else{ |
|
1251 | + } else{ |
|
1252 | 1252 | ACLAction::addActions($this->getACLCategory()); |
1253 | 1253 | } |
1254 | 1254 | } |
1255 | - } |
|
1256 | - else |
|
1255 | + } else |
|
1257 | 1256 | { |
1258 | 1257 | echo "Table already exists : $this->table_name<br>"; |
1259 | 1258 | } |
@@ -1281,10 +1280,13 @@ discard block |
||
1281 | 1280 | $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name. " does not exist"); |
1282 | 1281 | echo "meta data absent for table ".$this->table_name."<br>\n"; |
1283 | 1282 | } else { |
1284 | - if(empty($this->table_name))return; |
|
1285 | - if ($this->db->tableExists($this->table_name)) |
|
1286 | - |
|
1283 | + if(empty($this->table_name)) { |
|
1284 | + return; |
|
1285 | + } |
|
1286 | + if ($this->db->tableExists($this->table_name)) { |
|
1287 | + |
|
1287 | 1288 | $this->db->dropTable($this); |
1289 | + } |
|
1288 | 1290 | if ($this->db->tableExists($this->table_name. '_cstm')) |
1289 | 1291 | { |
1290 | 1292 | $this->db->dropTableName($this->table_name. '_cstm'); |
@@ -1322,8 +1324,9 @@ discard block |
||
1322 | 1324 | if (isset($def['type'])) { |
1323 | 1325 | $type=$def['type']; |
1324 | 1326 | } |
1325 | - if(isset($def['dbType'])) |
|
1326 | - $type .= $def['dbType']; |
|
1327 | + if(isset($def['dbType'])) { |
|
1328 | + $type .= $def['dbType']; |
|
1329 | + } |
|
1327 | 1330 | |
1328 | 1331 | if($def['type'] == 'html' || $def['type'] == 'longhtml') { |
1329 | 1332 | $this->$key = SugarCleaner::cleanHtml($this->$key, true); |
@@ -1373,7 +1376,9 @@ discard block |
||
1373 | 1376 | |
1374 | 1377 | $this->_checkOptimisticLocking($action, $isUpdate); |
1375 | 1378 | |
1376 | - if(!empty($this->modified_by_name)) $this->old_modified_by_name = $this->modified_by_name; |
|
1379 | + if(!empty($this->modified_by_name)) { |
|
1380 | + $this->old_modified_by_name = $this->modified_by_name; |
|
1381 | + } |
|
1377 | 1382 | if($this->update_modified_by) |
1378 | 1383 | { |
1379 | 1384 | $this->modified_user_id = 1; |
@@ -1384,8 +1389,9 @@ discard block |
||
1384 | 1389 | $this->modified_by_name = $current_user->user_name; |
1385 | 1390 | } |
1386 | 1391 | } |
1387 | - if ($this->deleted != 1) |
|
1388 | - $this->deleted = 0; |
|
1392 | + if ($this->deleted != 1) { |
|
1393 | + $this->deleted = 0; |
|
1394 | + } |
|
1389 | 1395 | if(!$isUpdate) |
1390 | 1396 | { |
1391 | 1397 | if (empty($this->date_entered)) |
@@ -1607,7 +1613,7 @@ discard block |
||
1607 | 1613 | |
1608 | 1614 | if(!$notify_mail->Send()) { |
1609 | 1615 | $GLOBALS['log']->fatal("Notifications: error sending e-mail (method: {$notify_mail->Mailer}), (error: {$notify_mail->ErrorInfo})"); |
1610 | - }else{ |
|
1616 | + } else{ |
|
1611 | 1617 | $GLOBALS['log']->info("Notifications: e-mail successfully sent"); |
1612 | 1618 | } |
1613 | 1619 | } |
@@ -1646,8 +1652,7 @@ discard block |
||
1646 | 1652 | $xtpl = new XTemplate(get_notify_template_file($current_language)); |
1647 | 1653 | if($this->module_dir == "Cases") { |
1648 | 1654 | $template_name = "Case"; //we should use Case, you can refer to the en_us.notify_template.html. |
1649 | - } |
|
1650 | - else { |
|
1655 | + } else { |
|
1651 | 1656 | $template_name = $beanList[$this->module_dir]; //bug 20637, in workflow this->object_name = strange chars. |
1652 | 1657 | } |
1653 | 1658 | |
@@ -1745,8 +1750,7 @@ discard block |
||
1745 | 1750 | // if we should use relation data from properties (for REQUEST-independent calls) |
1746 | 1751 | $rel_id = isset($this->new_rel_id) ? $this->new_rel_id : ''; |
1747 | 1752 | $rel_link = isset($this->new_rel_relname) ? $this->new_rel_relname : ''; |
1748 | - } |
|
1749 | - else |
|
1753 | + } else |
|
1750 | 1754 | { |
1751 | 1755 | // if we should use relation data from REQUEST |
1752 | 1756 | $rel_id = isset($_REQUEST['relate_id']) ? $_REQUEST['relate_id'] : ''; |
@@ -1765,8 +1769,7 @@ discard block |
||
1765 | 1769 | if ($isRelationshipLoaded && !empty($this->$rel_link) && $this->$rel_link->getRelationshipObject() && $this->$rel_link->getRelationshipObject()->getLHSModule() == $this->$rel_link->getRelationshipObject()->getRHSModule() ) |
1766 | 1770 | { |
1767 | 1771 | $new_rel_link = $this->$rel_link->getRelationshipObject()->getLHSLink(); |
1768 | - } |
|
1769 | - else |
|
1772 | + } else |
|
1770 | 1773 | { |
1771 | 1774 | //Try to find the link in this bean based on the relationship |
1772 | 1775 | foreach ($this->field_defs as $key => $def) |
@@ -1800,7 +1803,9 @@ discard block |
||
1800 | 1803 | foreach ($this->relationship_fields as $id => $rel_name) |
1801 | 1804 | { |
1802 | 1805 | |
1803 | - if (in_array($id, $exclude)) continue; |
|
1806 | + if (in_array($id, $exclude)) { |
|
1807 | + continue; |
|
1808 | + } |
|
1804 | 1809 | |
1805 | 1810 | if(!empty($this->$id)) |
1806 | 1811 | { |
@@ -1853,8 +1858,10 @@ discard block |
||
1853 | 1858 | foreach ($this->field_defs as $def) |
1854 | 1859 | { |
1855 | 1860 | if ($def ['type'] == 'relate' && isset ($def ['id_name']) && isset ($def ['link']) && isset ($def['save'])) { |
1856 | - if (in_array($def['id_name'], $exclude) || in_array($def['id_name'], $this->relationship_fields)) |
|
1857 | - continue; // continue to honor the exclude array and exclude any relationships that will be handled by the relationship_fields mechanism |
|
1861 | + if (in_array($def['id_name'], $exclude) || in_array($def['id_name'], $this->relationship_fields)) { |
|
1862 | + continue; |
|
1863 | + } |
|
1864 | + // continue to honor the exclude array and exclude any relationships that will be handled by the relationship_fields mechanism |
|
1858 | 1865 | |
1859 | 1866 | $linkField = $def ['link']; |
1860 | 1867 | if (isset($this->field_defs[$linkField])) { |
@@ -1911,12 +1918,14 @@ discard block |
||
1911 | 1918 | { |
1912 | 1919 | if (!empty($def['type']) && $def['type'] == "parent") |
1913 | 1920 | { |
1914 | - if (empty($def['type_name']) || empty($def['id_name'])) |
|
1915 | - continue; |
|
1921 | + if (empty($def['type_name']) || empty($def['id_name'])) { |
|
1922 | + continue; |
|
1923 | + } |
|
1916 | 1924 | $typeField = $def['type_name']; |
1917 | 1925 | $idField = $def['id_name']; |
1918 | - if (in_array($idField, $exclude)) |
|
1919 | - continue; |
|
1926 | + if (in_array($idField, $exclude)) { |
|
1927 | + continue; |
|
1928 | + } |
|
1920 | 1929 | //Determine if the parent field has changed. |
1921 | 1930 | if ( |
1922 | 1931 | //First check if the fetched row parent existed and now we no longer have one |
@@ -2039,8 +2048,9 @@ discard block |
||
2039 | 2048 | { |
2040 | 2049 | global $disable_date_format; |
2041 | 2050 | global $timedate; |
2042 | - if (empty($timedate)) |
|
2043 | - $timedate=TimeDate::getInstance(); |
|
2051 | + if (empty($timedate)) { |
|
2052 | + $timedate=TimeDate::getInstance(); |
|
2053 | + } |
|
2044 | 2054 | |
2045 | 2055 | if(empty($this->field_defs)) |
2046 | 2056 | { |
@@ -2052,15 +2062,16 @@ discard block |
||
2052 | 2062 | if(!isset($this->processed_dates_times[$field])) |
2053 | 2063 | { |
2054 | 2064 | $this->processed_dates_times[$field] = '1'; |
2055 | - if(empty($this->$field)) continue; |
|
2065 | + if(empty($this->$field)) { |
|
2066 | + continue; |
|
2067 | + } |
|
2056 | 2068 | if($field == 'date_modified' || $field == 'date_entered') |
2057 | 2069 | { |
2058 | 2070 | $this->$field = $this->db->fromConvert($this->$field, 'datetime'); |
2059 | 2071 | if(empty($disable_date_format)) { |
2060 | 2072 | $this->$field = $timedate->to_display_date_time($this->$field); |
2061 | 2073 | } |
2062 | - } |
|
2063 | - elseif(isset($this->field_name_map[$field]['type'])) |
|
2074 | + } elseif(isset($this->field_name_map[$field]['type'])) |
|
2064 | 2075 | { |
2065 | 2076 | $type = $this->field_name_map[$field]['type']; |
2066 | 2077 | |
@@ -2086,8 +2097,7 @@ discard block |
||
2086 | 2097 | $this->$rel_field = $timedate->to_display_time($mergetime); |
2087 | 2098 | } |
2088 | 2099 | } |
2089 | - } |
|
2090 | - else |
|
2100 | + } else |
|
2091 | 2101 | { |
2092 | 2102 | if(empty($disable_date_format)) { |
2093 | 2103 | $this->$field = $timedate->to_display_date($this->$field, false); |
@@ -2098,8 +2108,7 @@ discard block |
||
2098 | 2108 | if($this->$field == '0000-00-00 00:00:00') |
2099 | 2109 | { |
2100 | 2110 | $this->$field = ''; |
2101 | - } |
|
2102 | - else |
|
2111 | + } else |
|
2103 | 2112 | { |
2104 | 2113 | if(empty($disable_date_format)) { |
2105 | 2114 | $this->$field = $timedate->to_display_date_time($this->$field, true, true); |
@@ -2188,7 +2197,9 @@ discard block |
||
2188 | 2197 | switch($def['type']) { |
2189 | 2198 | case 'datetime': |
2190 | 2199 | case 'datetimecombo': |
2191 | - if(empty($this->$field)) break; |
|
2200 | + if(empty($this->$field)) { |
|
2201 | + break; |
|
2202 | + } |
|
2192 | 2203 | if ($this->$field == 'NULL') { |
2193 | 2204 | $this->$field = ''; |
2194 | 2205 | break; |
@@ -2200,7 +2211,9 @@ discard block |
||
2200 | 2211 | } |
2201 | 2212 | break; |
2202 | 2213 | case 'date': |
2203 | - if(empty($this->$field)) break; |
|
2214 | + if(empty($this->$field)) { |
|
2215 | + break; |
|
2216 | + } |
|
2204 | 2217 | if ($this->$field == 'NULL') { |
2205 | 2218 | $this->$field = ''; |
2206 | 2219 | break; |
@@ -2212,7 +2225,9 @@ discard block |
||
2212 | 2225 | } |
2213 | 2226 | break; |
2214 | 2227 | case 'time': |
2215 | - if(empty($this->$field)) break; |
|
2228 | + if(empty($this->$field)) { |
|
2229 | + break; |
|
2230 | + } |
|
2216 | 2231 | if ($this->$field == 'NULL') { |
2217 | 2232 | $this->$field = ''; |
2218 | 2233 | break; |
@@ -2301,7 +2316,9 @@ discard block |
||
2301 | 2316 | |
2302 | 2317 | $query .= $custom_join['join']; |
2303 | 2318 | $query .= " WHERE $this->table_name.id = ".$this->db->quoted($id); |
2304 | - if ($deleted) $query .= " AND $this->table_name.deleted=0"; |
|
2319 | + if ($deleted) { |
|
2320 | + $query .= " AND $this->table_name.deleted=0"; |
|
2321 | + } |
|
2305 | 2322 | $GLOBALS['log']->debug("Retrieve $this->object_name : ".$query); |
2306 | 2323 | $result = $this->db->limitQuery($query,0,1,true, "Retrieving record by id $this->table_name:$id found "); |
2307 | 2324 | if(empty($result)) |
@@ -2359,21 +2376,23 @@ discard block |
||
2359 | 2376 | if (isset($def [ 'type' ]) && $def [ 'type' ] == 'relate' && isset ( $def [ 'id_name'] ) && isset ( $def [ 'link'] ) && isset ( $def[ 'save' ])) { |
2360 | 2377 | if (isset($this->$key)) { |
2361 | 2378 | $this->rel_fields_before_value[$key]=$this->$key; |
2362 | - if (isset($this->$def [ 'id_name'])) |
|
2363 | - $this->rel_fields_before_value[$def [ 'id_name']]=$this->$def [ 'id_name']; |
|
2379 | + if (isset($this->$def [ 'id_name'])) { |
|
2380 | + $this->rel_fields_before_value[$def [ 'id_name']]=$this->$def [ 'id_name']; |
|
2381 | + } |
|
2382 | + } else { |
|
2383 | + $this->rel_fields_before_value[$key]=null; |
|
2364 | 2384 | } |
2365 | - else |
|
2366 | - $this->rel_fields_before_value[$key]=null; |
|
2367 | 2385 | } |
2368 | 2386 | } |
2369 | 2387 | if (isset($this->relationship_fields) && is_array($this->relationship_fields)) |
2370 | 2388 | { |
2371 | 2389 | foreach ($this->relationship_fields as $rel_id=>$rel_name) |
2372 | 2390 | { |
2373 | - if (isset($this->$rel_id)) |
|
2374 | - $this->rel_fields_before_value[$rel_id]=$this->$rel_id; |
|
2375 | - else |
|
2376 | - $this->rel_fields_before_value[$rel_id]=null; |
|
2391 | + if (isset($this->$rel_id)) { |
|
2392 | + $this->rel_fields_before_value[$rel_id]=$this->$rel_id; |
|
2393 | + } else { |
|
2394 | + $this->rel_fields_before_value[$rel_id]=null; |
|
2395 | + } |
|
2377 | 2396 | } |
2378 | 2397 | } |
2379 | 2398 | |
@@ -2399,8 +2418,9 @@ discard block |
||
2399 | 2418 | $nullvalue=''; |
2400 | 2419 | foreach($this->field_defs as $field=>$field_value) |
2401 | 2420 | { |
2402 | - if(($field == 'user_preferences' && $this->module_dir == 'Users') || ($field == 'internal' && $this->module_dir == 'Cases') ) |
|
2403 | - continue; |
|
2421 | + if(($field == 'user_preferences' && $this->module_dir == 'Users') || ($field == 'internal' && $this->module_dir == 'Cases') ) { |
|
2422 | + continue; |
|
2423 | + } |
|
2404 | 2424 | if(isset($row[$field])) |
2405 | 2425 | { |
2406 | 2426 | $this->$field = $row[$field]; |
@@ -2408,8 +2428,7 @@ discard block |
||
2408 | 2428 | if(!empty($row[$owner])){ |
2409 | 2429 | $this->$owner = $row[$owner]; |
2410 | 2430 | } |
2411 | - } |
|
2412 | - else |
|
2431 | + } else |
|
2413 | 2432 | { |
2414 | 2433 | $this->$field = $nullvalue; |
2415 | 2434 | } |
@@ -2453,10 +2472,11 @@ discard block |
||
2453 | 2472 | //handle distinct clause |
2454 | 2473 | $star = '*'; |
2455 | 2474 | if(substr_count(strtolower($query), 'distinct')){ |
2456 | - if (!empty($this->seed) && !empty($this->seed->table_name )) |
|
2457 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
2458 | - else |
|
2459 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
2475 | + if (!empty($this->seed) && !empty($this->seed->table_name )) { |
|
2476 | + $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
2477 | + } else { |
|
2478 | + $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
2479 | + } |
|
2460 | 2480 | |
2461 | 2481 | } |
2462 | 2482 | |
@@ -2477,10 +2497,11 @@ discard block |
||
2477 | 2497 | preg_match($pattern, $union_query, $matches); |
2478 | 2498 | if (!empty($matches)) { |
2479 | 2499 | if (stristr($matches[0], "distinct")) { |
2480 | - if (!empty($this->seed) && !empty($this->seed->table_name )) |
|
2481 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
2482 | - else |
|
2483 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
2500 | + if (!empty($this->seed) && !empty($this->seed->table_name )) { |
|
2501 | + $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
2502 | + } else { |
|
2503 | + $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
2504 | + } |
|
2484 | 2505 | } |
2485 | 2506 | } // if |
2486 | 2507 | $replacement = 'SELECT count(' . $star . ') c FROM '; |
@@ -2530,7 +2551,7 @@ discard block |
||
2530 | 2551 | if(!empty($owner_where)){ |
2531 | 2552 | if(empty($where)){ |
2532 | 2553 | $where = $owner_where; |
2533 | - }else{ |
|
2554 | + } else{ |
|
2534 | 2555 | $where .= ' AND '. $owner_where; |
2535 | 2556 | } |
2536 | 2557 | } |
@@ -2551,14 +2572,14 @@ discard block |
||
2551 | 2572 | */ |
2552 | 2573 | public function process_order_by($order_by, $submodule = null, $suppress_table_name = false) |
2553 | 2574 | { |
2554 | - if (empty($order_by)) |
|
2555 | - return $order_by; |
|
2575 | + if (empty($order_by)) { |
|
2576 | + return $order_by; |
|
2577 | + } |
|
2556 | 2578 | //submodule is empty,this is for list object in focus |
2557 | 2579 | if (empty($submodule)) |
2558 | 2580 | { |
2559 | 2581 | $bean_queried = $this; |
2560 | - } |
|
2561 | - else |
|
2582 | + } else |
|
2562 | 2583 | { |
2563 | 2584 | //submodule is set, so this is for subpanel, use submodule |
2564 | 2585 | $bean_queried = $submodule; |
@@ -2653,8 +2674,7 @@ discard block |
||
2653 | 2674 | if(empty($where)) |
2654 | 2675 | { |
2655 | 2676 | $where = $owner_where; |
2656 | - } |
|
2657 | - else |
|
2677 | + } else |
|
2658 | 2678 | { |
2659 | 2679 | $where .= ' AND '. $owner_where; |
2660 | 2680 | } |
@@ -2740,8 +2760,7 @@ discard block |
||
2740 | 2760 | if(empty($entire_where)) |
2741 | 2761 | { |
2742 | 2762 | $entire_where = ' WHERE ' . $where; |
2743 | - } |
|
2744 | - else |
|
2763 | + } else |
|
2745 | 2764 | { |
2746 | 2765 | $entire_where .= ' AND ' . $where; |
2747 | 2766 | } |
@@ -2781,16 +2800,15 @@ discard block |
||
2781 | 2800 | } |
2782 | 2801 | //call function from required file |
2783 | 2802 | $query_array = $shortcut_function_name($parameters); |
2784 | - }else{ |
|
2803 | + } else{ |
|
2785 | 2804 | //call function from parent bean |
2786 | 2805 | $query_array = $parentbean->$shortcut_function_name($parameters); |
2787 | 2806 | } |
2788 | - } |
|
2789 | - else |
|
2807 | + } else |
|
2790 | 2808 | { |
2791 | 2809 | $query_array = $parentbean->$shortcut_function_name(); |
2792 | 2810 | } |
2793 | - } else { |
|
2811 | + } else { |
|
2794 | 2812 | $related_field_name = $this_subpanel->get_data_source_name(); |
2795 | 2813 | if (!$parentbean->load_relationship($related_field_name)){ |
2796 | 2814 | unset ($parentbean->$related_field_name); |
@@ -2806,8 +2824,7 @@ discard block |
||
2806 | 2824 | if(empty($where_definition)) |
2807 | 2825 | { |
2808 | 2826 | $where_definition = $table_where; |
2809 | - } |
|
2810 | - else |
|
2827 | + } else |
|
2811 | 2828 | { |
2812 | 2829 | $where_definition .= ' AND ' . $table_where; |
2813 | 2830 | } |
@@ -2898,8 +2915,7 @@ discard block |
||
2898 | 2915 | { |
2899 | 2916 | $subpanel_def->load_sub_subpanels(); |
2900 | 2917 | $subpanel_list=$subpanel_def->sub_subpanels; |
2901 | - } |
|
2902 | - else |
|
2918 | + } else |
|
2903 | 2919 | { |
2904 | 2920 | $subpanel_list[]=$subpanel_def; |
2905 | 2921 | } |
@@ -2926,7 +2942,7 @@ discard block |
||
2926 | 2942 | } |
2927 | 2943 | //call function from required file |
2928 | 2944 | $tmp_final_query = $shortcut_function_name($parameters); |
2929 | - }else{ |
|
2945 | + } else{ |
|
2930 | 2946 | //call function from parent bean |
2931 | 2947 | $tmp_final_query = $parentbean->$shortcut_function_name($parameters); |
2932 | 2948 | } |
@@ -2954,8 +2970,9 @@ discard block |
||
2954 | 2970 | $query_fields = $GLOBALS['db']->getSelectFieldsFromQuery($subquery['select']); |
2955 | 2971 | foreach($query_fields as $field => $select) |
2956 | 2972 | { |
2957 | - if (!in_array($field, $all_fields)) |
|
2958 | - $all_fields[] = $field; |
|
2973 | + if (!in_array($field, $all_fields)) { |
|
2974 | + $all_fields[] = $field; |
|
2975 | + } |
|
2959 | 2976 | } |
2960 | 2977 | $subqueries[$i]['query_fields'] = $query_fields; |
2961 | 2978 | } |
@@ -2969,8 +2986,7 @@ discard block |
||
2969 | 2986 | if (!isset($subquery['query_fields'][$field])) |
2970 | 2987 | { |
2971 | 2988 | $subquery['select'] .= " NULL $field,"; |
2972 | - } |
|
2973 | - else |
|
2989 | + } else |
|
2974 | 2990 | { |
2975 | 2991 | $subquery['select'] .= " {$subquery['query_fields'][$field]},"; |
2976 | 2992 | } |
@@ -2992,12 +3008,10 @@ discard block |
||
2992 | 3008 | if (!empty($subquery['params']['distinct']) && !empty($subpanel_def->table_name)) |
2993 | 3009 | { |
2994 | 3010 | $query_rows = "( SELECT count(DISTINCT ". $subpanel_def->table_name . ".id)". $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
2995 | - } |
|
2996 | - elseif ($select_position !== false && $distinct_position!= false) |
|
3011 | + } elseif ($select_position !== false && $distinct_position!= false) |
|
2997 | 3012 | { |
2998 | 3013 | $query_rows = "( ".substr_replace($query_array['select'],"SELECT count(",$select_position,6). ")" . $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
2999 | - } |
|
3000 | - else |
|
3014 | + } else |
|
3001 | 3015 | { |
3002 | 3016 | //resort to default behavior. |
3003 | 3017 | $query_rows = "( SELECT count(*)". $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
@@ -3011,8 +3025,7 @@ discard block |
||
3011 | 3025 | if (empty($subquery['where'])) |
3012 | 3026 | { |
3013 | 3027 | $subquerystring.=" WHERE " .$subquery['secondary_where']; |
3014 | - } |
|
3015 | - else |
|
3028 | + } else |
|
3016 | 3029 | { |
3017 | 3030 | $subquerystring.=" AND " .$subquery['secondary_where']; |
3018 | 3031 | } |
@@ -3055,8 +3068,7 @@ discard block |
||
3055 | 3068 | { |
3056 | 3069 | $submodule->assign_display_fields($submodule->module_dir); |
3057 | 3070 | $response['list'] = array($submodule); |
3058 | - } |
|
3059 | - else |
|
3071 | + } else |
|
3060 | 3072 | { |
3061 | 3073 | $response['list'] = array(); |
3062 | 3074 | } |
@@ -3121,8 +3133,7 @@ discard block |
||
3121 | 3133 | if(empty($where)) |
3122 | 3134 | { |
3123 | 3135 | $where = $owner_where; |
3124 | - } |
|
3125 | - else |
|
3136 | + } else |
|
3126 | 3137 | { |
3127 | 3138 | $where .= ' AND '. $owner_where; |
3128 | 3139 | } |
@@ -3169,8 +3180,7 @@ discard block |
||
3169 | 3180 | if(empty($filter)) |
3170 | 3181 | { |
3171 | 3182 | $ret_array['select'] = " SELECT $distinct $this->table_name.* "; |
3172 | - } |
|
3173 | - else |
|
3183 | + } else |
|
3174 | 3184 | { |
3175 | 3185 | $ret_array['select'] = " SELECT $distinct $this->table_name.id "; |
3176 | 3186 | } |
@@ -3184,8 +3194,7 @@ discard block |
||
3184 | 3194 | { |
3185 | 3195 | $ret_array['secondary_select']=& $ret_array['select']; |
3186 | 3196 | $ret_array['secondary_from'] = & $ret_array['from']; |
3187 | - } |
|
3188 | - else |
|
3197 | + } else |
|
3189 | 3198 | { |
3190 | 3199 | $ret_array['secondary_select'] = ''; |
3191 | 3200 | } |
@@ -3230,17 +3239,15 @@ discard block |
||
3230 | 3239 | if(isset($this->field_defs[$field])) |
3231 | 3240 | { |
3232 | 3241 | $fields[$field]= $this->field_defs[$field]; |
3233 | - } |
|
3234 | - else |
|
3242 | + } else |
|
3235 | 3243 | { |
3236 | 3244 | $fields[$field] = array('force_exists'=>true); |
3237 | 3245 | } |
3238 | 3246 | } |
3239 | - }else{ |
|
3247 | + } else{ |
|
3240 | 3248 | $fields = $filter; |
3241 | 3249 | } |
3242 | - } |
|
3243 | - else |
|
3250 | + } else |
|
3244 | 3251 | { |
3245 | 3252 | $fields = $this->field_defs; |
3246 | 3253 | } |
@@ -3256,8 +3263,9 @@ discard block |
||
3256 | 3263 | $this->field_defs[$field]['source'] == 'non-db') |
3257 | 3264 | { |
3258 | 3265 | $addrelatefield = $this->get_relationship_field($field); |
3259 | - if ($addrelatefield) |
|
3260 | - $addrelate[$addrelatefield] = true; |
|
3266 | + if ($addrelatefield) { |
|
3267 | + $addrelate[$addrelatefield] = true; |
|
3268 | + } |
|
3261 | 3269 | } |
3262 | 3270 | if(!empty($this->field_defs[$field]['id_name'])){ |
3263 | 3271 | $addrelate[$this->field_defs[$field]['id_name']] = true; |
@@ -3279,15 +3287,15 @@ discard block |
||
3279 | 3287 | { |
3280 | 3288 | if(!empty($filter) && isset($filter[$field]['force_exists']) && $filter[$field]['force_exists']) |
3281 | 3289 | { |
3282 | - if ( isset($filter[$field]['force_default']) ) |
|
3283 | - $ret_array['select'] .= ", {$filter[$field]['force_default']} $field "; |
|
3284 | - else |
|
3285 | - //spaces are a fix for length issue problem with unions. The union only returns the maximum number of characters from the first select statement. |
|
3290 | + if ( isset($filter[$field]['force_default']) ) { |
|
3291 | + $ret_array['select'] .= ", {$filter[$field]['force_default']} $field "; |
|
3292 | + } else { |
|
3293 | + //spaces are a fix for length issue problem with unions. The union only returns the maximum number of characters from the first select statement. |
|
3286 | 3294 | $ret_array['select'] .= ", ' ' $field "; |
3295 | + } |
|
3287 | 3296 | } |
3288 | 3297 | continue; |
3289 | - } |
|
3290 | - else |
|
3298 | + } else |
|
3291 | 3299 | { |
3292 | 3300 | $data = $this->field_defs[$field]; |
3293 | 3301 | } |
@@ -3307,8 +3315,9 @@ discard block |
||
3307 | 3315 | } |
3308 | 3316 | } |
3309 | 3317 | |
3310 | - if (!$process_field) |
|
3311 | - continue; |
|
3318 | + if (!$process_field) { |
|
3319 | + continue; |
|
3320 | + } |
|
3312 | 3321 | } |
3313 | 3322 | |
3314 | 3323 | if( (!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter) )) |
@@ -3387,16 +3396,14 @@ discard block |
||
3387 | 3396 | if(empty($join_type)) |
3388 | 3397 | { |
3389 | 3398 | $params['join_type'] = ' LEFT JOIN '; |
3390 | - } |
|
3391 | - else |
|
3399 | + } else |
|
3392 | 3400 | { |
3393 | 3401 | $params['join_type'] = $join_type; |
3394 | 3402 | } |
3395 | 3403 | if(isset($data['join_name'])) |
3396 | 3404 | { |
3397 | 3405 | $params['join_table_alias'] = $data['join_name']; |
3398 | - } |
|
3399 | - else |
|
3406 | + } else |
|
3400 | 3407 | { |
3401 | 3408 | $params['join_table_alias'] = 'jt' . $jtcount; |
3402 | 3409 | |
@@ -3404,8 +3411,7 @@ discard block |
||
3404 | 3411 | if(isset($data['join_link_name'])) |
3405 | 3412 | { |
3406 | 3413 | $params['join_table_link_alias'] = $data['join_link_name']; |
3407 | - } |
|
3408 | - else |
|
3414 | + } else |
|
3409 | 3415 | { |
3410 | 3416 | $params['join_table_link_alias'] = 'jtl' . $jtcount; |
3411 | 3417 | } |
@@ -3445,8 +3451,7 @@ discard block |
||
3445 | 3451 | if(isset($rel_mod->field_defs['assigned_user_id'])) |
3446 | 3452 | { |
3447 | 3453 | $ret_array['secondary_select'].= " , ". $params['join_table_alias'] . ".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
3448 | - } |
|
3449 | - else |
|
3454 | + } else |
|
3450 | 3455 | { |
3451 | 3456 | if(isset($rel_mod->field_defs['created_by'])) |
3452 | 3457 | { |
@@ -3459,8 +3464,7 @@ discard block |
||
3459 | 3464 | if(isset($data['db_concat_fields'])) |
3460 | 3465 | { |
3461 | 3466 | $ret_array['secondary_select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
3462 | - } |
|
3463 | - else |
|
3467 | + } else |
|
3464 | 3468 | { |
3465 | 3469 | if(!isset($data['relationship_fields'])) |
3466 | 3470 | { |
@@ -3473,7 +3477,9 @@ discard block |
||
3473 | 3477 | } |
3474 | 3478 | $count_used =0; |
3475 | 3479 | foreach($used_join_key as $used_key) { |
3476 | - if($used_key == $join['rel_key']) $count_used++; |
|
3480 | + if($used_key == $join['rel_key']) { |
|
3481 | + $count_used++; |
|
3482 | + } |
|
3477 | 3483 | } |
3478 | 3484 | if($count_used <= 1) {//27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype |
3479 | 3485 | // add rel_key only if it was not aready added |
@@ -3487,7 +3493,9 @@ discard block |
||
3487 | 3493 | { |
3488 | 3494 | foreach($data['relationship_fields'] as $r_name=>$alias_name) |
3489 | 3495 | { |
3490 | - if(!empty( $secondarySelectedFields[$alias_name]))continue; |
|
3496 | + if(!empty( $secondarySelectedFields[$alias_name])) { |
|
3497 | + continue; |
|
3498 | + } |
|
3491 | 3499 | $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'].'.'. $r_name .' ' . $alias_name; |
3492 | 3500 | $secondarySelectedFields[$alias_name] = true; |
3493 | 3501 | } |
@@ -3500,14 +3508,12 @@ discard block |
||
3500 | 3508 | $ret_array['secondary_where'] = $params['join_table_link_alias'] . '.' . $join['rel_key']. "='" .$parentbean->id . "'"; |
3501 | 3509 | } |
3502 | 3510 | } |
3503 | - } |
|
3504 | - else |
|
3511 | + } else |
|
3505 | 3512 | { |
3506 | 3513 | if(isset($data['db_concat_fields'])) |
3507 | 3514 | { |
3508 | 3515 | $ret_array['select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
3509 | - } |
|
3510 | - else |
|
3516 | + } else |
|
3511 | 3517 | { |
3512 | 3518 | $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
3513 | 3519 | } |
@@ -3534,8 +3540,7 @@ discard block |
||
3534 | 3540 | if(isset($rel_mod->field_defs['assigned_user_id'])) |
3535 | 3541 | { |
3536 | 3542 | $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.assigned_user_id ' . $field . '_owner'; |
3537 | - } |
|
3538 | - else |
|
3543 | + } else |
|
3539 | 3544 | { |
3540 | 3545 | $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.created_by ' . $field . '_owner'; |
3541 | 3546 | } |
@@ -3570,20 +3575,22 @@ discard block |
||
3570 | 3575 | $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
3571 | 3576 | |
3572 | 3577 | // For relationship fields replace their alias by the corresponsding link table and r_name |
3573 | - if(isset($data['relationship_fields'])) |
|
3574 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
3578 | + if(isset($data['relationship_fields'])) { |
|
3579 | + foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
3575 | 3580 | { |
3576 | 3581 | $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
3582 | + } |
|
3577 | 3583 | $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
3578 | 3584 | } |
3579 | 3585 | } |
3580 | - }else{ |
|
3586 | + } else{ |
|
3581 | 3587 | $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.'.$data['rname'], $where); |
3582 | 3588 | |
3583 | 3589 | // For relationship fields replace their alias by the corresponsding link table and r_name |
3584 | - if(isset($data['relationship_fields'])) |
|
3585 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
3590 | + if(isset($data['relationship_fields'])) { |
|
3591 | + foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
3586 | 3592 | $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where); |
3593 | + } |
|
3587 | 3594 | } |
3588 | 3595 | if(!$table_joined) |
3589 | 3596 | { |
@@ -3600,8 +3607,7 @@ discard block |
||
3600 | 3607 | if(isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id'])) |
3601 | 3608 | { |
3602 | 3609 | $ret_array['select'] .= ", $this->table_name.assigned_user_id "; |
3603 | - } |
|
3604 | - else if(isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) |
|
3610 | + } else if(isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) |
|
3605 | 3611 | { |
3606 | 3612 | $ret_array['select'] .= ", $this->table_name.created_by "; |
3607 | 3613 | } |
@@ -3623,14 +3629,15 @@ discard block |
||
3623 | 3629 | if($show_deleted == 0) |
3624 | 3630 | { |
3625 | 3631 | $where_auto = "$this->table_name.deleted=0"; |
3626 | - }else if($show_deleted == 1) |
|
3632 | + } else if($show_deleted == 1) |
|
3627 | 3633 | { |
3628 | 3634 | $where_auto = "$this->table_name.deleted=1"; |
3629 | 3635 | } |
3630 | - if($where != "") |
|
3631 | - $ret_array['where'] = " where ($where) AND $where_auto"; |
|
3632 | - else |
|
3633 | - $ret_array['where'] = " where $where_auto"; |
|
3636 | + if($where != "") { |
|
3637 | + $ret_array['where'] = " where ($where) AND $where_auto"; |
|
3638 | + } else { |
|
3639 | + $ret_array['where'] = " where $where_auto"; |
|
3640 | + } |
|
3634 | 3641 | |
3635 | 3642 | //make call to process the order by clause |
3636 | 3643 | $order_by = $this->process_order_by($order_by); |
@@ -3660,8 +3667,9 @@ discard block |
||
3660 | 3667 | if (isset($value['relationship_fields']) && |
3661 | 3668 | in_array($field, $value['relationship_fields']) && |
3662 | 3669 | (!isset($value['link_type']) || $value['link_type'] != 'relationship_info') |
3663 | - ) |
|
3664 | - return $field_def; |
|
3670 | + ) { |
|
3671 | + return $field_def; |
|
3672 | + } |
|
3665 | 3673 | } |
3666 | 3674 | |
3667 | 3675 | return false; |
@@ -3709,24 +3717,23 @@ discard block |
||
3709 | 3717 | if(isset($field_def['db_concat_fields'])) |
3710 | 3718 | { |
3711 | 3719 | $queries[$child_info['parent_type']] .= ' , ' . $this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']) . ' parent_name'; |
3712 | - } |
|
3713 | - else |
|
3720 | + } else |
|
3714 | 3721 | { |
3715 | 3722 | $queries[$child_info['parent_type']] .= ' , name parent_name'; |
3716 | 3723 | } |
3717 | 3724 | if(isset($templates[$child_info['parent_type']]->field_defs['assigned_user_id'])) |
3718 | 3725 | { |
3719 | 3726 | $queries[$child_info['parent_type']] .= ", assigned_user_id parent_name_owner , '{$child_info['parent_type']}' parent_name_mod";; |
3720 | - }else if(isset($templates[$child_info['parent_type']]->field_defs['created_by'])) |
|
3727 | + } else if(isset($templates[$child_info['parent_type']]->field_defs['created_by'])) |
|
3721 | 3728 | { |
3722 | 3729 | $queries[$child_info['parent_type']] .= ", created_by parent_name_owner, '{$child_info['parent_type']}' parent_name_mod"; |
3723 | 3730 | } |
3724 | 3731 | $queries[$child_info['parent_type']] .= " FROM " . $templates[$child_info['parent_type']]->table_name ." WHERE id IN ('{$child_info['parent_id']}'"; |
3725 | - } |
|
3726 | - else |
|
3732 | + } else |
|
3727 | 3733 | { |
3728 | - if(empty($parent_child_map[$child_info['parent_id']])) |
|
3729 | - $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'"; |
|
3734 | + if(empty($parent_child_map[$child_info['parent_id']])) { |
|
3735 | + $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'"; |
|
3736 | + } |
|
3730 | 3737 | } |
3731 | 3738 | $parent_child_map[$child_info['parent_id']][] = $child_info['child_id']; |
3732 | 3739 | } |
@@ -3799,8 +3806,7 @@ discard block |
||
3799 | 3806 | $row_offset = (floor(($rows_found -1) / $limit)) * $limit; |
3800 | 3807 | } |
3801 | 3808 | } |
3802 | - } |
|
3803 | - else |
|
3809 | + } else |
|
3804 | 3810 | { |
3805 | 3811 | if((empty($limit) || $limit == -1)) |
3806 | 3812 | { |
@@ -3817,8 +3823,7 @@ discard block |
||
3817 | 3823 | if(!empty($limit) && $limit != -1 && $limit != -99) |
3818 | 3824 | { |
3819 | 3825 | $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: "); |
3820 | - } |
|
3821 | - else |
|
3826 | + } else |
|
3822 | 3827 | { |
3823 | 3828 | $result = $db->query($query,true,"Error retrieving $this->object_name list: "); |
3824 | 3829 | } |
@@ -3835,7 +3840,9 @@ discard block |
||
3835 | 3840 | while ($max_per_page == -99 || ($index < $row_offset + $max_per_page)) |
3836 | 3841 | { |
3837 | 3842 | $row = $db->fetchByAssoc($result); |
3838 | - if (empty($row)) break; |
|
3843 | + if (empty($row)) { |
|
3844 | + break; |
|
3845 | + } |
|
3839 | 3846 | |
3840 | 3847 | //instantiate a new class each time. This is because php5 passes |
3841 | 3848 | //by reference by default so if we continually update $this, we will |
@@ -3855,11 +3862,10 @@ discard block |
||
3855 | 3862 | } |
3856 | 3863 | |
3857 | 3864 | $GLOBALS['log']->debug("$temp->object_name({$row['id']}): ".$field." = ".$temp->$field); |
3858 | - }else if (isset($row[$this->table_name .'.'.$field])) |
|
3865 | + } else if (isset($row[$this->table_name .'.'.$field])) |
|
3859 | 3866 | { |
3860 | 3867 | $temp->$field = $row[$this->table_name .'.'.$field]; |
3861 | - } |
|
3862 | - else |
|
3868 | + } else |
|
3863 | 3869 | { |
3864 | 3870 | $temp->$field = ""; |
3865 | 3871 | } |
@@ -3867,7 +3873,9 @@ discard block |
||
3867 | 3873 | |
3868 | 3874 | $temp->check_date_relationships_load(); |
3869 | 3875 | $temp->fill_in_additional_list_fields(); |
3870 | - if($temp->hasCustomFields()) $temp->custom_fields->fill_relationships(); |
|
3876 | + if($temp->hasCustomFields()) { |
|
3877 | + $temp->custom_fields->fill_relationships(); |
|
3878 | + } |
|
3871 | 3879 | $temp->call_custom_logic("process_record"); |
3872 | 3880 | |
3873 | 3881 | // fix defect #44206. implement the same logic as sugar_currency_format |
@@ -3914,8 +3922,9 @@ discard block |
||
3914 | 3922 | if (!$is_count_query) |
3915 | 3923 | { |
3916 | 3924 | $count_query = SugarBean::create_list_count_query($query); |
3917 | - } else |
|
3918 | - $count_query=$query; |
|
3925 | + } else { |
|
3926 | + $count_query=$query; |
|
3927 | + } |
|
3919 | 3928 | |
3920 | 3929 | $result = $this->db->query($count_query, true, "Error running count query for $this->object_name List: "); |
3921 | 3930 | $row_num = 0; |
@@ -3988,8 +3997,7 @@ discard block |
||
3988 | 3997 | $row_offset = (floor(($rows_found -1) / $limit)) * $limit; |
3989 | 3998 | |
3990 | 3999 | } |
3991 | - } |
|
3992 | - else |
|
4000 | + } else |
|
3993 | 4001 | { |
3994 | 4002 | if((empty($limit) || $limit == -1)) |
3995 | 4003 | { |
@@ -4011,8 +4019,7 @@ discard block |
||
4011 | 4019 | if(!empty($limit) && $limit != -1 && $limit != -99) |
4012 | 4020 | { |
4013 | 4021 | $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $parent_bean->object_name list: "); |
4014 | - } |
|
4015 | - else |
|
4022 | + } else |
|
4016 | 4023 | { |
4017 | 4024 | $result = $db->query($query,true,"Error retrieving $this->object_name list: "); |
4018 | 4025 | } |
@@ -4058,13 +4065,11 @@ discard block |
||
4058 | 4065 | { |
4059 | 4066 | $current_bean->$field = $this->convertField($row[$field], $value); |
4060 | 4067 | unset($row[$field]); |
4061 | - } |
|
4062 | - else if (isset($row[$this->table_name .'.'.$field])) |
|
4068 | + } else if (isset($row[$this->table_name .'.'.$field])) |
|
4063 | 4069 | { |
4064 | 4070 | $current_bean->$field = $this->convertField($row[$this->table_name .'.'.$field], $value); |
4065 | 4071 | unset($row[$this->table_name .'.'.$field]); |
4066 | - } |
|
4067 | - else |
|
4072 | + } else |
|
4068 | 4073 | { |
4069 | 4074 | $current_bean->$field = ""; |
4070 | 4075 | unset($row[$field]); |
@@ -4088,8 +4093,7 @@ discard block |
||
4088 | 4093 | { |
4089 | 4094 | $execute_function[] = $value['function_class']; |
4090 | 4095 | $execute_function[] = $value['function_name']; |
4091 | - } |
|
4092 | - else |
|
4096 | + } else |
|
4093 | 4097 | { |
4094 | 4098 | $execute_function = $value['function_name']; |
4095 | 4099 | } |
@@ -4102,8 +4106,7 @@ discard block |
||
4102 | 4106 | $can_execute = false; |
4103 | 4107 | } else if($param == '$this') { |
4104 | 4108 | $execute_params[] = $this; |
4105 | - } |
|
4106 | - else |
|
4109 | + } else |
|
4107 | 4110 | { |
4108 | 4111 | $execute_params[] = $this->$param; |
4109 | 4112 | } |
@@ -4114,13 +4117,11 @@ discard block |
||
4114 | 4117 | $can_execute = false; |
4115 | 4118 | } else if($param == '$this') { |
4116 | 4119 | $execute_params[] = $current_bean; |
4117 | - } |
|
4118 | - else |
|
4120 | + } else |
|
4119 | 4121 | { |
4120 | 4122 | $execute_params[] = $current_bean->$param; |
4121 | 4123 | } |
4122 | - } |
|
4123 | - else |
|
4124 | + } else |
|
4124 | 4125 | { |
4125 | 4126 | $can_execute = false; |
4126 | 4127 | } |
@@ -4181,8 +4182,7 @@ discard block |
||
4181 | 4182 | if(isset($post_retrieve)) |
4182 | 4183 | { |
4183 | 4184 | $parent_fields = $this->retrieve_parent_fields($post_retrieve); |
4184 | - } |
|
4185 | - else |
|
4185 | + } else |
|
4186 | 4186 | { |
4187 | 4187 | $parent_fields = array(); |
4188 | 4188 | } |
@@ -4201,8 +4201,7 @@ discard block |
||
4201 | 4201 | $previous_offset++; |
4202 | 4202 | } |
4203 | 4203 | } |
4204 | - } |
|
4205 | - else |
|
4204 | + } else |
|
4206 | 4205 | { |
4207 | 4206 | $row_found = 0; |
4208 | 4207 | $parent_fields = array(); |
@@ -4271,8 +4270,9 @@ discard block |
||
4271 | 4270 | |
4272 | 4271 | $response = Array(); |
4273 | 4272 | $response['bean'] = $this; |
4274 | - if (empty($total_rows)) |
|
4275 | - $total_rows=0; |
|
4273 | + if (empty($total_rows)) { |
|
4274 | + $total_rows=0; |
|
4275 | + } |
|
4276 | 4276 | $response['row_count'] = $total_rows; |
4277 | 4277 | $response['next_offset'] = $next_offset; |
4278 | 4278 | $response['previous_offset'] = $previous_offset; |
@@ -4315,8 +4315,7 @@ discard block |
||
4315 | 4315 | { |
4316 | 4316 | $bean->$field = $row[$field]; |
4317 | 4317 | $GLOBALS['log']->debug("process_full_list: $bean->object_name({$row['id']}): ".$field." = ".$bean->$field); |
4318 | - } |
|
4319 | - else |
|
4318 | + } else |
|
4320 | 4319 | { |
4321 | 4320 | $bean->$field = ''; |
4322 | 4321 | } |
@@ -4333,8 +4332,11 @@ discard block |
||
4333 | 4332 | $list[] = $bean; |
4334 | 4333 | } |
4335 | 4334 | //} |
4336 | - if (isset($list)) return $list; |
|
4337 | - else return null; |
|
4335 | + if (isset($list)) { |
|
4336 | + return $list; |
|
4337 | + } else { |
|
4338 | + return null; |
|
4339 | + } |
|
4338 | 4340 | } |
4339 | 4341 | |
4340 | 4342 | /** |
@@ -4398,10 +4400,12 @@ discard block |
||
4398 | 4400 | $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); |
4399 | 4401 | |
4400 | 4402 | } |
4401 | - if(!empty($this->field_defs['created_by']) && !empty($this->created_by)) |
|
4402 | - $this->created_by_name = get_assigned_user_name($this->created_by); |
|
4403 | - if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) |
|
4404 | - $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
|
4403 | + if(!empty($this->field_defs['created_by']) && !empty($this->created_by)) { |
|
4404 | + $this->created_by_name = get_assigned_user_name($this->created_by); |
|
4405 | + } |
|
4406 | + if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) { |
|
4407 | + $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
|
4408 | + } |
|
4405 | 4409 | |
4406 | 4410 | if(!empty($this->field_defs['parent_name'])){ |
4407 | 4411 | $this->fill_in_additional_parent_fields(); |
@@ -4416,7 +4420,7 @@ discard block |
||
4416 | 4420 | |
4417 | 4421 | if(!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id){ |
4418 | 4422 | return false; |
4419 | - }else{ |
|
4423 | + } else{ |
|
4420 | 4424 | $this->parent_name = ''; |
4421 | 4425 | } |
4422 | 4426 | if(!empty($this->parent_type)) { |
@@ -4446,8 +4450,9 @@ discard block |
||
4446 | 4450 | { |
4447 | 4451 | $list=$this->$linkFieldName->get(); |
4448 | 4452 | $this->$idField = '' ; // match up with null value in $this->populateFromRow() |
4449 | - if (!empty($list)) |
|
4450 | - $this->$idField = $list[0]; |
|
4453 | + if (!empty($list)) { |
|
4454 | + $this->$idField = $list[0]; |
|
4455 | + } |
|
4451 | 4456 | } |
4452 | 4457 | } |
4453 | 4458 | |
@@ -4456,11 +4461,13 @@ discard block |
||
4456 | 4461 | */ |
4457 | 4462 | function fill_in_relationship_fields(){ |
4458 | 4463 | global $fill_in_rel_depth; |
4459 | - if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) |
|
4460 | - $fill_in_rel_depth = 0; |
|
4464 | + if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) { |
|
4465 | + $fill_in_rel_depth = 0; |
|
4466 | + } |
|
4461 | 4467 | |
4462 | - if($fill_in_rel_depth > 1) |
|
4463 | - return; |
|
4468 | + if($fill_in_rel_depth > 1) { |
|
4469 | + return; |
|
4470 | + } |
|
4464 | 4471 | |
4465 | 4472 | $fill_in_rel_depth++; |
4466 | 4473 | |
@@ -4502,13 +4509,13 @@ discard block |
||
4502 | 4509 | } |
4503 | 4510 | if(!empty($this->$id_name) && isset($this->$name)) |
4504 | 4511 | { |
4505 | - if(!isset($field['additionalFields'])) |
|
4506 | - $field['additionalFields'] = array(); |
|
4512 | + if(!isset($field['additionalFields'])) { |
|
4513 | + $field['additionalFields'] = array(); |
|
4514 | + } |
|
4507 | 4515 | if(!empty($field['rname'])) |
4508 | 4516 | { |
4509 | 4517 | $field['additionalFields'][$field['rname']]= $name; |
4510 | - } |
|
4511 | - else |
|
4518 | + } else |
|
4512 | 4519 | { |
4513 | 4520 | $field['additionalFields']['name']= $name; |
4514 | 4521 | } |
@@ -4543,8 +4550,7 @@ discard block |
||
4543 | 4550 | if(isset($_SESSION['show_deleted'])) |
4544 | 4551 | { |
4545 | 4552 | $this->mark_undeleted($id); |
4546 | - } |
|
4547 | - else |
|
4553 | + } else |
|
4548 | 4554 | { |
4549 | 4555 | // call the custom business logic |
4550 | 4556 | $custom_logic_arguments['id'] = $id; |
@@ -4806,8 +4812,7 @@ discard block |
||
4806 | 4812 | if(!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1) |
4807 | 4813 | { |
4808 | 4814 | $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $template->object_name list: "); |
4809 | - } |
|
4810 | - else |
|
4815 | + } else |
|
4811 | 4816 | { |
4812 | 4817 | $result = $db->query($query, true); |
4813 | 4818 | } |
@@ -4876,8 +4881,7 @@ discard block |
||
4876 | 4881 | if (!empty($limit)) |
4877 | 4882 | { |
4878 | 4883 | $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: "); |
4879 | - } |
|
4880 | - else |
|
4884 | + } else |
|
4881 | 4885 | { |
4882 | 4886 | $result = $db->query($query, true); |
4883 | 4887 | } |
@@ -4923,8 +4927,7 @@ discard block |
||
4923 | 4927 | if(empty($ids)) |
4924 | 4928 | { |
4925 | 4929 | $ids = "('" . $row['id'] . "'"; |
4926 | - } |
|
4927 | - else |
|
4930 | + } else |
|
4928 | 4931 | { |
4929 | 4932 | $ids .= ",'" . $row['id'] . "'"; |
4930 | 4933 | } |
@@ -4932,7 +4935,7 @@ discard block |
||
4932 | 4935 | if(empty($ids)) |
4933 | 4936 | { |
4934 | 4937 | $ids = "('')"; |
4935 | - }else{ |
|
4938 | + } else{ |
|
4936 | 4939 | $ids .= ')'; |
4937 | 4940 | } |
4938 | 4941 | |
@@ -5004,10 +5007,12 @@ discard block |
||
5004 | 5007 | if(isset($this->$field)){ |
5005 | 5008 | |
5006 | 5009 | // cn: bug 12270 - sensitive fields being passed arbitrarily in listViews |
5007 | - if(isset($sensitiveFields[$field])) |
|
5008 | - continue; |
|
5009 | - if(!isset($cache[$field])) |
|
5010 | - $cache[$field] = strtoupper($field); |
|
5010 | + if(isset($sensitiveFields[$field])) { |
|
5011 | + continue; |
|
5012 | + } |
|
5013 | + if(!isset($cache[$field])) { |
|
5014 | + $cache[$field] = strtoupper($field); |
|
5015 | + } |
|
5011 | 5016 | |
5012 | 5017 | //Fields hidden by Dependent Fields |
5013 | 5018 | if (isset($value['hidden']) && $value['hidden'] === true) { |
@@ -5024,18 +5029,17 @@ discard block |
||
5024 | 5029 | elseif(!empty($value['options']) && !empty($mod_strings[$value['options']][$this->$field])) |
5025 | 5030 | { |
5026 | 5031 | $return_array[$cache[$field]] = $mod_strings[$value['options']][$this->$field]; |
5027 | - } |
|
5028 | - else{ |
|
5032 | + } else{ |
|
5029 | 5033 | $return_array[$cache[$field]] = $this->$field; |
5030 | 5034 | } |
5031 | 5035 | //end bug 21672 |
5032 | 5036 | // tjy: no need to do this str_replace as the changes in 29994 for ListViewGeneric.tpl for translation handle this now |
5033 | 5037 | // }elseif(!empty($value['type']) && $value['type'] == 'multienum'&& empty($value['function'])){ |
5034 | 5038 | // $return_array[strtoupper($field)] = str_replace('^,^', ', ', $this->$field ); |
5035 | - }elseif(!empty($value['custom_module']) && $value['type'] != 'currency'){ |
|
5039 | + } elseif(!empty($value['custom_module']) && $value['type'] != 'currency'){ |
|
5036 | 5040 | // $this->format_field($value); |
5037 | 5041 | $return_array[$cache[$field]] = $this->$field; |
5038 | - }else{ |
|
5042 | + } else{ |
|
5039 | 5043 | $return_array[$cache[$field]] = $this->$field; |
5040 | 5044 | } |
5041 | 5045 | // handle "Assigned User Name" |
@@ -5154,23 +5158,29 @@ discard block |
||
5154 | 5158 | } |
5155 | 5159 | |
5156 | 5160 | function getRelatedFields($module, $id, $fields, $return_array = false){ |
5157 | - if(empty($GLOBALS['beanList'][$module]))return ''; |
|
5161 | + if(empty($GLOBALS['beanList'][$module])) { |
|
5162 | + return ''; |
|
5163 | + } |
|
5158 | 5164 | $object = BeanFactory::getObjectName($module); |
5159 | 5165 | |
5160 | 5166 | VardefManager::loadVardef($module, $object); |
5161 | - if(empty($GLOBALS['dictionary'][$object]['table']))return ''; |
|
5167 | + if(empty($GLOBALS['dictionary'][$object]['table'])) { |
|
5168 | + return ''; |
|
5169 | + } |
|
5162 | 5170 | $table = $GLOBALS['dictionary'][$object]['table']; |
5163 | 5171 | $query = 'SELECT id'; |
5164 | 5172 | foreach($fields as $field=>$alias){ |
5165 | 5173 | if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])){ |
5166 | 5174 | $query .= ' ,' .$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias ; |
5167 | - }else if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
|
5175 | + } else if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
|
5168 | 5176 | (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || |
5169 | 5177 | $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db")) |
5170 | 5178 | { |
5171 | 5179 | $query .= ' ,' .$table . '.' . $field . ' as ' . $alias; |
5172 | 5180 | } |
5173 | - if(!$return_array)$this->$alias = ''; |
|
5181 | + if(!$return_array) { |
|
5182 | + $this->$alias = ''; |
|
5183 | + } |
|
5174 | 5184 | } |
5175 | 5185 | if($query == 'SELECT id' || empty($id)){ |
5176 | 5186 | return ''; |
@@ -5181,8 +5191,7 @@ discard block |
||
5181 | 5191 | { |
5182 | 5192 | $query .= " , ". $table . ".assigned_user_id owner"; |
5183 | 5193 | |
5184 | - } |
|
5185 | - else if(isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) |
|
5194 | + } else if(isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) |
|
5186 | 5195 | { |
5187 | 5196 | $query .= " , ". $table . ".created_by owner"; |
5188 | 5197 | |
@@ -5218,8 +5227,9 @@ discard block |
||
5218 | 5227 | { |
5219 | 5228 | if(isset($this->field_name_map[$field]) && empty($this->$field)) |
5220 | 5229 | { |
5221 | - if($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum') |
|
5222 | - $this->$field = $field; |
|
5230 | + if($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum') { |
|
5231 | + $this->$field = $field; |
|
5232 | + } |
|
5223 | 5233 | if($this->field_name_map[$field]['type'] == 'date') |
5224 | 5234 | { |
5225 | 5235 | $this->$field = $timedate->to_display_date('1980-07-09'); |
@@ -5294,8 +5304,7 @@ discard block |
||
5294 | 5304 | $query = "INSERT INTO $table (id, ". implode(',', array_keys($relate_values)) . ", date_modified) VALUES ('" . create_guid() . "', " . "'" . implode("', '", $relate_values) . "', ".$date_modified.")" ; |
5295 | 5305 | |
5296 | 5306 | $this->db->query($query, false, "Creating Relationship:" . $query); |
5297 | - } |
|
5298 | - else if ($do_update) |
|
5307 | + } else if ($do_update) |
|
5299 | 5308 | { |
5300 | 5309 | $conds = array(); |
5301 | 5310 | foreach($data_values as $key=>$value) |
@@ -5374,10 +5383,12 @@ discard block |
||
5374 | 5383 | if(!isset($this->processed) || $this->processed == false){ |
5375 | 5384 | //add some logic to ensure we do not get into an infinite loop |
5376 | 5385 | if(!empty($this->logicHookDepth[$event])) { |
5377 | - if($this->logicHookDepth[$event] > $this->max_logic_depth) |
|
5378 | - return; |
|
5379 | - }else |
|
5380 | - $this->logicHookDepth[$event] = 0; |
|
5386 | + if($this->logicHookDepth[$event] > $this->max_logic_depth) { |
|
5387 | + return; |
|
5388 | + } |
|
5389 | + } else { |
|
5390 | + $this->logicHookDepth[$event] = 0; |
|
5391 | + } |
|
5381 | 5392 | |
5382 | 5393 | //we have to put the increment operator here |
5383 | 5394 | //otherwise we may never increase the depth for that event in the case |
@@ -5407,16 +5418,13 @@ discard block |
||
5407 | 5418 | if ($this->custom_fields->avail_fields[$name]['ext1']) |
5408 | 5419 | { |
5409 | 5420 | $realKey = 'ext1'; |
5410 | - } |
|
5411 | - elseif ($this->custom_fields->avail_fields[$name]['ext2']) |
|
5421 | + } elseif ($this->custom_fields->avail_fields[$name]['ext2']) |
|
5412 | 5422 | { |
5413 | 5423 | $realKey = 'ext2'; |
5414 | - } |
|
5415 | - elseif ($this->custom_fields->avail_fields[$name]['ext3']) |
|
5424 | + } elseif ($this->custom_fields->avail_fields[$name]['ext3']) |
|
5416 | 5425 | { |
5417 | 5426 | $realKey = 'ext3'; |
5418 | - } |
|
5419 | - else |
|
5427 | + } else |
|
5420 | 5428 | { |
5421 | 5429 | $GLOBALS['log']->fatal("SUGARBEAN: cannot find Real Key for custom field of type dropdown - cannot return Value."); |
5422 | 5430 | return false; |
@@ -5450,9 +5458,11 @@ discard block |
||
5450 | 5458 | /** |
5451 | 5459 | if($is_owner == 'not_set') |
5452 | 5460 | */ |
5453 | - if($is_owner === 'not_set') //eggsurplus: should be === |
|
5461 | + if($is_owner === 'not_set') { |
|
5462 | + //eggsurplus: should be === |
|
5454 | 5463 | { |
5455 | 5464 | $not_set = true; |
5465 | + } |
|
5456 | 5466 | $is_owner = $this->isOwner($current_user->id); |
5457 | 5467 | } |
5458 | 5468 | // DJM - OBS Customizations - May 2009 |
@@ -5503,8 +5513,9 @@ discard block |
||
5503 | 5513 | // DJM - OBS Customizations - END CHANGE |
5504 | 5514 | } |
5505 | 5515 | //if we don't implent acls return true |
5506 | - if(!$this->bean_implements('ACL')) |
|
5507 | - return true; |
|
5516 | + if(!$this->bean_implements('ACL')) { |
|
5517 | + return true; |
|
5518 | + } |
|
5508 | 5519 | $view = strtolower($view); |
5509 | 5520 | switch ($view) |
5510 | 5521 | { |
@@ -5522,7 +5533,7 @@ discard block |
||
5522 | 5533 | $temp = new $class(); |
5523 | 5534 | if(!empty($this->fetched_row) && !empty($this->fetched_row['id']) && !empty($this->fetched_row['assigned_user_id']) && !empty($this->fetched_row['created_by'])){ |
5524 | 5535 | $temp->populateFromRow($this->fetched_row); |
5525 | - }else{ |
|
5536 | + } else{ |
|
5526 | 5537 | $temp->retrieve($this->id); |
5527 | 5538 | } |
5528 | 5539 | $is_owner = $temp->isOwner($current_user->id); |
@@ -5601,10 +5612,11 @@ discard block |
||
5601 | 5612 | } |
5602 | 5613 | return false; |
5603 | 5614 | } elseif (isset($this->assigned_user_id)) { |
5604 | - if($this->assigned_user_id == $user_id) return true; |
|
5615 | + if($this->assigned_user_id == $user_id) { |
|
5616 | + return true; |
|
5617 | + } |
|
5605 | 5618 | return false; |
5606 | - } |
|
5607 | - else |
|
5619 | + } else |
|
5608 | 5620 | { |
5609 | 5621 | //other wise if there is a created_by that is the owner |
5610 | 5622 | if(isset($this->created_by) && $this->created_by == $user_id) |
@@ -5646,8 +5658,7 @@ discard block |
||
5646 | 5658 | if($this->ACLAccess('DetailView')) |
5647 | 5659 | { |
5648 | 5660 | $array_assign['MAIN'] = 'a'; |
5649 | - } |
|
5650 | - else |
|
5661 | + } else |
|
5651 | 5662 | { |
5652 | 5663 | $array_assign['MAIN'] = 'span'; |
5653 | 5664 | } |
@@ -5666,20 +5677,20 @@ discard block |
||
5666 | 5677 | |
5667 | 5678 | foreach($this->field_defs as $field=>$data) |
5668 | 5679 | { |
5669 | - if( !$dbOnly || !isset($data['source']) || $data['source'] == 'db') |
|
5670 | - if(!$stringOnly || is_string($this->$field)) |
|
5680 | + if( !$dbOnly || !isset($data['source']) || $data['source'] == 'db') { |
|
5681 | + if(!$stringOnly || is_string($this->$field)) |
|
5671 | 5682 | if($upperKeys) |
5672 | 5683 | { |
5673 | 5684 | if(!isset($cache[$field])){ |
5674 | 5685 | $cache[$field] = strtoupper($field); |
5686 | + } |
|
5675 | 5687 | } |
5676 | 5688 | $arr[$cache[$field]] = $this->$field; |
5677 | - } |
|
5678 | - else |
|
5689 | + } else |
|
5679 | 5690 | { |
5680 | 5691 | if(isset($this->$field)){ |
5681 | 5692 | $arr[$field] = $this->$field; |
5682 | - }else{ |
|
5693 | + } else{ |
|
5683 | 5694 | $arr[$field] = ''; |
5684 | 5695 | } |
5685 | 5696 | } |
@@ -5754,7 +5765,9 @@ discard block |
||
5754 | 5765 | |
5755 | 5766 | $this->fill_in_additional_list_fields(); |
5756 | 5767 | |
5757 | - if($this->hasCustomFields())$this->custom_fields->fill_relationships(); |
|
5768 | + if($this->hasCustomFields()) { |
|
5769 | + $this->custom_fields->fill_relationships(); |
|
5770 | + } |
|
5758 | 5771 | $this->call_custom_logic("process_record"); |
5759 | 5772 | } |
5760 | 5773 | |
@@ -5847,7 +5860,10 @@ discard block |
||
5847 | 5860 | */ |
5848 | 5861 | function decrypt_after_retrieve($value) |
5849 | 5862 | { |
5850 | - if(empty($value)) return $value; // no need to decrypt empty |
|
5863 | + if(empty($value)) { |
|
5864 | + return $value; |
|
5865 | + } |
|
5866 | + // no need to decrypt empty |
|
5851 | 5867 | require_once("include/utils/encryption_utils.php"); |
5852 | 5868 | return blowfishDecode($this->getEncryptKey(), $value); |
5853 | 5869 | } |
@@ -5874,16 +5890,14 @@ discard block |
||
5874 | 5890 | $_SESSION['o_lock_save'] = $saveform; |
5875 | 5891 | header('Location: index.php?module=OptimisticLock&action=LockResolve'); |
5876 | 5892 | die(); |
5877 | - } |
|
5878 | - else |
|
5893 | + } else |
|
5879 | 5894 | { |
5880 | 5895 | unset ($_SESSION['o_lock_object']); |
5881 | 5896 | unset ($_SESSION['o_lock_id']); |
5882 | 5897 | unset ($_SESSION['o_lock_dm']); |
5883 | 5898 | } |
5884 | 5899 | } |
5885 | - } |
|
5886 | - else |
|
5900 | + } else |
|
5887 | 5901 | { |
5888 | 5902 | if(isset($_SESSION['o_lock_object'])) { unset ($_SESSION['o_lock_object']); } |
5889 | 5903 | if(isset($_SESSION['o_lock_id'])) { unset ($_SESSION['o_lock_id']); } |
@@ -5898,9 +5912,11 @@ discard block |
||
5898 | 5912 | */ |
5899 | 5913 | private function _sendNotifications($check_notify){ |
5900 | 5914 | if($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true. |
5901 | - && !$this->isOwner($this->created_by) ) // cn: bug 42727 no need to send email to owner (within workflow) |
|
5915 | + && !$this->isOwner($this->created_by) ) { |
|
5916 | + // cn: bug 42727 no need to send email to owner (within workflow) |
|
5902 | 5917 | { |
5903 | 5918 | $admin = new Administration(); |
5919 | + } |
|
5904 | 5920 | $admin->retrieveSettings(); |
5905 | 5921 | $sendNotifications = false; |
5906 | 5922 | |
@@ -5908,13 +5924,11 @@ discard block |
||
5908 | 5924 | { |
5909 | 5925 | $GLOBALS['log']->info("Notifications: user assignment has changed, checking if user receives notifications"); |
5910 | 5926 | $sendNotifications = true; |
5911 | - } |
|
5912 | - elseif(isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1) |
|
5927 | + } elseif(isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1) |
|
5913 | 5928 | { |
5914 | 5929 | // cn: bug 5795 Send Invites failing for Contacts |
5915 | 5930 | $sendNotifications = true; |
5916 | - } |
|
5917 | - else |
|
5931 | + } else |
|
5918 | 5932 | { |
5919 | 5933 | $GLOBALS['log']->info("Notifications: not sending e-mail, notify_on is set to OFF"); |
5920 | 5934 | } |
@@ -6120,8 +6134,7 @@ discard block |
||
6120 | 6134 | !empty($this->field_defs['email_addresses_non_primary']) && $this->field_defs['email_addresses_non_primary']['type'] == 'email') |
6121 | 6135 | { |
6122 | 6136 | return true; |
6123 | - } |
|
6124 | - else |
|
6137 | + } else |
|
6125 | 6138 | { |
6126 | 6139 | return false; |
6127 | 6140 | } |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | { |
106 | 106 | $savedReminderIds = array(); |
107 | 107 | foreach ($remindersData as $reminderData) { |
108 | - if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $reminderData->id = ''; |
|
108 | + if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) { |
|
109 | + $reminderData->id = ''; |
|
110 | + } |
|
109 | 111 | $reminderBean = BeanFactory::getBean('Reminders', $reminderData->id); |
110 | 112 | $reminderBean->popup = $reminderData->popup; |
111 | 113 | $reminderBean->email = $reminderData->email; |
@@ -379,7 +381,9 @@ discard block |
||
379 | 381 | { |
380 | 382 | $ret = ''; |
381 | 383 | for ($i = 0; $i < strlen($timestr); $i++) { |
382 | - if ($timestr[$i] != "'") $ret .= $timestr[$i]; |
|
384 | + if ($timestr[$i] != "'") { |
|
385 | + $ret .= $timestr[$i]; |
|
386 | + } |
|
383 | 387 | } |
384 | 388 | return $ret; |
385 | 389 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -67,14 +69,17 @@ discard block |
||
67 | 69 | { |
68 | 70 | global $timedate; |
69 | 71 | |
70 | - if(empty($options['pbss_date_start'])) |
|
71 | - $options['pbss_date_start'] = $timedate->nowDbDate(); |
|
72 | + if(empty($options['pbss_date_start'])) { |
|
73 | + $options['pbss_date_start'] = $timedate->nowDbDate(); |
|
74 | + } |
|
72 | 75 | |
73 | - if(empty($options['pbss_date_end'])) |
|
74 | - $options['pbss_date_end'] = $timedate->asDbDate($timedate->getNow()->modify("+6 months")); |
|
76 | + if(empty($options['pbss_date_end'])) { |
|
77 | + $options['pbss_date_end'] = $timedate->asDbDate($timedate->getNow()->modify("+6 months")); |
|
78 | + } |
|
75 | 79 | |
76 | - if(empty($options['title'])) |
|
77 | - $options['title'] = translate('LBL_RGraph_PIPELINE_FORM_TITLE', 'Home'); |
|
80 | + if(empty($options['title'])) { |
|
81 | + $options['title'] = translate('LBL_RGraph_PIPELINE_FORM_TITLE', 'Home'); |
|
82 | + } |
|
78 | 83 | |
79 | 84 | parent::__construct($id,$options); |
80 | 85 | } |
@@ -86,11 +91,12 @@ discard block |
||
86 | 91 | { |
87 | 92 | global $app_list_strings; |
88 | 93 | |
89 | - if (!empty($this->pbss_sales_stages) && count($this->pbss_sales_stages) > 0) |
|
90 | - foreach ($this->pbss_sales_stages as $key) |
|
94 | + if (!empty($this->pbss_sales_stages) && count($this->pbss_sales_stages) > 0) { |
|
95 | + foreach ($this->pbss_sales_stages as $key) |
|
91 | 96 | $selected_datax[] = $key; |
92 | - else |
|
93 | - $selected_datax = array_keys($app_list_strings['sales_stage_dom']); |
|
97 | + } else { |
|
98 | + $selected_datax = array_keys($app_list_strings['sales_stage_dom']); |
|
99 | + } |
|
94 | 100 | |
95 | 101 | $this->_searchFields['pbss_sales_stages']['options'] = $app_list_strings['sales_stage_dom']; |
96 | 102 | $this->_searchFields['pbss_sales_stages']['input_name0'] = $selected_datax; |
@@ -265,15 +271,15 @@ discard block |
||
265 | 271 | $datax[$key] = $app_list_strings['sales_stage_dom'][$key]; |
266 | 272 | $selected_datax[] = $key; |
267 | 273 | } |
268 | - } |
|
269 | - else { |
|
274 | + } else { |
|
270 | 275 | $datax = $app_list_strings['sales_stage_dom']; |
271 | 276 | $selected_datax = array_keys($app_list_strings['sales_stage_dom']); |
272 | 277 | } |
273 | 278 | |
274 | 279 | $result = $db->query($query); |
275 | - while($row = $db->fetchByAssoc($result, false)) |
|
276 | - $temp_data[] = $row; |
|
280 | + while($row = $db->fetchByAssoc($result, false)) { |
|
281 | + $temp_data[] = $row; |
|
282 | + } |
|
277 | 283 | |
278 | 284 | // reorder and set the array based on the order of selected_datax |
279 | 285 | foreach($selected_datax as $sales_stage){ |
@@ -348,10 +354,11 @@ discard block |
||
348 | 354 | |
349 | 355 | protected function resizeLabel($label) |
350 | 356 | { |
351 | - if(strlen($label) < $this->maxLabelSizeBeforeTotal) |
|
352 | - return $label; |
|
353 | - else |
|
354 | - return substr($label,0,$this->maxLabelSizeBeforeTotal).$this->labelReplacementString; |
|
357 | + if(strlen($label) < $this->maxLabelSizeBeforeTotal) { |
|
358 | + return $label; |
|
359 | + } else { |
|
360 | + return substr($label,0,$this->maxLabelSizeBeforeTotal).$this->labelReplacementString; |
|
361 | + } |
|
355 | 362 | |
356 | 363 | } |
357 | 364 |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -106,10 +108,11 @@ discard block |
||
106 | 108 | } |
107 | 109 | |
108 | 110 | while($row = $this->db->fetchByAssoc($result)) { |
109 | - if($row['category']."_".$row['name'] == 'ldap_admin_password' || $row['category']."_".$row['name'] == 'proxy_password') |
|
110 | - $this->settings[$row['category']."_".$row['name']] = $this->decrypt_after_retrieve($row['value']); |
|
111 | - else |
|
112 | - $this->settings[$row['category']."_".$row['name']] = $row['value']; |
|
111 | + if($row['category']."_".$row['name'] == 'ldap_admin_password' || $row['category']."_".$row['name'] == 'proxy_password') { |
|
112 | + $this->settings[$row['category']."_".$row['name']] = $this->decrypt_after_retrieve($row['value']); |
|
113 | + } else { |
|
114 | + $this->settings[$row['category']."_".$row['name']] = $row['value']; |
|
115 | + } |
|
113 | 116 | $this->settings[$row['category']] = true; |
114 | 117 | } |
115 | 118 | $this->settings[$category] = true; |
@@ -120,8 +123,9 @@ discard block |
||
120 | 123 | $oe->getSystemMailerSettings(); |
121 | 124 | |
122 | 125 | foreach ($oe->field_defs as $def) { |
123 | - if (strpos($def, "mail_") !== false) |
|
124 | - $this->settings[$def] = $oe->$def; |
|
126 | + if (strpos($def, "mail_") !== false) { |
|
127 | + $this->settings[$def] = $oe->$def; |
|
128 | + } |
|
125 | 129 | } |
126 | 130 | } |
127 | 131 | |
@@ -165,13 +169,13 @@ discard block |
||
165 | 169 | $row = $this->db->fetchByAssoc($result); |
166 | 170 | $row_count = $row['the_count']; |
167 | 171 | |
168 | - if($category."_".$key == 'ldap_admin_password' || $category."_".$key == 'proxy_password') |
|
169 | - $value = $this->encrpyt_before_save($value); |
|
172 | + if($category."_".$key == 'ldap_admin_password' || $category."_".$key == 'proxy_password') { |
|
173 | + $value = $this->encrpyt_before_save($value); |
|
174 | + } |
|
170 | 175 | |
171 | 176 | if( $row_count == 0){ |
172 | 177 | $result = $this->db->query("INSERT INTO config (value, category, name) VALUES ('$value','$category', '$key')"); |
173 | - } |
|
174 | - else{ |
|
178 | + } else{ |
|
175 | 179 | $result = $this->db->query("UPDATE config SET value = '{$value}' WHERE category = '{$category}' AND name = '{$key}'"); |
176 | 180 | } |
177 | 181 | sugar_cache_clear('admin_settings_cache'); |
@@ -75,7 +75,9 @@ discard block |
||
75 | 75 | $vardef['type'] = 'varchar'; |
76 | 76 | } |
77 | 77 | |
78 | - if (isset($vardef['precision'])) unset($vardef['precision']); |
|
78 | + if (isset($vardef['precision'])) { |
|
79 | + unset($vardef['precision']); |
|
80 | + } |
|
79 | 81 | |
80 | 82 | //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user); |
81 | 83 | |
@@ -115,8 +117,9 @@ discard block |
||
115 | 117 | if (isset($vardef['function']) |
116 | 118 | && ($vardef['function'] == 'getEmailAddressWidget' |
117 | 119 | || $vardef['function']['name'] == 'getEmailAddressWidget') |
118 | - ) |
|
119 | - unset($vardef['function']); |
|
120 | + ) { |
|
121 | + unset($vardef['function']); |
|
122 | + } |
|
120 | 123 | |
121 | 124 | if (isset($vardef['name']) && ($vardef['name'] == 'date_modified')) { |
122 | 125 | $vardef['name'] = 'aow_temp_date'; |
@@ -149,8 +152,9 @@ discard block |
||
149 | 152 | } |
150 | 153 | |
151 | 154 | // hack to disable one of the js calls in this control |
152 | - if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) |
|
153 | - $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
|
155 | + if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) { |
|
156 | + $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
|
157 | + } |
|
154 | 158 | |
155 | 159 | |
156 | 160 | |
@@ -186,8 +190,9 @@ discard block |
||
186 | 190 | $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); |
187 | 191 | |
188 | 192 | $fieldlist = array(); |
189 | - if (!isset($focus) || !($focus instanceof SugarBean)) |
|
190 | - require_once($beanFiles[$beanList[$module]]); |
|
193 | + if (!isset($focus) || !($focus instanceof SugarBean)) { |
|
194 | + require_once($beanFiles[$beanList[$module]]); |
|
195 | + } |
|
191 | 196 | $focus = new $beanList[$module]; |
192 | 197 | // create the dropdowns for the parent type fields |
193 | 198 | $vardefFields[$fieldname] = $focus->field_defs[$fieldname]; |
@@ -197,11 +202,13 @@ discard block |
||
197 | 202 | foreach ($vardefFields as $name => $properties) { |
198 | 203 | $fieldlist[$name] = $properties; |
199 | 204 | // fill in enums |
200 | - if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) |
|
201 | - $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
|
205 | + if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) { |
|
206 | + $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
|
207 | + } |
|
202 | 208 | // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings |
203 | - elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) |
|
204 | - $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
|
209 | + elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) { |
|
210 | + $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
|
211 | + } |
|
205 | 212 | } |
206 | 213 | |
207 | 214 | // fill in function return values |
@@ -209,8 +216,9 @@ discard block |
||
209 | 216 | if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') { |
210 | 217 | $function = $fieldlist[$fieldname]['function']['name']; |
211 | 218 | // include various functions required in the various vardefs |
212 | - if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) |
|
213 | - require_once($fieldlist[$fieldname]['function']['include']); |
|
219 | + if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) { |
|
220 | + require_once($fieldlist[$fieldname]['function']['include']); |
|
221 | + } |
|
214 | 222 | $_REQUEST[$fieldname] = $value; |
215 | 223 | $value = $function($focus, $fieldname, $value, $view); |
216 | 224 | |
@@ -308,14 +316,14 @@ discard block |
||
308 | 316 | |
309 | 317 | if ($bean->field_defs[$field]['type'] == "multienum") { |
310 | 318 | $bean->$field = encodeMultienumValue($value); |
311 | - }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
319 | + } else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
312 | 320 | $save_field = $bean->field_defs[$field]['id_name']; |
313 | 321 | $bean->$save_field = $value; |
314 | 322 | if ($bean->field_defs[$field]['type'] == 'parent') { |
315 | 323 | $bean->parent_type = $_REQUEST['parent_type']; |
316 | 324 | $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name |
317 | 325 | } |
318 | - }else{ |
|
326 | + } else{ |
|
319 | 327 | $bean->$field = $value; |
320 | 328 | } |
321 | 329 | |
@@ -450,14 +458,15 @@ discard block |
||
450 | 458 | |
451 | 459 | //To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname |
452 | 460 | $fieldName = 'name';//$vardef['name']; |
453 | - if(!is_null($vardef['rname'])) |
|
454 | - $fieldName = $vardef['rname']; |
|
461 | + if(!is_null($vardef['rname'])) { |
|
462 | + $fieldName = $vardef['rname']; |
|
463 | + } |
|
455 | 464 | |
456 | 465 | if($vardef['ext2']){ |
457 | 466 | |
458 | 467 | $value .= getFieldValueFromModule($fieldName,$vardef['ext2'],$record) . "</a>"; |
459 | 468 | |
460 | - }else if(!empty($vardef['rname'])){ |
|
469 | + } else if(!empty($vardef['rname'])){ |
|
461 | 470 | $value .= getFieldValueFromModule($fieldName,$vardef['module'],$record) . "</a>"; |
462 | 471 | |
463 | 472 | } else { |
@@ -472,8 +481,9 @@ discard block |
||
472 | 481 | function getFieldValueFromModule($fieldname, $module, $id) |
473 | 482 | { |
474 | 483 | //Github bug 880, if the fieldname is null, do no call from bean |
475 | - if(is_null($fieldname)) |
|
476 | - return ''; |
|
484 | + if(is_null($fieldname)) { |
|
485 | + return ''; |
|
486 | + } |
|
477 | 487 | |
478 | 488 | $bean = BeanFactory::getBean($module, $id); |
479 | 489 | if (is_object($bean) && $bean->id != "") { |
@@ -497,7 +507,7 @@ discard block |
||
497 | 507 | |
498 | 508 | if($bean->ACLAccess('EditView')) { |
499 | 509 | return true; |
500 | - }else { |
|
510 | + } else { |
|
501 | 511 | return false; |
502 | 512 | } |
503 | 513 | } |