Passed
Push — scrutinizer-code-quality ( 27193c...09f5a1 )
by Adam
51:28
created
modules/Reminders_Invitees/Reminder_Invitee.php 3 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
         parent::Basic();
61 61
     }
62 62
 
63
-    public function bean_implements($interface){
64
-        switch($interface){
63
+    public function bean_implements($interface) {
64
+        switch ($interface) {
65 65
             case 'ACL': return true;
66 66
         }
67 67
         return false;
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
     public static function saveRemindersInviteesData($reminderId, $inviteesData) {
77 77
         $savedInviteeIds = array();
78
-        foreach($inviteesData as $k => $inviteeData) {
79
-            if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $inviteeData->id = '';
78
+        foreach ($inviteesData as $k => $inviteeData) {
79
+            if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $inviteeData->id = '';
80 80
             $reminderInviteeBean = BeanFactory::getBean('Reminders_Invitees', $inviteeData->id);
81 81
             $reminderInviteeBean->reminder_id = $reminderId;
82 82
             $reminderInviteeBean->related_invitee_module = $inviteeData->module;
83 83
             $reminderInviteeBean->related_invitee_module_id = $inviteeData->module_id;
84
-            if(!$inviteeData->id) {
84
+            if (!$inviteeData->id) {
85 85
                 $reminderInviteeBean->save();
86 86
                 $savedInviteeIds[] = $reminderInviteeBean->id;
87 87
             }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$ret = array();
109 109
 		$reminderInviteeBeen = new Reminder_Invitee();
110 110
 		$reminderInvitees = $reminderInviteeBeen->get_full_list("reminders_invitees.date_entered", "reminders_invitees.reminder_id = '$reminderId'");
111
-        if($reminderInvitees) {
111
+        if ($reminderInvitees) {
112 112
             foreach ($reminderInvitees as $reminderInvitee) {
113 113
                 $ret[] = array(
114 114
                     'id' => $isDuplicate ? null : $reminderInvitee->id,
@@ -125,21 +125,21 @@  discard block
 block discarded – undo
125 125
         $retValue = "unknown";
126 126
 
127 127
         $bean = BeanFactory::getBean($module, $moduleId);
128
-        switch($module) {
128
+        switch ($module) {
129 129
             case 'Users':
130 130
             case 'Contacts':
131 131
             case 'Leads':
132 132
             default:
133
-                if(isset($bean->first_name) && isset($bean->last_name)) {
133
+                if (isset($bean->first_name) && isset($bean->last_name)) {
134 134
                     $retValue = "{$bean->first_name} {$bean->last_name}";
135 135
                 }
136
-                else if(isset($bean->name)) {
136
+                else if (isset($bean->name)) {
137 137
                     $retValue = $bean->name;
138 138
                 }
139
-                else if(isset($bean->email)) {
139
+                else if (isset($bean->email)) {
140 140
                     $retValue = $bean->email;
141 141
                 }
142
-                if(!$retValue) {
142
+                if (!$retValue) {
143 143
                     $retValue = "$module ($moduleId)";
144 144
                 }
145 145
                 break;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
     public static function deleteRemindersInviteesMultiple($reminderId, $inviteeIds = array()) {
157 157
         $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list("", "reminders_invitees.reminder_id = '$reminderId'");
158
-        if($invitees) {
158
+        if ($invitees) {
159 159
             foreach ($invitees as $invitee) {
160 160
                 if (!in_array($invitee->id, $inviteeIds)) {
161 161
                     $invitee->mark_deleted($invitee->id);
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -76,7 +76,9 @@  discard block
 block discarded – undo
76 76
     public static function saveRemindersInviteesData($reminderId, $inviteesData) {
77 77
         $savedInviteeIds = array();
78 78
         foreach($inviteesData as $k => $inviteeData) {
79
-            if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $inviteeData->id = '';
79
+            if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) {
80
+                $inviteeData->id = '';
81
+            }
80 82
             $reminderInviteeBean = BeanFactory::getBean('Reminders_Invitees', $inviteeData->id);
81 83
             $reminderInviteeBean->reminder_id = $reminderId;
82 84
             $reminderInviteeBean->related_invitee_module = $inviteeData->module;
@@ -84,8 +86,7 @@  discard block
 block discarded – undo
84 86
             if(!$inviteeData->id) {
85 87
                 $reminderInviteeBean->save();
86 88
                 $savedInviteeIds[] = $reminderInviteeBean->id;
87
-            }
88
-            else {
89
+            } else {
89 90
                 $addedInvitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list("", "reminders_invitees.id != '{$inviteeData->id}' AND reminders_invitees.reminder_id = '{$reminderInviteeBean->reminder_id}' AND reminders_invitees.related_invitee_module = '{$reminderInviteeBean->related_invitee_module}' AND reminders_invitees.related_invitee_module_id = '{$reminderInviteeBean->related_invitee_module_id}'");
90 91
                 if (!$addedInvitees) {
91 92
                     $reminderInviteeBean->save();
@@ -132,11 +133,9 @@  discard block
 block discarded – undo
132 133
             default:
133 134
                 if(isset($bean->first_name) && isset($bean->last_name)) {
134 135
                     $retValue = "{$bean->first_name} {$bean->last_name}";
135
-                }
136
-                else if(isset($bean->name)) {
136
+                } else if(isset($bean->name)) {
137 137
                     $retValue = $bean->name;
138
-                }
139
-                else if(isset($bean->email)) {
138
+                } else if(isset($bean->email)) {
140 139
                     $retValue = $bean->email;
141 140
                 }
142 141
                 if(!$retValue) {
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
         return false;
68 68
     }
69 69
 
70
-	/**
71
-	 * Save multiple reminders invitees data.
72
-	 *
73
-	 * @param string $reminderId Related Reminder GUID
74
-	 * @param array $inviteesData Invitees Data
75
-	 */
70
+    /**
71
+     * Save multiple reminders invitees data.
72
+     *
73
+     * @param string $reminderId Related Reminder GUID
74
+     * @param array $inviteesData Invitees Data
75
+     */
76 76
     public static function saveRemindersInviteesData($reminderId, $inviteesData) {
77 77
         $savedInviteeIds = array();
78 78
         foreach($inviteesData as $k => $inviteeData) {
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
         self::deleteRemindersInviteesMultiple($reminderId, $savedInviteeIds);
99 99
     }
100 100
 
101
-	/**
102
-	 * Load reminders invitees data.
103
-	 *
104
-	 * @param string $reminderId Related Reminder GUID
105
-	 * @return array Invitees data
106
-	 */
107
-	public static function loadRemindersInviteesData($reminderId, $isDuplicate = false) {
108
-		$ret = array();
109
-		$reminderInviteeBeen = new Reminder_Invitee();
110
-		$reminderInvitees = $reminderInviteeBeen->get_full_list("reminders_invitees.date_entered", "reminders_invitees.reminder_id = '$reminderId'");
101
+    /**
102
+     * Load reminders invitees data.
103
+     *
104
+     * @param string $reminderId Related Reminder GUID
105
+     * @return array Invitees data
106
+     */
107
+    public static function loadRemindersInviteesData($reminderId, $isDuplicate = false) {
108
+        $ret = array();
109
+        $reminderInviteeBeen = new Reminder_Invitee();
110
+        $reminderInvitees = $reminderInviteeBeen->get_full_list("reminders_invitees.date_entered", "reminders_invitees.reminder_id = '$reminderId'");
111 111
         if($reminderInvitees) {
112 112
             foreach ($reminderInvitees as $reminderInvitee) {
113 113
                 $ret[] = array(
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
                 );
119 119
             }
120 120
         }
121
-		return $ret;
122
-	}
121
+        return $ret;
122
+    }
123 123
 
124 124
     private static function getInviteeName($module, $moduleId) {
125 125
         $retValue = "unknown";
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
         return $retValue;
148 148
     }
149 149
 
150
-	/**
151
-	 * Delete reminders invitees multiple.
152
-	 *
153
-	 * @param string $reminderId Related Reminder GUID
154
-	 * @param array $inviteeIds (optional) Exluded Invitees GUIDs, the invitee will not deleted if this argument contains that. Default is empty array.
155
-	 */
150
+    /**
151
+     * Delete reminders invitees multiple.
152
+     *
153
+     * @param string $reminderId Related Reminder GUID
154
+     * @param array $inviteeIds (optional) Exluded Invitees GUIDs, the invitee will not deleted if this argument contains that. Default is empty array.
155
+     */
156 156
     public static function deleteRemindersInviteesMultiple($reminderId, $inviteeIds = array()) {
157 157
         $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list("", "reminders_invitees.reminder_id = '$reminderId'");
158 158
         if($invitees) {
Please login to merge, or discard this patch.
modules/AOP_Case_Updates/Case_Updates.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         $bDate = $b->fetched_row['date_entered'];
160 160
         if($aDate < $bDate){
161 161
             return -1;
162
-        }elseif($aDate > $bDate){
162
+        } elseif($aDate > $bDate){
163 163
             return 1;
164 164
         }
165 165
         return 0;
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
     global $mod_strings;
196 196
     if($update->contact_id){
197 197
         $name = $update->getUpdateContact()->name;
198
-    }elseif($update->assigned_user_id){
198
+    } elseif($update->assigned_user_id){
199 199
         $name = $update->getUpdateUser()->name;
200
-    }else{
200
+    } else{
201 201
         $name = "Unknown";
202 202
     }
203 203
     $html = "<a href='' onclick='toggleCaseUpdate(\"".$update->id."\");return false;'>";
@@ -281,7 +281,9 @@  discard block
 block discarded – undo
281 281
     global $action;
282 282
 
283 283
     //on DetailView only
284
-    if($action != 'DetailView') return;
284
+    if($action != 'DetailView') {
285
+        return;
286
+    }
285 287
 
286 288
     //current record id
287 289
     $record = $_GET['record'];
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 
26
-function display_updates($focus, $field, $value, $view){
26
+function display_updates($focus, $field, $value, $view) {
27 27
     global $mod_strings;
28 28
 
29 29
     $hideImage = SugarThemeRegistry::current()->getImageURL('basic_search.gif');
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 </script>
128 128
 A;
129 129
 
130
-    $updates = $focus->get_linked_beans('aop_case_updates',"AOP_Case_Updates");
131
-    if(!$updates || is_null($focus->id)){
130
+    $updates = $focus->get_linked_beans('aop_case_updates', "AOP_Case_Updates");
131
+    if (!$updates || is_null($focus->id)) {
132 132
         $html .= quick_edit_case_updates($focus);
133 133
         return $html;
134 134
         //return $mod_strings['LBL_NO_CASE_UPDATES'];
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
 EOD;
155 155
 
156 156
 
157
-    usort($updates,function($a,$b){
157
+    usort($updates, function($a, $b) {
158 158
         $aDate = $a->fetched_row['date_entered'];
159 159
         $bDate = $b->fetched_row['date_entered'];
160
-        if($aDate < $bDate){
160
+        if ($aDate < $bDate) {
161 161
             return -1;
162
-        }elseif($aDate > $bDate){
162
+        }elseif ($aDate > $bDate) {
163 163
             return 1;
164 164
         }
165 165
         return 0;
166 166
     });
167 167
 
168
-    foreach($updates as $update){
168
+    foreach ($updates as $update) {
169 169
         $html .= display_single_update($update, $hideImage);
170 170
     }
171 171
     $html .= "</div>";
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 /**
179 179
  * @return mixed|string|void
180 180
  */
181
-function display_update_form(){
181
+function display_update_form() {
182 182
     global $mod_strings, $app_strings;
183
-    $sugar_smarty	= new Sugar_Smarty();
183
+    $sugar_smarty = new Sugar_Smarty();
184 184
     $sugar_smarty->assign('MOD', $mod_strings);
185 185
     $sugar_smarty->assign('APP', $app_strings);
186 186
     return $sugar_smarty->fetch('modules/AOP_Case_Updates/tpl/caseUpdateForm.tpl');
@@ -191,23 +191,23 @@  discard block
 block discarded – undo
191 191
  * @param SugarBean $update
192 192
  * @return string - html to be displayed
193 193
  */
194
-function getUpdateDisplayHead(SugarBean $update){
194
+function getUpdateDisplayHead(SugarBean $update) {
195 195
     global $mod_strings;
196
-    if($update->contact_id){
196
+    if ($update->contact_id) {
197 197
         $name = $update->getUpdateContact()->name;
198
-    }elseif($update->assigned_user_id){
198
+    }elseif ($update->assigned_user_id) {
199 199
         $name = $update->getUpdateUser()->name;
200
-    }else{
200
+    } else {
201 201
         $name = "Unknown";
202 202
     }
203 203
     $html = "<a href='' onclick='toggleCaseUpdate(\"".$update->id."\");return false;'>";
204 204
     $html .= "<img  id='caseUpdate".$update->id."Image' class='caseUpdateImage' src='".SugarThemeRegistry::current()->getImageURL('basic_search.gif')."'>";
205 205
     $html .= "</a>";
206
-    $html .= "<span>".($update->internal ? "<strong>" . $mod_strings['LBL_INTERNAL'] . "</strong> " : '') .$name . " ".$update->date_entered."</span><br>";
207
-    $notes = $update->get_linked_beans('notes','Notes');
208
-    if($notes){
209
-        $html.= $mod_strings['LBL_AOP_CASE_ATTACHMENTS'];
210
-        foreach($notes as $note){
206
+    $html .= "<span>".($update->internal ? "<strong>".$mod_strings['LBL_INTERNAL']."</strong> " : '').$name." ".$update->date_entered."</span><br>";
207
+    $notes = $update->get_linked_beans('notes', 'Notes');
208
+    if ($notes) {
209
+        $html .= $mod_strings['LBL_AOP_CASE_ATTACHMENTS'];
210
+        foreach ($notes as $note) {
211 211
             $html .= "<a href='index.php?module=Notes&action=DetailView&record={$note->id}'>{$note->filename}</a>&nbsp;";
212 212
         }
213 213
     }
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
  * @param AOP_Case_Updates $update
221 221
  * @return string - the html for the update
222 222
  */
223
-function display_single_update(AOP_Case_Updates $update){
223
+function display_single_update(AOP_Case_Updates $update) {
224 224
 
225 225
     /*if assigned user*/
226
-    if($update->assigned_user_id){
226
+    if ($update->assigned_user_id) {
227 227
         /*if internal update*/
228
-        if ($update->internal){
228
+        if ($update->internal) {
229 229
             $html = "<div id='caseStyleInternal'>".getUpdateDisplayHead($update);
230 230
             $html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>";
231 231
             $html .= nl2br(html_entity_decode($update->description));
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     }
244 244
 
245 245
     /*if contact user*/
246
-    if($update->contact_id){
246
+    if ($update->contact_id) {
247 247
         $html = "<div id='extramargin'><div id='caseStyleContact'>".getUpdateDisplayHead($update);
248 248
         $html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>";
249 249
         $html .= nl2br(html_entity_decode($update->description));
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  * @param $case
260 260
  * @return string - html link
261 261
  */
262
-function display_case_attachments($case){
262
+function display_case_attachments($case) {
263 263
     $html = '';
264
-    $notes = $case->get_linked_beans('notes','Notes');
265
-    if($notes){
266
-        foreach($notes as $note){
264
+    $notes = $case->get_linked_beans('notes', 'Notes');
265
+    if ($notes) {
266
+        foreach ($notes as $note) {
267 267
             $html .= "<a href='index.php?module=Notes&action=DetailView&record={$note->id}'>{$note->filename}</a>&nbsp;";
268 268
         }
269 269
     }
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
  *
278 278
  * @return string - the html to be displayed and javascript
279 279
  */
280
-function quick_edit_case_updates($case){
280
+function quick_edit_case_updates($case) {
281 281
     global $action;
282 282
 
283 283
     //on DetailView only
284
-    if($action != 'DetailView') return;
284
+    if ($action != 'DetailView') return;
285 285
 
286 286
     //current record id
287 287
     $record = $_GET['record'];
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
     $roles = $acl->getUserRoles($id);
295 295
 
296 296
     //Return if user cannot edit cases
297
-    if(in_array( "no edit cases", $roles) || $roles === "no edit cases"){
297
+    if (in_array("no edit cases", $roles) || $roles === "no edit cases") {
298 298
 
299 299
         return;
300 300
     }
301 301
     $internalChecked = '';
302
-    if($case->internal){
302
+    if ($case->internal) {
303 303
         $internalChecked = "checked='checked'";
304 304
     }
305 305
     $html = <<< EOD
Please login to merge, or discard this patch.
modules/AOP_Case_Updates/AOPAssignManager.php 2 patches
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,76 +1,76 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class AOPAssignManager{
2
+class AOPAssignManager {
3 3
     private $ieX = false;
4 4
     private $distributionMethod = '';
5 5
     private $aopFallback = true;
6 6
     private $assignableUsers = array();
7 7
 
8
-    function __construct($ieX = false){
8
+    function __construct($ieX = false) {
9 9
         global $sugar_config;
10 10
         $this->ieX = $ieX;
11
-        if($ieX) {
11
+        if ($ieX) {
12 12
             $inboundDistribMethod = $ieX->get_stored_options("distrib_method", "");
13
-        }else{
13
+        } else {
14 14
             $inboundDistribMethod = '';
15 15
         }
16
-        if($this->isAOPFallback($inboundDistribMethod)){
16
+        if ($this->isAOPFallback($inboundDistribMethod)) {
17 17
             $this->distributionMethod = $sugar_config['aop']['distribution_method'];
18 18
             $this->aopFallback = true;
19
-        }else{
19
+        } else {
20 20
             $this->distributionMethod = $inboundDistribMethod;
21 21
             $this->aopFallback = false;
22 22
         }
23 23
         $this->assignableUsers = $this->getAssignableUsers();
24 24
     }
25 25
 
26
-    private function isAOPFallback($distribMethod){
26
+    private function isAOPFallback($distribMethod) {
27 27
         return empty($distribMethod) || $distribMethod == 'AOPDefault';
28 28
     }
29 29
 
30
-    private function getDistributionOptions(){
30
+    private function getDistributionOptions() {
31 31
         global $sugar_config;
32
-        if($this->aopFallback){
32
+        if ($this->aopFallback) {
33 33
             return $sugar_config['aop']['distribution_options'];
34
-        }else{
34
+        } else {
35 35
             return $this->ieX->get_stored_options("distribution_options", '');
36 36
         }
37 37
     }
38 38
 
39
-    private function getRoleUsers($roleId){
39
+    private function getRoleUsers($roleId) {
40 40
         require_once('modules/ACLRoles/ACLRole.php');
41 41
         $role = new ACLRole();
42 42
         $role->retrieve($roleId);
43
-        $role_users = $role->get_linked_beans( 'users','User');
43
+        $role_users = $role->get_linked_beans('users', 'User');
44 44
         $r_users = array();
45
-        foreach($role_users as $role_user){
45
+        foreach ($role_users as $role_user) {
46 46
             $r_users[$role_user->id] = $role_user->name;
47 47
         }
48 48
         return $r_users;
49 49
     }
50 50
 
51
-    private function getAssignableUsers(){
52
-        if($this->distributionMethod == 'singleUser'){
51
+    private function getAssignableUsers() {
52
+        if ($this->distributionMethod == 'singleUser') {
53 53
             return array();
54 54
         }
55 55
         $distributionOptions = $this->getDistributionOptions();
56 56
 
57
-        if(empty($distributionOptions)){
57
+        if (empty($distributionOptions)) {
58 58
             return array();
59 59
         }
60
-        switch($distributionOptions[0]) {
60
+        switch ($distributionOptions[0]) {
61 61
             Case 'security_group':
62
-                if(file_exists('modules/SecurityGroups/SecurityGroup.php')){
62
+                if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
63 63
                     require_once('modules/SecurityGroups/SecurityGroup.php');
64 64
                     $security_group = new SecurityGroup();
65 65
                     $security_group->retrieve($distributionOptions[1]);
66
-                    $group_users = $security_group->get_linked_beans( 'users','User');
66
+                    $group_users = $security_group->get_linked_beans('users', 'User');
67 67
                     $users = array();
68 68
                     $r_users = array();
69
-                    if($distributionOptions[2] != ''){
69
+                    if ($distributionOptions[2] != '') {
70 70
                         $r_users = $this->getRoleUsers($distributionOptions[2]);
71 71
                     }
72
-                    foreach($group_users as $group_user){
73
-                        if($distributionOptions[2] != '' && !isset($r_users[$group_user->id])){
72
+                    foreach ($group_users as $group_user) {
73
+                        if ($distributionOptions[2] != '' && !isset($r_users[$group_user->id])) {
74 74
                             continue;
75 75
                         }
76 76
                         $users[$group_user->id] = $group_user->name;
@@ -90,57 +90,57 @@  discard block
 block discarded – undo
90 90
 
91 91
     }
92 92
 
93
-    private function getSingleUser(){
93
+    private function getSingleUser() {
94 94
         global $sugar_config;
95
-        if($this->singleUser){
95
+        if ($this->singleUser) {
96 96
             return $this->singleUser;
97 97
         }
98
-        if($this->aopFallback){
98
+        if ($this->aopFallback) {
99 99
             $this->singleUser = !empty($sugar_config['aop']['distribution_user_id']) ? $sugar_config['aop']['distribution_user_id'] : '';
100
-        }else{
100
+        } else {
101 101
             $this->singleUser = $this->ieX->get_stored_options("distribution_user_id", "");
102 102
         }
103 103
         return $this->singleUser;
104 104
     }
105 105
 
106
-    private function getLeastBusyCounts(){
107
-        if($this->leastBusyUsers){
106
+    private function getLeastBusyCounts() {
107
+        if ($this->leastBusyUsers) {
108 108
             return $this->leastBusyUsers;
109 109
         }
110 110
         global $db;
111
-        $idIn = implode("','",$db->arrayQuote(array_keys($this->assignableUsers)));
112
-        if($idIn){
111
+        $idIn = implode("','", $db->arrayQuote(array_keys($this->assignableUsers)));
112
+        if ($idIn) {
113 113
             $idIn = "'".$idIn."'";
114 114
         }
115 115
         $res = $db->query("SELECT assigned_user_id, COUNT(*) AS c FROM cases WHERE assigned_user_id IN ({$idIn}) AND deleted = 0 GROUP BY assigned_user_id ORDER BY COUNT(*)");
116 116
         $this->leastBusyUsers = array();
117
-        while($row = $db->fetchByAssoc($res)){
117
+        while ($row = $db->fetchByAssoc($res)) {
118 118
             $this->leastBusyUsers[$row['assigned_user_id']] = $row['c'];
119 119
         }
120 120
         return $this->leastBusyUsers;
121 121
     }
122 122
 
123
-    private function getLeastBusyUser(){
123
+    private function getLeastBusyUser() {
124 124
         $leastBusyCounts = $this->getLeastBusyCounts();
125 125
         asort($leastBusyCounts);
126 126
         reset($leastBusyCounts);
127 127
         return key($leastBusyCounts);
128 128
     }
129 129
 
130
-    private function updateLeastBusy($id){
131
-        if(!$this->leastBusyUsers){
130
+    private function updateLeastBusy($id) {
131
+        if (!$this->leastBusyUsers) {
132 132
             $this->getLeastBusyCounts();
133 133
         }
134 134
         $this->leastBusyUsers[$id] = $this->leastBusyUsers[$id] + 1;
135 135
     }
136 136
 
137
-    private function getRandomUser(){
137
+    private function getRandomUser() {
138 138
         $randKey = array_rand($this->assignableUsers);
139 139
         return $this->assignableUsers[$randKey];
140 140
     }
141 141
 
142
-    function getNextAssignedUser(){
143
-        switch($this->distributionMethod){
142
+    function getNextAssignedUser() {
143
+        switch ($this->distributionMethod) {
144 144
             case 'singleUser':
145 145
                 $userId = $this->getSingleUser();
146 146
                 break;
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
 
164 164
     private function getRoundRobinUser() {
165 165
         $id = empty($this->ieX) ? '' : $this->ieX->id;
166
-        $file = create_cache_directory('modules/AOP_Case_Updates/Users/') . $id . 'lastUser.cache.php';
167
-        if(isset($_SESSION['AOPlastuser'][$id]) && $_SESSION['AOPlastuser'][$id] != '') {
166
+        $file = create_cache_directory('modules/AOP_Case_Updates/Users/').$id.'lastUser.cache.php';
167
+        if (isset($_SESSION['AOPlastuser'][$id]) && $_SESSION['AOPlastuser'][$id] != '') {
168 168
             $lastUserId = $_SESSION['AOPlastuser'][$id];
169 169
         }
170
-        else if (is_file($file)){
170
+        else if (is_file($file)) {
171 171
             include $file;
172
-            if(isset($lastUser['User']) && $lastUser['User'] != '') {
172
+            if (isset($lastUser['User']) && $lastUser['User'] != '') {
173 173
                 $lastUserId = $lastUser['User'];
174 174
             }
175 175
         }
176 176
         $users = array_keys($this->assignableUsers);
177
-        $lastOffset = array_search($lastUserId,$users);
177
+        $lastOffset = array_search($lastUserId, $users);
178 178
         $newOffset = ($lastOffset + 1) % count($users);
179
-        if(!empty($users[$newOffset])) {
179
+        if (!empty($users[$newOffset])) {
180 180
             return $users[$newOffset];
181 181
         }
182 182
         return reset($users);
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
     private function setLastRoundRobinUser($user_id) {
186 186
         $id = empty($this->ieX) ? '' : $this->ieX->id;
187 187
         $_SESSION['AOPlastuser'][$id] = $user_id;
188
-        $file = create_cache_directory('modules/AOP_Case_Updates/Users/') . $id . 'lastUser.cache.php';
188
+        $file = create_cache_directory('modules/AOP_Case_Updates/Users/').$id.'lastUser.cache.php';
189 189
         $arrayString = var_export_helper(array('User' => $user_id));
190
-        $content =<<<eoq
190
+        $content = <<<eoq
191 191
 <?php
192 192
 	\$lastUser = {$arrayString};
193 193
 ?>
194 194
 eoq;
195
-        if($fh = @sugar_fopen($file, 'w')) {
195
+        if ($fh = @sugar_fopen($file, 'w')) {
196 196
             fputs($fh, $content);
197 197
             fclose($fh);
198 198
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
         $this->ieX = $ieX;
11 11
         if($ieX) {
12 12
             $inboundDistribMethod = $ieX->get_stored_options("distrib_method", "");
13
-        }else{
13
+        } else{
14 14
             $inboundDistribMethod = '';
15 15
         }
16 16
         if($this->isAOPFallback($inboundDistribMethod)){
17 17
             $this->distributionMethod = $sugar_config['aop']['distribution_method'];
18 18
             $this->aopFallback = true;
19
-        }else{
19
+        } else{
20 20
             $this->distributionMethod = $inboundDistribMethod;
21 21
             $this->aopFallback = false;
22 22
         }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         global $sugar_config;
32 32
         if($this->aopFallback){
33 33
             return $sugar_config['aop']['distribution_options'];
34
-        }else{
34
+        } else{
35 35
             return $this->ieX->get_stored_options("distribution_options", '');
36 36
         }
37 37
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         }
98 98
         if($this->aopFallback){
99 99
             $this->singleUser = !empty($sugar_config['aop']['distribution_user_id']) ? $sugar_config['aop']['distribution_user_id'] : '';
100
-        }else{
100
+        } else{
101 101
             $this->singleUser = $this->ieX->get_stored_options("distribution_user_id", "");
102 102
         }
103 103
         return $this->singleUser;
@@ -166,8 +166,7 @@  discard block
 block discarded – undo
166 166
         $file = create_cache_directory('modules/AOP_Case_Updates/Users/') . $id . 'lastUser.cache.php';
167 167
         if(isset($_SESSION['AOPlastuser'][$id]) && $_SESSION['AOPlastuser'][$id] != '') {
168 168
             $lastUserId = $_SESSION['AOPlastuser'][$id];
169
-        }
170
-        else if (is_file($file)){
169
+        } else if (is_file($file)){
171 170
             include $file;
172 171
             if(isset($lastUser['User']) && $lastUser['User'] != '') {
173 172
                 $lastUserId = $lastUser['User'];
Please login to merge, or discard this patch.
modules/SchedulersJobs/field_arrays.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -40,23 +40,23 @@
 block discarded – undo
40 40
 
41 41
 
42 42
 $fields_array['Schedulers_jobs'] = array (
43
-	'column_fields' => array (
44
-		'id',
45
-		'deleted',
46
-		'date_entered',
47
-		'date_modified',
48
-		'job_id',
49
-		'execute_time',
50
-		'status',
51
-	),
52
-	'list_fields' => array (
53
-		'id',
54
-		'job_id',
55
-		'execute_time'
56
-	),
57
-	'required_fields' => array (
58
-		'job_id' => 1,
59
-		'execute_time' => 1
60
-	)
43
+    'column_fields' => array (
44
+        'id',
45
+        'deleted',
46
+        'date_entered',
47
+        'date_modified',
48
+        'job_id',
49
+        'execute_time',
50
+        'status',
51
+    ),
52
+    'list_fields' => array (
53
+        'id',
54
+        'job_id',
55
+        'execute_time'
56
+    ),
57
+    'required_fields' => array (
58
+        'job_id' => 1,
59
+        'execute_time' => 1
60
+    )
61 61
 );
62 62
 ?>
Please login to merge, or discard this patch.
Spacing   +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') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
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.
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 
41 41
 
42
-$fields_array['Schedulers_jobs'] = array (
43
-	'column_fields' => array (
42
+$fields_array['Schedulers_jobs'] = array(
43
+	'column_fields' => array(
44 44
 		'id',
45 45
 		'deleted',
46 46
 		'date_entered',
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 		'execute_time',
50 50
 		'status',
51 51
 	),
52
-	'list_fields' => array (
52
+	'list_fields' => array(
53 53
 		'id',
54 54
 		'job_id',
55 55
 		'execute_time'
56 56
 	),
57
-	'required_fields' => array (
57
+	'required_fields' => array(
58 58
 		'job_id' => 1,
59 59
 		'execute_time' => 1
60 60
 	)
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
modules/SchedulersJobs/SchedulersJob.php 4 patches
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
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.
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     public $requeue; // Requeue on failure?
71 71
     public $retry_count;
72 72
     public $failure_count;
73
-    public $job_delay=0; // Frequency to run it
73
+    public $job_delay = 0; // Frequency to run it
74 74
     public $assigned_user_id; // User under which the task is running
75 75
     public $client; // Client ID that owns this job
76 76
     public $execute_time_db;
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 
79 79
 	// standard SugarBean child attrs
80 80
 	var $table_name		= "job_queue";
81
-	var $object_name		= "SchedulersJob";
81
+	var $object_name = "SchedulersJob";
82 82
 	var $module_dir		= "SchedulersJobs";
83 83
 	var $new_schema		= true;
84 84
 	var $process_save_dates = true;
85 85
 	// related fields
86
-	var $job_name;	// the Scheduler's 'name' field
87
-	var $job;		// the Scheduler's 'job' field
86
+	var $job_name; // the Scheduler's 'name' field
87
+	var $job; // the Scheduler's 'job' field
88 88
 	// object specific attributes
89 89
 	public $user; // User object
90 90
 	var $scheduler; // Scheduler parent
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	function SchedulersJob()
99 99
 	{
100 100
         parent::Basic();
101
-        if(!empty($GLOBALS['sugar_config']['jobs']['min_retry_interval'])) {
101
+        if (!empty($GLOBALS['sugar_config']['jobs']['min_retry_interval'])) {
102 102
             $this->min_interval = $GLOBALS['sugar_config']['jobs']['min_retry_interval'];
103 103
         }
104 104
 	}
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
      *
122 122
 	 * @return string Formatted datetime value
123 123
 	 */
124
-	function handleDateFormat($date='now', $user=null, $user_format=false) {
124
+	function handleDateFormat($date = 'now', $user = null, $user_format = false) {
125 125
 		global $timedate;
126 126
 
127
-		if(!isset($timedate) || empty($timedate))
127
+		if (!isset($timedate) || empty($timedate))
128 128
         {
129 129
 			$timedate = new TimeDate();
130 130
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		// get user for calculation
133 133
 		$user = (empty($user)) ? $this->user : $user;
134 134
 
135
-        if($date == 'now')
135
+        if ($date == 'now')
136 136
         {
137 137
             $dbTime = $timedate->asUser($timedate->getNow(), $user);
138 138
         } else {
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param	$job		String in URI-clean format
153 153
 	 * @param	$timeout	Int value in secs for cURL to timeout. 30 default.
154 154
 	 */
155
-	public function fireUrl($job, $timeout=30)
155
+	public function fireUrl($job, $timeout = 30)
156 156
 	{
157 157
 	// TODO: figure out what error is thrown when no more apache instances can be spun off
158 158
 	    // cURL inits
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 		curl_setopt($ch, CURLOPT_FAILONERROR, true); // silent failure (code >300);
162 162
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // do not follow location(); inits - we always use the current
163 163
 		curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
164
-		curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);  // not thread-safe
164
+		curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); // not thread-safe
165 165
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return into a variable to continue program execution
166 166
 		curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // never times out - bad idea?
167 167
 		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // 5 secs for connect timeout
168
-		curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);  // open brand new conn
168
+		curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); // open brand new conn
169 169
 		curl_setopt($ch, CURLOPT_HEADER, true); // do not return header info with result
170 170
 		curl_setopt($ch, CURLOPT_NOPROGRESS, true); // do not have progress bar
171 171
 		$urlparts = parse_url($job);
172
-		if(empty($urlparts['port'])) {
173
-		    if($urlparts['scheme'] == 'https'){
172
+		if (empty($urlparts['port'])) {
173
+		    if ($urlparts['scheme'] == 'https') {
174 174
 				$urlparts['port'] = 443;
175 175
 			} else {
176 176
 				$urlparts['port'] = 80;
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 
184 184
 		curl_setopt($ch, CURLOPT_NOSIGNAL, true); // ignore any cURL signals to PHP (for multi-threading)
185 185
 		$result = curl_exec($ch);
186
-		$cInfo = curl_getinfo($ch);	//url,content_type,header_size,request_size,filetime,http_code
186
+		$cInfo = curl_getinfo($ch); //url,content_type,header_size,request_size,filetime,http_code
187 187
 									//ssl_verify_result,total_time,namelookup_time,connect_time
188 188
 									//pretransfer_time,size_upload,size_download,speed_download,
189 189
 									//speed_upload,download_content_length,upload_content_length
190 190
 									//starttransfer_time,redirect_time
191
-		if(curl_errno($ch)) {
191
+		if (curl_errno($ch)) {
192 192
 		    $this->errors .= curl_errno($ch)."\n";
193 193
 		}
194 194
 		curl_close($ch);
195 195
 
196
-		if($result !== FALSE && $cInfo['http_code'] < 400) {
196
+		if ($result !== FALSE && $cInfo['http_code'] < 400) {
197 197
 			$GLOBALS['log']->debug("----->Firing was successful: $job");
198 198
 			$GLOBALS['log']->debug('----->WTIH RESULT: '.strip_tags($result).' AND '.strip_tags(print_r($cInfo, true)));
199 199
 			return true;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$temp_array = $this->get_list_view_array();
219 219
 		$temp_array['JOB_NAME'] = $this->job_name;
220
-		$temp_array['JOB']		= $this->job;
220
+		$temp_array['JOB'] = $this->job;
221 221
 
222 222
     	return $temp_array;
223 223
 	}
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
     public function resolveJob($resolution, $message = null)
277 277
     {
278 278
         $GLOBALS['log']->info("Resolving job {$this->id} as $resolution: $message");
279
-        if($resolution == self::JOB_FAILURE) {
279
+        if ($resolution == self::JOB_FAILURE) {
280 280
             $this->failure_count++;
281
-            if($this->requeue && $this->retry_count > 0) {
281
+            if ($this->requeue && $this->retry_count > 0) {
282 282
                 // retry failed job
283 283
                 $this->status = self::JOB_STATUS_QUEUED;
284
-                if($this->job_delay < $this->min_interval) {
284
+                if ($this->job_delay < $this->min_interval) {
285 285
                     $this->job_delay = $this->min_interval;
286 286
                 }
287 287
                 $this->execute_time = $GLOBALS['timedate']->getNow()->modify("+{$this->job_delay} seconds")->asDb();
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         $this->addMessages($message);
300 300
         $this->resolution = $resolution;
301 301
         $this->save();
302
-        if($this->status == self::JOB_STATUS_DONE && $this->resolution == self::JOB_SUCCESS) {
302
+        if ($this->status == self::JOB_STATUS_DONE && $this->resolution == self::JOB_SUCCESS) {
303 303
             $this->updateSchedulerSuccess();
304 304
         }
305 305
         return true;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     protected function updateSchedulerSuccess()
312 312
     {
313
-        if(empty($this->scheduler_id)) {
313
+        if (empty($this->scheduler_id)) {
314 314
             return;
315 315
         }
316 316
         $this->db->query("UPDATE schedulers SET last_run={$this->db->now()} WHERE id=".$this->db->quoted($this->scheduler_id));
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
      */
324 324
     protected function addMessages($message)
325 325
     {
326
-        if(!empty($this->errors)) {
326
+        if (!empty($this->errors)) {
327 327
             $this->message .= $this->errors;
328 328
             $this->errors = '';
329 329
         }
330
-        if(!empty($message)) {
330
+        if (!empty($message)) {
331 331
             $this->message .= "$message\n";
332 332
         }
333 333
     }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
         $this->status = self::JOB_STATUS_QUEUED;
344 344
         $this->addMessages($message);
345 345
         $this->resolution = self::JOB_PARTIAL;
346
-        if(empty($delay)) {
346
+        if (empty($delay)) {
347 347
             $delay = intval($this->job_delay);
348 348
         }
349 349
         $this->execute_time = $GLOBALS['timedate']->getNow()->modify("+$delay seconds")->asDb();
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      */
368 368
     public function unexpectedExit()
369 369
     {
370
-        if(!$this->job_done) {
370
+        if (!$this->job_done) {
371 371
             // Job wasn't properly finished, fail it
372 372
             $this->resolveJob(self::JOB_FAILURE, translate('ERR_FAILED', 'SchedulersJobs'));
373 373
         }
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
     {
384 384
         $job = new self();
385 385
         $job->retrieve($id);
386
-        if(empty($job->id)) {
386
+        if (empty($job->id)) {
387 387
             $GLOBALS['log']->fatal("Job $id not found.");
388 388
             return "Job $id not found.";
389 389
         }
390
-        if($job->status != self::JOB_STATUS_RUNNING) {
390
+        if ($job->status != self::JOB_STATUS_RUNNING) {
391 391
             $GLOBALS['log']->fatal("Job $id is not marked as running.");
392 392
             return "Job $id is not marked as running.";
393 393
         }
394
-        if($job->client != $client) {
394
+        if ($job->client != $client) {
395 395
             $GLOBALS['log']->fatal("Job $id belongs to client {$job->client}, can not run as $client.");
396 396
             return "Job $id belongs to another client, can not run as $client.";
397 397
         }
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
      */
412 412
     public function errorHandler($errno, $errstr, $errfile, $errline)
413 413
     {
414
-        switch($errno)
414
+        switch ($errno)
415 415
         {
416 416
     		case E_USER_WARNING:
417 417
     		case E_COMPILE_WARNING:
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
     {
448 448
         $GLOBALS['current_user'] = $user;
449 449
         // Reset the session
450
-        if(session_id()) {
450
+        if (session_id()) {
451 451
             session_destroy();
452 452
         }
453
-        if(!headers_sent()) {
453
+        if (!headers_sent()) {
454 454
     		session_start();
455 455
             session_regenerate_id();
456 456
         }
457
-        $_SESSION['is_valid_session']= true;
457
+        $_SESSION['is_valid_session'] = true;
458 458
     	$_SESSION['user_id'] = $user->id;
459 459
     	$_SESSION['type'] = 'user';
460 460
     	$_SESSION['authenticated_user_id'] = $user->id;
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
     protected function setJobUser()
468 468
     {
469 469
         // set up the current user and drop session
470
-        if(!empty($this->assigned_user_id)) {
470
+        if (!empty($this->assigned_user_id)) {
471 471
             $this->old_user = $GLOBALS['current_user'];
472
-            if(empty($this->user->id) || $this->assigned_user_id != $this->user->id) {
472
+            if (empty($this->user->id) || $this->assigned_user_id != $this->user->id) {
473 473
                 $this->user = BeanFactory::getBean('Users', $this->assigned_user_id);
474
-                if(empty($this->user->id)) {
474
+                if (empty($this->user->id)) {
475 475
                     $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_NOSUCHUSER', 'SchedulersJobs'), $this->assigned_user_id));
476 476
                     return false;
477 477
                 }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
      */
490 490
     protected function restoreJobUser()
491 491
     {
492
-        if(!empty($this->old_user->id) && $this->old_user->id != $this->user->id) {
492
+        if (!empty($this->old_user->id) && $this->old_user->id != $this->user->id) {
493 493
             $this->sudo($this->old_user);
494 494
         }
495 495
     }
@@ -504,27 +504,27 @@  discard block
 block discarded – undo
504 504
 
505 505
         $this->errors = "";
506 506
         $exJob = explode('::', $this->target, 2);
507
-        if($exJob[0] == 'function') {
507
+        if ($exJob[0] == 'function') {
508 508
             // set up the current user and drop session
509
-            if(!$this->setJobUser()) {
509
+            if (!$this->setJobUser()) {
510 510
                 return false;
511 511
             }
512 512
     		$func = $exJob[1];
513 513
 			$GLOBALS['log']->debug("----->SchedulersJob calling function: $func");
514 514
             set_error_handler(array($this, "errorHandler"), E_ALL & ~E_NOTICE & ~E_STRICT);
515
-			if(!is_callable($func)) {
515
+			if (!is_callable($func)) {
516 516
 			    $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_CALL', 'SchedulersJobs'), $func));
517 517
 			}
518 518
 			$data = array($this);
519
-			if(!empty($this->data)) {
519
+			if (!empty($this->data)) {
520 520
 			    $data[] = $this->data;
521 521
 			}
522 522
             $res = call_user_func_array($func, $data);
523 523
             restore_error_handler();
524 524
             $this->restoreJobUser();
525
-			if($this->status == self::JOB_STATUS_RUNNING) {
525
+			if ($this->status == self::JOB_STATUS_RUNNING) {
526 526
 			    // nobody updated the status yet - job function could do that
527
-    			if($res) {
527
+    			if ($res) {
528 528
     			    $this->resolveJob(self::JOB_SUCCESS);
529 529
     				return true;
530 530
     			} else {
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
 			} else {
535 535
 			    return $this->resolution != self::JOB_FAILURE;
536 536
 			}
537
-		} elseif($exJob[0] == 'url') {
538
-			if(function_exists('curl_init')) {
537
+		} elseif ($exJob[0] == 'url') {
538
+			if (function_exists('curl_init')) {
539 539
 				$GLOBALS['log']->debug('----->SchedulersJob firing URL job: '.$exJob[1]);
540 540
                 set_error_handler(array($this, "errorHandler"), E_ALL & ~E_NOTICE & ~E_STRICT);
541
-				if($this->fireUrl($exJob[1])) {
541
+				if ($this->fireUrl($exJob[1])) {
542 542
                     restore_error_handler();
543 543
                     $this->resolveJob(self::JOB_SUCCESS);
544 544
 					return true;
@@ -552,10 +552,10 @@  discard block
 block discarded – undo
552 552
 			}
553 553
 		} elseif ($exJob[0] == 'class') {
554 554
             $tmpJob = new $exJob[1]();
555
-            if($tmpJob instanceof RunnableSchedulerJob)
555
+            if ($tmpJob instanceof RunnableSchedulerJob)
556 556
             {
557 557
                 // set up the current user and drop session
558
-                if(!$this->setJobUser()) {
558
+                if (!$this->setJobUser()) {
559 559
                     return false;
560 560
                 }
561 561
                 $tmpJob->setJob($this);
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -573,12 +575,10 @@  discard block
 block discarded – undo
573 575
                 } else {
574 576
                     return $this->resolution != self::JOB_FAILURE;
575 577
                 }
576
-            }
577
-            else {
578
+            } else {
578 579
                 $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_JOBTYPE', 'SchedulersJobs'), strip_tags($this->target)));
579 580
             }
580
-        }
581
-        else {
581
+        } else {
582 582
 		    $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_JOBTYPE', 'SchedulersJobs'), strip_tags($this->target)));
583 583
 		}
584 584
 		return false;
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -356,6 +356,7 @@  discard block
 block discarded – undo
356 356
     /**
357 357
      * Delete a job
358 358
      * @see SugarBean::mark_deleted($id)
359
+     * @param string $id
359 360
      */
360 361
     public function mark_deleted($id)
361 362
     {
@@ -595,12 +596,15 @@  discard block
 block discarded – undo
595 596
     /**
596 597
      * @abstract
597 598
      * @param SchedulersJob $job
599
+     * @return void
598 600
      */
599 601
     public function setJob(SchedulersJob $job);
600 602
 
601 603
     /**
602 604
      * @abstract
603 605
      *
606
+     * @param string $data
607
+     * @return boolean
604 608
      */
605 609
     public function run($data);
606 610
 }
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
     const JOB_FAILURE = 'failure';
56 56
 
57 57
     // schema attributes
58
-	public $id;
59
-	public $name;
60
-	public $deleted;
61
-	public $date_entered;
62
-	public $date_modified;
63
-	public $scheduler_id;
64
-	public $execute_time; // when to execute
58
+    public $id;
59
+    public $name;
60
+    public $deleted;
61
+    public $date_entered;
62
+    public $date_modified;
63
+    public $scheduler_id;
64
+    public $execute_time; // when to execute
65 65
     public $status;
66 66
     public $resolution;
67 67
     public $message;
68
-	public $target; // URL or function name
68
+    public $target; // URL or function name
69 69
     public $data; // Data set
70 70
     public $requeue; // Requeue on failure?
71 71
     public $retry_count;
@@ -76,61 +76,61 @@  discard block
 block discarded – undo
76 76
     public $execute_time_db;
77 77
     public $percent_complete; // how much of the job is done
78 78
 
79
-	// standard SugarBean child attrs
80
-	var $table_name		= "job_queue";
81
-	var $object_name		= "SchedulersJob";
82
-	var $module_dir		= "SchedulersJobs";
83
-	var $new_schema		= true;
84
-	var $process_save_dates = true;
85
-	// related fields
86
-	var $job_name;	// the Scheduler's 'name' field
87
-	var $job;		// the Scheduler's 'job' field
88
-	// object specific attributes
89
-	public $user; // User object
90
-	var $scheduler; // Scheduler parent
91
-	public $min_interval = 30; // minimal interval for job reruns
92
-	protected $job_done = true;
79
+    // standard SugarBean child attrs
80
+    var $table_name		= "job_queue";
81
+    var $object_name		= "SchedulersJob";
82
+    var $module_dir		= "SchedulersJobs";
83
+    var $new_schema		= true;
84
+    var $process_save_dates = true;
85
+    // related fields
86
+    var $job_name;	// the Scheduler's 'name' field
87
+    var $job;		// the Scheduler's 'job' field
88
+    // object specific attributes
89
+    public $user; // User object
90
+    var $scheduler; // Scheduler parent
91
+    public $min_interval = 30; // minimal interval for job reruns
92
+    protected $job_done = true;
93 93
     protected $old_user;
94 94
 
95
-	/**
96
-	 * Job constructor.
97
-	 */
98
-	function __construct()
99
-	{
95
+    /**
96
+     * Job constructor.
97
+     */
98
+    function __construct()
99
+    {
100 100
         parent::__construct();
101 101
         if(!empty($GLOBALS['sugar_config']['jobs']['min_retry_interval'])) {
102 102
             $this->min_interval = $GLOBALS['sugar_config']['jobs']['min_retry_interval'];
103 103
         }
104
-	}
104
+    }
105 105
 
106
-	public function check_date_relationships_load()
107
-	{
106
+    public function check_date_relationships_load()
107
+    {
108 108
         // Hack to work around the mess with dates being auto-converted to user format on retrieve
109
-	    $this->execute_time_db = $this->db->fromConvert($this->execute_time, 'datetime');
110
-	    parent::check_date_relationships_load();
109
+        $this->execute_time_db = $this->db->fromConvert($this->execute_time, 'datetime');
110
+        parent::check_date_relationships_load();
111 111
     }
112
-	/**
112
+    /**
113 113
      * handleDateFormat
114 114
      *
115
-	 * This function handles returning a datetime value.  It allows a user instance to be passed in, but will default to the
115
+     * This function handles returning a datetime value.  It allows a user instance to be passed in, but will default to the
116 116
      * user member variable instance if none is found.
117 117
      *
118
-	 * @param string $date String value of the date to calculate, defaults to 'now'
119
-	 * @param object $user The User instance to use in calculating the time value, if empty, it will default to user member variable
120
-	 * @param boolean $user_format Boolean indicating whether or not to convert to user's time format, defaults to false
118
+     * @param string $date String value of the date to calculate, defaults to 'now'
119
+     * @param object $user The User instance to use in calculating the time value, if empty, it will default to user member variable
120
+     * @param boolean $user_format Boolean indicating whether or not to convert to user's time format, defaults to false
121 121
      *
122
-	 * @return string Formatted datetime value
123
-	 */
124
-	function handleDateFormat($date='now', $user=null, $user_format=false) {
125
-		global $timedate;
122
+     * @return string Formatted datetime value
123
+     */
124
+    function handleDateFormat($date='now', $user=null, $user_format=false) {
125
+        global $timedate;
126 126
 
127
-		if(!isset($timedate) || empty($timedate))
127
+        if(!isset($timedate) || empty($timedate))
128 128
         {
129
-			$timedate = new TimeDate();
130
-		}
129
+            $timedate = new TimeDate();
130
+        }
131 131
 
132
-		// get user for calculation
133
-		$user = (empty($user)) ? $this->user : $user;
132
+        // get user for calculation
133
+        $user = (empty($user)) ? $this->user : $user;
134 134
 
135 135
         if($date == 'now')
136 136
         {
@@ -141,109 +141,109 @@  discard block
 block discarded – undo
141 141
 
142 142
         // if $user_format is set to true then just return as th user's time format, otherwise, return as database format
143 143
         return $user_format ? $dbTime : $timedate->fromUser($dbTime, $user)->asDb();
144
-	}
145
-
146
-
147
-	///////////////////////////////////////////////////////////////////////////
148
-	////	SCHEDULERSJOB HELPER FUNCTIONS
149
-
150
-	/**
151
-	 * This function takes a passed URL and cURLs it to fake multi-threading with another httpd instance
152
-	 * @param	$job		String in URI-clean format
153
-	 * @param	$timeout	Int value in secs for cURL to timeout. 30 default.
154
-	 */
155
-	public function fireUrl($job, $timeout=30)
156
-	{
157
-	// TODO: figure out what error is thrown when no more apache instances can be spun off
158
-	    // cURL inits
159
-		$ch = curl_init();
160
-		curl_setopt($ch, CURLOPT_URL, $job); // set url
161
-		curl_setopt($ch, CURLOPT_FAILONERROR, true); // silent failure (code >300);
162
-		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // do not follow location(); inits - we always use the current
163
-		curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
164
-		curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);  // not thread-safe
165
-		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return into a variable to continue program execution
166
-		curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // never times out - bad idea?
167
-		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // 5 secs for connect timeout
168
-		curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);  // open brand new conn
169
-		curl_setopt($ch, CURLOPT_HEADER, true); // do not return header info with result
170
-		curl_setopt($ch, CURLOPT_NOPROGRESS, true); // do not have progress bar
171
-		$urlparts = parse_url($job);
172
-		if(empty($urlparts['port'])) {
173
-		    if($urlparts['scheme'] == 'https'){
174
-				$urlparts['port'] = 443;
175
-			} else {
176
-				$urlparts['port'] = 80;
177
-			}
178
-		}
179
-		curl_setopt($ch, CURLOPT_PORT, $urlparts['port']); // set port as reported by Server
180
-		//TODO make the below configurable
181
-		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // most customers will not have Certificate Authority account
182
-		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // most customers will not have Certificate Authority account
183
-
184
-		curl_setopt($ch, CURLOPT_NOSIGNAL, true); // ignore any cURL signals to PHP (for multi-threading)
185
-		$result = curl_exec($ch);
186
-		$cInfo = curl_getinfo($ch);	//url,content_type,header_size,request_size,filetime,http_code
187
-									//ssl_verify_result,total_time,namelookup_time,connect_time
188
-									//pretransfer_time,size_upload,size_download,speed_download,
189
-									//speed_upload,download_content_length,upload_content_length
190
-									//starttransfer_time,redirect_time
191
-		if(curl_errno($ch)) {
192
-		    $this->errors .= curl_errno($ch)."\n";
193
-		}
194
-		curl_close($ch);
195
-
196
-		if($result !== FALSE && $cInfo['http_code'] < 400) {
197
-			$GLOBALS['log']->debug("----->Firing was successful: $job");
198
-			$GLOBALS['log']->debug('----->WTIH RESULT: '.strip_tags($result).' AND '.strip_tags(print_r($cInfo, true)));
199
-			return true;
200
-		} else {
201
-			$GLOBALS['log']->fatal("Job failed: $job");
202
-			return false;
203
-		}
204
-	}
205
-	////	END SCHEDULERSJOB HELPER FUNCTIONS
206
-	///////////////////////////////////////////////////////////////////////////
207
-
208
-
209
-	///////////////////////////////////////////////////////////////////////////
210
-	////	STANDARD SUGARBEAN OVERRIDES
211
-	/**
212
-	 * This function gets DB data and preps it for ListViews
213
-	 */
214
-	function get_list_view_data()
215
-	{
216
-		global $mod_strings;
217
-
218
-		$temp_array = $this->get_list_view_array();
219
-		$temp_array['JOB_NAME'] = $this->job_name;
220
-		$temp_array['JOB']		= $this->job;
221
-
222
-    	return $temp_array;
223
-	}
224
-
225
-	/** method stub for future customization
226
-	 *
227
-	 */
228
-	function fill_in_additional_list_fields()
229
-	{
230
-		$this->fill_in_additional_detail_fields();
231
-	}
232
-
233
-
234
-	/**
235
-	 * Mark this job as failed
236
-	 * @param string $message
237
-	 */
144
+    }
145
+
146
+
147
+    ///////////////////////////////////////////////////////////////////////////
148
+    ////	SCHEDULERSJOB HELPER FUNCTIONS
149
+
150
+    /**
151
+     * This function takes a passed URL and cURLs it to fake multi-threading with another httpd instance
152
+     * @param	$job		String in URI-clean format
153
+     * @param	$timeout	Int value in secs for cURL to timeout. 30 default.
154
+     */
155
+    public function fireUrl($job, $timeout=30)
156
+    {
157
+    // TODO: figure out what error is thrown when no more apache instances can be spun off
158
+        // cURL inits
159
+        $ch = curl_init();
160
+        curl_setopt($ch, CURLOPT_URL, $job); // set url
161
+        curl_setopt($ch, CURLOPT_FAILONERROR, true); // silent failure (code >300);
162
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // do not follow location(); inits - we always use the current
163
+        curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
164
+        curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);  // not thread-safe
165
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return into a variable to continue program execution
166
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // never times out - bad idea?
167
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // 5 secs for connect timeout
168
+        curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);  // open brand new conn
169
+        curl_setopt($ch, CURLOPT_HEADER, true); // do not return header info with result
170
+        curl_setopt($ch, CURLOPT_NOPROGRESS, true); // do not have progress bar
171
+        $urlparts = parse_url($job);
172
+        if(empty($urlparts['port'])) {
173
+            if($urlparts['scheme'] == 'https'){
174
+                $urlparts['port'] = 443;
175
+            } else {
176
+                $urlparts['port'] = 80;
177
+            }
178
+        }
179
+        curl_setopt($ch, CURLOPT_PORT, $urlparts['port']); // set port as reported by Server
180
+        //TODO make the below configurable
181
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // most customers will not have Certificate Authority account
182
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // most customers will not have Certificate Authority account
183
+
184
+        curl_setopt($ch, CURLOPT_NOSIGNAL, true); // ignore any cURL signals to PHP (for multi-threading)
185
+        $result = curl_exec($ch);
186
+        $cInfo = curl_getinfo($ch);	//url,content_type,header_size,request_size,filetime,http_code
187
+                                    //ssl_verify_result,total_time,namelookup_time,connect_time
188
+                                    //pretransfer_time,size_upload,size_download,speed_download,
189
+                                    //speed_upload,download_content_length,upload_content_length
190
+                                    //starttransfer_time,redirect_time
191
+        if(curl_errno($ch)) {
192
+            $this->errors .= curl_errno($ch)."\n";
193
+        }
194
+        curl_close($ch);
195
+
196
+        if($result !== FALSE && $cInfo['http_code'] < 400) {
197
+            $GLOBALS['log']->debug("----->Firing was successful: $job");
198
+            $GLOBALS['log']->debug('----->WTIH RESULT: '.strip_tags($result).' AND '.strip_tags(print_r($cInfo, true)));
199
+            return true;
200
+        } else {
201
+            $GLOBALS['log']->fatal("Job failed: $job");
202
+            return false;
203
+        }
204
+    }
205
+    ////	END SCHEDULERSJOB HELPER FUNCTIONS
206
+    ///////////////////////////////////////////////////////////////////////////
207
+
208
+
209
+    ///////////////////////////////////////////////////////////////////////////
210
+    ////	STANDARD SUGARBEAN OVERRIDES
211
+    /**
212
+     * This function gets DB data and preps it for ListViews
213
+     */
214
+    function get_list_view_data()
215
+    {
216
+        global $mod_strings;
217
+
218
+        $temp_array = $this->get_list_view_array();
219
+        $temp_array['JOB_NAME'] = $this->job_name;
220
+        $temp_array['JOB']		= $this->job;
221
+
222
+        return $temp_array;
223
+    }
224
+
225
+    /** method stub for future customization
226
+     *
227
+     */
228
+    function fill_in_additional_list_fields()
229
+    {
230
+        $this->fill_in_additional_detail_fields();
231
+    }
232
+
233
+
234
+    /**
235
+     * Mark this job as failed
236
+     * @param string $message
237
+     */
238 238
     public function failJob($message = null)
239 239
     {
240 240
         return $this->resolveJob(self::JOB_FAILURE, $message);
241 241
     }
242 242
 
243
-	/**
244
-	 * Mark this job as success
245
-	 * @param string $message
246
-	 */
243
+    /**
244
+     * Mark this job as success
245
+     * @param string $message
246
+     */
247 247
     public function succeedJob($message = null)
248 248
     {
249 249
         return $this->resolveJob(self::JOB_SUCCESS, $message);
@@ -413,28 +413,28 @@  discard block
 block discarded – undo
413 413
     {
414 414
         switch($errno)
415 415
         {
416
-    		case E_USER_WARNING:
417
-    		case E_COMPILE_WARNING:
418
-    		case E_CORE_WARNING:
419
-    		case E_WARNING:
420
-    			$type = "Warning";
421
-    			break;
422
-    		case E_USER_ERROR:
423
-    		case E_COMPILE_ERROR:
424
-    		case E_CORE_ERROR:
425
-    		case E_ERROR:
426
-    			$type = "Fatal Error";
427
-	    		break;
428
-    		case E_PARSE:
429
-    			$type = "Parse Error";
430
-	    		break;
431
-    		case E_RECOVERABLE_ERROR:
432
-    			$type = "Recoverable Error";
433
-	    		break;
434
-		    default:
435
-		        // Ignore errors we don't know about
436
-		        return;
437
-    	}
416
+            case E_USER_WARNING:
417
+            case E_COMPILE_WARNING:
418
+            case E_CORE_WARNING:
419
+            case E_WARNING:
420
+                $type = "Warning";
421
+                break;
422
+            case E_USER_ERROR:
423
+            case E_COMPILE_ERROR:
424
+            case E_CORE_ERROR:
425
+            case E_ERROR:
426
+                $type = "Fatal Error";
427
+                break;
428
+            case E_PARSE:
429
+                $type = "Parse Error";
430
+                break;
431
+            case E_RECOVERABLE_ERROR:
432
+                $type = "Recoverable Error";
433
+                break;
434
+            default:
435
+                // Ignore errors we don't know about
436
+                return;
437
+        }
438 438
         $errstr = strip_tags($errstr);
439 439
         $this->errors .= sprintf(translate('ERR_PHP', 'SchedulersJobs'), $type, $errno, $errstr, $errfile, $errline)."\n";
440 440
     }
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
             session_destroy();
452 452
         }
453 453
         if(!headers_sent()) {
454
-    		session_start();
454
+            session_start();
455 455
             session_regenerate_id();
456 456
         }
457 457
         $_SESSION['is_valid_session']= true;
458
-    	$_SESSION['user_id'] = $user->id;
459
-    	$_SESSION['type'] = 'user';
460
-    	$_SESSION['authenticated_user_id'] = $user->id;
458
+        $_SESSION['user_id'] = $user->id;
459
+        $_SESSION['type'] = 'user';
460
+        $_SESSION['authenticated_user_id'] = $user->id;
461 461
     }
462 462
 
463 463
     /**
@@ -509,48 +509,48 @@  discard block
 block discarded – undo
509 509
             if(!$this->setJobUser()) {
510 510
                 return false;
511 511
             }
512
-    		$func = $exJob[1];
513
-			$GLOBALS['log']->debug("----->SchedulersJob calling function: $func");
512
+            $func = $exJob[1];
513
+            $GLOBALS['log']->debug("----->SchedulersJob calling function: $func");
514 514
             set_error_handler(array($this, "errorHandler"), E_ALL & ~E_NOTICE & ~E_STRICT);
515
-			if(!is_callable($func)) {
516
-			    $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_CALL', 'SchedulersJobs'), $func));
517
-			}
518
-			$data = array($this);
519
-			if(!empty($this->data)) {
520
-			    $data[] = $this->data;
521
-			}
515
+            if(!is_callable($func)) {
516
+                $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_CALL', 'SchedulersJobs'), $func));
517
+            }
518
+            $data = array($this);
519
+            if(!empty($this->data)) {
520
+                $data[] = $this->data;
521
+            }
522 522
             $res = call_user_func_array($func, $data);
523 523
             restore_error_handler();
524 524
             $this->restoreJobUser();
525
-			if($this->status == self::JOB_STATUS_RUNNING) {
526
-			    // nobody updated the status yet - job function could do that
527
-    			if($res) {
528
-    			    $this->resolveJob(self::JOB_SUCCESS);
529
-    				return true;
530
-    			} else {
531
-    			    $this->resolveJob(self::JOB_FAILURE);
532
-    			    return false;
533
-    			}
534
-			} else {
535
-			    return $this->resolution != self::JOB_FAILURE;
536
-			}
537
-		} elseif($exJob[0] == 'url') {
538
-			if(function_exists('curl_init')) {
539
-				$GLOBALS['log']->debug('----->SchedulersJob firing URL job: '.$exJob[1]);
525
+            if($this->status == self::JOB_STATUS_RUNNING) {
526
+                // nobody updated the status yet - job function could do that
527
+                if($res) {
528
+                    $this->resolveJob(self::JOB_SUCCESS);
529
+                    return true;
530
+                } else {
531
+                    $this->resolveJob(self::JOB_FAILURE);
532
+                    return false;
533
+                }
534
+            } else {
535
+                return $this->resolution != self::JOB_FAILURE;
536
+            }
537
+        } elseif($exJob[0] == 'url') {
538
+            if(function_exists('curl_init')) {
539
+                $GLOBALS['log']->debug('----->SchedulersJob firing URL job: '.$exJob[1]);
540 540
                 set_error_handler(array($this, "errorHandler"), E_ALL & ~E_NOTICE & ~E_STRICT);
541
-				if($this->fireUrl($exJob[1])) {
541
+                if($this->fireUrl($exJob[1])) {
542 542
                     restore_error_handler();
543 543
                     $this->resolveJob(self::JOB_SUCCESS);
544
-					return true;
545
-				} else {
544
+                    return true;
545
+                } else {
546 546
                     restore_error_handler();
547
-				    $this->resolveJob(self::JOB_FAILURE);
548
-					return false;
549
-				}
550
-			} else {
551
-			    $this->resolveJob(self::JOB_FAILURE, translate('ERR_CURL', 'SchedulersJobs'));
552
-			}
553
-		} elseif ($exJob[0] == 'class') {
547
+                    $this->resolveJob(self::JOB_FAILURE);
548
+                    return false;
549
+                }
550
+            } else {
551
+                $this->resolveJob(self::JOB_FAILURE, translate('ERR_CURL', 'SchedulersJobs'));
552
+            }
553
+        } elseif ($exJob[0] == 'class') {
554 554
             $tmpJob = new $exJob[1]();
555 555
             if($tmpJob instanceof RunnableSchedulerJob)
556 556
             {
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
             }
580 580
         }
581 581
         else {
582
-		    $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_JOBTYPE', 'SchedulersJobs'), strip_tags($this->target)));
583
-		}
584
-		return false;
582
+            $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_JOBTYPE', 'SchedulersJobs'), strip_tags($this->target)));
583
+        }
584
+        return false;
585 585
     }
586 586
 
587 587
 }  // end class Job
Please login to merge, or discard this patch.
modules/Import/ImportFieldSanitize.php 3 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 /*********************************************************************************
5 5
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -87,24 +87,24 @@  discard block
 block discarded – undo
87 87
     {
88 88
         static $sfh;
89 89
         
90
-        if(!isset($sfh)) {
90
+        if (!isset($sfh)) {
91 91
             require_once('include/SugarFields/SugarFieldHandler.php');
92 92
             $sfh = new SugarFieldHandler();
93 93
         }
94 94
         $value = $params[0];
95 95
         $vardef = $params[1];
96
-        if ( isset($params[2]) )
96
+        if (isset($params[2]))
97 97
             $focus = $params[2];
98 98
         else
99 99
             $focus = null;
100
-        if ( $name == 'relate' && !empty($params[3]) )
100
+        if ($name == 'relate' && !empty($params[3]))
101 101
             $this->addRelatedBean = true;
102 102
         else
103 103
             $this->addRelatedBean = false;
104 104
         
105 105
         $field = $sfh->getSugarField(ucfirst($name));
106
-        if ( $field instanceOf SugarFieldBase ) {
107
-            $value = $field->importSanitize($value,$vardef,$focus,$this);
106
+        if ($field instanceOf SugarFieldBase) {
107
+            $value = $field->importSanitize($value, $vardef, $focus, $this);
108 108
         }
109 109
         
110 110
         return $value;
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 
129 129
         $format = $this->dateformat;
130 130
 
131
-        if ( !$timedate->check_matching_format($value, $format) )
131
+        if (!$timedate->check_matching_format($value, $format))
132 132
             return false;
133 133
 
134
-        if ( !$this->isValidTimeDate($value, $format) )
134
+        if (!$this->isValidTimeDate($value, $format))
135 135
             return false;
136 136
 
137 137
         $value = $timedate->swap_formats(
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
         // cache $sea instance
157 157
         static $sea;
158 158
         
159
-        if ( !($sea instanceof SugarEmailAddress) ) {
159
+        if (!($sea instanceof SugarEmailAddress)) {
160 160
             $sea = new SugarEmailAddress;
161 161
         }
162 162
         
163
-        if ( !empty($value) && !preg_match($sea->regex,$value) ) {
163
+        if (!empty($value) && !preg_match($sea->regex, $value)) {
164 164
             return false;
165 165
         }
166 166
 
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
         static $focus_user;
185 185
 
186 186
         // cache this object since we'll be reusing it a bunch
187
-        if ( !($focus_user instanceof User) ) {
187
+        if (!($focus_user instanceof User)) {
188 188
 
189 189
             $focus_user = new User();
190 190
         }
191 191
 
192 192
 
193
-        if ( !empty($value) && strtolower($value) != "all" ) {
194
-            $theList   = explode(",",$value);
193
+        if (!empty($value) && strtolower($value) != "all") {
194
+            $theList   = explode(",", $value);
195 195
             $isValid   = true;
196 196
             $bad_names = array();
197 197
             foreach ($theList as $eachItem) {
198
-                if ( $focus_user->retrieve_user_id($eachItem)
198
+                if ($focus_user->retrieve_user_id($eachItem)
199 199
                         || $focus_user->retrieve($eachItem)
200 200
                 ) {
201 201
                     // all good
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                     continue;
207 207
                 }
208 208
             }
209
-            if(!$isValid) {
209
+            if (!$isValid) {
210 210
                 return false;
211 211
             }
212 212
         }
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
 
233 233
         $format = $this->timeformat;
234 234
 
235
-        if ( !$timedate->check_matching_format($value, $format) )
235
+        if (!$timedate->check_matching_format($value, $format))
236 236
             return false;
237 237
 
238
-        if ( !$this->isValidTimeDate($value, $format) )
238
+        if (!$this->isValidTimeDate($value, $format))
239 239
             return false;
240 240
 
241 241
         $value = $timedate->swap_formats(
@@ -266,46 +266,46 @@  discard block
 block discarded – undo
266 266
         $reg = $timedate->get_regular_expression($format);
267 267
         preg_match('@'.$reg['format'].'@', $value, $dateparts);
268 268
 
269
-        if ( empty($dateparts) )
269
+        if (empty($dateparts))
270 270
             return false;
271
-        if ( isset($reg['positions']['a'])
272
-                && !in_array($dateparts[$reg['positions']['a']], array('am','pm')) )
271
+        if (isset($reg['positions']['a'])
272
+                && !in_array($dateparts[$reg['positions']['a']], array('am', 'pm')))
273 273
             return false;
274
-        if ( isset($reg['positions']['A'])
275
-                && !in_array($dateparts[$reg['positions']['A']], array('AM','PM')) )
274
+        if (isset($reg['positions']['A'])
275
+                && !in_array($dateparts[$reg['positions']['A']], array('AM', 'PM')))
276 276
             return false;
277
-        if ( isset($reg['positions']['h']) && (
277
+        if (isset($reg['positions']['h']) && (
278 278
                 !is_numeric($dateparts[$reg['positions']['h']])
279 279
                 || $dateparts[$reg['positions']['h']] < 1
280
-                || $dateparts[$reg['positions']['h']] > 12 ) )
280
+                || $dateparts[$reg['positions']['h']] > 12 ))
281 281
             return false;
282
-        if ( isset($reg['positions']['H']) && (
282
+        if (isset($reg['positions']['H']) && (
283 283
                 !is_numeric($dateparts[$reg['positions']['H']])
284 284
                 || $dateparts[$reg['positions']['H']] < 0
285
-                || $dateparts[$reg['positions']['H']] > 23 ) )
285
+                || $dateparts[$reg['positions']['H']] > 23 ))
286 286
             return false;
287
-        if ( isset($reg['positions']['i']) && (
287
+        if (isset($reg['positions']['i']) && (
288 288
                 !is_numeric($dateparts[$reg['positions']['i']])
289 289
                 || $dateparts[$reg['positions']['i']] < 0
290
-                || $dateparts[$reg['positions']['i']] > 59 ) )
290
+                || $dateparts[$reg['positions']['i']] > 59 ))
291 291
             return false;
292
-        if ( isset($reg['positions']['s']) && (
292
+        if (isset($reg['positions']['s']) && (
293 293
                 !is_numeric($dateparts[$reg['positions']['s']])
294 294
                 || $dateparts[$reg['positions']['s']] < 0
295
-                || $dateparts[$reg['positions']['s']] > 59 ) )
295
+                || $dateparts[$reg['positions']['s']] > 59 ))
296 296
             return false;
297
-        if ( isset($reg['positions']['d']) && (
297
+        if (isset($reg['positions']['d']) && (
298 298
                 !is_numeric($dateparts[$reg['positions']['d']])
299 299
                 || $dateparts[$reg['positions']['d']] < 1
300
-                || $dateparts[$reg['positions']['d']] > 31 ) )
300
+                || $dateparts[$reg['positions']['d']] > 31 ))
301 301
             return false;
302
-        if ( isset($reg['positions']['m']) && (
302
+        if (isset($reg['positions']['m']) && (
303 303
                 !is_numeric($dateparts[$reg['positions']['m']])
304 304
                 || $dateparts[$reg['positions']['m']] < 1
305
-                || $dateparts[$reg['positions']['m']] > 12 ) )
305
+                || $dateparts[$reg['positions']['m']] > 12 ))
306 306
             return false;
307
-        if ( isset($reg['positions']['Y']) &&
308
-                !is_numeric($dateparts[$reg['positions']['Y']]) )
307
+        if (isset($reg['positions']['Y']) &&
308
+                !is_numeric($dateparts[$reg['positions']['Y']]))
309 309
             return false;
310 310
 
311 311
         return true;
Please login to merge, or discard this patch.
Braces   +56 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 
4 6
 /*********************************************************************************
5 7
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -93,14 +95,16 @@  discard block
 block discarded – undo
93 95
         }
94 96
         $value = $params[0];
95 97
         $vardef = $params[1];
96
-        if ( isset($params[2]) )
97
-            $focus = $params[2];
98
-        else
99
-            $focus = null;
100
-        if ( $name == 'relate' && !empty($params[3]) )
101
-            $this->addRelatedBean = true;
102
-        else
103
-            $this->addRelatedBean = false;
98
+        if ( isset($params[2]) ) {
99
+                    $focus = $params[2];
100
+        } else {
101
+                    $focus = null;
102
+        }
103
+        if ( $name == 'relate' && !empty($params[3]) ) {
104
+                    $this->addRelatedBean = true;
105
+        } else {
106
+                    $this->addRelatedBean = false;
107
+        }
104 108
         
105 109
         $field = $sfh->getSugarField(ucfirst($name));
106 110
         if ( $field instanceOf SugarFieldBase ) {
@@ -128,11 +132,13 @@  discard block
 block discarded – undo
128 132
 
129 133
         $format = $this->dateformat;
130 134
 
131
-        if ( !$timedate->check_matching_format($value, $format) )
132
-            return false;
135
+        if ( !$timedate->check_matching_format($value, $format) ) {
136
+                    return false;
137
+        }
133 138
 
134
-        if ( !$this->isValidTimeDate($value, $format) )
135
-            return false;
139
+        if ( !$this->isValidTimeDate($value, $format) ) {
140
+                    return false;
141
+        }
136 142
 
137 143
         $value = $timedate->swap_formats(
138 144
             $value, $format, $timedate->get_date_format());
@@ -199,8 +205,7 @@  discard block
 block discarded – undo
199 205
                         || $focus_user->retrieve($eachItem)
200 206
                 ) {
201 207
                     // all good
202
-                }
203
-                else {
208
+                } else {
204 209
                     $isValid     = false;
205 210
                     $bad_names[] = $eachItem;
206 211
                     continue;
@@ -232,11 +237,13 @@  discard block
 block discarded – undo
232 237
 
233 238
         $format = $this->timeformat;
234 239
 
235
-        if ( !$timedate->check_matching_format($value, $format) )
236
-            return false;
240
+        if ( !$timedate->check_matching_format($value, $format) ) {
241
+                    return false;
242
+        }
237 243
 
238
-        if ( !$this->isValidTimeDate($value, $format) )
239
-            return false;
244
+        if ( !$this->isValidTimeDate($value, $format) ) {
245
+                    return false;
246
+        }
240 247
 
241 248
         $value = $timedate->swap_formats(
242 249
             $value, $format, $timedate->get_time_format());
@@ -266,47 +273,57 @@  discard block
 block discarded – undo
266 273
         $reg = $timedate->get_regular_expression($format);
267 274
         preg_match('@'.$reg['format'].'@', $value, $dateparts);
268 275
 
269
-        if ( empty($dateparts) )
270
-            return false;
276
+        if ( empty($dateparts) ) {
277
+                    return false;
278
+        }
271 279
         if ( isset($reg['positions']['a'])
272
-                && !in_array($dateparts[$reg['positions']['a']], array('am','pm')) )
273
-            return false;
280
+                && !in_array($dateparts[$reg['positions']['a']], array('am','pm')) ) {
281
+                    return false;
282
+        }
274 283
         if ( isset($reg['positions']['A'])
275
-                && !in_array($dateparts[$reg['positions']['A']], array('AM','PM')) )
276
-            return false;
284
+                && !in_array($dateparts[$reg['positions']['A']], array('AM','PM')) ) {
285
+                    return false;
286
+        }
277 287
         if ( isset($reg['positions']['h']) && (
278 288
                 !is_numeric($dateparts[$reg['positions']['h']])
279 289
                 || $dateparts[$reg['positions']['h']] < 1
280
-                || $dateparts[$reg['positions']['h']] > 12 ) )
281
-            return false;
290
+                || $dateparts[$reg['positions']['h']] > 12 ) ) {
291
+                    return false;
292
+        }
282 293
         if ( isset($reg['positions']['H']) && (
283 294
                 !is_numeric($dateparts[$reg['positions']['H']])
284 295
                 || $dateparts[$reg['positions']['H']] < 0
285
-                || $dateparts[$reg['positions']['H']] > 23 ) )
286
-            return false;
296
+                || $dateparts[$reg['positions']['H']] > 23 ) ) {
297
+                    return false;
298
+        }
287 299
         if ( isset($reg['positions']['i']) && (
288 300
                 !is_numeric($dateparts[$reg['positions']['i']])
289 301
                 || $dateparts[$reg['positions']['i']] < 0
290
-                || $dateparts[$reg['positions']['i']] > 59 ) )
291
-            return false;
302
+                || $dateparts[$reg['positions']['i']] > 59 ) ) {
303
+                    return false;
304
+        }
292 305
         if ( isset($reg['positions']['s']) && (
293 306
                 !is_numeric($dateparts[$reg['positions']['s']])
294 307
                 || $dateparts[$reg['positions']['s']] < 0
295
-                || $dateparts[$reg['positions']['s']] > 59 ) )
296
-            return false;
308
+                || $dateparts[$reg['positions']['s']] > 59 ) ) {
309
+                    return false;
310
+        }
297 311
         if ( isset($reg['positions']['d']) && (
298 312
                 !is_numeric($dateparts[$reg['positions']['d']])
299 313
                 || $dateparts[$reg['positions']['d']] < 1
300
-                || $dateparts[$reg['positions']['d']] > 31 ) )
301
-            return false;
314
+                || $dateparts[$reg['positions']['d']] > 31 ) ) {
315
+                    return false;
316
+        }
302 317
         if ( isset($reg['positions']['m']) && (
303 318
                 !is_numeric($dateparts[$reg['positions']['m']])
304 319
                 || $dateparts[$reg['positions']['m']] < 1
305
-                || $dateparts[$reg['positions']['m']] > 12 ) )
306
-            return false;
320
+                || $dateparts[$reg['positions']['m']] > 12 ) ) {
321
+                    return false;
322
+        }
307 323
         if ( isset($reg['positions']['Y']) &&
308
-                !is_numeric($dateparts[$reg['positions']['Y']]) )
309
-            return false;
324
+                !is_numeric($dateparts[$reg['positions']['Y']]) ) {
325
+                    return false;
326
+        }
310 327
 
311 328
         return true;
312 329
     }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -253,7 +253,7 @@
 block discarded – undo
253 253
      *
254 254
      * @param  $value  string
255 255
      * @param  $format string
256
-     * @return string sanitized and validated value on success, bool false on failure
256
+     * @return boolean sanitized and validated value on success, bool false on failure
257 257
      */
258 258
     public function isValidTimeDate(
259 259
         $value,
Please login to merge, or discard this patch.
modules/Import/maps/ImportMapOutlook.php 4 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 
50 50
 class ImportMapOutlook extends ImportMapOther
51 51
 {
52
-	/**
52
+    /**
53 53
      * String identifier for this import
54 54
      */
55 55
     public $name = 'outlook';
56
-	/**
56
+    /**
57 57
      * Field delimiter
58 58
      */
59 59
     public $delimiter = ',';
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * Field enclosure
62 62
      */
63 63
     public $enclosure = '"';
64
-	/**
64
+    /**
65 65
      * Do we have a header?
66 66
      */
67 67
     public $has_header = true;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      * @param  string $module
73 73
      * @return array field mappings
74 74
      */
75
-	public function getMapping(
75
+    public function getMapping(
76 76
         $module
77 77
         )
78 78
     {
Please login to merge, or discard this patch.
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -78,19 +78,19 @@
 block discarded – undo
78 78
     {
79 79
         $return_array = parent::getMapping($module);
80 80
         switch ($module) {
81
-        case 'Contacts':
82
-        case 'Leads':
83
-            return $return_array + array(
84
-                "Job Title"=>"title",
85
-                "Home Country"=>"alt_address_country",
86
-                "E-mail 2 Address"=>"email2",
87
-                );
88
-            break;
89
-        case 'Accounts':
90
-            return $return_array;
91
-            break;
92
-        default:
93
-            return $return_array;
81
+            case 'Contacts':
82
+            case 'Leads':
83
+                return $return_array + array(
84
+                    "Job Title"=>"title",
85
+                    "Home Country"=>"alt_address_country",
86
+                    "E-mail 2 Address"=>"email2",
87
+                    );
88
+                break;
89
+            case 'Accounts':
90
+                return $return_array;
91
+                break;
92
+            default:
93
+                return $return_array;
94 94
         }
95 95
     }
96 96
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
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.
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
modules/Import/maps/ImportMapGoogle.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 class ImportMapGoogle extends ImportMapOther
46 46
 {
47
-	/**
47
+    /**
48 48
      * String identifier for this import
49 49
      */
50 50
     public $name = 'google';
@@ -55,38 +55,38 @@  discard block
 block discarded – undo
55 55
      * @param  string $module
56 56
      * @return array field mappings
57 57
      */
58
-	public function getMapping($module)
58
+    public function getMapping($module)
59 59
     {
60
-         $return_array = array(
61
-             'first_name' => array('sugar_key' => 'first_name', 'sugar_label' => '', 'default_label' => 'Given Name'),
62
-             'last_name' => array('sugar_key' => 'last_name', 'sugar_label' => '', 'default_label' => 'Family Name'),
63
-             'birthday' => array('sugar_key' => 'birthdate', 'sugar_label' => '', 'default_label' => 'Birthday'),
64
-             'title' => array('sugar_key' => 'title', 'sugar_label' => '', 'default_label' => 'Title'),
65
-             'notes' => array('sugar_key' => 'description', 'sugar_label' => '', 'default_label' => 'Notes'),
60
+            $return_array = array(
61
+                'first_name' => array('sugar_key' => 'first_name', 'sugar_label' => '', 'default_label' => 'Given Name'),
62
+                'last_name' => array('sugar_key' => 'last_name', 'sugar_label' => '', 'default_label' => 'Family Name'),
63
+                'birthday' => array('sugar_key' => 'birthdate', 'sugar_label' => '', 'default_label' => 'Birthday'),
64
+                'title' => array('sugar_key' => 'title', 'sugar_label' => '', 'default_label' => 'Title'),
65
+                'notes' => array('sugar_key' => 'description', 'sugar_label' => '', 'default_label' => 'Notes'),
66 66
 
67
-             'alt_address_street' => array('sugar_key' => 'alt_address_street', 'sugar_label' => '', 'default_label' => 'Home Street'),
68
-             'alt_address_postcode' => array('sugar_key' => 'alt_address_postalcode', 'sugar_label' => '', 'default_label' => 'Home Postcode'),
69
-             'alt_address_city' => array('sugar_key' => 'alt_address_city', 'sugar_label' => '', 'default_label' => 'Home City'),
70
-             'alt_address_state' => array('sugar_key' => 'alt_address_state', 'sugar_label' => '', 'default_label' => 'Home State'),
71
-             'alt_address_country' => array('sugar_key' => 'alt_address_country', 'sugar_label' => '', 'default_label' => 'Home Country'),
67
+                'alt_address_street' => array('sugar_key' => 'alt_address_street', 'sugar_label' => '', 'default_label' => 'Home Street'),
68
+                'alt_address_postcode' => array('sugar_key' => 'alt_address_postalcode', 'sugar_label' => '', 'default_label' => 'Home Postcode'),
69
+                'alt_address_city' => array('sugar_key' => 'alt_address_city', 'sugar_label' => '', 'default_label' => 'Home City'),
70
+                'alt_address_state' => array('sugar_key' => 'alt_address_state', 'sugar_label' => '', 'default_label' => 'Home State'),
71
+                'alt_address_country' => array('sugar_key' => 'alt_address_country', 'sugar_label' => '', 'default_label' => 'Home Country'),
72 72
 
73
-             'primary_address_street' => array('sugar_key' => 'primary_address_street', 'sugar_label' => '', 'default_label' => 'Work Street'),
74
-             'primary_address_postcode' => array('sugar_key' => 'primary_address_postalcode', 'sugar_label' => '', 'default_label' => 'Work Postcode'),
75
-             'primary_address_city' => array('sugar_key' => 'primary_address_city', 'sugar_label' => '', 'default_label' => 'Work City'),
76
-             'primary_address_state' => array('sugar_key' => 'primary_address_state', 'sugar_label' => '', 'default_label' => 'Work State'),
77
-             'primary_address_country' => array('sugar_key' => 'primary_address_country', 'sugar_label' => '', 'default_label' => 'Work Country'),
73
+                'primary_address_street' => array('sugar_key' => 'primary_address_street', 'sugar_label' => '', 'default_label' => 'Work Street'),
74
+                'primary_address_postcode' => array('sugar_key' => 'primary_address_postalcode', 'sugar_label' => '', 'default_label' => 'Work Postcode'),
75
+                'primary_address_city' => array('sugar_key' => 'primary_address_city', 'sugar_label' => '', 'default_label' => 'Work City'),
76
+                'primary_address_state' => array('sugar_key' => 'primary_address_state', 'sugar_label' => '', 'default_label' => 'Work State'),
77
+                'primary_address_country' => array('sugar_key' => 'primary_address_country', 'sugar_label' => '', 'default_label' => 'Work Country'),
78 78
 
79
-             'phone_main' => array('sugar_key' => 'phone_other', 'sugar_label' => '', 'default_label' => 'Main Phone'),
80
-             'phone_mobile' => array('sugar_key' => 'phone_mobile', 'sugar_label' => '', 'default_label' => 'Mobile Phone'),
81
-             'phone_home' => array('sugar_key' => 'phone_home', 'sugar_label' => '', 'default_label' => 'Home phone'),
82
-             'phone_work' => array('sugar_key' => 'phone_work', 'sugar_label' => '', 'default_label' => 'Work phone'),
83
-             'phone_fax' => array('sugar_key' => 'phone_fax', 'sugar_label' => '', 'default_label' => 'Fax phone'),
79
+                'phone_main' => array('sugar_key' => 'phone_other', 'sugar_label' => '', 'default_label' => 'Main Phone'),
80
+                'phone_mobile' => array('sugar_key' => 'phone_mobile', 'sugar_label' => '', 'default_label' => 'Mobile Phone'),
81
+                'phone_home' => array('sugar_key' => 'phone_home', 'sugar_label' => '', 'default_label' => 'Home phone'),
82
+                'phone_work' => array('sugar_key' => 'phone_work', 'sugar_label' => '', 'default_label' => 'Work phone'),
83
+                'phone_fax' => array('sugar_key' => 'phone_fax', 'sugar_label' => '', 'default_label' => 'Fax phone'),
84 84
 
85
-             'email1' => array('sugar_key' => 'email1', 'sugar_label' => 'LBL_EMAIL_ADDRESS', 'default_label' => 'Email Address'),
86
-             'email2' => array('sugar_key' => 'email2', 'sugar_label' => 'LBL_OTHER_EMAIL_ADDRESS', 'default_label' => 'Other Email'),
85
+                'email1' => array('sugar_key' => 'email1', 'sugar_label' => 'LBL_EMAIL_ADDRESS', 'default_label' => 'Email Address'),
86
+                'email2' => array('sugar_key' => 'email2', 'sugar_label' => 'LBL_OTHER_EMAIL_ADDRESS', 'default_label' => 'Other Email'),
87 87
 
88
-             'assigned_user_name' => array('sugar_key' => 'assigned_user_name', 'sugar_help_key' => 'LBL_EXTERNAL_ASSIGNED_TOOLTIP', 'sugar_label' => 'LBL_ASSIGNED_TO_NAME', 'default_label' => 'Assigned To'),
89
-             'team_name' => array('sugar_key' => 'team_name', 'sugar_help_key' => 'LBL_EXTERNAL_TEAM_TOOLTIP','sugar_label' => 'LBL_TEAMS', 'default_label' => 'Teams'),
88
+                'assigned_user_name' => array('sugar_key' => 'assigned_user_name', 'sugar_help_key' => 'LBL_EXTERNAL_ASSIGNED_TOOLTIP', 'sugar_label' => 'LBL_ASSIGNED_TO_NAME', 'default_label' => 'Assigned To'),
89
+                'team_name' => array('sugar_key' => 'team_name', 'sugar_help_key' => 'LBL_EXTERNAL_TEAM_TOOLTIP','sugar_label' => 'LBL_TEAMS', 'default_label' => 'Teams'),
90 90
             );
91 91
 
92 92
         if($module == 'Users')
Please login to merge, or discard this patch.
Spacing   +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') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
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.
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
              'email2' => array('sugar_key' => 'email2', 'sugar_label' => 'LBL_OTHER_EMAIL_ADDRESS', 'default_label' => 'Other Email'),
87 87
 
88 88
              'assigned_user_name' => array('sugar_key' => 'assigned_user_name', 'sugar_help_key' => 'LBL_EXTERNAL_ASSIGNED_TOOLTIP', 'sugar_label' => 'LBL_ASSIGNED_TO_NAME', 'default_label' => 'Assigned To'),
89
-             'team_name' => array('sugar_key' => 'team_name', 'sugar_help_key' => 'LBL_EXTERNAL_TEAM_TOOLTIP','sugar_label' => 'LBL_TEAMS', 'default_label' => 'Teams'),
89
+             'team_name' => array('sugar_key' => 'team_name', 'sugar_help_key' => 'LBL_EXTERNAL_TEAM_TOOLTIP', 'sugar_label' => 'LBL_TEAMS', 'default_label' => 'Teams'),
90 90
             );
91 91
 
92
-        if($module == 'Users')
92
+        if ($module == 'Users')
93 93
         {
94
-            $return_array['status'] =  array('sugar_key' => 'status', 'sugar_label' => '', 'default_label' => 'Status');
95
-            $return_array['full_name'] =  array('sugar_key' => 'user_name', 'sugar_label' => '', 'default_label' => 'Full Name');
94
+            $return_array['status'] = array('sugar_key' => 'status', 'sugar_label' => '', 'default_label' => 'Status');
95
+            $return_array['full_name'] = array('sugar_key' => 'user_name', 'sugar_label' => '', 'default_label' => 'Full Name');
96 96
         }
97 97
         return $return_array;
98 98
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
modules/Import/maps/ImportMapSalesforce.php 4 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 
50 50
 class ImportMapSalesforce extends ImportMapOther
51 51
 {
52
-	/**
52
+    /**
53 53
      * String identifier for this import
54 54
      */
55 55
     public $name = 'salesforce';
56
-	/**
56
+    /**
57 57
      * Field delimiter
58 58
      */
59 59
     public $delimiter = ',';
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
      * Field enclosure
62 62
      */
63 63
     public $enclosure = '"';
64
-	/**
64
+    /**
65 65
      * Do we have a header?
66 66
      */
67 67
     public $has_header = true;
68 68
 
69
-	/**
69
+    /**
70 70
      * Gets the default mapping for a module
71 71
      *
72 72
      * @param  string $module
73 73
      * @return array field mappings
74 74
      */
75
-	public function getMapping(
75
+    public function getMapping(
76 76
         $module
77 77
         )
78 78
     {
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
         }
152 152
     }
153 153
 	
154
-	/**
155
-	* @see ImportMapOther::getIgnoredFields()
154
+    /**
155
+     * @see ImportMapOther::getIgnoredFields()
156 156
      */
157
-	public function getIgnoredFields(
158
-		$module
159
-		)
160
-	{
161
-		return array_merge(parent::getIgnoredFields($module),array('id'));
162
-	}
157
+    public function getIgnoredFields(
158
+        $module
159
+        )
160
+    {
161
+        return array_merge(parent::getIgnoredFields($module),array('id'));
162
+    }
163 163
 }
164 164
 
165 165
 
Please login to merge, or discard this patch.
Switch Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -78,76 +78,76 @@
 block discarded – undo
78 78
     {
79 79
         $return_array = parent::getMapping($module);
80 80
         switch ($module) {
81
-        case 'Contacts':
82
-        case 'Leads':
83
-            return $return_array + array(
84
-                "Description"=>"description",
85
-                "Birthdate"=>"birthdate",
86
-                "Lead Source"=>"lead_source",
87
-                "Assistant"=>"assistant",
88
-                "Asst. Phone"=>"assistant_phone",
89
-                "Mailing Street"=>"primary_address_street",
90
-                "Mailing Address Line1"=>"primary_address_street_2",
91
-                "Mailing Address Line2"=>"primary_address_street_3",
92
-                "Mailing Address Line3"=>"primary_address_street_4",
93
-                "Mailing City"=>"primary_address_city",
94
-                "Mailing State"=>"primary_address_state",
95
-                "Mailing Zip/Postal Code"=>"primary_address_postalcode",
96
-                "Mailing Country"=>"primary_address_country",
97
-                "Other Street"=>"alt_address_street",
98
-                "Other Address Line 1"=>"alt_address_street_2",
99
-                "Other Address Line 2"=>"alt_address_street_3",
100
-                "Other Address Line 3"=>"alt_address_street_4",
101
-                "Other City"=>"alt_address_city",
102
-                "Other State"=>"alt_address_state",
103
-                "Other Zip/Postal Code"=>"alt_address_postalcode",
104
-                "Other Country"=>"alt_address_country",
105
-                "Phone"=>"phone_work",
106
-                "Mobile"=>"phone_mobile",
107
-                "Home Phone"=>"phone_home",
108
-                "Other Phone"=>"phone_other",
109
-                "Fax"=>"phone_fax",
110
-                "Email"=>"email1",
111
-                "Email Opt Out"=>"email_opt_out",
112
-                "Do Not Call"=>"do_not_call",
113
-                "Account Name"=>"account_name",
114
-                );
115
-            break;
116
-        case 'Accounts':
117
-            return array(
118
-                "Account Name"=>"name",
119
-                "Annual Revenue"=>"annual_revenue",
120
-                "Type"=>"account_type",
121
-                "Ticker Symbol"=>"ticker_symbol",
122
-                "Rating"=>"rating",
123
-                "Industry"=>"industry",
124
-                "SIC Code"=>"sic_code",
125
-                "Ownership"=>"ownership",
126
-                "Employees"=>"employees",
127
-                "Description"=>"description",
128
-                "Billing Street"=>"billing_address_street",
129
-                "Billing Address Line1"=>"billing_address_street_2",
130
-                "Billing Address Line2"=>"billing_address_street_3",
131
-                "Billing City"=>"billing_address_city",
132
-                "Billing State"=>"billing_address_state",
133
-                "Billing State/Province"=>"billing_address_state",
134
-                "Billing Zip/Postal Code"=>"billing_address_postalcode",
135
-                "Billing Country"=>"billing_address_country",
136
-                "Shipping Street"=>"shipping_address_street",
137
-                "Shipping Address Line1"=>"shipping_address_street_2",
138
-                "Shipping Address Line2"=>"shipping_address_street_3",
139
-                "Shipping City"=>"shipping_address_city",
140
-                "Shipping State"=>"shipping_address_state",
141
-                "Shipping Zip/Postal Code"=>"shipping_address_postalcode",
142
-                "Shipping Country"=>"shipping_address_country",
143
-                "Phone"=>"phone_office",
144
-                "Fax"=>"phone_fax",
145
-                "Website"=>"website",
146
-                "Created Date"=>"date_entered",
147
-                );
148
-            break;
149
-        default:
150
-            return $return_array;
81
+            case 'Contacts':
82
+            case 'Leads':
83
+                return $return_array + array(
84
+                    "Description"=>"description",
85
+                    "Birthdate"=>"birthdate",
86
+                    "Lead Source"=>"lead_source",
87
+                    "Assistant"=>"assistant",
88
+                    "Asst. Phone"=>"assistant_phone",
89
+                    "Mailing Street"=>"primary_address_street",
90
+                    "Mailing Address Line1"=>"primary_address_street_2",
91
+                    "Mailing Address Line2"=>"primary_address_street_3",
92
+                    "Mailing Address Line3"=>"primary_address_street_4",
93
+                    "Mailing City"=>"primary_address_city",
94
+                    "Mailing State"=>"primary_address_state",
95
+                    "Mailing Zip/Postal Code"=>"primary_address_postalcode",
96
+                    "Mailing Country"=>"primary_address_country",
97
+                    "Other Street"=>"alt_address_street",
98
+                    "Other Address Line 1"=>"alt_address_street_2",
99
+                    "Other Address Line 2"=>"alt_address_street_3",
100
+                    "Other Address Line 3"=>"alt_address_street_4",
101
+                    "Other City"=>"alt_address_city",
102
+                    "Other State"=>"alt_address_state",
103
+                    "Other Zip/Postal Code"=>"alt_address_postalcode",
104
+                    "Other Country"=>"alt_address_country",
105
+                    "Phone"=>"phone_work",
106
+                    "Mobile"=>"phone_mobile",
107
+                    "Home Phone"=>"phone_home",
108
+                    "Other Phone"=>"phone_other",
109
+                    "Fax"=>"phone_fax",
110
+                    "Email"=>"email1",
111
+                    "Email Opt Out"=>"email_opt_out",
112
+                    "Do Not Call"=>"do_not_call",
113
+                    "Account Name"=>"account_name",
114
+                    );
115
+                break;
116
+            case 'Accounts':
117
+                return array(
118
+                    "Account Name"=>"name",
119
+                    "Annual Revenue"=>"annual_revenue",
120
+                    "Type"=>"account_type",
121
+                    "Ticker Symbol"=>"ticker_symbol",
122
+                    "Rating"=>"rating",
123
+                    "Industry"=>"industry",
124
+                    "SIC Code"=>"sic_code",
125
+                    "Ownership"=>"ownership",
126
+                    "Employees"=>"employees",
127
+                    "Description"=>"description",
128
+                    "Billing Street"=>"billing_address_street",
129
+                    "Billing Address Line1"=>"billing_address_street_2",
130
+                    "Billing Address Line2"=>"billing_address_street_3",
131
+                    "Billing City"=>"billing_address_city",
132
+                    "Billing State"=>"billing_address_state",
133
+                    "Billing State/Province"=>"billing_address_state",
134
+                    "Billing Zip/Postal Code"=>"billing_address_postalcode",
135
+                    "Billing Country"=>"billing_address_country",
136
+                    "Shipping Street"=>"shipping_address_street",
137
+                    "Shipping Address Line1"=>"shipping_address_street_2",
138
+                    "Shipping Address Line2"=>"shipping_address_street_3",
139
+                    "Shipping City"=>"shipping_address_city",
140
+                    "Shipping State"=>"shipping_address_state",
141
+                    "Shipping Zip/Postal Code"=>"shipping_address_postalcode",
142
+                    "Shipping Country"=>"shipping_address_country",
143
+                    "Phone"=>"phone_office",
144
+                    "Fax"=>"phone_fax",
145
+                    "Website"=>"website",
146
+                    "Created Date"=>"date_entered",
147
+                    );
148
+                break;
149
+            default:
150
+                return $return_array;
151 151
         }
152 152
     }
153 153
 	
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
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.
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		$module
159 159
 		)
160 160
 	{
161
-		return array_merge(parent::getIgnoredFields($module),array('id'));
161
+		return array_merge(parent::getIgnoredFields($module), array('id'));
162 162
 	}
163 163
 }
164 164
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.