Test Failed
Push — CI ( 02428e...3e0292 )
by Adam
55:43
created
data/SugarBean.php 1 patch
Indentation   +738 added lines, -738 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,17 +2340,17 @@  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
-             if (! empty($this->$rel_field_name['name']))
2350
-             {
2351
-                 $this->fetched_rel_row[$rel_field_name['name']] = $this->$rel_field_name['name'];
2352
-             }
2353
-         }
2347
+            foreach ($this->get_related_fields() as $rel_field_name)
2348
+            {
2349
+                if (! empty($this->$rel_field_name['name']))
2350
+                {
2351
+                    $this->fetched_rel_row[$rel_field_name['name']] = $this->$rel_field_name['name'];
2352
+                }
2353
+            }
2354 2354
         //make a copy of fields in the relationship_fields array. These field values will be used to
2355 2355
         //clear relationship.
2356 2356
         foreach ( $this->field_defs as $key => $def )
@@ -2363,7 +2363,7 @@  discard block
 block discarded – undo
2363 2363
                 }
2364 2364
                 else
2365 2365
                     $this->rel_fields_before_value[$key]=null;
2366
-           }
2366
+            }
2367 2367
         }
2368 2368
         if (isset($this->relationship_fields) && is_array($this->relationship_fields))
2369 2369
         {
@@ -2418,14 +2418,14 @@  discard block
 block discarded – undo
2418 2418
 
2419 2419
 
2420 2420
     /**
2421
-    * Add any required joins to the list count query.  The joins are required if there
2422
-    * is a field in the $where clause that needs to be joined.
2423
-    *
2424
-    * @param string $query
2425
-    * @param string $where
2426
-    *
2427
-    * Internal Function, do Not override.
2428
-    */
2421
+     * Add any required joins to the list count query.  The joins are required if there
2422
+     * is a field in the $where clause that needs to be joined.
2423
+     *
2424
+     * @param string $query
2425
+     * @param string $where
2426
+     *
2427
+     * Internal Function, do Not override.
2428
+     */
2429 2429
     function add_list_count_joins(&$query, $where)
2430 2430
     {
2431 2431
         $custom_join = $this->getCustomJoin();
@@ -2434,15 +2434,15 @@  discard block
 block discarded – undo
2434 2434
     }
2435 2435
 
2436 2436
     /**
2437
-    * Changes the select expression of the given query to be 'count(*)' so you
2438
-    * can get the number of items the query will return.  This is used to
2439
-    * populate the upper limit on ListViews.
2437
+     * Changes the select expression of the given query to be 'count(*)' so you
2438
+     * can get the number of items the query will return.  This is used to
2439
+     * populate the upper limit on ListViews.
2440 2440
      *
2441 2441
      * @param string $query Select query string
2442 2442
      * @return string count query
2443 2443
      *
2444 2444
      * Internal function, do not override.
2445
-    */
2445
+     */
2446 2446
     function create_list_count_query($query)
2447 2447
     {
2448 2448
         // remove the 'order by' clause which is expected to be at the end of the query
@@ -2495,21 +2495,21 @@  discard block
 block discarded – undo
2495 2495
     }
2496 2496
 
2497 2497
     /**
2498
-    * This function returns a paged list of the current object type.  It is intended to allow for
2499
-    * hopping back and forth through pages of data.  It only retrieves what is on the current page.
2500
-    *
2501
-    * @internal This method must be called on a new instance.  It trashes the values of all the fields in the current one.
2502
-    * @param string $order_by
2503
-    * @param string $where Additional where clause
2504
-    * @param int $row_offset Optaional,default 0, starting row number
2505
-    * @param init $limit Optional, default -1
2506
-    * @param int $max Optional, default -1
2507
-    * @param boolean $show_deleted Optional, default 0, if set to 1 system will show deleted records.
2508
-    * @return array Fetched data.
2509
-    *
2510
-    * Internal function, do not override.
2511
-    *
2512
-    */
2498
+     * This function returns a paged list of the current object type.  It is intended to allow for
2499
+     * hopping back and forth through pages of data.  It only retrieves what is on the current page.
2500
+     *
2501
+     * @internal This method must be called on a new instance.  It trashes the values of all the fields in the current one.
2502
+     * @param string $order_by
2503
+     * @param string $where Additional where clause
2504
+     * @param int $row_offset Optaional,default 0, starting row number
2505
+     * @param init $limit Optional, default -1
2506
+     * @param int $max Optional, default -1
2507
+     * @param boolean $show_deleted Optional, default 0, if set to 1 system will show deleted records.
2508
+     * @return array Fetched data.
2509
+     *
2510
+     * Internal function, do not override.
2511
+     *
2512
+     */
2513 2513
     function get_list($order_by = "", $where = "", $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0, $singleSelect=false, $select_fields = array())
2514 2514
     {
2515 2515
         $GLOBALS['log']->debug("get_list:  order_by = '$order_by' and where = '$where' and limit = '$limit'");
@@ -2539,15 +2539,15 @@  discard block
 block discarded – undo
2539 2539
     }
2540 2540
 
2541 2541
     /**
2542
-    * Prefixes column names with this bean's table name.
2543
-    *
2544
-    * @param string $order_by  Order by clause to be processed
2545
-    * @param SugarBean $submodule name of the module this order by clause is for
2546
-    * @param boolean $suppress_table_name Whether table name should be suppressed
2547
-    * @return string Processed order by clause
2548
-    *
2549
-    * Internal function, do not override.
2550
-    */
2542
+     * Prefixes column names with this bean's table name.
2543
+     *
2544
+     * @param string $order_by  Order by clause to be processed
2545
+     * @param SugarBean $submodule name of the module this order by clause is for
2546
+     * @param boolean $suppress_table_name Whether table name should be suppressed
2547
+     * @return string Processed order by clause
2548
+     *
2549
+     * Internal function, do not override.
2550
+     */
2551 2551
     public function process_order_by($order_by, $submodule = null, $suppress_table_name = false)
2552 2552
     {
2553 2553
         if (empty($order_by))
@@ -2621,21 +2621,21 @@  discard block
 block discarded – undo
2621 2621
 
2622 2622
 
2623 2623
     /**
2624
-    * Returns a detail object like retrieving of the current object type.
2625
-    *
2626
-    * It is intended for use in navigation buttons on the DetailView.  It will pass an offset and limit argument to the sql query.
2627
-    * @internal This method must be called on a new instance.  It overrides the values of all the fields in the current one.
2628
-    *
2629
-    * @param string $order_by
2630
-    * @param string $where Additional where clause
2631
-    * @param int $row_offset Optaional,default 0, starting row number
2632
-    * @param init $limit Optional, default -1
2633
-    * @param int $max Optional, default -1
2634
-    * @param boolean $show_deleted Optioanl, default 0, if set to 1 system will show deleted records.
2635
-    * @return array Fetched data.
2636
-    *
2637
-    * Internal function, do not override.
2638
-    */
2624
+     * Returns a detail object like retrieving of the current object type.
2625
+     *
2626
+     * It is intended for use in navigation buttons on the DetailView.  It will pass an offset and limit argument to the sql query.
2627
+     * @internal This method must be called on a new instance.  It overrides the values of all the fields in the current one.
2628
+     *
2629
+     * @param string $order_by
2630
+     * @param string $where Additional where clause
2631
+     * @param int $row_offset Optaional,default 0, starting row number
2632
+     * @param init $limit Optional, default -1
2633
+     * @param int $max Optional, default -1
2634
+     * @param boolean $show_deleted Optioanl, default 0, if set to 1 system will show deleted records.
2635
+     * @return array Fetched data.
2636
+     *
2637
+     * Internal function, do not override.
2638
+     */
2639 2639
     function get_detail($order_by = "", $where = "",  $offset = 0, $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0)
2640 2640
     {
2641 2641
         $GLOBALS['log']->debug("get_detail:  order_by = '$order_by' and where = '$where' and limit = '$limit' and offset = '$offset'");
@@ -2659,25 +2659,25 @@  discard block
 block discarded – undo
2659 2659
             }
2660 2660
         }
2661 2661
 
2662
-		/* BEGIN - SECURITY GROUPS */
2663
-    	if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') )
2664
-    	{
2665
-			require_once('modules/SecurityGroups/SecurityGroup.php');
2666
-    		global $current_user;
2667
-    		$owner_where = $this->getOwnerWhere($current_user->id);
2668
-    		$group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id);
2669
-	    	if(!empty($owner_where)){
2670
-				if(empty($where))
2671
-	    		{
2672
-	    			$where = " (".  $owner_where." or ".$group_where.") ";
2673
-	    		} else {
2674
-	    			$where .= " AND (".  $owner_where." or ".$group_where.") ";
2675
-	    		}
2676
-			} else {
2677
-				$where .= ' AND '.  $group_where;
2678
-			}
2679
-    	}
2680
-    	/* END - SECURITY GROUPS */
2662
+        /* BEGIN - SECURITY GROUPS */
2663
+        if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') )
2664
+        {
2665
+            require_once('modules/SecurityGroups/SecurityGroup.php');
2666
+            global $current_user;
2667
+            $owner_where = $this->getOwnerWhere($current_user->id);
2668
+            $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id);
2669
+            if(!empty($owner_where)){
2670
+                if(empty($where))
2671
+                {
2672
+                    $where = " (".  $owner_where." or ".$group_where.") ";
2673
+                } else {
2674
+                    $where .= " AND (".  $owner_where." or ".$group_where.") ";
2675
+                }
2676
+            } else {
2677
+                $where .= ' AND '.  $group_where;
2678
+            }
2679
+        }
2680
+        /* END - SECURITY GROUPS */
2681 2681
         $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted, $offset);
2682 2682
 
2683 2683
         //Add Limit and Offset to query
@@ -2687,16 +2687,16 @@  discard block
 block discarded – undo
2687 2687
     }
2688 2688
 
