Completed
Push — console-installer ( e2b50d...6ce748 )
by Adam
22:30
created
modules/Calls/metadata/SearchFields.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -39,33 +39,33 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 global $current_user;
41 41
 $module_name = "Calls";
42
-$searchFields['Calls'] = array (
42
+$searchFields['Calls'] = array(
43 43
   'name' =>
44
-  array (
44
+  array(
45 45
     'query_type' => 'default',
46 46
   ),
47 47
   'contact_name' => 
48
-  array (
48
+  array(
49 49
     'query_type' => 'default',
50 50
     'db_field' => 
51
-    array (
51
+    array(
52 52
       0 => 'contacts.first_name',
53 53
       1 => 'contacts.last_name',
54 54
     ),
55 55
   ),
56 56
   'date_start' => 
57
-  array (
57
+  array(
58 58
     'query_type' => 'default',
59 59
   ),
60 60
   'location' => 
61
-  array (
61
+  array(
62 62
     'query_type' => 'default',
63 63
   ),
64 64
   'current_user_only' => 
65
-  array (
65
+  array(
66 66
     'query_type' => 'default',
67 67
     'db_field' => 
68
-    array (
68
+    array(
69 69
       0 => 'assigned_user_id',
70 70
     ),
71 71
     'my_items' => true,
@@ -73,98 +73,98 @@  discard block
 block discarded – undo
73 73
     'type' => 'bool',
74 74
   ),
75 75
   'assigned_user_id' => 
76
-  array (
76
+  array(
77 77
     'query_type' => 'default',
78 78
   ),
79 79
   'status' => 
80
-  array (
80
+  array(
81 81
     'query_type' => 'default',
82 82
     'options' => 'call_status_dom',
83 83
     'template_var' => 'STATUS_FILTER',
84 84
   ),
85 85
   'open_only' => 
86
-  array (
86
+  array(
87 87
     'query_type' => 'default',
88 88
     'db_field' => 
89
-    array (
89
+    array(
90 90
       0 => 'status',
91 91
     ),
92 92
     'operator' => 'not in',
93 93
     'closed_values' => 
94
-    array (
94
+    array(
95 95
       0 => 'Held',
96 96
       1 => 'Not Held',
97 97
     ),
98 98
     'type' => 'bool',
99 99
   ),
100 100
   'range_date_entered' => 
101
-  array (
101
+  array(
102 102
     'query_type' => 'default',
103 103
     'enable_range_search' => true,
104 104
     'is_date_field' => true,
105 105
   ),
106 106
   'start_range_date_entered' => 
107
-  array (
107
+  array(
108 108
     'query_type' => 'default',
109 109
     'enable_range_search' => true,
110 110
     'is_date_field' => true,
111 111
   ),
112 112
   'end_range_date_entered' => 
113
-  array (
113
+  array(
114 114
     'query_type' => 'default',
115 115
     'enable_range_search' => true,
116 116
     'is_date_field' => true,
117 117
   ),
118 118
   'range_date_modified' => 
119
-  array (
119
+  array(
120 120
     'query_type' => 'default',
121 121
     'enable_range_search' => true,
122 122
     'is_date_field' => true,
123 123
   ),
124 124
   'start_range_date_modified' => 
125
-  array (
125
+  array(
126 126
     'query_type' => 'default',
127 127
     'enable_range_search' => true,
128 128
     'is_date_field' => true,
129 129
   ),
130 130
   'end_range_date_modified' => 
131
-  array (
131
+  array(
132 132
     'query_type' => 'default',
133 133
     'enable_range_search' => true,
134 134
     'is_date_field' => true,
135 135
   ),
136 136
   'range_date_start' => 
137
-  array (
137
+  array(
138 138
     'query_type' => 'default',
139 139
     'enable_range_search' => true,
140 140
     'is_date_field' => true,
141 141
   ),
142 142
   'start_range_date_start' => 
143
-  array (
143
+  array(
144 144
     'query_type' => 'default',
145 145
     'enable_range_search' => true,
146 146
     'is_date_field' => true,
147 147
   ),
148 148
   'end_range_date_start' => 
149
-  array (
149
+  array(
150 150
     'query_type' => 'default',
151 151
     'enable_range_search' => true,
152 152
     'is_date_field' => true,
153 153
   ),
154 154
   'range_date_end' => 
155
-  array (
155
+  array(
156 156
     'query_type' => 'default',
157 157
     'enable_range_search' => true,
158 158
     'is_date_field' => true,
159 159
   ),
160 160
   'start_range_date_end' => 
161
-  array (
161
+  array(
162 162
     'query_type' => 'default',
163 163
     'enable_range_search' => true,
164 164
     'is_date_field' => true,
165 165
   ),
166 166
   'end_range_date_end' => 
167
-  array (
167
+  array(
168 168
     'query_type' => 'default',
169 169
     'enable_range_search' => true,
170 170
     'is_date_field' => true,
@@ -175,6 +175,6 @@  discard block
 block discarded – undo
175 175
         'subquery' => "SELECT favorites.parent_id FROM favorites
176 176
 			                    WHERE favorites.deleted = 0
177 177
 			                        and favorites.parent_type = '".$module_name."'
178
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
178
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
179 179
         'db_field'=>array('id')),
180 180
 );
181 181
\ No newline at end of file
Please login to merge, or discard this patch.
modules/Cases/metadata/SearchFields.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -39,42 +39,42 @@  discard block
 block discarded – undo
39 39
  ********************************************************************************/
40 40
 global $current_user;
41 41
 $module_name = "Cases";
42
-$searchFields['Cases'] = array (
42
+$searchFields['Cases'] = array(
43 43
   'name' => 
44
-  array (
44
+  array(
45 45
     'query_type' => 'default',
46 46
   ),
47 47
   'account_name' => 
48
-  array (
48
+  array(
49 49
     'query_type' => 'default',
50 50
     'db_field' => 
51
-    array (
51
+    array(
52 52
       0 => 'accounts.name',
53 53
     ),
54 54
   ),
55 55
   'status' => 
56
-  array (
56
+  array(
57 57
     'query_type' => 'default',
58 58
     'options' => 'case_status_dom',
59 59
     'template_var' => 'STATUS_OPTIONS',
60 60
   ),
61 61
   'priority' => 
62
-  array (
62
+  array(
63 63
     'query_type' => 'default',
64 64
     'options' => 'case_priority_dom',
65 65
     'template_var' => 'PRIORITY_OPTIONS',
66 66
     'options_add_blank' => true,
67 67
   ),
68 68
   'case_number' => 
69
-  array (
69
+  array(
70 70
     'query_type' => 'default',
71 71
     'operator' => 'in',
72 72
   ),
73 73
   'current_user_only' => 
74
-  array (
74
+  array(
75 75
     'query_type' => 'default',
76 76
     'db_field' => 
77
-    array (
77
+    array(
78 78
       0 => 'assigned_user_id',
79 79
     ),
80 80
     'my_items' => true,
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
     'type' => 'bool',
83 83
   ),
84 84
   'assigned_user_id' => 
85
-  array (
85
+  array(
86 86
     'query_type' => 'default',
87 87
   ),
88 88
   'open_only' => 
89
-  array (
89
+  array(
90 90
     'query_type' => 'default',
91 91
     'db_field' => 
92
-    array (
92
+    array(
93 93
       0 => 'status',
94 94
     ),
95 95
     'operator' => 'not in',
96 96
     'closed_values' => 
97
-    array (
97
+    array(
98 98
       0 => 'Closed',
99 99
       1 => 'Rejected',
100 100
       2 => 'Duplicate',
@@ -105,43 +105,43 @@  discard block
 block discarded – undo
105 105
     'type' => 'bool',
106 106
   ),
107 107
   'range_date_entered' => 
108
-  array (
108
+  array(
109 109
     'query_type' => 'default',
110 110
     'enable_range_search' => true,
111 111
     'is_date_field' => true,
112 112
   ),
113 113
   'start_range_date_entered' => 
114
-  array (
114
+  array(
115 115
     'query_type' => 'default',
116 116
     'enable_range_search' => true,
117 117
     'is_date_field' => true,
118 118
   ),
119 119
   'end_range_date_entered' => 
120
-  array (
120
+  array(
121 121
     'query_type' => 'default',
122 122
     'enable_range_search' => true,
123 123
     'is_date_field' => true,
124 124
   ),
125 125
   'range_date_modified' => 
126
-  array (
126
+  array(
127 127
     'query_type' => 'default',
128 128
     'enable_range_search' => true,
129 129
     'is_date_field' => true,
130 130
   ),
131 131
   'start_range_date_modified' => 
132
-  array (
132
+  array(
133 133
     'query_type' => 'default',
134 134
     'enable_range_search' => true,
135 135
     'is_date_field' => true,
136 136
   ),
137 137
   'end_range_date_modified' => 
138
-  array (
138
+  array(
139 139
     'query_type' => 'default',
140 140
     'enable_range_search' => true,
141 141
     'is_date_field' => true,
142 142
   ),
143 143
   'state' => 
144
-  array (
144
+  array(
145 145
     'query_type' => 'default',
146 146
   ),
147 147
     'favorites_only' => array(
@@ -150,6 +150,6 @@  discard block
 block discarded – undo
150 150
         'subquery' => "SELECT favorites.parent_id FROM favorites
151 151
 			                    WHERE favorites.deleted = 0
152 152
 			                        and favorites.parent_type = '".$module_name."'
153
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
153
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
154 154
         'db_field'=>array('id')),
155 155
 );
156 156
\ No newline at end of file
Please login to merge, or discard this patch.
modules/EmailTemplates/EmailTemplate.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
     /**
122 122
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
123 123
      */
124
-    public function EmailTemplate(){
124
+    public function EmailTemplate() {
125 125
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
126
-        if(isset($GLOBALS['log'])) {
126
+        if (isset($GLOBALS['log'])) {
127 127
             $GLOBALS['log']->deprecated($deprecatedMessage);
128 128
         }
129 129
         else {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                             }
369 369
                             if (!empty($tracker_url) && !empty($template_text) && !empty($matches[0][$i][0]) && !empty($tracked_urls[$matches[0][$i][0]])) {
370 370
                                 $template_text = substr_replace($template_text, $tracker_url, $matches[0][$i][1], strlen($matches[0][$i][0]));
371
-                                $template_text = str_replace($sugar_config['site_url'] . '/' . $sugar_config['site_url'], $sugar_config['site_url'], $template_text);
371
+                                $template_text = str_replace($sugar_config['site_url'].'/'.$sugar_config['site_url'], $sugar_config['site_url'], $template_text);
372 372
                             }
373 373
                         }
374 374
                     }
@@ -420,10 +420,10 @@  discard block
 block discarded – undo
420 420
         if ($beanList[$focus_name] == 'User') {
421 421
             $pattern_prefix = '$contact_user_';
422 422
         } else {
423
-            $pattern_prefix = '$' . strtolower($beanList[$focus_name]) . '_';
423
+            $pattern_prefix = '$'.strtolower($beanList[$focus_name]).'_';
424 424
         }
425 425
         $pattern_prefix_length = strlen($pattern_prefix);
426
-        $pattern = '/\\' . $pattern_prefix . '[A-Za-z_0-9]*/';
426
+        $pattern = '/\\'.$pattern_prefix.'[A-Za-z_0-9]*/';
427 427
 
428 428
         $return_array = array();
429 429
         foreach ($template_text_array as $key => $template_text) {
@@ -521,16 +521,16 @@  discard block
 block discarded – undo
521 521
                 $translated = translate($field_def['options'], 'Users', $user->$fieldName);
522 522
 
523 523
                 if (isset($translated) && !is_array($translated)) {
524
-                    $repl_arr["contact_user_" . $fieldName] = $translated;
524
+                    $repl_arr["contact_user_".$fieldName] = $translated;
525 525
                 } else { // unset enum field, make sure we have a match string to replace with ""
526
-                    $repl_arr["contact_user_" . $fieldName] = '';
526
+                    $repl_arr["contact_user_".$fieldName] = '';
527 527
                 }
528 528
             } else {
529 529
                 if (isset($user->$fieldName)) {
530 530
                     // bug 47647 - allow for fields to translate before adding to template
531
-                    $repl_arr["contact_user_" . $fieldName] = self::_convertToType($field_def['type'], $user->$fieldName);
531
+                    $repl_arr["contact_user_".$fieldName] = self::_convertToType($field_def['type'], $user->$fieldName);
532 532
                 } else {
533
-                    $repl_arr["contact_user_" . $fieldName] = "";
533
+                    $repl_arr["contact_user_".$fieldName] = "";
534 534
                 }
535 535
             }
536 536
         }
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
                 continue;
557 557
             }
558 558
             $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
559
-                'contact_' . $field_def['name'] => '',
560
-                'contact_account_' . $field_def['name'] => '',
559
+                'contact_'.$field_def['name'] => '',
560
+                'contact_account_'.$field_def['name'] => '',
561 561
             ));
562 562
         }
563 563
         foreach ($prospect->field_defs as $field_def) {
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
                 continue;
566 566
             }
567 567
             $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
568
-                'contact_' . $field_def['name'] => '',
569
-                'contact_account_' . $field_def['name'] => '',
568
+                'contact_'.$field_def['name'] => '',
569
+                'contact_account_'.$field_def['name'] => '',
570 570
             ));
571 571
         }
572 572
         foreach ($contact->field_defs as $field_def) {
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
                 continue;
575 575
             }
576 576
             $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
577
-                'contact_' . $field_def['name'] => '',
578
-                'contact_account_' . $field_def['name'] => '',
577
+                'contact_'.$field_def['name'] => '',
578
+                'contact_account_'.$field_def['name'] => '',
579 579
             ));
580 580
         }
581 581
         foreach ($acct->field_defs as $field_def) {
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
                 continue;
584 584
             }
585 585
             $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
586
-                'account_' . $field_def['name'] => '',
587
-                'account_contact_' . $field_def['name'] => '',
586
+                'account_'.$field_def['name'] => '',
587
+                'account_contact_'.$field_def['name'] => '',
588 588
             ));
589 589
         }
590 590
         // cn: end bug 9277 fix
@@ -609,21 +609,21 @@  discard block
 block discarded – undo
609 609
 
610 610
                         if (isset($translated) && !is_array($translated)) {
611 611
                             $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
612
-                                'account_' . $fieldName => $translated,
613
-                                'contact_account_' . $fieldName => $translated,
612
+                                'account_'.$fieldName => $translated,
613
+                                'contact_account_'.$fieldName => $translated,
614 614
                             ));
615 615
                         } else { // unset enum field, make sure we have a match string to replace with ""
616 616
                             $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
617
-                                'account_' . $fieldName => '',
618
-                                'contact_account_' . $fieldName => '',
617
+                                'account_'.$fieldName => '',
618
+                                'contact_account_'.$fieldName => '',
619 619
                             ));
620 620
                         }
621 621
                     } else {
622 622
                         // bug 47647 - allow for fields to translate before adding to template
623 623
                         $translated = self::_convertToType($field_def['type'], $acct->$fieldName);
624 624
                         $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
625
-                            'account_' . $fieldName => $translated,
626
-                            'contact_account_' . $fieldName => $translated,
625
+                            'account_'.$fieldName => $translated,
626
+                            'contact_account_'.$fieldName => $translated,
627 627
                         ));
628 628
                     }
629 629
                 }
@@ -654,13 +654,13 @@  discard block
 block discarded – undo
654 654
 
655 655
                     if (isset($translated) && !is_array($translated)) {
656 656
                         $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
657
-                            'contact_' . $fieldName => $translated,
658
-                            'contact_account_' . $fieldName => $translated,
657
+                            'contact_'.$fieldName => $translated,
658
+                            'contact_account_'.$fieldName => $translated,
659 659
                         ));
660 660
                     } else { // unset enum field, make sure we have a match string to replace with ""
661 661
                         $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
662
-                            'contact_' . $fieldName => '',
663
-                            'contact_account_' . $fieldName => '',
662
+                            'contact_'.$fieldName => '',
663
+                            'contact_account_'.$fieldName => '',
664 664
                         ));
665 665
                     }
666 666
                 } else {
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
                         // bug 47647 - allow for fields to translate before adding to template
669 669
                         $translated = self::_convertToType($field_def['type'], $contact->$fieldName);
670 670
                         $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
671
-                            'contact_' . $fieldName => $translated,
672
-                            'contact_account_' . $fieldName => $translated,
671
+                            'contact_'.$fieldName => $translated,
672
+                            'contact_account_'.$fieldName => $translated,
673 673
                         ));
674 674
                     } // if
675 675
                 }
@@ -690,27 +690,27 @@  discard block
 block discarded – undo
690 690
 
691 691
                     if (isset($translated) && !is_array($translated)) {
692 692
                         $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
693
-                            strtolower($beanList[$bean_name]) . "_" . $fieldName => $translated,
693
+                            strtolower($beanList[$bean_name])."_".$fieldName => $translated,
694 694
                         ));
695 695
                     } else { // unset enum field, make sure we have a match string to replace with ""
696 696
                         $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
697
-                            strtolower($beanList[$bean_name]) . "_" . $fieldName => '',
697
+                            strtolower($beanList[$bean_name])."_".$fieldName => '',
698 698
                         ));
699 699
                     }
700 700
                 } else {
701 701
                     // bug 47647 - translate currencies to appropriate values
702 702
                     $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
703
-                        strtolower($beanList[$bean_name]) . "_" . $fieldName => self::_convertToType($field_def['type'], $focus->$fieldName),
703
+                        strtolower($beanList[$bean_name])."_".$fieldName => self::_convertToType($field_def['type'], $focus->$fieldName),
704 704
                     ));
705 705
                 }
706 706
             } else {
707 707
                 if ($fieldName == 'full_name') {
708 708
                     $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
709
-                        strtolower($beanList[$bean_name]) . '_full_name' => $focus->get_summary_text(),
709
+                        strtolower($beanList[$bean_name]).'_full_name' => $focus->get_summary_text(),
710 710
                     ));
711 711
                 } else {
712 712
                     $repl_arr = EmailTemplate::add_replacement($repl_arr, $field_def, array(
713
-                        strtolower($beanList[$bean_name]) . "_" . $fieldName => '',
713
+                        strtolower($beanList[$bean_name])."_".$fieldName => '',
714 714
                     ));
715 715
                 }
716 716
             }
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
     {
762 762
         foreach ($bean_arr as $bean_name => $bean_id) {
763 763
 
764
-            $focus = BeanFactory::getBean($bean_name,$bean_id);
764
+            $focus = BeanFactory::getBean($bean_name, $bean_id);
765 765
 
766 766
             if ($bean_name == 'Leads' || $bean_name == 'Prospects') {
767 767
                 $bean_name = 'Contacts';
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
         $this->repairMozaikClears();
844 844
         $this->imageLinkReplaced = false;
845 845
         $this->repairEntryPointImages();
846
-        if($this->imageLinkReplaced) {
846
+        if ($this->imageLinkReplaced) {
847 847
             $this->save();
848 848
         }
849 849
         return $ret;
@@ -862,13 +862,13 @@  discard block
 block discarded – undo
862 862
         // repair the images url at entry points, change to a public direct link for remote email clients..
863 863
 
864 864
         $siteUrlQuoted = str_replace(array(':', '/'), array('\:', '\/'), $sugar_config['site_url']);
865
-        $regex = '/&lt;img src=&quot;(' . $siteUrlQuoted . '\/index\.php\?entryPoint=download&type=Notes&id=([a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12})&filename=[^&]+)&quot;/';
865
+        $regex = '/&lt;img src=&quot;('.$siteUrlQuoted.'\/index\.php\?entryPoint=download&type=Notes&id=([a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12})&filename=[^&]+)&quot;/';
866 866
 
867
-        if(preg_match($regex, $this->body_html, $match)) {
867
+        if (preg_match($regex, $this->body_html, $match)) {
868 868
             $splits = explode('.', $match[1]);
869 869
             $fileExtension = end($splits);
870 870
             $this->makePublicImage($match[2]);
871
-            $directLink = '&lt;img src=&quot;' . $sugar_config['site_url'] . '/public/' . $match[2] . '.' . $fileExtension . '&quot;';
871
+            $directLink = '&lt;img src=&quot;'.$sugar_config['site_url'].'/public/'.$match[2].'.'.$fileExtension.'&quot;';
872 872
             $this->body_html = str_replace($match[0], $directLink, $this->body_html);
873 873
             $this->imageLinkReplaced = true;
874 874
             $this->repairEntryPointImages();
@@ -877,25 +877,25 @@  discard block
 block discarded – undo
877 877
     }
878 878
 
879 879
     private function makePublicImage($id) {
880
-        $toFile = 'public/' . $id . '.jpg';
881
-        if(file_exists($toFile)) {
880
+        $toFile = 'public/'.$id.'.jpg';
881
+        if (file_exists($toFile)) {
882 882
             return;
883 883
         }
884
-        $fromFile = 'upload://' . $id;
885
-        if(!file_exists($fromFile)) {
884
+        $fromFile = 'upload://'.$id;
885
+        if (!file_exists($fromFile)) {
886 886
             throw new Exceptin('file not found');
887 887
         }
888
-        if(!file_exists('public')) {
888
+        if (!file_exists('public')) {
889 889
             sugar_mkdir('public', 777);
890 890
         }
891 891
         $fdata = file_get_contents($fromFile);
892
-        if(!file_put_contents($toFile, $fdata)) {
892
+        if (!file_put_contents($toFile, $fdata)) {
893 893
             throw new Exception('file write error');
894 894
         }
895 895
     }
896 896
 
897 897
     public function getAttachments() {
898
-        return BeanFactory::getBean('Notes')->get_full_list('', "parent_id = '" . $this->id . "'");
898
+        return BeanFactory::getBean('Notes')->get_full_list('', "parent_id = '".$this->id."'");
899 899
     }
900 900
 
901 901
 }
Please login to merge, or discard this patch.
modules/EmailTemplates/EmailTemplateData.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
 if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 function handleAttachmentForRemove() {
5
-    if(!empty($_REQUEST['attachmentsRemove'])) {
6
-        foreach($_REQUEST['attachmentsRemove'] as $attachmentIdForRemove) {
7
-            if($bean = BeanFactory::getBean('Notes', $attachmentIdForRemove)) {
5
+    if (!empty($_REQUEST['attachmentsRemove'])) {
6
+        foreach ($_REQUEST['attachmentsRemove'] as $attachmentIdForRemove) {
7
+            if ($bean = BeanFactory::getBean('Notes', $attachmentIdForRemove)) {
8 8
                 $bean->mark_deleted($bean->id);
9 9
             }
10 10
         }
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 $emailTemplateId = isset($_REQUEST['emailTemplateId']) && $_REQUEST['emailTemplateId'] ? $_REQUEST['emailTemplateId'] : null;
19 19
 $_SESSION['campaignWizard'][$_REQUEST['campaignId']]['defaultSelectedTemplateId'] = $emailTemplateId;
20 20
 
21
-if(preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/', $emailTemplateId) || !$emailTemplateId) {
21
+if (preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/', $emailTemplateId) || !$emailTemplateId) {
22 22
 
23 23
     $func = isset($_REQUEST['func']) ? $_REQUEST['func'] : null;
24 24
 
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
 
29 29
     include_once 'modules/EmailTemplates/EmailTemplateFormBase.php';
30 30
 
31
-    switch($func) {
31
+    switch ($func) {
32 32
 
33 33
         case 'update':
34 34
             $bean = BeanFactory::getBean('EmailTemplates', $emailTemplateId);
35
-            foreach($bean as $key => $value) {
36
-                if(in_array($key, $fields)) {
35
+            foreach ($bean as $key => $value) {
36
+                if (in_array($key, $fields)) {
37 37
                     $bean->$key = $_POST[$key];
38 38
                 }
39 39
             }
40 40
             $formBase = new EmailTemplateFormBase();
41 41
             $bean = $formBase->handleAttachmentsProcessImages($bean, false, true, 'download', true);
42
-            if($bean->save()) {
42
+            if ($bean->save()) {
43 43
                 $msgs[] = 'LBL_TEMPLATE_SAVED';
44 44
             }
45 45
             //$formBase = new EmailTemplateFormBase();
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
             handleAttachmentForRemove();
50 50
 
51 51
             // update marketing->template_id if we have a selected marketing..
52
-            if(!empty($_SESSION['campaignWizard'][$_REQUEST['campaignId']]['defaultSelectedMarketingId']) && !empty($_REQUEST['campaignId'])) {
52
+            if (!empty($_SESSION['campaignWizard'][$_REQUEST['campaignId']]['defaultSelectedMarketingId']) && !empty($_REQUEST['campaignId'])) {
53 53
                 $marketingId = $_SESSION['campaignWizard'][$_REQUEST['campaignId']]['defaultSelectedMarketingId'];
54 54
 
55 55
                 $campaign = BeanFactory::getBean('Campaigns', $_REQUEST['campaignId']);
56 56
                 $campaign->load_relationship('emailmarketing');
57 57
                 $marketings = $campaign->emailmarketing->get();
58 58
                 // just a double check for campaign->marketing relation correct is for e.g the user deleted the marketing record or something may could happened..
59
-                if(in_array($marketingId, $marketings)) {
59
+                if (in_array($marketingId, $marketings)) {
60 60
                     $marketing = BeanFactory::getBean('EmailMarketing', $marketingId);
61 61
                     $marketing->template_id = $emailTemplateId;
62 62
                     $marketing->save();
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
             $bean = BeanFactory::getBean('EmailTemplates', $emailTemplateId);
73 73
             $newBean = new EmailTemplate();
74 74
             $fieldsForCopy = array('type', 'description');
75
-            foreach($bean as $key => $value) {
76
-                if(in_array($key, $fields)) {
75
+            foreach ($bean as $key => $value) {
76
+                if (in_array($key, $fields)) {
77 77
                     $newBean->$key = $_POST[$key];
78 78
                 }
79
-                else if(in_array($key, $fieldsForCopy)) {
79
+                else if (in_array($key, $fieldsForCopy)) {
80 80
                     $newBean->$key = $bean->$key;
81 81
                 }
82 82
             }
83
-            if($newBean->save()) {
83
+            if ($newBean->save()) {
84 84
                 $msgs[] = 'LBL_TEMPLATE_SAVED';
85 85
             }
86 86
             //$formBase = new EmailTemplateFormBase();
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
             $focus = BeanFactory::getBean('EmailTemplates', $_REQUEST['attach_to_template_id']);
95 95
             //$data = $formBase->handleAttachments($focus, false, null);
96 96
             $data = $formBase->handleAttachmentsProcessImages($focus, false, true, 'download', true);
97
-            $redirectUrl = 'index.php?module=Campaigns&action=WizardMarketing&campaign_id=' . $_REQUEST['campaign_id'] . "&jump=2&template_id=" . $_REQUEST['attach_to_template_id']; // . '&marketing_id=' . $_REQUEST['attach_to_marketing_id'] . '&record=' . $_REQUEST['attach_to_marketing_id'];
98
-            header('Location: ' . $redirectUrl);
97
+            $redirectUrl = 'index.php?module=Campaigns&action=WizardMarketing&campaign_id='.$_REQUEST['campaign_id']."&jump=2&template_id=".$_REQUEST['attach_to_template_id']; // . '&marketing_id=' . $_REQUEST['attach_to_marketing_id'] . '&record=' . $_REQUEST['attach_to_marketing_id'];
98
+            header('Location: '.$redirectUrl);
99 99
             die();
100 100
             break;
101 101
 
102 102
         default: case 'get':
103
-            if($bean = BeanFactory::getBean('EmailTemplates', $emailTemplateId)) {
103
+            if ($bean = BeanFactory::getBean('EmailTemplates', $emailTemplateId)) {
104 104
                 $fields = array('id', 'name', 'body', 'body_html', 'subject');
105 105
                 foreach ($bean as $key => $value) {
106 106
                     if (in_array($key, $fields)) {
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 
111 111
                 $data['body_from_html'] = from_html($bean->body_html);
112 112
                 $attachmentBeans = $bean->getAttachments();
113
-                if($attachmentBeans) {
113
+                if ($attachmentBeans) {
114 114
                     $attachments = array();
115
-                    foreach($attachmentBeans as $attachmentBean) {
115
+                    foreach ($attachmentBeans as $attachmentBean) {
116 116
                         $attachments[] = array(
117 117
                             'id' => $attachmentBean->id,
118 118
                             'name' => $attachmentBean->name,
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 );
146 146
 
147 147
 $results = json_encode($results);
148
-if(!$results) {
149
-    if(json_last_error()) {
148
+if (!$results) {
149
+    if (json_last_error()) {
150 150
         $results = array(
151 151
             'error' => 'json_encode error: '.json_last_error_msg()
152 152
         );
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 
4 6
 function handleAttachmentForRemove() {
5 7
     if(!empty($_REQUEST['attachmentsRemove'])) {
@@ -60,8 +62,7 @@  discard block
 block discarded – undo
60 62
                     $marketing = BeanFactory::getBean('EmailMarketing', $marketingId);
61 63
                     $marketing->template_id = $emailTemplateId;
62 64
                     $marketing->save();
63
-                }
64
-                else {
65
+                } else {
65 66
                     // TODO something is not OK, the selected campaign isn't related to this marketing!!
66 67
                     $GLOBALS['log']->debug('Selected marketing not found!');
67 68
                 }
@@ -75,8 +76,7 @@  discard block
 block discarded – undo
75 76
             foreach($bean as $key => $value) {
76 77
                 if(in_array($key, $fields)) {
77 78
                     $newBean->$key = $_POST[$key];
78
-                }
79
-                else if(in_array($key, $fieldsForCopy)) {
79
+                } else if(in_array($key, $fieldsForCopy)) {
80 80
                     $newBean->$key = $bean->$key;
81 81
                 }
82 82
             }
@@ -125,16 +125,14 @@  discard block
 block discarded – undo
125 125
                     }
126 126
                     $data['attachments'] = $attachments;
127 127
                 }
128
-            }
129
-            else {
128
+            } else {
130 129
                 $error = 'Email Template not found.';
131 130
             }
132 131
             break;
133 132
     }
134 133
 
135 134
 
136
-}
137
-else {
135
+} else {
138 136
     $error = 'Illegal GUID format.';
139 137
 }
140 138
 
Please login to merge, or discard this patch.
modules/EmailTemplates/EmailTemplateFormBase.php 2 patches
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -54,24 +54,24 @@  discard block
 block discarded – undo
54 54
 
55 55
     }
56 56
 
57
-	function getFormBody($prefix, $mod='',$formname='', $size='30') {
57
+    function getFormBody($prefix, $mod='',$formname='', $size='30') {
58 58
 
59 59
 
60
-		global $mod_strings;
60
+        global $mod_strings;
61 61
 
62
-		$temp_strings = $mod_strings;
62
+        $temp_strings = $mod_strings;
63 63
 
64
-		if(!empty($mod)) {
65
-			global $current_language;
66
-			$mod_strings = return_module_language($current_language, $mod);
67
-		}
68
-					global $app_strings;
69
-					global $app_list_strings;
64
+        if(!empty($mod)) {
65
+            global $current_language;
66
+            $mod_strings = return_module_language($current_language, $mod);
67
+        }
68
+                    global $app_strings;
69
+                    global $app_list_strings;
70 70
 
71
-				$lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
72
-				$lbl_subject = $mod_strings['LBL_NOTE_SUBJECT'];
73
-				$lbl_description = $mod_strings['LBL_NOTE'];
74
-				$default_parent_type= $app_list_strings['record_type_default_key'];
71
+                $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
72
+                $lbl_subject = $mod_strings['LBL_NOTE_SUBJECT'];
73
+                $lbl_description = $mod_strings['LBL_NOTE'];
74
+                $default_parent_type= $app_list_strings['record_type_default_key'];
75 75
 
76 76
 $form = <<<EOF
77 77
 				<input type="hidden" name="${prefix}record" value="">
@@ -93,325 +93,325 @@  discard block
 block discarded – undo
93 93
 				</table></p>
94 94
 EOF;
95 95
 
96
-	$javascript = new javascript();
97
-	$javascript->setFormName($formname);
98
-	$javascript->setSugarBean(new EmailTemplate());
99
-	$javascript->addRequiredFields($prefix);
100
-	$form .=$javascript->getScript();
101
-	$mod_strings = $temp_strings;
102
-	return $form;
103
-	}
104
-
105
-	function getForm($prefix, $mod='') {
106
-		if(!empty($mod)) {
107
-		global $current_language;
108
-		$mod_strings = return_module_language($current_language, $mod);
109
-	}else global $mod_strings;
110
-		global $app_strings;
111
-		global $app_list_strings;
112
-
113
-		$lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
114
-		$lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
115
-		$lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
116
-
117
-
118
-		$the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
96
+    $javascript = new javascript();
97
+    $javascript->setFormName($formname);
98
+    $javascript->setSugarBean(new EmailTemplate());
99
+    $javascript->addRequiredFields($prefix);
100
+    $form .=$javascript->getScript();
101
+    $mod_strings = $temp_strings;
102
+    return $form;
103
+    }
104
+
105
+    function getForm($prefix, $mod='') {
106
+        if(!empty($mod)) {
107
+        global $current_language;
108
+        $mod_strings = return_module_language($current_language, $mod);
109
+    }else global $mod_strings;
110
+        global $app_strings;
111
+        global $app_list_strings;
112
+
113
+        $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
114
+        $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
115
+        $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
116
+
117
+
118
+        $the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
119 119
 $the_form .= <<<EOQ
120 120
 
121 121
 				<form name="${prefix}EmailTemplateSave" onSubmit="return check_form('${prefix}EmailTemplateSave')" method="POST" action="index.php">
122 122
 					<input type="hidden" name="${prefix}module" value="EmailTemplates">
123 123
 					<input type="hidden" name="${prefix}action" value="Save">
124 124
 EOQ;
125
-		$the_form .= $this->getFormBody($prefix, $mod, "${prefix}EmailTemplateSave", "20");
125
+        $the_form .= $this->getFormBody($prefix, $mod, "${prefix}EmailTemplateSave", "20");
126 126
 $the_form .= <<<EOQ
127 127
 				<p><input title="$lbl_save_button_title" accessKey="$lbl_save_button_key" class="button" type="submit" name="button" value="  $lbl_save_button_label  " ></p>
128 128
 				</form>
129 129
 
130 130
 EOQ;
131 131
 
132
-		$the_form .= get_left_form_footer();
133
-		$the_form .= get_validate_record_js();
134
-
135
-
136
-		return $the_form;
137
-	}
138
-
139
-
140
-	function handleSave($prefix,$redirect=true, $useRequired=false, $useSiteURL = false, $entryPoint = 'download', $useUploadFolder = false)
141
-	{
142
-		require_once('include/formbase.php');
143
-		require_once('include/upload_file.php');
144
-		global $upload_maxsize;
145
-		global $mod_strings;
146
-		global $sugar_config;
147
-
148
-		$focus = new EmailTemplate();
149
-		if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
150
-			return null;
151
-		}
152
-		$focus = populateFromPost($prefix, $focus);
153
-		//process the text only flag
154
-		if (isset($_POST['text_only']) && ($_POST['text_only'] == '1')) {
155
-			$focus->text_only = 1;
156
-		} else {
157
-			$focus->text_only = 0;
158
-		}
159
-		if (!$focus->ACLAccess('Save')) {
160
-			ACLController::displayNoAccess(true);
161
-			sugar_cleanup(true);
162
-		}
163
-		if (!isset($_REQUEST['published'])) $focus->published = 'off';
164
-
165
-		$this->handleAttachmentsProcessImages($focus, $redirect, $useSiteURL, $entryPoint, $useUploadFolder);
166
-		return $focus;
167
-	}
168
-
169
-	public function handleAttachmentsProcessImages($focus, $redirect, $useSiteURL = false, $entryPoint = 'download', $useUploadFolder = false) {
170
-		$return_id = $this->processImages($focus, $useSiteURL, $entryPoint, $useUploadFolder);
171
-		return $this->handleAttachments($focus, $redirect, $return_id);
172
-	}
173
-
174
-	public function processImages(&$focus, $useSiteURL, $entryPoint, $useUploadFolder) {
175
-		global $sugar_config;
176
-		$preProcessedImages = array();
177
-		$emailTemplateBodyHtml = from_html($focus->body_html);
178
-		if (strpos($emailTemplateBodyHtml, '"cache/images/')) {
179
-			$matches = array();
180
-			preg_match_all('#<img[^>]*[\s]+src[^=]*=[\s]*["\']cache/images/(.+?)["\']#si', $emailTemplateBodyHtml, $matches);
181
-			foreach ($matches[1] as $match) {
182
-				$filename = urldecode($match);
183
-				if ($filename != pathinfo($filename, PATHINFO_BASENAME)) {
184
-					// don't allow paths there
185
-					$emailTemplateBodyHtml = str_replace("cache/images/$match", "", $emailTemplateBodyHtml);
186
-					continue;
187
-				}
188
-				$file_location = sugar_cached("images/{$filename}");
189
-				$mime_type = pathinfo($filename, PATHINFO_EXTENSION);
190
-
191
-				if (file_exists($file_location)) {
192
-					//$id = create_guid();
193
-
194
-					$note = new Note();
195
-					$note->save();
196
-					$id = $note->id;
197
-
198
-					$newFileLocation = "upload://$id";
199
-					if (!copy($file_location, $newFileLocation)) {
200
-						$GLOBALS['log']->debug("EMAIL Template could not copy attachment to $newFileLocation");
201
-					} else {
202
-						if($useUploadFolder) {
203
-							$secureLink = ($useSiteURL ? $sugar_config['site_url'] . '/' : '') . "public/{$id}";
204
-							// create a copy with correct extension by mime type
205
-							if(!file_exists('public')) {
206
-								sugar_mkdir('public', 777);
207
-							}
208
-							if(copy($file_location, "public/{$id}.{$mime_type}")) {
209
-								$secureLink .= ".{$mime_type}";
210
-							}
211
-						}
212
-						else {
213
-							$secureLink = ($useSiteURL ? $sugar_config['site_url'] . '/' : '') . "index.php?entryPoint=" . $entryPoint . "&type=Notes&id={$id}&filename=" . $match;
214
-						}
215
-
216
-						$emailTemplateBodyHtml = str_replace("cache/images/$match", $secureLink, $emailTemplateBodyHtml);
217
-						//unlink($file_location);
218
-						$preProcessedImages[$filename] = $id;
219
-					}
220
-				} // if
221
-			} // foreach
222
-		} // if
223
-		if (isset($GLOBALS['check_notify'])) {
224
-			$check_notify = $GLOBALS['check_notify'];
225
-		} else {
226
-			$check_notify = FALSE;
227
-		}
228
-		if($preProcessedImages) {
229
-			$focus->body_html = $emailTemplateBodyHtml;
230
-		}
231
-		$return_id = $focus->save($check_notify);
232
-		return $return_id;
233
-	}
234
-
235
-	public function handleAttachments($focus, $redirect, $return_id) {
236
-		///////////////////////////////////////////////////////////////////////////////
237
-		////	ATTACHMENT HANDLING
238
-
239
-		///////////////////////////////////////////////////////////////////////////
240
-		////	ADDING NEW ATTACHMENTS
241
-
242
-		global $mod_strings;
243
-
244
-		$max_files_upload = count($_FILES);
245
-
246
-		if(!empty($focus->id)) {
247
-			$note = new Note();
248
-			$where = "notes.parent_id='{$focus->id}'";
249
-			if(!empty($_REQUEST['old_id'])) { // to support duplication of email templates
250
-				$where .= " OR notes.parent_id='".htmlspecialchars($_REQUEST['old_id'], ENT_QUOTES)."'";
251
-			}
252
-			$notes_list = $note->get_full_list("", $where, true);
253
-		}
254
-
255
-		if(!isset($notes_list)) {
256
-			$notes_list = array();
257
-		}
258
-
259
-		if(!is_array($focus->attachments)) { // PHP5 does not auto-create arrays(). Need to initialize it here.
260
-			$focus->attachments = array();
261
-		}
262
-		$focus->attachments = array_merge($focus->attachments, $notes_list);
263
-
264
-
265
-
266
-		//for($i = 0; $i < $max_files_upload; $i++) {
267
-
268
-		foreach ($_FILES as $key => $file)
269
-		{
270
-			$note = new Note();
271
-
272
-			//Images are presaved above so we need to prevent duplicate files from being created.
273
-			if( isset($preProcessedImages[$file['name']]) )
274
-			{
275
-			    $oldId = $preProcessedImages[$file['name']];
276
-			    $note->id = $oldId;
277
-			    $note->new_with_id = TRUE;
278
-			    $GLOBALS['log']->debug("Image {$file['name']} has already been processed.");
132
+        $the_form .= get_left_form_footer();
133
+        $the_form .= get_validate_record_js();
134
+
135
+
136
+        return $the_form;
137
+    }
138
+
139
+
140
+    function handleSave($prefix,$redirect=true, $useRequired=false, $useSiteURL = false, $entryPoint = 'download', $useUploadFolder = false)
141
+    {
142
+        require_once('include/formbase.php');
143
+        require_once('include/upload_file.php');
144
+        global $upload_maxsize;
145
+        global $mod_strings;
146
+        global $sugar_config;
147
+
148
+        $focus = new EmailTemplate();
149
+        if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
150
+            return null;
151
+        }
152
+        $focus = populateFromPost($prefix, $focus);
153
+        //process the text only flag
154
+        if (isset($_POST['text_only']) && ($_POST['text_only'] == '1')) {
155
+            $focus->text_only = 1;
156
+        } else {
157
+            $focus->text_only = 0;
158
+        }
159
+        if (!$focus->ACLAccess('Save')) {
160
+            ACLController::displayNoAccess(true);
161
+            sugar_cleanup(true);
162
+        }
163
+        if (!isset($_REQUEST['published'])) $focus->published = 'off';
164
+
165
+        $this->handleAttachmentsProcessImages($focus, $redirect, $useSiteURL, $entryPoint, $useUploadFolder);
166
+        return $focus;
167
+    }
168
+
169
+    public function handleAttachmentsProcessImages($focus, $redirect, $useSiteURL = false, $entryPoint = 'download', $useUploadFolder = false) {
170
+        $return_id = $this->processImages($focus, $useSiteURL, $entryPoint, $useUploadFolder);
171
+        return $this->handleAttachments($focus, $redirect, $return_id);
172
+    }
173
+
174
+    public function processImages(&$focus, $useSiteURL, $entryPoint, $useUploadFolder) {
175
+        global $sugar_config;
176
+        $preProcessedImages = array();
177
+        $emailTemplateBodyHtml = from_html($focus->body_html);
178
+        if (strpos($emailTemplateBodyHtml, '"cache/images/')) {
179
+            $matches = array();
180
+            preg_match_all('#<img[^>]*[\s]+src[^=]*=[\s]*["\']cache/images/(.+?)["\']#si', $emailTemplateBodyHtml, $matches);
181
+            foreach ($matches[1] as $match) {
182
+                $filename = urldecode($match);
183
+                if ($filename != pathinfo($filename, PATHINFO_BASENAME)) {
184
+                    // don't allow paths there
185
+                    $emailTemplateBodyHtml = str_replace("cache/images/$match", "", $emailTemplateBodyHtml);
186
+                    continue;
187
+                }
188
+                $file_location = sugar_cached("images/{$filename}");
189
+                $mime_type = pathinfo($filename, PATHINFO_EXTENSION);
190
+
191
+                if (file_exists($file_location)) {
192
+                    //$id = create_guid();
193
+
194
+                    $note = new Note();
195
+                    $note->save();
196
+                    $id = $note->id;
197
+
198
+                    $newFileLocation = "upload://$id";
199
+                    if (!copy($file_location, $newFileLocation)) {
200
+                        $GLOBALS['log']->debug("EMAIL Template could not copy attachment to $newFileLocation");
201
+                    } else {
202
+                        if($useUploadFolder) {
203
+                            $secureLink = ($useSiteURL ? $sugar_config['site_url'] . '/' : '') . "public/{$id}";
204
+                            // create a copy with correct extension by mime type
205
+                            if(!file_exists('public')) {
206
+                                sugar_mkdir('public', 777);
207
+                            }
208
+                            if(copy($file_location, "public/{$id}.{$mime_type}")) {
209
+                                $secureLink .= ".{$mime_type}";
210
+                            }
211
+                        }
212
+                        else {
213
+                            $secureLink = ($useSiteURL ? $sugar_config['site_url'] . '/' : '') . "index.php?entryPoint=" . $entryPoint . "&type=Notes&id={$id}&filename=" . $match;
214
+                        }
215
+
216
+                        $emailTemplateBodyHtml = str_replace("cache/images/$match", $secureLink, $emailTemplateBodyHtml);
217
+                        //unlink($file_location);
218
+                        $preProcessedImages[$filename] = $id;
219
+                    }
220
+                } // if
221
+            } // foreach
222
+        } // if
223
+        if (isset($GLOBALS['check_notify'])) {
224
+            $check_notify = $GLOBALS['check_notify'];
225
+        } else {
226
+            $check_notify = FALSE;
227
+        }
228
+        if($preProcessedImages) {
229
+            $focus->body_html = $emailTemplateBodyHtml;
230
+        }
231
+        $return_id = $focus->save($check_notify);
232
+        return $return_id;
233
+    }
234
+
235
+    public function handleAttachments($focus, $redirect, $return_id) {
236
+        ///////////////////////////////////////////////////////////////////////////////
237
+        ////	ATTACHMENT HANDLING
238
+
239
+        ///////////////////////////////////////////////////////////////////////////
240
+        ////	ADDING NEW ATTACHMENTS
241
+
242
+        global $mod_strings;
243
+
244
+        $max_files_upload = count($_FILES);
245
+
246
+        if(!empty($focus->id)) {
247
+            $note = new Note();
248
+            $where = "notes.parent_id='{$focus->id}'";
249
+            if(!empty($_REQUEST['old_id'])) { // to support duplication of email templates
250
+                $where .= " OR notes.parent_id='".htmlspecialchars($_REQUEST['old_id'], ENT_QUOTES)."'";
279 251
             }
252
+            $notes_list = $note->get_full_list("", $where, true);
253
+        }
254
+
255
+        if(!isset($notes_list)) {
256
+            $notes_list = array();
257
+        }
258
+
259
+        if(!is_array($focus->attachments)) { // PHP5 does not auto-create arrays(). Need to initialize it here.
260
+            $focus->attachments = array();
261
+        }
262
+        $focus->attachments = array_merge($focus->attachments, $notes_list);
263
+
264
+
265
+
266
+        //for($i = 0; $i < $max_files_upload; $i++) {
267
+
268
+        foreach ($_FILES as $key => $file)
269
+        {
270
+            $note = new Note();
280 271
 
281
-			$i=preg_replace("/email_attachment(.+)/",'$1',$key);
282
-			$upload_file = new UploadFile($key);
283
-
284
-			if(isset($_FILES[$key]) && $upload_file->confirm_upload() && preg_match("/^email_attachment/",$key)) {
285
-				$note->filename = $upload_file->get_stored_file_name();
286
-				$note->file = $upload_file;
287
-				$note->name = $mod_strings['LBL_EMAIL_ATTACHMENT'].': '.$note->file->original_file_name;
288
-				if(isset($_REQUEST['embedded'.$i]) && !empty($_REQUEST['embedded'.$i])){
289
-                  if($_REQUEST['embedded'.$i]=='true'){
290
-				  	$note->embed_flag =true;
291
-                  }
292
-                  else{
293
-                  	$note->embed_flag =false;
294
-                  }
295
-				}
296
-				array_push($focus->attachments, $note);
297
-			}
298
-
299
-		}
300
-
301
-		$focus->saved_attachments = array();
302
-		foreach($focus->attachments as $note)
303
-		{
304
-			if( !empty($note->id) && $note->new_with_id === FALSE)
305
-			{
306
-				if(empty($_REQUEST['old_id']))
307
-					array_push($focus->saved_attachments, $note); // to support duplication of email templates
308
-				else
309
-				{
310
-					// we're duplicating a template with attachments
311
-					// dupe the file, create a new note, assign the note to the new template
312
-					$newNote = new Note();
313
-					$newNote->retrieve($note->id);
314
-					$newNote->id = create_guid();
315
-					$newNote->parent_id = $focus->id;
316
-					$newNote->new_with_id = true;
317
-					$newNote->date_modified = '';
318
-					$newNote->date_entered = '';
319
-					/* BEGIN - SECURITY GROUPS */
320
-					//Need to do this so that attachments show under an EmailTemplate correctly for a normal user
321
-					global $current_user;
322
-					$newNote->assigned_user_id = $current_user->id;
323
-					/* END - SECURITY GROUPS */
324
-					$newNoteId = $newNote->save();
325
-
326
-					UploadFile::duplicate_file($note->id, $newNoteId, $note->filename);
327
-				}
328
-				continue;
329
-			}
330
-			$note->parent_id = $focus->id;
331
-			$note->parent_type = 'Emails';
332
-			$note->file_mime_type = $note->file->mime_type;
333
-			/* BEGIN - SECURITY GROUPS */
334
-			//Need to do this so that attachments show under an EmailTemplate correctly for a normal user
335
-			global $current_user;
336
-			$note->assigned_user_id = $current_user->id;
337
-			/* END - SECURITY GROUPS */
338
-			$note_id = $note->save();
339
-			array_push($focus->saved_attachments, $note);
340
-			$note->id = $note_id;
341
-
342
-			if($note->new_with_id === FALSE)
343
-    			$note->file->final_move($note->id);
344
-    	    else
345
-    	       $GLOBALS['log']->debug("Not performing final move for note id {$note->id} as it has already been processed");
346
-		}
347
-
348
-		////	END NEW ATTACHMENTS
349
-		///////////////////////////////////////////////////////////////////////////
350
-
351
-	///////////////////////////////////////////////////////////////////////////
352
-	////	ATTACHMENTS FROM DOCUMENTS
353
-	$count='';
354
-	//_pp($_REQUEST);
355
-	//_ppd(count($_REQUEST['document']));
356
-	if(!empty($_REQUEST['document'])){
357
-      $count = count($_REQUEST['document']);
272
+            //Images are presaved above so we need to prevent duplicate files from being created.
273
+            if( isset($preProcessedImages[$file['name']]) )
274
+            {
275
+                $oldId = $preProcessedImages[$file['name']];
276
+                $note->id = $oldId;
277
+                $note->new_with_id = TRUE;
278
+                $GLOBALS['log']->debug("Image {$file['name']} has already been processed.");
279
+            }
280
+
281
+            $i=preg_replace("/email_attachment(.+)/",'$1',$key);
282
+            $upload_file = new UploadFile($key);
283
+
284
+            if(isset($_FILES[$key]) && $upload_file->confirm_upload() && preg_match("/^email_attachment/",$key)) {
285
+                $note->filename = $upload_file->get_stored_file_name();
286
+                $note->file = $upload_file;
287
+                $note->name = $mod_strings['LBL_EMAIL_ATTACHMENT'].': '.$note->file->original_file_name;
288
+                if(isset($_REQUEST['embedded'.$i]) && !empty($_REQUEST['embedded'.$i])){
289
+                    if($_REQUEST['embedded'.$i]=='true'){
290
+                        $note->embed_flag =true;
291
+                    }
292
+                    else{
293
+                        $note->embed_flag =false;
294
+                    }
295
+                }
296
+                array_push($focus->attachments, $note);
297
+            }
298
+
299
+        }
300
+
301
+        $focus->saved_attachments = array();
302
+        foreach($focus->attachments as $note)
303
+        {
304
+            if( !empty($note->id) && $note->new_with_id === FALSE)
305
+            {
306
+                if(empty($_REQUEST['old_id']))
307
+                    array_push($focus->saved_attachments, $note); // to support duplication of email templates
308
+                else
309
+                {
310
+                    // we're duplicating a template with attachments
311
+                    // dupe the file, create a new note, assign the note to the new template
312
+                    $newNote = new Note();
313
+                    $newNote->retrieve($note->id);
314
+                    $newNote->id = create_guid();
315
+                    $newNote->parent_id = $focus->id;
316
+                    $newNote->new_with_id = true;
317
+                    $newNote->date_modified = '';
318
+                    $newNote->date_entered = '';
319
+                    /* BEGIN - SECURITY GROUPS */
320
+                    //Need to do this so that attachments show under an EmailTemplate correctly for a normal user
321
+                    global $current_user;
322
+                    $newNote->assigned_user_id = $current_user->id;
323
+                    /* END - SECURITY GROUPS */
324
+                    $newNoteId = $newNote->save();
325
+
326
+                    UploadFile::duplicate_file($note->id, $newNoteId, $note->filename);
327
+                }
328
+                continue;
329
+            }
330
+            $note->parent_id = $focus->id;
331
+            $note->parent_type = 'Emails';
332
+            $note->file_mime_type = $note->file->mime_type;
333
+            /* BEGIN - SECURITY GROUPS */
334
+            //Need to do this so that attachments show under an EmailTemplate correctly for a normal user
335
+            global $current_user;
336
+            $note->assigned_user_id = $current_user->id;
337
+            /* END - SECURITY GROUPS */
338
+            $note_id = $note->save();
339
+            array_push($focus->saved_attachments, $note);
340
+            $note->id = $note_id;
341
+
342
+            if($note->new_with_id === FALSE)
343
+                $note->file->final_move($note->id);
344
+            else
345
+                $GLOBALS['log']->debug("Not performing final move for note id {$note->id} as it has already been processed");
346
+        }
347
+
348
+        ////	END NEW ATTACHMENTS
349
+        ///////////////////////////////////////////////////////////////////////////
350
+
351
+    ///////////////////////////////////////////////////////////////////////////
352
+    ////	ATTACHMENTS FROM DOCUMENTS
353
+    $count='';
354
+    //_pp($_REQUEST);
355
+    //_ppd(count($_REQUEST['document']));
356
+    if(!empty($_REQUEST['document'])){
357
+        $count = count($_REQUEST['document']);
358 358
     }
359 359
     else{
360
-    	$count=10;
360
+        $count=10;
361 361
     }
362 362
 
363
-	for($i=0; $i<$count; $i++) {
364
-		if(isset($_REQUEST['documentId'.$i]) && !empty($_REQUEST['documentId'.$i])) {
365
-			$doc = new Document();
366
-			$docRev = new DocumentRevision();
367
-			$docNote = new Note();
363
+    for($i=0; $i<$count; $i++) {
364
+        if(isset($_REQUEST['documentId'.$i]) && !empty($_REQUEST['documentId'.$i])) {
365
+            $doc = new Document();
366
+            $docRev = new DocumentRevision();
367
+            $docNote = new Note();
368 368
 
369
-			$doc->retrieve($_REQUEST['documentId'.$i]);
370
-			$docRev->retrieve($doc->document_revision_id);
369
+            $doc->retrieve($_REQUEST['documentId'.$i]);
370
+            $docRev->retrieve($doc->document_revision_id);
371 371
 
372
-			array_push($focus->saved_attachments, $docRev);
372
+            array_push($focus->saved_attachments, $docRev);
373 373
 
374
-			$docNote->name = $doc->document_name;
375
-			$docNote->filename = $docRev->filename;
376
-			$docNote->description = $doc->description;
377
-			$docNote->parent_id = $focus->id;
378
-			$docNote->parent_type = 'Emails';
379
-			$docNote->file_mime_type = $docRev->file_mime_type;
380
-			$docId = $docNote = $docNote->save();
374
+            $docNote->name = $doc->document_name;
375
+            $docNote->filename = $docRev->filename;
376
+            $docNote->description = $doc->description;
377
+            $docNote->parent_id = $focus->id;
378
+            $docNote->parent_type = 'Emails';
379
+            $docNote->file_mime_type = $docRev->file_mime_type;
380
+            $docId = $docNote = $docNote->save();
381 381
 
382
-			UploadFile::duplicate_file($docRev->id, $docId, $docRev->filename);
383
-		}
382
+            UploadFile::duplicate_file($docRev->id, $docId, $docRev->filename);
383
+        }
384 384
 
385
-	}
385
+    }
386 386
 
387
-	////	END ATTACHMENTS FROM DOCUMENTS
388
-	///////////////////////////////////////////////////////////////////////////
387
+    ////	END ATTACHMENTS FROM DOCUMENTS
388
+    ///////////////////////////////////////////////////////////////////////////
389 389
 
390
-		///////////////////////////////////////////////////////////////////////////
391
-		////	REMOVE ATTACHMENTS
390
+        ///////////////////////////////////////////////////////////////////////////
391
+        ////	REMOVE ATTACHMENTS
392 392
 
393
-		if(isset($_REQUEST['remove_attachment']) && !empty($_REQUEST['remove_attachment'])) {
394
-			foreach($_REQUEST['remove_attachment'] as $noteId) {
395
-				$q = 'UPDATE notes SET deleted = 1 WHERE id = \''.$noteId.'\'';
396
-				$focus->db->query($q);
397
-			}
393
+        if(isset($_REQUEST['remove_attachment']) && !empty($_REQUEST['remove_attachment'])) {
394
+            foreach($_REQUEST['remove_attachment'] as $noteId) {
395
+                $q = 'UPDATE notes SET deleted = 1 WHERE id = \''.$noteId.'\'';
396
+                $focus->db->query($q);
397
+            }
398 398
 
399
-		}
399
+        }
400 400
 
401
-		////	END REMOVE ATTACHMENTS
402
-		///////////////////////////////////////////////////////////////////////////
403
-	////	END ATTACHMENT HANDLING
404
-	///////////////////////////////////////////////////////////////////////////////
401
+        ////	END REMOVE ATTACHMENTS
402
+        ///////////////////////////////////////////////////////////////////////////
403
+    ////	END ATTACHMENT HANDLING
404
+    ///////////////////////////////////////////////////////////////////////////////
405 405
 
406 406
         clear_register_value('select_array', $focus->object_name);
407 407
 
408
-		if($redirect) {
409
-		$GLOBALS['log']->debug("Saved record with id of ".$return_id);
410
-			handleRedirect($return_id, "EmailTemplates");
411
-		}else{
412
-			return $focus;
413
-		}
414
-	}
408
+        if($redirect) {
409
+        $GLOBALS['log']->debug("Saved record with id of ".$return_id);
410
+            handleRedirect($return_id, "EmailTemplates");
411
+        }else{
412
+            return $focus;
413
+        }
414
+    }
415 415
 
416 416
 }
417 417
 ?>
418 418
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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.
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 
55 55
     }
56 56
 
57
-	function getFormBody($prefix, $mod='',$formname='', $size='30') {
57
+	function getFormBody($prefix, $mod = '', $formname = '', $size = '30') {
58 58
 
59 59
 
60 60
 		global $mod_strings;
61 61
 
62 62
 		$temp_strings = $mod_strings;
63 63
 
64
-		if(!empty($mod)) {
64
+		if (!empty($mod)) {
65 65
 			global $current_language;
66 66
 			$mod_strings = return_module_language($current_language, $mod);
67 67
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 				$lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
72 72
 				$lbl_subject = $mod_strings['LBL_NOTE_SUBJECT'];
73 73
 				$lbl_description = $mod_strings['LBL_NOTE'];
74
-				$default_parent_type= $app_list_strings['record_type_default_key'];
74
+				$default_parent_type = $app_list_strings['record_type_default_key'];
75 75
 
76 76
 $form = <<<EOF
77 77
 				<input type="hidden" name="${prefix}record" value="">
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
 	$javascript->setFormName($formname);
98 98
 	$javascript->setSugarBean(new EmailTemplate());
99 99
 	$javascript->addRequiredFields($prefix);
100
-	$form .=$javascript->getScript();
100
+	$form .= $javascript->getScript();
101 101
 	$mod_strings = $temp_strings;
102 102
 	return $form;
103 103
 	}
104 104
 
105
-	function getForm($prefix, $mod='') {
106
-		if(!empty($mod)) {
105
+	function getForm($prefix, $mod = '') {
106
+		if (!empty($mod)) {
107 107
 		global $current_language;
108 108
 		$mod_strings = return_module_language($current_language, $mod);
109
-	}else global $mod_strings;
109
+	} else global $mod_strings;
110 110
 		global $app_strings;
111 111
 		global $app_list_strings;
112 112
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	}
138 138
 
139 139
 
140
-	function handleSave($prefix,$redirect=true, $useRequired=false, $useSiteURL = false, $entryPoint = 'download', $useUploadFolder = false)
140
+	function handleSave($prefix, $redirect = true, $useRequired = false, $useSiteURL = false, $entryPoint = 'download', $useUploadFolder = false)
141 141
 	{
142 142
 		require_once('include/formbase.php');
143 143
 		require_once('include/upload_file.php');
@@ -199,18 +199,18 @@  discard block
 block discarded – undo
199 199
 					if (!copy($file_location, $newFileLocation)) {
200 200
 						$GLOBALS['log']->debug("EMAIL Template could not copy attachment to $newFileLocation");
201 201
 					} else {
202
-						if($useUploadFolder) {
203
-							$secureLink = ($useSiteURL ? $sugar_config['site_url'] . '/' : '') . "public/{$id}";
202
+						if ($useUploadFolder) {
203
+							$secureLink = ($useSiteURL ? $sugar_config['site_url'].'/' : '')."public/{$id}";
204 204
 							// create a copy with correct extension by mime type
205
-							if(!file_exists('public')) {
205
+							if (!file_exists('public')) {
206 206
 								sugar_mkdir('public', 777);
207 207
 							}
208
-							if(copy($file_location, "public/{$id}.{$mime_type}")) {
208
+							if (copy($file_location, "public/{$id}.{$mime_type}")) {
209 209
 								$secureLink .= ".{$mime_type}";
210 210
 							}
211 211
 						}
212 212
 						else {
213
-							$secureLink = ($useSiteURL ? $sugar_config['site_url'] . '/' : '') . "index.php?entryPoint=" . $entryPoint . "&type=Notes&id={$id}&filename=" . $match;
213
+							$secureLink = ($useSiteURL ? $sugar_config['site_url'].'/' : '')."index.php?entryPoint=".$entryPoint."&type=Notes&id={$id}&filename=".$match;
214 214
 						}
215 215
 
216 216
 						$emailTemplateBodyHtml = str_replace("cache/images/$match", $secureLink, $emailTemplateBodyHtml);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		} else {
226 226
 			$check_notify = FALSE;
227 227
 		}
228
-		if($preProcessedImages) {
228
+		if ($preProcessedImages) {
229 229
 			$focus->body_html = $emailTemplateBodyHtml;
230 230
 		}
231 231
 		$return_id = $focus->save($check_notify);
@@ -243,20 +243,20 @@  discard block
 block discarded – undo
243 243
 
244 244
 		$max_files_upload = count($_FILES);
245 245
 
246
-		if(!empty($focus->id)) {
246
+		if (!empty($focus->id)) {
247 247
 			$note = new Note();
248 248
 			$where = "notes.parent_id='{$focus->id}'";
249
-			if(!empty($_REQUEST['old_id'])) { // to support duplication of email templates
249
+			if (!empty($_REQUEST['old_id'])) { // to support duplication of email templates
250 250
 				$where .= " OR notes.parent_id='".htmlspecialchars($_REQUEST['old_id'], ENT_QUOTES)."'";
251 251
 			}
252 252
 			$notes_list = $note->get_full_list("", $where, true);
253 253
 		}
254 254
 
255
-		if(!isset($notes_list)) {
255
+		if (!isset($notes_list)) {
256 256
 			$notes_list = array();
257 257
 		}
258 258
 
259
-		if(!is_array($focus->attachments)) { // PHP5 does not auto-create arrays(). Need to initialize it here.
259
+		if (!is_array($focus->attachments)) { // PHP5 does not auto-create arrays(). Need to initialize it here.
260 260
 			$focus->attachments = array();
261 261
 		}
262 262
 		$focus->attachments = array_merge($focus->attachments, $notes_list);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			$note = new Note();
271 271
 
272 272
 			//Images are presaved above so we need to prevent duplicate files from being created.
273
-			if( isset($preProcessedImages[$file['name']]) )
273
+			if (isset($preProcessedImages[$file['name']]))
274 274
 			{
275 275
 			    $oldId = $preProcessedImages[$file['name']];
276 276
 			    $note->id = $oldId;
@@ -278,19 +278,19 @@  discard block
 block discarded – undo
278 278
 			    $GLOBALS['log']->debug("Image {$file['name']} has already been processed.");
279 279
             }
280 280
 
281
-			$i=preg_replace("/email_attachment(.+)/",'$1',$key);
281
+			$i = preg_replace("/email_attachment(.+)/", '$1', $key);
282 282
 			$upload_file = new UploadFile($key);
283 283
 
284
-			if(isset($_FILES[$key]) && $upload_file->confirm_upload() && preg_match("/^email_attachment/",$key)) {
284
+			if (isset($_FILES[$key]) && $upload_file->confirm_upload() && preg_match("/^email_attachment/", $key)) {
285 285
 				$note->filename = $upload_file->get_stored_file_name();
286 286
 				$note->file = $upload_file;
287 287
 				$note->name = $mod_strings['LBL_EMAIL_ATTACHMENT'].': '.$note->file->original_file_name;
288
-				if(isset($_REQUEST['embedded'.$i]) && !empty($_REQUEST['embedded'.$i])){
289
-                  if($_REQUEST['embedded'.$i]=='true'){
290
-				  	$note->embed_flag =true;
288
+				if (isset($_REQUEST['embedded'.$i]) && !empty($_REQUEST['embedded'.$i])) {
289
+                  if ($_REQUEST['embedded'.$i] == 'true') {
290
+				  	$note->embed_flag = true;
291 291
                   }
292
-                  else{
293
-                  	$note->embed_flag =false;
292
+                  else {
293
+                  	$note->embed_flag = false;
294 294
                   }
295 295
 				}
296 296
 				array_push($focus->attachments, $note);
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 		}
300 300
 
301 301
 		$focus->saved_attachments = array();
302
-		foreach($focus->attachments as $note)
302
+		foreach ($focus->attachments as $note)
303 303
 		{
304
-			if( !empty($note->id) && $note->new_with_id === FALSE)
304
+			if (!empty($note->id) && $note->new_with_id === FALSE)
305 305
 			{
306
-				if(empty($_REQUEST['old_id']))
306
+				if (empty($_REQUEST['old_id']))
307 307
 					array_push($focus->saved_attachments, $note); // to support duplication of email templates
308 308
 				else
309 309
 				{
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 			array_push($focus->saved_attachments, $note);
340 340
 			$note->id = $note_id;
341 341
 
342
-			if($note->new_with_id === FALSE)
342
+			if ($note->new_with_id === FALSE)
343 343
     			$note->file->final_move($note->id);
344 344
     	    else
345 345
     	       $GLOBALS['log']->debug("Not performing final move for note id {$note->id} as it has already been processed");
@@ -350,18 +350,18 @@  discard block
 block discarded – undo
350 350
 
351 351
 	///////////////////////////////////////////////////////////////////////////
352 352
 	////	ATTACHMENTS FROM DOCUMENTS
353
-	$count='';
353
+	$count = '';
354 354
 	//_pp($_REQUEST);
355 355
 	//_ppd(count($_REQUEST['document']));
356
-	if(!empty($_REQUEST['document'])){
356
+	if (!empty($_REQUEST['document'])) {
357 357
       $count = count($_REQUEST['document']);
358 358
     }
359
-    else{
360
-    	$count=10;
359
+    else {
360
+    	$count = 10;
361 361
     }
362 362
 
363
-	for($i=0; $i<$count; $i++) {
364
-		if(isset($_REQUEST['documentId'.$i]) && !empty($_REQUEST['documentId'.$i])) {
363
+	for ($i = 0; $i < $count; $i++) {
364
+		if (isset($_REQUEST['documentId'.$i]) && !empty($_REQUEST['documentId'.$i])) {
365 365
 			$doc = new Document();
366 366
 			$docRev = new DocumentRevision();
367 367
 			$docNote = new Note();
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 		///////////////////////////////////////////////////////////////////////////
391 391
 		////	REMOVE ATTACHMENTS
392 392
 
393
-		if(isset($_REQUEST['remove_attachment']) && !empty($_REQUEST['remove_attachment'])) {
394
-			foreach($_REQUEST['remove_attachment'] as $noteId) {
393
+		if (isset($_REQUEST['remove_attachment']) && !empty($_REQUEST['remove_attachment'])) {
394
+			foreach ($_REQUEST['remove_attachment'] as $noteId) {
395 395
 				$q = 'UPDATE notes SET deleted = 1 WHERE id = \''.$noteId.'\'';
396 396
 				$focus->db->query($q);
397 397
 			}
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 
406 406
         clear_register_value('select_array', $focus->object_name);
407 407
 
408
-		if($redirect) {
408
+		if ($redirect) {
409 409
 		$GLOBALS['log']->debug("Saved record with id of ".$return_id);
410 410
 			handleRedirect($return_id, "EmailTemplates");
411
-		}else{
411
+		} else {
412 412
 			return $focus;
413 413
 		}
414 414
 	}
Please login to merge, or discard this patch.
modules/Contacts/metadata/SearchFields.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -40,47 +40,47 @@
 block discarded – undo
40 40
 global $current_user;
41 41
 $module_name = "Contacts";
42 42
 $searchFields['Contacts'] = 
43
-	array (
44
-		'first_name' => array( 'query_type'=>'default'),
45
-		'last_name'=> array('query_type'=>'default'),
46
-		'search_name'=> array('query_type'=>'default','db_field'=>array('first_name','last_name'),'force_unifiedsearch'=>true),
47
-		'account_name'=> array('query_type'=>'default','db_field'=>array('accounts.name')),
48
-		'lead_source'=> array('query_type'=>'default','operator'=>'=', 'options' => 'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
49
-		'do_not_call'=> array('query_type'=>'default', 'input_type' => 'checkbox', 'operator'=>'='),
50
-		'phone'=> array('query_type'=>'default','db_field'=>array('phone_mobile','phone_work','phone_other','phone_fax','assistant_phone')),
51
-		'email'=> array(
52
-			'query_type' => 'default',
53
-			'operator' => 'subquery',
54
-			'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE',
55
-			'db_field' => array(
56
-				'id',
57
-			),
58
-		),	
43
+    array (
44
+        'first_name' => array( 'query_type'=>'default'),
45
+        'last_name'=> array('query_type'=>'default'),
46
+        'search_name'=> array('query_type'=>'default','db_field'=>array('first_name','last_name'),'force_unifiedsearch'=>true),
47
+        'account_name'=> array('query_type'=>'default','db_field'=>array('accounts.name')),
48
+        'lead_source'=> array('query_type'=>'default','operator'=>'=', 'options' => 'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
49
+        'do_not_call'=> array('query_type'=>'default', 'input_type' => 'checkbox', 'operator'=>'='),
50
+        'phone'=> array('query_type'=>'default','db_field'=>array('phone_mobile','phone_work','phone_other','phone_fax','assistant_phone')),
51
+        'email'=> array(
52
+            'query_type' => 'default',
53
+            'operator' => 'subquery',
54
+            'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE',
55
+            'db_field' => array(
56
+                'id',
57
+            ),
58
+        ),	
59 59
         'favorites_only' => array(
60 60
             'query_type'=>'format',
61 61
             'operator' => 'subquery',
62
-			'subquery' => "SELECT favorites.parent_id FROM favorites
62
+            'subquery' => "SELECT favorites.parent_id FROM favorites
63 63
 			                    WHERE favorites.deleted = 0
64 64
 			                        and favorites.parent_type = '".$module_name."'
65 65
 			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
66 66
             'db_field'=>array('id')),
67
-		'assistant'=> array('query_type'=>'default'),
68
-		'address_street'=> array('query_type'=>'default','db_field'=>array('primary_address_street','alt_address_street')),
69
-		'address_city'=> array('query_type'=>'default','db_field'=>array('primary_address_city','alt_address_city')),
70
-		'address_state'=> array('query_type'=>'default','db_field'=>array('primary_address_state','alt_address_state')),
71
-		'address_postalcode'=> array('query_type'=>'default','db_field'=>array('primary_address_postalcode','alt_address_postalcode')),
72
-		'address_country'=> array('query_type'=>'default','db_field'=>array('primary_address_country','alt_address_country')),
73
-		'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
74
-		'assigned_user_id'=> array('query_type'=>'default'),
67
+        'assistant'=> array('query_type'=>'default'),
68
+        'address_street'=> array('query_type'=>'default','db_field'=>array('primary_address_street','alt_address_street')),
69
+        'address_city'=> array('query_type'=>'default','db_field'=>array('primary_address_city','alt_address_city')),
70
+        'address_state'=> array('query_type'=>'default','db_field'=>array('primary_address_state','alt_address_state')),
71
+        'address_postalcode'=> array('query_type'=>'default','db_field'=>array('primary_address_postalcode','alt_address_postalcode')),
72
+        'address_country'=> array('query_type'=>'default','db_field'=>array('primary_address_country','alt_address_country')),
73
+        'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
74
+        'assigned_user_id'=> array('query_type'=>'default'),
75 75
         'account_id'=> array('query_type'=>'default','db_field'=>array('accounts.id')),
76 76
         'campaign_name'=> array('query_type'=>'default'),
77
-		//Range Search Support 
78
-	    'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
-	    'start_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
80
-	    'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
81
-	    'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
82
-	    'start_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
77
+        //Range Search Support 
78
+        'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
+        'start_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
80
+        'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
81
+        'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
82
+        'start_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
83 83
         'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
84
-	    //Range Search Support 			
85
-	);
84
+        //Range Search Support 			
85
+    );
86 86
 ?>
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 global $current_user;
41 41
 $module_name = "Contacts";
42 42
 $searchFields['Contacts'] = 
43
-	array (
44
-		'first_name' => array( 'query_type'=>'default'),
43
+	array(
44
+		'first_name' => array('query_type'=>'default'),
45 45
 		'last_name'=> array('query_type'=>'default'),
46
-		'search_name'=> array('query_type'=>'default','db_field'=>array('first_name','last_name'),'force_unifiedsearch'=>true),
47
-		'account_name'=> array('query_type'=>'default','db_field'=>array('accounts.name')),
48
-		'lead_source'=> array('query_type'=>'default','operator'=>'=', 'options' => 'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
46
+		'search_name'=> array('query_type'=>'default', 'db_field'=>array('first_name', 'last_name'), 'force_unifiedsearch'=>true),
47
+		'account_name'=> array('query_type'=>'default', 'db_field'=>array('accounts.name')),
48
+		'lead_source'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
49 49
 		'do_not_call'=> array('query_type'=>'default', 'input_type' => 'checkbox', 'operator'=>'='),
50
-		'phone'=> array('query_type'=>'default','db_field'=>array('phone_mobile','phone_work','phone_other','phone_fax','assistant_phone')),
50
+		'phone'=> array('query_type'=>'default', 'db_field'=>array('phone_mobile', 'phone_work', 'phone_other', 'phone_fax', 'assistant_phone')),
51 51
 		'email'=> array(
52 52
 			'query_type' => 'default',
53 53
 			'operator' => 'subquery',
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
 			'subquery' => "SELECT favorites.parent_id FROM favorites
63 63
 			                    WHERE favorites.deleted = 0
64 64
 			                        and favorites.parent_type = '".$module_name."'
65
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
65
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
66 66
             'db_field'=>array('id')),
67 67
 		'assistant'=> array('query_type'=>'default'),
68
-		'address_street'=> array('query_type'=>'default','db_field'=>array('primary_address_street','alt_address_street')),
69
-		'address_city'=> array('query_type'=>'default','db_field'=>array('primary_address_city','alt_address_city')),
70
-		'address_state'=> array('query_type'=>'default','db_field'=>array('primary_address_state','alt_address_state')),
71
-		'address_postalcode'=> array('query_type'=>'default','db_field'=>array('primary_address_postalcode','alt_address_postalcode')),
72
-		'address_country'=> array('query_type'=>'default','db_field'=>array('primary_address_country','alt_address_country')),
73
-		'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
68
+		'address_street'=> array('query_type'=>'default', 'db_field'=>array('primary_address_street', 'alt_address_street')),
69
+		'address_city'=> array('query_type'=>'default', 'db_field'=>array('primary_address_city', 'alt_address_city')),
70
+		'address_state'=> array('query_type'=>'default', 'db_field'=>array('primary_address_state', 'alt_address_state')),
71
+		'address_postalcode'=> array('query_type'=>'default', 'db_field'=>array('primary_address_postalcode', 'alt_address_postalcode')),
72
+		'address_country'=> array('query_type'=>'default', 'db_field'=>array('primary_address_country', 'alt_address_country')),
73
+		'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'), 'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
74 74
 		'assigned_user_id'=> array('query_type'=>'default'),
75
-        'account_id'=> array('query_type'=>'default','db_field'=>array('accounts.id')),
75
+        'account_id'=> array('query_type'=>'default', 'db_field'=>array('accounts.id')),
76 76
         'campaign_name'=> array('query_type'=>'default'),
77 77
 		//Range Search Support 
78
-	    'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
-	    'start_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
80
-	    'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
81
-	    'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
82
-	    'start_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
83
-        'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
78
+	    'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
+	    'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
80
+	    'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
81
+	    'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
82
+	    'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
83
+        'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
84 84
 	    //Range Search Support 			
85 85
 	);
86 86
 ?>
Please login to merge, or discard this patch.
modules/Opportunities/metadata/SearchFields.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -40,48 +40,48 @@
 block discarded – undo
40 40
 global $current_user;
41 41
 $module_name = "Opportunities";
42 42
 $searchFields['Opportunities'] = 
43
-	array (
44
-		'name' => array( 'query_type'=>'default'),
45
-		'account_name'=> array('query_type'=>'default','db_field'=>array('accounts.name')),
46
-		'amount'=> array('query_type'=>'default'),
47
-		'next_step'=> array('query_type'=>'default'),
48
-		'probability'=> array('query_type'=>'default'),
49
-		'lead_source'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
50
-		'opportunity_type'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'opportunity_type_dom', 'template_var' => 'TYPE_OPTIONS'),
51
-		'sales_stage'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'sales_stage_dom', 'template_var' => 'SALES_STAGE_OPTIONS', 'options_add_blank' => true),
52
-		'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
53
-		'assigned_user_id'=> array('query_type'=>'default'),
54
-		'open_only' => array(
55
-			'query_type'=>'default',
56
-			'db_field'=>array('sales_stage'),
57
-			'operator'=>'not in',
58
-			'closed_values' => array('Closed Won', 'Closed Lost'),
59
-			'type'=>'bool',
60
-		),
43
+    array (
44
+        'name' => array( 'query_type'=>'default'),
45
+        'account_name'=> array('query_type'=>'default','db_field'=>array('accounts.name')),
46
+        'amount'=> array('query_type'=>'default'),
47
+        'next_step'=> array('query_type'=>'default'),
48
+        'probability'=> array('query_type'=>'default'),
49
+        'lead_source'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
50
+        'opportunity_type'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'opportunity_type_dom', 'template_var' => 'TYPE_OPTIONS'),
51
+        'sales_stage'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'sales_stage_dom', 'template_var' => 'SALES_STAGE_OPTIONS', 'options_add_blank' => true),
52
+        'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
53
+        'assigned_user_id'=> array('query_type'=>'default'),
54
+        'open_only' => array(
55
+            'query_type'=>'default',
56
+            'db_field'=>array('sales_stage'),
57
+            'operator'=>'not in',
58
+            'closed_values' => array('Closed Won', 'Closed Lost'),
59
+            'type'=>'bool',
60
+        ),
61 61
         'favorites_only' => array(
62 62
             'query_type'=>'format',
63 63
             'operator' => 'subquery',
64
-			'subquery' => "SELECT favorites.parent_id FROM favorites
64
+            'subquery' => "SELECT favorites.parent_id FROM favorites
65 65
 			                    WHERE favorites.deleted = 0
66 66
 			                        and favorites.parent_type = '".$module_name."'
67 67
 			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
68 68
             'db_field'=>array('id')),
69 69
 
70
-		//Range Search Support 
71
-	   'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
72
-	   'start_range_date_entered' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
73
-	   'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
74
-	   'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
75
-	   'start_range_date_modified' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
76
-       'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
70
+        //Range Search Support 
71
+        'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
72
+        'start_range_date_entered' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
73
+        'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
74
+        'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
75
+        'start_range_date_modified' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
76
+        'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
77 77
 	   
78
-       'range_date_closed' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
-	   'start_range_date_closed' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
80
-       'end_range_date_closed' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
78
+        'range_date_closed' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
+        'start_range_date_closed' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
80
+        'end_range_date_closed' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
81 81
 
82
-       'range_amount' => array ('query_type' => 'default', 'enable_range_search' => true),
83
-	   'start_range_amount' => array ('query_type' => 'default',  'enable_range_search' => true),
84
-       'end_range_amount' => array ('query_type' => 'default', 'enable_range_search' => true),
85
-		//Range Search Support 			
86
-	);
82
+        'range_amount' => array ('query_type' => 'default', 'enable_range_search' => true),
83
+        'start_range_amount' => array ('query_type' => 'default',  'enable_range_search' => true),
84
+        'end_range_amount' => array ('query_type' => 'default', 'enable_range_search' => true),
85
+        //Range Search Support 			
86
+    );
87 87
 ?>
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 global $current_user;
41 41
 $module_name = "Opportunities";
42 42
 $searchFields['Opportunities'] = 
43
-	array (
44
-		'name' => array( 'query_type'=>'default'),
45
-		'account_name'=> array('query_type'=>'default','db_field'=>array('accounts.name')),
43
+	array(
44
+		'name' => array('query_type'=>'default'),
45
+		'account_name'=> array('query_type'=>'default', 'db_field'=>array('accounts.name')),
46 46
 		'amount'=> array('query_type'=>'default'),
47 47
 		'next_step'=> array('query_type'=>'default'),
48 48
 		'probability'=> array('query_type'=>'default'),
49 49
 		'lead_source'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
50 50
 		'opportunity_type'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'opportunity_type_dom', 'template_var' => 'TYPE_OPTIONS'),
51 51
 		'sales_stage'=> array('query_type'=>'default', 'operator'=>'=', 'options' => 'sales_stage_dom', 'template_var' => 'SALES_STAGE_OPTIONS', 'options_add_blank' => true),
52
-		'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
52
+		'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'), 'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
53 53
 		'assigned_user_id'=> array('query_type'=>'default'),
54 54
 		'open_only' => array(
55 55
 			'query_type'=>'default',
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 			'subquery' => "SELECT favorites.parent_id FROM favorites
65 65
 			                    WHERE favorites.deleted = 0
66 66
 			                        and favorites.parent_type = '".$module_name."'
67
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
67
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
68 68
             'db_field'=>array('id')),
69 69
 
70 70
 		//Range Search Support 
71
-	   'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
72
-	   'start_range_date_entered' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
73
-	   'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
74
-	   'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
75
-	   'start_range_date_modified' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
76
-       'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
71
+	   'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
72
+	   'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
73
+	   'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
74
+	   'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
75
+	   'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
76
+       'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
77 77
 	   
78
-       'range_date_closed' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
-	   'start_range_date_closed' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
80
-       'end_range_date_closed' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
78
+       'range_date_closed' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
79
+	   'start_range_date_closed' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
80
+       'end_range_date_closed' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
81 81
 
82
-       'range_amount' => array ('query_type' => 'default', 'enable_range_search' => true),
83
-	   'start_range_amount' => array ('query_type' => 'default',  'enable_range_search' => true),
84
-       'end_range_amount' => array ('query_type' => 'default', 'enable_range_search' => true),
82
+       'range_amount' => array('query_type' => 'default', 'enable_range_search' => true),
83
+	   'start_range_amount' => array('query_type' => 'default', 'enable_range_search' => true),
84
+       'end_range_amount' => array('query_type' => 'default', 'enable_range_search' => true),
85 85
 		//Range Search Support 			
86 86
 	);
87 87
 ?>
Please login to merge, or discard this patch.
modules/Campaigns/GenerateWebToLeadForm.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -107,11 +107,11 @@
 block discarded – undo
107 107
 }
108 108
 
109 109
 $typeOfPerson = !empty($_REQUEST['typeOfPerson']) ? $_REQUEST['typeOfPerson'] : 'Lead';
110
- $person = new $typeOfPerson();
111
- $fieldsMetaData = new FieldsMetaData();
112
- $xtpl=new XTemplate ('modules/Campaigns/WebToLeadForm.html');
113
- $xtpl->assign("MOD", $mod_strings);
114
- $xtpl->assign("APP", $app_strings);
110
+    $person = new $typeOfPerson();
111
+    $fieldsMetaData = new FieldsMetaData();
112
+    $xtpl=new XTemplate ('modules/Campaigns/WebToLeadForm.html');
113
+    $xtpl->assign("MOD", $mod_strings);
114
+    $xtpl->assign("APP", $app_strings);
115 115
 
116 116
 include_once 'WebToLeadFormBuilder.php';
117 117
 $Web_To_Lead_Form_html = WebToLeadFormBuilder::generate(
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.