@@ -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. |
@@ -25,25 +25,25 @@ discard block |
||
| 25 | 25 | class AOR_Chart extends Basic { |
| 26 | 26 | |
| 27 | 27 | var $colours = "['#1f78b4','#a6cee3','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99','#b15928']"; |
| 28 | - var $new_schema = true; |
|
| 29 | - var $module_dir = 'AOR_Charts'; |
|
| 30 | - var $object_name = 'AOR_Chart'; |
|
| 31 | - var $table_name = 'aor_charts'; |
|
| 32 | - var $importable = true; |
|
| 33 | - var $disable_row_level_security = true ; |
|
| 28 | + var $new_schema = true; |
|
| 29 | + var $module_dir = 'AOR_Charts'; |
|
| 30 | + var $object_name = 'AOR_Chart'; |
|
| 31 | + var $table_name = 'aor_charts'; |
|
| 32 | + var $importable = true; |
|
| 33 | + var $disable_row_level_security = true ; |
|
| 34 | 34 | |
| 35 | - var $id; |
|
| 36 | - var $name; |
|
| 37 | - var $date_entered; |
|
| 38 | - var $date_modified; |
|
| 39 | - var $modified_user_id; |
|
| 40 | - var $modified_by_name; |
|
| 41 | - var $created_by; |
|
| 42 | - var $created_by_name; |
|
| 43 | - var $description; |
|
| 44 | - var $deleted; |
|
| 45 | - var $created_by_link; |
|
| 46 | - var $modified_user_link; |
|
| 35 | + var $id; |
|
| 36 | + var $name; |
|
| 37 | + var $date_entered; |
|
| 38 | + var $date_modified; |
|
| 39 | + var $modified_user_id; |
|
| 40 | + var $modified_by_name; |
|
| 41 | + var $created_by; |
|
| 42 | + var $created_by_name; |
|
| 43 | + var $description; |
|
| 44 | + var $deleted; |
|
| 45 | + var $created_by_link; |
|
| 46 | + var $modified_user_link; |
|
| 47 | 47 | |
| 48 | 48 | var $type; |
| 49 | 49 | var $x_field; |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - function AOR_Chart(){ |
|
| 56 | - parent::Basic(); |
|
| 57 | - } |
|
| 55 | + function AOR_Chart(){ |
|
| 56 | + parent::Basic(); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | function save_lines(array $post,AOR_Report $bean,$postKey){ |
| 60 | 60 | $seenIds = array(); |
@@ -1,26 +1,26 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Advanced OpenReports, SugarCRM Reporting. |
|
| 4 | - * @package Advanced OpenReports for SugarCRM |
|
| 5 | - * @copyright SalesAgility Ltd http://www.salesagility.com |
|
| 6 | - * |
|
| 7 | - * This program is free software; you can redistribute it and/or modify |
|
| 8 | - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
| 9 | - * the Free Software Foundation; either version 3 of the License, or |
|
| 10 | - * (at your option) any later version. |
|
| 11 | - * |
|
| 12 | - * This program is distributed in the hope that it will be useful, |
|
| 13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 | - * GNU General Public License for more details. |
|
| 16 | - * |
|
| 17 | - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 18 | - * along with this program; if not, see http://www.gnu.org/licenses |
|
| 19 | - * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
| 20 | - * Fifth Floor, Boston, MA 02110-1301 USA |
|
| 21 | - * |
|
| 22 | - * @author SalesAgility <[email protected]> |
|
| 23 | - */ |
|
| 3 | + * Advanced OpenReports, SugarCRM Reporting. |
|
| 4 | + * @package Advanced OpenReports for SugarCRM |
|
| 5 | + * @copyright SalesAgility Ltd http://www.salesagility.com |
|
| 6 | + * |
|
| 7 | + * This program is free software; you can redistribute it and/or modify |
|
| 8 | + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
| 9 | + * the Free Software Foundation; either version 3 of the License, or |
|
| 10 | + * (at your option) any later version. |
|
| 11 | + * |
|
| 12 | + * This program is distributed in the hope that it will be useful, |
|
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 | + * GNU General Public License for more details. |
|
| 16 | + * |
|
| 17 | + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 18 | + * along with this program; if not, see http://www.gnu.org/licenses |
|
| 19 | + * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
| 20 | + * Fifth Floor, Boston, MA 02110-1301 USA |
|
| 21 | + * |
|
| 22 | + * @author SalesAgility <[email protected]> |
|
| 23 | + */ |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * This file adds support for studio |
@@ -23,66 +23,66 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | $mod_strings = array ( |
| 26 | - 'LBL_ASSIGNED_TO_ID' => 'Assigned User Id', |
|
| 27 | - 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
|
| 28 | - 'LBL_ID' => 'ID', |
|
| 29 | - 'LBL_DATE_ENTERED' => 'Date Created', |
|
| 30 | - 'LBL_DATE_MODIFIED' => 'Date Modified', |
|
| 31 | - 'LBL_MODIFIED' => 'Modified By', |
|
| 32 | - 'LBL_MODIFIED_ID' => 'Modified By Id', |
|
| 33 | - 'LBL_MODIFIED_NAME' => 'Modified By Name', |
|
| 34 | - 'LBL_CREATED' => 'Created By', |
|
| 35 | - 'LBL_CREATED_ID' => 'Created By Id', |
|
| 36 | - 'LBL_DESCRIPTION' => 'Description', |
|
| 37 | - 'LBL_DELETED' => 'Deleted', |
|
| 38 | - 'LBL_NAME' => 'Name', |
|
| 39 | - 'LBL_CREATED_USER' => 'Created by User', |
|
| 40 | - 'LBL_MODIFIED_USER' => 'Modified by User', |
|
| 41 | - 'LBL_LIST_NAME' => 'Name', |
|
| 42 | - 'LBL_EDIT_BUTTON' => 'Edit', |
|
| 43 | - 'LBL_REMOVE' => 'Remove', |
|
| 44 | - 'LBL_LIST_FORM_TITLE' => 'Reports List', |
|
| 45 | - 'LBL_MODULE_NAME' => 'Reports', |
|
| 46 | - 'LBL_MODULE_TITLE' => 'Reports', |
|
| 47 | - 'LBL_HOMEPAGE_TITLE' => 'My Reports', |
|
| 48 | - 'LNK_NEW_RECORD' => 'Create Report', |
|
| 49 | - 'LNK_LIST' => 'View Reports', |
|
| 50 | - 'LNK_IMPORT_AOR_REPORTS' => 'Import Reports', |
|
| 51 | - 'LBL_SEARCH_FORM_TITLE' => 'Search Reports', |
|
| 52 | - 'LBL_HISTORY_SUBPANEL_TITLE' => 'View History', |
|
| 53 | - 'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities', |
|
| 54 | - 'LBL_AOR_REPORTS_SUBPANEL_TITLE' => 'Reports', |
|
| 55 | - 'LBL_NEW_FORM_TITLE' => 'New Reports', |
|
| 56 | - 'LBL_REPORT_MODULE' => 'Report Module', |
|
| 26 | + 'LBL_ASSIGNED_TO_ID' => 'Assigned User Id', |
|
| 27 | + 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
|
| 28 | + 'LBL_ID' => 'ID', |
|
| 29 | + 'LBL_DATE_ENTERED' => 'Date Created', |
|
| 30 | + 'LBL_DATE_MODIFIED' => 'Date Modified', |
|
| 31 | + 'LBL_MODIFIED' => 'Modified By', |
|
| 32 | + 'LBL_MODIFIED_ID' => 'Modified By Id', |
|
| 33 | + 'LBL_MODIFIED_NAME' => 'Modified By Name', |
|
| 34 | + 'LBL_CREATED' => 'Created By', |
|
| 35 | + 'LBL_CREATED_ID' => 'Created By Id', |
|
| 36 | + 'LBL_DESCRIPTION' => 'Description', |
|
| 37 | + 'LBL_DELETED' => 'Deleted', |
|
| 38 | + 'LBL_NAME' => 'Name', |
|
| 39 | + 'LBL_CREATED_USER' => 'Created by User', |
|
| 40 | + 'LBL_MODIFIED_USER' => 'Modified by User', |
|
| 41 | + 'LBL_LIST_NAME' => 'Name', |
|
| 42 | + 'LBL_EDIT_BUTTON' => 'Edit', |
|
| 43 | + 'LBL_REMOVE' => 'Remove', |
|
| 44 | + 'LBL_LIST_FORM_TITLE' => 'Reports List', |
|
| 45 | + 'LBL_MODULE_NAME' => 'Reports', |
|
| 46 | + 'LBL_MODULE_TITLE' => 'Reports', |
|
| 47 | + 'LBL_HOMEPAGE_TITLE' => 'My Reports', |
|
| 48 | + 'LNK_NEW_RECORD' => 'Create Report', |
|
| 49 | + 'LNK_LIST' => 'View Reports', |
|
| 50 | + 'LNK_IMPORT_AOR_REPORTS' => 'Import Reports', |
|
| 51 | + 'LBL_SEARCH_FORM_TITLE' => 'Search Reports', |
|
| 52 | + 'LBL_HISTORY_SUBPANEL_TITLE' => 'View History', |
|
| 53 | + 'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities', |
|
| 54 | + 'LBL_AOR_REPORTS_SUBPANEL_TITLE' => 'Reports', |
|
| 55 | + 'LBL_NEW_FORM_TITLE' => 'New Reports', |
|
| 56 | + 'LBL_REPORT_MODULE' => 'Report Module', |
|
| 57 | 57 | 'LBL_GRAPHS_PER_ROW' => 'Charts per row', |
| 58 | - 'LBL_FIELD_LINES' => 'Display Fields', |
|
| 59 | - 'LBL_ADD_FIELD' => 'Add Field', |
|
| 60 | - 'LBL_CONDITION_LINES' => 'Conditions', |
|
| 61 | - 'LBL_ADD_CONDITION' => 'Add Condition', |
|
| 62 | - 'LBL_EXPORT' => 'Export', |
|
| 63 | - 'LBL_DOWNLOAD_PDF' => 'Download PDF', |
|
| 64 | - 'LBL_ADD_TO_PROSPECT_LIST' => 'Add To Target List', |
|
| 65 | - 'LBL_AOR_MODULETREE_SUBPANEL_TITLE' => 'Module tree', |
|
| 66 | - 'LBL_AOR_FIELDS_SUBPANEL_TITLE' => 'Fields', |
|
| 67 | - 'LBL_AOR_CONDITIONS_SUBPANEL_TITLE' => 'Conditions', |
|
| 68 | - 'LBL_TOTAL' => 'Total', |
|
| 69 | - 'LBL_AOR_CHARTS_SUBPANEL_TITLE' => 'Charts', |
|
| 70 | - 'LBL_ADD_CHART' => 'Add chart', |
|
| 58 | + 'LBL_FIELD_LINES' => 'Display Fields', |
|
| 59 | + 'LBL_ADD_FIELD' => 'Add Field', |
|
| 60 | + 'LBL_CONDITION_LINES' => 'Conditions', |
|
| 61 | + 'LBL_ADD_CONDITION' => 'Add Condition', |
|
| 62 | + 'LBL_EXPORT' => 'Export', |
|
| 63 | + 'LBL_DOWNLOAD_PDF' => 'Download PDF', |
|
| 64 | + 'LBL_ADD_TO_PROSPECT_LIST' => 'Add To Target List', |
|
| 65 | + 'LBL_AOR_MODULETREE_SUBPANEL_TITLE' => 'Module tree', |
|
| 66 | + 'LBL_AOR_FIELDS_SUBPANEL_TITLE' => 'Fields', |
|
| 67 | + 'LBL_AOR_CONDITIONS_SUBPANEL_TITLE' => 'Conditions', |
|
| 68 | + 'LBL_TOTAL' => 'Total', |
|
| 69 | + 'LBL_AOR_CHARTS_SUBPANEL_TITLE' => 'Charts', |
|
| 70 | + 'LBL_ADD_CHART' => 'Add chart', |
|
| 71 | 71 | 'LBL_ADD_PARENTHESIS' => 'Drop parenthesis', |
| 72 | - 'LBL_CHART_TITLE' => 'Title', |
|
| 73 | - 'LBL_CHART_TYPE' => 'Type', |
|
| 74 | - 'LBL_CHART_X_FIELD' => 'X Axis', |
|
| 75 | - 'LBL_CHART_Y_FIELD' => 'Y Axis', |
|
| 76 | - 'LBL_AOR_REPORTS_DASHLET' => 'Reports', |
|
| 77 | - 'LBL_DASHLET_TITLE' => 'Title', |
|
| 78 | - 'LBL_DASHLET_REPORT' => 'Report', |
|
| 79 | - 'LBL_DASHLET_CHOOSE_REPORT' => 'Please choose a report', |
|
| 80 | - 'LBL_DASHLET_SAVE' => 'Save', |
|
| 81 | - 'LBL_DASHLET_CHARTS' => 'Charts', |
|
| 82 | - 'LBL_DASHLET_ONLY_CHARTS' => 'Only show charts', |
|
| 83 | - 'LBL_AOR_SCHEDULED_REPORTS_AOR_REPORTS_FROM_AOR_SCHEDULED_REPORTS_TITLE' => 'Scheduled Reports', |
|
| 84 | - 'LBL_UPDATE_PARAMETERS' => 'Update', |
|
| 85 | - 'LBL_PARAMETERS' => 'Parameters', |
|
| 72 | + 'LBL_CHART_TITLE' => 'Title', |
|
| 73 | + 'LBL_CHART_TYPE' => 'Type', |
|
| 74 | + 'LBL_CHART_X_FIELD' => 'X Axis', |
|
| 75 | + 'LBL_CHART_Y_FIELD' => 'Y Axis', |
|
| 76 | + 'LBL_AOR_REPORTS_DASHLET' => 'Reports', |
|
| 77 | + 'LBL_DASHLET_TITLE' => 'Title', |
|
| 78 | + 'LBL_DASHLET_REPORT' => 'Report', |
|
| 79 | + 'LBL_DASHLET_CHOOSE_REPORT' => 'Please choose a report', |
|
| 80 | + 'LBL_DASHLET_SAVE' => 'Save', |
|
| 81 | + 'LBL_DASHLET_CHARTS' => 'Charts', |
|
| 82 | + 'LBL_DASHLET_ONLY_CHARTS' => 'Only show charts', |
|
| 83 | + 'LBL_AOR_SCHEDULED_REPORTS_AOR_REPORTS_FROM_AOR_SCHEDULED_REPORTS_TITLE' => 'Scheduled Reports', |
|
| 84 | + 'LBL_UPDATE_PARAMETERS' => 'Update', |
|
| 85 | + 'LBL_PARAMETERS' => 'Parameters', |
|
| 86 | 86 | 'LBL_TOOLTIP_DRAG_DROP_ELEMS' => 'Drag and drop elements into field or condition area', |
| 87 | 87 | 'LBL_MAIN_GROUPS' => 'Main Group:', |
| 88 | 88 | ); |
@@ -84,27 +84,27 @@ discard block |
||
| 84 | 84 | public $id; |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * When createing a bean, you can specify a value in the id column as |
|
| 88 | - * long as that value is unique. During save, if the system finds an |
|
| 89 | - * id, it assumes it is an update. Setting new_with_id to true will |
|
| 90 | - * make sure the system performs an insert instead of an update. |
|
| 91 | - * |
|
| 92 | - * @var BOOL -- default false |
|
| 93 | - */ |
|
| 94 | - var $new_with_id = false; |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * How deep logic hooks can go |
|
| 99 | - * @var int |
|
| 100 | - */ |
|
| 101 | - protected $max_logic_depth = 10; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Disble vardefs. This should be set to true only for beans that do not have varders. Tracker is an example |
|
| 105 | - * |
|
| 106 | - * @var BOOL -- default false |
|
| 107 | - */ |
|
| 87 | + * When createing a bean, you can specify a value in the id column as |
|
| 88 | + * long as that value is unique. During save, if the system finds an |
|
| 89 | + * id, it assumes it is an update. Setting new_with_id to true will |
|
| 90 | + * make sure the system performs an insert instead of an update. |
|
| 91 | + * |
|
| 92 | + * @var BOOL -- default false |
|
| 93 | + */ |
|
| 94 | + var $new_with_id = false; |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * How deep logic hooks can go |
|
| 99 | + * @var int |
|
| 100 | + */ |
|
| 101 | + protected $max_logic_depth = 10; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Disble vardefs. This should be set to true only for beans that do not have varders. Tracker is an example |
|
| 105 | + * |
|
| 106 | + * @var BOOL -- default false |
|
| 107 | + */ |
|
| 108 | 108 | var $disable_vardefs = false; |
| 109 | 109 | |
| 110 | 110 | |
@@ -116,20 +116,20 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | var $new_assigned_user_name; |
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * An array of booleans. This array is cleared out when data is loaded. |
|
| 121 | - * As date/times are converted, a "1" is placed under the key, the field is converted. |
|
| 122 | - * |
|
| 123 | - * @var Array of booleans |
|
| 124 | - */ |
|
| 125 | - var $processed_dates_times = array(); |
|
| 119 | + /** |
|
| 120 | + * An array of booleans. This array is cleared out when data is loaded. |
|
| 121 | + * As date/times are converted, a "1" is placed under the key, the field is converted. |
|
| 122 | + * |
|
| 123 | + * @var Array of booleans |
|
| 124 | + */ |
|
| 125 | + var $processed_dates_times = array(); |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Whether to process date/time fields for storage in the database in GMT |
|
| 129 | - * |
|
| 130 | - * @var BOOL |
|
| 131 | - */ |
|
| 132 | - var $process_save_dates =true; |
|
| 127 | + /** |
|
| 128 | + * Whether to process date/time fields for storage in the database in GMT |
|
| 129 | + * |
|
| 130 | + * @var BOOL |
|
| 131 | + */ |
|
| 132 | + var $process_save_dates =true; |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * This signals to the bean that it is being saved in a mass mode. |
@@ -140,20 +140,20 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | var $save_from_post = true; |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * When running a query on related items using the method: retrieve_by_string_fields |
|
| 145 | - * this value will be set to true if more than one item matches the search criteria. |
|
| 146 | - * |
|
| 147 | - * @var BOOL |
|
| 148 | - */ |
|
| 149 | - var $duplicates_found = false; |
|
| 143 | + /** |
|
| 144 | + * When running a query on related items using the method: retrieve_by_string_fields |
|
| 145 | + * this value will be set to true if more than one item matches the search criteria. |
|
| 146 | + * |
|
| 147 | + * @var BOOL |
|
| 148 | + */ |
|
| 149 | + var $duplicates_found = false; |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * true if this bean has been deleted, false otherwise. |
|
| 153 | - * |
|
| 154 | - * @var BOOL |
|
| 155 | - */ |
|
| 156 | - var $deleted = 0; |
|
| 151 | + /** |
|
| 152 | + * true if this bean has been deleted, false otherwise. |
|
| 153 | + * |
|
| 154 | + * @var BOOL |
|
| 155 | + */ |
|
| 156 | + var $deleted = 0; |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * Should the date modified column of the bean be updated during save? |
@@ -201,22 +201,22 @@ discard block |
||
| 201 | 201 | var $table_name = ''; |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * This is the singular name of the bean. (i.e. Contact). |
|
| 205 | - * |
|
| 206 | - * @var String |
|
| 207 | - */ |
|
| 204 | + * This is the singular name of the bean. (i.e. Contact). |
|
| 205 | + * |
|
| 206 | + * @var String |
|
| 207 | + */ |
|
| 208 | 208 | var $object_name = ''; |
| 209 | 209 | |
| 210 | 210 | /** Set this to true if you query contains a sub-select and bean is converting both select statements |
| 211 | - * into count queries. |
|
| 212 | - */ |
|
| 211 | + * into count queries. |
|
| 212 | + */ |
|
| 213 | 213 | var $ungreedy_count=false; |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * The name of the module folder for this type of bean. |
|
| 217 | - * |
|
| 218 | - * @var String |
|
| 219 | - */ |
|
| 216 | + * The name of the module folder for this type of bean. |
|
| 217 | + * |
|
| 218 | + * @var String |
|
| 219 | + */ |
|
| 220 | 220 | var $module_dir = ''; |
| 221 | 221 | var $module_name = ''; |
| 222 | 222 | var $field_name_map; |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | var $importable = false; |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * Set to true in the child beans if the module use the special notification template |
|
| 253 | - */ |
|
| 252 | + * Set to true in the child beans if the module use the special notification template |
|
| 253 | + */ |
|
| 254 | 254 | var $special_notification = false; |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | protected $loaded_relationships = array(); |
| 284 | 284 | |
| 285 | - /** |
|
| 285 | + /** |
|
| 286 | 286 | * set to true if dependent fields updated |
| 287 | 287 | */ |
| 288 | 288 | protected $is_updated_dependent_fields = false; |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | return; |
| 662 | 662 | |
| 663 | 663 | foreach ($this->field_defs as $field => $value) { |
| 664 | - if( !empty($this->$field) |
|
| 664 | + if( !empty($this->$field) |
|
| 665 | 665 | && ((isset($value['default']) && $this->$field == $value['default']) || (!empty($value['display_default']) && $this->$field == $value['display_default'])) |
| 666 | 666 | ) { |
| 667 | 667 | $this->$field = null; |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | $this->$field = $this->parseDateDefault($value['display_default']); |
| 711 | 711 | } |
| 712 | 712 | break; |
| 713 | - case 'datetime': |
|
| 713 | + case 'datetime': |
|
| 714 | 714 | case 'datetimecombo': |
| 715 | 715 | if(!empty($value['display_default'])){ |
| 716 | 716 | $this->$field = $this->parseDateDefault($value['display_default'], true); |
@@ -723,9 +723,9 @@ discard block |
||
| 723 | 723 | $this->$field = $value['default']; |
| 724 | 724 | break; |
| 725 | 725 | case 'bool': |
| 726 | - if(isset($this->$field)){ |
|
| 727 | - break; |
|
| 728 | - } |
|
| 726 | + if(isset($this->$field)){ |
|
| 727 | + break; |
|
| 728 | + } |
|
| 729 | 729 | default: |
| 730 | 730 | if ( isset($value['default']) && $value['default'] !== '' ) { |
| 731 | 731 | $this->$field = htmlentities($value['default'], ENT_QUOTES, 'UTF-8'); |
@@ -788,10 +788,10 @@ discard block |
||
| 788 | 788 | /** |
| 789 | 789 | * This method has been deprecated. |
| 790 | 790 | * |
| 791 | - * @see removeRelationshipMeta() |
|
| 791 | + * @see removeRelationshipMeta() |
|
| 792 | 792 | * @deprecated 4.5.1 - Nov 14, 2006 |
| 793 | 793 | * @static |
| 794 | - */ |
|
| 794 | + */ |
|
| 795 | 795 | static function remove_relationship_meta($key,$db,$log,$tablename,$dictionary,$module_dir) |
| 796 | 796 | { |
| 797 | 797 | SugarBean::removeRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
@@ -927,10 +927,10 @@ discard block |
||
| 927 | 927 | |
| 928 | 928 | /** |
| 929 | 929 | * This method has been deprecated. |
| 930 | - * @see createRelationshipMeta() |
|
| 930 | + * @see createRelationshipMeta() |
|
| 931 | 931 | * @deprecated 4.5.1 - Nov 14, 2006 |
| 932 | 932 | * @static |
| 933 | - */ |
|
| 933 | + */ |
|
| 934 | 934 | static function create_relationship_meta($key,&$db,&$log,$tablename,$dictionary,$module_dir) |
| 935 | 935 | { |
| 936 | 936 | SugarBean::createRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | |
| 1085 | 1085 | $linked_fields=array(); |
| 1086 | 1086 | |
| 1087 | - // require_once('data/Link.php'); |
|
| 1087 | + // require_once('data/Link.php'); |
|
| 1088 | 1088 | |
| 1089 | 1089 | $fieldDefs = $this->getFieldDefinitions(); |
| 1090 | 1090 | |
@@ -1314,8 +1314,8 @@ discard block |
||
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
| 1317 | - * Cleans char, varchar, text, etc. fields of XSS type materials |
|
| 1318 | - */ |
|
| 1317 | + * Cleans char, varchar, text, etc. fields of XSS type materials |
|
| 1318 | + */ |
|
| 1319 | 1319 | function cleanBean() { |
| 1320 | 1320 | foreach($this->field_defs as $key => $def) { |
| 1321 | 1321 | |
@@ -1338,14 +1338,14 @@ discard block |
||
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | /** |
| 1341 | - * Implements a generic insert and update logic for any SugarBean |
|
| 1342 | - * This method only works for subclasses that implement the same variable names. |
|
| 1343 | - * This method uses the presence of an id field that is not null to signify and update. |
|
| 1344 | - * The id field should not be set otherwise. |
|
| 1345 | - * |
|
| 1346 | - * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email. |
|
| 1347 | - * @todo Add support for field type validation and encoding of parameters. |
|
| 1348 | - */ |
|
| 1341 | + * Implements a generic insert and update logic for any SugarBean |
|
| 1342 | + * This method only works for subclasses that implement the same variable names. |
|
| 1343 | + * This method uses the presence of an id field that is not null to signify and update. |
|
| 1344 | + * The id field should not be set otherwise. |
|
| 1345 | + * |
|
| 1346 | + * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email. |
|
| 1347 | + * @todo Add support for field type validation and encoding of parameters. |
|
| 1348 | + */ |
|
| 1349 | 1349 | function save($check_notify = FALSE) |
| 1350 | 1350 | { |
| 1351 | 1351 | $this->in_save = true; |
@@ -1362,14 +1362,14 @@ discard block |
||
| 1362 | 1362 | $isUpdate = false; |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - if ( $this->new_with_id == true ) |
|
| 1366 | - { |
|
| 1367 | - $isUpdate = false; |
|
| 1368 | - } |
|
| 1369 | - if(empty($this->date_modified) || $this->update_date_modified) |
|
| 1370 | - { |
|
| 1371 | - $this->date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 1372 | - } |
|
| 1365 | + if ( $this->new_with_id == true ) |
|
| 1366 | + { |
|
| 1367 | + $isUpdate = false; |
|
| 1368 | + } |
|
| 1369 | + if(empty($this->date_modified) || $this->update_date_modified) |
|
| 1370 | + { |
|
| 1371 | + $this->date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 1372 | + } |
|
| 1373 | 1373 | |
| 1374 | 1374 | $this->_checkOptimisticLocking($action, $isUpdate); |
| 1375 | 1375 | |
@@ -1483,10 +1483,10 @@ discard block |
||
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | |
| 1486 | - /* BEGIN - SECURITY GROUPS - inheritance */ |
|
| 1487 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 1488 | - SecurityGroup::inherit($this,$isUpdate); |
|
| 1489 | - /* END - SECURITY GROUPS */ |
|
| 1486 | + /* BEGIN - SECURITY GROUPS - inheritance */ |
|
| 1487 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 1488 | + SecurityGroup::inherit($this,$isUpdate); |
|
| 1489 | + /* END - SECURITY GROUPS */ |
|
| 1490 | 1490 | //If we aren't in setup mode and we have a current user and module, then we track |
| 1491 | 1491 | if(isset($GLOBALS['current_user']) && isset($this->module_dir)) |
| 1492 | 1492 | { |
@@ -1527,8 +1527,8 @@ discard block |
||
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | /** |
| 1530 | - * Determines which users receive a notification |
|
| 1531 | - */ |
|
| 1530 | + * Determines which users receive a notification |
|
| 1531 | + */ |
|
| 1532 | 1532 | function get_notification_recipients() { |
| 1533 | 1533 | $notify_user = new User(); |
| 1534 | 1534 | $notify_user->retrieve($this->assigned_user_id); |
@@ -1545,11 +1545,11 @@ discard block |
||
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | /** |
| 1548 | - * Handles sending out email notifications when items are first assigned to users |
|
| 1549 | - * |
|
| 1550 | - * @param string $notify_user user to notify |
|
| 1551 | - * @param string $admin the admin user that sends out the notification |
|
| 1552 | - */ |
|
| 1548 | + * Handles sending out email notifications when items are first assigned to users |
|
| 1549 | + * |
|
| 1550 | + * @param string $notify_user user to notify |
|
| 1551 | + * @param string $admin the admin user that sends out the notification |
|
| 1552 | + */ |
|
| 1553 | 1553 | function send_assignment_notifications($notify_user, $admin) |
| 1554 | 1554 | { |
| 1555 | 1555 | global $current_user; |
@@ -1580,7 +1580,7 @@ discard block |
||
| 1580 | 1580 | $notify_mail->FromName = $from_name; |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | - $oe = new OutboundEmail(); |
|
| 1583 | + $oe = new OutboundEmail(); |
|
| 1584 | 1584 | $oe = $oe->getUserMailerSettings($current_user); |
| 1585 | 1585 | //only send if smtp server is defined |
| 1586 | 1586 | if($sendEmail){ |
@@ -1616,9 +1616,9 @@ discard block |
||
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | /** |
| 1619 | - * This function handles create the email notifications email. |
|
| 1620 | - * @param string $notify_user the user to send the notification email to |
|
| 1621 | - */ |
|
| 1619 | + * This function handles create the email notifications email. |
|
| 1620 | + * @param string $notify_user the user to send the notification email to |
|
| 1621 | + */ |
|
| 1622 | 1622 | function create_notification_email($notify_user) { |
| 1623 | 1623 | global $sugar_version; |
| 1624 | 1624 | global $sugar_config; |
@@ -2027,104 +2027,104 @@ discard block |
||
| 2027 | 2027 | } |
| 2028 | 2028 | |
| 2029 | 2029 | /** |
| 2030 | - * This function retrieves a record of the appropriate type from the DB. |
|
| 2031 | - * It fills in all of the fields from the DB into the object it was called on. |
|
| 2032 | - * |
|
| 2033 | - * @param $id - If ID is specified, it overrides the current value of $this->id. If not specified the current value of $this->id will be used. |
|
| 2034 | - * @return this - The object that it was called apon or null if exactly 1 record was not found. |
|
| 2035 | - * |
|
| 2036 | - */ |
|
| 2037 | - |
|
| 2038 | - function check_date_relationships_load() |
|
| 2039 | - { |
|
| 2040 | - global $disable_date_format; |
|
| 2041 | - global $timedate; |
|
| 2042 | - if (empty($timedate)) |
|
| 2043 | - $timedate=TimeDate::getInstance(); |
|
| 2044 | - |
|
| 2045 | - if(empty($this->field_defs)) |
|
| 2046 | - { |
|
| 2047 | - return; |
|
| 2048 | - } |
|
| 2049 | - foreach($this->field_defs as $fieldDef) |
|
| 2050 | - { |
|
| 2051 | - $field = $fieldDef['name']; |
|
| 2052 | - if(!isset($this->processed_dates_times[$field])) |
|
| 2053 | - { |
|
| 2054 | - $this->processed_dates_times[$field] = '1'; |
|
| 2055 | - if(empty($this->$field)) continue; |
|
| 2056 | - if($field == 'date_modified' || $field == 'date_entered') |
|
| 2057 | - { |
|
| 2058 | - $this->$field = $this->db->fromConvert($this->$field, 'datetime'); |
|
| 2059 | - if(empty($disable_date_format)) { |
|
| 2060 | - $this->$field = $timedate->to_display_date_time($this->$field); |
|
| 2061 | - } |
|
| 2062 | - } |
|
| 2063 | - elseif(isset($this->field_name_map[$field]['type'])) |
|
| 2064 | - { |
|
| 2065 | - $type = $this->field_name_map[$field]['type']; |
|
| 2066 | - |
|
| 2067 | - if($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
| 2068 | - { |
|
| 2069 | - $type = $this->field_name_map[$field]['type']; |
|
| 2070 | - } |
|
| 2071 | - |
|
| 2072 | - if($type == 'date') |
|
| 2073 | - { |
|
| 2074 | - if($this->$field == '0000-00-00') |
|
| 2075 | - { |
|
| 2076 | - $this->$field = ''; |
|
| 2077 | - } elseif(!empty($this->field_name_map[$field]['rel_field'])) |
|
| 2078 | - { |
|
| 2079 | - $rel_field = $this->field_name_map[$field]['rel_field']; |
|
| 2080 | - |
|
| 2081 | - if(!empty($this->$rel_field)) |
|
| 2082 | - { |
|
| 2083 | - if(empty($disable_date_format)) { |
|
| 2084 | - $mergetime = $timedate->merge_date_time($this->$field,$this->$rel_field); |
|
| 2085 | - $this->$field = $timedate->to_display_date($mergetime); |
|
| 2086 | - $this->$rel_field = $timedate->to_display_time($mergetime); |
|
| 2087 | - } |
|
| 2088 | - } |
|
| 2089 | - } |
|
| 2090 | - else |
|
| 2091 | - { |
|
| 2092 | - if(empty($disable_date_format)) { |
|
| 2093 | - $this->$field = $timedate->to_display_date($this->$field, false); |
|
| 2094 | - } |
|
| 2095 | - } |
|
| 2096 | - } elseif($type == 'datetime' || $type == 'datetimecombo') |
|
| 2097 | - { |
|
| 2098 | - if($this->$field == '0000-00-00 00:00:00') |
|
| 2099 | - { |
|
| 2100 | - $this->$field = ''; |
|
| 2101 | - } |
|
| 2102 | - else |
|
| 2103 | - { |
|
| 2104 | - if(empty($disable_date_format)) { |
|
| 2105 | - $this->$field = $timedate->to_display_date_time($this->$field, true, true); |
|
| 2106 | - } |
|
| 2107 | - } |
|
| 2108 | - } elseif($type == 'time') |
|
| 2109 | - { |
|
| 2110 | - if($this->$field == '00:00:00') |
|
| 2111 | - { |
|
| 2112 | - $this->$field = ''; |
|
| 2113 | - } else |
|
| 2114 | - { |
|
| 2115 | - //$this->$field = from_db_convert($this->$field, 'time'); |
|
| 2116 | - if(empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
| 2117 | - { |
|
| 2118 | - $this->$field = $timedate->to_display_time($this->$field,true, false); |
|
| 2119 | - } |
|
| 2120 | - } |
|
| 2121 | - } elseif($type == 'encrypt' && empty($disable_date_format)){ |
|
| 2122 | - $this->$field = $this->decrypt_after_retrieve($this->$field); |
|
| 2123 | - } |
|
| 2124 | - } |
|
| 2125 | - } |
|
| 2126 | - } |
|
| 2127 | - } |
|
| 2030 | + * This function retrieves a record of the appropriate type from the DB. |
|
| 2031 | + * It fills in all of the fields from the DB into the object it was called on. |
|
| 2032 | + * |
|
| 2033 | + * @param $id - If ID is specified, it overrides the current value of $this->id. If not specified the current value of $this->id will be used. |
|
| 2034 | + * @return this - The object that it was called apon or null if exactly 1 record was not found. |
|
| 2035 | + * |
|
| 2036 | + */ |
|
| 2037 | + |
|
| 2038 | + function check_date_relationships_load() |
|
| 2039 | + { |
|
| 2040 | + global $disable_date_format; |
|
| 2041 | + global $timedate; |
|
| 2042 | + if (empty($timedate)) |
|
| 2043 | + $timedate=TimeDate::getInstance(); |
|
| 2044 | + |
|
| 2045 | + if(empty($this->field_defs)) |
|
| 2046 | + { |
|
| 2047 | + return; |
|
| 2048 | + } |
|
| 2049 | + foreach($this->field_defs as $fieldDef) |
|
| 2050 | + { |
|
| 2051 | + $field = $fieldDef['name']; |
|
| 2052 | + if(!isset($this->processed_dates_times[$field])) |
|
| 2053 | + { |
|
| 2054 | + $this->processed_dates_times[$field] = '1'; |
|
| 2055 | + if(empty($this->$field)) continue; |
|
| 2056 | + if($field == 'date_modified' || $field == 'date_entered') |
|
| 2057 | + { |
|
| 2058 | + $this->$field = $this->db->fromConvert($this->$field, 'datetime'); |
|
| 2059 | + if(empty($disable_date_format)) { |
|
| 2060 | + $this->$field = $timedate->to_display_date_time($this->$field); |
|
| 2061 | + } |
|
| 2062 | + } |
|
| 2063 | + elseif(isset($this->field_name_map[$field]['type'])) |
|
| 2064 | + { |
|
| 2065 | + $type = $this->field_name_map[$field]['type']; |
|
| 2066 | + |
|
| 2067 | + if($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
| 2068 | + { |
|
| 2069 | + $type = $this->field_name_map[$field]['type']; |
|
| 2070 | + } |
|
| 2071 | + |
|
| 2072 | + if($type == 'date') |
|
| 2073 | + { |
|
| 2074 | + if($this->$field == '0000-00-00') |
|
| 2075 | + { |
|
| 2076 | + $this->$field = ''; |
|
| 2077 | + } elseif(!empty($this->field_name_map[$field]['rel_field'])) |
|
| 2078 | + { |
|
| 2079 | + $rel_field = $this->field_name_map[$field]['rel_field']; |
|
| 2080 | + |
|
| 2081 | + if(!empty($this->$rel_field)) |
|
| 2082 | + { |
|
| 2083 | + if(empty($disable_date_format)) { |
|
| 2084 | + $mergetime = $timedate->merge_date_time($this->$field,$this->$rel_field); |
|
| 2085 | + $this->$field = $timedate->to_display_date($mergetime); |
|
| 2086 | + $this->$rel_field = $timedate->to_display_time($mergetime); |
|
| 2087 | + } |
|
| 2088 | + } |
|
| 2089 | + } |
|
| 2090 | + else |
|
| 2091 | + { |
|
| 2092 | + if(empty($disable_date_format)) { |
|
| 2093 | + $this->$field = $timedate->to_display_date($this->$field, false); |
|
| 2094 | + } |
|
| 2095 | + } |
|
| 2096 | + } elseif($type == 'datetime' || $type == 'datetimecombo') |
|
| 2097 | + { |
|
| 2098 | + if($this->$field == '0000-00-00 00:00:00') |
|
| 2099 | + { |
|
| 2100 | + $this->$field = ''; |
|
| 2101 | + } |
|
| 2102 | + else |
|
| 2103 | + { |
|
| 2104 | + if(empty($disable_date_format)) { |
|
| 2105 | + $this->$field = $timedate->to_display_date_time($this->$field, true, true); |
|
| 2106 | + } |
|
| 2107 | + } |
|
| 2108 | + } elseif($type == 'time') |
|
| 2109 | + { |
|
| 2110 | + if($this->$field == '00:00:00') |
|
| 2111 | + { |
|
| 2112 | + $this->$field = ''; |
|
| 2113 | + } else |
|
| 2114 | + { |
|
| 2115 | + //$this->$field = from_db_convert($this->$field, 'time'); |
|
| 2116 | + if(empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
| 2117 | + { |
|
| 2118 | + $this->$field = $timedate->to_display_time($this->$field,true, false); |
|
| 2119 | + } |
|
| 2120 | + } |
|
| 2121 | + } elseif($type == 'encrypt' && empty($disable_date_format)){ |
|
| 2122 | + $this->$field = $this->decrypt_after_retrieve($this->$field); |
|
| 2123 | + } |
|
| 2124 | + } |
|
| 2125 | + } |
|
| 2126 | + } |
|
| 2127 | + } |
|
| 2128 | 2128 | |
| 2129 | 2129 | /** |
| 2130 | 2130 | * This function processes the fields before save. |
@@ -2136,21 +2136,21 @@ discard block |
||
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | 2138 | /** |
| 2139 | - * Removes formatting from values posted from the user interface. |
|
| 2139 | + * Removes formatting from values posted from the user interface. |
|
| 2140 | 2140 | * It only unformats numbers. Function relies on user/system prefernce for format strings. |
| 2141 | 2141 | * |
| 2142 | 2142 | * Internal Function, do not override. |
| 2143 | - */ |
|
| 2143 | + */ |
|
| 2144 | 2144 | function unformat_all_fields() |
| 2145 | 2145 | { |
| 2146 | 2146 | $GLOBALS['log']->deprecated('SugarBean.php: unformat_all_fields() is deprecated'); |
| 2147 | 2147 | } |
| 2148 | 2148 | |
| 2149 | 2149 | /** |
| 2150 | - * This functions adds formatting to all number fields before presenting them to user interface. |
|
| 2150 | + * This functions adds formatting to all number fields before presenting them to user interface. |
|
| 2151 | 2151 | * |
| 2152 | 2152 | * Internal function, do not override. |
| 2153 | - */ |
|
| 2153 | + */ |
|
| 2154 | 2154 | function format_all_fields() |
| 2155 | 2155 | { |
| 2156 | 2156 | $GLOBALS['log']->deprecated('SugarBean.php: format_all_fields() is deprecated'); |
@@ -2190,8 +2190,8 @@ discard block |
||
| 2190 | 2190 | case 'datetimecombo': |
| 2191 | 2191 | if(empty($this->$field)) break; |
| 2192 | 2192 | if ($this->$field == 'NULL') { |
| 2193 | - $this->$field = ''; |
|
| 2194 | - break; |
|
| 2193 | + $this->$field = ''; |
|
| 2194 | + break; |
|
| 2195 | 2195 | } |
| 2196 | 2196 | if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/',$this->$field) ) { |
| 2197 | 2197 | // This appears to be formatted in user date/time |
@@ -2202,8 +2202,8 @@ discard block |
||
| 2202 | 2202 | case 'date': |
| 2203 | 2203 | if(empty($this->$field)) break; |
| 2204 | 2204 | if ($this->$field == 'NULL') { |
| 2205 | - $this->$field = ''; |
|
| 2206 | - break; |
|
| 2205 | + $this->$field = ''; |
|
| 2206 | + break; |
|
| 2207 | 2207 | } |
| 2208 | 2208 | if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$this->$field) ) { |
| 2209 | 2209 | // This date appears to be formatted in the user's format |
@@ -2214,8 +2214,8 @@ discard block |
||
| 2214 | 2214 | case 'time': |
| 2215 | 2215 | if(empty($this->$field)) break; |
| 2216 | 2216 | if ($this->$field == 'NULL') { |
| 2217 | - $this->$field = ''; |
|
| 2218 | - break; |
|
| 2217 | + $this->$field = ''; |
|
| 2218 | + break; |
|
| 2219 | 2219 | } |
| 2220 | 2220 | if ( preg_match('/(am|pm)/i',$this->$field) ) { |
| 2221 | 2221 | // This time appears to be formatted in the user's format |
@@ -2235,7 +2235,7 @@ discard block |
||
| 2235 | 2235 | $reformatted = true; |
| 2236 | 2236 | } |
| 2237 | 2237 | break; |
| 2238 | - case 'uint': |
|
| 2238 | + case 'uint': |
|
| 2239 | 2239 | case 'ulong': |
| 2240 | 2240 | case 'long': |
| 2241 | 2241 | case 'short': |
@@ -2248,21 +2248,21 @@ discard block |
||
| 2248 | 2248 | $this->$field = (int)unformat_number($this->$field); |
| 2249 | 2249 | $reformatted = true; |
| 2250 | 2250 | } |
| 2251 | - break; |
|
| 2252 | - case 'bool': |
|
| 2251 | + break; |
|
| 2252 | + case 'bool': |
|
| 2253 | 2253 | if (empty($this->$field)) { |
| 2254 | - $this->$field = false; |
|
| 2255 | - } else if(true === $this->$field || 1 == $this->$field) { |
|
| 2256 | - $this->$field = true; |
|
| 2257 | - } else if(in_array(strval($this->$field), $boolean_false_values)) { |
|
| 2258 | - $this->$field = false; |
|
| 2259 | - $reformatted = true; |
|
| 2260 | - } else { |
|
| 2261 | - $this->$field = true; |
|
| 2262 | - $reformatted = true; |
|
| 2263 | - } |
|
| 2264 | - break; |
|
| 2265 | - case 'encrypt': |
|
| 2254 | + $this->$field = false; |
|
| 2255 | + } else if(true === $this->$field || 1 == $this->$field) { |
|
| 2256 | + $this->$field = true; |
|
| 2257 | + } else if(in_array(strval($this->$field), $boolean_false_values)) { |
|
| 2258 | + $this->$field = false; |
|
| 2259 | + $reformatted = true; |
|
| 2260 | + } else { |
|
| 2261 | + $this->$field = true; |
|
| 2262 | + $reformatted = true; |
|
| 2263 | + } |
|
| 2264 | + break; |
|
| 2265 | + case 'encrypt': |
|
| 2266 | 2266 | $this->$field = $this->encrpyt_before_save($this->$field); |
| 2267 | 2267 | break; |
| 2268 | 2268 | } |
@@ -2284,7 +2284,7 @@ discard block |
||
| 2284 | 2284 | * @param boolean $deleted Optional, default true, if set to false deleted filter will not be added. |
| 2285 | 2285 | * |
| 2286 | 2286 | * Internal function, do not override. |
| 2287 | - */ |
|
| 2287 | + */ |
|
| 2288 | 2288 | function retrieve($id = -1, $encode=true,$deleted=true) |
| 2289 | 2289 | { |
| 2290 | 2290 | |
@@ -2340,18 +2340,18 @@ discard block |
||
| 2340 | 2340 | $this->custom_fields->fill_relationships(); |
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | - $this->is_updated_dependent_fields = false; |
|
| 2343 | + $this->is_updated_dependent_fields = false; |
|
| 2344 | 2344 | $this->fill_in_additional_detail_fields(); |
| 2345 | 2345 | $this->fill_in_relationship_fields(); |
| 2346 | 2346 | // save related fields values for audit |
| 2347 | - foreach ($this->get_related_fields() as $rel_field_name) |
|
| 2348 | - { |
|
| 2349 | - $field_name = $rel_field_name['name']; |
|
| 2350 | - if (! empty($this->$field_name)) |
|
| 2351 | - { |
|
| 2352 | - $this->fetched_rel_row[$rel_field_name['name']] = $this->$field_name; |
|
| 2353 | - } |
|
| 2354 | - } |
|
| 2347 | + foreach ($this->get_related_fields() as $rel_field_name) |
|
| 2348 | + { |
|
| 2349 | + $field_name = $rel_field_name['name']; |
|
| 2350 | + if (! empty($this->$field_name)) |
|
| 2351 | + { |
|
| 2352 | + $this->fetched_rel_row[$rel_field_name['name']] = $this->$field_name; |
|
| 2353 | + } |
|
| 2354 | + } |
|
| 2355 | 2355 | //make a copy of fields in the relationship_fields array. These field values will be used to |
| 2356 | 2356 | //clear relationship. |
| 2357 | 2357 | foreach ( $this->field_defs as $key => $def ) |
@@ -2364,7 +2364,7 @@ discard block |
||
| 2364 | 2364 | } |
| 2365 | 2365 | else |
| 2366 | 2366 | $this->rel_fields_before_value[$key]=null; |
| 2367 | - } |
|
| 2367 | + } |
|
| 2368 | 2368 | } |
| 2369 | 2369 | if (isset($this->relationship_fields) && is_array($this->relationship_fields)) |
| 2370 | 2370 | { |
@@ -2419,14 +2419,14 @@ discard block |
||
| 2419 | 2419 | |
| 2420 | 2420 | |
| 2421 | 2421 | /** |
| 2422 | - * Add any required joins to the list count query. The joins are required if there |
|
| 2423 | - * is a field in the $where clause that needs to be joined. |
|
| 2424 | - * |
|
| 2425 | - * @param string $query |
|
| 2426 | - * @param string $where |
|
| 2427 | - * |
|
| 2428 | - * Internal Function, do Not override. |
|
| 2429 | - */ |
|
| 2422 | + * Add any required joins to the list count query. The joins are required if there |
|
| 2423 | + * is a field in the $where clause that needs to be joined. |
|
| 2424 | + * |
|
| 2425 | + * @param string $query |
|
| 2426 | + * @param string $where |
|
| 2427 | + * |
|
| 2428 | + * Internal Function, do Not override. |
|
| 2429 | + */ |
|
| 2430 | 2430 | function add_list_count_joins(&$query, $where) |
| 2431 | 2431 | { |
| 2432 | 2432 | $custom_join = $this->getCustomJoin(); |
@@ -2435,15 +2435,15 @@ discard block |
||
| 2435 | 2435 | } |
| 2436 | 2436 | |
| 2437 | 2437 | /** |
| 2438 | - * Changes the select expression of the given query to be 'count(*)' so you |
|
| 2439 | - * can get the number of items the query will return. This is used to |
|
| 2440 | - * populate the upper limit on ListViews. |
|
| 2438 | + * Changes the select expression of the given query to be 'count(*)' so you |
|
| 2439 | + * can get the number of items the query will return. This is used to |
|
| 2440 | + * populate the upper limit on ListViews. |
|
| 2441 | 2441 | * |
| 2442 | 2442 | * @param string $query Select query string |
| 2443 | 2443 | * @return string count query |
| 2444 | 2444 | * |
| 2445 | 2445 | * Internal function, do not override. |
| 2446 | - */ |
|
| 2446 | + */ |
|
| 2447 | 2447 | function create_list_count_query($query) |
| 2448 | 2448 | { |
| 2449 | 2449 | // remove the 'order by' clause which is expected to be at the end of the query |
@@ -2496,21 +2496,21 @@ discard block |
||
| 2496 | 2496 | } |
| 2497 | 2497 | |
| 2498 | 2498 | /** |
| 2499 | - * This function returns a paged list of the current object type. It is intended to allow for |
|
| 2500 | - * hopping back and forth through pages of data. It only retrieves what is on the current page. |
|
| 2501 | - * |
|
| 2502 | - * @internal This method must be called on a new instance. It trashes the values of all the fields in the current one. |
|
| 2503 | - * @param string $order_by |
|
| 2504 | - * @param string $where Additional where clause |
|
| 2505 | - * @param int $row_offset Optaional,default 0, starting row number |
|
| 2506 | - * @param init $limit Optional, default -1 |
|
| 2507 | - * @param int $max Optional, default -1 |
|
| 2508 | - * @param boolean $show_deleted Optional, default 0, if set to 1 system will show deleted records. |
|
| 2509 | - * @return array Fetched data. |
|
| 2510 | - * |
|
| 2511 | - * Internal function, do not override. |
|
| 2512 | - * |
|
| 2513 | - */ |
|
| 2499 | + * This function returns a paged list of the current object type. It is intended to allow for |
|
| 2500 | + * hopping back and forth through pages of data. It only retrieves what is on the current page. |
|
| 2501 | + * |
|
| 2502 | + * @internal This method must be called on a new instance. It trashes the values of all the fields in the current one. |
|
| 2503 | + * @param string $order_by |
|
| 2504 | + * @param string $where Additional where clause |
|
| 2505 | + * @param int $row_offset Optaional,default 0, starting row number |
|
| 2506 | + * @param init $limit Optional, default -1 |
|
| 2507 | + * @param int $max Optional, default -1 |
|
| 2508 | + * @param boolean $show_deleted Optional, default 0, if set to 1 system will show deleted records. |
|
| 2509 | + * @return array Fetched data. |
|
| 2510 | + * |
|
| 2511 | + * Internal function, do not override. |
|
| 2512 | + * |
|
| 2513 | + */ |
|
| 2514 | 2514 | function get_list($order_by = "", $where = "", $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0, $singleSelect=false, $select_fields = array()) |
| 2515 | 2515 | { |
| 2516 | 2516 | $GLOBALS['log']->debug("get_list: order_by = '$order_by' and where = '$where' and limit = '$limit'"); |
@@ -2540,15 +2540,15 @@ discard block |
||
| 2540 | 2540 | } |
| 2541 | 2541 | |
| 2542 | 2542 | /** |
| 2543 | - * Prefixes column names with this bean's table name. |
|
| 2544 | - * |
|
| 2545 | - * @param string $order_by Order by clause to be processed |
|
| 2546 | - * @param SugarBean $submodule name of the module this order by clause is for |
|
| 2547 | - * @param boolean $suppress_table_name Whether table name should be suppressed |
|
| 2548 | - * @return string Processed order by clause |
|
| 2549 | - * |
|
| 2550 | - * Internal function, do not override. |
|
| 2551 | - */ |
|
| 2543 | + * Prefixes column names with this bean's table name. |
|
| 2544 | + * |
|
| 2545 | + * @param string $order_by Order by clause to be processed |
|
| 2546 | + * @param SugarBean $submodule name of the module this order by clause is for |
|
| 2547 | + * @param boolean $suppress_table_name Whether table name should be suppressed |
|
| 2548 | + * @return string Processed order by clause |
|
| 2549 | + * |
|
| 2550 | + * Internal function, do not override. |
|
| 2551 | + */ |
|
| 2552 | 2552 | public function process_order_by($order_by, $submodule = null, $suppress_table_name = false) |
| 2553 | 2553 | { |
| 2554 | 2554 | if (empty($order_by)) |
@@ -2622,21 +2622,21 @@ discard block |
||
| 2622 | 2622 | |
| 2623 | 2623 | |
| 2624 | 2624 | /** |
| 2625 | - * Returns a detail object like retrieving of the current object type. |
|
| 2626 | - * |
|
| 2627 | - * It is intended for use in navigation buttons on the DetailView. It will pass an offset and limit argument to the sql query. |
|
| 2628 | - * @internal This method must be called on a new instance. It overrides the values of all the fields in the current one. |
|
| 2629 | - * |
|
| 2630 | - * @param string $order_by |
|
| 2631 | - * @param string $where Additional where clause |
|
| 2632 | - * @param int $row_offset Optaional,default 0, starting row number |
|
| 2633 | - * @param init $limit Optional, default -1 |
|
| 2634 | - * @param int $max Optional, default -1 |
|
| 2635 | - * @param boolean $show_deleted Optioanl, default 0, if set to 1 system will show deleted records. |
|
| 2636 | - * @return array Fetched data. |
|
| 2637 | - * |
|
| 2638 | - * Internal function, do not override. |
|
| 2639 | - */ |
|
| 2625 | + * Returns a detail object like retrieving of the current object type. |
|
| 2626 | + * |
|
| 2627 | + * It is intended for use in navigation buttons on the DetailView. It will pass an offset and limit argument to the sql query. |
|
| 2628 | + * @internal This method must be called on a new instance. It overrides the values of all the fields in the current one. |
|
| 2629 | + * |
|
| 2630 | + * @param string $order_by |
|
| 2631 | + * @param string $where Additional where clause |
|
| 2632 | + * @param int $row_offset Optaional,default 0, starting row number |
|
| 2633 | + * @param init $limit Optional, default -1 |
|
| 2634 | + * @param int $max Optional, default -1 |
|
| 2635 | + * @param boolean $show_deleted Optioanl, default 0, if set to 1 system will show deleted records. |
|
| 2636 | + * @return array Fetched data. |
|
| 2637 | + * |
|
| 2638 | + * Internal function, do not override. |
|
| 2639 | + */ |
|
| 2640 | 2640 | function get_detail($order_by = "", $where = "", $offset = 0, $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
| 2641 | 2641 | { |
| 2642 | 2642 | $GLOBALS['log']->debug("get_detail: order_by = '$order_by' and where = '$where' and limit = '$limit' and offset = '$offset'"); |
@@ -2660,25 +2660,25 @@ discard block |
||
| 2660 | 2660 | } |
| 2661 | 2661 | } |
| 2662 | 2662 | |
| 2663 | - /* BEGIN - SECURITY GROUPS */ |
|
| 2664 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 2665 | - { |
|
| 2666 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 2667 | - global $current_user; |
|
| 2668 | - $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 2669 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 2670 | - if(!empty($owner_where)){ |
|
| 2671 | - if(empty($where)) |
|
| 2672 | - { |
|
| 2673 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
| 2674 | - } else { |
|
| 2675 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 2676 | - } |
|
| 2677 | - } else { |
|
| 2678 | - $where .= ' AND '. $group_where; |
|
| 2679 | - } |
|
| 2680 | - } |
|
| 2681 | - /* END - SECURITY GROUPS */ |
|
| 2663 | + /* BEGIN - SECURITY GROUPS */ |
|
| 2664 | + if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 2665 | + { |
|
| 2666 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 2667 | + global $current_user; |
|
| 2668 | + $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 2669 | + $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 2670 | + if(!empty($owner_where)){ |
|
| 2671 | + if(empty($where)) |
|
| 2672 | + { |
|
| 2673 | + $where = " (". $owner_where." or ".$group_where.") "; |
|
| 2674 | + } else { |
|
| 2675 | + $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 2676 | + } |
|
| 2677 | + } else { |
|
| 2678 | + $where .= ' AND '. $group_where; |
|
| 2679 | + } |
|
| 2680 | + } |
|
| 2681 | + /* END - SECURITY GROUPS */ |
|
| 2682 | 2682 | $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted, $offset); |
| 2683 | 2683 | |
| 2684 | 2684 | //Add Limit and Offset to query |
@@ -2688,16 +2688,16 @@ discard block |
||
| 2688 | 2688 | } |
| 2689 | 2689 | |
| 2690 | 2690 | /** |
| 2691 | - * Fetches data from all related tables. |
|
| 2692 | - * |
|
| 2693 | - * @param object $child_seed |
|
| 2694 | - * @param string $related_field_name relation to fetch data for |
|
| 2695 | - * @param string $order_by Optional, default empty |
|
| 2696 | - * @param string $where Optional, additional where clause |
|
| 2697 | - * @return array Fetched data. |
|
| 2698 | - * |
|
| 2699 | - * Internal function, do not override. |
|
| 2700 | - */ |
|
| 2691 | + * Fetches data from all related tables. |
|
| 2692 | + * |
|
| 2693 | + * @param object $child_seed |
|
| 2694 | + * @param string $related_field_name relation to fetch data for |
|
| 2695 | + * @param string $order_by Optional, default empty |
|
| 2696 | + * @param string $where Optional, additional where clause |
|
| 2697 | + * @return array Fetched data. |
|
| 2698 | + * |
|
| 2699 | + * Internal function, do not override. |
|
| 2700 | + */ |
|
| 2701 | 2701 | function get_related_list($child_seed,$related_field_name, $order_by = "", $where = "", |
| 2702 | 2702 | $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
| 2703 | 2703 | { |
@@ -3073,13 +3073,13 @@ discard block |
||
| 3073 | 3073 | |
| 3074 | 3074 | |
| 3075 | 3075 | /** |
| 3076 | - * Returns a full (ie non-paged) list of the current object type. |
|
| 3077 | - * |
|
| 3078 | - * @param string $order_by the order by SQL parameter. defaults to "" |
|
| 3079 | - * @param string $where where clause. defaults to "" |
|
| 3080 | - * @param boolean $check_dates. defaults to false |
|
| 3081 | - * @param int $show_deleted show deleted records. defaults to 0 |
|
| 3082 | - */ |
|
| 3076 | + * Returns a full (ie non-paged) list of the current object type. |
|
| 3077 | + * |
|
| 3078 | + * @param string $order_by the order by SQL parameter. defaults to "" |
|
| 3079 | + * @param string $where where clause. defaults to "" |
|
| 3080 | + * @param boolean $check_dates. defaults to false |
|
| 3081 | + * @param int $show_deleted show deleted records. defaults to 0 |
|
| 3082 | + */ |
|
| 3083 | 3083 | function get_full_list($order_by = "", $where = "", $check_dates=false, $show_deleted = 0) |
| 3084 | 3084 | { |
| 3085 | 3085 | $GLOBALS['log']->debug("get_full_list: order_by = '$order_by' and where = '$where'"); |
@@ -3107,7 +3107,7 @@ discard block |
||
| 3107 | 3107 | * @param boolean $singleSelect Optional, default false. |
| 3108 | 3108 | * @return String select query string, optionally an array value will be returned if $return_array= true. |
| 3109 | 3109 | */ |
| 3110 | - function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) |
|
| 3110 | + function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) |
|
| 3111 | 3111 | { |
| 3112 | 3112 | global $beanFiles, $beanList; |
| 3113 | 3113 | $selectedFields = array(); |
@@ -3127,41 +3127,41 @@ discard block |
||
| 3127 | 3127 | $where .= ' AND '. $owner_where; |
| 3128 | 3128 | } |
| 3129 | 3129 | } |
| 3130 | - /* BEGIN - SECURITY GROUPS */ |
|
| 3131 | - global $current_user, $sugar_config; |
|
| 3132 | - if($this->module_dir == 'Users' && !is_admin($current_user) |
|
| 3133 | - && isset($sugar_config['securitysuite_filter_user_list']) |
|
| 3134 | - && $sugar_config['securitysuite_filter_user_list'] == true |
|
| 3135 | - ) { |
|
| 3136 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3137 | - global $current_user; |
|
| 3138 | - $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
|
| 3139 | - //$group_where = "user_name = 'admin'"; |
|
| 3140 | - if(empty($where)) |
|
| 3141 | - { |
|
| 3142 | - $where = " (".$group_where.") "; |
|
| 3143 | - } else { |
|
| 3144 | - $where .= " AND (".$group_where.") "; |
|
| 3145 | - } |
|
| 3146 | - } else |
|
| 3147 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 3148 | - { |
|
| 3149 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3150 | - global $current_user; |
|
| 3151 | - $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 3152 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 3153 | - if(!empty($owner_where)){ |
|
| 3154 | - if(empty($where)) |
|
| 3155 | - { |
|
| 3156 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
| 3157 | - } else { |
|
| 3158 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 3159 | - } |
|
| 3160 | - } else { |
|
| 3161 | - $where .= ' AND '. $group_where; |
|
| 3162 | - } |
|
| 3163 | - } |
|
| 3164 | - /* END - SECURITY GROUPS */ |
|
| 3130 | + /* BEGIN - SECURITY GROUPS */ |
|
| 3131 | + global $current_user, $sugar_config; |
|
| 3132 | + if($this->module_dir == 'Users' && !is_admin($current_user) |
|
| 3133 | + && isset($sugar_config['securitysuite_filter_user_list']) |
|
| 3134 | + && $sugar_config['securitysuite_filter_user_list'] == true |
|
| 3135 | + ) { |
|
| 3136 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3137 | + global $current_user; |
|
| 3138 | + $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
|
| 3139 | + //$group_where = "user_name = 'admin'"; |
|
| 3140 | + if(empty($where)) |
|
| 3141 | + { |
|
| 3142 | + $where = " (".$group_where.") "; |
|
| 3143 | + } else { |
|
| 3144 | + $where .= " AND (".$group_where.") "; |
|
| 3145 | + } |
|
| 3146 | + } else |
|
| 3147 | + if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 3148 | + { |
|
| 3149 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3150 | + global $current_user; |
|
| 3151 | + $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 3152 | + $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 3153 | + if(!empty($owner_where)){ |
|
| 3154 | + if(empty($where)) |
|
| 3155 | + { |
|
| 3156 | + $where = " (". $owner_where." or ".$group_where.") "; |
|
| 3157 | + } else { |
|
| 3158 | + $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 3159 | + } |
|
| 3160 | + } else { |
|
| 3161 | + $where .= ' AND '. $group_where; |
|
| 3162 | + } |
|
| 3163 | + } |
|
| 3164 | + /* END - SECURITY GROUPS */ |
|
| 3165 | 3165 | if(!empty($params['distinct'])) |
| 3166 | 3166 | { |
| 3167 | 3167 | $distinct = ' DISTINCT '; |
@@ -3247,24 +3247,24 @@ discard block |
||
| 3247 | 3247 | |
| 3248 | 3248 | $used_join_key = array(); |
| 3249 | 3249 | |
| 3250 | - //walk through the fields and for every relationship field add their relationship_info field |
|
| 3251 | - //relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field |
|
| 3252 | - $addrelate = array(); |
|
| 3253 | - foreach($fields as $field=>$value) |
|
| 3254 | - { |
|
| 3255 | - if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && |
|
| 3256 | - $this->field_defs[$field]['source'] == 'non-db') |
|
| 3257 | - { |
|
| 3258 | - $addrelatefield = $this->get_relationship_field($field); |
|
| 3259 | - if ($addrelatefield) |
|
| 3260 | - $addrelate[$addrelatefield] = true; |
|
| 3261 | - } |
|
| 3262 | - if(!empty($this->field_defs[$field]['id_name'])){ |
|
| 3263 | - $addrelate[$this->field_defs[$field]['id_name']] = true; |
|
| 3264 | - } |
|
| 3265 | - } |
|
| 3266 | - |
|
| 3267 | - $fields = array_merge($addrelate, $fields); |
|
| 3250 | + //walk through the fields and for every relationship field add their relationship_info field |
|
| 3251 | + //relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field |
|
| 3252 | + $addrelate = array(); |
|
| 3253 | + foreach($fields as $field=>$value) |
|
| 3254 | + { |
|
| 3255 | + if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && |
|
| 3256 | + $this->field_defs[$field]['source'] == 'non-db') |
|
| 3257 | + { |
|
| 3258 | + $addrelatefield = $this->get_relationship_field($field); |
|
| 3259 | + if ($addrelatefield) |
|
| 3260 | + $addrelate[$addrelatefield] = true; |
|
| 3261 | + } |
|
| 3262 | + if(!empty($this->field_defs[$field]['id_name'])){ |
|
| 3263 | + $addrelate[$this->field_defs[$field]['id_name']] = true; |
|
| 3264 | + } |
|
| 3265 | + } |
|
| 3266 | + |
|
| 3267 | + $fields = array_merge($addrelate, $fields); |
|
| 3268 | 3268 | |
| 3269 | 3269 | foreach($fields as $field=>$value) |
| 3270 | 3270 | { |
@@ -3297,7 +3297,7 @@ discard block |
||
| 3297 | 3297 | //in opportunities module remove the contact_role/opportunity_role field. |
| 3298 | 3298 | if (isset($data['relationship_fields']) and !empty($data['relationship_fields'])) |
| 3299 | 3299 | { |
| 3300 | - $process_field = false; |
|
| 3300 | + $process_field = false; |
|
| 3301 | 3301 | foreach ($data['relationship_fields'] as $field_name) |
| 3302 | 3302 | { |
| 3303 | 3303 | if (isset($fields[$field_name])) |
@@ -3307,8 +3307,8 @@ discard block |
||
| 3307 | 3307 | } |
| 3308 | 3308 | } |
| 3309 | 3309 | |
| 3310 | - if (!$process_field) |
|
| 3311 | - continue; |
|
| 3310 | + if (!$process_field) |
|
| 3311 | + continue; |
|
| 3312 | 3312 | } |
| 3313 | 3313 | |
| 3314 | 3314 | if( (!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter) )) |
@@ -3416,27 +3416,27 @@ discard block |
||
| 3416 | 3416 | $rel_module = $this->$linkField->getRelatedModuleName(); |
| 3417 | 3417 | $table_joined = !empty($joined_tables[$params['join_table_alias']]) || (!empty($joined_tables[$params['join_table_link_alias']]) && isset($data['link_type']) && $data['link_type'] == 'relationship_info'); |
| 3418 | 3418 | |
| 3419 | - //if rname is set to 'name', and bean files exist, then check if field should be a concatenated name |
|
| 3420 | - global $beanFiles, $beanList; |
|
| 3419 | + //if rname is set to 'name', and bean files exist, then check if field should be a concatenated name |
|
| 3420 | + global $beanFiles, $beanList; |
|
| 3421 | 3421 | // °3/21/2014 FIX NS-TEAM - Relationship fields could not be displayed in subpanels |
| 3422 | 3422 | //if($data['rname'] && !empty($beanFiles[$beanList[$rel_module]])) { |
| 3423 | 3423 | if(isset($data['rname']) && $data['rname'] == 'name' && !empty($beanFiles[$beanList[$rel_module]])) { |
| 3424 | 3424 | |
| 3425 | - //create an instance of the related bean |
|
| 3426 | - require_once($beanFiles[$beanList[$rel_module]]); |
|
| 3427 | - $rel_mod = new $beanList[$rel_module](); |
|
| 3428 | - //if bean has first and last name fields, then name should be concatenated |
|
| 3429 | - if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){ |
|
| 3430 | - $data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name'); |
|
| 3431 | - } |
|
| 3432 | - } |
|
| 3425 | + //create an instance of the related bean |
|
| 3426 | + require_once($beanFiles[$beanList[$rel_module]]); |
|
| 3427 | + $rel_mod = new $beanList[$rel_module](); |
|
| 3428 | + //if bean has first and last name fields, then name should be concatenated |
|
| 3429 | + if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){ |
|
| 3430 | + $data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name'); |
|
| 3431 | + } |
|
| 3432 | + } |
|
| 3433 | 3433 | |
| 3434 | 3434 | |
| 3435 | - if($join['type'] == 'many-to-many') |
|
| 3436 | - { |
|
| 3437 | - if(empty($ret_array['secondary_select'])) |
|
| 3438 | - { |
|
| 3439 | - $ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id "; |
|
| 3435 | + if($join['type'] == 'many-to-many') |
|
| 3436 | + { |
|
| 3437 | + if(empty($ret_array['secondary_select'])) |
|
| 3438 | + { |
|
| 3439 | + $ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id "; |
|
| 3440 | 3440 | |
| 3441 | 3441 | if(!empty($beanFiles[$beanList[$rel_module]]) && $join_primary) |
| 3442 | 3442 | { |
@@ -3548,42 +3548,42 @@ discard block |
||
| 3548 | 3548 | // and this code changes accounts to jt4 as there is a self join with the accounts table. |
| 3549 | 3549 | //Martin fix #27494 |
| 3550 | 3550 | if(isset($data['db_concat_fields'])){ |
| 3551 | - $buildWhere = false; |
|
| 3551 | + $buildWhere = false; |
|
| 3552 | 3552 | if(in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) |
| 3553 | - { |
|
| 3554 | - $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
|
| 3555 | - if(preg_match($exp, $where, $matches)) |
|
| 3556 | - { |
|
| 3557 | - $search_expression = $matches[0]; |
|
| 3558 | - //Create three search conditions - first + last, first, last |
|
| 3559 | - $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
| 3560 | - $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
| 3561 | - $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
|
| 3562 | - $buildWhere = true; |
|
| 3563 | - $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
| 3564 | - } |
|
| 3565 | - } |
|
| 3566 | - |
|
| 3567 | - if(!$buildWhere) |
|
| 3568 | - { |
|
| 3569 | - $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
|
| 3570 | - $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
|
| 3571 | - |
|
| 3572 | - // 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) |
|
| 3575 | - { |
|
| 3576 | - $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
|
| 3577 | - $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
| 3578 | - } |
|
| 3579 | - } |
|
| 3553 | + { |
|
| 3554 | + $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
|
| 3555 | + if(preg_match($exp, $where, $matches)) |
|
| 3556 | + { |
|
| 3557 | + $search_expression = $matches[0]; |
|
| 3558 | + //Create three search conditions - first + last, first, last |
|
| 3559 | + $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
| 3560 | + $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
| 3561 | + $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
|
| 3562 | + $buildWhere = true; |
|
| 3563 | + $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
| 3564 | + } |
|
| 3565 | + } |
|
| 3566 | + |
|
| 3567 | + if(!$buildWhere) |
|
| 3568 | + { |
|
| 3569 | + $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
|
| 3570 | + $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
|
| 3571 | + |
|
| 3572 | + // 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) |
|
| 3575 | + { |
|
| 3576 | + $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
|
| 3577 | + $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
| 3578 | + } |
|
| 3579 | + } |
|
| 3580 | 3580 | }else{ |
| 3581 | 3581 | $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.'.$data['rname'], $where); |
| 3582 | 3582 | |
| 3583 | - // 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) |
|
| 3586 | - $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where); |
|
| 3583 | + // 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) |
|
| 3586 | + $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where); |
|
| 3587 | 3587 | } |
| 3588 | 3588 | if(!$table_joined) |
| 3589 | 3589 | { |
@@ -3612,12 +3612,12 @@ discard block |
||
| 3612 | 3612 | |
| 3613 | 3613 | } |
| 3614 | 3614 | |
| 3615 | - if ($ifListForExport) { |
|
| 3616 | - if(isset($this->field_defs['email1'])) { |
|
| 3617 | - $ret_array['select'].= " ,email_addresses.email_address email1"; |
|
| 3618 | - $ret_array['from'].= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
| 3619 | - } |
|
| 3620 | - } |
|
| 3615 | + if ($ifListForExport) { |
|
| 3616 | + if(isset($this->field_defs['email1'])) { |
|
| 3617 | + $ret_array['select'].= " ,email_addresses.email_address email1"; |
|
| 3618 | + $ret_array['from'].= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
| 3619 | + } |
|
| 3620 | + } |
|
| 3621 | 3621 | |
| 3622 | 3622 | $where_auto = '1=1'; |
| 3623 | 3623 | if($show_deleted == 0) |
@@ -3652,20 +3652,20 @@ discard block |
||
| 3652 | 3652 | return $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by']; |
| 3653 | 3653 | } |
| 3654 | 3654 | |
| 3655 | - // Check if field is defined through a relationship_info field, add this field when not present |
|
| 3656 | - function get_relationship_field($field) |
|
| 3657 | - { |
|
| 3658 | - foreach ($this->field_defs as $field_def => $value) |
|
| 3659 | - { |
|
| 3660 | - if (isset($value['relationship_fields']) && |
|
| 3661 | - in_array($field, $value['relationship_fields']) && |
|
| 3655 | + // Check if field is defined through a relationship_info field, add this field when not present |
|
| 3656 | + function get_relationship_field($field) |
|
| 3657 | + { |
|
| 3658 | + foreach ($this->field_defs as $field_def => $value) |
|
| 3659 | + { |
|
| 3660 | + if (isset($value['relationship_fields']) && |
|
| 3661 | + in_array($field, $value['relationship_fields']) && |
|
| 3662 | 3662 | (!isset($value['link_type']) || $value['link_type'] != 'relationship_info') |
| 3663 | 3663 | ) |
| 3664 | - return $field_def; |
|
| 3665 | - } |
|
| 3664 | + return $field_def; |
|
| 3665 | + } |
|
| 3666 | 3666 | |
| 3667 | - return false; |
|
| 3668 | - } |
|
| 3667 | + return false; |
|
| 3668 | + } |
|
| 3669 | 3669 | |
| 3670 | 3670 | /** |
| 3671 | 3671 | * Returns parent record data for objects that store relationship information |
@@ -3772,8 +3772,8 @@ discard block |
||
| 3772 | 3772 | global $sugar_config; |
| 3773 | 3773 | $db = DBManagerFactory::getInstance('listviews'); |
| 3774 | 3774 | /** |
| 3775 | - * if the row_offset is set to 'end' go to the end of the list |
|
| 3776 | - */ |
|
| 3775 | + * if the row_offset is set to 'end' go to the end of the list |
|
| 3776 | + */ |
|
| 3777 | 3777 | $toEnd = strval($row_offset) == 'end'; |
| 3778 | 3778 | $GLOBALS['log']->debug("process_list_query: ".$query); |
| 3779 | 3779 | if($max_per_page == -1) |
@@ -3901,13 +3901,13 @@ discard block |
||
| 3901 | 3901 | } |
| 3902 | 3902 | |
| 3903 | 3903 | /** |
| 3904 | - * Returns the number of rows that the given SQL query should produce |
|
| 3904 | + * Returns the number of rows that the given SQL query should produce |
|
| 3905 | 3905 | * |
| 3906 | 3906 | * Internal function, do not override. |
| 3907 | 3907 | * @param string $query valid select query |
| 3908 | 3908 | * @param boolean $is_count_query Optional, Default false, set to true if passed query is a count query. |
| 3909 | 3909 | * @return int count of rows found |
| 3910 | - */ |
|
| 3910 | + */ |
|
| 3911 | 3911 | function _get_num_rows_in_query($query, $is_count_query=false) |
| 3912 | 3912 | { |
| 3913 | 3913 | $num_rows_in_query = 0; |
@@ -3949,8 +3949,8 @@ discard block |
||
| 3949 | 3949 | { |
| 3950 | 3950 | $db = DBManagerFactory::getInstance('listviews'); |
| 3951 | 3951 | /** |
| 3952 | - * if the row_offset is set to 'end' go to the end of the list |
|
| 3953 | - */ |
|
| 3952 | + * if the row_offset is set to 'end' go to the end of the list |
|
| 3953 | + */ |
|
| 3954 | 3954 | $toEnd = strval($row_offset) == 'end'; |
| 3955 | 3955 | global $sugar_config; |
| 3956 | 3956 | $use_count_query=false; |
@@ -4188,7 +4188,7 @@ discard block |
||
| 4188 | 4188 | } |
| 4189 | 4189 | if(!empty($sugar_config['disable_count_query']) && !empty($limit)) |
| 4190 | 4190 | { |
| 4191 | - //C.L. Bug 43535 - Use the $index value to set the $rows_found value here |
|
| 4191 | + //C.L. Bug 43535 - Use the $index value to set the $rows_found value here |
|
| 4192 | 4192 | $rows_found = isset($index) ? $index : $row_offset + count($list); |
| 4193 | 4193 | |
| 4194 | 4194 | if(count($list) >= $limit) |
@@ -4338,28 +4338,28 @@ discard block |
||
| 4338 | 4338 | } |
| 4339 | 4339 | |
| 4340 | 4340 | /** |
| 4341 | - * Tracks the viewing of a detail record. |
|
| 4342 | - * This leverages get_summary_text() which is object specific. |
|
| 4343 | - * |
|
| 4344 | - * Internal function, do not override. |
|
| 4345 | - * @param string $user_id - String value of the user that is viewing the record. |
|
| 4346 | - * @param string $current_module - String value of the module being processed. |
|
| 4347 | - * @param string $current_view - String value of the current view |
|
| 4348 | - */ |
|
| 4349 | - function track_view($user_id, $current_module, $current_view='') |
|
| 4350 | - { |
|
| 4351 | - $trackerManager = TrackerManager::getInstance(); |
|
| 4352 | - if($monitor = $trackerManager->getMonitor('tracker')){ |
|
| 4353 | - $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb()); |
|
| 4354 | - $monitor->setValue('user_id', $user_id); |
|
| 4355 | - $monitor->setValue('module_name', $current_module); |
|
| 4356 | - $monitor->setValue('action', $current_view); |
|
| 4357 | - $monitor->setValue('item_id', $this->id); |
|
| 4358 | - $monitor->setValue('item_summary', $this->get_summary_text()); |
|
| 4359 | - $monitor->setValue('visible', $this->tracker_visibility); |
|
| 4360 | - $trackerManager->saveMonitor($monitor); |
|
| 4361 | - } |
|
| 4362 | - } |
|
| 4341 | + * Tracks the viewing of a detail record. |
|
| 4342 | + * This leverages get_summary_text() which is object specific. |
|
| 4343 | + * |
|
| 4344 | + * Internal function, do not override. |
|
| 4345 | + * @param string $user_id - String value of the user that is viewing the record. |
|
| 4346 | + * @param string $current_module - String value of the module being processed. |
|
| 4347 | + * @param string $current_view - String value of the current view |
|
| 4348 | + */ |
|
| 4349 | + function track_view($user_id, $current_module, $current_view='') |
|
| 4350 | + { |
|
| 4351 | + $trackerManager = TrackerManager::getInstance(); |
|
| 4352 | + if($monitor = $trackerManager->getMonitor('tracker')){ |
|
| 4353 | + $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb()); |
|
| 4354 | + $monitor->setValue('user_id', $user_id); |
|
| 4355 | + $monitor->setValue('module_name', $current_module); |
|
| 4356 | + $monitor->setValue('action', $current_view); |
|
| 4357 | + $monitor->setValue('item_id', $this->id); |
|
| 4358 | + $monitor->setValue('item_summary', $this->get_summary_text()); |
|
| 4359 | + $monitor->setValue('visible', $this->tracker_visibility); |
|
| 4360 | + $trackerManager->saveMonitor($monitor); |
|
| 4361 | + } |
|
| 4362 | + } |
|
| 4363 | 4363 | |
| 4364 | 4364 | /** |
| 4365 | 4365 | * Returns the summary text that should show up in the recent history list for this object. |
@@ -4372,12 +4372,12 @@ discard block |
||
| 4372 | 4372 | } |
| 4373 | 4373 | |
| 4374 | 4374 | /** |
| 4375 | - * This is designed to be overridden and add specific fields to each record. |
|
| 4376 | - * This allows the generic query to fill in the major fields, and then targeted |
|
| 4377 | - * queries to get related fields and add them to the record. The contact's |
|
| 4378 | - * account for instance. This method is only used for populating extra fields |
|
| 4379 | - * in lists. |
|
| 4380 | - */ |
|
| 4375 | + * This is designed to be overridden and add specific fields to each record. |
|
| 4376 | + * This allows the generic query to fill in the major fields, and then targeted |
|
| 4377 | + * queries to get related fields and add them to the record. The contact's |
|
| 4378 | + * account for instance. This method is only used for populating extra fields |
|
| 4379 | + * in lists. |
|
| 4380 | + */ |
|
| 4381 | 4381 | function fill_in_additional_list_fields(){ |
| 4382 | 4382 | if(!empty($this->field_defs['parent_name']) && empty($this->parent_name)){ |
| 4383 | 4383 | $this->fill_in_additional_parent_fields(); |
@@ -4385,12 +4385,12 @@ discard block |
||
| 4385 | 4385 | } |
| 4386 | 4386 | |
| 4387 | 4387 | /** |
| 4388 | - * This is designed to be overridden and add specific fields to each record. |
|
| 4389 | - * This allows the generic query to fill in the major fields, and then targeted |
|
| 4390 | - * queries to get related fields and add them to the record. The contact's |
|
| 4391 | - * account for instance. This method is only used for populating extra fields |
|
| 4392 | - * in the detail form |
|
| 4393 | - */ |
|
| 4388 | + * This is designed to be overridden and add specific fields to each record. |
|
| 4389 | + * This allows the generic query to fill in the major fields, and then targeted |
|
| 4390 | + * queries to get related fields and add them to the record. The contact's |
|
| 4391 | + * account for instance. This method is only used for populating extra fields |
|
| 4392 | + * in the detail form |
|
| 4393 | + */ |
|
| 4394 | 4394 | function fill_in_additional_detail_fields() |
| 4395 | 4395 | { |
| 4396 | 4396 | if(!empty($this->field_defs['assigned_user_name']) && !empty($this->assigned_user_id)){ |
@@ -4398,20 +4398,20 @@ discard block |
||
| 4398 | 4398 | $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); |
| 4399 | 4399 | |
| 4400 | 4400 | } |
| 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); |
|
| 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); |
|
| 4405 | 4405 | |
| 4406 | - if(!empty($this->field_defs['parent_name'])){ |
|
| 4407 | - $this->fill_in_additional_parent_fields(); |
|
| 4408 | - } |
|
| 4406 | + if(!empty($this->field_defs['parent_name'])){ |
|
| 4407 | + $this->fill_in_additional_parent_fields(); |
|
| 4408 | + } |
|
| 4409 | 4409 | } |
| 4410 | 4410 | |
| 4411 | 4411 | /** |
| 4412 | - * This is desgined to be overridden or called from extending bean. This method |
|
| 4413 | - * will fill in any parent_name fields. |
|
| 4414 | - */ |
|
| 4412 | + * This is desgined to be overridden or called from extending bean. This method |
|
| 4413 | + * will fill in any parent_name fields. |
|
| 4414 | + */ |
|
| 4415 | 4415 | function fill_in_additional_parent_fields() { |
| 4416 | 4416 | |
| 4417 | 4417 | if(!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id){ |
@@ -4452,8 +4452,8 @@ discard block |
||
| 4452 | 4452 | } |
| 4453 | 4453 | |
| 4454 | 4454 | /** |
| 4455 | - * Fill in fields where type = relate |
|
| 4456 | - */ |
|
| 4455 | + * Fill in fields where type = relate |
|
| 4456 | + */ |
|
| 4457 | 4457 | function fill_in_relationship_fields(){ |
| 4458 | 4458 | global $fill_in_rel_depth; |
| 4459 | 4459 | if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) |
@@ -4477,7 +4477,7 @@ discard block |
||
| 4477 | 4477 | |
| 4478 | 4478 | if (empty($this->$id_name)) |
| 4479 | 4479 | { |
| 4480 | - $this->fill_in_link_field($id_name, $field); |
|
| 4480 | + $this->fill_in_link_field($id_name, $field); |
|
| 4481 | 4481 | } |
| 4482 | 4482 | if(!empty($this->$id_name) && ( $this->object_name != $related_module || ( $this->object_name == $related_module && $this->$id_name != $this->id ))){ |
| 4483 | 4483 | if(isset($GLOBALS['beanList'][ $related_module])){ |
@@ -4503,7 +4503,7 @@ discard block |
||
| 4503 | 4503 | if(!empty($this->$id_name) && isset($this->$name)) |
| 4504 | 4504 | { |
| 4505 | 4505 | if(!isset($field['additionalFields'])) |
| 4506 | - $field['additionalFields'] = array(); |
|
| 4506 | + $field['additionalFields'] = array(); |
|
| 4507 | 4507 | if(!empty($field['rname'])) |
| 4508 | 4508 | { |
| 4509 | 4509 | $field['additionalFields'][$field['rname']]= $name; |
@@ -4521,8 +4521,8 @@ discard block |
||
| 4521 | 4521 | } |
| 4522 | 4522 | |
| 4523 | 4523 | /** |
| 4524 | - * This is a helper function that is used to quickly created indexes when creating tables. |
|
| 4525 | - */ |
|
| 4524 | + * This is a helper function that is used to quickly created indexes when creating tables. |
|
| 4525 | + */ |
|
| 4526 | 4526 | function create_index($query) |
| 4527 | 4527 | { |
| 4528 | 4528 | $GLOBALS['log']->info("create_index: $query"); |
@@ -4534,21 +4534,21 @@ discard block |
||
| 4534 | 4534 | * This function should be overridden in each module. It marks an item as deleted. |
| 4535 | 4535 | * |
| 4536 | 4536 | * If it is not overridden, then marking this type of item is not allowed |
| 4537 | - */ |
|
| 4538 | - function mark_deleted($id) |
|
| 4539 | - { |
|
| 4540 | - global $current_user; |
|
| 4541 | - $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4537 | + */ |
|
| 4538 | + function mark_deleted($id) |
|
| 4539 | + { |
|
| 4540 | + global $current_user; |
|
| 4541 | + $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4542 | 4542 | $id = $this->db->quote($id); |
| 4543 | - if(isset($_SESSION['show_deleted'])) |
|
| 4544 | - { |
|
| 4545 | - $this->mark_undeleted($id); |
|
| 4546 | - } |
|
| 4547 | - else |
|
| 4548 | - { |
|
| 4549 | - // call the custom business logic |
|
| 4550 | - $custom_logic_arguments['id'] = $id; |
|
| 4551 | - $this->call_custom_logic("before_delete", $custom_logic_arguments); |
|
| 4543 | + if(isset($_SESSION['show_deleted'])) |
|
| 4544 | + { |
|
| 4545 | + $this->mark_undeleted($id); |
|
| 4546 | + } |
|
| 4547 | + else |
|
| 4548 | + { |
|
| 4549 | + // call the custom business logic |
|
| 4550 | + $custom_logic_arguments['id'] = $id; |
|
| 4551 | + $this->call_custom_logic("before_delete", $custom_logic_arguments); |
|
| 4552 | 4552 | $this->deleted = 1; |
| 4553 | 4553 | $this->mark_relationships_deleted($id); |
| 4554 | 4554 | if ( isset($this->field_defs['modified_user_id']) ) { |
@@ -4581,16 +4581,16 @@ discard block |
||
| 4581 | 4581 | * Restores data deleted by call to mark_deleted() function. |
| 4582 | 4582 | * |
| 4583 | 4583 | * Internal function, do not override. |
| 4584 | - */ |
|
| 4584 | + */ |
|
| 4585 | 4585 | function mark_undeleted($id) |
| 4586 | 4586 | { |
| 4587 | 4587 | // call the custom business logic |
| 4588 | 4588 | $custom_logic_arguments['id'] = $id; |
| 4589 | 4589 | $this->call_custom_logic("before_restore", $custom_logic_arguments); |
| 4590 | 4590 | |
| 4591 | - $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4592 | - $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'"; |
|
| 4593 | - $this->db->query($query, true,"Error marking record undeleted: "); |
|
| 4591 | + $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4592 | + $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'"; |
|
| 4593 | + $this->db->query($query, true,"Error marking record undeleted: "); |
|
| 4594 | 4594 | |
| 4595 | 4595 | $this->restoreFiles(); |
| 4596 | 4596 | |
@@ -4598,17 +4598,17 @@ discard block |
||
| 4598 | 4598 | $this->call_custom_logic("after_restore", $custom_logic_arguments); |
| 4599 | 4599 | } |
| 4600 | 4600 | |
| 4601 | - /** |
|
| 4602 | - * This function deletes relationships to this object. It should be overridden |
|
| 4603 | - * to handle the relationships of the specific object. |
|
| 4604 | - * This function is called when the item itself is being deleted. |
|
| 4605 | - * |
|
| 4606 | - * @param int $id id of the relationship to delete |
|
| 4607 | - */ |
|
| 4608 | - function mark_relationships_deleted($id) |
|
| 4609 | - { |
|
| 4601 | + /** |
|
| 4602 | + * This function deletes relationships to this object. It should be overridden |
|
| 4603 | + * to handle the relationships of the specific object. |
|
| 4604 | + * This function is called when the item itself is being deleted. |
|
| 4605 | + * |
|
| 4606 | + * @param int $id id of the relationship to delete |
|
| 4607 | + */ |
|
| 4608 | + function mark_relationships_deleted($id) |
|
| 4609 | + { |
|
| 4610 | 4610 | $this->delete_linked($id); |
| 4611 | - } |
|
| 4611 | + } |
|
| 4612 | 4612 | |
| 4613 | 4613 | /** |
| 4614 | 4614 | * Returns path for files of bean or false on error |
@@ -4788,16 +4788,16 @@ discard block |
||
| 4788 | 4788 | } |
| 4789 | 4789 | |
| 4790 | 4790 | /** |
| 4791 | - * This function is used to execute the query and create an array template objects |
|
| 4792 | - * from the resulting ids from the query. |
|
| 4793 | - * It is currently used for building sub-panel arrays. |
|
| 4794 | - * |
|
| 4795 | - * @param string $query - the query that should be executed to build the list |
|
| 4796 | - * @param object $template - The object that should be used to copy the records. |
|
| 4797 | - * @param int $row_offset Optional, default 0 |
|
| 4798 | - * @param int $limit Optional, default -1 |
|
| 4799 | - * @return array |
|
| 4800 | - */ |
|
| 4791 | + * This function is used to execute the query and create an array template objects |
|
| 4792 | + * from the resulting ids from the query. |
|
| 4793 | + * It is currently used for building sub-panel arrays. |
|
| 4794 | + * |
|
| 4795 | + * @param string $query - the query that should be executed to build the list |
|
| 4796 | + * @param object $template - The object that should be used to copy the records. |
|
| 4797 | + * @param int $row_offset Optional, default 0 |
|
| 4798 | + * @param int $limit Optional, default -1 |
|
| 4799 | + * @return array |
|
| 4800 | + */ |
|
| 4801 | 4801 | function build_related_list($query, &$template, $row_offset = 0, $limit = -1) |
| 4802 | 4802 | { |
| 4803 | 4803 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
@@ -4833,17 +4833,17 @@ discard block |
||
| 4833 | 4833 | return $list; |
| 4834 | 4834 | } |
| 4835 | 4835 | |
| 4836 | - /** |
|
| 4837 | - * This function is used to execute the query and create an array template objects |
|
| 4838 | - * from the resulting ids from the query. |
|
| 4839 | - * It is currently used for building sub-panel arrays. It supports an additional |
|
| 4840 | - * where clause that is executed as a filter on the results |
|
| 4841 | - * |
|
| 4842 | - * @param string $query - the query that should be executed to build the list |
|
| 4843 | - * @param object $template - The object that should be used to copy the records. |
|
| 4844 | - */ |
|
| 4845 | - function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0) |
|
| 4846 | - { |
|
| 4836 | + /** |
|
| 4837 | + * This function is used to execute the query and create an array template objects |
|
| 4838 | + * from the resulting ids from the query. |
|
| 4839 | + * It is currently used for building sub-panel arrays. It supports an additional |
|
| 4840 | + * where clause that is executed as a filter on the results |
|
| 4841 | + * |
|
| 4842 | + * @param string $query - the query that should be executed to build the list |
|
| 4843 | + * @param object $template - The object that should be used to copy the records. |
|
| 4844 | + */ |
|
| 4845 | + function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0) |
|
| 4846 | + { |
|
| 4847 | 4847 | $db = DBManagerFactory::getInstance('listviews'); |
| 4848 | 4848 | // No need to do an additional query |
| 4849 | 4849 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
@@ -4904,7 +4904,7 @@ discard block |
||
| 4904 | 4904 | } |
| 4905 | 4905 | |
| 4906 | 4906 | return $list; |
| 4907 | - } |
|
| 4907 | + } |
|
| 4908 | 4908 | |
| 4909 | 4909 | /** |
| 4910 | 4910 | * Constructs an comma separated list of ids from passed query results. |
@@ -4940,15 +4940,15 @@ discard block |
||
| 4940 | 4940 | } |
| 4941 | 4941 | |
| 4942 | 4942 | /** |
| 4943 | - * Optionally copies values from fetched row into the bean. |
|
| 4944 | - * |
|
| 4945 | - * Internal function, do not override. |
|
| 4946 | - * |
|
| 4947 | - * @param string $query - the query that should be executed to build the list |
|
| 4948 | - * @param object $template - The object that should be used to copy the records |
|
| 4949 | - * @param array $field_list List of fields. |
|
| 4950 | - * @return array |
|
| 4951 | - */ |
|
| 4943 | + * Optionally copies values from fetched row into the bean. |
|
| 4944 | + * |
|
| 4945 | + * Internal function, do not override. |
|
| 4946 | + * |
|
| 4947 | + * @param string $query - the query that should be executed to build the list |
|
| 4948 | + * @param object $template - The object that should be used to copy the records |
|
| 4949 | + * @param array $field_list List of fields. |
|
| 4950 | + * @return array |
|
| 4951 | + */ |
|
| 4952 | 4952 | function build_related_list2($query, &$template, &$field_list) |
| 4953 | 4953 | { |
| 4954 | 4954 | $GLOBALS['log']->debug("Finding linked values $this->object_name: ".$query); |
@@ -5121,19 +5121,19 @@ discard block |
||
| 5121 | 5121 | $row = $this->convertRow($row); |
| 5122 | 5122 | $this->fetched_row = $row; |
| 5123 | 5123 | $this->fromArray($row); |
| 5124 | - $this->is_updated_dependent_fields = false; |
|
| 5124 | + $this->is_updated_dependent_fields = false; |
|
| 5125 | 5125 | $this->fill_in_additional_detail_fields(); |
| 5126 | 5126 | return $this; |
| 5127 | 5127 | } |
| 5128 | 5128 | |
| 5129 | 5129 | /** |
| 5130 | - * This method is called during an import before inserting a bean |
|
| 5131 | - * Define an associative array called $special_fields |
|
| 5132 | - * the keys are user defined, and don't directly map to the bean's fields |
|
| 5133 | - * the value is the method name within that bean that will do extra |
|
| 5134 | - * processing for that field. example: 'full_name'=>'get_names_from_full_name' |
|
| 5135 | - * |
|
| 5136 | - */ |
|
| 5130 | + * This method is called during an import before inserting a bean |
|
| 5131 | + * Define an associative array called $special_fields |
|
| 5132 | + * the keys are user defined, and don't directly map to the bean's fields |
|
| 5133 | + * the value is the method name within that bean that will do extra |
|
| 5134 | + * processing for that field. example: 'full_name'=>'get_names_from_full_name' |
|
| 5135 | + * |
|
| 5136 | + */ |
|
| 5137 | 5137 | function process_special_fields() |
| 5138 | 5138 | { |
| 5139 | 5139 | foreach ($this->special_functions as $func_name) |
@@ -5267,8 +5267,8 @@ discard block |
||
| 5267 | 5267 | { |
| 5268 | 5268 | $where = ''; |
| 5269 | 5269 | |
| 5270 | - // make sure there is a date modified |
|
| 5271 | - $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
|
| 5270 | + // make sure there is a date modified |
|
| 5271 | + $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
|
| 5272 | 5272 | |
| 5273 | 5273 | $row=null; |
| 5274 | 5274 | if($check_duplicates) |
@@ -5345,30 +5345,30 @@ discard block |
||
| 5345 | 5345 | } |
| 5346 | 5346 | |
| 5347 | 5347 | /** |
| 5348 | - * Trigger custom logic for this module that is defined for the provided hook |
|
| 5349 | - * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php. |
|
| 5350 | - * That file should define the $hook_version that should be used. |
|
| 5351 | - * It should also define the $hook_array. The $hook_array will be a two dimensional array |
|
| 5352 | - * the first dimension is the name of the event, the second dimension is the information needed |
|
| 5353 | - * to fire the hook. Each entry in the top level array should be defined on a single line to make it |
|
| 5354 | - * easier to automatically replace this file. There should be no contents of this file that are not replacable. |
|
| 5355 | - * |
|
| 5356 | - * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1'); |
|
| 5357 | - * This sample line creates a before_save hook. The hooks are procesed in the order in which they |
|
| 5358 | - * are added to the array. The second dimension is an array of: |
|
| 5359 | - * processing index (for sorting before exporting the array) |
|
| 5360 | - * A logic type hook |
|
| 5361 | - * label/type |
|
| 5362 | - * php file to include |
|
| 5363 | - * php class the method is in |
|
| 5364 | - * php method to call |
|
| 5365 | - * |
|
| 5366 | - * The method signature for version 1 hooks is: |
|
| 5367 | - * function NAME(&$bean, $event, $arguments) |
|
| 5368 | - * $bean - $this bean passed in by reference. |
|
| 5369 | - * $event - The string for the current event (i.e. before_save) |
|
| 5370 | - * $arguments - An array of arguments that are specific to the event. |
|
| 5371 | - */ |
|
| 5348 | + * Trigger custom logic for this module that is defined for the provided hook |
|
| 5349 | + * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php. |
|
| 5350 | + * That file should define the $hook_version that should be used. |
|
| 5351 | + * It should also define the $hook_array. The $hook_array will be a two dimensional array |
|
| 5352 | + * the first dimension is the name of the event, the second dimension is the information needed |
|
| 5353 | + * to fire the hook. Each entry in the top level array should be defined on a single line to make it |
|
| 5354 | + * easier to automatically replace this file. There should be no contents of this file that are not replacable. |
|
| 5355 | + * |
|
| 5356 | + * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1'); |
|
| 5357 | + * This sample line creates a before_save hook. The hooks are procesed in the order in which they |
|
| 5358 | + * are added to the array. The second dimension is an array of: |
|
| 5359 | + * processing index (for sorting before exporting the array) |
|
| 5360 | + * A logic type hook |
|
| 5361 | + * label/type |
|
| 5362 | + * php file to include |
|
| 5363 | + * php class the method is in |
|
| 5364 | + * php method to call |
|
| 5365 | + * |
|
| 5366 | + * The method signature for version 1 hooks is: |
|
| 5367 | + * function NAME(&$bean, $event, $arguments) |
|
| 5368 | + * $bean - $this bean passed in by reference. |
|
| 5369 | + * $event - The string for the current event (i.e. before_save) |
|
| 5370 | + * $arguments - An array of arguments that are specific to the event. |
|
| 5371 | + */ |
|
| 5372 | 5372 | function call_custom_logic($event, $arguments = null) |
| 5373 | 5373 | { |
| 5374 | 5374 | if(!isset($this->processed) || $this->processed == false){ |
@@ -5432,14 +5432,14 @@ discard block |
||
| 5432 | 5432 | return false; |
| 5433 | 5433 | } |
| 5434 | 5434 | /** |
| 5435 | - * Check whether the user has access to a particular view for the current bean/module |
|
| 5436 | - * @param $view string required, the view to determine access for i.e. DetailView, ListView... |
|
| 5437 | - * @param $is_owner bool optional, this is part of the ACL check if the current user is an owner they will receive different access |
|
| 5438 | - */ |
|
| 5439 | - /* BEGIN - SECURITY GROUPS - aclaccess */ |
|
| 5440 | - /** |
|
| 5435 | + * Check whether the user has access to a particular view for the current bean/module |
|
| 5436 | + * @param $view string required, the view to determine access for i.e. DetailView, ListView... |
|
| 5437 | + * @param $is_owner bool optional, this is part of the ACL check if the current user is an owner they will receive different access |
|
| 5438 | + */ |
|
| 5439 | + /* BEGIN - SECURITY GROUPS - aclaccess */ |
|
| 5440 | + /** |
|
| 5441 | 5441 | function ACLAccess($view,$is_owner='not_set') |
| 5442 | - */ |
|
| 5442 | + */ |
|
| 5443 | 5443 | function ACLAccess($view,$is_owner='not_set',$in_group='not_set') |
| 5444 | 5444 | { |
| 5445 | 5445 | global $current_user; |
@@ -5447,61 +5447,61 @@ discard block |
||
| 5447 | 5447 | return true; |
| 5448 | 5448 | } |
| 5449 | 5449 | $not_set = false; |
| 5450 | - /** |
|
| 5450 | + /** |
|
| 5451 | 5451 | if($is_owner == 'not_set') |
| 5452 | - */ |
|
| 5453 | - if($is_owner === 'not_set') //eggsurplus: should be === |
|
| 5452 | + */ |
|
| 5453 | + if($is_owner === 'not_set') //eggsurplus: should be === |
|
| 5454 | 5454 | { |
| 5455 | 5455 | $not_set = true; |
| 5456 | 5456 | $is_owner = $this->isOwner($current_user->id); |
| 5457 | 5457 | } |
| 5458 | - // DJM - OBS Customizations - May 2009 |
|
| 5459 | - // Moved this code to convert to lowercase from below. |
|
| 5460 | - // Added new action variable. |
|
| 5461 | - $view = strtolower($view); |
|
| 5462 | - $action = ''; |
|
| 5463 | - // DJM - OBS Customizations - END CHANGE |
|
| 5464 | - if($in_group === 'not_set') |
|
| 5465 | - { |
|
| 5466 | - require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 5467 | - // DJM - OBS Customizations - May 2009 |
|
| 5468 | - // Added the following switch statement to convert the view |
|
| 5469 | - // into an action value. As per the switch below. |
|
| 5470 | - // Added the action parameter to the groupHasAccess call. |
|
| 5471 | - switch ($view) |
|
| 5472 | - { |
|
| 5473 | - case 'list': |
|
| 5474 | - case 'index': |
|
| 5475 | - case 'listview': |
|
| 5476 | - $action = "list"; |
|
| 5477 | - break; |
|
| 5478 | - case 'edit': |
|
| 5479 | - case 'save': |
|
| 5480 | - case 'popupeditview': |
|
| 5481 | - case 'editview': |
|
| 5482 | - $action = "edit"; |
|
| 5483 | - break; |
|
| 5484 | - case 'view': |
|
| 5485 | - case 'detail': |
|
| 5486 | - case 'detailview': |
|
| 5487 | - $action = "view"; |
|
| 5488 | - break; |
|
| 5489 | - case 'delete': |
|
| 5490 | - $action = "delete" ; |
|
| 5491 | - break; |
|
| 5492 | - case 'export': |
|
| 5493 | - $action = "export"; |
|
| 5494 | - break; |
|
| 5495 | - case 'import': |
|
| 5496 | - $action = "import"; |
|
| 5497 | - break; |
|
| 5498 | - default: |
|
| 5499 | - $action = ""; |
|
| 5500 | - break; |
|
| 5501 | - } |
|
| 5502 | - $in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); |
|
| 5503 | - // DJM - OBS Customizations - END CHANGE |
|
| 5504 | - } |
|
| 5458 | + // DJM - OBS Customizations - May 2009 |
|
| 5459 | + // Moved this code to convert to lowercase from below. |
|
| 5460 | + // Added new action variable. |
|
| 5461 | + $view = strtolower($view); |
|
| 5462 | + $action = ''; |
|
| 5463 | + // DJM - OBS Customizations - END CHANGE |
|
| 5464 | + if($in_group === 'not_set') |
|
| 5465 | + { |
|
| 5466 | + require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 5467 | + // DJM - OBS Customizations - May 2009 |
|
| 5468 | + // Added the following switch statement to convert the view |
|
| 5469 | + // into an action value. As per the switch below. |
|
| 5470 | + // Added the action parameter to the groupHasAccess call. |
|
| 5471 | + switch ($view) |
|
| 5472 | + { |
|
| 5473 | + case 'list': |
|
| 5474 | + case 'index': |
|
| 5475 | + case 'listview': |
|
| 5476 | + $action = "list"; |
|
| 5477 | + break; |
|
| 5478 | + case 'edit': |
|
| 5479 | + case 'save': |
|
| 5480 | + case 'popupeditview': |
|
| 5481 | + case 'editview': |
|
| 5482 | + $action = "edit"; |
|
| 5483 | + break; |
|
| 5484 | + case 'view': |
|
| 5485 | + case 'detail': |
|
| 5486 | + case 'detailview': |
|
| 5487 | + $action = "view"; |
|
| 5488 | + break; |
|
| 5489 | + case 'delete': |
|
| 5490 | + $action = "delete" ; |
|
| 5491 | + break; |
|
| 5492 | + case 'export': |
|
| 5493 | + $action = "export"; |
|
| 5494 | + break; |
|
| 5495 | + case 'import': |
|
| 5496 | + $action = "import"; |
|
| 5497 | + break; |
|
| 5498 | + default: |
|
| 5499 | + $action = ""; |
|
| 5500 | + break; |
|
| 5501 | + } |
|
| 5502 | + $in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); |
|
| 5503 | + // DJM - OBS Customizations - END CHANGE |
|
| 5504 | + } |
|
| 5505 | 5505 | //if we don't implent acls return true |
| 5506 | 5506 | if(!$this->bean_implements('ACL')) |
| 5507 | 5507 | return true; |
@@ -5511,10 +5511,10 @@ discard block |
||
| 5511 | 5511 | case 'list': |
| 5512 | 5512 | case 'index': |
| 5513 | 5513 | case 'listview': |
| 5514 | - /** |
|
| 5514 | + /** |
|
| 5515 | 5515 | return ACLController::checkAccess($this->module_dir,'list', true); |
| 5516 | - */ |
|
| 5517 | - return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group); |
|
| 5516 | + */ |
|
| 5517 | + return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group); |
|
| 5518 | 5518 | case 'edit': |
| 5519 | 5519 | case 'save': |
| 5520 | 5520 | if( !$is_owner && $not_set && !empty($this->id)){ |
@@ -5529,32 +5529,32 @@ discard block |
||
| 5529 | 5529 | } |
| 5530 | 5530 | case 'popupeditview': |
| 5531 | 5531 | case 'editview': |
| 5532 | - /** |
|
| 5532 | + /** |
|
| 5533 | 5533 | return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype); |
| 5534 | - */ |
|
| 5535 | - return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group); |
|
| 5534 | + */ |
|
| 5535 | + return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group); |
|
| 5536 | 5536 | case 'view': |
| 5537 | 5537 | case 'detail': |
| 5538 | 5538 | case 'detailview': |
| 5539 | - /** |
|
| 5539 | + /** |
|
| 5540 | 5540 | return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype); |
| 5541 | - */ |
|
| 5542 | - return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group); |
|
| 5541 | + */ |
|
| 5542 | + return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group); |
|
| 5543 | 5543 | case 'delete': |
| 5544 | - /** |
|
| 5544 | + /** |
|
| 5545 | 5545 | return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype); |
| 5546 | - */ |
|
| 5547 | - return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group); |
|
| 5546 | + */ |
|
| 5547 | + return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group); |
|
| 5548 | 5548 | case 'export': |
| 5549 | - /** |
|
| 5549 | + /** |
|
| 5550 | 5550 | return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype); |
| 5551 | - */ |
|
| 5552 | - return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group); |
|
| 5551 | + */ |
|
| 5552 | + return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group); |
|
| 5553 | 5553 | case 'import': |
| 5554 | - /** |
|
| 5554 | + /** |
|
| 5555 | 5555 | return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype); |
| 5556 | - */ |
|
| 5557 | - return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group); |
|
| 5556 | + */ |
|
| 5557 | + return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group); |
|
| 5558 | 5558 | } |
| 5559 | 5559 | //if it is not one of the above views then it should be implemented on the page level |
| 5560 | 5560 | return true; |
@@ -5562,10 +5562,10 @@ discard block |
||
| 5562 | 5562 | /* END - SECURITY GROUPS */ |
| 5563 | 5563 | |
| 5564 | 5564 | /** |
| 5565 | - * Get owner field |
|
| 5566 | - * |
|
| 5567 | - * @return STRING |
|
| 5568 | - */ |
|
| 5565 | + * Get owner field |
|
| 5566 | + * |
|
| 5567 | + * @return STRING |
|
| 5568 | + */ |
|
| 5569 | 5569 | function getOwnerField($returnFieldName = false) |
| 5570 | 5570 | { |
| 5571 | 5571 | if (isset($this->field_defs['assigned_user_id'])) |
@@ -5582,11 +5582,11 @@ discard block |
||
| 5582 | 5582 | } |
| 5583 | 5583 | |
| 5584 | 5584 | /** |
| 5585 | - * Returns true of false if the user_id passed is the owner |
|
| 5586 | - * |
|
| 5587 | - * @param GUID $user_id |
|
| 5588 | - * @return boolean |
|
| 5589 | - */ |
|
| 5585 | + * Returns true of false if the user_id passed is the owner |
|
| 5586 | + * |
|
| 5587 | + * @param GUID $user_id |
|
| 5588 | + * @return boolean |
|
| 5589 | + */ |
|
| 5590 | 5590 | function isOwner($user_id) |
| 5591 | 5591 | { |
| 5592 | 5592 | //if we don't have an id we must be the owner as we are creating it |
@@ -5615,11 +5615,11 @@ discard block |
||
| 5615 | 5615 | return false; |
| 5616 | 5616 | } |
| 5617 | 5617 | /** |
| 5618 | - * Gets there where statement for checking if a user is an owner |
|
| 5619 | - * |
|
| 5620 | - * @param GUID $user_id |
|
| 5621 | - * @return STRING |
|
| 5622 | - */ |
|
| 5618 | + * Gets there where statement for checking if a user is an owner |
|
| 5619 | + * |
|
| 5620 | + * @param GUID $user_id |
|
| 5621 | + * @return STRING |
|
| 5622 | + */ |
|
| 5623 | 5623 | function getOwnerWhere($user_id) |
| 5624 | 5624 | { |
| 5625 | 5625 | if(isset($this->field_defs['assigned_user_id'])) |
@@ -5634,12 +5634,12 @@ discard block |
||
| 5634 | 5634 | } |
| 5635 | 5635 | |
| 5636 | 5636 | /** |
| 5637 | - * |
|
| 5638 | - * Used in order to manage ListView links and if they should |
|
| 5639 | - * links or not based on the ACL permissions of the user |
|
| 5640 | - * |
|
| 5641 | - * @return ARRAY of STRINGS |
|
| 5642 | - */ |
|
| 5637 | + * |
|
| 5638 | + * Used in order to manage ListView links and if they should |
|
| 5639 | + * links or not based on the ACL permissions of the user |
|
| 5640 | + * |
|
| 5641 | + * @return ARRAY of STRINGS |
|
| 5642 | + */ |
|
| 5643 | 5643 | function listviewACLHelper() |
| 5644 | 5644 | { |
| 5645 | 5645 | $array_assign = array(); |
@@ -5655,10 +5655,10 @@ discard block |
||
| 5655 | 5655 | } |
| 5656 | 5656 | |
| 5657 | 5657 | /** |
| 5658 | - * returns this bean as an array |
|
| 5659 | - * |
|
| 5660 | - * @return array of fields with id, name, access and category |
|
| 5661 | - */ |
|
| 5658 | + * returns this bean as an array |
|
| 5659 | + * |
|
| 5660 | + * @return array of fields with id, name, access and category |
|
| 5661 | + */ |
|
| 5662 | 5662 | function toArray($dbOnly = false, $stringOnly = false, $upperKeys=false) |
| 5663 | 5663 | { |
| 5664 | 5664 | static $cache = array(); |
@@ -5688,10 +5688,10 @@ discard block |
||
| 5688 | 5688 | } |
| 5689 | 5689 | |
| 5690 | 5690 | /** |
| 5691 | - * Converts an array into an acl mapping name value pairs into files |
|
| 5692 | - * |
|
| 5693 | - * @param Array $arr |
|
| 5694 | - */ |
|
| 5691 | + * Converts an array into an acl mapping name value pairs into files |
|
| 5692 | + * |
|
| 5693 | + * @param Array $arr |
|
| 5694 | + */ |
|
| 5695 | 5695 | function fromArray($arr) |
| 5696 | 5696 | { |
| 5697 | 5697 | foreach($arr as $name=>$value) |
@@ -5709,13 +5709,13 @@ discard block |
||
| 5709 | 5709 | public function convertRow($row) |
| 5710 | 5710 | { |
| 5711 | 5711 | foreach($this->field_defs as $name => $fieldDef) |
| 5712 | - { |
|
| 5713 | - // skip empty fields and non-db fields |
|
| 5712 | + { |
|
| 5713 | + // skip empty fields and non-db fields |
|
| 5714 | 5714 | if (isset($name) && !empty($row[$name])) { |
| 5715 | 5715 | $row[$name] = $this->convertField($row[$name], $fieldDef); |
| 5716 | 5716 | } |
| 5717 | 5717 | } |
| 5718 | - return $row; |
|
| 5718 | + return $row; |
|
| 5719 | 5719 | } |
| 5720 | 5720 | |
| 5721 | 5721 | /** |
@@ -5763,18 +5763,18 @@ discard block |
||
| 5763 | 5763 | return !empty($GLOBALS['dictionary'][$this->object_name]['custom_fields']); |
| 5764 | 5764 | } |
| 5765 | 5765 | |
| 5766 | - /** |
|
| 5767 | - * Ensure that fields within order by clauses are properly qualified with |
|
| 5768 | - * their tablename. This qualification is a requirement for sql server support. |
|
| 5769 | - * |
|
| 5770 | - * @param string $order_by original order by from the query |
|
| 5771 | - * @param string $qualify prefix for columns in the order by list. |
|
| 5772 | - * @return prefixed |
|
| 5773 | - * |
|
| 5774 | - * Internal function do not override. |
|
| 5775 | - */ |
|
| 5776 | - function create_qualified_order_by( $order_by, $qualify) |
|
| 5777 | - { // if the column is empty, but the sort order is defined, the value will throw an error, so do not proceed if no order by is given |
|
| 5766 | + /** |
|
| 5767 | + * Ensure that fields within order by clauses are properly qualified with |
|
| 5768 | + * their tablename. This qualification is a requirement for sql server support. |
|
| 5769 | + * |
|
| 5770 | + * @param string $order_by original order by from the query |
|
| 5771 | + * @param string $qualify prefix for columns in the order by list. |
|
| 5772 | + * @return prefixed |
|
| 5773 | + * |
|
| 5774 | + * Internal function do not override. |
|
| 5775 | + */ |
|
| 5776 | + function create_qualified_order_by( $order_by, $qualify) |
|
| 5777 | + { // if the column is empty, but the sort order is defined, the value will throw an error, so do not proceed if no order by is given |
|
| 5778 | 5778 | if (empty($order_by)) |
| 5779 | 5779 | { |
| 5780 | 5780 | return $order_by; |
@@ -5789,17 +5789,17 @@ discard block |
||
| 5789 | 5789 | $comma = ", "; |
| 5790 | 5790 | } |
| 5791 | 5791 | return $order_by_clause; |
| 5792 | - } |
|
| 5792 | + } |
|
| 5793 | 5793 | |
| 5794 | - /** |
|
| 5795 | - * Combined the contents of street field 2 thru 4 into the main field |
|
| 5796 | - * |
|
| 5797 | - * @param string $street_field |
|
| 5798 | - */ |
|
| 5794 | + /** |
|
| 5795 | + * Combined the contents of street field 2 thru 4 into the main field |
|
| 5796 | + * |
|
| 5797 | + * @param string $street_field |
|
| 5798 | + */ |
|
| 5799 | 5799 | |
| 5800 | - function add_address_streets( |
|
| 5801 | - $street_field |
|
| 5802 | - ) |
|
| 5800 | + function add_address_streets( |
|
| 5801 | + $street_field |
|
| 5802 | + ) |
|
| 5803 | 5803 | { |
| 5804 | 5804 | if (isset($this->$street_field)) { |
| 5805 | 5805 | $street_field_2 = $street_field.'_2'; |
@@ -5853,9 +5853,9 @@ discard block |
||
| 5853 | 5853 | } |
| 5854 | 5854 | |
| 5855 | 5855 | /** |
| 5856 | - * Moved from save() method, functionality is the same, but this is intended to handle |
|
| 5857 | - * Optimistic locking functionality. |
|
| 5858 | - */ |
|
| 5856 | + * Moved from save() method, functionality is the same, but this is intended to handle |
|
| 5857 | + * Optimistic locking functionality. |
|
| 5858 | + */ |
|
| 5859 | 5859 | private function _checkOptimisticLocking($action, $isUpdate){ |
| 5860 | 5860 | if($this->optimistic_lock && !isset($_SESSION['o_lock_fs'])){ |
| 5861 | 5861 | if(isset($_SESSION['o_lock_id']) && $_SESSION['o_lock_id'] == $this->id && $_SESSION['o_lock_on'] == $this->object_name) |
@@ -5894,8 +5894,8 @@ discard block |
||
| 5894 | 5894 | } |
| 5895 | 5895 | |
| 5896 | 5896 | /** |
| 5897 | - * Send assignment notifications and invites for meetings and calls |
|
| 5898 | - */ |
|
| 5897 | + * Send assignment notifications and invites for meetings and calls |
|
| 5898 | + */ |
|
| 5899 | 5899 | private function _sendNotifications($check_notify){ |
| 5900 | 5900 | 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 | 5901 | && !$this->isOwner($this->created_by) ) // cn: bug 42727 no need to send email to owner (within workflow) |
@@ -5983,11 +5983,11 @@ discard block |
||
| 5983 | 5983 | $result = sugar_cache_retrieve($cache_key); |
| 5984 | 5984 | if(!empty($result)) |
| 5985 | 5985 | { |
| 5986 | - // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache. |
|
| 5987 | - if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
| 5988 | - { |
|
| 5989 | - return null; |
|
| 5990 | - } |
|
| 5986 | + // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache. |
|
| 5987 | + if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
| 5988 | + { |
|
| 5989 | + return null; |
|
| 5990 | + } |
|
| 5991 | 5991 | |
| 5992 | 5992 | return $result; |
| 5993 | 5993 | } |
@@ -6004,7 +6004,7 @@ discard block |
||
| 6004 | 6004 | if(empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key])) |
| 6005 | 6005 | { |
| 6006 | 6006 | // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation |
| 6007 | - sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
|
| 6007 | + sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
|
| 6008 | 6008 | return null; |
| 6009 | 6009 | } |
| 6010 | 6010 | |
@@ -6015,8 +6015,8 @@ discard block |
||
| 6015 | 6015 | |
| 6016 | 6016 | // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation |
| 6017 | 6017 | sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
| 6018 | - return null; |
|
| 6019 | - } |
|
| 6018 | + return null; |
|
| 6019 | + } |
|
| 6020 | 6020 | |
| 6021 | 6021 | /** |
| 6022 | 6022 | * Returns the ACL category for this module; defaults to the SugarBean::$acl_category if defined |
@@ -6037,10 +6037,10 @@ discard block |
||
| 6037 | 6037 | * @param string $where |
| 6038 | 6038 | * @return string SQL query |
| 6039 | 6039 | */ |
| 6040 | - public function create_export_query($order_by, $where) |
|
| 6041 | - { |
|
| 6042 | - return $this->create_new_list_query($order_by, $where, array(), array(), 0, '', false, $this, true, true); |
|
| 6043 | - } |
|
| 6040 | + public function create_export_query($order_by, $where) |
|
| 6041 | + { |
|
| 6042 | + return $this->create_new_list_query($order_by, $where, array(), array(), 0, '', false, $this, true, true); |
|
| 6043 | + } |
|
| 6044 | 6044 | |
| 6045 | 6045 | /** |
| 6046 | 6046 | * Determine whether the given field is a relate field |
@@ -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 | } |
@@ -48,8 +48,8 @@ |
||
| 48 | 48 | $mod_strings = array ( |
| 49 | 49 | 'LBL_DELETE_USER_CONFIRM' => 'When the User record is deleted, the corresponding Employee record will also be deleted. After the user is deleted, any workflow definitions and reports involving the user might need to be updated.<br/><br/> Deleting a User record cannot be undone.', |
| 50 | 50 | |
| 51 | - 'LBL_DELETE_GROUP_CONFIRM' => 'Are you sure you want to delete this Group User? Click OK to delete the User record.<br/>After clicking OK, you will be given the ability to reassign records assigned to the Group User to another user.', |
|
| 52 | - 'LBL_DELETE_PORTAL_CONFIRM' => 'Are you sure you want to delete this Portal API User? Click OK to delete the User record.', |
|
| 51 | + 'LBL_DELETE_GROUP_CONFIRM' => 'Are you sure you want to delete this Group User? Click OK to delete the User record.<br/>After clicking OK, you will be given the ability to reassign records assigned to the Group User to another user.', |
|
| 52 | + 'LBL_DELETE_PORTAL_CONFIRM' => 'Are you sure you want to delete this Portal API User? Click OK to delete the User record.', |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | 'LNK_IMPORT_USERS' => 'Import Users', |