2689 2689
     /**
2690
-    * Fetches data from all related tables.
2691
-    *
2692
-    * @param object $child_seed
2693
-    * @param string $related_field_name relation to fetch data for
2694
-    * @param string $order_by Optional, default empty
2695
-    * @param string $where Optional, additional where clause
2696
-    * @return array Fetched data.
2697
-    *
2698
-    * Internal function, do not override.
2699
-    */
2690
+     * Fetches data from all related tables.
2691
+     *
2692
+     * @param object $child_seed
2693
+     * @param string $related_field_name relation to fetch data for
2694
+     * @param string $order_by Optional, default empty
2695
+     * @param string $where Optional, additional where clause
2696
+     * @return array Fetched data.
2697
+     *
2698
+     * Internal function, do not override.
2699
+     */
2700 2700
     function get_related_list($child_seed,$related_field_name, $order_by = "", $where = "",
2701 2701
     $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0)
2702 2702
     {
@@ -3072,13 +3072,13 @@  discard block
 block discarded – undo
3072 3072
 
3073 3073
 
3074 3074
     /**
3075
-    * Returns a full (ie non-paged) list of the current object type.
3076
-    *
3077
-    * @param string $order_by the order by SQL parameter. defaults to ""
3078
-    * @param string $where where clause. defaults to ""
3079
-    * @param boolean $check_dates. defaults to false
3080
-    * @param int $show_deleted show deleted records. defaults to 0
3081
-    */
3075
+     * Returns a full (ie non-paged) list of the current object type.
3076
+     *
3077
+     * @param string $order_by the order by SQL parameter. defaults to ""
3078
+     * @param string $where where clause. defaults to ""
3079
+     * @param boolean $check_dates. defaults to false
3080
+     * @param int $show_deleted show deleted records. defaults to 0
3081
+     */
3082 3082
     function get_full_list($order_by = "", $where = "", $check_dates=false, $show_deleted = 0)
3083 3083
     {
3084 3084
         $GLOBALS['log']->debug("get_full_list:  order_by = '$order_by' and where = '$where'");
@@ -3106,7 +3106,7 @@  discard block
 block discarded – undo
3106 3106
      * @param boolean $singleSelect Optional, default false.
3107 3107
      * @return String select query string, optionally an array value will be returned if $return_array= true.
3108 3108
      */
3109
-	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)
3109
+    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 3110
     {
3111 3111
         global $beanFiles, $beanList;
3112 3112
         $selectedFields = array();
@@ -3126,41 +3126,41 @@  discard block
 block discarded – undo
3126 3126
                 $where .= ' AND '.  $owner_where;
3127 3127
             }
3128 3128
         }
3129
-		/* BEGIN - SECURITY GROUPS */
3130
-    	global $current_user, $sugar_config;
3131
-    	if($this->module_dir == 'Users' && !is_admin($current_user)
3132
-				&& isset($sugar_config['securitysuite_filter_user_list'])
3133
-				&& $sugar_config['securitysuite_filter_user_list'] == true
3134
-    	) {
3135
-			require_once('modules/SecurityGroups/SecurityGroup.php');
3136
-    		global $current_user;
3137
-    		$group_where = SecurityGroup::getGroupUsersWhere($current_user->id);
3138
-    		//$group_where = "user_name = 'admin'";
3139
-    		if(empty($where))
3140
-    		{
3141
-    			$where = " (".$group_where.") ";
3142
-    		} else {
3143
-    			$where .= " AND (".$group_where.") ";
3144
-    		}
3145
-    	} else
3146
-    	if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') )
3147
-    	{
3148
-			require_once('modules/SecurityGroups/SecurityGroup.php');
3149
-    		global $current_user;
3150
-    		$owner_where = $this->getOwnerWhere($current_user->id);
3151
-    		$group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id);
3152
-	    	if(!empty($owner_where)){
3153
-				if(empty($where))
3154
-	    		{
3155
-	    			$where = " (".  $owner_where." or ".$group_where.") ";
3156
-	    		} else {
3157
-	    			$where .= " AND (".  $owner_where." or ".$group_where.") ";
3158
-	    		}
3159
-			} else {
3160
-				$where .= ' AND '.  $group_where;
3161
-			}
3162
-    	}
3163
-    	/* END - SECURITY GROUPS */
3129
+        /* BEGIN - SECURITY GROUPS */
3130
+        global $current_user, $sugar_config;
3131
+        if($this->module_dir == 'Users' && !is_admin($current_user)
3132
+                && isset($sugar_config['securitysuite_filter_user_list'])
3133
+                && $sugar_config['securitysuite_filter_user_list'] == true
3134
+        ) {
3135
+            require_once('modules/SecurityGroups/SecurityGroup.php');
3136
+            global $current_user;
3137
+            $group_where = SecurityGroup::getGroupUsersWhere($current_user->id);
3138
+            //$group_where = "user_name = 'admin'";
3139
+            if(empty($where))
3140
+            {
3141
+                $where = " (".$group_where.") ";
3142
+            } else {
3143
+                $where .= " AND (".$group_where.") ";
3144
+            }
3145
+        } else
3146
+        if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') )
3147
+        {
3148
+            require_once('modules/SecurityGroups/SecurityGroup.php');
3149
+            global $current_user;
3150
+            $owner_where = $this->getOwnerWhere($current_user->id);
3151
+            $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id);
3152
+            if(!empty($owner_where)){
3153
+                if(empty($where))
3154
+                {
3155
+                    $where = " (".  $owner_where." or ".$group_where.") ";
3156
+                } else {
3157
+                    $where .= " AND (".  $owner_where." or ".$group_where.") ";
3158
+                }
3159
+            } else {
3160
+                $where .= ' AND '.  $group_where;
3161
+            }
3162
+        }
3163
+        /* END - SECURITY GROUPS */
3164 3164
         if(!empty($params['distinct']))
3165 3165
         {
3166 3166
             $distinct = ' DISTINCT ';
@@ -3246,24 +3246,24 @@  discard block
 block discarded – undo
3246 3246
 
3247 3247
         $used_join_key = array();
3248 3248
 
3249
-	//walk through the fields and for every relationship field add their relationship_info field
3250
-	//relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field
3251
-	$addrelate = array();
3252
-	foreach($fields as $field=>$value)
3253
-	{
3254
-		if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && 
3255
-			$this->field_defs[$field]['source'] == 'non-db')
3256
-		{
3257
-			$addrelatefield = $this->get_relationship_field($field);
3258
-			if ($addrelatefield)
3259
-				$addrelate[$addrelatefield] = true;
3260
-		}
3261
-		if(!empty($this->field_defs[$field]['id_name'])){
3262
-			$addrelate[$this->field_defs[$field]['id_name']] = true;
3263
-		}
3264
-	}
3265
-
3266
-	$fields = array_merge($addrelate, $fields);
3249
+    //walk through the fields and for every relationship field add their relationship_info field
3250
+    //relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field
3251
+    $addrelate = array();
3252
+    foreach($fields as $field=>$value)
3253
+    {
3254
+        if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && 
3255
+            $this->field_defs[$field]['source'] == 'non-db')
3256
+        {
3257
+            $addrelatefield = $this->get_relationship_field($field);
3258
+            if ($addrelatefield)
3259
+                $addrelate[$addrelatefield] = true;
3260
+        }
3261
+        if(!empty($this->field_defs[$field]['id_name'])){
3262
+            $addrelate[$this->field_defs[$field]['id_name']] = true;
3263
+        }
3264
+    }
3265
+
3266
+    $fields = array_merge($addrelate, $fields);
3267 3267
 
3268 3268
         foreach($fields as $field=>$value)
3269 3269
         {
@@ -3296,7 +3296,7 @@  discard block
 block discarded – undo
3296 3296
             //in opportunities module remove the contact_role/opportunity_role field.
3297 3297
             if (isset($data['relationship_fields']) and !empty($data['relationship_fields']))
3298 3298
             {
3299
-		$process_field = false;
3299
+        $process_field = false;
3300 3300
                 foreach ($data['relationship_fields'] as $field_name)
3301 3301
                 {
3302 3302
                     if (isset($fields[$field_name]))
@@ -3306,8 +3306,8 @@  discard block
 block discarded – undo
3306 3306
                     }
3307 3307
                 }
3308 3308
 		
3309
-            	if (!$process_field)
3310
-                	continue;
3309
+                if (!$process_field)
3310
+                    continue;
3311 3311
             }
3312 3312
 
3313 3313
             if(  (!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter) ))
@@ -3414,27 +3414,27 @@  discard block
 block discarded – undo
3414 3414
                     $rel_module = $this->$data['link']->getRelatedModuleName();
3415 3415
                     $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');
3416 3416
 
3417
-					//if rname is set to 'name', and bean files exist, then check if field should be a concatenated name
3418
-					global $beanFiles, $beanList;
3417
+                    //if rname is set to 'name', and bean files exist, then check if field should be a concatenated name
3418
+                    global $beanFiles, $beanList;
3419 3419
                     // °3/21/2014 FIX NS-TEAM - Relationship fields could not be displayed in subpanels
3420 3420
                     //if($data['rname'] && !empty($beanFiles[$beanList[$rel_module]])) {
3421 3421
                     if(isset($data['rname']) && $data['rname'] == 'name' && !empty($beanFiles[$beanList[$rel_module]])) {
3422 3422
 
3423
-						//create an instance of the related bean
3424
-						require_once($beanFiles[$beanList[$rel_module]]);
3425
-						$rel_mod = new $beanList[$rel_module]();
3426
-						//if bean has first and last name fields, then name should be concatenated
3427
-						if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){
3428
-								$data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name');
3429
-						}
3430
-					}
3423
+                        //create an instance of the related bean
3424
+                        require_once($beanFiles[$beanList[$rel_module]]);
3425
+                        $rel_mod = new $beanList[$rel_module]();
3426
+                        //if bean has first and last name fields, then name should be concatenated
3427
+                        if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){
3428
+                                $data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name');
3429
+                        }
3430
+                    }
3431 3431
 
3432 3432
 
