Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created
modules/AOR_Scheduled_Reports/AOR_Scheduled_Reports.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
     var $last_run;
65 65
     var $aor_report_id;
66 66
 
67
-	function __construct(){
67
+	function __construct() {
68 68
         parent::__construct();
69 69
 	}
70 70
 
71 71
     /**
72 72
      * @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
73 73
      */
74
-    function AOR_Scheduled_Reports(){
74
+    function AOR_Scheduled_Reports() {
75 75
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
76
-        if(isset($GLOBALS['log'])) {
76
+        if (isset($GLOBALS['log'])) {
77 77
             $GLOBALS['log']->deprecated($deprecatedMessage);
78 78
         }
79 79
         else {
@@ -83,30 +83,30 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
 
86
-    function bean_implements($interface){
87
-        switch($interface){
86
+    function bean_implements($interface) {
87
+        switch ($interface) {
88 88
             case 'ACL': return true;
89 89
         }
90 90
         return false;
91 91
     }
92 92
 
93
-    function save($check_notify = FALSE){
93
+    function save($check_notify = FALSE) {
94 94
 
95
-        if(isset($_POST['email_recipients']) && is_array($_POST['email_recipients'])){
95
+        if (isset($_POST['email_recipients']) && is_array($_POST['email_recipients'])) {
96 96
             $this->email_recipients = base64_encode(serialize($_POST['email_recipients']));
97 97
         }
98 98
 
99 99
         parent::save($check_notify);
100 100
     }
101 101
 
102
-    function get_email_recipients(){
102
+    function get_email_recipients() {
103 103
 
104 104
         $params = unserialize(base64_decode($this->email_recipients));
105 105
 
106 106
         $emails = array();
107
-        if(isset($params['email_target_type'])){
108
-            foreach($params['email_target_type'] as $key => $field){
109
-                switch($field){
107
+        if (isset($params['email_target_type'])) {
108
+            foreach ($params['email_target_type'] as $key => $field) {
109
+                switch ($field) {
110 110
                     case 'Email Address':
111 111
                         $emails[] = $params['email'][$key];
112 112
                         break;
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
                         break;
118 118
                     case 'Users':
119 119
                         $users = array();
120
-                        switch($params['email'][$key][0]) {
120
+                        switch ($params['email'][$key][0]) {
121 121
                             Case 'security_group':
122
-                                if(file_exists('modules/SecurityGroups/SecurityGroup.php')){
122
+                                if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
123 123
                                     require_once('modules/SecurityGroups/SecurityGroup.php');
124 124
                                     $security_group = new SecurityGroup();
125 125
                                     $security_group->retrieve($params['email'][$key][1]);
126
-                                    $users = $security_group->get_linked_beans( 'users','User');
126
+                                    $users = $security_group->get_linked_beans('users', 'User');
127 127
                                     $r_users = array();
128
-                                    if($params['email'][$key][2] != ''){
128
+                                    if ($params['email'][$key][2] != '') {
129 129
                                         require_once('modules/ACLRoles/ACLRole.php');
130 130
                                         $role = new ACLRole();
131 131
                                         $role->retrieve($params['email'][$key][2]);
132
-                                        $role_users = $role->get_linked_beans( 'users','User');
133
-                                        foreach($role_users as $role_user){
132
+                                        $role_users = $role->get_linked_beans('users', 'User');
133
+                                        foreach ($role_users as $role_user) {
134 134
                                             $r_users[$role_user->id] = $role_user->name;
135 135
                                         }
136 136
                                     }
137
-                                    foreach($users as $user_id => $user){
138
-                                        if($params['email'][$key][2] != '' && !isset($r_users[$user->id])){
137
+                                    foreach ($users as $user_id => $user) {
138
+                                        if ($params['email'][$key][2] != '' && !isset($r_users[$user->id])) {
139 139
                                             unset($users[$user_id]);
140 140
                                         }
141 141
                                     }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                                 require_once('modules/ACLRoles/ACLRole.php');
147 147
                                 $role = new ACLRole();
148 148
                                 $role->retrieve($params['email'][$key][2]);
149
-                                $users = $role->get_linked_beans( 'users','User');
149
+                                $users = $role->get_linked_beans('users', 'User');
150 150
                                 break;
151 151
                             Case 'all':
152 152
                             default:
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                                 }
161 161
                                 break;
162 162
                         }
163
-                        foreach($users as $user){
163
+                        foreach ($users as $user) {
164 164
                             $emails[] = $user->emailAddress->getPrimaryAddress($user);
165 165
                         }
166 166
                         break;
@@ -171,18 +171,18 @@  discard block
 block discarded – undo
171 171
 
172 172
     }
173 173
 
174
-    function shouldRun(DateTime $date){
174
+    function shouldRun(DateTime $date) {
175 175
         global $timedate;
176
-        if(empty($date)){
176
+        if (empty($date)) {
177 177
             $date = new DateTime();
178 178
         }
179 179
         $cron = Cron\CronExpression::factory($this->schedule);
180
-        if(empty($this->last_run) && $cron->isDue($date)){
180
+        if (empty($this->last_run) && $cron->isDue($date)) {
181 181
             return true;
182 182
         }
183 183
         $lastRun = $timedate->fromDb($this->last_run);
184 184
         $next = $cron->getNextRunDate($lastRun);
185
-        if($next < $date){
185
+        if ($next < $date) {
186 186
             return true;
187 187
         }
188 188
         return false;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/AOW_Actions/actions/actionSendEmail.php 2 patches
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
 
29 29
     private $emailableModules = array();
30 30
 
31
-    function __construct($id = ''){
31
+    function __construct($id = '') {
32 32
         parent::__construct($id);
33 33
     }
34 34
 
35 35
     /**
36 36
      * @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
37 37
      */
38
-    function actionSendEmail($id = ''){
38
+    function actionSendEmail($id = '') {
39 39
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
40
-        if(isset($GLOBALS['log'])) {
40
+        if (isset($GLOBALS['log'])) {
41 41
             $GLOBALS['log']->deprecated($deprecatedMessage);
42 42
         }
43 43
         else {
@@ -47,50 +47,50 @@  discard block
 block discarded – undo
47 47
     }
48 48
 
49 49
 
50
-    function loadJS(){
50
+    function loadJS() {
51 51
         return array('modules/AOW_Actions/actions/actionSendEmail.js');
52 52
     }
53 53
 
54
-    function edit_display($line,SugarBean $bean = null, $params = array()){
54
+    function edit_display($line, SugarBean $bean = null, $params = array()) {
55 55
         global $app_list_strings;
56
-        $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name');
56
+        $email_templates_arr = get_bean_select_array(true, 'EmailTemplate', 'name');
57 57
 
58
-        if(!in_array($bean->module_dir,getEmailableModules())) unset($app_list_strings['aow_email_type_list']['Record Email']);
58
+        if (!in_array($bean->module_dir, getEmailableModules())) unset($app_list_strings['aow_email_type_list']['Record Email']);
59 59
         $targetOptions = getRelatedEmailableFields($bean->module_dir);
60
-        if(empty($targetOptions)) unset($app_list_strings['aow_email_type_list']['Related Field']);
60
+        if (empty($targetOptions)) unset($app_list_strings['aow_email_type_list']['Related Field']);
61 61
 
62 62
         $html = '<input type="hidden" name="aow_email_type_list" id="aow_email_type_list" value="'.get_select_options_with_id($app_list_strings['aow_email_type_list'], '').'">
63 63
 				  <input type="hidden" name="aow_email_to_list" id="aow_email_to_list" value="'.get_select_options_with_id($app_list_strings['aow_email_to_list'], '').'">';
64 64
 
65 65
         $checked = '';
66
-        if(isset($params['individual_email']) && $params['individual_email']) $checked = 'CHECKED';
66
+        if (isset($params['individual_email']) && $params['individual_email']) $checked = 'CHECKED';
67 67
 
68 68
         $html .= "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
69 69
         $html .= "<tr>";
70
-        $html .= '<td id="relate_label" scope="row" valign="top">'.translate("LBL_INDIVIDUAL_EMAILS","AOW_Actions").':';
70
+        $html .= '<td id="relate_label" scope="row" valign="top">'.translate("LBL_INDIVIDUAL_EMAILS", "AOW_Actions").':';
71 71
         $html .= '</td>';
72 72
         $html .= "<td valign='top' width='37.5%'>";
73 73
         $html .= "<input type='hidden' name='aow_actions_param[".$line."][individual_email]' value='0' >";
74 74
         $html .= "<input type='checkbox' id='aow_actions_param[".$line."][individual_email]' name='aow_actions_param[".$line."][individual_email]' value='1' $checked></td>";
75 75
         $html .= '</td>';
76 76
 
77
-        if(!isset($params['email_template'])) $params['email_template'] = '';
77
+        if (!isset($params['email_template'])) $params['email_template'] = '';
78 78
         $hidden = "style='visibility: hidden;'";
79
-        if($params['email_template'] != '') $hidden = "";
79
+        if ($params['email_template'] != '') $hidden = "";
80 80
 
81
-        $html .= '<td id="name_label" scope="row" valign="top" width="12.5%">'.translate("LBL_EMAIL_TEMPLATE","AOW_Actions").':<span class="required">*</span></td>';
81
+        $html .= '<td id="name_label" scope="row" valign="top" width="12.5%">'.translate("LBL_EMAIL_TEMPLATE", "AOW_Actions").':<span class="required">*</span></td>';
82 82
         $html .= "<td valign='top' width='37.5%'>";
83 83
         $html .= "<select name='aow_actions_param[".$line."][email_template]' id='aow_actions_param_email_template".$line."' onchange='show_edit_template_link(this,".$line.");' >".get_select_options_with_id($email_templates_arr, $params['email_template'])."</select>";
84 84
 
85
-        $html .= "&nbsp;<a href='javascript:open_email_template_form(".$line.")' >".translate('LBL_CREATE_EMAIL_TEMPLATE','AOW_Actions')."</a>";
86
-        $html .= "&nbsp;<span name='edit_template' id='aow_actions_edit_template_link".$line."' $hidden><a href='javascript:edit_email_template_form(".$line.")' >".translate('LBL_EDIT_EMAIL_TEMPLATE','AOW_Actions')."</a></span>";
85
+        $html .= "&nbsp;<a href='javascript:open_email_template_form(".$line.")' >".translate('LBL_CREATE_EMAIL_TEMPLATE', 'AOW_Actions')."</a>";
86
+        $html .= "&nbsp;<span name='edit_template' id='aow_actions_edit_template_link".$line."' $hidden><a href='javascript:edit_email_template_form(".$line.")' >".translate('LBL_EDIT_EMAIL_TEMPLATE', 'AOW_Actions')."</a></span>";
87 87
         $html .= "</td>";
88 88
         $html .= "</tr>";
89 89
         $html .= "<tr>";
90
-        $html .= '<td id="name_label" scope="row" valign="top" width="12.5%">'.translate("LBL_EMAIL","AOW_Actions").':<span class="required">*</span></td>';
90
+        $html .= '<td id="name_label" scope="row" valign="top" width="12.5%">'.translate("LBL_EMAIL", "AOW_Actions").':<span class="required">*</span></td>';
91 91
         $html .= '<td valign="top" scope="row" width="37.5%">';
92 92
 
93
-        $html .='<button type="button" onclick="add_emailLine('.$line.')"><img src="'.SugarThemeRegistry::current()->getImageURL('id-ff-add.png').'"></button>';
93
+        $html .= '<button type="button" onclick="add_emailLine('.$line.')"><img src="'.SugarThemeRegistry::current()->getImageURL('id-ff-add.png').'"></button>';
94 94
         $html .= '<table id="emailLine'.$line.'_table" width="100%"></table>';
95 95
         $html .= '</td>';
96 96
         $html .= "</tr>";
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
         $html .= "<script id ='aow_script".$line."'>";
100 100
 
101 101
         //backward compatible
102
-        if(isset($params['email_target_type']) && !is_array($params['email_target_type'])){
102
+        if (isset($params['email_target_type']) && !is_array($params['email_target_type'])) {
103 103
             $email = '';
104
-            switch($params['email_target_type']){
104
+            switch ($params['email_target_type']) {
105 105
                 case 'Email Address':
106 106
                     $email = $params['email'];
107 107
                     break;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
         }
117 117
         //end backward compatible
118 118
 
119
-        if(isset($params['email_target_type'])){
120
-            foreach($params['email_target_type'] as $key => $field){
121
-                if(is_array($params['email'][$key]))$params['email'][$key] = json_encode($params['email'][$key]);
119
+        if (isset($params['email_target_type'])) {
120
+            foreach ($params['email_target_type'] as $key => $field) {
121
+                if (is_array($params['email'][$key]))$params['email'][$key] = json_encode($params['email'][$key]);
122 122
                 $html .= "load_emailline('".$line."','".$params['email_to_type'][$key]."','".$params['email_target_type'][$key]."','".$params['email'][$key]."');";
123 123
             }
124 124
         }
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 
129 129
     }
130 130
 
131
-    private function getEmailsFromParams(SugarBean $bean, $params){
131
+    private function getEmailsFromParams(SugarBean $bean, $params) {
132 132
 
133 133
         $emails = array();
134 134
         //backward compatible
135
-        if(isset($params['email_target_type']) && !is_array($params['email_target_type'])){
135
+        if (isset($params['email_target_type']) && !is_array($params['email_target_type'])) {
136 136
             $email = '';
137
-            switch($params['email_target_type']){
137
+            switch ($params['email_target_type']) {
138 138
                 case 'Email Address':
139 139
                     $params['email'] = array($params['email']);
140 140
                     break;
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
             $params['email_to_type'] = array('to');
150 150
         }
151 151
         //end backward compatible
152
-        if(isset($params['email_target_type'])){
153
-            foreach($params['email_target_type'] as $key => $field){
154
-                switch($field){
152
+        if (isset($params['email_target_type'])) {
153
+            foreach ($params['email_target_type'] as $key => $field) {
154
+                switch ($field) {
155 155
                     case 'Email Address':
156
-                        if(trim($params['email'][$key]) != '')
156
+                        if (trim($params['email'][$key]) != '')
157 157
                             $emails[$params['email_to_type'][$key]][] = $params['email'][$key];
158 158
                         break;
159 159
                     case 'Specify User':
160 160
                         $user = new User();
161 161
                         $user->retrieve($params['email'][$key]);
162 162
                         $user_email = $user->emailAddress->getPrimaryAddress($user);
163
-                        if(trim($user_email) != '') {
163
+                        if (trim($user_email) != '') {
164 164
                             $emails[$params['email_to_type'][$key]][] = $user_email;
165 165
                             $emails['template_override'][$user_email] = array('Users' => $user->id);
166 166
                         }
@@ -168,25 +168,25 @@  discard block
 block discarded – undo
168 168
                         break;
169 169
                     case 'Users':
170 170
                         $users = array();
171
-                        switch($params['email'][$key][0]) {
171
+                        switch ($params['email'][$key][0]) {
172 172
                             Case 'security_group':
173
-                                if(file_exists('modules/SecurityGroups/SecurityGroup.php')){
173
+                                if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
174 174
                                     require_once('modules/SecurityGroups/SecurityGroup.php');
175 175
                                     $security_group = new SecurityGroup();
176 176
                                     $security_group->retrieve($params['email'][$key][1]);
177
-                                    $users = $security_group->get_linked_beans( 'users','User');
177
+                                    $users = $security_group->get_linked_beans('users', 'User');
178 178
                                     $r_users = array();
179
-                                    if($params['email'][$key][2] != ''){
179
+                                    if ($params['email'][$key][2] != '') {
180 180
                                         require_once('modules/ACLRoles/ACLRole.php');
181 181
                                         $role = new ACLRole();
182 182
                                         $role->retrieve($params['email'][$key][2]);
183
-                                        $role_users = $role->get_linked_beans( 'users','User');
184
-                                        foreach($role_users as $role_user){
183
+                                        $role_users = $role->get_linked_beans('users', 'User');
184
+                                        foreach ($role_users as $role_user) {
185 185
                                             $r_users[$role_user->id] = $role_user->name;
186 186
                                         }
187 187
                                     }
188
-                                    foreach($users as $user_id => $user){
189
-                                        if($params['email'][$key][2] != '' && !isset($r_users[$user->id])){
188
+                                    foreach ($users as $user_id => $user) {
189
+                                        if ($params['email'][$key][2] != '' && !isset($r_users[$user->id])) {
190 190
                                             unset($users[$user_id]);
191 191
                                         }
192 192
                                     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                                 require_once('modules/ACLRoles/ACLRole.php');
198 198
                                 $role = new ACLRole();
199 199
                                 $role->retrieve($params['email'][$key][2]);
200
-                                $users = $role->get_linked_beans( 'users','User');
200
+                                $users = $role->get_linked_beans('users', 'User');
201 201
                                 break;
202 202
                             Case 'all':
203 203
                             default:
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
                                 }
212 212
                                 break;
213 213
                         }
214
-                        foreach($users as $user){
214
+                        foreach ($users as $user) {
215 215
                             $user_email = $user->emailAddress->getPrimaryAddress($user);
216
-                            if(trim($user_email) != '') {
216
+                            if (trim($user_email) != '') {
217 217
                                 $emails[$params['email_to_type'][$key]][] = $user_email;
218 218
                                 $emails['template_override'][$user_email] = array('Users' => $user->id);
219 219
                             }
@@ -223,25 +223,25 @@  discard block
 block discarded – undo
223 223
                         $emailTarget = $params['email'][$key];
224 224
                         $relatedFields = array_merge($bean->get_related_fields(), $bean->get_linked_fields());
225 225
                         $field = $relatedFields[$emailTarget];
226
-                        if($field['type'] == 'relate') {
226
+                        if ($field['type'] == 'relate') {
227 227
                             $linkedBeans = array();
228 228
                             $idName = $field['id_name'];
229 229
                             $id = $bean->$idName;
230 230
                             $linkedBeans[] = BeanFactory::getBean($field['module'], $id);
231 231
                         }
232
-                        else if($field['type'] == 'link'){
232
+                        else if ($field['type'] == 'link') {
233 233
                             $relField = $field['name'];
234
-                            if(isset($field['module']) && $field['module'] != '') {
234
+                            if (isset($field['module']) && $field['module'] != '') {
235 235
                                 $rel_module = $field['module'];
236
-                            } else if($bean->load_relationship($relField)){
236
+                            } else if ($bean->load_relationship($relField)) {
237 237
                                 $rel_module = $bean->$relField->getRelatedModuleName();
238 238
                             }
239
-                            $linkedBeans = $bean->get_linked_beans($relField,$rel_module);
240
-                        }else{
241
-                            $linkedBeans = $bean->get_linked_beans($field['link'],$field['module']);
239
+                            $linkedBeans = $bean->get_linked_beans($relField, $rel_module);
240
+                        } else {
241
+                            $linkedBeans = $bean->get_linked_beans($field['link'], $field['module']);
242 242
                         }
243
-                        if($linkedBeans){
244
-                            foreach($linkedBeans as $linkedBean) {
243
+                        if ($linkedBeans) {
244
+                            foreach ($linkedBeans as $linkedBean) {
245 245
                                 $rel_email = $linkedBean->emailAddress->getPrimaryAddress($linkedBean);
246 246
                                 if (trim($rel_email) != '') {
247 247
                                     $emails[$params['email_to_type'][$key]][] = $rel_email;
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
                         break;
253 253
                     case 'Record Email':
254 254
                         $recordEmail = $bean->emailAddress->getPrimaryAddress($bean);
255
-                        if($recordEmail == '' && isset($bean->email1)) $recordEmail = $bean->email1;
256
-                        if(trim($recordEmail) != '')
255
+                        if ($recordEmail == '' && isset($bean->email1)) $recordEmail = $bean->email1;
256
+                        if (trim($recordEmail) != '')
257 257
                             $emails[$params['email_to_type'][$key]][] = $recordEmail;
258 258
                         break;
259 259
                 }
@@ -262,63 +262,63 @@  discard block
 block discarded – undo
262 262
         return $emails;
263 263
     }
264 264
 
265
-    function run_action(SugarBean $bean, $params = array(), $in_save=false){
265
+    function run_action(SugarBean $bean, $params = array(), $in_save = false) {
266 266
 
267 267
         include_once('modules/EmailTemplates/EmailTemplate.php');
268 268
         $emailTemp = new EmailTemplate();
269 269
         $emailTemp->retrieve($params['email_template']);
270 270
 
271
-        if($emailTemp->id == ''){
271
+        if ($emailTemp->id == '') {
272 272
             return false;
273 273
         }
274 274
 
275
-        $emails = $this->getEmailsFromParams($bean,$params);
275
+        $emails = $this->getEmailsFromParams($bean, $params);
276 276
 
277
-        if(!isset($emails['to']) || empty($emails['to']))
277
+        if (!isset($emails['to']) || empty($emails['to']))
278 278
             return false;
279 279
 
280 280
         $attachments = $this->getAttachments($emailTemp);
281 281
 
282
-        if(isset($params['individual_email']) && $params['individual_email']){
282
+        if (isset($params['individual_email']) && $params['individual_email']) {
283 283
 
284
-            foreach($emails['to'] as $email_to){
284
+            foreach ($emails['to'] as $email_to) {
285 285
                 $emailTemp = new EmailTemplate();
286 286
                 $emailTemp->retrieve($params['email_template']);
287 287
                 $template_override = isset($emails['template_override'][$email_to]) ? $emails['template_override'][$email_to] : array();
288
-                $this->parse_template($bean, $emailTemp,$template_override);
289
-                $this->sendEmail(array($email_to), $emailTemp->subject, $emailTemp->body_html, $emailTemp->body, $bean, $emails['cc'],$emails['bcc'],$attachments);
288
+                $this->parse_template($bean, $emailTemp, $template_override);
289
+                $this->sendEmail(array($email_to), $emailTemp->subject, $emailTemp->body_html, $emailTemp->body, $bean, $emails['cc'], $emails['bcc'], $attachments);
290 290
             }
291 291
 
292 292
         } else {
293 293
             $this->parse_template($bean, $emailTemp);
294
-            return $this->sendEmail($emails['to'], $emailTemp->subject, $emailTemp->body_html, $emailTemp->body, $bean, $emails['cc'],$emails['bcc'],$attachments);
294
+            return $this->sendEmail($emails['to'], $emailTemp->subject, $emailTemp->body_html, $emailTemp->body, $bean, $emails['cc'], $emails['bcc'], $attachments);
295 295
         }
296 296
         return true;
297 297
     }
298 298
 
299
-    function parse_template(SugarBean $bean, &$template, $object_override = array()){
299
+    function parse_template(SugarBean $bean, &$template, $object_override = array()) {
300 300
         global $sugar_config;
301 301
 
302 302
         require_once('modules/AOW_Actions/actions/templateParser.php');
303 303
 
304 304
         $object_arr[$bean->module_dir] = $bean->id;
305 305
 
306
-        foreach($bean->field_defs as $bean_arr){
307
-            if($bean_arr['type'] == 'relate'){
308
-                if(isset($bean_arr['module']) &&  $bean_arr['module'] != '' && isset($bean_arr['id_name']) &&  $bean_arr['id_name'] != '' && $bean_arr['module'] != 'EmailAddress'){
306
+        foreach ($bean->field_defs as $bean_arr) {
307
+            if ($bean_arr['type'] == 'relate') {
308
+                if (isset($bean_arr['module']) && $bean_arr['module'] != '' && isset($bean_arr['id_name']) && $bean_arr['id_name'] != '' && $bean_arr['module'] != 'EmailAddress') {
309 309
                     $idName = $bean_arr['id_name'];
310
-                    if(isset($bean->field_defs[$idName]) && $bean->field_defs[$idName]['source'] != 'non-db'){
311
-                        if(!isset($object_arr[$bean_arr['module']])) $object_arr[$bean_arr['module']] = $bean->$idName;
310
+                    if (isset($bean->field_defs[$idName]) && $bean->field_defs[$idName]['source'] != 'non-db') {
311
+                        if (!isset($object_arr[$bean_arr['module']])) $object_arr[$bean_arr['module']] = $bean->$idName;
312 312
                     }
313 313
                 }
314 314
             }
315
-            else if($bean_arr['type'] == 'link'){
316
-                if(!isset($bean_arr['module']) || $bean_arr['module'] == '') $bean_arr['module'] = getRelatedModule($bean->module_dir,$bean_arr['name']);
317
-                if(isset($bean_arr['module']) &&  $bean_arr['module'] != ''&& !isset($object_arr[$bean_arr['module']])&& $bean_arr['module'] != 'EmailAddress'){
318
-                    $linkedBeans = $bean->get_linked_beans($bean_arr['name'],$bean_arr['module'], array(), 0, 1);
319
-                    if($linkedBeans){
315
+            else if ($bean_arr['type'] == 'link') {
316
+                if (!isset($bean_arr['module']) || $bean_arr['module'] == '') $bean_arr['module'] = getRelatedModule($bean->module_dir, $bean_arr['name']);
317
+                if (isset($bean_arr['module']) && $bean_arr['module'] != '' && !isset($object_arr[$bean_arr['module']]) && $bean_arr['module'] != 'EmailAddress') {
318
+                    $linkedBeans = $bean->get_linked_beans($bean_arr['name'], $bean_arr['module'], array(), 0, 1);
319
+                    if ($linkedBeans) {
320 320
                         $linkedBean = $linkedBeans[0];
321
-                        if(!isset($object_arr[$linkedBean->module_dir])) $object_arr[$linkedBean->module_dir] = $linkedBean->id;
321
+                        if (!isset($object_arr[$linkedBean->module_dir])) $object_arr[$linkedBean->module_dir] = $linkedBean->id;
322 322
                     }
323 323
                 }
324 324
             }
@@ -330,34 +330,34 @@  discard block
 block discarded – undo
330 330
 
331 331
         $parsedSiteUrl = parse_url($sugar_config['site_url']);
332 332
         $host = $parsedSiteUrl['host'];
333
-        if(!isset($parsedSiteUrl['port'])) {
333
+        if (!isset($parsedSiteUrl['port'])) {
334 334
             $parsedSiteUrl['port'] = 80;
335 335
         }
336 336
 
337 337
         $port		= ($parsedSiteUrl['port'] != 80) ? ":".$parsedSiteUrl['port'] : '';
338 338
         $path		= !empty($parsedSiteUrl['path']) ? $parsedSiteUrl['path'] : "";
339
-        $cleanUrl	= "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}";
339
+        $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}";
340 340
 
341
-        $url =  $cleanUrl."/index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}";
341
+        $url = $cleanUrl."/index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}";
342 342
 
343
-        $template->subject = str_replace("\$contact_user","\$user",$template->subject);
344
-        $template->body_html = str_replace("\$contact_user","\$user",$template->body_html);
345
-        $template->body = str_replace("\$contact_user","\$user",$template->body);
343
+        $template->subject = str_replace("\$contact_user", "\$user", $template->subject);
344
+        $template->body_html = str_replace("\$contact_user", "\$user", $template->body_html);
345
+        $template->body = str_replace("\$contact_user", "\$user", $template->body);
346 346
         $template->subject = aowTemplateParser::parse_template($template->subject, $object_arr);
347 347
         $template->body_html = aowTemplateParser::parse_template($template->body_html, $object_arr);
348
-        $template->body_html = str_replace("\$url",$url,$template->body_html);
348
+        $template->body_html = str_replace("\$url", $url, $template->body_html);
349 349
         $template->body = aowTemplateParser::parse_template($template->body, $object_arr);
350
-        $template->body = str_replace("\$url",$url,$template->body);
350
+        $template->body = str_replace("\$url", $url, $template->body);
351 351
     }
352 352
 
353
-    function getAttachments(EmailTemplate $template){
353
+    function getAttachments(EmailTemplate $template) {
354 354
 
355 355
         $attachments = array();
356
-        if($template->id != ''){
356
+        if ($template->id != '') {
357 357
             $note_bean = new Note();
358
-            $notes = $note_bean->get_full_list('',"parent_type = 'Emails' AND parent_id = '".$template->id."'");
358
+            $notes = $note_bean->get_full_list('', "parent_type = 'Emails' AND parent_id = '".$template->id."'");
359 359
 
360
-            if($notes != null){
360
+            if ($notes != null) {
361 361
                 foreach ($notes as $note) {
362 362
                     $attachments[] = $note;
363 363
                 }
@@ -379,39 +379,39 @@  discard block
 block discarded – undo
379 379
         $mail->FromName = $defaults['name'];
380 380
         $mail->ClearAllRecipients();
381 381
         $mail->ClearReplyTos();
382
-        $mail->Subject=from_html($emailSubject);
383
-        $mail->Body=$emailBody;
382
+        $mail->Subject = from_html($emailSubject);
383
+        $mail->Body = $emailBody;
384 384
         $mail->AltBody = $altemailBody;
385 385
         $mail->handleAttachments($attachments);
386 386
         $mail->prepForOutbound();
387 387
 
388
-        if(empty($emailTo)) return false;
389
-        foreach($emailTo as $to){
388
+        if (empty($emailTo)) return false;
389
+        foreach ($emailTo as $to) {
390 390
             $mail->AddAddress($to);
391 391
         }
392
-        if(!empty($emailCc)){
393
-            foreach($emailCc as $email){
392
+        if (!empty($emailCc)) {
393
+            foreach ($emailCc as $email) {
394 394
                 $mail->AddCC($email);
395 395
             }
396 396
         }
397
-        if(!empty($emailBcc)){
398
-            foreach($emailBcc as $email){
397
+        if (!empty($emailBcc)) {
398
+            foreach ($emailBcc as $email) {
399 399
                 $mail->AddBCC($email);
400 400
             }
401 401
         }
402 402
 
403 403
         //now create email
404 404
         if (@$mail->Send()) {
405
-            $emailObj->to_addrs= implode(',',$emailTo);
406
-            $emailObj->cc_addrs= implode(',',$emailCc);
407
-            $emailObj->bcc_addrs= implode(',',$emailBcc);
408
-            $emailObj->type= 'out';
405
+            $emailObj->to_addrs = implode(',', $emailTo);
406
+            $emailObj->cc_addrs = implode(',', $emailCc);
407
+            $emailObj->bcc_addrs = implode(',', $emailBcc);
408
+            $emailObj->type = 'out';
409 409
             $emailObj->deleted = '0';
410 410
             $emailObj->name = $mail->Subject;
411 411
             $emailObj->description = $mail->AltBody;
412 412
             $emailObj->description_html = $mail->Body;
413 413
             $emailObj->from_addr = $mail->From;
414
-            if ( $relatedBean instanceOf SugarBean && !empty($relatedBean->id) ) {
414
+            if ($relatedBean instanceOf SugarBean && !empty($relatedBean->id)) {
415 415
                 $emailObj->parent_type = $relatedBean->module_dir;
416 416
                 $emailObj->parent_id = $relatedBean->id;
417 417
             }
Please login to merge, or discard this patch.
Braces   +46 added lines, -24 removed lines patch added patch discarded remove patch
@@ -39,8 +39,7 @@  discard block
 block discarded – undo
39 39
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
40 40
         if(isset($GLOBALS['log'])) {
41 41
             $GLOBALS['log']->deprecated($deprecatedMessage);
42
-        }
43
-        else {
42
+        } else {
44 43
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
45 44
         }
46 45
         self::__construct($id);
@@ -55,15 +54,21 @@  discard block
 block discarded – undo
55 54
         global $app_list_strings;
56 55
         $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name');
57 56
 
58
-        if(!in_array($bean->module_dir,getEmailableModules())) unset($app_list_strings['aow_email_type_list']['Record Email']);
57
+        if(!in_array($bean->module_dir,getEmailableModules())) {
58
+            unset($app_list_strings['aow_email_type_list']['Record Email']);
59
+        }
59 60
         $targetOptions = getRelatedEmailableFields($bean->module_dir);
60
-        if(empty($targetOptions)) unset($app_list_strings['aow_email_type_list']['Related Field']);
61
+        if(empty($targetOptions)) {
62
+            unset($app_list_strings['aow_email_type_list']['Related Field']);
63
+        }
61 64
 
62 65
         $html = '<input type="hidden" name="aow_email_type_list" id="aow_email_type_list" value="'.get_select_options_with_id($app_list_strings['aow_email_type_list'], '').'">
63 66
 				  <input type="hidden" name="aow_email_to_list" id="aow_email_to_list" value="'.get_select_options_with_id($app_list_strings['aow_email_to_list'], '').'">';
64 67
 
65 68
         $checked = '';
66
-        if(isset($params['individual_email']) && $params['individual_email']) $checked = 'CHECKED';
69
+        if(isset($params['individual_email']) && $params['individual_email']) {
70
+            $checked = 'CHECKED';
71
+        }
67 72
 
68 73
         $html .= "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
69 74
         $html .= "<tr>";
@@ -74,9 +79,13 @@  discard block
 block discarded – undo
74 79
         $html .= "<input type='checkbox' id='aow_actions_param[".$line."][individual_email]' name='aow_actions_param[".$line."][individual_email]' value='1' $checked></td>";
75 80
         $html .= '</td>';
76 81
 
77
-        if(!isset($params['email_template'])) $params['email_template'] = '';
82
+        if(!isset($params['email_template'])) {
83
+            $params['email_template'] = '';
84
+        }
78 85
         $hidden = "style='visibility: hidden;'";
79
-        if($params['email_template'] != '') $hidden = "";
86
+        if($params['email_template'] != '') {
87
+            $hidden = "";
88
+        }
80 89
 
81 90
         $html .= '<td id="name_label" scope="row" valign="top" width="12.5%">'.translate("LBL_EMAIL_TEMPLATE","AOW_Actions").':<span class="required">*</span></td>';
82 91
         $html .= "<td valign='top' width='37.5%'>";
@@ -118,7 +127,9 @@  discard block
 block discarded – undo
118 127
 
119 128
         if(isset($params['email_target_type'])){
120 129
             foreach($params['email_target_type'] as $key => $field){
121
-                if(is_array($params['email'][$key]))$params['email'][$key] = json_encode($params['email'][$key]);
130
+                if(is_array($params['email'][$key])) {
131
+                    $params['email'][$key] = json_encode($params['email'][$key]);
132
+                }
122 133
                 $html .= "load_emailline('".$line."','".$params['email_to_type'][$key]."','".$params['email_target_type'][$key]."','".$params['email'][$key]."');";
123 134
             }
124 135
         }
@@ -153,8 +164,9 @@  discard block
 block discarded – undo
153 164
             foreach($params['email_target_type'] as $key => $field){
154 165
                 switch($field){
155 166
                     case 'Email Address':
156
-                        if(trim($params['email'][$key]) != '')
157
-                            $emails[$params['email_to_type'][$key]][] = $params['email'][$key];
167
+                        if(trim($params['email'][$key]) != '') {
168
+                                                    $emails[$params['email_to_type'][$key]][] = $params['email'][$key];
169
+                        }
158 170
                         break;
159 171
                     case 'Specify User':
160 172
                         $user = new User();
@@ -228,8 +240,7 @@  discard block
 block discarded – undo
228 240
                             $idName = $field['id_name'];
229 241
                             $id = $bean->$idName;
230 242
                             $linkedBeans[] = BeanFactory::getBean($field['module'], $id);
231
-                        }
232
-                        else if($field['type'] == 'link'){
243
+                        } else if($field['type'] == 'link'){
233 244
                             $relField = $field['name'];
234 245
                             if(isset($field['module']) && $field['module'] != '') {
235 246
                                 $rel_module = $field['module'];
@@ -237,7 +248,7 @@  discard block
 block discarded – undo
237 248
                                 $rel_module = $bean->$relField->getRelatedModuleName();
238 249
                             }
239 250
                             $linkedBeans = $bean->get_linked_beans($relField,$rel_module);
240
-                        }else{
251
+                        } else{
241 252
                             $linkedBeans = $bean->get_linked_beans($field['link'],$field['module']);
242 253
                         }
243 254
                         if($linkedBeans){
@@ -252,9 +263,12 @@  discard block
 block discarded – undo
252 263
                         break;
253 264
                     case 'Record Email':
254 265
                         $recordEmail = $bean->emailAddress->getPrimaryAddress($bean);
255
-                        if($recordEmail == '' && isset($bean->email1)) $recordEmail = $bean->email1;
256
-                        if(trim($recordEmail) != '')
257
-                            $emails[$params['email_to_type'][$key]][] = $recordEmail;
266
+                        if($recordEmail == '' && isset($bean->email1)) {
267
+                            $recordEmail = $bean->email1;
268
+                        }
269
+                        if(trim($recordEmail) != '') {
270
+                                                    $emails[$params['email_to_type'][$key]][] = $recordEmail;
271
+                        }
258 272
                         break;
259 273
                 }
260 274
             }
@@ -274,8 +288,9 @@  discard block
 block discarded – undo
274 288
 
275 289
         $emails = $this->getEmailsFromParams($bean,$params);
276 290
 
277
-        if(!isset($emails['to']) || empty($emails['to']))
278
-            return false;
291
+        if(!isset($emails['to']) || empty($emails['to'])) {
292
+                    return false;
293
+        }
279 294
 
280 295
         $attachments = $this->getAttachments($emailTemp);
281 296
 
@@ -308,17 +323,22 @@  discard block
 block discarded – undo
308 323
                 if(isset($bean_arr['module']) &&  $bean_arr['module'] != '' && isset($bean_arr['id_name']) &&  $bean_arr['id_name'] != '' && $bean_arr['module'] != 'EmailAddress'){
309 324
                     $idName = $bean_arr['id_name'];
310 325
                     if(isset($bean->field_defs[$idName]) && $bean->field_defs[$idName]['source'] != 'non-db'){
311
-                        if(!isset($object_arr[$bean_arr['module']])) $object_arr[$bean_arr['module']] = $bean->$idName;
326
+                        if(!isset($object_arr[$bean_arr['module']])) {
327
+                            $object_arr[$bean_arr['module']] = $bean->$idName;
328
+                        }
312 329
                     }
313 330
                 }
314
-            }
315
-            else if($bean_arr['type'] == 'link'){
316
-                if(!isset($bean_arr['module']) || $bean_arr['module'] == '') $bean_arr['module'] = getRelatedModule($bean->module_dir,$bean_arr['name']);
331
+            } else if($bean_arr['type'] == 'link'){
332
+                if(!isset($bean_arr['module']) || $bean_arr['module'] == '') {
333
+                    $bean_arr['module'] = getRelatedModule($bean->module_dir,$bean_arr['name']);
334
+                }
317 335
                 if(isset($bean_arr['module']) &&  $bean_arr['module'] != ''&& !isset($object_arr[$bean_arr['module']])&& $bean_arr['module'] != 'EmailAddress'){
318 336
                     $linkedBeans = $bean->get_linked_beans($bean_arr['name'],$bean_arr['module'], array(), 0, 1);
319 337
                     if($linkedBeans){
320 338
                         $linkedBean = $linkedBeans[0];
321
-                        if(!isset($object_arr[$linkedBean->module_dir])) $object_arr[$linkedBean->module_dir] = $linkedBean->id;
339
+                        if(!isset($object_arr[$linkedBean->module_dir])) {
340
+                            $object_arr[$linkedBean->module_dir] = $linkedBean->id;
341
+                        }
322 342
                     }
323 343
                 }
324 344
             }
@@ -385,7 +405,9 @@  discard block
 block discarded – undo
385 405
         $mail->handleAttachments($attachments);
386 406
         $mail->prepForOutbound();
387 407
 
388
-        if(empty($emailTo)) return false;
408
+        if(empty($emailTo)) {
409
+            return false;
410
+        }
389 411
         foreach($emailTo as $to){
390 412
             $mail->AddAddress($to);
391 413
         }
Please login to merge, or discard this patch.
modules/AOW_Actions/actions/actionModifyRecord.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 require_once('modules/AOW_Actions/actions/actionCreateRecord.php');
28 28
 class actionModifyRecord extends actionCreateRecord {
29 29
 
30
-    function __construct($id = ''){
30
+    function __construct($id = '') {
31 31
         parent::__construct($id);
32 32
     }
33 33
 
34 34
     /**
35 35
      * @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
36 36
      */
37
-    function actionModifyRecord($id = ''){
37
+    function actionModifyRecord($id = '') {
38 38
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
39
-        if(isset($GLOBALS['log'])) {
39
+        if (isset($GLOBALS['log'])) {
40 40
             $GLOBALS['log']->deprecated($deprecatedMessage);
41 41
         }
42 42
         else {
@@ -46,32 +46,32 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
 
49
-    function loadJS(){
49
+    function loadJS() {
50 50
         return parent::loadJS();
51 51
     }
52 52
 
53
-    function edit_display($line,SugarBean $bean = null, $params = array()){
53
+    function edit_display($line, SugarBean $bean = null, $params = array()) {
54 54
         require_once("modules/AOW_WorkFlow/aow_utils.php");
55 55
 
56
-        $modules = getModuleRelationships($bean->module_dir,'EditView', $params['rel_type']);
56
+        $modules = getModuleRelationships($bean->module_dir, 'EditView', $params['rel_type']);
57 57
 
58 58
         $html = "<input type='hidden' name='aow_actions_param[".$line."][record_type]' id='aow_actions_param_record_type".$line."' value='' />";
59 59
         $html .= "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
60 60
         $html .= "<tr>";
61
-        $html .= '<td id="name_label" scope="row" valign="top">'.translate("LBL_RECORD_TYPE","AOW_Actions").':<span class="required">*</span>&nbsp;&nbsp;';
61
+        $html .= '<td id="name_label" scope="row" valign="top">'.translate("LBL_RECORD_TYPE", "AOW_Actions").':<span class="required">*</span>&nbsp;&nbsp;';
62 62
         $html .= "<select name='aow_actions_param[".$line."][rel_type]' id='aow_actions_param_rel_type".$line."'  onchange='show_mrModuleFields($line);'>".$modules."</select></td>";
63 63
         $html .= "</tr>";
64 64
         $html .= "<tr>";
65 65
         $html .= '<td colspan="4" scope="row"><table id="crLine'.$line.'_table" width="100%"></table></td>';
66 66
         $html .= "</tr>";
67 67
         $html .= "<tr>";
68
-        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" class="button" value="'.translate("LBL_ADD_FIELD","AOW_Actions").'" id="addcrline'.$line.'" onclick="add_crLine('.$line.')" /></td>';
68
+        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" class="button" value="'.translate("LBL_ADD_FIELD", "AOW_Actions").'" id="addcrline'.$line.'" onclick="add_crLine('.$line.')" /></td>';
69 69
         $html .= "</tr>";
70 70
         $html .= "<tr>";
71 71
         $html .= '<td colspan="4" scope="row"><table id="crRelLine'.$line.'_table" width="100%"></table></td>';
72 72
         $html .= "</tr>";
73 73
         $html .= "<tr>";
74
-        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" class="button" value="'.translate("LBL_ADD_RELATIONSHIP","AOW_Actions").'" id="addcrrelline'.$line.'" onclick="add_crRelLine('.$line.')" /></td>';
74
+        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" class="button" value="'.translate("LBL_ADD_RELATIONSHIP", "AOW_Actions").'" id="addcrrelline'.$line.'" onclick="add_crRelLine('.$line.')" /></td>';
75 75
         $html .= "</tr>";
76 76
 
77 77
 
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
         $html .= "cr_module[".$line."] = \"".$module."\";";
94 94
         $html .= "cr_fields[".$line."] = \"".trim(preg_replace('/\s+/', ' ', getModuleFields($module)))."\";";
95 95
         $html .= "cr_relationships[".$line."] = \"".trim(preg_replace('/\s+/', ' ', getModuleRelationships($module)))."\";";
96
-        if($params && array_key_exists('field',$params)){
97
-            foreach($params['field'] as $key => $field){
98
-                if(is_array($params['value'][$key]))$params['value'][$key] = json_encode($params['value'][$key]);
96
+        if ($params && array_key_exists('field', $params)) {
97
+            foreach ($params['field'] as $key => $field) {
98
+                if (is_array($params['value'][$key]))$params['value'][$key] = json_encode($params['value'][$key]);
99 99
 
100
-                $html .= "load_crline('".$line."','".$field."','".str_replace(array("\r\n","\r","\n")," ",$params['value'][$key])."','".$params['value_type'][$key]."');";
100
+                $html .= "load_crline('".$line."','".$field."','".str_replace(array("\r\n", "\r", "\n"), " ", $params['value'][$key])."','".$params['value_type'][$key]."');";
101 101
             }
102 102
         }
103
-        if(isset($params['rel'])){
104
-            foreach($params['rel'] as $key => $field){
105
-                if(is_array($params['rel_value'][$key]))$params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
103
+        if (isset($params['rel'])) {
104
+            foreach ($params['rel'] as $key => $field) {
105
+                if (is_array($params['rel_value'][$key]))$params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
106 106
 
107 107
                 $html .= "load_crrelline('".$line."','".$field."','".$params['rel_value'][$key]."','".$params['rel_value_type'][$key]."');";
108 108
             }
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
         return $html;
112 112
     }
113 113
 
114
-    function run_action(SugarBean $bean, $params = array(), $in_save=false){
114
+    function run_action(SugarBean $bean, $params = array(), $in_save = false) {
115 115
 
116
-        if(isset($params['rel_type']) && $params['rel_type'] != '' && $bean->module_dir != $params['rel_type']){
116
+        if (isset($params['rel_type']) && $params['rel_type'] != '' && $bean->module_dir != $params['rel_type']) {
117 117
             $relatedFields = $bean->get_linked_fields();
118 118
             $field = $relatedFields[$params['rel_type']];
119
-            if(!isset($field['module']) || $field['module'] == '') $field['module'] = getRelatedModule($bean->module_dir,$field['name']);
120
-            $linkedBeans = $bean->get_linked_beans($field['name'],$field['module']);
121
-            if($linkedBeans){
122
-                foreach($linkedBeans as $linkedBean){
119
+            if (!isset($field['module']) || $field['module'] == '') $field['module'] = getRelatedModule($bean->module_dir, $field['name']);
120
+            $linkedBeans = $bean->get_linked_beans($field['name'], $field['module']);
121
+            if ($linkedBeans) {
122
+                foreach ($linkedBeans as $linkedBean) {
123 123
                     $this->set_record($linkedBean, $bean, $params, false);
124 124
                     $this->set_relationships($linkedBean, $bean, $params);
125 125
                 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@  discard block
 block discarded – undo
38 38
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
39 39
         if(isset($GLOBALS['log'])) {
40 40
             $GLOBALS['log']->deprecated($deprecatedMessage);
41
-        }
42
-        else {
41
+        } else {
43 42
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
44 43
         }
45 44
         self::__construct($id);
@@ -95,14 +94,18 @@  discard block
 block discarded – undo
95 94
         $html .= "cr_relationships[".$line."] = \"".trim(preg_replace('/\s+/', ' ', getModuleRelationships($module)))."\";";
96 95
         if($params && array_key_exists('field',$params)){
97 96
             foreach($params['field'] as $key => $field){
98
-                if(is_array($params['value'][$key]))$params['value'][$key] = json_encode($params['value'][$key]);
97
+                if(is_array($params['value'][$key])) {
98
+                    $params['value'][$key] = json_encode($params['value'][$key]);
99
+                }
99 100
 
100 101
                 $html .= "load_crline('".$line."','".$field."','".str_replace(array("\r\n","\r","\n")," ",$params['value'][$key])."','".$params['value_type'][$key]."');";
101 102
             }
102 103
         }
103 104
         if(isset($params['rel'])){
104 105
             foreach($params['rel'] as $key => $field){
105
-                if(is_array($params['rel_value'][$key]))$params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
106
+                if(is_array($params['rel_value'][$key])) {
107
+                    $params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
108
+                }
106 109
 
107 110
                 $html .= "load_crrelline('".$line."','".$field."','".$params['rel_value'][$key]."','".$params['rel_value_type'][$key]."');";
108 111
             }
@@ -116,7 +119,9 @@  discard block
 block discarded – undo
116 119
         if(isset($params['rel_type']) && $params['rel_type'] != '' && $bean->module_dir != $params['rel_type']){
117 120
             $relatedFields = $bean->get_linked_fields();
118 121
             $field = $relatedFields[$params['rel_type']];
119
-            if(!isset($field['module']) || $field['module'] == '') $field['module'] = getRelatedModule($bean->module_dir,$field['name']);
122
+            if(!isset($field['module']) || $field['module'] == '') {
123
+                $field['module'] = getRelatedModule($bean->module_dir,$field['name']);
124
+            }
120 125
             $linkedBeans = $bean->get_linked_beans($field['name'],$field['module']);
121 126
             if($linkedBeans){
122 127
                 foreach($linkedBeans as $linkedBean){
Please login to merge, or discard this patch.
modules/AOW_Actions/actions/actionCreateRecord.php 2 patches
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
 require_once('modules/AOW_Actions/actions/actionBase.php');
27 27
 class actionCreateRecord extends actionBase {
28 28
 
29
-    function __construct($id = ''){
29
+    function __construct($id = '') {
30 30
         parent::__construct($id);
31 31
     }
32 32
 
33 33
     /**
34 34
      * @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
35 35
      */
36
-    function actionCreateRecord($id = ''){
36
+    function actionCreateRecord($id = '') {
37 37
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
38
-        if(isset($GLOBALS['log'])) {
38
+        if (isset($GLOBALS['log'])) {
39 39
             $GLOBALS['log']->deprecated($deprecatedMessage);
40 40
         }
41 41
         else {
@@ -45,24 +45,24 @@  discard block
 block discarded – undo
45 45
     }
46 46
 
47 47
 
48
-    function loadJS(){
48
+    function loadJS() {
49 49
 
50 50
         return array('modules/AOW_Actions/actions/actionCreateRecord.js');
51 51
     }
52 52
 
53
-    function edit_display($line,SugarBean $bean = null, $params = array()){
53
+    function edit_display($line, SugarBean $bean = null, $params = array()) {
54 54
         global $app_list_strings;
55 55
 
56 56
         $modules = $app_list_strings['aow_moduleList'];
57 57
 
58 58
         $checked = 'CHECKED';
59
-        if(isset($params['relate_to_workflow']) && !$params['relate_to_workflow']) $checked = '';
59
+        if (isset($params['relate_to_workflow']) && !$params['relate_to_workflow']) $checked = '';
60 60
 
61 61
         $html = "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
62 62
         $html .= "<tr>";
63
-        $html .= '<td id="name_label" scope="row" valign="top">'.translate("LBL_RECORD_TYPE","AOW_Actions").':<span class="required">*</span>&nbsp;&nbsp;';
63
+        $html .= '<td id="name_label" scope="row" valign="top">'.translate("LBL_RECORD_TYPE", "AOW_Actions").':<span class="required">*</span>&nbsp;&nbsp;';
64 64
         $html .= "<select name='aow_actions_param[".$line."][record_type]' id='aow_actions_param_record_type".$line."'  onchange='show_crModuleFields($line);'>".get_select_options_with_id($modules, $params['record_type'])."</select></td>";
65
-        $html .= '<td id="relate_label" scope="row" valign="top">'.translate("LBL_RELATE_WORKFLOW","AOW_Actions").':&nbsp;&nbsp;';
65
+        $html .= '<td id="relate_label" scope="row" valign="top">'.translate("LBL_RELATE_WORKFLOW", "AOW_Actions").':&nbsp;&nbsp;';
66 66
         $html .= "<input type='hidden' name='aow_actions_param[".$line."][relate_to_workflow]' value='0' >";
67 67
         $html .= "<input type='checkbox' id='aow_actions_param[".$line."][relate_to_workflow]' name='aow_actions_param[".$line."][relate_to_workflow]' value='1' $checked></td>";
68 68
         $html .= "</tr>";
@@ -70,32 +70,32 @@  discard block
 block discarded – undo
70 70
         $html .= '<td colspan="4" scope="row"><table id="crLine'.$line.'_table" width="100%"></table></td>';
71 71
         $html .= "</tr>";
72 72
         $html .= "<tr>";
73
-        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" style="display:none" class="button" value="'.translate("LBL_ADD_FIELD","AOW_Actions").'" id="addcrline'.$line.'" onclick="add_crLine('.$line.')" /></td>';
73
+        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" style="display:none" class="button" value="'.translate("LBL_ADD_FIELD", "AOW_Actions").'" id="addcrline'.$line.'" onclick="add_crLine('.$line.')" /></td>';
74 74
         $html .= "</tr>";
75 75
         $html .= "<tr>";
76 76
         $html .= '<td colspan="4" scope="row"><table id="crRelLine'.$line.'_table" width="100%"></table></td>';
77 77
         $html .= "</tr>";
78 78
         $html .= "<tr>";
79
-        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" style="display:none" class="button" value="'.translate("LBL_ADD_RELATIONSHIP","AOW_Actions").'" id="addcrrelline'.$line.'" onclick="add_crRelLine('.$line.')" /></td>';
79
+        $html .= '<td colspan="4" scope="row"><input type="button" tabindex="116" style="display:none" class="button" value="'.translate("LBL_ADD_RELATIONSHIP", "AOW_Actions").'" id="addcrrelline'.$line.'" onclick="add_crRelLine('.$line.')" /></td>';
80 80
         $html .= "</tr>";
81 81
 
82 82
 
83
-        if(isset($params['record_type']) && $params['record_type'] != ''){
83
+        if (isset($params['record_type']) && $params['record_type'] != '') {
84 84
             require_once("modules/AOW_WorkFlow/aow_utils.php");
85 85
             $html .= "<script id ='aow_script".$line."'>";
86 86
             $html .= "cr_fields[".$line."] = \"".trim(preg_replace('/\s+/', ' ', getModuleFields($params['record_type'])))."\";";
87 87
             $html .= "cr_relationships[".$line."] = \"".trim(preg_replace('/\s+/', ' ', getModuleRelationships($params['record_type'])))."\";";
88 88
             $html .= "cr_module[".$line."] = \"".$params['record_type']."\";";
89
-            if(isset($params['field'])){
90
-                foreach($params['field'] as $key => $field){
91
-                    if(is_array($params['value'][$key]))$params['value'][$key] = json_encode($params['value'][$key]);
89
+            if (isset($params['field'])) {
90
+                foreach ($params['field'] as $key => $field) {
91
+                    if (is_array($params['value'][$key]))$params['value'][$key] = json_encode($params['value'][$key]);
92 92
 
93
-                    $html .= "load_crline('".$line."','".$field."','".str_replace(array("\r\n","\r","\n")," ",$params['value'][$key])."','".$params['value_type'][$key]."');";
93
+                    $html .= "load_crline('".$line."','".$field."','".str_replace(array("\r\n", "\r", "\n"), " ", $params['value'][$key])."','".$params['value_type'][$key]."');";
94 94
                 }
95 95
             }
96
-            if(isset($params['rel'])){
97
-                foreach($params['rel'] as $key => $field){
98
-                    if(is_array($params['rel_value'][$key]))$params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
96
+            if (isset($params['rel'])) {
97
+                foreach ($params['rel'] as $key => $field) {
98
+                    if (is_array($params['rel_value'][$key]))$params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
99 99
 
100 100
                     $html .= "load_crrelline('".$line."','".$field."','".$params['rel_value'][$key]."','".$params['rel_value_type'][$key]."');";
101 101
                 }
@@ -106,21 +106,21 @@  discard block
 block discarded – undo
106 106
 
107 107
     }
108 108
 
109
-    function run_action(SugarBean $bean, $params = array(), $in_save=false){
109
+    function run_action(SugarBean $bean, $params = array(), $in_save = false) {
110 110
         global $beanList;
111 111
 
112
-        if(isset($params['record_type']) && $params['record_type'] != ''){
113
-            if($beanList[$params['record_type']]){
112
+        if (isset($params['record_type']) && $params['record_type'] != '') {
113
+            if ($beanList[$params['record_type']]) {
114 114
                 $record = new $beanList[$params['record_type']]();
115 115
                 $this->set_record($record, $bean, $params);
116 116
                 $this->set_relationships($record, $bean, $params);
117 117
 
118
-                if(isset($params['relate_to_workflow']) && $params['relate_to_workflow']){
118
+                if (isset($params['relate_to_workflow']) && $params['relate_to_workflow']) {
119 119
                     require_once('modules/Relationships/Relationship.php');
120 120
                     $key = Relationship::retrieve_by_modules($bean->module_dir, $record->module_dir, $GLOBALS['db']);
121 121
                     if (!empty($key)) {
122
-                        foreach($bean->field_defs as $field=>$def){
123
-                            if($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key){
122
+                        foreach ($bean->field_defs as $field=>$def) {
123
+                            if ($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key) {
124 124
                                 $bean->load_relationship($field);
125 125
                                 $bean->$field->add($record->id);
126 126
                                 break;
@@ -134,23 +134,23 @@  discard block
 block discarded – undo
134 134
         return false;
135 135
     }
136 136
 
137
-    function set_record(SugarBean $record, SugarBean $bean, $params = array(), $in_save = false){
137
+    function set_record(SugarBean $record, SugarBean $bean, $params = array(), $in_save = false) {
138 138
         global $app_list_strings, $timedate;
139 139
 
140 140
         $record_vardefs = $record->getFieldDefinitions();
141 141
 
142
-        if(isset($params['field'])){
143
-            foreach($params['field'] as $key => $field){
142
+        if (isset($params['field'])) {
143
+            foreach ($params['field'] as $key => $field) {
144 144
 
145
-                if($field == '') continue;
145
+                if ($field == '') continue;
146 146
                 $value = '';
147
-                switch($params['value_type'][$key]) {
147
+                switch ($params['value_type'][$key]) {
148 148
                     case 'Field':
149
-                        if($params['value'][$key] == '') continue;
149
+                        if ($params['value'][$key] == '') continue;
150 150
                         $fieldName = $params['value'][$key];
151 151
                         $data = $bean->field_defs[$fieldName];
152 152
 
153
-                        switch($data['type'] ) {
153
+                        switch ($data['type']) {
154 154
                             case 'double':
155 155
                             case 'decimal':
156 156
                             case 'currency':
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                                 $value = format_number($bean->$fieldName);
165 165
                                 break;
166 166
                             case 'relate':
167
-                                if(isset($data['id_name'])) {
167
+                                if (isset($data['id_name'])) {
168 168
                                     $idName = $data['id_name'];
169 169
                                     $value = $bean->$idName;
170 170
                                 }
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
                         break;
177 177
                     case 'Date':
178 178
                         $dformat = 'Y-m-d H:i:s';
179
-                        if($record_vardefs[$field]['type'] == 'date') $dformat = 'Y-m-d';
180
-                        switch($params['value'][$key][3]) {
179
+                        if ($record_vardefs[$field]['type'] == 'date') $dformat = 'Y-m-d';
180
+                        switch ($params['value'][$key][3]) {
181 181
                             case 'business_hours';
182
-                                if(file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')){
182
+                                if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) {
183 183
                                     require_once('modules/AOBH_BusinessHours/AOBH_BusinessHours.php');
184 184
 
185 185
                                     $businessHours = new AOBH_BusinessHours();
@@ -188,33 +188,33 @@  discard block
 block discarded – undo
188 188
                                     $sign = $params['value'][$key][1];
189 189
                                     $amount = $params['value'][$key][2];
190 190
 
191
-                                    if($sign != "plus"){
192
-                                        $amount = 0-$amount;
191
+                                    if ($sign != "plus") {
192
+                                        $amount = 0 - $amount;
193 193
                                     }
194
-                                    if($dateToUse == "now"){
194
+                                    if ($dateToUse == "now") {
195 195
                                         $value = $businessHours->addBusinessHours($amount);
196
-                                    }else if($dateToUse == "field"){
196
+                                    } else if ($dateToUse == "field") {
197 197
                                         $dateToUse = $params['field'][$key];
198 198
                                         $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->$dateToUse));
199
-                                    }else{
199
+                                    } else {
200 200
                                         $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->$dateToUse));
201 201
                                     }
202
-                                    $value = $timedate->asDb( $value );
202
+                                    $value = $timedate->asDb($value);
203 203
                                     break;
204 204
                                 }
205 205
                                 $params['value'][$key][3] = 'hours';
206 206
                             //No business hours module found - fall through.
207 207
                             default:
208
-                                if($params['value'][$key][0] == 'now'){
208
+                                if ($params['value'][$key][0] == 'now') {
209 209
                                     $date = gmdate($dformat);
210
-                                } else if($params['value'][$key][0] == 'field'){
210
+                                } else if ($params['value'][$key][0] == 'field') {
211 211
                                     $date = $record->fetched_row[$params['field'][$key]];
212 212
                                 } else {
213 213
                                     $date = $bean->fetched_row[$params['value'][$key][0]];
214 214
                                 }
215 215
 
216
-                                if($params['value'][$key][1] != 'now'){
217
-                                    $value = date($dformat, strtotime($date . ' '.$app_list_strings['aow_date_operator'][$params['value'][$key][1]].$params['value'][$key][2].' '.$params['value'][$key][3]));
216
+                                if ($params['value'][$key][1] != 'now') {
217
+                                    $value = date($dformat, strtotime($date.' '.$app_list_strings['aow_date_operator'][$params['value'][$key][1]].$params['value'][$key][2].' '.$params['value'][$key][3]));
218 218
                                 } else {
219 219
                                     $value = date($dformat, strtotime($date));
220 220
                                 }
@@ -224,26 +224,26 @@  discard block
 block discarded – undo
224 224
                     Case 'Round_Robin':
225 225
                     Case 'Least_Busy':
226 226
                     Case 'Random':
227
-                        switch($params['value'][$key][0]) {
227
+                        switch ($params['value'][$key][0]) {
228 228
                             Case 'security_group':
229
-                                if(file_exists('modules/SecurityGroups/SecurityGroup.php')){
229
+                                if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
230 230
                                     require_once('modules/SecurityGroups/SecurityGroup.php');
231 231
                                     $security_group = new SecurityGroup();
232 232
                                     $security_group->retrieve($params['value'][$key][1]);
233
-                                    $group_users = $security_group->get_linked_beans( 'users','User');
233
+                                    $group_users = $security_group->get_linked_beans('users', 'User');
234 234
                                     $users = array();
235 235
                                     $r_users = array();
236
-                                    if($params['value'][$key][2] != ''){
236
+                                    if ($params['value'][$key][2] != '') {
237 237
                                         require_once('modules/ACLRoles/ACLRole.php');
238 238
                                         $role = new ACLRole();
239 239
                                         $role->retrieve($params['value'][$key][2]);
240
-                                        $role_users = $role->get_linked_beans( 'users','User');
241
-                                        foreach($role_users as $role_user){
240
+                                        $role_users = $role->get_linked_beans('users', 'User');
241
+                                        foreach ($role_users as $role_user) {
242 242
                                             $r_users[$role_user->id] = $role_user->name;
243 243
                                         }
244 244
                                     }
245
-                                    foreach($group_users as $group_user){
246
-                                        if($params['value'][$key][2] != '' && !isset($r_users[$group_user->id])){
245
+                                    foreach ($group_users as $group_user) {
246
+                                        if ($params['value'][$key][2] != '' && !isset($r_users[$group_user->id])) {
247 247
                                             continue;
248 248
                                         }
249 249
                                         $users[$group_user->id] = $group_user->name;
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
                                 require_once('modules/ACLRoles/ACLRole.php');
256 256
                                 $role = new ACLRole();
257 257
                                 $role->retrieve($params['value'][$key][2]);
258
-                                $role_users = $role->get_linked_beans( 'users','User');
258
+                                $role_users = $role->get_linked_beans('users', 'User');
259 259
                                 $users = array();
260
-                                foreach($role_users as $role_user){
260
+                                foreach ($role_users as $role_user) {
261 261
                                     $users[$role_user->id] = $role_user->name;
262 262
                                 }
263 263
                                 break;
@@ -270,18 +270,18 @@  discard block
 block discarded – undo
270 270
                         // format the users array
271 271
                         $users = array_values(array_flip($users));
272 272
 
273
-                        if(empty($users)){
273
+                        if (empty($users)) {
274 274
                             $value = '';
275
-                        }else if (sizeof($users) == 1) {
275
+                        } else if (sizeof($users) == 1) {
276 276
                             $value = $users[0];
277 277
                         } else {
278
-                            switch($params['value_type'][$key]) {
278
+                            switch ($params['value_type'][$key]) {
279 279
                                 Case 'Round_Robin':
280 280
                                     $value = getRoundRobinUser($users, $this->id);
281 281
                                     break;
282 282
                                 Case 'Least_Busy':
283 283
                                     $user_id = 'assigned_user_id';
284
-                                    if(isset($record_vardefs[$field]['id_name']) && $record_vardefs[$field]['id_name'] != ''){
284
+                                    if (isset($record_vardefs[$field]['id_name']) && $record_vardefs[$field]['id_name'] != '') {
285 285
                                         $user_id = $record_vardefs[$field]['id_name'];
286 286
                                     }
287 287
                                     $value = getLeastBusyUser($users, $user_id, $record);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                         break;
303 303
                 }
304 304
 
305
-                if($record_vardefs[$field]['type'] == 'relate' && isset($record_vardefs[$field]['id_name'])) {
305
+                if ($record_vardefs[$field]['type'] == 'relate' && isset($record_vardefs[$field]['id_name'])) {
306 306
                     $field = $record_vardefs[$field]['id_name'];
307 307
                 }
308 308
                 $record->$field = $value;
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 
312 312
         $bean_processed = isset($record->processed) ? $record->processed : false;
313 313
 
314
-        if($in_save){
314
+        if ($in_save) {
315 315
             global $current_user;
316 316
             $record->processed = true;
317 317
             $check_notify = $record->assigned_user_id != $current_user->id && $record->assigned_user_id != $record->fetched_row['assigned_user_id'];
318 318
         }
319 319
         else $check_notify = $record->assigned_user_id != $record->fetched_row['assigned_user_id'];
320 320
 
321
-        $record->process_save_dates =false;
321
+        $record->process_save_dates = false;
322 322
         $record->new_with_id = false;
323 323
 
324 324
         $record->save($check_notify);
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
         $record->processed = $bean_processed;
327 327
     }
328 328
 
329
-    function set_relationships(SugarBean $record, SugarBean $bean, $params = array()){
329
+    function set_relationships(SugarBean $record, SugarBean $bean, $params = array()) {
330 330
 
331 331
         $record_vardefs = $record->getFieldDefinitions();
332 332
 
333 333
         require_once('modules/Relationships/Relationship.php');
334
-        if(isset($params['rel'])){
335
-            foreach($params['rel'] as $key => $field){
336
-                if($field == '' || $params['rel_value'][$key] == '') continue;
334
+        if (isset($params['rel'])) {
335
+            foreach ($params['rel'] as $key => $field) {
336
+                if ($field == '' || $params['rel_value'][$key] == '') continue;
337 337
 
338 338
                 $relField = $params['rel_value'][$key];
339 339
 
340
-                switch($params['rel_value_type'][$key]) {
340
+                switch ($params['rel_value_type'][$key]) {
341 341
                     case 'Field':
342 342
 
343 343
                         $data = $bean->field_defs[$relField];
344 344
 
345
-                        if($data['type'] == 'relate' && isset($data['id_name'])) {
345
+                        if ($data['type'] == 'relate' && isset($data['id_name'])) {
346 346
                             $relField = $data['id_name'];
347 347
                         }
348 348
                         $rel_id = $bean->$relField;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
                 }
354 354
 
355 355
                 $def = $record_vardefs[$field];
356
-                if($def['type'] == 'link' && !empty($def['relationship'])){
356
+                if ($def['type'] == 'link' && !empty($def['relationship'])) {
357 357
                     $record->load_relationship($field);
358 358
                     $record->$field->add($rel_id);
359 359
                 }
Please login to merge, or discard this patch.
Braces   +27 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
38 38
         if(isset($GLOBALS['log'])) {
39 39
             $GLOBALS['log']->deprecated($deprecatedMessage);
40
-        }
41
-        else {
40
+        } else {
42 41
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
43 42
         }
44 43
         self::__construct($id);
@@ -56,7 +55,9 @@  discard block
 block discarded – undo
56 55
         $modules = $app_list_strings['aow_moduleList'];
57 56
 
58 57
         $checked = 'CHECKED';
59
-        if(isset($params['relate_to_workflow']) && !$params['relate_to_workflow']) $checked = '';
58
+        if(isset($params['relate_to_workflow']) && !$params['relate_to_workflow']) {
59
+            $checked = '';
60
+        }
60 61
 
61 62
         $html = "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
62 63
         $html .= "<tr>";
@@ -88,14 +89,18 @@  discard block
 block discarded – undo
88 89
             $html .= "cr_module[".$line."] = \"".$params['record_type']."\";";
89 90
             if(isset($params['field'])){
90 91
                 foreach($params['field'] as $key => $field){
91
-                    if(is_array($params['value'][$key]))$params['value'][$key] = json_encode($params['value'][$key]);
92
+                    if(is_array($params['value'][$key])) {
93
+                        $params['value'][$key] = json_encode($params['value'][$key]);
94
+                    }
92 95
 
93 96
                     $html .= "load_crline('".$line."','".$field."','".str_replace(array("\r\n","\r","\n")," ",$params['value'][$key])."','".$params['value_type'][$key]."');";
94 97
                 }
95 98
             }
96 99
             if(isset($params['rel'])){
97 100
                 foreach($params['rel'] as $key => $field){
98
-                    if(is_array($params['rel_value'][$key]))$params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
101
+                    if(is_array($params['rel_value'][$key])) {
102
+                        $params['rel_value'][$key] = json_encode($params['rel_value'][$key]);
103
+                    }
99 104
 
100 105
                     $html .= "load_crrelline('".$line."','".$field."','".$params['rel_value'][$key]."','".$params['rel_value_type'][$key]."');";
101 106
                 }
@@ -142,11 +147,15 @@  discard block
 block discarded – undo
142 147
         if(isset($params['field'])){
143 148
             foreach($params['field'] as $key => $field){
144 149
 
145
-                if($field == '') continue;
150
+                if($field == '') {
151
+                    continue;
152
+                }
146 153
                 $value = '';
147 154
                 switch($params['value_type'][$key]) {
148 155
                     case 'Field':
149
-                        if($params['value'][$key] == '') continue;
156
+                        if($params['value'][$key] == '') {
157
+                            continue;
158
+                        }
150 159
                         $fieldName = $params['value'][$key];
151 160
                         $data = $bean->field_defs[$fieldName];
152 161
 
@@ -176,7 +185,9 @@  discard block
 block discarded – undo
176 185
                         break;
177 186
                     case 'Date':
178 187
                         $dformat = 'Y-m-d H:i:s';
179
-                        if($record_vardefs[$field]['type'] == 'date') $dformat = 'Y-m-d';
188
+                        if($record_vardefs[$field]['type'] == 'date') {
189
+                            $dformat = 'Y-m-d';
190
+                        }
180 191
                         switch($params['value'][$key][3]) {
181 192
                             case 'business_hours';
182 193
                                 if(file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')){
@@ -193,10 +204,10 @@  discard block
 block discarded – undo
193 204
                                     }
194 205
                                     if($dateToUse == "now"){
195 206
                                         $value = $businessHours->addBusinessHours($amount);
196
-                                    }else if($dateToUse == "field"){
207
+                                    } else if($dateToUse == "field"){
197 208
                                         $dateToUse = $params['field'][$key];
198 209
                                         $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->$dateToUse));
199
-                                    }else{
210
+                                    } else{
200 211
                                         $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->$dateToUse));
201 212
                                     }
202 213
                                     $value = $timedate->asDb( $value );
@@ -272,7 +283,7 @@  discard block
 block discarded – undo
272 283
 
273 284
                         if(empty($users)){
274 285
                             $value = '';
275
-                        }else if (sizeof($users) == 1) {
286
+                        } else if (sizeof($users) == 1) {
276 287
                             $value = $users[0];
277 288
                         } else {
278 289
                             switch($params['value_type'][$key]) {
@@ -315,8 +326,9 @@  discard block
 block discarded – undo
315 326
             global $current_user;
316 327
             $record->processed = true;
317 328
             $check_notify = $record->assigned_user_id != $current_user->id && $record->assigned_user_id != $record->fetched_row['assigned_user_id'];
329
+        } else {
330
+            $check_notify = $record->assigned_user_id != $record->fetched_row['assigned_user_id'];
318 331
         }
319
-        else $check_notify = $record->assigned_user_id != $record->fetched_row['assigned_user_id'];
320 332
 
321 333
         $record->process_save_dates =false;
322 334
         $record->new_with_id = false;
@@ -333,7 +345,9 @@  discard block
 block discarded – undo
333 345
         require_once('modules/Relationships/Relationship.php');
334 346
         if(isset($params['rel'])){
335 347
             foreach($params['rel'] as $key => $field){
336
-                if($field == '' || $params['rel_value'][$key] == '') continue;
348
+                if($field == '' || $params['rel_value'][$key] == '') {
349
+                    continue;
350
+                }
337 351
 
338 352
                 $relField = $params['rel_value'][$key];
339 353
 
Please login to merge, or discard this patch.
modules/AOW_Actions/actions/actionBase.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 
28 28
     var $id;
29 29
 
30
-    function __construct($id = ''){
30
+    function __construct($id = '') {
31 31
         $this->id = $id;
32 32
     }
33 33
 
34 34
     /**
35 35
      * @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
36 36
      */
37
-    function actionBase($id = ''){
37
+    function actionBase($id = '') {
38 38
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
39
-        if(isset($GLOBALS['log'])) {
39
+        if (isset($GLOBALS['log'])) {
40 40
             $GLOBALS['log']->deprecated($deprecatedMessage);
41 41
         }
42 42
         else {
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
 
49
-    function loadJS(){
49
+    function loadJS() {
50 50
 
51 51
         return array();
52 52
     }
53 53
 
54
-    function edit_display($line,SugarBean $bean = null, $params = array()){
54
+    function edit_display($line, SugarBean $bean = null, $params = array()) {
55 55
 
56 56
         return '';
57 57
 
58 58
     }
59 59
 
60
-    function run_action(SugarBean $bean, $params = array(), $in_save=false){
60
+    function run_action(SugarBean $bean, $params = array(), $in_save = false) {
61 61
 
62 62
         return true;
63 63
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/AOW_Actions/AOW_Action.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
     /**
74 74
      * @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
75 75
      */
76
-    function AOW_Action(){
76
+    function AOW_Action() {
77 77
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
78
-        if(isset($GLOBALS['log'])) {
78
+        if (isset($GLOBALS['log'])) {
79 79
             $GLOBALS['log']->deprecated($deprecatedMessage);
80 80
         }
81 81
         else {
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
     function save_lines($post_data, $parent, $key = '')
89 89
     {
90 90
 
91
-        $line_count = count($post_data[$key . 'action']);
91
+        $line_count = count($post_data[$key.'action']);
92 92
         $j = 0;
93 93
         for ($i = 0; $i < $line_count; ++$i) {
94 94
 
95
-            if ($post_data[$key . 'deleted'][$i] == 1) {
96
-                $this->mark_deleted($post_data[$key . 'id'][$i]);
95
+            if ($post_data[$key.'deleted'][$i] == 1) {
96
+                $this->mark_deleted($post_data[$key.'id'][$i]);
97 97
             } else {
98 98
                 $action = new AOW_Action();
99 99
                 foreach ($this->field_defs as $field_def) {
100 100
                     $field_name = $field_def['name'];
101
-                    if (isset($post_data[$key . $field_name][$i])) {
102
-                        $action->$field_name = $post_data[$key . $field_name][$i];
101
+                    if (isset($post_data[$key.$field_name][$i])) {
102
+                        $action->$field_name = $post_data[$key.$field_name][$i];
103 103
                     }
104 104
                 }
105 105
                 $params = array();
106
-                foreach ($post_data[$key . 'param'][$i] as $param_name => $param_value) {
106
+                foreach ($post_data[$key.'param'][$i] as $param_name => $param_value) {
107 107
                     if ($param_name == 'value') {
108 108
                         foreach ($param_value as $p_id => $p_value) {
109
-                            if ($post_data[$key . 'param'][$i]['value_type'][$p_id] == 'Value' && is_array($p_value)) $param_value[$p_id] = encodeMultienumValue($p_value);
109
+                            if ($post_data[$key.'param'][$i]['value_type'][$p_id] == 'Value' && is_array($p_value)) $param_value[$p_id] = encodeMultienumValue($p_value);
110 110
                         }
111 111
                     }
112 112
                     $params[$param_name] = $param_value;
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,8 +77,7 @@  discard block
 block discarded – undo
77 77
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
78 78
         if(isset($GLOBALS['log'])) {
79 79
             $GLOBALS['log']->deprecated($deprecatedMessage);
80
-        }
81
-        else {
80
+        } else {
82 81
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
83 82
         }
84 83
         self::__construct();
@@ -106,7 +105,9 @@  discard block
 block discarded – undo
106 105
                 foreach ($post_data[$key . 'param'][$i] as $param_name => $param_value) {
107 106
                     if ($param_name == 'value') {
108 107
                         foreach ($param_value as $p_id => $p_value) {
109
-                            if ($post_data[$key . 'param'][$i]['value_type'][$p_id] == 'Value' && is_array($p_value)) $param_value[$p_id] = encodeMultienumValue($p_value);
108
+                            if ($post_data[$key . 'param'][$i]['value_type'][$p_id] == 'Value' && is_array($p_value)) {
109
+                                $param_value[$p_id] = encodeMultienumValue($p_value);
110
+                            }
110 111
                         }
111 112
                     }
112 113
                     $params[$param_name] = $param_value;
Please login to merge, or discard this patch.
modules/Configurator/Configurator.php 3 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
 
44 44
 
45 45
 class Configurator {
46
-	var $config = '';
47
-	var $override = '';
48
-	var $allow_undefined = array ('stack_trace_errors', 'export_delimiter', 'use_real_names', 'developerMode', 'default_module_favicon', 'authenticationClass', 'SAML_loginurl', 'SAML_X509Cert', 'dashlet_auto_refresh_min', 'show_download_tab', 'enable_action_menu','enable_line_editing_list','enable_line_editing_detail');
49
-	var $errors = array ('main' => '');
50
-	var $logger = NULL;
51
-	var $previous_sugar_override_config_array = array();
52
-	var $useAuthenticationClass = false;
46
+    var $config = '';
47
+    var $override = '';
48
+    var $allow_undefined = array ('stack_trace_errors', 'export_delimiter', 'use_real_names', 'developerMode', 'default_module_favicon', 'authenticationClass', 'SAML_loginurl', 'SAML_X509Cert', 'dashlet_auto_refresh_min', 'show_download_tab', 'enable_action_menu','enable_line_editing_list','enable_line_editing_detail');
49
+    var $errors = array ('main' => '');
50
+    var $logger = NULL;
51
+    var $previous_sugar_override_config_array = array();
52
+    var $useAuthenticationClass = false;
53 53
     protected $error = null;
54 54
 
55
-	function __construct() {
56
-		$this->loadConfig();
57
-	}
55
+    function __construct() {
56
+        $this->loadConfig();
57
+    }
58 58
 
59 59
     /**
60 60
      * @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
@@ -71,62 +71,62 @@  discard block
 block discarded – undo
71 71
     }
72 72
 
73 73
 
74
-	function loadConfig() {
75
-		$this->logger = LoggerManager::getLogger();
76
-		global $sugar_config;
77
-		$this->config = $sugar_config;
78
-	}
79
-
80
-	function populateFromPost() {
81
-		$sugarConfig = SugarConfig::getInstance();
82
-		foreach ($_POST as $key => $value) {
83
-			if ($key == "logger_file_ext") {
84
-			    $trim_value = preg_replace('/.*\.([^\.]+)$/', '\1', $value);
85
-			    if(in_array($trim_value, $this->config['upload_badext'])) {
86
-			        $GLOBALS['log']->security("Invalid log file extension: trying to use invalid file extension '$value'.");
87
-			        continue;
88
-			    }
89
-			}
90
-			if (isset ($this->config[$key]) || in_array($key, $this->allow_undefined)) {
91
-				if (strcmp("$value", 'true') == 0) {
92
-					$value = true;
93
-				}
94
-				if (strcmp("$value", 'false') == 0) {
95
-					$value = false;
96
-				}
74
+    function loadConfig() {
75
+        $this->logger = LoggerManager::getLogger();
76
+        global $sugar_config;
77
+        $this->config = $sugar_config;
78
+    }
79
+
80
+    function populateFromPost() {
81
+        $sugarConfig = SugarConfig::getInstance();
82
+        foreach ($_POST as $key => $value) {
83
+            if ($key == "logger_file_ext") {
84
+                $trim_value = preg_replace('/.*\.([^\.]+)$/', '\1', $value);
85
+                if(in_array($trim_value, $this->config['upload_badext'])) {
86
+                    $GLOBALS['log']->security("Invalid log file extension: trying to use invalid file extension '$value'.");
87
+                    continue;
88
+                }
89
+            }
90
+            if (isset ($this->config[$key]) || in_array($key, $this->allow_undefined)) {
91
+                if (strcmp("$value", 'true') == 0) {
92
+                    $value = true;
93
+                }
94
+                if (strcmp("$value", 'false') == 0) {
95
+                    $value = false;
96
+                }
97 97
                 $this->config[$key] = $value;
98
-			} else {
98
+            } else {
99 99
                 $v = $sugarConfig->get(str_replace('_', '.', $key));
100 100
             if ($v  !== null){
101
-			   setDeepArrayValue($this->config, $key, $value);
102
-			}}
101
+                setDeepArrayValue($this->config, $key, $value);
102
+            }}
103 103
 
104
-		}
105
-
106
-	}
104
+        }
107 105
 
108
-	function handleOverride($fromParseLoggerSettings=false) {
109
-		global $sugar_config, $sugar_version;
110
-		$sc = SugarConfig::getInstance();
111
-		$overrideArray = $this->readOverride();
112
-		$this->previous_sugar_override_config_array = $overrideArray;
113
-		$diffArray = deepArrayDiff($this->config, $sugar_config);
114
-		$overrideArray = sugarArrayMergeRecursive($overrideArray, $diffArray);
106
+    }
115 107
 
116
-		// To remember checkbox state
117
-      if (!$this->useAuthenticationClass && !$fromParseLoggerSettings) {
118
-         if (isset($overrideArray['authenticationClass']) &&
108
+    function handleOverride($fromParseLoggerSettings=false) {
109
+        global $sugar_config, $sugar_version;
110
+        $sc = SugarConfig::getInstance();
111
+        $overrideArray = $this->readOverride();
112
+        $this->previous_sugar_override_config_array = $overrideArray;
113
+        $diffArray = deepArrayDiff($this->config, $sugar_config);
114
+        $overrideArray = sugarArrayMergeRecursive($overrideArray, $diffArray);
115
+
116
+        // To remember checkbox state
117
+        if (!$this->useAuthenticationClass && !$fromParseLoggerSettings) {
118
+            if (isset($overrideArray['authenticationClass']) &&
119 119
             $overrideArray['authenticationClass'] == 'SAMLAuthenticate') {
120
-      	  unset($overrideArray['authenticationClass']);
121
-      	}
122
-      }
120
+            unset($overrideArray['authenticationClass']);
121
+            }
122
+        }
123 123
 
124
-		$overideString = "<?php\n/***CONFIGURATOR***/\n";
124
+        $overideString = "<?php\n/***CONFIGURATOR***/\n";
125 125
 
126
-		sugar_cache_put('sugar_config', $this->config);
127
-		$GLOBALS['sugar_config'] = $this->config;
126
+        sugar_cache_put('sugar_config', $this->config);
127
+        $GLOBALS['sugar_config'] = $this->config;
128 128
 
129
-		//print_r($overrideArray);
129
+        //print_r($overrideArray);
130 130
         //Bug#53013: Clean the tpl cache if action menu style has been changed.
131 131
         if( isset($overrideArray['enable_action_menu']) &&
132 132
                 ( !isset($this->previous_sugar_override_config_array['enable_action_menu']) ||
@@ -138,123 +138,123 @@  discard block
 block discarded – undo
138 138
             $repair->clearTpls();
139 139
         }
140 140
 
141
-		foreach($overrideArray as $key => $val) {
142
-			if (in_array($key, $this->allow_undefined) || isset ($sugar_config[$key])) {
143
-				if (is_string($val) && strcmp($val, 'true') == 0) {
144
-					$val = true;
145
-					$this->config[$key] = $val;
146
-				}
147
-				if (is_string($val) && strcmp($val, 'false') == 0) {
148
-					$val = false;
149
-					$this->config[$key] = false;
150
-				}
151
-			}
152
-			$overideString .= override_value_to_string_recursive2('sugar_config', $key, $val);
153
-		}
154
-		$overideString .= '/***CONFIGURATOR***/';
155
-
156
-		$this->saveOverride($overideString);
157
-		if(isset($this->config['logger']['level']) && $this->logger) $this->logger->setLevel($this->config['logger']['level']);
158
-	}
159
-
160
-	//bug #27947 , if previous $sugar_config['stack_trace_errors'] is true and now we disable it , we should clear all the cache.
161
-	function clearCache(){
162
-		global $sugar_config, $sugar_version;
163
-		$currentConfigArray = $this->readOverride();
164
-		foreach($currentConfigArray as $key => $val) {
165
-			if (in_array($key, $this->allow_undefined) || isset ($sugar_config[$key])) {
166
-				if (empty($val) ) {
167
-					if(!empty($this->previous_sugar_override_config_array['stack_trace_errors']) && $key == 'stack_trace_errors'){
168
-						require_once('include/TemplateHandler/TemplateHandler.php');
169
-						TemplateHandler::clearAll();
170
-						return;
171
-					}
172
-				}
173
-			}
174
-		}
175
-	}
176
-
177
-	function saveConfig() {
141
+        foreach($overrideArray as $key => $val) {
142
+            if (in_array($key, $this->allow_undefined) || isset ($sugar_config[$key])) {
143
+                if (is_string($val) && strcmp($val, 'true') == 0) {
144
+                    $val = true;
145
+                    $this->config[$key] = $val;
146
+                }
147
+                if (is_string($val) && strcmp($val, 'false') == 0) {
148
+                    $val = false;
149
+                    $this->config[$key] = false;
150
+                }
151
+            }
152
+            $overideString .= override_value_to_string_recursive2('sugar_config', $key, $val);
153
+        }
154
+        $overideString .= '/***CONFIGURATOR***/';
155
+
156
+        $this->saveOverride($overideString);
157
+        if(isset($this->config['logger']['level']) && $this->logger) $this->logger->setLevel($this->config['logger']['level']);
158
+    }
159
+
160
+    //bug #27947 , if previous $sugar_config['stack_trace_errors'] is true and now we disable it , we should clear all the cache.
161
+    function clearCache(){
162
+        global $sugar_config, $sugar_version;
163
+        $currentConfigArray = $this->readOverride();
164
+        foreach($currentConfigArray as $key => $val) {
165
+            if (in_array($key, $this->allow_undefined) || isset ($sugar_config[$key])) {
166
+                if (empty($val) ) {
167
+                    if(!empty($this->previous_sugar_override_config_array['stack_trace_errors']) && $key == 'stack_trace_errors'){
168
+                        require_once('include/TemplateHandler/TemplateHandler.php');
169
+                        TemplateHandler::clearAll();
170
+                        return;
171
+                    }
172
+                }
173
+            }
174
+        }
175
+    }
176
+
177
+    function saveConfig() {
178 178
         if($this->saveImages() === false)
179 179
         {
180 180
             return false;
181 181
         }
182 182
 
183
-		$this->populateFromPost();
184
-		$this->handleOverride();
185
-		$this->clearCache();
186
-	}
187
-
188
-	function readOverride() {
189
-		$sugar_config = array();
190
-		if (file_exists('config_override.php')) {
191
-		    if ( !is_readable('config_override.php') ) {
192
-		        $GLOBALS['log']->fatal("Unable to read the config_override.php file. Check the file permissions");
193
-		    }
194
-	        else {
195
-	            include('config_override.php');
196
-	        }
197
-		}
198
-		return $sugar_config;
199
-	}
200
-	function saveOverride($override) {
183
+        $this->populateFromPost();
184
+        $this->handleOverride();
185
+        $this->clearCache();
186
+    }
187
+
188
+    function readOverride() {
189
+        $sugar_config = array();
190
+        if (file_exists('config_override.php')) {
191
+            if ( !is_readable('config_override.php') ) {
192
+                $GLOBALS['log']->fatal("Unable to read the config_override.php file. Check the file permissions");
193
+            }
194
+            else {
195
+                include('config_override.php');
196
+            }
197
+        }
198
+        return $sugar_config;
199
+    }
200
+    function saveOverride($override) {
201 201
         require_once('install/install_utils.php');
202
-	    if ( !file_exists('config_override.php') ) {
203
-	    	touch('config_override.php');
204
-	    }
205
-	    if ( !(make_writable('config_override.php')) ||  !(is_writable('config_override.php')) ) {
206
-	        $GLOBALS['log']->fatal("Unable to write to the config_override.php file. Check the file permissions");
207
-	        return;
208
-	    }
209
-		$fp = sugar_fopen('config_override.php', 'w');
210
-		fwrite($fp, $override);
211
-		fclose($fp);
212
-	}
213
-
214
-	function overrideClearDuplicates($array_name, $key) {
215
-		if (!empty ($this->override)) {
216
-			$pattern = '/.*CONFIGURATOR[^\$]*\$'.$array_name.'\[\''.$key.'\'\][\ ]*=[\ ]*[^;]*;\n/';
217
-			$this->override = preg_replace($pattern, '', $this->override);
218
-		} else {
219
-			$this->override = "<?php\n\n?>";
220
-		}
221
-
222
-	}
223
-
224
-	function replaceOverride($array_name, $key, $value) {
225
-		$GLOBALS[$array_name][$key] = $value;
226
-		$this->overrideClearDuplicates($array_name, $key);
227
-		$new_entry = '/***CONFIGURATOR***/'.override_value_to_string($array_name, $key, $value);
228
-		$this->override = str_replace('?>', "$new_entry\n?>", $this->override);
229
-	}
230
-
231
-	function restoreConfig() {
232
-		$this->readOverride();
233
-		$this->overrideClearDuplicates('sugar_config', '[a-zA-Z0-9\_]+');
234
-		$this->saveOverride();
235
-		ob_clean();
236
-		header('Location: index.php?action=EditView&module=Configurator');
237
-	}
238
-
239
-	function saveImages() {
240
-		if (!empty ($_POST['company_logo'])) {
202
+        if ( !file_exists('config_override.php') ) {
203
+            touch('config_override.php');
204
+        }
205
+        if ( !(make_writable('config_override.php')) ||  !(is_writable('config_override.php')) ) {
206
+            $GLOBALS['log']->fatal("Unable to write to the config_override.php file. Check the file permissions");
207
+            return;
208
+        }
209
+        $fp = sugar_fopen('config_override.php', 'w');
210
+        fwrite($fp, $override);
211
+        fclose($fp);
212
+    }
213
+
214
+    function overrideClearDuplicates($array_name, $key) {
215
+        if (!empty ($this->override)) {
216
+            $pattern = '/.*CONFIGURATOR[^\$]*\$'.$array_name.'\[\''.$key.'\'\][\ ]*=[\ ]*[^;]*;\n/';
217
+            $this->override = preg_replace($pattern, '', $this->override);
218
+        } else {
219
+            $this->override = "<?php\n\n?>";
220
+        }
221
+
222
+    }
223
+
224
+    function replaceOverride($array_name, $key, $value) {
225
+        $GLOBALS[$array_name][$key] = $value;
226
+        $this->overrideClearDuplicates($array_name, $key);
227
+        $new_entry = '/***CONFIGURATOR***/'.override_value_to_string($array_name, $key, $value);
228
+        $this->override = str_replace('?>', "$new_entry\n?>", $this->override);
229
+    }
230
+
231
+    function restoreConfig() {
232
+        $this->readOverride();
233
+        $this->overrideClearDuplicates('sugar_config', '[a-zA-Z0-9\_]+');
234
+        $this->saveOverride();
235
+        ob_clean();
236
+        header('Location: index.php?action=EditView&module=Configurator');
237
+    }
238
+
239
+    function saveImages() {
240
+        if (!empty ($_POST['company_logo'])) {
241 241
             if($this->saveCompanyLogo("upload://".$_POST['company_logo']) === false)
242 242
             {
243 243
                 return false;
244 244
             }
245
-		}
246
-	}
245
+        }
246
+    }
247 247
 
248
-	function checkTempImage($path)
249
-	{
248
+    function checkTempImage($path)
249
+    {
250 250
         if(!verify_uploaded_image($path)) {
251 251
             $error = translate('LBL_ALERT_TYPE_IMAGE');
252
-        	$GLOBALS['log']->fatal("A user ({$GLOBALS['current_user']->id}) attempted to use an invalid file for the logo - {$path}");
252
+            $GLOBALS['log']->fatal("A user ({$GLOBALS['current_user']->id}) attempted to use an invalid file for the logo - {$path}");
253 253
             $this->error = $error;
254 254
             return false;
255
-		}
256
-		return $path;
257
-	}
255
+        }
256
+        return $path;
257
+    }
258 258
 
259 259
     public function getError()
260 260
     {
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
      *
268 268
      * @param string $path path to the image to set as the company logo image
269 269
      */
270
-	function saveCompanyLogo($path)
270
+    function saveCompanyLogo($path)
271 271
     {
272
-    	$path = $this->checkTempImage($path);
272
+        $path = $this->checkTempImage($path);
273 273
         if($path === false)
274 274
         {
275 275
             return false;
@@ -279,73 +279,73 @@  discard block
 block discarded – undo
279 279
         copy($path,'custom/'. SugarThemeRegistry::current()->getDefaultImagePath(). '/company_logo.png');
280 280
         sugar_cache_clear('company_logo_attributes');
281 281
         SugarThemeRegistry::clearAllCaches();
282
-	}
283
-	/**
284
-	 * @params : none
285
-	 * @return : An array of logger configuration properties including log size, file extensions etc. See SugarLogger for more details.
286
-	 * Parses the old logger settings from the log4php.properties files.
287
-	 *
288
-	 */
289
-
290
-	function parseLoggerSettings(){
291
-		if(!function_exists('setDeepArrayValue')){
292
-			require('include/utils/array_utils.php');
293
-		}
294
-		if (file_exists('log4php.properties')) {
295
-			$fileContent = file_get_contents('log4php.properties');
296
-			$old_props = explode('\n', $fileContent);
297
-			$new_props = array();
298
-			$key_names=array();
299
-			foreach($old_props as $value) {
300
-				if(!empty($value) && !preg_match("/^\/\//", $value)) {
301
-					$temp = explode("=",$value);
302
-					$property = isset( $temp[1])? $temp[1] : array();
303
-					if(preg_match("/log4php.appender.A2.MaxFileSize=/",$value)){
304
-						setDeepArrayValue($this->config, 'logger_file_maxSize', rtrim( $property));
305
-					}
306
-					elseif(preg_match("/log4php.appender.A2.File=/", $value)){
307
-						$ext = preg_split("/\./",$property);
308
-						if(preg_match( "/^\./", $property)){ //begins with .
309
-							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[2]) ? '.' . rtrim( $ext[2]):'.log');
310
-							setDeepArrayValue($this->config, 'logger_file_name', rtrim( ".".$ext[1]));
311
-						}else{
312
-							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[1]) ? '.' . rtrim( $ext[1]):'.log');
313
-							setDeepArrayValue($this->config, 'logger_file_name', rtrim( $ext[0] ));
314
-						}
315
-					}elseif(preg_match("/log4php.appender.A2.layout.DateFormat=/",$value)){
316
-						setDeepArrayValue($this->config, 'logger_file_dateFormat', trim(rtrim( $property), '""'));
317
-
318
-					}elseif(preg_match("/log4php.rootLogger=/",$value)){
319
-						$property = explode(",",$property);
320
-						setDeepArrayValue($this->config, 'logger_level', rtrim( $property[0]));
321
-					}
322
-				}
323
-			}
324
-			setDeepArrayValue($this->config, 'logger_file_maxLogs', 10);
325
-			setDeepArrayValue($this->config, 'logger_file_suffix', "%m_%Y");
326
-			$this->handleOverride();
327
-			unlink('log4php.properties');
328
-			$GLOBALS['sugar_config'] = $this->config; //load the rest of the sugar_config settings.
329
-			require_once('include/SugarLogger/SugarLogger.php');
330
-			//$logger = new SugarLogger(); //this will create the log file.
331
-
332
-		}
333
-
334
-		if (!isset($this->config['logger']) || empty($this->config['logger'])) {
335
-			$this->config['logger'] = array (
336
-			'file' => array(
337
-				'ext' => '.log',
338
-				'name' => 'sugarcrm',
339
-				'dateFormat' => '%c',
340
-				'maxSize' => '10MB',
341
-				'maxLogs' => 10,
342
-				'suffix' => ''), // bug51583, change default suffix to blank for backwards comptability
343
-			'level' => 'fatal');
344
-		}
345
-		$this->handleOverride(true);
346
-
347
-
348
-	}
282
+    }
283
+    /**
284
+     * @params : none
285
+     * @return : An array of logger configuration properties including log size, file extensions etc. See SugarLogger for more details.
286
+     * Parses the old logger settings from the log4php.properties files.
287
+     *
288
+     */
289
+
290
+    function parseLoggerSettings(){
291
+        if(!function_exists('setDeepArrayValue')){
292
+            require('include/utils/array_utils.php');
293
+        }
294
+        if (file_exists('log4php.properties')) {
295
+            $fileContent = file_get_contents('log4php.properties');
296
+            $old_props = explode('\n', $fileContent);
297
+            $new_props = array();
298
+            $key_names=array();
299
+            foreach($old_props as $value) {
300
+                if(!empty($value) && !preg_match("/^\/\//", $value)) {
301
+                    $temp = explode("=",$value);
302
+                    $property = isset( $temp[1])? $temp[1] : array();
303
+                    if(preg_match("/log4php.appender.A2.MaxFileSize=/",$value)){
304
+                        setDeepArrayValue($this->config, 'logger_file_maxSize', rtrim( $property));
305
+                    }
306
+                    elseif(preg_match("/log4php.appender.A2.File=/", $value)){
307
+                        $ext = preg_split("/\./",$property);
308
+                        if(preg_match( "/^\./", $property)){ //begins with .
309
+                            setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[2]) ? '.' . rtrim( $ext[2]):'.log');
310
+                            setDeepArrayValue($this->config, 'logger_file_name', rtrim( ".".$ext[1]));
311
+                        }else{
312
+                            setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[1]) ? '.' . rtrim( $ext[1]):'.log');
313
+                            setDeepArrayValue($this->config, 'logger_file_name', rtrim( $ext[0] ));
314
+                        }
315
+                    }elseif(preg_match("/log4php.appender.A2.layout.DateFormat=/",$value)){
316
+                        setDeepArrayValue($this->config, 'logger_file_dateFormat', trim(rtrim( $property), '""'));
317
+
318
+                    }elseif(preg_match("/log4php.rootLogger=/",$value)){
319
+                        $property = explode(",",$property);
320
+                        setDeepArrayValue($this->config, 'logger_level', rtrim( $property[0]));
321
+                    }
322
+                }
323
+            }
324
+            setDeepArrayValue($this->config, 'logger_file_maxLogs', 10);
325
+            setDeepArrayValue($this->config, 'logger_file_suffix', "%m_%Y");
326
+            $this->handleOverride();
327
+            unlink('log4php.properties');
328
+            $GLOBALS['sugar_config'] = $this->config; //load the rest of the sugar_config settings.
329
+            require_once('include/SugarLogger/SugarLogger.php');
330
+            //$logger = new SugarLogger(); //this will create the log file.
331
+
332
+        }
333
+
334
+        if (!isset($this->config['logger']) || empty($this->config['logger'])) {
335
+            $this->config['logger'] = array (
336
+            'file' => array(
337
+                'ext' => '.log',
338
+                'name' => 'sugarcrm',
339
+                'dateFormat' => '%c',
340
+                'maxSize' => '10MB',
341
+                'maxLogs' => 10,
342
+                'suffix' => ''), // bug51583, change default suffix to blank for backwards comptability
343
+            'level' => 'fatal');
344
+        }
345
+        $this->handleOverride(true);
346
+
347
+
348
+    }
349 349
 
350 350
 
351 351
 
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 class Configurator {
46 46
 	var $config = '';
47 47
 	var $override = '';
48
-	var $allow_undefined = array ('stack_trace_errors', 'export_delimiter', 'use_real_names', 'developerMode', 'default_module_favicon', 'authenticationClass', 'SAML_loginurl', 'SAML_X509Cert', 'dashlet_auto_refresh_min', 'show_download_tab', 'enable_action_menu','enable_line_editing_list','enable_line_editing_detail');
49
-	var $errors = array ('main' => '');
48
+	var $allow_undefined = array('stack_trace_errors', 'export_delimiter', 'use_real_names', 'developerMode', 'default_module_favicon', 'authenticationClass', 'SAML_loginurl', 'SAML_X509Cert', 'dashlet_auto_refresh_min', 'show_download_tab', 'enable_action_menu', 'enable_line_editing_list', 'enable_line_editing_detail');
49
+	var $errors = array('main' => '');
50 50
 	var $logger = NULL;
51 51
 	var $previous_sugar_override_config_array = array();
52 52
 	var $useAuthenticationClass = false;
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
     /**
60 60
      * @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
61 61
      */
62
-    function Configurator(){
62
+    function Configurator() {
63 63
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
64
-        if(isset($GLOBALS['log'])) {
64
+        if (isset($GLOBALS['log'])) {
65 65
             $GLOBALS['log']->deprecated($deprecatedMessage);
66 66
         }
67 67
         else {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		foreach ($_POST as $key => $value) {
83 83
 			if ($key == "logger_file_ext") {
84 84
 			    $trim_value = preg_replace('/.*\.([^\.]+)$/', '\1', $value);
85
-			    if(in_array($trim_value, $this->config['upload_badext'])) {
85
+			    if (in_array($trim_value, $this->config['upload_badext'])) {
86 86
 			        $GLOBALS['log']->security("Invalid log file extension: trying to use invalid file extension '$value'.");
87 87
 			        continue;
88 88
 			    }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                 $this->config[$key] = $value;
98 98
 			} else {
99 99
                 $v = $sugarConfig->get(str_replace('_', '.', $key));
100
-            if ($v  !== null){
100
+            if ($v !== null) {
101 101
 			   setDeepArrayValue($this->config, $key, $value);
102 102
 			}}
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 	}
107 107
 
108
-	function handleOverride($fromParseLoggerSettings=false) {
108
+	function handleOverride($fromParseLoggerSettings = false) {
109 109
 		global $sugar_config, $sugar_version;
110 110
 		$sc = SugarConfig::getInstance();
111 111
 		$overrideArray = $this->readOverride();
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
 		//print_r($overrideArray);
130 130
         //Bug#53013: Clean the tpl cache if action menu style has been changed.
131
-        if( isset($overrideArray['enable_action_menu']) &&
132
-                ( !isset($this->previous_sugar_override_config_array['enable_action_menu']) ||
133
-                    $overrideArray['enable_action_menu'] != $this->previous_sugar_override_config_array['enable_action_menu'] )
131
+        if (isset($overrideArray['enable_action_menu']) &&
132
+                (!isset($this->previous_sugar_override_config_array['enable_action_menu']) ||
133
+                    $overrideArray['enable_action_menu'] != $this->previous_sugar_override_config_array['enable_action_menu'])
134 134
         ) {
135 135
             require_once('modules/Administration/QuickRepairAndRebuild.php');
136 136
             $repair = new RepairAndClear;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             $repair->clearTpls();
139 139
         }
140 140
 
141
-		foreach($overrideArray as $key => $val) {
141
+		foreach ($overrideArray as $key => $val) {
142 142
 			if (in_array($key, $this->allow_undefined) || isset ($sugar_config[$key])) {
143 143
 				if (is_string($val) && strcmp($val, 'true') == 0) {
144 144
 					$val = true;
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 		$overideString .= '/***CONFIGURATOR***/';
155 155
 
156 156
 		$this->saveOverride($overideString);
157
-		if(isset($this->config['logger']['level']) && $this->logger) $this->logger->setLevel($this->config['logger']['level']);
157
+		if (isset($this->config['logger']['level']) && $this->logger) $this->logger->setLevel($this->config['logger']['level']);
158 158
 	}
159 159
 
160 160
 	//bug #27947 , if previous $sugar_config['stack_trace_errors'] is true and now we disable it , we should clear all the cache.
161
-	function clearCache(){
161
+	function clearCache() {
162 162
 		global $sugar_config, $sugar_version;
163 163
 		$currentConfigArray = $this->readOverride();
164
-		foreach($currentConfigArray as $key => $val) {
164
+		foreach ($currentConfigArray as $key => $val) {
165 165
 			if (in_array($key, $this->allow_undefined) || isset ($sugar_config[$key])) {
166
-				if (empty($val) ) {
167
-					if(!empty($this->previous_sugar_override_config_array['stack_trace_errors']) && $key == 'stack_trace_errors'){
166
+				if (empty($val)) {
167
+					if (!empty($this->previous_sugar_override_config_array['stack_trace_errors']) && $key == 'stack_trace_errors') {
168 168
 						require_once('include/TemplateHandler/TemplateHandler.php');
169 169
 						TemplateHandler::clearAll();
170 170
 						return;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	}
176 176
 
177 177
 	function saveConfig() {
178
-        if($this->saveImages() === false)
178
+        if ($this->saveImages() === false)
179 179
         {
180 180
             return false;
181 181
         }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	function readOverride() {
189 189
 		$sugar_config = array();
190 190
 		if (file_exists('config_override.php')) {
191
-		    if ( !is_readable('config_override.php') ) {
191
+		    if (!is_readable('config_override.php')) {
192 192
 		        $GLOBALS['log']->fatal("Unable to read the config_override.php file. Check the file permissions");
193 193
 		    }
194 194
 	        else {
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	}
200 200
 	function saveOverride($override) {
201 201
         require_once('install/install_utils.php');
202
-	    if ( !file_exists('config_override.php') ) {
202
+	    if (!file_exists('config_override.php')) {
203 203
 	    	touch('config_override.php');
204 204
 	    }
205
-	    if ( !(make_writable('config_override.php')) ||  !(is_writable('config_override.php')) ) {
205
+	    if (!(make_writable('config_override.php')) || !(is_writable('config_override.php'))) {
206 206
 	        $GLOBALS['log']->fatal("Unable to write to the config_override.php file. Check the file permissions");
207 207
 	        return;
208 208
 	    }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 	function saveImages() {
240 240
 		if (!empty ($_POST['company_logo'])) {
241
-            if($this->saveCompanyLogo("upload://".$_POST['company_logo']) === false)
241
+            if ($this->saveCompanyLogo("upload://".$_POST['company_logo']) === false)
242 242
             {
243 243
                 return false;
244 244
             }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 	function checkTempImage($path)
249 249
 	{
250
-        if(!verify_uploaded_image($path)) {
250
+        if (!verify_uploaded_image($path)) {
251 251
             $error = translate('LBL_ALERT_TYPE_IMAGE');
252 252
         	$GLOBALS['log']->fatal("A user ({$GLOBALS['current_user']->id}) attempted to use an invalid file for the logo - {$path}");
253 253
             $this->error = $error;
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
 	function saveCompanyLogo($path)
271 271
     {
272 272
     	$path = $this->checkTempImage($path);
273
-        if($path === false)
273
+        if ($path === false)
274 274
         {
275 275
             return false;
276 276
         }
277 277
 
278 278
         mkdir_recursive('custom/'.SugarThemeRegistry::current()->getDefaultImagePath(), true);
279
-        copy($path,'custom/'. SugarThemeRegistry::current()->getDefaultImagePath(). '/company_logo.png');
279
+        copy($path, 'custom/'.SugarThemeRegistry::current()->getDefaultImagePath().'/company_logo.png');
280 280
         sugar_cache_clear('company_logo_attributes');
281 281
         SugarThemeRegistry::clearAllCaches();
282 282
 	}
@@ -287,37 +287,37 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 */
289 289
 
290
-	function parseLoggerSettings(){
291
-		if(!function_exists('setDeepArrayValue')){
290
+	function parseLoggerSettings() {
291
+		if (!function_exists('setDeepArrayValue')) {
292 292
 			require('include/utils/array_utils.php');
293 293
 		}
294 294
 		if (file_exists('log4php.properties')) {
295 295
 			$fileContent = file_get_contents('log4php.properties');
296 296
 			$old_props = explode('\n', $fileContent);
297 297
 			$new_props = array();
298
-			$key_names=array();
299
-			foreach($old_props as $value) {
300
-				if(!empty($value) && !preg_match("/^\/\//", $value)) {
301
-					$temp = explode("=",$value);
302
-					$property = isset( $temp[1])? $temp[1] : array();
303
-					if(preg_match("/log4php.appender.A2.MaxFileSize=/",$value)){
304
-						setDeepArrayValue($this->config, 'logger_file_maxSize', rtrim( $property));
298
+			$key_names = array();
299
+			foreach ($old_props as $value) {
300
+				if (!empty($value) && !preg_match("/^\/\//", $value)) {
301
+					$temp = explode("=", $value);
302
+					$property = isset($temp[1]) ? $temp[1] : array();
303
+					if (preg_match("/log4php.appender.A2.MaxFileSize=/", $value)) {
304
+						setDeepArrayValue($this->config, 'logger_file_maxSize', rtrim($property));
305 305
 					}
306
-					elseif(preg_match("/log4php.appender.A2.File=/", $value)){
307
-						$ext = preg_split("/\./",$property);
308
-						if(preg_match( "/^\./", $property)){ //begins with .
309
-							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[2]) ? '.' . rtrim( $ext[2]):'.log');
310
-							setDeepArrayValue($this->config, 'logger_file_name', rtrim( ".".$ext[1]));
311
-						}else{
312
-							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[1]) ? '.' . rtrim( $ext[1]):'.log');
313
-							setDeepArrayValue($this->config, 'logger_file_name', rtrim( $ext[0] ));
306
+					elseif (preg_match("/log4php.appender.A2.File=/", $value)) {
307
+						$ext = preg_split("/\./", $property);
308
+						if (preg_match("/^\./", $property)) { //begins with .
309
+							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[2]) ? '.'.rtrim($ext[2]) : '.log');
310
+							setDeepArrayValue($this->config, 'logger_file_name', rtrim(".".$ext[1]));
311
+						} else {
312
+							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[1]) ? '.'.rtrim($ext[1]) : '.log');
313
+							setDeepArrayValue($this->config, 'logger_file_name', rtrim($ext[0]));
314 314
 						}
315
-					}elseif(preg_match("/log4php.appender.A2.layout.DateFormat=/",$value)){
316
-						setDeepArrayValue($this->config, 'logger_file_dateFormat', trim(rtrim( $property), '""'));
315
+					}elseif (preg_match("/log4php.appender.A2.layout.DateFormat=/", $value)) {
316
+						setDeepArrayValue($this->config, 'logger_file_dateFormat', trim(rtrim($property), '""'));
317 317
 
318
-					}elseif(preg_match("/log4php.rootLogger=/",$value)){
319
-						$property = explode(",",$property);
320
-						setDeepArrayValue($this->config, 'logger_level', rtrim( $property[0]));
318
+					}elseif (preg_match("/log4php.rootLogger=/", $value)) {
319
+						$property = explode(",", $property);
320
+						setDeepArrayValue($this->config, 'logger_level', rtrim($property[0]));
321 321
 					}
322 322
 				}
323 323
 			}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		}
333 333
 
334 334
 		if (!isset($this->config['logger']) || empty($this->config['logger'])) {
335
-			$this->config['logger'] = array (
335
+			$this->config['logger'] = array(
336 336
 			'file' => array(
337 337
 				'ext' => '.log',
338 338
 				'name' => 'sugarcrm',
Please login to merge, or discard this patch.
Braces   +12 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -63,8 +65,7 @@  discard block
 block discarded – undo
63 65
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
64 66
         if(isset($GLOBALS['log'])) {
65 67
             $GLOBALS['log']->deprecated($deprecatedMessage);
66
-        }
67
-        else {
68
+        } else {
68 69
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
69 70
         }
70 71
         self::__construct();
@@ -154,7 +155,9 @@  discard block
 block discarded – undo
154 155
 		$overideString .= '/***CONFIGURATOR***/';
155 156
 
156 157
 		$this->saveOverride($overideString);
157
-		if(isset($this->config['logger']['level']) && $this->logger) $this->logger->setLevel($this->config['logger']['level']);
158
+		if(isset($this->config['logger']['level']) && $this->logger) {
159
+		    $this->logger->setLevel($this->config['logger']['level']);
160
+		}
158 161
 	}
159 162
 
160 163
 	//bug #27947 , if previous $sugar_config['stack_trace_errors'] is true and now we disable it , we should clear all the cache.
@@ -190,8 +193,7 @@  discard block
 block discarded – undo
190 193
 		if (file_exists('config_override.php')) {
191 194
 		    if ( !is_readable('config_override.php') ) {
192 195
 		        $GLOBALS['log']->fatal("Unable to read the config_override.php file. Check the file permissions");
193
-		    }
194
-	        else {
196
+		    } else {
195 197
 	            include('config_override.php');
196 198
 	        }
197 199
 		}
@@ -302,20 +304,19 @@  discard block
 block discarded – undo
302 304
 					$property = isset( $temp[1])? $temp[1] : array();
303 305
 					if(preg_match("/log4php.appender.A2.MaxFileSize=/",$value)){
304 306
 						setDeepArrayValue($this->config, 'logger_file_maxSize', rtrim( $property));
305
-					}
306
-					elseif(preg_match("/log4php.appender.A2.File=/", $value)){
307
+					} elseif(preg_match("/log4php.appender.A2.File=/", $value)){
307 308
 						$ext = preg_split("/\./",$property);
308 309
 						if(preg_match( "/^\./", $property)){ //begins with .
309 310
 							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[2]) ? '.' . rtrim( $ext[2]):'.log');
310 311
 							setDeepArrayValue($this->config, 'logger_file_name', rtrim( ".".$ext[1]));
311
-						}else{
312
+						} else{
312 313
 							setDeepArrayValue($this->config, 'logger_file_ext', isset($ext[1]) ? '.' . rtrim( $ext[1]):'.log');
313 314
 							setDeepArrayValue($this->config, 'logger_file_name', rtrim( $ext[0] ));
314 315
 						}
315
-					}elseif(preg_match("/log4php.appender.A2.layout.DateFormat=/",$value)){
316
+					} elseif(preg_match("/log4php.appender.A2.layout.DateFormat=/",$value)){
316 317
 						setDeepArrayValue($this->config, 'logger_file_dateFormat', trim(rtrim( $property), '""'));
317 318
 
318
-					}elseif(preg_match("/log4php.rootLogger=/",$value)){
319
+					} elseif(preg_match("/log4php.rootLogger=/",$value)){
319 320
 						$property = explode(",",$property);
320 321
 						setDeepArrayValue($this->config, 'logger_level', rtrim( $property[0]));
321 322
 					}
Please login to merge, or discard this patch.
modules/AOS_Contracts/AOS_Contracts_sugar.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	var $table_name = 'aos_contracts';
39 39
 	var $importable = true;
40 40
     var $lineItems = true;
41
-	var $disable_row_level_security = true ; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
41
+	var $disable_row_level_security = true; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
42 42
 		var $id;
43 43
 		var $name;
44 44
 		var $date_entered;
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
 		var $renewal_reminder_date;
65 65
 		var $contract_type;
66 66
 
67
-    function __construct(){
67
+    function __construct() {
68 68
 		parent::__construct();
69 69
 	}
70 70
 
71 71
     /**
72 72
      * @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
73 73
      */
74
-    function AOS_Contracts_sugar(){
74
+    function AOS_Contracts_sugar() {
75 75
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
76
-        if(isset($GLOBALS['log'])) {
76
+        if (isset($GLOBALS['log'])) {
77 77
             $GLOBALS['log']->deprecated($deprecatedMessage);
78 78
         }
79 79
         else {
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
 
86
-	function bean_implements($interface){
87
-		switch($interface){
86
+	function bean_implements($interface) {
87
+		switch ($interface) {
88 88
 			case 'ACL': return true;
89 89
 		}
90 90
 		return false;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/AOS_Contracts/views/view.detail.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 require_once('include/MVC/View/views/view.detail.php');
5 5
 
6 6
 class AOS_ContractsViewDetail extends ViewDetail {
7 7
 
8
-	function __construct(){
8
+	function __construct() {
9 9
  		parent::__construct();
10 10
  	}
11 11
 
12 12
     /**
13 13
      * @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
14 14
      */
15
-    function AOS_ContractsViewDetail(){
15
+    function AOS_ContractsViewDetail() {
16 16
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
17
-        if(isset($GLOBALS['log'])) {
17
+        if (isset($GLOBALS['log'])) {
18 18
             $GLOBALS['log']->deprecated($deprecatedMessage);
19 19
         }
20 20
         else {
@@ -24,28 +24,28 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
 
27
-	function display(){
27
+	function display() {
28 28
 		$this->populateContractTemplates();
29 29
 		$this->displayPopupHtml();
30 30
 		parent::display();
31 31
 	}
32 32
 
33
-	function populateContractTemplates(){
33
+	function populateContractTemplates() {
34 34
 		global $app_list_strings;
35 35
 
36 36
 		$sql = "SELECT id, name FROM aos_pdf_templates WHERE deleted = 0 AND type='AOS_Contracts' AND active = 1";
37 37
 
38 38
 		$res = $this->bean->db->query($sql);
39 39
         $app_list_strings['template_ddown_c_list'] = array();
40
-		while($row = $this->bean->db->fetchByAssoc($res)){
40
+		while ($row = $this->bean->db->fetchByAssoc($res)) {
41 41
 			$app_list_strings['template_ddown_c_list'][$row['id']] = $row['name'];
42 42
 		}
43 43
 	}
44 44
 
45
-	function displayPopupHtml(){
46
-		global $app_list_strings,$app_strings, $mod_strings;
45
+	function displayPopupHtml() {
46
+		global $app_list_strings, $app_strings, $mod_strings;
47 47
         $templates = array_keys($app_list_strings['template_ddown_c_list']);
48
-        if($templates){
48
+        if ($templates) {
49 49
 
50 50
 		echo '	<div id="popupDiv_ara" style="display:none;position:fixed;top: 39%; left: 41%;opacity:1;z-index:9999;background:#FFFFFF;">
51 51
 				<form id="popupForm" action="index.php?entryPoint=generatePdf" method="post">
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 						<b>'.$app_strings['LBL_SELECT_TEMPLATE'].':-</b>
56 56
 						</td>
57 57
 					</tr>';
58
-			foreach($templates as $template){
59
-				$template = str_replace('^','',$template);
58
+			foreach ($templates as $template) {
59
+				$template = str_replace('^', '', $template);
60 60
 				$js = "document.getElementById('popupDivBack_ara').style.display='none';document.getElementById('popupDiv_ara').style.display='none';var form=document.getElementById('popupForm');if(form!=null){form.templateID.value='".$template."';form.submit();}else{alert('Error!');}";
61 61
 				echo '<tr height="20">
62 62
 				<td width="17" valign="center"><a href="#" onclick="'.$js.'"><img src="themes/default/images/txt_image_inline.gif" width="16" height="16" /></a></td>
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 					}
92 92
 				</script>';
93 93
 		}
94
-		else{
94
+		else {
95 95
 			echo '<script>
96 96
 				function showPopup(task){
97 97
 				alert(\''.$mod_strings['LBL_NO_TEMPLATE'].'\');
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -58,8 +60,7 @@  discard block
 block discarded – undo
58 60
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
59 61
         if(isset($GLOBALS['log'])) {
60 62
             $GLOBALS['log']->deprecated($deprecatedMessage);
61
-        }
62
-        else {
63
+        } else {
63 64
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
64 65
         }
65 66
         self::__construct($button_properties);
@@ -123,8 +124,7 @@  discard block
 block discarded – undo
123 124
 
124 125
 		if ($subpanel_name == 'Project'){
125 126
 			$link_field_name = 'project_contacts_1';
126
-		}
127
-		else{
127
+		} else{
128 128
 			$link_field_name = $subpanel_definition->get_data_source_name(true);
129 129
 		}
130 130
 
Please login to merge, or discard this patch.