Completed
Push — master ( 97ae17...26fbd7 )
by Adam
18:33
created
include/ListView/ListViewData.php 1 patch
Spacing   +104 added lines, -104 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.
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	function getOrderBy($orderBy = '', $direction = '') {
77 77
 		if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
78
-            if(!empty($_REQUEST[$this->var_order_by])) {
78
+            if (!empty($_REQUEST[$this->var_order_by])) {
79 79
     			$direction = 'ASC';
80 80
     			$orderBy = $_REQUEST[$this->var_order_by];
81
-    			if(!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0) ){
81
+    			if (!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0)) {
82 82
     				$direction = $_REQUEST['lvso'];
83 83
     			}
84 84
             }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         }
88 88
 		else {
89 89
             $userPreferenceOrder = $GLOBALS['current_user']->getPreference('listviewOrder', $this->var_name);
90
-			if(!empty($_SESSION[$this->var_order_by])) {
90
+			if (!empty($_SESSION[$this->var_order_by])) {
91 91
 				$orderBy = $_SESSION[$this->var_order_by]['orderBy'];
92 92
 				$direction = $_SESSION[$this->var_order_by]['direction'];
93 93
             } elseif (!empty($userPreferenceOrder)) {
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 				$direction = 'DESC';
99 99
 			}
100 100
 		}
101
-		if(!empty($direction)) {
102
-    		if(strtolower($direction) == "desc") {
101
+		if (!empty($direction)) {
102
+    		if (strtolower($direction) == "desc") {
103 103
     		    $direction = 'DESC';
104 104
     		} else {
105 105
     		    $direction = 'ASC';
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @param STRING (ASC or DESC) $current_order
115 115
 	 * @return  STRING (ASC or DESC)
116 116
 	 */
117
-	function getReverseSortOrder($current_order){
118
-		return (strcmp(strtolower($current_order), 'asc') == 0)?'DESC':'ASC';
117
+	function getReverseSortOrder($current_order) {
118
+		return (strcmp(strtolower($current_order), 'asc') == 0) ? 'DESC' : 'ASC';
119 119
 	}
120 120
 	/**
121 121
 	 * gets the limit of how many rows to show per page
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
     {
146 146
         global $beanList;
147 147
 
148
-        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount',$this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
149
-        foreach($beanList as $bean)
148
+        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', $this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
149
+        foreach ($beanList as $bean)
150 150
         {
151 151
             $blockVariables[] = 'Home2_'.strtoupper($bean).'_ORDER_BY';
152 152
         }
@@ -164,30 +164,30 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param unknown_type $baseName
166 166
 	 */
167
-	function setVariableName($baseName, $where, $listviewName = null){
167
+	function setVariableName($baseName, $where, $listviewName = null) {
168 168
         global $timedate;
169
-        $module = (!empty($listviewName)) ? $listviewName: $_REQUEST['module'];
170
-        $this->var_name = $module .'2_'. strtoupper($baseName);
169
+        $module = (!empty($listviewName)) ? $listviewName : $_REQUEST['module'];
170
+        $this->var_name = $module.'2_'.strtoupper($baseName);
171 171
 
172
-		$this->var_order_by = $this->var_name .'_ORDER_BY';
173
-		$this->var_offset = $this->var_name . '_offset';
172
+		$this->var_order_by = $this->var_name.'_ORDER_BY';
173
+		$this->var_offset = $this->var_name.'_offset';
174 174
         $timestamp = sugar_microtime();
175 175
         $this->stamp = $timestamp;
176 176
 
177
-        $_SESSION[$module .'2_QUERY_QUERY'] = $where;
177
+        $_SESSION[$module.'2_QUERY_QUERY'] = $where;
178 178
 
179
-        $_SESSION[strtoupper($baseName) . "_FROM_LIST_VIEW"] = $timestamp;
180
-        $_SESSION[strtoupper($baseName) . "_DETAIL_NAV_HISTORY"] = false;
179
+        $_SESSION[strtoupper($baseName)."_FROM_LIST_VIEW"] = $timestamp;
180
+        $_SESSION[strtoupper($baseName)."_DETAIL_NAV_HISTORY"] = false;
181 181
 	}
182 182
 
183
-	function getTotalCount($main_query){
184
-		if(!empty($this->count_query)){
183
+	function getTotalCount($main_query) {
184
+		if (!empty($this->count_query)) {
185 185
 		    $count_query = $this->count_query;
186
-		}else{
186
+		} else {
187 187
 	        $count_query = $this->seed->create_list_count_query($main_query);
188 188
 	    }
189 189
 		$result = $this->db->query($count_query);
190
-		if($row = $this->db->fetchByAssoc($result)){
190
+		if ($row = $this->db->fetchByAssoc($result)) {
191 191
 			return $row['c'];
192 192
 		}
193 193
 		return 0;
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 	 * @param string:'id' $id_field
230 230
 	 * @return array('data'=> row data, 'pageData' => page data information, 'query' => original query string)
231 231
 	 */
232
-	function getListViewData($seed, $where, $offset=-1, $limit = -1, $filter_fields=array(),$params=array(),$id_field = 'id',$singleSelect=true) {
232
+	function getListViewData($seed, $where, $offset = -1, $limit = -1, $filter_fields = array(), $params = array(), $id_field = 'id', $singleSelect = true) {
233 233
         global $current_user;
234 234
         SugarVCR::erase($seed->module_dir);
235
-        $this->seed =& $seed;
235
+        $this->seed = & $seed;
236 236
         $totalCounted = empty($GLOBALS['sugar_config']['disable_count_query']);
237 237
         $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $seed->module_dir;
238
-        if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup'){
238
+        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
239 239
             $_SESSION['MAILMERGE_MODULE'] = $seed->module_dir;
240 240
         }
241 241
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		$this->seed->id = '[SELECT_ID_LIST]';
245 245
 
246 246
         // if $params tell us to override all ordering
247
-        if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
247
+        if (!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
248 248
             $order = $this->getOrderBy(strtolower($params['orderBy']), (empty($params['sortOrder']) ? '' : $params['sortOrder'])); // retreive from $_REQUEST
249 249
         }
250 250
         else {
@@ -252,17 +252,17 @@  discard block
 block discarded – undo
252 252
         }
253 253
 
254 254
         // still empty? try to use settings passed in $param
255
-        if(empty($order['orderBy']) && !empty($params['orderBy'])) {
255
+        if (empty($order['orderBy']) && !empty($params['orderBy'])) {
256 256
             $order['orderBy'] = $params['orderBy'];
257
-            $order['sortOrder'] =  (empty($params['sortOrder']) ? '' : $params['sortOrder']);
257
+            $order['sortOrder'] = (empty($params['sortOrder']) ? '' : $params['sortOrder']);
258 258
         }
259 259
 
260 260
         //rrs - bug: 21788. Do not use Order by stmts with fields that are not in the query.
261 261
         // Bug 22740 - Tweak this check to strip off the table name off the order by parameter.
262 262
         // Samir Gandhi : Do not remove the report_cache.date_modified condition as the report list view is broken
263 263
         $orderby = $order['orderBy'];
264
-        if (strpos($order['orderBy'],'.') && ($order['orderBy'] != "report_cache.date_modified")) {
265
-            $orderby = substr($order['orderBy'],strpos($order['orderBy'],'.')+1);
264
+        if (strpos($order['orderBy'], '.') && ($order['orderBy'] != "report_cache.date_modified")) {
265
+            $orderby = substr($order['orderBy'], strpos($order['orderBy'], '.') + 1);
266 266
         }
267 267
         if ($orderby != 'date_entered' && !in_array($orderby, array_keys($filter_fields))) {
268 268
         	$order['orderBy'] = '';
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 		if (empty($order['orderBy'])) {
273 273
             $orderBy = '';
274 274
         } else {
275
-            $orderBy = $order['orderBy'] . ' ' . $order['sortOrder'];
275
+            $orderBy = $order['orderBy'].' '.$order['sortOrder'];
276 276
             //wdong, Bug 25476, fix the sorting problem of Oracle.
277 277
             if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code'])
278
-                $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder'];
278
+                $orderBy = $params['custom_order_by_override']['custom_code'].' '.$order['sortOrder'];
279 279
         }
280 280
 
281 281
         if (empty($params['skipOrderSave'])) { // don't save preferences if told so
@@ -290,34 +290,34 @@  discard block
 block discarded – undo
290 290
 		$ret_array = $seed->create_new_list_query($orderBy, $where, $filter_fields, $params, 0, '', true, $seed, $singleSelect);
291 291
         $ret_array['inner_join'] = '';
292 292
         if (!empty($this->seed->listview_inner_join)) {
293
-            $ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' ';
293
+            $ret_array['inner_join'] = ' '.implode(' ', $this->seed->listview_inner_join).' ';
294 294
         }
295 295
 
296
-		if(!is_array($params)) $params = array();
297
-        if(!isset($params['custom_select'])) $params['custom_select'] = '';
298
-        if(!isset($params['custom_from'])) $params['custom_from'] = '';
299
-        if(!isset($params['custom_where'])) $params['custom_where'] = '';
300
-        if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
301
-		$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
296
+		if (!is_array($params)) $params = array();
297
+        if (!isset($params['custom_select'])) $params['custom_select'] = '';
298
+        if (!isset($params['custom_from'])) $params['custom_from'] = '';
299
+        if (!isset($params['custom_where'])) $params['custom_where'] = '';
300
+        if (!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
301
+		$main_query = $ret_array['select'].$params['custom_select'].$ret_array['from'].$params['custom_from'].$ret_array['inner_join'].$ret_array['where'].$params['custom_where'].$ret_array['order_by'].$params['custom_order_by'];
302 302
 		//C.L. - Fix for 23461
303
-		if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
303
+		if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
304 304
           	   $_SESSION['export_where'] = $ret_array['where'];
305 305
 		}
306
-   		if($limit < -1) {
306
+   		if ($limit < -1) {
307 307
 			$result = $this->db->query($main_query);
308 308
 		}
309 309
 		else {
310
-			if($limit == -1) {
310
+			if ($limit == -1) {
311 311
 				$limit = $this->getLimit();
312 312
             }
313 313
 			$dyn_offset = $this->getOffset();
314
-			if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
314
+			if ($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
315 315
 
316
-            if(strcmp($offset, 'end') == 0){
316
+            if (strcmp($offset, 'end') == 0) {
317 317
             	$totalCount = $this->getTotalCount($main_query);
318
-            	$offset = (floor(($totalCount -1) / $limit)) * $limit;
318
+            	$offset = (floor(($totalCount - 1) / $limit)) * $limit;
319 319
             }
320
-            if($this->seed->ACLAccess('ListView')) {
320
+            if ($this->seed->ACLAccess('ListView')) {
321 321
                 $result = $this->db->limitQuery($main_query, $offset, $limit + 1);
322 322
             }
323 323
             else {
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
         $idIndex = array();
336 336
         $id_list = '';
337 337
 
338
-   		while(($row = $this->db->fetchByAssoc($result)) != null)
338
+   		while (($row = $this->db->fetchByAssoc($result)) != null)
339 339
         {
340
-   			if($count < $limit)
340
+   			if ($count < $limit)
341 341
             {
342 342
    				$id_list .= ',\''.$row[$id_field].'\'';
343 343
    				$idIndex[$row[$id_field]][] = count($rows);
@@ -351,51 +351,51 @@  discard block
 block discarded – undo
351 351
             $id_list = '('.substr($id_list, 1).')';
352 352
         }
353 353
 
354
-        SugarVCR::store($this->seed->module_dir,  $main_query);
355
-		if($count != 0) {
354
+        SugarVCR::store($this->seed->module_dir, $main_query);
355
+		if ($count != 0) {
356 356
 			//NOW HANDLE SECONDARY QUERIES
357
-			if(!empty($ret_array['secondary_select'])) {
358
-				$secondary_query = $ret_array['secondary_select'] . $ret_array['secondary_from'] . ' WHERE '.$this->seed->table_name.'.id IN ' .$id_list;
359
-                if(isset($ret_array['order_by']))
357
+			if (!empty($ret_array['secondary_select'])) {
358
+				$secondary_query = $ret_array['secondary_select'].$ret_array['secondary_from'].' WHERE '.$this->seed->table_name.'.id IN '.$id_list;
359
+                if (isset($ret_array['order_by']))
360 360
                 {
361
-                    $secondary_query .= ' ' . $ret_array['order_by'];
361
+                    $secondary_query .= ' '.$ret_array['order_by'];
362 362
                 }
363 363
 
364 364
                 $secondary_result = $this->db->query($secondary_query);
365 365
 
366 366
                 $ref_id_count = array();
367
-				while($row = $this->db->fetchByAssoc($secondary_result)) {
367
+				while ($row = $this->db->fetchByAssoc($secondary_result)) {
368 368
 
369 369
                     $ref_id_count[$row['ref_id']][] = true;
370
-					foreach($row as $name=>$value) {
370
+					foreach ($row as $name=>$value) {
371 371
 						//add it to every row with the given id
372
-						foreach($idIndex[$row['ref_id']] as $index){
373
-						    $rows[$index][$name]=$value;
372
+						foreach ($idIndex[$row['ref_id']] as $index) {
373
+						    $rows[$index][$name] = $value;
374 374
 						}
375 375
 					}
376 376
 				}
377 377
 
378 378
                 $rows_keys = array_keys($rows);
379
-                foreach($rows_keys as $key)
379
+                foreach ($rows_keys as $key)
380 380
                 {
381 381
                     $rows[$key]['secondary_select_count'] = count($ref_id_count[$rows[$key]['ref_id']]);
382 382
                 }
383 383
 			}
384 384
 
385 385
             // retrieve parent names
386
-            if(!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
387
-                foreach($idIndex as $id => $rowIndex) {
388
-                    if(!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
386
+            if (!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
387
+                foreach ($idIndex as $id => $rowIndex) {
388
+                    if (!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
389 389
                         $post_retrieve[$rows[$rowIndex[0]]['parent_type']] = array();
390 390
                     }
391
-                    if(!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
391
+                    if (!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id, 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
392 392
                 }
393
-                if(isset($post_retrieve)) {
393
+                if (isset($post_retrieve)) {
394 394
                     $parent_fields = $seed->retrieve_parent_fields($post_retrieve);
395
-                    foreach($parent_fields as $child_id => $parent_data) {
395
+                    foreach ($parent_fields as $child_id => $parent_data) {
396 396
                         //add it to every row with the given id
397
-						foreach($idIndex[$child_id] as $index){
398
-						    $rows[$index]['parent_name']= $parent_data['parent_name'];
397
+						foreach ($idIndex[$child_id] as $index) {
398
+						    $rows[$index]['parent_name'] = $parent_data['parent_name'];
399 399
 						}
400 400
                     }
401 401
                 }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$pageData = array();
405 405
 
406 406
 			reset($rows);
407
-			while($row = current($rows)){
407
+			while ($row = current($rows)) {
408 408
 
409 409
                 $temp = clone $seed;
410 410
 			    $dataIndex = count($data);
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 				if (empty($this->seed->assigned_user_id) && !empty($temp->assigned_user_id)) {
415 415
 				    $this->seed->assigned_user_id = $temp->assigned_user_id;
416 416
 				}
417
-				if($idIndex[$row[$id_field]][0] == $dataIndex){
417
+				if ($idIndex[$row[$id_field]][0] == $dataIndex) {
418 418
 				    $pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
419
-				}else{
419
+				} else {
420 420
 				    $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
421 421
 				}
422 422
 				$data[$dataIndex] = $temp->get_list_view_data($filter_fields);
@@ -424,21 +424,21 @@  discard block
 block discarded – undo
424 424
                 $editViewAccess = $temp->ACLAccess('EditView');
425 425
                 $pageData['rowAccess'][$dataIndex] = array('view' => $detailViewAccess, 'edit' => $editViewAccess);
426 426
                 $additionalDetailsAllow = $this->additionalDetails && $detailViewAccess && (file_exists(
427
-                         'modules/' . $temp->module_dir . '/metadata/additionalDetails.php'
428
-                     ) || file_exists('custom/modules/' . $temp->module_dir . '/metadata/additionalDetails.php'));
427
+                         'modules/'.$temp->module_dir.'/metadata/additionalDetails.php'
428
+                     ) || file_exists('custom/modules/'.$temp->module_dir.'/metadata/additionalDetails.php'));
429 429
                 $additionalDetailsEdit = $editViewAccess;
430
-                if($additionalDetailsAllow) {
431
-                    if($this->additionalDetailsAjax) {
430
+                if ($additionalDetailsAllow) {
431
+                    if ($this->additionalDetailsAjax) {
432 432
 					   $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
433 433
                     }
434 434
                     else {
435
-                        $additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
436
-                        if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){
437
-                        	$additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
435
+                        $additionalDetailsFile = 'modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php';
436
+                        if (file_exists('custom/modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php')) {
437
+                        	$additionalDetailsFile = 'custom/modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php';
438 438
                         }
439 439
                         require_once($additionalDetailsFile);
440 440
                         $ar = $this->getAdditionalDetails($data[$dataIndex],
441
-                                    (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $this->seed->object_name,
441
+                                    (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction).$this->seed->object_name,
442 442
                                     $additionalDetailsEdit);
443 443
                     }
444 444
                     $pageData['additionalDetails'][$dataIndex] = $ar['string'];
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
 		$nextOffset = -1;
451 451
 		$prevOffset = -1;
452 452
 		$endOffset = -1;
453
-		if($count > $limit) {
453
+		if ($count > $limit) {
454 454
 			$nextOffset = $offset + $limit;
455 455
 		}
456 456
 
457
-		if($offset > 0) {
457
+		if ($offset > 0) {
458 458
 			$prevOffset = $offset - $limit;
459
-			if($prevOffset < 0)$prevOffset = 0;
459
+			if ($prevOffset < 0)$prevOffset = 0;
460 460
 		}
461 461
 		$totalCount = $count + $offset;
462 462
 
463
-		if( $count >= $limit && $totalCounted){
464
-			$totalCount  = $this->getTotalCount($main_query);
463
+		if ($count >= $limit && $totalCounted) {
464
+			$totalCount = $this->getTotalCount($main_query);
465 465
 		}
466 466
 		SugarVCR::recordIDs($this->seed->module_dir, array_keys($idIndex), $offset, $totalCount);
467 467
         $module_names = array(
@@ -471,21 +471,21 @@  discard block
 block discarded – undo
471 471
 		$pageData['ordering'] = $order;
472 472
 		$pageData['ordering']['sortOrder'] = $this->getReverseSortOrder($pageData['ordering']['sortOrder']);
473 473
         //get url parameters as an array
474
-        $pageData['queries'] = $this->generateQueries($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset,  $endOffset, $totalCounted);
474
+        $pageData['queries'] = $this->generateQueries($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset, $endOffset, $totalCounted);
475 475
         //join url parameters from array to a string
476 476
         $pageData['urls'] = $this->generateURLS($pageData['queries']);
477
-		$pageData['offsets'] = array( 'current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
477
+		$pageData['offsets'] = array('current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
478 478
 		$pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir, 'moduleName' => strtr($seed->module_dir, $module_names));
479 479
         $pageData['stamp'] = $this->stamp;
480 480
         $pageData['access'] = array('view' => $this->seed->ACLAccess('DetailView'), 'edit' => $this->seed->ACLAccess('EditView'));
481 481
 		$pageData['idIndex'] = $idIndex;
482
-        if(!$this->seed->ACLAccess('ListView')) {
482
+        if (!$this->seed->ACLAccess('ListView')) {
483 483
             $pageData['error'] = 'ACL restricted access';
484 484
         }
485 485
 
486 486
         $queryString = '';
487 487
 
488
-        if( isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "advanced_search" ||
488
+        if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "advanced_search" ||
489 489
         	isset($_REQUEST["type_basic"]) && (count($_REQUEST["type_basic"] > 1) || $_REQUEST["type_basic"][0] != "") ||
490 490
         	isset($_REQUEST["module"]) && $_REQUEST["module"] == "MergeRecords")
491 491
         {
@@ -493,19 +493,19 @@  discard block
 block discarded – undo
493 493
         }
494 494
         else if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "basic_search")
495 495
         {
496
-            if($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
496
+            if ($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
497 497
             else $searchMetaData = SearchForm::retrieveSearchDefs($seed->module_dir);
498 498
 
499 499
             $basicSearchFields = array();
500 500
 
501
-            if( isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']) )
501
+            if (isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']))
502 502
                 $basicSearchFields = $searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search'];
503 503
 
504
-            foreach( $basicSearchFields as $basicSearchField)
504
+            foreach ($basicSearchFields as $basicSearchField)
505 505
             {
506 506
                 $field_name = (is_array($basicSearchField) && isset($basicSearchField['name'])) ? $basicSearchField['name'] : $basicSearchField;
507 507
                 $field_name .= "_basic";
508
-                if( isset($_REQUEST[$field_name])  && ( !is_array($basicSearchField) || !isset($basicSearchField['type']) || $basicSearchField['type'] == 'text' || $basicSearchField['type'] == 'name') )
508
+                if (isset($_REQUEST[$field_name]) && (!is_array($basicSearchField) || !isset($basicSearchField['type']) || $basicSearchField['type'] == 'text' || $basicSearchField['type'] == 'name'))
509 509
                 {
510 510
                     // Ensure the encoding is UTF-8
511 511
                     $queryString = htmlentities($_REQUEST[$field_name], null, 'UTF-8');
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             }
515 515
         }
516 516
 
517
-		return array('data'=>$data , 'pageData'=>$pageData, 'query' => $queryString);
517
+		return array('data'=>$data, 'pageData'=>$pageData, 'query' => $queryString);
518 518
 	}
519 519
 
520 520
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
     {
529 529
         foreach ($queries as $name => $value)
530 530
         {
531
-            $queries[$name] = 'index.php?' . http_build_query($value);
531
+            $queries[$name] = 'index.php?'.http_build_query($value);
532 532
         }
533 533
         $this->base_url = $queries['baseURL'];
534 534
         return $queries;
@@ -554,22 +554,22 @@  discard block
 block discarded – undo
554 554
         $queries['orderBy'] = $queries['baseURL'];
555 555
         $queries['orderBy'][$this->var_order_by] = '';
556 556
 
557
-        if($nextOffset > -1)
557
+        if ($nextOffset > -1)
558 558
         {
559 559
             $queries['nextPage'] = $queries['baseURL'];
560 560
             $queries['nextPage'][$this->var_offset] = $nextOffset;
561 561
         }
562
-        if($offset > 0)
562
+        if ($offset > 0)
563 563
         {
564 564
             $queries['startPage'] = $queries['baseURL'];
565 565
             $queries['startPage'][$this->var_offset] = 0;
566 566
         }
567
-        if($prevOffset > -1)
567
+        if ($prevOffset > -1)
568 568
         {
569 569
             $queries['prevPage'] = $queries['baseURL'];
570 570
             $queries['prevPage'][$this->var_offset] = $prevOffset;
571 571
         }
572
-        if($totalCounted)
572
+        if ($totalCounted)
573 573
         {
574 574
             $queries['endPage'] = $queries['baseURL'];
575 575
             $queries['endPage'][$this->var_offset] = $endOffset;
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 
595 595
         $jscalendarImage = SugarThemeRegistry::current()->getImageURL('info_inline.gif');
596 596
 
597
-        $extra = "<span id='adspan_" . $id . "' "
597
+        $extra = "<span id='adspan_".$id."' "
598 598
                 . "onclick=\"lvg_dtails('$id')\" "
599 599
 				. " style='position: relative;'><!--not_in_theme!--><img vertical-align='middle' class='info' border='0' alt='".$app_strings['LBL_ADDITIONAL_DETAILS']."' src='$jscalendarImage'></span>";
600 600
 
@@ -618,27 +618,27 @@  discard block
 block discarded – undo
618 618
 
619 619
         $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
620 620
 
621
-        if(trim($results['string']) == '')
621
+        if (trim($results['string']) == '')
622 622
         {
623 623
             $results['string'] = $app_strings['LBL_NONE'];
624 624
         }
625 625
          	$close = false;
626 626
             $extra = "<img alt='{$app_strings['LBL_INFOINLINE']}' style='padding: 0px 5px 0px 2px' border='0' onclick=\"SUGAR.util.getStaticAdditionalDetails(this,'";
627 627
 
628
-            $extra .= str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string']) ;
628
+            $extra .= str_replace(array("\rn", "\r", "\n"), array('', '', '<br />'), $results['string']);
629 629
             $extra .= "','<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
630 630
 
631
-	        if($editAccess && !empty($results['editLink']))
631
+	        if ($editAccess && !empty($results['editLink']))
632 632
 	        {
633
-	            $extra .=  "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
633
+	            $extra .= "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
634 634
 	            $close = true;
635 635
 	        }
636 636
 	        $close = (!empty($results['viewLink'])) ? true : $close;
637 637
 	        $extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=".SugarThemeRegistry::current()->getImageURL('view_inline.png')."></a>" : '');
638 638
 
639
-            if($close == true) {
639
+            if ($close == true) {
640 640
             	$closeVal = "true";
641
-            	$extra .=  "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
641
+            	$extra .= "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
642 642
             } else {
643 643
             	$closeVal = "false";
644 644
             }
Please login to merge, or discard this patch.
include/utils/sugar_file_utils.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -53,39 +53,39 @@  discard block
 block discarded – undo
53 53
  * @param $context
54 54
  * @return boolean - Returns true on success false on failure
55 55
  */
56
-function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') {
56
+function sugar_mkdir($pathname, $mode = null, $recursive = false, $context = '') {
57 57
 	$mode = get_mode('dir_mode', $mode);
58 58
 
59
-	if ( sugar_is_dir($pathname,$mode) )
59
+	if (sugar_is_dir($pathname, $mode))
60 60
 	    return true;
61 61
 
62 62
 	$result = false;
63
-	if(empty($mode))
63
+	if (empty($mode))
64 64
 		$mode = 0777;
65
-	if(empty($context)) {
65
+	if (empty($context)) {
66 66
 		$result = @mkdir($pathname, $mode, $recursive);
67 67
 	} else {
68 68
 		$result = @mkdir($pathname, $mode, $recursive, $context);
69 69
 	}
70 70
 
71
-	if($result){
72
-		if(!sugar_chmod($pathname, $mode)){
71
+	if ($result) {
72
+		if (!sugar_chmod($pathname, $mode)) {
73 73
 			return false;
74 74
 		}
75
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
76
-			if(!sugar_chown($pathname)){
75
+		if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
76
+			if (!sugar_chown($pathname)) {
77 77
 				return false;
78 78
 			}
79 79
 		}
80
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
81
-   			if(!sugar_chgrp($pathname)) {
80
+		if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
81
+   			if (!sugar_chgrp($pathname)) {
82 82
    				return false;
83 83
    			}
84 84
 		}
85 85
 	}
86 86
 	else {
87 87
 		$errorMessage = "Cannot create directory $pathname cannot be touched";
88
-		if(is_null($GLOBALS['log'])) {
88
+		if (is_null($GLOBALS['log'])) {
89 89
 			throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
90 90
 		}
91 91
 		$GLOBALS['log']->error($errorMessage);
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
  * @param $context
109 109
  * @return boolean - Returns a file pointer on success, false otherwise
110 110
  */
111
-function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){
111
+function sugar_fopen($filename, $mode, $use_include_path = false, $context = null) {
112 112
 	//check to see if the file exists, if not then use touch to create it.
113
-	if(!file_exists($filename)){
113
+	if (!file_exists($filename)) {
114 114
 		sugar_touch($filename);
115 115
 	}
116 116
 
117
-	if(empty($context)) {
117
+	if (empty($context)) {
118 118
 
119 119
 		return fopen($filename, $mode, $use_include_path);
120 120
 	} else {
@@ -136,22 +136,22 @@  discard block
 block discarded – undo
136 136
  * @param $context
137 137
  * @return int - Returns the number of bytes written to the file, false otherwise.
138 138
  */
139
-function sugar_file_put_contents($filename, $data, $flags=null, $context=null){
139
+function sugar_file_put_contents($filename, $data, $flags = null, $context = null) {
140 140
 	//check to see if the file exists, if not then use touch to create it.
141
-	if(!file_exists($filename)){
141
+	if (!file_exists($filename)) {
142 142
 		sugar_touch($filename);
143 143
 	}
144 144
 
145
-	if ( !is_writable($filename) ) {
145
+	if (!is_writable($filename)) {
146 146
 	    $GLOBALS['log']->error("File $filename cannot be written to");
147 147
 	    return false;
148 148
 	}
149 149
 
150
-	if(empty($flags)) {
150
+	if (empty($flags)) {
151 151
 		return file_put_contents($filename, $data);
152
-	} elseif(empty($context)) {
152
+	} elseif (empty($context)) {
153 153
 		return file_put_contents($filename, $data, $flags);
154
-	} else{
154
+	} else {
155 155
 		return file_put_contents($filename, $data, $flags, $context);
156 156
 	}
157 157
 }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
  * @param context $context Context to pass into fopen operation
170 170
  * @return boolean - Returns true if $filename was created, false otherwise.
171 171
  */
172
-function sugar_file_put_contents_atomic($filename, $data, $mode='wb', $use_include_path=false, $context=null){
172
+function sugar_file_put_contents_atomic($filename, $data, $mode = 'wb', $use_include_path = false, $context = null) {
173 173
 
174 174
     $dir = dirname($filename);
175 175
     $temp = tempnam($dir, 'temp');
176 176
 
177 177
     if (!($f = @fopen($temp, $mode))) {
178
-        $temp =  $dir . DIRECTORY_SEPARATOR . uniqid('temp');
178
+        $temp = $dir.DIRECTORY_SEPARATOR.uniqid('temp');
179 179
         if (!($f = @fopen($temp, $mode))) {
180 180
             trigger_error("sugar_file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING);
181 181
             return false;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         }
197 197
     }
198 198
 
199
-    if(file_exists($filename))
199
+    if (file_exists($filename))
200 200
     {
201 201
        return sugar_chmod($filename, 0755);
202 202
     }
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
  * @param $context
215 215
  * @return string|boolean - Returns a file data on success, false otherwise
216 216
  */
217
-function sugar_file_get_contents($filename, $use_include_path=false, $context=null){
217
+function sugar_file_get_contents($filename, $use_include_path = false, $context = null) {
218 218
 	//check to see if the file exists, if not then use touch to create it.
219
-	if(!file_exists($filename)){
219
+	if (!file_exists($filename)) {
220 220
 		sugar_touch($filename);
221 221
 	}
222 222
 
223
-	if ( !is_readable($filename) ) {
223
+	if (!is_readable($filename)) {
224 224
 	    $GLOBALS['log']->error("File $filename cannot be read");
225 225
 	    return false;
226 226
 	}
227 227
 
228
-	if(empty($context)) {
228
+	if (empty($context)) {
229 229
 		return file_get_contents($filename, $use_include_path);
230 230
 	} else {
231 231
 		return file_get_contents($filename, $use_include_path, $context);
@@ -246,29 +246,29 @@  discard block
 block discarded – undo
246 246
  * @return boolean - Returns TRUE on success or FALSE on failure.
247 247
  *
248 248
  */
249
-function sugar_touch($filename, $time=null, $atime=null) {
249
+function sugar_touch($filename, $time = null, $atime = null) {
250 250
 
251 251
    $result = false;
252 252
 
253
-   if(!empty($atime) && !empty($time)) {
253
+   if (!empty($atime) && !empty($time)) {
254 254
    	  $result = @touch($filename, $time, $atime);
255
-   } else if(!empty($time)) {
255
+   } else if (!empty($time)) {
256 256
    	  $result = @touch($filename, $time);
257 257
    } else {
258 258
    	  $result = @touch($filename);
259 259
    }
260 260
 
261
-   if(!$result) {
261
+   if (!$result) {
262 262
        $GLOBALS['log']->error("File $filename cannot be touched");
263 263
        return $result;
264 264
    }
265
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){
265
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])) {
266 266
 		sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
267 267
 	}
268
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
268
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
269 269
 		sugar_chown($filename);
270 270
 	}
271
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
271
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
272 272
 		sugar_chgrp($filename);
273 273
 	}
274 274
 
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
  * @param  int $mode The integer value of the permissions mode to set the created directory to
285 285
  * @return boolean   Returns TRUE on success or FALSE on failure.
286 286
  */
287
-function sugar_chmod($filename, $mode=null) {
288
-    if ( !is_int($mode) )
289
-        $mode = (int) $mode;
290
-	if(!is_windows()){
291
-		if(!isset($mode)){
287
+function sugar_chmod($filename, $mode = null) {
288
+    if (!is_int($mode))
289
+        $mode = (int)$mode;
290
+	if (!is_windows()) {
291
+		if (!isset($mode)) {
292 292
 			$mode = get_mode('file_mode', $mode);
293 293
 		}
294
-        if(isset($mode) && $mode > 0){
294
+        if (isset($mode) && $mode > 0) {
295 295
 		   return @chmod($filename, $mode);
296
-		}else{
296
+		} else {
297 297
 	    	return false;
298 298
 		}
299 299
 	}
@@ -309,15 +309,15 @@  discard block
 block discarded – undo
309 309
  * @param user - A user name or number
310 310
  * @return boolean - Returns TRUE on success or FALSE on failure.
311 311
  */
312
-function sugar_chown($filename, $user='') {
313
-	if(!is_windows()){
314
-		if(strlen($user)){
312
+function sugar_chown($filename, $user = '') {
313
+	if (!is_windows()) {
314
+		if (strlen($user)) {
315 315
 			return chown($filename, $user);
316
-		}else{
317
-			if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
316
+		} else {
317
+			if (strlen($GLOBALS['sugar_config']['default_permissions']['user'])) {
318 318
 				$user = $GLOBALS['sugar_config']['default_permissions']['user'];
319 319
 				return chown($filename, $user);
320
-			}else{
320
+			} else {
321 321
 				return false;
322 322
 			}
323 323
 		}
@@ -334,15 +334,15 @@  discard block
 block discarded – undo
334 334
  * @param group - A group name or number
335 335
  * @return boolean - Returns TRUE on success or FALSE on failure.
336 336
  */
337
-function sugar_chgrp($filename, $group='') {
338
-	if(!is_windows()){
339
-		if(!empty($group)){
337
+function sugar_chgrp($filename, $group = '') {
338
+	if (!is_windows()) {
339
+		if (!empty($group)) {
340 340
 			return chgrp($filename, $group);
341
-		}else{
342
-			if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
341
+		} else {
342
+			if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
343 343
 				$group = $GLOBALS['sugar_config']['default_permissions']['group'];
344 344
 				return chgrp($filename, $group);
345
-			}else{
345
+			} else {
346 346
 				return false;
347 347
 			}
348 348
 		}
@@ -360,26 +360,26 @@  discard block
 block discarded – undo
360 360
  * defined in the config file.
361 361
  * @return int - the mode either found in the config file or passed in via the input parameter
362 362
  */
363
-function get_mode($key = 'dir_mode', $mode=null) {
364
-	if ( !is_int($mode) )
365
-        $mode = (int) $mode;
366
-    if(!class_exists('SugarConfig', true)) {
363
+function get_mode($key = 'dir_mode', $mode = null) {
364
+	if (!is_int($mode))
365
+        $mode = (int)$mode;
366
+    if (!class_exists('SugarConfig', true)) {
367 367
 		require 'include/SugarObjects/SugarConfig.php';
368 368
 	}
369
-	if(!is_windows()){
370
-		$conf_inst=SugarConfig::getInstance();
369
+	if (!is_windows()) {
370
+		$conf_inst = SugarConfig::getInstance();
371 371
 		$mode = $conf_inst->get('default_permissions.'.$key, $mode);
372 372
 	}
373 373
 	return $mode;
374 374
 }
375 375
 
376
-function sugar_is_dir($path, $mode='r'){
377
-		if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
376
+function sugar_is_dir($path, $mode = 'r') {
377
+		if (defined('TEMPLATE_URL'))return is_dir($path, $mode);
378 378
 		return is_dir($path);
379 379
 }
380 380
 
381
-function sugar_is_file($path, $mode='r'){
382
-		if(defined('TEMPLATE_URL'))return is_file($path, $mode);
381
+function sugar_is_file($path, $mode = 'r') {
382
+		if (defined('TEMPLATE_URL'))return is_file($path, $mode);
383 383
 		return is_file($path);
384 384
 }
385 385
 
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 function sugar_cached($file)
392 392
 {
393 393
     static $cdir = null;
394
-    if(empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
394
+    if (empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
395 395
         $cdir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
396 396
     }
397
-    if(empty($cdir)) {
397
+    if (empty($cdir)) {
398 398
         $cdir = "cache";
399 399
     }
400 400
     return "$cdir/$file";
Please login to merge, or discard this patch.
include/modules.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -79,18 +79,18 @@  discard block
 block discarded – undo
79 79
 $beanList['Cases']          = 'aCase';
80 80
 $beanList['Bugs']           = 'Bug';
81 81
 $beanList['ProspectLists']      = 'ProspectList';
82
-$beanList['Prospects']  = 'Prospect';
82
+$beanList['Prospects'] = 'Prospect';
83 83
 $beanList['Project']            = 'Project';
84
-$beanList['ProjectTask']            = 'ProjectTask';
84
+$beanList['ProjectTask'] = 'ProjectTask';
85 85
 $beanList['Campaigns']          = 'Campaign';
86
-$beanList['EmailMarketing']  = 'EmailMarketing';
86
+$beanList['EmailMarketing'] = 'EmailMarketing';
87 87
 $beanList['CampaignLog']        = 'CampaignLog';
88 88
 $beanList['CampaignTrackers']   = 'CampaignTracker';
89
-$beanList['Releases']       = 'Release';
89
+$beanList['Releases'] = 'Release';
90 90
 $beanList['Groups'] = 'Group';
91 91
 $beanList['EmailMan'] = 'EmailMan';
92
-$beanList['Schedulers']  = 'Scheduler';
93
-$beanList['SchedulersJobs']  = 'SchedulersJob';
92
+$beanList['Schedulers'] = 'Scheduler';
93
+$beanList['SchedulersJobs'] = 'SchedulersJob';
94 94
 $beanList['Contacts']       = 'Contact';
95 95
 $beanList['Accounts']       = 'Account';
96 96
 $beanList['DynamicFields']  = 'DynamicField';
@@ -106,19 +106,19 @@  discard block
 block discarded – undo
106 106
 $beanList['Currencies']     = 'Currency';
107 107
 $beanList['Trackers']       = 'Tracker';
108 108
 $beanList['Connectors']     = 'Connectors';
109
-$beanList['Import_1']         = 'ImportMap';
109
+$beanList['Import_1'] = 'ImportMap';
110 110
 $beanList['Import_2']       = 'UsersLastImport';
111 111
 $beanList['Versions']       = 'Version';
112 112
 $beanList['Administration'] = 'Administration';
113 113
 $beanList['vCals']          = 'vCal';
114 114
 $beanList['CustomFields']   = 'CustomFields';
115
-$beanList['Alerts']  = 'Alert';
115
+$beanList['Alerts'] = 'Alert';
116 116
 
117 117
 
118 118
 
119 119
 
120
-$beanList['Documents']  = 'Document';
121
-$beanList['DocumentRevisions']  = 'DocumentRevision';
120
+$beanList['Documents'] = 'Document';
121
+$beanList['DocumentRevisions'] = 'DocumentRevision';
122 122
 $beanList['Roles']  = 'Role';
123 123
 
124 124
 $beanList['Audit']  = 'Audit';
@@ -152,24 +152,24 @@  discard block
 block discarded – undo
152 152
 $beanFiles['aCase']         = 'modules/Cases/Case.php';
153 153
 $beanFiles['Bug']           = 'modules/Bugs/Bug.php';
154 154
 $beanFiles['Group'] = 'modules/Groups/Group.php';
155
-$beanFiles['CampaignLog']  = 'modules/CampaignLog/CampaignLog.php';
155
+$beanFiles['CampaignLog'] = 'modules/CampaignLog/CampaignLog.php';
156 156
 $beanFiles['Project']           = 'modules/Project/Project.php';
157
-$beanFiles['ProjectTask']           = 'modules/ProjectTask/ProjectTask.php';
157
+$beanFiles['ProjectTask'] = 'modules/ProjectTask/ProjectTask.php';
158 158
 $beanFiles['Campaign']          = 'modules/Campaigns/Campaign.php';
159 159
 $beanFiles['ProspectList']      = 'modules/ProspectLists/ProspectList.php';
160
-$beanFiles['Prospect']  = 'modules/Prospects/Prospect.php';
160
+$beanFiles['Prospect'] = 'modules/Prospects/Prospect.php';
161 161
 
162
-$beanFiles['EmailMarketing']          = 'modules/EmailMarketing/EmailMarketing.php';
163
-$beanFiles['CampaignTracker']  = 'modules/CampaignTrackers/CampaignTracker.php';
162
+$beanFiles['EmailMarketing'] = 'modules/EmailMarketing/EmailMarketing.php';
163
+$beanFiles['CampaignTracker'] = 'modules/CampaignTrackers/CampaignTracker.php';
164 164
 $beanFiles['Release']           = 'modules/Releases/Release.php';
165 165
 $beanFiles['EmailMan']          = 'modules/EmailMan/EmailMan.php';
166 166
 
167
-$beanFiles['Scheduler']  = 'modules/Schedulers/Scheduler.php';
168
-$beanFiles['SchedulersJob']  = 'modules/SchedulersJobs/SchedulersJob.php';
167
+$beanFiles['Scheduler'] = 'modules/Schedulers/Scheduler.php';
168
+$beanFiles['SchedulersJob'] = 'modules/SchedulersJobs/SchedulersJob.php';
169 169
 $beanFiles['Contact']       = 'modules/Contacts/Contact.php';
170 170
 $beanFiles['Account']       = 'modules/Accounts/Account.php';
171 171
 $beanFiles['Opportunity']   = 'modules/Opportunities/Opportunity.php';
172
-$beanFiles['EmailTemplate']         = 'modules/EmailTemplates/EmailTemplate.php';
172
+$beanFiles['EmailTemplate'] = 'modules/EmailTemplates/EmailTemplate.php';
173 173
 $beanFiles['Note']          = 'modules/Notes/Note.php';
174 174
 $beanFiles['Call']          = 'modules/Calls/Call.php';
175 175
 $beanFiles['Email']         = 'modules/Emails/Email.php';
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 $beanFiles['Task']          = 'modules/Tasks/Task.php';
178 178
 $beanFiles['User']          = 'modules/Users/User.php';
179 179
 $beanFiles['Employee']      = 'modules/Employees/Employee.php';
180
-$beanFiles['Currency']          = 'modules/Currencies/Currency.php';
181
-$beanFiles['Tracker']          = 'modules/Trackers/Tracker.php';
180
+$beanFiles['Currency'] = 'modules/Currencies/Currency.php';
181
+$beanFiles['Tracker'] = 'modules/Trackers/Tracker.php';
182 182
 $beanFiles['ImportMap']     = 'modules/Import/maps/ImportMap.php';
183
-$beanFiles['UsersLastImport']= 'modules/Import/UsersLastImport.php';
184
-$beanFiles['Administration']= 'modules/Administration/Administration.php';
185
-$beanFiles['UpgradeHistory']= 'modules/Administration/UpgradeHistory.php';
183
+$beanFiles['UsersLastImport'] = 'modules/Import/UsersLastImport.php';
184
+$beanFiles['Administration'] = 'modules/Administration/Administration.php';
185
+$beanFiles['UpgradeHistory'] = 'modules/Administration/UpgradeHistory.php';
186 186
 $beanFiles['vCal']          = 'modules/vCals/vCal.php';
187
-$beanFiles['Alert']          = 'modules/Alerts/Alert.php';
188
-$beanFiles['Version']           = 'modules/Versions/Version.php';
187
+$beanFiles['Alert'] = 'modules/Alerts/Alert.php';
188
+$beanFiles['Version'] = 'modules/Versions/Version.php';
189 189
 
190 190
 
191 191
 
192
-$beanFiles['Role']          = 'modules/Roles/Role.php';
192
+$beanFiles['Role'] = 'modules/Roles/Role.php';
193 193
 
194
-$beanFiles['Document']  = 'modules/Documents/Document.php';
194
+$beanFiles['Document'] = 'modules/Documents/Document.php';
195 195
 $beanFiles['DocumentRevision']  = 'modules/DocumentRevisions/DocumentRevision.php';
196 196
 $beanFiles['FieldsMetaData']    = 'modules/DynamicFields/FieldsMetaData.php';
197 197
 //$beanFiles['Audit']           = 'modules/Audit/Audit.php';
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 
206 206
 $beanFiles['SavedSearch']  = 'modules/SavedSearch/SavedSearch.php';
207
-$beanFiles['UserPreference']  = 'modules/UserPreferences/UserPreference.php';
207
+$beanFiles['UserPreference'] = 'modules/UserPreferences/UserPreference.php';
208 208
 $beanFiles['MergeRecord']  = 'modules/MergeRecords/MergeRecord.php';
209 209
 $beanFiles['EmailAddress'] = 'modules/EmailAddresses/EmailAddress.php';
210 210
 $beanFiles['EmailText'] = 'modules/EmailText/EmailText.php';
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
 //$beanList['Library']= 'Library';
217 217
 //$beanFiles['Library'] = 'modules/Library/Library.php';
218 218
 
219
-$beanFiles['Configurator']          = 'modules/Configurator/Configurator.php';
219
+$beanFiles['Configurator'] = 'modules/Configurator/Configurator.php';
220 220
 
221 221
 // added these lists for security settings for tabs
222 222
 $modInvisList = array('Administration', 'Currencies', 'CustomFields', 'Connectors',
223 223
     'Dropdown', 'Dynamic', 'DynamicFields', 'DynamicLayout', 'EditCustomFields',
224
-    'Help', 'Import',  'MySettings', 'EditCustomFields','FieldsMetaData',
224
+    'Help', 'Import', 'MySettings', 'EditCustomFields', 'FieldsMetaData',
225 225
     'UpgradeWizard', 'Trackers', 'Connectors', 'Employees', 'Calendar',
226
-    'Releases','Sync',
227
-    'Users',  'Versions', 'LabelEditor','Roles','EmailMarketing'
228
-    ,'OptimisticLock', 'TeamMemberships', 'TeamSets', 'TeamSetModule', 'Audit', 'MailMerge', 'MergeRecords', 'EmailAddresses','EmailText',
229
-    'Schedulers','Schedulers_jobs', /*'Queues',*/ 'EmailTemplates',
226
+    'Releases', 'Sync',
227
+    'Users', 'Versions', 'LabelEditor', 'Roles', 'EmailMarketing'
228
+    ,'OptimisticLock', 'TeamMemberships', 'TeamSets', 'TeamSetModule', 'Audit', 'MailMerge', 'MergeRecords', 'EmailAddresses', 'EmailText',
229
+    'Schedulers', 'Schedulers_jobs', /*'Queues',*/ 'EmailTemplates',
230 230
     'CampaignTrackers', 'CampaignLog', 'EmailMan', 'Prospects', 'ProspectLists',
231
-    'Groups','InboundEmail',
231
+    'Groups', 'InboundEmail',
232 232
     'ACLActions', 'ACLRoles',
233 233
     'DocumentRevisions',
234 234
     'ProjectTask',
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
 $modInvisList[] = 'Connectors';
266 266
 
267 267
 $report_include_modules = array();
268
-$report_include_modules['Currencies']='Currency';
268
+$report_include_modules['Currencies'] = 'Currency';
269 269
 //add prospects
270
-$report_include_modules['Prospects']='Prospect';
270
+$report_include_modules['Prospects'] = 'Prospect';
271 271
 $report_include_modules['DocumentRevisions'] = 'DocumentRevision';
272 272
 $report_include_modules['ProductCategories'] = 'ProductCategory';
273 273
 $report_include_modules['ProductTypes'] = 'ProductType';
274 274
 //add Tracker modules
275 275
 
276
-$report_include_modules['Trackers']         = 'Tracker';
276
+$report_include_modules['Trackers'] = 'Tracker';
277 277
 
278 278
 
279 279
 
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 //the bean class name == dictionary entry/object name convention
324 324
 //No future module should need an entry here.
325 325
 $objectList = array();
326
-$objectList['Cases'] =  'Case';
327
-$objectList['Groups'] =  'User';
328
-$objectList['Users'] =  'User';
326
+$objectList['Cases'] = 'Case';
327
+$objectList['Groups'] = 'User';
328
+$objectList['Users'] = 'User';
329 329
 
330 330
 
331 331
 // knowledge base
Please login to merge, or discard this patch.
include/TemplateHandler/TemplateHandler.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
       $this->cacheDir = sugar_cached('');
54 54
     }
55 55
 
56
-    function loadSmarty(){
57
-        if(empty($this->ss)){
56
+    function loadSmarty() {
57
+        if (empty($this->ss)) {
58 58
             $this->ss = new Sugar_Smarty();
59 59
         }
60 60
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     static function clearAll() {
69 69
     	global $beanList;
70
-		foreach($beanList as $module_dir =>$object_name){
70
+		foreach ($beanList as $module_dir =>$object_name) {
71 71
                 TemplateHandler::clearCache($module_dir);
72 72
 		}
73 73
     }
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
      * @param String $module The module directory to clear
81 81
      * @param String $view Optional view value (DetailView, EditView, etc.)
82 82
      */
83
-    static function clearCache($module, $view=''){
84
-        $cacheDir = create_cache_directory('modules/'. $module . '/');
83
+    static function clearCache($module, $view = '') {
84
+        $cacheDir = create_cache_directory('modules/'.$module.'/');
85 85
         $d = dir($cacheDir);
86
-        while($e = $d->read()){
87
-            if(!empty($view) && $e != $view )continue;
88
-            $end =strlen($e) - 4;
89
-            if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
90
-                unlink($cacheDir . $e);
86
+        while ($e = $d->read()) {
87
+            if (!empty($view) && $e != $view)continue;
88
+            $end = strlen($e) - 4;
89
+            if (is_file($cacheDir.$e) && $end > 1 && substr($e, $end) == '.tpl') {
90
+                unlink($cacheDir.$e);
91 91
             }
92 92
         }
93 93
     }
@@ -105,21 +105,21 @@  discard block
 block discarded – undo
105 105
     function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs) {
106 106
         $this->loadSmarty();
107 107
 
108
-        $cacheDir = create_cache_directory($this->templateDir. $module . '/');
109
-        $file = $cacheDir . $view . '.tpl';
110
-        $string = '{* Create Date: ' . date('Y-m-d H:i:s') . "*}\n";
108
+        $cacheDir = create_cache_directory($this->templateDir.$module.'/');
109
+        $file = $cacheDir.$view.'.tpl';
110
+        $string = '{* Create Date: '.date('Y-m-d H:i:s')."*}\n";
111 111
         $this->ss->left_delimiter = '{{';
112 112
         $this->ss->right_delimiter = '}}';
113 113
         $this->ss->assign('module', $module);
114 114
         $this->ss->assign('built_in_buttons', array('CANCEL', 'DELETE', 'DUPLICATE', 'EDIT', 'FIND_DUPLICATES', 'SAVE', 'CONNECTOR'));
115 115
         $contents = $this->ss->fetch($tpl);
116 116
         //Insert validation and quicksearch stuff here
117
-        if($view == 'EditView' || strpos($view,'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
117
+        if ($view == 'EditView' || strpos($view, 'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
118 118
 
119 119
             global $dictionary, $beanList, $app_strings, $mod_strings;
120 120
             $mod = $beanList[$module];
121 121
 
122
-            if($mod == 'aCase') {
122
+            if ($mod == 'aCase') {
123 123
                 $mod = 'Case';
124 124
             }
125 125
 
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
             //Retrieve all panel field definitions with displayParams Array field set
129 129
             $panelFields = array();
130 130
 
131
-            foreach($metaDataDefs['panels'] as $panel) {
132
-                    foreach($panel as $row) {
133
-                            foreach($row as $entry) {
134
-                                    if(empty($entry)) {
131
+            foreach ($metaDataDefs['panels'] as $panel) {
132
+                    foreach ($panel as $row) {
133
+                            foreach ($row as $entry) {
134
+                                    if (empty($entry)) {
135 135
                                        continue;
136 136
                                     }
137 137
 
138
-                                    if(is_array($entry) &&
138
+                                    if (is_array($entry) &&
139 139
                                        isset($entry['name']) &&
140 140
                                        isset($entry['displayParams']) &&
141 141
                                        isset($entry['displayParams']['required']) &&
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                                        $panelFields[$entry['name']] = $entry;
144 144
                                     }
145 145
 
146
-                                    if(is_array($entry)) {
146
+                                    if (is_array($entry)) {
147 147
                                       $defs2[$entry['name']] = $entry;
148 148
                                     } else {
149 149
                                       $defs2[$entry] = array('name' => $entry);
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
                     } //foreach
153 153
             } //foreach
154 154
 
155
-            foreach($panelFields as $field=>$value) {
155
+            foreach ($panelFields as $field=>$value) {
156 156
                       $nameList = array();
157
-                      if(!is_array($value['displayParams']['required'])) {
157
+                      if (!is_array($value['displayParams']['required'])) {
158 158
                          $nameList[] = $field;
159 159
                       } else {
160
-                         foreach($value['displayParams']['required'] as $groupedField) {
160
+                         foreach ($value['displayParams']['required'] as $groupedField) {
161 161
                                  $nameList[] = $groupedField;
162 162
                          }
163 163
                       }
164 164
 
165
-                      foreach($nameList as $x) {
166
-                         if(isset($defs[$x]) &&
165
+                      foreach ($nameList as $x) {
166
+                         if (isset($defs[$x]) &&
167 167
                             isset($defs[$x]['type']) &&
168 168
                             !isset($defs[$x]['required'])) {
169 169
                             $defs[$x]['required'] = true;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
             $javascript->setSugarBean($sugarbean);
184 184
             if ($view != "ConvertLead")
185
-                $javascript->addAllFields('', null,true);
185
+                $javascript->addAllFields('', null, true);
186 186
 
187 187
             $validatedFields = array();
188 188
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
             //3) not have validateDepedency set to false in metadata
194 194
             //4) have id_name in vardef entry
195 195
             //5) not already been added to Array
196
-            foreach($sugarbean->field_name_map as $name=>$def) {
196
+            foreach ($sugarbean->field_name_map as $name=>$def) {
197 197
 
198
-               if($def['type']=='relate' &&
198
+               if ($def['type'] == 'relate' &&
199 199
                   isset($defs2[$name]) &&
200 200
                   (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) &&
201 201
                   isset($def['id_name']) &&
202 202
                   !in_array($name, $validatedFields)) {
203 203
 
204
-                  if(isset($mod_strings[$def['vname']])
204
+                  if (isset($mod_strings[$def['vname']])
205 205
                         || isset($app_strings[$def['vname']])
206
-                        || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
206
+                        || translate($def['vname'], $sugarbean->module_dir) != $def['vname']) {
207 207
                      $vname = $def['vname'];
208 208
                   }
209
-                  else{
209
+                  else {
210 210
                      $vname = "undefined";
211 211
                   }
212 212
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
             $contents .= $javascript->getScript();
219 219
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
220 220
             $contents .= "{/literal}\n";
221
-        }else if(preg_match('/^SearchForm_.+/', $view)){
221
+        } else if (preg_match('/^SearchForm_.+/', $view)) {
222 222
             global $dictionary, $beanList, $app_strings, $mod_strings;
223 223
             $mod = $beanList[$module];
224 224
 
225
-            if($mod == 'aCase') {
225
+            if ($mod == 'aCase') {
226 226
                 $mod = 'Case';
227 227
             }
228 228
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         //Remove all the copyright comments
236 236
         $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents);
237 237
 
238
-        if($fh = @sugar_fopen($file, 'w')) {
238
+        if ($fh = @sugar_fopen($file, 'w')) {
239 239
             fputs($fh, $contents);
240 240
             fclose($fh);
241 241
         }
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
      * @param module string module name
252 252
      * @param view string view need (eg DetailView, EditView, etc)
253 253
      */
254
-    function checkTemplate($module, $view, $checkFormName = false, $formName='') {
255
-        if(inDeveloperMode() || !empty($_SESSION['developerMode'])){
254
+    function checkTemplate($module, $view, $checkFormName = false, $formName = '') {
255
+        if (inDeveloperMode() || !empty($_SESSION['developerMode'])) {
256 256
             return false;
257 257
         }
258 258
         $view = $checkFormName ? $formName : $view;
259
-        return file_exists($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
259
+        return file_exists($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
260 260
     }
261 261
 
262 262
     /**
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
      */
271 271
     function displayTemplate($module, $view, $tpl, $ajaxSave = false, $metaDataDefs = null) {
272 272
         $this->loadSmarty();
273
-        if(!$this->checkTemplate($module, $view)) {
273
+        if (!$this->checkTemplate($module, $view)) {
274 274
             $this->buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs);
275 275
         }
276
-        $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
277
-        if(file_exists($file)) {
276
+        $file = $this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl';
277
+        if (file_exists($file)) {
278 278
            return $this->ss->fetch($file);
279 279
         } else {
280 280
            global $app_strings;
281
-           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
282
-           return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
281
+           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'].": $file");
282
+           return $app_strings['ERR_NO_SUCH_FILE'].": $file";
283 283
         }
284 284
     }
285 285
 
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
      * @param view string view need (eg DetailView, EditView, etc)
291 291
      */
292 292
     function deleteTemplate($module, $view) {
293
-        if(is_file($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl')) {
293
+        if (is_file($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl')) {
294 294
             // Bug #54634 : RTC 18144 : Cannot add more than 1 user to role but popup is multi-selectable
295
-            if ( !isset($this->ss) )
295
+            if (!isset($this->ss))
296 296
             {
297 297
                 $this->loadSmarty();
298 298
             }
299
-            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
299
+            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
300 300
             SugarCache::cleanFile($cache_file_name);
301 301
 
302
-            return unlink($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
302
+            return unlink($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
303 303
         }
304 304
         return false;
305 305
     }
@@ -316,47 +316,47 @@  discard block
 block discarded – undo
316 316
      * @param strign $module
317 317
      * @return string
318 318
      */
319
-    public function createQuickSearchCode($defs, $defs2, $view = '', $module='')
319
+    public function createQuickSearchCode($defs, $defs2, $view = '', $module = '')
320 320
     {
321 321
         $sqs_objects = array();
322 322
         require_once('include/QuickSearchDefaults.php');
323
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
323
+        if (isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
324 324
         {
325 325
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
326
-        }else
326
+        } else
327 327
         {
328 328
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
329 329
         }
330 330
         $qsd->setFormName($view);
331
-        if(preg_match('/^SearchForm_.+/', $view)){
332
-        	if(strpos($view, 'popup_query_form')){
331
+        if (preg_match('/^SearchForm_.+/', $view)) {
332
+        	if (strpos($view, 'popup_query_form')) {
333 333
         		$qsd->setFormName('popup_query_form');
334 334
             	$parsedView = 'advanced';
335
-        	}else{
335
+        	} else {
336 336
         		$qsd->setFormName('search_form');
337 337
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
338 338
         	}
339 339
             //Loop through the Meta-Data fields to see which ones need quick search support
340
-            foreach($defs as $f) {
340
+            foreach ($defs as $f) {
341 341
                 $field = $f;
342
-                $name = $qsd->form_name . '_' . $field['name'];
342
+                $name = $qsd->form_name.'_'.$field['name'];
343 343
 
344
-                if($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si',$name)  || !empty($field['quicksearch']) ) {
345
-                    if(preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
344
+                if ($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch'])) {
345
+                    if (preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
346 346
 
347
-                        if($matches[0] == 'Campaigns') {
347
+                        if ($matches[0] == 'Campaigns') {
348 348
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
349
-                        } else if($matches[0] == 'Users'){
349
+                        } else if ($matches[0] == 'Users') {
350 350
 
351
-                            if(!empty($f['name']) && !empty($f['id_name'])) {
352
-                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
351
+                            if (!empty($f['name']) && !empty($f['id_name'])) {
352
+                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'], $f['id_name']);
353 353
                             }
354 354
                             else {
355 355
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
356 356
                             }
357
-                        } else if($matches[0] == 'Campaigns') {
357
+                        } else if ($matches[0] == 'Campaigns') {
358 358
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
359
-                        } else if($matches[0] == 'Accounts') {
359
+                        } else if ($matches[0] == 'Accounts') {
360 360
                             $nameKey = $name;
361 361
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
362 362
 
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
                             $shippingKey = isset($f['displayParams']['shippingKey']) ? $f['displayParams']['shippingKey'] : null;
370 370
                             $additionalFields = isset($f['displayParams']['additionalFields']) ? $f['displayParams']['additionalFields'] : null;
371 371
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
372
-                        } else if($matches[0] == 'Contacts'){
372
+                        } else if ($matches[0] == 'Contacts') {
373 373
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
374 374
                         }
375 375
                     } else {
376 376
                          $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
377
-                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
377
+                         if (!isset($field['field_list']) && !isset($field['populate_list'])) {
378 378
                              $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
379 379
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
380 380
                          } else {
@@ -382,63 +382,63 @@  discard block
 block discarded – undo
382 382
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
383 383
                          }
384 384
                     }
385
-                } else if($field['type'] == 'parent') {
385
+                } else if ($field['type'] == 'parent') {
386 386
                     $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent();
387 387
                 } //if-else
388 388
             } //foreach
389 389
 
390
-            foreach ( $sqs_objects as $name => $field )
391
-               foreach ( $field['populate_list'] as $key => $fieldname )
392
-                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
393
-        }else{
390
+            foreach ($sqs_objects as $name => $field)
391
+               foreach ($field['populate_list'] as $key => $fieldname)
392
+                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key].'_'.$parsedView;
393
+        } else {
394 394
             //Loop through the Meta-Data fields to see which ones need quick search support
395
-            foreach($defs2 as $f) {
396
-                if(!isset($defs[$f['name']])) continue;
395
+            foreach ($defs2 as $f) {
396
+                if (!isset($defs[$f['name']])) continue;
397 397
 
398 398
                 $field = $defs[$f['name']];
399 399
                 if ($view == "ConvertLead")
400 400
                 {
401
-                    $field['name'] = $module . $field['name'];
401
+                    $field['name'] = $module.$field['name'];
402 402
                     if (isset($field['module']) && isset($field['id_name']) && substr($field['id_name'], -4) == "_ida") {
403 403
                         $lc_module = strtolower($field['module']);
404 404
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
405 405
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
406
-                            $field['id_name'] = $module . $field['id_name'];
406
+                            $field['id_name'] = $module.$field['id_name'];
407 407
                         }
408 408
                         else
409
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
409
+                            $field['id_name'] = $field['name']."_".$field['id_name'];
410 410
                     }
411 411
                     else {
412 412
                         if (!empty($field['id_name']))
413 413
                             $field['id_name'] = $module.$field['id_name'];
414 414
                     }
415 415
                 }
416
-				$name = $qsd->form_name . '_' . $field['name'];
416
+				$name = $qsd->form_name.'_'.$field['name'];
417 417
 
418 418
 
419
-                if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) {
420
-                    if (!preg_match('/_c$/si',$name)
421
-                        && (!isset($field['id_name']) || !preg_match('/_c$/si',$field['id_name']))
419
+                if ($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch']))) {
420
+                    if (!preg_match('/_c$/si', $name)
421
+                        && (!isset($field['id_name']) || !preg_match('/_c$/si', $field['id_name']))
422 422
                         && preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)
423 423
                     ) {
424 424
 
425
-                        if($matches[0] == 'Campaigns') {
425
+                        if ($matches[0] == 'Campaigns') {
426 426
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
427
-                        } else if($matches[0] == 'Users'){
428
-                            if($field['name'] == 'reports_to_name'){
429
-                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
427
+                        } else if ($matches[0] == 'Users') {
428
+                            if ($field['name'] == 'reports_to_name') {
429
+                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name', 'reports_to_id');
430 430
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
431
-                            }elseif($field['name'] == 'assigned_user_name'){
432
-                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
431
+                            }elseif ($field['name'] == 'assigned_user_name') {
432
+                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name', 'assigned_user_id');
433 433
                              }
434 434
                              else
435 435
                              {
436 436
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
437 437
 
438 438
 							}
439
-                        } else if($matches[0] == 'Campaigns') {
439
+                        } else if ($matches[0] == 'Campaigns') {
440 440
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
441
-                        } else if($matches[0] == 'Accounts') {
441
+                        } else if ($matches[0] == 'Accounts') {
442 442
                             $nameKey = $name;
443 443
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
444 444
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
                             $shippingKey = SugarArray::staticGet($f, 'displayParams.shippingKey');
452 452
                             $additionalFields = SugarArray::staticGet($f, 'displayParams.additionalFields');
453 453
                             $sqs_objects[$name] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
454
-                        } else if($matches[0] == 'Contacts'){
454
+                        } else if ($matches[0] == 'Contacts') {
455 455
                             $sqs_objects[$name] = $qsd->getQSContact($field['name'], $field['id_name']);
456
-                            if(preg_match('/_c$/si',$name) || !empty($field['quicksearch'])){
456
+                            if (preg_match('/_c$/si', $name) || !empty($field['quicksearch'])) {
457 457
                                 $sqs_objects[$name]['field_list'] = array('salutation', 'first_name', 'last_name', 'id');
458 458
                             }
459 459
                         }
460 460
                     } else {
461 461
                         $sqs_objects[$name] = $qsd->getQSParent($field['module']);
462
-                        if(!isset($field['field_list']) && !isset($field['populate_list'])) {
462
+                        if (!isset($field['field_list']) && !isset($field['populate_list'])) {
463 463
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
464 464
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
465 465
                             if (!isset($field['rname']))
@@ -468,14 +468,14 @@  discard block
 block discarded – undo
468 468
                             {
469 469
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
470 470
                                 $sqs_objects[$name]['order'] = $field['rname'];
471
-                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'],'op'=>'like_custom','end'=>'%','value'=>''));
471
+                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'], 'op'=>'like_custom', 'end'=>'%', 'value'=>''));
472 472
                             }
473 473
                         } else {
474 474
                             $sqs_objects[$name]['populate_list'] = $field['field_list'];
475 475
                             $sqs_objects[$name]['field_list'] = $field['populate_list'];
476 476
                         }
477 477
                     }
478
-                } else if($field['type'] == 'parent') {
478
+                } else if ($field['type'] == 'parent') {
479 479
                     $sqs_objects[$name] = $qsd->getQSParent();
480 480
                 } //if-else
481 481
 
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
 
486 486
                 //merge populate_list && field_list with vardef
487 487
                 if (!empty($field['field_list']) && !empty($field['populate_list'])) {
488
-                    for ($j=0; $j<count($field['field_list']); $j++) {
488
+                    for ($j = 0; $j < count($field['field_list']); $j++) {
489 489
                 		//search for the same couple (field_list_item,populate_field_item)
490 490
                			$field_list_item = $field['field_list'][$j];
491
-               			$field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
491
+               			$field_list_item_alternate = $qsd->form_name.'_'.$field['field_list'][$j];
492 492
                			$populate_list_item = $field['populate_list'][$j];
493 493
                 		$found = false;
494
-                		for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
494
+                		for ($k = 0; $k < count($sqs_objects[$name]['field_list']); $k++) {
495 495
                 			if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
496 496
                 				$populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
497 497
                 				$found = true;
@@ -509,14 +509,14 @@  discard block
 block discarded – undo
509 509
         }
510 510
 
511 511
        //Implement QuickSearch for the field
512
-       if(!empty($sqs_objects) && count($sqs_objects) > 0) {
512
+       if (!empty($sqs_objects) && count($sqs_objects) > 0) {
513 513
            $quicksearch_js = '<script language="javascript">';
514
-           $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
514
+           $quicksearch_js .= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
515 515
            $json = getJSONobj();
516
-           foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
516
+           foreach ($sqs_objects as $sqsfield=>$sqsfieldArray) {
517 517
                $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
518 518
            }
519
-           return $quicksearch_js . '</script>';
519
+           return $quicksearch_js.'</script>';
520 520
        }
521 521
        return '';
522 522
     }
Please login to merge, or discard this patch.
include/connectors/ConnectorFactory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
  * Connector factory
43 43
  * @api
44 44
  */
45
-class ConnectorFactory{
45
+class ConnectorFactory {
46 46
 
47 47
 	static $source_map = array();
48 48
 
49
-	public static function getInstance($source_name){
50
-		if(empty(self::$source_map[$source_name])) {
49
+	public static function getInstance($source_name) {
50
+		if (empty(self::$source_map[$source_name])) {
51 51
 			require_once('include/connectors/sources/SourceFactory.php');
52 52
 			require_once('include/connectors/component.php');
53 53
 			$source = SourceFactory::getSource($source_name);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * which represents the inheritance structure to load up all required parents.
65 65
 	 * @param string $class the root class we want to load.
66 66
 	 */
67
-	public static function load($class, $type){
67
+	public static function load($class, $type) {
68 68
 		self::loadClass($class, $type);
69 69
 	}
70 70
 
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 	 * include a source class file.
73 73
 	 * @param string $class a class file to include.
74 74
 	 */
75
-	public static function loadClass($class, $type){
76
-		$dir = str_replace('_','/',$class);
75
+	public static function loadClass($class, $type) {
76
+		$dir = str_replace('_', '/', $class);
77 77
 		$parts = explode("/", $dir);
78
-		$file = $parts[count($parts)-1] . '.php';
79
-		if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){
78
+		$file = $parts[count($parts) - 1].'.php';
79
+		if (file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")) {
80 80
 			require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file");
81
-		} else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
81
+		} else if (file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
82 82
 			require_once("modules/Connectors/connectors/{$type}/{$dir}/$file");
83
-		} else if(file_exists("connectors/{$type}/{$dir}/$file")) {
83
+		} else if (file_exists("connectors/{$type}/{$dir}/$file")) {
84 84
 			require_once("connectors/{$type}/{$dir}/$file");
85 85
 		}
86 86
 	}
Please login to merge, or discard this patch.
include/MVC/View/SugarView.php 1 patch
Spacing   +228 added lines, -229 removed lines patch added patch discarded remove patch
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
         $this->_trackView();
125 125
 
126 126
         //For the ajaxUI, we need to use output buffering to return the page in an ajax friendly format
127
-        if ($this->_getOption('json_output')){
127
+        if ($this->_getOption('json_output')) {
128 128
 			ob_start();
129
-			if(!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
129
+			if (!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
130 130
 				echo $this->_getModLanguageJS();
131 131
 			}
132 132
 		}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $this->preDisplay();
142 142
         $this->displayErrors();
143 143
         $this->display();
144
-        if ( !empty($this->module) ) {
144
+        if (!empty($this->module)) {
145 145
             $GLOBALS['logic_hook']->call_custom_logic($this->module, 'after_ui_frame');
146 146
         } else {
147 147
             $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_frame');
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
                 'favicon' => $this->getFavicon(),
187 187
             );
188 188
 
189
-            if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
189
+            if (SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
190 190
                 $ajax_ret['moduleList'] = $this->displayHeader(true);
191 191
 
192
-            if(empty($this->responseTime))
192
+            if (empty($this->responseTime))
193 193
                 $this->_calculateFooterMetrics();
194 194
             $ajax_ret['responseTime'] = $this->responseTime;
195 195
             $json = getJSONobj();
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
     {
209 209
         $errors = '';
210 210
 
211
-        foreach($this->errors as $error) {
212
-            $errors .= '<span class="error">' . $error . '</span><br>';
211
+        foreach ($this->errors as $error) {
212
+            $errors .= '<span class="error">'.$error.'</span><br>';
213 213
         }
214 214
 
215
-        if ( !$this->suppressDisplayErrors ) {
215
+        if (!$this->suppressDisplayErrors) {
216 216
             echo $errors;
217 217
         }
218 218
         else {
@@ -249,14 +249,14 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $action = strtolower($this->action);
251 251
         //Skip save, tracked in SugarBean instead
252
-        if($action == 'save') {
252
+        if ($action == 'save') {
253 253
         return;
254 254
         }
255 255
 
256 256
 
257 257
         $trackerManager = TrackerManager::getInstance();
258 258
         $timeStamp = TimeDate::getInstance()->nowDb();
259
-        if($monitor = $trackerManager->getMonitor('tracker')){
259
+        if ($monitor = $trackerManager->getMonitor('tracker')) {
260 260
             $monitor->setValue('action', $action);
261 261
             $monitor->setValue('user_id', $GLOBALS['current_user']->id);
262 262
             $monitor->setValue('module_name', $this->module);
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
             //If visible is true, but there is no bean, do not track (invalid/unauthorized reference)
273 273
             //Also, do not track save actions where there is no bean id
274
-            if($monitor->visible && empty($this->bean->id)) {
274
+            if ($monitor->visible && empty($this->bean->id)) {
275 275
             $trackerManager->unsetMonitor($monitor);
276 276
             return;
277 277
             }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     /**
284 284
      * Displays the header on section of the page; basically everything before the content
285 285
      */
286
-    public function displayHeader($retModTabs=false)
286
+    public function displayHeader($retModTabs = false)
287 287
     {
288 288
         global $theme;
289 289
         global $max_tabs;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         $ss->assign("APP", $app_strings);
304 304
         $ss->assign("THEME", $theme);
305 305
         $ss->assign("THEME_CONFIG", $themeObject->getConfig());
306
-        $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true':'false');
306
+        $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
307 307
         $ss->assign("MODULE_NAME", $this->module);
308 308
         $ss->assign("langHeader", get_language_header());
309 309
 
@@ -319,17 +319,17 @@  discard block
 block discarded – undo
319 319
         if ($this->_getOption('view_print')) {
320 320
             $css .= '<link rel="stylesheet" type="text/css" href="'.$themeObject->getCSSURL('print.css').'" media="all" />';
321 321
         }
322
-        $ss->assign("SUGAR_CSS",$css);
322
+        $ss->assign("SUGAR_CSS", $css);
323 323
 
324 324
         // get javascript
325 325
         ob_start();
326 326
         $this->renderJavascript();
327 327
 
328
-        $ss->assign("SUGAR_JS",ob_get_contents().$themeObject->getJS());
328
+        $ss->assign("SUGAR_JS", ob_get_contents().$themeObject->getJS());
329 329
         ob_end_clean();
330 330
 
331 331
         // get favicon
332
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
332
+        if (isset($GLOBALS['sugar_config']['default_module_favicon']))
333 333
             $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
334 334
         else
335 335
             $module_favicon = false;
@@ -339,24 +339,24 @@  discard block
 block discarded – undo
339 339
 
340 340
         // build the shortcut menu
341 341
         $shortcut_menu = array();
342
-        foreach ( $this->getMenu() as $key => $menu_item )
342
+        foreach ($this->getMenu() as $key => $menu_item)
343 343
             $shortcut_menu[$key] = array(
344 344
                 "URL"         => $menu_item[0],
345 345
                 "LABEL"       => $menu_item[1],
346 346
                 "MODULE_NAME" => $menu_item[2],
347 347
                 "IMAGE"       => $themeObject
348
-                    ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
348
+                    ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
349 349
                 );
350
-        $ss->assign("SHORTCUT_MENU",$shortcut_menu);
350
+        $ss->assign("SHORTCUT_MENU", $shortcut_menu);
351 351
 
352 352
         // handle rtl text direction
353
-        if(isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL'){
353
+        if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
354 354
             $_SESSION['RTL'] = true;
355 355
         }
356
-        if(isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR'){
356
+        if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
357 357
             unset($_SESSION['RTL']);
358 358
         }
359
-        if(isset($_SESSION['RTL']) && $_SESSION['RTL']){
359
+        if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
360 360
             $ss->assign("DIR", 'dir="RTL"');
361 361
         }
362 362
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $companyLogoURL = $companyLogoURL_arr[0];
367 367
 
368 368
         $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
369
-        if(!empty($company_logo_attributes)) {
369
+        if (!empty($company_logo_attributes)) {
370 370
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
371 371
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
372 372
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
@@ -375,16 +375,16 @@  discard block
 block discarded – undo
375 375
             // Always need to md5 the file
376 376
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
377 377
 
378
-            list($width,$height) = getimagesize($companyLogoURL);
379
-            if ( $width > 212 || $height > 40 ) {
380
-                $resizePctWidth  = ($width - 212)/212;
381
-                $resizePctHeight = ($height - 40)/40;
382
-                if ( $resizePctWidth > $resizePctHeight )
378
+            list($width, $height) = getimagesize($companyLogoURL);
379
+            if ($width > 212 || $height > 40) {
380
+                $resizePctWidth  = ($width - 212) / 212;
381
+                $resizePctHeight = ($height - 40) / 40;
382
+                if ($resizePctWidth > $resizePctHeight)
383 383
                     $resizeAmount = $width / 212;
384 384
                 else
385 385
                     $resizeAmount = $height / 40;
386
-                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
387
-                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
386
+                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
387
+                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
388 388
             }
389 389
             else {
390 390
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
@@ -400,110 +400,110 @@  discard block
 block discarded – undo
400 400
                                 )
401 401
             );
402 402
         }
403
-        $ss->assign("COMPANY_LOGO_URL",getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
403
+        $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
404 404
 
405 405
         // get the global links
406 406
         $gcls = array();
407 407
         $global_control_links = array();
408 408
         require("include/globalControlLinks.php");
409 409
 
410
-        foreach($global_control_links as $key => $value) {
411
-            if ($key == 'users')  {   //represents logout link.
410
+        foreach ($global_control_links as $key => $value) {
411
+            if ($key == 'users') {   //represents logout link.
412 412
                 $ss->assign("LOGOUT_LINK", $value['linkinfo'][key($value['linkinfo'])]);
413
-                $ss->assign("LOGOUT_LABEL", key($value['linkinfo']));//key value for first element.
413
+                $ss->assign("LOGOUT_LABEL", key($value['linkinfo'])); //key value for first element.
414 414
                 continue;
415 415
             }
416 416
 
417 417
             foreach ($value as $linkattribute => $attributevalue) {
418 418
                 // get the main link info
419
-                if ( $linkattribute == 'linkinfo' ) {
419
+                if ($linkattribute == 'linkinfo') {
420 420
                     $gcls[$key] = array(
421 421
                         "LABEL" => key($attributevalue),
422 422
                         "URL"   => current($attributevalue),
423 423
                         "SUBMENU" => array(),
424 424
                         );
425
-                   if(substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
-                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"],11);
425
+                   if (substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
+                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"], 11);
427 427
                        $gcls[$key]["URL"] = "javascript:void(0)";
428 428
                    }
429 429
                 }
430 430
                 // and now the sublinks
431
-                if ( $linkattribute == 'submenu' && is_array($attributevalue) ) {
431
+                if ($linkattribute == 'submenu' && is_array($attributevalue)) {
432 432
                     foreach ($attributevalue as $submenulinkkey => $submenulinkinfo)
433 433
                         $gcls[$key]['SUBMENU'][$submenulinkkey] = array(
434 434
                             "LABEL" => key($submenulinkinfo),
435 435
                             "URL"   => current($submenulinkinfo),
436 436
                         );
437
-                       if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
-                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
437
+                       if (substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
+                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 11);
439 439
                            $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
440 440
                        }
441 441
                 }
442 442
             }
443 443
         }
444
-        $ss->assign("GCLS",$gcls);
444
+        $ss->assign("GCLS", $gcls);
445 445
 
446 446
         $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
447 447
 
448 448
         if ($this->action == "EditView" || $this->action == "Login")
449 449
             $ss->assign("ONLOAD", 'onload="set_focus()"');
450 450
 
451
-        $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
451
+        $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
452 452
 
453 453
         // get other things needed for page style popup
454 454
         if (isset($_SESSION["authenticated_user_id"])) {
455 455
             // get the current user name and id
456 456
             $ss->assign("CURRENT_USER", $current_user->full_name == '' || !showFullName()
457
-                ? $current_user->user_name : $current_user->full_name );
457
+                ? $current_user->user_name : $current_user->full_name);
458 458
             $ss->assign("CURRENT_USER_ID", $current_user->id);
459 459
 
460 460
             // get the last viewed records
461 461
             require_once("modules/Favorites/Favorites.php");
462 462
             $favorites = new Favorites();
463 463
             $favorite_records = $favorites->getCurrentUserSidebarFavorites();
464
-            $ss->assign("favoriteRecords",$favorite_records);
464
+            $ss->assign("favoriteRecords", $favorite_records);
465 465
 
466 466
             $tracker = new Tracker();
467 467
             $history = $tracker->get_recently_viewed($current_user->id);
468
-            $ss->assign("recentRecords",$this->processRecentRecords($history));
468
+            $ss->assign("recentRecords", $this->processRecentRecords($history));
469 469
         }
470 470
 
471 471
         $bakModStrings = $mod_strings;
472
-        if (isset($_SESSION["authenticated_user_id"]) ) {
472
+        if (isset($_SESSION["authenticated_user_id"])) {
473 473
             // get the module list
474 474
             $moduleTopMenu = array();
475 475
 
476 476
             $max_tabs = $current_user->getPreference('max_tabs');
477 477
             // Attempt to correct if max tabs count is extremely high.
478
-            if ( !isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10 ) {
478
+            if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
479 479
                 $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
480 480
                 $current_user->setPreference('max_tabs', $max_tabs, 0, 'global');
481 481
             }
482 482
 
483 483
             $moduleTab = $this->_getModuleTab();
484
-            $ss->assign('MODULE_TAB',$moduleTab);
484
+            $ss->assign('MODULE_TAB', $moduleTab);
485 485
 
486 486
 
487 487
             // See if they are using grouped tabs or not (removed in 6.0, returned in 6.1)
488 488
             $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
489
-            if ( !isset($user_navigation_paradigm) ) {
489
+            if (!isset($user_navigation_paradigm)) {
490 490
                 $user_navigation_paradigm = $GLOBALS['sugar_config']['default_navigation_paradigm'];
491 491
             }
492 492
 
493 493
 
494 494
             // Get the full module list for later use
495
-            foreach ( query_module_access_list($current_user) as $module ) {
495
+            foreach (query_module_access_list($current_user) as $module) {
496 496
                 // Bug 25948 - Check for the module being in the moduleList
497
-                if ( isset($app_list_strings['moduleList'][$module]) ) {
497
+                if (isset($app_list_strings['moduleList'][$module])) {
498 498
                     $fullModuleList[$module] = $app_list_strings['moduleList'][$module];
499 499
                 }
500 500
             }
501 501
 
502 502
 
503
-            if(!should_hide_iframes()) {
503
+            if (!should_hide_iframes()) {
504 504
                 $iFrame = new iFrame();
505 505
                 $frames = $iFrame->lookup_frames('tab');
506
-                foreach($frames as $key => $values){
506
+                foreach ($frames as $key => $values) {
507 507
                         $fullModuleList[$key] = $values;
508 508
                 }
509 509
             }
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                 unset($fullModuleList['iFrames']);
512 512
             }
513 513
 
514
-            if ( $user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
514
+            if ($user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
515 515
                 // We are using grouped tabs
516 516
                 require_once('include/GroupedTabs/GroupedTabStructure.php');
517 517
                 $groupedTabsClass = new GroupedTabStructure();
@@ -519,12 +519,12 @@  discard block
 block discarded – undo
519 519
                 //handle with submoremodules
520 520
                 $max_tabs = $current_user->getPreference('max_tabs');
521 521
                 // If the max_tabs isn't set incorrectly, set it within the range, to the default max sub tabs size
522
-                if ( !isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10){
522
+                if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
523 523
                     // We have a default value. Use it
524
-                    if(isset($GLOBALS['sugar_config']['default_max_tabs'])){
524
+                    if (isset($GLOBALS['sugar_config']['default_max_tabs'])) {
525 525
                         $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
526 526
                     }
527
-                    else{
527
+                    else {
528 528
                         $max_tabs = 8;
529 529
                     }
530 530
                 }
@@ -537,22 +537,22 @@  discard block
 block discarded – undo
537 537
 
538 538
                 // Setup the default group tab.
539 539
                 $allGroup = $app_strings['LBL_TABGROUP_ALL'];
540
-                $ss->assign('currentGroupTab',$allGroup);
540
+                $ss->assign('currentGroupTab', $allGroup);
541 541
                 $currentGroupTab = $allGroup;
542 542
                 $usersGroup = $current_user->getPreference('theme_current_group');
543 543
                 // Figure out which tab they currently have selected (stored as a user preference)
544
-                if ( !empty($usersGroup) && isset($groupTabs[$usersGroup]) ) {
544
+                if (!empty($usersGroup) && isset($groupTabs[$usersGroup])) {
545 545
                     $currentGroupTab = $usersGroup;
546 546
                 } else {
547
-                    $current_user->setPreference('theme_current_group',$currentGroupTab);
547
+                    $current_user->setPreference('theme_current_group', $currentGroupTab);
548 548
                 }
549 549
 
550
-                $ss->assign('currentGroupTab',$currentGroupTab);
550
+                $ss->assign('currentGroupTab', $currentGroupTab);
551 551
                 $usingGroupTabs = true;
552 552
 
553 553
             } else {
554 554
                 // Setup the default group tab.
555
-                $ss->assign('currentGroupTab',$app_strings['LBL_TABGROUP_ALL']);
555
+                $ss->assign('currentGroupTab', $app_strings['LBL_TABGROUP_ALL']);
556 556
 
557 557
                 $usingGroupTabs = false;
558 558
 
@@ -564,31 +564,31 @@  discard block
 block discarded – undo
564 564
             $topTabList = array();
565 565
 
566 566
             // Now time to go through each of the tab sets and fix them up.
567
-            foreach ( $groupTabs as $tabIdx => $tabData ) {
567
+            foreach ($groupTabs as $tabIdx => $tabData) {
568 568
                 $topTabs = $tabData['modules'];
569
-                if ( ! is_array($topTabs) ) {
569
+                if (!is_array($topTabs)) {
570 570
                     $topTabs = array();
571 571
                 }
572 572
                 $extraTabs = array();
573 573
 
574 574
                 // Split it in to the tabs that go across the top, and the ones that are on the extra menu.
575
-                if ( count($topTabs) > $max_tabs ) {
576
-                    $extraTabs = array_splice($topTabs,$max_tabs);
575
+                if (count($topTabs) > $max_tabs) {
576
+                    $extraTabs = array_splice($topTabs, $max_tabs);
577 577
                 }
578 578
                 // Make sure the current module is accessable through one of the top tabs
579
-                if ( !isset($topTabs[$moduleTab]) ) {
579
+                if (!isset($topTabs[$moduleTab])) {
580 580
                     // Nope, we need to add it.
581 581
                     // First, take it out of the extra menu, if it's there
582
-                    if ( isset($extraTabs[$moduleTab]) ) {
582
+                    if (isset($extraTabs[$moduleTab])) {
583 583
                         unset($extraTabs[$moduleTab]);
584 584
                     }
585
-                    if ( count($topTabs) >= $max_tabs - 1 ) {
585
+                    if (count($topTabs) >= $max_tabs - 1) {
586 586
                         // We already have the maximum number of tabs, so we need to shuffle the last one
587 587
                         // from the top to the first one of the extras
588
-                        $lastElem = array_splice($topTabs,$max_tabs-1);
588
+                        $lastElem = array_splice($topTabs, $max_tabs - 1);
589 589
                         $extraTabs = $lastElem + $extraTabs;
590 590
                     }
591
-                    if ( !empty($moduleTab) ) {
591
+                    if (!empty($moduleTab)) {
592 592
                         $topTabs[$moduleTab] = $app_list_strings['moduleList'][$moduleTab];
593 593
                     }
594 594
                 }
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                 */
608 608
 
609 609
                 // Get a unique list of the top tabs so we can build the popup menus for them
610
-                foreach ( $topTabs as $moduleKey => $module ) {
610
+                foreach ($topTabs as $moduleKey => $module) {
611 611
                     $topTabList[$moduleKey] = $module;
612 612
                 }
613 613
 
@@ -616,67 +616,67 @@  discard block
 block discarded – undo
616 616
             }
617 617
         }
618 618
 
619
-        if ( isset($topTabList) && is_array($topTabList) ) {
619
+        if (isset($topTabList) && is_array($topTabList)) {
620 620
             // Adding shortcuts array to menu array for displaying shortcuts associated with each module
621 621
             $shortcutTopMenu = array();
622
-            foreach($topTabList as $module_key => $label) {
622
+            foreach ($topTabList as $module_key => $label) {
623 623
                 global $mod_strings;
624 624
                 $mod_strings = return_module_language($current_language, $module_key);
625
-                foreach ( $this->getMenu($module_key) as $key => $menu_item ) {
625
+                foreach ($this->getMenu($module_key) as $key => $menu_item) {
626 626
                     $shortcutTopMenu[$module_key][$key] = array(
627 627
                         "URL"         => $menu_item[0],
628 628
                         "LABEL"       => $menu_item[1],
629 629
                         "MODULE_NAME" => $menu_item[2],
630 630
                         "IMAGE"       => $themeObject
631
-                        ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
631
+                        ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
632 632
                         "ID"          => $menu_item[2]."_link",
633 633
                         );
634 634
                 }
635 635
             }
636
-            if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
637
-            $ss->assign("groupTabs",$groupTabs);
638
-            $ss->assign("shortcutTopMenu",$shortcutTopMenu);
639
-            $ss->assign('USE_GROUP_TABS',$usingGroupTabs);
636
+            if (!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
637
+            $ss->assign("groupTabs", $groupTabs);
638
+            $ss->assign("shortcutTopMenu", $shortcutTopMenu);
639
+            $ss->assign('USE_GROUP_TABS', $usingGroupTabs);
640 640
 
641 641
             // This is here for backwards compatibility, someday, somewhere, it will be able to be removed
642
-            $ss->assign("moduleTopMenu",$groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
643
-            $ss->assign("moduleExtraMenu",$groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
642
+            $ss->assign("moduleTopMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
643
+            $ss->assign("moduleExtraMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
644 644
 
645 645
 
646 646
         }
647 647
         
648
-        if ( isset($extraTabs) && is_array($extraTabs) ) {
648
+        if (isset($extraTabs) && is_array($extraTabs)) {
649 649
             // Adding shortcuts array to extra menu array for displaying shortcuts associated with each module
650 650
             $shortcutExtraMenu = array();
651
-            foreach($extraTabs as $module_key => $label) {
651
+            foreach ($extraTabs as $module_key => $label) {
652 652
                 global $mod_strings;
653 653
                 $mod_strings = return_module_language($current_language, $module_key);
654
-                foreach ( $this->getMenu($module_key) as $key => $menu_item ) {
654
+                foreach ($this->getMenu($module_key) as $key => $menu_item) {
655 655
                     $shortcutExtraMenu[$module_key][$key] = array(
656 656
                         "URL"         => $menu_item[0],
657 657
                         "LABEL"       => $menu_item[1],
658 658
                         "MODULE_NAME" => $menu_item[2],
659 659
                         "IMAGE"       => $themeObject
660
-                        ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
660
+                        ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
661 661
                         "ID"          => $menu_item[2]."_link",
662 662
                         );
663 663
                 }
664 664
             }
665
-            $ss->assign("shortcutExtraMenu",$shortcutExtraMenu);
665
+            $ss->assign("shortcutExtraMenu", $shortcutExtraMenu);
666 666
         }
667 667
        
668
-       if(!empty($current_user)){
668
+       if (!empty($current_user)) {
669 669
        	$ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
670 670
        } 
671 671
       
672 672
        
673 673
         $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
674 674
         $homeImage = "<img src='$imageURL'>";
675
-		$ss->assign("homeImage",$homeImage);
675
+		$ss->assign("homeImage", $homeImage);
676 676
         global $mod_strings;
677 677
         $mod_strings = $bakModStrings;
678 678
         $headerTpl = $themeObject->getTemplate('header.tpl');
679
-        if (inDeveloperMode() )
679
+        if (inDeveloperMode())
680 680
             $ss->clear_compiled_tpl($headerTpl);
681 681
 
682 682
         if ($retModTabs)
@@ -688,9 +688,9 @@  discard block
 block discarded – undo
688 688
             $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
689 689
 
690 690
             $errorMessages = SugarApplication::getErrorMessages();
691
-            if ( !empty($errorMessages)) {
692
-                foreach ( $errorMessages as $error_message ) {
693
-                    echo('<p class="error">' . $error_message.'</p>');
691
+            if (!empty($errorMessages)) {
692
+                foreach ($errorMessages as $error_message) {
693
+                    echo('<p class="error">'.$error_message.'</p>');
694 694
                 }
695 695
             }
696 696
         }
@@ -725,13 +725,13 @@  discard block
 block discarded – undo
725 725
     {
726 726
         global $sugar_config, $timedate;
727 727
 
728
-        if(isset($this->bean->module_dir)){
728
+        if (isset($this->bean->module_dir)) {
729 729
             echo "<script>var module_sugar_grp1 = '{$this->bean->module_dir}';</script>";
730 730
         }
731
-        if(isset($_REQUEST['action'])){
731
+        if (isset($_REQUEST['action'])) {
732 732
             echo "<script>var action_sugar_grp1 = '{$_REQUEST['action']}';</script>";
733 733
         }
734
-        echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
734
+        echo '<script>jscal_today = 1000*'.$timedate->asUserTs($timedate->getNow()).'; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
735 735
         if (!is_file(sugar_cached("include/javascript/sugar_grp1.js"))) {
736 736
             $_REQUEST['root_directory'] = ".";
737 737
             require_once("jssource/minify_utils.php");
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
             if ( typeof(SUGAR.themes) == 'undefined' ) SUGAR.themes = {};
748 748
         </script>
749 749
 EOQ;
750
-        if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
750
+        if (isset($sugar_config['disc_client']) && $sugar_config['disc_client'])
751 751
             echo getVersionedScript('modules/Sync/headersync.js');
752 752
     }
753 753
 
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
         require_once ('modules/Currencies/Currency.php');
777 777
         list ($num_grp_sep, $dec_sep) = get_number_seperators();
778 778
 
779
-        $the_script = "<script type=\"text/javascript\">\n" . "\tvar time_reg_format = '" .
780
-             $timereg['format'] . "';\n" . "\tvar date_reg_format = '" .
781
-             $datereg['format'] . "';\n" . "\tvar date_reg_positions = { $date_pos };\n" .
782
-             "\tvar time_separator = '$time_separator';\n" .
783
-             "\tvar cal_date_format = '$cal_date_format';\n" .
784
-             "\tvar time_offset = $hour_offset;\n" . "\tvar num_grp_sep = '$num_grp_sep';\n" .
785
-             "\tvar dec_sep = '$dec_sep';\n" . "</script>";
779
+        $the_script = "<script type=\"text/javascript\">\n"."\tvar time_reg_format = '".
780
+             $timereg['format']."';\n"."\tvar date_reg_format = '".
781
+             $datereg['format']."';\n"."\tvar date_reg_positions = { $date_pos };\n".
782
+             "\tvar time_separator = '$time_separator';\n".
783
+             "\tvar cal_date_format = '$cal_date_format';\n".
784
+             "\tvar time_offset = $hour_offset;\n"."\tvar num_grp_sep = '$num_grp_sep';\n".
785
+             "\tvar dec_sep = '$dec_sep';\n"."</script>";
786 786
 
787 787
         return $the_script;
788 788
     }
@@ -810,13 +810,13 @@  discard block
 block discarded – undo
810 810
                 "sugar_cache_dir" => "cache/",
811 811
                 );
812 812
 
813
-            if(isset($this->bean->module_dir)){
813
+            if (isset($this->bean->module_dir)) {
814 814
                 $js_vars['module_sugar_grp1'] = $this->bean->module_dir;
815 815
             }
816
-            if(isset($_REQUEST['action'])){
816
+            if (isset($_REQUEST['action'])) {
817 817
                 $js_vars['action_sugar_grp1'] = $_REQUEST['action'];
818 818
             }
819
-            echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
819
+            echo '<script>jscal_today = 1000*'.$timedate->asUserTs($timedate->getNow()).'; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
820 820
             if (!is_file(sugar_cached("include/javascript/sugar_grp1.js")) || !is_file(sugar_cached("include/javascript/sugar_grp1_yui.js")) || !is_file(sugar_cached("include/javascript/sugar_grp1_jquery.js"))) {
821 821
                 $_REQUEST['root_directory'] = ".";
822 822
                 require_once("jssource/minify_utils.php");
@@ -829,33 +829,33 @@  discard block
 block discarded – undo
829 829
 
830 830
             // output necessary config js in the top of the page
831 831
             $config_js = $this->getSugarConfigJS();
832
-            if(!empty($config_js)){
832
+            if (!empty($config_js)) {
833 833
                 echo "<script>\n".implode("\n", $config_js)."</script>\n";
834 834
             }
835 835
 
836
-            if ( isset($sugar_config['email_sugarclient_listviewmaxselect']) ) {
836
+            if (isset($sugar_config['email_sugarclient_listviewmaxselect'])) {
837 837
                 echo "<script>SUGAR.config.email_sugarclient_listviewmaxselect = {$GLOBALS['sugar_config']['email_sugarclient_listviewmaxselect']};</script>";
838 838
             }
839 839
 
840
-            $image_server = (defined('TEMPLATE_URL'))?TEMPLATE_URL . '/':'';
841
-            echo '<script type="text/javascript">SUGAR.themes.image_server="' . $image_server . '";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF
842
-            echo '<script type="text/javascript">var name_format = "' . $locale->getLocaleFormatMacro() . '";</script>';
840
+            $image_server = (defined('TEMPLATE_URL')) ? TEMPLATE_URL.'/' : '';
841
+            echo '<script type="text/javascript">SUGAR.themes.image_server="'.$image_server.'";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF
842
+            echo '<script type="text/javascript">var name_format = "'.$locale->getLocaleFormatMacro().'";</script>';
843 843
             echo self::getJavascriptValidation();
844
-            if (!is_file(sugar_cached('jsLanguage/') . $GLOBALS['current_language'] . '.js')) {
844
+            if (!is_file(sugar_cached('jsLanguage/').$GLOBALS['current_language'].'.js')) {
845 845
                 require_once ('include/language/jsLanguage.php');
846 846
                 jsLanguage::createAppStringsCache($GLOBALS['current_language']);
847 847
             }
848
-            echo getVersionedScript('cache/jsLanguage/'. $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
848
+            echo getVersionedScript('cache/jsLanguage/'.$GLOBALS['current_language'].'.js', $GLOBALS['sugar_config']['js_lang_version']);
849 849
 
850 850
 			echo $this->_getModLanguageJS();
851 851
 
852
-            if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
852
+            if (isset($sugar_config['disc_client']) && $sugar_config['disc_client'])
853 853
                 echo getVersionedScript('modules/Sync/headersync.js');
854 854
 
855 855
 
856 856
             //echo out the $js_vars variables as javascript variables
857 857
             echo "<script type='text/javascript'>\n";
858
-            foreach($js_vars as $var=>$value)
858
+            foreach ($js_vars as $var=>$value)
859 859
             {
860 860
                 echo "var {$var} = '{$value}';\n";
861 861
             }
@@ -863,12 +863,12 @@  discard block
 block discarded – undo
863 863
         }
864 864
     }
865 865
 
866
-	protected function _getModLanguageJS(){
867
-		if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {
866
+	protected function _getModLanguageJS() {
867
+		if (!is_file(sugar_cached('jsLanguage/').$this->module.'/'.$GLOBALS['current_language'].'.js')) {
868 868
 			require_once ('include/language/jsLanguage.php');
869 869
 			jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);
870 870
 		}
871
-		return getVersionedScript("cache/jsLanguage/{$this->module}/". $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
871
+		return getVersionedScript("cache/jsLanguage/{$this->module}/".$GLOBALS['current_language'].'.js', $GLOBALS['sugar_config']['js_lang_version']);
872 872
 	}
873 873
 
874 874
     /**
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
         }
891 891
 
892 892
         $ss = new Sugar_Smarty();
893
-        $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
894
-        $ss->assign('MOD',return_module_language($GLOBALS['current_language'], 'Users'));
893
+        $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
894
+        $ss->assign('MOD', return_module_language($GLOBALS['current_language'], 'Users'));
895 895
 
896 896
 		$bottomLinkList = array();
897 897
 		 if (isset($this->action) && $this->action != "EditView") {
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
 		$bottomLinkList['backtotop'] = array($app_strings['LNK_BACKTOTOP'] => 'javascript:SUGAR.util.top();');
901 901
 
902 902
 		$bottomLinksStr = "";
903
-		foreach($bottomLinkList as $key => $value) {
904
-			foreach($value as $text => $link) {
903
+		foreach ($bottomLinkList as $key => $value) {
904
+			foreach ($value as $text => $link) {
905 905
 				   $href = $link;
906
-				   if(substr($link, 0, 11) == "javascript:") {
907
-                       $onclick = " onclick=\"".substr($link,11)."\"";
906
+				   if (substr($link, 0, 11) == "javascript:") {
907
+                       $onclick = " onclick=\"".substr($link, 11)."\"";
908 908
                        $href = "javascript:void(0)";
909 909
                    } else {
910 910
                    		$onclick = "";
@@ -916,9 +916,9 @@  discard block
 block discarded – undo
916 916
 				$bottomLinksStr .= " ".$text."</a>";
917 917
 			}
918 918
 		}
919
-		$ss->assign("BOTTOMLINKS",$bottomLinksStr);
919
+		$ss->assign("BOTTOMLINKS", $bottomLinksStr);
920 920
         if (SugarConfig::getInstance()->get('calculate_response_time', false))
921
-            $ss->assign('STATISTICS',$this->_getStatistics());
921
+            $ss->assign('STATISTICS', $this->_getStatistics());
922 922
 
923 923
         // Under the License referenced above, you are required to leave in all copyright statements in both
924 924
         // the code and end-user application.
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
         $companyLogoURL = $companyLogoURL_arr[0];
953 953
 
954 954
         $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
955
-        if(!empty($company_logo_attributes)) {
955
+        if (!empty($company_logo_attributes)) {
956 956
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
957 957
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
958 958
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
@@ -961,16 +961,16 @@  discard block
 block discarded – undo
961 961
             // Always need to md5 the file
962 962
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
963 963
 
964
-            list($width,$height) = getimagesize($companyLogoURL);
965
-            if ( $width > 212 || $height > 40 ) {
966
-                $resizePctWidth  = ($width - 212)/212;
967
-                $resizePctHeight = ($height - 40)/40;
968
-                if ( $resizePctWidth > $resizePctHeight )
964
+            list($width, $height) = getimagesize($companyLogoURL);
965
+            if ($width > 212 || $height > 40) {
966
+                $resizePctWidth  = ($width - 212) / 212;
967
+                $resizePctHeight = ($height - 40) / 40;
968
+                if ($resizePctWidth > $resizePctHeight)
969 969
                     $resizeAmount = $width / 212;
970 970
                 else
971 971
                     $resizeAmount = $height / 40;
972
-                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
973
-                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
972
+                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
973
+                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
974 974
             }
975 975
             else {
976 976
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
@@ -986,28 +986,28 @@  discard block
 block discarded – undo
986 986
                                 )
987 987
             );
988 988
         }
989
-        $ss->assign("COMPANY_LOGO_URL",getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
989
+        $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
990 990
 
991 991
         // Bug 38594 - Add in Trademark wording
992 992
         $copyright .= 'SugarCRM is a trademark of SugarCRM, Inc. All other company and product names may be trademarks of the respective companies with which they are associated.<br />';
993 993
 
994 994
         //rrs bug: 20923 - if this image does not exist as per the license, then the proper image will be displayed regardless, so no need
995 995
         //to display an empty image here.
996
-        if(file_exists('include/images/poweredby_sugarcrm_65.png')){
996
+        if (file_exists('include/images/poweredby_sugarcrm_65.png')) {
997 997
             $copyright .= $attribLinkImg;
998 998
         }
999 999
         // End Required Image
1000
-        $ss->assign('COPYRIGHT',$copyright);
1000
+        $ss->assign('COPYRIGHT', $copyright);
1001 1001
 
1002 1002
         // here we allocate the help link data
1003 1003
         $help_actions_blacklist = array('Login'); // we don't want to show a context help link here
1004
-        if (!in_array($this->action,$help_actions_blacklist)) {
1004
+        if (!in_array($this->action, $help_actions_blacklist)) {
1005 1005
             $url = 'javascript:void(window.open(\'index.php?module=Administration&action=SupportPortal&view=documentation&version='.$GLOBALS['sugar_version'].'&edition='.$GLOBALS['sugar_flavor'].'&lang='.$GLOBALS['current_language'].
1006 1006
                         '&help_module='.$this->module.'&help_action='.$this->action.'&key='.$GLOBALS['server_unique_key'].'\'))';
1007 1007
             $label = (isset($GLOBALS['app_list_strings']['moduleList'][$this->module]) ?
1008
-                        $GLOBALS['app_list_strings']['moduleList'][$this->module] : $this->module). ' '.$app_strings['LNK_HELP'];
1009
-            $ss->assign('HELP_LINK',SugarThemeRegistry::current()->getLink($url, $label, "id='help_link_two'",
1010
-                'help-dashlet.png', 'class="icon"',null,null,'','left'));
1008
+                        $GLOBALS['app_list_strings']['moduleList'][$this->module] : $this->module).' '.$app_strings['LNK_HELP'];
1009
+            $ss->assign('HELP_LINK', SugarThemeRegistry::current()->getLink($url, $label, "id='help_link_two'",
1010
+                'help-dashlet.png', 'class="icon"', null, null, '', 'left'));
1011 1011
         }
1012 1012
         // end
1013 1013
 
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
      */
1021 1021
     protected function _displaySubPanels()
1022 1022
     {
1023
-        if (isset($this->bean) && !empty($this->bean->id) && (file_exists('modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/Ext/Layoutdefs/layoutdefs.ext.php'))) {
1023
+        if (isset($this->bean) && !empty($this->bean->id) && (file_exists('modules/'.$this->module.'/metadata/subpaneldefs.php') || file_exists('custom/modules/'.$this->module.'/metadata/subpaneldefs.php') || file_exists('custom/modules/'.$this->module.'/Ext/Layoutdefs/layoutdefs.ext.php'))) {
1024 1024
             $GLOBALS['focus'] = $this->bean;
1025 1025
             require_once ('include/SubPanel/SubPanelTiles.php');
1026 1026
             $subpanel = new SubPanelTiles($this->bean, $this->module);
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
      */
1079 1079
     protected function _checkModule()
1080 1080
     {
1081
-        if(!empty($this->module) && !file_exists('modules/'.$this->module)){
1081
+        if (!empty($this->module) && !file_exists('modules/'.$this->module)) {
1082 1082
             $error = str_replace("[module]", "$this->module", $GLOBALS['app_strings']['ERR_CANNOT_FIND_MODULE']);
1083 1083
             $GLOBALS['log']->fatal($error);
1084 1084
             echo $error;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
     {
1108 1108
         $endTime = microtime(true);
1109 1109
         $deltaTime = $endTime - $GLOBALS['startTime'];
1110
-        $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'] . ' ' . number_format(round($deltaTime, 2), 2) . ' ' . $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1110
+        $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'].' '.number_format(round($deltaTime, 2), 2).' '.$GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1111 1111
         $return = $response_time_string;
1112 1112
        // $return .= '<br />';
1113 1113
         if (!empty($GLOBALS['sugar_config']['show_page_resources'])) {
@@ -1118,16 +1118,16 @@  discard block
 block discarded – undo
1118 1118
             // I believe the full get_include_files result set appears to have one entry for each file in real
1119 1119
             // case, and one entry in all lower case.
1120 1120
             $list_of_files_case_insensitive = array();
1121
-            foreach($included_files as $key => $name) {
1121
+            foreach ($included_files as $key => $name) {
1122 1122
                 // preserve the first capitalization encountered.
1123
-                $list_of_files_case_insensitive[mb_strtolower($name) ] = $name;
1123
+                $list_of_files_case_insensitive[mb_strtolower($name)] = $name;
1124 1124
             }
1125
-            $return .= $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_RESOURCES'] . '(' . DBManager::getQueryCount() . ',' . sizeof($list_of_files_case_insensitive) . ')<br>';
1125
+            $return .= $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_RESOURCES'].'('.DBManager::getQueryCount().','.sizeof($list_of_files_case_insensitive).')<br>';
1126 1126
             // Display performance of the internal and external caches....
1127 1127
             $cacheStats = SugarCache::instance()->getCacheStats();
1128
-            $return .= "External cache (hits/total=ratio) local ({$cacheStats['localHits']}/{$cacheStats['requests']}=" . round($cacheStats['localHits']*100/$cacheStats['requests'], 0) . "%)";
1129
-            $return .= " external ({$cacheStats['externalHits']}/{$cacheStats['requests']}=" . round($cacheStats['externalHits']*100/$cacheStats['requests'], 0) . "%)<br />";
1130
-            $return .= " misses ({$cacheStats['misses']}/{$cacheStats['requests']}=" . round($cacheStats['misses']*100/$cacheStats['requests'], 0) . "%)<br />";
1128
+            $return .= "External cache (hits/total=ratio) local ({$cacheStats['localHits']}/{$cacheStats['requests']}=".round($cacheStats['localHits'] * 100 / $cacheStats['requests'], 0)."%)";
1129
+            $return .= " external ({$cacheStats['externalHits']}/{$cacheStats['requests']}=".round($cacheStats['externalHits'] * 100 / $cacheStats['requests'], 0)."%)<br />";
1130
+            $return .= " misses ({$cacheStats['misses']}/{$cacheStats['requests']}=".round($cacheStats['misses'] * 100 / $cacheStats['requests'], 0)."%)<br />";
1131 1131
         }
1132 1132
 
1133 1133
         $return .= $this->logMemoryStatistics();
@@ -1144,37 +1144,36 @@  discard block
 block discarded – undo
1144 1144
      * @param $newline String of newline character to use (defaults to </ br>)
1145 1145
      * @return $message String formatted message about memory statistics
1146 1146
      */
1147
-    protected function logMemoryStatistics($newline='<br>')
1147
+    protected function logMemoryStatistics($newline = '<br>')
1148 1148
     {
1149 1149
         $log_message = '';
1150 1150
 
1151
-        if(!empty($GLOBALS['sugar_config']['log_memory_usage']))
1151
+        if (!empty($GLOBALS['sugar_config']['log_memory_usage']))
1152 1152
         {
1153
-            if(function_exists('memory_get_usage'))
1153
+            if (function_exists('memory_get_usage'))
1154 1154
             {
1155 1155
                 $memory_usage = memory_get_usage();
1156 1156
                 $bytes = $GLOBALS['app_strings']['LBL_SERVER_MEMORY_BYTES'];
1157 1157
                 $data = array($memory_usage, $bytes);
1158
-                $log_message = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_USAGE'], $data) . $newline;
1158
+                $log_message = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_USAGE'], $data).$newline;
1159 1159
             }
1160 1160
 
1161
-            if(function_exists('memory_get_peak_usage'))
1161
+            if (function_exists('memory_get_peak_usage'))
1162 1162
             {
1163 1163
                 $memory_peak_usage = memory_get_peak_usage();
1164 1164
                 $bytes = $GLOBALS['app_strings']['LBL_SERVER_MEMORY_BYTES'];
1165 1165
                 $data = array($memory_peak_usage, $bytes);
1166
-                $log_message .= string_format($GLOBALS['app_strings']['LBL_SERVER_PEAK_MEMORY_USAGE'], $data) . $newline;
1166
+                $log_message .= string_format($GLOBALS['app_strings']['LBL_SERVER_PEAK_MEMORY_USAGE'], $data).$newline;
1167 1167
             }
1168 1168
 
1169
-            if(!empty($log_message))
1169
+            if (!empty($log_message))
1170 1170
             {
1171
-                $data = array
1172
-                (
1171
+                $data = array(
1173 1172
                    !empty($this->module) ? $this->module : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1174 1173
                    !empty($this->action) ? $this->action : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1175 1174
                 );
1176 1175
 
1177
-                $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data) . $newline;
1176
+                $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data).$newline;
1178 1177
                 $output .= $log_message;
1179 1178
                 $fp = fopen("memory_usage.log", "ab");
1180 1179
                 fwrite($fp, $output);
@@ -1198,30 +1197,30 @@  discard block
 block discarded – undo
1198 1197
     {
1199 1198
         global $current_language, $current_user, $mod_strings, $app_strings, $module_menu;
1200 1199
 
1201
-        if ( empty($module) )
1200
+        if (empty($module))
1202 1201
             $module = $this->module;
1203 1202
 
1204 1203
         //Need to make sure the mod_strings match the requested module or Menus may fail
1205 1204
         $curr_mod_strings = $mod_strings;
1206
-        $mod_strings = return_module_language ( $current_language, $module ) ;
1205
+        $mod_strings = return_module_language($current_language, $module);
1207 1206
 
1208 1207
         $module_menu = array();
1209 1208
 
1210
-        if (file_exists('modules/' . $module . '/Menu.php')) {
1211
-            require('modules/' . $module . '/Menu.php');
1209
+        if (file_exists('modules/'.$module.'/Menu.php')) {
1210
+            require('modules/'.$module.'/Menu.php');
1212 1211
         }
1213
-        if (file_exists('custom/modules/' . $module . '/Ext/Menus/menu.ext.php')) {
1214
-            require('custom/modules/' . $module . '/Ext/Menus/menu.ext.php');
1212
+        if (file_exists('custom/modules/'.$module.'/Ext/Menus/menu.ext.php')) {
1213
+            require('custom/modules/'.$module.'/Ext/Menus/menu.ext.php');
1215 1214
         }
1216
-        if (!file_exists('modules/' . $module . '/Menu.php')
1217
-                && !file_exists('custom/modules/' . $module . '/Ext/Menus/menu.ext.php')
1215
+        if (!file_exists('modules/'.$module.'/Menu.php')
1216
+                && !file_exists('custom/modules/'.$module.'/Ext/Menus/menu.ext.php')
1218 1217
                 && !empty($GLOBALS['mod_strings']['LNK_NEW_RECORD'])) {
1219 1218
             $module_menu[] = array("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView",
1220
-                $GLOBALS['mod_strings']['LNK_NEW_RECORD'],"{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module" ,$module );
1219
+                $GLOBALS['mod_strings']['LNK_NEW_RECORD'], "{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module", $module);
1221 1220
             $module_menu[] = array("index.php?module=$module&action=index", $GLOBALS['mod_strings']['LNK_LIST'],
1222 1221
                 $module, $module);
1223
-            if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) )
1224
-                if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) )
1222
+            if (($this->bean instanceOf SugarBean) && !empty($this->bean->importable))
1223
+                if (!empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]))
1225 1224
                     $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1226 1225
                         $mod_strings['LNK_IMPORT_'.strtoupper($module)], "Import", $module);
1227 1226
                 else
@@ -1248,22 +1247,22 @@  discard block
 block discarded – undo
1248 1247
 
1249 1248
 		$userTabs = query_module_access_list($current_user);
1250 1249
 		//If the home tab is in the user array use it as the default tab, otherwise use the first element in the tab array
1251
-		$defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1250
+		$defaultTab = (in_array("Home", $userTabs)) ? "Home" : key($userTabs);
1252 1251
 		
1253 1252
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
1254
-        if ( !empty($_REQUEST['module_tab']) )
1253
+        if (!empty($_REQUEST['module_tab']))
1255 1254
             return $_REQUEST['module_tab'];
1256
-        elseif ( isset($moduleTabMap[$this->module]) )
1255
+        elseif (isset($moduleTabMap[$this->module]))
1257 1256
             return $moduleTabMap[$this->module];
1258 1257
         // Special cases
1259
-        elseif ( $this->module == 'MergeRecords' )
1258
+        elseif ($this->module == 'MergeRecords')
1260 1259
             return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module'];
1261
-        elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' )
1260
+        elseif ($this->module == 'Users' && $this->action == 'SetTimezone')
1262 1261
             return $defaultTab;
1263 1262
         // Default anonymous pages to be under Home
1264
-        elseif ( !isset($app_list_strings['moduleList'][$this->module]) )
1263
+        elseif (!isset($app_list_strings['moduleList'][$this->module]))
1265 1264
             return $defaultTab;
1266
-        elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" )
1265
+        elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui")
1267 1266
         	return $defaultTab;
1268 1267
         else
1269 1268
             return $this->module;
@@ -1283,42 +1282,42 @@  discard block
 block discarded – undo
1283 1282
 
1284 1283
         $theTitle = "<div class='moduleTitle'>\n";
1285 1284
 
1286
-        $module = preg_replace("/ /","",$this->module);
1285
+        $module = preg_replace("/ /", "", $this->module);
1287 1286
 
1288 1287
         $params = $this->_getModuleTitleParams();
1289 1288
         $index = 0;
1290 1289
 
1291
-		if(SugarThemeRegistry::current()->directionality == "rtl") {
1290
+		if (SugarThemeRegistry::current()->directionality == "rtl") {
1292 1291
 			$params = array_reverse($params);
1293 1292
 		}
1294
-		if(count($params) > 1) {
1293
+		if (count($params) > 1) {
1295 1294
 			array_shift($params);
1296 1295
 		}
1297 1296
 		$count = count($params);
1298 1297
         $paramString = '';
1299
-        foreach($params as $parm){
1298
+        foreach ($params as $parm) {
1300 1299
             $index++;
1301 1300
             $paramString .= $parm;
1302
-            if($index < $count){
1301
+            if ($index < $count) {
1303 1302
                 $paramString .= $this->getBreadCrumbSymbol();
1304 1303
             }
1305 1304
         }
1306 1305
 
1307
-        if(!empty($paramString)){
1306
+        if (!empty($paramString)) {
1308 1307
                $theTitle .= "<h2> $paramString </h2>";
1309 1308
 
1310
-            if($this->type == "detail"){
1311
-                $theTitle .= "<div class='favorite' record_id='" . $this->bean->id . "' module='" . $this->bean->module_dir . "'><div class='favorite_icon_outline'>" . SugarThemeRegistry::current()->getImage('favorite-star-outline','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div>
1312
-                                                    <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div></div>";
1309
+            if ($this->type == "detail") {
1310
+                $theTitle .= "<div class='favorite' record_id='".$this->bean->id."' module='".$this->bean->module_dir."'><div class='favorite_icon_outline'>".SugarThemeRegistry::current()->getImage('favorite-star-outline', 'title="'.translate('LBL_DASHLET_EDIT', 'Home').'" border="0"  align="absmiddle"', null, null, '.gif', translate('LBL_DASHLET_EDIT', 'Home'))."</div>
1311
+                                                    <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star', 'title="'.translate('LBL_DASHLET_EDIT', 'Home').'" border="0"  align="absmiddle"', null, null, '.gif', translate('LBL_DASHLET_EDIT', 'Home'))."</div></div>";
1313 1312
             }
1314 1313
            }
1315 1314
 
1316 1315
         // bug 56131 - restore conditional so that link doesn't appear where it shouldn't
1317
-        if($show_help || $this->type == 'list') {
1316
+        if ($show_help || $this->type == 'list') {
1318 1317
             $theTitle .= "<span class='utils'>";
1319 1318
             $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
1320
-            if($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>';$url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1321
-            if($show_help) {
1319
+            if ($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>'; $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1320
+            if ($show_help) {
1322 1321
                 $theTitle .= <<<EOHTML
1323 1322
 &nbsp;
1324 1323
 <a id="create_image" href="{$url}" class="utilsLink">
@@ -1344,31 +1343,31 @@  discard block
 block discarded – undo
1344 1343
     {
1345 1344
         $metadataFile = null;
1346 1345
         $foundViewDefs = false;
1347
-        $viewDef = strtolower($this->type) . 'viewdefs';
1348
-        $coreMetaPath = 'modules/'.$this->module.'/metadata/' . $viewDef . '.php';
1349
-        if(file_exists('custom/' .$coreMetaPath )){
1350
-            $metadataFile = 'custom/' . $coreMetaPath;
1346
+        $viewDef = strtolower($this->type).'viewdefs';
1347
+        $coreMetaPath = 'modules/'.$this->module.'/metadata/'.$viewDef.'.php';
1348
+        if (file_exists('custom/'.$coreMetaPath)) {
1349
+            $metadataFile = 'custom/'.$coreMetaPath;
1351 1350
             $foundViewDefs = true;
1352
-        }else{
1353
-            if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
1351
+        } else {
1352
+            if (file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')) {
1354 1353
                 require_once('custom/modules/'.$this->module.'/metadata/metafiles.php');
1355
-                if(!empty($metafiles[$this->module][$viewDef])){
1354
+                if (!empty($metafiles[$this->module][$viewDef])) {
1356 1355
                     $metadataFile = $metafiles[$this->module][$viewDef];
1357 1356
                     $foundViewDefs = true;
1358 1357
                 }
1359
-            }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
1358
+            }elseif (file_exists('modules/'.$this->module.'/metadata/metafiles.php')) {
1360 1359
                 require_once('modules/'.$this->module.'/metadata/metafiles.php');
1361
-                if(!empty($metafiles[$this->module][$viewDef])){
1360
+                if (!empty($metafiles[$this->module][$viewDef])) {
1362 1361
                     $metadataFile = $metafiles[$this->module][$viewDef];
1363 1362
                     $foundViewDefs = true;
1364 1363
                 }
1365 1364
             }
1366 1365
         }
1367 1366
 
1368
-        if(!$foundViewDefs && file_exists($coreMetaPath)){
1367
+        if (!$foundViewDefs && file_exists($coreMetaPath)) {
1369 1368
                 $metadataFile = $coreMetaPath;
1370 1369
         }
1371
-        $GLOBALS['log']->debug("metadatafile=". $metadataFile);
1370
+        $GLOBALS['log']->debug("metadatafile=".$metadataFile);
1372 1371
 
1373 1372
         return $metadataFile;
1374 1373
     }
@@ -1385,10 +1384,10 @@  discard block
 block discarded – undo
1385 1384
     {
1386 1385
         $params = array($this->_getModuleTitleListParam($browserTitle));
1387 1386
 		//$params = array();
1388
-        if (isset($this->action)){
1387
+        if (isset($this->action)) {
1389 1388
             switch ($this->action) {
1390 1389
             case 'EditView':
1391
-                if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1390
+                if (!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1392 1391
                     $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1393 1392
                     $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1394 1393
                 }
@@ -1412,18 +1411,18 @@  discard block
 block discarded – undo
1412 1411
      *                           there should be no HTML in the string
1413 1412
      * @return string
1414 1413
      */
1415
-    protected function _getModuleTitleListParam( $browserTitle = false )
1414
+    protected function _getModuleTitleListParam($browserTitle = false)
1416 1415
     {
1417 1416
     	global $current_user;
1418 1417
     	global $app_strings;
1419 1418
 
1420
-    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1419
+    	if (!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1421 1420
     		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1422 1421
     	else
1423 1422
     		$firstParam = $this->module;
1424 1423
 
1425 1424
     	$iconPath = $this->getModuleTitleIconPath($this->module);
1426
-    	if($this->action == "ListView" || $this->action == "index") {
1425
+    	if ($this->action == "ListView" || $this->action == "index") {
1427 1426
     	    if (!empty($iconPath) && !$browserTitle) {
1428 1427
     	    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1429 1428
     	    		return $app_strings['LBL_SEARCH']."&nbsp;"
@@ -1449,10 +1448,10 @@  discard block
 block discarded – undo
1449 1448
     protected function getModuleTitleIconPath($module)
1450 1449
     {
1451 1450
     	$iconPath = "";
1452
-    	if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1451
+    	if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png', false))) {
1453 1452
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1454 1453
     	}
1455
-    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1454
+    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png', false))) {
1456 1455
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1457 1456
     	}
1458 1457
     	return $iconPath;
@@ -1469,11 +1468,11 @@  discard block
 block discarded – undo
1469 1468
         global $app_strings;
1470 1469
 
1471 1470
         $browserTitle = $app_strings['LBL_BROWSER_TITLE'];
1472
-        if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') )
1471
+        if ($this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login'))
1473 1472
             return $browserTitle;
1474 1473
         $params = $this->_getModuleTitleParams(true);
1475
-        foreach ($params as $value )
1476
-            $browserTitle = strip_tags($value) . ' &raquo; ' . $browserTitle;
1474
+        foreach ($params as $value)
1475
+            $browserTitle = strip_tags($value).' &raquo; '.$browserTitle;
1477 1476
 
1478 1477
         return $browserTitle;
1479 1478
     }
@@ -1485,7 +1484,7 @@  discard block
 block discarded – undo
1485 1484
      */
1486 1485
     public function getBreadCrumbSymbol()
1487 1486
     {
1488
-    	if(SugarThemeRegistry::current()->directionality == "ltr") {
1487
+    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1489 1488
         	return "<span class='pointer'>&raquo;</span>";
1490 1489
         }
1491 1490
         else {
@@ -1498,29 +1497,29 @@  discard block
 block discarded – undo
1498 1497
      *
1499 1498
      * @return array
1500 1499
      */
1501
-    protected function getSugarConfigJS(){
1500
+    protected function getSugarConfigJS() {
1502 1501
         global $sugar_config;
1503 1502
 
1504 1503
         // Set all the config parameters in the JS config as necessary
1505 1504
         $config_js = array();
1506 1505
         // AjaxUI stock banned modules
1507 1506
         $config_js[] = "SUGAR.config.stockAjaxBannedModules = ".json_encode(ajaxBannedModules()).";";
1508
-        if ( isset($sugar_config['quicksearch_querydelay']) ) {
1507
+        if (isset($sugar_config['quicksearch_querydelay'])) {
1509 1508
             $config_js[] = $this->prepareConfigVarForJs('quicksearch_querydelay', $sugar_config['quicksearch_querydelay']);
1510 1509
         }
1511
-        if ( empty($sugar_config['disableAjaxUI']) ) {
1510
+        if (empty($sugar_config['disableAjaxUI'])) {
1512 1511
             $config_js[] = "SUGAR.config.disableAjaxUI = false;";
1513 1512
         }
1514
-        else{
1513
+        else {
1515 1514
             $config_js[] = "SUGAR.config.disableAjaxUI = true;";
1516 1515
         }
1517
-        if ( !empty($sugar_config['addAjaxBannedModules']) ){
1516
+        if (!empty($sugar_config['addAjaxBannedModules'])) {
1518 1517
             $config_js[] = $this->prepareConfigVarForJs('addAjaxBannedModules', $sugar_config['addAjaxBannedModules']);
1519 1518
         }
1520
-        if ( !empty($sugar_config['overrideAjaxBannedModules']) ){
1519
+        if (!empty($sugar_config['overrideAjaxBannedModules'])) {
1521 1520
             $config_js[] = $this->prepareConfigVarForJs('overrideAjaxBannedModules', $sugar_config['overrideAjaxBannedModules']);
1522 1521
         }
1523
-        if (!empty($sugar_config['js_available']) && is_array ($sugar_config['js_available']))
1522
+        if (!empty($sugar_config['js_available']) && is_array($sugar_config['js_available']))
1524 1523
         {
1525 1524
             foreach ($sugar_config['js_available'] as $configKey)
1526 1525
             {
@@ -1581,7 +1580,7 @@  discard block
 block discarded – undo
1581 1580
     protected function getFavicon()
1582 1581
     {
1583 1582
         // get favicon
1584
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
1583
+        if (isset($GLOBALS['sugar_config']['default_module_favicon']))
1585 1584
             $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
1586 1585
         else
1587 1586
             $module_favicon = false;
@@ -1589,10 +1588,10 @@  discard block
 block discarded – undo
1589 1588
         $themeObject = SugarThemeRegistry::current();
1590 1589
 
1591 1590
         $favicon = '';
1592
-        if ( $module_favicon )
1593
-            $favicon = $themeObject->getImageURL($this->module.'.gif',false);
1594
-        if ( !sugar_is_file($favicon) || !$module_favicon )
1595
-            $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
1591
+        if ($module_favicon)
1592
+            $favicon = $themeObject->getImageURL($this->module.'.gif', false);
1593
+        if (!sugar_is_file($favicon) || !$module_favicon)
1594
+            $favicon = $themeObject->getImageURL('sugar_icon.ico', false);
1596 1595
 
1597 1596
         $extension = pathinfo($favicon, PATHINFO_EXTENSION);
1598 1597
         switch ($extension)
@@ -1649,10 +1648,10 @@  discard block
 block discarded – undo
1649 1648
      * @return array augmented history with image link and shortened name
1650 1649
      */
1651 1650
     protected function processRecentRecords($history) {
1652
-        foreach ( $history as $key => $row ) {
1651
+        foreach ($history as $key => $row) {
1653 1652
             $history[$key]['item_summary_short'] = to_html(getTrackerSubstring($row['item_summary'])); //bug 56373 - need to re-HTML-encode
1654 1653
             $history[$key]['image'] = SugarThemeRegistry::current()
1655
-                ->getImage($row['module_name'],'border="0" align="absmiddle"',null,null,'.gif',$row['item_summary']);
1654
+                ->getImage($row['module_name'], 'border="0" align="absmiddle"', null, null, '.gif', $row['item_summary']);
1656 1655
         }
1657 1656
         return $history;
1658 1657
     }
@@ -1666,10 +1665,10 @@  discard block
 block discarded – undo
1666 1665
      *
1667 1666
 	 * @return boolean indicating true or false
1668 1667
 	 */
1669
-    public function checkPostMaxSizeError(){
1668
+    public function checkPostMaxSizeError() {
1670 1669
          //if the referrer is post, and the post array is empty, then an error has occurred, most likely
1671 1670
          //while uploading a file that exceeds the post_max_size.
1672
-         if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
1671
+         if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
1673 1672
              $GLOBALS['log']->fatal($GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT']);
1674 1673
              return true;
1675 1674
         }
Please login to merge, or discard this patch.
include/MVC/Controller/ControllerFactory.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,31 +49,31 @@
 block discarded – undo
49 49
 	 *
50 50
 	 * @return an instance of SugarController
51 51
 	 */
52
-	static function getController($module){
52
+	static function getController($module) {
53 53
 		$class = ucfirst($module).'Controller';
54
-		$customClass = 'Custom' . $class;
55
-		if(file_exists('custom/modules/'.$module.'/controller.php')){
56
-			$customClass = 'Custom' . $class;
54
+		$customClass = 'Custom'.$class;
55
+		if (file_exists('custom/modules/'.$module.'/controller.php')) {
56
+			$customClass = 'Custom'.$class;
57 57
 			require_once('custom/modules/'.$module.'/controller.php');
58
-			if(class_exists($customClass)){
58
+			if (class_exists($customClass)) {
59 59
 				$controller = new $customClass();
60
-			}else if(class_exists($class)){
60
+			} else if (class_exists($class)) {
61 61
 				$controller = new $class();
62 62
 			}
63
-		}elseif(file_exists('modules/'.$module.'/controller.php')){
63
+		}elseif (file_exists('modules/'.$module.'/controller.php')) {
64 64
 			require_once('modules/'.$module.'/controller.php');
65
-			if(class_exists($customClass)){
65
+			if (class_exists($customClass)) {
66 66
 				$controller = new $customClass();
67
-			}else if(class_exists($class)){
67
+			} else if (class_exists($class)) {
68 68
 				$controller = new $class();
69 69
 			}
70
-		}else{
71
-			if(file_exists('custom/include/MVC/Controller/SugarController.php')){
70
+		} else {
71
+			if (file_exists('custom/include/MVC/Controller/SugarController.php')) {
72 72
 				require_once('custom/include/MVC/Controller/SugarController.php');
73 73
 			}
74
-			if(class_exists('CustomSugarController')){
74
+			if (class_exists('CustomSugarController')) {
75 75
 				$controller = new CustomSugarController();
76
-			}else{
76
+			} else {
77 77
 			$controller = new SugarController();
78 78
 			}
79 79
 		}
Please login to merge, or discard this patch.
include/MVC/Controller/SugarController.php 1 patch
Spacing   +146 added lines, -151 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
  * Main SugarCRM controller
44 44
  * @api
45 45
  */
46
-class SugarController{
46
+class SugarController {
47 47
 	/**
48 48
 	 * remap actions in here
49 49
 	 * e.g. make all detail views go to edit views
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * Constructor. This ie meant tot load up the module, action, record as well
163 163
 	 * as the mapping arrays.
164 164
 	 */
165
-	function SugarController(){
165
+	function SugarController() {
166 166
 	}
167 167
 
168 168
 	/**
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 	 * on the controller.
171 171
 	 *
172 172
 	 */
173
-	public function setup($module = ''){
174
-		if(empty($module) && !empty($_REQUEST['module']))
173
+	public function setup($module = '') {
174
+		if (empty($module) && !empty($_REQUEST['module']))
175 175
 			$module = $_REQUEST['module'];
176 176
 		//set the module
177
-		if(!empty($module))
177
+		if (!empty($module))
178 178
 			$this->setModule($module);
179 179
 
180
-		if(!empty($_REQUEST['target_module']) && $_REQUEST['target_module'] != 'undefined') {
180
+		if (!empty($_REQUEST['target_module']) && $_REQUEST['target_module'] != 'undefined') {
181 181
 			$this->target_module = $_REQUEST['target_module'];
182 182
 		}
183 183
 		//set properties on the controller from the $_REQUEST
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @param object $module
192 192
 	 */
193
-	public function setModule($module){
193
+	public function setModule($module) {
194 194
 		$this->module = $module;
195 195
 	}
196 196
 
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
 	 * Set properties on the Controller from the $_REQUEST
199 199
 	 *
200 200
 	 */
201
-	private function loadPropertiesFromRequest(){
202
-		if(!empty($_REQUEST['action']))
201
+	private function loadPropertiesFromRequest() {
202
+		if (!empty($_REQUEST['action']))
203 203
 			$this->action = $_REQUEST['action'];
204
-		if(!empty($_REQUEST['record']))
204
+		if (!empty($_REQUEST['record']))
205 205
 			$this->record = $_REQUEST['record'];
206
-		if(!empty($_REQUEST['view']))
206
+		if (!empty($_REQUEST['view']))
207 207
 			$this->view = $_REQUEST['view'];
208
-		if(!empty($_REQUEST['return_module']))
208
+		if (!empty($_REQUEST['return_module']))
209 209
 			$this->return_module = $_REQUEST['return_module'];
210
-		if(!empty($_REQUEST['return_action']))
210
+		if (!empty($_REQUEST['return_action']))
211 211
 			$this->return_action = $_REQUEST['return_action'];
212
-		if(!empty($_REQUEST['return_id']))
212
+		if (!empty($_REQUEST['return_id']))
213 213
 			$this->return_id = $_REQUEST['return_id'];
214 214
 	}
215 215
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * Load map files for use within the Controller
218 218
 	 *
219 219
 	 */
220
-	private function loadMappings(){
220
+	private function loadMappings() {
221 221
 		$this->loadMapping('action_view_map');
222 222
 		$this->loadMapping('action_file_map');
223 223
 		$this->loadMapping('action_remap', true);
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	public function loadBean()
230 230
 	{
231
-		if(!empty($GLOBALS['beanList'][$this->module])){
231
+		if (!empty($GLOBALS['beanList'][$this->module])) {
232 232
 			$class = $GLOBALS['beanList'][$this->module];
233
-			if(!empty($GLOBALS['beanFiles'][$class])){
233
+			if (!empty($GLOBALS['beanFiles'][$class])) {
234 234
 				require_once($GLOBALS['beanFiles'][$class]);
235 235
 				$this->bean = new $class();
236
-				if(!empty($this->record)){
236
+				if (!empty($this->record)) {
237 237
 					$this->bean->retrieve($this->record);
238
-					if($this->bean)
238
+					if ($this->bean)
239 239
 						$GLOBALS['FOCUS'] = $this->bean;
240 240
 				}
241 241
 			}
@@ -245,38 +245,38 @@  discard block
 block discarded – undo
245 245
 	/**
246 246
 	 * Generic load method to load mapping arrays.
247 247
 	 */
248
-	private function loadMapping($var, $merge = false){
249
-		$$var = sugar_cache_retrieve("CONTROLLER_". $var . "_".$this->module);
250
-		if(!$$var){
251
-			if($merge && !empty($this->$var)){
248
+	private function loadMapping($var, $merge = false) {
249
+		$$var = sugar_cache_retrieve("CONTROLLER_".$var."_".$this->module);
250
+		if (!$$var) {
251
+			if ($merge && !empty($this->$var)) {
252 252
 				$$var = $this->$var;
253
-			}else{
253
+			} else {
254 254
 				$$var = array();
255 255
 			}
256
-			if(file_exists('include/MVC/Controller/'. $var . '.php')){
257
-				require('include/MVC/Controller/'. $var . '.php');
256
+			if (file_exists('include/MVC/Controller/'.$var.'.php')) {
257
+				require('include/MVC/Controller/'.$var.'.php');
258 258
 			}
259
-			if(file_exists('modules/'.$this->module.'/'. $var . '.php')){
260
-				require('modules/'.$this->module.'/'. $var . '.php');
259
+			if (file_exists('modules/'.$this->module.'/'.$var.'.php')) {
260
+				require('modules/'.$this->module.'/'.$var.'.php');
261 261
 			}
262
-			if(file_exists('custom/modules/'.$this->module.'/'. $var . '.php')){
263
-				require('custom/modules/'.$this->module.'/'. $var . '.php');
262
+			if (file_exists('custom/modules/'.$this->module.'/'.$var.'.php')) {
263
+				require('custom/modules/'.$this->module.'/'.$var.'.php');
264 264
 			}
265
-			if(file_exists('custom/include/MVC/Controller/'. $var . '.php')){
266
-				require('custom/include/MVC/Controller/'. $var . '.php');
265
+			if (file_exists('custom/include/MVC/Controller/'.$var.'.php')) {
266
+				require('custom/include/MVC/Controller/'.$var.'.php');
267 267
 			}
268 268
 
269 269
             // entry_point_registry -> EntryPointRegistry
270 270
 
271
-			$varname = str_replace(" ","",ucwords(str_replace("_"," ", $var)));
272
-            if(file_exists("custom/application/Ext/$varname/$var.ext.php")){
271
+			$varname = str_replace(" ", "", ucwords(str_replace("_", " ", $var)));
272
+            if (file_exists("custom/application/Ext/$varname/$var.ext.php")) {
273 273
 				require("custom/application/Ext/$varname/$var.ext.php");
274 274
 	        }
275
-			if(file_exists("custom/modules/{$this->module}/Ext/$varname/$var.ext.php")){
275
+			if (file_exists("custom/modules/{$this->module}/Ext/$varname/$var.ext.php")) {
276 276
 				require("custom/modules/{$this->module}/Ext/$varname/$var.ext.php");
277 277
 			}
278 278
 
279
-			sugar_cache_put("CONTROLLER_". $var . "_".$this->module, $$var);
279
+			sugar_cache_put("CONTROLLER_".$var."_".$this->module, $$var);
280 280
 		}
281 281
 		$this->$var = $$var;
282 282
 	}
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
         try
291 291
         {
292 292
             $this->process();
293
-            if(!empty($this->view))
293
+            if (!empty($this->view))
294 294
             {
295 295
                 $this->processView();
296 296
             }
297
-            elseif(!empty($this->redirect_url))
297
+            elseif (!empty($this->redirect_url))
298 298
             {
299 299
             			$this->redirect();
300 300
             }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
       */
315 315
     protected function handleException(Exception $e)
316 316
     {
317
-        $GLOBALS['log']->fatal('Exception in Controller: ' . $e->getMessage());
317
+        $GLOBALS['log']->fatal('Exception in Controller: '.$e->getMessage());
318 318
         $logicHook = new LogicHook();
319 319
 
320 320
         if (isset($this->bean))
@@ -331,18 +331,18 @@  discard block
 block discarded – undo
331 331
 	/**
332 332
 	 * Display the appropriate view.
333 333
 	 */
334
-	private function processView(){
335
-		if(!isset($this->view_object_map['remap_action']) && isset($this->action_view_map[strtolower($this->action)]))
334
+	private function processView() {
335
+		if (!isset($this->view_object_map['remap_action']) && isset($this->action_view_map[strtolower($this->action)]))
336 336
 		{
337 337
 		  $this->view_object_map['remap_action'] = $this->action_view_map[strtolower($this->action)];
338 338
 		}
339 339
 		$view = ViewFactory::loadView($this->view, $this->module, $this->bean, $this->view_object_map, $this->target_module);
340 340
 		$GLOBALS['current_view'] = $view;
341
-		if(!empty($this->bean) && !$this->bean->ACLAccess($view->type) && $view->type != 'list'){
341
+		if (!empty($this->bean) && !$this->bean->ACLAccess($view->type) && $view->type != 'list') {
342 342
 			ACLController::displayNoAccess(true);
343 343
 			sugar_cleanup(true);
344 344
 		}
345
-		if(isset($this->errors)){
345
+		if (isset($this->errors)) {
346 346
 		  $view->errors = $this->errors;
347 347
 		}
348 348
 		$view->process();
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 * 1) check for file
362 362
 	 * 2) check for action
363 363
 	 */
364
-	public function process(){
364
+	public function process() {
365 365
 		$GLOBALS['action'] = $this->action;
366 366
 		$GLOBALS['module'] = $this->module;
367 367
 
368 368
 		//check to ensure we have access to the module.
369
-		if($this->hasAccess){
369
+		if ($this->hasAccess) {
370 370
 			$this->do_action = $this->action;
371 371
 
372 372
 			$file = self::getActionFilename($this->do_action);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
             }
385 385
 
386 386
 			$this->redirect();
387
-		}else{
387
+		} else {
388 388
 			$this->no_access();
389 389
 		}
390 390
 	}
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 	 * false otherwise.  This is important b/c if none of these methods exists, then we will run the
399 399
 	 * action_default() method.
400 400
 	 */
401
-	protected function handle_action(){
401
+	protected function handle_action() {
402 402
 		$processed = false;
403
-		foreach($this->tasks as $task){
403
+		foreach ($this->tasks as $task) {
404 404
 			$processed = ($this->$task() || $processed);
405 405
 		}
406 406
 		$this->_processed = $processed;
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 	 * Perform an action prior to the specified action.
411 411
 	 * This can be overridde in a sub-class
412 412
 	 */
413
-	private function pre_action(){
414
-		$function = 'pre_' . $this->action;
415
-		if($this->hasFunction($function)){
413
+	private function pre_action() {
414
+		$function = 'pre_'.$this->action;
415
+		if ($this->hasFunction($function)) {
416 416
 			$GLOBALS['log']->debug('Performing pre_action');
417 417
 			$this->$function();
418 418
 			return true;
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
 	 * Perform the specified action.
425 425
 	 * This can be overridde in a sub-class
426 426
 	 */
427
-	private function do_action(){
428
-		$function =  'action_'. strtolower($this->do_action);
429
-		if($this->hasFunction($function)){
427
+	private function do_action() {
428
+		$function = 'action_'.strtolower($this->do_action);
429
+		if ($this->hasFunction($function)) {
430 430
 			$GLOBALS['log']->debug('Performing action: '.$function.' MODULE: '.$this->module);
431 431
 			$this->$function();
432 432
 			return true;
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 	 * Perform an action after to the specified action has occurred.
439 439
 	 * This can be overridde in a sub-class
440 440
 	 */
441
-	private function post_action(){
442
-		$function = 'post_' . $this->action;
443
-		if($this->hasFunction($function)){
441
+	private function post_action() {
442
+		$function = 'post_'.$this->action;
443
+		if ($this->hasFunction($function)) {
444 444
 			$GLOBALS['log']->debug('Performing post_action');
445 445
 			$this->$function();
446 446
 			return true;
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
 	/**
452 452
 	 * If there is no action found then display an error to the user.
453 453
 	 */
454
-	protected function no_action(){
454
+	protected function no_action() {
455 455
 		sugar_die($GLOBALS['app_strings']['LBL_NO_ACTION']);
456 456
 	}
457 457
 
458 458
 	/**
459 459
 	 * The default action handler for instances where we do not have access to process.
460 460
 	 */
461
-	protected function no_access(){
461
+	protected function no_access() {
462 462
 		$this->view = 'noaccess';
463 463
 	}
464 464
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @param function - the function to check
472 472
 	 * @return true if the method exists on the object, false otherwise
473 473
 	 */
474
-	protected function hasFunction($function){
474
+	protected function hasFunction($function) {
475 475
 		return method_exists($this, $function);
476 476
 	}
477 477
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @param string url - the url to which we will want to redirect
483 483
 	 */
484
-	protected function set_redirect($url){
484
+	protected function set_redirect($url) {
485 485
 		$this->redirect_url = $url;
486 486
 	}
487 487
 
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
 	 * Perform redirection based on the redirect_url
490 490
 	 *
491 491
 	 */
492
-	protected function redirect(){
492
+	protected function redirect() {
493 493
 
494
-		if(!empty($this->redirect_url))
494
+		if (!empty($this->redirect_url))
495 495
 			SugarApplication::redirect($this->redirect_url);
496 496
 	}
497 497
 
@@ -506,38 +506,38 @@  discard block
 block discarded – undo
506 506
 	/**
507 507
 	 * Do some processing before saving the bean to the database.
508 508
 	 */
509
-	public function pre_save(){
510
-		if(!empty($_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $this->bean->assigned_user_id && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id && empty($GLOBALS['sugar_config']['exclude_notifications'][$this->bean->module_dir])){
509
+	public function pre_save() {
510
+		if (!empty($_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $this->bean->assigned_user_id && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id && empty($GLOBALS['sugar_config']['exclude_notifications'][$this->bean->module_dir])) {
511 511
 			$this->bean->notify_on_save = true;
512 512
 		}
513 513
 		$GLOBALS['log']->debug("SugarController:: performing pre_save.");
514 514
         require_once('include/SugarFields/SugarFieldHandler.php');
515 515
         $sfh = new SugarFieldHandler();
516
-		foreach($this->bean->field_defs as $field => $properties) {
516
+		foreach ($this->bean->field_defs as $field => $properties) {
517 517
 			$type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
518 518
 		    $sf = $sfh->getSugarField(ucfirst($type), true);
519
-			if(isset($_POST[$field])) {
520
-				if(is_array($_POST[$field]) && !empty($properties['isMultiSelect'])) {
521
-					if(empty($_POST[$field][0])) {
519
+			if (isset($_POST[$field])) {
520
+				if (is_array($_POST[$field]) && !empty($properties['isMultiSelect'])) {
521
+					if (empty($_POST[$field][0])) {
522 522
 						unset($_POST[$field][0]);
523 523
 					}
524 524
 					$_POST[$field] = encodeMultienumValue($_POST[$field]);
525 525
 				}
526 526
 				$this->bean->$field = $_POST[$field];
527
-			} else if(!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field . '_multiselect'])) {
527
+			} else if (!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field.'_multiselect'])) {
528 528
 				$this->bean->$field = '';
529 529
 			}
530
-            if($sf != null){
530
+            if ($sf != null) {
531 531
                 $sf->save($this->bean, $_POST, $field, $properties);
532 532
             }
533 533
 		}
534 534
 
535
-		foreach($this->bean->relationship_fields as $field=>$link){
536
-			if(!empty($_POST[$field])){
535
+		foreach ($this->bean->relationship_fields as $field=>$link) {
536
+			if (!empty($_POST[$field])) {
537 537
 				$this->bean->$field = $_POST[$field];
538 538
 			}
539 539
 		}
540
-		if(!$this->bean->ACLAccess('save')){
540
+		if (!$this->bean->ACLAccess('save')) {
541 541
 			ACLController::displayNoAccess(true);
542 542
 			sugar_cleanup(true);
543 543
 		}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	/**
548 548
 	 * Perform the actual save
549 549
 	 */
550
-	public function action_save(){
550
+	public function action_save() {
551 551
 		$this->bean->save(!empty($this->bean->notify_on_save));
552 552
 	}
553 553
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 	/**
562 562
 	 * Specify what happens after the save has occurred.
563 563
 	 */
564
-	protected function post_save(){
564
+	protected function post_save() {
565 565
 		$module = (!empty($this->return_module) ? $this->return_module : $this->module);
566 566
 		$action = (!empty($this->return_action) ? $this->return_action : 'DetailView');
567 567
 		$id = (!empty($this->return_id) ? $this->return_id : $this->bean->id);
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
 	/**
578 578
 	 * Perform the actual deletion.
579 579
 	 */
580
-	protected function action_delete(){
580
+	protected function action_delete() {
581 581
 		//do any pre delete processing
582 582
 		//if there is some custom logic for deletion.
583
-		if(!empty($_REQUEST['record'])){
584
-			if(!$this->bean->ACLAccess('Delete')){
583
+		if (!empty($_REQUEST['record'])) {
584
+			if (!$this->bean->ACLAccess('Delete')) {
585 585
 				ACLController::displayNoAccess(true);
586 586
 				sugar_cleanup(true);
587 587
 			}
588 588
 			$this->bean->mark_deleted($_REQUEST['record']);
589
-		}else{
589
+		} else {
590 590
 			sugar_die("A record number must be specified to delete");
591 591
 		}
592 592
 	}
@@ -594,24 +594,21 @@  discard block
 block discarded – undo
594 594
 	/**
595 595
 	 * Specify what happens after the deletion has occurred.
596 596
 	 */
597
-	protected function post_delete(){
597
+	protected function post_delete() {
598 598
         if (empty($_REQUEST['return_url'])) {
599 599
             $return_module = isset($_REQUEST['return_module']) ?
600
-                $_REQUEST['return_module'] :
601
-                $GLOBALS['sugar_config']['default_module'];
600
+                $_REQUEST['return_module'] : $GLOBALS['sugar_config']['default_module'];
602 601
             $return_action = isset($_REQUEST['return_action']) ?
603
-                $_REQUEST['return_action'] :
604
-                $GLOBALS['sugar_config']['default_action'];
602
+                $_REQUEST['return_action'] : $GLOBALS['sugar_config']['default_action'];
605 603
             $return_id = isset($_REQUEST['return_id']) ?
606
-                $_REQUEST['return_id'] :
607
-                '';
604
+                $_REQUEST['return_id'] : '';
608 605
             $url = "index.php?module=".$return_module."&action=".$return_action."&record=".$return_id;
609 606
         } else {
610 607
             $url = $_REQUEST['return_url'];
611 608
         }
612 609
 
613 610
 		//eggsurplus Bug 23816: maintain VCR after an edit/save. If it is a duplicate then don't worry about it. The offset is now worthless.
614
-		if(isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
611
+		if (isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
615 612
 		    $url .= "&offset=".$_REQUEST['offset'];
616 613
 		}
617 614
 
@@ -620,15 +617,15 @@  discard block
 block discarded – undo
620 617
 	/**
621 618
 	 * Perform the actual massupdate.
622 619
 	 */
623
-	protected function action_massupdate(){
624
-		if(!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))){
625
-			if(!empty($_REQUEST['Delete']) && $_REQUEST['Delete']=='true' && !$this->bean->ACLAccess('delete')
626
-                || (empty($_REQUEST['Delete']) || $_REQUEST['Delete']!='true') && !$this->bean->ACLAccess('save')){
620
+	protected function action_massupdate() {
621
+		if (!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))) {
622
+			if (!empty($_REQUEST['Delete']) && $_REQUEST['Delete'] == 'true' && !$this->bean->ACLAccess('delete')
623
+                || (empty($_REQUEST['Delete']) || $_REQUEST['Delete'] != 'true') && !$this->bean->ACLAccess('save')) {
627 624
 				ACLController::displayNoAccess(true);
628 625
 				sugar_cleanup(true);
629 626
 			}
630 627
 
631
-            set_time_limit(0);//I'm wondering if we will set it never goes timeout here.
628
+            set_time_limit(0); //I'm wondering if we will set it never goes timeout here.
632 629
             // until we have more efficient way of handling MU, we have to disable the limit
633 630
             $GLOBALS['db']->setQueryLimit(0);
634 631
             require_once("include/MassUpdate.php");
@@ -636,40 +633,38 @@  discard block
 block discarded – undo
636 633
             $seed = loadBean($_REQUEST['module']);
637 634
             $mass = new MassUpdate();
638 635
             $mass->setSugarBean($seed);
639
-            if(isset($_REQUEST['entire']) && empty($_POST['mass'])) {
636
+            if (isset($_REQUEST['entire']) && empty($_POST['mass'])) {
640 637
                 $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']);
641 638
             }
642 639
             $mass->handleMassUpdate();
643
-            $storeQuery = new StoreQuery();//restore the current search. to solve bug 24722 for multi tabs massupdate.
640
+            $storeQuery = new StoreQuery(); //restore the current search. to solve bug 24722 for multi tabs massupdate.
644 641
             $temp_req = array('current_query_by_page' => $_REQUEST['current_query_by_page'], 'return_module' => $_REQUEST['return_module'], 'return_action' => $_REQUEST['return_action']);
645
-            if($_REQUEST['return_module'] == 'Emails') {
646
-                if(!empty($_REQUEST['type']) && !empty($_REQUEST['ie_assigned_user_id'])) {
642
+            if ($_REQUEST['return_module'] == 'Emails') {
643
+                if (!empty($_REQUEST['type']) && !empty($_REQUEST['ie_assigned_user_id'])) {
647 644
                     $this->req_for_email = array('type' => $_REQUEST['type'], 'ie_assigned_user_id' => $_REQUEST['ie_assigned_user_id']); // Specifically for My Achieves
648 645
                 }
649 646
             }
650 647
             $_REQUEST = array();
651 648
             $_REQUEST = unserialize(base64_decode($temp_req['current_query_by_page']));
652
-            unset($_REQUEST[$seed->module_dir.'2_'.strtoupper($seed->object_name).'_offset']);//after massupdate, the page should redirect to no offset page
649
+            unset($_REQUEST[$seed->module_dir.'2_'.strtoupper($seed->object_name).'_offset']); //after massupdate, the page should redirect to no offset page
653 650
             $storeQuery->saveFromRequest($_REQUEST['module']);
654
-            $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']);//for post_massupdate, to go back to original page.
655
-		}else{
651
+            $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']); //for post_massupdate, to go back to original page.
652
+		} else {
656 653
 			sugar_die("You must massupdate at least one record");
657 654
 		}
658 655
 	}
659 656
 	/**
660 657
 	 * Specify what happens after the massupdate has occurred.
661 658
 	 */
662
-	protected function post_massupdate(){
659
+	protected function post_massupdate() {
663 660
 		$return_module = isset($_REQUEST['return_module']) ?
664
-			$_REQUEST['return_module'] :
665
-			$GLOBALS['sugar_config']['default_module'];
661
+			$_REQUEST['return_module'] : $GLOBALS['sugar_config']['default_module'];
666 662
 		$return_action = isset($_REQUEST['return_action']) ?
667
-			$_REQUEST['return_action'] :
668
-			$GLOBALS['sugar_config']['default_action'];
663
+			$_REQUEST['return_action'] : $GLOBALS['sugar_config']['default_action'];
669 664
 		$url = "index.php?module=".$return_module."&action=".$return_action;
670
-		if($return_module == 'Emails'){//specificly for My Achieves
671
-			if(!empty($this->req_for_email['type']) && !empty($this->req_for_email['ie_assigned_user_id'])) {
672
-				$url = $url . "&type=".$this->req_for_email['type']."&assigned_user_id=".$this->req_for_email['ie_assigned_user_id'];
665
+		if ($return_module == 'Emails') {//specificly for My Achieves
666
+			if (!empty($this->req_for_email['type']) && !empty($this->req_for_email['ie_assigned_user_id'])) {
667
+				$url = $url."&type=".$this->req_for_email['type']."&assigned_user_id=".$this->req_for_email['ie_assigned_user_id'];
673 668
 			}
674 669
 		}
675 670
 		$this->set_redirect($url);
@@ -677,7 +672,7 @@  discard block
 block discarded – undo
677 672
 	/**
678 673
 	 * Perform the listview action
679 674
 	 */
680
-	protected function action_listview(){
675
+	protected function action_listview() {
681 676
 		$this->view_object_map['bean'] = $this->bean;
682 677
 		$this->view = 'list';
683 678
 	}
@@ -692,24 +687,24 @@  discard block
 block discarded – undo
692 687
 	/**
693 688
 	 * Action to handle when using a file as was done in previous versions of Sugar.
694 689
 	 */
695
-	protected function action_default(){
690
+	protected function action_default() {
696 691
 		$this->view = 'classic';
697 692
 	}
698 693
 
699 694
 	/**
700 695
 	 * this method id used within a Dashlet when performing an ajax call
701 696
 	 */
702
-	protected function action_callmethoddashlet(){
703
-		if(!empty($_REQUEST['id'])) {
697
+	protected function action_callmethoddashlet() {
698
+		if (!empty($_REQUEST['id'])) {
704 699
 		    $id = $_REQUEST['id'];
705 700
 		    $requestedMethod = $_REQUEST['method'];
706 701
 		    $dashletDefs = $GLOBALS['current_user']->getPreference('dashlets', 'Home'); // load user's dashlets config
707
-		    if(!empty($dashletDefs[$id])) {
702
+		    if (!empty($dashletDefs[$id])) {
708 703
 		        require_once($dashletDefs[$id]['fileLocation']);
709 704
 
710 705
 		        $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
711 706
 
712
-		        if(method_exists($dashlet, $requestedMethod) || method_exists($dashlet, '__call')) {
707
+		        if (method_exists($dashlet, $requestedMethod) || method_exists($dashlet, '__call')) {
713 708
 		            echo $dashlet->$requestedMethod();
714 709
 		        }
715 710
 		        else {
@@ -722,22 +717,22 @@  discard block
 block discarded – undo
722 717
 	/**
723 718
 	 * this method is used within a Dashlet when the options configuration is posted
724 719
 	 */
725
-	protected function action_configuredashlet(){
720
+	protected function action_configuredashlet() {
726 721
 		global $current_user, $mod_strings;
727 722
 
728
-		if(!empty($_REQUEST['id'])) {
723
+		if (!empty($_REQUEST['id'])) {
729 724
 		    $id = $_REQUEST['id'];
730 725
 		    $dashletDefs = $current_user->getPreference('dashlets', $_REQUEST['module']); // load user's dashlets config
731 726
 		    require_once($dashletDefs[$id]['fileLocation']);
732 727
 
733 728
 		    $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
734
-		    if(!empty($_REQUEST['configure']) && $_REQUEST['configure']) { // save settings
729
+		    if (!empty($_REQUEST['configure']) && $_REQUEST['configure']) { // save settings
735 730
 		        $dashletDefs[$id]['options'] = $dashlet->saveOptions($_REQUEST);
736 731
 		        $current_user->setPreference('dashlets', $dashletDefs, 0, $_REQUEST['module']);
737 732
 		    }
738 733
 		    else { // display options
739 734
 		        $json = getJSONobj();
740
-		        return 'result = ' . $json->encode((array('header' => $dashlet->title . ' : ' . $mod_strings['LBL_OPTIONS'],
735
+		        return 'result = '.$json->encode((array('header' => $dashlet->title.' : '.$mod_strings['LBL_OPTIONS'],
741 736
 		                                                 'body'  => $dashlet->displayOptions())));
742 737
 
743 738
 		    }
@@ -761,7 +756,7 @@  discard block
 block discarded – undo
761 756
         ob_clean();
762 757
         $retval = false;
763 758
 
764
-        if(method_exists($this->bean, 'deleteAttachment')) {
759
+        if (method_exists($this->bean, 'deleteAttachment')) {
765 760
             $duplicate = "false";
766 761
             if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == "true") {
767 762
                 $duplicate = "true";
@@ -779,7 +774,7 @@  discard block
 block discarded – undo
779 774
 	 * getActionFilename
780 775
 	 */
781 776
 	public static function getActionFilename($action) {
782
-	   if(isset(self::$action_case_file[$action])) {
777
+	   if (isset(self::$action_case_file[$action])) {
783 778
 	   	  return self::$action_case_file[$action];
784 779
 	   }
785 780
 	   return $action;
@@ -796,40 +791,40 @@  discard block
 block discarded – undo
796 791
 	 *
797 792
 	 * @return true if we want to stop processing, false if processing should continue
798 793
 	 */
799
-	private function blockFileAccess(){
794
+	private function blockFileAccess() {
800 795
 		//check if the we have enabled file_access_control and if so then check the mappings on the request;
801
-		if(!empty($GLOBALS['sugar_config']['admin_access_control']) && $GLOBALS['sugar_config']['admin_access_control']){
796
+		if (!empty($GLOBALS['sugar_config']['admin_access_control']) && $GLOBALS['sugar_config']['admin_access_control']) {
802 797
 			$this->loadMapping('file_access_control_map');
803 798
 			//since we have this turned on, check the mapping file
804 799
 			$module = strtolower($this->module);
805 800
 			$action = strtolower($this->do_action);
806
-			if(!empty($this->file_access_control_map['modules'][$module]['links'])){
801
+			if (!empty($this->file_access_control_map['modules'][$module]['links'])) {
807 802
 				$GLOBALS['admin_access_control_links'] = $this->file_access_control_map['modules'][$module]['links'];
808 803
 			}
809 804
 
810
-			if(!empty($this->file_access_control_map['modules'][$module]['actions']) && (in_array($action, $this->file_access_control_map['modules'][$module]['actions']) || !empty($this->file_access_control_map['modules'][$module]['actions'][$action]))){
805
+			if (!empty($this->file_access_control_map['modules'][$module]['actions']) && (in_array($action, $this->file_access_control_map['modules'][$module]['actions']) || !empty($this->file_access_control_map['modules'][$module]['actions'][$action]))) {
811 806
 				//check params
812
-				if(!empty($this->file_access_control_map['modules'][$module]['actions'][$action]['params'])){
807
+				if (!empty($this->file_access_control_map['modules'][$module]['actions'][$action]['params'])) {
813 808
 					$block = true;
814 809
 					$params = $this->file_access_control_map['modules'][$module]['actions'][$action]['params'];
815
-					foreach($params as $param => $paramVals){
816
-						if(!empty($_REQUEST[$param])){
817
-							if(!in_array($_REQUEST[$param], $paramVals)){
810
+					foreach ($params as $param => $paramVals) {
811
+						if (!empty($_REQUEST[$param])) {
812
+							if (!in_array($_REQUEST[$param], $paramVals)) {
818 813
 								$block = false;
819 814
 								break;
820 815
 							}
821 816
 						}
822 817
 					}
823
-					if($block){
818
+					if ($block) {
824 819
 						$this->_processed = true;
825 820
 						$this->no_access();
826 821
 					}
827
-				}else{
822
+				} else {
828 823
 					$this->_processed = true;
829 824
 					$this->no_access();
830 825
 				}
831 826
 			}
832
-		}else
827
+		} else
833 828
 			$this->_processed = false;
834 829
 	}
835 830
 
@@ -841,12 +836,12 @@  discard block
 block discarded – undo
841 836
 	 * the download entry point is mapped in the following file: entry_point_registry.php
842 837
 	 *
843 838
 	 */
844
-	private function handleEntryPoint(){
845
-		if(!empty($_REQUEST['entryPoint'])){
839
+	private function handleEntryPoint() {
840
+		if (!empty($_REQUEST['entryPoint'])) {
846 841
 			$this->loadMapping('entry_point_registry');
847 842
 			$entryPoint = $_REQUEST['entryPoint'];
848 843
 
849
-			if(!empty($this->entry_point_registry[$entryPoint])){
844
+			if (!empty($this->entry_point_registry[$entryPoint])) {
850 845
 				require_once($this->entry_point_registry[$entryPoint]['file']);
851 846
 				$this->_processed = true;
852 847
 				$this->view = '';
@@ -864,8 +859,8 @@  discard block
 block discarded – undo
864 859
     {
865 860
         $this->loadMapping('entry_point_registry');
866 861
 
867
-        if ( isset($this->entry_point_registry[$entryPoint]['auth'])
868
-                && !$this->entry_point_registry[$entryPoint]['auth'] )
862
+        if (isset($this->entry_point_registry[$entryPoint]['auth'])
863
+                && !$this->entry_point_registry[$entryPoint]['auth'])
869 864
             return false;
870 865
         return true;
871 866
     }
@@ -877,26 +872,26 @@  discard block
 block discarded – undo
877 872
 	protected function callLegacyCode()
878 873
 	{
879 874
 		$file = self::getActionFilename($this->do_action);
880
-		if ( isset($this->action_view_map[strtolower($this->do_action)]) ) {
875
+		if (isset($this->action_view_map[strtolower($this->do_action)])) {
881 876
 	        $action = $this->action_view_map[strtolower($this->do_action)];
882 877
 	    }
883 878
 	    else {
884 879
 	        $action = $this->do_action;
885 880
 	    }
886 881
 	    // index actions actually maps to the view.list.php view
887
-	    if ( $action == 'index' ) {
882
+	    if ($action == 'index') {
888 883
 	        $action = 'list';
889 884
 	    }
890 885
 
891
-		if ((file_exists('modules/' . $this->module . '/'. $file . '.php')
892
-                && !file_exists('modules/' . $this->module . '/views/view.'. $action . '.php'))
893
-            || (file_exists('custom/modules/' . $this->module . '/'. $file . '.php')
894
-                && !file_exists('custom/modules/' . $this->module . '/views/view.'. $action . '.php'))
886
+		if ((file_exists('modules/'.$this->module.'/'.$file.'.php')
887
+                && !file_exists('modules/'.$this->module.'/views/view.'.$action.'.php'))
888
+            || (file_exists('custom/modules/'.$this->module.'/'.$file.'.php')
889
+                && !file_exists('custom/modules/'.$this->module.'/views/view.'.$action.'.php'))
895 890
             ) {
896 891
 			// A 'classic' module, using the old pre-MVC display files
897 892
 			// We should now discard the bean we just obtained for tracking as the pre-MVC module will instantiate its own
898 893
 			unset($GLOBALS['FOCUS']);
899
-			$GLOBALS['log']->debug('Module:' . $this->module . ' using file: '. $file);
894
+			$GLOBALS['log']->debug('Module:'.$this->module.' using file: '.$file);
900 895
 			$this->action_default();
901 896
 			$this->_processed = true;
902 897
 		}
@@ -907,17 +902,17 @@  discard block
 block discarded – undo
907 902
 	 * action_file_map.php or action_view_map.php load those maps here.
908 903
 	 *
909 904
 	 */
910
-	private function handleActionMaps(){
911
-		if(!empty($this->action_file_map[strtolower($this->do_action)])){
905
+	private function handleActionMaps() {
906
+		if (!empty($this->action_file_map[strtolower($this->do_action)])) {
912 907
 			$this->view = '';
913
-			$GLOBALS['log']->debug('Using Action File Map:' . $this->action_file_map[strtolower($this->do_action)]);
908
+			$GLOBALS['log']->debug('Using Action File Map:'.$this->action_file_map[strtolower($this->do_action)]);
914 909
 			require_once($this->action_file_map[strtolower($this->do_action)]);
915 910
 			$this->_processed = true;
916
-		}elseif(!empty($this->action_view_map[strtolower($this->do_action)])){
917
-			$GLOBALS['log']->debug('Using Action View Map:' . $this->action_view_map[strtolower($this->do_action)]);
911
+		}elseif (!empty($this->action_view_map[strtolower($this->do_action)])) {
912
+			$GLOBALS['log']->debug('Using Action View Map:'.$this->action_view_map[strtolower($this->do_action)]);
918 913
 			$this->view = $this->action_view_map[strtolower($this->do_action)];
919 914
 			$this->_processed = true;
920
-		}else
915
+		} else
921 916
 			$this->no_action();
922 917
 	}
923 918
 
@@ -925,8 +920,8 @@  discard block
 block discarded – undo
925 920
 	 * Actually remap the action if required.
926 921
 	 *
927 922
 	 */
928
-	protected function remapAction(){
929
-		if(!empty($this->action_remap[$this->do_action])){
923
+	protected function remapAction() {
924
+		if (!empty($this->action_remap[$this->do_action])) {
930 925
 			$this->action = $this->action_remap[$this->do_action];
931 926
 			$this->do_action = $this->action;
932 927
 		}
Please login to merge, or discard this patch.
include/MVC/Controller/entry_point_registry.php 1 patch
Spacing   +11 added lines, -11 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.
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
     'jslang'=> array('file' => 'include/language/getJSLanguage.php', 'auth' => true),
71 71
 	'deleteAttachment' => array('file' => 'modules/FP_events/responseEntryPoint.php', 'auth' => false),
72 72
 	'responseEntryPoint' => array('file' => 'modules/FP_events/responseEntryPoint.php', 'auth' => false),
73
-	'formLetter' => array('file' => 'modules/AOS_PDF_Templates/formLetterPdf.php' , 'auth' => true),
74
-	'generatePdf' => array('file' => 'modules/AOS_PDF_Templates/generatePdf.php' , 'auth' => true),
75
-	'Reschedule' => array('file' => 'modules/Calls_Reschedule/Reschedule_popup.php' , 'auth' => true),
76
-	'Reschedule2' => array('file' => 'modules/Calls/Reschedule.php' , 'auth' => true),
77
-	'social' => array('file' => 'include/social/get_data.php' , 'auth' => true),
78
-	'social_reader' => array('file' => 'include/social/get_feed_data.php' , 'auth' => true),
79
-	'add_dash_page' => array('file' => 'modules/Home/AddDashboardPages.php' , 'auth' => true),
80
-	'retrieve_dash_page' => array('file' => 'include/MySugar/retrieve_dash_page.php' , 'auth' => true),
81
-	'remove_dash_page' => array('file' => 'modules/Home/RemoveDashboardPages.php' , 'auth' => true),
82
-	'rename_dash_page' => array('file' => 'modules/Home/RenameDashboardPages.php' , 'auth' => true)
73
+	'formLetter' => array('file' => 'modules/AOS_PDF_Templates/formLetterPdf.php', 'auth' => true),
74
+	'generatePdf' => array('file' => 'modules/AOS_PDF_Templates/generatePdf.php', 'auth' => true),
75
+	'Reschedule' => array('file' => 'modules/Calls_Reschedule/Reschedule_popup.php', 'auth' => true),
76
+	'Reschedule2' => array('file' => 'modules/Calls/Reschedule.php', 'auth' => true),
77
+	'social' => array('file' => 'include/social/get_data.php', 'auth' => true),
78
+	'social_reader' => array('file' => 'include/social/get_feed_data.php', 'auth' => true),
79
+	'add_dash_page' => array('file' => 'modules/Home/AddDashboardPages.php', 'auth' => true),
80
+	'retrieve_dash_page' => array('file' => 'include/MySugar/retrieve_dash_page.php', 'auth' => true),
81
+	'remove_dash_page' => array('file' => 'modules/Home/RemoveDashboardPages.php', 'auth' => true),
82
+	'rename_dash_page' => array('file' => 'modules/Home/RenameDashboardPages.php', 'auth' => true)
83 83
 );
84 84
 
85 85
 ?>
Please login to merge, or discard this patch.