Completed
Push — master ( a75ecc...97ae17 )
by Adam
71:21 queued 52:34
created
modules/AOR_Charts/AOR_Chart.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
modules/AOR_Reports/controller.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
modules/AOR_Reports/language/en_us.lang.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -23,66 +23,66 @@
 block discarded – undo
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
 );
Please login to merge, or discard this patch.
data/SugarBean.php 1 patch
Indentation   +739 added lines, -739 removed lines patch added patch discarded remove patch
@@ -84,27 +84,27 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
modules/Users/language/en_us.lang.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@
 block discarded – undo
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',
Please login to merge, or discard this patch.
modules/ACLActions/ACLAction.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 /* BEGIN - SECURITY GROUPS */
41 41
 if(file_exists("modules/ACLActions/actiondefs.override.php")){
42
-	require_once("modules/ACLActions/actiondefs.override.php");
42
+    require_once("modules/ACLActions/actiondefs.override.php");
43 43
 } else {
44 44
 require_once('modules/ACLActions/actiondefs.php');
45 45
 }
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
     }
56 56
 
57 57
     /**
58
-    * static addActions($category, $type='module')
59
-    * Adds all default actions for a category/type
60
-    *
61
-    * @param STRING $category - the category (e.g module name - Accounts, Contacts)
62
-    * @param STRING $type - the type (e.g. 'module', 'field')
63
-    */
58
+     * static addActions($category, $type='module')
59
+     * Adds all default actions for a category/type
60
+     *
61
+     * @param STRING $category - the category (e.g module name - Accounts, Contacts)
62
+     * @param STRING $type - the type (e.g. 'module', 'field')
63
+     */
64 64
     static function addActions($category, $type='module'){
65 65
         global $ACLActions;
66 66
         $db = DBManagerFactory::getInstance();
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     }
92 92
 
93 93
     /**
94
-    * static removeActions($category, $type='module')
95
-    * Removes all default actions for a category/type
96
-    *
97
-    * @param STRING $category - the category (e.g module name - Accounts, Contacts)
98
-    * @param STRING $type - the type (e.g. 'module', 'field')
99
-    */
94
+     * static removeActions($category, $type='module')
95
+     * Removes all default actions for a category/type
96
+     *
97
+     * @param STRING $category - the category (e.g module name - Accounts, Contacts)
98
+     * @param STRING $type - the type (e.g. 'module', 'field')
99
+     */
100 100
     public static function removeActions($category, $type='module'){
101 101
         global $ACLActions;
102 102
         $db = DBManagerFactory::getInstance();
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
     }
119 119
 
120 120
     /**
121
-    * static AccessColor($access)
122
-    *
123
-    * returns the color associated with an access level
124
-    * these colors exist in the definitions in modules/ACLActions/actiondefs.php
125
-    * @param INT $access - the access level you want the color for
126
-    * @return the color either name or hex representation or false if the level does not exist
127
-    */
121
+     * static AccessColor($access)
122
+     *
123
+     * returns the color associated with an access level
124
+     * these colors exist in the definitions in modules/ACLActions/actiondefs.php
125
+     * @param INT $access - the access level you want the color for
126
+     * @return the color either name or hex representation or false if the level does not exist
127
+     */
128 128
     protected static function AccessColor($access){
129 129
         global $ACLActionAccessLevels;
130 130
         if(isset($ACLActionAccessLevels[$access])){
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
     }
137 137
 
138 138
     /**
139
-    * static AccessName($access)
140
-    *
141
-    * returns the translated name  associated with an access level
142
-    * these label definitions  exist in the definitions in modules/ACLActions/actiondefs.php
143
-    * @param INT $access - the access level you want the color for
144
-    * @return the translated access level name or false if the level does not exist
145
-    */
139
+     * static AccessName($access)
140
+     *
141
+     * returns the translated name  associated with an access level
142
+     * these label definitions  exist in the definitions in modules/ACLActions/actiondefs.php
143
+     * @param INT $access - the access level you want the color for
144
+     * @return the translated access level name or false if the level does not exist
145
+     */
146 146
     static function AccessName($access){
147 147
         global $ACLActionAccessLevels;
148 148
         if(isset($ACLActionAccessLevels[$access])){
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
     }
173 173
 
174 174
     /**
175
-    * static getAccessOptions()
176
-    * this is used for building select boxes
177
-    * @return array containg access levels (ints) as keys and access names as values
178
-    */
175
+     * static getAccessOptions()
176
+     * this is used for building select boxes
177
+     * @return array containg access levels (ints) as keys and access names as values
178
+     */
179 179
     protected static function getAccessOptions( $action, $type='module'){
180 180
         global $ACLActions;
181 181
         $options = array();
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
     }
190 190
 
191 191
     /**
192
-    * function static getDefaultActions()
193
-    * This function will return a list of acl actions with their default access levels
194
-    *
195
-    *
196
-    */
192
+     * function static getDefaultActions()
193
+     * This function will return a list of acl actions with their default access levels
194
+     *
195
+     *
196
+     */
197 197
     public static function getDefaultActions($type='module', $action=''){
198 198
         $query = "SELECT * FROM acl_actions WHERE deleted=0 ";
199 199
         if(!empty($type)){
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 
218 218
 
219 219
     /**
220
-    * static getUserActions($user_id,$refresh=false, $category='', $action='')
221
-    * returns a list of user actions
222
-    * @param GUID $user_id
223
-    * @param BOOLEAN $refresh
224
-    * @param STRING $category
225
-    * @param STRING $action
226
-    * @return ARRAY of ACLActionsArray
227
-    */
220
+     * static getUserActions($user_id,$refresh=false, $category='', $action='')
221
+     * returns a list of user actions
222
+     * @param GUID $user_id
223
+     * @param BOOLEAN $refresh
224
+     * @param STRING $category
225
+     * @param STRING $action
226
+     * @return ARRAY of ACLActionsArray
227
+     */
228 228
 
229 229
     static function getUserActions($user_id,$refresh=false, $category='',$type='', $action=''){
230 230
         //check in the session if we already have it loaded
@@ -256,15 +256,15 @@  discard block
 block discarded – undo
256 256
         if(!empty($type)){
257 257
             $additional_where .= " AND acl_actions.acltype = '$type' ";
258 258
         }
259
-		/* BEGIN - SECURITY GROUPS */ 
260
-		/**
259
+        /* BEGIN - SECURITY GROUPS */ 
260
+        /**
261 261
         $query = "SELECT acl_actions .*, acl_roles_actions.access_override
262 262
                     FROM acl_actions
263 263
                     LEFT JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' AND  acl_roles_users.deleted = 0
264 264
                     LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = acl_roles_users.role_id AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted=0
265 265
                     WHERE acl_actions.deleted=0 $additional_where ORDER BY category,name";
266
-		*/
267
-		$query = "(SELECT acl_actions .*, acl_roles_actions.access_override, 1 as user_role
266
+         */
267
+        $query = "(SELECT acl_actions .*, acl_roles_actions.access_override, 1 as user_role
268 268
 				FROM acl_actions
269 269
 				INNER JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' AND  acl_roles_users.deleted = 0
270 270
 				LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = acl_roles_users.role_id AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted=0
@@ -286,34 +286,34 @@  discard block
 block discarded – undo
286 286
 				WHERE acl_actions.deleted = 0 )
287 287
 
288 288
 				ORDER BY user_role desc, category,name,access_override desc"; //want non-null to show first
289
-		 /* END - SECURITY GROUPS */
289
+            /* END - SECURITY GROUPS */
290 290
         $result = $db->query($query);
291 291
         $selected_actions = array();
292
-		/* BEGIN - SECURITY GROUPS */ 
293
-		global $sugar_config;
294
-		$has_user_role = false; //used for user_role_precedence
295
-		$has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults
296
-		/* END - SECURITY GROUPS */
292
+        /* BEGIN - SECURITY GROUPS */ 
293
+        global $sugar_config;
294
+        $has_user_role = false; //used for user_role_precedence
295
+        $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults
296
+        /* END - SECURITY GROUPS */
297 297
         while($row = $db->fetchByAssoc($result, FALSE) ){
298
-			/* BEGIN - SECURITY GROUPS */ 
299
-			if($has_user_role == false && $row['user_role'] == 1) {
300
-				$has_user_role = true;
301
-			}
302
-			if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) {
303
-				$has_role = true;
304
-			}
305
-			//if user roles should take precedence over group roles and we have a user role 
306
-			//break when we get to processing the group roles
307
-			if($has_user_role == true && $row['user_role'] == 0 
308
-					&& isset($sugar_config['securitysuite_user_role_precedence'])
309
-					&& $sugar_config['securitysuite_user_role_precedence'] == true ) 
310
-			{
311
-				break; 
312
-			}
313
-			if($row['user_role'] == -1 && $has_role == true) {
314
-				break; //no need for default actions when a role is assigned to the user or user's group already
315
-			}
316
-			/* END - SECURITY GROUPS */
298
+            /* BEGIN - SECURITY GROUPS */ 
299
+            if($has_user_role == false && $row['user_role'] == 1) {
300
+                $has_user_role = true;
301
+            }
302
+            if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) {
303
+                $has_role = true;
304
+            }
305
+            //if user roles should take precedence over group roles and we have a user role 
306
+            //break when we get to processing the group roles
307
+            if($has_user_role == true && $row['user_role'] == 0 
308
+                    && isset($sugar_config['securitysuite_user_role_precedence'])
309
+                    && $sugar_config['securitysuite_user_role_precedence'] == true ) 
310
+            {
311
+                break; 
312
+            }
313
+            if($row['user_role'] == -1 && $has_role == true) {
314
+                break; //no need for default actions when a role is assigned to the user or user's group already
315
+            }
316
+            /* END - SECURITY GROUPS */
317 317
             $acl = new ACLAction();
318 318
             $isOverride  = false;
319 319
             $acl->populateFromRow($row);
@@ -326,16 +326,16 @@  discard block
 block discarded – undo
326 326
 
327 327
             }
328 328
             if(!isset($selected_actions[$acl->category][$acl->acltype][$acl->name])
329
-				|| (
330
-					/* BEGIN - SECURITY GROUPS - additive security*/
331
-					(
332
-						(isset($sugar_config['securitysuite_additive']) && $sugar_config['securitysuite_additive'] == true
333
-						&& $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] < $acl->aclaccess) 
334
-					||
335
-						((!isset($sugar_config['securitysuite_additive']) || $sugar_config['securitysuite_additive'] == false)
336
-						&& $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] > $acl->aclaccess) 
337
-					)
338
-					/* END - SECURITY GROUPS */
329
+                || (
330
+                    /* BEGIN - SECURITY GROUPS - additive security*/
331
+                    (
332
+                        (isset($sugar_config['securitysuite_additive']) && $sugar_config['securitysuite_additive'] == true
333
+                        && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] < $acl->aclaccess) 
334
+                    ||
335
+                        ((!isset($sugar_config['securitysuite_additive']) || $sugar_config['securitysuite_additive'] == false)
336
+                        && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] > $acl->aclaccess) 
337
+                    )
338
+                    /* END - SECURITY GROUPS */
339 339
                     && $isOverride
340 340
                     )