3433
-    				if($join['type'] == 'many-to-many')
3434
-    				{
3435
-    					if(empty($ret_array['secondary_select']))
3436
-    					{
3437
-    						$ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id  ";
3433
+                    if($join['type'] == 'many-to-many')
3434
+                    {
3435
+                        if(empty($ret_array['secondary_select']))
3436
+                        {
3437
+                            $ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id  ";
3438 3438
 
3439 3439
                             if(!empty($beanFiles[$beanList[$rel_module]]) && $join_primary)
3440 3440
                             {
@@ -3546,42 +3546,42 @@  discard block
 block discarded – undo
3546 3546
                     // and this code changes accounts to jt4 as there is a self join with the accounts table.
3547 3547
                     //Martin fix #27494
3548 3548
                     if(isset($data['db_concat_fields'])){
3549
-                    	$buildWhere = false;
3549
+                        $buildWhere = false;
3550 3550
                         if(in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields']))
3551
-                    	{
3552
-                     	   $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/';
3553
-                    	   if(preg_match($exp, $where, $matches))
3554
-                    	   {
3555
-                    	   	  $search_expression = $matches[0];
3556
-                    	   	  //Create three search conditions - first + last, first, last
3557
-                    	   	  $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression);
3558
-                    	   	  $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression);
3559
-							  $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression);
3560
-							  $buildWhere = true;
3561
-							  $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where);
3562
-                    	   }
3563
-                    	}
3564
-
3565
-                    	if(!$buildWhere)
3566
-                    	{
3567
-	                       $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']);
3568
-	                       $where = preg_replace('/'.$data['name'].'/', $db_field, $where);
3569
-
3570
-				// For relationship fields replace their alias by the corresponsding link table and r_name
3571
-				if(isset($data['relationship_fields']))
3572
-					foreach($data['relationship_fields'] as $r_name=>$alias_name)
3573
-					{
3574
-						$db_field = $this->db->concat($params['join_table_link_alias'], $r_name);
3575
-						$where = preg_replace('/' . $alias_name . '/', $db_field, $where);
3576
-					}
3577
-                    	}
3551
+                        {
3552
+                            $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/';
3553
+                            if(preg_match($exp, $where, $matches))
3554
+                            {
3555
+                                    $search_expression = $matches[0];
3556
+                                    //Create three search conditions - first + last, first, last
3557
+                                    $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression);
3558
+                                    $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression);
3559
+                                $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression);
3560
+                                $buildWhere = true;
3561
+                                $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where);
3562
+                            }
3563
+                        }
3564
+
3565
+                        if(!$buildWhere)
3566
+                        {
3567
+                            $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']);
3568
+                            $where = preg_replace('/'.$data['name'].'/', $db_field, $where);
3569
+
3570
+                // For relationship fields replace their alias by the corresponsding link table and r_name
3571
+                if(isset($data['relationship_fields']))
3572
+                    foreach($data['relationship_fields'] as $r_name=>$alias_name)
3573
+                    {
3574
+                        $db_field = $this->db->concat($params['join_table_link_alias'], $r_name);
3575
+                        $where = preg_replace('/' . $alias_name . '/', $db_field, $where);
3576
+                    }
3577
+                        }
3578 3578
                     }else{
3579 3579
                         $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.'.$data['rname'], $where);
3580 3580
 
3581
-			// For relationship fields replace their alias by the corresponsding link table and r_name
3582
-			if(isset($data['relationship_fields']))
3583
-				foreach($data['relationship_fields'] as $r_name=>$alias_name)
3584
-					$where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where);
3581
+            // For relationship fields replace their alias by the corresponsding link table and r_name
3582
+            if(isset($data['relationship_fields']))
3583
+                foreach($data['relationship_fields'] as $r_name=>$alias_name)
3584
+                    $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where);
3585 3585
                     }
3586 3586
                     if(!$table_joined)
3587 3587
                     {
@@ -3610,12 +3610,12 @@  discard block
 block discarded – undo
3610 3610
 
3611 3611
         }
3612 3612
 
3613
-	if ($ifListForExport) {
3614
-		if(isset($this->field_defs['email1'])) {
3615
-			$ret_array['select'].= " ,email_addresses.email_address email1";
3616
-			$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 ";
3617
-		}
3618
-	}
3613
+    if ($ifListForExport) {
3614
+        if(isset($this->field_defs['email1'])) {
3615
+            $ret_array['select'].= " ,email_addresses.email_address email1";
3616
+            $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 ";
3617
+        }
3618
+    }
3619 3619
 
3620 3620
         $where_auto = '1=1';
3621 3621
         if($show_deleted == 0)
@@ -3650,18 +3650,18 @@  discard block
 block discarded – undo
3650 3650
         return  $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by'];
3651 3651
     }
3652 3652
 
3653
-	// Check if field is defined through a relationship_info field, add this field when not present 
3654
-	function get_relationship_field($field)
3655
-	{
3656
-		foreach ($this->field_defs as $field_def => $value)
3657
-		{
3658
-			if (isset($value['relationship_fields']) && 
3659
-				in_array($field, $value['relationship_fields']) )
3660
-				return $field_def;
3661
-		}
3653
+    // Check if field is defined through a relationship_info field, add this field when not present 
3654
+    function get_relationship_field($field)
3655
+    {
3656
+        foreach ($this->field_defs as $field_def => $value)
3657
+        {
3658
+            if (isset($value['relationship_fields']) && 
3659
+                in_array($field, $value['relationship_fields']) )
3660
+                return $field_def;
3661
+        }
3662 3662
 
3663
-		return false;
3664
-	}
3663
+        return false;
3664
+    }
3665 3665
 
3666 3666
     /**
3667 3667
      * Returns parent record data for objects that store relationship information
@@ -3768,8 +3768,8 @@  discard block
 block discarded – undo
3768 3768
         global $sugar_config;
3769 3769
         $db = DBManagerFactory::getInstance('listviews');
3770 3770
         /**
3771
-        * if the row_offset is set to 'end' go to the end of the list
3772
-        */
3771
+         * if the row_offset is set to 'end' go to the end of the list
3772
+         */
3773 3773
         $toEnd = strval($row_offset) == 'end';
3774 3774
         $GLOBALS['log']->debug("process_list_query: ".$query);
3775 3775
         if($max_per_page == -1)
@@ -3897,13 +3897,13 @@  discard block
 block discarded – undo
3897 3897
     }
3898 3898
 
3899 3899
     /**
3900
-    * Returns the number of rows that the given SQL query should produce
3900
+     * Returns the number of rows that the given SQL query should produce
3901 3901
      *
3902 3902
      * Internal function, do not override.
3903 3903
      * @param string $query valid select  query
3904 3904
      * @param boolean $is_count_query Optional, Default false, set to true if passed query is a count query.
3905 3905
      * @return int count of rows found
3906
-    */
3906
+     */
3907 3907
     function _get_num_rows_in_query($query, $is_count_query=false)
3908 3908
     {
3909 3909
         $num_rows_in_query = 0;
@@ -3945,8 +3945,8 @@  discard block
 block discarded – undo
3945 3945
     {
3946 3946
         $db = DBManagerFactory::getInstance('listviews');
3947 3947
         /**
3948
-        * if the row_offset is set to 'end' go to the end of the list
3949
-        */
3948
+         * if the row_offset is set to 'end' go to the end of the list
3949
+         */
3950 3950
         $toEnd = strval($row_offset) == 'end';
3951 3951
         global $sugar_config;
3952 3952
         $use_count_query=false;
@@ -4184,7 +4184,7 @@  discard block
 block discarded – undo
4184 4184
             }
4185 4185
             if(!empty($sugar_config['disable_count_query']) && !empty($limit))
4186 4186
             {
4187
-            	//C.L. Bug 43535 - Use the $index value to set the $rows_found value here
4187
+                //C.L. Bug 43535 - Use the $index value to set the $rows_found value here
4188 4188
                 $rows_found = isset($index) ? $index : $row_offset + count($list);
4189 4189
 
4190 4190
                 if(count($list) >= $limit)
@@ -4334,28 +4334,28 @@  discard block
 block discarded – undo
4334 4334
     }
4335 4335
 
4336 4336
     /**
4337
-    * Tracks the viewing of a detail record.
4338
-    * This leverages get_summary_text() which is object specific.
4339
-    *
4340
-    * Internal function, do not override.
4341
-    * @param string $user_id - String value of the user that is viewing the record.
4342
-    * @param string $current_module - String value of the module being processed.
4343
-    * @param string $current_view - String value of the current view
4344
-	*/
4345
-	function track_view($user_id, $current_module, $current_view='')
4346
-	{
4347
-	    $trackerManager = TrackerManager::getInstance();
4348
-		if($monitor = $trackerManager->getMonitor('tracker')){
4349
-	        $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb());
4350
-	        $monitor->setValue('user_id', $user_id);
4351
-	        $monitor->setValue('module_name', $current_module);
4352
-	        $monitor->setValue('action', $current_view);
4353
-	        $monitor->setValue('item_id', $this->id);
4354
-	        $monitor->setValue('item_summary', $this->get_summary_text());
4355
-	        $monitor->setValue('visible', $this->tracker_visibility);
4356
-	        $trackerManager->saveMonitor($monitor);
4357
-		}
4358
-	}
4337
+     * Tracks the viewing of a detail record.
4338
+     * This leverages get_summary_text() which is object specific.
4339
+     *
4340
+     * Internal function, do not override.
4341
+     * @param string $user_id - String value of the user that is viewing the record.
4342
+     * @param string $current_module - String value of the module being processed.
4343
+     * @param string $current_view - String value of the current view
4344
+     */
4345
+    function track_view($user_id, $current_module, $current_view='')
4346
+    {
4347
+        $trackerManager = TrackerManager::getInstance();
4348
+        if($monitor = $trackerManager->getMonitor('tracker')){
4349
+            $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb());
4350
+            $monitor->setValue('user_id', $user_id);
4351
+            $monitor->setValue('module_name', $current_module);
4352
+            $monitor->setValue('action', $current_view);
4353
+            $monitor->setValue('item_id', $this->id);
4354
+            $monitor->setValue('item_summary', $this->get_summary_text());
4355
+            $monitor->setValue('visible', $this->tracker_visibility);
4356
+            $trackerManager->saveMonitor($monitor);
4357
+        }
4358
+    }
4359 4359
 
