Completed
Push — master ( a75ecc...97ae17 )
by Adam
71:21 queued 52:34
created
modules/Charts/Dashlets/CampaignROIChartDashlet/CampaignROIChartDashlet.php 1 patch
Spacing   +29 added lines, -29 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.
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
     {
60 60
         $this->getSeedBean()->disable_row_level_security = false;
61 61
 
62
-        $campaigns = $this->getSeedBean()->get_full_list("","");
63
-        if ( $campaigns != null )
62
+        $campaigns = $this->getSeedBean()->get_full_list("", "");
63
+        if ($campaigns != null)
64 64
             foreach ($campaigns as $c)
65 65
                 $this->_searchFields['campaign_id']['options'][$c->id] = $c->name;
66 66
         else
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
         $rawData = $this->constructQuery(
78 78
             $GLOBALS['app_list_strings']['roi_type_dom'],
79 79
             $GLOBALS['app_list_strings']['roi_type_dom'],
80
-            $this->campaign_id[0],null,true,true,true,$this->id);
80
+            $this->campaign_id[0], null, true, true, true, $this->id);
81 81
 
82 82
         $currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
83
-        if ($GLOBALS['current_user']->getPreference('currency')){
83
+        if ($GLOBALS['current_user']->getPreference('currency')) {
84 84
 
85 85
             $currency = new Currency();
86 86
             $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         $chartHeight    = 500;
94 94
         $autoRefresh = $this->processAutoRefresh();
95 95
 
96
-        $chartReadyData = $this->prepareChartData($rawData,$currency_symbol,$thousands_symbol);
96
+        $chartReadyData = $this->prepareChartData($rawData, $currency_symbol, $thousands_symbol);
97 97
 
98 98
         //$chartReadyData['data'] = [[1.1,2.2],[3.3,4.4]];
99 99
         $jsonData = json_encode($chartReadyData['data']);
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         //$colours = "['red','blue','green','orange','yellow','pink']";
108 108
         $colours = "['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99','#b15928']";
109 109
 
110
-        if(!is_array($chartReadyData['data'])||count($chartReadyData['data']) < 1)
110
+        if (!is_array($chartReadyData['data']) || count($chartReadyData['data']) < 1)
111 111
         {
112 112
             return "<h3 class='noGraphDataPoints'>$this->noDataMessage</h3>";
113 113
         }
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
         //   return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $returnStr . '</div>'. $this->processAutoRefresh();
217 217
     }
218 218
 
219
-    protected function constructQuery($datay= array(),$targets=array(),$campaign_id = null, $cache_file_name='a_file', $refresh=false,$marketing_id='',$is_dashlet=false,$dashlet_id='') {
219
+    protected function constructQuery($datay = array(), $targets = array(), $campaign_id = null, $cache_file_name = 'a_file', $refresh = false, $marketing_id = '', $is_dashlet = false, $dashlet_id = '') {
220 220
         //global $app_strings,$mod_strings, $current_module_strings, $charset, $lang, $app_list_strings, $current_language,$sugar_config;
221 221
         global $mod_strings;
222 222
 
223
-        $campaign_id = (int) $campaign_id;
224
-        if(!$campaign_id) {
223
+        $campaign_id = (int)$campaign_id;
224
+        if (!$campaign_id) {
225 225
             $GLOBALS['log']->debug('roi chart need a campaign id');
226 226
             return false;
227 227
         }
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
 
233 233
         $focus = new Campaign();
234 234
         $focus->retrieve($campaign_id);
235
-        $opp_count=0;
236
-        $opp_query  = "select count(*) opp_count,sum(" . db_convert("amount_usdollar","IFNULL",array(0)).")  total_value";
235
+        $opp_count = 0;
236
+        $opp_query  = "select count(*) opp_count,sum(".db_convert("amount_usdollar", "IFNULL", array(0)).")  total_value";
237 237
         $opp_query .= " from opportunities";
238 238
         $opp_query .= " where campaign_id='$campaign_id'";
239 239
         $opp_query .= " and sales_stage='Prospecting'";
240 240
         $opp_query .= " and deleted=0";
241 241
 
242
-        $opp_result=$focus->db->query($opp_query);
243
-        $opp_data=$focus->db->fetchByAssoc($opp_result);
244
-        if (empty($opp_data['total_value'])) $opp_data['total_value']=0;
242
+        $opp_result = $focus->db->query($opp_query);
243
+        $opp_data = $focus->db->fetchByAssoc($opp_result);
244
+        if (empty($opp_data['total_value'])) $opp_data['total_value'] = 0;
245 245
 
246
-        $chartData['Total Value']= $opp_data['total_value'];
246
+        $chartData['Total Value'] = $opp_data['total_value'];
247 247
 
248 248
         //report query
249 249
         $opp_query1  = "select SUM(opp.amount) as revenue";
@@ -252,28 +252,28 @@  discard block
 block discarded – undo
252 252
         $opp_query1 .= " where opp.sales_stage = 'Closed Won'and camp.id='$campaign_id' and opp.deleted=0";
253 253
         $opp_query1 .= " group by camp.name";
254 254
 
255
-        $opp_result1=$focus->db->query($opp_query1);
256
-        $opp_data1=$focus->db->fetchByAssoc($opp_result1);
255
+        $opp_result1 = $focus->db->query($opp_query1);
256
+        $opp_data1 = $focus->db->fetchByAssoc($opp_result1);
257 257
 
258 258
         //if (empty($opp_data1[]))
259
-        if (empty($opp_data1['revenue'])){
259
+        if (empty($opp_data1['revenue'])) {
260 260
             $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']] = 0;
261 261
             unset($opp_data1['revenue']);
262
-        }else{
262
+        } else {
263 263
             $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']] = $opp_data1['revenue'];
264 264
             unset($opp_data1['revenue']);
265 265
             $not_empty = true;
266 266
         }
267 267
 
268
-        $chartData['Revenue']= $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']];
268
+        $chartData['Revenue'] = $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']];
269 269
 
270 270
         $camp_query1  = "select camp.name, SUM(camp.actual_cost) as investment,SUM(camp.budget) as budget,SUM(camp.expected_revenue) as expected_revenue";
271 271
         $camp_query1 .= " from campaigns camp";
272 272
         $camp_query1 .= " where camp.id='$campaign_id'";
273 273
         $camp_query1 .= " group by camp.name";
274 274
 
275
-        $camp_result1=$focus->db->query($camp_query1);
276
-        $camp_data1=$focus->db->fetchByAssoc($camp_result1);
275
+        $camp_result1 = $focus->db->query($camp_query1);
276
+        $camp_data1 = $focus->db->fetchByAssoc($camp_result1);
277 277
 
278 278
 
279 279
         if (empty($camp_data1['investment']))
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
         else
290 290
             $not_empty = true;
291 291
 
292
-        $chartData['Investment']= $camp_data1['investment'];
293
-        $chartData['Budget']= $camp_data1['budget'];
294
-        $chartData['Expected Revenue']= $camp_data1['expected_revenue'];
292
+        $chartData['Investment'] = $camp_data1['investment'];
293
+        $chartData['Budget'] = $camp_data1['budget'];
294
+        $chartData['Expected Revenue'] = $camp_data1['expected_revenue'];
295 295
 
296 296
         /*
297 297
             $opp_data1[$mod_strings['LBL_ROI_CHART_INVESTMENT']]=$camp_data1['investment'];
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
         return $chartData;
314 314
     }
315 315
 
316
-    protected function prepareChartData($data,$currency_symbol, $thousands_symbol)
316
+    protected function prepareChartData($data, $currency_symbol, $thousands_symbol)
317 317
     {
318 318
         //Use the  lead_source to categorise the data for the charts
319 319
         $chart['labels'] = array();
320 320
         $chart['data'] = array();
321 321
         //Need to add all elements into the key, as they are stacked (even though the category is not present, the value could be)
322 322
         $chart['key'] = array();
323
-        $chart['tooltips']= array();
323
+        $chart['tooltips'] = array();
324 324
 
325
-        foreach($data as $key=>$value)
325
+        foreach ($data as $key=>$value)
326 326
         {
327 327
             $formattedFloat = (float)number_format((float)$value, 2, '.', '');
328 328
             $chart['labels'][] = $key;
Please login to merge, or discard this patch.
Charts/Dashlets/PipelineBySalesStageDashlet/PipelineBySalesStageDashlet.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
     {
68 68
         global $timedate;
69 69
 
70
-        if(empty($options['pbss_date_start']))
70
+        if (empty($options['pbss_date_start']))
71 71
             $options['pbss_date_start'] = $timedate->nowDbDate();
72 72
 
73
-        if(empty($options['pbss_date_end']))
73
+        if (empty($options['pbss_date_end']))
74 74
             $options['pbss_date_end'] = $timedate->asDbDate($timedate->getNow()->modify("+6 months"));
75 75
 
76
-        if(empty($options['title']))
76
+        if (empty($options['title']))
77 77
             $options['title'] = translate('LBL_RGraph_PIPELINE_FORM_TITLE', 'Home');
78 78
 
79
-        parent::__construct($id,$options);
79
+        parent::__construct($id, $options);
80 80
     }
81 81
 
82 82
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         $thousands_symbol = translate('LBL_OPP_THOUSANDS', 'Charts');
110 110
 
111 111
         $currency_symbol = $sugar_config['default_currency_symbol'];
112
-        if ($current_user->getPreference('currency')){
112
+        if ($current_user->getPreference('currency')) {
113 113
 
114 114
             $currency = new Currency();
115 115
             $currency->retrieve($current_user->getPreference('currency'));
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
         //These are taken in the same fashion as the hard-coded array above
136 136
         $module = 'Opportunities';
137 137
         $action = 'index';
138
-        $query  ='true';
139
-        $searchFormTab ='advanced_search';
138
+        $query  = 'true';
139
+        $searchFormTab = 'advanced_search';
140 140
 
141 141
         $chartWidth     = 900;
142 142
         $chartHeight    = 500;
143 143
 
144
-        $autoRefresh = $this->processAutoRefresh();//$autoRefresh
144
+        $autoRefresh = $this->processAutoRefresh(); //$autoRefresh
145 145
 
146 146
         $colours = "['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99','#b15928']";
147 147
         //<canvas id='$canvasId' width='$chartWidth' height='$chartHeight'>[No canvas support]</canvas>
148 148
         //<canvas id='test123'  width='$chartWidth' height='$chartHeight'>[No canvas support]</canvas>
149 149
 
150 150
         //There is always an ending anchor value, hence this check is that the data array is less than 2
151
-        if(!is_array($chartReadyData['data'])||count($chartReadyData['data']) < 2)
151
+        if (!is_array($chartReadyData['data']) || count($chartReadyData['data']) < 2)
152 152
         {
153 153
             return "<h3 class='noGraphDataPoints'>$this->noDataMessage</h3>";
154 154
         }
@@ -272,13 +272,13 @@  discard block
 block discarded – undo
272 272
         }
273 273
 
274 274
         $result = $db->query($query);
275
-        while($row = $db->fetchByAssoc($result, false))
275
+        while ($row = $db->fetchByAssoc($result, false))
276 276
             $temp_data[] = $row;
277 277
 
278 278
         // reorder and set the array based on the order of selected_datax
279
-        foreach($selected_datax as $sales_stage){
280
-            foreach($temp_data as $key => $value){
281
-                if ($value['sales_stage'] == $sales_stage){
279
+        foreach ($selected_datax as $sales_stage) {
280
+            foreach ($temp_data as $key => $value) {
281
+                if ($value['sales_stage'] == $sales_stage) {
282 282
                     $value['sales_stage'] = $app_list_strings['sales_stage_dom'][$value['sales_stage']];
283 283
                     $value['key'] = $sales_stage;
284 284
                     $value['value'] = $value['sales_stage'];
@@ -318,40 +318,40 @@  discard block
 block discarded – undo
318 318
                         count(*) AS opp_count,
319 319
                         sum(amount_usdollar/1000) AS total
320 320
                     FROM users,opportunities  ";
321
-        $query .= " WHERE opportunities.date_closed >= ". db_convert("'".$this->pbss_date_start."'",'date').
322
-            " AND opportunities.date_closed <= ".db_convert("'".$this->pbss_date_end."'",'date') .
321
+        $query .= " WHERE opportunities.date_closed >= ".db_convert("'".$this->pbss_date_start."'", 'date').
322
+            " AND opportunities.date_closed <= ".db_convert("'".$this->pbss_date_end."'", 'date').
323 323
             " AND opportunities.assigned_user_id = users.id  AND opportunities.deleted=0 ";
324 324
         $query .= " GROUP BY opportunities.sales_stage";
325 325
 
326 326
         return $query;
327 327
     }
328 328
 
329
-    protected function prepareChartData($data,$currency_symbol, $thousands_symbol)
329
+    protected function prepareChartData($data, $currency_symbol, $thousands_symbol)
330 330
     {
331 331
         //return $data;
332
-        $chart['labels']=array();
333
-        $chart['data']=array();
332
+        $chart['labels'] = array();
333
+        $chart['data'] = array();
334 334
         $total = 0;
335
-        foreach($data as $i)
335
+        foreach ($data as $i)
336 336
         {
337 337
             //$chart['labelsAndValues'][]=$i['key'].' ('.$currency.(int)$i['total'].')';
338
-            $chart['labelsAndValues'][]=$this->resizeLabel($i['key']).' ('.$currency_symbol.(int)$i['total'].$thousands_symbol.')';
339
-            $chart['labels'][]=$i['key'];
340
-            $chart['data'][]=(int)$i['total'];
341
-            $total+=(int)$i['total'];
338
+            $chart['labelsAndValues'][] = $this->resizeLabel($i['key']).' ('.$currency_symbol.(int)$i['total'].$thousands_symbol.')';
339
+            $chart['labels'][] = $i['key'];
340
+            $chart['data'][] = (int)$i['total'];
341
+            $total += (int)$i['total'];
342 342
         }
343 343
         //The funnel needs n+1 elements (to bind the shape to as per http://www.rgraph.net/demos/funnel-interactive-key.html)
344 344
         //$chart['data'][]=1;
345
-        $chart['total']=$total;
345
+        $chart['total'] = $total;
346 346
         return $chart;
347 347
     }
348 348
 
349 349
     protected function resizeLabel($label)
350 350
     {
351
-        if(strlen($label) < $this->maxLabelSizeBeforeTotal)
351
+        if (strlen($label) < $this->maxLabelSizeBeforeTotal)
352 352
             return $label;
353 353
         else
354
-            return substr($label,0,$this->maxLabelSizeBeforeTotal).$this->labelReplacementString;
354
+            return substr($label, 0, $this->maxLabelSizeBeforeTotal).$this->labelReplacementString;
355 355
 
356 356
     }
357 357
 
Please login to merge, or discard this patch.
modules/Administration/DisplayWarnings.php 1 patch
Spacing   +25 added lines, -25 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.
@@ -41,37 +41,37 @@  discard block
 block discarded – undo
41 41
 
42 42
 
43 43
 global $db;
44
-function displayAdminError($errorString){
45
-	$output = '<p class="error">' . $errorString .'</p>';
44
+function displayAdminError($errorString) {
45
+	$output = '<p class="error">'.$errorString.'</p>';
46 46
 		echo $output;
47 47
 }
48 48
 
49
-if(!empty($_SESSION['display_lotuslive_alert'])){
49
+if (!empty($_SESSION['display_lotuslive_alert'])) {
50 50
     displayAdminError(translate('MSG_RECONNECT_LOTUSLIVE', 'Administration'));
51 51
 }
52 52
 
53 53
 
54 54
 
55 55
 
56
-if(isset($_SESSION['rebuild_relationships'])){
56
+if (isset($_SESSION['rebuild_relationships'])) {
57 57
 	displayAdminError(translate('MSG_REBUILD_RELATIONSHIPS', 'Administration'));
58 58
 }
59 59
 
60
-if(isset($_SESSION['rebuild_extensions'])){
60
+if (isset($_SESSION['rebuild_extensions'])) {
61 61
 	displayAdminError(translate('MSG_REBUILD_EXTENSIONS', 'Administration'));
62 62
 }
63 63
 
64
-if ( (strpos($_SERVER["SERVER_SOFTWARE"],'Microsoft-IIS') !== false) && (php_sapi_name() == 'cgi-fcgi') && (ini_get('fastcgi.logging') != '0') ) {
64
+if ((strpos($_SERVER["SERVER_SOFTWARE"], 'Microsoft-IIS') !== false) && (php_sapi_name() == 'cgi-fcgi') && (ini_get('fastcgi.logging') != '0')) {
65 65
     displayAdminError(translate('LBL_FASTCGI_LOGGING', 'Administration'));
66 66
 }
67
-if(is_admin($current_user)){
68
-if(!empty($_SESSION['COULD_NOT_CONNECT'])){
69
-	displayAdminError(translate('LBL_COULD_NOT_CONNECT', 'Administration') . ' '. $timedate->to_display_date_time($_SESSION['COULD_NOT_CONNECT']));
67
+if (is_admin($current_user)) {
68
+if (!empty($_SESSION['COULD_NOT_CONNECT'])) {
69
+	displayAdminError(translate('LBL_COULD_NOT_CONNECT', 'Administration').' '.$timedate->to_display_date_time($_SESSION['COULD_NOT_CONNECT']));
70 70
 }
71
-if(!empty($_SESSION['EXCEEDING_OC_LICENSES']) && $_SESSION['EXCEEDING_OC_LICENSES'] == true){
71
+if (!empty($_SESSION['EXCEEDING_OC_LICENSES']) && $_SESSION['EXCEEDING_OC_LICENSES'] == true) {
72 72
     displayAdminError(translate('LBL_EXCEEDING_OC_LICENSES', 'Administration'));
73 73
 }
74
-if(isset($license) && !empty($license->settings['license_msg_admin'])){
74
+if (isset($license) && !empty($license->settings['license_msg_admin'])) {
75 75
     // UUDDLRLRBA
76 76
 	$GLOBALS['log']->fatal(base64_decode($license->settings['license_msg_admin']));
77 77
     //displayAdminError(base64_decode($license->settings['license_msg_admin']));
@@ -86,35 +86,35 @@  discard block
 block discarded – undo
86 86
 //If sendmail has been configured by setting the config variable ignore this warning
87 87
 $sendMailEnabled = isset($sugar_config['allow_sendmail_outbound']) && $sugar_config['allow_sendmail_outbound'];
88 88
 
89
-if(trim($admin->settings['mail_smtpserver']) == '' && !$sendMailEnabled) {
90
-    if($admin->settings['notify_on']) {
89
+if (trim($admin->settings['mail_smtpserver']) == '' && !$sendMailEnabled) {
90
+    if ($admin->settings['notify_on']) {
91 91
         $smtp_error = true;
92 92
     }
93 93
 }
94 94
 
95
-if($smtp_error) {
96
-    displayAdminError(translate('WARN_NO_SMTP_SERVER_AVAILABLE_ERROR','Administration'));
95
+if ($smtp_error) {
96
+    displayAdminError(translate('WARN_NO_SMTP_SERVER_AVAILABLE_ERROR', 'Administration'));
97 97
 }
98 98
 
99
- if(!empty($dbconfig['db_host_name']) || $sugar_config['sugar_version'] != $sugar_version ){
99
+ if (!empty($dbconfig['db_host_name']) || $sugar_config['sugar_version'] != $sugar_version) {
100 100
        		displayAdminError(translate('WARN_REPAIR_CONFIG', 'Administration'));
101 101
         }
102 102
 
103
-        if( !isset($sugar_config['installer_locked']) || $sugar_config['installer_locked'] == false ){
103
+        if (!isset($sugar_config['installer_locked']) || $sugar_config['installer_locked'] == false) {
104 104
         	displayAdminError(translate('WARN_INSTALLER_LOCKED', 'Administration'));
105 105
 		}
106 106
 
107 107
 
108
-        if(empty($GLOBALS['sugar_config']['admin_access_control'])){
109
-			if(isset($_SESSION['invalid_versions'])){
108
+        if (empty($GLOBALS['sugar_config']['admin_access_control'])) {
109
+			if (isset($_SESSION['invalid_versions'])) {
110 110
 				$invalid_versions = $_SESSION['invalid_versions'];
111
-				foreach($invalid_versions as $invalid){
112
-					displayAdminError(translate('WARN_UPGRADE', 'Administration'). $invalid['name'] .translate('WARN_UPGRADE2', 'Administration'));
111
+				foreach ($invalid_versions as $invalid) {
112
+					displayAdminError(translate('WARN_UPGRADE', 'Administration').$invalid['name'].translate('WARN_UPGRADE2', 'Administration'));
113 113
 				}
114 114
 			}
115 115
 
116
-			if (isset($_SESSION['available_version'])){
117
-				if($_SESSION['available_version'] != $sugar_version)
116
+			if (isset($_SESSION['available_version'])) {
117
+				if ($_SESSION['available_version'] != $sugar_version)
118 118
 				{
119 119
 					displayAdminError(translate('WARN_UPGRADENOTE', 'Administration').$_SESSION['available_version_description']);
120 120
 				}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         }
123 123
 
124 124
 
125
-		if(isset($_SESSION['administrator_error']))
125
+		if (isset($_SESSION['administrator_error']))
126 126
 		{
127 127
 			// Only print DB errors once otherwise they will still look broken
128 128
 			// after they are fixed.
Please login to merge, or discard this patch.
modules/Administration/Administration.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     );
70 70
     var $disable_custom_fields = true;
71
-    var $checkbox_fields = Array("notify_send_by_default", "mail_smtpauth_req", "notify_on", 'portal_on', 'skypeout_on', 'system_mailmerge_on', 'proxy_auth', 'proxy_on', 'system_ldap_enabled','captcha_on');
71
+    var $checkbox_fields = Array("notify_send_by_default", "mail_smtpauth_req", "notify_on", 'portal_on', 'skypeout_on', 'system_mailmerge_on', 'proxy_auth', 'proxy_on', 'system_ldap_enabled', 'captcha_on');
72 72
 
73 73
     function Administration() {
74 74
         parent::SugarBean();
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
         $this->setupCustomFields('Administration');
77 77
     }
78 78
 
79
-    function retrieveSettings($category = FALSE, $clean=false) {
79
+    function retrieveSettings($category = FALSE, $clean = false) {
80 80
         // declare a cache for all settings
81 81
         $settings_cache = sugar_cache_retrieve('admin_settings_cache');
82 82
 
83
-        if($clean) {
83
+        if ($clean) {
84 84
             $settings_cache = array();
85 85
         }
86 86
 
87 87
         // Check for a cache hit
88
-        if(!empty($settings_cache)) {
88
+        if (!empty($settings_cache)) {
89 89
             $this->settings = $settings_cache;
90 90
             if (!empty($this->settings[$category]))
91 91
             {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             }
94 94
         }
95 95
 
96
-        if ( ! empty($category) ) {
96
+        if (!empty($category)) {
97 97
             $query = "SELECT category, name, value FROM {$this->table_name} WHERE category = '{$category}'";
98 98
         } else {
99 99
             $query = "SELECT category, name, value FROM {$this->table_name}";
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 
102 102
         $result = $this->db->query($query, true, "Unable to retrieve system settings");
103 103
 
104
-        if(empty($result)) {
104
+        if (empty($result)) {
105 105
             return NULL;
106 106
         }
107 107
 
108
-        while($row = $this->db->fetchByAssoc($result)) {
109
-            if($row['category']."_".$row['name'] == 'ldap_admin_password' || $row['category']."_".$row['name'] == 'proxy_password')
108
+        while ($row = $this->db->fetchByAssoc($result)) {
109
+            if ($row['category']."_".$row['name'] == 'ldap_admin_password' || $row['category']."_".$row['name'] == 'proxy_password')
110 110
                 $this->settings[$row['category']."_".$row['name']] = $this->decrypt_after_retrieve($row['value']);
111 111
             else
112 112
                 $this->settings[$row['category']."_".$row['name']] = $row['value'];
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         }
115 115
         $this->settings[$category] = true;
116 116
 
117
-        if(!isset($this->settings["mail_sendtype"])) {
117
+        if (!isset($this->settings["mail_sendtype"])) {
118 118
             // outbound email settings
119 119
             $oe = new OutboundEmail();
120 120
             $oe->getSystemMailerSettings();
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         }
127 127
 
128 128
         // At this point, we have built a new array that should be cached.
129
-        sugar_cache_put('admin_settings_cache',$this->settings);
129
+        sugar_cache_put('admin_settings_cache', $this->settings);
130 130
         return $this;
131 131
     }
132 132
 
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
         // outbound email settings
137 137
         $oe = new OutboundEmail();
138 138
 
139
-        foreach($_POST as $key => $val) {
139
+        foreach ($_POST as $key => $val) {
140 140
             $prefix = $this->get_config_prefix($key);
141
-            if(in_array($prefix[0], $this->config_categories)) {
142
-                if(is_array($val)){
143
-                    $val=implode(",",$val);
141
+            if (in_array($prefix[0], $this->config_categories)) {
142
+                if (is_array($val)) {
143
+                    $val = implode(",", $val);
144 144
                 }
145 145
                 $this->saveSetting($prefix[0], $prefix[1], $val);
146 146
             }
147
-            if(strpos($key, "mail_") !== false) {
148
-                if(in_array($key, $oe->field_defs)) {
147
+            if (strpos($key, "mail_") !== false) {
148
+                if (in_array($key, $oe->field_defs)) {
149 149
                     $oe->$key = $val;
150 150
                 }
151 151
             }
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
         $row = $this->db->fetchByAssoc($result);
166 166
         $row_count = $row['the_count'];
167 167
 
168
-        if($category."_".$key == 'ldap_admin_password' || $category."_".$key == 'proxy_password')
168
+        if ($category."_".$key == 'ldap_admin_password' || $category."_".$key == 'proxy_password')
169 169
             $value = $this->encrpyt_before_save($value);
170 170
 
171
-        if( $row_count == 0){
171
+        if ($row_count == 0) {
172 172
             $result = $this->db->query("INSERT INTO config (value, category, name) VALUES ('$value','$category', '$key')");
173 173
         }
174
-        else{
174
+        else {
175 175
             $result = $this->db->query("UPDATE config SET value = '{$value}' WHERE category = '{$category}' AND name = '{$key}'");
176 176
         }
177 177
         sugar_cache_clear('admin_settings_cache');
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     }
180 180
 
181 181
     function get_config_prefix($str) {
182
-        return Array(substr($str, 0, strpos($str, "_")), substr($str, strpos($str, "_")+1));
182
+        return Array(substr($str, 0, strpos($str, "_")), substr($str, strpos($str, "_") + 1));
183 183
     }
184 184
 }
185 185
 ?>
Please login to merge, or discard this patch.
modules/AOR_Charts/AOR_Chart.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	var $object_name = 'AOR_Chart';
31 31
 	var $table_name = 'aor_charts';
32 32
 	var $importable = true;
33
-	var $disable_row_level_security = true ;
33
+	var $disable_row_level_security = true;
34 34
 	
35 35
 	var $id;
36 36
 	var $name;
@@ -52,148 +52,148 @@  discard block
 block discarded – undo
52 52
 
53 53
 
54 54
 
55
-	function AOR_Chart(){
55
+	function AOR_Chart() {
56 56
 		parent::Basic();
57 57
 	}
58 58
 
59
-    function save_lines(array $post,AOR_Report $bean,$postKey){
59
+    function save_lines(array $post, AOR_Report $bean, $postKey) {
60 60
         $seenIds = array();
61
-        if(isset($post[$postKey.'id'])) {
62
-            foreach ($post[$postKey . 'id'] as $key => $id) {
61
+        if (isset($post[$postKey.'id'])) {
62
+            foreach ($post[$postKey.'id'] as $key => $id) {
63 63
                 if ($id) {
64 64
                     $aorChart = BeanFactory::getBean('AOR_Charts', $id);
65 65
                 } else {
66 66
                     $aorChart = BeanFactory::newBean('AOR_Charts');
67 67
                 }
68
-                $aorChart->name = $post[$postKey . 'title'][$key];
69
-                $aorChart->type = $post[$postKey . 'type'][$key];
70
-                $aorChart->x_field = $post[$postKey . 'x_field'][$key];
71
-                $aorChart->y_field = $post[$postKey . 'y_field'][$key];
68
+                $aorChart->name = $post[$postKey.'title'][$key];
69
+                $aorChart->type = $post[$postKey.'type'][$key];
70
+                $aorChart->x_field = $post[$postKey.'x_field'][$key];
71
+                $aorChart->y_field = $post[$postKey.'y_field'][$key];
72 72
                 $aorChart->aor_report_id = $bean->id;
73 73
                 $aorChart->save();
74 74
                 $seenIds[] = $aorChart->id;
75 75
             }
76 76
         }
77 77
         //Any beans that exist but aren't in $seenIds must have been removed.
78
-        foreach($bean->get_linked_beans('aor_charts','AOR_Charts') as $chart){
79
-            if(!in_array($chart->id,$seenIds)){
78
+        foreach ($bean->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) {
79
+            if (!in_array($chart->id, $seenIds)) {
80 80
                 $chart->mark_deleted($chart->id);
81 81
             }
82 82
         }
83 83
     }
84 84
 
85
-    private function getValidChartTypes(){
86
-        return array('bar','line','pie','radar','rose', 'grouped_bar', 'stacked_bar');
85
+    private function getValidChartTypes() {
86
+        return array('bar', 'line', 'pie', 'radar', 'rose', 'grouped_bar', 'stacked_bar');
87 87
     }
88 88
 
89 89
 
90
-    private function getColour($seed,$rgbArray = false){
90
+    private function getColour($seed, $rgbArray = false) {
91 91
         $hash = md5($seed);
92 92
         $r = hexdec(substr($hash, 0, 2));
93 93
         $g = hexdec(substr($hash, 2, 2));
94 94
         $b = hexdec(substr($hash, 4, 2));
95
-        if($rgbArray){
96
-            return array('R'=>$r,'G'=>$g,'B'=>$b);
95
+        if ($rgbArray) {
96
+            return array('R'=>$r, 'G'=>$g, 'B'=>$b);
97 97
         }
98 98
         $highR = $r + 10;
99 99
         $highG = $g + 10;
100 100
         $highB = $b + 10;
101
-        $main = '#'.str_pad(dechex($r),2,'0',STR_PAD_LEFT)
102
-            .str_pad(dechex($g),2,'0',STR_PAD_LEFT)
103
-            .str_pad(dechex($b),2,'0',STR_PAD_LEFT);
101
+        $main = '#'.str_pad(dechex($r), 2, '0', STR_PAD_LEFT)
102
+            .str_pad(dechex($g), 2, '0', STR_PAD_LEFT)
103
+            .str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
104 104
         $highlight = '#'.dechex($highR).dechex($highG).dechex($highB);
105
-        return array('main'=>$main,'highlight'=>$highlight);
105
+        return array('main'=>$main, 'highlight'=>$highlight);
106 106
     }
107 107
 
108
-    function buildChartImageBar($chartPicture,$recordImageMap = false){
108
+    function buildChartImageBar($chartPicture, $recordImageMap = false) {
109 109
         $scaleSettings = array("DrawSubTicks" => false, "LabelRotation" => 30, 'MinDivHeight' => 50);
110 110
         $chartPicture->drawScale($scaleSettings);
111 111
         $chartPicture->drawBarChart(array("RecordImageMap"=>$recordImageMap));
112 112
     }
113 113
 
114
-    function buildChartImagePie($chartPicture,$chartData, $reportData,$imageHeight, $imageWidth, $xName,$recordImageMap){
115
-        $PieChart = new pPie($chartPicture,$chartData);
114
+    function buildChartImagePie($chartPicture, $chartData, $reportData, $imageHeight, $imageWidth, $xName, $recordImageMap) {
115
+        $PieChart = new pPie($chartPicture, $chartData);
116 116
         $x = 0;
117
-        foreach($reportData as $row){
118
-            $PieChart->setSliceColor($x,$this->getColour($row[$xName],true));
117
+        foreach ($reportData as $row) {
118
+            $PieChart->setSliceColor($x, $this->getColour($row[$xName], true));
119 119
             $x++;
120 120
         }
121
-        $PieChart->draw2DPie($imageWidth/3,$imageHeight/2,array("Border"=>TRUE,'Radius'=>200,''=>true,"RecordImageMap"=>$recordImageMap));
122
-        $PieChart->drawPieLegend($imageWidth*0.7,$imageHeight/3, array('FontSize'=>10,"FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf",'BoxSize'=>14));
121
+        $PieChart->draw2DPie($imageWidth / 3, $imageHeight / 2, array("Border"=>TRUE, 'Radius'=>200, ''=>true, "RecordImageMap"=>$recordImageMap));
122
+        $PieChart->drawPieLegend($imageWidth * 0.7, $imageHeight / 3, array('FontSize'=>10, "FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", 'BoxSize'=>14));
123 123
     }
124 124
 
125
-    function buildChartImageLine($chartPicture, $recordImageMap = false){
126
-        $scaleSettings = array("XMargin"=>10,"YMargin"=>10,"GridR"=>200,"GridG"=>200,"GridB"=>200,'MinDivHeight' => 50,"LabelRotation" => 30);
125
+    function buildChartImageLine($chartPicture, $recordImageMap = false) {
126
+        $scaleSettings = array("XMargin"=>10, "YMargin"=>10, "GridR"=>200, "GridG"=>200, "GridB"=>200, 'MinDivHeight' => 50, "LabelRotation" => 30);
127 127
         $chartPicture->drawScale($scaleSettings);
128 128
         $chartPicture->drawLineChart(array("RecordImageMap"=>$recordImageMap));
129 129
     }
130 130
 
131
-    function buildChartImageRadar($chartPicture, $chartData,$recordImageMap){
131
+    function buildChartImageRadar($chartPicture, $chartData, $recordImageMap) {
132 132
         $SplitChart = new pRadar();
133
-        $Options = array("LabelPos"=>RADAR_LABELS_HORIZONTAL,"RecordImageMap"=>$recordImageMap);
134
-        $SplitChart->drawRadar($chartPicture,$chartData,$Options);
133
+        $Options = array("LabelPos"=>RADAR_LABELS_HORIZONTAL, "RecordImageMap"=>$recordImageMap);
134
+        $SplitChart->drawRadar($chartPicture, $chartData, $Options);
135 135
 
136 136
     }
137 137
 
138
-    public function buildChartImage(array $reportData, array $fields,$asDataURI = true, $generateImageMapId = false){
138
+    public function buildChartImage(array $reportData, array $fields, $asDataURI = true, $generateImageMapId = false) {
139 139
         global $current_user;
140 140
         require_once 'modules/AOR_Charts/lib/pChart/pChart.php';
141 141
 
142
-        if($generateImageMapId !== false){
142
+        if ($generateImageMapId !== false) {
143 143
             $generateImageMapId = $current_user->id."-".$generateImageMapId;
144 144
         }
145 145
 
146 146
         $html = '';
147
-        if(!in_array($this->type, $this->getValidChartTypes())){
147
+        if (!in_array($this->type, $this->getValidChartTypes())) {
148 148
             return $html;
149 149
         }
150 150
         $x = $fields[$this->x_field];
151 151
         $y = $fields[$this->y_field];
152
-        if(!$x || !$y){
152
+        if (!$x || !$y) {
153 153
             //Malformed chart object - missing an axis field
154 154
             return '';
155 155
         }
156
-        $xName = str_replace(' ','_',$x->label) . $this->x_field;
157
-        $yName = str_replace(' ','_',$y->label) . $this->y_field;
156
+        $xName = str_replace(' ', '_', $x->label).$this->x_field;
157
+        $yName = str_replace(' ', '_', $y->label).$this->y_field;
158 158
 
159 159
         $chartData = new pData();
160 160
         $chartData->loadPalette("modules/AOR_Charts/lib/pChart/palettes/navy.color", TRUE);
161 161
         $labels = array();
162
-        foreach($reportData as $row){
163
-            $chartData->addPoints($row[$yName],'data');
164
-            $chartData->addPoints($row[$xName],'Labels');
162
+        foreach ($reportData as $row) {
163
+            $chartData->addPoints($row[$yName], 'data');
164
+            $chartData->addPoints($row[$xName], 'Labels');
165 165
             $labels[] = $row[$xName];
166 166
         }
167 167
 
168
-        $chartData->setSerieDescription("Months","Month");
168
+        $chartData->setSerieDescription("Months", "Month");
169 169
         $chartData->setAbscissa("Labels");
170 170
 
171 171
         $imageHeight = 700;
172 172
         $imageWidth = 700;
173 173
 
174
-        $chartPicture = new pImage($imageWidth,$imageHeight,$chartData);
175
-        if($generateImageMapId){
174
+        $chartPicture = new pImage($imageWidth, $imageHeight, $chartData);
175
+        if ($generateImageMapId) {
176 176
             $imageMapDir = create_cache_directory('modules/AOR_Charts/ImageMap/'.$current_user->id.'/');
177
-            $chartPicture->initialiseImageMap($generateImageMapId,IMAGE_MAP_STORAGE_FILE,$generateImageMapId,$imageMapDir);
177
+            $chartPicture->initialiseImageMap($generateImageMapId, IMAGE_MAP_STORAGE_FILE, $generateImageMapId, $imageMapDir);
178 178
         }
179 179
 
180 180
         $chartPicture->Antialias = True;
181 181
 
182
-        $chartPicture->drawFilledRectangle(0,0,$imageWidth-1,$imageHeight-1,array("R"=>240,"G"=>240,"B"=>240,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0,));
182
+        $chartPicture->drawFilledRectangle(0, 0, $imageWidth - 1, $imageHeight - 1, array("R"=>240, "G"=>240, "B"=>240, "BorderR"=>0, "BorderG"=>0, "BorderB"=>0,));
183 183
 
184
-        $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf","FontSize"=>14));
184
+        $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize"=>14));
185 185
 
186
-        $chartPicture->drawText($imageWidth/2,20,$this->name,array("R"=>0,"G"=>0,"B"=>0,'Align'=>TEXT_ALIGN_TOPMIDDLE));
187
-        $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf","FontSize"=>6));
186
+        $chartPicture->drawText($imageWidth / 2, 20, $this->name, array("R"=>0, "G"=>0, "B"=>0, 'Align'=>TEXT_ALIGN_TOPMIDDLE));
187
+        $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize"=>6));
188 188
 
189
-        $chartPicture->setGraphArea(60,60,$imageWidth-60,$imageHeight-100);
189
+        $chartPicture->setGraphArea(60, 60, $imageWidth - 60, $imageHeight - 100);
190 190
 
191
-        switch($this->type){
191
+        switch ($this->type) {
192 192
             case 'radar':
193 193
                 $this->buildChartImageRadar($chartPicture, $chartData, !empty($generateImageMapId));
194 194
                 break;
195 195
             case 'pie':
196
-                $this->buildChartImagePie($chartPicture,$chartData, $reportData,$imageHeight, $imageWidth, $xName, !empty($generateImageMapId));
196
+                $this->buildChartImagePie($chartPicture, $chartData, $reportData, $imageHeight, $imageWidth, $xName, !empty($generateImageMapId));
197 197
                 break;
198 198
             case 'line':
199 199
                 $this->buildChartImageLine($chartPicture, !empty($generateImageMapId));
@@ -203,50 +203,50 @@  discard block
 block discarded – undo
203 203
                 $this->buildChartImageBar($chartPicture, !empty($generateImageMapId));
204 204
                 break;
205 205
         }
206
-        if($generateImageMapId) {
206
+        if ($generateImageMapId) {
207 207
             $chartPicture->replaceImageMapTitle("data", $labels);
208 208
         }
209 209
         ob_start();
210 210
         $chartPicture->render('');
211 211
         $img = ob_get_clean();
212
-        if($asDataURI){
212
+        if ($asDataURI) {
213 213
             return 'data:image/png;base64,'.base64_encode($img);
214
-        }else{
214
+        } else {
215 215
             return $img;
216 216
         }
217 217
     }
218 218
 
219
-    public function buildChartHTML(array $reportData, array $fields,$index = 0, $chartType = AOR_Report::CHART_TYPE_PCHART, AOR_Field $mainGroupField = null){
220
-        switch($chartType){
219
+    public function buildChartHTML(array $reportData, array $fields, $index = 0, $chartType = AOR_Report::CHART_TYPE_PCHART, AOR_Field $mainGroupField = null) {
220
+        switch ($chartType) {
221 221
             case AOR_Report::CHART_TYPE_PCHART:
222
-                return $this->buildChartHTMLPChart($reportData,$fields,$index);
222
+                return $this->buildChartHTMLPChart($reportData, $fields, $index);
223 223
             case AOR_Report::CHART_TYPE_CHARTJS:
224
-                return $this->buildChartHTMLChartJS($reportData,$fields);
224
+                return $this->buildChartHTMLChartJS($reportData, $fields);
225 225
             case AOR_Report::CHART_TYPE_RGRAPH:
226
-                return $this->buildChartHTMLRGraph($reportData,$fields, $mainGroupField);
226
+                return $this->buildChartHTMLRGraph($reportData, $fields, $mainGroupField);
227 227
         }
228 228
         return '';
229 229
     }
230 230
 
231 231
 
232
-    private function buildChartHTMLRGraph(array $reportData, array $fields, AOR_Field $mainGroupField = null){
232
+    private function buildChartHTMLRGraph(array $reportData, array $fields, AOR_Field $mainGroupField = null) {
233 233
         $html = '';
234
-        if(!in_array($this->type, $this->getValidChartTypes())){
234
+        if (!in_array($this->type, $this->getValidChartTypes())) {
235 235
             return $html;
236 236
         }
237 237
         $x = $fields[$this->x_field];
238 238
         $y = $fields[$this->y_field];
239
-        if(!$x || !$y){
239
+        if (!$x || !$y) {
240 240
             //Malformed chart object - missing an axis field
241 241
             return '';
242 242
         }
243
-        $xName = str_replace(' ','_',$x->label) . $this->x_field;
244
-        $yName = str_replace(' ','_',$y->label) . $this->y_field;
243
+        $xName = str_replace(' ', '_', $x->label).$this->x_field;
244
+        $yName = str_replace(' ', '_', $y->label).$this->y_field;
245 245
 
246 246
         $defaultHeight = 500;
247 247
         $defaultWidth = 900;
248 248
 
249
-        switch($this->type){
249
+        switch ($this->type) {
250 250
             /*
251 251
              //Polar was not implemented for the previous library (it is not in the getValidChartTypes method)
252 252
             case 'polar':
@@ -257,56 +257,56 @@  discard block
 block discarded – undo
257 257
             */
258 258
             case 'radar':
259 259
                 $chartFunction = 'Radar';
260
-                $data = $this->getRGraphBarChartData($reportData, $xName,$yName);
260
+                $data = $this->getRGraphBarChartData($reportData, $xName, $yName);
261 261
                 $config = $this->getRadarChartConfig();
262
-                $chart = $this->getRGraphRadarChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth);
262
+                $chart = $this->getRGraphRadarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth);
263 263
                 break;
264 264
             case 'pie':
265 265
                 $chartFunction = 'Pie';
266
-                $data = $this->getRGraphBarChartData($reportData, $xName,$yName);
266
+                $data = $this->getRGraphBarChartData($reportData, $xName, $yName);
267 267
                 $config = $this->getPieChartConfig();
268
-                $chart = $this->getRGraphPieChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id,  $defaultHeight,$defaultWidth);
268
+                $chart = $this->getRGraphPieChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth);
269 269
                 break;
270 270
             case 'line':
271 271
                 $chartFunction = 'Line';
272
-                $data = $this->getRGraphBarChartData($reportData, $xName,$yName);
272
+                $data = $this->getRGraphBarChartData($reportData, $xName, $yName);
273 273
                 $config = $this->getLineChartConfig();
274
-                $chart = $this->getRGraphLineChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id,  $defaultHeight,$defaultWidth);
274
+                $chart = $this->getRGraphLineChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth);
275 275
                 break;
