Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created
include/language/jsLanguage.php 2 patches
Spacing   +8 added lines, -8 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.
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
     /**
51 51
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
52 52
      */
53
-    function jsLanguage(){
53
+    function jsLanguage() {
54 54
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
55
-        if(isset($GLOBALS['log'])) {
55
+        if (isset($GLOBALS['log'])) {
56 56
             $GLOBALS['log']->deprecated($deprecatedMessage);
57 57
         }
58 58
         else {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 EOQ;
78 78
 
79 79
         $cacheDir = create_cache_directory('jsLanguage/');
80
-        if($fh = @sugar_fopen($cacheDir . $lang . '.js', "w")){
80
+        if ($fh = @sugar_fopen($cacheDir.$lang.'.js', "w")) {
81 81
             fputs($fh, $str);
82 82
             fclose($fh);
83 83
         }
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
         // cn: bug 8242 - non-US langpack chokes
90 90
         $mod_strings = return_module_language($lang, $moduleDir);
91 91
         $mod_strings_encoded = $json->encode($mod_strings);
92
-        $str = "SUGAR.language.setLanguage('" . $moduleDir . "', " . $mod_strings_encoded . ");";
92
+        $str = "SUGAR.language.setLanguage('".$moduleDir."', ".$mod_strings_encoded.");";
93 93
 
94
-        $cacheDir = create_cache_directory('jsLanguage/' . $moduleDir . '/');
94
+        $cacheDir = create_cache_directory('jsLanguage/'.$moduleDir.'/');
95 95
 
96
-        if($fh = @fopen($cacheDir . $lang . '.js', "w")){
96
+        if ($fh = @fopen($cacheDir.$lang.'.js', "w")) {
97 97
             fputs($fh, $str);
98 98
             fclose($fh);
99 99
         }
100 100
 
101
-        if($return) {
101
+        if ($return) {
102 102
             return $str;
103 103
         }
104 104
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.
include/SugarEmailAddress/SugarEmailAddress.php 2 patches
Spacing   +171 added lines, -171 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.
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
     /**
82 82
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
83 83
      */
84
-    public function SugarEmailAddress(){
84
+    public function SugarEmailAddress() {
85 85
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
86
-        if(isset($GLOBALS['log'])) {
86
+        if (isset($GLOBALS['log'])) {
87 87
             $GLOBALS['log']->deprecated($deprecatedMessage);
88 88
         }
89 89
         else {
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
      * @param string $module
100 100
      */
101 101
     function handleLegacySave($bean, $prefix = "") {
102
-        if(!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) {
102
+        if (!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) {
103 103
             if (empty($this->addresses) || !isset($_REQUEST['massupdate'])) {
104 104
                 $this->addresses = array();
105 105
                 $optOut = (isset($bean->email_opt_out) && $bean->email_opt_out == "1") ? true : false;
106 106
                 $invalid = (isset($bean->invalid_email) && $bean->invalid_email == "1") ? true : false;
107 107
 
108 108
                 $isPrimary = true;
109
-                for($i = 1; $i <= 10; $i++){
109
+                for ($i = 1; $i <= 10; $i++) {
110 110
                     $email = 'email'.$i;
111
-                    if(isset($bean->$email) && !empty($bean->$email)){
111
+                    if (isset($bean->$email) && !empty($bean->$email)) {
112 112
                         $opt_out_field = $email.'_opt_out';
113 113
                         $invalid_field = $email.'_invalid';
114 114
                         $field_optOut = (isset($bean->$opt_out_field)) ? $bean->$opt_out_field : $optOut;
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
                 }
120 120
             }
121 121
         }
122
-        $this->populateAddresses($bean->id, $bean->module_dir, array(),'');
123
-        if(isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) {
122
+        $this->populateAddresses($bean->id, $bean->module_dir, array(), '');
123
+        if (isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) {
124 124
             $this->populateLegacyFields($bean);
125 125
         }
126 126
     }
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
         return;
143 143
     }
144 144
 
145
-    function populateLegacyFields(&$bean){
145
+    function populateLegacyFields(&$bean) {
146 146
         $primary_found = false;
147 147
         $alternate_found = false;
148 148
         $alternate2_found = false;
149
-        foreach($this->addresses as $k=>$address) {
149
+        foreach ($this->addresses as $k=>$address) {
150 150
             if ($primary_found && $alternate_found)
151 151
                 break;
152 152
             if ($address['primary_address'] == 1 && !$primary_found) {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             } elseif (!$alternate_found) {
156 156
                 $alternate_index = $k;
157 157
                 $alternate_found = true;
158
-            } elseif (!$alternate2_found){
158
+            } elseif (!$alternate2_found) {
159 159
                 $alternate2_index = $k;
160 160
                 $alternate2_found = true;
161 161
             }
@@ -192,27 +192,27 @@  discard block
 block discarded – undo
192 192
         $args = func_get_args();
193 193
         return call_user_func_array(array($this, '_save'), $args);
194 194
     }
195
-    private function _save($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='', $in_workflow=false) {
196
-        if(empty($this->addresses) || $in_workflow){
197
-            $this->populateAddresses($id, $module, $new_addrs,$primary);
195
+    private function _save($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '', $in_workflow = false) {
196
+        if (empty($this->addresses) || $in_workflow) {
197
+            $this->populateAddresses($id, $module, $new_addrs, $primary);
198 198
         }
199 199
 
200 200
         //find all email addresses..
201
-        $current_links=array();
201
+        $current_links = array();
202 202
         // Need to correct this to handle the Employee/User split
203 203
         $module = $this->getCorrectedModule($module);
204
-        $q2="select *  from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0";
204
+        $q2 = "select *  from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0";
205 205
         $r2 = $this->db->query($q2);
206
-        while(($row2=$this->db->fetchByAssoc($r2)) != null ) {
207
-            $current_links[$row2['email_address_id']]=$row2;
206
+        while (($row2 = $this->db->fetchByAssoc($r2)) != null) {
207
+            $current_links[$row2['email_address_id']] = $row2;
208 208
         }
209 209
 
210 210
         $isConversion = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? true : false;
211 211
 
212 212
         if (!empty($this->addresses)) {
213 213
             // insert new relationships and create email address record, if they don't exist
214
-            foreach($this->addresses as $address) {
215
-                if(!empty($address['email_address'])) {
214
+            foreach ($this->addresses as $address) {
215
+                if (!empty($address['email_address'])) {
216 216
                     $guid = create_guid();
217 217
                     $emailId = isset($address['email_address_id'])
218 218
                         && isset($current_links[$address['email_address_id']])
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
                     $emailId = $this->AddUpdateEmailAddress($address['email_address'],
221 221
                                                             $address['invalid_email'],
222 222
                                                             $address['opt_out'],
223
-                                                            $emailId);// this will save the email address if not found
223
+                                                            $emailId); // this will save the email address if not found
224 224
 
225 225
                     //verify linkage and flags.
226
-                    $upd_eabr="";
226
+                    $upd_eabr = "";
227 227
                     if (isset($current_links[$emailId])) {
228 228
                         if (!$isConversion) { // do not update anything if this is for lead conversion
229
-                        if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address'] ) {
230
-                            $upd_eabr="UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'";
229
+                        if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address']) {
230
+                            $upd_eabr = "UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'";
231 231
                         }
232 232
 
233 233
                         unset($current_links[$emailId]);
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
         // for lead conversion, do not delete email addresses
259 259
         if (!empty($current_links) && !$isConversion) {
260 260
 
261
-            $delete="";
261
+            $delete = "";
262 262
             foreach ($current_links as $eabr) {
263 263
 
264
-                $delete.=empty($delete) ? "'".$this->db->quote($eabr['id']) . "' " : ",'" . $this->db->quote($eabr['id']) . "'";
264
+                $delete .= empty($delete) ? "'".$this->db->quote($eabr['id'])."' " : ",'".$this->db->quote($eabr['id'])."'";
265 265
             }
266 266
 
267
-            $eabr_unlink="update email_addr_bean_rel set deleted=1 where id in ({$delete})";
267
+            $eabr_unlink = "update email_addr_bean_rel set deleted=1 where id in ({$delete})";
268 268
             $this->db->query($eabr_unlink);
269 269
         }
270 270
         $this->stateBeforeWorkflow = null;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         )
287 287
     {
288 288
         $emailCaps = strtoupper(trim($email));
289
-        if(empty($emailCaps))
289
+        if (empty($emailCaps))
290 290
             return 0;
291 291
 
292 292
         $q = "SELECT *
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
         $r = $this->db->query($q, true);
325 325
 
326 326
         $retArr = array();
327
-        while($a = $this->db->fetchByAssoc($r)) {
327
+        while ($a = $this->db->fetchByAssoc($r)) {
328 328
             $retArr[] = $a['bean_id'];
329 329
         }
330
-        if(count($retArr) > 0) {
330
+        if (count($retArr) > 0) {
331 331
             return $retArr;
332 332
         } else {
333 333
             return false;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
         $email = trim($email);
349 349
 
350
-        if(empty($email)) {
350
+        if (empty($email)) {
351 351
             return array();
352 352
         }
353 353
 
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
                 WHERE ea.email_address_caps = $emailCaps and eabl.deleted=0 ";
357 357
         $r = $this->db->query($q);
358 358
 
359
-        while($a = $this->db->fetchByAssoc($r)) {
360
-            if(isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) {
359
+        while ($a = $this->db->fetchByAssoc($r)) {
360
+            if (isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) {
361 361
                 $className = $beanList[$a['bean_module']];
362 362
 
363
-                if(isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
364
-                    if(!class_exists($className)) {
363
+                if (isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
364
+                    if (!class_exists($className)) {
365 365
                         require_once($beanFiles[$className]);
366 366
                     }
367 367
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
      * @param string $replyTo GUID of reply-to address
390 390
      * @param string $invalid GUID of invalid address
391 391
      */
392
-    function populateAddresses($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='') {
392
+    function populateAddresses($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '') {
393 393
         $module = $this->getCorrectedModule($module);
394 394
         //One last check for the ConvertLead action in which case we need to change $module to 'Leads'
395 395
         $module = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? 'Leads' : $module;
@@ -400,54 +400,54 @@  discard block
 block discarded – undo
400 400
         $hasEmailValue = false;
401 401
         $email_ids = array();
402 402
 
403
-        if (isset($_REQUEST) && isset($_REQUEST[$module .'_email_widget_id'])) {
403
+        if (isset($_REQUEST) && isset($_REQUEST[$module.'_email_widget_id'])) {
404 404
 
405 405
             $fromRequest = false;
406 406
             // determine which array to process
407
-            foreach($_REQUEST as $k => $v) {
408
-                if(strpos($k, 'emailAddress') !== false) {
407
+            foreach ($_REQUEST as $k => $v) {
408
+                if (strpos($k, 'emailAddress') !== false) {
409 409
                    $fromRequest = true;
410 410
                    break;
411 411
                 }
412
-            $widget_id = $_REQUEST[$module .'_email_widget_id'];
412
+            $widget_id = $_REQUEST[$module.'_email_widget_id'];
413 413
     }
414 414
 
415 415
             //Iterate over the widgets for this module, in case there are multiple email widgets for this module
416
-            while(isset($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount]))
416
+            while (isset($_REQUEST[$module.$widget_id."emailAddress".$widgetCount]))
417 417
             {
418
-                if (empty($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount])) {
418
+                if (empty($_REQUEST[$module.$widget_id."emailAddress".$widgetCount])) {
419 419
                     $widgetCount++;
420 420
                     continue;
421 421
                 }
422 422
 
423 423
                 $hasEmailValue = true;
424 424
 
425
-                $eId = $module . $widget_id;
426
-                if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) {
427
-                   $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag'];
428
-                } else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) {
429
-                   $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag'];
425
+                $eId = $module.$widget_id;
426
+                if (isset($_REQUEST[$eId.'emailAddressPrimaryFlag'])) {
427
+                   $primaryValue = $_REQUEST[$eId.'emailAddressPrimaryFlag'];
428
+                } else if (isset($_REQUEST[$module.'emailAddressPrimaryFlag'])) {
429
+                   $primaryValue = $_REQUEST[$module.'emailAddressPrimaryFlag'];
430 430
                 }
431 431
 
432 432
                 $optOutValues = array();
433
-                if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) {
434
-                   $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag'];
435
-                } else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) {
436
-                   $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag'];
433
+                if (isset($_REQUEST[$eId.'emailAddressOptOutFlag'])) {
434
+                   $optOutValues = $_REQUEST[$eId.'emailAddressOptOutFlag'];
435
+                } else if (isset($_REQUEST[$module.'emailAddressOptOutFlag'])) {
436
+                   $optOutValues = $_REQUEST[$module.'emailAddressOptOutFlag'];
437 437
                 }
438 438
 
439 439
                 $invalidValues = array();
440
-                if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) {
441
-                   $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag'];
442
-                } else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) {
443
-                   $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag'];
440
+                if (isset($_REQUEST[$eId.'emailAddressInvalidFlag'])) {
441
+                   $invalidValues = $_REQUEST[$eId.'emailAddressInvalidFlag'];
442
+                } else if (isset($_REQUEST[$module.'emailAddressInvalidFlag'])) {
443
+                   $invalidValues = $_REQUEST[$module.'emailAddressInvalidFlag'];
444 444
                 }
445 445
 
446 446
                 $deleteValues = array();
447
-                if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) {
448
-                   $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag'];
449
-                } else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) {
450
-                   $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag'];
447
+                if (isset($_REQUEST[$eId.'emailAddressDeleteFlag'])) {
448
+                   $deleteValues = $_REQUEST[$eId.'emailAddressDeleteFlag'];
449
+                } else if (isset($_REQUEST[$module.'emailAddressDeleteFlag'])) {
450
+                   $deleteValues = $_REQUEST[$module.'emailAddressDeleteFlag'];
451 451
                 }
452 452
 
453 453
                 // prep from form save
@@ -455,36 +455,36 @@  discard block
 block discarded – undo
455 455
                 $replyToField = '';
456 456
                 $invalidField = '';
457 457
                 $optOutField = '';
458
-                if($fromRequest && empty($primary) && isset($primaryValue)) {
458
+                if ($fromRequest && empty($primary) && isset($primaryValue)) {
459 459
                     $primaryField = $primaryValue;
460 460
                 }
461 461
 
462
-                if($fromRequest && empty($replyTo)) {
463
-                    if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) {
464
-                       $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag'];
465
-                    } else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) {
466
-                       $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag'];
462
+                if ($fromRequest && empty($replyTo)) {
463
+                    if (isset($_REQUEST[$eId.'emailAddressReplyToFlag'])) {
464
+                       $replyToField = $_REQUEST[$eId.'emailAddressReplyToFlag'];
465
+                    } else if (isset($_REQUEST[$module.'emailAddressReplyToFlag'])) {
466
+                       $replyToField = $_REQUEST[$module.'emailAddressReplyToFlag'];
467 467
                     }
468 468
                 }
469
-                if($fromRequest && empty($new_addrs)) {
470
-                    foreach($_REQUEST as $k => $v) {
471
-                        if(preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) {
469
+                if ($fromRequest && empty($new_addrs)) {
470
+                    foreach ($_REQUEST as $k => $v) {
471
+                        if (preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) {
472 472
                             $new_addrs[$k] = $v;
473 473
                         }
474 474
                     }
475 475
                 }
476
-                if($fromRequest && empty($email_ids)) {
477
-                    foreach($_REQUEST as $k => $v) {
478
-                        if(preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) {
476
+                if ($fromRequest && empty($email_ids)) {
477
+                    foreach ($_REQUEST as $k => $v) {
478
+                        if (preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) {
479 479
                             $key = str_replace('emailAddressId', 'emailAddress', $k);
480 480
                             $email_ids[$key] = $v;
481 481
                         }
482 482
                     }
483 483
                 }
484 484
 
485
-                if($fromRequest && empty($new_addrs)) {
486
-                    foreach($_REQUEST as $k => $v) {
487
-                        if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
485
+                if ($fromRequest && empty($new_addrs)) {
486
+                    foreach ($_REQUEST as $k => $v) {
487
+                        if (preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
488 488
                             $validateFlag = str_replace("Value", "Flag", $k);
489 489
                             if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true")
490 490
                               $new_addrs[$k] = $v;
@@ -493,21 +493,21 @@  discard block
 block discarded – undo
493 493
                 }
494 494
 
495 495
                 //empty the addresses array if the post happened from email address widget.
496
-                if($post_from_email_address_widget) {
497
-                    $this->addresses=array();  //this gets populated during retrieve of the contact bean.
496
+                if ($post_from_email_address_widget) {
497
+                    $this->addresses = array(); //this gets populated during retrieve of the contact bean.
498 498
                 } else {
499 499
                     $optOutValues = array();
500 500
                     $invalidValues = array();
501
-                    foreach($new_addrs as $k=>$email) {
501
+                    foreach ($new_addrs as $k=>$email) {
502 502
                        preg_match('/emailAddress([0-9])+$/', $k, $matches);
503 503
                        $count = $matches[1];
504
-                       $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'");
505
-                       if(!empty($result)) {
506
-                          $row=$this->db->fetchByAssoc($result);
507
-                          if(!empty($row['opt_out'])) {
504
+                       $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '".$this->db->quote(strtoupper($email))."'");
505
+                       if (!empty($result)) {
506
+                          $row = $this->db->fetchByAssoc($result);
507
+                          if (!empty($row['opt_out'])) {
508 508
                              $optOutValues[$k] = "emailAddress$count";
509 509
                           }
510
-                          if(!empty($row['invalid_email'])) {
510
+                          if (!empty($row['invalid_email'])) {
511 511
                              $invalidValues[$k] = "emailAddress$count";
512 512
                           }
513 513
                        }
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
                 }
516 516
                 // Re-populate the addresses class variable if we have new address(es).
517 517
                 if (!empty($new_addrs)) {
518
-                    foreach($new_addrs as $k => $reqVar) {
518
+                    foreach ($new_addrs as $k => $reqVar) {
519 519
                         //$key = preg_match("/^$eId/s", $k) ? substr($k, strlen($eId)) : $k;
520 520
                         $reqVar = trim($reqVar);
521
-                        if(strpos($k, 'emailAddress') !== false) {
522
-                            if(!empty($reqVar) && !in_array($k, $deleteValues)) {
521
+                        if (strpos($k, 'emailAddress') !== false) {
522
+                            if (!empty($reqVar) && !in_array($k, $deleteValues)) {
523 523
                                 $email_id   = (array_key_exists($k, $email_ids)) ? $email_ids[$k] : null;
524 524
                                 $primary    = ($k == $primaryValue) ? true : false;
525 525
                                 $replyTo    = ($k == $replyToField) ? true : false;
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         }
537 537
 
538 538
         //If no widgets, set addresses array to empty
539
-        if($post_from_email_address_widget && !$hasEmailValue) {
539
+        if ($post_from_email_address_widget && !$hasEmailValue) {
540 540
            $this->addresses = array();
541 541
         }
542 542
     }
@@ -547,9 +547,9 @@  discard block
 block discarded – undo
547 547
      * @param bool $primary Default false
548 548
      * @param bool $replyTo Default false
549 549
      */
550
-    function addAddress($addr, $primary=false, $replyTo=false, $invalid=false, $optOut=false, $email_id = null) {
550
+    function addAddress($addr, $primary = false, $replyTo = false, $invalid = false, $optOut = false, $email_id = null) {
551 551
         $addr = html_entity_decode($addr, ENT_QUOTES);
552
-        if(preg_match($this->regex, $addr)) {
552
+        if (preg_match($this->regex, $addr)) {
553 553
             $primaryFlag = ($primary) ? '1' : '0';
554 554
             $replyToFlag = ($replyTo) ? '1' : '0';
555 555
             $invalidFlag = ($invalid) ? '1' : '0';
@@ -585,17 +585,17 @@  discard block
 block discarded – undo
585 585
      * Updates invalid_email and opt_out flags for each address
586 586
      */
587 587
     function updateFlags() {
588
-        if(!empty($this->addresses)) {
589
-            foreach($this->addresses as $addressMeta) {
590
-                if(isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) {
588
+        if (!empty($this->addresses)) {
589
+            foreach ($this->addresses as $addressMeta) {
590
+                if (isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) {
591 591
                     $address = $this->db->quote($this->_cleanAddress($addressMeta['email_address']));
592 592
 
593 593
                     $q = "SELECT * FROM email_addresses WHERE email_address = '{$address}'";
594 594
                     $r = $this->db->query($q);
595 595
                     $a = $this->db->fetchByAssoc($r);
596 596
 
597
-                    if(!empty($a)) {
598
-                        if(isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) {
597
+                    if (!empty($a)) {
598
+                        if (isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) {
599 599
                             $qUpdate = "UPDATE email_addresses SET invalid_email = ".intval($addressMeta['invalid_email']).", opt_out = ".intval($addressMeta['opt_out']).", date_modified = '".TimeDate::getInstance()->nowDb()."' WHERE id = '".$this->db->quote($a['id'])."'";
600 600
                             $rUpdate = $this->db->query($qUpdate);
601 601
                         }
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
     public function splitEmailAddress($addr)
609 609
     {
610 610
         $email = $this->_cleanAddress($addr);
611
-        if(!preg_match($this->regex, $email)) {
611
+        if (!preg_match($this->regex, $email)) {
612 612
             $email = ''; // remove bad email addr
613 613
         }
614 614
         $name = trim(str_replace(array($email, '<', '>', '"', "'"), '', $addr));
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
     function _cleanAddress($addr) {
625 625
         $addr = trim(from_html($addr));
626 626
 
627
-        if(strpos($addr, "<") !== false && strpos($addr, ">") !== false) {
628
-            $address = trim(substr($addr, strrpos($addr, "<") +1, strrpos($addr, ">") - strrpos($addr, "<") -1));
627
+        if (strpos($addr, "<") !== false && strpos($addr, ">") !== false) {
628
+            $address = trim(substr($addr, strrpos($addr, "<") + 1, strrpos($addr, ">") - strrpos($addr, "<") - 1));
629 629
         } else {
630 630
             $address = trim($addr);
631 631
         }
@@ -646,11 +646,11 @@  discard block
 block discarded – undo
646 646
         $r = $this->db->query($q);
647 647
         $a = $this->db->fetchByAssoc($r);
648 648
 
649
-        if(!empty($a) && !empty($a['id'])) {
649
+        if (!empty($a) && !empty($a['id'])) {
650 650
             return $a['id'];
651 651
         } else {
652 652
             $guid = '';
653
-            if(!empty($address)){
653
+            if (!empty($address)) {
654 654
                 $guid = create_guid();
655 655
                 $now = TimeDate::getInstance()->nowDb();
656 656
                 $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted)
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
      *        to propagate to the new SugarEmailAddress - see bug 39188
673 673
      * @return String GUID of Email Address or '' if cleaned address was empty.
674 674
      */
675
-    public function AddUpdateEmailAddress($addr,$invalid=0,$opt_out=0,$id=null)
675
+    public function AddUpdateEmailAddress($addr, $invalid = 0, $opt_out = 0, $id = null)
676 676
     {
677 677
         // sanity checks to avoid SQL injection.
678 678
         $invalid = intval($invalid);
@@ -722,12 +722,12 @@  discard block
 block discarded – undo
722 722
             if ($duplicate_email['invalid_email'] != $new_invalid ||
723 723
                 $duplicate_email['opt_out'] != $new_opt_out ||
724 724
                 (trim($duplicate_email['email_address']) != $address)) {
725
-                $upd_q = 'UPDATE ' . $this->table_name . ' ' .
726
-                    'SET email_address=\'' . $address . '\', ' .
727
-                    'invalid_email=' . $new_invalid . ', ' .
728
-                    'opt_out=' . $new_opt_out . ', ' .
729
-                    'date_modified=' . $this->db->now() . ' ' .
730
-                    'WHERE id=\'' . $this->db->quote($duplicate_email['id']) . '\'';
725
+                $upd_q = 'UPDATE '.$this->table_name.' '.
726
+                    'SET email_address=\''.$address.'\', '.
727
+                    'invalid_email='.$new_invalid.', '.
728
+                    'opt_out='.$new_opt_out.', '.
729
+                    'date_modified='.$this->db->now().' '.
730
+                    'WHERE id=\''.$this->db->quote($duplicate_email['id']).'\'';
731 731
                 $upd_r = $this->db->query($upd_q);
732 732
             }
733 733
             return $duplicate_email['id'];
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
         else {
736 736
             // no case-insensitive address match - it's new, or undeleted.
737 737
             $guid = '';
738
-            if(!empty($address)){
738
+            if (!empty($address)) {
739 739
                 $guid = create_guid();
740 740
                 $now = TimeDate::getInstance()->nowDb();
741 741
                 $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted, invalid_email, opt_out)
@@ -751,12 +751,12 @@  discard block
 block discarded – undo
751 751
      * @param object $focus Object in focus
752 752
      * @return string email
753 753
      */
754
-    function getPrimaryAddress($focus,$parent_id=null,$parent_type=null) {
754
+    function getPrimaryAddress($focus, $parent_id = null, $parent_type = null) {
755 755
 
756
-        $parent_type=empty($parent_type) ? $focus->module_dir : $parent_type;
756
+        $parent_type = empty($parent_type) ? $focus->module_dir : $parent_type;
757 757
         // Bug63174: Email address is not shown in the list view for employees
758 758
         $parent_type = $this->getCorrectedModule($parent_type);
759
-        $parent_id=empty($parent_id) ? $focus->id : $parent_id;
759
+        $parent_id = empty($parent_id) ? $focus->id : $parent_id;
760 760
 
761 761
         $q = "SELECT ea.email_address FROM email_addresses ea
762 762
                 LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
         $r = $this->db->limitQuery($q, 0, 1);
769 769
         $a = $this->db->fetchByAssoc($r);
770 770
 
771
-        if(isset($a['email_address'])) {
771
+        if (isset($a['email_address'])) {
772 772
             return $a['email_address'];
773 773
         }
774 774
         return '';
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
         $r = $this->db->query($q);
810 810
         $a = $this->db->fetchByAssoc($r);
811 811
 
812
-        if(isset($a['email_address'])) {
812
+        if (isset($a['email_address'])) {
813 813
             return $a['email_address'];
814 814
         }
815 815
         return '';
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
                 ORDER BY ear.reply_to_address, ear.primary_address DESC";
835 835
         $r = $this->db->query($q);
836 836
 
837
-        while($a = $this->db->fetchByAssoc($r, FALSE)) {
837
+        while ($a = $this->db->fetchByAssoc($r, FALSE)) {
838 838
             $return[] = $a;
839 839
         }
840 840
 
@@ -848,9 +848,9 @@  discard block
 block discarded – undo
848 848
      * @param bool asMetadata Default false
849 849
      * @return string HTML/JS for widget
850 850
      */
851
-    function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='',$tabindex='0')
851
+    function getEmailAddressWidgetEditView($id, $module, $asMetadata = false, $tpl = '', $tabindex = '0')
852 852
     {
853
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
853
+        if (!($this->smarty instanceOf Sugar_Smarty))
854 854
             $this->smarty = new Sugar_Smarty();
855 855
 
856 856
         global $app_strings, $dictionary, $beanList;
@@ -861,33 +861,33 @@  discard block
 block discarded – undo
861 861
         $passedModule = $module;
862 862
         $module = $this->getCorrectedModule($module);
863 863
         $saveModule = $module;
864
-        if(isset($_POST['is_converted']) && $_POST['is_converted']==true){
865
-            $id=$_POST['return_id'];
866
-            $module=$_POST['return_module'];
864
+        if (isset($_POST['is_converted']) && $_POST['is_converted'] == true) {
865
+            $id = $_POST['return_id'];
866
+            $module = $_POST['return_module'];
867 867
         }
868 868
         $prefillDataArr = array();
869
-        if(!empty($id)) {
869
+        if (!empty($id)) {
870 870
             $prefillDataArr = $this->getAddressesByGUID($id, $module);
871 871
             //When coming from convert leads, sometimes module is Contacts while the id is for a lead.
872 872
             if (empty($prefillDataArr) && $module == "Contacts")
873 873
                 $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
874
-        } else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){
875
-            $widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0';
874
+        } else if (isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])) {
875
+            $widget_id = isset($_REQUEST[$module.'_email_widget_id']) ? $_REQUEST[$module.'_email_widget_id'] : '0';
876 876
             $count = 0;
877
-            $key = $module . $widget_id . 'emailAddress'.$count;
878
-            while(isset($_REQUEST[$key])) {
877
+            $key = $module.$widget_id.'emailAddress'.$count;
878
+            while (isset($_REQUEST[$key])) {
879 879
                    $email = $_REQUEST[$key];
880
-                   $prefillDataArr[] =  array('email_address'=>$email,
880
+                   $prefillDataArr[] = array('email_address'=>$email,
881 881
                                              'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key,
882 882
                                              'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']),
883 883
                                              'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']),
884 884
                                              'reply_to_address'=>false
885 885
                                         );
886
-                   $key = $module . $widget_id . 'emailAddress' . ++$count;
886
+                   $key = $module.$widget_id.'emailAddress'.++$count;
887 887
             } //while
888 888
         }
889 889
 
890
-        if(!empty($prefillDataArr)) {
890
+        if (!empty($prefillDataArr)) {
891 891
             $json = new JSON(JSON_LOOSE_TYPE);
892 892
             $prefillData = $json->encode($prefillDataArr);
893 893
             $prefill = !empty($prefillDataArr) ? 'true' : 'false';
@@ -910,16 +910,16 @@  discard block
 block discarded – undo
910 910
         $form = $this->view;
911 911
 
912 912
         //determine if this should be a quickcreate form, or a quick create form under subpanels
913
-        if ($this->view == "QuickCreate"){
914
-            $form = 'form_DC'.$this->view .'_'.$module;
915
-            if(isset($_REQUEST['action']) && $_REQUEST['action']=='SubpanelCreates' ||  $_REQUEST['action']=='SubpanelEdits'){
916
-                $form = 'form_Subpanel'.$this->view .'_'.$module;
913
+        if ($this->view == "QuickCreate") {
914
+            $form = 'form_DC'.$this->view.'_'.$module;
915
+            if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'SubpanelCreates' || $_REQUEST['action'] == 'SubpanelEdits') {
916
+                $form = 'form_Subpanel'.$this->view.'_'.$module;
917 917
             }
918 918
         }
919 919
 
920 920
         $this->smarty->assign('emailView', $form);
921 921
 
922
-        if($module == 'Users') {
922
+        if ($module == 'Users') {
923 923
             $this->smarty->assign('useReplyTo', true);
924 924
         } else {
925 925
             $this->smarty->assign('useOptOut', true);
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
         $newEmail = $this->smarty->fetch($template);
931 931
 
932 932
 
933
-        if($asMetadata) {
933
+        if ($asMetadata) {
934 934
             // used by Email 2.0
935 935
             $ret = array();
936 936
             $ret['prefillData'] = $prefillDataArr;
@@ -948,18 +948,18 @@  discard block
 block discarded – undo
948 948
      * @param object $focus Bean in focus
949 949
      * @return string HTML/JS for widget
950 950
      */
951
-    function getEmailAddressWidgetDetailView($focus, $tpl='')
951
+    function getEmailAddressWidgetDetailView($focus, $tpl = '')
952 952
     {
953
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
953
+        if (!($this->smarty instanceOf Sugar_Smarty))
954 954
             $this->smarty = new Sugar_Smarty();
955 955
 
956 956
         global $app_strings;
957 957
         global $current_user;
958 958
         $assign = array();
959
-        if(empty($focus->id))return '';
959
+        if (empty($focus->id))return '';
960 960
         $prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir);
961 961
 
962
-        foreach($prefillData as $addressItem) {
962
+        foreach ($prefillData as $addressItem) {
963 963
             $key = ($addressItem['primary_address'] == 1) ? 'primary' : "";
964 964
             $key = ($addressItem['reply_to_address'] == 1) ? 'reply_to' : $key;
965 965
             $key = ($addressItem['opt_out'] == 1) ? 'opt_out' : $key;
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
      */
986 986
     function getEmailAddressWidgetDuplicatesView($focus)
987 987
     {
988
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
988
+        if (!($this->smarty instanceOf Sugar_Smarty))
989 989
             $this->smarty = new Sugar_Smarty();
990 990
 
991 991
         $count = 0;
@@ -995,49 +995,49 @@  discard block
 block discarded – undo
995 995
         $invalid = array();
996 996
         $mod = isset($focus) ? $focus->module_dir : "";
997 997
 
998
-        $widget_id = $_POST[$mod .'_email_widget_id'];
999
-        $this->smarty->assign('email_widget_id',$widget_id);
1000
-        $this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']);
998
+        $widget_id = $_POST[$mod.'_email_widget_id'];
999
+        $this->smarty->assign('email_widget_id', $widget_id);
1000
+        $this->smarty->assign('emailAddressWidget', $_POST['emailAddressWidget']);
1001 1001
 
1002
-        if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) {
1003
-           $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'];
1002
+        if (isset($_POST[$mod.$widget_id.'emailAddressPrimaryFlag'])) {
1003
+           $primary = $_POST[$mod.$widget_id.'emailAddressPrimaryFlag'];
1004 1004
         }
1005 1005
 
1006
-        while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) {
1007
-            $emails[] = $_POST[$mod . $widget_id . 'emailAddress' . $count];
1006
+        while (isset($_POST[$mod.$widget_id."emailAddress".$count])) {
1007
+            $emails[] = $_POST[$mod.$widget_id.'emailAddress'.$count];
1008 1008
             $count++;
1009 1009
         }
1010 1010
 
1011
-        if($count == 0) {
1011
+        if ($count == 0) {
1012 1012
            return "";
1013 1013
         }
1014 1014
 
1015
-        if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) {
1016
-           foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) {
1015
+        if (isset($_POST[$mod.$widget_id.'emailAddressOptOutFlag'])) {
1016
+           foreach ($_POST[$mod.$widget_id.'emailAddressOptOutFlag'] as $v) {
1017 1017
               $optOut[] = $v;
1018 1018
            }
1019 1019
         }
1020 1020
 
1021
-        if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) {
1022
-           foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) {
1021
+        if (isset($_POST[$mod.$widget_id.'emailAddressInvalidFlag'])) {
1022
+           foreach ($_POST[$mod.$widget_id.'emailAddressInvalidFlag'] as $v) {
1023 1023
               $invalid[] = $v;
1024 1024
            }
1025 1025
         }
1026 1026
 
1027
-        if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) {
1028
-           foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) {
1027
+        if (isset($_POST[$mod.$widget_id.'emailAddressReplyToFlag'])) {
1028
+           foreach ($_POST[$mod.$widget_id.'emailAddressReplyToFlag'] as $v) {
1029 1029
               $replyTo[] = $v;
1030 1030
            }
1031 1031
         }
1032 1032
 
1033
-        if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) {
1034
-           foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) {
1033
+        if (isset($_POST[$mod.$widget_id.'emailAddressDeleteFlag'])) {
1034
+           foreach ($_POST[$mod.$widget_id.'emailAddressDeleteFlag'] as $v) {
1035 1035
               $delete[] = $v;
1036 1036
            }
1037 1037
         }
1038 1038
 
1039
-        while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) {
1040
-            $verified[] = $_POST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count];
1039
+        while (isset($_POST[$mod.$widget_id."emailAddressVerifiedValue".$count])) {
1040
+            $verified[] = $_POST[$mod.$widget_id.'emailAddressVerifiedValue'.$count];
1041 1041
             $count++;
1042 1042
         }
1043 1043
 
@@ -1062,33 +1062,33 @@  discard block
 block discarded – undo
1062 1062
         $count = 0;
1063 1063
         $mod = isset($focus) ? $focus->module_dir : "";
1064 1064
 
1065
-        $widget_id = $_POST[$mod .'_email_widget_id'];
1066
-        $get .= '&' . $mod . '_email_widget_id='. $widget_id;
1065
+        $widget_id = $_POST[$mod.'_email_widget_id'];
1066
+        $get .= '&'.$mod.'_email_widget_id='.$widget_id;
1067 1067
         $get .= '&emailAddressWidget='.$_POST['emailAddressWidget'];
1068 1068
 
1069
-        while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) {
1070
-              $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]);
1069
+        while (isset($_REQUEST[$mod.$widget_id.'emailAddress'.$count])) {
1070
+              $get .= "&".$mod.$widget_id."emailAddress".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddress'.$count]);
1071 1071
               $count++;
1072 1072
         } //while
1073 1073
 
1074
-        while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) {
1075
-              $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]);
1074
+        while (isset($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count])) {
1075
+              $get .= "&".$mod.$widget_id."emailAddressVerifiedValue".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count]);
1076 1076
               $count++;
1077 1077
         } //while
1078 1078
 
1079 1079
         $options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag');
1080 1080
 
1081
-        foreach($options as $option) {
1081
+        foreach ($options as $option) {
1082 1082
             $count = 0;
1083 1083
             $optionIdentifier = $mod.$widget_id.$option;
1084
-            if(isset($_REQUEST[$optionIdentifier])) {
1085
-               if(is_array($_REQUEST[$optionIdentifier])) {
1086
-                   foreach($_REQUEST[$optionIdentifier] as $optOut) {
1087
-                      $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut;
1084
+            if (isset($_REQUEST[$optionIdentifier])) {
1085
+               if (is_array($_REQUEST[$optionIdentifier])) {
1086
+                   foreach ($_REQUEST[$optionIdentifier] as $optOut) {
1087
+                      $get .= "&".$optionIdentifier."[".$count."]=".$optOut;
1088 1088
                       $count++;
1089 1089
                    } //foreach
1090 1090
                } else {
1091
-                   $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier];
1091
+                   $get .= "&".$optionIdentifier."=".$_REQUEST[$optionIdentifier];
1092 1092
                }
1093 1093
             } //if
1094 1094
         } //foreach
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
  * @return string The value for the bean_module column in the email_addr_bean_rel table
1107 1107
  */
1108 1108
     function getCorrectedModule(&$module) {
1109
-        return ($module == "Employees")? "Users" : $module;
1109
+        return ($module == "Employees") ? "Users" : $module;
1110 1110
     }
1111 1111
 
1112 1112
     public function stash($parentBeanId, $moduleName)
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
         $ids = array();
1117 1117
         while ($row = $this->db->fetchByAssoc($result, false))
1118 1118
         {
1119
-            $ids[] =$this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection
1119
+            $ids[] = $this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection
1120 1120
         }
1121 1121
         if (!empty($ids))
1122 1122
         {
@@ -1140,15 +1140,15 @@  discard block
 block discarded – undo
1140 1140
  * @param string $view DetailView or EditView
1141 1141
  * @return string
1142 1142
  */
1143
-function getEmailAddressWidget($focus, $field, $value, $view, $tabindex='0') {
1143
+function getEmailAddressWidget($focus, $field, $value, $view, $tabindex = '0') {
1144 1144
     $sea = new SugarEmailAddress();
1145 1145
     $sea->setView($view);
1146 1146
 
1147
-        if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
1147
+        if ($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
1148 1148
             $module = $focus->module_dir;
1149 1149
             if ($view == 'ConvertLead' && $module == "Contacts")  $module = "Leads";
1150 1150
 
1151
-            return $sea->getEmailAddressWidgetEditView($focus->id, $module, false,'',$tabindex);
1151
+            return $sea->getEmailAddressWidgetEditView($focus->id, $module, false, '', $tabindex);
1152 1152
         }
1153 1153
 
1154 1154
     return $sea->getEmailAddressWidgetDetailView($focus);
Please login to merge, or discard this patch.
Braces   +40 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -85,8 +87,7 @@  discard block
 block discarded – undo
85 87
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
86 88
         if(isset($GLOBALS['log'])) {
87 89
             $GLOBALS['log']->deprecated($deprecatedMessage);
88
-        }
89
-        else {
90
+        } else {
90 91
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
91 92
         }
92 93
         self::__construct();
@@ -147,8 +148,9 @@  discard block
 block discarded – undo
147 148
         $alternate_found = false;
148 149
         $alternate2_found = false;
149 150
         foreach($this->addresses as $k=>$address) {
150
-            if ($primary_found && $alternate_found)
151
-                break;
151
+            if ($primary_found && $alternate_found) {
152
+                            break;
153
+            }
152 154
             if ($address['primary_address'] == 1 && !$primary_found) {
153 155
                 $primary_index = $k;
154 156
                 $primary_found = true;
@@ -286,8 +288,9 @@  discard block
 block discarded – undo
286 288
         )
287 289
     {
288 290
         $emailCaps = strtoupper(trim($email));
289
-        if(empty($emailCaps))
290
-            return 0;
291
+        if(empty($emailCaps)) {
292
+                    return 0;
293
+        }
291 294
 
292 295
         $q = "SELECT *
293 296
                 FROM email_addr_bean_rel eabl JOIN email_addresses ea
@@ -303,7 +306,9 @@  discard block
 block discarded – undo
303 306
 
304 307
         // do it this way to make the count accurate in oracle
305 308
         $i = 0;
306
-        while ($this->db->fetchByAssoc($r)) ++$i;
309
+        while ($this->db->fetchByAssoc($r)) {
310
+            ++$i;
311
+        }
307 312
 
308 313
         return $i;
309 314
     }
@@ -486,8 +491,9 @@  discard block
 block discarded – undo
486 491
                     foreach($_REQUEST as $k => $v) {
487 492
                         if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
488 493
                             $validateFlag = str_replace("Value", "Flag", $k);
489
-                            if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true")
490
-                              $new_addrs[$k] = $v;
494
+                            if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true") {
495
+                                                          $new_addrs[$k] = $v;
496
+                            }
491 497
                         }
492 498
                     }
493 499
                 }
@@ -690,8 +696,7 @@  discard block
 block discarded – undo
690 696
         if ($id) {
691 697
             $r = $this->db->query("SELECT * FROM email_addresses WHERE id='".$this->db->quote($id)."'");
692 698
             $current_email = $this->db->fetchByAssoc($r);
693
-        }
694
-        else {
699
+        } else {
695 700
             $current_email = null;
696 701
         }
697 702
 
@@ -731,8 +736,7 @@  discard block
 block discarded – undo
731 736
                 $upd_r = $this->db->query($upd_q);
732 737
             }
733 738
             return $duplicate_email['id'];
734
-        }
735
-        else {
739
+        } else {
736 740
             // no case-insensitive address match - it's new, or undeleted.
737 741
             $guid = '';
738 742
             if(!empty($address)){
@@ -798,8 +802,7 @@  discard block
 block discarded – undo
798 802
             // otherwise
799 803
             $q .= "
800 804
                 ORDER BY ear.reply_to_address DESC";
801
-        }
802
-        else
805
+        } else
803 806
         {
804 807
             // retrieve reply-to address only
805 808
             $q .= "
@@ -850,8 +853,9 @@  discard block
 block discarded – undo
850 853
      */
851 854
     function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='',$tabindex='0')
852 855
     {
853
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
854
-            $this->smarty = new Sugar_Smarty();
856
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
857
+                    $this->smarty = new Sugar_Smarty();
858
+        }
855 859
 
856 860
         global $app_strings, $dictionary, $beanList;
857 861
 
@@ -869,8 +873,9 @@  discard block
 block discarded – undo
869 873
         if(!empty($id)) {
870 874
             $prefillDataArr = $this->getAddressesByGUID($id, $module);
871 875
             //When coming from convert leads, sometimes module is Contacts while the id is for a lead.
872
-            if (empty($prefillDataArr) && $module == "Contacts")
873
-                $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
876
+            if (empty($prefillDataArr) && $module == "Contacts") {
877
+                            $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
878
+            }
874 879
         } else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){
875 880
             $widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0';
876 881
             $count = 0;
@@ -895,8 +900,9 @@  discard block
 block discarded – undo
895 900
 
896 901
         $required = false;
897 902
         $vardefs = $dictionary[$beanList[$passedModule]]['fields'];
898
-        if (!empty($vardefs['email1']) && isset($vardefs['email1']['required']) && $vardefs['email1']['required'])
899
-            $required = true;
903
+        if (!empty($vardefs['email1']) && isset($vardefs['email1']['required']) && $vardefs['email1']['required']) {
904
+                    $required = true;
905
+        }
900 906
         $this->smarty->assign('required', $required);
901 907
 
902 908
         $this->smarty->assign('module', $saveModule);
@@ -950,13 +956,16 @@  discard block
 block discarded – undo
950 956
      */
951 957
     function getEmailAddressWidgetDetailView($focus, $tpl='')
952 958
     {
953
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
954
-            $this->smarty = new Sugar_Smarty();
959
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
960
+                    $this->smarty = new Sugar_Smarty();
961
+        }
955 962
 
956 963
         global $app_strings;
957 964
         global $current_user;
958 965
         $assign = array();
959
-        if(empty($focus->id))return '';
966
+        if(empty($focus->id)) {
967
+            return '';
968
+        }
960 969
         $prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir);
961 970
 
962 971
         foreach($prefillData as $addressItem) {
@@ -985,8 +994,9 @@  discard block
 block discarded – undo
985 994
      */
986 995
     function getEmailAddressWidgetDuplicatesView($focus)
987 996
     {
988
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
989
-            $this->smarty = new Sugar_Smarty();
997
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
998
+                    $this->smarty = new Sugar_Smarty();
999
+        }
990 1000
 
991 1001
         $count = 0;
992 1002
         $emails = array();
@@ -1146,7 +1156,9 @@  discard block
 block discarded – undo
1146 1156
 
1147 1157
         if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
1148 1158
             $module = $focus->module_dir;
1149
-            if ($view == 'ConvertLead' && $module == "Contacts")  $module = "Leads";
1159
+            if ($view == 'ConvertLead' && $module == "Contacts") {
1160
+                $module = "Leads";
1161
+            }
1150 1162
 
1151 1163
             return $sea->getEmailAddressWidgetEditView($focus->id, $module, false,'',$tabindex);
1152 1164
         }
Please login to merge, or discard this patch.
include/SugarPHPMailer.php 3 patches
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -48,130 +48,130 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class SugarPHPMailer extends PHPMailer
50 50
 {
51
-	var $oe; // OutboundEmail
52
-	var $protocol = "tcp://";
53
-	var $preppedForOutbound = false;
54
-	var $disclosureEnabled;
55
-	var $disclosureText;
56
-	var $isHostEmpty = false;
57
-	var $opensslOpened = true;
58
-
59
-	/**
60
-	 * Sole constructor
61
-	 */
62
-	public function __construct() {
51
+    var $oe; // OutboundEmail
52
+    var $protocol = "tcp://";
53
+    var $preppedForOutbound = false;
54
+    var $disclosureEnabled;
55
+    var $disclosureText;
56
+    var $isHostEmpty = false;
57
+    var $opensslOpened = true;
58
+
59
+    /**
60
+     * Sole constructor
61
+     */
62
+    public function __construct() {
63 63
         parent::__construct();
64
-		global $locale;
65
-		global $current_user;
66
-		global $sugar_config;
64
+        global $locale;
65
+        global $current_user;
66
+        global $sugar_config;
67 67
 
68
-		$admin = new Administration();
69
-		$admin->retrieveSettings();
68
+        $admin = new Administration();
69
+        $admin->retrieveSettings();
70 70
 
71
-		if(isset($admin->settings['disclosure_enable']) && !empty($admin->settings['disclosure_enable'])) {
72
-			$this->disclosureEnabled = true;
73
-			$this->disclosureText = $admin->settings['disclosure_text'];
74
-		}
71
+        if(isset($admin->settings['disclosure_enable']) && !empty($admin->settings['disclosure_enable'])) {
72
+            $this->disclosureEnabled = true;
73
+            $this->disclosureText = $admin->settings['disclosure_text'];
74
+        }
75 75
 
76
-		$this->oe = new OutboundEmail();
77
-		$this->oe->getUserMailerSettings($current_user);
76
+        $this->oe = new OutboundEmail();
77
+        $this->oe->getUserMailerSettings($current_user);
78 78
 
79
-		$this->SetLanguage('en', 'include/phpmailer/language/');
80
-		$this->PluginDir	= 'include/phpmailer/';
81
-		$this->Mailer	 	= 'smtp';
79
+        $this->SetLanguage('en', 'include/phpmailer/language/');
80
+        $this->PluginDir	= 'include/phpmailer/';
81
+        $this->Mailer	 	= 'smtp';
82 82
         // cn: i18n
83 83
         $this->CharSet		= $locale->getPrecedentPreference('default_email_charset');
84
-		$this->Encoding		= 'quoted-printable';
84
+        $this->Encoding		= 'quoted-printable';
85 85
         $this->IsHTML(false);  // default to plain-text email
86 86
         $this->Hostname = $sugar_config['host_name'];
87 87
         $this->WordWrap		= 996;
88
-		// cn: gmail fix
89
-		$this->protocol = ($this->oe->mail_smtpssl == 1) ? "ssl://" : $this->protocol;
90
-
91
-	}
92
-
93
-	/**
94
-	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
95
-	 */
96
-	public function SugarPHPMailer(){
97
-		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
98
-		if(isset($GLOBALS['log'])) {
99
-			$GLOBALS['log']->deprecated($deprecatedMessage);
100
-		}
101
-		else {
102
-			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
103
-		}
104
-		self::__construct();
105
-	}
106
-
107
-	/**
108
-	 * Prefills outbound details
109
-	 */
110
-	function setMailer() {
111
-		global $current_user;
112
-
113
-		require_once("include/OutboundEmail/OutboundEmail.php");
114
-		$oe = new OutboundEmail();
115
-		$oe = $oe->getUserMailerSettings($current_user);
116
-
117
-		// ssl or tcp - keeping outside isSMTP b/c a default may inadvertently set ssl://
118
-		$this->protocol = ($oe->mail_smtpssl) ? "ssl://" : "tcp://";
119
-
120
-		if($oe->mail_sendtype == "SMTP")
121
-		{
122
-    		//Set mail send type information
123
-    		$this->Mailer = "smtp";
124
-    		$this->Host = $oe->mail_smtpserver;
125
-    		$this->Port = $oe->mail_smtpport;
88
+        // cn: gmail fix
89
+        $this->protocol = ($this->oe->mail_smtpssl == 1) ? "ssl://" : $this->protocol;
90
+
91
+    }
92
+
93
+    /**
94
+     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
95
+     */
96
+    public function SugarPHPMailer(){
97
+        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
98
+        if(isset($GLOBALS['log'])) {
99
+            $GLOBALS['log']->deprecated($deprecatedMessage);
100
+        }
101
+        else {
102
+            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
103
+        }
104
+        self::__construct();
105
+    }
106
+
107
+    /**
108
+     * Prefills outbound details
109
+     */
110
+    function setMailer() {
111
+        global $current_user;
112
+
113
+        require_once("include/OutboundEmail/OutboundEmail.php");
114
+        $oe = new OutboundEmail();
115
+        $oe = $oe->getUserMailerSettings($current_user);
116
+
117
+        // ssl or tcp - keeping outside isSMTP b/c a default may inadvertently set ssl://
118
+        $this->protocol = ($oe->mail_smtpssl) ? "ssl://" : "tcp://";
119
+
120
+        if($oe->mail_sendtype == "SMTP")
121
+        {
122
+            //Set mail send type information
123
+            $this->Mailer = "smtp";
124
+            $this->Host = $oe->mail_smtpserver;
125
+            $this->Port = $oe->mail_smtpport;
126 126
             if ($oe->mail_smtpssl == 1) {
127
-            	$this->SMTPSecure = 'ssl';
127
+                $this->SMTPSecure = 'ssl';
128 128
             } // if
129 129
             if ($oe->mail_smtpssl == 2) {
130
-            	$this->SMTPSecure = 'tls';
130
+                $this->SMTPSecure = 'tls';
131 131
             } // if
132 132
 
133
-    		if($oe->mail_smtpauth_req) {
134
-    			$this->SMTPAuth = TRUE;
135
-    			$this->Username = $oe->mail_smtpuser;
136
-    			$this->Password = $oe->mail_smtppass;
137
-    		}
138
-		}
139
-		else
140
-			$this->Mailer = "sendmail";
141
-	}
142
-
143
-	/**
144
-	 * Prefills mailer for system
145
-	 */
146
-	function setMailerForSystem() {
147
-		require_once("include/OutboundEmail/OutboundEmail.php");
148
-		$oe = new OutboundEmail();
149
-		$oe = $oe->getSystemMailerSettings();
150
-
151
-		// ssl or tcp - keeping outside isSMTP b/c a default may inadvertantly set ssl://
152
-		$this->protocol = ($oe->mail_smtpssl) ? "ssl://" : "tcp://";
153
-
154
-		if($oe->mail_sendtype == "SMTP")
155
-		{
156
-    		//Set mail send type information
157
-    		$this->Mailer = "smtp";
158
-    		$this->Host = $oe->mail_smtpserver;
159
-    		$this->Port = $oe->mail_smtpport;
133
+            if($oe->mail_smtpauth_req) {
134
+                $this->SMTPAuth = TRUE;
135
+                $this->Username = $oe->mail_smtpuser;
136
+                $this->Password = $oe->mail_smtppass;
137
+            }
138
+        }
139
+        else
140
+            $this->Mailer = "sendmail";
141
+    }
142
+
143
+    /**
144
+     * Prefills mailer for system
145
+     */
146
+    function setMailerForSystem() {
147
+        require_once("include/OutboundEmail/OutboundEmail.php");
148
+        $oe = new OutboundEmail();
149
+        $oe = $oe->getSystemMailerSettings();
150
+
151
+        // ssl or tcp - keeping outside isSMTP b/c a default may inadvertantly set ssl://
152
+        $this->protocol = ($oe->mail_smtpssl) ? "ssl://" : "tcp://";
153
+
154
+        if($oe->mail_sendtype == "SMTP")
155
+        {
156
+            //Set mail send type information
157
+            $this->Mailer = "smtp";
158
+            $this->Host = $oe->mail_smtpserver;
159
+            $this->Port = $oe->mail_smtpport;
160 160
             if ($oe->mail_smtpssl == 1) {
161 161
                 $this->SMTPSecure = 'ssl';
162 162
             } // if
163 163
             if ($oe->mail_smtpssl == 2) {
164
-            	$this->SMTPSecure = 'tls';
164
+                $this->SMTPSecure = 'tls';
165 165
             } // if
166
-    		if($oe->mail_smtpauth_req) {
167
-    			$this->SMTPAuth = TRUE;
168
-    			$this->Username = $oe->mail_smtpuser;
169
-    			$this->Password = $oe->mail_smtppass;
170
-    		}
171
-		}
172
-		else
173
-		  $this->Mailer = "sendmail";
174
-	}
166
+            if($oe->mail_smtpauth_req) {
167
+                $this->SMTPAuth = TRUE;
168
+                $this->Username = $oe->mail_smtpuser;
169
+                $this->Password = $oe->mail_smtppass;
170
+            }
171
+        }
172
+        else
173
+            $this->Mailer = "sendmail";
174
+    }
175 175
 
176 176
     /**
177 177
      * Attaches all fs, string, and binary attachments to the message.
@@ -230,38 +230,38 @@  discard block
 block discarded – undo
230 230
         return join("", $mime);
231 231
     }*/
232 232
 
233
-	/**
234
-	 * handles Charset translation for all visual parts of the email.
235
-	 * @param string charset Default = ''
236
-	 */
237
-	function prepForOutbound() {
238
-		global $locale;
239
-
240
-		if($this->preppedForOutbound == false) {
241
-			//bug 28534. We should not set it to true to circumvent the following conversion as each email is independent.
242
-			//$this->preppedForOutbound = true; // flag so we don't redo this
243
-			$OBCharset = $locale->getPrecedentPreference('default_email_charset');
244
-
245
-			// handle disclosure
246
-			if($this->disclosureEnabled) {
247
-				$this->Body .= "<br />&nbsp;<br />{$this->disclosureText}";
248
-				$this->AltBody .= "\r\r{$this->disclosureText}";
249
-			}
233
+    /**
234
+     * handles Charset translation for all visual parts of the email.
235
+     * @param string charset Default = ''
236
+     */
237
+    function prepForOutbound() {
238
+        global $locale;
239
+
240
+        if($this->preppedForOutbound == false) {
241
+            //bug 28534. We should not set it to true to circumvent the following conversion as each email is independent.
242
+            //$this->preppedForOutbound = true; // flag so we don't redo this
243
+            $OBCharset = $locale->getPrecedentPreference('default_email_charset');
244
+
245
+            // handle disclosure
246
+            if($this->disclosureEnabled) {
247
+                $this->Body .= "<br />&nbsp;<br />{$this->disclosureText}";
248
+                $this->AltBody .= "\r\r{$this->disclosureText}";
249
+            }
250 250
 
251
-			// body text
252
-			$this->Body		= from_html($locale->translateCharset(trim($this->Body), 'UTF-8', $OBCharset));
253
-			$this->AltBody		= from_html($locale->translateCharset(trim($this->AltBody), 'UTF-8', $OBCharset));
251
+            // body text
252
+            $this->Body		= from_html($locale->translateCharset(trim($this->Body), 'UTF-8', $OBCharset));
253
+            $this->AltBody		= from_html($locale->translateCharset(trim($this->AltBody), 'UTF-8', $OBCharset));
254 254
             $subjectUTF8		= from_html(trim($this->Subject));
255 255
             $subject			= $locale->translateCharset($subjectUTF8, 'UTF-8', $OBCharset);
256 256
             $this->Subject		= $locale->translateCharset($subjectUTF8, 'UTF-8', $OBCharset);
257 257
 
258
-			// HTML email RFC compliance
259
-			if($this->ContentType == "text/html") {
260
-				if(strpos($this->Body, '<html') === false) {
258
+            // HTML email RFC compliance
259
+            if($this->ContentType == "text/html") {
260
+                if(strpos($this->Body, '<html') === false) {
261 261
 
262 262
                     $langHeader = get_language_header();
263 263
 
264
-					$head=<<<eoq
264
+                    $head=<<<eoq
265 265
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
266 266
 <html xmlns="http://www.w3.org/1999/xhtml" {$langHeader}>
267 267
 <head>
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
 </head>
271 271
 <body>
272 272
 eoq;
273
-					$this->Body = $head.$this->Body."</body></html>";
274
-				}
275
-			}
273
+                    $this->Body = $head.$this->Body."</body></html>";
274
+                }
275
+            }
276 276
 
277
-			// Headers /////////////////////////////////
278
-			// the below is done in PHPMailer::CreateHeader();
279
-			//$this->Subject			= $locale->translateCharsetMIME(trim($this->Subject), 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
280
-			$this->FromName		= $locale->translateCharset(trim($this->FromName), 'UTF-8', $OBCharset);
281
-			/*
277
+            // Headers /////////////////////////////////
278
+            // the below is done in PHPMailer::CreateHeader();
279
+            //$this->Subject			= $locale->translateCharsetMIME(trim($this->Subject), 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
280
+            $this->FromName		= $locale->translateCharset(trim($this->FromName), 'UTF-8', $OBCharset);
281
+            /*
282 282
 			foreach($this->ReplyTo as $k => $v) {
283 283
 				$this->ReplyTo[$k][1] = $locale->translateCharset(trim($v[1]), 'UTF-8', $OBCharset);
284 284
 			}
@@ -296,129 +296,129 @@  discard block
 block discarded – undo
296 296
 			}
297 297
 			*/
298 298
 
299
-		}
300
-	}
301
-
302
-	/**
303
-	 * Replace images with locations specified by regex with cid: images
304
-	 * and attach needed files
305
-	 * @param string $regex Regular expression
306
-	 * @param string $local_prefix Prefix where local files are stored
307
-	 * @param bool $object Use attachment object
308
-	 */
309
-	public function replaceImageByRegex($regex, $local_prefix, $object = false)
310
-	{
311
-		preg_match_all("#<img[^>]*[\s]+src[^=]*=[\s]*[\"']($regex)(.+?)[\"']#si", $this->Body, $matches);
312
-		$i = 0;
299
+        }
300
+    }
301
+
302
+    /**
303
+     * Replace images with locations specified by regex with cid: images
304
+     * and attach needed files
305
+     * @param string $regex Regular expression
306
+     * @param string $local_prefix Prefix where local files are stored
307
+     * @param bool $object Use attachment object
308
+     */
309
+    public function replaceImageByRegex($regex, $local_prefix, $object = false)
310
+    {
311
+        preg_match_all("#<img[^>]*[\s]+src[^=]*=[\s]*[\"']($regex)(.+?)[\"']#si", $this->Body, $matches);
312
+        $i = 0;
313 313
         foreach($matches[2] as $match) {
314
-			$filename = urldecode($match);
315
-			$cid = $filename;
316
-			$file_location = $local_prefix.$filename;
317
-			if(!file_exists($file_location)) continue;
318
-			if($object) {
319
-			    if(preg_match('#&(?:amp;)?type=([\w]+)#i', $matches[0][$i], $typematch)) {
320
-			        switch(strtolower($typematch[1])) {
321
-			            case 'documents':
322
-			                $beanname = 'DocumentRevisions';
323
-			                break;
324
-			            case 'notes':
325
-			                $beanname = 'Notes';
326
-			                break;
327
-			        }
328
-			    }
329
-			    $mime_type = "application/octet-stream";
330
-			    if(isset($beanname)) {
331
-			        $bean = SugarModule::get($beanname)->loadBean();
332
-    			    $bean->retrieve($filename);
333
-    			    if(!empty($bean->id)) {
334
-        			    $mime_type = $bean->file_mime_type;
335
-        			    $filename = $bean->filename;
336
-    			    }
337
-			    }
338
-			} else {
339
-			    $mime_type = "image/".strtolower(pathinfo($filename, PATHINFO_EXTENSION));
340
-			}
341
-		    if (!$this->embeddedAttachmentExists($cid)) {
342
-		    	$this->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
343
-		    }
344
-		    $i++;
314
+            $filename = urldecode($match);
315
+            $cid = $filename;
316
+            $file_location = $local_prefix.$filename;
317
+            if(!file_exists($file_location)) continue;
318
+            if($object) {
319
+                if(preg_match('#&(?:amp;)?type=([\w]+)#i', $matches[0][$i], $typematch)) {
320
+                    switch(strtolower($typematch[1])) {
321
+                        case 'documents':
322
+                            $beanname = 'DocumentRevisions';
323
+                            break;
324
+                        case 'notes':
325
+                            $beanname = 'Notes';
326
+                            break;
327
+                    }
328
+                }
329
+                $mime_type = "application/octet-stream";
330
+                if(isset($beanname)) {
331
+                    $bean = SugarModule::get($beanname)->loadBean();
332
+                    $bean->retrieve($filename);
333
+                    if(!empty($bean->id)) {
334
+                        $mime_type = $bean->file_mime_type;
335
+                        $filename = $bean->filename;
336
+                    }
337
+                }
338
+            } else {
339
+                $mime_type = "image/".strtolower(pathinfo($filename, PATHINFO_EXTENSION));
340
+            }
341
+            if (!$this->embeddedAttachmentExists($cid)) {
342
+                $this->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
343
+            }
344
+            $i++;
345 345
         }
346
-		//replace references to cache with cid tag
347
-		$this->Body = preg_replace("|\"$regex|i",'"cid:',$this->Body);
348
-		// remove bad img line from outbound email
349
-		$this->Body = preg_replace('#<img[^>]+src[^=]*=\"\/([^>]*?[^>]*)>#sim', '', $this->Body);
350
-	}
351
-
352
-	/**
353
-	 * @param notes	array of note beans
354
-	 */
355
-	function handleAttachments($notes) {
356
-		global $sugar_config;
357
-
358
-		// cn: bug 4864 - reusing same SugarPHPMailer class, need to clear attachments
359
-		$this->ClearAttachments();
360
-
361
-		//replace references to cache/images with cid tag
346
+        //replace references to cache with cid tag
347
+        $this->Body = preg_replace("|\"$regex|i",'"cid:',$this->Body);
348
+        // remove bad img line from outbound email
349
+        $this->Body = preg_replace('#<img[^>]+src[^=]*=\"\/([^>]*?[^>]*)>#sim', '', $this->Body);
350
+    }
351
+
352
+    /**
353
+     * @param notes	array of note beans
354
+     */
355
+    function handleAttachments($notes) {
356
+        global $sugar_config;
357
+
358
+        // cn: bug 4864 - reusing same SugarPHPMailer class, need to clear attachments
359
+        $this->ClearAttachments();
360
+
361
+        //replace references to cache/images with cid tag
362 362
         $this->Body = preg_replace(';=\s*"'.preg_quote(sugar_cached('images/'), ';').';','="cid:',$this->Body);
363 363
 
364
-		$this->replaceImageByRegex("(?:{$sugar_config['site_url']})?/?cache/images/", sugar_cached("images/"));
365
-
366
-		//Replace any embeded images using the secure entryPoint for src url.
367
-		$this->replaceImageByRegex("(?:{$sugar_config['site_url']})?index.php[?]entryPoint=download&(?:amp;)?[^\"]+?id=", "upload://", true);
368
-
369
-		if (empty($notes)) {
370
-				return;
371
-		}
372
-		//Handle regular attachments.
373
-		foreach($notes as $note) {
374
-				$mime_type = 'text/plain';
375
-				$file_location = '';
376
-				$filename = '';
377
-
378
-				if($note->object_name == 'Note') {
379
-					if (! empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
380
-						$file_location = $note->file->temp_file_location;
381
-						$filename = $note->file->original_file_name;
382
-						$mime_type = $note->file->mime_type;
383
-					} else {
384
-						$file_location = "upload://{$note->id}";
385
-						$filename = $note->id.$note->filename;
386
-						$mime_type = $note->file_mime_type;
387
-					}
388
-				} elseif($note->object_name == 'DocumentRevision') { // from Documents
389
-					$filename = $note->id.$note->filename;
390
-					$file_location = "upload://$filename";
391
-					$mime_type = $note->file_mime_type;
392
-				}
393
-
394
-				$filename = substr($filename, 36, strlen($filename)); // strip GUID	for PHPMailer class to name outbound file
395
-				if (!$note->embed_flag) {
396
-					$this->AddAttachment($file_location, $filename, 'base64', $mime_type);
397
-				} // else
398
-			}
399
-	}
400
-
401
-	/**
402
-	 * overloads class.phpmailer's SetError() method so that we can log errors in sugarcrm.log
403
-	 *
404
-	 */
405
-	function SetError($msg) {
406
-		$GLOBALS['log']->fatal("SugarPHPMailer encountered an error: {$msg}");
407
-		parent::SetError($msg);
408
-	}
409
-
410
-	function SmtpConnect($options = array()) {
411
-		$connection = parent::SmtpConnect();
412
-		if (!$connection) {
413
-			global $app_strings;
414
-			if(isset($this->oe) && $this->oe->type == "system") {
415
-				$this->SetError($app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND']);
416
-			} else {
417
-				$this->SetError($app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND']);
418
-			} // else
419
-		}
420
-		return $connection;
421
-	} // fn
364
+        $this->replaceImageByRegex("(?:{$sugar_config['site_url']})?/?cache/images/", sugar_cached("images/"));
365
+
366
+        //Replace any embeded images using the secure entryPoint for src url.
367
+        $this->replaceImageByRegex("(?:{$sugar_config['site_url']})?index.php[?]entryPoint=download&(?:amp;)?[^\"]+?id=", "upload://", true);
368
+
369
+        if (empty($notes)) {
370
+                return;
371
+        }
372
+        //Handle regular attachments.
373
+        foreach($notes as $note) {
374
+                $mime_type = 'text/plain';
375
+                $file_location = '';
376
+                $filename = '';
377
+
378
+                if($note->object_name == 'Note') {
379
+                    if (! empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
380
+                        $file_location = $note->file->temp_file_location;
381
+                        $filename = $note->file->original_file_name;
382
+                        $mime_type = $note->file->mime_type;
383
+                    } else {
384
+                        $file_location = "upload://{$note->id}";
385
+                        $filename = $note->id.$note->filename;
386
+                        $mime_type = $note->file_mime_type;
387
+                    }
388
+                } elseif($note->object_name == 'DocumentRevision') { // from Documents
389
+                    $filename = $note->id.$note->filename;
390
+                    $file_location = "upload://$filename";
391
+                    $mime_type = $note->file_mime_type;
392
+                }
393
+
394
+                $filename = substr($filename, 36, strlen($filename)); // strip GUID	for PHPMailer class to name outbound file
395
+                if (!$note->embed_flag) {
396
+                    $this->AddAttachment($file_location, $filename, 'base64', $mime_type);
397
+                } // else
398
+            }
399
+    }
400
+
401
+    /**
402
+     * overloads class.phpmailer's SetError() method so that we can log errors in sugarcrm.log
403
+     *
404
+     */
405
+    function SetError($msg) {
406
+        $GLOBALS['log']->fatal("SugarPHPMailer encountered an error: {$msg}");
407
+        parent::SetError($msg);
408
+    }
409
+
410
+    function SmtpConnect($options = array()) {
411
+        $connection = parent::SmtpConnect();
412
+        if (!$connection) {
413
+            global $app_strings;
414
+            if(isset($this->oe) && $this->oe->type == "system") {
415
+                $this->SetError($app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND']);
416
+            } else {
417
+                $this->SetError($app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND']);
418
+            } // else
419
+        }
420
+        return $connection;
421
+    } // fn
422 422
 
423 423
     /*
424 424
      * overloads PHPMailer::PreSend() to allow for empty messages to go out.
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$admin = new Administration();
69 69
 		$admin->retrieveSettings();
70 70
 
71
-		if(isset($admin->settings['disclosure_enable']) && !empty($admin->settings['disclosure_enable'])) {
71
+		if (isset($admin->settings['disclosure_enable']) && !empty($admin->settings['disclosure_enable'])) {
72 72
 			$this->disclosureEnabled = true;
73 73
 			$this->disclosureText = $admin->settings['disclosure_text'];
74 74
 		}
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		$this->oe->getUserMailerSettings($current_user);
78 78
 
79 79
 		$this->SetLanguage('en', 'include/phpmailer/language/');
80
-		$this->PluginDir	= 'include/phpmailer/';
81
-		$this->Mailer	 	= 'smtp';
80
+		$this->PluginDir = 'include/phpmailer/';
81
+		$this->Mailer = 'smtp';
82 82
         // cn: i18n
83 83
         $this->CharSet		= $locale->getPrecedentPreference('default_email_charset');
84
-		$this->Encoding		= 'quoted-printable';
85
-        $this->IsHTML(false);  // default to plain-text email
84
+		$this->Encoding = 'quoted-printable';
85
+        $this->IsHTML(false); // default to plain-text email
86 86
         $this->Hostname = $sugar_config['host_name'];
87
-        $this->WordWrap		= 996;
87
+        $this->WordWrap = 996;
88 88
 		// cn: gmail fix
89 89
 		$this->protocol = ($this->oe->mail_smtpssl == 1) ? "ssl://" : $this->protocol;
90 90
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
95 95
 	 */
96
-	public function SugarPHPMailer(){
96
+	public function SugarPHPMailer() {
97 97
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
98
-		if(isset($GLOBALS['log'])) {
98
+		if (isset($GLOBALS['log'])) {
99 99
 			$GLOBALS['log']->deprecated($deprecatedMessage);
100 100
 		}
101 101
 		else {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		// ssl or tcp - keeping outside isSMTP b/c a default may inadvertently set ssl://
118 118
 		$this->protocol = ($oe->mail_smtpssl) ? "ssl://" : "tcp://";
119 119
 
120
-		if($oe->mail_sendtype == "SMTP")
120
+		if ($oe->mail_sendtype == "SMTP")
121 121
 		{
122 122
     		//Set mail send type information
123 123
     		$this->Mailer = "smtp";
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             	$this->SMTPSecure = 'tls';
131 131
             } // if
132 132
 
133
-    		if($oe->mail_smtpauth_req) {
133
+    		if ($oe->mail_smtpauth_req) {
134 134
     			$this->SMTPAuth = TRUE;
135 135
     			$this->Username = $oe->mail_smtpuser;
136 136
     			$this->Password = $oe->mail_smtppass;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		// ssl or tcp - keeping outside isSMTP b/c a default may inadvertantly set ssl://
152 152
 		$this->protocol = ($oe->mail_smtpssl) ? "ssl://" : "tcp://";
153 153
 
154
-		if($oe->mail_sendtype == "SMTP")
154
+		if ($oe->mail_sendtype == "SMTP")
155 155
 		{
156 156
     		//Set mail send type information
157 157
     		$this->Mailer = "smtp";
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             if ($oe->mail_smtpssl == 2) {
164 164
             	$this->SMTPSecure = 'tls';
165 165
             } // if
166
-    		if($oe->mail_smtpauth_req) {
166
+    		if ($oe->mail_smtpauth_req) {
167 167
     			$this->SMTPAuth = TRUE;
168 168
     			$this->Username = $oe->mail_smtpuser;
169 169
     			$this->Password = $oe->mail_smtppass;
@@ -237,31 +237,31 @@  discard block
 block discarded – undo
237 237
 	function prepForOutbound() {
238 238
 		global $locale;
239 239
 
240
-		if($this->preppedForOutbound == false) {
240
+		if ($this->preppedForOutbound == false) {
241 241
 			//bug 28534. We should not set it to true to circumvent the following conversion as each email is independent.
242 242
 			//$this->preppedForOutbound = true; // flag so we don't redo this
243 243
 			$OBCharset = $locale->getPrecedentPreference('default_email_charset');
244 244
 
245 245
 			// handle disclosure
246
-			if($this->disclosureEnabled) {
246
+			if ($this->disclosureEnabled) {
247 247
 				$this->Body .= "<br />&nbsp;<br />{$this->disclosureText}";
248 248
 				$this->AltBody .= "\r\r{$this->disclosureText}";
249 249
 			}
250 250
 
251 251
 			// body text
252
-			$this->Body		= from_html($locale->translateCharset(trim($this->Body), 'UTF-8', $OBCharset));
253
-			$this->AltBody		= from_html($locale->translateCharset(trim($this->AltBody), 'UTF-8', $OBCharset));
254
-            $subjectUTF8		= from_html(trim($this->Subject));
255
-            $subject			= $locale->translateCharset($subjectUTF8, 'UTF-8', $OBCharset);
256
-            $this->Subject		= $locale->translateCharset($subjectUTF8, 'UTF-8', $OBCharset);
252
+			$this->Body = from_html($locale->translateCharset(trim($this->Body), 'UTF-8', $OBCharset));
253
+			$this->AltBody = from_html($locale->translateCharset(trim($this->AltBody), 'UTF-8', $OBCharset));
254
+            $subjectUTF8 = from_html(trim($this->Subject));
255
+            $subject = $locale->translateCharset($subjectUTF8, 'UTF-8', $OBCharset);
256
+            $this->Subject = $locale->translateCharset($subjectUTF8, 'UTF-8', $OBCharset);
257 257
 
258 258
 			// HTML email RFC compliance
259
-			if($this->ContentType == "text/html") {
260
-				if(strpos($this->Body, '<html') === false) {
259
+			if ($this->ContentType == "text/html") {
260
+				if (strpos($this->Body, '<html') === false) {
261 261
 
262 262
                     $langHeader = get_language_header();
263 263
 
264
-					$head=<<<eoq
264
+					$head = <<<eoq
265 265
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
266 266
 <html xmlns="http://www.w3.org/1999/xhtml" {$langHeader}>
267 267
 <head>
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 			// Headers /////////////////////////////////
278 278
 			// the below is done in PHPMailer::CreateHeader();
279 279
 			//$this->Subject			= $locale->translateCharsetMIME(trim($this->Subject), 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
280
-			$this->FromName		= $locale->translateCharset(trim($this->FromName), 'UTF-8', $OBCharset);
280
+			$this->FromName = $locale->translateCharset(trim($this->FromName), 'UTF-8', $OBCharset);
281 281
 			/*
282 282
 			foreach($this->ReplyTo as $k => $v) {
283 283
 				$this->ReplyTo[$k][1] = $locale->translateCharset(trim($v[1]), 'UTF-8', $OBCharset);
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
 	{
311 311
 		preg_match_all("#<img[^>]*[\s]+src[^=]*=[\s]*[\"']($regex)(.+?)[\"']#si", $this->Body, $matches);
312 312
 		$i = 0;
313
-        foreach($matches[2] as $match) {
313
+        foreach ($matches[2] as $match) {
314 314
 			$filename = urldecode($match);
315 315
 			$cid = $filename;
316 316
 			$file_location = $local_prefix.$filename;
317
-			if(!file_exists($file_location)) continue;
318
-			if($object) {
319
-			    if(preg_match('#&(?:amp;)?type=([\w]+)#i', $matches[0][$i], $typematch)) {
320
-			        switch(strtolower($typematch[1])) {
317
+			if (!file_exists($file_location)) continue;
318
+			if ($object) {
319
+			    if (preg_match('#&(?:amp;)?type=([\w]+)#i', $matches[0][$i], $typematch)) {
320
+			        switch (strtolower($typematch[1])) {
321 321
 			            case 'documents':
322 322
 			                $beanname = 'DocumentRevisions';
323 323
 			                break;
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 			        }
328 328
 			    }
329 329
 			    $mime_type = "application/octet-stream";
330
-			    if(isset($beanname)) {
330
+			    if (isset($beanname)) {
331 331
 			        $bean = SugarModule::get($beanname)->loadBean();
332 332
     			    $bean->retrieve($filename);
333
-    			    if(!empty($bean->id)) {
333
+    			    if (!empty($bean->id)) {
334 334
         			    $mime_type = $bean->file_mime_type;
335 335
         			    $filename = $bean->filename;
336 336
     			    }
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 		    $i++;
345 345
         }
346 346
 		//replace references to cache with cid tag
347
-		$this->Body = preg_replace("|\"$regex|i",'"cid:',$this->Body);
347
+		$this->Body = preg_replace("|\"$regex|i", '"cid:', $this->Body);
348 348
 		// remove bad img line from outbound email
349 349
 		$this->Body = preg_replace('#<img[^>]+src[^=]*=\"\/([^>]*?[^>]*)>#sim', '', $this->Body);
350 350
 	}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		$this->ClearAttachments();
360 360
 
361 361
 		//replace references to cache/images with cid tag
362
-        $this->Body = preg_replace(';=\s*"'.preg_quote(sugar_cached('images/'), ';').';','="cid:',$this->Body);
362
+        $this->Body = preg_replace(';=\s*"'.preg_quote(sugar_cached('images/'), ';').';', '="cid:', $this->Body);
363 363
 
364 364
 		$this->replaceImageByRegex("(?:{$sugar_config['site_url']})?/?cache/images/", sugar_cached("images/"));
365 365
 
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 				return;
371 371
 		}
372 372
 		//Handle regular attachments.
373
-		foreach($notes as $note) {
373
+		foreach ($notes as $note) {
374 374
 				$mime_type = 'text/plain';
375 375
 				$file_location = '';
376 376
 				$filename = '';
377 377
 
378
-				if($note->object_name == 'Note') {
379
-					if (! empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
378
+				if ($note->object_name == 'Note') {
379
+					if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
380 380
 						$file_location = $note->file->temp_file_location;
381 381
 						$filename = $note->file->original_file_name;
382 382
 						$mime_type = $note->file->mime_type;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 						$filename = $note->id.$note->filename;
386 386
 						$mime_type = $note->file_mime_type;
387 387
 					}
388
-				} elseif($note->object_name == 'DocumentRevision') { // from Documents
388
+				} elseif ($note->object_name == 'DocumentRevision') { // from Documents
389 389
 					$filename = $note->id.$note->filename;
390 390
 					$file_location = "upload://$filename";
391 391
 					$mime_type = $note->file_mime_type;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 		$connection = parent::SmtpConnect();
412 412
 		if (!$connection) {
413 413
 			global $app_strings;
414
-			if(isset($this->oe) && $this->oe->type == "system") {
414
+			if (isset($this->oe) && $this->oe->type == "system") {
415 415
 				$this->SetError($app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND']);
416 416
 			} else {
417 417
 				$this->SetError($app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND']);
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
      */
426 426
     public function PreSend() {
427 427
         //check to see if message body is empty
428
-        if(empty($this->Body)){
428
+        if (empty($this->Body)) {
429 429
             //PHPMailer will throw an error if the body is empty, so insert a blank space if body is empty
430 430
             $this->Body = " ";
431 431
         }
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -97,8 +99,7 @@  discard block
 block discarded – undo
97 99
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
98 100
 		if(isset($GLOBALS['log'])) {
99 101
 			$GLOBALS['log']->deprecated($deprecatedMessage);
100
-		}
101
-		else {
102
+		} else {
102 103
 			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
103 104
 		}
104 105
 		self::__construct();
@@ -135,9 +136,9 @@  discard block
 block discarded – undo
135 136
     			$this->Username = $oe->mail_smtpuser;
136 137
     			$this->Password = $oe->mail_smtppass;
137 138
     		}
139
+		} else {
140
+					$this->Mailer = "sendmail";
138 141
 		}
139
-		else
140
-			$this->Mailer = "sendmail";
141 142
 	}
142 143
 
143 144
 	/**
@@ -168,9 +169,9 @@  discard block
 block discarded – undo
168 169
     			$this->Username = $oe->mail_smtpuser;
169 170
     			$this->Password = $oe->mail_smtppass;
170 171
     		}
172
+		} else {
173
+				  $this->Mailer = "sendmail";
171 174
 		}
172
-		else
173
-		  $this->Mailer = "sendmail";
174 175
 	}
175 176
 
176 177
     /**
@@ -314,7 +315,9 @@  discard block
 block discarded – undo
314 315
 			$filename = urldecode($match);
315 316
 			$cid = $filename;
316 317
 			$file_location = $local_prefix.$filename;
317
-			if(!file_exists($file_location)) continue;
318
+			if(!file_exists($file_location)) {
319
+			    continue;
320
+			}
318 321
 			if($object) {
319 322
 			    if(preg_match('#&(?:amp;)?type=([\w]+)#i', $matches[0][$i], $typematch)) {
320 323
 			        switch(strtolower($typematch[1])) {
Please login to merge, or discard this patch.
include/SugarObjects/templates/basic/Basic.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@
 block discarded – undo
51 51
     /**
52 52
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
53 53
      */
54
-    public function Basic(){
54
+    public function Basic() {
55 55
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
56
-        if(isset($GLOBALS['log'])) {
56
+        if (isset($GLOBALS['log'])) {
57 57
             $GLOBALS['log']->deprecated($deprecatedMessage);
58 58
         }
59 59
         else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
include/SubPanel/SubPanel.php 3 patches
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -45,420 +45,420 @@
 block discarded – undo
45 45
  */
46 46
 class SubPanel
47 47
 {
48
-	var $hideNewButton = false;
49
-	var $subpanel_id;
50
-	var $parent_record_id;
51
-	var $parent_module;  // the name of the parent module
52
-	var $parent_bean;  // the instantiated bean of the parent
53
-	var $template_file;
54
-	var $linked_fields;
55
-	var $action = 'DetailView';
56
-	var $show_select_button = true;
57
-	var $subpanel_define = null;  // contains the layout_def.php
58
-	var $subpanel_defs;
59
-	var $subpanel_query=null;
48
+    var $hideNewButton = false;
49
+    var $subpanel_id;
50
+    var $parent_record_id;
51
+    var $parent_module;  // the name of the parent module
52
+    var $parent_bean;  // the instantiated bean of the parent
53
+    var $template_file;
54
+    var $linked_fields;
55
+    var $action = 'DetailView';
56
+    var $show_select_button = true;
57
+    var $subpanel_define = null;  // contains the layout_def.php
58
+    var $subpanel_defs;
59
+    var $subpanel_query=null;
60 60
     var $layout_def_key='';
61
-	var $search_query='';
62
-	var $collections = array();
63
-
64
-	function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() )
65
-	{
66
-		global $beanList, $beanFiles, $focus, $app_strings;
67
-
68
-		$this->subpanel_defs=$subpanelDef;
69
-		$this->subpanel_id = $subpanel_id;
70
-		$this->parent_record_id = $record_id;
71
-		$this->parent_module = $module;
72
-		$this->layout_def_key = $layout_def_key;
73
-		$this->collections = $collections;
74
-
75
-		$this->parent_bean = $focus;
76
-		$result = $focus;
77
-
78
-		if(empty($result))
79
-		{
80
-			$parent_bean_name = $beanList[$module];
81
-			$parent_bean_file = $beanFiles[$parent_bean_name];
82
-			require_once($parent_bean_file);
83
-			$this->parent_bean = new $parent_bean_name();
84
-			$this->parent_bean->retrieve($this->parent_record_id);
85
-			$result = $this->parent_bean;
86
-		}
87
-
88
-		if($record_id!='fab4' && $result == null)
89
-		{
90
-			sugar_die($app_strings['ERROR_NO_RECORD']);
91
-		}
92
-		$this->buildSearchQuery();
93
-		if (empty($subpanelDef)) {
94
-			//load the subpanel by name.
95
-			if (!class_exists('MyClass')) {
96
-				require_once 'include/SubPanel/SubPanelDefinitions.php' ;
97
-			}
98
-			$panelsdef=new SubPanelDefinitions($result,$layout_def_key);
99
-			$subpanelDef=$panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query,$collections);
100
-			$this->subpanel_defs=$subpanelDef;
101
-
102
-		}
103
-	}
104
-
105
-	/**
106
-	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
107
-	 */
108
-	function SubPanel($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() ){
109
-		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
110
-		if(isset($GLOBALS['log'])) {
111
-			$GLOBALS['log']->deprecated($deprecatedMessage);
112
-		}
113
-		else {
114
-			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
115
-		}
116
-		self::__construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key, $collections);
117
-	}
118
-
119
-	function setTemplateFile($template_file)
120
-	{
121
-		$this->template_file = $template_file;
122
-	}
123
-
124
-	function setBeanList(&$value){
125
-		$this->bean_list =$value;
126
-	}
127
-
128
-	function setHideNewButton($value){
129
-		$this->hideNewButton = $value;
130
-	}
131
-
132
-
133
-	function getHeaderText( $currentModule){
134
-	}
135
-
136
-	function get_buttons( $panel_query=null)
137
-	{
138
-
139
-		$thisPanel =& $this->subpanel_defs;
140
-		$subpanel_def = $thisPanel->get_buttons();
141
-
142
-		if(!isset($this->listview)){
143
-			$this->listview = new ListView();
144
-		}
145
-		$layout_manager = $this->listview->getLayoutManager();
146
-		$widget_contents = '<div><table cellpadding="0" cellspacing="0"><tr>';
147
-		foreach($subpanel_def as $widget_data)
148
-		{
149
-			$widget_data['action'] = $_REQUEST['action'];
150
-			$widget_data['module'] =  $thisPanel->get_inst_prop_value('module');
151
-			$widget_data['focus'] = $this->parent_bean;
152
-			$widget_data['subpanel_definition'] = $thisPanel;
153
-			$widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">' . "\n";
154
-
155
-			if(empty($widget_data['widget_class']))
156
-			{
157
-				$widget_contents .= "widget_class not defined for top subpanel buttons";
158
-			}
159
-			else
160
-			{
161
-				$widget_contents .= $layout_manager->widgetDisplay($widget_data);
162
-			}
163
-
164
-			$widget_contents .= '</td>';
165
-		}
166
-
167
-		$widget_contents .= '</tr></table></div>';
168
-		return $widget_contents;
169
-	}
170
-
171
-
172
-	function ProcessSubPanelListView($xTemplatePath, &$mod_strings)
173
-	{
174
-		global $app_strings;
175
-		global $current_user;
176
-		global $sugar_config;
177
-
178
-		if(isset($this->listview)){
179
-			$ListView =& $this->listview;
180
-		}else{
181
-			$ListView = new ListView();
182
-		}
183
-		$ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings);
184
-		$ListView->xTemplateAssign("RETURN_URL", "&return_module=".$this->parent_module."&return_action=DetailView&return_id=".$this->parent_bean->id);
185
-		$ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module);  // TODO: what about unions?
186
-		$ListView->xTemplateAssign("RECORD_ID", $this->parent_bean->id);
187
-		$ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle"  border="0"',null,null,'.gif',$app_strings['LNK_EDIT']));
188
-		$ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_DELETE_INLINE']));
189
-		$ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_ID_FF_REMOVE']));
190
-		$header_text= '';
191
-
192
-		$ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id);
193
-		$ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm());
194
-		$display_sps = '';
195
-		if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none';
196
-		$ListView->xTemplateAssign("DISPLAY_SPS",$display_sps);
197
-
198
-		if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace']))
199
-		{
200
-			$exploded = explode('/', $xTemplatePath);
201
-			$file_name = $exploded[sizeof($exploded) - 1];
202
-			$mod_name =  $exploded[sizeof($exploded) - 2];
203
-			$header_text= "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang="
204
-				.$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif','Edit Layout')."</a>";
205
-		}
206
-		$ListView->setHeaderTitle('');
207
-		$ListView->setHeaderText('');
208
-
209
-		ob_start();
210
-
211
-		$ListView->is_dynamic = true;
212
-		$ListView->records_per_page = $sugar_config['list_max_entries_per_subpanel'] + 0;
213
-		if (isset($this->subpanel_defs->_instance_properties['records_per_page'])) {
214
-			$ListView->records_per_page = $this->subpanel_defs->_instance_properties['records_per_page'] + 0;
215
-		}
216
-		$ListView->start_link_wrapper = "javascript:showSubPanel('".$this->subpanel_id."','";
217
-		$ListView->subpanel_id = $this->subpanel_id;
218
-		$ListView->end_link_wrapper = "',true);";
219
-		if ( !empty($this->layout_def_key) ) {
220
-			$ListView->end_link_wrapper = '&layout_def_key='.$this->layout_def_key.$ListView->end_link_wrapper;
221
-		}
222
-
223
-		$where = '';
224
-		$ListView->setQuery($where, '', '', '');
225
-		$ListView->show_export_button = false;
226
-
227
-		//function returns the query that was used to populate sub-panel data.
228
-
229
-		$query=$ListView->process_dynamic_listview($this->parent_module, $this->parent_bean,$this->subpanel_defs);
230
-		$this->subpanel_query=$query;
231
-		$ob_contents = ob_get_contents();
232
-		ob_end_clean();
233
-		return $ob_contents;
234
-	}
235
-
236
-	function display()
237
-	{
238
-		$result_array = array();
239
-
240
-		$return_string = $this->ProcessSubPanelListView($this->template_file,$result_array);
241
-
242
-		print $return_string;
243
-	}
244
-
245
-	function getModulesWithSubpanels()
246
-	{
247
-		global $beanList;
248
-		$dir = dir('modules');
249
-		$modules = array();
250
-		while($entry = $dir->read())
251
-		{
252
-			if(file_exists('modules/' . $entry . '/layout_defs.php'))
253
-			{
254
-				$modules[$entry] = $entry;
255
-			}
256
-		}
257
-		return $modules;
258
-	}
259
-
260
-  static function getModuleSubpanels($module){
261
-  	require_once('include/SubPanel/SubPanelDefinitions.php');
262
-  		global $beanList, $beanFiles;
263
-  		if(!isset($beanList[$module])){
264
-  			return array();
265
-  		}
266
-
267
-  		$class = $beanList[$module];
268
-  		require_once($beanFiles[$class]);
269
-  		$mod = new $class();
270
-  		$spd = new SubPanelDefinitions($mod);
271
-  		$tabs = $spd->get_available_tabs(true);
272
-  		$ret_tabs = array();
273
-  		$reject_tabs = array('history'=>1, 'activities'=>1);
274
-  		foreach($tabs as $key=>$tab){
275
-  		    foreach($tab as $k=>$v){
61
+    var $search_query='';
62
+    var $collections = array();
63
+
64
+    function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() )
65
+    {
66
+        global $beanList, $beanFiles, $focus, $app_strings;
67
+
68
+        $this->subpanel_defs=$subpanelDef;
69
+        $this->subpanel_id = $subpanel_id;
70
+        $this->parent_record_id = $record_id;
71
+        $this->parent_module = $module;
72
+        $this->layout_def_key = $layout_def_key;
73
+        $this->collections = $collections;
74
+
75
+        $this->parent_bean = $focus;
76
+        $result = $focus;
77
+
78
+        if(empty($result))
79
+        {
80
+            $parent_bean_name = $beanList[$module];
81
+            $parent_bean_file = $beanFiles[$parent_bean_name];
82
+            require_once($parent_bean_file);
83
+            $this->parent_bean = new $parent_bean_name();
84
+            $this->parent_bean->retrieve($this->parent_record_id);
85
+            $result = $this->parent_bean;
86
+        }
87
+
88
+        if($record_id!='fab4' && $result == null)
89
+        {
90
+            sugar_die($app_strings['ERROR_NO_RECORD']);
91
+        }
92
+        $this->buildSearchQuery();
93
+        if (empty($subpanelDef)) {
94
+            //load the subpanel by name.
95
+            if (!class_exists('MyClass')) {
96
+                require_once 'include/SubPanel/SubPanelDefinitions.php' ;
97
+            }
98
+            $panelsdef=new SubPanelDefinitions($result,$layout_def_key);
99
+            $subpanelDef=$panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query,$collections);
100
+            $this->subpanel_defs=$subpanelDef;
101
+
102
+        }
103
+    }
104
+
105
+    /**
106
+     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
107
+     */
108
+    function SubPanel($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() ){
109
+        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
110
+        if(isset($GLOBALS['log'])) {
111
+            $GLOBALS['log']->deprecated($deprecatedMessage);
112
+        }
113
+        else {
114
+            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
115
+        }
116
+        self::__construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key, $collections);
117
+    }
118
+
119
+    function setTemplateFile($template_file)
120
+    {
121
+        $this->template_file = $template_file;
122
+    }
123
+
124
+    function setBeanList(&$value){
125
+        $this->bean_list =$value;
126
+    }
127
+
128
+    function setHideNewButton($value){
129
+        $this->hideNewButton = $value;
130
+    }
131
+
132
+
133
+    function getHeaderText( $currentModule){
134
+    }
135
+
136
+    function get_buttons( $panel_query=null)
137
+    {
138
+
139
+        $thisPanel =& $this->subpanel_defs;
140
+        $subpanel_def = $thisPanel->get_buttons();
141
+
142
+        if(!isset($this->listview)){
143
+            $this->listview = new ListView();
144
+        }
145
+        $layout_manager = $this->listview->getLayoutManager();
146
+        $widget_contents = '<div><table cellpadding="0" cellspacing="0"><tr>';
147
+        foreach($subpanel_def as $widget_data)
148
+        {
149
+            $widget_data['action'] = $_REQUEST['action'];
150
+            $widget_data['module'] =  $thisPanel->get_inst_prop_value('module');
151
+            $widget_data['focus'] = $this->parent_bean;
152
+            $widget_data['subpanel_definition'] = $thisPanel;
153
+            $widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">' . "\n";
154
+
155
+            if(empty($widget_data['widget_class']))
156
+            {
157
+                $widget_contents .= "widget_class not defined for top subpanel buttons";
158
+            }
159
+            else
160
+            {
161
+                $widget_contents .= $layout_manager->widgetDisplay($widget_data);
162
+            }
163
+
164
+            $widget_contents .= '</td>';
165
+        }
166
+
167
+        $widget_contents .= '</tr></table></div>';
168
+        return $widget_contents;
169
+    }
170
+
171
+
172
+    function ProcessSubPanelListView($xTemplatePath, &$mod_strings)
173
+    {
174
+        global $app_strings;
175
+        global $current_user;
176
+        global $sugar_config;
177
+
178
+        if(isset($this->listview)){
179
+            $ListView =& $this->listview;
180
+        }else{
181
+            $ListView = new ListView();
182
+        }
183
+        $ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings);
184
+        $ListView->xTemplateAssign("RETURN_URL", "&return_module=".$this->parent_module."&return_action=DetailView&return_id=".$this->parent_bean->id);
185
+        $ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module);  // TODO: what about unions?
186
+        $ListView->xTemplateAssign("RECORD_ID", $this->parent_bean->id);
187
+        $ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle"  border="0"',null,null,'.gif',$app_strings['LNK_EDIT']));
188
+        $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_DELETE_INLINE']));
189
+        $ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_ID_FF_REMOVE']));
190
+        $header_text= '';
191
+
192
+        $ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id);
193
+        $ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm());
194
+        $display_sps = '';
195
+        if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none';
196
+        $ListView->xTemplateAssign("DISPLAY_SPS",$display_sps);
197
+
198
+        if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace']))
199
+        {
200
+            $exploded = explode('/', $xTemplatePath);
201
+            $file_name = $exploded[sizeof($exploded) - 1];
202
+            $mod_name =  $exploded[sizeof($exploded) - 2];
203
+            $header_text= "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang="
204
+                .$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif','Edit Layout')."</a>";
205
+        }
206
+        $ListView->setHeaderTitle('');
207
+        $ListView->setHeaderText('');
208
+
209
+        ob_start();
210
+
211
+        $ListView->is_dynamic = true;
212
+        $ListView->records_per_page = $sugar_config['list_max_entries_per_subpanel'] + 0;
213
+        if (isset($this->subpanel_defs->_instance_properties['records_per_page'])) {
214
+            $ListView->records_per_page = $this->subpanel_defs->_instance_properties['records_per_page'] + 0;
215
+        }
216
+        $ListView->start_link_wrapper = "javascript:showSubPanel('".$this->subpanel_id."','";
217
+        $ListView->subpanel_id = $this->subpanel_id;
218
+        $ListView->end_link_wrapper = "',true);";
219
+        if ( !empty($this->layout_def_key) ) {
220
+            $ListView->end_link_wrapper = '&layout_def_key='.$this->layout_def_key.$ListView->end_link_wrapper;
221
+        }
222
+
223
+        $where = '';
224
+        $ListView->setQuery($where, '', '', '');
225
+        $ListView->show_export_button = false;
226
+
227
+        //function returns the query that was used to populate sub-panel data.
228
+
229
+        $query=$ListView->process_dynamic_listview($this->parent_module, $this->parent_bean,$this->subpanel_defs);
230
+        $this->subpanel_query=$query;
231
+        $ob_contents = ob_get_contents();
232
+        ob_end_clean();
233
+        return $ob_contents;
234
+    }
235
+
236
+    function display()
237
+    {
238
+        $result_array = array();
239
+
240
+        $return_string = $this->ProcessSubPanelListView($this->template_file,$result_array);
241
+
242
+        print $return_string;
243
+    }
244
+
245
+    function getModulesWithSubpanels()
246
+    {
247
+        global $beanList;
248
+        $dir = dir('modules');
249
+        $modules = array();
250
+        while($entry = $dir->read())
251
+        {
252
+            if(file_exists('modules/' . $entry . '/layout_defs.php'))
253
+            {
254
+                $modules[$entry] = $entry;
255
+            }
256
+        }
257
+        return $modules;
258
+    }
259
+
260
+    static function getModuleSubpanels($module){
261
+        require_once('include/SubPanel/SubPanelDefinitions.php');
262
+            global $beanList, $beanFiles;
263
+            if(!isset($beanList[$module])){
264
+                return array();
265
+            }
266
+
267
+            $class = $beanList[$module];
268
+            require_once($beanFiles[$class]);
269
+            $mod = new $class();
270
+            $spd = new SubPanelDefinitions($mod);
271
+            $tabs = $spd->get_available_tabs(true);
272
+            $ret_tabs = array();
273
+            $reject_tabs = array('history'=>1, 'activities'=>1);
274
+            foreach($tabs as $key=>$tab){
275
+                foreach($tab as $k=>$v){
276 276
                 if (! isset ( $reject_tabs [$k] )) {
277 277
                     $ret_tabs [$k] = $v;
278 278
                 }
279 279
             }
280
-  		}
280
+            }
281 281
 
282
-  		return $ret_tabs;
282
+            return $ret_tabs;
283 283
 
284 284
 
285
-  }
285
+    }
286 286
 
287
-  //saves overrides for defs
288
-  function saveSubPanelDefOverride( $panel, $subsection, $override){
289
-  		global $layout_defs, $beanList;
287
+    //saves overrides for defs
288
+    function saveSubPanelDefOverride( $panel, $subsection, $override){
289
+            global $layout_defs, $beanList;
290 290
 
291
-  		//save the new subpanel
292
-  		$name = "subpanel_layout['list_fields']";
291
+            //save the new subpanel
292
+            $name = "subpanel_layout['list_fields']";
293 293
 
294
-  		//bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels
295
-  		$path = 'custom/modules/'. $panel->_instance_properties['module'] . '/metadata/subpanels';
294
+            //bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels
295
+            $path = 'custom/modules/'. $panel->_instance_properties['module'] . '/metadata/subpanels';
296 296
 
297
-  		//bug# 40171: "Custom subpanels not working as expected"
298
-  		//each custom subpanel needs to have a unique custom def file
299
-  		$filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it)
300
-  		$oldName1 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name'] ;
301
-  		$oldName2 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['get_subpanel_data'] ;
302
-  		if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php")){
303
-  		  unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php");
304
-  		}
305
-  		if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php")){
306
-         unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php");
307
-  		}
308
-  		$extname = '_override'.$filename;
309
-  		//end of bug# 40171
297
+            //bug# 40171: "Custom subpanels not working as expected"
298
+            //each custom subpanel needs to have a unique custom def file
299
+            $filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it)
300
+            $oldName1 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name'] ;
301
+            $oldName2 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['get_subpanel_data'] ;
302
+            if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php")){
303
+            unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php");
304
+            }
305
+            if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php")){
306
+            unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php");
307
+            }
308
+            $extname = '_override'.$filename;
309
+            //end of bug# 40171
310 310
 
311
-  		mkdir_recursive($path, true);
312
-  		write_array_to_file( $name, $override,$path.'/' . $filename .'.php');
311
+            mkdir_recursive($path, true);
312
+            write_array_to_file( $name, $override,$path.'/' . $filename .'.php');
313 313
 
314
-  		//save the override for the layoutdef
314
+            //save the override for the layoutdef
315 315
         //tyoung 10.12.07 pushed panel->name to lowercase to match case in subpaneldefs.php files -
316 316
         //gave error on bad index 'module' as this override key didn't match the key in the subpaneldefs
317
-  		$name = "layout_defs['".  $panel->parent_bean->module_dir. "']['subpanel_setup']['" .strtolower($panel->name). "']";
317
+            $name = "layout_defs['".  $panel->parent_bean->module_dir. "']['subpanel_setup']['" .strtolower($panel->name). "']";
318 318
 //  	$GLOBALS['log']->debug('SubPanel.php->saveSubPanelDefOverride(): '.$name);
319
-  		$newValue = override_value_to_string($name, 'override_subpanel_name', $filename);
320
-  		mkdir_recursive('custom/Extension/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true);
321
-  		$fp = sugar_fopen('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$extname.php", 'w');
322
-  		fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n$newValue\n?>");
323
-  		fclose($fp);
324
-  		require_once('ModuleInstall/ModuleInstaller.php');
325
-  		$moduleInstaller = new ModuleInstaller();
326
-  		$moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs
327
-  		$moduleInstaller->rebuild_layoutdefs();
328
-  		if (file_exists('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php'))
329
-  			include('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php');
330
-  		if (file_exists('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'))
331
-  			include('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php');
332
-  }
333
-
334
-	function get_subpanel_setup($module)
335
-	{
336
-		$subpanel_setup = '';
337
-		$layout_defs = get_layout_defs();
338
-
339
-		if(!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup']))
340
-      {
341
-      	$subpanel_setup = $layout_defs[$module]['subpanel_setup'];
342
-      }
343
-
344
-      return $subpanel_setup;
345
-	}
346
-
347
-	/**
348
-	 * Retrieve the subpanel definition from the registered layout_defs arrays.
349
-	 */
350
-	function getSubPanelDefine($module, $subpanel_id)
351
-	{
352
-		$default_subpanel_define = SubPanel::_get_default_subpanel_define($module, $subpanel_id);
353
-		$custom_subpanel_define = SubPanel::_get_custom_subpanel_define($module, $subpanel_id);
354
-
355
-		$subpanel_define = array_merge($default_subpanel_define, $custom_subpanel_define);
356
-
357
-		if(empty($subpanel_define))
358
-		{
359
-			print('Could not load subpanel definition for: ' . $subpanel_id);
360
-		}
361
-
362
-		return $subpanel_define;
363
-	}
364
-
365
-	function _get_custom_subpanel_define($module, $subpanel_id)
366
-	{
367
-		$ret_val = array();
368
-
369
-		if($subpanel_id != '')
370
-		{
371
-			$layout_defs = get_layout_defs();
372
-
373
-			if(!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]))
374
-			{
375
-				$ret_val = $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id];
376
-			}
377
-		}
319
+            $newValue = override_value_to_string($name, 'override_subpanel_name', $filename);
320
+            mkdir_recursive('custom/Extension/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true);
321
+            $fp = sugar_fopen('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$extname.php", 'w');
322
+            fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n$newValue\n?>");
323
+            fclose($fp);
324
+            require_once('ModuleInstall/ModuleInstaller.php');
325
+            $moduleInstaller = new ModuleInstaller();
326
+            $moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs
327
+            $moduleInstaller->rebuild_layoutdefs();
328
+            if (file_exists('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php'))
329
+                include('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php');
330
+            if (file_exists('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'))
331
+                include('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php');
332
+    }
333
+
334
+    function get_subpanel_setup($module)
335
+    {
336
+        $subpanel_setup = '';
337
+        $layout_defs = get_layout_defs();
338
+
339
+        if(!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup']))
340
+        {
341
+            $subpanel_setup = $layout_defs[$module]['subpanel_setup'];
342
+        }
343
+
344
+        return $subpanel_setup;
345
+    }
346
+
347
+    /**
348
+     * Retrieve the subpanel definition from the registered layout_defs arrays.
349
+     */
350
+    function getSubPanelDefine($module, $subpanel_id)
351
+    {
352
+        $default_subpanel_define = SubPanel::_get_default_subpanel_define($module, $subpanel_id);
353
+        $custom_subpanel_define = SubPanel::_get_custom_subpanel_define($module, $subpanel_id);
354
+
355
+        $subpanel_define = array_merge($default_subpanel_define, $custom_subpanel_define);
356
+
357
+        if(empty($subpanel_define))
358
+        {
359
+            print('Could not load subpanel definition for: ' . $subpanel_id);
360
+        }
361
+
362
+        return $subpanel_define;
363
+    }
364
+
365
+    function _get_custom_subpanel_define($module, $subpanel_id)
366
+    {
367
+        $ret_val = array();
368
+
369
+        if($subpanel_id != '')
370
+        {
371
+            $layout_defs = get_layout_defs();
372
+
373
+            if(!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]))
374
+            {
375
+                $ret_val = $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id];
376
+            }
377
+        }
378 378
 
379
-		return $ret_val;
380
-	}
379
+        return $ret_val;
380
+    }
381 381
 
382
-	function _get_default_subpanel_define($module, $subpanel_id)
383
-	{
384
-		$ret_val = array();
382
+    function _get_default_subpanel_define($module, $subpanel_id)
383
+    {
384
+        $ret_val = array();
385 385
 
386
-		if($subpanel_id != '')
387
-		{
388
-	  		$layout_defs = get_layout_defs();
386
+        if($subpanel_id != '')
387
+        {
388
+                $layout_defs = get_layout_defs();
389 389
 
390
-			if(!empty($layout_defs[$subpanel_id]['default_subpanel_define']))
391
-			{
392
-				$ret_val = $layout_defs[$subpanel_id]['default_subpanel_define'];
393
-			}
394
-		}
390
+            if(!empty($layout_defs[$subpanel_id]['default_subpanel_define']))
391
+            {
392
+                $ret_val = $layout_defs[$subpanel_id]['default_subpanel_define'];
393
+            }
394
+        }
395 395
 
396
-		return $ret_val;
397
-	}
396
+        return $ret_val;
397
+    }
398 398
 
399
-	function buildSearchQuery()
400
-	{
401
-		require_once('include/SubPanel/SubPanelSearchForm.php');
399
+    function buildSearchQuery()
400
+    {
401
+        require_once('include/SubPanel/SubPanelSearchForm.php');
402 402
 
403
-		$module = 'Meetings';
403
+        $module = 'Meetings';
404 404
 
405
-		$seed = new Meeting();
405
+        $seed = new Meeting();
406 406
 
407
-		$_REQUEST['searchFormTab'] = 'basic_search';
408
-		$searchForm = new SubPanelSearchForm($seed, $module, $this);
407
+        $_REQUEST['searchFormTab'] = 'basic_search';
408
+        $searchForm = new SubPanelSearchForm($seed, $module, $this);
409 409
 
410
-		$searchMetaData = $searchForm->retrieveSearchDefs($module);
411
-		$searchForm->setup($searchMetaData['searchdefs'], $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search');
410
+        $searchMetaData = $searchForm->retrieveSearchDefs($module);
411
+        $searchForm->setup($searchMetaData['searchdefs'], $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search');
412 412
 
413
-		$searchForm->populateFromRequest();
413
+        $searchForm->populateFromRequest();
414 414
 
415
-		$where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir);
415
+        $where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir);
416 416
 
417
-		if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')';
418
-		$GLOBALS['log']->info("Subpanel Where Clause: $this->search_query");
417
+        if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')';
418
+        $GLOBALS['log']->info("Subpanel Where Clause: $this->search_query");
419 419
 
420
-		return print_r($where_clauses,true);
421
-	}
420
+        return print_r($where_clauses,true);
421
+    }
422 422
 
423
-	function get_searchdefs($module)
424
-	{
425
-		$thisPanel =& $this->subpanel_defs;
426
-		$subpanel_defs = $thisPanel->_instance_properties;
423
+    function get_searchdefs($module)
424
+    {
425
+        $thisPanel =& $this->subpanel_defs;
426
+        $subpanel_defs = $thisPanel->_instance_properties;
427 427
 
428
-		if(isset($subpanel_defs['searchdefs'])){
429
-			$searchdefs[$module]['layout']['basic_search'] = $subpanel_defs['searchdefs'];
430
-			$searchdefs[$module]['templateMeta'] = Array ('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array ( 'label' => 10, 'field' => 30 )) ;
431
-			return $searchdefs;
432
-		}
428
+        if(isset($subpanel_defs['searchdefs'])){
429
+            $searchdefs[$module]['layout']['basic_search'] = $subpanel_defs['searchdefs'];
430
+            $searchdefs[$module]['templateMeta'] = Array ('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array ( 'label' => 10, 'field' => 30 )) ;
431
+            return $searchdefs;
432
+        }
433 433
 
434
-		return false;
435
-	}
434
+        return false;
435
+    }
436 436
 
437
-	function getSearchForm()
438
-	{
439
-		require_once('include/SubPanel/SubPanelSearchForm.php');
437
+    function getSearchForm()
438
+    {
439
+        require_once('include/SubPanel/SubPanelSearchForm.php');
440 440
 
441
-		$module = 'Meetings';
441
+        $module = 'Meetings';
442 442
 
443
-		$seed = new Meeting();
443
+        $seed = new Meeting();
444 444
 
445
-		$searchForm = new SubPanelSearchForm($seed, $module, $this);
445
+        $searchForm = new SubPanelSearchForm($seed, $module, $this);
446 446
 
447
-		$searchMetaData = $searchForm->retrieveSearchDefs($module);
447
+        $searchMetaData = $searchForm->retrieveSearchDefs($module);
448 448
 
449
-		if ($subpanel_searchMetaData = $this->get_searchdefs($module)){
449
+        if ($subpanel_searchMetaData = $this->get_searchdefs($module)){
450 450
 
451
-			$searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search');
451
+            $searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search');
452 452
 
453
-			if(!empty($this->collections))
454
-				$searchForm->searchFields['collection'] = array();
453
+            if(!empty($this->collections))
454
+                $searchForm->searchFields['collection'] = array();
455 455
 
456
-			$searchForm->populateFromRequest();
456
+            $searchForm->populateFromRequest();
457 457
 
458
-			return $searchForm->display();
459
-		}
458
+            return $searchForm->display();
459
+        }
460 460
 
461
-		return '';
462
-	}
461
+        return '';
462
+    }
463 463
 }
464 464
 ?>
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 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.
@@ -48,24 +48,24 @@  discard block
 block discarded – undo
48 48
 	var $hideNewButton = false;
49 49
 	var $subpanel_id;
50 50
 	var $parent_record_id;
51
-	var $parent_module;  // the name of the parent module
52
-	var $parent_bean;  // the instantiated bean of the parent
51
+	var $parent_module; // the name of the parent module
52
+	var $parent_bean; // the instantiated bean of the parent
53 53
 	var $template_file;
54 54
 	var $linked_fields;
55 55
 	var $action = 'DetailView';
56 56
 	var $show_select_button = true;
57
-	var $subpanel_define = null;  // contains the layout_def.php
57
+	var $subpanel_define = null; // contains the layout_def.php
58 58
 	var $subpanel_defs;
59
-	var $subpanel_query=null;
60
-    var $layout_def_key='';
61
-	var $search_query='';
59
+	var $subpanel_query = null;
60
+    var $layout_def_key = '';
61
+	var $search_query = '';
62 62
 	var $collections = array();
63 63
 
64
-	function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() )
64
+	function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key = '', $collections = array())
65 65
 	{
66 66
 		global $beanList, $beanFiles, $focus, $app_strings;
67 67
 
68
-		$this->subpanel_defs=$subpanelDef;
68
+		$this->subpanel_defs = $subpanelDef;
69 69
 		$this->subpanel_id = $subpanel_id;
70 70
 		$this->parent_record_id = $record_id;
71 71
 		$this->parent_module = $module;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		$this->parent_bean = $focus;
76 76
 		$result = $focus;
77 77
 
78
-		if(empty($result))
78
+		if (empty($result))
79 79
 		{
80 80
 			$parent_bean_name = $beanList[$module];
81 81
 			$parent_bean_file = $beanFiles[$parent_bean_name];
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			$result = $this->parent_bean;
86 86
 		}
87 87
 
88
-		if($record_id!='fab4' && $result == null)
88
+		if ($record_id != 'fab4' && $result == null)
89 89
 		{
90 90
 			sugar_die($app_strings['ERROR_NO_RECORD']);
91 91
 		}
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 		if (empty($subpanelDef)) {
94 94
 			//load the subpanel by name.
95 95
 			if (!class_exists('MyClass')) {
96
-				require_once 'include/SubPanel/SubPanelDefinitions.php' ;
96
+				require_once 'include/SubPanel/SubPanelDefinitions.php';
97 97
 			}
98
-			$panelsdef=new SubPanelDefinitions($result,$layout_def_key);
99
-			$subpanelDef=$panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query,$collections);
100
-			$this->subpanel_defs=$subpanelDef;
98
+			$panelsdef = new SubPanelDefinitions($result, $layout_def_key);
99
+			$subpanelDef = $panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query, $collections);
100
+			$this->subpanel_defs = $subpanelDef;
101 101
 
102 102
 		}
103 103
 	}
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
107 107
 	 */
108
-	function SubPanel($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() ){
108
+	function SubPanel($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key = '', $collections = array()) {
109 109
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
110
-		if(isset($GLOBALS['log'])) {
110
+		if (isset($GLOBALS['log'])) {
111 111
 			$GLOBALS['log']->deprecated($deprecatedMessage);
112 112
 		}
113 113
 		else {
@@ -121,38 +121,38 @@  discard block
 block discarded – undo
121 121
 		$this->template_file = $template_file;
122 122
 	}
123 123
 
124
-	function setBeanList(&$value){
125
-		$this->bean_list =$value;
124
+	function setBeanList(&$value) {
125
+		$this->bean_list = $value;
126 126
 	}
127 127
 
128
-	function setHideNewButton($value){
128
+	function setHideNewButton($value) {
129 129
 		$this->hideNewButton = $value;
130 130
 	}
131 131
 
132 132
 
133
-	function getHeaderText( $currentModule){
133
+	function getHeaderText($currentModule) {
134 134
 	}
135 135
 
136
-	function get_buttons( $panel_query=null)
136
+	function get_buttons($panel_query = null)
137 137
 	{
138 138
 
139
-		$thisPanel =& $this->subpanel_defs;
139
+		$thisPanel = & $this->subpanel_defs;
140 140
 		$subpanel_def = $thisPanel->get_buttons();
141 141
 
142
-		if(!isset($this->listview)){
142
+		if (!isset($this->listview)) {
143 143
 			$this->listview = new ListView();
144 144
 		}
145 145
 		$layout_manager = $this->listview->getLayoutManager();
146 146
 		$widget_contents = '<div><table cellpadding="0" cellspacing="0"><tr>';
147
-		foreach($subpanel_def as $widget_data)
147
+		foreach ($subpanel_def as $widget_data)
148 148
 		{
149 149
 			$widget_data['action'] = $_REQUEST['action'];
150
-			$widget_data['module'] =  $thisPanel->get_inst_prop_value('module');
150
+			$widget_data['module'] = $thisPanel->get_inst_prop_value('module');
151 151
 			$widget_data['focus'] = $this->parent_bean;
152 152
 			$widget_data['subpanel_definition'] = $thisPanel;
153
-			$widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">' . "\n";
153
+			$widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">'."\n";
154 154
 
155
-			if(empty($widget_data['widget_class']))
155
+			if (empty($widget_data['widget_class']))
156 156
 			{
157 157
 				$widget_contents .= "widget_class not defined for top subpanel buttons";
158 158
 			}
@@ -175,33 +175,33 @@  discard block
 block discarded – undo
175 175
 		global $current_user;
176 176
 		global $sugar_config;
177 177
 
178
-		if(isset($this->listview)){
179
-			$ListView =& $this->listview;
180
-		}else{
178
+		if (isset($this->listview)) {
179
+			$ListView = & $this->listview;
180
+		} else {
181 181
 			$ListView = new ListView();
182 182
 		}
183
-		$ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings);
183
+		$ListView->initNewXTemplate($xTemplatePath, $this->subpanel_defs->mod_strings);
184 184
 		$ListView->xTemplateAssign("RETURN_URL", "&return_module=".$this->parent_module."&return_action=DetailView&return_id=".$this->parent_bean->id);
185
-		$ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module);  // TODO: what about unions?
185
+		$ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module); // TODO: what about unions?
186 186
 		$ListView->xTemplateAssign("RECORD_ID", $this->parent_bean->id);
187
-		$ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle"  border="0"',null,null,'.gif',$app_strings['LNK_EDIT']));
188
-		$ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_DELETE_INLINE']));
189
-		$ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_ID_FF_REMOVE']));
190
-		$header_text= '';
187
+		$ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline', 'align="absmiddle"  border="0"', null, null, '.gif', $app_strings['LNK_EDIT']));
188
+		$ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LBL_DELETE_INLINE']));
189
+		$ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LBL_ID_FF_REMOVE']));
190
+		$header_text = '';
191 191
 
192 192
 		$ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id);
193 193
 		$ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm());
194 194
 		$display_sps = '';
195
-		if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none';
196
-		$ListView->xTemplateAssign("DISPLAY_SPS",$display_sps);
195
+		if ($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none';
196
+		$ListView->xTemplateAssign("DISPLAY_SPS", $display_sps);
197 197
 
198
-		if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace']))
198
+		if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace']))
199 199
 		{
200 200
 			$exploded = explode('/', $xTemplatePath);
201 201
 			$file_name = $exploded[sizeof($exploded) - 1];
202
-			$mod_name =  $exploded[sizeof($exploded) - 2];
203
-			$header_text= "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang="
204
-				.$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif','Edit Layout')."</a>";
202
+			$mod_name = $exploded[sizeof($exploded) - 2];
203
+			$header_text = "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang="
204
+				.$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', 'Edit Layout')."</a>";
205 205
 		}
206 206
 		$ListView->setHeaderTitle('');
207 207
 		$ListView->setHeaderText('');
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		$ListView->start_link_wrapper = "javascript:showSubPanel('".$this->subpanel_id."','";
217 217
 		$ListView->subpanel_id = $this->subpanel_id;
218 218
 		$ListView->end_link_wrapper = "',true);";
219
-		if ( !empty($this->layout_def_key) ) {
219
+		if (!empty($this->layout_def_key)) {
220 220
 			$ListView->end_link_wrapper = '&layout_def_key='.$this->layout_def_key.$ListView->end_link_wrapper;
221 221
 		}
222 222
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 
227 227
 		//function returns the query that was used to populate sub-panel data.
228 228
 
229
-		$query=$ListView->process_dynamic_listview($this->parent_module, $this->parent_bean,$this->subpanel_defs);
230
-		$this->subpanel_query=$query;
229
+		$query = $ListView->process_dynamic_listview($this->parent_module, $this->parent_bean, $this->subpanel_defs);
230
+		$this->subpanel_query = $query;
231 231
 		$ob_contents = ob_get_contents();
232 232
 		ob_end_clean();
233 233
 		return $ob_contents;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	{
238 238
 		$result_array = array();
239 239
 
240
-		$return_string = $this->ProcessSubPanelListView($this->template_file,$result_array);
240
+		$return_string = $this->ProcessSubPanelListView($this->template_file, $result_array);
241 241
 
242 242
 		print $return_string;
243 243
 	}
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 		global $beanList;
248 248
 		$dir = dir('modules');
249 249
 		$modules = array();
250
-		while($entry = $dir->read())
250
+		while ($entry = $dir->read())
251 251
 		{
252
-			if(file_exists('modules/' . $entry . '/layout_defs.php'))
252
+			if (file_exists('modules/'.$entry.'/layout_defs.php'))
253 253
 			{
254 254
 				$modules[$entry] = $entry;
255 255
 			}
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 		return $modules;
258 258
 	}
259 259
 
260
-  static function getModuleSubpanels($module){
260
+  static function getModuleSubpanels($module) {
261 261
   	require_once('include/SubPanel/SubPanelDefinitions.php');
262 262
   		global $beanList, $beanFiles;
263
-  		if(!isset($beanList[$module])){
263
+  		if (!isset($beanList[$module])) {
264 264
   			return array();
265 265
   		}
266 266
 
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
   		$tabs = $spd->get_available_tabs(true);
272 272
   		$ret_tabs = array();
273 273
   		$reject_tabs = array('history'=>1, 'activities'=>1);
274
-  		foreach($tabs as $key=>$tab){
275
-  		    foreach($tab as $k=>$v){
276
-                if (! isset ( $reject_tabs [$k] )) {
274
+  		foreach ($tabs as $key=>$tab) {
275
+  		    foreach ($tab as $k=>$v) {
276
+                if (!isset ($reject_tabs [$k])) {
277 277
                     $ret_tabs [$k] = $v;
278 278
                 }
279 279
             }
@@ -285,50 +285,50 @@  discard block
 block discarded – undo
285 285
   }
286 286
 
287 287
   //saves overrides for defs
288
-  function saveSubPanelDefOverride( $panel, $subsection, $override){
288
+  function saveSubPanelDefOverride($panel, $subsection, $override) {
289 289
   		global $layout_defs, $beanList;
290 290
 
291 291
   		//save the new subpanel
292 292
   		$name = "subpanel_layout['list_fields']";
293 293
 
294 294
   		//bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels
295
-  		$path = 'custom/modules/'. $panel->_instance_properties['module'] . '/metadata/subpanels';
295
+  		$path = 'custom/modules/'.$panel->_instance_properties['module'].'/metadata/subpanels';
296 296
 
297 297
   		//bug# 40171: "Custom subpanels not working as expected"
298 298
   		//each custom subpanel needs to have a unique custom def file
299
-  		$filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it)
300
-  		$oldName1 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name'] ;
301
-  		$oldName2 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['get_subpanel_data'] ;
302
-  		if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php")){
303
-  		  unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php");
299
+  		$filename = $panel->parent_bean->object_name."_subpanel_".$panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it)
300
+  		$oldName1 = '_override'.$panel->parent_bean->object_name.$panel->_instance_properties['module'].$panel->_instance_properties['subpanel_name'];
301
+  		$oldName2 = '_override'.$panel->parent_bean->object_name.$panel->_instance_properties['get_subpanel_data'];
302
+  		if (file_exists('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName1.php")) {
303
+  		  unlink('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName1.php");
304 304
   		}
305
-  		if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php")){
306
-         unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php");
305
+  		if (file_exists('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName2.php")) {
306
+         unlink('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName2.php");
307 307
   		}
308 308
   		$extname = '_override'.$filename;
309 309
   		//end of bug# 40171
310 310
 
311 311
   		mkdir_recursive($path, true);
312
-  		write_array_to_file( $name, $override,$path.'/' . $filename .'.php');
312
+  		write_array_to_file($name, $override, $path.'/'.$filename.'.php');
313 313
 
314 314
   		//save the override for the layoutdef
315 315
         //tyoung 10.12.07 pushed panel->name to lowercase to match case in subpaneldefs.php files -
316 316
         //gave error on bad index 'module' as this override key didn't match the key in the subpaneldefs
317
-  		$name = "layout_defs['".  $panel->parent_bean->module_dir. "']['subpanel_setup']['" .strtolower($panel->name). "']";
317
+  		$name = "layout_defs['".$panel->parent_bean->module_dir."']['subpanel_setup']['".strtolower($panel->name)."']";
318 318
 //  	$GLOBALS['log']->debug('SubPanel.php->saveSubPanelDefOverride(): '.$name);
319 319
   		$newValue = override_value_to_string($name, 'override_subpanel_name', $filename);
320
-  		mkdir_recursive('custom/Extension/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true);
321
-  		$fp = sugar_fopen('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$extname.php", 'w');
320
+  		mkdir_recursive('custom/Extension/modules/'.$panel->parent_bean->module_dir.'/Ext/Layoutdefs', true);
321
+  		$fp = sugar_fopen('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$extname.php", 'w');
322 322
   		fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n$newValue\n?>");
323 323
   		fclose($fp);
324 324
   		require_once('ModuleInstall/ModuleInstaller.php');
325 325
   		$moduleInstaller = new ModuleInstaller();
326 326
   		$moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs
327 327
   		$moduleInstaller->rebuild_layoutdefs();
328
-  		if (file_exists('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php'))
329
-  			include('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php');
330
-  		if (file_exists('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'))
331
-  			include('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php');
328
+  		if (file_exists('modules/'.$panel->parent_bean->module_dir.'/layout_defs.php'))
329
+  			include('modules/'.$panel->parent_bean->module_dir.'/layout_defs.php');
330
+  		if (file_exists('custom/modules/'.$panel->parent_bean->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'))
331
+  			include('custom/modules/'.$panel->parent_bean->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php');
332 332
   }
333 333
 
334 334
 	function get_subpanel_setup($module)
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		$subpanel_setup = '';
337 337
 		$layout_defs = get_layout_defs();
338 338
 
339
-		if(!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup']))
339
+		if (!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup']))
340 340
       {
341 341
       	$subpanel_setup = $layout_defs[$module]['subpanel_setup'];
342 342
       }
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 
355 355
 		$subpanel_define = array_merge($default_subpanel_define, $custom_subpanel_define);
356 356
 
357
-		if(empty($subpanel_define))
357
+		if (empty($subpanel_define))
358 358
 		{
359
-			print('Could not load subpanel definition for: ' . $subpanel_id);
359
+			print('Could not load subpanel definition for: '.$subpanel_id);
360 360
 		}
361 361
 
362 362
 		return $subpanel_define;
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 	{
367 367
 		$ret_val = array();
368 368
 
369
-		if($subpanel_id != '')
369
+		if ($subpanel_id != '')
370 370
 		{
371 371
 			$layout_defs = get_layout_defs();
372 372
 
373
-			if(!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]))
373
+			if (!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]))
374 374
 			{
375 375
 				$ret_val = $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id];
376 376
 			}
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	{
384 384
 		$ret_val = array();
385 385
 
386
-		if($subpanel_id != '')
386
+		if ($subpanel_id != '')
387 387
 		{
388 388
 	  		$layout_defs = get_layout_defs();
389 389
 
390
-			if(!empty($layout_defs[$subpanel_id]['default_subpanel_define']))
390
+			if (!empty($layout_defs[$subpanel_id]['default_subpanel_define']))
391 391
 			{
392 392
 				$ret_val = $layout_defs[$subpanel_id]['default_subpanel_define'];
393 393
 			}
@@ -414,20 +414,20 @@  discard block
 block discarded – undo
414 414
 
415 415
 		$where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir);
416 416
 
417
-		if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')';
417
+		if (count($where_clauses) > 0)$this->search_query = '('.implode(' ) AND ( ', $where_clauses).')';
418 418
 		$GLOBALS['log']->info("Subpanel Where Clause: $this->search_query");
419 419
 
420
-		return print_r($where_clauses,true);
420
+		return print_r($where_clauses, true);
421 421
 	}
422 422
 
423 423
 	function get_searchdefs($module)
424 424
 	{
425
-		$thisPanel =& $this->subpanel_defs;
425
+		$thisPanel = & $this->subpanel_defs;
426 426
 		$subpanel_defs = $thisPanel->_instance_properties;
427 427
 
428
-		if(isset($subpanel_defs['searchdefs'])){
428
+		if (isset($subpanel_defs['searchdefs'])) {
429 429
 			$searchdefs[$module]['layout']['basic_search'] = $subpanel_defs['searchdefs'];
430
-			$searchdefs[$module]['templateMeta'] = Array ('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array ( 'label' => 10, 'field' => 30 )) ;
430
+			$searchdefs[$module]['templateMeta'] = Array('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array('label' => 10, 'field' => 30));
431 431
 			return $searchdefs;
432 432
 		}
433 433
 
@@ -446,11 +446,11 @@  discard block
 block discarded – undo
446 446
 
447 447
 		$searchMetaData = $searchForm->retrieveSearchDefs($module);
448 448
 
449
-		if ($subpanel_searchMetaData = $this->get_searchdefs($module)){
449
+		if ($subpanel_searchMetaData = $this->get_searchdefs($module)) {
450 450
 
451 451
 			$searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search');
452 452
 
453
-			if(!empty($this->collections))
453
+			if (!empty($this->collections))
454 454
 				$searchForm->searchFields['collection'] = array();
455 455
 
456 456
 			$searchForm->populateFromRequest();
Please login to merge, or discard this patch.
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -109,8 +111,7 @@  discard block
 block discarded – undo
109 111
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
110 112
 		if(isset($GLOBALS['log'])) {
111 113
 			$GLOBALS['log']->deprecated($deprecatedMessage);
112
-		}
113
-		else {
114
+		} else {
114 115
 			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
115 116
 		}
116 117
 		self::__construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key, $collections);
@@ -155,8 +156,7 @@  discard block
 block discarded – undo
155 156
 			if(empty($widget_data['widget_class']))
156 157
 			{
157 158
 				$widget_contents .= "widget_class not defined for top subpanel buttons";
158
-			}
159
-			else
159
+			} else
160 160
 			{
161 161
 				$widget_contents .= $layout_manager->widgetDisplay($widget_data);
162 162
 			}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
 		if(isset($this->listview)){
179 179
 			$ListView =& $this->listview;
180
-		}else{
180
+		} else{
181 181
 			$ListView = new ListView();
182 182
 		}
183 183
 		$ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings);
@@ -192,7 +192,9 @@  discard block
 block discarded – undo
192 192
 		$ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id);
193 193
 		$ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm());
194 194
 		$display_sps = '';
195
-		if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none';
195
+		if($this->search_query == '' && empty($this->collections)) {
196
+		    $display_sps = 'display:none';
197
+		}
196 198
 		$ListView->xTemplateAssign("DISPLAY_SPS",$display_sps);
197 199
 
198 200
 		if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace']))
@@ -325,10 +327,12 @@  discard block
 block discarded – undo
325 327
   		$moduleInstaller = new ModuleInstaller();
326 328
   		$moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs
327 329
   		$moduleInstaller->rebuild_layoutdefs();
328
-  		if (file_exists('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php'))
329
-  			include('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php');
330
-  		if (file_exists('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'))
331
-  			include('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php');
330
+  		if (file_exists('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php')) {
331
+  		  			include('modules/'.  $panel->parent_bean->module_dir . '/layout_defs.php');
332
+  		}
333
+  		if (file_exists('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) {
334
+  		  			include('custom/modules/'.  $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php');
335
+  		}
332 336
   }
333 337
 
334 338
 	function get_subpanel_setup($module)
@@ -414,7 +418,9 @@  discard block
 block discarded – undo
414 418
 
415 419
 		$where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir);
416 420
 
417
-		if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')';
421
+		if (count($where_clauses) > 0 ) {
422
+		    $this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')';
423
+		}
418 424
 		$GLOBALS['log']->info("Subpanel Where Clause: $this->search_query");
419 425
 
420 426
 		return print_r($where_clauses,true);
@@ -450,8 +456,9 @@  discard block
 block discarded – undo
450 456
 
451 457
 			$searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search');
452 458
 
453
-			if(!empty($this->collections))
454
-				$searchForm->searchFields['collection'] = array();
459
+			if(!empty($this->collections)) {
460
+							$searchForm->searchFields['collection'] = array();
461
+			}
455 462
 
456 463
 			$searchForm->populateFromRequest();
457 464
 
Please login to merge, or discard this patch.
include/SubPanel/SubPanelDefinitions.php 3 patches
Indentation   +722 added lines, -722 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 class aSubPanel
55 55
 {
56 56
 
57
-	var $name ;
58
-	var $_instance_properties ;
57
+    var $name ;
58
+    var $_instance_properties ;
59 59
 
60
-	var $mod_strings ;
61
-	var $panel_definition ;
62
-	var $sub_subpanels ;
63
-	var $parent_bean ;
60
+    var $mod_strings ;
61
+    var $panel_definition ;
62
+    var $sub_subpanels ;
63
+    var $parent_bean ;
64 64
 
65 65
     /**
66 66
      * Can we display this subpanel?
@@ -72,80 +72,80 @@  discard block
 block discarded – undo
72 72
      */
73 73
     var $canDisplay = true;
74 74
 
75
-	//module's table name and column fields.
76
-	var $table_name ;
77
-	var $db_fields ;
78
-	var $bean_name ;
79
-	var $template_instance ;
80
-
81
-	var $search_query;
82
-	var $base_collection_list = array();
83
-
84
-	function __construct ($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){
85
-
86
-		$this->_instance_properties = $instance_properties ;
87
-
88
-		if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ];
89
-
90
-		if(!empty($collections) && isset($instance_properties['collection_list' ])){
91
-			foreach($instance_properties['collection_list' ] as $cname => $value){
92
-				if(!in_array($value['module'], $collections)){
93
-					unset($instance_properties['collection_list'][$cname]);
94
-				}
95
-			}
96
-		}
97
-		if (!$this->isCollection()){
98
-			$table = strtolower($instance_properties['module']);
99
-			$search_query = str_replace('meetings',$table,$search_query);
100
-		}
101
-
102
-		$this->search_query = $search_query;
103
-		$this->name = $name ;
104
-		$this->parent_bean = $parent_bean ;
105
-
106
-		//set language
107
-		global $current_language ;
108
-		if (! isset ( $parent_bean->mbvardefs ))
109
-		{
110
-			$mod_strings = return_module_language ( $current_language, $parent_bean->module_dir ) ;
111
-		}
112
-		$this->mod_strings = $mod_strings ;
75
+    //module's table name and column fields.
76
+    var $table_name ;
77
+    var $db_fields ;
78
+    var $bean_name ;
79
+    var $template_instance ;
80
+
81
+    var $search_query;
82
+    var $base_collection_list = array();
83
+
84
+    function __construct ($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){
85
+
86
+        $this->_instance_properties = $instance_properties ;
87
+
88
+        if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ];
89
+
90
+        if(!empty($collections) && isset($instance_properties['collection_list' ])){
91
+            foreach($instance_properties['collection_list' ] as $cname => $value){
92
+                if(!in_array($value['module'], $collections)){
93
+                    unset($instance_properties['collection_list'][$cname]);
94
+                }
95
+            }
96
+        }
97
+        if (!$this->isCollection()){
98
+            $table = strtolower($instance_properties['module']);
99
+            $search_query = str_replace('meetings',$table,$search_query);
100
+        }
101
+
102
+        $this->search_query = $search_query;
103
+        $this->name = $name ;
104
+        $this->parent_bean = $parent_bean ;
105
+
106
+        //set language
107
+        global $current_language ;
108
+        if (! isset ( $parent_bean->mbvardefs ))
109
+        {
110
+            $mod_strings = return_module_language ( $current_language, $parent_bean->module_dir ) ;
111
+        }
112
+        $this->mod_strings = $mod_strings ;
113 113
 
114 114
         if ($this->isCollection ())
115
-		{
116
-			$this->canDisplay = $this->load_sub_subpanels () ; //load sub-panel definition.
117
-		} else
118
-		{
119
-			if (!is_dir('modules/' . $this->_instance_properties [ 'module' ])){
120
-				_pstack_trace();
121
-			}
122
-			$def_path = 'modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'subpanel_name' ] . '.php' ;
123
-
124
-			$orig_exists = is_file($def_path);
125
-			$loaded = false;
126
-			if ($orig_exists)
127
-			{
128
-				require ($def_path);
129
-				$loaded = true;
130
-			}
131
-			if (is_file("custom/$def_path") && (!$original_only  || !$orig_exists))
132
-			{
133
-				require ("custom/$def_path");
134
-				$loaded = true;
135
-			}
136
-
137
-			if (! $original_only && isset ( $this->_instance_properties [ 'override_subpanel_name' ] ) && file_exists ( 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ))
138
-			{
139
-				$cust_def_path = 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ;
140
-				require ($cust_def_path) ;
141
-				$loaded = true;
142
-			}
143
-
144
-			if (!$loaded)
145
-			{
146
-				$GLOBALS['log']->fatal("Failed to load original or custom subpanel data for $name in $def_path");
115
+        {
116
+            $this->canDisplay = $this->load_sub_subpanels () ; //load sub-panel definition.
117
+        } else
118
+        {
119
+            if (!is_dir('modules/' . $this->_instance_properties [ 'module' ])){
120
+                _pstack_trace();
121
+            }
122
+            $def_path = 'modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'subpanel_name' ] . '.php' ;
123
+
124
+            $orig_exists = is_file($def_path);
125
+            $loaded = false;
126
+            if ($orig_exists)
127
+            {
128
+                require ($def_path);
129
+                $loaded = true;
130
+            }
131
+            if (is_file("custom/$def_path") && (!$original_only  || !$orig_exists))
132
+            {
133
+                require ("custom/$def_path");
134
+                $loaded = true;
135
+            }
136
+
137
+            if (! $original_only && isset ( $this->_instance_properties [ 'override_subpanel_name' ] ) && file_exists ( 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ))
138
+            {
139
+                $cust_def_path = 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ;
140
+                require ($cust_def_path) ;
141
+                $loaded = true;
142
+            }
143
+
144
+            if (!$loaded)
145
+            {
146
+                $GLOBALS['log']->fatal("Failed to load original or custom subpanel data for $name in $def_path");
147 147
                 $this->canDisplay = false;
148
-			}
148
+            }
149 149
 
150 150
             // load module info from the module's bean file
151 151
             $this->load_module_info();
@@ -156,24 +156,24 @@  discard block
 block discarded – undo
156 156
             if (isset($subpanel_layout) && is_array($subpanel_layout)) {
157 157
                 $this->set_panel_definition($subpanel_layout);
158 158
 
159
-			}
160
-		}
159
+            }
160
+        }
161 161
 
162
-	}
162
+    }
163 163
 
164
-	/**
165
-	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
166
-	 */
167
-	function aSubPanel($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){
168
-		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
169
-		if(isset($GLOBALS['log'])) {
170
-			$GLOBALS['log']->deprecated($deprecatedMessage);
171
-		}
172
-		else {
173
-			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
174
-		}
175
-		self::__construct($name, $instance_properties, $parent_bean, $reload, $original_only, $search_query, $collections);
176
-	}
164
+    /**
165
+     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
166
+     */
167
+    function aSubPanel($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){
168
+        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
169
+        if(isset($GLOBALS['log'])) {
170
+            $GLOBALS['log']->deprecated($deprecatedMessage);
171
+        }
172
+        else {
173
+            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
174
+        }
175
+        self::__construct($name, $instance_properties, $parent_bean, $reload, $original_only, $search_query, $collections);
176
+    }
177 177
 
178 178
     /**
179 179
      * is the sub panel default hidden?
@@ -190,64 +190,64 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 
193
-	function distinct_query ()
194
-	{
195
-		if (isset ( $this->_instance_properties [ 'get_distinct_data' ] ))
196
-		{
197
-			return !empty($this->_instance_properties['get_distinct_data']) ? true : false;
198
-		}
199
-		return false ;
200
-	}
201
-
202
-	//return the translated header value.
203
-	function get_title ()
204
-	{
205
-		if (empty ( $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ))
206
-		{
207
-			return translate ( $this->_instance_properties [ 'title_key' ], $this->_instance_properties [ 'module' ] ) ;
208
-		}
209
-		return $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ;
210
-	}
211
-
212
-	//return the definition of buttons. looks for buttons in 2 locations.
213
-	function get_buttons ()
214
-	{
215
-		$buttons = array ( ) ;
216
-		if (isset ( $this->_instance_properties [ 'top_buttons' ] ))
217
-		{
218
-			//this will happen only in the case of sub-panels with multiple sources(activities).
219
-			$buttons = $this->_instance_properties [ 'top_buttons' ] ;
220
-		} else
221
-		{
222
-			$buttons = $this->panel_definition [ 'top_buttons' ] ;
223
-		}
224
-
225
-		// permissions. hide SubPanelTopComposeEmailButton from activities if email module is disabled.
226
-		//only email is  being tested becuase other submodules in activites/history such as notes, tasks, meetings and calls cannot be disabled.
227
-		//as of today these are the only 2 sub-panels that use the union clause.
228
-		$mod_name = $this->get_module_name () ;
229
-		if ($mod_name == 'Activities' || $mod_name == 'History')
230
-		{
231
-			global $modListHeader ;
232
-			global $modules_exempt_from_availability_check ;
233
-			if (isset ( $modListHeader ) && (! (array_key_exists ( 'Emails', $modListHeader ) or array_key_exists ( 'Emails', $modules_exempt_from_availability_check ))))
234
-			{
235
-				foreach ( $buttons as $key => $button )
236
-				{
237
-					foreach ( $button as $property => $value )
238
-					{
239
-						if ($value === 'SubPanelTopComposeEmailButton' || $value === 'SubPanelTopArchiveEmailButton')
240
-						{
241
-							//remove this button from the array.
242
-							unset ( $buttons [ $key ] ) ;
243
-						}
244
-					}
245
-				}
246
-			}
247
-		}
248
-
249
-		return $buttons ;
250
-	}
193
+    function distinct_query ()
194
+    {
195
+        if (isset ( $this->_instance_properties [ 'get_distinct_data' ] ))
196
+        {
197
+            return !empty($this->_instance_properties['get_distinct_data']) ? true : false;
198
+        }
199
+        return false ;
200
+    }
201
+
202
+    //return the translated header value.
203
+    function get_title ()
204
+    {
205
+        if (empty ( $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ))
206
+        {
207
+            return translate ( $this->_instance_properties [ 'title_key' ], $this->_instance_properties [ 'module' ] ) ;
208
+        }
209
+        return $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ;
210
+    }
211
+
212
+    //return the definition of buttons. looks for buttons in 2 locations.
213
+    function get_buttons ()
214
+    {
215
+        $buttons = array ( ) ;
216
+        if (isset ( $this->_instance_properties [ 'top_buttons' ] ))
217
+        {
218
+            //this will happen only in the case of sub-panels with multiple sources(activities).
219
+            $buttons = $this->_instance_properties [ 'top_buttons' ] ;
220
+        } else
221
+        {
222
+            $buttons = $this->panel_definition [ 'top_buttons' ] ;
223
+        }
224
+
225
+        // permissions. hide SubPanelTopComposeEmailButton from activities if email module is disabled.
226
+        //only email is  being tested becuase other submodules in activites/history such as notes, tasks, meetings and calls cannot be disabled.
227
+        //as of today these are the only 2 sub-panels that use the union clause.
228
+        $mod_name = $this->get_module_name () ;
229
+        if ($mod_name == 'Activities' || $mod_name == 'History')
230
+        {
231
+            global $modListHeader ;
232
+            global $modules_exempt_from_availability_check ;
233
+            if (isset ( $modListHeader ) && (! (array_key_exists ( 'Emails', $modListHeader ) or array_key_exists ( 'Emails', $modules_exempt_from_availability_check ))))
234
+            {
235
+                foreach ( $buttons as $key => $button )
236
+                {
237
+                    foreach ( $button as $property => $value )
238
+                    {
239
+                        if ($value === 'SubPanelTopComposeEmailButton' || $value === 'SubPanelTopArchiveEmailButton')
240
+                        {
241
+                            //remove this button from the array.
242
+                            unset ( $buttons [ $key ] ) ;
243
+                        }
244
+                    }
245
+                }
246
+            }
247
+        }
248
+
249
+        return $buttons ;
250
+    }
251 251
 
252 252
 
253 253
     /**
@@ -258,327 +258,327 @@  discard block
 block discarded – undo
258 258
      * @return bool         True by default if the subpanel was loaded.  Will return false if none in the collection are
259 259
      *                      allowed by the current user.
260 260
      */
261
-	function load_sub_subpanels ()
262
-	{
263
-
264
-		global $modListHeader ;
265
-		// added a check for security of tabs to see if an user has access to them
266
-		// this prevents passing an "unseen" tab to the query string and pulling up its contents
267
-		if (! isset ( $modListHeader ))
268
-		{
269
-			global $current_user ;
270
-			if (isset ( $current_user ))
271
-			{
272
-				$modListHeader = query_module_access_list ( $current_user ) ;
273
-			}
274
-		}
275
-
276
-		//by default all the activities modules are exempt, so hiding them won't affect their appearance unless the 'activity' subpanel itself is hidden.
277
-		//add email to the list temporarily so it is not affected in activities subpanel
278
-		global $modules_exempt_from_availability_check ;
279
-		$modules_exempt_from_availability_check['Emails'] = 'Emails';
280
-
281
-		$listFieldMap = array();
282
-
283
-		if (empty ( $this->sub_subpanels ))
284
-		{
285
-			$panels = $this->get_inst_prop_value ( 'collection_list' ) ;
286
-			foreach ( $panels as $panel => $properties )
287
-			{
288
-				if (array_key_exists ( $properties [ 'module' ], $modListHeader ) or array_key_exists ( $properties [ 'module' ], $modules_exempt_from_availability_check ))
289
-				{
290
-					$this->sub_subpanels [ $panel ] = new aSubPanel ( $panel, $properties, $this->parent_bean, false, false, $this->search_query ) ;
291
-				}
292
-			}
293
-			// if it's empty just dump out as there is nothing to process.
294
-			if(empty($this->sub_subpanels)) return false;
295
-			//Sync displayed list fields across the subpanels
296
-			$display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels);
297
-			$query_fields = array();
298
-			foreach ( $this->sub_subpanels as $key => $subpanel )
299
-			{
300
-				$list_fields = $subpanel->get_list_fields();
301
-				$listFieldMap[$key] = array();
302
-				$index = 0;
303
-				foreach($list_fields as $field => $def)
304
-				{
305
-					if (isset($def['vname']) && isset($def['width']))
306
-					{
307
-						$index++;
308
-						if(!empty($def['alias']))
309
-							$listFieldMap[$key][$def['alias']] = $field;
310
-						else
311
-							$listFieldMap[$key][$field] = $field;
312
-						if (!isset($display_fields[$def['vname']]))
313
-						{
314
-							if(sizeof($display_fields) > $index)
315
-							{
316
-								//Try to insert the new field in an order that makes sense
317
-								$start = array_slice($display_fields, 0, $index);
318
-								$end = array_slice($display_fields, $index);
319
-								$display_fields = array_merge(
320
-									$start,
321
-									array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )),
322
-									$end
323
-								);
324
-							} else
325
-							{
326
-								$display_fields[$def['vname']] = array(
327
-									'name' => empty($def['alias']) ? $field : $def['alias'],
328
-									'vname' => $def['vname'],
329
-									'width' => $def['width'],
330
-								);
331
-							}
332
-						}
333
-					} else {
334
-						$query_fields[$field] = $def;
335
-					}
336
-				}
337
-			}
338
-			foreach ( $this->sub_subpanels as $key => $subpanel )
339
-			{
340
-				$list_fields = array();
341
-				foreach($display_fields as $vname => $def)
342
-				{
343
-					$field = $def['name'];
344
-					$list_key = isset($listFieldMap[$key][$field]) ? $listFieldMap[$key][$field] : $field;
345
-
346
-					if (isset($subpanel->panel_definition['list_fields'][$field]))
347
-					{
348
-						$list_fields[$field] = $subpanel->panel_definition['list_fields'][$field];
349
-					}
350
-					else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key]))
351
-					{
352
-						$list_fields[$list_key] = $subpanel->panel_definition['list_fields'][$list_key];
353
-
354
-					}
355
-					else {
356
-						$list_fields[$field] = $display_fields[$vname];
357
-					}
358
-				}
359
-				foreach($query_fields as $field => $def)
360
-				{
361
-					if (isset($subpanel->panel_definition['list_fields'][$field]))
362
-					{
363
-						$list_fields[$field] = $subpanel->panel_definition['list_fields'][$field];
364
-					}
365
-					else {
366
-						$list_fields[$field] = $def;
367
-					}
368
-				}
369
-				$subpanel->panel_definition['list_fields'] = $list_fields;
370
-			}
371
-		}
372
-
373
-		return true;
374
-	}
375
-
376
-	protected function getDisplayFieldsFromCollection($sub_subpanels)
377
-	{
378
-		$display_fields = array();
379
-		foreach ($sub_subpanels as $key => $subpanel )
380
-		{
381
-			$list_fields = $subpanel->get_list_fields();
382
-			$index = 0;
383
-			foreach($list_fields as $field => $def)
384
-			{
385
-				if (isset($def['vname']) && isset($def['width']))
386
-				{
387
-					$index++;
388
-					if (!isset($display_fields[$def['vname']]))
389
-					{
390
-						if(sizeof($display_fields) > $index)
391
-						{
392
-							//Try to insert the new field in an order that makes sense
393
-							$start = array_slice($display_fields, 0, $index);
394
-							$end = array_slice($display_fields, $index);
395
-							$display_fields = array_merge(
396
-								$start,
397
-								array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )),
398
-								$end
399
-							);
400
-						} else
401
-						{
402
-							$display_fields[$def['vname']] = array(
403
-								'name' => $field,
404
-								'vname' => $def['vname'],
405
-								'width' => $def['width'],
406
-							);
407
-						}
408
-					}
409
-				}
410
-			}
411
-		}
412
-	}
413
-
414
-	function isDatasourceFunction ()
415
-	{
416
-		if (strpos ( $this->get_inst_prop_value ( 'get_subpanel_data' ), 'function' ) === false)
417
-		{
418
-			return false ;
419
-		}
420
-		return true ;
421
-	}
261
+    function load_sub_subpanels ()
262
+    {
263
+
264
+        global $modListHeader ;
265
+        // added a check for security of tabs to see if an user has access to them
266
+        // this prevents passing an "unseen" tab to the query string and pulling up its contents
267
+        if (! isset ( $modListHeader ))
268
+        {
269
+            global $current_user ;
270
+            if (isset ( $current_user ))
271
+            {
272
+                $modListHeader = query_module_access_list ( $current_user ) ;
273
+            }
274
+        }
275
+
276
+        //by default all the activities modules are exempt, so hiding them won't affect their appearance unless the 'activity' subpanel itself is hidden.
277
+        //add email to the list temporarily so it is not affected in activities subpanel
278
+        global $modules_exempt_from_availability_check ;
279
+        $modules_exempt_from_availability_check['Emails'] = 'Emails';
280
+
281
+        $listFieldMap = array();
282
+
283
+        if (empty ( $this->sub_subpanels ))
284
+        {
285
+            $panels = $this->get_inst_prop_value ( 'collection_list' ) ;
286
+            foreach ( $panels as $panel => $properties )
287
+            {
288
+                if (array_key_exists ( $properties [ 'module' ], $modListHeader ) or array_key_exists ( $properties [ 'module' ], $modules_exempt_from_availability_check ))
289
+                {
290
+                    $this->sub_subpanels [ $panel ] = new aSubPanel ( $panel, $properties, $this->parent_bean, false, false, $this->search_query ) ;
291
+                }
292
+            }
293
+            // if it's empty just dump out as there is nothing to process.
294
+            if(empty($this->sub_subpanels)) return false;
295
+            //Sync displayed list fields across the subpanels
296
+            $display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels);
297
+            $query_fields = array();
298
+            foreach ( $this->sub_subpanels as $key => $subpanel )
299
+            {
300
+                $list_fields = $subpanel->get_list_fields();
301
+                $listFieldMap[$key] = array();
302
+                $index = 0;
303
+                foreach($list_fields as $field => $def)
304
+                {
305
+                    if (isset($def['vname']) && isset($def['width']))
306
+                    {
307
+                        $index++;
308
+                        if(!empty($def['alias']))
309
+                            $listFieldMap[$key][$def['alias']] = $field;
310
+                        else
311
+                            $listFieldMap[$key][$field] = $field;
312
+                        if (!isset($display_fields[$def['vname']]))
313
+                        {
314
+                            if(sizeof($display_fields) > $index)
315
+                            {
316
+                                //Try to insert the new field in an order that makes sense
317
+                                $start = array_slice($display_fields, 0, $index);
318
+                                $end = array_slice($display_fields, $index);
319
+                                $display_fields = array_merge(
320
+                                    $start,
321
+                                    array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )),
322
+                                    $end
323
+                                );
324
+                            } else
325
+                            {
326
+                                $display_fields[$def['vname']] = array(
327
+                                    'name' => empty($def['alias']) ? $field : $def['alias'],
328
+                                    'vname' => $def['vname'],
329
+                                    'width' => $def['width'],
330
+                                );
331
+                            }
332
+                        }
333
+                    } else {
334
+                        $query_fields[$field] = $def;
335
+                    }
336
+                }
337
+            }
338
+            foreach ( $this->sub_subpanels as $key => $subpanel )
339
+            {
340
+                $list_fields = array();
341
+                foreach($display_fields as $vname => $def)
342
+                {
343
+                    $field = $def['name'];
344
+                    $list_key = isset($listFieldMap[$key][$field]) ? $listFieldMap[$key][$field] : $field;
345
+
346
+                    if (isset($subpanel->panel_definition['list_fields'][$field]))
347
+                    {
348
+                        $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field];
349
+                    }
350
+                    else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key]))
351
+                    {
352
+                        $list_fields[$list_key] = $subpanel->panel_definition['list_fields'][$list_key];
353
+
354
+                    }
355
+                    else {
356
+                        $list_fields[$field] = $display_fields[$vname];
357
+                    }
358
+                }
359
+                foreach($query_fields as $field => $def)
360
+                {
361
+                    if (isset($subpanel->panel_definition['list_fields'][$field]))
362
+                    {
363
+                        $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field];
364
+                    }
365
+                    else {
366
+                        $list_fields[$field] = $def;
367
+                    }
368
+                }
369
+                $subpanel->panel_definition['list_fields'] = $list_fields;
370
+            }
371
+        }
372
+
373
+        return true;
374
+    }
375
+
376
+    protected function getDisplayFieldsFromCollection($sub_subpanels)
377
+    {
378
+        $display_fields = array();
379
+        foreach ($sub_subpanels as $key => $subpanel )
380
+        {
381
+            $list_fields = $subpanel->get_list_fields();
382
+            $index = 0;
383
+            foreach($list_fields as $field => $def)
384
+            {
385
+                if (isset($def['vname']) && isset($def['width']))
386
+                {
387
+                    $index++;
388
+                    if (!isset($display_fields[$def['vname']]))
389
+                    {
390
+                        if(sizeof($display_fields) > $index)
391
+                        {
392
+                            //Try to insert the new field in an order that makes sense
393
+                            $start = array_slice($display_fields, 0, $index);
394
+                            $end = array_slice($display_fields, $index);
395
+                            $display_fields = array_merge(
396
+                                $start,
397
+                                array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )),
398
+                                $end
399
+                            );
400
+                        } else
401
+                        {
402
+                            $display_fields[$def['vname']] = array(
403
+                                'name' => $field,
404
+                                'vname' => $def['vname'],
405
+                                'width' => $def['width'],
406
+                            );
407
+                        }
408
+                    }
409
+                }
410
+            }
411
+        }
412
+    }
413
+
414
+    function isDatasourceFunction ()
415
+    {
416
+        if (strpos ( $this->get_inst_prop_value ( 'get_subpanel_data' ), 'function' ) === false)
417
+        {
418
+            return false ;
419
+        }
420
+        return true ;
421
+    }
422 422
 
423 423
     /**
424 424
      * Test to see if the sub panels defs contain a collection
425 425
      *
426 426
      * @return bool
427 427
      */
428
-	function isCollection ()
429
-	{
430
-		return ($this->get_inst_prop_value ( 'type' ) == 'collection');
431
-	}
432
-
433
-	//get value of a property defined at the panel instance level.
434
-	function get_inst_prop_value ( $name )
435
-	{
436
-		return isset($this->_instance_properties[$name]) ? $this->_instance_properties [ $name ] : null;
437
-	}
438
-	//get value of a property defined at the panel definition level.
439
-	function get_def_prop_value ( $name )
440
-	{
441
-		if (isset ( $this->panel_definition [ $name ] ))
442
-		{
443
-			return $this->panel_definition [ $name ] ;
444
-		} else
445
-		{
446
-			return null ;
447
-		}
448
-	}
449
-
450
-	//if datasource is of the type function then return the function name
451
-	//else return the value as is.
452
-	function get_function_parameters ()
453
-	{
454
-		$parameters = array ( ) ;
455
-		if ($this->isDatasourceFunction ())
456
-		{
457
-			$parameters = $this->get_inst_prop_value ( 'function_parameters' ) ;
458
-		}
459
-		return $parameters ;
460
-	}
461
-
462
-	function get_data_source_name ( $check_set_subpanel_data = false )
463
-	{
464
-		$prop_value = null ;
465
-		if ($check_set_subpanel_data)
466
-		{
467
-			$prop_value = $this->get_inst_prop_value ( 'set_subpanel_data' ) ;
468
-		}
469
-		if (! empty ( $prop_value ))
470
-		{
471
-			return $prop_value ;
472
-		} else
473
-		{
474
-			//fall back to default behavior.
475
-		}
476
-		if ($this->isDatasourceFunction ())
477
-		{
478
-			return (substr_replace ( $this->get_inst_prop_value ( 'get_subpanel_data' ), '', 0, 9 )) ;
479
-		} else
480
-		{
481
-			return $this->get_inst_prop_value ( 'get_subpanel_data' ) ;
482
-		}
483
-	}
484
-
485
-	//returns the where clause for the query.
486
-	function get_where ()
487
-	{
488
-		if($this->get_def_prop_value ( 'where' ) != '' && $this->search_query != ''){
489
-			return $this->get_def_prop_value ( 'where' ).' AND '.$this->search_query;
490
-		} else if($this->search_query != ''){
491
-			return $this->search_query;
492
-		}
493
-		return $this->get_def_prop_value ( 'where' ) ;
494
-	}
495
-
496
-	function is_fill_in_additional_fields ()
497
-	{
498
-		// do both. inst_prop returns values from metadata/subpaneldefs.php and def_prop returns from subpanel/default.php
499
-		$temp = $this->get_inst_prop_value ( 'fill_in_additional_fields' ) || $this->get_def_prop_value ( 'fill_in_additional_fields' ) ;
500
-		return $temp ;
501
-	}
502
-
503
-	function get_list_fields ()
504
-	{
505
-		if (isset ( $this->panel_definition [ 'list_fields' ] ))
506
-		{
507
-			return $this->panel_definition [ 'list_fields' ] ;
508
-		} else
509
-		{
510
-			return array ( ) ;
511
-		}
512
-	}
513
-
514
-	function get_module_name ()
515
-	{
516
-		return $this->get_inst_prop_value ( 'module' ) ;
517
-	}
518
-
519
-	function get_name ()
520
-	{
521
-		return $this->name ;
522
-	}
523
-
524
-	//load subpanel module's table name and column fields.
525
-	function load_module_info ()
526
-	{
527
-		global $beanList ;
528
-		global $beanFiles ;
529
-
530
-		$module_name = $this->get_module_name () ;
531
-		if (! empty ( $module_name ))
532
-		{
533
-
534
-			$bean_name = $beanList [ $this->get_module_name () ] ;
535
-
536
-			$this->bean_name = $bean_name ;
537
-
538
-			include_once ($beanFiles [ $bean_name ]) ;
539
-			$this->template_instance = new $bean_name ( ) ;
540
-			$this->template_instance->force_load_details = true ;
541
-			$this->table_name = $this->template_instance->table_name ;
542
-			//$this->db_fields=$this->template_instance->column_fields;
543
-		}
544
-	}
545
-	//this function is to be used only with sub-panels that are based
546
-	//on collections.
547
-	function get_header_panel_def ()
548
-	{
549
-		if (! empty ( $this->sub_subpanels ))
550
-		{
551
-			if (! empty ( $this->_instance_properties [ 'header_definition_from_subpanel' ] ) && ! empty ( $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ))
552
-			{
553
-				return $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ;
554
-			} else
555
-			{
556
-				$display_fields = array();
557
-				//If we are not pulling from a specific subpanel, create a list of all list fields and use that.
558
-				foreach($this->sub_subpanels as $subpanel)
559
-				{
560
-					$list_fields = $subpanel->get_list_fields();
561
-					foreach($list_fields as $field => $def)
562
-					{
563
-
564
-					}
565
-				}
566
-
567
-				reset ( $this->sub_subpanels ) ;
568
-				return current ( $this->sub_subpanels ) ;
569
-			}
570
-		}
571
-		return null ;
572
-	}
573
-
574
-	/**
575
-	 * Returns an array of current properties of the class.
576
-	 * It will simply give the class name for instances of classes.
577
-	 */
578
-	function _to_array ()
579
-	{
580
-		return array ( '_instance_properties' => $this->_instance_properties , 'db_fields' => $this->db_fields , 'mod_strings' => $this->mod_strings , 'name' => $this->name , 'panel_definition' => $this->panel_definition , 'parent_bean' => get_class ( $this->parent_bean ) , 'sub_subpanels' => $this->sub_subpanels , 'table_name' => $this->table_name , 'template_instance' => get_class ( $this->template_instance ) ) ;
581
-	}
428
+    function isCollection ()
429
+    {
430
+        return ($this->get_inst_prop_value ( 'type' ) == 'collection');
431
+    }
432
+
433
+    //get value of a property defined at the panel instance level.
434
+    function get_inst_prop_value ( $name )
435
+    {
436
+        return isset($this->_instance_properties[$name]) ? $this->_instance_properties [ $name ] : null;
437
+    }
438
+    //get value of a property defined at the panel definition level.
439
+    function get_def_prop_value ( $name )
440
+    {
441
+        if (isset ( $this->panel_definition [ $name ] ))
442
+        {
443
+            return $this->panel_definition [ $name ] ;
444
+        } else
445
+        {
446
+            return null ;
447
+        }
448
+    }
449
+
450
+    //if datasource is of the type function then return the function name
451
+    //else return the value as is.
452
+    function get_function_parameters ()
453
+    {
454
+        $parameters = array ( ) ;
455
+        if ($this->isDatasourceFunction ())
456
+        {
457
+            $parameters = $this->get_inst_prop_value ( 'function_parameters' ) ;
458
+        }
459
+        return $parameters ;
460
+    }
461
+
462
+    function get_data_source_name ( $check_set_subpanel_data = false )
463
+    {
464
+        $prop_value = null ;
465
+        if ($check_set_subpanel_data)
466
+        {
467
+            $prop_value = $this->get_inst_prop_value ( 'set_subpanel_data' ) ;
468
+        }
469
+        if (! empty ( $prop_value ))
470
+        {
471
+            return $prop_value ;
472
+        } else
473
+        {
474
+            //fall back to default behavior.
475
+        }
476
+        if ($this->isDatasourceFunction ())
477
+        {
478
+            return (substr_replace ( $this->get_inst_prop_value ( 'get_subpanel_data' ), '', 0, 9 )) ;
479
+        } else
480
+        {
481
+            return $this->get_inst_prop_value ( 'get_subpanel_data' ) ;
482
+        }
483
+    }
484
+
485
+    //returns the where clause for the query.
486
+    function get_where ()
487
+    {
488
+        if($this->get_def_prop_value ( 'where' ) != '' && $this->search_query != ''){
489
+            return $this->get_def_prop_value ( 'where' ).' AND '.$this->search_query;
490
+        } else if($this->search_query != ''){
491
+            return $this->search_query;
492
+        }
493
+        return $this->get_def_prop_value ( 'where' ) ;
494
+    }
495
+
496
+    function is_fill_in_additional_fields ()
497
+    {
498
+        // do both. inst_prop returns values from metadata/subpaneldefs.php and def_prop returns from subpanel/default.php
499
+        $temp = $this->get_inst_prop_value ( 'fill_in_additional_fields' ) || $this->get_def_prop_value ( 'fill_in_additional_fields' ) ;
500
+        return $temp ;
501
+    }
502
+
503
+    function get_list_fields ()
504
+    {
505
+        if (isset ( $this->panel_definition [ 'list_fields' ] ))
506
+        {
507
+            return $this->panel_definition [ 'list_fields' ] ;
508
+        } else
509
+        {
510
+            return array ( ) ;
511
+        }
512
+    }
513
+
514
+    function get_module_name ()
515
+    {
516
+        return $this->get_inst_prop_value ( 'module' ) ;
517
+    }
518
+
519
+    function get_name ()
520
+    {
521
+        return $this->name ;
522
+    }
523
+
524
+    //load subpanel module's table name and column fields.
525
+    function load_module_info ()
526
+    {
527
+        global $beanList ;
528
+        global $beanFiles ;
529
+
530
+        $module_name = $this->get_module_name () ;
531
+        if (! empty ( $module_name ))
532
+        {
533
+
534
+            $bean_name = $beanList [ $this->get_module_name () ] ;
535
+
536
+            $this->bean_name = $bean_name ;
537
+
538
+            include_once ($beanFiles [ $bean_name ]) ;
539
+            $this->template_instance = new $bean_name ( ) ;
540
+            $this->template_instance->force_load_details = true ;
541
+            $this->table_name = $this->template_instance->table_name ;
542
+            //$this->db_fields=$this->template_instance->column_fields;
543
+        }
544
+    }
545
+    //this function is to be used only with sub-panels that are based
546
+    //on collections.
547
+    function get_header_panel_def ()
548
+    {
549
+        if (! empty ( $this->sub_subpanels ))
550
+        {
551
+            if (! empty ( $this->_instance_properties [ 'header_definition_from_subpanel' ] ) && ! empty ( $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ))
552
+            {
553
+                return $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ;
554
+            } else
555
+            {
556
+                $display_fields = array();
557
+                //If we are not pulling from a specific subpanel, create a list of all list fields and use that.
558
+                foreach($this->sub_subpanels as $subpanel)
559
+                {
560
+                    $list_fields = $subpanel->get_list_fields();
561
+                    foreach($list_fields as $field => $def)
562
+                    {
563
+
564
+                    }
565
+                }
566
+
567
+                reset ( $this->sub_subpanels ) ;
568
+                return current ( $this->sub_subpanels ) ;
569
+            }
570
+        }
571
+        return null ;
572
+    }
573
+
574
+    /**
575
+     * Returns an array of current properties of the class.
576
+     * It will simply give the class name for instances of classes.
577
+     */
578
+    function _to_array ()
579
+    {
580
+        return array ( '_instance_properties' => $this->_instance_properties , 'db_fields' => $this->db_fields , 'mod_strings' => $this->mod_strings , 'name' => $this->name , 'panel_definition' => $this->panel_definition , 'parent_bean' => get_class ( $this->parent_bean ) , 'sub_subpanels' => $this->sub_subpanels , 'table_name' => $this->table_name , 'template_instance' => get_class ( $this->template_instance ) ) ;
581
+    }
582 582
 
583 583
     /**
584 584
      * Sets definition of the subpanel
@@ -596,301 +596,301 @@  discard block
 block discarded – undo
596 596
 class SubPanelDefinitions
597 597
 {
598 598
 
599
-	var $_focus ;
600
-	var $_visible_tabs_array ;
601
-	var $panels ;
602
-	var $layout_defs ;
603
-
604
-	/**
605
-	 * Enter description here...
606
-	 *
607
-	 * @param BEAN $focus - this is the bean you want to get the data from
608
-	 * @param STRING $layout_def_key - if you wish to use a layout_def defined in the default metadata/subpaneldefs.php that is not keyed off of $bean->module_dir pass in the key here
609
-	 * @param ARRAY $layout_def_override - if you wish to override the default loaded layout defs you pass them in here.
610
-	 * @return SubPanelDefinitions
611
-	 */
612
-	function __construct ( $focus , $layout_def_key = '' , $layout_def_override = '' )
613
-	{
614
-		$this->_focus = $focus ;
615
-		if (! empty ( $layout_def_override ))
616
-		{
617
-			$this->layout_defs = $layout_def_override ;
618
-
619
-		} else
620
-		{
621
-			$this->open_layout_defs ( false, $layout_def_key ) ;
622
-		}
623
-	}
624
-
625
-	/**
626
-	 * This function returns an ordered list of all "tabs", actually subpanels, for this module
627
-	 * The source list is obtained from the subpanel layout contained in the layout_defs for this module,
628
-	 * found either in the modules metadata/subpaneldefs.php file, or in the modules custom/.../Ext/Layoutdefs/layoutdefs.ext.php file
629
-	 * and filtered through an ACL check.
630
-	 * Note that the keys for the resulting array of tabs are in practice the name of the underlying source relationship for the subpanel
631
-	 * So for example, the key for a custom module's subpanel with Accounts might be 'one_one_accounts', as generated by the Studio Relationship Editor
632
-	 * Although OOB module subpanels have keys such as 'accounts', which might on the face of it appear to be a reference to the related module, in fact 'accounts' is still the relationship name
633
-	 * @param boolean 	Optional - include the subpanel title label in the return array (false)
634
-	 * @return array	All tabs that pass an ACL check
635
-	 */
636
-	function get_available_tabs ($FromGetModuleSubpanels=false)
637
-	{
638
-		global $modListHeader ;
639
-		global $modules_exempt_from_availability_check ;
640
-
641
-		if (isset ( $this->_visible_tabs_array ))
642
-			return $this->_visible_tabs_array ;
643
-
644
-		if (empty($modListHeader))
645
-		    $modListHeader = query_module_access_list($GLOBALS['current_user']);
646
-
647
-		$this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort
648
-
649
-		if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first
650
-		{
651
-			//retrieve list of hidden subpanels
652
-			$hidden_panels = $this->get_hidden_subpanels();
653
-
654
-			//activities is a special use case in that if it is hidden,
655
-			//then the history tab should be hidden too.
656
-			if(!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities',$hidden_panels)){
657
-				//add history to list hidden_panels
658
-				$hidden_panels['history'] = 'history';
659
-			}
660
-
661
-			foreach ( $this->layout_defs [ 'subpanel_setup' ] as $key => $values_array )
662
-			{
663
-				//exclude if this subpanel is hidden from admin screens
599
+    var $_focus ;
600
+    var $_visible_tabs_array ;
601
+    var $panels ;
602
+    var $layout_defs ;
603
+
604
+    /**
605
+     * Enter description here...
606
+     *
607
+     * @param BEAN $focus - this is the bean you want to get the data from
608
+     * @param STRING $layout_def_key - if you wish to use a layout_def defined in the default metadata/subpaneldefs.php that is not keyed off of $bean->module_dir pass in the key here
609
+     * @param ARRAY $layout_def_override - if you wish to override the default loaded layout defs you pass them in here.
610
+     * @return SubPanelDefinitions
611
+     */
612
+    function __construct ( $focus , $layout_def_key = '' , $layout_def_override = '' )
613
+    {
614
+        $this->_focus = $focus ;
615
+        if (! empty ( $layout_def_override ))
616
+        {
617
+            $this->layout_defs = $layout_def_override ;
618
+
619
+        } else
620
+        {
621
+            $this->open_layout_defs ( false, $layout_def_key ) ;
622
+        }
623
+    }
624
+
625
+    /**
626
+     * This function returns an ordered list of all "tabs", actually subpanels, for this module
627
+     * The source list is obtained from the subpanel layout contained in the layout_defs for this module,
628
+     * found either in the modules metadata/subpaneldefs.php file, or in the modules custom/.../Ext/Layoutdefs/layoutdefs.ext.php file
629
+     * and filtered through an ACL check.
630
+     * Note that the keys for the resulting array of tabs are in practice the name of the underlying source relationship for the subpanel
631
+     * So for example, the key for a custom module's subpanel with Accounts might be 'one_one_accounts', as generated by the Studio Relationship Editor
632
+     * Although OOB module subpanels have keys such as 'accounts', which might on the face of it appear to be a reference to the related module, in fact 'accounts' is still the relationship name
633
+     * @param boolean 	Optional - include the subpanel title label in the return array (false)
634
+     * @return array	All tabs that pass an ACL check
635
+     */
636
+    function get_available_tabs ($FromGetModuleSubpanels=false)
637
+    {
638
+        global $modListHeader ;
639
+        global $modules_exempt_from_availability_check ;
640
+
641
+        if (isset ( $this->_visible_tabs_array ))
642
+            return $this->_visible_tabs_array ;
643
+
644
+        if (empty($modListHeader))
645
+            $modListHeader = query_module_access_list($GLOBALS['current_user']);
646
+
647
+        $this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort
648
+
649
+        if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first
650
+        {
651
+            //retrieve list of hidden subpanels
652
+            $hidden_panels = $this->get_hidden_subpanels();
653
+
654
+            //activities is a special use case in that if it is hidden,
655
+            //then the history tab should be hidden too.
656
+            if(!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities',$hidden_panels)){
657
+                //add history to list hidden_panels
658
+                $hidden_panels['history'] = 'history';
659
+            }
660
+
661
+            foreach ( $this->layout_defs [ 'subpanel_setup' ] as $key => $values_array )
662
+            {
663
+                //exclude if this subpanel is hidden from admin screens
664 664
                 $module = $key;
665 665
                 if ( isset($values_array['module']) )
666 666
                     $module = strtolower($values_array['module']);
667
-				 if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){
668
-				 	//this panel is hidden, skip it
669
-				 	continue;
670
-				 }
671
-
672
-				// make sure the module attribute is set, else none of this works...
673
-				if ( !isset($values_array [ 'module' ])) {
674
-					$GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>" . var_export($values_array,true) . " - ingoring subpanel defintion") ;
675
-					continue;
676
-				}
677
-
678
-				//check permissions.
679
-				$exempt = array_key_exists ( $values_array [ 'module' ], $modules_exempt_from_availability_check ) ;
680
-				$ok = $exempt || ( (! ACLController::moduleSupportsACL ( $values_array [ 'module' ] ) || ACLController::checkAccess ( $values_array [ 'module' ], 'list', true ) ) ) ;
681
-
682
-				$GLOBALS [ 'log' ]->debug ( "SubPanelDefinitions->get_available_tabs(): " . $key . "= " . ( $exempt ? "exempt " : "not exempt " .( $ok ? " ACL OK" : "" ) ) ) ;
683
-
684
-				if ( $ok )
685
-				{
686
-					while ( ! empty ( $this->_visible_tabs_array [ $values_array [ 'order' ] ] ) )
687
-					{
688
-						$values_array [ 'order' ] ++ ;
689
-					}
690
-
691
-					$this->_visible_tabs_array [ $values_array ['order'] ] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key ;
692
-				}
693
-			}
694
-		}
695
-
696
-		ksort ( $this->_visible_tabs_array ) ;
697
-		return $this->_visible_tabs_array ;
698
-	}
699
-
700
-	/**
701
-	 * Load the definition of the a sub-panel.
702
-	 * Also the sub-panel is added to an array of sub-panels.
703
-	 * use of reload has been deprecated, since the subpanel is initialized every time.
667
+                    if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){
668
+                        //this panel is hidden, skip it
669
+                        continue;
670
+                    }
671
+
672
+                // make sure the module attribute is set, else none of this works...
673
+                if ( !isset($values_array [ 'module' ])) {
674
+                    $GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>" . var_export($values_array,true) . " - ingoring subpanel defintion") ;
675
+                    continue;
676
+                }
677
+
678
+                //check permissions.
679
+                $exempt = array_key_exists ( $values_array [ 'module' ], $modules_exempt_from_availability_check ) ;
680
+                $ok = $exempt || ( (! ACLController::moduleSupportsACL ( $values_array [ 'module' ] ) || ACLController::checkAccess ( $values_array [ 'module' ], 'list', true ) ) ) ;
681
+
682
+                $GLOBALS [ 'log' ]->debug ( "SubPanelDefinitions->get_available_tabs(): " . $key . "= " . ( $exempt ? "exempt " : "not exempt " .( $ok ? " ACL OK" : "" ) ) ) ;
683
+
684
+                if ( $ok )
685
+                {
686
+                    while ( ! empty ( $this->_visible_tabs_array [ $values_array [ 'order' ] ] ) )
687
+                    {
688
+                        $values_array [ 'order' ] ++ ;
689
+                    }
690
+
691
+                    $this->_visible_tabs_array [ $values_array ['order'] ] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key ;
692
+                }
693
+            }
694
+        }
695
+
696
+        ksort ( $this->_visible_tabs_array ) ;
697
+        return $this->_visible_tabs_array ;
698
+    }
699
+
700
+    /**
701
+     * Load the definition of the a sub-panel.
702
+     * Also the sub-panel is added to an array of sub-panels.
703
+     * use of reload has been deprecated, since the subpanel is initialized every time.
704 704
      *
705 705
      * @param string $name              The name of the sub-panel to reload
706 706
      * @param boolean $reload           Reload the sub-panel (unused)
707 707
      * @param boolean $original_only    Only load the original sub-panel and no custom ones
708 708
      * @return boolean|aSubPanel        Returns aSubPanel object or boolean false if one is not found or it can't be
709 709
      *      displayed due to ACL reasons.
710
-	 */
711
-	function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() )
712
-	{
713
-		if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ]))
714
-			return false;
710
+     */
711
+    function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() )
712
+    {
713
+        if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ]))
714
+            return false;
715 715
 
716
-		$subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ;
716
+        $subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ;
717 717
 
718
-		// only return the subpanel object if we can display it.
719
-		if($subpanel->canDisplay == true) {
720
-			return $subpanel;
721
-		}
718
+        // only return the subpanel object if we can display it.
719
+        if($subpanel->canDisplay == true) {
720
+            return $subpanel;
721
+        }
722 722
 
723
-		// by default return false so we don't show anything if it's not required.
724
-		return false;
725
-	}
723
+        // by default return false so we don't show anything if it's not required.
724
+        return false;
725
+    }
726 726
 
727
-	/**
728
-	 * Load the layout def file and associate the definition with a variable in the file.
729
-	 */
730
-	function open_layout_defs ( $reload = false , $layout_def_key = '' , $original_only = false )
731
-	{
732
-		$layout_defs [ $this->_focus->module_dir ] = array ( ) ;
733
-		$layout_defs [ $layout_def_key ] = array ( ) ;
727
+    /**
728
+     * Load the layout def file and associate the definition with a variable in the file.
729
+     */
730
+    function open_layout_defs ( $reload = false , $layout_def_key = '' , $original_only = false )
731
+    {
732
+        $layout_defs [ $this->_focus->module_dir ] = array ( ) ;
733
+        $layout_defs [ $layout_def_key ] = array ( ) ;
734 734
 
735
-		if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] )))
736
-		{
737
-			if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' ))
738
-				require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ;
735
+        if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] )))
736
+        {
737
+            if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' ))
738
+                require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ;
739 739
 
740
-			if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' ))
741
-				require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ;
740
+            if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' ))
741
+                require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ;
742 742
 
743
-			if (! empty ( $layout_def_key ))
744
-				$this->layout_defs = $layout_defs [ $layout_def_key ] ;
745
-			else
746
-				$this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ;
743
+            if (! empty ( $layout_def_key ))
744
+                $this->layout_defs = $layout_defs [ $layout_def_key ] ;
745
+            else
746
+                $this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ;
747 747
 
748
-		}
748
+        }
749 749
 
750
-	}
750
+    }
751 751
 
752
-	/**
753
-	 * Removes a tab from the list of loaded tabs.
754
-	 * Returns true if successful, false otherwise.
755
-	 * Hint: Used by Campaign's DetailView.
756
-	 */
757
-	function exclude_tab ( $tab_name )
758
-	{
759
-		$result = false ;
760
-		//unset layout definition
761
-		if (! empty ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ))
762
-		{
763
-			unset ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ) ;
764
-		}
765
-		//unset instance from _visible_tab_array
766
-		if (! empty ( $this->_visible_tabs_array ))
767
-		{
768
-			$key = array_search ( $tab_name, $this->_visible_tabs_array ) ;
769
-			if ($key !== false)
770
-			{
771
-				unset ( $this->_visible_tabs_array [ $key ] ) ;
772
-			}
773
-		}
774
-		return $result ;
775
-	}
776
-
777
-
778
-	/**
779
-	 * return all available subpanels that belong to the list of tab modules.  You can optionally return all
780
-	 * available subpanels, and also optionally group by module (prepends the key with the bean class name).
781
-	 */
782
-	function get_all_subpanels( $return_tab_modules_only = true, $group_by_module = false )
783
-	{
784
-		global $moduleList, $beanFiles, $beanList, $module;
752
+    /**
753
+     * Removes a tab from the list of loaded tabs.
754
+     * Returns true if successful, false otherwise.
755
+     * Hint: Used by Campaign's DetailView.
756
+     */
757
+    function exclude_tab ( $tab_name )
758
+    {
759
+        $result = false ;
760
+        //unset layout definition
761
+        if (! empty ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ))
762
+        {
763
+            unset ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ) ;
764
+        }
765
+        //unset instance from _visible_tab_array
766
+        if (! empty ( $this->_visible_tabs_array ))
767
+        {
768
+            $key = array_search ( $tab_name, $this->_visible_tabs_array ) ;
769
+            if ($key !== false)
770
+            {
771
+                unset ( $this->_visible_tabs_array [ $key ] ) ;
772
+            }
773
+        }
774
+        return $result ;
775
+    }
785 776
 
786
-		//use tab controller function to get module list with named keys
787
-		require_once("modules/MySettings/TabController.php");
788
-		$modules_to_check = TabController::get_key_array($moduleList);
789 777
 
790
-		//change case to match subpanel processing later on
791
-		$modules_to_check = array_change_key_case($modules_to_check);
778
+    /**
779
+     * return all available subpanels that belong to the list of tab modules.  You can optionally return all
780
+     * available subpanels, and also optionally group by module (prepends the key with the bean class name).
781
+     */
782
+    function get_all_subpanels( $return_tab_modules_only = true, $group_by_module = false )
783
+    {
784
+        global $moduleList, $beanFiles, $beanList, $module;
785
+
786
+        //use tab controller function to get module list with named keys
787
+        require_once("modules/MySettings/TabController.php");
788
+        $modules_to_check = TabController::get_key_array($moduleList);
789
+
790
+        //change case to match subpanel processing later on
791
+        $modules_to_check = array_change_key_case($modules_to_check);
792 792
         // Append on the CampaignLog module, because that is where the subpanels point, not directly to Campaigns
793 793
         $modules_to_check['campaignlog'] = "CampaignLog";
794 794
 
795 795
 
796
-		$spd = '';
797
-		$spd_arr = array();
798
-		//iterate through modules and build subpanel array
799
-		foreach($modules_to_check as $mod_name){
796
+        $spd = '';
797
+        $spd_arr = array();
798
+        //iterate through modules and build subpanel array
799
+        foreach($modules_to_check as $mod_name){
800 800
 
801
-			//skip if module name is not in bean list, otherwise get the bean class name
802
-			if(!isset($beanList[$mod_name])) continue;
803
-			$class = $beanList[$mod_name];
801
+            //skip if module name is not in bean list, otherwise get the bean class name
802
+            if(!isset($beanList[$mod_name])) continue;
803
+            $class = $beanList[$mod_name];
804 804
 
805
-			//skip if class name is not in file list, otherwise require the bean file and create new class
806
-			if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue;
805
+            //skip if class name is not in file list, otherwise require the bean file and create new class
806
+            if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue;
807 807
 
808
-			//retrieve subpanels for this bean
809
-			require_once($beanFiles[$class]);
810
-			$bean_class = new $class();
808
+            //retrieve subpanels for this bean
809
+            require_once($beanFiles[$class]);
810
+            $bean_class = new $class();
811 811
 
812
-			//create new subpanel definition instance and get list of tabs
813
-			$spd = new SubPanelDefinitions($bean_class) ;
814
-			$sub_tabs = $spd->get_available_tabs();
812
+            //create new subpanel definition instance and get list of tabs
813
+            $spd = new SubPanelDefinitions($bean_class) ;
814
+            $sub_tabs = $spd->get_available_tabs();
815 815
 
816
-			//add each subpanel to array of total subpanles
817
-			foreach( $sub_tabs as $panel_key){
818
-				$panel_key = strtolower($panel_key);
816
+            //add each subpanel to array of total subpanles
817
+            foreach( $sub_tabs as $panel_key){
818
+                $panel_key = strtolower($panel_key);
819 819
                 $panel_module = $panel_key;
820 820
                 if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) )
821 821
                     $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']);
822 822
                 //if module_only flag is set, only if it is also in module array
823
-				if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue;
824
-				$panel_key_name = $panel_module;
825
-
826
-				//group_by_key_name is set to true, then array will hold an entry for each
827
-				//subpanel, with the module name prepended in the key
828
-				if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name;
829
-				//add panel name to subpanel array
830
-				$spd_arr[$panel_key_name] = $panel_module;
831
-			}
832
-		}
833
-		return 	$spd_arr;
834
-	}
835
-
836
-	/*
823
+                if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue;
824
+                $panel_key_name = $panel_module;
825
+
826
+                //group_by_key_name is set to true, then array will hold an entry for each
827
+                //subpanel, with the module name prepended in the key
828
+                if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name;
829
+                //add panel name to subpanel array
830
+                $spd_arr[$panel_key_name] = $panel_module;
831
+            }
832
+        }
833
+        return 	$spd_arr;
834
+    }
835
+
836
+    /*
837 837
 	 * save array of hidden panels to mysettings category in config table
838 838
 	 */
839
-	function set_hidden_subpanels($panels){
840
-		$administration = new Administration();
841
-		$serialized = base64_encode(serialize($panels));
842
-		$administration->saveSetting('MySettings', 'hide_subpanels', $serialized);
843
-	}
839
+    function set_hidden_subpanels($panels){
840
+        $administration = new Administration();
841
+        $serialized = base64_encode(serialize($panels));
842
+        $administration->saveSetting('MySettings', 'hide_subpanels', $serialized);
843
+    }
844 844
 
845
-	/*
845
+    /*
846 846
 	 * retrieve hidden subpanels
847 847
 	 */
848
-	function get_hidden_subpanels(){
849
-		global $moduleList;
850
-
851
-		//create variable as static to minimize queries
852
-		static $hidden_subpanels = null;
853
-
854
-		// if the static value is not already cached, then retrieve it.
855
-		if(empty($hidden_subpanels))
856
-		{
857
-
858
-			//create Administration object and retrieve any settings for panels
859
-			$administration = new Administration();
860
-			$administration->retrieveSettings('MySettings');
861
-
862
-			if(isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])){
863
-				$hidden_subpanels = $administration->settings['MySettings_hide_subpanels'];
864
-				$hidden_subpanels = trim($hidden_subpanels);
865
-
866
-				//make sure serialized string is not empty
867
-				if (!empty($hidden_subpanels)){
868
-					//decode and unserialize to retrieve the array
869
-					$hidden_subpanels = base64_decode($hidden_subpanels);
870
-					$hidden_subpanels = unserialize($hidden_subpanels);
871
-
872
-					//Ensure modules saved in the preferences exist.
873
-					//get user preference
874
-					//unserialize and add to array if not empty
875
-					$pref_hidden = array();
876
-					foreach($pref_hidden as $id => $pref_hidden_panel) {
877
-						$hidden_subpanels[] = $pref_hidden_panel;
878
-					}
879
-
880
-
881
-				}else{
882
-					//no settings found, return empty
883
-					return $hidden_subpanels;
884
-				}
885
-			}
886
-			else
887
-			{	//no settings found, return empty
888
-				return $hidden_subpanels;
889
-			}
890
-		}
891
-
892
-		return $hidden_subpanels;
893
-	}
848
+    function get_hidden_subpanels(){
849
+        global $moduleList;
850
+
851
+        //create variable as static to minimize queries
852
+        static $hidden_subpanels = null;
853
+
854
+        // if the static value is not already cached, then retrieve it.
855
+        if(empty($hidden_subpanels))
856
+        {
857
+
858
+            //create Administration object and retrieve any settings for panels
859
+            $administration = new Administration();
860
+            $administration->retrieveSettings('MySettings');
861
+
862
+            if(isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])){
863
+                $hidden_subpanels = $administration->settings['MySettings_hide_subpanels'];
864
+                $hidden_subpanels = trim($hidden_subpanels);
865
+
866
+                //make sure serialized string is not empty
867
+                if (!empty($hidden_subpanels)){
868
+                    //decode and unserialize to retrieve the array
869
+                    $hidden_subpanels = base64_decode($hidden_subpanels);
870
+                    $hidden_subpanels = unserialize($hidden_subpanels);
871
+
872
+                    //Ensure modules saved in the preferences exist.
873
+                    //get user preference
874
+                    //unserialize and add to array if not empty
875
+                    $pref_hidden = array();
876
+                    foreach($pref_hidden as $id => $pref_hidden_panel) {
877
+                        $hidden_subpanels[] = $pref_hidden_panel;
878
+                    }
879
+
880
+
881
+                }else{
882
+                    //no settings found, return empty
883
+                    return $hidden_subpanels;
884
+                }
885
+            }
886
+            else
887
+            {	//no settings found, return empty
888
+                return $hidden_subpanels;
889
+            }
890
+        }
891
+
892
+        return $hidden_subpanels;
893
+    }
894 894
 
895 895
 
896 896
 }
Please login to merge, or discard this patch.
Spacing   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry) die ( 'Not A Valid Entry Point' ) ;
2
+if (!defined('sugarEntry') || !sugarEntry) die ('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 class aSubPanel
55 55
 {
56 56
 
57
-	var $name ;
58
-	var $_instance_properties ;
57
+	var $name;
58
+	var $_instance_properties;
59 59
 
60
-	var $mod_strings ;
61
-	var $panel_definition ;
62
-	var $sub_subpanels ;
63
-	var $parent_bean ;
60
+	var $mod_strings;
61
+	var $panel_definition;
62
+	var $sub_subpanels;
63
+	var $parent_bean;
64 64
 
65 65
     /**
66 66
      * Can we display this subpanel?
@@ -73,53 +73,53 @@  discard block
 block discarded – undo
73 73
     var $canDisplay = true;
74 74
 
75 75
 	//module's table name and column fields.
76
-	var $table_name ;
77
-	var $db_fields ;
78
-	var $bean_name ;
79
-	var $template_instance ;
76
+	var $table_name;
77
+	var $db_fields;
78
+	var $bean_name;
79
+	var $template_instance;
80 80
 
81 81
 	var $search_query;
82 82
 	var $base_collection_list = array();
83 83
 
84
-	function __construct ($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){
84
+	function __construct($name, $instance_properties, $parent_bean, $reload = false, $original_only = false, $search_query = '', $collections = array()) {
85 85
 
86
-		$this->_instance_properties = $instance_properties ;
86
+		$this->_instance_properties = $instance_properties;
87 87
 
88
-		if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ];
88
+		if (isset($instance_properties['collection_list'])) $this->base_collection_list = $instance_properties['collection_list'];
89 89
 
90
-		if(!empty($collections) && isset($instance_properties['collection_list' ])){
91
-			foreach($instance_properties['collection_list' ] as $cname => $value){
92
-				if(!in_array($value['module'], $collections)){
90
+		if (!empty($collections) && isset($instance_properties['collection_list'])) {
91
+			foreach ($instance_properties['collection_list'] as $cname => $value) {
92
+				if (!in_array($value['module'], $collections)) {
93 93
 					unset($instance_properties['collection_list'][$cname]);
94 94
 				}
95 95
 			}
96 96
 		}
97
-		if (!$this->isCollection()){
97
+		if (!$this->isCollection()) {
98 98
 			$table = strtolower($instance_properties['module']);
99
-			$search_query = str_replace('meetings',$table,$search_query);
99
+			$search_query = str_replace('meetings', $table, $search_query);
100 100
 		}
101 101
 
102 102
 		$this->search_query = $search_query;
103
-		$this->name = $name ;
104
-		$this->parent_bean = $parent_bean ;
103
+		$this->name = $name;
104
+		$this->parent_bean = $parent_bean;
105 105
 
106 106
 		//set language
107
-		global $current_language ;
108
-		if (! isset ( $parent_bean->mbvardefs ))
107
+		global $current_language;
108
+		if (!isset ($parent_bean->mbvardefs))
109 109
 		{
110
-			$mod_strings = return_module_language ( $current_language, $parent_bean->module_dir ) ;
110
+			$mod_strings = return_module_language($current_language, $parent_bean->module_dir);
111 111
 		}
112
-		$this->mod_strings = $mod_strings ;
112
+		$this->mod_strings = $mod_strings;
113 113
 
114
-        if ($this->isCollection ())
114
+        if ($this->isCollection())
115 115
 		{
116
-			$this->canDisplay = $this->load_sub_subpanels () ; //load sub-panel definition.
116
+			$this->canDisplay = $this->load_sub_subpanels(); //load sub-panel definition.
117 117
 		} else
118 118
 		{
119
-			if (!is_dir('modules/' . $this->_instance_properties [ 'module' ])){
119
+			if (!is_dir('modules/'.$this->_instance_properties ['module'])) {
120 120
 				_pstack_trace();
121 121
 			}
122
-			$def_path = 'modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'subpanel_name' ] . '.php' ;
122
+			$def_path = 'modules/'.$this->_instance_properties ['module'].'/metadata/subpanels/'.$this->_instance_properties ['subpanel_name'].'.php';
123 123
 
124 124
 			$orig_exists = is_file($def_path);
125 125
 			$loaded = false;
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 				require ($def_path);
129 129
 				$loaded = true;
130 130
 			}
131
-			if (is_file("custom/$def_path") && (!$original_only  || !$orig_exists))
131
+			if (is_file("custom/$def_path") && (!$original_only || !$orig_exists))
132 132
 			{
133 133
 				require ("custom/$def_path");
134 134
 				$loaded = true;
135 135
 			}
136 136
 
137
-			if (! $original_only && isset ( $this->_instance_properties [ 'override_subpanel_name' ] ) && file_exists ( 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ))
137
+			if (!$original_only && isset ($this->_instance_properties ['override_subpanel_name']) && file_exists('custom/modules/'.$this->_instance_properties ['module'].'/metadata/subpanels/'.$this->_instance_properties ['override_subpanel_name'].'.php'))
138 138
 			{
139
-				$cust_def_path = 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ;
140
-				require ($cust_def_path) ;
139
+				$cust_def_path = 'custom/modules/'.$this->_instance_properties ['module'].'/metadata/subpanels/'.$this->_instance_properties ['override_subpanel_name'].'.php';
140
+				require ($cust_def_path);
141 141
 				$loaded = true;
142 142
 			}
143 143
 
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	/**
165 165
 	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
166 166
 	 */
167
-	function aSubPanel($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){
167
+	function aSubPanel($name, $instance_properties, $parent_bean, $reload = false, $original_only = false, $search_query = '', $collections = array()) {
168 168
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
169
-		if(isset($GLOBALS['log'])) {
169
+		if (isset($GLOBALS['log'])) {
170 170
 			$GLOBALS['log']->deprecated($deprecatedMessage);
171 171
 		}
172 172
 		else {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function isDefaultHidden()
184 184
     {
185
-        if(isset($this->_instance_properties['default_hidden']) && $this->_instance_properties['default_hidden'] == true) {
185
+        if (isset($this->_instance_properties['default_hidden']) && $this->_instance_properties['default_hidden'] == true) {
186 186
             return true;
187 187
         }
188 188
 
@@ -190,63 +190,63 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 
193
-	function distinct_query ()
193
+	function distinct_query()
194 194
 	{
195
-		if (isset ( $this->_instance_properties [ 'get_distinct_data' ] ))
195
+		if (isset ($this->_instance_properties ['get_distinct_data']))
196 196
 		{
197 197
 			return !empty($this->_instance_properties['get_distinct_data']) ? true : false;
198 198
 		}
199
-		return false ;
199
+		return false;
200 200
 	}
201 201
 
202 202
 	//return the translated header value.
203
-	function get_title ()
203
+	function get_title()
204 204
 	{
205
-		if (empty ( $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ))
205
+		if (empty ($this->mod_strings [$this->_instance_properties ['title_key']]))
206 206
 		{
207
-			return translate ( $this->_instance_properties [ 'title_key' ], $this->_instance_properties [ 'module' ] ) ;
207
+			return translate($this->_instance_properties ['title_key'], $this->_instance_properties ['module']);
208 208
 		}
209
-		return $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ;
209
+		return $this->mod_strings [$this->_instance_properties ['title_key']];
210 210
 	}
211 211
 
212 212
 	//return the definition of buttons. looks for buttons in 2 locations.
213
-	function get_buttons ()
213
+	function get_buttons()
214 214
 	{
215
-		$buttons = array ( ) ;
216
-		if (isset ( $this->_instance_properties [ 'top_buttons' ] ))
215
+		$buttons = array( );
216
+		if (isset ($this->_instance_properties ['top_buttons']))
217 217
 		{
218 218
 			//this will happen only in the case of sub-panels with multiple sources(activities).
219
-			$buttons = $this->_instance_properties [ 'top_buttons' ] ;
219
+			$buttons = $this->_instance_properties ['top_buttons'];
220 220
 		} else
221 221
 		{
222
-			$buttons = $this->panel_definition [ 'top_buttons' ] ;
222
+			$buttons = $this->panel_definition ['top_buttons'];
223 223
 		}
224 224
 
225 225
 		// permissions. hide SubPanelTopComposeEmailButton from activities if email module is disabled.
226 226
 		//only email is  being tested becuase other submodules in activites/history such as notes, tasks, meetings and calls cannot be disabled.
227 227
 		//as of today these are the only 2 sub-panels that use the union clause.
228
-		$mod_name = $this->get_module_name () ;
228
+		$mod_name = $this->get_module_name();
229 229
 		if ($mod_name == 'Activities' || $mod_name == 'History')
230 230
 		{
231
-			global $modListHeader ;
232
-			global $modules_exempt_from_availability_check ;
233
-			if (isset ( $modListHeader ) && (! (array_key_exists ( 'Emails', $modListHeader ) or array_key_exists ( 'Emails', $modules_exempt_from_availability_check ))))
231
+			global $modListHeader;
232
+			global $modules_exempt_from_availability_check;
233
+			if (isset ($modListHeader) && (!(array_key_exists('Emails', $modListHeader) or array_key_exists('Emails', $modules_exempt_from_availability_check))))
234 234
 			{
235
-				foreach ( $buttons as $key => $button )
235
+				foreach ($buttons as $key => $button)
236 236
 				{
237
-					foreach ( $button as $property => $value )
237
+					foreach ($button as $property => $value)
238 238
 					{
239 239
 						if ($value === 'SubPanelTopComposeEmailButton' || $value === 'SubPanelTopArchiveEmailButton')
240 240
 						{
241 241
 							//remove this button from the array.
242
-							unset ( $buttons [ $key ] ) ;
242
+							unset ($buttons [$key]);
243 243
 						}
244 244
 					}
245 245
 				}
246 246
 			}
247 247
 		}
248 248
 
249
-		return $buttons ;
249
+		return $buttons;
250 250
 	}
251 251
 
252 252
 
@@ -258,67 +258,67 @@  discard block
 block discarded – undo
258 258
      * @return bool         True by default if the subpanel was loaded.  Will return false if none in the collection are
259 259
      *                      allowed by the current user.
260 260
      */
261
-	function load_sub_subpanels ()
261
+	function load_sub_subpanels()
262 262
 	{
263 263
 
264
-		global $modListHeader ;
264
+		global $modListHeader;
265 265
 		// added a check for security of tabs to see if an user has access to them
266 266
 		// this prevents passing an "unseen" tab to the query string and pulling up its contents
267
-		if (! isset ( $modListHeader ))
267
+		if (!isset ($modListHeader))
268 268
 		{
269
-			global $current_user ;
270
-			if (isset ( $current_user ))
269
+			global $current_user;
270
+			if (isset ($current_user))
271 271
 			{
272
-				$modListHeader = query_module_access_list ( $current_user ) ;
272
+				$modListHeader = query_module_access_list($current_user);
273 273
 			}
274 274
 		}
275 275
 
276 276
 		//by default all the activities modules are exempt, so hiding them won't affect their appearance unless the 'activity' subpanel itself is hidden.
277 277
 		//add email to the list temporarily so it is not affected in activities subpanel
278
-		global $modules_exempt_from_availability_check ;
278
+		global $modules_exempt_from_availability_check;
279 279
 		$modules_exempt_from_availability_check['Emails'] = 'Emails';
280 280
 
281 281
 		$listFieldMap = array();
282 282
 
283
-		if (empty ( $this->sub_subpanels ))
283
+		if (empty ($this->sub_subpanels))
284 284
 		{
285
-			$panels = $this->get_inst_prop_value ( 'collection_list' ) ;
286
-			foreach ( $panels as $panel => $properties )
285
+			$panels = $this->get_inst_prop_value('collection_list');
286
+			foreach ($panels as $panel => $properties)
287 287
 			{
288
-				if (array_key_exists ( $properties [ 'module' ], $modListHeader ) or array_key_exists ( $properties [ 'module' ], $modules_exempt_from_availability_check ))
288
+				if (array_key_exists($properties ['module'], $modListHeader) or array_key_exists($properties ['module'], $modules_exempt_from_availability_check))
289 289
 				{
290
-					$this->sub_subpanels [ $panel ] = new aSubPanel ( $panel, $properties, $this->parent_bean, false, false, $this->search_query ) ;
290
+					$this->sub_subpanels [$panel] = new aSubPanel($panel, $properties, $this->parent_bean, false, false, $this->search_query);
291 291
 				}
292 292
 			}
293 293
 			// if it's empty just dump out as there is nothing to process.
294
-			if(empty($this->sub_subpanels)) return false;
294
+			if (empty($this->sub_subpanels)) return false;
295 295
 			//Sync displayed list fields across the subpanels
296 296
 			$display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels);
297 297
 			$query_fields = array();
298
-			foreach ( $this->sub_subpanels as $key => $subpanel )
298
+			foreach ($this->sub_subpanels as $key => $subpanel)
299 299
 			{
300 300
 				$list_fields = $subpanel->get_list_fields();
301 301
 				$listFieldMap[$key] = array();
302 302
 				$index = 0;
303
-				foreach($list_fields as $field => $def)
303
+				foreach ($list_fields as $field => $def)
304 304
 				{
305 305
 					if (isset($def['vname']) && isset($def['width']))
306 306
 					{
307 307
 						$index++;
308
-						if(!empty($def['alias']))
308
+						if (!empty($def['alias']))
309 309
 							$listFieldMap[$key][$def['alias']] = $field;
310 310
 						else
311 311
 							$listFieldMap[$key][$field] = $field;
312 312
 						if (!isset($display_fields[$def['vname']]))
313 313
 						{
314
-							if(sizeof($display_fields) > $index)
314
+							if (sizeof($display_fields) > $index)
315 315
 							{
316 316
 								//Try to insert the new field in an order that makes sense
317 317
 								$start = array_slice($display_fields, 0, $index);
318 318
 								$end = array_slice($display_fields, $index);
319 319
 								$display_fields = array_merge(
320 320
 									$start,
321
-									array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )),
321
+									array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'])),
322 322
 									$end
323 323
 								);
324 324
 							} else
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 					}
336 336
 				}
337 337
 			}
338
-			foreach ( $this->sub_subpanels as $key => $subpanel )
338
+			foreach ($this->sub_subpanels as $key => $subpanel)
339 339
 			{
340 340
 				$list_fields = array();
341
-				foreach($display_fields as $vname => $def)
341
+				foreach ($display_fields as $vname => $def)
342 342
 				{
343 343
 					$field = $def['name'];
344 344
 					$list_key = isset($listFieldMap[$key][$field]) ? $listFieldMap[$key][$field] : $field;
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 						$list_fields[$field] = $display_fields[$vname];
357 357
 					}
358 358
 				}
359
-				foreach($query_fields as $field => $def)
359
+				foreach ($query_fields as $field => $def)
360 360
 				{
361 361
 					if (isset($subpanel->panel_definition['list_fields'][$field]))
362 362
 					{
@@ -376,25 +376,25 @@  discard block
 block discarded – undo
376 376
 	protected function getDisplayFieldsFromCollection($sub_subpanels)
377 377
 	{
378 378
 		$display_fields = array();
379
-		foreach ($sub_subpanels as $key => $subpanel )
379
+		foreach ($sub_subpanels as $key => $subpanel)
380 380
 		{
381 381
 			$list_fields = $subpanel->get_list_fields();
382 382
 			$index = 0;
383
-			foreach($list_fields as $field => $def)
383
+			foreach ($list_fields as $field => $def)
384 384
 			{
385 385
 				if (isset($def['vname']) && isset($def['width']))
386 386
 				{
387 387
 					$index++;
388 388
 					if (!isset($display_fields[$def['vname']]))
389 389
 					{
390
-						if(sizeof($display_fields) > $index)
390
+						if (sizeof($display_fields) > $index)
391 391
 						{
392 392
 							//Try to insert the new field in an order that makes sense
393 393
 							$start = array_slice($display_fields, 0, $index);
394 394
 							$end = array_slice($display_fields, $index);
395 395
 							$display_fields = array_merge(
396 396
 								$start,
397
-								array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )),
397
+								array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'])),
398 398
 								$end
399 399
 							);
400 400
 						} else
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 		}
412 412
 	}
413 413
 
414
-	function isDatasourceFunction ()
414
+	function isDatasourceFunction()
415 415
 	{
416
-		if (strpos ( $this->get_inst_prop_value ( 'get_subpanel_data' ), 'function' ) === false)
416
+		if (strpos($this->get_inst_prop_value('get_subpanel_data'), 'function') === false)
417 417
 		{
418
-			return false ;
418
+			return false;
419 419
 		}
420
-		return true ;
420
+		return true;
421 421
 	}
422 422
 
423 423
     /**
@@ -425,159 +425,159 @@  discard block
 block discarded – undo
425 425
      *
426 426
      * @return bool
427 427
      */
428
-	function isCollection ()
428
+	function isCollection()
429 429
 	{
430
-		return ($this->get_inst_prop_value ( 'type' ) == 'collection');
430
+		return ($this->get_inst_prop_value('type') == 'collection');
431 431
 	}
432 432
 
433 433
 	//get value of a property defined at the panel instance level.
434
-	function get_inst_prop_value ( $name )
434
+	function get_inst_prop_value($name)
435 435
 	{
436
-		return isset($this->_instance_properties[$name]) ? $this->_instance_properties [ $name ] : null;
436
+		return isset($this->_instance_properties[$name]) ? $this->_instance_properties [$name] : null;
437 437
 	}
438 438
 	//get value of a property defined at the panel definition level.
439
-	function get_def_prop_value ( $name )
439
+	function get_def_prop_value($name)
440 440
 	{
441
-		if (isset ( $this->panel_definition [ $name ] ))
441
+		if (isset ($this->panel_definition [$name]))
442 442
 		{
443
-			return $this->panel_definition [ $name ] ;
443
+			return $this->panel_definition [$name];
444 444
 		} else
445 445
 		{
446
-			return null ;
446
+			return null;
447 447
 		}
448 448
 	}
449 449
 
450 450
 	//if datasource is of the type function then return the function name
451 451
 	//else return the value as is.
452
-	function get_function_parameters ()
452
+	function get_function_parameters()
453 453
 	{
454
-		$parameters = array ( ) ;
455
-		if ($this->isDatasourceFunction ())
454
+		$parameters = array( );
455
+		if ($this->isDatasourceFunction())
456 456
 		{
457
-			$parameters = $this->get_inst_prop_value ( 'function_parameters' ) ;
457
+			$parameters = $this->get_inst_prop_value('function_parameters');
458 458
 		}
459
-		return $parameters ;
459
+		return $parameters;
460 460
 	}
461 461
 
462
-	function get_data_source_name ( $check_set_subpanel_data = false )
462
+	function get_data_source_name($check_set_subpanel_data = false)
463 463
 	{
464
-		$prop_value = null ;
464
+		$prop_value = null;
465 465
 		if ($check_set_subpanel_data)
466 466
 		{
467
-			$prop_value = $this->get_inst_prop_value ( 'set_subpanel_data' ) ;
467
+			$prop_value = $this->get_inst_prop_value('set_subpanel_data');
468 468
 		}
469
-		if (! empty ( $prop_value ))
469
+		if (!empty ($prop_value))
470 470
 		{
471
-			return $prop_value ;
471
+			return $prop_value;
472 472
 		} else
473 473
 		{
474 474
 			//fall back to default behavior.
475 475
 		}
476
-		if ($this->isDatasourceFunction ())
476
+		if ($this->isDatasourceFunction())
477 477
 		{
478
-			return (substr_replace ( $this->get_inst_prop_value ( 'get_subpanel_data' ), '', 0, 9 )) ;
478
+			return (substr_replace($this->get_inst_prop_value('get_subpanel_data'), '', 0, 9));
479 479
 		} else
480 480
 		{
481
-			return $this->get_inst_prop_value ( 'get_subpanel_data' ) ;
481
+			return $this->get_inst_prop_value('get_subpanel_data');
482 482
 		}
483 483
 	}
484 484
 
485 485
 	//returns the where clause for the query.
486
-	function get_where ()
486
+	function get_where()
487 487
 	{
488
-		if($this->get_def_prop_value ( 'where' ) != '' && $this->search_query != ''){
489
-			return $this->get_def_prop_value ( 'where' ).' AND '.$this->search_query;
490
-		} else if($this->search_query != ''){
488
+		if ($this->get_def_prop_value('where') != '' && $this->search_query != '') {
489
+			return $this->get_def_prop_value('where').' AND '.$this->search_query;
490
+		} else if ($this->search_query != '') {
491 491
 			return $this->search_query;
492 492
 		}
493
-		return $this->get_def_prop_value ( 'where' ) ;
493
+		return $this->get_def_prop_value('where');
494 494
 	}
495 495
 
496
-	function is_fill_in_additional_fields ()
496
+	function is_fill_in_additional_fields()
497 497
 	{
498 498
 		// do both. inst_prop returns values from metadata/subpaneldefs.php and def_prop returns from subpanel/default.php
499
-		$temp = $this->get_inst_prop_value ( 'fill_in_additional_fields' ) || $this->get_def_prop_value ( 'fill_in_additional_fields' ) ;
500
-		return $temp ;
499
+		$temp = $this->get_inst_prop_value('fill_in_additional_fields') || $this->get_def_prop_value('fill_in_additional_fields');
500
+		return $temp;
501 501
 	}
502 502
 
503
-	function get_list_fields ()
503
+	function get_list_fields()
504 504
 	{
505
-		if (isset ( $this->panel_definition [ 'list_fields' ] ))
505
+		if (isset ($this->panel_definition ['list_fields']))
506 506
 		{
507
-			return $this->panel_definition [ 'list_fields' ] ;
507
+			return $this->panel_definition ['list_fields'];
508 508
 		} else
509 509
 		{
510
-			return array ( ) ;
510
+			return array( );
511 511
 		}
512 512
 	}
513 513
 
514
-	function get_module_name ()
514
+	function get_module_name()
515 515
 	{
516
-		return $this->get_inst_prop_value ( 'module' ) ;
516
+		return $this->get_inst_prop_value('module');
517 517
 	}
518 518
 
519
-	function get_name ()
519
+	function get_name()
520 520
 	{
521
-		return $this->name ;
521
+		return $this->name;
522 522
 	}
523 523
 
524 524
 	//load subpanel module's table name and column fields.
525
-	function load_module_info ()
525
+	function load_module_info()
526 526
 	{
527
-		global $beanList ;
528
-		global $beanFiles ;
527
+		global $beanList;
528
+		global $beanFiles;
529 529
 
530
-		$module_name = $this->get_module_name () ;
531
-		if (! empty ( $module_name ))
530
+		$module_name = $this->get_module_name();
531
+		if (!empty ($module_name))
532 532
 		{
533 533
 
534
-			$bean_name = $beanList [ $this->get_module_name () ] ;
534
+			$bean_name = $beanList [$this->get_module_name()];
535 535
 
536
-			$this->bean_name = $bean_name ;
536
+			$this->bean_name = $bean_name;
537 537
 
538
-			include_once ($beanFiles [ $bean_name ]) ;
539
-			$this->template_instance = new $bean_name ( ) ;
540
-			$this->template_instance->force_load_details = true ;
541
-			$this->table_name = $this->template_instance->table_name ;
538
+			include_once ($beanFiles [$bean_name]);
539
+			$this->template_instance = new $bean_name( );
540
+			$this->template_instance->force_load_details = true;
541
+			$this->table_name = $this->template_instance->table_name;
542 542
 			//$this->db_fields=$this->template_instance->column_fields;
543 543
 		}
544 544
 	}
545 545
 	//this function is to be used only with sub-panels that are based
546 546
 	//on collections.
547
-	function get_header_panel_def ()
547
+	function get_header_panel_def()
548 548
 	{
549
-		if (! empty ( $this->sub_subpanels ))
549
+		if (!empty ($this->sub_subpanels))
550 550
 		{
551
-			if (! empty ( $this->_instance_properties [ 'header_definition_from_subpanel' ] ) && ! empty ( $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ))
551
+			if (!empty ($this->_instance_properties ['header_definition_from_subpanel']) && !empty ($this->sub_subpanels [$this->_instance_properties ['header_definition_from_subpanel']]))
552 552
 			{
553
-				return $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ;
553
+				return $this->sub_subpanels [$this->_instance_properties ['header_definition_from_subpanel']];
554 554
 			} else
555 555
 			{
556 556
 				$display_fields = array();
557 557
 				//If we are not pulling from a specific subpanel, create a list of all list fields and use that.
558
-				foreach($this->sub_subpanels as $subpanel)
558
+				foreach ($this->sub_subpanels as $subpanel)
559 559
 				{
560 560
 					$list_fields = $subpanel->get_list_fields();
561
-					foreach($list_fields as $field => $def)
561
+					foreach ($list_fields as $field => $def)
562 562
 					{
563 563
 
564 564
 					}
565 565
 				}
566 566
 
567
-				reset ( $this->sub_subpanels ) ;
568
-				return current ( $this->sub_subpanels ) ;
567
+				reset($this->sub_subpanels);
568
+				return current($this->sub_subpanels);
569 569
 			}
570 570
 		}
571
-		return null ;
571
+		return null;
572 572
 	}
573 573
 
574 574
 	/**
575 575
 	 * Returns an array of current properties of the class.
576 576
 	 * It will simply give the class name for instances of classes.
577 577
 	 */
578
-	function _to_array ()
578
+	function _to_array()
579 579
 	{
580
-		return array ( '_instance_properties' => $this->_instance_properties , 'db_fields' => $this->db_fields , 'mod_strings' => $this->mod_strings , 'name' => $this->name , 'panel_definition' => $this->panel_definition , 'parent_bean' => get_class ( $this->parent_bean ) , 'sub_subpanels' => $this->sub_subpanels , 'table_name' => $this->table_name , 'template_instance' => get_class ( $this->template_instance ) ) ;
580
+		return array('_instance_properties' => $this->_instance_properties, 'db_fields' => $this->db_fields, 'mod_strings' => $this->mod_strings, 'name' => $this->name, 'panel_definition' => $this->panel_definition, 'parent_bean' => get_class($this->parent_bean), 'sub_subpanels' => $this->sub_subpanels, 'table_name' => $this->table_name, 'template_instance' => get_class($this->template_instance));
581 581
 	}
582 582
 
583 583
     /**
@@ -596,10 +596,10 @@  discard block
 block discarded – undo
596 596
 class SubPanelDefinitions
597 597
 {
598 598
 
599
-	var $_focus ;
600
-	var $_visible_tabs_array ;
601
-	var $panels ;
602
-	var $layout_defs ;
599
+	var $_focus;
600
+	var $_visible_tabs_array;
601
+	var $panels;
602
+	var $layout_defs;
603 603
 
604 604
 	/**
605 605
 	 * Enter description here...
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
 	 * @param ARRAY $layout_def_override - if you wish to override the default loaded layout defs you pass them in here.
610 610
 	 * @return SubPanelDefinitions
611 611
 	 */
612
-	function __construct ( $focus , $layout_def_key = '' , $layout_def_override = '' )
612
+	function __construct($focus, $layout_def_key = '', $layout_def_override = '')
613 613
 	{
614
-		$this->_focus = $focus ;
615
-		if (! empty ( $layout_def_override ))
614
+		$this->_focus = $focus;
615
+		if (!empty ($layout_def_override))
616 616
 		{
617
-			$this->layout_defs = $layout_def_override ;
617
+			$this->layout_defs = $layout_def_override;
618 618
 
619 619
 		} else
620 620
 		{
621
-			$this->open_layout_defs ( false, $layout_def_key ) ;
621
+			$this->open_layout_defs(false, $layout_def_key);
622 622
 		}
623 623
 	}
624 624
 
@@ -633,68 +633,68 @@  discard block
 block discarded – undo
633 633
 	 * @param boolean 	Optional - include the subpanel title label in the return array (false)
634 634
 	 * @return array	All tabs that pass an ACL check
635 635
 	 */
636
-	function get_available_tabs ($FromGetModuleSubpanels=false)
636
+	function get_available_tabs($FromGetModuleSubpanels = false)
637 637
 	{
638
-		global $modListHeader ;
639
-		global $modules_exempt_from_availability_check ;
638
+		global $modListHeader;
639
+		global $modules_exempt_from_availability_check;
640 640
 
641
-		if (isset ( $this->_visible_tabs_array ))
642
-			return $this->_visible_tabs_array ;
641
+		if (isset ($this->_visible_tabs_array))
642
+			return $this->_visible_tabs_array;
643 643
 
644 644
 		if (empty($modListHeader))
645 645
 		    $modListHeader = query_module_access_list($GLOBALS['current_user']);
646 646
 
647
-		$this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort
647
+		$this->_visible_tabs_array = array( ); // bug 16820 - make sure this is an array for the later ksort
648 648
 
649
-		if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first
649
+		if (isset ($this->layout_defs ['subpanel_setup'])) // bug 17434 - belts-and-braces - check that we have some subpanels first
650 650
 		{
651 651
 			//retrieve list of hidden subpanels
652 652
 			$hidden_panels = $this->get_hidden_subpanels();
653 653
 
654 654
 			//activities is a special use case in that if it is hidden,
655 655
 			//then the history tab should be hidden too.
656
-			if(!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities',$hidden_panels)){
656
+			if (!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities', $hidden_panels)) {
657 657
 				//add history to list hidden_panels
658 658
 				$hidden_panels['history'] = 'history';
659 659
 			}
660 660
 
661
-			foreach ( $this->layout_defs [ 'subpanel_setup' ] as $key => $values_array )
661
+			foreach ($this->layout_defs ['subpanel_setup'] as $key => $values_array)
662 662
 			{
663 663
 				//exclude if this subpanel is hidden from admin screens
664 664
                 $module = $key;
665
-                if ( isset($values_array['module']) )
665
+                if (isset($values_array['module']))
666 666
                     $module = strtolower($values_array['module']);
667
-				 if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){
667
+				 if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels))) {
668 668
 				 	//this panel is hidden, skip it
669 669
 				 	continue;
670 670
 				 }
671 671
 
672 672
 				// make sure the module attribute is set, else none of this works...
673
-				if ( !isset($values_array [ 'module' ])) {
674
-					$GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>" . var_export($values_array,true) . " - ingoring subpanel defintion") ;
673
+				if (!isset($values_array ['module'])) {
674
+					$GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>".var_export($values_array, true)." - ingoring subpanel defintion");
675 675
 					continue;
676 676
 				}
677 677
 
678 678
 				//check permissions.
679
-				$exempt = array_key_exists ( $values_array [ 'module' ], $modules_exempt_from_availability_check ) ;
680
-				$ok = $exempt || ( (! ACLController::moduleSupportsACL ( $values_array [ 'module' ] ) || ACLController::checkAccess ( $values_array [ 'module' ], 'list', true ) ) ) ;
679
+				$exempt = array_key_exists($values_array ['module'], $modules_exempt_from_availability_check);
680
+				$ok = $exempt || ((!ACLController::moduleSupportsACL($values_array ['module']) || ACLController::checkAccess($values_array ['module'], 'list', true)));
681 681
 
682
-				$GLOBALS [ 'log' ]->debug ( "SubPanelDefinitions->get_available_tabs(): " . $key . "= " . ( $exempt ? "exempt " : "not exempt " .( $ok ? " ACL OK" : "" ) ) ) ;
682
+				$GLOBALS ['log']->debug("SubPanelDefinitions->get_available_tabs(): ".$key."= ".($exempt ? "exempt " : "not exempt ".($ok ? " ACL OK" : "")));
683 683
 
684
-				if ( $ok )
684
+				if ($ok)
685 685
 				{
686
-					while ( ! empty ( $this->_visible_tabs_array [ $values_array [ 'order' ] ] ) )
686
+					while (!empty ($this->_visible_tabs_array [$values_array ['order']]))
687 687
 					{
688
-						$values_array [ 'order' ] ++ ;
688
+						$values_array ['order']++;
689 689
 					}
690 690
 
691
-					$this->_visible_tabs_array [ $values_array ['order'] ] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key ;
691
+					$this->_visible_tabs_array [$values_array ['order']] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key;
692 692
 				}
693 693
 			}
694 694
 		}
695 695
 
696
-		ksort ( $this->_visible_tabs_array ) ;
697
-		return $this->_visible_tabs_array ;
696
+		ksort($this->_visible_tabs_array);
697
+		return $this->_visible_tabs_array;
698 698
 	}
699 699
 
700 700
 	/**
@@ -708,15 +708,15 @@  discard block
 block discarded – undo
708 708
      * @return boolean|aSubPanel        Returns aSubPanel object or boolean false if one is not found or it can't be
709 709
      *      displayed due to ACL reasons.
710 710
 	 */
711
-	function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() )
711
+	function load_subpanel($name, $reload = false, $original_only = false, $search_query = '', $collections = array())
712 712
 	{
713
-		if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ]))
713
+		if (!is_dir('modules/'.$this->layout_defs ['subpanel_setup'][strtolower($name)] ['module']))
714 714
 			return false;
715 715
 
716
-		$subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ;
716
+		$subpanel = new aSubPanel($name, $this->layout_defs ['subpanel_setup'] [strtolower($name)], $this->_focus, $reload, $original_only, $search_query, $collections);
717 717
 
718 718
 		// only return the subpanel object if we can display it.
719
-		if($subpanel->canDisplay == true) {
719
+		if ($subpanel->canDisplay == true) {
720 720
 			return $subpanel;
721 721
 		}
722 722
 
@@ -727,23 +727,23 @@  discard block
 block discarded – undo
727 727
 	/**
728 728
 	 * Load the layout def file and associate the definition with a variable in the file.
729 729
 	 */
730
-	function open_layout_defs ( $reload = false , $layout_def_key = '' , $original_only = false )
730
+	function open_layout_defs($reload = false, $layout_def_key = '', $original_only = false)
731 731
 	{
732
-		$layout_defs [ $this->_focus->module_dir ] = array ( ) ;
733
-		$layout_defs [ $layout_def_key ] = array ( ) ;
732
+		$layout_defs [$this->_focus->module_dir] = array( );
733
+		$layout_defs [$layout_def_key] = array( );
734 734
 
735
-		if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] )))
735
+		if (empty ($this->layout_defs) || $reload || (!empty ($layout_def_key) && !isset ($layout_defs [$layout_def_key])))
736 736
 		{
737
-			if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' ))
738
-				require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ;
737
+			if (file_exists('modules/'.$this->_focus->module_dir.'/metadata/subpaneldefs.php'))
738
+				require ('modules/'.$this->_focus->module_dir.'/metadata/subpaneldefs.php');
739 739
 
740
-			if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' ))
741
-				require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ;
740
+			if (!$original_only && file_exists('custom/modules/'.$this->_focus->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'))
741
+				require ('custom/modules/'.$this->_focus->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php');
742 742
 
743
-			if (! empty ( $layout_def_key ))
744
-				$this->layout_defs = $layout_defs [ $layout_def_key ] ;
743
+			if (!empty ($layout_def_key))
744
+				$this->layout_defs = $layout_defs [$layout_def_key];
745 745
 			else
746
-				$this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ;
746
+				$this->layout_defs = $layout_defs [$this->_focus->module_dir];
747 747
 
748 748
 		}
749 749
 
@@ -754,24 +754,24 @@  discard block
 block discarded – undo
754 754
 	 * Returns true if successful, false otherwise.
755 755
 	 * Hint: Used by Campaign's DetailView.
756 756
 	 */
757
-	function exclude_tab ( $tab_name )
757
+	function exclude_tab($tab_name)
758 758
 	{
759
-		$result = false ;
759
+		$result = false;
760 760
 		//unset layout definition
761
-		if (! empty ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ))
761
+		if (!empty ($this->layout_defs ['subpanel_setup'] [$tab_name]))
762 762
 		{
763
-			unset ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ) ;
763
+			unset ($this->layout_defs ['subpanel_setup'] [$tab_name]);
764 764
 		}
765 765
 		//unset instance from _visible_tab_array
766
-		if (! empty ( $this->_visible_tabs_array ))
766
+		if (!empty ($this->_visible_tabs_array))
767 767
 		{
768
-			$key = array_search ( $tab_name, $this->_visible_tabs_array ) ;
768
+			$key = array_search($tab_name, $this->_visible_tabs_array);
769 769
 			if ($key !== false)
770 770
 			{
771
-				unset ( $this->_visible_tabs_array [ $key ] ) ;
771
+				unset ($this->_visible_tabs_array [$key]);
772 772
 			}
773 773
 		}
774
-		return $result ;
774
+		return $result;
775 775
 	}
776 776
 
777 777
 
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	 * return all available subpanels that belong to the list of tab modules.  You can optionally return all
780 780
 	 * available subpanels, and also optionally group by module (prepends the key with the bean class name).
781 781
 	 */
782
-	function get_all_subpanels( $return_tab_modules_only = true, $group_by_module = false )
782
+	function get_all_subpanels($return_tab_modules_only = true, $group_by_module = false)
783 783
 	{
784 784
 		global $moduleList, $beanFiles, $beanList, $module;
785 785
 
@@ -796,36 +796,36 @@  discard block
 block discarded – undo
796 796
 		$spd = '';
797 797
 		$spd_arr = array();
798 798
 		//iterate through modules and build subpanel array
799
-		foreach($modules_to_check as $mod_name){
799
+		foreach ($modules_to_check as $mod_name) {
800 800
 
801 801
 			//skip if module name is not in bean list, otherwise get the bean class name
802
-			if(!isset($beanList[$mod_name])) continue;
802
+			if (!isset($beanList[$mod_name])) continue;
803 803
 			$class = $beanList[$mod_name];
804 804
 
805 805
 			//skip if class name is not in file list, otherwise require the bean file and create new class
806
-			if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue;
806
+			if (!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue;
807 807
 
808 808
 			//retrieve subpanels for this bean
809 809
 			require_once($beanFiles[$class]);
810 810
 			$bean_class = new $class();
811 811
 
812 812
 			//create new subpanel definition instance and get list of tabs
813
-			$spd = new SubPanelDefinitions($bean_class) ;
813
+			$spd = new SubPanelDefinitions($bean_class);
814 814
 			$sub_tabs = $spd->get_available_tabs();
815 815
 
816 816
 			//add each subpanel to array of total subpanles
817
-			foreach( $sub_tabs as $panel_key){
817
+			foreach ($sub_tabs as $panel_key) {
818 818
 				$panel_key = strtolower($panel_key);
819 819
                 $panel_module = $panel_key;
820
-                if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) )
820
+                if (isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']))
821 821
                     $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']);
822 822
                 //if module_only flag is set, only if it is also in module array
823
-				if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue;
823
+				if ($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue;
824 824
 				$panel_key_name = $panel_module;
825 825
 
826 826
 				//group_by_key_name is set to true, then array will hold an entry for each
827 827
 				//subpanel, with the module name prepended in the key
828
-				if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name;
828
+				if ($group_by_module) $panel_key_name = $class.'_'.$panel_key_name;
829 829
 				//add panel name to subpanel array
830 830
 				$spd_arr[$panel_key_name] = $panel_module;
831 831
 			}
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 	/*
837 837
 	 * save array of hidden panels to mysettings category in config table
838 838
 	 */
839
-	function set_hidden_subpanels($panels){
839
+	function set_hidden_subpanels($panels) {
840 840
 		$administration = new Administration();
841 841
 		$serialized = base64_encode(serialize($panels));
842 842
 		$administration->saveSetting('MySettings', 'hide_subpanels', $serialized);
@@ -845,26 +845,26 @@  discard block
 block discarded – undo
845 845
 	/*
846 846
 	 * retrieve hidden subpanels
847 847
 	 */
848
-	function get_hidden_subpanels(){
848
+	function get_hidden_subpanels() {
849 849
 		global $moduleList;
850 850
 
851 851
 		//create variable as static to minimize queries
852 852
 		static $hidden_subpanels = null;
853 853
 
854 854
 		// if the static value is not already cached, then retrieve it.
855
-		if(empty($hidden_subpanels))
855
+		if (empty($hidden_subpanels))
856 856
 		{
857 857
 
858 858
 			//create Administration object and retrieve any settings for panels
859 859
 			$administration = new Administration();
860 860
 			$administration->retrieveSettings('MySettings');
861 861
 
862
-			if(isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])){
862
+			if (isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])) {
863 863
 				$hidden_subpanels = $administration->settings['MySettings_hide_subpanels'];
864 864
 				$hidden_subpanels = trim($hidden_subpanels);
865 865
 
866 866
 				//make sure serialized string is not empty
867
-				if (!empty($hidden_subpanels)){
867
+				if (!empty($hidden_subpanels)) {
868 868
 					//decode and unserialize to retrieve the array
869 869
 					$hidden_subpanels = base64_decode($hidden_subpanels);
870 870
 					$hidden_subpanels = unserialize($hidden_subpanels);
@@ -873,12 +873,12 @@  discard block
 block discarded – undo
873 873
 					//get user preference
874 874
 					//unserialize and add to array if not empty
875 875
 					$pref_hidden = array();
876
-					foreach($pref_hidden as $id => $pref_hidden_panel) {
876
+					foreach ($pref_hidden as $id => $pref_hidden_panel) {
877 877
 						$hidden_subpanels[] = $pref_hidden_panel;
878 878
 					}
879 879
 
880 880
 
881
-				}else{
881
+				} else {
882 882
 					//no settings found, return empty
883 883
 					return $hidden_subpanels;
884 884
 				}
Please login to merge, or discard this patch.
Braces   +61 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry) die ( 'Not A Valid Entry Point' ) ;
2
+if (! defined ( 'sugarEntry' ) || ! sugarEntry) {
3
+    die ( 'Not A Valid Entry Point' ) ;
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -85,7 +87,9 @@  discard block
 block discarded – undo
85 87
 
86 88
 		$this->_instance_properties = $instance_properties ;
87 89
 
88
-		if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ];
90
+		if(isset($instance_properties['collection_list' ])) {
91
+		    $this->base_collection_list = $instance_properties['collection_list' ];
92
+		}
89 93
 
90 94
 		if(!empty($collections) && isset($instance_properties['collection_list' ])){
91 95
 			foreach($instance_properties['collection_list' ] as $cname => $value){
@@ -168,8 +172,7 @@  discard block
 block discarded – undo
168 172
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
169 173
 		if(isset($GLOBALS['log'])) {
170 174
 			$GLOBALS['log']->deprecated($deprecatedMessage);
171
-		}
172
-		else {
175
+		} else {
173 176
 			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
174 177
 		}
175 178
 		self::__construct($name, $instance_properties, $parent_bean, $reload, $original_only, $search_query, $collections);
@@ -291,7 +294,9 @@  discard block
 block discarded – undo
291 294
 				}
292 295
 			}
293 296
 			// if it's empty just dump out as there is nothing to process.
294
-			if(empty($this->sub_subpanels)) return false;
297
+			if(empty($this->sub_subpanels)) {
298
+			    return false;
299
+			}
295 300
 			//Sync displayed list fields across the subpanels
296 301
 			$display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels);
297 302
 			$query_fields = array();
@@ -305,10 +310,11 @@  discard block
 block discarded – undo
305 310
 					if (isset($def['vname']) && isset($def['width']))
306 311
 					{
307 312
 						$index++;
308
-						if(!empty($def['alias']))
309
-							$listFieldMap[$key][$def['alias']] = $field;
310
-						else
311
-							$listFieldMap[$key][$field] = $field;
313
+						if(!empty($def['alias'])) {
314
+													$listFieldMap[$key][$def['alias']] = $field;
315
+						} else {
316
+													$listFieldMap[$key][$field] = $field;
317
+						}
312 318
 						if (!isset($display_fields[$def['vname']]))
313 319
 						{
314 320
 							if(sizeof($display_fields) > $index)
@@ -346,13 +352,11 @@  discard block
 block discarded – undo
346 352
 					if (isset($subpanel->panel_definition['list_fields'][$field]))
347 353
 					{
348 354
 						$list_fields[$field] = $subpanel->panel_definition['list_fields'][$field];
349
-					}
350
-					else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key]))
355
+					} else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key]))
351 356
 					{
352 357
 						$list_fields[$list_key] = $subpanel->panel_definition['list_fields'][$list_key];
353 358
 
354
-					}
355
-					else {
359
+					} else {
356 360
 						$list_fields[$field] = $display_fields[$vname];
357 361
 					}
358 362
 				}
@@ -361,8 +365,7 @@  discard block
 block discarded – undo
361 365
 					if (isset($subpanel->panel_definition['list_fields'][$field]))
362 366
 					{
363 367
 						$list_fields[$field] = $subpanel->panel_definition['list_fields'][$field];
364
-					}
365
-					else {
368
+					} else {
366 369
 						$list_fields[$field] = $def;
367 370
 					}
368 371
 				}
@@ -638,18 +641,22 @@  discard block
 block discarded – undo
638 641
 		global $modListHeader ;
639 642
 		global $modules_exempt_from_availability_check ;
640 643
 
641
-		if (isset ( $this->_visible_tabs_array ))
642
-			return $this->_visible_tabs_array ;
644
+		if (isset ( $this->_visible_tabs_array )) {
645
+					return $this->_visible_tabs_array ;
646
+		}
643 647
 
644
-		if (empty($modListHeader))
645
-		    $modListHeader = query_module_access_list($GLOBALS['current_user']);
648
+		if (empty($modListHeader)) {
649
+				    $modListHeader = query_module_access_list($GLOBALS['current_user']);
650
+		}
646 651
 
647 652
 		$this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort
648 653
 
649
-		if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first
654
+		if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) {
655
+		    // bug 17434 - belts-and-braces - check that we have some subpanels first
650 656
 		{
651 657
 			//retrieve list of hidden subpanels
652 658
 			$hidden_panels = $this->get_hidden_subpanels();
659
+		}
653 660
 
654 661
 			//activities is a special use case in that if it is hidden,
655 662
 			//then the history tab should be hidden too.
@@ -662,8 +669,9 @@  discard block
 block discarded – undo
662 669
 			{
663 670
 				//exclude if this subpanel is hidden from admin screens
664 671
                 $module = $key;
665
-                if ( isset($values_array['module']) )
666
-                    $module = strtolower($values_array['module']);
672
+                if ( isset($values_array['module']) ) {
673
+                                    $module = strtolower($values_array['module']);
674
+                }
667 675
 				 if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){
668 676
 				 	//this panel is hidden, skip it
669 677
 				 	continue;
@@ -710,8 +718,9 @@  discard block
 block discarded – undo
710 718
 	 */
711 719
 	function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() )
712 720
 	{
713
-		if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ]))
714
-			return false;
721
+		if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ])) {
722
+					return false;
723
+		}
715 724
 
716 725
 		$subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ;
717 726
 
@@ -734,16 +743,19 @@  discard block
 block discarded – undo
734 743
 
735 744
 		if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] )))
736 745
 		{
737
-			if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' ))
738
-				require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ;
746
+			if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' )) {
747
+							require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ;
748
+			}
739 749
 
740
-			if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' ))
741
-				require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ;
750
+			if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' )) {
751
+							require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ;
752
+			}
742 753
 
743
-			if (! empty ( $layout_def_key ))
744
-				$this->layout_defs = $layout_defs [ $layout_def_key ] ;
745
-			else
746
-				$this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ;
754
+			if (! empty ( $layout_def_key )) {
755
+							$this->layout_defs = $layout_defs [ $layout_def_key ] ;
756
+			} else {
757
+							$this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ;
758
+			}
747 759
 
748 760
 		}
749 761
 
@@ -799,11 +811,15 @@  discard block
 block discarded – undo
799 811
 		foreach($modules_to_check as $mod_name){
800 812
 
801 813
 			//skip if module name is not in bean list, otherwise get the bean class name
802
-			if(!isset($beanList[$mod_name])) continue;
814
+			if(!isset($beanList[$mod_name])) {
815
+			    continue;
816
+			}
803 817
 			$class = $beanList[$mod_name];
804 818
 
805 819
 			//skip if class name is not in file list, otherwise require the bean file and create new class
806
-			if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue;
820
+			if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) {
821
+			    continue;
822
+			}
807 823
 
808 824
 			//retrieve subpanels for this bean
809 825
 			require_once($beanFiles[$class]);
@@ -817,15 +833,20 @@  discard block
 block discarded – undo
817 833
 			foreach( $sub_tabs as $panel_key){
818 834
 				$panel_key = strtolower($panel_key);
819 835
                 $panel_module = $panel_key;
820
-                if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) )
821
-                    $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']);
836
+                if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) ) {
837
+                                    $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']);
838
+                }
822 839
                 //if module_only flag is set, only if it is also in module array
823
-				if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue;
840
+				if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) {
841
+				    continue;
842
+				}
824 843
 				$panel_key_name = $panel_module;
825 844
 
826 845
 				//group_by_key_name is set to true, then array will hold an entry for each
827 846
 				//subpanel, with the module name prepended in the key
828
-				if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name;
847
+				if($group_by_module) {
848
+				    $panel_key_name = $class.'_'.$panel_key_name;
849
+				}
829 850
 				//add panel name to subpanel array
830 851
 				$spd_arr[$panel_key_name] = $panel_module;
831 852
 			}
@@ -878,12 +899,11 @@  discard block
 block discarded – undo
878 899
 					}
879 900
 
880 901
 
881
-				}else{
902
+				} else{
882 903
 					//no settings found, return empty
883 904
 					return $hidden_subpanels;
884 905
 				}
885
-			}
886
-			else
906
+			} else
887 907
 			{	//no settings found, return empty
888 908
 				return $hidden_subpanels;
889 909
 			}
Please login to merge, or discard this patch.
include/SubPanel/SubPanelSearchForm.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
 
8 8
 require_once('include/SearchForm/SearchForm2.php');
9 9
 
10
-class SubPanelSearchForm extends SearchForm  {
10
+class SubPanelSearchForm extends SearchForm {
11 11
 
12 12
     var $subPanel; // the instantiated bean of the subPanel
13 13
 
14
-    function __construct($seed, $module, $subPanel, $options = array()){
14
+    function __construct($seed, $module, $subPanel, $options = array()) {
15 15
         $this->subPanel = $subPanel;
16 16
         parent::__construct($seed, $module, 'DetailView', $options);
17 17
     }
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
21 21
      */
22
-    function SubPanelSearchForm($seed, $module, $subPanel, $options = array()){
22
+    function SubPanelSearchForm($seed, $module, $subPanel, $options = array()) {
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24
-        if(isset($GLOBALS['log'])) {
24
+        if (isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26 26
         }
27 27
         else {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     }
32 32
 
33 33
 
34
-    function display($header = false){
34
+    function display($header = false) {
35 35
         /*//global $app_list_strings;
36 36
         if($this->subPanel->subpanel_defs->isCollection() && isset($this->subPanel->subpanel_defs->base_collection_list)){
37 37
             $GLOBALS['app_list_strings']['collection_temp_list'] = $this->getCollectionList($this->subPanel->subpanel_defs->base_collection_list);
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
         $this->th->ss->assign('subpanel', $this->subPanel->subpanel_id);
40 40
 
41 41
         // Adding the offset to subpanel search field - this has no affect on pagination
42
-        if($this->subPanel->parent_bean->module_dir != ''){
42
+        if ($this->subPanel->parent_bean->module_dir != '') {
43 43
             $this->th->ss->assign('subpanelPageOffset', '<input type="hidden" name="'.$this->subPanel->parent_bean->module_dir.'_'.$this->subPanel->subpanel_id.'_CELL_offset" value="0" />');
44 44
         }
45 45
         $this->parsedView = 'sps';
46 46
         return parent::display($header);
47 47
     }
48 48
 
49
-    function getCollectionList($collection = array()){
49
+    function getCollectionList($collection = array()) {
50 50
         global $app_list_strings;
51 51
 
52 52
         $select = array();
53 53
 
54
-        if(!empty($collection)){
54
+        if (!empty($collection)) {
55 55
 
56 56
             $select = array();
57
-            foreach($collection as $name => $value_array){
58
-                if(isset($app_list_strings['moduleList'][$value_array['module']])){
57
+            foreach ($collection as $name => $value_array) {
58
+                if (isset($app_list_strings['moduleList'][$value_array['module']])) {
59 59
                     $select[$name] = $app_list_strings['moduleList'][$value_array['module']];
60 60
                 }
61 61
             }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         return $select;
64 64
     }
65 65
 
66
-    function displaySavedSearchSelect(){
66
+    function displaySavedSearchSelect() {
67 67
         return null;
68 68
     }
69 69
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
include/TemplateHandler/TemplateHandler.php 2 patches
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
     /**
58 58
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
59 59
      */
60
-    public function TemplateHandler(){
60
+    public function TemplateHandler() {
61 61
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
62
-        if(isset($GLOBALS['log'])) {
62
+        if (isset($GLOBALS['log'])) {
63 63
             $GLOBALS['log']->deprecated($deprecatedMessage);
64 64
         }
65 65
         else {
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
     }
70 70
 
71 71
 
72
-    function loadSmarty(){
73
-        if(empty($this->ss)){
72
+    function loadSmarty() {
73
+        if (empty($this->ss)) {
74 74
             $this->ss = new Sugar_Smarty();
75 75
         }
76 76
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     static function clearAll() {
85 85
     	global $beanList;
86
-		foreach($beanList as $module_dir =>$object_name){
86
+		foreach ($beanList as $module_dir =>$object_name) {
87 87
                 TemplateHandler::clearCache($module_dir);
88 88
 		}
89 89
     }
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
      * @param String $module The module directory to clear
97 97
      * @param String $view Optional view value (DetailView, EditView, etc.)
98 98
      */
99
-    static function clearCache($module, $view=''){
100
-        $cacheDir = create_cache_directory('modules/'. $module . '/');
99
+    static function clearCache($module, $view = '') {
100
+        $cacheDir = create_cache_directory('modules/'.$module.'/');
101 101
         $d = dir($cacheDir);
102
-        while($e = $d->read()){
103
-            if(!empty($view) && $e != $view )continue;
104
-            $end =strlen($e) - 4;
105
-            if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
106
-                unlink($cacheDir . $e);
102
+        while ($e = $d->read()) {
103
+            if (!empty($view) && $e != $view)continue;
104
+            $end = strlen($e) - 4;
105
+            if (is_file($cacheDir.$e) && $end > 1 && substr($e, $end) == '.tpl') {
106
+                unlink($cacheDir.$e);
107 107
             }
108 108
         }
109 109
     }
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
     function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs) {
122 122
         $this->loadSmarty();
123 123
 
124
-        $cacheDir = create_cache_directory($this->templateDir. $module . '/');
125
-        $file = $cacheDir . $view . '.tpl';
126
-        $string = '{* Create Date: ' . date('Y-m-d H:i:s') . "*}\n";
124
+        $cacheDir = create_cache_directory($this->templateDir.$module.'/');
125
+        $file = $cacheDir.$view.'.tpl';
126
+        $string = '{* Create Date: '.date('Y-m-d H:i:s')."*}\n";
127 127
         $this->ss->left_delimiter = '{{';
128 128
         $this->ss->right_delimiter = '}}';
129 129
         $this->ss->assign('module', $module);
130 130
         $this->ss->assign('built_in_buttons', array('CANCEL', 'DELETE', 'DUPLICATE', 'EDIT', 'FIND_DUPLICATES', 'SAVE', 'CONNECTOR'));
131 131
         $contents = $this->ss->fetch($tpl);
132 132
         //Insert validation and quicksearch stuff here
133
-        if($view == 'EditView' || strpos($view,'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
133
+        if ($view == 'EditView' || strpos($view, 'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
134 134
 
135 135
             global $dictionary, $beanList, $app_strings, $mod_strings;
136 136
             $mod = $beanList[$module];
137 137
 
138
-            if($mod == 'aCase') {
138
+            if ($mod == 'aCase') {
139 139
                 $mod = 'Case';
140 140
             }
141 141
 
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
             //Retrieve all panel field definitions with displayParams Array field set
145 145
             $panelFields = array();
146 146
 
147
-            foreach($metaDataDefs['panels'] as $panel) {
148
-                    foreach($panel as $row) {
149
-                            foreach($row as $entry) {
150
-                                    if(empty($entry)) {
147
+            foreach ($metaDataDefs['panels'] as $panel) {
148
+                    foreach ($panel as $row) {
149
+                            foreach ($row as $entry) {
150
+                                    if (empty($entry)) {
151 151
                                        continue;
152 152
                                     }
153 153
 
154
-                                    if(is_array($entry) &&
154
+                                    if (is_array($entry) &&
155 155
                                        isset($entry['name']) &&
156 156
                                        isset($entry['displayParams']) &&
157 157
                                        isset($entry['displayParams']['required']) &&
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                                        $panelFields[$entry['name']] = $entry;
160 160
                                     }
161 161
 
162
-                                    if(is_array($entry)) {
162
+                                    if (is_array($entry)) {
163 163
                                       $defs2[$entry['name']] = $entry;
164 164
                                     } else {
165 165
                                       $defs2[$entry] = array('name' => $entry);
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
                     } //foreach
169 169
             } //foreach
170 170
 
171
-            foreach($panelFields as $field=>$value) {
171
+            foreach ($panelFields as $field=>$value) {
172 172
                       $nameList = array();
173
-                      if(!is_array($value['displayParams']['required'])) {
173
+                      if (!is_array($value['displayParams']['required'])) {
174 174
                          $nameList[] = $field;
175 175
                       } else {
176
-                         foreach($value['displayParams']['required'] as $groupedField) {
176
+                         foreach ($value['displayParams']['required'] as $groupedField) {
177 177
                                  $nameList[] = $groupedField;
178 178
                          }
179 179
                       }
180 180
 
181
-                      foreach($nameList as $x) {
182
-                         if(isset($defs[$x]) &&
181
+                      foreach ($nameList as $x) {
182
+                         if (isset($defs[$x]) &&
183 183
                             isset($defs[$x]['type']) &&
184 184
                             !isset($defs[$x]['required'])) {
185 185
                             $defs[$x]['required'] = true;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
             $javascript->setSugarBean($sugarbean);
200 200
             if ($view != "ConvertLead")
201
-                $javascript->addAllFields('', null,true);
201
+                $javascript->addAllFields('', null, true);
202 202
 
203 203
             $validatedFields = array();
204 204
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -209,20 +209,20 @@  discard block
 block discarded – undo
209 209
             //3) not have validateDepedency set to false in metadata
210 210
             //4) have id_name in vardef entry
211 211
             //5) not already been added to Array
212
-            foreach($sugarbean->field_name_map as $name=>$def) {
212
+            foreach ($sugarbean->field_name_map as $name=>$def) {
213 213
 
214
-               if($def['type']=='relate' &&
214
+               if ($def['type'] == 'relate' &&
215 215
                   isset($defs2[$name]) &&
216 216
                   (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) &&
217 217
                   isset($def['id_name']) &&
218 218
                   !in_array($name, $validatedFields)) {
219 219
 
220
-                  if(isset($mod_strings[$def['vname']])
220
+                  if (isset($mod_strings[$def['vname']])
221 221
                         || isset($app_strings[$def['vname']])
222
-                        || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
222
+                        || translate($def['vname'], $sugarbean->module_dir) != $def['vname']) {
223 223
                      $vname = $def['vname'];
224 224
                   }
225
-                  else{
225
+                  else {
226 226
                      $vname = "undefined";
227 227
                   }
228 228
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
             $contents .= $javascript->getScript();
235 235
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
236 236
             $contents .= "{/literal}\n";
237
-        }else if(preg_match('/^SearchForm_.+/', $view)){
237
+        } else if (preg_match('/^SearchForm_.+/', $view)) {
238 238
             global $dictionary, $beanList, $app_strings, $mod_strings;
239 239
             $mod = $beanList[$module];
240 240
 
241
-            if($mod == 'aCase') {
241
+            if ($mod == 'aCase') {
242 242
                 $mod = 'Case';
243 243
             }
244 244
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         //Remove all the copyright comments
252 252
         $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents);
253 253
 
254
-        if($fh = @sugar_fopen($file, 'w')) {
254
+        if ($fh = @sugar_fopen($file, 'w')) {
255 255
             fputs($fh, $contents);
256 256
             fclose($fh);
257 257
         }
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
      * @param module string module name
268 268
      * @param view string view need (eg DetailView, EditView, etc)
269 269
      */
270
-    function checkTemplate($module, $view, $checkFormName = false, $formName='') {
271
-        if(inDeveloperMode() || !empty($_SESSION['developerMode'])){
270
+    function checkTemplate($module, $view, $checkFormName = false, $formName = '') {
271
+        if (inDeveloperMode() || !empty($_SESSION['developerMode'])) {
272 272
             return false;
273 273
         }
274 274
         $view = $checkFormName ? $formName : $view;
275
-        return file_exists($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
275
+        return file_exists($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
276 276
     }
277 277
 
278 278
     /**
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
      */
287 287
     function displayTemplate($module, $view, $tpl, $ajaxSave = false, $metaDataDefs = null) {
288 288
         $this->loadSmarty();
289
-        if(!$this->checkTemplate($module, $view)) {
289
+        if (!$this->checkTemplate($module, $view)) {
290 290
             $this->buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs);
291 291
         }
292
-        $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
293
-        if(file_exists($file)) {
292
+        $file = $this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl';
293
+        if (file_exists($file)) {
294 294
            return $this->ss->fetch($file);
295 295
         } else {
296 296
            global $app_strings;
297
-           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
298
-           return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
297
+           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'].": $file");
298
+           return $app_strings['ERR_NO_SUCH_FILE'].": $file";
299 299
         }
300 300
     }
301 301
 
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
      * @param view string view need (eg DetailView, EditView, etc)
307 307
      */
308 308
     function deleteTemplate($module, $view) {
309
-        if(is_file($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl')) {
309
+        if (is_file($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl')) {
310 310
             // Bug #54634 : RTC 18144 : Cannot add more than 1 user to role but popup is multi-selectable
311
-            if ( !isset($this->ss) )
311
+            if (!isset($this->ss))
312 312
             {
313 313
                 $this->loadSmarty();
314 314
             }
315
-            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
315
+            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
316 316
             SugarCache::cleanFile($cache_file_name);
317 317
 
318
-            return unlink($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
318
+            return unlink($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
319 319
         }
320 320
         return false;
321 321
     }
@@ -332,47 +332,47 @@  discard block
 block discarded – undo
332 332
      * @param strign $module
333 333
      * @return string
334 334
      */
335
-    public function createQuickSearchCode($defs, $defs2, $view = '', $module='')
335
+    public function createQuickSearchCode($defs, $defs2, $view = '', $module = '')
336 336
     {
337 337
         $sqs_objects = array();
338 338
         require_once('include/QuickSearchDefaults.php');
339
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
339
+        if (isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
340 340
         {
341 341
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
342
-        }else
342
+        } else
343 343
         {
344 344
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
345 345
         }
346 346
         $qsd->setFormName($view);
347
-        if(preg_match('/^SearchForm_.+/', $view)){
348
-        	if(strpos($view, 'popup_query_form')){
347
+        if (preg_match('/^SearchForm_.+/', $view)) {
348
+        	if (strpos($view, 'popup_query_form')) {
349 349
         		$qsd->setFormName('popup_query_form');
350 350
             	$parsedView = 'advanced';
351
-        	}else{
351
+        	} else {
352 352
         		$qsd->setFormName('search_form');
353 353
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
354 354
         	}
355 355
             //Loop through the Meta-Data fields to see which ones need quick search support
356
-            foreach($defs as $f) {
356
+            foreach ($defs as $f) {
357 357
                 $field = $f;
358
-                $name = $qsd->form_name . '_' . $field['name'];
358
+                $name = $qsd->form_name.'_'.$field['name'];
359 359
 
360
-                if($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si',$name)  || !empty($field['quicksearch']) ) {
361
-                    if(preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
360
+                if ($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch'])) {
361
+                    if (preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
362 362
 
363
-                        if($matches[0] == 'Campaigns') {
363
+                        if ($matches[0] == 'Campaigns') {
364 364
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
365
-                        } else if($matches[0] == 'Users'){
365
+                        } else if ($matches[0] == 'Users') {
366 366
 
367
-                            if(!empty($f['name']) && !empty($f['id_name'])) {
368
-                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
367
+                            if (!empty($f['name']) && !empty($f['id_name'])) {
368
+                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'], $f['id_name']);
369 369
                             }
370 370
                             else {
371 371
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
372 372
                             }
373
-                        } else if($matches[0] == 'Campaigns') {
373
+                        } else if ($matches[0] == 'Campaigns') {
374 374
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
375
-                        } else if($matches[0] == 'Accounts') {
375
+                        } else if ($matches[0] == 'Accounts') {
376 376
                             $nameKey = $name;
377 377
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
378 378
 
@@ -385,12 +385,12 @@  discard block
 block discarded – undo
385 385
                             $shippingKey = isset($f['displayParams']['shippingKey']) ? $f['displayParams']['shippingKey'] : null;
386 386
                             $additionalFields = isset($f['displayParams']['additionalFields']) ? $f['displayParams']['additionalFields'] : null;
387 387
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
388
-                        } else if($matches[0] == 'Contacts'){
388
+                        } else if ($matches[0] == 'Contacts') {
389 389
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
390 390
                         }
391 391
                     } else {
392 392
                          $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
393
-                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
393
+                         if (!isset($field['field_list']) && !isset($field['populate_list'])) {
394 394
                              $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
395 395
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
396 396
                          } else {
@@ -398,63 +398,63 @@  discard block
 block discarded – undo
398 398
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
399 399
                          }
400 400
                     }
401
-                } else if($field['type'] == 'parent') {
401
+                } else if ($field['type'] == 'parent') {
402 402
                     $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent();
403 403
                 } //if-else
404 404
             } //foreach
405 405
 
406
-            foreach ( $sqs_objects as $name => $field )
407
-               foreach ( $field['populate_list'] as $key => $fieldname )
408
-                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
409
-        }else{
406
+            foreach ($sqs_objects as $name => $field)
407
+               foreach ($field['populate_list'] as $key => $fieldname)
408
+                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key].'_'.$parsedView;
409
+        } else {
410 410
             //Loop through the Meta-Data fields to see which ones need quick search support
411
-            foreach($defs2 as $f) {
412
-                if(!isset($defs[$f['name']])) continue;
411
+            foreach ($defs2 as $f) {
412
+                if (!isset($defs[$f['name']])) continue;
413 413
 
414 414
                 $field = $defs[$f['name']];
415 415
                 if ($view == "ConvertLead")
416 416
                 {
417
-                    $field['name'] = $module . $field['name'];
417
+                    $field['name'] = $module.$field['name'];
418 418
                     if (isset($field['module']) && isset($field['id_name']) && substr($field['id_name'], -4) == "_ida") {
419 419
                         $lc_module = strtolower($field['module']);
420 420
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
421 421
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
422
-                            $field['id_name'] = $module . $field['id_name'];
422
+                            $field['id_name'] = $module.$field['id_name'];
423 423
                         }
424 424
                         else
425
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
425
+                            $field['id_name'] = $field['name']."_".$field['id_name'];
426 426
                     }
427 427
                     else {
428 428
                         if (!empty($field['id_name']))
429 429
                             $field['id_name'] = $module.$field['id_name'];
430 430
                     }
431 431
                 }
432
-				$name = $qsd->form_name . '_' . $field['name'];
432
+				$name = $qsd->form_name.'_'.$field['name'];
433 433
 
434 434
 
435
-                if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) {
436
-                    if (!preg_match('/_c$/si',$name)
437
-                        && (!isset($field['id_name']) || !preg_match('/_c$/si',$field['id_name']))
435
+                if ($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch']))) {
436
+                    if (!preg_match('/_c$/si', $name)
437
+                        && (!isset($field['id_name']) || !preg_match('/_c$/si', $field['id_name']))
438 438
                         && preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)
439 439
                     ) {
440 440
 
441
-                        if($matches[0] == 'Campaigns') {
441
+                        if ($matches[0] == 'Campaigns') {
442 442
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
443
-                        } else if($matches[0] == 'Users'){
444
-                            if($field['name'] == 'reports_to_name'){
445
-                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
443
+                        } else if ($matches[0] == 'Users') {
444
+                            if ($field['name'] == 'reports_to_name') {
445
+                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name', 'reports_to_id');
446 446
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
447
-                            }elseif($field['name'] == 'assigned_user_name'){
448
-                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
447
+                            }elseif ($field['name'] == 'assigned_user_name') {
448
+                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name', 'assigned_user_id');
449 449
                              }
450 450
                              else
451 451
                              {
452 452
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
453 453
 
454 454
 							}
455
-                        } else if($matches[0] == 'Campaigns') {
455
+                        } else if ($matches[0] == 'Campaigns') {
456 456
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
457
-                        } else if($matches[0] == 'Accounts') {
457
+                        } else if ($matches[0] == 'Accounts') {
458 458
                             $nameKey = $name;
459 459
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
460 460
 
@@ -467,15 +467,15 @@  discard block
 block discarded – undo
467 467
                             $shippingKey = SugarArray::staticGet($f, 'displayParams.shippingKey');
468 468
                             $additionalFields = SugarArray::staticGet($f, 'displayParams.additionalFields');
469 469
                             $sqs_objects[$name] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
470
-                        } else if($matches[0] == 'Contacts'){
470
+                        } else if ($matches[0] == 'Contacts') {
471 471
                             $sqs_objects[$name] = $qsd->getQSContact($field['name'], $field['id_name']);
472
-                            if(preg_match('/_c$/si',$name) || !empty($field['quicksearch'])){
472
+                            if (preg_match('/_c$/si', $name) || !empty($field['quicksearch'])) {
473 473
                                 $sqs_objects[$name]['field_list'] = array('salutation', 'first_name', 'last_name', 'id');
474 474
                             }
475 475
                         }
476 476
                     } else {
477 477
                         $sqs_objects[$name] = $qsd->getQSParent($field['module']);
478
-                        if(!isset($field['field_list']) && !isset($field['populate_list'])) {
478
+                        if (!isset($field['field_list']) && !isset($field['populate_list'])) {
479 479
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
480 480
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
481 481
                             if (!isset($field['rname']))
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
                             {
485 485
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
486 486
                                 $sqs_objects[$name]['order'] = $field['rname'];
487
-                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'],'op'=>'like_custom','end'=>'%','value'=>''));
487
+                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'], 'op'=>'like_custom', 'end'=>'%', 'value'=>''));
488 488
                             }
489 489
                         } else {
490 490
                             $sqs_objects[$name]['populate_list'] = $field['field_list'];
491 491
                             $sqs_objects[$name]['field_list'] = $field['populate_list'];
492 492
                         }
493 493
                     }
494
-                } else if($field['type'] == 'parent') {
494
+                } else if ($field['type'] == 'parent') {
495 495
                     $sqs_objects[$name] = $qsd->getQSParent();
496 496
                 } //if-else
497 497
 
@@ -501,13 +501,13 @@  discard block
 block discarded – undo
501 501
 
502 502
                 //merge populate_list && field_list with vardef
503 503
                 if (!empty($field['field_list']) && !empty($field['populate_list'])) {
504
-                    for ($j=0; $j<count($field['field_list']); $j++) {
504
+                    for ($j = 0; $j < count($field['field_list']); $j++) {
505 505
                 		//search for the same couple (field_list_item,populate_field_item)
506 506
                			$field_list_item = $field['field_list'][$j];
507
-               			$field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
507
+               			$field_list_item_alternate = $qsd->form_name.'_'.$field['field_list'][$j];
508 508
                			$populate_list_item = $field['populate_list'][$j];
509 509
                 		$found = false;
510
-                		for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
510
+                		for ($k = 0; $k < count($sqs_objects[$name]['field_list']); $k++) {
511 511
                 			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)
512 512
                 				$populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
513 513
                 				$found = true;
@@ -525,14 +525,14 @@  discard block
 block discarded – undo
525 525
         }
526 526
 
527 527
        //Implement QuickSearch for the field
528
-       if(!empty($sqs_objects) && count($sqs_objects) > 0) {
528
+       if (!empty($sqs_objects) && count($sqs_objects) > 0) {
529 529
            $quicksearch_js = '<script language="javascript">';
530
-           $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
530
+           $quicksearch_js .= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
531 531
            $json = getJSONobj();
532
-           foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
532
+           foreach ($sqs_objects as $sqsfield=>$sqsfieldArray) {
533 533
                $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
534 534
            }
535
-           return $quicksearch_js . '</script>';
535
+           return $quicksearch_js.'</script>';
536 536
        }
537 537
        return '';
538 538
     }
Please login to merge, or discard this patch.
Braces   +33 added lines, -29 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@  discard block
 block discarded – undo
61 61
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
62 62
         if(isset($GLOBALS['log'])) {
63 63
             $GLOBALS['log']->deprecated($deprecatedMessage);
64
-        }
65
-        else {
64
+        } else {
66 65
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
67 66
         }
68 67
         self::__construct();
@@ -100,7 +99,9 @@  discard block
 block discarded – undo
100 99
         $cacheDir = create_cache_directory('modules/'. $module . '/');
101 100
         $d = dir($cacheDir);
102 101
         while($e = $d->read()){
103
-            if(!empty($view) && $e != $view )continue;
102
+            if(!empty($view) && $e != $view ) {
103
+                continue;
104
+            }
104 105
             $end =strlen($e) - 4;
105 106
             if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
106 107
                 unlink($cacheDir . $e);
@@ -197,8 +198,9 @@  discard block
 block discarded – undo
197 198
             $javascript->setFormName($view);
198 199
 
199 200
             $javascript->setSugarBean($sugarbean);
200
-            if ($view != "ConvertLead")
201
-                $javascript->addAllFields('', null,true);
201
+            if ($view != "ConvertLead") {
202
+                            $javascript->addAllFields('', null,true);
203
+            }
202 204
 
203 205
             $validatedFields = array();
204 206
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -221,8 +223,7 @@  discard block
 block discarded – undo
221 223
                         || isset($app_strings[$def['vname']])
222 224
                         || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
223 225
                      $vname = $def['vname'];
224
-                  }
225
-                  else{
226
+                  } else{
226 227
                      $vname = "undefined";
227 228
                   }
228 229
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -234,7 +235,7 @@  discard block
 block discarded – undo
234 235
             $contents .= $javascript->getScript();
235 236
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
236 237
             $contents .= "{/literal}\n";
237
-        }else if(preg_match('/^SearchForm_.+/', $view)){
238
+        } else if(preg_match('/^SearchForm_.+/', $view)){
238 239
             global $dictionary, $beanList, $app_strings, $mod_strings;
239 240
             $mod = $beanList[$module];
240 241
 
@@ -336,10 +337,12 @@  discard block
 block discarded – undo
336 337
     {
337 338
         $sqs_objects = array();
338 339
         require_once('include/QuickSearchDefaults.php');
339
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
340
+        if(isset($this) && $this instanceof TemplateHandler) {
341
+            //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
340 342
         {
341 343
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
342
-        }else
344
+        }
345
+        } else
343 346
         {
344 347
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
345 348
         }
@@ -348,7 +351,7 @@  discard block
 block discarded – undo
348 351
         	if(strpos($view, 'popup_query_form')){
349 352
         		$qsd->setFormName('popup_query_form');
350 353
             	$parsedView = 'advanced';
351
-        	}else{
354
+        	} else{
352 355
         		$qsd->setFormName('search_form');
353 356
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
354 357
         	}
@@ -366,8 +369,7 @@  discard block
 block discarded – undo
366 369
 
367 370
                             if(!empty($f['name']) && !empty($f['id_name'])) {
368 371
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
369
-                            }
370
-                            else {
372
+                            } else {
371 373
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
372 374
                             }
373 375
                         } else if($matches[0] == 'Campaigns') {
@@ -403,13 +405,16 @@  discard block
 block discarded – undo
403 405
                 } //if-else
404 406
             } //foreach
405 407
 
406
-            foreach ( $sqs_objects as $name => $field )
407
-               foreach ( $field['populate_list'] as $key => $fieldname )
408
+            foreach ( $sqs_objects as $name => $field ) {
409
+                           foreach ( $field['populate_list'] as $key => $fieldname )
408 410
                     $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
409
-        }else{
411
+            }
412
+        } else{
410 413
             //Loop through the Meta-Data fields to see which ones need quick search support
411 414
             foreach($defs2 as $f) {
412
-                if(!isset($defs[$f['name']])) continue;
415
+                if(!isset($defs[$f['name']])) {
416
+                    continue;
417
+                }
413 418
 
414 419
                 $field = $defs[$f['name']];
415 420
                 if ($view == "ConvertLead")
@@ -420,13 +425,13 @@  discard block
 block discarded – undo
420 425
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
421 426
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
422 427
                             $field['id_name'] = $module . $field['id_name'];
428
+                        } else {
429
+                                                    $field['id_name'] = $field['name'] . "_" . $field['id_name'];
430
+                        }
431
+                    } else {
432
+                        if (!empty($field['id_name'])) {
433
+                                                    $field['id_name'] = $module.$field['id_name'];
423 434
                         }
424
-                        else
425
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
426
-                    }
427
-                    else {
428
-                        if (!empty($field['id_name']))
429
-                            $field['id_name'] = $module.$field['id_name'];
430 435
                     }
431 436
                 }
432 437
 				$name = $qsd->form_name . '_' . $field['name'];
@@ -444,10 +449,9 @@  discard block
 block discarded – undo
444 449
                             if($field['name'] == 'reports_to_name'){
445 450
                                 $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
446 451
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
447
-                            }elseif($field['name'] == 'assigned_user_name'){
452
+                            } elseif($field['name'] == 'assigned_user_name'){
448 453
                                  $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
449
-                             }
450
-                             else
454
+                             } else
451 455
                              {
452 456
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
453 457
 
@@ -478,9 +482,9 @@  discard block
 block discarded – undo
478 482
                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
479 483
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
480 484
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
481
-                            if (!isset($field['rname']))
482
-                                $sqs_objects[$name]['field_list'] = array('name', 'id');
483
-                            else
485
+                            if (!isset($field['rname'])) {
486
+                                                            $sqs_objects[$name]['field_list'] = array('name', 'id');
487
+                            } else
484 488
                             {
485 489
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
486 490
                                 $sqs_objects[$name]['order'] = $field['rname'];
Please login to merge, or discard this patch.
include/generic/SugarWidgets/SugarWidgetFieldvarchar.php 2 patches
Spacing   +6 added lines, -6 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.
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
     /**
50 50
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
51 51
      */
52
-    function SugarWidgetFieldVarchar(&$layout_manager){
52
+    function SugarWidgetFieldVarchar(&$layout_manager) {
53 53
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
54
-        if(isset($GLOBALS['log'])) {
54
+        if (isset($GLOBALS['log'])) {
55 55
             $GLOBALS['log']->deprecated($deprecatedMessage);
56 56
         }
57 57
         else {
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 
93 93
  function queryFilterone_of(&$layout_def)
94 94
  {
95
-    foreach($layout_def['input_name0'] as $key => $value) {
95
+    foreach ($layout_def['input_name0'] as $key => $value) {
96 96
         $layout_def['input_name0'][$key] = $GLOBALS['db']->quote($value);
97 97
     }
98
-    return $this->_get_column_select($layout_def) . " IN ('" . implode("','", $layout_def['input_name0']) . "')\n";
98
+    return $this->_get_column_select($layout_def)." IN ('".implode("','", $layout_def['input_name0'])."')\n";
99 99
  }
100 100
 
101 101
  function displayInput(&$layout_def)
102 102
  {
103
- 		$str = '<input type="text" size="20" value="' . $layout_def['input_name0'] . '" name="' . $layout_def['name'] . '">';
103
+ 		$str = '<input type="text" size="20" value="'.$layout_def['input_name0'].'" name="'.$layout_def['name'].'">';
104 104
  		return $str;
105 105
  }
106 106
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.