4360 4360
     /**
4361 4361
      * Returns the summary text that should show up in the recent history list for this object.
@@ -4368,12 +4368,12 @@  discard block
 block discarded – undo
4368 4368
     }
4369 4369
 
4370 4370
     /**
4371
-    * This is designed to be overridden and add specific fields to each record.
4372
-    * This allows the generic query to fill in the major fields, and then targeted
4373
-    * queries to get related fields and add them to the record.  The contact's
4374
-    * account for instance.  This method is only used for populating extra fields
4375
-    * in lists.
4376
-    */
4371
+     * This is designed to be overridden and add specific fields to each record.
4372
+     * This allows the generic query to fill in the major fields, and then targeted
4373
+     * queries to get related fields and add them to the record.  The contact's
4374
+     * account for instance.  This method is only used for populating extra fields
4375
+     * in lists.
4376
+     */
4377 4377
     function fill_in_additional_list_fields(){
4378 4378
         if(!empty($this->field_defs['parent_name']) && empty($this->parent_name)){
4379 4379
             $this->fill_in_additional_parent_fields();
@@ -4381,12 +4381,12 @@  discard block
 block discarded – undo
4381 4381
     }
4382 4382
 
4383 4383
     /**
4384
-    * This is designed to be overridden and add specific fields to each record.
4385
-    * This allows the generic query to fill in the major fields, and then targeted
4386
-    * queries to get related fields and add them to the record.  The contact's
4387
-    * account for instance.  This method is only used for populating extra fields
4388
-    * in the detail form
4389
-    */
4384
+     * This is designed to be overridden and add specific fields to each record.
4385
+     * This allows the generic query to fill in the major fields, and then targeted
4386
+     * queries to get related fields and add them to the record.  The contact's
4387
+     * account for instance.  This method is only used for populating extra fields
4388
+     * in the detail form
4389
+     */
4390 4390
     function fill_in_additional_detail_fields()
4391 4391
     {
4392 4392
         if(!empty($this->field_defs['assigned_user_name']) && !empty($this->assigned_user_id)){
@@ -4394,20 +4394,20 @@  discard block
 block discarded – undo
4394 4394
             $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
4395 4395
 
4396 4396
         }
4397
-		if(!empty($this->field_defs['created_by']) && !empty($this->created_by))
4398
-		$this->created_by_name = get_assigned_user_name($this->created_by);
4399
-		if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id))
4400
-		$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
4397
+        if(!empty($this->field_defs['created_by']) && !empty($this->created_by))
4398
+        $this->created_by_name = get_assigned_user_name($this->created_by);
4399
+        if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id))
4400
+        $this->modified_by_name = get_assigned_user_name($this->modified_user_id);
4401 4401
 
4402
-		if(!empty($this->field_defs['parent_name'])){
4403
-			$this->fill_in_additional_parent_fields();
4404
-		}
4402
+        if(!empty($this->field_defs['parent_name'])){
4403
+            $this->fill_in_additional_parent_fields();
4404
+        }
4405 4405
     }
4406 4406
 
