@@ -28,8 +28,9 @@ discard block |
||
| 28 | 28 | protected function log($message, $delimiter = "\n") |
| 29 | 29 | { |
| 30 | 30 | static $file = null; |
| 31 | - if ($file === null) |
|
| 32 | - $file = dirname(__FILE__) . '/../../cache/logs/viewer-debug.log'; |
|
| 31 | + if ($file === null) { |
|
| 32 | + $file = dirname(__FILE__) . '/../../cache/logs/viewer-debug.log'; |
|
| 33 | + } |
|
| 33 | 34 | if (self::$debugViewer) { |
| 34 | 35 | file_put_contents($file, $message . $delimiter, FILE_APPEND); |
| 35 | 36 | } |
@@ -173,10 +174,11 @@ discard block |
||
| 173 | 174 | foreach ($this->tpl_vars as $key => $smarty_variable) { |
| 174 | 175 | // Determine type of value being pased. |
| 175 | 176 | $valueType = 'literal'; |
| 176 | - if (is_object($smarty_variable->value)) |
|
| 177 | - $valueType = get_class($smarty_variable->value); |
|
| 178 | - else if (is_array($smarty_variable->value)) |
|
| 179 | - $valueType = 'array'; |
|
| 177 | + if (is_object($smarty_variable->value)) { |
|
| 178 | + $valueType = get_class($smarty_variable->value); |
|
| 179 | + } else if (is_array($smarty_variable->value)) { |
|
| 180 | + $valueType = 'array'; |
|
| 181 | + } |
|
| 180 | 182 | $this->log(sprintf("DATA: %s, TYPE: %s", $key, $valueType)); |
| 181 | 183 | } |
| 182 | 184 | } |
@@ -19,7 +19,9 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * @ignore |
| 21 | 21 | */ |
| 22 | -if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); |
|
| 22 | +if (!defined('LOG4PHP_DIR')) { |
|
| 23 | + define('LOG4PHP_DIR', dirname(__FILE__)); |
|
| 24 | +} |
|
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | */ |
@@ -102,8 +104,9 @@ discard block |
||
| 102 | 104 | { |
| 103 | 105 | static $instance; |
| 104 | 106 | |
| 105 | - if (!isset($instance)) |
|
| 106 | - $instance = new LoggerHierarchy(new LoggerRoot()); |
|
| 107 | + if (!isset($instance)) { |
|
| 108 | + $instance = new LoggerHierarchy(new LoggerRoot()); |
|
| 109 | + } |
|
| 107 | 110 | return $instance; |
| 108 | 111 | } |
| 109 | 112 | |
@@ -266,8 +269,9 @@ discard block |
||
| 266 | 269 | */ |
| 267 | 270 | public function &getRootLogger() |
| 268 | 271 | { |
| 269 | - if (!isset($this->root) || $this->root === null) |
|
| 270 | - $this->root = new LoggerRoot(); |
|
| 272 | + if (!isset($this->root) || $this->root === null) { |
|
| 273 | + $this->root = new LoggerRoot(); |
|
| 274 | + } |
|
| 271 | 275 | return $this->root; |
| 272 | 276 | } |
| 273 | 277 | |
@@ -355,8 +359,9 @@ discard block |
||
| 355 | 359 | */ |
| 356 | 360 | public function setThreshold($l) |
| 357 | 361 | { |
| 358 | - if ($l !== null) |
|
| 359 | - $this->threshold = $l; |
|
| 362 | + if ($l !== null) { |
|
| 363 | + $this->threshold = $l; |
|
| 364 | + } |
|
| 360 | 365 | } |
| 361 | 366 | |
| 362 | 367 | /** |
@@ -19,7 +19,9 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * @ignore |
| 21 | 21 | */ |
| 22 | -if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); |
|
| 22 | +if (!defined('LOG4PHP_DIR')) { |
|
| 23 | + define('LOG4PHP_DIR', dirname(__FILE__)); |
|
| 24 | +} |
|
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | */ |
@@ -55,8 +57,9 @@ discard block |
||
| 55 | 57 | public function LoggerRoot($level = null) |
| 56 | 58 | { |
| 57 | 59 | $this->Logger($this->name); |
| 58 | - if ($level === null) |
|
| 59 | - $level = LoggerLevel::getLevelAll(); |
|
| 60 | + if ($level === null) { |
|
| 61 | + $level = LoggerLevel::getLevelAll(); |
|
| 62 | + } |
|
| 60 | 63 | $this->setLevel($level); |
| 61 | 64 | } |
| 62 | 65 | |
@@ -106,7 +106,9 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // Checking if the principal is in the prefix |
| 108 | 108 | list($rowPrefix) = URLUtil::splitPath($row['uri']); |
| 109 | - if ($rowPrefix !== $prefixPath) continue; |
|
| 109 | + if ($rowPrefix !== $prefixPath) { |
|
| 110 | + continue; |
|
| 111 | + } |
|
| 110 | 112 | |
| 111 | 113 | $principal = [ |
| 112 | 114 | 'uri' => $row['uri'], |
@@ -146,7 +148,9 @@ discard block |
||
| 146 | 148 | $stmt->execute([$path]); |
| 147 | 149 | |
| 148 | 150 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 149 | - if (!$row) return; |
|
| 151 | + if (!$row) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 150 | 154 | |
| 151 | 155 | $principal = [ |
| 152 | 156 | 'id' => $row['id'], |
@@ -240,7 +244,10 @@ discard block |
||
| 240 | 244 | * @return array |
| 241 | 245 | */ |
| 242 | 246 | public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { |
| 243 | - if (count($searchProperties) == 0) return []; //No criteria |
|
| 247 | + if (count($searchProperties) == 0) { |
|
| 248 | + return []; |
|
| 249 | + } |
|
| 250 | + //No criteria |
|
| 244 | 251 | |
| 245 | 252 | $query = sprintf('SELECT uri FROM %s WHERE ', $this->tableName); |
| 246 | 253 | $values = []; |
@@ -256,7 +263,9 @@ discard block |
||
| 256 | 263 | // Unsupported property |
| 257 | 264 | return []; |
| 258 | 265 | } |
| 259 | - if (count($values) > 0) $query .= (strcmp($test, "anyof") == 0 ? " || " : " && "); |
|
| 266 | + if (count($values) > 0) { |
|
| 267 | + $query .= (strcmp($test, "anyof") == 0 ? " || " : " && "); |
|
| 268 | + } |
|
| 260 | 269 | $query .= 'lower(' . $column . ') LIKE lower(?)'; |
| 261 | 270 | $values[] = '%' . $value . '%'; |
| 262 | 271 | |
@@ -269,7 +278,9 @@ discard block |
||
| 269 | 278 | |
| 270 | 279 | // Checking if the principal is in the prefix |
| 271 | 280 | list($rowPrefix) = URLUtil::splitPath($row['uri']); |
| 272 | - if ($rowPrefix !== $prefixPath) continue; |
|
| 281 | + if ($rowPrefix !== $prefixPath) { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 273 | 284 | |
| 274 | 285 | $principals[] = $row['uri']; |
| 275 | 286 | |
@@ -300,7 +311,9 @@ discard block |
||
| 300 | 311 | $value = null; |
| 301 | 312 | $scheme = null; |
| 302 | 313 | list($scheme, $value) = explode(":", $uri, 2); |
| 303 | - if ($value === null) return null; |
|
| 314 | + if ($value === null) { |
|
| 315 | + return null; |
|
| 316 | + } |
|
| 304 | 317 | |
| 305 | 318 | $uri = null; |
| 306 | 319 | switch ($scheme){ |
@@ -312,7 +325,9 @@ discard block |
||
| 312 | 325 | while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
| 313 | 326 | // Checking if the principal is in the prefix |
| 314 | 327 | list($rowPrefix) = URLUtil::splitPath($row['uri']); |
| 315 | - if ($rowPrefix !== $principalPrefix) continue; |
|
| 328 | + if ($rowPrefix !== $principalPrefix) { |
|
| 329 | + continue; |
|
| 330 | + } |
|
| 316 | 331 | |
| 317 | 332 | $uri = $row['uri']; |
| 318 | 333 | break; //Stop on first match |
@@ -334,7 +349,9 @@ discard block |
||
| 334 | 349 | public function getGroupMemberSet($principal) { |
| 335 | 350 | |
| 336 | 351 | $principal = $this->getPrincipalByPath($principal); |
| 337 | - if (!$principal) throw new DAV\Exception('Principal not found'); |
|
| 352 | + if (!$principal) { |
|
| 353 | + throw new DAV\Exception('Principal not found'); |
|
| 354 | + } |
|
| 338 | 355 | |
| 339 | 356 | $query = 'SELECT principals.uri as uri FROM %s AS groupmembers LEFT JOIN %s AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'; |
| 340 | 357 | $query = sprintf($query, $this->groupMembersTableName, $this->tableName); |
@@ -358,7 +375,9 @@ discard block |
||
| 358 | 375 | public function getGroupMembership($principal) { |
| 359 | 376 | |
| 360 | 377 | $principal = $this->getPrincipalByPath($principal); |
| 361 | - if (!$principal) throw new DAV\Exception('Principal not found'); |
|
| 378 | + if (!$principal) { |
|
| 379 | + throw new DAV\Exception('Principal not found'); |
|
| 380 | + } |
|
| 362 | 381 | |
| 363 | 382 | $stmt = $this->pdo->prepare(sprintf('SELECT principals.uri as uri FROM %s AS groupmembers LEFT JOIN %s AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?', $this->groupMembersTableName, $this->tableName)); |
| 364 | 383 | $stmt->execute([$principal['id']]); |
@@ -396,7 +415,9 @@ discard block |
||
| 396 | 415 | $memberIds[] = $row['id']; |
| 397 | 416 | } |
| 398 | 417 | } |
| 399 | - if (!$principalId) throw new DAV\Exception('Principal not found'); |
|
| 418 | + if (!$principalId) { |
|
| 419 | + throw new DAV\Exception('Principal not found'); |
|
| 420 | + } |
|
| 400 | 421 | |
| 401 | 422 | // Wiping out old members |
| 402 | 423 | $stmt = $this->pdo->prepare(sprintf('DELETE FROM %s WHERE principal_id = ?;', $this->groupMembersTableName)); |
@@ -29,8 +29,9 @@ discard block |
||
| 29 | 29 | protected function log($message, $delimiter = '\n') |
| 30 | 30 | { |
| 31 | 31 | static $file = null; |
| 32 | - if ($file === null) |
|
| 33 | - $file = dirname(__FILE__) . '/../../cache/logs/viewer-debug.log'; |
|
| 32 | + if ($file === null) { |
|
| 33 | + $file = dirname(__FILE__) . '/../../cache/logs/viewer-debug.log'; |
|
| 34 | + } |
|
| 34 | 35 | if (self::$debugViewer) { |
| 35 | 36 | file_put_contents($file, $message . $delimiter, FILE_APPEND); |
| 36 | 37 | } |
@@ -177,10 +178,11 @@ discard block |
||
| 177 | 178 | foreach ($this->tpl_vars as $key => $smarty_variable) { |
| 178 | 179 | // Determine type of value being pased. |
| 179 | 180 | $valueType = 'literal'; |
| 180 | - if (is_object($smarty_variable->value)) |
|
| 181 | - $valueType = get_class($smarty_variable->value); |
|
| 182 | - else if (is_array($smarty_variable->value)) |
|
| 183 | - $valueType = 'array'; |
|
| 181 | + if (is_object($smarty_variable->value)) { |
|
| 182 | + $valueType = get_class($smarty_variable->value); |
|
| 183 | + } else if (is_array($smarty_variable->value)) { |
|
| 184 | + $valueType = 'array'; |
|
| 185 | + } |
|
| 184 | 186 | $this->log(sprintf("DATA: %s, TYPE: %s", $key, $valueType)); |
| 185 | 187 | } |
| 186 | 188 | } |
@@ -169,8 +169,9 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | //to get the owner id |
| 171 | 171 | $ownerid = $this->column_fields['assigned_user_id']; |
| 172 | - if (!isset($ownerid) || $ownerid == '') |
|
| 173 | - $ownerid = $current_user->id; |
|
| 172 | + if (!isset($ownerid) || $ownerid == '') { |
|
| 173 | + $ownerid = $current_user->id; |
|
| 174 | + } |
|
| 174 | 175 | |
| 175 | 176 | if (isset($file_details['original_name']) && $file_details['original_name'] != null) { |
| 176 | 177 | $file_name = $file_details['original_name']; |
@@ -337,16 +338,18 @@ discard block |
||
| 337 | 338 | } else { |
| 338 | 339 | $this->id = $this->newRecord; |
| 339 | 340 | } |
| 340 | - if (empty($currentUser->id)) |
|
| 341 | - $currentUser->id = 0; |
|
| 341 | + if (empty($currentUser->id)) { |
|
| 342 | + $currentUser->id = 0; |
|
| 343 | + } |
|
| 342 | 344 | |
| 343 | 345 | // Customization |
| 344 | 346 | $created_date_var = $adb->formatDate($date_var, true); |
| 345 | 347 | $modified_date_var = $adb->formatDate($date_var, true); |
| 346 | 348 | // Preserve the timestamp |
| 347 | 349 | if (self::isBulkSaveMode()) { |
| 348 | - if (!empty($this->column_fields['createdtime'])) |
|
| 349 | - $created_date_var = $adb->formatDate($this->column_fields['createdtime'], true); |
|
| 350 | + if (!empty($this->column_fields['createdtime'])) { |
|
| 351 | + $created_date_var = $adb->formatDate($this->column_fields['createdtime'], true); |
|
| 352 | + } |
|
| 350 | 353 | //NOTE : modifiedtime ignored to support vtws_sync API track changes. |
| 351 | 354 | } |
| 352 | 355 | // END |
@@ -376,10 +379,11 @@ discard block |
||
| 376 | 379 | private function resolve_query_result_value($result, $index, $columnname) |
| 377 | 380 | { |
| 378 | 381 | $adb = PearDatabase::getInstance(); |
| 379 | - if (is_array($result)) |
|
| 380 | - return $result[$index][$columnname]; |
|
| 381 | - else |
|
| 382 | - return $adb->query_result($result, $index, $columnname); |
|
| 382 | + if (is_array($result)) { |
|
| 383 | + return $result[$index][$columnname]; |
|
| 384 | + } else { |
|
| 385 | + return $adb->query_result($result, $index, $columnname); |
|
| 386 | + } |
|
| 383 | 387 | } |
| 384 | 388 | |
| 385 | 389 | /** Function to insert values in the specifed table for the specified module |
@@ -595,10 +599,10 @@ discard block |
||
| 595 | 599 | } else { |
| 596 | 600 | $fldvalue = $this->column_fields[$fieldname]; |
| 597 | 601 | } |
| 598 | - if ($uitype != 33 && $uitype != 8) |
|
| 599 | - $fldvalue = \vtlib\Functions::fromHTML($fldvalue, ($insertion_mode == 'edit') ? true : false); |
|
| 600 | - } |
|
| 601 | - else { |
|
| 602 | + if ($uitype != 33 && $uitype != 8) { |
|
| 603 | + $fldvalue = \vtlib\Functions::fromHTML($fldvalue, ($insertion_mode == 'edit') ? true : false); |
|
| 604 | + } |
|
| 605 | + } else { |
|
| 602 | 606 | $fldvalue = ''; |
| 603 | 607 | } |
| 604 | 608 | |
@@ -656,8 +660,9 @@ discard block |
||
| 656 | 660 | $query1 = "select * from vtiger_seattachmentsrel where crmid=?"; |
| 657 | 661 | $result = $adb->pquery($query1, array($notesid)); |
| 658 | 662 | $noofrows = $adb->num_rows($result); |
| 659 | - if ($noofrows != 0) |
|
| 660 | - $attachmentid = $adb->query_result($result, 0, 'attachmentsid'); |
|
| 663 | + if ($noofrows != 0) { |
|
| 664 | + $attachmentid = $adb->query_result($result, 0, 'attachmentsid'); |
|
| 665 | + } |
|
| 661 | 666 | if ($attachmentid != '') { |
| 662 | 667 | $query2 = "select * from vtiger_attachments where attachmentsid=?"; |
| 663 | 668 | $filename = $adb->query_result($adb->pquery($query2, array($attachmentid)), 0, 'name'); |
@@ -708,10 +713,11 @@ discard block |
||
| 708 | 713 | // Lookup module field cache |
| 709 | 714 | if ($module == 'Calendar' || $module == 'Events') { |
| 710 | 715 | getColumnFields('Calendar'); |
| 711 | - if (VTCacheUtils::lookupFieldInfo_Module('Events')) |
|
| 712 | - $cachedEventsFields = VTCacheUtils::lookupFieldInfo_Module('Events'); |
|
| 713 | - else |
|
| 714 | - $cachedEventsFields = []; |
|
| 716 | + if (VTCacheUtils::lookupFieldInfo_Module('Events')) { |
|
| 717 | + $cachedEventsFields = VTCacheUtils::lookupFieldInfo_Module('Events'); |
|
| 718 | + } else { |
|
| 719 | + $cachedEventsFields = []; |
|
| 720 | + } |
|
| 715 | 721 | $cachedCalendarFields = VTCacheUtils::lookupFieldInfo_Module('Calendar'); |
| 716 | 722 | $cachedModuleFields = array_merge($cachedEventsFields, $cachedCalendarFields); |
| 717 | 723 | $module = 'Calendar'; |
@@ -856,10 +862,11 @@ discard block |
||
| 856 | 862 | while ($row = $this->db->fetchByAssoc($result)) { |
| 857 | 863 | $rowid = $row[$this->table_index]; |
| 858 | 864 | |
| 859 | - if (isset($rowid)) |
|
| 860 | - $this->retrieve_entity_info($rowid, $this->module_name); |
|
| 861 | - else |
|
| 862 | - $this->db->println("rowid not set unable to retrieve"); |
|
| 865 | + if (isset($rowid)) { |
|
| 866 | + $this->retrieve_entity_info($rowid, $this->module_name); |
|
| 867 | + } else { |
|
| 868 | + $this->db->println("rowid not set unable to retrieve"); |
|
| 869 | + } |
|
| 863 | 870 | |
| 864 | 871 | |
| 865 | 872 | |
@@ -872,10 +879,11 @@ discard block |
||
| 872 | 879 | } |
| 873 | 880 | } |
| 874 | 881 | |
| 875 | - if (isset($list)) |
|
| 876 | - return $list; |
|
| 877 | - else |
|
| 878 | - return null; |
|
| 882 | + if (isset($list)) { |
|
| 883 | + return $list; |
|
| 884 | + } else { |
|
| 885 | + return null; |
|
| 886 | + } |
|
| 879 | 887 | } |
| 880 | 888 | |
| 881 | 889 | /** This function should be overridden in each module. It marks an item as deleted. |
@@ -1045,19 +1053,22 @@ discard block |
||
| 1045 | 1053 | require_once('include/utils/UserInfoUtil.php'); |
| 1046 | 1054 | foreach ($this->column_fields as $fieldname => $fieldvalue) { |
| 1047 | 1055 | $reset_value = false; |
| 1048 | - if (getFieldVisibilityPermission($moduleName, $current_user->id, $fieldname) != '0') |
|
| 1049 | - $reset_value = true; |
|
| 1056 | + if (getFieldVisibilityPermission($moduleName, $current_user->id, $fieldname) != '0') { |
|
| 1057 | + $reset_value = true; |
|
| 1058 | + } |
|
| 1050 | 1059 | |
| 1051 | - if ($fieldname == "record_id" || $fieldname == "record_module") |
|
| 1052 | - $reset_value = false; |
|
| 1060 | + if ($fieldname == "record_id" || $fieldname == "record_module") { |
|
| 1061 | + $reset_value = false; |
|
| 1062 | + } |
|
| 1053 | 1063 | |
| 1054 | 1064 | /* |
| 1055 | 1065 | if (isset($this->additional_column_fields) && in_array($fieldname, $this->additional_column_fields) === true) |
| 1056 | 1066 | $reset_value = false; |
| 1057 | 1067 | */ |
| 1058 | 1068 | |
| 1059 | - if ($reset_value === true) |
|
| 1060 | - $this->column_fields[$fieldname] = ""; |
|
| 1069 | + if ($reset_value === true) { |
|
| 1070 | + $this->column_fields[$fieldname] = ""; |
|
| 1071 | + } |
|
| 1061 | 1072 | } |
| 1062 | 1073 | } |
| 1063 | 1074 | |
@@ -1103,8 +1114,9 @@ discard block |
||
| 1103 | 1114 | } |
| 1104 | 1115 | |
| 1105 | 1116 | foreach ($colf as $key => $value) { |
| 1106 | - if (getFieldVisibilityPermission($module, $current_user->id, $key, 'readwrite') == '0') |
|
| 1107 | - $this->importable_fields[$key] = $value; |
|
| 1117 | + if (getFieldVisibilityPermission($module, $current_user->id, $key, 'readwrite') == '0') { |
|
| 1118 | + $this->importable_fields[$key] = $value; |
|
| 1119 | + } |
|
| 1108 | 1120 | } |
| 1109 | 1121 | } |
| 1110 | 1122 | |
@@ -1354,13 +1366,15 @@ discard block |
||
| 1354 | 1366 | $num_rows = $adb->num_rows($result); |
| 1355 | 1367 | for ($i = 0; $i < $num_rows; $i++) { |
| 1356 | 1368 | $columnname = $adb->query_result($result, $i, 'columnname'); |
| 1357 | - if (in_array($columnname, $this->sortby_fields)) |
|
| 1358 | - continue; |
|
| 1359 | - else |
|
| 1360 | - $this->sortby_fields[] = $columnname; |
|
| 1369 | + if (in_array($columnname, $this->sortby_fields)) { |
|
| 1370 | + continue; |
|
| 1371 | + } else { |
|
| 1372 | + $this->sortby_fields[] = $columnname; |
|
| 1373 | + } |
|
| 1374 | + } |
|
| 1375 | + if ($tabid == 21 || $tabid == 22) { |
|
| 1376 | + $this->sortby_fields[] = 'crmid'; |
|
| 1361 | 1377 | } |
| 1362 | - if ($tabid == 21 || $tabid == 22) |
|
| 1363 | - $this->sortby_fields[] = 'crmid'; |
|
| 1364 | 1378 | $log->debug("Exiting initSortByField"); |
| 1365 | 1379 | } |
| 1366 | 1380 | /* Function to check if the mod number already exits */ |
@@ -1370,10 +1384,11 @@ discard block |
||
| 1370 | 1384 | $adb = PearDatabase::getInstance(); |
| 1371 | 1385 | $result = $adb->pquery(sprintf("SELECT %s FROM *s WHERE %s = ?", $adb->sql_escape_string($column), $adb->sql_escape_string($table), $adb->sql_escape_string($column)), [$no]); |
| 1372 | 1386 | $num_rows = $adb->num_rows($result); |
| 1373 | - if ($num_rows > 0) |
|
| 1374 | - return true; |
|
| 1375 | - else |
|
| 1376 | - return false; |
|
| 1387 | + if ($num_rows > 0) { |
|
| 1388 | + return true; |
|
| 1389 | + } else { |
|
| 1390 | + return false; |
|
| 1391 | + } |
|
| 1377 | 1392 | } |
| 1378 | 1393 | |
| 1379 | 1394 | // END |
@@ -1386,8 +1401,9 @@ discard block |
||
| 1386 | 1401 | |
| 1387 | 1402 | vtlib_setup_modulevars($module, $this); |
| 1388 | 1403 | $tabid = \includes\Modules::getModuleId($module); |
| 1389 | - if (!\includes\fields\RecordNumber::isModuleSequenceConfigured($tabid)) |
|
| 1390 | - return; |
|
| 1404 | + if (!\includes\fields\RecordNumber::isModuleSequenceConfigured($tabid)) { |
|
| 1405 | + return; |
|
| 1406 | + } |
|
| 1391 | 1407 | $fieldinfo = $adb->pquery("SELECT * FROM vtiger_field WHERE tabid = ? && uitype = 4", Array($tabid)); |
| 1392 | 1408 | |
| 1393 | 1409 | $returninfo = []; |
@@ -1441,8 +1457,9 @@ discard block |
||
| 1441 | 1457 | $singular_modname = vtlib_toSingular($related_module); |
| 1442 | 1458 | $button = ''; |
| 1443 | 1459 | if ($actions) { |
| 1444 | - if (is_string($actions)) |
|
| 1445 | - $actions = explode(',', strtoupper($actions)); |
|
| 1460 | + if (is_string($actions)) { |
|
| 1461 | + $actions = explode(',', strtoupper($actions)); |
|
| 1462 | + } |
|
| 1446 | 1463 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
| 1447 | 1464 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "'> "; |
| 1448 | 1465 | } |
@@ -1455,10 +1472,11 @@ discard block |
||
| 1455 | 1472 | } |
| 1456 | 1473 | |
| 1457 | 1474 | // To make the edit or del link actions to return back to same view. |
| 1458 | - if ($singlepane_view == 'true') |
|
| 1459 | - $returnset = "&return_module=$this_module&return_action=DetailView&return_id=$id"; |
|
| 1460 | - else |
|
| 1461 | - $returnset = "&return_module=$this_module&return_action=CallRelatedList&return_id=$id"; |
|
| 1475 | + if ($singlepane_view == 'true') { |
|
| 1476 | + $returnset = "&return_module=$this_module&return_action=DetailView&return_id=$id"; |
|
| 1477 | + } else { |
|
| 1478 | + $returnset = "&return_module=$this_module&return_action=CallRelatedList&return_id=$id"; |
|
| 1479 | + } |
|
| 1462 | 1480 | |
| 1463 | 1481 | $userNameSql = \vtlib\Deprecated::getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', |
| 1464 | 1482 | 'last_name' => 'vtiger_users.last_name'), 'Users'); |
@@ -1480,8 +1498,9 @@ discard block |
||
| 1480 | 1498 | |
| 1481 | 1499 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
| 1482 | 1500 | |
| 1483 | - if ($return_value === null) |
|
| 1484 | - $return_value = []; |
|
| 1501 | + if ($return_value === null) { |
|
| 1502 | + $return_value = []; |
|
| 1503 | + } |
|
| 1485 | 1504 | $return_value['CUSTOM_BUTTON'] = $button; |
| 1486 | 1505 | return $return_value; |
| 1487 | 1506 | } |
@@ -1513,8 +1532,9 @@ discard block |
||
| 1513 | 1532 | return true; |
| 1514 | 1533 | } else if ($lastviewed && $modifiedon) { |
| 1515 | 1534 | /** Lastviewed and Modified time is available. */ |
| 1516 | - if ($this->__timediff($modifiedon, $lastviewed) > 0) |
|
| 1517 | - return true; |
|
| 1535 | + if ($this->__timediff($modifiedon, $lastviewed) > 0) { |
|
| 1536 | + return true; |
|
| 1537 | + } |
|
| 1518 | 1538 | } |
| 1519 | 1539 | } |
| 1520 | 1540 | return false; |
@@ -1534,8 +1554,9 @@ discard block |
||
| 1534 | 1554 | |
| 1535 | 1555 | $t2 = mktime($t2_h, $t2_i, $t2_s, $t2_m, $t2_d, $t2_y); |
| 1536 | 1556 | |
| 1537 | - if ($t1 == $t2) |
|
| 1538 | - return 0; |
|
| 1557 | + if ($t1 == $t2) { |
|
| 1558 | + return 0; |
|
| 1559 | + } |
|
| 1539 | 1560 | return $t2 - $t1; |
| 1540 | 1561 | } |
| 1541 | 1562 | |
@@ -1555,8 +1576,9 @@ discard block |
||
| 1555 | 1576 | */ |
| 1556 | 1577 | public function save_related_module($module, $crmid, $withModule, $withCrmid, $relatedName = false) |
| 1557 | 1578 | { |
| 1558 | - if (!is_array($withCrmid)) |
|
| 1559 | - $withCrmid = [$withCrmid]; |
|
| 1579 | + if (!is_array($withCrmid)) { |
|
| 1580 | + $withCrmid = [$withCrmid]; |
|
| 1581 | + } |
|
| 1560 | 1582 | switch ($relatedName) { |
| 1561 | 1583 | case 'get_many_to_many': |
| 1562 | 1584 | $this->saveRelatedM2M($module, $crmid, $withModule, $withCrmid); |
@@ -1577,8 +1599,9 @@ discard block |
||
| 1577 | 1599 | foreach ($withCrmid as $relcrmid) { |
| 1578 | 1600 | $check = $db->pquery(sprintf('SELECT 1 FROM `%s` WHERE %s = ? && %s = ?', $referenceInfo['table'], $referenceInfo['base'], $referenceInfo['rel']), [$relcrmid, $crmid]); |
| 1579 | 1601 | // Relation already exists? No need to add again |
| 1580 | - if ($check && $db->getRowCount($check)) |
|
| 1581 | - continue; |
|
| 1602 | + if ($check && $db->getRowCount($check)) { |
|
| 1603 | + continue; |
|
| 1604 | + } |
|
| 1582 | 1605 | $db->insert($referenceInfo['table'], [ |
| 1583 | 1606 | $referenceInfo['base'] => $relcrmid, |
| 1584 | 1607 | $referenceInfo['rel'] => $crmid |
@@ -1594,8 +1617,9 @@ discard block |
||
| 1594 | 1617 | if ($withModule == 'Documents') { |
| 1595 | 1618 | $checkpresence = $db->pquery('SELECT crmid FROM vtiger_senotesrel WHERE crmid = ? && notesid = ?', [$crmid, $relcrmid]); |
| 1596 | 1619 | // Relation already exists? No need to add again |
| 1597 | - if ($checkpresence && $db->getRowCount($checkpresence)) |
|
| 1598 | - continue; |
|
| 1620 | + if ($checkpresence && $db->getRowCount($checkpresence)) { |
|
| 1621 | + continue; |
|
| 1622 | + } |
|
| 1599 | 1623 | |
| 1600 | 1624 | $db->insert('vtiger_senotesrel', [ |
| 1601 | 1625 | 'crmid' => $crmid, |
@@ -1605,8 +1629,9 @@ discard block |
||
| 1605 | 1629 | $checkpresence = $db->pquery('SELECT crmid FROM vtiger_crmentityrel WHERE crmid = ? && module = ? && relcrmid = ? && relmodule = ?', [$crmid, $module, $relcrmid, $withModule] |
| 1606 | 1630 | ); |
| 1607 | 1631 | // Relation already exists? No need to add again |
| 1608 | - if ($checkpresence && $db->getRowCount($checkpresence)) |
|
| 1609 | - continue; |
|
| 1632 | + if ($checkpresence && $db->getRowCount($checkpresence)) { |
|
| 1633 | + continue; |
|
| 1634 | + } |
|
| 1610 | 1635 | |
| 1611 | 1636 | $db->insert('vtiger_crmentityrel', [ |
| 1612 | 1637 | 'crmid' => $crmid, |
@@ -1630,8 +1655,9 @@ discard block |
||
| 1630 | 1655 | public function delete_related_module($module, $crmid, $withModule, $withCrmid) |
| 1631 | 1656 | { |
| 1632 | 1657 | $db = PearDatabase::getInstance(); |
| 1633 | - if (!is_array($withCrmid)) |
|
| 1634 | - $withCrmid = Array($withCrmid); |
|
| 1658 | + if (!is_array($withCrmid)) { |
|
| 1659 | + $withCrmid = Array($withCrmid); |
|
| 1660 | + } |
|
| 1635 | 1661 | foreach ($withCrmid as $relcrmid) { |
| 1636 | 1662 | |
| 1637 | 1663 | if ($withModule == 'Documents') { |
@@ -1665,8 +1691,9 @@ discard block |
||
| 1665 | 1691 | |
| 1666 | 1692 | $button = ''; |
| 1667 | 1693 | if ($actions) { |
| 1668 | - if (is_string($actions)) |
|
| 1669 | - $actions = explode(',', strtoupper($actions)); |
|
| 1694 | + if (is_string($actions)) { |
|
| 1695 | + $actions = explode(',', strtoupper($actions)); |
|
| 1696 | + } |
|
| 1670 | 1697 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
| 1671 | 1698 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' " . |
| 1672 | 1699 | " type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$current_module&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\"" . |
@@ -1681,10 +1708,11 @@ discard block |
||
| 1681 | 1708 | } |
| 1682 | 1709 | |
| 1683 | 1710 | // To make the edit or del link actions to return back to same view. |
| 1684 | - if ($singlepane_view == 'true') |
|
| 1685 | - $returnset = "&return_module=$current_module&return_action=DetailView&return_id=$id"; |
|
| 1686 | - else |
|
| 1687 | - $returnset = "&return_module=$current_module&return_action=CallRelatedList&return_id=$id"; |
|
| 1711 | + if ($singlepane_view == 'true') { |
|
| 1712 | + $returnset = "&return_module=$current_module&return_action=DetailView&return_id=$id"; |
|
| 1713 | + } else { |
|
| 1714 | + $returnset = "&return_module=$current_module&return_action=CallRelatedList&return_id=$id"; |
|
| 1715 | + } |
|
| 1688 | 1716 | |
| 1689 | 1717 | $query = "SELECT vtiger_crmentity.*, $other->table_name.*"; |
| 1690 | 1718 | |
@@ -1698,10 +1726,12 @@ discard block |
||
| 1698 | 1726 | $query .= ", $tname.*"; |
| 1699 | 1727 | |
| 1700 | 1728 | // Setup the default JOIN conditions if not specified |
| 1701 | - if (empty($relmap[1])) |
|
| 1702 | - $relmap[1] = $other->table_name; |
|
| 1703 | - if (empty($relmap[2])) |
|
| 1704 | - $relmap[2] = $relmap[0]; |
|
| 1729 | + if (empty($relmap[1])) { |
|
| 1730 | + $relmap[1] = $other->table_name; |
|
| 1731 | + } |
|
| 1732 | + if (empty($relmap[2])) { |
|
| 1733 | + $relmap[2] = $relmap[0]; |
|
| 1734 | + } |
|
| 1705 | 1735 | $more_relation .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]"; |
| 1706 | 1736 | } |
| 1707 | 1737 | } |
@@ -1715,8 +1745,9 @@ discard block |
||
| 1715 | 1745 | $query .= " WHERE vtiger_crmentity.deleted = 0 && (vtiger_crmentityrel.crmid = $id || vtiger_crmentityrel.relcrmid = $id)"; |
| 1716 | 1746 | $return_value = GetRelatedList($current_module, $related_module, $other, $query, $button, $returnset); |
| 1717 | 1747 | |
| 1718 | - if ($return_value === null) |
|
| 1719 | - $return_value = []; |
|
| 1748 | + if ($return_value === null) { |
|
| 1749 | + $return_value = []; |
|
| 1750 | + } |
|
| 1720 | 1751 | $return_value['CUSTOM_BUTTON'] = $button; |
| 1721 | 1752 | |
| 1722 | 1753 | return $return_value; |
@@ -1749,10 +1780,11 @@ discard block |
||
| 1749 | 1780 | $row = []; |
| 1750 | 1781 | |
| 1751 | 1782 | // To make the edit or del link actions to return back to same view. |
| 1752 | - if ($singlepane_view == 'true') |
|
| 1753 | - $returnset = "&return_module=$currentModule&return_action=DetailView&return_id=$id"; |
|
| 1754 | - else |
|
| 1755 | - $returnset = "&return_module=$currentModule&return_action=CallRelatedList&return_id=$id"; |
|
| 1783 | + if ($singlepane_view == 'true') { |
|
| 1784 | + $returnset = "&return_module=$currentModule&return_action=DetailView&return_id=$id"; |
|
| 1785 | + } else { |
|
| 1786 | + $returnset = "&return_module=$currentModule&return_action=CallRelatedList&return_id=$id"; |
|
| 1787 | + } |
|
| 1756 | 1788 | |
| 1757 | 1789 | $return_value = null; |
| 1758 | 1790 | |
@@ -1783,8 +1815,9 @@ discard block |
||
| 1783 | 1815 | $button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">'; |
| 1784 | 1816 | $button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">'; |
| 1785 | 1817 | if ($actions) { |
| 1786 | - if (is_string($actions)) |
|
| 1787 | - $actions = explode(',', strtoupper($actions)); |
|
| 1818 | + if (is_string($actions)) { |
|
| 1819 | + $actions = explode(',', strtoupper($actions)); |
|
| 1820 | + } |
|
| 1788 | 1821 | if (in_array('ADD', $actions) && isPermitted($relatedModule, 1, '') == 'yes' && getFieldVisibilityPermission($relatedModule, $current_user->id, $dependentField, 'readwrite') == '0') { |
| 1789 | 1822 | $button .= "<input title='" . \includes\Language::translate('LBL_ADD_NEW') . " " . \includes\Language::translate($singular_modname, $relatedModule) . "' class='crmbutton small create'" . |
| 1790 | 1823 | " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"$relatedModule\"' type='submit' name='button'" . |
@@ -1794,8 +1827,9 @@ discard block |
||
| 1794 | 1827 | $query = $this->createDependentQuery($other, $row, $id); |
| 1795 | 1828 | $return_value = GetRelatedList($currentModule, $relatedModule, $other, $query, $button, $returnset); |
| 1796 | 1829 | } |
| 1797 | - if ($return_value === null) |
|
| 1798 | - $return_value = []; |
|
| 1830 | + if ($return_value === null) { |
|
| 1831 | + $return_value = []; |
|
| 1832 | + } |
|
| 1799 | 1833 | $return_value['CUSTOM_BUTTON'] = $button; |
| 1800 | 1834 | |
| 1801 | 1835 | return $return_value; |
@@ -1823,10 +1857,12 @@ discard block |
||
| 1823 | 1857 | continue; |
| 1824 | 1858 | } |
| 1825 | 1859 | // Setup the default JOIN conditions if not specified |
| 1826 | - if (empty($relmap[1])) |
|
| 1827 | - $relmap[1] = $other->table_name; |
|
| 1828 | - if (empty($relmap[2])) |
|
| 1829 | - $relmap[2] = $relmap[0]; |
|
| 1860 | + if (empty($relmap[1])) { |
|
| 1861 | + $relmap[1] = $other->table_name; |
|
| 1862 | + } |
|
| 1863 | + if (empty($relmap[2])) { |
|
| 1864 | + $relmap[2] = $relmap[0]; |
|
| 1865 | + } |
|
| 1830 | 1866 | $join .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]"; |
| 1831 | 1867 | } |
| 1832 | 1868 | } |
@@ -2355,8 +2391,9 @@ discard block |
||
| 2355 | 2391 | { |
| 2356 | 2392 | $adb = PearDatabase::getInstance(); |
| 2357 | 2393 | |
| 2358 | - if (!is_array($uitypes)) |
|
| 2359 | - $uitypes = array($uitypes); |
|
| 2394 | + if (!is_array($uitypes)) { |
|
| 2395 | + $uitypes = array($uitypes); |
|
| 2396 | + } |
|
| 2360 | 2397 | $module = get_class($this); |
| 2361 | 2398 | |
| 2362 | 2399 | $cachedModuleFields = VTCacheUtils::lookupFieldInfo_Module($module); |
@@ -2400,10 +2437,11 @@ discard block |
||
| 2400 | 2437 | $columnCount = count($lookupcolumns); |
| 2401 | 2438 | foreach ($lookupcolumns as $columnname) { |
| 2402 | 2439 | if (!empty($columnname)) { |
| 2403 | - if ($i == 0 || $i == ($columnCount)) |
|
| 2404 | - $query .= sprintf("%s = '%s'", $columnname, $value); |
|
| 2405 | - else |
|
| 2406 | - $query .= sprintf(" || %s = '%s'", $columnname, $value); |
|
| 2440 | + if ($i == 0 || $i == ($columnCount)) { |
|
| 2441 | + $query .= sprintf("%s = '%s'", $columnname, $value); |
|
| 2442 | + } else { |
|
| 2443 | + $query .= sprintf(" || %s = '%s'", $columnname, $value); |
|
| 2444 | + } |
|
| 2407 | 2445 | $i++; |
| 2408 | 2446 | } |
| 2409 | 2447 | } |
@@ -2460,8 +2498,9 @@ discard block |
||
| 2460 | 2498 | |
| 2461 | 2499 | public function getUserAccessConditionsQuerySR($module, $currentUser = false, $relatedRecord = false) |
| 2462 | 2500 | { |
| 2463 | - if ($currentUser === false) |
|
| 2464 | - $currentUser = vglobal('current_user'); |
|
| 2501 | + if ($currentUser === false) { |
|
| 2502 | + $currentUser = vglobal('current_user'); |
|
| 2503 | + } |
|
| 2465 | 2504 | |
| 2466 | 2505 | $userid = $currentUser->id; |
| 2467 | 2506 | $userPrivileges = \Vtiger_Util_Helper::getUserPrivilegesFile($userid); |
@@ -2687,10 +2726,11 @@ discard block |
||
| 2687 | 2726 | $log = LoggerManager::getInstance(); |
| 2688 | 2727 | $currentModule = vglobal('currentModule'); |
| 2689 | 2728 | $log->debug("Entering getSortOrder() method ..."); |
| 2690 | - if (AppRequest::has('sorder')) |
|
| 2691 | - $sorder = $this->db->sql_escape_string(AppRequest::getForSql('sorder')); |
|
| 2692 | - else |
|
| 2693 | - $sorder = (($_SESSION[$currentModule . '_Sort_Order'] != '') ? ($_SESSION[$currentModule . '_Sort_Order']) : ($this->default_sort_order)); |
|
| 2729 | + if (AppRequest::has('sorder')) { |
|
| 2730 | + $sorder = $this->db->sql_escape_string(AppRequest::getForSql('sorder')); |
|
| 2731 | + } else { |
|
| 2732 | + $sorder = (($_SESSION[$currentModule . '_Sort_Order'] != '') ? ($_SESSION[$currentModule . '_Sort_Order']) : ($this->default_sort_order)); |
|
| 2733 | + } |
|
| 2694 | 2734 | $log->debug("Exiting getSortOrder() method ..."); |
| 2695 | 2735 | return $sorder; |
| 2696 | 2736 | } |
@@ -2710,10 +2750,11 @@ discard block |
||
| 2710 | 2750 | $use_default_order_by = $this->default_order_by; |
| 2711 | 2751 | } |
| 2712 | 2752 | |
| 2713 | - if (AppRequest::has('order_by')) |
|
| 2714 | - $order_by = $this->db->sql_escape_string(AppRequest::getForSql('order_by')); |
|
| 2715 | - else |
|
| 2716 | - $order_by = (($_SESSION[$currentModule . '_Order_By'] != '') ? ($_SESSION[$currentModule . '_Order_By']) : ($use_default_order_by)); |
|
| 2753 | + if (AppRequest::has('order_by')) { |
|
| 2754 | + $order_by = $this->db->sql_escape_string(AppRequest::getForSql('order_by')); |
|
| 2755 | + } else { |
|
| 2756 | + $order_by = (($_SESSION[$currentModule . '_Order_By'] != '') ? ($_SESSION[$currentModule . '_Order_By']) : ($use_default_order_by)); |
|
| 2757 | + } |
|
| 2717 | 2758 | $log->debug("Exiting getOrderBy method ..."); |
| 2718 | 2759 | return $order_by; |
| 2719 | 2760 | } |
@@ -2753,8 +2794,9 @@ discard block |
||
| 2753 | 2794 | $selectClause = sprintf('SELECT %s.%s AS recordid,%s%s', $this->table_name, $this->table_index, $tableColumnsString, $additionalColumns); |
| 2754 | 2795 | |
| 2755 | 2796 | // Select Custom Field Table Columns if present |
| 2756 | - if (isset($this->customFieldTable)) |
|
| 2757 | - $query .= ", " . $this->customFieldTable[0] . ".* "; |
|
| 2797 | + if (isset($this->customFieldTable)) { |
|
| 2798 | + $query .= ", " . $this->customFieldTable[0] . ".* "; |
|
| 2799 | + } |
|
| 2758 | 2800 | |
| 2759 | 2801 | $fromClause = " FROM $this->table_name"; |
| 2760 | 2802 | |
@@ -2798,8 +2840,9 @@ discard block |
||
| 2798 | 2840 | foreach ($tableColumns as $tableColumn) { |
| 2799 | 2841 | $tableInfo = explode('.', $tableColumn); |
| 2800 | 2842 | $duplicateCheckClause .= " ifnull($tableColumn,'null') = ifnull(temp.$tableInfo[1],'null')"; |
| 2801 | - if (count($tableColumns) != $i++) |
|
| 2802 | - $duplicateCheckClause .= ' && '; |
|
| 2843 | + if (count($tableColumns) != $i++) { |
|
| 2844 | + $duplicateCheckClause .= ' && '; |
|
| 2845 | + } |
|
| 2803 | 2846 | } |
| 2804 | 2847 | |
| 2805 | 2848 | $query = $selectClause . $fromClause . |
@@ -69,8 +69,9 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function setError($code, $message = null) |
| 71 | 71 | { |
| 72 | - if ($message === null) |
|
| 73 | - $message = $code; |
|
| 72 | + if ($message === null) { |
|
| 73 | + $message = $code; |
|
| 74 | + } |
|
| 74 | 75 | $error = array('code' => $code, 'message' => $message); |
| 75 | 76 | $this->error = $error; |
| 76 | 77 | } |
@@ -172,24 +173,29 @@ discard block |
||
| 172 | 173 | |
| 173 | 174 | /* Set right charset (UTF-8) to avoid IE complaining about c00ce56e error */ |
| 174 | 175 | if ($this->emitType == self::$EMIT_JSON) { |
| 175 | - if (!$contentTypeSent) |
|
| 176 | - header('Content-type: text/json; charset=UTF-8'); |
|
| 176 | + if (!$contentTypeSent) { |
|
| 177 | + header('Content-type: text/json; charset=UTF-8'); |
|
| 178 | + } |
|
| 177 | 179 | $this->emitJSON(); |
| 178 | 180 | } else if ($this->emitType == self::$EMIT_JSONTEXT) { |
| 179 | - if (!$contentTypeSent) |
|
| 180 | - header('Content-type: text/json; charset=UTF-8'); |
|
| 181 | + if (!$contentTypeSent) { |
|
| 182 | + header('Content-type: text/json; charset=UTF-8'); |
|
| 183 | + } |
|
| 181 | 184 | $this->emitText(); |
| 182 | 185 | } else if ($this->emitType == self::$EMIT_HTML) { |
| 183 | - if (!$contentTypeSent) |
|
| 184 | - header('Content-type: text/html; charset=UTF-8'); |
|
| 186 | + if (!$contentTypeSent) { |
|
| 187 | + header('Content-type: text/html; charset=UTF-8'); |
|
| 188 | + } |
|
| 185 | 189 | $this->emitRaw(); |
| 186 | 190 | } else if ($this->emitType == self::$EMIT_RAW) { |
| 187 | - if (!$contentTypeSent) |
|
| 188 | - header('Content-type: text/plain; charset=UTF-8'); |
|
| 191 | + if (!$contentTypeSent) { |
|
| 192 | + header('Content-type: text/plain; charset=UTF-8'); |
|
| 193 | + } |
|
| 189 | 194 | $this->emitRaw(); |
| 190 | 195 | } else if ($this->emitType == self::$EMIT_JSONP) { |
| 191 | - if (!$contentTypeSent) |
|
| 192 | - header('Content-type: application/javascript; charset=UTF-8'); |
|
| 196 | + if (!$contentTypeSent) { |
|
| 197 | + header('Content-type: application/javascript; charset=UTF-8'); |
|
| 198 | + } |
|
| 193 | 199 | echo $this->emitJSONPFn . "("; |
| 194 | 200 | $this->emitJSON(); |
| 195 | 201 | echo ")"; |
@@ -210,15 +216,17 @@ discard block |
||
| 210 | 216 | protected function emitText() |
| 211 | 217 | { |
| 212 | 218 | if ($this->result === NULL) { |
| 213 | - if (is_string($this->error)) |
|
| 214 | - echo $this->error; |
|
| 215 | - else |
|
| 216 | - echo \includes\utils\Json::encode($this->prepareResponse()); |
|
| 219 | + if (is_string($this->error)) { |
|
| 220 | + echo $this->error; |
|
| 221 | + } else { |
|
| 222 | + echo \includes\utils\Json::encode($this->prepareResponse()); |
|
| 223 | + } |
|
| 217 | 224 | } else { |
| 218 | - if (is_string($this->result)) |
|
| 219 | - echo $this->result; |
|
| 220 | - else |
|
| 221 | - echo \includes\utils\Json::encode($this->prepareResponse()); |
|
| 225 | + if (is_string($this->result)) { |
|
| 226 | + echo $this->result; |
|
| 227 | + } else { |
|
| 228 | + echo \includes\utils\Json::encode($this->prepareResponse()); |
|
| 229 | + } |
|
| 222 | 230 | } |
| 223 | 231 | } |
| 224 | 232 | |
@@ -227,8 +235,9 @@ discard block |
||
| 227 | 235 | */ |
| 228 | 236 | protected function emitRaw() |
| 229 | 237 | { |
| 230 | - if ($this->result === NULL) |
|
| 231 | - echo (is_string($this->error)) ? $this->error : var_export($this->error, true); |
|
| 238 | + if ($this->result === NULL) { |
|
| 239 | + echo (is_string($this->error)) ? $this->error : var_export($this->error, true); |
|
| 240 | + } |
|
| 232 | 241 | echo $this->result; |
| 233 | 242 | } |
| 234 | 243 | } |
@@ -441,8 +441,9 @@ discard block |
||
| 441 | 441 | $this->checkError('Missing table name'); |
| 442 | 442 | return false; |
| 443 | 443 | } |
| 444 | - if ($where != '') |
|
| 445 | - $where = sprintf('WHERE %s', $where); |
|
| 444 | + if ($where != '') { |
|
| 445 | + $where = sprintf('WHERE %s', $where); |
|
| 446 | + } |
|
| 446 | 447 | if (count($params) === 0) { |
| 447 | 448 | $this->query(sprintf('DELETE FROM %s %s', $table, $where)); |
| 448 | 449 | } else { |
@@ -530,10 +531,12 @@ discard block |
||
| 530 | 531 | */ |
| 531 | 532 | public function flatten_array($input, $output = null) |
| 532 | 533 | { |
| 533 | - if ($input === null) |
|
| 534 | - return null; |
|
| 535 | - if ($output === null) |
|
| 536 | - $output = []; |
|
| 534 | + if ($input === null) { |
|
| 535 | + return null; |
|
| 536 | + } |
|
| 537 | + if ($output === null) { |
|
| 538 | + $output = []; |
|
| 539 | + } |
|
| 537 | 540 | foreach ($input as $value) { |
| 538 | 541 | if (is_array($value)) { |
| 539 | 542 | $output = $this->flatten_array($value, $output); |
@@ -606,15 +609,17 @@ discard block |
||
| 606 | 609 | { |
| 607 | 610 | if (isset($result) && $rowNum < 0) { |
| 608 | 611 | $row = $this->getRow($result); |
| 609 | - if ($encode && is_array($row)) |
|
| 610 | - return array_map('to_html', $row); |
|
| 612 | + if ($encode && is_array($row)) { |
|
| 613 | + return array_map('to_html', $row); |
|
| 614 | + } |
|
| 611 | 615 | return $row; |
| 612 | 616 | } |
| 613 | 617 | if ($this->getRowCount($result) > $rowNum) { |
| 614 | 618 | $row = $this->raw_query_result_rowdata($result, $rowNum); |
| 615 | 619 | } |
| 616 | - if ($encode && is_array($row)) |
|
| 617 | - return array_map('to_html', $row); |
|
| 620 | + if ($encode && is_array($row)) { |
|
| 621 | + return array_map('to_html', $row); |
|
| 622 | + } |
|
| 618 | 623 | return $row; |
| 619 | 624 | } |
| 620 | 625 | |
@@ -759,8 +764,9 @@ discard block |
||
| 759 | 764 | $this->log('sqlExprDatalist: empty arrays not allowed', 'error'); |
| 760 | 765 | $this->checkError('sqlExprDatalist: empty arrays not allowed'); |
| 761 | 766 | } |
| 762 | - foreach ($array as $key => $val) |
|
| 763 | - $l .= ($l ? ',' : '') . $this->quote($val); |
|
| 767 | + foreach ($array as $key => $val) { |
|
| 768 | + $l .= ($l ? ',' : '') . $this->quote($val); |
|
| 769 | + } |
|
| 764 | 770 | return ' ( ' . $l . ' ) '; |
| 765 | 771 | } |
| 766 | 772 | |
@@ -775,8 +781,9 @@ discard block |
||
| 775 | 781 | { |
| 776 | 782 | $result = $this->query($sql, $dieOnError, $msg); |
| 777 | 783 | |
| 778 | - if ($this->getRowCount($result) == 1) |
|
| 779 | - return $result; |
|
| 784 | + if ($this->getRowCount($result) == 1) { |
|
| 785 | + return $result; |
|
| 786 | + } |
|
| 780 | 787 | $this->log('Rows Returned:' . $this->getRowCount($result) . ' More than 1 row returned for ' . $sql, 'error'); |
| 781 | 788 | $this->checkError('Rows Returned:' . $this->getRowCount($result) . ' More than 1 row returned for ' . $sql, $dieOnError); |
| 782 | 789 | return ''; |
@@ -788,8 +795,9 @@ discard block |
||
| 788 | 795 | { |
| 789 | 796 | $result = $this->pquery($sql, $params, $dieOnError, $msg); |
| 790 | 797 | |
| 791 | - if ($this->getRowCount($result) == 1) |
|
| 792 | - return $result; |
|
| 798 | + if ($this->getRowCount($result) == 1) { |
|
| 799 | + return $result; |
|
| 800 | + } |
|
| 793 | 801 | $this->log('Rows Returned:' . $this->getRowCount($result) . ' More than 1 row returned for ' . $sql, 'error'); |
| 794 | 802 | $this->checkError('Rows Returned:' . $this->getRowCount($result) . ' More than 1 row returned for ' . $sql, $dieOnError); |
| 795 | 803 | return ''; |
@@ -853,8 +861,9 @@ discard block |
||
| 853 | 861 | if (isset($_SERVER['REQUEST_METHOD'])) { |
| 854 | 862 | $uri = $_SERVER['REQUEST_URI']; |
| 855 | 863 | $qmarkIndex = strpos($_SERVER['REQUEST_URI'], '?'); |
| 856 | - if ($qmarkIndex !== false) |
|
| 857 | - $uri = substr($uri, 0, $qmarkIndex); |
|
| 864 | + if ($qmarkIndex !== false) { |
|
| 865 | + $uri = substr($uri, 0, $qmarkIndex); |
|
| 866 | + } |
|
| 858 | 867 | $data = $uri . '?' . http_build_query($_SERVER['REQUEST_METHOD'] == 'GET' ? $_GET : $_POST); |
| 859 | 868 | } |
| 860 | 869 | $stmt = $db->database->prepare($logQuery); |
@@ -889,10 +898,12 @@ discard block |
||
| 889 | 898 | } |
| 890 | 899 | $args = rtrim($args, ','); |
| 891 | 900 | } |
| 892 | - if (!empty($callerfunc)) |
|
| 893 | - $callerfunc = " ($callerfunc)"; |
|
| 894 | - if (!empty($args)) |
|
| 895 | - $callerfunc .= "[$args] "; |
|
| 901 | + if (!empty($callerfunc)) { |
|
| 902 | + $callerfunc = " ($callerfunc)"; |
|
| 903 | + } |
|
| 904 | + if (!empty($args)) { |
|
| 905 | + $callerfunc .= "[$args] "; |
|
| 906 | + } |
|
| 896 | 907 | } |
| 897 | 908 | $data[] = 'CALLER: (' . $callers[$calleridx]['line'] . ') ' . $callers[$calleridx]['file'] . $callerfunc; |
| 898 | 909 | } |
@@ -50,8 +50,9 @@ discard block |
||
| 50 | 50 | if ($search_index === 0) { |
| 51 | 51 | $startindex = strlen($base_realpath) + 1; |
| 52 | 52 | // On windows $base_realpath ends with / and On Linux it will not have / at end! |
| 53 | - if (strrpos($base_realpath, '/') == strlen($base_realpath) - 1) |
|
| 54 | - $startindex -= 1; |
|
| 53 | + if (strrpos($base_realpath, '/') == strlen($base_realpath) - 1) { |
|
| 54 | + $startindex -= 1; |
|
| 55 | + } |
|
| 55 | 56 | $relpath = substr($src_realpath, $startindex); |
| 56 | 57 | } |
| 57 | 58 | return $relpath; |
@@ -62,8 +63,9 @@ discard block |
||
| 62 | 63 | */ |
| 63 | 64 | public function __fixDirSeparator($path) |
| 64 | 65 | { |
| 65 | - if ($path != '' && (strripos($path, '/') != strlen($path) - 1)) |
|
| 66 | - $path .= '/'; |
|
| 66 | + if ($path != '' && (strripos($path, '/') != strlen($path) - 1)) { |
|
| 67 | + $path .= '/'; |
|
| 68 | + } |
|
| 67 | 69 | return $path; |
| 68 | 70 | } |
| 69 | 71 | |
@@ -72,8 +74,9 @@ discard block |
||
| 72 | 74 | */ |
| 73 | 75 | public function __normalizePath($path) |
| 74 | 76 | { |
| 75 | - if ($path && strpos($path, '\\') !== false) |
|
| 76 | - $path = preg_replace("/\\\\/", "/", $path); |
|
| 77 | + if ($path && strpos($path, '\\') !== false) { |
|
| 78 | + $path = preg_replace("/\\\\/", "/", $path); |
|
| 79 | + } |
|
| 77 | 80 | return $path; |
| 78 | 81 | } |
| 79 | 82 | |
@@ -83,18 +86,21 @@ discard block |
||
| 83 | 86 | public function copyDirectoryFromDisk($dirname, $zipdirname = null, $excludeList = null, $basedirname = null) |
| 84 | 87 | { |
| 85 | 88 | $dir = opendir($dirname); |
| 86 | - if (strripos($dirname, '/') != strlen($dirname) - 1) |
|
| 87 | - $dirname .= '/'; |
|
| 89 | + if (strripos($dirname, '/') != strlen($dirname) - 1) { |
|
| 90 | + $dirname .= '/'; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if ($basedirname === null) |
|
| 90 | - $basedirname = realpath($dirname); |
|
| 93 | + if ($basedirname === null) { |
|
| 94 | + $basedirname = realpath($dirname); |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | while (false !== ($file = readdir($dir))) { |
| 93 | 98 | if ($file != '.' && $file != '..' && |
| 94 | 99 | $file != '.svn' && $file != 'CVS') { |
| 95 | 100 | // Exclude the file/directory |
| 96 | - if (!empty($excludeList) && in_array("$dirname$file", $excludeList)) |
|
| 97 | - continue; |
|
| 101 | + if (!empty($excludeList) && in_array("$dirname$file", $excludeList)) { |
|
| 102 | + continue; |
|
| 103 | + } |
|
| 98 | 104 | |
| 99 | 105 | if (is_dir("$dirname$file")) { |
| 100 | 106 | $this->copyDirectoryFromDisk("$dirname$file", $zipdirname, $excludeList, $basedirname); |