341 341
                 ||
@@ -388,70 +388,70 @@  discard block
 block discarded – undo
388 388
     }
389 389
     
390 390
     /**
391
-    * (static/ non-static)function hasAccess($is_owner= false , $access = 0)
392
-    * checks if a user has access to this acl if the user is an owner it will check if owners have access
393
-    *
394
-    * This function may either be used statically or not. If used staticlly a user must pass in an access level not equal to zero
395
-    * @param boolean $is_owner
396
-    * @param int $access
397
-    * @return true or false
398
-    */
399
-	/* BEGIN - SECURITY GROUPS */
400
-	/**
391
+     * (static/ non-static)function hasAccess($is_owner= false , $access = 0)
392
+     * checks if a user has access to this acl if the user is an owner it will check if owners have access
393
+     *
394
+     * This function may either be used statically or not. If used staticlly a user must pass in an access level not equal to zero
395
+     * @param boolean $is_owner
396
+     * @param int $access
397
+     * @return true or false
398
+     */
399
+    /* BEGIN - SECURITY GROUPS */
400
+    /**
401 401
     static function hasAccess($is_owner=false, $access = 0){
402
-	*/
403
-	static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){
404
-		/**
402
+     */
403
+    static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){
404
+        /**
405 405
         if($access != 0 && $access == ACL_ALLOW_ALL || ($is_owner && $access == ACL_ALLOW_OWNER))return true;
406 406
        //if this exists, then this function is not static, so check the aclaccess parameter
407 407
         if(isset($this) && isset($this->aclaccess)){
408 408
             if($this->aclaccess == ACL_ALLOW_ALL || ($is_owner && $this->aclaccess == ACL_ALLOW_OWNER))
409 409
             return true;
410 410
         }
411
-		*/
412
-		if($access != 0 && ($access == ACL_ALLOW_ALL 
413
-			|| ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) )  //if owner that's better than in group so count it...better way to clean this up?
414
-			|| ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow
415
-		)) {
416
-			return true;
417
-		}
411
+         */
412
+        if($access != 0 && ($access == ACL_ALLOW_ALL 
413
+            || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) )  //if owner that's better than in group so count it...better way to clean this up?
414
+            || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow
415
+        )) {
416
+            return true;
417
+        }
418 418
         if(!is_null($action) && isset($action->aclaccess)){
419
-			if($action->aclaccess == ACL_ALLOW_ALL
420
-				|| ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP))
421
-				|| ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow
422
-			) {
423
-            	return true;
424
-        	}
425
-		}
419
+            if($action->aclaccess == ACL_ALLOW_ALL
420
+                || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP))
421
+                || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow
422
+            ) {
423
+                return true;
424
+            }
425
+        }
426 426
         return false;
427 427
     }
428
-	/* END - SECURITY GROUPS */
429
-
430
-	/* BEGIN - SECURITY GROUPS */
431
-	/**
432
-	 * STATIC function userNeedsSecurityGroup($user_id, $category, $action,$type='module')
433
-	 * checks if a user should have ownership to do an action
434
-	 *
435
-	 * @param GUID $user_id
436
-	 * @param STRING $category
437
-	 * @param STRING $action
438
-	 * @param STRING $type
439
-	 * @return boolean
440
-	 */
441
-	static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){
442
-		//check if we don't have it set in the cache if not lets reload the cache
428
+    /* END - SECURITY GROUPS */
429
+
430
+    /* BEGIN - SECURITY GROUPS */
431
+    /**
432
+     * STATIC function userNeedsSecurityGroup($user_id, $category, $action,$type='module')
433
+     * checks if a user should have ownership to do an action
434
+     *
435
+     * @param GUID $user_id
436
+     * @param STRING $category
437
+     * @param STRING $action
438
+     * @param STRING $type
439
+     * @return boolean
440
+     */
441
+    static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){
442
+        //check if we don't have it set in the cache if not lets reload the cache
443 443
 		
444
-		if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){
445
-			ACLAction::getUserActions($user_id, false);
444
+        if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){
445
+            ACLAction::getUserActions($user_id, false);
446 446
 			
447
-		}
447
+        }
448 448
 		
449
-		if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){
450
-			return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP;
451
-		}
449
+        if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){
450
+            return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP;
451
+        }
452 452
         return false;
453 453
     }
454
-	/* END - SECURITY GROUPS */	
454
+    /* END - SECURITY GROUPS */	
455 455
 
456 456
 
457 457
 
@@ -461,20 +461,20 @@  discard block
 block discarded – undo
461 461
 
462 462
 