276 276
             case 'rose':
277 277
                 $chartFunction = 'Rose';
278
-                $data = $this->getRGraphBarChartData($reportData, $xName,$yName);
278
+                $data = $this->getRGraphBarChartData($reportData, $xName, $yName);
279 279
                 $config = $this->getRoseChartConfig();
280
-                $chart = $this->getRGraphRoseChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id,  $defaultHeight,$defaultWidth);
280
+                $chart = $this->getRGraphRoseChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth);
281 281
                 break;
282 282
             case 'grouped_bar':
283 283
                 $chartFunction = 'Grouped bar';
284
-                $data = $this->getRGraphGroupedBarChartData($reportData, $xName,$yName, $mainGroupField);
284
+                $data = $this->getRGraphGroupedBarChartData($reportData, $xName, $yName, $mainGroupField);
285 285
                 $config = $this->getGroupedBarChartConfig();
286
-                $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id,  $defaultHeight,$defaultWidth, true);
286
+                $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth, true);
287 287
                 break;
288 288
             case 'stacked_bar':
289 289
                 $chartFunction = 'Stacked bar';
290
-                $data = $this->getRGraphGroupedBarChartData($reportData, $xName,$yName, $mainGroupField);
290
+                $data = $this->getRGraphGroupedBarChartData($reportData, $xName, $yName, $mainGroupField);
291 291
                 $config = $this->getStackedBarChartConfig();