4407 4407
     /**
4408
-    * This is desgined to be overridden or called from extending bean. This method
4409
-    * will fill in any parent_name fields.
4410
-    */
4408
+     * This is desgined to be overridden or called from extending bean. This method
4409
+     * will fill in any parent_name fields.
4410
+     */
4411 4411
     function fill_in_additional_parent_fields() {
4412 4412
 
4413 4413
         if(!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id){
@@ -4448,8 +4448,8 @@  discard block
 block discarded – undo
4448 4448
     }
4449 4449
 
4450 4450
     /**
4451
-    * Fill in fields where type = relate
4452
-    */
4451
+     * Fill in fields where type = relate
4452
+     */
4453 4453
     function fill_in_relationship_fields(){
4454 4454
         global $fill_in_rel_depth;
4455 4455
         if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0)
@@ -4473,7 +4473,7 @@  discard block
 block discarded – undo
4473 4473
 
4474 4474
                     if (empty($this->$id_name))
4475 4475
                     {
4476
-                       $this->fill_in_link_field($id_name, $field);
4476
+                        $this->fill_in_link_field($id_name, $field);
4477 4477
                     }
4478 4478
                     if(!empty($this->$id_name) && ( $this->object_name != $related_module || ( $this->object_name == $related_module && $this->$id_name != $this->id ))){
4479 4479
                         if(isset($GLOBALS['beanList'][ $related_module])){
@@ -4499,7 +4499,7 @@  discard block
 block discarded – undo
4499 4499
                     if(!empty($this->$id_name) && isset($this->$name))
4500 4500
                     {
4501 4501
                         if(!isset($field['additionalFields']))
4502
-                           $field['additionalFields'] = array();
4502
+                            $field['additionalFields'] = array();
4503 4503
                         if(!empty($field['rname']))
4504 4504
                         {
4505 4505
                             $field['additionalFields'][$field['rname']]= $name;
@@ -4517,8 +4517,8 @@  discard block
 block discarded – undo
4517 4517
     }
4518 4518
 
4519 4519
     /**
4520
-    * This is a helper function that is used to quickly created indexes when creating tables.
4521
-    */
4520
+     * This is a helper function that is used to quickly created indexes when creating tables.
4521
+     */
4522 4522
     function create_index($query)
4523 4523
     {
4524 4524
         $GLOBALS['log']->info("create_index: $query");
@@ -4530,21 +4530,21 @@  discard block
 block discarded – undo
4530 4530
      * This function should be overridden in each module.  It marks an item as deleted.
4531 4531
      *
4532 4532
      * If it is not overridden, then marking this type of item is not allowed
4533
-	 */
4534
-	function mark_deleted($id)
4535
-	{
4536
-		global $current_user;
4537
-		$date_modified = $GLOBALS['timedate']->nowDb();
4533
+     */
4534
+    function mark_deleted($id)
4535
+    {
4536
+        global $current_user;
4537
+        $date_modified = $GLOBALS['timedate']->nowDb();
4538 4538
         $id = $this->db->quote($id);
4539
-		if(isset($_SESSION['show_deleted']))
4540
-		{
4541
-			$this->mark_undeleted($id);
4542
-		}
4543
-		else
4544
-		{
4545
-			// call the custom business logic
4546
-			$custom_logic_arguments['id'] = $id;
4547
-			$this->call_custom_logic("before_delete", $custom_logic_arguments);
4539
+        if(isset($_SESSION['show_deleted']))
4540
+        {
4541
+            $this->mark_undeleted($id);
4542
+        }
4543
+        else
4544
+        {
4545
+            // call the custom business logic
4546
+            $custom_logic_arguments['id'] = $id;
4547
+            $this->call_custom_logic("before_delete", $custom_logic_arguments);
4548 4548
             $this->deleted = 1;
4549 4549
             $this->mark_relationships_deleted($id);
4550 4550
             if ( isset($this->field_defs['modified_user_id']) ) {
@@ -4577,16 +4577,16 @@  discard block
 block discarded – undo
4577 4577
      * Restores data deleted by call to mark_deleted() function.
4578 4578
      *
4579 4579
      * Internal function, do not override.
4580
-    */
4580
+     */
4581 4581
     function mark_undeleted($id)
4582 4582
     {
4583 4583
         // call the custom business logic
4584 4584
         $custom_logic_arguments['id'] = $id;
4585 4585
         $this->call_custom_logic("before_restore", $custom_logic_arguments);
4586 4586
 
4587
-		$date_modified = $GLOBALS['timedate']->nowDb();
4588
-		$query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'";
4589
-		$this->db->query($query, true,"Error marking record undeleted: ");
4587
+        $date_modified = $GLOBALS['timedate']->nowDb();
4588
+        $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'";
4589
+        $this->db->query($query, true,"Error marking record undeleted: ");
4590 4590
 
4591 4591
         $this->restoreFiles();
4592 4592
 
@@ -4594,17 +4594,17 @@  discard block
 block discarded – undo
4594 4594
         $this->call_custom_logic("after_restore", $custom_logic_arguments);
4595 4595
     }
4596 4596
 
4597
-   /**
4598
-    * This function deletes relationships to this object.  It should be overridden
4599
-    * to handle the relationships of the specific object.
4600
-    * This function is called when the item itself is being deleted.
4601
-    *
4602
-    * @param int $id id of the relationship to delete
4603
-    */
4604
-   function mark_relationships_deleted($id)
4605
-   {
4597
+    /**
4598
+     * This function deletes relationships to this object.  It should be overridden
4599
+     * to handle the relationships of the specific object.
4600
+     * This function is called when the item itself is being deleted.
4601
+     *
4602
+     * @param int $id id of the relationship to delete
4603
+     */
4604
+    function mark_relationships_deleted($id)
4605
+    {
4606 4606
     $this->delete_linked($id);
4607
-   }
4607
+    }
4608 4608
 
4609 4609
     /**
4610 4610
      * Returns path for files of bean or false on error
@@ -4784,16 +4784,16 @@  discard block
 block discarded – undo
4784 4784
     }
4785 4785
 
4786 4786
     /**
4787
-    * This function is used to execute the query and create an array template objects
4788
-    * from the resulting ids from the query.
4789
-    * It is currently used for building sub-panel arrays.
4790
-    *
4791
-    * @param string $query - the query that should be executed to build the list
4792
-    * @param object $template - The object that should be used to copy the records.
4793
-    * @param int $row_offset Optional, default 0
4794
-    * @param int $limit Optional, default -1
4795
-    * @return array
4796
-    */
4787
+     * This function is used to execute the query and create an array template objects
4788
+     * from the resulting ids from the query.
4789
+     * It is currently used for building sub-panel arrays.
4790
+     *
4791
+     * @param string $query - the query that should be executed to build the list
4792
+     * @param object $template - The object that should be used to copy the records.
4793
+     * @param int $row_offset Optional, default 0
4794
+     * @param int $limit Optional, default -1
4795
+     * @return array
4796
+     */
4797 4797
     function build_related_list($query, &$template, $row_offset = 0, $limit = -1)
4798 4798
     {
4799 4799
         $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
@@ -4829,17 +4829,17 @@  discard block
 block discarded – undo
4829 4829
         return $list;
4830 4830
     }
4831 4831
 
4832
-  /**
4833
-    * This function is used to execute the query and create an array template objects
4834
-    * from the resulting ids from the query.
4835
-    * It is currently used for building sub-panel arrays. It supports an additional
4836
-    * where clause that is executed as a filter on the results
4837
-    *
4838
-    * @param string $query - the query that should be executed to build the list
4839
-    * @param object $template - The object that should be used to copy the records.
4840
-    */
4841
-  function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0)
4842
-  {
4832
+    /**
4833
+     * This function is used to execute the query and create an array template objects
4834
+     * from the resulting ids from the query.
4835
+     * It is currently used for building sub-panel arrays. It supports an additional
4836
+     * where clause that is executed as a filter on the results
4837
+     *
4838
+     * @param string $query - the query that should be executed to build the list
4839
+     * @param object $template - The object that should be used to copy the records.
4840
+     */
4841
+    function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0)
4842
+    {
4843 4843
     $db = DBManagerFactory::getInstance('listviews');
4844 4844
     // No need to do an additional query
4845 4845
     $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
@@ -4900,7 +4900,7 @@  discard block
 block discarded – undo
4900 4900
     }
4901 4901
 
4902 4902
     return $list;
4903
-  }
4903
+    }
4904 4904
 
4905 4905
     /**
4906 4906
      * Constructs an comma separated list of ids from passed query results.
@@ -4936,15 +4936,15 @@  discard block
 block discarded – undo
4936 4936
     }
4937 4937
 
4938 4938
     /**
4939
-    * Optionally copies values from fetched row into the bean.
4940
-    *
4941
-    * Internal function, do not override.
4942
-    *
4943
-    * @param string $query - the query that should be executed to build the list
4944
-    * @param object $template - The object that should be used to copy the records
4945
-    * @param array $field_list List of  fields.
4946
-    * @return array
4947
-    */
4939
+     * Optionally copies values from fetched row into the bean.
4940
+     *
4941
+     * Internal function, do not override.
4942
+     *
4943
+     * @param string $query - the query that should be executed to build the list
4944
+     * @param object $template - The object that should be used to copy the records
4945
+     * @param array $field_list List of  fields.
4946
+     * @return array
4947
+     */
4948 4948
     function build_related_list2($query, &$template, &$field_list)
4949 4949
     {
4950 4950
         $GLOBALS['log']->debug("Finding linked values $this->object_name: ".$query);
@@ -5117,19 +5117,19 @@  discard block
 block discarded – undo
5117 5117
         $row = $this->convertRow($row);
5118 5118
         $this->fetched_row = $row;
5119 5119
         $this->fromArray($row);
5120
-		$this->is_updated_dependent_fields = false;
5120
+        $this->is_updated_dependent_fields = false;
5121 5121
         $this->fill_in_additional_detail_fields();
5122 5122
         return $this;
5123 5123
     }
5124 5124
 
5125 5125
     /**
5126
-    * This method is called during an import before inserting a bean
5127
-    * Define an associative array called $special_fields
5128
-    * the keys are user defined, and don't directly map to the bean's fields
5129
-    * the value is the method name within that bean that will do extra
5130
-    * processing for that field. example: 'full_name'=>'get_names_from_full_name'
5131
-    *
5132
-    */
5126
+     * This method is called during an import before inserting a bean
5127
+     * Define an associative array called $special_fields
5128
+     * the keys are user defined, and don't directly map to the bean's fields
5129
+     * the value is the method name within that bean that will do extra
5130
+     * processing for that field. example: 'full_name'=>'get_names_from_full_name'
5131
+     *
5132
+     */
5133 5133
     function process_special_fields()
5134 5134
     {
5135 5135
         foreach ($this->special_functions as $func_name)
@@ -5263,8 +5263,8 @@  discard block
 block discarded – undo
5263 5263
     {
5264 5264
         $where = '';
5265 5265
 
5266
-		// make sure there is a date modified
5267
-		$date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime');
5266
+        // make sure there is a date modified
5267
+        $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime');
5268 5268
 
5269 5269
         $row=null;
5270 5270
         if($check_duplicates)
@@ -5341,30 +5341,30 @@  discard block
 block discarded – undo
5341 5341
     }
5342 5342
 
5343 5343
     /**
5344
-    * Trigger custom logic for this module that is defined for the provided hook
5345
-    * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php.
5346
-    * That file should define the $hook_version that should be used.
5347
-    * It should also define the $hook_array.  The $hook_array will be a two dimensional array
5348
-    * the first dimension is the name of the event, the second dimension is the information needed
5349
-    * to fire the hook.  Each entry in the top level array should be defined on a single line to make it
5350
-    * easier to automatically replace this file.  There should be no contents of this file that are not replacable.
5351
-    *
5352
-    * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1');
5353
-    * This sample line creates a before_save hook.  The hooks are procesed in the order in which they
5354
-    * are added to the array.  The second dimension is an array of:
5355
-    *		processing index (for sorting before exporting the array)
5356
-    *		A logic type hook
5357
-    *		label/type
5358
-    *		php file to include
5359
-    *		php class the method is in
5360
-    *		php method to call
5361
-    *
5362
-    * The method signature for version 1 hooks is:
5363
-    * function NAME(&$bean, $event, $arguments)
5364
-    * 		$bean - $this bean passed in by reference.
5365
-    *		$event - The string for the current event (i.e. before_save)
5366
-    * 		$arguments - An array of arguments that are specific to the event.
5367
-    */
5344
+     * Trigger custom logic for this module that is defined for the provided hook
5345
+     * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php.
5346
+     * That file should define the $hook_version that should be used.
5347
+     * It should also define the $hook_array.  The $hook_array will be a two dimensional array
5348
+     * the first dimension is the name of the event, the second dimension is the information needed
5349
+     * to fire the hook.  Each entry in the top level array should be defined on a single line to make it
5350
+     * easier to automatically replace this file.  There should be no contents of this file that are not replacable.
5351
+     *
5352
+     * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1');
5353
+     * This sample line creates a before_save hook.  The hooks are procesed in the order in which they
5354
+     * are added to the array.  The second dimension is an array of:
5355
+     *		processing index (for sorting before exporting the array)
5356
+     *		A logic type hook
5357
+     *		label/type
5358
+     *		php file to include
5359
+     *		php class the method is in
5360
+     *		php method to call
5361
+     *
5362
+     * The method signature for version 1 hooks is:
5363
+     * function NAME(&$bean, $event, $arguments)
5364
+     * 		$bean - $this bean passed in by reference.
5365
+     *		$event - The string for the current event (i.e. before_save)
5366
+     * 		$arguments - An array of arguments that are specific to the event.
5367
+     */
5368 5368
     function call_custom_logic($event, $arguments = null)
5369 5369
     {
5370 5370
         if(!isset($this->processed) || $this->processed == false){
@@ -5428,14 +5428,14 @@  discard block
 block discarded – undo
5428 5428
         return false;
5429 5429
     }
5430 5430
     /**
5431
-    * Check whether the user has access to a particular view for the current bean/module
5432
-    * @param $view string required, the view to determine access for i.e. DetailView, ListView...
5433
-    * @param $is_owner bool optional, this is part of the ACL check if the current user is an owner they will receive different access
5434
-    */
5435
-	/* BEGIN - SECURITY GROUPS - aclaccess */  
5436
-	/**
5431
+     * Check whether the user has access to a particular view for the current bean/module
5432
+     * @param $view string required, the view to determine access for i.e. DetailView, ListView...
5433
+     * @param $is_owner bool optional, this is part of the ACL check if the current user is an owner they will receive different access
5434
+     */
5435
+    /* BEGIN - SECURITY GROUPS - aclaccess */  
5436
+    /**
5437 5437
     function ACLAccess($view,$is_owner='not_set')
5438
-	*/
5438
+     */
5439 5439
     function ACLAccess($view,$is_owner='not_set',$in_group='not_set')
5440 5440
     {
5441 5441
         global $current_user;
@@ -5443,61 +5443,61 @@  discard block
 block discarded – undo
5443 5443
             return true;
5444 5444
         }
5445 5445
         $not_set = false;
5446
-		/**
5446
+        /**
5447 5447
         if($is_owner == 'not_set')
5448
-		*/
5449
-    	if($is_owner === 'not_set') //eggsurplus: should be ===
5448
+         */
5449
+        if($is_owner === 'not_set') //eggsurplus: should be ===
5450 5450
         {
5451 5451
             $not_set = true;
5452 5452
             $is_owner = $this->isOwner($current_user->id);
5453 5453
         }
5454
-		// DJM - OBS Customizations - May 2009
5455
-		// Moved this code to convert to lowercase from below.
5456
-		// Added new action variable.
5457
-		$view = strtolower($view);
5458
-		$action = '';
5459
-		// DJM - OBS Customizations - END CHANGE
5460
-    	if($in_group === 'not_set')
5461
-    	{
5462
-			require_once("modules/SecurityGroups/SecurityGroup.php");
5463
-			// DJM - OBS Customizations - May 2009
5464
-			// Added the following switch statement to convert the view
5465
-			// into an action value.  As per the switch below.
5466
-			// Added the action parameter to the groupHasAccess call.
5467
-    			switch ($view)
5468
-    			{
5469
-    				case 'list':
5470
-    				case 'index':
5471
-    				case 'listview':
5472
-    					$action = "list";
5473
-					break;
5474
-    				case 'edit':
5475
-    				case 'save':
5476
-		    		case 'popupeditview':
5477
- 		   		case 'editview':
5478
-  		  			$action = "edit";
5479
-					break;
5480
- 		   		case 'view':
5481
- 		   		case 'detail':
5482
- 		   		case 'detailview':
5483
- 		   			$action = "view";
5484
-					break;
5485
- 		   		case 'delete':
5486
- 		   			$action = "delete" ;
5487
-					break;
5488
- 		   		case 'export':
5489
- 		   			$action = "export";
5490
-					break;
5491
- 		   		case 'import':
5492
-  		  			$action = "import";
5493
-					break;
5494
-				default:
5495
-					$action = "";
5496
-					break;
5497
-    			}
5498
-			$in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); 
5499
-			// DJM - OBS Customizations - END CHANGE
5500
-    	}
5454
+        // DJM - OBS Customizations - May 2009
5455
+        // Moved this code to convert to lowercase from below.
5456
+        // Added new action variable.
5457
+        $view = strtolower($view);
5458
+        $action = '';
5459
+        // DJM - OBS Customizations - END CHANGE
5460
+        if($in_group === 'not_set')
5461
+        {
5462
+            require_once("modules/SecurityGroups/SecurityGroup.php");
5463
+            // DJM - OBS Customizations - May 2009
5464
+            // Added the following switch statement to convert the view
5465
+            // into an action value.  As per the switch below.
5466
+            // Added the action parameter to the groupHasAccess call.
5467
+                switch ($view)
5468
+                {
5469
+                    case 'list':
5470
+                    case 'index':
5471
+                    case 'listview':
5472
+                        $action = "list";
5473
+                    break;
5474
+                    case 'edit':
5475
+                    case 'save':
5476
+                    case 'popupeditview':
5477
+                    case 'editview':
5478
+                        $action = "edit";
5479
+                    break;
5480
+                    case 'view':
5481
+                    case 'detail':
5482
+                    case 'detailview':
5483
+                        $action = "view";
5484
+                    break;
5485
+                    case 'delete':
5486
+                        $action = "delete" ;
5487
+                    break;
5488
+                    case 'export':
5489
+                        $action = "export";
5490
+                    break;
5491
+                    case 'import':
5492
+                        $action = "import";
5493
+                    break;
5494
+                default:
5495
+                    $action = "";
5496
+                    break;
5497
+                }
5498
+            $in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); 
5499
+            // DJM - OBS Customizations - END CHANGE
5500
+        }
5501 5501
         //if we don't implent acls return true
5502 5502
         if(!$this->bean_implements('ACL'))
5503 5503
         return true;
@@ -5507,10 +5507,10 @@  discard block
 block discarded – undo
5507 5507
             case 'list':
5508 5508
             case 'index':
5509 5509
             case 'listview':
5510
-				/**
5510
+                /**
5511 5511
                 return ACLController::checkAccess($this->module_dir,'list', true);
5512
-				*/
5513
-    			return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group);
5512
+                 */
5513
+                return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group);
5514 5514
             case 'edit':
5515 5515
             case 'save':
5516 5516
                 if( !$is_owner && $not_set && !empty($this->id)){
@@ -5525,32 +5525,32 @@  discard block
 block discarded – undo
5525 5525
                 }
5526 5526
             case 'popupeditview':
5527 5527
             case 'editview':
5528
-				/**
5528
+                /**
5529 5529
                 return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype);
5530
-				*/
5531
-    			return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group);
5530
+                 */
5531
+                return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group);
5532 5532
             case 'view':
5533 5533
             case 'detail':
5534 5534
             case 'detailview':
5535
-				/**
5535
+                /**
5536 5536
                 return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype);
5537
-				*/
5538
-    			return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group);
5537
+                 */
5538
+                return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group);
5539 5539
             case 'delete':
5540
-				/**
5540
+                /**
5541 5541
                 return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype);
5542
-				*/
5543
-    			return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group);
5542
+                 */
5543
+                return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group);
5544 5544
             case 'export':