463 463
     /**
464
-    * static function userHasAccess($user_id, $category, $action, $is_owner = false)
465
-    *
466
-    * @param GUID $user_id the user id who you want to check access for
467
-    * @param STRING $category the category you would like to check access for
468
-    * @param STRING $action the action of that category you would like to check access for
469
-    * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for
470
-    */
471
-	/* BEGIN - SECURITY GROUPS - added $in_group */
472
-	/**
464
+     * static function userHasAccess($user_id, $category, $action, $is_owner = false)
465
+     *
466
+     * @param GUID $user_id the user id who you want to check access for
467
+     * @param STRING $category the category you would like to check access for
468
+     * @param STRING $action the action of that category you would like to check access for
469
+     * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for
470
+     */
471
+    /* BEGIN - SECURITY GROUPS - added $in_group */
472
+    /**
473 473
     public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false){
474
-	*/
475
-	public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){
476
-       global $current_user;
477
-       if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){
474
+     */
475
+    public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){
476
+        global $current_user;
477
+        if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){
478 478
         return true;
479 479
         }
480 480
         //check if we don't have it set in the cache if not lets reload the cache
@@ -488,22 +488,22 @@  discard block
 block discarded – undo
488 488
 /**
489 489
             return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']);
490 490
 */
491
-			return ACLAction::hasAccess($is_owner, $in_group, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']);
491
+            return ACLAction::hasAccess($is_owner, $in_group, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']);
492 492
         }
493 493
         return false;
494 494
 
495 495
     }
496
-	/* END - SECURITY GROUPS */
496
+    /* END - SECURITY GROUPS */
497 497
     /**
498
-    * function getUserAccessLevel($user_id, $category, $action,$type='module')
499
-    * returns the access level for a given category and action
500
-    *
501
-    * @param GUID  $user_id
502
-    * @param STRING $category
503
-    * @param STRING $action
504
-    * @param STRING $type
505
-    * @return INT (ACCESS LEVEL)
506
-    */
498
+     * function getUserAccessLevel($user_id, $category, $action,$type='module')
499
+     * returns the access level for a given category and action
500
+     *
501
+     * @param GUID  $user_id
502
+     * @param STRING $category
503
+     * @param STRING $action
504
+     * @param STRING $type
505
+     * @return INT (ACCESS LEVEL)
506
+     */
507 507
     public static function getUserAccessLevel($user_id, $category, $action,$type='module'){
508 508
         if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){
509 509
             ACLAction::getUserActions($user_id, false);
@@ -520,15 +520,15 @@  discard block
 block discarded – undo
520 520
     }
521 521
 
522 522
     /**
523
-    * STATIC function userNeedsOwnership($user_id, $category, $action,$type='module')
524
-    * checks if a user should have ownership to do an action
525
-    *
526
-    * @param GUID $user_id
527
-    * @param STRING $category
528
-    * @param STRING $action
529
-    * @param STRING $type
530
-    * @return boolean
531
-    */
523
+     * STATIC function userNeedsOwnership($user_id, $category, $action,$type='module')
524
+     * checks if a user should have ownership to do an action
525
+     *
526
+     * @param GUID $user_id
527
+     * @param STRING $category
528
+     * @param STRING $action
529
+     * @param STRING $type
530
+     * @return boolean
531
+     */
532 532
     public static function userNeedsOwnership($user_id, $category, $action,$type='module'){
533 533
         //check if we don't have it set in the cache if not lets reload the cache
534 534
 
@@ -545,12 +545,12 @@  discard block
 block discarded – undo
545 545
 
546 546
     }
547 547
     /**
548
-    *
549
-    * static pass by ref setupCategoriesMatrix(&$categories)
550
-    * takes in an array of categories and modifes them adding display information
551
-    *
552
-    * @param unknown_type $categories
553
-    */
548
+     *
549
+     * static pass by ref setupCategoriesMatrix(&$categories)
550
+     * takes in an array of categories and modifes them adding display information
551
+     *
552
+     * @param unknown_type $categories
553
+     */
554 554
     public static function setupCategoriesMatrix(&$categories){
555 555
         global $ACLActions, $current_user;
556 556
         $names = array();
@@ -593,11 +593,11 @@  discard block
 block discarded – undo
593 593
 
594 594
 
595 595
     /**
596
-    * function toArray()
597
-    * returns this acl as an array
598
-    *
599
-    * @return array of fields with id, name, access and category
600
-    */
596
+     * function toArray()
597
+     * returns this acl as an array
598
+     *
599
+     * @return array of fields with id, name, access and category
600
+     */
601 601
     function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false){
602 602
         $array_fields = array('id', 'aclaccess');
603 603
         $arr = array();
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
     }
609 609
 
