Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created
modules/AOW_WorkFlow/AOW_WorkFlow.php 2 patches
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	var $object_name = 'AOW_WorkFlow';
31 31
 	var $table_name = 'aow_workflow';
32 32
 	var $importable = false;
33
-	var $disable_row_level_security = true ;
33
+	var $disable_row_level_security = true;
34 34
 
35 35
 	var $id;
36 36
 	var $name;
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	var $status;
52 52
 	var $run_when;
53 53
 
54
-	public function __construct($init=true){
54
+	public function __construct($init = true) {
55 55
 		parent::__construct();
56
-        if($init){
56
+        if ($init) {
57 57
             $this->load_flow_beans();
58 58
             require_once('modules/AOW_WorkFlow/aow_utils.php');
59 59
         }
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
     /**
63 63
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
64 64
      */
65
-    public function AOW_WorkFlow($init=true){
65
+    public function AOW_WorkFlow($init = true) {
66 66
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
67
-        if(isset($GLOBALS['log'])) {
67
+        if (isset($GLOBALS['log'])) {
68 68
             $GLOBALS['log']->deprecated($deprecatedMessage);
69 69
         }
70 70
         else {
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
         self::__construct($init);
74 74
     }
75 75
 
76
-	function bean_implements($interface){
77
-		switch($interface){
76
+	function bean_implements($interface) {
77
+		switch ($interface) {
78 78
 			case 'ACL': return true;
79 79
 		}
80 80
 		return false;
81 81
 	}
82 82
 
83
-    function save($check_notify = FALSE){
84
-        if (empty($this->id)){
83
+    function save($check_notify = FALSE) {
84
+        if (empty($this->id)) {
85 85
             unset($_POST['aow_conditions_id']);
86 86
             unset($_POST['aow_actions_id']);
87 87
         }
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
         $action->save_lines($_POST, $this, 'aow_actions_');
98 98
     }
99 99
 
100
-    function load_flow_beans(){
100
+    function load_flow_beans() {
101 101
         global $beanList, $app_list_strings;
102 102
 
103 103
         $app_list_strings['aow_moduleList'] = $app_list_strings['moduleList'];
104 104
 
105
-        if(!empty($app_list_strings['aow_moduleList'])){
106
-            foreach($app_list_strings['aow_moduleList'] as $mkey => $mvalue){
107
-                if(!isset($beanList[$mkey]) || str_begin($mkey, 'AOW_')){
105
+        if (!empty($app_list_strings['aow_moduleList'])) {
106
+            foreach ($app_list_strings['aow_moduleList'] as $mkey => $mvalue) {
107
+                if (!isset($beanList[$mkey]) || str_begin($mkey, 'AOW_')) {
108 108
                     unset($app_list_strings['aow_moduleList'][$mkey]);
109 109
                 }
110 110
             }
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     /**
119 119
      * Select and run all active flows
120 120
      */
121
-	function run_flows(){
122
-		$flows = AOW_WorkFlow::get_full_list(''," aow_workflow.status = 'Active'  AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'In_Scheduler' OR aow_workflow.run_when = 'Create') ");
121
+	function run_flows() {
122
+		$flows = AOW_WorkFlow::get_full_list('', " aow_workflow.status = 'Active'  AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'In_Scheduler' OR aow_workflow.run_when = 'Create') ");
123 123
 
124
-        foreach($flows as $flow){
124
+        foreach ($flows as $flow) {
125 125
             $flow->run_flow();
126 126
         }
127 127
         return true;
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
     /**
131 131
      * Retrieve the beans to actioned and run the actions
132 132
      */
133
-    function run_flow(){
133
+    function run_flow() {
134 134
         $beans = $this->get_flow_beans();
135
-        if(!empty($beans)){
135
+        if (!empty($beans)) {
136 136
 
137
-            foreach($beans as $bean){
137
+            foreach ($beans as $bean) {
138 138
                 $bean->retrieve($bean->id);
139 139
                 $this->run_actions($bean);
140 140
             }
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
     /**
145 145
      * Select and run all active flows for the specified bean
146 146
      */
147
-    function run_bean_flows(SugarBean &$bean){
148
-        if(!isset($_REQUEST['module']) || $_REQUEST['module'] != 'Import'){
147
+    function run_bean_flows(SugarBean & $bean) {
148
+        if (!isset($_REQUEST['module']) || $_REQUEST['module'] != 'Import') {
149 149
 
150 150
             $query = "SELECT id FROM aow_workflow WHERE aow_workflow.flow_module = '".$bean->module_dir."' AND aow_workflow.status = 'Active' AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'On_Save' OR aow_workflow.run_when = 'Create') AND aow_workflow.deleted = 0 ";
151 151
 
152 152
             $result = $this->db->query($query, false);
153 153
             $flow = new AOW_WorkFlow();
154
-            while (($row = $bean->db->fetchByAssoc($result)) != null){
154
+            while (($row = $bean->db->fetchByAssoc($result)) != null) {
155 155
                 $flow ->retrieve($row['id']);
156
-                if($flow->check_valid_bean($bean))
156
+                if ($flow->check_valid_bean($bean))
157 157
                     $flow->run_actions($bean, true);
158 158
             }
159 159
         }
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
     /**
164 164
      * Use the condition statements and processed table to build query to retrieve beans to be actioned
165 165
      */
166
-    function get_flow_beans(){
166
+    function get_flow_beans() {
167 167
         global $beanList;
168 168
 
169
-        if($beanList[$this->flow_module]){
169
+        if ($beanList[$this->flow_module]) {
170 170
             $module = new $beanList[$this->flow_module]();
171 171
 
172 172
             $query = '';
@@ -175,22 +175,22 @@  discard block
 block discarded – undo
175 175
             $query_array['select'][] = $module->table_name.".id AS id";
176 176
             $query_array = $this->build_flow_query_where($query_array);
177 177
 
178
-            if(!empty($query_array)){
179
-                foreach ($query_array['select'] as $select){
180
-                    $query .=  ($query == '' ? 'SELECT ' : ', ').$select;
178
+            if (!empty($query_array)) {
179
+                foreach ($query_array['select'] as $select) {
180
+                    $query .= ($query == '' ? 'SELECT ' : ', ').$select;
181 181
                 }
182 182
 
183 183
                 $query .= ' FROM '.$module->table_name.' ';
184 184
 
185
-                if(isset($query_array['join'])){
186
-                    foreach ($query_array['join'] as $join){
185
+                if (isset($query_array['join'])) {
186
+                    foreach ($query_array['join'] as $join) {
187 187
                         $query .= $join;
188 188
                     }
189 189
                 }
190
-                if(isset($query_array['where'])){
190
+                if (isset($query_array['where'])) {
191 191
                     $query_where = '';
192
-                    foreach ($query_array['where'] as $where){
193
-                        $query_where .=  ($query_where == '' ? 'WHERE ' : ' AND ').$where;
192
+                    foreach ($query_array['where'] as $where) {
193
+                        $query_where .= ($query_where == '' ? 'WHERE ' : ' AND ').$where;
194 194
                     }
195 195
                     $query .= ' '.$query_where;
196 196
                 }
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
         return null;
203 203
     }
204 204
 
205
-    function build_flow_query_join($name, SugarBean $module, $type, $query = array()){
205
+    function build_flow_query_join($name, SugarBean $module, $type, $query = array()) {
206 206
 
207
-        if(!isset($query['join'][$name])){
207
+        if (!isset($query['join'][$name])) {
208 208
 
209
-            switch ($type){
209
+            switch ($type) {
210 210
                 case 'custom':
211
-                    $query['join'][$name] = 'LEFT JOIN '.$module->get_custom_table_name().' '.$name.' ON '.$module->table_name.'.id = '. $name.'.id_c ';
211
+                    $query['join'][$name] = 'LEFT JOIN '.$module->get_custom_table_name().' '.$name.' ON '.$module->table_name.'.id = '.$name.'.id_c ';
212 212
                     break;
213 213
 
214 214
                 case 'relationship':
215
-                    if($module->load_relationship($name)){
215
+                    if ($module->load_relationship($name)) {
216 216
                         $params['join_type'] = 'LEFT JOIN';
217 217
                         $params['join_table_alias'] = $name;
218 218
                         $join = $module->$name->getJoin($params, true);
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
         return $query;
231 231
     }
232 232
 
233
-    function build_flow_query_where($query = array()){
233
+    function build_flow_query_where($query = array()) {
234 234
         global $beanList;
235 235
 
236
-        if($beanList[$this->flow_module]){
236
+        if ($beanList[$this->flow_module]) {
237 237
             $module = new $beanList[$this->flow_module]();
238 238
 
239 239
             $sql = "SELECT id FROM aow_conditions WHERE aow_workflow_id = '".$this->id."' AND deleted = 0 ORDER BY condition_order ASC";
@@ -242,26 +242,26 @@  discard block
 block discarded – undo
242 242
             while ($row = $this->db->fetchByAssoc($result)) {
243 243
                 $condition = new AOW_Condition();
244 244
                 $condition->retrieve($row['id']);
245
-                $query = $this->build_query_where($condition,$module,$query);
246
-                if(empty($query)){
245
+                $query = $this->build_query_where($condition, $module, $query);
246
+                if (empty($query)) {
247 247
                     return $query;
248 248
                 }
249 249
             }
250
-            if($this->flow_run_on){
251
-                switch($this->flow_run_on){
250
+            if ($this->flow_run_on) {
251
+                switch ($this->flow_run_on) {
252 252
 
253 253
                     case'New_Records':
254
-                        $query['where'][] = $module->table_name . '.' . 'date_entered' . ' > ' . "'" .$this->date_entered."'";
254
+                        $query['where'][] = $module->table_name.'.'.'date_entered'.' > '."'".$this->date_entered."'";
255 255
                         Break;
256 256
 
257 257
                     case'Modified_Records':
258
-                        $query['where'][] = $module->table_name . '.' . 'date_modified' . ' > ' . "'" .$this->date_entered."'" . ' AND ' . $module->table_name . '.' . 'date_entered' . ' <> ' . $module->table_name . '.' . 'date_modified';
258
+                        $query['where'][] = $module->table_name.'.'.'date_modified'.' > '."'".$this->date_entered."'".' AND '.$module->table_name.'.'.'date_entered'.' <> '.$module->table_name.'.'.'date_modified';
259 259
                         Break;
260 260
 
261 261
                 }
262 262
             }
263 263
 
264
-            if(!$this->multiple_runs){
264
+            if (!$this->multiple_runs) {
265 265
                 $query['where'][] .= "NOT EXISTS (SELECT * FROM aow_processed WHERE aow_processed.aow_workflow_id='".$this->id."' AND aow_processed.parent_id=".$module->table_name.".id AND aow_processed.status = 'Complete' AND aow_processed.deleted = 0)";
266 266
             }
267 267
 
@@ -271,48 +271,48 @@  discard block
 block discarded – undo
271 271
         return $query;
272 272
     }
273 273
 
274
-    function build_query_where(AOW_Condition $condition, $module, $query = array()){
274
+    function build_query_where(AOW_Condition $condition, $module, $query = array()) {
275 275
         global $beanList, $app_list_strings, $sugar_config, $timedate;
276 276
         $path = unserialize(base64_decode($condition->module_path));
277 277
 
278 278
         $condition_module = $module;
279 279
         $table_alias = $condition_module->table_name;
280
-        if(isset($path[0]) && $path[0] != $module->module_dir){
281
-            foreach($path as $rel){
280
+        if (isset($path[0]) && $path[0] != $module->module_dir) {
281
+            foreach ($path as $rel) {
282 282
                 $query = $this->build_flow_query_join($rel, $condition_module, 'relationship', $query);
283
-                $condition_module = new $beanList[getRelatedModule($condition_module->module_dir,$rel)];
283
+                $condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)];
284 284
                 $table_alias = $rel;
285 285
             }
286 286
         }
287 287
 
288
-        if(isset($app_list_strings['aow_sql_operator_list'][$condition->operator])){
288
+        if (isset($app_list_strings['aow_sql_operator_list'][$condition->operator])) {
289 289
             $where_set = false;
290 290
 
291 291
             $data = $condition_module->field_defs[$condition->field];
292 292
 
293
-            if($data['type'] == 'relate' && isset($data['id_name'])) {
293
+            if ($data['type'] == 'relate' && isset($data['id_name'])) {
294 294
                 $condition->field = $data['id_name'];
295 295
             }
296
-            if(  (isset($data['source']) && $data['source'] == 'custom_fields')) {
296
+            if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
297 297
                 $field = $table_alias.'_cstm.'.$condition->field;
298 298
                 $query = $this->build_flow_query_join($table_alias.'_cstm', $condition_module, 'custom', $query);
299 299
             } else {
300 300
                 $field = $table_alias.'.'.$condition->field;
301 301
             }
302 302
 
303
-            if($condition->operator == 'is_null'){
303
+            if ($condition->operator == 'is_null') {
304 304
                 $query['where'][] = '('.$field.' '.$app_list_strings['aow_sql_operator_list'][$condition->operator].' OR '.$field.' '.$app_list_strings['aow_sql_operator_list']['Equal_To']." '')";
305 305
                 return $query;
306 306
             }
307 307
 
308
-            switch($condition->value_type) {
308
+            switch ($condition->value_type) {
309 309
                 case 'Field':
310 310
                     $data = $module->field_defs[$condition->value];
311 311
 
312
-                    if($data['type'] == 'relate' && isset($data['id_name'])) {
312
+                    if ($data['type'] == 'relate' && isset($data['id_name'])) {
313 313
                         $condition->value = $data['id_name'];
314 314
                     }
315
-                    if(  (isset($data['source']) && $data['source'] == 'custom_fields')) {
315
+                    if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
316 316
                         $value = $module->table_name.'_cstm.'.$condition->value;
317 317
                         $query = $this->build_flow_query_join($module->table_name.'_cstm', $module, 'custom', $query);
318 318
                     } else {
@@ -323,24 +323,24 @@  discard block
 block discarded – undo
323 323
                     //can't detect in scheduler so return
324 324
                     return array();
325 325
                 case 'Date':
326
-                    $params =  unserialize(base64_decode($condition->value));
327
-                    if($params[0] == 'now'){
328
-                        if($sugar_config['dbconfig']['db_type'] == 'mssql'){
329
-                            $value  = 'GetUTCDate()';
326
+                    $params = unserialize(base64_decode($condition->value));
327
+                    if ($params[0] == 'now') {
328
+                        if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
329
+                            $value = 'GetUTCDate()';
330 330
                         } else {
331 331
                             $value = 'UTC_TIMESTAMP()';
332 332
                         }
333
-                    } else if($params[0] == 'today'){
334
-                        if($sugar_config['dbconfig']['db_type'] == 'mssql'){
333
+                    } else if ($params[0] == 'today') {
334
+                        if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
335 335
                             //$field =
336
-                            $value  = 'CAST(GETDATE() AS DATE)';
336
+                            $value = 'CAST(GETDATE() AS DATE)';
337 337
                         } else {
338 338
                             $field = 'DATE('.$field.')';
339 339
                             $value = 'Curdate()';
340 340
                         }
341 341
                     } else {
342 342
                         $data = $module->field_defs[$params[0]];
343
-                        if(  (isset($data['source']) && $data['source'] == 'custom_fields')) {
343
+                        if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
344 344
                             $value = $module->table_name.'_cstm.'.$params[0];
345 345
                             $query = $this->build_flow_query_join($module->table_name.'_cstm', $module, 'custom', $query);
346 346
                         } else {
@@ -348,27 +348,27 @@  discard block
 block discarded – undo
348 348
                         }
349 349
                     }
350 350
 
351
-                    if($params[1] != 'now'){
352
-                        switch($params[3]) {
351
+                    if ($params[1] != 'now') {
352
+                        switch ($params[3]) {
353 353
                             case 'business_hours';
354
-                                if(file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php') && $params[0] == 'now'){
354
+                                if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php') && $params[0] == 'now') {
355 355
                                     require_once('modules/AOBH_BusinessHours/AOBH_BusinessHours.php');
356 356
 
357 357
                                     $businessHours = new AOBH_BusinessHours();
358 358
 
359 359
                                     $amount = $params[2];
360 360
 
361
-                                    if($params[1] != "plus"){
362
-                                        $amount = 0-$amount;
361
+                                    if ($params[1] != "plus") {
362
+                                        $amount = 0 - $amount;
363 363
                                     }
364 364
                                     $value = $businessHours->addBusinessHours($amount);
365
-                                    $value = "'".$timedate->asDb( $value )."'";
365
+                                    $value = "'".$timedate->asDb($value)."'";
366 366
                                     break;
367 367
                                 }
368 368
                                 //No business hours module found - fall through.
369 369
                                 $params[3] = 'hour';
370 370
                             default:
371
-                                if($sugar_config['dbconfig']['db_type'] == 'mssql'){
371
+                                if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
372 372
                                     $value = "DATEADD(".$params[3].",  ".$app_list_strings['aow_date_operator'][$params[1]]." $params[2], $value)";
373 373
                                 } else {
374 374
                                     $value = "DATE_ADD($value, INTERVAL ".$app_list_strings['aow_date_operator'][$params[1]]." $params[2] ".$params[3].")";
@@ -380,20 +380,20 @@  discard block
 block discarded – undo
380 380
 
381 381
                 case 'Multi':
382 382
                     $sep = ' AND ';
383
-                    if($condition->operator == 'Equal_To') $sep = ' OR ';
383
+                    if ($condition->operator == 'Equal_To') $sep = ' OR ';
384 384
                     $multi_values = unencodeMultienum($condition->value);
385
-                    if(!empty($multi_values)){
385
+                    if (!empty($multi_values)) {
386 386
                         $value = '(';
387
-                        if($data['type'] == 'multienum'){
388
-                            $multi_operator =  $condition->operator == 'Equal_To' ? 'LIKE' : 'NOT LIKE';
389
-                            foreach($multi_values as $multi_value){
390
-                                if($value != '(') $value .= $sep;
387
+                        if ($data['type'] == 'multienum') {
388
+                            $multi_operator = $condition->operator == 'Equal_To' ? 'LIKE' : 'NOT LIKE';
389
+                            foreach ($multi_values as $multi_value) {
390
+                                if ($value != '(') $value .= $sep;
391 391
                                 $value .= $field." $multi_operator '%^".$multi_value."^%'";
392 392
                             }
393 393
                         }
394 394
                         else {
395
-                            foreach($multi_values as $multi_value){
396
-                                if($value != '(') $value .= $sep;
395
+                            foreach ($multi_values as $multi_value) {
396
+                                if ($value != '(') $value .= $sep;
397 397
                                 $value .= $field.' '.$app_list_strings['aow_sql_operator_list'][$condition->operator]." '".$multi_value."'";
398 398
                             }
399 399
                         }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
                     $where_set = true;
404 404
                     break;
405 405
                 case 'SecurityGroup':
406
-                    if(file_exists('modules/SecurityGroups/SecurityGroup.php')){
406
+                    if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
407 407
                         //TODO check bean in group
408 408
                         return array();
409 409
                         break;
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
             }
417 417
 
418 418
             //handle like conditions
419
-            Switch($condition->operator) {
419
+            Switch ($condition->operator) {
420 420
                 case 'Contains':
421 421
                     $value = "CONCAT('%', ".$value." ,'%')";
422 422
                     break;
@@ -429,43 +429,43 @@  discard block
 block discarded – undo
429 429
             }
430 430
 
431 431
 
432
-            if(!$where_set) $query['where'][] = $field.' '.$app_list_strings['aow_sql_operator_list'][$condition->operator].' '.$value;
432
+            if (!$where_set) $query['where'][] = $field.' '.$app_list_strings['aow_sql_operator_list'][$condition->operator].' '.$value;
433 433
         }
434 434
 
435 435
         return $query;
436 436
 
437 437
     }
438 438
 
439
-    function check_valid_bean(SugarBean &$bean){
439
+    function check_valid_bean(SugarBean & $bean) {
440 440
         global $app_list_strings, $timedate;
441 441
 
442 442
         require_once('modules/AOW_Processed/AOW_Processed.php');
443 443
         $processed = new AOW_Processed();
444
-        if(!$this->multiple_runs){
445
-            $processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id,'parent_id' => $bean->id));
444
+        if (!$this->multiple_runs) {
445
+            $processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id, 'parent_id' => $bean->id));
446 446
 
447
-            if($processed->status == 'Complete'){
447
+            if ($processed->status == 'Complete') {
448 448
                 //has already run so return false
449 449
                 return false;
450 450
             }
451 451
         }
452 452
 
453
-        if(!isset($bean->date_entered)){
453
+        if (!isset($bean->date_entered)) {
454 454
             $bean->date_entered = $bean->fetched_row['date_entered'];
455 455
         }
456 456
 
457 457
 
458
-        if($this->flow_run_on){
458
+        if ($this->flow_run_on) {
459 459
 
460 460
             // database time correction with the user's time-zoneqq
461 461
             $beanDateEnteredTimestamp = strtotime($timedate->asUser(new DateTime($timedate->fromDb($bean->date_entered))));
462 462
             $beanDateModifiedTimestamp = strtotime($timedate->asUser(new DateTime($timedate->fromDb($bean->date_modified))));
463 463
             $thisDateEnteredTimestamp = strtotime($this->date_entered);
464 464
 
465
-            switch($this->flow_run_on){
465
+            switch ($this->flow_run_on) {
466 466
                 case'New_Records':
467 467
                     // it is an invalid bean if the user modify it now because the affection need on new records only!
468
-                    if(!empty($bean->fetched_row) ||
468
+                    if (!empty($bean->fetched_row) ||
469 469
                         $beanDateEnteredTimestamp < $thisDateEnteredTimestamp) {
470 470
                         return false;
471 471
                     }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
                 case'Modified_Records':
475 475
                     // it isn't a valid bean if the user create it now because the affection need on already exists records only!
476
-                    if(empty($bean->fetched_row) ||
476
+                    if (empty($bean->fetched_row) ||
477 477
                         ($beanDateModifiedTimestamp < $thisDateEnteredTimestamp && $beanDateModifiedTimestamp != $beanDateEnteredTimestamp)) {
478 478
                         return false;
479 479
                     }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 
496 496
             $condition_bean = $bean;
497 497
 
498
-            if(isset($path[0]) && $path[0] != $bean->module_dir){
498
+            if (isset($path[0]) && $path[0] != $bean->module_dir) {
499 499
                 $query_array = $this->build_query_where($condition, $condition_bean, $query_array);
500 500
                 continue;
501 501
             }
@@ -503,31 +503,31 @@  discard block
 block discarded – undo
503 503
             $field = $condition->field;
504 504
             $value = $condition->value;
505 505
 
506
-            $dateFields = array('date','datetime', 'datetimecombo');
507
-            if(isset($app_list_strings['aow_sql_operator_list'][$condition->operator])){
506
+            $dateFields = array('date', 'datetime', 'datetimecombo');
507
+            if (isset($app_list_strings['aow_sql_operator_list'][$condition->operator])) {
508 508
 
509 509
                 $data = $condition_bean->field_defs[$field];
510 510
 
511
-                if($data['type'] == 'relate' && isset($data['id_name'])) {
511
+                if ($data['type'] == 'relate' && isset($data['id_name'])) {
512 512
                     $field = $data['id_name'];
513 513
                     $condition->field = $data['id_name'];
514 514
                 }
515 515
                 $field = $condition_bean->$field;
516 516
 
517
-                if(in_array($data['type'],$dateFields)) {
517
+                if (in_array($data['type'], $dateFields)) {
518 518
                     $field = strtotime($field);
519 519
                 }
520 520
 
521
-                switch($condition->value_type) {
521
+                switch ($condition->value_type) {
522 522
                     case 'Field':
523 523
                         $data = $condition_bean->field_defs[$value];
524 524
 
525
-                        if($data['type'] == 'relate' && isset($data['id_name'])) {
525
+                        if ($data['type'] == 'relate' && isset($data['id_name'])) {
526 526
                             $value = $data['id_name'];
527 527
                         }
528 528
                         $value = $condition_bean->$value;
529 529
 
530
-                        if(in_array($data['type'],$dateFields)) {
530
+                        if (in_array($data['type'], $dateFields)) {
531 531
                             $value = strtotime($value);
532 532
                         }
533 533
 
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
 
536 536
                     case 'Any_Change':
537 537
                         $value = $condition_bean->fetched_row[$condition->field];
538
-                        if(in_array($data['type'],$dateFields)) {
538
+                        if (in_array($data['type'], $dateFields)) {
539 539
                             $value = strtotime($value);
540 540
                         }
541
-                        switch($condition->operator) {
541
+                        switch ($condition->operator) {
542 542
                             case 'Not_Equal_To';
543 543
                                 $condition->operator = 'Equal_To';
544 544
                                 break;
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
                         break;
551 551
 
552 552
                     case 'Date':
553
-                        $params =  unserialize(base64_decode($value));
553
+                        $params = unserialize(base64_decode($value));
554 554
                         $dateType = 'datetime';
555
-                        if($params[0] == 'now'){
555
+                        if ($params[0] == 'now') {
556 556
                             $value = date('Y-m-d H:i:s');
557
-                        } else if($params[0] == 'today'){
557
+                        } else if ($params[0] == 'today') {
558 558
                             $dateType = 'date';
559 559
                             $value = date('Y-m-d');
560 560
                             $field = strtotime(date('Y-m-d', $field));
@@ -563,28 +563,28 @@  discard block
 block discarded – undo
563 563
                             $value = $condition_bean->$fieldName;
564 564
                         }
565 565
 
566
-                        if($params[1] != 'now'){
567
-                            switch($params[3]) {
566
+                        if ($params[1] != 'now') {
567
+                            switch ($params[3]) {
568 568
                                 case 'business_hours';
569
-                                    if(file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')){
569
+                                    if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) {
570 570
                                         require_once('modules/AOBH_BusinessHours/AOBH_BusinessHours.php');
571 571
 
572 572
                                         $businessHours = new AOBH_BusinessHours();
573 573
 
574 574
                                         $amount = $params[2];
575
-                                        if($params[1] != "plus"){
576
-                                            $amount = 0-$amount;
575
+                                        if ($params[1] != "plus") {
576
+                                            $amount = 0 - $amount;
577 577
                                         }
578 578
 
579 579
                                         $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($value));
580
-                                        $value = strtotime($timedate->asDbType( $value, $dateType ));
580
+                                        $value = strtotime($timedate->asDbType($value, $dateType));
581 581
                                         break;
582 582
                                     }
583 583
                                     //No business hours module found - fall through.
584 584
                                     $params[3] = 'hours';
585 585
                                 default:
586 586
                                     $value = strtotime($value.' '.$app_list_strings['aow_date_operator'][$params[1]]." $params[2] ".$params[3]);
587
-                                    if($dateType == 'date') $value = strtotime(date('Y-m-d', $value));
587
+                                    if ($dateType == 'date') $value = strtotime(date('Y-m-d', $value));
588 588
                                     break;
589 589
                             }
590 590
                         } else {
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
                     case 'Multi':
596 596
 
597 597
                         $value = unencodeMultienum($value);
598
-                        if($data['type'] == 'multienum') $field = unencodeMultienum($field);
599
-                        switch($condition->operator) {
598
+                        if ($data['type'] == 'multienum') $field = unencodeMultienum($field);
599
+                        switch ($condition->operator) {
600 600
                             case 'Not_Equal_To';
601 601
                                 $condition->operator = 'Not_One_of';
602 602
                                 break;
@@ -607,9 +607,9 @@  discard block
 block discarded – undo
607 607
                         }
608 608
                         break;
609 609
                     case 'SecurityGroup':
610
-                        if(file_exists('modules/SecurityGroups/SecurityGroup.php')){
610
+                        if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
611 611
                             $sg_module = $condition_bean->module_dir;
612
-                            if(isset($data['module']) && $data['module'] != ''){
612
+                            if (isset($data['module']) && $data['module'] != '') {
613 613
                                 $sg_module = $data['module'];
614 614
                             }
615 615
                             $value = $this->check_in_group($field, $sg_module, $value);
@@ -618,38 +618,38 @@  discard block
 block discarded – undo
618 618
                         }
619 619
                     case 'Value':
620 620
                     default:
621
-                        if(in_array($data['type'],$dateFields) && trim($value) != '') {
621
+                        if (in_array($data['type'], $dateFields) && trim($value) != '') {
622 622
                             $value = strtotime($value);
623 623
                         }
624 624
                         break;
625 625
                 }
626 626
 
627
-                if(!($this->compare_condition($field, $value, $condition->operator))){
627
+                if (!($this->compare_condition($field, $value, $condition->operator))) {
628 628
                     return false;
629 629
                 }
630 630
 
631 631
             }
632 632
         }
633 633
 
634
-        if(isset($query_array['where'])){
634
+        if (isset($query_array['where'])) {
635 635
 
636 636
             $query = 'SELECT '.$bean->table_name.'.id AS id FROM '.$bean->table_name.' ';
637 637
 
638
-            if(isset($query_array['join'])){
639
-                foreach ($query_array['join'] as $join){
638
+            if (isset($query_array['join'])) {
639
+                foreach ($query_array['join'] as $join) {
640 640
                     $query .= $join;
641 641
                 }
642 642
             }
643 643
             $query_where = '';
644 644
             $query_array['where'][] = $bean->table_name.'.id = '."'".$bean->id."'";
645
-            foreach ($query_array['where'] as $where){
646
-                $query_where .=  ($query_where == '' ? 'WHERE ' : ' AND ').$where;
645
+            foreach ($query_array['where'] as $where) {
646
+                $query_where .= ($query_where == '' ? 'WHERE ' : ' AND ').$where;
647 647
             }
648 648
             $query .= ' '.$query_where;
649 649
 
650 650
             $rel_check = $bean->db->getOne($query);
651 651
 
652
-            if($rel_check == ''){
652
+            if ($rel_check == '') {
653 653
                 return false;
654 654
             }
655 655
 
@@ -658,57 +658,57 @@  discard block
 block discarded – undo
658 658
         return true;
659 659
     }
660 660
 
661
-    function compare_condition($var1, $var2, $operator = 'Equal_To'){
661
+    function compare_condition($var1, $var2, $operator = 'Equal_To') {
662 662
         switch ($operator) {
663 663
             case "Not_Equal_To": return $var1 != $var2;
664
-            case "Greater_Than":  return $var1 >  $var2;
665
-            case "Less_Than":  return $var1 <  $var2;
664
+            case "Greater_Than":  return $var1 > $var2;
665
+            case "Less_Than":  return $var1 < $var2;
666 666
             case "Greater_Than_or_Equal_To": return $var1 >= $var2;
667 667
             case "Less_Than_or_Equal_To": return $var1 <= $var2;
668
-            case "Contains" : return strpos($var1,$var2);
669
-            case "Starts_With" : return strrpos($var1,$var2, -strlen($var1));
670
-            case "Ends_With" : return strpos($var1,$var2,strlen($var1) - strlen($var2));
668
+            case "Contains" : return strpos($var1, $var2);
669
+            case "Starts_With" : return strrpos($var1, $var2, -strlen($var1));
670
+            case "Ends_With" : return strpos($var1, $var2, strlen($var1) - strlen($var2));
671 671
             case "is_null": return $var1 == '';
672 672
             case "One_of":
673
-                if(is_array($var1)){
674
-                    foreach($var1 as $var){
675
-                        if(in_array($var,$var2)) return true;
673
+                if (is_array($var1)) {
674
+                    foreach ($var1 as $var) {
675
+                        if (in_array($var, $var2)) return true;
676 676
                     }
677 677
                     return false;
678 678
                 }
679
-                else return in_array($var1,$var2);
679
+                else return in_array($var1, $var2);
680 680
             case "Not_One_of":
681
-                if(is_array($var1)){
682
-                    foreach($var1 as $var){
683
-                        if(in_array($var,$var2)) return false;
681
+                if (is_array($var1)) {
682
+                    foreach ($var1 as $var) {
683
+                        if (in_array($var, $var2)) return false;
684 684
                     }
685 685
                     return true;
686 686
                 }
687
-                else return !in_array($var1,$var2);
687
+                else return !in_array($var1, $var2);
688 688
             case "Equal_To":
689 689
             default: return $var1 == $var2;
690 690
         }
691 691
     }
692 692
 
693
-    function check_in_group($bean_id, $module, $group){
693
+    function check_in_group($bean_id, $module, $group) {
694 694
         $sql = "SELECT id FROM securitygroups_records WHERE record_id = '".$bean_id."' AND module = '".$module."' AND securitygroup_id = '".$group."' AND deleted=0";
695
-        if($module == 'Users')  $sql = "SELECT id FROM securitygroups_users WHERE user_id = '".$bean_id."' AND securitygroup_id = '".$group."' AND deleted=0";
695
+        if ($module == 'Users')  $sql = "SELECT id FROM securitygroups_users WHERE user_id = '".$bean_id."' AND securitygroup_id = '".$group."' AND deleted=0";
696 696
         $id = $this->db->getOne($sql);
697
-        if($id != '') return true;
697
+        if ($id != '') return true;
698 698
         return false;
699 699
     }
700 700
 
701 701
     /**
702 702
      * Run the actions against the passed $bean
703 703
      */
704
-    function run_actions(SugarBean &$bean, $in_save = false){
704
+    function run_actions(SugarBean & $bean, $in_save = false) {
705 705
 
706 706
         require_once('modules/AOW_Processed/AOW_Processed.php');
707 707
         $processed = new AOW_Processed();
708
-        if(!$this->multiple_runs){
709
-            $processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id,'parent_id' => $bean->id));
708
+        if (!$this->multiple_runs) {
709
+            $processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id, 'parent_id' => $bean->id));
710 710
 
711
-            if($processed->status == 'Complete'){
711
+            if ($processed->status == 'Complete') {
712 712
                 //should not have gotten this far, so return
713 713
                 return true;
714 714
             }
@@ -729,25 +729,25 @@  discard block
 block discarded – undo
729 729
             $action = new AOW_Action();
730 730
             $action->retrieve($row['id']);
731 731
 
732
-            if($this->multiple_runs || !$processed->db->getOne("select id from aow_processed_aow_actions where aow_processed_id = '".$processed->id."' AND aow_action_id = '".$action->id."' AND status = 'Complete'")){
732
+            if ($this->multiple_runs || !$processed->db->getOne("select id from aow_processed_aow_actions where aow_processed_id = '".$processed->id."' AND aow_action_id = '".$action->id."' AND status = 'Complete'")) {
733 733
                 $action_name = 'action'.$action->action;
734 734
 
735
-                if(file_exists('custom/modules/AOW_Actions/actions/'.$action_name.'.php')){
735
+                if (file_exists('custom/modules/AOW_Actions/actions/'.$action_name.'.php')) {
736 736
                     require_once('custom/modules/AOW_Actions/actions/'.$action_name.'.php');
737
-                } else if(file_exists('modules/AOW_Actions/actions/'.$action_name.'.php')){
737
+                } else if (file_exists('modules/AOW_Actions/actions/'.$action_name.'.php')) {
738 738
                     require_once('modules/AOW_Actions/actions/'.$action_name.'.php');
739 739
                 } else {
740 740
                     return false;
741 741
                 }
742 742
 
743
-                $custom_action_name = "custom" . $action_name;
744
-                if(class_exists($custom_action_name)){
743
+                $custom_action_name = "custom".$action_name;
744
+                if (class_exists($custom_action_name)) {
745 745
                     $action_name = $custom_action_name;
746 746
                 }
747 747
 
748 748
 
749 749
                 $flow_action = new $action_name($action->id);
750
-                if(!$flow_action->run_action($bean, unserialize(base64_decode($action->parameters)), $in_save)){
750
+                if (!$flow_action->run_action($bean, unserialize(base64_decode($action->parameters)), $in_save)) {
751 751
                     $pass = false;
752 752
                     $processed->aow_actions->add($action->id, array('status' => 'Failed'));
753 753
                 } else {
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 
758 758
         }
759 759
 
760
-        if($pass) $processed->status = 'Complete';
760
+        if ($pass) $processed->status = 'Complete';
761 761
         else $processed->status = 'Failed';
762 762
         $processed->save(false);
763 763
 
Please login to merge, or discard this patch.
Braces   +44 added lines, -20 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@  discard block
 block discarded – undo
66 66
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
67 67
         if(isset($GLOBALS['log'])) {
68 68
             $GLOBALS['log']->deprecated($deprecatedMessage);
69
-        }
70
-        else {
69
+        } else {
71 70
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
72 71
         }
73 72
         self::__construct($init);
@@ -153,8 +152,9 @@  discard block
 block discarded – undo
153 152
             $flow = new AOW_WorkFlow();
154 153
             while (($row = $bean->db->fetchByAssoc($result)) != null){
155 154
                 $flow ->retrieve($row['id']);
156
-                if($flow->check_valid_bean($bean))
157
-                    $flow->run_actions($bean, true);
155
+                if($flow->check_valid_bean($bean)) {
156
+                                    $flow->run_actions($bean, true);
157
+                }
158 158
             }
159 159
         }
160 160
         return true;
@@ -380,20 +380,25 @@  discard block
 block discarded – undo
380 380
 
381 381
                 case 'Multi':
382 382
                     $sep = ' AND ';
383
-                    if($condition->operator == 'Equal_To') $sep = ' OR ';
383
+                    if($condition->operator == 'Equal_To') {
384
+                        $sep = ' OR ';
385
+                    }
384 386
                     $multi_values = unencodeMultienum($condition->value);
385 387
                     if(!empty($multi_values)){
386 388
                         $value = '(';
387 389
                         if($data['type'] == 'multienum'){
388 390
                             $multi_operator =  $condition->operator == 'Equal_To' ? 'LIKE' : 'NOT LIKE';
389 391
                             foreach($multi_values as $multi_value){
390
-                                if($value != '(') $value .= $sep;
392
+                                if($value != '(') {
393
+                                    $value .= $sep;
394
+                                }
391 395
                                 $value .= $field." $multi_operator '%^".$multi_value."^%'";
392 396
                             }
393
-                        }
394
-                        else {
397
+                        } else {
395 398
                             foreach($multi_values as $multi_value){
396
-                                if($value != '(') $value .= $sep;
399
+                                if($value != '(') {
400
+                                    $value .= $sep;
401
+                                }
397 402
                                 $value .= $field.' '.$app_list_strings['aow_sql_operator_list'][$condition->operator]." '".$multi_value."'";
398 403
                             }
399 404
                         }
@@ -429,7 +434,9 @@  discard block
 block discarded – undo
429 434
             }
430 435
 
431 436
 
432
-            if(!$where_set) $query['where'][] = $field.' '.$app_list_strings['aow_sql_operator_list'][$condition->operator].' '.$value;
437
+            if(!$where_set) {
438
+                $query['where'][] = $field.' '.$app_list_strings['aow_sql_operator_list'][$condition->operator].' '.$value;
439
+            }
433 440
         }
434 441
 
435 442
         return $query;
@@ -584,7 +591,9 @@  discard block
 block discarded – undo
584 591
                                     $params[3] = 'hours';
585 592
                                 default:
586 593
                                     $value = strtotime($value.' '.$app_list_strings['aow_date_operator'][$params[1]]." $params[2] ".$params[3]);
587
-                                    if($dateType == 'date') $value = strtotime(date('Y-m-d', $value));
594
+                                    if($dateType == 'date') {
595
+                                        $value = strtotime(date('Y-m-d', $value));
596
+                                    }
588 597
                                     break;
589 598
                             }
590 599
                         } else {
@@ -595,7 +604,9 @@  discard block
 block discarded – undo
595 604
                     case 'Multi':
596 605
 
597 606
                         $value = unencodeMultienum($value);
598
-                        if($data['type'] == 'multienum') $field = unencodeMultienum($field);
607
+                        if($data['type'] == 'multienum') {
608
+                            $field = unencodeMultienum($field);
609
+                        }
599 610
                         switch($condition->operator) {
600 611
                             case 'Not_Equal_To';
601 612
                                 $condition->operator = 'Not_One_of';
@@ -672,19 +683,25 @@  discard block
 block discarded – undo
672 683
             case "One_of":
673 684
                 if(is_array($var1)){
674 685
                     foreach($var1 as $var){
675
-                        if(in_array($var,$var2)) return true;
686
+                        if(in_array($var,$var2)) {
687
+                            return true;
688
+                        }
676 689
                     }
677 690
                     return false;
691
+                } else {
692
+                    return in_array($var1,$var2);
678 693
                 }
679
-                else return in_array($var1,$var2);
680 694
             case "Not_One_of":
681 695
                 if(is_array($var1)){
682 696
                     foreach($var1 as $var){
683
-                        if(in_array($var,$var2)) return false;
697
+                        if(in_array($var,$var2)) {
698
+                            return false;
699
+                        }
684 700
                     }
685 701
                     return true;
702
+                } else {
703
+                    return !in_array($var1,$var2);
686 704
                 }
687
-                else return !in_array($var1,$var2);
688 705
             case "Equal_To":
689 706
             default: return $var1 == $var2;
690 707
         }
@@ -692,9 +709,13 @@  discard block
 block discarded – undo
692 709
 
693 710
     function check_in_group($bean_id, $module, $group){
694 711
         $sql = "SELECT id FROM securitygroups_records WHERE record_id = '".$bean_id."' AND module = '".$module."' AND securitygroup_id = '".$group."' AND deleted=0";
695
-        if($module == 'Users')  $sql = "SELECT id FROM securitygroups_users WHERE user_id = '".$bean_id."' AND securitygroup_id = '".$group."' AND deleted=0";
712
+        if($module == 'Users') {
713
+            $sql = "SELECT id FROM securitygroups_users WHERE user_id = '".$bean_id."' AND securitygroup_id = '".$group."' AND deleted=0";
714
+        }
696 715
         $id = $this->db->getOne($sql);
697
-        if($id != '') return true;
716
+        if($id != '') {
717
+            return true;
718
+        }
698 719
         return false;
699 720
     }
700 721
 
@@ -757,8 +778,11 @@  discard block
 block discarded – undo
757 778
 
758 779
         }
759 780
 
760
-        if($pass) $processed->status = 'Complete';
761
-        else $processed->status = 'Failed';
781
+        if($pass) {
782
+            $processed->status = 'Complete';
783
+        } else {
784
+            $processed->status = 'Failed';
785
+        }
762 786
         $processed->save(false);
763 787
 
764 788
         return $pass;
Please login to merge, or discard this patch.
modules/AOW_WorkFlow/Dashlets/AOW_WorkFlowDashlet/AOW_WorkFlowDashlet.php 2 patches
Spacing   +4 added lines, -4 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
  * Advanced OpenWorkflow, Automating SugarCRM.
5 5
  * @package Advanced OpenWorkflow for SugarCRM
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
         parent::__construct($id, $def);
36 36
 
37
-        if(empty($def['title'])) $this->title = translate('LBL_HOMEPAGE_TITLE', 'AOW_WorkFlow');
37
+        if (empty($def['title'])) $this->title = translate('LBL_HOMEPAGE_TITLE', 'AOW_WorkFlow');
38 38
 
39 39
         $this->searchFields = $dashletData['AOW_WorkFlowDashlet']['searchFields'];
40 40
         $this->columns = $dashletData['AOW_WorkFlowDashlet']['columns'];
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
47 47
      */
48
-    function AOW_WorkFlowDashlet($id, $def = null){
48
+    function AOW_WorkFlowDashlet($id, $def = null) {
49 49
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
50
-        if(isset($GLOBALS['log'])) {
50
+        if (isset($GLOBALS['log'])) {
51 51
             $GLOBALS['log']->deprecated($deprecatedMessage);
52 52
         }
53 53
         else {
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 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
  * Advanced OpenWorkflow, Automating SugarCRM.
5 7
  * @package Advanced OpenWorkflow for SugarCRM
@@ -34,7 +36,9 @@  discard block
 block discarded – undo
34 36
 
35 37
         parent::__construct($id, $def);
36 38
 
37
-        if(empty($def['title'])) $this->title = translate('LBL_HOMEPAGE_TITLE', 'AOW_WorkFlow');
39
+        if(empty($def['title'])) {
40
+            $this->title = translate('LBL_HOMEPAGE_TITLE', 'AOW_WorkFlow');
41
+        }
38 42
 
39 43
         $this->searchFields = $dashletData['AOW_WorkFlowDashlet']['searchFields'];
40 44
         $this->columns = $dashletData['AOW_WorkFlowDashlet']['columns'];
@@ -49,8 +53,7 @@  discard block
 block discarded – undo
49 53
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
50 54
         if(isset($GLOBALS['log'])) {
51 55
             $GLOBALS['log']->deprecated($deprecatedMessage);
52
-        }
53
-        else {
56
+        } else {
54 57
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
55 58
         }
56 59
         self::__construct($id, $def);
Please login to merge, or discard this patch.
modules/Calendar/views/view.getgr.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 
42 42
 class CalendarViewGetGR extends SugarView {
43 43
 
44
-	function __construct(){
44
+	function __construct() {
45 45
  		parent::__construct();
46 46
 	}
47 47
 
48 48
     /**
49 49
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
50 50
      */
51
-    function CalendarViewGetGR(){
51
+    function CalendarViewGetGR() {
52 52
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
53
-        if(isset($GLOBALS['log'])) {
53
+        if (isset($GLOBALS['log'])) {
54 54
             $GLOBALS['log']->deprecated($deprecatedMessage);
55 55
         }
56 56
         else {
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
 
63
-	function process(){
63
+	function process() {
64 64
 		$this->display();
65 65
 	}
66 66
 
67
-	function display(){
67
+	function display() {
68 68
 		error_reporting(0);
69 69
 		require_once('include/json_config.php');
70 70
 		global $json;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/Calendar/views/view.getgrusers.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 
42 42
 class CalendarViewGetGRUsers extends SugarView {
43 43
 
44
-	function __construct(){
44
+	function __construct() {
45 45
  		parent::__construct();
46 46
 	}
47 47
 
48 48
     /**
49 49
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
50 50
      */
51
-    function CalendarViewGetGRUsers(){
51
+    function CalendarViewGetGRUsers() {
52 52
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
53
-        if(isset($GLOBALS['log'])) {
53
+        if (isset($GLOBALS['log'])) {
54 54
             $GLOBALS['log']->deprecated($deprecatedMessage);
55 55
         }
56 56
         else {
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
 
63
-	function process(){
63
+	function process() {
64 64
 		$this->display();
65 65
 	}
66 66
 
67
-	function display(){
67
+	function display() {
68 68
 		$users_arr = array();
69 69
 		require_once("modules/Users/User.php");
70 70
 
71
-		$user_ids = explode(",", trim($_REQUEST['users'],','));
71
+		$user_ids = explode(",", trim($_REQUEST['users'], ','));
72 72
 		$user_ids = array_unique($user_ids);
73 73
 
74 74
 		require_once('include/json_config.php');
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 		$json = getJSONobj();
77 77
 		$json_config = new json_config();
78 78
 
79
-		foreach($user_ids as $u_id){
80
-			if(empty($u_id))
79
+		foreach ($user_ids as $u_id) {
80
+			if (empty($u_id))
81 81
 				continue;
82 82
 			$bean = new User();
83 83
 			$bean->retrieve($u_id);
84 84
 			array_push($users_arr, $json_config->populateBean($bean));
85 85
 		}
86 86
 
87
-		$GRjavascript = "\n" . $json_config->global_registry_var_name."['focus'].users_arr = " . $json->encode($users_arr) . ";\n";
87
+		$GRjavascript = "\n".$json_config->global_registry_var_name."['focus'].users_arr = ".$json->encode($users_arr).";\n";
88 88
 		ob_clean();
89 89
 		echo $GRjavascript;
90 90
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
53 53
         if(isset($GLOBALS['log'])) {
54 54
             $GLOBALS['log']->deprecated($deprecatedMessage);
55
-        }
56
-        else {
55
+        } else {
57 56
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
58 57
         }
59 58
         self::__construct();
@@ -77,8 +76,9 @@  discard block
 block discarded – undo
77 76
 		$json_config = new json_config();
78 77
 
79 78
 		foreach($user_ids as $u_id){
80
-			if(empty($u_id))
81
-				continue;
79
+			if(empty($u_id)) {
80
+							continue;
81
+			}
82 82
 			$bean = new User();
83 83
 			$bean->retrieve($u_id);
84 84
 			array_push($users_arr, $json_config->populateBean($bean));
Please login to merge, or discard this patch.
modules/Calendar/Dashlets/CalendarDashlet/CalendarDashlet.php 2 patches
Spacing   +15 added lines, -15 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.
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
     var $view = 'week';
47 47
 
48 48
     function __construct($id, $def) {
49
-        $this->loadLanguage('CalendarDashlet','modules/Calendar/Dashlets/');
49
+        $this->loadLanguage('CalendarDashlet', 'modules/Calendar/Dashlets/');
50 50
 
51 51
 		parent::__construct($id);
52 52
 
53 53
 		$this->isConfigurable = true;
54 54
 		$this->hasScript = true;
55 55
 
56
-		if(empty($def['title']))
56
+		if (empty($def['title']))
57 57
 			$this->title = $this->dashletStrings['LBL_TITLE'];
58 58
 		else
59 59
 			$this->title = $def['title'];
60 60
 
61
-		if(!empty($def['view']))
61
+		if (!empty($def['view']))
62 62
 			$this->view = $def['view'];
63 63
 
64 64
     }
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
     /**
67 67
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
68 68
      */
69
-    function CalendarDashlet($id, $def){
69
+    function CalendarDashlet($id, $def) {
70 70
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
71
-        if(isset($GLOBALS['log'])) {
71
+        if (isset($GLOBALS['log'])) {
72 72
             $GLOBALS['log']->deprecated($deprecatedMessage);
73 73
         }
74 74
         else {
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
     }
79 79
 
80 80
 
81
-    function display(){
81
+    function display() {
82 82
 		ob_start();
83 83
 
84
-		if(isset($GLOBALS['cal_strings']))
85
-			return parent::display() . "Only one Calendar dashlet is allowed.";
84
+		if (isset($GLOBALS['cal_strings']))
85
+			return parent::display()."Only one Calendar dashlet is allowed.";
86 86
 
87 87
 		require_once('modules/Calendar/Calendar.php');
88 88
 		require_once('modules/Calendar/CalendarDisplay.php');
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		global $cal_strings, $current_language;
92 92
 		$cal_strings = return_module_language($current_language, 'Calendar');
93 93
 
94
-		if(!ACLController::checkAccess('Calendar', 'list', true))
94
+		if (!ACLController::checkAccess('Calendar', 'list', true))
95 95
 			ACLController::displayNoAccess(true);
96 96
 
97 97
 		$cal = new Calendar($this->view);
@@ -99,26 +99,26 @@  discard block
 block discarded – undo
99 99
 		$cal->add_activities($GLOBALS['current_user']);
100 100
 		$cal->load_activities();
101 101
 
102
-		$display = new CalendarDisplay($cal,$this->id);
102
+		$display = new CalendarDisplay($cal, $this->id);
103 103
 		$display->display_calendar_header(false);
104 104
 		$display->display();
105 105
 
106 106
 		$str = ob_get_contents();
107 107
 		ob_end_clean();
108 108
 
109
-		return parent::display() . $str;
109
+		return parent::display().$str;
110 110
     }
111 111
 
112 112
 
113 113
     function displayOptions() {
114
-        global $app_strings,$mod_strings;
114
+        global $app_strings, $mod_strings;
115 115
         $ss = new Sugar_Smarty();
116 116
         $ss->assign('MOD', $this->dashletStrings);
117 117
         $ss->assign('title', $this->title);
118 118
         $ss->assign('view', $this->view);
119 119
         $ss->assign('id', $this->id);
120 120
 
121
-        return parent::displayOptions() . $ss->fetch('modules/Calendar/Dashlets/CalendarDashlet/CalendarDashletOptions.tpl');
121
+        return parent::displayOptions().$ss->fetch('modules/Calendar/Dashlets/CalendarDashlet/CalendarDashletOptions.tpl');
122 122
     }
123 123
 
124 124
     function saveOptions($req) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         return $options;
131 131
     }
132 132
 
133
-    function displayScript(){
133
+    function displayScript() {
134 134
 	return "";
135 135
     }
136 136
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -13 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.
@@ -53,13 +55,15 @@  discard block
 block discarded – undo
53 55
 		$this->isConfigurable = true;
54 56
 		$this->hasScript = true;
55 57
 
56
-		if(empty($def['title']))
57
-			$this->title = $this->dashletStrings['LBL_TITLE'];
58
-		else
59
-			$this->title = $def['title'];
58
+		if(empty($def['title'])) {
59
+					$this->title = $this->dashletStrings['LBL_TITLE'];
60
+		} else {
61
+					$this->title = $def['title'];
62
+		}
60 63
 
61
-		if(!empty($def['view']))
62
-			$this->view = $def['view'];
64
+		if(!empty($def['view'])) {
65
+					$this->view = $def['view'];
66
+		}
63 67
 
64 68
     }
65 69
 
@@ -70,8 +74,7 @@  discard block
 block discarded – undo
70 74
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
71 75
         if(isset($GLOBALS['log'])) {
72 76
             $GLOBALS['log']->deprecated($deprecatedMessage);
73
-        }
74
-        else {
77
+        } else {
75 78
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
76 79
         }
77 80
         self::__construct($id, $def);
@@ -81,8 +84,9 @@  discard block
 block discarded – undo
81 84
     function display(){
82 85
 		ob_start();
83 86
 
84
-		if(isset($GLOBALS['cal_strings']))
85
-			return parent::display() . "Only one Calendar dashlet is allowed.";
87
+		if(isset($GLOBALS['cal_strings'])) {
88
+					return parent::display() . "Only one Calendar dashlet is allowed.";
89
+		}
86 90
 
87 91
 		require_once('modules/Calendar/Calendar.php');
88 92
 		require_once('modules/Calendar/CalendarDisplay.php');
@@ -91,8 +95,9 @@  discard block
 block discarded – undo
91 95
 		global $cal_strings, $current_language;
92 96
 		$cal_strings = return_module_language($current_language, 'Calendar');
93 97
 
94
-		if(!ACLController::checkAccess('Calendar', 'list', true))
95
-			ACLController::displayNoAccess(true);
98
+		if(!ACLController::checkAccess('Calendar', 'list', true)) {
99
+					ACLController::displayNoAccess(true);
100
+		}
96 101
 
97 102
 		$cal = new Calendar($this->view);
98 103
 		$cal->dashlet = true;
Please login to merge, or discard this patch.
modules/vCals/HTTP_WebDAV_Server_vCal.php 2 patches
Spacing   +35 added lines, -35 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.
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
     /**
79 79
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
80 80
      */
81
-    function HTTP_WebDAV_Server_vCal(){
81
+    function HTTP_WebDAV_Server_vCal() {
82 82
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
83
-        if(isset($GLOBALS['log'])) {
83
+        if (isset($GLOBALS['log'])) {
84 84
             $GLOBALS['log']->deprecated($deprecatedMessage);
85 85
         }
86 86
         else {
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         function ServeRequest($base = false)
101 101
         {
102 102
 
103
-            global $sugar_config,$current_language;
103
+            global $sugar_config, $current_language;
104 104
 
105 105
             if (!empty($sugar_config['session_dir']))
106 106
             {
@@ -129,35 +129,35 @@  discard block
 block discarded – undo
129 129
             // set root directory, defaults to webserver document root if not set
130 130
             if ($base) {
131 131
                 $this->base = realpath($base); // TODO throw if not a directory
132
-            } else if(!$this->base) {
132
+            } else if (!$this->base) {
133 133
                 $this->base = $_SERVER['DOCUMENT_ROOT'];
134 134
             }
135 135
 
136 136
 
137
-            $query_arr =  array();
137
+            $query_arr = array();
138 138
              // set path
139
-            if ( empty($_SERVER["PATH_INFO"]))
139
+            if (empty($_SERVER["PATH_INFO"]))
140 140
             {
141 141
 				$this->path = "/";
142
-				if(strtolower($_SERVER["REQUEST_METHOD"]) == 'get'){
142
+				if (strtolower($_SERVER["REQUEST_METHOD"]) == 'get') {
143 143
 					$query_arr = $_REQUEST;
144
-				}else{
145
-					parse_str($_REQUEST['parms'],$query_arr);
144
+				} else {
145
+					parse_str($_REQUEST['parms'], $query_arr);
146 146
 				}
147
-            } else{
148
-              $this->path = $this->_urldecode( $_SERVER["PATH_INFO"]);
147
+            } else {
148
+              $this->path = $this->_urldecode($_SERVER["PATH_INFO"]);
149 149
 
150
-              if(ini_get("magic_quotes_gpc")) {
150
+              if (ini_get("magic_quotes_gpc")) {
151 151
                $this->path = stripslashes($this->path);
152 152
               }
153 153
 
154
-              $query_str = preg_replace('/^\//','',$this->path);
155
-              $query_arr =  array();
156
-              parse_str($query_str,$query_arr);
154
+              $query_str = preg_replace('/^\//', '', $this->path);
155
+              $query_arr = array();
156
+              parse_str($query_str, $query_arr);
157 157
             }
158 158
 
159 159
 
160
-            if ( ! empty($query_arr['type']))
160
+            if (!empty($query_arr['type']))
161 161
             {
162 162
               $this->vcal_type = $query_arr['type'];
163 163
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
               $this->vcal_type = 'vfb';
166 166
             }
167 167
 
168
-            if ( ! empty($query_arr['source']))
168
+            if (!empty($query_arr['source']))
169 169
             {
170 170
               $this->source = $query_arr['source'];
171 171
             }
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
               $this->source = 'outlook';
174 174
             }
175 175
 
176
-            if ( ! empty($query_arr['key']))
176
+            if (!empty($query_arr['key']))
177 177
             {
178 178
               $this->publish_key = $query_arr['key'];
179 179
             }
180 180
 
181 181
             // select user by email
182
-            if ( ! empty($query_arr['email']))
182
+            if (!empty($query_arr['email']))
183 183
             {
184 184
 
185 185
 
186 186
               // clean the string!
187 187
               $query_arr['email'] = clean_string($query_arr['email']);
188 188
               //get user info
189
-              $this->user_focus->retrieve_by_email_address( $query_arr['email']);
189
+              $this->user_focus->retrieve_by_email_address($query_arr['email']);
190 190
 
191 191
             }
192 192
             // else select user by user_name
193
-            else if ( ! empty($query_arr['user_name']))
193
+            else if (!empty($query_arr['user_name']))
194 194
             {
195 195
               // clean the string!
196 196
               $query_arr['user_name'] = clean_string($query_arr['user_name']);
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
               $this->user_focus->retrieve_by_string_fields($arr);
201 201
             }
202 202
             // else select user by user id
203
-            else if ( ! empty($query_arr['user_id']))
203
+            else if (!empty($query_arr['user_id']))
204 204
             {
205 205
                 $this->user_focus->retrieve($query_arr['user_id']);
206 206
             }
207 207
 
208 208
             // if we haven't found a user, then return 404
209
-            if ( empty($this->user_focus->id) || $this->user_focus->id == -1)
209
+            if (empty($this->user_focus->id) || $this->user_focus->id == -1)
210 210
             {
211 211
                 $this->http_status('401 Unauthorized');
212 212
                 if (!isset($query_arr['noAuth'])) {
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
          */
236 236
         function check_auth($type, $user, $pass)
237 237
         {
238
-            if(isset($_SESSION['authenticated_user_id'])) {
238
+            if (isset($_SESSION['authenticated_user_id'])) {
239 239
                 // allow logged in users access to freebusy info
240 240
                 return true;
241 241
             }
242
-            if(!empty($this->publish_key) && !empty($this->user_focus) && $this->user_focus->getPreference('calendar_publish_key' ) == $this->publish_key) {
242
+            if (!empty($this->publish_key) && !empty($this->user_focus) && $this->user_focus->getPreference('calendar_publish_key') == $this->publish_key) {
243 243
                 return true;
244 244
             }
245 245
             return false;
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
             }
358 358
 
359 359
             // DO AUTHORIZATION for publishing Free/busy to Sugar:
360
-            if ( empty($this->publish_key) ||
361
-                $this->publish_key != $this->user_focus->getPreference('calendar_publish_key' ))
360
+            if (empty($this->publish_key) ||
361
+                $this->publish_key != $this->user_focus->getPreference('calendar_publish_key'))
362 362
             {
363 363
                     $this->http_status("401 not authorized");
364 364
                     return;
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
             }
367 367
 
368 368
             // retrieve
369
-            $arr = array('user_id'=>$this->user_focus->id,'type'=>'vfb','source'=>$this->source);
369
+            $arr = array('user_id'=>$this->user_focus->id, 'type'=>'vfb', 'source'=>$this->source);
370 370
             $this->vcal_focus->retrieve_by_string_fields($arr);
371 371
 
372
-            $isUpdate  = false;
372
+            $isUpdate = false;
373 373
 
374
-            if ( ! empty($this->vcal_focus->user_id ) &&
375
-                $this->vcal_focus->user_id != -1 )
374
+            if (!empty($this->vcal_focus->user_id) &&
375
+                $this->vcal_focus->user_id != -1)
376 376
             {
377
-              $isUpdate  = true;
377
+              $isUpdate = true;
378 378
             }
379 379
 
380 380
             // open input stream
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
             $this->vcal_focus->user_id = $this->user_focus->id;
396 396
             $this->vcal_focus->save();
397 397
 
398
-            if ( $isUpdate )
398
+            if ($isUpdate)
399 399
             {
400 400
                $this->http_status("204 No Content");
401 401
             } else {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         function lock(&$options)
424 424
         {
425 425
 
426
-            $options["timeout"] = time()+300; // 5min. hardcoded
426
+            $options["timeout"] = time() + 300; // 5min. hardcoded
427 427
             return true;
428 428
         }
429 429
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -9 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.
@@ -82,8 +84,7 @@  discard block
 block discarded – undo
82 84
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
83 85
         if(isset($GLOBALS['log'])) {
84 86
             $GLOBALS['log']->deprecated($deprecatedMessage);
85
-        }
86
-        else {
87
+        } else {
87 88
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
88 89
         }
89 90
         self::__construct();
@@ -141,7 +142,7 @@  discard block
 block discarded – undo
141 142
 				$this->path = "/";
142 143
 				if(strtolower($_SERVER["REQUEST_METHOD"]) == 'get'){
143 144
 					$query_arr = $_REQUEST;
144
-				}else{
145
+				} else{
145 146
 					parse_str($_REQUEST['parms'],$query_arr);
146 147
 				}
147 148
             } else{
@@ -160,16 +161,14 @@  discard block
 block discarded – undo
160 161
             if ( ! empty($query_arr['type']))
161 162
             {
162 163
               $this->vcal_type = $query_arr['type'];
163
-            }
164
-            else {
164
+            } else {
165 165
               $this->vcal_type = 'vfb';
166 166
             }
167 167
 
168 168
             if ( ! empty($query_arr['source']))
169 169
             {
170 170
               $this->source = $query_arr['source'];
171
-            }
172
-            else {
171
+            } else {
173 172
               $this->source = 'outlook';
174 173
             }
175 174
 
@@ -308,7 +307,9 @@  discard block
 block discarded – undo
308 307
                (Not Implemented) response in such cases."
309 308
             */
310 309
             foreach ($_SERVER as $key => $val) {
311
-                if (strncmp($key, "HTTP_CONTENT", 11)) continue;
310
+                if (strncmp($key, "HTTP_CONTENT", 11)) {
311
+                    continue;
312
+                }
312 313
                 switch ($key) {
313 314
                 case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11
314 315
                     // TODO support this if ext/zlib filters are available
Please login to merge, or discard this patch.
modules/vCals/vCal.php 2 patches
Spacing   +23 added lines, -23 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.
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
     /**
80 80
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
81 81
      */
82
-    public function vCal(){
82
+    public function vCal() {
83 83
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
84
-        if(isset($GLOBALS['log'])) {
84
+        if (isset($GLOBALS['log'])) {
85 85
             $GLOBALS['log']->deprecated($deprecatedMessage);
86 86
         }
87 87
         else {
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
 	function create_sugar_freebusy($user_bean, $start_date_time, $end_date_time)
137 137
 	{
138 138
         $ical_array = array();
139
-		global $DO_USER_TIME_OFFSET,$timedate;
139
+		global $DO_USER_TIME_OFFSET, $timedate;
140 140
 
141 141
 		$DO_USER_TIME_OFFSET = true;
142
-		if(empty($GLOBALS['current_user']) || empty($GLOBALS['current_user']->id)) {
142
+		if (empty($GLOBALS['current_user']) || empty($GLOBALS['current_user']->id)) {
143 143
 		    $GLOBALS['current_user'] = $user_bean;
144 144
 		}
145 145
 		// get activities.. queries Meetings and Calls
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
 			'freebusy');
152 152
 
153 153
 		// loop thru each activity, get start/end time in UTC, and return FREEBUSY strings
154
-		foreach($acts_arr as $act)
154
+		foreach ($acts_arr as $act)
155 155
 		{
156 156
             $ID = $act->sugar_bean->id;
157 157
 			$startTimeUTC = $act->start_time->format(self::UTC_FORMAT);
158 158
 			$endTimeUTC = $act->end_time->format(self::UTC_FORMAT);
159
-            $ical_array[] = array("FREEBUSY", $startTimeUTC ."/". $endTimeUTC);
159
+            $ical_array[] = array("FREEBUSY", $startTimeUTC."/".$endTimeUTC);
160 160
             $ical_array[] = array("X-FREEBUSY-ID", $ID);
161 161
             $ical_array[] = array("X-FREEBUSY-TYPE", get_class($act->sugar_bean));
162 162
             //$ical_array[] = array(array("X-FREEBUSYID", $ID), array("FREEBUSY", $startTimeUTC ."/". $endTimeUTC));
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 
169 169
         // return a freebusy vcal string
170
-        function get_vcal_freebusy($user_focus,$cached=true)
170
+        function get_vcal_freebusy($user_focus, $cached = true)
171 171
         {
172 172
            global $locale, $timedate;
173 173
            $ical_array = array();
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
            }
228 228
 
229 229
            // UID:20030724T213406Z-10358-1000-1-12@phoenix
230
-           $str .= self::fold_ical_lines("DTSTAMP", $utc_now_time) . self::EOL;
230
+           $str .= self::fold_ical_lines("DTSTAMP", $utc_now_time).self::EOL;
231 231
            $str .= "END:VFREEBUSY".self::EOL;
232 232
            $str .= "END:VCALENDAR".self::EOL;
233 233
            return $str;
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
         {
248 248
             $focus = new vCal();
249 249
             // set freebusy members and save
250
-            $arr = array('user_id'=>$user_focus->id,'type'=>'vfb','source'=>'sugar');
250
+            $arr = array('user_id'=>$user_focus->id, 'type'=>'vfb', 'source'=>'sugar');
251 251
             $focus->retrieve_by_string_fields($arr);
252 252
 
253 253
 
254
-            $focus->content = $focus->get_vcal_freebusy($user_focus,false);
254
+            $focus->content = $focus->get_vcal_freebusy($user_focus, false);
255 255
             $focus->type = 'vfb';
256 256
             $focus->date_modified = null;
257 257
             $focus->source = 'sugar';
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public static function fold_ical_lines($key, $value)
267 267
     {
268
-        $iCalValue = $key . ":" . $value;
268
+        $iCalValue = $key.":".$value;
269 269
 
270 270
         if (strlen($iCalValue) <= self::CHARSPERLINE) {
271 271
             return $iCalValue;
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 
274 274
         $firstchars = substr($iCalValue, 0, self::CHARSPERLINE);
275 275
         $remainingchars = substr($iCalValue, self::CHARSPERLINE);
276
-        $end = self::EOL . self::TAB;
276
+        $end = self::EOL.self::TAB;
277 277
 
278 278
         $remainingchars = substr(
279 279
             chunk_split(
280
-                $end . $remainingchars,
280
+                $end.$remainingchars,
281 281
                 self::CHARSPERLINE + strlen(self::EOL),
282 282
                 $end
283 283
             ),
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             -strlen($end) // exclude last EOL and TAB chars
286 286
         );
287 287
 
288
-        return $firstchars . $remainingchars;
288
+        return $firstchars.$remainingchars;
289 289
     }
290 290
 
291 291
     /**
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
     /**
313 313
      * this function takes an iCal array and converts it to iCal string while following RFC rules
314 314
      */
315
-    public static function create_ical_string_from_array($ical_array,$no_folding=false)
315
+    public static function create_ical_string_from_array($ical_array, $no_folding = false)
316 316
     {
317 317
         $str = "";
318 318
         foreach ($ical_array as $ical) {
319
-            if($no_folding){
320
-                $str .= $ical[0].":".self::escape_ical_chars($ical[1]) . self::EOL;
319
+            if ($no_folding) {
320
+                $str .= $ical[0].":".self::escape_ical_chars($ical[1]).self::EOL;
321 321
             } else {
322
-                $str .= self::fold_ical_lines($ical[0], self::escape_ical_chars($ical[1])) . self::EOL;
322
+                $str .= self::fold_ical_lines($ical[0], self::escape_ical_chars($ical[1])).self::EOL;
323 323
             }
324 324
         }
325 325
         return $str;
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	/**
353 353
 	 * get ics file content for meeting invite email
354 354
 	 */
355
-	public static function get_ical_event(SugarBean $bean, User $user){
355
+	public static function get_ical_event(SugarBean $bean, User $user) {
356 356
         global $timedate;
357 357
         $ical_array = array();
358 358
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         $ical_array[] = array("PRODID", "-//SugarCRM//SugarCRM Calendar//EN");
362 362
         $ical_array[] = array("BEGIN", "VEVENT");
363 363
         $ical_array[] = array("UID", $bean->id);
364
-        $ical_array[] = array("ORGANIZED;CN=" . $user->full_name, $user->email1);
364
+        $ical_array[] = array("ORGANIZED;CN=".$user->full_name, $user->email1);
365 365
         $ical_array[] = array("DTSTART", $timedate->fromDb($bean->date_start)->format(self::UTC_FORMAT));
366 366
         $ical_array[] = array("DTEND", $timedate->fromDb($bean->date_end)->format(self::UTC_FORMAT));
367 367
 
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
         $ical_array[] = array("SUMMARY", $bean->name);
373 373
         $ical_array[] = array("LOCATION", $bean->location);
374 374
 
375
-        $descPrepend = empty($bean->join_url) ? "" : $bean->join_url . self::EOL . self::EOL;
376
-        $ical_array[] = array("DESCRIPTION", $descPrepend . $bean->description);
375
+        $descPrepend = empty($bean->join_url) ? "" : $bean->join_url.self::EOL.self::EOL;
376
+        $ical_array[] = array("DESCRIPTION", $descPrepend.$bean->description);
377 377
 
378 378
         $ical_array[] = array("END", "VEVENT");
379 379
         $ical_array[] = array("END", "VCALENDAR");
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.
modules/ACL/ACLJSController.php 3 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 
43 43
 class ACLJSController{
44 44
 
45
-	public function __construct($module,$form='', $is_owner=false){
45
+    public function __construct($module,$form='', $is_owner=false){
46 46
 
47
-		$this->module = $module;
48
-		$this->is_owner = $is_owner;
49
-		$this->form = $form;
50
-	}
47
+        $this->module = $module;
48
+        $this->is_owner = $is_owner;
49
+        $this->form = $form;
50
+    }
51 51
 
52 52
     /**
53 53
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
 
67
-	function getJavascript(){
68
-		global $action;
69
-		if(!ACLController::moduleSupportsACL($this->module)){
70
-			return '';
71
-		}
72
-		$script = "<SCRIPT>\n//BEGIN ACL JAVASCRIPT\n";
67
+    function getJavascript(){
68
+        global $action;
69
+        if(!ACLController::moduleSupportsACL($this->module)){
70
+            return '';
71
+        }
72
+        $script = "<SCRIPT>\n//BEGIN ACL JAVASCRIPT\n";
73 73
 
74
-		if($action == 'DetailView'){
75
-			if(!ACLController::checkAccess($this->module,'edit', $this->is_owner)){
76
-			$script .= <<<EOQ
74
+        if($action == 'DetailView'){
75
+            if(!ACLController::checkAccess($this->module,'edit', $this->is_owner)){
76
+            $script .= <<<EOQ
77 77
 						if(typeof(document.DetailView) != 'undefined'){
78 78
 							if(typeof(document.DetailView.elements['Edit']) != 'undefined'){
79 79
 								document.DetailView.elements['Edit'].disabled = 'disabled';
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 						}
85 85
 EOQ;
86 86
 }
87
-			if(!ACLController::checkAccess($this->module,'delete', $this->is_owner)){
88
-			$script .= <<<EOQ
87
+            if(!ACLController::checkAccess($this->module,'delete', $this->is_owner)){
88
+            $script .= <<<EOQ
89 89
 						if(typeof(document.DetailView) != 'undefined'){
90 90
 							if(typeof(document.DetailView.elements['Delete']) != 'undefined'){
91 91
 								document.DetailView.elements['Delete'].disabled = 'disabled';
@@ -93,94 +93,94 @@  discard block
 block discarded – undo
93 93
 						}
94 94
 EOQ;
95 95
 }
96
-		}
97
-		if(file_exists('modules/'. $this->module . '/metadata/acldefs.php')){
98
-			include('modules/'. $this->module . '/metadata/acldefs.php');
99
-
100
-			foreach($acldefs[$this->module]['forms'] as $form_name=>$form){
101
-
102
-				foreach($form as $field_name=>$field){
103
-
104
-					if($field['app_action'] == $action){
105
-						switch($form_name){
106
-							case 'by_id':
107
-								$script .= $this->getFieldByIdScript($field_name, $field);
108
-								break;
109
-							case 'by_name':
110
-								$script .= $this->getFieldByNameScript($field_name, $field);
111
-								break;
112
-							default:
113
-								$script .= $this->getFieldByFormScript($form_name, $field_name, $field);
114
-								break;
115
-						}
116
-					}
117
-
118
-				}
119
-			}
120
-		}
121
-		$script .=  '</SCRIPT>';
96
+        }
97
+        if(file_exists('modules/'. $this->module . '/metadata/acldefs.php')){
98
+            include('modules/'. $this->module . '/metadata/acldefs.php');
99
+
100
+            foreach($acldefs[$this->module]['forms'] as $form_name=>$form){
101
+
102
+                foreach($form as $field_name=>$field){
103
+
104
+                    if($field['app_action'] == $action){
105
+                        switch($form_name){
106
+                            case 'by_id':
107
+                                $script .= $this->getFieldByIdScript($field_name, $field);
108
+                                break;
109
+                            case 'by_name':
110
+                                $script .= $this->getFieldByNameScript($field_name, $field);
111
+                                break;
112
+                            default:
113
+                                $script .= $this->getFieldByFormScript($form_name, $field_name, $field);
114
+                                break;
115
+                        }
116
+                    }
117
+
118
+                }
119
+            }
120
+        }
121
+        $script .=  '</SCRIPT>';
122 122
 
123
-		return $script;
123
+        return $script;
124 124
 
125 125
 
126
-	}
126
+    }
127 127
 
128
-	function getHTMLValues($def){
129
-		$return_array = array();
130
-		switch($def['display_option']){
131
-			case 'clear_link':
132
-				$return_array['href']= "#";
133
-				$return_array['className']= "nolink";
134
-				break;
135
-			default;
136
-				$return_array[$def['display_option']] = $def['display_option'];
137
-				break;
128
+    function getHTMLValues($def){
129
+        $return_array = array();
130
+        switch($def['display_option']){
131
+            case 'clear_link':
132
+                $return_array['href']= "#";
133
+                $return_array['className']= "nolink";
134
+                break;
135
+            default;
136
+                $return_array[$def['display_option']] = $def['display_option'];
137
+                break;
138 138
 
139
-		}
140
-		return $return_array;
139
+        }
140
+        return $return_array;
141 141
 
142
-	}
142
+    }
143 143
 
144
-	function getFieldByIdScript($name, $def){
145
-		$script = '';
146
-		if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
147
-		foreach($this->getHTMLValues($def) as $key=>$value){
148
-			$script .=  "\nif(document.getElementById('$name'))document.getElementById('$name')." . $key . '="' .$value. '";'. "\n";
149
-		}
150
-		}
151
-		return $script;
144
+    function getFieldByIdScript($name, $def){
145
+        $script = '';
146
+        if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
147
+        foreach($this->getHTMLValues($def) as $key=>$value){
148
+            $script .=  "\nif(document.getElementById('$name'))document.getElementById('$name')." . $key . '="' .$value. '";'. "\n";
149
+        }
150
+        }
151
+        return $script;
152 152
 
153
-	}
153
+    }
154 154
 
155
-	function getFieldByNameScript($name, $def){
156
-		$script = '';
157
-		if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
155
+    function getFieldByNameScript($name, $def){
156
+        $script = '';
157
+        if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
158 158
 
159
-		foreach($this->getHTMLValues($def) as $key=>$value){
160
-			$script .=  <<<EOQ
159
+        foreach($this->getHTMLValues($def) as $key=>$value){
160
+            $script .=  <<<EOQ
161 161
 			var aclfields = document.getElementsByName('$name');
162 162
 			for(var i in aclfields){
163 163
 				aclfields[i].$key = '$value';
164 164
 			}
165 165
 EOQ;
166
-		}
167
-		}
168
-		return $script;
166
+        }
167
+        }
168
+        return $script;
169 169
 
170
-	}
170
+    }
171 171
 
172
-	function getFieldByFormScript($form, $name, $def){
173
-		$script = '';
172
+    function getFieldByFormScript($form, $name, $def){
173
+        $script = '';
174 174
 
175 175
 
176
-		if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
177
-			foreach($this->getHTMLValues($def) as $key=>$value){
178
-				$script .= "\nif(typeof(document.$form.$name.$key) != 'undefined')\n document.$form.$name.".$key . '="' .$value. '";';
179
-			}
180
-		}
181
-		return $script;
176
+        if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
177
+            foreach($this->getHTMLValues($def) as $key=>$value){
178
+                $script .= "\nif(typeof(document.$form.$name.$key) != 'undefined')\n document.$form.$name.".$key . '="' .$value. '";';
179
+            }
180
+        }
181
+        return $script;
182 182
 
183
-	}
183
+    }
184 184
 
185 185
 
186 186
 
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 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.
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 
41 41
 
42 42
 
43
-class ACLJSController{
43
+class ACLJSController {
44 44
 
45
-	public function __construct($module,$form='', $is_owner=false){
45
+	public function __construct($module, $form = '', $is_owner = false) {
46 46
 
47 47
 		$this->module = $module;
48 48
 		$this->is_owner = $is_owner;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
     /**
53 53
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
54 54
      */
55
-    public function ACLJSController($module,$form='', $is_owner=false){
55
+    public function ACLJSController($module, $form = '', $is_owner = false) {
56 56
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
57
-        if(isset($GLOBALS['log'])) {
57
+        if (isset($GLOBALS['log'])) {
58 58
             $GLOBALS['log']->deprecated($deprecatedMessage);
59 59
         }
60 60
         else {
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
 
67
-	function getJavascript(){
67
+	function getJavascript() {
68 68
 		global $action;
69
-		if(!ACLController::moduleSupportsACL($this->module)){
69
+		if (!ACLController::moduleSupportsACL($this->module)) {
70 70
 			return '';
71 71
 		}
72 72
 		$script = "<SCRIPT>\n//BEGIN ACL JAVASCRIPT\n";
73 73
 
74
-		if($action == 'DetailView'){
75
-			if(!ACLController::checkAccess($this->module,'edit', $this->is_owner)){
74
+		if ($action == 'DetailView') {
75
+			if (!ACLController::checkAccess($this->module, 'edit', $this->is_owner)) {
76 76
 			$script .= <<<EOQ
77 77
 						if(typeof(document.DetailView) != 'undefined'){
78 78
 							if(typeof(document.DetailView.elements['Edit']) != 'undefined'){
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 						}
85 85
 EOQ;
86 86
 }
87
-			if(!ACLController::checkAccess($this->module,'delete', $this->is_owner)){
87
+			if (!ACLController::checkAccess($this->module, 'delete', $this->is_owner)) {
88 88
 			$script .= <<<EOQ
89 89
 						if(typeof(document.DetailView) != 'undefined'){
90 90
 							if(typeof(document.DetailView.elements['Delete']) != 'undefined'){
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 EOQ;
95 95
 }
96 96
 		}
97
-		if(file_exists('modules/'. $this->module . '/metadata/acldefs.php')){
98
-			include('modules/'. $this->module . '/metadata/acldefs.php');
97
+		if (file_exists('modules/'.$this->module.'/metadata/acldefs.php')) {
98
+			include('modules/'.$this->module.'/metadata/acldefs.php');
99 99
 
100
-			foreach($acldefs[$this->module]['forms'] as $form_name=>$form){
100
+			foreach ($acldefs[$this->module]['forms'] as $form_name=>$form) {
101 101
 
102
-				foreach($form as $field_name=>$field){
102
+				foreach ($form as $field_name=>$field) {
103 103
 
104
-					if($field['app_action'] == $action){
105
-						switch($form_name){
104
+					if ($field['app_action'] == $action) {
105
+						switch ($form_name) {
106 106
 							case 'by_id':
107 107
 								$script .= $this->getFieldByIdScript($field_name, $field);
108 108
 								break;
@@ -118,19 +118,19 @@  discard block
 block discarded – undo
118 118
 				}
119 119
 			}
120 120
 		}
121
-		$script .=  '</SCRIPT>';
121
+		$script .= '</SCRIPT>';
122 122
 
123 123
 		return $script;
124 124
 
125 125
 
126 126
 	}
127 127
 
128
-	function getHTMLValues($def){
128
+	function getHTMLValues($def) {
129 129
 		$return_array = array();
130
-		switch($def['display_option']){
130
+		switch ($def['display_option']) {
131 131
 			case 'clear_link':
132
-				$return_array['href']= "#";
133
-				$return_array['className']= "nolink";
132
+				$return_array['href'] = "#";
133
+				$return_array['className'] = "nolink";
134 134
 				break;
135 135
 			default;
136 136
 				$return_array[$def['display_option']] = $def['display_option'];
@@ -141,23 +141,23 @@  discard block
 block discarded – undo
141 141
 
142 142
 	}
143 143
 
144
-	function getFieldByIdScript($name, $def){
144
+	function getFieldByIdScript($name, $def) {
145 145
 		$script = '';
146
-		if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
147
-		foreach($this->getHTMLValues($def) as $key=>$value){
148
-			$script .=  "\nif(document.getElementById('$name'))document.getElementById('$name')." . $key . '="' .$value. '";'. "\n";
146
+		if (!ACLController::checkAccess($def['module'], $def['action_option'], true)) {
147
+		foreach ($this->getHTMLValues($def) as $key=>$value) {
148
+			$script .= "\nif(document.getElementById('$name'))document.getElementById('$name').".$key.'="'.$value.'";'."\n";
149 149
 		}
150 150
 		}
151 151
 		return $script;
152 152
 
153 153
 	}
154 154
 
155
-	function getFieldByNameScript($name, $def){
155
+	function getFieldByNameScript($name, $def) {
156 156
 		$script = '';
157
-		if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
157
+		if (!ACLController::checkAccess($def['module'], $def['action_option'], true)) {
158 158
 
159
-		foreach($this->getHTMLValues($def) as $key=>$value){
160
-			$script .=  <<<EOQ
159
+		foreach ($this->getHTMLValues($def) as $key=>$value) {
160
+			$script .= <<<EOQ
161 161
 			var aclfields = document.getElementsByName('$name');
162 162
 			for(var i in aclfields){
163 163
 				aclfields[i].$key = '$value';
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 
170 170
 	}
171 171
 
172
-	function getFieldByFormScript($form, $name, $def){
172
+	function getFieldByFormScript($form, $name, $def) {
173 173
 		$script = '';
174 174
 
175 175
 
176
-		if(!ACLController::checkAccess($def['module'], $def['action_option'], true)){
177
-			foreach($this->getHTMLValues($def) as $key=>$value){
178
-				$script .= "\nif(typeof(document.$form.$name.$key) != 'undefined')\n document.$form.$name.".$key . '="' .$value. '";';
176
+		if (!ACLController::checkAccess($def['module'], $def['action_option'], true)) {
177
+			foreach ($this->getHTMLValues($def) as $key=>$value) {
178
+				$script .= "\nif(typeof(document.$form.$name.$key) != 'undefined')\n document.$form.$name.".$key.'="'.$value.'";';
179 179
 			}
180 180
 		}
181 181
 		return $script;
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.
modules/AOS_Products/views/view.edit.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  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
 require_once('include/MVC/View/views/view.edit.php');
5 5
 
6 6
 class AOS_ProductsViewEdit extends ViewEdit {
7
-	function __construct(){
7
+	function __construct() {
8 8
  		parent::__construct();
9 9
  	}
10 10
 
11 11
     /**
12 12
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
13 13
      */
14
-    function AOS_ProductsViewEdit(){
14
+    function AOS_ProductsViewEdit() {
15 15
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
16
-        if(isset($GLOBALS['log'])) {
16
+        if (isset($GLOBALS['log'])) {
17 17
             $GLOBALS['log']->deprecated($deprecatedMessage);
18 18
         }
19 19
         else {
@@ -23,22 +23,22 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
 
26
-    function display(){
26
+    function display() {
27 27
 
28
-        global $app_strings,$sugar_config;
28
+        global $app_strings, $sugar_config;
29 29
 
30 30
         isset($this->bean->product_image) ? $image = $this->bean->product_image : $image = '';
31 31
 
32 32
 
33
-        $temp = str_replace($sugar_config['site_url'].'/'.$sugar_config['upload_dir'],"", $image);
33
+        $temp = str_replace($sugar_config['site_url'].'/'.$sugar_config['upload_dir'], "", $image);
34 34
         $html = '<span id=\'new_attachment\' style=\'display:';
35
-        if(!empty($this->bean->product_image)){
35
+        if (!empty($this->bean->product_image)) {
36 36
             $html .= 'none';
37 37
         }
38 38
         $html .= '\'><input name="uploadimage" tabindex="3" type="file" size="60"/>
39 39
         	</span>
40 40
 		<span id=\'old_attachment\' style=\'display:';
41
-        if (empty($image)){
41
+        if (empty($image)) {
42 42
             $html .= 'none';
43 43
         }
44 44
         $html .= '\'><input type=\'hidden\' id=\'deleteAttachment\' name=\'deleteAttachment\' value=\'0\'>
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		<input type=\'button\' class=\'button\' value=\''.$app_strings['LBL_REMOVE'].'\' onclick=\'deleteProductImage();\' >
47 47
 		</span>';
48 48
 
49
-        $this->ss->assign('PRODUCT_IMAGE',$html);
49
+        $this->ss->assign('PRODUCT_IMAGE', $html);
50 50
         parent::display();
51 51
     }
52 52
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.