Completed
Push — console-installer ( e2b50d...6ce748 )
by Adam
22:30
created
modules/Campaigns/WizardNewsletterSave.php 1 patch
Spacing   +78 added lines, -78 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.
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 
52 52
     //create new campaign bean and populate
53 53
     $campaign_focus = new Campaign();
54
-    if(isset($_REQUEST['record']) && $_REQUEST['record'] && !(isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id'])) {
54
+    if (isset($_REQUEST['record']) && $_REQUEST['record'] && !(isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id'])) {
55 55
         $campaign_focus->retrieve($_REQUEST['record']);
56 56
     }
57
-    else if(isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id']) {
57
+    else if (isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id']) {
58 58
         $campaign_focus->retrieve($_REQUEST['campaign_id']);
59 59
     }
60 60
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 
64 64
     $campaign_focus = populateFromPost('', $campaign_focus);
65 65
 
66
-    foreach($camp_steps as $step){
67
-       $campaign_focus =  populate_wizard_bean_from_request($campaign_focus,$step);
66
+    foreach ($camp_steps as $step) {
67
+       $campaign_focus = populate_wizard_bean_from_request($campaign_focus, $step);
68 68
     }
69 69
 
70
-    switch($_REQUEST['currentstep']) {
70
+    switch ($_REQUEST['currentstep']) {
71 71
         case 1;
72 72
             //save here so we can link relationships
73 73
             $campaign_focus->save();
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             break;
77 77
         case 2;
78 78
             //process subscription lists if this is a newsletter
79
-            if($campaign_focus->campaign_type =='NewsLetter'){
79
+            if ($campaign_focus->campaign_type == 'NewsLetter') {
80 80
                 $pl_list = process_subscriptions_from_request($campaign_focus->name);
81 81
 
82 82
                 $campaign_focus->load_relationship('prospectlists');
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 $ui_ids = array();
85 85
 
86 86
                 //for each list returned, add the list to the relationship
87
-                foreach($pl_list as $pl){
87
+                foreach ($pl_list as $pl) {
88 88
                     $campaign_focus->prospectlists->add($pl->id);
89 89
                     //populate array with id's from UI'
90 90
                     $ui_ids[] = $pl->id;
@@ -92,30 +92,30 @@  discard block
 block discarded – undo
92 92
 
93 93
                 //now remove the lists that may have existed before, but were not specified in UI.
94 94
                 //this will enforce that Newsletters only have 3 available target lists.
95
-                foreach($existing_pls as $pl_del){
96
-                    if (!in_array($pl_del, $ui_ids)){
95
+                foreach ($existing_pls as $pl_del) {
96
+                    if (!in_array($pl_del, $ui_ids)) {
97 97
                         $campaign_focus->prospectlists->delete($campaign_focus->id, $pl_del);
98 98
                     }
99 99
                 }
100
-            } else{
100
+            } else {
101 101
                 //process target lists if this is not a newsletter
102 102
                 //remove Target Lists if defined
103 103
 
104
-                if(isset($_REQUEST['wiz_remove_target_list'])){
104
+                if (isset($_REQUEST['wiz_remove_target_list'])) {
105 105
 
106 106
                     $remove_target_strings = explode(",", $_REQUEST['wiz_remove_target_list']);
107
-                    foreach($remove_target_strings as $remove_trgt_string){
108
-                        if(!empty($remove_trgt_string)){
107
+                    foreach ($remove_target_strings as $remove_trgt_string) {
108
+                        if (!empty($remove_trgt_string)) {
109 109
                             //load relationship and add to the list
110 110
                             $campaign_focus->load_relationship('prospectlists');
111
-                            $campaign_focus->prospectlists->delete($campaign_focus->id,$remove_trgt_string);
111
+                            $campaign_focus->prospectlists->delete($campaign_focus->id, $remove_trgt_string);
112 112
                         }
113 113
                     }
114 114
                 }
115 115
 
116 116
 
117 117
                 //create new campaign tracker and save if defined
118
-                if(isset($_REQUEST['wiz_list_of_targets'])) {
118
+                if (isset($_REQUEST['wiz_list_of_targets'])) {
119 119
                     $target_strings = explode(",", $_REQUEST['wiz_list_of_targets']);
120 120
                     foreach ($target_strings as $trgt_string) {
121 121
                         $target_values = explode("@@", $trgt_string);
@@ -152,27 +152,27 @@  discard block
 block discarded – undo
152 152
 
153 153
 
154 154
             //remove campaign trackers if defined
155
-            if(isset($_REQUEST['wiz_remove_tracker_list'])) {
155
+            if (isset($_REQUEST['wiz_remove_tracker_list'])) {
156 156
 
157 157
                 $remove_tracker_strings = explode(",", $_REQUEST['wiz_remove_tracker_list']);
158
-                foreach($remove_tracker_strings as $remove_trkr_string){
159
-                    if(!empty($remove_trkr_string)){
158
+                foreach ($remove_tracker_strings as $remove_trkr_string) {
159
+                    if (!empty($remove_trkr_string)) {
160 160
                         //load relationship and add to the list
161 161
                         $campaign_focus->load_relationship('tracked_urls');
162
-                        $campaign_focus->tracked_urls->delete($campaign_focus->id,$remove_trkr_string);
162
+                        $campaign_focus->tracked_urls->delete($campaign_focus->id, $remove_trkr_string);
163 163
                     }
164 164
                 }
165 165
             }
166 166
 
167 167
 
168 168
             //save  campaign trackers and save if defined
169
-            if(isset($_REQUEST['wiz_list_of_existing_trackers'])) {
169
+            if (isset($_REQUEST['wiz_list_of_existing_trackers'])) {
170 170
                 $tracker_strings = explode(",", $_REQUEST['wiz_list_of_existing_trackers']);
171
-                foreach($tracker_strings as $trkr_string){
171
+                foreach ($tracker_strings as $trkr_string) {
172 172
                     $tracker_values = explode("@@", $trkr_string);
173 173
                     $ct_focus = new CampaignTracker();
174 174
                     $ct_focus->retrieve($tracker_values[0]);
175
-                    if(!empty($ct_focus->tracker_name)){
175
+                    if (!empty($ct_focus->tracker_name)) {
176 176
                         $ct_focus->tracker_name = $tracker_values[1];
177 177
                         $ct_focus->is_optout = $tracker_values[2];
178 178
                         $ct_focus->tracker_url = $tracker_values[3];
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 
188 188
 
189 189
             //create new campaign tracker and save if defined
190
-            if(isset($_REQUEST['wiz_list_of_trackers'])){
190
+            if (isset($_REQUEST['wiz_list_of_trackers'])) {
191 191
                 $tracker_strings = explode(",", $_REQUEST['wiz_list_of_trackers']);
192
-                foreach($tracker_strings as $trkr_string){
192
+                foreach ($tracker_strings as $trkr_string) {
193 193
                     $tracker_values = explode("@@", $trkr_string);
194
-                    if(count($tracker_values)==3){
194
+                    if (count($tracker_values) == 3) {
195 195
                         $ct_focus = new CampaignTracker();
196 196
                         $ct_focus->tracker_name = $tracker_values[0];
197 197
                         $ct_focus->is_optout = $tracker_values[1];
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
             $action = '';
218 218
             $redirectToTargetList = '';
219
-            if(isset($_REQUEST['wiz_direction'])){
219
+            if (isset($_REQUEST['wiz_direction'])) {
220 220
 
221
-                switch($_REQUEST['wiz_direction']) {
221
+                switch ($_REQUEST['wiz_direction']) {
222 222
                     case 'continue':
223 223
                     $action = 'WizardMarketing';
224 224
                         break;
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
                          $action = 'WizardMarketing';
231 231
                         break;
232 232
                 }
233
-            }else{
233
+            } else {
234 234
                 $action = 'WizardHome&record='.$campaign_focus->id;
235 235
             }
236 236
             //require_once('modules/Campaigns/WizardMarketing.php');
237 237
             $header_URL = "Location: index.php?return_module=Campaigns&module=Campaigns&action=".$action.$redirectToTargetList."&campaign_id=".$campaign_focus->id."&return_action=WizardNewsLetter&return_id=".$campaign_focus->id;
238 238
             $GLOBALS['log']->debug("about to post header URL of: $header_URL");
239 239
 
240
-            if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
240
+            if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
241 241
                 $href = $matches[1];
242 242
                 SugarApplication::redirect($href);
243 243
             }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
             break;
249 249
         case 3:
250 250
             //process subscription lists if this is a newsletter
251
-            if($campaign_focus->campaign_type =='NewsLetter'){
251
+            if ($campaign_focus->campaign_type == 'NewsLetter') {
252 252
                 $pl_list = process_subscriptions_from_request($campaign_focus->name);
253 253
 
254 254
                 $campaign_focus->load_relationship('prospectlists');
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 $ui_ids = array();
257 257
 
258 258
                 //for each list returned, add the list to the relationship
259
-                foreach($pl_list as $pl){
259
+                foreach ($pl_list as $pl) {
260 260
                     $campaign_focus->prospectlists->add($pl->id);
261 261
                     //populate array with id's from UI'
262 262
                     $ui_ids[] = $pl->id;
@@ -264,30 +264,30 @@  discard block
 block discarded – undo
264 264
 
265 265
                 //now remove the lists that may have existed before, but were not specified in UI.
266 266
                 //this will enforce that Newsletters only have 3 available target lists.
267
-                foreach($existing_pls as $pl_del){
268
-                    if (!in_array($pl_del, $ui_ids)){
267
+                foreach ($existing_pls as $pl_del) {
268
+                    if (!in_array($pl_del, $ui_ids)) {
269 269
                         $campaign_focus->prospectlists->delete($campaign_focus->id, $pl_del);
270 270
                     }
271 271
                 }
272
-            } else{
272
+            } else {
273 273
                 //process target lists if this is not a newsletter
274 274
                 //remove Target Lists if defined
275 275
 
276
-                if(isset($_REQUEST['wiz_remove_target_list'])){
276
+                if (isset($_REQUEST['wiz_remove_target_list'])) {
277 277
 
278 278
                     $remove_target_strings = explode(",", $_REQUEST['wiz_remove_target_list']);
279
-                    foreach($remove_target_strings as $remove_trgt_string){
280
-                        if(!empty($remove_trgt_string)){
279
+                    foreach ($remove_target_strings as $remove_trgt_string) {
280
+                        if (!empty($remove_trgt_string)) {
281 281
                             //load relationship and add to the list
282 282
                             $campaign_focus->load_relationship('prospectlists');
283
-                            $campaign_focus->prospectlists->delete($campaign_focus->id,$remove_trgt_string);
283
+                            $campaign_focus->prospectlists->delete($campaign_focus->id, $remove_trgt_string);
284 284
                         }
285 285
                     }
286 286
                 }
287 287
 
288 288
 
289 289
                 //create new campaign tracker and save if defined
290
-                if(isset($_REQUEST['wiz_list_of_targets'])) {
290
+                if (isset($_REQUEST['wiz_list_of_targets'])) {
291 291
                     $target_strings = explode(",", $_REQUEST['wiz_list_of_targets']);
292 292
                     foreach ($target_strings as $trgt_string) {
293 293
                         $target_values = explode("@@", $trgt_string);
@@ -324,27 +324,27 @@  discard block
 block discarded – undo
324 324
 
325 325
 
326 326
             //remove campaign trackers if defined
327
-            if(isset($_REQUEST['wiz_remove_tracker_list'])) {
327
+            if (isset($_REQUEST['wiz_remove_tracker_list'])) {
328 328
 
329 329
                 $remove_tracker_strings = explode(",", $_REQUEST['wiz_remove_tracker_list']);
330
-                foreach($remove_tracker_strings as $remove_trkr_string){
331
-                    if(!empty($remove_trkr_string)){
330
+                foreach ($remove_tracker_strings as $remove_trkr_string) {
331
+                    if (!empty($remove_trkr_string)) {
332 332
                         //load relationship and add to the list
333 333
                         $campaign_focus->load_relationship('tracked_urls');
334
-                        $campaign_focus->tracked_urls->delete($campaign_focus->id,$remove_trkr_string);
334
+                        $campaign_focus->tracked_urls->delete($campaign_focus->id, $remove_trkr_string);
335 335
                     }
336 336
                 }
337 337
             }
338 338
 
339 339
 
340 340
             //save  campaign trackers and save if defined
341
-            if(isset($_REQUEST['wiz_list_of_existing_trackers'])) {
341
+            if (isset($_REQUEST['wiz_list_of_existing_trackers'])) {
342 342
                 $tracker_strings = explode(",", $_REQUEST['wiz_list_of_existing_trackers']);
343
-                foreach($tracker_strings as $trkr_string){
343
+                foreach ($tracker_strings as $trkr_string) {
344 344
                     $tracker_values = explode("@@", $trkr_string);
345 345
                     $ct_focus = new CampaignTracker();
346 346
                     $ct_focus->retrieve($tracker_values[0]);
347
-                    if(!empty($ct_focus->tracker_name)){
347
+                    if (!empty($ct_focus->tracker_name)) {
348 348
                         $ct_focus->tracker_name = $tracker_values[1];
349 349
                         $ct_focus->is_optout = $tracker_values[2];
350 350
                         $ct_focus->tracker_url = $tracker_values[3];
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 
360 360
 
361 361
             //create new campaign tracker and save if defined
362
-            if(isset($_REQUEST['wiz_list_of_trackers'])){
362
+            if (isset($_REQUEST['wiz_list_of_trackers'])) {
363 363
                 $tracker_strings = explode(",", $_REQUEST['wiz_list_of_trackers']);
364
-                foreach($tracker_strings as $trkr_string){
364
+                foreach ($tracker_strings as $trkr_string) {
365 365
                     $tracker_values = explode("@@", $trkr_string);
366
-                    if(count($tracker_values)==3){
366
+                    if (count($tracker_values) == 3) {
367 367
                         $ct_focus = new CampaignTracker();
368 368
                         $ct_focus->tracker_name = $tracker_values[0];
369 369
                         $ct_focus->is_optout = $tracker_values[1];
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 
389 389
             $action = '';
390 390
             $redirectToTargetList = '';
391
-            if(isset($_REQUEST['wiz_direction'])){
391
+            if (isset($_REQUEST['wiz_direction'])) {
392 392
 
393
-                switch($_REQUEST['wiz_direction']) {
393
+                switch ($_REQUEST['wiz_direction']) {
394 394
                     case 'continue':
395 395
                         $action = 'WizardMarketing';
396 396
                         break;
@@ -402,13 +402,13 @@  discard block
 block discarded – undo
402 402
                         $action = 'WizardHome';
403 403
                         break;
404 404
                 }
405
-            }else{
405
+            } else {
406 406
                 $action = 'WizardHome&record='.$campaign_focus->id;
407 407
             }
408 408
             //require_once('modules/Campaigns/WizardMarketing.php');
409 409
             $header_URL = "Location: index.php?return_module=Campaigns&module=Campaigns&action=".$action.$redirectToTargetList."&campaign_id=".$campaign_focus->id."&record=".$campaign_focus->id;
410 410
             $GLOBALS['log']->debug("about to post header URL of: $header_URL");
411
-            if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
411
+            if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
412 412
                 $href = $matches[1];
413 413
                 SugarApplication::redirect($href);
414 414
             }
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
  * This function will populate the passed in bean with the post variables
426 426
  * that contain the specified prefix
427 427
  */
428
-function populate_wizard_bean_from_request($bean,$prefix){
429
-    foreach($_REQUEST as $key=> $val){
428
+function populate_wizard_bean_from_request($bean, $prefix) {
429
+    foreach ($_REQUEST as $key=> $val) {
430 430
      $key = trim($key);
431
-     if((strstr($key, $prefix )) && (strpos($key, $prefix )== 0)){
432
-          $field  =substr($key, strlen($prefix)) ;
433
-          if(isset($_REQUEST[$key]) && !empty($_REQUEST[$key])){
431
+     if ((strstr($key, $prefix)) && (strpos($key, $prefix) == 0)) {
432
+          $field = substr($key, strlen($prefix));
433
+          if (isset($_REQUEST[$key]) && !empty($_REQUEST[$key])) {
434 434
               //echo "prefix is $prefix, field is $field,    key is $key,   and value is $val<br>";
435 435
               $value = $_REQUEST[$key];
436 436
               $bean->$field = $value;
@@ -447,34 +447,34 @@  discard block
 block discarded – undo
447 447
  * If no prospect lists have been specified, then it will create one for you.  A total of 3 prospect lists
448 448
  * will be created for you (Subscription, Unsubscription, and test)
449 449
  */
450
-function process_subscriptions_from_request($campaign_name){
450
+function process_subscriptions_from_request($campaign_name) {
451 451
     global $mod_strings;
452 452
     $pl_list = array();
453 453
 
454 454
     //process default target list
455 455
     $create_new = true;
456 456
     $pl_subs = new ProspectList($campaign_name);
457
-    if(!empty($_REQUEST['wiz_step3_subscription_list_id'])){
457
+    if (!empty($_REQUEST['wiz_step3_subscription_list_id'])) {
458 458
         //if subscription list is specified then attach
459 459
         $pl_subs->retrieve($_REQUEST['wiz_step3_subscription_list_id']);
460 460
         //check to see name matches the bean, if not, then the user has chosen to create new bean
461
-        if($pl_subs->name == $_REQUEST['wiz_step3_subscription_name']){
461
+        if ($pl_subs->name == $_REQUEST['wiz_step3_subscription_name']) {
462 462
             $pl_list[] = $pl_subs;
463 463
             $create_new = false;
464 464
        }
465 465
 
466 466
     }
467 467
     //create new bio if one was not retrieved successfully
468
-    if($create_new){
468
+    if ($create_new) {
469 469
         //use default name if one has not been specified
470
-        $name = $campaign_name . " ".$mod_strings['LBL_SUBSCRIPTION_LIST'];
471
-        if(isset($_REQUEST['wiz_step3_subscription_name']) && !empty($_REQUEST['wiz_step3_subscription_name'])){
470
+        $name = $campaign_name." ".$mod_strings['LBL_SUBSCRIPTION_LIST'];
471
+        if (isset($_REQUEST['wiz_step3_subscription_name']) && !empty($_REQUEST['wiz_step3_subscription_name'])) {
472 472
             $name = $_REQUEST['wiz_step3_subscription_name'];
473 473
         }
474 474
         //if subscription list is not specified then create and attach default one
475 475
         $pl_subs->name = $name;
476 476
         $pl_subs->list_type = 'default';
477
-        $pl_subs->assigned_user_id= $GLOBALS['current_user']->id;
477
+        $pl_subs->assigned_user_id = $GLOBALS['current_user']->id;
478 478
         $pl_subs->save();
479 479
         $pl_list[] = $pl_subs;
480 480
     }
@@ -482,27 +482,27 @@  discard block
 block discarded – undo
482 482
     //process exempt target list
483 483
     $create_new = true;
484 484
     $pl_un_subs = new ProspectList();
485
-    if(!empty($_REQUEST['wiz_step3_unsubscription_list_id'])){
485
+    if (!empty($_REQUEST['wiz_step3_unsubscription_list_id'])) {
486 486
         //if unsubscription list is specified then attach
487 487
         $pl_un_subs->retrieve($_REQUEST['wiz_step3_unsubscription_list_id']);
488 488
         //check to see name matches the bean, if not, then the user has chosen to create new bean
489
-        if($pl_un_subs->name == $_REQUEST['wiz_step3_unsubscription_name']){
489
+        if ($pl_un_subs->name == $_REQUEST['wiz_step3_unsubscription_name']) {
490 490
             $pl_list[] = $pl_un_subs;
491 491
             $create_new = false;
492 492
        }
493 493
 
494 494
     }
495 495
     //create new bean if one was not retrieved successfully
496
-    if($create_new){
496
+    if ($create_new) {
497 497
         //use default name if one has not been specified
498
-        $name = $campaign_name . " ".$mod_strings['LBL_UNSUBSCRIPTION_LIST'];
499
-        if(isset($_REQUEST['wiz_step3_unsubscription_name']) && !empty($_REQUEST['wiz_step3_unsubscription_name'])){
498
+        $name = $campaign_name." ".$mod_strings['LBL_UNSUBSCRIPTION_LIST'];
499
+        if (isset($_REQUEST['wiz_step3_unsubscription_name']) && !empty($_REQUEST['wiz_step3_unsubscription_name'])) {
500 500
             $name = $_REQUEST['wiz_step3_unsubscription_name'];
501 501
         }
502 502
         //if unsubscription list is not specified then create and attach default one
503 503
         $pl_un_subs->name = $name;
504 504
         $pl_un_subs->list_type = 'exempt';
505
-        $pl_un_subs->assigned_user_id= $GLOBALS['current_user']->id;
505
+        $pl_un_subs->assigned_user_id = $GLOBALS['current_user']->id;
506 506
         $pl_un_subs->save();
507 507
         $pl_list[] = $pl_un_subs;
508 508
     }
@@ -510,26 +510,26 @@  discard block
 block discarded – undo
510 510
     //process test target list
511 511
     $pl_test = new ProspectList();
512 512
     $create_new = true;
513
-    if(!empty($_REQUEST['wiz_step3_test_list_id'])){
513
+    if (!empty($_REQUEST['wiz_step3_test_list_id'])) {
514 514
         //if test list is specified then attach
515 515
         $pl_test->retrieve($_REQUEST['wiz_step3_test_list_id']);
516 516
         //check to see name matches the bean, if not, then the user has chosen to create new bean
517
-        if($pl_test->name == $_REQUEST['wiz_step3_test_name']){
517
+        if ($pl_test->name == $_REQUEST['wiz_step3_test_name']) {
518 518
             $pl_list[] = $pl_test;
519 519
             $create_new = false;
520 520
         }
521 521
     }
522 522
     //create new bio if one was not retrieved successfully
523
-    if($create_new){
523
+    if ($create_new) {
524 524
         //use default name if one has not been specified
525
-        $name = $campaign_name . " ".$mod_strings['LBL_TEST_LIST'];
526
-        if(isset($_REQUEST['wiz_step3_test_name']) && !empty($_REQUEST['wiz_step3_test_name'])){
525
+        $name = $campaign_name." ".$mod_strings['LBL_TEST_LIST'];
526
+        if (isset($_REQUEST['wiz_step3_test_name']) && !empty($_REQUEST['wiz_step3_test_name'])) {
527 527
             $name = $_REQUEST['wiz_step3_test_name'];
528 528
         }
529 529
         //if test list is not specified then create and attach default one
530 530
         $pl_test->name = $name;
531 531
         $pl_test->list_type = 'test';
532
-        $pl_test->assigned_user_id= $GLOBALS['current_user']->id;
532
+        $pl_test->assigned_user_id = $GLOBALS['current_user']->id;
533 533
         $pl_test->save();
534 534
         $pl_list[] = $pl_test;
535 535
     }
Please login to merge, or discard this patch.
modules/Campaigns/WizardNewsletter.php 1 patch
Spacing   +140 added lines, -140 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.
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 /*************** GENERAL SETUP WORK **********/
65 65
 
66 66
 $focus = new Campaign();
67
-if(isset($_REQUEST['record'])) {
67
+if (isset($_REQUEST['record'])) {
68 68
     $focus->retrieve($_REQUEST['record']);
69 69
 }
70
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
70
+if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
71 71
     $focus->id = "";
72 72
 }
73 73
 global $theme;
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 
79 79
 $GLOBALS['log']->info("Campaign NewsLetter Wizard");
80 80
 
81
-if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
81
+if ((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] == 1) || ($focus->campaign_type == 'NewsLetter')) {
82 82
     echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_NEWSLETTER WIZARD_TITLE'].$focus->name), true, false);
83
-}else{
83
+} else {
84 84
     echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_CAMPAIGN'].$focus->name), true, false);   
85 85
 }
86 86
 
@@ -104,26 +104,26 @@  discard block
 block discarded – undo
104 104
 $sqs_objects = array('parent_name' => $qsd->getQSParent(), 
105 105
                     'assigned_user_name' => $qsd->getQSUser(),
106 106
                     //'prospect_list_name' => getProspectListQSObjects(),
107
-                    'test_name' => getProspectListQSObjects('prospect_list_type_test', 'test_name','wiz_step3_test_name_id'),
108
-                    'unsubscription_name' => getProspectListQSObjects('prospect_list_type_exempt', 'unsubscription_name','wiz_step3_unsubscription_name_id'),
109
-                    'subscription_name' => getProspectListQSObjects('prospect_list_type_default', 'subscription_name','wiz_step3_subscription_name_id'),
107
+                    'test_name' => getProspectListQSObjects('prospect_list_type_test', 'test_name', 'wiz_step3_test_name_id'),
108
+                    'unsubscription_name' => getProspectListQSObjects('prospect_list_type_exempt', 'unsubscription_name', 'wiz_step3_unsubscription_name_id'),
109
+                    'subscription_name' => getProspectListQSObjects('prospect_list_type_default', 'subscription_name', 'wiz_step3_subscription_name_id'),
110 110
                     );
111 111
                     
112 112
 
113
-$quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
113
+$quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = '.$json->encode($sqs_objects).'</script>';
114 114
 
115 115
 $ss->assign("JAVASCRIPT", $quicksearch_js);
116 116
 
117 117
 
118 118
 //set the campaign type based on wizardtype value from request object
119 119
 $campaign_type = 'newsletter';
120
-if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
120
+if ((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] == 1) || ($focus->campaign_type == 'NewsLetter')) {
121 121
     $campaign_type = 'newsletter';
122 122
     $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());    
123
-}elseif( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==2)  || ($focus->campaign_type=='Email') ){
123
+}elseif ((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] == 2) || ($focus->campaign_type == 'Email')) {
124 124
     $campaign_type = 'email';
125 125
     $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
126
-}else{
126
+} else {
127 127
     $campaign_type = 'general';
128 128
 }
129 129
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 //set default values
145 145
 $ss->assign("CALENDAR_LANG", "en");
146
-$ss->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
146
+$ss->assign("USER_DATEFORMAT", '('.$timedate->get_user_date_format().')');
147 147
 $ss->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
148 148
 $ss->assign("CAMP_DATE_ENTERED", $focus->date_entered);
149 149
 $ss->assign("CAMP_DATE_MODIFIED", $focus->date_modified);
@@ -170,50 +170,50 @@  discard block
 block discarded – undo
170 170
 
171 171
 $focus->list_view_parse_additional_sections($ss);
172 172
 
173
-$ss->assign("ASSIGNED_USER_ID", $focus->assigned_user_id );
173
+$ss->assign("ASSIGNED_USER_ID", $focus->assigned_user_id);
174 174
 
175
-if((!isset($focus->status)) && (!isset($focus->id)))
175
+if ((!isset($focus->status)) && (!isset($focus->id)))
176 176
     $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], 'Planning'));
177 177
 else
178 178
     $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], $focus->status));
179 179
 
180 180
 //hide frequency options if this is not a newsletter
181
-if($campaign_type == 'newsletter'){
181
+if ($campaign_type == 'newsletter') {
182 182
     $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "Select");
183 183
     $ss->assign("FREQUENCY_LABEL", $mod_strings['LBL_CAMPAIGN_FREQUENCY']);
184
-    if((!isset($focus->frequency)) && (!isset($focus->id))){
184
+    if ((!isset($focus->frequency)) && (!isset($focus->id))) {
185 185
         $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], 'Monthly'));
186
-    }else{
186
+    } else {
187 187
         $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], $focus->frequency));
188 188
     }
189
-}else{
189
+} else {
190 190
     $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "input type='hidden'");
191 191
     $ss->assign("FREQUENCY_LABEL", '&nbsp;');
192 192
 }
193 193
 global $current_user;
194 194
 require_once('modules/Currencies/ListCurrency.php');
195 195
 $currency = new ListCurrency();
196
-if(isset($focus->currency_id) && !empty($focus->currency_id)){
196
+if (isset($focus->currency_id) && !empty($focus->currency_id)) {
197 197
     $selectCurrency = $currency->getSelectOptions($focus->currency_id);
198 198
     $ss->assign("CURRENCY", $selectCurrency);
199 199
 }
200
-else if($current_user->getPreference('currency') && !isset($focus->id))
200
+else if ($current_user->getPreference('currency') && !isset($focus->id))
201 201
 {
202 202
     $selectCurrency = $currency->getSelectOptions($current_user->getPreference('currency'));
203 203
     $ss->assign("CURRENCY", $selectCurrency);
204
-}else{
204
+} else {
205 205
 
206 206
     $selectCurrency = $currency->getSelectOptions();
207 207
     $ss->assign("CURRENCY", $selectCurrency);
208 208
 
209 209
 }
210 210
 global $current_user;
211
-if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){  
211
+if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {  
212 212
     $record = '';
213
-    if(!empty($_REQUEST['record'])){
214
-        $record =   $_REQUEST['record'];
213
+    if (!empty($_REQUEST['record'])) {
214
+        $record = $_REQUEST['record'];
215 215
     }
216
-    $ss->assign("ADMIN_EDIT","<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif',$mod_strings['LBL_EDIT_LAYOUT'])."</a>");
216
+    $ss->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action']."&from_module=".$_REQUEST['module']."&record=".$record."'>".SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', $mod_strings['LBL_EDIT_LAYOUT'])."</a>");
217 217
 
218 218
 }
219 219
 
@@ -226,55 +226,55 @@  discard block
 block discarded – undo
226 226
 
227 227
 //fill out the campaign type dropdown based on type of campaign being created
228 228
 $ss->assign("campaign_type", $campaign_type);
229
-if($campaign_type == 'general'){
229
+if ($campaign_type == 'general') {
230 230
     //get regular campaign dom object and strip out entries for email and newsletter
231 231
     $myTypeOptionsArr = array();
232 232
     $OptionsArr = $app_list_strings['campaign_type_dom'];
233
-    foreach($OptionsArr as $key=>$val){
234
-        if($val =='Newsletter' || $val =='Email' || $val =='' ){
233
+    foreach ($OptionsArr as $key=>$val) {
234
+        if ($val == 'Newsletter' || $val == 'Email' || $val == '') {
235 235
             //do not add   
236
-        }else{
236
+        } else {
237 237
             $myTypeOptionsArr[$key] = $val;
238 238
         }
239 239
     }
240 240
     
241 241
     //now create select option html without the newsletter/email, or blank ('') options
242
-    $type_option_html =' ';
242
+    $type_option_html = ' ';
243 243
     $selected = false;
244
-    foreach($myTypeOptionsArr as $optionKey=>$optionName){
244
+    foreach ($myTypeOptionsArr as $optionKey=>$optionName) {
245 245
         //if the selected flag is set to true, then just populate
246
-        if($selected){
247
-            $type_option_html .="<option value='$optionKey' >$optionName</option>";
248
-        }else{//if not selected yet, check to see if this option should be selected
246
+        if ($selected) {
247
+            $type_option_html .= "<option value='$optionKey' >$optionName</option>";
248
+        } else {//if not selected yet, check to see if this option should be selected
249 249
             //if the campaign type is not empty, then select the retrieved type
250
-            if(!empty($focus->campaign_type)){
250
+            if (!empty($focus->campaign_type)) {
251 251
                 //check to see if key matches campaign type
252
-                if($optionKey == $focus->campaign_type){
252
+                if ($optionKey == $focus->campaign_type) {
253 253
                     //mark as selected
254
-                    $type_option_html .="<option value='$optionKey' selected>$optionName</option>";
254
+                    $type_option_html .= "<option value='$optionKey' selected>$optionName</option>";
255 255
                     //mark as selected for next time
256
-                    $selected=true;
257
-                }else{
256
+                    $selected = true;
257
+                } else {
258 258
                     //key does not match, just populate
259
-                    $type_option_html .="<option value='$optionKey' >$optionName</option>";
259
+                    $type_option_html .= "<option value='$optionKey' >$optionName</option>";
260 260
                 }
261
-            }else{
261
+            } else {
262 262
             //since the campaign type is empty, then select first one                
263
-                $type_option_html .="<option value='$optionKey' selected>$optionName</option>";    
263
+                $type_option_html .= "<option value='$optionKey' selected>$optionName</option>";    
264 264
                 //mark as selected for next time
265
-                $selected=true;
265
+                $selected = true;
266 266
             }
267 267
         }    
268 268
     }
269 269
     //assign the modified dropdown for general campaign creation
270 270
     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $type_option_html);
271 271
     $ss->assign("SHOULD_TYPE_BE_DISABLED", "select");    
272
-}elseif($campaign_type == 'email'){
272
+}elseif ($campaign_type == 'email') {
273 273
     //Assign Email as type of campaign being created an disable the select widget
274 274
     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_EMAIL']);
275 275
     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='Email'");
276 276
     $ss->assign("HIDE_CAMPAIGN_TYPE", true);
277
-}else{
277
+} else {
278 278
     //Assign NewsLetter as type of campaign being created an disable the select widget
279 279
     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_NEWSLETTER']);
280 280
     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='NewsLetter'");
@@ -291,33 +291,33 @@  discard block
 block discarded – undo
291 291
 $focus->load_relationship('tracked_urls');
292 292
 
293 293
 $trkr_lists = $focus->tracked_urls->get();
294
-$trkr_html ='';    
295
-$ss->assign('TRACKER_COUNT',count($trkr_lists));
296
-if(count($trkr_lists)>0){
294
+$trkr_html = '';    
295
+$ss->assign('TRACKER_COUNT', count($trkr_lists));
296
+if (count($trkr_lists) > 0) {
297 297
 global $odd_bg, $even_bg, $hilite_bg;
298 298
     
299 299
     $trkr_count = 0;
300 300
 //create the html to create tracker table
301
-    foreach($trkr_lists as $trkr_id){
301
+    foreach ($trkr_lists as $trkr_id) {
302 302
         $ct_focus = new CampaignTracker();
303 303
         $ct_focus->retrieve($trkr_id);
304
-      if(isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)){
305
-            if($ct_focus->is_optout){$opt = 'checked';}else{$opt = '';}
306
-            $trkr_html .= "<div id='existing_trkr".$trkr_count."'> <table width='100%' border='0' cellspacing='0' cellpadding='0'>" ;
307
-            $trkr_html .= "<tr class='evenListRowS1'><td width='15%'><input name='wiz_step3_is_optout".$trkr_count."' title='".$mod_strings['LBL_EDIT_OPT_OUT'] . $trkr_count ."' id='existing_is_optout". $trkr_count ."' class='checkbox' type='checkbox' $opt  /><input name='wiz_step3_id".$trkr_count."' value='".$ct_focus->id."' id='existing_tracker_id". $trkr_count ."'type='hidden''/></td>";
308
-            $trkr_html .= "<td width='40%'> <input id='existing_tracker_name". $trkr_count ."' type='text' size='20' maxlength='255' name='wiz_step3_tracker_name". $trkr_count ."' title='".$mod_strings['LBL_EDIT_TRACKER_NAME']. $trkr_count ."' value='".$ct_focus->tracker_name."' ></td>";
309
-            $trkr_html .= "<td width='40%'><input type='text' size='60' maxlength='255' name='wiz_step3_tracker_url". $trkr_count ."' title='".$mod_strings['LBL_EDIT_TRACKER_URL']. $trkr_count ."' id='existing_tracker_url". $trkr_count ."' value='".$ct_focus->tracker_url."' ></td>";
304
+      if (isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)) {
305
+            if ($ct_focus->is_optout) {$opt = 'checked'; } else {$opt = ''; }
306
+            $trkr_html .= "<div id='existing_trkr".$trkr_count."'> <table width='100%' border='0' cellspacing='0' cellpadding='0'>";
307
+            $trkr_html .= "<tr class='evenListRowS1'><td width='15%'><input name='wiz_step3_is_optout".$trkr_count."' title='".$mod_strings['LBL_EDIT_OPT_OUT'].$trkr_count."' id='existing_is_optout".$trkr_count."' class='checkbox' type='checkbox' $opt  /><input name='wiz_step3_id".$trkr_count."' value='".$ct_focus->id."' id='existing_tracker_id".$trkr_count."'type='hidden''/></td>";
308
+            $trkr_html .= "<td width='40%'> <input id='existing_tracker_name".$trkr_count."' type='text' size='20' maxlength='255' name='wiz_step3_tracker_name".$trkr_count."' title='".$mod_strings['LBL_EDIT_TRACKER_NAME'].$trkr_count."' value='".$ct_focus->tracker_name."' ></td>";
309
+            $trkr_html .= "<td width='40%'><input type='text' size='60' maxlength='255' name='wiz_step3_tracker_url".$trkr_count."' title='".$mod_strings['LBL_EDIT_TRACKER_URL'].$trkr_count."' id='existing_tracker_url".$trkr_count."' value='".$ct_focus->tracker_url."' ></td>";
310 310
             $trkr_html .= "<td><a href='#' onclick=\"javascript:remove_existing_tracker('existing_trkr".$trkr_count."','".$ct_focus->id."'); \" >  ";
311 311
             $trkr_html .= SugarThemeRegistry::current()->getImage('delete_inline', "border='0'  align='absmiddle'", 12, 12, ".gif", $mod_strings['LBL_DELETE'])."</a></td></tr></table></div>";
312 312
 
313 313
 
314 314
 
315 315
       }
316
-      $trkr_count =$trkr_count+1;
316
+      $trkr_count = $trkr_count + 1;
317 317
     }
318 318
     
319 319
     $trkr_html .= "<div id='no_trackers'></div>";
320
-    }else{
320
+    } else {
321 321
         $trkr_html .= "<div id='no_trackers'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
322 322
     }
323 323
     $ss->assign('EXISTING_TRACKERS', $trkr_html);
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 $targetList = BeanFactory::getBean('ProspectLists')->get_full_list();
397 397
 
398 398
 $targetListData = array();
399
-foreach($targetList as $prospectLst) {
399
+foreach ($targetList as $prospectLst) {
400 400
     $nxt = array(
401 401
         'id' => $prospectLst->id,
402 402
         'name' => $prospectLst->name,
@@ -425,29 +425,29 @@  discard block
 block discarded – undo
425 425
 
426 426
 $prospect_lists = $focus->prospectlists->get();
427 427
 
428
-if((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] ==1) || ($focus->campaign_type=='NewsLetter')){
428
+if ((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] == 1) || ($focus->campaign_type == 'NewsLetter')) {
429 429
  //this is a newsletter type campaign, fill in subscription values   
430 430
 
431 431
 //if prospect lists are returned, then iterate through and populate form values
432
-if(count($prospect_lists)>0){
432
+if (count($prospect_lists) > 0) {
433 433
     
434
-    foreach($prospect_lists as $pl_id){
434
+    foreach ($prospect_lists as $pl_id) {
435 435
     //retrieve prospect list
436 436
      $pl = new ProspectList();   
437 437
      $pl->retrieve($pl_id);
438 438
 
439
-      if(isset($pl->list_type) && !empty($pl->list_type)){
439
+      if (isset($pl->list_type) && !empty($pl->list_type)) {
440 440
          //assign values based on type
441
-         if(($pl->list_type == 'default') || ($pl->list_type == 'seed')){            
441
+         if (($pl->list_type == 'default') || ($pl->list_type == 'seed')) {            
442 442
             $ss->assign('SUBSCRIPTION_ID', $pl->id);
443 443
             $ss->assign('SUBSCRIPTION_NAME', $pl->name);
444 444
          };
445
-         if($pl->list_type == 'exempt'){
445
+         if ($pl->list_type == 'exempt') {
446 446
             $ss->assign('UNSUBSCRIPTION_ID', $pl->id);
447 447
             $ss->assign('UNSUBSCRIPTION_NAME', $pl->name);
448 448
          
449 449
          };
450
-         if($pl->list_type == 'test'){
450
+         if ($pl->list_type == 'test') {
451 451
             $ss->assign('TEST_ID', $pl->id);
452 452
             $ss->assign('TEST_NAME', $pl->name);
453 453
          
@@ -459,73 +459,73 @@  discard block
 block discarded – undo
459 459
 
460 460
 
461 461
 
462
-}else{
462
+} else {
463 463
     //this is not a newlsetter campaign, so fill in target list table
464 464
     //create array for javascript, this will help to display the option text, not the value
465
-    $dom_txt =' ';
466
-    foreach($app_list_strings['prospect_list_type_dom'] as $key=>$val){
467
-        $dom_txt .="if(trgt_type_text =='$key'){trgt_type_text='$val';}";
465
+    $dom_txt = ' ';
466
+    foreach ($app_list_strings['prospect_list_type_dom'] as $key=>$val) {
467
+        $dom_txt .= "if(trgt_type_text =='$key'){trgt_type_text='$val';}";
468 468
     }
469 469
     $ss->assign("PL_DOM_STMT", $dom_txt);
470 470
     $trgt_count = 0;
471 471
     $trgt_html = ' ';
472
-    if(count($prospect_lists)>0){
472
+    if (count($prospect_lists) > 0) {
473 473
 
474
-        foreach($prospect_lists as $pl_id){
474
+        foreach ($prospect_lists as $pl_id) {
475 475
             //retrieve prospect list
476 476
             $pl = new ProspectList();
477 477
             $pl_focus = $pl->retrieve($pl_id);
478
-            $trgt_html .= "<div id='existing_trgt".$trgt_count."'> <table class='tabDetailViewDL2' width='100%'>" ;
479
-            $trgt_html .= "<td width='100' style=\"width:25%\"> <input id='existing_target_name". $trgt_count ."' type='hidden' type='text' size='60' maxlength='255' name='existing_target_name". $trgt_count ."'  value='". $pl_focus->name."' ><a href=\"index.php?module=ProspectLists&action=DetailView&record=" . $pl_focus->id . "\" target=\"_blank\" title=\"" . $mod_strings['LBL_OPEN_IN_NEW_WINDOW'] . "\">". $pl_focus->name."</a></td>";
478
+            $trgt_html .= "<div id='existing_trgt".$trgt_count."'> <table class='tabDetailViewDL2' width='100%'>";
479
+            $trgt_html .= "<td width='100' style=\"width:25%\"> <input id='existing_target_name".$trgt_count."' type='hidden' type='text' size='60' maxlength='255' name='existing_target_name".$trgt_count."'  value='".$pl_focus->name."' ><a href=\"index.php?module=ProspectLists&action=DetailView&record=".$pl_focus->id."\" target=\"_blank\" title=\"".$mod_strings['LBL_OPEN_IN_NEW_WINDOW']."\">".$pl_focus->name."</a></td>";
480 480
             $trgt_html .= "<td width='100' style=\"width:25%\">".$pl_focus->get_entry_count()."</td>";
481
-            $trgt_html .= "<td width='100' style=\"width:25%\"><input type='hidden' size='60' maxlength='255' name='existing_tracker_list_type". $trgt_count ."'   id='existing_tracker_list_type". $trgt_count ."' value='".$pl_focus->list_type."' >".$app_list_strings['prospect_list_type_dom'][$pl_focus->list_type];
482
-            $trgt_html .= "<input type='hidden' name='added_target_id". $trgt_count ."' id='added_target_id". $trgt_count ."' value='". $pl_focus->id ."' ></td>";
481
+            $trgt_html .= "<td width='100' style=\"width:25%\"><input type='hidden' size='60' maxlength='255' name='existing_tracker_list_type".$trgt_count."'   id='existing_tracker_list_type".$trgt_count."' value='".$pl_focus->list_type."' >".$app_list_strings['prospect_list_type_dom'][$pl_focus->list_type];
482
+            $trgt_html .= "<input type='hidden' name='added_target_id".$trgt_count."' id='added_target_id".$trgt_count."' value='".$pl_focus->id."' ></td>";
483 483
             $trgt_html .= "<td width='100' style=\"width:25%\"><a href='#' onclick=\"javascript:remove_existing_target('existing_trgt".$trgt_count."','".$pl_focus->id."'); \" >  ";
484 484
             $trgt_html .= SugarThemeRegistry::current()->getImage('delete_inline', "border='0' align='absmiddle'", 12, 12, ".gif", $mod_strings['LBL_DELETE'])."</a></td></tr></table></div>";
485 485
 
486
-            $trgt_count =$trgt_count +1;
486
+            $trgt_count = $trgt_count + 1;
487 487
         }
488 488
 
489 489
         $trgt_html  .= "<div id='no_targets'></div>";
490
-    }else{
490
+    } else {
491 491
         $trgt_html  .= "<div id='no_targets'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
492 492
 
493 493
     }
494
-    $ss->assign('EXISTING_TARGETS', $trgt_html );
494
+    $ss->assign('EXISTING_TARGETS', $trgt_html);
495 495
 
496 496
 }
497 497
 
498 498
     
499 499
 /**************************** WIZARD UI DIV Stuff *******************/
500 500
 $mrkt_string = $mod_strings['LBL_NAVIGATION_MENU_MARKETING'];
501
-if(!empty($focus->id)){
501
+if (!empty($focus->id)) {
502 502
     $mrkt_url = "<a  href='index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome";
503 503
     $mrkt_url .= "&return_id=".$focus->id."&campaign_id=".$focus->id;
504
-    $mrkt_url .= "'>". $mrkt_string."</a>";
504
+    $mrkt_url .= "'>".$mrkt_string."</a>";
505 505
     $mrkt_string = $mrkt_url;
506 506
 }
507 507
     $summ_url = $mod_strings['LBL_NAVIGATION_MENU_SUMMARY'];
508
-    if(!empty($focus->id)){
508
+    if (!empty($focus->id)) {
509 509
         $summ_url = "<a  href='index.php?action=WizardHome&module=Campaigns";
510 510
         $summ_url .= "&return_id=".$focus->id."&record=".$focus->id;
511
-        $summ_url .= "'> ". $mod_strings['LBL_NAVIGATION_MENU_SUMMARY']."</a>";
511
+        $summ_url .= "'> ".$mod_strings['LBL_NAVIGATION_MENU_SUMMARY']."</a>";
512 512
     } 
513 513
    
514 514
 
515 515
 
516
-$script_to_call ='';
517
-    if (!empty($focus->id)){
516
+$script_to_call = '';
517
+    if (!empty($focus->id)) {
518 518
         $maxStep = 2;
519 519
         $script_to_call = "link_navs(1, {$maxStep});";
520
-        if(isset($_REQUEST['direct_step']) and !empty($_REQUEST['direct_step'])){
521
-            $directStep = (int) $_REQUEST['direct_step'];
522
-            if($directStep < 1) {
520
+        if (isset($_REQUEST['direct_step']) and !empty($_REQUEST['direct_step'])) {
521
+            $directStep = (int)$_REQUEST['direct_step'];
522
+            if ($directStep < 1) {
523 523
                 $directStep = 1;
524 524
             }
525
-            if($directStep > $maxStep) {
525
+            if ($directStep > $maxStep) {
526 526
                 $directStep = $maxStep;
527 527
             }
528
-            $script_to_call .='   direct(' . $directStep . ');';
528
+            $script_to_call .= '   direct('.$directStep.');';
529 529
         }
530 530
     } 
531 531
     $ss->assign("HILITE_ALL", $script_to_call);
@@ -565,56 +565,56 @@  discard block
 block discarded – undo
565 565
 
566 566
 //Create the html to fill in the wizard steps
567 567
 
568
-if($campaign_type == 'general'){
568
+if ($campaign_type == 'general') {
569 569
     $steps = create_campaign_steps();
570 570
 
571
-    foreach($steps as $key => $step) {
571
+    foreach ($steps as $key => $step) {
572 572
         $_steps[$key] = false;
573 573
     }
574
-    $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'campaign',$mrkt_string,$summ_url, 'dotlist'));
575
-    $ss->assign('HIDE_CONTINUE','hidden');
574
+    $ss->assign('NAV_ITEMS', create_wiz_menu_items($_steps, 'campaign', $mrkt_string, $summ_url, 'dotlist'));
575
+    $ss->assign('HIDE_CONTINUE', 'hidden');
576 576
 
577
-}elseif($campaign_type == 'email'){
577
+}elseif ($campaign_type == 'email') {
578 578
     $steps = create_email_steps();
579
-    if($focus->id) {
580
-        $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=" . $focus->id . "&record=" . $focus->id;
579
+    if ($focus->id) {
580
+        $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=".$focus->id."&record=".$focus->id;
581 581
     }
582 582
     else {
583 583
         $summ_url = false;
584 584
     }
585
-    foreach($steps as $key => $step) {
585
+    foreach ($steps as $key => $step) {
586 586
         $_steps[$key] = false;
587 587
     }
588 588
     $campaign_id = $focus->id;
589 589
     $marketing_id = isset($_REQUEST['marketing_id']) && $_REQUEST['marketing_id'] ? $_REQUEST['marketing_id'] : null;
590 590
     $template_id = isset($_REQUEST['template_id']) && $_REQUEST['template_id'] ? $_REQUEST['template_id'] : null;
591
-    $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'email',$mrkt_string,$summ_url, 'dotlist', $campaign_id, $marketing_id, $template_id));
592
-    $ss->assign('HIDE_CONTINUE','submit');
593
-}else{
591
+    $ss->assign('NAV_ITEMS', create_wiz_menu_items($_steps, 'email', $mrkt_string, $summ_url, 'dotlist', $campaign_id, $marketing_id, $template_id));
592
+    $ss->assign('HIDE_CONTINUE', 'submit');
593
+} else {
594 594
     $steps = create_newsletter_steps();
595 595
 
596
-    if($focus->id) {
597
-        $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=" . $focus->id . "&record=" . $focus->id;
596
+    if ($focus->id) {
597
+        $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=".$focus->id."&record=".$focus->id;
598 598
     }
599 599
     else {
600 600
         $summ_url = false;
601 601
     }
602
-    foreach($steps as $key => $step) {
602
+    foreach ($steps as $key => $step) {
603 603
         $_steps[$key] = false;
604 604
     }
605
-    $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'newsletter',$mrkt_string,$summ_url, 'dotlist'));
606
-    $ss->assign('HIDE_CONTINUE','submit');
605
+    $ss->assign('NAV_ITEMS', create_wiz_menu_items($_steps, 'newsletter', $mrkt_string, $summ_url, 'dotlist'));
606
+    $ss->assign('HIDE_CONTINUE', 'submit');
607 607
 }
608 608
 
609 609
 $ss->assign('TOTAL_STEPS', count($steps));
610
-$sshtml = create_wiz_step_divs($steps,$ss);
611
-$ss->assign('STEPS',$sshtml);
610
+$sshtml = create_wiz_step_divs($steps, $ss);
611
+$ss->assign('STEPS', $sshtml);
612 612
      	   	
613 613
 
614 614
 /**************************** FINAL END OF PAGE UI Stuff *******************/
615 615
 
616
-if(isset($_REQUEST['wizardtype'])) {
617
-    switch($_REQUEST['wizardtype']) {
616
+if (isset($_REQUEST['wizardtype'])) {
617
+    switch ($_REQUEST['wizardtype']) {
618 618
         case '1':
619 619
             $ss->assign('campaign_type', 'NewsLetter');
620 620
             break;
@@ -629,12 +629,12 @@  discard block
 block discarded – undo
629 629
 
630 630
 $ss->display(file_exists('custom/modules/Campaigns/tpls/WizardNewsletter.tpl') ? 'custom/modules/Campaigns/tpls/WizardNewsletter.tpl' : 'modules/Campaigns/tpls/WizardNewsletter.tpl');
631 631
 
632
-if(!$focus->id) {
632
+if (!$focus->id) {
633 633
     unset($_SESSION['campaignWizard'][$campaign_id]['defaultSelectedMarketingId']);
634 634
 }
635 635
 
636 636
 
637
-function create_newsletter_steps(){
637
+function create_newsletter_steps() {
638 638
     global $mod_strings;
639 639
     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
640 640
     //$steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
@@ -643,54 +643,54 @@  discard block
 block discarded – undo
643 643
     return  $steps;
644 644
 }
645 645
 
646
-function create_campaign_steps(){
646
+function create_campaign_steps() {
647 647
     global $mod_strings;
648 648
     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
649 649
     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
650
-    $steps[$mod_strings['LBL_TARGET_LISTS']]                   = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
650
+    $steps[$mod_strings['LBL_TARGET_LISTS']] = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
651 651
     return  $steps;
652 652
 }
653 653
 
654
-function create_email_steps(){
654
+function create_email_steps() {
655 655
     global $mod_strings;
656
-    $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
656
+    $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']] = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
657 657
     //$steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
658 658
     //$steps[$mod_strings['LBL_NAVIGATION_MENU_TRACKERS']]      = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl' : 'modules/Campaigns/tpls/WizardCampaignTracker.tpl';
659
-    $steps[$mod_strings['LBL_TARGET_LISTS']]                   = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
659
+    $steps[$mod_strings['LBL_TARGET_LISTS']] = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
660 660
     return  $steps;
661 661
 }
662 662
 
663 663
 
664
-function create_wiz_step_divs($steps,$ss){
664
+function create_wiz_step_divs($steps, $ss) {
665 665
     $step_html = '';
666
-    if(isset($steps)  && !empty($steps)){
667
-        $i=1;
668
-        foreach($steps as $name=>$step){
669
-            $step_html .="<p><div id='step$i'>";
666
+    if (isset($steps) && !empty($steps)) {
667
+        $i = 1;
668
+        foreach ($steps as $name=>$step) {
669
+            $step_html .= "<p><div id='step$i'>";
670 670
             $step_html .= $ss->fetch($step);
671
-            $step_html .="</div></p>";
672
-            $i = $i+1;
671
+            $step_html .= "</div></p>";
672
+            $i = $i + 1;
673 673
         }    
674 674
     }
675 675
     return $step_html;
676 676
 }
677 677
 
678
-function create_wiz_menu_items($steps,$type,$mrkt_string,$summ_url, $view = null, $campaign_id = null, $marketing_id = null, $template_id = null){
678
+function create_wiz_menu_items($steps, $type, $mrkt_string, $summ_url, $view = null, $campaign_id = null, $marketing_id = null, $template_id = null) {
679 679
 
680 680
     global $mod_strings;
681 681
 
682 682
 
683
-    if($view == 'dotlist') {
683
+    if ($view == 'dotlist') {
684 684
 
685 685
         include_once 'modules/Campaigns/DotListWizardMenu.php';
686 686
 
687
-        if($type!='campaign') {
687
+        if ($type != 'campaign') {
688 688
             $templateURLForProgressBar = false;
689 689
             if ($campaign_id && $marketing_id && $template_id) {
690 690
                 $templateURLForProgressBar = "index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome&return_id={$campaign_id}&campaign_id={$campaign_id}&jump=2&marketing_id={$marketing_id}&record={$marketing_id}&campaign_type=Email&template_id={$template_id}";
691 691
             }
692 692
 
693
-            if(preg_match('/\bhref=\'([^\']*)/', $mrkt_string, $matches)) {
693
+            if (preg_match('/\bhref=\'([^\']*)/', $mrkt_string, $matches)) {
694 694
                 $templateURLForProgressBar = $matches[1];
695 695
             }
696 696
 
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
         if ($type == 'newsletter' || $type == 'email') {
701 701
 
702 702
             preg_match('/\bhref=\'([^\']*)/', $mrkt_string, $matches);
703
-            if(isset($matches[1])) {
704
-                $marketingLink = $matches[1] . ($matches[1] ? '&jump=2' : false);
703
+            if (isset($matches[1])) {
704
+                $marketingLink = $matches[1].($matches[1] ? '&jump=2' : false);
705 705
             }
706 706
             else {
707 707
                 $marketingLink = false;
@@ -719,19 +719,19 @@  discard block
 block discarded – undo
719 719
     }
720 720
     else {
721 721
         $nav_html = '<table border="0" cellspacing="0" cellpadding="0" width="100%" >';
722
-        if(isset($steps)  && !empty($steps)){
723
-            $i=1;
724
-            foreach($steps as $name=>$step){
722
+        if (isset($steps) && !empty($steps)) {
723
+            $i = 1;
724
+            foreach ($steps as $name=>$step) {
725 725
                 $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step$i'>$name</div></td></tr>";
726
-                $i=$i+1;
726
+                $i = $i + 1;
727 727
             }
728 728
         }
729
-        if($type == 'newsletter'  ||  $type == 'email'){
730
-            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">$mrkt_string</div></td></tr>";
731
-            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+2).">".$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL']."</div></li>";
732
-            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+3).">".$summ_url."</div></td></tr>";
733
-        }else{
734
-            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">".$summ_url."</div></td></tr>";
729
+        if ($type == 'newsletter' || $type == 'email') {
730
+            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i + 1).">$mrkt_string</div></td></tr>";
731
+            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i + 2).">".$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL']."</div></li>";
732
+            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i + 3).">".$summ_url."</div></td></tr>";
733
+        } else {
734
+            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i + 1).">".$summ_url."</div></td></tr>";
735 735
         }
736 736
 
737 737
         $nav_html .= '</table>';
Please login to merge, or discard this patch.
modules/Campaigns/WebToLeadCapture.php 1 patch
Spacing   +43 added lines, -43 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.
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 $mod_strings = return_module_language($sugar_config['default_language'], 'Leads');
49 49
 
50
-$app_list_strings['record_type_module'] = array('Contact'=>'Contacts', 'Account'=>'Accounts', 'Opportunity'=>'Opportunities', 'Case'=>'Cases', 'Note'=>'Notes', 'Call'=>'Calls', 'Email'=>'Emails', 'Meeting'=>'Meetings', 'Task'=>'Tasks', 'Lead'=>'Leads','Bug'=>'Bugs',
50
+$app_list_strings['record_type_module'] = array('Contact'=>'Contacts', 'Account'=>'Accounts', 'Opportunity'=>'Opportunities', 'Case'=>'Cases', 'Note'=>'Notes', 'Call'=>'Calls', 'Email'=>'Emails', 'Meeting'=>'Meetings', 'Task'=>'Tasks', 'Lead'=>'Leads', 'Bug'=>'Bugs',
51 51
 
52 52
 );
53 53
 
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
 if (isset($_POST['campaign_id']) && !empty($_POST['campaign_id'])) {
62 62
 	    //adding the client ip address
63 63
 	    $_POST['client_id_address'] = query_client_ip();
64
-		$campaign_id=$_POST['campaign_id'];
64
+		$campaign_id = $_POST['campaign_id'];
65 65
 		$campaign = new Campaign();
66 66
 		$camp_query  = "select name,id from campaigns where id='$campaign_id'";
67 67
 		$camp_query .= " and deleted=0";
68
-        $camp_result=$campaign->db->query($camp_query);
68
+        $camp_result = $campaign->db->query($camp_query);
69 69
         $camp_data = $campaign->db->fetchByAssoc($camp_result);
70 70
         // Bug 41292 - have to select marketing_id for new lead
71 71
         $db = DBManagerFactory::getInstance();
72 72
         $marketing = new EmailMarketing();
73 73
         $marketing_query = $marketing->create_new_list_query(
74 74
                 'date_start desc, date_modified desc',
75
-                "campaign_id = '{$campaign_id}' and status = 'active' and date_start < " . $db->convert('', 'today'),
75
+                "campaign_id = '{$campaign_id}' and status = 'active' and date_start < ".$db->convert('', 'today'),
76 76
                 array('id')
77 77
         );
78 78
         $marketing_result = $db->limitQuery($marketing_query, 0, 1, true);
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 			$current_user->retrieve($_REQUEST['assigned_user_id']);
84 84
 		} 
85 85
 
86
-	    if(isset($camp_data) && $camp_data != null ){
86
+	    if (isset($camp_data) && $camp_data != null) {
87 87
 			$leadForm = new LeadFormBase();
88 88
             $lead = new Lead();
89 89
 			$prefix = '';
90
-			if(!empty($_POST['prefix'])){
90
+			if (!empty($_POST['prefix'])) {
91 91
 				$prefix = $_POST['prefix'];
92 92
 			}
93 93
 
94
-			if(empty($lead->id)) {
94
+			if (empty($lead->id)) {
95 95
                 $lead->id = create_guid();
96 96
                 $lead->new_with_id = true;
97 97
             }
98 98
             $GLOBALS['check_notify'] = true;
99 99
 
100 100
             //bug: 47574 - make sure, that webtolead_email1 field has same required attribute as email1 field
101
-            if(isset($lead->required_fields['email1'])){
101
+            if (isset($lead->required_fields['email1'])) {
102 102
                 $lead->required_fields['webtolead_email1'] = $lead->required_fields['email1'];
103 103
             }
104 104
             
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             // checkRequired needs a major overhaul before it works for web to lead forms.
115 115
             $lead = $leadForm->handleSave($prefix, false, false, false, $lead);
116 116
             
117
-			if(!empty($lead)){
117
+			if (!empty($lead)) {
118 118
 				
119 119
 	            //create campaign log
120 120
 	            $camplog = new CampaignLog();
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	            $camplog->related_type = $lead->module_dir;
124 124
 	            $camplog->activity_type = "lead";
125 125
 	            $camplog->target_type = $lead->module_dir;
126
-	            $campaign_log->activity_date=$timedate->now();
127
-	            $camplog->target_id    = $lead->id;
128
-                if(isset($marketing_data['id']))
126
+	            $campaign_log->activity_date = $timedate->now();
127
+	            $camplog->target_id = $lead->id;
128
+                if (isset($marketing_data['id']))
129 129
                 {
130 130
                     $camplog->marketing_id = $marketing_data['id'];
131 131
                 }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 
156 156
 		        $lead->load_relationship('campaigns');
157 157
 		        $lead->campaigns->add($camplog->id);
158
-                if(!empty($GLOBALS['check_notify'])) {
158
+                if (!empty($GLOBALS['check_notify'])) {
159 159
                     $lead->save($GLOBALS['check_notify']);
160 160
                 }
161 161
                 else {
@@ -164,47 +164,47 @@  discard block
 block discarded – undo
164 164
             }
165 165
 
166 166
             //in case there are forms out there still using email_opt_out
167
-            if(isset($_POST['webtolead_email_opt_out']) || isset($_POST['email_opt_out'])){
167
+            if (isset($_POST['webtolead_email_opt_out']) || isset($_POST['email_opt_out'])) {
168 168
                     
169
-                if(isset ($lead->email1) && !empty($lead->email1)){
169
+                if (isset ($lead->email1) && !empty($lead->email1)) {
170 170
                     $sea = new SugarEmailAddress();
171
-                    $sea->AddUpdateEmailAddress($lead->email1,0,1);
171
+                    $sea->AddUpdateEmailAddress($lead->email1, 0, 1);
172 172
                 }   
173
-                if(isset ($lead->email2) && !empty($lead->email2)){
173
+                if (isset ($lead->email2) && !empty($lead->email2)) {
174 174
                     $sea = new SugarEmailAddress();
175
-                    $sea->AddUpdateEmailAddress($lead->email2,0,1);
175
+                    $sea->AddUpdateEmailAddress($lead->email2, 0, 1);
176 176
                     
177 177
                 }
178 178
             }              
179
-			if(isset($_POST['redirect_url']) && !empty($_POST['redirect_url'])){
179
+			if (isset($_POST['redirect_url']) && !empty($_POST['redirect_url'])) {
180 180
 			    // Get the redirect url, and make sure the query string is not too long
181 181
 		        $redirect_url = $_POST['redirect_url'];
182 182
 		        $query_string = '';
183 183
 				$first_char = '&';
184
-				if(strpos($redirect_url, '?') === FALSE){
184
+				if (strpos($redirect_url, '?') === FALSE) {
185 185
 					$first_char = '?';
186 186
 				}
187 187
 				$first_iteration = true;
188 188
 				$get_and_post = array_merge($_GET, $_POST);
189
-				foreach($get_and_post as $param => $value) {
189
+				foreach ($get_and_post as $param => $value) {
190 190
 
191
-					if($param == 'redirect_url' && $param == 'submit')
191
+					if ($param == 'redirect_url' && $param == 'submit')
192 192
 						continue;
193 193
 					
194
-					if($first_iteration){
194
+					if ($first_iteration) {
195 195
 						$first_iteration = false;
196 196
 						$query_string .= $first_char;
197 197
 					}
198
-					else{
198
+					else {
199 199
 						$query_string .= "&";
200 200
 					}
201 201
 					$query_string .= "{$param}=".urlencode($value);
202 202
 				}
203
-				if(empty($lead)) {
204
-					if($first_iteration){
203
+				if (empty($lead)) {
204
+					if ($first_iteration) {
205 205
 						$query_string .= $first_char;
206 206
 					}
207
-					else{
207
+					else {
208 208
 						$query_string .= "&";
209 209
 					}
210 210
 					$query_string .= "error=1";
@@ -215,25 +215,25 @@  discard block
 block discarded – undo
215 215
 
216 216
 				// Check if the headers have been sent, or if the redirect url is greater than 2083 characters (IE max URL length)
217 217
 				//   and use a javascript form submission if that is the case.
218
-			    if(headers_sent() || strlen($redirect_url) > 2083){
219
-    				echo '<html ' . get_language_header() . '><head><title>SugarCRM</title></head><body>';
220
-    				echo '<form name="redirect" action="' .$_POST['redirect_url']. '" method="GET">';
218
+			    if (headers_sent() || strlen($redirect_url) > 2083) {
219
+    				echo '<html '.get_language_header().'><head><title>SugarCRM</title></head><body>';
220
+    				echo '<form name="redirect" action="'.$_POST['redirect_url'].'" method="GET">';
221 221
     
222
-    				foreach($_POST as $param => $value) {
223
-    					if($param != 'redirect_url' ||$param != 'submit') {
222
+    				foreach ($_POST as $param => $value) {
223
+    					if ($param != 'redirect_url' || $param != 'submit') {
224 224
     						echo '<input type="hidden" name="'.$param.'" value="'.$value.'">';
225 225
     					}
226 226
     				}
227
-    				if(empty($lead)) {
227
+    				if (empty($lead)) {
228 228
     					echo '<input type="hidden" name="error" value="1">';
229 229
     				}
230 230
     				echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>';
231 231
     				echo '</body></html>';
232 232
     			}
233
-				else{
233
+				else {
234 234
     				$header_URL = "Location: {$redirect_url}";
235 235
 
236
-					if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
236
+					if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
237 237
 						$href = $matches[1];
238 238
 						SugarApplication::redirect($href);
239 239
 					}
@@ -244,29 +244,29 @@  discard block
 block discarded – undo
244 244
     				die();
245 245
 			    }
246 246
 			}
247
-			else{
247
+			else {
248 248
 				echo $mod_strings['LBL_THANKS_FOR_SUBMITTING'];
249 249
 			}
250 250
 			sugar_cleanup();
251 251
 			// die to keep code from running into redirect case below
252 252
 			die();
253 253
 	    }
254
-	   else{
254
+	   else {
255 255
 	  	  echo $mod_strings['LBL_SERVER_IS_CURRENTLY_UNAVAILABLE'];
256 256
 	  }
257 257
 }
258 258
 
259 259
 if (!empty($_POST['redirect'])) {
260
-    if(headers_sent()){
261
-    	echo '<html ' . get_language_header() . '><head><title>SugarCRM</title></head><body>';
262
-    	echo '<form name="redirect" action="' .$_POST['redirect']. '" method="GET">';
260
+    if (headers_sent()) {
261
+    	echo '<html '.get_language_header().'><head><title>SugarCRM</title></head><body>';
262
+    	echo '<form name="redirect" action="'.$_POST['redirect'].'" method="GET">';
263 263
     	echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>';
264 264
     	echo '</body></html>';
265 265
     }
266
-    else{
266
+    else {
267 267
     	$header_URL = "Location: {$_POST['redirect']}";
268 268
 
269
-		if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
269
+		if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
270 270
 			$href = $matches[1];
271 271
 			SugarApplication::redirect($href);
272 272
 		}
Please login to merge, or discard this patch.
modules/Campaigns/WebToPersonCapture.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             } else {
238 238
                 $header_URL = "Location: {$redirect_url}";
239 239
 
240
-                if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
240
+                if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
241 241
                     $href = $matches[1];
242 242
                     SugarApplication::redirect($href);
243 243
                 }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
     } else {
274 274
         $header_URL = "Location: {$_POST['redirect']}";
275 275
 
276
-        if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
276
+        if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
277 277
             $href = $matches[1];
278 278
             SugarApplication::redirect($href);
279 279
         }
Please login to merge, or discard this patch.
modules/Campaigns/WizardCampaignSave.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 function getTemplateValidationMessages($templateId) {
44 44
     $msgs = array();
45
-    if(!$templateId) {
45
+    if (!$templateId) {
46 46
         $msgs[] = 'LBL_NO_SELECTED_TEMPLATE';
47 47
     }
48 48
     else {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 $campaignId = $db->quote($_POST['campaignId']);
65 65
 $marketingId = $db->quote($_POST['marketingId']);
66 66
 $func = isset($_REQUEST['func']) ? $_REQUEST['func'] : null;
67
-if($func == 'getTemplateValidation') {
67
+if ($func == 'getTemplateValidation') {
68 68
     if (!empty($_POST['templateId'])) {
69 69
         $templateId = $db->quote($_POST['templateId']);
70 70
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     if (!$marketingId) {
89 89
         if (!empty($_SESSION['campaignWizard'][$campaignId]['defaultSelectedMarketingId']) && $func != 'createEmailMarketing') {
90 90
             $marketingId = $_SESSION['campaignWizard'][$campaignId]['defaultSelectedMarketingId'];
91
-        } else if($func != 'createEmailMarketing') {
91
+        } else if ($func != 'createEmailMarketing') {
92 92
             $marketing = new EmailMarketing();
93 93
             $marketing->save();
94 94
             $marketingId = $marketing->id;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     if (!empty($_POST['templateId'])) {
108 108
         $marketing->template_id = $templateId;
109 109
     }
110
-    if($func != 'createEmailMarketing') {
110
+    if ($func != 'createEmailMarketing') {
111 111
         $marketing->save();
112 112
     }
113 113
 
Please login to merge, or discard this patch.
modules/Campaigns/WebToLeadCreation.php 1 patch
Spacing   +48 added lines, -48 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.
@@ -51,28 +51,28 @@  discard block
 block discarded – undo
51 51
 
52 52
 require_once('modules/Campaigns/utils.php');
53 53
 
54
-global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map,$import_file_name, $theme;
54
+global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map, $import_file_name, $theme;
55 55
 
56
-$xtpl=new XTemplate ('modules/Campaigns/WebToLeadCreation.html');
56
+$xtpl = new XTemplate('modules/Campaigns/WebToLeadCreation.html');
57 57
 $xtpl->assign("MOD", $mod_strings);
58 58
 $xtpl->assign("APP", $app_strings);
59
-if(isset($_REQUEST['module']))
59
+if (isset($_REQUEST['module']))
60 60
 {
61 61
     $xtpl->assign("MODULE", $_REQUEST['module']);
62 62
 }
63
-if(isset($_REQUEST['return_module']))
63
+if (isset($_REQUEST['return_module']))
64 64
 {
65 65
     $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
66 66
 }
67
-if(isset($_REQUEST['return_id']))
67
+if (isset($_REQUEST['return_id']))
68 68
 {
69 69
     $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
70 70
 }
71
-if(isset($_REQUEST['return_id']))
71
+if (isset($_REQUEST['return_id']))
72 72
 {
73 73
     $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
74 74
 }
75
-if(isset($_REQUEST['record']))
75
+if (isset($_REQUEST['record']))
76 76
 {
77 77
     $xtpl->assign("RECORD", $_REQUEST['record']);
78 78
 }
@@ -86,21 +86,21 @@  discard block
 block discarded – undo
86 86
 
87 87
 $beanList = filterFieldsFromBeans($subclasses);
88 88
 
89
-$xtpl->assign("BEAN_LIST",json_encode($beanList));
89
+$xtpl->assign("BEAN_LIST", json_encode($beanList));
90 90
 
91 91
 $personTypeList = "<select id='personTypeSelect'>";
92
-if(count($beanList) > 0)
92
+if (count($beanList) > 0)
93 93
 {
94
-    $count=0;
95
-    foreach($beanList as $b)
94
+    $count = 0;
95
+    foreach ($beanList as $b)
96 96
     {
97
-        $personTypeList.="<option value='".$count."'>".$b->name."</option>";
97
+        $personTypeList .= "<option value='".$count."'>".$b->name."</option>";
98 98
         $count++;
99 99
     }
100 100
 }
101 101
 else
102 102
 {
103
-    $personTypeList.="<option value='noPerson'>No matching types</option>";
103
+    $personTypeList .= "<option value='noPerson'>No matching types</option>";
104 104
 }
105 105
 
106 106
 $site_url = $sugar_config['site_url'];
@@ -127,18 +127,18 @@  discard block
 block discarded – undo
127 127
 		),
128 128
 );
129 129
 $encoded_users_popup_request_data = $json->encode($popup_request_data);
130
-$xtpl->assign('encoded_campaigns_popup_request_data' , $json->encode($popup_request_data));
130
+$xtpl->assign('encoded_campaigns_popup_request_data', $json->encode($popup_request_data));
131 131
 
132 132
 $field_defs_js = "var field_defs = {'Contacts':[";
133 133
 
134
-$xtpl->assign("WEB_POST_URL",$web_post_url);
134
+$xtpl->assign("WEB_POST_URL", $web_post_url);
135 135
 
136 136
 if (empty($focus->assigned_user_id) && empty($focus->id))  $focus->assigned_user_id = $current_user->id;
137 137
 if (empty($focus->assigned_name) && empty($focus->id))  $focus->assigned_user_name = $current_user->user_name;
138 138
 $xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
139
-$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id );
139
+$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id);
140 140
 
141
-$xtpl->assign("REDIRECT_URL_DEFAULT",'http://');
141
+$xtpl->assign("REDIRECT_URL_DEFAULT", 'http://');
142 142
 
143 143
 $xtpl->parse("main");
144 144
 $xtpl->out("main");
@@ -148,71 +148,71 @@  discard block
 block discarded – undo
148 148
 {
149 149
     global $app_strings;
150 150
     $formattedBeans = array();
151
-    foreach($beans as $b)
151
+    foreach ($beans as $b)
152 152
     {
153 153
         $formattedFields = array();
154 154
 //bug: 47574 - make sure, that webtolead_email1 field has same required attribute as email1 field
155
-        if(isset($b->field_defs['webtolead_email1']) && isset($b->field_defs['email1']) && isset($b->field_defs['email1']['required'])){
155
+        if (isset($b->field_defs['webtolead_email1']) && isset($b->field_defs['email1']) && isset($b->field_defs['email1']['required'])) {
156 156
             $b->field_defs['webtolead_email1']['required'] = $b->field_defs['email1']['required'];
157 157
         }
158 158
 
159
-        foreach($b->field_defs as $field_def)
159
+        foreach ($b->field_defs as $field_def)
160 160
         {
161 161
             $email_fields = false;
162
-            if($field_def['name']== 'email1' || $field_def['name']== 'email2')
162
+            if ($field_def['name'] == 'email1' || $field_def['name'] == 'email2')
163 163
             {
164 164
                 $email_fields = true;
165 165
             }
166
-            if($field_def['name']!= 'account_name'){
167
-                if( ( $field_def['type'] == 'relate' && empty($field_def['custom_type']) )
168
-                    || $field_def['type'] == 'assigned_user_name' || $field_def['type'] =='link' || $field_def['type'] =='function'
169
-                    || (isset($field_def['source'])  && $field_def['source']=='non-db' && !$email_fields) || $field_def['type'] == 'id')
166
+            if ($field_def['name'] != 'account_name') {
167
+                if (($field_def['type'] == 'relate' && empty($field_def['custom_type']))
168
+                    || $field_def['type'] == 'assigned_user_name' || $field_def['type'] == 'link' || $field_def['type'] == 'function'
169
+                    || (isset($field_def['source']) && $field_def['source'] == 'non-db' && !$email_fields) || $field_def['type'] == 'id')
170 170
                 {
171 171
                     continue;
172 172
                 }
173 173
             }
174
-            if($field_def['name']== 'deleted' || $field_def['name']=='converted' || $field_def['name']=='date_entered'
175
-                || $field_def['name']== 'date_modified' || $field_def['name']=='modified_user_id'
176
-                || $field_def['name']=='assigned_user_id' || $field_def['name']=='created_by'
177
-                || $field_def['name']=='team_id')
174
+            if ($field_def['name'] == 'deleted' || $field_def['name'] == 'converted' || $field_def['name'] == 'date_entered'
175
+                || $field_def['name'] == 'date_modified' || $field_def['name'] == 'modified_user_id'
176
+                || $field_def['name'] == 'assigned_user_id' || $field_def['name'] == 'created_by'
177
+                || $field_def['name'] == 'team_id')
178 178
             {
179 179
                 continue;
180 180
             }
181 181
 
182 182
             //If the field is hidden in the studio settings, then do not show
183
-            if(isset($field_def['studio']) && isset($field_def['studio']['editview']) && $field_def['studio']['editview']=== false )
183
+            if (isset($field_def['studio']) && isset($field_def['studio']['editview']) && $field_def['studio']['editview'] === false)
184 184
             {
185 185
                 continue;
186 186
             }
187 187
 
188 188
 
189
-            $field_def['vname'] = preg_replace('/:$/','',translate($field_def['vname'], $b->module_dir));
189
+            $field_def['vname'] = preg_replace('/:$/', '', translate($field_def['vname'], $b->module_dir));
190 190
 
191 191
             //$cols_name = "{'".$field_def['vname']."'}";
192 192
             $col_arr = array();
193
-            if((isset($field_def['required']) && $field_def['required'] != null && $field_def['required'] != 0)
194
-                || $field_def['name']=='last_name'
195
-            ){
196
-                $cols_name=$field_def['vname'].' '.$app_strings['LBL_REQUIRED_SYMBOL'];
197
-                $col_arr[0]=$cols_name;
198
-                $col_arr[1]=$field_def['name'];
199
-                $col_arr[2]=true;
193
+            if ((isset($field_def['required']) && $field_def['required'] != null && $field_def['required'] != 0)
194
+                || $field_def['name'] == 'last_name'
195
+            ) {
196
+                $cols_name = $field_def['vname'].' '.$app_strings['LBL_REQUIRED_SYMBOL'];
197
+                $col_arr[0] = $cols_name;
198
+                $col_arr[1] = $field_def['name'];
199
+                $col_arr[2] = true;
200 200
             }
201
-            else{
202
-                $cols_name=$field_def['vname'];
203
-                $col_arr[0]=$cols_name;
204
-                $col_arr[1]=$field_def['name'];
201
+            else {
202
+                $cols_name = $field_def['vname'];
203
+                $col_arr[0] = $cols_name;
204
+                $col_arr[1] = $field_def['name'];
205 205
             }
206
-            if (! in_array($cols_name, $formattedFields))
206
+            if (!in_array($cols_name, $formattedFields))
207 207
             {
208
-                array_push($formattedFields,$col_arr);
208
+                array_push($formattedFields, $col_arr);
209 209
             }
210 210
         }
211 211
 
212 212
         $holder = new stdClass();
213 213
         $holder->name = $b->object_name;
214 214
         $holder->fields = $formattedFields;
215
-        $holder->moduleKnownAs = translate($b->module_name,'LBL_MODULE_NAME');
215
+        $holder->moduleKnownAs = translate($b->module_name, 'LBL_MODULE_NAME');
216 216
         $holder->moduleDir = $b->module_dir;
217 217
         $holder->moduleName = $b->module_name;
218 218
         $formattedBeans[] = $holder;
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 function getListOfExtendingClasses($superclass)
230 230
 {
231 231
     $subclasses = array();
232
-    foreach($GLOBALS['moduleList'] as $mod)
232
+    foreach ($GLOBALS['moduleList'] as $mod)
233 233
     {
234 234
         $item = BeanFactory::getBean($mod);
235
-        if($item && is_subclass_of($item,$superclass))
235
+        if ($item && is_subclass_of($item, $superclass))
236 236
             $subclasses[] = $item;
237 237
     }
238 238
     return $subclasses;
Please login to merge, or discard this patch.
modules/Campaigns/WizardEmailSetupSave.php 1 patch
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.
@@ -60,22 +60,22 @@  discard block
 block discarded – undo
60 60
     //name is used as key in post, it is also used in creation of summary page for wizard,
61 61
     //so let's clean up the posting so we can reuse the save functionality for inbound emails and
62 62
     //from existing save.php's  
63
-    foreach($camp_steps as $step){
63
+    foreach ($camp_steps as $step) {
64 64
         clean_up_post($step);
65 65
     }
66 66
 /**************************** Save general Email Setup  *****************************/
67 67
 
68 68
 //we do not need to track location if location type is not set
69
-if(isset($_POST['tracking_entities_location_type'])) {
69
+if (isset($_POST['tracking_entities_location_type'])) {
70 70
     if ($_POST['tracking_entities_location_type'] != '2') {
71 71
         unset($_POST['tracking_entities_location']);
72 72
         unset($_POST['tracking_entities_location_type']);
73 73
     }
74 74
 }
75 75
 //if the check box is empty, then set it to 0
76
-if(!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; }
76
+if (!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; }
77 77
 //default ssl use to false
78
-if(!isset($_POST['mail_smtpssl'])) { $_POST['mail_smtpssl'] = 0; }
78
+if (!isset($_POST['mail_smtpssl'])) { $_POST['mail_smtpssl'] = 0; }
79 79
 //reuse existing saveconfig functionality
80 80
 $focus->saveConfig();
81 81
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
 /**************************** Add New Monitored Box  *****************************/
85 85
 //perform this if the option to create new mail box has been checked
86
-if(isset($_REQUEST['wiz_new_mbox']) && ($_REQUEST['wiz_new_mbox']=='1')){
86
+if (isset($_REQUEST['wiz_new_mbox']) && ($_REQUEST['wiz_new_mbox'] == '1')) {
87 87
     
88 88
    //Populate the Request variables that inboundemail expects
89 89
     $_REQUEST['mark_read'] = 1;
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
     require_once('modules/InboundEmail/Save.php');    
97 97
 
98 98
 }
99
-    if (!empty($_REQUEST['error'])){
99
+    if (!empty($_REQUEST['error'])) {
100 100
             //an error was found during inbound save.  This means the save was allowed but the inbound box had problems, return user to wizard
101 101
             //and display error message
102 102
             $header_URL = "Location: index.php?action=WizardEmailSetup&module=Campaigns&error=true";
103 103
 
104
-        if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
104
+        if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
105 105
             $href = $matches[1];
106 106
             SugarApplication::redirect($href);
107 107
         }
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
             header($headers);
110 110
         }
111 111
 
112
-    }else{
112
+    } else {
113 113
         //set navigation details
114 114
         $header_URL = "Location: index.php?action=index&module=Campaigns";
115 115
 
116
-        if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
116
+        if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
117 117
             $href = $matches[1];
118 118
             SugarApplication::redirect($href);
119 119
         }
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
  * which does not expect the prefix, and still use the generic create summary functionality in wizard, which
130 130
  * does expect the prefix.  
131 131
  */
132
-function clean_up_post($prefix){
132
+function clean_up_post($prefix) {
133 133
 
134 134
     foreach ($_REQUEST as $key => $val) {
135
-              if((strstr($key, $prefix )) && (strpos($key, $prefix )== 0)){
136
-              $newkey  =substr($key, strlen($prefix)) ;
135
+              if ((strstr($key, $prefix)) && (strpos($key, $prefix) == 0)) {
136
+              $newkey = substr($key, strlen($prefix));
137 137
               $_REQUEST[$newkey] = $val;
138 138
          }               
139 139
     }
140 140
 
141 141
     foreach ($_POST as $key => $val) {
142
-              if((strstr($key, $prefix )) && (strpos($key, $prefix )== 0)){
143
-              $newkey  =substr($key, strlen($prefix)) ;
142
+              if ((strstr($key, $prefix)) && (strpos($key, $prefix) == 0)) {
143
+              $newkey = substr($key, strlen($prefix));
144 144
               $_POST[$newkey] = $val;
145 145
               
146 146
          }               
Please login to merge, or discard this patch.
modules/Campaigns/DotListWizardMenu.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
 
24 24
     private function getWizardMenuItemHTML($i, $label, $link = false)
25 25
     {
26
-        if($i >= 4) {
26
+        if ($i >= 4) {
27 27
             parse_str($link, $args);
28
-            if(empty($args['marketing_id'])) {
28
+            if (empty($args['marketing_id'])) {
29 29
                 $link = false;
30 30
             }
31 31
         }
32 32
 
33
-        if($link != false) {
33
+        if ($link != false) {
34 34
             $html = '<li id="nav_step'.$i.'" class="nav-steps" data-nav-step="'.$i.'" data-nav-url="'.$link.'"><div>'.$label.'</div></li>';
35 35
         } else {
36 36
             $html = '<li id="nav_step'.$i.'" class="nav-steps" data-nav-step="'.$i.'"  data-nav-url=""><div>'.$label.'</div></li>';
Please login to merge, or discard this patch.
modules/Campaigns/WizardMarketingSave.php 1 patch
Spacing   +40 added lines, -40 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.
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
 $master = 'save';
54 54
 if (isset($_REQUEST['wiz_home_next_step']) && !empty($_REQUEST['wiz_home_next_step'])) {
55 55
     
56
-    if($_REQUEST['wiz_home_next_step']==3){
56
+    if ($_REQUEST['wiz_home_next_step'] == 3) {
57 57
         //user has chosen to save and schedule this campaign for email
58 58
         $master = 'send';
59
-    }elseif($_REQUEST['wiz_home_next_step']==2){
59
+    }elseif ($_REQUEST['wiz_home_next_step'] == 2) {
60 60
         //user has chosen to save and send this campaign in test mode
61 61
         $master = 'test';
62
-    }else{
62
+    } else {
63 63
         //user has chosen to simply save
64
-        $master  = 'save';        
64
+        $master = 'save';        
65 65
     }
66 66
         
67
-}else{
67
+} else {
68 68
      //default to just saving and exiting wizard
69 69
      $master = 'save';   
70 70
 }
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
     $marketing->retrieve($_REQUEST['record']);
79 79
 }
80 80
 else {
81
-    if(!empty($_SESSION['campaignWizard'][$_REQUEST['campaign_id']]['defaultSelectedMarketingId'])) {
81
+    if (!empty($_SESSION['campaignWizard'][$_REQUEST['campaign_id']]['defaultSelectedMarketingId'])) {
82 82
         $marketing->retrieve($_SESSION['campaignWizard'][$_REQUEST['campaign_id']]['defaultSelectedMarketingId']);
83 83
     }
84 84
 }
85
-if(!$marketing->ACLAccess('Save')){
85
+if (!$marketing->ACLAccess('Save')) {
86 86
         ACLController::displayNoAccess(true);
87 87
         sugar_cleanup(true);
88 88
 }
@@ -95,40 +95,40 @@  discard block
 block discarded – undo
95 95
 }
96 96
 
97 97
     foreach ($_REQUEST as $key => $val) {
98
-              if((strstr($key, $prefix )) && (strpos($key, $prefix )== 0)){
99
-              $newkey  =substr($key, strlen($prefix)) ;
98
+              if ((strstr($key, $prefix)) && (strpos($key, $prefix) == 0)) {
99
+              $newkey = substr($key, strlen($prefix));
100 100
               $_REQUEST[$newkey] = $val;
101 101
          }               
102 102
     }
103 103
 
104 104
     foreach ($_REQUEST as $key => $val) {
105
-              if((strstr($key, $prefix )) && (strpos($key, $prefix )== 0)){
106
-              $newkey  =substr($key, strlen($prefix)) ;
105
+              if ((strstr($key, $prefix)) && (strpos($key, $prefix) == 0)) {
106
+              $newkey = substr($key, strlen($prefix));
107 107
               $_REQUEST[$newkey] = $val;
108 108
          }               
109 109
     }
110 110
 
111
-if(!empty($_REQUEST['meridiem'])){
112
-    $_REQUEST['time_start'] = $timedate->merge_time_meridiem($_REQUEST['time_start'],$timedate->get_time_format(), $_REQUEST['meridiem']);
111
+if (!empty($_REQUEST['meridiem'])) {
112
+    $_REQUEST['time_start'] = $timedate->merge_time_meridiem($_REQUEST['time_start'], $timedate->get_time_format(), $_REQUEST['meridiem']);
113 113
 }
114 114
 
115
-if(empty($_REQUEST['time_start'])) {
116
-  $_REQUEST['date_start'] = $_REQUEST['date_start'] . ' 00:00';	
115
+if (empty($_REQUEST['time_start'])) {
116
+  $_REQUEST['date_start'] = $_REQUEST['date_start'].' 00:00';	
117 117
 } else {
118
-  $_REQUEST['date_start'] = $_REQUEST['date_start'] . ' ' . $_REQUEST['time_start'];
118
+  $_REQUEST['date_start'] = $_REQUEST['date_start'].' '.$_REQUEST['time_start'];
119 119
 }
120 120
 
121
-foreach($marketing->column_fields as $field)
121
+foreach ($marketing->column_fields as $field)
122 122
 {
123 123
     if ($field == 'all_prospect_lists') {
124
-        if(isset($_REQUEST[$field]) && $_REQUEST[$field]='on' )
124
+        if (isset($_REQUEST[$field]) && $_REQUEST[$field] = 'on')
125 125
         {
126 126
             $marketing->$field = 1;
127 127
         } else {
128 128
             $marketing->$field = 0;         
129 129
         }
130
-    }else {
131
-        if(isset($_REQUEST[$field]))
130
+    } else {
131
+        if (isset($_REQUEST[$field]))
132 132
         {
133 133
             $value = $_REQUEST[$field];
134 134
             $marketing->$field = trim($value);
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
     }
137 137
 }
138 138
 
139
-foreach($marketing->additional_column_fields as $field)
139
+foreach ($marketing->additional_column_fields as $field)
140 140
 {
141
-    if(isset($_REQUEST[$field]))
141
+    if (isset($_REQUEST[$field]))
142 142
     {
143 143
         $value = $_REQUEST[$field];
144 144
         $marketing->$field = $value;
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 
151 151
 //add prospect lists to campaign.
152 152
 $marketing->load_relationship('prospectlists');
153
-$prospectlists=$marketing->prospectlists->get();
154
-if ($marketing->all_prospect_lists==1) {
153
+$prospectlists = $marketing->prospectlists->get();
154
+if ($marketing->all_prospect_lists == 1) {
155 155
     //remove all related prospect lists.
156 156
     if (!empty($prospectlists)) {
157 157
         $marketing->prospectlists->delete($marketing->id);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     if (isset($_REQUEST['message_for']) && is_array($_REQUEST['message_for'])) {
161 161
         foreach ($_REQUEST['message_for'] as $prospect_list_id) {
162 162
             
163
-            $key=array_search($prospect_list_id,$prospectlists);
163
+            $key = array_search($prospect_list_id, $prospectlists);
164 164
             if ($key === null or $key === false) {
165 165
                 $marketing->prospectlists->add($prospect_list_id);          
166 166
             } else {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         }
170 170
         if (count($prospectlists) != 0) {
171 171
             foreach ($prospectlists as $key=>$list_id) {
172
-                $marketing->prospectlists->delete($marketing->id,$list_id);             
172
+                $marketing->prospectlists->delete($marketing->id, $list_id);             
173 173
             }   
174 174
         }
175 175
     }
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
 $mass[] = $marketing->id; 
180 180
 //if sending an email was chosen, set all the needed variables for queuing campaign
181 181
 
182
-if($master !='save'){
183
-    $_REQUEST['mass']= $mass;
184
-    $_POST['mass']=$mass;
185
-    $_REQUEST['record'] =$marketing->campaign_id;
186
-    $_POST['record']=$marketing->campaign_id;
182
+if ($master != 'save') {
183
+    $_REQUEST['mass'] = $mass;
184
+    $_POST['mass'] = $mass;
185
+    $_REQUEST['record'] = $marketing->campaign_id;
186
+    $_POST['record'] = $marketing->campaign_id;
187 187
     $_REQUEST['mode'] = $master;
188 188
      $_POST['mode'] = $master; 
189
-     $_REQUEST['from_wiz']= 'true';
189
+     $_REQUEST['from_wiz'] = 'true';
190 190
     require_once('modules/Campaigns/QueueCampaign.php');
191 191
 }
192 192
 
193
-if(isset($_REQUEST['show_wizard_summary']) && $_REQUEST['show_wizard_summary']) {
193
+if (isset($_REQUEST['show_wizard_summary']) && $_REQUEST['show_wizard_summary']) {
194 194
 
195
-    if( (isset($_REQUEST['sendMarketingEmailTest']) && $_REQUEST['sendMarketingEmailTest']) ||
196
-        (isset($_REQUEST['sendMarketingEmailSchedule']) && $_REQUEST['sendMarketingEmailSchedule']) ) {
195
+    if ((isset($_REQUEST['sendMarketingEmailTest']) && $_REQUEST['sendMarketingEmailTest']) ||
196
+        (isset($_REQUEST['sendMarketingEmailSchedule']) && $_REQUEST['sendMarketingEmailSchedule'])) {
197 197
         // set correct post variables..
198 198
         $_POST['module'] = 'Campaigns';
199 199
         $_POST['action'] = 'QueueCampaign';
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
         $_POST['direct_step'] = '1';
206 206
         //$_POST['campaign_id'] = '';
207 207
         $_POST['wiz_mass'] = $marketing->id;
208
-        if(isset($_REQUEST['sendMarketingEmailTest']) && $_REQUEST['sendMarketingEmailTest']) {
208
+        if (isset($_REQUEST['sendMarketingEmailTest']) && $_REQUEST['sendMarketingEmailTest']) {
209 209
             $_POST['mode'] = 'test';
210 210
         }
211
-        else if(isset($_REQUEST['sendMarketingEmailSchedule']) && $_REQUEST['sendMarketingEmailSchedule']) {
211
+        else if (isset($_REQUEST['sendMarketingEmailSchedule']) && $_REQUEST['sendMarketingEmailSchedule']) {
212 212
             $_POST['mode'] = 'send';
213 213
             $_SESSION['msg'] = 'LBL_EMAILS_SCHEDULED';
214 214
         }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
         exit;
223 223
     }
224 224
 
225
-    $header_URL = "Location: index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome&return_id=" . $marketing->campaign_id . "&campaign_id=" . $marketing->campaign_id . "&jump=3&marketing_id=" . $marketing->id;
225
+    $header_URL = "Location: index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome&return_id=".$marketing->campaign_id."&campaign_id=".$marketing->campaign_id."&jump=3&marketing_id=".$marketing->id;
226 226
 }
227 227
 else {
228 228
     $header_URL = "Location: index.php?action=WizardHome&module=Campaigns&record=".$marketing->campaign_id;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
 $GLOBALS['log']->debug("about to post header URL of: $header_URL");
232 232
 
233
-if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
233
+if (preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) {
234 234
     $href = $matches[1];
235 235
     SugarApplication::redirect($href);
236 236
 }
Please login to merge, or discard this patch.