@@ -19,7 +19,7 @@ |
||
19 | 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.'; |
20 | 20 | $PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.'; |
21 | 21 | $PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية ' . |
22 | - 'فشل في الارسال لكل من : '; |
|
22 | + 'فشل في الارسال لكل من : '; |
|
23 | 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; |
24 | 24 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.'; |
25 | 25 | $PHPMAILER_LANG['smtp_error'] = 'خطأ على مستوى الخادم SMTP: '; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $PHPMAILER_LANG['invalid_address'] = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح.'; |
19 | 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.'; |
20 | 20 | $PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.'; |
21 | -$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية ' . |
|
21 | +$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية '. |
|
22 | 22 | 'فشل في الارسال لكل من : '; |
23 | 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; |
24 | 24 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.'; |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function checkRequired($prefix, $required) |
56 | 56 | { |
57 | - foreach($required as $key) |
|
58 | - { |
|
59 | - if(!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key])) |
|
60 | - { |
|
61 | - return false; |
|
62 | - } |
|
63 | - } |
|
64 | - return true; |
|
57 | + foreach($required as $key) |
|
58 | + { |
|
59 | + if(!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key])) |
|
60 | + { |
|
61 | + return false; |
|
62 | + } |
|
63 | + } |
|
64 | + return true; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function populateFromPost($prefix, &$focus, $skipRetrieve = false, $checkACL = false) |
77 | 77 | { |
78 | - global $current_user; |
|
78 | + global $current_user; |
|
79 | 79 | |
80 | - if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) |
|
81 | - $focus->retrieve($_REQUEST[$prefix.'record']); |
|
80 | + if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) |
|
81 | + $focus->retrieve($_REQUEST[$prefix.'record']); |
|
82 | 82 | |
83 | - if(!empty($_POST['assigned_user_id']) && |
|
84 | - ($focus->assigned_user_id != $_POST['assigned_user_id']) && |
|
85 | - ($_POST['assigned_user_id'] != $current_user->id)) { |
|
86 | - $GLOBALS['check_notify'] = true; |
|
87 | - } |
|
83 | + if(!empty($_POST['assigned_user_id']) && |
|
84 | + ($focus->assigned_user_id != $_POST['assigned_user_id']) && |
|
85 | + ($_POST['assigned_user_id'] != $current_user->id)) { |
|
86 | + $GLOBALS['check_notify'] = true; |
|
87 | + } |
|
88 | 88 | if(isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '' ){ |
89 | 89 | $focus->new_with_id = true; |
90 | 90 | } |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | $relatedFields[$def['id_name']] = $field; |
107 | 107 | } |
108 | 108 | |
109 | - foreach($focus->field_defs as $field=>$def) { |
|
109 | + foreach($focus->field_defs as $field=>$def) { |
|
110 | 110 | if ( $field == 'id' && !empty($focus->id) ) { |
111 | 111 | // Don't try and overwrite the ID |
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | - $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type']; |
|
117 | - $sf = $sfh->getSugarField($type); |
|
116 | + $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type']; |
|
117 | + $sf = $sfh->getSugarField($type); |
|
118 | 118 | if($sf != null){ |
119 | 119 | $sf->save($focus, $_POST, $field, $def, $prefix); |
120 | 120 | } else { |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | $focus->$field = ''; |
153 | 153 | } |
154 | 154 | */ |
155 | - } |
|
155 | + } |
|
156 | 156 | |
157 | - foreach($focus->additional_column_fields as $field) { |
|
158 | - if(isset($_POST[$prefix.$field])) { |
|
159 | - $value = $_POST[$prefix.$field]; |
|
160 | - $focus->$field = $value; |
|
161 | - } |
|
162 | - } |
|
163 | - return $focus; |
|
157 | + foreach($focus->additional_column_fields as $field) { |
|
158 | + if(isset($_POST[$prefix.$field])) { |
|
159 | + $value = $_POST[$prefix.$field]; |
|
160 | + $focus->$field = $value; |
|
161 | + } |
|
162 | + } |
|
163 | + return $focus; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | function add_hidden_elements($key, $value) { |
@@ -182,73 +182,73 @@ discard block |
||
182 | 182 | |
183 | 183 | function getPostToForm($ignore='', $isRegularExpression=false) |
184 | 184 | { |
185 | - $fields = ''; |
|
186 | - if(!empty($ignore) && $isRegularExpression) { |
|
187 | - foreach ($_POST as $key=>$value){ |
|
188 | - if(!preg_match($ignore, $key)) { |
|
185 | + $fields = ''; |
|
186 | + if(!empty($ignore) && $isRegularExpression) { |
|
187 | + foreach ($_POST as $key=>$value){ |
|
188 | + if(!preg_match($ignore, $key)) { |
|
189 | 189 | $fields .= add_hidden_elements($key, $value); |
190 | - } |
|
191 | - } |
|
192 | - } else { |
|
193 | - foreach ($_POST as $key=>$value){ |
|
194 | - if($key != $ignore) { |
|
190 | + } |
|
191 | + } |
|
192 | + } else { |
|
193 | + foreach ($_POST as $key=>$value){ |
|
194 | + if($key != $ignore) { |
|
195 | 195 | $fields .= add_hidden_elements($key, $value); |
196 | - } |
|
197 | - } |
|
198 | - } |
|
199 | - return $fields; |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | + return $fields; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | function getGetToForm($ignore='', $usePostAsAuthority = false) |
203 | 203 | { |
204 | - $fields = ''; |
|
205 | - foreach ($_GET as $key=>$value) |
|
206 | - { |
|
207 | - if($key != $ignore){ |
|
208 | - if(!$usePostAsAuthority || !isset($_POST[$key])){ |
|
209 | - $fields.= "<input type='hidden' name='$key' value='$value'>"; |
|
210 | - } |
|
211 | - } |
|
212 | - } |
|
213 | - return $fields; |
|
204 | + $fields = ''; |
|
205 | + foreach ($_GET as $key=>$value) |
|
206 | + { |
|
207 | + if($key != $ignore){ |
|
208 | + if(!$usePostAsAuthority || !isset($_POST[$key])){ |
|
209 | + $fields.= "<input type='hidden' name='$key' value='$value'>"; |
|
210 | + } |
|
211 | + } |
|
212 | + } |
|
213 | + return $fields; |
|
214 | 214 | |
215 | 215 | } |
216 | 216 | function getAnyToForm($ignore='', $usePostAsAuthority = false) |
217 | 217 | { |
218 | - $fields = getPostToForm($ignore); |
|
219 | - $fields .= getGetToForm($ignore, $usePostAsAuthority); |
|
220 | - return $fields; |
|
218 | + $fields = getPostToForm($ignore); |
|
219 | + $fields .= getGetToForm($ignore, $usePostAsAuthority); |
|
220 | + return $fields; |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | 224 | function handleRedirect($return_id='', $return_module='', $additionalFlags = false) |
225 | 225 | { |
226 | - if(isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "") |
|
227 | - { |
|
228 | - header("Location: ". $_REQUEST['return_url']); |
|
229 | - exit; |
|
230 | - } |
|
231 | - |
|
232 | - $url = buildRedirectURL($return_id, $return_module); |
|
233 | - header($url); |
|
234 | - exit; |
|
226 | + if(isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "") |
|
227 | + { |
|
228 | + header("Location: ". $_REQUEST['return_url']); |
|
229 | + exit; |
|
230 | + } |
|
231 | + |
|
232 | + $url = buildRedirectURL($return_id, $return_module); |
|
233 | + header($url); |
|
234 | + exit; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | //eggsurplus: abstract to simplify unit testing |
238 | 238 | function buildRedirectURL($return_id='', $return_module='') |
239 | 239 | { |
240 | 240 | if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") |
241 | - { |
|
242 | - $return_module = $_REQUEST['return_module']; |
|
243 | - } |
|
244 | - else |
|
245 | - { |
|
246 | - $return_module = $return_module; |
|
247 | - } |
|
248 | - if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") |
|
249 | - { |
|
241 | + { |
|
242 | + $return_module = $_REQUEST['return_module']; |
|
243 | + } |
|
244 | + else |
|
245 | + { |
|
246 | + $return_module = $return_module; |
|
247 | + } |
|
248 | + if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") |
|
249 | + { |
|
250 | 250 | |
251 | - //if we are doing a "Close and Create New" |
|
251 | + //if we are doing a "Close and Create New" |
|
252 | 252 | if(isCloseAndCreateNewPressed()) |
253 | 253 | { |
254 | 254 | $return_action = "EditView"; |
@@ -257,40 +257,40 @@ discard block |
||
257 | 257 | |
258 | 258 | // Meeting Integration |
259 | 259 | if(isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) { |
260 | - $additionalFlags = array('meetingIntegrationShowForm' => '1'); |
|
260 | + $additionalFlags = array('meetingIntegrationShowForm' => '1'); |
|
261 | 261 | } |
262 | 262 | // END Meeting Integration |
263 | 263 | } |
264 | - // if we create a new record "Save", we want to redirect to the DetailView |
|
265 | - else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" |
|
266 | - && $_REQUEST['return_module'] != 'Activities' |
|
267 | - && $_REQUEST['return_module'] != 'Home' |
|
268 | - && $_REQUEST['return_module'] != 'Forecasts' |
|
269 | - && $_REQUEST['return_module'] != 'Calendar' |
|
270 | - && $_REQUEST['return_module'] != 'MailMerge' |
|
271 | - ) |
|
272 | - { |
|
273 | - $return_action = 'DetailView'; |
|
274 | - } elseif($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') { |
|
275 | - $return_module = $_REQUEST['module']; |
|
276 | - $return_action = $_REQUEST['return_action']; |
|
277 | - // wp: return action needs to be set for one-click close in task list |
|
278 | - } |
|
279 | - else |
|
280 | - { |
|
281 | - // if we "Cancel", we go back to the list view. |
|
282 | - $return_action = $_REQUEST['return_action']; |
|
283 | - } |
|
284 | - } |
|
285 | - else |
|
286 | - { |
|
287 | - $return_action = "DetailView"; |
|
288 | - } |
|
264 | + // if we create a new record "Save", we want to redirect to the DetailView |
|
265 | + else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" |
|
266 | + && $_REQUEST['return_module'] != 'Activities' |
|
267 | + && $_REQUEST['return_module'] != 'Home' |
|
268 | + && $_REQUEST['return_module'] != 'Forecasts' |
|
269 | + && $_REQUEST['return_module'] != 'Calendar' |
|
270 | + && $_REQUEST['return_module'] != 'MailMerge' |
|
271 | + ) |
|
272 | + { |
|
273 | + $return_action = 'DetailView'; |
|
274 | + } elseif($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') { |
|
275 | + $return_module = $_REQUEST['module']; |
|
276 | + $return_action = $_REQUEST['return_action']; |
|
277 | + // wp: return action needs to be set for one-click close in task list |
|
278 | + } |
|
279 | + else |
|
280 | + { |
|
281 | + // if we "Cancel", we go back to the list view. |
|
282 | + $return_action = $_REQUEST['return_action']; |
|
283 | + } |
|
284 | + } |
|
285 | + else |
|
286 | + { |
|
287 | + $return_action = "DetailView"; |
|
288 | + } |
|
289 | 289 | |
290 | - if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") |
|
291 | - { |
|
292 | - $return_id = $_REQUEST['return_id']; |
|
293 | - } |
|
290 | + if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") |
|
291 | + { |
|
292 | + $return_id = $_REQUEST['return_id']; |
|
293 | + } |
|
294 | 294 | |
295 | 295 | $add = ""; |
296 | 296 | if(isset($additionalFlags) && !empty($additionalFlags)) { |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | return "Location: $url"; |
321 | 321 | } |
322 | 322 | } else { |
323 | - $standard = "action=$return_action&module=$return_module&record=$return_id&isDuplicate=true&return_module=$return_module&return_action=$return_action&status=$status"; |
|
323 | + $standard = "action=$return_action&module=$return_module&record=$return_id&isDuplicate=true&return_module=$return_module&return_action=$return_action&status=$status"; |
|
324 | 324 | $url="index.php?{$standard}{$add}"; |
325 | 325 | if(!empty($_REQUEST['ajax_load'])) |
326 | 326 | { |
327 | 327 | $ajax_ret = array( |
328 | - 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n", |
|
329 | - 'menu' => array( |
|
330 | - 'module' => $return_module, |
|
331 | - 'label' => translate($return_module), |
|
332 | - ), |
|
328 | + 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n", |
|
329 | + 'menu' => array( |
|
330 | + 'module' => $return_module, |
|
331 | + 'label' => translate($return_module), |
|
332 | + ), |
|
333 | 333 | ); |
334 | 334 | $json = getJSONobj(); |
335 | 335 | echo $json->encode($ajax_ret); |
@@ -341,21 +341,21 @@ discard block |
||
341 | 341 | |
342 | 342 | function getLikeForEachWord($fieldname, $value, $minsize=4) |
343 | 343 | { |
344 | - $value = trim($value); |
|
345 | - $values = explode(' ',$value); |
|
346 | - $ret = ''; |
|
347 | - foreach($values as $val) |
|
348 | - { |
|
349 | - if(strlen($val) >= $minsize) |
|
350 | - { |
|
351 | - if(!empty($ret)) |
|
352 | - { |
|
353 | - $ret .= ' or'; |
|
354 | - } |
|
355 | - $ret .= ' '. $fieldname . ' LIKE %'.$val.'%'; |
|
356 | - } |
|
344 | + $value = trim($value); |
|
345 | + $values = explode(' ',$value); |
|
346 | + $ret = ''; |
|
347 | + foreach($values as $val) |
|
348 | + { |
|
349 | + if(strlen($val) >= $minsize) |
|
350 | + { |
|
351 | + if(!empty($ret)) |
|
352 | + { |
|
353 | + $ret .= ' or'; |
|
354 | + } |
|
355 | + $ret .= ' '. $fieldname . ' LIKE %'.$val.'%'; |
|
356 | + } |
|
357 | 357 | |
358 | - } |
|
358 | + } |
|
359 | 359 | |
360 | 360 | |
361 | 361 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function checkRequired($prefix, $required) |
56 | 56 | { |
57 | - foreach($required as $key) |
|
57 | + foreach ($required as $key) |
|
58 | 58 | { |
59 | - if(!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key])) |
|
59 | + if (!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key])) |
|
60 | 60 | { |
61 | 61 | return false; |
62 | 62 | } |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | { |
78 | 78 | global $current_user; |
79 | 79 | |
80 | - if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) |
|
80 | + if (!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) |
|
81 | 81 | $focus->retrieve($_REQUEST[$prefix.'record']); |
82 | 82 | |
83 | - if(!empty($_POST['assigned_user_id']) && |
|
83 | + if (!empty($_POST['assigned_user_id']) && |
|
84 | 84 | ($focus->assigned_user_id != $_POST['assigned_user_id']) && |
85 | 85 | ($_POST['assigned_user_id'] != $current_user->id)) { |
86 | 86 | $GLOBALS['check_notify'] = true; |
87 | 87 | } |
88 | - if(isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '' ){ |
|
88 | + if (isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '') { |
|
89 | 89 | $focus->new_with_id = true; |
90 | 90 | } |
91 | 91 | require_once('include/SugarFields/SugarFieldHandler.php'); |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | $relatedFields[$def['id_name']] = $field; |
107 | 107 | } |
108 | 108 | |
109 | - foreach($focus->field_defs as $field=>$def) { |
|
110 | - if ( $field == 'id' && !empty($focus->id) ) { |
|
109 | + foreach ($focus->field_defs as $field=>$def) { |
|
110 | + if ($field == 'id' && !empty($focus->id)) { |
|
111 | 111 | // Don't try and overwrite the ID |
112 | 112 | continue; |
113 | 113 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type']; |
117 | 117 | $sf = $sfh->getSugarField($type); |
118 | - if($sf != null){ |
|
118 | + if ($sf != null) { |
|
119 | 119 | $sf->save($focus, $_POST, $field, $def, $prefix); |
120 | 120 | } else { |
121 | 121 | $GLOBALS['log']->fatal("Field '$field' does not have a SugarField handler"); |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | */ |
155 | 155 | } |
156 | 156 | |
157 | - foreach($focus->additional_column_fields as $field) { |
|
158 | - if(isset($_POST[$prefix.$field])) { |
|
157 | + foreach ($focus->additional_column_fields as $field) { |
|
158 | + if (isset($_POST[$prefix.$field])) { |
|
159 | 159 | $value = $_POST[$prefix.$field]; |
160 | 160 | $focus->$field = $value; |
161 | 161 | } |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | |
183 | -function getPostToForm($ignore='', $isRegularExpression=false) |
|
183 | +function getPostToForm($ignore = '', $isRegularExpression = false) |
|
184 | 184 | { |
185 | 185 | $fields = ''; |
186 | - if(!empty($ignore) && $isRegularExpression) { |
|
187 | - foreach ($_POST as $key=>$value){ |
|
188 | - if(!preg_match($ignore, $key)) { |
|
186 | + if (!empty($ignore) && $isRegularExpression) { |
|
187 | + foreach ($_POST as $key=>$value) { |
|
188 | + if (!preg_match($ignore, $key)) { |
|
189 | 189 | $fields .= add_hidden_elements($key, $value); |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } else { |
193 | - foreach ($_POST as $key=>$value){ |
|
194 | - if($key != $ignore) { |
|
193 | + foreach ($_POST as $key=>$value) { |
|
194 | + if ($key != $ignore) { |
|
195 | 195 | $fields .= add_hidden_elements($key, $value); |
196 | 196 | } |
197 | 197 | } |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | return $fields; |
200 | 200 | } |
201 | 201 | |
202 | -function getGetToForm($ignore='', $usePostAsAuthority = false) |
|
202 | +function getGetToForm($ignore = '', $usePostAsAuthority = false) |
|
203 | 203 | { |
204 | 204 | $fields = ''; |
205 | 205 | foreach ($_GET as $key=>$value) |
206 | 206 | { |
207 | - if($key != $ignore){ |
|
208 | - if(!$usePostAsAuthority || !isset($_POST[$key])){ |
|
209 | - $fields.= "<input type='hidden' name='$key' value='$value'>"; |
|
207 | + if ($key != $ignore) { |
|
208 | + if (!$usePostAsAuthority || !isset($_POST[$key])) { |
|
209 | + $fields .= "<input type='hidden' name='$key' value='$value'>"; |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | return $fields; |
214 | 214 | |
215 | 215 | } |
216 | -function getAnyToForm($ignore='', $usePostAsAuthority = false) |
|
216 | +function getAnyToForm($ignore = '', $usePostAsAuthority = false) |
|
217 | 217 | { |
218 | 218 | $fields = getPostToForm($ignore); |
219 | 219 | $fields .= getGetToForm($ignore, $usePostAsAuthority); |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | -function handleRedirect($return_id='', $return_module='', $additionalFlags = false) |
|
224 | +function handleRedirect($return_id = '', $return_module = '', $additionalFlags = false) |
|
225 | 225 | { |
226 | - if(isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "") |
|
226 | + if (isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "") |
|
227 | 227 | { |
228 | - header("Location: ". $_REQUEST['return_url']); |
|
228 | + header("Location: ".$_REQUEST['return_url']); |
|
229 | 229 | exit; |
230 | 230 | } |
231 | 231 | |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | //eggsurplus: abstract to simplify unit testing |
238 | -function buildRedirectURL($return_id='', $return_module='') |
|
238 | +function buildRedirectURL($return_id = '', $return_module = '') |
|
239 | 239 | { |
240 | - if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") |
|
240 | + if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") |
|
241 | 241 | { |
242 | 242 | $return_module = $_REQUEST['return_module']; |
243 | 243 | } |
@@ -245,24 +245,24 @@ discard block |
||
245 | 245 | { |
246 | 246 | $return_module = $return_module; |
247 | 247 | } |
248 | - if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") |
|
248 | + if (isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") |
|
249 | 249 | { |
250 | 250 | |
251 | 251 | //if we are doing a "Close and Create New" |
252 | - if(isCloseAndCreateNewPressed()) |
|
252 | + if (isCloseAndCreateNewPressed()) |
|
253 | 253 | { |
254 | 254 | $return_action = "EditView"; |
255 | 255 | $isDuplicate = "true"; |
256 | 256 | $status = ""; |
257 | 257 | |
258 | 258 | // Meeting Integration |
259 | - if(isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) { |
|
259 | + if (isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) { |
|
260 | 260 | $additionalFlags = array('meetingIntegrationShowForm' => '1'); |
261 | 261 | } |
262 | 262 | // END Meeting Integration |
263 | 263 | } |
264 | 264 | // if we create a new record "Save", we want to redirect to the DetailView |
265 | - else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" |
|
265 | + else if (isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" |
|
266 | 266 | && $_REQUEST['return_module'] != 'Activities' |
267 | 267 | && $_REQUEST['return_module'] != 'Home' |
268 | 268 | && $_REQUEST['return_module'] != 'Forecasts' |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | ) |
272 | 272 | { |
273 | 273 | $return_action = 'DetailView'; |
274 | - } elseif($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') { |
|
274 | + } elseif ($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') { |
|
275 | 275 | $return_module = $_REQUEST['module']; |
276 | 276 | $return_action = $_REQUEST['return_action']; |
277 | 277 | // wp: return action needs to be set for one-click close in task list |
@@ -287,25 +287,25 @@ discard block |
||
287 | 287 | $return_action = "DetailView"; |
288 | 288 | } |
289 | 289 | |
290 | - if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") |
|
290 | + if (isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") |
|
291 | 291 | { |
292 | 292 | $return_id = $_REQUEST['return_id']; |
293 | 293 | } |
294 | 294 | |
295 | 295 | $add = ""; |
296 | - if(isset($additionalFlags) && !empty($additionalFlags)) { |
|
297 | - foreach($additionalFlags as $k => $v) { |
|
296 | + if (isset($additionalFlags) && !empty($additionalFlags)) { |
|
297 | + foreach ($additionalFlags as $k => $v) { |
|
298 | 298 | $add .= "&{$k}={$v}"; |
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | 302 | if (!isset($isDuplicate) || !$isDuplicate) |
303 | 303 | { |
304 | - $url="index.php?action=$return_action&module=$return_module&record=$return_id&return_module=$return_module&return_action=$return_action{$add}"; |
|
305 | - if(isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) { |
|
304 | + $url = "index.php?action=$return_action&module=$return_module&record=$return_id&return_module=$return_module&return_action=$return_action{$add}"; |
|
305 | + if (isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) { |
|
306 | 306 | $url .= "&offset=".$_REQUEST['offset']; |
307 | 307 | } |
308 | - if(!empty($_REQUEST['ajax_load'])) |
|
308 | + if (!empty($_REQUEST['ajax_load'])) |
|
309 | 309 | { |
310 | 310 | $ajax_ret = array( |
311 | 311 | 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n", |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | } |
322 | 322 | } else { |
323 | 323 | $standard = "action=$return_action&module=$return_module&record=$return_id&isDuplicate=true&return_module=$return_module&return_action=$return_action&status=$status"; |
324 | - $url="index.php?{$standard}{$add}"; |
|
325 | - if(!empty($_REQUEST['ajax_load'])) |
|
324 | + $url = "index.php?{$standard}{$add}"; |
|
325 | + if (!empty($_REQUEST['ajax_load'])) |
|
326 | 326 | { |
327 | 327 | $ajax_ret = array( |
328 | 328 | 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n", |
@@ -339,20 +339,20 @@ discard block |
||
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | -function getLikeForEachWord($fieldname, $value, $minsize=4) |
|
342 | +function getLikeForEachWord($fieldname, $value, $minsize = 4) |
|
343 | 343 | { |
344 | 344 | $value = trim($value); |
345 | - $values = explode(' ',$value); |
|
345 | + $values = explode(' ', $value); |
|
346 | 346 | $ret = ''; |
347 | - foreach($values as $val) |
|
347 | + foreach ($values as $val) |
|
348 | 348 | { |
349 | - if(strlen($val) >= $minsize) |
|
349 | + if (strlen($val) >= $minsize) |
|
350 | 350 | { |
351 | - if(!empty($ret)) |
|
351 | + if (!empty($ret)) |
|
352 | 352 | { |
353 | 353 | $ret .= ' or'; |
354 | 354 | } |
355 | - $ret .= ' '. $fieldname . ' LIKE %'.$val.'%'; |
|
355 | + $ret .= ' '.$fieldname.' LIKE %'.$val.'%'; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | } |
@@ -373,36 +373,36 @@ discard block |
||
373 | 373 | * @see include/generic/Save2.php |
374 | 374 | */ |
375 | 375 | |
376 | -function add_prospects_to_prospect_list($parent_id,$child_id) |
|
376 | +function add_prospects_to_prospect_list($parent_id, $child_id) |
|
377 | 377 | { |
378 | - $focus=BeanFactory::getBean('Prospects'); |
|
379 | - if(is_array($child_id)){ |
|
378 | + $focus = BeanFactory::getBean('Prospects'); |
|
379 | + if (is_array($child_id)) { |
|
380 | 380 | $uids = $child_id; |
381 | 381 | } |
382 | - else{ |
|
382 | + else { |
|
383 | 383 | $uids = array($child_id); |
384 | 384 | } |
385 | 385 | |
386 | 386 | $relationship = ''; |
387 | - foreach($focus->get_linked_fields() as $field => $def) { |
|
387 | + foreach ($focus->get_linked_fields() as $field => $def) { |
|
388 | 388 | if ($focus->load_relationship($field)) { |
389 | - if ( $focus->$field->getRelatedModuleName() == 'ProspectLists' ) { |
|
389 | + if ($focus->$field->getRelatedModuleName() == 'ProspectLists') { |
|
390 | 390 | $relationship = $field; |
391 | 391 | break; |
392 | 392 | } |
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | - if ( $relationship != '' ) { |
|
397 | - foreach ( $uids as $id) { |
|
396 | + if ($relationship != '') { |
|
397 | + foreach ($uids as $id) { |
|
398 | 398 | $focus->retrieve($id); |
399 | 399 | $focus->load_relationship($relationship); |
400 | - $focus->prospect_lists->add( $parent_id ); |
|
400 | + $focus->prospect_lists->add($parent_id); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | -function add_to_prospect_list($query_panel,$parent_module,$parent_type,$parent_id,$child_id,$link_attribute,$link_type,$parent) |
|
405 | +function add_to_prospect_list($query_panel, $parent_module, $parent_type, $parent_id, $child_id, $link_attribute, $link_type, $parent) |
|
406 | 406 | { |
407 | 407 | $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$query_panel); |
408 | 408 | $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$parent_module); |
@@ -419,21 +419,21 @@ discard block |
||
419 | 419 | } |
420 | 420 | $focus = new $parent_type(); |
421 | 421 | $focus->retrieve($parent_id); |
422 | - if(empty($focus->id)) { |
|
422 | + if (empty($focus->id)) { |
|
423 | 423 | return false; |
424 | 424 | } |
425 | - if(empty($parent)) { |
|
425 | + if (empty($parent)) { |
|
426 | 426 | return false; |
427 | 427 | } |
428 | 428 | |
429 | 429 | //if link_type is default then load relationship once and add all the child ids. |
430 | - $relationship_attribute=$link_attribute; |
|
430 | + $relationship_attribute = $link_attribute; |
|
431 | 431 | |
432 | 432 | //find all prospects based on the query |
433 | 433 | |
434 | 434 | $subpanel = new SubPanelTiles($parent, $parent->module_dir); |
435 | - $thisPanel=$subpanel->subpanel_definitions->load_subpanel($query_panel); |
|
436 | - if(empty($thisPanel)) { |
|
435 | + $thisPanel = $subpanel->subpanel_definitions->load_subpanel($query_panel); |
|
436 | + if (empty($thisPanel)) { |
|
437 | 437 | return false; |
438 | 438 | } |
439 | 439 | |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | $thisPanel->_instance_properties['function_parameters']['EMAIL_MARKETING_ID_VALUE'] = $_REQUEST['marketing_id']; |
444 | 444 | } |
445 | 445 | |
446 | - $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -99,-99,'', $thisPanel); |
|
446 | + $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -99, -99, '', $thisPanel); |
|
447 | 447 | |
448 | - if(!empty($result['list'])) { |
|
449 | - foreach($result['list'] as $object) { |
|
448 | + if (!empty($result['list'])) { |
|
449 | + foreach ($result['list'] as $object) { |
|
450 | 450 | if ($link_type != 'default') { |
451 | - $relationship_attribute=strtolower($object->$link_attribute); |
|
451 | + $relationship_attribute = strtolower($object->$link_attribute); |
|
452 | 452 | } |
453 | 453 | $GLOBALS['log']->debug('add_prospects_to_prospect_list:relationship_attribute:'.$relationship_attribute); |
454 | 454 | // load relationship for the first time or on change of relationship atribute. |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | //Link rows returned by a report to parent record. |
465 | -function save_from_report($report_id,$parent_id, $module_name, $relationship_attr_name) { |
|
465 | +function save_from_report($report_id, $parent_id, $module_name, $relationship_attr_name) { |
|
466 | 466 | global $beanFiles; |
467 | 467 | global $beanList; |
468 | 468 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | $GLOBALS['log']->debug("Save2:Module Name=".$module_name); |
473 | 473 | $GLOBALS['log']->debug("Save2:Relationship Attribute Name=".$relationship_attr_name); |
474 | 474 | |
475 | - $GLOBALS['log']->debug("Save2:Bean Name=" . $module_name); |
|
475 | + $GLOBALS['log']->debug("Save2:Bean Name=".$module_name); |
|
476 | 476 | $focus = BeanFactory::newBean($module_name); |
477 | 477 | |
478 | 478 | $focus->retrieve($parent_id); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | //fetch report definition. |
482 | 482 | global $current_language, $report_modules, $modules_report; |
483 | 483 | |
484 | - $mod_strings = return_module_language($current_language,"Reports"); |
|
484 | + $mod_strings = return_module_language($current_language, "Reports"); |
|
485 | 485 | |
486 | 486 | |
487 | 487 | $saved = new SavedReport(); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $result = $report->db->query($sql); |
499 | 499 | |
500 | 500 | $reportBean = BeanFactory::newBean($saved->module); |
501 | - while($row = $report->db->fetchByAssoc($result)) |
|
501 | + while ($row = $report->db->fetchByAssoc($result)) |
|
502 | 502 | { |
503 | 503 | $reportBean->id = $row['primaryid']; |
504 | 504 | $focus->$relationship_attr_name->add($reportBean); |
@@ -1,5 +1,7 @@ discard block |
||
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. |
@@ -77,8 +79,9 @@ discard block |
||
77 | 79 | { |
78 | 80 | global $current_user; |
79 | 81 | |
80 | - if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) |
|
81 | - $focus->retrieve($_REQUEST[$prefix.'record']); |
|
82 | + if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) { |
|
83 | + $focus->retrieve($_REQUEST[$prefix.'record']); |
|
84 | + } |
|
82 | 85 | |
83 | 86 | if(!empty($_POST['assigned_user_id']) && |
84 | 87 | ($focus->assigned_user_id != $_POST['assigned_user_id']) && |
@@ -240,8 +243,7 @@ discard block |
||
240 | 243 | if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") |
241 | 244 | { |
242 | 245 | $return_module = $_REQUEST['return_module']; |
243 | - } |
|
244 | - else |
|
246 | + } else |
|
245 | 247 | { |
246 | 248 | $return_module = $return_module; |
247 | 249 | } |
@@ -275,14 +277,12 @@ discard block |
||
275 | 277 | $return_module = $_REQUEST['module']; |
276 | 278 | $return_action = $_REQUEST['return_action']; |
277 | 279 | // wp: return action needs to be set for one-click close in task list |
278 | - } |
|
279 | - else |
|
280 | + } else |
|
280 | 281 | { |
281 | 282 | // if we "Cancel", we go back to the list view. |
282 | 283 | $return_action = $_REQUEST['return_action']; |
283 | 284 | } |
284 | - } |
|
285 | - else |
|
285 | + } else |
|
286 | 286 | { |
287 | 287 | $return_action = "DetailView"; |
288 | 288 | } |
@@ -378,8 +378,7 @@ discard block |
||
378 | 378 | $focus=BeanFactory::getBean('Prospects'); |
379 | 379 | if(is_array($child_id)){ |
380 | 380 | $uids = $child_id; |
381 | - } |
|
382 | - else{ |
|
381 | + } else{ |
|
383 | 382 | $uids = array($child_id); |
384 | 383 | } |
385 | 384 |
@@ -235,6 +235,9 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | //eggsurplus: abstract to simplify unit testing |
238 | +/** |
|
239 | + * @return string |
|
240 | + */ |
|
238 | 241 | function buildRedirectURL($return_id='', $return_module='') |
239 | 242 | { |
240 | 243 | if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") |
@@ -339,6 +342,9 @@ discard block |
||
339 | 342 | } |
340 | 343 | } |
341 | 344 | |
345 | +/** |
|
346 | + * @param string $fieldname |
|
347 | + */ |
|
342 | 348 | function getLikeForEachWord($fieldname, $value, $minsize=4) |
343 | 349 | { |
344 | 350 | $value = trim($value); |
@@ -1,5 +1,7 @@ discard block |
||
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. |
@@ -128,8 +130,9 @@ discard block |
||
128 | 130 | foreach($this->displayColumns as $name => $params) { |
129 | 131 | $this->displayColumns[$name]['width'] = round($this->displayColumns[$name]['width'] / $adjustment, 2); |
130 | 132 | // figure out which contextMenu objectsTypes are required |
131 | - if(!empty($params['contextMenu']['objectType'])) |
|
132 | - $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true; |
|
133 | + if(!empty($params['contextMenu']['objectType'])) { |
|
134 | + $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true; |
|
135 | + } |
|
133 | 136 | } |
134 | 137 | $this->th->ss->assign('displayColumns', $this->displayColumns); |
135 | 138 | |
@@ -147,10 +150,17 @@ discard block |
||
147 | 150 | $this->th->ss->assign('searchForm', $this->searchForm->display(false)); |
148 | 151 | //rrs |
149 | 152 | |
150 | - if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
153 | + if($this->export) { |
|
154 | + $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
155 | + } |
|
151 | 156 | $this->th->ss->assign('quickViewLinks', $this->quickViewLinks); |
152 | - if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access |
|
153 | - if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
157 | + if($this->mailMerge) { |
|
158 | + $this->th->ss->assign('mergeLink', $this->buildMergeLink()); |
|
159 | + } |
|
160 | + // still check for mailmerge access |
|
161 | + if($this->mergeduplicates) { |
|
162 | + $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
163 | + } |
|
154 | 164 | |
155 | 165 | |
156 | 166 | if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') { |
@@ -301,7 +311,7 @@ discard block |
||
301 | 311 | |
302 | 312 | if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){ |
303 | 313 | require('custom/modules/'.$this->module.'/metadata/metafiles.php'); |
304 | - }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
314 | + } elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
305 | 315 | require('modules/'.$this->module.'/metadata/metafiles.php'); |
306 | 316 | } |
307 | 317 | |
@@ -321,21 +331,24 @@ discard block |
||
321 | 331 | $displayColumns = array(); |
322 | 332 | if(!empty($_REQUEST['displayColumns'])) { |
323 | 333 | foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) { |
324 | - if(!empty($listViewDefs[$this->module][$col])) |
|
325 | - $displayColumns[$col] = $this->listviewdefs[$this->module][$col]; |
|
334 | + if(!empty($listViewDefs[$this->module][$col])) { |
|
335 | + $displayColumns[$col] = $this->listviewdefs[$this->module][$col]; |
|
336 | + } |
|
326 | 337 | } |
327 | - } |
|
328 | - else { |
|
338 | + } else { |
|
329 | 339 | foreach($this->listviewdefs[$this->module] as $col => $para) { |
330 | - if(!empty($para['default']) && $para['default']) |
|
331 | - $displayColumns[$col] = $para; |
|
340 | + if(!empty($para['default']) && $para['default']) { |
|
341 | + $displayColumns[$col] = $para; |
|
342 | + } |
|
332 | 343 | } |
333 | 344 | } |
334 | 345 | $params['massupdate'] = true; |
335 | 346 | if(!empty($_REQUEST['orderBy'])) { |
336 | 347 | $params['orderBy'] = $_REQUEST['orderBy']; |
337 | 348 | $params['overrideOrder'] = true; |
338 | - if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
349 | + if(!empty($_REQUEST['sortOrder'])) { |
|
350 | + $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
351 | + } |
|
339 | 352 | } |
340 | 353 | |
341 | 354 | $lv->displayColumns = $displayColumns; |
@@ -453,7 +466,9 @@ discard block |
||
453 | 466 | |
454 | 467 | // Need to include the default whereStatement |
455 | 468 | if(!empty($this->_popupMeta['whereStatement'])){ |
456 | - if(!empty($where))$where .= ' AND '; |
|
469 | + if(!empty($where)) { |
|
470 | + $where .= ' AND '; |
|
471 | + } |
|
457 | 472 | $where .= $this->_popupMeta['whereStatement']; |
458 | 473 | } |
459 | 474 | |
@@ -472,11 +487,13 @@ discard block |
||
472 | 487 | $this->formData[] = array('field' => $data); |
473 | 488 | $value = ''; |
474 | 489 | $this->customFieldDefs[$data['name']]= $data; |
475 | - if(!empty($_REQUEST[$data['name']])) |
|
476 | - $value = $_REQUEST[$data['name']]; |
|
490 | + if(!empty($_REQUEST[$data['name']])) { |
|
491 | + $value = $_REQUEST[$data['name']]; |
|
492 | + } |
|
477 | 493 | $this->customFieldDefs[$data['name']]['value'] = $value; |
478 | - }else |
|
479 | - $this->formData[] = array('field' => array('name'=>$data)); |
|
494 | + } else { |
|
495 | + $this->formData[] = array('field' => array('name'=>$data)); |
|
496 | + } |
|
480 | 497 | } |
481 | 498 | $this->fieldDefs = array(); |
482 | 499 | if($this->seed){ |
@@ -487,13 +504,15 @@ discard block |
||
487 | 504 | //if we have a relate type then reset to name so that we end up with a textbox |
488 | 505 | //rather than a select button |
489 | 506 | $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name']; |
490 | - if($this->fieldDefs[$name]['type'] == 'relate') |
|
491 | - $this->fieldDefs[$name]['type'] = 'name'; |
|
507 | + if($this->fieldDefs[$name]['type'] == 'relate') { |
|
508 | + $this->fieldDefs[$name]['type'] = 'name'; |
|
509 | + } |
|
492 | 510 | if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) { |
493 | 511 | $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums |
494 | 512 | } |
495 | - if(!empty($_REQUEST[$name])) |
|
496 | - $value = $_REQUEST[$name]; |
|
513 | + if(!empty($_REQUEST[$name])) { |
|
514 | + $value = $_REQUEST[$name]; |
|
515 | + } |
|
497 | 516 | $this->fieldDefs[$name]['value'] = $value; |
498 | 517 | } |
499 | 518 | } |
@@ -540,8 +559,9 @@ discard block |
||
540 | 559 | EOQ; |
541 | 560 | // if metadata contains custom inputs for the quickcreate |
542 | 561 | if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) { |
543 | - foreach($this->_popupMeta['customInput'] as $key => $value) |
|
544 | - $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n'; |
|
562 | + foreach($this->_popupMeta['customInput'] as $key => $value) { |
|
563 | + $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n'; |
|
564 | + } |
|
545 | 565 | } |
546 | 566 | |
547 | 567 |
@@ -70,6 +70,9 @@ discard block |
||
70 | 70 | var $module; |
71 | 71 | var $massUpdateData = ''; |
72 | 72 | |
73 | + /** |
|
74 | + * @param string $module |
|
75 | + */ |
|
73 | 76 | function PopupSmarty($seed, $module){ |
74 | 77 | parent::ListViewSmarty(); |
75 | 78 | $this->th = new TemplateHandler(); |
@@ -108,6 +111,7 @@ discard block |
||
108 | 111 | * @param file file Template file to use |
109 | 112 | * @param data array from ListViewData |
110 | 113 | * @param html_var string the corresponding html var in xtpl per row |
114 | + * @param string $htmlVar |
|
111 | 115 | * |
112 | 116 | */ |
113 | 117 | function process($file, $data, $htmlVar) { |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | define("NUM_COLS", 2); |
46 | 46 | class PopupSmarty extends ListViewSmarty{ |
47 | 47 | |
48 | - var $contextMenus = false; |
|
49 | - var $export = false; |
|
50 | - var $mailmerge = false; |
|
51 | - var $mergeduplicates = false; |
|
52 | - var $quickViewLinks = false; |
|
53 | - var $multiSelect = false; |
|
54 | - var $headerTpl; |
|
48 | + var $contextMenus = false; |
|
49 | + var $export = false; |
|
50 | + var $mailmerge = false; |
|
51 | + var $mergeduplicates = false; |
|
52 | + var $quickViewLinks = false; |
|
53 | + var $multiSelect = false; |
|
54 | + var $headerTpl; |
|
55 | 55 | var $footerTpl; |
56 | 56 | var $th; |
57 | 57 | var $tpl; |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | var $module; |
71 | 71 | var $massUpdateData = ''; |
72 | 72 | |
73 | - public function __construct($seed, $module){ |
|
74 | - parent::__construct(); |
|
75 | - $this->th = new TemplateHandler(); |
|
76 | - $this->th->loadSmarty(); |
|
77 | - $this->seed = $seed; |
|
78 | - $this->view = 'Popup'; |
|
79 | - $this->module = $module; |
|
80 | - $this->searchForm = new SearchForm($this->seed, $this->module); |
|
81 | - $this->th->deleteTemplate($module, $this->view); |
|
73 | + public function __construct($seed, $module){ |
|
74 | + parent::__construct(); |
|
75 | + $this->th = new TemplateHandler(); |
|
76 | + $this->th->loadSmarty(); |
|
77 | + $this->seed = $seed; |
|
78 | + $this->view = 'Popup'; |
|
79 | + $this->module = $module; |
|
80 | + $this->searchForm = new SearchForm($this->seed, $this->module); |
|
81 | + $this->th->deleteTemplate($module, $this->view); |
|
82 | 82 | $this->headerTpl = 'include/Popups/tpls/header.tpl'; |
83 | 83 | $this->footerTpl = 'include/Popups/tpls/footer.tpl'; |
84 | 84 | |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Assign several arrow image attributes to TemplateHandler smarty. Such as width, height, etc. |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $this->th->ss->assign('arrowAlt', translate('LBL_SORT')); |
102 | 102 | } |
103 | 103 | |
104 | - /** |
|
104 | + /** |
|
105 | 105 | * Processes the request. Calls ListViewData process. Also assigns all lang strings, export links, |
106 | 106 | * This is called from ListViewDisplay |
107 | 107 | * |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | * @param html_var string the corresponding html var in xtpl per row |
111 | 111 | * |
112 | 112 | */ |
113 | - function process($file, $data, $htmlVar) { |
|
113 | + function process($file, $data, $htmlVar) { |
|
114 | 114 | |
115 | - global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings; |
|
116 | - parent::process($file, $data, $htmlVar); |
|
115 | + global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings; |
|
116 | + parent::process($file, $data, $htmlVar); |
|
117 | 117 | |
118 | - $this->tpl = $file; |
|
119 | - $this->data = $data; |
|
118 | + $this->tpl = $file; |
|
119 | + $this->data = $data; |
|
120 | 120 | |
121 | 121 | $totalWidth = 0; |
122 | 122 | foreach($this->displayColumns as $name => $params) { |
@@ -131,47 +131,47 @@ discard block |
||
131 | 131 | if(!empty($params['contextMenu']['objectType'])) |
132 | 132 | $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true; |
133 | 133 | } |
134 | - $this->th->ss->assign('displayColumns', $this->displayColumns); |
|
134 | + $this->th->ss->assign('displayColumns', $this->displayColumns); |
|
135 | 135 | |
136 | 136 | |
137 | - $this->th->ss->assign('bgHilite', $hilite_bg); |
|
138 | - $this->th->ss->assign('colCount', count($this->displayColumns) + 1); |
|
139 | - $this->th->ss->assign('htmlVar', strtoupper($htmlVar)); |
|
140 | - $this->th->ss->assign('moduleString', $this->moduleString); |
|
137 | + $this->th->ss->assign('bgHilite', $hilite_bg); |
|
138 | + $this->th->ss->assign('colCount', count($this->displayColumns) + 1); |
|
139 | + $this->th->ss->assign('htmlVar', strtoupper($htmlVar)); |
|
140 | + $this->th->ss->assign('moduleString', $this->moduleString); |
|
141 | 141 | $this->th->ss->assign('editLinkString', $GLOBALS['app_strings']['LBL_EDIT_BUTTON']); |
142 | 142 | $this->th->ss->assign('viewLinkString', $GLOBALS['app_strings']['LBL_VIEW_BUTTON']); |
143 | 143 | |
144 | 144 | //rrs |
145 | 145 | $this->searchForm->parsedView = 'popup_query_form'; |
146 | 146 | $this->searchForm->displayType = 'popupView'; |
147 | - $this->th->ss->assign('searchForm', $this->searchForm->display(false)); |
|
147 | + $this->th->ss->assign('searchForm', $this->searchForm->display(false)); |
|
148 | 148 | //rrs |
149 | 149 | |
150 | - if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
151 | - $this->th->ss->assign('quickViewLinks', $this->quickViewLinks); |
|
152 | - if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access |
|
153 | - if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
150 | + if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
151 | + $this->th->ss->assign('quickViewLinks', $this->quickViewLinks); |
|
152 | + if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access |
|
153 | + if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
154 | 154 | |
155 | 155 | |
156 | - if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') { |
|
157 | - $this->multiSelect = true; |
|
158 | - } |
|
159 | - // handle save checks and stuff |
|
160 | - if($this->multiSelect) { |
|
161 | - $this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan()); |
|
162 | - $this->th->ss->assign('multiSelectData', $this->getMultiSelectData()); |
|
163 | - $this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>"); |
|
156 | + if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') { |
|
157 | + $this->multiSelect = true; |
|
158 | + } |
|
159 | + // handle save checks and stuff |
|
160 | + if($this->multiSelect) { |
|
161 | + $this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan()); |
|
162 | + $this->th->ss->assign('multiSelectData', $this->getMultiSelectData()); |
|
163 | + $this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>"); |
|
164 | 164 | $pageTotal = $this->data['pageData']['offsets']['next'] - $this->data['pageData']['offsets']['current']; |
165 | 165 | if($this->data['pageData']['offsets']['next'] < 0){ // If we are on the last page, 'next' is -1, which means we have to have a custom calculation |
166 | 166 | $pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current']; |
167 | 167 | } |
168 | - $this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal)); |
|
169 | - } |
|
168 | + $this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal)); |
|
169 | + } |
|
170 | 170 | |
171 | - $this->processArrows($data['pageData']['ordering']); |
|
172 | - $this->th->ss->assign('prerow', $this->multiSelect); |
|
173 | - $this->th->ss->assign('rowColor', array('oddListRow', 'evenListRow')); |
|
174 | - $this->th->ss->assign('bgColor', array($odd_bg, $even_bg)); |
|
171 | + $this->processArrows($data['pageData']['ordering']); |
|
172 | + $this->th->ss->assign('prerow', $this->multiSelect); |
|
173 | + $this->th->ss->assign('rowColor', array('oddListRow', 'evenListRow')); |
|
174 | + $this->th->ss->assign('bgColor', array($odd_bg, $even_bg)); |
|
175 | 175 | $this->th->ss->assign('contextMenus', $this->contextMenus); |
176 | 176 | |
177 | 177 | |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | |
192 | 192 | // arrow image attributes |
193 | 193 | $this->processArrowVars(); |
194 | - } |
|
194 | + } |
|
195 | 195 | |
196 | - /* |
|
196 | + /* |
|
197 | 197 | * Display the Smarty template. Here we are using the TemplateHandler for caching per the module. |
198 | 198 | */ |
199 | - function display($end = true) { |
|
199 | + function display($end = true) { |
|
200 | 200 | global $app_strings; |
201 | 201 | |
202 | 202 | if(!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) { |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); |
207 | 207 | |
208 | 208 | $this->th->ss->assign('data', $this->data['data']); |
209 | - $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']); |
|
210 | - $this->th->ss->assign('pageData', $this->data['pageData']); |
|
209 | + $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']); |
|
210 | + $this->th->ss->assign('pageData', $this->data['pageData']); |
|
211 | 211 | |
212 | 212 | $navStrings = array('next' => $GLOBALS['app_strings']['LNK_LIST_NEXT'], |
213 | 213 | 'previous' => $GLOBALS['app_strings']['LNK_LIST_PREVIOUS'], |
@@ -217,128 +217,128 @@ discard block |
||
217 | 217 | $this->th->ss->assign('navStrings', $navStrings); |
218 | 218 | |
219 | 219 | |
220 | - $associated_row_data = array(); |
|
221 | - |
|
222 | - //C.L. - Bug 44324 - Override the NAME entry to not display salutation so that the data returned from the popup can be searched on correctly |
|
223 | - $searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false; |
|
224 | - |
|
225 | - global $locale; |
|
226 | - foreach($this->data['data'] as $val) |
|
227 | - { |
|
228 | - $associated_row_data[$val['ID']] = $val; |
|
229 | - if($searchNameOverride) |
|
230 | - { |
|
231 | - $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']); |
|
232 | - } |
|
233 | - } |
|
234 | - $is_show_fullname = showFullName() ? 1 : 0; |
|
235 | - $json = getJSONobj(); |
|
236 | - $this->th->ss->assign('jsLang', $jsLang); |
|
237 | - $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2)); |
|
220 | + $associated_row_data = array(); |
|
221 | + |
|
222 | + //C.L. - Bug 44324 - Override the NAME entry to not display salutation so that the data returned from the popup can be searched on correctly |
|
223 | + $searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false; |
|
224 | + |
|
225 | + global $locale; |
|
226 | + foreach($this->data['data'] as $val) |
|
227 | + { |
|
228 | + $associated_row_data[$val['ID']] = $val; |
|
229 | + if($searchNameOverride) |
|
230 | + { |
|
231 | + $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']); |
|
232 | + } |
|
233 | + } |
|
234 | + $is_show_fullname = showFullName() ? 1 : 0; |
|
235 | + $json = getJSONobj(); |
|
236 | + $this->th->ss->assign('jsLang', $jsLang); |
|
237 | + $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2)); |
|
238 | 238 | $this->th->ss->assign('headerTpl', $this->headerTpl); |
239 | 239 | $this->th->ss->assign('footerTpl', $this->footerTpl); |
240 | 240 | $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data). '; var is_show_fullname = '.$is_show_fullname.';'); |
241 | - $this->th->ss->assign('module', $this->seed->module_dir); |
|
242 | - $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; |
|
243 | - |
|
244 | - $this->th->ss->assign('request_data', $request_data); |
|
245 | - $this->th->ss->assign('fields', $this->fieldDefs); |
|
246 | - $this->th->ss->assign('formData', $this->formData); |
|
247 | - $this->th->ss->assign('APP', $GLOBALS['app_strings']); |
|
248 | - $this->th->ss->assign('MOD', $GLOBALS['mod_strings']); |
|
241 | + $this->th->ss->assign('module', $this->seed->module_dir); |
|
242 | + $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; |
|
243 | + |
|
244 | + $this->th->ss->assign('request_data', $request_data); |
|
245 | + $this->th->ss->assign('fields', $this->fieldDefs); |
|
246 | + $this->th->ss->assign('formData', $this->formData); |
|
247 | + $this->th->ss->assign('APP', $GLOBALS['app_strings']); |
|
248 | + $this->th->ss->assign('MOD', $GLOBALS['mod_strings']); |
|
249 | 249 | if (isset($this->_popupMeta['create']['createButton'])) |
250 | - { |
|
251 | - $this->_popupMeta['create']['createButton'] = translate($this->_popupMeta['create']['createButton']); |
|
250 | + { |
|
251 | + $this->_popupMeta['create']['createButton'] = translate($this->_popupMeta['create']['createButton']); |
|
252 | 252 | } |
253 | - $this->th->ss->assign('popupMeta', $this->_popupMeta); |
|
253 | + $this->th->ss->assign('popupMeta', $this->_popupMeta); |
|
254 | 254 | $this->th->ss->assign('current_query', base64_encode(serialize($_REQUEST))); |
255 | - $this->th->ss->assign('customFields', $this->customFieldDefs); |
|
256 | - $this->th->ss->assign('numCols', NUM_COLS); |
|
257 | - $this->th->ss->assign('massUpdateData', $this->massUpdateData); |
|
258 | - $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']); |
|
255 | + $this->th->ss->assign('customFields', $this->customFieldDefs); |
|
256 | + $this->th->ss->assign('numCols', NUM_COLS); |
|
257 | + $this->th->ss->assign('massUpdateData', $this->massUpdateData); |
|
258 | + $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']); |
|
259 | 259 | $this->th->ss->assign('should_process', $this->should_process); |
260 | 260 | |
261 | - if($this->_create){ |
|
262 | - $this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm()); |
|
263 | - $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader()); |
|
264 | - $this->th->ss->assign('object_name', $this->seed->object_name); |
|
265 | - } |
|
266 | - $this->th->ss->assign('LIST_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'], '', false)); |
|
267 | - $this->th->ss->assign('SEARCH_FORM_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_SEARCH_FORM_TITLE'], '', false)); |
|
268 | - $str = $this->th->displayTemplate($this->seed->module_dir, $this->view, $this->tpl); |
|
269 | - return $str; |
|
270 | - } |
|
271 | - |
|
272 | - /* |
|
261 | + if($this->_create){ |
|
262 | + $this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm()); |
|
263 | + $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader()); |
|
264 | + $this->th->ss->assign('object_name', $this->seed->object_name); |
|
265 | + } |
|
266 | + $this->th->ss->assign('LIST_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'], '', false)); |
|
267 | + $this->th->ss->assign('SEARCH_FORM_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_SEARCH_FORM_TITLE'], '', false)); |
|
268 | + $str = $this->th->displayTemplate($this->seed->module_dir, $this->view, $this->tpl); |
|
269 | + return $str; |
|
270 | + } |
|
271 | + |
|
272 | + /* |
|
273 | 273 | * Setup up the smarty template. we added an extra step here to add the order by from the popupdefs. |
274 | 274 | */ |
275 | - function setup($seed, $file = null, $where = null, $params = Array(), $offset = 0, $limit = -1, $filter_fields = Array(), $id_field = 'id') { |
|
276 | - $args = func_get_args(); |
|
277 | - return call_user_func_array(array($this, '_setup'), $args); |
|
278 | - } |
|
279 | - function _setup($file) { |
|
280 | - |
|
281 | - if(isset($this->_popupMeta)){ |
|
282 | - if(isset($this->_popupMeta['create']['formBase'])) { |
|
283 | - require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']); |
|
284 | - $this->_create = true; |
|
285 | - } |
|
286 | - } |
|
287 | - if(!empty($this->_popupMeta['create'])){ |
|
288 | - $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
|
289 | - if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save') |
|
290 | - { |
|
291 | - //If it's a new record, set useRequired to false |
|
292 | - $useRequired = empty($_REQUEST['id']) ? false : true; |
|
293 | - $formBase->handleSave('', false, $useRequired); |
|
294 | - } |
|
295 | - } |
|
296 | - |
|
297 | - $params = array(); |
|
298 | - if(!empty($this->_popupMeta['orderBy'])){ |
|
299 | - $params['orderBy'] = $this->_popupMeta['orderBy']; |
|
300 | - } |
|
301 | - |
|
302 | - if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){ |
|
303 | - require('custom/modules/'.$this->module.'/metadata/metafiles.php'); |
|
304 | - }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
305 | - require('modules/'.$this->module.'/metadata/metafiles.php'); |
|
306 | - } |
|
307 | - |
|
308 | - if(!empty($metafiles[$this->module]['searchfields'])) { |
|
309 | - require($metafiles[$this->module]['searchfields']); |
|
310 | - } elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) { |
|
311 | - require('modules/'.$this->module.'/metadata/SearchFields.php'); |
|
312 | - } |
|
275 | + function setup($seed, $file = null, $where = null, $params = Array(), $offset = 0, $limit = -1, $filter_fields = Array(), $id_field = 'id') { |
|
276 | + $args = func_get_args(); |
|
277 | + return call_user_func_array(array($this, '_setup'), $args); |
|
278 | + } |
|
279 | + function _setup($file) { |
|
280 | + |
|
281 | + if(isset($this->_popupMeta)){ |
|
282 | + if(isset($this->_popupMeta['create']['formBase'])) { |
|
283 | + require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']); |
|
284 | + $this->_create = true; |
|
285 | + } |
|
286 | + } |
|
287 | + if(!empty($this->_popupMeta['create'])){ |
|
288 | + $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
|
289 | + if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save') |
|
290 | + { |
|
291 | + //If it's a new record, set useRequired to false |
|
292 | + $useRequired = empty($_REQUEST['id']) ? false : true; |
|
293 | + $formBase->handleSave('', false, $useRequired); |
|
294 | + } |
|
295 | + } |
|
296 | + |
|
297 | + $params = array(); |
|
298 | + if(!empty($this->_popupMeta['orderBy'])){ |
|
299 | + $params['orderBy'] = $this->_popupMeta['orderBy']; |
|
300 | + } |
|
301 | + |
|
302 | + if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){ |
|
303 | + require('custom/modules/'.$this->module.'/metadata/metafiles.php'); |
|
304 | + }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
305 | + require('modules/'.$this->module.'/metadata/metafiles.php'); |
|
306 | + } |
|
307 | + |
|
308 | + if(!empty($metafiles[$this->module]['searchfields'])) { |
|
309 | + require($metafiles[$this->module]['searchfields']); |
|
310 | + } elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) { |
|
311 | + require('modules/'.$this->module.'/metadata/SearchFields.php'); |
|
312 | + } |
|
313 | 313 | $this->searchdefs[$this->module]['templateMeta']['maxColumns'] = 2; |
314 | 314 | $this->searchdefs[$this->module]['templateMeta']['widths']['label'] = 10; |
315 | 315 | $this->searchdefs[$this->module]['templateMeta']['widths']['field'] = 30; |
316 | 316 | |
317 | 317 | $this->searchForm->view = 'PopupSearchForm'; |
318 | - $this->searchForm->setup($this->searchdefs, $searchFields, 'SearchFormGenericAdvanced.tpl', 'advanced_search', $this->listviewdefs); |
|
319 | - |
|
320 | - $lv = new ListViewSmarty(); |
|
321 | - $displayColumns = array(); |
|
322 | - if(!empty($_REQUEST['displayColumns'])) { |
|
323 | - foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) { |
|
324 | - if(!empty($listViewDefs[$this->module][$col])) |
|
325 | - $displayColumns[$col] = $this->listviewdefs[$this->module][$col]; |
|
326 | - } |
|
327 | - } |
|
328 | - else { |
|
329 | - foreach($this->listviewdefs[$this->module] as $col => $para) { |
|
330 | - if(!empty($para['default']) && $para['default']) |
|
331 | - $displayColumns[$col] = $para; |
|
332 | - } |
|
333 | - } |
|
334 | - $params['massupdate'] = true; |
|
335 | - if(!empty($_REQUEST['orderBy'])) { |
|
336 | - $params['orderBy'] = $_REQUEST['orderBy']; |
|
337 | - $params['overrideOrder'] = true; |
|
338 | - if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
339 | - } |
|
340 | - |
|
341 | - $lv->displayColumns = $displayColumns; |
|
318 | + $this->searchForm->setup($this->searchdefs, $searchFields, 'SearchFormGenericAdvanced.tpl', 'advanced_search', $this->listviewdefs); |
|
319 | + |
|
320 | + $lv = new ListViewSmarty(); |
|
321 | + $displayColumns = array(); |
|
322 | + if(!empty($_REQUEST['displayColumns'])) { |
|
323 | + foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) { |
|
324 | + if(!empty($listViewDefs[$this->module][$col])) |
|
325 | + $displayColumns[$col] = $this->listviewdefs[$this->module][$col]; |
|
326 | + } |
|
327 | + } |
|
328 | + else { |
|
329 | + foreach($this->listviewdefs[$this->module] as $col => $para) { |
|
330 | + if(!empty($para['default']) && $para['default']) |
|
331 | + $displayColumns[$col] = $para; |
|
332 | + } |
|
333 | + } |
|
334 | + $params['massupdate'] = true; |
|
335 | + if(!empty($_REQUEST['orderBy'])) { |
|
336 | + $params['orderBy'] = $_REQUEST['orderBy']; |
|
337 | + $params['overrideOrder'] = true; |
|
338 | + if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
339 | + } |
|
340 | + |
|
341 | + $lv->displayColumns = $displayColumns; |
|
342 | 342 | $this->searchForm->lv = $lv; |
343 | 343 | $this->searchForm->displaySavedSearch = false; |
344 | 344 | |
@@ -351,25 +351,25 @@ discard block |
||
351 | 351 | $this->should_process = true; |
352 | 352 | |
353 | 353 | if(isset($params['export'])) { |
354 | - $this->export = $params['export']; |
|
354 | + $this->export = $params['export']; |
|
355 | 355 | } |
356 | 356 | if(!empty($params['multiSelectPopup'])) { |
357 | - $this->multi_select_popup = $params['multiSelectPopup']; |
|
357 | + $this->multi_select_popup = $params['multiSelectPopup']; |
|
358 | 358 | } |
359 | - if(!empty($params['massupdate']) && $params['massupdate'] != false) { |
|
360 | - $this->show_mass_update_form = true; |
|
361 | - $this->mass = new MassUpdate(); |
|
362 | - $this->mass->setSugarBean($this->seed); |
|
363 | - if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) { |
|
359 | + if(!empty($params['massupdate']) && $params['massupdate'] != false) { |
|
360 | + $this->show_mass_update_form = true; |
|
361 | + $this->mass = new MassUpdate(); |
|
362 | + $this->mass->setSugarBean($this->seed); |
|
363 | + if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) { |
|
364 | 364 | $this->mass->handleMassUpdate(); |
365 | 365 | } |
366 | - } |
|
366 | + } |
|
367 | 367 | |
368 | 368 | // create filter fields based off of display columns |
369 | 369 | if(empty($this->filter_fields) || $this->mergeDisplayColumns) { |
370 | 370 | foreach($this->displayColumns as $columnName => $def) { |
371 | - $this->filter_fields[strtolower($columnName)] = true; |
|
372 | - if(!empty($def['related_fields'])) { |
|
371 | + $this->filter_fields[strtolower($columnName)] = true; |
|
372 | + if(!empty($def['related_fields'])) { |
|
373 | 373 | foreach($def['related_fields'] as $field) { |
374 | 374 | //id column is added by query construction function. This addition creates duplicates |
375 | 375 | //and causes issues in oracle. #10165 |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) { |
382 | - foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){ |
|
383 | - if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)]) |
|
384 | - { |
|
385 | - $this->filter_fields[strtolower($field)] = true; |
|
386 | - } |
|
387 | - } |
|
382 | + foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){ |
|
383 | + if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)]) |
|
384 | + { |
|
385 | + $this->filter_fields[strtolower($field)] = true; |
|
386 | + } |
|
387 | + } |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | foreach ($this->searchColumns as $columnName => $def ) |
@@ -418,119 +418,119 @@ discard block |
||
418 | 418 | } |
419 | 419 | |
420 | 420 | |
421 | - if (!empty($_REQUEST['query']) || (!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] != 'populate_only')) { |
|
422 | - $data = $this->lvd->getListViewData($this->seed, $searchWhere, 0, -1, $this->filter_fields, $params, 'id'); |
|
423 | - } else { |
|
424 | - $this->should_process = false; |
|
425 | - $data = array( |
|
426 | - 'data'=>array(), |
|
427 | - 'pageData'=>array( |
|
428 | - 'bean'=>array('moduleDir'=>$this->seed->module_dir), |
|
429 | - 'ordering'=>'', |
|
430 | - 'offsets'=>array('total'=>0,'next'=>0,'current'=>0), |
|
431 | - ), |
|
432 | - ); |
|
433 | - } |
|
421 | + if (!empty($_REQUEST['query']) || (!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] != 'populate_only')) { |
|
422 | + $data = $this->lvd->getListViewData($this->seed, $searchWhere, 0, -1, $this->filter_fields, $params, 'id'); |
|
423 | + } else { |
|
424 | + $this->should_process = false; |
|
425 | + $data = array( |
|
426 | + 'data'=>array(), |
|
427 | + 'pageData'=>array( |
|
428 | + 'bean'=>array('moduleDir'=>$this->seed->module_dir), |
|
429 | + 'ordering'=>'', |
|
430 | + 'offsets'=>array('total'=>0,'next'=>0,'current'=>0), |
|
431 | + ), |
|
432 | + ); |
|
433 | + } |
|
434 | 434 | |
435 | 435 | $this->fillDisplayColumnsWithVardefs(); |
436 | 436 | |
437 | - $this->process($file, $data, $this->seed->object_name); |
|
438 | - } |
|
437 | + $this->process($file, $data, $this->seed->object_name); |
|
438 | + } |
|
439 | 439 | |
440 | - /* |
|
440 | + /* |
|
441 | 441 | * Return the where clause as per the REQUEST. |
442 | 442 | */ |
443 | - function _get_where_clause() |
|
444 | - { |
|
445 | - $where = ''; |
|
446 | - $where_clauses = $this->searchForm->generateSearchWhere(true, $this->seed->module_dir); |
|
447 | - |
|
448 | - // Bug 43452 - FG - Changed the way generated Where array is imploded into the string. |
|
449 | - // Now it's imploding in the same way view.list.php do. |
|
450 | - if (count($where_clauses) > 0 ) { |
|
451 | - $where = '( ' . implode(' and ', $where_clauses) . ' )'; |
|
443 | + function _get_where_clause() |
|
444 | + { |
|
445 | + $where = ''; |
|
446 | + $where_clauses = $this->searchForm->generateSearchWhere(true, $this->seed->module_dir); |
|
447 | + |
|
448 | + // Bug 43452 - FG - Changed the way generated Where array is imploded into the string. |
|
449 | + // Now it's imploding in the same way view.list.php do. |
|
450 | + if (count($where_clauses) > 0 ) { |
|
451 | + $where = '( ' . implode(' and ', $where_clauses) . ' )'; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | // Need to include the default whereStatement |
455 | - if(!empty($this->_popupMeta['whereStatement'])){ |
|
455 | + if(!empty($this->_popupMeta['whereStatement'])){ |
|
456 | 456 | if(!empty($where))$where .= ' AND '; |
457 | 457 | $where .= $this->_popupMeta['whereStatement']; |
458 | - } |
|
458 | + } |
|
459 | 459 | |
460 | - return $where; |
|
461 | - } |
|
460 | + return $where; |
|
461 | + } |
|
462 | 462 | |
463 | - /* |
|
463 | + /* |
|
464 | 464 | * Generate the data for the search form on the header of the Popup. |
465 | 465 | */ |
466 | - function _build_field_defs(){ |
|
467 | - $this->formData = array(); |
|
468 | - $this->customFieldDefs = array(); |
|
469 | - foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){ |
|
470 | - if(is_array($data)){ |
|
471 | - |
|
472 | - $this->formData[] = array('field' => $data); |
|
473 | - $value = ''; |
|
474 | - $this->customFieldDefs[$data['name']]= $data; |
|
475 | - if(!empty($_REQUEST[$data['name']])) |
|
476 | - $value = $_REQUEST[$data['name']]; |
|
477 | - $this->customFieldDefs[$data['name']]['value'] = $value; |
|
478 | - }else |
|
479 | - $this->formData[] = array('field' => array('name'=>$data)); |
|
480 | - } |
|
481 | - $this->fieldDefs = array(); |
|
482 | - if($this->seed){ |
|
483 | - $this->seed->fill_in_additional_detail_fields(); |
|
484 | - |
|
485 | - foreach($this->seed->toArray() as $name => $value) { |
|
486 | - $this->fieldDefs[$name] = $this->seed->field_defs[$name]; |
|
487 | - //if we have a relate type then reset to name so that we end up with a textbox |
|
488 | - //rather than a select button |
|
489 | - $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name']; |
|
490 | - if($this->fieldDefs[$name]['type'] == 'relate') |
|
491 | - $this->fieldDefs[$name]['type'] = 'name'; |
|
492 | - if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) { |
|
493 | - $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums |
|
494 | - } |
|
495 | - if(!empty($_REQUEST[$name])) |
|
496 | - $value = $_REQUEST[$name]; |
|
497 | - $this->fieldDefs[$name]['value'] = $value; |
|
498 | - } |
|
499 | - } |
|
500 | - } |
|
501 | - |
|
502 | - function _getAddForm(){ |
|
503 | - $addform = ''; |
|
466 | + function _build_field_defs(){ |
|
467 | + $this->formData = array(); |
|
468 | + $this->customFieldDefs = array(); |
|
469 | + foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){ |
|
470 | + if(is_array($data)){ |
|
471 | + |
|
472 | + $this->formData[] = array('field' => $data); |
|
473 | + $value = ''; |
|
474 | + $this->customFieldDefs[$data['name']]= $data; |
|
475 | + if(!empty($_REQUEST[$data['name']])) |
|
476 | + $value = $_REQUEST[$data['name']]; |
|
477 | + $this->customFieldDefs[$data['name']]['value'] = $value; |
|
478 | + }else |
|
479 | + $this->formData[] = array('field' => array('name'=>$data)); |
|
480 | + } |
|
481 | + $this->fieldDefs = array(); |
|
482 | + if($this->seed){ |
|
483 | + $this->seed->fill_in_additional_detail_fields(); |
|
484 | + |
|
485 | + foreach($this->seed->toArray() as $name => $value) { |
|
486 | + $this->fieldDefs[$name] = $this->seed->field_defs[$name]; |
|
487 | + //if we have a relate type then reset to name so that we end up with a textbox |
|
488 | + //rather than a select button |
|
489 | + $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name']; |
|
490 | + if($this->fieldDefs[$name]['type'] == 'relate') |
|
491 | + $this->fieldDefs[$name]['type'] = 'name'; |
|
492 | + if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) { |
|
493 | + $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums |
|
494 | + } |
|
495 | + if(!empty($_REQUEST[$name])) |
|
496 | + $value = $_REQUEST[$name]; |
|
497 | + $this->fieldDefs[$name]['value'] = $value; |
|
498 | + } |
|
499 | + } |
|
500 | + } |
|
501 | + |
|
502 | + function _getAddForm(){ |
|
503 | + $addform = ''; |
|
504 | 504 | if(!$this->seed->ACLAccess('save')){ |
505 | 505 | return; |
506 | 506 | } |
507 | - if(!empty($this->_popupMeta['create'])){ |
|
508 | - $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
|
507 | + if(!empty($this->_popupMeta['create'])){ |
|
508 | + $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
|
509 | 509 | |
510 | 510 | |
511 | 511 | |
512 | - // TODO: cleanup the construction of $addform |
|
513 | - $prefix = empty($this->_popupMeta['create']['getFormBodyParams'][0]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][0]; |
|
514 | - $mod = empty($this->_popupMeta['create']['getFormBodyParams'][1]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][1]; |
|
515 | - $formBody = empty($this->_popupMeta['create']['getFormBodyParams'][2]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][2]; |
|
512 | + // TODO: cleanup the construction of $addform |
|
513 | + $prefix = empty($this->_popupMeta['create']['getFormBodyParams'][0]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][0]; |
|
514 | + $mod = empty($this->_popupMeta['create']['getFormBodyParams'][1]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][1]; |
|
515 | + $formBody = empty($this->_popupMeta['create']['getFormBodyParams'][2]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][2]; |
|
516 | 516 | |
517 | - $getFormMethod = (empty($this->_popupMeta['create']['getFormMethod']) ? 'getFormBody' : $this->_popupMeta['create']['getFormMethod']); |
|
518 | - $formbody = $formBase->$getFormMethod($prefix, $mod, $formBody); |
|
517 | + $getFormMethod = (empty($this->_popupMeta['create']['getFormMethod']) ? 'getFormBody' : $this->_popupMeta['create']['getFormMethod']); |
|
518 | + $formbody = $formBase->$getFormMethod($prefix, $mod, $formBody); |
|
519 | 519 | |
520 | - $addform = '<table><tr><td nowrap="nowrap" valign="top">' |
|
521 | - . str_replace('<br>', '</td><td nowrap="nowrap" valign="top"> ', $formbody) |
|
522 | - . '</td></tr></table>' |
|
523 | - . '<input type="hidden" name="action" value="Popup" />'; |
|
520 | + $addform = '<table><tr><td nowrap="nowrap" valign="top">' |
|
521 | + . str_replace('<br>', '</td><td nowrap="nowrap" valign="top"> ', $formbody) |
|
522 | + . '</td></tr></table>' |
|
523 | + . '<input type="hidden" name="action" value="Popup" />'; |
|
524 | 524 | |
525 | - return $addform; |
|
526 | - } |
|
527 | - } |
|
525 | + return $addform; |
|
526 | + } |
|
527 | + } |
|
528 | 528 | |
529 | - function _getAddFormHeader(){ |
|
530 | - $lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE']; |
|
531 | - $lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY']; |
|
532 | - $lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL']; |
|
533 | - $module_dir = $this->seed->module_dir; |
|
529 | + function _getAddFormHeader(){ |
|
530 | + $lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE']; |
|
531 | + $lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY']; |
|
532 | + $lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL']; |
|
533 | + $module_dir = $this->seed->module_dir; |
|
534 | 534 | $formSave = <<<EOQ |
535 | 535 | <input type="hidden" name="create" value="true"> |
536 | 536 | <input type="hidden" name="popup" value="true"> |
@@ -538,21 +538,21 @@ discard block |
||
538 | 538 | <input type="hidden" name="return_module" value="$module_dir"> |
539 | 539 | <input type="hidden" name="return_action" value="Popup"> |
540 | 540 | EOQ; |
541 | - // if metadata contains custom inputs for the quickcreate |
|
542 | - if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) { |
|
543 | - foreach($this->_popupMeta['customInput'] as $key => $value) |
|
544 | - $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n'; |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - $addformheader = get_form_header(translate($this->_popupMeta['create']['createButton']), $formSave, false); |
|
549 | - return $addformheader; |
|
550 | - } |
|
551 | - |
|
552 | - function getQuickCreate(){ |
|
553 | - require_once("include/EditView/PopupQuickCreate.php"); |
|
554 | - $qc = new PopupQuickCreate($this->module); |
|
555 | - return $qc->process($this->module); |
|
556 | - } |
|
541 | + // if metadata contains custom inputs for the quickcreate |
|
542 | + if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) { |
|
543 | + foreach($this->_popupMeta['customInput'] as $key => $value) |
|
544 | + $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n'; |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + $addformheader = get_form_header(translate($this->_popupMeta['create']['createButton']), $formSave, false); |
|
549 | + return $addformheader; |
|
550 | + } |
|
551 | + |
|
552 | + function getQuickCreate(){ |
|
553 | + require_once("include/EditView/PopupQuickCreate.php"); |
|
554 | + $qc = new PopupQuickCreate($this->module); |
|
555 | + return $qc->process($this->module); |
|
556 | + } |
|
557 | 557 | } |
558 | 558 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
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. |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | require_once('include/TemplateHandler/TemplateHandler.php'); |
44 | 44 | require_once('include/SearchForm/SearchForm2.php'); |
45 | 45 | define("NUM_COLS", 2); |
46 | -class PopupSmarty extends ListViewSmarty{ |
|
46 | +class PopupSmarty extends ListViewSmarty { |
|
47 | 47 | |
48 | 48 | var $contextMenus = false; |
49 | 49 | var $export = false; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | var $module; |
71 | 71 | var $massUpdateData = ''; |
72 | 72 | |
73 | - public function __construct($seed, $module){ |
|
73 | + public function __construct($seed, $module) { |
|
74 | 74 | parent::__construct(); |
75 | 75 | $this->th = new TemplateHandler(); |
76 | 76 | $this->th->loadSmarty(); |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function processArrowVars() |
93 | 93 | { |
94 | - $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false)); |
|
94 | + $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif', false)); |
|
95 | 95 | |
96 | - list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']); |
|
96 | + list($width, $height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']); |
|
97 | 97 | |
98 | 98 | $this->th->ss->assign('arrowExt', $pathParts['extension']); |
99 | 99 | $this->th->ss->assign('arrowWidth', $width); |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | $this->data = $data; |
120 | 120 | |
121 | 121 | $totalWidth = 0; |
122 | - foreach($this->displayColumns as $name => $params) { |
|
122 | + foreach ($this->displayColumns as $name => $params) { |
|
123 | 123 | $totalWidth += $params['width']; |
124 | 124 | } |
125 | 125 | $adjustment = $totalWidth / 100; |
126 | 126 | |
127 | 127 | $contextMenuObjectsTypes = array(); |
128 | - foreach($this->displayColumns as $name => $params) { |
|
128 | + foreach ($this->displayColumns as $name => $params) { |
|
129 | 129 | $this->displayColumns[$name]['width'] = round($this->displayColumns[$name]['width'] / $adjustment, 2); |
130 | 130 | // figure out which contextMenu objectsTypes are required |
131 | - if(!empty($params['contextMenu']['objectType'])) |
|
131 | + if (!empty($params['contextMenu']['objectType'])) |
|
132 | 132 | $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true; |
133 | 133 | } |
134 | 134 | $this->th->ss->assign('displayColumns', $this->displayColumns); |
@@ -147,22 +147,22 @@ discard block |
||
147 | 147 | $this->th->ss->assign('searchForm', $this->searchForm->display(false)); |
148 | 148 | //rrs |
149 | 149 | |
150 | - if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
150 | + if ($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
151 | 151 | $this->th->ss->assign('quickViewLinks', $this->quickViewLinks); |
152 | - if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access |
|
153 | - if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
152 | + if ($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access |
|
153 | + if ($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') { |
157 | 157 | $this->multiSelect = true; |
158 | 158 | } |
159 | 159 | // handle save checks and stuff |
160 | - if($this->multiSelect) { |
|
160 | + if ($this->multiSelect) { |
|
161 | 161 | $this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan()); |
162 | 162 | $this->th->ss->assign('multiSelectData', $this->getMultiSelectData()); |
163 | 163 | $this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>"); |
164 | 164 | $pageTotal = $this->data['pageData']['offsets']['next'] - $this->data['pageData']['offsets']['current']; |
165 | - if($this->data['pageData']['offsets']['next'] < 0){ // If we are on the last page, 'next' is -1, which means we have to have a custom calculation |
|
165 | + if ($this->data['pageData']['offsets']['next'] < 0) { // If we are on the last page, 'next' is -1, which means we have to have a custom calculation |
|
166 | 166 | $pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current']; |
167 | 167 | } |
168 | 168 | $this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal)); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | $this->th->ss->assign('contextMenus', $this->contextMenus); |
176 | 176 | |
177 | 177 | |
178 | - if($this->contextMenus && !empty($contextMenuObjectsTypes)) { |
|
178 | + if ($this->contextMenus && !empty($contextMenuObjectsTypes)) { |
|
179 | 179 | $script = ''; |
180 | 180 | $cm = new contextMenu(); |
181 | - foreach($contextMenuObjectsTypes as $type => $value) { |
|
181 | + foreach ($contextMenuObjectsTypes as $type => $value) { |
|
182 | 182 | $cm->loadFromFile($type); |
183 | 183 | $script .= $cm->getScript(); |
184 | 184 | $cm->menuItems = array(); // clear menuItems out |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | function display($end = true) { |
200 | 200 | global $app_strings; |
201 | 201 | |
202 | - if(!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) { |
|
202 | + if (!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) { |
|
203 | 203 | require_once('include/language/jsLanguage.php'); |
204 | 204 | jsLanguage::createAppStringsCache($GLOBALS['current_language']); |
205 | 205 | } |
206 | - $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); |
|
206 | + $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); |
|
207 | 207 | |
208 | 208 | $this->th->ss->assign('data', $this->data['data']); |
209 | 209 | $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']); |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | $searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false; |
224 | 224 | |
225 | 225 | global $locale; |
226 | - foreach($this->data['data'] as $val) |
|
226 | + foreach ($this->data['data'] as $val) |
|
227 | 227 | { |
228 | 228 | $associated_row_data[$val['ID']] = $val; |
229 | - if($searchNameOverride) |
|
229 | + if ($searchNameOverride) |
|
230 | 230 | { |
231 | 231 | $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']); |
232 | 232 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2)); |
238 | 238 | $this->th->ss->assign('headerTpl', $this->headerTpl); |
239 | 239 | $this->th->ss->assign('footerTpl', $this->footerTpl); |
240 | - $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data). '; var is_show_fullname = '.$is_show_fullname.';'); |
|
240 | + $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data).'; var is_show_fullname = '.$is_show_fullname.';'); |
|
241 | 241 | $this->th->ss->assign('module', $this->seed->module_dir); |
242 | 242 | $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; |
243 | 243 | |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']); |
259 | 259 | $this->th->ss->assign('should_process', $this->should_process); |
260 | 260 | |
261 | - if($this->_create){ |
|
262 | - $this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm()); |
|
261 | + if ($this->_create) { |
|
262 | + $this->th->ss->assign('ADDFORM', $this->getQuickCreate()); //$this->_getAddForm()); |
|
263 | 263 | $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader()); |
264 | 264 | $this->th->ss->assign('object_name', $this->seed->object_name); |
265 | 265 | } |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | } |
279 | 279 | function _setup($file) { |
280 | 280 | |
281 | - if(isset($this->_popupMeta)){ |
|
282 | - if(isset($this->_popupMeta['create']['formBase'])) { |
|
283 | - require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']); |
|
281 | + if (isset($this->_popupMeta)) { |
|
282 | + if (isset($this->_popupMeta['create']['formBase'])) { |
|
283 | + require_once('modules/'.$this->seed->module_dir.'/'.$this->_popupMeta['create']['formBase']); |
|
284 | 284 | $this->_create = true; |
285 | 285 | } |
286 | 286 | } |
287 | - if(!empty($this->_popupMeta['create'])){ |
|
287 | + if (!empty($this->_popupMeta['create'])) { |
|
288 | 288 | $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
289 | - if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save') |
|
289 | + if (isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save') |
|
290 | 290 | { |
291 | 291 | //If it's a new record, set useRequired to false |
292 | 292 | $useRequired = empty($_REQUEST['id']) ? false : true; |
@@ -295,19 +295,19 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | $params = array(); |
298 | - if(!empty($this->_popupMeta['orderBy'])){ |
|
298 | + if (!empty($this->_popupMeta['orderBy'])) { |
|
299 | 299 | $params['orderBy'] = $this->_popupMeta['orderBy']; |
300 | 300 | } |
301 | 301 | |
302 | - if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){ |
|
302 | + if (file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')) { |
|
303 | 303 | require('custom/modules/'.$this->module.'/metadata/metafiles.php'); |
304 | - }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
304 | + }elseif (file_exists('modules/'.$this->module.'/metadata/metafiles.php')) { |
|
305 | 305 | require('modules/'.$this->module.'/metadata/metafiles.php'); |
306 | 306 | } |
307 | 307 | |
308 | - if(!empty($metafiles[$this->module]['searchfields'])) { |
|
308 | + if (!empty($metafiles[$this->module]['searchfields'])) { |
|
309 | 309 | require($metafiles[$this->module]['searchfields']); |
310 | - } elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) { |
|
310 | + } elseif (file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) { |
|
311 | 311 | require('modules/'.$this->module.'/metadata/SearchFields.php'); |
312 | 312 | } |
313 | 313 | $this->searchdefs[$this->module]['templateMeta']['maxColumns'] = 2; |
@@ -319,23 +319,23 @@ discard block |
||
319 | 319 | |
320 | 320 | $lv = new ListViewSmarty(); |
321 | 321 | $displayColumns = array(); |
322 | - if(!empty($_REQUEST['displayColumns'])) { |
|
323 | - foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) { |
|
324 | - if(!empty($listViewDefs[$this->module][$col])) |
|
322 | + if (!empty($_REQUEST['displayColumns'])) { |
|
323 | + foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) { |
|
324 | + if (!empty($listViewDefs[$this->module][$col])) |
|
325 | 325 | $displayColumns[$col] = $this->listviewdefs[$this->module][$col]; |
326 | 326 | } |
327 | 327 | } |
328 | 328 | else { |
329 | - foreach($this->listviewdefs[$this->module] as $col => $para) { |
|
330 | - if(!empty($para['default']) && $para['default']) |
|
329 | + foreach ($this->listviewdefs[$this->module] as $col => $para) { |
|
330 | + if (!empty($para['default']) && $para['default']) |
|
331 | 331 | $displayColumns[$col] = $para; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | $params['massupdate'] = true; |
335 | - if(!empty($_REQUEST['orderBy'])) { |
|
335 | + if (!empty($_REQUEST['orderBy'])) { |
|
336 | 336 | $params['orderBy'] = $_REQUEST['orderBy']; |
337 | 337 | $params['overrideOrder'] = true; |
338 | - if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
338 | + if (!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | $lv->displayColumns = $displayColumns; |
@@ -350,27 +350,27 @@ discard block |
||
350 | 350 | |
351 | 351 | $this->should_process = true; |
352 | 352 | |
353 | - if(isset($params['export'])) { |
|
353 | + if (isset($params['export'])) { |
|
354 | 354 | $this->export = $params['export']; |
355 | 355 | } |
356 | - if(!empty($params['multiSelectPopup'])) { |
|
356 | + if (!empty($params['multiSelectPopup'])) { |
|
357 | 357 | $this->multi_select_popup = $params['multiSelectPopup']; |
358 | 358 | } |
359 | - if(!empty($params['massupdate']) && $params['massupdate'] != false) { |
|
359 | + if (!empty($params['massupdate']) && $params['massupdate'] != false) { |
|
360 | 360 | $this->show_mass_update_form = true; |
361 | 361 | $this->mass = new MassUpdate(); |
362 | 362 | $this->mass->setSugarBean($this->seed); |
363 | - if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) { |
|
363 | + if (!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) { |
|
364 | 364 | $this->mass->handleMassUpdate(); |
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | 368 | // create filter fields based off of display columns |
369 | - if(empty($this->filter_fields) || $this->mergeDisplayColumns) { |
|
370 | - foreach($this->displayColumns as $columnName => $def) { |
|
369 | + if (empty($this->filter_fields) || $this->mergeDisplayColumns) { |
|
370 | + foreach ($this->displayColumns as $columnName => $def) { |
|
371 | 371 | $this->filter_fields[strtolower($columnName)] = true; |
372 | - if(!empty($def['related_fields'])) { |
|
373 | - foreach($def['related_fields'] as $field) { |
|
372 | + if (!empty($def['related_fields'])) { |
|
373 | + foreach ($def['related_fields'] as $field) { |
|
374 | 374 | //id column is added by query construction function. This addition creates duplicates |
375 | 375 | //and causes issues in oracle. #10165 |
376 | 376 | if ($field != 'id') { |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) { |
382 | - foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){ |
|
383 | - if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)]) |
|
382 | + foreach ($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field) { |
|
383 | + if (!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)]) |
|
384 | 384 | { |
385 | 385 | $this->filter_fields[strtolower($field)] = true; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | } |
389 | 389 | } |
390 | - foreach ($this->searchColumns as $columnName => $def ) |
|
390 | + foreach ($this->searchColumns as $columnName => $def) |
|
391 | 391 | { |
392 | 392 | $this->filter_fields[strtolower($columnName)] = true; |
393 | 393 | } |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | * By default bean's create_new_list_query function loads fields displayed on the page or used in the search |
404 | 404 | * add fields used to populate forms from _viewdefs :: field_to_name_array to retrive from db |
405 | 405 | */ |
406 | - if ( isset($_REQUEST['field_to_name']) && $_REQUEST['field_to_name'] ) |
|
406 | + if (isset($_REQUEST['field_to_name']) && $_REQUEST['field_to_name']) |
|
407 | 407 | { |
408 | 408 | $_REQUEST['field_to_name'] = is_array($_REQUEST['field_to_name']) ? $_REQUEST['field_to_name'] : array($_REQUEST['field_to_name']); |
409 | - foreach ( $_REQUEST['field_to_name'] as $add_field ) |
|
409 | + foreach ($_REQUEST['field_to_name'] as $add_field) |
|
410 | 410 | { |
411 | 411 | $add_field = strtolower($add_field); |
412 | - if ( $add_field != 'id' && !isset($this->filter_fields[$add_field]) && isset($this->seed->field_defs[$add_field]) ) |
|
412 | + if ($add_field != 'id' && !isset($this->filter_fields[$add_field]) && isset($this->seed->field_defs[$add_field])) |
|
413 | 413 | { |
414 | 414 | $this->filter_fields[$add_field] = true; |
415 | 415 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | 'pageData'=>array( |
428 | 428 | 'bean'=>array('moduleDir'=>$this->seed->module_dir), |
429 | 429 | 'ordering'=>'', |
430 | - 'offsets'=>array('total'=>0,'next'=>0,'current'=>0), |
|
430 | + 'offsets'=>array('total'=>0, 'next'=>0, 'current'=>0), |
|
431 | 431 | ), |
432 | 432 | ); |
433 | 433 | } |
@@ -447,13 +447,13 @@ discard block |
||
447 | 447 | |
448 | 448 | // Bug 43452 - FG - Changed the way generated Where array is imploded into the string. |
449 | 449 | // Now it's imploding in the same way view.list.php do. |
450 | - if (count($where_clauses) > 0 ) { |
|
451 | - $where = '( ' . implode(' and ', $where_clauses) . ' )'; |
|
450 | + if (count($where_clauses) > 0) { |
|
451 | + $where = '( '.implode(' and ', $where_clauses).' )'; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | // Need to include the default whereStatement |
455 | - if(!empty($this->_popupMeta['whereStatement'])){ |
|
456 | - if(!empty($where))$where .= ' AND '; |
|
455 | + if (!empty($this->_popupMeta['whereStatement'])) { |
|
456 | + if (!empty($where))$where .= ' AND '; |
|
457 | 457 | $where .= $this->_popupMeta['whereStatement']; |
458 | 458 | } |
459 | 459 | |
@@ -463,48 +463,48 @@ discard block |
||
463 | 463 | /* |
464 | 464 | * Generate the data for the search form on the header of the Popup. |
465 | 465 | */ |
466 | - function _build_field_defs(){ |
|
466 | + function _build_field_defs() { |
|
467 | 467 | $this->formData = array(); |
468 | 468 | $this->customFieldDefs = array(); |
469 | - foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){ |
|
470 | - if(is_array($data)){ |
|
469 | + foreach ($this->searchdefs[$this->module]['layout']['advanced_search'] as $data) { |
|
470 | + if (is_array($data)) { |
|
471 | 471 | |
472 | 472 | $this->formData[] = array('field' => $data); |
473 | 473 | $value = ''; |
474 | - $this->customFieldDefs[$data['name']]= $data; |
|
475 | - if(!empty($_REQUEST[$data['name']])) |
|
474 | + $this->customFieldDefs[$data['name']] = $data; |
|
475 | + if (!empty($_REQUEST[$data['name']])) |
|
476 | 476 | $value = $_REQUEST[$data['name']]; |
477 | 477 | $this->customFieldDefs[$data['name']]['value'] = $value; |
478 | - }else |
|
478 | + } else |
|
479 | 479 | $this->formData[] = array('field' => array('name'=>$data)); |
480 | 480 | } |
481 | 481 | $this->fieldDefs = array(); |
482 | - if($this->seed){ |
|
482 | + if ($this->seed) { |
|
483 | 483 | $this->seed->fill_in_additional_detail_fields(); |
484 | 484 | |
485 | - foreach($this->seed->toArray() as $name => $value) { |
|
485 | + foreach ($this->seed->toArray() as $name => $value) { |
|
486 | 486 | $this->fieldDefs[$name] = $this->seed->field_defs[$name]; |
487 | 487 | //if we have a relate type then reset to name so that we end up with a textbox |
488 | 488 | //rather than a select button |
489 | 489 | $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name']; |
490 | - if($this->fieldDefs[$name]['type'] == 'relate') |
|
490 | + if ($this->fieldDefs[$name]['type'] == 'relate') |
|
491 | 491 | $this->fieldDefs[$name]['type'] = 'name'; |
492 | - if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) { |
|
492 | + if (isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) { |
|
493 | 493 | $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums |
494 | 494 | } |
495 | - if(!empty($_REQUEST[$name])) |
|
495 | + if (!empty($_REQUEST[$name])) |
|
496 | 496 | $value = $_REQUEST[$name]; |
497 | 497 | $this->fieldDefs[$name]['value'] = $value; |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - function _getAddForm(){ |
|
502 | + function _getAddForm() { |
|
503 | 503 | $addform = ''; |
504 | - if(!$this->seed->ACLAccess('save')){ |
|
504 | + if (!$this->seed->ACLAccess('save')) { |
|
505 | 505 | return; |
506 | 506 | } |
507 | - if(!empty($this->_popupMeta['create'])){ |
|
507 | + if (!empty($this->_popupMeta['create'])) { |
|
508 | 508 | $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
509 | 509 | |
510 | 510 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
529 | - function _getAddFormHeader(){ |
|
529 | + function _getAddFormHeader() { |
|
530 | 530 | $lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE']; |
531 | 531 | $lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY']; |
532 | 532 | $lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL']; |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | <input type="hidden" name="return_action" value="Popup"> |
540 | 540 | EOQ; |
541 | 541 | // if metadata contains custom inputs for the quickcreate |
542 | - if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) { |
|
543 | - foreach($this->_popupMeta['customInput'] as $key => $value) |
|
544 | - $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n'; |
|
542 | + if (!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) { |
|
543 | + foreach ($this->_popupMeta['customInput'] as $key => $value) |
|
544 | + $formSave .= '<input type="hidden" name="'.$key.'" value="'.$value.'">\n'; |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | return $addformheader; |
550 | 550 | } |
551 | 551 | |
552 | - function getQuickCreate(){ |
|
552 | + function getQuickCreate() { |
|
553 | 553 | require_once("include/EditView/PopupQuickCreate.php"); |
554 | 554 | $qc = new PopupQuickCreate($this->module); |
555 | 555 | return $qc->process($this->module); |
@@ -1,5 +1,5 @@ discard block |
||
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. |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | EOQ; |
63 | 63 | |
64 | 64 | $cacheDir = create_cache_directory('jsLanguage/'); |
65 | - if($fh = @sugar_fopen($cacheDir . $lang . '.js', "w")){ |
|
65 | + if ($fh = @sugar_fopen($cacheDir.$lang.'.js', "w")) { |
|
66 | 66 | fputs($fh, $str); |
67 | 67 | fclose($fh); |
68 | 68 | } |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | // cn: bug 8242 - non-US langpack chokes |
75 | 75 | $mod_strings = return_module_language($lang, $moduleDir); |
76 | 76 | $mod_strings_encoded = $json->encode($mod_strings); |
77 | - $str = "SUGAR.language.setLanguage('" . $moduleDir . "', " . $mod_strings_encoded . ");"; |
|
77 | + $str = "SUGAR.language.setLanguage('".$moduleDir."', ".$mod_strings_encoded.");"; |
|
78 | 78 | |
79 | - $cacheDir = create_cache_directory('jsLanguage/' . $moduleDir . '/'); |
|
79 | + $cacheDir = create_cache_directory('jsLanguage/'.$moduleDir.'/'); |
|
80 | 80 | |
81 | - if($fh = @fopen($cacheDir . $lang . '.js', "w")){ |
|
81 | + if ($fh = @fopen($cacheDir.$lang.'.js', "w")) { |
|
82 | 82 | fputs($fh, $str); |
83 | 83 | fclose($fh); |
84 | 84 | } |
85 | 85 | |
86 | - if($return) { |
|
86 | + if ($return) { |
|
87 | 87 | return $str; |
88 | 88 | } |
89 | 89 | } |
@@ -1,5 +1,7 @@ |
||
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. |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | if(empty($_REQUEST['module'])) |
48 | 48 | { |
49 | - die("'module' was not defined"); |
|
49 | + die("'module' was not defined"); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | if(!isset($beanList[$_REQUEST['module']])) |
53 | 53 | { |
54 | - die("'".$_REQUEST['module']."' is not defined in \$beanList"); |
|
54 | + die("'".$_REQUEST['module']."' is not defined in \$beanList"); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | if (!isset($_REQUEST['subpanel'])) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | include('include/SubPanel/SubPanel.php'); |
68 | 68 | $layout_def_key = ''; |
69 | 69 | if(!empty($_REQUEST['layout_def_key'])){ |
70 | - $layout_def_key = $_REQUEST['layout_def_key']; |
|
70 | + $layout_def_key = $_REQUEST['layout_def_key']; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $subpanel_object = new CustomSubPanel($module, $record, $subpanel,null, $layout_def_key, $collection); |
@@ -1,5 +1,5 @@ discard block |
||
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. |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39 | 39 | ********************************************************************************/ |
40 | 40 | |
41 | -ini_set('display_errors',1); |
|
41 | +ini_set('display_errors', 1); |
|
42 | 42 | |
43 | 43 | global $beanList; |
44 | 44 | global $beanFiles; |
45 | 45 | |
46 | 46 | |
47 | -if(empty($_REQUEST['module'])) |
|
47 | +if (empty($_REQUEST['module'])) |
|
48 | 48 | { |
49 | 49 | die("'module' was not defined"); |
50 | 50 | } |
51 | 51 | |
52 | -if(!isset($beanList[$_REQUEST['module']])) |
|
52 | +if (!isset($beanList[$_REQUEST['module']])) |
|
53 | 53 | { |
54 | 54 | die("'".$_REQUEST['module']."' is not defined in \$beanList"); |
55 | 55 | } |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | |
67 | 67 | include('include/SubPanel/SubPanel.php'); |
68 | 68 | $layout_def_key = ''; |
69 | -if(!empty($_REQUEST['layout_def_key'])){ |
|
69 | +if (!empty($_REQUEST['layout_def_key'])) { |
|
70 | 70 | $layout_def_key = $_REQUEST['layout_def_key']; |
71 | 71 | } |
72 | 72 | |
73 | -$subpanel_object = new CustomSubPanel($module, $record, $subpanel,null, $layout_def_key, $collection); |
|
73 | +$subpanel_object = new CustomSubPanel($module, $record, $subpanel, null, $layout_def_key, $collection); |
|
74 | 74 | |
75 | 75 | echo $subpanel_object->getSearchForm(); |
76 | 76 |
@@ -1,5 +1,7 @@ |
||
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. |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (! defined ( 'sugarEntry' ) || ! sugarEntry) { |
|
3 | + die ( 'Not A Valid Entry Point' ) ; |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -85,7 +87,9 @@ discard block |
||
85 | 87 | |
86 | 88 | $this->_instance_properties = $instance_properties ; |
87 | 89 | |
88 | - if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ]; |
|
90 | + if(isset($instance_properties['collection_list' ])) { |
|
91 | + $this->base_collection_list = $instance_properties['collection_list' ]; |
|
92 | + } |
|
89 | 93 | |
90 | 94 | if(!empty($collections) && isset($instance_properties['collection_list' ])){ |
91 | 95 | foreach($instance_properties['collection_list' ] as $cname => $value){ |
@@ -277,7 +281,9 @@ discard block |
||
277 | 281 | } |
278 | 282 | } |
279 | 283 | // if it's empty just dump out as there is nothing to process. |
280 | - if(empty($this->sub_subpanels)) return false; |
|
284 | + if(empty($this->sub_subpanels)) { |
|
285 | + return false; |
|
286 | + } |
|
281 | 287 | //Sync displayed list fields across the subpanels |
282 | 288 | $display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels); |
283 | 289 | $query_fields = array(); |
@@ -291,10 +297,11 @@ discard block |
||
291 | 297 | if (isset($def['vname']) && isset($def['width'])) |
292 | 298 | { |
293 | 299 | $index++; |
294 | - if(!empty($def['alias'])) |
|
295 | - $listFieldMap[$key][$def['alias']] = $field; |
|
296 | - else |
|
297 | - $listFieldMap[$key][$field] = $field; |
|
300 | + if(!empty($def['alias'])) { |
|
301 | + $listFieldMap[$key][$def['alias']] = $field; |
|
302 | + } else { |
|
303 | + $listFieldMap[$key][$field] = $field; |
|
304 | + } |
|
298 | 305 | if (!isset($display_fields[$def['vname']])) |
299 | 306 | { |
300 | 307 | if(sizeof($display_fields) > $index) |
@@ -332,13 +339,11 @@ discard block |
||
332 | 339 | if (isset($subpanel->panel_definition['list_fields'][$field])) |
333 | 340 | { |
334 | 341 | $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field]; |
335 | - } |
|
336 | - else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key])) |
|
342 | + } else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key])) |
|
337 | 343 | { |
338 | 344 | $list_fields[$list_key] = $subpanel->panel_definition['list_fields'][$list_key]; |
339 | 345 | |
340 | - } |
|
341 | - else { |
|
346 | + } else { |
|
342 | 347 | $list_fields[$field] = $display_fields[$vname]; |
343 | 348 | } |
344 | 349 | } |
@@ -347,8 +352,7 @@ discard block |
||
347 | 352 | if (isset($subpanel->panel_definition['list_fields'][$field])) |
348 | 353 | { |
349 | 354 | $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field]; |
350 | - } |
|
351 | - else { |
|
355 | + } else { |
|
352 | 356 | $list_fields[$field] = $def; |
353 | 357 | } |
354 | 358 | } |
@@ -624,18 +628,22 @@ discard block |
||
624 | 628 | global $modListHeader ; |
625 | 629 | global $modules_exempt_from_availability_check ; |
626 | 630 | |
627 | - if (isset ( $this->_visible_tabs_array )) |
|
628 | - return $this->_visible_tabs_array ; |
|
631 | + if (isset ( $this->_visible_tabs_array )) { |
|
632 | + return $this->_visible_tabs_array ; |
|
633 | + } |
|
629 | 634 | |
630 | - if (empty($modListHeader)) |
|
631 | - $modListHeader = query_module_access_list($GLOBALS['current_user']); |
|
635 | + if (empty($modListHeader)) { |
|
636 | + $modListHeader = query_module_access_list($GLOBALS['current_user']); |
|
637 | + } |
|
632 | 638 | |
633 | 639 | $this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort |
634 | 640 | |
635 | - if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first |
|
641 | + if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) { |
|
642 | + // bug 17434 - belts-and-braces - check that we have some subpanels first |
|
636 | 643 | { |
637 | 644 | //retrieve list of hidden subpanels |
638 | 645 | $hidden_panels = $this->get_hidden_subpanels(); |
646 | + } |
|
639 | 647 | |
640 | 648 | //activities is a special use case in that if it is hidden, |
641 | 649 | //then the history tab should be hidden too. |
@@ -648,8 +656,9 @@ discard block |
||
648 | 656 | { |
649 | 657 | //exclude if this subpanel is hidden from admin screens |
650 | 658 | $module = $key; |
651 | - if ( isset($values_array['module']) ) |
|
652 | - $module = strtolower($values_array['module']); |
|
659 | + if ( isset($values_array['module']) ) { |
|
660 | + $module = strtolower($values_array['module']); |
|
661 | + } |
|
653 | 662 | if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){ |
654 | 663 | //this panel is hidden, skip it |
655 | 664 | continue; |
@@ -696,8 +705,9 @@ discard block |
||
696 | 705 | */ |
697 | 706 | function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() ) |
698 | 707 | { |
699 | - if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ])) |
|
700 | - return false; |
|
708 | + if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ])) { |
|
709 | + return false; |
|
710 | + } |
|
701 | 711 | |
702 | 712 | $subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ; |
703 | 713 | |
@@ -720,16 +730,19 @@ discard block |
||
720 | 730 | |
721 | 731 | if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] ))) |
722 | 732 | { |
723 | - if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' )) |
|
724 | - require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ; |
|
733 | + if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' )) { |
|
734 | + require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ; |
|
735 | + } |
|
725 | 736 | |
726 | - if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' )) |
|
727 | - require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ; |
|
737 | + if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' )) { |
|
738 | + require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ; |
|
739 | + } |
|
728 | 740 | |
729 | - if (! empty ( $layout_def_key )) |
|
730 | - $this->layout_defs = $layout_defs [ $layout_def_key ] ; |
|
731 | - else |
|
732 | - $this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ; |
|
741 | + if (! empty ( $layout_def_key )) { |
|
742 | + $this->layout_defs = $layout_defs [ $layout_def_key ] ; |
|
743 | + } else { |
|
744 | + $this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ; |
|
745 | + } |
|
733 | 746 | |
734 | 747 | } |
735 | 748 | |
@@ -785,11 +798,15 @@ discard block |
||
785 | 798 | foreach($modules_to_check as $mod_name){ |
786 | 799 | |
787 | 800 | //skip if module name is not in bean list, otherwise get the bean class name |
788 | - if(!isset($beanList[$mod_name])) continue; |
|
801 | + if(!isset($beanList[$mod_name])) { |
|
802 | + continue; |
|
803 | + } |
|
789 | 804 | $class = $beanList[$mod_name]; |
790 | 805 | |
791 | 806 | //skip if class name is not in file list, otherwise require the bean file and create new class |
792 | - if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue; |
|
807 | + if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) { |
|
808 | + continue; |
|
809 | + } |
|
793 | 810 | |
794 | 811 | //retrieve subpanels for this bean |
795 | 812 | require_once($beanFiles[$class]); |
@@ -803,15 +820,20 @@ discard block |
||
803 | 820 | foreach( $sub_tabs as $panel_key){ |
804 | 821 | $panel_key = strtolower($panel_key); |
805 | 822 | $panel_module = $panel_key; |
806 | - if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) ) |
|
807 | - $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']); |
|
823 | + if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) ) { |
|
824 | + $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']); |
|
825 | + } |
|
808 | 826 | //if module_only flag is set, only if it is also in module array |
809 | - if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue; |
|
827 | + if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) { |
|
828 | + continue; |
|
829 | + } |
|
810 | 830 | $panel_key_name = $panel_module; |
811 | 831 | |
812 | 832 | //group_by_key_name is set to true, then array will hold an entry for each |
813 | 833 | //subpanel, with the module name prepended in the key |
814 | - if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name; |
|
834 | + if($group_by_module) { |
|
835 | + $panel_key_name = $class.'_'.$panel_key_name; |
|
836 | + } |
|
815 | 837 | //add panel name to subpanel array |
816 | 838 | $spd_arr[$panel_key_name] = $panel_module; |
817 | 839 | } |
@@ -864,12 +886,11 @@ discard block |
||
864 | 886 | } |
865 | 887 | |
866 | 888 | |
867 | - }else{ |
|
889 | + } else{ |
|
868 | 890 | //no settings found, return empty |
869 | 891 | return $hidden_subpanels; |
870 | 892 | } |
871 | - } |
|
872 | - else |
|
893 | + } else |
|
873 | 894 | { //no settings found, return empty |
874 | 895 | return $hidden_subpanels; |
875 | 896 | } |
@@ -417,11 +417,19 @@ |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | //get value of a property defined at the panel instance level. |
420 | + |
|
421 | + /** |
|
422 | + * @param string $name |
|
423 | + */ |
|
420 | 424 | function get_inst_prop_value ( $name ) |
421 | 425 | { |
422 | 426 | return isset($this->_instance_properties[$name]) ? $this->_instance_properties [ $name ] : null; |
423 | 427 | } |
424 | 428 | //get value of a property defined at the panel definition level. |
429 | + |
|
430 | + /** |
|
431 | + * @param string $name |
|
432 | + */ |
|
425 | 433 | function get_def_prop_value ( $name ) |
426 | 434 | { |
427 | 435 | if (isset ( $this->panel_definition [ $name ] )) |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | class aSubPanel |
55 | 55 | { |
56 | 56 | |
57 | - var $name ; |
|
58 | - var $_instance_properties ; |
|
57 | + var $name ; |
|
58 | + var $_instance_properties ; |
|
59 | 59 | |
60 | - var $mod_strings ; |
|
61 | - var $panel_definition ; |
|
62 | - var $sub_subpanels ; |
|
63 | - var $parent_bean ; |
|
60 | + var $mod_strings ; |
|
61 | + var $panel_definition ; |
|
62 | + var $sub_subpanels ; |
|
63 | + var $parent_bean ; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Can we display this subpanel? |
@@ -72,80 +72,80 @@ discard block |
||
72 | 72 | */ |
73 | 73 | var $canDisplay = true; |
74 | 74 | |
75 | - //module's table name and column fields. |
|
76 | - var $table_name ; |
|
77 | - var $db_fields ; |
|
78 | - var $bean_name ; |
|
79 | - var $template_instance ; |
|
80 | - |
|
81 | - var $search_query; |
|
82 | - var $base_collection_list = array(); |
|
83 | - |
|
84 | - function __construct ($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){ |
|
85 | - |
|
86 | - $this->_instance_properties = $instance_properties ; |
|
87 | - |
|
88 | - if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ]; |
|
89 | - |
|
90 | - if(!empty($collections) && isset($instance_properties['collection_list' ])){ |
|
91 | - foreach($instance_properties['collection_list' ] as $cname => $value){ |
|
92 | - if(!in_array($value['module'], $collections)){ |
|
93 | - unset($instance_properties['collection_list'][$cname]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - if (!$this->isCollection()){ |
|
98 | - $table = strtolower($instance_properties['module']); |
|
99 | - $search_query = str_replace('meetings',$table,$search_query); |
|
100 | - } |
|
101 | - |
|
102 | - $this->search_query = $search_query; |
|
103 | - $this->name = $name ; |
|
104 | - $this->parent_bean = $parent_bean ; |
|
105 | - |
|
106 | - //set language |
|
107 | - global $current_language ; |
|
108 | - if (! isset ( $parent_bean->mbvardefs )) |
|
109 | - { |
|
110 | - $mod_strings = return_module_language ( $current_language, $parent_bean->module_dir ) ; |
|
111 | - } |
|
112 | - $this->mod_strings = $mod_strings ; |
|
75 | + //module's table name and column fields. |
|
76 | + var $table_name ; |
|
77 | + var $db_fields ; |
|
78 | + var $bean_name ; |
|
79 | + var $template_instance ; |
|
80 | + |
|
81 | + var $search_query; |
|
82 | + var $base_collection_list = array(); |
|
83 | + |
|
84 | + function __construct ($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){ |
|
85 | + |
|
86 | + $this->_instance_properties = $instance_properties ; |
|
87 | + |
|
88 | + if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ]; |
|
89 | + |
|
90 | + if(!empty($collections) && isset($instance_properties['collection_list' ])){ |
|
91 | + foreach($instance_properties['collection_list' ] as $cname => $value){ |
|
92 | + if(!in_array($value['module'], $collections)){ |
|
93 | + unset($instance_properties['collection_list'][$cname]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + if (!$this->isCollection()){ |
|
98 | + $table = strtolower($instance_properties['module']); |
|
99 | + $search_query = str_replace('meetings',$table,$search_query); |
|
100 | + } |
|
101 | + |
|
102 | + $this->search_query = $search_query; |
|
103 | + $this->name = $name ; |
|
104 | + $this->parent_bean = $parent_bean ; |
|
105 | + |
|
106 | + //set language |
|
107 | + global $current_language ; |
|
108 | + if (! isset ( $parent_bean->mbvardefs )) |
|
109 | + { |
|
110 | + $mod_strings = return_module_language ( $current_language, $parent_bean->module_dir ) ; |
|
111 | + } |
|
112 | + $this->mod_strings = $mod_strings ; |
|
113 | 113 | |
114 | 114 | if ($this->isCollection ()) |
115 | - { |
|
116 | - $this->canDisplay = $this->load_sub_subpanels () ; //load sub-panel definition. |
|
117 | - } else |
|
118 | - { |
|
119 | - if (!is_dir('modules/' . $this->_instance_properties [ 'module' ])){ |
|
120 | - _pstack_trace(); |
|
121 | - } |
|
122 | - $def_path = 'modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'subpanel_name' ] . '.php' ; |
|
123 | - |
|
124 | - $orig_exists = is_file($def_path); |
|
125 | - $loaded = false; |
|
126 | - if ($orig_exists) |
|
127 | - { |
|
128 | - require ($def_path); |
|
129 | - $loaded = true; |
|
130 | - } |
|
131 | - if (is_file("custom/$def_path") && (!$original_only || !$orig_exists)) |
|
132 | - { |
|
133 | - require ("custom/$def_path"); |
|
134 | - $loaded = true; |
|
135 | - } |
|
136 | - |
|
137 | - if (! $original_only && isset ( $this->_instance_properties [ 'override_subpanel_name' ] ) && file_exists ( 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' )) |
|
138 | - { |
|
139 | - $cust_def_path = 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ; |
|
140 | - require ($cust_def_path) ; |
|
141 | - $loaded = true; |
|
142 | - } |
|
143 | - |
|
144 | - if (!$loaded) |
|
145 | - { |
|
146 | - $GLOBALS['log']->fatal("Failed to load original or custom subpanel data for $name in $def_path"); |
|
115 | + { |
|
116 | + $this->canDisplay = $this->load_sub_subpanels () ; //load sub-panel definition. |
|
117 | + } else |
|
118 | + { |
|
119 | + if (!is_dir('modules/' . $this->_instance_properties [ 'module' ])){ |
|
120 | + _pstack_trace(); |
|
121 | + } |
|
122 | + $def_path = 'modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'subpanel_name' ] . '.php' ; |
|
123 | + |
|
124 | + $orig_exists = is_file($def_path); |
|
125 | + $loaded = false; |
|
126 | + if ($orig_exists) |
|
127 | + { |
|
128 | + require ($def_path); |
|
129 | + $loaded = true; |
|
130 | + } |
|
131 | + if (is_file("custom/$def_path") && (!$original_only || !$orig_exists)) |
|
132 | + { |
|
133 | + require ("custom/$def_path"); |
|
134 | + $loaded = true; |
|
135 | + } |
|
136 | + |
|
137 | + if (! $original_only && isset ( $this->_instance_properties [ 'override_subpanel_name' ] ) && file_exists ( 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' )) |
|
138 | + { |
|
139 | + $cust_def_path = 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ; |
|
140 | + require ($cust_def_path) ; |
|
141 | + $loaded = true; |
|
142 | + } |
|
143 | + |
|
144 | + if (!$loaded) |
|
145 | + { |
|
146 | + $GLOBALS['log']->fatal("Failed to load original or custom subpanel data for $name in $def_path"); |
|
147 | 147 | $this->canDisplay = false; |
148 | - } |
|
148 | + } |
|
149 | 149 | |
150 | 150 | // load module info from the module's bean file |
151 | 151 | $this->load_module_info(); |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | if (isset($subpanel_layout) && is_array($subpanel_layout)) { |
157 | 157 | $this->set_panel_definition($subpanel_layout); |
158 | 158 | |
159 | - } |
|
160 | - } |
|
159 | + } |
|
160 | + } |
|
161 | 161 | |
162 | - } |
|
162 | + } |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * is the sub panel default hidden? |
@@ -176,64 +176,64 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | |
179 | - function distinct_query () |
|
180 | - { |
|
181 | - if (isset ( $this->_instance_properties [ 'get_distinct_data' ] )) |
|
182 | - { |
|
183 | - return !empty($this->_instance_properties['get_distinct_data']) ? true : false; |
|
184 | - } |
|
185 | - return false ; |
|
186 | - } |
|
187 | - |
|
188 | - //return the translated header value. |
|
189 | - function get_title () |
|
190 | - { |
|
191 | - if (empty ( $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] )) |
|
192 | - { |
|
193 | - return translate ( $this->_instance_properties [ 'title_key' ], $this->_instance_properties [ 'module' ] ) ; |
|
194 | - } |
|
195 | - return $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ; |
|
196 | - } |
|
197 | - |
|
198 | - //return the definition of buttons. looks for buttons in 2 locations. |
|
199 | - function get_buttons () |
|
200 | - { |
|
201 | - $buttons = array ( ) ; |
|
202 | - if (isset ( $this->_instance_properties [ 'top_buttons' ] )) |
|
203 | - { |
|
204 | - //this will happen only in the case of sub-panels with multiple sources(activities). |
|
205 | - $buttons = $this->_instance_properties [ 'top_buttons' ] ; |
|
206 | - } else |
|
207 | - { |
|
208 | - $buttons = $this->panel_definition [ 'top_buttons' ] ; |
|
209 | - } |
|
210 | - |
|
211 | - // permissions. hide SubPanelTopComposeEmailButton from activities if email module is disabled. |
|
212 | - //only email is being tested becuase other submodules in activites/history such as notes, tasks, meetings and calls cannot be disabled. |
|
213 | - //as of today these are the only 2 sub-panels that use the union clause. |
|
214 | - $mod_name = $this->get_module_name () ; |
|
215 | - if ($mod_name == 'Activities' || $mod_name == 'History') |
|
216 | - { |
|
217 | - global $modListHeader ; |
|
218 | - global $modules_exempt_from_availability_check ; |
|
219 | - if (isset ( $modListHeader ) && (! (array_key_exists ( 'Emails', $modListHeader ) or array_key_exists ( 'Emails', $modules_exempt_from_availability_check )))) |
|
220 | - { |
|
221 | - foreach ( $buttons as $key => $button ) |
|
222 | - { |
|
223 | - foreach ( $button as $property => $value ) |
|
224 | - { |
|
225 | - if ($value === 'SubPanelTopComposeEmailButton' || $value === 'SubPanelTopArchiveEmailButton') |
|
226 | - { |
|
227 | - //remove this button from the array. |
|
228 | - unset ( $buttons [ $key ] ) ; |
|
229 | - } |
|
230 | - } |
|
231 | - } |
|
232 | - } |
|
233 | - } |
|
234 | - |
|
235 | - return $buttons ; |
|
236 | - } |
|
179 | + function distinct_query () |
|
180 | + { |
|
181 | + if (isset ( $this->_instance_properties [ 'get_distinct_data' ] )) |
|
182 | + { |
|
183 | + return !empty($this->_instance_properties['get_distinct_data']) ? true : false; |
|
184 | + } |
|
185 | + return false ; |
|
186 | + } |
|
187 | + |
|
188 | + //return the translated header value. |
|
189 | + function get_title () |
|
190 | + { |
|
191 | + if (empty ( $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] )) |
|
192 | + { |
|
193 | + return translate ( $this->_instance_properties [ 'title_key' ], $this->_instance_properties [ 'module' ] ) ; |
|
194 | + } |
|
195 | + return $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ; |
|
196 | + } |
|
197 | + |
|
198 | + //return the definition of buttons. looks for buttons in 2 locations. |
|
199 | + function get_buttons () |
|
200 | + { |
|
201 | + $buttons = array ( ) ; |
|
202 | + if (isset ( $this->_instance_properties [ 'top_buttons' ] )) |
|
203 | + { |
|
204 | + //this will happen only in the case of sub-panels with multiple sources(activities). |
|
205 | + $buttons = $this->_instance_properties [ 'top_buttons' ] ; |
|
206 | + } else |
|
207 | + { |
|
208 | + $buttons = $this->panel_definition [ 'top_buttons' ] ; |
|
209 | + } |
|
210 | + |
|
211 | + // permissions. hide SubPanelTopComposeEmailButton from activities if email module is disabled. |
|
212 | + //only email is being tested becuase other submodules in activites/history such as notes, tasks, meetings and calls cannot be disabled. |
|
213 | + //as of today these are the only 2 sub-panels that use the union clause. |
|
214 | + $mod_name = $this->get_module_name () ; |
|
215 | + if ($mod_name == 'Activities' || $mod_name == 'History') |
|
216 | + { |
|
217 | + global $modListHeader ; |
|
218 | + global $modules_exempt_from_availability_check ; |
|
219 | + if (isset ( $modListHeader ) && (! (array_key_exists ( 'Emails', $modListHeader ) or array_key_exists ( 'Emails', $modules_exempt_from_availability_check )))) |
|
220 | + { |
|
221 | + foreach ( $buttons as $key => $button ) |
|
222 | + { |
|
223 | + foreach ( $button as $property => $value ) |
|
224 | + { |
|
225 | + if ($value === 'SubPanelTopComposeEmailButton' || $value === 'SubPanelTopArchiveEmailButton') |
|
226 | + { |
|
227 | + //remove this button from the array. |
|
228 | + unset ( $buttons [ $key ] ) ; |
|
229 | + } |
|
230 | + } |
|
231 | + } |
|
232 | + } |
|
233 | + } |
|
234 | + |
|
235 | + return $buttons ; |
|
236 | + } |
|
237 | 237 | |
238 | 238 | |
239 | 239 | /** |
@@ -244,327 +244,327 @@ discard block |
||
244 | 244 | * @return bool True by default if the subpanel was loaded. Will return false if none in the collection are |
245 | 245 | * allowed by the current user. |
246 | 246 | */ |
247 | - function load_sub_subpanels () |
|
248 | - { |
|
249 | - |
|
250 | - global $modListHeader ; |
|
251 | - // added a check for security of tabs to see if an user has access to them |
|
252 | - // this prevents passing an "unseen" tab to the query string and pulling up its contents |
|
253 | - if (! isset ( $modListHeader )) |
|
254 | - { |
|
255 | - global $current_user ; |
|
256 | - if (isset ( $current_user )) |
|
257 | - { |
|
258 | - $modListHeader = query_module_access_list ( $current_user ) ; |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - //by default all the activities modules are exempt, so hiding them won't affect their appearance unless the 'activity' subpanel itself is hidden. |
|
263 | - //add email to the list temporarily so it is not affected in activities subpanel |
|
264 | - global $modules_exempt_from_availability_check ; |
|
265 | - $modules_exempt_from_availability_check['Emails'] = 'Emails'; |
|
266 | - |
|
267 | - $listFieldMap = array(); |
|
268 | - |
|
269 | - if (empty ( $this->sub_subpanels )) |
|
270 | - { |
|
271 | - $panels = $this->get_inst_prop_value ( 'collection_list' ) ; |
|
272 | - foreach ( $panels as $panel => $properties ) |
|
273 | - { |
|
274 | - if (array_key_exists ( $properties [ 'module' ], $modListHeader ) or array_key_exists ( $properties [ 'module' ], $modules_exempt_from_availability_check )) |
|
275 | - { |
|
276 | - $this->sub_subpanels [ $panel ] = new aSubPanel ( $panel, $properties, $this->parent_bean, false, false, $this->search_query ) ; |
|
277 | - } |
|
278 | - } |
|
279 | - // if it's empty just dump out as there is nothing to process. |
|
280 | - if(empty($this->sub_subpanels)) return false; |
|
281 | - //Sync displayed list fields across the subpanels |
|
282 | - $display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels); |
|
283 | - $query_fields = array(); |
|
284 | - foreach ( $this->sub_subpanels as $key => $subpanel ) |
|
285 | - { |
|
286 | - $list_fields = $subpanel->get_list_fields(); |
|
287 | - $listFieldMap[$key] = array(); |
|
288 | - $index = 0; |
|
289 | - foreach($list_fields as $field => $def) |
|
290 | - { |
|
291 | - if (isset($def['vname']) && isset($def['width'])) |
|
292 | - { |
|
293 | - $index++; |
|
294 | - if(!empty($def['alias'])) |
|
295 | - $listFieldMap[$key][$def['alias']] = $field; |
|
296 | - else |
|
297 | - $listFieldMap[$key][$field] = $field; |
|
298 | - if (!isset($display_fields[$def['vname']])) |
|
299 | - { |
|
300 | - if(sizeof($display_fields) > $index) |
|
301 | - { |
|
302 | - //Try to insert the new field in an order that makes sense |
|
303 | - $start = array_slice($display_fields, 0, $index); |
|
304 | - $end = array_slice($display_fields, $index); |
|
305 | - $display_fields = array_merge( |
|
306 | - $start, |
|
307 | - array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )), |
|
308 | - $end |
|
309 | - ); |
|
310 | - } else |
|
311 | - { |
|
312 | - $display_fields[$def['vname']] = array( |
|
313 | - 'name' => empty($def['alias']) ? $field : $def['alias'], |
|
314 | - 'vname' => $def['vname'], |
|
315 | - 'width' => $def['width'], |
|
316 | - ); |
|
317 | - } |
|
318 | - } |
|
319 | - } else { |
|
320 | - $query_fields[$field] = $def; |
|
321 | - } |
|
322 | - } |
|
323 | - } |
|
324 | - foreach ( $this->sub_subpanels as $key => $subpanel ) |
|
325 | - { |
|
326 | - $list_fields = array(); |
|
327 | - foreach($display_fields as $vname => $def) |
|
328 | - { |
|
329 | - $field = $def['name']; |
|
330 | - $list_key = isset($listFieldMap[$key][$field]) ? $listFieldMap[$key][$field] : $field; |
|
331 | - |
|
332 | - if (isset($subpanel->panel_definition['list_fields'][$field])) |
|
333 | - { |
|
334 | - $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field]; |
|
335 | - } |
|
336 | - else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key])) |
|
337 | - { |
|
338 | - $list_fields[$list_key] = $subpanel->panel_definition['list_fields'][$list_key]; |
|
339 | - |
|
340 | - } |
|
341 | - else { |
|
342 | - $list_fields[$field] = $display_fields[$vname]; |
|
343 | - } |
|
344 | - } |
|
345 | - foreach($query_fields as $field => $def) |
|
346 | - { |
|
347 | - if (isset($subpanel->panel_definition['list_fields'][$field])) |
|
348 | - { |
|
349 | - $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field]; |
|
350 | - } |
|
351 | - else { |
|
352 | - $list_fields[$field] = $def; |
|
353 | - } |
|
354 | - } |
|
355 | - $subpanel->panel_definition['list_fields'] = $list_fields; |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - return true; |
|
360 | - } |
|
361 | - |
|
362 | - protected function getDisplayFieldsFromCollection($sub_subpanels) |
|
363 | - { |
|
364 | - $display_fields = array(); |
|
365 | - foreach ($sub_subpanels as $key => $subpanel ) |
|
366 | - { |
|
367 | - $list_fields = $subpanel->get_list_fields(); |
|
368 | - $index = 0; |
|
369 | - foreach($list_fields as $field => $def) |
|
370 | - { |
|
371 | - if (isset($def['vname']) && isset($def['width'])) |
|
372 | - { |
|
373 | - $index++; |
|
374 | - if (!isset($display_fields[$def['vname']])) |
|
375 | - { |
|
376 | - if(sizeof($display_fields) > $index) |
|
377 | - { |
|
378 | - //Try to insert the new field in an order that makes sense |
|
379 | - $start = array_slice($display_fields, 0, $index); |
|
380 | - $end = array_slice($display_fields, $index); |
|
381 | - $display_fields = array_merge( |
|
382 | - $start, |
|
383 | - array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )), |
|
384 | - $end |
|
385 | - ); |
|
386 | - } else |
|
387 | - { |
|
388 | - $display_fields[$def['vname']] = array( |
|
389 | - 'name' => $field, |
|
390 | - 'vname' => $def['vname'], |
|
391 | - 'width' => $def['width'], |
|
392 | - ); |
|
393 | - } |
|
394 | - } |
|
395 | - } |
|
396 | - } |
|
397 | - } |
|
398 | - } |
|
399 | - |
|
400 | - function isDatasourceFunction () |
|
401 | - { |
|
402 | - if (strpos ( $this->get_inst_prop_value ( 'get_subpanel_data' ), 'function' ) === false) |
|
403 | - { |
|
404 | - return false ; |
|
405 | - } |
|
406 | - return true ; |
|
407 | - } |
|
247 | + function load_sub_subpanels () |
|
248 | + { |
|
249 | + |
|
250 | + global $modListHeader ; |
|
251 | + // added a check for security of tabs to see if an user has access to them |
|
252 | + // this prevents passing an "unseen" tab to the query string and pulling up its contents |
|
253 | + if (! isset ( $modListHeader )) |
|
254 | + { |
|
255 | + global $current_user ; |
|
256 | + if (isset ( $current_user )) |
|
257 | + { |
|
258 | + $modListHeader = query_module_access_list ( $current_user ) ; |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + //by default all the activities modules are exempt, so hiding them won't affect their appearance unless the 'activity' subpanel itself is hidden. |
|
263 | + //add email to the list temporarily so it is not affected in activities subpanel |
|
264 | + global $modules_exempt_from_availability_check ; |
|
265 | + $modules_exempt_from_availability_check['Emails'] = 'Emails'; |
|
266 | + |
|
267 | + $listFieldMap = array(); |
|
268 | + |
|
269 | + if (empty ( $this->sub_subpanels )) |
|
270 | + { |
|
271 | + $panels = $this->get_inst_prop_value ( 'collection_list' ) ; |
|
272 | + foreach ( $panels as $panel => $properties ) |
|
273 | + { |
|
274 | + if (array_key_exists ( $properties [ 'module' ], $modListHeader ) or array_key_exists ( $properties [ 'module' ], $modules_exempt_from_availability_check )) |
|
275 | + { |
|
276 | + $this->sub_subpanels [ $panel ] = new aSubPanel ( $panel, $properties, $this->parent_bean, false, false, $this->search_query ) ; |
|
277 | + } |
|
278 | + } |
|
279 | + // if it's empty just dump out as there is nothing to process. |
|
280 | + if(empty($this->sub_subpanels)) return false; |
|
281 | + //Sync displayed list fields across the subpanels |
|
282 | + $display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels); |
|
283 | + $query_fields = array(); |
|
284 | + foreach ( $this->sub_subpanels as $key => $subpanel ) |
|
285 | + { |
|
286 | + $list_fields = $subpanel->get_list_fields(); |
|
287 | + $listFieldMap[$key] = array(); |
|
288 | + $index = 0; |
|
289 | + foreach($list_fields as $field => $def) |
|
290 | + { |
|
291 | + if (isset($def['vname']) && isset($def['width'])) |
|
292 | + { |
|
293 | + $index++; |
|
294 | + if(!empty($def['alias'])) |
|
295 | + $listFieldMap[$key][$def['alias']] = $field; |
|
296 | + else |
|
297 | + $listFieldMap[$key][$field] = $field; |
|
298 | + if (!isset($display_fields[$def['vname']])) |
|
299 | + { |
|
300 | + if(sizeof($display_fields) > $index) |
|
301 | + { |
|
302 | + //Try to insert the new field in an order that makes sense |
|
303 | + $start = array_slice($display_fields, 0, $index); |
|
304 | + $end = array_slice($display_fields, $index); |
|
305 | + $display_fields = array_merge( |
|
306 | + $start, |
|
307 | + array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )), |
|
308 | + $end |
|
309 | + ); |
|
310 | + } else |
|
311 | + { |
|
312 | + $display_fields[$def['vname']] = array( |
|
313 | + 'name' => empty($def['alias']) ? $field : $def['alias'], |
|
314 | + 'vname' => $def['vname'], |
|
315 | + 'width' => $def['width'], |
|
316 | + ); |
|
317 | + } |
|
318 | + } |
|
319 | + } else { |
|
320 | + $query_fields[$field] = $def; |
|
321 | + } |
|
322 | + } |
|
323 | + } |
|
324 | + foreach ( $this->sub_subpanels as $key => $subpanel ) |
|
325 | + { |
|
326 | + $list_fields = array(); |
|
327 | + foreach($display_fields as $vname => $def) |
|
328 | + { |
|
329 | + $field = $def['name']; |
|
330 | + $list_key = isset($listFieldMap[$key][$field]) ? $listFieldMap[$key][$field] : $field; |
|
331 | + |
|
332 | + if (isset($subpanel->panel_definition['list_fields'][$field])) |
|
333 | + { |
|
334 | + $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field]; |
|
335 | + } |
|
336 | + else if ($list_key != $field && isset($subpanel->panel_definition['list_fields'][$list_key])) |
|
337 | + { |
|
338 | + $list_fields[$list_key] = $subpanel->panel_definition['list_fields'][$list_key]; |
|
339 | + |
|
340 | + } |
|
341 | + else { |
|
342 | + $list_fields[$field] = $display_fields[$vname]; |
|
343 | + } |
|
344 | + } |
|
345 | + foreach($query_fields as $field => $def) |
|
346 | + { |
|
347 | + if (isset($subpanel->panel_definition['list_fields'][$field])) |
|
348 | + { |
|
349 | + $list_fields[$field] = $subpanel->panel_definition['list_fields'][$field]; |
|
350 | + } |
|
351 | + else { |
|
352 | + $list_fields[$field] = $def; |
|
353 | + } |
|
354 | + } |
|
355 | + $subpanel->panel_definition['list_fields'] = $list_fields; |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + return true; |
|
360 | + } |
|
361 | + |
|
362 | + protected function getDisplayFieldsFromCollection($sub_subpanels) |
|
363 | + { |
|
364 | + $display_fields = array(); |
|
365 | + foreach ($sub_subpanels as $key => $subpanel ) |
|
366 | + { |
|
367 | + $list_fields = $subpanel->get_list_fields(); |
|
368 | + $index = 0; |
|
369 | + foreach($list_fields as $field => $def) |
|
370 | + { |
|
371 | + if (isset($def['vname']) && isset($def['width'])) |
|
372 | + { |
|
373 | + $index++; |
|
374 | + if (!isset($display_fields[$def['vname']])) |
|
375 | + { |
|
376 | + if(sizeof($display_fields) > $index) |
|
377 | + { |
|
378 | + //Try to insert the new field in an order that makes sense |
|
379 | + $start = array_slice($display_fields, 0, $index); |
|
380 | + $end = array_slice($display_fields, $index); |
|
381 | + $display_fields = array_merge( |
|
382 | + $start, |
|
383 | + array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )), |
|
384 | + $end |
|
385 | + ); |
|
386 | + } else |
|
387 | + { |
|
388 | + $display_fields[$def['vname']] = array( |
|
389 | + 'name' => $field, |
|
390 | + 'vname' => $def['vname'], |
|
391 | + 'width' => $def['width'], |
|
392 | + ); |
|
393 | + } |
|
394 | + } |
|
395 | + } |
|
396 | + } |
|
397 | + } |
|
398 | + } |
|
399 | + |
|
400 | + function isDatasourceFunction () |
|
401 | + { |
|
402 | + if (strpos ( $this->get_inst_prop_value ( 'get_subpanel_data' ), 'function' ) === false) |
|
403 | + { |
|
404 | + return false ; |
|
405 | + } |
|
406 | + return true ; |
|
407 | + } |
|
408 | 408 | |
409 | 409 | /** |
410 | 410 | * Test to see if the sub panels defs contain a collection |
411 | 411 | * |
412 | 412 | * @return bool |
413 | 413 | */ |
414 | - function isCollection () |
|
415 | - { |
|
416 | - return ($this->get_inst_prop_value ( 'type' ) == 'collection'); |
|
417 | - } |
|
418 | - |
|
419 | - //get value of a property defined at the panel instance level. |
|
420 | - function get_inst_prop_value ( $name ) |
|
421 | - { |
|
422 | - return isset($this->_instance_properties[$name]) ? $this->_instance_properties [ $name ] : null; |
|
423 | - } |
|
424 | - //get value of a property defined at the panel definition level. |
|
425 | - function get_def_prop_value ( $name ) |
|
426 | - { |
|
427 | - if (isset ( $this->panel_definition [ $name ] )) |
|
428 | - { |
|
429 | - return $this->panel_definition [ $name ] ; |
|
430 | - } else |
|
431 | - { |
|
432 | - return null ; |
|
433 | - } |
|
434 | - } |
|
435 | - |
|
436 | - //if datasource is of the type function then return the function name |
|
437 | - //else return the value as is. |
|
438 | - function get_function_parameters () |
|
439 | - { |
|
440 | - $parameters = array ( ) ; |
|
441 | - if ($this->isDatasourceFunction ()) |
|
442 | - { |
|
443 | - $parameters = $this->get_inst_prop_value ( 'function_parameters' ) ; |
|
444 | - } |
|
445 | - return $parameters ; |
|
446 | - } |
|
447 | - |
|
448 | - function get_data_source_name ( $check_set_subpanel_data = false ) |
|
449 | - { |
|
450 | - $prop_value = null ; |
|
451 | - if ($check_set_subpanel_data) |
|
452 | - { |
|
453 | - $prop_value = $this->get_inst_prop_value ( 'set_subpanel_data' ) ; |
|
454 | - } |
|
455 | - if (! empty ( $prop_value )) |
|
456 | - { |
|
457 | - return $prop_value ; |
|
458 | - } else |
|
459 | - { |
|
460 | - //fall back to default behavior. |
|
461 | - } |
|
462 | - if ($this->isDatasourceFunction ()) |
|
463 | - { |
|
464 | - return (substr_replace ( $this->get_inst_prop_value ( 'get_subpanel_data' ), '', 0, 9 )) ; |
|
465 | - } else |
|
466 | - { |
|
467 | - return $this->get_inst_prop_value ( 'get_subpanel_data' ) ; |
|
468 | - } |
|
469 | - } |
|
470 | - |
|
471 | - //returns the where clause for the query. |
|
472 | - function get_where () |
|
473 | - { |
|
474 | - if($this->get_def_prop_value ( 'where' ) != '' && $this->search_query != ''){ |
|
475 | - return $this->get_def_prop_value ( 'where' ).' AND '.$this->search_query; |
|
476 | - } else if($this->search_query != ''){ |
|
477 | - return $this->search_query; |
|
478 | - } |
|
479 | - return $this->get_def_prop_value ( 'where' ) ; |
|
480 | - } |
|
481 | - |
|
482 | - function is_fill_in_additional_fields () |
|
483 | - { |
|
484 | - // do both. inst_prop returns values from metadata/subpaneldefs.php and def_prop returns from subpanel/default.php |
|
485 | - $temp = $this->get_inst_prop_value ( 'fill_in_additional_fields' ) || $this->get_def_prop_value ( 'fill_in_additional_fields' ) ; |
|
486 | - return $temp ; |
|
487 | - } |
|
488 | - |
|
489 | - function get_list_fields () |
|
490 | - { |
|
491 | - if (isset ( $this->panel_definition [ 'list_fields' ] )) |
|
492 | - { |
|
493 | - return $this->panel_definition [ 'list_fields' ] ; |
|
494 | - } else |
|
495 | - { |
|
496 | - return array ( ) ; |
|
497 | - } |
|
498 | - } |
|
499 | - |
|
500 | - function get_module_name () |
|
501 | - { |
|
502 | - return $this->get_inst_prop_value ( 'module' ) ; |
|
503 | - } |
|
504 | - |
|
505 | - function get_name () |
|
506 | - { |
|
507 | - return $this->name ; |
|
508 | - } |
|
509 | - |
|
510 | - //load subpanel module's table name and column fields. |
|
511 | - function load_module_info () |
|
512 | - { |
|
513 | - global $beanList ; |
|
514 | - global $beanFiles ; |
|
515 | - |
|
516 | - $module_name = $this->get_module_name () ; |
|
517 | - if (! empty ( $module_name )) |
|
518 | - { |
|
519 | - |
|
520 | - $bean_name = $beanList [ $this->get_module_name () ] ; |
|
521 | - |
|
522 | - $this->bean_name = $bean_name ; |
|
523 | - |
|
524 | - include_once ($beanFiles [ $bean_name ]) ; |
|
525 | - $this->template_instance = new $bean_name ( ) ; |
|
526 | - $this->template_instance->force_load_details = true ; |
|
527 | - $this->table_name = $this->template_instance->table_name ; |
|
528 | - //$this->db_fields=$this->template_instance->column_fields; |
|
529 | - } |
|
530 | - } |
|
531 | - //this function is to be used only with sub-panels that are based |
|
532 | - //on collections. |
|
533 | - function get_header_panel_def () |
|
534 | - { |
|
535 | - if (! empty ( $this->sub_subpanels )) |
|
536 | - { |
|
537 | - if (! empty ( $this->_instance_properties [ 'header_definition_from_subpanel' ] ) && ! empty ( $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] )) |
|
538 | - { |
|
539 | - return $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ; |
|
540 | - } else |
|
541 | - { |
|
542 | - $display_fields = array(); |
|
543 | - //If we are not pulling from a specific subpanel, create a list of all list fields and use that. |
|
544 | - foreach($this->sub_subpanels as $subpanel) |
|
545 | - { |
|
546 | - $list_fields = $subpanel->get_list_fields(); |
|
547 | - foreach($list_fields as $field => $def) |
|
548 | - { |
|
549 | - |
|
550 | - } |
|
551 | - } |
|
552 | - |
|
553 | - reset ( $this->sub_subpanels ) ; |
|
554 | - return current ( $this->sub_subpanels ) ; |
|
555 | - } |
|
556 | - } |
|
557 | - return null ; |
|
558 | - } |
|
559 | - |
|
560 | - /** |
|
561 | - * Returns an array of current properties of the class. |
|
562 | - * It will simply give the class name for instances of classes. |
|
563 | - */ |
|
564 | - function _to_array () |
|
565 | - { |
|
566 | - return array ( '_instance_properties' => $this->_instance_properties , 'db_fields' => $this->db_fields , 'mod_strings' => $this->mod_strings , 'name' => $this->name , 'panel_definition' => $this->panel_definition , 'parent_bean' => get_class ( $this->parent_bean ) , 'sub_subpanels' => $this->sub_subpanels , 'table_name' => $this->table_name , 'template_instance' => get_class ( $this->template_instance ) ) ; |
|
567 | - } |
|
414 | + function isCollection () |
|
415 | + { |
|
416 | + return ($this->get_inst_prop_value ( 'type' ) == 'collection'); |
|
417 | + } |
|
418 | + |
|
419 | + //get value of a property defined at the panel instance level. |
|
420 | + function get_inst_prop_value ( $name ) |
|
421 | + { |
|
422 | + return isset($this->_instance_properties[$name]) ? $this->_instance_properties [ $name ] : null; |
|
423 | + } |
|
424 | + //get value of a property defined at the panel definition level. |
|
425 | + function get_def_prop_value ( $name ) |
|
426 | + { |
|
427 | + if (isset ( $this->panel_definition [ $name ] )) |
|
428 | + { |
|
429 | + return $this->panel_definition [ $name ] ; |
|
430 | + } else |
|
431 | + { |
|
432 | + return null ; |
|
433 | + } |
|
434 | + } |
|
435 | + |
|
436 | + //if datasource is of the type function then return the function name |
|
437 | + //else return the value as is. |
|
438 | + function get_function_parameters () |
|
439 | + { |
|
440 | + $parameters = array ( ) ; |
|
441 | + if ($this->isDatasourceFunction ()) |
|
442 | + { |
|
443 | + $parameters = $this->get_inst_prop_value ( 'function_parameters' ) ; |
|
444 | + } |
|
445 | + return $parameters ; |
|
446 | + } |
|
447 | + |
|
448 | + function get_data_source_name ( $check_set_subpanel_data = false ) |
|
449 | + { |
|
450 | + $prop_value = null ; |
|
451 | + if ($check_set_subpanel_data) |
|
452 | + { |
|
453 | + $prop_value = $this->get_inst_prop_value ( 'set_subpanel_data' ) ; |
|
454 | + } |
|
455 | + if (! empty ( $prop_value )) |
|
456 | + { |
|
457 | + return $prop_value ; |
|
458 | + } else |
|
459 | + { |
|
460 | + //fall back to default behavior. |
|
461 | + } |
|
462 | + if ($this->isDatasourceFunction ()) |
|
463 | + { |
|
464 | + return (substr_replace ( $this->get_inst_prop_value ( 'get_subpanel_data' ), '', 0, 9 )) ; |
|
465 | + } else |
|
466 | + { |
|
467 | + return $this->get_inst_prop_value ( 'get_subpanel_data' ) ; |
|
468 | + } |
|
469 | + } |
|
470 | + |
|
471 | + //returns the where clause for the query. |
|
472 | + function get_where () |
|
473 | + { |
|
474 | + if($this->get_def_prop_value ( 'where' ) != '' && $this->search_query != ''){ |
|
475 | + return $this->get_def_prop_value ( 'where' ).' AND '.$this->search_query; |
|
476 | + } else if($this->search_query != ''){ |
|
477 | + return $this->search_query; |
|
478 | + } |
|
479 | + return $this->get_def_prop_value ( 'where' ) ; |
|
480 | + } |
|
481 | + |
|
482 | + function is_fill_in_additional_fields () |
|
483 | + { |
|
484 | + // do both. inst_prop returns values from metadata/subpaneldefs.php and def_prop returns from subpanel/default.php |
|
485 | + $temp = $this->get_inst_prop_value ( 'fill_in_additional_fields' ) || $this->get_def_prop_value ( 'fill_in_additional_fields' ) ; |
|
486 | + return $temp ; |
|
487 | + } |
|
488 | + |
|
489 | + function get_list_fields () |
|
490 | + { |
|
491 | + if (isset ( $this->panel_definition [ 'list_fields' ] )) |
|
492 | + { |
|
493 | + return $this->panel_definition [ 'list_fields' ] ; |
|
494 | + } else |
|
495 | + { |
|
496 | + return array ( ) ; |
|
497 | + } |
|
498 | + } |
|
499 | + |
|
500 | + function get_module_name () |
|
501 | + { |
|
502 | + return $this->get_inst_prop_value ( 'module' ) ; |
|
503 | + } |
|
504 | + |
|
505 | + function get_name () |
|
506 | + { |
|
507 | + return $this->name ; |
|
508 | + } |
|
509 | + |
|
510 | + //load subpanel module's table name and column fields. |
|
511 | + function load_module_info () |
|
512 | + { |
|
513 | + global $beanList ; |
|
514 | + global $beanFiles ; |
|
515 | + |
|
516 | + $module_name = $this->get_module_name () ; |
|
517 | + if (! empty ( $module_name )) |
|
518 | + { |
|
519 | + |
|
520 | + $bean_name = $beanList [ $this->get_module_name () ] ; |
|
521 | + |
|
522 | + $this->bean_name = $bean_name ; |
|
523 | + |
|
524 | + include_once ($beanFiles [ $bean_name ]) ; |
|
525 | + $this->template_instance = new $bean_name ( ) ; |
|
526 | + $this->template_instance->force_load_details = true ; |
|
527 | + $this->table_name = $this->template_instance->table_name ; |
|
528 | + //$this->db_fields=$this->template_instance->column_fields; |
|
529 | + } |
|
530 | + } |
|
531 | + //this function is to be used only with sub-panels that are based |
|
532 | + //on collections. |
|
533 | + function get_header_panel_def () |
|
534 | + { |
|
535 | + if (! empty ( $this->sub_subpanels )) |
|
536 | + { |
|
537 | + if (! empty ( $this->_instance_properties [ 'header_definition_from_subpanel' ] ) && ! empty ( $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] )) |
|
538 | + { |
|
539 | + return $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ; |
|
540 | + } else |
|
541 | + { |
|
542 | + $display_fields = array(); |
|
543 | + //If we are not pulling from a specific subpanel, create a list of all list fields and use that. |
|
544 | + foreach($this->sub_subpanels as $subpanel) |
|
545 | + { |
|
546 | + $list_fields = $subpanel->get_list_fields(); |
|
547 | + foreach($list_fields as $field => $def) |
|
548 | + { |
|
549 | + |
|
550 | + } |
|
551 | + } |
|
552 | + |
|
553 | + reset ( $this->sub_subpanels ) ; |
|
554 | + return current ( $this->sub_subpanels ) ; |
|
555 | + } |
|
556 | + } |
|
557 | + return null ; |
|
558 | + } |
|
559 | + |
|
560 | + /** |
|
561 | + * Returns an array of current properties of the class. |
|
562 | + * It will simply give the class name for instances of classes. |
|
563 | + */ |
|
564 | + function _to_array () |
|
565 | + { |
|
566 | + return array ( '_instance_properties' => $this->_instance_properties , 'db_fields' => $this->db_fields , 'mod_strings' => $this->mod_strings , 'name' => $this->name , 'panel_definition' => $this->panel_definition , 'parent_bean' => get_class ( $this->parent_bean ) , 'sub_subpanels' => $this->sub_subpanels , 'table_name' => $this->table_name , 'template_instance' => get_class ( $this->template_instance ) ) ; |
|
567 | + } |
|
568 | 568 | |
569 | 569 | /** |
570 | 570 | * Sets definition of the subpanel |
@@ -582,301 +582,301 @@ discard block |
||
582 | 582 | class SubPanelDefinitions |
583 | 583 | { |
584 | 584 | |
585 | - var $_focus ; |
|
586 | - var $_visible_tabs_array ; |
|
587 | - var $panels ; |
|
588 | - var $layout_defs ; |
|
589 | - |
|
590 | - /** |
|
591 | - * Enter description here... |
|
592 | - * |
|
593 | - * @param BEAN $focus - this is the bean you want to get the data from |
|
594 | - * @param STRING $layout_def_key - if you wish to use a layout_def defined in the default metadata/subpaneldefs.php that is not keyed off of $bean->module_dir pass in the key here |
|
595 | - * @param ARRAY $layout_def_override - if you wish to override the default loaded layout defs you pass them in here. |
|
596 | - * @return SubPanelDefinitions |
|
597 | - */ |
|
598 | - function __construct ( $focus , $layout_def_key = '' , $layout_def_override = '' ) |
|
599 | - { |
|
600 | - $this->_focus = $focus ; |
|
601 | - if (! empty ( $layout_def_override )) |
|
602 | - { |
|
603 | - $this->layout_defs = $layout_def_override ; |
|
604 | - |
|
605 | - } else |
|
606 | - { |
|
607 | - $this->open_layout_defs ( false, $layout_def_key ) ; |
|
608 | - } |
|
609 | - } |
|
610 | - |
|
611 | - /** |
|
612 | - * This function returns an ordered list of all "tabs", actually subpanels, for this module |
|
613 | - * The source list is obtained from the subpanel layout contained in the layout_defs for this module, |
|
614 | - * found either in the modules metadata/subpaneldefs.php file, or in the modules custom/.../Ext/Layoutdefs/layoutdefs.ext.php file |
|
615 | - * and filtered through an ACL check. |
|
616 | - * Note that the keys for the resulting array of tabs are in practice the name of the underlying source relationship for the subpanel |
|
617 | - * So for example, the key for a custom module's subpanel with Accounts might be 'one_one_accounts', as generated by the Studio Relationship Editor |
|
618 | - * Although OOB module subpanels have keys such as 'accounts', which might on the face of it appear to be a reference to the related module, in fact 'accounts' is still the relationship name |
|
619 | - * @param boolean Optional - include the subpanel title label in the return array (false) |
|
620 | - * @return array All tabs that pass an ACL check |
|
621 | - */ |
|
622 | - function get_available_tabs ($FromGetModuleSubpanels=false) |
|
623 | - { |
|
624 | - global $modListHeader ; |
|
625 | - global $modules_exempt_from_availability_check ; |
|
626 | - |
|
627 | - if (isset ( $this->_visible_tabs_array )) |
|
628 | - return $this->_visible_tabs_array ; |
|
629 | - |
|
630 | - if (empty($modListHeader)) |
|
631 | - $modListHeader = query_module_access_list($GLOBALS['current_user']); |
|
632 | - |
|
633 | - $this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort |
|
634 | - |
|
635 | - if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first |
|
636 | - { |
|
637 | - //retrieve list of hidden subpanels |
|
638 | - $hidden_panels = $this->get_hidden_subpanels(); |
|
639 | - |
|
640 | - //activities is a special use case in that if it is hidden, |
|
641 | - //then the history tab should be hidden too. |
|
642 | - if(!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities',$hidden_panels)){ |
|
643 | - //add history to list hidden_panels |
|
644 | - $hidden_panels['history'] = 'history'; |
|
645 | - } |
|
646 | - |
|
647 | - foreach ( $this->layout_defs [ 'subpanel_setup' ] as $key => $values_array ) |
|
648 | - { |
|
649 | - //exclude if this subpanel is hidden from admin screens |
|
585 | + var $_focus ; |
|
586 | + var $_visible_tabs_array ; |
|
587 | + var $panels ; |
|
588 | + var $layout_defs ; |
|
589 | + |
|
590 | + /** |
|
591 | + * Enter description here... |
|
592 | + * |
|
593 | + * @param BEAN $focus - this is the bean you want to get the data from |
|
594 | + * @param STRING $layout_def_key - if you wish to use a layout_def defined in the default metadata/subpaneldefs.php that is not keyed off of $bean->module_dir pass in the key here |
|
595 | + * @param ARRAY $layout_def_override - if you wish to override the default loaded layout defs you pass them in here. |
|
596 | + * @return SubPanelDefinitions |
|
597 | + */ |
|
598 | + function __construct ( $focus , $layout_def_key = '' , $layout_def_override = '' ) |
|
599 | + { |
|
600 | + $this->_focus = $focus ; |
|
601 | + if (! empty ( $layout_def_override )) |
|
602 | + { |
|
603 | + $this->layout_defs = $layout_def_override ; |
|
604 | + |
|
605 | + } else |
|
606 | + { |
|
607 | + $this->open_layout_defs ( false, $layout_def_key ) ; |
|
608 | + } |
|
609 | + } |
|
610 | + |
|
611 | + /** |
|
612 | + * This function returns an ordered list of all "tabs", actually subpanels, for this module |
|
613 | + * The source list is obtained from the subpanel layout contained in the layout_defs for this module, |
|
614 | + * found either in the modules metadata/subpaneldefs.php file, or in the modules custom/.../Ext/Layoutdefs/layoutdefs.ext.php file |
|
615 | + * and filtered through an ACL check. |
|
616 | + * Note that the keys for the resulting array of tabs are in practice the name of the underlying source relationship for the subpanel |
|
617 | + * So for example, the key for a custom module's subpanel with Accounts might be 'one_one_accounts', as generated by the Studio Relationship Editor |
|
618 | + * Although OOB module subpanels have keys such as 'accounts', which might on the face of it appear to be a reference to the related module, in fact 'accounts' is still the relationship name |
|
619 | + * @param boolean Optional - include the subpanel title label in the return array (false) |
|
620 | + * @return array All tabs that pass an ACL check |
|
621 | + */ |
|
622 | + function get_available_tabs ($FromGetModuleSubpanels=false) |
|
623 | + { |
|
624 | + global $modListHeader ; |
|
625 | + global $modules_exempt_from_availability_check ; |
|
626 | + |
|
627 | + if (isset ( $this->_visible_tabs_array )) |
|
628 | + return $this->_visible_tabs_array ; |
|
629 | + |
|
630 | + if (empty($modListHeader)) |
|
631 | + $modListHeader = query_module_access_list($GLOBALS['current_user']); |
|
632 | + |
|
633 | + $this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort |
|
634 | + |
|
635 | + if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first |
|
636 | + { |
|
637 | + //retrieve list of hidden subpanels |
|
638 | + $hidden_panels = $this->get_hidden_subpanels(); |
|
639 | + |
|
640 | + //activities is a special use case in that if it is hidden, |
|
641 | + //then the history tab should be hidden too. |
|
642 | + if(!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities',$hidden_panels)){ |
|
643 | + //add history to list hidden_panels |
|
644 | + $hidden_panels['history'] = 'history'; |
|
645 | + } |
|
646 | + |
|
647 | + foreach ( $this->layout_defs [ 'subpanel_setup' ] as $key => $values_array ) |
|
648 | + { |
|
649 | + //exclude if this subpanel is hidden from admin screens |
|
650 | 650 | $module = $key; |
651 | 651 | if ( isset($values_array['module']) ) |
652 | 652 | $module = strtolower($values_array['module']); |
653 | - if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){ |
|
654 | - //this panel is hidden, skip it |
|
655 | - continue; |
|
656 | - } |
|
657 | - |
|
658 | - // make sure the module attribute is set, else none of this works... |
|
659 | - if ( !isset($values_array [ 'module' ])) { |
|
660 | - $GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>" . var_export($values_array,true) . " - ingoring subpanel defintion") ; |
|
661 | - continue; |
|
662 | - } |
|
663 | - |
|
664 | - //check permissions. |
|
665 | - $exempt = array_key_exists ( $values_array [ 'module' ], $modules_exempt_from_availability_check ) ; |
|
666 | - $ok = $exempt || ( (! ACLController::moduleSupportsACL ( $values_array [ 'module' ] ) || ACLController::checkAccess ( $values_array [ 'module' ], 'list', true ) ) ) ; |
|
667 | - |
|
668 | - $GLOBALS [ 'log' ]->debug ( "SubPanelDefinitions->get_available_tabs(): " . $key . "= " . ( $exempt ? "exempt " : "not exempt " .( $ok ? " ACL OK" : "" ) ) ) ; |
|
669 | - |
|
670 | - if ( $ok ) |
|
671 | - { |
|
672 | - while ( ! empty ( $this->_visible_tabs_array [ $values_array [ 'order' ] ] ) ) |
|
673 | - { |
|
674 | - $values_array [ 'order' ] ++ ; |
|
675 | - } |
|
676 | - |
|
677 | - $this->_visible_tabs_array [ $values_array ['order'] ] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key ; |
|
678 | - } |
|
679 | - } |
|
680 | - } |
|
681 | - |
|
682 | - ksort ( $this->_visible_tabs_array ) ; |
|
683 | - return $this->_visible_tabs_array ; |
|
684 | - } |
|
685 | - |
|
686 | - /** |
|
687 | - * Load the definition of the a sub-panel. |
|
688 | - * Also the sub-panel is added to an array of sub-panels. |
|
689 | - * use of reload has been deprecated, since the subpanel is initialized every time. |
|
653 | + if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){ |
|
654 | + //this panel is hidden, skip it |
|
655 | + continue; |
|
656 | + } |
|
657 | + |
|
658 | + // make sure the module attribute is set, else none of this works... |
|
659 | + if ( !isset($values_array [ 'module' ])) { |
|
660 | + $GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>" . var_export($values_array,true) . " - ingoring subpanel defintion") ; |
|
661 | + continue; |
|
662 | + } |
|
663 | + |
|
664 | + //check permissions. |
|
665 | + $exempt = array_key_exists ( $values_array [ 'module' ], $modules_exempt_from_availability_check ) ; |
|
666 | + $ok = $exempt || ( (! ACLController::moduleSupportsACL ( $values_array [ 'module' ] ) || ACLController::checkAccess ( $values_array [ 'module' ], 'list', true ) ) ) ; |
|
667 | + |
|
668 | + $GLOBALS [ 'log' ]->debug ( "SubPanelDefinitions->get_available_tabs(): " . $key . "= " . ( $exempt ? "exempt " : "not exempt " .( $ok ? " ACL OK" : "" ) ) ) ; |
|
669 | + |
|
670 | + if ( $ok ) |
|
671 | + { |
|
672 | + while ( ! empty ( $this->_visible_tabs_array [ $values_array [ 'order' ] ] ) ) |
|
673 | + { |
|
674 | + $values_array [ 'order' ] ++ ; |
|
675 | + } |
|
676 | + |
|
677 | + $this->_visible_tabs_array [ $values_array ['order'] ] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key ; |
|
678 | + } |
|
679 | + } |
|
680 | + } |
|
681 | + |
|
682 | + ksort ( $this->_visible_tabs_array ) ; |
|
683 | + return $this->_visible_tabs_array ; |
|
684 | + } |
|
685 | + |
|
686 | + /** |
|
687 | + * Load the definition of the a sub-panel. |
|
688 | + * Also the sub-panel is added to an array of sub-panels. |
|
689 | + * use of reload has been deprecated, since the subpanel is initialized every time. |
|
690 | 690 | * |
691 | 691 | * @param string $name The name of the sub-panel to reload |
692 | 692 | * @param boolean $reload Reload the sub-panel (unused) |
693 | 693 | * @param boolean $original_only Only load the original sub-panel and no custom ones |
694 | 694 | * @return boolean|aSubPanel Returns aSubPanel object or boolean false if one is not found or it can't be |
695 | 695 | * displayed due to ACL reasons. |
696 | - */ |
|
697 | - function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() ) |
|
698 | - { |
|
699 | - if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ])) |
|
700 | - return false; |
|
696 | + */ |
|
697 | + function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() ) |
|
698 | + { |
|
699 | + if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ])) |
|
700 | + return false; |
|
701 | 701 | |
702 | - $subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ; |
|
702 | + $subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ; |
|
703 | 703 | |
704 | - // only return the subpanel object if we can display it. |
|
705 | - if($subpanel->canDisplay == true) { |
|
706 | - return $subpanel; |
|
707 | - } |
|
704 | + // only return the subpanel object if we can display it. |
|
705 | + if($subpanel->canDisplay == true) { |
|
706 | + return $subpanel; |
|
707 | + } |
|
708 | 708 | |
709 | - // by default return false so we don't show anything if it's not required. |
|
710 | - return false; |
|
711 | - } |
|
709 | + // by default return false so we don't show anything if it's not required. |
|
710 | + return false; |
|
711 | + } |
|
712 | 712 | |
713 | - /** |
|
714 | - * Load the layout def file and associate the definition with a variable in the file. |
|
715 | - */ |
|
716 | - function open_layout_defs ( $reload = false , $layout_def_key = '' , $original_only = false ) |
|
717 | - { |
|
718 | - $layout_defs [ $this->_focus->module_dir ] = array ( ) ; |
|
719 | - $layout_defs [ $layout_def_key ] = array ( ) ; |
|
713 | + /** |
|
714 | + * Load the layout def file and associate the definition with a variable in the file. |
|
715 | + */ |
|
716 | + function open_layout_defs ( $reload = false , $layout_def_key = '' , $original_only = false ) |
|
717 | + { |
|
718 | + $layout_defs [ $this->_focus->module_dir ] = array ( ) ; |
|
719 | + $layout_defs [ $layout_def_key ] = array ( ) ; |
|
720 | 720 | |
721 | - if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] ))) |
|
722 | - { |
|
723 | - if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' )) |
|
724 | - require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ; |
|
721 | + if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] ))) |
|
722 | + { |
|
723 | + if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' )) |
|
724 | + require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ; |
|
725 | 725 | |
726 | - if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' )) |
|
727 | - require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ; |
|
726 | + if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' )) |
|
727 | + require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ; |
|
728 | 728 | |
729 | - if (! empty ( $layout_def_key )) |
|
730 | - $this->layout_defs = $layout_defs [ $layout_def_key ] ; |
|
731 | - else |
|
732 | - $this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ; |
|
729 | + if (! empty ( $layout_def_key )) |
|
730 | + $this->layout_defs = $layout_defs [ $layout_def_key ] ; |
|
731 | + else |
|
732 | + $this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ; |
|
733 | 733 | |
734 | - } |
|
734 | + } |
|
735 | 735 | |
736 | - } |
|
736 | + } |
|
737 | 737 | |
738 | - /** |
|
739 | - * Removes a tab from the list of loaded tabs. |
|
740 | - * Returns true if successful, false otherwise. |
|
741 | - * Hint: Used by Campaign's DetailView. |
|
742 | - */ |
|
743 | - function exclude_tab ( $tab_name ) |
|
744 | - { |
|
745 | - $result = false ; |
|
746 | - //unset layout definition |
|
747 | - if (! empty ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] )) |
|
748 | - { |
|
749 | - unset ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ) ; |
|
750 | - } |
|
751 | - //unset instance from _visible_tab_array |
|
752 | - if (! empty ( $this->_visible_tabs_array )) |
|
753 | - { |
|
754 | - $key = array_search ( $tab_name, $this->_visible_tabs_array ) ; |
|
755 | - if ($key !== false) |
|
756 | - { |
|
757 | - unset ( $this->_visible_tabs_array [ $key ] ) ; |
|
758 | - } |
|
759 | - } |
|
760 | - return $result ; |
|
761 | - } |
|
762 | - |
|
763 | - |
|
764 | - /** |
|
765 | - * return all available subpanels that belong to the list of tab modules. You can optionally return all |
|
766 | - * available subpanels, and also optionally group by module (prepends the key with the bean class name). |
|
767 | - */ |
|
768 | - function get_all_subpanels( $return_tab_modules_only = true, $group_by_module = false ) |
|
769 | - { |
|
770 | - global $moduleList, $beanFiles, $beanList, $module; |
|
738 | + /** |
|
739 | + * Removes a tab from the list of loaded tabs. |
|
740 | + * Returns true if successful, false otherwise. |
|
741 | + * Hint: Used by Campaign's DetailView. |
|
742 | + */ |
|
743 | + function exclude_tab ( $tab_name ) |
|
744 | + { |
|
745 | + $result = false ; |
|
746 | + //unset layout definition |
|
747 | + if (! empty ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] )) |
|
748 | + { |
|
749 | + unset ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ) ; |
|
750 | + } |
|
751 | + //unset instance from _visible_tab_array |
|
752 | + if (! empty ( $this->_visible_tabs_array )) |
|
753 | + { |
|
754 | + $key = array_search ( $tab_name, $this->_visible_tabs_array ) ; |
|
755 | + if ($key !== false) |
|
756 | + { |
|
757 | + unset ( $this->_visible_tabs_array [ $key ] ) ; |
|
758 | + } |
|
759 | + } |
|
760 | + return $result ; |
|
761 | + } |
|
762 | + |
|
763 | + |
|
764 | + /** |
|
765 | + * return all available subpanels that belong to the list of tab modules. You can optionally return all |
|
766 | + * available subpanels, and also optionally group by module (prepends the key with the bean class name). |
|
767 | + */ |
|
768 | + function get_all_subpanels( $return_tab_modules_only = true, $group_by_module = false ) |
|
769 | + { |
|
770 | + global $moduleList, $beanFiles, $beanList, $module; |
|
771 | 771 | |
772 | - //use tab controller function to get module list with named keys |
|
773 | - require_once("modules/MySettings/TabController.php"); |
|
774 | - $modules_to_check = TabController::get_key_array($moduleList); |
|
772 | + //use tab controller function to get module list with named keys |
|
773 | + require_once("modules/MySettings/TabController.php"); |
|
774 | + $modules_to_check = TabController::get_key_array($moduleList); |
|
775 | 775 | |
776 | - //change case to match subpanel processing later on |
|
777 | - $modules_to_check = array_change_key_case($modules_to_check); |
|
776 | + //change case to match subpanel processing later on |
|
777 | + $modules_to_check = array_change_key_case($modules_to_check); |
|
778 | 778 | // Append on the CampaignLog module, because that is where the subpanels point, not directly to Campaigns |
779 | 779 | $modules_to_check['campaignlog'] = "CampaignLog"; |
780 | 780 | |
781 | 781 | |
782 | - $spd = ''; |
|
783 | - $spd_arr = array(); |
|
784 | - //iterate through modules and build subpanel array |
|
785 | - foreach($modules_to_check as $mod_name){ |
|
782 | + $spd = ''; |
|
783 | + $spd_arr = array(); |
|
784 | + //iterate through modules and build subpanel array |
|
785 | + foreach($modules_to_check as $mod_name){ |
|
786 | 786 | |
787 | - //skip if module name is not in bean list, otherwise get the bean class name |
|
788 | - if(!isset($beanList[$mod_name])) continue; |
|
789 | - $class = $beanList[$mod_name]; |
|
787 | + //skip if module name is not in bean list, otherwise get the bean class name |
|
788 | + if(!isset($beanList[$mod_name])) continue; |
|
789 | + $class = $beanList[$mod_name]; |
|
790 | 790 | |
791 | - //skip if class name is not in file list, otherwise require the bean file and create new class |
|
792 | - if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue; |
|
791 | + //skip if class name is not in file list, otherwise require the bean file and create new class |
|
792 | + if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue; |
|
793 | 793 | |
794 | - //retrieve subpanels for this bean |
|
795 | - require_once($beanFiles[$class]); |
|
796 | - $bean_class = new $class(); |
|
794 | + //retrieve subpanels for this bean |
|
795 | + require_once($beanFiles[$class]); |
|
796 | + $bean_class = new $class(); |
|
797 | 797 | |
798 | - //create new subpanel definition instance and get list of tabs |
|
799 | - $spd = new SubPanelDefinitions($bean_class) ; |
|
800 | - $sub_tabs = $spd->get_available_tabs(); |
|
798 | + //create new subpanel definition instance and get list of tabs |
|
799 | + $spd = new SubPanelDefinitions($bean_class) ; |
|
800 | + $sub_tabs = $spd->get_available_tabs(); |
|
801 | 801 | |
802 | - //add each subpanel to array of total subpanles |
|
803 | - foreach( $sub_tabs as $panel_key){ |
|
804 | - $panel_key = strtolower($panel_key); |
|
802 | + //add each subpanel to array of total subpanles |
|
803 | + foreach( $sub_tabs as $panel_key){ |
|
804 | + $panel_key = strtolower($panel_key); |
|
805 | 805 | $panel_module = $panel_key; |
806 | 806 | if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) ) |
807 | 807 | $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']); |
808 | 808 | //if module_only flag is set, only if it is also in module array |
809 | - if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue; |
|
810 | - $panel_key_name = $panel_module; |
|
811 | - |
|
812 | - //group_by_key_name is set to true, then array will hold an entry for each |
|
813 | - //subpanel, with the module name prepended in the key |
|
814 | - if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name; |
|
815 | - //add panel name to subpanel array |
|
816 | - $spd_arr[$panel_key_name] = $panel_module; |
|
817 | - } |
|
818 | - } |
|
819 | - return $spd_arr; |
|
820 | - } |
|
821 | - |
|
822 | - /* |
|
809 | + if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue; |
|
810 | + $panel_key_name = $panel_module; |
|
811 | + |
|
812 | + //group_by_key_name is set to true, then array will hold an entry for each |
|
813 | + //subpanel, with the module name prepended in the key |
|
814 | + if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name; |
|
815 | + //add panel name to subpanel array |
|
816 | + $spd_arr[$panel_key_name] = $panel_module; |
|
817 | + } |
|
818 | + } |
|
819 | + return $spd_arr; |
|
820 | + } |
|
821 | + |
|
822 | + /* |
|
823 | 823 | * save array of hidden panels to mysettings category in config table |
824 | 824 | */ |
825 | - function set_hidden_subpanels($panels){ |
|
826 | - $administration = new Administration(); |
|
827 | - $serialized = base64_encode(serialize($panels)); |
|
828 | - $administration->saveSetting('MySettings', 'hide_subpanels', $serialized); |
|
829 | - } |
|
825 | + function set_hidden_subpanels($panels){ |
|
826 | + $administration = new Administration(); |
|
827 | + $serialized = base64_encode(serialize($panels)); |
|
828 | + $administration->saveSetting('MySettings', 'hide_subpanels', $serialized); |
|
829 | + } |
|
830 | 830 | |
831 | - /* |
|
831 | + /* |
|
832 | 832 | * retrieve hidden subpanels |
833 | 833 | */ |
834 | - function get_hidden_subpanels(){ |
|
835 | - global $moduleList; |
|
836 | - |
|
837 | - //create variable as static to minimize queries |
|
838 | - static $hidden_subpanels = null; |
|
839 | - |
|
840 | - // if the static value is not already cached, then retrieve it. |
|
841 | - if(empty($hidden_subpanels)) |
|
842 | - { |
|
843 | - |
|
844 | - //create Administration object and retrieve any settings for panels |
|
845 | - $administration = new Administration(); |
|
846 | - $administration->retrieveSettings('MySettings'); |
|
847 | - |
|
848 | - if(isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])){ |
|
849 | - $hidden_subpanels = $administration->settings['MySettings_hide_subpanels']; |
|
850 | - $hidden_subpanels = trim($hidden_subpanels); |
|
851 | - |
|
852 | - //make sure serialized string is not empty |
|
853 | - if (!empty($hidden_subpanels)){ |
|
854 | - //decode and unserialize to retrieve the array |
|
855 | - $hidden_subpanels = base64_decode($hidden_subpanels); |
|
856 | - $hidden_subpanels = unserialize($hidden_subpanels); |
|
857 | - |
|
858 | - //Ensure modules saved in the preferences exist. |
|
859 | - //get user preference |
|
860 | - //unserialize and add to array if not empty |
|
861 | - $pref_hidden = array(); |
|
862 | - foreach($pref_hidden as $id => $pref_hidden_panel) { |
|
863 | - $hidden_subpanels[] = $pref_hidden_panel; |
|
864 | - } |
|
865 | - |
|
866 | - |
|
867 | - }else{ |
|
868 | - //no settings found, return empty |
|
869 | - return $hidden_subpanels; |
|
870 | - } |
|
871 | - } |
|
872 | - else |
|
873 | - { //no settings found, return empty |
|
874 | - return $hidden_subpanels; |
|
875 | - } |
|
876 | - } |
|
877 | - |
|
878 | - return $hidden_subpanels; |
|
879 | - } |
|
834 | + function get_hidden_subpanels(){ |
|
835 | + global $moduleList; |
|
836 | + |
|
837 | + //create variable as static to minimize queries |
|
838 | + static $hidden_subpanels = null; |
|
839 | + |
|
840 | + // if the static value is not already cached, then retrieve it. |
|
841 | + if(empty($hidden_subpanels)) |
|
842 | + { |
|
843 | + |
|
844 | + //create Administration object and retrieve any settings for panels |
|
845 | + $administration = new Administration(); |
|
846 | + $administration->retrieveSettings('MySettings'); |
|
847 | + |
|
848 | + if(isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])){ |
|
849 | + $hidden_subpanels = $administration->settings['MySettings_hide_subpanels']; |
|
850 | + $hidden_subpanels = trim($hidden_subpanels); |
|
851 | + |
|
852 | + //make sure serialized string is not empty |
|
853 | + if (!empty($hidden_subpanels)){ |
|
854 | + //decode and unserialize to retrieve the array |
|
855 | + $hidden_subpanels = base64_decode($hidden_subpanels); |
|
856 | + $hidden_subpanels = unserialize($hidden_subpanels); |
|
857 | + |
|
858 | + //Ensure modules saved in the preferences exist. |
|
859 | + //get user preference |
|
860 | + //unserialize and add to array if not empty |
|
861 | + $pref_hidden = array(); |
|
862 | + foreach($pref_hidden as $id => $pref_hidden_panel) { |
|
863 | + $hidden_subpanels[] = $pref_hidden_panel; |
|
864 | + } |
|
865 | + |
|
866 | + |
|
867 | + }else{ |
|
868 | + //no settings found, return empty |
|
869 | + return $hidden_subpanels; |
|
870 | + } |
|
871 | + } |
|
872 | + else |
|
873 | + { //no settings found, return empty |
|
874 | + return $hidden_subpanels; |
|
875 | + } |
|
876 | + } |
|
877 | + |
|
878 | + return $hidden_subpanels; |
|
879 | + } |
|
880 | 880 | |
881 | 881 | |
882 | 882 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die ('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | class aSubPanel |
55 | 55 | { |
56 | 56 | |
57 | - var $name ; |
|
58 | - var $_instance_properties ; |
|
57 | + var $name; |
|
58 | + var $_instance_properties; |
|
59 | 59 | |
60 | - var $mod_strings ; |
|
61 | - var $panel_definition ; |
|
62 | - var $sub_subpanels ; |
|
63 | - var $parent_bean ; |
|
60 | + var $mod_strings; |
|
61 | + var $panel_definition; |
|
62 | + var $sub_subpanels; |
|
63 | + var $parent_bean; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Can we display this subpanel? |
@@ -73,53 +73,53 @@ discard block |
||
73 | 73 | var $canDisplay = true; |
74 | 74 | |
75 | 75 | //module's table name and column fields. |
76 | - var $table_name ; |
|
77 | - var $db_fields ; |
|
78 | - var $bean_name ; |
|
79 | - var $template_instance ; |
|
76 | + var $table_name; |
|
77 | + var $db_fields; |
|
78 | + var $bean_name; |
|
79 | + var $template_instance; |
|
80 | 80 | |
81 | 81 | var $search_query; |
82 | 82 | var $base_collection_list = array(); |
83 | 83 | |
84 | - function __construct ($name , $instance_properties , $parent_bean , $reload = false , $original_only = false, $search_query = '', $collections = array() ){ |
|
84 | + function __construct($name, $instance_properties, $parent_bean, $reload = false, $original_only = false, $search_query = '', $collections = array()) { |
|
85 | 85 | |
86 | - $this->_instance_properties = $instance_properties ; |
|
86 | + $this->_instance_properties = $instance_properties; |
|
87 | 87 | |
88 | - if(isset($instance_properties['collection_list' ])) $this->base_collection_list = $instance_properties['collection_list' ]; |
|
88 | + if (isset($instance_properties['collection_list'])) $this->base_collection_list = $instance_properties['collection_list']; |
|
89 | 89 | |
90 | - if(!empty($collections) && isset($instance_properties['collection_list' ])){ |
|
91 | - foreach($instance_properties['collection_list' ] as $cname => $value){ |
|
92 | - if(!in_array($value['module'], $collections)){ |
|
90 | + if (!empty($collections) && isset($instance_properties['collection_list'])) { |
|
91 | + foreach ($instance_properties['collection_list'] as $cname => $value) { |
|
92 | + if (!in_array($value['module'], $collections)) { |
|
93 | 93 | unset($instance_properties['collection_list'][$cname]); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | - if (!$this->isCollection()){ |
|
97 | + if (!$this->isCollection()) { |
|
98 | 98 | $table = strtolower($instance_properties['module']); |
99 | - $search_query = str_replace('meetings',$table,$search_query); |
|
99 | + $search_query = str_replace('meetings', $table, $search_query); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $this->search_query = $search_query; |
103 | - $this->name = $name ; |
|
104 | - $this->parent_bean = $parent_bean ; |
|
103 | + $this->name = $name; |
|
104 | + $this->parent_bean = $parent_bean; |
|
105 | 105 | |
106 | 106 | //set language |
107 | - global $current_language ; |
|
108 | - if (! isset ( $parent_bean->mbvardefs )) |
|
107 | + global $current_language; |
|
108 | + if (!isset ($parent_bean->mbvardefs)) |
|
109 | 109 | { |
110 | - $mod_strings = return_module_language ( $current_language, $parent_bean->module_dir ) ; |
|
110 | + $mod_strings = return_module_language($current_language, $parent_bean->module_dir); |
|
111 | 111 | } |
112 | - $this->mod_strings = $mod_strings ; |
|
112 | + $this->mod_strings = $mod_strings; |
|
113 | 113 | |
114 | - if ($this->isCollection ()) |
|
114 | + if ($this->isCollection()) |
|
115 | 115 | { |
116 | - $this->canDisplay = $this->load_sub_subpanels () ; //load sub-panel definition. |
|
116 | + $this->canDisplay = $this->load_sub_subpanels(); //load sub-panel definition. |
|
117 | 117 | } else |
118 | 118 | { |
119 | - if (!is_dir('modules/' . $this->_instance_properties [ 'module' ])){ |
|
119 | + if (!is_dir('modules/'.$this->_instance_properties ['module'])) { |
|
120 | 120 | _pstack_trace(); |
121 | 121 | } |
122 | - $def_path = 'modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'subpanel_name' ] . '.php' ; |
|
122 | + $def_path = 'modules/'.$this->_instance_properties ['module'].'/metadata/subpanels/'.$this->_instance_properties ['subpanel_name'].'.php'; |
|
123 | 123 | |
124 | 124 | $orig_exists = is_file($def_path); |
125 | 125 | $loaded = false; |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | require ($def_path); |
129 | 129 | $loaded = true; |
130 | 130 | } |
131 | - if (is_file("custom/$def_path") && (!$original_only || !$orig_exists)) |
|
131 | + if (is_file("custom/$def_path") && (!$original_only || !$orig_exists)) |
|
132 | 132 | { |
133 | 133 | require ("custom/$def_path"); |
134 | 134 | $loaded = true; |
135 | 135 | } |
136 | 136 | |
137 | - if (! $original_only && isset ( $this->_instance_properties [ 'override_subpanel_name' ] ) && file_exists ( 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' )) |
|
137 | + if (!$original_only && isset ($this->_instance_properties ['override_subpanel_name']) && file_exists('custom/modules/'.$this->_instance_properties ['module'].'/metadata/subpanels/'.$this->_instance_properties ['override_subpanel_name'].'.php')) |
|
138 | 138 | { |
139 | - $cust_def_path = 'custom/modules/' . $this->_instance_properties [ 'module' ] . '/metadata/subpanels/' . $this->_instance_properties [ 'override_subpanel_name' ] . '.php' ; |
|
140 | - require ($cust_def_path) ; |
|
139 | + $cust_def_path = 'custom/modules/'.$this->_instance_properties ['module'].'/metadata/subpanels/'.$this->_instance_properties ['override_subpanel_name'].'.php'; |
|
140 | + require ($cust_def_path); |
|
141 | 141 | $loaded = true; |
142 | 142 | } |
143 | 143 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function isDefaultHidden() |
170 | 170 | { |
171 | - if(isset($this->_instance_properties['default_hidden']) && $this->_instance_properties['default_hidden'] == true) { |
|
171 | + if (isset($this->_instance_properties['default_hidden']) && $this->_instance_properties['default_hidden'] == true) { |
|
172 | 172 | return true; |
173 | 173 | } |
174 | 174 | |
@@ -176,63 +176,63 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | |
179 | - function distinct_query () |
|
179 | + function distinct_query() |
|
180 | 180 | { |
181 | - if (isset ( $this->_instance_properties [ 'get_distinct_data' ] )) |
|
181 | + if (isset ($this->_instance_properties ['get_distinct_data'])) |
|
182 | 182 | { |
183 | 183 | return !empty($this->_instance_properties['get_distinct_data']) ? true : false; |
184 | 184 | } |
185 | - return false ; |
|
185 | + return false; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | //return the translated header value. |
189 | - function get_title () |
|
189 | + function get_title() |
|
190 | 190 | { |
191 | - if (empty ( $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] )) |
|
191 | + if (empty ($this->mod_strings [$this->_instance_properties ['title_key']])) |
|
192 | 192 | { |
193 | - return translate ( $this->_instance_properties [ 'title_key' ], $this->_instance_properties [ 'module' ] ) ; |
|
193 | + return translate($this->_instance_properties ['title_key'], $this->_instance_properties ['module']); |
|
194 | 194 | } |
195 | - return $this->mod_strings [ $this->_instance_properties [ 'title_key' ] ] ; |
|
195 | + return $this->mod_strings [$this->_instance_properties ['title_key']]; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | //return the definition of buttons. looks for buttons in 2 locations. |
199 | - function get_buttons () |
|
199 | + function get_buttons() |
|
200 | 200 | { |
201 | - $buttons = array ( ) ; |
|
202 | - if (isset ( $this->_instance_properties [ 'top_buttons' ] )) |
|
201 | + $buttons = array( ); |
|
202 | + if (isset ($this->_instance_properties ['top_buttons'])) |
|
203 | 203 | { |
204 | 204 | //this will happen only in the case of sub-panels with multiple sources(activities). |
205 | - $buttons = $this->_instance_properties [ 'top_buttons' ] ; |
|
205 | + $buttons = $this->_instance_properties ['top_buttons']; |
|
206 | 206 | } else |
207 | 207 | { |
208 | - $buttons = $this->panel_definition [ 'top_buttons' ] ; |
|
208 | + $buttons = $this->panel_definition ['top_buttons']; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | // permissions. hide SubPanelTopComposeEmailButton from activities if email module is disabled. |
212 | 212 | //only email is being tested becuase other submodules in activites/history such as notes, tasks, meetings and calls cannot be disabled. |
213 | 213 | //as of today these are the only 2 sub-panels that use the union clause. |
214 | - $mod_name = $this->get_module_name () ; |
|
214 | + $mod_name = $this->get_module_name(); |
|
215 | 215 | if ($mod_name == 'Activities' || $mod_name == 'History') |
216 | 216 | { |
217 | - global $modListHeader ; |
|
218 | - global $modules_exempt_from_availability_check ; |
|
219 | - if (isset ( $modListHeader ) && (! (array_key_exists ( 'Emails', $modListHeader ) or array_key_exists ( 'Emails', $modules_exempt_from_availability_check )))) |
|
217 | + global $modListHeader; |
|
218 | + global $modules_exempt_from_availability_check; |
|
219 | + if (isset ($modListHeader) && (!(array_key_exists('Emails', $modListHeader) or array_key_exists('Emails', $modules_exempt_from_availability_check)))) |
|
220 | 220 | { |
221 | - foreach ( $buttons as $key => $button ) |
|
221 | + foreach ($buttons as $key => $button) |
|
222 | 222 | { |
223 | - foreach ( $button as $property => $value ) |
|
223 | + foreach ($button as $property => $value) |
|
224 | 224 | { |
225 | 225 | if ($value === 'SubPanelTopComposeEmailButton' || $value === 'SubPanelTopArchiveEmailButton') |
226 | 226 | { |
227 | 227 | //remove this button from the array. |
228 | - unset ( $buttons [ $key ] ) ; |
|
228 | + unset ($buttons [$key]); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | - return $buttons ; |
|
235 | + return $buttons; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -244,67 +244,67 @@ discard block |
||
244 | 244 | * @return bool True by default if the subpanel was loaded. Will return false if none in the collection are |
245 | 245 | * allowed by the current user. |
246 | 246 | */ |
247 | - function load_sub_subpanels () |
|
247 | + function load_sub_subpanels() |
|
248 | 248 | { |
249 | 249 | |
250 | - global $modListHeader ; |
|
250 | + global $modListHeader; |
|
251 | 251 | // added a check for security of tabs to see if an user has access to them |
252 | 252 | // this prevents passing an "unseen" tab to the query string and pulling up its contents |
253 | - if (! isset ( $modListHeader )) |
|
253 | + if (!isset ($modListHeader)) |
|
254 | 254 | { |
255 | - global $current_user ; |
|
256 | - if (isset ( $current_user )) |
|
255 | + global $current_user; |
|
256 | + if (isset ($current_user)) |
|
257 | 257 | { |
258 | - $modListHeader = query_module_access_list ( $current_user ) ; |
|
258 | + $modListHeader = query_module_access_list($current_user); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | //by default all the activities modules are exempt, so hiding them won't affect their appearance unless the 'activity' subpanel itself is hidden. |
263 | 263 | //add email to the list temporarily so it is not affected in activities subpanel |
264 | - global $modules_exempt_from_availability_check ; |
|
264 | + global $modules_exempt_from_availability_check; |
|
265 | 265 | $modules_exempt_from_availability_check['Emails'] = 'Emails'; |
266 | 266 | |
267 | 267 | $listFieldMap = array(); |
268 | 268 | |
269 | - if (empty ( $this->sub_subpanels )) |
|
269 | + if (empty ($this->sub_subpanels)) |
|
270 | 270 | { |
271 | - $panels = $this->get_inst_prop_value ( 'collection_list' ) ; |
|
272 | - foreach ( $panels as $panel => $properties ) |
|
271 | + $panels = $this->get_inst_prop_value('collection_list'); |
|
272 | + foreach ($panels as $panel => $properties) |
|
273 | 273 | { |
274 | - if (array_key_exists ( $properties [ 'module' ], $modListHeader ) or array_key_exists ( $properties [ 'module' ], $modules_exempt_from_availability_check )) |
|
274 | + if (array_key_exists($properties ['module'], $modListHeader) or array_key_exists($properties ['module'], $modules_exempt_from_availability_check)) |
|
275 | 275 | { |
276 | - $this->sub_subpanels [ $panel ] = new aSubPanel ( $panel, $properties, $this->parent_bean, false, false, $this->search_query ) ; |
|
276 | + $this->sub_subpanels [$panel] = new aSubPanel($panel, $properties, $this->parent_bean, false, false, $this->search_query); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | // if it's empty just dump out as there is nothing to process. |
280 | - if(empty($this->sub_subpanels)) return false; |
|
280 | + if (empty($this->sub_subpanels)) return false; |
|
281 | 281 | //Sync displayed list fields across the subpanels |
282 | 282 | $display_fields = $this->getDisplayFieldsFromCollection($this->sub_subpanels); |
283 | 283 | $query_fields = array(); |
284 | - foreach ( $this->sub_subpanels as $key => $subpanel ) |
|
284 | + foreach ($this->sub_subpanels as $key => $subpanel) |
|
285 | 285 | { |
286 | 286 | $list_fields = $subpanel->get_list_fields(); |
287 | 287 | $listFieldMap[$key] = array(); |
288 | 288 | $index = 0; |
289 | - foreach($list_fields as $field => $def) |
|
289 | + foreach ($list_fields as $field => $def) |
|
290 | 290 | { |
291 | 291 | if (isset($def['vname']) && isset($def['width'])) |
292 | 292 | { |
293 | 293 | $index++; |
294 | - if(!empty($def['alias'])) |
|
294 | + if (!empty($def['alias'])) |
|
295 | 295 | $listFieldMap[$key][$def['alias']] = $field; |
296 | 296 | else |
297 | 297 | $listFieldMap[$key][$field] = $field; |
298 | 298 | if (!isset($display_fields[$def['vname']])) |
299 | 299 | { |
300 | - if(sizeof($display_fields) > $index) |
|
300 | + if (sizeof($display_fields) > $index) |
|
301 | 301 | { |
302 | 302 | //Try to insert the new field in an order that makes sense |
303 | 303 | $start = array_slice($display_fields, 0, $index); |
304 | 304 | $end = array_slice($display_fields, $index); |
305 | 305 | $display_fields = array_merge( |
306 | 306 | $start, |
307 | - array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )), |
|
307 | + array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'])), |
|
308 | 308 | $end |
309 | 309 | ); |
310 | 310 | } else |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
324 | - foreach ( $this->sub_subpanels as $key => $subpanel ) |
|
324 | + foreach ($this->sub_subpanels as $key => $subpanel) |
|
325 | 325 | { |
326 | 326 | $list_fields = array(); |
327 | - foreach($display_fields as $vname => $def) |
|
327 | + foreach ($display_fields as $vname => $def) |
|
328 | 328 | { |
329 | 329 | $field = $def['name']; |
330 | 330 | $list_key = isset($listFieldMap[$key][$field]) ? $listFieldMap[$key][$field] : $field; |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $list_fields[$field] = $display_fields[$vname]; |
343 | 343 | } |
344 | 344 | } |
345 | - foreach($query_fields as $field => $def) |
|
345 | + foreach ($query_fields as $field => $def) |
|
346 | 346 | { |
347 | 347 | if (isset($subpanel->panel_definition['list_fields'][$field])) |
348 | 348 | { |
@@ -362,25 +362,25 @@ discard block |
||
362 | 362 | protected function getDisplayFieldsFromCollection($sub_subpanels) |
363 | 363 | { |
364 | 364 | $display_fields = array(); |
365 | - foreach ($sub_subpanels as $key => $subpanel ) |
|
365 | + foreach ($sub_subpanels as $key => $subpanel) |
|
366 | 366 | { |
367 | 367 | $list_fields = $subpanel->get_list_fields(); |
368 | 368 | $index = 0; |
369 | - foreach($list_fields as $field => $def) |
|
369 | + foreach ($list_fields as $field => $def) |
|
370 | 370 | { |
371 | 371 | if (isset($def['vname']) && isset($def['width'])) |
372 | 372 | { |
373 | 373 | $index++; |
374 | 374 | if (!isset($display_fields[$def['vname']])) |
375 | 375 | { |
376 | - if(sizeof($display_fields) > $index) |
|
376 | + if (sizeof($display_fields) > $index) |
|
377 | 377 | { |
378 | 378 | //Try to insert the new field in an order that makes sense |
379 | 379 | $start = array_slice($display_fields, 0, $index); |
380 | 380 | $end = array_slice($display_fields, $index); |
381 | 381 | $display_fields = array_merge( |
382 | 382 | $start, |
383 | - array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'] )), |
|
383 | + array($def['vname'] => array('name' => $field, 'vname' => $def['vname'], 'width' => $def['width'])), |
|
384 | 384 | $end |
385 | 385 | ); |
386 | 386 | } else |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
400 | - function isDatasourceFunction () |
|
400 | + function isDatasourceFunction() |
|
401 | 401 | { |
402 | - if (strpos ( $this->get_inst_prop_value ( 'get_subpanel_data' ), 'function' ) === false) |
|
402 | + if (strpos($this->get_inst_prop_value('get_subpanel_data'), 'function') === false) |
|
403 | 403 | { |
404 | - return false ; |
|
404 | + return false; |
|
405 | 405 | } |
406 | - return true ; |
|
406 | + return true; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -411,159 +411,159 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return bool |
413 | 413 | */ |
414 | - function isCollection () |
|
414 | + function isCollection() |
|
415 | 415 | { |
416 | - return ($this->get_inst_prop_value ( 'type' ) == 'collection'); |
|
416 | + return ($this->get_inst_prop_value('type') == 'collection'); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | //get value of a property defined at the panel instance level. |
420 | - function get_inst_prop_value ( $name ) |
|
420 | + function get_inst_prop_value($name) |
|
421 | 421 | { |
422 | - return isset($this->_instance_properties[$name]) ? $this->_instance_properties [ $name ] : null; |
|
422 | + return isset($this->_instance_properties[$name]) ? $this->_instance_properties [$name] : null; |
|
423 | 423 | } |
424 | 424 | //get value of a property defined at the panel definition level. |
425 | - function get_def_prop_value ( $name ) |
|
425 | + function get_def_prop_value($name) |
|
426 | 426 | { |
427 | - if (isset ( $this->panel_definition [ $name ] )) |
|
427 | + if (isset ($this->panel_definition [$name])) |
|
428 | 428 | { |
429 | - return $this->panel_definition [ $name ] ; |
|
429 | + return $this->panel_definition [$name]; |
|
430 | 430 | } else |
431 | 431 | { |
432 | - return null ; |
|
432 | + return null; |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | 436 | //if datasource is of the type function then return the function name |
437 | 437 | //else return the value as is. |
438 | - function get_function_parameters () |
|
438 | + function get_function_parameters() |
|
439 | 439 | { |
440 | - $parameters = array ( ) ; |
|
441 | - if ($this->isDatasourceFunction ()) |
|
440 | + $parameters = array( ); |
|
441 | + if ($this->isDatasourceFunction()) |
|
442 | 442 | { |
443 | - $parameters = $this->get_inst_prop_value ( 'function_parameters' ) ; |
|
443 | + $parameters = $this->get_inst_prop_value('function_parameters'); |
|
444 | 444 | } |
445 | - return $parameters ; |
|
445 | + return $parameters; |
|
446 | 446 | } |
447 | 447 | |
448 | - function get_data_source_name ( $check_set_subpanel_data = false ) |
|
448 | + function get_data_source_name($check_set_subpanel_data = false) |
|
449 | 449 | { |
450 | - $prop_value = null ; |
|
450 | + $prop_value = null; |
|
451 | 451 | if ($check_set_subpanel_data) |
452 | 452 | { |
453 | - $prop_value = $this->get_inst_prop_value ( 'set_subpanel_data' ) ; |
|
453 | + $prop_value = $this->get_inst_prop_value('set_subpanel_data'); |
|
454 | 454 | } |
455 | - if (! empty ( $prop_value )) |
|
455 | + if (!empty ($prop_value)) |
|
456 | 456 | { |
457 | - return $prop_value ; |
|
457 | + return $prop_value; |
|
458 | 458 | } else |
459 | 459 | { |
460 | 460 | //fall back to default behavior. |
461 | 461 | } |
462 | - if ($this->isDatasourceFunction ()) |
|
462 | + if ($this->isDatasourceFunction()) |
|
463 | 463 | { |
464 | - return (substr_replace ( $this->get_inst_prop_value ( 'get_subpanel_data' ), '', 0, 9 )) ; |
|
464 | + return (substr_replace($this->get_inst_prop_value('get_subpanel_data'), '', 0, 9)); |
|
465 | 465 | } else |
466 | 466 | { |
467 | - return $this->get_inst_prop_value ( 'get_subpanel_data' ) ; |
|
467 | + return $this->get_inst_prop_value('get_subpanel_data'); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
471 | 471 | //returns the where clause for the query. |
472 | - function get_where () |
|
472 | + function get_where() |
|
473 | 473 | { |
474 | - if($this->get_def_prop_value ( 'where' ) != '' && $this->search_query != ''){ |
|
475 | - return $this->get_def_prop_value ( 'where' ).' AND '.$this->search_query; |
|
476 | - } else if($this->search_query != ''){ |
|
474 | + if ($this->get_def_prop_value('where') != '' && $this->search_query != '') { |
|
475 | + return $this->get_def_prop_value('where').' AND '.$this->search_query; |
|
476 | + } else if ($this->search_query != '') { |
|
477 | 477 | return $this->search_query; |
478 | 478 | } |
479 | - return $this->get_def_prop_value ( 'where' ) ; |
|
479 | + return $this->get_def_prop_value('where'); |
|
480 | 480 | } |
481 | 481 | |
482 | - function is_fill_in_additional_fields () |
|
482 | + function is_fill_in_additional_fields() |
|
483 | 483 | { |
484 | 484 | // do both. inst_prop returns values from metadata/subpaneldefs.php and def_prop returns from subpanel/default.php |
485 | - $temp = $this->get_inst_prop_value ( 'fill_in_additional_fields' ) || $this->get_def_prop_value ( 'fill_in_additional_fields' ) ; |
|
486 | - return $temp ; |
|
485 | + $temp = $this->get_inst_prop_value('fill_in_additional_fields') || $this->get_def_prop_value('fill_in_additional_fields'); |
|
486 | + return $temp; |
|
487 | 487 | } |
488 | 488 | |
489 | - function get_list_fields () |
|
489 | + function get_list_fields() |
|
490 | 490 | { |
491 | - if (isset ( $this->panel_definition [ 'list_fields' ] )) |
|
491 | + if (isset ($this->panel_definition ['list_fields'])) |
|
492 | 492 | { |
493 | - return $this->panel_definition [ 'list_fields' ] ; |
|
493 | + return $this->panel_definition ['list_fields']; |
|
494 | 494 | } else |
495 | 495 | { |
496 | - return array ( ) ; |
|
496 | + return array( ); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - function get_module_name () |
|
500 | + function get_module_name() |
|
501 | 501 | { |
502 | - return $this->get_inst_prop_value ( 'module' ) ; |
|
502 | + return $this->get_inst_prop_value('module'); |
|
503 | 503 | } |
504 | 504 | |
505 | - function get_name () |
|
505 | + function get_name() |
|
506 | 506 | { |
507 | - return $this->name ; |
|
507 | + return $this->name; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | //load subpanel module's table name and column fields. |
511 | - function load_module_info () |
|
511 | + function load_module_info() |
|
512 | 512 | { |
513 | - global $beanList ; |
|
514 | - global $beanFiles ; |
|
513 | + global $beanList; |
|
514 | + global $beanFiles; |
|
515 | 515 | |
516 | - $module_name = $this->get_module_name () ; |
|
517 | - if (! empty ( $module_name )) |
|
516 | + $module_name = $this->get_module_name(); |
|
517 | + if (!empty ($module_name)) |
|
518 | 518 | { |
519 | 519 | |
520 | - $bean_name = $beanList [ $this->get_module_name () ] ; |
|
520 | + $bean_name = $beanList [$this->get_module_name()]; |
|
521 | 521 | |
522 | - $this->bean_name = $bean_name ; |
|
522 | + $this->bean_name = $bean_name; |
|
523 | 523 | |
524 | - include_once ($beanFiles [ $bean_name ]) ; |
|
525 | - $this->template_instance = new $bean_name ( ) ; |
|
526 | - $this->template_instance->force_load_details = true ; |
|
527 | - $this->table_name = $this->template_instance->table_name ; |
|
524 | + include_once ($beanFiles [$bean_name]); |
|
525 | + $this->template_instance = new $bean_name( ); |
|
526 | + $this->template_instance->force_load_details = true; |
|
527 | + $this->table_name = $this->template_instance->table_name; |
|
528 | 528 | //$this->db_fields=$this->template_instance->column_fields; |
529 | 529 | } |
530 | 530 | } |
531 | 531 | //this function is to be used only with sub-panels that are based |
532 | 532 | //on collections. |
533 | - function get_header_panel_def () |
|
533 | + function get_header_panel_def() |
|
534 | 534 | { |
535 | - if (! empty ( $this->sub_subpanels )) |
|
535 | + if (!empty ($this->sub_subpanels)) |
|
536 | 536 | { |
537 | - if (! empty ( $this->_instance_properties [ 'header_definition_from_subpanel' ] ) && ! empty ( $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] )) |
|
537 | + if (!empty ($this->_instance_properties ['header_definition_from_subpanel']) && !empty ($this->sub_subpanels [$this->_instance_properties ['header_definition_from_subpanel']])) |
|
538 | 538 | { |
539 | - return $this->sub_subpanels [ $this->_instance_properties [ 'header_definition_from_subpanel' ] ] ; |
|
539 | + return $this->sub_subpanels [$this->_instance_properties ['header_definition_from_subpanel']]; |
|
540 | 540 | } else |
541 | 541 | { |
542 | 542 | $display_fields = array(); |
543 | 543 | //If we are not pulling from a specific subpanel, create a list of all list fields and use that. |
544 | - foreach($this->sub_subpanels as $subpanel) |
|
544 | + foreach ($this->sub_subpanels as $subpanel) |
|
545 | 545 | { |
546 | 546 | $list_fields = $subpanel->get_list_fields(); |
547 | - foreach($list_fields as $field => $def) |
|
547 | + foreach ($list_fields as $field => $def) |
|
548 | 548 | { |
549 | 549 | |
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - reset ( $this->sub_subpanels ) ; |
|
554 | - return current ( $this->sub_subpanels ) ; |
|
553 | + reset($this->sub_subpanels); |
|
554 | + return current($this->sub_subpanels); |
|
555 | 555 | } |
556 | 556 | } |
557 | - return null ; |
|
557 | + return null; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
561 | 561 | * Returns an array of current properties of the class. |
562 | 562 | * It will simply give the class name for instances of classes. |
563 | 563 | */ |
564 | - function _to_array () |
|
564 | + function _to_array() |
|
565 | 565 | { |
566 | - return array ( '_instance_properties' => $this->_instance_properties , 'db_fields' => $this->db_fields , 'mod_strings' => $this->mod_strings , 'name' => $this->name , 'panel_definition' => $this->panel_definition , 'parent_bean' => get_class ( $this->parent_bean ) , 'sub_subpanels' => $this->sub_subpanels , 'table_name' => $this->table_name , 'template_instance' => get_class ( $this->template_instance ) ) ; |
|
566 | + return array('_instance_properties' => $this->_instance_properties, 'db_fields' => $this->db_fields, 'mod_strings' => $this->mod_strings, 'name' => $this->name, 'panel_definition' => $this->panel_definition, 'parent_bean' => get_class($this->parent_bean), 'sub_subpanels' => $this->sub_subpanels, 'table_name' => $this->table_name, 'template_instance' => get_class($this->template_instance)); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -582,10 +582,10 @@ discard block |
||
582 | 582 | class SubPanelDefinitions |
583 | 583 | { |
584 | 584 | |
585 | - var $_focus ; |
|
586 | - var $_visible_tabs_array ; |
|
587 | - var $panels ; |
|
588 | - var $layout_defs ; |
|
585 | + var $_focus; |
|
586 | + var $_visible_tabs_array; |
|
587 | + var $panels; |
|
588 | + var $layout_defs; |
|
589 | 589 | |
590 | 590 | /** |
591 | 591 | * Enter description here... |
@@ -595,16 +595,16 @@ discard block |
||
595 | 595 | * @param ARRAY $layout_def_override - if you wish to override the default loaded layout defs you pass them in here. |
596 | 596 | * @return SubPanelDefinitions |
597 | 597 | */ |
598 | - function __construct ( $focus , $layout_def_key = '' , $layout_def_override = '' ) |
|
598 | + function __construct($focus, $layout_def_key = '', $layout_def_override = '') |
|
599 | 599 | { |
600 | - $this->_focus = $focus ; |
|
601 | - if (! empty ( $layout_def_override )) |
|
600 | + $this->_focus = $focus; |
|
601 | + if (!empty ($layout_def_override)) |
|
602 | 602 | { |
603 | - $this->layout_defs = $layout_def_override ; |
|
603 | + $this->layout_defs = $layout_def_override; |
|
604 | 604 | |
605 | 605 | } else |
606 | 606 | { |
607 | - $this->open_layout_defs ( false, $layout_def_key ) ; |
|
607 | + $this->open_layout_defs(false, $layout_def_key); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
@@ -619,68 +619,68 @@ discard block |
||
619 | 619 | * @param boolean Optional - include the subpanel title label in the return array (false) |
620 | 620 | * @return array All tabs that pass an ACL check |
621 | 621 | */ |
622 | - function get_available_tabs ($FromGetModuleSubpanels=false) |
|
622 | + function get_available_tabs($FromGetModuleSubpanels = false) |
|
623 | 623 | { |
624 | - global $modListHeader ; |
|
625 | - global $modules_exempt_from_availability_check ; |
|
624 | + global $modListHeader; |
|
625 | + global $modules_exempt_from_availability_check; |
|
626 | 626 | |
627 | - if (isset ( $this->_visible_tabs_array )) |
|
628 | - return $this->_visible_tabs_array ; |
|
627 | + if (isset ($this->_visible_tabs_array)) |
|
628 | + return $this->_visible_tabs_array; |
|
629 | 629 | |
630 | 630 | if (empty($modListHeader)) |
631 | 631 | $modListHeader = query_module_access_list($GLOBALS['current_user']); |
632 | 632 | |
633 | - $this->_visible_tabs_array = array ( ) ; // bug 16820 - make sure this is an array for the later ksort |
|
633 | + $this->_visible_tabs_array = array( ); // bug 16820 - make sure this is an array for the later ksort |
|
634 | 634 | |
635 | - if (isset ( $this->layout_defs [ 'subpanel_setup' ] )) // bug 17434 - belts-and-braces - check that we have some subpanels first |
|
635 | + if (isset ($this->layout_defs ['subpanel_setup'])) // bug 17434 - belts-and-braces - check that we have some subpanels first |
|
636 | 636 | { |
637 | 637 | //retrieve list of hidden subpanels |
638 | 638 | $hidden_panels = $this->get_hidden_subpanels(); |
639 | 639 | |
640 | 640 | //activities is a special use case in that if it is hidden, |
641 | 641 | //then the history tab should be hidden too. |
642 | - if(!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities',$hidden_panels)){ |
|
642 | + if (!empty($hidden_panels) && is_array($hidden_panels) && in_array('activities', $hidden_panels)) { |
|
643 | 643 | //add history to list hidden_panels |
644 | 644 | $hidden_panels['history'] = 'history'; |
645 | 645 | } |
646 | 646 | |
647 | - foreach ( $this->layout_defs [ 'subpanel_setup' ] as $key => $values_array ) |
|
647 | + foreach ($this->layout_defs ['subpanel_setup'] as $key => $values_array) |
|
648 | 648 | { |
649 | 649 | //exclude if this subpanel is hidden from admin screens |
650 | 650 | $module = $key; |
651 | - if ( isset($values_array['module']) ) |
|
651 | + if (isset($values_array['module'])) |
|
652 | 652 | $module = strtolower($values_array['module']); |
653 | - if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels)) ){ |
|
653 | + if ($hidden_panels && is_array($hidden_panels) && (in_array($module, $hidden_panels) || array_key_exists($module, $hidden_panels))) { |
|
654 | 654 | //this panel is hidden, skip it |
655 | 655 | continue; |
656 | 656 | } |
657 | 657 | |
658 | 658 | // make sure the module attribute is set, else none of this works... |
659 | - if ( !isset($values_array [ 'module' ])) { |
|
660 | - $GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>" . var_export($values_array,true) . " - ingoring subpanel defintion") ; |
|
659 | + if (!isset($values_array ['module'])) { |
|
660 | + $GLOBALS['log']->debug("SubPanelDefinitions->get_available_tabs(): no module defined in subpaneldefs for '$key' =>".var_export($values_array, true)." - ingoring subpanel defintion"); |
|
661 | 661 | continue; |
662 | 662 | } |
663 | 663 | |
664 | 664 | //check permissions. |
665 | - $exempt = array_key_exists ( $values_array [ 'module' ], $modules_exempt_from_availability_check ) ; |
|
666 | - $ok = $exempt || ( (! ACLController::moduleSupportsACL ( $values_array [ 'module' ] ) || ACLController::checkAccess ( $values_array [ 'module' ], 'list', true ) ) ) ; |
|
665 | + $exempt = array_key_exists($values_array ['module'], $modules_exempt_from_availability_check); |
|
666 | + $ok = $exempt || ((!ACLController::moduleSupportsACL($values_array ['module']) || ACLController::checkAccess($values_array ['module'], 'list', true))); |
|
667 | 667 | |
668 | - $GLOBALS [ 'log' ]->debug ( "SubPanelDefinitions->get_available_tabs(): " . $key . "= " . ( $exempt ? "exempt " : "not exempt " .( $ok ? " ACL OK" : "" ) ) ) ; |
|
668 | + $GLOBALS ['log']->debug("SubPanelDefinitions->get_available_tabs(): ".$key."= ".($exempt ? "exempt " : "not exempt ".($ok ? " ACL OK" : ""))); |
|
669 | 669 | |
670 | - if ( $ok ) |
|
670 | + if ($ok) |
|
671 | 671 | { |
672 | - while ( ! empty ( $this->_visible_tabs_array [ $values_array [ 'order' ] ] ) ) |
|
672 | + while (!empty ($this->_visible_tabs_array [$values_array ['order']])) |
|
673 | 673 | { |
674 | - $values_array [ 'order' ] ++ ; |
|
674 | + $values_array ['order']++; |
|
675 | 675 | } |
676 | 676 | |
677 | - $this->_visible_tabs_array [ $values_array ['order'] ] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key ; |
|
677 | + $this->_visible_tabs_array [$values_array ['order']] = ($FromGetModuleSubpanels) ? array($key=>$values_array['title_key']) : $key; |
|
678 | 678 | } |
679 | 679 | } |
680 | 680 | } |
681 | 681 | |
682 | - ksort ( $this->_visible_tabs_array ) ; |
|
683 | - return $this->_visible_tabs_array ; |
|
682 | + ksort($this->_visible_tabs_array); |
|
683 | + return $this->_visible_tabs_array; |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -694,15 +694,15 @@ discard block |
||
694 | 694 | * @return boolean|aSubPanel Returns aSubPanel object or boolean false if one is not found or it can't be |
695 | 695 | * displayed due to ACL reasons. |
696 | 696 | */ |
697 | - function load_subpanel ( $name , $reload = false , $original_only = false, $search_query = '', $collections = array() ) |
|
697 | + function load_subpanel($name, $reload = false, $original_only = false, $search_query = '', $collections = array()) |
|
698 | 698 | { |
699 | - if (!is_dir('modules/' . $this->layout_defs [ 'subpanel_setup' ][ strtolower ( $name ) ] [ 'module' ])) |
|
699 | + if (!is_dir('modules/'.$this->layout_defs ['subpanel_setup'][strtolower($name)] ['module'])) |
|
700 | 700 | return false; |
701 | 701 | |
702 | - $subpanel = new aSubPanel ( $name, $this->layout_defs [ 'subpanel_setup' ] [ strtolower ( $name ) ], $this->_focus, $reload, $original_only, $search_query, $collections ) ; |
|
702 | + $subpanel = new aSubPanel($name, $this->layout_defs ['subpanel_setup'] [strtolower($name)], $this->_focus, $reload, $original_only, $search_query, $collections); |
|
703 | 703 | |
704 | 704 | // only return the subpanel object if we can display it. |
705 | - if($subpanel->canDisplay == true) { |
|
705 | + if ($subpanel->canDisplay == true) { |
|
706 | 706 | return $subpanel; |
707 | 707 | } |
708 | 708 | |
@@ -713,23 +713,23 @@ discard block |
||
713 | 713 | /** |
714 | 714 | * Load the layout def file and associate the definition with a variable in the file. |
715 | 715 | */ |
716 | - function open_layout_defs ( $reload = false , $layout_def_key = '' , $original_only = false ) |
|
716 | + function open_layout_defs($reload = false, $layout_def_key = '', $original_only = false) |
|
717 | 717 | { |
718 | - $layout_defs [ $this->_focus->module_dir ] = array ( ) ; |
|
719 | - $layout_defs [ $layout_def_key ] = array ( ) ; |
|
718 | + $layout_defs [$this->_focus->module_dir] = array( ); |
|
719 | + $layout_defs [$layout_def_key] = array( ); |
|
720 | 720 | |
721 | - if (empty ( $this->layout_defs ) || $reload || (! empty ( $layout_def_key ) && ! isset ( $layout_defs [ $layout_def_key ] ))) |
|
721 | + if (empty ($this->layout_defs) || $reload || (!empty ($layout_def_key) && !isset ($layout_defs [$layout_def_key]))) |
|
722 | 722 | { |
723 | - if (file_exists ( 'modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php' )) |
|
724 | - require ('modules/' . $this->_focus->module_dir . '/metadata/subpaneldefs.php') ; |
|
723 | + if (file_exists('modules/'.$this->_focus->module_dir.'/metadata/subpaneldefs.php')) |
|
724 | + require ('modules/'.$this->_focus->module_dir.'/metadata/subpaneldefs.php'); |
|
725 | 725 | |
726 | - if (! $original_only && file_exists ( 'custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php' )) |
|
727 | - require ('custom/modules/' . $this->_focus->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php') ; |
|
726 | + if (!$original_only && file_exists('custom/modules/'.$this->_focus->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
727 | + require ('custom/modules/'.$this->_focus->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
728 | 728 | |
729 | - if (! empty ( $layout_def_key )) |
|
730 | - $this->layout_defs = $layout_defs [ $layout_def_key ] ; |
|
729 | + if (!empty ($layout_def_key)) |
|
730 | + $this->layout_defs = $layout_defs [$layout_def_key]; |
|
731 | 731 | else |
732 | - $this->layout_defs = $layout_defs [ $this->_focus->module_dir ] ; |
|
732 | + $this->layout_defs = $layout_defs [$this->_focus->module_dir]; |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | |
@@ -740,24 +740,24 @@ discard block |
||
740 | 740 | * Returns true if successful, false otherwise. |
741 | 741 | * Hint: Used by Campaign's DetailView. |
742 | 742 | */ |
743 | - function exclude_tab ( $tab_name ) |
|
743 | + function exclude_tab($tab_name) |
|
744 | 744 | { |
745 | - $result = false ; |
|
745 | + $result = false; |
|
746 | 746 | //unset layout definition |
747 | - if (! empty ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] )) |
|
747 | + if (!empty ($this->layout_defs ['subpanel_setup'] [$tab_name])) |
|
748 | 748 | { |
749 | - unset ( $this->layout_defs [ 'subpanel_setup' ] [ $tab_name ] ) ; |
|
749 | + unset ($this->layout_defs ['subpanel_setup'] [$tab_name]); |
|
750 | 750 | } |
751 | 751 | //unset instance from _visible_tab_array |
752 | - if (! empty ( $this->_visible_tabs_array )) |
|
752 | + if (!empty ($this->_visible_tabs_array)) |
|
753 | 753 | { |
754 | - $key = array_search ( $tab_name, $this->_visible_tabs_array ) ; |
|
754 | + $key = array_search($tab_name, $this->_visible_tabs_array); |
|
755 | 755 | if ($key !== false) |
756 | 756 | { |
757 | - unset ( $this->_visible_tabs_array [ $key ] ) ; |
|
757 | + unset ($this->_visible_tabs_array [$key]); |
|
758 | 758 | } |
759 | 759 | } |
760 | - return $result ; |
|
760 | + return $result; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * return all available subpanels that belong to the list of tab modules. You can optionally return all |
766 | 766 | * available subpanels, and also optionally group by module (prepends the key with the bean class name). |
767 | 767 | */ |
768 | - function get_all_subpanels( $return_tab_modules_only = true, $group_by_module = false ) |
|
768 | + function get_all_subpanels($return_tab_modules_only = true, $group_by_module = false) |
|
769 | 769 | { |
770 | 770 | global $moduleList, $beanFiles, $beanList, $module; |
771 | 771 | |
@@ -782,36 +782,36 @@ discard block |
||
782 | 782 | $spd = ''; |
783 | 783 | $spd_arr = array(); |
784 | 784 | //iterate through modules and build subpanel array |
785 | - foreach($modules_to_check as $mod_name){ |
|
785 | + foreach ($modules_to_check as $mod_name) { |
|
786 | 786 | |
787 | 787 | //skip if module name is not in bean list, otherwise get the bean class name |
788 | - if(!isset($beanList[$mod_name])) continue; |
|
788 | + if (!isset($beanList[$mod_name])) continue; |
|
789 | 789 | $class = $beanList[$mod_name]; |
790 | 790 | |
791 | 791 | //skip if class name is not in file list, otherwise require the bean file and create new class |
792 | - if(!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue; |
|
792 | + if (!isset($beanFiles[$class]) || !file_exists($beanFiles[$class])) continue; |
|
793 | 793 | |
794 | 794 | //retrieve subpanels for this bean |
795 | 795 | require_once($beanFiles[$class]); |
796 | 796 | $bean_class = new $class(); |
797 | 797 | |
798 | 798 | //create new subpanel definition instance and get list of tabs |
799 | - $spd = new SubPanelDefinitions($bean_class) ; |
|
799 | + $spd = new SubPanelDefinitions($bean_class); |
|
800 | 800 | $sub_tabs = $spd->get_available_tabs(); |
801 | 801 | |
802 | 802 | //add each subpanel to array of total subpanles |
803 | - foreach( $sub_tabs as $panel_key){ |
|
803 | + foreach ($sub_tabs as $panel_key) { |
|
804 | 804 | $panel_key = strtolower($panel_key); |
805 | 805 | $panel_module = $panel_key; |
806 | - if ( isset($spd->layout_defs['subpanel_setup'][$panel_key]['module']) ) |
|
806 | + if (isset($spd->layout_defs['subpanel_setup'][$panel_key]['module'])) |
|
807 | 807 | $panel_module = strtolower($spd->layout_defs['subpanel_setup'][$panel_key]['module']); |
808 | 808 | //if module_only flag is set, only if it is also in module array |
809 | - if($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue; |
|
809 | + if ($return_tab_modules_only && !array_key_exists($panel_module, $modules_to_check)) continue; |
|
810 | 810 | $panel_key_name = $panel_module; |
811 | 811 | |
812 | 812 | //group_by_key_name is set to true, then array will hold an entry for each |
813 | 813 | //subpanel, with the module name prepended in the key |
814 | - if($group_by_module) $panel_key_name = $class.'_'.$panel_key_name; |
|
814 | + if ($group_by_module) $panel_key_name = $class.'_'.$panel_key_name; |
|
815 | 815 | //add panel name to subpanel array |
816 | 816 | $spd_arr[$panel_key_name] = $panel_module; |
817 | 817 | } |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | /* |
823 | 823 | * save array of hidden panels to mysettings category in config table |
824 | 824 | */ |
825 | - function set_hidden_subpanels($panels){ |
|
825 | + function set_hidden_subpanels($panels) { |
|
826 | 826 | $administration = new Administration(); |
827 | 827 | $serialized = base64_encode(serialize($panels)); |
828 | 828 | $administration->saveSetting('MySettings', 'hide_subpanels', $serialized); |
@@ -831,26 +831,26 @@ discard block |
||
831 | 831 | /* |
832 | 832 | * retrieve hidden subpanels |
833 | 833 | */ |
834 | - function get_hidden_subpanels(){ |
|
834 | + function get_hidden_subpanels() { |
|
835 | 835 | global $moduleList; |
836 | 836 | |
837 | 837 | //create variable as static to minimize queries |
838 | 838 | static $hidden_subpanels = null; |
839 | 839 | |
840 | 840 | // if the static value is not already cached, then retrieve it. |
841 | - if(empty($hidden_subpanels)) |
|
841 | + if (empty($hidden_subpanels)) |
|
842 | 842 | { |
843 | 843 | |
844 | 844 | //create Administration object and retrieve any settings for panels |
845 | 845 | $administration = new Administration(); |
846 | 846 | $administration->retrieveSettings('MySettings'); |
847 | 847 | |
848 | - if(isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])){ |
|
848 | + if (isset($administration->settings) && isset($administration->settings['MySettings_hide_subpanels'])) { |
|
849 | 849 | $hidden_subpanels = $administration->settings['MySettings_hide_subpanels']; |
850 | 850 | $hidden_subpanels = trim($hidden_subpanels); |
851 | 851 | |
852 | 852 | //make sure serialized string is not empty |
853 | - if (!empty($hidden_subpanels)){ |
|
853 | + if (!empty($hidden_subpanels)) { |
|
854 | 854 | //decode and unserialize to retrieve the array |
855 | 855 | $hidden_subpanels = base64_decode($hidden_subpanels); |
856 | 856 | $hidden_subpanels = unserialize($hidden_subpanels); |
@@ -859,12 +859,12 @@ discard block |
||
859 | 859 | //get user preference |
860 | 860 | //unserialize and add to array if not empty |
861 | 861 | $pref_hidden = array(); |
862 | - foreach($pref_hidden as $id => $pref_hidden_panel) { |
|
862 | + foreach ($pref_hidden as $id => $pref_hidden_panel) { |
|
863 | 863 | $hidden_subpanels[] = $pref_hidden_panel; |
864 | 864 | } |
865 | 865 | |
866 | 866 | |
867 | - }else{ |
|
867 | + } else { |
|
868 | 868 | //no settings found, return empty |
869 | 869 | return $hidden_subpanels; |
870 | 870 | } |
@@ -1,5 +1,7 @@ discard block |
||
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. |
@@ -141,8 +143,7 @@ discard block |
||
141 | 143 | if(empty($widget_data['widget_class'])) |
142 | 144 | { |
143 | 145 | $widget_contents .= "widget_class not defined for top subpanel buttons"; |
144 | - } |
|
145 | - else |
|
146 | + } else |
|
146 | 147 | { |
147 | 148 | $widget_contents .= $layout_manager->widgetDisplay($widget_data); |
148 | 149 | } |
@@ -163,7 +164,7 @@ discard block |
||
163 | 164 | |
164 | 165 | if(isset($this->listview)){ |
165 | 166 | $ListView =& $this->listview; |
166 | - }else{ |
|
167 | + } else{ |
|
167 | 168 | $ListView = new ListView(); |
168 | 169 | } |
169 | 170 | $ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings); |
@@ -178,7 +179,9 @@ discard block |
||
178 | 179 | $ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id); |
179 | 180 | $ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm()); |
180 | 181 | $display_sps = ''; |
181 | - if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none'; |
|
182 | + if($this->search_query == '' && empty($this->collections)) { |
|
183 | + $display_sps = 'display:none'; |
|
184 | + } |
|
182 | 185 | $ListView->xTemplateAssign("DISPLAY_SPS",$display_sps); |
183 | 186 | |
184 | 187 | if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) |
@@ -311,10 +314,12 @@ discard block |
||
311 | 314 | $moduleInstaller = new ModuleInstaller(); |
312 | 315 | $moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs |
313 | 316 | $moduleInstaller->rebuild_layoutdefs(); |
314 | - if (file_exists('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php')) |
|
315 | - include('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php'); |
|
316 | - if (file_exists('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
317 | - include('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
317 | + if (file_exists('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php')) { |
|
318 | + include('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php'); |
|
319 | + } |
|
320 | + if (file_exists('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) { |
|
321 | + include('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
322 | + } |
|
318 | 323 | } |
319 | 324 | |
320 | 325 | function get_subpanel_setup($module) |
@@ -400,7 +405,9 @@ discard block |
||
400 | 405 | |
401 | 406 | $where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir); |
402 | 407 | |
403 | - if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')'; |
|
408 | + if (count($where_clauses) > 0 ) { |
|
409 | + $this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')'; |
|
410 | + } |
|
404 | 411 | $GLOBALS['log']->info("Subpanel Where Clause: $this->search_query"); |
405 | 412 | |
406 | 413 | return print_r($where_clauses,true); |
@@ -436,8 +443,9 @@ discard block |
||
436 | 443 | |
437 | 444 | $searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search'); |
438 | 445 | |
439 | - if(!empty($this->collections)) |
|
440 | - $searchForm->searchFields['collection'] = array(); |
|
446 | + if(!empty($this->collections)) { |
|
447 | + $searchForm->searchFields['collection'] = array(); |
|
448 | + } |
|
441 | 449 | |
442 | 450 | $searchForm->populateFromRequest(); |
443 | 451 |
@@ -102,6 +102,9 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | + /** |
|
106 | + * @param string $template_file |
|
107 | + */ |
|
105 | 108 | function setTemplateFile($template_file) |
106 | 109 | { |
107 | 110 | $this->template_file = $template_file; |
@@ -271,6 +274,10 @@ discard block |
||
271 | 274 | } |
272 | 275 | |
273 | 276 | //saves overrides for defs |
277 | + |
|
278 | + /** |
|
279 | + * @param string $subsection |
|
280 | + */ |
|
274 | 281 | function saveSubPanelDefOverride( $panel, $subsection, $override){ |
275 | 282 | global $layout_defs, $beanList; |
276 | 283 | |
@@ -406,6 +413,9 @@ discard block |
||
406 | 413 | return print_r($where_clauses,true); |
407 | 414 | } |
408 | 415 | |
416 | + /** |
|
417 | + * @param string $module |
|
418 | + */ |
|
409 | 419 | function get_searchdefs($module) |
410 | 420 | { |
411 | 421 | $thisPanel =& $this->subpanel_defs; |
@@ -45,406 +45,406 @@ |
||
45 | 45 | */ |
46 | 46 | class SubPanel |
47 | 47 | { |
48 | - var $hideNewButton = false; |
|
49 | - var $subpanel_id; |
|
50 | - var $parent_record_id; |
|
51 | - var $parent_module; // the name of the parent module |
|
52 | - var $parent_bean; // the instantiated bean of the parent |
|
53 | - var $template_file; |
|
54 | - var $linked_fields; |
|
55 | - var $action = 'DetailView'; |
|
56 | - var $show_select_button = true; |
|
57 | - var $subpanel_define = null; // contains the layout_def.php |
|
58 | - var $subpanel_defs; |
|
59 | - var $subpanel_query=null; |
|
48 | + var $hideNewButton = false; |
|
49 | + var $subpanel_id; |
|
50 | + var $parent_record_id; |
|
51 | + var $parent_module; // the name of the parent module |
|
52 | + var $parent_bean; // the instantiated bean of the parent |
|
53 | + var $template_file; |
|
54 | + var $linked_fields; |
|
55 | + var $action = 'DetailView'; |
|
56 | + var $show_select_button = true; |
|
57 | + var $subpanel_define = null; // contains the layout_def.php |
|
58 | + var $subpanel_defs; |
|
59 | + var $subpanel_query=null; |
|
60 | 60 | var $layout_def_key=''; |
61 | - var $search_query=''; |
|
62 | - var $collections = array(); |
|
63 | - |
|
64 | - function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() ) |
|
65 | - { |
|
66 | - global $beanList, $beanFiles, $focus, $app_strings; |
|
67 | - |
|
68 | - $this->subpanel_defs=$subpanelDef; |
|
69 | - $this->subpanel_id = $subpanel_id; |
|
70 | - $this->parent_record_id = $record_id; |
|
71 | - $this->parent_module = $module; |
|
72 | - $this->layout_def_key = $layout_def_key; |
|
73 | - $this->collections = $collections; |
|
74 | - |
|
75 | - $this->parent_bean = $focus; |
|
76 | - $result = $focus; |
|
77 | - |
|
78 | - if(empty($result)) |
|
79 | - { |
|
80 | - $parent_bean_name = $beanList[$module]; |
|
81 | - $parent_bean_file = $beanFiles[$parent_bean_name]; |
|
82 | - require_once($parent_bean_file); |
|
83 | - $this->parent_bean = new $parent_bean_name(); |
|
84 | - $this->parent_bean->retrieve($this->parent_record_id); |
|
85 | - $result = $this->parent_bean; |
|
86 | - } |
|
87 | - |
|
88 | - if($record_id!='fab4' && $result == null) |
|
89 | - { |
|
90 | - sugar_die($app_strings['ERROR_NO_RECORD']); |
|
91 | - } |
|
92 | - $this->buildSearchQuery(); |
|
93 | - if (empty($subpanelDef)) { |
|
94 | - //load the subpanel by name. |
|
95 | - if (!class_exists('MyClass')) { |
|
96 | - require_once 'include/SubPanel/SubPanelDefinitions.php' ; |
|
97 | - } |
|
98 | - $panelsdef=new SubPanelDefinitions($result,$layout_def_key); |
|
99 | - $subpanelDef=$panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query,$collections); |
|
100 | - $this->subpanel_defs=$subpanelDef; |
|
101 | - |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - function setTemplateFile($template_file) |
|
106 | - { |
|
107 | - $this->template_file = $template_file; |
|
108 | - } |
|
109 | - |
|
110 | - function setBeanList(&$value){ |
|
111 | - $this->bean_list =$value; |
|
112 | - } |
|
113 | - |
|
114 | - function setHideNewButton($value){ |
|
115 | - $this->hideNewButton = $value; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - function getHeaderText( $currentModule){ |
|
120 | - } |
|
121 | - |
|
122 | - function get_buttons( $panel_query=null) |
|
123 | - { |
|
124 | - |
|
125 | - $thisPanel =& $this->subpanel_defs; |
|
126 | - $subpanel_def = $thisPanel->get_buttons(); |
|
127 | - |
|
128 | - if(!isset($this->listview)){ |
|
129 | - $this->listview = new ListView(); |
|
130 | - } |
|
131 | - $layout_manager = $this->listview->getLayoutManager(); |
|
132 | - $widget_contents = '<div><table cellpadding="0" cellspacing="0"><tr>'; |
|
133 | - foreach($subpanel_def as $widget_data) |
|
134 | - { |
|
135 | - $widget_data['action'] = $_REQUEST['action']; |
|
136 | - $widget_data['module'] = $thisPanel->get_inst_prop_value('module'); |
|
137 | - $widget_data['focus'] = $this->parent_bean; |
|
138 | - $widget_data['subpanel_definition'] = $thisPanel; |
|
139 | - $widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">' . "\n"; |
|
140 | - |
|
141 | - if(empty($widget_data['widget_class'])) |
|
142 | - { |
|
143 | - $widget_contents .= "widget_class not defined for top subpanel buttons"; |
|
144 | - } |
|
145 | - else |
|
146 | - { |
|
147 | - $widget_contents .= $layout_manager->widgetDisplay($widget_data); |
|
148 | - } |
|
149 | - |
|
150 | - $widget_contents .= '</td>'; |
|
151 | - } |
|
152 | - |
|
153 | - $widget_contents .= '</tr></table></div>'; |
|
154 | - return $widget_contents; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - function ProcessSubPanelListView($xTemplatePath, &$mod_strings) |
|
159 | - { |
|
160 | - global $app_strings; |
|
161 | - global $current_user; |
|
162 | - global $sugar_config; |
|
163 | - |
|
164 | - if(isset($this->listview)){ |
|
165 | - $ListView =& $this->listview; |
|
166 | - }else{ |
|
167 | - $ListView = new ListView(); |
|
168 | - } |
|
169 | - $ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings); |
|
170 | - $ListView->xTemplateAssign("RETURN_URL", "&return_module=".$this->parent_module."&return_action=DetailView&return_id=".$this->parent_bean->id); |
|
171 | - $ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module); // TODO: what about unions? |
|
172 | - $ListView->xTemplateAssign("RECORD_ID", $this->parent_bean->id); |
|
173 | - $ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LNK_EDIT'])); |
|
174 | - $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_DELETE_INLINE'])); |
|
175 | - $ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_ID_FF_REMOVE'])); |
|
176 | - $header_text= ''; |
|
177 | - |
|
178 | - $ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id); |
|
179 | - $ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm()); |
|
180 | - $display_sps = ''; |
|
181 | - if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none'; |
|
182 | - $ListView->xTemplateAssign("DISPLAY_SPS",$display_sps); |
|
183 | - |
|
184 | - if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) |
|
185 | - { |
|
186 | - $exploded = explode('/', $xTemplatePath); |
|
187 | - $file_name = $exploded[sizeof($exploded) - 1]; |
|
188 | - $mod_name = $exploded[sizeof($exploded) - 2]; |
|
189 | - $header_text= " <a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang=" |
|
190 | - .$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif','Edit Layout')."</a>"; |
|
191 | - } |
|
192 | - $ListView->setHeaderTitle(''); |
|
193 | - $ListView->setHeaderText(''); |
|
194 | - |
|
195 | - ob_start(); |
|
196 | - |
|
197 | - $ListView->is_dynamic = true; |
|
198 | - $ListView->records_per_page = $sugar_config['list_max_entries_per_subpanel'] + 0; |
|
199 | - if (isset($this->subpanel_defs->_instance_properties['records_per_page'])) { |
|
200 | - $ListView->records_per_page = $this->subpanel_defs->_instance_properties['records_per_page'] + 0; |
|
201 | - } |
|
202 | - $ListView->start_link_wrapper = "javascript:showSubPanel('".$this->subpanel_id."','"; |
|
203 | - $ListView->subpanel_id = $this->subpanel_id; |
|
204 | - $ListView->end_link_wrapper = "',true);"; |
|
205 | - if ( !empty($this->layout_def_key) ) { |
|
206 | - $ListView->end_link_wrapper = '&layout_def_key='.$this->layout_def_key.$ListView->end_link_wrapper; |
|
207 | - } |
|
208 | - |
|
209 | - $where = ''; |
|
210 | - $ListView->setQuery($where, '', '', ''); |
|
211 | - $ListView->show_export_button = false; |
|
212 | - |
|
213 | - //function returns the query that was used to populate sub-panel data. |
|
214 | - |
|
215 | - $query=$ListView->process_dynamic_listview($this->parent_module, $this->parent_bean,$this->subpanel_defs); |
|
216 | - $this->subpanel_query=$query; |
|
217 | - $ob_contents = ob_get_contents(); |
|
218 | - ob_end_clean(); |
|
219 | - return $ob_contents; |
|
220 | - } |
|
221 | - |
|
222 | - function display() |
|
223 | - { |
|
224 | - $result_array = array(); |
|
225 | - |
|
226 | - $return_string = $this->ProcessSubPanelListView($this->template_file,$result_array); |
|
227 | - |
|
228 | - print $return_string; |
|
229 | - } |
|
230 | - |
|
231 | - function getModulesWithSubpanels() |
|
232 | - { |
|
233 | - global $beanList; |
|
234 | - $dir = dir('modules'); |
|
235 | - $modules = array(); |
|
236 | - while($entry = $dir->read()) |
|
237 | - { |
|
238 | - if(file_exists('modules/' . $entry . '/layout_defs.php')) |
|
239 | - { |
|
240 | - $modules[$entry] = $entry; |
|
241 | - } |
|
242 | - } |
|
243 | - return $modules; |
|
244 | - } |
|
245 | - |
|
246 | - static function getModuleSubpanels($module){ |
|
247 | - require_once('include/SubPanel/SubPanelDefinitions.php'); |
|
248 | - global $beanList, $beanFiles; |
|
249 | - if(!isset($beanList[$module])){ |
|
250 | - return array(); |
|
251 | - } |
|
252 | - |
|
253 | - $class = $beanList[$module]; |
|
254 | - require_once($beanFiles[$class]); |
|
255 | - $mod = new $class(); |
|
256 | - $spd = new SubPanelDefinitions($mod); |
|
257 | - $tabs = $spd->get_available_tabs(true); |
|
258 | - $ret_tabs = array(); |
|
259 | - $reject_tabs = array('history'=>1, 'activities'=>1); |
|
260 | - foreach($tabs as $key=>$tab){ |
|
261 | - foreach($tab as $k=>$v){ |
|
61 | + var $search_query=''; |
|
62 | + var $collections = array(); |
|
63 | + |
|
64 | + function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() ) |
|
65 | + { |
|
66 | + global $beanList, $beanFiles, $focus, $app_strings; |
|
67 | + |
|
68 | + $this->subpanel_defs=$subpanelDef; |
|
69 | + $this->subpanel_id = $subpanel_id; |
|
70 | + $this->parent_record_id = $record_id; |
|
71 | + $this->parent_module = $module; |
|
72 | + $this->layout_def_key = $layout_def_key; |
|
73 | + $this->collections = $collections; |
|
74 | + |
|
75 | + $this->parent_bean = $focus; |
|
76 | + $result = $focus; |
|
77 | + |
|
78 | + if(empty($result)) |
|
79 | + { |
|
80 | + $parent_bean_name = $beanList[$module]; |
|
81 | + $parent_bean_file = $beanFiles[$parent_bean_name]; |
|
82 | + require_once($parent_bean_file); |
|
83 | + $this->parent_bean = new $parent_bean_name(); |
|
84 | + $this->parent_bean->retrieve($this->parent_record_id); |
|
85 | + $result = $this->parent_bean; |
|
86 | + } |
|
87 | + |
|
88 | + if($record_id!='fab4' && $result == null) |
|
89 | + { |
|
90 | + sugar_die($app_strings['ERROR_NO_RECORD']); |
|
91 | + } |
|
92 | + $this->buildSearchQuery(); |
|
93 | + if (empty($subpanelDef)) { |
|
94 | + //load the subpanel by name. |
|
95 | + if (!class_exists('MyClass')) { |
|
96 | + require_once 'include/SubPanel/SubPanelDefinitions.php' ; |
|
97 | + } |
|
98 | + $panelsdef=new SubPanelDefinitions($result,$layout_def_key); |
|
99 | + $subpanelDef=$panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query,$collections); |
|
100 | + $this->subpanel_defs=$subpanelDef; |
|
101 | + |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + function setTemplateFile($template_file) |
|
106 | + { |
|
107 | + $this->template_file = $template_file; |
|
108 | + } |
|
109 | + |
|
110 | + function setBeanList(&$value){ |
|
111 | + $this->bean_list =$value; |
|
112 | + } |
|
113 | + |
|
114 | + function setHideNewButton($value){ |
|
115 | + $this->hideNewButton = $value; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + function getHeaderText( $currentModule){ |
|
120 | + } |
|
121 | + |
|
122 | + function get_buttons( $panel_query=null) |
|
123 | + { |
|
124 | + |
|
125 | + $thisPanel =& $this->subpanel_defs; |
|
126 | + $subpanel_def = $thisPanel->get_buttons(); |
|
127 | + |
|
128 | + if(!isset($this->listview)){ |
|
129 | + $this->listview = new ListView(); |
|
130 | + } |
|
131 | + $layout_manager = $this->listview->getLayoutManager(); |
|
132 | + $widget_contents = '<div><table cellpadding="0" cellspacing="0"><tr>'; |
|
133 | + foreach($subpanel_def as $widget_data) |
|
134 | + { |
|
135 | + $widget_data['action'] = $_REQUEST['action']; |
|
136 | + $widget_data['module'] = $thisPanel->get_inst_prop_value('module'); |
|
137 | + $widget_data['focus'] = $this->parent_bean; |
|
138 | + $widget_data['subpanel_definition'] = $thisPanel; |
|
139 | + $widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">' . "\n"; |
|
140 | + |
|
141 | + if(empty($widget_data['widget_class'])) |
|
142 | + { |
|
143 | + $widget_contents .= "widget_class not defined for top subpanel buttons"; |
|
144 | + } |
|
145 | + else |
|
146 | + { |
|
147 | + $widget_contents .= $layout_manager->widgetDisplay($widget_data); |
|
148 | + } |
|
149 | + |
|
150 | + $widget_contents .= '</td>'; |
|
151 | + } |
|
152 | + |
|
153 | + $widget_contents .= '</tr></table></div>'; |
|
154 | + return $widget_contents; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + function ProcessSubPanelListView($xTemplatePath, &$mod_strings) |
|
159 | + { |
|
160 | + global $app_strings; |
|
161 | + global $current_user; |
|
162 | + global $sugar_config; |
|
163 | + |
|
164 | + if(isset($this->listview)){ |
|
165 | + $ListView =& $this->listview; |
|
166 | + }else{ |
|
167 | + $ListView = new ListView(); |
|
168 | + } |
|
169 | + $ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings); |
|
170 | + $ListView->xTemplateAssign("RETURN_URL", "&return_module=".$this->parent_module."&return_action=DetailView&return_id=".$this->parent_bean->id); |
|
171 | + $ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module); // TODO: what about unions? |
|
172 | + $ListView->xTemplateAssign("RECORD_ID", $this->parent_bean->id); |
|
173 | + $ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LNK_EDIT'])); |
|
174 | + $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_DELETE_INLINE'])); |
|
175 | + $ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_ID_FF_REMOVE'])); |
|
176 | + $header_text= ''; |
|
177 | + |
|
178 | + $ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id); |
|
179 | + $ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm()); |
|
180 | + $display_sps = ''; |
|
181 | + if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none'; |
|
182 | + $ListView->xTemplateAssign("DISPLAY_SPS",$display_sps); |
|
183 | + |
|
184 | + if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) |
|
185 | + { |
|
186 | + $exploded = explode('/', $xTemplatePath); |
|
187 | + $file_name = $exploded[sizeof($exploded) - 1]; |
|
188 | + $mod_name = $exploded[sizeof($exploded) - 2]; |
|
189 | + $header_text= " <a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang=" |
|
190 | + .$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif','Edit Layout')."</a>"; |
|
191 | + } |
|
192 | + $ListView->setHeaderTitle(''); |
|
193 | + $ListView->setHeaderText(''); |
|
194 | + |
|
195 | + ob_start(); |
|
196 | + |
|
197 | + $ListView->is_dynamic = true; |
|
198 | + $ListView->records_per_page = $sugar_config['list_max_entries_per_subpanel'] + 0; |
|
199 | + if (isset($this->subpanel_defs->_instance_properties['records_per_page'])) { |
|
200 | + $ListView->records_per_page = $this->subpanel_defs->_instance_properties['records_per_page'] + 0; |
|
201 | + } |
|
202 | + $ListView->start_link_wrapper = "javascript:showSubPanel('".$this->subpanel_id."','"; |
|
203 | + $ListView->subpanel_id = $this->subpanel_id; |
|
204 | + $ListView->end_link_wrapper = "',true);"; |
|
205 | + if ( !empty($this->layout_def_key) ) { |
|
206 | + $ListView->end_link_wrapper = '&layout_def_key='.$this->layout_def_key.$ListView->end_link_wrapper; |
|
207 | + } |
|
208 | + |
|
209 | + $where = ''; |
|
210 | + $ListView->setQuery($where, '', '', ''); |
|
211 | + $ListView->show_export_button = false; |
|
212 | + |
|
213 | + //function returns the query that was used to populate sub-panel data. |
|
214 | + |
|
215 | + $query=$ListView->process_dynamic_listview($this->parent_module, $this->parent_bean,$this->subpanel_defs); |
|
216 | + $this->subpanel_query=$query; |
|
217 | + $ob_contents = ob_get_contents(); |
|
218 | + ob_end_clean(); |
|
219 | + return $ob_contents; |
|
220 | + } |
|
221 | + |
|
222 | + function display() |
|
223 | + { |
|
224 | + $result_array = array(); |
|
225 | + |
|
226 | + $return_string = $this->ProcessSubPanelListView($this->template_file,$result_array); |
|
227 | + |
|
228 | + print $return_string; |
|
229 | + } |
|
230 | + |
|
231 | + function getModulesWithSubpanels() |
|
232 | + { |
|
233 | + global $beanList; |
|
234 | + $dir = dir('modules'); |
|
235 | + $modules = array(); |
|
236 | + while($entry = $dir->read()) |
|
237 | + { |
|
238 | + if(file_exists('modules/' . $entry . '/layout_defs.php')) |
|
239 | + { |
|
240 | + $modules[$entry] = $entry; |
|
241 | + } |
|
242 | + } |
|
243 | + return $modules; |
|
244 | + } |
|
245 | + |
|
246 | + static function getModuleSubpanels($module){ |
|
247 | + require_once('include/SubPanel/SubPanelDefinitions.php'); |
|
248 | + global $beanList, $beanFiles; |
|
249 | + if(!isset($beanList[$module])){ |
|
250 | + return array(); |
|
251 | + } |
|
252 | + |
|
253 | + $class = $beanList[$module]; |
|
254 | + require_once($beanFiles[$class]); |
|
255 | + $mod = new $class(); |
|
256 | + $spd = new SubPanelDefinitions($mod); |
|
257 | + $tabs = $spd->get_available_tabs(true); |
|
258 | + $ret_tabs = array(); |
|
259 | + $reject_tabs = array('history'=>1, 'activities'=>1); |
|
260 | + foreach($tabs as $key=>$tab){ |
|
261 | + foreach($tab as $k=>$v){ |
|
262 | 262 | if (! isset ( $reject_tabs [$k] )) { |
263 | 263 | $ret_tabs [$k] = $v; |
264 | 264 | } |
265 | 265 | } |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - return $ret_tabs; |
|
268 | + return $ret_tabs; |
|
269 | 269 | |
270 | 270 | |
271 | - } |
|
271 | + } |
|
272 | 272 | |
273 | - //saves overrides for defs |
|
274 | - function saveSubPanelDefOverride( $panel, $subsection, $override){ |
|
275 | - global $layout_defs, $beanList; |
|
273 | + //saves overrides for defs |
|
274 | + function saveSubPanelDefOverride( $panel, $subsection, $override){ |
|
275 | + global $layout_defs, $beanList; |
|
276 | 276 | |
277 | - //save the new subpanel |
|
278 | - $name = "subpanel_layout['list_fields']"; |
|
277 | + //save the new subpanel |
|
278 | + $name = "subpanel_layout['list_fields']"; |
|
279 | 279 | |
280 | - //bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels |
|
281 | - $path = 'custom/modules/'. $panel->_instance_properties['module'] . '/metadata/subpanels'; |
|
280 | + //bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels |
|
281 | + $path = 'custom/modules/'. $panel->_instance_properties['module'] . '/metadata/subpanels'; |
|
282 | 282 | |
283 | - //bug# 40171: "Custom subpanels not working as expected" |
|
284 | - //each custom subpanel needs to have a unique custom def file |
|
285 | - $filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it) |
|
286 | - $oldName1 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name'] ; |
|
287 | - $oldName2 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['get_subpanel_data'] ; |
|
288 | - if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php")){ |
|
289 | - unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php"); |
|
290 | - } |
|
291 | - if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php")){ |
|
292 | - unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php"); |
|
293 | - } |
|
294 | - $extname = '_override'.$filename; |
|
295 | - //end of bug# 40171 |
|
283 | + //bug# 40171: "Custom subpanels not working as expected" |
|
284 | + //each custom subpanel needs to have a unique custom def file |
|
285 | + $filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it) |
|
286 | + $oldName1 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name'] ; |
|
287 | + $oldName2 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['get_subpanel_data'] ; |
|
288 | + if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php")){ |
|
289 | + unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php"); |
|
290 | + } |
|
291 | + if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php")){ |
|
292 | + unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php"); |
|
293 | + } |
|
294 | + $extname = '_override'.$filename; |
|
295 | + //end of bug# 40171 |
|
296 | 296 | |
297 | - mkdir_recursive($path, true); |
|
298 | - write_array_to_file( $name, $override,$path.'/' . $filename .'.php'); |
|
297 | + mkdir_recursive($path, true); |
|
298 | + write_array_to_file( $name, $override,$path.'/' . $filename .'.php'); |
|
299 | 299 | |
300 | - //save the override for the layoutdef |
|
300 | + //save the override for the layoutdef |
|
301 | 301 | //tyoung 10.12.07 pushed panel->name to lowercase to match case in subpaneldefs.php files - |
302 | 302 | //gave error on bad index 'module' as this override key didn't match the key in the subpaneldefs |
303 | - $name = "layout_defs['". $panel->parent_bean->module_dir. "']['subpanel_setup']['" .strtolower($panel->name). "']"; |
|
303 | + $name = "layout_defs['". $panel->parent_bean->module_dir. "']['subpanel_setup']['" .strtolower($panel->name). "']"; |
|
304 | 304 | // $GLOBALS['log']->debug('SubPanel.php->saveSubPanelDefOverride(): '.$name); |
305 | - $newValue = override_value_to_string($name, 'override_subpanel_name', $filename); |
|
306 | - mkdir_recursive('custom/Extension/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true); |
|
307 | - $fp = sugar_fopen('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$extname.php", 'w'); |
|
308 | - fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n$newValue\n?>"); |
|
309 | - fclose($fp); |
|
310 | - require_once('ModuleInstall/ModuleInstaller.php'); |
|
311 | - $moduleInstaller = new ModuleInstaller(); |
|
312 | - $moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs |
|
313 | - $moduleInstaller->rebuild_layoutdefs(); |
|
314 | - if (file_exists('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php')) |
|
315 | - include('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php'); |
|
316 | - if (file_exists('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
317 | - include('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
318 | - } |
|
319 | - |
|
320 | - function get_subpanel_setup($module) |
|
321 | - { |
|
322 | - $subpanel_setup = ''; |
|
323 | - $layout_defs = get_layout_defs(); |
|
324 | - |
|
325 | - if(!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup'])) |
|
326 | - { |
|
327 | - $subpanel_setup = $layout_defs[$module]['subpanel_setup']; |
|
328 | - } |
|
329 | - |
|
330 | - return $subpanel_setup; |
|
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * Retrieve the subpanel definition from the registered layout_defs arrays. |
|
335 | - */ |
|
336 | - function getSubPanelDefine($module, $subpanel_id) |
|
337 | - { |
|
338 | - $default_subpanel_define = SubPanel::_get_default_subpanel_define($module, $subpanel_id); |
|
339 | - $custom_subpanel_define = SubPanel::_get_custom_subpanel_define($module, $subpanel_id); |
|
340 | - |
|
341 | - $subpanel_define = array_merge($default_subpanel_define, $custom_subpanel_define); |
|
342 | - |
|
343 | - if(empty($subpanel_define)) |
|
344 | - { |
|
345 | - print('Could not load subpanel definition for: ' . $subpanel_id); |
|
346 | - } |
|
347 | - |
|
348 | - return $subpanel_define; |
|
349 | - } |
|
350 | - |
|
351 | - function _get_custom_subpanel_define($module, $subpanel_id) |
|
352 | - { |
|
353 | - $ret_val = array(); |
|
354 | - |
|
355 | - if($subpanel_id != '') |
|
356 | - { |
|
357 | - $layout_defs = get_layout_defs(); |
|
358 | - |
|
359 | - if(!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id])) |
|
360 | - { |
|
361 | - $ret_val = $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]; |
|
362 | - } |
|
363 | - } |
|
305 | + $newValue = override_value_to_string($name, 'override_subpanel_name', $filename); |
|
306 | + mkdir_recursive('custom/Extension/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true); |
|
307 | + $fp = sugar_fopen('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$extname.php", 'w'); |
|
308 | + fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n$newValue\n?>"); |
|
309 | + fclose($fp); |
|
310 | + require_once('ModuleInstall/ModuleInstaller.php'); |
|
311 | + $moduleInstaller = new ModuleInstaller(); |
|
312 | + $moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs |
|
313 | + $moduleInstaller->rebuild_layoutdefs(); |
|
314 | + if (file_exists('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php')) |
|
315 | + include('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php'); |
|
316 | + if (file_exists('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
317 | + include('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
318 | + } |
|
319 | + |
|
320 | + function get_subpanel_setup($module) |
|
321 | + { |
|
322 | + $subpanel_setup = ''; |
|
323 | + $layout_defs = get_layout_defs(); |
|
324 | + |
|
325 | + if(!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup'])) |
|
326 | + { |
|
327 | + $subpanel_setup = $layout_defs[$module]['subpanel_setup']; |
|
328 | + } |
|
329 | + |
|
330 | + return $subpanel_setup; |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * Retrieve the subpanel definition from the registered layout_defs arrays. |
|
335 | + */ |
|
336 | + function getSubPanelDefine($module, $subpanel_id) |
|
337 | + { |
|
338 | + $default_subpanel_define = SubPanel::_get_default_subpanel_define($module, $subpanel_id); |
|
339 | + $custom_subpanel_define = SubPanel::_get_custom_subpanel_define($module, $subpanel_id); |
|
340 | + |
|
341 | + $subpanel_define = array_merge($default_subpanel_define, $custom_subpanel_define); |
|
342 | + |
|
343 | + if(empty($subpanel_define)) |
|
344 | + { |
|
345 | + print('Could not load subpanel definition for: ' . $subpanel_id); |
|
346 | + } |
|
347 | + |
|
348 | + return $subpanel_define; |
|
349 | + } |
|
350 | + |
|
351 | + function _get_custom_subpanel_define($module, $subpanel_id) |
|
352 | + { |
|
353 | + $ret_val = array(); |
|
354 | + |
|
355 | + if($subpanel_id != '') |
|
356 | + { |
|
357 | + $layout_defs = get_layout_defs(); |
|
358 | + |
|
359 | + if(!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id])) |
|
360 | + { |
|
361 | + $ret_val = $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]; |
|
362 | + } |
|
363 | + } |
|
364 | 364 | |
365 | - return $ret_val; |
|
366 | - } |
|
365 | + return $ret_val; |
|
366 | + } |
|
367 | 367 | |
368 | - function _get_default_subpanel_define($module, $subpanel_id) |
|
369 | - { |
|
370 | - $ret_val = array(); |
|
368 | + function _get_default_subpanel_define($module, $subpanel_id) |
|
369 | + { |
|
370 | + $ret_val = array(); |
|
371 | 371 | |
372 | - if($subpanel_id != '') |
|
373 | - { |
|
374 | - $layout_defs = get_layout_defs(); |
|
372 | + if($subpanel_id != '') |
|
373 | + { |
|
374 | + $layout_defs = get_layout_defs(); |
|
375 | 375 | |
376 | - if(!empty($layout_defs[$subpanel_id]['default_subpanel_define'])) |
|
377 | - { |
|
378 | - $ret_val = $layout_defs[$subpanel_id]['default_subpanel_define']; |
|
379 | - } |
|
380 | - } |
|
376 | + if(!empty($layout_defs[$subpanel_id]['default_subpanel_define'])) |
|
377 | + { |
|
378 | + $ret_val = $layout_defs[$subpanel_id]['default_subpanel_define']; |
|
379 | + } |
|
380 | + } |
|
381 | 381 | |
382 | - return $ret_val; |
|
383 | - } |
|
382 | + return $ret_val; |
|
383 | + } |
|
384 | 384 | |
385 | - function buildSearchQuery() |
|
386 | - { |
|
387 | - require_once('include/SubPanel/SubPanelSearchForm.php'); |
|
385 | + function buildSearchQuery() |
|
386 | + { |
|
387 | + require_once('include/SubPanel/SubPanelSearchForm.php'); |
|
388 | 388 | |
389 | - $module = 'Meetings'; |
|
389 | + $module = 'Meetings'; |
|
390 | 390 | |
391 | - $seed = new Meeting(); |
|
391 | + $seed = new Meeting(); |
|
392 | 392 | |
393 | - $_REQUEST['searchFormTab'] = 'basic_search'; |
|
394 | - $searchForm = new SubPanelSearchForm($seed, $module, $this); |
|
393 | + $_REQUEST['searchFormTab'] = 'basic_search'; |
|
394 | + $searchForm = new SubPanelSearchForm($seed, $module, $this); |
|
395 | 395 | |
396 | - $searchMetaData = $searchForm->retrieveSearchDefs($module); |
|
397 | - $searchForm->setup($searchMetaData['searchdefs'], $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search'); |
|
396 | + $searchMetaData = $searchForm->retrieveSearchDefs($module); |
|
397 | + $searchForm->setup($searchMetaData['searchdefs'], $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search'); |
|
398 | 398 | |
399 | - $searchForm->populateFromRequest(); |
|
399 | + $searchForm->populateFromRequest(); |
|
400 | 400 | |
401 | - $where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir); |
|
401 | + $where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir); |
|
402 | 402 | |
403 | - if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')'; |
|
404 | - $GLOBALS['log']->info("Subpanel Where Clause: $this->search_query"); |
|
403 | + if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')'; |
|
404 | + $GLOBALS['log']->info("Subpanel Where Clause: $this->search_query"); |
|
405 | 405 | |
406 | - return print_r($where_clauses,true); |
|
407 | - } |
|
406 | + return print_r($where_clauses,true); |
|
407 | + } |
|
408 | 408 | |
409 | - function get_searchdefs($module) |
|
410 | - { |
|
411 | - $thisPanel =& $this->subpanel_defs; |
|
412 | - $subpanel_defs = $thisPanel->_instance_properties; |
|
409 | + function get_searchdefs($module) |
|
410 | + { |
|
411 | + $thisPanel =& $this->subpanel_defs; |
|
412 | + $subpanel_defs = $thisPanel->_instance_properties; |
|
413 | 413 | |
414 | - if(isset($subpanel_defs['searchdefs'])){ |
|
415 | - $searchdefs[$module]['layout']['basic_search'] = $subpanel_defs['searchdefs']; |
|
416 | - $searchdefs[$module]['templateMeta'] = Array ('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array ( 'label' => 10, 'field' => 30 )) ; |
|
417 | - return $searchdefs; |
|
418 | - } |
|
414 | + if(isset($subpanel_defs['searchdefs'])){ |
|
415 | + $searchdefs[$module]['layout']['basic_search'] = $subpanel_defs['searchdefs']; |
|
416 | + $searchdefs[$module]['templateMeta'] = Array ('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array ( 'label' => 10, 'field' => 30 )) ; |
|
417 | + return $searchdefs; |
|
418 | + } |
|
419 | 419 | |
420 | - return false; |
|
421 | - } |
|
420 | + return false; |
|
421 | + } |
|
422 | 422 | |
423 | - function getSearchForm() |
|
424 | - { |
|
425 | - require_once('include/SubPanel/SubPanelSearchForm.php'); |
|
423 | + function getSearchForm() |
|
424 | + { |
|
425 | + require_once('include/SubPanel/SubPanelSearchForm.php'); |
|
426 | 426 | |
427 | - $module = 'Meetings'; |
|
427 | + $module = 'Meetings'; |
|
428 | 428 | |
429 | - $seed = new Meeting(); |
|
429 | + $seed = new Meeting(); |
|
430 | 430 | |
431 | - $searchForm = new SubPanelSearchForm($seed, $module, $this); |
|
431 | + $searchForm = new SubPanelSearchForm($seed, $module, $this); |
|
432 | 432 | |
433 | - $searchMetaData = $searchForm->retrieveSearchDefs($module); |
|
433 | + $searchMetaData = $searchForm->retrieveSearchDefs($module); |
|
434 | 434 | |
435 | - if ($subpanel_searchMetaData = $this->get_searchdefs($module)){ |
|
435 | + if ($subpanel_searchMetaData = $this->get_searchdefs($module)){ |
|
436 | 436 | |
437 | - $searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search'); |
|
437 | + $searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search'); |
|
438 | 438 | |
439 | - if(!empty($this->collections)) |
|
440 | - $searchForm->searchFields['collection'] = array(); |
|
439 | + if(!empty($this->collections)) |
|
440 | + $searchForm->searchFields['collection'] = array(); |
|
441 | 441 | |
442 | - $searchForm->populateFromRequest(); |
|
442 | + $searchForm->populateFromRequest(); |
|
443 | 443 | |
444 | - return $searchForm->display(); |
|
445 | - } |
|
444 | + return $searchForm->display(); |
|
445 | + } |
|
446 | 446 | |
447 | - return ''; |
|
448 | - } |
|
447 | + return ''; |
|
448 | + } |
|
449 | 449 | } |
450 | 450 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -48,24 +48,24 @@ discard block |
||
48 | 48 | var $hideNewButton = false; |
49 | 49 | var $subpanel_id; |
50 | 50 | var $parent_record_id; |
51 | - var $parent_module; // the name of the parent module |
|
52 | - var $parent_bean; // the instantiated bean of the parent |
|
51 | + var $parent_module; // the name of the parent module |
|
52 | + var $parent_bean; // the instantiated bean of the parent |
|
53 | 53 | var $template_file; |
54 | 54 | var $linked_fields; |
55 | 55 | var $action = 'DetailView'; |
56 | 56 | var $show_select_button = true; |
57 | - var $subpanel_define = null; // contains the layout_def.php |
|
57 | + var $subpanel_define = null; // contains the layout_def.php |
|
58 | 58 | var $subpanel_defs; |
59 | - var $subpanel_query=null; |
|
60 | - var $layout_def_key=''; |
|
61 | - var $search_query=''; |
|
59 | + var $subpanel_query = null; |
|
60 | + var $layout_def_key = ''; |
|
61 | + var $search_query = ''; |
|
62 | 62 | var $collections = array(); |
63 | 63 | |
64 | - function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key='', $collections = array() ) |
|
64 | + function __construct($module, $record_id, $subpanel_id, $subpanelDef, $layout_def_key = '', $collections = array()) |
|
65 | 65 | { |
66 | 66 | global $beanList, $beanFiles, $focus, $app_strings; |
67 | 67 | |
68 | - $this->subpanel_defs=$subpanelDef; |
|
68 | + $this->subpanel_defs = $subpanelDef; |
|
69 | 69 | $this->subpanel_id = $subpanel_id; |
70 | 70 | $this->parent_record_id = $record_id; |
71 | 71 | $this->parent_module = $module; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->parent_bean = $focus; |
76 | 76 | $result = $focus; |
77 | 77 | |
78 | - if(empty($result)) |
|
78 | + if (empty($result)) |
|
79 | 79 | { |
80 | 80 | $parent_bean_name = $beanList[$module]; |
81 | 81 | $parent_bean_file = $beanFiles[$parent_bean_name]; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $result = $this->parent_bean; |
86 | 86 | } |
87 | 87 | |
88 | - if($record_id!='fab4' && $result == null) |
|
88 | + if ($record_id != 'fab4' && $result == null) |
|
89 | 89 | { |
90 | 90 | sugar_die($app_strings['ERROR_NO_RECORD']); |
91 | 91 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | if (empty($subpanelDef)) { |
94 | 94 | //load the subpanel by name. |
95 | 95 | if (!class_exists('MyClass')) { |
96 | - require_once 'include/SubPanel/SubPanelDefinitions.php' ; |
|
96 | + require_once 'include/SubPanel/SubPanelDefinitions.php'; |
|
97 | 97 | } |
98 | - $panelsdef=new SubPanelDefinitions($result,$layout_def_key); |
|
99 | - $subpanelDef=$panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query,$collections); |
|
100 | - $this->subpanel_defs=$subpanelDef; |
|
98 | + $panelsdef = new SubPanelDefinitions($result, $layout_def_key); |
|
99 | + $subpanelDef = $panelsdef->load_subpanel($subpanel_id, false, false, $this->search_query, $collections); |
|
100 | + $this->subpanel_defs = $subpanelDef; |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | } |
@@ -107,38 +107,38 @@ discard block |
||
107 | 107 | $this->template_file = $template_file; |
108 | 108 | } |
109 | 109 | |
110 | - function setBeanList(&$value){ |
|
111 | - $this->bean_list =$value; |
|
110 | + function setBeanList(&$value) { |
|
111 | + $this->bean_list = $value; |
|
112 | 112 | } |
113 | 113 | |
114 | - function setHideNewButton($value){ |
|
114 | + function setHideNewButton($value) { |
|
115 | 115 | $this->hideNewButton = $value; |
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - function getHeaderText( $currentModule){ |
|
119 | + function getHeaderText($currentModule) { |
|
120 | 120 | } |
121 | 121 | |
122 | - function get_buttons( $panel_query=null) |
|
122 | + function get_buttons($panel_query = null) |
|
123 | 123 | { |
124 | 124 | |
125 | - $thisPanel =& $this->subpanel_defs; |
|
125 | + $thisPanel = & $this->subpanel_defs; |
|
126 | 126 | $subpanel_def = $thisPanel->get_buttons(); |
127 | 127 | |
128 | - if(!isset($this->listview)){ |
|
128 | + if (!isset($this->listview)) { |
|
129 | 129 | $this->listview = new ListView(); |
130 | 130 | } |
131 | 131 | $layout_manager = $this->listview->getLayoutManager(); |
132 | 132 | $widget_contents = '<div><table cellpadding="0" cellspacing="0"><tr>'; |
133 | - foreach($subpanel_def as $widget_data) |
|
133 | + foreach ($subpanel_def as $widget_data) |
|
134 | 134 | { |
135 | 135 | $widget_data['action'] = $_REQUEST['action']; |
136 | - $widget_data['module'] = $thisPanel->get_inst_prop_value('module'); |
|
136 | + $widget_data['module'] = $thisPanel->get_inst_prop_value('module'); |
|
137 | 137 | $widget_data['focus'] = $this->parent_bean; |
138 | 138 | $widget_data['subpanel_definition'] = $thisPanel; |
139 | - $widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">' . "\n"; |
|
139 | + $widget_contents .= '<td style="padding-right: 2px; padding-bottom: 2px;">'."\n"; |
|
140 | 140 | |
141 | - if(empty($widget_data['widget_class'])) |
|
141 | + if (empty($widget_data['widget_class'])) |
|
142 | 142 | { |
143 | 143 | $widget_contents .= "widget_class not defined for top subpanel buttons"; |
144 | 144 | } |
@@ -161,33 +161,33 @@ discard block |
||
161 | 161 | global $current_user; |
162 | 162 | global $sugar_config; |
163 | 163 | |
164 | - if(isset($this->listview)){ |
|
165 | - $ListView =& $this->listview; |
|
166 | - }else{ |
|
164 | + if (isset($this->listview)) { |
|
165 | + $ListView = & $this->listview; |
|
166 | + } else { |
|
167 | 167 | $ListView = new ListView(); |
168 | 168 | } |
169 | - $ListView->initNewXTemplate($xTemplatePath,$this->subpanel_defs->mod_strings); |
|
169 | + $ListView->initNewXTemplate($xTemplatePath, $this->subpanel_defs->mod_strings); |
|
170 | 170 | $ListView->xTemplateAssign("RETURN_URL", "&return_module=".$this->parent_module."&return_action=DetailView&return_id=".$this->parent_bean->id); |
171 | - $ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module); // TODO: what about unions? |
|
171 | + $ListView->xTemplateAssign("RELATED_MODULE", $this->parent_module); // TODO: what about unions? |
|
172 | 172 | $ListView->xTemplateAssign("RECORD_ID", $this->parent_bean->id); |
173 | - $ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LNK_EDIT'])); |
|
174 | - $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_DELETE_INLINE'])); |
|
175 | - $ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LBL_ID_FF_REMOVE'])); |
|
176 | - $header_text= ''; |
|
173 | + $ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LNK_EDIT'])); |
|
174 | + $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LBL_DELETE_INLINE'])); |
|
175 | + $ListView->xTemplateAssign("REMOVE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LBL_ID_FF_REMOVE'])); |
|
176 | + $header_text = ''; |
|
177 | 177 | |
178 | 178 | $ListView->xTemplateAssign("SUBPANEL_ID", $this->subpanel_id); |
179 | 179 | $ListView->xTemplateAssign("SUBPANEL_SEARCH", $this->getSearchForm()); |
180 | 180 | $display_sps = ''; |
181 | - if($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none'; |
|
182 | - $ListView->xTemplateAssign("DISPLAY_SPS",$display_sps); |
|
181 | + if ($this->search_query == '' && empty($this->collections)) $display_sps = 'display:none'; |
|
182 | + $ListView->xTemplateAssign("DISPLAY_SPS", $display_sps); |
|
183 | 183 | |
184 | - if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) |
|
184 | + if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) |
|
185 | 185 | { |
186 | 186 | $exploded = explode('/', $xTemplatePath); |
187 | 187 | $file_name = $exploded[sizeof($exploded) - 1]; |
188 | - $mod_name = $exploded[sizeof($exploded) - 2]; |
|
189 | - $header_text= " <a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang=" |
|
190 | - .$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif','Edit Layout')."</a>"; |
|
188 | + $mod_name = $exploded[sizeof($exploded) - 2]; |
|
189 | + $header_text = " <a href='index.php?action=index&module=DynamicLayout&from_action=$file_name&from_module=$mod_name&mod_lang=" |
|
190 | + .$_REQUEST['module']."'>".SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', 'Edit Layout')."</a>"; |
|
191 | 191 | } |
192 | 192 | $ListView->setHeaderTitle(''); |
193 | 193 | $ListView->setHeaderText(''); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $ListView->start_link_wrapper = "javascript:showSubPanel('".$this->subpanel_id."','"; |
203 | 203 | $ListView->subpanel_id = $this->subpanel_id; |
204 | 204 | $ListView->end_link_wrapper = "',true);"; |
205 | - if ( !empty($this->layout_def_key) ) { |
|
205 | + if (!empty($this->layout_def_key)) { |
|
206 | 206 | $ListView->end_link_wrapper = '&layout_def_key='.$this->layout_def_key.$ListView->end_link_wrapper; |
207 | 207 | } |
208 | 208 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | |
213 | 213 | //function returns the query that was used to populate sub-panel data. |
214 | 214 | |
215 | - $query=$ListView->process_dynamic_listview($this->parent_module, $this->parent_bean,$this->subpanel_defs); |
|
216 | - $this->subpanel_query=$query; |
|
215 | + $query = $ListView->process_dynamic_listview($this->parent_module, $this->parent_bean, $this->subpanel_defs); |
|
216 | + $this->subpanel_query = $query; |
|
217 | 217 | $ob_contents = ob_get_contents(); |
218 | 218 | ob_end_clean(); |
219 | 219 | return $ob_contents; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | { |
224 | 224 | $result_array = array(); |
225 | 225 | |
226 | - $return_string = $this->ProcessSubPanelListView($this->template_file,$result_array); |
|
226 | + $return_string = $this->ProcessSubPanelListView($this->template_file, $result_array); |
|
227 | 227 | |
228 | 228 | print $return_string; |
229 | 229 | } |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | global $beanList; |
234 | 234 | $dir = dir('modules'); |
235 | 235 | $modules = array(); |
236 | - while($entry = $dir->read()) |
|
236 | + while ($entry = $dir->read()) |
|
237 | 237 | { |
238 | - if(file_exists('modules/' . $entry . '/layout_defs.php')) |
|
238 | + if (file_exists('modules/'.$entry.'/layout_defs.php')) |
|
239 | 239 | { |
240 | 240 | $modules[$entry] = $entry; |
241 | 241 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | return $modules; |
244 | 244 | } |
245 | 245 | |
246 | - static function getModuleSubpanels($module){ |
|
246 | + static function getModuleSubpanels($module) { |
|
247 | 247 | require_once('include/SubPanel/SubPanelDefinitions.php'); |
248 | 248 | global $beanList, $beanFiles; |
249 | - if(!isset($beanList[$module])){ |
|
249 | + if (!isset($beanList[$module])) { |
|
250 | 250 | return array(); |
251 | 251 | } |
252 | 252 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | $tabs = $spd->get_available_tabs(true); |
258 | 258 | $ret_tabs = array(); |
259 | 259 | $reject_tabs = array('history'=>1, 'activities'=>1); |
260 | - foreach($tabs as $key=>$tab){ |
|
261 | - foreach($tab as $k=>$v){ |
|
262 | - if (! isset ( $reject_tabs [$k] )) { |
|
260 | + foreach ($tabs as $key=>$tab) { |
|
261 | + foreach ($tab as $k=>$v) { |
|
262 | + if (!isset ($reject_tabs [$k])) { |
|
263 | 263 | $ret_tabs [$k] = $v; |
264 | 264 | } |
265 | 265 | } |
@@ -271,50 +271,50 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | //saves overrides for defs |
274 | - function saveSubPanelDefOverride( $panel, $subsection, $override){ |
|
274 | + function saveSubPanelDefOverride($panel, $subsection, $override) { |
|
275 | 275 | global $layout_defs, $beanList; |
276 | 276 | |
277 | 277 | //save the new subpanel |
278 | 278 | $name = "subpanel_layout['list_fields']"; |
279 | 279 | |
280 | 280 | //bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels |
281 | - $path = 'custom/modules/'. $panel->_instance_properties['module'] . '/metadata/subpanels'; |
|
281 | + $path = 'custom/modules/'.$panel->_instance_properties['module'].'/metadata/subpanels'; |
|
282 | 282 | |
283 | 283 | //bug# 40171: "Custom subpanels not working as expected" |
284 | 284 | //each custom subpanel needs to have a unique custom def file |
285 | - $filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it) |
|
286 | - $oldName1 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name'] ; |
|
287 | - $oldName2 = '_override' . $panel->parent_bean->object_name .$panel->_instance_properties['get_subpanel_data'] ; |
|
288 | - if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php")){ |
|
289 | - unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName1.php"); |
|
285 | + $filename = $panel->parent_bean->object_name."_subpanel_".$panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it) |
|
286 | + $oldName1 = '_override'.$panel->parent_bean->object_name.$panel->_instance_properties['module'].$panel->_instance_properties['subpanel_name']; |
|
287 | + $oldName2 = '_override'.$panel->parent_bean->object_name.$panel->_instance_properties['get_subpanel_data']; |
|
288 | + if (file_exists('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName1.php")) { |
|
289 | + unlink('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName1.php"); |
|
290 | 290 | } |
291 | - if (file_exists('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php")){ |
|
292 | - unlink('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$oldName2.php"); |
|
291 | + if (file_exists('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName2.php")) { |
|
292 | + unlink('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$oldName2.php"); |
|
293 | 293 | } |
294 | 294 | $extname = '_override'.$filename; |
295 | 295 | //end of bug# 40171 |
296 | 296 | |
297 | 297 | mkdir_recursive($path, true); |
298 | - write_array_to_file( $name, $override,$path.'/' . $filename .'.php'); |
|
298 | + write_array_to_file($name, $override, $path.'/'.$filename.'.php'); |
|
299 | 299 | |
300 | 300 | //save the override for the layoutdef |
301 | 301 | //tyoung 10.12.07 pushed panel->name to lowercase to match case in subpaneldefs.php files - |
302 | 302 | //gave error on bad index 'module' as this override key didn't match the key in the subpaneldefs |
303 | - $name = "layout_defs['". $panel->parent_bean->module_dir. "']['subpanel_setup']['" .strtolower($panel->name). "']"; |
|
303 | + $name = "layout_defs['".$panel->parent_bean->module_dir."']['subpanel_setup']['".strtolower($panel->name)."']"; |
|
304 | 304 | // $GLOBALS['log']->debug('SubPanel.php->saveSubPanelDefOverride(): '.$name); |
305 | 305 | $newValue = override_value_to_string($name, 'override_subpanel_name', $filename); |
306 | - mkdir_recursive('custom/Extension/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true); |
|
307 | - $fp = sugar_fopen('custom/Extension/modules/'. $panel->parent_bean->module_dir . "/Ext/Layoutdefs/$extname.php", 'w'); |
|
306 | + mkdir_recursive('custom/Extension/modules/'.$panel->parent_bean->module_dir.'/Ext/Layoutdefs', true); |
|
307 | + $fp = sugar_fopen('custom/Extension/modules/'.$panel->parent_bean->module_dir."/Ext/Layoutdefs/$extname.php", 'w'); |
|
308 | 308 | fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n$newValue\n?>"); |
309 | 309 | fclose($fp); |
310 | 310 | require_once('ModuleInstall/ModuleInstaller.php'); |
311 | 311 | $moduleInstaller = new ModuleInstaller(); |
312 | 312 | $moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs |
313 | 313 | $moduleInstaller->rebuild_layoutdefs(); |
314 | - if (file_exists('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php')) |
|
315 | - include('modules/'. $panel->parent_bean->module_dir . '/layout_defs.php'); |
|
316 | - if (file_exists('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
317 | - include('custom/modules/'. $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
314 | + if (file_exists('modules/'.$panel->parent_bean->module_dir.'/layout_defs.php')) |
|
315 | + include('modules/'.$panel->parent_bean->module_dir.'/layout_defs.php'); |
|
316 | + if (file_exists('custom/modules/'.$panel->parent_bean->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
317 | + include('custom/modules/'.$panel->parent_bean->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | function get_subpanel_setup($module) |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $subpanel_setup = ''; |
323 | 323 | $layout_defs = get_layout_defs(); |
324 | 324 | |
325 | - if(!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup'])) |
|
325 | + if (!empty($layout_defs) && !empty($layout_defs[$module]['subpanel_setup'])) |
|
326 | 326 | { |
327 | 327 | $subpanel_setup = $layout_defs[$module]['subpanel_setup']; |
328 | 328 | } |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | |
341 | 341 | $subpanel_define = array_merge($default_subpanel_define, $custom_subpanel_define); |
342 | 342 | |
343 | - if(empty($subpanel_define)) |
|
343 | + if (empty($subpanel_define)) |
|
344 | 344 | { |
345 | - print('Could not load subpanel definition for: ' . $subpanel_id); |
|
345 | + print('Could not load subpanel definition for: '.$subpanel_id); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | return $subpanel_define; |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | { |
353 | 353 | $ret_val = array(); |
354 | 354 | |
355 | - if($subpanel_id != '') |
|
355 | + if ($subpanel_id != '') |
|
356 | 356 | { |
357 | 357 | $layout_defs = get_layout_defs(); |
358 | 358 | |
359 | - if(!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id])) |
|
359 | + if (!empty($layout_defs[$module]['custom_subpanel_defines'][$subpanel_id])) |
|
360 | 360 | { |
361 | 361 | $ret_val = $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]; |
362 | 362 | } |
@@ -369,11 +369,11 @@ discard block |
||
369 | 369 | { |
370 | 370 | $ret_val = array(); |
371 | 371 | |
372 | - if($subpanel_id != '') |
|
372 | + if ($subpanel_id != '') |
|
373 | 373 | { |
374 | 374 | $layout_defs = get_layout_defs(); |
375 | 375 | |
376 | - if(!empty($layout_defs[$subpanel_id]['default_subpanel_define'])) |
|
376 | + if (!empty($layout_defs[$subpanel_id]['default_subpanel_define'])) |
|
377 | 377 | { |
378 | 378 | $ret_val = $layout_defs[$subpanel_id]['default_subpanel_define']; |
379 | 379 | } |
@@ -400,20 +400,20 @@ discard block |
||
400 | 400 | |
401 | 401 | $where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir); |
402 | 402 | |
403 | - if (count($where_clauses) > 0 )$this->search_query = '('. implode(' ) AND ( ', $where_clauses) . ')'; |
|
403 | + if (count($where_clauses) > 0)$this->search_query = '('.implode(' ) AND ( ', $where_clauses).')'; |
|
404 | 404 | $GLOBALS['log']->info("Subpanel Where Clause: $this->search_query"); |
405 | 405 | |
406 | - return print_r($where_clauses,true); |
|
406 | + return print_r($where_clauses, true); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | function get_searchdefs($module) |
410 | 410 | { |
411 | - $thisPanel =& $this->subpanel_defs; |
|
411 | + $thisPanel = & $this->subpanel_defs; |
|
412 | 412 | $subpanel_defs = $thisPanel->_instance_properties; |
413 | 413 | |
414 | - if(isset($subpanel_defs['searchdefs'])){ |
|
414 | + if (isset($subpanel_defs['searchdefs'])) { |
|
415 | 415 | $searchdefs[$module]['layout']['basic_search'] = $subpanel_defs['searchdefs']; |
416 | - $searchdefs[$module]['templateMeta'] = Array ('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array ( 'label' => 10, 'field' => 30 )) ; |
|
416 | + $searchdefs[$module]['templateMeta'] = Array('maxColumns' => 3, 'maxColumnsBasic' => 4, 'widths' => Array('label' => 10, 'field' => 30)); |
|
417 | 417 | return $searchdefs; |
418 | 418 | } |
419 | 419 | |
@@ -432,11 +432,11 @@ discard block |
||
432 | 432 | |
433 | 433 | $searchMetaData = $searchForm->retrieveSearchDefs($module); |
434 | 434 | |
435 | - if ($subpanel_searchMetaData = $this->get_searchdefs($module)){ |
|
435 | + if ($subpanel_searchMetaData = $this->get_searchdefs($module)) { |
|
436 | 436 | |
437 | 437 | $searchForm->setup($subpanel_searchMetaData, $searchMetaData['searchFields'], 'SubpanelSearchFormGeneric.tpl', 'basic_search'); |
438 | 438 | |
439 | - if(!empty($this->collections)) |
|
439 | + if (!empty($this->collections)) |
|
440 | 440 | $searchForm->searchFields['collection'] = array(); |
441 | 441 | |
442 | 442 | $searchForm->populateFromRequest(); |
@@ -49,8 +49,8 @@ |
||
49 | 49 | function get_layout_defs() |
50 | 50 | { |
51 | 51 | //TODO add global memory cache support here. If there is an in memory cache, leverage it. |
52 | - global $layout_defs; |
|
53 | - return $layout_defs; |
|
52 | + global $layout_defs; |
|
53 | + return $layout_defs; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | ?> |
57 | 57 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
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. |
@@ -1,5 +1,7 @@ |
||
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. |
@@ -1,5 +1,7 @@ discard block |
||
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. |
@@ -111,8 +113,9 @@ discard block |
||
111 | 113 | function _getTabs($tabs, $showTabs = true, $selectedGroup='All') |
112 | 114 | { |
113 | 115 | //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
114 | - if($selectedGroup=='All') |
|
115 | - $selectedGroup=translate('LBL_TABGROUP_ALL'); |
|
116 | + if($selectedGroup=='All') { |
|
117 | + $selectedGroup=translate('LBL_TABGROUP_ALL'); |
|
118 | + } |
|
116 | 119 | |
117 | 120 | // Set up a mapping from subpanelID, found in the $tabs list, to the source module name |
118 | 121 | // As the $GLOBALS['tabStructure'] array holds the Group Tabs by module name we need to efficiently convert between the two |
@@ -127,8 +130,9 @@ discard block |
||
127 | 130 | // Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
128 | 131 | // use object property instead new object to have ability run unit test (can override subpanel_definitions) |
129 | 132 | $subpanel = $this->subpanel_definitions->load_subpanel( $subpanelID ); |
130 | - if ($subpanel !== false) |
|
131 | - $moduleNames [ $subpanelID ] = $subpanel->get_module_name() ; |
|
133 | + if ($subpanel !== false) { |
|
134 | + $moduleNames [ $subpanelID ] = $subpanel->get_module_name() ; |
|
135 | + } |
|
132 | 136 | } |
133 | 137 | |
134 | 138 | $groups = array () ; |
@@ -138,11 +142,12 @@ discard block |
||
138 | 142 | { |
139 | 143 | foreach( $subModules['modules'] as $key => $subModule ) |
140 | 144 | { |
141 | - foreach ( $tabs as $subpanelID ) |
|
142 | - if (isset($moduleNames[ $subpanelID ] ) && strcasecmp( $subModule , $moduleNames[ $subpanelID ] ) === 0) |
|
145 | + foreach ( $tabs as $subpanelID ) { |
|
146 | + if (isset($moduleNames[ $subpanelID ] ) && strcasecmp( $subModule , $moduleNames[ $subpanelID ] ) === 0) |
|
143 | 147 | { |
144 | 148 | // Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
145 | 149 | $groups [ translate ( $mainTab ) ] [ 'modules' ] [] = $subpanelID ; |
150 | + } |
|
146 | 151 | $found [ $subpanelID ] = true ; |
147 | 152 | } |
148 | 153 | } |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | |
153 | 158 | foreach( $tabs as $subpanelID ) |
154 | 159 | { |
155 | - if ( ! isset ( $found [ $subpanelID ] ) ) |
|
156 | - $groups [ translate ('LBL_TABGROUP_OTHER') ]['modules'] [] = $subpanelID ; |
|
160 | + if ( ! isset ( $found [ $subpanelID ] ) ) { |
|
161 | + $groups [ translate ('LBL_TABGROUP_OTHER') ]['modules'] [] = $subpanelID ; |
|
162 | + } |
|
157 | 163 | } |
158 | 164 | |
159 | 165 | /* Move history to same tab as activities */ |
@@ -168,8 +174,7 @@ discard block |
||
168 | 174 | /* Move hist from there to here */ |
169 | 175 | $groups[$mainTab]['modules'] []= 'history'; |
170 | 176 | } |
171 | - } |
|
172 | - else if(false !== ($i = array_search('history', array_map('strtolower', $group['modules'])))) |
|
177 | + } else if(false !== ($i = array_search('history', array_map('strtolower', $group['modules'])))) |
|
173 | 178 | { |
174 | 179 | unset($groups[$mainTab]['modules'][$i]); |
175 | 180 | if(empty($groups[$mainTab]['modules'])) |
@@ -184,10 +189,11 @@ discard block |
||
184 | 189 | * Note that if a tab group already exists with the name 'All', |
185 | 190 | * it will be overwritten in this union operation. |
186 | 191 | */ |
187 | - if(count($groups) <= 1) |
|
188 | - $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)); |
|
189 | - else |
|
190 | - $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)) + $groups; |
|
192 | + if(count($groups) <= 1) { |
|
193 | + $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)); |
|
194 | + } else { |
|
195 | + $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)) + $groups; |
|
196 | + } |
|
191 | 197 | /* Note - all $display checking and array_intersects with $tabs |
192 | 198 | * are now redundant (thanks to GroupedTabStructure), and could |
193 | 199 | * be removed for performance, but for now can stay to help ensure |
@@ -261,8 +267,7 @@ discard block |
||
261 | 267 | $sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup); |
262 | 268 | $sugarTab->display(); |
263 | 269 | } |
264 | - } |
|
265 | - else |
|
270 | + } else |
|
266 | 271 | { |
267 | 272 | $tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $selectedGroup); |
268 | 273 |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | class SubPanelTilesTabs extends SubPanelTiles |
49 | 49 | { |
50 | 50 | |
51 | - function __construct(&$focus, $layout_def_key='', $layout_def_override = '') |
|
52 | - { |
|
51 | + function __construct(&$focus, $layout_def_key='', $layout_def_override = '') |
|
52 | + { |
|
53 | 53 | |
54 | - $this->focus = $focus; |
|
55 | - $this->id = $focus->id; |
|
56 | - $this->module = $focus->module_dir; |
|
57 | - $this->layout_def_key = $layout_def_key; |
|
58 | - $this->subpanel_definitions = new SubPanelDefinitions($focus, $layout_def_key, $layout_def_override); |
|
59 | - } |
|
54 | + $this->focus = $focus; |
|
55 | + $this->id = $focus->id; |
|
56 | + $this->module = $focus->module_dir; |
|
57 | + $this->layout_def_key = $layout_def_key; |
|
58 | + $this->subpanel_definitions = new SubPanelDefinitions($focus, $layout_def_key, $layout_def_override); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | function getSubpanelGroupLayout($selectedGroup) |
62 | 62 | { |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | { |
78 | 78 | //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
79 | 79 | if($key=='All') |
80 | - { |
|
81 | - $key=translate('LBL_TABGROUP_ALL'); |
|
82 | - } |
|
80 | + { |
|
81 | + $key=translate('LBL_TABGROUP_ALL'); |
|
82 | + } |
|
83 | 83 | $usersCustomLayout = SubPanelTilesTabs::getSubpanelGroupLayout($key); |
84 | 84 | if(!empty($usersCustomLayout)) |
85 | 85 | { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $tabs = array_intersect($usersCustomLayout, $tabs); |
92 | 92 | foreach($diff as $subpanel) |
93 | 93 | { |
94 | - $tabs []= $subpanel; |
|
94 | + $tabs []= $subpanel; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -112,39 +112,39 @@ discard block |
||
112 | 112 | { |
113 | 113 | //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
114 | 114 | if($selectedGroup=='All') |
115 | - $selectedGroup=translate('LBL_TABGROUP_ALL'); |
|
116 | - |
|
117 | - // Set up a mapping from subpanelID, found in the $tabs list, to the source module name |
|
118 | - // As the $GLOBALS['tabStructure'] array holds the Group Tabs by module name we need to efficiently convert between the two |
|
119 | - // when constructing the subpanel tabs |
|
120 | - // Note that we can't use the very similar GroupedTabStructure class as it lacks this mapping, and logically, it is designed |
|
121 | - // for use when constructing the module by module tabs, not the subpanel tabs, as we move away from using module names to represent |
|
122 | - // subpanels, and use unique subpanel IDs instead. |
|
123 | - |
|
124 | - $moduleNames = array () ; |
|
125 | - foreach ( $tabs as $subpanelID ) |
|
126 | - { |
|
115 | + $selectedGroup=translate('LBL_TABGROUP_ALL'); |
|
116 | + |
|
117 | + // Set up a mapping from subpanelID, found in the $tabs list, to the source module name |
|
118 | + // As the $GLOBALS['tabStructure'] array holds the Group Tabs by module name we need to efficiently convert between the two |
|
119 | + // when constructing the subpanel tabs |
|
120 | + // Note that we can't use the very similar GroupedTabStructure class as it lacks this mapping, and logically, it is designed |
|
121 | + // for use when constructing the module by module tabs, not the subpanel tabs, as we move away from using module names to represent |
|
122 | + // subpanels, and use unique subpanel IDs instead. |
|
123 | + |
|
124 | + $moduleNames = array () ; |
|
125 | + foreach ( $tabs as $subpanelID ) |
|
126 | + { |
|
127 | 127 | // Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
128 | 128 | // use object property instead new object to have ability run unit test (can override subpanel_definitions) |
129 | 129 | $subpanel = $this->subpanel_definitions->load_subpanel( $subpanelID ); |
130 | - if ($subpanel !== false) |
|
131 | - $moduleNames [ $subpanelID ] = $subpanel->get_module_name() ; |
|
132 | - } |
|
130 | + if ($subpanel !== false) |
|
131 | + $moduleNames [ $subpanelID ] = $subpanel->get_module_name() ; |
|
132 | + } |
|
133 | 133 | |
134 | - $groups = array () ; |
|
135 | - $found = array () ; |
|
134 | + $groups = array () ; |
|
135 | + $found = array () ; |
|
136 | 136 | |
137 | 137 | foreach( $GLOBALS['tabStructure'] as $mainTab => $subModules) |
138 | 138 | { |
139 | 139 | foreach( $subModules['modules'] as $key => $subModule ) |
140 | 140 | { |
141 | - foreach ( $tabs as $subpanelID ) |
|
141 | + foreach ( $tabs as $subpanelID ) |
|
142 | 142 | if (isset($moduleNames[ $subpanelID ] ) && strcasecmp( $subModule , $moduleNames[ $subpanelID ] ) === 0) |
143 | 143 | { |
144 | 144 | // Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
145 | 145 | $groups [ translate ( $mainTab ) ] [ 'modules' ] [] = $subpanelID ; |
146 | - $found [ $subpanelID ] = true ; |
|
147 | - } |
|
146 | + $found [ $subpanelID ] = true ; |
|
147 | + } |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | |
153 | 153 | foreach( $tabs as $subpanelID ) |
154 | 154 | { |
155 | - if ( ! isset ( $found [ $subpanelID ] ) ) |
|
156 | - $groups [ translate ('LBL_TABGROUP_OTHER') ]['modules'] [] = $subpanelID ; |
|
155 | + if ( ! isset ( $found [ $subpanelID ] ) ) |
|
156 | + $groups [ translate ('LBL_TABGROUP_OTHER') ]['modules'] [] = $subpanelID ; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /* Move history to same tab as activities */ |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | { |
162 | 162 | foreach($groups as $mainTab => $group) |
163 | 163 | { |
164 | - if(in_array('activities', array_map('strtolower', $group['modules']))) |
|
164 | + if(in_array('activities', array_map('strtolower', $group['modules']))) |
|
165 | 165 | { |
166 | - if(!in_array('history', array_map('strtolower', $group['modules']))) |
|
166 | + if(!in_array('history', array_map('strtolower', $group['modules']))) |
|
167 | 167 | { |
168 | - /* Move hist from there to here */ |
|
168 | + /* Move hist from there to here */ |
|
169 | 169 | $groups[$mainTab]['modules'] []= 'history'; |
170 | 170 | } |
171 | 171 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | unset($groups[$mainTab]['modules'][$i]); |
175 | 175 | if(empty($groups[$mainTab]['modules'])) |
176 | 176 | { |
177 | - unset($groups[$mainTab]); |
|
177 | + unset($groups[$mainTab]); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * it will be overwritten in this union operation. |
186 | 186 | */ |
187 | 187 | if(count($groups) <= 1) |
188 | - $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)); |
|
188 | + $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)); |
|
189 | 189 | else |
190 | 190 | $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)) + $groups; |
191 | 191 | /* Note - all $display checking and array_intersects with $tabs |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | $retTabs = array(); |
198 | 198 | if($showTabs) |
199 | 199 | { |
200 | - require_once('include/SubPanel/SugarTab.php'); |
|
201 | - $sugarTab = new SugarTab(); |
|
200 | + require_once('include/SubPanel/SugarTab.php'); |
|
201 | + $sugarTab = new SugarTab(); |
|
202 | 202 | |
203 | 203 | $displayTabs = array(); |
204 | 204 | $otherTabs = array(); |
205 | 205 | |
206 | - foreach ($groups as $key=>$tab) |
|
207 | - { |
|
206 | + foreach ($groups as $key=>$tab) |
|
207 | + { |
|
208 | 208 | $display = false; |
209 | 209 | foreach($tab['modules'] as $subkey=>$subtab) |
210 | 210 | { |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | $relevantTabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $key); |
228 | 228 | |
229 | 229 | $sugarTabs[$key] = array(//'url'=>'index.php?module=' . $_REQUEST['module'] . '&record=' . $_REQUEST['record'] . '&action=' . $_REQUEST['action']. '&subpanel=' . $key.'#tabs', |
230 | - //'url'=>"javascript:SUGAR.util.retrieveAndFill('index.php?to_pdf=1&module=MySettings&action=LoadTabSubpanels&loadModule={$_REQUEST['module']}&record={$_REQUEST['record']}&subpanel=$key','subpanel_list',null,null,null);", |
|
231 | - 'label'=>( !empty($tab['label']) ? $tab['label']: $key ), |
|
232 | - 'type'=>$selected); |
|
230 | + //'url'=>"javascript:SUGAR.util.retrieveAndFill('index.php?to_pdf=1&module=MySettings&action=LoadTabSubpanels&loadModule={$_REQUEST['module']}&record={$_REQUEST['record']}&subpanel=$key','subpanel_list',null,null,null);", |
|
231 | + 'label'=>( !empty($tab['label']) ? $tab['label']: $key ), |
|
232 | + 'type'=>$selected); |
|
233 | 233 | |
234 | 234 | $otherTabs[$key] = array('key'=>$key, 'tabs'=>array()); |
235 | 235 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $retTabs = $orderedTabs; |
247 | 247 | } |
248 | 248 | } |
249 | - } |
|
249 | + } |
|
250 | 250 | |
251 | 251 | if(empty($displayTabs) && !empty($otherTabs)) |
252 | 252 | { |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | if (!empty($sugarTabs) || !empty($otherTabs) ) { |
261 | - $sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup); |
|
262 | - $sugarTab->display(); |
|
261 | + $sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup); |
|
262 | + $sugarTab->display(); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | else |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules'])); |
270 | 270 | } |
271 | 271 | |
272 | - return $retTabs; |
|
273 | - } |
|
272 | + return $retTabs; |
|
273 | + } |
|
274 | 274 | } |
275 | 275 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | class SubPanelTilesTabs extends SubPanelTiles |
49 | 49 | { |
50 | 50 | |
51 | - function __construct(&$focus, $layout_def_key='', $layout_def_override = '') |
|
51 | + function __construct(&$focus, $layout_def_key = '', $layout_def_override = '') |
|
52 | 52 | { |
53 | 53 | |
54 | 54 | $this->focus = $focus; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $layoutParams = $this->module; |
66 | 66 | //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
67 | - if($selectedGroup != translate('LBL_TABGROUP_ALL')) |
|
67 | + if ($selectedGroup != translate('LBL_TABGROUP_ALL')) |
|
68 | 68 | { |
69 | 69 | $layoutParams .= ':'.$selectedGroup; |
70 | 70 | } |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | return $current_user->getPreference('subpanelLayout', $layoutParams); |
74 | 74 | } |
75 | 75 | |
76 | - function applyUserCustomLayoutToTabs($tabs, $key='All') |
|
76 | + function applyUserCustomLayoutToTabs($tabs, $key = 'All') |
|
77 | 77 | { |
78 | 78 | //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
79 | - if($key=='All') |
|
79 | + if ($key == 'All') |
|
80 | 80 | { |
81 | - $key=translate('LBL_TABGROUP_ALL'); |
|
81 | + $key = translate('LBL_TABGROUP_ALL'); |
|
82 | 82 | } |
83 | 83 | $usersCustomLayout = SubPanelTilesTabs::getSubpanelGroupLayout($key); |
84 | - if(!empty($usersCustomLayout)) |
|
84 | + if (!empty($usersCustomLayout)) |
|
85 | 85 | { |
86 | 86 | /* Return elements of the custom layout |
87 | 87 | * which occur in $tabs in unchanged order. |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * not included in the layout. */ |
90 | 90 | $diff = array_diff($tabs, $usersCustomLayout); |
91 | 91 | $tabs = array_intersect($usersCustomLayout, $tabs); |
92 | - foreach($diff as $subpanel) |
|
92 | + foreach ($diff as $subpanel) |
|
93 | 93 | { |
94 | - $tabs []= $subpanel; |
|
94 | + $tabs [] = $subpanel; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | * @param boolean $showTabs Call the view code to display the generated tabs |
105 | 105 | * @param string $selectedGroup (Optional) Name of any selected tab (defaults to 'All') |
106 | 106 | */ |
107 | - function getTabs($showTabs = true, $selectedGroup='') { |
|
107 | + function getTabs($showTabs = true, $selectedGroup = '') { |
|
108 | 108 | $args = func_get_args(); |
109 | 109 | return call_user_func_array(array($this, '_getTabs'), $args); |
110 | 110 | } |
111 | - function _getTabs($tabs, $showTabs = true, $selectedGroup='All') |
|
111 | + function _getTabs($tabs, $showTabs = true, $selectedGroup = 'All') |
|
112 | 112 | { |
113 | 113 | //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
114 | - if($selectedGroup=='All') |
|
115 | - $selectedGroup=translate('LBL_TABGROUP_ALL'); |
|
114 | + if ($selectedGroup == 'All') |
|
115 | + $selectedGroup = translate('LBL_TABGROUP_ALL'); |
|
116 | 116 | |
117 | 117 | // Set up a mapping from subpanelID, found in the $tabs list, to the source module name |
118 | 118 | // As the $GLOBALS['tabStructure'] array holds the Group Tabs by module name we need to efficiently convert between the two |
@@ -121,58 +121,58 @@ discard block |
||
121 | 121 | // for use when constructing the module by module tabs, not the subpanel tabs, as we move away from using module names to represent |
122 | 122 | // subpanels, and use unique subpanel IDs instead. |
123 | 123 | |
124 | - $moduleNames = array () ; |
|
125 | - foreach ( $tabs as $subpanelID ) |
|
124 | + $moduleNames = array(); |
|
125 | + foreach ($tabs as $subpanelID) |
|
126 | 126 | { |
127 | 127 | // Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
128 | 128 | // use object property instead new object to have ability run unit test (can override subpanel_definitions) |
129 | - $subpanel = $this->subpanel_definitions->load_subpanel( $subpanelID ); |
|
129 | + $subpanel = $this->subpanel_definitions->load_subpanel($subpanelID); |
|
130 | 130 | if ($subpanel !== false) |
131 | - $moduleNames [ $subpanelID ] = $subpanel->get_module_name() ; |
|
131 | + $moduleNames [$subpanelID] = $subpanel->get_module_name(); |
|
132 | 132 | } |
133 | 133 | |
134 | - $groups = array () ; |
|
135 | - $found = array () ; |
|
134 | + $groups = array(); |
|
135 | + $found = array(); |
|
136 | 136 | |
137 | - foreach( $GLOBALS['tabStructure'] as $mainTab => $subModules) |
|
137 | + foreach ($GLOBALS['tabStructure'] as $mainTab => $subModules) |
|
138 | 138 | { |
139 | - foreach( $subModules['modules'] as $key => $subModule ) |
|
139 | + foreach ($subModules['modules'] as $key => $subModule) |
|
140 | 140 | { |
141 | - foreach ( $tabs as $subpanelID ) |
|
142 | - if (isset($moduleNames[ $subpanelID ] ) && strcasecmp( $subModule , $moduleNames[ $subpanelID ] ) === 0) |
|
141 | + foreach ($tabs as $subpanelID) |
|
142 | + if (isset($moduleNames[$subpanelID]) && strcasecmp($subModule, $moduleNames[$subpanelID]) === 0) |
|
143 | 143 | { |
144 | 144 | // Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
145 | - $groups [ translate ( $mainTab ) ] [ 'modules' ] [] = $subpanelID ; |
|
146 | - $found [ $subpanelID ] = true ; |
|
145 | + $groups [translate($mainTab)] ['modules'] [] = $subpanelID; |
|
146 | + $found [$subpanelID] = true; |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Put all the remaining subpanels into the 'Other' tab. |
152 | 152 | |
153 | - foreach( $tabs as $subpanelID ) |
|
153 | + foreach ($tabs as $subpanelID) |
|
154 | 154 | { |
155 | - if ( ! isset ( $found [ $subpanelID ] ) ) |
|
156 | - $groups [ translate ('LBL_TABGROUP_OTHER') ]['modules'] [] = $subpanelID ; |
|
155 | + if (!isset ($found [$subpanelID])) |
|
156 | + $groups [translate('LBL_TABGROUP_OTHER')]['modules'] [] = $subpanelID; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /* Move history to same tab as activities */ |
160 | - if(in_array('history', $tabs) && in_array('activities', $tabs)) |
|
160 | + if (in_array('history', $tabs) && in_array('activities', $tabs)) |
|
161 | 161 | { |
162 | - foreach($groups as $mainTab => $group) |
|
162 | + foreach ($groups as $mainTab => $group) |
|
163 | 163 | { |
164 | - if(in_array('activities', array_map('strtolower', $group['modules']))) |
|
164 | + if (in_array('activities', array_map('strtolower', $group['modules']))) |
|
165 | 165 | { |
166 | - if(!in_array('history', array_map('strtolower', $group['modules']))) |
|
166 | + if (!in_array('history', array_map('strtolower', $group['modules']))) |
|
167 | 167 | { |
168 | 168 | /* Move hist from there to here */ |
169 | - $groups[$mainTab]['modules'] []= 'history'; |
|
169 | + $groups[$mainTab]['modules'] [] = 'history'; |
|
170 | 170 | } |
171 | 171 | } |
172 | - else if(false !== ($i = array_search('history', array_map('strtolower', $group['modules'])))) |
|
172 | + else if (false !== ($i = array_search('history', array_map('strtolower', $group['modules'])))) |
|
173 | 173 | { |
174 | 174 | unset($groups[$mainTab]['modules'][$i]); |
175 | - if(empty($groups[$mainTab]['modules'])) |
|
175 | + if (empty($groups[$mainTab]['modules'])) |
|
176 | 176 | { |
177 | 177 | unset($groups[$mainTab]); |
178 | 178 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * Note that if a tab group already exists with the name 'All', |
185 | 185 | * it will be overwritten in this union operation. |
186 | 186 | */ |
187 | - if(count($groups) <= 1) |
|
187 | + if (count($groups) <= 1) |
|
188 | 188 | $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)); |
189 | 189 | else |
190 | 190 | $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)) + $groups; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | |
197 | 197 | $retTabs = array(); |
198 | - if($showTabs) |
|
198 | + if ($showTabs) |
|
199 | 199 | { |
200 | 200 | require_once('include/SubPanel/SugarTab.php'); |
201 | 201 | $sugarTab = new SugarTab(); |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | foreach ($groups as $key=>$tab) |
207 | 207 | { |
208 | 208 | $display = false; |
209 | - foreach($tab['modules'] as $subkey=>$subtab) |
|
209 | + foreach ($tab['modules'] as $subkey=>$subtab) |
|
210 | 210 | { |
211 | - if(in_array(strtolower($subtab), $tabs)) |
|
211 | + if (in_array(strtolower($subtab), $tabs)) |
|
212 | 212 | { |
213 | 213 | $display = true; |
214 | 214 | break; |
@@ -217,30 +217,30 @@ discard block |
||
217 | 217 | |
218 | 218 | $selected = ''; |
219 | 219 | |
220 | - if($selectedGroup == $key) |
|
220 | + if ($selectedGroup == $key) |
|
221 | 221 | { |
222 | 222 | $selected = 'current'; |
223 | 223 | } |
224 | 224 | |
225 | - if($display) |
|
225 | + if ($display) |
|
226 | 226 | { |
227 | 227 | $relevantTabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $key); |
228 | 228 | |
229 | 229 | $sugarTabs[$key] = array(//'url'=>'index.php?module=' . $_REQUEST['module'] . '&record=' . $_REQUEST['record'] . '&action=' . $_REQUEST['action']. '&subpanel=' . $key.'#tabs', |
230 | 230 | //'url'=>"javascript:SUGAR.util.retrieveAndFill('index.php?to_pdf=1&module=MySettings&action=LoadTabSubpanels&loadModule={$_REQUEST['module']}&record={$_REQUEST['record']}&subpanel=$key','subpanel_list',null,null,null);", |
231 | - 'label'=>( !empty($tab['label']) ? $tab['label']: $key ), |
|
231 | + 'label'=>(!empty($tab['label']) ? $tab['label'] : $key), |
|
232 | 232 | 'type'=>$selected); |
233 | 233 | |
234 | 234 | $otherTabs[$key] = array('key'=>$key, 'tabs'=>array()); |
235 | 235 | |
236 | 236 | $orderedTabs = array_intersect($relevantTabs, array_map('strtolower', $groups[$key]['modules'])); |
237 | 237 | |
238 | - foreach($orderedTabs as $subkey => $subtab) |
|
238 | + foreach ($orderedTabs as $subkey => $subtab) |
|
239 | 239 | { |
240 | 240 | $otherTabs[$key]['tabs'][$subkey] = array('key'=>$subtab, 'label'=>translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$subtab]['title_key'])); |
241 | 241 | } |
242 | 242 | |
243 | - if($selectedGroup == $key) |
|
243 | + if ($selectedGroup == $key) |
|
244 | 244 | { |
245 | 245 | $displayTabs = $otherTabs[$key]['tabs']; |
246 | 246 | $retTabs = $orderedTabs; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - if(empty($displayTabs) && !empty($otherTabs)) |
|
251 | + if (empty($displayTabs) && !empty($otherTabs)) |
|
252 | 252 | { |
253 | 253 | //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
254 | 254 | $selectedGroup = translate('LBL_TABGROUP_ALL'); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | $retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules'])); |
258 | 258 | } |
259 | 259 | |
260 | - if (!empty($sugarTabs) || !empty($otherTabs) ) { |
|
260 | + if (!empty($sugarTabs) || !empty($otherTabs)) { |
|
261 | 261 | $sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup); |
262 | 262 | $sugarTab->display(); |
263 | 263 | } |