@@ -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 | } |
@@ -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 | } |
@@ -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,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,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 | } |
@@ -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 | } |
@@ -47,176 +47,176 @@ discard block |
||
| 47 | 47 | ********************************************************************************/ |
| 48 | 48 | |
| 49 | 49 | class Call extends SugarBean { |
| 50 | - var $field_name_map; |
|
| 51 | - // Stored fields |
|
| 52 | - var $id; |
|
| 53 | - var $json_id; |
|
| 54 | - var $date_entered; |
|
| 55 | - var $date_modified; |
|
| 56 | - var $assigned_user_id; |
|
| 57 | - var $modified_user_id; |
|
| 58 | - var $description; |
|
| 59 | - var $name; |
|
| 60 | - var $status; |
|
| 61 | - var $date_start; |
|
| 62 | - var $time_start; |
|
| 63 | - var $duration_hours; |
|
| 64 | - var $duration_minutes; |
|
| 65 | - var $date_end; |
|
| 66 | - var $parent_type; |
|
| 67 | - var $parent_type_options; |
|
| 68 | - var $parent_id; |
|
| 69 | - var $contact_id; |
|
| 70 | - var $user_id; |
|
| 71 | - var $lead_id; |
|
| 72 | - var $direction; |
|
| 73 | - var $reminder_time; |
|
| 74 | - var $reminder_time_options; |
|
| 75 | - var $reminder_checked; |
|
| 76 | - var $email_reminder_time; |
|
| 77 | - var $email_reminder_checked; |
|
| 78 | - var $email_reminder_sent; |
|
| 79 | - var $required; |
|
| 80 | - var $accept_status; |
|
| 81 | - var $created_by; |
|
| 82 | - var $created_by_name; |
|
| 83 | - var $modified_by_name; |
|
| 84 | - var $parent_name; |
|
| 85 | - var $contact_name; |
|
| 86 | - var $contact_phone; |
|
| 87 | - var $contact_email; |
|
| 88 | - var $account_id; |
|
| 89 | - var $opportunity_id; |
|
| 90 | - var $case_id; |
|
| 91 | - var $assigned_user_name; |
|
| 92 | - var $note_id; |
|
| 50 | + var $field_name_map; |
|
| 51 | + // Stored fields |
|
| 52 | + var $id; |
|
| 53 | + var $json_id; |
|
| 54 | + var $date_entered; |
|
| 55 | + var $date_modified; |
|
| 56 | + var $assigned_user_id; |
|
| 57 | + var $modified_user_id; |
|
| 58 | + var $description; |
|
| 59 | + var $name; |
|
| 60 | + var $status; |
|
| 61 | + var $date_start; |
|
| 62 | + var $time_start; |
|
| 63 | + var $duration_hours; |
|
| 64 | + var $duration_minutes; |
|
| 65 | + var $date_end; |
|
| 66 | + var $parent_type; |
|
| 67 | + var $parent_type_options; |
|
| 68 | + var $parent_id; |
|
| 69 | + var $contact_id; |
|
| 70 | + var $user_id; |
|
| 71 | + var $lead_id; |
|
| 72 | + var $direction; |
|
| 73 | + var $reminder_time; |
|
| 74 | + var $reminder_time_options; |
|
| 75 | + var $reminder_checked; |
|
| 76 | + var $email_reminder_time; |
|
| 77 | + var $email_reminder_checked; |
|
| 78 | + var $email_reminder_sent; |
|
| 79 | + var $required; |
|
| 80 | + var $accept_status; |
|
| 81 | + var $created_by; |
|
| 82 | + var $created_by_name; |
|
| 83 | + var $modified_by_name; |
|
| 84 | + var $parent_name; |
|
| 85 | + var $contact_name; |
|
| 86 | + var $contact_phone; |
|
| 87 | + var $contact_email; |
|
| 88 | + var $account_id; |
|
| 89 | + var $opportunity_id; |
|
| 90 | + var $case_id; |
|
| 91 | + var $assigned_user_name; |
|
| 92 | + var $note_id; |
|
| 93 | 93 | var $outlook_id; |
| 94 | - var $update_vcal = true; |
|
| 95 | - var $contacts_arr; |
|
| 96 | - var $users_arr; |
|
| 97 | - var $leads_arr; |
|
| 98 | - var $default_call_name_values = array('Assemble catalogs', 'Make travel arrangements', 'Send a letter', 'Send contract', 'Send fax', 'Send a follow-up letter', 'Send literature', 'Send proposal', 'Send quote'); |
|
| 99 | - var $minutes_value_default = 15; |
|
| 100 | - var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45'); |
|
| 101 | - var $table_name = "calls"; |
|
| 102 | - var $rel_users_table = "calls_users"; |
|
| 103 | - var $rel_contacts_table = "calls_contacts"; |
|
| 94 | + var $update_vcal = true; |
|
| 95 | + var $contacts_arr; |
|
| 96 | + var $users_arr; |
|
| 97 | + var $leads_arr; |
|
| 98 | + var $default_call_name_values = array('Assemble catalogs', 'Make travel arrangements', 'Send a letter', 'Send contract', 'Send fax', 'Send a follow-up letter', 'Send literature', 'Send proposal', 'Send quote'); |
|
| 99 | + var $minutes_value_default = 15; |
|
| 100 | + var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45'); |
|
| 101 | + var $table_name = "calls"; |
|
| 102 | + var $rel_users_table = "calls_users"; |
|
| 103 | + var $rel_contacts_table = "calls_contacts"; |
|
| 104 | 104 | var $rel_leads_table = "calls_leads"; |
| 105 | - var $module_dir = 'Calls'; |
|
| 106 | - var $object_name = "Call"; |
|
| 107 | - var $new_schema = true; |
|
| 108 | - var $importable = true; |
|
| 109 | - var $syncing = false; |
|
| 110 | - var $recurring_source; |
|
| 111 | - |
|
| 112 | - // This is used to retrieve related fields from form posts. |
|
| 113 | - var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name'); |
|
| 114 | - var $relationship_fields = array( 'account_id' => 'accounts', |
|
| 115 | - 'opportunity_id' => 'opportunities', |
|
| 116 | - 'contact_id' => 'contacts', |
|
| 117 | - 'case_id' => 'cases', |
|
| 118 | - 'user_id' => 'users', |
|
| 119 | - 'assigned_user_id' => 'users', |
|
| 120 | - 'note_id' => 'notes', |
|
| 105 | + var $module_dir = 'Calls'; |
|
| 106 | + var $object_name = "Call"; |
|
| 107 | + var $new_schema = true; |
|
| 108 | + var $importable = true; |
|
| 109 | + var $syncing = false; |
|
| 110 | + var $recurring_source; |
|
| 111 | + |
|
| 112 | + // This is used to retrieve related fields from form posts. |
|
| 113 | + var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name'); |
|
| 114 | + var $relationship_fields = array( 'account_id' => 'accounts', |
|
| 115 | + 'opportunity_id' => 'opportunities', |
|
| 116 | + 'contact_id' => 'contacts', |
|
| 117 | + 'case_id' => 'cases', |
|
| 118 | + 'user_id' => 'users', |
|
| 119 | + 'assigned_user_id' => 'users', |
|
| 120 | + 'note_id' => 'notes', |
|
| 121 | 121 | 'lead_id' => 'leads', |
| 122 | - ); |
|
| 123 | - |
|
| 124 | - public function __construct() { |
|
| 125 | - parent::__construct(); |
|
| 126 | - global $app_list_strings; |
|
| 127 | - |
|
| 128 | - $this->setupCustomFields('Calls'); |
|
| 129 | - |
|
| 130 | - foreach ($this->field_defs as $field) { |
|
| 131 | - $this->field_name_map[$field['name']] = $field; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 138 | - $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @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 |
|
| 143 | - */ |
|
| 144 | - public function Call(){ |
|
| 145 | - $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 146 | - if(isset($GLOBALS['log'])) { |
|
| 147 | - $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 148 | - } |
|
| 149 | - else { |
|
| 150 | - trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 151 | - } |
|
| 152 | - self::__construct(); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Disable edit if call is recurring and source is not Sugar. It should be edited only from Outlook. |
|
| 157 | - * @param $view string |
|
| 158 | - * @param $is_owner bool |
|
| 159 | - */ |
|
| 160 | - function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
| 161 | - // don't check if call is being synced from Outlook |
|
| 162 | - if($this->syncing == false){ |
|
| 163 | - $view = strtolower($view); |
|
| 164 | - switch($view){ |
|
| 165 | - case 'edit': |
|
| 166 | - case 'save': |
|
| 167 | - case 'editview': |
|
| 168 | - case 'delete': |
|
| 169 | - if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - return parent::ACLAccess($view,$is_owner,$in_group); |
|
| 175 | - } |
|
| 122 | + ); |
|
| 123 | + |
|
| 124 | + public function __construct() { |
|
| 125 | + parent::__construct(); |
|
| 126 | + global $app_list_strings; |
|
| 127 | + |
|
| 128 | + $this->setupCustomFields('Calls'); |
|
| 129 | + |
|
| 130 | + foreach ($this->field_defs as $field) { |
|
| 131 | + $this->field_name_map[$field['name']] = $field; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 138 | + $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @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 |
|
| 143 | + */ |
|
| 144 | + public function Call(){ |
|
| 145 | + $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 146 | + if(isset($GLOBALS['log'])) { |
|
| 147 | + $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 148 | + } |
|
| 149 | + else { |
|
| 150 | + trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 151 | + } |
|
| 152 | + self::__construct(); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Disable edit if call is recurring and source is not Sugar. It should be edited only from Outlook. |
|
| 157 | + * @param $view string |
|
| 158 | + * @param $is_owner bool |
|
| 159 | + */ |
|
| 160 | + function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
| 161 | + // don't check if call is being synced from Outlook |
|
| 162 | + if($this->syncing == false){ |
|
| 163 | + $view = strtolower($view); |
|
| 164 | + switch($view){ |
|
| 165 | + case 'edit': |
|
| 166 | + case 'save': |
|
| 167 | + case 'editview': |
|
| 168 | + case 'delete': |
|
| 169 | + if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + return parent::ACLAccess($view,$is_owner,$in_group); |
|
| 175 | + } |
|
| 176 | 176 | // save date_end by calculating user input |
| 177 | 177 | // this is for calendar |
| 178 | - function save($check_notify = FALSE) { |
|
| 179 | - global $timedate,$current_user; |
|
| 178 | + function save($check_notify = FALSE) { |
|
| 179 | + global $timedate,$current_user; |
|
| 180 | 180 | |
| 181 | - if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) |
|
| 181 | + if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) |
|
| 182 | 182 | { |
| 183 | - $td = $timedate->fromDb($this->date_start); |
|
| 184 | - if($td) |
|
| 185 | - { |
|
| 186 | - $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); |
|
| 187 | - } |
|
| 183 | + $td = $timedate->fromDb($this->date_start); |
|
| 184 | + if($td) |
|
| 185 | + { |
|
| 186 | + $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); |
|
| 187 | + } |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { |
|
| 191 | - $check_notify = true; |
|
| 190 | + if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { |
|
| 191 | + $check_notify = true; |
|
| 192 | 192 | } else { |
| 193 | - $check_notify = false; |
|
| 194 | - } |
|
| 195 | - if(empty($_REQUEST['send_invites'])) { |
|
| 196 | - if(!empty($this->id)) { |
|
| 197 | - $old_record = new Call(); |
|
| 198 | - $old_record->retrieve($this->id); |
|
| 199 | - $old_assigned_user_id = $old_record->assigned_user_id; |
|
| 200 | - } |
|
| 201 | - 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']) ){ |
|
| 202 | - $this->special_notification = true; |
|
| 203 | - if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) { |
|
| 204 | - $check_notify = true; |
|
| 205 | - } |
|
| 193 | + $check_notify = false; |
|
| 194 | + } |
|
| 195 | + if(empty($_REQUEST['send_invites'])) { |
|
| 196 | + if(!empty($this->id)) { |
|
| 197 | + $old_record = new Call(); |
|
| 198 | + $old_record->retrieve($this->id); |
|
| 199 | + $old_assigned_user_id = $old_record->assigned_user_id; |
|
| 200 | + } |
|
| 201 | + 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']) ){ |
|
| 202 | + $this->special_notification = true; |
|
| 203 | + if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) { |
|
| 204 | + $check_notify = true; |
|
| 205 | + } |
|
| 206 | 206 | if(isset($_REQUEST['assigned_user_name'])) { |
| 207 | 207 | $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; |
| 208 | 208 | } |
| 209 | - } |
|
| 210 | - } |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | if (empty($this->status) ) { |
| 212 | 212 | $this->status = $this->getDefaultStatus(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - // prevent a mass mailing for recurring meetings created in Calendar module |
|
| 216 | - if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { |
|
| 217 | - $check_notify = false; |
|
| 218 | - } |
|
| 219 | - /*nsingh 7/3/08 commenting out as bug #20814 is invalid |
|
| 215 | + // prevent a mass mailing for recurring meetings created in Calendar module |
|
| 216 | + if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { |
|
| 217 | + $check_notify = false; |
|
| 218 | + } |
|
| 219 | + /*nsingh 7/3/08 commenting out as bug #20814 is invalid |
|
| 220 | 220 | if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ |
| 221 | 221 | $this->reminder_checked = '1'; |
| 222 | 222 | $this->reminder_time = $current_user->getPreference('reminder_time'); |
@@ -227,87 +227,87 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | if($this->update_vcal) { |
| 230 | - vCal::cache_sugar_vcal($current_user); |
|
| 230 | + vCal::cache_sugar_vcal($current_user); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if(isset($_REQUEST['reminders_data'])) { |
|
| 234 | - Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
|
| 235 | - } |
|
| 233 | + if(isset($_REQUEST['reminders_data'])) { |
|
| 234 | + Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | return $return_id; |
| 238 | - } |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - /** Returns a list of the associated contacts |
|
| 241 | - * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. |
|
| 242 | - * All Rights Reserved.. |
|
| 243 | - * Contributor(s): ______________________________________.. |
|
| 244 | - */ |
|
| 245 | - function get_contacts() |
|
| 246 | - { |
|
| 247 | - // First, get the list of IDs. |
|
| 248 | - $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0"; |
|
| 240 | + /** Returns a list of the associated contacts |
|
| 241 | + * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. |
|
| 242 | + * All Rights Reserved.. |
|
| 243 | + * Contributor(s): ______________________________________.. |
|
| 244 | + */ |
|
| 245 | + function get_contacts() |
|
| 246 | + { |
|
| 247 | + // First, get the list of IDs. |
|
| 248 | + $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0"; |
|
| 249 | 249 | |
| 250 | - return $this->build_related_list($query, new Contact()); |
|
| 251 | - } |
|
| 250 | + return $this->build_related_list($query, new Contact()); |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | |
| 254 | - function get_summary_text() |
|
| 255 | - { |
|
| 256 | - return "$this->name"; |
|
| 257 | - } |
|
| 254 | + function get_summary_text() |
|
| 255 | + { |
|
| 256 | + return "$this->name"; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - function create_list_query($order_by, $where, $show_deleted=0) |
|
| 260 | - { |
|
| 259 | + function create_list_query($order_by, $where, $show_deleted=0) |
|
| 260 | + { |
|
| 261 | 261 | $custom_join = $this->getCustomJoin(); |
| 262 | 262 | $query = "SELECT "; |
| 263 | - $query .= " |
|
| 263 | + $query .= " |
|
| 264 | 264 | calls.*,"; |
| 265 | - if ( preg_match("/calls_users\.user_id/",$where)) |
|
| 266 | - { |
|
| 267 | - $query .= "calls_users.required, |
|
| 265 | + if ( preg_match("/calls_users\.user_id/",$where)) |
|
| 266 | + { |
|
| 267 | + $query .= "calls_users.required, |
|
| 268 | 268 | calls_users.accept_status,"; |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - $query .= " |
|
| 271 | + $query .= " |
|
| 272 | 272 | users.user_name as assigned_user_name"; |
| 273 | 273 | $query .= $custom_join['select']; |
| 274 | 274 | |
| 275 | - // this line will help generate a GMT-metric to compare to a locale's timezone |
|
| 275 | + // this line will help generate a GMT-metric to compare to a locale's timezone |
|
| 276 | 276 | |
| 277 | - if ( preg_match("/contacts/",$where)){ |
|
| 278 | - $query .= ", contacts.first_name, contacts.last_name"; |
|
| 279 | - $query .= ", contacts.assigned_user_id contact_name_owner"; |
|
| 280 | - } |
|
| 281 | - $query .= " FROM calls "; |
|
| 277 | + if ( preg_match("/contacts/",$where)){ |
|
| 278 | + $query .= ", contacts.first_name, contacts.last_name"; |
|
| 279 | + $query .= ", contacts.assigned_user_id contact_name_owner"; |
|
| 280 | + } |
|
| 281 | + $query .= " FROM calls "; |
|
| 282 | 282 | |
| 283 | - if ( preg_match("/contacts/",$where)){ |
|
| 284 | - $query .= "LEFT JOIN calls_contacts |
|
| 283 | + if ( preg_match("/contacts/",$where)){ |
|
| 284 | + $query .= "LEFT JOIN calls_contacts |
|
| 285 | 285 | ON calls.id=calls_contacts.call_id |
| 286 | 286 | LEFT JOIN contacts |
| 287 | 287 | ON calls_contacts.contact_id=contacts.id "; |
| 288 | - } |
|
| 289 | - if ( preg_match('/calls_users\.user_id/',$where)) |
|
| 290 | - { |
|
| 291 | - $query .= "LEFT JOIN calls_users |
|
| 288 | + } |
|
| 289 | + if ( preg_match('/calls_users\.user_id/',$where)) |
|
| 290 | + { |
|
| 291 | + $query .= "LEFT JOIN calls_users |
|
| 292 | 292 | ON calls.id=calls_users.call_id and calls_users.deleted=0 "; |
| 293 | - } |
|
| 294 | - $query .= " |
|
| 293 | + } |
|
| 294 | + $query .= " |
|
| 295 | 295 | LEFT JOIN users |
| 296 | 296 | ON calls.assigned_user_id=users.id "; |
| 297 | 297 | $query .= $custom_join['join']; |
| 298 | - $where_auto = '1=1'; |
|
| 299 | - if($show_deleted == 0){ |
|
| 300 | - $where_auto = " $this->table_name.deleted=0 "; |
|
| 301 | - }else if($show_deleted == 1){ |
|
| 302 | - $where_auto = " $this->table_name.deleted=1 "; |
|
| 303 | - } |
|
| 298 | + $where_auto = '1=1'; |
|
| 299 | + if($show_deleted == 0){ |
|
| 300 | + $where_auto = " $this->table_name.deleted=0 "; |
|
| 301 | + }else if($show_deleted == 1){ |
|
| 302 | + $where_auto = " $this->table_name.deleted=1 "; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - //$where_auto .= " GROUP BY calls.id"; |
|
| 305 | + //$where_auto .= " GROUP BY calls.id"; |
|
| 306 | 306 | |
| 307 | - if($where != "") |
|
| 308 | - $query .= "where $where AND ".$where_auto; |
|
| 309 | - else |
|
| 310 | - $query .= "where ".$where_auto; |
|
| 307 | + if($where != "") |
|
| 308 | + $query .= "where $where AND ".$where_auto; |
|
| 309 | + else |
|
| 310 | + $query .= "where ".$where_auto; |
|
| 311 | 311 | |
| 312 | 312 | $order_by = $this->process_order_by($order_by); |
| 313 | 313 | if (empty($order_by)) { |
@@ -315,14 +315,14 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | $query .= ' ORDER BY ' . $order_by; |
| 317 | 317 | |
| 318 | - return $query; |
|
| 319 | - } |
|
| 318 | + return $query; |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | 321 | function create_export_query($order_by, $where, $relate_link_join='') |
| 322 | 322 | { |
| 323 | 323 | $custom_join = $this->getCustomJoin(true, true, $where); |
| 324 | 324 | $custom_join['join'] .= $relate_link_join; |
| 325 | - $contact_required = stristr($where, "contacts"); |
|
| 325 | + $contact_required = stristr($where, "contacts"); |
|
| 326 | 326 | if($contact_required) |
| 327 | 327 | { |
| 328 | 328 | $query = "SELECT calls.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name "; |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
| 342 | - $query .= " LEFT JOIN users ON calls.assigned_user_id=users.id "; |
|
| 342 | + $query .= " LEFT JOIN users ON calls.assigned_user_id=users.id "; |
|
| 343 | 343 | |
| 344 | 344 | $query .= $custom_join['join']; |
| 345 | 345 | |
| 346 | - if($where != "") |
|
| 346 | + if($where != "") |
|
| 347 | 347 | $query .= "where $where AND ".$where_auto; |
| 348 | 348 | else |
| 349 | 349 | $query .= "where ".$where_auto; |
@@ -361,199 +361,199 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | |
| 363 | 363 | |
| 364 | - function fill_in_additional_detail_fields() |
|
| 365 | - { |
|
| 366 | - global $locale; |
|
| 367 | - parent::fill_in_additional_detail_fields(); |
|
| 368 | - if (!empty($this->contact_id)) { |
|
| 369 | - $query = "SELECT first_name, last_name FROM contacts "; |
|
| 370 | - $query .= "WHERE id='$this->contact_id' AND deleted=0"; |
|
| 371 | - $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: "); |
|
| 372 | - |
|
| 373 | - // Get the contact name. |
|
| 374 | - $row = $this->db->fetchByAssoc($result); |
|
| 375 | - $GLOBALS['log']->info("additional call fields $query"); |
|
| 376 | - if($row != null) |
|
| 377 | - { |
|
| 378 | - $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', ''); |
|
| 379 | - $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name"); |
|
| 380 | - $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id"); |
|
| 381 | - } |
|
| 382 | - } |
|
| 383 | - if (!isset($this->duration_minutes)) { |
|
| 384 | - $this->duration_minutes = $this->minutes_value_default; |
|
| 385 | - } |
|
| 364 | + function fill_in_additional_detail_fields() |
|
| 365 | + { |
|
| 366 | + global $locale; |
|
| 367 | + parent::fill_in_additional_detail_fields(); |
|
| 368 | + if (!empty($this->contact_id)) { |
|
| 369 | + $query = "SELECT first_name, last_name FROM contacts "; |
|
| 370 | + $query .= "WHERE id='$this->contact_id' AND deleted=0"; |
|
| 371 | + $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: "); |
|
| 372 | + |
|
| 373 | + // Get the contact name. |
|
| 374 | + $row = $this->db->fetchByAssoc($result); |
|
| 375 | + $GLOBALS['log']->info("additional call fields $query"); |
|
| 376 | + if($row != null) |
|
| 377 | + { |
|
| 378 | + $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', ''); |
|
| 379 | + $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name"); |
|
| 380 | + $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id"); |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | + if (!isset($this->duration_minutes)) { |
|
| 384 | + $this->duration_minutes = $this->minutes_value_default; |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | 387 | global $timedate; |
| 388 | 388 | //setting default date and time |
| 389 | - if (is_null($this->date_start)) { |
|
| 390 | - $this->date_start = $timedate->now(); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - if (is_null($this->duration_hours)) |
|
| 394 | - $this->duration_hours = "0"; |
|
| 395 | - if (is_null($this->duration_minutes)) |
|
| 396 | - $this->duration_minutes = "1"; |
|
| 397 | - |
|
| 398 | - $this->fill_in_additional_parent_fields(); |
|
| 399 | - |
|
| 400 | - global $app_list_strings; |
|
| 401 | - $parent_types = $app_list_strings['record_type_display']; |
|
| 402 | - $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
| 403 | - foreach($disabled_parent_types as $disabled_parent_type){ |
|
| 404 | - if($disabled_parent_type != $this->parent_type){ |
|
| 405 | - unset($parent_types[$disabled_parent_type]); |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type); |
|
| 410 | - |
|
| 411 | - if (empty($this->reminder_time)) { |
|
| 412 | - $this->reminder_time = -1; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - if ( empty($this->id) ) { |
|
| 416 | - $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
|
| 417 | - if ( isset($reminder_t) ) |
|
| 418 | - $this->reminder_time = $reminder_t; |
|
| 419 | - } |
|
| 420 | - $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
|
| 421 | - |
|
| 422 | - if (empty($this->email_reminder_time)) { |
|
| 423 | - $this->email_reminder_time = -1; |
|
| 424 | - } |
|
| 425 | - if(empty($this->id)){ |
|
| 426 | - $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
|
| 427 | - if(isset($reminder_t)) |
|
| 428 | - $this->email_reminder_time = $reminder_t; |
|
| 429 | - } |
|
| 430 | - $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
|
| 431 | - |
|
| 432 | - if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) { |
|
| 433 | - $this->parent_type = $_REQUEST['parent_type']; |
|
| 434 | - } elseif (is_null($this->parent_type)) { |
|
| 435 | - $this->parent_type = $app_list_strings['record_type_default_key']; |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - function get_list_view_data(){ |
|
| 441 | - $call_fields = $this->get_list_view_array(); |
|
| 442 | - global $app_list_strings, $focus, $action, $currentModule; |
|
| 443 | - if (isset($focus->id)) $id = $focus->id; |
|
| 444 | - else $id = ''; |
|
| 445 | - if (isset($this->parent_type) && $this->parent_type != null) |
|
| 446 | - { |
|
| 447 | - $call_fields['PARENT_MODULE'] = $this->parent_type; |
|
| 448 | - } |
|
| 449 | - if ($this->status == "Planned") { |
|
| 450 | - //cn: added this if() to deal with sequential Closes in Meetings. this is a hack to a hack (formbase.php->handleRedirect) |
|
| 451 | - if(empty($action)) |
|
| 452 | - $action = "index"; |
|
| 389 | + if (is_null($this->date_start)) { |
|
| 390 | + $this->date_start = $timedate->now(); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + if (is_null($this->duration_hours)) |
|
| 394 | + $this->duration_hours = "0"; |
|
| 395 | + if (is_null($this->duration_minutes)) |
|
| 396 | + $this->duration_minutes = "1"; |
|
| 397 | + |
|
| 398 | + $this->fill_in_additional_parent_fields(); |
|
| 399 | + |
|
| 400 | + global $app_list_strings; |
|
| 401 | + $parent_types = $app_list_strings['record_type_display']; |
|
| 402 | + $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
| 403 | + foreach($disabled_parent_types as $disabled_parent_type){ |
|
| 404 | + if($disabled_parent_type != $this->parent_type){ |
|
| 405 | + unset($parent_types[$disabled_parent_type]); |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type); |
|
| 410 | + |
|
| 411 | + if (empty($this->reminder_time)) { |
|
| 412 | + $this->reminder_time = -1; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + if ( empty($this->id) ) { |
|
| 416 | + $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
|
| 417 | + if ( isset($reminder_t) ) |
|
| 418 | + $this->reminder_time = $reminder_t; |
|
| 419 | + } |
|
| 420 | + $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
|
| 421 | + |
|
| 422 | + if (empty($this->email_reminder_time)) { |
|
| 423 | + $this->email_reminder_time = -1; |
|
| 424 | + } |
|
| 425 | + if(empty($this->id)){ |
|
| 426 | + $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
|
| 427 | + if(isset($reminder_t)) |
|
| 428 | + $this->email_reminder_time = $reminder_t; |
|
| 429 | + } |
|
| 430 | + $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
|
| 431 | + |
|
| 432 | + if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) { |
|
| 433 | + $this->parent_type = $_REQUEST['parent_type']; |
|
| 434 | + } elseif (is_null($this->parent_type)) { |
|
| 435 | + $this->parent_type = $app_list_strings['record_type_default_key']; |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + function get_list_view_data(){ |
|
| 441 | + $call_fields = $this->get_list_view_array(); |
|
| 442 | + global $app_list_strings, $focus, $action, $currentModule; |
|
| 443 | + if (isset($focus->id)) $id = $focus->id; |
|
| 444 | + else $id = ''; |
|
| 445 | + if (isset($this->parent_type) && $this->parent_type != null) |
|
| 446 | + { |
|
| 447 | + $call_fields['PARENT_MODULE'] = $this->parent_type; |
|
| 448 | + } |
|
| 449 | + if ($this->status == "Planned") { |
|
| 450 | + //cn: added this if() to deal with sequential Closes in Meetings. this is a hack to a hack (formbase.php->handleRedirect) |
|
| 451 | + if(empty($action)) |
|
| 452 | + $action = "index"; |
|
| 453 | 453 | |
| 454 | 454 | $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>"; |
| 455 | - if ($this->ACLAccess('edit')) { |
|
| 455 | + if ($this->ACLAccess('edit')) { |
|
| 456 | 456 | $call_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline"," border='0'",null,null,'.gif',translate('LBL_CLOSEINLINE'))."</a>"; |
| 457 | 457 | } else { |
| 458 | 458 | $call_fields['SET_COMPLETE'] = ''; |
| 459 | 459 | } |
| 460 | - } |
|
| 461 | - global $timedate; |
|
| 462 | - $today = $timedate->nowDb(); |
|
| 463 | - $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day")); |
|
| 464 | - $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']); |
|
| 465 | - $date_db = $timedate->to_db($mergeTime); |
|
| 466 | - if( $date_db < $today){ |
|
| 467 | - $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>"; |
|
| 468 | - }else if($date_db < $nextday){ |
|
| 469 | - $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>"; |
|
| 470 | - }else{ |
|
| 471 | - $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>"; |
|
| 472 | - } |
|
| 473 | - $this->fill_in_additional_detail_fields(); |
|
| 474 | - |
|
| 475 | - //make sure we grab the localized version of the contact name, if a contact is provided |
|
| 476 | - if (!empty($this->contact_id)) { |
|
| 477 | - // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs |
|
| 460 | + } |
|
| 461 | + global $timedate; |
|
| 462 | + $today = $timedate->nowDb(); |
|
| 463 | + $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day")); |
|
| 464 | + $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']); |
|
| 465 | + $date_db = $timedate->to_db($mergeTime); |
|
| 466 | + if( $date_db < $today){ |
|
| 467 | + $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>"; |
|
| 468 | + }else if($date_db < $nextday){ |
|
| 469 | + $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>"; |
|
| 470 | + }else{ |
|
| 471 | + $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>"; |
|
| 472 | + } |
|
| 473 | + $this->fill_in_additional_detail_fields(); |
|
| 474 | + |
|
| 475 | + //make sure we grab the localized version of the contact name, if a contact is provided |
|
| 476 | + if (!empty($this->contact_id)) { |
|
| 477 | + // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs |
|
| 478 | 478 | $contact_temp = BeanFactory::getBean("Contacts", $this->contact_id); |
| 479 | 479 | if(!empty($contact_temp)) { |
| 480 | 480 | $contact_temp->_create_proper_name_field(); |
| 481 | 481 | $this->contact_name = $contact_temp->full_name; |
| 482 | 482 | } |
| 483 | - } |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | 485 | $call_fields['CONTACT_ID'] = $this->contact_id; |
| 486 | 486 | $call_fields['CONTACT_NAME'] = $this->contact_name; |
| 487 | - $call_fields['PARENT_NAME'] = $this->parent_name; |
|
| 487 | + $call_fields['PARENT_NAME'] = $this->parent_name; |
|
| 488 | 488 | $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true; |
| 489 | - $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true; |
|
| 489 | + $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true; |
|
| 490 | 490 | |
| 491 | - return $call_fields; |
|
| 492 | - } |
|
| 491 | + return $call_fields; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - function set_notification_body($xtpl, $call) { |
|
| 495 | - global $sugar_config; |
|
| 496 | - global $app_list_strings; |
|
| 497 | - global $current_user; |
|
| 498 | - global $app_list_strings; |
|
| 499 | - global $timedate; |
|
| 494 | + function set_notification_body($xtpl, $call) { |
|
| 495 | + global $sugar_config; |
|
| 496 | + global $app_list_strings; |
|
| 497 | + global $current_user; |
|
| 498 | + global $app_list_strings; |
|
| 499 | + global $timedate; |
|
| 500 | 500 | |
| 501 | 501 | // rrs: bug 42684 - passing a contact breaks this call |
| 502 | - $notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user; |
|
| 503 | - |
|
| 504 | - |
|
| 505 | - // Assumes $call dates are in user format |
|
| 506 | - $calldate = $timedate->fromDb($call->date_start); |
|
| 507 | - $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser); |
|
| 508 | - |
|
| 509 | - if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) { |
|
| 510 | - $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 511 | - '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 512 | - } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) { |
|
| 513 | - $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 514 | - '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 515 | - } else { |
|
| 516 | - $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 517 | - '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name); |
|
| 521 | - $xtpl->assign("CALL_SUBJECT", $call->name); |
|
| 522 | - $xtpl->assign("CALL_STARTDATE", $xOffset); |
|
| 523 | - $xtpl->assign("CALL_HOURS", $call->duration_hours); |
|
| 524 | - $xtpl->assign("CALL_MINUTES", $call->duration_minutes); |
|
| 525 | - $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : "")); |
|
| 526 | - $xtpl->assign("CALL_DESCRIPTION", $call->description); |
|
| 527 | - |
|
| 528 | - return $xtpl; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - |
|
| 532 | - function get_call_users() { |
|
| 533 | - $template = new User(); |
|
| 534 | - // First, get the list of IDs. |
|
| 535 | - $query = "SELECT calls_users.required, calls_users.accept_status, calls_users.user_id from calls_users where calls_users.call_id='$this->id' AND calls_users.deleted=0"; |
|
| 536 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
| 537 | - $result = $this->db->query($query, true); |
|
| 538 | - $list = Array(); |
|
| 539 | - |
|
| 540 | - while($row = $this->db->fetchByAssoc($result)) { |
|
| 541 | - $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one |
|
| 542 | - $record = $template->retrieve($row['user_id']); |
|
| 543 | - $template->required = $row['required']; |
|
| 544 | - $template->accept_status = $row['accept_status']; |
|
| 545 | - |
|
| 546 | - if($record != null) { |
|
| 547 | - // this copies the object into the array |
|
| 548 | - $list[] = $template; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - return $list; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - |
|
| 555 | - function get_invite_calls(&$user) |
|
| 556 | - { |
|
| 502 | + $notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user; |
|
| 503 | + |
|
| 504 | + |
|
| 505 | + // Assumes $call dates are in user format |
|
| 506 | + $calldate = $timedate->fromDb($call->date_start); |
|
| 507 | + $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser); |
|
| 508 | + |
|
| 509 | + if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) { |
|
| 510 | + $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 511 | + '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 512 | + } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) { |
|
| 513 | + $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 514 | + '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 515 | + } else { |
|
| 516 | + $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 517 | + '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name); |
|
| 521 | + $xtpl->assign("CALL_SUBJECT", $call->name); |
|
| 522 | + $xtpl->assign("CALL_STARTDATE", $xOffset); |
|
| 523 | + $xtpl->assign("CALL_HOURS", $call->duration_hours); |
|
| 524 | + $xtpl->assign("CALL_MINUTES", $call->duration_minutes); |
|
| 525 | + $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : "")); |
|
| 526 | + $xtpl->assign("CALL_DESCRIPTION", $call->description); |
|
| 527 | + |
|
| 528 | + return $xtpl; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + |
|
| 532 | + function get_call_users() { |
|
| 533 | + $template = new User(); |
|
| 534 | + // First, get the list of IDs. |
|
| 535 | + $query = "SELECT calls_users.required, calls_users.accept_status, calls_users.user_id from calls_users where calls_users.call_id='$this->id' AND calls_users.deleted=0"; |
|
| 536 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
| 537 | + $result = $this->db->query($query, true); |
|
| 538 | + $list = Array(); |
|
| 539 | + |
|
| 540 | + while($row = $this->db->fetchByAssoc($result)) { |
|
| 541 | + $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one |
|
| 542 | + $record = $template->retrieve($row['user_id']); |
|
| 543 | + $template->required = $row['required']; |
|
| 544 | + $template->accept_status = $row['accept_status']; |
|
| 545 | + |
|
| 546 | + if($record != null) { |
|
| 547 | + // this copies the object into the array |
|
| 548 | + $list[] = $template; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + return $list; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + |
|
| 555 | + function get_invite_calls(&$user) |
|
| 556 | + { |
|
| 557 | 557 | $template = $this; |
| 558 | 558 | // First, get the list of IDs. |
| 559 | 559 | $query = "SELECT calls_users.required, calls_users.accept_status, calls_users.call_id from calls_users where calls_users.user_id='$user->id' AND ( calls_users.accept_status IS NULL OR calls_users.accept_status='none') AND calls_users.deleted=0"; |
@@ -568,182 +568,182 @@ discard block |
||
| 568 | 568 | |
| 569 | 569 | while($row = $this->db->fetchByAssoc($result)) |
| 570 | 570 | { |
| 571 | - $record = $template->retrieve($row['call_id']); |
|
| 572 | - $template->required = $row['required']; |
|
| 573 | - $template->accept_status = $row['accept_status']; |
|
| 571 | + $record = $template->retrieve($row['call_id']); |
|
| 572 | + $template->required = $row['required']; |
|
| 573 | + $template->accept_status = $row['accept_status']; |
|
| 574 | 574 | |
| 575 | 575 | |
| 576 | - if($record != null) |
|
| 577 | - { |
|
| 576 | + if($record != null) |
|
| 577 | + { |
|
| 578 | 578 | // this copies the object into the array |
| 579 | 579 | $list[] = $template; |
| 580 | - } |
|
| 580 | + } |
|
| 581 | 581 | } |
| 582 | 582 | return $list; |
| 583 | 583 | |
| 584 | - } |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | |
| 587 | - function set_accept_status(&$user,$status) |
|
| 588 | - { |
|
| 587 | + function set_accept_status(&$user,$status) |
|
| 588 | + { |
|
| 589 | 589 | if ( $user->object_name == 'User') |
| 590 | 590 | { |
| 591 | - $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id); |
|
| 592 | - $data_values = array('accept_status'=>$status); |
|
| 593 | - $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
| 594 | - global $current_user; |
|
| 591 | + $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id); |
|
| 592 | + $data_values = array('accept_status'=>$status); |
|
| 593 | + $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
| 594 | + global $current_user; |
|
| 595 | 595 | |
| 596 | - if ( $this->update_vcal ) |
|
| 597 | - { |
|
| 596 | + if ( $this->update_vcal ) |
|
| 597 | + { |
|
| 598 | 598 | vCal::cache_sugar_vcal($user); |
| 599 | - } |
|
| 599 | + } |
|
| 600 | 600 | } |
| 601 | 601 | else if ( $user->object_name == 'Contact') |
| 602 | 602 | { |
| 603 | - $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id); |
|
| 604 | - $data_values = array('accept_status'=>$status); |
|
| 605 | - $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values); |
|
| 603 | + $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id); |
|
| 604 | + $data_values = array('accept_status'=>$status); |
|
| 605 | + $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values); |
|
| 606 | 606 | } |
| 607 | 607 | else if ( $user->object_name == 'Lead') |
| 608 | 608 | { |
| 609 | - $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id); |
|
| 610 | - $data_values = array('accept_status'=>$status); |
|
| 611 | - $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values); |
|
| 609 | + $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id); |
|
| 610 | + $data_values = array('accept_status'=>$status); |
|
| 611 | + $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values); |
|
| 612 | + } |
|
| 612 | 613 | } |
| 613 | - } |
|
| 614 | 614 | |
| 615 | 615 | |
| 616 | 616 | |
| 617 | - function get_notification_recipients() { |
|
| 618 | - if($this->special_notification) { |
|
| 619 | - return parent::get_notification_recipients(); |
|
| 620 | - } |
|
| 617 | + function get_notification_recipients() { |
|
| 618 | + if($this->special_notification) { |
|
| 619 | + return parent::get_notification_recipients(); |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true)); |
| 623 | - $list = array(); |
|
| 623 | + $list = array(); |
|
| 624 | 624 | if(!is_array($this->contacts_arr)) { |
| 625 | - $this->contacts_arr = array(); |
|
| 626 | - } |
|
| 625 | + $this->contacts_arr = array(); |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - if(!is_array($this->users_arr)) { |
|
| 629 | - $this->users_arr = array(); |
|
| 630 | - } |
|
| 628 | + if(!is_array($this->users_arr)) { |
|
| 629 | + $this->users_arr = array(); |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | 632 | if(!is_array($this->leads_arr)) { |
| 633 | - $this->leads_arr = array(); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - foreach($this->users_arr as $user_id) { |
|
| 637 | - $notify_user = new User(); |
|
| 638 | - $notify_user->retrieve($user_id); |
|
| 639 | - $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 640 | - $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 641 | - $list[$notify_user->id] = $notify_user; |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - foreach($this->contacts_arr as $contact_id) { |
|
| 645 | - $notify_user = new Contact(); |
|
| 646 | - $notify_user->retrieve($contact_id); |
|
| 647 | - $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 648 | - $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 649 | - $list[$notify_user->id] = $notify_user; |
|
| 650 | - } |
|
| 633 | + $this->leads_arr = array(); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + foreach($this->users_arr as $user_id) { |
|
| 637 | + $notify_user = new User(); |
|
| 638 | + $notify_user->retrieve($user_id); |
|
| 639 | + $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 640 | + $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 641 | + $list[$notify_user->id] = $notify_user; |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + foreach($this->contacts_arr as $contact_id) { |
|
| 645 | + $notify_user = new Contact(); |
|
| 646 | + $notify_user->retrieve($contact_id); |
|
| 647 | + $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 648 | + $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 649 | + $list[$notify_user->id] = $notify_user; |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | 652 | foreach($this->leads_arr as $lead_id) { |
| 653 | - $notify_user = new Lead(); |
|
| 654 | - $notify_user->retrieve($lead_id); |
|
| 655 | - $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 656 | - $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 657 | - $list[$notify_user->id] = $notify_user; |
|
| 658 | - } |
|
| 659 | - global $sugar_config; |
|
| 660 | - if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
|
| 661 | - global $current_user; |
|
| 662 | - if(isset($list[$current_user->id])) |
|
| 663 | - unset($list[$current_user->id]); |
|
| 664 | - } |
|
| 653 | + $notify_user = new Lead(); |
|
| 654 | + $notify_user->retrieve($lead_id); |
|
| 655 | + $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 656 | + $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 657 | + $list[$notify_user->id] = $notify_user; |
|
| 658 | + } |
|
| 659 | + global $sugar_config; |
|
| 660 | + if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
|
| 661 | + global $current_user; |
|
| 662 | + if(isset($list[$current_user->id])) |
|
| 663 | + unset($list[$current_user->id]); |
|
| 664 | + } |
|
| 665 | 665 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true)); |
| 666 | - return $list; |
|
| 667 | - } |
|
| 666 | + return $list; |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | 669 | function bean_implements($interface){ |
| 670 | - switch($interface){ |
|
| 671 | - case 'ACL':return true; |
|
| 672 | - } |
|
| 673 | - return false; |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - function listviewACLHelper(){ |
|
| 677 | - $array_assign = parent::listviewACLHelper(); |
|
| 678 | - $is_owner = false; |
|
| 679 | - $in_group = false; //SECURITY GROUPS |
|
| 680 | - if(!empty($this->parent_name)){ |
|
| 681 | - |
|
| 682 | - if(!empty($this->parent_name_owner)){ |
|
| 683 | - global $current_user; |
|
| 684 | - $is_owner = $current_user->id == $this->parent_name_owner; |
|
| 685 | - } |
|
| 686 | - /* BEGIN - SECURITY GROUPS */ |
|
| 687 | - //parent_name_owner not being set for whatever reason so we need to figure this out |
|
| 688 | - else if(!empty($this->parent_type) && !empty($this->parent_id)) { |
|
| 689 | - global $current_user; |
|
| 670 | + switch($interface){ |
|
| 671 | + case 'ACL':return true; |
|
| 672 | + } |
|
| 673 | + return false; |
|
| 674 | + } |
|
| 675 | + |
|
| 676 | + function listviewACLHelper(){ |
|
| 677 | + $array_assign = parent::listviewACLHelper(); |
|
| 678 | + $is_owner = false; |
|
| 679 | + $in_group = false; //SECURITY GROUPS |
|
| 680 | + if(!empty($this->parent_name)){ |
|
| 681 | + |
|
| 682 | + if(!empty($this->parent_name_owner)){ |
|
| 683 | + global $current_user; |
|
| 684 | + $is_owner = $current_user->id == $this->parent_name_owner; |
|
| 685 | + } |
|
| 686 | + /* BEGIN - SECURITY GROUPS */ |
|
| 687 | + //parent_name_owner not being set for whatever reason so we need to figure this out |
|
| 688 | + else if(!empty($this->parent_type) && !empty($this->parent_id)) { |
|
| 689 | + global $current_user; |
|
| 690 | 690 | $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id); |
| 691 | 691 | if($parent_bean !== false) { |
| 692 | - $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 692 | + $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 693 | 693 | } |
| 694 | - } |
|
| 695 | - require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 696 | - $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view'); |
|
| 697 | - /* END - SECURITY GROUPS */ |
|
| 698 | - } |
|
| 699 | - |
|
| 700 | - /* BEGIN - SECURITY GROUPS */ |
|
| 701 | - /** |
|
| 694 | + } |
|
| 695 | + require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 696 | + $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view'); |
|
| 697 | + /* END - SECURITY GROUPS */ |
|
| 698 | + } |
|
| 699 | + |
|
| 700 | + /* BEGIN - SECURITY GROUPS */ |
|
| 701 | + /** |
|
| 702 | 702 | if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){ |
| 703 | - */ |
|
| 704 | - if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
| 705 | - /* END - SECURITY GROUPS */ |
|
| 706 | - $array_assign['PARENT'] = 'a'; |
|
| 707 | - }else{ |
|
| 708 | - $array_assign['PARENT'] = 'span'; |
|
| 709 | - } |
|
| 710 | - $is_owner = false; |
|
| 711 | - $in_group = false; //SECURITY GROUPS |
|
| 712 | - if(!empty($this->contact_name)){ |
|
| 713 | - |
|
| 714 | - if(!empty($this->contact_name_owner)){ |
|
| 715 | - global $current_user; |
|
| 716 | - $is_owner = $current_user->id == $this->contact_name_owner; |
|
| 717 | - } |
|
| 718 | - /* BEGIN - SECURITY GROUPS */ |
|
| 719 | - //contact_name_owner not being set for whatever reason so we need to figure this out |
|
| 720 | - else { |
|
| 721 | - global $current_user; |
|
| 703 | + */ |
|
| 704 | + if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
| 705 | + /* END - SECURITY GROUPS */ |
|
| 706 | + $array_assign['PARENT'] = 'a'; |
|
| 707 | + }else{ |
|
| 708 | + $array_assign['PARENT'] = 'span'; |
|
| 709 | + } |
|
| 710 | + $is_owner = false; |
|
| 711 | + $in_group = false; //SECURITY GROUPS |
|
| 712 | + if(!empty($this->contact_name)){ |
|
| 713 | + |
|
| 714 | + if(!empty($this->contact_name_owner)){ |
|
| 715 | + global $current_user; |
|
| 716 | + $is_owner = $current_user->id == $this->contact_name_owner; |
|
| 717 | + } |
|
| 718 | + /* BEGIN - SECURITY GROUPS */ |
|
| 719 | + //contact_name_owner not being set for whatever reason so we need to figure this out |
|
| 720 | + else { |
|
| 721 | + global $current_user; |
|
| 722 | 722 | $parent_bean = BeanFactory::getBean('Contacts',$this->contact_id); |
| 723 | 723 | if($parent_bean !== false) { |
| 724 | - $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 724 | + $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 725 | 725 | } |
| 726 | - } |
|
| 727 | - require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 728 | - $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); |
|
| 729 | - /* END - SECURITY GROUPS */ |
|
| 730 | - } |
|
| 731 | - /* BEGIN - SECURITY GROUPS */ |
|
| 732 | - /** |
|
| 726 | + } |
|
| 727 | + require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 728 | + $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); |
|
| 729 | + /* END - SECURITY GROUPS */ |
|
| 730 | + } |
|
| 731 | + /* BEGIN - SECURITY GROUPS */ |
|
| 732 | + /** |
|
| 733 | 733 | if( ACLController::checkAccess('Contacts', 'view', $is_owner)){ |
| 734 | - */ |
|
| 735 | - if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){ |
|
| 736 | - /* END - SECURITY GROUPS */ |
|
| 737 | - $array_assign['CONTACT'] = 'a'; |
|
| 738 | - }else{ |
|
| 739 | - $array_assign['CONTACT'] = 'span'; |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - return $array_assign; |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - function save_relationship_changes($is_update, $exclude = array()) { |
|
| 746 | - if(empty($this->in_workflow)) |
|
| 734 | + */ |
|
| 735 | + if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){ |
|
| 736 | + /* END - SECURITY GROUPS */ |
|
| 737 | + $array_assign['CONTACT'] = 'a'; |
|
| 738 | + }else{ |
|
| 739 | + $array_assign['CONTACT'] = 'span'; |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + return $array_assign; |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + function save_relationship_changes($is_update, $exclude = array()) { |
|
| 746 | + if(empty($this->in_workflow)) |
|
| 747 | 747 | { |
| 748 | 748 | if(empty($this->in_import)) |
| 749 | 749 | { |
@@ -751,12 +751,12 @@ discard block |
||
| 751 | 751 | //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship |
| 752 | 752 | if(!empty($GLOBALS['soap_server_object'])) |
| 753 | 753 | { |
| 754 | - $exclude = array('lead_id', 'contact_id', 'user_id'); |
|
| 755 | - } |
|
| 754 | + $exclude = array('lead_id', 'contact_id', 'user_id'); |
|
| 755 | + } |
|
| 756 | 756 | else |
| 757 | 757 | { |
| 758 | - $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id'); |
|
| 759 | - } |
|
| 758 | + $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id'); |
|
| 759 | + } |
|
| 760 | 760 | } |
| 761 | 761 | else |
| 762 | 762 | { |
@@ -765,15 +765,15 @@ discard block |
||
| 765 | 765 | |
| 766 | 766 | |
| 767 | 767 | } |
| 768 | - parent::save_relationship_changes($is_update, $exclude); |
|
| 769 | - } |
|
| 768 | + parent::save_relationship_changes($is_update, $exclude); |
|
| 769 | + } |
|
| 770 | 770 | |
| 771 | 771 | public function getDefaultStatus() |
| 772 | 772 | { |
| 773 | - $def = $this->field_defs['status']; |
|
| 774 | - if (isset($def['default'])) { |
|
| 775 | - return $def['default']; |
|
| 776 | - } else { |
|
| 773 | + $def = $this->field_defs['status']; |
|
| 774 | + if (isset($def['default'])) { |
|
| 775 | + return $def['default']; |
|
| 776 | + } else { |
|
| 777 | 777 | $app = return_app_list_strings_language($GLOBALS['current_language']); |
| 778 | 778 | if (isset($def['options']) && isset($app[$def['options']])) { |
| 779 | 779 | $keys = array_keys($app[$def['options']]); |