5545
-				/**
5545
+                /**
5546 5546
                 return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype);
5547
-				*/
5548
-    			return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group);
5547
+                 */
5548
+                return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group);
5549 5549
             case 'import':
5550
-				/**
5550
+                /**
5551 5551
                 return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype);
5552
-				*/
5553
-    			return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group);
5552
+                 */
5553
+                return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group);
5554 5554
         }
5555 5555
         //if it is not one of the above views then it should be implemented on the page level
5556 5556
         return true;
@@ -5558,10 +5558,10 @@  discard block
 block discarded – undo
5558 5558
     /* END - SECURITY GROUPS */
5559 5559
 
5560 5560
     /**
5561
-    * Get owner field
5562
-    *
5563
-    * @return STRING
5564
-    */
5561
+     * Get owner field
5562
+     *
5563
+     * @return STRING
5564
+     */
5565 5565
     function getOwnerField($returnFieldName = false)
5566 5566
     {
5567 5567
         if (isset($this->field_defs['assigned_user_id']))
@@ -5578,11 +5578,11 @@  discard block
 block discarded – undo
5578 5578
     }
5579 5579
 
5580 5580
     /**
5581
-    * Returns true of false if the user_id passed is the owner
5582
-    *
5583
-    * @param GUID $user_id
5584
-    * @return boolean
5585
-    */
5581
+     * Returns true of false if the user_id passed is the owner
5582
+     *
5583
+     * @param GUID $user_id
5584
+     * @return boolean
5585
+     */
5586 5586
     function isOwner($user_id)
5587 5587
     {
5588 5588
         //if we don't have an id we must be the owner as we are creating it
@@ -5611,11 +5611,11 @@  discard block
 block discarded – undo
5611 5611
         return false;
5612 5612
     }
5613 5613
     /**
5614
-    * Gets there where statement for checking if a user is an owner
5615
-    *
5616
-    * @param GUID $user_id
5617
-    * @return STRING
5618
-    */
5614
+     * Gets there where statement for checking if a user is an owner
5615
+     *
5616
+     * @param GUID $user_id
5617
+     * @return STRING
5618
+     */
5619 5619
     function getOwnerWhere($user_id)
5620 5620
     {
5621 5621
         if(isset($this->field_defs['assigned_user_id']))
@@ -5630,12 +5630,12 @@  discard block
 block discarded – undo
5630 5630
     }
5631 5631
 
5632 5632
     /**
5633
-    *
5634
-    * Used in order to manage ListView links and if they should
5635
-    * links or not based on the ACL permissions of the user
5636
-    *
5637
-    * @return ARRAY of STRINGS
5638
-    */
5633
+     *
5634
+     * Used in order to manage ListView links and if they should
5635
+     * links or not based on the ACL permissions of the user
5636
+     *
5637
+     * @return ARRAY of STRINGS
5638
+     */
5639 5639
     function listviewACLHelper()
5640 5640
     {
5641 5641
         $array_assign = array();
@@ -5651,10 +5651,10 @@  discard block
 block discarded – undo
5651 5651
     }
5652 5652
 
5653 5653
     /**
5654
-    * returns this bean as an array
5655
-    *
5656
-    * @return array of fields with id, name, access and category
5657
-    */
5654
+     * returns this bean as an array
5655
+     *
5656
+     * @return array of fields with id, name, access and category
5657
+     */
5658 5658
     function toArray($dbOnly = false, $stringOnly = false, $upperKeys=false)
5659 5659
     {
5660 5660
         static $cache = array();
@@ -5684,10 +5684,10 @@  discard block
 block discarded – undo
5684 5684
     }
5685 5685
 
5686 5686
     /**
5687
-    * Converts an array into an acl mapping name value pairs into files
5688
-    *
5689
-    * @param Array $arr
5690
-    */
5687
+     * Converts an array into an acl mapping name value pairs into files
5688
+     *
5689
+     * @param Array $arr
5690
+     */
5691 5691
     function fromArray($arr)
5692 5692
     {
5693 5693
         foreach($arr as $name=>$value)
@@ -5705,13 +5705,13 @@  discard block
 block discarded – undo
5705 5705
     public function convertRow($row)
5706 5706
     {
5707 5707
         foreach($this->field_defs as $name => $fieldDef)
5708
-		{
5709
-		    // skip empty fields and non-db fields
5708
+        {
5709
+            // skip empty fields and non-db fields
5710 5710
             if (isset($name) && !empty($row[$name])) {
5711 5711
                 $row[$name] = $this->convertField($row[$name], $fieldDef);
5712 5712
             }
5713 5713
         }
5714
-		return $row;
5714
+        return $row;
5715 5715
     }
5716 5716
 
5717 5717
     /**
@@ -5759,18 +5759,18 @@  discard block
 block discarded – undo
5759 5759
         return !empty($GLOBALS['dictionary'][$this->object_name]['custom_fields']);
5760 5760
     }
5761 5761
 
5762
-   /**
5763
-    * Ensure that fields within order by clauses are properly qualified with
5764
-    * their tablename.  This qualification is a requirement for sql server support.
5765
-    *
5766
-    * @param string $order_by original order by from the query
5767
-    * @param string $qualify prefix for columns in the order by list.
5768
-    * @return  prefixed
5769
-    *
5770
-    * Internal function do not override.
5771
-    */
5772
-   function create_qualified_order_by( $order_by, $qualify)
5773
-   {	// 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
5762
+    /**
5763
+     * Ensure that fields within order by clauses are properly qualified with
5764
+     * their tablename.  This qualification is a requirement for sql server support.
5765
+     *
5766
+     * @param string $order_by original order by from the query
5767
+     * @param string $qualify prefix for columns in the order by list.
5768
+     * @return  prefixed
5769
+     *
5770
+     * Internal function do not override.
5771
+     */
5772
+    function create_qualified_order_by( $order_by, $qualify)
5773
+    {	// 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
5774 5774
     if (empty($order_by))
5775 5775
     {
5776 5776
         return $order_by;
@@ -5785,17 +5785,17 @@  discard block
 block discarded – undo
5785 5785
         $comma = ", ";
5786 5786
     }
5787 5787
     return $order_by_clause;
5788
-   }
5788
+    }
5789 5789
 
5790
-   /**
5791
-    * Combined the contents of street field 2 thru 4 into the main field
5792
-    *
5793
-    * @param string $street_field
5794
-    */
5790
+    /**
5791
+     * Combined the contents of street field 2 thru 4 into the main field
5792
+     *
5793
+     * @param string $street_field
5794
+     */
5795 5795
 
5796
-   function add_address_streets(
5797
-       $street_field
5798
-       )
5796
+    function add_address_streets(
5797
+        $street_field
5798
+        )
5799 5799
     {
5800 5800
         if (isset($this->$street_field)) {
5801 5801
             $street_field_2 = $street_field.'_2';
@@ -5849,9 +5849,9 @@  discard block
 block discarded – undo
5849 5849
     }
5850 5850
 
5851 5851
     /**
5852
-    * Moved from save() method, functionality is the same, but this is intended to handle
5853
-    * Optimistic locking functionality.
5854
-    */
5852
+     * Moved from save() method, functionality is the same, but this is intended to handle
5853
+     * Optimistic locking functionality.
5854
+     */
5855 5855
     private function _checkOptimisticLocking($action, $isUpdate){
5856 5856
         if($this->optimistic_lock && !isset($_SESSION['o_lock_fs'])){
5857 5857
             if(isset($_SESSION['o_lock_id']) && $_SESSION['o_lock_id'] == $this->id && $_SESSION['o_lock_on'] == $this->object_name)
@@ -5890,8 +5890,8 @@  discard block
 block discarded – undo
5890 5890
     }
5891 5891
 
5892 5892
     /**
5893
-    * Send assignment notifications and invites for meetings and calls
5894
-    */
5893
+     * Send assignment notifications and invites for meetings and calls
5894
+     */
5895 5895
     private function _sendNotifications($check_notify){
5896 5896
         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.
5897 5897
            && !$this->isOwner($this->created_by) )  // cn: bug 42727 no need to send email to owner (within workflow)
@@ -5979,11 +5979,11 @@  discard block
 block discarded – undo
5979 5979
         $result = sugar_cache_retrieve($cache_key);
5980 5980
         if(!empty($result))
5981 5981
         {
5982
-        	// Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache.
5983
-        	if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE)
5984
-        	{
5985
-        		return null;
5986
-        	}
5982
+            // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache.
5983
+            if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE)
5984
+            {
5985
+                return null;
5986
+            }
5987 5987
 
5988 5988
             return $result;
5989 5989
         }
@@ -6000,7 +6000,7 @@  discard block
 block discarded – undo
6000 6000
             if(empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key]))
