@@ -114,11 +114,17 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | |
117 | + /** |
|
118 | + * @return string |
|
119 | + */ |
|
117 | 120 | public function unformatField($formattedField, $vardef){ |
118 | 121 | // The base field doesn't do any formatting, so override it in subclasses for more specific actions |
119 | 122 | return $formattedField; |
120 | 123 | } |
121 | 124 | |
125 | + /** |
|
126 | + * @param string $view |
|
127 | + */ |
|
122 | 128 | function getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex = -1, $view){ |
123 | 129 | $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
124 | 130 | |
@@ -376,6 +382,9 @@ discard block |
||
376 | 382 | |
377 | 383 | } |
378 | 384 | |
385 | + /** |
|
386 | + * @param string $fieldType |
|
387 | + */ |
|
379 | 388 | protected function getAccessKey($vardef, $fieldType = null, $module = null) { |
380 | 389 | global $app_strings; |
381 | 390 |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
56 | 56 | */ |
57 | - function SugarFieldBase($type){ |
|
57 | + function SugarFieldBase($type) { |
|
58 | 58 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
59 | - if(isset($GLOBALS['log'])) { |
|
59 | + if (isset($GLOBALS['log'])) { |
|
60 | 60 | $GLOBALS['log']->deprecated($deprecatedMessage); |
61 | 61 | } |
62 | 62 | else { |
@@ -65,55 +65,55 @@ discard block |
||
65 | 65 | self::__construct($type); |
66 | 66 | } |
67 | 67 | |
68 | - function fetch($path){ |
|
68 | + function fetch($path) { |
|
69 | 69 | $additional = ''; |
70 | - if(!$this->hasButton && !empty($this->button)){ |
|
71 | - $additional .= '<input type="button" class="button" ' . $this->button . '>'; |
|
70 | + if (!$this->hasButton && !empty($this->button)) { |
|
71 | + $additional .= '<input type="button" class="button" '.$this->button.'>'; |
|
72 | 72 | } |
73 | - if(!empty($this->buttons)){ |
|
74 | - foreach($this->buttons as $v){ |
|
75 | - $additional .= ' <input type="button" class="button" ' . $v . '>'; |
|
73 | + if (!empty($this->buttons)) { |
|
74 | + foreach ($this->buttons as $v) { |
|
75 | + $additional .= ' <input type="button" class="button" '.$v.'>'; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | } |
79 | - if(!empty($this->image)){ |
|
80 | - $additional .= ' <img ' . $this->image . '>'; |
|
79 | + if (!empty($this->image)) { |
|
80 | + $additional .= ' <img '.$this->image.'>'; |
|
81 | 81 | } |
82 | - return $this->ss->fetch($path) . $additional; |
|
82 | + return $this->ss->fetch($path).$additional; |
|
83 | 83 | } |
84 | 84 | |
85 | - function findTemplate($view){ |
|
85 | + function findTemplate($view) { |
|
86 | 86 | static $tplCache = array(); |
87 | 87 | |
88 | - if ( isset($tplCache[$this->type][$view]) ) { |
|
88 | + if (isset($tplCache[$this->type][$view])) { |
|
89 | 89 | return $tplCache[$this->type][$view]; |
90 | 90 | } |
91 | 91 | |
92 | 92 | $lastClass = get_class($this); |
93 | - $classList = array($this->type,str_replace('SugarField','',$lastClass)); |
|
94 | - while ( $lastClass = get_parent_class($lastClass) ) { |
|
95 | - $classList[] = str_replace('SugarField','',$lastClass); |
|
93 | + $classList = array($this->type, str_replace('SugarField', '', $lastClass)); |
|
94 | + while ($lastClass = get_parent_class($lastClass)) { |
|
95 | + $classList[] = str_replace('SugarField', '', $lastClass); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $tplName = ''; |
99 | - foreach ( $classList as $className ) { |
|
99 | + foreach ($classList as $className) { |
|
100 | 100 | global $current_language; |
101 | - if(isset($current_language)) { |
|
102 | - $tplName = 'include/SugarFields/Fields/'. $className .'/'. $current_language . '.' . $view .'.tpl'; |
|
103 | - if ( file_exists('custom/'.$tplName) ) { |
|
101 | + if (isset($current_language)) { |
|
102 | + $tplName = 'include/SugarFields/Fields/'.$className.'/'.$current_language.'.'.$view.'.tpl'; |
|
103 | + if (file_exists('custom/'.$tplName)) { |
|
104 | 104 | $tplName = 'custom/'.$tplName; |
105 | 105 | break; |
106 | 106 | } |
107 | - if ( file_exists($tplName) ) { |
|
107 | + if (file_exists($tplName)) { |
|
108 | 108 | break; |
109 | 109 | } |
110 | 110 | } |
111 | - $tplName = 'include/SugarFields/Fields/'. $className .'/'. $view .'.tpl'; |
|
112 | - if ( file_exists('custom/'.$tplName) ) { |
|
111 | + $tplName = 'include/SugarFields/Fields/'.$className.'/'.$view.'.tpl'; |
|
112 | + if (file_exists('custom/'.$tplName)) { |
|
113 | 113 | $tplName = 'custom/'.$tplName; |
114 | 114 | break; |
115 | 115 | } |
116 | - if ( file_exists($tplName) ) { |
|
116 | + if (file_exists($tplName)) { |
|
117 | 117 | break; |
118 | 118 | } |
119 | 119 | } |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | return $tplName; |
124 | 124 | } |
125 | 125 | |
126 | - public function formatField($rawField, $vardef){ |
|
126 | + public function formatField($rawField, $vardef) { |
|
127 | 127 | // The base field doesn't do any formatting, so override it in subclasses for more specific actions |
128 | 128 | return $rawField; |
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | - public function unformatField($formattedField, $vardef){ |
|
132 | + public function unformatField($formattedField, $vardef) { |
|
133 | 133 | // The base field doesn't do any formatting, so override it in subclasses for more specific actions |
134 | 134 | return $formattedField; |
135 | 135 | } |
136 | 136 | |
137 | - function getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex = -1, $view){ |
|
137 | + function getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex = -1, $view) { |
|
138 | 138 | $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
139 | 139 | |
140 | 140 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | $this->ss->left_delimiter = '{'; |
160 | 160 | $this->ss->right_delimiter = '}'; |
161 | - $this->ss->assign('col',$vardef['name']); |
|
161 | + $this->ss->assign('col', $vardef['name']); |
|
162 | 162 | |
163 | 163 | return $this->fetch($this->findTemplate('ListView')); |
164 | 164 | } |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | |
180 | 180 | // 99% of all fields will just format like a listview, but just in case, it's here to override |
181 | 181 | function getChangeLogSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
182 | - return $this->formatField($parentFieldArray[$vardef['name']],$vardef); |
|
182 | + return $this->formatField($parentFieldArray[$vardef['name']], $vardef); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
186 | 186 | function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
187 | - if(!empty($vardef['function']['returns']) && $vardef['function']['returns'] == 'html'){ |
|
187 | + if (!empty($vardef['function']['returns']) && $vardef['function']['returns'] == 'html') { |
|
188 | 188 | $type = $this->type; |
189 | 189 | $this->type = 'Base'; |
190 | - $result= $this->getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
190 | + $result = $this->getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
191 | 191 | $this->type = $type; |
192 | 192 | return $result; |
193 | 193 | } |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
211 | - if(!empty($vardef['auto_increment']))$vardef['len']=255; |
|
211 | + if (!empty($vardef['auto_increment']))$vardef['len'] = 255; |
|
212 | 212 | return $this->getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex, 'EditView'); |
213 | 213 | } |
214 | 214 | |
215 | - function getPopupViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex){ |
|
215 | + function getPopupViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
|
216 | 216 | if (is_array($displayParams) && !isset($displayParams['formName'])) |
217 | 217 | $displayParams['formName'] = 'popup_query_form'; |
218 | 218 | else if (empty($displayParams)) |
@@ -220,14 +220,14 @@ discard block |
||
220 | 220 | return $this->getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); |
221 | 221 | } |
222 | 222 | |
223 | - public function getEmailTemplateValue($inputField, $vardef, $context = null){ |
|
223 | + public function getEmailTemplateValue($inputField, $vardef, $context = null) { |
|
224 | 224 | // This does not return a smarty section, instead it returns a direct value |
225 | - return $this->formatField($inputField,$vardef); |
|
225 | + return $this->formatField($inputField, $vardef); |
|
226 | 226 | } |
227 | 227 | |
228 | - function displayFromFunc( $displayType, $parentFieldArray, $vardef, $displayParams, $tabindex = 0 ) { |
|
228 | + function displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex = 0) { |
|
229 | 229 | |
230 | - if ( ! is_array($vardef['function']) ) { |
|
230 | + if (!is_array($vardef['function'])) { |
|
231 | 231 | $funcName = $vardef['function']; |
232 | 232 | $includeFile = ''; |
233 | 233 | $onListView = false; |
@@ -235,28 +235,28 @@ discard block |
||
235 | 235 | } else { |
236 | 236 | $funcName = $vardef['function']['name']; |
237 | 237 | $includeFile = ''; |
238 | - if ( isset($vardef['function']['include']) ) { |
|
238 | + if (isset($vardef['function']['include'])) { |
|
239 | 239 | $includeFile = $vardef['function']['include']; |
240 | 240 | } |
241 | - if ( isset($vardef['function']['onListView']) && $vardef['function']['onListView'] == true ) { |
|
241 | + if (isset($vardef['function']['onListView']) && $vardef['function']['onListView'] == true) { |
|
242 | 242 | $onListView = true; |
243 | 243 | } else { |
244 | 244 | $onListView = false; |
245 | 245 | } |
246 | - if ( isset($vardef['function']['returns']) && $vardef['function']['returns'] == 'html' ) { |
|
246 | + if (isset($vardef['function']['returns']) && $vardef['function']['returns'] == 'html') { |
|
247 | 247 | $returnsHtml = true; |
248 | 248 | } else { |
249 | 249 | $returnsHtml = false; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - if ( $displayType == 'ListView' |
|
253 | + if ($displayType == 'ListView' |
|
254 | 254 | || $displayType == 'popupView' |
255 | 255 | || $displayType == 'searchView' |
256 | 256 | ) { |
257 | 257 | // Traditionally, before 6.0, additional functions were never called, so this code doesn't get called unless the vardef forces it |
258 | - if ( $onListView ) { |
|
259 | - if ( !empty($includeFile) ) { |
|
258 | + if ($onListView) { |
|
259 | + if (!empty($includeFile)) { |
|
260 | 260 | require_once($includeFile); |
261 | 261 | } |
262 | 262 | |
@@ -266,19 +266,19 @@ discard block |
||
266 | 266 | return $this->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex); |
267 | 267 | } |
268 | 268 | } else { |
269 | - if ( !empty($displayParams['idName']) ) { |
|
269 | + if (!empty($displayParams['idName'])) { |
|
270 | 270 | $fieldName = $displayParams['idName']; |
271 | 271 | } else { |
272 | 272 | $fieldName = $vardef['name']; |
273 | 273 | } |
274 | - if ( $returnsHtml ) { |
|
274 | + if ($returnsHtml) { |
|
275 | 275 | $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
276 | 276 | $tpl = $this->findTemplate($displayType.'Function'); |
277 | - if ( $tpl == '' ) { |
|
277 | + if ($tpl == '') { |
|
278 | 278 | // Can't find a function template, just use the base |
279 | 279 | $tpl = $this->findTemplate('DetailViewFunction'); |
280 | 280 | } |
281 | - return "<span id='{$vardef['name']}_span'>" . $this->fetch($tpl) . '</span>'; |
|
281 | + return "<span id='{$vardef['name']}_span'>".$this->fetch($tpl).'</span>'; |
|
282 | 282 | } else { |
283 | 283 | return '{sugar_run_helper include="'.$includeFile.'" func="'.$funcName.'" bean=$bean field="'.$fieldName.'" value=$fields.'.$fieldName.'.value displayType="'.$displayType.'"}'; |
284 | 284 | } |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | * @param $args Mixed value containing haystack to search for value in |
312 | 312 | * @return $value Mixed value that the SugarField should return |
313 | 313 | */ |
314 | - function getSearchInput($key='', $args=array()) |
|
314 | + function getSearchInput($key = '', $args = array()) |
|
315 | 315 | { |
316 | 316 | //Nothing specified return empty string |
317 | - if(empty($key) || empty($args)) |
|
317 | + if (empty($key) || empty($args)) |
|
318 | 318 | { |
319 | 319 | return ''; |
320 | 320 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | /** |
333 | 333 | * Setup function to assign values to the smarty template, should be called before every display function |
334 | 334 | */ |
335 | - function setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass=true) { |
|
335 | + function setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass = true) { |
|
336 | 336 | $this->button = ''; |
337 | 337 | $this->buttons = ''; |
338 | 338 | $this->image = ''; |
@@ -352,36 +352,36 @@ discard block |
||
352 | 352 | |
353 | 353 | //for adding attributes to the field |
354 | 354 | |
355 | - if(!empty($displayParams['field'])){ |
|
355 | + if (!empty($displayParams['field'])) { |
|
356 | 356 | $plusField = ''; |
357 | - foreach($displayParams['field'] as $key=>$value){ |
|
358 | - $plusField .= ' ' . $key . '="' . $value . '"';//bug 27381 |
|
357 | + foreach ($displayParams['field'] as $key=>$value) { |
|
358 | + $plusField .= ' '.$key.'="'.$value.'"'; //bug 27381 |
|
359 | 359 | } |
360 | 360 | $displayParams['field'] = $plusField; |
361 | 361 | } |
362 | 362 | //for adding attributes to the button |
363 | - if(!empty($displayParams['button'])){ |
|
363 | + if (!empty($displayParams['button'])) { |
|
364 | 364 | $plusField = ''; |
365 | - foreach($displayParams['button'] as $key=>$value){ |
|
366 | - $plusField .= ' ' . $key . '="' . $value . '"'; |
|
365 | + foreach ($displayParams['button'] as $key=>$value) { |
|
366 | + $plusField .= ' '.$key.'="'.$value.'"'; |
|
367 | 367 | } |
368 | 368 | $displayParams['button'] = $plusField; |
369 | 369 | $this->button = $displayParams['button']; |
370 | 370 | } |
371 | - if(!empty($displayParams['buttons'])){ |
|
371 | + if (!empty($displayParams['buttons'])) { |
|
372 | 372 | $plusField = ''; |
373 | - foreach($displayParams['buttons'] as $keys=>$values){ |
|
374 | - foreach($values as $key=>$value){ |
|
375 | - $plusField[$keys] .= ' ' . $key . '="' . $value . '"'; |
|
373 | + foreach ($displayParams['buttons'] as $keys=>$values) { |
|
374 | + foreach ($values as $key=>$value) { |
|
375 | + $plusField[$keys] .= ' '.$key.'="'.$value.'"'; |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | $displayParams['buttons'] = $plusField; |
379 | 379 | $this->buttons = $displayParams['buttons']; |
380 | 380 | } |
381 | - if(!empty($displayParams['image'])){ |
|
381 | + if (!empty($displayParams['image'])) { |
|
382 | 382 | $plusField = ''; |
383 | - foreach($displayParams['image'] as $key=>$value){ |
|
384 | - $plusField .= ' ' . $key . '="' . $value . '"'; |
|
383 | + foreach ($displayParams['image'] as $key=>$value) { |
|
384 | + $plusField .= ' '.$key.'="'.$value.'"'; |
|
385 | 385 | } |
386 | 386 | $displayParams['image'] = $plusField; |
387 | 387 | $this->image = $displayParams['image']; |
@@ -401,38 +401,38 @@ discard block |
||
401 | 401 | ); |
402 | 402 | |
403 | 403 | // Labels are always in uppercase |
404 | - if ( isset($fieldType) ) { |
|
404 | + if (isset($fieldType)) { |
|
405 | 405 | $fieldType = strtoupper($fieldType); |
406 | 406 | } |
407 | 407 | |
408 | - if ( isset($module) ) { |
|
408 | + if (isset($module)) { |
|
409 | 409 | $module = strtoupper($module); |
410 | 410 | } |
411 | 411 | |
412 | 412 | // The vardef is the most specific, then the module + fieldType, then the module, then the fieldType |
413 | - if ( isset($vardef['accessKey']) ) { |
|
413 | + if (isset($vardef['accessKey'])) { |
|
414 | 414 | $labelList['accessKey'][] = $vardef['accessKey']; |
415 | 415 | } |
416 | - if ( isset($vardef['accessKeySelect']) ) { |
|
416 | + if (isset($vardef['accessKeySelect'])) { |
|
417 | 417 | $labelList['accessKeySelect'][] = $vardef['accessKeySelect']; |
418 | 418 | } |
419 | - if ( isset($vardef['accessKeyClear']) ) { |
|
419 | + if (isset($vardef['accessKeyClear'])) { |
|
420 | 420 | $labelList['accessKeyClear'][] = $vardef['accessKeyClear']; |
421 | 421 | } |
422 | 422 | |
423 | - if ( isset($fieldType) && isset($module) ) { |
|
423 | + if (isset($fieldType) && isset($module)) { |
|
424 | 424 | $labelList['accessKey'][] = 'LBL_ACCESSKEY_'.$fieldType.'_'.$module; |
425 | 425 | $labelList['accessKeySelect'][] = 'LBL_ACCESSKEY_SELECT_'.$fieldType.'_'.$module; |
426 | 426 | $labelList['accessKeyClear'][] = 'LBL_ACCESSKEY_CLEAR_'.$fieldType.'_'.$module; |
427 | 427 | } |
428 | 428 | |
429 | - if ( isset($module) ) { |
|
429 | + if (isset($module)) { |
|
430 | 430 | $labelList['accessKey'][] = 'LBL_ACCESSKEY_'.$module; |
431 | 431 | $labelList['accessKeySelect'][] = 'LBL_ACCESSKEY_SELECT_'.$module; |
432 | 432 | $labelList['accessKeyClear'][] = 'LBL_ACCESSKEY_CLEAR_'.$module; |
433 | 433 | } |
434 | 434 | |
435 | - if ( isset($fieldType) ) { |
|
435 | + if (isset($fieldType)) { |
|
436 | 436 | $labelList['accessKey'][] = 'LBL_ACCESSKEY_'.$fieldType; |
437 | 437 | $labelList['accessKeySelect'][] = 'LBL_ACCESSKEY_SELECT_'.$fieldType; |
438 | 438 | $labelList['accessKeyClear'][] = 'LBL_ACCESSKEY_CLEAR_'.$fieldType; |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | |
446 | 446 | // Figure out the label and the key for the button. |
447 | 447 | // Later on we may attempt to make sure there are no two buttons with the same keys, but for now we will just use whatever is specified. |
448 | - $keyTypes = array('accessKey','accessKeySelect','accessKeyClear'); |
|
448 | + $keyTypes = array('accessKey', 'accessKeySelect', 'accessKeyClear'); |
|
449 | 449 | $accessKeyList = array( |
450 | 450 | 'accessKey' => '', |
451 | 451 | 'accessKeyLabel' => '', |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | 'accessKeyClearLabel' => '', |
458 | 458 | 'accessKeyClearTitle' => '', |
459 | 459 | ); |
460 | - foreach( $keyTypes as $type ) { |
|
461 | - foreach ( $labelList[$type] as $tryThis ) { |
|
462 | - if ( isset($app_strings[$tryThis.'_KEY']) && isset($app_strings[$tryThis.'_TITLE']) && isset($app_strings[$tryThis.'_LABEL']) ) { |
|
460 | + foreach ($keyTypes as $type) { |
|
461 | + foreach ($labelList[$type] as $tryThis) { |
|
462 | + if (isset($app_strings[$tryThis.'_KEY']) && isset($app_strings[$tryThis.'_TITLE']) && isset($app_strings[$tryThis.'_LABEL'])) { |
|
463 | 463 | $accessKeyList[$type] = $tryThis.'_KEY'; |
464 | 464 | $accessKeyList[$type.'Title'] = $tryThis.'_TITLE'; |
465 | 465 | $accessKeyList[$type.'Label'] = $tryThis.'_LABEL'; |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | * @param array params - an array of paramester relevant to the save, most likely will be $_REQUEST |
478 | 478 | */ |
479 | 479 | public function save(&$bean, $params, $field, $properties, $prefix = '') { |
480 | - if ( isset($params[$prefix.$field]) ) { |
|
481 | - if(isset($properties['len']) && isset($properties['type']) && $this->isTrimmable($properties['type'])){ |
|
480 | + if (isset($params[$prefix.$field])) { |
|
481 | + if (isset($properties['len']) && isset($properties['type']) && $this->isTrimmable($properties['type'])) { |
|
482 | 482 | $bean->$field = trim($this->unformatField($params[$prefix.$field], $properties)); |
483 | 483 | } |
484 | 484 | else { |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | ImportFieldSanitize $settings |
514 | 514 | ) |
515 | 515 | { |
516 | - if( isset($vardef['len']) ) { |
|
516 | + if (isset($vardef['len'])) { |
|
517 | 517 | // check for field length |
518 | 518 | $value = sugar_substr($value, $vardef['len']); |
519 | 519 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | */ |
530 | 530 | protected function isRangeSearchView($vardef) |
531 | 531 | { |
532 | - return !empty($vardef['enable_range_search']) && !empty($_REQUEST['action']) && $_REQUEST['action']!='Popup'; |
|
532 | + return !empty($vardef['enable_range_search']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != 'Popup'; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -545,19 +545,19 @@ discard block |
||
545 | 545 | protected function setupFieldArray($parentFieldArray, $vardef) |
546 | 546 | { |
547 | 547 | $fieldName = $vardef['name']; |
548 | - if ( is_array($parentFieldArray) ) |
|
548 | + if (is_array($parentFieldArray)) |
|
549 | 549 | { |
550 | 550 | $fieldNameUpper = strtoupper($fieldName); |
551 | - if ( isset($parentFieldArray[$fieldNameUpper])) |
|
551 | + if (isset($parentFieldArray[$fieldNameUpper])) |
|
552 | 552 | { |
553 | - $parentFieldArray[$fieldName] = $this->formatField($parentFieldArray[$fieldNameUpper],$vardef); |
|
553 | + $parentFieldArray[$fieldName] = $this->formatField($parentFieldArray[$fieldNameUpper], $vardef); |
|
554 | 554 | } else { |
555 | 555 | $parentFieldArray[$fieldName] = ''; |
556 | 556 | } |
557 | 557 | } elseif (is_object($parentFieldArray)) { |
558 | - if ( isset($parentFieldArray->$fieldName) ) |
|
558 | + if (isset($parentFieldArray->$fieldName)) |
|
559 | 559 | { |
560 | - $parentFieldArray->$fieldName = $this->formatField($parentFieldArray->$fieldName,$vardef); |
|
560 | + $parentFieldArray->$fieldName = $this->formatField($parentFieldArray->$fieldName, $vardef); |
|
561 | 561 | } else { |
562 | 562 | $parentFieldArray->$fieldName = ''; |
563 | 563 | } |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
59 | 59 | if(isset($GLOBALS['log'])) { |
60 | 60 | $GLOBALS['log']->deprecated($deprecatedMessage); |
61 | - } |
|
62 | - else { |
|
61 | + } else { |
|
63 | 62 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
64 | 63 | } |
65 | 64 | self::__construct($type); |
@@ -148,8 +147,7 @@ discard block |
||
148 | 147 | if ($this->type != 'Enum' && $this->type != 'Radioenum') |
149 | 148 | { |
150 | 149 | $parentFieldArray = $this->setupFieldArray($parentFieldArray, $vardef); |
151 | - } |
|
152 | - else |
|
150 | + } else |
|
153 | 151 | { |
154 | 152 | $vardef['name'] = strtoupper($vardef['name']); |
155 | 153 | } |
@@ -208,15 +206,18 @@ discard block |
||
208 | 206 | |
209 | 207 | |
210 | 208 | function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
211 | - if(!empty($vardef['auto_increment']))$vardef['len']=255; |
|
209 | + if(!empty($vardef['auto_increment'])) { |
|
210 | + $vardef['len']=255; |
|
211 | + } |
|
212 | 212 | return $this->getSmartyView($parentFieldArray, $vardef, $displayParams, $tabindex, 'EditView'); |
213 | 213 | } |
214 | 214 | |
215 | 215 | function getPopupViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex){ |
216 | - if (is_array($displayParams) && !isset($displayParams['formName'])) |
|
217 | - $displayParams['formName'] = 'popup_query_form'; |
|
218 | - else if (empty($displayParams)) |
|
219 | - $displayParams = array('formName' => 'popup_query_form'); |
|
216 | + if (is_array($displayParams) && !isset($displayParams['formName'])) { |
|
217 | + $displayParams['formName'] = 'popup_query_form'; |
|
218 | + } else if (empty($displayParams)) { |
|
219 | + $displayParams = array('formName' => 'popup_query_form'); |
|
220 | + } |
|
220 | 221 | return $this->getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); |
221 | 222 | } |
222 | 223 | |
@@ -340,8 +341,7 @@ discard block |
||
340 | 341 | { |
341 | 342 | $this->ss->left_delimiter = '{{'; |
342 | 343 | $this->ss->right_delimiter = '}}'; |
343 | - } |
|
344 | - else |
|
344 | + } else |
|
345 | 345 | { |
346 | 346 | $this->ss->left_delimiter = '{'; |
347 | 347 | $this->ss->right_delimiter = '}'; |
@@ -480,8 +480,7 @@ discard block |
||
480 | 480 | if ( isset($params[$prefix.$field]) ) { |
481 | 481 | if(isset($properties['len']) && isset($properties['type']) && $this->isTrimmable($properties['type'])){ |
482 | 482 | $bean->$field = trim($this->unformatField($params[$prefix.$field], $properties)); |
483 | - } |
|
484 | - else { |
|
483 | + } else { |
|
485 | 484 | $bean->$field = $this->unformatField($params[$prefix.$field], $properties); |
486 | 485 | } |
487 | 486 | } |
@@ -311,17 +311,17 @@ discard block |
||
311 | 311 | $this->optimistic_lock = true; |
312 | 312 | } |
313 | 313 | } |
314 | - $loaded_defs[$this->object_name]['column_fields'] =& $this->column_fields; |
|
315 | - $loaded_defs[$this->object_name]['list_fields'] =& $this->list_fields; |
|
316 | - $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields; |
|
317 | - $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map; |
|
318 | - $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs; |
|
314 | + $loaded_defs[$this->object_name]['column_fields'] = & $this->column_fields; |
|
315 | + $loaded_defs[$this->object_name]['list_fields'] = & $this->list_fields; |
|
316 | + $loaded_defs[$this->object_name]['required_fields'] = & $this->required_fields; |
|
317 | + $loaded_defs[$this->object_name]['field_name_map'] = & $this->field_name_map; |
|
318 | + $loaded_defs[$this->object_name]['field_defs'] = & $this->field_defs; |
|
319 | 319 | } else { |
320 | - $this->column_fields =& $loaded_defs[$this->object_name]['column_fields']; |
|
321 | - $this->list_fields =& $loaded_defs[$this->object_name]['list_fields']; |
|
322 | - $this->required_fields =& $loaded_defs[$this->object_name]['required_fields']; |
|
323 | - $this->field_name_map =& $loaded_defs[$this->object_name]['field_name_map']; |
|
324 | - $this->field_defs =& $loaded_defs[$this->object_name]['field_defs']; |
|
320 | + $this->column_fields = & $loaded_defs[$this->object_name]['column_fields']; |
|
321 | + $this->list_fields = & $loaded_defs[$this->object_name]['list_fields']; |
|
322 | + $this->required_fields = & $loaded_defs[$this->object_name]['required_fields']; |
|
323 | + $this->field_name_map = & $loaded_defs[$this->object_name]['field_name_map']; |
|
324 | + $this->field_defs = & $loaded_defs[$this->object_name]['field_defs']; |
|
325 | 325 | $this->added_custom_field_defs = true; |
326 | 326 | |
327 | 327 | if (!isset($this->custom_fields) && |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
345 | 345 | */ |
346 | - public function SugarBean(){ |
|
346 | + public function SugarBean() { |
|
347 | 347 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
348 | - if(isset($GLOBALS['log'])) { |
|
348 | + if (isset($GLOBALS['log'])) { |
|
349 | 349 | $GLOBALS['log']->deprecated($deprecatedMessage); |
350 | 350 | } |
351 | 351 | else { |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | { |
458 | 458 | //load the module dictionary if not supplied. |
459 | 459 | if ((!isset($dictionary) or empty($dictionary)) && !empty($module_dir)) { |
460 | - $filename = 'modules/' . $module_dir . '/vardefs.php'; |
|
460 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
461 | 461 | if (file_exists($filename)) { |
462 | 462 | include($filename); |
463 | 463 | } |
464 | 464 | } |
465 | 465 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) { |
466 | - $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table " . $tablename . " does not exist"); |
|
467 | - display_notice("meta data absent for table " . $tablename . " keyed to $key "); |
|
466 | + $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
467 | + display_notice("meta data absent for table ".$tablename." keyed to $key "); |
|
468 | 468 | } else { |
469 | 469 | if (isset($dictionary[$key]['relationships'])) { |
470 | 470 | $RelationshipDefs = $dictionary[$key]['relationships']; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | //load the module dictionary if not supplied. |
496 | 496 | if (empty($dictionary) && !empty($module_dir)) { |
497 | 497 | if ($is_custom) { |
498 | - $filename = 'custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php'; |
|
498 | + $filename = 'custom/modules/'.$module_dir.'/Ext/Vardefs/vardefs.ext.php'; |
|
499 | 499 | } else { |
500 | 500 | if ($key == 'User') { |
501 | 501 | // a very special case for the Employees module |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | // Users/vardefs.php |
504 | 504 | $filename = 'modules/Users/vardefs.php'; |
505 | 505 | } else { |
506 | - $filename = 'modules/' . $module_dir . '/vardefs.php'; |
|
506 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | |
@@ -514,14 +514,14 @@ discard block |
||
514 | 514 | $dictionary = $GLOBALS['dictionary']; |
515 | 515 | } |
516 | 516 | } else { |
517 | - $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename); |
|
517 | + $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found".$filename); |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
522 | 522 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) { |
523 | - $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table " . $tablename . " does not exist"); |
|
524 | - display_notice("meta data absent for table " . $tablename . " keyed to $key "); |
|
523 | + $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
524 | + display_notice("meta data absent for table ".$tablename." keyed to $key "); |
|
525 | 525 | } else { |
526 | 526 | if (isset($dictionary[$key]['relationships'])) { |
527 | 527 | $RelationshipDefs = $dictionary[$key]['relationships']; |
@@ -530,18 +530,18 @@ discard block |
||
530 | 530 | $beanList_ucase = array_change_key_case($beanList, CASE_UPPER); |
531 | 531 | foreach ($RelationshipDefs as $rel_name => $rel_def) { |
532 | 532 | if (isset($rel_def['lhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['lhs_module'])])) { |
533 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' lhs module is missing ' . $rel_def['lhs_module']); |
|
533 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' lhs module is missing '.$rel_def['lhs_module']); |
|
534 | 534 | continue; |
535 | 535 | } |
536 | 536 | if (isset($rel_def['rhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['rhs_module'])])) { |
537 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' rhs module is missing ' . $rel_def['rhs_module']); |
|
537 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' rhs module is missing '.$rel_def['rhs_module']); |
|
538 | 538 | continue; |
539 | 539 | } |
540 | 540 | |
541 | 541 | |
542 | 542 | //check whether relationship exists or not first. |
543 | 543 | if (Relationship::exists($rel_name, $db)) { |
544 | - $GLOBALS['log']->debug('Skipping, relationship already exists ' . $rel_name); |
|
544 | + $GLOBALS['log']->debug('Skipping, relationship already exists '.$rel_name); |
|
545 | 545 | } else { |
546 | 546 | $seed = BeanFactory::getBean("Relationships"); |
547 | 547 | $keys = array_keys($seed->field_defs); |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | |
560 | 560 | |
561 | 561 | $column_list = implode(",", array_keys($toInsert)); |
562 | - $value_list = "'" . implode("','", array_values($toInsert)) . "'"; |
|
562 | + $value_list = "'".implode("','", array_values($toInsert))."'"; |
|
563 | 563 | |
564 | 564 | //create the record. todo add error check. |
565 | - $insert_string = "INSERT into relationships (" . $column_list . ") values (" . $value_list . ")"; |
|
565 | + $insert_string = "INSERT into relationships (".$column_list.") values (".$value_list.")"; |
|
566 | 566 | $db->query($insert_string, true); |
567 | 567 | } |
568 | 568 | } |
@@ -638,11 +638,11 @@ discard block |
||
638 | 638 | $tmp_final_query = $parentbean->$shortcut_function_name(); |
639 | 639 | } |
640 | 640 | if (!$first) { |
641 | - $final_query_rows .= ' UNION ALL ( ' . $parentbean->create_list_count_query($tmp_final_query, $parameters) . ' )'; |
|
642 | - $final_query .= ' UNION ALL ( ' . $tmp_final_query . ' )'; |
|
641 | + $final_query_rows .= ' UNION ALL ( '.$parentbean->create_list_count_query($tmp_final_query, $parameters).' )'; |
|
642 | + $final_query .= ' UNION ALL ( '.$tmp_final_query.' )'; |
|
643 | 643 | } else { |
644 | - $final_query_rows = '(' . $parentbean->create_list_count_query($tmp_final_query, $parameters) . ')'; |
|
645 | - $final_query = '(' . $tmp_final_query . ')'; |
|
644 | + $final_query_rows = '('.$parentbean->create_list_count_query($tmp_final_query, $parameters).')'; |
|
645 | + $final_query = '('.$tmp_final_query.')'; |
|
646 | 646 | $first = false; |
647 | 647 | } |
648 | 648 | } |
@@ -673,32 +673,32 @@ discard block |
||
673 | 673 | } |
674 | 674 | $subquery['select'] = substr($subquery['select'], 0, strlen($subquery['select']) - 1); |
675 | 675 | //Put the query into the final_query |
676 | - $query = $subquery['select'] . " " . $subquery['from'] . " " . $subquery['where']; |
|
676 | + $query = $subquery['select']." ".$subquery['from']." ".$subquery['where']; |
|
677 | 677 | if (!$first) { |
678 | - $query = ' UNION ALL ( ' . $query . ' )'; |
|
678 | + $query = ' UNION ALL ( '.$query.' )'; |
|
679 | 679 | $final_query_rows .= " UNION ALL "; |
680 | 680 | } else { |
681 | - $query = '(' . $query . ')'; |
|
681 | + $query = '('.$query.')'; |
|
682 | 682 | $first = false; |
683 | 683 | } |
684 | 684 | $query_array = $subquery['query_array']; |
685 | 685 | $select_position = strpos($query_array['select'], "SELECT"); |
686 | 686 | $distinct_position = strpos($query_array['select'], "DISTINCT"); |
687 | 687 | if (!empty($subquery['params']['distinct']) && !empty($subpanel_def->table_name)) { |
688 | - $query_rows = "( SELECT count(DISTINCT " . $subpanel_def->table_name . ".id)" . $subquery['from_min'] . $query_array['join'] . $subquery['where'] . ' )'; |
|
688 | + $query_rows = "( SELECT count(DISTINCT ".$subpanel_def->table_name.".id)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
689 | 689 | } elseif ($select_position !== false && $distinct_position != false) { |
690 | - $query_rows = "( " . substr_replace($query_array['select'], "SELECT count(", $select_position, 6) . ")" . $subquery['from_min'] . $query_array['join'] . $subquery['where'] . ' )'; |
|
690 | + $query_rows = "( ".substr_replace($query_array['select'], "SELECT count(", $select_position, 6).")".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
691 | 691 | } else { |
692 | 692 | //resort to default behavior. |
693 | - $query_rows = "( SELECT count(*)" . $subquery['from_min'] . $query_array['join'] . $subquery['where'] . ' )'; |
|
693 | + $query_rows = "( SELECT count(*)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
694 | 694 | } |
695 | 695 | if (!empty($subquery['secondary_select'])) { |
696 | - $subquerystring = $subquery['secondary_select'] . $subquery['secondary_from'] . $query_array['join'] . $subquery['where']; |
|
696 | + $subquerystring = $subquery['secondary_select'].$subquery['secondary_from'].$query_array['join'].$subquery['where']; |
|
697 | 697 | if (!empty($subquery['secondary_where'])) { |
698 | 698 | if (empty($subquery['where'])) { |
699 | - $subquerystring .= " WHERE " . $subquery['secondary_where']; |
|
699 | + $subquerystring .= " WHERE ".$subquery['secondary_where']; |
|
700 | 700 | } else { |
701 | - $subquerystring .= " AND " . $subquery['secondary_where']; |
|
701 | + $subquerystring .= " AND ".$subquery['secondary_where']; |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | $secondary_queries[] = $subquerystring; |
@@ -721,12 +721,12 @@ discard block |
||
721 | 721 | } |
722 | 722 | |
723 | 723 | if (!empty($sort_order)) { |
724 | - $order_by .= ' ' . $sort_order; |
|
724 | + $order_by .= ' '.$sort_order; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | $order_by = $parentbean->process_order_by($order_by, $submodule, $suppress_table_name); |
728 | 728 | if (!empty($order_by)) { |
729 | - $final_query .= ' ORDER BY ' . $order_by; |
|
729 | + $final_query .= ' ORDER BY '.$order_by; |
|
730 | 730 | } |
731 | 731 | } |
732 | 732 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | if (empty($where_definition)) { |
795 | 795 | $where_definition = $table_where; |
796 | 796 | } else { |
797 | - $where_definition .= ' AND ' . $table_where; |
|
797 | + $where_definition .= ' AND '.$table_where; |
|
798 | 798 | } |
799 | 799 | } |
800 | 800 | |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | |
816 | 816 | |
817 | 817 | if (!$subpanel_def->isCollection() && isset($list_fields[$order_by]) && isset($submodule->field_defs[$order_by]) && (!isset($submodule->field_defs[$order_by]['source']) || $submodule->field_defs[$order_by]['source'] == 'db')) { |
818 | - $order_by = $submodule->table_name . '.' . $order_by; |
|
818 | + $order_by = $submodule->table_name.'.'.$order_by; |
|
819 | 819 | } |
820 | 820 | $table_name = $this_subpanel->table_name; |
821 | 821 | $panel_name = $this_subpanel->name; |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | |
832 | 832 | $subquery = $submodule->create_new_list_query('', $subwhere, $list_fields, $params, 0, '', true, $parentbean, $singleSelect); |
833 | 833 | |
834 | - $subquery['select'] = $subquery['select'] . " , '$panel_name' panel_name "; |
|
835 | - $subquery['from'] = $subquery['from'] . $query_array['join']; |
|
834 | + $subquery['select'] = $subquery['select']." , '$panel_name' panel_name "; |
|
835 | + $subquery['from'] = $subquery['from'].$query_array['join']; |
|
836 | 836 | $subquery['query_array'] = $query_array; |
837 | 837 | $subquery['params'] = $params; |
838 | 838 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | $use_count_query = false; |
871 | 871 | $processing_collection = $subpanel_def->isCollection(); |
872 | 872 | |
873 | - $GLOBALS['log']->debug("process_union_list_query: " . $query); |
|
873 | + $GLOBALS['log']->debug("process_union_list_query: ".$query); |
|
874 | 874 | if ($max_per_page == -1) { |
875 | 875 | $max_per_page = $sugar_config['list_max_entries_per_subpanel']; |
876 | 876 | } |
@@ -947,9 +947,9 @@ discard block |
||
947 | 947 | if (isset($row[$field])) { |
948 | 948 | $current_bean->$field = $this->convertField($row[$field], $value); |
949 | 949 | unset($row[$field]); |
950 | - } elseif (isset($row[$this->table_name . '.' . $field])) { |
|
951 | - $current_bean->$field = $this->convertField($row[$this->table_name . '.' . $field], $value); |
|
952 | - unset($row[$this->table_name . '.' . $field]); |
|
950 | + } elseif (isset($row[$this->table_name.'.'.$field])) { |
|
951 | + $current_bean->$field = $this->convertField($row[$this->table_name.'.'.$field], $value); |
|
952 | + unset($row[$this->table_name.'.'.$field]); |
|
953 | 953 | } else { |
954 | 954 | $current_bean->$field = ""; |
955 | 955 | unset($row[$field]); |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | $class = $beanList[$child_info['parent_type']]; |
1117 | 1117 | // Added to avoid error below; just silently fail and write message to log |
1118 | 1118 | if (empty($beanFiles[$class])) { |
1119 | - $GLOBALS['log']->error($this->object_name . '::retrieve_parent_fields() - cannot load class "' . $class . '", skip loading.'); |
|
1119 | + $GLOBALS['log']->error($this->object_name.'::retrieve_parent_fields() - cannot load class "'.$class.'", skip loading.'); |
|
1120 | 1120 | continue; |
1121 | 1121 | } |
1122 | 1122 | require_once($beanFiles[$class]); |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | $queries[$child_info['parent_type']] = "SELECT id "; |
1128 | 1128 | $field_def = $templates[$child_info['parent_type']]->field_defs['name']; |
1129 | 1129 | if (isset($field_def['db_concat_fields'])) { |
1130 | - $queries[$child_info['parent_type']] .= ' , ' . $this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']) . ' parent_name'; |
|
1130 | + $queries[$child_info['parent_type']] .= ' , '.$this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']).' parent_name'; |
|
1131 | 1131 | } else { |
1132 | 1132 | $queries[$child_info['parent_type']] .= ' , name parent_name'; |
1133 | 1133 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | } elseif (isset($templates[$child_info['parent_type']]->field_defs['created_by'])) { |
1138 | 1138 | $queries[$child_info['parent_type']] .= ", created_by parent_name_owner, '{$child_info['parent_type']}' parent_name_mod"; |
1139 | 1139 | } |
1140 | - $queries[$child_info['parent_type']] .= " FROM " . $templates[$child_info['parent_type']]->table_name . " WHERE id IN ('{$child_info['parent_id']}'"; |
|
1140 | + $queries[$child_info['parent_type']] .= " FROM ".$templates[$child_info['parent_type']]->table_name." WHERE id IN ('{$child_info['parent_id']}'"; |
|
1141 | 1141 | } else { |
1142 | 1142 | if (empty($parent_child_map[$child_info['parent_id']])) { |
1143 | 1143 | $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'"; |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | } |
1150 | 1150 | $results = array(); |
1151 | 1151 | foreach ($queries as $query) { |
1152 | - $result = $this->db->query($query . ')'); |
|
1152 | + $result = $this->db->query($query.')'); |
|
1153 | 1153 | while ($row = $this->db->fetchByAssoc($result)) { |
1154 | 1154 | $results[$row['id']] = $row; |
1155 | 1155 | } |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | */ |
1235 | 1235 | public function get_custom_table_name() |
1236 | 1236 | { |
1237 | - return $this->getTableName() . '_cstm'; |
|
1237 | + return $this->getTableName().'_cstm'; |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | */ |
1475 | 1475 | public function load_relationship($rel_name) |
1476 | 1476 | { |
1477 | - $GLOBALS['log']->debug("SugarBean[{$this->object_name}].load_relationships, Loading relationship (" . $rel_name . ")."); |
|
1477 | + $GLOBALS['log']->debug("SugarBean[{$this->object_name}].load_relationships, Loading relationship (".$rel_name.")."); |
|
1478 | 1478 | |
1479 | 1479 | if (empty($rel_name)) { |
1480 | 1480 | $GLOBALS['log']->error("SugarBean.load_relationships, Null relationship name passed."); |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | return true; |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | - $GLOBALS['log']->debug("SugarBean.load_relationships, Error Loading relationship (" . $rel_name . ")"); |
|
1512 | + $GLOBALS['log']->debug("SugarBean.load_relationships, Error Loading relationship (".$rel_name.")"); |
|
1513 | 1513 | return false; |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | $idField = $value_array['id_name']; |
1617 | 1617 | if (isset($fieldDefs[$idField]) && isset($fieldDefs[$idField]['type']) && $fieldDefs[$idField]['type'] == 'link') { |
1618 | 1618 | $tmpFieldDefs = $fieldDefs[$idField]; |
1619 | - $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir) . " " . $GLOBALS['app_strings']['LBL_ID']; |
|
1619 | + $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir)." ".$GLOBALS['app_strings']['LBL_ID']; |
|
1620 | 1620 | $importableFields[$idField] = $tmpFieldDefs; |
1621 | 1621 | } |
1622 | 1622 | } |
@@ -1640,8 +1640,8 @@ discard block |
||
1640 | 1640 | |
1641 | 1641 | $key = $this->getObjectName(); |
1642 | 1642 | if (!array_key_exists($key, $dictionary)) { |
1643 | - $GLOBALS['log']->fatal("create_tables: Metadata for table " . $this->table_name . " does not exist"); |
|
1644 | - display_notice("meta data absent for table " . $this->table_name . " keyed to $key "); |
|
1643 | + $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name." does not exist"); |
|
1644 | + display_notice("meta data absent for table ".$this->table_name." keyed to $key "); |
|
1645 | 1645 | } else { |
1646 | 1646 | if (!$this->db->tableExists($this->table_name)) { |
1647 | 1647 | $this->db->createTable($this); |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | */ |
1703 | 1703 | public function get_audit_table_name() |
1704 | 1704 | { |
1705 | - return $this->getTableName() . '_audit'; |
|
1705 | + return $this->getTableName().'_audit'; |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | 1708 | /** |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | require('metadata/audit_templateMetaData.php'); |
1721 | 1721 | |
1722 | 1722 | // Bug: 52583 Need ability to customize template for audit tables |
1723 | - $custom = 'custom/metadata/audit_templateMetaData_' . $this->getTableName() . '.php'; |
|
1723 | + $custom = 'custom/metadata/audit_templateMetaData_'.$this->getTableName().'.php'; |
|
1724 | 1724 | if (file_exists($custom)) { |
1725 | 1725 | require($custom); |
1726 | 1726 | } |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | |
1731 | 1731 | // Renaming template indexes to fit the particular audit table (removed the brittle hard coding) |
1732 | 1732 | foreach ($indices as $nr => $properties) { |
1733 | - $indices[$nr]['name'] = 'idx_' . strtolower($this->getTableName()) . '_' . $properties['name']; |
|
1733 | + $indices[$nr]['name'] = 'idx_'.strtolower($this->getTableName()).'_'.$properties['name']; |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | $engine = null; |
@@ -1754,8 +1754,8 @@ discard block |
||
1754 | 1754 | global $dictionary; |
1755 | 1755 | $key = $this->getObjectName(); |
1756 | 1756 | if (!array_key_exists($key, $dictionary)) { |
1757 | - $GLOBALS['log']->fatal("drop_tables: Metadata for table " . $this->table_name . " does not exist"); |
|
1758 | - echo "meta data absent for table " . $this->table_name . "<br>\n"; |
|
1757 | + $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name." does not exist"); |
|
1758 | + echo "meta data absent for table ".$this->table_name."<br>\n"; |
|
1759 | 1759 | } else { |
1760 | 1760 | if (empty($this->table_name)) { |
1761 | 1761 | return; |
@@ -1763,8 +1763,8 @@ discard block |
||
1763 | 1763 | if ($this->db->tableExists($this->table_name)) { |
1764 | 1764 | $this->db->dropTable($this); |
1765 | 1765 | } |
1766 | - if ($this->db->tableExists($this->table_name . '_cstm')) { |
|
1767 | - $this->db->dropTableName($this->table_name . '_cstm'); |
|
1766 | + if ($this->db->tableExists($this->table_name.'_cstm')) { |
|
1767 | + $this->db->dropTableName($this->table_name.'_cstm'); |
|
1768 | 1768 | DynamicField::deleteCache(); |
1769 | 1769 | } |
1770 | 1770 | if ($this->db->tableExists($this->get_audit_table_name())) { |
@@ -2059,7 +2059,7 @@ discard block |
||
2059 | 2059 | break; |
2060 | 2060 | } |
2061 | 2061 | if ($reformatted) { |
2062 | - $GLOBALS['log']->deprecated('Formatting correction: ' . $this->module_dir . '->' . $field . ' had formatting automatically corrected. This will be removed in the future, please upgrade your external code'); |
|
2062 | + $GLOBALS['log']->deprecated('Formatting correction: '.$this->module_dir.'->'.$field.' had formatting automatically corrected. This will be removed in the future, please upgrade your external code'); |
|
2063 | 2063 | } |
2064 | 2064 | } |
2065 | 2065 | } |
@@ -2101,7 +2101,7 @@ discard block |
||
2101 | 2101 | $_SESSION['o_lock_object'] = $this->toArray(); |
2102 | 2102 | $saveform = "<form name='save' id='save' method='POST'>"; |
2103 | 2103 | foreach ($_POST as $key => $arg) { |
2104 | - $saveform .= "<input type='hidden' name='" . addslashes($key) . "' value='" . addslashes($arg) . "'>"; |
|
2104 | + $saveform .= "<input type='hidden' name='".addslashes($key)."' value='".addslashes($arg)."'>"; |
|
2105 | 2105 | } |
2106 | 2106 | $saveform .= "</form><script>document.getElementById('save').submit();</script>"; |
2107 | 2107 | $_SESSION['o_lock_save'] = $saveform; |
@@ -2281,7 +2281,7 @@ discard block |
||
2281 | 2281 | if ($rel_name == $new_rel_link && $this->$id != $new_rel_id) { |
2282 | 2282 | $new_rel_id = ''; |
2283 | 2283 | } |
2284 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: ' . $rel_name . ' = ' . $this->$id); |
|
2284 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: '.$rel_name.' = '.$this->$id); |
|
2285 | 2285 | //already related the new relationship id so let's set it to false so we don't add it again using the _REQUEST['relate_i'] mechanism in a later block |
2286 | 2286 | $this->load_relationship($rel_name); |
2287 | 2287 | $rel_add = $this->$rel_name->add($this->$id); |
@@ -2292,7 +2292,7 @@ discard block |
||
2292 | 2292 | } else { |
2293 | 2293 | //if before value is not empty then attempt to delete relationship |
2294 | 2294 | if (!empty($this->rel_fields_before_value[$id])) { |
2295 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute' . $rel_name); |
|
2295 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute'.$rel_name); |
|
2296 | 2296 | $this->load_relationship($rel_name); |
2297 | 2297 | $this->$rel_name->delete($this->id, $this->rel_fields_before_value[$id]); |
2298 | 2298 | } |
@@ -2334,7 +2334,7 @@ discard block |
||
2334 | 2334 | |
2335 | 2335 | if (!empty($this->rel_fields_before_value[$idName]) && empty($this->$idName)) { |
2336 | 2336 | //if before value is not empty then attempt to delete relationship |
2337 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record: {$def [ 'link' ]} = {$this->rel_fields_before_value[$def [ 'id_name' ]]}"); |
|
2337 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record: {$def ['link']} = {$this->rel_fields_before_value[$def ['id_name']]}"); |
|
2338 | 2338 | $success = $this->$def ['link']->delete($this->id, $this->rel_fields_before_value[$def ['id_name']]); |
2339 | 2339 | // just need to make sure it's true and not an array as it's possible to return an array |
2340 | 2340 | if ($success == true) { |
@@ -2342,11 +2342,11 @@ discard block |
||
2342 | 2342 | } else { |
2343 | 2343 | $modified_relationships['remove']['failure'][] = $def['link']; |
2344 | 2344 | } |
2345 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned " . var_export($success, true)); |
|
2345 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned ".var_export($success, true)); |
|
2346 | 2346 | } |
2347 | 2347 | |
2348 | 2348 | if (!empty($this->$idName) && is_string($this->$idName)) { |
2349 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to add a relationship record - {$def [ 'link' ]} = {$this->$def [ 'id_name' ]}"); |
|
2349 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to add a relationship record - {$def ['link']} = {$this->$def ['id_name']}"); |
|
2350 | 2350 | |
2351 | 2351 | $success = $this->$linkField->add($this->$idName); |
2352 | 2352 | |
@@ -2357,7 +2357,7 @@ discard block |
||
2357 | 2357 | $modified_relationships['add']['failure'][] = $linkField; |
2358 | 2358 | } |
2359 | 2359 | |
2360 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned " . var_export($success, true)); |
|
2360 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned ".var_export($success, true)); |
|
2361 | 2361 | } |
2362 | 2362 | } else { |
2363 | 2363 | $GLOBALS['log']->fatal("Failed to load relationship {$linkField} while saving {$this->module_dir}"); |
@@ -2741,10 +2741,10 @@ discard block |
||
2741 | 2741 | $template_name = "Default"; |
2742 | 2742 | } |
2743 | 2743 | if (!empty($_SESSION["special_notification"]) && $_SESSION["special_notification"]) { |
2744 | - $template_name = $beanList[$this->module_dir] . 'Special'; |
|
2744 | + $template_name = $beanList[$this->module_dir].'Special'; |
|
2745 | 2745 | } |
2746 | 2746 | if ($this->special_notification) { |
2747 | - $template_name = $beanList[$this->module_dir] . 'Special'; |
|
2747 | + $template_name = $beanList[$this->module_dir].'Special'; |
|
2748 | 2748 | } |
2749 | 2749 | $xtpl->assign("ASSIGNED_USER", $this->new_assigned_user_name); |
2750 | 2750 | $xtpl->assign("ASSIGNER", $current_user->name); |
@@ -2755,17 +2755,17 @@ discard block |
||
2755 | 2755 | $parsedSiteUrl['port'] = 80; |
2756 | 2756 | } |
2757 | 2757 | |
2758 | - $port = ($parsedSiteUrl['port'] != 80) ? ":" . $parsedSiteUrl['port'] : ''; |
|
2758 | + $port = ($parsedSiteUrl['port'] != 80) ? ":".$parsedSiteUrl['port'] : ''; |
|
2759 | 2759 | $path = !empty($parsedSiteUrl['path']) ? $parsedSiteUrl['path'] : ""; |
2760 | 2760 | $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}"; |
2761 | 2761 | |
2762 | - $xtpl->assign("URL", $cleanUrl . "/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}"); |
|
2762 | + $xtpl->assign("URL", $cleanUrl."/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}"); |
|
2763 | 2763 | $xtpl->assign("SUGAR", "Sugar v{$sugar_version}"); |
2764 | 2764 | $xtpl->parse($template_name); |
2765 | - $xtpl->parse($template_name . "_Subject"); |
|
2765 | + $xtpl->parse($template_name."_Subject"); |
|
2766 | 2766 | |
2767 | 2767 | $notify_mail->Body = from_html(trim($xtpl->text($template_name))); |
2768 | - $notify_mail->Subject = from_html($xtpl->text($template_name . "_Subject")); |
|
2768 | + $notify_mail->Subject = from_html($xtpl->text($template_name."_Subject")); |
|
2769 | 2769 | |
2770 | 2770 | // cn: bug 8568 encode notify email in User's outbound email encoding |
2771 | 2771 | $notify_mail->prepForOutbound(); |
@@ -2857,7 +2857,7 @@ discard block |
||
2857 | 2857 | if (empty($where)) { |
2858 | 2858 | $where = $owner_where; |
2859 | 2859 | } else { |
2860 | - $where .= ' AND ' . $owner_where; |
|
2860 | + $where .= ' AND '.$owner_where; |
|
2861 | 2861 | } |
2862 | 2862 | } |
2863 | 2863 | } |
@@ -2911,7 +2911,7 @@ discard block |
||
2911 | 2911 | if (empty($where)) { |
2912 | 2912 | $where = $owner_where; |
2913 | 2913 | } else { |
2914 | - $where .= ' AND ' . $owner_where; |
|
2914 | + $where .= ' AND '.$owner_where; |
|
2915 | 2915 | } |
2916 | 2916 | } |
2917 | 2917 | /* BEGIN - SECURITY GROUPS */ |
@@ -2925,9 +2925,9 @@ discard block |
||
2925 | 2925 | $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
2926 | 2926 | //$group_where = "user_name = 'admin'"; |
2927 | 2927 | if (empty($where)) { |
2928 | - $where = " (" . $group_where . ") "; |
|
2928 | + $where = " (".$group_where.") "; |
|
2929 | 2929 | } else { |
2930 | - $where .= " AND (" . $group_where . ") "; |
|
2930 | + $where .= " AND (".$group_where.") "; |
|
2931 | 2931 | } |
2932 | 2932 | } elseif ($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list')) { |
2933 | 2933 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
@@ -2936,12 +2936,12 @@ discard block |
||
2936 | 2936 | $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
2937 | 2937 | if (!empty($owner_where)) { |
2938 | 2938 | if (empty($where)) { |
2939 | - $where = " (" . $owner_where . " or " . $group_where . ") "; |
|
2939 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
2940 | 2940 | } else { |
2941 | - $where .= " AND (" . $owner_where . " or " . $group_where . ") "; |
|
2941 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
2942 | 2942 | } |
2943 | 2943 | } else { |
2944 | - $where .= ' AND ' . $group_where; |
|
2944 | + $where .= ' AND '.$group_where; |
|
2945 | 2945 | } |
2946 | 2946 | } |
2947 | 2947 | /* END - SECURITY GROUPS */ |
@@ -2960,7 +2960,7 @@ discard block |
||
2960 | 2960 | $ret_array['order_by'] = ''; |
2961 | 2961 | //secondary selects are selects that need to be run after the primary query to retrieve additional info on main |
2962 | 2962 | if ($singleSelect) { |
2963 | - $ret_array['secondary_select'] =& $ret_array['select']; |
|
2963 | + $ret_array['secondary_select'] = & $ret_array['select']; |
|
2964 | 2964 | $ret_array['secondary_from'] = &$ret_array['from']; |
2965 | 2965 | } else { |
2966 | 2966 | $ret_array['secondary_select'] = ''; |
@@ -3034,7 +3034,7 @@ discard block |
||
3034 | 3034 | //alias is used to alias field names |
3035 | 3035 | $alias = ''; |
3036 | 3036 | if (isset($value['alias'])) { |
3037 | - $alias = ' as ' . $value['alias'] . ' '; |
|
3037 | + $alias = ' as '.$value['alias'].' '; |
|
3038 | 3038 | } |
3039 | 3039 | |
3040 | 3040 | if (empty($this->field_defs[$field]) || !empty($value['force_blank'])) { |
@@ -3073,29 +3073,29 @@ discard block |
||
3073 | 3073 | $selectedFields["$this->table_name.$field"] = true; |
3074 | 3074 | } elseif ((!isset($data['source']) || $data['source'] == 'custom_fields') && (!empty($alias) || !empty($filter))) { |
3075 | 3075 | //add this column only if it has NOT already been added to select statement string |
3076 | - $colPos = strpos($ret_array['select'], "$this->table_name" . "_cstm" . ".$field"); |
|
3076 | + $colPos = strpos($ret_array['select'], "$this->table_name"."_cstm".".$field"); |
|
3077 | 3077 | if (!$colPos || $colPos < 0) { |
3078 | - $ret_array['select'] .= ", $this->table_name" . "_cstm" . ".$field $alias"; |
|
3078 | + $ret_array['select'] .= ", $this->table_name"."_cstm".".$field $alias"; |
|
3079 | 3079 | } |
3080 | 3080 | |
3081 | 3081 | $selectedFields["$this->table_name.$field"] = true; |
3082 | 3082 | } |
3083 | 3083 | |
3084 | 3084 | if ($data['type'] != 'relate' && isset($data['db_concat_fields'])) { |
3085 | - $ret_array['select'] .= ", " . $this->db->concat($this->table_name, $data['db_concat_fields']) . " as $field"; |
|
3085 | + $ret_array['select'] .= ", ".$this->db->concat($this->table_name, $data['db_concat_fields'])." as $field"; |
|
3086 | 3086 | $selectedFields[$this->db->concat($this->table_name, $data['db_concat_fields'])] = true; |
3087 | 3087 | } |
3088 | 3088 | //Custom relate field or relate fields built in module builder which have no link field associated. |
3089 | 3089 | if ($data['type'] == 'relate' && (isset($data['custom_module']) || isset($data['ext2']))) { |
3090 | - $joinTableAlias = 'jt' . $jtcount; |
|
3090 | + $joinTableAlias = 'jt'.$jtcount; |
|
3091 | 3091 | $relateJoinInfo = $this->custom_fields->getRelateJoin($data, $joinTableAlias, false); |
3092 | 3092 | $ret_array['select'] .= $relateJoinInfo['select']; |
3093 | 3093 | $ret_array['from'] .= $relateJoinInfo['from']; |
3094 | 3094 | //Replace any references to the relationship in the where clause with the new alias |
3095 | 3095 | //If the link isn't set, assume that search used the local table for the field |
3096 | 3096 | $searchTable = isset($data['link']) ? $relateJoinInfo['rel_table'] : $this->table_name; |
3097 | - $field_name = $relateJoinInfo['rel_table'] . '.' . !empty($data['name']) ? $data['name'] : 'name'; |
|
3098 | - $where = preg_replace('/(^|[\s(])' . $field_name . '/', '${1}' . $relateJoinInfo['name_field'], $where); |
|
3097 | + $field_name = $relateJoinInfo['rel_table'].'.'.!empty($data['name']) ? $data['name'] : 'name'; |
|
3098 | + $where = preg_replace('/(^|[\s(])'.$field_name.'/', '${1}'.$relateJoinInfo['name_field'], $where); |
|
3099 | 3099 | $jtcount++; |
3100 | 3100 | } |
3101 | 3101 | //Parent Field |
@@ -3103,7 +3103,7 @@ discard block |
||
3103 | 3103 | //See if we need to join anything by inspecting the where clause |
3104 | 3104 | $match = preg_match('/(^|[\s(])parent_([a-zA-Z]+_?[a-zA-Z]+)_([a-zA-Z]+_?[a-zA-Z]+)\.name/', $where, $matches); |
3105 | 3105 | if ($match) { |
3106 | - $joinTableAlias = 'jt' . $jtcount; |
|
3106 | + $joinTableAlias = 'jt'.$jtcount; |
|
3107 | 3107 | $joinModule = $matches[2]; |
3108 | 3108 | $joinTable = $matches[3]; |
3109 | 3109 | $localTable = $this->table_name; |
@@ -3124,7 +3124,7 @@ discard block |
||
3124 | 3124 | $ret_array['from'] .= " LEFT JOIN $joinTable $joinTableAlias |
3125 | 3125 | ON $localTable.{$data['id_name']} = $joinTableAlias.id"; |
3126 | 3126 | //Replace any references to the relationship in the where clause with the new alias |
3127 | - $where = preg_replace('/(^|[\s(])parent_' . $joinModule . '_' . $joinTable . '\.name/', '${1}' . $nameField, $where); |
|
3127 | + $where = preg_replace('/(^|[\s(])parent_'.$joinModule.'_'.$joinTable.'\.name/', '${1}'.$nameField, $where); |
|
3128 | 3128 | $jtcount++; |
3129 | 3129 | } |
3130 | 3130 | } |
@@ -3133,7 +3133,7 @@ discard block |
||
3133 | 3133 | { |
3134 | 3134 | $linkField = $data['link']; |
3135 | 3135 | $this->load_relationship($linkField); |
3136 | - if(!empty($this->$linkField)) |
|
3136 | + if (!empty($this->$linkField)) |
|
3137 | 3137 | { |
3138 | 3138 | $params = array(); |
3139 | 3139 | if (empty($join_type)) { |
@@ -3144,12 +3144,12 @@ discard block |
||
3144 | 3144 | if (isset($data['join_name'])) { |
3145 | 3145 | $params['join_table_alias'] = $data['join_name']; |
3146 | 3146 | } else { |
3147 | - $params['join_table_alias'] = 'jt' . $jtcount; |
|
3147 | + $params['join_table_alias'] = 'jt'.$jtcount; |
|
3148 | 3148 | } |
3149 | 3149 | if (isset($data['join_link_name'])) { |
3150 | 3150 | $params['join_table_link_alias'] = $data['join_link_name']; |
3151 | 3151 | } else { |
3152 | - $params['join_table_link_alias'] = 'jtl' . $jtcount; |
|
3152 | + $params['join_table_link_alias'] = 'jtl'.$jtcount; |
|
3153 | 3153 | } |
3154 | 3154 | $join_primary = !isset($data['join_primary']) || $data['join_primary']; |
3155 | 3155 | |
@@ -3182,20 +3182,20 @@ discard block |
||
3182 | 3182 | require_once($beanFiles[$beanList[$rel_module]]); |
3183 | 3183 | $rel_mod = new $beanList[$rel_module](); |
3184 | 3184 | if (isset($rel_mod->field_defs['assigned_user_id'])) { |
3185 | - $ret_array['secondary_select'] .= " , " . $params['join_table_alias'] . ".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
3185 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
3186 | 3186 | } else { |
3187 | 3187 | if (isset($rel_mod->field_defs['created_by'])) { |
3188 | - $ret_array['secondary_select'] .= " , " . $params['join_table_alias'] . ".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
3188 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
3189 | 3189 | } |
3190 | 3190 | } |
3191 | 3191 | } |
3192 | 3192 | } |
3193 | 3193 | |
3194 | 3194 | if (isset($data['db_concat_fields'])) { |
3195 | - $ret_array['secondary_select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
3195 | + $ret_array['secondary_select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
3196 | 3196 | } else { |
3197 | 3197 | if (!isset($data['relationship_fields'])) { |
3198 | - $ret_array['secondary_select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
3198 | + $ret_array['secondary_select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
3199 | 3199 | } |
3200 | 3200 | } |
3201 | 3201 | if (!$singleSelect) { |
@@ -3211,54 +3211,54 @@ discard block |
||
3211 | 3211 | //27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype |
3212 | 3212 | // add rel_key only if it was not already added |
3213 | 3213 | if (!$singleSelect) { |
3214 | - $ret_array['select'] .= ", ' ' " . $join['rel_key'] . ' '; |
|
3214 | + $ret_array['select'] .= ", ' ' ".$join['rel_key'].' '; |
|
3215 | 3215 | } |
3216 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'] . '.' . $join['rel_key'] . ' ' . $join['rel_key']; |
|
3216 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$join['rel_key'].' '.$join['rel_key']; |
|
3217 | 3217 | } |
3218 | 3218 | if (isset($data['relationship_fields'])) { |
3219 | 3219 | foreach ($data['relationship_fields'] as $r_name => $alias_name) { |
3220 | 3220 | if (!empty($secondarySelectedFields[$alias_name])) { |
3221 | 3221 | continue; |
3222 | 3222 | } |
3223 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'] . '.' . $r_name . ' ' . $alias_name; |
|
3223 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$r_name.' '.$alias_name; |
|
3224 | 3224 | $secondarySelectedFields[$alias_name] = true; |
3225 | 3225 | } |
3226 | 3226 | } |
3227 | 3227 | if (!$table_joined) { |
3228 | - $ret_array['secondary_from'] .= ' ' . $join['join'] . ' AND ' . $params['join_table_alias'] . '.deleted=0'; |
|
3228 | + $ret_array['secondary_from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
3229 | 3229 | if (isset($data['link_type']) && $data['link_type'] == 'relationship_info' && ($parentbean instanceof SugarBean)) { |
3230 | - $ret_array['secondary_where'] = $params['join_table_link_alias'] . '.' . $join['rel_key'] . "='" . $parentbean->id . "'"; |
|
3230 | + $ret_array['secondary_where'] = $params['join_table_link_alias'].'.'.$join['rel_key']."='".$parentbean->id."'"; |
|
3231 | 3231 | } |
3232 | 3232 | } |
3233 | 3233 | } else { |
3234 | 3234 | if (isset($data['db_concat_fields'])) { |
3235 | - $ret_array['select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
3235 | + $ret_array['select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
3236 | 3236 | } else { |
3237 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
3237 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
3238 | 3238 | } |
3239 | 3239 | if (isset($data['additionalFields'])) { |
3240 | 3240 | foreach ($data['additionalFields'] as $k => $v) { |
3241 | 3241 | if (!empty($data['id_name']) && $data['id_name'] == $v && !empty($fields[$data['id_name']])) { |
3242 | 3242 | continue; |
3243 | 3243 | } |
3244 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $k . ' ' . $v; |
|
3244 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$k.' '.$v; |
|
3245 | 3245 | } |
3246 | 3246 | } |
3247 | 3247 | if (!$table_joined) { |
3248 | - $ret_array['from'] .= ' ' . $join['join'] . ' AND ' . $params['join_table_alias'] . '.deleted=0'; |
|
3248 | + $ret_array['from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
3249 | 3249 | if (!empty($beanList[$rel_module]) && !empty($beanFiles[$beanList[$rel_module]])) { |
3250 | 3250 | require_once($beanFiles[$beanList[$rel_module]]); |
3251 | 3251 | $rel_mod = new $beanList[$rel_module](); |
3252 | 3252 | if (isset($value['target_record_key']) && !empty($filter)) { |
3253 | - $selectedFields[$this->table_name . '.' . $value['target_record_key']] = true; |
|
3253 | + $selectedFields[$this->table_name.'.'.$value['target_record_key']] = true; |
|
3254 | 3254 | $ret_array['select'] .= " , $this->table_name.{$value['target_record_key']} "; |
3255 | 3255 | } |
3256 | 3256 | if (isset($rel_mod->field_defs['assigned_user_id'])) { |
3257 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.assigned_user_id ' . $field . '_owner'; |
|
3257 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.assigned_user_id '.$field.'_owner'; |
|
3258 | 3258 | } else { |
3259 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.created_by ' . $field . '_owner'; |
|
3259 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.created_by '.$field.'_owner'; |
|
3260 | 3260 | } |
3261 | - $ret_array['select'] .= " , '" . $rel_module . "' " . $field . '_mod'; |
|
3261 | + $ret_array['select'] .= " , '".$rel_module."' ".$field.'_mod'; |
|
3262 | 3262 | } |
3263 | 3263 | } |
3264 | 3264 | } |
@@ -3268,37 +3268,37 @@ discard block |
||
3268 | 3268 | if (isset($data['db_concat_fields'])) { |
3269 | 3269 | $buildWhere = false; |
3270 | 3270 | if (in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) { |
3271 | - $exp = '/\(\s*?' . $data['name'] . '.*?\%\'\s*?\)/'; |
|
3271 | + $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
|
3272 | 3272 | if (preg_match($exp, $where, $matches)) { |
3273 | 3273 | $search_expression = $matches[0]; |
3274 | 3274 | //Create three search conditions - first + last, first, last |
3275 | - $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
3276 | - $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
3275 | + $first_name_search = str_replace($data['name'], $params['join_table_alias'].'.first_name', $search_expression); |
|
3276 | + $last_name_search = str_replace($data['name'], $params['join_table_alias'].'.last_name', $search_expression); |
|
3277 | 3277 | $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
3278 | 3278 | $buildWhere = true; |
3279 | - $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
3279 | + $where = str_replace($search_expression, '('.$full_name_search.' OR '.$first_name_search.' OR '.$last_name_search.')', $where); |
|
3280 | 3280 | } |
3281 | 3281 | } |
3282 | 3282 | |
3283 | 3283 | if (!$buildWhere) { |
3284 | 3284 | $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
3285 | - $where = preg_replace('/' . $data['name'] . '/', $db_field, $where); |
|
3285 | + $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
|
3286 | 3286 | |
3287 | 3287 | // For relationship fields replace their alias by the corresponding link table and r_name |
3288 | 3288 | if (isset($data['relationship_fields'])) { |
3289 | 3289 | foreach ($data['relationship_fields'] as $r_name => $alias_name) { |
3290 | 3290 | $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
3291 | - $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
3291 | + $where = preg_replace('/'.$alias_name.'/', $db_field, $where); |
|
3292 | 3292 | } |
3293 | 3293 | } |
3294 | 3294 | } |
3295 | 3295 | } else { |
3296 | - $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.' . $data['rname'], $where); |
|
3296 | + $where = preg_replace('/(^|[\s(])'.$data['name'].'/', '${1}'.$params['join_table_alias'].'.'.$data['rname'], $where); |
|
3297 | 3297 | |
3298 | 3298 | // For relationship fields replace their alias by the corresponding link table and r_name |
3299 | 3299 | if (isset($data['relationship_fields'])) { |
3300 | 3300 | foreach ($data['relationship_fields'] as $r_name => $alias_name) { |
3301 | - $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.' . $r_name, $where); |
|
3301 | + $where = preg_replace('/(^|[\s(])'.$alias_name.'/', '${1}'.$params['join_table_link_alias'].'.'.$r_name, $where); |
|
3302 | 3302 | } |
3303 | 3303 | } |
3304 | 3304 | } |
@@ -3312,12 +3312,12 @@ discard block |
||
3312 | 3312 | } |
3313 | 3313 | } |
3314 | 3314 | if (!empty($filter)) { |
3315 | - if (isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name . '.assigned_user_id'])) { |
|
3315 | + if (isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id'])) { |
|
3316 | 3316 | $ret_array['select'] .= ", $this->table_name.assigned_user_id "; |
3317 | - } elseif (isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name . '.created_by'])) { |
|
3317 | + } elseif (isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) { |
|
3318 | 3318 | $ret_array['select'] .= ", $this->table_name.created_by "; |
3319 | 3319 | } |
3320 | - if (isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name . '.system_id'])) { |
|
3320 | + if (isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name.'.system_id'])) { |
|
3321 | 3321 | $ret_array['select'] .= ", $this->table_name.system_id "; |
3322 | 3322 | } |
3323 | 3323 | } |
@@ -3344,7 +3344,7 @@ discard block |
||
3344 | 3344 | //make call to process the order by clause |
3345 | 3345 | $order_by = $this->process_order_by($order_by); |
3346 | 3346 | if (!empty($order_by)) { |
3347 | - $ret_array['order_by'] = " ORDER BY " . $order_by; |
|
3347 | + $ret_array['order_by'] = " ORDER BY ".$order_by; |
|
3348 | 3348 | } |
3349 | 3349 | if ($singleSelect) { |
3350 | 3350 | unset($ret_array['secondary_where']); |
@@ -3356,7 +3356,7 @@ discard block |
||
3356 | 3356 | return $ret_array; |
3357 | 3357 | } |
3358 | 3358 | |
3359 | - return $ret_array['select'] . $ret_array['from'] . $ret_array['where'] . $ret_array['order_by']; |
|
3359 | + return $ret_array['select'].$ret_array['from'].$ret_array['where'].$ret_array['order_by']; |
|
3360 | 3360 | } |
3361 | 3361 | |
3362 | 3362 | public function get_relationship_field($field) |
@@ -3431,9 +3431,9 @@ discard block |
||
3431 | 3431 | |
3432 | 3432 | if (empty($field_defs['table']) && !$suppress_table_name) { |
3433 | 3433 | if ($source == 'db') { |
3434 | - $list_column[0] = $bean_queried->table_name . '.' . $list_column[0]; |
|
3434 | + $list_column[0] = $bean_queried->table_name.'.'.$list_column[0]; |
|
3435 | 3435 | } elseif ($source == 'custom_fields') { |
3436 | - $list_column[0] = $bean_queried->table_name . '_cstm.' . $list_column[0]; |
|
3436 | + $list_column[0] = $bean_queried->table_name.'_cstm.'.$list_column[0]; |
|
3437 | 3437 | } |
3438 | 3438 | } |
3439 | 3439 | |
@@ -3489,7 +3489,7 @@ discard block |
||
3489 | 3489 | * if the row_offset is set to 'end' go to the end of the list |
3490 | 3490 | */ |
3491 | 3491 | $toEnd = strval($row_offset) == 'end'; |
3492 | - $GLOBALS['log']->debug("process_list_query: " . $query); |
|
3492 | + $GLOBALS['log']->debug("process_list_query: ".$query); |
|
3493 | 3493 | if ($max_per_page == -1) { |
3494 | 3494 | $max_per_page = $sugar_config['list_max_entries_per_page']; |
3495 | 3495 | } |
@@ -3548,14 +3548,14 @@ discard block |
||
3548 | 3548 | foreach ($this->field_defs as $field => $value) { |
3549 | 3549 | if (isset($row[$field])) { |
3550 | 3550 | $temp->$field = $row[$field]; |
3551 | - $owner_field = $field . '_owner'; |
|
3551 | + $owner_field = $field.'_owner'; |
|
3552 | 3552 | if (isset($row[$owner_field])) { |
3553 | 3553 | $temp->$owner_field = $row[$owner_field]; |
3554 | 3554 | } |
3555 | 3555 | |
3556 | - $GLOBALS['log']->debug("$temp->object_name({$row['id']}): " . $field . " = " . $temp->$field); |
|
3557 | - } elseif (isset($row[$this->table_name . '.' . $field])) { |
|
3558 | - $temp->$field = $row[$this->table_name . '.' . $field]; |
|
3556 | + $GLOBALS['log']->debug("$temp->object_name({$row['id']}): ".$field." = ".$temp->$field); |
|
3557 | + } elseif (isset($row[$this->table_name.'.'.$field])) { |
|
3558 | + $temp->$field = $row[$this->table_name.'.'.$field]; |
|
3559 | 3559 | } else { |
3560 | 3560 | $temp->$field = ""; |
3561 | 3561 | } |
@@ -3608,22 +3608,22 @@ discard block |
||
3608 | 3608 | public function create_list_count_query($query) |
3609 | 3609 | { |
3610 | 3610 | // remove the 'order by' clause which is expected to be at the end of the query |
3611 | - $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
3611 | + $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
3612 | 3612 | $replacement = ''; |
3613 | 3613 | $query = preg_replace($pattern, $replacement, $query); |
3614 | 3614 | //handle distinct clause |
3615 | 3615 | $star = '*'; |
3616 | 3616 | if (substr_count(strtolower($query), 'distinct')) { |
3617 | 3617 | if (!empty($this->seed) && !empty($this->seed->table_name)) { |
3618 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
3618 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
3619 | 3619 | } else { |
3620 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
3620 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
3621 | 3621 | } |
3622 | 3622 | } |
3623 | 3623 | |
3624 | 3624 | // change the select expression to 'count(*)' |
3625 | - $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
3626 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
3625 | + $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
3626 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
3627 | 3627 | |
3628 | 3628 | //if the passed query has union clause then replace all instances of the pattern. |
3629 | 3629 | //this is very rare. I have seen this happening only from projects module. |
@@ -3639,13 +3639,13 @@ discard block |
||
3639 | 3639 | if (!empty($matches)) { |
3640 | 3640 | if (stristr($matches[0], "distinct")) { |
3641 | 3641 | if (!empty($this->seed) && !empty($this->seed->table_name)) { |
3642 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
3642 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
3643 | 3643 | } else { |
3644 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
3644 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
3645 | 3645 | } |
3646 | 3646 | } |
3647 | 3647 | } // if |
3648 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
3648 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
3649 | 3649 | $union_qs[$key] = preg_replace($pattern, $replacement, $union_query, 1); |
3650 | 3650 | } |
3651 | 3651 | $modified_select_query = implode(" UNION ALL ", $union_qs); |
@@ -3711,7 +3711,7 @@ discard block |
||
3711 | 3711 | if (empty($where)) { |
3712 | 3712 | $where = $owner_where; |
3713 | 3713 | } else { |
3714 | - $where .= ' AND ' . $owner_where; |
|
3714 | + $where .= ' AND '.$owner_where; |
|
3715 | 3715 | } |
3716 | 3716 | } |
3717 | 3717 | |
@@ -3723,12 +3723,12 @@ discard block |
||
3723 | 3723 | $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
3724 | 3724 | if (!empty($owner_where)) { |
3725 | 3725 | if (empty($where)) { |
3726 | - $where = " (" . $owner_where . " or " . $group_where . ") "; |
|
3726 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
3727 | 3727 | } else { |
3728 | - $where .= " AND (" . $owner_where . " or " . $group_where . ") "; |
|
3728 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
3729 | 3729 | } |
3730 | 3730 | } else { |
3731 | - $where .= ' AND ' . $group_where; |
|
3731 | + $where .= ' AND '.$group_where; |
|
3732 | 3732 | } |
3733 | 3733 | } |
3734 | 3734 | /* END - SECURITY GROUPS */ |
@@ -3757,7 +3757,7 @@ discard block |
||
3757 | 3757 | public function process_detail_query($query, $row_offset, $limit = -1, $max_per_page = -1, $where = '', $offset = 0) |
3758 | 3758 | { |
3759 | 3759 | global $sugar_config; |
3760 | - $GLOBALS['log']->debug("process_detail_query: " . $query); |
|
3760 | + $GLOBALS['log']->debug("process_detail_query: ".$query); |
|
3761 | 3761 | if ($max_per_page == -1) { |
3762 | 3762 | $max_per_page = $sugar_config['list_max_entries_per_page']; |
3763 | 3763 | } |
@@ -3823,14 +3823,14 @@ discard block |
||
3823 | 3823 | } |
3824 | 3824 | $custom_join = $this->getCustomJoin(); |
3825 | 3825 | |
3826 | - $query = "SELECT $this->table_name.*" . $custom_join['select'] . " FROM $this->table_name "; |
|
3826 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name "; |
|
3827 | 3827 | |
3828 | 3828 | $query .= $custom_join['join']; |
3829 | - $query .= " WHERE $this->table_name.id = " . $this->db->quoted($id); |
|
3829 | + $query .= " WHERE $this->table_name.id = ".$this->db->quoted($id); |
|
3830 | 3830 | if ($deleted) { |
3831 | 3831 | $query .= " AND $this->table_name.deleted=0"; |
3832 | 3832 | } |
3833 | - $GLOBALS['log']->debug("Retrieve $this->object_name : " . $query); |
|
3833 | + $GLOBALS['log']->debug("Retrieve $this->object_name : ".$query); |
|
3834 | 3834 | $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record by id $this->table_name:$id found "); |
3835 | 3835 | if (empty($result)) { |
3836 | 3836 | return null; |
@@ -3981,7 +3981,7 @@ discard block |
||
3981 | 3981 | } |
3982 | 3982 | if (isset($row[$field])) { |
3983 | 3983 | $this->$field = $row[$field]; |
3984 | - $owner = $field . '_owner'; |
|
3984 | + $owner = $field.'_owner'; |
|
3985 | 3985 | if (!empty($row[$owner])) { |
3986 | 3986 | $this->$owner = $row[$owner]; |
3987 | 3987 | } |
@@ -4178,12 +4178,12 @@ discard block |
||
4178 | 4178 | $query = 'SELECT id'; |
4179 | 4179 | foreach ($fields as $field => $alias) { |
4180 | 4180 | if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) { |
4181 | - $query .= ' ,' . $this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias; |
|
4181 | + $query .= ' ,'.$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']).' as '.$alias; |
|
4182 | 4182 | } elseif (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
4183 | 4183 | (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || |
4184 | 4184 | $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db") |
4185 | 4185 | ) { |
4186 | - $query .= ' ,' . $table . '.' . $field . ' as ' . $alias; |
|
4186 | + $query .= ' ,'.$table.'.'.$field.' as '.$alias; |
|
4187 | 4187 | } |
4188 | 4188 | if (!$return_array) { |
4189 | 4189 | $this->$alias = ''; |
@@ -4195,12 +4195,12 @@ discard block |
||
4195 | 4195 | |
4196 | 4196 | |
4197 | 4197 | if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) { |
4198 | - $query .= " , " . $table . ".assigned_user_id owner"; |
|
4198 | + $query .= " , ".$table.".assigned_user_id owner"; |
|
4199 | 4199 | } elseif (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) { |
4200 | - $query .= " , " . $table . ".created_by owner"; |
|
4200 | + $query .= " , ".$table.".created_by owner"; |
|
4201 | 4201 | } |
4202 | - $query .= ' FROM ' . $table . ' WHERE deleted=0 AND id='; |
|
4203 | - $result = $GLOBALS['db']->query($query . "'$id'"); |
|
4202 | + $query .= ' FROM '.$table.' WHERE deleted=0 AND id='; |
|
4203 | + $result = $GLOBALS['db']->query($query."'$id'"); |
|
4204 | 4204 | $row = $GLOBALS['db']->fetchByAssoc($result); |
4205 | 4205 | if ($return_array) { |
4206 | 4206 | return $row; |
@@ -4208,9 +4208,9 @@ discard block |
||
4208 | 4208 | $owner = (empty($row['owner'])) ? '' : $row['owner']; |
4209 | 4209 | foreach ($fields as $alias) { |
4210 | 4210 | $this->$alias = (!empty($row[$alias])) ? $row[$alias] : ''; |
4211 | - $alias = $alias . '_owner'; |
|
4211 | + $alias = $alias.'_owner'; |
|
4212 | 4212 | $this->$alias = $owner; |
4213 | - $a_mod = $alias . '_mod'; |
|
4213 | + $a_mod = $alias.'_mod'; |
|
4214 | 4214 | $this->$a_mod = $module; |
4215 | 4215 | } |
4216 | 4216 | } |
@@ -4370,15 +4370,15 @@ discard block |
||
4370 | 4370 | $entire_where = $query_array['where']; |
4371 | 4371 | if (!empty($where)) { |
4372 | 4372 | if (empty($entire_where)) { |
4373 | - $entire_where = ' WHERE ' . $where; |
|
4373 | + $entire_where = ' WHERE '.$where; |
|
4374 | 4374 | } else { |
4375 | - $entire_where .= ' AND ' . $where; |
|
4375 | + $entire_where .= ' AND '.$where; |
|
4376 | 4376 | } |
4377 | 4377 | } |
4378 | 4378 | |
4379 | - $query = 'SELECT ' . $child_seed->table_name . '.* ' . $query_array['from'] . ' ' . $entire_where; |
|
4379 | + $query = 'SELECT '.$child_seed->table_name.'.* '.$query_array['from'].' '.$entire_where; |
|
4380 | 4380 | if (!empty($order_by)) { |
4381 | - $query .= " ORDER BY " . $order_by; |
|
4381 | + $query .= " ORDER BY ".$order_by; |
|
4382 | 4382 | } |
4383 | 4383 | |
4384 | 4384 | return $child_seed->process_list_query($query, $row_offset, $limit, $max, $where); |
@@ -4414,9 +4414,9 @@ discard block |
||
4414 | 4414 | */ |
4415 | 4415 | public function process_full_list_query($query, $check_date = false) |
4416 | 4416 | { |
4417 | - $GLOBALS['log']->debug("process_full_list_query: query is " . $query); |
|
4417 | + $GLOBALS['log']->debug("process_full_list_query: query is ".$query); |
|
4418 | 4418 | $result = $this->db->query($query, false); |
4419 | - $GLOBALS['log']->debug("process_full_list_query: result is " . print_r($result, true)); |
|
4419 | + $GLOBALS['log']->debug("process_full_list_query: result is ".print_r($result, true)); |
|
4420 | 4420 | $class = get_class($this); |
4421 | 4421 | $isFirstTime = true; |
4422 | 4422 | $bean = new $class(); |
@@ -4432,7 +4432,7 @@ discard block |
||
4432 | 4432 | foreach ($bean->field_defs as $field => $value) { |
4433 | 4433 | if (isset($row[$field])) { |
4434 | 4434 | $bean->$field = $row[$field]; |
4435 | - $GLOBALS['log']->debug("process_full_list: $bean->object_name({$row['id']}): " . $field . " = " . $bean->$field); |
|
4435 | + $GLOBALS['log']->debug("process_full_list: $bean->object_name({$row['id']}): ".$field." = ".$bean->$field); |
|
4436 | 4436 | } else { |
4437 | 4437 | $bean->$field = ''; |
4438 | 4438 | } |
@@ -4524,7 +4524,7 @@ discard block |
||
4524 | 4524 | $this->call_custom_logic("before_restore", $custom_logic_arguments); |
4525 | 4525 | |
4526 | 4526 | $date_modified = $GLOBALS['timedate']->nowDb(); |
4527 | - $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) . "'"; |
|
4527 | + $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='".$this->db->quote($id)."'"; |
|
4528 | 4528 | $this->db->query($query, true, "Error marking record undeleted: "); |
4529 | 4529 | |
4530 | 4530 | $this->restoreFiles(); |
@@ -4554,9 +4554,9 @@ discard block |
||
4554 | 4554 | $directory = $this->deleteFileDirectory(); |
4555 | 4555 | |
4556 | 4556 | foreach ($files as $file) { |
4557 | - if (sugar_is_file('upload://deleted/' . $directory . '/' . $file)) { |
|
4558 | - if (!sugar_rename('upload://deleted/' . $directory . '/' . $file, 'upload://' . $file)) { |
|
4559 | - $GLOBALS['log']->error('Could not move file ' . $directory . '/' . $file . ' from deleted directory'); |
|
4557 | + if (sugar_is_file('upload://deleted/'.$directory.'/'.$file)) { |
|
4558 | + if (!sugar_rename('upload://deleted/'.$directory.'/'.$file, 'upload://'.$file)) { |
|
4559 | + $GLOBALS['log']->error('Could not move file '.$directory.'/'.$file.' from deleted directory'); |
|
4560 | 4560 | } |
4561 | 4561 | } |
4562 | 4562 | } |
@@ -4565,7 +4565,7 @@ discard block |
||
4565 | 4565 | * @var DBManager $db |
4566 | 4566 | */ |
4567 | 4567 | global $db; |
4568 | - $db->query('DELETE FROM cron_remove_documents WHERE bean_id=' . $db->quoted($this->id)); |
|
4568 | + $db->query('DELETE FROM cron_remove_documents WHERE bean_id='.$db->quoted($this->id)); |
|
4569 | 4569 | |
4570 | 4570 | return true; |
4571 | 4571 | } |
@@ -4713,19 +4713,19 @@ discard block |
||
4713 | 4713 | |
4714 | 4714 | $directory = $this->deleteFileDirectory(); |
4715 | 4715 | |
4716 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
4716 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
4717 | 4717 | if (!$isCreated) { |
4718 | - sugar_mkdir('upload://deleted/' . $directory, 0777, true); |
|
4719 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
4718 | + sugar_mkdir('upload://deleted/'.$directory, 0777, true); |
|
4719 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
4720 | 4720 | } |
4721 | 4721 | if (!$isCreated) { |
4722 | 4722 | return false; |
4723 | 4723 | } |
4724 | 4724 | |
4725 | 4725 | foreach ($files as $file) { |
4726 | - if (file_exists('upload://' . $file)) { |
|
4727 | - if (!sugar_rename('upload://' . $file, 'upload://deleted/' . $directory . '/' . $file)) { |
|
4728 | - $GLOBALS['log']->error('Could not move file ' . $file . ' to deleted directory'); |
|
4726 | + if (file_exists('upload://'.$file)) { |
|
4727 | + if (!sugar_rename('upload://'.$file, 'upload://deleted/'.$directory.'/'.$file)) { |
|
4728 | + $GLOBALS['log']->error('Could not move file '.$file.' to deleted directory'); |
|
4729 | 4729 | } |
4730 | 4730 | } |
4731 | 4731 | } |
@@ -4745,7 +4745,7 @@ discard block |
||
4745 | 4745 | } |
4746 | 4746 | if (empty($record['id'])) { |
4747 | 4747 | $record['id'] = $db->quoted(create_guid()); |
4748 | - $db->query('INSERT INTO cron_remove_documents (' . implode(', ', array_keys($record)) . ') VALUES(' . implode(', ', $record) . ')'); |
|
4748 | + $db->query('INSERT INTO cron_remove_documents ('.implode(', ', array_keys($record)).') VALUES('.implode(', ', $record).')'); |
|
4749 | 4749 | } else { |
4750 | 4750 | $db->query("UPDATE cron_remove_documents SET date_modified={$record['date_modified']} WHERE id={$record['id']}"); |
4751 | 4751 | } |
@@ -4766,7 +4766,7 @@ discard block |
||
4766 | 4766 | */ |
4767 | 4767 | public function build_related_list($query, &$template, $row_offset = 0, $limit = -1) |
4768 | 4768 | { |
4769 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: " . $query); |
|
4769 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
4770 | 4770 | $db = DBManagerFactory::getInstance('listviews'); |
4771 | 4771 | |
4772 | 4772 | if (!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1) { |
@@ -4813,7 +4813,7 @@ discard block |
||
4813 | 4813 | { |
4814 | 4814 | $db = DBManagerFactory::getInstance('listviews'); |
4815 | 4815 | // No need to do an additional query |
4816 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: " . $query); |
|
4816 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
4817 | 4817 | if (empty($in) && !empty($query)) { |
4818 | 4818 | $idList = $this->build_related_in($query); |
4819 | 4819 | $in = $idList['in']; |
@@ -4879,9 +4879,9 @@ discard block |
||
4879 | 4879 | while ($row = $this->db->fetchByAssoc($result)) { |
4880 | 4880 | $idList[] = $row['id']; |
4881 | 4881 | if (empty($ids)) { |
4882 | - $ids = "('" . $row['id'] . "'"; |
|
4882 | + $ids = "('".$row['id']."'"; |
|
4883 | 4883 | } else { |
4884 | - $ids .= ",'" . $row['id'] . "'"; |
|
4884 | + $ids .= ",'".$row['id']."'"; |
|
4885 | 4885 | } |
4886 | 4886 | } |
4887 | 4887 | if (empty($ids)) { |
@@ -4905,7 +4905,7 @@ discard block |
||
4905 | 4905 | */ |
4906 | 4906 | public function build_related_list2($query, &$template, &$field_list) |
4907 | 4907 | { |
4908 | - $GLOBALS['log']->debug("Finding linked values $this->object_name: " . $query); |
|
4908 | + $GLOBALS['log']->debug("Finding linked values $this->object_name: ".$query); |
|
4909 | 4909 | |
4910 | 4910 | $result = $this->db->query($query, true); |
4911 | 4911 | |
@@ -5019,9 +5019,9 @@ discard block |
||
5019 | 5019 | { |
5020 | 5020 | $where_clause = $this->get_where($fields_array, $deleted); |
5021 | 5021 | $custom_join = $this->getCustomJoin(); |
5022 | - $query = "SELECT $this->table_name.*" . $custom_join['select'] . " FROM $this->table_name " . $custom_join['join']; |
|
5022 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name ".$custom_join['join']; |
|
5023 | 5023 | $query .= " $where_clause"; |
5024 | - $GLOBALS['log']->debug("Retrieve $this->object_name: " . $query); |
|
5024 | + $GLOBALS['log']->debug("Retrieve $this->object_name: ".$query); |
|
5025 | 5025 | //requireSingleResult has been deprecated. |
5026 | 5026 | //$result = $this->db->requireSingleResult($query, true, "Retrieving record $where_clause:"); |
5027 | 5027 | $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record $where_clause:"); |
@@ -5060,7 +5060,7 @@ discard block |
||
5060 | 5060 | } |
5061 | 5061 | $name = $this->db->getValidDBName($name); |
5062 | 5062 | |
5063 | - $where_clause .= "$name = " . $this->db->quoted($value); |
|
5063 | + $where_clause .= "$name = ".$this->db->quoted($value); |
|
5064 | 5064 | } |
5065 | 5065 | if (!empty($where_clause)) { |
5066 | 5066 | if ($deleted) { |
@@ -5158,7 +5158,7 @@ discard block |
||
5158 | 5158 | $where = ''; |
5159 | 5159 | |
5160 | 5160 | // make sure there is a date modified |
5161 | - $date_modified = $this->db->convert("'" . $GLOBALS['timedate']->nowDb() . "'", 'datetime'); |
|
5161 | + $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
|
5162 | 5162 | |
5163 | 5163 | $row = null; |
5164 | 5164 | if ($check_duplicates) { |
@@ -5168,7 +5168,7 @@ discard block |
||
5168 | 5168 | $where .= " AND $name = '$value' "; |
5169 | 5169 | } |
5170 | 5170 | $query .= $where; |
5171 | - $result = $this->db->query($query, false, "Looking For Duplicate Relationship:" . $query); |
|
5171 | + $result = $this->db->query($query, false, "Looking For Duplicate Relationship:".$query); |
|
5172 | 5172 | $row = $this->db->fetchByAssoc($result); |
5173 | 5173 | } |
5174 | 5174 | |
@@ -5177,16 +5177,16 @@ discard block |
||
5177 | 5177 | if (isset($data_values)) { |
5178 | 5178 | $relate_values = array_merge($relate_values, $data_values); |
5179 | 5179 | } |
5180 | - $query = "INSERT INTO $table (id, " . implode(',', array_keys($relate_values)) . ", date_modified) VALUES ('" . create_guid() . "', " . "'" . implode("', '", $relate_values) . "', " . $date_modified . ")"; |
|
5180 | + $query = "INSERT INTO $table (id, ".implode(',', array_keys($relate_values)).", date_modified) VALUES ('".create_guid()."', "."'".implode("', '", $relate_values)."', ".$date_modified.")"; |
|
5181 | 5181 | |
5182 | - $this->db->query($query, false, "Creating Relationship:" . $query); |
|
5182 | + $this->db->query($query, false, "Creating Relationship:".$query); |
|
5183 | 5183 | } elseif ($do_update) { |
5184 | 5184 | $conds = array(); |
5185 | 5185 | foreach ($data_values as $key => $value) { |
5186 | - array_push($conds, $key . "='" . $this->db->quote($value) . "'"); |
|
5186 | + array_push($conds, $key."='".$this->db->quote($value)."'"); |
|
5187 | 5187 | } |
5188 | - $query = "UPDATE $table SET " . implode(',', $conds) . ",date_modified=" . $date_modified . " " . $where; |
|
5189 | - $this->db->query($query, false, "Updating Relationship:" . $query); |
|
5188 | + $query = "UPDATE $table SET ".implode(',', $conds).",date_modified=".$date_modified." ".$where; |
|
5189 | + $this->db->query($query, false, "Updating Relationship:".$query); |
|
5190 | 5190 | } |
5191 | 5191 | } |
5192 | 5192 | |
@@ -5197,7 +5197,7 @@ discard block |
||
5197 | 5197 | $query .= " AND $name = '$value' "; |
5198 | 5198 | } |
5199 | 5199 | $query .= " ORDER BY $select_id "; |
5200 | - $result = $this->db->query($query, false, "Retrieving Relationship:" . $query); |
|
5200 | + $result = $this->db->query($query, false, "Retrieving Relationship:".$query); |
|
5201 | 5201 | $ids = array(); |
5202 | 5202 | while ($row = $this->db->fetchByAssoc($result)) { |
5203 | 5203 | $ids[] = $row; |
@@ -5208,13 +5208,13 @@ discard block |
||
5208 | 5208 | public function loadLayoutDefs() |
5209 | 5209 | { |
5210 | 5210 | global $layout_defs; |
5211 | - if (empty($this->layout_def) && file_exists('modules/' . $this->module_dir . '/layout_defs.php')) { |
|
5212 | - include_once('modules/' . $this->module_dir . '/layout_defs.php'); |
|
5213 | - if (file_exists('custom/modules/' . $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) { |
|
5214 | - include_once('custom/modules/' . $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
5211 | + if (empty($this->layout_def) && file_exists('modules/'.$this->module_dir.'/layout_defs.php')) { |
|
5212 | + include_once('modules/'.$this->module_dir.'/layout_defs.php'); |
|
5213 | + if (file_exists('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php')) { |
|
5214 | + include_once('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
5215 | 5215 | } |
5216 | 5216 | if (empty($layout_defs[get_class($this)])) { |
5217 | - echo "\$layout_defs[" . get_class($this) . "]; does not exist"; |
|
5217 | + echo "\$layout_defs[".get_class($this)."]; does not exist"; |
|
5218 | 5218 | } |
5219 | 5219 | |
5220 | 5220 | $this->layout_def = $layout_defs[get_class($this)]; |
@@ -5440,8 +5440,8 @@ discard block |
||
5440 | 5440 | $tmp = explode(",", $order_by); |
5441 | 5441 | $comma = ' '; |
5442 | 5442 | foreach ($tmp as $stmp) { |
5443 | - $stmp = (substr_count($stmp, ".") > 0 ? trim($stmp) : "$qualify." . trim($stmp)); |
|
5444 | - $order_by_clause .= $comma . $stmp; |
|
5443 | + $stmp = (substr_count($stmp, ".") > 0 ? trim($stmp) : "$qualify.".trim($stmp)); |
|
5444 | + $order_by_clause .= $comma.$stmp; |
|
5445 | 5445 | $comma = ", "; |
5446 | 5446 | } |
5447 | 5447 | return $order_by_clause; |
@@ -5457,19 +5457,19 @@ discard block |
||
5457 | 5457 | $street_field |
5458 | 5458 | ) { |
5459 | 5459 | if (isset($this->$street_field)) { |
5460 | - $street_field_2 = $street_field . '_2'; |
|
5461 | - $street_field_3 = $street_field . '_3'; |
|
5462 | - $street_field_4 = $street_field . '_4'; |
|
5460 | + $street_field_2 = $street_field.'_2'; |
|
5461 | + $street_field_3 = $street_field.'_3'; |
|
5462 | + $street_field_4 = $street_field.'_4'; |
|
5463 | 5463 | if (isset($this->$street_field_2)) { |
5464 | - $this->$street_field .= "\n" . $this->$street_field_2; |
|
5464 | + $this->$street_field .= "\n".$this->$street_field_2; |
|
5465 | 5465 | unset($this->$street_field_2); |
5466 | 5466 | } |
5467 | 5467 | if (isset($this->$street_field_3)) { |
5468 | - $this->$street_field .= "\n" . $this->$street_field_3; |
|
5468 | + $this->$street_field .= "\n".$this->$street_field_3; |
|
5469 | 5469 | unset($this->$street_field_3); |
5470 | 5470 | } |
5471 | 5471 | if (isset($this->$street_field_4)) { |
5472 | - $this->$street_field .= "\n" . $this->$street_field_4; |
|
5472 | + $this->$street_field .= "\n".$this->$street_field_4; |
|
5473 | 5473 | unset($this->$street_field_4); |
5474 | 5474 | } |
5475 | 5475 | $this->$street_field = trim($this->$street_field, "\n"); |
@@ -23,8 +23,7 @@ |
||
23 | 23 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
24 | 24 | if(isset($GLOBALS['log'])) { |
25 | 25 | $GLOBALS['log']->deprecated($deprecatedMessage); |
26 | - } |
|
27 | - else { |
|
26 | + } else { |
|
28 | 27 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
29 | 28 | } |
30 | 29 | self::__construct($seed, $module, $subPanel, $options); |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | |
40 | 40 | require_once('ModuleInstall/PackageManager/PackageManagerDisplay.php'); |
41 | 41 | require_once('ModuleInstall/PackageManager/PackageManager.php'); |
42 | - class PackageController{ |
|
42 | + class PackageController { |
|
43 | 43 | var $_pm; |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Constructor: this class is called from the the ajax call and handles invoking the correct |
47 | 47 | * functionality on the server. |
48 | 48 | */ |
49 | - function __construct(){ |
|
49 | + function __construct() { |
|
50 | 50 | $this->_pm = new PackageManager(); |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
55 | 55 | */ |
56 | - function PackageController(){ |
|
56 | + function PackageController() { |
|
57 | 57 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
58 | - if(isset($GLOBALS['log'])) { |
|
58 | + if (isset($GLOBALS['log'])) { |
|
59 | 59 | $GLOBALS['log']->deprecated($deprecatedMessage); |
60 | 60 | } |
61 | 61 | else { |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | - function performBasicSearch(){ |
|
68 | + function performBasicSearch() { |
|
69 | 69 | $json = getJSONobj(); |
70 | 70 | $search_term = ''; |
71 | 71 | $node_id = ''; |
72 | - if(isset($_REQUEST['search_term'])) { |
|
72 | + if (isset($_REQUEST['search_term'])) { |
|
73 | 73 | $search_term = nl2br($_REQUEST['search_term']); |
74 | 74 | } |
75 | - if(isset($_REQUEST['node_id'])) { |
|
75 | + if (isset($_REQUEST['node_id'])) { |
|
76 | 76 | $node_id = nl2br($_REQUEST['node_id']); |
77 | 77 | } |
78 | 78 | $xml = PackageManager::getPackages($node_id); |
79 | - echo 'result = ' . $json->encode(array('packages' => $xml)); |
|
79 | + echo 'result = '.$json->encode(array('packages' => $xml)); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -87,33 +87,33 @@ discard block |
||
87 | 87 | * @return packages xml string consisting of the packages and releases which belong to |
88 | 88 | * the category |
89 | 89 | */ |
90 | - function getPackages(){ |
|
90 | + function getPackages() { |
|
91 | 91 | $json = getJSONobj(); |
92 | 92 | $category_id = ''; |
93 | 93 | |
94 | - if(isset($_REQUEST['category_id'])) { |
|
94 | + if (isset($_REQUEST['category_id'])) { |
|
95 | 95 | $category_id = nl2br($_REQUEST['category_id']); |
96 | 96 | } |
97 | 97 | $xml = PackageManager::getPackages($category_id); |
98 | - echo 'result = ' . $json->encode(array('package_output' => $xml)); |
|
98 | + echo 'result = '.$json->encode(array('package_output' => $xml)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Obtain a list of releases from the server. This function is currently used for generating the patches/langpacks for upgrade wizard |
103 | 103 | * as well as during installation |
104 | 104 | */ |
105 | - function getReleases(){ |
|
105 | + function getReleases() { |
|
106 | 106 | $json = getJSONobj(); |
107 | 107 | $category_id = ''; |
108 | 108 | $package_id = ''; |
109 | 109 | $types = ''; |
110 | - if(isset($_REQUEST['category_id'])) { |
|
110 | + if (isset($_REQUEST['category_id'])) { |
|
111 | 111 | $category_id = nl2br($_REQUEST['category_id']); |
112 | 112 | } |
113 | - if(isset($_REQUEST['package_id'])) { |
|
113 | + if (isset($_REQUEST['package_id'])) { |
|
114 | 114 | $package_id = nl2br($_REQUEST['package_id']); |
115 | 115 | } |
116 | - if(isset($_REQUEST['types'])) { |
|
116 | + if (isset($_REQUEST['types'])) { |
|
117 | 117 | $types = nl2br($_REQUEST['types']); |
118 | 118 | } |
119 | 119 | $types = explode(',', $types); |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | $count = count($types); |
123 | 123 | $index = 1; |
124 | 124 | $type_str = ''; |
125 | - foreach($types as $type){ |
|
125 | + foreach ($types as $type) { |
|
126 | 126 | $type_str .= "'".$type."'"; |
127 | - if($index < $count) |
|
127 | + if ($index < $count) |
|
128 | 128 | $type_str .= ","; |
129 | 129 | $index++; |
130 | 130 | } |
@@ -134,24 +134,24 @@ discard block |
||
134 | 134 | $releases = PackageManager::getReleases($category_id, $package_id, $filter); |
135 | 135 | $nodes = array(); |
136 | 136 | $release_map = array(); |
137 | - foreach($releases['packages'] as $release){ |
|
137 | + foreach ($releases['packages'] as $release) { |
|
138 | 138 | $release = PackageManager::fromNameValueList($release); |
139 | 139 | $nodes[] = array('description' => $release['description'], 'version' => $release['version'], 'build_number' => $release['build_number'], 'id' => $release['id']); |
140 | 140 | $release_map[$release['id']] = array('package_id' => $release['package_id'], 'category_id' => $release['category_id']); |
141 | 141 | } |
142 | 142 | $_SESSION['ML_PATCHES'] = $release_map; |
143 | - echo 'result = ' . $json->encode(array('releases' => $nodes)); |
|
143 | + echo 'result = '.$json->encode(array('releases' => $nodes)); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * Obtain a promotion from the depot |
148 | 148 | */ |
149 | - function getPromotion(){ |
|
149 | + function getPromotion() { |
|
150 | 150 | $json = getJSONobj(); |
151 | 151 | |
152 | 152 | $header = PackageManager::getPromotion(); |
153 | 153 | |
154 | - echo 'result = ' . $json->encode(array('promotion' => $header)); |
|
154 | + echo 'result = '.$json->encode(array('promotion' => $header)); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -162,34 +162,34 @@ discard block |
||
162 | 162 | * @param release_id this is passed via POST and is the release id of the release we wish to download |
163 | 163 | * @return bool true is successful in downloading, false otherwise |
164 | 164 | */ |
165 | - function download(){ |
|
165 | + function download() { |
|
166 | 166 | global $sugar_config; |
167 | 167 | $json = getJSONobj(); |
168 | 168 | $package_id = ''; |
169 | - $category_id = ''; |
|
169 | + $category_id = ''; |
|
170 | 170 | $release_id = ''; |
171 | - if(isset($_REQUEST['package_id'])) { |
|
171 | + if (isset($_REQUEST['package_id'])) { |
|
172 | 172 | $package_id = nl2br($_REQUEST['package_id']); |
173 | 173 | } |
174 | - if(isset($_REQUEST['category_id'])) { |
|
174 | + if (isset($_REQUEST['category_id'])) { |
|
175 | 175 | $category_id = nl2br($_REQUEST['category_id']); |
176 | 176 | } |
177 | - if(isset($_REQUEST['release_id'])) { |
|
177 | + if (isset($_REQUEST['release_id'])) { |
|
178 | 178 | $release_id = nl2br($_REQUEST['release_id']); |
179 | 179 | } |
180 | 180 | $GLOBALS['log']->debug("PACKAGE ID: ".$package_id); |
181 | 181 | $GLOBALS['log']->debug("CATEGORY ID: ".$category_id); |
182 | 182 | $GLOBALS['log']->debug("RELEASE ID: ".$release_id); |
183 | 183 | $result = $this->_pm->download($category_id, $package_id, $release_id); |
184 | - $GLOBALS['log']->debug("RESULT: ".print_r($result,true)); |
|
184 | + $GLOBALS['log']->debug("RESULT: ".print_r($result, true)); |
|
185 | 185 | $success = 'false'; |
186 | - if($result != null){ |
|
186 | + if ($result != null) { |
|
187 | 187 | $GLOBALS['log']->debug("Performing Setup"); |
188 | 188 | $this->_pm->performSetup($result, 'module', false); |
189 | 189 | $GLOBALS['log']->debug("Complete Setup"); |
190 | 190 | $success = 'true'; |
191 | 191 | } |
192 | - echo 'result = ' . $json->encode(array('success' => $success)); |
|
192 | + echo 'result = '.$json->encode(array('success' => $success)); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -198,27 +198,27 @@ discard block |
||
198 | 198 | * @param id - the id of the parent_category, -1 if this is the root |
199 | 199 | * @return array - a list of categories/nodes which are underneath this node |
200 | 200 | */ |
201 | - function getCategories(){ |
|
201 | + function getCategories() { |
|
202 | 202 | $json = getJSONobj(); |
203 | 203 | $node_id = ''; |
204 | - if(isset($_REQUEST['category_id'])) { |
|
204 | + if (isset($_REQUEST['category_id'])) { |
|
205 | 205 | $node_id = nl2br($_REQUEST['category_id']); |
206 | 206 | } |
207 | 207 | $GLOBALS['log']->debug("NODE ID: ".$node_id); |
208 | 208 | $nodes = PackageManager::getCategories($node_id); |
209 | - echo 'result = ' . $json->encode(array('nodes' => $nodes)); |
|
209 | + echo 'result = '.$json->encode(array('nodes' => $nodes)); |
|
210 | 210 | } |
211 | 211 | |
212 | - function getNodes(){ |
|
212 | + function getNodes() { |
|
213 | 213 | $json = getJSONobj(); |
214 | 214 | $category_id = ''; |
215 | - if(isset($_REQUEST['category_id'])) { |
|
215 | + if (isset($_REQUEST['category_id'])) { |
|
216 | 216 | $category_id = nl2br($_REQUEST['category_id']); |
217 | 217 | } |
218 | 218 | $GLOBALS['log']->debug("CATEGORY ID: ".$category_id); |
219 | 219 | $nodes = PackageManager::getModuleLoaderCategoryPackages($category_id); |
220 | 220 | $GLOBALS['log']->debug(var_export($nodes, true)); |
221 | - echo 'result = ' . $json->encode(array('nodes' => $nodes)); |
|
221 | + echo 'result = '.$json->encode(array('nodes' => $nodes)); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -226,18 +226,18 @@ discard block |
||
226 | 226 | * @param type the type to check for |
227 | 227 | * @return array return an array of releases for each given installed object if an update is found |
228 | 228 | */ |
229 | - function checkForUpdates(){ |
|
229 | + function checkForUpdates() { |
|
230 | 230 | $json = getJSONobj(); |
231 | 231 | $type = ''; |
232 | - if(isset($_REQUEST['type'])) { |
|
232 | + if (isset($_REQUEST['type'])) { |
|
233 | 233 | $type = nl2br($_REQUEST['type']); |
234 | 234 | } |
235 | 235 | $pm = new PackageManager(); |
236 | 236 | $updates = $pm->checkForUpdates(); |
237 | 237 | $nodes = array(); |
238 | 238 | $release_map = array(); |
239 | - if(!empty($updates)){ |
|
240 | - foreach($updates as $update){ |
|
239 | + if (!empty($updates)) { |
|
240 | + foreach ($updates as $update) { |
|
241 | 241 | $update = PackageManager::fromNameValueList($update); |
242 | 242 | $nodes[] = array('label' => $update['name'], 'description' => $update['description'], 'version' => $update['version'], 'build_number' => $update['build_number'], 'id' => $update['id'], 'type' => $update['type']); |
243 | 243 | $release_map[$update['id']] = array('package_id' => $update['package_id'], 'category_id' => $update['category_id'], 'type' => $update['type']); |
@@ -246,115 +246,115 @@ discard block |
||
246 | 246 | //patches |
247 | 247 | $filter = array(array('name' => 'type', 'value' => "'patch'")); |
248 | 248 | $releases = $pm->getReleases('', '', $filter); |
249 | - if(!empty($releases['packages'])){ |
|
250 | - foreach($releases['packages'] as $update){ |
|
249 | + if (!empty($releases['packages'])) { |
|
250 | + foreach ($releases['packages'] as $update) { |
|
251 | 251 | $update = PackageManager::fromNameValueList($update); |
252 | 252 | $nodes[] = array('label' => $update['name'], 'description' => $update['description'], 'version' => $update['version'], 'build_number' => $update['build_number'], 'id' => $update['id'], 'type' => $update['type']); |
253 | 253 | $release_map[$update['id']] = array('package_id' => $update['package_id'], 'category_id' => $update['category_id'], 'type' => $update['type']); |
254 | 254 | } |
255 | 255 | } |
256 | 256 | $_SESSION['ML_PATCHES'] = $release_map; |
257 | - echo 'result = ' . $json->encode(array('updates' => $nodes)); |
|
257 | + echo 'result = '.$json->encode(array('updates' => $nodes)); |
|
258 | 258 | } |
259 | 259 | |
260 | - function getLicenseText(){ |
|
260 | + function getLicenseText() { |
|
261 | 261 | $json = getJSONobj(); |
262 | 262 | $file = ''; |
263 | - if(isset($_REQUEST['file'])) { |
|
263 | + if (isset($_REQUEST['file'])) { |
|
264 | 264 | $file = hashToFile($_REQUEST['file']); |
265 | 265 | } |
266 | 266 | $GLOBALS['log']->debug("FILE : ".$file); |
267 | - echo 'result = ' . $json->encode(array('license_display' => PackageManagerDisplay::buildLicenseOutput($file))); |
|
267 | + echo 'result = '.$json->encode(array('license_display' => PackageManagerDisplay::buildLicenseOutput($file))); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
271 | 271 | * build the list of modules that are currently in the staging area waiting to be installed |
272 | 272 | */ |
273 | - function getPackagesInStaging(){ |
|
273 | + function getPackagesInStaging() { |
|
274 | 274 | $packages = $this->_pm->getPackagesInStaging('module'); |
275 | 275 | $json = getJSONobj(); |
276 | 276 | |
277 | - echo 'result = ' . $json->encode(array('packages' => $packages)); |
|
277 | + echo 'result = '.$json->encode(array('packages' => $packages)); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
281 | 281 | * build the list of modules that are currently in the staging area waiting to be installed |
282 | 282 | */ |
283 | - function performInstall(){ |
|
283 | + function performInstall() { |
|
284 | 284 | $file = ''; |
285 | - if(isset($_REQUEST['file'])) { |
|
285 | + if (isset($_REQUEST['file'])) { |
|
286 | 286 | $file = hashToFile($_REQUEST['file']); |
287 | 287 | } |
288 | - if(!empty($file)){ |
|
288 | + if (!empty($file)) { |
|
289 | 289 | $this->_pm->performInstall($file); |
290 | 290 | } |
291 | 291 | $json = getJSONobj(); |
292 | 292 | |
293 | - echo 'result = ' . $json->encode(array('result' => 'success')); |
|
293 | + echo 'result = '.$json->encode(array('result' => 'success')); |
|
294 | 294 | } |
295 | 295 | |
296 | - function authenticate(){ |
|
296 | + function authenticate() { |
|
297 | 297 | $json = getJSONobj(); |
298 | 298 | $username = ''; |
299 | 299 | $password = ''; |
300 | 300 | $servername = ''; |
301 | 301 | $terms_checked = ''; |
302 | - if(isset($_REQUEST['username'])) { |
|
302 | + if (isset($_REQUEST['username'])) { |
|
303 | 303 | $username = nl2br($_REQUEST['username']); |
304 | 304 | } |
305 | - if(isset($_REQUEST['password'])) { |
|
305 | + if (isset($_REQUEST['password'])) { |
|
306 | 306 | $password = nl2br($_REQUEST['password']); |
307 | 307 | } |
308 | - if(isset($_REQUEST['servername'])) { |
|
308 | + if (isset($_REQUEST['servername'])) { |
|
309 | 309 | $servername = $_REQUEST['servername']; |
310 | 310 | } |
311 | - if(isset($_REQUEST['terms_checked'])) { |
|
311 | + if (isset($_REQUEST['terms_checked'])) { |
|
312 | 312 | $terms_checked = $_REQUEST['terms_checked']; |
313 | - if($terms_checked == 'on') |
|
313 | + if ($terms_checked == 'on') |
|
314 | 314 | $terms_checked = true; |
315 | 315 | } |
316 | 316 | |
317 | - if(!empty($username) && !empty($password)){ |
|
317 | + if (!empty($username) && !empty($password)) { |
|
318 | 318 | $password = md5($password); |
319 | 319 | $result = PackageManager::authenticate($username, $password, $servername, $terms_checked); |
320 | - if(!is_array($result) && $result == true) |
|
320 | + if (!is_array($result) && $result == true) |
|
321 | 321 | $status = 'success'; |
322 | 322 | else |
323 | 323 | $status = $result['faultstring']; |
324 | - }else{ |
|
325 | - $status = 'failed'; |
|
324 | + } else { |
|
325 | + $status = 'failed'; |
|
326 | 326 | } |
327 | 327 | |
328 | - echo 'result = ' . $json->encode(array('status' => $status)); |
|
328 | + echo 'result = '.$json->encode(array('status' => $status)); |
|
329 | 329 | } |
330 | 330 | |
331 | - function getDocumentation(){ |
|
331 | + function getDocumentation() { |
|
332 | 332 | $json = getJSONobj(); |
333 | 333 | $package_id = ''; |
334 | 334 | $release_id = ''; |
335 | 335 | |
336 | - if(isset($_REQUEST['package_id'])) { |
|
336 | + if (isset($_REQUEST['package_id'])) { |
|
337 | 337 | $package_id = nl2br($_REQUEST['package_id']); |
338 | 338 | } |
339 | - if(isset($_REQUEST['release_id'])) { |
|
339 | + if (isset($_REQUEST['release_id'])) { |
|
340 | 340 | $release_id = nl2br($_REQUEST['release_id']); |
341 | 341 | } |
342 | 342 | |
343 | 343 | $documents = PackageManager::getDocumentation($package_id, $release_id); |
344 | 344 | $GLOBALS['log']->debug("DOCUMENTS: ".var_export($documents, true)); |
345 | - echo 'result = ' . $json->encode(array('documents' => $documents)); |
|
345 | + echo 'result = '.$json->encode(array('documents' => $documents)); |
|
346 | 346 | } |
347 | 347 | |
348 | - function downloadedDocumentation(){ |
|
348 | + function downloadedDocumentation() { |
|
349 | 349 | $json = getJSONobj(); |
350 | 350 | $document_id = ''; |
351 | 351 | |
352 | - if(isset($_REQUEST['document_id'])) { |
|
352 | + if (isset($_REQUEST['document_id'])) { |
|
353 | 353 | $document_id = nl2br($_REQUEST['document_id']); |
354 | 354 | } |
355 | 355 | $GLOBALS['log']->debug("Downloading Document: ".$document_id); |
356 | 356 | PackageManagerComm::downloadedDocumentation($document_id); |
357 | - echo 'result = ' . $json->encode(array('result' => 'true')); |
|
357 | + echo 'result = '.$json->encode(array('result' => 'true')); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -365,27 +365,27 @@ discard block |
||
365 | 365 | */ |
366 | 366 | protected function rmMetaFile($file, $meta) |
367 | 367 | { |
368 | - $metafile = pathinfo($file, PATHINFO_DIRNAME)."/". pathinfo($file, PATHINFO_FILENAME)."-$meta.php"; |
|
369 | - if(file_exists($metafile)) { |
|
368 | + $metafile = pathinfo($file, PATHINFO_DIRNAME)."/".pathinfo($file, PATHINFO_FILENAME)."-$meta.php"; |
|
369 | + if (file_exists($metafile)) { |
|
370 | 370 | unlink($metafile); |
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
374 | - function remove(){ |
|
374 | + function remove() { |
|
375 | 375 | $json = getJSONobj(); |
376 | 376 | $file = ''; |
377 | 377 | |
378 | - if(isset($_REQUEST['file'])) { |
|
378 | + if (isset($_REQUEST['file'])) { |
|
379 | 379 | $file = urldecode(hashToFile($_REQUEST['file'])); |
380 | 380 | } |
381 | 381 | $GLOBALS['log']->debug("FILE TO REMOVE: ".$file); |
382 | - if(!empty($file)){ |
|
382 | + if (!empty($file)) { |
|
383 | 383 | unlink($file); |
384 | - foreach(array("manifest", "icon") as $meta) { |
|
384 | + foreach (array("manifest", "icon") as $meta) { |
|
385 | 385 | $this->rmMetaFile($file, $meta); |
386 | 386 | } |
387 | 387 | } |
388 | - echo 'result = ' . $json->encode(array('result' => 'true')); |
|
388 | + echo 'result = '.$json->encode(array('result' => 'true')); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | ?> |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
58 | 58 | if(isset($GLOBALS['log'])) { |
59 | 59 | $GLOBALS['log']->deprecated($deprecatedMessage); |
60 | - } |
|
61 | - else { |
|
60 | + } else { |
|
62 | 61 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
63 | 62 | } |
64 | 63 | self::__construct(); |
@@ -124,8 +123,9 @@ discard block |
||
124 | 123 | $type_str = ''; |
125 | 124 | foreach($types as $type){ |
126 | 125 | $type_str .= "'".$type."'"; |
127 | - if($index < $count) |
|
128 | - $type_str .= ","; |
|
126 | + if($index < $count) { |
|
127 | + $type_str .= ","; |
|
128 | + } |
|
129 | 129 | $index++; |
130 | 130 | } |
131 | 131 | |
@@ -310,18 +310,20 @@ discard block |
||
310 | 310 | } |
311 | 311 | if(isset($_REQUEST['terms_checked'])) { |
312 | 312 | $terms_checked = $_REQUEST['terms_checked']; |
313 | - if($terms_checked == 'on') |
|
314 | - $terms_checked = true; |
|
313 | + if($terms_checked == 'on') { |
|
314 | + $terms_checked = true; |
|
315 | + } |
|
315 | 316 | } |
316 | 317 | |
317 | 318 | if(!empty($username) && !empty($password)){ |
318 | 319 | $password = md5($password); |
319 | 320 | $result = PackageManager::authenticate($username, $password, $servername, $terms_checked); |
320 | - if(!is_array($result) && $result == true) |
|
321 | - $status = 'success'; |
|
322 | - else |
|
323 | - $status = $result['faultstring']; |
|
324 | - }else{ |
|
321 | + if(!is_array($result) && $result == true) { |
|
322 | + $status = 'success'; |
|
323 | + } else { |
|
324 | + $status = $result['faultstring']; |
|
325 | + } |
|
326 | + } else{ |
|
325 | 327 | $status = 'failed'; |
326 | 328 | } |
327 | 329 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $name_value_list = PackageManager::fromNameValueList($name_value_list); |
90 | 90 | return $name_value_list['description']; |
91 | 91 | }else { |
92 | - return ''; |
|
92 | + return ''; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * Obtain a list of category/packages/releases for use within the module loader |
98 | 98 | */ |
99 | 99 | function getModuleLoaderCategoryPackages($category_id = ''){ |
100 | - $filter = array(); |
|
101 | - $filter = array('type' => "'module', 'theme', 'langpack'"); |
|
102 | - $filter = PackageManager::toNameValueList($filter); |
|
103 | - return PackageManager::getCategoryPackages($category_id, $filter); |
|
100 | + $filter = array(); |
|
101 | + $filter = array('type' => "'module', 'theme', 'langpack'"); |
|
102 | + $filter = PackageManager::toNameValueList($filter); |
|
103 | + return PackageManager::getCategoryPackages($category_id, $filter); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,41 +108,41 @@ discard block |
||
108 | 108 | * @return category_packages |
109 | 109 | */ |
110 | 110 | function getCategoryPackages($category_id = '', $filter = array()){ |
111 | - $results = PackageManagerComm::getCategoryPackages($category_id, $filter); |
|
112 | - PackageManagerComm::errorCheck(); |
|
113 | - $nodes = array(); |
|
111 | + $results = PackageManagerComm::getCategoryPackages($category_id, $filter); |
|
112 | + PackageManagerComm::errorCheck(); |
|
113 | + $nodes = array(); |
|
114 | 114 | |
115 | 115 | $nodes[$category_id]['packages'] = array(); |
116 | 116 | if(!empty($results['categories'])){ |
117 | - foreach($results['categories'] as $category){ |
|
118 | - $mycat = PackageManager::fromNameValueList($category); |
|
119 | - $nodes[$mycat['id']] = array('id' => $mycat['id'], 'label' => $mycat['name'], 'description' => $mycat['description'], 'type' => 'cat', 'parent' => $mycat['parent_id']); |
|
120 | - $nodes[$mycat['id']]['packages'] = array(); |
|
121 | - } |
|
122 | - } |
|
123 | - if(!empty($results['packages'])){ |
|
124 | - $uh = new UpgradeHistory(); |
|
125 | - foreach($results['packages'] as $package){ |
|
126 | - $mypack = PackageManager::fromNameValueList($package); |
|
127 | - $nodes[$mypack['category_id']]['packages'][$mypack['id']] = array('id' => $mypack['id'], 'label' => $mypack['name'], 'description' => $mypack['description'], 'category_id' => $mypack['category_id'], 'type' => 'package'); |
|
128 | - $releases = PackageManager::getReleases($category_id, $mypack['id'], $filter); |
|
129 | - $arr_releases = array(); |
|
130 | - $nodes[$mypack['category_id']]['packages'][$mypack['id']]['releases'] = array(); |
|
131 | - if(!empty($releases['packages'])){ |
|
132 | - foreach($releases['packages'] as $release){ |
|
133 | - $myrelease = PackageManager::fromNameValueList($release); |
|
134 | - //check to see if we already this one installed |
|
135 | - $result = $uh->determineIfUpgrade($myrelease['id_name'], $myrelease['version']); |
|
136 | - $enable = false; |
|
137 | - if($result == true || is_array($result)) |
|
138 | - $enable = true; |
|
139 | - $nodes[$mypack['category_id']]['packages'][$mypack['id']]['releases'][$myrelease['id']] = array('id' => $myrelease['id'], 'version' => $myrelease['version'], 'label' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id'], 'type' => 'release', 'enable' => $enable); |
|
140 | - } |
|
141 | - } |
|
142 | - //array_push($nodes[$mypack['category_id']]['packages'], $package_arr); |
|
143 | - } |
|
144 | - } |
|
145 | - $GLOBALS['log']->debug("NODES". var_export($nodes, true)); |
|
117 | + foreach($results['categories'] as $category){ |
|
118 | + $mycat = PackageManager::fromNameValueList($category); |
|
119 | + $nodes[$mycat['id']] = array('id' => $mycat['id'], 'label' => $mycat['name'], 'description' => $mycat['description'], 'type' => 'cat', 'parent' => $mycat['parent_id']); |
|
120 | + $nodes[$mycat['id']]['packages'] = array(); |
|
121 | + } |
|
122 | + } |
|
123 | + if(!empty($results['packages'])){ |
|
124 | + $uh = new UpgradeHistory(); |
|
125 | + foreach($results['packages'] as $package){ |
|
126 | + $mypack = PackageManager::fromNameValueList($package); |
|
127 | + $nodes[$mypack['category_id']]['packages'][$mypack['id']] = array('id' => $mypack['id'], 'label' => $mypack['name'], 'description' => $mypack['description'], 'category_id' => $mypack['category_id'], 'type' => 'package'); |
|
128 | + $releases = PackageManager::getReleases($category_id, $mypack['id'], $filter); |
|
129 | + $arr_releases = array(); |
|
130 | + $nodes[$mypack['category_id']]['packages'][$mypack['id']]['releases'] = array(); |
|
131 | + if(!empty($releases['packages'])){ |
|
132 | + foreach($releases['packages'] as $release){ |
|
133 | + $myrelease = PackageManager::fromNameValueList($release); |
|
134 | + //check to see if we already this one installed |
|
135 | + $result = $uh->determineIfUpgrade($myrelease['id_name'], $myrelease['version']); |
|
136 | + $enable = false; |
|
137 | + if($result == true || is_array($result)) |
|
138 | + $enable = true; |
|
139 | + $nodes[$mypack['category_id']]['packages'][$mypack['id']]['releases'][$myrelease['id']] = array('id' => $myrelease['id'], 'version' => $myrelease['version'], 'label' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id'], 'type' => 'release', 'enable' => $enable); |
|
140 | + } |
|
141 | + } |
|
142 | + //array_push($nodes[$mypack['category_id']]['packages'], $package_arr); |
|
143 | + } |
|
144 | + } |
|
145 | + $GLOBALS['log']->debug("NODES". var_export($nodes, true)); |
|
146 | 146 | return $nodes; |
147 | 147 | } |
148 | 148 | |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | $results = PackageManagerComm::getCategories($category_id, $filter); |
158 | 158 | PackageManagerComm::errorCheck(); |
159 | 159 | if(!empty($results['categories'])){ |
160 | - foreach($results['categories'] as $category){ |
|
161 | - $mycat = PackageManager::fromNameValueList($category); |
|
162 | - $nodes[] = array('id' => $mycat['id'], 'label' => $mycat['name'], 'description' => $mycat['description'], 'type' => 'cat', 'parent' => $mycat['parent_id']); |
|
163 | - } |
|
160 | + foreach($results['categories'] as $category){ |
|
161 | + $mycat = PackageManager::fromNameValueList($category); |
|
162 | + $nodes[] = array('id' => $mycat['id'], 'label' => $mycat['name'], 'description' => $mycat['description'], 'type' => 'cat', 'parent' => $mycat['parent_id']); |
|
163 | + } |
|
164 | 164 | } |
165 | 165 | return $nodes; |
166 | 166 | } |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | //$xml = ''; |
174 | 174 | //$xml .= '<packages>'; |
175 | 175 | if(!empty($results['packages'])){ |
176 | - foreach($results['packages'] as $package){ |
|
177 | - $mypack = PackageManager::fromNameValueList($package); |
|
178 | - $packages[$mypack['id']] = array('package_id' => $mypack['id'], 'name' => $mypack['name'], 'description' => $mypack['description'], 'category_id' => $mypack['category_id']); |
|
179 | - $releases = PackageManager::getReleases($category_id, $mypack['id']); |
|
180 | - $arr_releases = array(); |
|
181 | - foreach($releases['packages'] as $release){ |
|
182 | - $myrelease = PackageManager::fromNameValueList($release); |
|
183 | - $arr_releases[$myrelease['id']] = array('release_id' => $myrelease['id'], 'version' => $myrelease['version'], 'description' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id']); |
|
184 | - } |
|
185 | - $packages[$mypack['id']]['releases'] = $arr_releases; |
|
186 | - } |
|
176 | + foreach($results['packages'] as $package){ |
|
177 | + $mypack = PackageManager::fromNameValueList($package); |
|
178 | + $packages[$mypack['id']] = array('package_id' => $mypack['id'], 'name' => $mypack['name'], 'description' => $mypack['description'], 'category_id' => $mypack['category_id']); |
|
179 | + $releases = PackageManager::getReleases($category_id, $mypack['id']); |
|
180 | + $arr_releases = array(); |
|
181 | + foreach($releases['packages'] as $release){ |
|
182 | + $myrelease = PackageManager::fromNameValueList($release); |
|
183 | + $arr_releases[$myrelease['id']] = array('release_id' => $myrelease['id'], 'version' => $myrelease['version'], 'description' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id']); |
|
184 | + } |
|
185 | + $packages[$mypack['id']]['releases'] = $arr_releases; |
|
186 | + } |
|
187 | 187 | } |
188 | 188 | return $packages; |
189 | 189 | } |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | if(!empty($release_id)){ |
209 | 209 | $filename = PackageManagerComm::addDownload($category_id, $package_id, $release_id); |
210 | 210 | if($filename){ |
211 | - $GLOBALS['log']->debug('RESULT: '.$filename); |
|
212 | - PackageManagerComm::errorCheck(); |
|
213 | - $filepath = PackageManagerComm::performDownload($filename); |
|
214 | - return $filepath; |
|
211 | + $GLOBALS['log']->debug('RESULT: '.$filename); |
|
212 | + PackageManagerComm::errorCheck(); |
|
213 | + $filepath = PackageManagerComm::performDownload($filename); |
|
214 | + return $filepath; |
|
215 | 215 | } |
216 | 216 | }else{ |
217 | 217 | return null; |
@@ -232,20 +232,20 @@ discard block |
||
232 | 232 | PackageManagerComm::clearSession(); |
233 | 233 | $result = PackageManagerComm::login($terms_checked); |
234 | 234 | if(is_array($result)) |
235 | - return $result; |
|
236 | - else |
|
237 | - return true; |
|
235 | + return $result; |
|
236 | + else |
|
237 | + return true; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | function setCredentials($username, $password, $systemname){ |
241 | 241 | |
242 | 242 | $admin = new Administration(); |
243 | 243 | $admin->retrieveSettings(); |
244 | - $admin->saveSetting(CREDENTIAL_CATEGORY, CREDENTIAL_USERNAME, $username); |
|
245 | - $admin->saveSetting(CREDENTIAL_CATEGORY, CREDENTIAL_PASSWORD, $password); |
|
246 | - if(!empty($systemname)){ |
|
247 | - $admin->saveSetting('system', 'name', $systemname); |
|
248 | - } |
|
244 | + $admin->saveSetting(CREDENTIAL_CATEGORY, CREDENTIAL_USERNAME, $username); |
|
245 | + $admin->saveSetting(CREDENTIAL_CATEGORY, CREDENTIAL_PASSWORD, $password); |
|
246 | + if(!empty($systemname)){ |
|
247 | + $admin->saveSetting('system', 'name', $systemname); |
|
248 | + } |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | static function getCredentials(){ |
@@ -255,21 +255,21 @@ discard block |
||
255 | 255 | $credentials = array(); |
256 | 256 | $credentials['username'] = ''; |
257 | 257 | $credentials['password'] = ''; |
258 | - $credentials['system_name'] = ''; |
|
258 | + $credentials['system_name'] = ''; |
|
259 | 259 | if(!empty($admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME])){ |
260 | - $credentials['username'] = $admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME]; |
|
260 | + $credentials['username'] = $admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME]; |
|
261 | 261 | } |
262 | 262 | if(!empty($admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME])){ |
263 | - $credentials['password'] = $admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_PASSWORD]; |
|
263 | + $credentials['password'] = $admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_PASSWORD]; |
|
264 | 264 | } |
265 | 265 | if(!empty($admin->settings['system_name'])){ |
266 | - $credentials['system_name'] = $admin->settings['system_name']; |
|
266 | + $credentials['system_name'] = $admin->settings['system_name']; |
|
267 | 267 | } |
268 | 268 | return $credentials; |
269 | 269 | } |
270 | 270 | |
271 | 271 | function getTermsAndConditions(){ |
272 | - return PackageManagerComm::getTermsAndConditions(); |
|
272 | + return PackageManagerComm::getTermsAndConditions(); |
|
273 | 273 | |
274 | 274 | } |
275 | 275 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return documents |
283 | 283 | */ |
284 | 284 | function getDocumentation($package_id, $release_id){ |
285 | - if(!empty($release_id) || !empty($package_id)){ |
|
285 | + if(!empty($release_id) || !empty($package_id)){ |
|
286 | 286 | $documents = PackageManagerComm::getDocumentation($package_id, $release_id); |
287 | 287 | return $documents; |
288 | 288 | }else{ |
@@ -295,33 +295,33 @@ discard block |
||
295 | 295 | * The depot will then send back a list of modules that need to be updated |
296 | 296 | */ |
297 | 297 | function checkForUpdates(){ |
298 | - $lists = $this->buildInstalledReleases(array('module'), true); |
|
299 | - $updates = array(); |
|
300 | - if(!empty($lists)){ |
|
301 | - $updates = PackageManagerComm::checkForUpdates($lists); |
|
302 | - }//fi |
|
303 | - return $updates; |
|
298 | + $lists = $this->buildInstalledReleases(array('module'), true); |
|
299 | + $updates = array(); |
|
300 | + if(!empty($lists)){ |
|
301 | + $updates = PackageManagerComm::checkForUpdates($lists); |
|
302 | + }//fi |
|
303 | + return $updates; |
|
304 | 304 | } |
305 | 305 | |
306 | - //////////////////////////////////////////////////////// |
|
307 | - /////////// HELPER FUNCTIONS |
|
306 | + //////////////////////////////////////////////////////// |
|
307 | + /////////// HELPER FUNCTIONS |
|
308 | 308 | function toNameValueList($array){ |
309 | - $list = array(); |
|
310 | - foreach($array as $name=>$value){ |
|
311 | - $list[] = array('name'=>$name, 'value'=>$value); |
|
312 | - } |
|
313 | - return $list; |
|
314 | - } |
|
315 | - |
|
316 | - function toNameValueLists($arrays){ |
|
317 | - $lists = array(); |
|
318 | - foreach($arrays as $array){ |
|
319 | - $lists[] = PackageManager::toNameValueList($array); |
|
320 | - } |
|
321 | - return $lists; |
|
322 | - } |
|
323 | - |
|
324 | - function fromNameValueList($nvl){ |
|
309 | + $list = array(); |
|
310 | + foreach($array as $name=>$value){ |
|
311 | + $list[] = array('name'=>$name, 'value'=>$value); |
|
312 | + } |
|
313 | + return $list; |
|
314 | + } |
|
315 | + |
|
316 | + function toNameValueLists($arrays){ |
|
317 | + $lists = array(); |
|
318 | + foreach($arrays as $array){ |
|
319 | + $lists[] = PackageManager::toNameValueList($array); |
|
320 | + } |
|
321 | + return $lists; |
|
322 | + } |
|
323 | + |
|
324 | + function fromNameValueList($nvl){ |
|
325 | 325 | $array = array(); |
326 | 326 | foreach($nvl as $list){ |
327 | 327 | $array[$list['name']] = $list['value']; |
@@ -330,19 +330,19 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | function buildInstalledReleases($types = array('module')){ |
333 | - //1) get list of installed modules |
|
334 | - $installeds = $this->getInstalled($types); |
|
335 | - $releases = array(); |
|
336 | - foreach($installeds as $installed){ |
|
337 | - $releases[] = array('name' => $installed->name, 'id_name' => $installed->id_name, 'version' => $installed->version, 'filename' => $installed->filename, 'type' => $installed->type); |
|
338 | - } |
|
333 | + //1) get list of installed modules |
|
334 | + $installeds = $this->getInstalled($types); |
|
335 | + $releases = array(); |
|
336 | + foreach($installeds as $installed){ |
|
337 | + $releases[] = array('name' => $installed->name, 'id_name' => $installed->id_name, 'version' => $installed->version, 'filename' => $installed->filename, 'type' => $installed->type); |
|
338 | + } |
|
339 | 339 | |
340 | - $lists = array(); |
|
341 | - $name_value_list = array(); |
|
342 | - if(!empty($releases)){ |
|
343 | - $lists = $this->toNameValueLists($releases); |
|
344 | - }//fi |
|
345 | - return $lists; |
|
340 | + $lists = array(); |
|
341 | + $name_value_list = array(); |
|
342 | + if(!empty($releases)){ |
|
343 | + $lists = $this->toNameValueLists($releases); |
|
344 | + }//fi |
|
345 | + return $lists; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | function buildPackageXML($package, $releases = array()){ |
@@ -351,19 +351,19 @@ discard block |
||
351 | 351 | $xml .= '<name>'.$package['name'].'</name>'; |
352 | 352 | $xml .= '<description>'.$package['description'].'</description>'; |
353 | 353 | if(!empty($releases)){ |
354 | - $xml .= '<releases>'; |
|
355 | - foreach($releases['packages'] as $release){ |
|
356 | - |
|
357 | - $myrelease = PackageManager::fromNameValueList($release); |
|
358 | - $xml .= '<release>'; |
|
359 | - $xml .= '<release_id>'.$myrelease['id'].'</release_id>'; |
|
360 | - $xml .= '<version>'.$myrelease['version'].'</version>'; |
|
361 | - $xml .= '<description>'.$myrelease['description'].'</description>'; |
|
362 | - $xml .= '<package_id>'.$package['id'].'</package_id>'; |
|
363 | - $xml .= '<category_id>'.$package['category_id'].'</category_id>'; |
|
364 | - $xml .= '</release>'; |
|
365 | - } |
|
366 | - $xml .= '</releases>'; |
|
354 | + $xml .= '<releases>'; |
|
355 | + foreach($releases['packages'] as $release){ |
|
356 | + |
|
357 | + $myrelease = PackageManager::fromNameValueList($release); |
|
358 | + $xml .= '<release>'; |
|
359 | + $xml .= '<release_id>'.$myrelease['id'].'</release_id>'; |
|
360 | + $xml .= '<version>'.$myrelease['version'].'</version>'; |
|
361 | + $xml .= '<description>'.$myrelease['description'].'</description>'; |
|
362 | + $xml .= '<package_id>'.$package['id'].'</package_id>'; |
|
363 | + $xml .= '<category_id>'.$package['category_id'].'</category_id>'; |
|
364 | + $xml .= '</release>'; |
|
365 | + } |
|
366 | + $xml .= '</releases>'; |
|
367 | 367 | } |
368 | 368 | $xml .= '</package>'; |
369 | 369 | return $xml; |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - if( isset($manifest['acceptable_sugar_flavors']) && sizeof($manifest['acceptable_sugar_flavors']) > 0 ){ |
|
447 | + if( isset($manifest['acceptable_sugar_flavors']) && sizeof($manifest['acceptable_sugar_flavors']) > 0 ){ |
|
448 | 448 | $flavor_ok = false; |
449 | 449 | foreach( $manifest['acceptable_sugar_flavors'] as $match ){ |
450 | 450 | if( $match == $sugar_flavor ){ |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
480 | 480 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
481 | 481 | $manifest_file = $this->extractManifest( $base_filename,$base_tmp_upgrade_dir); |
482 | - $GLOBALS['log']->debug("Manifest: ".$manifest_file); |
|
482 | + $GLOBALS['log']->debug("Manifest: ".$manifest_file); |
|
483 | 483 | if($view == 'module') |
484 | 484 | $license_file = $this->extractFile($base_filename, 'LICENSE.txt', $base_tmp_upgrade_dir); |
485 | 485 | if(is_file($manifest_file)){ |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | $messages = '<script>ajaxStatus.flashStatus("' .$base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS'] . ', 5000");</script>'; |
522 | 522 | }else{ |
523 | 523 | if($display_messages) |
524 | - $messages = '<script>ajaxStatus.flashStatus("' .$mod_strings['ERR_UW_UPLOAD_ERROR'] . ', 5000");</script>'; |
|
524 | + $messages = '<script>ajaxStatus.flashStatus("' .$mod_strings['ERR_UW_UPLOAD_ERROR'] . ', 5000");</script>'; |
|
525 | 525 | } |
526 | 526 | }//fi |
527 | 527 | else{ |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | $mi = new ModuleInstaller(); |
554 | 554 | $mi->silent = $silent; |
555 | 555 | $mod_strings = return_module_language($current_language, "Administration"); |
556 | - $GLOBALS['log']->debug("ABOUT TO INSTALL: ".$file); |
|
556 | + $GLOBALS['log']->debug("ABOUT TO INSTALL: ".$file); |
|
557 | 557 | if(preg_match("#.*\.zip\$#", $file)) { |
558 | - $GLOBALS['log']->debug("1: ".$file); |
|
558 | + $GLOBALS['log']->debug("1: ".$file); |
|
559 | 559 | // handle manifest.php |
560 | 560 | $target_manifest = remove_file_extension( $file ) . '-manifest.php'; |
561 | 561 | include($target_manifest); |
@@ -565,18 +565,18 @@ discard block |
||
565 | 565 | unzip($file, $unzip_dir ); |
566 | 566 | $GLOBALS['log']->debug("3: ".$unzip_dir); |
567 | 567 | $id_name = $installdefs['id']; |
568 | - $version = $manifest['version']; |
|
569 | - $uh = new UpgradeHistory(); |
|
570 | - $previous_install = array(); |
|
571 | - if(!empty($id_name) & !empty($version)) |
|
572 | - $previous_install = $uh->determineIfUpgrade($id_name, $version); |
|
573 | - $previous_version = (empty($previous_install['version'])) ? '' : $previous_install['version']; |
|
574 | - $previous_id = (empty($previous_install['id'])) ? '' : $previous_install['id']; |
|
568 | + $version = $manifest['version']; |
|
569 | + $uh = new UpgradeHistory(); |
|
570 | + $previous_install = array(); |
|
571 | + if(!empty($id_name) & !empty($version)) |
|
572 | + $previous_install = $uh->determineIfUpgrade($id_name, $version); |
|
573 | + $previous_version = (empty($previous_install['version'])) ? '' : $previous_install['version']; |
|
574 | + $previous_id = (empty($previous_install['id'])) ? '' : $previous_install['id']; |
|
575 | 575 | |
576 | 576 | if(!empty($previous_version)){ |
577 | - $mi->install($unzip_dir, true, $previous_version); |
|
577 | + $mi->install($unzip_dir, true, $previous_version); |
|
578 | 578 | }else{ |
579 | - $mi->install($unzip_dir); |
|
579 | + $mi->install($unzip_dir); |
|
580 | 580 | } |
581 | 581 | $GLOBALS['log']->debug("INSTALLED: ".$file); |
582 | 582 | $new_upgrade = new UpgradeHistory(); |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | $new_upgrade->name = $manifest['name']; |
590 | 590 | $new_upgrade->description = $manifest['description']; |
591 | 591 | $new_upgrade->id_name = $id_name; |
592 | - $serial_manifest = array(); |
|
593 | - $serial_manifest['manifest'] = (isset($manifest) ? $manifest : ''); |
|
594 | - $serial_manifest['installdefs'] = (isset($installdefs) ? $installdefs : ''); |
|
595 | - $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); |
|
596 | - $new_upgrade->manifest = base64_encode(serialize($serial_manifest)); |
|
592 | + $serial_manifest = array(); |
|
593 | + $serial_manifest['manifest'] = (isset($manifest) ? $manifest : ''); |
|
594 | + $serial_manifest['installdefs'] = (isset($installdefs) ? $installdefs : ''); |
|
595 | + $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); |
|
596 | + $new_upgrade->manifest = base64_encode(serialize($serial_manifest)); |
|
597 | 597 | //$new_upgrade->unique_key = (isset($manifest['unique_key'])) ? $manifest['unique_key'] : ''; |
598 | 598 | $new_upgrade->save(); |
599 | 599 | //unlink($file); |
@@ -601,16 +601,16 @@ discard block |
||
601 | 601 | } |
602 | 602 | |
603 | 603 | function performUninstall($name){ |
604 | - $uh = new UpgradeHistory(); |
|
605 | - $uh->name = $name; |
|
606 | - $uh->id_name = $name; |
|
607 | - $found = $uh->checkForExisting($uh); |
|
608 | - if($found != null){ |
|
609 | - global $sugar_config; |
|
610 | - global $mod_strings; |
|
611 | - global $current_language; |
|
612 | - $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
|
613 | - $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
|
604 | + $uh = new UpgradeHistory(); |
|
605 | + $uh->name = $name; |
|
606 | + $uh->id_name = $name; |
|
607 | + $found = $uh->checkForExisting($uh); |
|
608 | + if($found != null){ |
|
609 | + global $sugar_config; |
|
610 | + global $mod_strings; |
|
611 | + global $current_language; |
|
612 | + $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
|
613 | + $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
|
614 | 614 | if(is_file($found->filename)){ |
615 | 615 | if(!isset($GLOBALS['mi_remove_tables']))$GLOBALS['mi_remove_tables'] = true; |
616 | 616 | $unzip_dir = mk_temp_dir( $base_tmp_upgrade_dir ); |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | //file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem |
626 | 626 | $found->delete(); |
627 | 627 | } |
628 | - } |
|
628 | + } |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | function getUITextForType( $type ){ |
@@ -686,10 +686,10 @@ discard block |
||
686 | 686 | $content_values = array_values($uContent); |
687 | 687 | $alreadyProcessed = array(); |
688 | 688 | foreach($content_values as $val){ |
689 | - if(empty($alreadyProcessed[$val])){ |
|
690 | - $upgrade_contents[] = $val; |
|
691 | - $alreadyProcessed[$val] = true; |
|
692 | - } |
|
689 | + if(empty($alreadyProcessed[$val])){ |
|
690 | + $upgrade_contents[] = $val; |
|
691 | + $alreadyProcessed[$val] = true; |
|
692 | + } |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | $upgrades_available = 0; |
@@ -703,35 +703,35 @@ discard block |
||
703 | 703 | $the_base = basename($upgrade_content); |
704 | 704 | $the_md5 = md5_file($upgrade_content); |
705 | 705 | $md5_matches = $uh->findByMd5($the_md5); |
706 | - $file_install = $upgrade_content; |
|
706 | + $file_install = $upgrade_content; |
|
707 | 707 | if(empty($md5_matches)) |
708 | 708 | { |
709 | 709 | $target_manifest = remove_file_extension( $upgrade_content ) . '-manifest.php'; |
710 | 710 | if(file_exists($target_manifest)) { |
711 | - require_once($target_manifest); |
|
712 | - |
|
713 | - $name = empty($manifest['name']) ? $upgrade_content : $manifest['name']; |
|
714 | - $version = empty($manifest['version']) ? '' : $manifest['version']; |
|
715 | - $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; |
|
716 | - $icon = ''; |
|
717 | - $description = empty($manifest['description']) ? 'None' : $manifest['description']; |
|
718 | - $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; |
|
719 | - $type = $this->getUITextForType( $manifest['type'] ); |
|
720 | - $manifest_type = $manifest['type']; |
|
721 | - $dependencies = array(); |
|
722 | - if( isset( $manifest['dependencies']) ){ |
|
723 | - $dependencies = $manifest['dependencies']; |
|
724 | - } |
|
711 | + require_once($target_manifest); |
|
712 | + |
|
713 | + $name = empty($manifest['name']) ? $upgrade_content : $manifest['name']; |
|
714 | + $version = empty($manifest['version']) ? '' : $manifest['version']; |
|
715 | + $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; |
|
716 | + $icon = ''; |
|
717 | + $description = empty($manifest['description']) ? 'None' : $manifest['description']; |
|
718 | + $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; |
|
719 | + $type = $this->getUITextForType( $manifest['type'] ); |
|
720 | + $manifest_type = $manifest['type']; |
|
721 | + $dependencies = array(); |
|
722 | + if( isset( $manifest['dependencies']) ){ |
|
723 | + $dependencies = $manifest['dependencies']; |
|
724 | + } |
|
725 | 725 | } |
726 | 726 | |
727 | - //check dependencies first |
|
728 | - if(!empty($dependencies)) { |
|
729 | - $uh = new UpgradeHistory(); |
|
730 | - $not_found = $uh->checkDependencies($dependencies); |
|
731 | - if(!empty($not_found) && count($not_found) > 0){ |
|
732 | - $file_install = 'errors_'.$mod_strings['ERR_UW_NO_DEPENDENCY']."[".implode(',', $not_found)."]"; |
|
733 | - } |
|
734 | - } |
|
727 | + //check dependencies first |
|
728 | + if(!empty($dependencies)) { |
|
729 | + $uh = new UpgradeHistory(); |
|
730 | + $not_found = $uh->checkDependencies($dependencies); |
|
731 | + if(!empty($not_found) && count($not_found) > 0){ |
|
732 | + $file_install = 'errors_'.$mod_strings['ERR_UW_NO_DEPENDENCY']."[".implode(',', $not_found)."]"; |
|
733 | + } |
|
734 | + } |
|
735 | 735 | |
736 | 736 | if($view == 'default' && $manifest_type != 'patch') { |
737 | 737 | continue; |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | $upgrades_available++; |
753 | 753 | |
754 | 754 | $packages[] = array('name' => $name, 'version' => $version, 'published_date' => $published_date, |
755 | - 'description' => $description, 'uninstallable' =>$uninstallable, 'type' => $type, |
|
756 | - 'file' => fileToHash($upgrade_content), 'file_install' => fileToHash($upgrade_content), 'unFile' => fileToHash($upgrade_content)); |
|
755 | + 'description' => $description, 'uninstallable' =>$uninstallable, 'type' => $type, |
|
756 | + 'file' => fileToHash($upgrade_content), 'file_install' => fileToHash($upgrade_content), 'unFile' => fileToHash($upgrade_content)); |
|
757 | 757 | }//fi |
758 | 758 | }//rof |
759 | 759 | return $packages; |
@@ -781,112 +781,112 @@ discard block |
||
781 | 781 | * @return an array of installed upgrade_history objects |
782 | 782 | */ |
783 | 783 | function getInstalled($types = array('module')){ |
784 | - $uh = new UpgradeHistory(); |
|
785 | - $in = ""; |
|
786 | - for($i = 0; $i < count($types); $i++){ |
|
787 | - $in .= "'".$types[$i]."'"; |
|
788 | - if(($i+1) < count($types)){ |
|
789 | - $in .= ","; |
|
790 | - } |
|
791 | - } |
|
792 | - $query = "SELECT * FROM ".$uh->table_name." WHERE type IN (".$in.")"; |
|
793 | - return $uh->getList($query); |
|
784 | + $uh = new UpgradeHistory(); |
|
785 | + $in = ""; |
|
786 | + for($i = 0; $i < count($types); $i++){ |
|
787 | + $in .= "'".$types[$i]."'"; |
|
788 | + if(($i+1) < count($types)){ |
|
789 | + $in .= ","; |
|
790 | + } |
|
791 | + } |
|
792 | + $query = "SELECT * FROM ".$uh->table_name." WHERE type IN (".$in.")"; |
|
793 | + return $uh->getList($query); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | function getinstalledPackages($types = array('module', 'langpack')){ |
797 | - global $sugar_config; |
|
798 | - $installeds = $this->getInstalled($types); |
|
799 | - $packages = array(); |
|
800 | - $upgrades_installed = 0; |
|
801 | - $uh = new UpgradeHistory(); |
|
797 | + global $sugar_config; |
|
798 | + $installeds = $this->getInstalled($types); |
|
799 | + $packages = array(); |
|
800 | + $upgrades_installed = 0; |
|
801 | + $uh = new UpgradeHistory(); |
|
802 | 802 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
803 | 803 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
804 | - foreach($installeds as $installed) |
|
805 | - { |
|
806 | - $populate = false; |
|
807 | - $filename = from_html($installed->filename); |
|
808 | - $date_entered = $installed->date_entered; |
|
809 | - $type = $installed->type; |
|
810 | - $version = $installed->version; |
|
811 | - $uninstallable = false; |
|
812 | - $link = ""; |
|
813 | - $description = $installed->description; |
|
814 | - $name = $installed->name; |
|
815 | - $enabled = true; |
|
816 | - $enabled_string = 'ENABLED'; |
|
817 | - //if the name is empty then we should try to pull from manifest and populate upgrade_history_table |
|
818 | - if(empty($name)){ |
|
819 | - $populate = true; |
|
820 | - } |
|
821 | - $upgrades_installed++; |
|
822 | - switch($type) |
|
823 | - { |
|
824 | - case "theme": |
|
825 | - case "langpack": |
|
826 | - case "module": |
|
827 | - case "patch": |
|
828 | - if($populate){ |
|
829 | - $manifest_file = $this->extractManifest($filename, $base_tmp_upgrade_dir); |
|
830 | - require_once($manifest_file); |
|
831 | - $GLOBALS['log']->info("Filling in upgrade_history table"); |
|
832 | - $populate = false; |
|
833 | - if( isset( $manifest['name'] ) ){ |
|
834 | - $name = $manifest['name']; |
|
835 | - $installed->name = $name; |
|
836 | - } |
|
837 | - if( isset( $manifest['description'] ) ){ |
|
838 | - $description = $manifest['description']; |
|
839 | - $installed->description = $description; |
|
840 | - } |
|
841 | - if(isset($installdefs) && isset( $installdefs['id'] ) ){ |
|
842 | - $id_name = $installdefs['id']; |
|
843 | - $installed->id_name = $id_name; |
|
844 | - } |
|
845 | - |
|
846 | - $serial_manifest = array(); |
|
847 | - $serial_manifest['manifest'] = (isset($manifest) ? $manifest : ''); |
|
848 | - $serial_manifest['installdefs'] = (isset($installdefs) ? $installdefs : ''); |
|
849 | - $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); |
|
850 | - $installed->manifest = base64_encode(serialize($serial_manifest)); |
|
851 | - $installed->save(); |
|
852 | - }else{ |
|
853 | - $serial_manifest = unserialize(base64_decode($installed->manifest)); |
|
854 | - $manifest = $serial_manifest['manifest']; |
|
855 | - } |
|
856 | - if(($upgrades_installed==0 || $uh->UninstallAvailable($installeds, $installed)) |
|
857 | - && is_file($filename) && !empty($manifest['is_uninstallable'])) |
|
858 | - { |
|
859 | - $uninstallable = true; |
|
860 | - } |
|
861 | - $enabled = $installed->enabled; |
|
862 | - if(!$enabled) |
|
863 | - $enabled_string = 'DISABLED'; |
|
864 | - $file_uninstall = $filename; |
|
865 | - if(!$uninstallable){ |
|
866 | - $file_uninstall = 'UNINSTALLABLE'; |
|
867 | - $enabled_string = 'UNINSTALLABLE'; |
|
868 | - } else { |
|
869 | - $file_uninstall = fileToHash( $file_uninstall ); |
|
870 | - } |
|
871 | - |
|
872 | - $packages[] = array( |
|
873 | - 'name' => $name, |
|
874 | - 'version' => $version, |
|
875 | - 'type' => $type, |
|
876 | - 'published_date' => $date_entered, |
|
877 | - 'description' => $description, |
|
878 | - 'uninstallable' =>$uninstallable, |
|
879 | - 'file_install' => $file_uninstall , |
|
880 | - 'file' => fileToHash($filename), |
|
881 | - 'enabled' => $enabled_string |
|
882 | - ); |
|
883 | - break; |
|
884 | - default: |
|
885 | - break; |
|
886 | - } |
|
887 | - |
|
888 | - }//rof |
|
889 | - return $packages; |
|
890 | - } |
|
891 | - } |
|
804 | + foreach($installeds as $installed) |
|
805 | + { |
|
806 | + $populate = false; |
|
807 | + $filename = from_html($installed->filename); |
|
808 | + $date_entered = $installed->date_entered; |
|
809 | + $type = $installed->type; |
|
810 | + $version = $installed->version; |
|
811 | + $uninstallable = false; |
|
812 | + $link = ""; |
|
813 | + $description = $installed->description; |
|
814 | + $name = $installed->name; |
|
815 | + $enabled = true; |
|
816 | + $enabled_string = 'ENABLED'; |
|
817 | + //if the name is empty then we should try to pull from manifest and populate upgrade_history_table |
|
818 | + if(empty($name)){ |
|
819 | + $populate = true; |
|
820 | + } |
|
821 | + $upgrades_installed++; |
|
822 | + switch($type) |
|
823 | + { |
|
824 | + case "theme": |
|
825 | + case "langpack": |
|
826 | + case "module": |
|
827 | + case "patch": |
|
828 | + if($populate){ |
|
829 | + $manifest_file = $this->extractManifest($filename, $base_tmp_upgrade_dir); |
|
830 | + require_once($manifest_file); |
|
831 | + $GLOBALS['log']->info("Filling in upgrade_history table"); |
|
832 | + $populate = false; |
|
833 | + if( isset( $manifest['name'] ) ){ |
|
834 | + $name = $manifest['name']; |
|
835 | + $installed->name = $name; |
|
836 | + } |
|
837 | + if( isset( $manifest['description'] ) ){ |
|
838 | + $description = $manifest['description']; |
|
839 | + $installed->description = $description; |
|
840 | + } |
|
841 | + if(isset($installdefs) && isset( $installdefs['id'] ) ){ |
|
842 | + $id_name = $installdefs['id']; |
|
843 | + $installed->id_name = $id_name; |
|
844 | + } |
|
845 | + |
|
846 | + $serial_manifest = array(); |
|
847 | + $serial_manifest['manifest'] = (isset($manifest) ? $manifest : ''); |
|
848 | + $serial_manifest['installdefs'] = (isset($installdefs) ? $installdefs : ''); |
|
849 | + $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); |
|
850 | + $installed->manifest = base64_encode(serialize($serial_manifest)); |
|
851 | + $installed->save(); |
|
852 | + }else{ |
|
853 | + $serial_manifest = unserialize(base64_decode($installed->manifest)); |
|
854 | + $manifest = $serial_manifest['manifest']; |
|
855 | + } |
|
856 | + if(($upgrades_installed==0 || $uh->UninstallAvailable($installeds, $installed)) |
|
857 | + && is_file($filename) && !empty($manifest['is_uninstallable'])) |
|
858 | + { |
|
859 | + $uninstallable = true; |
|
860 | + } |
|
861 | + $enabled = $installed->enabled; |
|
862 | + if(!$enabled) |
|
863 | + $enabled_string = 'DISABLED'; |
|
864 | + $file_uninstall = $filename; |
|
865 | + if(!$uninstallable){ |
|
866 | + $file_uninstall = 'UNINSTALLABLE'; |
|
867 | + $enabled_string = 'UNINSTALLABLE'; |
|
868 | + } else { |
|
869 | + $file_uninstall = fileToHash( $file_uninstall ); |
|
870 | + } |
|
871 | + |
|
872 | + $packages[] = array( |
|
873 | + 'name' => $name, |
|
874 | + 'version' => $version, |
|
875 | + 'type' => $type, |
|
876 | + 'published_date' => $date_entered, |
|
877 | + 'description' => $description, |
|
878 | + 'uninstallable' =>$uninstallable, |
|
879 | + 'file_install' => $file_uninstall , |
|
880 | + 'file' => fileToHash($filename), |
|
881 | + 'enabled' => $enabled_string |
|
882 | + ); |
|
883 | + break; |
|
884 | + default: |
|
885 | + break; |
|
886 | + } |
|
887 | + |
|
888 | + }//rof |
|
889 | + return $packages; |
|
890 | + } |
|
891 | + } |
|
892 | 892 | ?> |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | require_once('include/entryPoint.php'); |
50 | 50 | require_once('ModuleInstall/PackageManager/PackageManagerComm.php'); |
51 | 51 | |
52 | -class PackageManager{ |
|
52 | +class PackageManager { |
|
53 | 53 | var $soap_client; |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Constructor: In this method we will initialize the nusoap client to point to the hearbeat server |
57 | 57 | */ |
58 | - function __construct(){ |
|
58 | + function __construct() { |
|
59 | 59 | $this->db = DBManagerFactory::getInstance(); |
60 | 60 | $this->upload_dir = empty($GLOBALS['sugar_config']['upload_dir']) ? 'upload' : rtrim($GLOBALS['sugar_config']['upload_dir'], '/\\'); |
61 | 61 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
65 | 65 | */ |
66 | - function PackageManager(){ |
|
66 | + function PackageManager() { |
|
67 | 67 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
68 | - if(isset($GLOBALS['log'])) { |
|
68 | + if (isset($GLOBALS['log'])) { |
|
69 | 69 | $GLOBALS['log']->deprecated($deprecatedMessage); |
70 | 70 | } |
71 | 71 | else { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | - function initializeComm(){ |
|
78 | + function initializeComm() { |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * Obtain a promotion from SugarDepot |
84 | 84 | * @return string the string from the promotion |
85 | 85 | */ |
86 | - function getPromotion(){ |
|
86 | + function getPromotion() { |
|
87 | 87 | $name_value_list = PackageManagerComm::getPromotion(); |
88 | - if(!empty($name_value_list)){ |
|
88 | + if (!empty($name_value_list)) { |
|
89 | 89 | $name_value_list = PackageManager::fromNameValueList($name_value_list); |
90 | 90 | return $name_value_list['description']; |
91 | - }else { |
|
91 | + } else { |
|
92 | 92 | return ''; |
93 | 93 | } |
94 | 94 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Obtain a list of category/packages/releases for use within the module loader |
98 | 98 | */ |
99 | - function getModuleLoaderCategoryPackages($category_id = ''){ |
|
99 | + function getModuleLoaderCategoryPackages($category_id = '') { |
|
100 | 100 | $filter = array(); |
101 | 101 | $filter = array('type' => "'module', 'theme', 'langpack'"); |
102 | 102 | $filter = PackageManager::toNameValueList($filter); |
@@ -107,34 +107,34 @@ discard block |
||
107 | 107 | * Obtain the list of category_packages from SugarDepot |
108 | 108 | * @return category_packages |
109 | 109 | */ |
110 | - function getCategoryPackages($category_id = '', $filter = array()){ |
|
110 | + function getCategoryPackages($category_id = '', $filter = array()) { |
|
111 | 111 | $results = PackageManagerComm::getCategoryPackages($category_id, $filter); |
112 | 112 | PackageManagerComm::errorCheck(); |
113 | 113 | $nodes = array(); |
114 | 114 | |
115 | 115 | $nodes[$category_id]['packages'] = array(); |
116 | - if(!empty($results['categories'])){ |
|
117 | - foreach($results['categories'] as $category){ |
|
116 | + if (!empty($results['categories'])) { |
|
117 | + foreach ($results['categories'] as $category) { |
|
118 | 118 | $mycat = PackageManager::fromNameValueList($category); |
119 | 119 | $nodes[$mycat['id']] = array('id' => $mycat['id'], 'label' => $mycat['name'], 'description' => $mycat['description'], 'type' => 'cat', 'parent' => $mycat['parent_id']); |
120 | 120 | $nodes[$mycat['id']]['packages'] = array(); |
121 | 121 | } |
122 | 122 | } |
123 | - if(!empty($results['packages'])){ |
|
123 | + if (!empty($results['packages'])) { |
|
124 | 124 | $uh = new UpgradeHistory(); |
125 | - foreach($results['packages'] as $package){ |
|
125 | + foreach ($results['packages'] as $package) { |
|
126 | 126 | $mypack = PackageManager::fromNameValueList($package); |
127 | 127 | $nodes[$mypack['category_id']]['packages'][$mypack['id']] = array('id' => $mypack['id'], 'label' => $mypack['name'], 'description' => $mypack['description'], 'category_id' => $mypack['category_id'], 'type' => 'package'); |
128 | 128 | $releases = PackageManager::getReleases($category_id, $mypack['id'], $filter); |
129 | 129 | $arr_releases = array(); |
130 | 130 | $nodes[$mypack['category_id']]['packages'][$mypack['id']]['releases'] = array(); |
131 | - if(!empty($releases['packages'])){ |
|
132 | - foreach($releases['packages'] as $release){ |
|
131 | + if (!empty($releases['packages'])) { |
|
132 | + foreach ($releases['packages'] as $release) { |
|
133 | 133 | $myrelease = PackageManager::fromNameValueList($release); |
134 | 134 | //check to see if we already this one installed |
135 | 135 | $result = $uh->determineIfUpgrade($myrelease['id_name'], $myrelease['version']); |
136 | 136 | $enable = false; |
137 | - if($result == true || is_array($result)) |
|
137 | + if ($result == true || is_array($result)) |
|
138 | 138 | $enable = true; |
139 | 139 | $nodes[$mypack['category_id']]['packages'][$mypack['id']]['releases'][$myrelease['id']] = array('id' => $myrelease['id'], 'version' => $myrelease['version'], 'label' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id'], 'type' => 'release', 'enable' => $enable); |
140 | 140 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | //array_push($nodes[$mypack['category_id']]['packages'], $package_arr); |
143 | 143 | } |
144 | 144 | } |
145 | - $GLOBALS['log']->debug("NODES". var_export($nodes, true)); |
|
145 | + $GLOBALS['log']->debug("NODES".var_export($nodes, true)); |
|
146 | 146 | return $nodes; |
147 | 147 | } |
148 | 148 | |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @param filter an array of filters to pass to limit the query |
153 | 153 | * @return array an array of categories for display on the client |
154 | 154 | */ |
155 | - function getCategories($category_id, $filter = array()){ |
|
155 | + function getCategories($category_id, $filter = array()) { |
|
156 | 156 | $nodes = array(); |
157 | 157 | $results = PackageManagerComm::getCategories($category_id, $filter); |
158 | 158 | PackageManagerComm::errorCheck(); |
159 | - if(!empty($results['categories'])){ |
|
160 | - foreach($results['categories'] as $category){ |
|
159 | + if (!empty($results['categories'])) { |
|
160 | + foreach ($results['categories'] as $category) { |
|
161 | 161 | $mycat = PackageManager::fromNameValueList($category); |
162 | 162 | $nodes[] = array('id' => $mycat['id'], 'label' => $mycat['name'], 'description' => $mycat['description'], 'type' => 'cat', 'parent' => $mycat['parent_id']); |
163 | 163 | } |
@@ -165,22 +165,22 @@ discard block |
||
165 | 165 | return $nodes; |
166 | 166 | } |
167 | 167 | |
168 | - function getPackages($category_id, $filter = array()){ |
|
168 | + function getPackages($category_id, $filter = array()) { |
|
169 | 169 | $nodes = array(); |
170 | 170 | $results = PackageManagerComm::getPackages($category_id, $filter); |
171 | 171 | PackageManagerComm::errorCheck(); |
172 | 172 | $packages = array(); |
173 | 173 | //$xml = ''; |
174 | 174 | //$xml .= '<packages>'; |
175 | - if(!empty($results['packages'])){ |
|
176 | - foreach($results['packages'] as $package){ |
|
175 | + if (!empty($results['packages'])) { |
|
176 | + foreach ($results['packages'] as $package) { |
|
177 | 177 | $mypack = PackageManager::fromNameValueList($package); |
178 | 178 | $packages[$mypack['id']] = array('package_id' => $mypack['id'], 'name' => $mypack['name'], 'description' => $mypack['description'], 'category_id' => $mypack['category_id']); |
179 | 179 | $releases = PackageManager::getReleases($category_id, $mypack['id']); |
180 | 180 | $arr_releases = array(); |
181 | - foreach($releases['packages'] as $release){ |
|
181 | + foreach ($releases['packages'] as $release) { |
|
182 | 182 | $myrelease = PackageManager::fromNameValueList($release); |
183 | - $arr_releases[$myrelease['id']] = array('release_id' => $myrelease['id'], 'version' => $myrelease['version'], 'description' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id']); |
|
183 | + $arr_releases[$myrelease['id']] = array('release_id' => $myrelease['id'], 'version' => $myrelease['version'], 'description' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id']); |
|
184 | 184 | } |
185 | 185 | $packages[$mypack['id']]['releases'] = $arr_releases; |
186 | 186 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | return $packages; |
189 | 189 | } |
190 | 190 | |
191 | - function getReleases($category_id, $package_id, $filter = array()){ |
|
191 | + function getReleases($category_id, $package_id, $filter = array()) { |
|
192 | 192 | $releases = PackageManagerComm::getReleases($category_id, $package_id, $filter); |
193 | 193 | PackageManagerComm::errorCheck(); |
194 | 194 | return $releases; |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | public function download($category_id, $package_id, $release_id) |
206 | 206 | { |
207 | 207 | $GLOBALS['log']->debug('RELEASE _ID: '.$release_id); |
208 | - if(!empty($release_id)){ |
|
208 | + if (!empty($release_id)) { |
|
209 | 209 | $filename = PackageManagerComm::addDownload($category_id, $package_id, $release_id); |
210 | - if($filename){ |
|
210 | + if ($filename) { |
|
211 | 211 | $GLOBALS['log']->debug('RESULT: '.$filename); |
212 | 212 | PackageManagerComm::errorCheck(); |
213 | 213 | $filepath = PackageManagerComm::performDownload($filename); |
214 | 214 | return $filepath; |
215 | 215 | } |
216 | - }else{ |
|
216 | + } else { |
|
217 | 217 | return null; |
218 | 218 | } |
219 | 219 | } |
@@ -227,28 +227,28 @@ discard block |
||
227 | 227 | * @param systemname the user's download key |
228 | 228 | * @return true if successful, false otherwise |
229 | 229 | */ |
230 | - function authenticate($username, $password, $systemname='', $terms_checked = true){ |
|
230 | + function authenticate($username, $password, $systemname = '', $terms_checked = true) { |
|
231 | 231 | PackageManager::setCredentials($username, $password, $systemname); |
232 | 232 | PackageManagerComm::clearSession(); |
233 | 233 | $result = PackageManagerComm::login($terms_checked); |
234 | - if(is_array($result)) |
|
234 | + if (is_array($result)) |
|
235 | 235 | return $result; |
236 | 236 | else |
237 | 237 | return true; |
238 | 238 | } |
239 | 239 | |
240 | - function setCredentials($username, $password, $systemname){ |
|
240 | + function setCredentials($username, $password, $systemname) { |
|
241 | 241 | |
242 | 242 | $admin = new Administration(); |
243 | 243 | $admin->retrieveSettings(); |
244 | 244 | $admin->saveSetting(CREDENTIAL_CATEGORY, CREDENTIAL_USERNAME, $username); |
245 | 245 | $admin->saveSetting(CREDENTIAL_CATEGORY, CREDENTIAL_PASSWORD, $password); |
246 | - if(!empty($systemname)){ |
|
246 | + if (!empty($systemname)) { |
|
247 | 247 | $admin->saveSetting('system', 'name', $systemname); |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - static function getCredentials(){ |
|
251 | + static function getCredentials() { |
|
252 | 252 | |
253 | 253 | $admin = new Administration(); |
254 | 254 | $admin->retrieveSettings(CREDENTIAL_CATEGORY, true); |
@@ -256,19 +256,19 @@ discard block |
||
256 | 256 | $credentials['username'] = ''; |
257 | 257 | $credentials['password'] = ''; |
258 | 258 | $credentials['system_name'] = ''; |
259 | - if(!empty($admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME])){ |
|
259 | + if (!empty($admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME])) { |
|
260 | 260 | $credentials['username'] = $admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME]; |
261 | 261 | } |
262 | - if(!empty($admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME])){ |
|
262 | + if (!empty($admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_USERNAME])) { |
|
263 | 263 | $credentials['password'] = $admin->settings[CREDENTIAL_CATEGORY.'_'.CREDENTIAL_PASSWORD]; |
264 | 264 | } |
265 | - if(!empty($admin->settings['system_name'])){ |
|
265 | + if (!empty($admin->settings['system_name'])) { |
|
266 | 266 | $credentials['system_name'] = $admin->settings['system_name']; |
267 | 267 | } |
268 | 268 | return $credentials; |
269 | 269 | } |
270 | 270 | |
271 | - function getTermsAndConditions(){ |
|
271 | + function getTermsAndConditions() { |
|
272 | 272 | return PackageManagerComm::getTermsAndConditions(); |
273 | 273 | |
274 | 274 | } |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return documents |
283 | 283 | */ |
284 | - function getDocumentation($package_id, $release_id){ |
|
285 | - if(!empty($release_id) || !empty($package_id)){ |
|
284 | + function getDocumentation($package_id, $release_id) { |
|
285 | + if (!empty($release_id) || !empty($package_id)) { |
|
286 | 286 | $documents = PackageManagerComm::getDocumentation($package_id, $release_id); |
287 | 287 | return $documents; |
288 | - }else{ |
|
288 | + } else { |
|
289 | 289 | return null; |
290 | 290 | } |
291 | 291 | } |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | * Grab the list of installed modules and send that list to the depot. |
295 | 295 | * The depot will then send back a list of modules that need to be updated |
296 | 296 | */ |
297 | - function checkForUpdates(){ |
|
297 | + function checkForUpdates() { |
|
298 | 298 | $lists = $this->buildInstalledReleases(array('module'), true); |
299 | 299 | $updates = array(); |
300 | - if(!empty($lists)){ |
|
300 | + if (!empty($lists)) { |
|
301 | 301 | $updates = PackageManagerComm::checkForUpdates($lists); |
302 | 302 | }//fi |
303 | 303 | return $updates; |
@@ -305,54 +305,54 @@ discard block |
||
305 | 305 | |
306 | 306 | //////////////////////////////////////////////////////// |
307 | 307 | /////////// HELPER FUNCTIONS |
308 | - function toNameValueList($array){ |
|
308 | + function toNameValueList($array) { |
|
309 | 309 | $list = array(); |
310 | - foreach($array as $name=>$value){ |
|
310 | + foreach ($array as $name=>$value) { |
|
311 | 311 | $list[] = array('name'=>$name, 'value'=>$value); |
312 | 312 | } |
313 | 313 | return $list; |
314 | 314 | } |
315 | 315 | |
316 | - function toNameValueLists($arrays){ |
|
316 | + function toNameValueLists($arrays) { |
|
317 | 317 | $lists = array(); |
318 | - foreach($arrays as $array){ |
|
318 | + foreach ($arrays as $array) { |
|
319 | 319 | $lists[] = PackageManager::toNameValueList($array); |
320 | 320 | } |
321 | 321 | return $lists; |
322 | 322 | } |
323 | 323 | |
324 | - function fromNameValueList($nvl){ |
|
324 | + function fromNameValueList($nvl) { |
|
325 | 325 | $array = array(); |
326 | - foreach($nvl as $list){ |
|
326 | + foreach ($nvl as $list) { |
|
327 | 327 | $array[$list['name']] = $list['value']; |
328 | 328 | } |
329 | 329 | return $array; |
330 | 330 | } |
331 | 331 | |
332 | - function buildInstalledReleases($types = array('module')){ |
|
332 | + function buildInstalledReleases($types = array('module')) { |
|
333 | 333 | //1) get list of installed modules |
334 | 334 | $installeds = $this->getInstalled($types); |
335 | 335 | $releases = array(); |
336 | - foreach($installeds as $installed){ |
|
336 | + foreach ($installeds as $installed) { |
|
337 | 337 | $releases[] = array('name' => $installed->name, 'id_name' => $installed->id_name, 'version' => $installed->version, 'filename' => $installed->filename, 'type' => $installed->type); |
338 | 338 | } |
339 | 339 | |
340 | 340 | $lists = array(); |
341 | 341 | $name_value_list = array(); |
342 | - if(!empty($releases)){ |
|
342 | + if (!empty($releases)) { |
|
343 | 343 | $lists = $this->toNameValueLists($releases); |
344 | 344 | }//fi |
345 | 345 | return $lists; |
346 | 346 | } |
347 | 347 | |
348 | - function buildPackageXML($package, $releases = array()){ |
|
348 | + function buildPackageXML($package, $releases = array()) { |
|
349 | 349 | $xml = '<package>'; |
350 | 350 | $xml .= '<package_id>'.$package['id'].'</package_id>'; |
351 | 351 | $xml .= '<name>'.$package['name'].'</name>'; |
352 | 352 | $xml .= '<description>'.$package['description'].'</description>'; |
353 | - if(!empty($releases)){ |
|
353 | + if (!empty($releases)) { |
|
354 | 354 | $xml .= '<releases>'; |
355 | - foreach($releases['packages'] as $release){ |
|
355 | + foreach ($releases['packages'] as $release) { |
|
356 | 356 | |
357 | 357 | $myrelease = PackageManager::fromNameValueList($release); |
358 | 358 | $xml .= '<release>'; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | private function addToCleanup($dir) |
375 | 375 | { |
376 | - if(empty($this->cleanUpDirs)) { |
|
376 | + if (empty($this->cleanUpDirs)) { |
|
377 | 377 | register_shutdown_function(array($this, "cleanUpTempDir")); |
378 | 378 | } |
379 | 379 | $this->cleanUpDirs[] = $dir; |
@@ -381,155 +381,155 @@ discard block |
||
381 | 381 | |
382 | 382 | public function cleanUpTempDir() |
383 | 383 | { |
384 | - foreach($this->cleanUpDirs as $dir) { |
|
384 | + foreach ($this->cleanUpDirs as $dir) { |
|
385 | 385 | rmdir_recursive($dir); |
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | 389 | ////////////////////////////////////////////////////////////////////// |
390 | 390 | /////////// INSTALL SECTION |
391 | - function extractFile( $zip_file, $file_in_zip, $base_tmp_upgrade_dir){ |
|
392 | - $my_zip_dir = mk_temp_dir( $base_tmp_upgrade_dir ); |
|
391 | + function extractFile($zip_file, $file_in_zip, $base_tmp_upgrade_dir) { |
|
392 | + $my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir); |
|
393 | 393 | $this->addToCleanup($my_zip_dir); |
394 | - unzip_file( $zip_file, $file_in_zip, $my_zip_dir ); |
|
395 | - return( "$my_zip_dir/$file_in_zip" ); |
|
394 | + unzip_file($zip_file, $file_in_zip, $my_zip_dir); |
|
395 | + return("$my_zip_dir/$file_in_zip"); |
|
396 | 396 | } |
397 | 397 | |
398 | - function extractManifest( $zip_file,$base_tmp_upgrade_dir ) { |
|
398 | + function extractManifest($zip_file, $base_tmp_upgrade_dir) { |
|
399 | 399 | global $sugar_config; |
400 | 400 | $base_upgrade_dir = $this->upload_dir."/upgrades"; |
401 | 401 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
402 | - return $this->extractFile( $zip_file, "manifest.php",$base_tmp_upgrade_dir ); |
|
402 | + return $this->extractFile($zip_file, "manifest.php", $base_tmp_upgrade_dir); |
|
403 | 403 | } |
404 | 404 | |
405 | - function validate_manifest( $manifest ){ |
|
405 | + function validate_manifest($manifest) { |
|
406 | 406 | // takes a manifest.php manifest array and validates contents |
407 | 407 | global $subdirs; |
408 | 408 | global $sugar_version; |
409 | 409 | global $sugar_flavor; |
410 | 410 | global $mod_strings; |
411 | 411 | |
412 | - if( !isset($manifest['type']) ){ |
|
412 | + if (!isset($manifest['type'])) { |
|
413 | 413 | die($mod_strings['ERROR_MANIFEST_TYPE']); |
414 | 414 | } |
415 | 415 | $type = $manifest['type']; |
416 | 416 | $GLOBALS['log']->debug("Getting InstallType"); |
417 | - if( $this->getInstallType( "/$type/" ) == "" ){ |
|
417 | + if ($this->getInstallType("/$type/") == "") { |
|
418 | 418 | $GLOBALS['log']->debug("Error with InstallType".$type); |
419 | - die($mod_strings['ERROR_PACKAGE_TYPE']. ": '" . $type . "'." ); |
|
419 | + die($mod_strings['ERROR_PACKAGE_TYPE'].": '".$type."'."); |
|
420 | 420 | } |
421 | 421 | $GLOBALS['log']->debug("Passed with InstallType"); |
422 | - if( isset($manifest['acceptable_sugar_versions']) ){ |
|
422 | + if (isset($manifest['acceptable_sugar_versions'])) { |
|
423 | 423 | $version_ok = false; |
424 | 424 | $matches_empty = true; |
425 | - if( isset($manifest['acceptable_sugar_versions']['exact_matches']) ){ |
|
425 | + if (isset($manifest['acceptable_sugar_versions']['exact_matches'])) { |
|
426 | 426 | $matches_empty = false; |
427 | - foreach( $manifest['acceptable_sugar_versions']['exact_matches'] as $match ){ |
|
428 | - if( $match == $sugar_version ){ |
|
427 | + foreach ($manifest['acceptable_sugar_versions']['exact_matches'] as $match) { |
|
428 | + if ($match == $sugar_version) { |
|
429 | 429 | $version_ok = true; |
430 | 430 | } |
431 | 431 | } |
432 | 432 | } |
433 | - if( !$version_ok && isset($manifest['acceptable_sugar_versions']['regex_matches']) ){ |
|
433 | + if (!$version_ok && isset($manifest['acceptable_sugar_versions']['regex_matches'])) { |
|
434 | 434 | $matches_empty = false; |
435 | - foreach( $manifest['acceptable_sugar_versions']['regex_matches'] as $match ){ |
|
436 | - if( preg_match( "/$match/", $sugar_version ) ){ |
|
435 | + foreach ($manifest['acceptable_sugar_versions']['regex_matches'] as $match) { |
|
436 | + if (preg_match("/$match/", $sugar_version)) { |
|
437 | 437 | $version_ok = true; |
438 | 438 | } |
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
442 | - if( !$matches_empty && !$version_ok ){ |
|
443 | - die( $mod_strings['ERROR_VERSION_INCOMPATIBLE'] . $sugar_version ); |
|
442 | + if (!$matches_empty && !$version_ok) { |
|
443 | + die($mod_strings['ERROR_VERSION_INCOMPATIBLE'].$sugar_version); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - if( isset($manifest['acceptable_sugar_flavors']) && sizeof($manifest['acceptable_sugar_flavors']) > 0 ){ |
|
447 | + if (isset($manifest['acceptable_sugar_flavors']) && sizeof($manifest['acceptable_sugar_flavors']) > 0) { |
|
448 | 448 | $flavor_ok = false; |
449 | - foreach( $manifest['acceptable_sugar_flavors'] as $match ){ |
|
450 | - if( $match == $sugar_flavor ){ |
|
449 | + foreach ($manifest['acceptable_sugar_flavors'] as $match) { |
|
450 | + if ($match == $sugar_flavor) { |
|
451 | 451 | $flavor_ok = true; |
452 | 452 | } |
453 | 453 | } |
454 | - if( !$flavor_ok ){ |
|
454 | + if (!$flavor_ok) { |
|
455 | 455 | //die( $mod_strings['ERROR_FLAVOR_INCOMPATIBLE'] . $sugar_flavor ); |
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | - function getInstallType( $type_string ){ |
|
460 | + function getInstallType($type_string) { |
|
461 | 461 | // detect file type |
462 | 462 | global $subdirs; |
463 | 463 | $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); |
464 | 464 | |
465 | 465 | |
466 | - foreach( $subdirs as $subdir ){ |
|
467 | - if( preg_match( "#/$subdir/#", $type_string ) ){ |
|
468 | - return( $subdir ); |
|
466 | + foreach ($subdirs as $subdir) { |
|
467 | + if (preg_match("#/$subdir/#", $type_string)) { |
|
468 | + return($subdir); |
|
469 | 469 | } |
470 | 470 | } |
471 | 471 | // return empty if no match |
472 | - return( "" ); |
|
472 | + return(""); |
|
473 | 473 | } |
474 | 474 | |
475 | - function performSetup($tempFile, $view = 'module', $display_messages = true){ |
|
476 | - global $sugar_config,$mod_strings; |
|
475 | + function performSetup($tempFile, $view = 'module', $display_messages = true) { |
|
476 | + global $sugar_config, $mod_strings; |
|
477 | 477 | $base_filename = urldecode($tempFile); |
478 | 478 | $GLOBALS['log']->debug("BaseFileName: ".$base_filename); |
479 | 479 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
480 | 480 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
481 | - $manifest_file = $this->extractManifest( $base_filename,$base_tmp_upgrade_dir); |
|
481 | + $manifest_file = $this->extractManifest($base_filename, $base_tmp_upgrade_dir); |
|
482 | 482 | $GLOBALS['log']->debug("Manifest: ".$manifest_file); |
483 | - if($view == 'module') |
|
483 | + if ($view == 'module') |
|
484 | 484 | $license_file = $this->extractFile($base_filename, 'LICENSE.txt', $base_tmp_upgrade_dir); |
485 | - if(is_file($manifest_file)){ |
|
486 | - $GLOBALS['log']->debug("VALIDATING MANIFEST". $manifest_file); |
|
487 | - require_once( $manifest_file ); |
|
488 | - $this->validate_manifest($manifest ); |
|
485 | + if (is_file($manifest_file)) { |
|
486 | + $GLOBALS['log']->debug("VALIDATING MANIFEST".$manifest_file); |
|
487 | + require_once($manifest_file); |
|
488 | + $this->validate_manifest($manifest); |
|
489 | 489 | $upgrade_zip_type = $manifest['type']; |
490 | 490 | $GLOBALS['log']->debug("VALIDATED MANIFEST"); |
491 | 491 | // exclude the bad permutations |
492 | - if( $view == "module" ){ |
|
493 | - if ($upgrade_zip_type != "module" && $upgrade_zip_type != "theme" && $upgrade_zip_type != "langpack"){ |
|
492 | + if ($view == "module") { |
|
493 | + if ($upgrade_zip_type != "module" && $upgrade_zip_type != "theme" && $upgrade_zip_type != "langpack") { |
|
494 | 494 | $this->unlinkTempFiles(); |
495 | - if($display_messages) |
|
495 | + if ($display_messages) |
|
496 | 496 | die($mod_strings['ERR_UW_NOT_ACCEPTIBLE_TYPE']); |
497 | 497 | } |
498 | - }elseif( $view == "default" ){ |
|
499 | - if($upgrade_zip_type != "patch" ){ |
|
498 | + }elseif ($view == "default") { |
|
499 | + if ($upgrade_zip_type != "patch") { |
|
500 | 500 | $this->unlinkTempFiles(); |
501 | - if($display_messages) |
|
501 | + if ($display_messages) |
|
502 | 502 | die($mod_strings['ERR_UW_ONLY_PATCHES']); |
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | - $base_filename = preg_replace( "#\\\\#", "/", $base_filename ); |
|
507 | - $base_filename = basename( $base_filename ); |
|
508 | - mkdir_recursive( "$base_upgrade_dir/$upgrade_zip_type" ); |
|
506 | + $base_filename = preg_replace("#\\\\#", "/", $base_filename); |
|
507 | + $base_filename = basename($base_filename); |
|
508 | + mkdir_recursive("$base_upgrade_dir/$upgrade_zip_type"); |
|
509 | 509 | $target_path = "$base_upgrade_dir/$upgrade_zip_type/$base_filename"; |
510 | - $target_manifest = remove_file_extension( $target_path ) . "-manifest.php"; |
|
510 | + $target_manifest = remove_file_extension($target_path)."-manifest.php"; |
|
511 | 511 | |
512 | - if( isset($manifest['icon']) && $manifest['icon'] != "" ){ |
|
513 | - $icon_location = $this->extractFile( $tempFile ,$manifest['icon'], $base_tmp_upgrade_dir ); |
|
514 | - $path_parts = pathinfo( $icon_location ); |
|
515 | - copy( $icon_location, remove_file_extension( $target_path ) . "-icon." . $path_parts['extension'] ); |
|
512 | + if (isset($manifest['icon']) && $manifest['icon'] != "") { |
|
513 | + $icon_location = $this->extractFile($tempFile, $manifest['icon'], $base_tmp_upgrade_dir); |
|
514 | + $path_parts = pathinfo($icon_location); |
|
515 | + copy($icon_location, remove_file_extension($target_path)."-icon.".$path_parts['extension']); |
|
516 | 516 | } |
517 | 517 | |
518 | - if( copy( $tempFile , $target_path ) ){ |
|
519 | - copy( $manifest_file, $target_manifest ); |
|
520 | - if($display_messages) |
|
521 | - $messages = '<script>ajaxStatus.flashStatus("' .$base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS'] . ', 5000");</script>'; |
|
522 | - }else{ |
|
523 | - if($display_messages) |
|
524 | - $messages = '<script>ajaxStatus.flashStatus("' .$mod_strings['ERR_UW_UPLOAD_ERROR'] . ', 5000");</script>'; |
|
518 | + if (copy($tempFile, $target_path)) { |
|
519 | + copy($manifest_file, $target_manifest); |
|
520 | + if ($display_messages) |
|
521 | + $messages = '<script>ajaxStatus.flashStatus("'.$base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS'].', 5000");</script>'; |
|
522 | + } else { |
|
523 | + if ($display_messages) |
|
524 | + $messages = '<script>ajaxStatus.flashStatus("'.$mod_strings['ERR_UW_UPLOAD_ERROR'].', 5000");</script>'; |
|
525 | 525 | } |
526 | 526 | }//fi |
527 | - else{ |
|
527 | + else { |
|
528 | 528 | $this->unlinkTempFiles(); |
529 | - if($display_messages) |
|
529 | + if ($display_messages) |
|
530 | 530 | die($mod_strings['ERR_UW_NO_MANIFEST']); |
531 | 531 | } |
532 | - if(isset($messages)) |
|
532 | + if (isset($messages)) |
|
533 | 533 | return $messages; |
534 | 534 | } |
535 | 535 | |
@@ -539,13 +539,13 @@ discard block |
||
539 | 539 | @unlink("upload://".$_FILES['upgrade_zip']['name']); |
540 | 540 | } |
541 | 541 | |
542 | - function performInstall($file, $silent=true){ |
|
542 | + function performInstall($file, $silent = true) { |
|
543 | 543 | global $sugar_config; |
544 | 544 | global $mod_strings; |
545 | 545 | global $current_language; |
546 | 546 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
547 | 547 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
548 | - if(!file_exists($base_tmp_upgrade_dir)){ |
|
548 | + if (!file_exists($base_tmp_upgrade_dir)) { |
|
549 | 549 | mkdir_recursive($base_tmp_upgrade_dir, true); |
550 | 550 | } |
551 | 551 | |
@@ -554,28 +554,28 @@ discard block |
||
554 | 554 | $mi->silent = $silent; |
555 | 555 | $mod_strings = return_module_language($current_language, "Administration"); |
556 | 556 | $GLOBALS['log']->debug("ABOUT TO INSTALL: ".$file); |
557 | - if(preg_match("#.*\.zip\$#", $file)) { |
|
557 | + if (preg_match("#.*\.zip\$#", $file)) { |
|
558 | 558 | $GLOBALS['log']->debug("1: ".$file); |
559 | 559 | // handle manifest.php |
560 | - $target_manifest = remove_file_extension( $file ) . '-manifest.php'; |
|
560 | + $target_manifest = remove_file_extension($file).'-manifest.php'; |
|
561 | 561 | include($target_manifest); |
562 | 562 | $GLOBALS['log']->debug("2: ".$file); |
563 | - $unzip_dir = mk_temp_dir( $base_tmp_upgrade_dir ); |
|
563 | + $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir); |
|
564 | 564 | $this->addToCleanup($unzip_dir); |
565 | - unzip($file, $unzip_dir ); |
|
565 | + unzip($file, $unzip_dir); |
|
566 | 566 | $GLOBALS['log']->debug("3: ".$unzip_dir); |
567 | 567 | $id_name = $installdefs['id']; |
568 | 568 | $version = $manifest['version']; |
569 | 569 | $uh = new UpgradeHistory(); |
570 | 570 | $previous_install = array(); |
571 | - if(!empty($id_name) & !empty($version)) |
|
571 | + if (!empty($id_name) & !empty($version)) |
|
572 | 572 | $previous_install = $uh->determineIfUpgrade($id_name, $version); |
573 | 573 | $previous_version = (empty($previous_install['version'])) ? '' : $previous_install['version']; |
574 | 574 | $previous_id = (empty($previous_install['id'])) ? '' : $previous_install['id']; |
575 | 575 | |
576 | - if(!empty($previous_version)){ |
|
576 | + if (!empty($previous_version)) { |
|
577 | 577 | $mi->install($unzip_dir, true, $previous_version); |
578 | - }else{ |
|
578 | + } else { |
|
579 | 579 | $mi->install($unzip_dir); |
580 | 580 | } |
581 | 581 | $GLOBALS['log']->debug("INSTALLED: ".$file); |
@@ -593,100 +593,100 @@ discard block |
||
593 | 593 | $serial_manifest['manifest'] = (isset($manifest) ? $manifest : ''); |
594 | 594 | $serial_manifest['installdefs'] = (isset($installdefs) ? $installdefs : ''); |
595 | 595 | $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); |
596 | - $new_upgrade->manifest = base64_encode(serialize($serial_manifest)); |
|
596 | + $new_upgrade->manifest = base64_encode(serialize($serial_manifest)); |
|
597 | 597 | //$new_upgrade->unique_key = (isset($manifest['unique_key'])) ? $manifest['unique_key'] : ''; |
598 | 598 | $new_upgrade->save(); |
599 | 599 | //unlink($file); |
600 | 600 | }//fi |
601 | 601 | } |
602 | 602 | |
603 | - function performUninstall($name){ |
|
603 | + function performUninstall($name) { |
|
604 | 604 | $uh = new UpgradeHistory(); |
605 | 605 | $uh->name = $name; |
606 | 606 | $uh->id_name = $name; |
607 | 607 | $found = $uh->checkForExisting($uh); |
608 | - if($found != null){ |
|
608 | + if ($found != null) { |
|
609 | 609 | global $sugar_config; |
610 | 610 | global $mod_strings; |
611 | 611 | global $current_language; |
612 | 612 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
613 | 613 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
614 | - if(is_file($found->filename)){ |
|
615 | - if(!isset($GLOBALS['mi_remove_tables']))$GLOBALS['mi_remove_tables'] = true; |
|
616 | - $unzip_dir = mk_temp_dir( $base_tmp_upgrade_dir ); |
|
617 | - unzip($found->filename, $unzip_dir ); |
|
614 | + if (is_file($found->filename)) { |
|
615 | + if (!isset($GLOBALS['mi_remove_tables']))$GLOBALS['mi_remove_tables'] = true; |
|
616 | + $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir); |
|
617 | + unzip($found->filename, $unzip_dir); |
|
618 | 618 | $mi = new ModuleInstaller(); |
619 | 619 | $mi->silent = true; |
620 | - $mi->uninstall( "$unzip_dir"); |
|
620 | + $mi->uninstall("$unzip_dir"); |
|
621 | 621 | $found->delete(); |
622 | - unlink(remove_file_extension( $found->filename ) . '-manifest.php'); |
|
622 | + unlink(remove_file_extension($found->filename).'-manifest.php'); |
|
623 | 623 | unlink($found->filename); |
624 | - }else{ |
|
624 | + } else { |
|
625 | 625 | //file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem |
626 | 626 | $found->delete(); |
627 | 627 | } |
628 | 628 | } |
629 | 629 | } |
630 | 630 | |
631 | - function getUITextForType( $type ){ |
|
632 | - if( $type == "full" ){ |
|
633 | - return( "Full Upgrade" ); |
|
631 | + function getUITextForType($type) { |
|
632 | + if ($type == "full") { |
|
633 | + return("Full Upgrade"); |
|
634 | 634 | } |
635 | - if( $type == "langpack" ){ |
|
636 | - return( "Language Pack" ); |
|
635 | + if ($type == "langpack") { |
|
636 | + return("Language Pack"); |
|
637 | 637 | } |
638 | - if( $type == "module" ){ |
|
639 | - return( "Module" ); |
|
638 | + if ($type == "module") { |
|
639 | + return("Module"); |
|
640 | 640 | } |
641 | - if( $type == "patch" ){ |
|
642 | - return( "Patch" ); |
|
641 | + if ($type == "patch") { |
|
642 | + return("Patch"); |
|
643 | 643 | } |
644 | - if( $type == "theme" ){ |
|
645 | - return( "Theme" ); |
|
644 | + if ($type == "theme") { |
|
645 | + return("Theme"); |
|
646 | 646 | } |
647 | 647 | } |
648 | 648 | |
649 | - function getImageForType( $type ){ |
|
649 | + function getImageForType($type) { |
|
650 | 650 | |
651 | 651 | $icon = ""; |
652 | - switch( $type ){ |
|
652 | + switch ($type) { |
|
653 | 653 | case "full": |
654 | - $icon = SugarThemeRegistry::current()->getImage("Upgrade", "" ,null,null,'.gif', "Upgrade"); |
|
654 | + $icon = SugarThemeRegistry::current()->getImage("Upgrade", "", null, null, '.gif', "Upgrade"); |
|
655 | 655 | |
656 | 656 | break; |
657 | 657 | case "langpack": |
658 | - $icon = SugarThemeRegistry::current()->getImage("LanguagePacks", "",null,null,'.gif',"Language Packs" ); |
|
658 | + $icon = SugarThemeRegistry::current()->getImage("LanguagePacks", "", null, null, '.gif', "Language Packs"); |
|
659 | 659 | |
660 | 660 | break; |
661 | 661 | case "module": |
662 | - $icon = SugarThemeRegistry::current()->getImage("ModuleLoader", "" ,null,null,'.gif', "Module Loader"); |
|
662 | + $icon = SugarThemeRegistry::current()->getImage("ModuleLoader", "", null, null, '.gif', "Module Loader"); |
|
663 | 663 | |
664 | 664 | break; |
665 | 665 | case "patch": |
666 | - $icon = SugarThemeRegistry::current()->getImage("PatchUpgrades", "",null,null,'.gif', "Patch Upgrades" ); |
|
666 | + $icon = SugarThemeRegistry::current()->getImage("PatchUpgrades", "", null, null, '.gif', "Patch Upgrades"); |
|
667 | 667 | |
668 | 668 | break; |
669 | 669 | case "theme": |
670 | - $icon = SugarThemeRegistry::current()->getImage("Themes", "",null,null,'.gif', "Themes" ); |
|
670 | + $icon = SugarThemeRegistry::current()->getImage("Themes", "", null, null, '.gif', "Themes"); |
|
671 | 671 | |
672 | 672 | break; |
673 | 673 | default: |
674 | 674 | break; |
675 | 675 | } |
676 | - return( $icon ); |
|
676 | + return($icon); |
|
677 | 677 | } |
678 | 678 | |
679 | - function getPackagesInStaging($view = 'module'){ |
|
679 | + function getPackagesInStaging($view = 'module') { |
|
680 | 680 | global $sugar_config; |
681 | 681 | global $current_language; |
682 | 682 | $uh = new UpgradeHistory(); |
683 | - $base_upgrade_dir = "upload://upgrades"; |
|
684 | - $uContent = findAllFiles( $base_upgrade_dir, array() , false, 'zip'); |
|
683 | + $base_upgrade_dir = "upload://upgrades"; |
|
684 | + $uContent = findAllFiles($base_upgrade_dir, array(), false, 'zip'); |
|
685 | 685 | $upgrade_contents = array(); |
686 | 686 | $content_values = array_values($uContent); |
687 | 687 | $alreadyProcessed = array(); |
688 | - foreach($content_values as $val){ |
|
689 | - if(empty($alreadyProcessed[$val])){ |
|
688 | + foreach ($content_values as $val) { |
|
689 | + if (empty($alreadyProcessed[$val])) { |
|
690 | 690 | $upgrade_contents[] = $val; |
691 | 691 | $alreadyProcessed[$val] = true; |
692 | 692 | } |
@@ -695,8 +695,8 @@ discard block |
||
695 | 695 | $upgrades_available = 0; |
696 | 696 | $packages = array(); |
697 | 697 | $mod_strings = return_module_language($current_language, "Administration"); |
698 | - foreach($upgrade_contents as $upgrade_content) { |
|
699 | - if(!preg_match('#.*\.zip$#', strtolower($upgrade_content)) || preg_match("#.*./zips/.*#", strtolower($upgrade_content))) { |
|
698 | + foreach ($upgrade_contents as $upgrade_content) { |
|
699 | + if (!preg_match('#.*\.zip$#', strtolower($upgrade_content)) || preg_match("#.*./zips/.*#", strtolower($upgrade_content))) { |
|
700 | 700 | continue; |
701 | 701 | } |
702 | 702 | |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | $the_md5 = md5_file($upgrade_content); |
705 | 705 | $md5_matches = $uh->findByMd5($the_md5); |
706 | 706 | $file_install = $upgrade_content; |
707 | - if(empty($md5_matches)) |
|
707 | + if (empty($md5_matches)) |
|
708 | 708 | { |
709 | - $target_manifest = remove_file_extension( $upgrade_content ) . '-manifest.php'; |
|
710 | - if(file_exists($target_manifest)) { |
|
709 | + $target_manifest = remove_file_extension($upgrade_content).'-manifest.php'; |
|
710 | + if (file_exists($target_manifest)) { |
|
711 | 711 | require_once($target_manifest); |
712 | 712 | |
713 | 713 | $name = empty($manifest['name']) ? $upgrade_content : $manifest['name']; |
@@ -716,37 +716,37 @@ discard block |
||
716 | 716 | $icon = ''; |
717 | 717 | $description = empty($manifest['description']) ? 'None' : $manifest['description']; |
718 | 718 | $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; |
719 | - $type = $this->getUITextForType( $manifest['type'] ); |
|
719 | + $type = $this->getUITextForType($manifest['type']); |
|
720 | 720 | $manifest_type = $manifest['type']; |
721 | 721 | $dependencies = array(); |
722 | - if( isset( $manifest['dependencies']) ){ |
|
723 | - $dependencies = $manifest['dependencies']; |
|
722 | + if (isset($manifest['dependencies'])) { |
|
723 | + $dependencies = $manifest['dependencies']; |
|
724 | 724 | } |
725 | 725 | } |
726 | 726 | |
727 | 727 | //check dependencies first |
728 | - if(!empty($dependencies)) { |
|
728 | + if (!empty($dependencies)) { |
|
729 | 729 | $uh = new UpgradeHistory(); |
730 | 730 | $not_found = $uh->checkDependencies($dependencies); |
731 | - if(!empty($not_found) && count($not_found) > 0){ |
|
731 | + if (!empty($not_found) && count($not_found) > 0) { |
|
732 | 732 | $file_install = 'errors_'.$mod_strings['ERR_UW_NO_DEPENDENCY']."[".implode(',', $not_found)."]"; |
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
736 | - if($view == 'default' && $manifest_type != 'patch') { |
|
736 | + if ($view == 'default' && $manifest_type != 'patch') { |
|
737 | 737 | continue; |
738 | 738 | } |
739 | 739 | |
740 | - if($view == 'module' |
|
740 | + if ($view == 'module' |
|
741 | 741 | && $manifest_type != 'module' && $manifest_type != 'theme' && $manifest_type != 'langpack') { |
742 | 742 | continue; |
743 | 743 | } |
744 | 744 | |
745 | - if(empty($manifest['icon'])) { |
|
746 | - $icon = $this->getImageForType( $manifest['type'] ); |
|
745 | + if (empty($manifest['icon'])) { |
|
746 | + $icon = $this->getImageForType($manifest['type']); |
|
747 | 747 | } else { |
748 | - $path_parts = pathinfo( $manifest['icon'] ); |
|
749 | - $icon = "<img src=\"" . remove_file_extension( $upgrade_content ) . "-icon." . $path_parts['extension'] . "\">"; |
|
748 | + $path_parts = pathinfo($manifest['icon']); |
|
749 | + $icon = "<img src=\"".remove_file_extension($upgrade_content)."-icon.".$path_parts['extension']."\">"; |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | $upgrades_available++; |
@@ -759,15 +759,15 @@ discard block |
||
759 | 759 | return $packages; |
760 | 760 | } |
761 | 761 | |
762 | - function getLicenseFromFile($file){ |
|
762 | + function getLicenseFromFile($file) { |
|
763 | 763 | global $sugar_config; |
764 | 764 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
765 | 765 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
766 | 766 | $license_file = $this->extractFile($file, 'LICENSE.txt', $base_tmp_upgrade_dir); |
767 | - if(is_file($license_file)){ |
|
767 | + if (is_file($license_file)) { |
|
768 | 768 | $contents = file_get_contents($license_file); |
769 | 769 | return $contents; |
770 | - }else{ |
|
770 | + } else { |
|
771 | 771 | return null; |
772 | 772 | } |
773 | 773 | } |
@@ -780,12 +780,12 @@ discard block |
||
780 | 780 | * |
781 | 781 | * @return an array of installed upgrade_history objects |
782 | 782 | */ |
783 | - function getInstalled($types = array('module')){ |
|
783 | + function getInstalled($types = array('module')) { |
|
784 | 784 | $uh = new UpgradeHistory(); |
785 | 785 | $in = ""; |
786 | - for($i = 0; $i < count($types); $i++){ |
|
786 | + for ($i = 0; $i < count($types); $i++) { |
|
787 | 787 | $in .= "'".$types[$i]."'"; |
788 | - if(($i+1) < count($types)){ |
|
788 | + if (($i + 1) < count($types)) { |
|
789 | 789 | $in .= ","; |
790 | 790 | } |
791 | 791 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | return $uh->getList($query); |
794 | 794 | } |
795 | 795 | |
796 | - function getinstalledPackages($types = array('module', 'langpack')){ |
|
796 | + function getinstalledPackages($types = array('module', 'langpack')) { |
|
797 | 797 | global $sugar_config; |
798 | 798 | $installeds = $this->getInstalled($types); |
799 | 799 | $packages = array(); |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | $uh = new UpgradeHistory(); |
802 | 802 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
803 | 803 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
804 | - foreach($installeds as $installed) |
|
804 | + foreach ($installeds as $installed) |
|
805 | 805 | { |
806 | 806 | $populate = false; |
807 | 807 | $filename = from_html($installed->filename); |
@@ -815,31 +815,31 @@ discard block |
||
815 | 815 | $enabled = true; |
816 | 816 | $enabled_string = 'ENABLED'; |
817 | 817 | //if the name is empty then we should try to pull from manifest and populate upgrade_history_table |
818 | - if(empty($name)){ |
|
818 | + if (empty($name)) { |
|
819 | 819 | $populate = true; |
820 | 820 | } |
821 | 821 | $upgrades_installed++; |
822 | - switch($type) |
|
822 | + switch ($type) |
|
823 | 823 | { |
824 | 824 | case "theme": |
825 | 825 | case "langpack": |
826 | 826 | case "module": |
827 | 827 | case "patch": |
828 | - if($populate){ |
|
828 | + if ($populate) { |
|
829 | 829 | $manifest_file = $this->extractManifest($filename, $base_tmp_upgrade_dir); |
830 | 830 | require_once($manifest_file); |
831 | 831 | $GLOBALS['log']->info("Filling in upgrade_history table"); |
832 | 832 | $populate = false; |
833 | - if( isset( $manifest['name'] ) ){ |
|
833 | + if (isset($manifest['name'])) { |
|
834 | 834 | $name = $manifest['name']; |
835 | 835 | $installed->name = $name; |
836 | 836 | } |
837 | - if( isset( $manifest['description'] ) ){ |
|
837 | + if (isset($manifest['description'])) { |
|
838 | 838 | $description = $manifest['description']; |
839 | 839 | $installed->description = $description; |
840 | 840 | } |
841 | - if(isset($installdefs) && isset( $installdefs['id'] ) ){ |
|
842 | - $id_name = $installdefs['id']; |
|
841 | + if (isset($installdefs) && isset($installdefs['id'])) { |
|
842 | + $id_name = $installdefs['id']; |
|
843 | 843 | $installed->id_name = $id_name; |
844 | 844 | } |
845 | 845 | |
@@ -849,24 +849,24 @@ discard block |
||
849 | 849 | $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); |
850 | 850 | $installed->manifest = base64_encode(serialize($serial_manifest)); |
851 | 851 | $installed->save(); |
852 | - }else{ |
|
852 | + } else { |
|
853 | 853 | $serial_manifest = unserialize(base64_decode($installed->manifest)); |
854 | 854 | $manifest = $serial_manifest['manifest']; |
855 | 855 | } |
856 | - if(($upgrades_installed==0 || $uh->UninstallAvailable($installeds, $installed)) |
|
856 | + if (($upgrades_installed == 0 || $uh->UninstallAvailable($installeds, $installed)) |
|
857 | 857 | && is_file($filename) && !empty($manifest['is_uninstallable'])) |
858 | 858 | { |
859 | 859 | $uninstallable = true; |
860 | 860 | } |
861 | 861 | $enabled = $installed->enabled; |
862 | - if(!$enabled) |
|
862 | + if (!$enabled) |
|
863 | 863 | $enabled_string = 'DISABLED'; |
864 | 864 | $file_uninstall = $filename; |
865 | - if(!$uninstallable){ |
|
865 | + if (!$uninstallable) { |
|
866 | 866 | $file_uninstall = 'UNINSTALLABLE'; |
867 | 867 | $enabled_string = 'UNINSTALLABLE'; |
868 | 868 | } else { |
869 | - $file_uninstall = fileToHash( $file_uninstall ); |
|
869 | + $file_uninstall = fileToHash($file_uninstall); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | $packages[] = array( |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | 'published_date' => $date_entered, |
877 | 877 | 'description' => $description, |
878 | 878 | 'uninstallable' =>$uninstallable, |
879 | - 'file_install' => $file_uninstall , |
|
879 | + 'file_install' => $file_uninstall, |
|
880 | 880 | 'file' => fileToHash($filename), |
881 | 881 | 'enabled' => $enabled_string |
882 | 882 | ); |
@@ -67,8 +67,7 @@ discard block |
||
67 | 67 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
68 | 68 | if(isset($GLOBALS['log'])) { |
69 | 69 | $GLOBALS['log']->deprecated($deprecatedMessage); |
70 | - } |
|
71 | - else { |
|
70 | + } else { |
|
72 | 71 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
73 | 72 | } |
74 | 73 | self::__construct(); |
@@ -88,7 +87,7 @@ discard block |
||
88 | 87 | if(!empty($name_value_list)){ |
89 | 88 | $name_value_list = PackageManager::fromNameValueList($name_value_list); |
90 | 89 | return $name_value_list['description']; |
91 | - }else { |
|
90 | + } else { |
|
92 | 91 | return ''; |
93 | 92 | } |
94 | 93 | } |
@@ -134,8 +133,9 @@ discard block |
||
134 | 133 | //check to see if we already this one installed |
135 | 134 | $result = $uh->determineIfUpgrade($myrelease['id_name'], $myrelease['version']); |
136 | 135 | $enable = false; |
137 | - if($result == true || is_array($result)) |
|
138 | - $enable = true; |
|
136 | + if($result == true || is_array($result)) { |
|
137 | + $enable = true; |
|
138 | + } |
|
139 | 139 | $nodes[$mypack['category_id']]['packages'][$mypack['id']]['releases'][$myrelease['id']] = array('id' => $myrelease['id'], 'version' => $myrelease['version'], 'label' => $myrelease['description'], 'category_id' => $mypack['category_id'], 'package_id' => $mypack['id'], 'type' => 'release', 'enable' => $enable); |
140 | 140 | } |
141 | 141 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $filepath = PackageManagerComm::performDownload($filename); |
214 | 214 | return $filepath; |
215 | 215 | } |
216 | - }else{ |
|
216 | + } else{ |
|
217 | 217 | return null; |
218 | 218 | } |
219 | 219 | } |
@@ -231,10 +231,11 @@ discard block |
||
231 | 231 | PackageManager::setCredentials($username, $password, $systemname); |
232 | 232 | PackageManagerComm::clearSession(); |
233 | 233 | $result = PackageManagerComm::login($terms_checked); |
234 | - if(is_array($result)) |
|
235 | - return $result; |
|
236 | - else |
|
237 | - return true; |
|
234 | + if(is_array($result)) { |
|
235 | + return $result; |
|
236 | + } else { |
|
237 | + return true; |
|
238 | + } |
|
238 | 239 | } |
239 | 240 | |
240 | 241 | function setCredentials($username, $password, $systemname){ |
@@ -285,7 +286,7 @@ discard block |
||
285 | 286 | if(!empty($release_id) || !empty($package_id)){ |
286 | 287 | $documents = PackageManagerComm::getDocumentation($package_id, $release_id); |
287 | 288 | return $documents; |
288 | - }else{ |
|
289 | + } else{ |
|
289 | 290 | return null; |
290 | 291 | } |
291 | 292 | } |
@@ -480,8 +481,9 @@ discard block |
||
480 | 481 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
481 | 482 | $manifest_file = $this->extractManifest( $base_filename,$base_tmp_upgrade_dir); |
482 | 483 | $GLOBALS['log']->debug("Manifest: ".$manifest_file); |
483 | - if($view == 'module') |
|
484 | - $license_file = $this->extractFile($base_filename, 'LICENSE.txt', $base_tmp_upgrade_dir); |
|
484 | + if($view == 'module') { |
|
485 | + $license_file = $this->extractFile($base_filename, 'LICENSE.txt', $base_tmp_upgrade_dir); |
|
486 | + } |
|
485 | 487 | if(is_file($manifest_file)){ |
486 | 488 | $GLOBALS['log']->debug("VALIDATING MANIFEST". $manifest_file); |
487 | 489 | require_once( $manifest_file ); |
@@ -492,14 +494,16 @@ discard block |
||
492 | 494 | if( $view == "module" ){ |
493 | 495 | if ($upgrade_zip_type != "module" && $upgrade_zip_type != "theme" && $upgrade_zip_type != "langpack"){ |
494 | 496 | $this->unlinkTempFiles(); |
495 | - if($display_messages) |
|
496 | - die($mod_strings['ERR_UW_NOT_ACCEPTIBLE_TYPE']); |
|
497 | + if($display_messages) { |
|
498 | + die($mod_strings['ERR_UW_NOT_ACCEPTIBLE_TYPE']); |
|
499 | + } |
|
497 | 500 | } |
498 | - }elseif( $view == "default" ){ |
|
501 | + } elseif( $view == "default" ){ |
|
499 | 502 | if($upgrade_zip_type != "patch" ){ |
500 | 503 | $this->unlinkTempFiles(); |
501 | - if($display_messages) |
|
502 | - die($mod_strings['ERR_UW_ONLY_PATCHES']); |
|
504 | + if($display_messages) { |
|
505 | + die($mod_strings['ERR_UW_ONLY_PATCHES']); |
|
506 | + } |
|
503 | 507 | } |
504 | 508 | } |
505 | 509 | |
@@ -517,20 +521,24 @@ discard block |
||
517 | 521 | |
518 | 522 | if( copy( $tempFile , $target_path ) ){ |
519 | 523 | copy( $manifest_file, $target_manifest ); |
520 | - if($display_messages) |
|
521 | - $messages = '<script>ajaxStatus.flashStatus("' .$base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS'] . ', 5000");</script>'; |
|
522 | - }else{ |
|
523 | - if($display_messages) |
|
524 | - $messages = '<script>ajaxStatus.flashStatus("' .$mod_strings['ERR_UW_UPLOAD_ERROR'] . ', 5000");</script>'; |
|
524 | + if($display_messages) { |
|
525 | + $messages = '<script>ajaxStatus.flashStatus("' .$base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS'] . ', 5000");</script>'; |
|
526 | + } |
|
527 | + } else{ |
|
528 | + if($display_messages) { |
|
529 | + $messages = '<script>ajaxStatus.flashStatus("' .$mod_strings['ERR_UW_UPLOAD_ERROR'] . ', 5000");</script>'; |
|
530 | + } |
|
525 | 531 | } |
526 | 532 | }//fi |
527 | 533 | else{ |
528 | 534 | $this->unlinkTempFiles(); |
529 | - if($display_messages) |
|
530 | - die($mod_strings['ERR_UW_NO_MANIFEST']); |
|
535 | + if($display_messages) { |
|
536 | + die($mod_strings['ERR_UW_NO_MANIFEST']); |
|
537 | + } |
|
538 | + } |
|
539 | + if(isset($messages)) { |
|
540 | + return $messages; |
|
531 | 541 | } |
532 | - if(isset($messages)) |
|
533 | - return $messages; |
|
534 | 542 | } |
535 | 543 | |
536 | 544 | function unlinkTempFiles() { |
@@ -568,14 +576,15 @@ discard block |
||
568 | 576 | $version = $manifest['version']; |
569 | 577 | $uh = new UpgradeHistory(); |
570 | 578 | $previous_install = array(); |
571 | - if(!empty($id_name) & !empty($version)) |
|
572 | - $previous_install = $uh->determineIfUpgrade($id_name, $version); |
|
579 | + if(!empty($id_name) & !empty($version)) { |
|
580 | + $previous_install = $uh->determineIfUpgrade($id_name, $version); |
|
581 | + } |
|
573 | 582 | $previous_version = (empty($previous_install['version'])) ? '' : $previous_install['version']; |
574 | 583 | $previous_id = (empty($previous_install['id'])) ? '' : $previous_install['id']; |
575 | 584 | |
576 | 585 | if(!empty($previous_version)){ |
577 | 586 | $mi->install($unzip_dir, true, $previous_version); |
578 | - }else{ |
|
587 | + } else{ |
|
579 | 588 | $mi->install($unzip_dir); |
580 | 589 | } |
581 | 590 | $GLOBALS['log']->debug("INSTALLED: ".$file); |
@@ -612,7 +621,9 @@ discard block |
||
612 | 621 | $base_upgrade_dir = $this->upload_dir.'/upgrades'; |
613 | 622 | $base_tmp_upgrade_dir = "$base_upgrade_dir/temp"; |
614 | 623 | if(is_file($found->filename)){ |
615 | - if(!isset($GLOBALS['mi_remove_tables']))$GLOBALS['mi_remove_tables'] = true; |
|
624 | + if(!isset($GLOBALS['mi_remove_tables'])) { |
|
625 | + $GLOBALS['mi_remove_tables'] = true; |
|
626 | + } |
|
616 | 627 | $unzip_dir = mk_temp_dir( $base_tmp_upgrade_dir ); |
617 | 628 | unzip($found->filename, $unzip_dir ); |
618 | 629 | $mi = new ModuleInstaller(); |
@@ -621,7 +632,7 @@ discard block |
||
621 | 632 | $found->delete(); |
622 | 633 | unlink(remove_file_extension( $found->filename ) . '-manifest.php'); |
623 | 634 | unlink($found->filename); |
624 | - }else{ |
|
635 | + } else{ |
|
625 | 636 | //file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem |
626 | 637 | $found->delete(); |
627 | 638 | } |
@@ -767,7 +778,7 @@ discard block |
||
767 | 778 | if(is_file($license_file)){ |
768 | 779 | $contents = file_get_contents($license_file); |
769 | 780 | return $contents; |
770 | - }else{ |
|
781 | + } else{ |
|
771 | 782 | return null; |
772 | 783 | } |
773 | 784 | } |
@@ -849,7 +860,7 @@ discard block |
||
849 | 860 | $serial_manifest['upgrade_manifest'] = (isset($upgrade_manifest) ? $upgrade_manifest : ''); |
850 | 861 | $installed->manifest = base64_encode(serialize($serial_manifest)); |
851 | 862 | $installed->save(); |
852 | - }else{ |
|
863 | + } else{ |
|
853 | 864 | $serial_manifest = unserialize(base64_decode($installed->manifest)); |
854 | 865 | $manifest = $serial_manifest['manifest']; |
855 | 866 | } |
@@ -859,8 +870,9 @@ discard block |
||
859 | 870 | $uninstallable = true; |
860 | 871 | } |
861 | 872 | $enabled = $installed->enabled; |
862 | - if(!$enabled) |
|
863 | - $enabled_string = 'DISABLED'; |
|
873 | + if(!$enabled) { |
|
874 | + $enabled_string = 'DISABLED'; |
|
875 | + } |
|
864 | 876 | $file_uninstall = $filename; |
865 | 877 | if(!$uninstallable){ |
866 | 878 | $file_uninstall = 'UNINSTALLABLE'; |
@@ -39,21 +39,21 @@ discard block |
||
39 | 39 | |
40 | 40 | require_once('include/ListView/ListViewSmarty.php'); |
41 | 41 | |
42 | -class ListViewPackages extends ListViewSmarty{ |
|
42 | +class ListViewPackages extends ListViewSmarty { |
|
43 | 43 | var $secondaryDisplayColumns; |
44 | 44 | /** |
45 | 45 | * Constructor Call ListViewSmarty |
46 | 46 | */ |
47 | - function __construct(){ |
|
47 | + function __construct() { |
|
48 | 48 | parent::__construct(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
53 | 53 | */ |
54 | - function ListViewPackages(){ |
|
54 | + function ListViewPackages() { |
|
55 | 55 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
56 | - if(isset($GLOBALS['log'])) { |
|
56 | + if (isset($GLOBALS['log'])) { |
|
57 | 57 | $GLOBALS['log']->deprecated($deprecatedMessage); |
58 | 58 | } |
59 | 59 | else { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param data the data to display on the page |
70 | 70 | * @param file the template file to parse |
71 | 71 | */ |
72 | - function setup($data, $file, $where, $params = Array(), $offset = 0, $limit = -1, $filter_fields = Array(), $id_field = 'id'){ |
|
72 | + function setup($data, $file, $where, $params = Array(), $offset = 0, $limit = -1, $filter_fields = Array(), $id_field = 'id') { |
|
73 | 73 | $this->data = $data; |
74 | 74 | $this->tpl = $file; |
75 | 75 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * Override the display method |
79 | 79 | */ |
80 | - function display($end = true){ |
|
80 | + function display($end = true) { |
|
81 | 81 | global $odd_bg, $even_bg, $app_strings; |
82 | 82 | $this->ss->assign('rowColor', array('oddListRow', 'evenListRow')); |
83 | 83 | $this->ss->assign('bgColor', array($odd_bg, $even_bg)); |
@@ -23,8 +23,7 @@ |
||
23 | 23 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
24 | 24 | if(isset($GLOBALS['log'])) { |
25 | 25 | $GLOBALS['log']->deprecated($deprecatedMessage); |
26 | - } |
|
27 | - else { |
|
26 | + } else { |
|
28 | 27 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
29 | 28 | } |
30 | 29 | self::__construct($seed, $module, $subPanel, $options); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
3 | - die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) |
|
3 | + die ('Not A Valid Entry Point'); |
|
4 | 4 | |
5 | 5 | /********************************************************************************* |
6 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | var $base_path = ""; |
48 | 48 | |
49 | 49 | public function __construct($module = '') { |
50 | - $this->module = (! empty ( $module )) ? $module :( (isset($_REQUEST['module']) && ! empty($_REQUEST['module'])) ? $_REQUEST ['module'] : ''); |
|
50 | + $this->module = (!empty ($module)) ? $module : ((isset($_REQUEST['module']) && !empty($_REQUEST['module'])) ? $_REQUEST ['module'] : ''); |
|
51 | 51 | $this->base_path = "custom/Extension/modules/{$this->module}/Ext/Vardefs"; |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
56 | 56 | */ |
57 | - public function DynamicField($module = ''){ |
|
57 | + public function DynamicField($module = '') { |
|
58 | 58 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
59 | - if(isset($GLOBALS['log'])) { |
|
59 | + if (isset($GLOBALS['log'])) { |
|
60 | 60 | $GLOBALS['log']->deprecated($deprecatedMessage); |
61 | 61 | } |
62 | 62 | else { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | function getModuleName() |
69 | 69 | { |
70 | - return $this->module ; |
|
70 | + return $this->module; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /* |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function getPackageName() |
77 | 77 | { |
78 | - return null ; |
|
78 | + return null; |
|
79 | 79 | } |
80 | 80 | |
81 | - function deleteCache(){ |
|
81 | + function deleteCache() { |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -92,20 +92,20 @@ discard block |
||
92 | 92 | if ($bean) { |
93 | 93 | $this->bean = $bean; |
94 | 94 | } |
95 | - if (isset ( $this->bean->module_dir )) { |
|
95 | + if (isset ($this->bean->module_dir)) { |
|
96 | 96 | $this->module = $this->bean->module_dir; |
97 | 97 | } |
98 | - if(!isset($GLOBALS['dictionary'][$this->bean->object_name]['custom_fields'])){ |
|
99 | - $this->buildCache ( $this->module ); |
|
98 | + if (!isset($GLOBALS['dictionary'][$this->bean->object_name]['custom_fields'])) { |
|
99 | + $this->buildCache($this->module); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - function setLabel( $language='en_us' , $key , $value ) |
|
103 | + function setLabel($language = 'en_us', $key, $value) |
|
104 | 104 | { |
105 | - $params [ "label_" . $key ] = $value; |
|
106 | - require_once 'modules/ModuleBuilder/parsers/parser.label.php' ; |
|
107 | - $parser = new ParserLabel ( $this->module ) ; |
|
108 | - $parser->handleSave( $params , $language); |
|
105 | + $params ["label_".$key] = $value; |
|
106 | + require_once 'modules/ModuleBuilder/parsers/parser.label.php'; |
|
107 | + $parser = new ParserLabel($this->module); |
|
108 | + $parser->handleSave($params, $language); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -115,58 +115,58 @@ discard block |
||
115 | 115 | * @param boolean saveCache Boolean value indicating whether or not to pass saveCache value to saveToVardef, defaults to true |
116 | 116 | * @return unknown |
117 | 117 | */ |
118 | - function buildCache($module = false, $saveCache=true) { |
|
118 | + function buildCache($module = false, $saveCache = true) { |
|
119 | 119 | //We can't build the cache while installing as the required database tables may not exist. |
120 | - if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true|| empty($GLOBALS['db'])) |
|
120 | + if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true || empty($GLOBALS['db'])) |
|
121 | 121 | return false; |
122 | - if($module == '../data')return false; |
|
122 | + if ($module == '../data')return false; |
|
123 | 123 | |
124 | - static $results = array ( ) ; |
|
124 | + static $results = array( ); |
|
125 | 125 | |
126 | 126 | $where = ''; |
127 | - if (! empty ( $module )) { |
|
127 | + if (!empty ($module)) { |
|
128 | 128 | $where .= " custom_module='$module' AND "; |
129 | - unset( $results[ $module ] ) ; // clear out any old results for the module as $results is declared static |
|
129 | + unset($results[$module]); // clear out any old results for the module as $results is declared static |
|
130 | 130 | } |
131 | 131 | else |
132 | 132 | { |
133 | - $results = array ( ) ; // clear out results - if we remove a module we don't want to have its old vardefs hanging around |
|
133 | + $results = array( ); // clear out results - if we remove a module we don't want to have its old vardefs hanging around |
|
134 | 134 | } |
135 | 135 | |
136 | - $GLOBALS['log']->debug('rebuilding cache for ' . $module); |
|
136 | + $GLOBALS['log']->debug('rebuilding cache for '.$module); |
|
137 | 137 | $query = "SELECT * FROM fields_meta_data WHERE $where deleted = 0"; |
138 | 138 | |
139 | - $result = $GLOBALS['db']->query ( $query ); |
|
139 | + $result = $GLOBALS['db']->query($query); |
|
140 | 140 | require_once ('modules/DynamicFields/FieldCases.php'); |
141 | 141 | |
142 | 142 | // retrieve the field definition from the fields_meta_data table |
143 | 143 | // using 'encode'=false to fetchByAssoc to prevent any pre-formatting of the base metadata |
144 | 144 | // for immediate use in HTML. This metadata will be further massaged by get_field_def() and so should not be pre-formatted |
145 | - while ( $row = $GLOBALS['db']->fetchByAssoc ( $result, false ) ) { |
|
146 | - $field = get_widget ( $row ['type'] ); |
|
145 | + while ($row = $GLOBALS['db']->fetchByAssoc($result, false)) { |
|
146 | + $field = get_widget($row ['type']); |
|
147 | 147 | |
148 | - foreach ( $row as $key => $value ) { |
|
148 | + foreach ($row as $key => $value) { |
|
149 | 149 | $field->$key = $value; |
150 | 150 | } |
151 | 151 | $field->default = $field->default_value; |
152 | - $vardef = $field->get_field_def (); |
|
152 | + $vardef = $field->get_field_def(); |
|
153 | 153 | $vardef ['id'] = $row ['id']; |
154 | 154 | $vardef ['custom_module'] = $row ['custom_module']; |
155 | - if (empty ( $vardef ['source'] )) |
|
155 | + if (empty ($vardef ['source'])) |
|
156 | 156 | $vardef ['source'] = 'custom_fields'; |
157 | - if (empty ( $results [$row ['custom_module']] )) |
|
158 | - $results [$row ['custom_module']] = array ( ); |
|
157 | + if (empty ($results [$row ['custom_module']])) |
|
158 | + $results [$row ['custom_module']] = array( ); |
|
159 | 159 | $results [$row ['custom_module']] [$row ['name']] = $vardef; |
160 | 160 | } |
161 | - if (empty ( $module )) { |
|
162 | - foreach ( $results as $module => $result ) { |
|
163 | - $this->saveToVardef ( $module, $result, $saveCache); |
|
161 | + if (empty ($module)) { |
|
162 | + foreach ($results as $module => $result) { |
|
163 | + $this->saveToVardef($module, $result, $saveCache); |
|
164 | 164 | } |
165 | 165 | } else { |
166 | - if (! empty ( $results [$module] )) { |
|
167 | - $this->saveToVardef ( $module, $results [$module], $saveCache); |
|
168 | - }else{ |
|
169 | - $this->saveToVardef ( $module, false, $saveCache); |
|
166 | + if (!empty ($results [$module])) { |
|
167 | + $this->saveToVardef($module, $results [$module], $saveCache); |
|
168 | + } else { |
|
169 | + $this->saveToVardef($module, false, $saveCache); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | * Returns the widget for a custom field from the fields_meta_data table. |
179 | 179 | */ |
180 | 180 | function getFieldWidget($module, $fieldName) { |
181 | - if (empty($module) || empty($fieldName)){ |
|
181 | + if (empty($module) || empty($fieldName)) { |
|
182 | 182 | sugar_die("Unable to load widget for '$module' : '$fieldName'"); |
183 | 183 | } |
184 | 184 | $query = "SELECT * FROM fields_meta_data WHERE custom_module='$module' AND name='$fieldName' AND deleted = 0"; |
185 | - $result = $GLOBALS['db']->query ( $query ); |
|
185 | + $result = $GLOBALS['db']->query($query); |
|
186 | 186 | require_once ('modules/DynamicFields/FieldCases.php'); |
187 | - if ( $row = $GLOBALS['db']->fetchByAssoc ( $result ) ) { |
|
188 | - $field = get_widget ( $row ['type'] ); |
|
187 | + if ($row = $GLOBALS['db']->fetchByAssoc($result)) { |
|
188 | + $field = get_widget($row ['type']); |
|
189 | 189 | $field->populateFromRow($row); |
190 | 190 | return $field; |
191 | 191 | } |
@@ -199,41 +199,41 @@ discard block |
||
199 | 199 | * @param array $result |
200 | 200 | * @param boolean saveCache Boolean value indicating whether or not to call VardefManager::saveCache, defaults to true |
201 | 201 | */ |
202 | - function saveToVardef($module,$result,$saveCache=true) { |
|
202 | + function saveToVardef($module, $result, $saveCache = true) { |
|
203 | 203 | |
204 | 204 | |
205 | 205 | global $beanList; |
206 | - if (! empty ( $beanList [$module] )) { |
|
206 | + if (!empty ($beanList [$module])) { |
|
207 | 207 | $object = BeanFactory::getObjectName($module); |
208 | 208 | |
209 | - if(empty($GLOBALS['dictionary'][$object]['fields'])){ |
|
209 | + if (empty($GLOBALS['dictionary'][$object]['fields'])) { |
|
210 | 210 | //if the vardef isn't loaded let's try loading it. |
211 | - VardefManager::refreshVardefs($module,$object, null, false); |
|
211 | + VardefManager::refreshVardefs($module, $object, null, false); |
|
212 | 212 | //if it's still not loaded we really don't have anything useful to cache |
213 | - if(empty($GLOBALS['dictionary'][$object]['fields']))return; |
|
213 | + if (empty($GLOBALS['dictionary'][$object]['fields']))return; |
|
214 | 214 | } |
215 | 215 | if (!isset($GLOBALS['dictionary'][$object]['custom_fields'])) { |
216 | 216 | $GLOBALS['dictionary'][$object]['custom_fields'] = false; |
217 | 217 | } |
218 | - if (! empty ( $GLOBALS ['dictionary'] [$object] )) { |
|
219 | - if (! empty ( $result )) { |
|
218 | + if (!empty ($GLOBALS ['dictionary'] [$object])) { |
|
219 | + if (!empty ($result)) { |
|
220 | 220 | // First loop to add |
221 | 221 | |
222 | - foreach ( $result as $field ) { |
|
223 | - foreach($field as $k=>$v){ |
|
222 | + foreach ($result as $field) { |
|
223 | + foreach ($field as $k=>$v) { |
|
224 | 224 | //allows values for custom fields to be defined outside of the scope of studio |
225 | - if(!isset($GLOBALS ['dictionary'] [$object] ['fields'] [$field ['name']][$k])){ |
|
225 | + if (!isset($GLOBALS ['dictionary'] [$object] ['fields'] [$field ['name']][$k])) { |
|
226 | 226 | $GLOBALS ['dictionary'] [$object] ['fields'] [$field ['name']][$k] = $v; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Second loop to remove |
232 | - foreach ( $GLOBALS ['dictionary'] [$object] ['fields'] as $name => $fieldDef ) { |
|
232 | + foreach ($GLOBALS ['dictionary'] [$object] ['fields'] as $name => $fieldDef) { |
|
233 | 233 | |
234 | - if (isset ( $fieldDef ['custom_module'] )) { |
|
235 | - if (! isset ( $result [$name] )) { |
|
236 | - unset ( $GLOBALS ['dictionary'] [$object] ['fields'] [$name] ); |
|
234 | + if (isset ($fieldDef ['custom_module'])) { |
|
235 | + if (!isset ($result [$name])) { |
|
236 | + unset ($GLOBALS ['dictionary'] [$object] ['fields'] [$name]); |
|
237 | 237 | } else { |
238 | 238 | $GLOBALS ['dictionary'] [$object] ['custom_fields'] = true; |
239 | 239 | } |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | } |
245 | 245 | |
246 | 246 | $manager = new VardefManager(); |
247 | - if($saveCache) |
|
247 | + if ($saveCache) |
|
248 | 248 | { |
249 | - $manager->saveCache ($this->module, $object); |
|
249 | + $manager->saveCache($this->module, $object); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | // Everything works off of vardefs, so let's have it save the users vardefs |
@@ -269,38 +269,38 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return array select=>select columns, join=>prebuilt join statement |
271 | 271 | */ |
272 | - function getJOIN( $expandedList = false , $includeRelates = false, &$where = false){ |
|
273 | - if(!$this->bean->hasCustomFields()){ |
|
272 | + function getJOIN($expandedList = false, $includeRelates = false, &$where = false) { |
|
273 | + if (!$this->bean->hasCustomFields()) { |
|
274 | 274 | return array( |
275 | 275 | 'select' => '', |
276 | 276 | 'join' => '' |
277 | 277 | ); |
278 | 278 | } |
279 | 279 | |
280 | - if (empty($expandedList) ) |
|
280 | + if (empty($expandedList)) |
|
281 | 281 | { |
282 | - $select = ",{$this->bean->table_name}_cstm.*" ; |
|
282 | + $select = ",{$this->bean->table_name}_cstm.*"; |
|
283 | 283 | } |
284 | 284 | else |
285 | 285 | { |
286 | 286 | $select = ''; |
287 | 287 | $isList = is_array($expandedList); |
288 | - foreach($this->bean->field_defs as $name=>$field) |
|
288 | + foreach ($this->bean->field_defs as $name=>$field) |
|
289 | 289 | { |
290 | - if (!empty($field['source']) && $field['source'] == 'custom_fields' && (!$isList || !empty($expandedList[$name]))){ |
|
290 | + if (!empty($field['source']) && $field['source'] == 'custom_fields' && (!$isList || !empty($expandedList[$name]))) { |
|
291 | 291 | // assumption: that the column name in _cstm is the same as the field name. Currently true. |
292 | 292 | // however, two types of dynamic fields do not have columns in the custom table - html fields (they're readonly) and flex relates (parent_name doesn't exist) |
293 | - if ( $field['type'] != 'html' && $name != 'parent_name') |
|
294 | - $select .= ",{$this->bean->table_name}_cstm.{$name}" ; |
|
293 | + if ($field['type'] != 'html' && $name != 'parent_name') |
|
294 | + $select .= ",{$this->bean->table_name}_cstm.{$name}"; |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | } |
298 | - $join = " LEFT JOIN " .$this->bean->table_name. "_cstm ON " .$this->bean->table_name. ".id = ". $this->bean->table_name. "_cstm.id_c "; |
|
298 | + $join = " LEFT JOIN ".$this->bean->table_name."_cstm ON ".$this->bean->table_name.".id = ".$this->bean->table_name."_cstm.id_c "; |
|
299 | 299 | |
300 | 300 | if ($includeRelates) { |
301 | 301 | $jtAlias = "relJoin"; |
302 | 302 | $jtCount = 1; |
303 | - foreach($this->bean->field_defs as $name=>$field) |
|
303 | + foreach ($this->bean->field_defs as $name=>$field) |
|
304 | 304 | { |
305 | 305 | if ($field['type'] == 'relate' && isset($field['custom_module'])) { |
306 | 306 | $relateJoinInfo = $this->getRelateJoin($field, $jtAlias.$jtCount); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | { |
312 | 312 | $pattern = '/'.$field['name'].'\slike/i'; |
313 | 313 | $replacement = $relateJoinInfo['name_field'].' like'; |
314 | - $where = preg_replace($pattern,$replacement,$where); |
|
314 | + $where = preg_replace($pattern, $replacement, $where); |
|
315 | 315 | } |
316 | 316 | $jtCount++; |
317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | global $beanFiles, $beanList, $module; |
330 | 330 | $rel_module = $field_def['module']; |
331 | - if(empty($beanFiles[$beanList[$rel_module]])) { |
|
331 | + if (empty($beanFiles[$beanList[$rel_module]])) { |
|
332 | 332 | return false; |
333 | 333 | } |
334 | 334 | |
@@ -338,25 +338,25 @@ discard block |
||
338 | 338 | if (isset($rel_mod->field_defs['name'])) |
339 | 339 | { |
340 | 340 | $name_field_def = $rel_mod->field_defs['name']; |
341 | - if(isset($name_field_def['db_concat_fields'])) |
|
341 | + if (isset($name_field_def['db_concat_fields'])) |
|
342 | 342 | { |
343 | 343 | $name_field = db_concat($joinTableAlias, $name_field_def['db_concat_fields']); |
344 | 344 | } |
345 | 345 | //If the name field is non-db, we need to find another field to display |
346 | - else if(!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == "non-db" && !empty($field_def['rname'])) |
|
346 | + else if (!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == "non-db" && !empty($field_def['rname'])) |
|
347 | 347 | { |
348 | - $name_field = "$joinTableAlias." . $field_def['rname']; |
|
348 | + $name_field = "$joinTableAlias.".$field_def['rname']; |
|
349 | 349 | } |
350 | 350 | else |
351 | 351 | { |
352 | 352 | $name_field = "$joinTableAlias.name"; |
353 | 353 | } |
354 | 354 | } |
355 | - $tableName = isset($field_def['custom_module']) ? "{$this->bean->table_name}_cstm" : $this->bean->table_name ; |
|
355 | + $tableName = isset($field_def['custom_module']) ? "{$this->bean->table_name}_cstm" : $this->bean->table_name; |
|
356 | 356 | $relID = $field_def['id_name']; |
357 | 357 | $ret_array['rel_table'] = $rel_table; |
358 | 358 | $ret_array['name_field'] = $name_field; |
359 | - $ret_array['select'] = ($withIdName ? ", {$tableName}.{$relID}" : "") . ", {$name_field} {$field_def['name']} "; |
|
359 | + $ret_array['select'] = ($withIdName ? ", {$tableName}.{$relID}" : "").", {$name_field} {$field_def['name']} "; |
|
360 | 360 | $ret_array['from'] = " LEFT JOIN $rel_table $joinTableAlias ON $tableName.$relID = $joinTableAlias.id" |
361 | 361 | . " AND $joinTableAlias.deleted=0 "; |
362 | 362 | return $ret_array; |
@@ -366,24 +366,24 @@ discard block |
||
366 | 366 | * Fills in all the custom fields of type relate relationships for an object |
367 | 367 | * |
368 | 368 | */ |
369 | - function fill_relationships(){ |
|
369 | + function fill_relationships() { |
|
370 | 370 | global $beanList, $beanFiles; |
371 | - if(!empty($this->bean->relDepth)) { |
|
372 | - if($this->bean->relDepth > 1)return; |
|
373 | - }else{ |
|
371 | + if (!empty($this->bean->relDepth)) { |
|
372 | + if ($this->bean->relDepth > 1)return; |
|
373 | + } else { |
|
374 | 374 | $this->bean->relDepth = 0; |
375 | 375 | } |
376 | - foreach($this->bean->field_defs as $field){ |
|
377 | - if(empty($field['source']) || $field['source'] != 'custom_fields')continue; |
|
378 | - if($field['type'] == 'relate'){ |
|
379 | - $related_module =$field['ext2']; |
|
376 | + foreach ($this->bean->field_defs as $field) { |
|
377 | + if (empty($field['source']) || $field['source'] != 'custom_fields')continue; |
|
378 | + if ($field['type'] == 'relate') { |
|
379 | + $related_module = $field['ext2']; |
|
380 | 380 | $name = $field['name']; |
381 | 381 | if (empty($this->bean->$name)) { //Don't load the relationship twice |
382 | 382 | $id_name = $field['id_name']; |
383 | - if(isset($beanList[ $related_module])){ |
|
383 | + if (isset($beanList[$related_module])) { |
|
384 | 384 | $class = $beanList[$related_module]; |
385 | 385 | |
386 | - if(file_exists($beanFiles[$class]) && isset($this->bean->$name)){ |
|
386 | + if (file_exists($beanFiles[$class]) && isset($this->bean->$name)) { |
|
387 | 387 | require_once($beanFiles[$class]); |
388 | 388 | $mod = new $class(); |
389 | 389 | $mod->relDepth = $this->bean->relDepth + 1; |
@@ -401,72 +401,72 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @param boolean $isUpdate |
403 | 403 | */ |
404 | - function save($isUpdate){ |
|
404 | + function save($isUpdate) { |
|
405 | 405 | |
406 | - if($this->bean->hasCustomFields() && isset($this->bean->id)){ |
|
406 | + if ($this->bean->hasCustomFields() && isset($this->bean->id)) { |
|
407 | 407 | |
408 | - if($isUpdate){ |
|
409 | - $query = "UPDATE ". $this->bean->table_name. "_cstm SET "; |
|
408 | + if ($isUpdate) { |
|
409 | + $query = "UPDATE ".$this->bean->table_name."_cstm SET "; |
|
410 | 410 | } |
411 | - $queryInsert = "INSERT INTO ". $this->bean->table_name. "_cstm (id_c"; |
|
411 | + $queryInsert = "INSERT INTO ".$this->bean->table_name."_cstm (id_c"; |
|
412 | 412 | $values = "('".$this->bean->id."'"; |
413 | 413 | $first = true; |
414 | - foreach($this->bean->field_defs as $name=>$field){ |
|
414 | + foreach ($this->bean->field_defs as $name=>$field) { |
|
415 | 415 | |
416 | - if(empty($field['source']) || $field['source'] != 'custom_fields')continue; |
|
417 | - if($field['type'] == 'html' || $field['type'] == 'parent')continue; |
|
418 | - if(isset($this->bean->$name)){ |
|
416 | + if (empty($field['source']) || $field['source'] != 'custom_fields')continue; |
|
417 | + if ($field['type'] == 'html' || $field['type'] == 'parent')continue; |
|
418 | + if (isset($this->bean->$name)) { |
|
419 | 419 | $quote = "'"; |
420 | 420 | |
421 | - if(in_array($field['type'], array('int', 'float', 'double', 'uint', 'ulong', 'long', 'short', 'tinyint', 'currency', 'decimal'))) { |
|
421 | + if (in_array($field['type'], array('int', 'float', 'double', 'uint', 'ulong', 'long', 'short', 'tinyint', 'currency', 'decimal'))) { |
|
422 | 422 | $quote = ''; |
423 | - if(!isset($this->bean->$name) || !is_numeric($this->bean->$name) ){ |
|
424 | - if($field['required']){ |
|
423 | + if (!isset($this->bean->$name) || !is_numeric($this->bean->$name)) { |
|
424 | + if ($field['required']) { |
|
425 | 425 | $this->bean->$name = 0; |
426 | - }else{ |
|
426 | + } else { |
|
427 | 427 | $this->bean->$name = 'NULL'; |
428 | 428 | } |
429 | 429 | } |
430 | 430 | } |
431 | - if ( $field['type'] == 'bool' ) { |
|
432 | - if ( $this->bean->$name === FALSE ) |
|
431 | + if ($field['type'] == 'bool') { |
|
432 | + if ($this->bean->$name === FALSE) |
|
433 | 433 | $this->bean->$name = '0'; |
434 | - elseif ( $this->bean->$name === TRUE ) |
|
434 | + elseif ($this->bean->$name === TRUE) |
|
435 | 435 | $this->bean->$name = '1'; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $val = $this->bean->$name; |
439 | - if(($field['type'] == 'date' || $field['type'] == 'datetimecombo') && (empty($this->bean->$name )|| $this->bean->$name == '1900-01-01')){ |
|
439 | + if (($field['type'] == 'date' || $field['type'] == 'datetimecombo') && (empty($this->bean->$name) || $this->bean->$name == '1900-01-01')) { |
|
440 | 440 | $quote = ''; |
441 | 441 | $val = 'NULL'; |
442 | 442 | $this->bean->$name = ''; // do not set it to string 'NULL' |
443 | 443 | } |
444 | - if($isUpdate){ |
|
445 | - if($first){ |
|
444 | + if ($isUpdate) { |
|
445 | + if ($first) { |
|
446 | 446 | $query .= " $name=$quote".$GLOBALS['db']->quote($val)."$quote"; |
447 | 447 | |
448 | - }else{ |
|
448 | + } else { |
|
449 | 449 | $query .= " ,$name=$quote".$GLOBALS['db']->quote($val)."$quote"; |
450 | 450 | } |
451 | 451 | } |
452 | 452 | $first = false; |
453 | 453 | $queryInsert .= " ,$name"; |
454 | - $values .= " ,$quote". $GLOBALS['db']->quote($val). "$quote"; |
|
454 | + $values .= " ,$quote".$GLOBALS['db']->quote($val)."$quote"; |
|
455 | 455 | } |
456 | 456 | } |
457 | - if($isUpdate){ |
|
458 | - $query.= " WHERE id_c='" . $this->bean->id ."'"; |
|
457 | + if ($isUpdate) { |
|
458 | + $query .= " WHERE id_c='".$this->bean->id."'"; |
|
459 | 459 | |
460 | 460 | } |
461 | 461 | |
462 | 462 | $queryInsert .= " ) VALUES $values )"; |
463 | 463 | |
464 | - if(!$first){ |
|
465 | - if(!$isUpdate){ |
|
464 | + if (!$first) { |
|
465 | + if (!$isUpdate) { |
|
466 | 466 | $GLOBALS['db']->query($queryInsert); |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | $checkquery = "SELECT id_c FROM {$this->bean->table_name}_cstm WHERE id_c = '{$this->bean->id}'"; |
469 | - if ( $GLOBALS['db']->getOne($checkquery) ) { |
|
469 | + if ($GLOBALS['db']->getOne($checkquery)) { |
|
470 | 470 | $result = $GLOBALS['db']->query($query); |
471 | 471 | } else { |
472 | 472 | $GLOBALS['db']->query($queryInsert); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | * Use the widgets get_db_modify_alter_table() method to get the table sql - some widgets do not need any custom table modifications |
482 | 482 | * @param STRING $name - field name |
483 | 483 | */ |
484 | - function deleteField($widget){ |
|
484 | + function deleteField($widget) { |
|
485 | 485 | require_once('modules/DynamicFields/templates/Fields/TemplateField.php'); |
486 | 486 | global $beanList; |
487 | 487 | if (!($widget instanceof TemplateField)) { |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | $object_name = $newName != false ? $newName : $object_name; |
498 | 498 | } |
499 | 499 | |
500 | - $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='" . $this->module . $widget->name . "'"); |
|
501 | - $sql = $widget->get_db_delete_alter_table( $this->bean->table_name . "_cstm" ) ; |
|
502 | - if (! empty( $sql ) ) |
|
503 | - $GLOBALS['db']->query( $sql ); |
|
500 | + $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='".$this->module.$widget->name."'"); |
|
501 | + $sql = $widget->get_db_delete_alter_table($this->bean->table_name."_cstm"); |
|
502 | + if (!empty($sql)) |
|
503 | + $GLOBALS['db']->query($sql); |
|
504 | 504 | |
505 | 505 | $this->removeVardefExtension($widget); |
506 | 506 | VardefManager::clearVardef(); |
@@ -512,25 +512,25 @@ discard block |
||
512 | 512 | * Method required by the TemplateRelatedTextField->save() method |
513 | 513 | * Taken from MBModule's implementation |
514 | 514 | */ |
515 | - function fieldExists($name = '', $type = ''){ |
|
515 | + function fieldExists($name = '', $type = '') { |
|
516 | 516 | // must get the vardefs from the GLOBAL array as $bean->field_defs does not contain the values from the cache at this point |
517 | 517 | // TODO: fix this - saveToVardefs() updates GLOBAL['dictionary'] correctly, obtaining its information directly from the fields_meta_data table via buildCache()... |
518 | 518 | $name = $this->getDBName($name); |
519 | 519 | $vardefs = $GLOBALS['dictionary'][$this->bean->object_name]['fields']; |
520 | - if(!empty($vardefs)){ |
|
521 | - if(empty($type) && empty($name)) |
|
520 | + if (!empty($vardefs)) { |
|
521 | + if (empty($type) && empty($name)) |
|
522 | 522 | return false; |
523 | - else if(empty($type)) |
|
523 | + else if (empty($type)) |
|
524 | 524 | return !empty($vardefs[$name]); |
525 | - else if(empty($name)){ |
|
526 | - foreach($vardefs as $def){ |
|
527 | - if(!empty($def['type']) && $def['type'] == $type) |
|
525 | + else if (empty($name)) { |
|
526 | + foreach ($vardefs as $def) { |
|
527 | + if (!empty($def['type']) && $def['type'] == $type) |
|
528 | 528 | return true; |
529 | 529 | } |
530 | 530 | return false; |
531 | - }else |
|
531 | + } else |
|
532 | 532 | return (!empty($vardefs[$name]) && ($vardefs[$name]['type'] == $type)); |
533 | - }else{ |
|
533 | + } else { |
|
534 | 534 | return false; |
535 | 535 | } |
536 | 536 | } |
@@ -542,24 +542,24 @@ discard block |
||
542 | 542 | * @param Field Object $field |
543 | 543 | * @return boolean |
544 | 544 | */ |
545 | - function addFieldObject(&$field){ |
|
545 | + function addFieldObject(&$field) { |
|
546 | 546 | $GLOBALS['log']->debug('adding field'); |
547 | 547 | $object_name = $this->module; |
548 | 548 | $db_name = $field->name; |
549 | 549 | |
550 | 550 | $fmd = new FieldsMetaData(); |
551 | - $id = $fmd->retrieve($object_name.$db_name,true, false); |
|
551 | + $id = $fmd->retrieve($object_name.$db_name, true, false); |
|
552 | 552 | $is_update = false; |
553 | - $label = strtoupper( $field->label ); |
|
554 | - if(!empty($id)){ |
|
553 | + $label = strtoupper($field->label); |
|
554 | + if (!empty($id)) { |
|
555 | 555 | $is_update = true; |
556 | - }else{ |
|
556 | + } else { |
|
557 | 557 | $db_name = $this->getDBName($field->name); |
558 | 558 | $field->name = $db_name; |
559 | 559 | } |
560 | 560 | $this->createCustomTable(); |
561 | 561 | $fmd->id = $object_name.$db_name; |
562 | - $fmd->custom_module= $object_name; |
|
562 | + $fmd->custom_module = $object_name; |
|
563 | 563 | $fmd->name = $db_name; |
564 | 564 | $fmd->vname = $label; |
565 | 565 | $fmd->type = $field->type; |
@@ -574,16 +574,16 @@ discard block |
||
574 | 574 | $fmd->ext4 = (isset($field->ext4) ? $field->ext4 : ''); |
575 | 575 | $fmd->comments = $field->comment; |
576 | 576 | $fmd->massupdate = $field->massupdate; |
577 | - $fmd->importable = ( isset ( $field->importable ) ) ? $field->importable : null ; |
|
577 | + $fmd->importable = (isset ($field->importable)) ? $field->importable : null; |
|
578 | 578 | $fmd->duplicate_merge = $field->duplicate_merge; |
579 | - $fmd->audited =$field->audited; |
|
579 | + $fmd->audited = $field->audited; |
|
580 | 580 | $fmd->inline_edit = $field->inline_edit; |
581 | 581 | $fmd->reportable = ($field->reportable ? 1 : 0); |
582 | - if(!$is_update){ |
|
583 | - $fmd->new_with_id=true; |
|
582 | + if (!$is_update) { |
|
583 | + $fmd->new_with_id = true; |
|
584 | 584 | } |
585 | - if($field){ |
|
586 | - if(!$is_update){ |
|
585 | + if ($field) { |
|
586 | + if (!$is_update) { |
|
587 | 587 | //Do two SQL calls here in this case |
588 | 588 | //The first is to create the column in the custom table without the default value |
589 | 589 | //The second is to modify the column created in the custom table to set the default value |
@@ -593,21 +593,21 @@ discard block |
||
593 | 593 | // resetting default and default_value does not work for multienum and causes trouble for mssql |
594 | 594 | // so using a temporary variable here to indicate that we don't want default for this query |
595 | 595 | $field->no_default = 1; |
596 | - $query = $field->get_db_add_alter_table($this->bean->table_name . '_cstm'); |
|
596 | + $query = $field->get_db_add_alter_table($this->bean->table_name.'_cstm'); |
|
597 | 597 | // unsetting temporary member variable |
598 | 598 | unset($field->no_default); |
599 | - if(!empty($query)){ |
|
599 | + if (!empty($query)) { |
|
600 | 600 | $GLOBALS['db']->query($query, true, "Cannot create column"); |
601 | 601 | $field->default = $fmd->default_value; |
602 | 602 | $field->default_value = $fmd->default_value; |
603 | - $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm'); |
|
604 | - if(!empty($query)){ |
|
603 | + $query = $field->get_db_modify_alter_table($this->bean->table_name.'_cstm'); |
|
604 | + if (!empty($query)) { |
|
605 | 605 | $GLOBALS['db']->query($query, true, "Cannot set default"); |
606 | 606 | } |
607 | 607 | } |
608 | - }else{ |
|
609 | - $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm'); |
|
610 | - if(!empty($query)){ |
|
608 | + } else { |
|
609 | + $query = $field->get_db_modify_alter_table($this->bean->table_name.'_cstm'); |
|
610 | + if (!empty($query)) { |
|
611 | 611 | $GLOBALS['db']->query($query, true, "Cannot modify field"); |
612 | 612 | } |
613 | 613 | } |
@@ -621,18 +621,18 @@ discard block |
||
621 | 621 | |
622 | 622 | function saveExtendedAttributes($field, $column_fields) |
623 | 623 | { |
624 | - require_once ('modules/ModuleBuilder/parsers/StandardField.php') ; |
|
625 | - require_once ('modules/DynamicFields/FieldCases.php') ; |
|
624 | + require_once ('modules/ModuleBuilder/parsers/StandardField.php'); |
|
625 | + require_once ('modules/DynamicFields/FieldCases.php'); |
|
626 | 626 | global $beanList; |
627 | 627 | |
628 | 628 | $to_save = array(); |
629 | - $base_field = get_widget ( $field->type) ; |
|
630 | - foreach ($field->vardef_map as $property => $fmd_col){ |
|
629 | + $base_field = get_widget($field->type); |
|
630 | + foreach ($field->vardef_map as $property => $fmd_col) { |
|
631 | 631 | //Skip over attribes that are either the default or part of the normal attributes stored in the DB |
632 | 632 | if (!isset($field->$property) || in_array($fmd_col, $column_fields) || in_array($property, $column_fields) |
633 | 633 | || $this->isDefaultValue($property, $field->$property, $base_field) |
634 | 634 | || $property == "action" || $property == "label_value" || $property == "label" |
635 | - || (substr($property, 0,3) == 'ext' && strlen($property) == 4)) |
|
635 | + || (substr($property, 0, 3) == 'ext' && strlen($property) == 4)) |
|
636 | 636 | { |
637 | 637 | continue; |
638 | 638 | } |
@@ -648,19 +648,19 @@ discard block |
||
648 | 648 | { |
649 | 649 | switch ($property) { |
650 | 650 | case "importable": |
651 | - return ( $value === 'true' || $value === '1' || $value === true || $value === 1 ); break; |
|
651 | + return ($value === 'true' || $value === '1' || $value === true || $value === 1); break; |
|
652 | 652 | case "required": |
653 | 653 | case "audited": |
654 | 654 | case "inline_edit": |
655 | 655 | case "massupdate": |
656 | - return ( $value === 'false' || $value === '0' || $value === false || $value === 0); break; |
|
656 | + return ($value === 'false' || $value === '0' || $value === false || $value === 0); break; |
|
657 | 657 | case "default_value": |
658 | 658 | case "default": |
659 | 659 | case "help": |
660 | 660 | case "comments": |
661 | 661 | return ($value == ""); |
662 | 662 | case "duplicate_merge": |
663 | - return ( $value === 'false' || $value === '0' || $value === false || $value === 0 || $value === "disabled"); break; |
|
663 | + return ($value === 'false' || $value === '0' || $value === false || $value === 0 || $value === "disabled"); break; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | if (isset($baseField->$property)) |
@@ -677,10 +677,10 @@ discard block |
||
677 | 677 | $vBean = $bean_name == "aCase" ? "Case" : $bean_name; |
678 | 678 | $file_loc = "$this->base_path/sugarfield_{$field->name}.php"; |
679 | 679 | |
680 | - $out = "<?php\n // created: " . date('Y-m-d H:i:s') . "\n"; |
|
680 | + $out = "<?php\n // created: ".date('Y-m-d H:i:s')."\n"; |
|
681 | 681 | foreach ($def_override as $property => $val) |
682 | 682 | { |
683 | - $out .= override_value_to_string_recursive(array($vBean, "fields", $field->name, $property), "dictionary", $val) . "\n"; |
|
683 | + $out .= override_value_to_string_recursive(array($vBean, "fields", $field->name, $property), "dictionary", $val)."\n"; |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | $out .= "\n ?>"; |
@@ -688,15 +688,15 @@ discard block |
||
688 | 688 | if (!file_exists($this->base_path)) |
689 | 689 | mkdir_recursive($this->base_path); |
690 | 690 | |
691 | - if( $fh = @sugar_fopen( $file_loc, 'w' ) ) |
|
691 | + if ($fh = @sugar_fopen($file_loc, 'w')) |
|
692 | 692 | { |
693 | - fputs( $fh, $out); |
|
694 | - fclose( $fh ); |
|
695 | - return true ; |
|
693 | + fputs($fh, $out); |
|
694 | + fclose($fh); |
|
695 | + return true; |
|
696 | 696 | } |
697 | 697 | else |
698 | 698 | { |
699 | - return false ; |
|
699 | + return false; |
|
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
@@ -733,11 +733,11 @@ discard block |
||
733 | 733 | * @param unknown_type $comment |
734 | 734 | * @return boolean |
735 | 735 | */ |
736 | - function addField($name,$label='', $type='Text',$max_size='255',$required_option='optional', $default_value='', $ext1='', $ext2='', $ext3='',$audited=0, $inline_edit = 1, $mass_update = 0 , $ext4='', $help='',$duplicate_merge=0, $comment=''){ |
|
736 | + function addField($name, $label = '', $type = 'Text', $max_size = '255', $required_option = 'optional', $default_value = '', $ext1 = '', $ext2 = '', $ext3 = '', $audited = 0, $inline_edit = 1, $mass_update = 0, $ext4 = '', $help = '', $duplicate_merge = 0, $comment = '') { |
|
737 | 737 | require_once('modules/DynamicFields/templates/Fields/TemplateField.php'); |
738 | 738 | $field = new TemplateField(); |
739 | 739 | $field->label = $label; |
740 | - if(empty($field->label)){ |
|
740 | + if (empty($field->label)) { |
|
741 | 741 | $field->label = $name; |
742 | 742 | } |
743 | 743 | $field->name = $name; |
@@ -763,10 +763,10 @@ discard block |
||
763 | 763 | * Creates the custom table with an id of id_c |
764 | 764 | * |
765 | 765 | */ |
766 | - function createCustomTable($execute = true){ |
|
766 | + function createCustomTable($execute = true) { |
|
767 | 767 | $out = ""; |
768 | 768 | if (!$GLOBALS['db']->tableExists($this->bean->table_name."_cstm")) { |
769 | - $GLOBALS['log']->debug('creating custom table for '. $this->bean->table_name); |
|
769 | + $GLOBALS['log']->debug('creating custom table for '.$this->bean->table_name); |
|
770 | 770 | $iddef = array( |
771 | 771 | "id_c" => array( |
772 | 772 | "name" => "id_c", |
@@ -783,21 +783,21 @@ discard block |
||
783 | 783 | ); |
784 | 784 | |
785 | 785 | $query = $GLOBALS['db']->createTableSQLParams($this->bean->table_name."_cstm", $iddef, $ididx); |
786 | - if(!$GLOBALS['db']->supports("inline_keys")) { |
|
786 | + if (!$GLOBALS['db']->supports("inline_keys")) { |
|
787 | 787 | $indicesArr = $GLOBALS['db']->getConstraintSql($ididx, $this->bean->table_name."_cstm"); |
788 | 788 | } else { |
789 | 789 | $indicesArr = array(); |
790 | 790 | } |
791 | - if($execute) { |
|
791 | + if ($execute) { |
|
792 | 792 | $GLOBALS['db']->query($query); |
793 | - if(!empty($indicesArr)) { |
|
794 | - foreach($indicesArr as $idxq) { |
|
793 | + if (!empty($indicesArr)) { |
|
794 | + foreach ($indicesArr as $idxq) { |
|
795 | 795 | $GLOBALS['db']->query($idxq); |
796 | 796 | } |
797 | 797 | } |
798 | 798 | } |
799 | - $out = $query . "\n"; |
|
800 | - if(!empty($indicesArr)) { |
|
799 | + $out = $query."\n"; |
|
800 | + if (!empty($indicesArr)) { |
|
801 | 801 | $out .= join("\n", $indicesArr)."\n"; |
802 | 802 | } |
803 | 803 | |
@@ -811,11 +811,11 @@ discard block |
||
811 | 811 | * Updates the db schema and adds any custom fields we have used if the custom table was dropped |
812 | 812 | * |
813 | 813 | */ |
814 | - function add_existing_custom_fields($execute = true){ |
|
814 | + function add_existing_custom_fields($execute = true) { |
|
815 | 815 | $out = ""; |
816 | - if($this->bean->hasCustomFields()){ |
|
817 | - foreach($this->bean->field_defs as $name=>$data){ |
|
818 | - if(empty($data['source']) || $data['source'] != 'custom_fields') |
|
816 | + if ($this->bean->hasCustomFields()) { |
|
817 | + foreach ($this->bean->field_defs as $name=>$data) { |
|
818 | + if (empty($data['source']) || $data['source'] != 'custom_fields') |
|
819 | 819 | continue; |
820 | 820 | $out .= $this->add_existing_custom_field($data, $execute); |
821 | 821 | } |
@@ -826,11 +826,11 @@ discard block |
||
826 | 826 | function add_existing_custom_field($data, $execute = true) |
827 | 827 | { |
828 | 828 | |
829 | - $field = get_widget ( $data ['type'] ); |
|
829 | + $field = get_widget($data ['type']); |
|
830 | 830 | $field->populateFromRow($data); |
831 | 831 | $query = "/*MISSING IN DATABASE - {$data['name']} - ROW*/\n" |
832 | - . $field->get_db_add_alter_table($this->bean->table_name . '_cstm'); |
|
833 | - $out = $query . "\n"; |
|
832 | + . $field->get_db_add_alter_table($this->bean->table_name.'_cstm'); |
|
833 | + $out = $query."\n"; |
|
834 | 834 | if ($execute) |
835 | 835 | $GLOBALS['db']->query($query); |
836 | 836 | |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | $db = $GLOBALS['db']; |
849 | 849 | $tablename = $this->bean->table_name."_cstm"; |
850 | 850 | $compareFieldDefs = $db->get_columns($tablename); |
851 | - foreach($this->bean->field_defs as $name=>$data){ |
|
852 | - if(empty($data['source']) || $data['source'] != 'custom_fields') |
|
851 | + foreach ($this->bean->field_defs as $name=>$data) { |
|
852 | + if (empty($data['source']) || $data['source'] != 'custom_fields') |
|
853 | 853 | continue; |
854 | 854 | /** |
855 | 855 | * @bug 43471 |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | * force the name to be lower as it needs to be lower since that is how it's put into the key |
860 | 860 | * in the get_columns() call above. |
861 | 861 | */ |
862 | - if(!empty($compareFieldDefs[strtolower($name)])) { |
|
862 | + if (!empty($compareFieldDefs[strtolower($name)])) { |
|
863 | 863 | continue; |
864 | 864 | } |
865 | 865 | $out .= $this->add_existing_custom_field($data, $execute); |
@@ -878,24 +878,24 @@ discard block |
||
878 | 878 | * @return string The core of the system label name - returns currency_id5 for example, when the full label would then be LBL_CURRENCY_ID5 |
879 | 879 | * TODO: Only the core is returned for historical reasons - switch to return the real system label |
880 | 880 | */ |
881 | - function addLabel ( $displayLabel ) |
|
881 | + function addLabel($displayLabel) |
|
882 | 882 | { |
883 | - $mod_strings = return_module_language($GLOBALS[ 'current_language' ], $this->module); |
|
883 | + $mod_strings = return_module_language($GLOBALS['current_language'], $this->module); |
|
884 | 884 | $limit = 10; |
885 | 885 | $count = 0; |
886 | 886 | $field_key = $this->getDBName($displayLabel, false); |
887 | 887 | $systemLabel = $field_key; |
888 | - if(!$this->use_existing_labels){ // use_existing_labels defaults to false in this module; as of today, only set to true by ModuleInstaller.php |
|
889 | - while( isset( $mod_strings [ $systemLabel ] ) && $count <= $limit ) |
|
888 | + if (!$this->use_existing_labels) { // use_existing_labels defaults to false in this module; as of today, only set to true by ModuleInstaller.php |
|
889 | + while (isset($mod_strings [$systemLabel]) && $count <= $limit) |
|
890 | 890 | { |
891 | - $systemLabel = $field_key. "_$count"; |
|
891 | + $systemLabel = $field_key."_$count"; |
|
892 | 892 | $count++; |
893 | 893 | } |
894 | 894 | } |
895 | 895 | $selMod = (!empty($_REQUEST['view_module'])) ? $_REQUEST['view_module'] : $this->module; |
896 | - require_once 'modules/ModuleBuilder/parsers/parser.label.php' ; |
|
897 | - $parser = new ParserLabel ( $selMod , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ; |
|
898 | - $parser->handleSave ( array('label_'. $systemLabel => $displayLabel ) , $GLOBALS [ 'current_language' ] ) ; |
|
896 | + require_once 'modules/ModuleBuilder/parsers/parser.label.php'; |
|
897 | + $parser = new ParserLabel($selMod, isset ($_REQUEST ['view_package']) ? $_REQUEST ['view_package'] : null); |
|
898 | + $parser->handleSave(array('label_'.$systemLabel => $displayLabel), $GLOBALS ['current_language']); |
|
899 | 899 | |
900 | 900 | return $systemLabel; |
901 | 901 | } |
@@ -907,27 +907,27 @@ discard block |
||
907 | 907 | * @param BOOLEAN $_C do we append _c to the name |
908 | 908 | * @return STRING |
909 | 909 | */ |
910 | - function getDBName($name, $_C= true){ |
|
910 | + function getDBName($name, $_C = true) { |
|
911 | 911 | static $cached_results = array(); |
912 | - if(!empty($cached_results[$name])) |
|
912 | + if (!empty($cached_results[$name])) |
|
913 | 913 | { |
914 | 914 | return $cached_results[$name]; |
915 | 915 | } |
916 | 916 | $exclusions = array('parent_type', 'parent_id', 'currency_id', 'parent_name'); |
917 | 917 | // Remove any non-db friendly characters |
918 | - $return_value = preg_replace("/[^\w]+/","_",$name); |
|
919 | - if($_C == true && !in_array($return_value, $exclusions) && substr($return_value, -2) != '_c'){ |
|
918 | + $return_value = preg_replace("/[^\w]+/", "_", $name); |
|
919 | + if ($_C == true && !in_array($return_value, $exclusions) && substr($return_value, -2) != '_c') { |
|
920 | 920 | $return_value .= '_c'; |
921 | 921 | } |
922 | 922 | $cached_results[$name] = $return_value; |
923 | 923 | return $return_value; |
924 | 924 | } |
925 | 925 | |
926 | - function setWhereClauses(&$where_clauses){ |
|
926 | + function setWhereClauses(&$where_clauses) { |
|
927 | 927 | if (isset($this->avail_fields)) { |
928 | - foreach($this->avail_fields as $name=>$value){ |
|
929 | - if(!empty($_REQUEST[$name])){ |
|
930 | - $where_clauses[] = $this->bean->table_name . "_cstm.$name LIKE '". $GLOBALS['db']->quote($_REQUEST[$name]). "%'"; |
|
928 | + foreach ($this->avail_fields as $name=>$value) { |
|
929 | + if (!empty($_REQUEST[$name])) { |
|
930 | + $where_clauses[] = $this->bean->table_name."_cstm.$name LIKE '".$GLOBALS['db']->quote($_REQUEST[$name])."%'"; |
|
931 | 931 | } |
932 | 932 | } |
933 | 933 | } |
@@ -947,12 +947,12 @@ discard block |
||
947 | 947 | |
948 | 948 | function retrieve() |
949 | 949 | { |
950 | - if(!isset($this->bean)){ |
|
950 | + if (!isset($this->bean)) { |
|
951 | 951 | $GLOBALS['log']->fatal("DynamicField retrieve, bean not instantiated: ".var_export(debug_print_backtrace(), true)); |
952 | 952 | return false; |
953 | 953 | } |
954 | 954 | |
955 | - if(!$this->bean->hasCustomFields()){ |
|
955 | + if (!$this->bean->hasCustomFields()) { |
|
956 | 956 | return false; |
957 | 957 | } |
958 | 958 | |
@@ -960,9 +960,9 @@ discard block |
||
960 | 960 | $result = $GLOBALS['db']->query($query); |
961 | 961 | $row = $GLOBALS['db']->fetchByAssoc($result); |
962 | 962 | |
963 | - if($row) |
|
963 | + if ($row) |
|
964 | 964 | { |
965 | - foreach($row as $name=>$value) |
|
965 | + foreach ($row as $name=>$value) |
|
966 | 966 | { |
967 | 967 | // originally in pre-r30895 we checked if this field was in avail_fields i.e., in fields_meta_data and not deleted |
968 | 968 | // with the removal of avail_fields post-r30895 we have simplified this - we now retrieve every custom field even if previously deleted |
@@ -975,12 +975,12 @@ discard block |
||
975 | 975 | |
976 | 976 | function populateXTPL($xtpl, $view) { |
977 | 977 | |
978 | - if($this->bean->hasCustomFields()){ |
|
978 | + if ($this->bean->hasCustomFields()) { |
|
979 | 979 | $results = $this->getAllFieldsView($view, 'xtpl'); |
980 | - foreach($results as $name=>$value){ |
|
981 | - if(is_array($value['xtpl'])) |
|
980 | + foreach ($results as $name=>$value) { |
|
981 | + if (is_array($value['xtpl'])) |
|
982 | 982 | { |
983 | - foreach($value['xtpl'] as $xName=>$xValue) |
|
983 | + foreach ($value['xtpl'] as $xName=>$xValue) |
|
984 | 984 | { |
985 | 985 | $xtpl->assign(strtoupper($xName), $xValue); |
986 | 986 | } |
@@ -992,24 +992,24 @@ discard block |
||
992 | 992 | |
993 | 993 | } |
994 | 994 | |
995 | - function populateAllXTPL($xtpl, $view){ |
|
995 | + function populateAllXTPL($xtpl, $view) { |
|
996 | 996 | $this->populateXTPL($xtpl, $view); |
997 | 997 | |
998 | 998 | } |
999 | 999 | |
1000 | - function getAllFieldsView($view, $type){ |
|
1000 | + function getAllFieldsView($view, $type) { |
|
1001 | 1001 | require_once ('modules/DynamicFields/FieldCases.php'); |
1002 | 1002 | $results = array(); |
1003 | - foreach($this->bean->field_defs as $name=>$data){ |
|
1004 | - if(empty($data['source']) || $data['source'] != 'custom_fields') |
|
1003 | + foreach ($this->bean->field_defs as $name=>$data) { |
|
1004 | + if (empty($data['source']) || $data['source'] != 'custom_fields') |
|
1005 | 1005 | { |
1006 | 1006 | continue; |
1007 | 1007 | } |
1008 | - $field = get_widget ( $data ['type'] ); |
|
1008 | + $field = get_widget($data ['type']); |
|
1009 | 1009 | $field->populateFromRow($data); |
1010 | 1010 | $field->view = $view; |
1011 | 1011 | $field->bean = $this->bean; |
1012 | - switch(strtolower($type)) |
|
1012 | + switch (strtolower($type)) |
|
1013 | 1013 | { |
1014 | 1014 | case 'xtpl': |
1015 | 1015 | $results[$name] = array('xtpl'=>$field->get_xtpl()); |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
2 | +if (! defined ( 'sugarEntry' ) || ! sugarEntry) { |
|
3 | 3 | die ( 'Not A Valid Entry Point' ) ; |
4 | +} |
|
4 | 5 | |
5 | 6 | /********************************************************************************* |
6 | 7 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -58,8 +59,7 @@ discard block |
||
58 | 59 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
59 | 60 | if(isset($GLOBALS['log'])) { |
60 | 61 | $GLOBALS['log']->deprecated($deprecatedMessage); |
61 | - } |
|
62 | - else { |
|
62 | + } else { |
|
63 | 63 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
64 | 64 | } |
65 | 65 | self::__construct($module); |
@@ -117,9 +117,12 @@ discard block |
||
117 | 117 | */ |
118 | 118 | function buildCache($module = false, $saveCache=true) { |
119 | 119 | //We can't build the cache while installing as the required database tables may not exist. |
120 | - if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true|| empty($GLOBALS['db'])) |
|
120 | + if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true|| empty($GLOBALS['db'])) { |
|
121 | + return false; |
|
122 | + } |
|
123 | + if($module == '../data') { |
|
121 | 124 | return false; |
122 | - if($module == '../data')return false; |
|
125 | + } |
|
123 | 126 | |
124 | 127 | static $results = array ( ) ; |
125 | 128 | |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | if (! empty ( $module )) { |
128 | 131 | $where .= " custom_module='$module' AND "; |
129 | 132 | unset( $results[ $module ] ) ; // clear out any old results for the module as $results is declared static |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $results = array ( ) ; // clear out results - if we remove a module we don't want to have its old vardefs hanging around |
134 | 136 | } |
@@ -152,10 +154,12 @@ discard block |
||
152 | 154 | $vardef = $field->get_field_def (); |
153 | 155 | $vardef ['id'] = $row ['id']; |
154 | 156 | $vardef ['custom_module'] = $row ['custom_module']; |
155 | - if (empty ( $vardef ['source'] )) |
|
156 | - $vardef ['source'] = 'custom_fields'; |
|
157 | - if (empty ( $results [$row ['custom_module']] )) |
|
158 | - $results [$row ['custom_module']] = array ( ); |
|
157 | + if (empty ( $vardef ['source'] )) { |
|
158 | + $vardef ['source'] = 'custom_fields'; |
|
159 | + } |
|
160 | + if (empty ( $results [$row ['custom_module']] )) { |
|
161 | + $results [$row ['custom_module']] = array ( ); |
|
162 | + } |
|
159 | 163 | $results [$row ['custom_module']] [$row ['name']] = $vardef; |
160 | 164 | } |
161 | 165 | if (empty ( $module )) { |
@@ -165,7 +169,7 @@ discard block |
||
165 | 169 | } else { |
166 | 170 | if (! empty ( $results [$module] )) { |
167 | 171 | $this->saveToVardef ( $module, $results [$module], $saveCache); |
168 | - }else{ |
|
172 | + } else{ |
|
169 | 173 | $this->saveToVardef ( $module, false, $saveCache); |
170 | 174 | } |
171 | 175 | } |
@@ -210,7 +214,9 @@ discard block |
||
210 | 214 | //if the vardef isn't loaded let's try loading it. |
211 | 215 | VardefManager::refreshVardefs($module,$object, null, false); |
212 | 216 | //if it's still not loaded we really don't have anything useful to cache |
213 | - if(empty($GLOBALS['dictionary'][$object]['fields']))return; |
|
217 | + if(empty($GLOBALS['dictionary'][$object]['fields'])) { |
|
218 | + return; |
|
219 | + } |
|
214 | 220 | } |
215 | 221 | if (!isset($GLOBALS['dictionary'][$object]['custom_fields'])) { |
216 | 222 | $GLOBALS['dictionary'][$object]['custom_fields'] = false; |
@@ -280,8 +286,7 @@ discard block |
||
280 | 286 | if (empty($expandedList) ) |
281 | 287 | { |
282 | 288 | $select = ",{$this->bean->table_name}_cstm.*" ; |
283 | - } |
|
284 | - else |
|
289 | + } else |
|
285 | 290 | { |
286 | 291 | $select = ''; |
287 | 292 | $isList = is_array($expandedList); |
@@ -290,8 +295,9 @@ discard block |
||
290 | 295 | if (!empty($field['source']) && $field['source'] == 'custom_fields' && (!$isList || !empty($expandedList[$name]))){ |
291 | 296 | // assumption: that the column name in _cstm is the same as the field name. Currently true. |
292 | 297 | // however, two types of dynamic fields do not have columns in the custom table - html fields (they're readonly) and flex relates (parent_name doesn't exist) |
293 | - if ( $field['type'] != 'html' && $name != 'parent_name') |
|
294 | - $select .= ",{$this->bean->table_name}_cstm.{$name}" ; |
|
298 | + if ( $field['type'] != 'html' && $name != 'parent_name') { |
|
299 | + $select .= ",{$this->bean->table_name}_cstm.{$name}" ; |
|
300 | + } |
|
295 | 301 | } |
296 | 302 | } |
297 | 303 | } |
@@ -346,8 +352,7 @@ discard block |
||
346 | 352 | else if(!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == "non-db" && !empty($field_def['rname'])) |
347 | 353 | { |
348 | 354 | $name_field = "$joinTableAlias." . $field_def['rname']; |
349 | - } |
|
350 | - else |
|
355 | + } else |
|
351 | 356 | { |
352 | 357 | $name_field = "$joinTableAlias.name"; |
353 | 358 | } |
@@ -369,12 +374,16 @@ discard block |
||
369 | 374 | function fill_relationships(){ |
370 | 375 | global $beanList, $beanFiles; |
371 | 376 | if(!empty($this->bean->relDepth)) { |
372 | - if($this->bean->relDepth > 1)return; |
|
373 | - }else{ |
|
377 | + if($this->bean->relDepth > 1) { |
|
378 | + return; |
|
379 | + } |
|
380 | + } else{ |
|
374 | 381 | $this->bean->relDepth = 0; |
375 | 382 | } |
376 | 383 | foreach($this->bean->field_defs as $field){ |
377 | - if(empty($field['source']) || $field['source'] != 'custom_fields')continue; |
|
384 | + if(empty($field['source']) || $field['source'] != 'custom_fields') { |
|
385 | + continue; |
|
386 | + } |
|
378 | 387 | if($field['type'] == 'relate'){ |
379 | 388 | $related_module =$field['ext2']; |
380 | 389 | $name = $field['name']; |
@@ -413,8 +422,12 @@ discard block |
||
413 | 422 | $first = true; |
414 | 423 | foreach($this->bean->field_defs as $name=>$field){ |
415 | 424 | |
416 | - if(empty($field['source']) || $field['source'] != 'custom_fields')continue; |
|
417 | - if($field['type'] == 'html' || $field['type'] == 'parent')continue; |
|
425 | + if(empty($field['source']) || $field['source'] != 'custom_fields') { |
|
426 | + continue; |
|
427 | + } |
|
428 | + if($field['type'] == 'html' || $field['type'] == 'parent') { |
|
429 | + continue; |
|
430 | + } |
|
418 | 431 | if(isset($this->bean->$name)){ |
419 | 432 | $quote = "'"; |
420 | 433 | |
@@ -423,16 +436,17 @@ discard block |
||
423 | 436 | if(!isset($this->bean->$name) || !is_numeric($this->bean->$name) ){ |
424 | 437 | if($field['required']){ |
425 | 438 | $this->bean->$name = 0; |
426 | - }else{ |
|
439 | + } else{ |
|
427 | 440 | $this->bean->$name = 'NULL'; |
428 | 441 | } |
429 | 442 | } |
430 | 443 | } |
431 | 444 | if ( $field['type'] == 'bool' ) { |
432 | - if ( $this->bean->$name === FALSE ) |
|
433 | - $this->bean->$name = '0'; |
|
434 | - elseif ( $this->bean->$name === TRUE ) |
|
435 | - $this->bean->$name = '1'; |
|
445 | + if ( $this->bean->$name === FALSE ) { |
|
446 | + $this->bean->$name = '0'; |
|
447 | + } elseif ( $this->bean->$name === TRUE ) { |
|
448 | + $this->bean->$name = '1'; |
|
449 | + } |
|
436 | 450 | } |
437 | 451 | |
438 | 452 | $val = $this->bean->$name; |
@@ -445,7 +459,7 @@ discard block |
||
445 | 459 | if($first){ |
446 | 460 | $query .= " $name=$quote".$GLOBALS['db']->quote($val)."$quote"; |
447 | 461 | |
448 | - }else{ |
|
462 | + } else{ |
|
449 | 463 | $query .= " ,$name=$quote".$GLOBALS['db']->quote($val)."$quote"; |
450 | 464 | } |
451 | 465 | } |
@@ -464,7 +478,7 @@ discard block |
||
464 | 478 | if(!$first){ |
465 | 479 | if(!$isUpdate){ |
466 | 480 | $GLOBALS['db']->query($queryInsert); |
467 | - }else{ |
|
481 | + } else{ |
|
468 | 482 | $checkquery = "SELECT id_c FROM {$this->bean->table_name}_cstm WHERE id_c = '{$this->bean->id}'"; |
469 | 483 | if ( $GLOBALS['db']->getOne($checkquery) ) { |
470 | 484 | $result = $GLOBALS['db']->query($query); |
@@ -499,8 +513,9 @@ discard block |
||
499 | 513 | |
500 | 514 | $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='" . $this->module . $widget->name . "'"); |
501 | 515 | $sql = $widget->get_db_delete_alter_table( $this->bean->table_name . "_cstm" ) ; |
502 | - if (! empty( $sql ) ) |
|
503 | - $GLOBALS['db']->query( $sql ); |
|
516 | + if (! empty( $sql ) ) { |
|
517 | + $GLOBALS['db']->query( $sql ); |
|
518 | + } |
|
504 | 519 | |
505 | 520 | $this->removeVardefExtension($widget); |
506 | 521 | VardefManager::clearVardef(); |
@@ -518,19 +533,21 @@ discard block |
||
518 | 533 | $name = $this->getDBName($name); |
519 | 534 | $vardefs = $GLOBALS['dictionary'][$this->bean->object_name]['fields']; |
520 | 535 | if(!empty($vardefs)){ |
521 | - if(empty($type) && empty($name)) |
|
522 | - return false; |
|
523 | - else if(empty($type)) |
|
524 | - return !empty($vardefs[$name]); |
|
525 | - else if(empty($name)){ |
|
536 | + if(empty($type) && empty($name)) { |
|
537 | + return false; |
|
538 | + } else if(empty($type)) { |
|
539 | + return !empty($vardefs[$name]); |
|
540 | + } else if(empty($name)){ |
|
526 | 541 | foreach($vardefs as $def){ |
527 | - if(!empty($def['type']) && $def['type'] == $type) |
|
528 | - return true; |
|
542 | + if(!empty($def['type']) && $def['type'] == $type) { |
|
543 | + return true; |
|
544 | + } |
|
529 | 545 | } |
530 | 546 | return false; |
531 | - }else |
|
532 | - return (!empty($vardefs[$name]) && ($vardefs[$name]['type'] == $type)); |
|
533 | - }else{ |
|
547 | + } else { |
|
548 | + return (!empty($vardefs[$name]) && ($vardefs[$name]['type'] == $type)); |
|
549 | + } |
|
550 | + } else{ |
|
534 | 551 | return false; |
535 | 552 | } |
536 | 553 | } |
@@ -553,7 +570,7 @@ discard block |
||
553 | 570 | $label = strtoupper( $field->label ); |
554 | 571 | if(!empty($id)){ |
555 | 572 | $is_update = true; |
556 | - }else{ |
|
573 | + } else{ |
|
557 | 574 | $db_name = $this->getDBName($field->name); |
558 | 575 | $field->name = $db_name; |
559 | 576 | } |
@@ -564,8 +581,10 @@ discard block |
||
564 | 581 | $fmd->vname = $label; |
565 | 582 | $fmd->type = $field->type; |
566 | 583 | $fmd->help = $field->help; |
567 | - if (!empty($field->len)) |
|
568 | - $fmd->len = $field->len; // tyoung bug 15407 - was being set to $field->size so changes weren't being saved |
|
584 | + if (!empty($field->len)) { |
|
585 | + $fmd->len = $field->len; |
|
586 | + } |
|
587 | + // tyoung bug 15407 - was being set to $field->size so changes weren't being saved |
|
569 | 588 | $fmd->required = ($field->required ? 1 : 0); |
570 | 589 | $fmd->default_value = $field->default; |
571 | 590 | $fmd->ext1 = $field->ext1; |
@@ -605,7 +624,7 @@ discard block |
||
605 | 624 | $GLOBALS['db']->query($query, true, "Cannot set default"); |
606 | 625 | } |
607 | 626 | } |
608 | - }else{ |
|
627 | + } else{ |
|
609 | 628 | $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm'); |
610 | 629 | if(!empty($query)){ |
611 | 630 | $GLOBALS['db']->query($query, true, "Cannot modify field"); |
@@ -685,16 +704,16 @@ discard block |
||
685 | 704 | |
686 | 705 | $out .= "\n ?>"; |
687 | 706 | |
688 | - if (!file_exists($this->base_path)) |
|
689 | - mkdir_recursive($this->base_path); |
|
707 | + if (!file_exists($this->base_path)) { |
|
708 | + mkdir_recursive($this->base_path); |
|
709 | + } |
|
690 | 710 | |
691 | 711 | if( $fh = @sugar_fopen( $file_loc, 'w' ) ) |
692 | 712 | { |
693 | 713 | fputs( $fh, $out); |
694 | 714 | fclose( $fh ); |
695 | 715 | return true ; |
696 | - } |
|
697 | - else |
|
716 | + } else |
|
698 | 717 | { |
699 | 718 | return false ; |
700 | 719 | } |
@@ -815,8 +834,9 @@ discard block |
||
815 | 834 | $out = ""; |
816 | 835 | if($this->bean->hasCustomFields()){ |
817 | 836 | foreach($this->bean->field_defs as $name=>$data){ |
818 | - if(empty($data['source']) || $data['source'] != 'custom_fields') |
|
819 | - continue; |
|
837 | + if(empty($data['source']) || $data['source'] != 'custom_fields') { |
|
838 | + continue; |
|
839 | + } |
|
820 | 840 | $out .= $this->add_existing_custom_field($data, $execute); |
821 | 841 | } |
822 | 842 | } |
@@ -831,8 +851,9 @@ discard block |
||
831 | 851 | $query = "/*MISSING IN DATABASE - {$data['name']} - ROW*/\n" |
832 | 852 | . $field->get_db_add_alter_table($this->bean->table_name . '_cstm'); |
833 | 853 | $out = $query . "\n"; |
834 | - if ($execute) |
|
835 | - $GLOBALS['db']->query($query); |
|
854 | + if ($execute) { |
|
855 | + $GLOBALS['db']->query($query); |
|
856 | + } |
|
836 | 857 | |
837 | 858 | return $out; |
838 | 859 | } |
@@ -841,16 +862,18 @@ discard block |
||
841 | 862 | { |
842 | 863 | $out = $this->createCustomTable($execute); |
843 | 864 | //If the table didn't exist, createCustomTable will have returned all the SQL to create and populate it |
844 | - if (!empty($out)) |
|
845 | - return "/*Checking Custom Fields for module : {$this->module} */\n$out"; |
|
865 | + if (!empty($out)) { |
|
866 | + return "/*Checking Custom Fields for module : {$this->module} */\n$out"; |
|
867 | + } |
|
846 | 868 | //Otherwise make sure all the custom fields defined in the vardefs exist in the custom table. |
847 | 869 | //We aren't checking for data types, just that the column exists. |
848 | 870 | $db = $GLOBALS['db']; |
849 | 871 | $tablename = $this->bean->table_name."_cstm"; |
850 | 872 | $compareFieldDefs = $db->get_columns($tablename); |
851 | 873 | foreach($this->bean->field_defs as $name=>$data){ |
852 | - if(empty($data['source']) || $data['source'] != 'custom_fields') |
|
853 | - continue; |
|
874 | + if(empty($data['source']) || $data['source'] != 'custom_fields') { |
|
875 | + continue; |
|
876 | + } |
|
854 | 877 | /** |
855 | 878 | * @bug 43471 |
856 | 879 | * @issue 43471 |
@@ -864,8 +887,9 @@ discard block |
||
864 | 887 | } |
865 | 888 | $out .= $this->add_existing_custom_field($data, $execute); |
866 | 889 | } |
867 | - if (!empty($out)) |
|
868 | - $out = "/*Checking Custom Fields for module : {$this->module} */\n$out"; |
|
890 | + if (!empty($out)) { |
|
891 | + $out = "/*Checking Custom Fields for module : {$this->module} */\n$out"; |
|
892 | + } |
|
869 | 893 | |
870 | 894 | return $out; |
871 | 895 | } |
@@ -51,75 +51,75 @@ discard block |
||
51 | 51 | |
52 | 52 | |
53 | 53 | class FieldsMetaData extends SugarBean { |
54 | - // database table columns |
|
55 | - var $id; |
|
56 | - var $name; |
|
57 | - var $vname; |
|
58 | - var $custom_module; |
|
59 | - var $type; |
|
60 | - var $len; |
|
61 | - var $required; |
|
62 | - var $default_value; |
|
63 | - var $deleted; |
|
64 | - var $ext1; |
|
65 | - var $ext2; |
|
66 | - var $ext3; |
|
67 | - var $audited; |
|
68 | - var $inline_edit; |
|
54 | + // database table columns |
|
55 | + var $id; |
|
56 | + var $name; |
|
57 | + var $vname; |
|
58 | + var $custom_module; |
|
59 | + var $type; |
|
60 | + var $len; |
|
61 | + var $required; |
|
62 | + var $default_value; |
|
63 | + var $deleted; |
|
64 | + var $ext1; |
|
65 | + var $ext2; |
|
66 | + var $ext3; |
|
67 | + var $audited; |
|
68 | + var $inline_edit; |
|
69 | 69 | var $duplicate_merge; |
70 | 70 | var $reportable; |
71 | - var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
72 | - |
|
73 | - var $table_name = 'fields_meta_data'; |
|
74 | - var $object_name = 'FieldsMetaData'; |
|
75 | - var $module_dir = 'DynamicFields'; |
|
76 | - var $column_fields = array( |
|
77 | - 'id', |
|
78 | - 'name', |
|
79 | - 'vname', |
|
80 | - 'custom_module', |
|
81 | - 'type', |
|
82 | - 'len', |
|
83 | - 'required', |
|
84 | - 'default_value', |
|
85 | - 'deleted', |
|
86 | - 'ext1', |
|
87 | - 'ext2', |
|
88 | - 'ext3', |
|
89 | - 'audited', |
|
90 | - 'inline_edit', |
|
91 | - 'massupdate', |
|
71 | + var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
72 | + |
|
73 | + var $table_name = 'fields_meta_data'; |
|
74 | + var $object_name = 'FieldsMetaData'; |
|
75 | + var $module_dir = 'DynamicFields'; |
|
76 | + var $column_fields = array( |
|
77 | + 'id', |
|
78 | + 'name', |
|
79 | + 'vname', |
|
80 | + 'custom_module', |
|
81 | + 'type', |
|
82 | + 'len', |
|
83 | + 'required', |
|
84 | + 'default_value', |
|
85 | + 'deleted', |
|
86 | + 'ext1', |
|
87 | + 'ext2', |
|
88 | + 'ext3', |
|
89 | + 'audited', |
|
90 | + 'inline_edit', |
|
91 | + 'massupdate', |
|
92 | 92 | 'duplicate_merge', |
93 | 93 | 'reportable', |
94 | - ); |
|
95 | - |
|
96 | - var $list_fields = array( |
|
97 | - 'id', |
|
98 | - 'name', |
|
99 | - 'vname', |
|
100 | - 'type', |
|
101 | - 'len', |
|
102 | - 'required', |
|
103 | - 'default_value', |
|
104 | - 'audited', |
|
94 | + ); |
|
95 | + |
|
96 | + var $list_fields = array( |
|
97 | + 'id', |
|
98 | + 'name', |
|
99 | + 'vname', |
|
100 | + 'type', |
|
101 | + 'len', |
|
102 | + 'required', |
|
103 | + 'default_value', |
|
104 | + 'audited', |
|
105 | 105 | 'inline_edit', |
106 | - 'massupdate', |
|
106 | + 'massupdate', |
|
107 | 107 | 'duplicate_merge', |
108 | 108 | 'reportable', |
109 | - ); |
|
109 | + ); |
|
110 | 110 | |
111 | - var $field_name_map; |
|
112 | - var $new_schema = true; |
|
111 | + var $field_name_map; |
|
112 | + var $new_schema = true; |
|
113 | 113 | |
114 | - ////////////////////////////////////////////////////////////////// |
|
115 | - // METHODS |
|
116 | - ////////////////////////////////////////////////////////////////// |
|
114 | + ////////////////////////////////////////////////////////////////// |
|
115 | + // METHODS |
|
116 | + ////////////////////////////////////////////////////////////////// |
|
117 | 117 | |
118 | 118 | public function __construct() |
119 | - { |
|
120 | - parent::__construct(); |
|
121 | - $this->disable_row_level_security = true; |
|
122 | - } |
|
119 | + { |
|
120 | + parent::__construct(); |
|
121 | + $this->disable_row_level_security = true; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | |
139 | - function mark_deleted($id) |
|
140 | - { |
|
141 | - $query = "DELETE FROM $this->table_name WHERE id='$id'"; |
|
142 | - $this->db->query($query, true,"Error deleting record: "); |
|
143 | - $this->mark_relationships_deleted($id); |
|
139 | + function mark_deleted($id) |
|
140 | + { |
|
141 | + $query = "DELETE FROM $this->table_name WHERE id='$id'"; |
|
142 | + $this->db->query($query, true,"Error deleting record: "); |
|
143 | + $this->mark_relationships_deleted($id); |
|
144 | 144 | |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - function get_list_view_data(){ |
|
148 | - $data = parent::get_list_view_data(); |
|
149 | - $data['VNAME'] = translate($this->vname, $this->custom_module); |
|
150 | - $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >'; |
|
151 | - return $data; |
|
152 | - } |
|
147 | + function get_list_view_data(){ |
|
148 | + $data = parent::get_list_view_data(); |
|
149 | + $data['VNAME'] = translate($this->vname, $this->custom_module); |
|
150 | + $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >'; |
|
151 | + return $data; |
|
152 | + } |
|
153 | 153 | |
154 | 154 | |
155 | - function get_summary_text() |
|
156 | - { |
|
157 | - return $this->name; |
|
158 | - } |
|
155 | + function get_summary_text() |
|
156 | + { |
|
157 | + return $this->name; |
|
158 | + } |
|
159 | 159 | } |
160 | 160 | ?> |
@@ -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. |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | var $inline_edit; |
69 | 69 | var $duplicate_merge; |
70 | 70 | var $reportable; |
71 | - var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
71 | + var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,); |
|
72 | 72 | |
73 | 73 | var $table_name = 'fields_meta_data'; |
74 | 74 | var $object_name = 'FieldsMetaData'; |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
126 | 126 | */ |
127 | - public function FieldsMetaData(){ |
|
127 | + public function FieldsMetaData() { |
|
128 | 128 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
129 | - if(isset($GLOBALS['log'])) { |
|
129 | + if (isset($GLOBALS['log'])) { |
|
130 | 130 | $GLOBALS['log']->deprecated($deprecatedMessage); |
131 | 131 | } |
132 | 132 | else { |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | function mark_deleted($id) |
140 | 140 | { |
141 | 141 | $query = "DELETE FROM $this->table_name WHERE id='$id'"; |
142 | - $this->db->query($query, true,"Error deleting record: "); |
|
142 | + $this->db->query($query, true, "Error deleting record: "); |
|
143 | 143 | $this->mark_relationships_deleted($id); |
144 | 144 | |
145 | 145 | } |
146 | 146 | |
147 | - function get_list_view_data(){ |
|
147 | + function get_list_view_data() { |
|
148 | 148 | $data = parent::get_list_view_data(); |
149 | 149 | $data['VNAME'] = translate($this->vname, $this->custom_module); |
150 | - $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >'; |
|
150 | + $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="'.$this->id.'"> <a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record='.$this->id.'" >'; |
|
151 | 151 | return $data; |
152 | 152 | } |
153 | 153 |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | * Date: 06/03/15 |
44 | 44 | * Comments |
45 | 45 | */ |
46 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
46 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
47 | + die('Not A Valid Entry Point'); |
|
48 | +} |
|
47 | 49 | |
48 | 50 | class CasesController extends SugarController { |
49 | 51 | |
@@ -90,8 +92,7 @@ discard block |
||
90 | 92 | $count++; |
91 | 93 | } |
92 | 94 | echo '</table>'; |
93 | - } |
|
94 | - else { |
|
95 | + } else { |
|
95 | 96 | echo $mod_strings['LBL_NO_SUGGESTIONS']; |
96 | 97 | } |
97 | 98 | die(); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | if (!empty($reminderBeans)) { |
243 | 243 | foreach ($reminderBeans as $reminderBean) { |
244 | 244 | $eventBean = BeanFactory::getBean($reminderBean->related_event_module, $reminderBean->related_event_module_id); |
245 | - if($eventBean) { |
|
245 | + if ($eventBean) { |
|
246 | 246 | $remind_ts = $timedate->fromUser($eventBean->date_start)->modify("-{$reminderBean->timer_email} seconds")->ts; |
247 | 247 | $now_ts = $timedate->getNow()->ts; |
248 | 248 | if ($now_ts >= $remind_ts) { |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $timeRemind = $popupReminder->timer_popup; |
326 | 326 | $timeStart -= $timeRemind; |
327 | 327 | |
328 | - $url = 'index.php?action=DetailView&module=' . $popupReminder->related_event_module . '&record=' . $popupReminder->related_event_module_id; |
|
328 | + $url = 'index.php?action=DetailView&module='.$popupReminder->related_event_module.'&record='.$popupReminder->related_event_module_id; |
|
329 | 329 | $instructions = $app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG']; |
330 | 330 | |
331 | 331 | if ($popupReminder->related_event_module == 'Meetings') { |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | |
346 | 346 | $relatedToMeeting = $alert->getRelatedName($popupReminder->related_event_module, $popupReminder->related_event_module_id); |
347 | 347 | |
348 | - $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'] . $desc1 . "\n"; |
|
349 | - $description = $description . "\n" . $app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'] . (isset($relatedEvent->status) ? $relatedEvent->status : '') . "\n" . $app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO'] . $relatedToMeeting; |
|
348 | + $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'].$desc1."\n"; |
|
349 | + $description = $description."\n".$app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'].(isset($relatedEvent->status) ? $relatedEvent->status : '')."\n".$app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO'].$relatedToMeeting; |
|
350 | 350 | |
351 | 351 | |
352 | 352 | if (isset($relatedEvent->date_start)) { |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | |
365 | 365 | // standard functionality |
366 | 366 | $alert->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING'], $meetingName, |
367 | - $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'] . $time, |
|
368 | - $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'] . $location . |
|
369 | - $description . |
|
367 | + $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$time, |
|
368 | + $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'].$location. |
|
369 | + $description. |
|
370 | 370 | $instructions, |
371 | 371 | $timeStart - strtotime($alertDateTimeNow), |
372 | 372 | $url |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | |
430 | 430 | private function upgradeEventPersonQuery(SugarBean $event, $person_table) |
431 | 431 | { |
432 | - $eventIdField = strtolower($event->object_name) . '_id'; |
|
432 | + $eventIdField = strtolower($event->object_name).'_id'; |
|
433 | 433 | $query = " |
434 | 434 | SELECT * FROM {$event->table_name}_{$person_table} |
435 | 435 | WHERE |
@@ -443,9 +443,9 @@ discard block |
||
443 | 443 | { |
444 | 444 | $eventIdField = array_search($event->table_name, $event->relationship_fields); |
445 | 445 | if (!$eventIdField) { |
446 | - $eventIdField = strtolower($event->object_name . '_id'); |
|
446 | + $eventIdField = strtolower($event->object_name.'_id'); |
|
447 | 447 | } |
448 | - $personIdField = strtolower($person->object_name) . '_id'; |
|
448 | + $personIdField = strtolower($person->object_name).'_id'; |
|
449 | 449 | $query = " |
450 | 450 | SELECT * FROM {$event->table_name}_{$person->table_name} |
451 | 451 | WHERE |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
3 | - die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) |
|
3 | + die ('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -39,107 +39,107 @@ discard block |
||
39 | 39 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
40 | 40 | ********************************************************************************/ |
41 | 41 | |
42 | -include ('include/modules.php') ; |
|
42 | +include ('include/modules.php'); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | -global $db, $mod_strings ; |
|
47 | -$log = & $GLOBALS [ 'log' ] ; |
|
46 | +global $db, $mod_strings; |
|
47 | +$log = & $GLOBALS ['log']; |
|
48 | 48 | |
49 | -$query = "DELETE FROM relationships" ; |
|
50 | -$db->query ( $query ) ; |
|
49 | +$query = "DELETE FROM relationships"; |
|
50 | +$db->query($query); |
|
51 | 51 | |
52 | 52 | //clear cache before proceeding.. |
53 | -VardefManager::clearVardef () ; |
|
53 | +VardefManager::clearVardef(); |
|
54 | 54 | |
55 | 55 | // loop through all of the modules and create entries in the Relationships table (the relationships metadata) for every standard relationship, that is, relationships defined in the /modules/<module>/vardefs.php |
56 | 56 | // SugarBean::createRelationshipMeta just takes the relationship definition in a file and inserts it as is into the Relationships table |
57 | 57 | // It does not override or recreate existing relationships |
58 | -foreach ( $GLOBALS['beanFiles'] as $bean => $file ) |
|
58 | +foreach ($GLOBALS['beanFiles'] as $bean => $file) |
|
59 | 59 | { |
60 | - if (strlen ( $file ) > 0 && file_exists ( $file )) |
|
60 | + if (strlen($file) > 0 && file_exists($file)) |
|
61 | 61 | { |
62 | - if (! class_exists ( $bean )) |
|
62 | + if (!class_exists($bean)) |
|
63 | 63 | { |
64 | - require ($file) ; |
|
64 | + require ($file); |
|
65 | 65 | } |
66 | - $focus = new $bean ( ) ; |
|
67 | - if ( $focus instanceOf SugarBean ) { |
|
68 | - $table_name = $focus->table_name ; |
|
69 | - $empty = array() ; |
|
70 | - if (empty ( $_REQUEST [ 'silent' ] )) |
|
71 | - echo $mod_strings [ 'LBL_REBUILD_REL_PROC_META' ] . $focus->table_name . "..." ; |
|
72 | - SugarBean::createRelationshipMeta ( $focus->getObjectName (), $db, $table_name, $empty, $focus->module_dir ) ; |
|
73 | - if (empty ( $_REQUEST [ 'silent' ] )) |
|
74 | - echo $mod_strings [ 'LBL_DONE' ] . '<br>' ; |
|
66 | + $focus = new $bean( ); |
|
67 | + if ($focus instanceOf SugarBean) { |
|
68 | + $table_name = $focus->table_name; |
|
69 | + $empty = array(); |
|
70 | + if (empty ($_REQUEST ['silent'])) |
|
71 | + echo $mod_strings ['LBL_REBUILD_REL_PROC_META'].$focus->table_name."..."; |
|
72 | + SugarBean::createRelationshipMeta($focus->getObjectName(), $db, $table_name, $empty, $focus->module_dir); |
|
73 | + if (empty ($_REQUEST ['silent'])) |
|
74 | + echo $mod_strings ['LBL_DONE'].'<br>'; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | // do the same for custom relationships (true in the last parameter to SugarBean::createRelationshipMeta) - that is, relationships defined in the custom/modules/<modulename>/Ext/vardefs/ area |
80 | -foreach ( $GLOBALS['beanFiles'] as $bean => $file ) |
|
80 | +foreach ($GLOBALS['beanFiles'] as $bean => $file) |
|
81 | 81 | { |
82 | 82 | //skip this file if it does not exist |
83 | - if(!file_exists($file)) continue; |
|
83 | + if (!file_exists($file)) continue; |
|
84 | 84 | |
85 | - if (! class_exists ( $bean )) |
|
85 | + if (!class_exists($bean)) |
|
86 | 86 | { |
87 | - require ($file) ; |
|
87 | + require ($file); |
|
88 | 88 | } |
89 | - $focus = new $bean ( ) ; |
|
90 | - if ( $focus instanceOf SugarBean ) { |
|
91 | - $table_name = $focus->table_name ; |
|
92 | - $empty = array() ; |
|
93 | - if (empty ( $_REQUEST [ 'silent' ] )) |
|
94 | - echo $mod_strings [ 'LBL_REBUILD_REL_PROC_C_META' ] . $focus->table_name . "..." ; |
|
95 | - SugarBean::createRelationshipMeta ( $focus->getObjectName (), $db, $table_name, $empty, $focus->module_dir, true ) ; |
|
96 | - if (empty ( $_REQUEST [ 'silent' ] )) |
|
97 | - echo $mod_strings [ 'LBL_DONE' ] . '<br>' ; |
|
89 | + $focus = new $bean( ); |
|
90 | + if ($focus instanceOf SugarBean) { |
|
91 | + $table_name = $focus->table_name; |
|
92 | + $empty = array(); |
|
93 | + if (empty ($_REQUEST ['silent'])) |
|
94 | + echo $mod_strings ['LBL_REBUILD_REL_PROC_C_META'].$focus->table_name."..."; |
|
95 | + SugarBean::createRelationshipMeta($focus->getObjectName(), $db, $table_name, $empty, $focus->module_dir, true); |
|
96 | + if (empty ($_REQUEST ['silent'])) |
|
97 | + echo $mod_strings ['LBL_DONE'].'<br>'; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | // finally, whip through the list of relationships defined in TableDictionary.php, that is all the relationships in the metadata directory, and install those |
102 | - $dictionary = array ( ) ; |
|
103 | - require ('modules/TableDictionary.php') ; |
|
102 | + $dictionary = array( ); |
|
103 | + require ('modules/TableDictionary.php'); |
|
104 | 104 | //for module installer incase we already loaded the table dictionary |
105 | - if (file_exists ( 'custom/application/Ext/TableDictionary/tabledictionary.ext.php' )) |
|
105 | + if (file_exists('custom/application/Ext/TableDictionary/tabledictionary.ext.php')) |
|
106 | 106 | { |
107 | - include ('custom/application/Ext/TableDictionary/tabledictionary.ext.php') ; |
|
107 | + include ('custom/application/Ext/TableDictionary/tabledictionary.ext.php'); |
|
108 | 108 | } |
109 | - $rel_dictionary = $dictionary ; |
|
110 | - foreach ( $rel_dictionary as $rel_name => $rel_data ) |
|
109 | + $rel_dictionary = $dictionary; |
|
110 | + foreach ($rel_dictionary as $rel_name => $rel_data) |
|
111 | 111 | { |
112 | - $table = isset($rel_data [ 'table' ]) ? $rel_data [ 'table' ] : "" ; |
|
112 | + $table = isset($rel_data ['table']) ? $rel_data ['table'] : ""; |
|
113 | 113 | |
114 | - if (empty ( $_REQUEST [ 'silent' ] )) |
|
115 | - echo $mod_strings [ 'LBL_REBUILD_REL_PROC_C_META' ] . $rel_name . "..." ; |
|
116 | - SugarBean::createRelationshipMeta ( $rel_name, $db, $table, $rel_dictionary, '' ) ; |
|
117 | - if (empty ( $_REQUEST [ 'silent' ] )) |
|
118 | - echo $mod_strings [ 'LBL_DONE' ] . '<br>' ; |
|
114 | + if (empty ($_REQUEST ['silent'])) |
|
115 | + echo $mod_strings ['LBL_REBUILD_REL_PROC_C_META'].$rel_name."..."; |
|
116 | + SugarBean::createRelationshipMeta($rel_name, $db, $table, $rel_dictionary, ''); |
|
117 | + if (empty ($_REQUEST ['silent'])) |
|
118 | + echo $mod_strings ['LBL_DONE'].'<br>'; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | //clean relationship cache..will be rebuilt upon first access. |
122 | -if (empty ( $_REQUEST [ 'silent' ] )) |
|
123 | - echo $mod_strings [ 'LBL_REBUILD_REL_DEL_CACHE' ] ; |
|
124 | -Relationship::delete_cache () ; |
|
122 | +if (empty ($_REQUEST ['silent'])) |
|
123 | + echo $mod_strings ['LBL_REBUILD_REL_DEL_CACHE']; |
|
124 | +Relationship::delete_cache(); |
|
125 | 125 | |
126 | 126 | ////////////////////////////////////////////////////////////////////////////// |
127 | 127 | // Remove the "Rebuild Relationships" red text message on admin logins |
128 | 128 | |
129 | 129 | |
130 | -if (empty ( $_REQUEST [ 'silent' ] )) |
|
131 | - echo $mod_strings [ 'LBL_REBUILD_REL_UPD_WARNING' ] ; |
|
130 | +if (empty ($_REQUEST ['silent'])) |
|
131 | + echo $mod_strings ['LBL_REBUILD_REL_UPD_WARNING']; |
|
132 | 132 | |
133 | 133 | $rel = new Relationship(); |
134 | 134 | Relationship::delete_cache(); |
135 | 135 | $rel->build_relationship_cache(); |
136 | 136 | |
137 | 137 | // unset the session variable so it is not picked up in DisplayWarnings.php |
138 | -if (isset ( $_SESSION [ 'rebuild_relationships' ] )) |
|
138 | +if (isset ($_SESSION ['rebuild_relationships'])) |
|
139 | 139 | { |
140 | - unset ( $_SESSION [ 'rebuild_relationships' ] ) ; |
|
140 | + unset ($_SESSION ['rebuild_relationships']); |
|
141 | 141 | } |
142 | 142 | |
143 | -if (empty ( $_REQUEST [ 'silent' ] )) |
|
144 | - echo $mod_strings [ 'LBL_DONE' ] ; |
|
143 | +if (empty ($_REQUEST ['silent'])) |
|
144 | + echo $mod_strings ['LBL_DONE']; |
|
145 | 145 | ?> |