@@ -374,6 +374,11 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Function which returns the value based on result type (array / ADODB ResultSet) |
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * @param integer $index |
|
| 380 | + * @param string $columnname |
|
| 381 | + */ |
|
| 377 | 382 | private function resolve_query_result_value($result, $index, $columnname) |
| 378 | 383 | { |
| 379 | 384 | $adb = PearDatabase::getInstance(); |
@@ -633,7 +638,7 @@ discard block |
||
| 633 | 638 | } |
| 634 | 639 | |
| 635 | 640 | /** Function to delete a record in the specifed table |
| 636 | - * @param $table_name -- table name:: Type varchar |
|
| 641 | + * @param string $table_name -- table name:: Type varchar |
|
| 637 | 642 | * The function will delete a record .The id is obtained from the class variable $this->id and the columnname got from $this->tab_name_index[$table_name] |
| 638 | 643 | */ |
| 639 | 644 | public function deleteRelation($table_name) |
@@ -817,6 +822,7 @@ discard block |
||
| 817 | 822 | |
| 818 | 823 | /** Function to saves the values in all the tables mentioned in the class variable $tab_name for the specified module |
| 819 | 824 | * @param $module -- module:: Type varchar |
| 825 | + * @param string $module_name |
|
| 820 | 826 | */ |
| 821 | 827 | public function save($module_name, $fileid = '') |
| 822 | 828 | { |
@@ -2562,10 +2568,10 @@ discard block |
||
| 2562 | 2568 | |
| 2563 | 2569 | /** |
| 2564 | 2570 | * |
| 2565 | - * @param <type> $module |
|
| 2566 | - * @param <type> $user |
|
| 2571 | + * @param Users $user |
|
| 2567 | 2572 | * @param <type> $parentRole |
| 2568 | 2573 | * @param <type> $userGroups |
| 2574 | + * @param string $tableName |
|
| 2569 | 2575 | */ |
| 2570 | 2576 | protected function setupTemporaryTable($tableName, $tabId, $user, $parentRole, $userGroups) |
| 2571 | 2577 | { |
@@ -545,7 +545,7 @@ |
||
| 545 | 545 | } elseif ($uitype === 10) { |
| 546 | 546 | if (empty($this->column_fields[$fieldname])) { |
| 547 | 547 | $fldvalue = 0; |
| 548 | - }else |
|
| 548 | + } else |
|
| 549 | 549 | $fldvalue = $this->column_fields[$fieldname]; |
| 550 | 550 | } elseif ($uitype === 7) { |
| 551 | 551 | //strip out the spaces and commas in numbers if given ie., in amounts there may be , |
@@ -165,8 +165,9 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | //to get the owner id |
| 167 | 167 | $ownerid = $this->column_fields['assigned_user_id']; |
| 168 | - if (!isset($ownerid) || $ownerid == '') |
|
| 169 | - $ownerid = $current_user->id; |
|
| 168 | + if (!isset($ownerid) || $ownerid == '') { |
|
| 169 | + $ownerid = $current_user->id; |
|
| 170 | + } |
|
| 170 | 171 | |
| 171 | 172 | if (isset($file_details['original_name']) && $file_details['original_name'] != null) { |
| 172 | 173 | $file_name = $file_details['original_name']; |
@@ -333,16 +334,18 @@ discard block |
||
| 333 | 334 | } else { |
| 334 | 335 | $this->id = $this->newRecord; |
| 335 | 336 | } |
| 336 | - if (empty($currentUser->id)) |
|
| 337 | - $currentUser->id = 0; |
|
| 337 | + if (empty($currentUser->id)) { |
|
| 338 | + $currentUser->id = 0; |
|
| 339 | + } |
|
| 338 | 340 | |
| 339 | 341 | // Customization |
| 340 | 342 | $created_date_var = $adb->formatDate($date_var, true); |
| 341 | 343 | $modified_date_var = $adb->formatDate($date_var, true); |
| 342 | 344 | // Preserve the timestamp |
| 343 | 345 | if (self::isBulkSaveMode()) { |
| 344 | - if (!empty($this->column_fields['createdtime'])) |
|
| 345 | - $created_date_var = $adb->formatDate($this->column_fields['createdtime'], true); |
|
| 346 | + if (!empty($this->column_fields['createdtime'])) { |
|
| 347 | + $created_date_var = $adb->formatDate($this->column_fields['createdtime'], true); |
|
| 348 | + } |
|
| 346 | 349 | //NOTE : modifiedtime ignored to support vtws_sync API track changes. |
| 347 | 350 | } |
| 348 | 351 | // END |
@@ -372,10 +375,11 @@ discard block |
||
| 372 | 375 | private function resolve_query_result_value($result, $index, $columnname) |
| 373 | 376 | { |
| 374 | 377 | $adb = PearDatabase::getInstance(); |
| 375 | - if (is_array($result)) |
|
| 376 | - return $result[$index][$columnname]; |
|
| 377 | - else |
|
| 378 | - return $adb->query_result($result, $index, $columnname); |
|
| 378 | + if (is_array($result)) { |
|
| 379 | + return $result[$index][$columnname]; |
|
| 380 | + } else { |
|
| 381 | + return $adb->query_result($result, $index, $columnname); |
|
| 382 | + } |
|
| 379 | 383 | } |
| 380 | 384 | |
| 381 | 385 | /** Function to insert values in the specifed table for the specified module |
@@ -545,8 +549,9 @@ discard block |
||
| 545 | 549 | } elseif ($uitype === 10) { |
| 546 | 550 | if (empty($this->column_fields[$fieldname])) { |
| 547 | 551 | $fldvalue = 0; |
| 548 | - }else |
|
| 549 | - $fldvalue = $this->column_fields[$fieldname]; |
|
| 552 | + } else { |
|
| 553 | + $fldvalue = $this->column_fields[$fieldname]; |
|
| 554 | + } |
|
| 550 | 555 | } elseif ($uitype === 7) { |
| 551 | 556 | //strip out the spaces and commas in numbers if given ie., in amounts there may be , |
| 552 | 557 | $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]); //trim($this->column_fields[$fieldname],","); |
@@ -595,10 +600,10 @@ discard block |
||
| 595 | 600 | } else { |
| 596 | 601 | $fldvalue = $this->column_fields[$fieldname]; |
| 597 | 602 | } |
| 598 | - if ($uitype !== 33 && $uitype !== 8) |
|
| 599 | - $fldvalue = \vtlib\Functions::fromHTML($fldvalue, ($insertion_mode == 'edit') ? true : false); |
|
| 600 | - } |
|
| 601 | - else { |
|
| 603 | + if ($uitype !== 33 && $uitype !== 8) { |
|
| 604 | + $fldvalue = \vtlib\Functions::fromHTML($fldvalue, ($insertion_mode == 'edit') ? true : false); |
|
| 605 | + } |
|
| 606 | + } else { |
|
| 602 | 607 | $fldvalue = ''; |
| 603 | 608 | } |
| 604 | 609 | |
@@ -656,8 +661,9 @@ discard block |
||
| 656 | 661 | $query1 = "select * from vtiger_seattachmentsrel where crmid=?"; |
| 657 | 662 | $result = $adb->pquery($query1, array($notesid)); |
| 658 | 663 | $noofrows = $adb->num_rows($result); |
| 659 | - if ($noofrows != 0) |
|
| 660 | - $attachmentid = $adb->query_result($result, 0, 'attachmentsid'); |
|
| 664 | + if ($noofrows != 0) { |
|
| 665 | + $attachmentid = $adb->query_result($result, 0, 'attachmentsid'); |
|
| 666 | + } |
|
| 661 | 667 | if ($attachmentid != '') { |
| 662 | 668 | $query2 = "select * from vtiger_attachments where attachmentsid=?"; |
| 663 | 669 | $filename = $adb->query_result($adb->pquery($query2, array($attachmentid)), 0, 'name'); |
@@ -708,10 +714,11 @@ discard block |
||
| 708 | 714 | // Lookup module field cache |
| 709 | 715 | if ($module == 'Calendar' || $module == 'Events') { |
| 710 | 716 | getColumnFields('Calendar'); |
| 711 | - if (VTCacheUtils::lookupFieldInfo_Module('Events')) |
|
| 712 | - $cachedEventsFields = VTCacheUtils::lookupFieldInfo_Module('Events'); |
|
| 713 | - else |
|
| 714 | - $cachedEventsFields = []; |
|
| 717 | + if (VTCacheUtils::lookupFieldInfo_Module('Events')) { |
|
| 718 | + $cachedEventsFields = VTCacheUtils::lookupFieldInfo_Module('Events'); |
|
| 719 | + } else { |
|
| 720 | + $cachedEventsFields = []; |
|
| 721 | + } |
|
| 715 | 722 | $cachedCalendarFields = VTCacheUtils::lookupFieldInfo_Module('Calendar'); |
| 716 | 723 | $cachedModuleFields = array_merge($cachedEventsFields, $cachedCalendarFields); |
| 717 | 724 | $module = 'Calendar'; |
@@ -858,10 +865,11 @@ discard block |
||
| 858 | 865 | while ($row = $this->db->fetchByAssoc($result)) { |
| 859 | 866 | $rowid = $row[$this->table_index]; |
| 860 | 867 | |
| 861 | - if (isset($rowid)) |
|
| 862 | - $this->retrieve_entity_info($rowid, $this->module_name); |
|
| 863 | - else |
|
| 864 | - $this->db->println("rowid not set unable to retrieve"); |
|
| 868 | + if (isset($rowid)) { |
|
| 869 | + $this->retrieve_entity_info($rowid, $this->module_name); |
|
| 870 | + } else { |
|
| 871 | + $this->db->println("rowid not set unable to retrieve"); |
|
| 872 | + } |
|
| 865 | 873 | |
| 866 | 874 | |
| 867 | 875 | |
@@ -874,10 +882,11 @@ discard block |
||
| 874 | 882 | } |
| 875 | 883 | } |
| 876 | 884 | |
| 877 | - if (isset($list)) |
|
| 878 | - return $list; |
|
| 879 | - else |
|
| 880 | - return null; |
|
| 885 | + if (isset($list)) { |
|
| 886 | + return $list; |
|
| 887 | + } else { |
|
| 888 | + return null; |
|
| 889 | + } |
|
| 881 | 890 | } |
| 882 | 891 | |
| 883 | 892 | /** This function should be overridden in each module. It marks an item as deleted. |
@@ -1047,19 +1056,22 @@ discard block |
||
| 1047 | 1056 | require_once('include/utils/UserInfoUtil.php'); |
| 1048 | 1057 | foreach ($this->column_fields as $fieldname => $fieldvalue) { |
| 1049 | 1058 | $reset_value = false; |
| 1050 | - if (getFieldVisibilityPermission($moduleName, $current_user->id, $fieldname) != '0') |
|
| 1051 | - $reset_value = true; |
|
| 1059 | + if (getFieldVisibilityPermission($moduleName, $current_user->id, $fieldname) != '0') { |
|
| 1060 | + $reset_value = true; |
|
| 1061 | + } |
|
| 1052 | 1062 | |
| 1053 | - if ($fieldname == "record_id" || $fieldname == "record_module") |
|
| 1054 | - $reset_value = false; |
|
| 1063 | + if ($fieldname == "record_id" || $fieldname == "record_module") { |
|
| 1064 | + $reset_value = false; |
|
| 1065 | + } |
|
| 1055 | 1066 | |
| 1056 | 1067 | /* |
| 1057 | 1068 | if (isset($this->additional_column_fields) && in_array($fieldname, $this->additional_column_fields) === true) |
| 1058 | 1069 | $reset_value = false; |
| 1059 | 1070 | */ |
| 1060 | 1071 | |
| 1061 | - if ($reset_value === true) |
|
| 1062 | - $this->column_fields[$fieldname] = ""; |
|
| 1072 | + if ($reset_value === true) { |
|
| 1073 | + $this->column_fields[$fieldname] = ""; |
|
| 1074 | + } |
|
| 1063 | 1075 | } |
| 1064 | 1076 | } |
| 1065 | 1077 | |
@@ -1105,8 +1117,9 @@ discard block |
||
| 1105 | 1117 | } |
| 1106 | 1118 | |
| 1107 | 1119 | foreach ($colf as $key => $value) { |
| 1108 | - if (getFieldVisibilityPermission($module, $current_user->id, $key, 'readwrite') == '0') |
|
| 1109 | - $this->importable_fields[$key] = $value; |
|
| 1120 | + if (getFieldVisibilityPermission($module, $current_user->id, $key, 'readwrite') == '0') { |
|
| 1121 | + $this->importable_fields[$key] = $value; |
|
| 1122 | + } |
|
| 1110 | 1123 | } |
| 1111 | 1124 | } |
| 1112 | 1125 | |
@@ -1353,13 +1366,15 @@ discard block |
||
| 1353 | 1366 | $num_rows = $adb->num_rows($result); |
| 1354 | 1367 | for ($i = 0; $i < $num_rows; $i++) { |
| 1355 | 1368 | $columnname = $adb->query_result($result, $i, 'columnname'); |
| 1356 | - if (in_array($columnname, $this->sortby_fields)) |
|
| 1357 | - continue; |
|
| 1358 | - else |
|
| 1359 | - $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'; |
|
| 1360 | 1377 | } |
| 1361 | - if ($tabid == 21 || $tabid == 22) |
|
| 1362 | - $this->sortby_fields[] = 'crmid'; |
|
| 1363 | 1378 | \App\Log::trace("Exiting initSortByField"); |
| 1364 | 1379 | } |
| 1365 | 1380 | /* Function to check if the mod number already exits */ |
@@ -1369,10 +1384,11 @@ discard block |
||
| 1369 | 1384 | $adb = PearDatabase::getInstance(); |
| 1370 | 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]); |
| 1371 | 1386 | $num_rows = $adb->num_rows($result); |
| 1372 | - if ($num_rows > 0) |
|
| 1373 | - return true; |
|
| 1374 | - else |
|
| 1375 | - return false; |
|
| 1387 | + if ($num_rows > 0) { |
|
| 1388 | + return true; |
|
| 1389 | + } else { |
|
| 1390 | + return false; |
|
| 1391 | + } |
|
| 1376 | 1392 | } |
| 1377 | 1393 | |
| 1378 | 1394 | // END |
@@ -1385,8 +1401,9 @@ discard block |
||
| 1385 | 1401 | |
| 1386 | 1402 | vtlib_setup_modulevars($module, $this); |
| 1387 | 1403 | $tabid = \App\Module::getModuleId($module); |
| 1388 | - if (!\includes\fields\RecordNumber::isModuleSequenceConfigured($tabid)) |
|
| 1389 | - return; |
|
| 1404 | + if (!\includes\fields\RecordNumber::isModuleSequenceConfigured($tabid)) { |
|
| 1405 | + return; |
|
| 1406 | + } |
|
| 1390 | 1407 | $fieldinfo = $adb->pquery("SELECT * FROM vtiger_field WHERE tabid = ? && uitype = 4", Array($tabid)); |
| 1391 | 1408 | |
| 1392 | 1409 | $returninfo = []; |
@@ -1440,8 +1457,9 @@ discard block |
||
| 1440 | 1457 | $singular_modname = vtlib_toSingular($related_module); |
| 1441 | 1458 | $button = ''; |
| 1442 | 1459 | if ($actions) { |
| 1443 | - if (is_string($actions)) |
|
| 1444 | - $actions = explode(',', strtoupper($actions)); |
|
| 1460 | + if (is_string($actions)) { |
|
| 1461 | + $actions = explode(',', strtoupper($actions)); |
|
| 1462 | + } |
|
| 1445 | 1463 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
| 1446 | 1464 | $button .= "<input title='" . \App\Language::translate('LBL_SELECT') . " " . \App\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='" . \App\Language::translate('LBL_SELECT') . " " . \App\Language::translate($related_module) . "'> "; |
| 1447 | 1465 | } |
@@ -1454,10 +1472,11 @@ discard block |
||
| 1454 | 1472 | } |
| 1455 | 1473 | |
| 1456 | 1474 | // To make the edit or del link actions to return back to same view. |
| 1457 | - if ($singlepane_view == 'true') |
|
| 1458 | - $returnset = "&return_module=$this_module&return_action=DetailView&return_id=$id"; |
|
| 1459 | - else |
|
| 1460 | - $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 | + } |
|
| 1461 | 1480 | |
| 1462 | 1481 | $userNameSql = \vtlib\Deprecated::getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', |
| 1463 | 1482 | 'last_name' => 'vtiger_users.last_name'), 'Users'); |
@@ -1479,8 +1498,9 @@ discard block |
||
| 1479 | 1498 | |
| 1480 | 1499 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
| 1481 | 1500 | |
| 1482 | - if ($return_value === null) |
|
| 1483 | - $return_value = []; |
|
| 1501 | + if ($return_value === null) { |
|
| 1502 | + $return_value = []; |
|
| 1503 | + } |
|
| 1484 | 1504 | $return_value['CUSTOM_BUTTON'] = $button; |
| 1485 | 1505 | return $return_value; |
| 1486 | 1506 | } |
@@ -1512,8 +1532,9 @@ discard block |
||
| 1512 | 1532 | return true; |
| 1513 | 1533 | } else if ($lastviewed && $modifiedon) { |
| 1514 | 1534 | /** Lastviewed and Modified time is available. */ |
| 1515 | - if ($this->__timediff($modifiedon, $lastviewed) > 0) |
|
| 1516 | - return true; |
|
| 1535 | + if ($this->__timediff($modifiedon, $lastviewed) > 0) { |
|
| 1536 | + return true; |
|
| 1537 | + } |
|
| 1517 | 1538 | } |
| 1518 | 1539 | } |
| 1519 | 1540 | return false; |
@@ -1533,8 +1554,9 @@ discard block |
||
| 1533 | 1554 | |
| 1534 | 1555 | $t2 = mktime($t2_h, $t2_i, $t2_s, $t2_m, $t2_d, $t2_y); |
| 1535 | 1556 | |
| 1536 | - if ($t1 == $t2) |
|
| 1537 | - return 0; |
|
| 1557 | + if ($t1 == $t2) { |
|
| 1558 | + return 0; |
|
| 1559 | + } |
|
| 1538 | 1560 | return $t2 - $t1; |
| 1539 | 1561 | } |
| 1540 | 1562 | |
@@ -1554,8 +1576,9 @@ discard block |
||
| 1554 | 1576 | */ |
| 1555 | 1577 | public function save_related_module($module, $crmid, $withModule, $withCrmid, $relatedName = false) |
| 1556 | 1578 | { |
| 1557 | - if (!is_array($withCrmid)) |
|
| 1558 | - $withCrmid = [$withCrmid]; |
|
| 1579 | + if (!is_array($withCrmid)) { |
|
| 1580 | + $withCrmid = [$withCrmid]; |
|
| 1581 | + } |
|
| 1559 | 1582 | switch ($relatedName) { |
| 1560 | 1583 | case 'get_many_to_many': |
| 1561 | 1584 | $this->saveRelatedM2M($module, $crmid, $withModule, $withCrmid); |
@@ -1576,8 +1599,9 @@ discard block |
||
| 1576 | 1599 | foreach ($withCrmid as $relcrmid) { |
| 1577 | 1600 | $check = $db->pquery(sprintf('SELECT 1 FROM `%s` WHERE %s = ? && %s = ?', $referenceInfo['table'], $referenceInfo['base'], $referenceInfo['rel']), [$relcrmid, $crmid]); |
| 1578 | 1601 | // Relation already exists? No need to add again |
| 1579 | - if ($check && $db->getRowCount($check)) |
|
| 1580 | - continue; |
|
| 1602 | + if ($check && $db->getRowCount($check)) { |
|
| 1603 | + continue; |
|
| 1604 | + } |
|
| 1581 | 1605 | $db->insert($referenceInfo['table'], [ |
| 1582 | 1606 | $referenceInfo['base'] => $relcrmid, |
| 1583 | 1607 | $referenceInfo['rel'] => $crmid |
@@ -1593,8 +1617,9 @@ discard block |
||
| 1593 | 1617 | if ($withModule == 'Documents') { |
| 1594 | 1618 | $checkpresence = $db->pquery('SELECT crmid FROM vtiger_senotesrel WHERE crmid = ? && notesid = ?', [$crmid, $relcrmid]); |
| 1595 | 1619 | // Relation already exists? No need to add again |
| 1596 | - if ($checkpresence && $db->getRowCount($checkpresence)) |
|
| 1597 | - continue; |
|
| 1620 | + if ($checkpresence && $db->getRowCount($checkpresence)) { |
|
| 1621 | + continue; |
|
| 1622 | + } |
|
| 1598 | 1623 | |
| 1599 | 1624 | $db->insert('vtiger_senotesrel', [ |
| 1600 | 1625 | 'crmid' => $crmid, |
@@ -1604,8 +1629,9 @@ discard block |
||
| 1604 | 1629 | $checkpresence = $db->pquery('SELECT crmid FROM vtiger_crmentityrel WHERE crmid = ? AND module = ? AND relcrmid = ? AND relmodule = ?', [$crmid, $module, $relcrmid, $withModule] |
| 1605 | 1630 | ); |
| 1606 | 1631 | // Relation already exists? No need to add again |
| 1607 | - if ($checkpresence && $db->getRowCount($checkpresence)) |
|
| 1608 | - continue; |
|
| 1632 | + if ($checkpresence && $db->getRowCount($checkpresence)) { |
|
| 1633 | + continue; |
|
| 1634 | + } |
|
| 1609 | 1635 | \App\Db::getInstance()->createCommand()->insert('vtiger_crmentityrel', [ |
| 1610 | 1636 | 'crmid' => $crmid, |
| 1611 | 1637 | 'module' => $module, |
@@ -1628,8 +1654,9 @@ discard block |
||
| 1628 | 1654 | public function delete_related_module($module, $crmid, $withModule, $withCrmid) |
| 1629 | 1655 | { |
| 1630 | 1656 | $db = PearDatabase::getInstance(); |
| 1631 | - if (!is_array($withCrmid)) |
|
| 1632 | - $withCrmid = Array($withCrmid); |
|
| 1657 | + if (!is_array($withCrmid)) { |
|
| 1658 | + $withCrmid = Array($withCrmid); |
|
| 1659 | + } |
|
| 1633 | 1660 | foreach ($withCrmid as $relcrmid) { |
| 1634 | 1661 | |
| 1635 | 1662 | if ($withModule == 'Documents') { |
@@ -1663,8 +1690,9 @@ discard block |
||
| 1663 | 1690 | |
| 1664 | 1691 | $button = ''; |
| 1665 | 1692 | if ($actions) { |
| 1666 | - if (is_string($actions)) |
|
| 1667 | - $actions = explode(',', strtoupper($actions)); |
|
| 1693 | + if (is_string($actions)) { |
|
| 1694 | + $actions = explode(',', strtoupper($actions)); |
|
| 1695 | + } |
|
| 1668 | 1696 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
| 1669 | 1697 | $button .= "<input title='" . \App\Language::translate('LBL_SELECT') . " " . \App\Language::translate($related_module) . "' class='crmbutton small edit' " . |
| 1670 | 1698 | " 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');\"" . |
@@ -1679,10 +1707,11 @@ discard block |
||
| 1679 | 1707 | } |
| 1680 | 1708 | |
| 1681 | 1709 | // To make the edit or del link actions to return back to same view. |
| 1682 | - if ($singlepane_view == 'true') |
|
| 1683 | - $returnset = "&return_module=$current_module&return_action=DetailView&return_id=$id"; |
|
| 1684 | - else |
|
| 1685 | - $returnset = "&return_module=$current_module&return_action=CallRelatedList&return_id=$id"; |
|
| 1710 | + if ($singlepane_view == 'true') { |
|
| 1711 | + $returnset = "&return_module=$current_module&return_action=DetailView&return_id=$id"; |
|
| 1712 | + } else { |
|
| 1713 | + $returnset = "&return_module=$current_module&return_action=CallRelatedList&return_id=$id"; |
|
| 1714 | + } |
|
| 1686 | 1715 | |
| 1687 | 1716 | $query = "SELECT vtiger_crmentity.*, $other->table_name.*"; |
| 1688 | 1717 | |
@@ -1696,10 +1725,12 @@ discard block |
||
| 1696 | 1725 | $query .= ", $tname.*"; |
| 1697 | 1726 | |
| 1698 | 1727 | // Setup the default JOIN conditions if not specified |
| 1699 | - if (empty($relmap[1])) |
|
| 1700 | - $relmap[1] = $other->table_name; |
|
| 1701 | - if (empty($relmap[2])) |
|
| 1702 | - $relmap[2] = $relmap[0]; |
|
| 1728 | + if (empty($relmap[1])) { |
|
| 1729 | + $relmap[1] = $other->table_name; |
|
| 1730 | + } |
|
| 1731 | + if (empty($relmap[2])) { |
|
| 1732 | + $relmap[2] = $relmap[0]; |
|
| 1733 | + } |
|
| 1703 | 1734 | $more_relation .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]"; |
| 1704 | 1735 | } |
| 1705 | 1736 | } |
@@ -1713,8 +1744,9 @@ discard block |
||
| 1713 | 1744 | $query .= " WHERE vtiger_crmentity.deleted = 0 && (vtiger_crmentityrel.crmid = $id || vtiger_crmentityrel.relcrmid = $id)"; |
| 1714 | 1745 | $return_value = GetRelatedList($current_module, $related_module, $other, $query, $button, $returnset); |
| 1715 | 1746 | |
| 1716 | - if ($return_value === null) |
|
| 1717 | - $return_value = []; |
|
| 1747 | + if ($return_value === null) { |
|
| 1748 | + $return_value = []; |
|
| 1749 | + } |
|
| 1718 | 1750 | $return_value['CUSTOM_BUTTON'] = $button; |
| 1719 | 1751 | |
| 1720 | 1752 | return $return_value; |
@@ -1746,10 +1778,11 @@ discard block |
||
| 1746 | 1778 | $button = ''; |
| 1747 | 1779 | |
| 1748 | 1780 | // To make the edit or del link actions to return back to same view. |
| 1749 | - if ($singlepane_view == 'true') |
|
| 1750 | - $returnset = "&return_module=$currentModule&return_action=DetailView&return_id=$id"; |
|
| 1751 | - else |
|
| 1752 | - $returnset = "&return_module=$currentModule&return_action=CallRelatedList&return_id=$id"; |
|
| 1781 | + if ($singlepane_view == 'true') { |
|
| 1782 | + $returnset = "&return_module=$currentModule&return_action=DetailView&return_id=$id"; |
|
| 1783 | + } else { |
|
| 1784 | + $returnset = "&return_module=$currentModule&return_action=CallRelatedList&return_id=$id"; |
|
| 1785 | + } |
|
| 1753 | 1786 | |
| 1754 | 1787 | $return_value = null; |
| 1755 | 1788 | |
@@ -1782,8 +1815,9 @@ discard block |
||
| 1782 | 1815 | $button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">'; |
| 1783 | 1816 | $button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">'; |
| 1784 | 1817 | if ($actions) { |
| 1785 | - if (is_string($actions)) |
|
| 1786 | - $actions = explode(',', strtoupper($actions)); |
|
| 1818 | + if (is_string($actions)) { |
|
| 1819 | + $actions = explode(',', strtoupper($actions)); |
|
| 1820 | + } |
|
| 1787 | 1821 | if (in_array('ADD', $actions) && isPermitted($relatedModule, 1, '') == 'yes' && getFieldVisibilityPermission($relatedModule, $current_user->id, $dependentField, 'readwrite') == '0') { |
| 1788 | 1822 | $button .= "<input title='" . \App\Language::translate('LBL_ADD_NEW') . " " . \App\Language::translate($singular_modname, $relatedModule) . "' class='crmbutton small create'" . |
| 1789 | 1823 | " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"$relatedModule\"' type='submit' name='button'" . |
@@ -1793,8 +1827,9 @@ discard block |
||
| 1793 | 1827 | $query = $this->createDependentQuery($other, $row, $id); |
| 1794 | 1828 | $return_value = GetRelatedList($currentModule, $relatedModule, $other, $query, $button, $returnset); |
| 1795 | 1829 | } |
| 1796 | - if ($return_value === null) |
|
| 1797 | - $return_value = []; |
|
| 1830 | + if ($return_value === null) { |
|
| 1831 | + $return_value = []; |
|
| 1832 | + } |
|
| 1798 | 1833 | $return_value['CUSTOM_BUTTON'] = $button; |
| 1799 | 1834 | |
| 1800 | 1835 | return $return_value; |
@@ -1822,10 +1857,12 @@ discard block |
||
| 1822 | 1857 | continue; |
| 1823 | 1858 | } |
| 1824 | 1859 | // Setup the default JOIN conditions if not specified |
| 1825 | - if (empty($relmap[1])) |
|
| 1826 | - $relmap[1] = $other->table_name; |
|
| 1827 | - if (empty($relmap[2])) |
|
| 1828 | - $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 | + } |
|
| 1829 | 1866 | $join .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]"; |
| 1830 | 1867 | } |
| 1831 | 1868 | } |
@@ -2357,8 +2394,9 @@ discard block |
||
| 2357 | 2394 | { |
| 2358 | 2395 | $adb = PearDatabase::getInstance(); |
| 2359 | 2396 | |
| 2360 | - if (!is_array($uitypes)) |
|
| 2361 | - $uitypes = array($uitypes); |
|
| 2397 | + if (!is_array($uitypes)) { |
|
| 2398 | + $uitypes = array($uitypes); |
|
| 2399 | + } |
|
| 2362 | 2400 | $module = get_class($this); |
| 2363 | 2401 | |
| 2364 | 2402 | $cachedModuleFields = VTCacheUtils::lookupFieldInfo_Module($module); |
@@ -2402,10 +2440,11 @@ discard block |
||
| 2402 | 2440 | $columnCount = count($lookupcolumns); |
| 2403 | 2441 | foreach ($lookupcolumns as $columnname) { |
| 2404 | 2442 | if (!empty($columnname)) { |
| 2405 | - if ($i == 0 || $i == ($columnCount)) |
|
| 2406 | - $query .= sprintf("%s = '%s'", $columnname, $value); |
|
| 2407 | - else |
|
| 2408 | - $query .= sprintf(" || %s = '%s'", $columnname, $value); |
|
| 2443 | + if ($i == 0 || $i == ($columnCount)) { |
|
| 2444 | + $query .= sprintf("%s = '%s'", $columnname, $value); |
|
| 2445 | + } else { |
|
| 2446 | + $query .= sprintf(" || %s = '%s'", $columnname, $value); |
|
| 2447 | + } |
|
| 2409 | 2448 | $i++; |
| 2410 | 2449 | } |
| 2411 | 2450 | } |
@@ -2613,10 +2652,11 @@ discard block |
||
| 2613 | 2652 | |
| 2614 | 2653 | $currentModule = vglobal('currentModule'); |
| 2615 | 2654 | \App\Log::trace("Entering getSortOrder() method ..."); |
| 2616 | - if (AppRequest::has('sorder')) |
|
| 2617 | - $sorder = $this->db->sql_escape_string(AppRequest::getForSql('sorder')); |
|
| 2618 | - else |
|
| 2619 | - $sorder = (($_SESSION[$currentModule . '_Sort_Order'] != '') ? ($_SESSION[$currentModule . '_Sort_Order']) : ($this->default_sort_order)); |
|
| 2655 | + if (AppRequest::has('sorder')) { |
|
| 2656 | + $sorder = $this->db->sql_escape_string(AppRequest::getForSql('sorder')); |
|
| 2657 | + } else { |
|
| 2658 | + $sorder = (($_SESSION[$currentModule . '_Sort_Order'] != '') ? ($_SESSION[$currentModule . '_Sort_Order']) : ($this->default_sort_order)); |
|
| 2659 | + } |
|
| 2620 | 2660 | \App\Log::trace("Exiting getSortOrder() method ..."); |
| 2621 | 2661 | return $sorder; |
| 2622 | 2662 | } |
@@ -2636,10 +2676,11 @@ discard block |
||
| 2636 | 2676 | $use_default_order_by = $this->default_order_by; |
| 2637 | 2677 | } |
| 2638 | 2678 | |
| 2639 | - if (AppRequest::has('order_by')) |
|
| 2640 | - $order_by = $this->db->sql_escape_string(AppRequest::getForSql('order_by')); |
|
| 2641 | - else |
|
| 2642 | - $order_by = (($_SESSION[$currentModule . '_Order_By'] != '') ? ($_SESSION[$currentModule . '_Order_By']) : ($use_default_order_by)); |
|
| 2679 | + if (AppRequest::has('order_by')) { |
|
| 2680 | + $order_by = $this->db->sql_escape_string(AppRequest::getForSql('order_by')); |
|
| 2681 | + } else { |
|
| 2682 | + $order_by = (($_SESSION[$currentModule . '_Order_By'] != '') ? ($_SESSION[$currentModule . '_Order_By']) : ($use_default_order_by)); |
|
| 2683 | + } |
|
| 2643 | 2684 | \App\Log::trace("Exiting getOrderBy method ..."); |
| 2644 | 2685 | return $order_by; |
| 2645 | 2686 | } |
@@ -2679,8 +2720,9 @@ discard block |
||
| 2679 | 2720 | $selectClause = sprintf('SELECT %s.%s AS recordid,%s%s', $this->table_name, $this->table_index, $tableColumnsString, $additionalColumns); |
| 2680 | 2721 | |
| 2681 | 2722 | // Select Custom Field Table Columns if present |
| 2682 | - if (isset($this->customFieldTable)) |
|
| 2683 | - $query .= ", " . $this->customFieldTable[0] . ".* "; |
|
| 2723 | + if (isset($this->customFieldTable)) { |
|
| 2724 | + $query .= ", " . $this->customFieldTable[0] . ".* "; |
|
| 2725 | + } |
|
| 2684 | 2726 | |
| 2685 | 2727 | $fromClause = " FROM $this->table_name"; |
| 2686 | 2728 | |
@@ -2724,8 +2766,9 @@ discard block |
||
| 2724 | 2766 | foreach ($tableColumns as $tableColumn) { |
| 2725 | 2767 | $tableInfo = explode('.', $tableColumn); |
| 2726 | 2768 | $duplicateCheckClause .= " ifnull($tableColumn,'null') = ifnull(temp.$tableInfo[1],'null')"; |
| 2727 | - if (count($tableColumns) != $i++) |
|
| 2728 | - $duplicateCheckClause .= ' && '; |
|
| 2769 | + if (count($tableColumns) != $i++) { |
|
| 2770 | + $duplicateCheckClause .= ' && '; |
|
| 2771 | + } |
|
| 2729 | 2772 | } |
| 2730 | 2773 | |
| 2731 | 2774 | $query = $selectClause . $fromClause . |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Function to get the class name of a given Component, of given Type, for a given Module |
| 101 | - * @param <String> $componentType |
|
| 101 | + * @param string $componentType |
|
| 102 | 102 | * @param <String> $componentName |
| 103 | 103 | * @param <String> $moduleName |
| 104 | 104 | * @return <String> Required Class Name |
@@ -124,8 +124,9 @@ |
||
| 124 | 124 | $secondFallBackModuleDir = $secondFallBackModuleClassPath = $actualModule; |
| 125 | 125 | if ($actualModule != 'Users') { |
| 126 | 126 | $baseModule = $moduleHierarchyParts[0]; |
| 127 | - if ($baseModule == 'Settings') |
|
| 128 | - $baseModule = 'Settings:Vtiger'; |
|
| 127 | + if ($baseModule == 'Settings') { |
|
| 128 | + $baseModule = 'Settings:Vtiger'; |
|
| 129 | + } |
|
| 129 | 130 | $firstFallBackDir = str_replace(':', '.', $baseModule); |
| 130 | 131 | $firstFallBackClassPath = str_replace(':', '_', $baseModule); |
| 131 | 132 | } |
@@ -54,6 +54,9 @@ discard block |
||
| 54 | 54 | return $user; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | + /** |
|
| 58 | + * @param Vtiger_Request $request |
|
| 59 | + */ |
|
| 57 | 60 | protected function triggerCheckPermission($handler, $request) |
| 58 | 61 | { |
| 59 | 62 | $moduleName = $request->getModule(); |
@@ -73,6 +76,9 @@ discard block |
||
| 73 | 76 | throw new \Exception\NoPermitted('LBL_NOT_ACCESSIBLE'); |
| 74 | 77 | } |
| 75 | 78 | |
| 79 | + /** |
|
| 80 | + * @param Vtiger_Request $request |
|
| 81 | + */ |
|
| 76 | 82 | protected function triggerPreProcess($handler, $request) |
| 77 | 83 | { |
| 78 | 84 | if ($request->isAjax()) { |
@@ -82,6 +88,9 @@ discard block |
||
| 82 | 88 | $handler->preProcess($request); |
| 83 | 89 | } |
| 84 | 90 | |
| 91 | + /** |
|
| 92 | + * @param Vtiger_Request $request |
|
| 93 | + */ |
|
| 85 | 94 | protected function triggerPostProcess($handler, $request) |
| 86 | 95 | { |
| 87 | 96 | if ($request->isAjax()) { |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | |
| 64 | 64 | /** Function to display the Products which are related to the PriceBook |
| 65 | 65 | * @param string $query - query to get the list of products which are related to the current PriceBook |
| 66 | - * @param object $focus - PriceBook object which contains all the information of the current PriceBook |
|
| 66 | + * @param PriceBooks $focus - PriceBook object which contains all the information of the current PriceBook |
|
| 67 | 67 | * @param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional |
| 68 | 68 | * return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Product entries |
| 69 | 69 | */ |
@@ -112,22 +112,26 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $limit_start_rec = ($start - 1) * $listMaxEntriesPerPage; |
| 114 | 114 | |
| 115 | - if ($adb->isPostgres()) |
|
| 116 | - $list_result = $adb->pquery($query . |
|
| 115 | + if ($adb->isPostgres()) { |
|
| 116 | + $list_result = $adb->pquery($query . |
|
| 117 | 117 | " OFFSET $limit_start_rec LIMIT $listMaxEntriesPerPage ", []); |
| 118 | - else |
|
| 119 | - $list_result = $adb->pquery($query . |
|
| 118 | + } else { |
|
| 119 | + $list_result = $adb->pquery($query . |
|
| 120 | 120 | " LIMIT $limit_start_rec, $listMaxEntriesPerPage ", []); |
| 121 | + } |
|
| 121 | 122 | |
| 122 | 123 | $header = []; |
| 123 | 124 | $header[] = \App\Language::translate('LBL_LIST_PRODUCT_NAME'); |
| 124 | - if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') |
|
| 125 | - $header[] = \App\Language::translate('LBL_PRODUCT_CODE'); |
|
| 126 | - if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') |
|
| 127 | - $header[] = \App\Language::translate('LBL_PRODUCT_UNIT_PRICE'); |
|
| 125 | + if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') { |
|
| 126 | + $header[] = \App\Language::translate('LBL_PRODUCT_CODE'); |
|
| 127 | + } |
|
| 128 | + if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { |
|
| 129 | + $header[] = \App\Language::translate('LBL_PRODUCT_UNIT_PRICE'); |
|
| 130 | + } |
|
| 128 | 131 | $header[] = \App\Language::translate('LBL_PB_LIST_PRICE'); |
| 129 | - if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') |
|
| 130 | - $header[] = \App\Language::translate('LBL_ACTION'); |
|
| 132 | + if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') { |
|
| 133 | + $header[] = \App\Language::translate('LBL_ACTION'); |
|
| 134 | + } |
|
| 131 | 135 | |
| 132 | 136 | $currency_id = $focus->column_fields['currency_id']; |
| 133 | 137 | $numRows = $adb->num_rows($list_result); |
@@ -143,10 +147,12 @@ discard block |
||
| 143 | 147 | |
| 144 | 148 | $entries = []; |
| 145 | 149 | $entries[] = \vtlib\Functions::textLength($adb->query_result($list_result, $i, "productname")); |
| 146 | - if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') |
|
| 147 | - $entries[] = $adb->query_result($list_result, $i, "productcode"); |
|
| 148 | - if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') |
|
| 149 | - $entries[] = CurrencyField::convertToUserFormat($unit_price, null, true); |
|
| 150 | + if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') { |
|
| 151 | + $entries[] = $adb->query_result($list_result, $i, "productcode"); |
|
| 152 | + } |
|
| 153 | + if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { |
|
| 154 | + $entries[] = CurrencyField::convertToUserFormat($unit_price, null, true); |
|
| 155 | + } |
|
| 150 | 156 | |
| 151 | 157 | $entries[] = CurrencyField::convertToUserFormat($listprice, null, true); |
| 152 | 158 | $action = ""; |
@@ -156,12 +162,14 @@ discard block |
||
| 156 | 162 | $action .= '<img src="' . vtiger_imageurl('blank.gif', $theme) . '" border="0" />'; |
| 157 | 163 | } |
| 158 | 164 | if (isPermitted("PriceBooks", "Delete", "") == 'yes' && isPermitted('Products', 'Delete', $entity_id) == 'yes') { |
| 159 | - if ($action != "") |
|
| 160 | - $action .= ' | '; |
|
| 165 | + if ($action != "") { |
|
| 166 | + $action .= ' | '; |
|
| 167 | + } |
|
| 161 | 168 | $action .= '<img src="' . vtiger_imageurl('delete.gif', $theme) . '" onclick="if(confirm(\'' . \App\Language::translate('ARE_YOU_SURE') . '\')) deletePriceBookProductRel(' . $entity_id . ',' . $pricebook_id . ');" alt="' . \App\Language::translate('LBL_DELETE') . '" title="' . \App\Language::translate('LBL_DELETE') . '" style="cursor:pointer;" border="0">'; |
| 162 | 169 | } |
| 163 | - if ($action != "") |
|
| 164 | - $entries[] = $action; |
|
| 170 | + if ($action != "") { |
|
| 171 | + $entries[] = $action; |
|
| 172 | + } |
|
| 165 | 173 | $entries_list[] = $entries; |
| 166 | 174 | } |
| 167 | 175 | $navigationOutput[] = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows); |
@@ -120,6 +120,9 @@ discard block |
||
| 120 | 120 | public $tag_start = 0; |
| 121 | 121 | private $dom = null; |
| 122 | 122 | |
| 123 | + /** |
|
| 124 | + * @param simple_html_dom $dom |
|
| 125 | + */ |
|
| 123 | 126 | public function __construct($dom) |
| 124 | 127 | { |
| 125 | 128 | $this->dom = $dom; |
@@ -1553,6 +1556,10 @@ discard block |
||
| 1553 | 1556 | } |
| 1554 | 1557 | |
| 1555 | 1558 | // parse attributes |
| 1559 | +/** |
|
| 1560 | + * @param simple_html_dom_node $node |
|
| 1561 | + * @param string[] $space |
|
| 1562 | + */ |
|
| 1556 | 1563 | protected function parse_attr($node, $name, &$space) |
| 1557 | 1564 | { |
| 1558 | 1565 | // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037 |
@@ -1589,6 +1596,10 @@ discard block |
||
| 1589 | 1596 | } |
| 1590 | 1597 | |
| 1591 | 1598 | // link node's parent |
| 1599 | +/** |
|
| 1600 | + * @param simple_html_dom_node $node |
|
| 1601 | + * @param boolean $is_child |
|
| 1602 | + */ |
|
| 1592 | 1603 | protected function link_nodes(&$node, $is_child) |
| 1593 | 1604 | { |
| 1594 | 1605 | $node->parent = $this->parent; |
@@ -1599,6 +1610,9 @@ discard block |
||
| 1599 | 1610 | } |
| 1600 | 1611 | |
| 1601 | 1612 | // as a text node |
| 1613 | +/** |
|
| 1614 | + * @param string $tag |
|
| 1615 | + */ |
|
| 1602 | 1616 | protected function as_text_node($tag) |
| 1603 | 1617 | { |
| 1604 | 1618 | $node = new simple_html_dom_node($this); |
@@ -1609,12 +1623,18 @@ discard block |
||
| 1609 | 1623 | return true; |
| 1610 | 1624 | } |
| 1611 | 1625 | |
| 1626 | +/** |
|
| 1627 | + * @param string $chars |
|
| 1628 | + */ |
|
| 1612 | 1629 | protected function skip($chars) |
| 1613 | 1630 | { |
| 1614 | 1631 | $this->pos += strspn($this->doc, $chars, $this->pos); |
| 1615 | 1632 | $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1616 | 1633 | } |
| 1617 | 1634 | |
| 1635 | +/** |
|
| 1636 | + * @param string $chars |
|
| 1637 | + */ |
|
| 1618 | 1638 | protected function copy_skip($chars) |
| 1619 | 1639 | { |
| 1620 | 1640 | $pos = $this->pos; |
@@ -1626,6 +1646,9 @@ discard block |
||
| 1626 | 1646 | return substr($this->doc, $pos, $len); |
| 1627 | 1647 | } |
| 1628 | 1648 | |
| 1649 | +/** |
|
| 1650 | + * @param string $chars |
|
| 1651 | + */ |
|
| 1629 | 1652 | protected function copy_until($chars) |
| 1630 | 1653 | { |
| 1631 | 1654 | $pos = $this->pos; |
@@ -1635,6 +1658,9 @@ discard block |
||
| 1635 | 1658 | return substr($this->doc, $pos, $len); |
| 1636 | 1659 | } |
| 1637 | 1660 | |
| 1661 | +/** |
|
| 1662 | + * @param string $char |
|
| 1663 | + */ |
|
| 1638 | 1664 | protected function copy_until_char($char) |
| 1639 | 1665 | { |
| 1640 | 1666 | if ($this->char === null) |
@@ -1655,6 +1681,9 @@ discard block |
||
| 1655 | 1681 | return substr($this->doc, $pos_old, $pos - $pos_old); |
| 1656 | 1682 | } |
| 1657 | 1683 | |
| 1684 | +/** |
|
| 1685 | + * @param string $char |
|
| 1686 | + */ |
|
| 1658 | 1687 | protected function copy_until_char_escape($char) |
| 1659 | 1688 | { |
| 1660 | 1689 | if ($this->char === null) |
@@ -1686,6 +1715,9 @@ discard block |
||
| 1686 | 1715 | |
| 1687 | 1716 | // remove noise from html content |
| 1688 | 1717 | // save the noise in the $this->noise array. |
| 1718 | +/** |
|
| 1719 | + * @param string $pattern |
|
| 1720 | + */ |
|
| 1689 | 1721 | protected function remove_noise($pattern, $remove_tag = false) |
| 1690 | 1722 | { |
| 1691 | 1723 | global $debugObject; |
@@ -1713,6 +1745,9 @@ discard block |
||
| 1713 | 1745 | } |
| 1714 | 1746 | |
| 1715 | 1747 | // restore noise to html content |
| 1748 | +/** |
|
| 1749 | + * @param string|null $text |
|
| 1750 | + */ |
|
| 1716 | 1751 | function restore_noise($text) |
| 1717 | 1752 | { |
| 1718 | 1753 | global $debugObject; |
@@ -399,9 +399,9 @@ discard block |
||
| 399 | 399 | if (isset($this->_[HDOM_INFO_INNER])) |
| 400 | 400 | return $this->_[HDOM_INFO_INNER]; |
| 401 | 401 | switch ($this->nodetype) { |
| 402 | - case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 403 | - case HDOM_TYPE_COMMENT: return ''; |
|
| 404 | - case HDOM_TYPE_UNKNOWN: return ''; |
|
| 402 | + case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
| 403 | + case HDOM_TYPE_COMMENT: return ''; |
|
| 404 | + case HDOM_TYPE_UNKNOWN: return ''; |
|
| 405 | 405 | } |
| 406 | 406 | if (strcasecmp($this->tag, 'script') === 0) |
| 407 | 407 | return ''; |
@@ -640,19 +640,19 @@ discard block |
||
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | switch ($exp) { |
| 643 | - case '=': |
|
| 644 | - return ($value === $pattern); |
|
| 645 | - case '!=': |
|
| 646 | - return ($value !== $pattern); |
|
| 647 | - case '^=': |
|
| 648 | - return preg_match("/^" . preg_quote($pattern, '/') . "/", $value); |
|
| 649 | - case '$=': |
|
| 650 | - return preg_match("/" . preg_quote($pattern, '/') . "$/", $value); |
|
| 651 | - case '*=': |
|
| 652 | - if ($pattern[0] == '/') { |
|
| 653 | - return preg_match($pattern, $value); |
|
| 654 | - } |
|
| 655 | - return preg_match("/" . $pattern . "/i", $value); |
|
| 643 | + case '=': |
|
| 644 | + return ($value === $pattern); |
|
| 645 | + case '!=': |
|
| 646 | + return ($value !== $pattern); |
|
| 647 | + case '^=': |
|
| 648 | + return preg_match("/^" . preg_quote($pattern, '/') . "/", $value); |
|
| 649 | + case '$=': |
|
| 650 | + return preg_match("/" . preg_quote($pattern, '/') . "$/", $value); |
|
| 651 | + case '*=': |
|
| 652 | + if ($pattern[0] == '/') { |
|
| 653 | + return preg_match($pattern, $value); |
|
| 654 | + } |
|
| 655 | + return preg_match("/" . $pattern . "/i", $value); |
|
| 656 | 656 | } |
| 657 | 657 | return false; |
| 658 | 658 | } |
@@ -736,11 +736,11 @@ discard block |
||
| 736 | 736 | return $this->convert_text($this->attr[$name]); |
| 737 | 737 | } |
| 738 | 738 | switch ($name) { |
| 739 | - case 'outertext': return $this->outertext(); |
|
| 740 | - case 'innertext': return $this->innertext(); |
|
| 741 | - case 'plaintext': return $this->text(); |
|
| 742 | - case 'xmltext': return $this->xmltext(); |
|
| 743 | - default: return array_key_exists($name, $this->attr); |
|
| 739 | + case 'outertext': return $this->outertext(); |
|
| 740 | + case 'innertext': return $this->innertext(); |
|
| 741 | + case 'plaintext': return $this->text(); |
|
| 742 | + case 'xmltext': return $this->xmltext(); |
|
| 743 | + default: return array_key_exists($name, $this->attr); |
|
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | // I am SURE that this doesn't work properly. |
| 226 | 226 | // It fails to unset the current node from it's current parents nodes or children list first. |
| 227 | - if($parent !== null) |
|
| 227 | + if ($parent !== null) |
|
| 228 | 228 | { |
| 229 | 229 | $this->parent = $parent; |
| 230 | 230 | $this->parent->nodes[] = $this; |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | $node->tag = 'unknown'; |
| 1428 | 1428 | } |
| 1429 | 1429 | if ($this->char === '>') |
| 1430 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1430 | + $node->_[HDOM_INFO_TEXT] .= '>'; |
|
| 1431 | 1431 | $this->link_nodes($node, true); |
| 1432 | 1432 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1433 | 1433 | return true; |
@@ -1450,7 +1450,7 @@ discard block |
||
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | 1452 | if ($this->char === '>') |
| 1453 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1453 | + $node->_[HDOM_INFO_TEXT] .= '>'; |
|
| 1454 | 1454 | $this->link_nodes($node, false); |
| 1455 | 1455 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1456 | 1456 | return true; |
@@ -153,8 +153,9 @@ discard block |
||
| 153 | 153 | echo $lead . $this->tag; |
| 154 | 154 | if ($show_attr && count($this->attr) > 0) { |
| 155 | 155 | echo '('; |
| 156 | - foreach ($this->attr as $k => $v) |
|
| 157 | - echo "[$k]=>\"" . $this->$k . '", '; |
|
| 156 | + foreach ($this->attr as $k => $v) { |
|
| 157 | + echo "[$k]=>\"" . $this->$k . '", '; |
|
| 158 | + } |
|
| 158 | 159 | echo ')'; |
| 159 | 160 | } |
| 160 | 161 | echo "\n"; |
@@ -246,8 +247,9 @@ discard block |
||
| 246 | 247 | if ($idx === -1) { |
| 247 | 248 | return $this->children; |
| 248 | 249 | } |
| 249 | -if (isset($this->children[$idx])) |
|
| 250 | +if (isset($this->children[$idx])) { |
|
| 250 | 251 | return $this->children[$idx]; |
| 252 | +} |
|
| 251 | 253 | return null; |
| 252 | 254 | } |
| 253 | 255 | |
@@ -290,14 +292,17 @@ discard block |
||
| 290 | 292 | // returns the previous sibling of node |
| 291 | 293 | function prev_sibling() |
| 292 | 294 | { |
| 293 | -if ($this->parent === null) |
|
| 295 | +if ($this->parent === null) { |
|
| 294 | 296 | return null; |
| 297 | +} |
|
| 295 | 298 | $idx = 0; |
| 296 | 299 | $count = count($this->parent->children); |
| 297 | -while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
| 300 | +while ($idx < $count && $this !== $this->parent->children[$idx]) { |
|
| 298 | 301 | ++$idx; |
| 299 | -if (--$idx < 0) |
|
| 302 | +} |
|
| 303 | +if (--$idx < 0) { |
|
| 300 | 304 | return null; |
| 305 | +} |
|
| 301 | 306 | return $this->parent->children[$idx]; |
| 302 | 307 | } |
| 303 | 308 | |
@@ -328,14 +333,17 @@ discard block |
||
| 328 | 333 | // get dom node's inner html |
| 329 | 334 | function innertext() |
| 330 | 335 | { |
| 331 | -if (isset($this->_[HDOM_INFO_INNER])) |
|
| 336 | +if (isset($this->_[HDOM_INFO_INNER])) { |
|
| 332 | 337 | return $this->_[HDOM_INFO_INNER]; |
| 333 | -if (isset($this->_[HDOM_INFO_TEXT])) |
|
| 338 | +} |
|
| 339 | +if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 334 | 340 | return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
| 341 | +} |
|
| 335 | 342 | |
| 336 | 343 | $ret = ''; |
| 337 | -foreach ($this->nodes as $n) |
|
| 344 | +foreach ($this->nodes as $n) { |
|
| 338 | 345 | $ret .= $n->outertext(); |
| 346 | +} |
|
| 339 | 347 | return $ret; |
| 340 | 348 | } |
| 341 | 349 | |
@@ -353,18 +361,21 @@ discard block |
||
| 353 | 361 | $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text); |
| 354 | 362 | } |
| 355 | 363 | |
| 356 | -if ($this->tag === 'root') |
|
| 364 | +if ($this->tag === 'root') { |
|
| 357 | 365 | return $this->innertext(); |
| 366 | +} |
|
| 358 | 367 | |
| 359 | 368 | // trigger callback |
| 360 | 369 | if ($this->dom && $this->dom->callback !== null) { |
| 361 | 370 | call_user_func_array($this->dom->callback, array($this)); |
| 362 | 371 | } |
| 363 | 372 | |
| 364 | -if (isset($this->_[HDOM_INFO_OUTER])) |
|
| 373 | +if (isset($this->_[HDOM_INFO_OUTER])) { |
|
| 365 | 374 | return $this->_[HDOM_INFO_OUTER]; |
| 366 | -if (isset($this->_[HDOM_INFO_TEXT])) |
|
| 375 | +} |
|
| 376 | +if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 367 | 377 | return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
| 378 | +} |
|
| 368 | 379 | |
| 369 | 380 | // render begin tag |
| 370 | 381 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) { |
@@ -388,25 +399,29 @@ discard block |
||
| 388 | 399 | } |
| 389 | 400 | |
| 390 | 401 | // render end tag |
| 391 | -if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) |
|
| 402 | +if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) { |
|
| 392 | 403 | $ret .= '</' . $this->tag . '>'; |
| 404 | +} |
|
| 393 | 405 | return $ret; |
| 394 | 406 | } |
| 395 | 407 | |
| 396 | 408 | // get dom node's plain text |
| 397 | 409 | function text() |
| 398 | 410 | { |
| 399 | -if (isset($this->_[HDOM_INFO_INNER])) |
|
| 411 | +if (isset($this->_[HDOM_INFO_INNER])) { |
|
| 400 | 412 | return $this->_[HDOM_INFO_INNER]; |
| 413 | +} |
|
| 401 | 414 | switch ($this->nodetype) { |
| 402 | 415 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
| 403 | 416 | case HDOM_TYPE_COMMENT: return ''; |
| 404 | 417 | case HDOM_TYPE_UNKNOWN: return ''; |
| 405 | 418 | } |
| 406 | -if (strcasecmp($this->tag, 'script') === 0) |
|
| 419 | +if (strcasecmp($this->tag, 'script') === 0) { |
|
| 407 | 420 | return ''; |
| 408 | -if (strcasecmp($this->tag, 'style') === 0) |
|
| 421 | +} |
|
| 422 | +if (strcasecmp($this->tag, 'style') === 0) { |
|
| 409 | 423 | return ''; |
| 424 | +} |
|
| 410 | 425 | |
| 411 | 426 | $ret = ''; |
| 412 | 427 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -437,8 +452,9 @@ discard block |
||
| 437 | 452 | function makeup() |
| 438 | 453 | { |
| 439 | 454 | // text, comment, unknown |
| 440 | -if (isset($this->_[HDOM_INFO_TEXT])) |
|
| 455 | +if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 441 | 456 | return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
| 457 | +} |
|
| 442 | 458 | |
| 443 | 459 | $ret = '<' . $this->tag; |
| 444 | 460 | $i = -1; |
@@ -447,14 +463,15 @@ discard block |
||
| 447 | 463 | ++$i; |
| 448 | 464 | |
| 449 | 465 | // skip removed attribute |
| 450 | - if ($val === null || $val === false) |
|
| 451 | - continue; |
|
| 466 | + if ($val === null || $val === false) { |
|
| 467 | + continue; |
|
| 468 | + } |
|
| 452 | 469 | |
| 453 | 470 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
| 454 | 471 | //no value attr: nowrap, checked selected... |
| 455 | - if ($val === true) |
|
| 456 | - $ret .= $key; |
|
| 457 | - else { |
|
| 472 | + if ($val === true) { |
|
| 473 | + $ret .= $key; |
|
| 474 | + } else { |
|
| 458 | 475 | switch ($this->_[HDOM_INFO_QUOTE][$i]) { |
| 459 | 476 | case HDOM_QUOTE_DOUBLE: $quote = '"'; |
| 460 | 477 | break; |
@@ -474,18 +491,21 @@ discard block |
||
| 474 | 491 | function find($selector, $idx = null, $lowercase = false) |
| 475 | 492 | { |
| 476 | 493 | $selectors = $this->parse_selector($selector); |
| 477 | -if (($count = count($selectors)) === 0) |
|
| 494 | +if (($count = count($selectors)) === 0) { |
|
| 478 | 495 | return []; |
| 496 | +} |
|
| 479 | 497 | $found_keys = []; |
| 480 | 498 | |
| 481 | 499 | // find each selector |
| 482 | 500 | for ($c = 0; $c < $count; ++$c) { |
| 483 | 501 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
| 484 | 502 | // used to be: if (($levle=count($selectors[0]))===0) return []; |
| 485 | - if (($levle = count($selectors[$c])) === 0) |
|
| 486 | - return []; |
|
| 487 | - if (!isset($this->_[HDOM_INFO_BEGIN])) |
|
| 488 | - return []; |
|
| 503 | + if (($levle = count($selectors[$c])) === 0) { |
|
| 504 | + return []; |
|
| 505 | + } |
|
| 506 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
| 507 | + return []; |
|
| 508 | + } |
|
| 489 | 509 | |
| 490 | 510 | $head = array($this->_[HDOM_INFO_BEGIN] => 1); |
| 491 | 511 | |
@@ -501,8 +521,9 @@ discard block |
||
| 501 | 521 | } |
| 502 | 522 | |
| 503 | 523 | foreach ($head as $k => $v) { |
| 504 | - if (!isset($found_keys[$k])) |
|
| 505 | - $found_keys[$k] = 1; |
|
| 524 | + if (!isset($found_keys[$k])) { |
|
| 525 | + $found_keys[$k] = 1; |
|
| 526 | + } |
|
| 506 | 527 | } |
| 507 | 528 | } |
| 508 | 529 | |
@@ -510,14 +531,16 @@ discard block |
||
| 510 | 531 | ksort($found_keys); |
| 511 | 532 | |
| 512 | 533 | $found = []; |
| 513 | -foreach ($found_keys as $k => $v) |
|
| 534 | +foreach ($found_keys as $k => $v) { |
|
| 514 | 535 | $found[] = $this->dom->nodes[$k]; |
| 536 | +} |
|
| 515 | 537 | |
| 516 | 538 | // return nth-element or array |
| 517 | -if (is_null($idx)) |
|
| 539 | +if (is_null($idx)) { |
|
| 518 | 540 | return $found; |
| 519 | -else if ($idx < 0) |
|
| 541 | +} else if ($idx < 0) { |
|
| 520 | 542 | $idx = count($found) + $idx; |
| 543 | +} |
|
| 521 | 544 | return (isset($found[$idx])) ? $found[$idx] : null; |
| 522 | 545 | } |
| 523 | 546 | |
@@ -562,8 +585,9 @@ discard block |
||
| 562 | 585 | $pass = true; |
| 563 | 586 | |
| 564 | 587 | if ($tag === '*' && !$key) { |
| 565 | - if (in_array($node, $this->children, true)) |
|
| 566 | - $ret[$i] = 1; |
|
| 588 | + if (in_array($node, $this->children, true)) { |
|
| 589 | + $ret[$i] = 1; |
|
| 590 | + } |
|
| 567 | 591 | continue; |
| 568 | 592 | } |
| 569 | 593 | |
@@ -574,11 +598,13 @@ discard block |
||
| 574 | 598 | // compare key |
| 575 | 599 | if ($pass && $key) { |
| 576 | 600 | if ($no_key) { |
| 577 | - if (isset($node->attr[$key])) |
|
| 578 | - $pass = false; |
|
| 601 | + if (isset($node->attr[$key])) { |
|
| 602 | + $pass = false; |
|
| 603 | + } |
|
| 579 | 604 | } else { |
| 580 | - if (($key != "plaintext") && !isset($node->attr[$key])) |
|
| 581 | - $pass = false; |
|
| 605 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
| 606 | + $pass = false; |
|
| 607 | + } |
|
| 582 | 608 | } |
| 583 | 609 | } |
| 584 | 610 | // compare value |
@@ -614,16 +640,19 @@ discard block |
||
| 614 | 640 | } else { |
| 615 | 641 | $check = $this->match($exp, $val, $k); |
| 616 | 642 | } |
| 617 | - if ($check) |
|
| 618 | - break; |
|
| 643 | + if ($check) { |
|
| 644 | + break; |
|
| 645 | + } |
|
| 619 | 646 | } |
| 620 | 647 | } |
| 621 | 648 | } |
| 622 | - if (!$check) |
|
| 623 | - $pass = false; |
|
| 649 | + if (!$check) { |
|
| 650 | + $pass = false; |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + if ($pass) { |
|
| 654 | + $ret[$i] = 1; |
|
| 624 | 655 | } |
| 625 | - if ($pass) |
|
| 626 | - $ret[$i] = 1; |
|
| 627 | 656 | unset($node); |
| 628 | 657 | } |
| 629 | 658 | // It's passed by reference so this is actually what this function returns. |
@@ -683,11 +712,13 @@ discard block |
||
| 683 | 712 | |
| 684 | 713 | foreach ($matches as $m) { |
| 685 | 714 | $m[0] = trim($m[0]); |
| 686 | - if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') |
|
| 687 | - continue; |
|
| 715 | + if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') { |
|
| 716 | + continue; |
|
| 717 | + } |
|
| 688 | 718 | // for browser generated xpath |
| 689 | - if ($m[1] === 'tbody') |
|
| 690 | - continue; |
|
| 719 | + if ($m[1] === 'tbody') { |
|
| 720 | + continue; |
|
| 721 | + } |
|
| 691 | 722 | |
| 692 | 723 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
| 693 | 724 | if (!empty($m[2])) { |
@@ -725,8 +756,9 @@ discard block |
||
| 725 | 756 | $result = []; |
| 726 | 757 | } |
| 727 | 758 | } |
| 728 | -if (count($result) > 0) |
|
| 759 | +if (count($result) > 0) { |
|
| 729 | 760 | $selectors[] = $result; |
| 761 | +} |
|
| 730 | 762 | return $selectors; |
| 731 | 763 | } |
| 732 | 764 | |
@@ -749,8 +781,9 @@ discard block |
||
| 749 | 781 | switch ($name) { |
| 750 | 782 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
| 751 | 783 | case 'innertext': |
| 752 | - if (isset($this->_[HDOM_INFO_TEXT])) |
|
| 753 | - return $this->_[HDOM_INFO_TEXT] = $value; |
|
| 784 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
| 785 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
| 786 | + } |
|
| 754 | 787 | return $this->_[HDOM_INFO_INNER] = $value; |
| 755 | 788 | } |
| 756 | 789 | if (!isset($this->attr[$name])) { |
@@ -773,9 +806,10 @@ discard block |
||
| 773 | 806 | |
| 774 | 807 | function __unset($name) |
| 775 | 808 | { |
| 776 | -if (isset($this->attr[$name])) |
|
| 809 | +if (isset($this->attr[$name])) { |
|
| 777 | 810 | unset($this->attr[$name]); |
| 778 | 811 | } |
| 812 | +} |
|
| 779 | 813 | |
| 780 | 814 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
| 781 | 815 | function convert_text($text) |
@@ -835,27 +869,30 @@ discard block |
||
| 835 | 869 | for ($i = 0; $i < $len; $i++) { |
| 836 | 870 | $c = ord($str[$i]); |
| 837 | 871 | if ($c > 128) { |
| 838 | - if (($c >= 254)) |
|
| 839 | - return false; |
|
| 840 | - elseif ($c >= 252) |
|
| 841 | - $bits = 6; |
|
| 842 | - elseif ($c >= 248) |
|
| 843 | - $bits = 5; |
|
| 844 | - elseif ($c >= 240) |
|
| 845 | - $bits = 4; |
|
| 846 | - elseif ($c >= 224) |
|
| 847 | - $bits = 3; |
|
| 848 | - elseif ($c >= 192) |
|
| 849 | - $bits = 2; |
|
| 850 | - else |
|
| 851 | - return false; |
|
| 852 | - if (($i + $bits) > $len) |
|
| 853 | - return false; |
|
| 872 | + if (($c >= 254)) { |
|
| 873 | + return false; |
|
| 874 | + } elseif ($c >= 252) { |
|
| 875 | + $bits = 6; |
|
| 876 | + } elseif ($c >= 248) { |
|
| 877 | + $bits = 5; |
|
| 878 | + } elseif ($c >= 240) { |
|
| 879 | + $bits = 4; |
|
| 880 | + } elseif ($c >= 224) { |
|
| 881 | + $bits = 3; |
|
| 882 | + } elseif ($c >= 192) { |
|
| 883 | + $bits = 2; |
|
| 884 | + } else { |
|
| 885 | + return false; |
|
| 886 | + } |
|
| 887 | + if (($i + $bits) > $len) { |
|
| 888 | + return false; |
|
| 889 | + } |
|
| 854 | 890 | while ($bits > 1) { |
| 855 | 891 | $i++; |
| 856 | 892 | $b = ord($str[$i]); |
| 857 | - if ($b < 128 || $b > 191) |
|
| 858 | - return false; |
|
| 893 | + if ($b < 128 || $b > 191) { |
|
| 894 | + return false; |
|
| 895 | + } |
|
| 859 | 896 | $bits--; |
| 860 | 897 | } |
| 861 | 898 | } |
@@ -1175,8 +1212,9 @@ discard block |
||
| 1175 | 1212 | function save($filepath = '') |
| 1176 | 1213 | { |
| 1177 | 1214 | $ret = $this->root->innertext(); |
| 1178 | -if ($filepath !== '') |
|
| 1215 | +if ($filepath !== '') { |
|
| 1179 | 1216 | file_put_contents($filepath, $ret, LOCK_EX); |
| 1217 | +} |
|
| 1180 | 1218 | return $ret; |
| 1181 | 1219 | } |
| 1182 | 1220 | |
@@ -1195,9 +1233,10 @@ discard block |
||
| 1195 | 1233 | $n = null; |
| 1196 | 1234 | } |
| 1197 | 1235 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
| 1198 | -if (isset($this->children)) |
|
| 1236 | +if (isset($this->children)) { |
|
| 1199 | 1237 | foreach ($this->children as $n) { |
| 1200 | 1238 | $n->clear(); |
| 1239 | +} |
|
| 1201 | 1240 | $n = null; |
| 1202 | 1241 | } |
| 1203 | 1242 | if (isset($this->parent)) { |
@@ -1249,9 +1288,10 @@ discard block |
||
| 1249 | 1288 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
| 1250 | 1289 | $this->root->nodetype = HDOM_TYPE_ROOT; |
| 1251 | 1290 | $this->parent = $this->root; |
| 1252 | -if ($this->size > 0) |
|
| 1291 | +if ($this->size > 0) { |
|
| 1253 | 1292 | $this->char = $this->doc[0]; |
| 1254 | 1293 | } |
| 1294 | +} |
|
| 1255 | 1295 | |
| 1256 | 1296 | // parse html content |
| 1257 | 1297 | protected function parse() |
@@ -1360,8 +1400,9 @@ discard block |
||
| 1360 | 1400 | $tag = $this->copy_until_char('>'); |
| 1361 | 1401 | |
| 1362 | 1402 | // skip attributes in end tag |
| 1363 | - if (($pos = strpos($tag, ' ')) !== false) |
|
| 1364 | - $tag = substr($tag, 0, $pos); |
|
| 1403 | + if (($pos = strpos($tag, ' ')) !== false) { |
|
| 1404 | + $tag = substr($tag, 0, $pos); |
|
| 1405 | + } |
|
| 1365 | 1406 | |
| 1366 | 1407 | $parent_lower = strtolower($this->parent->tag); |
| 1367 | 1408 | $tag_lower = strtolower($tag); |
@@ -1371,23 +1412,25 @@ discard block |
||
| 1371 | 1412 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1372 | 1413 | $org_parent = $this->parent; |
| 1373 | 1414 | |
| 1374 | - while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
| 1375 | - $this->parent = $this->parent->parent; |
|
| 1415 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) { |
|
| 1416 | + $this->parent = $this->parent->parent; |
|
| 1417 | + } |
|
| 1376 | 1418 | |
| 1377 | 1419 | if (strtolower($this->parent->tag) !== $tag_lower) { |
| 1378 | 1420 | $this->parent = $org_parent; // restore origonal parent |
| 1379 | - if ($this->parent->parent) |
|
| 1380 | - $this->parent = $this->parent->parent; |
|
| 1421 | + if ($this->parent->parent) { |
|
| 1422 | + $this->parent = $this->parent->parent; |
|
| 1423 | + } |
|
| 1381 | 1424 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1382 | 1425 | return $this->as_text_node($tag); |
| 1383 | 1426 | } |
| 1384 | - } |
|
| 1385 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) { |
|
| 1427 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) { |
|
| 1386 | 1428 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1387 | 1429 | $org_parent = $this->parent; |
| 1388 | 1430 | |
| 1389 | - while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
| 1390 | - $this->parent = $this->parent->parent; |
|
| 1431 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) { |
|
| 1432 | + $this->parent = $this->parent->parent; |
|
| 1433 | + } |
|
| 1391 | 1434 | |
| 1392 | 1435 | if (strtolower($this->parent->tag) !== $tag_lower) { |
| 1393 | 1436 | $this->parent = $org_parent; // restore origonal parent |
@@ -1397,13 +1440,15 @@ discard block |
||
| 1397 | 1440 | } else if (($this->parent->parent) && strtolower($this->parent->parent->tag) === $tag_lower) { |
| 1398 | 1441 | $this->parent->_[HDOM_INFO_END] = 0; |
| 1399 | 1442 | $this->parent = $this->parent->parent; |
| 1400 | - } else |
|
| 1401 | - return $this->as_text_node($tag); |
|
| 1443 | + } else { |
|
| 1444 | + return $this->as_text_node($tag); |
|
| 1445 | + } |
|
| 1402 | 1446 | } |
| 1403 | 1447 | |
| 1404 | 1448 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
| 1405 | - if ($this->parent->parent) |
|
| 1406 | - $this->parent = $this->parent->parent; |
|
| 1449 | + if ($this->parent->parent) { |
|
| 1450 | + $this->parent = $this->parent->parent; |
|
| 1451 | + } |
|
| 1407 | 1452 | |
| 1408 | 1453 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1409 | 1454 | return true; |
@@ -1426,8 +1471,9 @@ discard block |
||
| 1426 | 1471 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
| 1427 | 1472 | $node->tag = 'unknown'; |
| 1428 | 1473 | } |
| 1429 | - if ($this->char === '>') |
|
| 1430 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1474 | + if ($this->char === '>') { |
|
| 1475 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1476 | + } |
|
| 1431 | 1477 | $this->link_nodes($node, true); |
| 1432 | 1478 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1433 | 1479 | return true; |
@@ -1449,8 +1495,9 @@ discard block |
||
| 1449 | 1495 | return true; |
| 1450 | 1496 | } |
| 1451 | 1497 | |
| 1452 | - if ($this->char === '>') |
|
| 1453 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1498 | + if ($this->char === '>') { |
|
| 1499 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
| 1500 | + } |
|
| 1454 | 1501 | $this->link_nodes($node, false); |
| 1455 | 1502 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1456 | 1503 | return true; |
@@ -1511,8 +1558,9 @@ discard block |
||
| 1511 | 1558 | if ($name !== '/' && $name !== '') { |
| 1512 | 1559 | $space[1] = $this->copy_skip($this->token_blank); |
| 1513 | 1560 | $name = $this->restore_noise($name); |
| 1514 | - if ($this->lowercase) |
|
| 1515 | - $name = strtolower($name); |
|
| 1561 | + if ($this->lowercase) { |
|
| 1562 | + $name = strtolower($name); |
|
| 1563 | + } |
|
| 1516 | 1564 | if ($this->char === '=') { |
| 1517 | 1565 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1518 | 1566 | $this->parse_attr($node, $name, $space); |
@@ -1520,14 +1568,17 @@ discard block |
||
| 1520 | 1568 | //no value attr: nowrap, checked selected... |
| 1521 | 1569 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
| 1522 | 1570 | $node->attr[$name] = true; |
| 1523 | - if ($this->char != '>') |
|
| 1524 | - $this->char = $this->doc[--$this->pos]; // prev |
|
| 1571 | + if ($this->char != '>') { |
|
| 1572 | + $this->char = $this->doc[--$this->pos]; |
|
| 1573 | + } |
|
| 1574 | + // prev |
|
| 1525 | 1575 | } |
| 1526 | 1576 | $node->_[HDOM_INFO_SPACE][] = $space; |
| 1527 | 1577 | $space = array($this->copy_skip($this->token_blank), '', ''); |
| 1528 | - } else |
|
| 1529 | - break; |
|
| 1530 | -} while ($this->char !== '>' && $this->char !== '/'); |
|
| 1578 | + } else { |
|
| 1579 | + break; |
|
| 1580 | + } |
|
| 1581 | + } while ($this->char !== '>' && $this->char !== '/'); |
|
| 1531 | 1582 | |
| 1532 | 1583 | $this->link_nodes($node, true); |
| 1533 | 1584 | $node->_[HDOM_INFO_ENDSPACE] = $space[0]; |
@@ -1538,9 +1589,10 @@ discard block |
||
| 1538 | 1589 | $node->_[HDOM_INFO_END] = 0; |
| 1539 | 1590 | } else { |
| 1540 | 1591 | // reset parent |
| 1541 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) |
|
| 1542 | - $this->parent = $node; |
|
| 1543 | -} |
|
| 1592 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
| 1593 | + $this->parent = $node; |
|
| 1594 | + } |
|
| 1595 | + } |
|
| 1544 | 1596 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1545 | 1597 | // If it's a BR tag, we need to set it's text to the default text. |
| 1546 | 1598 | // This way when we see it in plaintext, we can generate formatting that the user wants. |
@@ -1621,8 +1673,9 @@ discard block |
||
| 1621 | 1673 | $len = strspn($this->doc, $chars, $pos); |
| 1622 | 1674 | $this->pos += $len; |
| 1623 | 1675 | $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
| 1624 | -if ($len === 0) |
|
| 1676 | +if ($len === 0) { |
|
| 1625 | 1677 | return ''; |
| 1678 | +} |
|
| 1626 | 1679 | return substr($this->doc, $pos, $len); |
| 1627 | 1680 | } |
| 1628 | 1681 | |
@@ -1637,8 +1690,9 @@ discard block |
||
| 1637 | 1690 | |
| 1638 | 1691 | protected function copy_until_char($char) |
| 1639 | 1692 | { |
| 1640 | -if ($this->char === null) |
|
| 1693 | +if ($this->char === null) { |
|
| 1641 | 1694 | return ''; |
| 1695 | +} |
|
| 1642 | 1696 | |
| 1643 | 1697 | if (($pos = strpos($this->doc, $char, $this->pos)) === false) { |
| 1644 | 1698 | $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
@@ -1647,8 +1701,9 @@ discard block |
||
| 1647 | 1701 | return $ret; |
| 1648 | 1702 | } |
| 1649 | 1703 | |
| 1650 | -if ($pos === $this->pos) |
|
| 1704 | +if ($pos === $this->pos) { |
|
| 1651 | 1705 | return ''; |
| 1706 | +} |
|
| 1652 | 1707 | $pos_old = $this->pos; |
| 1653 | 1708 | $this->char = $this->doc[$pos]; |
| 1654 | 1709 | $this->pos = $pos; |
@@ -1657,8 +1712,9 @@ discard block |
||
| 1657 | 1712 | |
| 1658 | 1713 | protected function copy_until_char_escape($char) |
| 1659 | 1714 | { |
| 1660 | -if ($this->char === null) |
|
| 1715 | +if ($this->char === null) { |
|
| 1661 | 1716 | return ''; |
| 1717 | +} |
|
| 1662 | 1718 | |
| 1663 | 1719 | $start = $this->pos; |
| 1664 | 1720 | while (1) { |
@@ -1669,8 +1725,9 @@ discard block |
||
| 1669 | 1725 | return $ret; |
| 1670 | 1726 | } |
| 1671 | 1727 | |
| 1672 | - if ($pos === $this->pos) |
|
| 1673 | - return ''; |
|
| 1728 | + if ($pos === $this->pos) { |
|
| 1729 | + return ''; |
|
| 1730 | + } |
|
| 1674 | 1731 | |
| 1675 | 1732 | if ($this->doc[$pos - 1] === '\\') { |
| 1676 | 1733 | $start = $pos + 1; |
@@ -59,6 +59,8 @@ |
||
| 59 | 59 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
| 60 | 60 | * All Rights Reserved. |
| 61 | 61 | * Contributor(s): ______________________________________.. |
| 62 | + * @param string $item_id |
|
| 63 | + * @param string $item_summary |
|
| 62 | 64 | */ |
| 63 | 65 | public function track_view($user_id, $current_module, $item_id, $item_summary) |
| 64 | 66 | { |
@@ -80,8 +80,9 @@ |
||
| 80 | 80 | $fieldlists = explode(',', $fieldsname); |
| 81 | 81 | $fl = []; |
| 82 | 82 | foreach ($fieldlists as $w => $c) { |
| 83 | - if (count($fl)) |
|
| 84 | - $fl[] = "' '"; |
|
| 83 | + if (count($fl)) { |
|
| 84 | + $fl[] = "' '"; |
|
| 85 | + } |
|
| 85 | 86 | $fl[] = $c; |
| 86 | 87 | } |
| 87 | 88 | $fieldsname = $adb->concat($fl); |
@@ -378,6 +378,11 @@ |
||
| 378 | 378 | * Returns an string value |
| 379 | 379 | */ |
| 380 | 380 | |
| 381 | +/** |
|
| 382 | + * @param string $url_qry |
|
| 383 | + * @param string $module |
|
| 384 | + * @param string $related_module |
|
| 385 | + */ |
|
| 381 | 386 | function getRelatedTableHeaderNavigation($navigation_array, $url_qry, $module, $related_module, $recordid) |
| 382 | 387 | { |
| 383 | 388 | $log = LoggerManager::getInstance(); |
@@ -592,7 +592,7 @@ |
||
| 592 | 592 | $chars = preg_split('/(&[^;\s]+;)|/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE); |
| 593 | 593 | $html_length = count($chars); |
| 594 | 594 | // check if we can predict the return value and save some processing time |
| 595 | - if (($html_length === 0) || ( $start >= $html_length) || ( isset($length) && ( $length <= -$html_length))) |
|
| 595 | + if (($html_length === 0) || ($start >= $html_length) || (isset($length) && ($length <= -$html_length))) |
|
| 596 | 596 | return ""; |
| 597 | 597 | |
| 598 | 598 | //calculate start position |
@@ -351,18 +351,21 @@ discard block |
||
| 351 | 351 | $start = $_SESSION['rlvs'][$module][$related]['start']; |
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | - if (AppRequest::has('viewname') && AppRequest::get('viewname') != '') |
|
| 355 | - $lv_array['viewname'] = AppRequest::get('viewname'); |
|
| 354 | + if (AppRequest::has('viewname') && AppRequest::get('viewname') != '') { |
|
| 355 | + $lv_array['viewname'] = AppRequest::get('viewname'); |
|
| 356 | + } |
|
| 356 | 357 | |
| 357 | - if ($related == '') |
|
| 358 | - $_SESSION['lvs'][AppRequest::get('module')] = $lv_array; |
|
| 359 | - else |
|
| 360 | - $_SESSION['rlvs'][$module][$related] = $lv_array; |
|
| 358 | + if ($related == '') { |
|
| 359 | + $_SESSION['lvs'][AppRequest::get('module')] = $lv_array; |
|
| 360 | + } else { |
|
| 361 | + $_SESSION['rlvs'][$module][$related] = $lv_array; |
|
| 362 | + } |
|
| 361 | 363 | |
| 362 | 364 | if ($start < ceil($noofrows / $max_ent) && $start != '') { |
| 363 | 365 | $start = ceil($noofrows / $max_ent); |
| 364 | - if ($related == '') |
|
| 365 | - $_SESSION['lvs'][$currentModule]['start'] = $start; |
|
| 366 | + if ($related == '') { |
|
| 367 | + $_SESSION['lvs'][$currentModule]['start'] = $start; |
|
| 368 | + } |
|
| 366 | 369 | } |
| 367 | 370 | } |
| 368 | 371 | /* * Function to get the table headers for related listview |
@@ -385,8 +388,9 @@ discard block |
||
| 385 | 388 | |
| 386 | 389 | $relatedListResult = $adb->pquery('SELECT * FROM vtiger_relatedlists WHERE tabid=? AND |
| 387 | 390 | related_tabid=?', array($tabid, $relatedTabId)); |
| 388 | - if (empty($relatedListResult)) |
|
| 389 | - return; |
|
| 391 | + if (empty($relatedListResult)) { |
|
| 392 | + return; |
|
| 393 | + } |
|
| 390 | 394 | $relatedListRow = $adb->fetchByAssoc($relatedListResult); |
| 391 | 395 | $header = $relatedListRow['label']; |
| 392 | 396 | $actions = $relatedListRow['actions']; |
@@ -435,11 +439,12 @@ discard block |
||
| 435 | 439 | } |
| 436 | 440 | $output .= '</td>'; |
| 437 | 441 | \App\Log::trace("Exiting getTableHeaderNavigation method ..."); |
| 438 | - if ($navigation_array['first'] == '') |
|
| 439 | - return; |
|
| 440 | - else |
|
| 441 | - return $output; |
|
| 442 | -} |
|
| 442 | + if ($navigation_array['first'] == '') { |
|
| 443 | + return; |
|
| 444 | + } else { |
|
| 445 | + return $output; |
|
| 446 | + } |
|
| 447 | + } |
|
| 443 | 448 | /* Function to get the Entity Id of a given Entity Name */ |
| 444 | 449 | |
| 445 | 450 | function getEntityId($module, $entityName) |
@@ -469,23 +474,26 @@ discard block |
||
| 469 | 474 | $entityId = $adb->query_result($result, 0, $entityidfield); |
| 470 | 475 | } |
| 471 | 476 | } |
| 472 | - if (!empty($entityId)) |
|
| 473 | - return $entityId; |
|
| 474 | - else |
|
| 475 | - return 0; |
|
| 476 | -} |
|
| 477 | + if (!empty($entityId)) { |
|
| 478 | + return $entityId; |
|
| 479 | + } else { |
|
| 480 | + return 0; |
|
| 481 | + } |
|
| 482 | + } |
|
| 477 | 483 | |
| 478 | 484 | function decode_html($str) |
| 479 | 485 | { |
| 480 | 486 | $defaultCharset = AppConfig::main('default_charset'); |
| 481 | - if (empty($default_charset)) |
|
| 482 | - $defaultCharset = 'UTF-8'; |
|
| 487 | + if (empty($default_charset)) { |
|
| 488 | + $defaultCharset = 'UTF-8'; |
|
| 489 | + } |
|
| 483 | 490 | // Direct Popup action or Ajax Popup action should be treated the same. |
| 484 | - if (AppRequest::get('action') === 'Popup' || (AppRequest::has('action') && AppRequest::get('file') === 'Popup')) |
|
| 485 | - return html_entity_decode($str); |
|
| 486 | - else |
|
| 487 | - return html_entity_decode($str, ENT_QUOTES, $defaultCharset); |
|
| 488 | -} |
|
| 491 | + if (AppRequest::get('action') === 'Popup' || (AppRequest::has('action') && AppRequest::get('file') === 'Popup')) { |
|
| 492 | + return html_entity_decode($str); |
|
| 493 | + } else { |
|
| 494 | + return html_entity_decode($str, ENT_QUOTES, $defaultCharset); |
|
| 495 | + } |
|
| 496 | + } |
|
| 489 | 497 | |
| 490 | 498 | function popup_decode_html($str) |
| 491 | 499 | { |
@@ -578,22 +586,25 @@ discard block |
||
| 578 | 586 | |
| 579 | 587 | function html_substr($str, $start, $length = NULL) |
| 580 | 588 | { |
| 581 | - if ($length === 0) |
|
| 582 | - return ""; |
|
| 589 | + if ($length === 0) { |
|
| 590 | + return ""; |
|
| 591 | + } |
|
| 583 | 592 | //check if we can simply use the built-in functions |
| 584 | 593 | if (strpos($str, '&') === false) { //No entities. Use built-in functions |
| 585 | - if ($length === NULL) |
|
| 586 | - return substr($str, $start); |
|
| 587 | - else |
|
| 588 | - return substr($str, $start, $length); |
|
| 594 | + if ($length === NULL) { |
|
| 595 | + return substr($str, $start); |
|
| 596 | + } else { |
|
| 597 | + return substr($str, $start, $length); |
|
| 598 | + } |
|
| 589 | 599 | } |
| 590 | 600 | |
| 591 | 601 | // create our array of characters and html entities |
| 592 | 602 | $chars = preg_split('/(&[^;\s]+;)|/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE); |
| 593 | 603 | $html_length = count($chars); |
| 594 | 604 | // check if we can predict the return value and save some processing time |
| 595 | - if (($html_length === 0) || ( $start >= $html_length) || ( isset($length) && ( $length <= -$html_length))) |
|
| 596 | - return ""; |
|
| 605 | + if (($html_length === 0) || ( $start >= $html_length) || ( isset($length) && ( $length <= -$html_length))) { |
|
| 606 | + return ""; |
|
| 607 | + } |
|
| 597 | 608 | |
| 598 | 609 | //calculate start position |
| 599 | 610 | if ($start >= 0) { |
@@ -602,9 +613,10 @@ discard block |
||
| 602 | 613 | $start = max($start, -$html_length); |
| 603 | 614 | $real_start = $chars[$html_length + $start][1]; |
| 604 | 615 | } |
| 605 | - if (!isset($length)) // no $length argument passed, return all remaining characters |
|
| 616 | + if (!isset($length)) { |
|
| 617 | + // no $length argument passed, return all remaining characters |
|
| 606 | 618 | return substr($str, $real_start); |
| 607 | - else if ($length > 0) { // copy $length chars |
|
| 619 | + } else if ($length > 0) { // copy $length chars |
|
| 608 | 620 | if ($start + $length >= $html_length) { // return all remaining characters |
| 609 | 621 | return substr($str, $real_start); |
| 610 | 622 | } else { //return $length characters |
@@ -395,6 +395,9 @@ discard block |
||
| 395 | 395 | /** Report module information based on used. */ |
| 396 | 396 | static $_reportmodule_infoperuser_cache = []; |
| 397 | 397 | |
| 398 | + /** |
|
| 399 | + * @param string $reportid |
|
| 400 | + */ |
|
| 398 | 401 | static function lookupReport_Info($userid, $reportid) |
| 399 | 402 | { |
| 400 | 403 | |
@@ -406,6 +409,9 @@ discard block |
||
| 406 | 409 | return false; |
| 407 | 410 | } |
| 408 | 411 | |
| 412 | + /** |
|
| 413 | + * @param string $reportid |
|
| 414 | + */ |
|
| 409 | 415 | static function updateReport_Info($userid, $reportid, $primarymodule, $secondarymodules, $reporttype, $reportname, $description, $folderid, $owner) |
| 410 | 416 | { |
| 411 | 417 | if (!isset(self::$_reportmodule_infoperuser_cache[$userid])) { |
@@ -428,6 +434,9 @@ discard block |
||
| 428 | 434 | /** Report module sub-ordinate users information. */ |
| 429 | 435 | static $_reportmodule_subordinateuserid_cache = []; |
| 430 | 436 | |
| 437 | + /** |
|
| 438 | + * @param string $reportid |
|
| 439 | + */ |
|
| 431 | 440 | static function lookupReport_SubordinateUsers($reportid) |
| 432 | 441 | { |
| 433 | 442 | if (isset(self::$_reportmodule_subordinateuserid_cache[$reportid])) { |
@@ -436,6 +445,9 @@ discard block |
||
| 436 | 445 | return false; |
| 437 | 446 | } |
| 438 | 447 | |
| 448 | + /** |
|
| 449 | + * @param string $reportid |
|
| 450 | + */ |
|
| 439 | 451 | static function updateReport_SubordinateUsers($reportid, $userids) |
| 440 | 452 | { |
| 441 | 453 | self::$_reportmodule_subordinateuserid_cache[$reportid] = $userids; |
@@ -444,6 +456,9 @@ discard block |
||
| 444 | 456 | /** Report module information based on used. */ |
| 445 | 457 | static $_reportmodule_scheduledinfoperuser_cache = []; |
| 446 | 458 | |
| 459 | + /** |
|
| 460 | + * @param string $reportid |
|
| 461 | + */ |
|
| 447 | 462 | static function lookupReport_ScheduledInfo($userid, $reportid) |
| 448 | 463 | { |
| 449 | 464 | |
@@ -455,6 +470,10 @@ discard block |
||
| 455 | 470 | return false; |
| 456 | 471 | } |
| 457 | 472 | |
| 473 | + /** |
|
| 474 | + * @param string $reportid |
|
| 475 | + * @param boolean $isScheduled |
|
| 476 | + */ |
|
| 458 | 477 | static function updateReport_ScheduledInfo($userid, $reportid, $isScheduled, $scheduledFormat, $scheduledInterval, $scheduledRecipients, $scheduledTime) |
| 459 | 478 | { |
| 460 | 479 | if (!isset(self::$_reportmodule_scheduledinfoperuser_cache[$userid])) { |
@@ -479,6 +498,9 @@ discard block |
||
| 479 | 498 | self::$_userSignature[$userName] = $signature; |
| 480 | 499 | } |
| 481 | 500 | |
| 501 | + /** |
|
| 502 | + * @return string |
|
| 503 | + */ |
|
| 482 | 504 | public static function getUserSignature($userName) |
| 483 | 505 | { |
| 484 | 506 | return self::$_userSignature[$userName]; |
@@ -491,6 +513,9 @@ discard block |
||
| 491 | 513 | self::$_userFullName[$userName] = $fullName; |
| 492 | 514 | } |
| 493 | 515 | |
| 516 | + /** |
|
| 517 | + * @return string |
|
| 518 | + */ |
|
| 494 | 519 | public static function getUserFullName($userName) |
| 495 | 520 | { |
| 496 | 521 | return self::$_userFullName[$userName]; |
@@ -503,6 +528,9 @@ discard block |
||
| 503 | 528 | return self::$_report_field_bylabel[$module][$label]; |
| 504 | 529 | } |
| 505 | 530 | |
| 531 | + /** |
|
| 532 | + * @param string $label |
|
| 533 | + */ |
|
| 506 | 534 | public static function setReportFieldByLabel($module, $label, $fieldInfo) |
| 507 | 535 | { |
| 508 | 536 | self::$_report_field_bylabel[$module][$label] = $fieldInfo; |
@@ -48,6 +48,9 @@ |
||
| 48 | 48 | return $row; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + /** |
|
| 52 | + * @param boolean $t |
|
| 53 | + */ |
|
| 51 | 54 | public static function sanitizeData($newRow, $meta, $t = null) |
| 52 | 55 | { |
| 53 | 56 | |
@@ -24,8 +24,9 @@ discard block |
||
| 24 | 24 | $fieldColumnMapping = $meta->getFieldColumnMapping(); |
| 25 | 25 | $columnFieldMapping = array_flip($fieldColumnMapping); |
| 26 | 26 | foreach ($row as $col => $val) { |
| 27 | - if (array_key_exists($col, $columnFieldMapping)) |
|
| 28 | - $newRow[$columnFieldMapping[$col]] = $val; |
|
| 27 | + if (array_key_exists($col, $columnFieldMapping)) { |
|
| 28 | + $newRow[$columnFieldMapping[$col]] = $val; |
|
| 29 | + } |
|
| 29 | 30 | } |
| 30 | 31 | $newRow = DataTransform::sanitizeData($newRow, $meta, true); |
| 31 | 32 | return $newRow; |
@@ -149,8 +150,9 @@ discard block |
||
| 149 | 150 | $allFields = $meta->getFieldColumnMapping(); |
| 150 | 151 | $newRow = []; |
| 151 | 152 | foreach ($allFields as $field => $col) { |
| 152 | - if (isset($row[$field])) |
|
| 153 | - $newRow[$field] = $row[$field]; |
|
| 153 | + if (isset($row[$field])) { |
|
| 154 | + $newRow[$field] = $row[$field]; |
|
| 155 | + } |
|
| 154 | 156 | } |
| 155 | 157 | if (isset($row[$recordString])) { |
| 156 | 158 | $newRow[$recordString] = $row[$recordString]; |