6001 6001
             {
6002 6002
                 // It was not loaded....  Fail.  Cache null to prevent future repeats of this calculation
6003
-				sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE);
6003
+                sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE);
6004 6004
                 return  null;
6005 6005
             }
6006 6006
 
@@ -6011,8 +6011,8 @@  discard block
 block discarded – undo
6011 6011
 
6012 6012
         // It was not loaded....  Fail.  Cache null to prevent future repeats of this calculation
6013 6013
         sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE);
6014
-		return null;
6015
-	}
6014
+        return null;
6015
+    }
6016 6016
 
6017 6017
     /**
6018 6018
      * Returns the ACL category for this module; defaults to the SugarBean::$acl_category if defined
@@ -6033,10 +6033,10 @@  discard block
 block discarded – undo
6033 6033
      * @param string $where
6034 6034
      * @return string SQL query
6035 6035
      */
6036
-	public function create_export_query($order_by, $where)
6037
-	{
6038
-		return $this->create_new_list_query($order_by, $where, array(), array(), 0, '', false, $this, true, true);
6039
-	}
6036
+    public function create_export_query($order_by, $where)
6037
+    {
6038
+        return $this->create_new_list_query($order_by, $where, array(), array(), 0, '', false, $this, true, true);
6039
+    }
6040 6040
 
6041 6041
     /**
6042 6042
      * Determine whether the given field is a relate field
Please login to merge, or discard this patch.
data/Relationships/One2OneBeanRelationship.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,9 +102,9 @@
 block discarded – undo
102 102
 
103 103
         //join the related module's table
104 104
         $join .= "$join_type $targetTableWithAlias ON $targetTable.$targetKey=$startingTable.$startingKey"
105
-               . " AND $targetTable.deleted=$deleted\n"
105
+                . " AND $targetTable.deleted=$deleted\n"
106 106
         //Next add any role filters
107
-               . $this->getRoleWhere();
107
+                . $this->getRoleWhere();
108 108
 
109 109
         if($return_array){
110 110
             return array(
Please login to merge, or discard this patch.
data/Relationships/One2MBeanRelationship.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         //First join the relationship table
296 296
         $join .= "$join_type $targetTableWithAlias ON $startingTable.$startingKey=$targetTable.$targetKey AND $targetTable.deleted=0\n"
297 297
         //Next add any role filters
298
-               . $this->getRoleWhere(($linkIsLHS) ? $targetTable : $startingTable) . "\n";
298
+                . $this->getRoleWhere(($linkIsLHS) ? $targetTable : $startingTable) . "\n";
299 299
 
300 300
         if($return_array){
301 301
             return array(
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
         $query .= "$join_type $targetTableWithAlias ON $startingTable.$startingKey=$targetTable.$targetKey AND $targetTable.deleted=0\n"
356 356
         //Next add any role filters
357
-               . $this->getRoleWhere($tableInRoleFilter) . "\n";
357
+                . $this->getRoleWhere($tableInRoleFilter) . "\n";
358 358
 
359 359
         if (!empty($params['return_as_array'])) {
360 360
             $return_array = true;
Please login to merge, or discard this patch.
data/Relationships/M2MRelationship.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -131,28 +131,28 @@  discard block
 block discarded – undo
131 131
         $lhsLinkName = $this->lhsLink;
132 132
         $rhsLinkName = $this->rhsLink;
133 133
         
134
-    	/* BEGIN - SECURITY GROUPS */
135
-    	//Need to hijack this as security groups will not contain a link on the module side
136
-    	//due to the way the module works. Plus it would remove the relative ease of adding custom module support
134
+        /* BEGIN - SECURITY GROUPS */
135
+        //Need to hijack this as security groups will not contain a link on the module side
136
+        //due to the way the module works. Plus it would remove the relative ease of adding custom module support
137 137
     	
138
-    	if(get_class($rhs) != 'User' && get_class($rhs) != 'ACLRole' && get_class($lhs) == 'SecurityGroup') {
139
-			$rhs->$rhsLinkName->addBean($lhs);			
140
-			$this->callBeforeAdd($rhs, $lhs, $rhsLinkName);
141
-
142
-			$dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields);
143
-			$this->addRow($dataToInsert);
144
-    		$rhs->$rhsLinkName->addBean($lhs);
145
-    		$this->callAfterAdd($lhs, $rhs, $lhsLinkName);
146
-    	} else if(get_class($lhs) != 'User' && get_class($lhs) != 'ACLRole' && get_class($rhs) == 'SecurityGroup') {
147
-			$lhs->$lhsLinkName->addBean($rhs);			
148
-			$this->callBeforeAdd($lhs, $rhs, $lhsLinkName);
149
-
150
-			$dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields);
151
-			$this->addRow($dataToInsert);
152
-    		$lhs->$lhsLinkName->addBean($rhs);
153
-    		$this->callAfterAdd($rhs, $lhs, $rhsLinkName);
154
-    	} else {
155
-    	/* END - SECURITY GROUPS */
138
+        if(get_class($rhs) != 'User' && get_class($rhs) != 'ACLRole' && get_class($lhs) == 'SecurityGroup') {
139
+            $rhs->$rhsLinkName->addBean($lhs);			
140
+            $this->callBeforeAdd($rhs, $lhs, $rhsLinkName);
141
+
142
+            $dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields);
143
+            $this->addRow($dataToInsert);
144
+            $rhs->$rhsLinkName->addBean($lhs);
145
+            $this->callAfterAdd($lhs, $rhs, $lhsLinkName);
146
+        } else if(get_class($lhs) != 'User' && get_class($lhs) != 'ACLRole' && get_class($rhs) == 'SecurityGroup') {
147
+            $lhs->$lhsLinkName->addBean($rhs);			
148
+            $this->callBeforeAdd($lhs, $rhs, $lhsLinkName);
149
+
150
+            $dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields);
151
+            $this->addRow($dataToInsert);
152
+            $lhs->$lhsLinkName->addBean($rhs);
153
+            $this->callAfterAdd($rhs, $lhs, $rhsLinkName);
154
+        } else {
155
+        /* END - SECURITY GROUPS */
156 156
 
157 157
         if (empty($lhs->$lhsLinkName) && !$lhs->load_relationship($lhsLinkName))
158 158
         {
@@ -262,50 +262,50 @@  discard block
 block discarded – undo
262 262
             return false;
263 263
         }
264 264
         
265
-    	/* BEGIN - SECURITY GROUPS */
266
-    	//Need to hijack this as security groups will not contain a link on the module side
267
-    	//due to the way the module works. Plus it would remove the relative ease of adding custom module support
265
+        /* BEGIN - SECURITY GROUPS */
266
+        //Need to hijack this as security groups will not contain a link on the module side
267
+        //due to the way the module works. Plus it would remove the relative ease of adding custom module support
268 268
     	
269
-    	if(get_class($lhs) == 'SecurityGroup' || get_class($rhs) == 'SecurityGroup') {
270
-			$dataToRemove = array(
271
-				$this->def['join_key_lhs'] => $lhs->id,
272
-				$this->def['join_key_rhs'] => $rhs->id
273
-			);
274
-
275
-
276
-              if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes")
277
-              {
278
-                  if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2)
279
-                  {
280
-                      $lhs->$lhsLinkName->load();
281
-                      $this->callBeforeDelete($lhs, $rhs, $lhsLinkName);
282
-                  }
283
-
284
-                  if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2)
285
-                  {
286
-                      $rhs->$rhsLinkName->load();
287
-                      $this->callBeforeDelete($rhs, $lhs, $rhsLinkName);
288
-                  }
289
-              }
290
-
291
-			$this->removeRow($dataToRemove);
269
+        if(get_class($lhs) == 'SecurityGroup' || get_class($rhs) == 'SecurityGroup') {
270
+            $dataToRemove = array(
271
+                $this->def['join_key_lhs'] => $lhs->id,
272
+                $this->def['join_key_rhs'] => $rhs->id
273
+            );
274
+
275
+
276
+                if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes")
277
+                {
278
+                    if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2)
279
+                    {
280
+                        $lhs->$lhsLinkName->load();
281
+                        $this->callBeforeDelete($lhs, $rhs, $lhsLinkName);
282
+                    }
283
+
284
+                    if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2)
285
+                    {
286
+                        $rhs->$rhsLinkName->load();
287
+                        $this->callBeforeDelete($rhs, $lhs, $rhsLinkName);
288
+                    }
289
+                }
290
+
291
+            $this->removeRow($dataToRemove);
292 292
 			
