Test Failed
Push — scrutinizer-code-quality ( fda4f9...951274 )
by Adam
53:10
created
include/database/DBManagerFactory.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                     }
81 81
                     break;
82 82
                 case "mssql":
83
-                  	if ( function_exists('sqlsrv_connect')
83
+                      if ( function_exists('sqlsrv_connect')
84 84
                                 && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv' )) {
85 85
                         $my_db_manager = 'SqlsrvManager';
86 86
                     } elseif (self::isFreeTDS()
@@ -122,20 +122,20 @@  discard block
 block discarded – undo
122 122
     }
123 123
 
124 124
     /**
125
-	 * Returns a reference to the DB object for instance $instanceName, or the default
125
+     * Returns a reference to the DB object for instance $instanceName, or the default
126 126
      * instance if one is not specified
127 127
      *
128 128
      * @param  string $instanceName optional, name of the instance
129 129
      * @return object DBManager instance
130 130
      */
131
-	public static function getInstance($instanceName = '')
131
+    public static function getInstance($instanceName = '')
132 132
     {
133 133
         global $sugar_config;
134 134
         static $count = 0, $old_count = 0;
135 135
 
136 136
         //fall back to the default instance name
137 137
         if(empty($sugar_config['db'][$instanceName])){
138
-        	$instanceName = '';
138
+            $instanceName = '';
139 139
         }
140 140
         if(!isset(self::$instances[$instanceName])){
141 141
             $config = $sugar_config['dbconfig'];
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     /**
249 249
      * Check if we have freeTDS driver installed
250 250
      * Invoked when connected to mssql. checks if we have freetds version of mssql library.
251
-	 * the response is put into a global variable.
251
+     * the response is put into a global variable.
252 252
      * @return bool
253 253
      */
254 254
     public static function isFreeTDS()
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
         static $is_freetds = null;
257 257
 
258 258
         if($is_freetds === null) {
259
-    		ob_start();
260
-    		phpinfo(INFO_MODULES);
261
-    		$info=ob_get_contents();
262
-    		ob_end_clean();
259
+            ob_start();
260
+            phpinfo(INFO_MODULES);
261
+            $info=ob_get_contents();
262
+            ob_end_clean();
263 263
 
264
-    		$is_freetds = (strpos($info,'FreeTDS') !== false);
264
+            $is_freetds = (strpos($info,'FreeTDS') !== false);
265 265
         }
266 266
 
267 267
         return $is_freetds;
268
-     }
268
+        }
269 269
 }
270 270
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 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.
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
     {
70 70
         global $sugar_config;
71 71
 
72
-        if(empty($config['db_manager'])) {
72
+        if (empty($config['db_manager'])) {
73 73
             // standard types
74
-            switch($type) {
74
+            switch ($type) {
75 75
                 case "mysql":
76 76
                     if (empty($sugar_config['mysqli_disabled']) && function_exists('mysqli_connect')) {
77 77
                         $my_db_manager = 'MysqliManager';
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
                     }
81 81
                     break;
82 82
                 case "mssql":
83
-                  	if ( function_exists('sqlsrv_connect')
84
-                                && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv' )) {
83
+                  	if (function_exists('sqlsrv_connect')
84
+                                && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv')) {
85 85
                         $my_db_manager = 'SqlsrvManager';
86 86
                     } elseif (self::isFreeTDS()
87
-                                && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds' )) {
87
+                                && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) {
88 88
                         $my_db_manager = 'FreeTDSManager';
89 89
                     } else {
90 90
                         $my_db_manager = 'MssqlManager';
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                     break;
93 93
                 default:
94 94
                     $my_db_manager = self::getManagerByType($type, false);
95
-                    if(empty($my_db_manager)) {
95
+                    if (empty($my_db_manager)) {
96 96
                         $GLOBALS['log']->fatal("unable to load DB manager for: $type");
97 97
                         sugar_die("Cannot load DB manager");
98 98
                     }
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
         // sanitize the name
105 105
         $my_db_manager = preg_replace("/[^A-Za-z0-9_-]/", "", $my_db_manager);
106 106
 
107
-        if(!empty($config['db_manager_class'])){
107
+        if (!empty($config['db_manager_class'])) {
108 108
             $my_db_manager = $config['db_manager_class'];
109 109
         } else {
110
-            if(file_exists("custom/include/database/{$my_db_manager}.php")) {
110
+            if (file_exists("custom/include/database/{$my_db_manager}.php")) {
111 111
                 require_once("custom/include/database/{$my_db_manager}.php");
112 112
             } else {
113 113
                 require_once("include/database/{$my_db_manager}.php");
114 114
             }
115 115
         }
116 116
 
117
-        if(class_exists($my_db_manager)) {
117
+        if (class_exists($my_db_manager)) {
118 118
             return new $my_db_manager();
119 119
         } else {
120 120
             return null;
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
         static $count = 0, $old_count = 0;
135 135
 
136 136
         //fall back to the default instance name
137
-        if(empty($sugar_config['db'][$instanceName])){
137
+        if (empty($sugar_config['db'][$instanceName])) {
138 138
         	$instanceName = '';
139 139
         }
140
-        if(!isset(self::$instances[$instanceName])){
140
+        if (!isset(self::$instances[$instanceName])) {
141 141
             $config = $sugar_config['dbconfig'];
142 142
             $count++;
143 143
                 self::$instances[$instanceName] = self::getTypeInstance($config['db_type'], $config);
144
-                if(!empty($sugar_config['dbconfigoption'])) {
144
+                if (!empty($sugar_config['dbconfigoption'])) {
145 145
                     self::$instances[$instanceName]->setOptions($sugar_config['dbconfigoption']);
146 146
                 }
147 147
                 self::$instances[$instanceName]->connect($config, true);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public static function disconnectAll()
161 161
     {
162
-        foreach(self::$instances as $instance) {
162
+        foreach (self::$instances as $instance) {
163 163
             $instance->disconnect();
164 164
         }
165 165
         self::$instances = array();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     public static function getManagerByType($type, $validate = true)
178 178
     {
179 179
         $drivers = self::getDbDrivers($validate);
180
-        if(!empty($drivers[$type])) {
180
+        if (!empty($drivers[$type])) {
181 181
             return get_class($drivers[$type]);
182 182
         }
183 183
         return false;
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
      */
192 192
     protected static function scanDriverDir($dir, &$drivers, $validate = true)
193 193
     {
194
-        if(!is_dir($dir)) return;
194
+        if (!is_dir($dir)) return;
195 195
         $scandir = opendir($dir);
196
-        if($scandir === false) return;
197
-        while(($name = readdir($scandir)) !== false) {
198
-            if(substr($name, -11) != "Manager.php") continue;
199
-            if($name == "DBManager.php") continue;
196
+        if ($scandir === false) return;
197
+        while (($name = readdir($scandir)) !== false) {
198
+            if (substr($name, -11) != "Manager.php") continue;
199
+            if ($name == "DBManager.php") continue;
200 200
             require_once("$dir/$name");
201 201
             $classname = substr($name, 0, -4);
202
-            if(!class_exists($classname)) continue;
202
+            if (!class_exists($classname)) continue;
203 203
             $driver = new $classname;
204
-            if(!$validate || $driver->valid()) {
205
-                if(empty($drivers[$driver->dbType])) {
206
-                    $drivers[$driver->dbType]  = array();
204
+            if (!$validate || $driver->valid()) {
205
+                if (empty($drivers[$driver->dbType])) {
206
+                    $drivers[$driver->dbType] = array();
207 207
                 }
208 208
                 $drivers[$driver->dbType][] = $driver;
209 209
             }
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
         self::scanDriverDir("custom/include/database", $drivers, $validate);
236 236
 
237 237
         $result = array();
238
-        foreach($drivers as $type => $tdrivers) {
239
-            if(empty($tdrivers)) continue;
240
-            if(count($tdrivers) > 1) {
238
+        foreach ($drivers as $type => $tdrivers) {
239
+            if (empty($tdrivers)) continue;
240
+            if (count($tdrivers) > 1) {
241 241
                 usort($tdrivers, array(__CLASS__, "_compareDrivers"));
242 242
             }
243 243
             $result[$type] = $tdrivers[0];
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
     {
256 256
         static $is_freetds = null;
257 257
 
258
-        if($is_freetds === null) {
258
+        if ($is_freetds === null) {
259 259
     		ob_start();
260 260
     		phpinfo(INFO_MODULES);
261
-    		$info=ob_get_contents();
261
+    		$info = ob_get_contents();
262 262
     		ob_end_clean();
263 263
 
264
-    		$is_freetds = (strpos($info,'FreeTDS') !== false);
264
+    		$is_freetds = (strpos($info, 'FreeTDS') !== false);
265 265
         }
266 266
 
267 267
         return $is_freetds;
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 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.
@@ -191,15 +193,25 @@  discard block
 block discarded – undo
191 193
      */
192 194
     protected static function scanDriverDir($dir, &$drivers, $validate = true)
193 195
     {
194
-        if(!is_dir($dir)) return;
196
+        if(!is_dir($dir)) {
197
+            return;
198
+        }
195 199
         $scandir = opendir($dir);
196
-        if($scandir === false) return;
200
+        if($scandir === false) {
201
+            return;
202
+        }
197 203
         while(($name = readdir($scandir)) !== false) {
198
-            if(substr($name, -11) != "Manager.php") continue;
199
-            if($name == "DBManager.php") continue;
204
+            if(substr($name, -11) != "Manager.php") {
205
+                continue;
206
+            }
207
+            if($name == "DBManager.php") {
208
+                continue;
209
+            }
200 210
             require_once("$dir/$name");
201 211
             $classname = substr($name, 0, -4);
202
-            if(!class_exists($classname)) continue;
212
+            if(!class_exists($classname)) {
213
+                continue;
214
+            }
203 215
             $driver = new $classname;
204 216
             if(!$validate || $driver->valid()) {
205 217
                 if(empty($drivers[$driver->dbType])) {
@@ -236,7 +248,9 @@  discard block
 block discarded – undo
236 248
 
237 249
         $result = array();
238 250
         foreach($drivers as $type => $tdrivers) {
239
-            if(empty($tdrivers)) continue;
251
+            if(empty($tdrivers)) {
252
+                continue;
253
+            }
240 254
             if(count($tdrivers) > 1) {
241 255
                 usort($tdrivers, array(__CLASS__, "_compareDrivers"));
242 256
             }
Please login to merge, or discard this patch.
include/ListView/ListView.php 4 patches
Spacing   +373 added lines, -373 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
  */
46 46
 class ListView
47 47
 {
48
-    var $local_theme= null;
49
-    var $local_app_strings= null;
48
+    var $local_theme = null;
49
+    var $local_app_strings = null;
50 50
     var $local_image_path = null;
51 51
     var $local_current_module = null;
52 52
     var $local_mod_strings = null;
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
     var $child_focus = '';
82 82
     var $layout_manager = null;
83 83
     var $process_for_popups = false;
84
-    var $multi_select_popup=false;
84
+    var $multi_select_popup = false;
85 85
     var $_additionalDetails = false;
86 86
     var $additionalDetailsFunction = null;
87 87
     var $sort_order = '';
88
-    var $force_mass_update=false;
89
-    var $keep_mass_update_form_open=false;
88
+    var $force_mass_update = false;
89
+    var $keep_mass_update_form_open = false;
90 90
     var $ignorePopulateOnly = false;
91 91
 
92 92
 function setDataArray($value) {
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     echo "<form name='MassUpdate' method='post' action='index.php'>";
101 101
     $this->processListViewTwo($seed, $xTemplateSection, $html_varName);
102 102
 
103
-    echo "<a href='javascript:" . ((!$this->multi_select_popup) ? 'sListView.' : ''). "check_all(document.MassUpdate, \"mass[]\", true)'>".translate('LBL_CHECKALL')."</a> - <a href='javascript:sListView.check_all(document.MassUpdate, \"mass[]\", false);'>".translate('LBL_CLEARALL')."</a>";
103
+    echo "<a href='javascript:".((!$this->multi_select_popup) ? 'sListView.' : '')."check_all(document.MassUpdate, \"mass[]\", true)'>".translate('LBL_CHECKALL')."</a> - <a href='javascript:sListView.check_all(document.MassUpdate, \"mass[]\", false);'>".translate('LBL_CLEARALL')."</a>";
104 104
     echo '<br><br>';
105 105
 }
106 106
 
@@ -110,109 +110,109 @@  discard block
 block discarded – undo
110 110
     global $sugar_config;
111 111
 
112 112
     $populateOnly = $this->ignorePopulateOnly ? FALSE : (!empty($sugar_config['save_query']) && $sugar_config['save_query'] == 'populate_only');
113
-    if(isset($seed->module_dir) && $populateOnly) {
114
-        if(empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI')&& (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) {
115
-            $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
113
+    if (isset($seed->module_dir) && $populateOnly) {
114
+        if (empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI') && (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) {
115
+            $_SESSION['last_search_mod'] = $_REQUEST['module'];
116 116
             return;
117 117
         }
118 118
     }
119
-    if(strcmp(strtolower($_REQUEST['action']), 'popup') != 0){
120
-        $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
119
+    if (strcmp(strtolower($_REQUEST['action']), 'popup') != 0) {
120
+        $_SESSION['last_search_mod'] = $_REQUEST['module'];
121 121
     }
122 122
     //following session variable will track the detail view navigation history.
123 123
     //needs to the reset after each search.
124
-    $this->setLocalSessionVariable($html_varName,"DETAIL_NAV_HISTORY",false);
124
+    $this->setLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY", false);
125 125
 
126 126
     require_once('include/MassUpdate.php');
127 127
     $mass = new MassUpdate();
128 128
     $add_acl_javascript = false;
129
-    if(!isset($_REQUEST['action'])) {
130
-        $this->shouldProcess=false;
129
+    if (!isset($_REQUEST['action'])) {
130
+        $this->shouldProcess = false;
131 131
     } else {
132 132
     $this->shouldProcess = is_subclass_of($seed, "SugarBean")
133
-        && (($_REQUEST['action'] == 'index') || ('ListView' == substr($_REQUEST['action'],0,8)) /* cn: to include all ListViewXXX.php type views */)
133
+        && (($_REQUEST['action'] == 'index') || ('ListView' == substr($_REQUEST['action'], 0, 8)) /* cn: to include all ListViewXXX.php type views */)
134 134
         && ($_REQUEST['module'] == $seed->module_dir);
135 135
     }
136 136
 
137 137
     //when processing a multi-select popup.
138
-    if($this->process_for_popups && $this->multi_select_popup)  $this->shouldProcess =true;
138
+    if ($this->process_for_popups && $this->multi_select_popup)  $this->shouldProcess = true;
139 139
     //mass update turned off?
140
-    if(!$this->show_mass_update) $this->shouldProcess = false;
141
-    if(is_subclass_of($seed, "SugarBean")) {
142
-        if($seed->bean_implements('ACL')) {
143
-            if(!ACLController::checkAccess($seed->module_dir,'list',true)) {
144
-                if($_REQUEST['module'] != 'Home') {
140
+    if (!$this->show_mass_update) $this->shouldProcess = false;
141
+    if (is_subclass_of($seed, "SugarBean")) {
142
+        if ($seed->bean_implements('ACL')) {
143
+            if (!ACLController::checkAccess($seed->module_dir, 'list', true)) {
144
+                if ($_REQUEST['module'] != 'Home') {
145 145
                     ACLController::displayNoAccess();
146 146
                 }
147 147
                 return;
148 148
             }
149
-            if(!ACLController::checkAccess($seed->module_dir,'export',true)) {
150
-                $sugar_config['disable_export']= true;
149
+            if (!ACLController::checkAccess($seed->module_dir, 'export', true)) {
150
+                $sugar_config['disable_export'] = true;
151 151
             }
152 152
 
153 153
         }
154 154
     }
155 155
 
156 156
     //force mass update form if requested.
157
-    if($this->force_mass_update) {
157
+    if ($this->force_mass_update) {
158 158
         $this->shouldProcess = true;
159 159
     }
160 160
 
161
-    if($this->shouldProcess) {
161
+    if ($this->shouldProcess) {
162 162
         echo $mass->getDisplayMassUpdateForm(true, $this->multi_select_popup);
163 163
         echo $mass->getMassUpdateFormHeader($this->multi_select_popup);
164 164
         $mass->setSugarBean($seed);
165 165
 
166 166
         //C.L. Fix for 10048, do not process handleMassUpdate for multi select popups
167
-        if(!$this->multi_select_popup) {
167
+        if (!$this->multi_select_popup) {
168 168
             $mass->handleMassUpdate();
169 169
         }
170 170
     }
171 171
 
172
-    $this->processListViewTwo($seed,$xTemplateSection, $html_varName);
172
+    $this->processListViewTwo($seed, $xTemplateSection, $html_varName);
173 173
 
174
-    if($this->shouldProcess && empty($this->process_for_popups)) {
174
+    if ($this->shouldProcess && empty($this->process_for_popups)) {
175 175
         //echo "<a href='javascript:sListView.clear_all(document.MassUpdate, \"mass[]\");'>".translate('LBL_CLEARALL')."</a>";
176 176
         // cn: preserves current functionality, exception is InboundEmail
177
-        if($this->show_mass_update_form) {
177
+        if ($this->show_mass_update_form) {
178 178
             echo $mass->getMassUpdateForm();
179 179
         }
180
-        if(!$this->keep_mass_update_form_open) {
180
+        if (!$this->keep_mass_update_form_open) {
181 181
             echo $mass->endMassUpdateForm();
182 182
         }
183 183
     }
184 184
 }
185 185
 
186 186
 
187
-function process_dynamic_listview($source_module, $sugarbean,$subpanel_def)
187
+function process_dynamic_listview($source_module, $sugarbean, $subpanel_def)
188 188
 {
189 189
         $this->source_module = $source_module;
190 190
         $this->subpanel_module = $subpanel_def->name;
191
-        if(!isset($this->xTemplate))
191
+        if (!isset($this->xTemplate))
192 192
             $this->createXTemplate();
193 193
 
194
-        $html_var = $this->subpanel_module . "_CELL";
194
+        $html_var = $this->subpanel_module."_CELL";
195 195
 
196
-        $list_data = $this->processUnionBeans($sugarbean,$subpanel_def, $html_var);
196
+        $list_data = $this->processUnionBeans($sugarbean, $subpanel_def, $html_var);
197 197
 
198 198
         $list = $list_data['list'];
199 199
         $parent_data = $list_data['parent_data'];
200 200
 
201
-        if($subpanel_def->isCollection()) {
202
-            $thepanel=$subpanel_def->get_header_panel_def();
201
+        if ($subpanel_def->isCollection()) {
202
+            $thepanel = $subpanel_def->get_header_panel_def();
203 203
         } else {
204
-            $thepanel=$subpanel_def;
204
+            $thepanel = $subpanel_def;
205 205
         }
206 206
 
207 207
 
208 208
 
209 209
         $this->process_dynamic_listview_header($thepanel->get_module_name(), $thepanel, $html_var);
210
-        $this->process_dynamic_listview_rows($list,$parent_data, 'dyn_list_view', $html_var,$subpanel_def);
210
+        $this->process_dynamic_listview_rows($list, $parent_data, 'dyn_list_view', $html_var, $subpanel_def);
211 211
 
212
-        if($this->display_header_and_footer)
212
+        if ($this->display_header_and_footer)
213 213
         {
214 214
             $this->getAdditionalHeader();
215
-            if(!empty($this->header_title))
215
+            if (!empty($this->header_title))
216 216
             {
217 217
                 echo get_form_header($this->header_title, $this->header_text, false);
218 218
             }
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 
221 221
         $this->xTemplate->out('dyn_list_view');
222 222
 
223
-        if(isset($_SESSION['validation']))
223
+        if (isset($_SESSION['validation']))
224 224
         {
225 225
             print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
226 226
         }
227
-        if(isset($list_data['query'])) {
227
+        if (isset($list_data['query'])) {
228 228
             return ($list_data['query']);
229 229
         }
230 230
     }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
  * @param unknown $html_varName
237 237
  * @desc INTERNAL FUNCTION handles the rows
238 238
  */
239
- function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def)
239
+ function process_dynamic_listview_rows($data, $parent_data, $xtemplateSection, $html_varName, $subpanel_def)
240 240
  {
241 241
     global $subpanel_item_count;
242 242
     global $odd_bg;
@@ -261,37 +261,37 @@  discard block
 block discarded – undo
261 261
     //Either retrieve the is_fill_in_additional_fields property from the lone
262 262
     //subpanel or visit each subpanel's subpanels to retrieve the is_fill_in_addition_fields
263 263
     //property
264
-    $subpanel_list=array();
265
-    if($subpanel_def->isCollection()) {
266
-        $subpanel_list=$subpanel_def->sub_subpanels;
264
+    $subpanel_list = array();
265
+    if ($subpanel_def->isCollection()) {
266
+        $subpanel_list = $subpanel_def->sub_subpanels;
267 267
     } else {
268
-        $subpanel_list[]= $subpanel_def;
268
+        $subpanel_list[] = $subpanel_def;
269 269
     }
270 270
 
271
-    foreach($subpanel_list as $this_subpanel)
271
+    foreach ($subpanel_list as $this_subpanel)
272 272
     {
273
-        if($this_subpanel->is_fill_in_additional_fields())
273
+        if ($this_subpanel->is_fill_in_additional_fields())
274 274
         {
275 275
             $fill_additional_fields[] = $this_subpanel->bean_name;
276 276
             $fill_additional_fields[$this_subpanel->bean_name] = true;
277 277
         }
278 278
     }
279 279
 
280
-    if ( empty($data) ) {
280
+    if (empty($data)) {
281 281
         $this->xTemplate->assign("ROW_COLOR", 'oddListRow');
282
-        $thepanel=$subpanel_def;
283
-        if($subpanel_def->isCollection())
284
-            $thepanel=$subpanel_def->get_header_panel_def();
282
+        $thepanel = $subpanel_def;
283
+        if ($subpanel_def->isCollection())
284
+            $thepanel = $subpanel_def->get_header_panel_def();
285 285
         $this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields()));
286 286
         $this->xTemplate->parse($xtemplateSection.".nodata");
287 287
     }
288
-    while(list($aVal, $aItem) = each($data))
288
+    while (list($aVal, $aItem) = each($data))
289 289
     {
290 290
         $subpanel_item_count++;
291 291
         $aItem->check_date_relationships_load();
292 292
         // TODO: expensive and needs to be removed and done better elsewhere
293 293
 
294
-        if(!empty($fill_additional_fields[$aItem->object_name])
294
+        if (!empty($fill_additional_fields[$aItem->object_name])
295 295
         || ($aItem->object_name == 'Case' && !empty($fill_additional_fields['aCase']))
296 296
         )
297 297
         {
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
         //rrs bug: 25343
302 302
         $aItem->call_custom_logic("process_record");
303 303
 
304
-        if(isset($parent_data[$aItem->id])) {
304
+        if (isset($parent_data[$aItem->id])) {
305 305
 
306 306
             $aItem->parent_name = $parent_data[$aItem->id]['parent_name'];
307
-            if(!empty($parent_data[$aItem->id]['parent_name_owner'])) {
308
-            $aItem->parent_name_owner =  $parent_data[$aItem->id]['parent_name_owner'];
309
-            $aItem->parent_name_mod =  $parent_data[$aItem->id]['parent_name_mod'];
307
+            if (!empty($parent_data[$aItem->id]['parent_name_owner'])) {
308
+            $aItem->parent_name_owner = $parent_data[$aItem->id]['parent_name_owner'];
309
+            $aItem->parent_name_mod = $parent_data[$aItem->id]['parent_name_mod'];
310 310
         }}
311 311
         $fields = $aItem->get_list_view_data();
312
-        if(isset($processed_ids[$aItem->id])) {
312
+        if (isset($processed_ids[$aItem->id])) {
313 313
             continue;
314 314
 
315 315
         } else {
@@ -320,50 +320,50 @@  discard block
 block discarded – undo
320 320
         //ADD OFFSET TO ARRAY
321 321
         $fields['OFFSET'] = ($offset + $count + 1);
322 322
 
323
-        if($this->shouldProcess) {
324
-            if($aItem->ACLAccess('EditView')) {
325
-            $this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "' />");
323
+        if ($this->shouldProcess) {
324
+            if ($aItem->ACLAccess('EditView')) {
325
+            $this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='".$fields['ID']."' />");
326 326
             } else {
327 327
                 $this->xTemplate->assign('PREROW', '');
328 328
 
329 329
             }
330
-            if($aItem->ACLAccess('DetailView')) {
331
-                $this->xTemplate->assign('TAG_NAME','a');
330
+            if ($aItem->ACLAccess('DetailView')) {
331
+                $this->xTemplate->assign('TAG_NAME', 'a');
332 332
             } else {
333
-                $this->xTemplate->assign('TAG_NAME','span');
333
+                $this->xTemplate->assign('TAG_NAME', 'span');
334 334
             }
335 335
             $this->xTemplate->assign('CHECKALL', "<input type='checkbox'  title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."' class='checkbox' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' />");
336 336
         }
337 337
 
338
-        if($oddRow)
338
+        if ($oddRow)
339 339
         {
340 340
             $ROW_COLOR = 'oddListRow';
341
-            $BG_COLOR =  $odd_bg;
341
+            $BG_COLOR = $odd_bg;
342 342
         }
343 343
         else
344 344
         {
345 345
             $ROW_COLOR = 'evenListRow';
346
-            $BG_COLOR =  $even_bg;
346
+            $BG_COLOR = $even_bg;
347 347
         }
348 348
         $oddRow = !$oddRow;
349 349
 		$button_contents = array();
350 350
         $this->xTemplate->assign("ROW_COLOR", $ROW_COLOR);
351 351
         $this->xTemplate->assign("BG_COLOR", $BG_COLOR);
352 352
         $layout_manager = $this->getLayoutManager();
353
-        $layout_manager->setAttribute('context','List');
354
-        $layout_manager->setAttribute('image_path',$this->local_image_path);
353
+        $layout_manager->setAttribute('context', 'List');
354
+        $layout_manager->setAttribute('image_path', $this->local_image_path);
355 355
         $layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']);
356
-        if(!empty($this->child_focus))
357
-            $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir);
356
+        if (!empty($this->child_focus))
357
+            $layout_manager->setAttribute('related_module_name', $this->child_focus->module_dir);
358 358
 
359 359
         //AG$subpanel_data = $this->list_field_defs;
360 360
         //$bla = array_pop($subpanel_data);
361 361
         //select which sub-panel to display here, the decision will be made based on the type of
362 362
         //the sub-panel and panel in the bean being processed.
363
-        if($subpanel_def->isCollection()) {
364
-            $thepanel=$subpanel_def->sub_subpanels[$aItem->panel_name];
363
+        if ($subpanel_def->isCollection()) {
364
+            $thepanel = $subpanel_def->sub_subpanels[$aItem->panel_name];
365 365
         } else {
366
-            $thepanel=$subpanel_def;
366
+            $thepanel = $subpanel_def;
367 367
         }
368 368
 
369 369
 		/* BEGIN - SECURITY GROUPS */ 
@@ -374,22 +374,22 @@  discard block
 block discarded – undo
374 374
 		$aclaccess_in_group = false;
375 375
 
376 376
 		global $current_user;
377
-		if(is_admin($current_user)) {
377
+		if (is_admin($current_user)) {
378 378
 			$aclaccess_is_owner = true;
379 379
 		} else {
380 380
 			$aclaccess_is_owner = $aItem->isOwner($current_user->id);
381 381
 		}
382 382
 
383 383
 		require_once("modules/SecurityGroups/SecurityGroup.php");
384
-		$aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir,$aItem->id);
384
+		$aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir, $aItem->id);
385 385
         	
386 386
     	/* END - SECURITY GROUPS */ 
387 387
     	
388 388
         //get data source name
389
-        $linked_field=$thepanel->get_data_source_name();
390
-        $linked_field_set=$thepanel->get_data_source_name(true);
389
+        $linked_field = $thepanel->get_data_source_name();
390
+        $linked_field_set = $thepanel->get_data_source_name(true);
391 391
         static $count;
392
-        if(!isset($count))$count = 0;
392
+        if (!isset($count))$count = 0;
393 393
 		/* BEGIN - SECURITY GROUPS */ 
394 394
 		/**
395 395
         $field_acl['DetailView'] = $aItem->ACLAccess('DetailView');
@@ -398,19 +398,19 @@  discard block
 block discarded – undo
398 398
         $field_acl['Delete'] = $aItem->ACLAccess('Delete');
399 399
 		*/
400 400
 		//pass is_owner, in_group...vars defined above
401
-        $field_acl['DetailView'] = $aItem->ACLAccess('DetailView',$aclaccess_is_owner,$aclaccess_in_group);
402
-        $field_acl['ListView'] = $aItem->ACLAccess('ListView',$aclaccess_is_owner,$aclaccess_in_group);
403
-        $field_acl['EditView'] = $aItem->ACLAccess('EditView',$aclaccess_is_owner,$aclaccess_in_group);
404
-        $field_acl['Delete'] = $aItem->ACLAccess('Delete',$aclaccess_is_owner,$aclaccess_in_group);
401
+        $field_acl['DetailView'] = $aItem->ACLAccess('DetailView', $aclaccess_is_owner, $aclaccess_in_group);
402
+        $field_acl['ListView'] = $aItem->ACLAccess('ListView', $aclaccess_is_owner, $aclaccess_in_group);
403
+        $field_acl['EditView'] = $aItem->ACLAccess('EditView', $aclaccess_is_owner, $aclaccess_in_group);
404
+        $field_acl['Delete'] = $aItem->ACLAccess('Delete', $aclaccess_is_owner, $aclaccess_in_group);
405 405
 		/* END - SECURITY GROUPS */ 
406
-        foreach($thepanel->get_list_fields() as $field_name=>$list_field)
406
+        foreach ($thepanel->get_list_fields() as $field_name=>$list_field)
407 407
         {
408 408
             //add linked field attribute to the array.
409
-            $list_field['linked_field']=$linked_field;
410
-            $list_field['linked_field_set']=$linked_field_set;
409
+            $list_field['linked_field'] = $linked_field;
410
+            $list_field['linked_field_set'] = $linked_field_set;
411 411
 
412 412
             $usage = empty($list_field['usage']) ? '' : $list_field['usage'];
413
-            if($usage == 'query_only' && !empty($list_field['force_query_only_display'])){
413
+            if ($usage == 'query_only' && !empty($list_field['force_query_only_display'])) {
414 414
                 //if you are here you have column that is query only but needs to be displayed as blank.  This is helpful
415 415
                 //for collections such as Activities where you have a field in only one object and wish to show it in the subpanel list
416 416
                 $count++;
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
                 $this->xTemplate->assign('CELL', $widget_contents);
421 421
                 $this->xTemplate->parse($xtemplateSection.".row.cell");
422 422
 
423
-            }else if($usage != 'query_only')
423
+            } else if ($usage != 'query_only')
424 424
             {
425
-                $list_field['name']=$field_name;
425
+                $list_field['name'] = $field_name;
426 426
 
427 427
                 $module_field = $field_name.'_mod';
428 428
                 $owner_field = $field_name.'_owner';
429
-                if(!empty($aItem->$module_field)) {
429
+                if (!empty($aItem->$module_field)) {
430 430
 
431 431
                     $list_field['owner_id'] = $aItem->$owner_field;
432 432
                     $list_field['owner_module'] = $aItem->$module_field;
@@ -435,71 +435,71 @@  discard block
 block discarded – undo
435 435
                     $list_field['owner_id'] = false;
436 436
                     $list_field['owner_module'] = false;
437 437
                 }
438
-                if(isset($list_field['alias'])) $list_field['name'] = $list_field['alias'];
439
-                else $list_field['name']=$field_name;
438
+                if (isset($list_field['alias'])) $list_field['name'] = $list_field['alias'];
439
+                else $list_field['name'] = $field_name;
440 440
                 $list_field['fields'] = $fields;
441 441
                 $list_field['module'] = $aItem->module_dir;
442 442
                 $list_field['start_link_wrapper'] = $this->start_link_wrapper;
443 443
                 $list_field['end_link_wrapper'] = $this->end_link_wrapper;
444 444
                 $list_field['subpanel_id'] = $this->subpanel_id;
445 445
                 $list_field += $field_acl;
446
-                if ( isset($aItem->field_defs[strtolower($list_field['name'])])) {
446
+                if (isset($aItem->field_defs[strtolower($list_field['name'])])) {
447 447
                     require_once('include/SugarFields/SugarFieldHandler.php');
448 448
                     // We need to see if a sugar field exists for this field type first,
449 449
                     // if it doesn't, toss it at the old sugarWidgets. This is for
450 450
                     // backwards compatibility and will be removed in a future release
451 451
                     $vardef = $aItem->field_defs[strtolower($list_field['name'])];
452
-                    if ( isset($vardef['type']) ) {
453
-                        $fieldType = isset($vardef['custom_type'])?$vardef['custom_type']:$vardef['type'];
454
-                        $tmpField = SugarFieldHandler::getSugarField($fieldType,true);
452
+                    if (isset($vardef['type'])) {
453
+                        $fieldType = isset($vardef['custom_type']) ? $vardef['custom_type'] : $vardef['type'];
454
+                        $tmpField = SugarFieldHandler::getSugarField($fieldType, true);
455 455
                     } else {
456 456
                         $tmpField = NULL;
457 457
                     }
458 458
 
459
-                    if ( $tmpField != NULL ) {
460
-                        $widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'],$vardef,'ListView',$list_field);
459
+                    if ($tmpField != NULL) {
460
+                        $widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'], $vardef, 'ListView', $list_field);
461 461
                     } else {
462 462
                         // No SugarField for this particular type
463 463
                         // Use the old, icky, SugarWidget for now
464 464
                         $widget_contents = $layout_manager->widgetDisplay($list_field);
465 465
                     }
466 466
 
467
-                    if ( isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink' ) {
467
+                    if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink') {
468 468
                         // We need to call into the old SugarWidgets for the time being, so it can generate a proper link with all the various corner-cases handled
469 469
                         // So we'll populate the field data with the pre-rendered display for the field
470 470
                         $list_field['fields'][$field_name] = $widget_contents;
471
-                        if('full_name' == $field_name){//bug #32465
471
+                        if ('full_name' == $field_name) {//bug #32465
472 472
                            $list_field['fields'][strtoupper($field_name)] = $widget_contents;
473 473
                         }
474 474
 
475 475
                         //vardef source is non db, assign the field name to varname for processing of column.
476
-                        if(!empty($vardef['source']) && $vardef['source']=='non-db'){
476
+                        if (!empty($vardef['source']) && $vardef['source'] == 'non-db') {
477 477
                             $list_field['varname'] = $field_name;
478 478
 
479 479
                         }
480 480
                         $widget_contents = $layout_manager->widgetDisplay($list_field);
481
-                    } else if(isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink' ) {
481
+                    } else if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink') {
482 482
                         $widget_contents = $layout_manager->widgetDisplay($list_field);
483 483
                     }
484 484
 
485 485
                  $count++;
486 486
                 $this->xTemplate->assign('CELL_COUNT', $count);
487 487
                 $this->xTemplate->assign('CLASS', "");
488
-                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
488
+                if (empty($widget_contents)) $widget_contents = '&nbsp;';
489 489
                 $this->xTemplate->assign('CELL', $widget_contents);
490 490
                 $this->xTemplate->parse($xtemplateSection.".row.cell");
491 491
                 } else {
492 492
                     // This handles the edit and remove buttons and icon widget
493
-                	if( isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") {
493
+                	if (isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") {
494 494
 		                $count++;
495 495
 		                $widget_contents = $layout_manager->widgetDisplay($list_field);
496 496
 		                $this->xTemplate->assign('CELL_COUNT', $count);
497 497
 		                $this->xTemplate->assign('CLASS', "");
498
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
498
+		                if (empty($widget_contents)) $widget_contents = '&nbsp;';
499 499
 		                $this->xTemplate->assign('CELL', $widget_contents);
500 500
 		                $this->xTemplate->parse($xtemplateSection.".row.cell");
501 501
                 	} elseif (preg_match("/button/i", $list_field['name'])) {
502
-                        if ((($list_field['name'] === 'edit_button' && $field_acl['EditView']) || ($list_field['name'] === 'close_button' && $field_acl['EditView']) || ($list_field['name'] === 'remove_button' && $field_acl['Delete'])) && '' != ($_content = $layout_manager->widgetDisplay($list_field)) )
502
+                        if ((($list_field['name'] === 'edit_button' && $field_acl['EditView']) || ($list_field['name'] === 'close_button' && $field_acl['EditView']) || ($list_field['name'] === 'remove_button' && $field_acl['Delete'])) && '' != ($_content = $layout_manager->widgetDisplay($list_field)))
503 503
                         {
504 504
                             $button_contents[] = $_content;
505 505
                             unset($_content);
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
                			$this->xTemplate->assign('CLASS', "");
514 514
                			$widget_contents = $layout_manager->widgetDisplay($list_field);
515 515
 		                $this->xTemplate->assign('CELL_COUNT', $count);
516
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
516
+		                if (empty($widget_contents)) $widget_contents = '&nbsp;';
517 517
 		                $this->xTemplate->assign('CELL', $widget_contents);
518 518
 		                $this->xTemplate->parse($xtemplateSection.".row.cell");
519 519
                 	}
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 
526 526
         // Make sure we have at least one button before rendering a column for
527 527
         // the action buttons in a list view. Relevant bugs: #51647 and #51640.
528
-        if(!empty($button_contents))
528
+        if (!empty($button_contents))
529 529
         {
530 530
             $button_contents = array_filter($button_contents);
531 531
             if (!empty($button_contents))
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
             // bug#51275: smarty widget to help provide the action menu functionality as it is currently sprinkled throughout the app with html
535 535
                 require_once('include/Smarty/plugins/function.sugar_action_menu.php');
536 536
                 $tempid = create_guid();
537
-                array_unshift($button_contents, "<div style='display: inline' id='$tempid'>" . array_shift($button_contents) . "</div>");
537
+                array_unshift($button_contents, "<div style='display: inline' id='$tempid'>".array_shift($button_contents)."</div>");
538 538
                 $action_button = smarty_function_sugar_action_menu(array(
539 539
                     'id' => $tempid,
540 540
                     'buttons' => $button_contents,
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
             $this->xTemplate->assign('CELL_COUNT', ++$count);
551 551
             //Bug#51275 for beta3 pre_script is not required any more
552 552
             $this->xTemplate->assign('CELL', $action_button);
553
-            $this->xTemplate->parse($xtemplateSection . ".row.cell");
553
+            $this->xTemplate->parse($xtemplateSection.".row.cell");
554 554
         }
555 555
 
556 556
 
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
  function ListView() {
583 583
 
584 584
 
585
-    if(!$this->initialized) {
585
+    if (!$this->initialized) {
586 586
         global $sugar_config;
587 587
         $this->records_per_page = $sugar_config['list_max_entries_per_page'] + 0;
588 588
         $this->initialized = true;
589 589
         global $app_strings, $currentModule;
590 590
         $this->local_theme = SugarThemeRegistry::current()->__toString();
591
-        $this->local_app_strings =$app_strings;
591
+        $this->local_app_strings = $app_strings;
592 592
         $this->local_image_path = SugarThemeRegistry::current()->getImagePath();
593 593
         $this->local_current_module = $currentModule;
594 594
     }
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
  * Contributor(s): ______________________________________.
620 620
 */
621 621
  function setXTemplatePath($value) {
622
-    $this->xTemplatePath= $value;
622
+    $this->xTemplatePath = $value;
623 623
 }
624 624
 
625 625
 /**this is a helper function for allowing ListView to create a new XTemplate it groups parameters that should be set into a single function
@@ -629,22 +629,22 @@  discard block
 block discarded – undo
629 629
 */
630 630
  function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) {
631 631
     $this->setXTemplatePath($XTemplatePath);
632
-    if(isset($modString))
632
+    if (isset($modString))
633 633
         $this->setModStrings($modString);
634
-    if(isset($imagePath))
634
+    if (isset($imagePath))
635 635
         $this->setImagePath($imagePath);
636 636
 }
637 637
 
638 638
 
639
-function getOrderBy($varName, $defaultOrderBy='', $force_sortorder='') {
640
-    $sortBy = $this->getSessionVariable($varName, "ORDER_BY") ;
639
+function getOrderBy($varName, $defaultOrderBy = '', $force_sortorder = '') {
640
+    $sortBy = $this->getSessionVariable($varName, "ORDER_BY");
641 641
 
642 642
     $orderByDirection = $this->getSessionVariableName($varName, "order_by_direction");
643 643
     $orderByColumn = $this->getSessionVariableName($varName, "ORDER_BY");
644 644
     $lastEqualsSortBy = false;
645 645
     $defaultOrder = false; //ascending
646 646
 
647
-    if(empty($sortBy)) {
647
+    if (empty($sortBy)) {
648 648
         $this->setUserVariable($varName, "ORDER_BY", $defaultOrderBy);
649 649
         $sortBy = $defaultOrderBy;
650 650
     } else {
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
         }
683 683
         $desc = $orderByValue == 'desc';
684 684
         $orderByDirectionValue = false;
685
-        $this->setSessionVariable($varName, $sortBy . "S", $desc);
685
+        $this->setSessionVariable($varName, $sortBy."S", $desc);
686 686
         if (!empty($sortBy))
687 687
         {
688 688
             if (empty($force_sortorder))
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
                     {
694 694
                         $orderByDirectionValue = $desc ? 'asc' : 'desc';
695 695
                     }
696
-                    $this->query_orderby = $sortBy . ' ' . $orderByValue;
696
+                    $this->query_orderby = $sortBy.' '.$orderByValue;
697 697
                 }
698 698
             } else
699 699
             {
700
-                $this->query_orderby = $sortBy . ' ' . $force_sortorder;
700
+                $this->query_orderby = $sortBy.' '.$force_sortorder;
701 701
             }
702 702
             if (!isset($this->appendToBaseUrl))
703 703
             {
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
             }
715 715
             //Just clear from url...
716 716
             $this->appendToBaseUrl[$orderByColumn] = false;
717
-    }else {
717
+    } else {
718 718
         $this->query_orderby = "";
719 719
     }
720 720
     $this->sortby = $sortBy;
@@ -728,15 +728,15 @@  discard block
 block discarded – undo
728 728
  * All Rights Reserved.
729 729
  * Contributor(s): ______________________________________.
730 730
 */
731
- function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) {
731
+ function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride = true) {
732 732
     $this->query_where = $where;
733
-    if($this->getSessionVariable("query", "where") != $where) {
733
+    if ($this->getSessionVariable("query", "where") != $where) {
734 734
         $this->query_where_has_changed = true;
735 735
         $this->setSessionVariable("query", "where", $where);
736 736
     }
737 737
 
738 738
     $this->query_limit = $limit;
739
-    if(!$allowOrderByOveride) {
739
+    if (!$allowOrderByOveride) {
740 740
         $this->query_orderby = $orderBy;
741 741
         return;
742 742
     }
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 */
760 760
  function setTheme($theme) {
761 761
     $this->local_theme = $theme;
762
-    if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
762
+    if (isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
763 763
 }
764 764
 
765 765
 /**sets the AppStrings used only use if it is different from the global
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
  function setAppStrings($app_strings) {
771 771
     unset($this->local_app_strings);
772 772
     $this->local_app_strings = $app_strings;
773
-    if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
773
+    if (isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
774 774
 }
775 775
 
776 776
 /**sets the ModStrings used
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
  function setModStrings($mod_strings) {
782 782
     unset($this->local_module_strings);
783 783
     $this->local_mod_strings = $mod_strings;
784
-    if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
784
+    if (isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
785 785
 }
786 786
 
787 787
 /**sets the ImagePath used
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
 */
792 792
  function setImagePath($image_path) {
793 793
     $this->local_image_path = $image_path;
794
-    if(empty($this->local_image_path)) {
794
+    if (empty($this->local_image_path)) {
795 795
         $this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath();
796 796
     }
797
-    if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
797
+    if (isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
798 798
 }
799 799
 
800 800
 /**sets the currentModule only use if this is different from the global
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
  function setCurrentModule($currentModule) {
806 806
     unset($this->local_current_module);
807 807
     $this->local_current_module = $currentModule;
808
-    if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
808
+    if (isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
809 809
 }
810 810
 
811 811
 /**INTERNAL FUNCTION creates an XTemplate DO NOT CALL THIS THIS IS AN INTERNAL FUNCTION
@@ -814,12 +814,12 @@  discard block
 block discarded – undo
814 814
  * Contributor(s): ______________________________________.
815 815
 */
816 816
  function createXTemplate() {
817
-    if(!isset($this->xTemplate)) {
818
-        if(isset($this->xTemplatePath)) {
817
+    if (!isset($this->xTemplate)) {
818
+        if (isset($this->xTemplatePath)) {
819 819
 
820 820
             $this->xTemplate = new XTemplate($this->xTemplatePath);
821 821
             $this->xTemplate->assign("APP", $this->local_app_strings);
822
-            if(isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings);
822
+            if (isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings);
823 823
             $this->xTemplate->assign("THEME", $this->local_theme);
824 824
             $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
825 825
             $this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 */
855 855
  function xTemplateAssign($name, $value) {
856 856
 
857
-        if(!isset($this->xTemplate)) {
857
+        if (!isset($this->xTemplate)) {
858 858
             $this->createXTemplate();
859 859
         }
860 860
         $this->xTemplate->assign($name, $value);
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
  * Contributor(s): ______________________________________.
868 868
 */
869 869
  function getOffset($localVarName) {
870
- 	if($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
871
- 		$this->setSessionVariable($localVarName,"offset", 0);
870
+ 	if ($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
871
+ 		$this->setSessionVariable($localVarName, "offset", 0);
872 872
  	}
873
-	$offset = $this->getSessionVariable($localVarName,"offset");
874
-	if(isset($offset)) {
873
+	$offset = $this->getSessionVariable($localVarName, "offset");
874
+	if (isset($offset)) {
875 875
 		return $offset;
876 876
 	}
877 877
 	return 0;
@@ -891,12 +891,12 @@  discard block
 block discarded – undo
891 891
  * All Rights Reserved.
892 892
  * Contributor(s): ______________________________________.
893 893
 */
894
- function setSessionVariable($localVarName,$varName, $value) {
894
+ function setSessionVariable($localVarName, $varName, $value) {
895 895
     $_SESSION[$this->local_current_module."_".$localVarName."_".$varName] = $value;
896 896
 }
897 897
 
898
-function setUserVariable($localVarName,$varName, $value) {
899
-        if($this->is_dynamic ||  $localVarName == 'CELL')return;
898
+function setUserVariable($localVarName, $varName, $value) {
899
+        if ($this->is_dynamic || $localVarName == 'CELL')return;
900 900
         global $current_user;
901 901
         $current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value);
902 902
 }
@@ -906,13 +906,13 @@  discard block
 block discarded – undo
906 906
  * All Rights Reserved.
907 907
  * Contributor(s): ______________________________________.
908 908
 */
909
- function getSessionVariable($localVarName,$varName) {
909
+ function getSessionVariable($localVarName, $varName) {
910 910
     //Set any variables pass in through request first
911
-    if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
912
-        $this->setSessionVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
911
+    if (isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
912
+        $this->setSessionVariable($localVarName, $varName, $_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
913 913
     }
914 914
 
915
-    if(isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])) {
915
+    if (isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])) {
916 916
         return $_SESSION[$this->getSessionVariableName($localVarName, $varName)];
917 917
     }
918 918
     return "";
@@ -920,10 +920,10 @@  discard block
 block discarded – undo
920 920
 
921 921
 function getUserVariable($localVarName, $varName) {
922 922
     global $current_user;
923
-    if($this->is_dynamic ||  $localVarName == 'CELL')return;
924
-    if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
923
+    if ($this->is_dynamic || $localVarName == 'CELL')return;
924
+    if (isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
925 925
 
926
-            $this->setUserVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
926
+            $this->setUserVariable($localVarName, $varName, $_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
927 927
     }
928 928
     return $current_user->getPreference($this->getSessionVariableName($localVarName, $varName));
929 929
 }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
           'default',
948 948
         );
949 949
 
950
-        foreach($priority_map as $p) {
950
+        foreach ($priority_map as $p) {
951 951
             if (key_exists($p, $sortOrderList)) {
952 952
                 $order = strtolower($sortOrderList[$p]);
953 953
                 if (in_array($order, array('asc', 'desc'))) {
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
     * All Rights Reserved.
970 970
     * Contributor(s): ______________________________________..
971 971
     */
972
-    function getSessionVariableName($localVarName,$varName) {
972
+    function getSessionVariableName($localVarName, $varName) {
973 973
         return $this->local_current_module."_".$localVarName."_".$varName;
974 974
     }
975 975
 
@@ -997,22 +997,22 @@  discard block
 block discarded – undo
997 997
         SugarVCR::erase($seed->module_dir);
998 998
         $params = array();
999 999
         //$filter = array('id', 'full_name');
1000
-        $filter=array();
1000
+        $filter = array();
1001 1001
         $ret_array = $seed->create_new_list_query($this->query_orderby, $this->query_where, $filter, $params, 0, '', true, $seed, true);
1002
-        if(!is_array($params)) $params = array();
1003
-        if(!isset($params['custom_select'])) $params['custom_select'] = '';
1004
-        if(!isset($params['custom_from'])) $params['custom_from'] = '';
1005
-        if(!isset($params['custom_where'])) $params['custom_where'] = '';
1006
-        if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
1007
-        $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
1008
-        SugarVCR::store($seed->module_dir,  $main_query);
1002
+        if (!is_array($params)) $params = array();
1003
+        if (!isset($params['custom_select'])) $params['custom_select'] = '';
1004
+        if (!isset($params['custom_from'])) $params['custom_from'] = '';
1005
+        if (!isset($params['custom_where'])) $params['custom_where'] = '';
1006
+        if (!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
1007
+        $main_query = $ret_array['select'].$params['custom_select'].$ret_array['from'].$params['custom_from'].$ret_array['where'].$params['custom_where'].$ret_array['order_by'].$params['custom_order_by'];
1008
+        SugarVCR::store($seed->module_dir, $main_query);
1009 1009
         //ADDING VCR CONTROL
1010 1010
 
1011
-        if(empty($this->related_field_name)) {
1011
+        if (empty($this->related_field_name)) {
1012 1012
             $response = $seed->get_list($this->query_orderby, $this->query_where, $current_offset, $this->query_limit);
1013 1013
         } else {
1014 1014
             $related_field_name = $this->related_field_name;
1015
-            $response = $seed->get_related_list($this->child_focus,$related_field_name, $this->query_orderby,
1015
+            $response = $seed->get_related_list($this->child_focus, $related_field_name, $this->query_orderby,
1016 1016
             $this->query_where, $current_offset, $this->query_limit);
1017 1017
         }
1018 1018
 
@@ -1021,12 +1021,12 @@  discard block
 block discarded – undo
1021 1021
         $next_offset = $response['next_offset'];
1022 1022
         $previous_offset = $response['previous_offset'];
1023 1023
 
1024
-        if(!empty($response['current_offset'])) {
1024
+        if (!empty($response['current_offset'])) {
1025 1025
             $current_offset = $response['current_offset'];
1026 1026
         }
1027 1027
 
1028 1028
         $list_view_row_count = $row_count;
1029
-        $this->processListNavigation($xtemplateSection,$html_varName, $current_offset, $next_offset, $previous_offset, $row_count, null, null, empty($seed->column_fields) ? null : count($seed->column_fields));
1029
+        $this->processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, null, null, empty($seed->column_fields) ? null : count($seed->column_fields));
1030 1030
 
1031 1031
         return $list;
1032 1032
     }
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
     function processUnionBeans($sugarbean, $subpanel_def, $html_var = 'CELL') {
1037 1037
 
1038 1038
 		$last_detailview_record = $this->getSessionVariable("detailview", "record");
1039
-		if(!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id){
1039
+		if (!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id) {
1040 1040
 			$GLOBALS['record_has_changed'] = true;
1041 1041
 		}
1042 1042
 		$this->setSessionVariable("detailview", "record", $sugarbean->id);
@@ -1053,14 +1053,14 @@  discard block
 block discarded – undo
1053 1053
         $sort_order['request'] = isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : null;
1054 1054
 
1055 1055
         // see if the session data has a sort order
1056
-        if (isset($_SESSION['last_sub' . $this->subpanel_module . '_order']))
1056
+        if (isset($_SESSION['last_sub'.$this->subpanel_module.'_order']))
1057 1057
         {
1058
-            $sort_order['session'] = $_SESSION['last_sub' . $this->subpanel_module . '_order'];
1058
+            $sort_order['session'] = $_SESSION['last_sub'.$this->subpanel_module.'_order'];
1059 1059
 
1060 1060
             // We swap the order when the request contains an offset (indicating a column sort issued);
1061 1061
             // otherwise we do not sort.  If we don't make this check, then the subpanel listview will
1062 1062
             // swap ordering each time a new record is entered via quick create forms
1063
-            if (isset($_REQUEST[$module . '_' . $html_var . '_offset']))
1063
+            if (isset($_REQUEST[$module.'_'.$html_var.'_offset']))
1064 1064
             {
1065 1065
                 $sort_order['session'] = $sort_order['session'] == 'asc' ? 'desc' : 'asc';
1066 1066
             }
@@ -1083,10 +1083,10 @@  discard block
 block discarded – undo
1083 1083
             $this->query_orderby = 'id';
1084 1084
         }
1085 1085
 
1086
-        $this->getOrderBy($html_var,$this->query_orderby, $this->sort_order);
1086
+        $this->getOrderBy($html_var, $this->query_orderby, $this->sort_order);
1087 1087
 
1088
-        $_SESSION['last_sub' .$this->subpanel_module. '_order'] = $this->sort_order;
1089
-        $_SESSION['last_sub' .$this->subpanel_module. '_url'] = $this->getBaseURL($html_var);
1088
+        $_SESSION['last_sub'.$this->subpanel_module.'_order'] = $this->sort_order;
1089
+        $_SESSION['last_sub'.$this->subpanel_module.'_url'] = $this->getBaseURL($html_var);
1090 1090
 
1091 1091
 		// Bug 8139 - Correct Subpanel sorting on 'name', when subpanel sorting default is 'last_name, first_name'
1092 1092
 		if (($this->sortby == 'name' || $this->sortby == 'last_name') &&
@@ -1094,21 +1094,21 @@  discard block
 block discarded – undo
1094 1094
 			$this->sortby = 'last_name '.$this->sort_order.', first_name ';
1095 1095
 		}
1096 1096
 
1097
-        if(!empty($this->response)){
1098
-            $response =& $this->response;
1097
+        if (!empty($this->response)) {
1098
+            $response = & $this->response;
1099 1099
             echo 'cached';
1100
-        }else{
1101
-            $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1102
-            $this->response =& $response;
1100
+        } else {
1101
+            $response = SugarBean::get_union_related_list($sugarbean, $this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page, $this->query_limit, $subpanel_def);
1102
+            $this->response = & $response;
1103 1103
         }
1104 1104
         $list = $response['list'];
1105 1105
         $row_count = $response['row_count'];
1106 1106
         $next_offset = $response['next_offset'];
1107 1107
         $previous_offset = $response['previous_offset'];
1108
-        if(!empty($response['current_offset']))$current_offset = $response['current_offset'];
1108
+        if (!empty($response['current_offset']))$current_offset = $response['current_offset'];
1109 1109
         global $list_view_row_count;
1110 1110
         $list_view_row_count = $row_count;
1111
-        $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean,$subpanel_def);
1111
+        $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean, $subpanel_def);
1112 1112
 
1113 1113
         return array('list'=>$list, 'parent_data'=>$response['parent_data'], 'query'=>$response['query']);
1114 1114
     }
@@ -1116,34 +1116,34 @@  discard block
 block discarded – undo
1116 1116
     function getBaseURL($html_varName) {
1117 1117
         static $cache = array();
1118 1118
 
1119
-        if(!empty($cache[$html_varName]))return $cache[$html_varName];
1120
-        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount','current_query_by_page');
1121
-        if(!empty($this->base_URL)) {
1119
+        if (!empty($cache[$html_varName]))return $cache[$html_varName];
1120
+        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'current_query_by_page');
1121
+        if (!empty($this->base_URL)) {
1122 1122
             return $this->base_URL;
1123 1123
         }
1124 1124
 
1125 1125
             $baseurl = $_SERVER['PHP_SELF'];
1126
-            if(empty($baseurl)) {
1126
+            if (empty($baseurl)) {
1127 1127
                 $baseurl = 'index.php';
1128 1128
             }
1129 1129
 
1130 1130
             /*fixes an issue with deletes when doing a search*/
1131
-            foreach(array_merge($_GET, $_POST) as $name=>$value) {
1131
+            foreach (array_merge($_GET, $_POST) as $name=>$value) {
1132 1132
                 //echo ("$name = $value <br/>");
1133
-                if(!empty($value) && $name != 'sort_order' //&& $name != ListView::getSessionVariableName($html_varName,"ORDER_BY")
1134
-                        && $name != ListView::getSessionVariableName($html_varName,"offset")
1133
+                if (!empty($value) && $name != 'sort_order' //&& $name != ListView::getSessionVariableName($html_varName,"ORDER_BY")
1134
+                        && $name != ListView::getSessionVariableName($html_varName, "offset")
1135 1135
                         /*&& substr_count($name, "ORDER_BY")==0*/ && !in_array($name, $blockVariables))
1136 1136
                 {
1137
-                    if(is_array($value)) {
1138
-                        foreach($value as $valuename=>$valuevalue) {
1139
-                            if(substr_count($baseurl, '?') > 0)
1137
+                    if (is_array($value)) {
1138
+                        foreach ($value as $valuename=>$valuevalue) {
1139
+                            if (substr_count($baseurl, '?') > 0)
1140 1140
                                 $baseurl	.= "&{$name}[]=".$valuevalue;
1141 1141
                             else
1142 1142
                                 $baseurl	.= "?{$name}[]=".$valuevalue;
1143 1143
                         }
1144 1144
                     } else {
1145 1145
                         $value = urlencode($value);
1146
-                        if(substr_count($baseurl, '?') > 0) {
1146
+                        if (substr_count($baseurl, '?') > 0) {
1147 1147
                             $baseurl	.= "&$name=$value";
1148 1148
                         } else {
1149 1149
                             $baseurl	.= "?$name=$value";
@@ -1153,17 +1153,17 @@  discard block
 block discarded – undo
1153 1153
             }
1154 1154
 
1155 1155
 
1156
-            if($_SERVER['REQUEST_METHOD'] == 'POST') {
1156
+            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1157 1157
                 // at this point it is possible that the above foreach already executed resulting in double ?'s in the url
1158
-                if(substr_count($baseurl, '?') == 0) {
1158
+                if (substr_count($baseurl, '?') == 0) {
1159 1159
                     $baseurl .= '?';
1160 1160
                 }
1161
-                if(isset($_REQUEST['action'])) $baseurl.= '&action='.$_REQUEST['action'];
1162
-                if(isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record'];
1163
-                if(isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module'];
1161
+                if (isset($_REQUEST['action'])) $baseurl .= '&action='.$_REQUEST['action'];
1162
+                if (isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record'];
1163
+                if (isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module'];
1164 1164
             }
1165 1165
 
1166
-            $baseurl .= "&".ListView::getSessionVariableName($html_varName,"offset")."=";
1166
+            $baseurl .= "&".ListView::getSessionVariableName($html_varName, "offset")."=";
1167 1167
             $cache[$html_varName] = $baseurl;
1168 1168
             return $baseurl;
1169 1169
     }
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
     * All Rights Reserved.
1178 1178
     * Contributor(s): ______________________________________..
1179 1179
     */
1180
-    function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean=null, $subpanel_def=null, $col_count = 20) {
1180
+    function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean = null, $subpanel_def = null, $col_count = 20) {
1181 1181
 
1182 1182
         global $export_module;
1183 1183
         global $sugar_config;
@@ -1187,40 +1187,40 @@  discard block
 block discarded – undo
1187 1187
 
1188 1188
         $start_record = $current_offset + 1;
1189 1189
 
1190
-        if(!is_numeric($col_count))
1190
+        if (!is_numeric($col_count))
1191 1191
             $col_count = 20;
1192 1192
 
1193
-        if($row_count == 0)
1193
+        if ($row_count == 0)
1194 1194
             $start_record = 0;
1195 1195
 
1196 1196
         $end_record = $start_record + $this->records_per_page;
1197 1197
         // back up the the last page.
1198
-        if($end_record > $row_count+1) {
1199
-            $end_record = $row_count+1;
1198
+        if ($end_record > $row_count + 1) {
1199
+            $end_record = $row_count + 1;
1200 1200
         }
1201 1201
         // Determine the start location of the last page
1202
-        if($row_count == 0)
1202
+        if ($row_count == 0)
1203 1203
             $number_pages = 0;
1204 1204
         else
1205 1205
             $number_pages = floor(($row_count - 1) / $this->records_per_page);
1206 1206
 
1207 1207
         $last_offset = $number_pages * $this->records_per_page;
1208 1208
 
1209
-        if(empty($this->query_limit)  || $this->query_limit > $this->records_per_page) {
1209
+        if (empty($this->query_limit) || $this->query_limit > $this->records_per_page) {
1210 1210
             $this->base_URL = $this->getBaseURL($html_varName);
1211 1211
             $dynamic_url = '';
1212 1212
 
1213
-            if($this->is_dynamic) {
1214
-                $dynamic_url .='&'. $this->getSessionVariableName($html_varName,'ORDER_BY') . '='. $this->getSessionVariable($html_varName,'ORDER_BY').'&sort_order='.$this->sort_order.'&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->subpanel_module;
1213
+            if ($this->is_dynamic) {
1214
+                $dynamic_url .= '&'.$this->getSessionVariableName($html_varName, 'ORDER_BY').'='.$this->getSessionVariable($html_varName, 'ORDER_BY').'&sort_order='.$this->sort_order.'&to_pdf=true&action=SubPanelViewer&subpanel='.$this->subpanel_module;
1215 1215
             }
1216 1216
 
1217 1217
             $current_URL = htmlentities($this->base_URL.$current_offset.$dynamic_url);
1218 1218
             $start_URL = htmlentities($this->base_URL."0".$dynamic_url);
1219
-            $previous_URL  = htmlentities($this->base_URL.$previous_offset.$dynamic_url);
1219
+            $previous_URL = htmlentities($this->base_URL.$previous_offset.$dynamic_url);
1220 1220
             $next_URL  = htmlentities($this->base_URL.$next_offset.$dynamic_url);
1221
-            $end_URL  = htmlentities($this->base_URL.'end'.$dynamic_url);
1221
+            $end_URL = htmlentities($this->base_URL.'end'.$dynamic_url);
1222 1222
 
1223
-            if(!empty($this->start_link_wrapper)) {
1223
+            if (!empty($this->start_link_wrapper)) {
1224 1224
                 $current_URL = $this->start_link_wrapper.$current_URL.$this->end_link_wrapper;
1225 1225
                 $start_URL = $this->start_link_wrapper.$start_URL.$this->end_link_wrapper;
1226 1226
                 $previous_URL = $this->start_link_wrapper.$previous_URL.$this->end_link_wrapper;
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 
1231 1231
             $moduleString = htmlspecialchars("{$currentModule}_{$html_varName}_offset");
1232 1232
             $moduleStringOrder = htmlspecialchars("{$currentModule}_{$html_varName}_ORDER_BY");
1233
-            if($this->shouldProcess && !$this->multi_select_popup) {
1233
+            if ($this->shouldProcess && !$this->multi_select_popup) {
1234 1234
                 // check the checkboxes onload
1235 1235
                 echo "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n";
1236 1236
 
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
                 $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid'];
1239 1239
                 $select_entire_list = ($massUpdateRun) ? 0 : (isset($_POST['select_entire_list']) ? $_POST['select_entire_list'] : (isset($_REQUEST['select_entire_list']) ? htmlspecialchars($_REQUEST['select_entire_list']) : 0));
1240 1240
 
1241
-                echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" .
1241
+                echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n".
1242 1242
                     "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n".
1243 1243
                     "<input type='hidden' name='{$moduleString}' value='0'>\n".
1244 1244
                     "<input type='hidden' name='{$moduleStringOrder}' value='0'>\n";
@@ -1248,64 +1248,64 @@  discard block
 block discarded – undo
1248 1248
 
1249 1249
             $GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, $previous_offset, $next_offset, $last_offset)");
1250 1250
 
1251
-            if(0 == $current_offset) {
1252
-                $start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1253
-                $previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1251
+            if (0 == $current_offset) {
1252
+                $start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off", "aborder='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1253
+                $previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1254 1254
             } else {
1255
-                if($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks.
1256
-                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1257
-                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1258
-                } elseif($this->shouldProcess) {
1259
-                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\"; sListView.save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1260
-                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\"; sListView.save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1255
+                if ($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks.
1256
+                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1257
+                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1258
+                } elseif ($this->shouldProcess) {
1259
+                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\"; sListView.save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1260
+                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\"; sListView.save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1261 1261
                 } else {
1262 1262
                     $onClick = '';
1263
-                    if(0 != preg_match('/javascript.*/', $start_URL)){
1263
+                    if (0 != preg_match('/javascript.*/', $start_URL)) {
1264 1264
                         $onClick = "\"$start_URL;\"";
1265
-                    }else{
1266
-                        $onClick ="'location.href=\"$start_URL\";'";
1265
+                    } else {
1266
+                        $onClick = "'location.href=\"$start_URL\";'";
1267 1267
                     }
1268
-                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1268
+                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1269 1269
 
1270 1270
                     $onClick = '';
1271
-                    if(0 != preg_match('/javascript.*/', $previous_URL)){
1271
+                    if (0 != preg_match('/javascript.*/', $previous_URL)) {
1272 1272
                         $onClick = "\"$previous_URL;\"";
1273
-                    }else{
1273
+                    } else {
1274 1274
                         $onClick = "'location.href=\"$previous_URL\";'";
1275 1275
                     }
1276
-                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1276
+                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1277 1277
                 }
1278 1278
             }
1279 1279
 
1280
-            if($last_offset <= $current_offset) {
1281
-                $end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1282
-                $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1280
+            if ($last_offset <= $current_offset) {
1281
+                $end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1282
+                $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off", "aborder='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1283 1283
             } else {
1284
-                if($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks.
1285
-                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks($last_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1286
-                    if(!empty($sugar_config['disable_count_query'])) {
1284
+                if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks.
1285
+                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks($last_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1286
+                    if (!empty($sugar_config['disable_count_query'])) {
1287 1287
                         $end_link = '';
1288 1288
                     }
1289
-                    $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1290
-                } elseif($this->shouldProcess) {
1291
-                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1292
-                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\"; sListView.save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1289
+                    $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1290
+                } elseif ($this->shouldProcess) {
1291
+                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1292
+                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\"; sListView.save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1293 1293
                 } else {
1294 1294
                     $onClick = '';
1295
-                    if(0 != preg_match('/javascript.*/', $next_URL)){
1295
+                    if (0 != preg_match('/javascript.*/', $next_URL)) {
1296 1296
                         $onClick = "\"$next_URL;\"";
1297
-                    }else{
1298
-                        $onClick ="'location.href=\"$next_URL\";'";
1297
+                    } else {
1298
+                        $onClick = "'location.href=\"$next_URL\";'";
1299 1299
                     }
1300
-                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1300
+                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1301 1301
 
1302 1302
                     $onClick = '';
1303
-                    if(0 != preg_match('/javascript.*/', $end_URL)){
1303
+                    if (0 != preg_match('/javascript.*/', $end_URL)) {
1304 1304
                         $onClick = "\"$end_URL;\"";
1305
-                    }else{
1305
+                    } else {
1306 1306
                         $onClick = "'location.href=\"$end_URL\";'";
1307 1307
                     }
1308
-                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1308
+                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1309 1309
 
1310 1310
                 }
1311 1311
             }
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
             $GLOBALS['log']->info("Offset (next, current, prev)($next_offset, $current_offset, $previous_offset)");
1314 1314
             $GLOBALS['log']->info("Start/end records ($start_record, $end_record)");
1315 1315
 
1316
-            $end_record = $end_record-1;
1316
+            $end_record = $end_record - 1;
1317 1317
 
1318 1318
 $script_href = "<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $this->records_per_page)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;&#x28;{$this->records_per_page}&#x29;&#x200E;</a>"
1319 1319
  . "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$row_count}&#x29;&#x200E;</a>"
@@ -1336,14 +1336,14 @@  discard block
 block discarded – undo
1336 1336
                 }
1337 1337
                 </script>";
1338 1338
 
1339
-            if($this->show_select_menu)
1339
+            if ($this->show_select_menu)
1340 1340
             {
1341 1341
                 $total_label = "";
1342 1342
                 $total = $row_count;
1343 1343
                 $pageTotal = ($row_count > 0) ? $end_record - $start_record + 1 : 0;
1344 1344
                 if (!empty($GLOBALS['sugar_config']['disable_count_query']) && $GLOBALS['sugar_config']['disable_count_query'] === true && $total > $pageTotal) {
1345 1345
                     $this->show_plus = true;
1346
-                    $total =  $pageTotal;
1346
+                    $total = $pageTotal;
1347 1347
                     $total_label = $total.'+';
1348 1348
                 } else {
1349 1349
                     $this->show_plus = false;
@@ -1365,16 +1365,16 @@  discard block
 block discarded – undo
1365 1365
                     'id' => 'selectLink',
1366 1366
                     'buttons' => $menuItems,
1367 1367
                     'flat' => false,
1368
-                ),$this->xTemplate);
1368
+                ), $this->xTemplate);
1369 1369
 
1370 1370
             } else {
1371 1371
                 $select_link = "&nbsp;";
1372 1372
             }
1373 1373
 
1374
-            $export_link = '<input class="button" type="button" value="'.$this->local_app_strings['LBL_EXPORT'].'" ' .
1374
+            $export_link = '<input class="button" type="button" value="'.$this->local_app_strings['LBL_EXPORT'].'" '.
1375 1375
                     'onclick="return sListView.send_form(true, \''.$_REQUEST['module'].'\', \'index.php?entryPoint=export\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\')">';
1376 1376
 
1377
-            if($this->show_delete_button) {
1377
+            if ($this->show_delete_button) {
1378 1378
                 $delete_link = '<input class="button" type="button" id="delete_button" name="Delete" value="'.$this->local_app_strings['LBL_DELETE_BUTTON_LABEL'].'" onclick="return sListView.send_mass_update(\'selected\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\', 1)">';
1379 1379
             } else {
1380 1380
                 $delete_link = '&nbsp;';
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
             $admin->retrieveSettings('system');
1385 1385
 
1386 1386
             $user_merge = $current_user->getPreference('mailmerge_on');
1387
-            if($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) {
1387
+            if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) {
1388 1388
                 echo "<script>
1389 1389
                 function mailmerge_dialog(el) {
1390 1390
                    	var \$dialog = \$('<div></div>')
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
                         . "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?action=index&module=MailMerge&entire=true\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>')
1394 1394
 					.dialog({
1395 1395
 						autoOpen: false,
1396
-						title: '". $this->local_app_strings['LBL_MAILMERGE']."',
1396
+						title: '".$this->local_app_strings['LBL_MAILMERGE']."',
1397 1397
 						width: 150,
1398 1398
 						position: {
1399 1399
 						    my: myPos,
@@ -1409,16 +1409,16 @@  discard block
 block discarded – undo
1409 1409
                 $merge_link = "&nbsp;";
1410 1410
             }
1411 1411
 
1412
-            $selected_objects_span = "&nbsp;|&nbsp;{$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input  style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='" . ((isset($_POST['mass'])) ? count($_POST['mass']): 0) . "' />";
1412
+            $selected_objects_span = "&nbsp;|&nbsp;{$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input  style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='".((isset($_POST['mass'])) ? count($_POST['mass']) : 0)."' />";
1413 1413
 
1414
-            if($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import'
1414
+            if ($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import'
1415 1415
                 || $this->show_export_button == false
1416 1416
                 || (!empty($sugar_config['disable_export']))
1417 1417
                 || (!empty($sugar_config['admin_export_only'])
1418 1418
                 && !(
1419 1419
                         is_admin($current_user)
1420 1420
                         || (ACLController::moduleSupportsACL($_REQUEST['module'])
1421
-                            && ACLAction::getUserAccessLevel($current_user->id,$_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED
1421
+                            && ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED
1422 1422
                             && (ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN ||
1423 1423
                                 ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN_DEV)))))
1424 1424
             {
@@ -1427,13 +1427,13 @@  discard block
 block discarded – undo
1427 1427
                 }
1428 1428
                 $export_link = "&nbsp;";
1429 1429
                 $merge_link = "&nbsp;";
1430
-            } elseif($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") {
1430
+            } elseif ($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") {
1431 1431
                 $merge_link = "&nbsp;";
1432 1432
             }
1433 1433
 
1434
-            if($this->show_paging == true) {
1435
-                if(!empty($sugar_config['disable_count_query'])) {
1436
-                    if($row_count > $end_record) {
1434
+            if ($this->show_paging == true) {
1435
+                if (!empty($sugar_config['disable_count_query'])) {
1436
+                    if ($row_count > $end_record) {
1437 1437
                         $row_count .= '+';
1438 1438
                     }
1439 1439
                 }
@@ -1449,16 +1449,16 @@  discard block
 block discarded – undo
1449 1449
                     $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"  >";
1450 1450
 
1451 1451
                     //attempt to get the query to recreate this subpanel
1452
-                    if(!empty($this->response)){
1453
-                        $response =& $this->response;
1454
-                    }else{
1455
-                        $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1452
+                    if (!empty($this->response)) {
1453
+                        $response = & $this->response;
1454
+                    } else {
1455
+                        $response = SugarBean::get_union_related_list($sugarbean, $this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page, $this->query_limit, $subpanel_def);
1456 1456
                         $this->response = $response;
1457 1457
                     }
1458 1458
                     //if query is present, then pass it in as parameter
1459
-                    if (isset($response['query']) && !empty($response['query'])){
1459
+                    if (isset($response['query']) && !empty($response['query'])) {
1460 1460
                         $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']);
1461
-                    }else{
1461
+                    } else {
1462 1462
                         $html_text .= $subpanelTiles->get_buttons($subpanel_def);
1463 1463
                     }
1464 1464
                 }
@@ -1468,11 +1468,11 @@  discard block
 block discarded – undo
1468 1468
                 $html_text .= "</td>\n<td nowrap align=\"right\">".$start_link."&nbsp;&nbsp;".$previous_link."&nbsp;&nbsp;<span class='pageNumbers'>(".$start_record." - ".$end_record." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")</span>&nbsp;&nbsp;".$next_link."&nbsp;&nbsp;".$end_link."</td></tr></table>\n";
1469 1469
                 $html_text .= "</td>\n";
1470 1470
                 $html_text .= "</tr>\n";
1471
-                $this->xTemplate->assign("PAGINATION",$html_text);
1471
+                $this->xTemplate->assign("PAGINATION", $html_text);
1472 1472
             }
1473 1473
 
1474 1474
             //C.L. - Fix for 23461
1475
-            if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1475
+            if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1476 1476
                 $_SESSION['export_where'] = $this->query_where;
1477 1477
             }
1478 1478
             $this->xTemplate->parse($xtemplateSection.".list_nav_row");
@@ -1481,24 +1481,24 @@  discard block
 block discarded – undo
1481 1481
 
1482 1482
     function processOrderBy($html_varName) {
1483 1483
 
1484
-        if(!isset($this->base_URL)) {
1484
+        if (!isset($this->base_URL)) {
1485 1485
             $this->base_URL = $_SERVER['PHP_SELF'];
1486 1486
 
1487
-            if(isset($_SERVER['QUERY_STRING'])) {
1488
-                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=[0-9a-zA-Z\_\.]*/","",$this->base_URL .'?'.$_SERVER['QUERY_STRING']);
1489
-                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"offset")."=[0-9]*/","",$this->base_URL);
1487
+            if (isset($_SERVER['QUERY_STRING'])) {
1488
+                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName, "ORDER_BY")."=[0-9a-zA-Z\_\.]*/", "", $this->base_URL.'?'.$_SERVER['QUERY_STRING']);
1489
+                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName, "offset")."=[0-9]*/", "", $this->base_URL);
1490 1490
             }
1491
-            if($_SERVER['REQUEST_METHOD'] == 'POST') {
1491
+            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1492 1492
                 $this->base_URL .= '?';
1493
-                if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
1494
-                if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
1495
-                if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
1493
+                if (isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
1494
+                if (isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
1495
+                if (isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
1496 1496
             }
1497
-            $this->base_URL .= "&".$this->getSessionVariableName($html_varName,"offset")."=";
1497
+            $this->base_URL .= "&".$this->getSessionVariableName($html_varName, "offset")."=";
1498 1498
         }
1499 1499
 
1500
-        if($this->is_dynamic) {
1501
-            $this->base_URL.='&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->source_module;
1500
+        if ($this->is_dynamic) {
1501
+            $this->base_URL .= '&to_pdf=true&action=SubPanelViewer&subpanel='.$this->source_module;
1502 1502
         }
1503 1503
 
1504 1504
         //bug43465 start
@@ -1506,19 +1506,19 @@  discard block
 block discarded – undo
1506 1506
         {
1507 1507
             foreach ($this->appendToBaseUrl as $key => $value)
1508 1508
             {
1509
-                $fullRequestString = $key . '=' . $value;
1509
+                $fullRequestString = $key.'='.$value;
1510 1510
 
1511 1511
                 if ($this->base_URL == "/index.php")
1512 1512
                 {
1513 1513
                     $this->base_URL .= "?";
1514 1514
                 } else
1515 1515
                 {
1516
-                    if ($fullRequestString == substr($this->baseURL, '-' . strlen($fullRequestString)))
1516
+                    if ($fullRequestString == substr($this->baseURL, '-'.strlen($fullRequestString)))
1517 1517
                     {
1518
-                        $this->base_URL = preg_replace("/&" . $key . "\=.*/", "", $this->base_URL);
1518
+                        $this->base_URL = preg_replace("/&".$key."\=.*/", "", $this->base_URL);
1519 1519
                     } else
1520 1520
                     {
1521
-                        $this->base_URL = preg_replace("/&" . $key . "\=.*?&/", "&", $this->base_URL);
1521
+                        $this->base_URL = preg_replace("/&".$key."\=.*?&/", "&", $this->base_URL);
1522 1522
                     }
1523 1523
                     $this->base_URL .= "&";
1524 1524
                 }
@@ -1530,9 +1530,9 @@  discard block
 block discarded – undo
1530 1530
         }
1531 1531
         //bug43465 end
1532 1532
 
1533
-        $sort_URL_base = $this->base_URL. "&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=";
1533
+        $sort_URL_base = $this->base_URL."&".$this->getSessionVariableName($html_varName, "ORDER_BY")."=";
1534 1534
 
1535
-        if($sort_URL_base !== "")
1535
+        if ($sort_URL_base !== "")
1536 1536
         {
1537 1537
             $this->xTemplate->assign("ORDER_BY", $sort_URL_base);
1538 1538
             return $sort_URL_base;
@@ -1583,19 +1583,19 @@  discard block
 block discarded – undo
1583 1583
         $mergeList = array();
1584 1584
         $module = '';
1585 1585
         //todo what is this?  It is using an array as a boolean
1586
-        while(list($aVal, $aItem) = each($data))
1586
+        while (list($aVal, $aItem) = each($data))
1587 1587
         {
1588
-            if(isset($this->data_array)) {
1588
+            if (isset($this->data_array)) {
1589 1589
                 $fields = $this->data_array;
1590 1590
             } else {
1591 1591
                 $aItem->check_date_relationships_load();
1592 1592
                 $fields = $aItem->get_list_view_data();
1593 1593
             }
1594 1594
 
1595
-            if(is_object($aItem)) { // cn: bug 5349
1595
+            if (is_object($aItem)) { // cn: bug 5349
1596 1596
                 //add item id to merge list, if the button is clicked
1597 1597
                 $mergeList[] = $aItem->id;
1598
-                if(empty($module)) {
1598
+                if (empty($module)) {
1599 1599
                     $module = $aItem->module_dir;
1600 1600
                 }
1601 1601
             }
@@ -1604,37 +1604,37 @@  discard block
 block discarded – undo
1604 1604
                 $fields['OFFSET'] = ($offset + $count + 1);
1605 1605
 
1606 1606
             $fields['STAMP'] = $timeStamp;
1607
-            if($this->shouldProcess) {
1607
+            if ($this->shouldProcess) {
1608 1608
 
1609 1609
             $prerow = '';
1610
-            if(!isset($this->data_array)) {
1611
-                $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "'>";
1610
+            if (!isset($this->data_array)) {
1611
+                $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='".$fields['ID']."'>";
1612 1612
             }
1613 1613
             $this->xTemplate->assign('PREROW', $prerow);
1614 1614
 
1615 1615
             $this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox'  title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."'  name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>");
1616 1616
             }
1617
-            if(!isset($this->data_array)) {
1617
+            if (!isset($this->data_array)) {
1618 1618
                 $tag = $aItem->listviewACLHelper();
1619
-                $this->xTemplate->assign('TAG',$tag) ;
1619
+                $this->xTemplate->assign('TAG', $tag);
1620 1620
             }
1621 1621
 
1622
-            if($oddRow)
1622
+            if ($oddRow)
1623 1623
             {
1624 1624
                 $ROW_COLOR = 'oddListRow';
1625
-                $BG_COLOR =  $odd_bg;
1625
+                $BG_COLOR = $odd_bg;
1626 1626
             }
1627 1627
             else
1628 1628
             {
1629 1629
                 $ROW_COLOR = 'evenListRow';
1630
-                $BG_COLOR =  $even_bg;
1630
+                $BG_COLOR = $even_bg;
1631 1631
             }
1632 1632
             $oddRow = !$oddRow;
1633 1633
 
1634 1634
             $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
1635 1635
             $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
1636 1636
 
1637
-            if(isset($this->data_array))
1637
+            if (isset($this->data_array))
1638 1638
             {
1639 1639
                 $this->xTemplate->assign('KEY', $aVal);
1640 1640
                 $this->xTemplate->assign('VALUE', $aItem);
@@ -1645,23 +1645,23 @@  discard block
 block discarded – undo
1645 1645
             {
1646 1646
     //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
1647 1647
     // Bug #2786
1648
-                if($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/' . $aItem->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'))) {
1648
+                if ($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/'.$aItem->module_dir.'/metadata/additionalDetails.php') || file_exists('custom/modules/'.$aItem->module_dir.'/metadata/additionalDetails.php'))) {
1649 1649
 
1650
-                    $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1651
-                    if(file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')){
1652
-                        $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1650
+                    $additionalDetailsFile = 'modules/'.$aItem->module_dir.'/metadata/additionalDetails.php';
1651
+                    if (file_exists('custom/modules/'.$aItem->module_dir.'/metadata/additionalDetails.php')) {
1652
+                        $additionalDetailsFile = 'custom/modules/'.$aItem->module_dir.'/metadata/additionalDetails.php';
1653 1653
                     }
1654 1654
 
1655 1655
                     require_once($additionalDetailsFile);
1656
-                    $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
1656
+                    $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction).$aItem->object_name;
1657 1657
                     $results = $ad_function($fields);
1658 1658
                     $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
1659 1659
 
1660
-                    if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
1660
+                    if (trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
1661 1661
                     $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']].'</a>';
1662 1662
                 }
1663 1663
 
1664
-                if($aItem->ACLAccess('Delete')) {
1664
+                if ($aItem->ACLAccess('Delete')) {
1665 1665
                     $delete = '<a class="listViewTdToolsS1" onclick="return confirm(\''.$this->local_app_strings['NTC_DELETE_CONFIRMATION'].'\')" href="'.'index.php?action=Delete&module='.$aItem->module_dir.'&record='.$fields['ID'].'&return_module='.$aItem->module_dir.'&return_action=index&return_id=">'.$this->local_app_strings['LBL_DELETE_INLINE'].'</a>';
1666 1666
                     require_once('include/Smarty/plugins/function.sugar_action_menu.php');
1667 1667
                     $fields['DELETE_BUTTON'] = smarty_function_sugar_action_menu(array(
@@ -1675,26 +1675,26 @@  discard block
 block discarded – undo
1675 1675
                 $aItem->setupCustomFields($aItem->module_dir);
1676 1676
                 $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
1677 1677
             }
1678
-            if(!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
1678
+            if (!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
1679 1679
                 $count++;
1680 1680
             }
1681
-            if(isset($this->data_array)) {
1681
+            if (isset($this->data_array)) {
1682 1682
                 $count++;
1683 1683
             }
1684
-            if(!isset($this->data_array)) {
1684
+            if (!isset($this->data_array)) {
1685 1685
                 $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
1686 1686
 
1687
-                if($this->xTemplate->exists($xtemplateSection.'.row.pro')) {
1687
+                if ($this->xTemplate->exists($xtemplateSection.'.row.pro')) {
1688 1688
                     $this->xTemplate->parse($xtemplateSection.'.row.pro');
1689 1689
                 }
1690 1690
             }
1691
-            $this->xTemplate->parse($xtemplateSection . '.row');
1691
+            $this->xTemplate->parse($xtemplateSection.'.row');
1692 1692
 
1693
-            if(isset($fields['ID'])) {
1693
+            if (isset($fields['ID'])) {
1694 1694
                 $associated_row_data[$fields['ID']] = $fields;
1695 1695
                 // Bug 38908: cleanup data for JS to avoid having &nbsp; shuffled around
1696
-                foreach($fields as $key => $value) {
1697
-                    if($value == '&nbsp;') {
1696
+                foreach ($fields as $key => $value) {
1697
+                    if ($value == '&nbsp;') {
1698 1698
                         $associated_row_data[$fields['ID']][$key] = '';
1699 1699
                     }
1700 1700
                 }
@@ -1703,21 +1703,21 @@  discard block
 block discarded – undo
1703 1703
 
1704 1704
         $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
1705 1705
         $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
1706
-        if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1706
+        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1707 1707
             $_SESSION['MAILMERGE_MODULE'] = $module;
1708 1708
         }
1709 1709
 
1710
-        if($this->process_for_popups)
1710
+        if ($this->process_for_popups)
1711 1711
         {
1712 1712
             $json = getJSONobj();
1713 1713
             $is_show_fullname = showFullName() ? 1 : 0;
1714
-            $associated_javascript_data = '<script type="text/javascript">' . "\n"
1714
+            $associated_javascript_data = '<script type="text/javascript">'."\n"
1715 1715
                 //. '<!-- // associated javascript data generated by ListView' . "\n"
1716 1716
                 . 'var associated_javascript_data = '
1717
-                . $json->encode($associated_row_data) . ";\n"
1717
+                . $json->encode($associated_row_data).";\n"
1718 1718
                 //. '-->' . "\n"
1719 1719
                 . 'var is_show_fullname = '
1720
-                . $is_show_fullname . ";\n"
1720
+                . $is_show_fullname.";\n"
1721 1721
                 . '</script>';
1722 1722
             $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
1723 1723
         }
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
     function getLayoutManager()
1730 1730
     {
1731 1731
         require_once('include/generic/LayoutManager.php');
1732
-        if($this->layout_manager == null)
1732
+        if ($this->layout_manager == null)
1733 1733
         {
1734 1734
             $this->layout_manager = new LayoutManager();
1735 1735
         }
@@ -1742,36 +1742,36 @@  discard block
 block discarded – undo
1742 1742
 
1743 1743
 
1744 1744
         $layout_manager = $this->getLayoutManager();
1745
-        $layout_manager->setAttribute('order_by_link',$this->processOrderBy($html_var));
1746
-        $layout_manager->setAttribute('context','HeaderCell');
1747
-        $layout_manager->setAttribute('image_path',$this->local_image_path);
1748
-        $layout_manager->setAttribute('html_varName',$html_var);
1745
+        $layout_manager->setAttribute('order_by_link', $this->processOrderBy($html_var));
1746
+        $layout_manager->setAttribute('context', 'HeaderCell');
1747
+        $layout_manager->setAttribute('image_path', $this->local_image_path);
1748
+        $layout_manager->setAttribute('html_varName', $html_var);
1749 1749
         $layout_manager->setAttribute('module_name', $source_module);
1750
-        list($orderBy,$desc) = $this->getOrderByInfo($html_var);
1750
+        list($orderBy, $desc) = $this->getOrderByInfo($html_var);
1751 1751
 
1752
-        if($orderBy == 'amount*1')
1752
+        if ($orderBy == 'amount*1')
1753 1753
         {
1754
-            $orderBy=  'amount';
1754
+            $orderBy = 'amount';
1755 1755
         }
1756 1756
 		$buttons = false;
1757 1757
         $col_count = 0;
1758
-        foreach($subpanel_def->get_list_fields() as $column_name=>$widget_args)
1758
+        foreach ($subpanel_def->get_list_fields() as $column_name=>$widget_args)
1759 1759
         {
1760 1760
             $usage = empty($widget_args['usage']) ? '' : $widget_args['usage'];
1761
-            if($usage != 'query_only' || !empty($widget_args['force_query_only_display']))
1761
+            if ($usage != 'query_only' || !empty($widget_args['force_query_only_display']))
1762 1762
             {
1763 1763
                 $imgArrow = '';
1764 1764
 
1765
-                if($orderBy == $column_name || (isset($widget_args['sort_by']) && str_replace('.','_',$widget_args['sort_by']) == $orderBy))
1765
+                if ($orderBy == $column_name || (isset($widget_args['sort_by']) && str_replace('.', '_', $widget_args['sort_by']) == $orderBy))
1766 1766
                 {
1767 1767
                     $imgArrow = "_down";
1768
-                    if($this->sort_order == 'asc') {
1768
+                    if ($this->sort_order == 'asc') {
1769 1769
                         $imgArrow = "_up";
1770 1770
                     }
1771 1771
                 }
1772 1772
 
1773 1773
                 if (!preg_match("/_button/i", $column_name)) {
1774
-	                $widget_args['name']=$column_name;
1774
+	                $widget_args['name'] = $column_name;
1775 1775
 	                $widget_args['sort'] = $imgArrow;
1776 1776
 	                $widget_args['start_link_wrapper'] = $this->start_link_wrapper;
1777 1777
 	                $widget_args['end_link_wrapper'] = $this->end_link_wrapper;
@@ -1781,8 +1781,8 @@  discard block
 block discarded – undo
1781 1781
 	                $cell_width = empty($widget_args['width']) ? '' : $widget_args['width'];
1782 1782
 	                $this->xTemplate->assign('HEADER_CELL', $widget_contents);
1783 1783
 	                static $count;
1784
-	            if(!isset($count))$count = 0; else $count++;
1785
-                    if($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"';
1784
+	            if (!isset($count))$count = 0; else $count++;
1785
+                    if ($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"';
1786 1786
                     else {
1787 1787
                         $footable = 'data-hide="phone"';
1788 1788
                         if ($col_count > 2) $footable = 'data-hide="phone,phonelandscape"';
@@ -1799,7 +1799,7 @@  discard block
 block discarded – undo
1799 1799
             ++$col_count;
1800 1800
         }
1801 1801
 
1802
-        if($buttons) {
1802
+        if ($buttons) {
1803 1803
                     $this->xTemplate->assign('FOOTABLE', '');
1804 1804
         			$this->xTemplate->assign('HEADER_CELL', "&nbsp;");
1805 1805
         			$this->xTemplate->assign('CELL_COUNT', $count);
@@ -1827,37 +1827,37 @@  discard block
 block discarded – undo
1827 1827
 
1828 1828
     function processListViewTwo($seed, $xTemplateSection, $html_varName) {
1829 1829
         global $current_user;
1830
-        if(!isset($this->xTemplate)) {
1830
+        if (!isset($this->xTemplate)) {
1831 1831
             $this->createXTemplate();
1832 1832
         }
1833 1833
 
1834 1834
         $isSugarBean = is_subclass_of($seed, "SugarBean");
1835 1835
         $list = null;
1836 1836
 
1837
-        if($isSugarBean) {
1837
+        if ($isSugarBean) {
1838 1838
             $list = $this->processSugarBean($xTemplateSection, $html_varName, $seed);
1839 1839
         } else {
1840 1840
             $list = $seed;
1841 1841
         }
1842 1842
 
1843 1843
         if (is_object($seed) && isset($seed->object_name) && $seed->object_name == 'WorkFlow') {
1844
-            $tab=array();
1844
+            $tab = array();
1845 1845
             $access = get_workflow_admin_modules_for_user($current_user);
1846 1846
             for ($i = 0; $i < count($list); $i++) {
1847
-                if(!empty($access[$list[$i]->base_module])){
1848
-                    $tab[]=$list[$i];
1847
+                if (!empty($access[$list[$i]->base_module])) {
1848
+                    $tab[] = $list[$i];
1849 1849
                 }
1850 1850
             }
1851 1851
             $list = $tab;
1852 1852
         }
1853 1853
 
1854
-        if($this->is_dynamic) {
1855
-            $this->processHeaderDynamic($xTemplateSection,$html_varName);
1856
-            $this->processListRows($list,$xTemplateSection, $html_varName);
1854
+        if ($this->is_dynamic) {
1855
+            $this->processHeaderDynamic($xTemplateSection, $html_varName);
1856
+            $this->processListRows($list, $xTemplateSection, $html_varName);
1857 1857
         } else {
1858 1858
             $this->processSortArrows($html_varName);
1859 1859
 
1860
-            if($isSugarBean) {
1860
+            if ($isSugarBean) {
1861 1861
                 $seed->parse_additional_headers($this->xTemplate, $xTemplateSection);
1862 1862
             }
1863 1863
             $this->xTemplateAssign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
@@ -1866,19 +1866,19 @@  discard block
 block discarded – undo
1866 1866
             $this->processOrderBy($html_varName);
1867 1867
 
1868 1868
 
1869
-            $this->processListRows($list,$xTemplateSection, $html_varName);
1869
+            $this->processListRows($list, $xTemplateSection, $html_varName);
1870 1870
         }
1871 1871
 
1872
-        if($this->display_header_and_footer) {
1872
+        if ($this->display_header_and_footer) {
1873 1873
             $this->getAdditionalHeader();
1874
-            if(!empty($this->header_title)) {
1874
+            if (!empty($this->header_title)) {
1875 1875
                 echo get_form_header($this->header_title, $this->header_text, false);
1876 1876
             }
1877 1877
         }
1878 1878
 
1879 1879
         $this->xTemplate->out($xTemplateSection);
1880 1880
 
1881
-        if(isset($_SESSION['validation'])) {
1881
+        if (isset($_SESSION['validation'])) {
1882 1882
             print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
1883 1883
         }
1884 1884
     }
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
     }
1891 1891
 
1892 1892
     function getArrowUpDownStart($upDown) {
1893
-        $ext = ( SugarThemeRegistry::current()->pngSupport ? "png" : "gif" );
1893
+        $ext = (SugarThemeRegistry::current()->pngSupport ? "png" : "gif");
1894 1894
 
1895 1895
         if (!isset($upDown) || empty($upDown)) {
1896 1896
             $upDown = "";
@@ -1901,7 +1901,7 @@  discard block
 block discarded – undo
1901 1901
 	function getArrowEnd() {
1902 1902
 		$imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1903 1903
 
1904
-        list($width,$height) = ListView::getArrowImageSize();
1904
+        list($width, $height) = ListView::getArrowImageSize();
1905 1905
 
1906 1906
 		return '.'.$imgFileParts['extension']."' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">";
1907 1907
     }
@@ -1912,13 +1912,13 @@  discard block
 block discarded – undo
1912 1912
         }
1913 1913
         $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif"));
1914 1914
 
1915
-        list($width,$height) = ListView::getArrowUpDownImageSize($upDown);
1915
+        list($width, $height) = ListView::getArrowUpDownImageSize($upDown);
1916 1916
 
1917 1917
         //get the right alt tag for the sort
1918 1918
         $sortStr = translate('LBL_ALT_SORT');
1919
-        if($upDown == '_down'){
1919
+        if ($upDown == '_down') {
1920 1920
             $sortStr = translate('LBL_ALT_SORT_DESC');
1921
-        }elseif($upDown == '_up'){
1921
+        }elseif ($upDown == '_up') {
1922 1922
             $sortStr = translate('LBL_ALT_SORT_ASC');
1923 1923
         }
1924 1924
         return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>";
@@ -1926,13 +1926,13 @@  discard block
 block discarded – undo
1926 1926
 
1927 1927
 	function getArrowImageSize() {
1928 1928
 	    // jbasicChartDashletsExpColust get the non-sort image's size.. the up and down have be the same.
1929
-		$image = SugarThemeRegistry::current()->getImageURL("arrow.gif",false);
1929
+		$image = SugarThemeRegistry::current()->getImageURL("arrow.gif", false);
1930 1930
 
1931 1931
         $cache_key = 'arrow_size.'.$image;
1932 1932
 
1933 1933
         // Check the cache
1934 1934
         $result = sugar_cache_retrieve($cache_key);
1935
-        if(!empty($result))
1935
+        if (!empty($result))
1936 1936
         return $result;
1937 1937
 
1938 1938
         // No cache hit.  Calculate the value and return.
@@ -1943,13 +1943,13 @@  discard block
 block discarded – undo
1943 1943
 
1944 1944
     function getArrowUpDownImageSize($upDown) {
1945 1945
         // just get the non-sort image's size.. the up and down have be the same.
1946
-        $image = SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif",false);
1946
+        $image = SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif", false);
1947 1947
 
1948 1948
         $cache_key = 'arrowupdown_size.'.$image;
1949 1949
 
1950 1950
         // Check the cache
1951 1951
         $result = sugar_cache_retrieve($cache_key);
1952
-        if(!empty($result))
1952
+        if (!empty($result))
1953 1953
         return $result;
1954 1954
 
1955 1955
         // No cache hit.  Calculate the value and return.
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 		$orderBy = $this->getSessionVariable($html_varName, "OBL");
1964 1964
 		$desc = $this->getSessionVariable($html_varName, $orderBy.'S');
1965 1965
 		$orderBy = str_replace('.', '_', $orderBy);
1966
-		return array($orderBy,$desc);
1966
+		return array($orderBy, $desc);
1967 1967
 	}
1968 1968
 
1969 1969
     function processSortArrows($html_varName)
@@ -1971,20 +1971,20 @@  discard block
 block discarded – undo
1971 1971
 
1972 1972
         $this->xTemplateAssign("arrow_start", $this->getArrowStart());
1973 1973
 
1974
-        list($orderBy,$desc) = $this->getOrderByInfo($html_varName);
1974
+        list($orderBy, $desc) = $this->getOrderByInfo($html_varName);
1975 1975
 
1976 1976
 		$imgArrow = "_up";
1977
-		if($desc) {
1977
+		if ($desc) {
1978 1978
 			$imgArrow = "_down";
1979 1979
 		}
1980 1980
 		/**
1981 1981
 		 * @deprecated only used by legacy opportunites listview, nothing current. Leaving for BC
1982 1982
 		 */
1983
-		if($orderBy == 'amount')
1983
+		if ($orderBy == 'amount')
1984 1984
 		{
1985 1985
 			$this->xTemplateAssign('amount_arrow', $imgArrow);
1986 1986
 		}
1987
-		else if($orderBy == 'amount_usdollar')
1987
+		else if ($orderBy == 'amount_usdollar')
1988 1988
 		{
1989 1989
 			$this->xTemplateAssign('amount_usdollar_arrow', $imgArrow);
1990 1990
 		}
@@ -1997,31 +1997,31 @@  discard block
 block discarded – undo
1997 1997
     }
1998 1998
 
1999 1999
     // this is where translation happens for dynamic list views
2000
-    function loadListFieldDefs(&$subpanel_fields,&$child_focus)
2000
+    function loadListFieldDefs(&$subpanel_fields, &$child_focus)
2001 2001
     {
2002 2002
         $this->list_field_defs = $subpanel_fields;
2003 2003
 
2004
-        for($i=0;$i < count($this->list_field_defs);$i++)
2004
+        for ($i = 0; $i < count($this->list_field_defs); $i++)
2005 2005
         {
2006 2006
             $list_field = $this->list_field_defs[$i];
2007 2007
             $field_def = null;
2008 2008
             $key = '';
2009
-            if(!empty($list_field['vname']))
2009
+            if (!empty($list_field['vname']))
2010 2010
             {
2011 2011
                 $key = $list_field['vname'];
2012
-            } else if(isset($list_field['name']) &&  isset($child_focus->field_defs[$list_field['name']]))
2012
+            } else if (isset($list_field['name']) && isset($child_focus->field_defs[$list_field['name']]))
2013 2013
             {
2014 2014
                     $field_def = $child_focus->field_defs[$list_field['name']];
2015 2015
                     $key = $field_def['vname'];
2016 2016
             }
2017
-            if(!empty($key))
2017
+            if (!empty($key))
2018 2018
             {
2019
-                $list_field['label'] = translate($key,$child_focus->module_dir);
2020
-                $this->list_field_defs[$i]['label'] = preg_replace('/:$/','',$list_field['label']);
2019
+                $list_field['label'] = translate($key, $child_focus->module_dir);
2020
+                $this->list_field_defs[$i]['label'] = preg_replace('/:$/', '', $list_field['label']);
2021 2021
             }
2022 2022
             else
2023 2023
             {
2024
-                $this->list_field_defs[$i]['label'] ='&nbsp;';
2024
+                $this->list_field_defs[$i]['label'] = '&nbsp;';
2025 2025
             }
2026 2026
         }
2027 2027
     }
@@ -2036,7 +2036,7 @@  discard block
 block discarded – undo
2036 2036
      * All Rights Reserved.
2037 2037
      * Contributor(s): ______________________________________.
2038 2038
      */
2039
-     function setLocalSessionVariable($localVarName,$varName, $value) {
2039
+     function setLocalSessionVariable($localVarName, $varName, $value) {
2040 2040
         $_SESSION[$localVarName."_".$varName] = $value;
2041 2041
      }
2042 2042
 
@@ -2046,11 +2046,11 @@  discard block
 block discarded – undo
2046 2046
      * All Rights Reserved.
2047 2047
      * Contributor(s): ______________________________________.
2048 2048
      */
2049
- function getLocalSessionVariable($localVarName,$varName) {
2050
-    if(isset($_SESSION[$localVarName."_".$varName])) {
2049
+ function getLocalSessionVariable($localVarName, $varName) {
2050
+    if (isset($_SESSION[$localVarName."_".$varName])) {
2051 2051
         return $_SESSION[$localVarName."_".$varName];
2052 2052
     }
2053
-    else{
2053
+    else {
2054 2054
         return "";
2055 2055
     }
2056 2056
  }
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
  /* Set to true if you want Additional Details to appear in the listview
2059 2059
   */
2060 2060
  function setAdditionalDetails($value = true, $function = '') {
2061
-    if(!empty($function)) $this->additionalDetailsFunction = $function;
2061
+    if (!empty($function)) $this->additionalDetailsFunction = $function;
2062 2062
     $this->_additionalDetails = $value;
2063 2063
  }
2064 2064
 
Please login to merge, or discard this patch.
Braces   +173 added lines, -101 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.
@@ -135,9 +137,13 @@  discard block
 block discarded – undo
135 137
     }
136 138
 
137 139
     //when processing a multi-select popup.
138
-    if($this->process_for_popups && $this->multi_select_popup)  $this->shouldProcess =true;
140
+    if($this->process_for_popups && $this->multi_select_popup) {
141
+        $this->shouldProcess =true;
142
+    }
139 143
     //mass update turned off?
140
-    if(!$this->show_mass_update) $this->shouldProcess = false;
144
+    if(!$this->show_mass_update) {
145
+        $this->shouldProcess = false;
146
+    }
141 147
     if(is_subclass_of($seed, "SugarBean")) {
142 148
         if($seed->bean_implements('ACL')) {
143 149
             if(!ACLController::checkAccess($seed->module_dir,'list',true)) {
@@ -188,8 +194,9 @@  discard block
 block discarded – undo
188 194
 {
189 195
         $this->source_module = $source_module;
190 196
         $this->subpanel_module = $subpanel_def->name;
191
-        if(!isset($this->xTemplate))
192
-            $this->createXTemplate();
197
+        if(!isset($this->xTemplate)) {
198
+                    $this->createXTemplate();
199
+        }
193 200
 
194 201
         $html_var = $this->subpanel_module . "_CELL";
195 202
 
@@ -280,8 +287,9 @@  discard block
 block discarded – undo
280 287
     if ( empty($data) ) {
281 288
         $this->xTemplate->assign("ROW_COLOR", 'oddListRow');
282 289
         $thepanel=$subpanel_def;
283
-        if($subpanel_def->isCollection())
284
-            $thepanel=$subpanel_def->get_header_panel_def();
290
+        if($subpanel_def->isCollection()) {
291
+                    $thepanel=$subpanel_def->get_header_panel_def();
292
+        }
285 293
         $this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields()));
286 294
         $this->xTemplate->parse($xtemplateSection.".nodata");
287 295
     }
@@ -339,8 +347,7 @@  discard block
 block discarded – undo
339 347
         {
340 348
             $ROW_COLOR = 'oddListRow';
341 349
             $BG_COLOR =  $odd_bg;
342
-        }
343
-        else
350
+        } else
344 351
         {
345 352
             $ROW_COLOR = 'evenListRow';
346 353
             $BG_COLOR =  $even_bg;
@@ -353,8 +360,9 @@  discard block
 block discarded – undo
353 360
         $layout_manager->setAttribute('context','List');
354 361
         $layout_manager->setAttribute('image_path',$this->local_image_path);
355 362
         $layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']);
356
-        if(!empty($this->child_focus))
357
-            $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir);
363
+        if(!empty($this->child_focus)) {
364
+                    $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir);
365
+        }
358 366
 
359 367
         //AG$subpanel_data = $this->list_field_defs;
360 368
         //$bla = array_pop($subpanel_data);
@@ -389,7 +397,9 @@  discard block
 block discarded – undo
389 397
         $linked_field=$thepanel->get_data_source_name();
390 398
         $linked_field_set=$thepanel->get_data_source_name(true);
391 399
         static $count;
392
-        if(!isset($count))$count = 0;
400
+        if(!isset($count)) {
401
+            $count = 0;
402
+        }
393 403
 		/* BEGIN - SECURITY GROUPS */ 
394 404
 		/**
395 405
         $field_acl['DetailView'] = $aItem->ACLAccess('DetailView');
@@ -420,7 +430,7 @@  discard block
 block discarded – undo
420 430
                 $this->xTemplate->assign('CELL', $widget_contents);
421 431
                 $this->xTemplate->parse($xtemplateSection.".row.cell");
422 432
 
423
-            }else if($usage != 'query_only')
433
+            } else if($usage != 'query_only')
424 434
             {
425 435
                 $list_field['name']=$field_name;
426 436
 
@@ -435,8 +445,11 @@  discard block
 block discarded – undo
435 445
                     $list_field['owner_id'] = false;
436 446
                     $list_field['owner_module'] = false;
437 447
                 }
438
-                if(isset($list_field['alias'])) $list_field['name'] = $list_field['alias'];
439
-                else $list_field['name']=$field_name;
448
+                if(isset($list_field['alias'])) {
449
+                    $list_field['name'] = $list_field['alias'];
450
+                } else {
451
+                    $list_field['name']=$field_name;
452
+                }
440 453
                 $list_field['fields'] = $fields;
441 454
                 $list_field['module'] = $aItem->module_dir;
442 455
                 $list_field['start_link_wrapper'] = $this->start_link_wrapper;
@@ -485,7 +498,9 @@  discard block
 block discarded – undo
485 498
                  $count++;
486 499
                 $this->xTemplate->assign('CELL_COUNT', $count);
487 500
                 $this->xTemplate->assign('CLASS', "");
488
-                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
501
+                if ( empty($widget_contents) ) {
502
+                    $widget_contents = '&nbsp;';
503
+                }
489 504
                 $this->xTemplate->assign('CELL', $widget_contents);
490 505
                 $this->xTemplate->parse($xtemplateSection.".row.cell");
491 506
                 } else {
@@ -495,7 +510,9 @@  discard block
 block discarded – undo
495 510
 		                $widget_contents = $layout_manager->widgetDisplay($list_field);
496 511
 		                $this->xTemplate->assign('CELL_COUNT', $count);
497 512
 		                $this->xTemplate->assign('CLASS', "");
498
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
513
+		                if ( empty($widget_contents) ) {
514
+		                    $widget_contents = '&nbsp;';
515
+		                }
499 516
 		                $this->xTemplate->assign('CELL', $widget_contents);
500 517
 		                $this->xTemplate->parse($xtemplateSection.".row.cell");
501 518
                 	} elseif (preg_match("/button/i", $list_field['name'])) {
@@ -503,8 +520,7 @@  discard block
 block discarded – undo
503 520
                         {
504 521
                             $button_contents[] = $_content;
505 522
                             unset($_content);
506
-                        }
507
-                        else
523
+                        } else
508 524
                         {
509 525
                             $button_contents[] = '';
510 526
                         }
@@ -513,7 +529,9 @@  discard block
 block discarded – undo
513 529
                			$this->xTemplate->assign('CLASS', "");
514 530
                			$widget_contents = $layout_manager->widgetDisplay($list_field);
515 531
 		                $this->xTemplate->assign('CELL_COUNT', $count);
516
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
532
+		                if ( empty($widget_contents) ) {
533
+		                    $widget_contents = '&nbsp;';
534
+		                }
517 535
 		                $this->xTemplate->assign('CELL', $widget_contents);
518 536
 		                $this->xTemplate->parse($xtemplateSection.".row.cell");
519 537
                 	}
@@ -541,8 +559,7 @@  discard block
 block discarded – undo
541 559
                     'class' => 'clickMenu subpanel records fancymenu button',
542 560
                     'flat' => false //assign flat value as false to display dropdown menu at any other preferences.
543 561
                 ), $this->xTemplate);
544
-            }
545
-            else
562
+            } else
546 563
             {
547 564
                 $action_button = '';
548 565
             }
@@ -629,11 +646,13 @@  discard block
 block discarded – undo
629 646
 */
630 647
  function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) {
631 648
     $this->setXTemplatePath($XTemplatePath);
632
-    if(isset($modString))
633
-        $this->setModStrings($modString);
634
-    if(isset($imagePath))
635
-        $this->setImagePath($imagePath);
636
-}
649
+    if(isset($modString)) {
650
+            $this->setModStrings($modString);
651
+    }
652
+    if(isset($imagePath)) {
653
+            $this->setImagePath($imagePath);
654
+    }
655
+    }
637 656
 
638 657
 
639 658
 function getOrderBy($varName, $defaultOrderBy='', $force_sortorder='') {
@@ -714,7 +733,7 @@  discard block
 block discarded – undo
714 733
             }
715 734
             //Just clear from url...
716 735
             $this->appendToBaseUrl[$orderByColumn] = false;
717
-    }else {
736
+    } else {
718 737
         $this->query_orderby = "";
719 738
     }
720 739
     $this->sortby = $sortBy;
@@ -759,8 +778,10 @@  discard block
 block discarded – undo
759 778
 */
760 779
  function setTheme($theme) {
761 780
     $this->local_theme = $theme;
762
-    if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
763
-}
781
+    if(isset($this->xTemplate)) {
782
+        $this->xTemplate->assign("THEME", $this->local_theme);
783
+    }
784
+    }
764 785
 
765 786
 /**sets the AppStrings used only use if it is different from the global
766 787
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -770,8 +791,10 @@  discard block
 block discarded – undo
770 791
  function setAppStrings($app_strings) {
771 792
     unset($this->local_app_strings);
772 793
     $this->local_app_strings = $app_strings;
773
-    if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
774
-}
794
+    if(isset($this->xTemplate)) {
795
+        $this->xTemplate->assign("APP", $this->local_app_strings);
796
+    }
797
+    }
775 798
 
776 799
 /**sets the ModStrings used
777 800
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -781,8 +804,10 @@  discard block
 block discarded – undo
781 804
  function setModStrings($mod_strings) {
782 805
     unset($this->local_module_strings);
783 806
     $this->local_mod_strings = $mod_strings;
784
-    if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
785
-}
807
+    if(isset($this->xTemplate)) {
808
+        $this->xTemplate->assign("MOD", $this->local_mod_strings);
809
+    }
810
+    }
786 811
 
787 812
 /**sets the ImagePath used
788 813
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -794,8 +819,10 @@  discard block
 block discarded – undo
794 819
     if(empty($this->local_image_path)) {
795 820
         $this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath();
796 821
     }
797
-    if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
798
-}
822
+    if(isset($this->xTemplate)) {
823
+        $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
824
+    }
825
+    }
799 826
 
800 827
 /**sets the currentModule only use if this is different from the global
801 828
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -805,8 +832,10 @@  discard block
 block discarded – undo
805 832
  function setCurrentModule($currentModule) {
806 833
     unset($this->local_current_module);
807 834
     $this->local_current_module = $currentModule;
808
-    if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
809
-}
835
+    if(isset($this->xTemplate)) {
836
+        $this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
837
+    }
838
+    }
810 839
 
811 840
 /**INTERNAL FUNCTION creates an XTemplate DO NOT CALL THIS THIS IS AN INTERNAL FUNCTION
812 841
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -819,7 +848,9 @@  discard block
 block discarded – undo
819 848
 
820 849
             $this->xTemplate = new XTemplate($this->xTemplatePath);
821 850
             $this->xTemplate->assign("APP", $this->local_app_strings);
822
-            if(isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings);
851
+            if(isset($this->local_mod_strings)) {
852
+                $this->xTemplate->assign("MOD", $this->local_mod_strings);
853
+            }
823 854
             $this->xTemplate->assign("THEME", $this->local_theme);
824 855
             $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
825 856
             $this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
@@ -896,7 +927,9 @@  discard block
 block discarded – undo
896 927
 }
897 928
 
898 929
 function setUserVariable($localVarName,$varName, $value) {
899
-        if($this->is_dynamic ||  $localVarName == 'CELL')return;
930
+        if($this->is_dynamic ||  $localVarName == 'CELL') {
931
+            return;
932
+        }
900 933
         global $current_user;
901 934
         $current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value);
902 935
 }
@@ -920,7 +953,9 @@  discard block
 block discarded – undo
920 953
 
921 954
 function getUserVariable($localVarName, $varName) {
922 955
     global $current_user;
923
-    if($this->is_dynamic ||  $localVarName == 'CELL')return;
956
+    if($this->is_dynamic ||  $localVarName == 'CELL') {
957
+        return;
958
+    }
924 959
     if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
925 960
 
926 961
             $this->setUserVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
@@ -999,11 +1034,21 @@  discard block
 block discarded – undo
999 1034
         //$filter = array('id', 'full_name');
1000 1035
         $filter=array();
1001 1036
         $ret_array = $seed->create_new_list_query($this->query_orderby, $this->query_where, $filter, $params, 0, '', true, $seed, true);
1002
-        if(!is_array($params)) $params = array();
1003
-        if(!isset($params['custom_select'])) $params['custom_select'] = '';
1004
-        if(!isset($params['custom_from'])) $params['custom_from'] = '';
1005
-        if(!isset($params['custom_where'])) $params['custom_where'] = '';
1006
-        if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
1037
+        if(!is_array($params)) {
1038
+            $params = array();
1039
+        }
1040
+        if(!isset($params['custom_select'])) {
1041
+            $params['custom_select'] = '';
1042
+        }
1043
+        if(!isset($params['custom_from'])) {
1044
+            $params['custom_from'] = '';
1045
+        }
1046
+        if(!isset($params['custom_where'])) {
1047
+            $params['custom_where'] = '';
1048
+        }
1049
+        if(!isset($params['custom_order_by'])) {
1050
+            $params['custom_order_by'] = '';
1051
+        }
1007 1052
         $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
1008 1053
         SugarVCR::store($seed->module_dir,  $main_query);
1009 1054
         //ADDING VCR CONTROL
@@ -1064,8 +1109,7 @@  discard block
 block discarded – undo
1064 1109
             {
1065 1110
                 $sort_order['session'] = $sort_order['session'] == 'asc' ? 'desc' : 'asc';
1066 1111
             }
1067
-        }
1068
-        else
1112
+        } else
1069 1113
         {
1070 1114
             $sort_order['session'] = null;
1071 1115
         }
@@ -1097,7 +1141,7 @@  discard block
 block discarded – undo
1097 1141
         if(!empty($this->response)){
1098 1142
             $response =& $this->response;
1099 1143
             echo 'cached';
1100
-        }else{
1144
+        } else{
1101 1145
             $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1102 1146
             $this->response =& $response;
1103 1147
         }
@@ -1105,7 +1149,9 @@  discard block
 block discarded – undo
1105 1149
         $row_count = $response['row_count'];
1106 1150
         $next_offset = $response['next_offset'];
1107 1151
         $previous_offset = $response['previous_offset'];
1108
-        if(!empty($response['current_offset']))$current_offset = $response['current_offset'];
1152
+        if(!empty($response['current_offset'])) {
1153
+            $current_offset = $response['current_offset'];
1154
+        }
1109 1155
         global $list_view_row_count;
1110 1156
         $list_view_row_count = $row_count;
1111 1157
         $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean,$subpanel_def);
@@ -1116,7 +1162,9 @@  discard block
 block discarded – undo
1116 1162
     function getBaseURL($html_varName) {
1117 1163
         static $cache = array();
1118 1164
 
1119
-        if(!empty($cache[$html_varName]))return $cache[$html_varName];
1165
+        if(!empty($cache[$html_varName])) {
1166
+            return $cache[$html_varName];
1167
+        }
1120 1168
         $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount','current_query_by_page');
1121 1169
         if(!empty($this->base_URL)) {
1122 1170
             return $this->base_URL;
@@ -1136,10 +1184,11 @@  discard block
 block discarded – undo
1136 1184
                 {
1137 1185
                     if(is_array($value)) {
1138 1186
                         foreach($value as $valuename=>$valuevalue) {
1139
-                            if(substr_count($baseurl, '?') > 0)
1140
-                                $baseurl	.= "&{$name}[]=".$valuevalue;
1141
-                            else
1142
-                                $baseurl	.= "?{$name}[]=".$valuevalue;
1187
+                            if(substr_count($baseurl, '?') > 0) {
1188
+                                                            $baseurl	.= "&{$name}[]=".$valuevalue;
1189
+                            } else {
1190
+                                                            $baseurl	.= "?{$name}[]=".$valuevalue;
1191
+                            }
1143 1192
                         }
1144 1193
                     } else {
1145 1194
                         $value = urlencode($value);
@@ -1158,9 +1207,15 @@  discard block
 block discarded – undo
1158 1207
                 if(substr_count($baseurl, '?') == 0) {
1159 1208
                     $baseurl .= '?';
1160 1209
                 }
1161
-                if(isset($_REQUEST['action'])) $baseurl.= '&action='.$_REQUEST['action'];
1162
-                if(isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record'];
1163
-                if(isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module'];
1210
+                if(isset($_REQUEST['action'])) {
1211
+                    $baseurl.= '&action='.$_REQUEST['action'];
1212
+                }
1213
+                if(isset($_REQUEST['record'])) {
1214
+                    $baseurl .= '&record='.$_REQUEST['record'];
1215
+                }
1216
+                if(isset($_REQUEST['module'])) {
1217
+                    $baseurl .= '&module='.$_REQUEST['module'];
1218
+                }
1164 1219
             }
1165 1220
 
1166 1221
             $baseurl .= "&".ListView::getSessionVariableName($html_varName,"offset")."=";
@@ -1187,11 +1242,13 @@  discard block
 block discarded – undo
1187 1242
 
1188 1243
         $start_record = $current_offset + 1;
1189 1244
 
1190
-        if(!is_numeric($col_count))
1191
-            $col_count = 20;
1245
+        if(!is_numeric($col_count)) {
1246
+                    $col_count = 20;
1247
+        }
1192 1248
 
1193
-        if($row_count == 0)
1194
-            $start_record = 0;
1249
+        if($row_count == 0) {
1250
+                    $start_record = 0;
1251
+        }
1195 1252
 
1196 1253
         $end_record = $start_record + $this->records_per_page;
1197 1254
         // back up the the last page.
@@ -1199,10 +1256,11 @@  discard block
 block discarded – undo
1199 1256
             $end_record = $row_count+1;
1200 1257
         }
1201 1258
         // Determine the start location of the last page
1202
-        if($row_count == 0)
1203
-            $number_pages = 0;
1204
-        else
1205
-            $number_pages = floor(($row_count - 1) / $this->records_per_page);
1259
+        if($row_count == 0) {
1260
+                    $number_pages = 0;
1261
+        } else {
1262
+                    $number_pages = floor(($row_count - 1) / $this->records_per_page);
1263
+        }
1206 1264
 
1207 1265
         $last_offset = $number_pages * $this->records_per_page;
1208 1266
 
@@ -1262,7 +1320,7 @@  discard block
 block discarded – undo
1262 1320
                     $onClick = '';
1263 1321
                     if(0 != preg_match('/javascript.*/', $start_URL)){
1264 1322
                         $onClick = "\"$start_URL;\"";
1265
-                    }else{
1323
+                    } else{
1266 1324
                         $onClick ="'location.href=\"$start_URL\";'";
1267 1325
                     }
1268 1326
                     $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
@@ -1270,7 +1328,7 @@  discard block
 block discarded – undo
1270 1328
                     $onClick = '';
1271 1329
                     if(0 != preg_match('/javascript.*/', $previous_URL)){
1272 1330
                         $onClick = "\"$previous_URL;\"";
1273
-                    }else{
1331
+                    } else{
1274 1332
                         $onClick = "'location.href=\"$previous_URL\";'";
1275 1333
                     }
1276 1334
                     $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
@@ -1294,7 +1352,7 @@  discard block
 block discarded – undo
1294 1352
                     $onClick = '';
1295 1353
                     if(0 != preg_match('/javascript.*/', $next_URL)){
1296 1354
                         $onClick = "\"$next_URL;\"";
1297
-                    }else{
1355
+                    } else{
1298 1356
                         $onClick ="'location.href=\"$next_URL\";'";
1299 1357
                     }
1300 1358
                     $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
@@ -1302,7 +1360,7 @@  discard block
 block discarded – undo
1302 1360
                     $onClick = '';
1303 1361
                     if(0 != preg_match('/javascript.*/', $end_URL)){
1304 1362
                         $onClick = "\"$end_URL;\"";
1305
-                    }else{
1363
+                    } else{
1306 1364
                         $onClick = "'location.href=\"$end_URL\";'";
1307 1365
                     }
1308 1366
                     $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
@@ -1451,18 +1509,17 @@  discard block
 block discarded – undo
1451 1509
                     //attempt to get the query to recreate this subpanel
1452 1510
                     if(!empty($this->response)){
1453 1511
                         $response =& $this->response;
1454
-                    }else{
1512
+                    } else{
1455 1513
                         $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1456 1514
                         $this->response = $response;
1457 1515
                     }
1458 1516
                     //if query is present, then pass it in as parameter
1459 1517
                     if (isset($response['query']) && !empty($response['query'])){
1460 1518
                         $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']);
1461
-                    }else{
1519
+                    } else{
1462 1520
                         $html_text .= $subpanelTiles->get_buttons($subpanel_def);
1463 1521
                     }
1464
-                }
1465
-                else {
1522
+                } else {
1466 1523
                     $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"  nowrap>$select_link&nbsp;$export_link&nbsp;$delete_link&nbsp;$selected_objects_span";
1467 1524
                 }
1468 1525
                 $html_text .= "</td>\n<td nowrap align=\"right\">".$start_link."&nbsp;&nbsp;".$previous_link."&nbsp;&nbsp;<span class='pageNumbers'>(".$start_record." - ".$end_record." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")</span>&nbsp;&nbsp;".$next_link."&nbsp;&nbsp;".$end_link."</td></tr></table>\n";
@@ -1490,9 +1547,15 @@  discard block
 block discarded – undo
1490 1547
             }
1491 1548
             if($_SERVER['REQUEST_METHOD'] == 'POST') {
1492 1549
                 $this->base_URL .= '?';
1493
-                if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
1494
-                if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
1495
-                if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
1550
+                if(isset($_REQUEST['action'])) {
1551
+                    $this->base_URL .= '&action='.$_REQUEST['action'];
1552
+                }
1553
+                if(isset($_REQUEST['record'])) {
1554
+                    $this->base_URL .= '&record='.$_REQUEST['record'];
1555
+                }
1556
+                if(isset($_REQUEST['module'])) {
1557
+                    $this->base_URL .= '&module='.$_REQUEST['module'];
1558
+                }
1496 1559
             }
1497 1560
             $this->base_URL .= "&".$this->getSessionVariableName($html_varName,"offset")."=";
1498 1561
         }
@@ -1623,8 +1686,7 @@  discard block
 block discarded – undo
1623 1686
             {
1624 1687
                 $ROW_COLOR = 'oddListRow';
1625 1688
                 $BG_COLOR =  $odd_bg;
1626
-            }
1627
-            else
1689
+            } else
1628 1690
             {
1629 1691
                 $ROW_COLOR = 'evenListRow';
1630 1692
                 $BG_COLOR =  $even_bg;
@@ -1640,8 +1702,7 @@  discard block
 block discarded – undo
1640 1702
                 $this->xTemplate->assign('VALUE', $aItem);
1641 1703
                 $this->xTemplate->assign('INDEX', $count);
1642 1704
 
1643
-            }
1644
-            else
1705
+            } else
1645 1706
             {
1646 1707
     //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
1647 1708
     // Bug #2786
@@ -1657,7 +1718,9 @@  discard block
 block discarded – undo
1657 1718
                     $results = $ad_function($fields);
1658 1719
                     $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
1659 1720
 
1660
-                    if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
1721
+                    if(trim($results['string']) == '') {
1722
+                        $results['string'] = $app_strings['LBL_NONE'];
1723
+                    }
1661 1724
                     $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']].'</a>';
1662 1725
                 }
1663 1726
 
@@ -1781,12 +1844,21 @@  discard block
 block discarded – undo
1781 1844
 	                $cell_width = empty($widget_args['width']) ? '' : $widget_args['width'];
1782 1845
 	                $this->xTemplate->assign('HEADER_CELL', $widget_contents);
1783 1846
 	                static $count;
1784
-	            if(!isset($count))$count = 0; else $count++;
1785
-                    if($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"';
1786
-                    else {
1847
+	            if(!isset($count)) {
1848
+	                $count = 0;
1849
+	            } else {
1850
+	                $count++;
1851
+	            }
1852
+                    if($col_count == 0 || $column_name == 'name') {
1853
+                        $footable = 'data-toggle="true"';
1854
+                    } else {
1787 1855
                         $footable = 'data-hide="phone"';
1788
-                        if ($col_count > 2) $footable = 'data-hide="phone,phonelandscape"';
1789
-                        if ($col_count > 4) $footable = 'data-hide="phone,phonelandscape,tablet"';
1856
+                        if ($col_count > 2) {
1857
+                            $footable = 'data-hide="phone,phonelandscape"';
1858
+                        }
1859
+                        if ($col_count > 4) {
1860
+                            $footable = 'data-hide="phone,phonelandscape,tablet"';
1861
+                        }
1790 1862
                     }
1791 1863
                     $this->xTemplate->assign('FOOTABLE', $footable);
1792 1864
 	                $this->xTemplate->assign('CELL_COUNT', $count);
@@ -1918,7 +1990,7 @@  discard block
 block discarded – undo
1918 1990
         $sortStr = translate('LBL_ALT_SORT');
1919 1991
         if($upDown == '_down'){
1920 1992
             $sortStr = translate('LBL_ALT_SORT_DESC');
1921
-        }elseif($upDown == '_up'){
1993
+        } elseif($upDown == '_up'){
1922 1994
             $sortStr = translate('LBL_ALT_SORT_ASC');
1923 1995
         }
1924 1996
         return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>";
@@ -1932,8 +2004,9 @@  discard block
 block discarded – undo
1932 2004
 
1933 2005
         // Check the cache
1934 2006
         $result = sugar_cache_retrieve($cache_key);
1935
-        if(!empty($result))
1936
-        return $result;
2007
+        if(!empty($result)) {
2008
+                return $result;
2009
+        }
1937 2010
 
1938 2011
         // No cache hit.  Calculate the value and return.
1939 2012
         $result = getimagesize($image);
@@ -1949,8 +2022,9 @@  discard block
 block discarded – undo
1949 2022
 
1950 2023
         // Check the cache
1951 2024
         $result = sugar_cache_retrieve($cache_key);
1952
-        if(!empty($result))
1953
-        return $result;
2025
+        if(!empty($result)) {
2026
+                return $result;
2027
+        }
1954 2028
 
1955 2029
         // No cache hit.  Calculate the value and return.
1956 2030
         $result = getimagesize($image);
@@ -1983,12 +2057,10 @@  discard block
 block discarded – undo
1983 2057
 		if($orderBy == 'amount')
1984 2058
 		{
1985 2059
 			$this->xTemplateAssign('amount_arrow', $imgArrow);
1986
-		}
1987
-		else if($orderBy == 'amount_usdollar')
2060
+		} else if($orderBy == 'amount_usdollar')
1988 2061
 		{
1989 2062
 			$this->xTemplateAssign('amount_usdollar_arrow', $imgArrow);
1990
-		}
1991
-		else
2063
+		} else
1992 2064
 		{
1993 2065
 			$this->xTemplateAssign($orderBy.'_arrow', $imgArrow);
1994 2066
 		}
@@ -2018,8 +2090,7 @@  discard block
 block discarded – undo
2018 2090
             {
2019 2091
                 $list_field['label'] = translate($key,$child_focus->module_dir);
2020 2092
                 $this->list_field_defs[$i]['label'] = preg_replace('/:$/','',$list_field['label']);
2021
-            }
2022
-            else
2093
+            } else
2023 2094
             {
2024 2095
                 $this->list_field_defs[$i]['label'] ='&nbsp;';
2025 2096
             }
@@ -2049,8 +2120,7 @@  discard block
 block discarded – undo
2049 2120
  function getLocalSessionVariable($localVarName,$varName) {
2050 2121
     if(isset($_SESSION[$localVarName."_".$varName])) {
2051 2122
         return $_SESSION[$localVarName."_".$varName];
2052
-    }
2053
-    else{
2123
+    } else{
2054 2124
         return "";
2055 2125
     }
2056 2126
  }
@@ -2058,7 +2128,9 @@  discard block
 block discarded – undo
2058 2128
  /* Set to true if you want Additional Details to appear in the listview
2059 2129
   */
2060 2130
  function setAdditionalDetails($value = true, $function = '') {
2061
-    if(!empty($function)) $this->additionalDetailsFunction = $function;
2131
+    if(!empty($function)) {
2132
+        $this->additionalDetailsFunction = $function;
2133
+    }
2062 2134
     $this->_additionalDetails = $value;
2063 2135
  }
2064 2136
 
Please login to merge, or discard this patch.
Doc Comments   +34 added lines, -7 removed lines patch added patch discarded remove patch
@@ -105,6 +105,9 @@  discard block
 block discarded – undo
105 105
 }
106 106
 
107 107
 
108
+/**
109
+ * @param string $xTemplateSection
110
+ */
108 111
 function processListView($seed, $xTemplateSection, $html_varName)
109 112
 {
110 113
     global $sugar_config;
@@ -232,8 +235,8 @@  discard block
 block discarded – undo
232 235
 /**
233 236
  * @return void
234 237
  * @param unknown $data
235
- * @param unknown $xTemplateSection
236
- * @param unknown $html_varName
238
+ * @param string $xtemplateSection
239
+ * @param string $html_varName
237 240
  * @desc INTERNAL FUNCTION handles the rows
238 241
  */
239 242
  function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def)
@@ -610,6 +613,9 @@  discard block
 block discarded – undo
610 613
  * All Rights Reserved.
611 614
  * Contributor(s): ______________________________________.
612 615
 */
616
+ /**
617
+  * @param string $value
618
+  */
613 619
  function setHeaderText($value) {
614 620
     $this->header_text = $value;
615 621
 }
@@ -728,6 +734,9 @@  discard block
 block discarded – undo
728 734
  * All Rights Reserved.
729 735
  * Contributor(s): ______________________________________.
730 736
 */
737
+ /**
738
+  * @param string $where
739
+  */
731 740
  function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) {
732 741
     $this->query_where = $where;
733 742
     if($this->getSessionVariable("query", "where") != $where) {
@@ -834,6 +843,9 @@  discard block
 block discarded – undo
834 843
  * All Rights Reserved.
835 844
  * Contributor(s): ______________________________________.
836 845
 */
846
+ /**
847
+  * @param XTemplate $newXTemplate
848
+  */
837 849
  function setXTemplate($newXTemplate) {
838 850
     $this->xTemplate = $newXTemplate;
839 851
 }
@@ -852,6 +864,9 @@  discard block
 block discarded – undo
852 864
  * All Rights Reserved.
853 865
  * Contributor(s): ______________________________________.
854 866
 */
867
+ /**
868
+  * @param string $name
869
+  */
855 870
  function xTemplateAssign($name, $value) {
856 871
 
857 872
         if(!isset($this->xTemplate)) {
@@ -906,6 +921,9 @@  discard block
 block discarded – undo
906 921
  * All Rights Reserved.
907 922
  * Contributor(s): ______________________________________.
908 923
 */
924
+ /**
925
+  * @param string $varName
926
+  */
909 927
  function getSessionVariable($localVarName,$varName) {
910 928
     //Set any variables pass in through request first
911 929
     if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
@@ -961,7 +979,7 @@  discard block
 block discarded – undo
961 979
 
962 980
     /**
963 981
 
964
-    * @return void
982
+    * @return string
965 983
     * @param unknown $localVarName
966 984
     * @param unknown $varName
967 985
     * @desc INTERNAL FUNCTION returns the session/query variable name
@@ -977,7 +995,7 @@  discard block
 block discarded – undo
977 995
 
978 996
     * @return void
979 997
     * @param unknown $seed
980
-    * @param unknown $xTemplateSection
998
+    * @param unknown $xtemplateSection
981 999
     * @param unknown $html_varName
982 1000
     * @desc INTERNAL FUNCTION Handles List Views using seeds that extend SugarBean
983 1001
         $XTemplateSection is the section in the XTemplate file that should be parsed usually main
@@ -1169,8 +1187,7 @@  discard block
 block discarded – undo
1169 1187
     }
1170 1188
     /**
1171 1189
     * @return void
1172
-    * @param unknown $data
1173
-    * @param unknown $xTemplateSection
1190
+    * @param unknown $xtemplateSection
1174 1191
     * @param unknown $html_varName
1175 1192
     * @desc INTERNAL FUNCTION process the List Navigation
1176 1193
     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -1550,7 +1567,7 @@  discard block
 block discarded – undo
1550 1567
     /**
1551 1568
     * @return void
1552 1569
     * @param unknown $data
1553
-    * @param unknown $xTemplateSection
1570
+    * @param unknown $xtemplateSection
1554 1571
     * @param unknown $html_varName
1555 1572
     * @desc INTERNAL FUNCTION handles the rows
1556 1573
     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -2036,6 +2053,10 @@  discard block
 block discarded – undo
2036 2053
      * All Rights Reserved.
2037 2054
      * Contributor(s): ______________________________________.
2038 2055
      */
2056
+
2057
+     /**
2058
+      * @param string $varName
2059
+      */
2039 2060
      function setLocalSessionVariable($localVarName,$varName, $value) {
2040 2061
         $_SESSION[$localVarName."_".$varName] = $value;
2041 2062
      }
@@ -2046,6 +2067,12 @@  discard block
 block discarded – undo
2046 2067
      * All Rights Reserved.
2047 2068
      * Contributor(s): ______________________________________.
2048 2069
      */
2070
+
2071
+ /**
2072
+  * @param string $varName
2073
+  *
2074
+  * @return string
2075
+  */
2049 2076
  function getLocalSessionVariable($localVarName,$varName) {
2050 2077
     if(isset($_SESSION[$localVarName."_".$varName])) {
2051 2078
         return $_SESSION[$localVarName."_".$varName];
Please login to merge, or discard this patch.
Indentation   +194 added lines, -196 removed lines patch added patch discarded remove patch
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
  * @param unknown $html_varName
237 237
  * @desc INTERNAL FUNCTION handles the rows
238 238
  */
239
- function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def)
240
- {
239
+    function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def)
240
+    {
241 241
     global $subpanel_item_count;
242 242
     global $odd_bg;
243 243
     global $even_bg;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             $BG_COLOR =  $even_bg;
347 347
         }
348 348
         $oddRow = !$oddRow;
349
-		$button_contents = array();
349
+        $button_contents = array();
350 350
         $this->xTemplate->assign("ROW_COLOR", $ROW_COLOR);
351 351
         $this->xTemplate->assign("BG_COLOR", $BG_COLOR);
352 352
         $layout_manager = $this->getLayoutManager();
@@ -366,43 +366,43 @@  discard block
 block discarded – undo
366 366
             $thepanel=$subpanel_def;
367 367
         }
368 368
 
369
-		/* BEGIN - SECURITY GROUPS */
369
+        /* BEGIN - SECURITY GROUPS */
370 370
 
371
-		//This check is costly doing it field by field in the below foreach
372
-		//instead pull up here and do once per record....
373
-		$aclaccess_is_owner = false;
374
-		$aclaccess_in_group = false;
371
+        //This check is costly doing it field by field in the below foreach
372
+        //instead pull up here and do once per record....
373
+        $aclaccess_is_owner = false;
374
+        $aclaccess_in_group = false;
375 375
 
376
-		global $current_user;
377
-		if(is_admin($current_user)) {
378
-			$aclaccess_is_owner = true;
379
-		} else {
380
-			$aclaccess_is_owner = $aItem->isOwner($current_user->id);
381
-		}
376
+        global $current_user;
377
+        if(is_admin($current_user)) {
378
+            $aclaccess_is_owner = true;
379
+        } else {
380
+            $aclaccess_is_owner = $aItem->isOwner($current_user->id);
381
+        }
382 382
 
383
-		require_once("modules/SecurityGroups/SecurityGroup.php");
384
-		$aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir,$aItem->id);
383
+        require_once("modules/SecurityGroups/SecurityGroup.php");
384
+        $aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir,$aItem->id);
385 385
 
386
-    	/* END - SECURITY GROUPS */
386
+        /* END - SECURITY GROUPS */
387 387
 
388 388
         //get data source name
389 389
         $linked_field=$thepanel->get_data_source_name();
390 390
         $linked_field_set=$thepanel->get_data_source_name(true);
391 391
         static $count;
392 392
         if(!isset($count))$count = 0;
393
-		/* BEGIN - SECURITY GROUPS */
394
-		/**
393
+        /* BEGIN - SECURITY GROUPS */
394
+        /**
395 395
         $field_acl['DetailView'] = $aItem->ACLAccess('DetailView');
396 396
         $field_acl['ListView'] = $aItem->ACLAccess('ListView');
397 397
         $field_acl['EditView'] = $aItem->ACLAccess('EditView');
398 398
         $field_acl['Delete'] = $aItem->ACLAccess('Delete');
399
-		*/
400
-		//pass is_owner, in_group...vars defined above
399
+         */
400
+        //pass is_owner, in_group...vars defined above
401 401
         $field_acl['DetailView'] = $aItem->ACLAccess('DetailView',$aclaccess_is_owner,$aclaccess_in_group);
402 402
         $field_acl['ListView'] = $aItem->ACLAccess('ListView',$aclaccess_is_owner,$aclaccess_in_group);
403 403
         $field_acl['EditView'] = $aItem->ACLAccess('EditView',$aclaccess_is_owner,$aclaccess_in_group);
404 404
         $field_acl['Delete'] = $aItem->ACLAccess('Delete',$aclaccess_is_owner,$aclaccess_in_group);
405
-		/* END - SECURITY GROUPS */
405
+        /* END - SECURITY GROUPS */
406 406
         foreach($thepanel->get_list_fields() as $field_name=>$list_field)
407 407
         {
408 408
             //add linked field attribute to the array.
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                         // So we'll populate the field data with the pre-rendered display for the field
470 470
                         $list_field['fields'][$field_name] = $widget_contents;
471 471
                         if('full_name' == $field_name){//bug #32465
472
-                           $list_field['fields'][strtoupper($field_name)] = $widget_contents;
472
+                            $list_field['fields'][strtoupper($field_name)] = $widget_contents;
473 473
                         }
474 474
 
475 475
                         //vardef source is non db, assign the field name to varname for processing of column.
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                         $widget_contents = $layout_manager->widgetDisplay($list_field);
483 483
                     }
484 484
 
485
-                 $count++;
485
+                    $count++;
486 486
                 $this->xTemplate->assign('CELL_COUNT', $count);
487 487
                 $this->xTemplate->assign('CLASS', "");
488 488
                 if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
@@ -490,15 +490,15 @@  discard block
 block discarded – undo
490 490
                 $this->xTemplate->parse($xtemplateSection.".row.cell");
491 491
                 } else {
492 492
                     // This handles the edit and remove buttons and icon widget
493
-                	if( isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") {
494
-		                $count++;
495
-		                $widget_contents = $layout_manager->widgetDisplay($list_field);
496
-		                $this->xTemplate->assign('CELL_COUNT', $count);
497
-		                $this->xTemplate->assign('CLASS', "");
498
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
499
-		                $this->xTemplate->assign('CELL', $widget_contents);
500
-		                $this->xTemplate->parse($xtemplateSection.".row.cell");
501
-                	} elseif (preg_match("/button/i", $list_field['name'])) {
493
+                    if( isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") {
494
+                        $count++;
495
+                        $widget_contents = $layout_manager->widgetDisplay($list_field);
496
+                        $this->xTemplate->assign('CELL_COUNT', $count);
497
+                        $this->xTemplate->assign('CLASS', "");
498
+                        if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
499
+                        $this->xTemplate->assign('CELL', $widget_contents);
500
+                        $this->xTemplate->parse($xtemplateSection.".row.cell");
501
+                    } elseif (preg_match("/button/i", $list_field['name'])) {
502 502
                         if ((($list_field['name'] === 'edit_button' && $field_acl['EditView']) || ($list_field['name'] === 'close_button' && $field_acl['EditView']) || ($list_field['name'] === 'remove_button' && $field_acl['Delete'])) && '' != ($_content = $layout_manager->widgetDisplay($list_field)) )
503 503
                         {
504 504
                             $button_contents[] = $_content;
@@ -508,15 +508,15 @@  discard block
 block discarded – undo
508 508
                         {
509 509
                             $button_contents[] = '';
510 510
                         }
511
-                	} else {
512
-               			$count++;
513
-               			$this->xTemplate->assign('CLASS', "");
514
-               			$widget_contents = $layout_manager->widgetDisplay($list_field);
515
-		                $this->xTemplate->assign('CELL_COUNT', $count);
516
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
517
-		                $this->xTemplate->assign('CELL', $widget_contents);
518
-		                $this->xTemplate->parse($xtemplateSection.".row.cell");
519
-                	}
511
+                    } else {
512
+                            $count++;
513
+                            $this->xTemplate->assign('CLASS', "");
514
+                            $widget_contents = $layout_manager->widgetDisplay($list_field);
515
+                        $this->xTemplate->assign('CELL_COUNT', $count);
516
+                        if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
517
+                        $this->xTemplate->assign('CELL', $widget_contents);
518
+                        $this->xTemplate->parse($xtemplateSection.".row.cell");
519
+                    }
520 520
                 }
521 521
 
522 522
             }
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
  * All Rights Reserved.
580 580
  * Contributor(s): ______________________________________.
581 581
 */
582
- function __construct() {
582
+    function __construct() {
583 583
 
584 584
 
585 585
     if(!$this->initialized) {
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
  * All Rights Reserved.
599 599
  * Contributor(s): ______________________________________.
600 600
 */
601
- function setRecordsPerPage($count) {
601
+    function setRecordsPerPage($count) {
602 602
     $this->records_per_page = $count;
603 603
 }
604 604
 /**sets the header title */
605
- function setHeaderTitle($value) {
605
+    function setHeaderTitle($value) {
606 606
     $this->header_title = $value;
607 607
 }
608 608
 /**sets the header text this is text that's appended to the header table and is usually used for the creation of buttons
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
  * All Rights Reserved.
611 611
  * Contributor(s): ______________________________________.
612 612
 */
613
- function setHeaderText($value) {
613
+    function setHeaderText($value) {
614 614
     $this->header_text = $value;
615 615
 }
616 616
 /**sets the path for the XTemplate HTML file to be used this is only needed to be set if you are allowing ListView to create the XTemplate
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
  * All Rights Reserved.
619 619
  * Contributor(s): ______________________________________.
620 620
 */
621
- function setXTemplatePath($value) {
621
+    function setXTemplatePath($value) {
622 622
     $this->xTemplatePath= $value;
623 623
 }
624 624
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
  * All Rights Reserved.
628 628
  * Contributor(s): ______________________________________.
629 629
 */
630
- function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) {
630
+    function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) {
631 631
     $this->setXTemplatePath($XTemplatePath);
632 632
     if(isset($modString))
633 633
         $this->setModStrings($modString);
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
  * All Rights Reserved.
729 729
  * Contributor(s): ______________________________________.
730 730
 */
731
- function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) {
731
+    function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) {
732 732
     $this->query_where = $where;
733 733
     if($this->getSessionVariable("query", "where") != $where) {
734 734
         $this->query_where_has_changed = true;
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
  * All Rights Reserved.
758 758
  * Contributor(s): ______________________________________.
759 759
 */
760
- function setTheme($theme) {
760
+    function setTheme($theme) {
761 761
     $this->local_theme = $theme;
762 762
     if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
763 763
 }
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
  * All Rights Reserved.
768 768
  * Contributor(s): ______________________________________.
769 769
 */
770
- function setAppStrings($app_strings) {
770
+    function setAppStrings($app_strings) {
771 771
     unset($this->local_app_strings);
772 772
     $this->local_app_strings = $app_strings;
773 773
     if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
  * All Rights Reserved.
779 779
  * Contributor(s): ______________________________________.
780 780
 */
781
- function setModStrings($mod_strings) {
781
+    function setModStrings($mod_strings) {
782 782
     unset($this->local_module_strings);
783 783
     $this->local_mod_strings = $mod_strings;
784 784
     if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
  * All Rights Reserved.
790 790
  * Contributor(s): ______________________________________.
791 791
 */
792
- function setImagePath($image_path) {
792
+    function setImagePath($image_path) {
793 793
     $this->local_image_path = $image_path;
794 794
     if(empty($this->local_image_path)) {
795 795
         $this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath();
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
  * All Rights Reserved.
803 803
  * Contributor(s): ______________________________________.
804 804
 */
805
- function setCurrentModule($currentModule) {
805
+    function setCurrentModule($currentModule) {
806 806
     unset($this->local_current_module);
807 807
     $this->local_current_module = $currentModule;
808 808
     if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
  * All Rights Reserved.
814 814
  * Contributor(s): ______________________________________.
815 815
 */
816
- function createXTemplate() {
816
+    function createXTemplate() {
817 817
     if(!isset($this->xTemplate)) {
818 818
         if(isset($this->xTemplatePath)) {
819 819
 
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
  * All Rights Reserved.
835 835
  * Contributor(s): ______________________________________.
836 836
 */
837
- function setXTemplate($newXTemplate) {
837
+    function setXTemplate($newXTemplate) {
838 838
     $this->xTemplate = $newXTemplate;
839 839
 }
840 840
 
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
  * All Rights Reserved.
844 844
  * Contributor(s): ______________________________________.
845 845
 */
846
- function getXTemplate() {
846
+    function getXTemplate() {
847 847
     return $this->xTemplate;
848 848
 }
849 849
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
  * All Rights Reserved.
853 853
  * Contributor(s): ______________________________________.
854 854
 */
855
- function xTemplateAssign($name, $value) {
855
+    function xTemplateAssign($name, $value) {
856 856
 
857 857
         if(!isset($this->xTemplate)) {
858 858
             $this->createXTemplate();
@@ -866,15 +866,15 @@  discard block
 block discarded – undo
866 866
  * All Rights Reserved.
867 867
  * Contributor(s): ______________________________________.
868 868
 */
869
- function getOffset($localVarName) {
870
- 	if($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
871
- 		$this->setSessionVariable($localVarName,"offset", 0);
872
- 	}
873
-	$offset = $this->getSessionVariable($localVarName,"offset");
874
-	if(isset($offset)) {
875
-		return $offset;
876
-	}
877
-	return 0;
869
+    function getOffset($localVarName) {
870
+        if($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
871
+            $this->setSessionVariable($localVarName,"offset", 0);
872
+        }
873
+    $offset = $this->getSessionVariable($localVarName,"offset");
874
+    if(isset($offset)) {
875
+        return $offset;
876
+    }
877
+    return 0;
878 878
 }
879 879
 
880 880
 /**INTERNAL FUNCTION sets the offset in the session
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
  * All Rights Reserved.
883 883
  * Contributor(s): ______________________________________.
884 884
 */
885
- function setOffset($localVarName, $value) {
885
+    function setOffset($localVarName, $value) {
886 886
         $this->setSessionVariable($localVarName, "offset", $value);
887 887
 }
888 888
 
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
  * All Rights Reserved.
892 892
  * Contributor(s): ______________________________________.
893 893
 */
894
- function setSessionVariable($localVarName,$varName, $value) {
894
+    function setSessionVariable($localVarName,$varName, $value) {
895 895
     $_SESSION[$this->local_current_module."_".$localVarName."_".$varName] = $value;
896 896
 }
897 897
 
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
  * All Rights Reserved.
907 907
  * Contributor(s): ______________________________________.
908 908
 */
909
- function getSessionVariable($localVarName,$varName) {
909
+    function getSessionVariable($localVarName,$varName) {
910 910
     //Set any variables pass in through request first
911 911
     if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
912 912
         $this->setSessionVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
@@ -941,10 +941,10 @@  discard block
 block discarded – undo
941 941
     function calculateSortOrder($sortOrderList)
942 942
     {
943 943
         $priority_map = array(
944
-          'request',
945
-          'session',
946
-          'subpaneldefs',
947
-          'default',
944
+            'request',
945
+            'session',
946
+            'subpaneldefs',
947
+            'default',
948 948
         );
949 949
 
950 950
         foreach($priority_map as $p) {
@@ -960,33 +960,31 @@  discard block
 block discarded – undo
960 960
 
961 961
 
962 962
     /**
963
-
964
-    * @return void
965
-    * @param unknown $localVarName
966
-    * @param unknown $varName
967
-    * @desc INTERNAL FUNCTION returns the session/query variable name
968
-    * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
969
-    * All Rights Reserved.
970
-    * Contributor(s): ______________________________________..
971
-    */
963
+     * @return void
964
+     * @param unknown $localVarName
965
+     * @param unknown $varName
966
+     * @desc INTERNAL FUNCTION returns the session/query variable name
967
+     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
968
+     * All Rights Reserved.
969
+     * Contributor(s): ______________________________________..
970
+     */
972 971
     function getSessionVariableName($localVarName,$varName) {
973 972
         return $this->local_current_module."_".$localVarName."_".$varName;
974 973
     }
975 974
 
976 975
     /**
977
-
978
-    * @return void
979
-    * @param unknown $seed
980
-    * @param unknown $xTemplateSection
981
-    * @param unknown $html_varName
982
-    * @desc INTERNAL FUNCTION Handles List Views using seeds that extend SugarBean
976
+     * @return void
977
+     * @param unknown $seed
978
+     * @param unknown $xTemplateSection
979
+     * @param unknown $html_varName
980
+     * @desc INTERNAL FUNCTION Handles List Views using seeds that extend SugarBean
983 981
         $XTemplateSection is the section in the XTemplate file that should be parsed usually main
984 982
         $html_VarName is the variable name used in the XTemplateFile e.g. TASK
985 983
         $seed is a seed that extends SugarBean
986
-        * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
987
-        * All Rights Reserved..
988
-        * Contributor(s): ______________________________________..
989
-    */
984
+     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
985
+     * All Rights Reserved..
986
+     * Contributor(s): ______________________________________..
987
+     */
990 988
     function processSugarBean($xtemplateSection, $html_varName, $seed) {
991 989
         global $list_view_row_count;
992 990
 
@@ -1035,15 +1033,15 @@  discard block
 block discarded – undo
1035 1033
 
1036 1034
     function processUnionBeans($sugarbean, $subpanel_def, $html_var = 'CELL') {
1037 1035
 
1038
-		$last_detailview_record = $this->getSessionVariable("detailview", "record");
1039
-		if(!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id){
1040
-			$GLOBALS['record_has_changed'] = true;
1041
-		}
1042
-		$this->setSessionVariable("detailview", "record", $sugarbean->id);
1036
+        $last_detailview_record = $this->getSessionVariable("detailview", "record");
1037
+        if(!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id){
1038
+            $GLOBALS['record_has_changed'] = true;
1039
+        }
1040
+        $this->setSessionVariable("detailview", "record", $sugarbean->id);
1043 1041
 
1044
-		$current_offset = $this->getOffset($html_var);
1045
-		$module = isset($_REQUEST['module']) ? $_REQUEST['module'] : '';
1046
-		$response = array();
1042
+        $current_offset = $this->getOffset($html_var);
1043
+        $module = isset($_REQUEST['module']) ? $_REQUEST['module'] : '';
1044
+        $response = array();
1047 1045
 
1048 1046
         // choose sort order
1049 1047
         $sort_order = array();
@@ -1088,11 +1086,11 @@  discard block
 block discarded – undo
1088 1086
         $_SESSION['last_sub' .$this->subpanel_module. '_order'] = $this->sort_order;
1089 1087
         $_SESSION['last_sub' .$this->subpanel_module. '_url'] = $this->getBaseURL($html_var);
1090 1088
 
1091
-		// Bug 8139 - Correct Subpanel sorting on 'name', when subpanel sorting default is 'last_name, first_name'
1092
-		if (($this->sortby == 'name' || $this->sortby == 'last_name') &&
1093
-			str_replace(' ', '', trim($subpanel_def->_instance_properties['sort_by'])) == 'last_name,first_name') {
1094
-			$this->sortby = 'last_name '.$this->sort_order.', first_name ';
1095
-		}
1089
+        // Bug 8139 - Correct Subpanel sorting on 'name', when subpanel sorting default is 'last_name, first_name'
1090
+        if (($this->sortby == 'name' || $this->sortby == 'last_name') &&
1091
+            str_replace(' ', '', trim($subpanel_def->_instance_properties['sort_by'])) == 'last_name,first_name') {
1092
+            $this->sortby = 'last_name '.$this->sort_order.', first_name ';
1093
+        }
1096 1094
 
1097 1095
         if(!empty($this->response)){
1098 1096
             $response =& $this->response;
@@ -1168,15 +1166,15 @@  discard block
 block discarded – undo
1168 1166
             return $baseurl;
1169 1167
     }
1170 1168
     /**
1171
-    * @return void
1172
-    * @param unknown $data
1173
-    * @param unknown $xTemplateSection
1174
-    * @param unknown $html_varName
1175
-    * @desc INTERNAL FUNCTION process the List Navigation
1176
-    * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1177
-    * All Rights Reserved.
1178
-    * Contributor(s): ______________________________________..
1179
-    */
1169
+     * @return void
1170
+     * @param unknown $data
1171
+     * @param unknown $xTemplateSection
1172
+     * @param unknown $html_varName
1173
+     * @desc INTERNAL FUNCTION process the List Navigation
1174
+     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1175
+     * All Rights Reserved.
1176
+     * Contributor(s): ______________________________________..
1177
+     */
1180 1178
     function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean=null, $subpanel_def=null, $col_count = 20) {
1181 1179
 
1182 1180
         global $export_module;
@@ -1316,8 +1314,8 @@  discard block
 block discarded – undo
1316 1314
             $end_record = $end_record-1;
1317 1315
 
1318 1316
 $script_href = "<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $this->records_per_page)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;&#x28;{$this->records_per_page}&#x29;&#x200E;</a>"
1319
- . "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$row_count}&#x29;&#x200E;</a>"
1320
- . "<a style=\'width: 150px\' name=\"deselect\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>";
1317
+    . "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$row_count}&#x29;&#x200E;</a>"
1318
+    . "<a style=\'width: 150px\' name=\"deselect\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>";
1321 1319
 
1322 1320
 $close_inline_img = SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $app_strings['LBL_CLOSEINLINE']);
1323 1321
 
@@ -1548,15 +1546,15 @@  discard block
 block discarded – undo
1548 1546
 
1549 1547
 
1550 1548
     /**
1551
-    * @return void
1552
-    * @param unknown $data
1553
-    * @param unknown $xTemplateSection
1554
-    * @param unknown $html_varName
1555
-    * @desc INTERNAL FUNCTION handles the rows
1556
-    * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1557
-    * All Rights Reserved.
1558
-    * Contributor(s): ______________________________________..
1559
-    */
1549
+     * @return void
1550
+     * @param unknown $data
1551
+     * @param unknown $xTemplateSection
1552
+     * @param unknown $html_varName
1553
+     * @desc INTERNAL FUNCTION handles the rows
1554
+     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1555
+     * All Rights Reserved.
1556
+     * Contributor(s): ______________________________________..
1557
+     */
1560 1558
     function processListRows($data, $xtemplateSection, $html_varName)
1561 1559
     {
1562 1560
         global $odd_bg;
@@ -1753,7 +1751,7 @@  discard block
 block discarded – undo
1753 1751
         {
1754 1752
             $orderBy=  'amount';
1755 1753
         }
1756
-		$buttons = false;
1754
+        $buttons = false;
1757 1755
         $col_count = 0;
1758 1756
         foreach($subpanel_def->get_list_fields() as $column_name=>$widget_args)
1759 1757
         {
@@ -1771,17 +1769,17 @@  discard block
 block discarded – undo
1771 1769
                 }
1772 1770
 
1773 1771
                 if (!preg_match("/_button/i", $column_name)) {
1774
-	                $widget_args['name']=$column_name;
1775
-	                $widget_args['sort'] = $imgArrow;
1776
-	                $widget_args['start_link_wrapper'] = $this->start_link_wrapper;
1777
-	                $widget_args['end_link_wrapper'] = $this->end_link_wrapper;
1778
-	                $widget_args['subpanel_module'] = $this->subpanel_module;
1779
-
1780
-	                $widget_contents = $layout_manager->widgetDisplay($widget_args);
1781
-	                $cell_width = empty($widget_args['width']) ? '' : $widget_args['width'];
1782
-	                $this->xTemplate->assign('HEADER_CELL', $widget_contents);
1783
-	                static $count;
1784
-	            if(!isset($count))$count = 0; else $count++;
1772
+                    $widget_args['name']=$column_name;
1773
+                    $widget_args['sort'] = $imgArrow;
1774
+                    $widget_args['start_link_wrapper'] = $this->start_link_wrapper;
1775
+                    $widget_args['end_link_wrapper'] = $this->end_link_wrapper;
1776
+                    $widget_args['subpanel_module'] = $this->subpanel_module;
1777
+
1778
+                    $widget_contents = $layout_manager->widgetDisplay($widget_args);
1779
+                    $cell_width = empty($widget_args['width']) ? '' : $widget_args['width'];
1780
+                    $this->xTemplate->assign('HEADER_CELL', $widget_contents);
1781
+                    static $count;
1782
+                if(!isset($count))$count = 0; else $count++;
1785 1783
                     if($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"';
1786 1784
                     else {
1787 1785
                         $footable = 'data-hide="phone"';
@@ -1789,11 +1787,11 @@  discard block
 block discarded – undo
1789 1787
                         if ($col_count > 4) $footable = 'data-hide="phone,phonelandscape,tablet"';
1790 1788
                     }
1791 1789
                     $this->xTemplate->assign('FOOTABLE', $footable);
1792
-	                $this->xTemplate->assign('CELL_COUNT', $count);
1793
-	                $this->xTemplate->assign('CELL_WIDTH', $cell_width);
1794
-	                $this->xTemplate->parse('dyn_list_view.header_cell');
1790
+                    $this->xTemplate->assign('CELL_COUNT', $count);
1791
+                    $this->xTemplate->assign('CELL_WIDTH', $cell_width);
1792
+                    $this->xTemplate->parse('dyn_list_view.header_cell');
1795 1793
                 } else {
1796
-                	$buttons = true;
1794
+                    $buttons = true;
1797 1795
                 }
1798 1796
             }
1799 1797
             ++$col_count;
@@ -1801,29 +1799,29 @@  discard block
 block discarded – undo
1801 1799
 
1802 1800
         if($buttons) {
1803 1801
                     $this->xTemplate->assign('FOOTABLE', '');
1804
-        			$this->xTemplate->assign('HEADER_CELL', "&nbsp;");
1805
-        			$this->xTemplate->assign('CELL_COUNT', $count);
1806
-	                $this->xTemplate->assign('CELL_WIDTH', $cell_width);
1807
-	                $this->xTemplate->parse('dyn_list_view.header_cell');
1802
+                    $this->xTemplate->assign('HEADER_CELL', "&nbsp;");
1803
+                    $this->xTemplate->assign('CELL_COUNT', $count);
1804
+                    $this->xTemplate->assign('CELL_WIDTH', $cell_width);
1805
+                    $this->xTemplate->parse('dyn_list_view.header_cell');
1808 1806
         }
1809 1807
 
1810 1808
     }
1811 1809
 
1812 1810
 
1813 1811
     /**
1814
-    * @return void
1815
-    * @param unknown $seed
1816
-    * @param unknown $xTemplateSection
1817
-    * @param unknown $html_varName
1818
-    * @desc PUBLIC FUNCTION Handles List Views using seeds that extend SugarBean
1812
+     * @return void
1813
+     * @param unknown $seed
1814
+     * @param unknown $xTemplateSection
1815
+     * @param unknown $html_varName
1816
+     * @desc PUBLIC FUNCTION Handles List Views using seeds that extend SugarBean
1819 1817
         $XTemplateSection is the section in the XTemplate file that should be parsed usually main
1820 1818
         $html_VarName is the variable name used in the XTemplateFile e.g. TASK
1821 1819
         $seed is a seed there are two types of seeds one is a subclass of SugarBean, the other is a list usually created from a sugar bean using get_list
1822 1820
         if no XTemplate is set it will create  a new XTemplate
1823
-        * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
1824
-        * All Rights Reserved..
1825
-        * Contributor(s): ______________________________________..
1826
-    */
1821
+     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
1822
+     * All Rights Reserved..
1823
+     * Contributor(s): ______________________________________..
1824
+     */
1827 1825
 
1828 1826
     function processListViewTwo($seed, $xTemplateSection, $html_varName) {
1829 1827
         global $current_user;
@@ -1898,12 +1896,12 @@  discard block
 block discarded – undo
1898 1896
         return "&nbsp;<img border='0' src='".SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.{$ext}")."' ";
1899 1897
     }
1900 1898
 
1901
-	function getArrowEnd() {
1902
-		$imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1899
+    function getArrowEnd() {
1900
+        $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1903 1901
 
1904 1902
         list($width,$height) = ListView::getArrowImageSize();
1905 1903
 
1906
-		return '.'.$imgFileParts['extension']."' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">";
1904
+        return '.'.$imgFileParts['extension']."' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">";
1907 1905
     }
1908 1906
 
1909 1907
     function getArrowUpDownEnd($upDown) {
@@ -1924,9 +1922,9 @@  discard block
 block discarded – undo
1924 1922
         return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>";
1925 1923
     }
1926 1924
 
1927
-	function getArrowImageSize() {
1928
-	    // jbasicChartDashletsExpColust get the non-sort image's size.. the up and down have be the same.
1929
-		$image = SugarThemeRegistry::current()->getImageURL("arrow.gif",false);
1925
+    function getArrowImageSize() {
1926
+        // jbasicChartDashletsExpColust get the non-sort image's size.. the up and down have be the same.
1927
+        $image = SugarThemeRegistry::current()->getImageURL("arrow.gif",false);
1930 1928
 
1931 1929
         $cache_key = 'arrow_size.'.$image;
1932 1930
 
@@ -1958,13 +1956,13 @@  discard block
 block discarded – undo
1958 1956
         return $result;
1959 1957
     }
1960 1958
 
1961
-	function getOrderByInfo($html_varName)
1962
-	{
1963
-		$orderBy = $this->getSessionVariable($html_varName, "OBL");
1964
-		$desc = $this->getSessionVariable($html_varName, $orderBy.'S');
1965
-		$orderBy = str_replace('.', '_', $orderBy);
1966
-		return array($orderBy,$desc);
1967
-	}
1959
+    function getOrderByInfo($html_varName)
1960
+    {
1961
+        $orderBy = $this->getSessionVariable($html_varName, "OBL");
1962
+        $desc = $this->getSessionVariable($html_varName, $orderBy.'S');
1963
+        $orderBy = str_replace('.', '_', $orderBy);
1964
+        return array($orderBy,$desc);
1965
+    }
1968 1966
 
1969 1967
     function processSortArrows($html_varName)
1970 1968
     {
@@ -1973,25 +1971,25 @@  discard block
 block discarded – undo
1973 1971
 
1974 1972
         list($orderBy,$desc) = $this->getOrderByInfo($html_varName);
1975 1973
 
1976
-		$imgArrow = "_up";
1977
-		if($desc) {
1978
-			$imgArrow = "_down";
1979
-		}
1980
-		/**
1981
-		 * @deprecated only used by legacy opportunites listview, nothing current. Leaving for BC
1982
-		 */
1983
-		if($orderBy == 'amount')
1984
-		{
1985
-			$this->xTemplateAssign('amount_arrow', $imgArrow);
1986
-		}
1987
-		else if($orderBy == 'amount_usdollar')
1988
-		{
1989
-			$this->xTemplateAssign('amount_usdollar_arrow', $imgArrow);
1990
-		}
1991
-		else
1992
-		{
1993
-			$this->xTemplateAssign($orderBy.'_arrow', $imgArrow);
1994
-		}
1974
+        $imgArrow = "_up";
1975
+        if($desc) {
1976
+            $imgArrow = "_down";
1977
+        }
1978
+        /**
1979
+         * @deprecated only used by legacy opportunites listview, nothing current. Leaving for BC
1980
+         */
1981
+        if($orderBy == 'amount')
1982
+        {
1983
+            $this->xTemplateAssign('amount_arrow', $imgArrow);
1984
+        }
1985
+        else if($orderBy == 'amount_usdollar')
1986
+        {
1987
+            $this->xTemplateAssign('amount_usdollar_arrow', $imgArrow);
1988
+        }
1989
+        else
1990
+        {
1991
+            $this->xTemplateAssign($orderBy.'_arrow', $imgArrow);
1992
+        }
1995 1993
 
1996 1994
         $this->xTemplateAssign('arrow_end', $this->getArrowEnd());
1997 1995
     }
@@ -2030,37 +2028,37 @@  discard block
 block discarded – undo
2030 2028
         return sugar_microtime();
2031 2029
     }
2032 2030
 
2033
-     /**INTERNAL FUNCTION sets a session variable keeping it local to the listview
2031
+        /**INTERNAL FUNCTION sets a session variable keeping it local to the listview
2034 2032
      not the current_module
2035 2033
      * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
2036 2034
      * All Rights Reserved.
2037 2035
      * Contributor(s): ______________________________________.
2038 2036
      */
2039
-     function setLocalSessionVariable($localVarName,$varName, $value) {
2037
+        function setLocalSessionVariable($localVarName,$varName, $value) {
2040 2038
         $_SESSION[$localVarName."_".$varName] = $value;
2041
-     }
2039
+        }
2042 2040
 
2043
-     /**INTERNAL FUNCTION returns a session variable that is local to the listview,
2041
+        /**INTERNAL FUNCTION returns a session variable that is local to the listview,
2044 2042
      not the current_module
2045 2043
      * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
2046 2044
      * All Rights Reserved.
2047 2045
      * Contributor(s): ______________________________________.
2048 2046
      */
2049
- function getLocalSessionVariable($localVarName,$varName) {
2047
+    function getLocalSessionVariable($localVarName,$varName) {
2050 2048
     if(isset($_SESSION[$localVarName."_".$varName])) {
2051 2049
         return $_SESSION[$localVarName."_".$varName];
2052 2050
     }
2053 2051
     else{
2054 2052
         return "";
2055 2053
     }
2056
- }
2054
+    }
2057 2055
 
2058
- /* Set to true if you want Additional Details to appear in the listview
2056
+    /* Set to true if you want Additional Details to appear in the listview
2059 2057
   */
2060
- function setAdditionalDetails($value = true, $function = '') {
2058
+    function setAdditionalDetails($value = true, $function = '') {
2061 2059
     if(!empty($function)) $this->additionalDetailsFunction = $function;
2062 2060
     $this->_additionalDetails = $value;
2063
- }
2061
+    }
2064 2062
 
2065 2063
 }
2066 2064
 ?>
Please login to merge, or discard this patch.
include/ListView/ListViewData.php 4 patches
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	function getOrderBy($orderBy = '', $direction = '') {
77 77
 		if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
78
-            if(!empty($_REQUEST[$this->var_order_by])) {
78
+            if (!empty($_REQUEST[$this->var_order_by])) {
79 79
     			$direction = 'ASC';
80 80
     			$orderBy = $_REQUEST[$this->var_order_by];
81
-    			if(!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0) ){
81
+    			if (!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0)) {
82 82
     				$direction = $_REQUEST['lvso'];
83 83
     			}
84 84
             }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         }
88 88
 		else {
89 89
             $userPreferenceOrder = $GLOBALS['current_user']->getPreference('listviewOrder', $this->var_name);
90
-			if(!empty($_SESSION[$this->var_order_by])) {
90
+			if (!empty($_SESSION[$this->var_order_by])) {
91 91
 				$orderBy = $_SESSION[$this->var_order_by]['orderBy'];
92 92
 				$direction = $_SESSION[$this->var_order_by]['direction'];
93 93
             } elseif (!empty($userPreferenceOrder)) {
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 				$direction = 'DESC';
99 99
 			}
100 100
 		}
101
-		if(!empty($direction)) {
102
-    		if(strtolower($direction) == "desc") {
101
+		if (!empty($direction)) {
102
+    		if (strtolower($direction) == "desc") {
103 103
     		    $direction = 'DESC';
104 104
     		} else {
105 105
     		    $direction = 'ASC';
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @param STRING (ASC or DESC) $current_order
115 115
 	 * @return  STRING (ASC or DESC)
116 116
 	 */
117
-	function getReverseSortOrder($current_order){
118
-		return (strcmp(strtolower($current_order), 'asc') == 0)?'DESC':'ASC';
117
+	function getReverseSortOrder($current_order) {
118
+		return (strcmp(strtolower($current_order), 'asc') == 0) ? 'DESC' : 'ASC';
119 119
 	}
120 120
 	/**
121 121
 	 * gets the limit of how many rows to show per page
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
     {
146 146
         global $beanList;
147 147
 
148
-        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount',$this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
149
-        foreach($beanList as $bean)
148
+        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', $this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
149
+        foreach ($beanList as $bean)
150 150
         {
151 151
             $blockVariables[] = 'Home2_'.strtoupper($bean).'_ORDER_BY';
152 152
         }
@@ -164,30 +164,30 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param unknown_type $baseName
166 166
 	 */
167
-	function setVariableName($baseName, $where, $listviewName = null){
167
+	function setVariableName($baseName, $where, $listviewName = null) {
168 168
         global $timedate;
169
-        $module = (!empty($listviewName)) ? $listviewName: $_REQUEST['module'];
170
-        $this->var_name = $module .'2_'. strtoupper($baseName);
169
+        $module = (!empty($listviewName)) ? $listviewName : $_REQUEST['module'];
170
+        $this->var_name = $module.'2_'.strtoupper($baseName);
171 171
 
172
-		$this->var_order_by = $this->var_name .'_ORDER_BY';
173
-		$this->var_offset = $this->var_name . '_offset';
172
+		$this->var_order_by = $this->var_name.'_ORDER_BY';
173
+		$this->var_offset = $this->var_name.'_offset';
174 174
         $timestamp = sugar_microtime();
175 175
         $this->stamp = $timestamp;
176 176
 
177
-        $_SESSION[$module .'2_QUERY_QUERY'] = $where;
177
+        $_SESSION[$module.'2_QUERY_QUERY'] = $where;
178 178
 
179
-        $_SESSION[strtoupper($baseName) . "_FROM_LIST_VIEW"] = $timestamp;
180
-        $_SESSION[strtoupper($baseName) . "_DETAIL_NAV_HISTORY"] = false;
179
+        $_SESSION[strtoupper($baseName)."_FROM_LIST_VIEW"] = $timestamp;
180
+        $_SESSION[strtoupper($baseName)."_DETAIL_NAV_HISTORY"] = false;
181 181
 	}
182 182
 
183
-	function getTotalCount($main_query){
184
-		if(!empty($this->count_query)){
183
+	function getTotalCount($main_query) {
184
+		if (!empty($this->count_query)) {
185 185
 		    $count_query = $this->count_query;
186
-		}else{
186
+		} else {
187 187
 	        $count_query = $this->seed->create_list_count_query($main_query);
188 188
 	    }
189 189
 		$result = $this->db->query($count_query);
190
-		if($row = $this->db->fetchByAssoc($result)){
190
+		if ($row = $this->db->fetchByAssoc($result)) {
191 191
 			return $row['c'];
192 192
 		}
193 193
 		return 0;
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 	 * @param string:'id' $id_field
230 230
 	 * @return array('data'=> row data, 'pageData' => page data information, 'query' => original query string)
231 231
 	 */
232
-	function getListViewData($seed, $where, $offset=-1, $limit = -1, $filter_fields=array(),$params=array(),$id_field = 'id',$singleSelect=true) {
232
+	function getListViewData($seed, $where, $offset = -1, $limit = -1, $filter_fields = array(), $params = array(), $id_field = 'id', $singleSelect = true) {
233 233
         global $current_user;
234 234
         SugarVCR::erase($seed->module_dir);
235
-        $this->seed =& $seed;
235
+        $this->seed = & $seed;
236 236
         $totalCounted = empty($GLOBALS['sugar_config']['disable_count_query']);
237 237
         $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $seed->module_dir;
238
-        if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup'){
238
+        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
239 239
             $_SESSION['MAILMERGE_MODULE'] = $seed->module_dir;
240 240
         }
241 241
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		$this->seed->id = '[SELECT_ID_LIST]';
245 245
 
246 246
         // if $params tell us to override all ordering
247
-        if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
247
+        if (!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
248 248
             $order = $this->getOrderBy(strtolower($params['orderBy']), (empty($params['sortOrder']) ? '' : $params['sortOrder'])); // retreive from $_REQUEST
249 249
         }
250 250
         else {
@@ -252,17 +252,17 @@  discard block
 block discarded – undo
252 252
         }
253 253
 
254 254
         // still empty? try to use settings passed in $param
255
-        if(empty($order['orderBy']) && !empty($params['orderBy'])) {
255
+        if (empty($order['orderBy']) && !empty($params['orderBy'])) {
256 256
             $order['orderBy'] = $params['orderBy'];
257
-            $order['sortOrder'] =  (empty($params['sortOrder']) ? '' : $params['sortOrder']);
257
+            $order['sortOrder'] = (empty($params['sortOrder']) ? '' : $params['sortOrder']);
258 258
         }
259 259
 
260 260
         //rrs - bug: 21788. Do not use Order by stmts with fields that are not in the query.
261 261
         // Bug 22740 - Tweak this check to strip off the table name off the order by parameter.
262 262
         // Samir Gandhi : Do not remove the report_cache.date_modified condition as the report list view is broken
263 263
         $orderby = $order['orderBy'];
264
-        if (strpos($order['orderBy'],'.') && ($order['orderBy'] != "report_cache.date_modified")) {
265
-            $orderby = substr($order['orderBy'],strpos($order['orderBy'],'.')+1);
264
+        if (strpos($order['orderBy'], '.') && ($order['orderBy'] != "report_cache.date_modified")) {
265
+            $orderby = substr($order['orderBy'], strpos($order['orderBy'], '.') + 1);
266 266
         }
267 267
         if ($orderby != 'date_entered' && !in_array($orderby, array_keys($filter_fields))) {
268 268
         	$order['orderBy'] = '';
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 		if (empty($order['orderBy'])) {
273 273
             $orderBy = '';
274 274
         } else {
275
-            $orderBy = $order['orderBy'] . ' ' . $order['sortOrder'];
275
+            $orderBy = $order['orderBy'].' '.$order['sortOrder'];
276 276
             //wdong, Bug 25476, fix the sorting problem of Oracle.
277 277
             if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code'])
278
-                $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder'];
278
+                $orderBy = $params['custom_order_by_override']['custom_code'].' '.$order['sortOrder'];
279 279
         }
280 280
 
281 281
         if (empty($params['skipOrderSave'])) { // don't save preferences if told so
@@ -290,34 +290,34 @@  discard block
 block discarded – undo
290 290
 		$ret_array = $seed->create_new_list_query($orderBy, $where, $filter_fields, $params, 0, '', true, $seed, $singleSelect);
291 291
         $ret_array['inner_join'] = '';
292 292
         if (!empty($this->seed->listview_inner_join)) {
293
-            $ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' ';
293
+            $ret_array['inner_join'] = ' '.implode(' ', $this->seed->listview_inner_join).' ';
294 294
         }
295 295
 
296
-		if(!is_array($params)) $params = array();
297
-        if(!isset($params['custom_select'])) $params['custom_select'] = '';
298
-        if(!isset($params['custom_from'])) $params['custom_from'] = '';
299
-        if(!isset($params['custom_where'])) $params['custom_where'] = '';
300
-        if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
301
-		$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
296
+		if (!is_array($params)) $params = array();
297
+        if (!isset($params['custom_select'])) $params['custom_select'] = '';
298
+        if (!isset($params['custom_from'])) $params['custom_from'] = '';
299
+        if (!isset($params['custom_where'])) $params['custom_where'] = '';
300
+        if (!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
301
+		$main_query = $ret_array['select'].$params['custom_select'].$ret_array['from'].$params['custom_from'].$ret_array['inner_join'].$ret_array['where'].$params['custom_where'].$ret_array['order_by'].$params['custom_order_by'];
302 302
 		//C.L. - Fix for 23461
303
-		if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
303
+		if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
304 304
           	   $_SESSION['export_where'] = $ret_array['where'];
305 305
 		}
306
-   		if($limit < -1) {
306
+   		if ($limit < -1) {
307 307
 			$result = $this->db->query($main_query);
308 308
 		}
309 309
 		else {
310
-			if($limit == -1) {
310
+			if ($limit == -1) {
311 311
 				$limit = $this->getLimit();
312 312
             }
313 313
 			$dyn_offset = $this->getOffset();
314
-			if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
314
+			if ($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
315 315
 
316
-            if(strcmp($offset, 'end') == 0){
316
+            if (strcmp($offset, 'end') == 0) {
317 317
             	$totalCount = $this->getTotalCount($main_query);
318
-            	$offset = (floor(($totalCount -1) / $limit)) * $limit;
318
+            	$offset = (floor(($totalCount - 1) / $limit)) * $limit;
319 319
             }
320
-            if($this->seed->ACLAccess('ListView')) {
320
+            if ($this->seed->ACLAccess('ListView')) {
321 321
                 $result = $this->db->limitQuery($main_query, $offset, $limit + 1);
322 322
             }
323 323
             else {
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
         $idIndex = array();
336 336
         $id_list = '';
337 337
 
338
-   		while(($row = $this->db->fetchByAssoc($result)) != null)
338
+   		while (($row = $this->db->fetchByAssoc($result)) != null)
339 339
         {
340
-   			if($count < $limit)
340
+   			if ($count < $limit)
341 341
             {
342 342
    				$id_list .= ',\''.$row[$id_field].'\'';
343 343
    				$idIndex[$row[$id_field]][] = count($rows);
@@ -351,51 +351,51 @@  discard block
 block discarded – undo
351 351
             $id_list = '('.substr($id_list, 1).')';
352 352
         }
353 353
 
354
-        SugarVCR::store($this->seed->module_dir,  $main_query);
355
-		if($count != 0) {
354
+        SugarVCR::store($this->seed->module_dir, $main_query);
355
+		if ($count != 0) {
356 356
 			//NOW HANDLE SECONDARY QUERIES
357
-			if(!empty($ret_array['secondary_select'])) {
358
-				$secondary_query = $ret_array['secondary_select'] . $ret_array['secondary_from'] . ' WHERE '.$this->seed->table_name.'.id IN ' .$id_list;
359
-                if(isset($ret_array['order_by']))
357
+			if (!empty($ret_array['secondary_select'])) {
358
+				$secondary_query = $ret_array['secondary_select'].$ret_array['secondary_from'].' WHERE '.$this->seed->table_name.'.id IN '.$id_list;
359
+                if (isset($ret_array['order_by']))
360 360
                 {
361
-                    $secondary_query .= ' ' . $ret_array['order_by'];
361
+                    $secondary_query .= ' '.$ret_array['order_by'];
362 362
                 }
363 363
 
364 364
                 $secondary_result = $this->db->query($secondary_query);
365 365
 
366 366
                 $ref_id_count = array();
367
-				while($row = $this->db->fetchByAssoc($secondary_result)) {
367
+				while ($row = $this->db->fetchByAssoc($secondary_result)) {
368 368
 
369 369
                     $ref_id_count[$row['ref_id']][] = true;
370
-					foreach($row as $name=>$value) {
370
+					foreach ($row as $name=>$value) {
371 371
 						//add it to every row with the given id
372
-						foreach($idIndex[$row['ref_id']] as $index){
373
-						    $rows[$index][$name]=$value;
372
+						foreach ($idIndex[$row['ref_id']] as $index) {
373
+						    $rows[$index][$name] = $value;
374 374
 						}
375 375
 					}
376 376
 				}
377 377
 
378 378
                 $rows_keys = array_keys($rows);
379
-                foreach($rows_keys as $key)
379
+                foreach ($rows_keys as $key)
380 380
                 {
381 381
                     $rows[$key]['secondary_select_count'] = count($ref_id_count[$rows[$key]['ref_id']]);
382 382
                 }
383 383
 			}
384 384
 
385 385
             // retrieve parent names
386
-            if(!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
387
-                foreach($idIndex as $id => $rowIndex) {
388
-                    if(!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
386
+            if (!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
387
+                foreach ($idIndex as $id => $rowIndex) {
388
+                    if (!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
389 389
                         $post_retrieve[$rows[$rowIndex[0]]['parent_type']] = array();
390 390
                     }
391
-                    if(!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
391
+                    if (!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id, 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
392 392
                 }
393
-                if(isset($post_retrieve)) {
393
+                if (isset($post_retrieve)) {
394 394
                     $parent_fields = $seed->retrieve_parent_fields($post_retrieve);
395
-                    foreach($parent_fields as $child_id => $parent_data) {
395
+                    foreach ($parent_fields as $child_id => $parent_data) {
396 396
                         //add it to every row with the given id
397
-						foreach($idIndex[$child_id] as $index){
398
-						    $rows[$index]['parent_name']= $parent_data['parent_name'];
397
+						foreach ($idIndex[$child_id] as $index) {
398
+						    $rows[$index]['parent_name'] = $parent_data['parent_name'];
399 399
 						}
400 400
                     }
401 401
                 }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$pageData = array();
405 405
 
406 406
 			reset($rows);
407
-			while($row = current($rows)){
407
+			while ($row = current($rows)) {
408 408
 
409 409
                 $temp = clone $seed;
410 410
 			    $dataIndex = count($data);
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 				if (empty($this->seed->assigned_user_id) && !empty($temp->assigned_user_id)) {
415 415
 				    $this->seed->assigned_user_id = $temp->assigned_user_id;
416 416
 				}
417
-				if($idIndex[$row[$id_field]][0] == $dataIndex){
417
+				if ($idIndex[$row[$id_field]][0] == $dataIndex) {
418 418
 				    $pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
419
-				}else{
419
+				} else {
420 420
 				    $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
421 421
 				}
422 422
 				$data[$dataIndex] = $temp->get_list_view_data($filter_fields);
@@ -424,21 +424,21 @@  discard block
 block discarded – undo
424 424
                 $editViewAccess = $temp->ACLAccess('EditView');
425 425
                 $pageData['rowAccess'][$dataIndex] = array('view' => $detailViewAccess, 'edit' => $editViewAccess);
426 426
                 $additionalDetailsAllow = $this->additionalDetails && $detailViewAccess && (file_exists(
427
-                         'modules/' . $temp->module_dir . '/metadata/additionalDetails.php'
428
-                     ) || file_exists('custom/modules/' . $temp->module_dir . '/metadata/additionalDetails.php'));
427
+                         'modules/'.$temp->module_dir.'/metadata/additionalDetails.php'
428
+                     ) || file_exists('custom/modules/'.$temp->module_dir.'/metadata/additionalDetails.php'));
429 429
                 $additionalDetailsEdit = $editViewAccess;
430
-                if($additionalDetailsAllow) {
431
-                    if($this->additionalDetailsAjax) {
430
+                if ($additionalDetailsAllow) {
431
+                    if ($this->additionalDetailsAjax) {
432 432
 					   $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
433 433
                     }
434 434
                     else {
435
-                        $additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
436
-                        if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){
437
-                        	$additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
435
+                        $additionalDetailsFile = 'modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php';
436
+                        if (file_exists('custom/modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php')) {
437
+                        	$additionalDetailsFile = 'custom/modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php';
438 438
                         }
439 439
                         require_once($additionalDetailsFile);
440 440
                         $ar = $this->getAdditionalDetails($data[$dataIndex],
441
-                                    (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $this->seed->object_name,
441
+                                    (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction).$this->seed->object_name,
442 442
                                     $additionalDetailsEdit);
443 443
                     }
444 444
                     $pageData['additionalDetails'][$dataIndex] = $ar['string'];
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
 		$nextOffset = -1;
451 451
 		$prevOffset = -1;
452 452
 		$endOffset = -1;
453
-		if($count > $limit) {
453
+		if ($count > $limit) {
454 454
 			$nextOffset = $offset + $limit;
455 455
 		}
456 456
 
457
-		if($offset > 0) {
457
+		if ($offset > 0) {
458 458
 			$prevOffset = $offset - $limit;
459
-			if($prevOffset < 0)$prevOffset = 0;
459
+			if ($prevOffset < 0)$prevOffset = 0;
460 460
 		}
461 461
 		$totalCount = $count + $offset;
462 462
 
463
-		if( $count >= $limit && $totalCounted){
464
-			$totalCount  = $this->getTotalCount($main_query);
463
+		if ($count >= $limit && $totalCounted) {
464
+			$totalCount = $this->getTotalCount($main_query);
465 465
 		}
466 466
 		SugarVCR::recordIDs($this->seed->module_dir, array_keys($idIndex), $offset, $totalCount);
467 467
         $module_names = array(
@@ -471,21 +471,21 @@  discard block
 block discarded – undo
471 471
 		$pageData['ordering'] = $order;
472 472
 		$pageData['ordering']['sortOrder'] = $this->getReverseSortOrder($pageData['ordering']['sortOrder']);
473 473
         //get url parameters as an array
474
-        $pageData['queries'] = $this->generateQueries($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset,  $endOffset, $totalCounted);
474
+        $pageData['queries'] = $this->generateQueries($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset, $endOffset, $totalCounted);
475 475
         //join url parameters from array to a string
476 476
         $pageData['urls'] = $this->generateURLS($pageData['queries']);
477
-		$pageData['offsets'] = array( 'current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
477
+		$pageData['offsets'] = array('current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
478 478
 		$pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir, 'moduleName' => strtr($seed->module_dir, $module_names));
479 479
         $pageData['stamp'] = $this->stamp;
480 480
         $pageData['access'] = array('view' => $this->seed->ACLAccess('DetailView'), 'edit' => $this->seed->ACLAccess('EditView'));
481 481
 		$pageData['idIndex'] = $idIndex;
482
-        if(!$this->seed->ACLAccess('ListView')) {
482
+        if (!$this->seed->ACLAccess('ListView')) {
483 483
             $pageData['error'] = 'ACL restricted access';
484 484
         }
485 485
 
486 486
         $queryString = '';
487 487
 
488
-        if( isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "advanced_search" ||
488
+        if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "advanced_search" ||
489 489
         	isset($_REQUEST["type_basic"]) && (count($_REQUEST["type_basic"] > 1) || $_REQUEST["type_basic"][0] != "") ||
490 490
         	isset($_REQUEST["module"]) && $_REQUEST["module"] == "MergeRecords")
491 491
         {
@@ -493,19 +493,19 @@  discard block
 block discarded – undo
493 493
         }
494 494
         else if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "basic_search")
495 495
         {
496
-            if($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
496
+            if ($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
497 497
             else $searchMetaData = SearchForm::retrieveSearchDefs($seed->module_dir);
498 498
 
499 499
             $basicSearchFields = array();
500 500
 
501
-            if( isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']) )
501
+            if (isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']))
502 502
                 $basicSearchFields = $searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search'];
503 503
 
504
-            foreach( $basicSearchFields as $basicSearchField)
504
+            foreach ($basicSearchFields as $basicSearchField)
505 505
             {
506 506
                 $field_name = (is_array($basicSearchField) && isset($basicSearchField['name'])) ? $basicSearchField['name'] : $basicSearchField;
507 507
                 $field_name .= "_basic";
508
-                if( isset($_REQUEST[$field_name])  && ( !is_array($basicSearchField) || !isset($basicSearchField['type']) || $basicSearchField['type'] == 'text' || $basicSearchField['type'] == 'name') )
508
+                if (isset($_REQUEST[$field_name]) && (!is_array($basicSearchField) || !isset($basicSearchField['type']) || $basicSearchField['type'] == 'text' || $basicSearchField['type'] == 'name'))
509 509
                 {
510 510
                     // Ensure the encoding is UTF-8
511 511
                     $queryString = htmlentities($_REQUEST[$field_name], null, 'UTF-8');
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             }
515 515
         }
516 516
 
517
-		return array('data'=>$data , 'pageData'=>$pageData, 'query' => $queryString);
517
+		return array('data'=>$data, 'pageData'=>$pageData, 'query' => $queryString);
518 518
 	}
519 519
 
520 520
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
     {
529 529
         foreach ($queries as $name => $value)
530 530
         {
531
-            $queries[$name] = 'index.php?' . http_build_query($value);
531
+            $queries[$name] = 'index.php?'.http_build_query($value);
532 532
         }
533 533
         $this->base_url = $queries['baseURL'];
534 534
         return $queries;
@@ -554,22 +554,22 @@  discard block
 block discarded – undo
554 554
         $queries['orderBy'] = $queries['baseURL'];
555 555
         $queries['orderBy'][$this->var_order_by] = '';
556 556
 
557
-        if($nextOffset > -1)
557
+        if ($nextOffset > -1)
558 558
         {
559 559
             $queries['nextPage'] = $queries['baseURL'];
560 560
             $queries['nextPage'][$this->var_offset] = $nextOffset;
561 561
         }
562
-        if($offset > 0)
562
+        if ($offset > 0)
563 563
         {
564 564
             $queries['startPage'] = $queries['baseURL'];
565 565
             $queries['startPage'][$this->var_offset] = 0;
566 566
         }
567
-        if($prevOffset > -1)
567
+        if ($prevOffset > -1)
568 568
         {
569 569
             $queries['prevPage'] = $queries['baseURL'];
570 570
             $queries['prevPage'][$this->var_offset] = $prevOffset;
571 571
         }
572
-        if($totalCounted)
572
+        if ($totalCounted)
573 573
         {
574 574
             $queries['endPage'] = $queries['baseURL'];
575 575
             $queries['endPage'][$this->var_offset] = $endOffset;
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 
595 595
         $jscalendarImage = SugarThemeRegistry::current()->getImageURL('info_inline.gif');
596 596
 
597
-        $extra = "<span id='adspan_" . $id . "' "
597
+        $extra = "<span id='adspan_".$id."' "
598 598
                 . "onclick=\"lvg_dtails('$id')\" "
599 599
 				. " style='position: relative;'><!--not_in_theme!--><img vertical-align='middle' class='info' border='0' alt='".$app_strings['LBL_ADDITIONAL_DETAILS']."' src='$jscalendarImage'></span>";
600 600
 
@@ -618,27 +618,27 @@  discard block
 block discarded – undo
618 618
 
619 619
         $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
620 620
 
621
-        if(trim($results['string']) == '')
621
+        if (trim($results['string']) == '')
622 622
         {
623 623
             $results['string'] = $app_strings['LBL_NONE'];
624 624
         }
625 625
          	$close = false;
626 626
             $extra = "<img alt='{$app_strings['LBL_INFOINLINE']}' style='padding: 0px 5px 0px 2px' border='0' onclick=\"SUGAR.util.getStaticAdditionalDetails(this,'";
627 627
 
628
-            $extra .= str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string']) ;
628
+            $extra .= str_replace(array("\rn", "\r", "\n"), array('', '', '<br />'), $results['string']);
629 629
             $extra .= "','<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
630 630
 
631
-	        if($editAccess && !empty($results['editLink']))
631
+	        if ($editAccess && !empty($results['editLink']))
632 632
 	        {
633
-	            $extra .=  "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
633
+	            $extra .= "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
634 634
 	            $close = true;
635 635
 	        }
636 636
 	        $close = (!empty($results['viewLink'])) ? true : $close;
637 637
 	        $extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=".SugarThemeRegistry::current()->getImageURL('view_inline.png')."></a>" : '');
638 638
 
639
-            if($close == true) {
639
+            if ($close == true) {
640 640
             	$closeVal = "true";
641
-            	$extra .=  "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
641
+            	$extra .= "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
642 642
             } else {
643 643
             	$closeVal = "false";
644 644
             }
Please login to merge, or discard this patch.
Braces   +47 added lines, -31 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.
@@ -84,8 +86,7 @@  discard block
 block discarded – undo
84 86
             }
85 87
             $_SESSION[$this->var_order_by] = array('orderBy'=>$orderBy, 'direction'=> $direction);
86 88
             $_SESSION['lvd']['last_ob'] = $orderBy;
87
-        }
88
-		else {
89
+        } else {
89 90
             $userPreferenceOrder = $GLOBALS['current_user']->getPreference('listviewOrder', $this->var_name);
90 91
 			if(!empty($_SESSION[$this->var_order_by])) {
91 92
 				$orderBy = $_SESSION[$this->var_order_by]['orderBy'];
@@ -183,7 +184,7 @@  discard block
 block discarded – undo
183 184
 	function getTotalCount($main_query){
184 185
 		if(!empty($this->count_query)){
185 186
 		    $count_query = $this->count_query;
186
-		}else{
187
+		} else{
187 188
 	        $count_query = $this->seed->create_list_count_query($main_query);
188 189
 	    }
189 190
 		$result = $this->db->query($count_query);
@@ -246,8 +247,7 @@  discard block
 block discarded – undo
246 247
         // if $params tell us to override all ordering
247 248
         if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
248 249
             $order = $this->getOrderBy(strtolower($params['orderBy']), (empty($params['sortOrder']) ? '' : $params['sortOrder'])); // retreive from $_REQUEST
249
-        }
250
-        else {
250
+        } else {
251 251
             $order = $this->getOrderBy(); // retreive from $_REQUEST
252 252
         }
253 253
 
@@ -274,8 +274,9 @@  discard block
 block discarded – undo
274 274
         } else {
275 275
             $orderBy = $order['orderBy'] . ' ' . $order['sortOrder'];
276 276
             //wdong, Bug 25476, fix the sorting problem of Oracle.
277
-            if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code'])
278
-                $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder'];
277
+            if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code']) {
278
+                            $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder'];
279
+            }
279 280
         }
280 281
 
281 282
         if (empty($params['skipOrderSave'])) { // don't save preferences if told so
@@ -293,11 +294,21 @@  discard block
 block discarded – undo
293 294
             $ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' ';
294 295
         }
295 296
 
296
-		if(!is_array($params)) $params = array();
297
-        if(!isset($params['custom_select'])) $params['custom_select'] = '';
298
-        if(!isset($params['custom_from'])) $params['custom_from'] = '';
299
-        if(!isset($params['custom_where'])) $params['custom_where'] = '';
300
-        if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
297
+		if(!is_array($params)) {
298
+		    $params = array();
299
+		}
300
+        if(!isset($params['custom_select'])) {
301
+            $params['custom_select'] = '';
302
+        }
303
+        if(!isset($params['custom_from'])) {
304
+            $params['custom_from'] = '';
305
+        }
306
+        if(!isset($params['custom_where'])) {
307
+            $params['custom_where'] = '';
308
+        }
309
+        if(!isset($params['custom_order_by'])) {
310
+            $params['custom_order_by'] = '';
311
+        }
301 312
 		$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
302 313
 		//C.L. - Fix for 23461
303 314
 		if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
@@ -305,13 +316,14 @@  discard block
 block discarded – undo
305 316
 		}
306 317
    		if($limit < -1) {
307 318
 			$result = $this->db->query($main_query);
308
-		}
309
-		else {
319
+		} else {
310 320
 			if($limit == -1) {
311 321
 				$limit = $this->getLimit();
312 322
             }
313 323
 			$dyn_offset = $this->getOffset();
314
-			if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
324
+			if($dyn_offset > 0 || !is_int($dyn_offset)) {
325
+			    $offset = $dyn_offset;
326
+			}
315 327
 
316 328
             if(strcmp($offset, 'end') == 0){
317 329
             	$totalCount = $this->getTotalCount($main_query);
@@ -319,8 +331,7 @@  discard block
 block discarded – undo
319 331
             }
320 332
             if($this->seed->ACLAccess('ListView')) {
321 333
                 $result = $this->db->limitQuery($main_query, $offset, $limit + 1);
322
-            }
323
-            else {
334
+            } else {
324 335
                 $result = array();
325 336
             }
326 337
 
@@ -388,7 +399,9 @@  discard block
 block discarded – undo
388 399
                     if(!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
389 400
                         $post_retrieve[$rows[$rowIndex[0]]['parent_type']] = array();
390 401
                     }
391
-                    if(!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
402
+                    if(!empty($rows[$rowIndex[0]]['parent_id'])) {
403
+                        $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
404
+                    }
392 405
                 }
393 406
                 if(isset($post_retrieve)) {
394 407
                     $parent_fields = $seed->retrieve_parent_fields($post_retrieve);
@@ -416,7 +429,7 @@  discard block
 block discarded – undo
416 429
 				}
417 430
 				if($idIndex[$row[$id_field]][0] == $dataIndex){
418 431
 				    $pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
419
-				}else{
432
+				} else{
420 433
 				    $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
421 434
 				}
422 435
 				$data[$dataIndex] = $temp->get_list_view_data($filter_fields);
@@ -430,8 +443,7 @@  discard block
 block discarded – undo
430 443
                 if($additionalDetailsAllow) {
431 444
                     if($this->additionalDetailsAjax) {
432 445
 					   $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
433
-                    }
434
-                    else {
446
+                    } else {
435 447
                         $additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
436 448
                         if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){
437 449
                         	$additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
@@ -456,7 +468,9 @@  discard block
 block discarded – undo
456 468
 
457 469
 		if($offset > 0) {
458 470
 			$prevOffset = $offset - $limit;
459
-			if($prevOffset < 0)$prevOffset = 0;
471
+			if($prevOffset < 0) {
472
+			    $prevOffset = 0;
473
+			}
460 474
 		}
461 475
 		$totalCount = $count + $offset;
462 476
 
@@ -490,16 +504,19 @@  discard block
 block discarded – undo
490 504
         	isset($_REQUEST["module"]) && $_REQUEST["module"] == "MergeRecords")
491 505
         {
492 506
             $queryString = "-advanced_search";
493
-        }
494
-        else if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "basic_search")
507
+        } else if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "basic_search")
495 508
         {
496
-            if($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
497
-            else $searchMetaData = SearchForm::retrieveSearchDefs($seed->module_dir);
509
+            if($seed->module_dir == "Reports") {
510
+                $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
511
+            } else {
512
+                $searchMetaData = SearchForm::retrieveSearchDefs($seed->module_dir);
513
+            }
498 514
 
499 515
             $basicSearchFields = array();
500 516
 
501
-            if( isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']) )
502
-                $basicSearchFields = $searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search'];
517
+            if( isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']) ) {
518
+                            $basicSearchFields = $searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search'];
519
+            }
503 520
 
504 521
             foreach( $basicSearchFields as $basicSearchField)
505 522
             {
@@ -573,8 +590,7 @@  discard block
 block discarded – undo
573 590
         {
574 591
             $queries['endPage'] = $queries['baseURL'];
575 592
             $queries['endPage'][$this->var_offset] = $endOffset;
576
-        }
577
-        else
593
+        } else
578 594
         {
579 595
             $queries['endPage'] = $queries['baseURL'];
580 596
             $queries['endPage'][$this->var_offset] = 'end';
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -162,7 +162,8 @@  discard block
 block discarded – undo
162 162
 	/**
163 163
 	 * based off of a base name it sets base, offset, and order by variable names to retrieve them from requests and sessions
164 164
 	 *
165
-	 * @param unknown_type $baseName
165
+	 * @param string $baseName
166
+	 * @param string $where
166 167
 	 */
167 168
 	function setVariableName($baseName, $where, $listviewName = null){
168 169
         global $timedate;
@@ -180,6 +181,9 @@  discard block
 block discarded – undo
180 181
         $_SESSION[strtoupper($baseName) . "_DETAIL_NAV_HISTORY"] = false;
181 182
 	}
182 183
 
184
+	/**
185
+	 * @param string $main_query
186
+	 */
183 187
 	function getTotalCount($main_query){
184 188
 		if(!empty($this->count_query)){
185 189
 		    $count_query = $this->count_query;
@@ -605,8 +609,8 @@  discard block
 block discarded – undo
605 609
      * generates the additional details values
606 610
      *
607 611
      * @param unknown_type $fields
608
-     * @param unknown_type $adFunction
609
-     * @param unknown_type $editAccess
612
+     * @param string $adFunction
613
+     * @param boolean $editAccess
610 614
      * @return array string to attach to field
611 615
      */
612 616
     function getAdditionalDetails($fields, $adFunction, $editAccess)
Please login to merge, or discard this patch.
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
  */
47 47
 class ListViewData {
48 48
 
49
-	var $additionalDetails = true;
49
+    var $additionalDetails = true;
50 50
     var $listviewName = null;
51
-	var $additionalDetailsAllow = null;
51
+    var $additionalDetailsAllow = null;
52 52
     var $additionalDetailsAjax = true; // leave this true when using filter fields
53 53
     var $additionalDetailsFieldToAdd = 'NAME'; // where the span will be attached to
54 54
     var $base_url = null;
@@ -58,82 +58,82 @@  discard block
 block discarded – undo
58 58
      */
59 59
     var $count_query = '';
60 60
 
61
-	/**
62
-	 * Constructor sets the limitName to look up the limit in $sugar_config
63
-	 *
64
-	 * @return ListViewData
65
-	 */
66
-	public function __construct() {
67
-		$this->limitName = 'list_max_entries_per_page';
68
-		$this->db = DBManagerFactory::getInstance('listviews');
69
-	}
70
-
71
-	/**
72
-	 * checks the request for the order by and if that is not set then it checks the session for it
73
-	 *
74
-	 * @return array containing the keys orderBy => field being ordered off of and sortOrder => the sort order of that field
75
-	 */
76
-	function getOrderBy($orderBy = '', $direction = '') {
77
-		if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
61
+    /**
62
+     * Constructor sets the limitName to look up the limit in $sugar_config
63
+     *
64
+     * @return ListViewData
65
+     */
66
+    public function __construct() {
67
+        $this->limitName = 'list_max_entries_per_page';
68
+        $this->db = DBManagerFactory::getInstance('listviews');
69
+    }
70
+
71
+    /**
72
+     * checks the request for the order by and if that is not set then it checks the session for it
73
+     *
74
+     * @return array containing the keys orderBy => field being ordered off of and sortOrder => the sort order of that field
75
+     */
76
+    function getOrderBy($orderBy = '', $direction = '') {
77
+        if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
78 78
             if(!empty($_REQUEST[$this->var_order_by])) {
79
-    			$direction = 'ASC';
80
-    			$orderBy = $_REQUEST[$this->var_order_by];
81
-    			if(!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0) ){
82
-    				$direction = $_REQUEST['lvso'];
83
-    			}
79
+                $direction = 'ASC';
80
+                $orderBy = $_REQUEST[$this->var_order_by];
81
+                if(!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0) ){
82
+                    $direction = $_REQUEST['lvso'];
83
+                }
84 84
             }
85 85
             $_SESSION[$this->var_order_by] = array('orderBy'=>$orderBy, 'direction'=> $direction);
86 86
             $_SESSION['lvd']['last_ob'] = $orderBy;
87 87
         }
88
-		else {
88
+        else {
89 89
             $userPreferenceOrder = $GLOBALS['current_user']->getPreference('listviewOrder', $this->var_name);
90
-			if(!empty($_SESSION[$this->var_order_by])) {
91
-				$orderBy = $_SESSION[$this->var_order_by]['orderBy'];
92
-				$direction = $_SESSION[$this->var_order_by]['direction'];
90
+            if(!empty($_SESSION[$this->var_order_by])) {
91
+                $orderBy = $_SESSION[$this->var_order_by]['orderBy'];
92
+                $direction = $_SESSION[$this->var_order_by]['direction'];
93 93
             } elseif (!empty($userPreferenceOrder)) {
94 94
                 $orderBy = $userPreferenceOrder['orderBy'];
95 95
                 $direction = $userPreferenceOrder['sortOrder'];
96 96
             } else {
97
-				$orderBy = 'date_entered';
98
-				$direction = 'DESC';
99
-			}
100
-		}
101
-		if(!empty($direction)) {
102
-    		if(strtolower($direction) == "desc") {
103
-    		    $direction = 'DESC';
104
-    		} else {
105
-    		    $direction = 'ASC';
106
-    		}
107
-		}
108
-		return array('orderBy' => $orderBy, 'sortOrder' => $direction);
109
-	}
110
-
111
-	/**
112
-	 * gets the reverse of the sort order for use on links to reverse a sort order from what is currently used
113
-	 *
114
-	 * @param STRING (ASC or DESC) $current_order
115
-	 * @return  STRING (ASC or DESC)
116
-	 */
117
-	function getReverseSortOrder($current_order){
118
-		return (strcmp(strtolower($current_order), 'asc') == 0)?'DESC':'ASC';
119
-	}
120
-	/**
121
-	 * gets the limit of how many rows to show per page
122
-	 *
123
-	 * @return INT (the limit)
124
-	 */
125
-	function getLimit() {
126
-		return $GLOBALS['sugar_config'][$this->limitName];
127
-	}
128
-
129
-	/**
130
-	 * returns the current offset
131
-	 *
132
-	 * @return INT (current offset)
133
-	 */
134
-	function getOffset() {
135
-		return (!empty($_REQUEST[$this->var_offset])) ? $_REQUEST[$this->var_offset] : 0;
136
-	}
97
+                $orderBy = 'date_entered';
98
+                $direction = 'DESC';
99
+            }
100
+        }
101
+        if(!empty($direction)) {
102
+            if(strtolower($direction) == "desc") {
103
+                $direction = 'DESC';
104
+            } else {
105
+                $direction = 'ASC';
106
+            }
107
+        }
108
+        return array('orderBy' => $orderBy, 'sortOrder' => $direction);
109
+    }
110
+
111
+    /**
112
+     * gets the reverse of the sort order for use on links to reverse a sort order from what is currently used
113
+     *
114
+     * @param STRING (ASC or DESC) $current_order
115
+     * @return  STRING (ASC or DESC)
116
+     */
117
+    function getReverseSortOrder($current_order){
118
+        return (strcmp(strtolower($current_order), 'asc') == 0)?'DESC':'ASC';
119
+    }
120
+    /**
121
+     * gets the limit of how many rows to show per page
122
+     *
123
+     * @return INT (the limit)
124
+     */
125
+    function getLimit() {
126
+        return $GLOBALS['sugar_config'][$this->limitName];
127
+    }
128
+
129
+    /**
130
+     * returns the current offset
131
+     *
132
+     * @return INT (current offset)
133
+     */
134
+    function getOffset() {
135
+        return (!empty($_REQUEST[$this->var_offset])) ? $_REQUEST[$this->var_offset] : 0;
136
+    }
137 137
 
138 138
     /**
139 139
      * generates the base url without
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
         return $params;
160 160
     }
161 161
 
162
-	/**
163
-	 * based off of a base name it sets base, offset, and order by variable names to retrieve them from requests and sessions
164
-	 *
165
-	 * @param unknown_type $baseName
166
-	 */
167
-	function setVariableName($baseName, $where, $listviewName = null){
162
+    /**
163
+     * based off of a base name it sets base, offset, and order by variable names to retrieve them from requests and sessions
164
+     *
165
+     * @param unknown_type $baseName
166
+     */
167
+    function setVariableName($baseName, $where, $listviewName = null){
168 168
         global $timedate;
169 169
         $module = (!empty($listviewName)) ? $listviewName: $_REQUEST['module'];
170 170
         $this->var_name = $module .'2_'. strtoupper($baseName);
171 171
 
172
-		$this->var_order_by = $this->var_name .'_ORDER_BY';
173
-		$this->var_offset = $this->var_name . '_offset';
172
+        $this->var_order_by = $this->var_name .'_ORDER_BY';
173
+        $this->var_offset = $this->var_name . '_offset';
174 174
         $timestamp = sugar_microtime();
175 175
         $this->stamp = $timestamp;
176 176
 
@@ -178,58 +178,58 @@  discard block
 block discarded – undo
178 178
 
179 179
         $_SESSION[strtoupper($baseName) . "_FROM_LIST_VIEW"] = $timestamp;
180 180
         $_SESSION[strtoupper($baseName) . "_DETAIL_NAV_HISTORY"] = false;
181
-	}
182
-
183
-	function getTotalCount($main_query){
184
-		if(!empty($this->count_query)){
185
-		    $count_query = $this->count_query;
186
-		}else{
187
-	        $count_query = $this->seed->create_list_count_query($main_query);
188
-	    }
189
-		$result = $this->db->query($count_query);
190
-		if($row = $this->db->fetchByAssoc($result)){
191
-			return $row['c'];
192
-		}
193
-		return 0;
194
-	}
195
-
196
-	/**
197
-	 * takes in a seed and creates the list view query based off of that seed
198
-	 * if the $limit value is set to -1 then it will use the default limit and offset values
199
-	 *
200
-	 * it will return an array with two key values
201
-	 * 	1. 'data'=> this is an array of row data
202
-	 *  2. 'pageData'=> this is an array containg three values
203
-	 * 			a.'ordering'=> array('orderBy'=> the field being ordered by , 'sortOrder'=> 'ASC' or 'DESC')
204
-	 * 			b.'urls'=>array('baseURL'=>url used to generate other urls ,
205
-	 * 							'orderBy'=> the base url for order by
206
-	 * 							//the following may not be set (so check empty to see if they are set)
207
-	 * 							'nextPage'=> the url for the next group of results,
208
-	 * 							'prevPage'=> the url for the prev group of results,
209
-	 * 							'startPage'=> the url for the start of the group,
210
-	 * 							'endPage'=> the url for the last set of results in the group
211
-	 * 			c.'offsets'=>array(
212
-	 * 								'current'=>current offset
213
-	 * 								'next'=> next group offset
214
-	 * 								'prev'=> prev group offset
215
-	 * 								'end'=> the offset of the last group
216
-	 * 								'total'=> the total count (only accurate if totalCounted = true otherwise it is either the total count if less than the limit or the total count + 1 )
217
-	 * 								'totalCounted'=> if a count query was used to get the total count
218
-	 *
219
-	 * @param SugarBean $seed
220
-	 * @param string $where
221
-	 * @param int:0 $offset
222
-	 * @param int:-1 $limit
223
-	 * @param string[]:array() $filter_fields
224
-	 * @param array:array() $params
225
-	 * 	Potential $params are
181
+    }
182
+
183
+    function getTotalCount($main_query){
184
+        if(!empty($this->count_query)){
185
+            $count_query = $this->count_query;
186
+        }else{
187
+            $count_query = $this->seed->create_list_count_query($main_query);
188
+        }
189
+        $result = $this->db->query($count_query);
190
+        if($row = $this->db->fetchByAssoc($result)){
191
+            return $row['c'];
192
+        }
193
+        return 0;
194
+    }
195
+
196
+    /**
197
+     * takes in a seed and creates the list view query based off of that seed
198
+     * if the $limit value is set to -1 then it will use the default limit and offset values
199
+     *
200
+     * it will return an array with two key values
201
+     * 	1. 'data'=> this is an array of row data
202
+     *  2. 'pageData'=> this is an array containg three values
203
+     * 			a.'ordering'=> array('orderBy'=> the field being ordered by , 'sortOrder'=> 'ASC' or 'DESC')
204
+     * 			b.'urls'=>array('baseURL'=>url used to generate other urls ,
205
+     * 							'orderBy'=> the base url for order by
206
+     * 							//the following may not be set (so check empty to see if they are set)
207
+     * 							'nextPage'=> the url for the next group of results,
208
+     * 							'prevPage'=> the url for the prev group of results,
209
+     * 							'startPage'=> the url for the start of the group,
210
+     * 							'endPage'=> the url for the last set of results in the group
211
+     * 			c.'offsets'=>array(
212
+     * 								'current'=>current offset
213
+     * 								'next'=> next group offset
214
+     * 								'prev'=> prev group offset
215
+     * 								'end'=> the offset of the last group
216
+     * 								'total'=> the total count (only accurate if totalCounted = true otherwise it is either the total count if less than the limit or the total count + 1 )
217
+     * 								'totalCounted'=> if a count query was used to get the total count
218
+     *
219
+     * @param SugarBean $seed
220
+     * @param string $where
221
+     * @param int:0 $offset
222
+     * @param int:-1 $limit
223
+     * @param string[]:array() $filter_fields
224
+     * @param array:array() $params
225
+     * 	Potential $params are
226 226
 		$params['distinct'] = use distinct key word
227 227
 		$params['include_custom_fields'] = (on by default)
228 228
         $params['custom_XXXX'] = append custom statements to query
229
-	 * @param string:'id' $id_field
230
-	 * @return array('data'=> row data, 'pageData' => page data information, 'query' => original query string)
231
-	 */
232
-	function getListViewData($seed, $where, $offset=-1, $limit = -1, $filter_fields=array(),$params=array(),$id_field = 'id',$singleSelect=true) {
229
+     * @param string:'id' $id_field
230
+     * @return array('data'=> row data, 'pageData' => page data information, 'query' => original query string)
231
+     */
232
+    function getListViewData($seed, $where, $offset=-1, $limit = -1, $filter_fields=array(),$params=array(),$id_field = 'id',$singleSelect=true) {
233 233
         global $current_user;
234 234
         SugarVCR::erase($seed->module_dir);
235 235
         $this->seed =& $seed;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
         $this->setVariableName($seed->object_name, $where, $this->listviewName);
243 243
 
244
-		$this->seed->id = '[SELECT_ID_LIST]';
244
+        $this->seed->id = '[SELECT_ID_LIST]';
245 245
 
246 246
         // if $params tell us to override all ordering
247 247
         if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
             $orderby = substr($order['orderBy'],strpos($order['orderBy'],'.')+1);
266 266
         }
267 267
         if ($orderby != 'date_entered' && !in_array($orderby, array_keys($filter_fields))) {
268
-        	$order['orderBy'] = '';
269
-        	$order['sortOrder'] = '';
268
+            $order['orderBy'] = '';
269
+            $order['sortOrder'] = '';
270 270
         }
271 271
 
272
-		if (empty($order['orderBy'])) {
272
+        if (empty($order['orderBy'])) {
273 273
             $orderBy = '';
274 274
         } else {
275 275
             $orderBy = $order['orderBy'] . ' ' . $order['sortOrder'];
@@ -282,40 +282,40 @@  discard block
 block discarded – undo
282 282
             $current_user->setPreference('listviewOrder', $order, 0, $this->var_name); // save preference
283 283
         }
284 284
 
285
-		// If $params tells us to override for the special last_name, first_name sorting
286
-		if (!empty($params['overrideLastNameOrder']) && $order['orderBy'] == 'last_name') {
287
-			$orderBy = 'last_name '.$order['sortOrder'].', first_name '.$order['sortOrder'];
288
-		}
285
+        // If $params tells us to override for the special last_name, first_name sorting
286
+        if (!empty($params['overrideLastNameOrder']) && $order['orderBy'] == 'last_name') {
287
+            $orderBy = 'last_name '.$order['sortOrder'].', first_name '.$order['sortOrder'];
288
+        }
289 289
 
290
-		$ret_array = $seed->create_new_list_query($orderBy, $where, $filter_fields, $params, 0, '', true, $seed, $singleSelect);
290
+        $ret_array = $seed->create_new_list_query($orderBy, $where, $filter_fields, $params, 0, '', true, $seed, $singleSelect);
291 291
         $ret_array['inner_join'] = '';
292 292
         if (!empty($this->seed->listview_inner_join)) {
293 293
             $ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' ';
294 294
         }
295 295
 
296
-		if(!is_array($params)) $params = array();
296
+        if(!is_array($params)) $params = array();
297 297
         if(!isset($params['custom_select'])) $params['custom_select'] = '';
298 298
         if(!isset($params['custom_from'])) $params['custom_from'] = '';
299 299
         if(!isset($params['custom_where'])) $params['custom_where'] = '';
300 300
         if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
301
-		$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
302
-		//C.L. - Fix for 23461
303
-		if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
304
-          	   $_SESSION['export_where'] = $ret_array['where'];
305
-		}
306
-   		if($limit < -1) {
307
-			$result = $this->db->query($main_query);
308
-		}
309
-		else {
310
-			if($limit == -1) {
311
-				$limit = $this->getLimit();
301
+        $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
302
+        //C.L. - Fix for 23461
303
+        if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
304
+                    $_SESSION['export_where'] = $ret_array['where'];
305
+        }
306
+            if($limit < -1) {
307
+            $result = $this->db->query($main_query);
308
+        }
309
+        else {
310
+            if($limit == -1) {
311
+                $limit = $this->getLimit();
312 312
             }
313
-			$dyn_offset = $this->getOffset();
314
-			if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
313
+            $dyn_offset = $this->getOffset();
314
+            if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
315 315
 
316 316
             if(strcmp($offset, 'end') == 0){
317
-            	$totalCount = $this->getTotalCount($main_query);
318
-            	$offset = (floor(($totalCount -1) / $limit)) * $limit;
317
+                $totalCount = $this->getTotalCount($main_query);
318
+                $offset = (floor(($totalCount -1) / $limit)) * $limit;
319 319
             }
320 320
             if($this->seed->ACLAccess('ListView')) {
321 321
                 $result = $this->db->limitQuery($main_query, $offset, $limit + 1);
@@ -324,27 +324,27 @@  discard block
 block discarded – undo
324 324
                 $result = array();
325 325
             }
326 326
 
327
-		}
327
+        }
328 328
 
329
-		$data = array();
329
+        $data = array();
330 330
 
331
-		$temp = clone $seed;
331
+        $temp = clone $seed;
332 332
 
333
-		$rows = array();
334
-		$count = 0;
333
+        $rows = array();
334
+        $count = 0;
335 335
         $idIndex = array();
336 336
         $id_list = '';
337 337
 
338
-   		while(($row = $this->db->fetchByAssoc($result)) != null)
338
+            while(($row = $this->db->fetchByAssoc($result)) != null)
339 339
         {
340
-   			if($count < $limit)
340
+                if($count < $limit)
341 341
             {
342
-   				$id_list .= ',\''.$row[$id_field].'\'';
343
-   				$idIndex[$row[$id_field]][] = count($rows);
344
-   				$rows[] = $seed->convertRow($row);
345
-   			}
346
-   			$count++;
347
-   		}
342
+                    $id_list .= ',\''.$row[$id_field].'\'';
343
+                    $idIndex[$row[$id_field]][] = count($rows);
344
+                    $rows[] = $seed->convertRow($row);
345
+                }
346
+                $count++;
347
+            }
348 348
 
349 349
         if (!empty($id_list))
350 350
         {
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
         }
353 353
 
354 354
         SugarVCR::store($this->seed->module_dir,  $main_query);
355
-		if($count != 0) {
356
-			//NOW HANDLE SECONDARY QUERIES
357
-			if(!empty($ret_array['secondary_select'])) {
358
-				$secondary_query = $ret_array['secondary_select'] . $ret_array['secondary_from'] . ' WHERE '.$this->seed->table_name.'.id IN ' .$id_list;
355
+        if($count != 0) {
356
+            //NOW HANDLE SECONDARY QUERIES
357
+            if(!empty($ret_array['secondary_select'])) {
358
+                $secondary_query = $ret_array['secondary_select'] . $ret_array['secondary_from'] . ' WHERE '.$this->seed->table_name.'.id IN ' .$id_list;
359 359
                 if(isset($ret_array['order_by']))
360 360
                 {
361 361
                     $secondary_query .= ' ' . $ret_array['order_by'];
@@ -364,23 +364,23 @@  discard block
 block discarded – undo
364 364
                 $secondary_result = $this->db->query($secondary_query);
365 365
 
366 366
                 $ref_id_count = array();
367
-				while($row = $this->db->fetchByAssoc($secondary_result)) {
367
+                while($row = $this->db->fetchByAssoc($secondary_result)) {
368 368
 
369 369
                     $ref_id_count[$row['ref_id']][] = true;
370
-					foreach($row as $name=>$value) {
371
-						//add it to every row with the given id
372
-						foreach($idIndex[$row['ref_id']] as $index){
373
-						    $rows[$index][$name]=$value;
374
-						}
375
-					}
376
-				}
370
+                    foreach($row as $name=>$value) {
371
+                        //add it to every row with the given id
372
+                        foreach($idIndex[$row['ref_id']] as $index){
373
+                            $rows[$index][$name]=$value;
374
+                        }
375
+                    }
376
+                }
377 377
 
378 378
                 $rows_keys = array_keys($rows);
379 379
                 foreach($rows_keys as $key)
380 380
                 {
381 381
                     $rows[$key]['secondary_select_count'] = count($ref_id_count[$rows[$key]['ref_id']]);
382 382
                 }
383
-			}
383
+            }
384 384
 
385 385
             // retrieve parent names
386 386
             if(!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
@@ -394,47 +394,47 @@  discard block
 block discarded – undo
394 394
                     $parent_fields = $seed->retrieve_parent_fields($post_retrieve);
395 395
                     foreach($parent_fields as $child_id => $parent_data) {
396 396
                         //add it to every row with the given id
397
-						foreach($idIndex[$child_id] as $index){
398
-						    $rows[$index]['parent_name']= $parent_data['parent_name'];
399
-						}
397
+                        foreach($idIndex[$child_id] as $index){
398
+                            $rows[$index]['parent_name']= $parent_data['parent_name'];
399
+                        }
400 400
                     }
401 401
                 }
402 402
             }
403 403
 
404
-			$pageData = array();
404
+            $pageData = array();
405 405
 
406
-			reset($rows);
407
-			while($row = current($rows)){
406
+            reset($rows);
407
+            while($row = current($rows)){
408 408
 
409 409
                 $temp = clone $seed;
410
-			    $dataIndex = count($data);
411
-
412
-			    $temp->setupCustomFields($temp->module_dir);
413
-				$temp->loadFromRow($row);
414
-				if (empty($this->seed->assigned_user_id) && !empty($temp->assigned_user_id)) {
415
-				    $this->seed->assigned_user_id = $temp->assigned_user_id;
416
-				}
417
-				if($idIndex[$row[$id_field]][0] == $dataIndex){
418
-				    $pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
419
-				}else{
420
-				    $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
421
-				}
422
-				$data[$dataIndex] = $temp->get_list_view_data($filter_fields);
410
+                $dataIndex = count($data);
411
+
412
+                $temp->setupCustomFields($temp->module_dir);
413
+                $temp->loadFromRow($row);
414
+                if (empty($this->seed->assigned_user_id) && !empty($temp->assigned_user_id)) {
415
+                    $this->seed->assigned_user_id = $temp->assigned_user_id;
416
+                }
417
+                if($idIndex[$row[$id_field]][0] == $dataIndex){
418
+                    $pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
419
+                }else{
420
+                    $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
421
+                }
422
+                $data[$dataIndex] = $temp->get_list_view_data($filter_fields);
423 423
                 $detailViewAccess = $temp->ACLAccess('DetailView');
424 424
                 $editViewAccess = $temp->ACLAccess('EditView');
425 425
                 $pageData['rowAccess'][$dataIndex] = array('view' => $detailViewAccess, 'edit' => $editViewAccess);
426 426
                 $additionalDetailsAllow = $this->additionalDetails && $detailViewAccess && (file_exists(
427
-                         'modules/' . $temp->module_dir . '/metadata/additionalDetails.php'
428
-                     ) || file_exists('custom/modules/' . $temp->module_dir . '/metadata/additionalDetails.php'));
427
+                            'modules/' . $temp->module_dir . '/metadata/additionalDetails.php'
428
+                        ) || file_exists('custom/modules/' . $temp->module_dir . '/metadata/additionalDetails.php'));
429 429
                 $additionalDetailsEdit = $editViewAccess;
430 430
                 if($additionalDetailsAllow) {
431 431
                     if($this->additionalDetailsAjax) {
432
-					   $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
432
+                        $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
433 433
                     }
434 434
                     else {
435 435
                         $additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
436 436
                         if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){
437
-                        	$additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
437
+                            $additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
438 438
                         }
439 439
                         require_once($additionalDetailsFile);
440 440
                         $ar = $this->getAdditionalDetails($data[$dataIndex],
@@ -443,42 +443,42 @@  discard block
 block discarded – undo
443 443
                     }
444 444
                     $pageData['additionalDetails'][$dataIndex] = $ar['string'];
445 445
                     $pageData['additionalDetails']['fieldToAddTo'] = $ar['fieldToAddTo'];
446
-				}
447
-				next($rows);
448
-			}
449
-		}
450
-		$nextOffset = -1;
451
-		$prevOffset = -1;
452
-		$endOffset = -1;
453
-		if($count > $limit) {
454
-			$nextOffset = $offset + $limit;
455
-		}
456
-
457
-		if($offset > 0) {
458
-			$prevOffset = $offset - $limit;
459
-			if($prevOffset < 0)$prevOffset = 0;
460
-		}
461
-		$totalCount = $count + $offset;
462
-
463
-		if( $count >= $limit && $totalCounted){
464
-			$totalCount  = $this->getTotalCount($main_query);
465
-		}
466
-		SugarVCR::recordIDs($this->seed->module_dir, array_keys($idIndex), $offset, $totalCount);
446
+                }
447
+                next($rows);
448
+            }
449
+        }
450
+        $nextOffset = -1;
451
+        $prevOffset = -1;
452
+        $endOffset = -1;
453
+        if($count > $limit) {
454
+            $nextOffset = $offset + $limit;
455
+        }
456
+
457
+        if($offset > 0) {
458
+            $prevOffset = $offset - $limit;
459
+            if($prevOffset < 0)$prevOffset = 0;
460
+        }
461
+        $totalCount = $count + $offset;
462
+
463
+        if( $count >= $limit && $totalCounted){
464
+            $totalCount  = $this->getTotalCount($main_query);
465
+        }
466
+        SugarVCR::recordIDs($this->seed->module_dir, array_keys($idIndex), $offset, $totalCount);
467 467
         $module_names = array(
468 468
             'Prospects' => 'Targets'
469 469
         );
470
-		$endOffset = (floor(($totalCount - 1) / $limit)) * $limit;
471
-		$pageData['ordering'] = $order;
472
-		$pageData['ordering']['sortOrder'] = $this->getReverseSortOrder($pageData['ordering']['sortOrder']);
470
+        $endOffset = (floor(($totalCount - 1) / $limit)) * $limit;
471
+        $pageData['ordering'] = $order;
472
+        $pageData['ordering']['sortOrder'] = $this->getReverseSortOrder($pageData['ordering']['sortOrder']);
473 473
         //get url parameters as an array
474 474
         $pageData['queries'] = $this->generateQueries($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset,  $endOffset, $totalCounted);
475 475
         //join url parameters from array to a string
476 476
         $pageData['urls'] = $this->generateURLS($pageData['queries']);
477
-		$pageData['offsets'] = array( 'current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
478
-		$pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir, 'moduleName' => strtr($seed->module_dir, $module_names));
477
+        $pageData['offsets'] = array( 'current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
478
+        $pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir, 'moduleName' => strtr($seed->module_dir, $module_names));
479 479
         $pageData['stamp'] = $this->stamp;
480 480
         $pageData['access'] = array('view' => $this->seed->ACLAccess('DetailView'), 'edit' => $this->seed->ACLAccess('EditView'));
481
-		$pageData['idIndex'] = $idIndex;
481
+        $pageData['idIndex'] = $idIndex;
482 482
         if(!$this->seed->ACLAccess('ListView')) {
483 483
             $pageData['error'] = 'ACL restricted access';
484 484
         }
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
         $queryString = '';
487 487
 
488 488
         if( isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "advanced_search" ||
489
-        	isset($_REQUEST["type_basic"]) && (count($_REQUEST["type_basic"] > 1) || $_REQUEST["type_basic"][0] != "") ||
490
-        	isset($_REQUEST["module"]) && $_REQUEST["module"] == "MergeRecords")
489
+            isset($_REQUEST["type_basic"]) && (count($_REQUEST["type_basic"] > 1) || $_REQUEST["type_basic"][0] != "") ||
490
+            isset($_REQUEST["module"]) && $_REQUEST["module"] == "MergeRecords")
491 491
         {
492 492
             $queryString = "-advanced_search";
493 493
         }
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
             }
515 515
         }
516 516
 
517
-		return array('data'=>$data , 'pageData'=>$pageData, 'query' => $queryString);
518
-	}
517
+        return array('data'=>$data , 'pageData'=>$pageData, 'query' => $queryString);
518
+    }
519 519
 
520 520
 
521 521
     /**
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
         return $queries;
583 583
     }
584 584
 
585
-	/**
586
-	 * generates the additional details span to be retrieved via ajax
587
-	 *
588
-	 * @param GUID id id of the record
589
-	 * @return array string to attach to field
590
-	 */
591
-	function getAdditionalDetailsAjax($id)
585
+    /**
586
+     * generates the additional details span to be retrieved via ajax
587
+     *
588
+     * @param GUID id id of the record
589
+     * @return array string to attach to field
590
+     */
591
+    function getAdditionalDetailsAjax($id)
592 592
     {
593 593
         global $app_strings;
594 594
 
@@ -596,10 +596,10 @@  discard block
 block discarded – undo
596 596
 
597 597
         $extra = "<span id='adspan_" . $id . "' "
598 598
                 . "onclick=\"lvg_dtails('$id')\" "
599
-				. " style='position: relative;'><!--not_in_theme!--><img vertical-align='middle' class='info' border='0' alt='".$app_strings['LBL_ADDITIONAL_DETAILS']."' src='$jscalendarImage'></span>";
599
+                . " style='position: relative;'><!--not_in_theme!--><img vertical-align='middle' class='info' border='0' alt='".$app_strings['LBL_ADDITIONAL_DETAILS']."' src='$jscalendarImage'></span>";
600 600
 
601 601
         return array('fieldToAddTo' => $this->additionalDetailsFieldToAdd, 'string' => $extra);
602
-	}
602
+    }
603 603
 
604 604
     /**
605 605
      * generates the additional details values
@@ -622,25 +622,25 @@  discard block
 block discarded – undo
622 622
         {
623 623
             $results['string'] = $app_strings['LBL_NONE'];
624 624
         }
625
-         	$close = false;
625
+                $close = false;
626 626
             $extra = "<img alt='{$app_strings['LBL_INFOINLINE']}' style='padding: 0px 5px 0px 2px' border='0' onclick=\"SUGAR.util.getStaticAdditionalDetails(this,'";
627 627
 
628 628
             $extra .= str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string']) ;
629 629
             $extra .= "','<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
630 630
 
631
-	        if($editAccess && !empty($results['editLink']))
632
-	        {
633
-	            $extra .=  "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
634
-	            $close = true;
635
-	        }
636
-	        $close = (!empty($results['viewLink'])) ? true : $close;
637
-	        $extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=".SugarThemeRegistry::current()->getImageURL('view_inline.png')."></a>" : '');
631
+            if($editAccess && !empty($results['editLink']))
632
+            {
633
+                $extra .=  "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
634
+                $close = true;
635
+            }
636
+            $close = (!empty($results['viewLink'])) ? true : $close;
637
+            $extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=".SugarThemeRegistry::current()->getImageURL('view_inline.png')."></a>" : '');
638 638
 
639 639
             if($close == true) {
640
-            	$closeVal = "true";
641
-            	$extra .=  "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
640
+                $closeVal = "true";
641
+                $extra .=  "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
642 642
             } else {
643
-            	$closeVal = "false";
643
+                $closeVal = "false";
644 644
             }
645 645
             $extra .= "',".$closeVal.")\" src='".SugarThemeRegistry::current()->getImageURL('info_inline.png')."' class='info'>";
646 646
 
Please login to merge, or discard this patch.
include/utils/sugar_file_utils.php 4 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -54,44 +54,44 @@  discard block
 block discarded – undo
54 54
  * @return boolean - Returns true on success false on failure
55 55
  */
56 56
 function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') {
57
-	$mode = get_mode('dir_mode', $mode);
58
-
59
-	if ( sugar_is_dir($pathname,$mode) )
60
-	    return true;
61
-
62
-	$result = false;
63
-	if(empty($mode))
64
-		$mode = 0777;
65
-	if(empty($context)) {
66
-		$result = @mkdir($pathname, $mode, $recursive);
67
-	} else {
68
-		$result = @mkdir($pathname, $mode, $recursive, $context);
69
-	}
70
-
71
-	if($result){
72
-		if(!sugar_chmod($pathname, $mode)){
73
-			return false;
74
-		}
75
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
76
-			if(!sugar_chown($pathname)){
77
-				return false;
78
-			}
79
-		}
80
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
81
-   			if(!sugar_chgrp($pathname)) {
82
-   				return false;
83
-   			}
84
-		}
85
-	}
86
-	else {
87
-		$errorMessage = "Cannot create directory $pathname cannot be touched";
88
-		if(is_null($GLOBALS['log'])) {
89
-			throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
90
-		}
91
-		$GLOBALS['log']->error($errorMessage);
92
-	}
93
-
94
-	return $result;
57
+    $mode = get_mode('dir_mode', $mode);
58
+
59
+    if ( sugar_is_dir($pathname,$mode) )
60
+        return true;
61
+
62
+    $result = false;
63
+    if(empty($mode))
64
+        $mode = 0777;
65
+    if(empty($context)) {
66
+        $result = @mkdir($pathname, $mode, $recursive);
67
+    } else {
68
+        $result = @mkdir($pathname, $mode, $recursive, $context);
69
+    }
70
+
71
+    if($result){
72
+        if(!sugar_chmod($pathname, $mode)){
73
+            return false;
74
+        }
75
+        if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
76
+            if(!sugar_chown($pathname)){
77
+                return false;
78
+            }
79
+        }
80
+        if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
81
+                if(!sugar_chgrp($pathname)) {
82
+                    return false;
83
+                }
84
+        }
85
+    }
86
+    else {
87
+        $errorMessage = "Cannot create directory $pathname cannot be touched";
88
+        if(is_null($GLOBALS['log'])) {
89
+            throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
90
+        }
91
+        $GLOBALS['log']->error($errorMessage);
92
+    }
93
+
94
+    return $result;
95 95
 }
96 96
 
97 97
 /**
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
  * @return boolean - Returns a file pointer on success, false otherwise
110 110
  */
111 111
 function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){
112
-	//check to see if the file exists, if not then use touch to create it.
113
-	if(!file_exists($filename)){
114
-		sugar_touch($filename);
115
-	}
112
+    //check to see if the file exists, if not then use touch to create it.
113
+    if(!file_exists($filename)){
114
+        sugar_touch($filename);
115
+    }
116 116
 
117
-	if(empty($context)) {
117
+    if(empty($context)) {
118 118
 
119
-		return fopen($filename, $mode, $use_include_path);
120
-	} else {
121
-		return fopen($filename, $mode, $use_include_path, $context);
122
-	}
119
+        return fopen($filename, $mode, $use_include_path);
120
+    } else {
121
+        return fopen($filename, $mode, $use_include_path, $context);
122
+    }
123 123
 }
124 124
 
125 125
 /**
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
  * @return int - Returns the number of bytes written to the file, false otherwise.
138 138
  */
139 139
 function sugar_file_put_contents($filename, $data, $flags=null, $context=null){
140
-	//check to see if the file exists, if not then use touch to create it.
141
-	if(!file_exists($filename)){
142
-		sugar_touch($filename);
143
-	}
144
-
145
-	if ( !is_writable($filename) ) {
146
-	    $GLOBALS['log']->error("File $filename cannot be written to");
147
-	    return false;
148
-	}
149
-
150
-	if(empty($flags)) {
151
-		return file_put_contents($filename, $data);
152
-	} elseif(empty($context)) {
153
-		return file_put_contents($filename, $data, $flags);
154
-	} else{
155
-		return file_put_contents($filename, $data, $flags, $context);
156
-	}
140
+    //check to see if the file exists, if not then use touch to create it.
141
+    if(!file_exists($filename)){
142
+        sugar_touch($filename);
143
+    }
144
+
145
+    if ( !is_writable($filename) ) {
146
+        $GLOBALS['log']->error("File $filename cannot be written to");
147
+        return false;
148
+    }
149
+
150
+    if(empty($flags)) {
151
+        return file_put_contents($filename, $data);
152
+    } elseif(empty($context)) {
153
+        return file_put_contents($filename, $data, $flags);
154
+    } else{
155
+        return file_put_contents($filename, $data, $flags, $context);
156
+    }
157 157
 }
158 158
 
159 159
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
     if(file_exists($filename))
200 200
     {
201
-       return sugar_chmod($filename, 0755);
201
+        return sugar_chmod($filename, 0755);
202 202
     }
203 203
 
204 204
     return false;
@@ -215,21 +215,21 @@  discard block
 block discarded – undo
215 215
  * @return string|boolean - Returns a file data on success, false otherwise
216 216
  */
217 217
 function sugar_file_get_contents($filename, $use_include_path=false, $context=null){
218
-	//check to see if the file exists, if not then use touch to create it.
219
-	if(!file_exists($filename)){
220
-		sugar_touch($filename);
221
-	}
222
-
223
-	if ( !is_readable($filename) ) {
224
-	    $GLOBALS['log']->error("File $filename cannot be read");
225
-	    return false;
226
-	}
227
-
228
-	if(empty($context)) {
229
-		return file_get_contents($filename, $use_include_path);
230
-	} else {
231
-		return file_get_contents($filename, $use_include_path, $context);
232
-	}
218
+    //check to see if the file exists, if not then use touch to create it.
219
+    if(!file_exists($filename)){
220
+        sugar_touch($filename);
221
+    }
222
+
223
+    if ( !is_readable($filename) ) {
224
+        $GLOBALS['log']->error("File $filename cannot be read");
225
+        return false;
226
+    }
227
+
228
+    if(empty($context)) {
229
+        return file_get_contents($filename, $use_include_path);
230
+    } else {
231
+        return file_get_contents($filename, $use_include_path, $context);
232
+    }
233 233
 }
234 234
 
235 235
 /**
@@ -248,31 +248,31 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function sugar_touch($filename, $time=null, $atime=null) {
250 250
 
251
-   $result = false;
252
-
253
-   if(!empty($atime) && !empty($time)) {
254
-   	  $result = @touch($filename, $time, $atime);
255
-   } else if(!empty($time)) {
256
-   	  $result = @touch($filename, $time);
257
-   } else {
258
-   	  $result = @touch($filename);
259
-   }
260
-
261
-   if(!$result) {
262
-       $GLOBALS['log']->error("File $filename cannot be touched");
263
-       return $result;
264
-   }
265
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){
266
-		sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
267
-	}
268
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
269
-		sugar_chown($filename);
270
-	}
271
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
272
-		sugar_chgrp($filename);
273
-	}
274
-
275
-   return true;
251
+    $result = false;
252
+
253
+    if(!empty($atime) && !empty($time)) {
254
+            $result = @touch($filename, $time, $atime);
255
+    } else if(!empty($time)) {
256
+            $result = @touch($filename, $time);
257
+    } else {
258
+            $result = @touch($filename);
259
+    }
260
+
261
+    if(!$result) {
262
+        $GLOBALS['log']->error("File $filename cannot be touched");
263
+        return $result;
264
+    }
265
+    if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){
266
+        sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
267
+    }
268
+    if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
269
+        sugar_chown($filename);
270
+    }
271
+    if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
272
+        sugar_chgrp($filename);
273
+    }
274
+
275
+    return true;
276 276
 }
277 277
 
278 278
 /**
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
 function sugar_chmod($filename, $mode=null) {
288 288
     if ( !is_int($mode) )
289 289
         $mode = (int) $mode;
290
-	if(!is_windows()){
291
-		if(!isset($mode)){
292
-			$mode = get_mode('file_mode', $mode);
293
-		}
290
+    if(!is_windows()){
291
+        if(!isset($mode)){
292
+            $mode = get_mode('file_mode', $mode);
293
+        }
294 294
         if(isset($mode) && $mode > 0){
295
-		   return @chmod($filename, $mode);
296
-		}else{
297
-	    	return false;
298
-		}
299
-	}
300
-	return true;
295
+            return @chmod($filename, $mode);
296
+        }else{
297
+            return false;
298
+        }
299
+    }
300
+    return true;
301 301
 }
302 302
 
303 303
 /**
@@ -310,19 +310,19 @@  discard block
 block discarded – undo
310 310
  * @return boolean - Returns TRUE on success or FALSE on failure.
311 311
  */
312 312
 function sugar_chown($filename, $user='') {
313
-	if(!is_windows()){
314
-		if(strlen($user)){
315
-			return chown($filename, $user);
316
-		}else{
317
-			if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
318
-				$user = $GLOBALS['sugar_config']['default_permissions']['user'];
319
-				return chown($filename, $user);
320
-			}else{
321
-				return false;
322
-			}
323
-		}
324
-	}
325
-	return true;
313
+    if(!is_windows()){
314
+        if(strlen($user)){
315
+            return chown($filename, $user);
316
+        }else{
317
+            if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
318
+                $user = $GLOBALS['sugar_config']['default_permissions']['user'];
319
+                return chown($filename, $user);
320
+            }else{
321
+                return false;
322
+            }
323
+        }
324
+    }
325
+    return true;
326 326
 }
327 327
 
328 328
 /**
@@ -335,19 +335,19 @@  discard block
 block discarded – undo
335 335
  * @return boolean - Returns TRUE on success or FALSE on failure.
336 336
  */
337 337
 function sugar_chgrp($filename, $group='') {
338
-	if(!is_windows()){
339
-		if(!empty($group)){
340
-			return chgrp($filename, $group);
341
-		}else{
342
-			if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
343
-				$group = $GLOBALS['sugar_config']['default_permissions']['group'];
344
-				return chgrp($filename, $group);
345
-			}else{
346
-				return false;
347
-			}
348
-		}
349
-	}
350
-	return true;
338
+    if(!is_windows()){
339
+        if(!empty($group)){
340
+            return chgrp($filename, $group);
341
+        }else{
342
+            if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
343
+                $group = $GLOBALS['sugar_config']['default_permissions']['group'];
344
+                return chgrp($filename, $group);
345
+            }else{
346
+                return false;
347
+            }
348
+        }
349
+    }
350
+    return true;
351 351
 }
352 352
 
353 353
 /**
@@ -361,26 +361,26 @@  discard block
 block discarded – undo
361 361
  * @return int - the mode either found in the config file or passed in via the input parameter
362 362
  */
363 363
 function get_mode($key = 'dir_mode', $mode=null) {
364
-	if ( !is_int($mode) )
364
+    if ( !is_int($mode) )
365 365
         $mode = (int) $mode;
366 366
     if(!class_exists('SugarConfig', true)) {
367
-		require 'include/SugarObjects/SugarConfig.php';
368
-	}
369
-	if(!is_windows()){
370
-		$conf_inst=SugarConfig::getInstance();
371
-		$mode = $conf_inst->get('default_permissions.'.$key, $mode);
372
-	}
373
-	return $mode;
367
+        require 'include/SugarObjects/SugarConfig.php';
368
+    }
369
+    if(!is_windows()){
370
+        $conf_inst=SugarConfig::getInstance();
371
+        $mode = $conf_inst->get('default_permissions.'.$key, $mode);
372
+    }
373
+    return $mode;
374 374
 }
375 375
 
376 376
 function sugar_is_dir($path, $mode='r'){
377
-		if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
378
-		return is_dir($path);
377
+        if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
378
+        return is_dir($path);
379 379
 }
380 380
 
381 381
 function sugar_is_file($path, $mode='r'){
382
-		if(defined('TEMPLATE_URL'))return is_file($path, $mode);
383
-		return is_file($path);
382
+        if(defined('TEMPLATE_URL'))return is_file($path, $mode);
383
+        return is_file($path);
384 384
 }
385 385
 
386 386
 /**
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -53,39 +53,39 @@  discard block
 block discarded – undo
53 53
  * @param $context
54 54
  * @return boolean - Returns true on success false on failure
55 55
  */
56
-function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') {
56
+function sugar_mkdir($pathname, $mode = null, $recursive = false, $context = '') {
57 57
 	$mode = get_mode('dir_mode', $mode);
58 58
 
59
-	if ( sugar_is_dir($pathname,$mode) )
59
+	if (sugar_is_dir($pathname, $mode))
60 60
 	    return true;
61 61
 
62 62
 	$result = false;
63
-	if(empty($mode))
63
+	if (empty($mode))
64 64
 		$mode = 0777;
65
-	if(empty($context)) {
65
+	if (empty($context)) {
66 66
 		$result = @mkdir($pathname, $mode, $recursive);
67 67
 	} else {
68 68
 		$result = @mkdir($pathname, $mode, $recursive, $context);
69 69
 	}
70 70
 
71
-	if($result){
72
-		if(!sugar_chmod($pathname, $mode)){
71
+	if ($result) {
72
+		if (!sugar_chmod($pathname, $mode)) {
73 73
 			return false;
74 74
 		}
75
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
76
-			if(!sugar_chown($pathname)){
75
+		if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
76
+			if (!sugar_chown($pathname)) {
77 77
 				return false;
78 78
 			}
79 79
 		}
80
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
81
-   			if(!sugar_chgrp($pathname)) {
80
+		if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
81
+   			if (!sugar_chgrp($pathname)) {
82 82
    				return false;
83 83
    			}
84 84
 		}
85 85
 	}
86 86
 	else {
87 87
 		$errorMessage = "Cannot create directory $pathname cannot be touched";
88
-		if(is_null($GLOBALS['log'])) {
88
+		if (is_null($GLOBALS['log'])) {
89 89
 			throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
90 90
 		}
91 91
 		$GLOBALS['log']->error($errorMessage);
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
  * @param $context
109 109
  * @return boolean - Returns a file pointer on success, false otherwise
110 110
  */
111
-function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){
111
+function sugar_fopen($filename, $mode, $use_include_path = false, $context = null) {
112 112
 	//check to see if the file exists, if not then use touch to create it.
113
-	if(!file_exists($filename)){
113
+	if (!file_exists($filename)) {
114 114
 		sugar_touch($filename);
115 115
 	}
116 116
 
117
-	if(empty($context)) {
117
+	if (empty($context)) {
118 118
 
119 119
 		return fopen($filename, $mode, $use_include_path);
120 120
 	} else {
@@ -136,22 +136,22 @@  discard block
 block discarded – undo
136 136
  * @param $context
137 137
  * @return int - Returns the number of bytes written to the file, false otherwise.
138 138
  */
139
-function sugar_file_put_contents($filename, $data, $flags=null, $context=null){
139
+function sugar_file_put_contents($filename, $data, $flags = null, $context = null) {
140 140
 	//check to see if the file exists, if not then use touch to create it.
141
-	if(!file_exists($filename)){
141
+	if (!file_exists($filename)) {
142 142
 		sugar_touch($filename);
143 143
 	}
144 144
 
145
-	if ( !is_writable($filename) ) {
145
+	if (!is_writable($filename)) {
146 146
 	    $GLOBALS['log']->error("File $filename cannot be written to");
147 147
 	    return false;
148 148
 	}
149 149
 
150
-	if(empty($flags)) {
150
+	if (empty($flags)) {
151 151
 		return file_put_contents($filename, $data);
152
-	} elseif(empty($context)) {
152
+	} elseif (empty($context)) {
153 153
 		return file_put_contents($filename, $data, $flags);
154
-	} else{
154
+	} else {
155 155
 		return file_put_contents($filename, $data, $flags, $context);
156 156
 	}
157 157
 }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
  * @param context $context Context to pass into fopen operation
170 170
  * @return boolean - Returns true if $filename was created, false otherwise.
171 171
  */
172
-function sugar_file_put_contents_atomic($filename, $data, $mode='wb', $use_include_path=false, $context=null){
172
+function sugar_file_put_contents_atomic($filename, $data, $mode = 'wb', $use_include_path = false, $context = null) {
173 173
 
174 174
     $dir = dirname($filename);
175 175
     $temp = tempnam($dir, 'temp');
176 176
 
177 177
     if (!($f = @fopen($temp, $mode))) {
178
-        $temp =  $dir . DIRECTORY_SEPARATOR . uniqid('temp');
178
+        $temp = $dir.DIRECTORY_SEPARATOR.uniqid('temp');
179 179
         if (!($f = @fopen($temp, $mode))) {
180 180
             trigger_error("sugar_file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING);
181 181
             return false;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         }
197 197
     }
198 198
 
199
-    if(file_exists($filename))
199
+    if (file_exists($filename))
200 200
     {
201 201
        return sugar_chmod($filename, 0755);
202 202
     }
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
  * @param $context
215 215
  * @return string|boolean - Returns a file data on success, false otherwise
216 216
  */
217
-function sugar_file_get_contents($filename, $use_include_path=false, $context=null){
217
+function sugar_file_get_contents($filename, $use_include_path = false, $context = null) {
218 218
 	//check to see if the file exists, if not then use touch to create it.
219
-	if(!file_exists($filename)){
219
+	if (!file_exists($filename)) {
220 220
 		sugar_touch($filename);
221 221
 	}
222 222
 
223
-	if ( !is_readable($filename) ) {
223
+	if (!is_readable($filename)) {
224 224
 	    $GLOBALS['log']->error("File $filename cannot be read");
225 225
 	    return false;
226 226
 	}
227 227
 
228
-	if(empty($context)) {
228
+	if (empty($context)) {
229 229
 		return file_get_contents($filename, $use_include_path);
230 230
 	} else {
231 231
 		return file_get_contents($filename, $use_include_path, $context);
@@ -246,29 +246,29 @@  discard block
 block discarded – undo
246 246
  * @return boolean - Returns TRUE on success or FALSE on failure.
247 247
  *
248 248
  */
249
-function sugar_touch($filename, $time=null, $atime=null) {
249
+function sugar_touch($filename, $time = null, $atime = null) {
250 250
 
251 251
    $result = false;
252 252
 
253
-   if(!empty($atime) && !empty($time)) {
253
+   if (!empty($atime) && !empty($time)) {
254 254
    	  $result = @touch($filename, $time, $atime);
255
-   } else if(!empty($time)) {
255
+   } else if (!empty($time)) {
256 256
    	  $result = @touch($filename, $time);
257 257
    } else {
258 258
    	  $result = @touch($filename);
259 259
    }
260 260
 
261
-   if(!$result) {
261
+   if (!$result) {
262 262
        $GLOBALS['log']->error("File $filename cannot be touched");
263 263
        return $result;
264 264
    }
265
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){
265
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])) {
266 266
 		sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
267 267
 	}
268
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
268
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
269 269
 		sugar_chown($filename);
270 270
 	}
271
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
271
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
272 272
 		sugar_chgrp($filename);
273 273
 	}
274 274
 
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
  * @param  int $mode The integer value of the permissions mode to set the created directory to
285 285
  * @return boolean   Returns TRUE on success or FALSE on failure.
286 286
  */
287
-function sugar_chmod($filename, $mode=null) {
288
-    if ( !is_int($mode) )
289
-        $mode = (int) $mode;
290
-	if(!is_windows()){
291
-		if(!isset($mode)){
287
+function sugar_chmod($filename, $mode = null) {
288
+    if (!is_int($mode))
289
+        $mode = (int)$mode;
290
+	if (!is_windows()) {
291
+		if (!isset($mode)) {
292 292
 			$mode = get_mode('file_mode', $mode);
293 293
 		}
294
-        if(isset($mode) && $mode > 0){
294
+        if (isset($mode) && $mode > 0) {
295 295
 		   return @chmod($filename, $mode);
296
-		}else{
296
+		} else {
297 297
 	    	return false;
298 298
 		}
299 299
 	}
@@ -309,15 +309,15 @@  discard block
 block discarded – undo
309 309
  * @param user - A user name or number
310 310
  * @return boolean - Returns TRUE on success or FALSE on failure.
311 311
  */
312
-function sugar_chown($filename, $user='') {
313
-	if(!is_windows()){
314
-		if(strlen($user)){
312
+function sugar_chown($filename, $user = '') {
313
+	if (!is_windows()) {
314
+		if (strlen($user)) {
315 315
 			return chown($filename, $user);
316
-		}else{
317
-			if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
316
+		} else {
317
+			if (strlen($GLOBALS['sugar_config']['default_permissions']['user'])) {
318 318
 				$user = $GLOBALS['sugar_config']['default_permissions']['user'];
319 319
 				return chown($filename, $user);
320
-			}else{
320
+			} else {
321 321
 				return false;
322 322
 			}
323 323
 		}
@@ -334,15 +334,15 @@  discard block
 block discarded – undo
334 334
  * @param group - A group name or number
335 335
  * @return boolean - Returns TRUE on success or FALSE on failure.
336 336
  */
337
-function sugar_chgrp($filename, $group='') {
338
-	if(!is_windows()){
339
-		if(!empty($group)){
337
+function sugar_chgrp($filename, $group = '') {
338
+	if (!is_windows()) {
339
+		if (!empty($group)) {
340 340
 			return chgrp($filename, $group);
341
-		}else{
342
-			if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
341
+		} else {
342
+			if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
343 343
 				$group = $GLOBALS['sugar_config']['default_permissions']['group'];
344 344
 				return chgrp($filename, $group);
345
-			}else{
345
+			} else {
346 346
 				return false;
347 347
 			}
348 348
 		}
@@ -360,26 +360,26 @@  discard block
 block discarded – undo
360 360
  * defined in the config file.
361 361
  * @return int - the mode either found in the config file or passed in via the input parameter
362 362
  */
363
-function get_mode($key = 'dir_mode', $mode=null) {
364
-	if ( !is_int($mode) )
365
-        $mode = (int) $mode;
366
-    if(!class_exists('SugarConfig', true)) {
363
+function get_mode($key = 'dir_mode', $mode = null) {
364
+	if (!is_int($mode))
365
+        $mode = (int)$mode;
366
+    if (!class_exists('SugarConfig', true)) {
367 367
 		require 'include/SugarObjects/SugarConfig.php';
368 368
 	}
369
-	if(!is_windows()){
370
-		$conf_inst=SugarConfig::getInstance();
369
+	if (!is_windows()) {
370
+		$conf_inst = SugarConfig::getInstance();
371 371
 		$mode = $conf_inst->get('default_permissions.'.$key, $mode);
372 372
 	}
373 373
 	return $mode;
374 374
 }
375 375
 
376
-function sugar_is_dir($path, $mode='r'){
377
-		if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
376
+function sugar_is_dir($path, $mode = 'r') {
377
+		if (defined('TEMPLATE_URL'))return is_dir($path, $mode);
378 378
 		return is_dir($path);
379 379
 }
380 380
 
381
-function sugar_is_file($path, $mode='r'){
382
-		if(defined('TEMPLATE_URL'))return is_file($path, $mode);
381
+function sugar_is_file($path, $mode = 'r') {
382
+		if (defined('TEMPLATE_URL'))return is_file($path, $mode);
383 383
 		return is_file($path);
384 384
 }
385 385
 
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 function sugar_cached($file)
392 392
 {
393 393
     static $cdir = null;
394
-    if(empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
394
+    if (empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
395 395
         $cdir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
396 396
     }
397
-    if(empty($cdir)) {
397
+    if (empty($cdir)) {
398 398
         $cdir = "cache";
399 399
     }
400 400
     return "$cdir/$file";
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 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.
@@ -56,12 +58,14 @@  discard block
 block discarded – undo
56 58
 function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') {
57 59
 	$mode = get_mode('dir_mode', $mode);
58 60
 
59
-	if ( sugar_is_dir($pathname,$mode) )
60
-	    return true;
61
+	if ( sugar_is_dir($pathname,$mode) ) {
62
+		    return true;
63
+	}
61 64
 
62 65
 	$result = false;
63
-	if(empty($mode))
64
-		$mode = 0777;
66
+	if(empty($mode)) {
67
+			$mode = 0777;
68
+	}
65 69
 	if(empty($context)) {
66 70
 		$result = @mkdir($pathname, $mode, $recursive);
67 71
 	} else {
@@ -82,8 +86,7 @@  discard block
 block discarded – undo
82 86
    				return false;
83 87
    			}
84 88
 		}
85
-	}
86
-	else {
89
+	} else {
87 90
 		$errorMessage = "Cannot create directory $pathname cannot be touched";
88 91
 		if(is_null($GLOBALS['log'])) {
89 92
 			throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
@@ -285,15 +288,16 @@  discard block
 block discarded – undo
285 288
  * @return boolean   Returns TRUE on success or FALSE on failure.
286 289
  */
287 290
 function sugar_chmod($filename, $mode=null) {
288
-    if ( !is_int($mode) )
289
-        $mode = (int) $mode;
291
+    if ( !is_int($mode) ) {
292
+            $mode = (int) $mode;
293
+    }
290 294
 	if(!is_windows()){
291 295
 		if(!isset($mode)){
292 296
 			$mode = get_mode('file_mode', $mode);
293 297
 		}
294 298
         if(isset($mode) && $mode > 0){
295 299
 		   return @chmod($filename, $mode);
296
-		}else{
300
+		} else{
297 301
 	    	return false;
298 302
 		}
299 303
 	}
@@ -313,11 +317,11 @@  discard block
 block discarded – undo
313 317
 	if(!is_windows()){
314 318
 		if(strlen($user)){
315 319
 			return chown($filename, $user);
316
-		}else{
320
+		} else{
317 321
 			if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
318 322
 				$user = $GLOBALS['sugar_config']['default_permissions']['user'];
319 323
 				return chown($filename, $user);
320
-			}else{
324
+			} else{
321 325
 				return false;
322 326
 			}
323 327
 		}
@@ -338,11 +342,11 @@  discard block
 block discarded – undo
338 342
 	if(!is_windows()){
339 343
 		if(!empty($group)){
340 344
 			return chgrp($filename, $group);
341
-		}else{
345
+		} else{
342 346
 			if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
343 347
 				$group = $GLOBALS['sugar_config']['default_permissions']['group'];
344 348
 				return chgrp($filename, $group);
345
-			}else{
349
+			} else{
346 350
 				return false;
347 351
 			}
348 352
 		}
@@ -361,8 +365,9 @@  discard block
 block discarded – undo
361 365
  * @return int - the mode either found in the config file or passed in via the input parameter
362 366
  */
363 367
 function get_mode($key = 'dir_mode', $mode=null) {
364
-	if ( !is_int($mode) )
365
-        $mode = (int) $mode;
368
+	if ( !is_int($mode) ) {
369
+	        $mode = (int) $mode;
370
+	}
366 371
     if(!class_exists('SugarConfig', true)) {
367 372
 		require 'include/SugarObjects/SugarConfig.php';
368 373
 	}
@@ -374,12 +379,16 @@  discard block
 block discarded – undo
374 379
 }
375 380
 
376 381
 function sugar_is_dir($path, $mode='r'){
377
-		if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
382
+		if(defined('TEMPLATE_URL')) {
383
+		    return is_dir($path, $mode);
384
+		}
378 385
 		return is_dir($path);
379 386
 }
380 387
 
381 388
 function sugar_is_file($path, $mode='r'){
382
-		if(defined('TEMPLATE_URL'))return is_file($path, $mode);
389
+		if(defined('TEMPLATE_URL')) {
390
+		    return is_file($path, $mode);
391
+		}
383 392
 		return is_file($path);
384 393
 }
385 394
 
Please login to merge, or discard this patch.
Doc Comments   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  * 0777 by default.
49 49
  *
50 50
  * @param $pathname - String value of the directory to create
51
- * @param $mode - The integer value of the permissions mode to set the created directory to
51
+ * @param integer $mode - The integer value of the permissions mode to set the created directory to
52 52
  * @param $recursive - boolean value indicating whether or not to create recursive directories if needed
53 53
  * @param $context
54 54
  * @return boolean - Returns true on success false on failure
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
  * 0777 by default.
104 104
  *
105 105
  * @param $filename - String value of the file to create
106
- * @param $mode - The integer value of the permissions mode to set the created file to
106
+ * @param string $mode - The integer value of the permissions mode to set the created file to
107 107
  * @param $$use_include_path - boolean value indicating whether or not to search the the included_path
108 108
  * @param $context
109
- * @return boolean - Returns a file pointer on success, false otherwise
109
+ * @return resource - Returns a file pointer on success, false otherwise
110 110
  */
111 111
 function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){
112 112
 	//check to see if the file exists, if not then use touch to create it.
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @param $filename - String value of the file to create
134 134
  * @param $data - The data to be written to the file
135
- * @param $flags - int as specifed by file_put_contents parameters
135
+ * @param integer $flags - int as specifed by file_put_contents parameters
136 136
  * @param $context
137 137
  * @return int - Returns the number of bytes written to the file, false otherwise.
138 138
  */
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
  * This is an atomic version of sugar_file_put_contents.  It attempts to circumvent the shortcomings of file_put_contents
163 163
  * by creating a temporary unique file and then doing an atomic rename operation.
164 164
  *
165
- * @param $filename - String value of the file to create
166
- * @param $data - The data to be written to the file
165
+ * @param string $filename - String value of the file to create
166
+ * @param string $data - The data to be written to the file
167 167
  * @param string $mode String value of the parameter to specify the type of access you require to the file stream
168 168
  * @param boolean $use_include_path set to '1' or TRUE if you want to search for the file in the include_path too
169 169
  * @param context $context Context to pass into fopen operation
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
  * @param $filename - String value of the file to create
213 213
  * @param $use_include_path - boolean value indicating whether or not to search the the included_path
214 214
  * @param $context
215
- * @return string|boolean - Returns a file data on success, false otherwise
215
+ * @return false|string - Returns a file data on success, false otherwise
216 216
  */
217 217
 function sugar_file_get_contents($filename, $use_include_path=false, $context=null){
218 218
 	//check to see if the file exists, if not then use touch to create it.
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * may be set with the permissions specified in the configuration file (if set).
242 242
  *
243 243
  * @param $filename - The name of the file being touched.
244
- * @param $time - The touch time. If time  is not supplied, the current system time is used.
244
+ * @param integer $time - The touch time. If time  is not supplied, the current system time is used.
245 245
  * @param $atime - If present, the access time of the given filename is set to the value of atime
246 246
  * @return boolean - Returns TRUE on success or FALSE on failure.
247 247
  *
Please login to merge, or discard this patch.
include/TemplateHandler/TemplateHandler.php 4 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     var $templateDir = 'modules/';
51 51
     var $ss;
52 52
     function TemplateHandler() {
53
-      $this->cacheDir = sugar_cached('');
53
+        $this->cacheDir = sugar_cached('');
54 54
     }
55 55
 
56 56
     function loadSmarty(){
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
      *
67 67
      */
68 68
     static function clearAll() {
69
-    	global $beanList;
70
-		foreach($beanList as $module_dir =>$object_name){
69
+        global $beanList;
70
+        foreach($beanList as $module_dir =>$object_name){
71 71
                 TemplateHandler::clearCache($module_dir);
72
-		}
72
+        }
73 73
     }
74 74
 
75 75
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                     foreach($panel as $row) {
133 133
                             foreach($row as $entry) {
134 134
                                     if(empty($entry)) {
135
-                                       continue;
135
+                                        continue;
136 136
                                     }
137 137
 
138 138
                                     if(is_array($entry) &&
@@ -140,35 +140,35 @@  discard block
 block discarded – undo
140 140
                                        isset($entry['displayParams']) &&
141 141
                                        isset($entry['displayParams']['required']) &&
142 142
                                        $entry['displayParams']['required']) {
143
-                                       $panelFields[$entry['name']] = $entry;
143
+                                        $panelFields[$entry['name']] = $entry;
144 144
                                     }
145 145
 
146 146
                                     if(is_array($entry)) {
147
-                                      $defs2[$entry['name']] = $entry;
147
+                                        $defs2[$entry['name']] = $entry;
148 148
                                     } else {
149
-                                      $defs2[$entry] = array('name' => $entry);
149
+                                        $defs2[$entry] = array('name' => $entry);
150 150
                                     }
151 151
                             } //foreach
152 152
                     } //foreach
153 153
             } //foreach
154 154
 
155 155
             foreach($panelFields as $field=>$value) {
156
-                      $nameList = array();
157
-                      if(!is_array($value['displayParams']['required'])) {
158
-                         $nameList[] = $field;
159
-                      } else {
160
-                         foreach($value['displayParams']['required'] as $groupedField) {
161
-                                 $nameList[] = $groupedField;
162
-                         }
163
-                      }
164
-
165
-                      foreach($nameList as $x) {
166
-                         if(isset($defs[$x]) &&
156
+                        $nameList = array();
157
+                        if(!is_array($value['displayParams']['required'])) {
158
+                            $nameList[] = $field;
159
+                        } else {
160
+                            foreach($value['displayParams']['required'] as $groupedField) {
161
+                                    $nameList[] = $groupedField;
162
+                            }
163
+                        }
164
+
165
+                        foreach($nameList as $x) {
166
+                            if(isset($defs[$x]) &&
167 167
                             isset($defs[$x]['type']) &&
168 168
                             !isset($defs[$x]['required'])) {
169 169
                             $defs[$x]['required'] = true;
170
-                         }
171
-                      }
170
+                            }
171
+                        }
172 172
             } //foreach
173 173
 
174 174
             //Create a base class with field_name_map property
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
             //5) not already been added to Array
196 196
             foreach($sugarbean->field_name_map as $name=>$def) {
197 197
 
198
-               if($def['type']=='relate' &&
198
+                if($def['type']=='relate' &&
199 199
                   isset($defs2[$name]) &&
200 200
                   (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) &&
201 201
                   isset($def['id_name']) &&
202 202
                   !in_array($name, $validatedFields)) {
203 203
 
204
-                  if(isset($mod_strings[$def['vname']])
204
+                    if(isset($mod_strings[$def['vname']])
205 205
                         || isset($app_strings[$def['vname']])
206 206
                         || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
207
-                     $vname = $def['vname'];
208
-                  }
209
-                  else{
210
-                     $vname = "undefined";
211
-                  }
212
-                  $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
213
-                  $validatedFields[] = $name;
214
-               }
207
+                        $vname = $def['vname'];
208
+                    }
209
+                    else{
210
+                        $vname = "undefined";
211
+                    }
212
+                    $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
213
+                    $validatedFields[] = $name;
214
+                }
215 215
             } //foreach
216 216
 
217 217
             $contents .= "{literal}\n";
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
         }
276 276
         $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
277 277
         if(file_exists($file)) {
278
-           return $this->ss->fetch($file);
278
+            return $this->ss->fetch($file);
279 279
         } else {
280
-           global $app_strings;
281
-           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
282
-           return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
280
+            global $app_strings;
281
+            $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
282
+            return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
283 283
         }
284 284
     }
285 285
 
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
         }
330 330
         $qsd->setFormName($view);
331 331
         if(preg_match('/^SearchForm_.+/', $view)){
332
-        	if(strpos($view, 'popup_query_form')){
333
-        		$qsd->setFormName('popup_query_form');
334
-            	$parsedView = 'advanced';
335
-        	}else{
336
-        		$qsd->setFormName('search_form');
337
-            	$parsedView = preg_replace("/^SearchForm_/", "", $view);
338
-        	}
332
+            if(strpos($view, 'popup_query_form')){
333
+                $qsd->setFormName('popup_query_form');
334
+                $parsedView = 'advanced';
335
+            }else{
336
+                $qsd->setFormName('search_form');
337
+                $parsedView = preg_replace("/^SearchForm_/", "", $view);
338
+            }
339 339
             //Loop through the Meta-Data fields to see which ones need quick search support
340 340
             foreach($defs as $f) {
341 341
                 $field = $f;
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
374 374
                         }
375 375
                     } else {
376
-                         $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
377
-                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
378
-                             $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
379
-                             $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
380
-                         } else {
381
-                             $sqs_objects[$name.'_'.$parsedView]['populate_list'] = $field['field_list'];
382
-                             $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
383
-                         }
376
+                            $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
377
+                            if(!isset($field['field_list']) && !isset($field['populate_list'])) {
378
+                                $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
379
+                                $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
380
+                            } else {
381
+                                $sqs_objects[$name.'_'.$parsedView]['populate_list'] = $field['field_list'];
382
+                                $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
383
+                            }
384 384
                     }
385 385
                 } else if($field['type'] == 'parent') {
386 386
                     $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent();
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             } //foreach
389 389
 
390 390
             foreach ( $sqs_objects as $name => $field )
391
-               foreach ( $field['populate_list'] as $key => $fieldname )
391
+                foreach ( $field['populate_list'] as $key => $fieldname )
392 392
                     $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
393 393
         }else{
394 394
             //Loop through the Meta-Data fields to see which ones need quick search support
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                             $field['id_name'] = $module.$field['id_name'];
414 414
                     }
415 415
                 }
416
-				$name = $qsd->form_name . '_' . $field['name'];
416
+                $name = $qsd->form_name . '_' . $field['name'];
417 417
 
418 418
 
419 419
                 if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) {
@@ -427,15 +427,15 @@  discard block
 block discarded – undo
427 427
                         } else if($matches[0] == 'Users'){
428 428
                             if($field['name'] == 'reports_to_name'){
429 429
                                 $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
430
-                             // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
430
+                                // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
431 431
                             }elseif($field['name'] == 'assigned_user_name'){
432
-                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
433
-                             }
434
-                             else
435
-                             {
436
-                                 $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
432
+                                    $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
433
+                                }
434
+                                else
435
+                                {
436
+                                    $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
437 437
 
438
-							}
438
+                            }
439 439
                         } else if($matches[0] == 'Campaigns') {
440 440
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
441 441
                         } else if($matches[0] == 'Accounts') {
@@ -486,39 +486,39 @@  discard block
 block discarded – undo
486 486
                 //merge populate_list && field_list with vardef
487 487
                 if (!empty($field['field_list']) && !empty($field['populate_list'])) {
488 488
                     for ($j=0; $j<count($field['field_list']); $j++) {
489
-                		//search for the same couple (field_list_item,populate_field_item)
490
-               			$field_list_item = $field['field_list'][$j];
491
-               			$field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
492
-               			$populate_list_item = $field['populate_list'][$j];
493
-                		$found = false;
494
-                		for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
495
-                			if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
496
-                				$populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
497
-                				$found = true;
498
-                				break;
499
-                			}
500
-                		}
501
-                		if (!$found) {
502
-                			$sqs_objects[$name]['field_list'][] = $field['populate_list'][$j]; // as in lines 462 and 463
503
-                			$sqs_objects[$name]['populate_list'][] = $field['field_list'][$j];
504
-                		}
505
-                	}
489
+                        //search for the same couple (field_list_item,populate_field_item)
490
+                            $field_list_item = $field['field_list'][$j];
491
+                            $field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
492
+                            $populate_list_item = $field['populate_list'][$j];
493
+                        $found = false;
494
+                        for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
495
+                            if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
496
+                                $populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
497
+                                $found = true;
498
+                                break;
499
+                            }
500
+                        }
501
+                        if (!$found) {
502
+                            $sqs_objects[$name]['field_list'][] = $field['populate_list'][$j]; // as in lines 462 and 463
503
+                            $sqs_objects[$name]['populate_list'][] = $field['field_list'][$j];
504
+                        }
505
+                    }
506 506
                 }
507 507
 
508 508
             } //foreach
509 509
         }
510 510
 
511
-       //Implement QuickSearch for the field
512
-       if(!empty($sqs_objects) && count($sqs_objects) > 0) {
513
-           $quicksearch_js = '<script language="javascript">';
514
-           $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
515
-           $json = getJSONobj();
516
-           foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
517
-               $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
518
-           }
519
-           return $quicksearch_js . '</script>';
520
-       }
521
-       return '';
511
+        //Implement QuickSearch for the field
512
+        if(!empty($sqs_objects) && count($sqs_objects) > 0) {
513
+            $quicksearch_js = '<script language="javascript">';
514
+            $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
515
+            $json = getJSONobj();
516
+            foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
517
+                $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
518
+            }
519
+            return $quicksearch_js . '</script>';
520
+        }
521
+        return '';
522 522
     }
523 523
 
524 524
     
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
       $this->cacheDir = sugar_cached('');
54 54
     }
55 55
 
56
-    function loadSmarty(){
57
-        if(empty($this->ss)){
56
+    function loadSmarty() {
57
+        if (empty($this->ss)) {
58 58
             $this->ss = new Sugar_Smarty();
59 59
         }
60 60
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     static function clearAll() {
69 69
     	global $beanList;
70
-		foreach($beanList as $module_dir =>$object_name){
70
+		foreach ($beanList as $module_dir =>$object_name) {
71 71
                 TemplateHandler::clearCache($module_dir);
72 72
 		}
73 73
     }
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
      * @param String $module The module directory to clear
81 81
      * @param String $view Optional view value (DetailView, EditView, etc.)
82 82
      */
83
-    static function clearCache($module, $view=''){
84
-        $cacheDir = create_cache_directory('modules/'. $module . '/');
83
+    static function clearCache($module, $view = '') {
84
+        $cacheDir = create_cache_directory('modules/'.$module.'/');
85 85
         $d = dir($cacheDir);
86
-        while($e = $d->read()){
87
-            if(!empty($view) && $e != $view )continue;
88
-            $end =strlen($e) - 4;
89
-            if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
90
-                unlink($cacheDir . $e);
86
+        while ($e = $d->read()) {
87
+            if (!empty($view) && $e != $view)continue;
88
+            $end = strlen($e) - 4;
89
+            if (is_file($cacheDir.$e) && $end > 1 && substr($e, $end) == '.tpl') {
90
+                unlink($cacheDir.$e);
91 91
             }
92 92
         }
93 93
     }
@@ -105,21 +105,21 @@  discard block
 block discarded – undo
105 105
     function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs) {
106 106
         $this->loadSmarty();
107 107
 
108
-        $cacheDir = create_cache_directory($this->templateDir. $module . '/');
109
-        $file = $cacheDir . $view . '.tpl';
110
-        $string = '{* Create Date: ' . date('Y-m-d H:i:s') . "*}\n";
108
+        $cacheDir = create_cache_directory($this->templateDir.$module.'/');
109
+        $file = $cacheDir.$view.'.tpl';
110
+        $string = '{* Create Date: '.date('Y-m-d H:i:s')."*}\n";
111 111
         $this->ss->left_delimiter = '{{';
112 112
         $this->ss->right_delimiter = '}}';
113 113
         $this->ss->assign('module', $module);
114 114
         $this->ss->assign('built_in_buttons', array('CANCEL', 'DELETE', 'DUPLICATE', 'EDIT', 'FIND_DUPLICATES', 'SAVE', 'CONNECTOR'));
115 115
         $contents = $this->ss->fetch($tpl);
116 116
         //Insert validation and quicksearch stuff here
117
-        if($view == 'EditView' || strpos($view,'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
117
+        if ($view == 'EditView' || strpos($view, 'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
118 118
 
119 119
             global $dictionary, $beanList, $app_strings, $mod_strings;
120 120
             $mod = $beanList[$module];
121 121
 
122
-            if($mod == 'aCase') {
122
+            if ($mod == 'aCase') {
123 123
                 $mod = 'Case';
124 124
             }
125 125
 
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
             //Retrieve all panel field definitions with displayParams Array field set
129 129
             $panelFields = array();
130 130
 
131
-            foreach($metaDataDefs['panels'] as $panel) {
132
-                    foreach($panel as $row) {
133
-                            foreach($row as $entry) {
134
-                                    if(empty($entry)) {
131
+            foreach ($metaDataDefs['panels'] as $panel) {
132
+                    foreach ($panel as $row) {
133
+                            foreach ($row as $entry) {
134
+                                    if (empty($entry)) {
135 135
                                        continue;
136 136
                                     }
137 137
 
138
-                                    if(is_array($entry) &&
138
+                                    if (is_array($entry) &&
139 139
                                        isset($entry['name']) &&
140 140
                                        isset($entry['displayParams']) &&
141 141
                                        isset($entry['displayParams']['required']) &&
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                                        $panelFields[$entry['name']] = $entry;
144 144
                                     }
145 145
 
146
-                                    if(is_array($entry)) {
146
+                                    if (is_array($entry)) {
147 147
                                       $defs2[$entry['name']] = $entry;
148 148
                                     } else {
149 149
                                       $defs2[$entry] = array('name' => $entry);
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
                     } //foreach
153 153
             } //foreach
154 154
 
155
-            foreach($panelFields as $field=>$value) {
155
+            foreach ($panelFields as $field=>$value) {
156 156
                       $nameList = array();
157
-                      if(!is_array($value['displayParams']['required'])) {
157
+                      if (!is_array($value['displayParams']['required'])) {
158 158
                          $nameList[] = $field;
159 159
                       } else {
160
-                         foreach($value['displayParams']['required'] as $groupedField) {
160
+                         foreach ($value['displayParams']['required'] as $groupedField) {
161 161
                                  $nameList[] = $groupedField;
162 162
                          }
163 163
                       }
164 164
 
165
-                      foreach($nameList as $x) {
166
-                         if(isset($defs[$x]) &&
165
+                      foreach ($nameList as $x) {
166
+                         if (isset($defs[$x]) &&
167 167
                             isset($defs[$x]['type']) &&
168 168
                             !isset($defs[$x]['required'])) {
169 169
                             $defs[$x]['required'] = true;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
             $javascript->setSugarBean($sugarbean);
184 184
             if ($view != "ConvertLead")
185
-                $javascript->addAllFields('', null,true);
185
+                $javascript->addAllFields('', null, true);
186 186
 
187 187
             $validatedFields = array();
188 188
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
             //3) not have validateDepedency set to false in metadata
194 194
             //4) have id_name in vardef entry
195 195
             //5) not already been added to Array
196
-            foreach($sugarbean->field_name_map as $name=>$def) {
196
+            foreach ($sugarbean->field_name_map as $name=>$def) {
197 197
 
198
-               if($def['type']=='relate' &&
198
+               if ($def['type'] == 'relate' &&
199 199
                   isset($defs2[$name]) &&
200 200
                   (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) &&
201 201
                   isset($def['id_name']) &&
202 202
                   !in_array($name, $validatedFields)) {
203 203
 
204
-                  if(isset($mod_strings[$def['vname']])
204
+                  if (isset($mod_strings[$def['vname']])
205 205
                         || isset($app_strings[$def['vname']])
206
-                        || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
206
+                        || translate($def['vname'], $sugarbean->module_dir) != $def['vname']) {
207 207
                      $vname = $def['vname'];
208 208
                   }
209
-                  else{
209
+                  else {
210 210
                      $vname = "undefined";
211 211
                   }
212 212
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
             $contents .= $javascript->getScript();
219 219
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
220 220
             $contents .= "{/literal}\n";
221
-        }else if(preg_match('/^SearchForm_.+/', $view)){
221
+        } else if (preg_match('/^SearchForm_.+/', $view)) {
222 222
             global $dictionary, $beanList, $app_strings, $mod_strings;
223 223
             $mod = $beanList[$module];
224 224
 
225
-            if($mod == 'aCase') {
225
+            if ($mod == 'aCase') {
226 226
                 $mod = 'Case';
227 227
             }
228 228
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         //Remove all the copyright comments
236 236
         $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents);
237 237
 
238
-        if($fh = @sugar_fopen($file, 'w')) {
238
+        if ($fh = @sugar_fopen($file, 'w')) {
239 239
             fputs($fh, $contents);
240 240
             fclose($fh);
241 241
         }
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
      * @param module string module name
252 252
      * @param view string view need (eg DetailView, EditView, etc)
253 253
      */
254
-    function checkTemplate($module, $view, $checkFormName = false, $formName='') {
255
-        if(inDeveloperMode() || !empty($_SESSION['developerMode'])){
254
+    function checkTemplate($module, $view, $checkFormName = false, $formName = '') {
255
+        if (inDeveloperMode() || !empty($_SESSION['developerMode'])) {
256 256
             return false;
257 257
         }
258 258
         $view = $checkFormName ? $formName : $view;
259
-        return file_exists($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
259
+        return file_exists($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
260 260
     }
261 261
 
262 262
     /**
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
      */
271 271
     function displayTemplate($module, $view, $tpl, $ajaxSave = false, $metaDataDefs = null) {
272 272
         $this->loadSmarty();
273
-        if(!$this->checkTemplate($module, $view)) {
273
+        if (!$this->checkTemplate($module, $view)) {
274 274
             $this->buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs);
275 275
         }
276
-        $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
277
-        if(file_exists($file)) {
276
+        $file = $this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl';
277
+        if (file_exists($file)) {
278 278
            return $this->ss->fetch($file);
279 279
         } else {
280 280
            global $app_strings;
281
-           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
282
-           return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
281
+           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'].": $file");
282
+           return $app_strings['ERR_NO_SUCH_FILE'].": $file";
283 283
         }
284 284
     }
285 285
 
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
      * @param view string view need (eg DetailView, EditView, etc)
291 291
      */
292 292
     function deleteTemplate($module, $view) {
293
-        if(is_file($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl')) {
293
+        if (is_file($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl')) {
294 294
             // Bug #54634 : RTC 18144 : Cannot add more than 1 user to role but popup is multi-selectable
295
-            if ( !isset($this->ss) )
295
+            if (!isset($this->ss))
296 296
             {
297 297
                 $this->loadSmarty();
298 298
             }
299
-            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
299
+            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
300 300
             SugarCache::cleanFile($cache_file_name);
301 301
 
302
-            return unlink($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
302
+            return unlink($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
303 303
         }
304 304
         return false;
305 305
     }
@@ -316,47 +316,47 @@  discard block
 block discarded – undo
316 316
      * @param strign $module
317 317
      * @return string
318 318
      */
319
-    public function createQuickSearchCode($defs, $defs2, $view = '', $module='')
319
+    public function createQuickSearchCode($defs, $defs2, $view = '', $module = '')
320 320
     {
321 321
         $sqs_objects = array();
322 322
         require_once('include/QuickSearchDefaults.php');
323
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
323
+        if (isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
324 324
         {
325 325
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
326
-        }else
326
+        } else
327 327
         {
328 328
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
329 329
         }
330 330
         $qsd->setFormName($view);
331
-        if(preg_match('/^SearchForm_.+/', $view)){
332
-        	if(strpos($view, 'popup_query_form')){
331
+        if (preg_match('/^SearchForm_.+/', $view)) {
332
+        	if (strpos($view, 'popup_query_form')) {
333 333
         		$qsd->setFormName('popup_query_form');
334 334
             	$parsedView = 'advanced';
335
-        	}else{
335
+        	} else {
336 336
         		$qsd->setFormName('search_form');
337 337
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
338 338
         	}
339 339
             //Loop through the Meta-Data fields to see which ones need quick search support
340
-            foreach($defs as $f) {
340
+            foreach ($defs as $f) {
341 341
                 $field = $f;
342
-                $name = $qsd->form_name . '_' . $field['name'];
342
+                $name = $qsd->form_name.'_'.$field['name'];
343 343
 
344
-                if($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si',$name)  || !empty($field['quicksearch']) ) {
345
-                    if(preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
344
+                if ($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch'])) {
345
+                    if (preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
346 346
 
347
-                        if($matches[0] == 'Campaigns') {
347
+                        if ($matches[0] == 'Campaigns') {
348 348
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
349
-                        } else if($matches[0] == 'Users'){
349
+                        } else if ($matches[0] == 'Users') {
350 350
 
351
-                            if(!empty($f['name']) && !empty($f['id_name'])) {
352
-                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
351
+                            if (!empty($f['name']) && !empty($f['id_name'])) {
352
+                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'], $f['id_name']);
353 353
                             }
354 354
                             else {
355 355
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
356 356
                             }
357
-                        } else if($matches[0] == 'Campaigns') {
357
+                        } else if ($matches[0] == 'Campaigns') {
358 358
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
359
-                        } else if($matches[0] == 'Accounts') {
359
+                        } else if ($matches[0] == 'Accounts') {
360 360
                             $nameKey = $name;
361 361
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
362 362
 
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
                             $shippingKey = isset($f['displayParams']['shippingKey']) ? $f['displayParams']['shippingKey'] : null;
370 370
                             $additionalFields = isset($f['displayParams']['additionalFields']) ? $f['displayParams']['additionalFields'] : null;
371 371
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
372
-                        } else if($matches[0] == 'Contacts'){
372
+                        } else if ($matches[0] == 'Contacts') {
373 373
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
374 374
                         }
375 375
                     } else {
376 376
                          $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
377
-                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
377
+                         if (!isset($field['field_list']) && !isset($field['populate_list'])) {
378 378
                              $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
379 379
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
380 380
                          } else {
@@ -382,63 +382,63 @@  discard block
 block discarded – undo
382 382
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
383 383
                          }
384 384
                     }
385
-                } else if($field['type'] == 'parent') {
385
+                } else if ($field['type'] == 'parent') {
386 386
                     $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent();
387 387
                 } //if-else
388 388
             } //foreach
389 389
 
390
-            foreach ( $sqs_objects as $name => $field )
391
-               foreach ( $field['populate_list'] as $key => $fieldname )
392
-                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
393
-        }else{
390
+            foreach ($sqs_objects as $name => $field)
391
+               foreach ($field['populate_list'] as $key => $fieldname)
392
+                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key].'_'.$parsedView;
393
+        } else {
394 394
             //Loop through the Meta-Data fields to see which ones need quick search support
395
-            foreach($defs2 as $f) {
396
-                if(!isset($defs[$f['name']])) continue;
395
+            foreach ($defs2 as $f) {
396
+                if (!isset($defs[$f['name']])) continue;
397 397
 
398 398
                 $field = $defs[$f['name']];
399 399
                 if ($view == "ConvertLead")
400 400
                 {
401
-                    $field['name'] = $module . $field['name'];
401
+                    $field['name'] = $module.$field['name'];
402 402
                     if (isset($field['module']) && isset($field['id_name']) && substr($field['id_name'], -4) == "_ida") {
403 403
                         $lc_module = strtolower($field['module']);
404 404
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
405 405
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
406
-                            $field['id_name'] = $module . $field['id_name'];
406
+                            $field['id_name'] = $module.$field['id_name'];
407 407
                         }
408 408
                         else
409
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
409
+                            $field['id_name'] = $field['name']."_".$field['id_name'];
410 410
                     }
411 411
                     else {
412 412
                         if (!empty($field['id_name']))
413 413
                             $field['id_name'] = $module.$field['id_name'];
414 414
                     }
415 415
                 }
416
-				$name = $qsd->form_name . '_' . $field['name'];
416
+				$name = $qsd->form_name.'_'.$field['name'];
417 417
 
418 418
 
419
-                if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) {
420
-                    if (!preg_match('/_c$/si',$name)
421
-                        && (!isset($field['id_name']) || !preg_match('/_c$/si',$field['id_name']))
419
+                if ($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch']))) {
420
+                    if (!preg_match('/_c$/si', $name)
421
+                        && (!isset($field['id_name']) || !preg_match('/_c$/si', $field['id_name']))
422 422
                         && preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)
423 423
                     ) {
424 424
 
425
-                        if($matches[0] == 'Campaigns') {
425
+                        if ($matches[0] == 'Campaigns') {
426 426
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
427
-                        } else if($matches[0] == 'Users'){
428
-                            if($field['name'] == 'reports_to_name'){
429
-                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
427
+                        } else if ($matches[0] == 'Users') {
428
+                            if ($field['name'] == 'reports_to_name') {
429
+                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name', 'reports_to_id');
430 430
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
431
-                            }elseif($field['name'] == 'assigned_user_name'){
432
-                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
431
+                            }elseif ($field['name'] == 'assigned_user_name') {
432
+                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name', 'assigned_user_id');
433 433
                              }
434 434
                              else
435 435
                              {
436 436
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
437 437
 
438 438
 							}
439
-                        } else if($matches[0] == 'Campaigns') {
439
+                        } else if ($matches[0] == 'Campaigns') {
440 440
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
441
-                        } else if($matches[0] == 'Accounts') {
441
+                        } else if ($matches[0] == 'Accounts') {
442 442
                             $nameKey = $name;
443 443
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
444 444
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
                             $shippingKey = SugarArray::staticGet($f, 'displayParams.shippingKey');
452 452
                             $additionalFields = SugarArray::staticGet($f, 'displayParams.additionalFields');
453 453
                             $sqs_objects[$name] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
454
-                        } else if($matches[0] == 'Contacts'){
454
+                        } else if ($matches[0] == 'Contacts') {
455 455
                             $sqs_objects[$name] = $qsd->getQSContact($field['name'], $field['id_name']);
456
-                            if(preg_match('/_c$/si',$name) || !empty($field['quicksearch'])){
456
+                            if (preg_match('/_c$/si', $name) || !empty($field['quicksearch'])) {
457 457
                                 $sqs_objects[$name]['field_list'] = array('salutation', 'first_name', 'last_name', 'id');
458 458
                             }
459 459
                         }
460 460
                     } else {
461 461
                         $sqs_objects[$name] = $qsd->getQSParent($field['module']);
462
-                        if(!isset($field['field_list']) && !isset($field['populate_list'])) {
462
+                        if (!isset($field['field_list']) && !isset($field['populate_list'])) {
463 463
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
464 464
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
465 465
                             if (!isset($field['rname']))
@@ -468,14 +468,14 @@  discard block
 block discarded – undo
468 468
                             {
469 469
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
470 470
                                 $sqs_objects[$name]['order'] = $field['rname'];
471
-                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'],'op'=>'like_custom','end'=>'%','value'=>''));
471
+                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'], 'op'=>'like_custom', 'end'=>'%', 'value'=>''));
472 472
                             }
473 473
                         } else {
474 474
                             $sqs_objects[$name]['populate_list'] = $field['field_list'];
475 475
                             $sqs_objects[$name]['field_list'] = $field['populate_list'];
476 476
                         }
477 477
                     }
478
-                } else if($field['type'] == 'parent') {
478
+                } else if ($field['type'] == 'parent') {
479 479
                     $sqs_objects[$name] = $qsd->getQSParent();
480 480
                 } //if-else
481 481
 
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
 
486 486
                 //merge populate_list && field_list with vardef
487 487
                 if (!empty($field['field_list']) && !empty($field['populate_list'])) {
488
-                    for ($j=0; $j<count($field['field_list']); $j++) {
488
+                    for ($j = 0; $j < count($field['field_list']); $j++) {
489 489
                 		//search for the same couple (field_list_item,populate_field_item)
490 490
                			$field_list_item = $field['field_list'][$j];
491
-               			$field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
491
+               			$field_list_item_alternate = $qsd->form_name.'_'.$field['field_list'][$j];
492 492
                			$populate_list_item = $field['populate_list'][$j];
493 493
                 		$found = false;
494
-                		for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
494
+                		for ($k = 0; $k < count($sqs_objects[$name]['field_list']); $k++) {
495 495
                 			if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
496 496
                 				$populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
497 497
                 				$found = true;
@@ -509,14 +509,14 @@  discard block
 block discarded – undo
509 509
         }
510 510
 
511 511
        //Implement QuickSearch for the field
512
-       if(!empty($sqs_objects) && count($sqs_objects) > 0) {
512
+       if (!empty($sqs_objects) && count($sqs_objects) > 0) {
513 513
            $quicksearch_js = '<script language="javascript">';
514
-           $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
514
+           $quicksearch_js .= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
515 515
            $json = getJSONobj();
516
-           foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
516
+           foreach ($sqs_objects as $sqsfield=>$sqsfieldArray) {
517 517
                $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
518 518
            }
519
-           return $quicksearch_js . '</script>';
519
+           return $quicksearch_js.'</script>';
520 520
        }
521 521
        return '';
522 522
     }
Please login to merge, or discard this patch.
Braces   +32 added lines, -27 removed lines patch added patch discarded remove patch
@@ -84,7 +84,9 @@  discard block
 block discarded – undo
84 84
         $cacheDir = create_cache_directory('modules/'. $module . '/');
85 85
         $d = dir($cacheDir);
86 86
         while($e = $d->read()){
87
-            if(!empty($view) && $e != $view )continue;
87
+            if(!empty($view) && $e != $view ) {
88
+                continue;
89
+            }
88 90
             $end =strlen($e) - 4;
89 91
             if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
90 92
                 unlink($cacheDir . $e);
@@ -181,8 +183,9 @@  discard block
 block discarded – undo
181 183
             $javascript->setFormName($view);
182 184
 
183 185
             $javascript->setSugarBean($sugarbean);
184
-            if ($view != "ConvertLead")
185
-                $javascript->addAllFields('', null,true);
186
+            if ($view != "ConvertLead") {
187
+                            $javascript->addAllFields('', null,true);
188
+            }
186 189
 
187 190
             $validatedFields = array();
188 191
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -205,8 +208,7 @@  discard block
 block discarded – undo
205 208
                         || isset($app_strings[$def['vname']])
206 209
                         || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
207 210
                      $vname = $def['vname'];
208
-                  }
209
-                  else{
211
+                  } else{
210 212
                      $vname = "undefined";
211 213
                   }
212 214
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -218,7 +220,7 @@  discard block
 block discarded – undo
218 220
             $contents .= $javascript->getScript();
219 221
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
220 222
             $contents .= "{/literal}\n";
221
-        }else if(preg_match('/^SearchForm_.+/', $view)){
223
+        } else if(preg_match('/^SearchForm_.+/', $view)){
222 224
             global $dictionary, $beanList, $app_strings, $mod_strings;
223 225
             $mod = $beanList[$module];
224 226
 
@@ -320,10 +322,12 @@  discard block
 block discarded – undo
320 322
     {
321 323
         $sqs_objects = array();
322 324
         require_once('include/QuickSearchDefaults.php');
323
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
325
+        if(isset($this) && $this instanceof TemplateHandler) {
326
+            //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
324 327
         {
325 328
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
326
-        }else
329
+        }
330
+        } else
327 331
         {
328 332
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
329 333
         }
@@ -332,7 +336,7 @@  discard block
 block discarded – undo
332 336
         	if(strpos($view, 'popup_query_form')){
333 337
         		$qsd->setFormName('popup_query_form');
334 338
             	$parsedView = 'advanced';
335
-        	}else{
339
+        	} else{
336 340
         		$qsd->setFormName('search_form');
337 341
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
338 342
         	}
@@ -350,8 +354,7 @@  discard block
 block discarded – undo
350 354
 
351 355
                             if(!empty($f['name']) && !empty($f['id_name'])) {
352 356
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
353
-                            }
354
-                            else {
357
+                            } else {
355 358
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
356 359
                             }
357 360
                         } else if($matches[0] == 'Campaigns') {
@@ -387,13 +390,16 @@  discard block
 block discarded – undo
387 390
                 } //if-else
388 391
             } //foreach
389 392
 
390
-            foreach ( $sqs_objects as $name => $field )
391
-               foreach ( $field['populate_list'] as $key => $fieldname )
393
+            foreach ( $sqs_objects as $name => $field ) {
394
+                           foreach ( $field['populate_list'] as $key => $fieldname )
392 395
                     $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
393
-        }else{
396
+            }
397
+        } else{
394 398
             //Loop through the Meta-Data fields to see which ones need quick search support
395 399
             foreach($defs2 as $f) {
396
-                if(!isset($defs[$f['name']])) continue;
400
+                if(!isset($defs[$f['name']])) {
401
+                    continue;
402
+                }
397 403
 
398 404
                 $field = $defs[$f['name']];
399 405
                 if ($view == "ConvertLead")
@@ -404,13 +410,13 @@  discard block
 block discarded – undo
404 410
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
405 411
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
406 412
                             $field['id_name'] = $module . $field['id_name'];
413
+                        } else {
414
+                                                    $field['id_name'] = $field['name'] . "_" . $field['id_name'];
415
+                        }
416
+                    } else {
417
+                        if (!empty($field['id_name'])) {
418
+                                                    $field['id_name'] = $module.$field['id_name'];
407 419
                         }
408
-                        else
409
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
410
-                    }
411
-                    else {
412
-                        if (!empty($field['id_name']))
413
-                            $field['id_name'] = $module.$field['id_name'];
414 420
                     }
415 421
                 }
416 422
 				$name = $qsd->form_name . '_' . $field['name'];
@@ -428,10 +434,9 @@  discard block
 block discarded – undo
428 434
                             if($field['name'] == 'reports_to_name'){
429 435
                                 $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
430 436
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
431
-                            }elseif($field['name'] == 'assigned_user_name'){
437
+                            } elseif($field['name'] == 'assigned_user_name'){
432 438
                                  $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
433
-                             }
434
-                             else
439
+                             } else
435 440
                              {
436 441
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
437 442
 
@@ -462,9 +467,9 @@  discard block
 block discarded – undo
462 467
                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
463 468
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
464 469
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
465
-                            if (!isset($field['rname']))
466
-                                $sqs_objects[$name]['field_list'] = array('name', 'id');
467
-                            else
470
+                            if (!isset($field['rname'])) {
471
+                                                            $sqs_objects[$name]['field_list'] = array('name', 'id');
472
+                            } else
468 473
                             {
469 474
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
470 475
                                 $sqs_objects[$name]['order'] = $field['rname'];
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -310,7 +310,7 @@
 block discarded – undo
310 310
      * This function creates the $sqs_objects array that will be used by the quicksearch Javascript
311 311
      * code.  The $sqs_objects array is wrapped in a $json->encode call.
312 312
      *
313
-     * @param array $def The vardefs.php definitions
313
+     * @param array $defs The vardefs.php definitions
314 314
      * @param array $defs2 The Meta-Data file definitions
315 315
      * @param string $view
316 316
      * @param strign $module
Please login to merge, or discard this patch.
include/connectors/ConnectorFactory.php 4 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -44,45 +44,45 @@
 block discarded – undo
44 44
  */
45 45
 class ConnectorFactory{
46 46
 
47
-	static $source_map = array();
47
+    static $source_map = array();
48 48
 
49
-	public static function getInstance($source_name){
50
-		if(empty(self::$source_map[$source_name])) {
51
-			require_once('include/connectors/sources/SourceFactory.php');
52
-			require_once('include/connectors/component.php');
53
-			$source = SourceFactory::getSource($source_name);
54
-			$component = new component();
55
-			$component->setSource($source);
56
-			$component->init();
57
-			self::$source_map[$source_name] = $component;
58
-		}
59
-		return self::$source_map[$source_name];
60
-	}
49
+    public static function getInstance($source_name){
50
+        if(empty(self::$source_map[$source_name])) {
51
+            require_once('include/connectors/sources/SourceFactory.php');
52
+            require_once('include/connectors/component.php');
53
+            $source = SourceFactory::getSource($source_name);
54
+            $component = new component();
55
+            $component->setSource($source);
56
+            $component->init();
57
+            self::$source_map[$source_name] = $component;
58
+        }
59
+        return self::$source_map[$source_name];
60
+    }
61 61
 
62
-	/**
63
-	 * Split the class name by _ and go through the class name
64
-	 * which represents the inheritance structure to load up all required parents.
65
-	 * @param string $class the root class we want to load.
66
-	 */
67
-	public static function load($class, $type){
68
-		self::loadClass($class, $type);
69
-	}
62
+    /**
63
+     * Split the class name by _ and go through the class name
64
+     * which represents the inheritance structure to load up all required parents.
65
+     * @param string $class the root class we want to load.
66
+     */
67
+    public static function load($class, $type){
68
+        self::loadClass($class, $type);
69
+    }
70 70
 
71
-	/**
72
-	 * include a source class file.
73
-	 * @param string $class a class file to include.
74
-	 */
75
-	public static function loadClass($class, $type){
76
-		$dir = str_replace('_','/',$class);
77
-		$parts = explode("/", $dir);
78
-		$file = $parts[count($parts)-1] . '.php';
79
-		if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){
80
-			require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file");
81
-		} else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
82
-			require_once("modules/Connectors/connectors/{$type}/{$dir}/$file");
83
-		} else if(file_exists("connectors/{$type}/{$dir}/$file")) {
84
-			require_once("connectors/{$type}/{$dir}/$file");
85
-		}
86
-	}
71
+    /**
72
+     * include a source class file.
73
+     * @param string $class a class file to include.
74
+     */
75
+    public static function loadClass($class, $type){
76
+        $dir = str_replace('_','/',$class);
77
+        $parts = explode("/", $dir);
78
+        $file = $parts[count($parts)-1] . '.php';
79
+        if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){
80
+            require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file");
81
+        } else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
82
+            require_once("modules/Connectors/connectors/{$type}/{$dir}/$file");
83
+        } else if(file_exists("connectors/{$type}/{$dir}/$file")) {
84
+            require_once("connectors/{$type}/{$dir}/$file");
85
+        }
86
+    }
87 87
 }
88 88
 ?>
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
  * Connector factory
43 43
  * @api
44 44
  */
45
-class ConnectorFactory{
45
+class ConnectorFactory {
46 46
 
47 47
 	static $source_map = array();
48 48
 
49
-	public static function getInstance($source_name){
50
-		if(empty(self::$source_map[$source_name])) {
49
+	public static function getInstance($source_name) {
50
+		if (empty(self::$source_map[$source_name])) {
51 51
 			require_once('include/connectors/sources/SourceFactory.php');
52 52
 			require_once('include/connectors/component.php');
53 53
 			$source = SourceFactory::getSource($source_name);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * which represents the inheritance structure to load up all required parents.
65 65
 	 * @param string $class the root class we want to load.
66 66
 	 */
67
-	public static function load($class, $type){
67
+	public static function load($class, $type) {
68 68
 		self::loadClass($class, $type);
69 69
 	}
70 70
 
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 	 * include a source class file.
73 73
 	 * @param string $class a class file to include.
74 74
 	 */
75
-	public static function loadClass($class, $type){
76
-		$dir = str_replace('_','/',$class);
75
+	public static function loadClass($class, $type) {
76
+		$dir = str_replace('_', '/', $class);
77 77
 		$parts = explode("/", $dir);
78
-		$file = $parts[count($parts)-1] . '.php';
79
-		if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){
78
+		$file = $parts[count($parts) - 1].'.php';
79
+		if (file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")) {
80 80
 			require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file");
81
-		} else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
81
+		} else if (file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
82 82
 			require_once("modules/Connectors/connectors/{$type}/{$dir}/$file");
83
-		} else if(file_exists("connectors/{$type}/{$dir}/$file")) {
83
+		} else if (file_exists("connectors/{$type}/{$dir}/$file")) {
84 84
 			require_once("connectors/{$type}/{$dir}/$file");
85 85
 		}
86 86
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 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.
Please login to merge, or discard this patch.
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -63,6 +63,7 @@
 block discarded – undo
63 63
 	 * Split the class name by _ and go through the class name
64 64
 	 * which represents the inheritance structure to load up all required parents.
65 65
 	 * @param string $class the root class we want to load.
66
+	 * @param string $type
66 67
 	 */
67 68
 	public static function load($class, $type){
68 69
 		self::loadClass($class, $type);
Please login to merge, or discard this patch.
include/MVC/View/SugarView.php 5 patches
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1387,18 +1387,18 @@
 block discarded – undo
1387 1387
 		//$params = array();
1388 1388
         if (isset($this->action)){
1389 1389
             switch ($this->action) {
1390
-            case 'EditView':
1391
-                if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1392
-                    $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1393
-                    $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1394
-                }
1395
-                else
1396
-                    $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1397
-                break;
1398
-            case 'DetailView':
1399
-                $beanName = $this->bean->get_summary_text();
1400
-                $params[] = $beanName;
1401
-                break;
1390
+                case 'EditView':
1391
+                    if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1392
+                        $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1393
+                        $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1394
+                    }
1395
+                    else
1396
+                        $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1397
+                    break;
1398
+                case 'DetailView':
1399
+                    $beanName = $this->bean->get_summary_text();
1400
+                    $params[] = $beanName;
1401
+                    break;
1402 1402
             }
1403 1403
         }
1404 1404
 
Please login to merge, or discard this patch.
Spacing   +228 added lines, -229 removed lines patch added patch discarded remove patch
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
         $this->_trackView();
125 125
 
126 126
         //For the ajaxUI, we need to use output buffering to return the page in an ajax friendly format
127
-        if ($this->_getOption('json_output')){
127
+        if ($this->_getOption('json_output')) {
128 128
 			ob_start();
129
-			if(!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
129
+			if (!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
130 130
 				echo $this->_getModLanguageJS();
131 131
 			}
132 132
 		}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $this->preDisplay();
142 142
         $this->displayErrors();
143 143
         $this->display();
144
-        if ( !empty($this->module) ) {
144
+        if (!empty($this->module)) {
145 145
             $GLOBALS['logic_hook']->call_custom_logic($this->module, 'after_ui_frame');
146 146
         } else {
147 147
             $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_frame');
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
                 'favicon' => $this->getFavicon(),
187 187
             );
188 188
 
189
-            if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
189
+            if (SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
190 190
                 $ajax_ret['moduleList'] = $this->displayHeader(true);
191 191
 
192
-            if(empty($this->responseTime))
192
+            if (empty($this->responseTime))
193 193
                 $this->_calculateFooterMetrics();
194 194
             $ajax_ret['responseTime'] = $this->responseTime;
195 195
             $json = getJSONobj();
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
     {
209 209
         $errors = '';
210 210
 
211
-        foreach($this->errors as $error) {
212
-            $errors .= '<span class="error">' . $error . '</span><br>';
211
+        foreach ($this->errors as $error) {
212
+            $errors .= '<span class="error">'.$error.'</span><br>';
213 213
         }
214 214
 
215
-        if ( !$this->suppressDisplayErrors ) {
215
+        if (!$this->suppressDisplayErrors) {
216 216
             echo $errors;
217 217
         }
218 218
         else {
@@ -249,14 +249,14 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $action = strtolower($this->action);
251 251
         //Skip save, tracked in SugarBean instead
252
-        if($action == 'save') {
252
+        if ($action == 'save') {
253 253
         return;
254 254
         }
255 255
 
256 256
 
257 257
         $trackerManager = TrackerManager::getInstance();
258 258
         $timeStamp = TimeDate::getInstance()->nowDb();
259
-        if($monitor = $trackerManager->getMonitor('tracker')){
259
+        if ($monitor = $trackerManager->getMonitor('tracker')) {
260 260
             $monitor->setValue('action', $action);
261 261
             $monitor->setValue('user_id', $GLOBALS['current_user']->id);
262 262
             $monitor->setValue('module_name', $this->module);
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
             //If visible is true, but there is no bean, do not track (invalid/unauthorized reference)
273 273
             //Also, do not track save actions where there is no bean id
274
-            if($monitor->visible && empty($this->bean->id)) {
274
+            if ($monitor->visible && empty($this->bean->id)) {
275 275
             $trackerManager->unsetMonitor($monitor);
276 276
             return;
277 277
             }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     /**
284 284
      * Displays the header on section of the page; basically everything before the content
285 285
      */
286
-    public function displayHeader($retModTabs=false)
286
+    public function displayHeader($retModTabs = false)
287 287
     {
288 288
         global $theme;
289 289
         global $max_tabs;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         $ss->assign("APP", $app_strings);
304 304
         $ss->assign("THEME", $theme);
305 305
         $ss->assign("THEME_CONFIG", $themeObject->getConfig());
306
-        $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true':'false');
306
+        $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
307 307
         $ss->assign("MODULE_NAME", $this->module);
308 308
         $ss->assign("langHeader", get_language_header());
309 309
 
@@ -319,17 +319,17 @@  discard block
 block discarded – undo
319 319
         if ($this->_getOption('view_print')) {
320 320
             $css .= '<link rel="stylesheet" type="text/css" href="'.$themeObject->getCSSURL('print.css').'" media="all" />';
321 321
         }
322
-        $ss->assign("SUGAR_CSS",$css);
322
+        $ss->assign("SUGAR_CSS", $css);
323 323
 
324 324
         // get javascript
325 325
         ob_start();
326 326
         $this->renderJavascript();
327 327
 
328
-        $ss->assign("SUGAR_JS",ob_get_contents().$themeObject->getJS());
328
+        $ss->assign("SUGAR_JS", ob_get_contents().$themeObject->getJS());
329 329
         ob_end_clean();
330 330
 
331 331
         // get favicon
332
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
332
+        if (isset($GLOBALS['sugar_config']['default_module_favicon']))
333 333
             $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
334 334
         else
335 335
             $module_favicon = false;
@@ -339,24 +339,24 @@  discard block
 block discarded – undo
339 339
 
340 340
         // build the shortcut menu
341 341
         $shortcut_menu = array();
342
-        foreach ( $this->getMenu() as $key => $menu_item )
342
+        foreach ($this->getMenu() as $key => $menu_item)
343 343
             $shortcut_menu[$key] = array(
344 344
                 "URL"         => $menu_item[0],
345 345
                 "LABEL"       => $menu_item[1],
346 346
                 "MODULE_NAME" => $menu_item[2],
347 347
                 "IMAGE"       => $themeObject
348
-                    ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
348
+                    ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
349 349
                 );
350
-        $ss->assign("SHORTCUT_MENU",$shortcut_menu);
350
+        $ss->assign("SHORTCUT_MENU", $shortcut_menu);
351 351
 
352 352
         // handle rtl text direction
353
-        if(isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL'){
353
+        if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
354 354
             $_SESSION['RTL'] = true;
355 355
         }
356
-        if(isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR'){
356
+        if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
357 357
             unset($_SESSION['RTL']);
358 358
         }
359
-        if(isset($_SESSION['RTL']) && $_SESSION['RTL']){
359
+        if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
360 360
             $ss->assign("DIR", 'dir="RTL"');
361 361
         }
362 362
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $companyLogoURL = $companyLogoURL_arr[0];
367 367
 
368 368
         $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
369
-        if(!empty($company_logo_attributes)) {
369
+        if (!empty($company_logo_attributes)) {
370 370
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
371 371
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
372 372
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
@@ -375,16 +375,16 @@  discard block
 block discarded – undo
375 375
             // Always need to md5 the file
376 376
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
377 377
 
378
-            list($width,$height) = getimagesize($companyLogoURL);
379
-            if ( $width > 212 || $height > 40 ) {
380
-                $resizePctWidth  = ($width - 212)/212;
381
-                $resizePctHeight = ($height - 40)/40;
382
-                if ( $resizePctWidth > $resizePctHeight )
378
+            list($width, $height) = getimagesize($companyLogoURL);
379
+            if ($width > 212 || $height > 40) {
380
+                $resizePctWidth  = ($width - 212) / 212;
381
+                $resizePctHeight = ($height - 40) / 40;
382
+                if ($resizePctWidth > $resizePctHeight)
383 383
                     $resizeAmount = $width / 212;
384 384
                 else
385 385
                     $resizeAmount = $height / 40;
386
-                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
387
-                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
386
+                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
387
+                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
388 388
             }
389 389
             else {
390 390
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
@@ -400,110 +400,110 @@  discard block
 block discarded – undo
400 400
                                 )
401 401
             );
402 402
         }
403
-        $ss->assign("COMPANY_LOGO_URL",getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
403
+        $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
404 404
 
405 405
         // get the global links
406 406
         $gcls = array();
407 407
         $global_control_links = array();
408 408
         require("include/globalControlLinks.php");
409 409
 
410
-        foreach($global_control_links as $key => $value) {
411
-            if ($key == 'users')  {   //represents logout link.
410
+        foreach ($global_control_links as $key => $value) {
411
+            if ($key == 'users') {   //represents logout link.
412 412
                 $ss->assign("LOGOUT_LINK", $value['linkinfo'][key($value['linkinfo'])]);
413
-                $ss->assign("LOGOUT_LABEL", key($value['linkinfo']));//key value for first element.
413
+                $ss->assign("LOGOUT_LABEL", key($value['linkinfo'])); //key value for first element.
414 414
                 continue;
415 415
             }
416 416
 
417 417
             foreach ($value as $linkattribute => $attributevalue) {
418 418
                 // get the main link info
419
-                if ( $linkattribute == 'linkinfo' ) {
419
+                if ($linkattribute == 'linkinfo') {
420 420
                     $gcls[$key] = array(
421 421
                         "LABEL" => key($attributevalue),
422 422
                         "URL"   => current($attributevalue),
423 423
                         "SUBMENU" => array(),
424 424
                         );
425
-                   if(substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
-                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"],11);
425
+                   if (substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
+                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"], 11);
427 427
                        $gcls[$key]["URL"] = "javascript:void(0)";
428 428
                    }
429 429
                 }
430 430
                 // and now the sublinks
431
-                if ( $linkattribute == 'submenu' && is_array($attributevalue) ) {
431
+                if ($linkattribute == 'submenu' && is_array($attributevalue)) {
432 432
                     foreach ($attributevalue as $submenulinkkey => $submenulinkinfo)
433 433
                         $gcls[$key]['SUBMENU'][$submenulinkkey] = array(
434 434
                             "LABEL" => key($submenulinkinfo),
435 435
                             "URL"   => current($submenulinkinfo),
436 436
                         );
437
-                       if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
-                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
437
+                       if (substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
+                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 11);
439 439
                            $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
440 440
                        }
441 441
                 }
442 442
             }
443 443
         }
444
-        $ss->assign("GCLS",$gcls);
444
+        $ss->assign("GCLS", $gcls);
445 445
 
446 446
         $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
447 447
 
448 448
         if ($this->action == "EditView" || $this->action == "Login")
449 449
             $ss->assign("ONLOAD", 'onload="set_focus()"');
450 450
 
451
-        $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
451
+        $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
452 452
 
453 453
         // get other things needed for page style popup
454 454
         if (isset($_SESSION["authenticated_user_id"])) {
455 455
             // get the current user name and id
456 456
             $ss->assign("CURRENT_USER", $current_user->full_name == '' || !showFullName()
457
-                ? $current_user->user_name : $current_user->full_name );
457
+                ? $current_user->user_name : $current_user->full_name);
458 458
             $ss->assign("CURRENT_USER_ID", $current_user->id);
459 459
 
460 460
             // get the last viewed records
461 461
             require_once("modules/Favorites/Favorites.php");
462 462
             $favorites = new Favorites();
463 463
             $favorite_records = $favorites->getCurrentUserSidebarFavorites();
464
-            $ss->assign("favoriteRecords",$favorite_records);
464
+            $ss->assign("favoriteRecords", $favorite_records);
465 465
 
466 466
             $tracker = new Tracker();
467 467
             $history = $tracker->get_recently_viewed($current_user->id);
468
-            $ss->assign("recentRecords",$this->processRecentRecords($history));
468
+            $ss->assign("recentRecords", $this->processRecentRecords($history));
469 469
         }
470 470
 
471 471
         $bakModStrings = $mod_strings;
472
-        if (isset($_SESSION["authenticated_user_id"]) ) {
472
+        if (isset($_SESSION["authenticated_user_id"])) {
473 473
             // get the module list
474 474
             $moduleTopMenu = array();
475 475
 
476 476
             $max_tabs = $current_user->getPreference('max_tabs');
477 477
             // Attempt to correct if max tabs count is extremely high.
478
-            if ( !isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10 ) {
478
+            if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
479 479
                 $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
480 480
                 $current_user->setPreference('max_tabs', $max_tabs, 0, 'global');
481 481
             }
482 482
 
483 483
             $moduleTab = $this->_getModuleTab();
484
-            $ss->assign('MODULE_TAB',$moduleTab);
484
+            $ss->assign('MODULE_TAB', $moduleTab);
485 485
 
486 486
 
487 487
             // See if they are using grouped tabs or not (removed in 6.0, returned in 6.1)
488 488
             $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
489
-            if ( !isset($user_navigation_paradigm) ) {
489
+            if (!isset($user_navigation_paradigm)) {
490 490
                 $user_navigation_paradigm = $GLOBALS['sugar_config']['default_navigation_paradigm'];
491 491
             }
492 492
 
493 493
 
494 494
             // Get the full module list for later use
495
-            foreach ( query_module_access_list($current_user) as $module ) {
495
+            foreach (query_module_access_list($current_user) as $module) {
496 496
                 // Bug 25948 - Check for the module being in the moduleList
497
-                if ( isset($app_list_strings['moduleList'][$module]) ) {
497
+                if (isset($app_list_strings['moduleList'][$module])) {
498 498
                     $fullModuleList[$module] = $app_list_strings['moduleList'][$module];
499 499
                 }
500 500
             }
501 501
 
502 502
 
503
-            if(!should_hide_iframes()) {
503
+            if (!should_hide_iframes()) {
504 504
                 $iFrame = new iFrame();
505 505
                 $frames = $iFrame->lookup_frames('tab');
506
-                foreach($frames as $key => $values){
506
+                foreach ($frames as $key => $values) {
507 507
                         $fullModuleList[$key] = $values;
508 508
                 }
509 509
             }
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                 unset($fullModuleList['iFrames']);
512 512
             }
513 513
 
514
-            if ( $user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
514
+            if ($user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
515 515
                 // We are using grouped tabs
516 516
                 require_once('include/GroupedTabs/GroupedTabStructure.php');
517 517
                 $groupedTabsClass = new GroupedTabStructure();
@@ -519,12 +519,12 @@  discard block
 block discarded – undo
519 519
                 //handle with submoremodules
520 520
                 $max_tabs = $current_user->getPreference('max_tabs');
521 521
                 // If the max_tabs isn't set incorrectly, set it within the range, to the default max sub tabs size
522
-                if ( !isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10){
522
+                if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
523 523
                     // We have a default value. Use it
524
-                    if(isset($GLOBALS['sugar_config']['default_max_tabs'])){
524
+                    if (isset($GLOBALS['sugar_config']['default_max_tabs'])) {
525 525
                         $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
526 526
                     }
527
-                    else{
527
+                    else {
528 528
                         $max_tabs = 8;
529 529
                     }
530 530
                 }
@@ -537,22 +537,22 @@  discard block
 block discarded – undo
537 537
 
538 538
                 // Setup the default group tab.
539 539
                 $allGroup = $app_strings['LBL_TABGROUP_ALL'];
540
-                $ss->assign('currentGroupTab',$allGroup);
540
+                $ss->assign('currentGroupTab', $allGroup);
541 541
                 $currentGroupTab = $allGroup;
542 542
                 $usersGroup = $current_user->getPreference('theme_current_group');
543 543
                 // Figure out which tab they currently have selected (stored as a user preference)
544
-                if ( !empty($usersGroup) && isset($groupTabs[$usersGroup]) ) {
544
+                if (!empty($usersGroup) && isset($groupTabs[$usersGroup])) {
545 545
                     $currentGroupTab = $usersGroup;
546 546
                 } else {
547
-                    $current_user->setPreference('theme_current_group',$currentGroupTab);
547
+                    $current_user->setPreference('theme_current_group', $currentGroupTab);
548 548
                 }
549 549
 
550
-                $ss->assign('currentGroupTab',$currentGroupTab);
550
+                $ss->assign('currentGroupTab', $currentGroupTab);
551 551
                 $usingGroupTabs = true;
552 552
 
553 553
             } else {
554 554
                 // Setup the default group tab.
555
-                $ss->assign('currentGroupTab',$app_strings['LBL_TABGROUP_ALL']);
555
+                $ss->assign('currentGroupTab', $app_strings['LBL_TABGROUP_ALL']);
556 556
 
557 557
                 $usingGroupTabs = false;
558 558
 
@@ -564,31 +564,31 @@  discard block
 block discarded – undo
564 564
             $topTabList = array();
565 565
 
566 566
             // Now time to go through each of the tab sets and fix them up.
567
-            foreach ( $groupTabs as $tabIdx => $tabData ) {
567
+            foreach ($groupTabs as $tabIdx => $tabData) {
568 568
                 $topTabs = $tabData['modules'];
569
-                if ( ! is_array($topTabs) ) {
569
+                if (!is_array($topTabs)) {
570 570
                     $topTabs = array();
571 571
                 }
572 572
                 $extraTabs = array();
573 573
 
574 574
                 // Split it in to the tabs that go across the top, and the ones that are on the extra menu.
575
-                if ( count($topTabs) > $max_tabs ) {
576
-                    $extraTabs = array_splice($topTabs,$max_tabs);
575
+                if (count($topTabs) > $max_tabs) {
576
+                    $extraTabs = array_splice($topTabs, $max_tabs);
577 577
                 }
578 578
                 // Make sure the current module is accessable through one of the top tabs
579
-                if ( !isset($topTabs[$moduleTab]) ) {
579
+                if (!isset($topTabs[$moduleTab])) {
580 580
                     // Nope, we need to add it.
581 581
                     // First, take it out of the extra menu, if it's there
582
-                    if ( isset($extraTabs[$moduleTab]) ) {
582
+                    if (isset($extraTabs[$moduleTab])) {
583 583
                         unset($extraTabs[$moduleTab]);
584 584
                     }
585
-                    if ( count($topTabs) >= $max_tabs - 1 ) {
585
+                    if (count($topTabs) >= $max_tabs - 1) {
586 586
                         // We already have the maximum number of tabs, so we need to shuffle the last one
587 587
                         // from the top to the first one of the extras
588
-                        $lastElem = array_splice($topTabs,$max_tabs-1);
588
+                        $lastElem = array_splice($topTabs, $max_tabs - 1);
589 589
                         $extraTabs = $lastElem + $extraTabs;
590 590
                     }
591
-                    if ( !empty($moduleTab) ) {
591
+                    if (!empty($moduleTab)) {
592 592
                         $topTabs[$moduleTab] = $app_list_strings['moduleList'][$moduleTab];
593 593
                     }
594 594
                 }
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                 */
608 608
 
609 609
                 // Get a unique list of the top tabs so we can build the popup menus for them
610
-                foreach ( $topTabs as $moduleKey => $module ) {
610
+                foreach ($topTabs as $moduleKey => $module) {
611 611
                     $topTabList[$moduleKey] = $module;
612 612
                 }
613 613
 
@@ -616,67 +616,67 @@  discard block
 block discarded – undo
616 616
             }
617 617
         }
618 618
 
619
-        if ( isset($topTabList) && is_array($topTabList) ) {
619
+        if (isset($topTabList) && is_array($topTabList)) {
620 620
             // Adding shortcuts array to menu array for displaying shortcuts associated with each module
621 621
             $shortcutTopMenu = array();
622
-            foreach($topTabList as $module_key => $label) {
622
+            foreach ($topTabList as $module_key => $label) {
623 623
                 global $mod_strings;
624 624
                 $mod_strings = return_module_language($current_language, $module_key);
625
-                foreach ( $this->getMenu($module_key) as $key => $menu_item ) {
625
+                foreach ($this->getMenu($module_key) as $key => $menu_item) {
626 626
                     $shortcutTopMenu[$module_key][$key] = array(
627 627
                         "URL"         => $menu_item[0],
628 628
                         "LABEL"       => $menu_item[1],
629 629
                         "MODULE_NAME" => $menu_item[2],
630 630
                         "IMAGE"       => $themeObject
631
-                        ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
631
+                        ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
632 632
                         "ID"          => $menu_item[2]."_link",
633 633
                         );
634 634
                 }
635 635
             }
636
-            if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
637
-            $ss->assign("groupTabs",$groupTabs);
638
-            $ss->assign("shortcutTopMenu",$shortcutTopMenu);
639
-            $ss->assign('USE_GROUP_TABS',$usingGroupTabs);
636
+            if (!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
637
+            $ss->assign("groupTabs", $groupTabs);
638
+            $ss->assign("shortcutTopMenu", $shortcutTopMenu);
639
+            $ss->assign('USE_GROUP_TABS', $usingGroupTabs);
640 640
 
641 641
             // This is here for backwards compatibility, someday, somewhere, it will be able to be removed
642
-            $ss->assign("moduleTopMenu",$groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
643
-            $ss->assign("moduleExtraMenu",$groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
642
+            $ss->assign("moduleTopMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
643
+            $ss->assign("moduleExtraMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
644 644
 
645 645
 
646 646
         }
647 647
         
648
-        if ( isset($extraTabs) && is_array($extraTabs) ) {
648
+        if (isset($extraTabs) && is_array($extraTabs)) {
649 649
             // Adding shortcuts array to extra menu array for displaying shortcuts associated with each module
650 650
             $shortcutExtraMenu = array();
651
-            foreach($extraTabs as $module_key => $label) {
651
+            foreach ($extraTabs as $module_key => $label) {
652 652
                 global $mod_strings;
653 653
                 $mod_strings = return_module_language($current_language, $module_key);
654
-                foreach ( $this->getMenu($module_key) as $key => $menu_item ) {
654
+                foreach ($this->getMenu($module_key) as $key => $menu_item) {
655 655
                     $shortcutExtraMenu[$module_key][$key] = array(
656 656
                         "URL"         => $menu_item[0],
657 657
                         "LABEL"       => $menu_item[1],
658 658
                         "MODULE_NAME" => $menu_item[2],
659 659
                         "IMAGE"       => $themeObject
660
-                        ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
660
+                        ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
661 661
                         "ID"          => $menu_item[2]."_link",
662 662
                         );
663 663
                 }
664 664
             }
665
-            $ss->assign("shortcutExtraMenu",$shortcutExtraMenu);
665
+            $ss->assign("shortcutExtraMenu", $shortcutExtraMenu);
666 666
         }
667 667
        
668
-       if(!empty($current_user)){
668
+       if (!empty($current_user)) {
669 669
        	$ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
670 670
        } 
671 671
       
672 672
        
673 673
         $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
674 674
         $homeImage = "<img src='$imageURL'>";
675
-		$ss->assign("homeImage",$homeImage);
675
+		$ss->assign("homeImage", $homeImage);
676 676
         global $mod_strings;
677 677
         $mod_strings = $bakModStrings;
678 678
         $headerTpl = $themeObject->getTemplate('header.tpl');
679
-        if (inDeveloperMode() )
679
+        if (inDeveloperMode())
680 680
             $ss->clear_compiled_tpl($headerTpl);
681 681
 
682 682
         if ($retModTabs)
@@ -688,9 +688,9 @@  discard block
 block discarded – undo
688 688
             $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
689 689
 
690 690
             $errorMessages = SugarApplication::getErrorMessages();
691
-            if ( !empty($errorMessages)) {
692
-                foreach ( $errorMessages as $error_message ) {
693
-                    echo('<p class="error">' . $error_message.'</p>');
691
+            if (!empty($errorMessages)) {
692
+                foreach ($errorMessages as $error_message) {
693
+                    echo('<p class="error">'.$error_message.'</p>');
694 694
                 }
695 695
             }
696 696
         }
@@ -725,13 +725,13 @@  discard block
 block discarded – undo
725 725
     {
726 726
         global $sugar_config, $timedate;
727 727
 
728
-        if(isset($this->bean->module_dir)){
728
+        if (isset($this->bean->module_dir)) {
729 729
             echo "<script>var module_sugar_grp1 = '{$this->bean->module_dir}';</script>";
730 730
         }
731
-        if(isset($_REQUEST['action'])){
731
+        if (isset($_REQUEST['action'])) {
732 732
             echo "<script>var action_sugar_grp1 = '{$_REQUEST['action']}';</script>";
733 733
         }
734
-        echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
734
+        echo '<script>jscal_today = 1000*'.$timedate->asUserTs($timedate->getNow()).'; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
735 735
         if (!is_file(sugar_cached("include/javascript/sugar_grp1.js"))) {
736 736
             $_REQUEST['root_directory'] = ".";
737 737
             require_once("jssource/minify_utils.php");
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
             if ( typeof(SUGAR.themes) == 'undefined' ) SUGAR.themes = {};
748 748
         </script>
749 749
 EOQ;
750
-        if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
750
+        if (isset($sugar_config['disc_client']) && $sugar_config['disc_client'])
751 751
             echo getVersionedScript('modules/Sync/headersync.js');
752 752
     }
753 753
 
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
         require_once ('modules/Currencies/Currency.php');
777 777
         list ($num_grp_sep, $dec_sep) = get_number_seperators();
778 778
 
779
-        $the_script = "<script type=\"text/javascript\">\n" . "\tvar time_reg_format = '" .
780
-             $timereg['format'] . "';\n" . "\tvar date_reg_format = '" .
781
-             $datereg['format'] . "';\n" . "\tvar date_reg_positions = { $date_pos };\n" .
782
-             "\tvar time_separator = '$time_separator';\n" .
783
-             "\tvar cal_date_format = '$cal_date_format';\n" .
784
-             "\tvar time_offset = $hour_offset;\n" . "\tvar num_grp_sep = '$num_grp_sep';\n" .
785
-             "\tvar dec_sep = '$dec_sep';\n" . "</script>";
779
+        $the_script = "<script type=\"text/javascript\">\n"."\tvar time_reg_format = '".
780
+             $timereg['format']."';\n"."\tvar date_reg_format = '".
781
+             $datereg['format']."';\n"."\tvar date_reg_positions = { $date_pos };\n".
782
+             "\tvar time_separator = '$time_separator';\n".
783
+             "\tvar cal_date_format = '$cal_date_format';\n".
784
+             "\tvar time_offset = $hour_offset;\n"."\tvar num_grp_sep = '$num_grp_sep';\n".
785
+             "\tvar dec_sep = '$dec_sep';\n"."</script>";
786 786
 
787 787
         return $the_script;
788 788
     }
@@ -810,13 +810,13 @@  discard block
 block discarded – undo
810 810
                 "sugar_cache_dir" => "cache/",
811 811
                 );
812 812
 
813
-            if(isset($this->bean->module_dir)){
813
+            if (isset($this->bean->module_dir)) {
814 814
                 $js_vars['module_sugar_grp1'] = $this->bean->module_dir;
815 815
             }
816
-            if(isset($_REQUEST['action'])){
816
+            if (isset($_REQUEST['action'])) {
817 817
                 $js_vars['action_sugar_grp1'] = $_REQUEST['action'];
818 818
             }
819
-            echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
819
+            echo '<script>jscal_today = 1000*'.$timedate->asUserTs($timedate->getNow()).'; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
820 820
             if (!is_file(sugar_cached("include/javascript/sugar_grp1.js")) || !is_file(sugar_cached("include/javascript/sugar_grp1_yui.js")) || !is_file(sugar_cached("include/javascript/sugar_grp1_jquery.js"))) {
821 821
                 $_REQUEST['root_directory'] = ".";
822 822
                 require_once("jssource/minify_utils.php");
@@ -829,33 +829,33 @@  discard block
 block discarded – undo
829 829
 
830 830
             // output necessary config js in the top of the page
831 831
             $config_js = $this->getSugarConfigJS();
832
-            if(!empty($config_js)){
832
+            if (!empty($config_js)) {
833 833
                 echo "<script>\n".implode("\n", $config_js)."</script>\n";
834 834
             }
835 835
 
836
-            if ( isset($sugar_config['email_sugarclient_listviewmaxselect']) ) {
836
+            if (isset($sugar_config['email_sugarclient_listviewmaxselect'])) {
837 837
                 echo "<script>SUGAR.config.email_sugarclient_listviewmaxselect = {$GLOBALS['sugar_config']['email_sugarclient_listviewmaxselect']};</script>";
838 838
             }
839 839
 
840
-            $image_server = (defined('TEMPLATE_URL'))?TEMPLATE_URL . '/':'';
841
-            echo '<script type="text/javascript">SUGAR.themes.image_server="' . $image_server . '";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF
842
-            echo '<script type="text/javascript">var name_format = "' . $locale->getLocaleFormatMacro() . '";</script>';
840
+            $image_server = (defined('TEMPLATE_URL')) ? TEMPLATE_URL.'/' : '';
841
+            echo '<script type="text/javascript">SUGAR.themes.image_server="'.$image_server.'";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF
842
+            echo '<script type="text/javascript">var name_format = "'.$locale->getLocaleFormatMacro().'";</script>';
843 843
             echo self::getJavascriptValidation();
844
-            if (!is_file(sugar_cached('jsLanguage/') . $GLOBALS['current_language'] . '.js')) {
844
+            if (!is_file(sugar_cached('jsLanguage/').$GLOBALS['current_language'].'.js')) {
845 845
                 require_once ('include/language/jsLanguage.php');
846 846
                 jsLanguage::createAppStringsCache($GLOBALS['current_language']);
847 847
             }
848
-            echo getVersionedScript('cache/jsLanguage/'. $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
848
+            echo getVersionedScript('cache/jsLanguage/'.$GLOBALS['current_language'].'.js', $GLOBALS['sugar_config']['js_lang_version']);
849 849
 
850 850
 			echo $this->_getModLanguageJS();
851 851
 
852
-            if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
852
+            if (isset($sugar_config['disc_client']) && $sugar_config['disc_client'])
853 853
                 echo getVersionedScript('modules/Sync/headersync.js');
854 854
 
855 855
 
856 856
             //echo out the $js_vars variables as javascript variables
857 857
             echo "<script type='text/javascript'>\n";
858
-            foreach($js_vars as $var=>$value)
858
+            foreach ($js_vars as $var=>$value)
859 859
             {
860 860
                 echo "var {$var} = '{$value}';\n";
861 861
             }
@@ -863,12 +863,12 @@  discard block
 block discarded – undo
863 863
         }
864 864
     }
865 865
 
866
-	protected function _getModLanguageJS(){
867
-		if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {
866
+	protected function _getModLanguageJS() {
867
+		if (!is_file(sugar_cached('jsLanguage/').$this->module.'/'.$GLOBALS['current_language'].'.js')) {
868 868
 			require_once ('include/language/jsLanguage.php');
869 869
 			jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);
870 870
 		}
871
-		return getVersionedScript("cache/jsLanguage/{$this->module}/". $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
871
+		return getVersionedScript("cache/jsLanguage/{$this->module}/".$GLOBALS['current_language'].'.js', $GLOBALS['sugar_config']['js_lang_version']);
872 872
 	}
873 873
 
874 874
     /**
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
         }
891 891
 
892 892
         $ss = new Sugar_Smarty();
893
-        $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
894
-        $ss->assign('MOD',return_module_language($GLOBALS['current_language'], 'Users'));
893
+        $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
894
+        $ss->assign('MOD', return_module_language($GLOBALS['current_language'], 'Users'));
895 895
 
896 896
 		$bottomLinkList = array();
897 897
 		 if (isset($this->action) && $this->action != "EditView") {
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
 		$bottomLinkList['backtotop'] = array($app_strings['LNK_BACKTOTOP'] => 'javascript:SUGAR.util.top();');
901 901
 
902 902
 		$bottomLinksStr = "";
903
-		foreach($bottomLinkList as $key => $value) {
904
-			foreach($value as $text => $link) {
903
+		foreach ($bottomLinkList as $key => $value) {
904
+			foreach ($value as $text => $link) {
905 905
 				   $href = $link;
906
-				   if(substr($link, 0, 11) == "javascript:") {
907
-                       $onclick = " onclick=\"".substr($link,11)."\"";
906
+				   if (substr($link, 0, 11) == "javascript:") {
907
+                       $onclick = " onclick=\"".substr($link, 11)."\"";
908 908
                        $href = "javascript:void(0)";
909 909
                    } else {
910 910
                    		$onclick = "";
@@ -916,9 +916,9 @@  discard block
 block discarded – undo
916 916
 				$bottomLinksStr .= " ".$text."</a>";
917 917
 			}
918 918
 		}
919
-		$ss->assign("BOTTOMLINKS",$bottomLinksStr);
919
+		$ss->assign("BOTTOMLINKS", $bottomLinksStr);
920 920
         if (SugarConfig::getInstance()->get('calculate_response_time', false))
921
-            $ss->assign('STATISTICS',$this->_getStatistics());
921
+            $ss->assign('STATISTICS', $this->_getStatistics());
922 922
 
923 923
         // Under the License referenced above, you are required to leave in all copyright statements in both
924 924
         // the code and end-user application.
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
         $companyLogoURL = $companyLogoURL_arr[0];
953 953
 
954 954
         $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
955
-        if(!empty($company_logo_attributes)) {
955
+        if (!empty($company_logo_attributes)) {
956 956
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
957 957
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
958 958
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
@@ -961,16 +961,16 @@  discard block
 block discarded – undo
961 961
             // Always need to md5 the file
962 962
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
963 963
 
964
-            list($width,$height) = getimagesize($companyLogoURL);
965
-            if ( $width > 212 || $height > 40 ) {
966
-                $resizePctWidth  = ($width - 212)/212;
967
-                $resizePctHeight = ($height - 40)/40;
968
-                if ( $resizePctWidth > $resizePctHeight )
964
+            list($width, $height) = getimagesize($companyLogoURL);
965
+            if ($width > 212 || $height > 40) {
966
+                $resizePctWidth  = ($width - 212) / 212;
967
+                $resizePctHeight = ($height - 40) / 40;
968
+                if ($resizePctWidth > $resizePctHeight)
969 969
                     $resizeAmount = $width / 212;
970 970
                 else
971 971
                     $resizeAmount = $height / 40;
972
-                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
973
-                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
972
+                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
973
+                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
974 974
             }
975 975
             else {
976 976
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
@@ -986,28 +986,28 @@  discard block
 block discarded – undo
986 986
                                 )
987 987
             );
988 988
         }
989
-        $ss->assign("COMPANY_LOGO_URL",getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
989
+        $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
990 990
 
991 991
         // Bug 38594 - Add in Trademark wording
992 992
         $copyright .= 'SugarCRM is a trademark of SugarCRM, Inc. All other company and product names may be trademarks of the respective companies with which they are associated.<br />';
993 993
 
994 994
         //rrs bug: 20923 - if this image does not exist as per the license, then the proper image will be displayed regardless, so no need
995 995
         //to display an empty image here.
996
-        if(file_exists('include/images/poweredby_sugarcrm_65.png')){
996
+        if (file_exists('include/images/poweredby_sugarcrm_65.png')) {
997 997
             $copyright .= $attribLinkImg;
998 998
         }
999 999
         // End Required Image
1000
-        $ss->assign('COPYRIGHT',$copyright);
1000
+        $ss->assign('COPYRIGHT', $copyright);
1001 1001
 
1002 1002
         // here we allocate the help link data
1003 1003
         $help_actions_blacklist = array('Login'); // we don't want to show a context help link here
1004
-        if (!in_array($this->action,$help_actions_blacklist)) {
1004
+        if (!in_array($this->action, $help_actions_blacklist)) {
1005 1005
             $url = 'javascript:void(window.open(\'index.php?module=Administration&action=SupportPortal&view=documentation&version='.$GLOBALS['sugar_version'].'&edition='.$GLOBALS['sugar_flavor'].'&lang='.$GLOBALS['current_language'].
1006 1006
                         '&help_module='.$this->module.'&help_action='.$this->action.'&key='.$GLOBALS['server_unique_key'].'\'))';
1007 1007
             $label = (isset($GLOBALS['app_list_strings']['moduleList'][$this->module]) ?
1008
-                        $GLOBALS['app_list_strings']['moduleList'][$this->module] : $this->module). ' '.$app_strings['LNK_HELP'];
1009
-            $ss->assign('HELP_LINK',SugarThemeRegistry::current()->getLink($url, $label, "id='help_link_two'",
1010
-                'help-dashlet.png', 'class="icon"',null,null,'','left'));
1008
+                        $GLOBALS['app_list_strings']['moduleList'][$this->module] : $this->module).' '.$app_strings['LNK_HELP'];
1009
+            $ss->assign('HELP_LINK', SugarThemeRegistry::current()->getLink($url, $label, "id='help_link_two'",
1010
+                'help-dashlet.png', 'class="icon"', null, null, '', 'left'));
1011 1011
         }
1012 1012
         // end
1013 1013
 
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
      */
1021 1021
     protected function _displaySubPanels()
1022 1022
     {
1023
-        if (isset($this->bean) && !empty($this->bean->id) && (file_exists('modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/Ext/Layoutdefs/layoutdefs.ext.php'))) {
1023
+        if (isset($this->bean) && !empty($this->bean->id) && (file_exists('modules/'.$this->module.'/metadata/subpaneldefs.php') || file_exists('custom/modules/'.$this->module.'/metadata/subpaneldefs.php') || file_exists('custom/modules/'.$this->module.'/Ext/Layoutdefs/layoutdefs.ext.php'))) {
1024 1024
             $GLOBALS['focus'] = $this->bean;
1025 1025
             require_once ('include/SubPanel/SubPanelTiles.php');
1026 1026
             $subpanel = new SubPanelTiles($this->bean, $this->module);
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
      */
1079 1079
     protected function _checkModule()
1080 1080
     {
1081
-        if(!empty($this->module) && !file_exists('modules/'.$this->module)){
1081
+        if (!empty($this->module) && !file_exists('modules/'.$this->module)) {
1082 1082
             $error = str_replace("[module]", "$this->module", $GLOBALS['app_strings']['ERR_CANNOT_FIND_MODULE']);
1083 1083
             $GLOBALS['log']->fatal($error);
1084 1084
             echo $error;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
     {
1108 1108
         $endTime = microtime(true);
1109 1109
         $deltaTime = $endTime - $GLOBALS['startTime'];
1110
-        $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'] . ' ' . number_format(round($deltaTime, 2), 2) . ' ' . $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1110
+        $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'].' '.number_format(round($deltaTime, 2), 2).' '.$GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1111 1111
         $return = $response_time_string;
1112 1112
        // $return .= '<br />';
1113 1113
         if (!empty($GLOBALS['sugar_config']['show_page_resources'])) {
@@ -1118,16 +1118,16 @@  discard block
 block discarded – undo
1118 1118
             // I believe the full get_include_files result set appears to have one entry for each file in real
1119 1119
             // case, and one entry in all lower case.
1120 1120
             $list_of_files_case_insensitive = array();
1121
-            foreach($included_files as $key => $name) {
1121
+            foreach ($included_files as $key => $name) {
1122 1122
                 // preserve the first capitalization encountered.
1123
-                $list_of_files_case_insensitive[mb_strtolower($name) ] = $name;
1123
+                $list_of_files_case_insensitive[mb_strtolower($name)] = $name;
1124 1124
             }
1125
-            $return .= $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_RESOURCES'] . '(' . DBManager::getQueryCount() . ',' . sizeof($list_of_files_case_insensitive) . ')<br>';
1125
+            $return .= $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_RESOURCES'].'('.DBManager::getQueryCount().','.sizeof($list_of_files_case_insensitive).')<br>';
1126 1126
             // Display performance of the internal and external caches....
1127 1127
             $cacheStats = SugarCache::instance()->getCacheStats();
1128
-            $return .= "External cache (hits/total=ratio) local ({$cacheStats['localHits']}/{$cacheStats['requests']}=" . round($cacheStats['localHits']*100/$cacheStats['requests'], 0) . "%)";
1129
-            $return .= " external ({$cacheStats['externalHits']}/{$cacheStats['requests']}=" . round($cacheStats['externalHits']*100/$cacheStats['requests'], 0) . "%)<br />";
1130
-            $return .= " misses ({$cacheStats['misses']}/{$cacheStats['requests']}=" . round($cacheStats['misses']*100/$cacheStats['requests'], 0) . "%)<br />";
1128
+            $return .= "External cache (hits/total=ratio) local ({$cacheStats['localHits']}/{$cacheStats['requests']}=".round($cacheStats['localHits'] * 100 / $cacheStats['requests'], 0)."%)";
1129
+            $return .= " external ({$cacheStats['externalHits']}/{$cacheStats['requests']}=".round($cacheStats['externalHits'] * 100 / $cacheStats['requests'], 0)."%)<br />";
1130
+            $return .= " misses ({$cacheStats['misses']}/{$cacheStats['requests']}=".round($cacheStats['misses'] * 100 / $cacheStats['requests'], 0)."%)<br />";
1131 1131
         }
1132 1132
 
1133 1133
         $return .= $this->logMemoryStatistics();
@@ -1144,37 +1144,36 @@  discard block
 block discarded – undo
1144 1144
      * @param $newline String of newline character to use (defaults to </ br>)
1145 1145
      * @return $message String formatted message about memory statistics
1146 1146
      */
1147
-    protected function logMemoryStatistics($newline='<br>')
1147
+    protected function logMemoryStatistics($newline = '<br>')
1148 1148
     {
1149 1149
         $log_message = '';
1150 1150
 
1151
-        if(!empty($GLOBALS['sugar_config']['log_memory_usage']))
1151
+        if (!empty($GLOBALS['sugar_config']['log_memory_usage']))
1152 1152
         {
1153
-            if(function_exists('memory_get_usage'))
1153
+            if (function_exists('memory_get_usage'))
1154 1154
             {
1155 1155
                 $memory_usage = memory_get_usage();
1156 1156
                 $bytes = $GLOBALS['app_strings']['LBL_SERVER_MEMORY_BYTES'];
1157 1157
                 $data = array($memory_usage, $bytes);
1158
-                $log_message = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_USAGE'], $data) . $newline;
1158
+                $log_message = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_USAGE'], $data).$newline;
1159 1159
             }
1160 1160
 
1161
-            if(function_exists('memory_get_peak_usage'))
1161
+            if (function_exists('memory_get_peak_usage'))
1162 1162
             {
1163 1163
                 $memory_peak_usage = memory_get_peak_usage();
1164 1164
                 $bytes = $GLOBALS['app_strings']['LBL_SERVER_MEMORY_BYTES'];
1165 1165
                 $data = array($memory_peak_usage, $bytes);
1166
-                $log_message .= string_format($GLOBALS['app_strings']['LBL_SERVER_PEAK_MEMORY_USAGE'], $data) . $newline;
1166
+                $log_message .= string_format($GLOBALS['app_strings']['LBL_SERVER_PEAK_MEMORY_USAGE'], $data).$newline;
1167 1167
             }
1168 1168
 
1169
-            if(!empty($log_message))
1169
+            if (!empty($log_message))
1170 1170
             {
1171
-                $data = array
1172
-                (
1171
+                $data = array(
1173 1172
                    !empty($this->module) ? $this->module : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1174 1173
                    !empty($this->action) ? $this->action : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1175 1174
                 );
1176 1175
 
1177
-                $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data) . $newline;
1176
+                $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data).$newline;
1178 1177
                 $output .= $log_message;
1179 1178
                 $fp = fopen("memory_usage.log", "ab");
1180 1179
                 fwrite($fp, $output);
@@ -1198,30 +1197,30 @@  discard block
 block discarded – undo
1198 1197
     {
1199 1198
         global $current_language, $current_user, $mod_strings, $app_strings, $module_menu;
1200 1199
 
1201
-        if ( empty($module) )
1200
+        if (empty($module))
1202 1201
             $module = $this->module;
1203 1202
 
1204 1203
         //Need to make sure the mod_strings match the requested module or Menus may fail
1205 1204
         $curr_mod_strings = $mod_strings;
1206
-        $mod_strings = return_module_language ( $current_language, $module ) ;
1205
+        $mod_strings = return_module_language($current_language, $module);
1207 1206
 
1208 1207
         $module_menu = array();
1209 1208
 
1210
-        if (file_exists('modules/' . $module . '/Menu.php')) {
1211
-            require('modules/' . $module . '/Menu.php');
1209
+        if (file_exists('modules/'.$module.'/Menu.php')) {
1210
+            require('modules/'.$module.'/Menu.php');
1212 1211
         }
1213
-        if (file_exists('custom/modules/' . $module . '/Ext/Menus/menu.ext.php')) {
1214
-            require('custom/modules/' . $module . '/Ext/Menus/menu.ext.php');
1212
+        if (file_exists('custom/modules/'.$module.'/Ext/Menus/menu.ext.php')) {
1213
+            require('custom/modules/'.$module.'/Ext/Menus/menu.ext.php');
1215 1214
         }
1216
-        if (!file_exists('modules/' . $module . '/Menu.php')
1217
-                && !file_exists('custom/modules/' . $module . '/Ext/Menus/menu.ext.php')
1215
+        if (!file_exists('modules/'.$module.'/Menu.php')
1216
+                && !file_exists('custom/modules/'.$module.'/Ext/Menus/menu.ext.php')
1218 1217
                 && !empty($GLOBALS['mod_strings']['LNK_NEW_RECORD'])) {
1219 1218
             $module_menu[] = array("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView",
1220
-                $GLOBALS['mod_strings']['LNK_NEW_RECORD'],"{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module" ,$module );
1219
+                $GLOBALS['mod_strings']['LNK_NEW_RECORD'], "{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module", $module);
1221 1220
             $module_menu[] = array("index.php?module=$module&action=index", $GLOBALS['mod_strings']['LNK_LIST'],
1222 1221
                 $module, $module);
1223
-            if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) )
1224
-                if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) )
1222
+            if (($this->bean instanceOf SugarBean) && !empty($this->bean->importable))
1223
+                if (!empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]))
1225 1224
                     $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1226 1225
                         $mod_strings['LNK_IMPORT_'.strtoupper($module)], "Import", $module);
1227 1226
                 else
@@ -1248,22 +1247,22 @@  discard block
 block discarded – undo
1248 1247
 
1249 1248
 		$userTabs = query_module_access_list($current_user);
1250 1249
 		//If the home tab is in the user array use it as the default tab, otherwise use the first element in the tab array
1251
-		$defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1250
+		$defaultTab = (in_array("Home", $userTabs)) ? "Home" : key($userTabs);
1252 1251
 		
1253 1252
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
1254
-        if ( !empty($_REQUEST['module_tab']) )
1253
+        if (!empty($_REQUEST['module_tab']))
1255 1254
             return $_REQUEST['module_tab'];
1256
-        elseif ( isset($moduleTabMap[$this->module]) )
1255
+        elseif (isset($moduleTabMap[$this->module]))
1257 1256
             return $moduleTabMap[$this->module];
1258 1257
         // Special cases
1259
-        elseif ( $this->module == 'MergeRecords' )
1258
+        elseif ($this->module == 'MergeRecords')
1260 1259
             return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module'];
1261
-        elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' )
1260
+        elseif ($this->module == 'Users' && $this->action == 'SetTimezone')
1262 1261
             return $defaultTab;
1263 1262
         // Default anonymous pages to be under Home
1264
-        elseif ( !isset($app_list_strings['moduleList'][$this->module]) )
1263
+        elseif (!isset($app_list_strings['moduleList'][$this->module]))
1265 1264
             return $defaultTab;
1266
-        elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" )
1265
+        elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui")
1267 1266
         	return $defaultTab;
1268 1267
         else
1269 1268
             return $this->module;
@@ -1283,42 +1282,42 @@  discard block
 block discarded – undo
1283 1282
 
1284 1283
         $theTitle = "<div class='moduleTitle'>\n";
1285 1284
 
1286
-        $module = preg_replace("/ /","",$this->module);
1285
+        $module = preg_replace("/ /", "", $this->module);
1287 1286
 
1288 1287
         $params = $this->_getModuleTitleParams();
1289 1288
         $index = 0;
1290 1289
 
1291
-		if(SugarThemeRegistry::current()->directionality == "rtl") {
1290
+		if (SugarThemeRegistry::current()->directionality == "rtl") {
1292 1291
 			$params = array_reverse($params);
1293 1292
 		}
1294
-		if(count($params) > 1) {
1293
+		if (count($params) > 1) {
1295 1294
 			array_shift($params);
1296 1295
 		}
1297 1296
 		$count = count($params);
1298 1297
         $paramString = '';
1299
-        foreach($params as $parm){
1298
+        foreach ($params as $parm) {
1300 1299
             $index++;
1301 1300
             $paramString .= $parm;
1302
-            if($index < $count){
1301
+            if ($index < $count) {
1303 1302
                 $paramString .= $this->getBreadCrumbSymbol();
1304 1303
             }
1305 1304
         }
1306 1305
 
1307
-        if(!empty($paramString)){
1306
+        if (!empty($paramString)) {
1308 1307
                $theTitle .= "<h2> $paramString </h2>";
1309 1308
 
1310
-            if($this->type == "detail"){
1311
-                $theTitle .= "<div class='favorite' record_id='" . $this->bean->id . "' module='" . $this->bean->module_dir . "'><div class='favorite_icon_outline'>" . SugarThemeRegistry::current()->getImage('favorite-star-outline','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div>
1312
-                                                    <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div></div>";
1309
+            if ($this->type == "detail") {
1310
+                $theTitle .= "<div class='favorite' record_id='".$this->bean->id."' module='".$this->bean->module_dir."'><div class='favorite_icon_outline'>".SugarThemeRegistry::current()->getImage('favorite-star-outline', 'title="'.translate('LBL_DASHLET_EDIT', 'Home').'" border="0"  align="absmiddle"', null, null, '.gif', translate('LBL_DASHLET_EDIT', 'Home'))."</div>
1311
+                                                    <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star', 'title="'.translate('LBL_DASHLET_EDIT', 'Home').'" border="0"  align="absmiddle"', null, null, '.gif', translate('LBL_DASHLET_EDIT', 'Home'))."</div></div>";
1313 1312
             }
1314 1313
            }
1315 1314
 
1316 1315
         // bug 56131 - restore conditional so that link doesn't appear where it shouldn't
1317
-        if($show_help || $this->type == 'list') {
1316
+        if ($show_help || $this->type == 'list') {
1318 1317
             $theTitle .= "<span class='utils'>";
1319 1318
             $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
1320
-            if($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>';$url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1321
-            if($show_help) {
1319
+            if ($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>'; $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1320
+            if ($show_help) {
1322 1321
                 $theTitle .= <<<EOHTML
1323 1322
 &nbsp;
1324 1323
 <a id="create_image" href="{$url}" class="utilsLink">
@@ -1344,31 +1343,31 @@  discard block
 block discarded – undo
1344 1343
     {
1345 1344
         $metadataFile = null;
1346 1345
         $foundViewDefs = false;
1347
-        $viewDef = strtolower($this->type) . 'viewdefs';
1348
-        $coreMetaPath = 'modules/'.$this->module.'/metadata/' . $viewDef . '.php';
1349
-        if(file_exists('custom/' .$coreMetaPath )){
1350
-            $metadataFile = 'custom/' . $coreMetaPath;
1346
+        $viewDef = strtolower($this->type).'viewdefs';
1347
+        $coreMetaPath = 'modules/'.$this->module.'/metadata/'.$viewDef.'.php';
1348
+        if (file_exists('custom/'.$coreMetaPath)) {
1349
+            $metadataFile = 'custom/'.$coreMetaPath;
1351 1350
             $foundViewDefs = true;
1352
-        }else{
1353
-            if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
1351
+        } else {
1352
+            if (file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')) {
1354 1353
                 require_once('custom/modules/'.$this->module.'/metadata/metafiles.php');
1355
-                if(!empty($metafiles[$this->module][$viewDef])){
1354
+                if (!empty($metafiles[$this->module][$viewDef])) {
1356 1355
                     $metadataFile = $metafiles[$this->module][$viewDef];
1357 1356
                     $foundViewDefs = true;
1358 1357
                 }
1359
-            }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
1358
+            }elseif (file_exists('modules/'.$this->module.'/metadata/metafiles.php')) {
1360 1359
                 require_once('modules/'.$this->module.'/metadata/metafiles.php');
1361
-                if(!empty($metafiles[$this->module][$viewDef])){
1360
+                if (!empty($metafiles[$this->module][$viewDef])) {
1362 1361
                     $metadataFile = $metafiles[$this->module][$viewDef];
1363 1362
                     $foundViewDefs = true;
1364 1363
                 }
1365 1364
             }
1366 1365
         }
1367 1366
 
1368
-        if(!$foundViewDefs && file_exists($coreMetaPath)){
1367
+        if (!$foundViewDefs && file_exists($coreMetaPath)) {
1369 1368
                 $metadataFile = $coreMetaPath;
1370 1369
         }
1371
-        $GLOBALS['log']->debug("metadatafile=". $metadataFile);
1370
+        $GLOBALS['log']->debug("metadatafile=".$metadataFile);
1372 1371
 
1373 1372
         return $metadataFile;
1374 1373
     }
@@ -1385,10 +1384,10 @@  discard block
 block discarded – undo
1385 1384
     {
1386 1385
         $params = array($this->_getModuleTitleListParam($browserTitle));
1387 1386
 		//$params = array();
1388
-        if (isset($this->action)){
1387
+        if (isset($this->action)) {
1389 1388
             switch ($this->action) {
1390 1389
             case 'EditView':
1391
-                if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1390
+                if (!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1392 1391
                     $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1393 1392
                     $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1394 1393
                 }
@@ -1412,18 +1411,18 @@  discard block
 block discarded – undo
1412 1411
      *                           there should be no HTML in the string
1413 1412
      * @return string
1414 1413
      */
1415
-    protected function _getModuleTitleListParam( $browserTitle = false )
1414
+    protected function _getModuleTitleListParam($browserTitle = false)
1416 1415
     {
1417 1416
     	global $current_user;
1418 1417
     	global $app_strings;
1419 1418
 
1420
-    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1419
+    	if (!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1421 1420
     		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1422 1421
     	else
1423 1422
     		$firstParam = $this->module;
1424 1423
 
1425 1424
     	$iconPath = $this->getModuleTitleIconPath($this->module);
1426
-    	if($this->action == "ListView" || $this->action == "index") {
1425
+    	if ($this->action == "ListView" || $this->action == "index") {
1427 1426
     	    if (!empty($iconPath) && !$browserTitle) {
1428 1427
     	    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1429 1428
     	    		return $app_strings['LBL_SEARCH']."&nbsp;"
@@ -1449,10 +1448,10 @@  discard block
 block discarded – undo
1449 1448
     protected function getModuleTitleIconPath($module)
1450 1449
     {
1451 1450
     	$iconPath = "";
1452
-    	if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1451
+    	if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png', false))) {
1453 1452
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1454 1453
     	}
1455
-    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1454
+    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png', false))) {
1456 1455
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1457 1456
     	}
1458 1457
     	return $iconPath;
@@ -1469,11 +1468,11 @@  discard block
 block discarded – undo
1469 1468
         global $app_strings;
1470 1469
 
1471 1470
         $browserTitle = $app_strings['LBL_BROWSER_TITLE'];
1472
-        if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') )
1471
+        if ($this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login'))
1473 1472
             return $browserTitle;
1474 1473
         $params = $this->_getModuleTitleParams(true);
1475
-        foreach ($params as $value )
1476
-            $browserTitle = strip_tags($value) . ' &raquo; ' . $browserTitle;
1474
+        foreach ($params as $value)
1475
+            $browserTitle = strip_tags($value).' &raquo; '.$browserTitle;
1477 1476
 
1478 1477
         return $browserTitle;
1479 1478
     }
@@ -1485,7 +1484,7 @@  discard block
 block discarded – undo
1485 1484
      */
1486 1485
     public function getBreadCrumbSymbol()
1487 1486
     {
1488
-    	if(SugarThemeRegistry::current()->directionality == "ltr") {
1487
+    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1489 1488
         	return "<span class='pointer'>&raquo;</span>";
1490 1489
         }
1491 1490
         else {
@@ -1498,29 +1497,29 @@  discard block
 block discarded – undo
1498 1497
      *
1499 1498
      * @return array
1500 1499
      */
1501
-    protected function getSugarConfigJS(){
1500
+    protected function getSugarConfigJS() {
1502 1501
         global $sugar_config;
1503 1502
 
1504 1503
         // Set all the config parameters in the JS config as necessary
1505 1504
         $config_js = array();
1506 1505
         // AjaxUI stock banned modules
1507 1506
         $config_js[] = "SUGAR.config.stockAjaxBannedModules = ".json_encode(ajaxBannedModules()).";";
1508
-        if ( isset($sugar_config['quicksearch_querydelay']) ) {
1507
+        if (isset($sugar_config['quicksearch_querydelay'])) {
1509 1508
             $config_js[] = $this->prepareConfigVarForJs('quicksearch_querydelay', $sugar_config['quicksearch_querydelay']);
1510 1509
         }
1511
-        if ( empty($sugar_config['disableAjaxUI']) ) {
1510
+        if (empty($sugar_config['disableAjaxUI'])) {
1512 1511
             $config_js[] = "SUGAR.config.disableAjaxUI = false;";
1513 1512
         }
1514
-        else{
1513
+        else {
1515 1514
             $config_js[] = "SUGAR.config.disableAjaxUI = true;";
1516 1515
         }
1517
-        if ( !empty($sugar_config['addAjaxBannedModules']) ){
1516
+        if (!empty($sugar_config['addAjaxBannedModules'])) {
1518 1517
             $config_js[] = $this->prepareConfigVarForJs('addAjaxBannedModules', $sugar_config['addAjaxBannedModules']);
1519 1518
         }
1520
-        if ( !empty($sugar_config['overrideAjaxBannedModules']) ){
1519
+        if (!empty($sugar_config['overrideAjaxBannedModules'])) {
1521 1520
             $config_js[] = $this->prepareConfigVarForJs('overrideAjaxBannedModules', $sugar_config['overrideAjaxBannedModules']);
1522 1521
         }
1523
-        if (!empty($sugar_config['js_available']) && is_array ($sugar_config['js_available']))
1522
+        if (!empty($sugar_config['js_available']) && is_array($sugar_config['js_available']))
1524 1523
         {
1525 1524
             foreach ($sugar_config['js_available'] as $configKey)
1526 1525
             {
@@ -1581,7 +1580,7 @@  discard block
 block discarded – undo
1581 1580
     protected function getFavicon()
1582 1581
     {
1583 1582
         // get favicon
1584
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
1583
+        if (isset($GLOBALS['sugar_config']['default_module_favicon']))
1585 1584
             $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
1586 1585
         else
1587 1586
             $module_favicon = false;
@@ -1589,10 +1588,10 @@  discard block
 block discarded – undo
1589 1588
         $themeObject = SugarThemeRegistry::current();
1590 1589
 
1591 1590
         $favicon = '';
1592
-        if ( $module_favicon )
1593
-            $favicon = $themeObject->getImageURL($this->module.'.gif',false);
1594
-        if ( !sugar_is_file($favicon) || !$module_favicon )
1595
-            $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
1591
+        if ($module_favicon)
1592
+            $favicon = $themeObject->getImageURL($this->module.'.gif', false);
1593
+        if (!sugar_is_file($favicon) || !$module_favicon)
1594
+            $favicon = $themeObject->getImageURL('sugar_icon.ico', false);
1596 1595
 
1597 1596
         $extension = pathinfo($favicon, PATHINFO_EXTENSION);
1598 1597
         switch ($extension)
@@ -1649,10 +1648,10 @@  discard block
 block discarded – undo
1649 1648
      * @return array augmented history with image link and shortened name
1650 1649
      */
1651 1650
     protected function processRecentRecords($history) {
1652
-        foreach ( $history as $key => $row ) {
1651
+        foreach ($history as $key => $row) {
1653 1652
             $history[$key]['item_summary_short'] = to_html(getTrackerSubstring($row['item_summary'])); //bug 56373 - need to re-HTML-encode
1654 1653
             $history[$key]['image'] = SugarThemeRegistry::current()
1655
-                ->getImage($row['module_name'],'border="0" align="absmiddle"',null,null,'.gif',$row['item_summary']);
1654
+                ->getImage($row['module_name'], 'border="0" align="absmiddle"', null, null, '.gif', $row['item_summary']);
1656 1655
         }
1657 1656
         return $history;
1658 1657
     }
@@ -1666,10 +1665,10 @@  discard block
 block discarded – undo
1666 1665
      *
1667 1666
 	 * @return boolean indicating true or false
1668 1667
 	 */
1669
-    public function checkPostMaxSizeError(){
1668
+    public function checkPostMaxSizeError() {
1670 1669
          //if the referrer is post, and the post array is empty, then an error has occurred, most likely
1671 1670
          //while uploading a file that exceeds the post_max_size.
1672
-         if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
1671
+         if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
1673 1672
              $GLOBALS['log']->fatal($GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT']);
1674 1673
              return true;
1675 1674
         }
Please login to merge, or discard this patch.
Braces   +131 added lines, -105 removed lines patch added patch discarded remove patch
@@ -161,13 +161,17 @@  discard block
 block discarded – undo
161 161
             echo $jsAlerts->getScript();
162 162
         }
163 163
 
164
-        if ($this->_getOption('show_subpanels') && !empty($_REQUEST['record'])) $this->_displaySubPanels();
164
+        if ($this->_getOption('show_subpanels') && !empty($_REQUEST['record'])) {
165
+            $this->_displaySubPanels();
166
+        }
165 167
 
166 168
         if ($this->action === 'Login') {
167 169
             //this is needed for a faster loading login page ie won't render unless the tables are closed
168 170
             ob_flush();
169 171
         }
170
-        if ($this->_getOption('show_footer')) $this->displayFooter();
172
+        if ($this->_getOption('show_footer')) {
173
+            $this->displayFooter();
174
+        }
171 175
         $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_footer');
172 176
         if ($this->_getOption('json_output'))
173 177
         {
@@ -186,11 +190,13 @@  discard block
 block discarded – undo
186 190
                 'favicon' => $this->getFavicon(),
187 191
             );
188 192
 
189
-            if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
190
-                $ajax_ret['moduleList'] = $this->displayHeader(true);
193
+            if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic) {
194
+                            $ajax_ret['moduleList'] = $this->displayHeader(true);
195
+            }
191 196
 
192
-            if(empty($this->responseTime))
193
-                $this->_calculateFooterMetrics();
197
+            if(empty($this->responseTime)) {
198
+                            $this->_calculateFooterMetrics();
199
+            }
194 200
             $ajax_ret['responseTime'] = $this->responseTime;
195 201
             $json = getJSONobj();
196 202
             echo $json->encode($ajax_ret);
@@ -214,8 +220,7 @@  discard block
 block discarded – undo
214 220
 
215 221
         if ( !$this->suppressDisplayErrors ) {
216 222
             echo $errors;
217
-        }
218
-        else {
223
+        } else {
219 224
             return $errors;
220 225
         }
221 226
     }
@@ -329,24 +334,26 @@  discard block
 block discarded – undo
329 334
         ob_end_clean();
330 335
 
331 336
         // get favicon
332
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
333
-            $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
334
-        else
335
-            $module_favicon = false;
337
+        if(isset($GLOBALS['sugar_config']['default_module_favicon'])) {
338
+                    $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
339
+        } else {
340
+                    $module_favicon = false;
341
+        }
336 342
 
337 343
         $favicon = $this->getFavicon();
338 344
         $ss->assign('FAVICON_URL', $favicon['url']);
339 345
 
340 346
         // build the shortcut menu
341 347
         $shortcut_menu = array();
342
-        foreach ( $this->getMenu() as $key => $menu_item )
343
-            $shortcut_menu[$key] = array(
348
+        foreach ( $this->getMenu() as $key => $menu_item ) {
349
+                    $shortcut_menu[$key] = array(
344 350
                 "URL"         => $menu_item[0],
345 351
                 "LABEL"       => $menu_item[1],
346 352
                 "MODULE_NAME" => $menu_item[2],
347 353
                 "IMAGE"       => $themeObject
348 354
                     ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
349 355
                 );
356
+        }
350 357
         $ss->assign("SHORTCUT_MENU",$shortcut_menu);
351 358
 
352 359
         // handle rtl text direction
@@ -370,8 +377,7 @@  discard block
 block discarded – undo
370 377
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
371 378
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
372 379
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
373
-        }
374
-        else {
380
+        } else {
375 381
             // Always need to md5 the file
376 382
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
377 383
 
@@ -379,14 +385,14 @@  discard block
 block discarded – undo
379 385
             if ( $width > 212 || $height > 40 ) {
380 386
                 $resizePctWidth  = ($width - 212)/212;
381 387
                 $resizePctHeight = ($height - 40)/40;
382
-                if ( $resizePctWidth > $resizePctHeight )
383
-                    $resizeAmount = $width / 212;
384
-                else
385
-                    $resizeAmount = $height / 40;
388
+                if ( $resizePctWidth > $resizePctHeight ) {
389
+                                    $resizeAmount = $width / 212;
390
+                } else {
391
+                                    $resizeAmount = $height / 40;
392
+                }
386 393
                 $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
387 394
                 $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
388
-            }
389
-            else {
395
+            } else {
390 396
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
391 397
                 $ss->assign("COMPANY_LOGO_HEIGHT", $height);
392 398
             }
@@ -429,11 +435,12 @@  discard block
 block discarded – undo
429 435
                 }
430 436
                 // and now the sublinks
431 437
                 if ( $linkattribute == 'submenu' && is_array($attributevalue) ) {
432
-                    foreach ($attributevalue as $submenulinkkey => $submenulinkinfo)
433
-                        $gcls[$key]['SUBMENU'][$submenulinkkey] = array(
438
+                    foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) {
439
+                                            $gcls[$key]['SUBMENU'][$submenulinkkey] = array(
434 440
                             "LABEL" => key($submenulinkinfo),
435 441
                             "URL"   => current($submenulinkinfo),
436 442
                         );
443
+                    }
437 444
                        if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438 445
                            $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
439 446
                            $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
@@ -445,8 +452,9 @@  discard block
 block discarded – undo
445 452
 
446 453
         $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
447 454
 
448
-        if ($this->action == "EditView" || $this->action == "Login")
449
-            $ss->assign("ONLOAD", 'onload="set_focus()"');
455
+        if ($this->action == "EditView" || $this->action == "Login") {
456
+                    $ss->assign("ONLOAD", 'onload="set_focus()"');
457
+        }
450 458
 
451 459
         $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
452 460
 
@@ -506,8 +514,7 @@  discard block
 block discarded – undo
506 514
                 foreach($frames as $key => $values){
507 515
                         $fullModuleList[$key] = $values;
508 516
                 }
509
-            }
510
-            elseif (isset($fullModuleList['iFrames'])) {
517
+            } elseif (isset($fullModuleList['iFrames'])) {
511 518
                 unset($fullModuleList['iFrames']);
512 519
             }
513 520
 
@@ -523,8 +530,7 @@  discard block
 block discarded – undo
523 530
                     // We have a default value. Use it
524 531
                     if(isset($GLOBALS['sugar_config']['default_max_tabs'])){
525 532
                         $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
526
-                    }
527
-                    else{
533
+                    } else{
528 534
                         $max_tabs = 8;
529 535
                     }
530 536
                 }
@@ -633,7 +639,9 @@  discard block
 block discarded – undo
633 639
                         );
634 640
                 }
635 641
             }
636
-            if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
642
+            if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) {
643
+                $ss->assign('lock_homepage', true);
644
+            }
637 645
             $ss->assign("groupTabs",$groupTabs);
638 646
             $ss->assign("shortcutTopMenu",$shortcutTopMenu);
639 647
             $ss->assign('USE_GROUP_TABS',$usingGroupTabs);
@@ -676,8 +684,9 @@  discard block
 block discarded – undo
676 684
         global $mod_strings;
677 685
         $mod_strings = $bakModStrings;
678 686
         $headerTpl = $themeObject->getTemplate('header.tpl');
679
-        if (inDeveloperMode() )
680
-            $ss->clear_compiled_tpl($headerTpl);
687
+        if (inDeveloperMode() ) {
688
+                    $ss->clear_compiled_tpl($headerTpl);
689
+        }
681 690
 
682 691
         if ($retModTabs)
683 692
         {
@@ -716,8 +725,9 @@  discard block
 block discarded – undo
716 725
         global $gridline, $request_string, $modListHeader, $dashletData, $authController, $locale, $currentModule, $import_bean_map, $image_path, $license;
717 726
         global $user_unique_key, $server_unique_key, $barChartColors, $modules_exempt_from_availability_check, $dictionary, $current_language, $beanList, $beanFiles, $sugar_build, $sugar_codename;
718 727
         global $timedate, $login_error; // cn: bug 13855 - timedate not available to classic views.
719
-        if (!empty($this->module))
720
-            $currentModule = $this->module;
728
+        if (!empty($this->module)) {
729
+                    $currentModule = $this->module;
730
+        }
721 731
         require_once ($file);
722 732
     }
723 733
 
@@ -747,8 +757,9 @@  discard block
 block discarded – undo
747 757
             if ( typeof(SUGAR.themes) == 'undefined' ) SUGAR.themes = {};
748 758
         </script>
749 759
 EOQ;
750
-        if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
751
-            echo getVersionedScript('modules/Sync/headersync.js');
760
+        if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) {
761
+                    echo getVersionedScript('modules/Sync/headersync.js');
762
+        }
752 763
     }
753 764
 
754 765
     /**
@@ -849,8 +860,9 @@  discard block
 block discarded – undo
849 860
 
850 861
 			echo $this->_getModLanguageJS();
851 862
 
852
-            if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
853
-                echo getVersionedScript('modules/Sync/headersync.js');
863
+            if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) {
864
+                            echo getVersionedScript('modules/Sync/headersync.js');
865
+            }
854 866
 
855 867
 
856 868
             //echo out the $js_vars variables as javascript variables
@@ -917,8 +929,9 @@  discard block
 block discarded – undo
917 929
 			}
918 930
 		}
919 931
 		$ss->assign("BOTTOMLINKS",$bottomLinksStr);
920
-        if (SugarConfig::getInstance()->get('calculate_response_time', false))
921
-            $ss->assign('STATISTICS',$this->_getStatistics());
932
+        if (SugarConfig::getInstance()->get('calculate_response_time', false)) {
933
+                    $ss->assign('STATISTICS',$this->_getStatistics());
934
+        }
922 935
 
923 936
         // Under the License referenced above, you are required to leave in all copyright statements in both
924 937
         // the code and end-user application.
@@ -956,8 +969,7 @@  discard block
 block discarded – undo
956 969
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
957 970
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
958 971
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
959
-        }
960
-        else {
972
+        } else {
961 973
             // Always need to md5 the file
962 974
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
963 975
 
@@ -965,14 +977,14 @@  discard block
 block discarded – undo
965 977
             if ( $width > 212 || $height > 40 ) {
966 978
                 $resizePctWidth  = ($width - 212)/212;
967 979
                 $resizePctHeight = ($height - 40)/40;
968
-                if ( $resizePctWidth > $resizePctHeight )
969
-                    $resizeAmount = $width / 212;
970
-                else
971
-                    $resizeAmount = $height / 40;
980
+                if ( $resizePctWidth > $resizePctHeight ) {
981
+                                    $resizeAmount = $width / 212;
982
+                } else {
983
+                                    $resizeAmount = $height / 40;
984
+                }
972 985
                 $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
973 986
                 $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
974
-            }
975
-            else {
987
+            } else {
976 988
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
977 989
                 $ss->assign("COMPANY_LOGO_HEIGHT", $height);
978 990
             }
@@ -1030,8 +1042,9 @@  discard block
 block discarded – undo
1030 1042
 
1031 1043
     protected function _buildModuleList()
1032 1044
     {
1033
-        if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
1034
-            $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
1045
+        if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader'])) {
1046
+                    $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
1047
+        }
1035 1048
     }
1036 1049
 
1037 1050
     /**
@@ -1051,7 +1064,9 @@  discard block
 block discarded – undo
1051 1064
             return $this->options['show_all'];
1052 1065
         } elseif (!empty($this->options) && isset($this->options[$option])) {
1053 1066
             return $this->options[$option];
1054
-        } else return $default;
1067
+        } else {
1068
+            return $default;
1069
+        }
1055 1070
     }
1056 1071
 
1057 1072
     /**
@@ -1088,10 +1103,11 @@  discard block
 block discarded – undo
1088 1103
 
1089 1104
     public function renderJavascript()
1090 1105
     {
1091
-        if ($this->action !== 'Login')
1092
-            $this->_displayJavascript();
1093
-        else
1094
-            $this->_displayLoginJS();
1106
+        if ($this->action !== 'Login') {
1107
+                    $this->_displayJavascript();
1108
+        } else {
1109
+                    $this->_displayLoginJS();
1110
+        }
1095 1111
     }
1096 1112
 
1097 1113
     private function _calculateFooterMetrics()
@@ -1198,8 +1214,9 @@  discard block
 block discarded – undo
1198 1214
     {
1199 1215
         global $current_language, $current_user, $mod_strings, $app_strings, $module_menu;
1200 1216
 
1201
-        if ( empty($module) )
1202
-            $module = $this->module;
1217
+        if ( empty($module) ) {
1218
+                    $module = $this->module;
1219
+        }
1203 1220
 
1204 1221
         //Need to make sure the mod_strings match the requested module or Menus may fail
1205 1222
         $curr_mod_strings = $mod_strings;
@@ -1220,13 +1237,14 @@  discard block
 block discarded – undo
1220 1237
                 $GLOBALS['mod_strings']['LNK_NEW_RECORD'],"{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module" ,$module );
1221 1238
             $module_menu[] = array("index.php?module=$module&action=index", $GLOBALS['mod_strings']['LNK_LIST'],
1222 1239
                 $module, $module);
1223
-            if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) )
1224
-                if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) )
1240
+            if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) ) {
1241
+                            if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) )
1225 1242
                     $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1226 1243
                         $mod_strings['LNK_IMPORT_'.strtoupper($module)], "Import", $module);
1227
-                else
1228
-                    $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1244
+            } else {
1245
+                                    $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1229 1246
                         $app_strings['LBL_IMPORT'], "Import", $module);
1247
+                }
1230 1248
         }
1231 1249
         if (file_exists('custom/application/Ext/Menus/menu.ext.php')) {
1232 1250
             require('custom/application/Ext/Menus/menu.ext.php');
@@ -1251,22 +1269,25 @@  discard block
 block discarded – undo
1251 1269
 		$defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1252 1270
 		
1253 1271
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
1254
-        if ( !empty($_REQUEST['module_tab']) )
1255
-            return $_REQUEST['module_tab'];
1256
-        elseif ( isset($moduleTabMap[$this->module]) )
1257
-            return $moduleTabMap[$this->module];
1272
+        if ( !empty($_REQUEST['module_tab']) ) {
1273
+                    return $_REQUEST['module_tab'];
1274
+        } elseif ( isset($moduleTabMap[$this->module]) ) {
1275
+                    return $moduleTabMap[$this->module];
1276
+        }
1258 1277
         // Special cases
1259
-        elseif ( $this->module == 'MergeRecords' )
1260
-            return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module'];
1261
-        elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' )
1262
-            return $defaultTab;
1278
+        elseif ( $this->module == 'MergeRecords' ) {
1279
+                    return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module'];
1280
+        } elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' ) {
1281
+                    return $defaultTab;
1282
+        }
1263 1283
         // Default anonymous pages to be under Home
1264
-        elseif ( !isset($app_list_strings['moduleList'][$this->module]) )
1265
-            return $defaultTab;
1266
-        elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" )
1267
-        	return $defaultTab;
1268
-        else
1269
-            return $this->module;
1284
+        elseif ( !isset($app_list_strings['moduleList'][$this->module]) ) {
1285
+                    return $defaultTab;
1286
+        } elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" ) {
1287
+                	return $defaultTab;
1288
+        } else {
1289
+                    return $this->module;
1290
+        }
1270 1291
     }
1271 1292
 
1272 1293
    /**
@@ -1317,7 +1338,10 @@  discard block
 block discarded – undo
1317 1338
         if($show_help || $this->type == 'list') {
1318 1339
             $theTitle .= "<span class='utils'>";
1319 1340
             $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
1320
-            if($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>';$url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1341
+            if($this->type == 'list') {
1342
+                $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>';
1343
+            }
1344
+            $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1321 1345
             if($show_help) {
1322 1346
                 $theTitle .= <<<EOHTML
1323 1347
 &nbsp;
@@ -1349,14 +1373,14 @@  discard block
 block discarded – undo
1349 1373
         if(file_exists('custom/' .$coreMetaPath )){
1350 1374
             $metadataFile = 'custom/' . $coreMetaPath;
1351 1375
             $foundViewDefs = true;
1352
-        }else{
1376
+        } else{
1353 1377
             if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
1354 1378
                 require_once('custom/modules/'.$this->module.'/metadata/metafiles.php');
1355 1379
                 if(!empty($metafiles[$this->module][$viewDef])){
1356 1380
                     $metadataFile = $metafiles[$this->module][$viewDef];
1357 1381
                     $foundViewDefs = true;
1358 1382
                 }
1359
-            }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
1383
+            } elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
1360 1384
                 require_once('modules/'.$this->module.'/metadata/metafiles.php');
1361 1385
                 if(!empty($metafiles[$this->module][$viewDef])){
1362 1386
                     $metadataFile = $metafiles[$this->module][$viewDef];
@@ -1391,9 +1415,9 @@  discard block
 block discarded – undo
1391 1415
                 if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1392 1416
                     $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1393 1417
                     $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1418
+                } else {
1419
+                                    $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1394 1420
                 }
1395
-                else
1396
-                    $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1397 1421
                 break;
1398 1422
             case 'DetailView':
1399 1423
                 $beanName = $this->bean->get_summary_text();
@@ -1417,10 +1441,11 @@  discard block
 block discarded – undo
1417 1441
     	global $current_user;
1418 1442
     	global $app_strings;
1419 1443
 
1420
-    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1421
-    		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1422
-    	else
1423
-    		$firstParam = $this->module;
1444
+    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module])) {
1445
+    	    		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1446
+    	} else {
1447
+    	    		$firstParam = $this->module;
1448
+    	}
1424 1449
 
1425 1450
     	$iconPath = $this->getModuleTitleIconPath($this->module);
1426 1451
     	if($this->action == "ListView" || $this->action == "index") {
@@ -1436,8 +1461,7 @@  discard block
 block discarded – undo
1436 1461
 			} else {
1437 1462
 				return $firstParam;
1438 1463
 			}
1439
-    	}
1440
-    	else {
1464
+    	} else {
1441 1465
 		    if (!empty($iconPath) && !$browserTitle) {
1442 1466
 				//return "<a href='index.php?module={$this->module}&action=index'>$this->module</a>";
1443 1467
 			} else {
@@ -1451,8 +1475,7 @@  discard block
 block discarded – undo
1451 1475
     	$iconPath = "";
1452 1476
     	if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1453 1477
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1454
-    	}
1455
-    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1478
+    	} else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1456 1479
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1457 1480
     	}
1458 1481
     	return $iconPath;
@@ -1469,11 +1492,13 @@  discard block
 block discarded – undo
1469 1492
         global $app_strings;
1470 1493
 
1471 1494
         $browserTitle = $app_strings['LBL_BROWSER_TITLE'];
1472
-        if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') )
1473
-            return $browserTitle;
1495
+        if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') ) {
1496
+                    return $browserTitle;
1497
+        }
1474 1498
         $params = $this->_getModuleTitleParams(true);
1475
-        foreach ($params as $value )
1476
-            $browserTitle = strip_tags($value) . ' &raquo; ' . $browserTitle;
1499
+        foreach ($params as $value ) {
1500
+                    $browserTitle = strip_tags($value) . ' &raquo; ' . $browserTitle;
1501
+        }
1477 1502
 
1478 1503
         return $browserTitle;
1479 1504
     }
@@ -1487,8 +1512,7 @@  discard block
 block discarded – undo
1487 1512
     {
1488 1513
     	if(SugarThemeRegistry::current()->directionality == "ltr") {
1489 1514
         	return "<span class='pointer'>&raquo;</span>";
1490
-        }
1491
-        else {
1515
+        } else {
1492 1516
         	return "<span class='pointer'>&laquo;</span>";
1493 1517
         }
1494 1518
     }
@@ -1510,8 +1534,7 @@  discard block
 block discarded – undo
1510 1534
         }
1511 1535
         if ( empty($sugar_config['disableAjaxUI']) ) {
1512 1536
             $config_js[] = "SUGAR.config.disableAjaxUI = false;";
1513
-        }
1514
-        else{
1537
+        } else{
1515 1538
             $config_js[] = "SUGAR.config.disableAjaxUI = true;";
1516 1539
         }
1517 1540
         if ( !empty($sugar_config['addAjaxBannedModules']) ){
@@ -1581,18 +1604,21 @@  discard block
 block discarded – undo
1581 1604
     protected function getFavicon()
1582 1605
     {
1583 1606
         // get favicon
1584
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
1585
-            $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
1586
-        else
1587
-            $module_favicon = false;
1607
+        if(isset($GLOBALS['sugar_config']['default_module_favicon'])) {
1608
+                    $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
1609
+        } else {
1610
+                    $module_favicon = false;
1611
+        }
1588 1612
 
1589 1613
         $themeObject = SugarThemeRegistry::current();
1590 1614
 
1591 1615
         $favicon = '';
1592
-        if ( $module_favicon )
1593
-            $favicon = $themeObject->getImageURL($this->module.'.gif',false);
1594
-        if ( !sugar_is_file($favicon) || !$module_favicon )
1595
-            $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
1616
+        if ( $module_favicon ) {
1617
+                    $favicon = $themeObject->getImageURL($this->module.'.gif',false);
1618
+        }
1619
+        if ( !sugar_is_file($favicon) || !$module_favicon ) {
1620
+                    $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
1621
+        }
1596 1622
 
1597 1623
         $extension = pathinfo($favicon, PATHINFO_EXTENSION);
1598 1624
         switch ($extension)
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1039,6 +1039,7 @@  discard block
 block discarded – undo
1039 1039
      *
1040 1040
      * @param string option - the option that we want to know the valye of
1041 1041
      * @param bool default - what the default value should be if we do not find the option
1042
+     * @param string $option
1042 1043
      *
1043 1044
      * @return bool - the value of the option
1044 1045
      */
@@ -1273,7 +1274,7 @@  discard block
 block discarded – undo
1273 1274
     * Return the "breadcrumbs" to display at the top of the page
1274 1275
     *
1275 1276
     * @param  bool $show_help optional, true if we show the help links
1276
-    * @return HTML string containing breadcrumb title
1277
+    * @return string string containing breadcrumb title
1277 1278
     */
1278 1279
     public function getModuleTitle(
1279 1280
         $show_help = true
@@ -1446,6 +1447,9 @@  discard block
 block discarded – undo
1446 1447
     	}
1447 1448
     }
1448 1449
 
1450
+    /**
1451
+     * @param string $module
1452
+     */
1449 1453
     protected function getModuleTitleIconPath($module)
1450 1454
     {
1451 1455
     	$iconPath = "";
@@ -1496,7 +1500,7 @@  discard block
 block discarded – undo
1496 1500
     /**
1497 1501
      * Fetch config values to be put into an array for JavaScript
1498 1502
      *
1499
-     * @return array
1503
+     * @return string[]
1500 1504
      */
1501 1505
     protected function getSugarConfigJS(){
1502 1506
         global $sugar_config;
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 
126 126
         //For the ajaxUI, we need to use output buffering to return the page in an ajax friendly format
127 127
         if ($this->_getOption('json_output')){
128
-			ob_start();
129
-			if(!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
130
-				echo $this->_getModLanguageJS();
131
-			}
132
-		}
128
+            ob_start();
129
+            if(!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
130
+                echo $this->_getModLanguageJS();
131
+            }
132
+        }
133 133
 
134 134
         if ($this->_getOption('show_header')) {
135 135
             $this->displayHeader();
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
             $module = $this->module;
176 176
             $ajax_ret = array(
177 177
                 'content' => mb_detect_encoding($content) == "UTF-8" ? $content : utf8_encode($content),
178
-                 'menu' => array(
179
-                     'module' => $module,
180
-                     'label' => translate($module),
181
-                     $this->getMenu($module),
182
-                 ),
178
+                    'menu' => array(
179
+                        'module' => $module,
180
+                        'label' => translate($module),
181
+                        $this->getMenu($module),
182
+                    ),
183 183
                 'title' => $this->getBrowserTitle(),
184 184
                 'action' => isset($_REQUEST['action']) ? $_REQUEST['action'] : "",
185 185
                 'record' => isset($_REQUEST['record']) ? $_REQUEST['record'] : "",
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
                         "URL"   => current($attributevalue),
423 423
                         "SUBMENU" => array(),
424 424
                         );
425
-                   if(substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
-                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"],11);
427
-                       $gcls[$key]["URL"] = "javascript:void(0)";
428
-                   }
425
+                    if(substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
+                        $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"],11);
427
+                        $gcls[$key]["URL"] = "javascript:void(0)";
428
+                    }
429 429
                 }
430 430
                 // and now the sublinks
431 431
                 if ( $linkattribute == 'submenu' && is_array($attributevalue) ) {
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
                             "LABEL" => key($submenulinkinfo),
435 435
                             "URL"   => current($submenulinkinfo),
436 436
                         );
437
-                       if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
-                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
439
-                           $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
440
-                       }
437
+                        if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
+                            $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
439
+                            $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
440
+                        }
441 441
                 }
442 442
             }
443 443
         }
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
             $ss->assign("shortcutExtraMenu",$shortcutExtraMenu);
666 666
         }
667 667
 
668
-       if(!empty($current_user)){
669
-       	$ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
670
-       }
668
+        if(!empty($current_user)){
669
+            $ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
670
+        }
671 671
 
672 672
 
673 673
         $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
674 674
         $homeImage = "<img src='$imageURL'>";
675
-		$ss->assign("homeImage",$homeImage);
675
+        $ss->assign("homeImage",$homeImage);
676 676
         global $mod_strings;
677 677
         $mod_strings = $bakModStrings;
678 678
         $headerTpl = $themeObject->getTemplate('header.tpl');
@@ -777,12 +777,12 @@  discard block
 block discarded – undo
777 777
         list ($num_grp_sep, $dec_sep) = get_number_seperators();
778 778
 
779 779
         $the_script = "<script type=\"text/javascript\">\n" . "\tvar time_reg_format = '" .
780
-             $timereg['format'] . "';\n" . "\tvar date_reg_format = '" .
781
-             $datereg['format'] . "';\n" . "\tvar date_reg_positions = { $date_pos };\n" .
782
-             "\tvar time_separator = '$time_separator';\n" .
783
-             "\tvar cal_date_format = '$cal_date_format';\n" .
784
-             "\tvar time_offset = $hour_offset;\n" . "\tvar num_grp_sep = '$num_grp_sep';\n" .
785
-             "\tvar dec_sep = '$dec_sep';\n" . "</script>";
780
+                $timereg['format'] . "';\n" . "\tvar date_reg_format = '" .
781
+                $datereg['format'] . "';\n" . "\tvar date_reg_positions = { $date_pos };\n" .
782
+                "\tvar time_separator = '$time_separator';\n" .
783
+                "\tvar cal_date_format = '$cal_date_format';\n" .
784
+                "\tvar time_offset = $hour_offset;\n" . "\tvar num_grp_sep = '$num_grp_sep';\n" .
785
+                "\tvar dec_sep = '$dec_sep';\n" . "</script>";
786 786
 
787 787
         return $the_script;
788 788
     }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
             }
848 848
             echo getVersionedScript('cache/jsLanguage/'. $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
849 849
 
850
-			echo $this->_getModLanguageJS();
850
+            echo $this->_getModLanguageJS();
851 851
 
852 852
             if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
853 853
                 echo getVersionedScript('modules/Sync/headersync.js');
@@ -863,13 +863,13 @@  discard block
 block discarded – undo
863 863
         }
864 864
     }
865 865
 
866
-	protected function _getModLanguageJS(){
867
-		if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {
868
-			require_once ('include/language/jsLanguage.php');
869
-			jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);
870
-		}
871
-		return getVersionedScript("cache/jsLanguage/{$this->module}/". $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
872
-	}
866
+    protected function _getModLanguageJS(){
867
+        if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {
868
+            require_once ('include/language/jsLanguage.php');
869
+            jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);
870
+        }
871
+        return getVersionedScript("cache/jsLanguage/{$this->module}/". $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
872
+    }
873 873
 
874 874
     /**
875 875
      * Called from process(). This method will display the footer on the page.
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
         global $sugar_config;
883 883
         global $app_strings;
884 884
         global $mod_strings;
885
-		$themeObject = SugarThemeRegistry::current();
885
+        $themeObject = SugarThemeRegistry::current();
886 886
         //decide whether or not to show themepicker, default is to show
887 887
         $showThemePicker = true;
888 888
         if (isset($sugar_config['showThemePicker'])) {
@@ -893,30 +893,30 @@  discard block
 block discarded – undo
893 893
         $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
894 894
         $ss->assign('MOD',return_module_language($GLOBALS['current_language'], 'Users'));
895 895
 
896
-		$bottomLinkList = array();
897
-		 if (isset($this->action) && $this->action != "EditView") {
898
-			 $bottomLinkList['print'] = array($app_strings['LNK_PRINT'] => getPrintLink());
899
-		}
900
-		$bottomLinkList['backtotop'] = array($app_strings['LNK_BACKTOTOP'] => 'javascript:SUGAR.util.top();');
901
-
902
-		$bottomLinksStr = "";
903
-		foreach($bottomLinkList as $key => $value) {
904
-			foreach($value as $text => $link) {
905
-				   $href = $link;
906
-				   if(substr($link, 0, 11) == "javascript:") {
907
-                       $onclick = " onclick=\"".substr($link,11)."\"";
908
-                       $href = "javascript:void(0)";
909
-                   } else {
910
-                   		$onclick = "";
911
-                   	}
896
+        $bottomLinkList = array();
897
+            if (isset($this->action) && $this->action != "EditView") {
898
+                $bottomLinkList['print'] = array($app_strings['LNK_PRINT'] => getPrintLink());
899
+        }
900
+        $bottomLinkList['backtotop'] = array($app_strings['LNK_BACKTOTOP'] => 'javascript:SUGAR.util.top();');
901
+
902
+        $bottomLinksStr = "";
903
+        foreach($bottomLinkList as $key => $value) {
904
+            foreach($value as $text => $link) {
905
+                    $href = $link;
906
+                    if(substr($link, 0, 11) == "javascript:") {
907
+                        $onclick = " onclick=\"".substr($link,11)."\"";
908
+                        $href = "javascript:void(0)";
909
+                    } else {
910
+                            $onclick = "";
911
+                        }
912 912
                 $imageURL = SugarThemeRegistry::current()->getImageURL($key.'.gif');
913
-				$bottomLinksStr .= "<a href=\"{$href}\"";
914
-				$bottomLinksStr .= (isset($onclick)) ? $onclick : "";
915
-				$bottomLinksStr .= "><img src='{$imageURL}' alt=''>"; //keeping alt blank on purpose for 508 (text will be read instead)
916
-				$bottomLinksStr .= " ".$text."</a>";
917
-			}
918
-		}
919
-		$ss->assign("BOTTOMLINKS",$bottomLinksStr);
913
+                $bottomLinksStr .= "<a href=\"{$href}\"";
914
+                $bottomLinksStr .= (isset($onclick)) ? $onclick : "";
915
+                $bottomLinksStr .= "><img src='{$imageURL}' alt=''>"; //keeping alt blank on purpose for 508 (text will be read instead)
916
+                $bottomLinksStr .= " ".$text."</a>";
917
+            }
918
+        }
919
+        $ss->assign("BOTTOMLINKS",$bottomLinksStr);
920 920
         if (SugarConfig::getInstance()->get('calculate_response_time', false))
921 921
             $ss->assign('STATISTICS',$this->_getStatistics());
922 922
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
         $attribLinkImg = "<img style='margin-top: 2px' border='0' width='120' height='34' src='include/images/poweredby_sugarcrm_65.png' alt='Powered By SugarCRM'>\n";
947 947
 
948 948
 
949
-		// handle resizing of the company logo correctly on the fly
949
+        // handle resizing of the company logo correctly on the fly
950 950
         $companyLogoURL = $themeObject->getImageURL('company_logo.png');
951 951
         $companyLogoURL_arr = explode('?', $companyLogoURL);
952 952
         $companyLogoURL = $companyLogoURL_arr[0];
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 
1070 1070
 
1071 1071
         $trackerManager = TrackerManager::getInstance();
1072
-	    $trackerManager->save();
1072
+        $trackerManager->save();
1073 1073
 
1074 1074
     }
1075 1075
 
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
         $deltaTime = $endTime - $GLOBALS['startTime'];
1110 1110
         $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'] . ' ' . number_format(round($deltaTime, 2), 2) . ' ' . $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1111 1111
         $return = $response_time_string;
1112
-       // $return .= '<br />';
1112
+        // $return .= '<br />';
1113 1113
         if (!empty($GLOBALS['sugar_config']['show_page_resources'])) {
1114 1114
             // Print out the resources used in constructing the page.
1115 1115
             $included_files = get_included_files();
@@ -1170,8 +1170,8 @@  discard block
 block discarded – undo
1170 1170
             {
1171 1171
                 $data = array
1172 1172
                 (
1173
-                   !empty($this->module) ? $this->module : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1174
-                   !empty($this->action) ? $this->action : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1173
+                    !empty($this->module) ? $this->module : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1174
+                    !empty($this->action) ? $this->action : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1175 1175
                 );
1176 1176
 
1177 1177
                 $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data) . $newline;
@@ -1240,15 +1240,15 @@  discard block
 block discarded – undo
1240 1240
     }
1241 1241
 
1242 1242
     /**
1243
-    * Returns the module name which should be highlighted in the module menu
1243
+     * Returns the module name which should be highlighted in the module menu
1244 1244
      */
1245 1245
     protected function _getModuleTab()
1246 1246
     {
1247 1247
         global $app_list_strings, $moduleTabMap, $current_user;
1248 1248
 
1249
-		$userTabs = query_module_access_list($current_user);
1250
-		//If the home tab is in the user array use it as the default tab, otherwise use the first element in the tab array
1251
-		$defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1249
+        $userTabs = query_module_access_list($current_user);
1250
+        //If the home tab is in the user array use it as the default tab, otherwise use the first element in the tab array
1251
+        $defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1252 1252
 
1253 1253
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
1254 1254
         if ( !empty($_REQUEST['module_tab']) )
@@ -1264,17 +1264,17 @@  discard block
 block discarded – undo
1264 1264
         elseif ( !isset($app_list_strings['moduleList'][$this->module]) )
1265 1265
             return $defaultTab;
1266 1266
         elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" )
1267
-        	return $defaultTab;
1267
+            return $defaultTab;
1268 1268
         else
1269 1269
             return $this->module;
1270 1270
     }
1271 1271
 
1272
-   /**
1273
-    * Return the "breadcrumbs" to display at the top of the page
1274
-    *
1275
-    * @param  bool $show_help optional, true if we show the help links
1276
-    * @return HTML string containing breadcrumb title
1277
-    */
1272
+    /**
1273
+     * Return the "breadcrumbs" to display at the top of the page
1274
+     *
1275
+     * @param  bool $show_help optional, true if we show the help links
1276
+     * @return HTML string containing breadcrumb title
1277
+     */
1278 1278
     public function getModuleTitle(
1279 1279
         $show_help = true
1280 1280
         )
@@ -1288,13 +1288,13 @@  discard block
 block discarded – undo
1288 1288
         $params = $this->_getModuleTitleParams();
1289 1289
         $index = 0;
1290 1290
 
1291
-		if(SugarThemeRegistry::current()->directionality == "rtl") {
1292
-			$params = array_reverse($params);
1293
-		}
1294
-		if(count($params) > 1) {
1295
-			array_shift($params);
1296
-		}
1297
-		$count = count($params);
1291
+        if(SugarThemeRegistry::current()->directionality == "rtl") {
1292
+            $params = array_reverse($params);
1293
+        }
1294
+        if(count($params) > 1) {
1295
+            array_shift($params);
1296
+        }
1297
+        $count = count($params);
1298 1298
         $paramString = '';
1299 1299
         foreach($params as $parm){
1300 1300
             $index++;
@@ -1305,13 +1305,13 @@  discard block
 block discarded – undo
1305 1305
         }
1306 1306
 
1307 1307
         if(!empty($paramString)){
1308
-               $theTitle .= "<h2> $paramString </h2>";
1308
+                $theTitle .= "<h2> $paramString </h2>";
1309 1309
 
1310 1310
             if($this->type == "detail"){
1311 1311
                 $theTitle .= "<div class='favorite' record_id='" . $this->bean->id . "' module='" . $this->bean->module_dir . "'><div class='favorite_icon_outline'>" . SugarThemeRegistry::current()->getImage('favorite-star-outline','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div>
1312 1312
                                                     <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div></div>";
1313 1313
             }
1314
-           }
1314
+            }
1315 1315
 
1316 1316
         // bug 56131 - restore conditional so that link doesn't appear where it shouldn't
1317 1317
         if($show_help || $this->type == 'list') {
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
     protected function _getModuleTitleParams($browserTitle = false)
1385 1385
     {
1386 1386
         $params = array($this->_getModuleTitleListParam($browserTitle));
1387
-		//$params = array();
1387
+        //$params = array();
1388 1388
         if (isset($this->action)){
1389 1389
             switch ($this->action) {
1390 1390
             case 'EditView':
@@ -1414,48 +1414,48 @@  discard block
 block discarded – undo
1414 1414
      */
1415 1415
     protected function _getModuleTitleListParam( $browserTitle = false )
1416 1416
     {
1417
-    	global $current_user;
1418
-    	global $app_strings;
1419
-
1420
-    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1421
-    		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1422
-    	else
1423
-    		$firstParam = $this->module;
1424
-
1425
-    	$iconPath = $this->getModuleTitleIconPath($this->module);
1426
-    	if($this->action == "ListView" || $this->action == "index") {
1427
-    	    if (!empty($iconPath) && !$browserTitle) {
1428
-    	    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1429
-    	    		return $app_strings['LBL_SEARCH']."&nbsp;"
1430
-    	    			 . "$firstParam";
1431
-
1432
-    	    	} else {
1433
-					return "$firstParam"
1434
-					     . "&nbsp;".$app_strings['LBL_SEARCH'];
1435
-    	    	}
1436
-			} else {
1437
-				return $firstParam;
1438
-			}
1439
-    	}
1440
-    	else {
1441
-		    if (!empty($iconPath) && !$browserTitle) {
1442
-				//return "<a href='index.php?module={$this->module}&action=index'>$this->module</a>";
1443
-			} else {
1444
-				return $firstParam;
1445
-			}
1446
-    	}
1417
+        global $current_user;
1418
+        global $app_strings;
1419
+
1420
+        if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1421
+            $firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1422
+        else
1423
+            $firstParam = $this->module;
1424
+
1425
+        $iconPath = $this->getModuleTitleIconPath($this->module);
1426
+        if($this->action == "ListView" || $this->action == "index") {
1427
+            if (!empty($iconPath) && !$browserTitle) {
1428
+                if (SugarThemeRegistry::current()->directionality == "ltr") {
1429
+                    return $app_strings['LBL_SEARCH']."&nbsp;"
1430
+                            . "$firstParam";
1431
+
1432
+                } else {
1433
+                    return "$firstParam"
1434
+                            . "&nbsp;".$app_strings['LBL_SEARCH'];
1435
+                }
1436
+            } else {
1437
+                return $firstParam;
1438
+            }
1439
+        }
1440
+        else {
1441
+            if (!empty($iconPath) && !$browserTitle) {
1442
+                //return "<a href='index.php?module={$this->module}&action=index'>$this->module</a>";
1443
+            } else {
1444
+                return $firstParam;
1445
+            }
1446
+        }
1447 1447
     }
1448 1448
 
1449 1449
     protected function getModuleTitleIconPath($module)
1450 1450
     {
1451
-    	$iconPath = "";
1452
-    	if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1453
-    		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1454
-    	}
1455
-    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1456
-    		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1457
-    	}
1458
-    	return $iconPath;
1451
+        $iconPath = "";
1452
+        if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1453
+            $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1454
+        }
1455
+        else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1456
+            $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1457
+        }
1458
+        return $iconPath;
1459 1459
     }
1460 1460
 
1461 1461
     /**
@@ -1485,11 +1485,11 @@  discard block
 block discarded – undo
1485 1485
      */
1486 1486
     public function getBreadCrumbSymbol()
1487 1487
     {
1488
-    	if(SugarThemeRegistry::current()->directionality == "ltr") {
1489
-        	return "<span class='pointer'>&raquo;</span>";
1488
+        if(SugarThemeRegistry::current()->directionality == "ltr") {
1489
+            return "<span class='pointer'>&raquo;</span>";
1490 1490
         }
1491 1491
         else {
1492
-        	return "<span class='pointer'>&laquo;</span>";
1492
+            return "<span class='pointer'>&laquo;</span>";
1493 1493
         }
1494 1494
     }
1495 1495
 
@@ -1658,20 +1658,20 @@  discard block
 block discarded – undo
1658 1658
     }
1659 1659
 
1660 1660
     /**
1661
-	 * Determines whether the state of the post global array indicates there was an error uploading a
1661
+     * Determines whether the state of the post global array indicates there was an error uploading a
1662 1662
      * file that exceeds the post_max_size setting.  Such an error can be detected if:
1663 1663
      *  1. The Server['REQUEST_METHOD'] will still point to POST
1664 1664
      *  2. POST and FILES global arrays will be returned empty despite the request method
1665 1665
      * This also results in a redirect to the home page (due to lack of module and action in POST)
1666 1666
      *
1667
-	 * @return boolean indicating true or false
1668
-	 */
1667
+     * @return boolean indicating true or false
1668
+     */
1669 1669
     public function checkPostMaxSizeError(){
1670
-         //if the referrer is post, and the post array is empty, then an error has occurred, most likely
1671
-         //while uploading a file that exceeds the post_max_size.
1672
-         if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
1673
-             $GLOBALS['log']->fatal($GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT']);
1674
-             return true;
1670
+            //if the referrer is post, and the post array is empty, then an error has occurred, most likely
1671
+            //while uploading a file that exceeds the post_max_size.
1672
+            if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
1673
+                $GLOBALS['log']->fatal($GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT']);
1674
+                return true;
1675 1675
         }
1676 1676
         return false;
1677 1677
     }
Please login to merge, or discard this patch.
include/MVC/Controller/ControllerFactory.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -44,43 +44,43 @@
 block discarded – undo
44 44
  */
45 45
 class ControllerFactory
46 46
 {
47
-	/**
48
-	 * Obtain an instance of the correct controller.
49
-	 *
50
-	 * @return an instance of SugarController
51
-	 */
52
-	static function getController($module){
53
-		$class = ucfirst($module).'Controller';
54
-		$customClass = 'Custom' . $class;
55
-		if(file_exists('custom/modules/'.$module.'/controller.php')){
56
-			$customClass = 'Custom' . $class;
57
-			require_once('custom/modules/'.$module.'/controller.php');
58
-			if(class_exists($customClass)){
59
-				$controller = new $customClass();
60
-			}else if(class_exists($class)){
61
-				$controller = new $class();
62
-			}
63
-		}elseif(file_exists('modules/'.$module.'/controller.php')){
64
-			require_once('modules/'.$module.'/controller.php');
65
-			if(class_exists($customClass)){
66
-				$controller = new $customClass();
67
-			}else if(class_exists($class)){
68
-				$controller = new $class();
69
-			}
70
-		}else{
71
-			if(file_exists('custom/include/MVC/Controller/SugarController.php')){
72
-				require_once('custom/include/MVC/Controller/SugarController.php');
73
-			}
74
-			if(class_exists('CustomSugarController')){
75
-				$controller = new CustomSugarController();
76
-			}else{
77
-			$controller = new SugarController();
78
-			}
79
-		}
80
-		//setup the controller
81
-		$controller->setup($module);
82
-		return $controller;
83
-	}
47
+    /**
48
+     * Obtain an instance of the correct controller.
49
+     *
50
+     * @return an instance of SugarController
51
+     */
52
+    static function getController($module){
53
+        $class = ucfirst($module).'Controller';
54
+        $customClass = 'Custom' . $class;
55
+        if(file_exists('custom/modules/'.$module.'/controller.php')){
56
+            $customClass = 'Custom' . $class;
57
+            require_once('custom/modules/'.$module.'/controller.php');
58
+            if(class_exists($customClass)){
59
+                $controller = new $customClass();
60
+            }else if(class_exists($class)){
61
+                $controller = new $class();
62
+            }
63
+        }elseif(file_exists('modules/'.$module.'/controller.php')){
64
+            require_once('modules/'.$module.'/controller.php');
65
+            if(class_exists($customClass)){
66
+                $controller = new $customClass();
67
+            }else if(class_exists($class)){
68
+                $controller = new $class();
69
+            }
70
+        }else{
71
+            if(file_exists('custom/include/MVC/Controller/SugarController.php')){
72
+                require_once('custom/include/MVC/Controller/SugarController.php');
73
+            }
74
+            if(class_exists('CustomSugarController')){
75
+                $controller = new CustomSugarController();
76
+            }else{
77
+            $controller = new SugarController();
78
+            }
79
+        }
80
+        //setup the controller
81
+        $controller->setup($module);
82
+        return $controller;
83
+    }
84 84
 
85 85
 }
86 86
 ?>
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,31 +49,31 @@
 block discarded – undo
49 49
 	 *
50 50
 	 * @return an instance of SugarController
51 51
 	 */
52
-	static function getController($module){
52
+	static function getController($module) {
53 53
 		$class = ucfirst($module).'Controller';
54
-		$customClass = 'Custom' . $class;
55
-		if(file_exists('custom/modules/'.$module.'/controller.php')){
56
-			$customClass = 'Custom' . $class;
54
+		$customClass = 'Custom'.$class;
55
+		if (file_exists('custom/modules/'.$module.'/controller.php')) {
56
+			$customClass = 'Custom'.$class;
57 57
 			require_once('custom/modules/'.$module.'/controller.php');
58
-			if(class_exists($customClass)){
58
+			if (class_exists($customClass)) {
59 59
 				$controller = new $customClass();
60
-			}else if(class_exists($class)){
60
+			} else if (class_exists($class)) {
61 61
 				$controller = new $class();
62 62
 			}
63
-		}elseif(file_exists('modules/'.$module.'/controller.php')){
63
+		}elseif (file_exists('modules/'.$module.'/controller.php')) {
64 64
 			require_once('modules/'.$module.'/controller.php');
65
-			if(class_exists($customClass)){
65
+			if (class_exists($customClass)) {
66 66
 				$controller = new $customClass();
67
-			}else if(class_exists($class)){
67
+			} else if (class_exists($class)) {
68 68
 				$controller = new $class();
69 69
 			}
70
-		}else{
71
-			if(file_exists('custom/include/MVC/Controller/SugarController.php')){
70
+		} else {
71
+			if (file_exists('custom/include/MVC/Controller/SugarController.php')) {
72 72
 				require_once('custom/include/MVC/Controller/SugarController.php');
73 73
 			}
74
-			if(class_exists('CustomSugarController')){
74
+			if (class_exists('CustomSugarController')) {
75 75
 				$controller = new CustomSugarController();
76
-			}else{
76
+			} else {
77 77
 			$controller = new SugarController();
78 78
 			}
79 79
 		}
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -57,23 +57,23 @@
 block discarded – undo
57 57
 			require_once('custom/modules/'.$module.'/controller.php');
58 58
 			if(class_exists($customClass)){
59 59
 				$controller = new $customClass();
60
-			}else if(class_exists($class)){
60
+			} else if(class_exists($class)){
61 61
 				$controller = new $class();
62 62
 			}
63
-		}elseif(file_exists('modules/'.$module.'/controller.php')){
63
+		} elseif(file_exists('modules/'.$module.'/controller.php')){
64 64
 			require_once('modules/'.$module.'/controller.php');
65 65
 			if(class_exists($customClass)){
66 66
 				$controller = new $customClass();
67
-			}else if(class_exists($class)){
67
+			} else if(class_exists($class)){
68 68
 				$controller = new $class();
69 69
 			}
70
-		}else{
70
+		} else{
71 71
 			if(file_exists('custom/include/MVC/Controller/SugarController.php')){
72 72
 				require_once('custom/include/MVC/Controller/SugarController.php');
73 73
 			}
74 74
 			if(class_exists('CustomSugarController')){
75 75
 				$controller = new CustomSugarController();
76
-			}else{
76
+			} else{
77 77
 			$controller = new SugarController();
78 78
 			}
79 79
 		}
Please login to merge, or discard this patch.
include/MVC/Controller/SugarController.php 4 patches
Braces   +52 added lines, -46 removed lines patch added patch discarded remove patch
@@ -171,11 +171,13 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 */
173 173
 	public function setup($module = ''){
174
-		if(empty($module) && !empty($_REQUEST['module']))
175
-			$module = $_REQUEST['module'];
174
+		if(empty($module) && !empty($_REQUEST['module'])) {
175
+					$module = $_REQUEST['module'];
176
+		}
176 177
 		//set the module
177
-		if(!empty($module))
178
-			$this->setModule($module);
178
+		if(!empty($module)) {
179
+					$this->setModule($module);
180
+		}
179 181
 
180 182
 		if(!empty($_REQUEST['target_module']) && $_REQUEST['target_module'] != 'undefined') {
181 183
 			$this->target_module = $_REQUEST['target_module'];
@@ -199,18 +201,24 @@  discard block
 block discarded – undo
199 201
 	 *
200 202
 	 */
201 203
 	private function loadPropertiesFromRequest(){
202
-		if(!empty($_REQUEST['action']))
203
-			$this->action = $_REQUEST['action'];
204
-		if(!empty($_REQUEST['record']))
205
-			$this->record = $_REQUEST['record'];
206
-		if(!empty($_REQUEST['view']))
207
-			$this->view = $_REQUEST['view'];
208
-		if(!empty($_REQUEST['return_module']))
209
-			$this->return_module = $_REQUEST['return_module'];
210
-		if(!empty($_REQUEST['return_action']))
211
-			$this->return_action = $_REQUEST['return_action'];
212
-		if(!empty($_REQUEST['return_id']))
213
-			$this->return_id = $_REQUEST['return_id'];
204
+		if(!empty($_REQUEST['action'])) {
205
+					$this->action = $_REQUEST['action'];
206
+		}
207
+		if(!empty($_REQUEST['record'])) {
208
+					$this->record = $_REQUEST['record'];
209
+		}
210
+		if(!empty($_REQUEST['view'])) {
211
+					$this->view = $_REQUEST['view'];
212
+		}
213
+		if(!empty($_REQUEST['return_module'])) {
214
+					$this->return_module = $_REQUEST['return_module'];
215
+		}
216
+		if(!empty($_REQUEST['return_action'])) {
217
+					$this->return_action = $_REQUEST['return_action'];
218
+		}
219
+		if(!empty($_REQUEST['return_id'])) {
220
+					$this->return_id = $_REQUEST['return_id'];
221
+		}
214 222
 	}
215 223
 
216 224
 	/**
@@ -235,8 +243,9 @@  discard block
 block discarded – undo
235 243
 				$this->bean = new $class();
236 244
 				if(!empty($this->record)){
237 245
 					$this->bean->retrieve($this->record);
238
-					if($this->bean)
239
-						$GLOBALS['FOCUS'] = $this->bean;
246
+					if($this->bean) {
247
+											$GLOBALS['FOCUS'] = $this->bean;
248
+					}
240 249
 				}
241 250
 			}
242 251
 		}
@@ -250,7 +259,7 @@  discard block
 block discarded – undo
250 259
 		if(!$$var){
251 260
 			if($merge && !empty($this->$var)){
252 261
 				$$var = $this->$var;
253
-			}else{
262
+			} else{
254 263
 				$$var = array();
255 264
 			}
256 265
 			if(file_exists('include/MVC/Controller/'. $var . '.php')){
@@ -293,13 +302,11 @@  discard block
 block discarded – undo
293 302
             if(!empty($this->view))
294 303
             {
295 304
                 $this->processView();
296
-            }
297
-            elseif(!empty($this->redirect_url))
305
+            } elseif(!empty($this->redirect_url))
298 306
             {
299 307
             			$this->redirect();
300 308
             }
301
-        }
302
-        catch (Exception $e)
309
+        } catch (Exception $e)
303 310
         {
304 311
             $this->handleException($e);
305 312
         }
@@ -321,8 +328,7 @@  discard block
 block discarded – undo
321 328
         {
322 329
             $logicHook->setBean($this->bean);
323 330
             $logicHook->call_custom_logic($this->bean->module_dir, "handle_exception", $e);
324
-        }
325
-        else
331
+        } else
326 332
         {
327 333
             $logicHook->call_custom_logic('', "handle_exception", $e);
328 334
         }
@@ -384,7 +390,7 @@  discard block
 block discarded – undo
384 390
             }
385 391
 
386 392
 			$this->redirect();
387
-		}else{
393
+		} else{
388 394
 			$this->no_access();
389 395
 		}
390 396
 	}
@@ -491,8 +497,9 @@  discard block
 block discarded – undo
491 497
 	 */
492 498
 	protected function redirect(){
493 499
 
494
-		if(!empty($this->redirect_url))
495
-			SugarApplication::redirect($this->redirect_url);
500
+		if(!empty($this->redirect_url)) {
501
+					SugarApplication::redirect($this->redirect_url);
502
+		}
496 503
 	}
497 504
 
498 505
 	////////////////////////////////////////////////////////
@@ -586,7 +593,7 @@  discard block
 block discarded – undo
586 593
 				sugar_cleanup(true);
587 594
 			}
588 595
 			$this->bean->mark_deleted($_REQUEST['record']);
589
-		}else{
596
+		} else{
590 597
 			sugar_die("A record number must be specified to delete");
591 598
 		}
592 599
 	}
@@ -652,7 +659,7 @@  discard block
 block discarded – undo
652 659
             unset($_REQUEST[$seed->module_dir.'2_'.strtoupper($seed->object_name).'_offset']);//after massupdate, the page should redirect to no offset page
653 660
             $storeQuery->saveFromRequest($_REQUEST['module']);
654 661
             $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']);//for post_massupdate, to go back to original page.
655
-		}else{
662
+		} else{
656 663
 			sugar_die("You must massupdate at least one record");
657 664
 		}
658 665
 	}
@@ -711,8 +718,7 @@  discard block
 block discarded – undo
711 718
 
712 719
 		        if(method_exists($dashlet, $requestedMethod) || method_exists($dashlet, '__call')) {
713 720
 		            echo $dashlet->$requestedMethod();
714
-		        }
715
-		        else {
721
+		        } else {
716 722
 		            echo 'no method';
717 723
 		        }
718 724
 		    }
@@ -734,15 +740,13 @@  discard block
 block discarded – undo
734 740
 		    if(!empty($_REQUEST['configure']) && $_REQUEST['configure']) { // save settings
735 741
 		        $dashletDefs[$id]['options'] = $dashlet->saveOptions($_REQUEST);
736 742
 		        $current_user->setPreference('dashlets', $dashletDefs, 0, $_REQUEST['module']);
737
-		    }
738
-		    else { // display options
743
+		    } else { // display options
739 744
 		        $json = getJSONobj();
740 745
 		        return 'result = ' . $json->encode((array('header' => $dashlet->title . ' : ' . $mod_strings['LBL_OPTIONS'],
741 746
 		                                                 'body'  => $dashlet->displayOptions())));
742 747
 
743 748
 		    }
744
-		}
745
-		else {
749
+		} else {
746 750
 		    return '0';
747 751
 		}
748 752
 	}
@@ -824,13 +828,14 @@  discard block
 block discarded – undo
824 828
 						$this->_processed = true;
825 829
 						$this->no_access();
826 830
 					}
827
-				}else{
831
+				} else{
828 832
 					$this->_processed = true;
829 833
 					$this->no_access();
830 834
 				}
831 835
 			}
832
-		}else
833
-			$this->_processed = false;
836
+		} else {
837
+					$this->_processed = false;
838
+		}
834 839
 	}
835 840
 
836 841
 	/**
@@ -865,8 +870,9 @@  discard block
 block discarded – undo
865 870
         $this->loadMapping('entry_point_registry');
866 871
 
867 872
         if ( isset($this->entry_point_registry[$entryPoint]['auth'])
868
-                && !$this->entry_point_registry[$entryPoint]['auth'] )
869
-            return false;
873
+                && !$this->entry_point_registry[$entryPoint]['auth'] ) {
874
+                    return false;
875
+        }
870 876
         return true;
871 877
     }
872 878
 
@@ -879,8 +885,7 @@  discard block
 block discarded – undo
879 885
 		$file = self::getActionFilename($this->do_action);
880 886
 		if ( isset($this->action_view_map[strtolower($this->do_action)]) ) {
881 887
 	        $action = $this->action_view_map[strtolower($this->do_action)];
882
-	    }
883
-	    else {
888
+	    } else {
884 889
 	        $action = $this->do_action;
885 890
 	    }
886 891
 	    // index actions actually maps to the view.list.php view
@@ -913,12 +918,13 @@  discard block
 block discarded – undo
913 918
 			$GLOBALS['log']->debug('Using Action File Map:' . $this->action_file_map[strtolower($this->do_action)]);
914 919
 			require_once($this->action_file_map[strtolower($this->do_action)]);
915 920
 			$this->_processed = true;
916
-		}elseif(!empty($this->action_view_map[strtolower($this->do_action)])){
921
+		} elseif(!empty($this->action_view_map[strtolower($this->do_action)])){
917 922
 			$GLOBALS['log']->debug('Using Action View Map:' . $this->action_view_map[strtolower($this->do_action)]);
918 923
 			$this->view = $this->action_view_map[strtolower($this->do_action)];
919 924
 			$this->_processed = true;
920
-		}else
921
-			$this->no_action();
925
+		} else {
926
+					$this->no_action();
927
+		}
922 928
 	}
923 929
 
924 930
 	/**
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -244,6 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 	/**
246 246
 	 * Generic load method to load mapping arrays.
247
+	 * @param string $var
247 248
 	 */
248 249
 	private function loadMapping($var, $merge = false){
249 250
 		$$var = sugar_cache_retrieve("CONTROLLER_". $var . "_".$this->module);
@@ -469,7 +470,8 @@  discard block
 block discarded – undo
469 470
 	/**
470 471
 	 * Determine if a given function exists on the objects
471 472
 	 * @param function - the function to check
472
-	 * @return true if the method exists on the object, false otherwise
473
+	 * @param string $function
474
+	 * @return boolean if the method exists on the object, false otherwise
473 475
 	 */
474 476
 	protected function hasFunction($function){
475 477
 		return method_exists($this, $function);
@@ -777,6 +779,7 @@  discard block
 block discarded – undo
777 779
 
778 780
 	/**
779 781
 	 * getActionFilename
782
+	 * @param string $action
780 783
 	 */
781 784
 	public static function getActionFilename($action) {
782 785
 	   if(isset(self::$action_case_file[$action])) {
Please login to merge, or discard this patch.
Indentation   +677 added lines, -677 removed lines patch added patch discarded remove patch
@@ -44,247 +44,247 @@  discard block
 block discarded – undo
44 44
  * @api
45 45
  */
46 46
 class SugarController{
47
-	/**
48
-	 * remap actions in here
49
-	 * e.g. make all detail views go to edit views
50
-	 * $action_remap = array('detailview'=>'editview');
51
-	 */
52
-	protected $action_remap = array('index'=>'listview');
53
-	/**
54
-	 * The name of the current module.
55
-	 */
56
-	public $module = 'Home';
57
-	/**
58
-	 * The name of the target module.
59
-	 */
60
-	public $target_module = null;
61
-	/**
62
-	 * The name of the current action.
63
-	 */
64
-	public $action = 'index';
65
-	/**
66
-	 * The id of the current record.
67
-	 */
68
-	public $record = '';
69
-	/**
70
-	 * The name of the return module.
71
-	 */
72
-	public $return_module = null;
73
-	/**
74
-	 * The name of the return action.
75
-	 */
76
-	public $return_action = null;
77
-	/**
78
-	 * The id of the return record.
79
-	 */
80
-	public $return_id = null;
81
-	/**
82
-	 * If the action was remapped it will be set to do_action and then we will just
83
-	 * use do_action for the actual action to perform.
84
-	 */
85
-	protected $do_action = 'index';
86
-	/**
87
-	 * If a bean is present that set it.
88
-	 */
89
-	public $bean = null;
90
-	/**
91
-	 * url to redirect to
92
-	 */
93
-	public $redirect_url = '';
94
-	/**
95
-	 * any subcontroller can modify this to change the view
96
-	 */
97
-	public $view = 'classic';
98
-	/**
99
-	 * this array will hold the mappings between a key and an object for use within the view.
100
-	 */
101
-	public $view_object_map = array();
47
+    /**
48
+     * remap actions in here
49
+     * e.g. make all detail views go to edit views
50
+     * $action_remap = array('detailview'=>'editview');
51
+     */
52
+    protected $action_remap = array('index'=>'listview');
53
+    /**
54
+     * The name of the current module.
55
+     */
56
+    public $module = 'Home';
57
+    /**
58
+     * The name of the target module.
59
+     */
60
+    public $target_module = null;
61
+    /**
62
+     * The name of the current action.
63
+     */
64
+    public $action = 'index';
65
+    /**
66
+     * The id of the current record.
67
+     */
68
+    public $record = '';
69
+    /**
70
+     * The name of the return module.
71
+     */
72
+    public $return_module = null;
73
+    /**
74
+     * The name of the return action.
75
+     */
76
+    public $return_action = null;
77
+    /**
78
+     * The id of the return record.
79
+     */
80
+    public $return_id = null;
81
+    /**
82
+     * If the action was remapped it will be set to do_action and then we will just
83
+     * use do_action for the actual action to perform.
84
+     */
85
+    protected $do_action = 'index';
86
+    /**
87
+     * If a bean is present that set it.
88
+     */
89
+    public $bean = null;
90
+    /**
91
+     * url to redirect to
92
+     */
93
+    public $redirect_url = '';
94
+    /**
95
+     * any subcontroller can modify this to change the view
96
+     */
97
+    public $view = 'classic';
98
+    /**
99
+     * this array will hold the mappings between a key and an object for use within the view.
100
+     */
101
+    public $view_object_map = array();
102 102
 
103
-	/**
104
-	 * This array holds the methods that handleAction() will invoke, in sequence.
105
-	 */
106
-	protected $tasks = array(
107
-					   'pre_action',
108
-					   'do_action',
109
-					   'post_action'
110
-					   );
111
-	/**
112
-	 * List of options to run through within the process() method.
113
-	 * This list is meant to easily allow additions for new functionality as well as
114
-	 * the ability to add a controller's own handling.
115
-	 */
116
-	public $process_tasks = array(
117
-						'blockFileAccess',
118
-						'handleEntryPoint',
119
-						'callLegacyCode',
120
-						'remapAction',
121
-						'handle_action',
122
-						'handleActionMaps',
123
-					);
124
-	/**
125
-	 * Whether or not the action has been handled by $process_tasks
126
-	 *
127
-	 * @var bool
128
-	 */
129
-	protected $_processed = false;
130
-	/**
131
-	 * Map an action directly to a file
132
-	 */
133
-	/**
134
-	 * Map an action directly to a file. This will be loaded from action_file_map.php
135
-	 */
136
-	protected $action_file_map = array();
137
-	/**
138
-	 * Map an action directly to a view
139
-	 */
140
-	/**
141
-	 * Map an action directly to a view. This will be loaded from action_view_map.php
142
-	 */
143
-	protected $action_view_map = array();
103
+    /**
104
+     * This array holds the methods that handleAction() will invoke, in sequence.
105
+     */
106
+    protected $tasks = array(
107
+                        'pre_action',
108
+                        'do_action',
109
+                        'post_action'
110
+                        );
111
+    /**
112
+     * List of options to run through within the process() method.
113
+     * This list is meant to easily allow additions for new functionality as well as
114
+     * the ability to add a controller's own handling.
115
+     */
116
+    public $process_tasks = array(
117
+                        'blockFileAccess',
118
+                        'handleEntryPoint',
119
+                        'callLegacyCode',
120
+                        'remapAction',
121
+                        'handle_action',
122
+                        'handleActionMaps',
123
+                    );
124
+    /**
125
+     * Whether or not the action has been handled by $process_tasks
126
+     *
127
+     * @var bool
128
+     */
129
+    protected $_processed = false;
130
+    /**
131
+     * Map an action directly to a file
132
+     */
133
+    /**
134
+     * Map an action directly to a file. This will be loaded from action_file_map.php
135
+     */
136
+    protected $action_file_map = array();
137
+    /**
138
+     * Map an action directly to a view
139
+     */
140
+    /**
141
+     * Map an action directly to a view. This will be loaded from action_view_map.php
142
+     */
143
+    protected $action_view_map = array();
144 144
 
145
-	/**
146
-	 * This can be set from the application to tell us whether we have authorization to
147
-	 * process the action. If this is set we will default to the noaccess view.
148
-	 */
149
-	public $hasAccess = true;
145
+    /**
146
+     * This can be set from the application to tell us whether we have authorization to
147
+     * process the action. If this is set we will default to the noaccess view.
148
+     */
149
+    public $hasAccess = true;
150 150
 
151
-	/**
152
-	 * Map case sensitive filenames to action.  This is used for linux/unix systems
153
-	 * where filenames are case sensitive
154
-	 */
155
-	public static $action_case_file = array(
156
-										'editview'=>'EditView',
157
-										'detailview'=>'DetailView',
158
-										'listview'=>'ListView'
159
-									  );
160
-
161
-	/**
162
-	 * Constructor. This ie meant tot load up the module, action, record as well
163
-	 * as the mapping arrays.
164
-	 */
165
-	public function __construct(){
166
-	}
151
+    /**
152
+     * Map case sensitive filenames to action.  This is used for linux/unix systems
153
+     * where filenames are case sensitive
154
+     */
155
+    public static $action_case_file = array(
156
+                                        'editview'=>'EditView',
157
+                                        'detailview'=>'DetailView',
158
+                                        'listview'=>'ListView'
159
+                                        );
167 160
 
168
-	/**
169
-	 * Called from SugarApplication and is meant to perform the setup operations
170
-	 * on the controller.
171
-	 *
172
-	 */
173
-	public function setup($module = ''){
174
-		if(empty($module) && !empty($_REQUEST['module']))
175
-			$module = $_REQUEST['module'];
176
-		//set the module
177
-		if(!empty($module))
178
-			$this->setModule($module);
179
-
180
-		if(!empty($_REQUEST['target_module']) && $_REQUEST['target_module'] != 'undefined') {
181
-			$this->target_module = $_REQUEST['target_module'];
182
-		}
183
-		//set properties on the controller from the $_REQUEST
184
-		$this->loadPropertiesFromRequest();
185
-		//load the mapping files
186
-		$this->loadMappings();
187
-	}
188
-	/**
189
-	 * Set the module on the Controller
190
-	 *
191
-	 * @param object $module
192
-	 */
193
-	public function setModule($module){
194
-		$this->module = $module;
195
-	}
161
+    /**
162
+     * Constructor. This ie meant tot load up the module, action, record as well
163
+     * as the mapping arrays.
164
+     */
165
+    public function __construct(){
166
+    }
196 167
 
197
-	/**
198
-	 * Set properties on the Controller from the $_REQUEST
199
-	 *
200
-	 */
201
-	private function loadPropertiesFromRequest(){
202
-		if(!empty($_REQUEST['action']))
203
-			$this->action = $_REQUEST['action'];
204
-		if(!empty($_REQUEST['record']))
205
-			$this->record = $_REQUEST['record'];
206
-		if(!empty($_REQUEST['view']))
207
-			$this->view = $_REQUEST['view'];
208
-		if(!empty($_REQUEST['return_module']))
209
-			$this->return_module = $_REQUEST['return_module'];
210
-		if(!empty($_REQUEST['return_action']))
211
-			$this->return_action = $_REQUEST['return_action'];
212
-		if(!empty($_REQUEST['return_id']))
213
-			$this->return_id = $_REQUEST['return_id'];
214
-	}
168
+    /**
169
+     * Called from SugarApplication and is meant to perform the setup operations
170
+     * on the controller.
171
+     *
172
+     */
173
+    public function setup($module = ''){
174
+        if(empty($module) && !empty($_REQUEST['module']))
175
+            $module = $_REQUEST['module'];
176
+        //set the module
177
+        if(!empty($module))
178
+            $this->setModule($module);
179
+
180
+        if(!empty($_REQUEST['target_module']) && $_REQUEST['target_module'] != 'undefined') {
181
+            $this->target_module = $_REQUEST['target_module'];
182
+        }
183
+        //set properties on the controller from the $_REQUEST
184
+        $this->loadPropertiesFromRequest();
185
+        //load the mapping files
186
+        $this->loadMappings();
187
+    }
188
+    /**
189
+     * Set the module on the Controller
190
+     *
191
+     * @param object $module
192
+     */
193
+    public function setModule($module){
194
+        $this->module = $module;
195
+    }
215 196
 
216
-	/**
217
-	 * Load map files for use within the Controller
218
-	 *
219
-	 */
220
-	private function loadMappings(){
221
-		$this->loadMapping('action_view_map');
222
-		$this->loadMapping('action_file_map');
223
-		$this->loadMapping('action_remap', true);
224
-	}
197
+    /**
198
+     * Set properties on the Controller from the $_REQUEST
199
+     *
200
+     */
201
+    private function loadPropertiesFromRequest(){
202
+        if(!empty($_REQUEST['action']))
203
+            $this->action = $_REQUEST['action'];
204
+        if(!empty($_REQUEST['record']))
205
+            $this->record = $_REQUEST['record'];
206
+        if(!empty($_REQUEST['view']))
207
+            $this->view = $_REQUEST['view'];
208
+        if(!empty($_REQUEST['return_module']))
209
+            $this->return_module = $_REQUEST['return_module'];
210
+        if(!empty($_REQUEST['return_action']))
211
+            $this->return_action = $_REQUEST['return_action'];
212
+        if(!empty($_REQUEST['return_id']))
213
+            $this->return_id = $_REQUEST['return_id'];
214
+    }
225 215
 
226
-	/**
227
-	 * Given a record id load the bean. This bean is accessible from any sub controllers.
228
-	 */
229
-	public function loadBean()
230
-	{
231
-		if(!empty($GLOBALS['beanList'][$this->module])){
232
-			$class = $GLOBALS['beanList'][$this->module];
233
-			if(!empty($GLOBALS['beanFiles'][$class])){
234
-				require_once($GLOBALS['beanFiles'][$class]);
235
-				$this->bean = new $class();
236
-				if(!empty($this->record)){
237
-					$this->bean->retrieve($this->record);
238
-					if($this->bean)
239
-						$GLOBALS['FOCUS'] = $this->bean;
240
-				}
241
-			}
242
-		}
243
-	}
216
+    /**
217
+     * Load map files for use within the Controller
218
+     *
219
+     */
220
+    private function loadMappings(){
221
+        $this->loadMapping('action_view_map');
222
+        $this->loadMapping('action_file_map');
223
+        $this->loadMapping('action_remap', true);
224
+    }
244 225
 
245
-	/**
246
-	 * Generic load method to load mapping arrays.
247
-	 */
248
-	private function loadMapping($var, $merge = false){
249
-		$$var = sugar_cache_retrieve("CONTROLLER_". $var . "_".$this->module);
250
-		if(!$$var){
251
-			if($merge && !empty($this->$var)){
252
-				$$var = $this->$var;
253
-			}else{
254
-				$$var = array();
255
-			}
256
-			if(file_exists('include/MVC/Controller/'. $var . '.php')){
257
-				require('include/MVC/Controller/'. $var . '.php');
258
-			}
259
-			if(file_exists('modules/'.$this->module.'/'. $var . '.php')){
260
-				require('modules/'.$this->module.'/'. $var . '.php');
261
-			}
262
-			if(file_exists('custom/modules/'.$this->module.'/'. $var . '.php')){
263
-				require('custom/modules/'.$this->module.'/'. $var . '.php');
264
-			}
265
-			if(file_exists('custom/include/MVC/Controller/'. $var . '.php')){
266
-				require('custom/include/MVC/Controller/'. $var . '.php');
267
-			}
226
+    /**
227
+     * Given a record id load the bean. This bean is accessible from any sub controllers.
228
+     */
229
+    public function loadBean()
230
+    {
231
+        if(!empty($GLOBALS['beanList'][$this->module])){
232
+            $class = $GLOBALS['beanList'][$this->module];
233
+            if(!empty($GLOBALS['beanFiles'][$class])){
234
+                require_once($GLOBALS['beanFiles'][$class]);
235
+                $this->bean = new $class();
236
+                if(!empty($this->record)){
237
+                    $this->bean->retrieve($this->record);
238
+                    if($this->bean)
239
+                        $GLOBALS['FOCUS'] = $this->bean;
240
+                }
241
+            }
242
+        }
243
+    }
244
+
245
+    /**
246
+     * Generic load method to load mapping arrays.
247
+     */
248
+    private function loadMapping($var, $merge = false){
249
+        $$var = sugar_cache_retrieve("CONTROLLER_". $var . "_".$this->module);
250
+        if(!$$var){
251
+            if($merge && !empty($this->$var)){
252
+                $$var = $this->$var;
253
+            }else{
254
+                $$var = array();
255
+            }
256
+            if(file_exists('include/MVC/Controller/'. $var . '.php')){
257
+                require('include/MVC/Controller/'. $var . '.php');
258
+            }
259
+            if(file_exists('modules/'.$this->module.'/'. $var . '.php')){
260
+                require('modules/'.$this->module.'/'. $var . '.php');
261
+            }
262
+            if(file_exists('custom/modules/'.$this->module.'/'. $var . '.php')){
263
+                require('custom/modules/'.$this->module.'/'. $var . '.php');
264
+            }
265
+            if(file_exists('custom/include/MVC/Controller/'. $var . '.php')){
266
+                require('custom/include/MVC/Controller/'. $var . '.php');
267
+            }
268 268
 
269 269
             // entry_point_registry -> EntryPointRegistry
270 270
 
271
-			$varname = str_replace(" ","",ucwords(str_replace("_"," ", $var)));
271
+            $varname = str_replace(" ","",ucwords(str_replace("_"," ", $var)));
272 272
             if(file_exists("custom/application/Ext/$varname/$var.ext.php")){
273
-				require("custom/application/Ext/$varname/$var.ext.php");
274
-	        }
275
-			if(file_exists("custom/modules/{$this->module}/Ext/$varname/$var.ext.php")){
276
-				require("custom/modules/{$this->module}/Ext/$varname/$var.ext.php");
277
-			}
278
-
279
-			sugar_cache_put("CONTROLLER_". $var . "_".$this->module, $$var);
280
-		}
281
-		$this->$var = $$var;
282
-	}
273
+                require("custom/application/Ext/$varname/$var.ext.php");
274
+            }
275
+            if(file_exists("custom/modules/{$this->module}/Ext/$varname/$var.ext.php")){
276
+                require("custom/modules/{$this->module}/Ext/$varname/$var.ext.php");
277
+            }
283 278
 
284
-	/**
285
-	 * This method is called from SugarApplication->execute and it will bootstrap the entire controller process
286
-	 */
287
-	final public function execute()
279
+            sugar_cache_put("CONTROLLER_". $var . "_".$this->module, $$var);
280
+        }
281
+        $this->$var = $$var;
282
+    }
283
+
284
+    /**
285
+     * This method is called from SugarApplication->execute and it will bootstrap the entire controller process
286
+     */
287
+    final public function execute()
288 288
     {
289 289
 
290 290
         try
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             }
297 297
             elseif(!empty($this->redirect_url))
298 298
             {
299
-            			$this->redirect();
299
+                        $this->redirect();
300 300
             }
301 301
         }
302 302
         catch (Exception $e)
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
 
307 307
 
308 308
 
309
-	}
309
+    }
310 310
 
311 311
     /**
312
-      * Handle exception
313
-      * @param Exception $e
314
-      */
312
+     * Handle exception
313
+     * @param Exception $e
314
+     */
315 315
     protected function handleException(Exception $e)
316 316
     {
317 317
         $GLOBALS['log']->fatal('Exception in Controller: ' . $e->getMessage());
@@ -328,52 +328,52 @@  discard block
 block discarded – undo
328 328
         }
329 329
     }
330 330
 
331
-	/**
332
-	 * Display the appropriate view.
333
-	 */
334
-	private function processView(){
335
-		if(!isset($this->view_object_map['remap_action']) && isset($this->action_view_map[strtolower($this->action)]))
336
-		{
337
-		  $this->view_object_map['remap_action'] = $this->action_view_map[strtolower($this->action)];
338
-		}
339
-		$view = ViewFactory::loadView($this->view, $this->module, $this->bean, $this->view_object_map, $this->target_module);
340
-		$GLOBALS['current_view'] = $view;
341
-		if(!empty($this->bean) && !$this->bean->ACLAccess($view->type) && $view->type != 'list'){
342
-			ACLController::displayNoAccess(true);
343
-			sugar_cleanup(true);
344
-		}
345
-		if(isset($this->errors)){
346
-		  $view->errors = $this->errors;
347
-		}
348
-		$view->process();
349
-	}
331
+    /**
332
+     * Display the appropriate view.
333
+     */
334
+    private function processView(){
335
+        if(!isset($this->view_object_map['remap_action']) && isset($this->action_view_map[strtolower($this->action)]))
336
+        {
337
+            $this->view_object_map['remap_action'] = $this->action_view_map[strtolower($this->action)];
338
+        }
339
+        $view = ViewFactory::loadView($this->view, $this->module, $this->bean, $this->view_object_map, $this->target_module);
340
+        $GLOBALS['current_view'] = $view;
341
+        if(!empty($this->bean) && !$this->bean->ACLAccess($view->type) && $view->type != 'list'){
342
+            ACLController::displayNoAccess(true);
343
+            sugar_cleanup(true);
344
+        }
345
+        if(isset($this->errors)){
346
+            $view->errors = $this->errors;
347
+        }
348
+        $view->process();
349
+    }
350 350
 
351
-	/**
352
-	 * Meant to be overridden by a subclass and allows for specific functionality to be
353
-	 * injected prior to the process() method being called.
354
-	 */
355
-	public function preProcess()
356
-	{}
357
-
358
-	/**
359
-	 * if we have a function to support the action use it otherwise use the default action
360
-	 *
361
-	 * 1) check for file
362
-	 * 2) check for action
363
-	 */
364
-	public function process(){
365
-		$GLOBALS['action'] = $this->action;
366
-		$GLOBALS['module'] = $this->module;
351
+    /**
352
+     * Meant to be overridden by a subclass and allows for specific functionality to be
353
+     * injected prior to the process() method being called.
354
+     */
355
+    public function preProcess()
356
+    {}
367 357
 
368
-		//check to ensure we have access to the module.
369
-		if($this->hasAccess){
370
-			$this->do_action = $this->action;
358
+    /**
359
+     * if we have a function to support the action use it otherwise use the default action
360
+     *
361
+     * 1) check for file
362
+     * 2) check for action
363
+     */
364
+    public function process(){
365
+        $GLOBALS['action'] = $this->action;
366
+        $GLOBALS['module'] = $this->module;
371 367
 
372
-			$file = self::getActionFilename($this->do_action);
368
+        //check to ensure we have access to the module.
369
+        if($this->hasAccess){
370
+            $this->do_action = $this->action;
373 371
 
374
-			$this->loadBean();
372
+            $file = self::getActionFilename($this->do_action);
375 373
 
376
-			$processed = false;
374
+            $this->loadBean();
375
+
376
+            $processed = false;
377 377
             if (!$this->_processed) {
378 378
                 foreach ($this->process_tasks as $process) {
379 379
                     $this->$process();
@@ -383,172 +383,172 @@  discard block
 block discarded – undo
383 383
                 }
384 384
             }
385 385
 
386
-			$this->redirect();
387
-		}else{
388
-			$this->no_access();
389
-		}
390
-	}
386
+            $this->redirect();
387
+        }else{
388
+            $this->no_access();
389
+        }
390
+    }
391 391
 
392
-	/**
393
-	 * This method is called from the process method. I could also be called within an action_* method.
394
-	 * It allows a developer to override any one of these methods contained within,
395
-	 * or if the developer so chooses they can override the entire action_* method.
396
-	 *
397
-	 * @return true if any one of the pre_, do_, or post_ methods have been defined,
398
-	 * false otherwise.  This is important b/c if none of these methods exists, then we will run the
399
-	 * action_default() method.
400
-	 */
401
-	protected function handle_action(){
402
-		$processed = false;
403
-		foreach($this->tasks as $task){
404
-			$processed = ($this->$task() || $processed);
405
-		}
406
-		$this->_processed = $processed;
407
-	}
392
+    /**
393
+     * This method is called from the process method. I could also be called within an action_* method.
394
+     * It allows a developer to override any one of these methods contained within,
395
+     * or if the developer so chooses they can override the entire action_* method.
396
+     *
397
+     * @return true if any one of the pre_, do_, or post_ methods have been defined,
398
+     * false otherwise.  This is important b/c if none of these methods exists, then we will run the
399
+     * action_default() method.
400
+     */
401
+    protected function handle_action(){
402
+        $processed = false;
403
+        foreach($this->tasks as $task){
404
+            $processed = ($this->$task() || $processed);
405
+        }
406
+        $this->_processed = $processed;
407
+    }
408 408
 
409
-	/**
410
-	 * Perform an action prior to the specified action.
411
-	 * This can be overridde in a sub-class
412
-	 */
413
-	private function pre_action(){
414
-		$function = 'pre_' . $this->action;
415
-		if($this->hasFunction($function)){
416
-			$GLOBALS['log']->debug('Performing pre_action');
417
-			$this->$function();
418
-			return true;
419
-		}
420
-		return false;
421
-	}
409
+    /**
410
+     * Perform an action prior to the specified action.
411
+     * This can be overridde in a sub-class
412
+     */
413
+    private function pre_action(){
414
+        $function = 'pre_' . $this->action;
415
+        if($this->hasFunction($function)){
416
+            $GLOBALS['log']->debug('Performing pre_action');
417
+            $this->$function();
418
+            return true;
419
+        }
420
+        return false;
421
+    }
422 422
 
423
-	/**
424
-	 * Perform the specified action.
425
-	 * This can be overridde in a sub-class
426
-	 */
427
-	private function do_action(){
428
-		$function =  'action_'. strtolower($this->do_action);
429
-		if($this->hasFunction($function)){
430
-			$GLOBALS['log']->debug('Performing action: '.$function.' MODULE: '.$this->module);
431
-			$this->$function();
432
-			return true;
433
-		}
434
-		return false;
435
-	}
423
+    /**
424
+     * Perform the specified action.
425
+     * This can be overridde in a sub-class
426
+     */
427
+    private function do_action(){
428
+        $function =  'action_'. strtolower($this->do_action);
429
+        if($this->hasFunction($function)){
430
+            $GLOBALS['log']->debug('Performing action: '.$function.' MODULE: '.$this->module);
431
+            $this->$function();
432
+            return true;
433
+        }
434
+        return false;
435
+    }
436 436
 
437
-	/**
438
-	 * Perform an action after to the specified action has occurred.
439
-	 * This can be overridde in a sub-class
440
-	 */
441
-	private function post_action(){
442
-		$function = 'post_' . $this->action;
443
-		if($this->hasFunction($function)){
444
-			$GLOBALS['log']->debug('Performing post_action');
445
-			$this->$function();
446
-			return true;
447
-		}
448
-		return false;
449
-	}
437
+    /**
438
+     * Perform an action after to the specified action has occurred.
439
+     * This can be overridde in a sub-class
440
+     */
441
+    private function post_action(){
442
+        $function = 'post_' . $this->action;
443
+        if($this->hasFunction($function)){
444
+            $GLOBALS['log']->debug('Performing post_action');
445
+            $this->$function();
446
+            return true;
447
+        }
448
+        return false;
449
+    }
450 450
 
451
-	/**
452
-	 * If there is no action found then display an error to the user.
453
-	 */
454
-	protected function no_action(){
455
-		sugar_die($GLOBALS['app_strings']['LBL_NO_ACTION']);
456
-	}
451
+    /**
452
+     * If there is no action found then display an error to the user.
453
+     */
454
+    protected function no_action(){
455
+        sugar_die($GLOBALS['app_strings']['LBL_NO_ACTION']);
456
+    }
457 457
 
458
-	/**
459
-	 * The default action handler for instances where we do not have access to process.
460
-	 */
461
-	protected function no_access(){
462
-		$this->view = 'noaccess';
463
-	}
458
+    /**
459
+     * The default action handler for instances where we do not have access to process.
460
+     */
461
+    protected function no_access(){
462
+        $this->view = 'noaccess';
463
+    }
464 464
 
465
-	///////////////////////////////////////////////
466
-	/////// HELPER FUNCTIONS
467
-	///////////////////////////////////////////////
465
+    ///////////////////////////////////////////////
466
+    /////// HELPER FUNCTIONS
467
+    ///////////////////////////////////////////////
468 468
 
469
-	/**
470
-	 * Determine if a given function exists on the objects
471
-	 * @param function - the function to check
472
-	 * @return true if the method exists on the object, false otherwise
473
-	 */
474
-	protected function hasFunction($function){
475
-		return method_exists($this, $function);
476
-	}
469
+    /**
470
+     * Determine if a given function exists on the objects
471
+     * @param function - the function to check
472
+     * @return true if the method exists on the object, false otherwise
473
+     */
474
+    protected function hasFunction($function){
475
+        return method_exists($this, $function);
476
+    }
477 477
 
478 478
 
479
-	/**
480
-	 * Set the url to which we will want to redirect
481
-	 *
482
-	 * @param string url - the url to which we will want to redirect
483
-	 */
484
-	protected function set_redirect($url){
485
-		$this->redirect_url = $url;
486
-	}
479
+    /**
480
+     * Set the url to which we will want to redirect
481
+     *
482
+     * @param string url - the url to which we will want to redirect
483
+     */
484
+    protected function set_redirect($url){
485
+        $this->redirect_url = $url;
486
+    }
487 487
 
488
-	/**
489
-	 * Perform redirection based on the redirect_url
490
-	 *
491
-	 */
492
-	protected function redirect(){
488
+    /**
489
+     * Perform redirection based on the redirect_url
490
+     *
491
+     */
492
+    protected function redirect(){
493 493
 
494
-		if(!empty($this->redirect_url))
495
-			SugarApplication::redirect($this->redirect_url);
496
-	}
494
+        if(!empty($this->redirect_url))
495
+            SugarApplication::redirect($this->redirect_url);
496
+    }
497 497
 
498
-	////////////////////////////////////////////////////////
499
-	////// DEFAULT ACTIONS
500
-	///////////////////////////////////////////////////////
498
+    ////////////////////////////////////////////////////////
499
+    ////// DEFAULT ACTIONS
500
+    ///////////////////////////////////////////////////////
501 501
 
502
-	/*
502
+    /*
503 503
 	 * Save a bean
504 504
 	 */
505 505
 
506
-	/**
507
-	 * Do some processing before saving the bean to the database.
508
-	 */
509
-	public function pre_save(){
510
-		if(!empty($_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $this->bean->assigned_user_id && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id && empty($GLOBALS['sugar_config']['exclude_notifications'][$this->bean->module_dir])){
511
-			$this->bean->notify_on_save = true;
512
-		}
513
-		$GLOBALS['log']->debug("SugarController:: performing pre_save.");
506
+    /**
507
+     * Do some processing before saving the bean to the database.
508
+     */
509
+    public function pre_save(){
510
+        if(!empty($_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $this->bean->assigned_user_id && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id && empty($GLOBALS['sugar_config']['exclude_notifications'][$this->bean->module_dir])){
511
+            $this->bean->notify_on_save = true;
512
+        }
513
+        $GLOBALS['log']->debug("SugarController:: performing pre_save.");
514 514
         require_once('include/SugarFields/SugarFieldHandler.php');
515 515
         $sfh = new SugarFieldHandler();
516
-		foreach($this->bean->field_defs as $field => $properties) {
517
-			$type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
518
-		    $sf = $sfh->getSugarField(ucfirst($type), true);
519
-			if(isset($_POST[$field])) {
520
-				if(is_array($_POST[$field]) && !empty($properties['isMultiSelect'])) {
521
-					if(empty($_POST[$field][0])) {
522
-						unset($_POST[$field][0]);
523
-					}
524
-					$_POST[$field] = encodeMultienumValue($_POST[$field]);
525
-				}
526
-				$this->bean->$field = $_POST[$field];
527
-			} else if(!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field . '_multiselect'])) {
528
-				$this->bean->$field = '';
529
-			}
516
+        foreach($this->bean->field_defs as $field => $properties) {
517
+            $type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
518
+            $sf = $sfh->getSugarField(ucfirst($type), true);
519
+            if(isset($_POST[$field])) {
520
+                if(is_array($_POST[$field]) && !empty($properties['isMultiSelect'])) {
521
+                    if(empty($_POST[$field][0])) {
522
+                        unset($_POST[$field][0]);
523
+                    }
524
+                    $_POST[$field] = encodeMultienumValue($_POST[$field]);
525
+                }
526
+                $this->bean->$field = $_POST[$field];
527
+            } else if(!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field . '_multiselect'])) {
528
+                $this->bean->$field = '';
529
+            }
530 530
             if($sf != null){
531 531
                 $sf->save($this->bean, $_POST, $field, $properties);
532 532
             }
533
-		}
534
-
535
-		foreach($this->bean->relationship_fields as $field=>$link){
536
-			if(!empty($_POST[$field])){
537
-				$this->bean->$field = $_POST[$field];
538
-			}
539
-		}
540
-		if(!$this->bean->ACLAccess('save')){
541
-			ACLController::displayNoAccess(true);
542
-			sugar_cleanup(true);
543
-		}
544
-	}
533
+        }
545 534
 
546
-	/**
547
-	 * Perform the actual save
548
-	 */
549
-	public function action_save(){
550
-		$this->bean->save(!empty($this->bean->notify_on_save));
551
-	}
535
+        foreach($this->bean->relationship_fields as $field=>$link){
536
+            if(!empty($_POST[$field])){
537
+                $this->bean->$field = $_POST[$field];
538
+            }
539
+        }
540
+        if(!$this->bean->ACLAccess('save')){
541
+            ACLController::displayNoAccess(true);
542
+            sugar_cleanup(true);
543
+        }
544
+    }
545
+
546
+    /**
547
+     * Perform the actual save
548
+     */
549
+    public function action_save(){
550
+        $this->bean->save(!empty($this->bean->notify_on_save));
551
+    }
552 552
 
553 553
 
554 554
     public function action_spot()
@@ -557,43 +557,43 @@  discard block
 block discarded – undo
557 557
     }
558 558
 
559 559
 
560
-	/**
561
-	 * Specify what happens after the save has occurred.
562
-	 */
563
-	protected function post_save(){
564
-		$module = (!empty($this->return_module) ? $this->return_module : $this->module);
565
-		$action = (!empty($this->return_action) ? $this->return_action : 'DetailView');
566
-		$id = (!empty($this->return_id) ? $this->return_id : $this->bean->id);
560
+    /**
561
+     * Specify what happens after the save has occurred.
562
+     */
563
+    protected function post_save(){
564
+        $module = (!empty($this->return_module) ? $this->return_module : $this->module);
565
+        $action = (!empty($this->return_action) ? $this->return_action : 'DetailView');
566
+        $id = (!empty($this->return_id) ? $this->return_id : $this->bean->id);
567 567
 
568
-		$url = "index.php?module=".$module."&action=".$action."&record=".$id;
569
-		$this->set_redirect($url);
570
-	}
568
+        $url = "index.php?module=".$module."&action=".$action."&record=".$id;
569
+        $this->set_redirect($url);
570
+    }
571 571
 
572
-	/*
572
+    /*
573 573
 	 * Delete a bean
574 574
 	 */
575 575
 
576
-	/**
577
-	 * Perform the actual deletion.
578
-	 */
579
-	protected function action_delete(){
580
-		//do any pre delete processing
581
-		//if there is some custom logic for deletion.
582
-		if(!empty($_REQUEST['record'])){
583
-			if(!$this->bean->ACLAccess('Delete')){
584
-				ACLController::displayNoAccess(true);
585
-				sugar_cleanup(true);
586
-			}
587
-			$this->bean->mark_deleted($_REQUEST['record']);
588
-		}else{
589
-			sugar_die("A record number must be specified to delete");
590
-		}
591
-	}
576
+    /**
577
+     * Perform the actual deletion.
578
+     */
579
+    protected function action_delete(){
580
+        //do any pre delete processing
581
+        //if there is some custom logic for deletion.
582
+        if(!empty($_REQUEST['record'])){
583
+            if(!$this->bean->ACLAccess('Delete')){
584
+                ACLController::displayNoAccess(true);
585
+                sugar_cleanup(true);
586
+            }
587
+            $this->bean->mark_deleted($_REQUEST['record']);
588
+        }else{
589
+            sugar_die("A record number must be specified to delete");
590
+        }
591
+    }
592 592
 
593
-	/**
594
-	 * Specify what happens after the deletion has occurred.
595
-	 */
596
-	protected function post_delete(){
593
+    /**
594
+     * Specify what happens after the deletion has occurred.
595
+     */
596
+    protected function post_delete(){
597 597
         if (empty($_REQUEST['return_url'])) {
598 598
             $return_module = isset($_REQUEST['return_module']) ?
599 599
                 $_REQUEST['return_module'] :
@@ -609,23 +609,23 @@  discard block
 block discarded – undo
609 609
             $url = $_REQUEST['return_url'];
610 610
         }
611 611
 
612
-		//eggsurplus Bug 23816: maintain VCR after an edit/save. If it is a duplicate then don't worry about it. The offset is now worthless.
613
-		if(isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
614
-		    $url .= "&offset=".$_REQUEST['offset'];
615
-		}
612
+        //eggsurplus Bug 23816: maintain VCR after an edit/save. If it is a duplicate then don't worry about it. The offset is now worthless.
613
+        if(isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
614
+            $url .= "&offset=".$_REQUEST['offset'];
615
+        }
616 616
 
617
-		$this->set_redirect($url);
618
-	}
619
-	/**
620
-	 * Perform the actual massupdate.
621
-	 */
622
-	protected function action_massupdate(){
623
-		if(!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))){
624
-			if(!empty($_REQUEST['Delete']) && $_REQUEST['Delete']=='true' && !$this->bean->ACLAccess('delete')
617
+        $this->set_redirect($url);
618
+    }
619
+    /**
620
+     * Perform the actual massupdate.
621
+     */
622
+    protected function action_massupdate(){
623
+        if(!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))){
624
+            if(!empty($_REQUEST['Delete']) && $_REQUEST['Delete']=='true' && !$this->bean->ACLAccess('delete')
625 625
                 || (empty($_REQUEST['Delete']) || $_REQUEST['Delete']!='true') && !$this->bean->ACLAccess('save')){
626
-				ACLController::displayNoAccess(true);
627
-				sugar_cleanup(true);
628
-			}
626
+                ACLController::displayNoAccess(true);
627
+                sugar_cleanup(true);
628
+            }
629 629
 
630 630
             set_time_limit(0);//I'm wondering if we will set it never goes timeout here.
631 631
             // until we have more efficient way of handling MU, we have to disable the limit
@@ -651,35 +651,35 @@  discard block
 block discarded – undo
651 651
             unset($_REQUEST[$seed->module_dir.'2_'.strtoupper($seed->object_name).'_offset']);//after massupdate, the page should redirect to no offset page
652 652
             $storeQuery->saveFromRequest($_REQUEST['module']);
653 653
             $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']);//for post_massupdate, to go back to original page.
654
-		}else{
655
-			sugar_die("You must massupdate at least one record");
656
-		}
657
-	}
658
-	/**
659
-	 * Specify what happens after the massupdate has occurred.
660
-	 */
661
-	protected function post_massupdate(){
662
-		$return_module = isset($_REQUEST['return_module']) ?
663
-			$_REQUEST['return_module'] :
664
-			$GLOBALS['sugar_config']['default_module'];
665
-		$return_action = isset($_REQUEST['return_action']) ?
666
-			$_REQUEST['return_action'] :
667
-			$GLOBALS['sugar_config']['default_action'];
668
-		$url = "index.php?module=".$return_module."&action=".$return_action;
669
-		if($return_module == 'Emails'){//specificly for My Achieves
670
-			if(!empty($this->req_for_email['type']) && !empty($this->req_for_email['ie_assigned_user_id'])) {
671
-				$url = $url . "&type=".$this->req_for_email['type']."&assigned_user_id=".$this->req_for_email['ie_assigned_user_id'];
672
-			}
673
-		}
674
-		$this->set_redirect($url);
675
-	}
676
-	/**
677
-	 * Perform the listview action
678
-	 */
679
-	protected function action_listview(){
680
-		$this->view_object_map['bean'] = $this->bean;
681
-		$this->view = 'list';
682
-	}
654
+        }else{
655
+            sugar_die("You must massupdate at least one record");
656
+        }
657
+    }
658
+    /**
659
+     * Specify what happens after the massupdate has occurred.
660
+     */
661
+    protected function post_massupdate(){
662
+        $return_module = isset($_REQUEST['return_module']) ?
663
+            $_REQUEST['return_module'] :
664
+            $GLOBALS['sugar_config']['default_module'];
665
+        $return_action = isset($_REQUEST['return_action']) ?
666
+            $_REQUEST['return_action'] :
667
+            $GLOBALS['sugar_config']['default_action'];
668
+        $url = "index.php?module=".$return_module."&action=".$return_action;
669
+        if($return_module == 'Emails'){//specificly for My Achieves
670
+            if(!empty($this->req_for_email['type']) && !empty($this->req_for_email['ie_assigned_user_id'])) {
671
+                $url = $url . "&type=".$this->req_for_email['type']."&assigned_user_id=".$this->req_for_email['ie_assigned_user_id'];
672
+            }
673
+        }
674
+        $this->set_redirect($url);
675
+    }
676
+    /**
677
+     * Perform the listview action
678
+     */
679
+    protected function action_listview(){
680
+        $this->view_object_map['bean'] = $this->bean;
681
+        $this->view = 'list';
682
+    }
683 683
 
684 684
 /*
685 685
 
@@ -688,63 +688,63 @@  discard block
 block discarded – undo
688 688
 	}
689 689
 */
690 690
 
691
-	/**
692
-	 * Action to handle when using a file as was done in previous versions of Sugar.
693
-	 */
694
-	protected function action_default(){
695
-		$this->view = 'classic';
696
-	}
691
+    /**
692
+     * Action to handle when using a file as was done in previous versions of Sugar.
693
+     */
694
+    protected function action_default(){
695
+        $this->view = 'classic';
696
+    }
697 697
 
698
-	/**
699
-	 * this method id used within a Dashlet when performing an ajax call
700
-	 */
701
-	protected function action_callmethoddashlet(){
702
-		if(!empty($_REQUEST['id'])) {
703
-		    $id = $_REQUEST['id'];
704
-		    $requestedMethod = $_REQUEST['method'];
705
-		    $dashletDefs = $GLOBALS['current_user']->getPreference('dashlets', 'Home'); // load user's dashlets config
706
-		    if(!empty($dashletDefs[$id])) {
707
-		        require_once($dashletDefs[$id]['fileLocation']);
708
-
709
-		        $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
710
-
711
-		        if(method_exists($dashlet, $requestedMethod) || method_exists($dashlet, '__call')) {
712
-		            echo $dashlet->$requestedMethod();
713
-		        }
714
-		        else {
715
-		            echo 'no method';
716
-		        }
717
-		    }
718
-		}
719
-	}
698
+    /**
699
+     * this method id used within a Dashlet when performing an ajax call
700
+     */
701
+    protected function action_callmethoddashlet(){
702
+        if(!empty($_REQUEST['id'])) {
703
+            $id = $_REQUEST['id'];
704
+            $requestedMethod = $_REQUEST['method'];
705
+            $dashletDefs = $GLOBALS['current_user']->getPreference('dashlets', 'Home'); // load user's dashlets config
706
+            if(!empty($dashletDefs[$id])) {
707
+                require_once($dashletDefs[$id]['fileLocation']);
708
+
709
+                $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
710
+
711
+                if(method_exists($dashlet, $requestedMethod) || method_exists($dashlet, '__call')) {
712
+                    echo $dashlet->$requestedMethod();
713
+                }
714
+                else {
715
+                    echo 'no method';
716
+                }
717
+            }
718
+        }
719
+    }
720 720
 
721
-	/**
722
-	 * this method is used within a Dashlet when the options configuration is posted
723
-	 */
724
-	protected function action_configuredashlet(){
725
-		global $current_user, $mod_strings;
726
-
727
-		if(!empty($_REQUEST['id'])) {
728
-		    $id = $_REQUEST['id'];
729
-		    $dashletDefs = $current_user->getPreference('dashlets', $_REQUEST['module']); // load user's dashlets config
730
-		    require_once($dashletDefs[$id]['fileLocation']);
731
-
732
-		    $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
733
-		    if(!empty($_REQUEST['configure']) && $_REQUEST['configure']) { // save settings
734
-		        $dashletDefs[$id]['options'] = $dashlet->saveOptions($_REQUEST);
735
-		        $current_user->setPreference('dashlets', $dashletDefs, 0, $_REQUEST['module']);
736
-		    }
737
-		    else { // display options
738
-		        $json = getJSONobj();
739
-		        return 'result = ' . $json->encode((array('header' => $dashlet->title . ' : ' . $mod_strings['LBL_OPTIONS'],
740
-		                                                 'body'  => $dashlet->displayOptions())));
741
-
742
-		    }
743
-		}
744
-		else {
745
-		    return '0';
746
-		}
747
-	}
721
+    /**
722
+     * this method is used within a Dashlet when the options configuration is posted
723
+     */
724
+    protected function action_configuredashlet(){
725
+        global $current_user, $mod_strings;
726
+
727
+        if(!empty($_REQUEST['id'])) {
728
+            $id = $_REQUEST['id'];
729
+            $dashletDefs = $current_user->getPreference('dashlets', $_REQUEST['module']); // load user's dashlets config
730
+            require_once($dashletDefs[$id]['fileLocation']);
731
+
732
+            $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
733
+            if(!empty($_REQUEST['configure']) && $_REQUEST['configure']) { // save settings
734
+                $dashletDefs[$id]['options'] = $dashlet->saveOptions($_REQUEST);
735
+                $current_user->setPreference('dashlets', $dashletDefs, 0, $_REQUEST['module']);
736
+            }
737
+            else { // display options
738
+                $json = getJSONobj();
739
+                return 'result = ' . $json->encode((array('header' => $dashlet->title . ' : ' . $mod_strings['LBL_OPTIONS'],
740
+                                                            'body'  => $dashlet->displayOptions())));
741
+
742
+            }
743
+        }
744
+        else {
745
+            return '0';
746
+        }
747
+    }
748 748
 
749 749
     /**
750 750
      * Global method to delete an attachment
@@ -774,84 +774,84 @@  discard block
 block discarded – undo
774 774
         sugar_cleanup(true);
775 775
     }
776 776
 
777
-	/**
778
-	 * getActionFilename
779
-	 */
780
-	public static function getActionFilename($action) {
781
-	   if(isset(self::$action_case_file[$action])) {
782
-	   	  return self::$action_case_file[$action];
783
-	   }
784
-	   return $action;
785
-	}
777
+    /**
778
+     * getActionFilename
779
+     */
780
+    public static function getActionFilename($action) {
781
+        if(isset(self::$action_case_file[$action])) {
782
+                return self::$action_case_file[$action];
783
+        }
784
+        return $action;
785
+    }
786 786
 
787
-	/********************************************************************/
788
-	// 				PROCESS TASKS
789
-	/********************************************************************/
787
+    /********************************************************************/
788
+    // 				PROCESS TASKS
789
+    /********************************************************************/
790 790
 
791
-	/**
792
-	 * Given the module and action, determine whether the super/admin has prevented access
793
-	 * to this url. In addition if any links specified for this module, load the links into
794
-	 * GLOBALS
795
-	 *
796
-	 * @return true if we want to stop processing, false if processing should continue
797
-	 */
798
-	private function blockFileAccess(){
799
-		//check if the we have enabled file_access_control and if so then check the mappings on the request;
800
-		if(!empty($GLOBALS['sugar_config']['admin_access_control']) && $GLOBALS['sugar_config']['admin_access_control']){
801
-			$this->loadMapping('file_access_control_map');
802
-			//since we have this turned on, check the mapping file
803
-			$module = strtolower($this->module);
804
-			$action = strtolower($this->do_action);
805
-			if(!empty($this->file_access_control_map['modules'][$module]['links'])){
806
-				$GLOBALS['admin_access_control_links'] = $this->file_access_control_map['modules'][$module]['links'];
807
-			}
808
-
809
-			if(!empty($this->file_access_control_map['modules'][$module]['actions']) && (in_array($action, $this->file_access_control_map['modules'][$module]['actions']) || !empty($this->file_access_control_map['modules'][$module]['actions'][$action]))){
810
-				//check params
811
-				if(!empty($this->file_access_control_map['modules'][$module]['actions'][$action]['params'])){
812
-					$block = true;
813
-					$params = $this->file_access_control_map['modules'][$module]['actions'][$action]['params'];
814
-					foreach($params as $param => $paramVals){
815
-						if(!empty($_REQUEST[$param])){
816
-							if(!in_array($_REQUEST[$param], $paramVals)){
817
-								$block = false;
818
-								break;
819
-							}
820
-						}
821
-					}
822
-					if($block){
823
-						$this->_processed = true;
824
-						$this->no_access();
825
-					}
826
-				}else{
827
-					$this->_processed = true;
828
-					$this->no_access();
829
-				}
830
-			}
831
-		}else
832
-			$this->_processed = false;
833
-	}
791
+    /**
792
+     * Given the module and action, determine whether the super/admin has prevented access
793
+     * to this url. In addition if any links specified for this module, load the links into
794
+     * GLOBALS
795
+     *
796
+     * @return true if we want to stop processing, false if processing should continue
797
+     */
798
+    private function blockFileAccess(){
799
+        //check if the we have enabled file_access_control and if so then check the mappings on the request;
800
+        if(!empty($GLOBALS['sugar_config']['admin_access_control']) && $GLOBALS['sugar_config']['admin_access_control']){
801
+            $this->loadMapping('file_access_control_map');
802
+            //since we have this turned on, check the mapping file
803
+            $module = strtolower($this->module);
804
+            $action = strtolower($this->do_action);
805
+            if(!empty($this->file_access_control_map['modules'][$module]['links'])){
806
+                $GLOBALS['admin_access_control_links'] = $this->file_access_control_map['modules'][$module]['links'];
807
+            }
834 808
 
835
-	/**
836
-	 * This code is part of the entry points reworking. We have consolidated all
837
-	 * entry points to go through index.php. Now in order to bring up an entry point
838
-	 * it will follow the format:
839
-	 * 'index.php?entryPoint=download'
840
-	 * the download entry point is mapped in the following file: entry_point_registry.php
841
-	 *
842
-	 */
843
-	private function handleEntryPoint(){
844
-		if(!empty($_REQUEST['entryPoint'])){
845
-			$this->loadMapping('entry_point_registry');
846
-			$entryPoint = $_REQUEST['entryPoint'];
847
-
848
-			if(!empty($this->entry_point_registry[$entryPoint])){
849
-				require_once($this->entry_point_registry[$entryPoint]['file']);
850
-				$this->_processed = true;
851
-				$this->view = '';
852
-			}
853
-		}
854
-	}
809
+            if(!empty($this->file_access_control_map['modules'][$module]['actions']) && (in_array($action, $this->file_access_control_map['modules'][$module]['actions']) || !empty($this->file_access_control_map['modules'][$module]['actions'][$action]))){
810
+                //check params
811
+                if(!empty($this->file_access_control_map['modules'][$module]['actions'][$action]['params'])){
812
+                    $block = true;
813
+                    $params = $this->file_access_control_map['modules'][$module]['actions'][$action]['params'];
814
+                    foreach($params as $param => $paramVals){
815
+                        if(!empty($_REQUEST[$param])){
816
+                            if(!in_array($_REQUEST[$param], $paramVals)){
817
+                                $block = false;
818
+                                break;
819
+                            }
820
+                        }
821
+                    }
822
+                    if($block){
823
+                        $this->_processed = true;
824
+                        $this->no_access();
825
+                    }
826
+                }else{
827
+                    $this->_processed = true;
828
+                    $this->no_access();
829
+                }
830
+            }
831
+        }else
832
+            $this->_processed = false;
833
+    }
834
+
835
+    /**
836
+     * This code is part of the entry points reworking. We have consolidated all
837
+     * entry points to go through index.php. Now in order to bring up an entry point
838
+     * it will follow the format:
839
+     * 'index.php?entryPoint=download'
840
+     * the download entry point is mapped in the following file: entry_point_registry.php
841
+     *
842
+     */
843
+    private function handleEntryPoint(){
844
+        if(!empty($_REQUEST['entryPoint'])){
845
+            $this->loadMapping('entry_point_registry');
846
+            $entryPoint = $_REQUEST['entryPoint'];
847
+
848
+            if(!empty($this->entry_point_registry[$entryPoint])){
849
+                require_once($this->entry_point_registry[$entryPoint]['file']);
850
+                $this->_processed = true;
851
+                $this->view = '';
852
+            }
853
+        }
854
+    }
855 855
 
856 856
     /**
857 857
      * Checks to see if the requested entry point requires auth
@@ -869,67 +869,67 @@  discard block
 block discarded – undo
869 869
         return true;
870 870
     }
871 871
 
872
-	/**
873
-	 * Meant to handle old views e.g. DetailView.php.
874
-	 *
875
-	 */
876
-	protected function callLegacyCode()
877
-	{
878
-		$file = self::getActionFilename($this->do_action);
879
-		if ( isset($this->action_view_map[strtolower($this->do_action)]) ) {
880
-	        $action = $this->action_view_map[strtolower($this->do_action)];
881
-	    }
882
-	    else {
883
-	        $action = $this->do_action;
884
-	    }
885
-	    // index actions actually maps to the view.list.php view
886
-	    if ( $action == 'index' ) {
887
-	        $action = 'list';
888
-	    }
889
-
890
-		if ((file_exists('modules/' . $this->module . '/'. $file . '.php')
872
+    /**
873
+     * Meant to handle old views e.g. DetailView.php.
874
+     *
875
+     */
876
+    protected function callLegacyCode()
877
+    {
878
+        $file = self::getActionFilename($this->do_action);
879
+        if ( isset($this->action_view_map[strtolower($this->do_action)]) ) {
880
+            $action = $this->action_view_map[strtolower($this->do_action)];
881
+        }
882
+        else {
883
+            $action = $this->do_action;
884
+        }
885
+        // index actions actually maps to the view.list.php view
886
+        if ( $action == 'index' ) {
887
+            $action = 'list';
888
+        }
889
+
890
+        if ((file_exists('modules/' . $this->module . '/'. $file . '.php')
891 891
                 && !file_exists('modules/' . $this->module . '/views/view.'. $action . '.php'))
892 892
             || (file_exists('custom/modules/' . $this->module . '/'. $file . '.php')
893 893
                 && !file_exists('custom/modules/' . $this->module . '/views/view.'. $action . '.php'))
894 894
             ) {
895
-			// A 'classic' module, using the old pre-MVC display files
896
-			// We should now discard the bean we just obtained for tracking as the pre-MVC module will instantiate its own
897
-			unset($GLOBALS['FOCUS']);
898
-			$GLOBALS['log']->debug('Module:' . $this->module . ' using file: '. $file);
899
-			$this->action_default();
900
-			$this->_processed = true;
901
-		}
902
-	}
895
+            // A 'classic' module, using the old pre-MVC display files
896
+            // We should now discard the bean we just obtained for tracking as the pre-MVC module will instantiate its own
897
+            unset($GLOBALS['FOCUS']);
898
+            $GLOBALS['log']->debug('Module:' . $this->module . ' using file: '. $file);
899
+            $this->action_default();
900
+            $this->_processed = true;
901
+        }
902
+    }
903 903
 
904
-	/**
905
-	 * If the action has been remapped to a different action as defined in
906
-	 * action_file_map.php or action_view_map.php load those maps here.
907
-	 *
908
-	 */
909
-	private function handleActionMaps(){
910
-		if(!empty($this->action_file_map[strtolower($this->do_action)])){
911
-			$this->view = '';
912
-			$GLOBALS['log']->debug('Using Action File Map:' . $this->action_file_map[strtolower($this->do_action)]);
913
-			require_once($this->action_file_map[strtolower($this->do_action)]);
914
-			$this->_processed = true;
915
-		}elseif(!empty($this->action_view_map[strtolower($this->do_action)])){
916
-			$GLOBALS['log']->debug('Using Action View Map:' . $this->action_view_map[strtolower($this->do_action)]);
917
-			$this->view = $this->action_view_map[strtolower($this->do_action)];
918
-			$this->_processed = true;
919
-		}else
920
-			$this->no_action();
921
-	}
904
+    /**
905
+     * If the action has been remapped to a different action as defined in
906
+     * action_file_map.php or action_view_map.php load those maps here.
907
+     *
908
+     */
909
+    private function handleActionMaps(){
910
+        if(!empty($this->action_file_map[strtolower($this->do_action)])){
911
+            $this->view = '';
912
+            $GLOBALS['log']->debug('Using Action File Map:' . $this->action_file_map[strtolower($this->do_action)]);
913
+            require_once($this->action_file_map[strtolower($this->do_action)]);
914
+            $this->_processed = true;
915
+        }elseif(!empty($this->action_view_map[strtolower($this->do_action)])){
916
+            $GLOBALS['log']->debug('Using Action View Map:' . $this->action_view_map[strtolower($this->do_action)]);
917
+            $this->view = $this->action_view_map[strtolower($this->do_action)];
918
+            $this->_processed = true;
919
+        }else
920
+            $this->no_action();
921
+    }
922 922
 
923
-	/**
924
-	 * Actually remap the action if required.
925
-	 *
926
-	 */
927
-	protected function remapAction(){
928
-		if(!empty($this->action_remap[$this->do_action])){
929
-			$this->action = $this->action_remap[$this->do_action];
930
-			$this->do_action = $this->action;
931
-		}
932
-	}
923
+    /**
924
+     * Actually remap the action if required.
925
+     *
926
+     */
927
+    protected function remapAction(){
928
+        if(!empty($this->action_remap[$this->do_action])){
929
+            $this->action = $this->action_remap[$this->do_action];
930
+            $this->do_action = $this->action;
931
+        }
932
+    }
933 933
 
934 934
 }
935 935
 ?>
Please login to merge, or discard this patch.
Spacing   +146 added lines, -151 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
  * Main SugarCRM controller
44 44
  * @api
45 45
  */
46
-class SugarController{
46
+class SugarController {
47 47
 	/**
48 48
 	 * remap actions in here
49 49
 	 * e.g. make all detail views go to edit views
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * Constructor. This ie meant tot load up the module, action, record as well
163 163
 	 * as the mapping arrays.
164 164
 	 */
165
-	public function __construct(){
165
+	public function __construct() {
166 166
 	}
167 167
 
168 168
 	/**
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 	 * on the controller.
171 171
 	 *
172 172
 	 */
173
-	public function setup($module = ''){
174
-		if(empty($module) && !empty($_REQUEST['module']))
173
+	public function setup($module = '') {
174
+		if (empty($module) && !empty($_REQUEST['module']))
175 175
 			$module = $_REQUEST['module'];
176 176
 		//set the module
177
-		if(!empty($module))
177
+		if (!empty($module))
178 178
 			$this->setModule($module);
179 179
 
180
-		if(!empty($_REQUEST['target_module']) && $_REQUEST['target_module'] != 'undefined') {
180
+		if (!empty($_REQUEST['target_module']) && $_REQUEST['target_module'] != 'undefined') {
181 181
 			$this->target_module = $_REQUEST['target_module'];
182 182
 		}
183 183
 		//set properties on the controller from the $_REQUEST
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @param object $module
192 192
 	 */
193
-	public function setModule($module){
193
+	public function setModule($module) {
194 194
 		$this->module = $module;
195 195
 	}
196 196
 
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
 	 * Set properties on the Controller from the $_REQUEST
199 199
 	 *
200 200
 	 */
201
-	private function loadPropertiesFromRequest(){
202
-		if(!empty($_REQUEST['action']))
201
+	private function loadPropertiesFromRequest() {
202
+		if (!empty($_REQUEST['action']))
203 203
 			$this->action = $_REQUEST['action'];
204
-		if(!empty($_REQUEST['record']))
204
+		if (!empty($_REQUEST['record']))
205 205
 			$this->record = $_REQUEST['record'];
206
-		if(!empty($_REQUEST['view']))
206
+		if (!empty($_REQUEST['view']))
207 207
 			$this->view = $_REQUEST['view'];
208
-		if(!empty($_REQUEST['return_module']))
208
+		if (!empty($_REQUEST['return_module']))
209 209
 			$this->return_module = $_REQUEST['return_module'];
210
-		if(!empty($_REQUEST['return_action']))
210
+		if (!empty($_REQUEST['return_action']))
211 211
 			$this->return_action = $_REQUEST['return_action'];
212
-		if(!empty($_REQUEST['return_id']))
212
+		if (!empty($_REQUEST['return_id']))
213 213
 			$this->return_id = $_REQUEST['return_id'];
214 214
 	}
215 215
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * Load map files for use within the Controller
218 218
 	 *
219 219
 	 */
220
-	private function loadMappings(){
220
+	private function loadMappings() {
221 221
 		$this->loadMapping('action_view_map');
222 222
 		$this->loadMapping('action_file_map');
223 223
 		$this->loadMapping('action_remap', true);
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	public function loadBean()
230 230
 	{
231
-		if(!empty($GLOBALS['beanList'][$this->module])){
231
+		if (!empty($GLOBALS['beanList'][$this->module])) {
232 232
 			$class = $GLOBALS['beanList'][$this->module];
233
-			if(!empty($GLOBALS['beanFiles'][$class])){
233
+			if (!empty($GLOBALS['beanFiles'][$class])) {
234 234
 				require_once($GLOBALS['beanFiles'][$class]);
235 235
 				$this->bean = new $class();
236
-				if(!empty($this->record)){
236
+				if (!empty($this->record)) {
237 237
 					$this->bean->retrieve($this->record);
238
-					if($this->bean)
238
+					if ($this->bean)
239 239
 						$GLOBALS['FOCUS'] = $this->bean;
240 240
 				}
241 241
 			}
@@ -245,38 +245,38 @@  discard block
 block discarded – undo
245 245
 	/**
246 246
 	 * Generic load method to load mapping arrays.
247 247
 	 */
248
-	private function loadMapping($var, $merge = false){
249
-		$$var = sugar_cache_retrieve("CONTROLLER_". $var . "_".$this->module);
250
-		if(!$$var){
251
-			if($merge && !empty($this->$var)){
248
+	private function loadMapping($var, $merge = false) {
249
+		$$var = sugar_cache_retrieve("CONTROLLER_".$var."_".$this->module);
250
+		if (!$$var) {
251
+			if ($merge && !empty($this->$var)) {
252 252
 				$$var = $this->$var;
253
-			}else{
253
+			} else {
254 254
 				$$var = array();
255 255
 			}
256
-			if(file_exists('include/MVC/Controller/'. $var . '.php')){
257
-				require('include/MVC/Controller/'. $var . '.php');
256
+			if (file_exists('include/MVC/Controller/'.$var.'.php')) {
257
+				require('include/MVC/Controller/'.$var.'.php');
258 258
 			}
259
-			if(file_exists('modules/'.$this->module.'/'. $var . '.php')){
260
-				require('modules/'.$this->module.'/'. $var . '.php');
259
+			if (file_exists('modules/'.$this->module.'/'.$var.'.php')) {
260
+				require('modules/'.$this->module.'/'.$var.'.php');
261 261
 			}
262
-			if(file_exists('custom/modules/'.$this->module.'/'. $var . '.php')){
263
-				require('custom/modules/'.$this->module.'/'. $var . '.php');
262
+			if (file_exists('custom/modules/'.$this->module.'/'.$var.'.php')) {
263
+				require('custom/modules/'.$this->module.'/'.$var.'.php');
264 264
 			}
265
-			if(file_exists('custom/include/MVC/Controller/'. $var . '.php')){
266
-				require('custom/include/MVC/Controller/'. $var . '.php');
265
+			if (file_exists('custom/include/MVC/Controller/'.$var.'.php')) {
266
+				require('custom/include/MVC/Controller/'.$var.'.php');
267 267
 			}
268 268
 
269 269
             // entry_point_registry -> EntryPointRegistry
270 270
 
271
-			$varname = str_replace(" ","",ucwords(str_replace("_"," ", $var)));
272
-            if(file_exists("custom/application/Ext/$varname/$var.ext.php")){
271
+			$varname = str_replace(" ", "", ucwords(str_replace("_", " ", $var)));
272
+            if (file_exists("custom/application/Ext/$varname/$var.ext.php")) {
273 273
 				require("custom/application/Ext/$varname/$var.ext.php");
274 274
 	        }
275
-			if(file_exists("custom/modules/{$this->module}/Ext/$varname/$var.ext.php")){
275
+			if (file_exists("custom/modules/{$this->module}/Ext/$varname/$var.ext.php")) {
276 276
 				require("custom/modules/{$this->module}/Ext/$varname/$var.ext.php");
277 277
 			}
278 278
 
279
-			sugar_cache_put("CONTROLLER_". $var . "_".$this->module, $$var);
279
+			sugar_cache_put("CONTROLLER_".$var."_".$this->module, $$var);
280 280
 		}
281 281
 		$this->$var = $$var;
282 282
 	}
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
         try
291 291
         {
292 292
             $this->process();
293
-            if(!empty($this->view))
293
+            if (!empty($this->view))
294 294
             {
295 295
                 $this->processView();
296 296
             }
297
-            elseif(!empty($this->redirect_url))
297
+            elseif (!empty($this->redirect_url))
298 298
             {
299 299
             			$this->redirect();
300 300
             }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
       */
315 315
     protected function handleException(Exception $e)
316 316
     {
317
-        $GLOBALS['log']->fatal('Exception in Controller: ' . $e->getMessage());
317
+        $GLOBALS['log']->fatal('Exception in Controller: '.$e->getMessage());
318 318
         $logicHook = new LogicHook();
319 319
 
320 320
         if (isset($this->bean))
@@ -331,18 +331,18 @@  discard block
 block discarded – undo
331 331
 	/**
332 332
 	 * Display the appropriate view.
333 333
 	 */
334
-	private function processView(){
335
-		if(!isset($this->view_object_map['remap_action']) && isset($this->action_view_map[strtolower($this->action)]))
334
+	private function processView() {
335
+		if (!isset($this->view_object_map['remap_action']) && isset($this->action_view_map[strtolower($this->action)]))
336 336
 		{
337 337
 		  $this->view_object_map['remap_action'] = $this->action_view_map[strtolower($this->action)];
338 338
 		}
339 339
 		$view = ViewFactory::loadView($this->view, $this->module, $this->bean, $this->view_object_map, $this->target_module);
340 340
 		$GLOBALS['current_view'] = $view;
341
-		if(!empty($this->bean) && !$this->bean->ACLAccess($view->type) && $view->type != 'list'){
341
+		if (!empty($this->bean) && !$this->bean->ACLAccess($view->type) && $view->type != 'list') {
342 342
 			ACLController::displayNoAccess(true);
343 343
 			sugar_cleanup(true);
344 344
 		}
345
-		if(isset($this->errors)){
345
+		if (isset($this->errors)) {
346 346
 		  $view->errors = $this->errors;
347 347
 		}
348 348
 		$view->process();
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 * 1) check for file
362 362
 	 * 2) check for action
363 363
 	 */
364
-	public function process(){
364
+	public function process() {
365 365
 		$GLOBALS['action'] = $this->action;
366 366
 		$GLOBALS['module'] = $this->module;
367 367
 
368 368
 		//check to ensure we have access to the module.
369
-		if($this->hasAccess){
369
+		if ($this->hasAccess) {
370 370
 			$this->do_action = $this->action;
371 371
 
372 372
 			$file = self::getActionFilename($this->do_action);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
             }
385 385
 
386 386
 			$this->redirect();
387
-		}else{
387
+		} else {
388 388
 			$this->no_access();
389 389
 		}
390 390
 	}
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 	 * false otherwise.  This is important b/c if none of these methods exists, then we will run the
399 399
 	 * action_default() method.
400 400
 	 */
401
-	protected function handle_action(){
401
+	protected function handle_action() {
402 402
 		$processed = false;
403
-		foreach($this->tasks as $task){
403
+		foreach ($this->tasks as $task) {
404 404
 			$processed = ($this->$task() || $processed);
405 405
 		}
406 406
 		$this->_processed = $processed;
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 	 * Perform an action prior to the specified action.
411 411
 	 * This can be overridde in a sub-class
412 412
 	 */
413
-	private function pre_action(){
414
-		$function = 'pre_' . $this->action;
415
-		if($this->hasFunction($function)){
413
+	private function pre_action() {
414
+		$function = 'pre_'.$this->action;
415
+		if ($this->hasFunction($function)) {
416 416
 			$GLOBALS['log']->debug('Performing pre_action');
417 417
 			$this->$function();
418 418
 			return true;
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
 	 * Perform the specified action.
425 425
 	 * This can be overridde in a sub-class
426 426
 	 */
427
-	private function do_action(){
428
-		$function =  'action_'. strtolower($this->do_action);
429
-		if($this->hasFunction($function)){
427
+	private function do_action() {
428
+		$function = 'action_'.strtolower($this->do_action);
429
+		if ($this->hasFunction($function)) {
430 430
 			$GLOBALS['log']->debug('Performing action: '.$function.' MODULE: '.$this->module);
431 431
 			$this->$function();
432 432
 			return true;
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 	 * Perform an action after to the specified action has occurred.
439 439
 	 * This can be overridde in a sub-class
440 440
 	 */
441
-	private function post_action(){
442
-		$function = 'post_' . $this->action;
443
-		if($this->hasFunction($function)){
441
+	private function post_action() {
442
+		$function = 'post_'.$this->action;
443
+		if ($this->hasFunction($function)) {
444 444
 			$GLOBALS['log']->debug('Performing post_action');
445 445
 			$this->$function();
446 446
 			return true;
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
 	/**
452 452
 	 * If there is no action found then display an error to the user.
453 453
 	 */
454
-	protected function no_action(){
454
+	protected function no_action() {
455 455
 		sugar_die($GLOBALS['app_strings']['LBL_NO_ACTION']);
456 456
 	}
457 457
 
458 458
 	/**
459 459
 	 * The default action handler for instances where we do not have access to process.
460 460
 	 */
461
-	protected function no_access(){
461
+	protected function no_access() {
462 462
 		$this->view = 'noaccess';
463 463
 	}
464 464
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @param function - the function to check
472 472
 	 * @return true if the method exists on the object, false otherwise
473 473
 	 */
474
-	protected function hasFunction($function){
474
+	protected function hasFunction($function) {
475 475
 		return method_exists($this, $function);
476 476
 	}
477 477
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @param string url - the url to which we will want to redirect
483 483
 	 */
484
-	protected function set_redirect($url){
484
+	protected function set_redirect($url) {
485 485
 		$this->redirect_url = $url;
486 486
 	}
487 487
 
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
 	 * Perform redirection based on the redirect_url
490 490
 	 *
491 491
 	 */
492
-	protected function redirect(){
492
+	protected function redirect() {
493 493
 
494
-		if(!empty($this->redirect_url))
494
+		if (!empty($this->redirect_url))
495 495
 			SugarApplication::redirect($this->redirect_url);
496 496
 	}
497 497
 
@@ -506,38 +506,38 @@  discard block
 block discarded – undo
506 506
 	/**
507 507
 	 * Do some processing before saving the bean to the database.
508 508
 	 */
509
-	public function pre_save(){
510
-		if(!empty($_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $this->bean->assigned_user_id && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id && empty($GLOBALS['sugar_config']['exclude_notifications'][$this->bean->module_dir])){
509
+	public function pre_save() {
510
+		if (!empty($_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $this->bean->assigned_user_id && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id && empty($GLOBALS['sugar_config']['exclude_notifications'][$this->bean->module_dir])) {
511 511
 			$this->bean->notify_on_save = true;
512 512
 		}
513 513
 		$GLOBALS['log']->debug("SugarController:: performing pre_save.");
514 514
         require_once('include/SugarFields/SugarFieldHandler.php');
515 515
         $sfh = new SugarFieldHandler();
516
-		foreach($this->bean->field_defs as $field => $properties) {
516
+		foreach ($this->bean->field_defs as $field => $properties) {
517 517
 			$type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
518 518
 		    $sf = $sfh->getSugarField(ucfirst($type), true);
519
-			if(isset($_POST[$field])) {
520
-				if(is_array($_POST[$field]) && !empty($properties['isMultiSelect'])) {
521
-					if(empty($_POST[$field][0])) {
519
+			if (isset($_POST[$field])) {
520
+				if (is_array($_POST[$field]) && !empty($properties['isMultiSelect'])) {
521
+					if (empty($_POST[$field][0])) {
522 522
 						unset($_POST[$field][0]);
523 523
 					}
524 524
 					$_POST[$field] = encodeMultienumValue($_POST[$field]);
525 525
 				}
526 526
 				$this->bean->$field = $_POST[$field];
527
-			} else if(!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field . '_multiselect'])) {
527
+			} else if (!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field.'_multiselect'])) {
528 528
 				$this->bean->$field = '';
529 529
 			}
530
-            if($sf != null){
530
+            if ($sf != null) {
531 531
                 $sf->save($this->bean, $_POST, $field, $properties);
532 532
             }
533 533
 		}
534 534
 
535
-		foreach($this->bean->relationship_fields as $field=>$link){
536
-			if(!empty($_POST[$field])){
535
+		foreach ($this->bean->relationship_fields as $field=>$link) {
536
+			if (!empty($_POST[$field])) {
537 537
 				$this->bean->$field = $_POST[$field];
538 538
 			}
539 539
 		}
540
-		if(!$this->bean->ACLAccess('save')){
540
+		if (!$this->bean->ACLAccess('save')) {
541 541
 			ACLController::displayNoAccess(true);
542 542
 			sugar_cleanup(true);
543 543
 		}
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	/**
547 547
 	 * Perform the actual save
548 548
 	 */
549
-	public function action_save(){
549
+	public function action_save() {
550 550
 		$this->bean->save(!empty($this->bean->notify_on_save));
551 551
 	}
552 552
 
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	/**
561 561
 	 * Specify what happens after the save has occurred.
562 562
 	 */
563
-	protected function post_save(){
563
+	protected function post_save() {
564 564
 		$module = (!empty($this->return_module) ? $this->return_module : $this->module);
565 565
 		$action = (!empty($this->return_action) ? $this->return_action : 'DetailView');
566 566
 		$id = (!empty($this->return_id) ? $this->return_id : $this->bean->id);
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 	/**
577 577
 	 * Perform the actual deletion.
578 578
 	 */
579
-	protected function action_delete(){
579
+	protected function action_delete() {
580 580
 		//do any pre delete processing
581 581
 		//if there is some custom logic for deletion.
582
-		if(!empty($_REQUEST['record'])){
583
-			if(!$this->bean->ACLAccess('Delete')){
582
+		if (!empty($_REQUEST['record'])) {
583
+			if (!$this->bean->ACLAccess('Delete')) {
584 584
 				ACLController::displayNoAccess(true);
585 585
 				sugar_cleanup(true);
586 586
 			}
587 587
 			$this->bean->mark_deleted($_REQUEST['record']);
588
-		}else{
588
+		} else {
589 589
 			sugar_die("A record number must be specified to delete");
590 590
 		}
591 591
 	}
@@ -593,24 +593,21 @@  discard block
 block discarded – undo
593 593
 	/**
594 594
 	 * Specify what happens after the deletion has occurred.
595 595
 	 */
596
-	protected function post_delete(){
596
+	protected function post_delete() {
597 597
         if (empty($_REQUEST['return_url'])) {
598 598
             $return_module = isset($_REQUEST['return_module']) ?
599
-                $_REQUEST['return_module'] :
600
-                $GLOBALS['sugar_config']['default_module'];
599
+                $_REQUEST['return_module'] : $GLOBALS['sugar_config']['default_module'];
601 600
             $return_action = isset($_REQUEST['return_action']) ?
602
-                $_REQUEST['return_action'] :
603
-                $GLOBALS['sugar_config']['default_action'];
601
+                $_REQUEST['return_action'] : $GLOBALS['sugar_config']['default_action'];
604 602
             $return_id = isset($_REQUEST['return_id']) ?
605
-                $_REQUEST['return_id'] :
606
-                '';
603
+                $_REQUEST['return_id'] : '';
607 604
             $url = "index.php?module=".$return_module."&action=".$return_action."&record=".$return_id;
608 605
         } else {
609 606
             $url = $_REQUEST['return_url'];
610 607
         }
611 608
 
612 609
 		//eggsurplus Bug 23816: maintain VCR after an edit/save. If it is a duplicate then don't worry about it. The offset is now worthless.
613
-		if(isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
610
+		if (isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
614 611
 		    $url .= "&offset=".$_REQUEST['offset'];
615 612
 		}
616 613
 
@@ -619,15 +616,15 @@  discard block
 block discarded – undo
619 616
 	/**
620 617
 	 * Perform the actual massupdate.
621 618
 	 */
622
-	protected function action_massupdate(){
623
-		if(!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))){
624
-			if(!empty($_REQUEST['Delete']) && $_REQUEST['Delete']=='true' && !$this->bean->ACLAccess('delete')
625
-                || (empty($_REQUEST['Delete']) || $_REQUEST['Delete']!='true') && !$this->bean->ACLAccess('save')){
619
+	protected function action_massupdate() {
620
+		if (!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))) {
621
+			if (!empty($_REQUEST['Delete']) && $_REQUEST['Delete'] == 'true' && !$this->bean->ACLAccess('delete')
622
+                || (empty($_REQUEST['Delete']) || $_REQUEST['Delete'] != 'true') && !$this->bean->ACLAccess('save')) {
626 623
 				ACLController::displayNoAccess(true);
627 624
 				sugar_cleanup(true);
628 625
 			}
629 626
 
630
-            set_time_limit(0);//I'm wondering if we will set it never goes timeout here.
627
+            set_time_limit(0); //I'm wondering if we will set it never goes timeout here.
631 628
             // until we have more efficient way of handling MU, we have to disable the limit
632 629
             $GLOBALS['db']->setQueryLimit(0);
633 630
             require_once("include/MassUpdate.php");
@@ -635,40 +632,38 @@  discard block
 block discarded – undo
635 632
             $seed = loadBean($_REQUEST['module']);
636 633
             $mass = new MassUpdate();
637 634
             $mass->setSugarBean($seed);
638
-            if(isset($_REQUEST['entire']) && empty($_POST['mass'])) {
635
+            if (isset($_REQUEST['entire']) && empty($_POST['mass'])) {
639 636
                 $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']);
640 637
             }
641 638
             $mass->handleMassUpdate();
642
-            $storeQuery = new StoreQuery();//restore the current search. to solve bug 24722 for multi tabs massupdate.
639
+            $storeQuery = new StoreQuery(); //restore the current search. to solve bug 24722 for multi tabs massupdate.
643 640
             $temp_req = array('current_query_by_page' => $_REQUEST['current_query_by_page'], 'return_module' => $_REQUEST['return_module'], 'return_action' => $_REQUEST['return_action']);
644
-            if($_REQUEST['return_module'] == 'Emails') {
645
-                if(!empty($_REQUEST['type']) && !empty($_REQUEST['ie_assigned_user_id'])) {
641
+            if ($_REQUEST['return_module'] == 'Emails') {
642
+                if (!empty($_REQUEST['type']) && !empty($_REQUEST['ie_assigned_user_id'])) {
646 643
                     $this->req_for_email = array('type' => $_REQUEST['type'], 'ie_assigned_user_id' => $_REQUEST['ie_assigned_user_id']); // Specifically for My Achieves
647 644
                 }
648 645
             }
649 646
             $_REQUEST = array();
650 647
             $_REQUEST = sugar_unserialize(base64_decode($temp_req['current_query_by_page']));
651
-            unset($_REQUEST[$seed->module_dir.'2_'.strtoupper($seed->object_name).'_offset']);//after massupdate, the page should redirect to no offset page
648
+            unset($_REQUEST[$seed->module_dir.'2_'.strtoupper($seed->object_name).'_offset']); //after massupdate, the page should redirect to no offset page
652 649
             $storeQuery->saveFromRequest($_REQUEST['module']);
653
-            $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']);//for post_massupdate, to go back to original page.
654
-		}else{
650
+            $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']); //for post_massupdate, to go back to original page.
651
+		} else {
655 652
 			sugar_die("You must massupdate at least one record");
656 653
 		}
657 654
 	}
658 655
 	/**
659 656
 	 * Specify what happens after the massupdate has occurred.
660 657
 	 */
661
-	protected function post_massupdate(){
658
+	protected function post_massupdate() {
662 659
 		$return_module = isset($_REQUEST['return_module']) ?
663
-			$_REQUEST['return_module'] :
664
-			$GLOBALS['sugar_config']['default_module'];
660
+			$_REQUEST['return_module'] : $GLOBALS['sugar_config']['default_module'];
665 661
 		$return_action = isset($_REQUEST['return_action']) ?
666
-			$_REQUEST['return_action'] :
667
-			$GLOBALS['sugar_config']['default_action'];
662
+			$_REQUEST['return_action'] : $GLOBALS['sugar_config']['default_action'];
668 663
 		$url = "index.php?module=".$return_module."&action=".$return_action;
669
-		if($return_module == 'Emails'){//specificly for My Achieves
670
-			if(!empty($this->req_for_email['type']) && !empty($this->req_for_email['ie_assigned_user_id'])) {
671
-				$url = $url . "&type=".$this->req_for_email['type']."&assigned_user_id=".$this->req_for_email['ie_assigned_user_id'];
664
+		if ($return_module == 'Emails') {//specificly for My Achieves
665
+			if (!empty($this->req_for_email['type']) && !empty($this->req_for_email['ie_assigned_user_id'])) {
666
+				$url = $url."&type=".$this->req_for_email['type']."&assigned_user_id=".$this->req_for_email['ie_assigned_user_id'];
672 667
 			}
673 668
 		}
674 669
 		$this->set_redirect($url);
@@ -676,7 +671,7 @@  discard block
 block discarded – undo
676 671
 	/**
677 672
 	 * Perform the listview action
678 673
 	 */
679
-	protected function action_listview(){
674
+	protected function action_listview() {
680 675
 		$this->view_object_map['bean'] = $this->bean;
681 676
 		$this->view = 'list';
682 677
 	}
@@ -691,24 +686,24 @@  discard block
 block discarded – undo
691 686
 	/**
692 687
 	 * Action to handle when using a file as was done in previous versions of Sugar.
693 688
 	 */
694
-	protected function action_default(){
689
+	protected function action_default() {
695 690
 		$this->view = 'classic';
696 691
 	}
697 692
 
698 693
 	/**
699 694
 	 * this method id used within a Dashlet when performing an ajax call
700 695
 	 */
701
-	protected function action_callmethoddashlet(){
702
-		if(!empty($_REQUEST['id'])) {
696
+	protected function action_callmethoddashlet() {
697
+		if (!empty($_REQUEST['id'])) {
703 698
 		    $id = $_REQUEST['id'];
704 699
 		    $requestedMethod = $_REQUEST['method'];
705 700
 		    $dashletDefs = $GLOBALS['current_user']->getPreference('dashlets', 'Home'); // load user's dashlets config
706
-		    if(!empty($dashletDefs[$id])) {
701
+		    if (!empty($dashletDefs[$id])) {
707 702
 		        require_once($dashletDefs[$id]['fileLocation']);
708 703
 
709 704
 		        $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
710 705
 
711
-		        if(method_exists($dashlet, $requestedMethod) || method_exists($dashlet, '__call')) {
706
+		        if (method_exists($dashlet, $requestedMethod) || method_exists($dashlet, '__call')) {
712 707
 		            echo $dashlet->$requestedMethod();
713 708
 		        }
714 709
 		        else {
@@ -721,22 +716,22 @@  discard block
 block discarded – undo
721 716
 	/**
722 717
 	 * this method is used within a Dashlet when the options configuration is posted
723 718
 	 */
724
-	protected function action_configuredashlet(){
719
+	protected function action_configuredashlet() {
725 720
 		global $current_user, $mod_strings;
726 721
 
727
-		if(!empty($_REQUEST['id'])) {
722
+		if (!empty($_REQUEST['id'])) {
728 723
 		    $id = $_REQUEST['id'];
729 724
 		    $dashletDefs = $current_user->getPreference('dashlets', $_REQUEST['module']); // load user's dashlets config
730 725
 		    require_once($dashletDefs[$id]['fileLocation']);
731 726
 
732 727
 		    $dashlet = new $dashletDefs[$id]['className']($id, (isset($dashletDefs[$id]['options']) ? $dashletDefs[$id]['options'] : array()));
733
-		    if(!empty($_REQUEST['configure']) && $_REQUEST['configure']) { // save settings
728
+		    if (!empty($_REQUEST['configure']) && $_REQUEST['configure']) { // save settings
734 729
 		        $dashletDefs[$id]['options'] = $dashlet->saveOptions($_REQUEST);
735 730
 		        $current_user->setPreference('dashlets', $dashletDefs, 0, $_REQUEST['module']);
736 731
 		    }
737 732
 		    else { // display options
738 733
 		        $json = getJSONobj();
739
-		        return 'result = ' . $json->encode((array('header' => $dashlet->title . ' : ' . $mod_strings['LBL_OPTIONS'],
734
+		        return 'result = '.$json->encode((array('header' => $dashlet->title.' : '.$mod_strings['LBL_OPTIONS'],
740 735
 		                                                 'body'  => $dashlet->displayOptions())));
741 736
 
742 737
 		    }
@@ -760,7 +755,7 @@  discard block
 block discarded – undo
760 755
         ob_clean();
761 756
         $retval = false;
762 757
 
763
-        if(method_exists($this->bean, 'deleteAttachment')) {
758
+        if (method_exists($this->bean, 'deleteAttachment')) {
764 759
             $duplicate = "false";
765 760
             if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == "true") {
766 761
                 $duplicate = "true";
@@ -778,7 +773,7 @@  discard block
 block discarded – undo
778 773
 	 * getActionFilename
779 774
 	 */
780 775
 	public static function getActionFilename($action) {
781
-	   if(isset(self::$action_case_file[$action])) {
776
+	   if (isset(self::$action_case_file[$action])) {
782 777
 	   	  return self::$action_case_file[$action];
783 778
 	   }
784 779
 	   return $action;
@@ -795,40 +790,40 @@  discard block
 block discarded – undo
795 790
 	 *
796 791
 	 * @return true if we want to stop processing, false if processing should continue
797 792
 	 */
798
-	private function blockFileAccess(){
793
+	private function blockFileAccess() {
799 794
 		//check if the we have enabled file_access_control and if so then check the mappings on the request;
800
-		if(!empty($GLOBALS['sugar_config']['admin_access_control']) && $GLOBALS['sugar_config']['admin_access_control']){
795
+		if (!empty($GLOBALS['sugar_config']['admin_access_control']) && $GLOBALS['sugar_config']['admin_access_control']) {
801 796
 			$this->loadMapping('file_access_control_map');
802 797
 			//since we have this turned on, check the mapping file
803 798
 			$module = strtolower($this->module);
804 799
 			$action = strtolower($this->do_action);
805
-			if(!empty($this->file_access_control_map['modules'][$module]['links'])){
800
+			if (!empty($this->file_access_control_map['modules'][$module]['links'])) {
806 801
 				$GLOBALS['admin_access_control_links'] = $this->file_access_control_map['modules'][$module]['links'];
807 802
 			}
808 803
 
809
-			if(!empty($this->file_access_control_map['modules'][$module]['actions']) && (in_array($action, $this->file_access_control_map['modules'][$module]['actions']) || !empty($this->file_access_control_map['modules'][$module]['actions'][$action]))){
804
+			if (!empty($this->file_access_control_map['modules'][$module]['actions']) && (in_array($action, $this->file_access_control_map['modules'][$module]['actions']) || !empty($this->file_access_control_map['modules'][$module]['actions'][$action]))) {
810 805
 				//check params
811
-				if(!empty($this->file_access_control_map['modules'][$module]['actions'][$action]['params'])){
806
+				if (!empty($this->file_access_control_map['modules'][$module]['actions'][$action]['params'])) {
812 807
 					$block = true;
813 808
 					$params = $this->file_access_control_map['modules'][$module]['actions'][$action]['params'];
814
-					foreach($params as $param => $paramVals){
815
-						if(!empty($_REQUEST[$param])){
816
-							if(!in_array($_REQUEST[$param], $paramVals)){
809
+					foreach ($params as $param => $paramVals) {
810
+						if (!empty($_REQUEST[$param])) {
811
+							if (!in_array($_REQUEST[$param], $paramVals)) {
817 812
 								$block = false;
818 813
 								break;
819 814
 							}
820 815
 						}
821 816
 					}
822
-					if($block){
817
+					if ($block) {
823 818
 						$this->_processed = true;
824 819
 						$this->no_access();
825 820
 					}
826
-				}else{
821
+				} else {
827 822
 					$this->_processed = true;
828 823
 					$this->no_access();
829 824
 				}
830 825
 			}
831
-		}else
826
+		} else
832 827
 			$this->_processed = false;
833 828
 	}
834 829
 
@@ -840,12 +835,12 @@  discard block
 block discarded – undo
840 835
 	 * the download entry point is mapped in the following file: entry_point_registry.php
841 836
 	 *
842 837
 	 */
843
-	private function handleEntryPoint(){
844
-		if(!empty($_REQUEST['entryPoint'])){
838
+	private function handleEntryPoint() {
839
+		if (!empty($_REQUEST['entryPoint'])) {
845 840
 			$this->loadMapping('entry_point_registry');
846 841
 			$entryPoint = $_REQUEST['entryPoint'];
847 842
 
848
-			if(!empty($this->entry_point_registry[$entryPoint])){
843
+			if (!empty($this->entry_point_registry[$entryPoint])) {
849 844
 				require_once($this->entry_point_registry[$entryPoint]['file']);
850 845
 				$this->_processed = true;
851 846
 				$this->view = '';
@@ -863,8 +858,8 @@  discard block
 block discarded – undo
863 858
     {
864 859
         $this->loadMapping('entry_point_registry');
865 860
 
866
-        if ( isset($this->entry_point_registry[$entryPoint]['auth'])
867
-                && !$this->entry_point_registry[$entryPoint]['auth'] )
861
+        if (isset($this->entry_point_registry[$entryPoint]['auth'])
862
+                && !$this->entry_point_registry[$entryPoint]['auth'])
868 863
             return false;
869 864
         return true;
870 865
     }
@@ -876,26 +871,26 @@  discard block
 block discarded – undo
876 871
 	protected function callLegacyCode()
877 872
 	{
878 873
 		$file = self::getActionFilename($this->do_action);
879
-		if ( isset($this->action_view_map[strtolower($this->do_action)]) ) {
874
+		if (isset($this->action_view_map[strtolower($this->do_action)])) {
880 875
 	        $action = $this->action_view_map[strtolower($this->do_action)];
881 876
 	    }
882 877
 	    else {
883 878
 	        $action = $this->do_action;
884 879
 	    }
885 880
 	    // index actions actually maps to the view.list.php view
886
-	    if ( $action == 'index' ) {
881
+	    if ($action == 'index') {
887 882
 	        $action = 'list';
888 883
 	    }
889 884
 
890
-		if ((file_exists('modules/' . $this->module . '/'. $file . '.php')
891
-                && !file_exists('modules/' . $this->module . '/views/view.'. $action . '.php'))
892
-            || (file_exists('custom/modules/' . $this->module . '/'. $file . '.php')
893
-                && !file_exists('custom/modules/' . $this->module . '/views/view.'. $action . '.php'))
885
+		if ((file_exists('modules/'.$this->module.'/'.$file.'.php')
886
+                && !file_exists('modules/'.$this->module.'/views/view.'.$action.'.php'))
887
+            || (file_exists('custom/modules/'.$this->module.'/'.$file.'.php')
888
+                && !file_exists('custom/modules/'.$this->module.'/views/view.'.$action.'.php'))
894 889
             ) {
895 890
 			// A 'classic' module, using the old pre-MVC display files
896 891
 			// We should now discard the bean we just obtained for tracking as the pre-MVC module will instantiate its own
897 892
 			unset($GLOBALS['FOCUS']);
898
-			$GLOBALS['log']->debug('Module:' . $this->module . ' using file: '. $file);
893
+			$GLOBALS['log']->debug('Module:'.$this->module.' using file: '.$file);
899 894
 			$this->action_default();
900 895
 			$this->_processed = true;
901 896
 		}
@@ -906,17 +901,17 @@  discard block
 block discarded – undo
906 901
 	 * action_file_map.php or action_view_map.php load those maps here.
907 902
 	 *
908 903
 	 */
909
-	private function handleActionMaps(){
910
-		if(!empty($this->action_file_map[strtolower($this->do_action)])){
904
+	private function handleActionMaps() {
905
+		if (!empty($this->action_file_map[strtolower($this->do_action)])) {
911 906
 			$this->view = '';
912
-			$GLOBALS['log']->debug('Using Action File Map:' . $this->action_file_map[strtolower($this->do_action)]);
907
+			$GLOBALS['log']->debug('Using Action File Map:'.$this->action_file_map[strtolower($this->do_action)]);
913 908
 			require_once($this->action_file_map[strtolower($this->do_action)]);
914 909
 			$this->_processed = true;
915
-		}elseif(!empty($this->action_view_map[strtolower($this->do_action)])){
916
-			$GLOBALS['log']->debug('Using Action View Map:' . $this->action_view_map[strtolower($this->do_action)]);
910
+		}elseif (!empty($this->action_view_map[strtolower($this->do_action)])) {
911
+			$GLOBALS['log']->debug('Using Action View Map:'.$this->action_view_map[strtolower($this->do_action)]);
917 912
 			$this->view = $this->action_view_map[strtolower($this->do_action)];
918 913
 			$this->_processed = true;
919
-		}else
914
+		} else
920 915
 			$this->no_action();
921 916
 	}
922 917
 
@@ -924,8 +919,8 @@  discard block
 block discarded – undo
924 919
 	 * Actually remap the action if required.
925 920
 	 *
926 921
 	 */
927
-	protected function remapAction(){
928
-		if(!empty($this->action_remap[$this->do_action])){
922
+	protected function remapAction() {
923
+		if (!empty($this->action_remap[$this->do_action])) {
929 924
 			$this->action = $this->action_remap[$this->do_action];
930 925
 			$this->do_action = $this->action;
931 926
 		}
Please login to merge, or discard this patch.