292
-                $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id,  $defaultHeight,$defaultWidth, false);
292
+                $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth, false);
293 293
                 break;
294 294
             case 'bar':
295 295
             default:
296 296
                 $chartFunction = 'Bar';
297
-                $data = $this->getRGraphBarChartData($reportData, $xName,$yName);
297
+                $data = $this->getRGraphBarChartData($reportData, $xName, $yName);
298 298
                 $config = $this->getBarChartConfig();
299
-                $chart = $this->getRGraphBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id,  $defaultHeight,$defaultWidth);
299
+                $chart = $this->getRGraphBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth);
300 300
                 break;
301 301
         }
302 302
 
303 303
         return $chart;
304 304
     }
305 305
 
306
-    private function getRGraphRoseChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
306
+    private function getRGraphRoseChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
307 307
     {
308 308
         $dataArray = json_decode($chartDataValues);
309
-        if(!is_array($dataArray)||count($dataArray) < 1)
309
+        if (!is_array($dataArray) || count($dataArray) < 1)
310 310
         {
311 311
             return "<h3>$this->noDataMessage</h3>";
312 312
         }
@@ -340,14 +340,14 @@  discard block
 block discarded – undo
340 340
     //I have not used a parameter for getRGraphBarChart to say whether to group etc, as the future development could be quite different
341 341
     //for both, hence the separate methods.  However, the $grouped parameter allows us to specify whether the chart is grouped (true)
342 342
     //or stacked (false)
343
-    private function getRGraphGroupedBarChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400, $grouped = false)
343
+    private function getRGraphGroupedBarChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400, $grouped = false)
344 344
     {
345 345
         //$keys = array_keys($chartTooltips);
346 346
 
347 347
 
348
-        $i=0;
349
-        foreach($chartDataValues as $rowKey => $row) {
350
-            foreach($row as $key => $value) {
348
+        $i = 0;
349
+        foreach ($chartDataValues as $rowKey => $row) {
350
+            foreach ($row as $key => $value) {
351 351
                 $_tooltips[$rowKey][$key] = $chartTooltips[$i];
352 352
                 $i++;
353 353
             }
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 
357 357
         $dataArray = json_decode($chartDataValues);
358 358
         $grouping = 'grouped'; //$mainGroupField->label; //'grouped';
359
-        if(!$grouped)
360
-            $grouping='stacked';
361
-        if(!is_array($dataArray)||count($dataArray) < 1)
359
+        if (!$grouped)
360
+            $grouping = 'stacked';
361
+        if (!is_array($dataArray) || count($dataArray) < 1)
362 362
         {
363 363
             return "<h3>$this->noDataMessage</h3>";
364 364
         }
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 
400 400
 
401 401
 
402
-    private function getRGraphBarChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
402
+    private function getRGraphBarChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
403 403
     {
404 404
         $dataArray = json_decode($chartDataValues);
405
-        if(!is_array($dataArray)||count($dataArray) < 1)
405
+        if (!is_array($dataArray) || count($dataArray) < 1)
406 406
         {
407 407
             return "<h3>$this->noDataMessage</h3>";
408 408
         }
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
         return $html;
440 440
     }
441 441
 
442
-    private function getRGraphRadarChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
442
+    private function getRGraphRadarChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
443 443
     {
444 444
         $dataArray = json_decode($chartDataValues);
445
-        if(!is_array($dataArray)||count($dataArray) < 1)
445
+        if (!is_array($dataArray) || count($dataArray) < 1)
446 446
         {
447 447
             return "<h3>$this->noDataMessage</h3>";
448 448
         }
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
         return $html;
473 473
     }
474 474
 
475
-    private function getRGraphPieChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
475
+    private function getRGraphPieChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
476 476
     {
477 477
         $dataArray = json_decode($chartDataValues);
478
-        if(!is_array($dataArray)||count($dataArray) < 1)
478
+        if (!is_array($dataArray) || count($dataArray) < 1)
479 479
         {
480 480
             return "<h3>$this->noDataMessage</h3>";
481 481
         }
@@ -508,10 +508,10 @@  discard block
 block discarded – undo
508 508
         return $html;
509 509
     }
510 510
 
511
-    private function getRGraphLineChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
511
+    private function getRGraphLineChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400)
512 512
     {
513 513
         $dataArray = json_decode($chartDataValues);
514
-        if(!is_array($dataArray)||count($dataArray) < 1)
514
+        if (!is_array($dataArray) || count($dataArray) < 1)
515 515
         {
516 516
             return "<h3>$this->noDataMessage</h3>";
517 517
         }
@@ -551,45 +551,45 @@  discard block
 block discarded – undo
551 551
         return $html;
552 552
     }
553 553
 
554
-    private function buildChartHTMLChartJS(array $reportData, array $fields){
554
+    private function buildChartHTMLChartJS(array $reportData, array $fields) {
555 555
         $html = '';
556
-        if(!in_array($this->type, $this->getValidChartTypes())){
556
+        if (!in_array($this->type, $this->getValidChartTypes())) {
557 557
             return $html;
558 558
         }
559 559
         $x = $fields[$this->x_field];
560 560
         $y = $fields[$this->y_field];
561
-        if(!$x || !$y){
561
+        if (!$x || !$y) {
562 562
             //Malformed chart object - missing an axis field
563 563
             return '';
564 564
         }
565
-        $xName = str_replace(' ','_',$x->label) . $this->x_field;
566
-        $yName = str_replace(' ','_',$y->label) . $this->y_field;
565
+        $xName = str_replace(' ', '_', $x->label).$this->x_field;
566
+        $yName = str_replace(' ', '_', $y->label).$this->y_field;
567 567
 
568
-        switch($this->type){
568
+        switch ($this->type) {
569 569
             case 'polar':
570 570
                 $chartFunction = 'PolarArea';
571
-                $data = $this->getPolarChartData($reportData, $xName,$yName);
571
+                $data = $this->getPolarChartData($reportData, $xName, $yName);
572 572
                 $config = $this->getPolarChartConfig();
573 573
                 break;
574 574
             case 'radar':
575 575
                 $chartFunction = 'Radar';
576
-                $data = $this->getRadarChartData($reportData, $xName,$yName);
576
+                $data = $this->getRadarChartData($reportData, $xName, $yName);
577 577
                 $config = $this->getRadarChartConfig();
578 578
                 break;
579 579
             case 'pie':
580 580
                 $chartFunction = 'Pie';
581
-                $data = $this->getPieChartData($reportData, $xName,$yName);
581
+                $data = $this->getPieChartData($reportData, $xName, $yName);
582 582
                 $config = $this->getPieChartConfig();
583 583
                 break;
584 584
             case 'line':
585 585
                 $chartFunction = 'Line';
586
-                $data = $this->getLineChartData($reportData, $xName,$yName);
586
+                $data = $this->getLineChartData($reportData, $xName, $yName);
587 587
                 $config = $this->getLineChartConfig();
588 588
                 break;
589 589
             case 'bar':
590 590
             default:
591 591
                 $chartFunction = 'Bar';
592
-                $data = $this->getBarChartData($reportData, $xName,$yName);
592
+                $data = $this->getBarChartData($reportData, $xName, $yName);
593 593
                 $config = $this->getBarChartConfig();
594 594
                 break;
595 595
         }
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
         return $html;
617 617
     }
618 618
 
619
-    private function buildChartHTMLPChart(array $reportData, array $fields,$index = 0){
619
+    private function buildChartHTMLPChart(array $reportData, array $fields, $index = 0) {
620 620
         $html = '';
621
-        $imgUri = $this->buildChartImage($reportData,$fields,true,$index);
621
+        $imgUri = $this->buildChartImage($reportData, $fields, true, $index);
622 622
         $img = "<img id='{$this->id}_img' src='{$imgUri}'>";
623 623
         $html .= $img;
624 624
         $html .= <<<EOF
@@ -633,24 +633,24 @@  discard block
 block discarded – undo
633 633
 
634 634
     private function getShortenedLabel($label, $maxLabelSize = 20)
635 635
     {
636
-        if(strlen($label) > $maxLabelSize)
636
+        if (strlen($label) > $maxLabelSize)
637 637
         {
638
-            return substr($label,0,$maxLabelSize).'...';
638
+            return substr($label, 0, $maxLabelSize).'...';
639 639
         }
640 640
         else
641 641
             return $label;
642 642
     }
643 643
 
644 644
 
645
-    private function getRGraphGroupedBarChartData($reportData, $xName,$yName, AOR_Field $mainGroupField = null){
645
+    private function getRGraphGroupedBarChartData($reportData, $xName, $yName, AOR_Field $mainGroupField = null) {
646 646
 
647 647
 
648 648
         // get z-axis name
649 649
 
650 650
         $zName = null;
651
-        foreach($reportData[0] as $key => $value) {
651
+        foreach ($reportData[0] as $key => $value) {
652 652
             $field = str_replace(' ', '_', is_null($mainGroupField) ? 'no data' : $mainGroupField->label);
653
-            if (preg_match('/^' . $field . '[0-9]+/', $key)) {
653
+            if (preg_match('/^'.$field.'[0-9]+/', $key)) {
654 654
                 $zName = $key;
655 655
                 break;
656 656
             }
@@ -664,20 +664,20 @@  discard block
 block discarded – undo
664 664
         $tooltips = array();
665 665
 
666 666
         $usedKeys = array();
667
-        foreach($reportData as $key => $row) {
667
+        foreach ($reportData as $key => $row) {
668 668
             $filter = $row[$xName];
669
-            foreach($reportData as $key2 => $row2) {
670
-                if($row2[$xName] == $filter && !in_array($key, $usedKeys)) {
671
-                    $data      [ $row[$xName]  ]   [] = (float) $row[$yName];
672
-                    $tooltips  [ $row[$xName]  ]   [] = $row[$zName];
669
+            foreach ($reportData as $key2 => $row2) {
670
+                if ($row2[$xName] == $filter && !in_array($key, $usedKeys)) {
671
+                    $data      [$row[$xName]]   [] = (float)$row[$yName];
672
+                    $tooltips  [$row[$xName]]   [] = $row[$zName];
673 673
                     $usedKeys[] = $key;
674 674
                 }
675 675
             }
676 676
         }
677 677
 
678 678
         $_data = array();
679
-        foreach($data as $label => $values) {
680
-            foreach($values as $key => $value) {
679
+        foreach ($data as $label => $values) {
680
+            foreach ($values as $key => $value) {
681 681
                 $_data[$label][$tooltips[$label][$key]] = $value;
682 682
             }
683 683
         }
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
         $_data = array();
690 690
         $_labels = array();
691 691
         $_tooltips = array();
692
-        foreach($data as $label => $values) {
692
+        foreach ($data as $label => $values) {
693 693
             $_labels[] = $this->getShortenedLabel($label);
694 694
             $_values = array();
695
-            foreach($values as $tooltip => $value) {
696
-                $_tooltips[] = $tooltip . " ($value)";
695
+            foreach ($values as $tooltip => $value) {
696
+                $_tooltips[] = $tooltip." ($value)";
697 697
                 $_values[] = $value;
698 698
             }
699 699
             $_data[] = $_values;
@@ -711,11 +711,11 @@  discard block
 block discarded – undo
711 711
 
712 712
     }
713 713
 
714
-    private function getRGraphBarChartData($reportData, $xName,$yName){
715
-        $chart['labels']=array();
716
-        $chart['data']=array();
717
-        $chart['tooltips']=array();
718
-        foreach($reportData as $row){
714
+    private function getRGraphBarChartData($reportData, $xName, $yName) {
715
+        $chart['labels'] = array();
716
+        $chart['data'] = array();
717
+        $chart['tooltips'] = array();
718
+        foreach ($reportData as $row) {
719 719
             $chart['labels'][] = $this->getShortenedLabel($row[$xName]);
720 720
             $chart['tooltips'][] = $row[$xName];
721 721
             $chart['data'][] = (float)$row[$yName];
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
     }
726 726
 
727 727
 
728
-    private function getBarChartData($reportData, $xName,$yName){
728
+    private function getBarChartData($reportData, $xName, $yName) {
729 729
         $data = array();
730 730
         $data['labels'] = array();
731 731
         $datasetData = array();
732
-        foreach($reportData as $row){
732
+        foreach ($reportData as $row) {
733 733
             $data['labels'][] = $row[$xName];
734 734
             $datasetData[] = $row[$yName];
735 735
         }
@@ -746,14 +746,14 @@  discard block
 block discarded – undo
746 746
         return $data;
747 747
     }
748 748
 
749
-    private function getLineChartData($reportData, $xName,$yName){
750
-        return $this->getBarChartData($reportData, $xName,$yName);
749
+    private function getLineChartData($reportData, $xName, $yName) {
750
+        return $this->getBarChartData($reportData, $xName, $yName);
751 751
     }
752 752
 
753
-    private function getBarChartConfig(){
753
+    private function getBarChartConfig() {
754 754
         return array();
755 755
     }
756
-    private function getLineChartConfig(){
756
+    private function getLineChartConfig() {
757 757
         return $this->getBarChartConfig();
758 758
     }
759 759
 
@@ -767,36 +767,36 @@  discard block
 block discarded – undo
767 767
         return $this->getBarChartConfig();
768 768
     }
769 769
 
770
-    private function getRoseChartConfig(){
770
+    private function getRoseChartConfig() {
771 771
         return $this->getBarChartConfig();
772 772
     }
773 773
 
774
-    private function getRadarChartData($reportData, $xName,$yName){
775
-        return $this->getBarChartData($reportData, $xName,$yName);
774
+    private function getRadarChartData($reportData, $xName, $yName) {
775
+        return $this->getBarChartData($reportData, $xName, $yName);
776 776
     }
777 777
 
778
-    private function getPolarChartData($reportData, $xName,$yName){
779
-        return $this->getPieChartData($reportData, $xName,$yName);
778
+    private function getPolarChartData($reportData, $xName, $yName) {
779
+        return $this->getPieChartData($reportData, $xName, $yName);
780 780
     }
781 781
 
782
-    private function getRadarChartConfig(){
782
+    private function getRadarChartConfig() {
783 783
         return array();
784 784
     }
785 785
 
786
-    private function getPolarChartConfig(){
786
+    private function getPolarChartConfig() {
787 787
         return $this->getPieChartConfig();
788 788
     }
789
-    private function getPieChartConfig(){
789
+    private function getPieChartConfig() {
790 790
         $config = array();
791 791
         $config['legendTemplate'] = "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;<%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>";
792 792
         return $config;
793 793
     }
794 794
 
795
-    private function getPieChartData($reportData, $xName,$yName){
795
+    private function getPieChartData($reportData, $xName, $yName) {
796 796
         $data = array();
797 797
 
798
-        foreach($reportData as $row){
799
-            if(!$row[$yName]){
798
+        foreach ($reportData as $row) {
799
+            if (!$row[$yName]) {
800 800
                 continue;
801 801
             }
802 802
             $colour = $this->getColour($row[$xName]);
Please login to merge, or discard this patch.
modules/AOP_Case_Updates/Case_Updates.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 
26
-function display_updates($focus, $field, $value, $view){
26
+function display_updates($focus, $field, $value, $view) {
27 27
     global $mod_strings;
28 28
 
29 29
     $hideImage = SugarThemeRegistry::current()->getImageURL('basic_search.gif');
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 </script>
128 128
 A;
129 129
 
130
-    $updates = $focus->get_linked_beans('aop_case_updates',"AOP_Case_Updates");
131
-    if(!$updates || is_null($focus->id)){
130
+    $updates = $focus->get_linked_beans('aop_case_updates', "AOP_Case_Updates");
131
+    if (!$updates || is_null($focus->id)) {
132 132
         $html .= quick_edit_case_updates($focus);
133 133
         return $html;
134 134
         //return $mod_strings['LBL_NO_CASE_UPDATES'];
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
 EOD;
155 155
 
156 156
 
157
-    usort($updates,function($a,$b){
157
+    usort($updates, function($a, $b) {
158 158
         $aDate = $a->fetched_row['date_entered'];
159 159
         $bDate = $b->fetched_row['date_entered'];
160
-        if($aDate < $bDate){
160
+        if ($aDate < $bDate) {
161 161
             return -1;
162
-        }elseif($aDate > $bDate){
162
+        }elseif ($aDate > $bDate) {
163 163
             return 1;
164 164
         }
165 165
         return 0;
166 166
     });
167 167
 
168
-    foreach($updates as $update){
168
+    foreach ($updates as $update) {
169 169
         $html .= display_single_update($update, $hideImage);
170 170
     }
171 171
     $html .= "</div>";
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 /**
179 179
  * @return mixed|string|void
180 180
  */
181
-function display_update_form(){
181
+function display_update_form() {
182 182
     global $mod_strings, $app_strings;
183
-    $sugar_smarty	= new Sugar_Smarty();
183
+    $sugar_smarty = new Sugar_Smarty();
184 184
     $sugar_smarty->assign('MOD', $mod_strings);
185 185
     $sugar_smarty->assign('APP', $app_strings);
186 186
     return $sugar_smarty->fetch('modules/AOP_Case_Updates/tpl/caseUpdateForm.tpl');
@@ -191,23 +191,23 @@  discard block
 block discarded – undo
191 191
  * @param SugarBean $update
192 192
  * @return string - html to be displayed
193 193
  */
194
-function getUpdateDisplayHead(SugarBean $update){
194
+function getUpdateDisplayHead(SugarBean $update) {
195 195
     global $mod_strings;
196
-    if($update->contact_id){
196
+    if ($update->contact_id) {
197 197
         $name = $update->getUpdateContact()->name;
198
-    }elseif($update->assigned_user_id){
198
+    }elseif ($update->assigned_user_id) {
199 199
         $name = $update->getUpdateUser()->name;
200
-    }else{
200
+    } else {
201 201
         $name = "Unknown";
202 202
     }
203 203
     $html = "<a href='' onclick='toggleCaseUpdate(\"".$update->id."\");return false;'>";
204 204
     $html .= "<img  id='caseUpdate".$update->id."Image' class='caseUpdateImage' src='".SugarThemeRegistry::current()->getImageURL('basic_search.gif')."'>";
205 205
     $html .= "</a>";
206
-    $html .= "<span>".($update->internal ? "<strong>" . $mod_strings['LBL_INTERNAL'] . "</strong> " : '') .$name . " ".$update->date_entered."</span><br>";
207
-    $notes = $update->get_linked_beans('notes','Notes');
208
-    if($notes){
209
-        $html.= $mod_strings['LBL_AOP_CASE_ATTACHMENTS'];
210
-        foreach($notes as $note){
206
+    $html .= "<span>".($update->internal ? "<strong>".$mod_strings['LBL_INTERNAL']."</strong> " : '').$name." ".$update->date_entered."</span><br>";
207
+    $notes = $update->get_linked_beans('notes', 'Notes');
208
+    if ($notes) {
209
+        $html .= $mod_strings['LBL_AOP_CASE_ATTACHMENTS'];
210
+        foreach ($notes as $note) {
211 211
             $html .= "<a href='index.php?module=Notes&action=DetailView&record={$note->id}'>{$note->filename}</a>&nbsp;";
212 212
         }
213 213
     }
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
  * @param AOP_Case_Updates $update
221 221
  * @return string - the html for the update
222 222
  */
223
-function display_single_update(AOP_Case_Updates $update){
223
+function display_single_update(AOP_Case_Updates $update) {
224 224
 
225 225
     /*if assigned user*/
226
-    if($update->assigned_user_id){
226
+    if ($update->assigned_user_id) {
227 227
         /*if internal update*/
228
-        if ($update->internal){
228
+        if ($update->internal) {
229 229
             $html = "<div id='caseStyleInternal'>".getUpdateDisplayHead($update);
230 230
             $html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>";
231 231
             $html .= nl2br(html_entity_decode($update->description));
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     }
244 244
 
245 245
     /*if contact user*/
246
-    if($update->contact_id){
246
+    if ($update->contact_id) {
247 247
         $html = "<div id='extramargin'><div id='caseStyleContact'>".getUpdateDisplayHead($update);
248 248
         $html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>";
249 249
         $html .= nl2br(html_entity_decode($update->description));
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  * @param $case
260 260
  * @return string - html link
261 261
  */
262
-function display_case_attachments($case){
262
+function display_case_attachments($case) {
263 263
     $html = '';
264
-    $notes = $case->get_linked_beans('notes','Notes');
265
-    if($notes){
266
-        foreach($notes as $note){
264
+    $notes = $case->get_linked_beans('notes', 'Notes');
265
+    if ($notes) {
266
+        foreach ($notes as $note) {
267 267
             $html .= "<a href='index.php?module=Notes&action=DetailView&record={$note->id}'>{$note->filename}</a>&nbsp;";
268 268
         }
269 269
     }
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
  *
278 278
  * @return string - the html to be displayed and javascript
279 279
  */
280
-function quick_edit_case_updates($case){
280
+function quick_edit_case_updates($case) {
281 281
     global $action;
282 282
 
283 283
     //on DetailView only
284
-    if($action != 'DetailView') return;
284
+    if ($action != 'DetailView') return;
285 285
 
286 286
     //current record id
287 287
     $record = $_GET['record'];
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
     $roles = $acl->getUserRoles($id);
295 295
 
296 296
     //Return if user cannot edit cases
297
-    if(in_array( "no edit cases", $roles) || $roles === "no edit cases"){
297
+    if (in_array("no edit cases", $roles) || $roles === "no edit cases") {
298 298
 
299 299
         return;
300 300
     }
301 301
     $internalChecked = '';
302
-    if($case->internal){
302
+    if ($case->internal) {
303 303
         $internalChecked = "checked='checked'";
304 304
     }
305 305
     $html = <<< EOD
Please login to merge, or discard this patch.
modules/AOP_Case_Updates/AOP_Case_Updates.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -30,35 +30,35 @@  discard block
 block discarded – undo
30 30
 require_once 'include/clean.php';
31 31
 class AOP_Case_Updates extends AOP_Case_Updates_sugar {
32 32
 
33
-    function AOP_Case_Updates(){
33
+    function AOP_Case_Updates() {
34 34
         parent::AOP_Case_Updates_sugar();
35 35
     }
36 36
 
37
-    function save($check_notify = false){
37
+    function save($check_notify = false) {
38 38
         $this->name = SugarCleaner::cleanHtml($this->name);
39 39
         $this->description = SugarCleaner::cleanHtml($this->description);
40 40
         global $current_user, $sugar_config;
41 41
         parent::save($check_notify);
42 42
         $email_template = new EmailTemplate();
43
-        if($_REQUEST['module'] == 'Import'){
43
+        if ($_REQUEST['module'] == 'Import') {
44 44
             //Don't send email on import
45 45
             return;
46 46
         }
47
-        if(!isAOPEnabled()){
47
+        if (!isAOPEnabled()) {
48 48
             return;
49 49
         }
50
-        if($this->internal){
50
+        if ($this->internal) {
51 51
             return;
52 52
         }
53 53
         $signature = array();
54 54
         $addDelimiter = true;
55 55
         $aop_config = $sugar_config['aop'];
56
-        if($this->assigned_user_id){
57
-            if($aop_config['contact_email_template_id']){
56
+        if ($this->assigned_user_id) {
57
+            if ($aop_config['contact_email_template_id']) {
58 58
                 $email_template = $email_template->retrieve($aop_config['contact_email_template_id']);
59 59
                 $signature = $current_user->getDefaultSignature();
60 60
             }
61
-            if($email_template) {
61
+            if ($email_template) {
62 62
                 foreach ($this->getContacts() as $contact) {
63 63
                     $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
64 64
                     $emails = array();
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
                     $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $contact->id);
67 67
                 }
68 68
             }
69
-        }else{
69
+        } else {
70 70
             $emails = $this->getEmailForUser();
71
-            if($aop_config['user_email_template_id']){
71
+            if ($aop_config['user_email_template_id']) {
72 72
                 $email_template = $email_template->retrieve($aop_config['user_email_template_id']);
73 73
             }
74 74
             $addDelimiter = false;
75
-            if($emails && $email_template){
75
+            if ($emails && $email_template) {
76 76
                 $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
77
-                $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter,$this->contact_id);
77
+                $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $this->contact_id);
78 78
             }
79 79
         }
80 80
 
@@ -83,68 +83,68 @@  discard block
 block discarded – undo
83 83
     /**
84 84
      * @return aCase
85 85
      */
86
-    public function getCase(){
87
-        $case = BeanFactory::getBean("Cases",$this->case_id);
86
+    public function getCase() {
87
+        $case = BeanFactory::getBean("Cases", $this->case_id);
88 88
         return $case;
89 89
     }
90 90
 
91
-    public function getContacts(){
91
+    public function getContacts() {
92 92
         $case = $this->getCase();
93
-        if($case){
94
-            return $case->get_linked_beans("contacts","Contacts");
93
+        if ($case) {
94
+            return $case->get_linked_beans("contacts", "Contacts");
95 95
         }
96 96
         return null;
97 97
     }
98 98
 
99
-    public function getUpdateContact(){
100
-        if($this->contact_id){
101
-            return BeanFactory::getBean("Contacts",$this->contact_id);
99
+    public function getUpdateContact() {
100
+        if ($this->contact_id) {
101
+            return BeanFactory::getBean("Contacts", $this->contact_id);
102 102
         }
103 103
         return null;
104 104
     }
105
-    public function getUser(){
106
-        $user = BeanFactory::getBean('Users',$this->getCase()->assigned_user_id);
105
+    public function getUser() {
106
+        $user = BeanFactory::getBean('Users', $this->getCase()->assigned_user_id);
107 107
         return $user;
108 108
     }
109
-    public function getUpdateUser(){
110
-        $user = BeanFactory::getBean('Users',$this->assigned_user_id);
109
+    public function getUpdateUser() {
110
+        $user = BeanFactory::getBean('Users', $this->assigned_user_id);
111 111
         return $user;
112 112
     }
113 113
 
114
-    private function getEmailForUser(){
114
+    private function getEmailForUser() {
115 115
         $user = $this->getUser();
116
-        if($user){
116
+        if ($user) {
117 117
             return array($user->emailAddress->getPrimaryAddress($user));
118 118
         }
119 119
         return array();
120 120
     }
121 121
 
122
-    private function populateTemplate(EmailTemplate $template, $addDelimiter = true, $contactId = null){
122
+    private function populateTemplate(EmailTemplate $template, $addDelimiter = true, $contactId = null) {
123 123
         global $app_strings, $sugar_config;
124 124
         //Order of beans seems to matter here so we place contact first.
125 125
         $userId = '';
126 126
         $user = $this->getUpdateUser();
127
-        if(!$user){
127
+        if (!$user) {
128 128
             $this->getUser();
129 129
         }
130
-        $beans = array("Contacts" => $contactId,"Cases" => $this->getCase()->id, "Users" => $user->id, "AOP_Case_Updates" => $this->id);
130
+        $beans = array("Contacts" => $contactId, "Cases" => $this->getCase()->id, "Users" => $user->id, "AOP_Case_Updates" => $this->id);
131 131
         $ret = array();
132
-        $ret['subject'] = from_html(aop_parse_template($template->subject,$beans));
133
-        $body = aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body_html),$beans);
134
-        $bodyAlt = aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body),$beans);
135
-        if($addDelimiter){
136
-            $body = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'] . $body;
137
-            $bodyAlt = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'] . $bodyAlt;
132
+        $ret['subject'] = from_html(aop_parse_template($template->subject, $beans));
133
+        $body = aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body_html), $beans);
134
+        $bodyAlt = aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body), $beans);
135
+        if ($addDelimiter) {
136
+            $body = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].$body;
137
+            $bodyAlt = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].$bodyAlt;
138 138
         }
139 139
         $ret['body'] = from_html($body);
140 140
         $ret['body_alt'] = strip_tags(from_html($bodyAlt));
141 141
         return $ret;
142 142
     }
143 143
 
144
-    private function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null){
144
+    private function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null) {
145 145
         $GLOBALS['log']->info("AOPCaseUpdates: sendEmail called");
146 146
         require_once("include/SugarPHPMailer.php");
147
-        $mailer=new SugarPHPMailer();
147
+        $mailer = new SugarPHPMailer();
148 148
         $admin = new Administration();
149 149
         $admin->retrieveSettings();
150 150
 
@@ -152,35 +152,35 @@  discard block
 block discarded – undo
152 152
         $mailer->setMailerForSystem();
153 153
 
154 154
         $signatureHTML = "";
155
-        if($signature && array_key_exists("signature_html",$signature)){
155
+        if ($signature && array_key_exists("signature_html", $signature)) {
156 156
             $signatureHTML = from_html($signature['signature_html']);
157 157
         }
158 158
         $signaturePlain = "";
159
-        if($signature && array_key_exists("signature",$signature)){
159
+        if ($signature && array_key_exists("signature", $signature)) {
160 160
             $signaturePlain = $signature['signature'];
161 161
         }
162 162
         $emailSettings = getPortalEmailSettings();
163 163
         $text = $this->populateTemplate($template, $addDelimiter, $contactId);
164 164
         $mailer->Subject = $text['subject'];
165
-        $mailer->Body = $text['body'] . $signatureHTML;
165
+        $mailer->Body = $text['body'].$signatureHTML;
166 166
         $mailer->IsHTML(true);
167
-        $mailer->AltBody = $text['body_alt'] . $signaturePlain;
167
+        $mailer->AltBody = $text['body_alt'].$signaturePlain;
168 168
         $mailer->From     = $emailSettings['from_address'];
169 169
         $mailer->FromName = $emailSettings['from_name'];
170
-        foreach($emails as $email){
170
+        foreach ($emails as $email) {
171 171
             $mailer->AddAddress($email);
172 172
         }
173
-        if ($mailer->Send()){
173
+        if ($mailer->Send()) {
174 174
             require_once('modules/Emails/Email.php');
175 175
             $emailObj = new Email();
176
-            $emailObj->to_addrs = implode(",",$emails);
177
-            $emailObj->type= 'out';
176
+            $emailObj->to_addrs = implode(",", $emails);
177
+            $emailObj->type = 'out';
178 178
             $emailObj->deleted = '0';
179 179
             $emailObj->name = $mailer->Subject;
180 180
             $emailObj->description = $mailer->AltBody;
181 181
             $emailObj->description_html = $mailer->Body;
182 182
             $emailObj->from_addr = $mailer->From;
183
-            if ( $caseId) {
183
+            if ($caseId) {
184 184
                 $emailObj->parent_type = "Cases";
185 185
                 $emailObj->parent_id = $caseId;
186 186
             }
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
             $emailObj->created_by = '1';
190 190
             $emailObj->status = 'sent';
191 191
             $emailObj->save();
192
-        }else{
193
-            $GLOBALS['log']->info("AOPCaseUpdates: Could not send email:  " . $mailer->ErrorInfo);
192
+        } else {
193
+            $GLOBALS['log']->info("AOPCaseUpdates: Could not send email:  ".$mailer->ErrorInfo);
194 194
             return false;
195 195
         }
196 196
         return true;
Please login to merge, or discard this patch.
modules/AOP_Case_Updates/CaseUpdatesHook.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 class CaseUpdatesHook {
26 26
     private $slug_size = 50;
27 27
 
28
-    private function getCaseCounts(){
28
+    private function getCaseCounts() {
29 29
         global $db;
30 30
         $counts = array();
31 31
         $r = $db->query("SELECT users.id,count(cases.id) AS c FROM users LEFT JOIN cases ON (cases.assigned_user_id = users.id AND cases.status != 'Closed' AND cases.status != 'Duplicate' AND cases.status != 'Rejected') WHERE NOT users.deleted GROUP BY users.id");
32
-        while($a = $db->fetchByAssoc($r)){
32
+        while ($a = $db->fetchByAssoc($r)) {
33 33
             $counts[$a['id']] = $a['c'];
34 34
         }
35 35
         return $counts;
36 36
     }
37 37
 
38
-    private function getAssignToUser(){
38
+    private function getAssignToUser() {
39 39
         require_once 'modules/AOP_Case_Updates/AOPAssignManager.php';
40 40
         $assignManager = new AOPAssignManager();
41 41
         return $assignManager->getNextAssignedUser();
42 42
     }
43 43
 
44
-    private function arrangeFilesArray(){
44
+    private function arrangeFilesArray() {
45 45
         $count = 0;
46
-        foreach($_FILES['case_update_file'] as $key => $vals){
47
-            foreach($vals as $index => $val){
48
-                if(!array_key_exists('case_update_file'.$index,$_FILES)){
46
+        foreach ($_FILES['case_update_file'] as $key => $vals) {
47
+            foreach ($vals as $index => $val) {
48
+                if (!array_key_exists('case_update_file'.$index, $_FILES)) {
49 49
                     $_FILES['case_update_file'.$index] = array();
50 50
                     $count++;
51 51
                 }
@@ -56,34 +56,34 @@  discard block
 block discarded – undo
56 56
     }
57 57
 
58 58
 
59
-    public function saveUpdate($bean, $event, $arguments){
60
-        if(!isAOPEnabled()){
59
+    public function saveUpdate($bean, $event, $arguments) {
60
+        if (!isAOPEnabled()) {
61 61
             return;
62 62
         }
63 63
         global $current_user, $app_list_strings;
64
-        if(empty($bean->fetched_row) || !$bean->id){
64
+        if (empty($bean->fetched_row) || !$bean->id) {
65 65
 
66
-            if(!$bean->state){
66
+            if (!$bean->state) {
67 67
                 $bean->state = $app_list_strings['case_state_default_key'];
68 68
             }
69
-            if($bean->status == "New"){
69
+            if ($bean->status == "New") {
70 70
                 $bean->status = $app_list_strings['case_status_default_key'];
71 71
             }
72 72
 
73 73
             //New case - assign
74
-            if(!$bean->assigned_user_id){
74
+            if (!$bean->assigned_user_id) {
75 75
                 $userId = $this->getAssignToUser();
76 76
                 $bean->assigned_user_id = $userId;
77 77
                 $bean->notify_inworkflow = true;
78 78
             }
79 79
             return;
80 80
         }
81
-        if($_REQUEST['module'] == 'Import'){
81
+        if ($_REQUEST['module'] == 'Import') {
82 82
             return;
83 83
         }
84 84
         //Grab the update field and create a new update with it.
85 85
         $text = $bean->update_text;
86
-        if(!$text && empty($_FILES['case_update_file'])){
86
+        if (!$text && empty($_FILES['case_update_file'])) {
87 87
             //No text or files, so nothing really to save.
88 88
             return;
89 89
         }
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
         $case_update->internal = $bean->internal;
94 94
         $bean->internal = false;
95 95
         $case_update->assigned_user_id = $current_user->id;
96
-        if(strlen($text) > $this->slug_size){
97
-            $case_update->name = substr($text,0,$this->slug_size)."...";
96
+        if (strlen($text) > $this->slug_size) {
97
+            $case_update->name = substr($text, 0, $this->slug_size)."...";
98 98
         }
99 99
         $case_update->description = nl2br($text);
100 100
         $case_update->case_id = $bean->id;
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 
103 103
         $fileCount = $this->arrangeFilesArray();
104 104
 
105
-        for($x = 0; $x < $fileCount; $x++){
106
-            if($_FILES['case_update_file']['error'][$x] == UPLOAD_ERR_NO_FILE){
105
+        for ($x = 0; $x < $fileCount; $x++) {
106
+            if ($_FILES['case_update_file']['error'][$x] == UPLOAD_ERR_NO_FILE) {
107 107
                 continue;
108 108
             }
109 109
             $uploadFile = new UploadFile('case_update_file'.$x);
110
-            if(!$uploadFile->confirm_upload()){
110
+            if (!$uploadFile->confirm_upload()) {
111 111
                 continue;
112 112
             }
113 113
             $note = $this->newNote($case_update->id);
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
             $uploadFile->final_move($note->id);
119 119
         }
120 120
         $postPrefix = 'case_update_id_';
121
-        foreach($_POST as $key => $val){
122
-            if(strpos($key, $postPrefix) !== 0 || empty($val)){
121
+        foreach ($_POST as $key => $val) {
122
+            if (strpos($key, $postPrefix) !== 0 || empty($val)) {
123 123
                 continue;
124 124
             }
125 125
             //Val is selected doc id
126
-            $doc = BeanFactory::getBean('Documents',$val);
127
-            if(!$doc){
126
+            $doc = BeanFactory::getBean('Documents', $val);
127
+            if (!$doc) {
128 128
                 continue;
129 129
             }
130 130
             $note = $this->newNote($case_update->id);
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
             $note->save();
135 135
             $srcFile = "upload://{$doc->document_revision_id}";
136 136
             $destFile = "upload://{$note->id}";
137
-            copy($srcFile,$destFile);
137
+            copy($srcFile, $destFile);
138 138
         }
139 139
     }
140 140
 
141
-    private function newNote($caseUpdateId){
141
+    private function newNote($caseUpdateId) {
142 142
         $note = BeanFactory::newBean('Notes');
143 143
         $note->parent_type = 'AOP_Case_Updates';
144 144
         $note->parent_id = $caseUpdateId;
@@ -146,30 +146,30 @@  discard block
 block discarded – undo
146 146
         return $note;
147 147
     }
148 148
 
149
-    private function linkAccountAndCase($case_id,$account_id){
150
-        if(!$account_id || !$case_id){
149
+    private function linkAccountAndCase($case_id, $account_id) {
150
+        if (!$account_id || !$case_id) {
151 151
             return;
152 152
         }
153
-        $case = BeanFactory::getBean("Cases",$case_id);
154
-        if(!$case->account_id){
153
+        $case = BeanFactory::getBean("Cases", $case_id);
154
+        if (!$case->account_id) {
155 155
             $case->account_id = $account_id;
156 156
             $case->save();
157 157
         }
158 158
     }
159 159
 
160
-    public function assignAccount($bean, $event, $arguments){
161
-        if($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts"){
160
+    public function assignAccount($bean, $event, $arguments) {
161
+        if ($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts") {
162 162
             return;
163 163
         }
164
-        if(!isAOPEnabled()){
164
+        if (!isAOPEnabled()) {
165 165
             return;
166 166
         }
167
-        $contact = BeanFactory::getBean("Contacts",$arguments['related_id']);
167
+        $contact = BeanFactory::getBean("Contacts", $arguments['related_id']);
168 168
         $contact->load_relationship("accounts");
169
-        if(!$contact || !$contact->account_id){
169
+        if (!$contact || !$contact->account_id) {
170 170
             return;
171 171
         }
172
-        $this->linkAccountAndCase($bean->id,$contact->account_id);
172
+        $this->linkAccountAndCase($bean->id, $contact->account_id);
173 173
     }
174 174
 
175 175
     /**
@@ -178,26 +178,26 @@  discard block
 block discarded – undo
178 178
      * @param $event
179 179
      * @param $arguments
180 180
      */
181
-    public function saveEmailUpdate($bean, $event, $arguments){
181
+    public function saveEmailUpdate($bean, $event, $arguments) {
182 182
         global $mod_strings;
183
-        if($bean->intent != "createcase" || $bean->parent_type != "Cases"){
183
+        if ($bean->intent != "createcase" || $bean->parent_type != "Cases") {
184 184
             $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate: Not a create case or wrong parent type");
185 185
             return;
186 186
         }
187
-        if(!isAOPEnabled()){
187
+        if (!isAOPEnabled()) {
188 188
             return;
189 189
         }
190
-        if(!$bean->parent_id ){
190
+        if (!$bean->parent_id) {
191 191
             $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate No parent id");
192 192
             return;
193 193
         }
194 194
 
195
-        if($bean->cases){
195
+        if ($bean->cases) {
196 196
             $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate cases already set");
197 197
             return;
198 198
         }
199 199
 
200
-        if($bean->fetched_row['parent_id']){
200
+        if ($bean->fetched_row['parent_id']) {
201 201
             //Will have been processed already
202 202
             return;
203 203
         }
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
         $ea = new SugarEmailAddress();
207 207
         $beans = $ea->getBeansByEmailAddress($bean->from_addr);
208 208
         $contact_id = null;
209
-        foreach($beans as $emailBean){
210
-            if($emailBean->module_name == "Contacts" && !empty($emailBean->id)){
209
+        foreach ($beans as $emailBean) {
210
+            if ($emailBean->module_name == "Contacts" && !empty($emailBean->id)) {
211 211
                 $contact_id = $emailBean->id;
212
-                $this->linkAccountAndCase($bean->parent_id,$emailBean->account_id);
212
+                $this->linkAccountAndCase($bean->parent_id, $emailBean->account_id);
213 213
             }
214 214
         }
215 215
         $case_update = new AOP_Case_Updates();
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
         $case_update->internal = false;
221 221
         $case_update->case_id = $bean->parent_id;
222 222
         $case_update->save();
223
-        $notes = $bean->get_linked_beans('notes','Notes');
224
-        foreach($notes as $note){
223
+        $notes = $bean->get_linked_beans('notes', 'Notes');
224
+        foreach ($notes as $note) {
225 225
             //Link notes to case update also
226 226
             $newNote = BeanFactory::newBean('Notes');
227 227
             $newNote->name = $note->name;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             $newNote->save();
233 233
             $srcFile = "upload://{$note->id}";
234 234
             $destFile = "upload://{$newNote->id}";
235
-            copy($srcFile,$destFile);
235
+            copy($srcFile, $destFile);
236 236
         }
237 237
 
238 238
         $this->updateCaseStatus($case_update->case_id);
@@ -242,71 +242,71 @@  discard block
 block discarded – undo
242 242
      * Changes the status of the supplied case based on the case_status_changes config values.
243 243
      * @param $caseId
244 244
      */
245
-    private function updateCaseStatus($caseId){
245
+    private function updateCaseStatus($caseId) {
246 246
         global $sugar_config;
247
-        if(empty($caseId)){
247
+        if (empty($caseId)) {
248 248
             return;
249 249
         }
250
-        if(empty($sugar_config['aop']['case_status_changes'])){
250
+        if (empty($sugar_config['aop']['case_status_changes'])) {
251 251
             return;
252 252
         }
253
-        $statusMap = json_decode($sugar_config['aop']['case_status_changes'],1);
254
-        if(empty($statusMap)){
253
+        $statusMap = json_decode($sugar_config['aop']['case_status_changes'], 1);
254
+        if (empty($statusMap)) {
255 255
             return;
256 256
         }
257
-        $case = BeanFactory::getBean('Cases',$caseId);
258
-        if(empty($case)){
257
+        $case = BeanFactory::getBean('Cases', $caseId);
258
+        if (empty($case)) {
259 259
             return;
260 260
         }
261
-        if(array_key_exists($case->status,$statusMap)){
261
+        if (array_key_exists($case->status, $statusMap)) {
262 262
             $case->status = $statusMap[$case->status];
263
-            $statusBits = explode('_',$case->status);
263
+            $statusBits = explode('_', $case->status);
264 264
             $case->state = array_shift($statusBits);
265 265
             $case->save();
266 266
         }
267 267
 
268 268
     }
269 269
 
270
-    private function unquoteEmail($text){
270
+    private function unquoteEmail($text) {
271 271
         global $app_strings;
272 272
         $text = html_entity_decode($text);
273
-        $text = preg_replace('/(\r\n|\r|\n)/s',"\n",$text);
274
-        $pos = strpos($text,$app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER']);
275
-        if($pos !== false){
276
-            $text = substr($text,0,$pos);
273
+        $text = preg_replace('/(\r\n|\r|\n)/s', "\n", $text);
274
+        $pos = strpos($text, $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER']);
275
+        if ($pos !== false) {
276
+            $text = substr($text, 0, $pos);
277 277
         }
278 278
         return $text;
279 279
     }
280 280
 
281
-    public function closureNotifyPrep($bean, $event, $arguments){
282
-        if($_REQUEST['module'] == 'Import'){
281
+    public function closureNotifyPrep($bean, $event, $arguments) {
282
+        if ($_REQUEST['module'] == 'Import') {
283 283
             return;
284 284
         }
285
-        if($bean->state!= "Closed" || $bean->fetched_row['state'] == "Closed"){
285
+        if ($bean->state != "Closed" || $bean->fetched_row['state'] == "Closed") {
286 286
             $bean->send_closure_email = false;
287
-        }else{
287
+        } else {
288 288
             $bean->send_closure_email = true;
289 289
         }
290 290
 
291 291
     }
292 292
 
293
-    public function closureNotify($bean, $event, $arguments){
294
-        if($_REQUEST['module'] == 'Import'){
293
+    public function closureNotify($bean, $event, $arguments) {
294
+        if ($_REQUEST['module'] == 'Import') {
295 295
             return;
296 296
         }
297
-        if($bean->state != "Closed" || !$bean->send_closure_email){
297
+        if ($bean->state != "Closed" || !$bean->send_closure_email) {
298 298
             return;
299 299
         }
300 300
         $this->sendClosureEmail($bean, $arguments['related_bean']);
301 301
     }
302 302
 
303
-    private function sendClosureEmail(aCase $bean){
304
-        if(!isAOPEnabled()){
303
+    private function sendClosureEmail(aCase $bean) {
304
+        if (!isAOPEnabled()) {
305 305
             return;
306 306
         }
307 307
         $GLOBALS['log']->warn("CaseUpdatesHook: sendClosureEmail called");
308 308
         require_once("include/SugarPHPMailer.php");
309
-        $mailer=new SugarPHPMailer();
309
+        $mailer = new SugarPHPMailer();
310 310
         $admin = new Administration();
311 311
         $admin->retrieveSettings();
312 312
 
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
         $aop_config = $this->getAOPConfig();
318 318
         $email_template = $email_template->retrieve($aop_config['case_closure_email_template_id']);
319 319
 
320
-        if(!$email_template){
320
+        if (!$email_template) {
321 321
             $GLOBALS['log']->warn("CaseUpdatesHook: sendClosureEmail template is empty");
322 322
             return false;
323 323
         }
324 324
 
325
-        $contact = $bean->get_linked_beans("contacts","Contact");
326
-        if($contact){
325
+        $contact = $bean->get_linked_beans("contacts", "Contact");
326
+        if ($contact) {
327 327
             $contact = $contact[0];
328
-        }else{
328
+        } else {
329 329
             return false;
330 330
         }
331 331
 
@@ -342,10 +342,10 @@  discard block
 block discarded – undo
342 342
         $email = $contact->emailAddress->getPrimaryAddress($contact);
343 343
 
344 344
         $mailer->AddAddress($email);
345
-        if (!$mailer->Send()){
346
-            $GLOBALS['log']->info("CaseUpdatesHook: Could not send email:  " . $mailer->ErrorInfo);
345
+        if (!$mailer->Send()) {
346
+            $GLOBALS['log']->info("CaseUpdatesHook: Could not send email:  ".$mailer->ErrorInfo);
347 347
             return false;
348
-        }else{
348
+        } else {
349 349
             $this->logEmail($email, $mailer, $bean->id);
350 350
             return true;
351 351
         }
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
      * @param $event
359 359
      * @param $arguments
360 360
      */
361
-    public function creationNotify($bean, $event, $arguments){
362
-        if($_REQUEST['module'] == 'Import'){
361
+    public function creationNotify($bean, $event, $arguments) {
362
+        if ($_REQUEST['module'] == 'Import') {
363 363
             return;
364 364
         }
365
-        if($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts"){
365
+        if ($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts") {
366 366
             return;
367 367
         }
368
-        if(!$bean->fetched_row){
368
+        if (!$bean->fetched_row) {
369 369
             return;
370 370
         }
371
-        if(!empty($arguments['related_bean'])){
371
+        if (!empty($arguments['related_bean'])) {
372 372
             $contact = $arguments['related_bean'];
373
-        }else{
374
-            $contact = BeanFactory::getBean("Contacts",$arguments['related_id']);
373
+        } else {
374
+            $contact = BeanFactory::getBean("Contacts", $arguments['related_id']);
375 375
         }
376 376
         $this->sendCreationEmail($bean, $contact);
377 377
     }
378 378
 
379
-    private function populateTemplate(EmailTemplate $template, aCase $bean, $contact){
379
+    private function populateTemplate(EmailTemplate $template, aCase $bean, $contact) {
380 380
         global $app_strings, $sugar_config;
381 381
         //Order of beans seems to matter here so we place contact first.
382 382
         $beans = array(
@@ -385,26 +385,26 @@  discard block
 block discarded – undo
385 385
             "Users" => $bean->assigned_user_id
386 386
         );
387 387
         $ret = array();
388
-        $ret['subject'] = from_html(aop_parse_template($template->subject,$beans));
389
-        $ret['body'] = from_html($app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body_html),$beans));
390
-        $ret['body_alt'] = strip_tags(from_html(aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body),$beans)));
388
+        $ret['subject'] = from_html(aop_parse_template($template->subject, $beans));
389
+        $ret['body'] = from_html($app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body_html), $beans));
390
+        $ret['body_alt'] = strip_tags(from_html(aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body), $beans)));
391 391
         return $ret;
392 392
     }
393 393
 
394
-    private function getAOPConfig(){
394
+    private function getAOPConfig() {
395 395
         global $sugar_config;
396
-        if(!array_key_exists("aop",$sugar_config)){
396
+        if (!array_key_exists("aop", $sugar_config)) {
397 397
             return array();
398 398
         }
399 399
         return $sugar_config['aop'];
400 400
     }
401 401
 
402
-    private function sendCreationEmail(aCase $bean, $contact){
403
-        if(!isAOPEnabled()){
402
+    private function sendCreationEmail(aCase $bean, $contact) {
403
+        if (!isAOPEnabled()) {
404 404
             return;
405 405
         }
406 406
         require_once("include/SugarPHPMailer.php");
407
-        $mailer=new SugarPHPMailer();
407
+        $mailer = new SugarPHPMailer();
408 408
         $admin = new Administration();
409 409
         $admin->retrieveSettings();
410 410
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 
416 416
         $aop_config = $this->getAOPConfig();
417 417
         $email_template = $email_template->retrieve($aop_config['case_creation_email_template_id']);
418
-        if(!$aop_config['case_creation_email_template_id'] || !$email_template){
418
+        if (!$aop_config['case_creation_email_template_id'] || !$email_template) {
419 419
             $GLOBALS['log']->warn("CaseUpdatesHook: sendCreationEmail template is empty");
420 420
             return false;
421 421
         }
@@ -429,24 +429,24 @@  discard block
 block discarded – undo
429 429
         $mailer->From     = $emailSettings['from_address'];
430 430
         $mailer->FromName = $emailSettings['from_name'];
431 431
         $email = $contact->emailAddress->getPrimaryAddress($contact);
432
-        if(empty($email) && !empty($contact->email1)){
432
+        if (empty($email) && !empty($contact->email1)) {
433 433
             $email = $contact->email1;
434 434
         }
435 435
         $mailer->AddAddress($email);
436
-        if (!$mailer->Send()){
437
-            $GLOBALS['log']->info("CaseUpdatesHook: Could not send email:  " . $mailer->ErrorInfo);
436
+        if (!$mailer->Send()) {
437
+            $GLOBALS['log']->info("CaseUpdatesHook: Could not send email:  ".$mailer->ErrorInfo);
438 438
             return false;
439
-        }else{
439
+        } else {
440 440
             $this->logEmail($email, $mailer, $bean->id);
441 441
             return true;
442 442
         }
443 443
     }
444 444
 
445
-    private function logEmail($email, $mailer, $caseId = null){
445
+    private function logEmail($email, $mailer, $caseId = null) {
446 446
         require_once('modules/Emails/Email.php');
447 447
         $emailObj = new Email();
448 448
         $emailObj->to_addrs = $email;
449
-        $emailObj->type= 'out';
449
+        $emailObj->type = 'out';
450 450
         $emailObj->deleted = '0';
451 451
         $emailObj->name = $mailer->Subject;
452 452
         $emailObj->description = $mailer->AltBody;
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         $emailObj->save();
464 464
     }
465 465
 
466
-    public function filterHTML($bean, $event, $arguments){
467
-        $bean->description = SugarCleaner::cleanHtml($bean->description,true);
466
+    public function filterHTML($bean, $event, $arguments) {
467
+        $bean->description = SugarCleaner::cleanHtml($bean->description, true);
468 468
     }
469 469
 }
Please login to merge, or discard this patch.
modules/AOR_Fields/AOR_Field.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 
83 83
         require_once('modules/AOW_WorkFlow/aow_utils.php');
84 84
 
85
-        $line_count = count($post_data[$key . 'field']);
85
+        $line_count = count($post_data[$key.'field']);
86 86
         for ($i = 0; $i < $line_count; ++$i) {
87 87
 
88
-            if ($post_data[$key . 'deleted'][$i] == 1) {
89
-                $this->mark_deleted($post_data[$key . 'id'][$i]);
88
+            if ($post_data[$key.'deleted'][$i] == 1) {
89
+                $this->mark_deleted($post_data[$key.'id'][$i]);
90 90
             } else {
91 91
                 $field = new AOR_Field();
92 92
                 $field->group_display = false;
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
 
103 103
                 foreach ($this->field_defs as $field_def) {
104 104
                     $field_name = $field_def['name'];
105
-                    if (is_array($post_data[$key . $field_name])) {
106
-                        if ($field_name != 'group_display' && isset($post_data[$key . $field_name][$i])) {
107
-                            if (is_array($post_data[$key . $field_name][$i])) {
108
-                                $post_data[$key . $field_name][$i] = base64_encode(serialize($post_data[$key . $field_name][$i]));
105
+                    if (is_array($post_data[$key.$field_name])) {
106
+                        if ($field_name != 'group_display' && isset($post_data[$key.$field_name][$i])) {
107
+                            if (is_array($post_data[$key.$field_name][$i])) {
108
+                                $post_data[$key.$field_name][$i] = base64_encode(serialize($post_data[$key.$field_name][$i]));
109 109
                             } else if ($field_name == 'value') {
110
-                                $post_data[$key . $field_name][$i] = fixUpFormatting($_REQUEST['report_module'], $field->field, $post_data[$key . $field_name][$i]);
110
+                                $post_data[$key.$field_name][$i] = fixUpFormatting($_REQUEST['report_module'], $field->field, $post_data[$key.$field_name][$i]);
111 111
                             }
112 112
                             if ($field_name == 'module_path') {
113
-                                $post_data[$key . $field_name][$i] = base64_encode(serialize(explode(":", $post_data[$key . $field_name][$i])));
113
+                                $post_data[$key.$field_name][$i] = base64_encode(serialize(explode(":", $post_data[$key.$field_name][$i])));
114 114
                             }
115
-                            $field->$field_name = $post_data[$key . $field_name][$i];
115
+                            $field->$field_name = $post_data[$key.$field_name][$i];
116 116
                         }
117
-                    } else if (is_null($post_data[$key . $field_name])) {
117
+                    } else if (is_null($post_data[$key.$field_name])) {
118 118
                         // do nothing
119 119
                     } else {
120
-                        throw new Exception('illegal type in post data at key ' . $key . $field_name . ' ' . gettype($post_data[$key . $field_name]));
120
+                        throw new Exception('illegal type in post data at key '.$key.$field_name.' '.gettype($post_data[$key.$field_name]));
121 121
                     }
122 122
 
123 123
                 }
Please login to merge, or discard this patch.