@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $arrayofcss = array('/takepos/css/pos.css.php', '/takepos/css/colorbox.css'); |
119 | 119 | |
120 | 120 | if (getDolGlobalInt('TAKEPOS_COLOR_THEME') == 1) { |
121 | - $arrayofcss[] = '/takepos/css/colorful.css'; |
|
121 | + $arrayofcss[] = '/takepos/css/colorful.css'; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | limit = maxproduct-1; |
332 | 332 | } |
333 | 333 | // Only show products for sale (tosell=1) |
334 | - $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) { |
|
334 | + $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken(); ?>&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) { |
|
335 | 335 | console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs"); |
336 | 336 | console.log(data); |
337 | 337 | while (ishow < maxproduct) { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | <?php |
389 | 389 | // Add js from hooks |
390 | - $parameters=array(); |
|
390 | + $parameters = array(); |
|
391 | 391 | $parameters['caller'] = 'loadProducts'; |
392 | 392 | $hookmanager->executeHooks('completeJSProductDisplay', $parameters); |
393 | 393 | print $hookmanager->resPrint; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | var offset = <?php echo ($MAXPRODUCT - 2); ?> * pageproducts; |
433 | 433 | // Only show products for sale (tosell=1) |
434 | - $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken();?>&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) { |
|
434 | + $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&token=<?php echo newToken(); ?>&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) { |
|
435 | 435 | console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat); |
436 | 436 | |
437 | 437 | if (typeof (data[0]) == "undefined" && moreorless=="more"){ // Return if no more pages |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | if (idproduct=="") return; |
493 | 493 | // Call page invoice.php to generate the section with product lines |
494 | 494 | $("#poslines").load("invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline+"&qty="+qty, function() { |
495 | - <?php if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();";?> |
|
495 | + <?php if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();"; ?> |
|
496 | 496 | }); |
497 | 497 | } |
498 | 498 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | function ChangeThirdparty(idcustomer) { |
503 | 503 | console.log("ChangeThirdparty"); |
504 | 504 | // Call page list.php to change customer |
505 | - $("#poslines").load("../societe/list.php?action=change&token=<?php echo newToken();?>&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() { |
|
505 | + $("#poslines").load("../societe/list.php?action=change&token=<?php echo newToken(); ?>&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() { |
|
506 | 506 | }); |
507 | 507 | |
508 | 508 | ClearSearch(); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid); |
576 | 576 | |
577 | - $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken();?>&id='+invoiceid, function(data) { |
|
577 | + $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&token=<?php echo newToken(); ?>&id='+invoiceid, function(data) { |
|
578 | 578 | var r; |
579 | 579 | |
580 | 580 | if (parseInt(data['paye']) === 1) { |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | pageproducts = 0; |
645 | 645 | jQuery(".wrapper2 .catwatermark").hide(); |
646 | 646 | var nbsearchresults = 0; |
647 | - $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken();?>&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { |
|
647 | + $.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&token=<?php echo newToken(); ?>&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { |
|
648 | 648 | for (i = 0; i < <?php echo $MAXPRODUCT ?>; i++) { |
649 | 649 | if (typeof (data[i]) == "undefined") { |
650 | 650 | $("#prowatermark" + i).html(""); |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | <?php |
690 | 690 | // Add js from hooks |
691 | - $parameters=array(); |
|
691 | + $parameters = array(); |
|
692 | 692 | $parameters['caller'] = 'search2'; |
693 | 693 | $hookmanager->executeHooks('completeJSProductDisplay', $parameters); |
694 | 694 | print $hookmanager->resPrint; |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | } |
727 | 727 | else { |
728 | 728 | $("#prodiv<?php echo $MAXPRODUCT - 2; ?> span").show(); |
729 | - var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2;?>)); |
|
729 | + var search_start_less = Math.max(0, parseInt(search_start) - parseInt(<?php echo $MAXPRODUCT - 2; ?>)); |
|
730 | 730 | $("#search_start_less").val(search_start_less); |
731 | 731 | } |
732 | 732 | if (nbsearchresults != <?php echo $MAXPRODUCT - 2; ?>) { |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | } |
735 | 735 | else { |
736 | 736 | $("#prodiv<?php echo $MAXPRODUCT - 1; ?> span").show(); |
737 | - var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2;?>); |
|
737 | + var search_start_more = parseInt(search_start) + parseInt(<?php echo $MAXPRODUCT - 2; ?>); |
|
738 | 738 | $("#search_start_more").val(search_start_more); |
739 | 739 | } |
740 | 740 | }); |
@@ -831,14 +831,14 @@ discard block |
||
831 | 831 | |
832 | 832 | function TakeposPrintingOrder(){ |
833 | 833 | console.log("TakeposPrintingOrder"); |
834 | - $("#poslines").load("invoice.php?action=order&token=<?php echo newToken();?>&place="+place, function() { |
|
834 | + $("#poslines").load("invoice.php?action=order&token=<?php echo newToken(); ?>&place="+place, function() { |
|
835 | 835 | //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); |
836 | 836 | }); |
837 | 837 | } |
838 | 838 | |
839 | 839 | function TakeposPrintingTemp(){ |
840 | 840 | console.log("TakeposPrintingTemp"); |
841 | - $("#poslines").load("invoice.php?action=temp&token=<?php echo newToken();?>&place="+place, function() { |
|
841 | + $("#poslines").load("invoice.php?action=temp&token=<?php echo newToken(); ?>&place="+place, function() { |
|
842 | 842 | //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); |
843 | 843 | }); |
844 | 844 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | } |
861 | 861 | |
862 | 862 | function DolibarrOpenDrawer() { |
863 | - console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken();?>&term=<?php print urlencode($_SESSION["takeposterminal"]); ?>"); |
|
863 | + console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=<?php echo newToken(); ?>&term=<?php print urlencode($_SESSION["takeposterminal"]); ?>"); |
|
864 | 864 | $.ajax({ |
865 | 865 | type: "GET", |
866 | 866 | data: { token: '<?php echo currentToken(); ?>' }, |
@@ -1200,15 +1200,15 @@ discard block |
||
1200 | 1200 | |
1201 | 1201 | // TakePOS setup check |
1202 | 1202 | if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) { |
1203 | - $sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement"; |
|
1204 | - $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")"; |
|
1203 | + $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; |
|
1204 | + $sql .= " WHERE entity IN (".getEntity('c_paiement').")"; |
|
1205 | 1205 | $sql .= " AND active = 1"; |
1206 | 1206 | $sql .= " ORDER BY libelle"; |
1207 | 1207 | |
1208 | 1208 | $resql = $db->query($sql); |
1209 | 1209 | $paiementsModes = array(); |
1210 | 1210 | if ($resql) { |
1211 | - while ( $obj = $db->fetch_object($resql) ) { |
|
1211 | + while ($obj = $db->fetch_object($resql)) { |
|
1212 | 1212 | $paycode = $obj->code; |
1213 | 1213 | if ($paycode == 'LIQ') { |
1214 | 1214 | $paycode = 'CASH'; |
@@ -1217,9 +1217,9 @@ discard block |
||
1217 | 1217 | $paycode = 'CHEQUE'; |
1218 | 1218 | } |
1219 | 1219 | |
1220 | - $constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"]; |
|
1220 | + $constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; |
|
1221 | 1221 | //var_dump($constantforkey.' '.$conf->global->$constantforkey); |
1222 | - if ( !empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) { |
|
1222 | + if (!empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) { |
|
1223 | 1223 | array_push($paiementsModes, $obj); |
1224 | 1224 | } |
1225 | 1225 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { |
1256 | 1256 | $menus[$r++] = array('title'=>'<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action'=>'Customer();'); |
1257 | 1257 | } |
1258 | -if ( ! getDolGlobalString('TAKEPOS_HIDE_HISTORY')) { |
|
1258 | +if (!getDolGlobalString('TAKEPOS_HIDE_HISTORY')) { |
|
1259 | 1259 | $menus[$r++] = array('title'=>'<span class="fa fa-history paddingrightonly"></span><div class="trunc">'.$langs->trans("History").'</div>', 'action'=>'History();'); |
1260 | 1260 | } |
1261 | 1261 | $menus[$r++] = array('title'=>'<span class="fa fa-cube paddingrightonly"></span><div class="trunc">'.$langs->trans("FreeZone").'</div>', 'action'=>'FreeZone();'); |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | $parameters = array('menus'=>$menus); |
1326 | 1326 | $reshook = $hookmanager->executeHooks('ActionButtons', $parameters); |
1327 | 1327 | if ($reshook == 0) { //add buttons |
1328 | - if (is_array($hookmanager->resArray) ) { |
|
1328 | + if (is_array($hookmanager->resArray)) { |
|
1329 | 1329 | foreach ($hookmanager->resArray as $resArray) { |
1330 | 1330 | foreach ($resArray as $butmenu) { |
1331 | 1331 | $menus[$r++] = $butmenu; |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | } |
1334 | 1334 | } elseif ($reshook == 1) { |
1335 | 1335 | $r = 0; //replace buttons |
1336 | - if (is_array($hookmanager->resArray) ) { |
|
1336 | + if (is_array($hookmanager->resArray)) { |
|
1337 | 1337 | foreach ($hookmanager->resArray as $resArray) { |
1338 | 1338 | foreach ($resArray as $butmenu) { |
1339 | 1339 | $menus[$r++] = $butmenu; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | public $mode_reglement_id; |
64 | 64 | public $mode_reglement_code; // Code in llx_c_paiement |
65 | 65 | |
66 | - public $totalpaid; // duplicate with sumpayed |
|
67 | - public $totaldeposits; // duplicate with sumdeposit |
|
68 | - public $totalcreditnotes; // duplicate with sumcreditnote |
|
66 | + public $totalpaid; // duplicate with sumpayed |
|
67 | + public $totaldeposits; // duplicate with sumdeposit |
|
68 | + public $totalcreditnotes; // duplicate with sumcreditnote |
|
69 | 69 | |
70 | 70 | public $sumpayed; |
71 | 71 | public $sumpayed_multicurrency; |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $sharedentity = 'facture_fourn'; |
392 | 392 | } |
393 | 393 | |
394 | - $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4; |
|
394 | + $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3.$field4; |
|
395 | 395 | $sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t"; |
396 | 396 | $sql .= " WHERE pf.".$field." = ".((int) $this->id); |
397 | 397 | $sql .= " AND pf.".$field2." = p.rowid"; |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | if ($this->status > self::STATUS_DRAFT && $this->paye == 0) { |
990 | 990 | // Get the default payment mode for BAN payment of the third party |
991 | 991 | require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; |
992 | - $bac = new CompanyBankAccount($this->db); // table societe_rib |
|
992 | + $bac = new CompanyBankAccount($this->db); // table societe_rib |
|
993 | 993 | $result = $bac->fetch(0, $this->socid, 1, 'ban'); |
994 | 994 | if ($result <= 0 || empty($bac->id)) { |
995 | 995 | $this->error = $langs->trans("ThirdpartyHasNoDefaultBanAccount"); |
@@ -1003,12 +1003,12 @@ discard block |
||
1003 | 1003 | $sql .= " FROM ".$this->db->prefix()."prelevement_demande"; |
1004 | 1004 | $sql .= " WHERE rowid = ".((int) $did); |
1005 | 1005 | if ($type != 'bank-transfer' && $type != 'credit-transfer') { |
1006 | - $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1006 | + $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1007 | 1007 | } |
1008 | 1008 | if ($type != 'direct-debit') { |
1009 | - $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1009 | + $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one |
|
1010 | 1010 | } |
1011 | - $sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0) |
|
1011 | + $sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0) |
|
1012 | 1012 | |
1013 | 1013 | dol_syslog(get_class($this)."::makeStripeSepaRequest load requests to process", LOG_DEBUG); |
1014 | 1014 | $resql = $this->db->query($sql); |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | |
1025 | 1025 | if (is_numeric($amount) && $amount != 0) { |
1026 | 1026 | require_once DOL_DOCUMENT_ROOT.'/societe/class/companypaymentmode.class.php'; |
1027 | - $companypaymentmode = new CompanyPaymentMode($this->db); // table societe_rib |
|
1027 | + $companypaymentmode = new CompanyPaymentMode($this->db); // table societe_rib |
|
1028 | 1028 | $companypaymentmode->fetch($bac->id); |
1029 | 1029 | |
1030 | 1030 | $this->stripechargedone = 0; |
@@ -1034,11 +1034,11 @@ discard block |
||
1034 | 1034 | |
1035 | 1035 | $currency = $conf->currency; |
1036 | 1036 | |
1037 | - $errorforinvoice = 0; // We reset the $errorforinvoice at each invoice loop |
|
1037 | + $errorforinvoice = 0; // We reset the $errorforinvoice at each invoice loop |
|
1038 | 1038 | |
1039 | 1039 | $this->fetch_thirdparty(); |
1040 | 1040 | |
1041 | - dol_syslog("--- Process payment request amount=".$amount." thirdparty_id=" . $this->thirdparty->id . ", thirdparty_name=" . $this->thirdparty->name . " ban id=" . $bac->id, LOG_DEBUG); |
|
1041 | + dol_syslog("--- Process payment request amount=".$amount." thirdparty_id=".$this->thirdparty->id.", thirdparty_name=".$this->thirdparty->name." ban id=".$bac->id, LOG_DEBUG); |
|
1042 | 1042 | |
1043 | 1043 | //$alreadypayed = $this->getSommePaiement(); |
1044 | 1044 | //$amount_credit_notes_included = $this->getSumCreditNotesUsed(); |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | $amountstripe = $amountstripe * 100; |
1054 | 1054 | } |
1055 | 1055 | |
1056 | - $fk_bank_account = getDolGlobalInt('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); // Bank account used for SEPA direct debit or credit transfer. Must be the Stripe account in Dolibarr. |
|
1056 | + $fk_bank_account = getDolGlobalInt('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); // Bank account used for SEPA direct debit or credit transfer. Must be the Stripe account in Dolibarr. |
|
1057 | 1057 | if (!($fk_bank_account > 0)) { |
1058 | 1058 | $error++; |
1059 | 1059 | $errorforinvoice++; |
@@ -1109,42 +1109,42 @@ discard block |
||
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | //var_dump($companypaymentmode); |
1112 | - dol_syslog("We will try to pay with companypaymentmodeid=" . $companypaymentmode->id . " stripe_card_ref=" . $companypaymentmode->stripe_card_ref . " mode=" . $companypaymentmode->status, LOG_DEBUG); |
|
1112 | + dol_syslog("We will try to pay with companypaymentmodeid=".$companypaymentmode->id." stripe_card_ref=".$companypaymentmode->stripe_card_ref." mode=".$companypaymentmode->status, LOG_DEBUG); |
|
1113 | 1113 | |
1114 | 1114 | $thirdparty = new Societe($this->db); |
1115 | 1115 | $resultthirdparty = $thirdparty->fetch($this->socid); |
1116 | 1116 | |
1117 | - include_once DOL_DOCUMENT_ROOT . '/stripe/class/stripe.class.php'; // This include the include of htdocs/stripe/config.php |
|
1117 | + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; // This include the include of htdocs/stripe/config.php |
|
1118 | 1118 | // So it inits or erases the $stripearrayofkeysbyenv |
1119 | 1119 | $stripe = new Stripe($this->db); |
1120 | 1120 | |
1121 | 1121 | if (empty($savstripearrayofkeysbyenv)) $savstripearrayofkeysbyenv = $stripearrayofkeysbyenv; |
1122 | - dol_syslog("makeStripeSepaRequest Current Stripe environment is " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key']); |
|
1122 | + dol_syslog("makeStripeSepaRequest Current Stripe environment is ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key']); |
|
1123 | 1123 | dol_syslog("makeStripeSepaRequest Current Saved Stripe environment is ".$savstripearrayofkeysbyenv[$servicestatus]['publishable_key']); |
1124 | 1124 | |
1125 | 1125 | $foundalternativestripeaccount = ''; |
1126 | 1126 | |
1127 | 1127 | // Force stripe to another value (by default this value is empty) |
1128 | - if (! empty($forcestripe)) { |
|
1128 | + if (!empty($forcestripe)) { |
|
1129 | 1129 | dol_syslog("makeStripeSepaRequest A dedicated stripe account was forced, so we switch to it."); |
1130 | 1130 | |
1131 | 1131 | $tmparray = explode('@', $forcestripe); |
1132 | - if (! empty($tmparray[1])) { |
|
1132 | + if (!empty($tmparray[1])) { |
|
1133 | 1133 | $tmparray2 = explode(':', $tmparray[1]); |
1134 | - if (! empty($tmparray2[1])) { |
|
1134 | + if (!empty($tmparray2[1])) { |
|
1135 | 1135 | $stripearrayofkeysbyenv[$servicestatus]["publishable_key"] = $tmparray2[0]; |
1136 | 1136 | $stripearrayofkeysbyenv[$servicestatus]["secret_key"] = $tmparray2[1]; |
1137 | 1137 | |
1138 | 1138 | $stripearrayofkeys = $stripearrayofkeysbyenv[$servicestatus]; |
1139 | 1139 | \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); |
1140 | 1140 | |
1141 | - $foundalternativestripeaccount = $tmparray[0]; // Store the customer id |
|
1141 | + $foundalternativestripeaccount = $tmparray[0]; // Store the customer id |
|
1142 | 1142 | |
1143 | 1143 | dol_syslog("makeStripeSepaRequest We use now customer=".$foundalternativestripeaccount." publishable_key=".$stripearrayofkeys['publishable_key'], LOG_DEBUG); |
1144 | 1144 | } |
1145 | 1145 | } |
1146 | 1146 | |
1147 | - if (! $foundalternativestripeaccount) { |
|
1147 | + if (!$foundalternativestripeaccount) { |
|
1148 | 1148 | $stripearrayofkeysbyenv = $savstripearrayofkeysbyenv; |
1149 | 1149 | |
1150 | 1150 | $stripearrayofkeys = $savstripearrayofkeysbyenv[$servicestatus]; |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | dol_syslog("makeStripeSepaRequest No dedicated Stripe Account requested, so we use global one, so ".$stripearrayofkeys['publishable_key'], LOG_DEBUG); |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - $stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here) |
|
1162 | + $stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here) |
|
1163 | 1163 | |
1164 | 1164 | if ($foundalternativestripeaccount) { |
1165 | 1165 | if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | } |
1170 | 1170 | } else { |
1171 | 1171 | $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0); |
1172 | - if (empty($customer) && ! empty($stripe->error)) { |
|
1172 | + if (empty($customer) && !empty($stripe->error)) { |
|
1173 | 1173 | $this->errors[] = $stripe->error; |
1174 | 1174 | } |
1175 | 1175 | /*if (!empty($customer) && empty($customer->sources)) { |
@@ -1196,15 +1196,15 @@ discard block |
||
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | if ($stripecard) { // Can be src_... (for sepa) or pm_... (new card mode). Note that card_... (old card mode) should not happen here. |
1199 | - $FULLTAG = 'DID='.$did.'-INV=' . $this->id . '-CUS=' . $thirdparty->id; |
|
1200 | - $description = 'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG . ' did='.$did.' ref=' . $this->ref; |
|
1199 | + $FULLTAG = 'DID='.$did.'-INV='.$this->id.'-CUS='.$thirdparty->id; |
|
1200 | + $description = 'Stripe payment from makeStripeSepaRequest: '.$FULLTAG.' did='.$did.' ref='.$this->ref; |
|
1201 | 1201 | |
1202 | 1202 | $stripefailurecode = ''; |
1203 | 1203 | $stripefailuremessage = ''; |
1204 | 1204 | $stripefailuredeclinecode = ''; |
1205 | 1205 | |
1206 | 1206 | // Using new SCA method |
1207 | - dol_syslog("* Create payment on SEPA " . $stripecard->id . ", amounttopay=" . $amounttopay . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG); |
|
1207 | + dol_syslog("* Create payment on SEPA ".$stripecard->id.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG); |
|
1208 | 1208 | |
1209 | 1209 | // Create payment intent and charge payment (confirmnow = true) |
1210 | 1210 | $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1, 1, $did); |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | $charge->failure_message = $stripe->error; |
1226 | 1226 | $charge->failure_declinecode = $stripe->declinecode; |
1227 | 1227 | $stripefailurecode = $stripe->code; |
1228 | - $stripefailuremessage = 'Action required. Contact the support at ';// . $conf->global->SELLYOURSAAS_MAIN_EMAIL; |
|
1228 | + $stripefailuremessage = 'Action required. Contact the support at '; // . $conf->global->SELLYOURSAAS_MAIN_EMAIL; |
|
1229 | 1229 | $stripefailuredeclinecode = $stripe->declinecode; |
1230 | 1230 | } else { |
1231 | 1231 | dol_syslog(var_export($paymentintent, true), LOG_DEBUG); |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | |
1247 | 1247 | // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) |
1248 | 1248 | if (empty($charge) || $charge->status == 'failed') { |
1249 | - dol_syslog('Failed to charge payment mode ' . $stripecard->id . ' stripefailurecode=' . $stripefailurecode . ' stripefailuremessage=' . $stripefailuremessage . ' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING); |
|
1249 | + dol_syslog('Failed to charge payment mode '.$stripecard->id.' stripefailurecode='.$stripefailurecode.' stripefailuremessage='.$stripefailuremessage.' stripefailuredeclinecode='.$stripefailuredeclinecode, LOG_WARNING); |
|
1250 | 1250 | |
1251 | 1251 | // Save a stripe payment was in error |
1252 | 1252 | $this->stripechargeerror++; |
@@ -1259,8 +1259,8 @@ discard block |
||
1259 | 1259 | $errauthenticationmessage = $langs->trans("ErrSCAAuthentication"); |
1260 | 1260 | $errmsg = $errauthenticationmessage; |
1261 | 1261 | } elseif (in_array($stripefailuredeclinecode, ['insufficient_funds', 'generic_decline'])) { |
1262 | - $errmsg .= ': ' . $charge->failure_code; |
|
1263 | - $errmsg .= ($charge->failure_message ? ' - ' : '') . ' ' . $charge->failure_message; |
|
1262 | + $errmsg .= ': '.$charge->failure_code; |
|
1263 | + $errmsg .= ($charge->failure_message ? ' - ' : '').' '.$charge->failure_message; |
|
1264 | 1264 | if (empty($stripefailurecode)) { |
1265 | 1265 | $stripefailurecode = $charge->failure_code; |
1266 | 1266 | } |
@@ -1268,8 +1268,8 @@ discard block |
||
1268 | 1268 | $stripefailuremessage = $charge->failure_message; |
1269 | 1269 | } |
1270 | 1270 | } else { |
1271 | - $errmsg .= ': failure_code=' . $charge->failure_code; |
|
1272 | - $errmsg .= ($charge->failure_message ? ' - ' : '') . ' failure_message=' . $charge->failure_message; |
|
1271 | + $errmsg .= ': failure_code='.$charge->failure_code; |
|
1272 | + $errmsg .= ($charge->failure_message ? ' - ' : '').' failure_message='.$charge->failure_message; |
|
1273 | 1273 | if (empty($stripefailurecode)) { |
1274 | 1274 | $stripefailurecode = $charge->failure_code; |
1275 | 1275 | } |
@@ -1278,24 +1278,24 @@ discard block |
||
1278 | 1278 | } |
1279 | 1279 | } |
1280 | 1280 | } else { |
1281 | - $errmsg .= ': ' . $stripefailurecode . ' - ' . $stripefailuremessage; |
|
1282 | - $errmsg .= ($stripefailuredeclinecode ? ' - ' . $stripefailuredeclinecode : ''); |
|
1281 | + $errmsg .= ': '.$stripefailurecode.' - '.$stripefailuremessage; |
|
1282 | + $errmsg .= ($stripefailuredeclinecode ? ' - '.$stripefailuredeclinecode : ''); |
|
1283 | 1283 | } |
1284 | 1284 | |
1285 | - $description = 'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG; |
|
1286 | - $postactionmessages[] = $errmsg . ' (' . $stripearrayofkeys['publishable_key'] . ')'; |
|
1285 | + $description = 'Stripe payment ERROR from makeStripeSepaRequest: '.$FULLTAG; |
|
1286 | + $postactionmessages[] = $errmsg.' ('.$stripearrayofkeys['publishable_key'].')'; |
|
1287 | 1287 | $this->errors[] = $errmsg; |
1288 | 1288 | } else { |
1289 | 1289 | dol_syslog('Successfuly request '.$type.' '.$stripecard->id); |
1290 | 1290 | |
1291 | - $postactionmessages[] = 'Success to request '.$type.' (' . $charge->id . ' with ' . $stripearrayofkeys['publishable_key'] . ')'; |
|
1291 | + $postactionmessages[] = 'Success to request '.$type.' ('.$charge->id.' with '.$stripearrayofkeys['publishable_key'].')'; |
|
1292 | 1292 | |
1293 | 1293 | // Save a stripe payment was done in realy life so later we will be able to force a commit on recorded payments |
1294 | 1294 | // even if in batch mode (method doTakePaymentStripe), we will always make all action in one transaction with a forced commit. |
1295 | 1295 | $this->stripechargedone++; |
1296 | 1296 | |
1297 | 1297 | // Default description used for label of event. Will be overwrite by another value later. |
1298 | - $description = 'Stripe payment request OK (' . $charge->id . ') from makeStripeSepaRequest: ' . $FULLTAG; |
|
1298 | + $description = 'Stripe payment request OK ('.$charge->id.') from makeStripeSepaRequest: '.$FULLTAG; |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 | $object = $this; |
@@ -1304,8 +1304,8 @@ discard block |
||
1304 | 1304 | if (empty($charge) || $charge->status == 'failed') { |
1305 | 1305 | $actioncode = 'PAYMENT_STRIPE_KO'; |
1306 | 1306 | $extraparams = $stripefailurecode; |
1307 | - $extraparams .= (($extraparams && $stripefailuremessage) ? ' - ' : '') . $stripefailuremessage; |
|
1308 | - $extraparams .= (($extraparams && $stripefailuredeclinecode) ? ' - ' : '') . $stripefailuredeclinecode; |
|
1307 | + $extraparams .= (($extraparams && $stripefailuremessage) ? ' - ' : '').$stripefailuremessage; |
|
1308 | + $extraparams .= (($extraparams && $stripefailuredeclinecode) ? ' - ' : '').$stripefailuredeclinecode; |
|
1309 | 1309 | } else { |
1310 | 1310 | $actioncode = 'PAYMENT_STRIPE_OK'; |
1311 | 1311 | $extraparams = ''; |
@@ -1313,13 +1313,13 @@ discard block |
||
1313 | 1313 | } else { |
1314 | 1314 | $error++; |
1315 | 1315 | $errorforinvoice++; |
1316 | - dol_syslog("No ban payment method found for this stripe customer " . $customer->id, LOG_WARNING); |
|
1317 | - $this->errors[] = 'Failed to get direct debit payment method for stripe customer = ' . $customer->id; |
|
1316 | + dol_syslog("No ban payment method found for this stripe customer ".$customer->id, LOG_WARNING); |
|
1317 | + $this->errors[] = 'Failed to get direct debit payment method for stripe customer = '.$customer->id; |
|
1318 | 1318 | |
1319 | 1319 | $description = 'Failed to find or use the payment mode - no ban defined for the thirdparty account'; |
1320 | 1320 | $stripefailurecode = 'BADPAYMENTMODE'; |
1321 | 1321 | $stripefailuremessage = 'Failed to find or use the payment mode - no ban defined for the thirdparty account'; |
1322 | - $postactionmessages[] = $description . ' (' . $stripearrayofkeys['publishable_key'] . ')'; |
|
1322 | + $postactionmessages[] = $description.' ('.$stripearrayofkeys['publishable_key'].')'; |
|
1323 | 1323 | |
1324 | 1324 | $object = $this; |
1325 | 1325 | |
@@ -1339,11 +1339,11 @@ discard block |
||
1339 | 1339 | } |
1340 | 1340 | } else { // Else of the if ($resultthirdparty > 0 && ! empty($customer)) { |
1341 | 1341 | if ($resultthirdparty <= 0) { |
1342 | - dol_syslog('SellYourSaasUtils Failed to load customer for thirdparty_id = ' . $thirdparty->id, LOG_WARNING); |
|
1343 | - $this->errors[] = 'Failed to load Stripe account for thirdparty_id = ' . $thirdparty->id; |
|
1342 | + dol_syslog('SellYourSaasUtils Failed to load customer for thirdparty_id = '.$thirdparty->id, LOG_WARNING); |
|
1343 | + $this->errors[] = 'Failed to load Stripe account for thirdparty_id = '.$thirdparty->id; |
|
1344 | 1344 | } else { // $customer stripe not found |
1345 | - dol_syslog('SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_WARNING); |
|
1346 | - $this->errors[] = 'Failed to get Stripe account id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key']; |
|
1345 | + dol_syslog('SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = '.$thirdparty->id." in mode ".$servicestatus." in Stripe env ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_WARNING); |
|
1346 | + $this->errors[] = 'Failed to get Stripe account id for thirdparty_id = '.$thirdparty->id." in mode ".$servicestatus." in Stripe env ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; |
|
1347 | 1347 | } |
1348 | 1348 | $error++; |
1349 | 1349 | $errorforinvoice++; |
@@ -1360,24 +1360,24 @@ discard block |
||
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | if ($description) { |
1363 | - dol_syslog("* Record event for credit transfer or direct debit request result - " . $description); |
|
1363 | + dol_syslog("* Record event for credit transfer or direct debit request result - ".$description); |
|
1364 | 1364 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
1365 | 1365 | |
1366 | 1366 | // Insert record of payment (success or error) |
1367 | 1367 | $actioncomm = new ActionComm($this->db); |
1368 | 1368 | |
1369 | - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
1370 | - $actioncomm->code = 'AC_' . $actioncode; |
|
1369 | + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
1370 | + $actioncomm->code = 'AC_'.$actioncode; |
|
1371 | 1371 | $actioncomm->label = $description; |
1372 | 1372 | $actioncomm->note_private = join(",\n", $postactionmessages); |
1373 | 1373 | $actioncomm->fk_project = $this->fk_project; |
1374 | 1374 | $actioncomm->datep = $now; |
1375 | 1375 | $actioncomm->datef = $now; |
1376 | - $actioncomm->percentage = -1; // Not applicable |
|
1376 | + $actioncomm->percentage = -1; // Not applicable |
|
1377 | 1377 | $actioncomm->socid = $thirdparty->id; |
1378 | 1378 | $actioncomm->contactid = 0; |
1379 | - $actioncomm->authorid = $user->id; // User saving action |
|
1380 | - $actioncomm->userownerid = $user->id; // Owner of action |
|
1379 | + $actioncomm->authorid = $user->id; // User saving action |
|
1380 | + $actioncomm->userownerid = $user->id; // Owner of action |
|
1381 | 1381 | // Fields when action is a real email (content is already into note) |
1382 | 1382 | /*$actioncomm->email_msgid = $object->email_msgid; |
1383 | 1383 | $actioncomm->email_from = $object->email_from; |
@@ -1399,14 +1399,14 @@ discard block |
||
1399 | 1399 | } catch (Exception $e) { |
1400 | 1400 | $error++; |
1401 | 1401 | $errorforinvoice++; |
1402 | - dol_syslog('Error ' . $e->getMessage(), LOG_ERR); |
|
1403 | - $this->errors[] = 'Error ' . $e->getMessage(); |
|
1402 | + dol_syslog('Error '.$e->getMessage(), LOG_ERR); |
|
1403 | + $this->errors[] = 'Error '.$e->getMessage(); |
|
1404 | 1404 | } |
1405 | 1405 | } else { // If remain to pay is null |
1406 | 1406 | $error++; |
1407 | 1407 | $errorforinvoice++; |
1408 | - dol_syslog("Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?", LOG_WARNING); |
|
1409 | - $this->errors[] = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?"; |
|
1408 | + dol_syslog("Remain to pay is null for the invoice ".$this->id." ".$this->ref.". Why is the invoice not classified 'Paid' ?", LOG_WARNING); |
|
1409 | + $this->errors[] = "Remain to pay is null for the invoice ".$this->id." ".$this->ref.". Why is the invoice not classified 'Paid' ?"; |
|
1410 | 1410 | } |
1411 | 1411 | } |
1412 | 1412 | |
@@ -1546,10 +1546,10 @@ discard block |
||
1546 | 1546 | $s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring; |
1547 | 1547 | $s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring; |
1548 | 1548 | $s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring; |
1549 | - $s .= ''; // Hash of xml invoice |
|
1550 | - $s .= ''; // ecda signature |
|
1551 | - $s .= ''; // ecda public key |
|
1552 | - $s .= ''; // ecda signature of public key stamp |
|
1549 | + $s .= ''; // Hash of xml invoice |
|
1550 | + $s .= ''; // ecda signature |
|
1551 | + $s .= ''; // ecda public key |
|
1552 | + $s .= ''; // ecda signature of public key stamp |
|
1553 | 1553 | |
1554 | 1554 | $s = base64_encode($s); |
1555 | 1555 | |
@@ -1617,8 +1617,8 @@ discard block |
||
1617 | 1617 | $s .= "S\n"; |
1618 | 1618 | $s .= dol_trunc($bankaccount->proprio, 70, 'right', 'UTF-8', 1)."\n"; |
1619 | 1619 | $addresslinearray = explode("\n", $bankaccount->owner_address); |
1620 | - $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 |
|
1621 | - $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 |
|
1620 | + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 |
|
1621 | + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 |
|
1622 | 1622 | /*$s .= dol_trunc($mysoc->zip, 16, 'right', 'UTF-8', 1)."\n"; |
1623 | 1623 | $s .= dol_trunc($mysoc->town, 35, 'right', 'UTF-8', 1)."\n"; |
1624 | 1624 | $s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1)."\n";*/ |
@@ -1626,8 +1626,8 @@ discard block |
||
1626 | 1626 | $s .= "S\n"; |
1627 | 1627 | $s .= dol_trunc($mysoc->name, 70, 'right', 'UTF-8', 1)."\n"; |
1628 | 1628 | $addresslinearray = explode("\n", $mysoc->address); |
1629 | - $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 |
|
1630 | - $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 |
|
1629 | + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 |
|
1630 | + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 |
|
1631 | 1631 | $s .= dol_trunc($mysoc->zip, 16, 'right', 'UTF-8', 1)."\n"; |
1632 | 1632 | $s .= dol_trunc($mysoc->town, 35, 'right', 'UTF-8', 1)."\n"; |
1633 | 1633 | $s .= dol_trunc($mysoc->country_code, 2, 'right', 'UTF-8', 1)."\n"; |
@@ -1647,14 +1647,14 @@ discard block |
||
1647 | 1647 | $s .= "S\n"; |
1648 | 1648 | $s .= dol_trunc($this->thirdparty->name, 70, 'right', 'UTF-8', 1)."\n"; |
1649 | 1649 | $addresslinearray = explode("\n", $this->thirdparty->address); |
1650 | - $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 |
|
1651 | - $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 |
|
1650 | + $s .= dol_trunc(empty($addresslinearray[1]) ? '' : $addresslinearray[1], 70, 'right', 'UTF-8', 1)."\n"; // address line 1 |
|
1651 | + $s .= dol_trunc(empty($addresslinearray[2]) ? '' : $addresslinearray[2], 70, 'right', 'UTF-8', 1)."\n"; // address line 2 |
|
1652 | 1652 | $s .= dol_trunc($this->thirdparty->zip, 16, 'right', 'UTF-8', 1)."\n"; |
1653 | 1653 | $s .= dol_trunc($this->thirdparty->town, 35, 'right', 'UTF-8', 1)."\n"; |
1654 | 1654 | $s .= dol_trunc($this->thirdparty->country_code, 2, 'right', 'UTF-8', 1)."\n"; |
1655 | 1655 | // ID of payment |
1656 | - $s .= "NON\n"; // NON or QRR |
|
1657 | - $s .= "\n"; // QR Code reference if previous field is QRR |
|
1656 | + $s .= "NON\n"; // NON or QRR |
|
1657 | + $s .= "\n"; // QR Code reference if previous field is QRR |
|
1658 | 1658 | // Free text |
1659 | 1659 | if ($complementaryinfo) { |
1660 | 1660 | $s .= $complementaryinfo."\n"; |
@@ -25,42 +25,42 @@ discard block |
||
25 | 25 | * \remarks To run this script as CLI: phpunit filename.php |
26 | 26 | */ |
27 | 27 | |
28 | -global $conf,$user,$langs,$db; |
|
28 | +global $conf, $user, $langs, $db; |
|
29 | 29 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
30 | 30 | //require_once 'PHPUnit/Autoload.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
32 | 32 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
33 | 33 | require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php'; |
34 | 34 | |
35 | -if (! defined('NOREQUIREUSER')) { |
|
35 | +if (!defined('NOREQUIREUSER')) { |
|
36 | 36 | define('NOREQUIREUSER', '1'); |
37 | 37 | } |
38 | -if (! defined('NOREQUIREDB')) { |
|
38 | +if (!defined('NOREQUIREDB')) { |
|
39 | 39 | define('NOREQUIREDB', '1'); |
40 | 40 | } |
41 | -if (! defined('NOREQUIRESOC')) { |
|
41 | +if (!defined('NOREQUIRESOC')) { |
|
42 | 42 | define('NOREQUIRESOC', '1'); |
43 | 43 | } |
44 | -if (! defined('NOREQUIRETRAN')) { |
|
44 | +if (!defined('NOREQUIRETRAN')) { |
|
45 | 45 | define('NOREQUIRETRAN', '1'); |
46 | 46 | } |
47 | -if (! defined('NOCSRFCHECK')) { |
|
47 | +if (!defined('NOCSRFCHECK')) { |
|
48 | 48 | define('NOCSRFCHECK', '1'); |
49 | 49 | } |
50 | -if (! defined('NOTOKENRENEWAL')) { |
|
50 | +if (!defined('NOTOKENRENEWAL')) { |
|
51 | 51 | define('NOTOKENRENEWAL', '1'); |
52 | 52 | } |
53 | -if (! defined('NOREQUIREMENU')) { |
|
53 | +if (!defined('NOREQUIREMENU')) { |
|
54 | 54 | define('NOREQUIREMENU', '1'); // If there is no menu to show |
55 | 55 | } |
56 | -if (! defined('NOREQUIREHTML')) { |
|
56 | +if (!defined('NOREQUIREHTML')) { |
|
57 | 57 | define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
58 | 58 | } |
59 | -if (! defined('NOREQUIREAJAX')) { |
|
59 | +if (!defined('NOREQUIREAJAX')) { |
|
60 | 60 | define('NOREQUIREAJAX', '1'); |
61 | 61 | } |
62 | -if (! defined("NOLOGIN")) { |
|
63 | - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
62 | +if (!defined("NOLOGIN")) { |
|
63 | + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | print "\n".$langs->trans("CurrentTimeZone").' : '.getServerTimeZoneString(); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | parent::__construct($name); |
96 | 96 | |
97 | 97 | //$this->sharedFixture |
98 | - global $conf,$user,$langs,$db,$mysoc; |
|
99 | - $this->savconf=$conf; |
|
100 | - $this->savuser=$user; |
|
101 | - $this->savlangs=$langs; |
|
102 | - $this->savdb=$db; |
|
103 | - $this->savmysoc=$mysoc; |
|
98 | + global $conf, $user, $langs, $db, $mysoc; |
|
99 | + $this->savconf = $conf; |
|
100 | + $this->savuser = $user; |
|
101 | + $this->savlangs = $langs; |
|
102 | + $this->savdb = $db; |
|
103 | + $this->savmysoc = $mysoc; |
|
104 | 104 | |
105 | 105 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
106 | 106 | //print " - db ".$db->db; |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function setUpBeforeClass(): void |
116 | 116 | { |
117 | - global $conf,$user,$langs,$db; |
|
117 | + global $conf, $user, $langs, $db; |
|
118 | 118 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
119 | 119 | |
120 | - if (! function_exists('mb_substr')) { |
|
120 | + if (!function_exists('mb_substr')) { |
|
121 | 121 | print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(1); |
122 | 122 | } |
123 | 123 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public static function tearDownAfterClass(): void |
141 | 141 | { |
142 | - global $conf,$user,$langs,$db; |
|
142 | + global $conf, $user, $langs, $db; |
|
143 | 143 | //$db->rollback(); |
144 | 144 | |
145 | 145 | print __METHOD__."\n"; |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function setUp(): void |
154 | 154 | { |
155 | - global $conf,$user,$langs,$db,$mysoc; |
|
156 | - $conf=$this->savconf; |
|
157 | - $user=$this->savuser; |
|
158 | - $langs=$this->savlangs; |
|
159 | - $db=$this->savdb; |
|
160 | - $mysoc=$this->savmysoc; |
|
155 | + global $conf, $user, $langs, $db, $mysoc; |
|
156 | + $conf = $this->savconf; |
|
157 | + $user = $this->savuser; |
|
158 | + $langs = $this->savlangs; |
|
159 | + $db = $this->savdb; |
|
160 | + $mysoc = $this->savmysoc; |
|
161 | 161 | |
162 | 162 | print __METHOD__."\n"; |
163 | 163 | } |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | global $conf, $langs; |
184 | 184 | |
185 | 185 | // An attempt for SQL injection |
186 | - $filter='if(now()=sysdate()%2Csleep(6)%2C0)'; |
|
186 | + $filter = 'if(now()=sysdate()%2Csleep(6)%2C0)'; |
|
187 | 187 | $sql = forgeSQLFromUniversalSearchCriteria($filter); |
188 | 188 | $this->assertEquals($sql, 'Filter syntax error - Bad syntax of the search string'); |
189 | 189 | |
190 | 190 | // A real search string |
191 | - $filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))'; |
|
191 | + $filter = '(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))'; |
|
192 | 192 | $sql = forgeSQLFromUniversalSearchCriteria($filter); |
193 | 193 | $this->assertEquals($sql, ' AND ((((statut = 1) or (entity IN (__AAA__))) and (abc < 2) and (abc <> 1.23)))'); |
194 | 194 | |
195 | - $filter="(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)"; |
|
195 | + $filter = "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)"; |
|
196 | 196 | $sql = forgeSQLFromUniversalSearchCriteria($filter); |
197 | 197 | $this->assertEquals($sql, " AND ((t.ref LIKE 'SO-%') or (t.date_creation < '20160101') or (t.date_creation < 0) or (t.nature IS NULL))"); |
198 | 198 | |
@@ -258,23 +258,23 @@ discard block |
||
258 | 258 | { |
259 | 259 | // Nb of line is same than entry text |
260 | 260 | |
261 | - $input="bidon@bademail"; |
|
262 | - $result=isValidEmail($input); |
|
261 | + $input = "bidon@bademail"; |
|
262 | + $result = isValidEmail($input); |
|
263 | 263 | print __METHOD__." result=".$result."\n"; |
264 | 264 | $this->assertFalse($result, 'Check isValidEmail '.$input); |
265 | 265 | |
266 | - $input="[email protected]"; |
|
267 | - $result=isValidEmail($input); |
|
266 | + $input = "[email protected]"; |
|
267 | + $result = isValidEmail($input); |
|
268 | 268 | print __METHOD__." result=".$result."\n"; |
269 | 269 | $this->assertTrue($result, 'Check isValidEmail '.$input); |
270 | 270 | |
271 | - $input="The name of sender <[email protected]>"; |
|
272 | - $result=isValidEmail($input); |
|
271 | + $input = "The name of sender <[email protected]>"; |
|
272 | + $result = isValidEmail($input); |
|
273 | 273 | print __METHOD__." result=".$result."\n"; |
274 | 274 | $this->assertFalse($result, 'Check isValidEmail '.$input); |
275 | 275 | |
276 | - $input="[email protected]"; |
|
277 | - $result=isValidEmail($input); |
|
276 | + $input = "[email protected]"; |
|
277 | + $result = isValidEmail($input); |
|
278 | 278 | print __METHOD__." result=".$result."\n"; |
279 | 279 | $this->assertTrue($result, 'Check isValidEmail '.$input); |
280 | 280 | } |
@@ -288,18 +288,18 @@ discard block |
||
288 | 288 | { |
289 | 289 | // Nb of line is same than entry text |
290 | 290 | |
291 | - $input="yahoo.com"; |
|
292 | - $result=isValidMXRecord($input); |
|
291 | + $input = "yahoo.com"; |
|
292 | + $result = isValidMXRecord($input); |
|
293 | 293 | print __METHOD__." result=".$result."\n"; |
294 | 294 | $this->assertEquals(1, $result); |
295 | 295 | |
296 | - $input="yhaoo.com"; |
|
297 | - $result=isValidMXRecord($input); |
|
296 | + $input = "yhaoo.com"; |
|
297 | + $result = isValidMXRecord($input); |
|
298 | 298 | print __METHOD__." result=".$result."\n"; |
299 | 299 | $this->assertEquals(0, $result); |
300 | 300 | |
301 | - $input="dolibarr.fr"; |
|
302 | - $result=isValidMXRecord($input); |
|
301 | + $input = "dolibarr.fr"; |
|
302 | + $result = isValidMXRecord($input); |
|
303 | 303 | print __METHOD__." result=".$result."\n"; |
304 | 304 | $this->assertEquals(0, $result); |
305 | 305 | } |
@@ -313,57 +313,57 @@ discard block |
||
313 | 313 | { |
314 | 314 | // Nb of line is same than entry text |
315 | 315 | |
316 | - $input="aaaa"; |
|
317 | - $result=dolGetFirstLineOfText($input); |
|
316 | + $input = "aaaa"; |
|
317 | + $result = dolGetFirstLineOfText($input); |
|
318 | 318 | print __METHOD__." result=".$result."\n"; |
319 | 319 | $this->assertEquals("aaaa", $result); |
320 | 320 | |
321 | - $input="aaaa\nbbbbbbbbbbbb\n"; |
|
322 | - $result=dolGetFirstLineOfText($input, 2); |
|
321 | + $input = "aaaa\nbbbbbbbbbbbb\n"; |
|
322 | + $result = dolGetFirstLineOfText($input, 2); |
|
323 | 323 | print __METHOD__." result=".$result."\n"; |
324 | 324 | $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); |
325 | 325 | |
326 | - $input="aaaa<br>bbbbbbbbbbbb<br>"; |
|
327 | - $result=dolGetFirstLineOfText($input, 2); |
|
326 | + $input = "aaaa<br>bbbbbbbbbbbb<br>"; |
|
327 | + $result = dolGetFirstLineOfText($input, 2); |
|
328 | 328 | print __METHOD__." result=".$result."\n"; |
329 | 329 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result); |
330 | 330 | |
331 | 331 | // Nb of line is lower |
332 | 332 | |
333 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
334 | - $result=dolGetFirstLineOfText($input); |
|
333 | + $input = "aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
334 | + $result = dolGetFirstLineOfText($input); |
|
335 | 335 | print __METHOD__." result=".$result."\n"; |
336 | 336 | $this->assertEquals("aaaa...", $result); |
337 | 337 | |
338 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
339 | - $result=dolGetFirstLineOfText($input); |
|
338 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
339 | + $result = dolGetFirstLineOfText($input); |
|
340 | 340 | print __METHOD__." result=".$result."\n"; |
341 | 341 | $this->assertEquals("aaaa...", $result); |
342 | 342 | |
343 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
344 | - $result=dolGetFirstLineOfText($input, 2); |
|
343 | + $input = "aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
344 | + $result = dolGetFirstLineOfText($input, 2); |
|
345 | 345 | print __METHOD__." result=".$result."\n"; |
346 | 346 | $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); |
347 | 347 | |
348 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
349 | - $result=dolGetFirstLineOfText($input, 2); |
|
348 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
349 | + $result = dolGetFirstLineOfText($input, 2); |
|
350 | 350 | print __METHOD__." result=".$result."\n"; |
351 | 351 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result); |
352 | 352 | |
353 | 353 | // Nb of line is higher |
354 | 354 | |
355 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
356 | - $result=dolGetFirstLineOfText($input, 100); |
|
355 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
356 | + $result = dolGetFirstLineOfText($input, 100); |
|
357 | 357 | print __METHOD__." result=".$result."\n"; |
358 | 358 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); |
359 | 359 | |
360 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
361 | - $result=dolGetFirstLineOfText($input, 100); |
|
360 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
361 | + $result = dolGetFirstLineOfText($input, 100); |
|
362 | 362 | print __METHOD__." result=".$result."\n"; |
363 | 363 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); |
364 | 364 | |
365 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
366 | - $result=dolGetFirstLineOfText($input, 100); |
|
365 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
366 | + $result = dolGetFirstLineOfText($input, 100); |
|
367 | 367 | print __METHOD__." result=".$result."\n"; |
368 | 368 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); |
369 | 369 | } |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | var_dump($tmp); |
385 | 385 | */ |
386 | 386 | |
387 | - $result=dol_buildpath('/google/oauth2callback.php', 2); |
|
387 | + $result = dol_buildpath('/google/oauth2callback.php', 2); |
|
388 | 388 | print __METHOD__." result=".$result."\n"; |
389 | 389 | $this->assertStringStartsWith('http', $result); |
390 | 390 | |
391 | - $result=dol_buildpath('/google/oauth2callback.php', 3); |
|
391 | + $result = dol_buildpath('/google/oauth2callback.php', 3); |
|
392 | 392 | print __METHOD__." result=".$result."\n"; |
393 | 393 | $this->assertStringStartsWith('http', $result); |
394 | 394 | } |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | public function testGetBrowserInfo() |
403 | 403 | { |
404 | 404 | // MSIE 5.0 |
405 | - $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; |
|
406 | - $tmp=getBrowserInfo($user_agent); |
|
405 | + $user_agent = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; |
|
406 | + $tmp = getBrowserInfo($user_agent); |
|
407 | 407 | $this->assertEquals('ie', $tmp['browsername']); |
408 | 408 | $this->assertEquals('5.0', $tmp['browserversion']); |
409 | 409 | $this->assertEmpty($tmp['phone']); |
@@ -411,40 +411,40 @@ discard block |
||
411 | 411 | $this->assertEquals('classic', $tmp['layout']); |
412 | 412 | |
413 | 413 | // Firefox 0.9.1 |
414 | - $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; |
|
415 | - $tmp=getBrowserInfo($user_agent); |
|
414 | + $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; |
|
415 | + $tmp = getBrowserInfo($user_agent); |
|
416 | 416 | $this->assertEquals('firefox', $tmp['browsername']); |
417 | 417 | $this->assertEquals('0.9.1', $tmp['browserversion']); |
418 | 418 | $this->assertEmpty($tmp['phone']); |
419 | 419 | $this->assertFalse($tmp['tablet']); |
420 | 420 | $this->assertEquals('classic', $tmp['layout']); |
421 | 421 | |
422 | - $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; |
|
423 | - $tmp=getBrowserInfo($user_agent); |
|
422 | + $user_agent = 'Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; |
|
423 | + $tmp = getBrowserInfo($user_agent); |
|
424 | 424 | $this->assertEquals('opera', $tmp['browsername']); |
425 | 425 | $this->assertEquals('6.03', $tmp['browserversion']); |
426 | 426 | $this->assertEmpty($tmp['phone']); |
427 | 427 | $this->assertFalse($tmp['tablet']); |
428 | 428 | $this->assertEquals('classic', $tmp['layout']); |
429 | 429 | |
430 | - $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; |
|
431 | - $tmp=getBrowserInfo($user_agent); |
|
430 | + $user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; |
|
431 | + $tmp = getBrowserInfo($user_agent); |
|
432 | 432 | $this->assertEquals('chrome', $tmp['browsername']); |
433 | 433 | $this->assertEquals('19.0.1042.0', $tmp['browserversion']); |
434 | 434 | $this->assertEmpty($tmp['phone']); |
435 | 435 | $this->assertFalse($tmp['tablet']); |
436 | 436 | $this->assertEquals('classic', $tmp['layout']); |
437 | 437 | |
438 | - $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; |
|
439 | - $tmp=getBrowserInfo($user_agent); |
|
438 | + $user_agent = 'chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; |
|
439 | + $tmp = getBrowserInfo($user_agent); |
|
440 | 440 | $this->assertEquals('chrome', $tmp['browsername']); |
441 | 441 | $this->assertEquals('17.0.963.56', $tmp['browserversion']); |
442 | 442 | $this->assertEmpty($tmp['phone']); |
443 | 443 | $this->assertFalse($tmp['tablet']); |
444 | 444 | $this->assertEquals('classic', $tmp['layout']); |
445 | 445 | |
446 | - $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; |
|
447 | - $tmp=getBrowserInfo($user_agent); |
|
446 | + $user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; |
|
447 | + $tmp = getBrowserInfo($user_agent); |
|
448 | 448 | $this->assertEquals('safari', $tmp['browsername']); |
449 | 449 | $this->assertEquals('533.21.1', $tmp['browserversion']); |
450 | 450 | $this->assertEmpty($tmp['phone']); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | //Internet Explorer 11 |
455 | 455 | $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; |
456 | - $tmp=getBrowserInfo($user_agent); |
|
456 | + $tmp = getBrowserInfo($user_agent); |
|
457 | 457 | $this->assertEquals('ie', $tmp['browsername']); |
458 | 458 | $this->assertEquals('11.0', $tmp['browserversion']); |
459 | 459 | $this->assertEmpty($tmp['phone']); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | |
463 | 463 | //Internet Explorer 11 bis |
464 | 464 | $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; |
465 | - $tmp=getBrowserInfo($user_agent); |
|
465 | + $tmp = getBrowserInfo($user_agent); |
|
466 | 466 | $this->assertEquals('ie', $tmp['browsername']); |
467 | 467 | $this->assertEquals('11.0', $tmp['browserversion']); |
468 | 468 | $this->assertEmpty($tmp['phone']); |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | |
472 | 472 | //iPad |
473 | 473 | $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; |
474 | - $tmp=getBrowserInfo($user_agent); |
|
474 | + $tmp = getBrowserInfo($user_agent); |
|
475 | 475 | $this->assertEquals('safari', $tmp['browsername']); |
476 | 476 | $this->assertEquals('8536.25', $tmp['browserversion']); |
477 | 477 | $this->assertEquals('ios', $tmp['browseros']); |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | |
481 | 481 | //Lynx |
482 | 482 | $user_agent = 'Lynx/2.8.8dev.3 libwww‑FM/2.14 SSL‑MM/1.4.1'; |
483 | - $tmp=getBrowserInfo($user_agent); |
|
483 | + $tmp = getBrowserInfo($user_agent); |
|
484 | 484 | $this->assertEquals('lynxlinks', $tmp['browsername']); |
485 | 485 | $this->assertEquals('2.8.8', $tmp['browserversion']); |
486 | 486 | $this->assertEquals('unknown', $tmp['browseros']); |
@@ -547,71 +547,71 @@ discard block |
||
547 | 547 | public function testDolTextIsHtml() |
548 | 548 | { |
549 | 549 | // True |
550 | - $input='<html>xxx</html>'; |
|
551 | - $after=dol_textishtml($input); |
|
550 | + $input = '<html>xxx</html>'; |
|
551 | + $after = dol_textishtml($input); |
|
552 | 552 | $this->assertTrue($after, 'Test with html tag'); |
553 | - $input='<body>xxx</body>'; |
|
554 | - $after=dol_textishtml($input); |
|
553 | + $input = '<body>xxx</body>'; |
|
554 | + $after = dol_textishtml($input); |
|
555 | 555 | $this->assertTrue($after, 'Test with body tag'); |
556 | - $input='xxx <b>yyy</b> zzz'; |
|
557 | - $after=dol_textishtml($input); |
|
556 | + $input = 'xxx <b>yyy</b> zzz'; |
|
557 | + $after = dol_textishtml($input); |
|
558 | 558 | $this->assertTrue($after, 'Test with b tag'); |
559 | - $input='xxx <u>yyy</u> zzz'; |
|
560 | - $after=dol_textishtml($input); |
|
559 | + $input = 'xxx <u>yyy</u> zzz'; |
|
560 | + $after = dol_textishtml($input); |
|
561 | 561 | $this->assertTrue($after, 'Test with u tag'); |
562 | - $input='text with <div>some div</div>'; |
|
563 | - $after=dol_textishtml($input); |
|
562 | + $input = 'text with <div>some div</div>'; |
|
563 | + $after = dol_textishtml($input); |
|
564 | 564 | $this->assertTrue($after, 'Test with div tag'); |
565 | - $input='text with HTML entities'; |
|
566 | - $after=dol_textishtml($input); |
|
565 | + $input = 'text with HTML entities'; |
|
566 | + $after = dol_textishtml($input); |
|
567 | 567 | $this->assertTrue($after, 'Test with entities tag'); |
568 | - $input='xxx<br>'; |
|
569 | - $after=dol_textishtml($input); |
|
568 | + $input = 'xxx<br>'; |
|
569 | + $after = dol_textishtml($input); |
|
570 | 570 | $this->assertTrue($after, 'Test with entities br'); |
571 | - $input='xxx<br >'; |
|
572 | - $after=dol_textishtml($input); |
|
571 | + $input = 'xxx<br >'; |
|
572 | + $after = dol_textishtml($input); |
|
573 | 573 | $this->assertTrue($after, 'Test with entities br'); |
574 | - $input='xxx<br style="eee">'; |
|
575 | - $after=dol_textishtml($input); |
|
574 | + $input = 'xxx<br style="eee">'; |
|
575 | + $after = dol_textishtml($input); |
|
576 | 576 | $this->assertTrue($after, 'Test with entities br and attributes'); |
577 | - $input='xxx<br style="eee" >'; |
|
578 | - $after=dol_textishtml($input); |
|
577 | + $input = 'xxx<br style="eee" >'; |
|
578 | + $after = dol_textishtml($input); |
|
579 | 579 | $this->assertTrue($after, 'Test with entities br and attributes bis'); |
580 | - $input='<h2>abc</h2>'; |
|
581 | - $after=dol_textishtml($input); |
|
580 | + $input = '<h2>abc</h2>'; |
|
581 | + $after = dol_textishtml($input); |
|
582 | 582 | $this->assertTrue($after, 'Test with entities h2'); |
583 | - $input='<img id="abc" src="https://xxx.com/aaa/image.png" />'; |
|
584 | - $after=dol_textishtml($input); |
|
583 | + $input = '<img id="abc" src="https://xxx.com/aaa/image.png" />'; |
|
584 | + $after = dol_textishtml($input); |
|
585 | 585 | $this->assertTrue($after, 'Test with img tag'); |
586 | - $input='<a class="azerty" href="https://xxx.com/aaa/image.png" />'; |
|
587 | - $after=dol_textishtml($input); |
|
586 | + $input = '<a class="azerty" href="https://xxx.com/aaa/image.png" />'; |
|
587 | + $after = dol_textishtml($input); |
|
588 | 588 | $this->assertTrue($after, 'Test with a tag'); |
589 | - $input='This is a text with html spaces'; |
|
590 | - $after=dol_textishtml($input); |
|
589 | + $input = 'This is a text with html spaces'; |
|
590 | + $after = dol_textishtml($input); |
|
591 | 591 | $this->assertTrue($after, 'Test with a '); |
592 | - $input='This is a text with accent é'; |
|
593 | - $after=dol_textishtml($input); |
|
592 | + $input = 'This is a text with accent é'; |
|
593 | + $after = dol_textishtml($input); |
|
594 | 594 | $this->assertTrue($after, 'Test with a é'); |
595 | - $input='<i class="abc">xxx</i>'; |
|
596 | - $after=dol_textishtml($input); |
|
595 | + $input = '<i class="abc">xxx</i>'; |
|
596 | + $after = dol_textishtml($input); |
|
597 | 597 | $this->assertTrue($after, 'Test with i tag and class;'); |
598 | 598 | |
599 | 599 | // False |
600 | - $input='xxx < br>'; |
|
601 | - $after=dol_textishtml($input); |
|
600 | + $input = 'xxx < br>'; |
|
601 | + $after = dol_textishtml($input); |
|
602 | 602 | $this->assertFalse($after); |
603 | - $input='xxx <[email protected]>'; // <em> is html, <em... is not |
|
604 | - $after=dol_textishtml($input); |
|
603 | + $input = 'xxx <[email protected]>'; // <em> is html, <em... is not |
|
604 | + $after = dol_textishtml($input); |
|
605 | 605 | $this->assertFalse($after); |
606 | - $input='xxx <brstyle="ee">'; |
|
607 | - $after=dol_textishtml($input); |
|
606 | + $input = 'xxx <brstyle="ee">'; |
|
607 | + $after = dol_textishtml($input); |
|
608 | 608 | $this->assertFalse($after); |
609 | - $input='This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content |
|
610 | - $after=dol_textishtml($input); |
|
609 | + $input = 'This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content |
|
610 | + $after = dol_textishtml($input); |
|
611 | 611 | $this->assertFalse($after); |
612 | 612 | |
613 | - $input="A text\nwith a link https://aaa?param=abc&param2=def"; |
|
614 | - $after=dol_textishtml($input); |
|
613 | + $input = "A text\nwith a link https://aaa?param=abc&param2=def"; |
|
614 | + $after = dol_textishtml($input); |
|
615 | 615 | $this->assertFalse($after); |
616 | 616 | } |
617 | 617 | |
@@ -623,32 +623,32 @@ discard block |
||
623 | 623 | */ |
624 | 624 | public function testDolHtmlCleanLastBr() |
625 | 625 | { |
626 | - $input="A string\n"; |
|
627 | - $after=dol_htmlcleanlastbr($input); |
|
626 | + $input = "A string\n"; |
|
627 | + $after = dol_htmlcleanlastbr($input); |
|
628 | 628 | $this->assertEquals("A string", $after); |
629 | 629 | |
630 | - $input="A string first\nA string second\n"; |
|
631 | - $after=dol_htmlcleanlastbr($input); |
|
630 | + $input = "A string first\nA string second\n"; |
|
631 | + $after = dol_htmlcleanlastbr($input); |
|
632 | 632 | $this->assertEquals("A string first\nA string second", $after); |
633 | 633 | |
634 | - $input="A string\n\n\n"; |
|
635 | - $after=dol_htmlcleanlastbr($input); |
|
634 | + $input = "A string\n\n\n"; |
|
635 | + $after = dol_htmlcleanlastbr($input); |
|
636 | 636 | $this->assertEquals("A string", $after); |
637 | 637 | |
638 | - $input="A string<br>"; |
|
639 | - $after=dol_htmlcleanlastbr($input); |
|
638 | + $input = "A string<br>"; |
|
639 | + $after = dol_htmlcleanlastbr($input); |
|
640 | 640 | $this->assertEquals("A string", $after); |
641 | 641 | |
642 | - $input="A string first<br>\nA string second<br>"; |
|
643 | - $after=dol_htmlcleanlastbr($input); |
|
642 | + $input = "A string first<br>\nA string second<br>"; |
|
643 | + $after = dol_htmlcleanlastbr($input); |
|
644 | 644 | $this->assertEquals("A string first<br>\nA string second", $after); |
645 | 645 | |
646 | - $input="A string\n<br type=\"_moz\" />\n"; |
|
647 | - $after=dol_htmlcleanlastbr($input); |
|
646 | + $input = "A string\n<br type=\"_moz\" />\n"; |
|
647 | + $after = dol_htmlcleanlastbr($input); |
|
648 | 648 | $this->assertEquals("A string", $after); |
649 | 649 | |
650 | - $input="A string\n<br><br />\n\n"; |
|
651 | - $after=dol_htmlcleanlastbr($input); |
|
650 | + $input = "A string\n<br><br />\n\n"; |
|
651 | + $after = dol_htmlcleanlastbr($input); |
|
652 | 652 | $this->assertEquals("A string", $after); |
653 | 653 | |
654 | 654 | return true; |
@@ -661,16 +661,16 @@ discard block |
||
661 | 661 | */ |
662 | 662 | public function testDolConcat() |
663 | 663 | { |
664 | - $text1="A string 1"; $text2="A string 2"; // text 1 and 2 are text, concat need only \n |
|
665 | - $after=dol_concatdesc($text1, $text2); |
|
664 | + $text1 = "A string 1"; $text2 = "A string 2"; // text 1 and 2 are text, concat need only \n |
|
665 | + $after = dol_concatdesc($text1, $text2); |
|
666 | 666 | $this->assertEquals("A string 1\nA string 2", $after); |
667 | 667 | |
668 | - $text1="A<br>string 1"; $text2="A string 2"; // text 1 is html, concat need <br>\n |
|
669 | - $after=dol_concatdesc($text1, $text2); |
|
668 | + $text1 = "A<br>string 1"; $text2 = "A string 2"; // text 1 is html, concat need <br>\n |
|
669 | + $after = dol_concatdesc($text1, $text2); |
|
670 | 670 | $this->assertEquals("A<br>string 1<br>\nA string 2", $after); |
671 | 671 | |
672 | - $text1="A string 1"; $text2="A <b>string</b> 2"; // text 2 is html, concat need <br>\n |
|
673 | - $after=dol_concatdesc($text1, $text2); |
|
672 | + $text1 = "A string 1"; $text2 = "A <b>string</b> 2"; // text 2 is html, concat need <br>\n |
|
673 | + $after = dol_concatdesc($text1, $text2); |
|
674 | 674 | $this->assertEquals("A string 1<br>\nA <b>string</b> 2", $after); |
675 | 675 | |
676 | 676 | return true; |
@@ -684,12 +684,12 @@ discard block |
||
684 | 684 | */ |
685 | 685 | public function testDolStringNoSpecial() |
686 | 686 | { |
687 | - $text="A string with space and special char like ' or ° and more...\n"; |
|
688 | - $after=dol_string_nospecial($text, '_', '', '', 0); |
|
687 | + $text = "A string with space and special char like ' or ° and more...\n"; |
|
688 | + $after = dol_string_nospecial($text, '_', '', '', 0); |
|
689 | 689 | $this->assertEquals("A_string_with_space_and_special_char_like___or___and_more...\n", $after, "testDolStringNoSpecial 1"); |
690 | 690 | |
691 | - $text="A string with space and special char like ' or ° and more...\n"; |
|
692 | - $after=dol_string_nospecial($text, '_', '', '', 1); |
|
691 | + $text = "A string with space and special char like ' or ° and more...\n"; |
|
692 | + $after = dol_string_nospecial($text, '_', '', '', 1); |
|
693 | 693 | $this->assertEquals("A string with space and special char like _ or _ and more...\n", $after, "testDolStringNoSpecial 2"); |
694 | 694 | |
695 | 695 | return true; |
@@ -702,52 +702,52 @@ discard block |
||
702 | 702 | */ |
703 | 703 | public function testDolStringNohtmltag() |
704 | 704 | { |
705 | - $text="A\nstring\n\nand more\n"; |
|
706 | - $after=dol_string_nohtmltag($text, 0); |
|
705 | + $text = "A\nstring\n\nand more\n"; |
|
706 | + $after = dol_string_nohtmltag($text, 0); |
|
707 | 707 | $this->assertEquals("A\nstring\n\nand more", $after, "test1a"); |
708 | 708 | |
709 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
710 | - $after=dol_string_nohtmltag($text, 0); |
|
709 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
710 | + $after = dol_string_nohtmltag($text, 0); |
|
711 | 711 | $this->assertEquals("A string\n\n\n\n\nwith html tag", $after, 'test2a 2 br and 3 \n give 5 \n'); |
712 | 712 | |
713 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
714 | - $after=dol_string_nohtmltag($text, 1); |
|
713 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
714 | + $after = dol_string_nohtmltag($text, 1); |
|
715 | 715 | $this->assertEquals("A string with html tag", $after, 'test2b 2 br and 3 \n give 1 space'); |
716 | 716 | |
717 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
718 | - $after=dol_string_nohtmltag($text, 2); |
|
717 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
718 | + $after = dol_string_nohtmltag($text, 2); |
|
719 | 719 | $this->assertEquals("A string\n\nwith html tag", $after, 'test2c 2 br and 3 \n give 2 \n'); |
720 | 720 | |
721 | - $text="A <b>string<b><br>\r\n<br>\r\n\r\nwith html tag<br>\n"; |
|
722 | - $after=dol_string_nohtmltag($text, 2); |
|
721 | + $text = "A <b>string<b><br>\r\n<br>\r\n\r\nwith html tag<br>\n"; |
|
722 | + $after = dol_string_nohtmltag($text, 2); |
|
723 | 723 | $this->assertEquals("A string\n\nwith html tag", $after, 'test2c 2 br and 3 \r\n give 2 \n'); |
724 | 724 | |
725 | - $text="A string<br>Another string"; |
|
726 | - $after=dol_string_nohtmltag($text, 0); |
|
725 | + $text = "A string<br>Another string"; |
|
726 | + $after = dol_string_nohtmltag($text, 0); |
|
727 | 727 | $this->assertEquals("A string\nAnother string", $after, "test4"); |
728 | 728 | |
729 | - $text="A string<br>Another string"; |
|
730 | - $after=dol_string_nohtmltag($text, 1); |
|
729 | + $text = "A string<br>Another string"; |
|
730 | + $after = dol_string_nohtmltag($text, 1); |
|
731 | 731 | $this->assertEquals("A string Another string", $after, "test5"); |
732 | 732 | |
733 | - $text='<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>'; |
|
734 | - $after=dol_string_nohtmltag($text, 1); |
|
733 | + $text = '<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>'; |
|
734 | + $after = dol_string_nohtmltag($text, 1); |
|
735 | 735 | $this->assertEquals("ABC", $after, "test6"); |
736 | 736 | |
737 | - $text='<a href="/myurl" title="<u>Afficher projet</u>">DEF</a>'; |
|
738 | - $after=dol_string_nohtmltag($text, 1); |
|
737 | + $text = '<a href="/myurl" title="<u>Afficher projet</u>">DEF</a>'; |
|
738 | + $after = dol_string_nohtmltag($text, 1); |
|
739 | 739 | $this->assertEquals("DEF", $after, "test7"); |
740 | 740 | |
741 | - $text='<a href="/myurl" title="<u>A title</u>">HIJ</a>'; |
|
742 | - $after=dol_string_nohtmltag($text, 0); |
|
741 | + $text = '<a href="/myurl" title="<u>A title</u>">HIJ</a>'; |
|
742 | + $after = dol_string_nohtmltag($text, 0); |
|
743 | 743 | $this->assertEquals("HIJ", $after, "test8"); |
744 | 744 | |
745 | - $text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n"; |
|
746 | - $after=dol_string_nohtmltag($text, 0); |
|
745 | + $text = "A <b>string<b>\n\nwith html tag and '<' chars<br>\n"; |
|
746 | + $after = dol_string_nohtmltag($text, 0); |
|
747 | 747 | $this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test9"); |
748 | 748 | |
749 | - $text="A <b>string<b>\n\nwith tag with < chars<br>\n"; |
|
750 | - $after=dol_string_nohtmltag($text, 1); |
|
749 | + $text = "A <b>string<b>\n\nwith tag with < chars<br>\n"; |
|
750 | + $after = dol_string_nohtmltag($text, 1); |
|
751 | 751 | $this->assertEquals("A string with tag with < chars", $after, "test10"); |
752 | 752 | |
753 | 753 | return true; |
@@ -764,38 +764,38 @@ discard block |
||
764 | 764 | { |
765 | 765 | // Text not already HTML |
766 | 766 | |
767 | - $input="A string\nwith a é, &, < and >."; |
|
768 | - $after=dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
767 | + $input = "A string\nwith a é, &, < and >."; |
|
768 | + $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
769 | 769 | $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
770 | 770 | |
771 | - $input="A string\nwith a é, &, < and >."; |
|
772 | - $after=dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
771 | + $input = "A string\nwith a é, &, < and >."; |
|
772 | + $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
773 | 773 | $this->assertEquals("A string<br>with a é, &, < and >.", $after); |
774 | 774 | |
775 | - $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
776 | - $after=dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
775 | + $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
776 | + $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
777 | 777 | $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
778 | 778 | |
779 | - $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
780 | - $after=dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
779 | + $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
780 | + $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
781 | 781 | $this->assertEquals("A string<br>with a é, &, < and >.", $after); |
782 | 782 | |
783 | 783 | // Text already HTML, so &,<,> should not be converted |
784 | 784 | |
785 | - $input="A string<br>\nwith a é, &, < and >."; |
|
786 | - $after=dol_htmlentitiesbr($input); |
|
785 | + $input = "A string<br>\nwith a é, &, < and >."; |
|
786 | + $after = dol_htmlentitiesbr($input); |
|
787 | 787 | $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
788 | 788 | |
789 | - $input="<li>\nA string with a é, &, < and >.</li>\nAnother string"; |
|
790 | - $after=dol_htmlentitiesbr($input); |
|
789 | + $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string"; |
|
790 | + $after = dol_htmlentitiesbr($input); |
|
791 | 791 | $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string", $after); |
792 | 792 | |
793 | - $input="A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned |
|
794 | - $after=dol_htmlentitiesbr($input); |
|
793 | + $input = "A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned |
|
794 | + $after = dol_htmlentitiesbr($input); |
|
795 | 795 | $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
796 | 796 | |
797 | - $input="<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned |
|
798 | - $after=dol_htmlentitiesbr($input); |
|
797 | + $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned |
|
798 | + $after = dol_htmlentitiesbr($input); |
|
799 | 799 | $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string", $after); |
800 | 800 | |
801 | 801 | // TODO Add test with param $removelasteolbr = 0 |
@@ -812,18 +812,18 @@ discard block |
||
812 | 812 | public function testDolNbOfLinesBis() |
813 | 813 | { |
814 | 814 | // This is not a html string so nb of lines depends on \n |
815 | - $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; |
|
816 | - $after=dol_nboflines_bis($input, 0); |
|
815 | + $input = "A string\nwith a é, &, < and > and bold tag.\nThird line"; |
|
816 | + $after = dol_nboflines_bis($input, 0); |
|
817 | 817 | $this->assertEquals($after, 3); |
818 | 818 | |
819 | 819 | // This is a html string so nb of lines depends on <br> |
820 | - $input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; |
|
821 | - $after=dol_nboflines_bis($input, 0); |
|
820 | + $input = "A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; |
|
821 | + $after = dol_nboflines_bis($input, 0); |
|
822 | 822 | $this->assertEquals($after, 1); |
823 | 823 | |
824 | 824 | // This is a html string so nb of lines depends on <br> |
825 | - $input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; |
|
826 | - $after=dol_nboflines_bis($input, 0); |
|
825 | + $input = "A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; |
|
826 | + $after = dol_nboflines_bis($input, 0); |
|
827 | 827 | $this->assertEquals($after, 3); |
828 | 828 | |
829 | 829 | return true; |
@@ -839,8 +839,8 @@ discard block |
||
839 | 839 | { |
840 | 840 | // Text not already HTML |
841 | 841 | |
842 | - $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
843 | - $after=dol_string_unaccent($input); |
|
842 | + $input = "A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
843 | + $after = dol_string_unaccent($input); |
|
844 | 844 | $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after); |
845 | 845 | } |
846 | 846 | |
@@ -853,17 +853,17 @@ discard block |
||
853 | 853 | public function testDolUtf8Check() |
854 | 854 | { |
855 | 855 | // True |
856 | - $result=utf8_check('azerty'); |
|
856 | + $result = utf8_check('azerty'); |
|
857 | 857 | $this->assertTrue($result); |
858 | 858 | |
859 | - $file=dirname(__FILE__).'/textutf8.txt'; |
|
860 | - $filecontent=file_get_contents($file); |
|
861 | - $result=utf8_check($filecontent); |
|
859 | + $file = dirname(__FILE__).'/textutf8.txt'; |
|
860 | + $filecontent = file_get_contents($file); |
|
861 | + $result = utf8_check($filecontent); |
|
862 | 862 | $this->assertTrue($result); |
863 | 863 | |
864 | - $file=dirname(__FILE__).'/textiso.txt'; |
|
865 | - $filecontent=file_get_contents($file); |
|
866 | - $result=utf8_check($filecontent); |
|
864 | + $file = dirname(__FILE__).'/textiso.txt'; |
|
865 | + $filecontent = file_get_contents($file); |
|
866 | + $result = utf8_check($filecontent); |
|
867 | 867 | $this->assertFalse($result); |
868 | 868 | } |
869 | 869 | |
@@ -875,15 +875,15 @@ discard block |
||
875 | 875 | public function testDolAsciiCheck() |
876 | 876 | { |
877 | 877 | // True |
878 | - $result=ascii_check('azerty'); |
|
878 | + $result = ascii_check('azerty'); |
|
879 | 879 | $this->assertTrue($result); |
880 | 880 | |
881 | - $result=ascii_check('é'); |
|
881 | + $result = ascii_check('é'); |
|
882 | 882 | $this->assertFalse($result); |
883 | 883 | |
884 | - $file=dirname(__FILE__).'/textutf8.txt'; |
|
885 | - $filecontent=file_get_contents($file); |
|
886 | - $result=ascii_check($filecontent); |
|
884 | + $file = dirname(__FILE__).'/textutf8.txt'; |
|
885 | + $filecontent = file_get_contents($file); |
|
886 | + $result = ascii_check($filecontent); |
|
887 | 887 | $this->assertFalse($result); |
888 | 888 | } |
889 | 889 | |
@@ -895,49 +895,49 @@ discard block |
||
895 | 895 | public function testDolTrunc() |
896 | 896 | { |
897 | 897 | // Default trunc (will add … if truncation truncation or keep last char if only one char) |
898 | - $input="éeéeéeàa"; |
|
899 | - $after=dol_trunc($input, 3); |
|
898 | + $input = "éeéeéeàa"; |
|
899 | + $after = dol_trunc($input, 3); |
|
900 | 900 | $this->assertEquals("éeé…", $after, 'Test A1'); |
901 | - $after=dol_trunc($input, 2); |
|
901 | + $after = dol_trunc($input, 2); |
|
902 | 902 | $this->assertEquals("ée…", $after, 'Test A2'); |
903 | - $after=dol_trunc($input, 1); |
|
903 | + $after = dol_trunc($input, 1); |
|
904 | 904 | $this->assertEquals("é…", $after, 'Test A3'); |
905 | - $input="éeée"; |
|
906 | - $after=dol_trunc($input, 3); |
|
905 | + $input = "éeée"; |
|
906 | + $after = dol_trunc($input, 3); |
|
907 | 907 | $this->assertEquals("éeée", $after, 'Test B1'); |
908 | - $after=dol_trunc($input, 2); |
|
908 | + $after = dol_trunc($input, 2); |
|
909 | 909 | $this->assertEquals("ée…", $after, 'Test B2'); |
910 | - $after=dol_trunc($input, 1); |
|
910 | + $after = dol_trunc($input, 1); |
|
911 | 911 | $this->assertEquals("é…", $after, 'Test B3'); |
912 | - $input="éeée"; |
|
913 | - $after=dol_trunc($input, 3); |
|
912 | + $input = "éeée"; |
|
913 | + $after = dol_trunc($input, 3); |
|
914 | 914 | $this->assertEquals("éeée", $after, 'Test C1'); |
915 | - $after=dol_trunc($input, 2); |
|
915 | + $after = dol_trunc($input, 2); |
|
916 | 916 | $this->assertEquals("ée…", $after, 'Test C2'); |
917 | - $after=dol_trunc($input, 1); |
|
917 | + $after = dol_trunc($input, 1); |
|
918 | 918 | $this->assertEquals("é…", $after, 'Test C3'); |
919 | - $input="éeé"; |
|
920 | - $after=dol_trunc($input, 3); |
|
919 | + $input = "éeé"; |
|
920 | + $after = dol_trunc($input, 3); |
|
921 | 921 | $this->assertEquals("éeé", $after, 'Test C'); |
922 | - $after=dol_trunc($input, 2); |
|
922 | + $after = dol_trunc($input, 2); |
|
923 | 923 | $this->assertEquals("éeé", $after, 'Test D'); |
924 | - $after=dol_trunc($input, 1); |
|
924 | + $after = dol_trunc($input, 1); |
|
925 | 925 | $this->assertEquals("é…", $after, 'Test E'); |
926 | 926 | // Trunc with no … |
927 | - $input="éeéeéeàa"; |
|
928 | - $after=dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
927 | + $input = "éeéeéeàa"; |
|
928 | + $after = dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
929 | 929 | $this->assertEquals("éeé", $after, 'Test F'); |
930 | - $after=dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
930 | + $after = dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
931 | 931 | $this->assertEquals("ée", $after, 'Test G'); |
932 | - $input="éeé"; |
|
933 | - $after=dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
932 | + $input = "éeé"; |
|
933 | + $after = dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
934 | 934 | $this->assertEquals("éeé", $after, 'Test H'); |
935 | - $after=dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
935 | + $after = dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
936 | 936 | $this->assertEquals("ée", $after, 'Test I'); |
937 | - $after=dol_trunc($input, 1, 'right', 'UTF-8', 1); |
|
937 | + $after = dol_trunc($input, 1, 'right', 'UTF-8', 1); |
|
938 | 938 | $this->assertEquals("é", $after, 'Test J'); |
939 | - $input="éeéeéeàa"; |
|
940 | - $after=dol_trunc($input, 4, 'middle'); |
|
939 | + $input = "éeéeéeàa"; |
|
940 | + $after = dol_trunc($input, 4, 'middle'); |
|
941 | 941 | $this->assertEquals("ée…àa", $after, 'Test K'); |
942 | 942 | |
943 | 943 | return true; |
@@ -952,49 +952,49 @@ discard block |
||
952 | 952 | { |
953 | 953 | global $conf; |
954 | 954 | |
955 | - $savtz=date_default_timezone_get(); |
|
955 | + $savtz = date_default_timezone_get(); |
|
956 | 956 | |
957 | 957 | // Some test for UTC TZ |
958 | 958 | date_default_timezone_set('UTC'); |
959 | 959 | |
960 | 960 | // Check bad hours |
961 | - $result=dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours) |
|
961 | + $result = dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours) |
|
962 | 962 | print __METHOD__." result=".$result."\n"; |
963 | 963 | $this->assertEquals('', $result); |
964 | - $result=dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes) |
|
964 | + $result = dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes) |
|
965 | 965 | print __METHOD__." result=".$result."\n"; |
966 | 966 | $this->assertEquals('', $result); |
967 | - $result=dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds) |
|
967 | + $result = dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds) |
|
968 | 968 | print __METHOD__." result=".$result."\n"; |
969 | 969 | $this->assertEquals('', $result); |
970 | - $result=dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32) |
|
970 | + $result = dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32) |
|
971 | 971 | print __METHOD__." result=".$result."\n"; |
972 | 972 | $this->assertEquals('', $result); |
973 | - $result=dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13) |
|
973 | + $result = dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13) |
|
974 | 974 | print __METHOD__." result=".$result."\n"; |
975 | 975 | $this->assertEquals('', $result); |
976 | 976 | |
977 | - $result=dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261 |
|
977 | + $result = dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261 |
|
978 | 978 | print __METHOD__." result=".$result."\n"; |
979 | 979 | $this->assertEquals(7261, $result); |
980 | 980 | |
981 | - $result=dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
981 | + $result = dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
982 | 982 | print __METHOD__." result=".$result."\n"; |
983 | - $tz=getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter) |
|
984 | - $this->assertEquals(7200-($tz*3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter |
|
983 | + $tz = getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter) |
|
984 | + $this->assertEquals(7200 - ($tz * 3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter |
|
985 | 985 | |
986 | 986 | // Some test for local TZ Europe/Paris |
987 | 987 | date_default_timezone_set('Europe/Paris'); |
988 | 988 | |
989 | 989 | // Check that tz for paris in winter is used |
990 | - $result=dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
990 | + $result = dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
991 | 991 | print __METHOD__." result=".$result."\n"; |
992 | - $this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris |
|
992 | + $this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris |
|
993 | 993 | |
994 | 994 | // Check that daylight saving time is used |
995 | - $result=dol_mktime(2, 0, 0, 6, 1, 2014, 0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT |
|
995 | + $result = dol_mktime(2, 0, 0, 6, 1, 2014, 0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT |
|
996 | 996 | print __METHOD__." result=".$result."\n"; |
997 | - $this->assertEquals(1401588000-3600-3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer |
|
997 | + $this->assertEquals(1401588000 - 3600 - 3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer |
|
998 | 998 | |
999 | 999 | date_default_timezone_set($savtz); |
1000 | 1000 | } |
@@ -1007,14 +1007,14 @@ discard block |
||
1007 | 1007 | */ |
1008 | 1008 | public function testDolEscapeJs() |
1009 | 1009 | { |
1010 | - $input="x&<b>#</b>,\"'"; // " will be converted into ' |
|
1011 | - $result=dol_escape_js($input); |
|
1010 | + $input = "x&<b>#</b>,\"'"; // " will be converted into ' |
|
1011 | + $result = dol_escape_js($input); |
|
1012 | 1012 | $this->assertEquals("x&<b>#</b>,\'\'", $result, "Test mode=0"); |
1013 | 1013 | |
1014 | - $result=dol_escape_js($input, 1); |
|
1014 | + $result = dol_escape_js($input, 1); |
|
1015 | 1015 | $this->assertEquals("x&<b>#</b>,\"\'", $result, "Test mode=1"); |
1016 | 1016 | |
1017 | - $result=dol_escape_js($input, 2); |
|
1017 | + $result = dol_escape_js($input, 2); |
|
1018 | 1018 | $this->assertEquals("x&<b>#</b>,\\\"'", $result, "Test mode=2"); |
1019 | 1019 | } |
1020 | 1020 | |
@@ -1026,12 +1026,12 @@ discard block |
||
1026 | 1026 | */ |
1027 | 1027 | public function testDolEscapeHtmlTag() |
1028 | 1028 | { |
1029 | - $input='x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed |
|
1030 | - $result=dol_escape_htmltag($input); |
|
1029 | + $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed |
|
1030 | + $result = dol_escape_htmltag($input); |
|
1031 | 1031 | $this->assertEquals('x&#,"', $result); |
1032 | 1032 | |
1033 | - $input='x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed |
|
1034 | - $result=dol_escape_htmltag($input, 1); |
|
1033 | + $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed |
|
1034 | + $result = dol_escape_htmltag($input, 1); |
|
1035 | 1035 | $this->assertEquals('x&<b>#</b>,"', $result); |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1043,33 +1043,33 @@ discard block |
||
1043 | 1043 | */ |
1044 | 1044 | public function testDolFormatAddress() |
1045 | 1045 | { |
1046 | - global $conf,$user,$langs,$db; |
|
1047 | - $conf=$this->savconf; |
|
1048 | - $user=$this->savuser; |
|
1049 | - $langs=$this->savlangs; |
|
1050 | - $db=$this->savdb; |
|
1046 | + global $conf, $user, $langs, $db; |
|
1047 | + $conf = $this->savconf; |
|
1048 | + $user = $this->savuser; |
|
1049 | + $langs = $this->savlangs; |
|
1050 | + $db = $this->savdb; |
|
1051 | 1051 | |
1052 | - $object=new Societe($db); |
|
1052 | + $object = new Societe($db); |
|
1053 | 1053 | $object->initAsSpecimen(); |
1054 | 1054 | |
1055 | - $object->country_code='FR'; |
|
1056 | - $address=dol_format_address($object); |
|
1055 | + $object->country_code = 'FR'; |
|
1056 | + $address = dol_format_address($object); |
|
1057 | 1057 | $this->assertEquals("21 jump street\n99999 MyTown", $address); |
1058 | 1058 | |
1059 | - $object->country_code='GB'; |
|
1060 | - $address=dol_format_address($object); |
|
1059 | + $object->country_code = 'GB'; |
|
1060 | + $address = dol_format_address($object); |
|
1061 | 1061 | $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); |
1062 | 1062 | |
1063 | - $object->country_code='US'; |
|
1064 | - $address=dol_format_address($object); |
|
1063 | + $object->country_code = 'US'; |
|
1064 | + $address = dol_format_address($object); |
|
1065 | 1065 | $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); |
1066 | 1066 | |
1067 | - $object->country_code='AU'; |
|
1068 | - $address=dol_format_address($object); |
|
1067 | + $object->country_code = 'AU'; |
|
1068 | + $address = dol_format_address($object); |
|
1069 | 1069 | $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); |
1070 | 1070 | |
1071 | - $object->country_code='JP'; |
|
1072 | - $address=dol_format_address($object); |
|
1071 | + $object->country_code = 'JP'; |
|
1072 | + $address = dol_format_address($object); |
|
1073 | 1073 | $this->assertEquals("21 jump street\nMyState, MyTown 99999", $address); |
1074 | 1074 | } |
1075 | 1075 | |
@@ -1081,29 +1081,29 @@ discard block |
||
1081 | 1081 | */ |
1082 | 1082 | public function testDolPrintPhone() |
1083 | 1083 | { |
1084 | - global $conf,$user,$langs,$db; |
|
1085 | - $conf=$this->savconf; |
|
1086 | - $user=$this->savuser; |
|
1087 | - $langs=$this->savlangs; |
|
1088 | - $db=$this->savdb; |
|
1084 | + global $conf, $user, $langs, $db; |
|
1085 | + $conf = $this->savconf; |
|
1086 | + $user = $this->savuser; |
|
1087 | + $langs = $this->savlangs; |
|
1088 | + $db = $this->savdb; |
|
1089 | 1089 | |
1090 | - $object=new Societe($db); |
|
1090 | + $object = new Societe($db); |
|
1091 | 1091 | $object->initAsSpecimen(); |
1092 | 1092 | |
1093 | - $object->country_code='FR'; |
|
1094 | - $phone=dol_print_phone('1234567890', $object->country_code); |
|
1093 | + $object->country_code = 'FR'; |
|
1094 | + $phone = dol_print_phone('1234567890', $object->country_code); |
|
1095 | 1095 | $this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 1'); |
1096 | 1096 | |
1097 | - $object->country_code='FR'; |
|
1098 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ''); |
|
1097 | + $object->country_code = 'FR'; |
|
1098 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ''); |
|
1099 | 1099 | $this->assertEquals('<span style="margin-right: 10px;">1234567890</span>', $phone, 'Phone for FR 2'); |
1100 | 1100 | |
1101 | - $object->country_code='FR'; |
|
1102 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
1101 | + $object->country_code = 'FR'; |
|
1102 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
1103 | 1103 | $this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 3'); |
1104 | 1104 | |
1105 | - $object->country_code='CA'; |
|
1106 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
1105 | + $object->country_code = 'CA'; |
|
1106 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
1107 | 1107 | $this->assertEquals('<span style="margin-right: 10px;">(123) 456-7890</span>', $phone, 'Phone for CA 1'); |
1108 | 1108 | } |
1109 | 1109 | |
@@ -1115,24 +1115,24 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | public function testImgPicto() |
1117 | 1117 | { |
1118 | - $s=img_picto('title', 'user'); |
|
1118 | + $s = img_picto('title', 'user'); |
|
1119 | 1119 | print __METHOD__." s=".$s."\n"; |
1120 | 1120 | $this->assertStringContainsStringIgnoringCase('fa-user', $s, 'testImgPicto1'); |
1121 | 1121 | |
1122 | - $s=img_picto('title', 'img.png', 'style="float: right"', 0); |
|
1122 | + $s = img_picto('title', 'img.png', 'style="float: right"', 0); |
|
1123 | 1123 | print __METHOD__." s=".$s."\n"; |
1124 | 1124 | $this->assertStringContainsStringIgnoringCase('theme', $s, 'testImgPicto2'); |
1125 | 1125 | $this->assertStringContainsStringIgnoringCase('style="float: right"', $s, 'testImgPicto2'); |
1126 | 1126 | |
1127 | - $s=img_picto('title', '/fullpath/img.png', '', 1); |
|
1127 | + $s = img_picto('title', '/fullpath/img.png', '', 1); |
|
1128 | 1128 | print __METHOD__." s=".$s."\n"; |
1129 | 1129 | $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto3'); |
1130 | 1130 | |
1131 | - $s=img_picto('title', '/fullpath/img.png', '', true); |
|
1131 | + $s = img_picto('title', '/fullpath/img.png', '', true); |
|
1132 | 1132 | print __METHOD__." s=".$s."\n"; |
1133 | 1133 | $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto4'); |
1134 | 1134 | |
1135 | - $s=img_picto('title', 'delete', '', 0, 1); |
|
1135 | + $s = img_picto('title', 'delete', '', 0, 1); |
|
1136 | 1136 | print __METHOD__." s=".$s."\n"; |
1137 | 1137 | $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png', $s, 'testImgPicto5'); |
1138 | 1138 | } |
@@ -1144,10 +1144,10 @@ discard block |
||
1144 | 1144 | */ |
1145 | 1145 | public function testDolNow() |
1146 | 1146 | { |
1147 | - $now=dol_now('gmt'); |
|
1148 | - $nowtzserver=dol_now('tzserver'); |
|
1149 | - print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n"; |
|
1150 | - $this->assertEquals(getServerTimeZoneInt('now')*3600, ($nowtzserver-$now)); |
|
1147 | + $now = dol_now('gmt'); |
|
1148 | + $nowtzserver = dol_now('tzserver'); |
|
1149 | + print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now') * 3600)."\n"; |
|
1150 | + $this->assertEquals(getServerTimeZoneInt('now') * 3600, ($nowtzserver - $now)); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1157,25 +1157,25 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | public function testVerifCond() |
1159 | 1159 | { |
1160 | - $verifcond=verifCond('1==1'); |
|
1160 | + $verifcond = verifCond('1==1'); |
|
1161 | 1161 | $this->assertTrue($verifcond, 'Test a true comparison'); |
1162 | 1162 | |
1163 | - $verifcond=verifCond('1==2'); |
|
1163 | + $verifcond = verifCond('1==2'); |
|
1164 | 1164 | $this->assertFalse($verifcond, 'Test a false comparison'); |
1165 | 1165 | |
1166 | - $verifcond=verifCond('isModEnabled("facture")'); |
|
1166 | + $verifcond = verifCond('isModEnabled("facture")'); |
|
1167 | 1167 | $this->assertTrue($verifcond, 'Test that the conf property of a module reports true when enabled'); |
1168 | 1168 | |
1169 | - $verifcond=verifCond('isModEnabled("moduledummy")'); |
|
1169 | + $verifcond = verifCond('isModEnabled("moduledummy")'); |
|
1170 | 1170 | $this->assertFalse($verifcond, 'Test that the conf property of a module reports false when disabled'); |
1171 | 1171 | |
1172 | - $verifcond=verifCond(0); |
|
1172 | + $verifcond = verifCond(0); |
|
1173 | 1173 | $this->assertFalse($verifcond, 'Test that verifConf(0) return False'); |
1174 | 1174 | |
1175 | - $verifcond=verifCond("0"); |
|
1175 | + $verifcond = verifCond("0"); |
|
1176 | 1176 | $this->assertFalse($verifcond, 'Test that verifConf("0") return False'); |
1177 | 1177 | |
1178 | - $verifcond=verifCond(''); |
|
1178 | + $verifcond = verifCond(''); |
|
1179 | 1179 | $this->assertTrue($verifcond, 'Test that verifConf("") return False (special case)'); |
1180 | 1180 | } |
1181 | 1181 | |
@@ -1186,75 +1186,75 @@ discard block |
||
1186 | 1186 | */ |
1187 | 1187 | public function testGetDefaultTva() |
1188 | 1188 | { |
1189 | - global $conf,$user,$langs,$db; |
|
1190 | - $this->savconf=$conf; |
|
1191 | - $this->savuser=$user; |
|
1192 | - $this->savlangs=$langs; |
|
1193 | - $this->savdb=$db; |
|
1189 | + global $conf, $user, $langs, $db; |
|
1190 | + $this->savconf = $conf; |
|
1191 | + $this->savuser = $user; |
|
1192 | + $this->savlangs = $langs; |
|
1193 | + $this->savdb = $db; |
|
1194 | 1194 | |
1195 | 1195 | // Sellers |
1196 | - $companyfrnovat=new Societe($db); |
|
1197 | - $companyfrnovat->country_code='FR'; |
|
1198 | - $companyfrnovat->tva_assuj=0; |
|
1196 | + $companyfrnovat = new Societe($db); |
|
1197 | + $companyfrnovat->country_code = 'FR'; |
|
1198 | + $companyfrnovat->tva_assuj = 0; |
|
1199 | 1199 | |
1200 | - $companyfr=new Societe($db); |
|
1201 | - $companyfr->country_code='FR'; |
|
1202 | - $companyfr->tva_assuj=1; |
|
1203 | - $companyfr->tva_intra='FR9999'; |
|
1200 | + $companyfr = new Societe($db); |
|
1201 | + $companyfr->country_code = 'FR'; |
|
1202 | + $companyfr->tva_assuj = 1; |
|
1203 | + $companyfr->tva_intra = 'FR9999'; |
|
1204 | 1204 | |
1205 | 1205 | // Buyers |
1206 | - $companymc=new Societe($db); |
|
1207 | - $companymc->country_code='MC'; |
|
1208 | - $companymc->tva_assuj=1; |
|
1209 | - $companyfr->tva_intra='MC9999'; |
|
1206 | + $companymc = new Societe($db); |
|
1207 | + $companymc->country_code = 'MC'; |
|
1208 | + $companymc->tva_assuj = 1; |
|
1209 | + $companyfr->tva_intra = 'MC9999'; |
|
1210 | 1210 | |
1211 | - $companyit=new Societe($db); |
|
1212 | - $companyit->country_code='IT'; |
|
1213 | - $companyit->tva_assuj=1; |
|
1214 | - $companyit->tva_intra='IT99999'; |
|
1211 | + $companyit = new Societe($db); |
|
1212 | + $companyit->country_code = 'IT'; |
|
1213 | + $companyit->tva_assuj = 1; |
|
1214 | + $companyit->tva_intra = 'IT99999'; |
|
1215 | 1215 | |
1216 | - $companyde=new Societe($db); |
|
1217 | - $companyde->country_code='DE'; |
|
1218 | - $companyde->tva_assuj=1; |
|
1219 | - $companyde->tva_intra='DE99999'; |
|
1216 | + $companyde = new Societe($db); |
|
1217 | + $companyde->country_code = 'DE'; |
|
1218 | + $companyde->tva_assuj = 1; |
|
1219 | + $companyde->tva_intra = 'DE99999'; |
|
1220 | 1220 | |
1221 | - $notcompanyde=new Societe($db); |
|
1222 | - $notcompanyde->country_code='DE'; |
|
1223 | - $notcompanyde->tva_assuj=0; |
|
1224 | - $notcompanyde->tva_intra=''; |
|
1225 | - $notcompanyde->typent_code='TE_PRIVATE'; |
|
1221 | + $notcompanyde = new Societe($db); |
|
1222 | + $notcompanyde->country_code = 'DE'; |
|
1223 | + $notcompanyde->tva_assuj = 0; |
|
1224 | + $notcompanyde->tva_intra = ''; |
|
1225 | + $notcompanyde->typent_code = 'TE_PRIVATE'; |
|
1226 | 1226 | |
1227 | - $companyus=new Societe($db); |
|
1228 | - $companyus->country_code='US'; |
|
1229 | - $companyus->tva_assuj=1; |
|
1230 | - $companyus->tva_intra=''; |
|
1227 | + $companyus = new Societe($db); |
|
1228 | + $companyus->country_code = 'US'; |
|
1229 | + $companyus->tva_assuj = 1; |
|
1230 | + $companyus->tva_intra = ''; |
|
1231 | 1231 | |
1232 | 1232 | |
1233 | 1233 | // Test RULE 0 (FR-DE) |
1234 | 1234 | // Not tested |
1235 | 1235 | |
1236 | 1236 | // Test RULE 1 |
1237 | - $vat=get_default_tva($companyfrnovat, $companymc, 0); |
|
1237 | + $vat = get_default_tva($companyfrnovat, $companymc, 0); |
|
1238 | 1238 | $this->assertEquals(0, $vat, 'RULE 1'); |
1239 | 1239 | |
1240 | 1240 | // Test RULE 2 (FR-FR) |
1241 | - $vat=get_default_tva($companyfr, $companyfr, 0); |
|
1241 | + $vat = get_default_tva($companyfr, $companyfr, 0); |
|
1242 | 1242 | $this->assertEquals(20, $vat, 'RULE 2'); |
1243 | 1243 | |
1244 | 1244 | // Test RULE 2 (FR-MC) |
1245 | - $vat=get_default_tva($companyfr, $companymc, 0); |
|
1245 | + $vat = get_default_tva($companyfr, $companymc, 0); |
|
1246 | 1246 | $this->assertEquals(20, $vat, 'RULE 2'); |
1247 | 1247 | |
1248 | 1248 | // Test RULE 3 (FR-DE company) |
1249 | - $vat=get_default_tva($companyfr, $companyit, 0); |
|
1249 | + $vat = get_default_tva($companyfr, $companyit, 0); |
|
1250 | 1250 | $this->assertEquals(0, $vat, 'RULE 3'); |
1251 | 1251 | |
1252 | 1252 | // Test RULE 4 (FR-DE not a company) |
1253 | - $vat=get_default_tva($companyfr, $notcompanyde, 0); |
|
1253 | + $vat = get_default_tva($companyfr, $notcompanyde, 0); |
|
1254 | 1254 | $this->assertEquals(20, $vat, 'RULE 4'); |
1255 | 1255 | |
1256 | 1256 | // Test RULE 5 (FR-US) |
1257 | - $vat=get_default_tva($companyfr, $companyus, 0); |
|
1257 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1258 | 1258 | $this->assertEquals(0, $vat, 'RULE 5'); |
1259 | 1259 | |
1260 | 1260 | |
@@ -1262,23 +1262,23 @@ discard block |
||
1262 | 1262 | $conf->global->SERVICE_ARE_ECOMMERCE_200238EC = 1; |
1263 | 1263 | |
1264 | 1264 | // Test RULE 1 (FR-US) |
1265 | - $vat=get_default_tva($companyfr, $companyus, 0); |
|
1265 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1266 | 1266 | $this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC'); |
1267 | 1267 | |
1268 | 1268 | // Test RULE 2 (FR-FR) |
1269 | - $vat=get_default_tva($companyfr, $companyfr, 0); |
|
1269 | + $vat = get_default_tva($companyfr, $companyfr, 0); |
|
1270 | 1270 | $this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC'); |
1271 | 1271 | |
1272 | 1272 | // Test RULE 3 (FR-DE company) |
1273 | - $vat=get_default_tva($companyfr, $companyde, 0); |
|
1273 | + $vat = get_default_tva($companyfr, $companyde, 0); |
|
1274 | 1274 | $this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC'); |
1275 | 1275 | |
1276 | 1276 | // Test RULE 4 (FR-DE not a company) |
1277 | - $vat=get_default_tva($companyfr, $notcompanyde, 0); |
|
1277 | + $vat = get_default_tva($companyfr, $notcompanyde, 0); |
|
1278 | 1278 | $this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC'); |
1279 | 1279 | |
1280 | 1280 | // Test RULE 5 (FR-US) |
1281 | - $vat=get_default_tva($companyfr, $companyus, 0); |
|
1281 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1282 | 1282 | $this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC'); |
1283 | 1283 | } |
1284 | 1284 | |
@@ -1289,73 +1289,73 @@ discard block |
||
1289 | 1289 | */ |
1290 | 1290 | public function testGetDefaultLocalTax() |
1291 | 1291 | { |
1292 | - global $conf,$user,$langs,$db; |
|
1293 | - $this->savconf=$conf; |
|
1294 | - $this->savuser=$user; |
|
1295 | - $this->savlangs=$langs; |
|
1296 | - $this->savdb=$db; |
|
1297 | - |
|
1298 | - $companyfrnovat=new Societe($db); |
|
1299 | - $companyfrnovat->country_code='FR'; |
|
1300 | - $companyfrnovat->tva_assuj=0; |
|
1301 | - $companyfrnovat->localtax1_assuj=0; |
|
1302 | - $companyfrnovat->localtax2_assuj=0; |
|
1303 | - |
|
1304 | - $companyes=new Societe($db); |
|
1305 | - $companyes->country_code='ES'; |
|
1306 | - $companyes->tva_assuj=1; |
|
1307 | - $companyes->localtax1_assuj=1; |
|
1308 | - $companyes->localtax2_assuj=1; |
|
1309 | - |
|
1310 | - $companymc=new Societe($db); |
|
1311 | - $companymc->country_code='MC'; |
|
1312 | - $companymc->tva_assuj=1; |
|
1313 | - $companymc->localtax1_assuj=0; |
|
1314 | - $companymc->localtax2_assuj=0; |
|
1315 | - |
|
1316 | - $companyit=new Societe($db); |
|
1317 | - $companyit->country_code='IT'; |
|
1318 | - $companyit->tva_assuj=1; |
|
1319 | - $companyit->tva_intra='IT99999'; |
|
1320 | - $companyit->localtax1_assuj=0; |
|
1321 | - $companyit->localtax2_assuj=0; |
|
1322 | - |
|
1323 | - $notcompanyit=new Societe($db); |
|
1324 | - $notcompanyit->country_code='IT'; |
|
1325 | - $notcompanyit->tva_assuj=1; |
|
1326 | - $notcompanyit->tva_intra=''; |
|
1327 | - $notcompanyit->typent_code='TE_PRIVATE'; |
|
1328 | - $notcompanyit->localtax1_assuj=0; |
|
1329 | - $notcompanyit->localtax2_assuj=0; |
|
1330 | - |
|
1331 | - $companyus=new Societe($db); |
|
1332 | - $companyus->country_code='US'; |
|
1333 | - $companyus->tva_assuj=1; |
|
1334 | - $companyus->tva_intra=''; |
|
1335 | - $companyus->localtax1_assuj=0; |
|
1336 | - $companyus->localtax2_assuj=0; |
|
1292 | + global $conf, $user, $langs, $db; |
|
1293 | + $this->savconf = $conf; |
|
1294 | + $this->savuser = $user; |
|
1295 | + $this->savlangs = $langs; |
|
1296 | + $this->savdb = $db; |
|
1297 | + |
|
1298 | + $companyfrnovat = new Societe($db); |
|
1299 | + $companyfrnovat->country_code = 'FR'; |
|
1300 | + $companyfrnovat->tva_assuj = 0; |
|
1301 | + $companyfrnovat->localtax1_assuj = 0; |
|
1302 | + $companyfrnovat->localtax2_assuj = 0; |
|
1303 | + |
|
1304 | + $companyes = new Societe($db); |
|
1305 | + $companyes->country_code = 'ES'; |
|
1306 | + $companyes->tva_assuj = 1; |
|
1307 | + $companyes->localtax1_assuj = 1; |
|
1308 | + $companyes->localtax2_assuj = 1; |
|
1309 | + |
|
1310 | + $companymc = new Societe($db); |
|
1311 | + $companymc->country_code = 'MC'; |
|
1312 | + $companymc->tva_assuj = 1; |
|
1313 | + $companymc->localtax1_assuj = 0; |
|
1314 | + $companymc->localtax2_assuj = 0; |
|
1315 | + |
|
1316 | + $companyit = new Societe($db); |
|
1317 | + $companyit->country_code = 'IT'; |
|
1318 | + $companyit->tva_assuj = 1; |
|
1319 | + $companyit->tva_intra = 'IT99999'; |
|
1320 | + $companyit->localtax1_assuj = 0; |
|
1321 | + $companyit->localtax2_assuj = 0; |
|
1322 | + |
|
1323 | + $notcompanyit = new Societe($db); |
|
1324 | + $notcompanyit->country_code = 'IT'; |
|
1325 | + $notcompanyit->tva_assuj = 1; |
|
1326 | + $notcompanyit->tva_intra = ''; |
|
1327 | + $notcompanyit->typent_code = 'TE_PRIVATE'; |
|
1328 | + $notcompanyit->localtax1_assuj = 0; |
|
1329 | + $notcompanyit->localtax2_assuj = 0; |
|
1330 | + |
|
1331 | + $companyus = new Societe($db); |
|
1332 | + $companyus->country_code = 'US'; |
|
1333 | + $companyus->tva_assuj = 1; |
|
1334 | + $companyus->tva_intra = ''; |
|
1335 | + $companyus->localtax1_assuj = 0; |
|
1336 | + $companyus->localtax2_assuj = 0; |
|
1337 | 1337 | |
1338 | 1338 | // Test RULE FR-MC |
1339 | - $vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0); |
|
1340 | - $vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0); |
|
1339 | + $vat1 = get_default_localtax($companyfrnovat, $companymc, 1, 0); |
|
1340 | + $vat2 = get_default_localtax($companyfrnovat, $companymc, 2, 0); |
|
1341 | 1341 | $this->assertEquals(0, $vat1); |
1342 | 1342 | $this->assertEquals(0, $vat2); |
1343 | 1343 | |
1344 | 1344 | // Test RULE ES-ES |
1345 | - $vat1=get_default_localtax($companyes, $companyes, 1, 0); |
|
1346 | - $vat2=get_default_localtax($companyes, $companyes, 2, 0); |
|
1345 | + $vat1 = get_default_localtax($companyes, $companyes, 1, 0); |
|
1346 | + $vat2 = get_default_localtax($companyes, $companyes, 2, 0); |
|
1347 | 1347 | $this->assertEquals($vat1, 5.2); |
1348 | - $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1348 | + $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1349 | 1349 | |
1350 | 1350 | // Test RULE ES-IT |
1351 | - $vat1=get_default_localtax($companyes, $companyit, 1, 0); |
|
1352 | - $vat2=get_default_localtax($companyes, $companyit, 2, 0); |
|
1351 | + $vat1 = get_default_localtax($companyes, $companyit, 1, 0); |
|
1352 | + $vat2 = get_default_localtax($companyes, $companyit, 2, 0); |
|
1353 | 1353 | $this->assertEquals(0, $vat1); |
1354 | 1354 | $this->assertEquals(0, $vat2); |
1355 | 1355 | |
1356 | 1356 | // Test RULE ES-IT |
1357 | - $vat1=get_default_localtax($companyes, $notcompanyit, 1, 0); |
|
1358 | - $vat2=get_default_localtax($companyes, $notcompanyit, 2, 0); |
|
1357 | + $vat1 = get_default_localtax($companyes, $notcompanyit, 1, 0); |
|
1358 | + $vat2 = get_default_localtax($companyes, $notcompanyit, 2, 0); |
|
1359 | 1359 | $this->assertEquals(0, $vat1); |
1360 | 1360 | $this->assertEquals(0, $vat2); |
1361 | 1361 | |
@@ -1363,8 +1363,8 @@ discard block |
||
1363 | 1363 | // Not tested |
1364 | 1364 | |
1365 | 1365 | // Test RULE ES-US |
1366 | - $vat1=get_default_localtax($companyes, $companyus, 1, 0); |
|
1367 | - $vat2=get_default_localtax($companyes, $companyus, 2, 0); |
|
1366 | + $vat1 = get_default_localtax($companyes, $companyus, 1, 0); |
|
1367 | + $vat2 = get_default_localtax($companyes, $companyus, 2, 0); |
|
1368 | 1368 | $this->assertEquals(0, $vat1); |
1369 | 1369 | $this->assertEquals(0, $vat2); |
1370 | 1370 | } |
@@ -1398,14 +1398,14 @@ discard block |
||
1398 | 1398 | */ |
1399 | 1399 | public function testDolExplodeIntoArray() |
1400 | 1400 | { |
1401 | - $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1402 | - $tmp=dolExplodeIntoArray($stringtoexplode, '.', '='); |
|
1401 | + $stringtoexplode = 'AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1402 | + $tmp = dolExplodeIntoArray($stringtoexplode, '.', '='); |
|
1403 | 1403 | |
1404 | 1404 | print __METHOD__." tmp=".json_encode($tmp)."\n"; |
1405 | 1405 | $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp)); |
1406 | 1406 | |
1407 | - $stringtoexplode="AA=B/B;CC=\n\rEE=FF\nHH=GG;;;\nII=JJ\n"; |
|
1408 | - $tmp=dolExplodeIntoArray($stringtoexplode, "(\r\n|\n|\r|;)", '='); |
|
1407 | + $stringtoexplode = "AA=B/B;CC=\n\rEE=FF\nHH=GG;;;\nII=JJ\n"; |
|
1408 | + $tmp = dolExplodeIntoArray($stringtoexplode, "(\r\n|\n|\r|;)", '='); |
|
1409 | 1409 | |
1410 | 1410 | print __METHOD__." tmp=".json_encode($tmp)."\n"; |
1411 | 1411 | $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG","II":"JJ"}', json_encode($tmp)); |
@@ -1533,48 +1533,48 @@ discard block |
||
1533 | 1533 | |
1534 | 1534 | $conf->global->MAIN_START_WEEK = 0; |
1535 | 1535 | |
1536 | - $tmp=dol_getdate(24*60*60+1, false, 'UTC'); // 2/1/1970 and 1 second = friday |
|
1536 | + $tmp = dol_getdate(24 * 60 * 60 + 1, false, 'UTC'); // 2/1/1970 and 1 second = friday |
|
1537 | 1537 | $this->assertEquals(5, $tmp['wday'], 'Bad value of day in week'); |
1538 | 1538 | |
1539 | 1539 | $conf->global->MAIN_START_WEEK = 1; |
1540 | 1540 | |
1541 | - $tmp=dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday |
|
1541 | + $tmp = dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday |
|
1542 | 1542 | $this->assertEquals(4, $tmp['wday'], 'Bad value of day in week'); |
1543 | 1543 | |
1544 | - $tmp=dol_getdate(24*60*60+1, false, 'UTC'); // 2/1/1970 and 1 second = friday |
|
1544 | + $tmp = dol_getdate(24 * 60 * 60 + 1, false, 'UTC'); // 2/1/1970 and 1 second = friday |
|
1545 | 1545 | $this->assertEquals(5, $tmp['wday'], 'Bad value of day in week'); |
1546 | 1546 | |
1547 | - $tmp=dol_getdate(1, false, "Europe/Paris"); // 1/1/1970 and 1 second = thirday |
|
1547 | + $tmp = dol_getdate(1, false, "Europe/Paris"); // 1/1/1970 and 1 second = thirday |
|
1548 | 1548 | $this->assertEquals(1970, $tmp['year']); |
1549 | 1549 | $this->assertEquals(1, $tmp['mon']); |
1550 | 1550 | $this->assertEquals(1, $tmp['mday']); |
1551 | 1551 | $this->assertEquals(4, $tmp['wday']); |
1552 | 1552 | $this->assertEquals(0, $tmp['yday']); |
1553 | - $this->assertEquals(1, $tmp['hours']); // We are winter, so we are GMT+1 even during summer |
|
1553 | + $this->assertEquals(1, $tmp['hours']); // We are winter, so we are GMT+1 even during summer |
|
1554 | 1554 | $this->assertEquals(0, $tmp['minutes']); |
1555 | 1555 | $this->assertEquals(1, $tmp['seconds']); |
1556 | 1556 | |
1557 | - $tmp=dol_getdate(15638401, false, "Europe/Paris"); // 1/7/1970 and 1 second = wednesday |
|
1557 | + $tmp = dol_getdate(15638401, false, "Europe/Paris"); // 1/7/1970 and 1 second = wednesday |
|
1558 | 1558 | $this->assertEquals(1970, $tmp['year']); |
1559 | 1559 | $this->assertEquals(7, $tmp['mon']); |
1560 | 1560 | $this->assertEquals(1, $tmp['mday']); |
1561 | 1561 | $this->assertEquals(3, $tmp['wday']); |
1562 | 1562 | $this->assertEquals(181, $tmp['yday']); |
1563 | - $this->assertEquals(1, $tmp['hours']); // There is no daylight in 1970, so we are GMT+1 even during summer |
|
1563 | + $this->assertEquals(1, $tmp['hours']); // There is no daylight in 1970, so we are GMT+1 even during summer |
|
1564 | 1564 | $this->assertEquals(0, $tmp['minutes']); |
1565 | 1565 | $this->assertEquals(1, $tmp['seconds']); |
1566 | 1566 | |
1567 | - $tmp=dol_getdate(1593561601, false, "Europe/Paris"); // 1/7/2020 and 1 second = wednesday |
|
1567 | + $tmp = dol_getdate(1593561601, false, "Europe/Paris"); // 1/7/2020 and 1 second = wednesday |
|
1568 | 1568 | $this->assertEquals(2020, $tmp['year']); |
1569 | 1569 | $this->assertEquals(7, $tmp['mon']); |
1570 | 1570 | $this->assertEquals(1, $tmp['mday']); |
1571 | 1571 | $this->assertEquals(3, $tmp['wday']); |
1572 | - $this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february |
|
1573 | - $this->assertEquals(2, $tmp['hours']); // There is a daylight, so we are GMT+2 |
|
1572 | + $this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february |
|
1573 | + $this->assertEquals(2, $tmp['hours']); // There is a daylight, so we are GMT+2 |
|
1574 | 1574 | $this->assertEquals(0, $tmp['minutes']); |
1575 | 1575 | $this->assertEquals(1, $tmp['seconds']); |
1576 | 1576 | |
1577 | - $tmp=dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday |
|
1577 | + $tmp = dol_getdate(1, false, 'UTC'); // 1/1/1970 and 1 second = thirday |
|
1578 | 1578 | $this->assertEquals(1970, $tmp['year']); |
1579 | 1579 | $this->assertEquals(1, $tmp['mon']); |
1580 | 1580 | $this->assertEquals(1, $tmp['mday']); |
@@ -1585,7 +1585,7 @@ discard block |
||
1585 | 1585 | $this->assertEquals(0, $tmp['minutes']); |
1586 | 1586 | $this->assertEquals(1, $tmp['seconds']); |
1587 | 1587 | |
1588 | - $tmp=dol_getdate(15638401, false, 'UTC'); // 1/7/1970 and 1 second = wednesday |
|
1588 | + $tmp = dol_getdate(15638401, false, 'UTC'); // 1/7/1970 and 1 second = wednesday |
|
1589 | 1589 | $this->assertEquals(1970, $tmp['year']); |
1590 | 1590 | $this->assertEquals(7, $tmp['mon']); |
1591 | 1591 | $this->assertEquals(1, $tmp['mday']); |
@@ -1596,12 +1596,12 @@ discard block |
||
1596 | 1596 | $this->assertEquals(0, $tmp['minutes']); |
1597 | 1597 | $this->assertEquals(1, $tmp['seconds']); |
1598 | 1598 | |
1599 | - $tmp=dol_getdate(1593561601, false, 'UTC'); // 1/7/2020 and 1 second = wednesday |
|
1599 | + $tmp = dol_getdate(1593561601, false, 'UTC'); // 1/7/2020 and 1 second = wednesday |
|
1600 | 1600 | $this->assertEquals(2020, $tmp['year']); |
1601 | 1601 | $this->assertEquals(7, $tmp['mon']); |
1602 | 1602 | $this->assertEquals(1, $tmp['mday']); |
1603 | 1603 | $this->assertEquals(3, $tmp['wday']); |
1604 | - $this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february |
|
1604 | + $this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february |
|
1605 | 1605 | // We must disable this because on CI, timezone is may be UTC or something else |
1606 | 1606 | //$this->assertEquals(2, $tmp['hours']); // There is a daylight, so we are GMT+2 |
1607 | 1607 | $this->assertEquals(0, $tmp['minutes']); |
@@ -1658,11 +1658,11 @@ discard block |
||
1658 | 1658 | { |
1659 | 1659 | global $conf, $langs; |
1660 | 1660 | |
1661 | - $chaine='This is an ISO string'; |
|
1661 | + $chaine = 'This is an ISO string'; |
|
1662 | 1662 | $result = dol_string_is_good_iso($chaine); |
1663 | 1663 | $this->assertEquals($result, 1); |
1664 | 1664 | |
1665 | - $chaine='This is a not ISO string '.chr(0); |
|
1665 | + $chaine = 'This is a not ISO string '.chr(0); |
|
1666 | 1666 | $result = dol_string_is_good_iso($chaine); |
1667 | 1667 | $this->assertEquals($result, 0); |
1668 | 1668 | |
@@ -1679,18 +1679,18 @@ discard block |
||
1679 | 1679 | { |
1680 | 1680 | global $conf, $langs; |
1681 | 1681 | |
1682 | - $_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4'; |
|
1683 | - $_SERVER['HTTP_CLIENT_IP']='5.6.7.8'; |
|
1682 | + $_SERVER['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'; |
|
1683 | + $_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8'; |
|
1684 | 1684 | $result = getUserRemoteIP(); |
1685 | 1685 | $this->assertEquals($result, '1.2.3.4'); |
1686 | 1686 | |
1687 | - $_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4<corrupted>'; |
|
1688 | - $_SERVER['HTTP_CLIENT_IP']='5.6.7.8'; |
|
1687 | + $_SERVER['HTTP_X_FORWARDED_FOR'] = '1.2.3.4<corrupted>'; |
|
1688 | + $_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8'; |
|
1689 | 1689 | $result = getUserRemoteIP(); |
1690 | 1690 | $this->assertEquals($result, '5.6.7.8'); |
1691 | 1691 | |
1692 | - $_SERVER['HTTP_X_FORWARDED_FOR']='[1:2:3:4]'; |
|
1693 | - $_SERVER['HTTP_CLIENT_IP']='5.6.7.8'; |
|
1692 | + $_SERVER['HTTP_X_FORWARDED_FOR'] = '[1:2:3:4]'; |
|
1693 | + $_SERVER['HTTP_CLIENT_IP'] = '5.6.7.8'; |
|
1694 | 1694 | $result = getUserRemoteIP(); |
1695 | 1695 | $this->assertEquals($result, '[1:2:3:4]'); |
1696 | 1696 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user->fetch(1); |
37 | 37 | $user->getrights(); |
38 | 38 | } |
39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
40 | 40 | |
41 | 41 | $langs->load("main"); |
42 | 42 | |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | parent::__construct($name); |
68 | 68 | |
69 | 69 | //$this->sharedFixture |
70 | - global $conf,$user,$langs,$db; |
|
71 | - $this->savconf=$conf; |
|
72 | - $this->savuser=$user; |
|
73 | - $this->savlangs=$langs; |
|
74 | - $this->savdb=$db; |
|
70 | + global $conf, $user, $langs, $db; |
|
71 | + $this->savconf = $conf; |
|
72 | + $this->savuser = $user; |
|
73 | + $this->savlangs = $langs; |
|
74 | + $this->savdb = $db; |
|
75 | 75 | |
76 | 76 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
77 | 77 | //print " - db ".$db->db; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function setUpBeforeClass(): void |
87 | 87 | { |
88 | - global $conf,$user,$langs,$db; |
|
88 | + global $conf, $user, $langs, $db; |
|
89 | 89 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
90 | 90 | |
91 | 91 | print __METHOD__."\n"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public static function tearDownAfterClass(): void |
100 | 100 | { |
101 | - global $conf,$user,$langs,$db; |
|
101 | + global $conf, $user, $langs, $db; |
|
102 | 102 | $db->rollback(); |
103 | 103 | |
104 | 104 | print __METHOD__."\n"; |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function setUp(): void |
113 | 113 | { |
114 | - global $conf,$user,$langs,$db; |
|
115 | - $conf=$this->savconf; |
|
116 | - $user=$this->savuser; |
|
117 | - $langs=$this->savlangs; |
|
118 | - $db=$this->savdb; |
|
114 | + global $conf, $user, $langs, $db; |
|
115 | + $conf = $this->savconf; |
|
116 | + $user = $this->savuser; |
|
117 | + $langs = $this->savlangs; |
|
118 | + $db = $this->savdb; |
|
119 | 119 | |
120 | 120 | print __METHOD__."\n"; |
121 | 121 | } |
@@ -137,16 +137,16 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function testBankAccountCreate() |
139 | 139 | { |
140 | - global $conf,$user,$langs,$db; |
|
141 | - $conf=$this->savconf; |
|
142 | - $user=$this->savuser; |
|
143 | - $langs=$this->savlangs; |
|
144 | - $db=$this->savdb; |
|
140 | + global $conf, $user, $langs, $db; |
|
141 | + $conf = $this->savconf; |
|
142 | + $user = $this->savuser; |
|
143 | + $langs = $this->savlangs; |
|
144 | + $db = $this->savdb; |
|
145 | 145 | |
146 | 146 | $localobject = new Account($db); |
147 | 147 | $localobject->initAsSpecimen(); |
148 | 148 | $localobject->date_solde = dol_now(); |
149 | - $result=$localobject->create($user); |
|
149 | + $result = $localobject->create($user); |
|
150 | 150 | |
151 | 151 | print __METHOD__." result=".$result."\n"; |
152 | 152 | $this->assertLessThan($result, 0); |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function testBankAccountFetch($id) |
167 | 167 | { |
168 | - global $conf,$user,$langs,$db; |
|
169 | - $conf=$this->savconf; |
|
170 | - $user=$this->savuser; |
|
171 | - $langs=$this->savlangs; |
|
172 | - $db=$this->savdb; |
|
168 | + global $conf, $user, $langs, $db; |
|
169 | + $conf = $this->savconf; |
|
170 | + $user = $this->savuser; |
|
171 | + $langs = $this->savlangs; |
|
172 | + $db = $this->savdb; |
|
173 | 173 | |
174 | - $localobject=new Account($db); |
|
175 | - $result=$localobject->fetch($id); |
|
174 | + $localobject = new Account($db); |
|
175 | + $result = $localobject->fetch($id); |
|
176 | 176 | |
177 | 177 | print __METHOD__." id=".$id." result=".$result."\n"; |
178 | 178 | $this->assertLessThan($result, 0); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function testBankAccountOther($localobject) |
193 | 193 | { |
194 | - global $conf,$user,$langs,$db; |
|
195 | - $conf=$this->savconf; |
|
196 | - $user=$this->savuser; |
|
197 | - $langs=$this->savlangs; |
|
198 | - $db=$this->savdb; |
|
194 | + global $conf, $user, $langs, $db; |
|
195 | + $conf = $this->savconf; |
|
196 | + $user = $this->savuser; |
|
197 | + $langs = $this->savlangs; |
|
198 | + $db = $this->savdb; |
|
199 | 199 | |
200 | 200 | /*$result=$localobject->setstatus(0); |
201 | 201 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $this->assertTrue($result); |
215 | 215 | |
216 | 216 | // Test checkIbanForAccount for CI account |
217 | - $localobject2=new Account($db); |
|
217 | + $localobject2 = new Account($db); |
|
218 | 218 | $localobject2->country = 'CI'; |
219 | 219 | $localobject2->iban = 'CI77A12312341234123412341234'; |
220 | 220 | $result = checkIbanForAccount($localobject2); |
@@ -235,15 +235,15 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function testBankAccountDelete($id) |
237 | 237 | { |
238 | - global $conf,$user,$langs,$db; |
|
239 | - $conf=$this->savconf; |
|
240 | - $user=$this->savuser; |
|
241 | - $langs=$this->savlangs; |
|
242 | - $db=$this->savdb; |
|
243 | - |
|
244 | - $localobject=new Account($db); |
|
245 | - $result=$localobject->fetch($id); |
|
246 | - $result=$localobject->delete($user); |
|
238 | + global $conf, $user, $langs, $db; |
|
239 | + $conf = $this->savconf; |
|
240 | + $user = $this->savuser; |
|
241 | + $langs = $this->savlangs; |
|
242 | + $db = $this->savdb; |
|
243 | + |
|
244 | + $localobject = new Account($db); |
|
245 | + $result = $localobject->fetch($id); |
|
246 | + $result = $localobject->delete($user); |
|
247 | 247 | |
248 | 248 | print __METHOD__." id=".$id." result=".$result."\n"; |
249 | 249 | $this->assertLessThan($result, 0); |
@@ -24,32 +24,32 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | |
31 | -if (! defined('NOREQUIRESOC')) { |
|
31 | +if (!defined('NOREQUIRESOC')) { |
|
32 | 32 | define('NOREQUIRESOC', '1'); |
33 | 33 | } |
34 | -if (! defined('NOCSRFCHECK')) { |
|
34 | +if (!defined('NOCSRFCHECK')) { |
|
35 | 35 | define('NOCSRFCHECK', '1'); |
36 | 36 | } |
37 | -if (! defined('NOTOKENRENEWAL')) { |
|
37 | +if (!defined('NOTOKENRENEWAL')) { |
|
38 | 38 | define('NOTOKENRENEWAL', '1'); |
39 | 39 | } |
40 | -if (! defined('NOREQUIREMENU')) { |
|
40 | +if (!defined('NOREQUIREMENU')) { |
|
41 | 41 | define('NOREQUIREMENU', '1'); // If there is no menu to show |
42 | 42 | } |
43 | -if (! defined('NOREQUIREHTML')) { |
|
43 | +if (!defined('NOREQUIREHTML')) { |
|
44 | 44 | define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
45 | 45 | } |
46 | -if (! defined('NOREQUIREAJAX')) { |
|
46 | +if (!defined('NOREQUIREAJAX')) { |
|
47 | 47 | define('NOREQUIREAJAX', '1'); |
48 | 48 | } |
49 | -if (! defined("NOLOGIN")) { |
|
50 | - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
49 | +if (!defined("NOLOGIN")) { |
|
50 | + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
51 | 51 | } |
52 | -if (! defined("NOSESSION")) { |
|
52 | +if (!defined("NOSESSION")) { |
|
53 | 53 | define("NOSESSION", '1'); |
54 | 54 | } |
55 | 55 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $user->fetch(1); |
64 | 64 | $user->getrights(); |
65 | 65 | } |
66 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
66 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
67 | 67 | |
68 | 68 | |
69 | 69 | /** |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | parent::__construct($name); |
93 | 93 | |
94 | 94 | //$this->sharedFixture |
95 | - global $conf,$user,$langs,$db; |
|
96 | - $this->savconf=$conf; |
|
97 | - $this->savuser=$user; |
|
98 | - $this->savlangs=$langs; |
|
99 | - $this->savdb=$db; |
|
95 | + global $conf, $user, $langs, $db; |
|
96 | + $this->savconf = $conf; |
|
97 | + $this->savuser = $user; |
|
98 | + $this->savlangs = $langs; |
|
99 | + $this->savdb = $db; |
|
100 | 100 | |
101 | 101 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
102 | 102 | //print " - db ".$db->db; |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public static function setUpBeforeClass(): void |
112 | 112 | { |
113 | - global $conf,$user,$langs,$db; |
|
114 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
113 | + global $conf, $user, $langs, $db; |
|
114 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
115 | 115 | |
116 | 116 | print __METHOD__."\n"; |
117 | 117 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public static function tearDownAfterClass(): void |
125 | 125 | { |
126 | - global $conf,$user,$langs,$db; |
|
126 | + global $conf, $user, $langs, $db; |
|
127 | 127 | $db->rollback(); |
128 | 128 | |
129 | 129 | // Restore value to a neutral value (it was set to a test value by some tests) |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function setUp(): void |
141 | 141 | { |
142 | - global $conf,$user,$langs,$db; |
|
143 | - $conf=$this->savconf; |
|
144 | - $user=$this->savuser; |
|
145 | - $langs=$this->savlangs; |
|
146 | - $db=$this->savdb; |
|
142 | + global $conf, $user, $langs, $db; |
|
143 | + $conf = $this->savconf; |
|
144 | + $user = $this->savuser; |
|
145 | + $langs = $this->savlangs; |
|
146 | + $db = $this->savdb; |
|
147 | 147 | |
148 | 148 | print __METHOD__."\n"; |
149 | 149 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function testSetLang() |
167 | 167 | { |
168 | 168 | global $conf; |
169 | - $conf=$this->savconf; |
|
169 | + $conf = $this->savconf; |
|
170 | 170 | |
171 | 171 | $tmplangs = new Translate('', $conf); |
172 | 172 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | // More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet |
188 | 188 | |
189 | 189 | // Should be OK |
190 | - $expectedresult=0; |
|
190 | + $expectedresult = 0; |
|
191 | 191 | |
192 | 192 | /* |
193 | 193 | $test = ''; |
@@ -195,107 +195,107 @@ discard block |
||
195 | 195 | $this->assertGreaterThanOrEqual(0, $result, 'Error on testSqlAndScriptInject kkk'); |
196 | 196 | */ |
197 | 197 | |
198 | - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php'; |
|
199 | - $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
198 | + $_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php'; |
|
199 | + $result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
200 | 200 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should be ok'); |
201 | 201 | |
202 | 202 | $test = 'This is a < inside string with < and > also and tag like <a> before the >'; |
203 | - $result=testSqlAndScriptInject($test, 0); |
|
203 | + $result = testSqlAndScriptInject($test, 0); |
|
204 | 204 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0b'); |
205 | 205 | |
206 | 206 | $test = 'This is the union of all for the selection of the best'; |
207 | - $result=testSqlAndScriptInject($test, 0); |
|
207 | + $result = testSqlAndScriptInject($test, 0); |
|
208 | 208 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0c'); |
209 | 209 | |
210 | - $test='/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking'; |
|
211 | - $result=testSqlAndScriptInject($test, 1); |
|
210 | + $test = '/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking'; |
|
211 | + $result = testSqlAndScriptInject($test, 1); |
|
212 | 212 | print "test=".$test." result=".$result."\n"; |
213 | 213 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject with a valid url'); |
214 | 214 | |
215 | 215 | // Should detect attack |
216 | - $expectedresult=1; |
|
216 | + $expectedresult = 1; |
|
217 | 217 | |
218 | - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php/<svg>'; |
|
219 | - $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
218 | + $_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php/<svg>'; |
|
219 | + $result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
220 | 220 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should detect XSS'); |
221 | 221 | |
222 | 222 | $test = 'select @@version'; |
223 | - $result=testSqlAndScriptInject($test, 0); |
|
223 | + $result = testSqlAndScriptInject($test, 0); |
|
224 | 224 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1a. Should find an attack on POST param and did not.'); |
225 | 225 | |
226 | 226 | $test = 'select @@version'; |
227 | - $result=testSqlAndScriptInject($test, 1); |
|
227 | + $result = testSqlAndScriptInject($test, 1); |
|
228 | 228 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1b. Should find an attack on GET param and did not.'); |
229 | 229 | |
230 | 230 | $test = '... update ... set ... ='; |
231 | - $result=testSqlAndScriptInject($test, 1); |
|
231 | + $result = testSqlAndScriptInject($test, 1); |
|
232 | 232 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2a. Should find an attack on GET param and did not.'); |
233 | 233 | |
234 | 234 | $test = "delete\nfrom"; |
235 | - $result=testSqlAndScriptInject($test, 1); |
|
235 | + $result = testSqlAndScriptInject($test, 1); |
|
236 | 236 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2b. Should find an attack on GET param and did not.'); |
237 | 237 | |
238 | 238 | $test = 'action=update& ... set ... ='; |
239 | - $result=testSqlAndScriptInject($test, 1); |
|
239 | + $result = testSqlAndScriptInject($test, 1); |
|
240 | 240 | $this->assertEquals(0, $result, 'Error on testSqlAndScriptInject for SQL2b. Should not find an attack on GET param and did.'); |
241 | 241 | |
242 | 242 | $test = '... union ... selection '; |
243 | - $result=testSqlAndScriptInject($test, 1); |
|
243 | + $result = testSqlAndScriptInject($test, 1); |
|
244 | 244 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2c. Should find an attack on GET param and did not.'); |
245 | 245 | |
246 | 246 | $test = 'javascript:'; |
247 | - $result=testSqlAndScriptInject($test, 0); |
|
247 | + $result = testSqlAndScriptInject($test, 0); |
|
248 | 248 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript1. Should find an attack and did not.'); |
249 | 249 | |
250 | 250 | $test = 'javascript:'; |
251 | - $result=testSqlAndScriptInject($test, 0); |
|
251 | + $result = testSqlAndScriptInject($test, 0); |
|
252 | 252 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2. Should find an attack and did not.'); |
253 | 253 | |
254 | 254 | $test = 'javascript&colon;alert(1)'; |
255 | - $result=testSqlAndScriptInject($test, 0); |
|
255 | + $result = testSqlAndScriptInject($test, 0); |
|
256 | 256 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2'); |
257 | 257 | |
258 | - $test="<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
259 | - $result=testSqlAndScriptInject($test, 0); |
|
258 | + $test = "<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
259 | + $result = testSqlAndScriptInject($test, 0); |
|
260 | 260 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa1'); |
261 | 261 | |
262 | - $test="<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
263 | - $result=testSqlAndScriptInject($test, 2); |
|
262 | + $test = "<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
263 | + $result = testSqlAndScriptInject($test, 2); |
|
264 | 264 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa2'); |
265 | 265 | |
266 | - $test='<IMG SRC=# onmouseover="alert(1)">'; |
|
267 | - $result=testSqlAndScriptInject($test, 0); |
|
266 | + $test = '<IMG SRC=# onmouseover="alert(1)">'; |
|
267 | + $result = testSqlAndScriptInject($test, 0); |
|
268 | 268 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa3'); |
269 | - $test='<IMG SRC onmouseover="alert(1)">'; |
|
270 | - $result=testSqlAndScriptInject($test, 0); |
|
269 | + $test = '<IMG SRC onmouseover="alert(1)">'; |
|
270 | + $result = testSqlAndScriptInject($test, 0); |
|
271 | 271 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa4'); |
272 | - $test='<IMG onmouseover="alert(1)">'; |
|
273 | - $result=testSqlAndScriptInject($test, 0); |
|
272 | + $test = '<IMG onmouseover="alert(1)">'; |
|
273 | + $result = testSqlAndScriptInject($test, 0); |
|
274 | 274 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa5'); |
275 | - $test='<IMG SRC=/ onerror="alert(1)">'; |
|
276 | - $result=testSqlAndScriptInject($test, 0); |
|
275 | + $test = '<IMG SRC=/ onerror="alert(1)">'; |
|
276 | + $result = testSqlAndScriptInject($test, 0); |
|
277 | 277 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa6'); |
278 | - $test='<IMG SRC="  javascript:alert(1);">'; |
|
279 | - $result=testSqlAndScriptInject($test, 0); |
|
278 | + $test = '<IMG SRC="  javascript:alert(1);">'; |
|
279 | + $result = testSqlAndScriptInject($test, 0); |
|
280 | 280 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7'); |
281 | 281 | |
282 | - $test='<IMG SRC=javascript:alert('XSS')>'; |
|
283 | - $result=testSqlAndScriptInject($test, 0); |
|
282 | + $test = '<IMG SRC=javascript:alert('XSS')>'; |
|
283 | + $result = testSqlAndScriptInject($test, 0); |
|
284 | 284 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb'); |
285 | 285 | |
286 | - $test='<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>'; |
|
287 | - $result=testSqlAndScriptInject($test, 0); |
|
286 | + $test = '<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>'; |
|
287 | + $result = testSqlAndScriptInject($test, 0); |
|
288 | 288 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc'); |
289 | 289 | |
290 | - $test='<IMG SRC="javascript:alert(\'XSS\');">'; |
|
291 | - $result=testSqlAndScriptInject($test, 1); |
|
290 | + $test = '<IMG SRC="javascript:alert(\'XSS\');">'; |
|
291 | + $result = testSqlAndScriptInject($test, 1); |
|
292 | 292 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ddd'); |
293 | 293 | |
294 | - $test='<IMG """><SCRIPT>alert("XSS")</SCRIPT>">'; |
|
295 | - $result=testSqlAndScriptInject($test, 0); |
|
294 | + $test = '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">'; |
|
295 | + $result = testSqlAndScriptInject($test, 0); |
|
296 | 296 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); |
297 | 297 | |
298 | - $test='<!-- Google analytics --> |
|
298 | + $test = '<!-- Google analytics --> |
|
299 | 299 | <script> |
300 | 300 | (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){ |
301 | 301 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
@@ -306,60 +306,60 @@ discard block |
||
306 | 306 | ga(\'send\', \'pageview\'); |
307 | 307 | |
308 | 308 | </script>'; |
309 | - $result=testSqlAndScriptInject($test, 0); |
|
309 | + $result = testSqlAndScriptInject($test, 0); |
|
310 | 310 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); |
311 | 311 | |
312 | - $test="<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
313 | - $test="<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
312 | + $test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
313 | + $test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
314 | 314 | |
315 | - $test='<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
316 | - $result=testSqlAndScriptInject($test, 0); |
|
315 | + $test = '<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
316 | + $result = testSqlAndScriptInject($test, 0); |
|
317 | 317 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff1'); |
318 | - $test='<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
319 | - $result=testSqlAndScriptInject($test, 0); |
|
318 | + $test = '<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
319 | + $result = testSqlAndScriptInject($test, 0); |
|
320 | 320 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff2'); |
321 | 321 | |
322 | 322 | // This case seems to be filtered by browsers now. |
323 | - $test='<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>'; |
|
323 | + $test = '<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>'; |
|
324 | 324 | //$result=testSqlAndScriptInject($test, 0); |
325 | 325 | //$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ggg'); |
326 | 326 | |
327 | - $test='<iframe src=http://xss.rocks/scriptlet.html <'; |
|
328 | - $result=testSqlAndScriptInject($test, 0); |
|
327 | + $test = '<iframe src=http://xss.rocks/scriptlet.html <'; |
|
328 | + $result = testSqlAndScriptInject($test, 0); |
|
329 | 329 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject hhh'); |
330 | 330 | |
331 | - $test='Set.constructor`alert\x281\x29```'; |
|
332 | - $result=testSqlAndScriptInject($test, 0); |
|
331 | + $test = 'Set.constructor`alert\x281\x29```'; |
|
332 | + $result = testSqlAndScriptInject($test, 0); |
|
333 | 333 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject iii'); |
334 | 334 | |
335 | - $test="on<!-- ab\nc -->error=alert(1)"; |
|
336 | - $result=testSqlAndScriptInject($test, 0); |
|
335 | + $test = "on<!-- ab\nc -->error=alert(1)"; |
|
336 | + $result = testSqlAndScriptInject($test, 0); |
|
337 | 337 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj'); |
338 | 338 | |
339 | - $test="<img src=x one<a>rror=alert(document.location)"; |
|
340 | - $result=testSqlAndScriptInject($test, 0); |
|
339 | + $test = "<img src=x one<a>rror=alert(document.location)"; |
|
340 | + $result = testSqlAndScriptInject($test, 0); |
|
341 | 341 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject kkk'); |
342 | 342 | |
343 | - $test="<a onpointerdown=alert(document.domain)>XSS</a>"; |
|
344 | - $result=testSqlAndScriptInject($test, 0); |
|
343 | + $test = "<a onpointerdown=alert(document.domain)>XSS</a>"; |
|
344 | + $result = testSqlAndScriptInject($test, 0); |
|
345 | 345 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject lll'); |
346 | 346 | |
347 | - $test='<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
348 | - $result=testSqlAndScriptInject($test, 0); |
|
347 | + $test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
348 | + $result = testSqlAndScriptInject($test, 0); |
|
349 | 349 | //print "test=".$test." result=".$result."\n"; |
350 | 350 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject mmm'); |
351 | 351 | |
352 | 352 | |
353 | - $test="Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
354 | - $result=testSqlAndScriptInject($test, 0); // result must be 0 |
|
353 | + $test = "Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
354 | + $result = testSqlAndScriptInject($test, 0); // result must be 0 |
|
355 | 355 | $this->assertEquals(0, $result, 'Error on testSqlAndScriptInject mmm, result should be 0 and is not'); |
356 | 356 | |
357 | - $test ='<a href="j	a	v	asc
ri	pt:(a	l	e	r	t	(document.cookie))">XSS</a>'; |
|
358 | - $result=testSqlAndScriptInject($test, 0); |
|
357 | + $test = '<a href="j	a	v	asc
ri	pt:(a	l	e	r	t	(document.cookie))">XSS</a>'; |
|
358 | + $result = testSqlAndScriptInject($test, 0); |
|
359 | 359 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject nnn, result should be >= 1 and is not'); |
360 | 360 | |
361 | - $test="/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
362 | - $result=testSqlAndScriptInject($test, 2); |
|
361 | + $test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
362 | + $result = testSqlAndScriptInject($test, 2); |
|
363 | 363 | //print "test=".$test." result=".$result."\n"; |
364 | 364 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject with a non valid UTF8 char'); |
365 | 365 | } |
@@ -371,201 +371,201 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function testGETPOST() |
373 | 373 | { |
374 | - global $conf,$user,$langs,$db; |
|
375 | - $conf=$this->savconf; |
|
376 | - $user=$this->savuser; |
|
377 | - $langs=$this->savlangs; |
|
378 | - $db=$this->savdb; |
|
374 | + global $conf, $user, $langs, $db; |
|
375 | + $conf = $this->savconf; |
|
376 | + $user = $this->savuser; |
|
377 | + $langs = $this->savlangs; |
|
378 | + $db = $this->savdb; |
|
379 | 379 | |
380 | 380 | // Force default mode |
381 | 381 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; |
382 | 382 | $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; |
383 | 383 | |
384 | - $_COOKIE["id"]=111; |
|
385 | - $_GET["param1"]="222"; |
|
386 | - $_POST["param1"]="333"; |
|
387 | - $_GET["param2"]='a/b#e(pr)qq-rr\cc'; |
|
388 | - $_GET["param3"]='"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
389 | - $_GET["param4a"]='../../dir'; |
|
390 | - $_GET["param4b"]='..\..\dirwindows'; |
|
391 | - $_GET["param5"]="a_1-b"; |
|
392 | - $_POST["param6"]=""><svg onload='console.log("123")'>"; |
|
393 | - $_POST["param6b"]='<<<../>../>../svg><<<../>../>../animate =alert(1)>abc'; |
|
394 | - $_GET["param7"]='"c:\this is a path~1\aaan &#x110;" abc<bad>def</bad>'; |
|
395 | - $_POST["param8a"]="Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
396 | - $_POST['param8b']='<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
397 | - $_POST['param8c']='< with space after is ok'; |
|
398 | - $_POST['param8d']='<abc123 is html to clean'; |
|
399 | - $_POST['param8e']='<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
400 | - $_POST['param8f']='abc<<svg <><<animate onbegin=alert(document.domain) a'; |
|
401 | - $_POST["param9"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\''; |
|
402 | - $_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\''; |
|
403 | - $_POST["param11"]=' Name <[email protected]> '; |
|
404 | - $_POST["param12"]='<!DOCTYPE html><html>aaa</html>'; |
|
405 | - $_POST["param13"]='n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
406 | - $_POST["param13b"]='n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
407 | - $_POST["param14"]="Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
408 | - $_POST["param15"]="<img onerror<=alert(document.domain)> src=>0xbeefed"; |
|
384 | + $_COOKIE["id"] = 111; |
|
385 | + $_GET["param1"] = "222"; |
|
386 | + $_POST["param1"] = "333"; |
|
387 | + $_GET["param2"] = 'a/b#e(pr)qq-rr\cc'; |
|
388 | + $_GET["param3"] = '"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
389 | + $_GET["param4a"] = '../../dir'; |
|
390 | + $_GET["param4b"] = '..\..\dirwindows'; |
|
391 | + $_GET["param5"] = "a_1-b"; |
|
392 | + $_POST["param6"] = ""><svg onload='console.log("123")'>"; |
|
393 | + $_POST["param6b"] = '<<<../>../>../svg><<<../>../>../animate =alert(1)>abc'; |
|
394 | + $_GET["param7"] = '"c:\this is a path~1\aaan &#x110;" abc<bad>def</bad>'; |
|
395 | + $_POST["param8a"] = "Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
396 | + $_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
397 | + $_POST['param8c'] = '< with space after is ok'; |
|
398 | + $_POST['param8d'] = '<abc123 is html to clean'; |
|
399 | + $_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
400 | + $_POST['param8f'] = 'abc<<svg <><<animate onbegin=alert(document.domain) a'; |
|
401 | + $_POST["param9"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\''; |
|
402 | + $_POST["param10"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\''; |
|
403 | + $_POST["param11"] = ' Name <[email protected]> '; |
|
404 | + $_POST["param12"] = '<!DOCTYPE html><html>aaa</html>'; |
|
405 | + $_POST["param13"] = 'n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
406 | + $_POST["param13b"] = 'n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
407 | + $_POST["param14"] = "Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
408 | + $_POST["param15"] = "<img onerror<=alert(document.domain)> src=>0xbeefed"; |
|
409 | 409 | //$_POST["param15b"]="<html><head><title>Example HTML</title></head><body><div><p>This is a paragraph.</div><ul><li>Item 1</li><li>Item 2</li></ol></body><html>"; |
410 | - $_POST["param16"]='<a style="z-index: 1000">abc</a>'; |
|
411 | - $_POST["param17"]='<span style="background-image: url(logout.php)">abc</span>'; |
|
412 | - $_POST["param18"]='<span style="background-image: url(...?...action=aaa)">abc</span>'; |
|
413 | - $_POST["param19"]='<a href="j	a	v	asc
ri	pt:(alert(document.cookie))">XSS</a>'; |
|
410 | + $_POST["param16"] = '<a style="z-index: 1000">abc</a>'; |
|
411 | + $_POST["param17"] = '<span style="background-image: url(logout.php)">abc</span>'; |
|
412 | + $_POST["param18"] = '<span style="background-image: url(...?...action=aaa)">abc</span>'; |
|
413 | + $_POST["param19"] = '<a href="j	a	v	asc
ri	pt:(alert(document.cookie))">XSS</a>'; |
|
414 | 414 | //$_POST["param19"]='<a href="javascript:alert(document.cookie)">XSS</a>'; |
415 | 415 | |
416 | - $result=GETPOST('id', 'int'); // Must return nothing |
|
416 | + $result = GETPOST('id', 'int'); // Must return nothing |
|
417 | 417 | print __METHOD__." result=".$result."\n"; |
418 | 418 | $this->assertEquals($result, ''); |
419 | 419 | |
420 | - $result=GETPOST("param1", 'int'); |
|
420 | + $result = GETPOST("param1", 'int'); |
|
421 | 421 | print __METHOD__." result=".$result."\n"; |
422 | 422 | $this->assertEquals($result, 222, 'Test on param1 with no 3rd param'); |
423 | 423 | |
424 | - $result=GETPOST("param1", 'int', 2); |
|
424 | + $result = GETPOST("param1", 'int', 2); |
|
425 | 425 | print __METHOD__." result=".$result."\n"; |
426 | 426 | $this->assertEquals($result, 333, 'Test on param1 with 3rd param = 2'); |
427 | 427 | |
428 | 428 | // Test with alpha |
429 | 429 | |
430 | - $result=GETPOST("param2", 'alpha'); |
|
430 | + $result = GETPOST("param2", 'alpha'); |
|
431 | 431 | print __METHOD__." result=".$result."\n"; |
432 | 432 | $this->assertEquals($result, $_GET["param2"], 'Test on param2'); |
433 | 433 | |
434 | - $result=GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
434 | + $result = GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
435 | 435 | print __METHOD__." result=".$result."\n"; |
436 | 436 | $this->assertEquals($result, 'na/b#e(pr)qq-rr\cc', 'Test on param3'); |
437 | 437 | |
438 | - $result=GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
438 | + $result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
439 | 439 | print __METHOD__." result=".$result."\n"; |
440 | 440 | $this->assertEquals($result, 'dir'); |
441 | 441 | |
442 | - $result=GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
442 | + $result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
443 | 443 | print __METHOD__." result=".$result."\n"; |
444 | 444 | $this->assertEquals($result, 'dirwindows'); |
445 | 445 | |
446 | 446 | // Test with aZ09 |
447 | 447 | |
448 | - $result=GETPOST("param1", 'aZ09'); |
|
448 | + $result = GETPOST("param1", 'aZ09'); |
|
449 | 449 | print __METHOD__." result=".$result."\n"; |
450 | 450 | $this->assertEquals($result, $_GET["param1"]); |
451 | 451 | |
452 | - $result=GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
452 | + $result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
453 | 453 | print __METHOD__." result=".$result."\n"; |
454 | 454 | $this->assertEquals($result, ''); |
455 | 455 | |
456 | - $result=GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
456 | + $result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
457 | 457 | print __METHOD__." result=".$result."\n"; |
458 | 458 | $this->assertEquals($result, ''); |
459 | 459 | |
460 | - $result=GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
460 | + $result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
461 | 461 | print __METHOD__." result=".$result."\n"; |
462 | 462 | $this->assertEquals('', $result); |
463 | 463 | |
464 | - $result=GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
464 | + $result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
465 | 465 | print __METHOD__." result=".$result."\n"; |
466 | 466 | $this->assertEquals('', $result); |
467 | 467 | |
468 | - $result=GETPOST("param5", 'aZ09'); |
|
468 | + $result = GETPOST("param5", 'aZ09'); |
|
469 | 469 | print __METHOD__." result=".$result."\n"; |
470 | 470 | $this->assertEquals($_GET["param5"], $result); |
471 | 471 | |
472 | 472 | // Test with nohtml |
473 | 473 | |
474 | - $result=GETPOST("param6", 'nohtml'); |
|
474 | + $result = GETPOST("param6", 'nohtml'); |
|
475 | 475 | print __METHOD__." result=".$result."\n"; |
476 | 476 | $this->assertEquals('">', $result); |
477 | 477 | |
478 | 478 | // Test with alpha = alphanohtml. We must convert the html entities like n and disable all entities |
479 | 479 | |
480 | - $result=GETPOST("param6", 'alphanohtml'); |
|
480 | + $result = GETPOST("param6", 'alphanohtml'); |
|
481 | 481 | print __METHOD__." result=".$result."\n"; |
482 | 482 | $this->assertEquals('>', $result); |
483 | 483 | |
484 | - $result=GETPOST("param6b", 'alphanohtml'); |
|
484 | + $result = GETPOST("param6b", 'alphanohtml'); |
|
485 | 485 | print __METHOD__." result=".$result."\n"; |
486 | 486 | $this->assertEquals('abc', $result); |
487 | 487 | |
488 | - $result=GETPOST("param8a", 'alphanohtml'); |
|
488 | + $result = GETPOST("param8a", 'alphanohtml'); |
|
489 | 489 | print __METHOD__." result=".$result."\n"; |
490 | 490 | $this->assertEquals("Hackersvg onload='console.log(123)'", $result); |
491 | 491 | |
492 | - $result=GETPOST("param8b", 'alphanohtml'); |
|
492 | + $result = GETPOST("param8b", 'alphanohtml'); |
|
493 | 493 | print __METHOD__." result=".$result."\n"; |
494 | 494 | $this->assertEquals('img src=x onerror=alert(document.location) t=', $result, 'Test a string with non closing html tag with alphanohtml'); |
495 | 495 | |
496 | - $result=GETPOST("param8c", 'alphanohtml'); |
|
496 | + $result = GETPOST("param8c", 'alphanohtml'); |
|
497 | 497 | print __METHOD__." result=".$result."\n"; |
498 | 498 | $this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml'); |
499 | 499 | |
500 | - $result=GETPOST("param8d", 'alphanohtml'); |
|
500 | + $result = GETPOST("param8d", 'alphanohtml'); |
|
501 | 501 | print __METHOD__." result=".$result."\n"; |
502 | 502 | $this->assertEquals('abc123 is html to clean', $result, 'Test a string with non closing html tag with alphanohtml'); |
503 | 503 | |
504 | - $result=GETPOST("param8e", 'alphanohtml'); |
|
504 | + $result = GETPOST("param8e", 'alphanohtml'); |
|
505 | 505 | print __METHOD__." result=".$result."\n"; |
506 | 506 | $this->assertEquals($_POST['param8e'], $result, 'Test a string with non closing html tag with alphanohtml'); |
507 | 507 | |
508 | - $result=GETPOST("param8f", 'alphanohtml'); |
|
508 | + $result = GETPOST("param8f", 'alphanohtml'); |
|
509 | 509 | print __METHOD__." result=".$result."\n"; |
510 | 510 | $this->assertEquals('abcsvg animate onbegin=alert(document.domain) a', $result, 'Test a string with html tag open with several <'); |
511 | 511 | |
512 | - $result=GETPOST("param9", 'alphanohtml'); |
|
512 | + $result = GETPOST("param9", 'alphanohtml'); |
|
513 | 513 | print __METHOD__." result=".$result."\n"; |
514 | 514 | $this->assertEquals($_POST["param9"], $result); |
515 | 515 | |
516 | - $result=GETPOST("param10", 'alphanohtml'); |
|
516 | + $result = GETPOST("param10", 'alphanohtml'); |
|
517 | 517 | print __METHOD__." result=".$result."\n"; |
518 | 518 | $this->assertEquals($_POST["param9"], $result, 'We should get param9 after processing param10'); |
519 | 519 | |
520 | - $result=GETPOST("param11", 'alphanohtml'); |
|
520 | + $result = GETPOST("param11", 'alphanohtml'); |
|
521 | 521 | print __METHOD__." result=".$result."\n"; |
522 | 522 | $this->assertEquals("Name", $result, 'Test an email string with alphanohtml'); |
523 | 523 | |
524 | - $result=GETPOST("param13", 'alphanohtml'); |
|
524 | + $result = GETPOST("param13", 'alphanohtml'); |
|
525 | 525 | print __METHOD__." result=".$result."\n"; |
526 | 526 | $this->assertEquals('n n > < XSS', $result, 'Test that html entities are decoded with alpha'); |
527 | 527 | |
528 | 528 | // Test with alphawithlgt |
529 | 529 | |
530 | - $result=GETPOST("param11", 'alphawithlgt'); |
|
530 | + $result = GETPOST("param11", 'alphawithlgt'); |
|
531 | 531 | print __METHOD__." result=".$result."\n"; |
532 | 532 | $this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt'); |
533 | 533 | |
534 | 534 | // Test with restricthtml: we must remove html open/close tag and content but not htmlentities (we can decode html entities for ascii chars like n) |
535 | 535 | |
536 | - $result=GETPOST("param6", 'restricthtml'); |
|
536 | + $result = GETPOST("param6", 'restricthtml'); |
|
537 | 537 | print __METHOD__." result param6=".$result."\n"; |
538 | 538 | $this->assertEquals('">', $result); |
539 | 539 | |
540 | - $result=GETPOST("param7", 'restricthtml'); |
|
540 | + $result = GETPOST("param7", 'restricthtml'); |
|
541 | 541 | print __METHOD__." result param7 = ".$result."\n"; |
542 | 542 | $this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result); |
543 | 543 | |
544 | - $result=GETPOST("param8e", 'restricthtml'); |
|
544 | + $result = GETPOST("param8e", 'restricthtml'); |
|
545 | 545 | print __METHOD__." result param8e = ".$result."\n"; |
546 | 546 | $this->assertEquals('', $result); |
547 | 547 | |
548 | - $result=GETPOST("param12", 'restricthtml'); |
|
548 | + $result = GETPOST("param12", 'restricthtml'); |
|
549 | 549 | print __METHOD__." result=".$result."\n"; |
550 | 550 | $this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml'); |
551 | 551 | |
552 | - $result=GETPOST("param13", 'restricthtml'); |
|
552 | + $result = GETPOST("param13", 'restricthtml'); |
|
553 | 553 | print __METHOD__." result=".$result."\n"; |
554 | 554 | $this->assertEquals('n n > < " <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13 that HTML entities are decoded with restricthtml, but only for common alpha chars'); |
555 | 555 | |
556 | - $result=GETPOST("param13b", 'restricthtml'); |
|
556 | + $result = GETPOST("param13b", 'restricthtml'); |
|
557 | 557 | print __METHOD__." result=".$result."\n"; |
558 | 558 | $this->assertEquals('n n > < " <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13b that HTML entities are decoded with restricthtml, but only for common alpha chars'); |
559 | 559 | |
560 | - $result=GETPOST("param14", 'restricthtml'); |
|
560 | + $result = GETPOST("param14", 'restricthtml'); |
|
561 | 561 | print __METHOD__." result=".$result."\n"; |
562 | 562 | $this->assertEquals("Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)", $result, 'Test 14'); |
563 | 563 | |
564 | - $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
564 | + $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
565 | 565 | print __METHOD__." result=".$result."\n"; |
566 | - $this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
566 | + $this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
567 | 567 | |
568 | - $result=GETPOST("param19", 'restricthtml'); |
|
568 | + $result = GETPOST("param19", 'restricthtml'); |
|
569 | 569 | print __METHOD__." result=".$result."\n"; |
570 | 570 | $this->assertEquals('<a href="(alert(document.cookie))">XSS</a>', $result, 'Test 19'); |
571 | 571 | |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1; |
575 | 575 | |
576 | 576 | |
577 | - $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
577 | + $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
578 | 578 | print __METHOD__." result=".$result."\n"; |
579 | - $this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
|
579 | + $this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
|
580 | 580 | //$this->assertEquals('<img onerror> src=>0xbeefed', $result, 'Test 15b'); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
581 | 581 | |
582 | 582 | |
@@ -585,19 +585,19 @@ discard block |
||
585 | 585 | // Test with restricthtml + MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES to test disabling of bad atrributes |
586 | 586 | $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1; |
587 | 587 | |
588 | - $result=GETPOST("param15", 'restricthtml'); |
|
588 | + $result = GETPOST("param15", 'restricthtml'); |
|
589 | 589 | print __METHOD__." result=".$result."\n"; |
590 | 590 | $this->assertEquals('<img src="">0xbeefed', $result, 'Test 15c'); |
591 | 591 | |
592 | - $result=GETPOST('param16', 'restricthtml'); |
|
592 | + $result = GETPOST('param16', 'restricthtml'); |
|
593 | 593 | print __METHOD__." result=".$result."\n"; |
594 | 594 | $this->assertEquals('<a style=" 1000">abc</a>', $result, 'Test tag a with forbidden attribute z-index'); |
595 | 595 | |
596 | - $result=GETPOST('param17', 'restricthtml'); |
|
596 | + $result = GETPOST('param17', 'restricthtml'); |
|
597 | 597 | print __METHOD__." result=".$result."\n"; |
598 | 598 | $this->assertEquals('<span style="background-image: url()">abc</span>', $result, 'Test anytag with a forbidden value for attribute'); |
599 | 599 | |
600 | - $result=GETPOST('param18', 'restricthtml'); |
|
600 | + $result = GETPOST('param18', 'restricthtml'); |
|
601 | 601 | print __METHOD__." result=".$result."\n"; |
602 | 602 | $this->assertEquals('<span style="background-image: url(...?...aaa)">abc</span>', $result, 'Test anytag with a forbidden value for attribute'); |
603 | 603 | |
@@ -606,40 +606,40 @@ discard block |
||
606 | 606 | |
607 | 607 | // Special test for GETPOST of backtopage, backtolist or backtourl parameter |
608 | 608 | |
609 | - $_POST["backtopage"]='//www.google.com'; |
|
610 | - $result=GETPOST("backtopage"); |
|
609 | + $_POST["backtopage"] = '//www.google.com'; |
|
610 | + $result = GETPOST("backtopage"); |
|
611 | 611 | print __METHOD__." result=".$result."\n"; |
612 | 612 | $this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
613 | 613 | |
614 | - $_POST["backtopage"]='https:https://www.google.com'; |
|
615 | - $result=GETPOST("backtopage"); |
|
614 | + $_POST["backtopage"] = 'https:https://www.google.com'; |
|
615 | + $result = GETPOST("backtopage"); |
|
616 | 616 | print __METHOD__." result=".$result."\n"; |
617 | 617 | $this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
618 | 618 | |
619 | - $_POST["backtolist"]='::HTTPS://www.google.com'; |
|
620 | - $result=GETPOST("backtolist"); |
|
619 | + $_POST["backtolist"] = '::HTTPS://www.google.com'; |
|
620 | + $result = GETPOST("backtolist"); |
|
621 | 621 | print __METHOD__." result=".$result."\n"; |
622 | 622 | $this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
623 | 623 | |
624 | - $_POST["backtopage"]='http:www.google.com'; |
|
625 | - $result=GETPOST("backtopage"); |
|
624 | + $_POST["backtopage"] = 'http:www.google.com'; |
|
625 | + $result = GETPOST("backtopage"); |
|
626 | 626 | print __METHOD__." result=".$result."\n"; |
627 | 627 | $this->assertEquals('httpwww.google.com', $result, 'Test for backtopage param'); |
628 | 628 | |
629 | - $_POST["backtopage"]='/mydir/mypage.php?aa=a%10a'; |
|
630 | - $result=GETPOST("backtopage"); |
|
629 | + $_POST["backtopage"] = '/mydir/mypage.php?aa=a%10a'; |
|
630 | + $result = GETPOST("backtopage"); |
|
631 | 631 | print __METHOD__." result=".$result."\n"; |
632 | 632 | $this->assertEquals('/mydir/mypage.php?aa=a%10a', $result, 'Test for backtopage param'); |
633 | 633 | |
634 | - $_POST["backtopage"]='javascripT&javascript#javascriptxjavascript3a alert(1)'; |
|
635 | - $result=GETPOST("backtopage"); |
|
634 | + $_POST["backtopage"] = 'javascripT&javascript#javascriptxjavascript3a alert(1)'; |
|
635 | + $result = GETPOST("backtopage"); |
|
636 | 636 | print __METHOD__." result=".$result."\n"; |
637 | 637 | $this->assertEquals('x3aalert(1)', $result, 'Test for backtopage param'); |
638 | 638 | |
639 | 639 | |
640 | 640 | $conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3; |
641 | - $_POST["pagecontentwithlinks"]='<img src="aaa"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
642 | - $result=GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
641 | + $_POST["pagecontentwithlinks"] = '<img src="aaa"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
642 | + $result = GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
643 | 643 | print __METHOD__." result=".$result."\n"; |
644 | 644 | $this->assertEquals('TooManyLinksIntoHTMLString', $result, 'Test on limit on GETPOST fails'); |
645 | 645 | |
@@ -653,15 +653,15 @@ discard block |
||
653 | 653 | */ |
654 | 654 | public function testEncodeDecode() |
655 | 655 | { |
656 | - $stringtotest="This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode."; |
|
656 | + $stringtotest = "This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode."; |
|
657 | 657 | |
658 | - $encodedstring=dol_encode($stringtotest); |
|
659 | - $decodedstring=dol_decode($encodedstring); |
|
658 | + $encodedstring = dol_encode($stringtotest); |
|
659 | + $decodedstring = dol_decode($encodedstring); |
|
660 | 660 | print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; |
661 | 661 | $this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with no parameter'); |
662 | 662 | |
663 | - $encodedstring=dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
664 | - $decodedstring=dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
663 | + $encodedstring = dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
664 | + $decodedstring = dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
665 | 665 | print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; |
666 | 666 | $this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with a key parameter'); |
667 | 667 | |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | $this->assertEquals('a : b " c \' d ' e é', $decodedstring, 'Function did not sanitize correclty'); |
681 | 681 | |
682 | 682 | $stringtotest = 'a : b " c ' d ' e é'; |
683 | - $decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES|ENT_HTML5); |
|
683 | + $decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES | ENT_HTML5); |
|
684 | 684 | $this->assertEquals('a : b " c \' d \' e é', $decodedstring, 'Function did not sanitize correclty'); |
685 | 685 | |
686 | 686 | return 0; |
@@ -744,21 +744,21 @@ discard block |
||
744 | 744 | { |
745 | 745 | global $conf; |
746 | 746 | |
747 | - $genpass1=getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
747 | + $genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
748 | 748 | print __METHOD__." genpass1=".$genpass1."\n"; |
749 | 749 | $this->assertEquals(strlen($genpass1), 32); |
750 | 750 | |
751 | - $genpass1=getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
751 | + $genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
752 | 752 | print __METHOD__." genpass1=".$genpass1."\n"; |
753 | 753 | $this->assertEquals(strlen($genpass1), 32); |
754 | 754 | |
755 | - $conf->global->USER_PASSWORD_GENERATED='None'; |
|
756 | - $genpass2=getRandomPassword(false); // Should return an empty string |
|
755 | + $conf->global->USER_PASSWORD_GENERATED = 'None'; |
|
756 | + $genpass2 = getRandomPassword(false); // Should return an empty string |
|
757 | 757 | print __METHOD__." genpass2=".$genpass2."\n"; |
758 | 758 | $this->assertEquals($genpass2, ''); |
759 | 759 | |
760 | - $conf->global->USER_PASSWORD_GENERATED='Standard'; |
|
761 | - $genpass3=getRandomPassword(false); // Should return a password of 12 chars |
|
760 | + $conf->global->USER_PASSWORD_GENERATED = 'Standard'; |
|
761 | + $genpass3 = getRandomPassword(false); // Should return a password of 12 chars |
|
762 | 762 | print __METHOD__." genpass3=".$genpass3."\n"; |
763 | 763 | $this->assertEquals(strlen($genpass3), 12); |
764 | 764 | |
@@ -772,16 +772,16 @@ discard block |
||
772 | 772 | */ |
773 | 773 | public function testRestrictedArea() |
774 | 774 | { |
775 | - global $conf,$user,$langs,$db; |
|
776 | - $conf=$this->savconf; |
|
777 | - $user=$this->savuser; |
|
778 | - $langs=$this->savlangs; |
|
779 | - $db=$this->savdb; |
|
775 | + global $conf, $user, $langs, $db; |
|
776 | + $conf = $this->savconf; |
|
777 | + $user = $this->savuser; |
|
778 | + $langs = $this->savlangs; |
|
779 | + $db = $this->savdb; |
|
780 | 780 | |
781 | 781 | //$dummyuser=new User($db); |
782 | 782 | //$result=restrictedArea($dummyuser,'societe'); |
783 | 783 | |
784 | - $result=restrictedArea($user, 'societe'); |
|
784 | + $result = restrictedArea($user, 'societe'); |
|
785 | 785 | $this->assertEquals(1, $result); |
786 | 786 | } |
787 | 787 | |
@@ -799,42 +799,42 @@ discard block |
||
799 | 799 | $url = 'ftp://mydomain.com'; |
800 | 800 | $tmp = getURLContent($url); |
801 | 801 | print __METHOD__." url=".$url."\n"; |
802 | - $this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported' |
|
802 | + $this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported' |
|
803 | 803 | |
804 | - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
805 | - $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
804 | + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
805 | + $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
806 | 806 | print __METHOD__." url=".$url."\n"; |
807 | 807 | $this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 response and stop here'); |
808 | 808 | |
809 | - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
810 | - $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
809 | + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
810 | + $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
811 | 811 | print __METHOD__." url=".$url."\n"; |
812 | 812 | $this->assertEquals(200, $tmp['http_code'], 'Should GET url 301 with a follow -> 200 but we get '.$tmp['http_code']); |
813 | 813 | |
814 | 814 | $url = 'http://localhost'; |
815 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
815 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
816 | 816 | print __METHOD__." url=".$url."\n"; |
817 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
817 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
818 | 818 | |
819 | 819 | $url = 'http://127.0.0.1'; |
820 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
820 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
821 | 821 | print __METHOD__." url=".$url."\n"; |
822 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
822 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
823 | 823 | |
824 | 824 | $url = 'http://127.0.2.1'; |
825 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
825 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
826 | 826 | print __METHOD__." url=".$url."\n"; |
827 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
827 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
828 | 828 | |
829 | 829 | $url = 'https://169.254.0.1'; |
830 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
830 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
831 | 831 | print __METHOD__." url=".$url."\n"; |
832 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
832 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
833 | 833 | |
834 | 834 | $url = 'http://[::1]'; |
835 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
835 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
836 | 836 | print __METHOD__." url=".$url."\n"; |
837 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
837 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
838 | 838 | |
839 | 839 | /*$url = 'localtest.me'; |
840 | 840 | $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | */ |
844 | 844 | |
845 | 845 | $url = 'http://192.0.0.192'; |
846 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
846 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
847 | 847 | print __METHOD__." url=".$url." tmp['http_code'] = ".$tmp['http_code']."\n"; |
848 | - $this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
848 | + $this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
849 | 849 | |
850 | 850 | return 0; |
851 | 851 | } |
@@ -857,22 +857,22 @@ discard block |
||
857 | 857 | */ |
858 | 858 | public function testDolSanitizeUrl() |
859 | 859 | { |
860 | - global $conf,$user,$langs,$db; |
|
861 | - $conf=$this->savconf; |
|
862 | - $user=$this->savuser; |
|
863 | - $langs=$this->savlangs; |
|
864 | - $db=$this->savdb; |
|
860 | + global $conf, $user, $langs, $db; |
|
861 | + $conf = $this->savconf; |
|
862 | + $user = $this->savuser; |
|
863 | + $langs = $this->savlangs; |
|
864 | + $db = $this->savdb; |
|
865 | 865 | |
866 | 866 | $test = 'javascripT&javascript#x3a alert(1)'; |
867 | - $result=dol_sanitizeUrl($test); |
|
867 | + $result = dol_sanitizeUrl($test); |
|
868 | 868 | $this->assertEquals('x3a alert(1)', $result, 'Test on dol_sanitizeUrl A'); |
869 | 869 | |
870 | 870 | $test = 'javajavascriptscript&cjavascriptolon;alert(1)'; |
871 | - $result=dol_sanitizeUrl($test); |
|
871 | + $result = dol_sanitizeUrl($test); |
|
872 | 872 | $this->assertEquals('alert(1)', $result, 'Test on dol_sanitizeUrl B'); |
873 | 873 | |
874 | 874 | $test = '/javas:cript/google.com'; |
875 | - $result=dol_sanitizeUrl($test); |
|
875 | + $result = dol_sanitizeUrl($test); |
|
876 | 876 | $this->assertEquals('google.com', $result, 'Test on dol_sanitizeUrl C'); |
877 | 877 | } |
878 | 878 | |
@@ -883,26 +883,26 @@ discard block |
||
883 | 883 | */ |
884 | 884 | public function testDolSanitizeEmail() |
885 | 885 | { |
886 | - global $conf,$user,$langs,$db; |
|
887 | - $conf=$this->savconf; |
|
888 | - $user=$this->savuser; |
|
889 | - $langs=$this->savlangs; |
|
890 | - $db=$this->savdb; |
|
886 | + global $conf, $user, $langs, $db; |
|
887 | + $conf = $this->savconf; |
|
888 | + $user = $this->savuser; |
|
889 | + $langs = $this->savlangs; |
|
890 | + $db = $this->savdb; |
|
891 | 891 | |
892 | 892 | $test = '[email protected] <My name>, [email protected] <Another name>'; |
893 | - $result=dol_sanitizeEmail($test); |
|
893 | + $result = dol_sanitizeEmail($test); |
|
894 | 894 | $this->assertEquals($test, $result, 'Test on dol_sanitizeEmail A'); |
895 | 895 | |
896 | 896 | $test = "[email protected] <My name>,\[email protected] <Another name>"; |
897 | - $result=dol_sanitizeEmail($test); |
|
897 | + $result = dol_sanitizeEmail($test); |
|
898 | 898 | $this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail B'); |
899 | 899 | |
900 | 900 | $test = '[email protected] <My name>,\[email protected] <Another name>'; |
901 | - $result=dol_sanitizeEmail($test); |
|
901 | + $result = dol_sanitizeEmail($test); |
|
902 | 902 | $this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail C'); |
903 | 903 | |
904 | 904 | $test = '[email protected] <My name>, "bcc:bbb"@mycompany.com <Another name>'; |
905 | - $result=dol_sanitizeEmail($test); |
|
905 | + $result = dol_sanitizeEmail($test); |
|
906 | 906 | $this->assertEquals('[email protected] <My name>, [email protected] <Another name>', $result, 'Test on dol_sanitizeEmail D'); |
907 | 907 | } |
908 | 908 | |
@@ -913,19 +913,19 @@ discard block |
||
913 | 913 | */ |
914 | 914 | public function testDolSanitizeFileName() |
915 | 915 | { |
916 | - global $conf,$user,$langs,$db; |
|
917 | - $conf=$this->savconf; |
|
918 | - $user=$this->savuser; |
|
919 | - $langs=$this->savlangs; |
|
920 | - $db=$this->savdb; |
|
916 | + global $conf, $user, $langs, $db; |
|
917 | + $conf = $this->savconf; |
|
918 | + $user = $this->savuser; |
|
919 | + $langs = $this->savlangs; |
|
920 | + $db = $this->savdb; |
|
921 | 921 | |
922 | 922 | //$dummyuser=new User($db); |
923 | 923 | //$result=restrictedArea($dummyuser,'societe'); |
924 | 924 | |
925 | - $result=dol_sanitizeFileName('bad file | evilaction'); |
|
925 | + $result = dol_sanitizeFileName('bad file | evilaction'); |
|
926 | 926 | $this->assertEquals('bad file _ evilaction', $result); |
927 | 927 | |
928 | - $result=dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam'); |
|
928 | + $result = dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam'); |
|
929 | 929 | $this->assertEquals('bad file _evilparam _evilparam _evilparam _evilparam', $result); |
930 | 930 | } |
931 | 931 | |
@@ -936,17 +936,17 @@ discard block |
||
936 | 936 | */ |
937 | 937 | public function testDolEval() |
938 | 938 | { |
939 | - global $conf,$user,$langs,$db; |
|
940 | - $conf=$this->savconf; |
|
941 | - $user=$this->savuser; |
|
942 | - $langs=$this->savlangs; |
|
943 | - $db=$this->savdb; |
|
939 | + global $conf, $user, $langs, $db; |
|
940 | + $conf = $this->savconf; |
|
941 | + $user = $this->savuser; |
|
942 | + $langs = $this->savlangs; |
|
943 | + $db = $this->savdb; |
|
944 | 944 | |
945 | - $result=dol_eval('1==1', 1, 0); |
|
945 | + $result = dol_eval('1==1', 1, 0); |
|
946 | 946 | print "result1 = ".$result."\n"; |
947 | 947 | $this->assertTrue($result); |
948 | 948 | |
949 | - $result=dol_eval('1==2', 1, 0); |
|
949 | + $result = dol_eval('1==2', 1, 0); |
|
950 | 950 | print "result2 = ".$result."\n"; |
951 | 951 | $this->assertFalse($result); |
952 | 952 | |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
955 | 955 | |
956 | 956 | $s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"'; |
957 | - $result=dol_eval($s, 1, 1, '2'); |
|
957 | + $result = dol_eval($s, 1, 1, '2'); |
|
958 | 958 | print "result3 = ".$result."\n"; |
959 | 959 | $this->assertEquals('Parent project not found', $result); |
960 | 960 | |
@@ -995,48 +995,48 @@ discard block |
||
995 | 995 | print "result12 = ".$result."\n"; |
996 | 996 | $this->assertStringContainsString('Bad string syntax to evaluate', $result); |
997 | 997 | |
998 | - $result=dol_eval("90402.38+267678+0", 1, 1, 1); |
|
998 | + $result = dol_eval("90402.38+267678+0", 1, 1, 1); |
|
999 | 999 | print "result13 = ".$result."\n"; |
1000 | 1000 | $this->assertEquals('358080.38', $result); |
1001 | 1001 | |
1002 | - global $leftmenu; // Used into strings to eval |
|
1002 | + global $leftmenu; // Used into strings to eval |
|
1003 | 1003 | |
1004 | 1004 | $leftmenu = 'AAA'; |
1005 | - $result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1005 | + $result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1006 | 1006 | print "result = ".$result."\n"; |
1007 | 1007 | $this->assertTrue($result); |
1008 | 1008 | |
1009 | 1009 | // Same with a value that does not match |
1010 | 1010 | $leftmenu = 'XXX'; |
1011 | - $result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1011 | + $result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1012 | 1012 | print "result14 = ".$result."\n"; |
1013 | 1013 | $this->assertFalse($result); |
1014 | 1014 | |
1015 | 1015 | $leftmenu = 'AAA'; |
1016 | - $result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1016 | + $result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1017 | 1017 | print "result15 = ".$result."\n"; |
1018 | 1018 | $this->assertTrue($result); |
1019 | 1019 | |
1020 | 1020 | $leftmenu = 'XXX'; |
1021 | - $result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1021 | + $result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1022 | 1022 | print "result16 = ".$result."\n"; |
1023 | 1023 | $this->assertFalse($result); |
1024 | 1024 | |
1025 | 1025 | $string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)'; |
1026 | - $result=dol_eval($string, 1, 1, '1'); |
|
1026 | + $result = dol_eval($string, 1, 1, '1'); |
|
1027 | 1027 | print "result17 = ".$result."\n"; |
1028 | 1028 | $this->assertTrue($result); |
1029 | 1029 | |
1030 | - $result=dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
1030 | + $result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
1031 | 1031 | print "result18 = ".$result."\n"; |
1032 | 1032 | $this->assertFalse($result); |
1033 | 1033 | |
1034 | - $a='ab'; |
|
1034 | + $a = 'ab'; |
|
1035 | 1035 | $result = (string) dol_eval("(\$a.'s')", 1, 0); |
1036 | 1036 | print "result19 = ".$result."\n"; |
1037 | 1037 | $this->assertStringContainsString('Bad string syntax to evaluate', $result); |
1038 | 1038 | |
1039 | - $leftmenu='abs'; |
|
1039 | + $leftmenu = 'abs'; |
|
1040 | 1040 | $result = (string) dol_eval('$leftmenu(-5)', 1, 0); |
1041 | 1041 | print "result20 = ".$result."\n"; |
1042 | 1042 | $this->assertStringContainsString('Bad string syntax to evaluate', $result); |
@@ -1050,24 +1050,24 @@ discard block |
||
1050 | 1050 | */ |
1051 | 1051 | public function testCheckLoginPassEntity() |
1052 | 1052 | { |
1053 | - $login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); |
|
1053 | + $login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); |
|
1054 | 1054 | print __METHOD__." login=".$login."\n"; |
1055 | 1055 | $this->assertEquals($login, ''); |
1056 | 1056 | |
1057 | - $login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); |
|
1057 | + $login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); |
|
1058 | 1058 | print __METHOD__." login=".$login."\n"; |
1059 | 1059 | $this->assertEquals($login, ''); |
1060 | 1060 | |
1061 | - $login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists |
|
1061 | + $login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists |
|
1062 | 1062 | print __METHOD__." login=".$login."\n"; |
1063 | 1063 | $this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed'); |
1064 | 1064 | |
1065 | - $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method |
|
1065 | + $login = checkLoginPassEntity('admin', 'admin', 1, array('http', 'dolibarr')); // Should work because of second authentication method |
|
1066 | 1066 | print __METHOD__." login=".$login."\n"; |
1067 | 1067 | $this->assertEquals($login, 'admin'); |
1068 | 1068 | |
1069 | - $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); |
|
1069 | + $login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); |
|
1070 | 1070 | print __METHOD__." login=".$login."\n"; |
1071 | - $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1071 | + $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1072 | 1072 | } |
1073 | 1073 | } |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | $modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha')); |
75 | 75 | $objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha')); |
76 | 76 | $dicname = dol_sanitizeFileName(GETPOST('dicname', 'alpha')); |
77 | -$editorname= GETPOST('editorname', 'alpha'); |
|
78 | -$editorurl= GETPOST('editorurl', 'alpha'); |
|
79 | -$version= GETPOST('version', 'alpha'); |
|
80 | -$family= GETPOST('family', 'alpha'); |
|
81 | -$picto= GETPOST('idpicto', 'alpha'); |
|
82 | -$idmodule= GETPOST('idmodule', 'alpha'); |
|
77 | +$editorname = GETPOST('editorname', 'alpha'); |
|
78 | +$editorurl = GETPOST('editorurl', 'alpha'); |
|
79 | +$version = GETPOST('version', 'alpha'); |
|
80 | +$family = GETPOST('family', 'alpha'); |
|
81 | +$picto = GETPOST('idpicto', 'alpha'); |
|
82 | +$idmodule = GETPOST('idmodule', 'alpha'); |
|
83 | 83 | |
84 | 84 | // Security check |
85 | 85 | if (!isModEnabled('modulebuilder')) { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | // Copy last html.formsetup.class.php' to backport folder |
251 | 251 | $tryToCopyFromSetupClass = true; |
252 | - $backportDest = $destdir .'/backport/v16/core/class'; |
|
252 | + $backportDest = $destdir.'/backport/v16/core/class'; |
|
253 | 253 | $backportFileSrc = DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; |
254 | 254 | $backportFileDest = $backportDest.'/html.formsetup.class.php'; |
255 | 255 | $result = dol_mkdir($backportDest); |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | clearstatcache(true); |
389 | 389 | if (function_exists('opcache_invalidate')) { |
390 | - opcache_reset(); // remove the include cache hell ! |
|
390 | + opcache_reset(); // remove the include cache hell ! |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | header("Location: ".$_SERVER["PHP_SELF"].'?module='.$modulename); |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | } |
837 | 837 | } |
838 | 838 | $stringLog = implode("\n", $strreplace); |
839 | - dolReplaceInFile($destfile, array('//include::ChangeLog.md[]' => '','__CHANGELOG__' => $stringLog)); |
|
839 | + dolReplaceInFile($destfile, array('//include::ChangeLog.md[]' => '', '__CHANGELOG__' => $stringLog)); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | // Delete old documentation files |
@@ -1311,7 +1311,7 @@ discard block |
||
1311 | 1311 | } |
1312 | 1312 | $rights = $moduleobj->rights; |
1313 | 1313 | $moduledescriptorfile = $destdir.'/core/modules/mod'.$module.'.class.php'; |
1314 | - $checkComment=checkExistComment($moduledescriptorfile, 1); |
|
1314 | + $checkComment = checkExistComment($moduledescriptorfile, 1); |
|
1315 | 1315 | if ($checkComment < 0) { |
1316 | 1316 | setEventMessages($langs->trans("WarningCommentNotFound", $langs->trans("Permissions"), "mod".$module."class.php"), null, 'warnings'); |
1317 | 1317 | } else { |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | $menus = $moduleobj->menu; |
1480 | - $counter = 0 ; |
|
1480 | + $counter = 0; |
|
1481 | 1481 | foreach ($menus as $menu) { |
1482 | 1482 | if ($menu['leftmenu'] == strtolower($objectname)) { |
1483 | 1483 | $counter++; |
@@ -1630,7 +1630,7 @@ discard block |
||
1630 | 1630 | } else { |
1631 | 1631 | createNewDictionnary($module, $moduledescriptorfile, $newdicname, $dictionaries); |
1632 | 1632 | if (function_exists('opcache_invalidate')) { |
1633 | - opcache_reset(); // remove the include cache hell ! |
|
1633 | + opcache_reset(); // remove the include cache hell ! |
|
1634 | 1634 | } |
1635 | 1635 | clearstatcache(true); |
1636 | 1636 | header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '')); |
@@ -1704,7 +1704,7 @@ discard block |
||
1704 | 1704 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); |
1705 | 1705 | } |
1706 | 1706 | |
1707 | - if (!$error && !GETPOST('regenerateclasssql')&& !GETPOST('regeneratemissing')) { |
|
1707 | + if (!$error && !GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { |
|
1708 | 1708 | $addfieldentry = array( |
1709 | 1709 | 'name'=>GETPOST('propname', 'aZ09'), |
1710 | 1710 | 'label'=>GETPOST('proplabel', 'alpha'), |
@@ -1719,7 +1719,7 @@ discard block |
||
1719 | 1719 | 'isameasure'=>GETPOST('propisameasure', 'int'), |
1720 | 1720 | 'comment'=>GETPOST('propcomment', 'alpha'), |
1721 | 1721 | 'help'=>GETPOST('prophelp', 'alpha'), |
1722 | - 'css'=>GETPOST('propcss', 'alpha'), // Can be 'maxwidth500 widthcentpercentminusxx' for example |
|
1722 | + 'css'=>GETPOST('propcss', 'alpha'), // Can be 'maxwidth500 widthcentpercentminusxx' for example |
|
1723 | 1723 | 'cssview'=>GETPOST('propcssview', 'alpha'), |
1724 | 1724 | 'csslist'=>GETPOST('propcsslist', 'alpha'), |
1725 | 1725 | 'default'=>GETPOST('propdefault', 'restricthtml'), |
@@ -1870,7 +1870,7 @@ discard block |
||
1870 | 1870 | |
1871 | 1871 | clearstatcache(true); |
1872 | 1872 | if (function_exists('opcache_invalidate')) { |
1873 | - opcache_reset(); // remove the include cache hell ! |
|
1873 | + opcache_reset(); // remove the include cache hell ! |
|
1874 | 1874 | } |
1875 | 1875 | |
1876 | 1876 | header("Location: ".$_SERVER["PHP_SELF"].'?module=deletemodule'); |
@@ -1962,7 +1962,7 @@ discard block |
||
1962 | 1962 | |
1963 | 1963 | clearstatcache(true); |
1964 | 1964 | if (function_exists('opcache_invalidate')) { |
1965 | - opcache_reset(); // remove the include cache hell ! |
|
1965 | + opcache_reset(); // remove the include cache hell ! |
|
1966 | 1966 | } |
1967 | 1967 | $resultko = 0; |
1968 | 1968 | foreach ($filetodelete as $tmpfiletodelete) { |
@@ -2039,11 +2039,11 @@ discard block |
||
2039 | 2039 | } |
2040 | 2040 | |
2041 | 2041 | if (!empty(GETPOST('dictionnarykey'))) { |
2042 | - $newdicname = $dicts['tabname'][GETPOST('dictionnarykey')-1]; |
|
2042 | + $newdicname = $dicts['tabname'][GETPOST('dictionnarykey') - 1]; |
|
2043 | 2043 | } |
2044 | 2044 | |
2045 | 2045 | //chercher la table dicname |
2046 | - $query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($newdicname) . "'"; |
|
2046 | + $query = "SHOW TABLES LIKE '".MAIN_DB_PREFIX.strtolower($newdicname)."'"; |
|
2047 | 2047 | $checkTable = $db->query($query); |
2048 | 2048 | if ($checkTable && $db->num_rows($checkTable) <= 0) { |
2049 | 2049 | $error++; |
@@ -2082,7 +2082,7 @@ discard block |
||
2082 | 2082 | setEventMessages($langs->trans("DictionaryDeleted", ucfirst(substr($newdicname, 2))), null); |
2083 | 2083 | } |
2084 | 2084 | if (function_exists('opcache_invalidate')) { |
2085 | - opcache_reset(); // remove the include cache hell ! |
|
2085 | + opcache_reset(); // remove the include cache hell ! |
|
2086 | 2086 | } |
2087 | 2087 | clearstatcache(true); |
2088 | 2088 | header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '')); |
@@ -2090,7 +2090,7 @@ discard block |
||
2090 | 2090 | } |
2091 | 2091 | } |
2092 | 2092 | if ($dirins && $action == 'updatedictionary' && GETPOST('dictionnarykey')) { |
2093 | - $keydict = GETPOST('dictionnarykey') - 1 ; |
|
2093 | + $keydict = GETPOST('dictionnarykey') - 1; |
|
2094 | 2094 | |
2095 | 2095 | $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; |
2096 | 2096 | $destdir = $dirins.'/'.strtolower($module); |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | setEventMessages($langs->trans("DictionaryNameUpdated", ucfirst(GETPOST('tablib'))), null); |
2125 | 2125 | } |
2126 | 2126 | if (function_exists('opcache_invalidate')) { |
2127 | - opcache_reset(); // remove the include cache hell ! |
|
2127 | + opcache_reset(); // remove the include cache hell ! |
|
2128 | 2128 | } |
2129 | 2129 | clearstatcache(true); |
2130 | 2130 | header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '')); |
@@ -2244,13 +2244,13 @@ discard block |
||
2244 | 2244 | |
2245 | 2245 | //check existing object permission |
2246 | 2246 | $counter = 0; |
2247 | - $permsForObject =array(); |
|
2247 | + $permsForObject = array(); |
|
2248 | 2248 | $permissions = $moduleobj->rights; |
2249 | 2249 | $allObject = array(); |
2250 | 2250 | |
2251 | 2251 | $countPerms = count($permissions); |
2252 | 2252 | |
2253 | - for ($i =0; $i<$countPerms; $i++) { |
|
2253 | + for ($i = 0; $i < $countPerms; $i++) { |
|
2254 | 2254 | if ($permissions[$i][4] == $objectForPerms) { |
2255 | 2255 | $counter++; |
2256 | 2256 | if (count($permsForObject) < 3) { |
@@ -2262,7 +2262,7 @@ discard block |
||
2262 | 2262 | |
2263 | 2263 | // check if label of object already exists |
2264 | 2264 | $countPermsObj = count($permsForObject); |
2265 | - for ($j = 0; $j<$countPermsObj; $j++) { |
|
2265 | + for ($j = 0; $j < $countPermsObj; $j++) { |
|
2266 | 2266 | if (in_array($crud, $permsForObject[$j])) { |
2267 | 2267 | $error++; |
2268 | 2268 | setEventMessages($langs->trans("ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)), null, 'errors'); |
@@ -2299,7 +2299,7 @@ discard block |
||
2299 | 2299 | |
2300 | 2300 | clearstatcache(true); |
2301 | 2301 | if (function_exists('opcache_invalidate')) { |
2302 | - opcache_reset(); // remove the include cache hell ! |
|
2302 | + opcache_reset(); // remove the include cache hell ! |
|
2303 | 2303 | } |
2304 | 2304 | header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); |
2305 | 2305 | exit; |
@@ -2308,7 +2308,7 @@ discard block |
||
2308 | 2308 | |
2309 | 2309 | |
2310 | 2310 | // Update permission |
2311 | -if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& empty($cancel)) { |
|
2311 | +if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright') && empty($cancel)) { |
|
2312 | 2312 | $error = 0; |
2313 | 2313 | // load class and check if right exist |
2314 | 2314 | $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; |
@@ -2351,21 +2351,21 @@ discard block |
||
2351 | 2351 | } |
2352 | 2352 | |
2353 | 2353 | $permissions = $moduleobj->rights; |
2354 | - $key =(int) GETPOST('counter')-1; |
|
2354 | + $key = (int) GETPOST('counter') - 1; |
|
2355 | 2355 | //get permission want to delete from permissions array |
2356 | 2356 | $x1 = $permissions[$key][1]; |
2357 | 2357 | $x2 = $permissions[$key][4]; |
2358 | 2358 | $x3 = $permissions[$key][5]; |
2359 | 2359 | //check existing object permission |
2360 | 2360 | $counter = 0; |
2361 | - $permsForObject =array(); |
|
2361 | + $permsForObject = array(); |
|
2362 | 2362 | $permissions = $moduleobj->rights; |
2363 | 2363 | $firstRight = 0; |
2364 | 2364 | $existRight = 0; |
2365 | 2365 | $allObject = array(); |
2366 | 2366 | |
2367 | 2367 | $countPerms = count($permissions); |
2368 | - for ($i =0; $i<$countPerms; $i++) { |
|
2368 | + for ($i = 0; $i < $countPerms; $i++) { |
|
2369 | 2369 | if ($permissions[$i][4] == $objectForPerms) { |
2370 | 2370 | $counter++; |
2371 | 2371 | if (count($permsForObject) < 3) { |
@@ -2377,7 +2377,7 @@ discard block |
||
2377 | 2377 | |
2378 | 2378 | if ($label != $x1 && $crud != $x3) { |
2379 | 2379 | $countPermsObj = count($permsForObject); |
2380 | - for ($j = 0; $j<$countPermsObj; $j++) { |
|
2380 | + for ($j = 0; $j < $countPermsObj; $j++) { |
|
2381 | 2381 | if (in_array($label, $permsForObject[$j])) { |
2382 | 2382 | $error++; |
2383 | 2383 | setEventMessages($langs->trans("ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)), null, 'errors'); |
@@ -2405,7 +2405,7 @@ discard block |
||
2405 | 2405 | setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null); |
2406 | 2406 | clearstatcache(true); |
2407 | 2407 | if (function_exists('opcache_invalidate')) { |
2408 | - opcache_reset(); // remove the include cache hell ! |
|
2408 | + opcache_reset(); // remove the include cache hell ! |
|
2409 | 2409 | } |
2410 | 2410 | header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); |
2411 | 2411 | exit; |
@@ -2429,7 +2429,7 @@ discard block |
||
2429 | 2429 | } |
2430 | 2430 | |
2431 | 2431 | $permissions = $moduleobj->rights; |
2432 | - $key = (int) GETPOST('permskey', 'int')-1; |
|
2432 | + $key = (int) GETPOST('permskey', 'int') - 1; |
|
2433 | 2433 | |
2434 | 2434 | if (!$error) { |
2435 | 2435 | // check if module is enabled |
@@ -2455,7 +2455,7 @@ discard block |
||
2455 | 2455 | |
2456 | 2456 | clearstatcache(true); |
2457 | 2457 | if (function_exists('opcache_invalidate')) { |
2458 | - opcache_reset(); // remove the include cache hell ! |
|
2458 | + opcache_reset(); // remove the include cache hell ! |
|
2459 | 2459 | } |
2460 | 2460 | |
2461 | 2461 | header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); |
@@ -2624,7 +2624,7 @@ discard block |
||
2624 | 2624 | |
2625 | 2625 | clearstatcache(true); |
2626 | 2626 | if (function_exists('opcache_invalidate')) { |
2627 | - opcache_reset(); // remove the include cache hell ! |
|
2627 | + opcache_reset(); // remove the include cache hell ! |
|
2628 | 2628 | } |
2629 | 2629 | |
2630 | 2630 | setEventMessages($langs->trans('MenuDeletedSuccessfuly'), null); |
@@ -2680,7 +2680,7 @@ discard block |
||
2680 | 2680 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Url")), null, 'errors'); |
2681 | 2681 | } |
2682 | 2682 | if (!empty(GETPOST('target'))) { |
2683 | - $targets = array('_blank','_self','_parent','_top',''); |
|
2683 | + $targets = array('_blank', '_self', '_parent', '_top', ''); |
|
2684 | 2684 | if (!in_array(GETPOST('target'), $targets)) { |
2685 | 2685 | $error++; |
2686 | 2686 | setEventMessages($langs->trans("ErrorFieldValue", $langs->transnoentities("target")), null, 'errors'); |
@@ -2714,7 +2714,7 @@ discard block |
||
2714 | 2714 | $objects = dolGetListOfObjectClasses($destdir); |
2715 | 2715 | |
2716 | 2716 | if (GETPOST('type', 'alpha') == 'left') { |
2717 | - if (empty(GETPOST('leftmenu')) && count($objects) >0) { |
|
2717 | + if (empty(GETPOST('leftmenu')) && count($objects) > 0) { |
|
2718 | 2718 | $error++; |
2719 | 2719 | setEventMessages($langs->trans("ErrorCoherenceMenu", $langs->transnoentities("leftmenu"), $langs->transnoentities("type")), null, 'errors'); |
2720 | 2720 | } |
@@ -2777,7 +2777,7 @@ discard block |
||
2777 | 2777 | |
2778 | 2778 | // modify a menu |
2779 | 2779 | if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && GETPOST('tabobj')) { |
2780 | - $objectname = GETPOST('tabobj'); |
|
2780 | + $objectname = GETPOST('tabobj'); |
|
2781 | 2781 | $dirins = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; |
2782 | 2782 | $destdir = $dirins.'/'.strtolower($module); |
2783 | 2783 | $objects = dolGetListOfObjectClasses($destdir); |
@@ -2862,7 +2862,7 @@ discard block |
||
2862 | 2862 | } |
2863 | 2863 | if ($result < 0) { |
2864 | 2864 | setEventMessages($langs->trans('ErrorMenuExistValue'), null, 'errors'); |
2865 | - header("Location: ".$_SERVER["PHP_SELF"].'?action=editmenu&token='.newToken().'&menukey='.urlencode($key+1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.($key+1)); |
|
2865 | + header("Location: ".$_SERVER["PHP_SELF"].'?action=editmenu&token='.newToken().'&menukey='.urlencode($key + 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.($key + 1)); |
|
2866 | 2866 | exit; |
2867 | 2867 | } |
2868 | 2868 | setEventMessages($langs->trans('MenuUpdatedSuccessfuly'), null); |
@@ -3320,7 +3320,7 @@ discard block |
||
3320 | 3320 | $h++; |
3321 | 3321 | |
3322 | 3322 | $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : ''); |
3323 | - $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans("Dictionaries") : $langs->trans('Dictionaries').' <span class="badge">'.$countDictionaries."</span>"); |
|
3323 | + $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans("Dictionaries") : $langs->trans('Dictionaries').' <span class="badge">'.$countDictionaries."</span>"); |
|
3324 | 3324 | $head2[$h][2] = 'dictionaries'; |
3325 | 3325 | $h++; |
3326 | 3326 | |
@@ -3891,16 +3891,16 @@ discard block |
||
3891 | 3891 | // Define path for sql file |
3892 | 3892 | $pathtosql = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'-'.strtolower($module).'.sql'; |
3893 | 3893 | $result = dol_buildpath($pathtosql); |
3894 | - if (! dol_is_file($result)) { |
|
3894 | + if (!dol_is_file($result)) { |
|
3895 | 3895 | $pathtosql = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'.sql'; |
3896 | 3896 | $result = dol_buildpath($pathtosql); |
3897 | - if (! dol_is_file($result)) { |
|
3897 | + if (!dol_is_file($result)) { |
|
3898 | 3898 | $pathtosql = 'install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($tabobj).'-'.strtolower($module).'.sql'; |
3899 | 3899 | $result = dol_buildpath($pathtosql); |
3900 | - if (! dol_is_file($result)) { |
|
3900 | + if (!dol_is_file($result)) { |
|
3901 | 3901 | $pathtosql = 'install/mysql/tables/llx_'.strtolower($module).'-'.strtolower($module).'.sql'; |
3902 | 3902 | $result = dol_buildpath($pathtosql); |
3903 | - if (! dol_is_file($result)) { |
|
3903 | + if (!dol_is_file($result)) { |
|
3904 | 3904 | $pathtosql = 'install/mysql/tables/llx_'.strtolower($module).'.sql'; |
3905 | 3905 | $pathtosqlextra = 'install/mysql/tables/llx_'.strtolower($module).'_extrafields.sql'; |
3906 | 3906 | $result = dol_buildpath($pathtosql); |
@@ -3919,7 +3919,7 @@ discard block |
||
3919 | 3919 | $pathtosqlroot = preg_replace('/\/llx_.*$/', '', $pathtosql); |
3920 | 3920 | |
3921 | 3921 | $pathtosqlkey = preg_replace('/\.sql$/', '.key.sql', $pathtosql); |
3922 | - $pathtosqlextrakey = preg_replace('/\.sql$/', '.key.sql', $pathtosqlextra); |
|
3922 | + $pathtosqlextrakey = preg_replace('/\.sql$/', '.key.sql', $pathtosqlextra); |
|
3923 | 3923 | |
3924 | 3924 | $pathtolib = strtolower($module).'/lib/'.strtolower($module).'.lib.php'; |
3925 | 3925 | $pathtoobjlib = strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($tabobj).'.lib.php'; |
@@ -3978,7 +3978,7 @@ discard block |
||
3978 | 3978 | |
3979 | 3979 | // API file |
3980 | 3980 | print '<br>'; |
3981 | - print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtoapi) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'</span></strike>').'</strong>'; |
|
3981 | + print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtoapi) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi) ? '' : '</span></strike>').'</strong>'; |
|
3982 | 3982 | if (dol_is_file($realpathtoapi)) { |
3983 | 3983 | $file = file_get_contents($realpathtoapi); |
3984 | 3984 | if (preg_match('/var '.$tabobj.'\s+([^\s]*)\s/ims', $file, $objs)) { |
@@ -4000,7 +4000,7 @@ discard block |
||
4000 | 4000 | } |
4001 | 4001 | // PHPUnit |
4002 | 4002 | print '<br>'; |
4003 | - print '<span class="fa fa-file-o"></span> '.$langs->trans("TestClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtophpunit) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'</span></strike>').'</strong>'; |
|
4003 | + print '<span class="fa fa-file-o"></span> '.$langs->trans("TestClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtophpunit) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit) ? '' : '</span></strike>').'</strong>'; |
|
4004 | 4004 | if (dol_is_file($realpathtophpunit)) { |
4005 | 4005 | print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; |
4006 | 4006 | print ' '; |
@@ -4216,26 +4216,26 @@ discard block |
||
4216 | 4216 | $propname = $propkey; |
4217 | 4217 | $proplabel = $propval['label']; |
4218 | 4218 | $proptype = $propval['type']; |
4219 | - $proparrayofkeyval = !empty($propval['arrayofkeyval'])?$propval['arrayofkeyval']:''; |
|
4219 | + $proparrayofkeyval = !empty($propval['arrayofkeyval']) ? $propval['arrayofkeyval'] : ''; |
|
4220 | 4220 | $propnotnull = !empty($propval['notnull']) ? $propval['notnull'] : '0'; |
4221 | - $propdefault = !empty($propval['default'])?$propval['default']:''; |
|
4222 | - $propindex = !empty($propval['index'])?$propval['index']:''; |
|
4223 | - $propforeignkey = !empty($propval['foreignkey'])?$propval['foreignkey']:''; |
|
4221 | + $propdefault = !empty($propval['default']) ? $propval['default'] : ''; |
|
4222 | + $propindex = !empty($propval['index']) ? $propval['index'] : ''; |
|
4223 | + $propforeignkey = !empty($propval['foreignkey']) ? $propval['foreignkey'] : ''; |
|
4224 | 4224 | $propposition = $propval['position']; |
4225 | 4225 | $propenabled = $propval['enabled']; |
4226 | 4226 | $propvisible = $propval['visible']; |
4227 | - $propnoteditable = !empty($propval['noteditable'])?$propval['noteditable']:0; |
|
4228 | - $propalwayseditable = !empty($propval['alwayseditable'])?$propval['alwayseditable']:0; |
|
4229 | - $propsearchall = !empty($propval['searchall'])?$propval['searchall']:0; |
|
4230 | - $propisameasure = !empty($propval['isameasure'])?$propval['isameasure']:0; |
|
4231 | - $propcss = !empty($propval['css'])?$propval['css']:''; |
|
4232 | - $propcssview = !empty($propval['cssview'])?$propval['cssview']:''; |
|
4233 | - $propcsslist = !empty($propval['csslist'])?$propval['csslist']:''; |
|
4234 | - $prophelp = !empty($propval['help'])?$propval['help']:''; |
|
4235 | - $propshowoncombobox = !empty($propval['showoncombobox'])?$propval['showoncombobox']:0; |
|
4227 | + $propnoteditable = !empty($propval['noteditable']) ? $propval['noteditable'] : 0; |
|
4228 | + $propalwayseditable = !empty($propval['alwayseditable']) ? $propval['alwayseditable'] : 0; |
|
4229 | + $propsearchall = !empty($propval['searchall']) ? $propval['searchall'] : 0; |
|
4230 | + $propisameasure = !empty($propval['isameasure']) ? $propval['isameasure'] : 0; |
|
4231 | + $propcss = !empty($propval['css']) ? $propval['css'] : ''; |
|
4232 | + $propcssview = !empty($propval['cssview']) ? $propval['cssview'] : ''; |
|
4233 | + $propcsslist = !empty($propval['csslist']) ? $propval['csslist'] : ''; |
|
4234 | + $prophelp = !empty($propval['help']) ? $propval['help'] : ''; |
|
4235 | + $propshowoncombobox = !empty($propval['showoncombobox']) ? $propval['showoncombobox'] : 0; |
|
4236 | 4236 | //$propdisabled=$propval['disabled']; |
4237 | - $propvalidate = !empty($propval['validate'])?$propval['validate']:0; |
|
4238 | - $propcomment = !empty($propval['comment'])?$propval['comment']:''; |
|
4237 | + $propvalidate = !empty($propval['validate']) ? $propval['validate'] : 0; |
|
4238 | + $propcomment = !empty($propval['comment']) ? $propval['comment'] : ''; |
|
4239 | 4239 | |
4240 | 4240 | print '<tr class="oddeven">'; |
4241 | 4241 | |
@@ -4613,14 +4613,14 @@ discard block |
||
4613 | 4613 | $i = 0; |
4614 | 4614 | $maxi = count($dicts['tabname']); |
4615 | 4615 | while ($i < $maxi) { |
4616 | - if ($action == 'editdict' && $i == (int) GETPOST('dictionnarykey', 'int')-1) { |
|
4616 | + if ($action == 'editdict' && $i == (int) GETPOST('dictionnarykey', 'int') - 1) { |
|
4617 | 4617 | print '<tr class="oddeven">'; |
4618 | 4618 | print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
4619 | 4619 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
4620 | 4620 | print '<input type="hidden" name="tab" value="dictionaries">'; |
4621 | 4621 | print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; |
4622 | 4622 | print '<input type="hidden" name="action" value="updatedictionary">'; |
4623 | - print '<input type="hidden" name="dictionnarykey" value="'.($i+1).'">'; |
|
4623 | + print '<input type="hidden" name="dictionnarykey" value="'.($i + 1).'">'; |
|
4624 | 4624 | |
4625 | 4625 | print '<td class="tdsticky tdstickygray">'; |
4626 | 4626 | print ($i + 1); |
@@ -4716,8 +4716,8 @@ discard block |
||
4716 | 4716 | print '</td>'; |
4717 | 4717 | |
4718 | 4718 | print '<td class="center tdstickyright tdstickyghostwhite">'; |
4719 | - print '<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=editdict&token='.newToken().'&dictionnarykey='.urlencode($i+1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_edit().'</a>'; |
|
4720 | - print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletedict&token='.newToken().'&dictionnarykey='.urlencode($i+1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_delete().'</a>'; |
|
4719 | + print '<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=editdict&token='.newToken().'&dictionnarykey='.urlencode($i + 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_edit().'</a>'; |
|
4720 | + print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletedict&token='.newToken().'&dictionnarykey='.urlencode($i + 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_delete().'</a>'; |
|
4721 | 4721 | print '</td>'; |
4722 | 4722 | |
4723 | 4723 | print '</tr>'; |
@@ -4924,7 +4924,7 @@ discard block |
||
4924 | 4924 | print_liste_field_titre("", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'center ', $langs->trans('')); |
4925 | 4925 | |
4926 | 4926 | print "</tr>\n"; |
4927 | - $r = count($menus)+1; |
|
4927 | + $r = count($menus) + 1; |
|
4928 | 4928 | // for adding menu on module |
4929 | 4929 | print '<tr>'; |
4930 | 4930 | print '<td class="center"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>'; |
@@ -4947,7 +4947,7 @@ discard block |
||
4947 | 4947 | print '<td class="center"><input id="leftmenu" type="text" class="left maxwidth" name="leftmenu" value="'.dol_escape_htmltag(GETPOST('leftmenu', 'alpha')).'"></td>'; |
4948 | 4948 | print '<td class="left"><input id="url" type="text" class="left maxwidth" name="url" value="'.dol_escape_htmltag(GETPOST('url', 'alpha')).'"></td>'; |
4949 | 4949 | print '<td class="left"><input type="text" class="left maxwidth" name="langs" value="'.strtolower($module).'@'.strtolower($module).'" readonly></td>'; |
4950 | - print '<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000+$r).'" readonly></td>'; |
|
4950 | + print '<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).'" readonly></td>'; |
|
4951 | 4951 | print '<td class="center">'; |
4952 | 4952 | print '<select class="center maxwidth" name="enabled">'; |
4953 | 4953 | print '<option value="1" selected>'.$langs->trans("Show").'</option>'; |
@@ -4985,7 +4985,7 @@ discard block |
||
4985 | 4985 | $propMainmenu = !empty($menu['mainmenu']) ? $menu['mainmenu'] : GETPOST('mainmenu'); |
4986 | 4986 | $propLeftmenu = !empty($menu['leftmenu']) ? $menu['leftmenu'] : GETPOST('leftmenu'); |
4987 | 4987 | $propUrl = !empty($menu['url']) ? $menu['url'] : GETPOST('url', 'alpha'); |
4988 | - $propPerms = !empty($menu['perms']) ? $menu['perms'] : GETPOST('perms'); |
|
4988 | + $propPerms = !empty($menu['perms']) ? $menu['perms'] : GETPOST('perms'); |
|
4989 | 4989 | $propUser = !empty($menu['user']) ? $menu['user'] : GETPOST('user'); |
4990 | 4990 | $propTarget = !empty($menu['target']) ? $menu['target'] : GETPOST('target'); |
4991 | 4991 | $propEnabled = !empty($menu['enabled']) ? $menu['enabled'] : GETPOST('enabled'); |
@@ -5035,7 +5035,7 @@ discard block |
||
5035 | 5035 | print '<td class="left"><input type="text" class="left maxwidth" name="leftmenu" value="'.dol_escape_htmltag($propLeftmenu).'" readonly></td>'; |
5036 | 5036 | print '<td class="left"><input type="text" class="left maxwidth" name="url" value="'.dol_escape_htmltag($propUrl).'"></td>'; |
5037 | 5037 | print '<td class="left"><input type="text" class="left maxwidth" name="langs" value="'.strtolower($module).'@'.strtolower($module).'" readonly></td>'; |
5038 | - print '<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000+$r-1).'" readonly></td>'; |
|
5038 | + print '<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r - 1).'" readonly></td>'; |
|
5039 | 5039 | print '<td class="left">'; |
5040 | 5040 | print '<select class="center maxwidth" name="enabled">'; |
5041 | 5041 | print '<option selected value="'.dol_escape_htmltag($propEnabled).'">'.(dol_escape_htmltag($propEnabled) == '' ? $langs->trans('Hide') : $langs->trans('Show')).'</option>'; |
@@ -5126,7 +5126,7 @@ discard block |
||
5126 | 5126 | if (strpos($menu['perms'], "\$user->hasRight") !== 0) { |
5127 | 5127 | print ''; |
5128 | 5128 | } else { |
5129 | - print (dol_escape_htmltag($langs->trans($crud[$valPerms])) ); |
|
5129 | + print (dol_escape_htmltag($langs->trans($crud[$valPerms]))); |
|
5130 | 5130 | } |
5131 | 5131 | print '</td>'; |
5132 | 5132 | |
@@ -5148,7 +5148,7 @@ discard block |
||
5148 | 5148 | print '<td class="center tdstickyright tdstickyghostwhite">'; |
5149 | 5149 | if ($menu['titre'] != 'Module'.$module.'Name') { |
5150 | 5150 | print '<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=editmenu&token='.newToken().'&menukey='.urlencode($i).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_edit().'</a>'; |
5151 | - print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletemenu&token='.newToken().'&menukey='.urlencode($i-1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_delete().'</a>'; |
|
5151 | + print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletemenu&token='.newToken().'&menukey='.urlencode($i - 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_delete().'</a>'; |
|
5152 | 5152 | } |
5153 | 5153 | print '</td>'; |
5154 | 5154 | } |
@@ -5174,7 +5174,7 @@ discard block |
||
5174 | 5174 | } |
5175 | 5175 | }); |
5176 | 5176 | |
5177 | - var groupedRights = ' . $groupedRights_json . '; |
|
5177 | + var groupedRights = ' . $groupedRights_json.'; |
|
5178 | 5178 | var objectsSelect = $("select[id=\'objects\']"); |
5179 | 5179 | var permsSelect = $("select[id=\'perms\']"); |
5180 | 5180 | |
@@ -5245,7 +5245,7 @@ discard block |
||
5245 | 5245 | $dir = $dirread.'/'.$modulelowercase.'/class'; |
5246 | 5246 | $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); |
5247 | 5247 | $objects = array('myobject'); |
5248 | - $reg =array(); |
|
5248 | + $reg = array(); |
|
5249 | 5249 | foreach ($listofobject as $fileobj) { |
5250 | 5250 | $tmpcontent = file_get_contents($fileobj['fullname']); |
5251 | 5251 | if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) { |
@@ -5396,7 +5396,7 @@ discard block |
||
5396 | 5396 | if (in_array($perm[5], array('lire', 'read', 'creer', 'write', 'effacer', 'delete'))) { |
5397 | 5397 | print dol_escape_htmltag(ucfirst($perm[4])); |
5398 | 5398 | } else { |
5399 | - print ''; // No particular object |
|
5399 | + print ''; // No particular object |
|
5400 | 5400 | } |
5401 | 5401 | print '</td>'; |
5402 | 5402 | |
@@ -6233,9 +6233,9 @@ discard block |
||
6233 | 6233 | |
6234 | 6234 | print '<td>'; |
6235 | 6235 | if ($tabName[0] === "+") { |
6236 | - print '<span class="badge badge-status4 badge-status">' . dol_escape_htmltag($tabName) . '</span>'; |
|
6236 | + print '<span class="badge badge-status4 badge-status">'.dol_escape_htmltag($tabName).'</span>'; |
|
6237 | 6237 | } else { |
6238 | - print '<span class="badge badge-status8 badge-status">' . dol_escape_htmltag($tabName) . '</span>'; |
|
6238 | + print '<span class="badge badge-status8 badge-status">'.dol_escape_htmltag($tabName).'</span>'; |
|
6239 | 6239 | } |
6240 | 6240 | print '</td>'; |
6241 | 6241 |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public $price; |
140 | 140 | |
141 | - public $price_formated; // used by takepos/ajax/ajax.php |
|
141 | + public $price_formated; // used by takepos/ajax/ajax.php |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Selling price with tax |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public $price_ttc; |
149 | 149 | |
150 | - public $price_ttc_formated; // used by takepos/ajax/ajax.php |
|
150 | + public $price_ttc_formated; // used by takepos/ajax/ajax.php |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Minimum price net |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | public $packaging; |
227 | 227 | |
228 | 228 | |
229 | - public $lifetime; // In seconds |
|
229 | + public $lifetime; // In seconds |
|
230 | 230 | |
231 | 231 | public $qc_frequency; |
232 | 232 | |
@@ -358,20 +358,20 @@ discard block |
||
358 | 358 | |
359 | 359 | //! Metric of products |
360 | 360 | public $weight; |
361 | - public $weight_units; // scale -3, 0, 3, 6 |
|
361 | + public $weight_units; // scale -3, 0, 3, 6 |
|
362 | 362 | public $length; |
363 | - public $length_units; // scale -3, 0, 3, 6 |
|
363 | + public $length_units; // scale -3, 0, 3, 6 |
|
364 | 364 | public $width; |
365 | - public $width_units; // scale -3, 0, 3, 6 |
|
365 | + public $width_units; // scale -3, 0, 3, 6 |
|
366 | 366 | public $height; |
367 | - public $height_units; // scale -3, 0, 3, 6 |
|
367 | + public $height_units; // scale -3, 0, 3, 6 |
|
368 | 368 | public $surface; |
369 | - public $surface_units; // scale -3, 0, 3, 6 |
|
369 | + public $surface_units; // scale -3, 0, 3, 6 |
|
370 | 370 | public $volume; |
371 | - public $volume_units; // scale -3, 0, 3, 6 |
|
371 | + public $volume_units; // scale -3, 0, 3, 6 |
|
372 | 372 | |
373 | 373 | public $net_measure; |
374 | - public $net_measure_units; // scale -3, 0, 3, 6 |
|
374 | + public $net_measure_units; // scale -3, 0, 3, 6 |
|
375 | 375 | |
376 | 376 | public $accountancy_code_sell; |
377 | 377 | public $accountancy_code_sell_intra; |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), |
559 | 559 | //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), |
560 | 560 | //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), |
561 | - 'mandatory_period' => array('type'=>'integer', 'label'=>'mandatory_period', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000), |
|
561 | + 'mandatory_period' => array('type'=>'integer', 'label'=>'mandatory_period', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000), |
|
562 | 562 | ); |
563 | 563 | |
564 | 564 | /** |
@@ -856,9 +856,9 @@ discard block |
||
856 | 856 | |
857 | 857 | // update accountancy for this entity |
858 | 858 | if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { |
859 | - $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " .((int) $this->id) . " AND entity = " . ((int) $conf->entity)); |
|
859 | + $this->db->query("DELETE FROM ".$this->db->prefix()."product_perentity WHERE fk_product = ".((int) $this->id)." AND entity = ".((int) $conf->entity)); |
|
860 | 860 | |
861 | - $sql = "INSERT INTO " . $this->db->prefix() . "product_perentity ("; |
|
861 | + $sql = "INSERT INTO ".$this->db->prefix()."product_perentity ("; |
|
862 | 862 | $sql .= " fk_product"; |
863 | 863 | $sql .= ", entity"; |
864 | 864 | $sql .= ", accountancy_code_buy"; |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | $sql .= ", accountancy_code_sell_export"; |
870 | 870 | $sql .= ") VALUES ("; |
871 | 871 | $sql .= $this->id; |
872 | - $sql .= ", " . $conf->entity; |
|
873 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; |
|
874 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; |
|
875 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_export) . "'"; |
|
876 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; |
|
877 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; |
|
878 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; |
|
872 | + $sql .= ", ".$conf->entity; |
|
873 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; |
|
874 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'"; |
|
875 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'"; |
|
876 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; |
|
877 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; |
|
878 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; |
|
879 | 879 | $sql .= ")"; |
880 | 880 | $result = $this->db->query($sql); |
881 | 881 | if (!$result) { |
@@ -1240,12 +1240,12 @@ discard block |
||
1240 | 1240 | $sql .= ", note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'null'); |
1241 | 1241 | $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; |
1242 | 1242 | if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { |
1243 | - $sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'"; |
|
1244 | - $sql .= ", accountancy_code_buy_intra = '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; |
|
1245 | - $sql .= ", accountancy_code_buy_export = '" . $this->db->escape($this->accountancy_code_buy_export) . "'"; |
|
1246 | - $sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'"; |
|
1247 | - $sql .= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; |
|
1248 | - $sql .= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; |
|
1243 | + $sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'"; |
|
1244 | + $sql .= ", accountancy_code_buy_intra = '".$this->db->escape($this->accountancy_code_buy_intra)."'"; |
|
1245 | + $sql .= ", accountancy_code_buy_export = '".$this->db->escape($this->accountancy_code_buy_export)."'"; |
|
1246 | + $sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'"; |
|
1247 | + $sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'"; |
|
1248 | + $sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'"; |
|
1249 | 1249 | } |
1250 | 1250 | $sql .= ", desiredstock = ".((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? (float) $this->desiredstock : "null"); |
1251 | 1251 | $sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | $sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1); |
1254 | 1254 | $sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); |
1255 | 1255 | $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); |
1256 | - $sql .= ", mandatory_period = ".($this->mandatory_period ); |
|
1256 | + $sql .= ", mandatory_period = ".($this->mandatory_period); |
|
1257 | 1257 | // stock field is not here because it is a denormalized value from product_stock. |
1258 | 1258 | $sql .= " WHERE rowid = ".((int) $id); |
1259 | 1259 | |
@@ -1275,9 +1275,9 @@ discard block |
||
1275 | 1275 | |
1276 | 1276 | // update accountancy for this entity |
1277 | 1277 | if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { |
1278 | - $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity)); |
|
1278 | + $this->db->query("DELETE FROM ".$this->db->prefix()."product_perentity WHERE fk_product = ".((int) $this->id)." AND entity = ".((int) $conf->entity)); |
|
1279 | 1279 | |
1280 | - $sql = "INSERT INTO " . $this->db->prefix() . "product_perentity ("; |
|
1280 | + $sql = "INSERT INTO ".$this->db->prefix()."product_perentity ("; |
|
1281 | 1281 | $sql .= " fk_product"; |
1282 | 1282 | $sql .= ", entity"; |
1283 | 1283 | $sql .= ", accountancy_code_buy"; |
@@ -1288,13 +1288,13 @@ discard block |
||
1288 | 1288 | $sql .= ", accountancy_code_sell_export"; |
1289 | 1289 | $sql .= ") VALUES ("; |
1290 | 1290 | $sql .= $this->id; |
1291 | - $sql .= ", " . $conf->entity; |
|
1292 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; |
|
1293 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; |
|
1294 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_export) . "'"; |
|
1295 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; |
|
1296 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; |
|
1297 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; |
|
1291 | + $sql .= ", ".$conf->entity; |
|
1292 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; |
|
1293 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'"; |
|
1294 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'"; |
|
1295 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; |
|
1296 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; |
|
1297 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; |
|
1298 | 1298 | $sql .= ")"; |
1299 | 1299 | $result = $this->db->query($sql); |
1300 | 1300 | if (!$result) { |
@@ -1592,7 +1592,7 @@ discard block |
||
1592 | 1592 | } |
1593 | 1593 | } elseif (isset($this->multilangs[$key])) { |
1594 | 1594 | if (empty($this->multilangs["$key"]["label"])) { |
1595 | - $this->errors[] = $key . ' : ' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); |
|
1595 | + $this->errors[] = $key.' : '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); |
|
1596 | 1596 | return -1; |
1597 | 1597 | } |
1598 | 1598 | |
@@ -1788,7 +1788,7 @@ discard block |
||
1788 | 1788 | private function getArrayForPriceCompare($level = 0) |
1789 | 1789 | { |
1790 | 1790 | |
1791 | - $testExit = array('multiprices','multiprices_ttc','multiprices_base_type','multiprices_min','multiprices_min_ttc','multiprices_tva_tx','multiprices_recuperableonly'); |
|
1791 | + $testExit = array('multiprices', 'multiprices_ttc', 'multiprices_base_type', 'multiprices_min', 'multiprices_min_ttc', 'multiprices_tva_tx', 'multiprices_recuperableonly'); |
|
1792 | 1792 | |
1793 | 1793 | foreach ($testExit as $field) { |
1794 | 1794 | if (!isset($this->$field)) { |
@@ -2411,20 +2411,20 @@ discard block |
||
2411 | 2411 | |
2412 | 2412 | //For MultiCompany |
2413 | 2413 | //PMP per entity & Stocks Sharings stock_reel includes only stocks shared with this entity |
2414 | - $separatedEntityPMP = false; // Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product. |
|
2415 | - $separatedStock = false; // Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses. |
|
2414 | + $separatedEntityPMP = false; // Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product. |
|
2415 | + $separatedStock = false; // Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses. |
|
2416 | 2416 | $visibleWarehousesEntities = $conf->entity; |
2417 | 2417 | if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED)) { |
2418 | 2418 | if (!empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) { |
2419 | - $checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity); |
|
2420 | - if ($this->db->num_rows($checkPMPPerEntity)>0) { |
|
2419 | + $checkPMPPerEntity = $this->db->query("SELECT pmp FROM ".$this->db->prefix()."product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity); |
|
2420 | + if ($this->db->num_rows($checkPMPPerEntity) > 0) { |
|
2421 | 2421 | $separatedEntityPMP = true; |
2422 | 2422 | } |
2423 | 2423 | } |
2424 | 2424 | global $mc; |
2425 | 2425 | $separatedStock = true; |
2426 | 2426 | if (isset($mc->sharings['stock']) && !empty($mc->sharings['stock'])) { |
2427 | - $visibleWarehousesEntities .= "," . implode(",", $mc->sharings['stock']); |
|
2427 | + $visibleWarehousesEntities .= ",".implode(",", $mc->sharings['stock']); |
|
2428 | 2428 | } |
2429 | 2429 | } |
2430 | 2430 | if ($separatedEntityPMP) { |
@@ -2441,10 +2441,10 @@ discard block |
||
2441 | 2441 | } |
2442 | 2442 | $sql .= " FROM ".$this->db->prefix()."product as p"; |
2443 | 2443 | if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) || $separatedEntityPMP) { |
2444 | - $sql .= " LEFT JOIN " . $this->db->prefix() . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); |
|
2444 | + $sql .= " LEFT JOIN ".$this->db->prefix()."product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = ".((int) $conf->entity); |
|
2445 | 2445 | } |
2446 | 2446 | if ($separatedStock) { |
2447 | - $sql .= " LEFT JOIN " . $this->db->prefix() . "product_stock as sp ON sp.fk_product = p.rowid AND sp.fk_entrepot IN (SELECT rowid FROM ".$this->db->prefix()."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))"; |
|
2447 | + $sql .= " LEFT JOIN ".$this->db->prefix()."product_stock as sp ON sp.fk_product = p.rowid AND sp.fk_entrepot IN (SELECT rowid FROM ".$this->db->prefix()."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))"; |
|
2448 | 2448 | } |
2449 | 2449 | |
2450 | 2450 | if ($id) { |
@@ -2598,15 +2598,15 @@ discard block |
||
2598 | 2598 | $sql .= " WHERE entity IN (".getEntity('productprice').")"; |
2599 | 2599 | $sql .= " AND price_level=".((int) $i); |
2600 | 2600 | $sql .= " AND fk_product = ".((int) $this->id); |
2601 | - $sql .= " ORDER BY date_price DESC, rowid DESC"; // Get the most recent line |
|
2602 | - $sql .= " LIMIT 1"; // Only the first one |
|
2601 | + $sql .= " ORDER BY date_price DESC, rowid DESC"; // Get the most recent line |
|
2602 | + $sql .= " LIMIT 1"; // Only the first one |
|
2603 | 2603 | $resql = $this->db->query($sql); |
2604 | 2604 | if ($resql) { |
2605 | 2605 | $result = $this->db->fetch_array($resql); |
2606 | 2606 | |
2607 | 2607 | $this->multiprices[$i] = $result ? $result["price"] : null; |
2608 | 2608 | $this->multiprices_ttc[$i] = $result ? $result["price_ttc"] : null; |
2609 | - $this->multiprices_min[$i] = $result ? $result["price_min"] : null; |
|
2609 | + $this->multiprices_min[$i] = $result ? $result["price_min"] : null; |
|
2610 | 2610 | $this->multiprices_min_ttc[$i] = $result ? $result["price_min_ttc"] : null; |
2611 | 2611 | $this->multiprices_base_type[$i] = $result ? $result["price_base_type"] : null; |
2612 | 2612 | // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on |
@@ -2826,7 +2826,7 @@ discard block |
||
2826 | 2826 | $obj = $this->db->fetch_object($result); |
2827 | 2827 | $this->stats_mo['customers_'.$role] = $obj->nb_customers ? $obj->nb_customers : 0; |
2828 | 2828 | $this->stats_mo['nb_'.$role] = $obj->nb ? $obj->nb : 0; |
2829 | - $this->stats_mo['qty_'.$role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM() |
|
2829 | + $this->stats_mo['qty_'.$role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM() |
|
2830 | 2830 | } else { |
2831 | 2831 | $this->error = $this->db->error(); |
2832 | 2832 | $error++; |
@@ -4300,7 +4300,7 @@ discard block |
||
4300 | 4300 | //Addition of a product with the highest rank +1 |
4301 | 4301 | $sql = "INSERT INTO ".$this->db->prefix()."product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)"; |
4302 | 4302 | $sql .= " VALUES (".((int) $id_pere).", ".((int) $id_fils).", ".price2num($qty, 'MS').", ".price2num($incdec, 'MS').", ".((int) $rank).")"; |
4303 | - if (! $this->db->query($sql)) { |
|
4303 | + if (!$this->db->query($sql)) { |
|
4304 | 4304 | dol_print_error($this->db); |
4305 | 4305 | return -1; |
4306 | 4306 | } else { |
@@ -4383,17 +4383,17 @@ discard block |
||
4383 | 4383 | |
4384 | 4384 | // Updated ranks so that none are missing |
4385 | 4385 | $sqlrank = "SELECT rowid, rang FROM ".$this->db->prefix()."product_association"; |
4386 | - $sqlrank.= " WHERE fk_product_pere = ".((int) $fk_parent); |
|
4387 | - $sqlrank.= " ORDER BY rang"; |
|
4386 | + $sqlrank .= " WHERE fk_product_pere = ".((int) $fk_parent); |
|
4387 | + $sqlrank .= " ORDER BY rang"; |
|
4388 | 4388 | $resqlrank = $this->db->query($sqlrank); |
4389 | 4389 | if ($resqlrank) { |
4390 | 4390 | $cpt = 0; |
4391 | 4391 | while ($objrank = $this->db->fetch_object($resqlrank)) { |
4392 | 4392 | $cpt++; |
4393 | 4393 | $sql = "UPDATE ".$this->db->prefix()."product_association"; |
4394 | - $sql.= " SET rang = ".((int) $cpt); |
|
4395 | - $sql.= " WHERE rowid = ".((int) $objrank->rowid); |
|
4396 | - if (! $this->db->query($sql)) { |
|
4394 | + $sql .= " SET rang = ".((int) $cpt); |
|
4395 | + $sql .= " WHERE rowid = ".((int) $objrank->rowid); |
|
4396 | + if (!$this->db->query($sql)) { |
|
4397 | 4397 | dol_print_error($this->db); |
4398 | 4398 | return -1; |
4399 | 4399 | } |
@@ -4814,7 +4814,7 @@ discard block |
||
4814 | 4814 | if (isset($this->sousprods) && is_array($this->sousprods)) { |
4815 | 4815 | foreach ($this->sousprods as $prod_name => $desc_product) { |
4816 | 4816 | if (is_array($desc_product)) { |
4817 | - $this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id, $ignore_stock_load); // This set $this->res |
|
4817 | + $this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id, $ignore_stock_load); // This set $this->res |
|
4818 | 4818 | } |
4819 | 4819 | } |
4820 | 4820 | } |
@@ -4969,9 +4969,9 @@ discard block |
||
4969 | 4969 | $sql .= " WHERE p.rowid = pa.fk_product_fils"; |
4970 | 4970 | $sql .= " AND pa.fk_product_pere = ".((int) $id); |
4971 | 4971 | $sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens |
4972 | - $sql.= " ORDER BY pa.rang"; |
|
4972 | + $sql .= " ORDER BY pa.rang"; |
|
4973 | 4973 | |
4974 | - dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.(is_array($parents)?implode(',', $parents):$parents), LOG_DEBUG); |
|
4974 | + dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level.' parents='.(is_array($parents) ?implode(',', $parents) : $parents), LOG_DEBUG); |
|
4975 | 4975 | |
4976 | 4976 | if ($level == 1) { |
4977 | 4977 | $alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly |
@@ -5061,38 +5061,38 @@ discard block |
||
5061 | 5061 | if (!empty($this->entity)) { |
5062 | 5062 | $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80, 0, 0, 0, 0, 1); |
5063 | 5063 | if ($this->nbphoto > 0) { |
5064 | - $datas['photo'] = '<div class="photointooltip floatright">'."\n" . $tmpphoto . '</div>'; |
|
5064 | + $datas['photo'] = '<div class="photointooltip floatright">'."\n".$tmpphoto.'</div>'; |
|
5065 | 5065 | } |
5066 | 5066 | } |
5067 | 5067 | |
5068 | 5068 | if ($this->type == Product::TYPE_PRODUCT) { |
5069 | 5069 | $datas['picto'] = img_picto('', 'product').' <u class="paddingrightonly">'.$langs->trans("Product").'</u>'; |
5070 | 5070 | } elseif ($this->type == Product::TYPE_SERVICE) { |
5071 | - $datas['picto']= img_picto('', 'service').' <u class="paddingrightonly">'.$langs->trans("Service").'</u>'; |
|
5071 | + $datas['picto'] = img_picto('', 'service').' <u class="paddingrightonly">'.$langs->trans("Service").'</u>'; |
|
5072 | 5072 | } |
5073 | 5073 | if (isset($this->status) && isset($this->status_buy)) { |
5074 | - $datas['status']= ' '.$this->getLibStatut(5, 0) . ' '.$this->getLibStatut(5, 1); |
|
5074 | + $datas['status'] = ' '.$this->getLibStatut(5, 0).' '.$this->getLibStatut(5, 1); |
|
5075 | 5075 | } |
5076 | 5076 | |
5077 | 5077 | if (!empty($this->ref)) { |
5078 | - $datas['ref']= '<br><b>'.$langs->trans('ProductRef').':</b> '.$this->ref; |
|
5078 | + $datas['ref'] = '<br><b>'.$langs->trans('ProductRef').':</b> '.$this->ref; |
|
5079 | 5079 | } |
5080 | 5080 | if (!empty($this->label)) { |
5081 | - $datas['label']= '<br><b>'.$langs->trans('ProductLabel').':</b> '.$this->label; |
|
5081 | + $datas['label'] = '<br><b>'.$langs->trans('ProductLabel').':</b> '.$this->label; |
|
5082 | 5082 | } |
5083 | 5083 | if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { |
5084 | 5084 | if (isModEnabled('productbatch')) { |
5085 | 5085 | $langs->load("productbatch"); |
5086 | - $datas['batchstatus']= "<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0, 2); |
|
5086 | + $datas['batchstatus'] = "<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0, 2); |
|
5087 | 5087 | } |
5088 | 5088 | } |
5089 | 5089 | if (isModEnabled('barcode')) { |
5090 | - $datas['barcode']= '<br><b>'.$langs->trans('BarCode').':</b> '.$this->barcode; |
|
5090 | + $datas['barcode'] = '<br><b>'.$langs->trans('BarCode').':</b> '.$this->barcode; |
|
5091 | 5091 | } |
5092 | 5092 | |
5093 | 5093 | if ($this->type == Product::TYPE_PRODUCT) { |
5094 | 5094 | if ($this->weight) { |
5095 | - $datas['weight']= "<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); |
|
5095 | + $datas['weight'] = "<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); |
|
5096 | 5096 | } |
5097 | 5097 | $labelsize = ""; |
5098 | 5098 | if ($this->length) { |
@@ -5105,7 +5105,7 @@ discard block |
||
5105 | 5105 | $labelsize .= ($labelsize ? " - " : "")."<b>".$langs->trans("Height").'</b>: '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); |
5106 | 5106 | } |
5107 | 5107 | if ($labelsize) { |
5108 | - $datas['size']= "<br>".$labelsize; |
|
5108 | + $datas['size'] = "<br>".$labelsize; |
|
5109 | 5109 | } |
5110 | 5110 | |
5111 | 5111 | $labelsurfacevolume = ""; |
@@ -5116,7 +5116,7 @@ discard block |
||
5116 | 5116 | $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."<b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); |
5117 | 5117 | } |
5118 | 5118 | if ($labelsurfacevolume) { |
5119 | - $datas['surface']= "<br>" . $labelsurfacevolume; |
|
5119 | + $datas['surface'] = "<br>".$labelsurfacevolume; |
|
5120 | 5120 | } |
5121 | 5121 | } |
5122 | 5122 | if (!empty($this->pmp) && $this->pmp) { |
@@ -5146,9 +5146,9 @@ discard block |
||
5146 | 5146 | } |
5147 | 5147 | // show categories for this record only in ajax to not overload lists |
5148 | 5148 | if (isModEnabled('categorie') && !$nofetch) { |
5149 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
5149 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
5150 | 5150 | $form = new Form($this->db); |
5151 | - $datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_PRODUCT, 1); |
|
5151 | + $datas['categories'] = '<br>'.$form->showCategories($this->id, Categorie::TYPE_PRODUCT, 1); |
|
5152 | 5152 | } |
5153 | 5153 | |
5154 | 5154 | return $datas; |
@@ -5200,7 +5200,7 @@ discard block |
||
5200 | 5200 | $label = $langs->trans("ShowProduct"); |
5201 | 5201 | $linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"'; |
5202 | 5202 | } |
5203 | - $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1, 1).'"' : ' title="tocomplete"'); |
|
5203 | + $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1, 1).'"' : ' title="tocomplete"'); |
|
5204 | 5204 | $linkclose .= $dataparams.' class="nowraponall '.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; |
5205 | 5205 | } else { |
5206 | 5206 | $linkclose = ' class="nowraponall'.($morecss ? ' '.$morecss : '').'"'; |
@@ -5377,7 +5377,7 @@ discard block |
||
5377 | 5377 | $labelStatus = ($status == 1 ? $langs->transnoentitiesnoconv('ProductStatusOnBatch') : $langs->transnoentitiesnoconv('ProductStatusOnSerial')); |
5378 | 5378 | $labelStatusShort = ($status == 1 ? $langs->transnoentitiesnoconv('ProductStatusOnBatchShort') : $langs->transnoentitiesnoconv('ProductStatusOnSerialShort')); |
5379 | 5379 | } |
5380 | - } elseif ( $type == 2 && $status == 2 ) { |
|
5380 | + } elseif ($type == 2 && $status == 2) { |
|
5381 | 5381 | $labelStatus = $langs->transnoentitiesnoconv('ProductStatusOnSerial'); |
5382 | 5382 | $labelStatusShort = $langs->transnoentitiesnoconv('ProductStatusOnSerialShort'); |
5383 | 5383 | } |
@@ -5587,7 +5587,7 @@ discard block |
||
5587 | 5587 | $sql .= " AND w.statut IN (".$this->db->sanitize(implode(',', $warehouseStatus)).")"; |
5588 | 5588 | } |
5589 | 5589 | |
5590 | - $sql .= " ORDER BY ps.reel ".(!empty($conf->global->DO_NOT_TRY_TO_DEFRAGMENT_STOCKS_WAREHOUSE)?'DESC':'ASC'); // Note : qty ASC is important for expedition card, to avoid stock fragmentation; |
|
5590 | + $sql .= " ORDER BY ps.reel ".(!empty($conf->global->DO_NOT_TRY_TO_DEFRAGMENT_STOCKS_WAREHOUSE) ? 'DESC' : 'ASC'); // Note : qty ASC is important for expedition card, to avoid stock fragmentation; |
|
5591 | 5591 | |
5592 | 5592 | dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); |
5593 | 5593 | $result = $this->db->query($sql); |
@@ -5668,7 +5668,7 @@ discard block |
||
5668 | 5668 | if (isModEnabled("supplier_order")) { |
5669 | 5669 | $filterStatus = empty($conf->global->SUPPLIER_ORDER_STATUS_FOR_VIRTUAL_STOCK) ? '3,4' : $conf->global->SUPPLIER_ORDER_STATUS_FOR_VIRTUAL_STOCK; |
5670 | 5670 | if (isset($includedraftpoforvirtual)) { |
5671 | - $filterStatus = '0,1,2,'.$filterStatus; // 1,2 may have already been inside $filterStatus but it is better to have twice than missing $filterStatus does not include them |
|
5671 | + $filterStatus = '0,1,2,'.$filterStatus; // 1,2 may have already been inside $filterStatus but it is better to have twice than missing $filterStatus does not include them |
|
5672 | 5672 | } |
5673 | 5673 | $result = $this->load_stats_commande_fournisseur(0, $filterStatus, 1, $dateofvirtualstock); |
5674 | 5674 | if ($result < 0) { |
@@ -6369,7 +6369,7 @@ discard block |
||
6369 | 6369 | global $langs; |
6370 | 6370 | |
6371 | 6371 | if (empty($this->duration_value)) { |
6372 | - $this->errors[]='ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice'; |
|
6372 | + $this->errors[] = 'ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice'; |
|
6373 | 6373 | return -1; |
6374 | 6374 | } |
6375 | 6375 | |
@@ -6406,7 +6406,7 @@ discard block |
||
6406 | 6406 | */ |
6407 | 6407 | public function getKanbanView($option = '', $arraydata = null) |
6408 | 6408 | { |
6409 | - global $langs,$conf; |
|
6409 | + global $langs, $conf; |
|
6410 | 6410 | |
6411 | 6411 | $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); |
6412 | 6412 | |
@@ -6445,7 +6445,7 @@ discard block |
||
6445 | 6445 | $return .= '<br><span class="info-box-status opacitymedium">'.$langs->trans('PhysicalStock').' : <span class="bold">'.$this->stock_reel.'</span></span>'; |
6446 | 6446 | } |
6447 | 6447 | if (method_exists($this, 'getLibStatut')) { |
6448 | - $return .='<br><span class="info-box-status margintoponly">'.$this->getLibStatut(3, 1).' '.$this->getLibStatut(3, 0).'</span>'; |
|
6448 | + $return .= '<br><span class="info-box-status margintoponly">'.$this->getLibStatut(3, 1).' '.$this->getLibStatut(3, 0).'</span>'; |
|
6449 | 6449 | } |
6450 | 6450 | $return .= '</div>'; |
6451 | 6451 | $return .= '</div>'; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $maxfilesizearray = getMaxFileSizeArray(); |
199 | 199 | $maxmin = $maxfilesizearray['maxmin']; |
200 | 200 | if ($maxmin > 0) { |
201 | - $texte .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file |
|
201 | + $texte .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file |
|
202 | 202 | } |
203 | 203 | $texte .= ' <input type="file" name="uploadfile">'; |
204 | 204 | $texte .= '<input type="hidden" value="USERGROUP_ADDON_PDF_ODT_PATH" name="keyforuploaddir">'; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); |
288 | 288 | $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); |
289 | 289 | |
290 | - $newfiletmp = $objectref . '_' . $newfiletmp; |
|
290 | + $newfiletmp = $objectref.'_'.$newfiletmp; |
|
291 | 291 | |
292 | 292 | // Get extension (ods or odt) |
293 | 293 | $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | if ($format == '1') { |
297 | 297 | $format = '%Y%m%d%H%M%S'; |
298 | 298 | } |
299 | - $filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat; |
|
299 | + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; |
|
300 | 300 | } else { |
301 | - $filename = $newfiletmp . '.' . $newfileformat; |
|
301 | + $filename = $newfiletmp.'.'.$newfileformat; |
|
302 | 302 | } |
303 | - $file = $dir . '/' . $filename; |
|
303 | + $file = $dir.'/'.$filename; |
|
304 | 304 | //print "newdir=".$dir; |
305 | 305 | //print "newfile=".$newfile; |
306 | 306 | //print "file=".$file; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | dol_mkdir($conf->user->dir_temp); |
310 | 310 | if (!is_writable($conf->user->dir_temp)) { |
311 | 311 | $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->user->dir_temp); |
312 | - dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); |
|
312 | + dol_syslog('Error in write_file: '.$this->error, LOG_ERR); |
|
313 | 313 | return -1; |
314 | 314 | } |
315 | 315 |
@@ -31,9 +31,9 @@ |
||
31 | 31 | if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) { |
32 | 32 | if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To discard case when id is list of ids like '1,2,3...' |
33 | 33 | if ($object->element == 'usergroup') { |
34 | - $ret = $object->fetch($id, (empty($ref)? '' : $ref), true); // to load $object->members |
|
34 | + $ret = $object->fetch($id, (empty($ref) ? '' : $ref), true); // to load $object->members |
|
35 | 35 | } else { |
36 | - $ret = $object->fetch($id, (empty($ref)? '' : $ref)); |
|
36 | + $ret = $object->fetch($id, (empty($ref) ? '' : $ref)); |
|
37 | 37 | } |
38 | 38 | if ($ret > 0) { |
39 | 39 | $object->fetch_thirdparty(); |