293
-			if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes")
294
-			{
295
-				if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2)
296
-				{
297
-					$lhs->$lhsLinkName->load();
298
-					$this->callAfterDelete($lhs, $rhs, $lhsLinkName);
299
-				}
300
-
301
-				if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2)
302
-				{
303
-					$rhs->$rhsLinkName->load();
304
-					$this->callAfterDelete($rhs, $lhs, $rhsLinkName);
305
-				}
306
-			}
307
-		} else {
308
-    	/* END - SECURITY GROUPS */        
293
+            if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes")
294
+            {
295
+                if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2)
296
+                {
297
+                    $lhs->$lhsLinkName->load();
298
+                    $this->callAfterDelete($lhs, $rhs, $lhsLinkName);
299
+                }
300
+
301
+                if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2)
302
+                {
303
+                    $rhs->$rhsLinkName->load();
304
+                    $this->callAfterDelete($rhs, $lhs, $rhsLinkName);
305
+                }
306
+            }
307
+        } else {
308
+        /* END - SECURITY GROUPS */        
309 309
         if (empty($lhs->$lhsLinkName) && !$lhs->load_relationship($lhsLinkName))
310 310
         {
311 311
             $GLOBALS['log']->fatal("could not load LHS $lhsLinkName");
@@ -512,9 +512,9 @@  discard block
 block discarded – undo
512 512
         //First join the relationship table
513 513
         $join .= "$join_type $joinTableWithAlias ON $join1 AND $joinTable.deleted=0\n"
514 514
         //Next add any role filters
515
-               . $this->getRoleWhere($joinTable) . "\n"
515
+                . $this->getRoleWhere($joinTable) . "\n"
516 516
         //Then finally join the related module's table
517
-               . "$join_type $targetTableWithAlias ON $join2 AND $targetTable.deleted=0\n";
517
+                . "$join_type $targetTableWithAlias ON $join2 AND $targetTable.deleted=0\n";
518 518
 
519 519
         if($return_array){
520 520
             return array(
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
         //First join the relationship table
567 567
         $query .= "$join_type $joinTableWithAlias ON $where AND $joinTable.deleted=0\n"
568 568
         //Next add any role filters
569
-               . $this->getRoleWhere($joinTable, $ignoreRole) . "\n";
569
+                . $this->getRoleWhere($joinTable, $ignoreRole) . "\n";
570 570
 
571 571
         if (!empty($params['return_as_array'])) {
572 572
             $return_array = true;
Please login to merge, or discard this patch.
data/Relationships/One2MRelationship.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             );
101 101
             if (!isset($this->lhsLinkDef['name']) && isset($this->lhsLinkDef[0]))
102 102
             {
103
-              $this->lhsLinkDef = $this->lhsLinkDef[0];
103
+                $this->lhsLinkDef = $this->lhsLinkDef[0];
104 104
             }
105 105
             if (!isset($this->rhsLinkDef['name']) && isset($this->rhsLinkDef[0])) {
106 106
                 $this->rhsLinkDef = $this->rhsLinkDef[0];
@@ -128,35 +128,35 @@  discard block
 block discarded – undo
128 128
         //If the current data matches the existing data, don't do anything
129 129
         if (!$this->checkExisting($dataToInsert))
130 130
         {
131
-			// Pre-load the RHS relationship, which is used later in the add() function and expects a Bean
132
-			// and we also use it for clearing relationships in case of non self-referencing O2M relations
133
-			// (should be preloaded because when using the relate_to field for updating/saving relationships,
134
-			// only the bean id is loaded into $rhs->$rhsLinkName)
135
-			$rhsLinkName = $this->rhsLink;
136
-			$rhs->load_relationship($rhsLinkName);
131
+            // Pre-load the RHS relationship, which is used later in the add() function and expects a Bean
132
+            // and we also use it for clearing relationships in case of non self-referencing O2M relations
133
+            // (should be preloaded because when using the relate_to field for updating/saving relationships,
134
+            // only the bean id is loaded into $rhs->$rhsLinkName)
135
+            $rhsLinkName = $this->rhsLink;
136
+            $rhs->load_relationship($rhsLinkName);
137 137
         	
138
-			// If it's a One2Many self-referencing relationship
139
-        	// the positions of the default One (LHS) and Many (RHS) are swaped
140
-        	// so we should clear the links from the many (left) side
141
-        	if ($this->selfReferencing) {
142
-        		// Load right hand side relationship name
143
-	            $linkName = $this->rhsLink;
144
-	            // Load the relationship into the left hand side bean
145
-	            $lhs->load_relationship($linkName);
138
+            // If it's a One2Many self-referencing relationship
139
+            // the positions of the default One (LHS) and Many (RHS) are swaped
140
+            // so we should clear the links from the many (left) side
141
+            if ($this->selfReferencing) {
142
+                // Load right hand side relationship name
143
+                $linkName = $this->rhsLink;
144
+                // Load the relationship into the left hand side bean
145
+                $lhs->load_relationship($linkName);
146 146
 	            
147
-	            // Pick the loaded link
148
-	            $link = $lhs->$linkName;
149
-	            // Get many (LHS) side bean
150
-	            $focus = $link->getFocus();
151
-	            // Get relations
152
-	        	$related = $link->getBeans();
147
+                // Pick the loaded link
148
+                $link = $lhs->$linkName;
149
+                // Get many (LHS) side bean
150
+                $focus = $link->getFocus();
151
+                // Get relations
152
+                $related = $link->getBeans();
153 153
 	        	
154
-        		// Clear the relations from many side bean
155
-	        	foreach($related as $relBean) {
156
-	        		$this->remove($focus, $relBean);
157
-	        	}
154
+                // Clear the relations from many side bean
155
+                foreach($related as $relBean) {
156
+                    $this->remove($focus, $relBean);
157
+                }
158 158
             } else { // For non self-referencing, remove all the relationships from the many (RHS) side
159
-            	$this->removeAll($rhs->$rhsLinkName);
159
+                $this->removeAll($rhs->$rhsLinkName);
160 160
             }
161 161
             
162 162
             // Add relationship
Please login to merge, or discard this patch.
data/Relationships/RelationshipFactory.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -213,9 +213,9 @@
 block discarded – undo
213 213
         $buildingRelCache = false;
214 214
     }
215 215
 
216
-	protected function getCacheFile() {
217
-		return sugar_cached("Relationships/relationships.cache.php");
218
-	}
216
+    protected function getCacheFile() {
217
+        return sugar_cached("Relationships/relationships.cache.php");
218
+    }
219 219
 
220 220
 
221 221
 
Please login to merge, or discard this patch.
soap.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- if(!defined('sugarEntry'))define('sugarEntry', true);
2
+    if(!defined('sugarEntry'))define('sugarEntry', true);
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 //New API is in these files
67 67
 if(!empty($administrator->settings['portal_on'])) {
68
-	require_once('soap/SoapPortalUsers.php');
68
+    require_once('soap/SoapPortalUsers.php');
69 69
 }
70 70
 
71 71
 require_once('soap/SoapSugarUsers.php');
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 $observers = $resourceManager->getObservers();
89 89
 //Call set_soap_server for SoapResourceObserver instance(s)
90 90
 foreach($observers as $observer) {
91
-   if(method_exists($observer, 'set_soap_server')) {
92
-   	  $observer->set_soap_server($server);
93
-   }
91
+    if(method_exists($observer, 'set_soap_server')) {
92
+            $observer->set_soap_server($server);
93
+    }
94 94
 }
95 95
 
96 96
 $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
Please login to merge, or discard this patch.
modules/Connectors/InstallDefaultConnectors.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -40,26 +40,26 @@  discard block
 block discarded – undo
40 40
 
41 41
 
42 42
 $default_modules_sources = array (
43
-  'Accounts' =>
44
-  array (
45
-     'ext_rest_insideview' => 'ext_rest_insideview',
46
-  ),
47
-  'Contacts' =>
48
-  array (
49
-     'ext_rest_insideview' => 'ext_rest_insideview',
50
-  ),
51
-  'Leads' =>
52
-  array (
53
-     'ext_rest_insideview' => 'ext_rest_insideview',
54
-  ),
55
-  'Prospects' =>
56
-  array (
43
+    'Accounts' =>
44
+    array (
45
+        'ext_rest_insideview' => 'ext_rest_insideview',
46
+    ),
47
+    'Contacts' =>
48
+    array (
49
+        'ext_rest_insideview' => 'ext_rest_insideview',
50
+    ),
51
+    'Leads' =>
52
+    array (
53
+        'ext_rest_insideview' => 'ext_rest_insideview',
54
+    ),
55
+    'Prospects' =>
56
+    array (
57 57
 
58
-  ),
59
-  'Opportunities' =>
60
-  array (
58
+    ),
59
+    'Opportunities' =>
60
+    array (
61 61
     'ext_rest_insideview' => 'ext_rest_insideview',
62
-  ),
62
+    ),
63 63
 );
64 64
 
65 65
 $previous_connectors = array();
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 }
104 104
 
105 105
 if(!file_exists('custom/modules/Connectors/metadata')) {
106
-   mkdir_recursive('custom/modules/Connectors/metadata');
106
+    mkdir_recursive('custom/modules/Connectors/metadata');
107 107
 }
108 108
 
109 109
 if(!write_array_to_file('modules_sources', $default_modules_sources, 'custom/modules/Connectors/metadata/display_config.php')) {
110
-   $GLOBALS['log']->fatal('Cannot write file custom/modules/Connectors/metadata/display_config.php');
110
+    $GLOBALS['log']->fatal('Cannot write file custom/modules/Connectors/metadata/display_config.php');
111 111
 }
112 112
 
113 113
 ?>
Please login to merge, or discard this patch.
modules/Connectors/ConnectorRecord.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@
 block discarded – undo
41 41
 
42 42
 
43 43
 
44
- class ConnectorRecord extends MergeRecord{
45
-	var $object_name = 'ConnectorRecord';
44
+    class ConnectorRecord extends MergeRecord{
45
+    var $object_name = 'ConnectorRecord';
46 46
     var $module_dir = 'Connector'; 
47 47
     
48 48
     
49 49
     function ConnectorRecord($merge_module = '', $merge_id = '') {
50
-       parent::MergeRecord($merge_module, $merge_id);
50
+        parent::MergeRecord($merge_module, $merge_id);
51 51
     }
52 52
 
53
- }
53
+    }
54 54
 ?>
Please login to merge, or discard this patch.