@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | 'relate' => 'varchar', |
141 | 141 | 'multienum'=> 'text', |
142 | 142 | 'html' => 'text', |
143 | - 'longhtml' => 'text', |
|
144 | - 'datetime' => 'datetime', |
|
143 | + 'longhtml' => 'text', |
|
144 | + 'datetime' => 'datetime', |
|
145 | 145 | 'datetimecombo' => 'datetime', |
146 | 146 | 'time' => 'datetime', |
147 | 147 | 'bool' => 'bit', |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'url' => 'varchar', |
157 | 157 | 'encrypt' => 'varchar', |
158 | 158 | 'file' => 'varchar', |
159 | - 'decimal_tpl' => 'decimal(%d, %d)', |
|
159 | + 'decimal_tpl' => 'decimal(%d, %d)', |
|
160 | 160 | ); |
161 | 161 | |
162 | 162 | protected $connectOptions = null; |
@@ -236,16 +236,16 @@ discard block |
||
236 | 236 | //it will throw an Unable to select database message. |
237 | 237 | |
238 | 238 | if(!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)){ |
239 | - $connected = false; |
|
240 | - for($i=0;$i<5;$i++){ |
|
241 | - usleep(200000); |
|
242 | - if(@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
243 | - $connected = true; |
|
244 | - break; |
|
245 | - } |
|
246 | - } |
|
247 | - if(!$connected){ |
|
248 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}"); |
|
239 | + $connected = false; |
|
240 | + for($i=0;$i<5;$i++){ |
|
241 | + usleep(200000); |
|
242 | + if(@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
243 | + $connected = true; |
|
244 | + break; |
|
245 | + } |
|
246 | + } |
|
247 | + if(!$connected){ |
|
248 | + $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}"); |
|
249 | 249 | if($dieOnError) { |
250 | 250 | if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
251 | 251 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | } else { |
256 | 256 | return false; |
257 | 257 | } |
258 | - } |
|
259 | - } |
|
258 | + } |
|
259 | + } |
|
260 | 260 | |
261 | 261 | if(!$this->checkError('Could Not Connect', $dieOnError)) |
262 | 262 | $GLOBALS['log']->info("connected to db"); |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | return true; |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
270 | + /** |
|
271 | 271 | * @see DBManager::version() |
272 | 272 | */ |
273 | 273 | public function version() |
274 | 274 | { |
275 | 275 | return $this->getOne("SELECT @@VERSION as version"); |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
278 | + /** |
|
279 | 279 | * @see DBManager::query() |
280 | - */ |
|
281 | - public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
280 | + */ |
|
281 | + public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
282 | 282 | { |
283 | 283 | if(is_array($sql)) { |
284 | 284 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | if ((substr_count($sql, "'") & 1)) |
288 | 288 | $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
289 | 289 | |
290 | - $sql = $this->_appendN($sql); |
|
290 | + $sql = $this->_appendN($sql); |
|
291 | 291 | |
292 | 292 | $GLOBALS['log']->info('Query:' . $sql); |
293 | 293 | $this->checkConnection(); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $this->query_time = microtime(true); |
296 | 296 | |
297 | 297 | // Bug 34892 - Clear out previous error message by checking the @@ERROR global variable |
298 | - @mssql_query("SELECT @@ERROR", $this->database); |
|
298 | + @mssql_query("SELECT @@ERROR", $this->database); |
|
299 | 299 | |
300 | 300 | $result = $suppress?@mssql_query($sql, $this->database):mssql_query($sql, $this->database); |
301 | 301 | |
@@ -305,18 +305,18 @@ discard block |
||
305 | 305 | // not affect the functionality of the query |
306 | 306 | $sqlmsg = mssql_get_last_message(); |
307 | 307 | $sqlpos = strpos($sqlmsg, 'Changed database context to'); |
308 | - $sqlpos2 = strpos($sqlmsg, 'Warning:'); |
|
309 | - $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
|
308 | + $sqlpos2 = strpos($sqlmsg, 'Warning:'); |
|
309 | + $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
|
310 | 310 | |
311 | - if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) // if sqlmsg has 'Changed database context to', just log it |
|
312 | - $GLOBALS['log']->debug($sqlmsg . ": " . $sql ); |
|
313 | - else { |
|
314 | - $GLOBALS['log']->fatal($sqlmsg . ": " . $sql ); |
|
315 | - if($dieOnError) |
|
316 | - sugar_die('SQL Error : ' . $sqlmsg); |
|
317 | - else |
|
318 | - echo 'SQL Error : ' . $sqlmsg; |
|
319 | - } |
|
311 | + if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) // if sqlmsg has 'Changed database context to', just log it |
|
312 | + $GLOBALS['log']->debug($sqlmsg . ": " . $sql ); |
|
313 | + else { |
|
314 | + $GLOBALS['log']->fatal($sqlmsg . ": " . $sql ); |
|
315 | + if($dieOnError) |
|
316 | + sugar_die('SQL Error : ' . $sqlmsg); |
|
317 | + else |
|
318 | + echo 'SQL Error : ' . $sqlmsg; |
|
319 | + } |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | $this->query_time = microtime(true) - $this->query_time; |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | return $limitUnionSQL; |
427 | 427 | } |
428 | 428 | |
429 | - /** |
|
430 | - * FIXME: verify and thoroughly test this code, these regexps look fishy |
|
429 | + /** |
|
430 | + * FIXME: verify and thoroughly test this code, these regexps look fishy |
|
431 | 431 | * @see DBManager::limitQuery() |
432 | 432 | */ |
433 | 433 | public function limitQuery($sql, $start, $count, $dieOnError = false, $msg = '', $execute = true) |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | }else{ |
570 | 570 | //if there is a distinct clause, form query with rownumber after distinct |
571 | 571 | if ($hasDistinct) { |
572 | - $newSQL = "SELECT TOP $count * FROM |
|
572 | + $newSQL = "SELECT TOP $count * FROM |
|
573 | 573 | ( |
574 | 574 | SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, " . $distinctSQLARRAY[0] . " |
575 | 575 | " . $distinctSQLARRAY[1] . " |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | WHERE row_number > $start"; |
580 | 580 | } |
581 | 581 | else { |
582 | - $newSQL = "SELECT TOP $count * FROM |
|
582 | + $newSQL = "SELECT TOP $count * FROM |
|
583 | 583 | ( |
584 | 584 | " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $sqlArray['FROM'][0]['alias'] . ".id) AS row_number, " . $matches[2] . $matches[3]. " |
585 | 585 | ) |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | while ($i<$count && $offset<strlen($p_sql)) { |
627 | 627 | if ($offset > strlen($p_sql)) |
628 | 628 | { |
629 | - break; |
|
629 | + break; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | $beg_sin = strpos($p_sql, $strip_beg, $offset); |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | * @param array $pattern_array |
666 | 666 | * @return string |
667 | 667 | */ |
668 | - private function addPatternToSQL($token, array $pattern_array) |
|
668 | + private function addPatternToSQL($token, array $pattern_array) |
|
669 | 669 | { |
670 | 670 | //strip all single quotes out |
671 | 671 | $pattern_array = array_reverse($pattern_array); |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | * @param string $alias |
685 | 685 | * @return string |
686 | 686 | */ |
687 | - private function getAliasFromSQL($sql, $alias) |
|
687 | + private function getAliasFromSQL($sql, $alias) |
|
688 | 688 | { |
689 | 689 | $matches = array(); |
690 | 690 | preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU',$sql, $matches); |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | |
787 | 787 | // If there is no ordering direction (ASC/DESC), use ASC by default |
788 | 788 | if (strpos($orig_order_match, " ") === false) { |
789 | - $orig_order_match .= " ASC"; |
|
789 | + $orig_order_match .= " ASC"; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | //grab first space in order by |
@@ -810,11 +810,11 @@ discard block |
||
810 | 810 | $lastSpacePos = strrpos($containsColStr, " "); |
811 | 811 | //use positions of column name, space before name, and length of column to find the correct column name |
812 | 812 | $col_name = substr($sql, $lastSpacePos, $colMatchPos-$lastSpacePos+strlen($orderMatch)); |
813 | - //bug 25485. When sorting by a custom field in Account List and then pressing NEXT >, system gives an error |
|
814 | - $containsCommaPos = strpos($col_name, ","); |
|
815 | - if($containsCommaPos !== false) { |
|
816 | - $col_name = substr($col_name, $containsCommaPos+1); |
|
817 | - } |
|
813 | + //bug 25485. When sorting by a custom field in Account List and then pressing NEXT >, system gives an error |
|
814 | + $containsCommaPos = strpos($col_name, ","); |
|
815 | + if($containsCommaPos !== false) { |
|
816 | + $col_name = substr($col_name, $containsCommaPos+1); |
|
817 | + } |
|
818 | 818 | //add the "asc/desc" order back |
819 | 819 | $col_name = $col_name. " ". $asc_desc; |
820 | 820 | |
@@ -967,14 +967,14 @@ discard block |
||
967 | 967 | } |
968 | 968 | |
969 | 969 | |
970 | - /** |
|
970 | + /** |
|
971 | 971 | * @see DBManager::getFieldsArray() |
972 | 972 | */ |
973 | - public function getFieldsArray($result, $make_lower_case = false) |
|
974 | - { |
|
975 | - $field_array = array(); |
|
973 | + public function getFieldsArray($result, $make_lower_case = false) |
|
974 | + { |
|
975 | + $field_array = array(); |
|
976 | 976 | |
977 | - if(! isset($result) || empty($result)) |
|
977 | + if(! isset($result) || empty($result)) |
|
978 | 978 | return 0; |
979 | 979 | |
980 | 980 | $i = 0; |
@@ -991,37 +991,37 @@ discard block |
||
991 | 991 | } |
992 | 992 | |
993 | 993 | return $field_array; |
994 | - } |
|
994 | + } |
|
995 | 995 | |
996 | 996 | /** |
997 | 997 | * @see DBManager::getAffectedRowCount() |
998 | 998 | */ |
999 | - public function getAffectedRowCount($result) |
|
999 | + public function getAffectedRowCount($result) |
|
1000 | 1000 | { |
1001 | 1001 | return $this->getOne("SELECT @@ROWCOUNT"); |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - /** |
|
1005 | - * @see DBManager::fetchRow() |
|
1006 | - */ |
|
1007 | - public function fetchRow($result) |
|
1008 | - { |
|
1009 | - if (empty($result)) return false; |
|
1004 | + /** |
|
1005 | + * @see DBManager::fetchRow() |
|
1006 | + */ |
|
1007 | + public function fetchRow($result) |
|
1008 | + { |
|
1009 | + if (empty($result)) return false; |
|
1010 | 1010 | |
1011 | 1011 | $row = mssql_fetch_assoc($result); |
1012 | 1012 | //MSSQL returns a space " " when a varchar column is empty ("") and not null. |
1013 | 1013 | //We need to iterate through the returned row array and strip empty spaces |
1014 | 1014 | if(!empty($row)){ |
1015 | 1015 | foreach($row as $key => $column) { |
1016 | - //notice we only strip if one space is returned. we do not want to strip |
|
1017 | - //strings with intentional spaces (" foo ") |
|
1018 | - if (!empty($column) && $column ==" ") { |
|
1019 | - $row[$key] = ''; |
|
1020 | - } |
|
1016 | + //notice we only strip if one space is returned. we do not want to strip |
|
1017 | + //strings with intentional spaces (" foo ") |
|
1018 | + if (!empty($column) && $column ==" ") { |
|
1019 | + $row[$key] = ''; |
|
1020 | + } |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | return $row; |
1024 | - } |
|
1024 | + } |
|
1025 | 1025 | |
1026 | 1026 | /** |
1027 | 1027 | * @see DBManager::quote() |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | if (!empty($r)) { |
1070 | 1070 | while ($a = $this->fetchByAssoc($r)) { |
1071 | 1071 | $row = array_values($a); |
1072 | - $tables[]=$row[0]; |
|
1072 | + $tables[]=$row[0]; |
|
1073 | 1073 | } |
1074 | 1074 | return $tables; |
1075 | 1075 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | ) |
1127 | 1127 | "; |
1128 | 1128 | //create full text index |
1129 | - $FTSqry[] = "CREATE FULLTEXT INDEX ON fts_wakeup |
|
1129 | + $FTSqry[] = "CREATE FULLTEXT INDEX ON fts_wakeup |
|
1130 | 1130 | ( |
1131 | 1131 | body |
1132 | 1132 | Language 0X0 |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | $len = $this->date_formats[$additional_parameters[0]]; |
1196 | 1196 | return "LEFT(CONVERT(varchar($len),". $string . ",120),$len)"; |
1197 | 1197 | } else { |
1198 | - return "LEFT(CONVERT(varchar(10),". $string . ",120),10)"; |
|
1198 | + return "LEFT(CONVERT(varchar(10),". $string . ",120),10)"; |
|
1199 | 1199 | } |
1200 | 1200 | case 'ifnull': |
1201 | 1201 | if(empty($additional_parameters_string)) { |
@@ -1237,14 +1237,14 @@ discard block |
||
1237 | 1237 | case 'datetime': return substr($string, 0,19); |
1238 | 1238 | case 'date': return substr($string, 0, 10); |
1239 | 1239 | case 'time': return substr($string, 11); |
1240 | - } |
|
1241 | - return $string; |
|
1240 | + } |
|
1241 | + return $string; |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | /** |
1245 | 1245 | * @see DBManager::createTableSQLParams() |
1246 | 1246 | */ |
1247 | - public function createTableSQLParams($tablename, $fieldDefs, $indices) |
|
1247 | + public function createTableSQLParams($tablename, $fieldDefs, $indices) |
|
1248 | 1248 | { |
1249 | 1249 | if (empty($tablename) || empty($fieldDefs)) |
1250 | 1250 | return ''; |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | break; |
1323 | 1323 | default: |
1324 | 1324 | return ''; |
1325 | - } |
|
1325 | + } |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | /** |
@@ -1338,14 +1338,14 @@ discard block |
||
1338 | 1338 | $columns = array(); |
1339 | 1339 | if ($this->isFieldArray($fieldDefs)) { |
1340 | 1340 | foreach ($fieldDefs as $def) |
1341 | - { |
|
1342 | - //if the column is being modified drop the default value |
|
1343 | - //constraint if it exists. alterSQLRep will add the constraint back |
|
1344 | - if (!empty($constraints[$def['name']])) { |
|
1345 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$def['name']]; |
|
1346 | - } |
|
1347 | - //check to see if we need to drop related indexes before the alter |
|
1348 | - $indices = $this->get_indices($tablename); |
|
1341 | + { |
|
1342 | + //if the column is being modified drop the default value |
|
1343 | + //constraint if it exists. alterSQLRep will add the constraint back |
|
1344 | + if (!empty($constraints[$def['name']])) { |
|
1345 | + $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$def['name']]; |
|
1346 | + } |
|
1347 | + //check to see if we need to drop related indexes before the alter |
|
1348 | + $indices = $this->get_indices($tablename); |
|
1349 | 1349 | foreach ( $indices as $index ) { |
1350 | 1350 | if ( in_array($def['name'],$index['fields']) ) { |
1351 | 1351 | $sql .= ' ' . $this->add_drop_constraint($tablename,$index,true).' '; |
@@ -1353,16 +1353,16 @@ discard block |
||
1353 | 1353 | } |
1354 | 1354 | } |
1355 | 1355 | |
1356 | - $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename); |
|
1357 | - } |
|
1356 | + $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename); |
|
1357 | + } |
|
1358 | 1358 | } |
1359 | 1359 | else { |
1360 | 1360 | //if the column is being modified drop the default value |
1361 | - //constraint if it exists. alterSQLRep will add the constraint back |
|
1362 | - if (!empty($constraints[$fieldDefs['name']])) { |
|
1363 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$fieldDefs['name']]; |
|
1364 | - } |
|
1365 | - //check to see if we need to drop related indexes before the alter |
|
1361 | + //constraint if it exists. alterSQLRep will add the constraint back |
|
1362 | + if (!empty($constraints[$fieldDefs['name']])) { |
|
1363 | + $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$fieldDefs['name']]; |
|
1364 | + } |
|
1365 | + //check to see if we need to drop related indexes before the alter |
|
1366 | 1366 | $indices = $this->get_indices($tablename); |
1367 | 1367 | foreach ( $indices as $index ) { |
1368 | 1368 | if ( in_array($fieldDefs['name'],$index['fields']) ) { |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | |
1375 | - $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired,$tablename); |
|
1375 | + $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired,$tablename); |
|
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | $columns = implode(", ", $columns); |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | |
1384 | 1384 | protected function setAutoIncrement($table, $field_name) |
1385 | 1385 | { |
1386 | - return "identity(1,1)"; |
|
1387 | - } |
|
1386 | + return "identity(1,1)"; |
|
1387 | + } |
|
1388 | 1388 | |
1389 | 1389 | /** |
1390 | 1390 | * @see DBManager::setAutoIncrementStart() |
@@ -1393,16 +1393,16 @@ discard block |
||
1393 | 1393 | { |
1394 | 1394 | if($start_value > 1) |
1395 | 1395 | $start_value -= 1; |
1396 | - $this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS"); |
|
1396 | + $this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS"); |
|
1397 | 1397 | return true; |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - /** |
|
1400 | + /** |
|
1401 | 1401 | * @see DBManager::getAutoIncrement() |
1402 | 1402 | */ |
1403 | 1403 | public function getAutoIncrement($table, $field_name) |
1404 | 1404 | { |
1405 | - $result = $this->getOne("select IDENT_CURRENT('$table') + IDENT_INCR ( '$table' ) as 'Auto_increment'"); |
|
1405 | + $result = $this->getOne("select IDENT_CURRENT('$table') + IDENT_INCR ( '$table' ) as 'Auto_increment'"); |
|
1406 | 1406 | return $result; |
1407 | 1407 | } |
1408 | 1408 | |
@@ -1457,8 +1457,8 @@ discard block |
||
1457 | 1457 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
1458 | 1458 | $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
1459 | 1459 | } |
1460 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) |
|
1461 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1460 | + elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) |
|
1461 | + $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1462 | 1462 | elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) |
1463 | 1463 | $columns[$column_name]['len']=strtolower($row['LENGTH']); |
1464 | 1464 | if ( stristr($row['TYPE_NAME'],'identity') ) { |
@@ -1585,7 +1585,7 @@ discard block |
||
1585 | 1585 | protected function full_text_indexing_enabled($dbname = null) |
1586 | 1586 | { |
1587 | 1587 | // check to see if we already have install setting in session |
1588 | - if(!isset($_SESSION['IsFulltextInstalled'])) |
|
1588 | + if(!isset($_SESSION['IsFulltextInstalled'])) |
|
1589 | 1589 | $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed(); |
1590 | 1590 | |
1591 | 1591 | // check to see if FTS Indexing service is installed |
@@ -1593,27 +1593,27 @@ discard block |
||
1593 | 1593 | return false; |
1594 | 1594 | |
1595 | 1595 | // grab the dbname if it was not passed through |
1596 | - if (empty($dbname)) { |
|
1597 | - global $sugar_config; |
|
1598 | - $dbname = $sugar_config['dbconfig']['db_name']; |
|
1599 | - } |
|
1596 | + if (empty($dbname)) { |
|
1597 | + global $sugar_config; |
|
1598 | + $dbname = $sugar_config['dbconfig']['db_name']; |
|
1599 | + } |
|
1600 | 1600 | //we already know that Indexing service is installed, now check |
1601 | 1601 | //to see if it is enabled |
1602 | - $res = $this->getOne("SELECT DATABASEPROPERTY('$dbname', 'IsFulltextEnabled') ftext"); |
|
1602 | + $res = $this->getOne("SELECT DATABASEPROPERTY('$dbname', 'IsFulltextEnabled') ftext"); |
|
1603 | 1603 | return !empty($res); |
1604 | - } |
|
1604 | + } |
|
1605 | 1605 | |
1606 | 1606 | /** |
1607 | 1607 | * Creates default full text catalog |
1608 | 1608 | */ |
1609 | - protected function create_default_full_text_catalog() |
|
1609 | + protected function create_default_full_text_catalog() |
|
1610 | 1610 | { |
1611 | - if ($this->full_text_indexing_enabled()) { |
|
1612 | - $catalog = $this->ftsCatalogName(); |
|
1611 | + if ($this->full_text_indexing_enabled()) { |
|
1612 | + $catalog = $this->ftsCatalogName(); |
|
1613 | 1613 | $GLOBALS['log']->debug("Creating the default catalog for full-text indexing, $catalog"); |
1614 | 1614 | |
1615 | 1615 | //drop catalog if exists. |
1616 | - $ret = $this->query(" |
|
1616 | + $ret = $this->query(" |
|
1617 | 1617 | if not exists( |
1618 | 1618 | select * |
1619 | 1619 | from sys.fulltext_catalogs |
@@ -1621,11 +1621,11 @@ discard block |
||
1621 | 1621 | ) |
1622 | 1622 | CREATE FULLTEXT CATALOG $catalog"); |
1623 | 1623 | |
1624 | - if (empty($ret)) { |
|
1625 | - $GLOBALS['log']->error("Error creating default full-text catalog, $catalog"); |
|
1626 | - } |
|
1627 | - } |
|
1628 | - } |
|
1624 | + if (empty($ret)) { |
|
1625 | + $GLOBALS['log']->error("Error creating default full-text catalog, $catalog"); |
|
1626 | + } |
|
1627 | + } |
|
1628 | + } |
|
1629 | 1629 | |
1630 | 1630 | /** |
1631 | 1631 | * Function returns name of the constraint automatically generated by sql-server. |
@@ -1635,7 +1635,7 @@ discard block |
||
1635 | 1635 | * @param string $column |
1636 | 1636 | * @return string |
1637 | 1637 | */ |
1638 | - private function get_field_default_constraint_name($table, $column = null) |
|
1638 | + private function get_field_default_constraint_name($table, $column = null) |
|
1639 | 1639 | { |
1640 | 1640 | static $results = array(); |
1641 | 1641 | |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | return null; |
1673 | - } |
|
1673 | + } |
|
1674 | 1674 | |
1675 | 1675 | /** |
1676 | 1676 | * @see DBManager::massageFieldDef() |
@@ -1692,7 +1692,7 @@ discard block |
||
1692 | 1692 | case 'varchar' : |
1693 | 1693 | case 'nvarchar' : |
1694 | 1694 | $fieldDef['len'] = $this->isTextType($fieldDef['dbType']) ? 'max' : '255'; |
1695 | - break; |
|
1695 | + break; |
|
1696 | 1696 | case 'image' : $fieldDef['len'] = '2147483647'; break; |
1697 | 1697 | case 'ntext' : $fieldDef['len'] = '2147483646'; break; // Note: this is from legacy code, don't know if this is correct |
1698 | 1698 | } |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | && empty($fieldDef['precision']) |
1702 | 1702 | && !strpos($fieldDef['len'], ',')) |
1703 | 1703 | { |
1704 | - $fieldDef['len'] .= ',0'; // Adding 0 precision if it is not specified |
|
1704 | + $fieldDef['len'] .= ',0'; // Adding 0 precision if it is not specified |
|
1705 | 1705 | } |
1706 | 1706 | |
1707 | 1707 | if(empty($fieldDef['default']) |
@@ -1709,8 +1709,8 @@ discard block |
||
1709 | 1709 | { |
1710 | 1710 | $fieldDef['default'] = '0'; |
1711 | 1711 | } |
1712 | - if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) |
|
1713 | - $fieldDef['default'] = ''; |
|
1712 | + if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) |
|
1713 | + $fieldDef['default'] = ''; |
|
1714 | 1714 | // if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) ) |
1715 | 1715 | // $fieldDef['len'] = '1'; |
1716 | 1716 | // if ($fieldDef['type'] == 'bool' && empty($fieldDef['len']) ) |
@@ -1739,30 +1739,30 @@ discard block |
||
1739 | 1739 | */ |
1740 | 1740 | protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
1741 | 1741 | { |
1742 | - //Bug 25814 |
|
1743 | - if(isset($fieldDef['name'])){ |
|
1744 | - $colType = $this->getFieldType($fieldDef); |
|
1745 | - if(stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])){ |
|
1746 | - $fieldDef['len'] = min($fieldDef['len'],38); |
|
1747 | - } |
|
1748 | - //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair |
|
1749 | - if(stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8){ |
|
1750 | - unset($fieldDef['len']); |
|
1751 | - } |
|
1752 | - } |
|
1753 | - |
|
1754 | - // always return as array for post-processing |
|
1755 | - $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
|
1756 | - |
|
1757 | - // Bug 24307 - Don't add precision for float fields. |
|
1758 | - if ( stristr($ref['colType'],'float') ) |
|
1759 | - $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']); |
|
1742 | + //Bug 25814 |
|
1743 | + if(isset($fieldDef['name'])){ |
|
1744 | + $colType = $this->getFieldType($fieldDef); |
|
1745 | + if(stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])){ |
|
1746 | + $fieldDef['len'] = min($fieldDef['len'],38); |
|
1747 | + } |
|
1748 | + //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair |
|
1749 | + if(stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8){ |
|
1750 | + unset($fieldDef['len']); |
|
1751 | + } |
|
1752 | + } |
|
1753 | + |
|
1754 | + // always return as array for post-processing |
|
1755 | + $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
|
1756 | + |
|
1757 | + // Bug 24307 - Don't add precision for float fields. |
|
1758 | + if ( stristr($ref['colType'],'float') ) |
|
1759 | + $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']); |
|
1760 | 1760 | |
1761 | 1761 | if ( $return_as_array ) |
1762 | 1762 | return $ref; |
1763 | 1763 | else |
1764 | 1764 | return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
1765 | - } |
|
1765 | + } |
|
1766 | 1766 | |
1767 | 1767 | /** |
1768 | 1768 | * Saves changes to module's audit table |
@@ -1771,13 +1771,13 @@ discard block |
||
1771 | 1771 | * @param array $changes changes |
1772 | 1772 | */ |
1773 | 1773 | public function save_audit_records(SugarBean $bean, $changes) |
1774 | - { |
|
1775 | - //Bug 25078 fixed by Martin Hu: sqlserver haven't 'date' type, trim extra "00:00:00" |
|
1776 | - if($changes['data_type'] == 'date'){ |
|
1777 | - $changes['before'] = str_replace(' 00:00:00','',$changes['before']); |
|
1778 | - } |
|
1779 | - parent::save_audit_records($bean,$changes); |
|
1780 | - } |
|
1774 | + { |
|
1775 | + //Bug 25078 fixed by Martin Hu: sqlserver haven't 'date' type, trim extra "00:00:00" |
|
1776 | + if($changes['data_type'] == 'date'){ |
|
1777 | + $changes['before'] = str_replace(' 00:00:00','',$changes['before']); |
|
1778 | + } |
|
1779 | + parent::save_audit_records($bean,$changes); |
|
1780 | + } |
|
1781 | 1781 | |
1782 | 1782 | /** |
1783 | 1783 | * Disconnects from the database |
@@ -1786,7 +1786,7 @@ discard block |
||
1786 | 1786 | */ |
1787 | 1787 | public function disconnect() |
1788 | 1788 | { |
1789 | - $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
|
1789 | + $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
|
1790 | 1790 | if(!empty($this->database)){ |
1791 | 1791 | $this->freeResult(); |
1792 | 1792 | mssql_close($this->database); |
@@ -1803,21 +1803,21 @@ discard block |
||
1803 | 1803 | mssql_free_result($dbResult); |
1804 | 1804 | } |
1805 | 1805 | |
1806 | - /** |
|
1807 | - * (non-PHPdoc) |
|
1808 | - * @see DBManager::lastDbError() |
|
1809 | - */ |
|
1806 | + /** |
|
1807 | + * (non-PHPdoc) |
|
1808 | + * @see DBManager::lastDbError() |
|
1809 | + */ |
|
1810 | 1810 | public function lastDbError() |
1811 | 1811 | { |
1812 | 1812 | $sqlmsg = mssql_get_last_message(); |
1813 | 1813 | if(empty($sqlmsg)) return false; |
1814 | 1814 | global $app_strings; |
1815 | 1815 | if (empty($app_strings) |
1816 | - or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
|
1817 | - or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
1816 | + or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
|
1817 | + or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
1818 | 1818 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
1819 | 1819 | //only if connection if made before language is set. |
1820 | - return false; |
|
1820 | + return false; |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | $sqlpos = strpos($sqlmsg, 'Changed database context to'); |
@@ -1826,7 +1826,7 @@ discard block |
||
1826 | 1826 | if ( $sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false ) { |
1827 | 1827 | return false; |
1828 | 1828 | } else { |
1829 | - global $app_strings; |
|
1829 | + global $app_strings; |
|
1830 | 1830 | //ERR_MSSQL_DB_CONTEXT: localized version of 'Changed database context to' message |
1831 | 1831 | if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])) { |
1832 | 1832 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
@@ -1842,7 +1842,7 @@ discard block |
||
1842 | 1842 | } |
1843 | 1843 | |
1844 | 1844 | if ( strlen($sqlmsg) > 2 ) { |
1845 | - return "SQL Server error: " . $sqlmsg; |
|
1845 | + return "SQL Server error: " . $sqlmsg; |
|
1846 | 1846 | } |
1847 | 1847 | |
1848 | 1848 | return false; |
@@ -2065,7 +2065,7 @@ discard block |
||
2065 | 2065 | public function installConfig() |
2066 | 2066 | { |
2067 | 2067 | return array( |
2068 | - 'LBL_DBCONFIG_MSG3' => array( |
|
2068 | + 'LBL_DBCONFIG_MSG3' => array( |
|
2069 | 2069 | "setup_db_database_name" => array("label" => 'LBL_DBCONF_DB_NAME', "required" => true), |
2070 | 2070 | ), |
2071 | 2071 | 'LBL_DBCONFIG_MSG2' => array( |
@@ -2097,8 +2097,8 @@ discard block |
||
2097 | 2097 | * @return string |
2098 | 2098 | */ |
2099 | 2099 | |
2100 | - public function getGuidSQL() |
|
2100 | + public function getGuidSQL() |
|
2101 | 2101 | { |
2102 | - return 'NEWID()'; |
|
2102 | + return 'NEWID()'; |
|
2103 | 2103 | } |
2104 | 2104 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -168,8 +170,9 @@ discard block |
||
168 | 170 | { |
169 | 171 | global $sugar_config; |
170 | 172 | |
171 | - if (is_null($configOptions)) |
|
172 | - $configOptions = $sugar_config['dbconfig']; |
|
173 | + if (is_null($configOptions)) { |
|
174 | + $configOptions = $sugar_config['dbconfig']; |
|
175 | + } |
|
173 | 176 | |
174 | 177 | //SET DATEFORMAT to 'YYYY-MM-DD'' |
175 | 178 | ini_set('mssql.datetimeconvert', '0'); |
@@ -258,8 +261,9 @@ discard block |
||
258 | 261 | } |
259 | 262 | } |
260 | 263 | |
261 | - if(!$this->checkError('Could Not Connect', $dieOnError)) |
|
262 | - $GLOBALS['log']->info("connected to db"); |
|
264 | + if(!$this->checkError('Could Not Connect', $dieOnError)) { |
|
265 | + $GLOBALS['log']->info("connected to db"); |
|
266 | + } |
|
263 | 267 | |
264 | 268 | $this->connectOptions = $configOptions; |
265 | 269 | |
@@ -284,8 +288,9 @@ discard block |
||
284 | 288 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
285 | 289 | } |
286 | 290 | // Flag if there are odd number of single quotes |
287 | - if ((substr_count($sql, "'") & 1)) |
|
288 | - $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
291 | + if ((substr_count($sql, "'") & 1)) { |
|
292 | + $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
293 | + } |
|
289 | 294 | |
290 | 295 | $sql = $this->_appendN($sql); |
291 | 296 | |
@@ -308,14 +313,16 @@ discard block |
||
308 | 313 | $sqlpos2 = strpos($sqlmsg, 'Warning:'); |
309 | 314 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
310 | 315 | |
311 | - if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) // if sqlmsg has 'Changed database context to', just log it |
|
316 | + if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) { |
|
317 | + // if sqlmsg has 'Changed database context to', just log it |
|
312 | 318 | $GLOBALS['log']->debug($sqlmsg . ": " . $sql ); |
313 | - else { |
|
319 | + } else { |
|
314 | 320 | $GLOBALS['log']->fatal($sqlmsg . ": " . $sql ); |
315 | - if($dieOnError) |
|
316 | - sugar_die('SQL Error : ' . $sqlmsg); |
|
317 | - else |
|
318 | - echo 'SQL Error : ' . $sqlmsg; |
|
321 | + if($dieOnError) { |
|
322 | + sugar_die('SQL Error : ' . $sqlmsg); |
|
323 | + } else { |
|
324 | + echo 'SQL Error : ' . $sqlmsg; |
|
325 | + } |
|
319 | 326 | } |
320 | 327 | } |
321 | 328 | |
@@ -340,8 +347,9 @@ discard block |
||
340 | 347 | private function handleUnionLimitQuery($sql, $start, $count) |
341 | 348 | { |
342 | 349 | //set the start to 0, no negs |
343 | - if ($start < 0) |
|
344 | - $start=0; |
|
350 | + if ($start < 0) { |
|
351 | + $start=0; |
|
352 | + } |
|
345 | 353 | |
346 | 354 | $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
347 | 355 | |
@@ -390,8 +398,7 @@ discard block |
||
390 | 398 | $rowNumOrderBy = 'id'; |
391 | 399 | $unionOrderBy = ""; |
392 | 400 | } |
393 | - } |
|
394 | - else { |
|
401 | + } else { |
|
395 | 402 | //there are no order by elements, so just pass back string |
396 | 403 | $unionsql = $sql; |
397 | 404 | //with no guidance on what to use for required order by in rownumber function, |
@@ -413,8 +420,7 @@ discard block |
||
413 | 420 | if ($count == 1 && $start == 0) |
414 | 421 | { |
415 | 422 | $limitUnionSQL = "SELECT TOP $count * FROM (" .$unionsql .") as top_count ".$unionOrderBy; |
416 | - } |
|
417 | - else |
|
423 | + } else |
|
418 | 424 | { |
419 | 425 | $limitUnionSQL = "SELECT TOP $count * FROM( select ROW_NUMBER() OVER ( order by " |
420 | 426 | .$rowNumOrderBy.") AS row_number, * FROM (" |
@@ -436,11 +442,12 @@ discard block |
||
436 | 442 | $count = (int)$count; |
437 | 443 | $newSQL = $sql; |
438 | 444 | $distinctSQLARRAY = array(); |
439 | - if (strpos($sql, "UNION") && !preg_match("/(')(UNION).?(')/i", $sql)) |
|
440 | - $newSQL = $this->handleUnionLimitQuery($sql,$start,$count); |
|
441 | - else { |
|
442 | - if ($start < 0) |
|
443 | - $start = 0; |
|
445 | + if (strpos($sql, "UNION") && !preg_match("/(')(UNION).?(')/i", $sql)) { |
|
446 | + $newSQL = $this->handleUnionLimitQuery($sql,$start,$count); |
|
447 | + } else { |
|
448 | + if ($start < 0) { |
|
449 | + $start = 0; |
|
450 | + } |
|
444 | 451 | $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
445 | 452 | $this->lastsql = $sql; |
446 | 453 | $matches = array(); |
@@ -461,20 +468,17 @@ discard block |
||
461 | 468 | " . $selectPart[2] . $orderByMatch[1]. " |
462 | 469 | ) AS a |
463 | 470 | WHERE row_number > $start"; |
464 | - } |
|
465 | - else { |
|
471 | + } else { |
|
466 | 472 | $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
467 | 473 | } |
468 | - } |
|
469 | - else { |
|
474 | + } else { |
|
470 | 475 | $distinct_o = strpos($match_two, "distinct"); |
471 | 476 | $up_to_distinct_str = substr($match_two, 0, $distinct_o); |
472 | 477 | //check to see if the distinct is within a function, if so, then proceed as normal |
473 | 478 | if (strpos($up_to_distinct_str,"(")) { |
474 | 479 | //proceed as normal |
475 | 480 | $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
476 | - } |
|
477 | - else { |
|
481 | + } else { |
|
478 | 482 | //if distinct is not within a function, then parse |
479 | 483 | //string contains distinct clause, "TOP needs to come after Distinct" |
480 | 484 | //get position of distinct |
@@ -556,8 +560,7 @@ discard block |
||
556 | 560 | group by " . $grpByStr . " |
557 | 561 | ) AS a |
558 | 562 | WHERE row_number > $start"; |
559 | - } |
|
560 | - else { |
|
563 | + } else { |
|
561 | 564 | $newSQL = "SELECT TOP $count * FROM |
562 | 565 | ( |
563 | 566 | " . $matches[1] . " ROW_NUMBER() |
@@ -566,7 +569,7 @@ discard block |
||
566 | 569 | ) AS a |
567 | 570 | WHERE row_number > $start"; |
568 | 571 | } |
569 | - }else{ |
|
572 | + } else{ |
|
570 | 573 | //if there is a distinct clause, form query with rownumber after distinct |
571 | 574 | if ($hasDistinct) { |
572 | 575 | $newSQL = "SELECT TOP $count * FROM |
@@ -577,8 +580,7 @@ discard block |
||
577 | 580 | ) |
578 | 581 | AS a |
579 | 582 | WHERE row_number > $start"; |
580 | - } |
|
581 | - else { |
|
583 | + } else { |
|
582 | 584 | $newSQL = "SELECT TOP $count * FROM |
583 | 585 | ( |
584 | 586 | " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $sqlArray['FROM'][0]['alias'] . ".id) AS row_number, " . $matches[2] . $matches[3]. " |
@@ -617,8 +619,9 @@ discard block |
||
617 | 619 | //strip all single quotes out |
618 | 620 | $count = substr_count ( $p_sql, $strip_beg); |
619 | 621 | $increment = 1; |
620 | - if ($strip_beg != $strip_end) |
|
621 | - $increment = 2; |
|
622 | + if ($strip_beg != $strip_end) { |
|
623 | + $increment = 2; |
|
624 | + } |
|
622 | 625 | |
623 | 626 | $i=0; |
624 | 627 | $offset = 0; |
@@ -780,9 +783,10 @@ discard block |
||
780 | 783 | { |
781 | 784 | $sql = strtolower($sql); |
782 | 785 | $orig_order_match = trim($orig_order_match); |
783 | - if (strpos($orig_order_match, ".") != 0) |
|
784 | - //this has a tablename defined, pass in the order match |
|
786 | + if (strpos($orig_order_match, ".") != 0) { |
|
787 | + //this has a tablename defined, pass in the order match |
|
785 | 788 | return $orig_order_match; |
789 | + } |
|
786 | 790 | |
787 | 791 | // If there is no ordering direction (ASC/DESC), use ASC by default |
788 | 792 | if (strpos($orig_order_match, " ") === false) { |
@@ -824,15 +828,15 @@ discard block |
||
824 | 828 | //break out of here, log this |
825 | 829 | $GLOBALS['log']->debug("No match was found for order by, pass string back untouched as: $orig_order_match"); |
826 | 830 | return $orig_order_match; |
827 | - } |
|
828 | - else { |
|
831 | + } else { |
|
829 | 832 | //if found, then parse and return |
830 | 833 | //grab string up to the aliased column |
831 | 834 | $GLOBALS['log']->debug("order by found, process sql string"); |
832 | 835 | |
833 | 836 | $psql = (trim($this->getAliasFromSQL($sql, $orderMatch ))); |
834 | - if (empty($psql)) |
|
835 | - $psql = trim(substr($sql, 0, $found_in_sql)); |
|
837 | + if (empty($psql)) { |
|
838 | + $psql = trim(substr($sql, 0, $found_in_sql)); |
|
839 | + } |
|
836 | 840 | |
837 | 841 | //grab the last comma before the alias |
838 | 842 | preg_match('/\s+' . trim($orderMatch). '/', $psql, $match, PREG_OFFSET_CAPTURE); |
@@ -845,8 +849,9 @@ discard block |
||
845 | 849 | //this is especially true for unified search from home screen |
846 | 850 | |
847 | 851 | $alias_beg_pos = 0; |
848 | - if(strpos($psql, " as ")) |
|
849 | - $alias_beg_pos = strpos($psql, " as "); |
|
852 | + if(strpos($psql, " as ")) { |
|
853 | + $alias_beg_pos = strpos($psql, " as "); |
|
854 | + } |
|
850 | 855 | |
851 | 856 | // Bug # 44923 - This breaks the query and does not properly filter isnull |
852 | 857 | // as there are other functions such as ltrim and rtrim. |
@@ -883,8 +888,9 @@ discard block |
||
883 | 888 | //correct table name. |
884 | 889 | if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str]) && isset($beanFiles[$beanList[$module_str]])){ |
885 | 890 | //if the class is not already loaded, then load files |
886 | - if (!class_exists($beanList[$module_str])) |
|
887 | - require_once($beanFiles[$beanList[$module_str]]); |
|
891 | + if (!class_exists($beanList[$module_str])) { |
|
892 | + require_once($beanFiles[$beanList[$module_str]]); |
|
893 | + } |
|
888 | 894 | |
889 | 895 | //instantiate new bean |
890 | 896 | $module_bean = new $beanList[$module_str](); |
@@ -897,8 +903,7 @@ discard block |
||
897 | 903 | $GLOBALS['log']->debug("Could not find table name for module $module_str. "); |
898 | 904 | $tbl_name = $module_str; |
899 | 905 | } |
900 | - } |
|
901 | - else { |
|
906 | + } else { |
|
902 | 907 | //since the module does NOT exist in beanlist, then we have to parse the string |
903 | 908 | //and grab the table name from the passed in sql |
904 | 909 | $GLOBALS['log']->debug("Could not find table name from module in request, retrieve from passed in sql"); |
@@ -919,8 +924,9 @@ discard block |
||
919 | 924 | // MFH BUG #14009: Also check to see if there are any carriage returns before the next space so that we don't grab any arbitrary joins or other tables. |
920 | 925 | $carriage_ret = strpos($tableEnd,"\n"); |
921 | 926 | $next_space = strpos($tableEnd," " ); |
922 | - if ($carriage_ret < $next_space) |
|
923 | - $next_space = $carriage_ret; |
|
927 | + if ($carriage_ret < $next_space) { |
|
928 | + $next_space = $carriage_ret; |
|
929 | + } |
|
924 | 930 | if ($next_space > 0) { |
925 | 931 | $tbl_name= substr($tableEnd,0, $next_space); |
926 | 932 | if(empty($tbl_name)){ |
@@ -943,18 +949,17 @@ discard block |
||
943 | 949 | || $alias_tbl_name == "outer" |
944 | 950 | || $alias_tbl_name == "right") { |
945 | 951 | //not aliased, do nothing |
946 | - } |
|
947 | - elseif ($alias_tbl_name == "as") { |
|
952 | + } elseif ($alias_tbl_name == "as") { |
|
948 | 953 | //the next word is the table name |
949 | 954 | $aliasTableEnd = trim(substr($aliasTableEnd, $alias_space)); |
950 | 955 | $alias_space = strpos ($aliasTableEnd, " " ); |
951 | 956 | if ($alias_space > 0) { |
952 | 957 | $alias_tbl_name= trim(substr($aliasTableEnd,0, $alias_space)); |
953 | - if (!empty($alias_tbl_name)) |
|
954 | - $tbl_name = $alias_tbl_name; |
|
958 | + if (!empty($alias_tbl_name)) { |
|
959 | + $tbl_name = $alias_tbl_name; |
|
960 | + } |
|
955 | 961 | } |
956 | - } |
|
957 | - else { |
|
962 | + } else { |
|
958 | 963 | //this is table alias |
959 | 964 | $tbl_name = $alias_tbl_name; |
960 | 965 | } |
@@ -974,16 +979,19 @@ discard block |
||
974 | 979 | { |
975 | 980 | $field_array = array(); |
976 | 981 | |
977 | - if(! isset($result) || empty($result)) |
|
978 | - return 0; |
|
982 | + if(! isset($result) || empty($result)) { |
|
983 | + return 0; |
|
984 | + } |
|
979 | 985 | |
980 | 986 | $i = 0; |
981 | 987 | while ($i < mssql_num_fields($result)) { |
982 | 988 | $meta = mssql_fetch_field($result, $i); |
983 | - if (!$meta) |
|
984 | - return 0; |
|
985 | - if($make_lower_case==true) |
|
986 | - $meta->name = strtolower($meta->name); |
|
989 | + if (!$meta) { |
|
990 | + return 0; |
|
991 | + } |
|
992 | + if($make_lower_case==true) { |
|
993 | + $meta->name = strtolower($meta->name); |
|
994 | + } |
|
987 | 995 | |
988 | 996 | $field_array[] = $meta->name; |
989 | 997 | |
@@ -1006,7 +1014,9 @@ discard block |
||
1006 | 1014 | */ |
1007 | 1015 | public function fetchRow($result) |
1008 | 1016 | { |
1009 | - if (empty($result)) return false; |
|
1017 | + if (empty($result)) { |
|
1018 | + return false; |
|
1019 | + } |
|
1010 | 1020 | |
1011 | 1021 | $row = mssql_fetch_assoc($result); |
1012 | 1022 | //MSSQL returns a space " " when a varchar column is empty ("") and not null. |
@@ -1088,8 +1098,9 @@ discard block |
||
1088 | 1098 | $tables = array(); |
1089 | 1099 | $r = $this->query('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES'); |
1090 | 1100 | if (is_resource($r)) { |
1091 | - while ($a = $this->fetchByAssoc($r)) |
|
1092 | - $tables[] = $a['TABLE_NAME']; |
|
1101 | + while ($a = $this->fetchByAssoc($r)) { |
|
1102 | + $tables[] = $a['TABLE_NAME']; |
|
1103 | + } |
|
1093 | 1104 | |
1094 | 1105 | return $tables; |
1095 | 1106 | } |
@@ -1246,12 +1257,14 @@ discard block |
||
1246 | 1257 | */ |
1247 | 1258 | public function createTableSQLParams($tablename, $fieldDefs, $indices) |
1248 | 1259 | { |
1249 | - if (empty($tablename) || empty($fieldDefs)) |
|
1250 | - return ''; |
|
1260 | + if (empty($tablename) || empty($fieldDefs)) { |
|
1261 | + return ''; |
|
1262 | + } |
|
1251 | 1263 | |
1252 | 1264 | $columns = $this->columnSQLRep($fieldDefs, false, $tablename); |
1253 | - if (empty($columns)) |
|
1254 | - return ''; |
|
1265 | + if (empty($columns)) { |
|
1266 | + return ''; |
|
1267 | + } |
|
1255 | 1268 | |
1256 | 1269 | return "CREATE TABLE $tablename ($columns)"; |
1257 | 1270 | } |
@@ -1263,7 +1276,9 @@ discard block |
||
1263 | 1276 | public function isTextType($type) |
1264 | 1277 | { |
1265 | 1278 | $type = strtolower($type); |
1266 | - if(!isset($this->type_map[$type])) return false; |
|
1279 | + if(!isset($this->type_map[$type])) { |
|
1280 | + return false; |
|
1281 | + } |
|
1267 | 1282 | return in_array($this->type_map[$type], array('ntext','text','image', 'nvarchar(max)')); |
1268 | 1283 | } |
1269 | 1284 | |
@@ -1316,8 +1331,9 @@ discard block |
||
1316 | 1331 | $f_def = $this->oneColumnSQLRep($def, $ignoreRequired,$tablename, true); |
1317 | 1332 | $f_stmt = "ALTER COLUMN ".$f_def['name'].' '.$f_def['colType'].' '. |
1318 | 1333 | $f_def['required'].' '.$f_def['auto_increment']."\n"; |
1319 | - if (!empty( $f_def['default'])) |
|
1320 | - $f_stmt .= " ALTER TABLE " . $tablename . " ADD ". $f_def['default'] . " FOR " . $def['name']; |
|
1334 | + if (!empty( $f_def['default'])) { |
|
1335 | + $f_stmt .= " ALTER TABLE " . $tablename . " ADD ". $f_def['default'] . " FOR " . $def['name']; |
|
1336 | + } |
|
1321 | 1337 | return $f_stmt; |
1322 | 1338 | break; |
1323 | 1339 | default: |
@@ -1355,8 +1371,7 @@ discard block |
||
1355 | 1371 | |
1356 | 1372 | $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename); |
1357 | 1373 | } |
1358 | - } |
|
1359 | - else { |
|
1374 | + } else { |
|
1360 | 1375 | //if the column is being modified drop the default value |
1361 | 1376 | //constraint if it exists. alterSQLRep will add the constraint back |
1362 | 1377 | if (!empty($constraints[$fieldDefs['name']])) { |
@@ -1391,8 +1406,9 @@ discard block |
||
1391 | 1406 | */ |
1392 | 1407 | public function setAutoIncrementStart($table, $field_name, $start_value) |
1393 | 1408 | { |
1394 | - if($start_value > 1) |
|
1395 | - $start_value -= 1; |
|
1409 | + if($start_value > 1) { |
|
1410 | + $start_value -= 1; |
|
1411 | + } |
|
1396 | 1412 | $this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS"); |
1397 | 1413 | return true; |
1398 | 1414 | } |
@@ -1428,10 +1444,11 @@ discard block |
||
1428 | 1444 | $indices = array(); |
1429 | 1445 | while (($row=$this->fetchByAssoc($result)) != null) { |
1430 | 1446 | $index_type = 'index'; |
1431 | - if ($row['is_primary_key'] == '1') |
|
1432 | - $index_type = 'primary'; |
|
1433 | - elseif ($row['is_unique'] == 1 ) |
|
1434 | - $index_type = 'unique'; |
|
1447 | + if ($row['is_primary_key'] == '1') { |
|
1448 | + $index_type = 'primary'; |
|
1449 | + } elseif ($row['is_unique'] == 1 ) { |
|
1450 | + $index_type = 'unique'; |
|
1451 | + } |
|
1435 | 1452 | $name = strtolower($row['index_name']); |
1436 | 1453 | $indices[$name]['name'] = $name; |
1437 | 1454 | $indices[$name]['type'] = $index_type; |
@@ -1456,18 +1473,19 @@ discard block |
||
1456 | 1473 | if ( $row['TYPE_NAME'] == 'decimal' ) { |
1457 | 1474 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
1458 | 1475 | $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
1476 | + } elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
1477 | + $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1478 | + } elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
|
1479 | + $columns[$column_name]['len']=strtolower($row['LENGTH']); |
|
1459 | 1480 | } |
1460 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) |
|
1461 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1462 | - elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) |
|
1463 | - $columns[$column_name]['len']=strtolower($row['LENGTH']); |
|
1464 | 1481 | if ( stristr($row['TYPE_NAME'],'identity') ) { |
1465 | 1482 | $columns[$column_name]['auto_increment'] = '1'; |
1466 | 1483 | $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME'])); |
1467 | 1484 | } |
1468 | 1485 | |
1469 | - if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) |
|
1470 | - $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
|
1486 | + if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) { |
|
1487 | + $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
|
1488 | + } |
|
1471 | 1489 | |
1472 | 1490 | $column_def = 1; |
1473 | 1491 | if ( strtolower($tablename) == 'relationships' ) { |
@@ -1476,12 +1494,13 @@ discard block |
||
1476 | 1494 | if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
1477 | 1495 | $matches = array(); |
1478 | 1496 | $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES); |
1479 | - if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) |
|
1480 | - $columns[$column_name]['default'] = $matches[1]; |
|
1481 | - elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) |
|
1482 | - $columns[$column_name]['default'] = $matches[1]; |
|
1483 | - else |
|
1484 | - $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
|
1497 | + if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) { |
|
1498 | + $columns[$column_name]['default'] = $matches[1]; |
|
1499 | + } elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) { |
|
1500 | + $columns[$column_name]['default'] = $matches[1]; |
|
1501 | + } else { |
|
1502 | + $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
|
1503 | + } |
|
1485 | 1504 | } |
1486 | 1505 | } |
1487 | 1506 | return $columns; |
@@ -1513,53 +1532,61 @@ discard block |
||
1513 | 1532 | // generic indices |
1514 | 1533 | case 'index': |
1515 | 1534 | case 'alternate_key': |
1516 | - if ($drop) |
|
1517 | - $sql = "DROP INDEX {$name} ON {$table}"; |
|
1518 | - else |
|
1519 | - $sql = "CREATE INDEX {$name} ON {$table} ({$fields})"; |
|
1535 | + if ($drop) { |
|
1536 | + $sql = "DROP INDEX {$name} ON {$table}"; |
|
1537 | + } else { |
|
1538 | + $sql = "CREATE INDEX {$name} ON {$table} ({$fields})"; |
|
1539 | + } |
|
1520 | 1540 | break; |
1521 | 1541 | case 'clustered': |
1522 | - if ($drop) |
|
1523 | - $sql = "DROP INDEX {$name} ON {$table}"; |
|
1524 | - else |
|
1525 | - $sql = "CREATE CLUSTERED INDEX $name ON $table ($fields)"; |
|
1542 | + if ($drop) { |
|
1543 | + $sql = "DROP INDEX {$name} ON {$table}"; |
|
1544 | + } else { |
|
1545 | + $sql = "CREATE CLUSTERED INDEX $name ON $table ($fields)"; |
|
1546 | + } |
|
1526 | 1547 | break; |
1527 | 1548 | // constraints as indices |
1528 | 1549 | case 'unique': |
1529 | - if ($drop) |
|
1530 | - $sql = "ALTER TABLE {$table} DROP CONSTRAINT $name"; |
|
1531 | - else |
|
1532 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE ({$fields})"; |
|
1550 | + if ($drop) { |
|
1551 | + $sql = "ALTER TABLE {$table} DROP CONSTRAINT $name"; |
|
1552 | + } else { |
|
1553 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE ({$fields})"; |
|
1554 | + } |
|
1533 | 1555 | break; |
1534 | 1556 | case 'primary': |
1535 | - if ($drop) |
|
1536 | - $sql = "ALTER TABLE {$table} DROP CONSTRAINT {$name}"; |
|
1537 | - else |
|
1538 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} PRIMARY KEY ({$fields})"; |
|
1557 | + if ($drop) { |
|
1558 | + $sql = "ALTER TABLE {$table} DROP CONSTRAINT {$name}"; |
|
1559 | + } else { |
|
1560 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} PRIMARY KEY ({$fields})"; |
|
1561 | + } |
|
1539 | 1562 | break; |
1540 | 1563 | case 'foreign': |
1541 | - if ($drop) |
|
1542 | - $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
1543 | - else |
|
1544 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} FOREIGN KEY ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignFields']})"; |
|
1564 | + if ($drop) { |
|
1565 | + $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
1566 | + } else { |
|
1567 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} FOREIGN KEY ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignFields']})"; |
|
1568 | + } |
|
1545 | 1569 | break; |
1546 | 1570 | case 'fulltext': |
1547 | 1571 | if ($this->full_text_indexing_enabled() && $drop) { |
1548 | 1572 | $sql = "DROP FULLTEXT INDEX ON {$table}"; |
1549 | 1573 | } elseif ($this->full_text_indexing_enabled()) { |
1550 | 1574 | $catalog_name=$this->ftsCatalogName(); |
1551 | - if ( isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') |
|
1552 | - $catalog_name = $definition['catalog_name']; |
|
1575 | + if ( isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') { |
|
1576 | + $catalog_name = $definition['catalog_name']; |
|
1577 | + } |
|
1553 | 1578 | |
1554 | 1579 | $language = "Language 1033"; |
1555 | - if (isset($definition['language']) && !empty($definition['language'])) |
|
1556 | - $language = "Language " . $definition['language']; |
|
1580 | + if (isset($definition['language']) && !empty($definition['language'])) { |
|
1581 | + $language = "Language " . $definition['language']; |
|
1582 | + } |
|
1557 | 1583 | |
1558 | 1584 | $key_index = $definition['key_index']; |
1559 | 1585 | |
1560 | 1586 | $change_tracking = "auto"; |
1561 | - if (isset($definition['change_tracking']) && !empty($definition['change_tracking'])) |
|
1562 | - $change_tracking = $definition['change_tracking']; |
|
1587 | + if (isset($definition['change_tracking']) && !empty($definition['change_tracking'])) { |
|
1588 | + $change_tracking = $definition['change_tracking']; |
|
1589 | + } |
|
1563 | 1590 | |
1564 | 1591 | $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking" ; |
1565 | 1592 | } |
@@ -1585,12 +1612,14 @@ discard block |
||
1585 | 1612 | protected function full_text_indexing_enabled($dbname = null) |
1586 | 1613 | { |
1587 | 1614 | // check to see if we already have install setting in session |
1588 | - if(!isset($_SESSION['IsFulltextInstalled'])) |
|
1589 | - $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed(); |
|
1615 | + if(!isset($_SESSION['IsFulltextInstalled'])) { |
|
1616 | + $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed(); |
|
1617 | + } |
|
1590 | 1618 | |
1591 | 1619 | // check to see if FTS Indexing service is installed |
1592 | - if(empty($_SESSION['IsFulltextInstalled'])) |
|
1593 | - return false; |
|
1620 | + if(empty($_SESSION['IsFulltextInstalled'])) { |
|
1621 | + return false; |
|
1622 | + } |
|
1594 | 1623 | |
1595 | 1624 | // grab the dbname if it was not passed through |
1596 | 1625 | if (empty($dbname)) { |
@@ -1639,8 +1668,9 @@ discard block |
||
1639 | 1668 | { |
1640 | 1669 | static $results = array(); |
1641 | 1670 | |
1642 | - if ( empty($column) && isset($results[$table]) ) |
|
1643 | - return $results[$table]; |
|
1671 | + if ( empty($column) && isset($results[$table]) ) { |
|
1672 | + return $results[$table]; |
|
1673 | + } |
|
1644 | 1674 | |
1645 | 1675 | $query = <<<EOQ |
1646 | 1676 | select s.name, o.name, c.name dtrt, d.name ctrt |
@@ -1653,18 +1683,20 @@ discard block |
||
1653 | 1683 | on s.schema_id = o.schema_id |
1654 | 1684 | where o.name = '$table' |
1655 | 1685 | EOQ; |
1656 | - if ( !empty($column) ) |
|
1657 | - $query .= " and c.name = '$column'"; |
|
1686 | + if ( !empty($column) ) { |
|
1687 | + $query .= " and c.name = '$column'"; |
|
1688 | + } |
|
1658 | 1689 | $res = $this->query($query); |
1659 | 1690 | if ( !empty($column) ) { |
1660 | 1691 | $row = $this->fetchByAssoc($res); |
1661 | - if (!empty($row)) |
|
1662 | - return $row['ctrt']; |
|
1663 | - } |
|
1664 | - else { |
|
1692 | + if (!empty($row)) { |
|
1693 | + return $row['ctrt']; |
|
1694 | + } |
|
1695 | + } else { |
|
1665 | 1696 | $returnResult = array(); |
1666 | - while ( $row = $this->fetchByAssoc($res) ) |
|
1667 | - $returnResult[$row['dtrt']] = $row['ctrt']; |
|
1697 | + while ( $row = $this->fetchByAssoc($res) ) { |
|
1698 | + $returnResult[$row['dtrt']] = $row['ctrt']; |
|
1699 | + } |
|
1668 | 1700 | $results[$table] = $returnResult; |
1669 | 1701 | return $returnResult; |
1670 | 1702 | } |
@@ -1679,8 +1711,9 @@ discard block |
||
1679 | 1711 | { |
1680 | 1712 | parent::massageFieldDef($fieldDef,$tablename); |
1681 | 1713 | |
1682 | - if ($fieldDef['type'] == 'int') |
|
1683 | - $fieldDef['len'] = '4'; |
|
1714 | + if ($fieldDef['type'] == 'int') { |
|
1715 | + $fieldDef['len'] = '4'; |
|
1716 | + } |
|
1684 | 1717 | |
1685 | 1718 | if(empty($fieldDef['len'])) |
1686 | 1719 | { |
@@ -1709,9 +1742,10 @@ discard block |
||
1709 | 1742 | { |
1710 | 1743 | $fieldDef['default'] = '0'; |
1711 | 1744 | } |
1712 | - if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) |
|
1713 | - $fieldDef['default'] = ''; |
|
1714 | -// if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) ) |
|
1745 | + if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) { |
|
1746 | + $fieldDef['default'] = ''; |
|
1747 | + } |
|
1748 | + // if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) ) |
|
1715 | 1749 | // $fieldDef['len'] = '1'; |
1716 | 1750 | // if ($fieldDef['type'] == 'bool' && empty($fieldDef['len']) ) |
1717 | 1751 | // $fieldDef['len'] = '1'; |
@@ -1755,13 +1789,15 @@ discard block |
||
1755 | 1789 | $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
1756 | 1790 | |
1757 | 1791 | // Bug 24307 - Don't add precision for float fields. |
1758 | - if ( stristr($ref['colType'],'float') ) |
|
1759 | - $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']); |
|
1792 | + if ( stristr($ref['colType'],'float') ) { |
|
1793 | + $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']); |
|
1794 | + } |
|
1760 | 1795 | |
1761 | - if ( $return_as_array ) |
|
1762 | - return $ref; |
|
1763 | - else |
|
1764 | - return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
1796 | + if ( $return_as_array ) { |
|
1797 | + return $ref; |
|
1798 | + } else { |
|
1799 | + return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
1800 | + } |
|
1765 | 1801 | } |
1766 | 1802 | |
1767 | 1803 | /** |
@@ -1799,8 +1835,9 @@ discard block |
||
1799 | 1835 | */ |
1800 | 1836 | protected function freeDbResult($dbResult) |
1801 | 1837 | { |
1802 | - if(!empty($dbResult)) |
|
1803 | - mssql_free_result($dbResult); |
|
1838 | + if(!empty($dbResult)) { |
|
1839 | + mssql_free_result($dbResult); |
|
1840 | + } |
|
1804 | 1841 | } |
1805 | 1842 | |
1806 | 1843 | /** |
@@ -1810,7 +1847,9 @@ discard block |
||
1810 | 1847 | public function lastDbError() |
1811 | 1848 | { |
1812 | 1849 | $sqlmsg = mssql_get_last_message(); |
1813 | - if(empty($sqlmsg)) return false; |
|
1850 | + if(empty($sqlmsg)) { |
|
1851 | + return false; |
|
1852 | + } |
|
1814 | 1853 | global $app_strings; |
1815 | 1854 | if (empty($app_strings) |
1816 | 1855 | or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
@@ -1833,11 +1872,11 @@ discard block |
||
1833 | 1872 | //only if connection if made before languge is set. |
1834 | 1873 | $GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg); |
1835 | 1874 | return false; |
1836 | - } |
|
1837 | - else { |
|
1875 | + } else { |
|
1838 | 1876 | $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); |
1839 | - if ( $sqlpos !== false ) |
|
1840 | - return false; |
|
1877 | + if ( $sqlpos !== false ) { |
|
1878 | + return false; |
|
1879 | + } |
|
1841 | 1880 | } |
1842 | 1881 | } |
1843 | 1882 | |
@@ -1882,8 +1921,9 @@ discard block |
||
1882 | 1921 | protected function _appendN($sql) |
1883 | 1922 | { |
1884 | 1923 | // If there are no single quotes, don't bother, will just assume there is no character data |
1885 | - if (strpos($sql, "'") === false) |
|
1886 | - return $sql; |
|
1924 | + if (strpos($sql, "'") === false) { |
|
1925 | + return $sql; |
|
1926 | + } |
|
1887 | 1927 | |
1888 | 1928 | // Flag if there are odd number of single quotes, just continue without trying to append N |
1889 | 1929 | if ((substr_count($sql, "'") & 1)) { |
@@ -1922,14 +1962,17 @@ discard block |
||
1922 | 1962 | } |
1923 | 1963 | } |
1924 | 1964 | |
1925 | - if (!empty($replace)) |
|
1926 | - $sql = str_replace(array_keys($replace), $replace, $sql); |
|
1965 | + if (!empty($replace)) { |
|
1966 | + $sql = str_replace(array_keys($replace), $replace, $sql); |
|
1967 | + } |
|
1927 | 1968 | |
1928 | - if (!empty($pairs)) |
|
1929 | - $sql = str_replace(array_keys($pairs), $pairs, $sql); |
|
1969 | + if (!empty($pairs)) { |
|
1970 | + $sql = str_replace(array_keys($pairs), $pairs, $sql); |
|
1971 | + } |
|
1930 | 1972 | |
1931 | - if(strpos($sql, "<@#@#@PAIR@#@#@>")) |
|
1932 | - $sql = str_replace(array('<@#@#@PAIR@#@#@>'), array("''"), $sql); |
|
1973 | + if(strpos($sql, "<@#@#@PAIR@#@#@>")) { |
|
1974 | + $sql = str_replace(array('<@#@#@PAIR@#@#@>'), array("''"), $sql); |
|
1975 | + } |
|
1933 | 1976 | |
1934 | 1977 | return $sql; |
1935 | 1978 | } |
@@ -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. |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | ini_set('mssql.datetimeconvert', '0'); |
176 | 176 | |
177 | 177 | //set the text size and textlimit to max number so that blob columns are not truncated |
178 | - ini_set('mssql.textlimit','2147483647'); |
|
179 | - ini_set('mssql.textsize','2147483647'); |
|
180 | - ini_set('mssql.charset','UTF-8'); |
|
178 | + ini_set('mssql.textlimit', '2147483647'); |
|
179 | + ini_set('mssql.textsize', '2147483647'); |
|
180 | + ini_set('mssql.charset', 'UTF-8'); |
|
181 | 181 | |
182 | - if(!empty($configOptions['db_host_instance'])) { |
|
182 | + if (!empty($configOptions['db_host_instance'])) { |
|
183 | 183 | $configOptions['db_host_instance'] = trim($configOptions['db_host_instance']); |
184 | 184 | } |
185 | 185 | //set the connections parameters |
@@ -191,37 +191,37 @@ discard block |
||
191 | 191 | |
192 | 192 | //create persistent connection |
193 | 193 | if ($this->getOption('persistent')) { |
194 | - $this->database =@mssql_pconnect( |
|
195 | - $connect_param , |
|
194 | + $this->database = @mssql_pconnect( |
|
195 | + $connect_param, |
|
196 | 196 | $configOptions['db_user_name'], |
197 | 197 | $configOptions['db_password'] |
198 | 198 | ); |
199 | 199 | } |
200 | 200 | //if no persistent connection created, then create regular connection |
201 | - if(!$this->database){ |
|
201 | + if (!$this->database) { |
|
202 | 202 | $this->database = mssql_connect( |
203 | - $connect_param , |
|
203 | + $connect_param, |
|
204 | 204 | $configOptions['db_user_name'], |
205 | 205 | $configOptions['db_password'] |
206 | 206 | ); |
207 | - if(!$this->database){ |
|
207 | + if (!$this->database) { |
|
208 | 208 | $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']. |
209 | 209 | " as ".$configOptions['db_user_name']."."); |
210 | - if($dieOnError) { |
|
210 | + if ($dieOnError) { |
|
211 | 211 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
212 | 212 | } else { |
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | } |
216 | - if($this->database && $this->getOption('persistent')){ |
|
216 | + if ($this->database && $this->getOption('persistent')) { |
|
217 | 217 | $_SESSION['administrator_error'] = "<B>Severe Performance Degradation: Persistent Database Connections " |
218 | 218 | . "not working. Please set \$sugar_config['dbconfigoption']['persistent'] to false in your " |
219 | 219 | . "config.php file</B>"; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | //make sure connection exists |
223 | - if(!$this->database) { |
|
224 | - if($dieOnError) { |
|
223 | + if (!$this->database) { |
|
224 | + if ($dieOnError) { |
|
225 | 225 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
226 | 226 | } else { |
227 | 227 | return false; |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | //mssql db maximum number of 5 times at the interval of .2 second. If can not connect |
236 | 236 | //it will throw an Unable to select database message. |
237 | 237 | |
238 | - if(!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
238 | + if (!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)) { |
|
239 | 239 | $connected = false; |
240 | - for($i=0;$i<5;$i++){ |
|
240 | + for ($i = 0; $i < 5; $i++) { |
|
241 | 241 | usleep(200000); |
242 | - if(@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
242 | + if (@mssql_select_db($configOptions['db_name'], $this->database)) { |
|
243 | 243 | $connected = true; |
244 | 244 | break; |
245 | 245 | } |
246 | 246 | } |
247 | - if(!$connected){ |
|
248 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}"); |
|
249 | - if($dieOnError) { |
|
250 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
247 | + if (!$connected) { |
|
248 | + $GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}"); |
|
249 | + if ($dieOnError) { |
|
250 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
251 | 251 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
252 | 252 | } else { |
253 | 253 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - if(!$this->checkError('Could Not Connect', $dieOnError)) |
|
261 | + if (!$this->checkError('Could Not Connect', $dieOnError)) |
|
262 | 262 | $GLOBALS['log']->info("connected to db"); |
263 | 263 | |
264 | 264 | $this->connectOptions = $configOptions; |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
282 | 282 | { |
283 | - if(is_array($sql)) { |
|
283 | + if (is_array($sql)) { |
|
284 | 284 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
285 | 285 | } |
286 | 286 | // Flag if there are odd number of single quotes |
287 | 287 | if ((substr_count($sql, "'") & 1)) |
288 | - $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
288 | + $GLOBALS['log']->error("SQL statement[".$sql."] has odd number of single quotes."); |
|
289 | 289 | |
290 | 290 | $sql = $this->_appendN($sql); |
291 | 291 | |
292 | - $GLOBALS['log']->debug('Query:' . $sql); |
|
292 | + $GLOBALS['log']->debug('Query:'.$sql); |
|
293 | 293 | $this->checkConnection(); |
294 | 294 | $this->countQuery($sql); |
295 | 295 | $this->query_time = microtime(true); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | // Bug 34892 - Clear out previous error message by checking the @@ERROR global variable |
298 | 298 | @mssql_query("SELECT @@ERROR", $this->database); |
299 | 299 | |
300 | - $result = $suppress?@mssql_query($sql, $this->database):mssql_query($sql, $this->database); |
|
300 | + $result = $suppress ? @mssql_query($sql, $this->database) : mssql_query($sql, $this->database); |
|
301 | 301 | |
302 | 302 | if (!$result) { |
303 | 303 | // awu Bug 10657: ignoring mssql error message 'Changed database context to' - an intermittent |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
310 | 310 | |
311 | 311 | if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) // if sqlmsg has 'Changed database context to', just log it |
312 | - $GLOBALS['log']->debug($sqlmsg . ": " . $sql ); |
|
312 | + $GLOBALS['log']->debug($sqlmsg.": ".$sql); |
|
313 | 313 | else { |
314 | - $GLOBALS['log']->fatal($sqlmsg . ": " . $sql ); |
|
315 | - if($dieOnError) |
|
316 | - sugar_die('SQL Error : ' . $sqlmsg); |
|
314 | + $GLOBALS['log']->fatal($sqlmsg.": ".$sql); |
|
315 | + if ($dieOnError) |
|
316 | + sugar_die('SQL Error : '.$sqlmsg); |
|
317 | 317 | else |
318 | - echo 'SQL Error : ' . $sqlmsg; |
|
318 | + echo 'SQL Error : '.$sqlmsg; |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $GLOBALS['log']->debug('Query Execution Time:'.$this->query_time); |
324 | 324 | |
325 | 325 | |
326 | - $this->checkError($msg.' Query Failed: ' . $sql, $dieOnError); |
|
326 | + $this->checkError($msg.' Query Failed: '.$sql, $dieOnError); |
|
327 | 327 | |
328 | 328 | return $result; |
329 | 329 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | { |
342 | 342 | //set the start to 0, no negs |
343 | 343 | if ($start < 0) |
344 | - $start=0; |
|
344 | + $start = 0; |
|
345 | 345 | |
346 | - $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
|
346 | + $GLOBALS['log']->debug(print_r(func_get_args(), true)); |
|
347 | 347 | |
348 | 348 | $this->lastsql = $sql; |
349 | 349 | |
350 | 350 | //change the casing to lower for easier string comparison, and trim whitespaces |
351 | - $sql = strtolower(trim($sql)) ; |
|
351 | + $sql = strtolower(trim($sql)); |
|
352 | 352 | |
353 | 353 | //set default sql |
354 | 354 | $limitUnionSQL = $sql; |
@@ -364,16 +364,16 @@ discard block |
||
364 | 364 | $arr_count = 0; |
365 | 365 | |
366 | 366 | //process if there are elements |
367 | - if ($unionOrderByCount){ |
|
367 | + if ($unionOrderByCount) { |
|
368 | 368 | //we really want the last order by, so reconstruct string |
369 | 369 | //adding a 1 to count, as we dont wish to process the last element |
370 | 370 | $unionsql = ''; |
371 | - while ($unionOrderByCount>$arr_count+1) { |
|
371 | + while ($unionOrderByCount > $arr_count + 1) { |
|
372 | 372 | $unionsql .= $orderByArray[$arr_count]; |
373 | - $arr_count = $arr_count+1; |
|
373 | + $arr_count = $arr_count + 1; |
|
374 | 374 | //add an "order by" string back if we are coming into loop again |
375 | 375 | //remember they were taken out when array was created |
376 | - if ($unionOrderByCount>$arr_count+1) { |
|
376 | + if ($unionOrderByCount > $arr_count + 1) { |
|
377 | 377 | $unionsql .= "order by"; |
378 | 378 | } |
379 | 379 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | //so we do not want to strip the alias like in other queries. Just add the "order by" string and |
404 | 404 | //pass column name as is |
405 | 405 | if ($unionOrderBy != '') { |
406 | - $unionOrderBy = ' order by ' . $unionOrderBy; |
|
406 | + $unionOrderBy = ' order by '.$unionOrderBy; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | //Bug 56560, use top query in conjunction with rownumber() function |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | //If not for paging, no need to use rownumber() function |
413 | 413 | if ($count == 1 && $start == 0) |
414 | 414 | { |
415 | - $limitUnionSQL = "SELECT TOP $count * FROM (" .$unionsql .") as top_count ".$unionOrderBy; |
|
415 | + $limitUnionSQL = "SELECT TOP $count * FROM (".$unionsql.") as top_count ".$unionOrderBy; |
|
416 | 416 | } |
417 | 417 | else |
418 | 418 | { |
419 | 419 | $limitUnionSQL = "SELECT TOP $count * FROM( select ROW_NUMBER() OVER ( order by " |
420 | 420 | .$rowNumOrderBy.") AS row_number, * FROM (" |
421 | - .$unionsql .") As numbered) " |
|
421 | + .$unionsql.") As numbered) " |
|
422 | 422 | . "As top_count_limit WHERE row_number > $start " |
423 | 423 | .$unionOrderBy; |
424 | 424 | } |
@@ -437,64 +437,64 @@ discard block |
||
437 | 437 | $newSQL = $sql; |
438 | 438 | $distinctSQLARRAY = array(); |
439 | 439 | if (strpos($sql, "UNION") && !preg_match("/(')(UNION).?(')/i", $sql)) |
440 | - $newSQL = $this->handleUnionLimitQuery($sql,$start,$count); |
|
440 | + $newSQL = $this->handleUnionLimitQuery($sql, $start, $count); |
|
441 | 441 | else { |
442 | 442 | if ($start < 0) |
443 | 443 | $start = 0; |
444 | - $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
|
444 | + $GLOBALS['log']->debug(print_r(func_get_args(), true)); |
|
445 | 445 | $this->lastsql = $sql; |
446 | 446 | $matches = array(); |
447 | - preg_match('/^(.*SELECT\b)(.*?\bFROM\b.*\bWHERE\b)(.*)$/isU',$sql, $matches); |
|
447 | + preg_match('/^(.*SELECT\b)(.*?\bFROM\b.*\bWHERE\b)(.*)$/isU', $sql, $matches); |
|
448 | 448 | if (!empty($matches[3])) { |
449 | 449 | if ($start == 0) { |
450 | 450 | $match_two = strtolower($matches[2]); |
451 | - if (!strpos($match_two, "distinct")> 0 && strpos($match_two, "distinct") !==0) { |
|
451 | + if (!strpos($match_two, "distinct") > 0 && strpos($match_two, "distinct") !== 0) { |
|
452 | 452 | $orderByMatch = array(); |
453 | - preg_match('/^(.*)(\bORDER BY\b)(.*)$/is',$matches[3], $orderByMatch); |
|
453 | + preg_match('/^(.*)(\bORDER BY\b)(.*)$/is', $matches[3], $orderByMatch); |
|
454 | 454 | if (!empty($orderByMatch[3])) { |
455 | 455 | $selectPart = array(); |
456 | 456 | preg_match('/^(.*)(\bFROM\b.*)$/isU', $matches[2], $selectPart); |
457 | 457 | $newSQL = "SELECT TOP $count * FROM |
458 | 458 | ( |
459 | - " . $matches[1] . $selectPart[1] . ", ROW_NUMBER() |
|
460 | - OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number |
|
461 | - " . $selectPart[2] . $orderByMatch[1]. " |
|
459 | + ".$matches[1].$selectPart[1].", ROW_NUMBER() |
|
460 | + OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]).") AS row_number |
|
461 | + " . $selectPart[2].$orderByMatch[1]." |
|
462 | 462 | ) AS a |
463 | 463 | WHERE row_number > $start"; |
464 | 464 | } |
465 | 465 | else { |
466 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
466 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | else { |
470 | 470 | $distinct_o = strpos($match_two, "distinct"); |
471 | 471 | $up_to_distinct_str = substr($match_two, 0, $distinct_o); |
472 | 472 | //check to see if the distinct is within a function, if so, then proceed as normal |
473 | - if (strpos($up_to_distinct_str,"(")) { |
|
473 | + if (strpos($up_to_distinct_str, "(")) { |
|
474 | 474 | //proceed as normal |
475 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
475 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
476 | 476 | } |
477 | 477 | else { |
478 | 478 | //if distinct is not within a function, then parse |
479 | 479 | //string contains distinct clause, "TOP needs to come after Distinct" |
480 | 480 | //get position of distinct |
481 | 481 | $match_zero = strtolower($matches[0]); |
482 | - $distinct_pos = strpos($match_zero , "distinct"); |
|
482 | + $distinct_pos = strpos($match_zero, "distinct"); |
|
483 | 483 | //get position of where |
484 | 484 | $where_pos = strpos($match_zero, "where"); |
485 | 485 | //parse through string |
486 | - $beg = substr($matches[0], 0, $distinct_pos+9 ); |
|
487 | - $mid = substr($matches[0], strlen($beg), ($where_pos+5) - (strlen($beg))); |
|
488 | - $end = substr($matches[0], strlen($beg) + strlen($mid) ); |
|
486 | + $beg = substr($matches[0], 0, $distinct_pos + 9); |
|
487 | + $mid = substr($matches[0], strlen($beg), ($where_pos + 5) - (strlen($beg))); |
|
488 | + $end = substr($matches[0], strlen($beg) + strlen($mid)); |
|
489 | 489 | //repopulate matches array |
490 | 490 | $matches[1] = $beg; $matches[2] = $mid; $matches[3] = $end; |
491 | 491 | |
492 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
492 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } else { |
496 | 496 | $orderByMatch = array(); |
497 | - preg_match('/^(.*)(\bORDER BY\b)(.*)$/is',$matches[3], $orderByMatch); |
|
497 | + preg_match('/^(.*)(\bORDER BY\b)(.*)$/is', $matches[3], $orderByMatch); |
|
498 | 498 | |
499 | 499 | //if there is a distinct clause, parse sql string as we will have to insert the rownumber |
500 | 500 | //for paging, AFTER the distinct clause |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | |
513 | 513 | //take out the select and distinct from string so we can reuse in group by |
514 | 514 | $dist_str = 'distinct'; |
515 | - preg_match('/\b' . $dist_str . '\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
|
516 | - $matches_sql = trim(substr($matches_sql,$matchesPartSQL[0][1] + strlen($dist_str))); |
|
515 | + preg_match('/\b'.$dist_str.'\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
|
516 | + $matches_sql = trim(substr($matches_sql, $matchesPartSQL[0][1] + strlen($dist_str))); |
|
517 | 517 | //get the position of where and from for further processing |
518 | 518 | preg_match('/\bfrom\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
519 | 519 | $from_pos = $matchesPartSQL[0][1]; |
@@ -521,17 +521,17 @@ discard block |
||
521 | 521 | $where_pos = $matchesPartSQL[0][1]; |
522 | 522 | //split the sql into a string before and after the from clause |
523 | 523 | //we will use the columns being selected to construct the group by clause |
524 | - if ($from_pos>0 ) { |
|
524 | + if ($from_pos > 0) { |
|
525 | 525 | $distinctSQLARRAY[0] = substr($matches_sql, 0, $from_pos); |
526 | 526 | $distinctSQLARRAY[1] = substr($matches_sql, $from_pos); |
527 | 527 | //get position of order by (if it exists) so we can strip it from the string |
528 | 528 | $ob_pos = strpos($distinctSQLARRAY[1], "order by"); |
529 | 529 | if ($ob_pos) { |
530 | - $distinctSQLARRAY[1] = substr($distinctSQLARRAY[1],0,$ob_pos); |
|
530 | + $distinctSQLARRAY[1] = substr($distinctSQLARRAY[1], 0, $ob_pos); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | // strip off last closing parentheses from the where clause |
534 | - $distinctSQLARRAY[1] = preg_replace('/\)\s$/',' ',$distinctSQLARRAY[1]); |
|
534 | + $distinctSQLARRAY[1] = preg_replace('/\)\s$/', ' ', $distinctSQLARRAY[1]); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | $grpByStr = array(); |
@@ -550,30 +550,30 @@ discard block |
||
550 | 550 | $newSQL = "SELECT TOP $count * FROM |
551 | 551 | ( |
552 | 552 | SELECT ROW_NUMBER() |
553 | - OVER (ORDER BY " . preg_replace('/^' . $dist_str . '\s+/', '', $this->returnOrderBy($sql, $orderByMatch[3])) . ") AS row_number, |
|
554 | - count(*) counter, " . $distinctSQLARRAY[0] . " |
|
555 | - " . $distinctSQLARRAY[1] . " |
|
556 | - group by " . $grpByStr . " |
|
553 | + OVER (ORDER BY ".preg_replace('/^'.$dist_str.'\s+/', '', $this->returnOrderBy($sql, $orderByMatch[3])).") AS row_number, |
|
554 | + count(*) counter, " . $distinctSQLARRAY[0]." |
|
555 | + " . $distinctSQLARRAY[1]." |
|
556 | + group by " . $grpByStr." |
|
557 | 557 | ) AS a |
558 | 558 | WHERE row_number > $start"; |
559 | 559 | } |
560 | 560 | else { |
561 | 561 | $newSQL = "SELECT TOP $count * FROM |
562 | 562 | ( |
563 | - " . $matches[1] . " ROW_NUMBER() |
|
564 | - OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number, |
|
565 | - " . $matches[2] . $orderByMatch[1]. " |
|
563 | + ".$matches[1]." ROW_NUMBER() |
|
564 | + OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]).") AS row_number, |
|
565 | + " . $matches[2].$orderByMatch[1]." |
|
566 | 566 | ) AS a |
567 | 567 | WHERE row_number > $start"; |
568 | 568 | } |
569 | - }else{ |
|
569 | + } else { |
|
570 | 570 | //if there is a distinct clause, form query with rownumber after distinct |
571 | 571 | if ($hasDistinct) { |
572 | 572 | $newSQL = "SELECT TOP $count * FROM |
573 | 573 | ( |
574 | - SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, " . $distinctSQLARRAY[0] . " |
|
575 | - " . $distinctSQLARRAY[1] . " |
|
576 | - group by " . $grpByStr . " |
|
574 | + SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, ".$distinctSQLARRAY[0]." |
|
575 | + " . $distinctSQLARRAY[1]." |
|
576 | + group by " . $grpByStr." |
|
577 | 577 | ) |
578 | 578 | AS a |
579 | 579 | WHERE row_number > $start"; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | else { |
582 | 582 | $newSQL = "SELECT TOP $count * FROM |
583 | 583 | ( |
584 | - " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $sqlArray['FROM'][0]['alias'] . ".id) AS row_number, " . $matches[2] . $matches[3]. " |
|
584 | + ".$matches[1]." ROW_NUMBER() OVER (ORDER BY ".$sqlArray['FROM'][0]['alias'].".id) AS row_number, ".$matches[2].$matches[3]." |
|
585 | 585 | ) |
586 | 586 | AS a |
587 | 587 | WHERE row_number > $start"; |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
594 | - $GLOBALS['log']->debug('Limit Query: ' . $newSQL); |
|
595 | - if($execute) { |
|
596 | - $result = $this->query($newSQL, $dieOnError, $msg); |
|
594 | + $GLOBALS['log']->debug('Limit Query: '.$newSQL); |
|
595 | + if ($execute) { |
|
596 | + $result = $this->query($newSQL, $dieOnError, $msg); |
|
597 | 597 | $this->dump_slow_queries($newSQL); |
598 | 598 | return $result; |
599 | 599 | } else { |
@@ -615,15 +615,15 @@ discard block |
||
615 | 615 | private function removePatternFromSQL($p_sql, $strip_beg, $strip_end, $patt = 'patt') |
616 | 616 | { |
617 | 617 | //strip all single quotes out |
618 | - $count = substr_count ( $p_sql, $strip_beg); |
|
618 | + $count = substr_count($p_sql, $strip_beg); |
|
619 | 619 | $increment = 1; |
620 | 620 | if ($strip_beg != $strip_end) |
621 | 621 | $increment = 2; |
622 | 622 | |
623 | - $i=0; |
|
623 | + $i = 0; |
|
624 | 624 | $offset = 0; |
625 | 625 | $strip_array = array(); |
626 | - while ($i<$count && $offset<strlen($p_sql)) { |
|
626 | + while ($i < $count && $offset < strlen($p_sql)) { |
|
627 | 627 | if ($offset > strlen($p_sql)) |
628 | 628 | { |
629 | 629 | break; |
@@ -634,23 +634,23 @@ discard block |
||
634 | 634 | { |
635 | 635 | break; |
636 | 636 | } |
637 | - $sec_sin = strpos($p_sql, $strip_end, $beg_sin+1); |
|
638 | - $strip_array[$patt.$i] = substr($p_sql, $beg_sin, $sec_sin - $beg_sin +1); |
|
637 | + $sec_sin = strpos($p_sql, $strip_end, $beg_sin + 1); |
|
638 | + $strip_array[$patt.$i] = substr($p_sql, $beg_sin, $sec_sin - $beg_sin + 1); |
|
639 | 639 | if ($increment > 1) { |
640 | 640 | //we are in here because beginning and end patterns are not identical, so search for nesting |
641 | - $exists = strpos($strip_array[$patt.$i], $strip_beg ); |
|
642 | - if ($exists>=0) { |
|
643 | - $nested_pos = (strrpos($strip_array[$patt.$i], $strip_beg )); |
|
644 | - $strip_array[$patt.$i] = substr($p_sql,$nested_pos+$beg_sin,$sec_sin - ($nested_pos+$beg_sin)+1); |
|
645 | - $p_sql = substr($p_sql, 0, $nested_pos+$beg_sin) . " ##". $patt.$i."## " . substr($p_sql, $sec_sin+1); |
|
641 | + $exists = strpos($strip_array[$patt.$i], $strip_beg); |
|
642 | + if ($exists >= 0) { |
|
643 | + $nested_pos = (strrpos($strip_array[$patt.$i], $strip_beg)); |
|
644 | + $strip_array[$patt.$i] = substr($p_sql, $nested_pos + $beg_sin, $sec_sin - ($nested_pos + $beg_sin) + 1); |
|
645 | + $p_sql = substr($p_sql, 0, $nested_pos + $beg_sin)." ##".$patt.$i."## ".substr($p_sql, $sec_sin + 1); |
|
646 | 646 | $i = $i + 1; |
647 | 647 | continue; |
648 | 648 | } |
649 | 649 | } |
650 | - $p_len = strlen("##". $patt.$i."##"); |
|
651 | - $p_sql = substr($p_sql, 0, $beg_sin) . " ##". $patt.$i."## " . substr($p_sql, $sec_sin+1); |
|
650 | + $p_len = strlen("##".$patt.$i."##"); |
|
651 | + $p_sql = substr($p_sql, 0, $beg_sin)." ##".$patt.$i."## ".substr($p_sql, $sec_sin + 1); |
|
652 | 652 | //move the marker up |
653 | - $offset = ($sec_sin-($sec_sin-$beg_sin))+$p_len+1; // Adjusting the starting point of the marker |
|
653 | + $offset = ($sec_sin - ($sec_sin - $beg_sin)) + $p_len + 1; // Adjusting the starting point of the marker |
|
654 | 654 | |
655 | 655 | $i = $i + 1; |
656 | 656 | } |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | $pattern_array = array_reverse($pattern_array); |
673 | 673 | |
674 | 674 | foreach ($pattern_array as $key => $replace) { |
675 | - $token = str_replace( " ##".$key."## ", $replace,$token); |
|
675 | + $token = str_replace(" ##".$key."## ", $replace, $token); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | return $token; |
@@ -688,11 +688,11 @@ discard block |
||
688 | 688 | private function getAliasFromSQL($sql, $alias) |
689 | 689 | { |
690 | 690 | $matches = array(); |
691 | - preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU',$sql, $matches); |
|
691 | + preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU', $sql, $matches); |
|
692 | 692 | //parse all single and double quotes out of array |
693 | - $sin_array = $this->removePatternFromSQL($matches[2], "'", "'","sin_"); |
|
693 | + $sin_array = $this->removePatternFromSQL($matches[2], "'", "'", "sin_"); |
|
694 | 694 | $new_sql = array_pop($sin_array); |
695 | - $dub_array = $this->removePatternFromSQL($new_sql, "\"", "\"","dub_"); |
|
695 | + $dub_array = $this->removePatternFromSQL($new_sql, "\"", "\"", "dub_"); |
|
696 | 696 | $new_sql = array_pop($dub_array); |
697 | 697 | |
698 | 698 | //search for parenthesis |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | |
702 | 702 | //all functions should be removed now, so split the array on commas |
703 | 703 | $mstr_sql_array = explode(",", $new_sql); |
704 | - foreach($mstr_sql_array as $token ) { |
|
704 | + foreach ($mstr_sql_array as $token) { |
|
705 | 705 | if (strpos($token, $alias)) { |
706 | 706 | //found token, add back comments |
707 | 707 | $token = $this->addPatternToSQL($token, $paren_array); |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | $found = $found_in_sql; |
740 | 740 | |
741 | 741 | //if still no match found, then we need to parse through the string |
742 | - if (!$found_in_sql){ |
|
742 | + if (!$found_in_sql) { |
|
743 | 743 | //get count of how many times the match exists in string |
744 | 744 | $found_count = substr_count($sql, $orderMatch); |
745 | 745 | $i = 0; |
@@ -748,21 +748,21 @@ discard block |
||
748 | 748 | //loop through string as many times as there is a match |
749 | 749 | while ($found_count > $i) { |
750 | 750 | //get the first match |
751 | - $found_in_sql = strpos($sql, $orderMatch,$first_); |
|
751 | + $found_in_sql = strpos($sql, $orderMatch, $first_); |
|
752 | 752 | //make sure there was a match |
753 | - if($found_in_sql){ |
|
753 | + if ($found_in_sql) { |
|
754 | 754 | //grab the next 2 individual characters |
755 | - $str_plusone = substr($sql,$found_in_sql + $len,1); |
|
756 | - $str_plustwo = substr($sql,$found_in_sql + $len+1,1); |
|
755 | + $str_plusone = substr($sql, $found_in_sql + $len, 1); |
|
756 | + $str_plustwo = substr($sql, $found_in_sql + $len + 1, 1); |
|
757 | 757 | //if one of those characters is a comma, then we have our alias |
758 | - if ($str_plusone === "," || $str_plustwo === ","){ |
|
758 | + if ($str_plusone === "," || $str_plustwo === ",") { |
|
759 | 759 | //keep track of this position |
760 | 760 | $found = $found_in_sql; |
761 | 761 | } |
762 | 762 | } |
763 | 763 | //set the offset and increase the iteration counter |
764 | - $first_ = $found_in_sql+$len; |
|
765 | - $i = $i+1; |
|
764 | + $first_ = $found_in_sql + $len; |
|
765 | + $i = $i + 1; |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | //return $found, defaults have been set, so if no match was found it will be a negative number |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | $firstSpace = strpos($orig_order_match, " "); |
795 | 795 | |
796 | 796 | //split order by into column name and ascending/descending |
797 | - $orderMatch = " " . strtolower(substr($orig_order_match, 0, $firstSpace)); |
|
798 | - $asc_desc = trim(substr($orig_order_match,$firstSpace)); |
|
797 | + $orderMatch = " ".strtolower(substr($orig_order_match, 0, $firstSpace)); |
|
798 | + $asc_desc = trim(substr($orig_order_match, $firstSpace)); |
|
799 | 799 | |
800 | 800 | //look for column name as an alias in sql string |
801 | 801 | $found_in_sql = $this->findColumnByAlias($sql, $orderMatch); |
@@ -806,18 +806,18 @@ discard block |
||
806 | 806 | $colMatchPos = strpos($sql, $orderMatch); |
807 | 807 | if ($colMatchPos !== false) { |
808 | 808 | //grab sub string up to column name |
809 | - $containsColStr = substr($sql,0, $colMatchPos); |
|
809 | + $containsColStr = substr($sql, 0, $colMatchPos); |
|
810 | 810 | //get position of first space, so we can grab table name |
811 | 811 | $lastSpacePos = strrpos($containsColStr, " "); |
812 | 812 | //use positions of column name, space before name, and length of column to find the correct column name |
813 | - $col_name = substr($sql, $lastSpacePos, $colMatchPos-$lastSpacePos+strlen($orderMatch)); |
|
813 | + $col_name = substr($sql, $lastSpacePos, $colMatchPos - $lastSpacePos + strlen($orderMatch)); |
|
814 | 814 | //bug 25485. When sorting by a custom field in Account List and then pressing NEXT >, system gives an error |
815 | 815 | $containsCommaPos = strpos($col_name, ","); |
816 | - if($containsCommaPos !== false) { |
|
817 | - $col_name = substr($col_name, $containsCommaPos+1); |
|
816 | + if ($containsCommaPos !== false) { |
|
817 | + $col_name = substr($col_name, $containsCommaPos + 1); |
|
818 | 818 | } |
819 | 819 | //add the "asc/desc" order back |
820 | - $col_name = $col_name. " ". $asc_desc; |
|
820 | + $col_name = $col_name." ".$asc_desc; |
|
821 | 821 | |
822 | 822 | //return column name |
823 | 823 | return $col_name; |
@@ -831,22 +831,22 @@ discard block |
||
831 | 831 | //grab string up to the aliased column |
832 | 832 | $GLOBALS['log']->debug("order by found, process sql string"); |
833 | 833 | |
834 | - $psql = (trim($this->getAliasFromSQL($sql, $orderMatch ))); |
|
834 | + $psql = (trim($this->getAliasFromSQL($sql, $orderMatch))); |
|
835 | 835 | if (empty($psql)) |
836 | 836 | $psql = trim(substr($sql, 0, $found_in_sql)); |
837 | 837 | |
838 | 838 | //grab the last comma before the alias |
839 | - preg_match('/\s+' . trim($orderMatch). '/', $psql, $match, PREG_OFFSET_CAPTURE); |
|
839 | + preg_match('/\s+'.trim($orderMatch).'/', $psql, $match, PREG_OFFSET_CAPTURE); |
|
840 | 840 | $comma_pos = $match[0][1]; |
841 | 841 | //substring between the comma and the alias to find the joined_table alias and column name |
842 | - $col_name = substr($psql,0, $comma_pos); |
|
842 | + $col_name = substr($psql, 0, $comma_pos); |
|
843 | 843 | |
844 | 844 | //make sure the string does not have an end parenthesis |
845 | 845 | //and is not part of a function (i.e. "ISNULL(leads.last_name,'') as name" ) |
846 | 846 | //this is especially true for unified search from home screen |
847 | 847 | |
848 | 848 | $alias_beg_pos = 0; |
849 | - if(strpos($psql, " as ")) |
|
849 | + if (strpos($psql, " as ")) |
|
850 | 850 | $alias_beg_pos = strpos($psql, " as "); |
851 | 851 | |
852 | 852 | // Bug # 44923 - This breaks the query and does not properly filter isnull |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | $alias_beg_pos = strpos($psql, " "); */ |
856 | 856 | |
857 | 857 | if ($alias_beg_pos > 0) { |
858 | - $col_name = substr($psql,0, $alias_beg_pos ); |
|
858 | + $col_name = substr($psql, 0, $alias_beg_pos); |
|
859 | 859 | } |
860 | 860 | //add the "asc/desc" order back |
861 | - $col_name = $col_name. " ". $asc_desc; |
|
861 | + $col_name = $col_name." ".$asc_desc; |
|
862 | 862 | |
863 | 863 | //pass in new order by |
864 | - $GLOBALS['log']->debug("order by being returned is " . $col_name); |
|
864 | + $GLOBALS['log']->debug("order by being returned is ".$col_name); |
|
865 | 865 | return $col_name; |
866 | 866 | } |
867 | 867 | } |
@@ -877,12 +877,12 @@ discard block |
||
877 | 877 | { |
878 | 878 | |
879 | 879 | global $beanList, $beanFiles; |
880 | - $GLOBALS['log']->debug("Module being processed is " . $module_str); |
|
880 | + $GLOBALS['log']->debug("Module being processed is ".$module_str); |
|
881 | 881 | //get the right module files |
882 | 882 | //the module string exists in bean list, then process bean for correct table name |
883 | 883 | //note that we exempt the reports module from this, as queries from reporting module should be parsed for |
884 | 884 | //correct table name. |
885 | - if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str]) && isset($beanFiles[$beanList[$module_str]])){ |
|
885 | + if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str]) && isset($beanFiles[$beanList[$module_str]])) { |
|
886 | 886 | //if the class is not already loaded, then load files |
887 | 887 | if (!class_exists($beanList[$module_str])) |
888 | 888 | require_once($beanFiles[$beanList[$module_str]]); |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | //make sure table name is not just a blank space, or empty |
895 | 895 | $tbl_name = trim($tbl_name); |
896 | 896 | |
897 | - if(empty($tbl_name)){ |
|
897 | + if (empty($tbl_name)) { |
|
898 | 898 | $GLOBALS['log']->debug("Could not find table name for module $module_str. "); |
899 | 899 | $tbl_name = $module_str; |
900 | 900 | } |
@@ -911,20 +911,20 @@ discard block |
||
911 | 911 | $sql = str_replace(array("\n", "\r"), " ", $sql); |
912 | 912 | |
913 | 913 | //look for the location of the "from" in sql string |
914 | - $fromLoc = strpos($sql," from " ); |
|
915 | - if ($fromLoc>0){ |
|
914 | + $fromLoc = strpos($sql, " from "); |
|
915 | + if ($fromLoc > 0) { |
|
916 | 916 | //found from, substring from the " FROM " string in sql to end |
917 | - $tableEnd = substr($sql, $fromLoc+6); |
|
917 | + $tableEnd = substr($sql, $fromLoc + 6); |
|
918 | 918 | //We know that tablename will be next parameter after from, so |
919 | 919 | //grab the next space after table name. |
920 | 920 | // MFH BUG #14009: Also check to see if there are any carriage returns before the next space so that we don't grab any arbitrary joins or other tables. |
921 | - $carriage_ret = strpos($tableEnd,"\n"); |
|
922 | - $next_space = strpos($tableEnd," " ); |
|
921 | + $carriage_ret = strpos($tableEnd, "\n"); |
|
922 | + $next_space = strpos($tableEnd, " "); |
|
923 | 923 | if ($carriage_ret < $next_space) |
924 | 924 | $next_space = $carriage_ret; |
925 | 925 | if ($next_space > 0) { |
926 | - $tbl_name= substr($tableEnd,0, $next_space); |
|
927 | - if(empty($tbl_name)){ |
|
926 | + $tbl_name = substr($tableEnd, 0, $next_space); |
|
927 | + if (empty($tbl_name)) { |
|
928 | 928 | $GLOBALS['log']->debug("Could not find table name sql either, return $module_str. "); |
929 | 929 | $tbl_name = $module_str; |
930 | 930 | } |
@@ -932,11 +932,11 @@ discard block |
||
932 | 932 | |
933 | 933 | //grab the table, to see if it is aliased |
934 | 934 | $aliasTableEnd = trim(substr($tableEnd, $next_space)); |
935 | - $alias_space = strpos ($aliasTableEnd, " " ); |
|
936 | - if ($alias_space > 0){ |
|
937 | - $alias_tbl_name= substr($aliasTableEnd,0, $alias_space); |
|
935 | + $alias_space = strpos($aliasTableEnd, " "); |
|
936 | + if ($alias_space > 0) { |
|
937 | + $alias_tbl_name = substr($aliasTableEnd, 0, $alias_space); |
|
938 | 938 | strtolower($alias_tbl_name); |
939 | - if(empty($alias_tbl_name) |
|
939 | + if (empty($alias_tbl_name) |
|
940 | 940 | || $alias_tbl_name == "where" |
941 | 941 | || $alias_tbl_name == "inner" |
942 | 942 | || $alias_tbl_name == "left" |
@@ -948,9 +948,9 @@ discard block |
||
948 | 948 | elseif ($alias_tbl_name == "as") { |
949 | 949 | //the next word is the table name |
950 | 950 | $aliasTableEnd = trim(substr($aliasTableEnd, $alias_space)); |
951 | - $alias_space = strpos ($aliasTableEnd, " " ); |
|
951 | + $alias_space = strpos($aliasTableEnd, " "); |
|
952 | 952 | if ($alias_space > 0) { |
953 | - $alias_tbl_name= trim(substr($aliasTableEnd,0, $alias_space)); |
|
953 | + $alias_tbl_name = trim(substr($aliasTableEnd, 0, $alias_space)); |
|
954 | 954 | if (!empty($alias_tbl_name)) |
955 | 955 | $tbl_name = $alias_tbl_name; |
956 | 956 | } |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | { |
976 | 976 | $field_array = array(); |
977 | 977 | |
978 | - if(! isset($result) || empty($result)) |
|
978 | + if (!isset($result) || empty($result)) |
|
979 | 979 | return 0; |
980 | 980 | |
981 | 981 | $i = 0; |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | $meta = mssql_fetch_field($result, $i); |
984 | 984 | if (!$meta) |
985 | 985 | return 0; |
986 | - if($make_lower_case==true) |
|
986 | + if ($make_lower_case == true) |
|
987 | 987 | $meta->name = strtolower($meta->name); |
988 | 988 | |
989 | 989 | $field_array[] = $meta->name; |
@@ -1012,11 +1012,11 @@ discard block |
||
1012 | 1012 | $row = mssql_fetch_assoc($result); |
1013 | 1013 | //MSSQL returns a space " " when a varchar column is empty ("") and not null. |
1014 | 1014 | //We need to iterate through the returned row array and strip empty spaces |
1015 | - if(!empty($row)){ |
|
1016 | - foreach($row as $key => $column) { |
|
1015 | + if (!empty($row)) { |
|
1016 | + foreach ($row as $key => $column) { |
|
1017 | 1017 | //notice we only strip if one space is returned. we do not want to strip |
1018 | 1018 | //strings with intentional spaces (" foo ") |
1019 | - if (!empty($column) && $column ==" ") { |
|
1019 | + if (!empty($column) && $column == " ") { |
|
1020 | 1020 | $row[$key] = ''; |
1021 | 1021 | } |
1022 | 1022 | } |
@@ -1029,10 +1029,10 @@ discard block |
||
1029 | 1029 | */ |
1030 | 1030 | public function quote($string) |
1031 | 1031 | { |
1032 | - if(is_array($string)) { |
|
1032 | + if (is_array($string)) { |
|
1033 | 1033 | return $this->arrayQuote($string); |
1034 | 1034 | } |
1035 | - return str_replace("'","''", $this->quoteInternal($string)); |
|
1035 | + return str_replace("'", "''", $this->quoteInternal($string)); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | if (!empty($r)) { |
1071 | 1071 | while ($a = $this->fetchByAssoc($r)) { |
1072 | 1072 | $row = array_values($a); |
1073 | - $tables[]=$row[0]; |
|
1073 | + $tables[] = $row[0]; |
|
1074 | 1074 | } |
1075 | 1075 | return $tables; |
1076 | 1076 | } |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | { |
1086 | 1086 | $GLOBALS['log']->debug('MSSQL fetching table list'); |
1087 | 1087 | |
1088 | - if($this->getDatabase()) { |
|
1088 | + if ($this->getDatabase()) { |
|
1089 | 1089 | $tables = array(); |
1090 | 1090 | $r = $this->query('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES'); |
1091 | 1091 | if (is_resource($r)) { |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | { |
1110 | 1110 | $GLOBALS['log']->debug('MSSQL about to wakeup FTS'); |
1111 | 1111 | |
1112 | - if($this->getDatabase()) { |
|
1112 | + if ($this->getDatabase()) { |
|
1113 | 1113 | //create wakeup catalog |
1114 | 1114 | $FTSqry[] = "if not exists( select * from sys.fulltext_catalogs where name ='wakeup_catalog' ) |
1115 | 1115 | CREATE FULLTEXT CATALOG wakeup_catalog |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $FTSqry[] = 'ALTER FULLTEXT INDEX ON fts_wakeup START FULL POPULATION'; |
1150 | 1150 | $FTSqry[] = 'ALTER FULLTEXT INDEX ON fts_wakeup SET CHANGE_TRACKING AUTO'; |
1151 | 1151 | |
1152 | - foreach($FTSqry as $q){ |
|
1152 | + foreach ($FTSqry as $q) { |
|
1153 | 1153 | sleep(3); |
1154 | 1154 | $this->query($q); |
1155 | 1155 | } |
@@ -1172,12 +1172,12 @@ discard block |
||
1172 | 1172 | { |
1173 | 1173 | // convert the parameters array into a comma delimited string |
1174 | 1174 | if (!empty($additional_parameters)) { |
1175 | - $additional_parameters_string = ','.implode(',',$additional_parameters); |
|
1175 | + $additional_parameters_string = ','.implode(',', $additional_parameters); |
|
1176 | 1176 | } else { |
1177 | 1177 | $additional_parameters_string = ''; |
1178 | 1178 | } |
1179 | 1179 | $all_parameters = $additional_parameters; |
1180 | - if(is_array($string)) { |
|
1180 | + if (is_array($string)) { |
|
1181 | 1181 | $all_parameters = array_merge($string, $all_parameters); |
1182 | 1182 | } elseif (!is_null($string)) { |
1183 | 1183 | array_unshift($all_parameters, $string); |
@@ -1189,22 +1189,22 @@ discard block |
||
1189 | 1189 | case 'left': |
1190 | 1190 | return "LEFT($string$additional_parameters_string)"; |
1191 | 1191 | case 'date_format': |
1192 | - if(!empty($additional_parameters[0]) && $additional_parameters[0][0] == "'") { |
|
1192 | + if (!empty($additional_parameters[0]) && $additional_parameters[0][0] == "'") { |
|
1193 | 1193 | $additional_parameters[0] = trim($additional_parameters[0], "'"); |
1194 | 1194 | } |
1195 | - if(!empty($additional_parameters) && isset($this->date_formats[$additional_parameters[0]])) { |
|
1195 | + if (!empty($additional_parameters) && isset($this->date_formats[$additional_parameters[0]])) { |
|
1196 | 1196 | $len = $this->date_formats[$additional_parameters[0]]; |
1197 | - return "LEFT(CONVERT(varchar($len),". $string . ",120),$len)"; |
|
1197 | + return "LEFT(CONVERT(varchar($len),".$string.",120),$len)"; |
|
1198 | 1198 | } else { |
1199 | - return "LEFT(CONVERT(varchar(10),". $string . ",120),10)"; |
|
1199 | + return "LEFT(CONVERT(varchar(10),".$string.",120),10)"; |
|
1200 | 1200 | } |
1201 | 1201 | case 'ifnull': |
1202 | - if(empty($additional_parameters_string)) { |
|
1202 | + if (empty($additional_parameters_string)) { |
|
1203 | 1203 | $additional_parameters_string = ",''"; |
1204 | 1204 | } |
1205 | 1205 | return "ISNULL($string$additional_parameters_string)"; |
1206 | 1206 | case 'concat': |
1207 | - return implode("+",$all_parameters); |
|
1207 | + return implode("+", $all_parameters); |
|
1208 | 1208 | case 'text2char': |
1209 | 1209 | return "CAST($string AS varchar(8000))"; |
1210 | 1210 | case 'quarter': |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | case 'add_tz_offset' : |
1221 | 1221 | $getUserUTCOffset = $GLOBALS['timedate']->getUserUTCOffset(); |
1222 | 1222 | $operation = $getUserUTCOffset < 0 ? '-' : '+'; |
1223 | - return 'DATEADD(minute, ' . $operation . abs($getUserUTCOffset) . ', ' . $string. ')'; |
|
1223 | + return 'DATEADD(minute, '.$operation.abs($getUserUTCOffset).', '.$string.')'; |
|
1224 | 1224 | case 'avg': |
1225 | 1225 | return "avg($string)"; |
1226 | 1226 | } |
@@ -1233,9 +1233,9 @@ discard block |
||
1233 | 1233 | */ |
1234 | 1234 | public function fromConvert($string, $type) |
1235 | 1235 | { |
1236 | - switch($type) { |
|
1236 | + switch ($type) { |
|
1237 | 1237 | case 'datetimecombo': |
1238 | - case 'datetime': return substr($string, 0,19); |
|
1238 | + case 'datetime': return substr($string, 0, 19); |
|
1239 | 1239 | case 'date': return substr($string, 0, 10); |
1240 | 1240 | case 'time': return substr($string, 11); |
1241 | 1241 | } |
@@ -1264,8 +1264,8 @@ discard block |
||
1264 | 1264 | public function isTextType($type) |
1265 | 1265 | { |
1266 | 1266 | $type = strtolower($type); |
1267 | - if(!isset($this->type_map[$type])) return false; |
|
1268 | - return in_array($this->type_map[$type], array('ntext','text','image', 'nvarchar(max)')); |
|
1267 | + if (!isset($this->type_map[$type])) return false; |
|
1268 | + return in_array($this->type_map[$type], array('ntext', 'text', 'image', 'nvarchar(max)')); |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | /** |
@@ -1275,13 +1275,13 @@ discard block |
||
1275 | 1275 | public function emptyValue($type) |
1276 | 1276 | { |
1277 | 1277 | $ctype = $this->getColumnType($type); |
1278 | - if($ctype == "datetime") { |
|
1278 | + if ($ctype == "datetime") { |
|
1279 | 1279 | return $this->convert($this->quoted("1970-01-01 00:00:00"), "datetime"); |
1280 | 1280 | } |
1281 | - if($ctype == "date") { |
|
1281 | + if ($ctype == "date") { |
|
1282 | 1282 | return $this->convert($this->quoted("1970-01-01"), "datetime"); |
1283 | 1283 | } |
1284 | - if($ctype == "time") { |
|
1284 | + if ($ctype == "time") { |
|
1285 | 1285 | return $this->convert($this->quoted("00:00:00"), "time"); |
1286 | 1286 | } |
1287 | 1287 | return parent::emptyValue($type); |
@@ -1304,21 +1304,21 @@ discard block |
||
1304 | 1304 | */ |
1305 | 1305 | protected function alterSQLRep($action, array $def, $ignoreRequired, $tablename) |
1306 | 1306 | { |
1307 | - switch($action){ |
|
1307 | + switch ($action) { |
|
1308 | 1308 | case 'add': |
1309 | - $f_def=$this->oneColumnSQLRep($def, $ignoreRequired,$tablename,false); |
|
1310 | - return "ADD " . $f_def; |
|
1309 | + $f_def = $this->oneColumnSQLRep($def, $ignoreRequired, $tablename, false); |
|
1310 | + return "ADD ".$f_def; |
|
1311 | 1311 | break; |
1312 | 1312 | case 'drop': |
1313 | - return "DROP COLUMN " . $def['name']; |
|
1313 | + return "DROP COLUMN ".$def['name']; |
|
1314 | 1314 | break; |
1315 | 1315 | case 'modify': |
1316 | 1316 | //You cannot specify a default value for a column for MSSQL |
1317 | - $f_def = $this->oneColumnSQLRep($def, $ignoreRequired,$tablename, true); |
|
1317 | + $f_def = $this->oneColumnSQLRep($def, $ignoreRequired, $tablename, true); |
|
1318 | 1318 | $f_stmt = "ALTER COLUMN ".$f_def['name'].' '.$f_def['colType'].' '. |
1319 | 1319 | $f_def['required'].' '.$f_def['auto_increment']."\n"; |
1320 | - if (!empty( $f_def['default'])) |
|
1321 | - $f_stmt .= " ALTER TABLE " . $tablename . " ADD ". $f_def['default'] . " FOR " . $def['name']; |
|
1320 | + if (!empty($f_def['default'])) |
|
1321 | + $f_stmt .= " ALTER TABLE ".$tablename." ADD ".$f_def['default']." FOR ".$def['name']; |
|
1322 | 1322 | return $f_stmt; |
1323 | 1323 | break; |
1324 | 1324 | default: |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | */ |
1335 | 1335 | protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
1336 | 1336 | { |
1337 | - $sql=$sql2=''; |
|
1337 | + $sql = $sql2 = ''; |
|
1338 | 1338 | $constraints = $this->get_field_default_constraint_name($tablename); |
1339 | 1339 | $columns = array(); |
1340 | 1340 | if ($this->isFieldArray($fieldDefs)) { |
@@ -1343,41 +1343,41 @@ discard block |
||
1343 | 1343 | //if the column is being modified drop the default value |
1344 | 1344 | //constraint if it exists. alterSQLRep will add the constraint back |
1345 | 1345 | if (!empty($constraints[$def['name']])) { |
1346 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$def['name']]; |
|
1346 | + $sql .= " ALTER TABLE ".$tablename." DROP CONSTRAINT ".$constraints[$def['name']]; |
|
1347 | 1347 | } |
1348 | 1348 | //check to see if we need to drop related indexes before the alter |
1349 | 1349 | $indices = $this->get_indices($tablename); |
1350 | - foreach ( $indices as $index ) { |
|
1351 | - if ( in_array($def['name'],$index['fields']) ) { |
|
1352 | - $sql .= ' ' . $this->add_drop_constraint($tablename,$index,true).' '; |
|
1353 | - $sql2 .= ' ' . $this->add_drop_constraint($tablename,$index,false).' '; |
|
1350 | + foreach ($indices as $index) { |
|
1351 | + if (in_array($def['name'], $index['fields'])) { |
|
1352 | + $sql .= ' '.$this->add_drop_constraint($tablename, $index, true).' '; |
|
1353 | + $sql2 .= ' '.$this->add_drop_constraint($tablename, $index, false).' '; |
|
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename); |
|
1357 | + $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired, $tablename); |
|
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | else { |
1361 | 1361 | //if the column is being modified drop the default value |
1362 | 1362 | //constraint if it exists. alterSQLRep will add the constraint back |
1363 | 1363 | if (!empty($constraints[$fieldDefs['name']])) { |
1364 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$fieldDefs['name']]; |
|
1364 | + $sql .= " ALTER TABLE ".$tablename." DROP CONSTRAINT ".$constraints[$fieldDefs['name']]; |
|
1365 | 1365 | } |
1366 | 1366 | //check to see if we need to drop related indexes before the alter |
1367 | 1367 | $indices = $this->get_indices($tablename); |
1368 | - foreach ( $indices as $index ) { |
|
1369 | - if ( in_array($fieldDefs['name'],$index['fields']) ) { |
|
1370 | - $sql .= ' ' . $this->add_drop_constraint($tablename,$index,true).' '; |
|
1371 | - $sql2 .= ' ' . $this->add_drop_constraint($tablename,$index,false).' '; |
|
1368 | + foreach ($indices as $index) { |
|
1369 | + if (in_array($fieldDefs['name'], $index['fields'])) { |
|
1370 | + $sql .= ' '.$this->add_drop_constraint($tablename, $index, true).' '; |
|
1371 | + $sql2 .= ' '.$this->add_drop_constraint($tablename, $index, false).' '; |
|
1372 | 1372 | } |
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | |
1376 | - $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired,$tablename); |
|
1376 | + $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired, $tablename); |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | $columns = implode(", ", $columns); |
1380 | - $sql .= " ALTER TABLE $tablename $columns " . $sql2; |
|
1380 | + $sql .= " ALTER TABLE $tablename $columns ".$sql2; |
|
1381 | 1381 | |
1382 | 1382 | return $sql; |
1383 | 1383 | } |
@@ -1392,7 +1392,7 @@ discard block |
||
1392 | 1392 | */ |
1393 | 1393 | public function setAutoIncrementStart($table, $field_name, $start_value) |
1394 | 1394 | { |
1395 | - if($start_value > 1) |
|
1395 | + if ($start_value > 1) |
|
1396 | 1396 | $start_value -= 1; |
1397 | 1397 | $this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS"); |
1398 | 1398 | return true; |
@@ -1427,11 +1427,11 @@ discard block |
||
1427 | 1427 | $result = $this->query($query); |
1428 | 1428 | |
1429 | 1429 | $indices = array(); |
1430 | - while (($row=$this->fetchByAssoc($result)) != null) { |
|
1430 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
1431 | 1431 | $index_type = 'index'; |
1432 | 1432 | if ($row['is_primary_key'] == '1') |
1433 | 1433 | $index_type = 'primary'; |
1434 | - elseif ($row['is_unique'] == 1 ) |
|
1434 | + elseif ($row['is_unique'] == 1) |
|
1435 | 1435 | $index_type = 'unique'; |
1436 | 1436 | $name = strtolower($row['index_name']); |
1437 | 1437 | $indices[$name]['name'] = $name; |
@@ -1450,36 +1450,36 @@ discard block |
||
1450 | 1450 | $result = $this->query("sp_columns $tablename"); |
1451 | 1451 | |
1452 | 1452 | $columns = array(); |
1453 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
1453 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
1454 | 1454 | $column_name = strtolower($row['COLUMN_NAME']); |
1455 | - $columns[$column_name]['name']=$column_name; |
|
1456 | - $columns[$column_name]['type']=strtolower($row['TYPE_NAME']); |
|
1457 | - if ( $row['TYPE_NAME'] == 'decimal' ) { |
|
1458 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1459 | - $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
|
1455 | + $columns[$column_name]['name'] = $column_name; |
|
1456 | + $columns[$column_name]['type'] = strtolower($row['TYPE_NAME']); |
|
1457 | + if ($row['TYPE_NAME'] == 'decimal') { |
|
1458 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
1459 | + $columns[$column_name]['len'] .= ','.strtolower($row['SCALE']); |
|
1460 | 1460 | } |
1461 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) |
|
1462 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1463 | - elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) |
|
1464 | - $columns[$column_name]['len']=strtolower($row['LENGTH']); |
|
1465 | - if ( stristr($row['TYPE_NAME'],'identity') ) { |
|
1461 | + elseif (in_array($row['TYPE_NAME'], array('nchar', 'nvarchar'))) |
|
1462 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
1463 | + elseif (!in_array($row['TYPE_NAME'], array('datetime', 'text'))) |
|
1464 | + $columns[$column_name]['len'] = strtolower($row['LENGTH']); |
|
1465 | + if (stristr($row['TYPE_NAME'], 'identity')) { |
|
1466 | 1466 | $columns[$column_name]['auto_increment'] = '1'; |
1467 | - $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME'])); |
|
1467 | + $columns[$column_name]['type'] = str_replace(' identity', '', strtolower($row['TYPE_NAME'])); |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | - if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) |
|
1470 | + if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'], 'PRI'))) |
|
1471 | 1471 | $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
1472 | 1472 | |
1473 | 1473 | $column_def = 1; |
1474 | - if ( strtolower($tablename) == 'relationships' ) { |
|
1474 | + if (strtolower($tablename) == 'relationships') { |
|
1475 | 1475 | $column_def = $this->getOne("select cdefault from syscolumns where id = object_id('relationships') and name = '$column_name'"); |
1476 | 1476 | } |
1477 | - if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
1477 | + if ($column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
1478 | 1478 | $matches = array(); |
1479 | - $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES); |
|
1480 | - if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) |
|
1479 | + $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'], ENT_QUOTES); |
|
1480 | + if (preg_match('/\([\(|\'](.*)[\)|\']\)/i', $row['COLUMN_DEF'], $matches)) |
|
1481 | 1481 | $columns[$column_name]['default'] = $matches[1]; |
1482 | - elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) |
|
1482 | + elseif (preg_match('/\(N\'(.*)\'\)/i', $row['COLUMN_DEF'], $matches)) |
|
1483 | 1483 | $columns[$column_name]['default'] = $matches[1]; |
1484 | 1484 | else |
1485 | 1485 | $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | */ |
1495 | 1495 | protected function ftsCatalogName() |
1496 | 1496 | { |
1497 | - if(isset($this->connectOptions['db_name'])) { |
|
1497 | + if (isset($this->connectOptions['db_name'])) { |
|
1498 | 1498 | return $this->connectOptions['db_name']."_fts_catalog"; |
1499 | 1499 | } |
1500 | 1500 | return 'sugar_fts_catalog'; |
@@ -1506,11 +1506,11 @@ discard block |
||
1506 | 1506 | public function add_drop_constraint($table, $definition, $drop = false) |
1507 | 1507 | { |
1508 | 1508 | $type = $definition['type']; |
1509 | - $fields = is_array($definition['fields'])?implode(',',$definition['fields']):$definition['fields']; |
|
1509 | + $fields = is_array($definition['fields']) ? implode(',', $definition['fields']) : $definition['fields']; |
|
1510 | 1510 | $name = $definition['name']; |
1511 | 1511 | $sql = ''; |
1512 | 1512 | |
1513 | - switch ($type){ |
|
1513 | + switch ($type) { |
|
1514 | 1514 | // generic indices |
1515 | 1515 | case 'index': |
1516 | 1516 | case 'alternate_key': |
@@ -1548,13 +1548,13 @@ discard block |
||
1548 | 1548 | if ($this->full_text_indexing_enabled() && $drop) { |
1549 | 1549 | $sql = "DROP FULLTEXT INDEX ON {$table}"; |
1550 | 1550 | } elseif ($this->full_text_indexing_enabled()) { |
1551 | - $catalog_name=$this->ftsCatalogName(); |
|
1552 | - if ( isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') |
|
1551 | + $catalog_name = $this->ftsCatalogName(); |
|
1552 | + if (isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') |
|
1553 | 1553 | $catalog_name = $definition['catalog_name']; |
1554 | 1554 | |
1555 | 1555 | $language = "Language 1033"; |
1556 | 1556 | if (isset($definition['language']) && !empty($definition['language'])) |
1557 | - $language = "Language " . $definition['language']; |
|
1557 | + $language = "Language ".$definition['language']; |
|
1558 | 1558 | |
1559 | 1559 | $key_index = $definition['key_index']; |
1560 | 1560 | |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | if (isset($definition['change_tracking']) && !empty($definition['change_tracking'])) |
1563 | 1563 | $change_tracking = $definition['change_tracking']; |
1564 | 1564 | |
1565 | - $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking" ; |
|
1565 | + $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking"; |
|
1566 | 1566 | } |
1567 | 1567 | break; |
1568 | 1568 | } |
@@ -1586,11 +1586,11 @@ discard block |
||
1586 | 1586 | protected function full_text_indexing_enabled($dbname = null) |
1587 | 1587 | { |
1588 | 1588 | // check to see if we already have install setting in session |
1589 | - if(!isset($_SESSION['IsFulltextInstalled'])) |
|
1589 | + if (!isset($_SESSION['IsFulltextInstalled'])) |
|
1590 | 1590 | $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed(); |
1591 | 1591 | |
1592 | 1592 | // check to see if FTS Indexing service is installed |
1593 | - if(empty($_SESSION['IsFulltextInstalled'])) |
|
1593 | + if (empty($_SESSION['IsFulltextInstalled'])) |
|
1594 | 1594 | return false; |
1595 | 1595 | |
1596 | 1596 | // grab the dbname if it was not passed through |
@@ -1640,7 +1640,7 @@ discard block |
||
1640 | 1640 | { |
1641 | 1641 | static $results = array(); |
1642 | 1642 | |
1643 | - if ( empty($column) && isset($results[$table]) ) |
|
1643 | + if (empty($column) && isset($results[$table])) |
|
1644 | 1644 | return $results[$table]; |
1645 | 1645 | |
1646 | 1646 | $query = <<<EOQ |
@@ -1654,17 +1654,17 @@ discard block |
||
1654 | 1654 | on s.schema_id = o.schema_id |
1655 | 1655 | where o.name = '$table' |
1656 | 1656 | EOQ; |
1657 | - if ( !empty($column) ) |
|
1657 | + if (!empty($column)) |
|
1658 | 1658 | $query .= " and c.name = '$column'"; |
1659 | 1659 | $res = $this->query($query); |
1660 | - if ( !empty($column) ) { |
|
1660 | + if (!empty($column)) { |
|
1661 | 1661 | $row = $this->fetchByAssoc($res); |
1662 | 1662 | if (!empty($row)) |
1663 | 1663 | return $row['ctrt']; |
1664 | 1664 | } |
1665 | 1665 | else { |
1666 | 1666 | $returnResult = array(); |
1667 | - while ( $row = $this->fetchByAssoc($res) ) |
|
1667 | + while ($row = $this->fetchByAssoc($res)) |
|
1668 | 1668 | $returnResult[$row['dtrt']] = $row['ctrt']; |
1669 | 1669 | $results[$table] = $returnResult; |
1670 | 1670 | return $returnResult; |
@@ -1678,14 +1678,14 @@ discard block |
||
1678 | 1678 | */ |
1679 | 1679 | public function massageFieldDef(&$fieldDef, $tablename) |
1680 | 1680 | { |
1681 | - parent::massageFieldDef($fieldDef,$tablename); |
|
1681 | + parent::massageFieldDef($fieldDef, $tablename); |
|
1682 | 1682 | |
1683 | 1683 | if ($fieldDef['type'] == 'int') |
1684 | 1684 | $fieldDef['len'] = '4'; |
1685 | 1685 | |
1686 | - if(empty($fieldDef['len'])) |
|
1686 | + if (empty($fieldDef['len'])) |
|
1687 | 1687 | { |
1688 | - switch($fieldDef['type']) { |
|
1688 | + switch ($fieldDef['type']) { |
|
1689 | 1689 | case 'bit' : |
1690 | 1690 | case 'bool' : $fieldDef['len'] = '1'; break; |
1691 | 1691 | case 'smallint' : $fieldDef['len'] = '2'; break; |
@@ -1695,22 +1695,22 @@ discard block |
||
1695 | 1695 | $fieldDef['len'] = $this->isTextType($fieldDef['dbType']) ? 'max' : '255'; |
1696 | 1696 | break; |
1697 | 1697 | case 'image' : $fieldDef['len'] = '2147483647'; break; |
1698 | - case 'ntext' : $fieldDef['len'] = '2147483646'; break; // Note: this is from legacy code, don't know if this is correct |
|
1698 | + case 'ntext' : $fieldDef['len'] = '2147483646'; break; // Note: this is from legacy code, don't know if this is correct |
|
1699 | 1699 | } |
1700 | 1700 | } |
1701 | - if($fieldDef['type'] == 'decimal' |
|
1701 | + if ($fieldDef['type'] == 'decimal' |
|
1702 | 1702 | && empty($fieldDef['precision']) |
1703 | 1703 | && !strpos($fieldDef['len'], ',')) |
1704 | 1704 | { |
1705 | 1705 | $fieldDef['len'] .= ',0'; // Adding 0 precision if it is not specified |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - if(empty($fieldDef['default']) |
|
1709 | - && in_array($fieldDef['type'],array('bit','bool'))) |
|
1708 | + if (empty($fieldDef['default']) |
|
1709 | + && in_array($fieldDef['type'], array('bit', 'bool'))) |
|
1710 | 1710 | { |
1711 | 1711 | $fieldDef['default'] = '0'; |
1712 | 1712 | } |
1713 | - if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) |
|
1713 | + if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default'])) |
|
1714 | 1714 | $fieldDef['default'] = ''; |
1715 | 1715 | // if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) ) |
1716 | 1716 | // $fieldDef['len'] = '1'; |
@@ -1741,13 +1741,13 @@ discard block |
||
1741 | 1741 | protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
1742 | 1742 | { |
1743 | 1743 | //Bug 25814 |
1744 | - if(isset($fieldDef['name'])){ |
|
1744 | + if (isset($fieldDef['name'])) { |
|
1745 | 1745 | $colType = $this->getFieldType($fieldDef); |
1746 | - if(stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])){ |
|
1747 | - $fieldDef['len'] = min($fieldDef['len'],38); |
|
1746 | + if (stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])) { |
|
1747 | + $fieldDef['len'] = min($fieldDef['len'], 38); |
|
1748 | 1748 | } |
1749 | 1749 | //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair |
1750 | - if(stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8){ |
|
1750 | + if (stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8) { |
|
1751 | 1751 | unset($fieldDef['len']); |
1752 | 1752 | } |
1753 | 1753 | } |
@@ -1756,10 +1756,10 @@ discard block |
||
1756 | 1756 | $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
1757 | 1757 | |
1758 | 1758 | // Bug 24307 - Don't add precision for float fields. |
1759 | - if ( stristr($ref['colType'],'float') ) |
|
1760 | - $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']); |
|
1759 | + if (stristr($ref['colType'], 'float')) |
|
1760 | + $ref['colType'] = preg_replace('/(,\d+)/', '', $ref['colType']); |
|
1761 | 1761 | |
1762 | - if ( $return_as_array ) |
|
1762 | + if ($return_as_array) |
|
1763 | 1763 | return $ref; |
1764 | 1764 | else |
1765 | 1765 | return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
@@ -1774,10 +1774,10 @@ discard block |
||
1774 | 1774 | public function save_audit_records(SugarBean $bean, $changes) |
1775 | 1775 | { |
1776 | 1776 | //Bug 25078 fixed by Martin Hu: sqlserver haven't 'date' type, trim extra "00:00:00" |
1777 | - if($changes['data_type'] == 'date'){ |
|
1778 | - $changes['before'] = str_replace(' 00:00:00','',$changes['before']); |
|
1777 | + if ($changes['data_type'] == 'date') { |
|
1778 | + $changes['before'] = str_replace(' 00:00:00', '', $changes['before']); |
|
1779 | 1779 | } |
1780 | - parent::save_audit_records($bean,$changes); |
|
1780 | + parent::save_audit_records($bean, $changes); |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | 1783 | /** |
@@ -1788,7 +1788,7 @@ discard block |
||
1788 | 1788 | public function disconnect() |
1789 | 1789 | { |
1790 | 1790 | $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
1791 | - if(!empty($this->database)){ |
|
1791 | + if (!empty($this->database)) { |
|
1792 | 1792 | $this->freeResult(); |
1793 | 1793 | mssql_close($this->database); |
1794 | 1794 | $this->database = null; |
@@ -1800,7 +1800,7 @@ discard block |
||
1800 | 1800 | */ |
1801 | 1801 | protected function freeDbResult($dbResult) |
1802 | 1802 | { |
1803 | - if(!empty($dbResult)) |
|
1803 | + if (!empty($dbResult)) |
|
1804 | 1804 | mssql_free_result($dbResult); |
1805 | 1805 | } |
1806 | 1806 | |
@@ -1811,11 +1811,11 @@ discard block |
||
1811 | 1811 | public function lastDbError() |
1812 | 1812 | { |
1813 | 1813 | $sqlmsg = mssql_get_last_message(); |
1814 | - if(empty($sqlmsg)) return false; |
|
1814 | + if (empty($sqlmsg)) return false; |
|
1815 | 1815 | global $app_strings; |
1816 | 1816 | if (empty($app_strings) |
1817 | 1817 | or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
1818 | - or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
1818 | + or !isset($app_strings['ERR_MSSQL_WARNING'])) { |
|
1819 | 1819 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
1820 | 1820 | //only if connection if made before language is set. |
1821 | 1821 | return false; |
@@ -1824,7 +1824,7 @@ discard block |
||
1824 | 1824 | $sqlpos = strpos($sqlmsg, 'Changed database context to'); |
1825 | 1825 | $sqlpos2 = strpos($sqlmsg, 'Warning:'); |
1826 | 1826 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
1827 | - if ( $sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false ) { |
|
1827 | + if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) { |
|
1828 | 1828 | return false; |
1829 | 1829 | } else { |
1830 | 1830 | global $app_strings; |
@@ -1832,18 +1832,18 @@ discard block |
||
1832 | 1832 | if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])) { |
1833 | 1833 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
1834 | 1834 | //only if connection if made before languge is set. |
1835 | - $GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg); |
|
1835 | + $GLOBALS['log']->debug("Ignoring this database message: ".$sqlmsg); |
|
1836 | 1836 | return false; |
1837 | 1837 | } |
1838 | 1838 | else { |
1839 | 1839 | $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); |
1840 | - if ( $sqlpos !== false ) |
|
1840 | + if ($sqlpos !== false) |
|
1841 | 1841 | return false; |
1842 | 1842 | } |
1843 | 1843 | } |
1844 | 1844 | |
1845 | - if ( strlen($sqlmsg) > 2 ) { |
|
1846 | - return "SQL Server error: " . $sqlmsg; |
|
1845 | + if (strlen($sqlmsg) > 2) { |
|
1846 | + return "SQL Server error: ".$sqlmsg; |
|
1847 | 1847 | } |
1848 | 1848 | |
1849 | 1849 | return false; |
@@ -1864,7 +1864,7 @@ discard block |
||
1864 | 1864 | */ |
1865 | 1865 | public function validateQuery($query) |
1866 | 1866 | { |
1867 | - if(!$this->isSelect($query)) { |
|
1867 | + if (!$this->isSelect($query)) { |
|
1868 | 1868 | return false; |
1869 | 1869 | } |
1870 | 1870 | $this->query("SET SHOWPLAN_TEXT ON"); |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | |
1889 | 1889 | // Flag if there are odd number of single quotes, just continue without trying to append N |
1890 | 1890 | if ((substr_count($sql, "'") & 1)) { |
1891 | - $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
1891 | + $GLOBALS['log']->error("SQL statement[".$sql."] has odd number of single quotes."); |
|
1892 | 1892 | return $sql; |
1893 | 1893 | } |
1894 | 1894 | |
@@ -1918,7 +1918,7 @@ discard block |
||
1918 | 1918 | // We are assuming that all nvarchar columns are no more than 200 characters in length |
1919 | 1919 | // One problem we face is the image column type in reports which cannot accept nvarchar data |
1920 | 1920 | if (!empty($value) && !is_numeric(trim(str_replace(array("'", ","), "", $value))) && !preg_match('/^\'[\,]\'$/', $value)) { |
1921 | - $replace[$value] = 'N' . trim($value, "N"); |
|
1921 | + $replace[$value] = 'N'.trim($value, "N"); |
|
1922 | 1922 | } |
1923 | 1923 | } |
1924 | 1924 | } |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | if (!empty($pairs)) |
1930 | 1930 | $sql = str_replace(array_keys($pairs), $pairs, $sql); |
1931 | 1931 | |
1932 | - if(strpos($sql, "<@#@#@PAIR@#@#@>")) |
|
1932 | + if (strpos($sql, "<@#@#@PAIR@#@#@>")) |
|
1933 | 1933 | $sql = str_replace(array('<@#@#@PAIR@#@#@>'), array("''"), $sql); |
1934 | 1934 | |
1935 | 1935 | return $sql; |
@@ -1956,22 +1956,22 @@ discard block |
||
1956 | 1956 | public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()) |
1957 | 1957 | { |
1958 | 1958 | $condition = $or_condition = array(); |
1959 | - foreach($must_terms as $term) { |
|
1959 | + foreach ($must_terms as $term) { |
|
1960 | 1960 | $condition[] = $this->quoteTerm($term); |
1961 | 1961 | } |
1962 | 1962 | |
1963 | - foreach($terms as $term) { |
|
1963 | + foreach ($terms as $term) { |
|
1964 | 1964 | $or_condition[] = $this->quoteTerm($term); |
1965 | 1965 | } |
1966 | 1966 | |
1967 | - if(!empty($or_condition)) { |
|
1967 | + if (!empty($or_condition)) { |
|
1968 | 1968 | $condition[] = "(".join(" | ", $or_condition).")"; |
1969 | 1969 | } |
1970 | 1970 | |
1971 | - foreach($exclude_terms as $term) { |
|
1971 | + foreach ($exclude_terms as $term) { |
|
1972 | 1972 | $condition[] = " NOT ".$this->quoteTerm($term); |
1973 | 1973 | } |
1974 | - $condition = $this->quoted(join(" AND ",$condition)); |
|
1974 | + $condition = $this->quoted(join(" AND ", $condition)); |
|
1975 | 1975 | return "CONTAINS($field, $condition)"; |
1976 | 1976 | } |
1977 | 1977 | |
@@ -2060,7 +2060,7 @@ discard block |
||
2060 | 2060 | public function isDatabaseNameValid($name) |
2061 | 2061 | { |
2062 | 2062 | // No funny chars, does not begin with number |
2063 | - return preg_match('/^[0-9#@]+|[\"\'\*\/\\?\:\\<\>\-\ \&\!\(\)\[\]\{\}\;\,\.\`\~\|\\\\]+/', $name)==0; |
|
2063 | + return preg_match('/^[0-9#@]+|[\"\'\*\/\\?\:\\<\>\-\ \&\!\(\)\[\]\{\}\;\,\.\`\~\|\\\\]+/', $name) == 0; |
|
2064 | 2064 | } |
2065 | 2065 | |
2066 | 2066 | public function installConfig() |
@@ -42,27 +42,27 @@ discard block |
||
42 | 42 | |
43 | 43 | class AuthenticationController |
44 | 44 | { |
45 | - public $loggedIn = false; //if a user has attempted to login |
|
46 | - public $authenticated = false; |
|
47 | - public $loginSuccess = false;// if a user has successfully logged in |
|
45 | + public $loggedIn = false; //if a user has attempted to login |
|
46 | + public $authenticated = false; |
|
47 | + public $loginSuccess = false;// if a user has successfully logged in |
|
48 | 48 | |
49 | - protected static $authcontrollerinstance = null; |
|
49 | + protected static $authcontrollerinstance = null; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var SugarAuthenticate |
53 | 53 | */ |
54 | 54 | public $authController; |
55 | 55 | |
56 | - /** |
|
57 | - * Creates an instance of the authentication controller and loads it |
|
58 | - * |
|
59 | - * @param STRING $type - the authentication Controller |
|
60 | - * @return AuthenticationController - |
|
61 | - */ |
|
62 | - public function __construct($type = null) |
|
63 | - { |
|
56 | + /** |
|
57 | + * Creates an instance of the authentication controller and loads it |
|
58 | + * |
|
59 | + * @param STRING $type - the authentication Controller |
|
60 | + * @return AuthenticationController - |
|
61 | + */ |
|
62 | + public function __construct($type = null) |
|
63 | + { |
|
64 | 64 | $this->authController = $this->getAuthController($type); |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Get auth controller object |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // check in custom dir first, in case someone want's to override an auth controller |
84 | - if (file_exists('custom/modules/Users/authentication/'.$type.'/' . $type . '.php')) { |
|
84 | + if (file_exists('custom/modules/Users/authentication/'.$type.'/' . $type . '.php')) { |
|
85 | 85 | require_once('custom/modules/Users/authentication/'.$type.'/' . $type . '.php'); |
86 | 86 | } elseif (file_exists('modules/Users/authentication/'.$type.'/' . $type . '.php')) { |
87 | 87 | require_once('modules/Users/authentication/'.$type.'/' . $type . '.php'); |
@@ -98,123 +98,123 @@ discard block |
||
98 | 98 | return new $type(); |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Returns an instance of the authentication controller |
|
103 | - * |
|
104 | - * @param string $type this is the type of authetnication you want to use default is SugarAuthenticate |
|
105 | - * @return an instance of the authetnciation controller |
|
106 | - */ |
|
107 | - public static function getInstance($type = null) |
|
108 | - { |
|
109 | - if (empty(self::$authcontrollerinstance)) { |
|
110 | - self::$authcontrollerinstance = new AuthenticationController($type); |
|
111 | - } |
|
112 | - |
|
113 | - return self::$authcontrollerinstance; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * This function is called when a user initially tries to login. |
|
118 | - * |
|
119 | - * @param string $username |
|
120 | - * @param string $password |
|
121 | - * @param array $PARAMS |
|
122 | - * @return boolean true if the user successfully logs in or false otherwise. |
|
123 | - */ |
|
124 | - public function login($username, $password, $PARAMS = array()) |
|
125 | - { |
|
126 | - //kbrill bug #13225 |
|
127 | - $_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts']))? $_SESSION['loginAttempts'] + 1: 1; |
|
128 | - unset($GLOBALS['login_error']); |
|
129 | - |
|
130 | - if($this->loggedIn)return $this->loginSuccess; |
|
131 | - LogicHook::initialize()->call_custom_logic('Users', 'before_login'); |
|
132 | - |
|
133 | - $this->loginSuccess = $this->authController->loginAuthenticate($username, $password, false, $PARAMS); |
|
134 | - $this->loggedIn = true; |
|
135 | - |
|
136 | - if($this->loginSuccess){ |
|
137 | - //Ensure the user is authorized |
|
138 | - checkAuthUserStatus(); |
|
139 | - |
|
140 | - //loginLicense(); |
|
141 | - if(!empty($GLOBALS['login_error'])){ |
|
142 | - unset($_SESSION['authenticated_user_id']); |
|
143 | - $GLOBALS['log']->fatal('FAILED LOGIN: potential hack attempt:'.$GLOBALS['login_error']); |
|
144 | - $this->loginSuccess = false; |
|
145 | - return false; |
|
146 | - } |
|
147 | - |
|
148 | - //call business logic hook |
|
149 | - if(isset($GLOBALS['current_user'])) |
|
150 | - $GLOBALS['current_user']->call_custom_logic('after_login'); |
|
151 | - |
|
152 | - // Check for running Admin Wizard |
|
153 | - $config = new Administration(); |
|
154 | - $config->retrieveSettings(); |
|
155 | - if ( is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard' ) { |
|
156 | - $GLOBALS['module'] = 'Configurator'; |
|
157 | - $GLOBALS['action'] = 'AdminWizard'; |
|
158 | - ob_clean(); |
|
159 | - header("Location: index.php?module=Configurator&action=AdminWizard"); |
|
160 | - sugar_cleanup(true); |
|
161 | - } |
|
162 | - |
|
163 | - $ut = $GLOBALS['current_user']->getPreference('ut'); |
|
164 | - $checkTimeZone = true; |
|
165 | - if (is_array($PARAMS) && !empty($PARAMS) && isset($PARAMS['passwordEncrypted'])) { |
|
166 | - $checkTimeZone = false; |
|
167 | - } // if |
|
168 | - if(empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone' ) { |
|
169 | - $GLOBALS['module'] = 'Users'; |
|
170 | - $GLOBALS['action'] = 'Wizard'; |
|
171 | - ob_clean(); |
|
172 | - header("Location: index.php?module=Users&action=Wizard"); |
|
173 | - sugar_cleanup(true); |
|
174 | - } |
|
175 | - }else{ |
|
176 | - //kbrill bug #13225 |
|
177 | - LogicHook::initialize(); |
|
178 | - $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed'); |
|
179 | - $GLOBALS['log']->fatal('FAILED LOGIN:attempts[' .$_SESSION['loginAttempts'] .'] - '. $username); |
|
180 | - } |
|
181 | - // if password has expired, set a session variable |
|
182 | - |
|
183 | - return $this->loginSuccess; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * This is called on every page hit. |
|
188 | - * It returns true if the current session is authenticated or false otherwise |
|
189 | - * |
|
190 | - * @return booelan |
|
191 | - */ |
|
192 | - public function sessionAuthenticate() |
|
193 | - { |
|
194 | - if(!$this->authenticated){ |
|
195 | - $this->authenticated = $this->authController->sessionAuthenticate(); |
|
196 | - } |
|
197 | - if($this->authenticated){ |
|
198 | - if(!isset($_SESSION['userStats']['pages'])){ |
|
199 | - $_SESSION['userStats']['loginTime'] = time(); |
|
200 | - $_SESSION['userStats']['pages'] = 0; |
|
201 | - } |
|
202 | - $_SESSION['userStats']['lastTime'] = time(); |
|
203 | - $_SESSION['userStats']['pages']++; |
|
204 | - |
|
205 | - } |
|
206 | - return $this->authenticated; |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Called when a user requests to logout. Should invalidate the session and redirect |
|
211 | - * to the login page. |
|
212 | - */ |
|
213 | - public function logout() |
|
214 | - { |
|
215 | - $GLOBALS['current_user']->call_custom_logic('before_logout'); |
|
216 | - $this->authController->logout(); |
|
217 | - LogicHook::initialize(); |
|
218 | - $GLOBALS['logic_hook']->call_custom_logic('Users', 'after_logout'); |
|
219 | - } |
|
101 | + /** |
|
102 | + * Returns an instance of the authentication controller |
|
103 | + * |
|
104 | + * @param string $type this is the type of authetnication you want to use default is SugarAuthenticate |
|
105 | + * @return an instance of the authetnciation controller |
|
106 | + */ |
|
107 | + public static function getInstance($type = null) |
|
108 | + { |
|
109 | + if (empty(self::$authcontrollerinstance)) { |
|
110 | + self::$authcontrollerinstance = new AuthenticationController($type); |
|
111 | + } |
|
112 | + |
|
113 | + return self::$authcontrollerinstance; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * This function is called when a user initially tries to login. |
|
118 | + * |
|
119 | + * @param string $username |
|
120 | + * @param string $password |
|
121 | + * @param array $PARAMS |
|
122 | + * @return boolean true if the user successfully logs in or false otherwise. |
|
123 | + */ |
|
124 | + public function login($username, $password, $PARAMS = array()) |
|
125 | + { |
|
126 | + //kbrill bug #13225 |
|
127 | + $_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts']))? $_SESSION['loginAttempts'] + 1: 1; |
|
128 | + unset($GLOBALS['login_error']); |
|
129 | + |
|
130 | + if($this->loggedIn)return $this->loginSuccess; |
|
131 | + LogicHook::initialize()->call_custom_logic('Users', 'before_login'); |
|
132 | + |
|
133 | + $this->loginSuccess = $this->authController->loginAuthenticate($username, $password, false, $PARAMS); |
|
134 | + $this->loggedIn = true; |
|
135 | + |
|
136 | + if($this->loginSuccess){ |
|
137 | + //Ensure the user is authorized |
|
138 | + checkAuthUserStatus(); |
|
139 | + |
|
140 | + //loginLicense(); |
|
141 | + if(!empty($GLOBALS['login_error'])){ |
|
142 | + unset($_SESSION['authenticated_user_id']); |
|
143 | + $GLOBALS['log']->fatal('FAILED LOGIN: potential hack attempt:'.$GLOBALS['login_error']); |
|
144 | + $this->loginSuccess = false; |
|
145 | + return false; |
|
146 | + } |
|
147 | + |
|
148 | + //call business logic hook |
|
149 | + if(isset($GLOBALS['current_user'])) |
|
150 | + $GLOBALS['current_user']->call_custom_logic('after_login'); |
|
151 | + |
|
152 | + // Check for running Admin Wizard |
|
153 | + $config = new Administration(); |
|
154 | + $config->retrieveSettings(); |
|
155 | + if ( is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard' ) { |
|
156 | + $GLOBALS['module'] = 'Configurator'; |
|
157 | + $GLOBALS['action'] = 'AdminWizard'; |
|
158 | + ob_clean(); |
|
159 | + header("Location: index.php?module=Configurator&action=AdminWizard"); |
|
160 | + sugar_cleanup(true); |
|
161 | + } |
|
162 | + |
|
163 | + $ut = $GLOBALS['current_user']->getPreference('ut'); |
|
164 | + $checkTimeZone = true; |
|
165 | + if (is_array($PARAMS) && !empty($PARAMS) && isset($PARAMS['passwordEncrypted'])) { |
|
166 | + $checkTimeZone = false; |
|
167 | + } // if |
|
168 | + if(empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone' ) { |
|
169 | + $GLOBALS['module'] = 'Users'; |
|
170 | + $GLOBALS['action'] = 'Wizard'; |
|
171 | + ob_clean(); |
|
172 | + header("Location: index.php?module=Users&action=Wizard"); |
|
173 | + sugar_cleanup(true); |
|
174 | + } |
|
175 | + }else{ |
|
176 | + //kbrill bug #13225 |
|
177 | + LogicHook::initialize(); |
|
178 | + $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed'); |
|
179 | + $GLOBALS['log']->fatal('FAILED LOGIN:attempts[' .$_SESSION['loginAttempts'] .'] - '. $username); |
|
180 | + } |
|
181 | + // if password has expired, set a session variable |
|
182 | + |
|
183 | + return $this->loginSuccess; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * This is called on every page hit. |
|
188 | + * It returns true if the current session is authenticated or false otherwise |
|
189 | + * |
|
190 | + * @return booelan |
|
191 | + */ |
|
192 | + public function sessionAuthenticate() |
|
193 | + { |
|
194 | + if(!$this->authenticated){ |
|
195 | + $this->authenticated = $this->authController->sessionAuthenticate(); |
|
196 | + } |
|
197 | + if($this->authenticated){ |
|
198 | + if(!isset($_SESSION['userStats']['pages'])){ |
|
199 | + $_SESSION['userStats']['loginTime'] = time(); |
|
200 | + $_SESSION['userStats']['pages'] = 0; |
|
201 | + } |
|
202 | + $_SESSION['userStats']['lastTime'] = time(); |
|
203 | + $_SESSION['userStats']['pages']++; |
|
204 | + |
|
205 | + } |
|
206 | + return $this->authenticated; |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Called when a user requests to logout. Should invalidate the session and redirect |
|
211 | + * to the login page. |
|
212 | + */ |
|
213 | + public function logout() |
|
214 | + { |
|
215 | + $GLOBALS['current_user']->call_custom_logic('before_logout'); |
|
216 | + $this->authController->logout(); |
|
217 | + LogicHook::initialize(); |
|
218 | + $GLOBALS['logic_hook']->call_custom_logic('Users', 'after_logout'); |
|
219 | + } |
|
220 | 220 | } |
@@ -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. |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | public $loggedIn = false; //if a user has attempted to login |
46 | 46 | public $authenticated = false; |
47 | - public $loginSuccess = false;// if a user has successfully logged in |
|
47 | + public $loginSuccess = false; // if a user has successfully logged in |
|
48 | 48 | |
49 | 49 | protected static $authcontrollerinstance = null; |
50 | 50 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // check in custom dir first, in case someone want's to override an auth controller |
84 | - if (file_exists('custom/modules/Users/authentication/'.$type.'/' . $type . '.php')) { |
|
85 | - require_once('custom/modules/Users/authentication/'.$type.'/' . $type . '.php'); |
|
86 | - } elseif (file_exists('modules/Users/authentication/'.$type.'/' . $type . '.php')) { |
|
87 | - require_once('modules/Users/authentication/'.$type.'/' . $type . '.php'); |
|
84 | + if (file_exists('custom/modules/Users/authentication/'.$type.'/'.$type.'.php')) { |
|
85 | + require_once('custom/modules/Users/authentication/'.$type.'/'.$type.'.php'); |
|
86 | + } elseif (file_exists('modules/Users/authentication/'.$type.'/'.$type.'.php')) { |
|
87 | + require_once('modules/Users/authentication/'.$type.'/'.$type.'.php'); |
|
88 | 88 | } else { |
89 | 89 | require_once('modules/Users/authentication/SugarAuthenticate/SugarAuthenticate.php'); |
90 | 90 | $type = 'SugarAuthenticate'; |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | public function login($username, $password, $PARAMS = array()) |
125 | 125 | { |
126 | 126 | //kbrill bug #13225 |
127 | - $_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts']))? $_SESSION['loginAttempts'] + 1: 1; |
|
127 | + $_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts'])) ? $_SESSION['loginAttempts'] + 1 : 1; |
|
128 | 128 | unset($GLOBALS['login_error']); |
129 | 129 | |
130 | - if($this->loggedIn)return $this->loginSuccess; |
|
130 | + if ($this->loggedIn)return $this->loginSuccess; |
|
131 | 131 | LogicHook::initialize()->call_custom_logic('Users', 'before_login'); |
132 | 132 | |
133 | 133 | $this->loginSuccess = $this->authController->loginAuthenticate($username, $password, false, $PARAMS); |
134 | 134 | $this->loggedIn = true; |
135 | 135 | |
136 | - if($this->loginSuccess){ |
|
136 | + if ($this->loginSuccess) { |
|
137 | 137 | //Ensure the user is authorized |
138 | 138 | checkAuthUserStatus(); |
139 | 139 | |
140 | 140 | //loginLicense(); |
141 | - if(!empty($GLOBALS['login_error'])){ |
|
141 | + if (!empty($GLOBALS['login_error'])) { |
|
142 | 142 | unset($_SESSION['authenticated_user_id']); |
143 | 143 | $GLOBALS['log']->fatal('FAILED LOGIN: potential hack attempt:'.$GLOBALS['login_error']); |
144 | 144 | $this->loginSuccess = false; |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | //call business logic hook |
149 | - if(isset($GLOBALS['current_user'])) |
|
149 | + if (isset($GLOBALS['current_user'])) |
|
150 | 150 | $GLOBALS['current_user']->call_custom_logic('after_login'); |
151 | 151 | |
152 | 152 | // Check for running Admin Wizard |
153 | 153 | $config = new Administration(); |
154 | 154 | $config->retrieveSettings(); |
155 | - if ( is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard' ) { |
|
155 | + if (is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard') { |
|
156 | 156 | $GLOBALS['module'] = 'Configurator'; |
157 | 157 | $GLOBALS['action'] = 'AdminWizard'; |
158 | 158 | ob_clean(); |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | if (is_array($PARAMS) && !empty($PARAMS) && isset($PARAMS['passwordEncrypted'])) { |
166 | 166 | $checkTimeZone = false; |
167 | 167 | } // if |
168 | - if(empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone' ) { |
|
168 | + if (empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone') { |
|
169 | 169 | $GLOBALS['module'] = 'Users'; |
170 | 170 | $GLOBALS['action'] = 'Wizard'; |
171 | 171 | ob_clean(); |
172 | 172 | header("Location: index.php?module=Users&action=Wizard"); |
173 | 173 | sugar_cleanup(true); |
174 | 174 | } |
175 | - }else{ |
|
175 | + } else { |
|
176 | 176 | //kbrill bug #13225 |
177 | 177 | LogicHook::initialize(); |
178 | 178 | $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed'); |
179 | - $GLOBALS['log']->fatal('FAILED LOGIN:attempts[' .$_SESSION['loginAttempts'] .'] - '. $username); |
|
179 | + $GLOBALS['log']->fatal('FAILED LOGIN:attempts['.$_SESSION['loginAttempts'].'] - '.$username); |
|
180 | 180 | } |
181 | 181 | // if password has expired, set a session variable |
182 | 182 | |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function sessionAuthenticate() |
193 | 193 | { |
194 | - if(!$this->authenticated){ |
|
194 | + if (!$this->authenticated) { |
|
195 | 195 | $this->authenticated = $this->authController->sessionAuthenticate(); |
196 | 196 | } |
197 | - if($this->authenticated){ |
|
198 | - if(!isset($_SESSION['userStats']['pages'])){ |
|
197 | + if ($this->authenticated) { |
|
198 | + if (!isset($_SESSION['userStats']['pages'])) { |
|
199 | 199 | $_SESSION['userStats']['loginTime'] = time(); |
200 | 200 | $_SESSION['userStats']['pages'] = 0; |
201 | 201 | } |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | if(strpos($server_software,'Microsoft-IIS') !== false) |
157 | 157 | { |
158 | 158 | installLog("calling handleWebConfig()"); |
159 | - handleWebConfig(); |
|
159 | + handleWebConfig(); |
|
160 | 160 | } else { |
161 | - installLog("calling handleHtaccess()"); |
|
161 | + installLog("calling handleHtaccess()"); |
|
162 | 162 | handleHtaccess(); |
163 | 163 | } |
164 | 164 | |
@@ -228,27 +228,27 @@ discard block |
||
228 | 228 | * loop through all the Beans and create their tables |
229 | 229 | */ |
230 | 230 | installStatus($mod_strings['STAT_CREATE_DB']); |
231 | - installLog("looping through all the Beans and create their tables"); |
|
232 | - //start by clearing out the vardefs |
|
233 | - VardefManager::clearVardef(); |
|
231 | + installLog("looping through all the Beans and create their tables"); |
|
232 | + //start by clearing out the vardefs |
|
233 | + VardefManager::clearVardef(); |
|
234 | 234 | installerHook('pre_createAllModuleTables'); |
235 | 235 | |
236 | 236 | |
237 | 237 | foreach( $beanFiles as $bean => $file ) { |
238 | - $doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask','jjwg_Maps','jjwg_Address_Cache','jjwg_Areas','jjwg_Markers'); |
|
238 | + $doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask','jjwg_Maps','jjwg_Address_Cache','jjwg_Areas','jjwg_Markers'); |
|
239 | 239 | |
240 | - if(in_array($bean, $doNotInit)) { |
|
241 | - $focus = new $bean(false); |
|
242 | - } else { |
|
243 | - $focus = new $bean(); |
|
244 | - } |
|
240 | + if(in_array($bean, $doNotInit)) { |
|
241 | + $focus = new $bean(false); |
|
242 | + } else { |
|
243 | + $focus = new $bean(); |
|
244 | + } |
|
245 | 245 | |
246 | - if ( $bean == 'Configurator' ) |
|
247 | - continue; |
|
246 | + if ( $bean == 'Configurator' ) |
|
247 | + continue; |
|
248 | 248 | |
249 | 249 | $table_name = $focus->table_name; |
250 | 250 | //installStatus(sprintf($mod_strings['STAT_CREATE_DB_TABLE'], $focus->table_name )); |
251 | - installLog("processing table ".$focus->table_name); |
|
251 | + installLog("processing table ".$focus->table_name); |
|
252 | 252 | // check to see if we have already setup this table |
253 | 253 | if(!in_array($table_name, $processed_tables)) { |
254 | 254 | if(!file_exists("modules/".$focus->module_dir."/vardefs.php")){ |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | continue; // support new vardef definitions |
261 | 261 | } |
262 | 262 | } else { |
263 | - continue; //no further processing needed for ignored beans. |
|
263 | + continue; //no further processing needed for ignored beans. |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // table has not been setup...we will do it now and remember that |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | installerHook('pre_createModuleTable', array('module' => $focus->getObjectName())); |
289 | 289 | SugarBean::createRelationshipMeta($focus->getObjectName(), $db, $table_name, $empty, $focus->module_dir); |
290 | 290 | installerHook('post_createModuleTable', array('module' => $focus->getObjectName())); |
291 | - echo "."; |
|
291 | + echo "."; |
|
292 | 292 | |
293 | 293 | } // end if() |
294 | 294 | } |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | |
421 | 421 | //require_once('modules/Connectors/InstallDefaultConnectors.php'); |
422 | 422 | |
423 | - /////////////////////////////////////////////////////////////////////////////// |
|
424 | - //// INSTALL PASSWORD TEMPLATES |
|
423 | + /////////////////////////////////////////////////////////////////////////////// |
|
424 | + //// INSTALL PASSWORD TEMPLATES |
|
425 | 425 | include('install/seed_data/Advanced_Password_SeedData.php'); |
426 | 426 | |
427 | 427 | /////////////////////////////////////////////////////////////////////////////// |
@@ -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. |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | |
41 | 41 | function installStatus($msg, $cmd = null, $overwrite = false, $before = '[ok]<br>') { |
42 | 42 | $fname = 'install/status.json'; |
43 | - if(!$overwrite && file_exists($fname)) { |
|
43 | + if (!$overwrite && file_exists($fname)) { |
|
44 | 44 | $stat = json_decode(file_get_contents($fname)); |
45 | 45 | //$msg = json_encode($stat); |
46 | - $msg = $stat->message . $before . $msg; |
|
46 | + $msg = $stat->message.$before.$msg; |
|
47 | 47 | } |
48 | 48 | file_put_contents($fname, json_encode(array( |
49 | 49 | 'message' => $msg, |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | // This file will load the configuration settings from session data, |
56 | 56 | // write to the config file, and execute any necessary database steps. |
57 | 57 | $GLOBALS['installing'] = true; |
58 | -if( !isset( $install_script ) || !$install_script ){ |
|
58 | +if (!isset($install_script) || !$install_script) { |
|
59 | 59 | die($mod_strings['ERR_NO_DIRECT_SCRIPT']); |
60 | 60 | } |
61 | -ini_set("output_buffering","0"); |
|
61 | +ini_set("output_buffering", "0"); |
|
62 | 62 | set_time_limit(3600); |
63 | 63 | // flush after each output so the user can see the progress in real-time |
64 | 64 | ob_implicit_flush(); |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $parsed_url = parse_url($setup_site_url); |
99 | 99 | $setup_site_host_name = $parsed_url['host']; |
100 | 100 | $setup_site_log_dir = isset($_SESSION['setup_site_custom_log_dir']) ? $_SESSION['setup_site_log_dir'] : '.'; |
101 | -$setup_site_log_file = 'suitecrm.log'; // may be an option later |
|
101 | +$setup_site_log_file = 'suitecrm.log'; // may be an option later |
|
102 | 102 | $setup_site_session_path = isset($_SESSION['setup_site_custom_session_path']) ? $_SESSION['setup_site_session_path'] : ''; |
103 | -$setup_site_log_level ='fatal'; |
|
103 | +$setup_site_log_level = 'fatal'; |
|
104 | 104 | |
105 | 105 | /*sugar_cache_clear('TeamSetsCache'); |
106 | 106 | if ( file_exists($cache_dir .'modules/Teams/TeamSetCache.php') ) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | unlink($cache_dir.'modules/Teams/TeamSetMD5Cache.php'); |
113 | 113 | }*/ |
114 | 114 | $langHeader = get_language_header(); |
115 | -$out =<<<EOQ |
|
115 | +$out = <<<EOQ |
|
116 | 116 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
117 | 117 | <!DOCTYPE HTML> |
118 | 118 | <html {$langHeader}> |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | //handleLog4Php(); |
154 | 154 | |
155 | 155 | $server_software = $_SERVER["SERVER_SOFTWARE"]; |
156 | -if(strpos($server_software,'Microsoft-IIS') !== false) |
|
156 | +if (strpos($server_software, 'Microsoft-IIS') !== false) |
|
157 | 157 | { |
158 | 158 | installLog("calling handleWebConfig()"); |
159 | 159 | handleWebConfig(); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | echo "<br>"; |
170 | 170 | |
171 | 171 | // create the SugarCRM database |
172 | -if($setup_db_create_database) { |
|
172 | +if ($setup_db_create_database) { |
|
173 | 173 | installLog("calling handleDbCreateDatabase()"); |
174 | 174 | installerHook('pre_handleDbCreateDatabase'); |
175 | 175 | handleDbCreateDatabase(); |
@@ -193,19 +193,19 @@ discard block |
||
193 | 193 | $ModuleInstaller->rebuild_tabledictionary();*/ |
194 | 194 | |
195 | 195 | // create the SugarCRM database user |
196 | -if($setup_db_create_sugarsales_user){ |
|
196 | +if ($setup_db_create_sugarsales_user) { |
|
197 | 197 | installerHook('pre_handleDbCreateSugarUser'); |
198 | 198 | handleDbCreateSugarUser(); |
199 | 199 | installerHook('post_handleDbCreateSugarUser'); |
200 | 200 | } |
201 | 201 | |
202 | -foreach( $beanFiles as $bean => $file ){ |
|
203 | - require_once( $file ); |
|
202 | +foreach ($beanFiles as $bean => $file) { |
|
203 | + require_once($file); |
|
204 | 204 | } |
205 | 205 | echo "<br>"; |
206 | 206 | // load up the config_override.php file. |
207 | 207 | // This is used to provide default user settings |
208 | -if( is_file("config_override.php") ){ |
|
208 | +if (is_file("config_override.php")) { |
|
209 | 209 | require_once("config_override.php"); |
210 | 210 | } |
211 | 211 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $new_report = 1; |
220 | 220 | |
221 | 221 | // add non-module Beans to this array to keep the installer from erroring. |
222 | -$nonStandardModules = array ( |
|
222 | +$nonStandardModules = array( |
|
223 | 223 | //'Tracker', |
224 | 224 | ); |
225 | 225 | |
@@ -234,29 +234,29 @@ discard block |
||
234 | 234 | installerHook('pre_createAllModuleTables'); |
235 | 235 | |
236 | 236 | |
237 | -foreach( $beanFiles as $bean => $file ) { |
|
238 | - $doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask','jjwg_Maps','jjwg_Address_Cache','jjwg_Areas','jjwg_Markers'); |
|
237 | +foreach ($beanFiles as $bean => $file) { |
|
238 | + $doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask', 'jjwg_Maps', 'jjwg_Address_Cache', 'jjwg_Areas', 'jjwg_Markers'); |
|
239 | 239 | |
240 | - if(in_array($bean, $doNotInit)) { |
|
240 | + if (in_array($bean, $doNotInit)) { |
|
241 | 241 | $focus = new $bean(false); |
242 | 242 | } else { |
243 | 243 | $focus = new $bean(); |
244 | 244 | } |
245 | 245 | |
246 | - if ( $bean == 'Configurator' ) |
|
246 | + if ($bean == 'Configurator') |
|
247 | 247 | continue; |
248 | 248 | |
249 | 249 | $table_name = $focus->table_name; |
250 | 250 | //installStatus(sprintf($mod_strings['STAT_CREATE_DB_TABLE'], $focus->table_name )); |
251 | 251 | installLog("processing table ".$focus->table_name); |
252 | 252 | // check to see if we have already setup this table |
253 | - if(!in_array($table_name, $processed_tables)) { |
|
254 | - if(!file_exists("modules/".$focus->module_dir."/vardefs.php")){ |
|
253 | + if (!in_array($table_name, $processed_tables)) { |
|
254 | + if (!file_exists("modules/".$focus->module_dir."/vardefs.php")) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | - if(!in_array($bean, $nonStandardModules)) { |
|
257 | + if (!in_array($bean, $nonStandardModules)) { |
|
258 | 258 | require_once("modules/".$focus->module_dir."/vardefs.php"); // load up $dictionary |
259 | - if($dictionary[$focus->object_name]['table'] == 'does_not_exist') { |
|
259 | + if ($dictionary[$focus->object_name]['table'] == 'does_not_exist') { |
|
260 | 260 | continue; // support new vardef definitions |
261 | 261 | } |
262 | 262 | } else { |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | |
269 | 269 | $focus->db->database = $db->database; // set db connection so we do not need to reconnect |
270 | 270 | |
271 | - if($setup_db_drop_tables) { |
|
271 | + if ($setup_db_drop_tables) { |
|
272 | 272 | drop_table_install($focus); |
273 | 273 | installLog("dropping table ".$focus->table_name); |
274 | 274 | } |
275 | 275 | |
276 | - if(create_table_if_not_exist($focus)) { |
|
276 | + if (create_table_if_not_exist($focus)) { |
|
277 | 277 | installLog("creating table ".$focus->table_name); |
278 | - if( $bean == "User" ){ |
|
278 | + if ($bean == "User") { |
|
279 | 279 | $new_tables = 1; |
280 | 280 | } |
281 | - if($bean == "Administration") |
|
281 | + if ($bean == "Administration") |
|
282 | 282 | $new_config = 1; |
283 | 283 | |
284 | 284 | |
@@ -303,20 +303,20 @@ discard block |
||
303 | 303 | //// START RELATIONSHIP CREATION |
304 | 304 | |
305 | 305 | ksort($rel_dictionary); |
306 | - foreach( $rel_dictionary as $rel_name => $rel_data ){ |
|
306 | + foreach ($rel_dictionary as $rel_name => $rel_data) { |
|
307 | 307 | $table = $rel_data['table']; |
308 | 308 | |
309 | - if( $setup_db_drop_tables ){ |
|
310 | - if( $db->tableExists($table) ){ |
|
309 | + if ($setup_db_drop_tables) { |
|
310 | + if ($db->tableExists($table)) { |
|
311 | 311 | $db->dropTableName($table); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | - if( !$db->tableExists($table) ){ |
|
315 | + if (!$db->tableExists($table)) { |
|
316 | 316 | $db->createTableParams($table, $rel_data['fields'], $rel_data['indices']); |
317 | 317 | } |
318 | 318 | |
319 | - SugarBean::createRelationshipMeta($rel_name,$db,$table,$rel_dictionary,''); |
|
319 | + SugarBean::createRelationshipMeta($rel_name, $db, $table, $rel_dictionary, ''); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /////////////////////////////////////////////////////////////////////////////// |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | |
377 | 377 | /////////////////////////////////////////////////////////////////////////// |
378 | 378 | //// FINALIZE LANG PACK INSTALL |
379 | - if(isset($_SESSION['INSTALLED_LANG_PACKS']) && is_array($_SESSION['INSTALLED_LANG_PACKS']) && !empty($_SESSION['INSTALLED_LANG_PACKS'])) { |
|
379 | + if (isset($_SESSION['INSTALLED_LANG_PACKS']) && is_array($_SESSION['INSTALLED_LANG_PACKS']) && !empty($_SESSION['INSTALLED_LANG_PACKS'])) { |
|
380 | 380 | updateUpgradeHistory(); |
381 | 381 | } |
382 | 382 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | $memoryUsed = ''; |
395 | 395 | if (function_exists('memory_get_usage')) { |
396 | - $memoryUsed = $mod_strings['LBL_PERFORM_OUTRO_5'] . memory_get_usage() . $mod_strings['LBL_PERFORM_OUTRO_6']; |
|
396 | + $memoryUsed = $mod_strings['LBL_PERFORM_OUTRO_5'].memory_get_usage().$mod_strings['LBL_PERFORM_OUTRO_6']; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | FP; |
422 | 422 | } |
423 | 423 | |
424 | - if( isset($_SESSION['setup_site_sugarbeet_automatic_checks']) && $_SESSION['setup_site_sugarbeet_automatic_checks'] == true){ |
|
424 | + if (isset($_SESSION['setup_site_sugarbeet_automatic_checks']) && $_SESSION['setup_site_sugarbeet_automatic_checks'] == true) { |
|
425 | 425 | set_CheckUpdates_config_setting('automatic'); |
426 | - }else{ |
|
426 | + } else { |
|
427 | 427 | set_CheckUpdates_config_setting('manual'); |
428 | 428 | } |
429 | - if(!empty($_SESSION['setup_system_name'])){ |
|
430 | - $admin=new Administration(); |
|
431 | - $admin->saveSetting('system','name',$_SESSION['setup_system_name']); |
|
429 | + if (!empty($_SESSION['setup_system_name'])) { |
|
430 | + $admin = new Administration(); |
|
431 | + $admin->saveSetting('system', 'name', $_SESSION['setup_system_name']); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | // Bug 28601 - Set the default list of tabs to show |
@@ -490,16 +490,16 @@ discard block |
||
490 | 490 | |
491 | 491 | // populating the db with seed data |
492 | 492 | installLog("populating the db with seed data"); |
493 | -if( $_SESSION['demoData'] != 'no' ){ |
|
493 | +if ($_SESSION['demoData'] != 'no') { |
|
494 | 494 | installerHook('pre_installDemoData'); |
495 | - set_time_limit( 301 ); |
|
495 | + set_time_limit(301); |
|
496 | 496 | |
497 | 497 | echo "<br>"; |
498 | 498 | echo "<b>{$mod_strings['LBL_PERFORM_DEMO_DATA']}</b>"; |
499 | 499 | echo "<br><br>"; |
500 | 500 | |
501 | - print( $render_table_close ); |
|
502 | - print( $render_table_open ); |
|
501 | + print($render_table_close); |
|
502 | + print($render_table_open); |
|
503 | 503 | |
504 | 504 | global $current_user; |
505 | 505 | $current_user = new User(); |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | //$focus->retrieveSettings(); |
540 | 540 | // switch off the adminwizard (mark that we have got past this point) |
541 | 541 | installLog('AdminWizard OFF'); |
542 | -$focus->saveSetting('system','adminwizard',1); |
|
542 | +$focus->saveSetting('system', 'adminwizard', 1); |
|
543 | 543 | |
544 | 544 | installLog('saveConfig'); |
545 | 545 | $focus->saveConfig(); |
@@ -554,10 +554,10 @@ discard block |
||
554 | 554 | |
555 | 555 | installLog('handleOverride'); |
556 | 556 | // add local settings to config overrides |
557 | -if(!empty($_SESSION['default_date_format'])) $sugar_config['default_date_format'] = $_SESSION['default_date_format']; |
|
558 | -if(!empty($_SESSION['default_time_format'])) $sugar_config['default_time_format'] = $_SESSION['default_time_format']; |
|
559 | -if(!empty($_SESSION['default_language'])) $sugar_config['default_language'] = $_SESSION['default_language']; |
|
560 | -if(!empty($_SESSION['default_locale_name_format'])) $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format']; |
|
557 | +if (!empty($_SESSION['default_date_format'])) $sugar_config['default_date_format'] = $_SESSION['default_date_format']; |
|
558 | +if (!empty($_SESSION['default_time_format'])) $sugar_config['default_time_format'] = $_SESSION['default_time_format']; |
|
559 | +if (!empty($_SESSION['default_language'])) $sugar_config['default_language'] = $_SESSION['default_language']; |
|
560 | +if (!empty($_SESSION['default_locale_name_format'])) $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format']; |
|
561 | 561 | //$configurator->handleOverride(); |
562 | 562 | |
563 | 563 | |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | $currency = new Currency; |
577 | 577 | installLog('retrieve'); |
578 | 578 | $currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name'])); |
579 | -if ( !empty($currency->id) |
|
579 | +if (!empty($currency->id) |
|
580 | 580 | && $currency->symbol == $_REQUEST['default_currency_symbol'] |
581 | - && $currency->iso4217 == $_REQUEST['default_currency_iso4217'] ) { |
|
581 | + && $currency->iso4217 == $_REQUEST['default_currency_iso4217']) { |
|
582 | 582 | $currency->deleted = 1; |
583 | 583 | installLog('DBG: save currency'); |
584 | 584 | $currency->save(); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | $sugar_config = get_sugar_config_defaults(); |
602 | 602 | |
603 | 603 | // set local settings - if neccessary you can set here more fields as named in User module / EditView form... |
604 | -if(isset($_REQUEST['timezone']) && $_REQUEST['timezone']) { |
|
604 | +if (isset($_REQUEST['timezone']) && $_REQUEST['timezone']) { |
|
605 | 605 | $current_user->setPreference('timezone', $_REQUEST['timezone']); |
606 | 606 | } |
607 | 607 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | //$_POST[''] = $_REQUEST['export_delimiter']; |
621 | 621 | |
622 | 622 | $_POST['record'] = $current_user->id; |
623 | -$_POST['is_admin'] = ( $current_user->is_admin ? 'on' : '' ); |
|
623 | +$_POST['is_admin'] = ($current_user->is_admin ? 'on' : ''); |
|
624 | 624 | $_POST['use_real_names'] = true; |
625 | 625 | $_POST['reminder_checked'] = '1'; |
626 | 626 | $_POST['reminder_time'] = 1800; |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | $_POST['mailmerge_on'] = 'on'; |
629 | 629 | $_POST['receive_notifications'] = $current_user->receive_notifications; |
630 | 630 | installLog('DBG: SugarThemeRegistry::getDefault'); |
631 | -$_POST['user_theme'] = (string) SugarThemeRegistry::getDefault(); |
|
631 | +$_POST['user_theme'] = (string)SugarThemeRegistry::getDefault(); |
|
632 | 632 | |
633 | 633 | // save and redirect to new view |
634 | 634 | $_REQUEST['return_module'] = 'Home'; |
@@ -638,15 +638,15 @@ discard block |
||
638 | 638 | |
639 | 639 | // restore superglobals and vars |
640 | 640 | $GLOBALS = $varStack['GLOBALS']; |
641 | -foreach($varStack['defined_vars'] as $__key => $__value) $$__key = $__value; |
|
641 | +foreach ($varStack['defined_vars'] as $__key => $__value) $$__key = $__value; |
|
642 | 642 | |
643 | 643 | |
644 | 644 | |
645 | 645 | $endTime = microtime(true); |
646 | 646 | $deltaTime = $endTime - $startTime; |
647 | 647 | |
648 | -if( count( $bottle ) > 0 ){ |
|
649 | - foreach( $bottle as $bottle_message ){ |
|
648 | +if (count($bottle) > 0) { |
|
649 | + foreach ($bottle as $bottle_message) { |
|
650 | 650 | $bottleMsg .= "{$bottle_message}\n"; |
651 | 651 | } |
652 | 652 | } else { |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | } |
655 | 655 | installerHook('post_installModules'); |
656 | 656 | |
657 | -$out =<<<EOQ |
|
657 | +$out = <<<EOQ |
|
658 | 658 | <br><p><b>{$mod_strings['LBL_PERFORM_OUTRO_1']} {$setup_sugar_version} {$mod_strings['LBL_PERFORM_OUTRO_2']}</b></p> |
659 | 659 | |
660 | 660 | {$mod_strings['LBL_PERFORM_OUTRO_3']} {$deltaTime} {$mod_strings['LBL_PERFORM_OUTRO_4']}<br /> |
@@ -676,6 +676,6 @@ discard block |
||
676 | 676 | echo $out; |
677 | 677 | |
678 | 678 | $loginURL = str_replace('install.php', 'index.php', "//$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); |
679 | -installStatus(sprintf($mod_strings['STAT_INSTALL_FINISH_LOGIN'], $loginURL ) , array('function' => 'redirect', 'arguments' => $loginURL) ); |
|
679 | +installStatus(sprintf($mod_strings['STAT_INSTALL_FINISH_LOGIN'], $loginURL), array('function' => 'redirect', 'arguments' => $loginURL)); |
|
680 | 680 | |
681 | 681 | ?> |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -243,8 +245,9 @@ discard block |
||
243 | 245 | $focus = new $bean(); |
244 | 246 | } |
245 | 247 | |
246 | - if ( $bean == 'Configurator' ) |
|
247 | - continue; |
|
248 | + if ( $bean == 'Configurator' ) { |
|
249 | + continue; |
|
250 | + } |
|
248 | 251 | |
249 | 252 | $table_name = $focus->table_name; |
250 | 253 | //installStatus(sprintf($mod_strings['STAT_CREATE_DB_TABLE'], $focus->table_name )); |
@@ -278,8 +281,9 @@ discard block |
||
278 | 281 | if( $bean == "User" ){ |
279 | 282 | $new_tables = 1; |
280 | 283 | } |
281 | - if($bean == "Administration") |
|
282 | - $new_config = 1; |
|
284 | + if($bean == "Administration") { |
|
285 | + $new_config = 1; |
|
286 | + } |
|
283 | 287 | |
284 | 288 | |
285 | 289 | } |
@@ -404,8 +408,9 @@ discard block |
||
404 | 408 | } |
405 | 409 | if ($fp && (!isset($_SESSION['oc_install']) || $_SESSION['oc_install'] == false)) { |
406 | 410 | @fclose($fp); |
407 | - if ($next_step == 9999) |
|
408 | - $next_step = 8; |
|
411 | + if ($next_step == 9999) { |
|
412 | + $next_step = 8; |
|
413 | + } |
|
409 | 414 | $fpResult = <<<FP |
410 | 415 | <form action="install.php" method="post" name="form" id="form"> |
411 | 416 | <input type="hidden" name="current_step" value="{$next_step}"> |
@@ -423,7 +428,7 @@ discard block |
||
423 | 428 | |
424 | 429 | if( isset($_SESSION['setup_site_sugarbeet_automatic_checks']) && $_SESSION['setup_site_sugarbeet_automatic_checks'] == true){ |
425 | 430 | set_CheckUpdates_config_setting('automatic'); |
426 | - }else{ |
|
431 | + } else{ |
|
427 | 432 | set_CheckUpdates_config_setting('manual'); |
428 | 433 | } |
429 | 434 | if(!empty($_SESSION['setup_system_name'])){ |
@@ -554,10 +559,18 @@ discard block |
||
554 | 559 | |
555 | 560 | installLog('handleOverride'); |
556 | 561 | // add local settings to config overrides |
557 | -if(!empty($_SESSION['default_date_format'])) $sugar_config['default_date_format'] = $_SESSION['default_date_format']; |
|
558 | -if(!empty($_SESSION['default_time_format'])) $sugar_config['default_time_format'] = $_SESSION['default_time_format']; |
|
559 | -if(!empty($_SESSION['default_language'])) $sugar_config['default_language'] = $_SESSION['default_language']; |
|
560 | -if(!empty($_SESSION['default_locale_name_format'])) $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format']; |
|
562 | +if(!empty($_SESSION['default_date_format'])) { |
|
563 | + $sugar_config['default_date_format'] = $_SESSION['default_date_format']; |
|
564 | +} |
|
565 | +if(!empty($_SESSION['default_time_format'])) { |
|
566 | + $sugar_config['default_time_format'] = $_SESSION['default_time_format']; |
|
567 | +} |
|
568 | +if(!empty($_SESSION['default_language'])) { |
|
569 | + $sugar_config['default_language'] = $_SESSION['default_language']; |
|
570 | +} |
|
571 | +if(!empty($_SESSION['default_locale_name_format'])) { |
|
572 | + $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format']; |
|
573 | +} |
|
561 | 574 | //$configurator->handleOverride(); |
562 | 575 | |
563 | 576 | |
@@ -638,7 +651,9 @@ discard block |
||
638 | 651 | |
639 | 652 | // restore superglobals and vars |
640 | 653 | $GLOBALS = $varStack['GLOBALS']; |
641 | -foreach($varStack['defined_vars'] as $__key => $__value) $$__key = $__value; |
|
654 | +foreach($varStack['defined_vars'] as $__key => $__value) { |
|
655 | + $$__key = $__value; |
|
656 | +} |
|
642 | 657 | |
643 | 658 | |
644 | 659 |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | private function getFormItems($mod_strings, $app_list_strings, $sugarConfigDefaults, $drivers, $checked, $db, $errors, $supportedLanguages, |
224 | - $current_language, $customSession, $customLog, $customId, $customSessionHidden, $customLogHidden, $customIdHidden) { |
|
224 | + $current_language, $customSession, $customLog, $customId, $customSessionHidden, $customLogHidden, $customIdHidden) { |
|
225 | 225 | |
226 | 226 | |
227 | 227 | |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | $_SESSION['email1'] = null; |
446 | 446 | } |
447 | 447 | |
448 | - if(!isset($_SESSION['setup_site_admin_user_name'])) { |
|
449 | - $_SESSION['setup_site_admin_user_name'] = null; |
|
450 | - } |
|
448 | + if(!isset($_SESSION['setup_site_admin_user_name'])) { |
|
449 | + $_SESSION['setup_site_admin_user_name'] = null; |
|
450 | + } |
|
451 | 451 | |
452 | 452 | $out .=<<<EOQ |
453 | 453 | <div class='install_block'> |
@@ -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. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ********************************************************************************/ |
40 | 40 | |
41 | 41 | |
42 | -if( !isset( $install_script ) || !$install_script ){ |
|
42 | +if (!isset($install_script) || !$install_script) { |
|
43 | 43 | die($mod_strings['ERR_NO_DIRECT_SCRIPT']); |
44 | 44 | } |
45 | 45 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | public static function getSelect($name, $options, $default) { |
89 | 89 | $out = "<select name=\"$name\">"; |
90 | - foreach($options as $key => $value) { |
|
90 | + foreach ($options as $key => $value) { |
|
91 | 91 | $selected = ''; |
92 | - if($key==$default) $selected = ' selected="selected"'; |
|
92 | + if ($key == $default) $selected = ' selected="selected"'; |
|
93 | 93 | $out .= "<option label=\"$value\" value=\"$key\"$selected>$value</option>"; |
94 | 94 | } |
95 | 95 | $out .= "</select>"; |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | <div class=\"form_section\"> |
239 | 239 | <h3>{$mod_strings['LBL_SYSOPTS_DB']}</h3>"; |
240 | 240 | |
241 | - foreach($drivers as $type => $driver) { |
|
242 | - $oci = ($type == "oci8")?"":'none'; // hack for special oracle message |
|
243 | - $out_dbtypesel.=<<<EOQ |
|
241 | + foreach ($drivers as $type => $driver) { |
|
242 | + $oci = ($type == "oci8") ? "" : 'none'; // hack for special oracle message |
|
243 | + $out_dbtypesel .= <<<EOQ |
|
244 | 244 | <input type="radio" class="checkbox" name="setup_db_type" id="setup_db_type" value="$type" {$checked[$type]} onclick="onDBTypeClick(this);//document.getElementById('ociMsg').style.display='$oci'"/>{$mod_strings[$driver->label]}<br> |
245 | 245 | EOQ; |
246 | 246 | } |
247 | - $out_dbtypesel.=<<<EOQ |
|
247 | + $out_dbtypesel .= <<<EOQ |
|
248 | 248 | </div> |
249 | 249 | <div name="ociMsg" id="ociMsg" style="display:none"></div> |
250 | 250 | <!-- </div> --> |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $out2 = $out_dbtypesel; |
255 | 255 | |
256 | 256 | |
257 | - $out2.=<<<EOQ2 |
|
257 | + $out2 .= <<<EOQ2 |
|
258 | 258 | |
259 | 259 | <!-- <div class="floatbox"> --> |
260 | 260 | |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | |
266 | 266 | $config_params = $db->installConfig(); |
267 | 267 | $form = ''; |
268 | - foreach($config_params as $group => $gdata) { |
|
269 | - $form.= "<div class='install_block'>"; |
|
270 | - if($mod_strings[$group . '_LABEL']) { |
|
271 | - $form .= "<label>{$mod_strings[$group . '_LABEL']}" . "<i> i <div class=\"tooltip\">{$mod_strings[$group]}</div></i></label>\n"; |
|
268 | + foreach ($config_params as $group => $gdata) { |
|
269 | + $form .= "<div class='install_block'>"; |
|
270 | + if ($mod_strings[$group.'_LABEL']) { |
|
271 | + $form .= "<label>{$mod_strings[$group.'_LABEL']}"."<i> i <div class=\"tooltip\">{$mod_strings[$group]}</div></i></label>\n"; |
|
272 | 272 | } |
273 | - foreach($gdata as $name => $value) { |
|
273 | + foreach ($gdata as $name => $value) { |
|
274 | 274 | |
275 | - if(!empty($value)) { |
|
276 | - if(!empty($value['required'])) { |
|
275 | + if (!empty($value)) { |
|
276 | + if (!empty($value['required'])) { |
|
277 | 277 | $form .= "<span class=\"required\">*</span>"; |
278 | 278 | } |
279 | 279 | else { |
280 | 280 | } |
281 | - if(!empty($_SESSION[$name])) { |
|
281 | + if (!empty($_SESSION[$name])) { |
|
282 | 282 | $sessval = $_SESSION[$name]; |
283 | 283 | } else { |
284 | 284 | $sessval = ''; |
285 | 285 | } |
286 | - if(!empty($value["type"])) { |
|
286 | + if (!empty($value["type"])) { |
|
287 | 287 | $type = $value["type"]; |
288 | 288 | } else { |
289 | 289 | $type = ''; |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | |
294 | 294 | FORM; |
295 | 295 | //if the type is password, set a hidden field to capture the value. This is so that we can properly encode special characters, which is a limitation with password fields |
296 | - if($type=='password'){ |
|
296 | + if ($type == 'password') { |
|
297 | 297 | $form .= "</div><div class=\"install_block\"><label>{$mod_strings['LBL_DBCONF_TITLE_PSWD_INFO_LABEL']}</label><span> </span><input type='$type' name='{$name}_entry' id='{$name}_entry' value='".urldecode($sessval)."'><input type='hidden' name='$name' id='$name' value='".urldecode($sessval)."'></div><div class=\"install_block\">"; |
298 | - }else{ |
|
298 | + } else { |
|
299 | 299 | $form .= "<input type='$type' name='$name' id='$name' value='$sessval'>"; |
300 | 300 | } |
301 | 301 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | |
321 | 321 | //if we are installing in custom mode, include the following html |
322 | - if($db->supports("create_user")) { |
|
322 | + if ($db->supports("create_user")) { |
|
323 | 323 | // create / set db user dropdown |
324 | 324 | $auto_select = ''; |
325 | 325 | $provide_select = ''; |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | $same_select = 'selected'; |
343 | 343 | } |
344 | 344 | $dbUSRDD = "<select name='dbUSRData' id='dbUSRData' onchange='toggleDBUser();'>"; |
345 | - $dbUSRDD .= "<option value='provide' $provide_select>" . $mod_strings['LBL_DBCONFIG_PROVIDE_DD'] . "</option>"; |
|
346 | - $dbUSRDD .= "<option value='create' $create_select>" . $mod_strings['LBL_DBCONFIG_CREATE_DD'] . "</option>"; |
|
347 | - $dbUSRDD .= "<option value='same' $same_select>" . $mod_strings['LBL_DBCONFIG_SAME_DD'] . "</option>"; |
|
345 | + $dbUSRDD .= "<option value='provide' $provide_select>".$mod_strings['LBL_DBCONFIG_PROVIDE_DD']."</option>"; |
|
346 | + $dbUSRDD .= "<option value='create' $create_select>".$mod_strings['LBL_DBCONFIG_CREATE_DD']."</option>"; |
|
347 | + $dbUSRDD .= "<option value='same' $same_select>".$mod_strings['LBL_DBCONFIG_SAME_DD']."</option>"; |
|
348 | 348 | $dbUSRDD .= "</select><br> "; |
349 | 349 | |
350 | 350 | |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | |
389 | 389 | EOQ2; |
390 | 390 | } |
391 | - $out =$out2; |
|
391 | + $out = $out2; |
|
392 | 392 | |
393 | 393 | |
394 | 394 | |
395 | 395 | // ------ siteConfig_a.php |
396 | - $out .=<<<EOQ |
|
396 | + $out .= <<<EOQ |
|
397 | 397 | </div> |
398 | 398 | </div> |
399 | 399 | <div class="floatbox" id="fb6"> |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | <h3>{$mod_strings['LBL_SITECFG_TITLE2']}<div class="tooltip-toggle"><em> i </em><div class="tooltip">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</div></div></h3> |
406 | 406 | EOQ; |
407 | 407 | //hide this in typical mode |
408 | - if(!empty($_SESSION['install_type']) && strtolower($_SESSION['install_type'])=='custom'){ |
|
409 | - $out .=<<<EOQ |
|
408 | + if (!empty($_SESSION['install_type']) && strtolower($_SESSION['install_type']) == 'custom') { |
|
409 | + $out .= <<<EOQ |
|
410 | 410 | <div class='install_block'> |
411 | 411 | {$mod_strings['LBL_SITECFG_URL_MSG']} |
412 | 412 | <span class="required">*</span> |
@@ -419,17 +419,17 @@ discard block |
||
419 | 419 | </div> |
420 | 420 | EOQ; |
421 | 421 | $db = getDbConnection(); |
422 | - if($db->supports("collation")) { |
|
422 | + if ($db->supports("collation")) { |
|
423 | 423 | $collationOptions = $db->getCollationList(); |
424 | 424 | } |
425 | - if(!empty($collationOptions)) { |
|
426 | - if(isset($_SESSION['setup_db_options']['collation'])) { |
|
425 | + if (!empty($collationOptions)) { |
|
426 | + if (isset($_SESSION['setup_db_options']['collation'])) { |
|
427 | 427 | $default = $_SESSION['setup_db_options']['collation']; |
428 | 428 | } else { |
429 | 429 | $default = $db->getDefaultCollation(); |
430 | 430 | } |
431 | 431 | $options = get_select_options_with_id(array_combine($collationOptions, $collationOptions), $default); |
432 | - $out .=<<<EOQ |
|
432 | + $out .= <<<EOQ |
|
433 | 433 | <div class='install_block'> |
434 | 434 | <br>{$mod_strings['LBL_SITECFG_COLLATION_MSG']} |
435 | 435 | <span class="required">*</span> |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | } |
442 | 442 | |
443 | 443 | $help_url = get_help_button_url(); |
444 | - if(!isset($_SESSION['email1'])) { |
|
444 | + if (!isset($_SESSION['email1'])) { |
|
445 | 445 | $_SESSION['email1'] = null; |
446 | 446 | } |
447 | 447 | |
448 | - if(!isset($_SESSION['setup_site_admin_user_name'])) { |
|
448 | + if (!isset($_SESSION['setup_site_admin_user_name'])) { |
|
449 | 449 | $_SESSION['setup_site_admin_user_name'] = null; |
450 | 450 | } |
451 | 451 | |
452 | - $out .=<<<EOQ |
|
452 | + $out .= <<<EOQ |
|
453 | 453 | <div class='install_block'> |
454 | 454 | <!-- |
455 | 455 | <p class="ibmsg">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</p> |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | EOQ; |
499 | 499 | |
500 | 500 | |
501 | - $out.=<<<EOQ |
|
501 | + $out .= <<<EOQ |
|
502 | 502 | </div><!-- dbg2 --> |
503 | 503 | EOQ; |
504 | 504 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $demoDD = "<select name='demoData' id='demoData' class='select'><option value='no' >".$mod_strings['LBL_NO']."</option><option value='yes'>".$mod_strings['LBL_YES']."</option>"; |
518 | 518 | $demoDD .= "</select>"; |
519 | 519 | |
520 | - $out .=<<<EOQ3 |
|
520 | + $out .= <<<EOQ3 |
|
521 | 521 | </div> |
522 | 522 | </div> |
523 | 523 | |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | $notify_allow_default_outbound_checked = empty($_SESSION['notify_allow_default_outbound']) ? '' : ' checked="checked" '; |
560 | 560 | |
561 | 561 | // set default smtp toggle buttons selected value |
562 | - if(empty($_SESSION['smtp_tab_selected'])) $_SESSION['smtp_tab_selected'] = 'smtp_tab_other'; |
|
562 | + if (empty($_SESSION['smtp_tab_selected'])) $_SESSION['smtp_tab_selected'] = 'smtp_tab_other'; |
|
563 | 563 | |
564 | 564 | $out .= <<<EOQ |
565 | 565 | <div class="floatbox full" id="fb2"> |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | // db setup (dbConfig_a.php) |
820 | - $out2 =<<<EOQ2 |
|
820 | + $out2 = <<<EOQ2 |
|
821 | 821 | <input type='hidden' name='setup_db_drop_tables' id='setup_db_drop_tables' value=''> |
822 | 822 | </div> |
823 | 823 | EOQ2; |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | $currentLogoLink = SugarThemeRegistry::current()->getImageURL('company_logo.png'); |
837 | 837 | // show logo if we have |
838 | 838 | $hiddenLogo = ''; |
839 | - if(!file_exists($currentLogoLink)) { |
|
839 | + if (!file_exists($currentLogoLink)) { |
|
840 | 840 | $hiddenLogo = 'display:none;'; |
841 | 841 | } |
842 | 842 | |
@@ -989,10 +989,10 @@ discard block |
||
989 | 989 | EOQ; |
990 | 990 | |
991 | 991 | |
992 | -$out.= "<div class=\"floatbox full\">"; |
|
993 | -$out.= " <h3 onclick=\"$(this).next().toggle();\" class=\"toggler\">» {$mod_strings['LBL_SITECFG_SECURITY_TITLE']}</h3>"; |
|
992 | +$out .= "<div class=\"floatbox full\">"; |
|
993 | +$out .= " <h3 onclick=\"$(this).next().toggle();\" class=\"toggler\">» {$mod_strings['LBL_SITECFG_SECURITY_TITLE']}</h3>"; |
|
994 | 994 | |
995 | - $out.=<<<EOQ |
|
995 | + $out .= <<<EOQ |
|
996 | 996 | |
997 | 997 | <div class="security-block" style="display:none;"> |
998 | 998 | <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell"> |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | </div><!-- dbg1 --> |
1082 | 1082 | EOQ; |
1083 | 1083 | |
1084 | -$out.= "</div>"; |
|
1084 | +$out .= "</div>"; |
|
1085 | 1085 | |
1086 | 1086 | |
1087 | 1087 | |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | private function getFormControlls($mod_strings, $formId) { |
1092 | - $out =<<<EOQ |
|
1092 | + $out = <<<EOQ |
|
1093 | 1093 | <div id="checkingDiv" style="display:none"> |
1094 | 1094 | <p><img alt="{$mod_strings['LBL_LICENSE_CHKDB_HEADER']}" src='install/processing.gif'> <br>{$mod_strings['LBL_LICENSE_CHKDB_HEADER']}</p> |
1095 | 1095 | </div> |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | private function getFormScripts($mod_strings, $next_step) { |
1378 | - $out =<<<EOQ |
|
1378 | + $out = <<<EOQ |
|
1379 | 1379 | /** |
1380 | 1380 | * Submit form without step. |
1381 | 1381 | */ |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | * @return string output |
1576 | 1576 | */ |
1577 | 1577 | public function show($data = null) { |
1578 | - foreach($data as $__key => $__val) { |
|
1578 | + foreach ($data as $__key => $__val) { |
|
1579 | 1579 | $$__key = $__val; |
1580 | 1580 | } |
1581 | 1581 | $formId = 'installForm'; |
@@ -1633,7 +1633,7 @@ discard block |
||
1633 | 1633 | |
1634 | 1634 | |
1635 | 1635 | |
1636 | -if( !isset( $install_script ) || !$install_script ){ |
|
1636 | +if (!isset($install_script) || !$install_script) { |
|
1637 | 1637 | die($mod_strings['ERR_NO_DIRECT_SCRIPT']); |
1638 | 1638 | } |
1639 | 1639 | |
@@ -1641,20 +1641,20 @@ discard block |
||
1641 | 1641 | |
1642 | 1642 | //---------------- systemOption: db driver select |
1643 | 1643 | |
1644 | -if(!isset($_SESSION['setup_db_type']) || $_SESSION['setup_db_type'] ==''){ |
|
1644 | +if (!isset($_SESSION['setup_db_type']) || $_SESSION['setup_db_type'] == '') { |
|
1645 | 1645 | $_SESSION['setup_db_type'] = 'mysql'; |
1646 | 1646 | } |
1647 | 1647 | $setup_db_type = $_SESSION['setup_db_type']; |
1648 | 1648 | |
1649 | 1649 | $errs = ''; |
1650 | -if(isset($validation_errors)) { |
|
1651 | - if(count($validation_errors) > 0) { |
|
1650 | +if (isset($validation_errors)) { |
|
1651 | + if (count($validation_errors) > 0) { |
|
1652 | 1652 | $errs = '<div id="errorMsgs">'; |
1653 | 1653 | $errs .= "<p>{$mod_strings['LBL_SYSOPTS_ERRS_TITLE']}</p>"; |
1654 | 1654 | $errs .= '<ul>'; |
1655 | 1655 | |
1656 | - foreach($validation_errors as $error) { |
|
1657 | - $errs .= '<li>' . $error . '</li>'; |
|
1656 | + foreach ($validation_errors as $error) { |
|
1657 | + $errs .= '<li>'.$error.'</li>'; |
|
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | $errs .= '</ul>'; |
@@ -1663,7 +1663,7 @@ discard block |
||
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | $drivers = DBManagerFactory::getDbDrivers(); |
1666 | -foreach(array_keys($drivers) as $dname) { |
|
1666 | +foreach (array_keys($drivers) as $dname) { |
|
1667 | 1667 | $checked[$dname] = ''; |
1668 | 1668 | } |
1669 | 1669 | $checked[$setup_db_type] = 'checked="checked"'; |
@@ -1672,8 +1672,8 @@ discard block |
||
1672 | 1672 | |
1673 | 1673 | //----------------- dbConfig_a: db name user pass... |
1674 | 1674 | |
1675 | -if(empty($_SESSION['setup_db_host_name'])){ |
|
1676 | - $_SESSION['setup_db_host_name'] = (isset($sugar_config['db_host_name'])) ? $sugar_config['db_host_name'] : $_SERVER['SERVER_NAME']; |
|
1675 | +if (empty($_SESSION['setup_db_host_name'])) { |
|
1676 | + $_SESSION['setup_db_host_name'] = (isset($sugar_config['db_host_name'])) ? $sugar_config['db_host_name'] : $_SERVER['SERVER_NAME']; |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | |
@@ -1682,16 +1682,16 @@ discard block |
||
1682 | 1682 | $createDb = (!empty($_SESSION['setup_db_create_database'])) ? 'checked="checked"' : ''; |
1683 | 1683 | $dropCreate = (!empty($_SESSION['setup_db_drop_tables'])) ? 'checked="checked"' : ''; |
1684 | 1684 | $instanceName = ''; |
1685 | -if (isset($_SESSION['setup_db_host_instance']) && !empty($_SESSION['setup_db_host_instance'])){ |
|
1685 | +if (isset($_SESSION['setup_db_host_instance']) && !empty($_SESSION['setup_db_host_instance'])) { |
|
1686 | 1686 | $instanceName = $_SESSION['setup_db_host_instance']; |
1687 | 1687 | } |
1688 | 1688 | |
1689 | -$setupDbPortNum =''; |
|
1690 | -if (isset($_SESSION['setup_db_port_num']) && !empty($_SESSION['setup_db_port_num'])){ |
|
1689 | +$setupDbPortNum = ''; |
|
1690 | +if (isset($_SESSION['setup_db_port_num']) && !empty($_SESSION['setup_db_port_num'])) { |
|
1691 | 1691 | $setupDbPortNum = $_SESSION['setup_db_port_num']; |
1692 | 1692 | } |
1693 | 1693 | |
1694 | -if(!isset($_SESSION['setup_db_manager'])) { |
|
1694 | +if (!isset($_SESSION['setup_db_manager'])) { |
|
1695 | 1695 | $_SESSION['setup_db_manager'] = null; |
1696 | 1696 | } |
1697 | 1697 | |
@@ -1704,54 +1704,54 @@ discard block |
||
1704 | 1704 | //----------------- siteConfig_a.php Site Config & admin user |
1705 | 1705 | |
1706 | 1706 | |
1707 | -if( is_file("config.php") ){ |
|
1708 | - if(!empty($sugar_config['default_theme'])) |
|
1707 | +if (is_file("config.php")) { |
|
1708 | + if (!empty($sugar_config['default_theme'])) |
|
1709 | 1709 | $_SESSION['site_default_theme'] = $sugar_config['default_theme']; |
1710 | 1710 | |
1711 | - if(!empty($sugar_config['disable_persistent_connections'])) |
|
1711 | + if (!empty($sugar_config['disable_persistent_connections'])) |
|
1712 | 1712 | $_SESSION['disable_persistent_connections'] = |
1713 | 1713 | $sugar_config['disable_persistent_connections']; |
1714 | - if(!empty($sugar_config['default_language'])) |
|
1714 | + if (!empty($sugar_config['default_language'])) |
|
1715 | 1715 | $_SESSION['default_language'] = $sugar_config['default_language']; |
1716 | - if(!empty($sugar_config['translation_string_prefix'])) |
|
1716 | + if (!empty($sugar_config['translation_string_prefix'])) |
|
1717 | 1717 | $_SESSION['translation_string_prefix'] = $sugar_config['translation_string_prefix']; |
1718 | - if(!empty($sugar_config['default_charset'])) |
|
1718 | + if (!empty($sugar_config['default_charset'])) |
|
1719 | 1719 | $_SESSION['default_charset'] = $sugar_config['default_charset']; |
1720 | 1720 | |
1721 | - if(!empty($sugar_config['default_currency_name'])) |
|
1721 | + if (!empty($sugar_config['default_currency_name'])) |
|
1722 | 1722 | $_SESSION['default_currency_name'] = $sugar_config['default_currency_name']; |
1723 | - if(!empty($sugar_config['default_currency_symbol'])) |
|
1723 | + if (!empty($sugar_config['default_currency_symbol'])) |
|
1724 | 1724 | $_SESSION['default_currency_symbol'] = $sugar_config['default_currency_symbol']; |
1725 | - if(!empty($sugar_config['default_currency_iso4217'])) |
|
1725 | + if (!empty($sugar_config['default_currency_iso4217'])) |
|
1726 | 1726 | $_SESSION['default_currency_iso4217'] = $sugar_config['default_currency_iso4217']; |
1727 | 1727 | |
1728 | - if(!empty($sugar_config['rss_cache_time'])) |
|
1728 | + if (!empty($sugar_config['rss_cache_time'])) |
|
1729 | 1729 | $_SESSION['rss_cache_time'] = $sugar_config['rss_cache_time']; |
1730 | - if(!empty($sugar_config['languages'])) |
|
1730 | + if (!empty($sugar_config['languages'])) |
|
1731 | 1731 | { |
1732 | 1732 | // We need to encode the languages in a way that can be retrieved later. |
1733 | 1733 | $language_keys = Array(); |
1734 | 1734 | $language_values = Array(); |
1735 | 1735 | |
1736 | - foreach($sugar_config['languages'] as $key=>$value) |
|
1736 | + foreach ($sugar_config['languages'] as $key=>$value) |
|
1737 | 1737 | { |
1738 | 1738 | $language_keys[] = $key; |
1739 | 1739 | $language_values[] = $value; |
1740 | 1740 | } |
1741 | 1741 | |
1742 | - $_SESSION['language_keys'] = urlencode(implode(",",$language_keys)); |
|
1743 | - $_SESSION['language_values'] = urlencode(implode(",",$language_values)); |
|
1742 | + $_SESSION['language_keys'] = urlencode(implode(",", $language_keys)); |
|
1743 | + $_SESSION['language_values'] = urlencode(implode(",", $language_values)); |
|
1744 | 1744 | } |
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | //// errors |
1748 | 1748 | $errors = ''; |
1749 | -if( isset($validation_errors) && is_array($validation_errors)){ |
|
1750 | - if( count($validation_errors) > 0 ){ |
|
1749 | +if (isset($validation_errors) && is_array($validation_errors)) { |
|
1750 | + if (count($validation_errors) > 0) { |
|
1751 | 1751 | $errors = '<div id="errorMsgs">'; |
1752 | 1752 | $errors .= '<p>'.$mod_strings['LBL_SITECFG_FIX_ERRORS'].'</p><ul>'; |
1753 | - foreach( $validation_errors as $error ){ |
|
1754 | - $errors .= '<li>' . $error . '</li>'; |
|
1753 | + foreach ($validation_errors as $error) { |
|
1754 | + $errors .= '<li>'.$error.'</li>'; |
|
1755 | 1755 | } |
1756 | 1756 | $errors .= '</ul></div>'; |
1757 | 1757 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -89,7 +91,9 @@ discard block |
||
89 | 91 | $out = "<select name=\"$name\">"; |
90 | 92 | foreach($options as $key => $value) { |
91 | 93 | $selected = ''; |
92 | - if($key==$default) $selected = ' selected="selected"'; |
|
94 | + if($key==$default) { |
|
95 | + $selected = ' selected="selected"'; |
|
96 | + } |
|
93 | 97 | $out .= "<option label=\"$value\" value=\"$key\"$selected>$value</option>"; |
94 | 98 | } |
95 | 99 | $out .= "</select>"; |
@@ -275,8 +279,7 @@ discard block |
||
275 | 279 | if(!empty($value)) { |
276 | 280 | if(!empty($value['required'])) { |
277 | 281 | $form .= "<span class=\"required\">*</span>"; |
278 | - } |
|
279 | - else { |
|
282 | + } else { |
|
280 | 283 | } |
281 | 284 | if(!empty($_SESSION[$name])) { |
282 | 285 | $sessval = $_SESSION[$name]; |
@@ -295,7 +298,7 @@ discard block |
||
295 | 298 | //if the type is password, set a hidden field to capture the value. This is so that we can properly encode special characters, which is a limitation with password fields |
296 | 299 | if($type=='password'){ |
297 | 300 | $form .= "</div><div class=\"install_block\"><label>{$mod_strings['LBL_DBCONF_TITLE_PSWD_INFO_LABEL']}</label><span> </span><input type='$type' name='{$name}_entry' id='{$name}_entry' value='".urldecode($sessval)."'><input type='hidden' name='$name' id='$name' value='".urldecode($sessval)."'></div><div class=\"install_block\">"; |
298 | - }else{ |
|
301 | + } else{ |
|
299 | 302 | $form .= "<input type='$type' name='$name' id='$name' value='$sessval'>"; |
300 | 303 | } |
301 | 304 | |
@@ -559,7 +562,9 @@ discard block |
||
559 | 562 | $notify_allow_default_outbound_checked = empty($_SESSION['notify_allow_default_outbound']) ? '' : ' checked="checked" '; |
560 | 563 | |
561 | 564 | // set default smtp toggle buttons selected value |
562 | - if(empty($_SESSION['smtp_tab_selected'])) $_SESSION['smtp_tab_selected'] = 'smtp_tab_other'; |
|
565 | + if(empty($_SESSION['smtp_tab_selected'])) { |
|
566 | + $_SESSION['smtp_tab_selected'] = 'smtp_tab_other'; |
|
567 | + } |
|
563 | 568 | |
564 | 569 | $out .= <<<EOQ |
565 | 570 | <div class="floatbox full" id="fb2"> |
@@ -1705,28 +1710,37 @@ discard block |
||
1705 | 1710 | |
1706 | 1711 | |
1707 | 1712 | if( is_file("config.php") ){ |
1708 | - if(!empty($sugar_config['default_theme'])) |
|
1709 | - $_SESSION['site_default_theme'] = $sugar_config['default_theme']; |
|
1713 | + if(!empty($sugar_config['default_theme'])) { |
|
1714 | + $_SESSION['site_default_theme'] = $sugar_config['default_theme']; |
|
1715 | + } |
|
1710 | 1716 | |
1711 | - if(!empty($sugar_config['disable_persistent_connections'])) |
|
1712 | - $_SESSION['disable_persistent_connections'] = |
|
1717 | + if(!empty($sugar_config['disable_persistent_connections'])) { |
|
1718 | + $_SESSION['disable_persistent_connections'] = |
|
1713 | 1719 | $sugar_config['disable_persistent_connections']; |
1714 | - if(!empty($sugar_config['default_language'])) |
|
1715 | - $_SESSION['default_language'] = $sugar_config['default_language']; |
|
1716 | - if(!empty($sugar_config['translation_string_prefix'])) |
|
1717 | - $_SESSION['translation_string_prefix'] = $sugar_config['translation_string_prefix']; |
|
1718 | - if(!empty($sugar_config['default_charset'])) |
|
1719 | - $_SESSION['default_charset'] = $sugar_config['default_charset']; |
|
1720 | - |
|
1721 | - if(!empty($sugar_config['default_currency_name'])) |
|
1722 | - $_SESSION['default_currency_name'] = $sugar_config['default_currency_name']; |
|
1723 | - if(!empty($sugar_config['default_currency_symbol'])) |
|
1724 | - $_SESSION['default_currency_symbol'] = $sugar_config['default_currency_symbol']; |
|
1725 | - if(!empty($sugar_config['default_currency_iso4217'])) |
|
1726 | - $_SESSION['default_currency_iso4217'] = $sugar_config['default_currency_iso4217']; |
|
1727 | - |
|
1728 | - if(!empty($sugar_config['rss_cache_time'])) |
|
1729 | - $_SESSION['rss_cache_time'] = $sugar_config['rss_cache_time']; |
|
1720 | + } |
|
1721 | + if(!empty($sugar_config['default_language'])) { |
|
1722 | + $_SESSION['default_language'] = $sugar_config['default_language']; |
|
1723 | + } |
|
1724 | + if(!empty($sugar_config['translation_string_prefix'])) { |
|
1725 | + $_SESSION['translation_string_prefix'] = $sugar_config['translation_string_prefix']; |
|
1726 | + } |
|
1727 | + if(!empty($sugar_config['default_charset'])) { |
|
1728 | + $_SESSION['default_charset'] = $sugar_config['default_charset']; |
|
1729 | + } |
|
1730 | + |
|
1731 | + if(!empty($sugar_config['default_currency_name'])) { |
|
1732 | + $_SESSION['default_currency_name'] = $sugar_config['default_currency_name']; |
|
1733 | + } |
|
1734 | + if(!empty($sugar_config['default_currency_symbol'])) { |
|
1735 | + $_SESSION['default_currency_symbol'] = $sugar_config['default_currency_symbol']; |
|
1736 | + } |
|
1737 | + if(!empty($sugar_config['default_currency_iso4217'])) { |
|
1738 | + $_SESSION['default_currency_iso4217'] = $sugar_config['default_currency_iso4217']; |
|
1739 | + } |
|
1740 | + |
|
1741 | + if(!empty($sugar_config['rss_cache_time'])) { |
|
1742 | + $_SESSION['rss_cache_time'] = $sugar_config['rss_cache_time']; |
|
1743 | + } |
|
1730 | 1744 | if(!empty($sugar_config['languages'])) |
1731 | 1745 | { |
1732 | 1746 | // We need to encode the languages in a way that can be retrieved later. |
@@ -75,7 +75,9 @@ discard block |
||
75 | 75 | $vardef['type'] = 'varchar'; |
76 | 76 | } |
77 | 77 | |
78 | - if (isset($vardef['precision'])) unset($vardef['precision']); |
|
78 | + if (isset($vardef['precision'])) { |
|
79 | + unset($vardef['precision']); |
|
80 | + } |
|
79 | 81 | |
80 | 82 | //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user); |
81 | 83 | |
@@ -115,8 +117,9 @@ discard block |
||
115 | 117 | if (isset($vardef['function']) |
116 | 118 | && ($vardef['function'] == 'getEmailAddressWidget' |
117 | 119 | || $vardef['function']['name'] == 'getEmailAddressWidget') |
118 | - ) |
|
119 | - unset($vardef['function']); |
|
120 | + ) { |
|
121 | + unset($vardef['function']); |
|
122 | + } |
|
120 | 123 | |
121 | 124 | if (isset($vardef['name']) && ($vardef['name'] == 'date_modified')) { |
122 | 125 | $vardef['name'] = 'aow_temp_date'; |
@@ -149,8 +152,9 @@ discard block |
||
149 | 152 | } |
150 | 153 | |
151 | 154 | // hack to disable one of the js calls in this control |
152 | - if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) |
|
153 | - $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
|
155 | + if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) { |
|
156 | + $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
|
157 | + } |
|
154 | 158 | |
155 | 159 | |
156 | 160 | |
@@ -186,8 +190,9 @@ discard block |
||
186 | 190 | $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); |
187 | 191 | |
188 | 192 | $fieldlist = array(); |
189 | - if (!isset($focus) || !($focus instanceof SugarBean)) |
|
190 | - require_once($beanFiles[$beanList[$module]]); |
|
193 | + if (!isset($focus) || !($focus instanceof SugarBean)) { |
|
194 | + require_once($beanFiles[$beanList[$module]]); |
|
195 | + } |
|
191 | 196 | $focus = new $beanList[$module]; |
192 | 197 | // create the dropdowns for the parent type fields |
193 | 198 | $vardefFields[$fieldname] = $focus->field_defs[$fieldname]; |
@@ -197,11 +202,13 @@ discard block |
||
197 | 202 | foreach ($vardefFields as $name => $properties) { |
198 | 203 | $fieldlist[$name] = $properties; |
199 | 204 | // fill in enums |
200 | - if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) |
|
201 | - $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
|
205 | + if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) { |
|
206 | + $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
|
207 | + } |
|
202 | 208 | // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings |
203 | - elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) |
|
204 | - $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
|
209 | + elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) { |
|
210 | + $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
|
211 | + } |
|
205 | 212 | } |
206 | 213 | |
207 | 214 | // fill in function return values |
@@ -209,8 +216,9 @@ discard block |
||
209 | 216 | if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') { |
210 | 217 | $function = $fieldlist[$fieldname]['function']['name']; |
211 | 218 | // include various functions required in the various vardefs |
212 | - if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) |
|
213 | - require_once($fieldlist[$fieldname]['function']['include']); |
|
219 | + if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) { |
|
220 | + require_once($fieldlist[$fieldname]['function']['include']); |
|
221 | + } |
|
214 | 222 | $_REQUEST[$fieldname] = $value; |
215 | 223 | $value = $function($focus, $fieldname, $value, $view); |
216 | 224 | |
@@ -308,14 +316,14 @@ discard block |
||
308 | 316 | |
309 | 317 | if ($bean->field_defs[$field]['type'] == "multienum") { |
310 | 318 | $bean->$field = encodeMultienumValue($value); |
311 | - }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
319 | + } else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
312 | 320 | $save_field = $bean->field_defs[$field]['id_name']; |
313 | 321 | $bean->$save_field = $value; |
314 | 322 | if ($bean->field_defs[$field]['type'] == 'parent') { |
315 | 323 | $bean->parent_type = $_REQUEST['parent_type']; |
316 | 324 | $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name |
317 | 325 | } |
318 | - }else{ |
|
326 | + } else{ |
|
319 | 327 | $bean->$field = $value; |
320 | 328 | } |
321 | 329 | |
@@ -450,14 +458,15 @@ discard block |
||
450 | 458 | |
451 | 459 | //To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname |
452 | 460 | $fieldName = 'name';//$vardef['name']; |
453 | - if(!is_null($vardef['rname'])) |
|
454 | - $fieldName = $vardef['rname']; |
|
461 | + if(!is_null($vardef['rname'])) { |
|
462 | + $fieldName = $vardef['rname']; |
|
463 | + } |
|
455 | 464 | |
456 | 465 | if($vardef['ext2']){ |
457 | 466 | |
458 | 467 | $value .= getFieldValueFromModule($fieldName,$vardef['ext2'],$record) . "</a>"; |
459 | 468 | |
460 | - }else if(!empty($vardef['rname'])){ |
|
469 | + } else if(!empty($vardef['rname'])){ |
|
461 | 470 | $value .= getFieldValueFromModule($fieldName,$vardef['module'],$record) . "</a>"; |
462 | 471 | |
463 | 472 | } else { |
@@ -472,8 +481,9 @@ discard block |
||
472 | 481 | function getFieldValueFromModule($fieldname, $module, $id) |
473 | 482 | { |
474 | 483 | //Github bug 880, if the fieldname is null, do no call from bean |
475 | - if(is_null($fieldname)) |
|
476 | - return ''; |
|
484 | + if(is_null($fieldname)) { |
|
485 | + return ''; |
|
486 | + } |
|
477 | 487 | |
478 | 488 | $bean = BeanFactory::getBean($module, $id); |
479 | 489 | if (is_object($bean) && $bean->id != "") { |
@@ -497,7 +507,7 @@ discard block |
||
497 | 507 | |
498 | 508 | if($bean->ACLAccess('EditView')) { |
499 | 509 | return true; |
500 | - }else { |
|
510 | + } else { |
|
501 | 511 | return false; |
502 | 512 | } |
503 | 513 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | 'd.m.Y' => '23.12.2010', |
121 | 121 | 'm.d.Y' => '12.23.2010', |
122 | 122 | ) : $dateFormats, |
123 | - 'dbconfig' => $dbconfig, // this must be set!! |
|
124 | - 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
123 | + 'dbconfig' => $dbconfig, // this must be set!! |
|
124 | + 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
125 | 125 | 'default_action' => empty($default_action) ? 'index' : $default_action, |
126 | 126 | 'default_charset' => empty($default_charset) ? 'UTF-8' : $default_charset, |
127 | 127 | 'default_currency_name' => empty($default_currency_name) ? 'US Dollar' : $default_currency_name, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | 'display_inbound_email_buttons' => empty($display_inbound_email_buttons) ? false : $display_inbound_email_buttons, |
150 | 150 | 'history_max_viewed' => empty($history_max_viewed) ? 50 : $history_max_viewed, |
151 | 151 | 'host_name' => empty($host_name) ? 'localhost' : $host_name, |
152 | - 'import_dir' => $import_dir, // this must be set!! |
|
152 | + 'import_dir' => $import_dir, // this must be set!! |
|
153 | 153 | 'import_max_records_per_file' => 100, |
154 | 154 | 'import_max_records_total_limit' => '', |
155 | 155 | 'languages' => empty($languages) ? array('en_us' => 'English (US)') : $languages, |
@@ -169,21 +169,21 @@ discard block |
||
169 | 169 | ), |
170 | 170 | 'require_accounts' => empty($requireAccounts) ? true : $requireAccounts, |
171 | 171 | 'rss_cache_time' => empty($RSS_CACHE_TIME) ? '10800' : $RSS_CACHE_TIME, |
172 | - 'session_dir' => $session_dir, // this must be set!! |
|
173 | - 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
172 | + 'session_dir' => $session_dir, // this must be set!! |
|
173 | + 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
174 | 174 | 'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable |
175 | 175 | 'showThemePicker' => true, |
176 | 176 | 'sugar_version' => empty($sugar_version) ? 'unknown' : $sugar_version, |
177 | 177 | 'time_formats' => empty($timeFormats) ? array( |
178 | 178 | 'H:i' => '23:00', 'h:ia' => '11:00 pm', 'h:iA' => '11:00PM', |
179 | - 'H.i' => '23.00', 'h.ia' => '11.00 pm', 'h.iA' => '11.00PM', ) : $timeFormats, |
|
180 | - 'tmp_dir' => $tmp_dir, // this must be set!! |
|
179 | + 'H.i' => '23.00', 'h.ia' => '11.00 pm', 'h.iA' => '11.00PM',) : $timeFormats, |
|
180 | + 'tmp_dir' => $tmp_dir, // this must be set!! |
|
181 | 181 | 'translation_string_prefix' => empty($translation_string_prefix) ? false : $translation_string_prefix, |
182 | 182 | 'unique_key' => empty($unique_key) ? md5(create_guid()) : $unique_key, |
183 | 183 | 'upload_badext' => empty($upload_badext) ? array( |
184 | 184 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
185 | - 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', ) : $upload_badext, |
|
186 | - 'upload_dir' => $upload_dir, // this must be set!! |
|
185 | + 'asp', 'cfm', 'js', 'vbs', 'html', 'htm',) : $upload_badext, |
|
186 | + 'upload_dir' => $upload_dir, // this must be set!! |
|
187 | 187 | 'upload_maxsize' => empty($upload_maxsize) ? 30000000 : $upload_maxsize, |
188 | 188 | 'import_max_execution_time' => empty($import_max_execution_time) ? 3600 : $import_max_execution_time, |
189 | 189 | 'lock_homepage' => false, |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | 'date_formats' => array( |
250 | 250 | 'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010', |
251 | 251 | 'Y/m/d' => '2010/12/23', 'm/d/Y' => '12/23/2010', 'd/m/Y' => '23/12/2010', |
252 | - 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010', ), |
|
252 | + 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010',), |
|
253 | 253 | 'name_formats' => array( |
254 | 254 | 's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', 'l, s f' => 'l, s f', |
255 | 255 | 'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s', |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | 'persistent' => true, |
259 | 259 | 'autofree' => false, |
260 | 260 | 'debug' => 0, |
261 | - 'ssl' => false, ), |
|
261 | + 'ssl' => false,), |
|
262 | 262 | 'default_action' => 'index', |
263 | 263 | 'default_charset' => return_session_value_or_default('default_charset', |
264 | 264 | 'UTF-8'), |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | 'sugarbeet' => true, |
322 | 322 | 'time_formats' => array( |
323 | 323 | 'H:i' => '23:00', 'h:ia' => '11:00pm', 'h:iA' => '11:00PM', 'h:i a' => '11:00 pm', 'h:i A' => '11:00 PM', |
324 | - 'H.i' => '23.00', 'h.ia' => '11.00pm', 'h.iA' => '11.00PM', 'h.i a' => '11.00 pm', 'h.i A' => '11.00 PM', ), |
|
324 | + 'H.i' => '23.00', 'h.ia' => '11.00pm', 'h.iA' => '11.00PM', 'h.i a' => '11.00 pm', 'h.i A' => '11.00 PM',), |
|
325 | 325 | 'tracker_max_display_length' => 15, |
326 | 326 | 'translation_string_prefix' => return_session_value_or_default('translation_string_prefix', false), |
327 | 327 | 'upload_badext' => array( |
328 | 328 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
329 | - 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml', ), |
|
329 | + 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml',), |
|
330 | 330 | 'upload_maxsize' => 30000000, |
331 | 331 | 'import_max_execution_time' => 3600, |
332 | 332 | // 'use_php_code_json' => returnPhpJsonStatus(), |
@@ -164,23 +164,23 @@ |
||
164 | 164 | $meeting->parent_name = 'Account'; |
165 | 165 | |
166 | 166 | $expected = array( |
167 | - 'DELETED' => 0, |
|
168 | - 'PARENT_TYPE' => 'Accounts', |
|
169 | - 'STATUS' => 'Planned', |
|
170 | - 'TYPE' => 'Sugar', |
|
171 | - 'REMINDER_TIME' => '-1', |
|
172 | - 'EMAIL_REMINDER_TIME' => '-1', |
|
173 | - 'EMAIL_REMINDER_SENT' => '0', |
|
174 | - 'SEQUENCE' => '0', |
|
175 | - 'CONTACT_NAME' => 'test', |
|
176 | - 'PARENT_NAME' => '', |
|
177 | - 'CONTACT_ID' => 1, |
|
178 | - 'REPEAT_INTERVAL' => '1', |
|
179 | - 'PARENT_MODULE' => 'Accounts', |
|
180 | - 'SET_COMPLETE' => '<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Meetings","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=fqXdFZ_r6FC1K7P_Fy3mVw" border=\'0\' alt="Close" /></a>', |
|
181 | - 'DATE_START' => '<font class=\'overdueTask\'></font>', |
|
182 | - 'REMINDER_CHECKED' => false, |
|
183 | - 'EMAIL_REMINDER_CHECKED' => false, |
|
167 | + 'DELETED' => 0, |
|
168 | + 'PARENT_TYPE' => 'Accounts', |
|
169 | + 'STATUS' => 'Planned', |
|
170 | + 'TYPE' => 'Sugar', |
|
171 | + 'REMINDER_TIME' => '-1', |
|
172 | + 'EMAIL_REMINDER_TIME' => '-1', |
|
173 | + 'EMAIL_REMINDER_SENT' => '0', |
|
174 | + 'SEQUENCE' => '0', |
|
175 | + 'CONTACT_NAME' => 'test', |
|
176 | + 'PARENT_NAME' => '', |
|
177 | + 'CONTACT_ID' => 1, |
|
178 | + 'REPEAT_INTERVAL' => '1', |
|
179 | + 'PARENT_MODULE' => 'Accounts', |
|
180 | + 'SET_COMPLETE' => '<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Meetings","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=fqXdFZ_r6FC1K7P_Fy3mVw" border=\'0\' alt="Close" /></a>', |
|
181 | + 'DATE_START' => '<font class=\'overdueTask\'></font>', |
|
182 | + 'REMINDER_CHECKED' => false, |
|
183 | + 'EMAIL_REMINDER_CHECKED' => false, |
|
184 | 184 | ); |
185 | 185 | |
186 | 186 | $actual = $meeting->get_list_view_data(); |
@@ -145,9 +145,9 @@ |
||
145 | 145 | 'EMAIL_REMINDER_SENT' => '0', |
146 | 146 | 'REPEAT_INTERVAL' => '1', |
147 | 147 | 'SET_COMPLETE' => '~' |
148 | - .preg_quote('<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Calls","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=') |
|
149 | - .'[\w-]+' |
|
150 | - .preg_quote('" border=\'0\' alt="Close" /></a>').'~', |
|
148 | + .preg_quote('<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Calls","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=') |
|
149 | + .'[\w-]+' |
|
150 | + .preg_quote('" border=\'0\' alt="Close" /></a>').'~', |
|
151 | 151 | 'DATE_START' => '<font class=\'overdueTask\'></font>', |
152 | 152 | 'CONTACT_ID' => null, |
153 | 153 | 'CONTACT_NAME' => null, |
@@ -40,150 +40,150 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | class Meeting extends SugarBean { |
43 | - // Stored fields |
|
44 | - var $id; |
|
45 | - var $date_entered; |
|
46 | - var $date_modified; |
|
47 | - var $assigned_user_id; |
|
48 | - var $modified_user_id; |
|
49 | - var $created_by; |
|
50 | - var $created_by_name; |
|
51 | - var $modified_by_name; |
|
52 | - var $description; |
|
53 | - var $name; |
|
54 | - var $location; |
|
55 | - var $status; |
|
56 | - var $type; |
|
57 | - var $date_start; |
|
58 | - var $time_start; |
|
59 | - var $date_end; |
|
60 | - var $duration_hours; |
|
61 | - var $duration_minutes; |
|
62 | - var $time_meridiem; |
|
63 | - var $parent_type; |
|
64 | - var $parent_type_options; |
|
65 | - var $parent_id; |
|
66 | - var $field_name_map; |
|
67 | - var $contact_id; |
|
68 | - var $user_id; |
|
69 | - var $meeting_id; |
|
70 | - var $reminder_time; |
|
71 | - var $reminder_checked; |
|
72 | - var $email_reminder_time; |
|
73 | - var $email_reminder_checked; |
|
74 | - var $email_reminder_sent; |
|
75 | - var $required; |
|
76 | - var $accept_status; |
|
77 | - var $parent_name; |
|
78 | - var $contact_name; |
|
79 | - var $contact_phone; |
|
80 | - var $contact_email; |
|
81 | - var $account_id; |
|
82 | - var $opportunity_id; |
|
83 | - var $case_id; |
|
84 | - var $assigned_user_name; |
|
85 | - var $outlook_id; |
|
86 | - var $sequence; |
|
87 | - var $syncing = false; |
|
88 | - var $recurring_source; |
|
89 | - |
|
90 | - var $update_vcal = true; |
|
91 | - var $contacts_arr; |
|
92 | - var $users_arr; |
|
93 | - var $meetings_arr; |
|
94 | - // when assoc w/ a user/contact: |
|
95 | - var $minutes_value_default = 15; |
|
96 | - var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45'); |
|
97 | - var $table_name = "meetings"; |
|
98 | - var $rel_users_table = "meetings_users"; |
|
99 | - var $rel_contacts_table = "meetings_contacts"; |
|
100 | - var $rel_leads_table = "meetings_leads"; |
|
101 | - var $module_dir = "Meetings"; |
|
102 | - var $object_name = "Meeting"; |
|
103 | - |
|
104 | - var $importable = true; |
|
105 | - // This is used to retrieve related fields from form posts. |
|
106 | - var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name', 'accept_status'); |
|
107 | - var $relationship_fields = array('account_id'=>'accounts','opportunity_id'=>'opportunity','case_id'=>'case', |
|
108 | - 'assigned_user_id'=>'users','contact_id'=>'contacts', 'user_id'=>'users', 'meeting_id'=>'meetings'); |
|
109 | - // so you can run get_users() twice and run query only once |
|
110 | - var $cached_get_users = null; |
|
111 | - var $new_schema = true; |
|
43 | + // Stored fields |
|
44 | + var $id; |
|
45 | + var $date_entered; |
|
46 | + var $date_modified; |
|
47 | + var $assigned_user_id; |
|
48 | + var $modified_user_id; |
|
49 | + var $created_by; |
|
50 | + var $created_by_name; |
|
51 | + var $modified_by_name; |
|
52 | + var $description; |
|
53 | + var $name; |
|
54 | + var $location; |
|
55 | + var $status; |
|
56 | + var $type; |
|
57 | + var $date_start; |
|
58 | + var $time_start; |
|
59 | + var $date_end; |
|
60 | + var $duration_hours; |
|
61 | + var $duration_minutes; |
|
62 | + var $time_meridiem; |
|
63 | + var $parent_type; |
|
64 | + var $parent_type_options; |
|
65 | + var $parent_id; |
|
66 | + var $field_name_map; |
|
67 | + var $contact_id; |
|
68 | + var $user_id; |
|
69 | + var $meeting_id; |
|
70 | + var $reminder_time; |
|
71 | + var $reminder_checked; |
|
72 | + var $email_reminder_time; |
|
73 | + var $email_reminder_checked; |
|
74 | + var $email_reminder_sent; |
|
75 | + var $required; |
|
76 | + var $accept_status; |
|
77 | + var $parent_name; |
|
78 | + var $contact_name; |
|
79 | + var $contact_phone; |
|
80 | + var $contact_email; |
|
81 | + var $account_id; |
|
82 | + var $opportunity_id; |
|
83 | + var $case_id; |
|
84 | + var $assigned_user_name; |
|
85 | + var $outlook_id; |
|
86 | + var $sequence; |
|
87 | + var $syncing = false; |
|
88 | + var $recurring_source; |
|
89 | + |
|
90 | + var $update_vcal = true; |
|
91 | + var $contacts_arr; |
|
92 | + var $users_arr; |
|
93 | + var $meetings_arr; |
|
94 | + // when assoc w/ a user/contact: |
|
95 | + var $minutes_value_default = 15; |
|
96 | + var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45'); |
|
97 | + var $table_name = "meetings"; |
|
98 | + var $rel_users_table = "meetings_users"; |
|
99 | + var $rel_contacts_table = "meetings_contacts"; |
|
100 | + var $rel_leads_table = "meetings_leads"; |
|
101 | + var $module_dir = "Meetings"; |
|
102 | + var $object_name = "Meeting"; |
|
103 | + |
|
104 | + var $importable = true; |
|
105 | + // This is used to retrieve related fields from form posts. |
|
106 | + var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name', 'accept_status'); |
|
107 | + var $relationship_fields = array('account_id'=>'accounts','opportunity_id'=>'opportunity','case_id'=>'case', |
|
108 | + 'assigned_user_id'=>'users','contact_id'=>'contacts', 'user_id'=>'users', 'meeting_id'=>'meetings'); |
|
109 | + // so you can run get_users() twice and run query only once |
|
110 | + var $cached_get_users = null; |
|
111 | + var $new_schema = true; |
|
112 | 112 | var $date_changed = false; |
113 | 113 | |
114 | - /** |
|
115 | - * sole constructor |
|
116 | - */ |
|
117 | - public function __construct() { |
|
118 | - parent::__construct(); |
|
119 | - $this->setupCustomFields('Meetings'); |
|
120 | - foreach($this->field_defs as $field) { |
|
121 | - $this->field_name_map[$field['name']] = $field; |
|
122 | - } |
|
114 | + /** |
|
115 | + * sole constructor |
|
116 | + */ |
|
117 | + public function __construct() { |
|
118 | + parent::__construct(); |
|
119 | + $this->setupCustomFields('Meetings'); |
|
120 | + foreach($this->field_defs as $field) { |
|
121 | + $this->field_name_map[$field['name']] = $field; |
|
122 | + } |
|
123 | 123 | // $this->fill_in_additional_detail_fields(); |
124 | 124 | if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) { |
125 | 125 | $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
126 | 126 | } |
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @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 |
|
131 | - */ |
|
132 | - public function Meeting(){ |
|
133 | - $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
134 | - if(isset($GLOBALS['log'])) { |
|
135 | - $GLOBALS['log']->deprecated($deprecatedMessage); |
|
136 | - } |
|
137 | - else { |
|
138 | - trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
139 | - } |
|
140 | - self::__construct(); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Disable edit if meeting is recurring and source is not Sugar. It should be edited only from Outlook. |
|
145 | - * @param $view string |
|
146 | - * @param $is_owner bool |
|
147 | - */ |
|
148 | - function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
149 | - // don't check if meeting is being synced from Outlook |
|
150 | - if($this->syncing == false){ |
|
151 | - $view = strtolower($view); |
|
152 | - switch($view){ |
|
153 | - case 'edit': |
|
154 | - case 'save': |
|
155 | - case 'editview': |
|
156 | - case 'delete': |
|
157 | - if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
158 | - return false; |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - return parent::ACLAccess($view,$is_owner,$in_group); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Stub for integration |
|
167 | - * @return bool |
|
168 | - */ |
|
169 | - function hasIntegratedMeeting() { |
|
170 | - return false; |
|
171 | - } |
|
172 | - |
|
173 | - // save date_end by calculating user input |
|
174 | - // this is for calendar |
|
175 | - function save($check_notify = FALSE) { |
|
176 | - global $timedate; |
|
177 | - global $current_user; |
|
178 | - |
|
179 | - global $disable_date_format; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @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 |
|
131 | + */ |
|
132 | + public function Meeting(){ |
|
133 | + $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
134 | + if(isset($GLOBALS['log'])) { |
|
135 | + $GLOBALS['log']->deprecated($deprecatedMessage); |
|
136 | + } |
|
137 | + else { |
|
138 | + trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
139 | + } |
|
140 | + self::__construct(); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Disable edit if meeting is recurring and source is not Sugar. It should be edited only from Outlook. |
|
145 | + * @param $view string |
|
146 | + * @param $is_owner bool |
|
147 | + */ |
|
148 | + function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
149 | + // don't check if meeting is being synced from Outlook |
|
150 | + if($this->syncing == false){ |
|
151 | + $view = strtolower($view); |
|
152 | + switch($view){ |
|
153 | + case 'edit': |
|
154 | + case 'save': |
|
155 | + case 'editview': |
|
156 | + case 'delete': |
|
157 | + if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
158 | + return false; |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + return parent::ACLAccess($view,$is_owner,$in_group); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Stub for integration |
|
167 | + * @return bool |
|
168 | + */ |
|
169 | + function hasIntegratedMeeting() { |
|
170 | + return false; |
|
171 | + } |
|
172 | + |
|
173 | + // save date_end by calculating user input |
|
174 | + // this is for calendar |
|
175 | + function save($check_notify = FALSE) { |
|
176 | + global $timedate; |
|
177 | + global $current_user; |
|
178 | + |
|
179 | + global $disable_date_format; |
|
180 | 180 | |
181 | 181 | if(isset($this->date_start)) |
182 | 182 | { |
183 | 183 | $td = $timedate->fromDb($this->date_start); |
184 | 184 | if(!$td){ |
185 | - $this->date_start = $timedate->to_db($this->date_start); |
|
186 | - $td = $timedate->fromDb($this->date_start); |
|
185 | + $this->date_start = $timedate->to_db($this->date_start); |
|
186 | + $td = $timedate->fromDb($this->date_start); |
|
187 | 187 | } |
188 | 188 | if($td) |
189 | 189 | { |
@@ -199,30 +199,30 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - $check_notify =(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') ? true : false; |
|
203 | - if(empty($_REQUEST['send_invites'])) { |
|
204 | - if(!empty($this->id)) { |
|
205 | - $old_record = new Meeting(); |
|
206 | - $old_record->retrieve($this->id); |
|
207 | - $old_assigned_user_id = $old_record->assigned_user_id; |
|
208 | - } |
|
209 | - if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){ |
|
210 | - $this->special_notification = true; |
|
211 | - $check_notify = true; |
|
202 | + $check_notify =(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') ? true : false; |
|
203 | + if(empty($_REQUEST['send_invites'])) { |
|
204 | + if(!empty($this->id)) { |
|
205 | + $old_record = new Meeting(); |
|
206 | + $old_record->retrieve($this->id); |
|
207 | + $old_assigned_user_id = $old_record->assigned_user_id; |
|
208 | + } |
|
209 | + if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){ |
|
210 | + $this->special_notification = true; |
|
211 | + $check_notify = true; |
|
212 | 212 | if(isset($_REQUEST['assigned_user_name'])) { |
213 | 213 | $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; |
214 | 214 | } |
215 | - } |
|
216 | - } |
|
217 | - /*nsingh 7/3/08 commenting out as bug #20814 is invalid |
|
215 | + } |
|
216 | + } |
|
217 | + /*nsingh 7/3/08 commenting out as bug #20814 is invalid |
|
218 | 218 | if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ |
219 | 219 | $this->reminder_checked = '1'; |
220 | 220 | $this->reminder_time = $current_user->getPreference('reminder_time'); |
221 | 221 | }*/ |
222 | 222 | |
223 | - // prevent a mass mailing for recurring meetings created in Calendar module |
|
224 | - if(empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) |
|
225 | - $check_notify = false; |
|
223 | + // prevent a mass mailing for recurring meetings created in Calendar module |
|
224 | + if(empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) |
|
225 | + $check_notify = false; |
|
226 | 226 | |
227 | 227 | if (empty($this->status) ) { |
228 | 228 | $this->status = $this->getDefaultStatus(); |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | if (empty($this->type)) { |
246 | - $this->type = 'Sugar'; |
|
247 | - } |
|
246 | + $this->type = 'Sugar'; |
|
247 | + } |
|
248 | 248 | |
249 | 249 | if ( isset($api) && is_a($api,'WebMeeting') && empty($this->in_relationship_update) ) { |
250 | 250 | // Make sure the API initialized and it supports Web Meetings |
@@ -272,175 +272,175 @@ discard block |
||
272 | 272 | $api->logoff(); |
273 | 273 | } |
274 | 274 | |
275 | - $return_id = parent::save($check_notify); |
|
275 | + $return_id = parent::save($check_notify); |
|
276 | 276 | |
277 | - if($this->update_vcal) { |
|
278 | - vCal::cache_sugar_vcal($current_user); |
|
279 | - } |
|
277 | + if($this->update_vcal) { |
|
278 | + vCal::cache_sugar_vcal($current_user); |
|
279 | + } |
|
280 | 280 | |
281 | - if(isset($_REQUEST['reminders_data'])) { |
|
282 | - Reminder::saveRemindersDataJson('Meetings', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
|
283 | - } |
|
281 | + if(isset($_REQUEST['reminders_data'])) { |
|
282 | + Reminder::saveRemindersDataJson('Meetings', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
|
283 | + } |
|
284 | 284 | |
285 | 285 | |
286 | - return $return_id; |
|
287 | - } |
|
286 | + return $return_id; |
|
287 | + } |
|
288 | 288 | |
289 | - // this is for calendar |
|
290 | - function mark_deleted($id) { |
|
289 | + // this is for calendar |
|
290 | + function mark_deleted($id) { |
|
291 | 291 | |
292 | - require_once("modules/Calendar/CalendarUtils.php"); |
|
293 | - CalendarUtils::correctRecurrences($this, $id); |
|
292 | + require_once("modules/Calendar/CalendarUtils.php"); |
|
293 | + CalendarUtils::correctRecurrences($this, $id); |
|
294 | 294 | |
295 | - global $current_user; |
|
295 | + global $current_user; |
|
296 | 296 | |
297 | - parent::mark_deleted($id); |
|
297 | + parent::mark_deleted($id); |
|
298 | 298 | |
299 | - if($this->update_vcal) { |
|
300 | - vCal::cache_sugar_vcal($current_user); |
|
301 | - } |
|
302 | - } |
|
299 | + if($this->update_vcal) { |
|
300 | + vCal::cache_sugar_vcal($current_user); |
|
301 | + } |
|
302 | + } |
|
303 | 303 | |
304 | - function get_summary_text() { |
|
305 | - return "$this->name"; |
|
306 | - } |
|
304 | + function get_summary_text() { |
|
305 | + return "$this->name"; |
|
306 | + } |
|
307 | 307 | |
308 | 308 | function create_export_query($order_by, $where, $relate_link_join='') |
309 | 309 | { |
310 | 310 | $custom_join = $this->getCustomJoin(true, true, $where); |
311 | 311 | $custom_join['join'] .= $relate_link_join; |
312 | - $contact_required = stristr($where, "contacts"); |
|
312 | + $contact_required = stristr($where, "contacts"); |
|
313 | 313 | |
314 | - if($contact_required) { |
|
315 | - $query = "SELECT meetings.*, contacts.first_name, contacts.last_name, contacts.assigned_user_id contact_name_owner, users.user_name as assigned_user_name "; |
|
314 | + if($contact_required) { |
|
315 | + $query = "SELECT meetings.*, contacts.first_name, contacts.last_name, contacts.assigned_user_id contact_name_owner, users.user_name as assigned_user_name "; |
|
316 | 316 | $query .= $custom_join['select']; |
317 | - $query .= " FROM contacts, meetings, meetings_contacts "; |
|
318 | - $where_auto = " meetings_contacts.contact_id = contacts.id AND meetings_contacts.meeting_id = meetings.id AND meetings.deleted=0 AND contacts.deleted=0"; |
|
319 | - } else { |
|
320 | - $query = 'SELECT meetings.*, users.user_name as assigned_user_name '; |
|
317 | + $query .= " FROM contacts, meetings, meetings_contacts "; |
|
318 | + $where_auto = " meetings_contacts.contact_id = contacts.id AND meetings_contacts.meeting_id = meetings.id AND meetings.deleted=0 AND contacts.deleted=0"; |
|
319 | + } else { |
|
320 | + $query = 'SELECT meetings.*, users.user_name as assigned_user_name '; |
|
321 | 321 | $query .= $custom_join['select']; |
322 | - $query .= ' FROM meetings '; |
|
323 | - $where_auto = "meetings.deleted=0"; |
|
324 | - } |
|
325 | - $query .= " LEFT JOIN users ON meetings.assigned_user_id=users.id "; |
|
322 | + $query .= ' FROM meetings '; |
|
323 | + $where_auto = "meetings.deleted=0"; |
|
324 | + } |
|
325 | + $query .= " LEFT JOIN users ON meetings.assigned_user_id=users.id "; |
|
326 | 326 | |
327 | 327 | $query .= $custom_join['join']; |
328 | 328 | |
329 | - if($where != "") |
|
330 | - $query .= " where $where AND ".$where_auto; |
|
331 | - else |
|
332 | - $query .= " where ".$where_auto; |
|
329 | + if($where != "") |
|
330 | + $query .= " where $where AND ".$where_auto; |
|
331 | + else |
|
332 | + $query .= " where ".$where_auto; |
|
333 | 333 | |
334 | 334 | $order_by = $this->process_order_by($order_by); |
335 | 335 | if (!empty($order_by)) { |
336 | 336 | $query .= ' ORDER BY ' . $order_by; |
337 | 337 | } |
338 | 338 | |
339 | - return $query; |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - |
|
344 | - function fill_in_additional_detail_fields() { |
|
345 | - global $locale; |
|
346 | - // Fill in the assigned_user_name |
|
347 | - $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); |
|
348 | - |
|
349 | - if (!empty($this->contact_id)) { |
|
350 | - $query = "SELECT first_name, last_name FROM contacts "; |
|
351 | - $query .= "WHERE id='$this->contact_id' AND deleted=0"; |
|
352 | - $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: "); |
|
339 | + return $query; |
|
340 | + } |
|
353 | 341 | |
354 | - // Get the contact name. |
|
355 | - $row = $this->db->fetchByAssoc($result); |
|
356 | - $GLOBALS['log']->info("additional call fields $query"); |
|
357 | - if($row != null) |
|
358 | - { |
|
359 | - $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', ''); |
|
360 | - $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name"); |
|
361 | - $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id"); |
|
362 | - } |
|
363 | - } |
|
364 | 342 | |
365 | 343 | |
344 | + function fill_in_additional_detail_fields() { |
|
345 | + global $locale; |
|
346 | + // Fill in the assigned_user_name |
|
347 | + $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); |
|
366 | 348 | |
367 | - $this->created_by_name = get_assigned_user_name($this->created_by); |
|
368 | - $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
|
369 | - $this->fill_in_additional_parent_fields(); |
|
349 | + if (!empty($this->contact_id)) { |
|
350 | + $query = "SELECT first_name, last_name FROM contacts "; |
|
351 | + $query .= "WHERE id='$this->contact_id' AND deleted=0"; |
|
352 | + $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: "); |
|
370 | 353 | |
371 | - if (!isset($this->time_hour_start)) { |
|
372 | - $this->time_start_hour = intval(substr($this->time_start, 0, 2)); |
|
373 | - } //if-else |
|
354 | + // Get the contact name. |
|
355 | + $row = $this->db->fetchByAssoc($result); |
|
356 | + $GLOBALS['log']->info("additional call fields $query"); |
|
357 | + if($row != null) |
|
358 | + { |
|
359 | + $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', ''); |
|
360 | + $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name"); |
|
361 | + $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id"); |
|
362 | + } |
|
363 | + } |
|
374 | 364 | |
375 | - if (isset($this->time_minute_start)) { |
|
376 | - $time_start_minutes = $this->time_minute_start; |
|
377 | - } else { |
|
378 | - $time_start_minutes = substr($this->time_start, 3, 5); |
|
379 | - if ($time_start_minutes > 0 && $time_start_minutes < 15) { |
|
380 | - $time_start_minutes = "15"; |
|
381 | - } else if ($time_start_minutes > 15 && $time_start_minutes < 30) { |
|
382 | - $time_start_minutes = "30"; |
|
383 | - } else if ($time_start_minutes > 30 && $time_start_minutes < 45) { |
|
384 | - $time_start_minutes = "45"; |
|
385 | - } else if ($time_start_minutes > 45) { |
|
386 | - $this->time_start_hour += 1; |
|
387 | - $time_start_minutes = "00"; |
|
388 | - } //if-else |
|
389 | - } //if-else |
|
390 | 365 | |
391 | 366 | |
392 | - if (isset($this->time_hour_start)) { |
|
393 | - $time_start_hour = $this->time_hour_start; |
|
394 | - } else { |
|
395 | - $time_start_hour = intval(substr($this->time_start, 0, 2)); |
|
396 | - } |
|
367 | + $this->created_by_name = get_assigned_user_name($this->created_by); |
|
368 | + $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
|
369 | + $this->fill_in_additional_parent_fields(); |
|
370 | + |
|
371 | + if (!isset($this->time_hour_start)) { |
|
372 | + $this->time_start_hour = intval(substr($this->time_start, 0, 2)); |
|
373 | + } //if-else |
|
374 | + |
|
375 | + if (isset($this->time_minute_start)) { |
|
376 | + $time_start_minutes = $this->time_minute_start; |
|
377 | + } else { |
|
378 | + $time_start_minutes = substr($this->time_start, 3, 5); |
|
379 | + if ($time_start_minutes > 0 && $time_start_minutes < 15) { |
|
380 | + $time_start_minutes = "15"; |
|
381 | + } else if ($time_start_minutes > 15 && $time_start_minutes < 30) { |
|
382 | + $time_start_minutes = "30"; |
|
383 | + } else if ($time_start_minutes > 30 && $time_start_minutes < 45) { |
|
384 | + $time_start_minutes = "45"; |
|
385 | + } else if ($time_start_minutes > 45) { |
|
386 | + $this->time_start_hour += 1; |
|
387 | + $time_start_minutes = "00"; |
|
388 | + } //if-else |
|
389 | + } //if-else |
|
390 | + |
|
391 | + |
|
392 | + if (isset($this->time_hour_start)) { |
|
393 | + $time_start_hour = $this->time_hour_start; |
|
394 | + } else { |
|
395 | + $time_start_hour = intval(substr($this->time_start, 0, 2)); |
|
396 | + } |
|
397 | 397 | |
398 | - global $timedate; |
|
398 | + global $timedate; |
|
399 | 399 | $this->time_meridiem = $timedate->AMPMMenu('', $this->time_start, 'onchange="SugarWidgetScheduler.update_time();"'); |
400 | - $hours_arr = array (); |
|
401 | - $num_of_hours = 13; |
|
402 | - $start_at = 1; |
|
403 | - |
|
404 | - if (empty ($time_meridiem)) { |
|
405 | - $num_of_hours = 24; |
|
406 | - $start_at = 0; |
|
407 | - } //if |
|
408 | - |
|
409 | - for ($i = $start_at; $i < $num_of_hours; $i ++) { |
|
410 | - $i = $i.""; |
|
411 | - if (strlen($i) == 1) { |
|
412 | - $i = "0".$i; |
|
413 | - } |
|
414 | - $hours_arr[$i] = $i; |
|
415 | - } //for |
|
400 | + $hours_arr = array (); |
|
401 | + $num_of_hours = 13; |
|
402 | + $start_at = 1; |
|
403 | + |
|
404 | + if (empty ($time_meridiem)) { |
|
405 | + $num_of_hours = 24; |
|
406 | + $start_at = 0; |
|
407 | + } //if |
|
408 | + |
|
409 | + for ($i = $start_at; $i < $num_of_hours; $i ++) { |
|
410 | + $i = $i.""; |
|
411 | + if (strlen($i) == 1) { |
|
412 | + $i = "0".$i; |
|
413 | + } |
|
414 | + $hours_arr[$i] = $i; |
|
415 | + } //for |
|
416 | 416 | |
417 | 417 | if (!isset($this->duration_minutes)) { |
418 | - $this->duration_minutes = $this->minutes_value_default; |
|
419 | - } |
|
418 | + $this->duration_minutes = $this->minutes_value_default; |
|
419 | + } |
|
420 | 420 | |
421 | 421 | //setting default date and time |
422 | - if (is_null($this->date_start)) |
|
423 | - $this->date_start = $timedate->now(); |
|
424 | - if (is_null($this->time_start)) |
|
425 | - $this->time_start = $timedate->to_display_time(TimeDate::getInstance()->nowDb(), true); |
|
426 | - if (is_null($this->duration_hours)) { |
|
427 | - $this->duration_hours = "0"; |
|
428 | - } |
|
429 | - if (is_null($this->duration_minutes)) |
|
430 | - $this->duration_minutes = "1"; |
|
431 | - |
|
432 | - if(empty($this->id) && !empty($_REQUEST['date_start'])){ |
|
433 | - $this->date_start = $_REQUEST['date_start']; |
|
434 | - } |
|
422 | + if (is_null($this->date_start)) |
|
423 | + $this->date_start = $timedate->now(); |
|
424 | + if (is_null($this->time_start)) |
|
425 | + $this->time_start = $timedate->to_display_time(TimeDate::getInstance()->nowDb(), true); |
|
426 | + if (is_null($this->duration_hours)) { |
|
427 | + $this->duration_hours = "0"; |
|
428 | + } |
|
429 | + if (is_null($this->duration_minutes)) |
|
430 | + $this->duration_minutes = "1"; |
|
431 | + |
|
432 | + if(empty($this->id) && !empty($_REQUEST['date_start'])){ |
|
433 | + $this->date_start = $_REQUEST['date_start']; |
|
434 | + } |
|
435 | 435 | if(!empty($this->date_start)) |
436 | 436 | { |
437 | 437 | $td = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(),$this->date_start); |
438 | 438 | if (!empty($td)) |
439 | 439 | { |
440 | - if (!empty($this->duration_hours) && $this->duration_hours != '') |
|
440 | + if (!empty($this->duration_hours) && $this->duration_hours != '') |
|
441 | 441 | { |
442 | - $td = $td->modify("+{$this->duration_hours} hours"); |
|
443 | - } |
|
442 | + $td = $td->modify("+{$this->duration_hours} hours"); |
|
443 | + } |
|
444 | 444 | if (!empty($this->duration_minutes) && $this->duration_minutes != '') |
445 | 445 | { |
446 | 446 | $td = $td->modify("+{$this->duration_minutes} mins"); |
@@ -451,77 +451,77 @@ discard block |
||
451 | 451 | { |
452 | 452 | $GLOBALS['log']->fatal("Meeting::save: Bad date {$this->date_start} for format ".$GLOBALS['timedate']->get_date_time_format()); |
453 | 453 | } |
454 | - } |
|
455 | - |
|
456 | - global $app_list_strings; |
|
457 | - $parent_types = $app_list_strings['record_type_display']; |
|
458 | - $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
459 | - foreach($disabled_parent_types as $disabled_parent_type){ |
|
460 | - if($disabled_parent_type != $this->parent_type){ |
|
461 | - unset($parent_types[$disabled_parent_type]); |
|
462 | - } |
|
463 | - } |
|
464 | - |
|
465 | - $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type); |
|
466 | - if (empty($this->reminder_time)) { |
|
467 | - $this->reminder_time = -1; |
|
468 | - } |
|
469 | - |
|
470 | - if ( empty($this->id) ) { |
|
471 | - $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
|
472 | - if ( isset($reminder_t) ) |
|
473 | - $this->reminder_time = $reminder_t; |
|
474 | - } |
|
475 | - $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
|
476 | - |
|
477 | - if (empty($this->email_reminder_time)) { |
|
478 | - $this->email_reminder_time = -1; |
|
479 | - } |
|
480 | - if(empty($this->id)){ |
|
481 | - $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
|
482 | - if(isset($reminder_t)) |
|
483 | - $this->email_reminder_time = $reminder_t; |
|
484 | - } |
|
485 | - $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
|
486 | - |
|
487 | - if (isset ($_REQUEST['parent_type']) && empty($this->parent_type)) { |
|
488 | - $this->parent_type = $_REQUEST['parent_type']; |
|
489 | - } elseif (is_null($this->parent_type)) { |
|
490 | - $this->parent_type = $app_list_strings['record_type_default_key']; |
|
491 | - } |
|
492 | - |
|
493 | - } |
|
494 | - |
|
495 | - function get_list_view_data() { |
|
496 | - $meeting_fields = $this->get_list_view_array(); |
|
497 | - |
|
498 | - global $app_list_strings, $focus, $action, $currentModule; |
|
499 | - if(isset($this->parent_type)) |
|
500 | - $meeting_fields['PARENT_MODULE'] = $this->parent_type; |
|
501 | - if($this->status == "Planned") { |
|
502 | - //cn: added this if() to deal with sequential Closes in Meetings. this is a hack to a hack(formbase.php->handleRedirect) |
|
503 | - if(empty($action)) |
|
504 | - $action = "index"; |
|
454 | + } |
|
455 | + |
|
456 | + global $app_list_strings; |
|
457 | + $parent_types = $app_list_strings['record_type_display']; |
|
458 | + $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
459 | + foreach($disabled_parent_types as $disabled_parent_type){ |
|
460 | + if($disabled_parent_type != $this->parent_type){ |
|
461 | + unset($parent_types[$disabled_parent_type]); |
|
462 | + } |
|
463 | + } |
|
464 | + |
|
465 | + $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type); |
|
466 | + if (empty($this->reminder_time)) { |
|
467 | + $this->reminder_time = -1; |
|
468 | + } |
|
469 | + |
|
470 | + if ( empty($this->id) ) { |
|
471 | + $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
|
472 | + if ( isset($reminder_t) ) |
|
473 | + $this->reminder_time = $reminder_t; |
|
474 | + } |
|
475 | + $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
|
476 | + |
|
477 | + if (empty($this->email_reminder_time)) { |
|
478 | + $this->email_reminder_time = -1; |
|
479 | + } |
|
480 | + if(empty($this->id)){ |
|
481 | + $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
|
482 | + if(isset($reminder_t)) |
|
483 | + $this->email_reminder_time = $reminder_t; |
|
484 | + } |
|
485 | + $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
|
486 | + |
|
487 | + if (isset ($_REQUEST['parent_type']) && empty($this->parent_type)) { |
|
488 | + $this->parent_type = $_REQUEST['parent_type']; |
|
489 | + } elseif (is_null($this->parent_type)) { |
|
490 | + $this->parent_type = $app_list_strings['record_type_default_key']; |
|
491 | + } |
|
492 | + |
|
493 | + } |
|
494 | + |
|
495 | + function get_list_view_data() { |
|
496 | + $meeting_fields = $this->get_list_view_array(); |
|
497 | + |
|
498 | + global $app_list_strings, $focus, $action, $currentModule; |
|
499 | + if(isset($this->parent_type)) |
|
500 | + $meeting_fields['PARENT_MODULE'] = $this->parent_type; |
|
501 | + if($this->status == "Planned") { |
|
502 | + //cn: added this if() to deal with sequential Closes in Meetings. this is a hack to a hack(formbase.php->handleRedirect) |
|
503 | + if(empty($action)) |
|
504 | + $action = "index"; |
|
505 | 505 | $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>"; |
506 | - if ($this->ACLAccess('edit')) { |
|
506 | + if ($this->ACLAccess('edit')) { |
|
507 | 507 | $meeting_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline"," border='0'",null,null,'.gif',translate('LBL_CLOSEINLINE'))."</a>"; |
508 | 508 | } else { |
509 | 509 | $meeting_fields['SET_COMPLETE'] = ''; |
510 | 510 | } |
511 | - } |
|
512 | - global $timedate; |
|
513 | - $today = $timedate->nowDb(); |
|
514 | - $nextday = $timedate->asDbDate($timedate->getNow()->get("+1 day")); |
|
515 | - $mergeTime = $meeting_fields['DATE_START']; //$timedate->merge_date_time($meeting_fields['DATE_START'], $meeting_fields['TIME_START']); |
|
516 | - $date_db = $timedate->to_db($mergeTime); |
|
517 | - if($date_db < $today ) { |
|
518 | - $meeting_fields['DATE_START']= "<font class='overdueTask'>".$meeting_fields['DATE_START']."</font>"; |
|
519 | - }else if($date_db < $nextday) { |
|
520 | - $meeting_fields['DATE_START'] = "<font class='todaysTask'>".$meeting_fields['DATE_START']."</font>"; |
|
521 | - } else { |
|
522 | - $meeting_fields['DATE_START'] = "<font class='futureTask'>".$meeting_fields['DATE_START']."</font>"; |
|
523 | - } |
|
524 | - $this->fill_in_additional_detail_fields(); |
|
511 | + } |
|
512 | + global $timedate; |
|
513 | + $today = $timedate->nowDb(); |
|
514 | + $nextday = $timedate->asDbDate($timedate->getNow()->get("+1 day")); |
|
515 | + $mergeTime = $meeting_fields['DATE_START']; //$timedate->merge_date_time($meeting_fields['DATE_START'], $meeting_fields['TIME_START']); |
|
516 | + $date_db = $timedate->to_db($mergeTime); |
|
517 | + if($date_db < $today ) { |
|
518 | + $meeting_fields['DATE_START']= "<font class='overdueTask'>".$meeting_fields['DATE_START']."</font>"; |
|
519 | + }else if($date_db < $nextday) { |
|
520 | + $meeting_fields['DATE_START'] = "<font class='todaysTask'>".$meeting_fields['DATE_START']."</font>"; |
|
521 | + } else { |
|
522 | + $meeting_fields['DATE_START'] = "<font class='futureTask'>".$meeting_fields['DATE_START']."</font>"; |
|
523 | + } |
|
524 | + $this->fill_in_additional_detail_fields(); |
|
525 | 525 | |
526 | 526 | // make sure we grab the localized version of the contact name, if a contact is provided |
527 | 527 | if (!empty($this->contact_id)) |
@@ -537,342 +537,342 @@ discard block |
||
537 | 537 | |
538 | 538 | $meeting_fields['CONTACT_ID'] = $this->contact_id; |
539 | 539 | $meeting_fields['CONTACT_NAME'] = $this->contact_name; |
540 | - $meeting_fields['PARENT_NAME'] = $this->parent_name; |
|
540 | + $meeting_fields['PARENT_NAME'] = $this->parent_name; |
|
541 | 541 | $meeting_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true; |
542 | 542 | $meeting_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true; |
543 | 543 | |
544 | 544 | |
545 | - return $meeting_fields; |
|
546 | - } |
|
547 | - |
|
548 | - function set_notification_body($xtpl, &$meeting) { |
|
549 | - global $sugar_config; |
|
550 | - global $app_list_strings; |
|
551 | - global $current_user; |
|
552 | - global $timedate; |
|
553 | - |
|
554 | - |
|
555 | - // cn: bug 9494 - passing a contact breaks this call |
|
556 | - $notifyUser =($meeting->current_notify_user->object_name == 'User') ? $meeting->current_notify_user : $current_user; |
|
557 | - // cn: bug 8078 - fixed call to $timedate |
|
558 | - if(strtolower(get_class($meeting->current_notify_user)) == 'contact') { |
|
559 | - $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
560 | - '/index.php?entryPoint=acceptDecline&module=Meetings&contact_id='.$meeting->current_notify_user->id.'&record='.$meeting->id); |
|
561 | - } elseif(strtolower(get_class($meeting->current_notify_user)) == 'lead') { |
|
562 | - $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
563 | - '/index.php?entryPoint=acceptDecline&module=Meetings&lead_id='.$meeting->current_notify_user->id.'&record='.$meeting->id); |
|
564 | - } else { |
|
565 | - $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
566 | - '/index.php?entryPoint=acceptDecline&module=Meetings&user_id='.$meeting->current_notify_user->id.'&record='.$meeting->id); |
|
567 | - } |
|
568 | - $xtpl->assign("MEETING_TO", $meeting->current_notify_user->new_assigned_user_name); |
|
569 | - $xtpl->assign("MEETING_SUBJECT", trim($meeting->name)); |
|
570 | - $xtpl->assign("MEETING_STATUS",(isset($meeting->status)? $app_list_strings['meeting_status_dom'][$meeting->status]:"")); |
|
571 | - $typekey = strtolower($meeting->type); |
|
572 | - if(isset($meeting->type)) { |
|
573 | - if(!empty($app_list_strings['eapm_list'][$typekey])) { |
|
574 | - $typestring = $app_list_strings['eapm_list'][$typekey]; |
|
575 | - } else { |
|
576 | - $typestring = $app_list_strings['meeting_type_dom'][$meeting->type]; |
|
577 | - } |
|
578 | - } |
|
579 | - $xtpl->assign("MEETING_TYPE", isset($meeting->type)? $typestring:""); |
|
580 | - $startdate = $timedate->fromDb($meeting->date_start); |
|
581 | - $xtpl->assign("MEETING_STARTDATE", $timedate->asUser($startdate, $notifyUser)." ".TimeDate::userTimezoneSuffix($startdate, $notifyUser)); |
|
582 | - $enddate = $timedate->fromDb($meeting->date_end); |
|
583 | - $xtpl->assign("MEETING_ENDDATE", $timedate->asUser($enddate, $notifyUser)." ".TimeDate::userTimezoneSuffix($enddate, $notifyUser)); |
|
584 | - $xtpl->assign("MEETING_HOURS", $meeting->duration_hours); |
|
585 | - $xtpl->assign("MEETING_MINUTES", $meeting->duration_minutes); |
|
586 | - $xtpl->assign("MEETING_DESCRIPTION", $meeting->description); |
|
545 | + return $meeting_fields; |
|
546 | + } |
|
547 | + |
|
548 | + function set_notification_body($xtpl, &$meeting) { |
|
549 | + global $sugar_config; |
|
550 | + global $app_list_strings; |
|
551 | + global $current_user; |
|
552 | + global $timedate; |
|
553 | + |
|
554 | + |
|
555 | + // cn: bug 9494 - passing a contact breaks this call |
|
556 | + $notifyUser =($meeting->current_notify_user->object_name == 'User') ? $meeting->current_notify_user : $current_user; |
|
557 | + // cn: bug 8078 - fixed call to $timedate |
|
558 | + if(strtolower(get_class($meeting->current_notify_user)) == 'contact') { |
|
559 | + $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
560 | + '/index.php?entryPoint=acceptDecline&module=Meetings&contact_id='.$meeting->current_notify_user->id.'&record='.$meeting->id); |
|
561 | + } elseif(strtolower(get_class($meeting->current_notify_user)) == 'lead') { |
|
562 | + $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
563 | + '/index.php?entryPoint=acceptDecline&module=Meetings&lead_id='.$meeting->current_notify_user->id.'&record='.$meeting->id); |
|
564 | + } else { |
|
565 | + $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
566 | + '/index.php?entryPoint=acceptDecline&module=Meetings&user_id='.$meeting->current_notify_user->id.'&record='.$meeting->id); |
|
567 | + } |
|
568 | + $xtpl->assign("MEETING_TO", $meeting->current_notify_user->new_assigned_user_name); |
|
569 | + $xtpl->assign("MEETING_SUBJECT", trim($meeting->name)); |
|
570 | + $xtpl->assign("MEETING_STATUS",(isset($meeting->status)? $app_list_strings['meeting_status_dom'][$meeting->status]:"")); |
|
571 | + $typekey = strtolower($meeting->type); |
|
572 | + if(isset($meeting->type)) { |
|
573 | + if(!empty($app_list_strings['eapm_list'][$typekey])) { |
|
574 | + $typestring = $app_list_strings['eapm_list'][$typekey]; |
|
575 | + } else { |
|
576 | + $typestring = $app_list_strings['meeting_type_dom'][$meeting->type]; |
|
577 | + } |
|
578 | + } |
|
579 | + $xtpl->assign("MEETING_TYPE", isset($meeting->type)? $typestring:""); |
|
580 | + $startdate = $timedate->fromDb($meeting->date_start); |
|
581 | + $xtpl->assign("MEETING_STARTDATE", $timedate->asUser($startdate, $notifyUser)." ".TimeDate::userTimezoneSuffix($startdate, $notifyUser)); |
|
582 | + $enddate = $timedate->fromDb($meeting->date_end); |
|
583 | + $xtpl->assign("MEETING_ENDDATE", $timedate->asUser($enddate, $notifyUser)." ".TimeDate::userTimezoneSuffix($enddate, $notifyUser)); |
|
584 | + $xtpl->assign("MEETING_HOURS", $meeting->duration_hours); |
|
585 | + $xtpl->assign("MEETING_MINUTES", $meeting->duration_minutes); |
|
586 | + $xtpl->assign("MEETING_DESCRIPTION", $meeting->description); |
|
587 | 587 | if ( !empty($meeting->join_url) ) { |
588 | 588 | $xtpl->assign('MEETING_URL', $meeting->join_url); |
589 | 589 | $xtpl->parse('Meeting.Meeting_External_API'); |
590 | 590 | } |
591 | 591 | |
592 | - return $xtpl; |
|
593 | - } |
|
592 | + return $xtpl; |
|
593 | + } |
|
594 | 594 | |
595 | - /** |
|
596 | - * Redefine method to attach ics file to notification email |
|
597 | - */ |
|
598 | - public function create_notification_email($notify_user){ |
|
595 | + /** |
|
596 | + * Redefine method to attach ics file to notification email |
|
597 | + */ |
|
598 | + public function create_notification_email($notify_user){ |
|
599 | 599 | // reset acceptance status for non organizer if date is changed |
600 | 600 | if (($notify_user->id != $GLOBALS['current_user']->id) && $this->date_changed) { |
601 | 601 | $this->set_accept_status($notify_user, 'none'); |
602 | 602 | } |
603 | 603 | |
604 | - $notify_mail = parent::create_notification_email($notify_user); |
|
605 | - |
|
606 | - $path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id; |
|
607 | - |
|
608 | - require_once("modules/vCals/vCal.php"); |
|
609 | - $content = vCal::get_ical_event($this, $GLOBALS['current_user']); |
|
610 | - |
|
611 | - if(file_put_contents($path,$content)){ |
|
612 | - $notify_mail->AddAttachment($path, 'meeting.ics', 'base64', 'text/calendar'); |
|
613 | - } |
|
614 | - return $notify_mail; |
|
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Redefine method to remove ics after email is sent |
|
619 | - */ |
|
620 | - public function send_assignment_notifications($notify_user, $admin){ |
|
621 | - parent::send_assignment_notifications($notify_user, $admin); |
|
622 | - |
|
623 | - $path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id; |
|
624 | - unlink($path); |
|
625 | - } |
|
626 | - |
|
627 | - function get_meeting_users() { |
|
628 | - $template = new User(); |
|
629 | - // First, get the list of IDs. |
|
630 | - $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.user_id from meetings_users where meetings_users.meeting_id='$this->id' AND meetings_users.deleted=0"; |
|
631 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
632 | - $result = $this->db->query($query, true); |
|
633 | - $list = Array(); |
|
634 | - |
|
635 | - while($row = $this->db->fetchByAssoc($result)) { |
|
636 | - $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one |
|
637 | - $record = $template->retrieve($row['user_id']); |
|
638 | - $template->required = $row['required']; |
|
639 | - $template->accept_status = $row['accept_status']; |
|
640 | - |
|
641 | - if($record != null) { |
|
642 | - // this copies the object into the array |
|
643 | - $list[] = $template; |
|
644 | - } |
|
645 | - } |
|
646 | - return $list; |
|
647 | - } |
|
648 | - |
|
649 | - function get_invite_meetings(&$user) { |
|
650 | - $template = $this; |
|
651 | - // First, get the list of IDs. |
|
652 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
653 | - $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.meeting_id from meetings_users where meetings_users.user_id='$user->id' AND( meetings_users.accept_status IS NULL OR meetings_users.accept_status='none') AND meetings_users.deleted=0"; |
|
654 | - $result = $this->db->query($query, true); |
|
655 | - $list = Array(); |
|
656 | - |
|
657 | - while($row = $this->db->fetchByAssoc($result)) { |
|
658 | - $record = $template->retrieve($row['meeting_id']); |
|
659 | - $template->required = $row['required']; |
|
660 | - $template->accept_status = $row['accept_status']; |
|
661 | - |
|
662 | - |
|
663 | - if($record != null) |
|
664 | - { |
|
665 | - // this copies the object into the array |
|
666 | - $list[] = $template; |
|
667 | - } |
|
668 | - } |
|
669 | - return $list; |
|
670 | - } |
|
671 | - |
|
672 | - |
|
673 | - function set_accept_status(&$user,$status) |
|
674 | - { |
|
675 | - if($user->object_name == 'User') |
|
676 | - { |
|
677 | - $relate_values = array('user_id'=>$user->id,'meeting_id'=>$this->id); |
|
678 | - $data_values = array('accept_status'=>$status); |
|
679 | - $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
680 | - global $current_user; |
|
681 | - |
|
682 | - if($this->update_vcal) |
|
683 | - { |
|
684 | - vCal::cache_sugar_vcal($user); |
|
685 | - } |
|
686 | - } |
|
687 | - else if($user->object_name == 'Contact') |
|
688 | - { |
|
689 | - $relate_values = array('contact_id'=>$user->id,'meeting_id'=>$this->id); |
|
690 | - $data_values = array('accept_status'=>$status); |
|
691 | - $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values); |
|
692 | - } |
|
604 | + $notify_mail = parent::create_notification_email($notify_user); |
|
605 | + |
|
606 | + $path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id; |
|
607 | + |
|
608 | + require_once("modules/vCals/vCal.php"); |
|
609 | + $content = vCal::get_ical_event($this, $GLOBALS['current_user']); |
|
610 | + |
|
611 | + if(file_put_contents($path,$content)){ |
|
612 | + $notify_mail->AddAttachment($path, 'meeting.ics', 'base64', 'text/calendar'); |
|
613 | + } |
|
614 | + return $notify_mail; |
|
615 | + } |
|
616 | + |
|
617 | + /** |
|
618 | + * Redefine method to remove ics after email is sent |
|
619 | + */ |
|
620 | + public function send_assignment_notifications($notify_user, $admin){ |
|
621 | + parent::send_assignment_notifications($notify_user, $admin); |
|
622 | + |
|
623 | + $path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id; |
|
624 | + unlink($path); |
|
625 | + } |
|
626 | + |
|
627 | + function get_meeting_users() { |
|
628 | + $template = new User(); |
|
629 | + // First, get the list of IDs. |
|
630 | + $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.user_id from meetings_users where meetings_users.meeting_id='$this->id' AND meetings_users.deleted=0"; |
|
631 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
632 | + $result = $this->db->query($query, true); |
|
633 | + $list = Array(); |
|
634 | + |
|
635 | + while($row = $this->db->fetchByAssoc($result)) { |
|
636 | + $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one |
|
637 | + $record = $template->retrieve($row['user_id']); |
|
638 | + $template->required = $row['required']; |
|
639 | + $template->accept_status = $row['accept_status']; |
|
640 | + |
|
641 | + if($record != null) { |
|
642 | + // this copies the object into the array |
|
643 | + $list[] = $template; |
|
644 | + } |
|
645 | + } |
|
646 | + return $list; |
|
647 | + } |
|
648 | + |
|
649 | + function get_invite_meetings(&$user) { |
|
650 | + $template = $this; |
|
651 | + // First, get the list of IDs. |
|
652 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
653 | + $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.meeting_id from meetings_users where meetings_users.user_id='$user->id' AND( meetings_users.accept_status IS NULL OR meetings_users.accept_status='none') AND meetings_users.deleted=0"; |
|
654 | + $result = $this->db->query($query, true); |
|
655 | + $list = Array(); |
|
656 | + |
|
657 | + while($row = $this->db->fetchByAssoc($result)) { |
|
658 | + $record = $template->retrieve($row['meeting_id']); |
|
659 | + $template->required = $row['required']; |
|
660 | + $template->accept_status = $row['accept_status']; |
|
661 | + |
|
662 | + |
|
663 | + if($record != null) |
|
664 | + { |
|
665 | + // this copies the object into the array |
|
666 | + $list[] = $template; |
|
667 | + } |
|
668 | + } |
|
669 | + return $list; |
|
670 | + } |
|
671 | + |
|
672 | + |
|
673 | + function set_accept_status(&$user,$status) |
|
674 | + { |
|
675 | + if($user->object_name == 'User') |
|
676 | + { |
|
677 | + $relate_values = array('user_id'=>$user->id,'meeting_id'=>$this->id); |
|
678 | + $data_values = array('accept_status'=>$status); |
|
679 | + $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
680 | + global $current_user; |
|
681 | + |
|
682 | + if($this->update_vcal) |
|
683 | + { |
|
684 | + vCal::cache_sugar_vcal($user); |
|
685 | + } |
|
686 | + } |
|
687 | + else if($user->object_name == 'Contact') |
|
688 | + { |
|
689 | + $relate_values = array('contact_id'=>$user->id,'meeting_id'=>$this->id); |
|
690 | + $data_values = array('accept_status'=>$status); |
|
691 | + $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values); |
|
692 | + } |
|
693 | 693 | else if($user->object_name == 'Lead') |
694 | - { |
|
695 | - $relate_values = array('lead_id'=>$user->id,'meeting_id'=>$this->id); |
|
696 | - $data_values = array('accept_status'=>$status); |
|
697 | - $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values); |
|
698 | - } |
|
699 | - } |
|
694 | + { |
|
695 | + $relate_values = array('lead_id'=>$user->id,'meeting_id'=>$this->id); |
|
696 | + $data_values = array('accept_status'=>$status); |
|
697 | + $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values); |
|
698 | + } |
|
699 | + } |
|
700 | 700 | |
701 | 701 | |
702 | - function get_notification_recipients() { |
|
703 | - if($this->special_notification) { |
|
704 | - return parent::get_notification_recipients(); |
|
705 | - } |
|
702 | + function get_notification_recipients() { |
|
703 | + if($this->special_notification) { |
|
704 | + return parent::get_notification_recipients(); |
|
705 | + } |
|
706 | 706 | |
707 | - $list = array(); |
|
708 | - if(!is_array($this->contacts_arr)) { |
|
709 | - $this->contacts_arr = array(); |
|
710 | - } |
|
707 | + $list = array(); |
|
708 | + if(!is_array($this->contacts_arr)) { |
|
709 | + $this->contacts_arr = array(); |
|
710 | + } |
|
711 | 711 | |
712 | - if(!is_array($this->users_arr)) { |
|
713 | - $this->users_arr = array(); |
|
714 | - } |
|
712 | + if(!is_array($this->users_arr)) { |
|
713 | + $this->users_arr = array(); |
|
714 | + } |
|
715 | 715 | |
716 | 716 | if(!is_array($this->leads_arr)) { |
717 | - $this->leads_arr = array(); |
|
718 | - } |
|
719 | - |
|
720 | - foreach($this->users_arr as $user_id) { |
|
721 | - $notify_user = new User(); |
|
722 | - $notify_user->retrieve($user_id); |
|
723 | - $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
724 | - $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
725 | - $list[$notify_user->id] = $notify_user; |
|
726 | - } |
|
727 | - |
|
728 | - foreach($this->contacts_arr as $contact_id) { |
|
729 | - $notify_user = new Contact(); |
|
730 | - $notify_user->retrieve($contact_id); |
|
731 | - $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
732 | - $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
733 | - $list[$notify_user->id] = $notify_user; |
|
734 | - } |
|
717 | + $this->leads_arr = array(); |
|
718 | + } |
|
719 | + |
|
720 | + foreach($this->users_arr as $user_id) { |
|
721 | + $notify_user = new User(); |
|
722 | + $notify_user->retrieve($user_id); |
|
723 | + $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
724 | + $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
725 | + $list[$notify_user->id] = $notify_user; |
|
726 | + } |
|
727 | + |
|
728 | + foreach($this->contacts_arr as $contact_id) { |
|
729 | + $notify_user = new Contact(); |
|
730 | + $notify_user->retrieve($contact_id); |
|
731 | + $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
732 | + $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
733 | + $list[$notify_user->id] = $notify_user; |
|
734 | + } |
|
735 | 735 | |
736 | 736 | foreach($this->leads_arr as $lead_id) { |
737 | - $notify_user = new Lead(); |
|
738 | - $notify_user->retrieve($lead_id); |
|
739 | - $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
740 | - $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
741 | - $list[$notify_user->id] = $notify_user; |
|
742 | - } |
|
743 | - |
|
744 | - global $sugar_config; |
|
745 | - if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
|
746 | - global $current_user; |
|
747 | - if(isset($list[$current_user->id])) |
|
748 | - unset($list[$current_user->id]); |
|
749 | - } |
|
750 | - return $list; |
|
751 | - } |
|
752 | - |
|
753 | - |
|
754 | - function bean_implements($interface) { |
|
755 | - switch($interface) { |
|
756 | - case 'ACL':return true; |
|
757 | - } |
|
758 | - return false; |
|
759 | - } |
|
760 | - |
|
761 | - function listviewACLHelper() { |
|
762 | - $array_assign = parent::listviewACLHelper(); |
|
763 | - $is_owner = false; |
|
764 | - $in_group = false; //SECURITY GROUPS |
|
765 | - if(!empty($this->parent_name)) { |
|
766 | - |
|
767 | - if(!empty($this->parent_name_owner)) { |
|
768 | - global $current_user; |
|
769 | - $is_owner = $current_user->id == $this->parent_name_owner; |
|
770 | - } |
|
771 | - /* BEGIN - SECURITY GROUPS */ |
|
772 | - //parent_name_owner not being set for whatever reason so we need to figure this out |
|
773 | - else if(!empty($this->parent_type) && !empty($this->parent_id)) { |
|
774 | - global $current_user; |
|
737 | + $notify_user = new Lead(); |
|
738 | + $notify_user->retrieve($lead_id); |
|
739 | + $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
740 | + $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
741 | + $list[$notify_user->id] = $notify_user; |
|
742 | + } |
|
743 | + |
|
744 | + global $sugar_config; |
|
745 | + if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
|
746 | + global $current_user; |
|
747 | + if(isset($list[$current_user->id])) |
|
748 | + unset($list[$current_user->id]); |
|
749 | + } |
|
750 | + return $list; |
|
751 | + } |
|
752 | + |
|
753 | + |
|
754 | + function bean_implements($interface) { |
|
755 | + switch($interface) { |
|
756 | + case 'ACL':return true; |
|
757 | + } |
|
758 | + return false; |
|
759 | + } |
|
760 | + |
|
761 | + function listviewACLHelper() { |
|
762 | + $array_assign = parent::listviewACLHelper(); |
|
763 | + $is_owner = false; |
|
764 | + $in_group = false; //SECURITY GROUPS |
|
765 | + if(!empty($this->parent_name)) { |
|
766 | + |
|
767 | + if(!empty($this->parent_name_owner)) { |
|
768 | + global $current_user; |
|
769 | + $is_owner = $current_user->id == $this->parent_name_owner; |
|
770 | + } |
|
771 | + /* BEGIN - SECURITY GROUPS */ |
|
772 | + //parent_name_owner not being set for whatever reason so we need to figure this out |
|
773 | + else if(!empty($this->parent_type) && !empty($this->parent_id)) { |
|
774 | + global $current_user; |
|
775 | 775 | $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id); |
776 | 776 | if($parent_bean !== false) { |
777 | - $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
777 | + $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
778 | 778 | } |
779 | - } |
|
780 | - require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
781 | - $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view'); |
|
782 | - /* END - SECURITY GROUPS */ |
|
783 | - } |
|
784 | - |
|
785 | - /* BEGIN - SECURITY GROUPS */ |
|
786 | - /** |
|
779 | + } |
|
780 | + require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
781 | + $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view'); |
|
782 | + /* END - SECURITY GROUPS */ |
|
783 | + } |
|
784 | + |
|
785 | + /* BEGIN - SECURITY GROUPS */ |
|
786 | + /** |
|
787 | 787 | if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)) { |
788 | - */ |
|
789 | - if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
788 | + */ |
|
789 | + if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
790 | 790 | /* END - SECURITY GROUPS */ |
791 | - $array_assign['PARENT'] = 'a'; |
|
792 | - } else { |
|
793 | - $array_assign['PARENT'] = 'span'; |
|
794 | - } |
|
795 | - |
|
796 | - $is_owner = false; |
|
797 | - $in_group = false; //SECURITY GROUPS |
|
798 | - |
|
799 | - if(!empty($this->contact_name)) { |
|
800 | - if(!empty($this->contact_name_owner)) { |
|
801 | - global $current_user; |
|
802 | - $is_owner = $current_user->id == $this->contact_name_owner; |
|
803 | - } |
|
804 | - /* BEGIN - SECURITY GROUPS */ |
|
805 | - //contact_name_owner not being set for whatever reason so we need to figure this out |
|
806 | - else { |
|
807 | - global $current_user; |
|
791 | + $array_assign['PARENT'] = 'a'; |
|
792 | + } else { |
|
793 | + $array_assign['PARENT'] = 'span'; |
|
794 | + } |
|
795 | + |
|
796 | + $is_owner = false; |
|
797 | + $in_group = false; //SECURITY GROUPS |
|
798 | + |
|
799 | + if(!empty($this->contact_name)) { |
|
800 | + if(!empty($this->contact_name_owner)) { |
|
801 | + global $current_user; |
|
802 | + $is_owner = $current_user->id == $this->contact_name_owner; |
|
803 | + } |
|
804 | + /* BEGIN - SECURITY GROUPS */ |
|
805 | + //contact_name_owner not being set for whatever reason so we need to figure this out |
|
806 | + else { |
|
807 | + global $current_user; |
|
808 | 808 | $parent_bean = BeanFactory::getBean('Contacts',$this->contact_id); |
809 | 809 | if($parent_bean !== false) { |
810 | - $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
810 | + $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
811 | 811 | } |
812 | - } |
|
813 | - require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
814 | - $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); |
|
815 | - /* END - SECURITY GROUPS */ |
|
816 | - } |
|
817 | - |
|
818 | - /* BEGIN - SECURITY GROUPS */ |
|
819 | - /** |
|
812 | + } |
|
813 | + require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
814 | + $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); |
|
815 | + /* END - SECURITY GROUPS */ |
|
816 | + } |
|
817 | + |
|
818 | + /* BEGIN - SECURITY GROUPS */ |
|
819 | + /** |
|
820 | 820 | if(ACLController::checkAccess('Contacts', 'view', $is_owner)) { |
821 | - */ |
|
822 | - if(ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) { |
|
821 | + */ |
|
822 | + if(ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) { |
|
823 | 823 | /* END - SECURITY GROUPS */ |
824 | - $array_assign['CONTACT'] = 'a'; |
|
825 | - } else { |
|
826 | - $array_assign['CONTACT'] = 'span'; |
|
827 | - } |
|
828 | - return $array_assign; |
|
829 | - } |
|
830 | - |
|
831 | - |
|
832 | - function save_relationship_changes($is_update, $exclude = array()) { |
|
833 | - if(empty($this->in_workflow)) { |
|
834 | - if(empty($this->in_import)){//if a meeting is being imported then contact_id should not be excluded |
|
835 | - //if the global soap_server_object variable is not empty (as in from a soap/OPI call), then process the assigned_user_id relationship, otherwise |
|
836 | - //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship |
|
837 | - if(!empty($GLOBALS['soap_server_object'])){ |
|
838 | - $exclude = array('contact_id', 'user_id'); |
|
839 | - }else{ |
|
840 | - $exclude = array('contact_id', 'user_id','assigned_user_id'); |
|
841 | - } |
|
842 | - } |
|
843 | - else{ |
|
844 | - $exclude = array('user_id'); |
|
845 | - } |
|
846 | - } |
|
847 | - parent::save_relationship_changes($is_update, $exclude); |
|
848 | - } |
|
849 | - |
|
850 | - |
|
851 | - /** |
|
852 | - * @see SugarBean::afterImportSave() |
|
853 | - */ |
|
854 | - public function afterImportSave() |
|
855 | - { |
|
856 | - if ( $this->parent_type == 'Contacts' ) { |
|
857 | - $this->load_relationship('contacts'); |
|
858 | - if ( !$this->contacts->relationship_exists('contacts',array('id'=>$this->parent_id)) ) |
|
859 | - $this->contacts->add($this->parent_id); |
|
860 | - } |
|
861 | - elseif ( $this->parent_type == 'Leads' ) { |
|
862 | - $this->load_relationship('leads'); |
|
863 | - if ( !$this->leads->relationship_exists('leads',array('id'=>$this->parent_id)) ) |
|
864 | - $this->leads->add($this->parent_id); |
|
865 | - } |
|
866 | - |
|
867 | - parent::afterImportSave(); |
|
868 | - } |
|
824 | + $array_assign['CONTACT'] = 'a'; |
|
825 | + } else { |
|
826 | + $array_assign['CONTACT'] = 'span'; |
|
827 | + } |
|
828 | + return $array_assign; |
|
829 | + } |
|
830 | + |
|
831 | + |
|
832 | + function save_relationship_changes($is_update, $exclude = array()) { |
|
833 | + if(empty($this->in_workflow)) { |
|
834 | + if(empty($this->in_import)){//if a meeting is being imported then contact_id should not be excluded |
|
835 | + //if the global soap_server_object variable is not empty (as in from a soap/OPI call), then process the assigned_user_id relationship, otherwise |
|
836 | + //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship |
|
837 | + if(!empty($GLOBALS['soap_server_object'])){ |
|
838 | + $exclude = array('contact_id', 'user_id'); |
|
839 | + }else{ |
|
840 | + $exclude = array('contact_id', 'user_id','assigned_user_id'); |
|
841 | + } |
|
842 | + } |
|
843 | + else{ |
|
844 | + $exclude = array('user_id'); |
|
845 | + } |
|
846 | + } |
|
847 | + parent::save_relationship_changes($is_update, $exclude); |
|
848 | + } |
|
849 | + |
|
850 | + |
|
851 | + /** |
|
852 | + * @see SugarBean::afterImportSave() |
|
853 | + */ |
|
854 | + public function afterImportSave() |
|
855 | + { |
|
856 | + if ( $this->parent_type == 'Contacts' ) { |
|
857 | + $this->load_relationship('contacts'); |
|
858 | + if ( !$this->contacts->relationship_exists('contacts',array('id'=>$this->parent_id)) ) |
|
859 | + $this->contacts->add($this->parent_id); |
|
860 | + } |
|
861 | + elseif ( $this->parent_type == 'Leads' ) { |
|
862 | + $this->load_relationship('leads'); |
|
863 | + if ( !$this->leads->relationship_exists('leads',array('id'=>$this->parent_id)) ) |
|
864 | + $this->leads->add($this->parent_id); |
|
865 | + } |
|
866 | + |
|
867 | + parent::afterImportSave(); |
|
868 | + } |
|
869 | 869 | |
870 | 870 | public function getDefaultStatus() |
871 | 871 | { |
872 | - $def = $this->field_defs['status']; |
|
873 | - if (isset($def['default'])) { |
|
874 | - return $def['default']; |
|
875 | - } else { |
|
872 | + $def = $this->field_defs['status']; |
|
873 | + if (isset($def['default'])) { |
|
874 | + return $def['default']; |
|
875 | + } else { |
|
876 | 876 | $app = return_app_list_strings_language($GLOBALS['current_language']); |
877 | 877 | if (isset($def['options']) && isset($app[$def['options']])) { |
878 | 878 | $keys = array_keys($app[$def['options']]); |
@@ -888,9 +888,9 @@ discard block |
||
888 | 888 | //TODO: do we really need focus, name and view params for this function |
889 | 889 | function getMeetingsExternalApiDropDown($focus = null, $name = null, $value = null, $view = null) |
890 | 890 | { |
891 | - global $dictionary, $app_list_strings; |
|
891 | + global $dictionary, $app_list_strings; |
|
892 | 892 | |
893 | - $cacheKeyName = 'meetings_type_drop_down'; |
|
893 | + $cacheKeyName = 'meetings_type_drop_down'; |
|
894 | 894 | |
895 | 895 | $apiList = sugar_cache_retrieve($cacheKeyName); |
896 | 896 | if ($apiList === null) |
@@ -902,17 +902,17 @@ discard block |
||
902 | 902 | sugar_cache_put($cacheKeyName, $apiList); |
903 | 903 | } |
904 | 904 | |
905 | - if(!empty($value) && empty($apiList[$value])) |
|
906 | - { |
|
907 | - $apiList[$value] = $value; |
|
905 | + if(!empty($value) && empty($apiList[$value])) |
|
906 | + { |
|
907 | + $apiList[$value] = $value; |
|
908 | 908 | } |
909 | - //bug 46294: adding list of options to dropdown list (if it is not the default list) |
|
909 | + //bug 46294: adding list of options to dropdown list (if it is not the default list) |
|
910 | 910 | if ($dictionary['Meeting']['fields']['type']['options'] != "eapm_list") |
911 | 911 | { |
912 | 912 | $apiList = array_merge(getMeetingTypeOptions($dictionary, $app_list_strings), $apiList); |
913 | 913 | } |
914 | 914 | |
915 | - return $apiList; |
|
915 | + return $apiList; |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -923,20 +923,20 @@ discard block |
||
923 | 923 | */ |
924 | 924 | function getMeetingTypeOptions($dictionary, $app_list_strings) |
925 | 925 | { |
926 | - $result = array(); |
|
926 | + $result = array(); |
|
927 | 927 | |
928 | 928 | // getting name of meeting type to fill dropdown list by its values |
929 | 929 | if (isset($dictionary['Meeting']['fields']['type']['options'])) |
930 | - { |
|
931 | - $typeName = $dictionary['Meeting']['fields']['type']['options']; |
|
930 | + { |
|
931 | + $typeName = $dictionary['Meeting']['fields']['type']['options']; |
|
932 | 932 | |
933 | 933 | if (!empty($app_list_strings[$typeName])) |
934 | - { |
|
935 | - $typeList = $app_list_strings[$typeName]; |
|
934 | + { |
|
935 | + $typeList = $app_list_strings[$typeName]; |
|
936 | 936 | |
937 | 937 | foreach ($typeList as $key => $value) |
938 | - { |
|
939 | - $result[$value] = $value; |
|
938 | + { |
|
939 | + $result[$value] = $value; |
|
940 | 940 | } |
941 | 941 | } |
942 | 942 | } |