610 610
     /**
611
-    * function fromArray($arr)
612
-    * converts an array into an acl mapping name value pairs into files
613
-    *
614
-    * @param Array $arr
615
-    */
611
+     * function fromArray($arr)
612
+     * converts an array into an acl mapping name value pairs into files
613
+     *
614
+     * @param Array $arr
615
+     */
616 616
     function fromArray($arr){
617 617
         foreach($arr as $name=>$value){
618 618
             $this->$name = $value;
@@ -620,10 +620,10 @@  discard block
 block discarded – undo
620 620
     }
621 621
 
622 622
     /**
623
-    * function clearSessionCache()
624
-    * clears the session variable storing the cache information for acls
625
-    *
626
-    */
623
+     * function clearSessionCache()
624
+     * clears the session variable storing the cache information for acls
625
+     *
626
+     */
627 627
     function clearSessionCache(){
628 628
         unset($_SESSION['ACL']);
629 629
     }
Please login to merge, or discard this patch.
modules/AOR_Reports/AOR_Report.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,42 +23,42 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 class AOR_Report extends Basic {
26
-	var $new_schema = true;
27
-	var $module_dir = 'AOR_Reports';
28
-	var $object_name = 'AOR_Report';
29
-	var $table_name = 'aor_reports';
30
-	var $importable = true;
31
-	var $disable_row_level_security = true ;
32
-
33
-	var $id;
34
-	var $name;
35
-	var $date_entered;
36
-	var $date_modified;
37
-	var $modified_user_id;
38
-	var $modified_by_name;
39
-	var $created_by;
40
-	var $created_by_name;
41
-	var $description;
42
-	var $deleted;
43
-	var $created_by_link;
44
-	var $modified_user_link;
45
-	var $assigned_user_id;
46
-	var $assigned_user_name;
47
-	var $assigned_user_link;
48
-	var $report_module;
49
-
50
-	function AOR_Report(){
51
-		parent::Basic();
26
+    var $new_schema = true;
27
+    var $module_dir = 'AOR_Reports';
28
+    var $object_name = 'AOR_Report';
29
+    var $table_name = 'aor_reports';
30
+    var $importable = true;
31
+    var $disable_row_level_security = true ;
32
+
33
+    var $id;
34
+    var $name;
35
+    var $date_entered;
36
+    var $date_modified;
37
+    var $modified_user_id;
38
+    var $modified_by_name;
39
+    var $created_by;
40
+    var $created_by_name;
41
+    var $description;
42
+    var $deleted;
43
+    var $created_by_link;
44
+    var $modified_user_link;
45
+    var $assigned_user_id;
46
+    var $assigned_user_name;
47
+    var $assigned_user_link;
48
+    var $report_module;
49
+
50
+    function AOR_Report(){
51
+        parent::Basic();
52 52
         $this->load_report_beans();
53 53
         require_once('modules/AOW_WorkFlow/aow_utils.php');
54
-	}
54
+    }
55 55
 
56
-	function bean_implements($interface){
57
-		switch($interface){
58
-			case 'ACL': return true;
59
-		}
60
-		return false;
61
-	}
56
+    function bean_implements($interface){
57
+        switch($interface){
58
+            case 'ACL': return true;
59
+        }
60
+        return false;
61
+    }
62 62
 
63 63
     function save($check_notify = FALSE){
64 64
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART){
122 122
         global $beanList;
123 123
         $linkedCharts = $this->get_linked_beans('aor_charts','AOR_Charts');
124
-	if(!$linkedCharts){
124
+    if(!$linkedCharts){
125 125
             //No charts to display
126 126
             return '';
127 127
         }
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
             while ($row = $this->db->fetchByAssoc($result)) {
479 479
                 if($html != '') $html .= '<br />';
480 480
 
481
-               $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra);
481
+                $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra);
482 482
 
483 483
             }
484 484
         }
Please login to merge, or discard this patch.
modules/AOR_Conditions/vardefs.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 $dictionary['AOR_Condition'] = array(
26
-	'table'=>'aor_conditions',
27
-	'audited'=>false,
28
-	'duplicate_merge'=>true,
29
-	'fields'=>array (
30
-  'aor_report_id' =>
31
-  array (
26
+    'table'=>'aor_conditions',
27
+    'audited'=>false,
28
+    'duplicate_merge'=>true,
29
+    'fields'=>array (
30
+    'aor_report_id' =>
31
+    array (
32 32
     'required' => false,
33 33
     'name' => 'aor_report_id',
34 34
     'vname' => 'LBL_AOR_REPORT_ID',
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
     'merge_filter' => 'disabled',
46 46
     'len' => 36,
47 47
     'size' => '20',
48
-  ),
49
-  'condition_order' => 
50
-  array (
48
+    ),
49
+    'condition_order' => 
50
+    array (
51 51
     'required' => false,
52 52
     'name' => 'condition_order',
53 53
     'vname' => 'LBL_ORDER',
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     'size' => '20',
67 67
     'enable_range_search' => false,
68 68
     'disable_num_format' => '',
69
-  ),
69
+    ),
70 70
         'logic_op' => array(
71 71
             'name' => 'logic_op',
72 72
             'vname' => 'LBL_LOGIC_OP',
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
             'vname' => 'LBL_PARENTHESIS',
79 79
             'type' => 'varchar',
80 80
         ),
81
-  'module_path' =>
82
-  array (
81
+    'module_path' =>
82
+    array (
83 83
     'name' => 'module_path',
84 84
     'type' => 'longtext',
85 85
     'vname' => 'LBL_MODULE_PATH',
86 86
     'isnull' => true,
87
-  ),
88
-  'field' => 
89
-  array (
87
+    ),
88
+    'field' => 
89
+    array (
90 90
     'required' => false,
91 91
     'name' => 'field',
92 92
     'vname' => 'LBL_FIELD',
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
     'options' => 'user_type_dom',
107 107
     'studio' => 'visible',
108 108
     'dependency' => false,
109
-  ),
110
-  'operator' => 
111
-  array (
109
+    ),
110
+    'operator' => 
111
+    array (
112 112
     'required' => false,
113 113
     'name' => 'operator',
114 114
     'vname' => 'LBL_OPERATOR',
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     'options' => 'aor_operator_list',
130 130
     'studio' => 'visible',
131 131
     'dependency' => false,
132
-  ),
132
+    ),
133 133
     'value_type' =>
134 134
     array (
135 135
     'required' => false,
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
     'options' => 'aor_condition_type_list',
153 153
     'studio' => 'visible',
154 154
     'dependency' => false,
155
-  ),
156
-  'value' => 
157
-  array (
155
+    ),
156
+    'value' => 
157
+    array (
158 158
     'required' => false,
159 159
     'name' => 'value',
160 160
     'vname' => 'LBL_VALUE',
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     'merge_filter' => 'disabled',
172 172
     'len' => '255',
173 173
     'size' => '20',
174
-  ),
174
+    ),
175 175
         'parameter' =>
176 176
             array (
177 177
                 'required' => false,
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
                 'merge_filter' => 'disabled',
191 191
                 'studio' => 'visible',
192 192
             ),
193
-  'aor_reports' =>
194
-  array (
193
+    'aor_reports' =>
194
+    array (
195 195
     'name' => 'aor_reports',
196 196
     'type' => 'link',
197 197
     'relationship' => 'aor_report_aor_conditions',
198 198
     'module'=>'AOR_Reports',
199 199
     'bean_name'=>'AOR_Reports',
200 200
     'source'=>'non-db',
201
-  ),
201
+    ),
202 202
 ),
203
-	'relationships'=>array (
203
+    'relationships'=>array (
204 204
 ),
205 205
     'indices' => array(
206 206
         array(
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
             'fields' => array('aor_report_id'),
210 210
         ),
211 211
     ),
212
-	'optimistic_locking'=>true,
213
-	'unified_search'=>true,
212
+    'optimistic_locking'=>true,
213
+    'unified_search'=>true,
214 214
 );
215 215
 
216 216
 if (!class_exists('VardefManager')){
Please login to merge, or discard this patch.
modules/Home/UnifiedSearchAdvanced.php 1 patch
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -69,95 +69,95 @@  discard block
 block discarded – undo
69 69
         $this->cache_display = sugar_cached('modules/unified_search_modules_display.php');
70 70
     }
71 71
 
72
-	function getDropDownDiv($tpl = 'modules/Home/UnifiedSearchAdvanced.tpl') {
73
-		global $app_list_strings, $app_strings;
72
+    function getDropDownDiv($tpl = 'modules/Home/UnifiedSearchAdvanced.tpl') {
73
+        global $app_list_strings, $app_strings;
74 74
 
75
-		if(!file_exists($this->cache_search))
76
-		{
77
-			$this->buildCache();
78
-		}
75
+        if(!file_exists($this->cache_search))
76
+        {
77
+            $this->buildCache();
78
+        }
79 79
 
80
-		$unified_search_modules_display = $this->getUnifiedSearchModulesDisplay();
80
+        $unified_search_modules_display = $this->getUnifiedSearchModulesDisplay();
81 81
 
82
-		global $mod_strings, $modListHeader, $app_list_strings, $current_user, $app_strings, $beanList;
83
-		$users_modules = $current_user->getPreference('globalSearch', 'search');
82
+        global $mod_strings, $modListHeader, $app_list_strings, $current_user, $app_strings, $beanList;
83
+        $users_modules = $current_user->getPreference('globalSearch', 'search');
84 84
 
85
-		// preferences are empty, select all
86
-		if(empty($users_modules)) {
87
-			$users_modules = array();
88
-			foreach($unified_search_modules_display as $module=>$data) {
89
-				if (!empty($data['visible']) ) {
85
+        // preferences are empty, select all
86
+        if(empty($users_modules)) {
87
+            $users_modules = array();
88
+            foreach($unified_search_modules_display as $module=>$data) {
89
+                if (!empty($data['visible']) ) {
90 90
                     $users_modules[$module] = $beanList[$module];
91 91
                 }
92
-			}
93
-			$current_user->setPreference('globalSearch', $users_modules, 0, 'search');
94
-		}
92
+            }
93
+            $current_user->setPreference('globalSearch', $users_modules, 0, 'search');
94
+        }
95 95
 
96
-		$sugar_smarty = new Sugar_Smarty();
96
+        $sugar_smarty = new Sugar_Smarty();
97 97
 
98
-		$modules_to_search = array();
98
+        $modules_to_search = array();
99 99
 
100
-		foreach($users_modules as $key=>$module)
101
-		{
100
+        foreach($users_modules as $key=>$module)
101
+        {
102 102
             if(ACLController::checkAccess($key, 'list', true))
103 103
             {
104 104
                 $modules_to_search[$key]['checked'] = true;
105 105
             }
106
-		}
107
-
108
-		if(!empty($this->query_string))
109
-		{
110
-			$sugar_smarty->assign('query_string', securexss($this->query_string));
111
-		} else {
112
-			$sugar_smarty->assign('query_string', '');
113
-		}
114
-
115
-		$sugar_smarty->assign('MOD', return_module_language($GLOBALS['current_language'], 'Administration'));
116
-		$sugar_smarty->assign('APP', $app_strings);
117
-		$sugar_smarty->assign('USE_SEARCH_GIF', 0);
118
-		$sugar_smarty->assign('LBL_SEARCH_BUTTON_LABEL', $app_strings['LBL_SEARCH_BUTTON_LABEL']);
119
-		$sugar_smarty->assign('LBL_SEARCH_BUTTON_TITLE', $app_strings['LBL_SEARCH_BUTTON_TITLE']);
120
-		$sugar_smarty->assign('LBL_SEARCH', $app_strings['LBL_SEARCH']);
121
-
122
-		$json_enabled = array();
123
-		$json_disabled = array();
124
-
125
-		//Now add the rest of the modules that are searchable via Global Search settings
126
-		foreach($unified_search_modules_display as $module=>$data)
127
-		{
128
-			if(!isset($modules_to_search[$module]) && $data['visible'] && ACLController::checkAccess($module, 'list', true))
129
-			{
130
-			   $modules_to_search[$module]['checked'] = false;
131
-			} else if (isset($modules_to_search[$module]) && !$data['visible']) {
132
-			   unset($modules_to_search[$module]);
133
-			}
134
-		}
135
-
136
-		//Create the two lists (doing it this way preserves the user's ordering choice for enabled modules)
137
-		foreach($modules_to_search as $module=>$data)
138
-		{
139
-			$label = isset($app_list_strings['moduleList'][$module]) ? $app_list_strings['moduleList'][$module] : $module;
140
-			if(!empty($data['checked']))
141
-			{
142
-				$json_enabled[] = array("module" => $module, 'label' => $label);
143
-			} else {
144
-				$json_disabled[] = array("module" => $module, 'label' => $label);
145
-			}
146
-		}
147
-
148
-		$sugar_smarty->assign('enabled_modules', json_encode($json_enabled));
149
-		$sugar_smarty->assign('disabled_modules', json_encode($json_disabled));
150
-
151
-		$showDiv = $current_user->getPreference('showGSDiv', 'search');
152
-		if(!isset($showDiv))
153
-		{
154
-		   $showDiv = 'no';
155
-		}
156
-
157
-		$sugar_smarty->assign('SHOWGSDIV', $showDiv);
158
-		$sugar_smarty->debugging = true;
159
-		return $sugar_smarty->fetch($tpl);
160
-	}
106
+        }
107
+
108
+        if(!empty($this->query_string))
109
+        {
110
+            $sugar_smarty->assign('query_string', securexss($this->query_string));
111
+        } else {
112
+            $sugar_smarty->assign('query_string', '');
113
+        }
114
+
115
+        $sugar_smarty->assign('MOD', return_module_language($GLOBALS['current_language'], 'Administration'));
116
+        $sugar_smarty->assign('APP', $app_strings);
117
+        $sugar_smarty->assign('USE_SEARCH_GIF', 0);
118
+        $sugar_smarty->assign('LBL_SEARCH_BUTTON_LABEL', $app_strings['LBL_SEARCH_BUTTON_LABEL']);
119
+        $sugar_smarty->assign('LBL_SEARCH_BUTTON_TITLE', $app_strings['LBL_SEARCH_BUTTON_TITLE']);
120
+        $sugar_smarty->assign('LBL_SEARCH', $app_strings['LBL_SEARCH']);
121
+
122
+        $json_enabled = array();
123
+        $json_disabled = array();
124
+
125
+        //Now add the rest of the modules that are searchable via Global Search settings
126
+        foreach($unified_search_modules_display as $module=>$data)
127
+        {
128
+            if(!isset($modules_to_search[$module]) && $data['visible'] && ACLController::checkAccess($module, 'list', true))
129
+            {
130
+                $modules_to_search[$module]['checked'] = false;
131
+            } else if (isset($modules_to_search[$module]) && !$data['visible']) {
132
+                unset($modules_to_search[$module]);
133
+            }
134
+        }
135
+
136
+        //Create the two lists (doing it this way preserves the user's ordering choice for enabled modules)
137
+        foreach($modules_to_search as $module=>$data)
138
+        {
139
+            $label = isset($app_list_strings['moduleList'][$module]) ? $app_list_strings['moduleList'][$module] : $module;
140
+            if(!empty($data['checked']))
141
+            {
142
+                $json_enabled[] = array("module" => $module, 'label' => $label);
143
+            } else {
144
+                $json_disabled[] = array("module" => $module, 'label' => $label);
145
+            }
146
+        }
147
+
148
+        $sugar_smarty->assign('enabled_modules', json_encode($json_enabled));
149
+        $sugar_smarty->assign('disabled_modules', json_encode($json_disabled));
150
+
151
+        $showDiv = $current_user->getPreference('showGSDiv', 'search');
152
+        if(!isset($showDiv))
153
+        {
154
+            $showDiv = 'no';
155
+        }
156
+
157
+        $sugar_smarty->assign('SHOWGSDIV', $showDiv);
158
+        $sugar_smarty->debugging = true;
159
+        return $sugar_smarty->fetch($tpl);
160
+    }
161 161
 
162 162
 
163 163
     /**
@@ -170,70 +170,70 @@  discard block
 block discarded – undo
170 170
      *
171 171
      *
172 172
      */
173
-	function search() {
173
+    function search() {
174 174
 
175 175
         $unified_search_modules = $this->getUnifiedSearchModules();
176
-		$unified_search_modules_display = $this->getUnifiedSearchModulesDisplay();
176
+        $unified_search_modules_display = $this->getUnifiedSearchModulesDisplay();
177 177
 
178 178
 
179
-		require_once 'include/ListView/ListViewSmarty.php';
179
+        require_once 'include/ListView/ListViewSmarty.php';
180 180
 
181
-		global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
182
-		$home_mod_strings = return_module_language($current_language, 'Home');
181
+        global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
182
+        $home_mod_strings = return_module_language($current_language, 'Home');
183 183
 
184
-		$this->query_string = $GLOBALS['db']->quote(securexss(from_html(clean_string($this->query_string, 'UNIFIED_SEARCH'))));
184
+        $this->query_string = $GLOBALS['db']->quote(securexss(from_html(clean_string($this->query_string, 'UNIFIED_SEARCH'))));
185 185
 
186
-		if(!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
187
-			$modules_to_search = array();
188
-			if(!empty($_REQUEST['search_modules']))
189
-			{
190
-			    foreach(explode (',', $_REQUEST['search_modules'] ) as $key)
191
-	            {
186
+        if(!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
187
+            $modules_to_search = array();
188
+            if(!empty($_REQUEST['search_modules']))
189
+            {
190
+                foreach(explode (',', $_REQUEST['search_modules'] ) as $key)
191
+                {
192 192
                     if (isset($unified_search_modules_display[$key]) && !empty($unified_search_modules_display[$key]['visible']))
193 193
                     {
194 194
                         $modules_to_search[$key] = $beanList[$key];
195 195
                     }
196
-	            }
197
-			}
198
-
199
-			$current_user->setPreference('showGSDiv', isset($_REQUEST['showGSDiv']) ? $_REQUEST['showGSDiv'] : 'no', 0, 'search');
200
-			$current_user->setPreference('globalSearch', $modules_to_search, 0, 'search'); // save selections to user preference
201
-		} else {
202
-			$users_modules = $current_user->getPreference('globalSearch', 'search');
203
-			$modules_to_search = array();
204
-
205
-			if(!empty($users_modules)) {
206
-				// use user's previous selections
207
-			    foreach ( $users_modules as $key => $value ) {
208
-			    	if (isset($unified_search_modules_display[$key]) && !empty($unified_search_modules_display[$key]['visible'])) {
209
-		            	$modules_to_search[$key] = $beanList[$key];
210
-		        	}
211
-			    }
212
-			} else {
213
-				foreach($unified_search_modules_display as $module=>$data) {
214
-				    if (!empty($data['visible']) ) {
215
-				        $modules_to_search[$module] = $beanList[$module];
216
-				    }
217
-				}
218
-			}
219
-			$current_user->setPreference('globalSearch', $modules_to_search, 'search');
220
-		}
221
-
222
-
223
-		$templateFile = 'modules/Home/UnifiedSearchAdvancedForm.tpl';
224
-		if(file_exists('custom/' . $templateFile))
225
-		{
226
-		   $templateFile = 'custom/'.$templateFile;
227
-		}
228
-
229
-		echo $this->getDropDownDiv($templateFile);
230
-
231
-		$module_results = array();
232
-		$module_counts = array();
233
-		$has_results = false;
234
-
235
-		if(!empty($this->query_string)) {
236
-			foreach($modules_to_search as $moduleName => $beanName) {
196
+                }
197
+            }
198
+
199
+            $current_user->setPreference('showGSDiv', isset($_REQUEST['showGSDiv']) ? $_REQUEST['showGSDiv'] : 'no', 0, 'search');
200
+            $current_user->setPreference('globalSearch', $modules_to_search, 0, 'search'); // save selections to user preference
201
+        } else {
202
+            $users_modules = $current_user->getPreference('globalSearch', 'search');
203
+            $modules_to_search = array();
204
+
205
+            if(!empty($users_modules)) {
206
+                // use user's previous selections
207
+                foreach ( $users_modules as $key => $value ) {
208
+                    if (isset($unified_search_modules_display[$key]) && !empty($unified_search_modules_display[$key]['visible'])) {
209
+                        $modules_to_search[$key] = $beanList[$key];
210
+                    }
211
+                }
212
+            } else {
213
+                foreach($unified_search_modules_display as $module=>$data) {
214
+                    if (!empty($data['visible']) ) {
215
+                        $modules_to_search[$module] = $beanList[$module];
216
+                    }
217
+                }
218
+            }
219
+            $current_user->setPreference('globalSearch', $modules_to_search, 'search');
220
+        }
221
+
222
+
223
+        $templateFile = 'modules/Home/UnifiedSearchAdvancedForm.tpl';
224
+        if(file_exists('custom/' . $templateFile))
225
+        {
226
+            $templateFile = 'custom/'.$templateFile;
227
+        }
228
+
229
+        echo $this->getDropDownDiv($templateFile);
230
+
231
+        $module_results = array();
232
+        $module_counts = array();
233
+        $has_results = false;
234
+
235
+        if(!empty($this->query_string)) {
236
+            foreach($modules_to_search as $moduleName => $beanName) {
237 237
                 require_once $beanFiles[$beanName] ;
238 238
                 $seed = new $beanName();
239 239
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
                 //retrieve the original list view defs and store for processing in case of custom layout changes
245 245
                 require('modules/'.$seed->module_dir.'/metadata/listviewdefs.php');
246
-				$orig_listViewDefs = $listViewDefs;
246
+                $orig_listViewDefs = $listViewDefs;
247 247
 
248 248
                 if(file_exists('custom/modules/'.$seed->module_dir.'/metadata/listviewdefs.php'))
249 249
                 {
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
                     continue;
256 256
                 }
257 257
 
258
-			    $unifiedSearchFields = array () ;
258
+                $unifiedSearchFields = array () ;
259 259
                 $innerJoins = array();
260 260
                 foreach ( $unified_search_modules[ $moduleName ]['fields'] as $field=>$def )
261 261
                 {
262
-                	$listViewCheckField = strtoupper($field);
263
-                	//check to see if the field is in listview defs
264
-					if ( empty($listViewDefs[$seed->module_dir][$listViewCheckField]['default']) ) {
265
-						//check to see if field is in original list view defs (in case we are using custom layout defs)
266
-						if (!empty($orig_listViewDefs[$seed->module_dir][$listViewCheckField]['default']) ) {
267
-							//if we are here then the layout has been customized, but the field is still needed for query creation
268
-							$listViewDefs[$seed->module_dir][$listViewCheckField] = $orig_listViewDefs[$seed->module_dir][$listViewCheckField];
269
-						}
262
+                    $listViewCheckField = strtoupper($field);
263
+                    //check to see if the field is in listview defs
264
+                    if ( empty($listViewDefs[$seed->module_dir][$listViewCheckField]['default']) ) {
265
+                        //check to see if field is in original list view defs (in case we are using custom layout defs)
266
+                        if (!empty($orig_listViewDefs[$seed->module_dir][$listViewCheckField]['default']) ) {
267
+                            //if we are here then the layout has been customized, but the field is still needed for query creation
268
+                            $listViewDefs[$seed->module_dir][$listViewCheckField] = $orig_listViewDefs[$seed->module_dir][$listViewCheckField];
269
+                        }
270 270
 
271
-					}
271
+                    }
272 272
 
273 273
                     //bug: 34125 we might want to try to use the LEFT JOIN operator instead of the INNER JOIN in the case we are
274 274
                     //joining against a field that has not been populated.
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 require_once $beanFiles[$beanName] ;
303 303
                 $seed = new $beanName();
304 304
                 
305
-				require_once $this->searchFormPath;
305
+                require_once $this->searchFormPath;
306 306
                 $searchForm = new $this->searchFormClass ( $seed, $moduleName ) ;
307 307
 
308 308
                 $searchForm->setup (array ( $moduleName => array() ) , $unifiedSearchFields , '' , 'saved_views' /* hack to avoid setup doing further unwanted processing */ ) ;
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
                 $params = array('custom_select' => "");
312 312
                 foreach($innerJoins as $field=>$def) {
313 313
                     if (isset ($def['db_field'])) {
314
-                      foreach($def['db_field'] as $dbfield)
315
-                          $where_clauses[] = $dbfield . " LIKE '" . $this->query_string . "%'";
316
-                          $params['custom_select'] .= ", $dbfield";
317
-                          $params['distinct'] = true;
318
-                          //$filterFields[$dbfield] = $dbfield;
314
+                        foreach($def['db_field'] as $dbfield)
315
+                            $where_clauses[] = $dbfield . " LIKE '" . $this->query_string . "%'";
316
+                            $params['custom_select'] .= ", $dbfield";
317
+                            $params['distinct'] = true;
318
+                            //$filterFields[$dbfield] = $dbfield;
319 319
                     }
320 320
                 }
321 321
 
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 
342 342
                 if(count($displayColumns) > 0)
343 343
                 {
344
-                	$lv->displayColumns = $displayColumns;
344
+                    $lv->displayColumns = $displayColumns;
345 345
                 } else {
346
-                	$lv->displayColumns = $listViewDefs[$seed->module_dir];
346
+                    $lv->displayColumns = $listViewDefs[$seed->module_dir];
347 347
                 }
348 348
 
349 349
                 $lv->export = false;
@@ -368,56 +368,56 @@  discard block
 block discarded – undo
368 368
                     $module_results[$moduleName] .= $lv->display(false, false);
369 369
                 }
370 370
 
371
-			}
372
-		}
371
+            }
372
+        }
373 373
 
374
-		if($has_results) {
375
-			foreach($module_counts as $name=>$value) {
376
-				echo $module_results[$name];
377
-			}
378
-		} else if(empty($_REQUEST['form_only'])) {
379
-			echo $home_mod_strings['LBL_NO_RESULTS'];
380
-			echo $home_mod_strings['LBL_NO_RESULTS_TIPS'];
381
-		}
374
+        if($has_results) {
375
+            foreach($module_counts as $name=>$value) {
376
+                echo $module_results[$name];
377
+            }
378
+        } else if(empty($_REQUEST['form_only'])) {
379
+            echo $home_mod_strings['LBL_NO_RESULTS'];
380
+            echo $home_mod_strings['LBL_NO_RESULTS_TIPS'];
381
+        }
382 382
 
383
-	}
383
+    }
384 384
 
385
-	function buildCache()
386
-	{
385
+    function buildCache()
386
+    {
387 387
 
388
-		global $beanList, $beanFiles, $dictionary;
388
+        global $beanList, $beanFiles, $dictionary;
389 389
 
390
-		$supported_modules = array();
390
+        $supported_modules = array();
391 391
 
392
-		foreach($beanList as $moduleName=>$beanName)
393
-		{
394
-			if (!isset($beanFiles[$beanName]))
395
-				continue;
392
+        foreach($beanList as $moduleName=>$beanName)
393
+        {
394
+            if (!isset($beanFiles[$beanName]))
395
+                continue;
396 396
 
397
-			$beanName = BeanFactory::getObjectName($moduleName);
398
-			$manager = new VardefManager ( );
399
-			$manager->loadVardef( $moduleName , $beanName ) ;
397
+            $beanName = BeanFactory::getObjectName($moduleName);
398
+            $manager = new VardefManager ( );
399
+            $manager->loadVardef( $moduleName , $beanName ) ;
400 400
 
401
-			// obtain the field definitions used by generateSearchWhere (duplicate code in view.list.php)
402
-			if(file_exists('custom/modules/'.$moduleName.'/metadata/metafiles.php')){
401
+            // obtain the field definitions used by generateSearchWhere (duplicate code in view.list.php)
402
+            if(file_exists('custom/modules/'.$moduleName.'/metadata/metafiles.php')){
403 403
                 require('custom/modules/'.$moduleName.'/metadata/metafiles.php');
404 404
             }elseif(file_exists('modules/'.$moduleName.'/metadata/metafiles.php')){
405 405
                 require('modules/'.$moduleName.'/metadata/metafiles.php');
406 406
             }
407 407
 
408 408
 
409
-			if(!empty($metafiles[$moduleName]['searchfields']))
410
-			{
411
-				require $metafiles[$moduleName]['searchfields'] ;
412
-			} else if(file_exists("modules/{$moduleName}/metadata/SearchFields.php")) {
413
-				require "modules/{$moduleName}/metadata/SearchFields.php" ;
414
-			}
409
+            if(!empty($metafiles[$moduleName]['searchfields']))
410
+            {
411
+                require $metafiles[$moduleName]['searchfields'] ;
412
+            } else if(file_exists("modules/{$moduleName}/metadata/SearchFields.php")) {
413
+                require "modules/{$moduleName}/metadata/SearchFields.php" ;
414
+            }
415 415
 
416
-			//Load custom SearchFields.php if it exists
417
-			if(file_exists("custom/modules/{$moduleName}/metadata/SearchFields.php"))
418
-			{
419
-				require "custom/modules/{$moduleName}/metadata/SearchFields.php" ;
420
-			}				
416
+            //Load custom SearchFields.php if it exists
417
+            if(file_exists("custom/modules/{$moduleName}/metadata/SearchFields.php"))
418
+            {
419
+                require "custom/modules/{$moduleName}/metadata/SearchFields.php" ;
420
+            }				
421 421
 
422 422
             //If there are $searchFields are empty, just continue, there are no search fields defined for the module
423 423
             if(empty($searchFields[$moduleName]))
@@ -425,34 +425,34 @@  discard block
 block discarded – undo
425 425
                 continue;
426 426
             }
427 427
 
428
-			$isCustomModule = preg_match('/^([a-z0-9]{1,5})_([a-z0-9_]+)$/i' , $moduleName);
429
-
430
-			//If the bean supports unified search or if it's a custom module bean and unified search is not defined
431
-			if(!empty($dictionary[$beanName]['unified_search']) || $isCustomModule)
432
-			{
433
-				$fields = array();
434
-				foreach ( $dictionary [ $beanName ][ 'fields' ] as $field => $def )
435
-				{
436
-					// We cannot enable or disable unified_search for email in the vardefs as we don't actually have a vardef entry for 'email'
437
-					// the searchFields entry for 'email' doesn't correspond to any vardef entry. Instead it contains SQL to directly perform the search.
438
-					// So as a proxy we allow any field in the vardefs that has a name starting with 'email...' to be tagged with the 'unified_search' parameter
439
-
440
-					if (strpos($field,'email') !== false)
441
-					{
442
-						$field = 'email' ;
443
-					}
444
-
445
-					//bug: 38139 - allow phone to be searched through Global Search
446
-					if (strpos($field,'phone') !== false)
447
-					{
448
-						$field = 'phone' ;
449
-					}
450
-
451
-					if ( !empty($def['unified_search']) && isset ( $searchFields [ $moduleName ] [ $field ]  ))
452
-					{
453
-						$fields [ $field ] = $searchFields [ $moduleName ] [ $field ] ;
454
-					}
455
-				}
428
+            $isCustomModule = preg_match('/^([a-z0-9]{1,5})_([a-z0-9_]+)$/i' , $moduleName);
429
+
430
+            //If the bean supports unified search or if it's a custom module bean and unified search is not defined
431
+            if(!empty($dictionary[$beanName]['unified_search']) || $isCustomModule)
432
+            {
433
+                $fields = array();
434
+                foreach ( $dictionary [ $beanName ][ 'fields' ] as $field => $def )
435
+                {
436
+                    // We cannot enable or disable unified_search for email in the vardefs as we don't actually have a vardef entry for 'email'
437
+                    // the searchFields entry for 'email' doesn't correspond to any vardef entry. Instead it contains SQL to directly perform the search.
438
+                    // So as a proxy we allow any field in the vardefs that has a name starting with 'email...' to be tagged with the 'unified_search' parameter
439
+
440
+                    if (strpos($field,'email') !== false)
441
+                    {
442
+                        $field = 'email' ;
443
+                    }
444
+
445
+                    //bug: 38139 - allow phone to be searched through Global Search
446
+                    if (strpos($field,'phone') !== false)
447
+                    {
448
+                        $field = 'phone' ;
449
+                    }
450
+
451
+                    if ( !empty($def['unified_search']) && isset ( $searchFields [ $moduleName ] [ $field ]  ))
452
+                    {
453
+                        $fields [ $field ] = $searchFields [ $moduleName ] [ $field ] ;
454
+                    }
455
+                }
456 456
 
457 457
                 foreach ($searchFields[$moduleName] as $field => $def)
458 458
                 {
@@ -465,23 +465,23 @@  discard block
 block discarded – undo
465 465
                     }
466 466
                 }
467 467
 
468
-				if(count($fields) > 0) {
469
-					$supported_modules [$moduleName] ['fields'] = $fields;
470
-					if (isset($dictionary[$beanName]['unified_search_default_enabled']) && $dictionary[$beanName]['unified_search_default_enabled'] === TRUE)
471
-					{
468
+                if(count($fields) > 0) {
469
+                    $supported_modules [$moduleName] ['fields'] = $fields;
470
+                    if (isset($dictionary[$beanName]['unified_search_default_enabled']) && $dictionary[$beanName]['unified_search_default_enabled'] === TRUE)
471
+                    {
472 472
                         $supported_modules [$moduleName]['default'] = true;
473 473
                     } else {
474 474
                         $supported_modules [$moduleName]['default'] = false;
475 475
                     }
476
-				}
476
+                }
477 477
 
478
-			}
478
+            }
479 479
 
480
-		}
480
+        }
481 481
 
482
-		ksort($supported_modules);
483
-		write_array_to_file('unified_search_modules', $supported_modules, $this->cache_search);
484
-	}
482
+        ksort($supported_modules);
483
+        write_array_to_file('unified_search_modules', $supported_modules, $this->cache_search);
484
+    }
485 485
 
486 486
     /**
487 487
      * Retrieve the enabled and disabled modules used for global search.
@@ -525,9 +525,9 @@  discard block
 block discarded – undo
525 525
                 $label = isset($app_list_strings['moduleList'][$module]) ? $app_list_strings['moduleList'][$module] : $module;
526 526
                 if($data['default'])
527 527
                 {
528
-                  $json_enabled[] = array("module" => $module, 'label' => $label);
528
+                    $json_enabled[] = array("module" => $module, 'label' => $label);
529 529
                 } else {
530
-                  $json_disabled[] = array("module" => $module, 'label' => $label);
530
+                    $json_disabled[] = array("module" => $module, 'label' => $label);
531 531
                 }
532 532
             }
533 533
         }
@@ -536,47 +536,47 @@  discard block
 block discarded – undo
536 536
     }
537 537
 
538 538
 
539
-	/**
540
-	 * saveGlobalSearchSettings
541
-	 * This method handles the administrator's request to save the searchable modules selected and stores
542
-	 * the results in the unified_search_modules_display.php file
543
-	 *
544
-	 */
545
-	function saveGlobalSearchSettings()
546
-	{
547
-		if(isset($_REQUEST['enabled_modules']))
548
-		{
539
+    /**
540
+     * saveGlobalSearchSettings
541
+     * This method handles the administrator's request to save the searchable modules selected and stores
542
+     * the results in the unified_search_modules_display.php file
543
+     *
544
+     */
545
+    function saveGlobalSearchSettings()
546
+    {
547
+        if(isset($_REQUEST['enabled_modules']))
548
+        {
549 549
             $unified_search_modules_display = $this->getUnifiedSearchModulesDisplay();
550 550
 
551
-			$new_unified_search_modules_display = array();
551
+            $new_unified_search_modules_display = array();
552 552
 
553 553
             foreach(explode (',', $_REQUEST['enabled_modules'] ) as $module)
554 554
             {
555 555
                 $new_unified_search_modules_display[$module]['visible'] = true;
556 556
             }
557 557
 
558
-			foreach($unified_search_modules_display as $module=>$data)
559
-			{
560
-				if(!isset($new_unified_search_modules_display[$module]))
561
-				{
562
-				   $new_unified_search_modules_display[$module]['visible'] = false;
563
-				}
564
-			}
565
-
566
-			$this->writeUnifiedSearchModulesDisplayFile($new_unified_search_modules_display);
567
-		}
568
-	}
569
-
570
-
571
-	public static function unlinkUnifiedSearchModulesFile() {
572
-		//clear the unified_search_module.php file
573
-		$cache_search = sugar_cached('modules/unified_search_modules.php');
574
-    	if(file_exists($cache_search))
575
-    	{
576
-    		$GLOBALS['log']->info("unlink {$cache_search}");
577
-    		unlink($cache_search);
578
-    	}
579
-	}
558
+            foreach($unified_search_modules_display as $module=>$data)
559
+            {
560
+                if(!isset($new_unified_search_modules_display[$module]))
561
+                {
562
+                    $new_unified_search_modules_display[$module]['visible'] = false;
563
+                }
564
+            }
565
+
566
+            $this->writeUnifiedSearchModulesDisplayFile($new_unified_search_modules_display);
567
+        }
568
+    }
569
+
570
+
571
+    public static function unlinkUnifiedSearchModulesFile() {
572
+        //clear the unified_search_module.php file
573
+        $cache_search = sugar_cached('modules/unified_search_modules.php');
574
+        if(file_exists($cache_search))
575
+        {
576
+            $GLOBALS['log']->info("unlink {$cache_search}");
577
+            unlink($cache_search);
578
+        }
579
+    }
580 580
     
581 581
 
582 582
     /**
@@ -589,21 +589,21 @@  discard block
 block discarded – undo
589 589
      */
590 590
     public function getUnifiedSearchModules()
591 591
     {
592
-		//Make directory if it doesn't exist
592
+        //Make directory if it doesn't exist
593 593
         $cachedir = sugar_cached('modules');
594
-		if(!file_exists($cachedir))
595
-		{
596
-		   mkdir_recursive($cachedir);
597
-		}
594
+        if(!file_exists($cachedir))
595
+        {
596
+            mkdir_recursive($cachedir);
597
+        }
598 598
 
599
-		//Load unified_search_modules.php file
599
+        //Load unified_search_modules.php file
600 600
         $cachedFile = sugar_cached('modules/unified_search_modules.php');
601
-		if(!file_exists($cachedFile))
602
-		{
603
-			$this->buildCache();
604
-		}
601
+        if(!file_exists($cachedFile))
602
+        {
603
+            $this->buildCache();
604
+        }
605 605
 
606
-		include $cachedFile;
606
+        include $cachedFile;
607 607
         return $unified_search_modules;
608 608
     }
609 609
 
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
      */
619 619
     public function getUnifiedSearchModulesDisplay()
620 620
     {
621
-		if(!file_exists('custom/modules/unified_search_modules_display.php'))
622
-		{
621
+        if(!file_exists('custom/modules/unified_search_modules_display.php'))
622
+        {
623 623
             $unified_search_modules = $this->getUnifiedSearchModules();
624 624
 
625 625
             $unified_search_modules_display = array();
@@ -633,13 +633,13 @@  discard block
 block discarded – undo
633 633
             }
634 634
 
635 635
             $this->writeUnifiedSearchModulesDisplayFile($unified_search_modules_display);
636
-		}
636
+        }
637 637
 
638
-		include('custom/modules/unified_search_modules_display.php');
638
+        include('custom/modules/unified_search_modules_display.php');
639 639
         return $unified_search_modules_display;
640 640
     }
641 641
 
642
-	/*
642
+    /*
643 643
 	 * writeUnifiedSearchModulesDisplayFile
644 644
 	 * Private method to handle writing the unified_search_modules_display value to file
645 645
 	 *
@@ -647,35 +647,35 @@  discard block
 block discarded – undo
647 647
 	 * @return boolean value indication whether or not file was successfully written
648 648
 	 * @throws Exception Thrown if the file write operation fails
649 649
 	 */
650
-	private function writeUnifiedSearchModulesDisplayFile($unified_search_modules_display)
651
-	{
652
-		if(is_null($unified_search_modules_display) || empty($unified_search_modules_display))
653
-		{
654
-		   return false;
655
-		}
656
-
657
-	    if(!write_array_to_file("unified_search_modules_display", $unified_search_modules_display, 'custom/modules/unified_search_modules_display.php'))
658
-	    {
659
-	    	//Log error message and throw Exception
660
-	    	global $app_strings;
661
-	    	$msg = string_format($app_strings['ERR_FILE_WRITE'], array('custom/modules/unified_search_modules_display.php'));
662
-	    	$GLOBALS['log']->error($msg);
663
-	    	throw new Exception($msg);
664
-	    }
665
-
666
-	    return true;
667
-	}
650
+    private function writeUnifiedSearchModulesDisplayFile($unified_search_modules_display)
651
+    {
652
+        if(is_null($unified_search_modules_display) || empty($unified_search_modules_display))
653
+        {
654
+            return false;
655
+        }
656
+
657
+        if(!write_array_to_file("unified_search_modules_display", $unified_search_modules_display, 'custom/modules/unified_search_modules_display.php'))
658
+        {
659
+            //Log error message and throw Exception
660
+            global $app_strings;
661
+            $msg = string_format($app_strings['ERR_FILE_WRITE'], array('custom/modules/unified_search_modules_display.php'));
662
+            $GLOBALS['log']->error($msg);
663
+            throw new Exception($msg);
664
+        }
665
+
666
+        return true;
667
+    }
668 668
 }
669 669
 
670 670
 
671 671
 function unified_search_modules_cmp($a, $b) {
672
-	if(!isset($a['translated']) || !isset($b['translated']))
673
-	{
674
-	   return 0;
675
-	}
672
+    if(!isset($a['translated']) || !isset($b['translated']))
673
+    {
674
+        return 0;
675
+    }
676 676
 
677
-	$name1 = strtolower($a['translated']);
678
-	$name2 = strtolower($b['translated']);
677
+    $name1 = strtolower($a['translated']);
678
+    $name2 = strtolower($b['translated']);
679 679
 
680
-	return $name1 < $name2 ? -1 : 1;
680
+    return $name1 < $name2 ? -1 : 1;
681 681
 }
Please login to merge, or discard this patch.