Fix GETPOST use should be avoid in classes

This commit is contained in:
Laurent Destailleur 2024-02-02 23:46:12 +01:00
parent 97006d6945
commit 1d6cbe1fda
39 changed files with 135 additions and 83 deletions

View File

@ -471,7 +471,7 @@ class Boms extends DolibarrApi
throw new RestException(500, 'Line to delete (rowid: '.$lineid.') is not a line of BOM (id: '.$this->bom->id.')');
}
$updateRes = $this->bom->deleteline(DolibarrApiAccess::$user, $lineid);
$updateRes = $this->bom->deleteLine(DolibarrApiAccess::$user, $lineid);
if ($updateRes > 0) {
return $this->get($id);
} else {

View File

@ -258,7 +258,7 @@ if (empty($reshook)) {
}
} elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) {
// Remove line
$result = $object->deleteline($lineid);
$result = $object->deleteLine($lineid);
// reorder lines
if ($result > 0) {
$object->line_order(true);

View File

@ -567,7 +567,7 @@ class Proposals extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$updateRes = $this->propal->deleteline($lineid, $id);
$updateRes = $this->propal->deleteLine($lineid, $id);
if ($updateRes > 0) {
return $this->get($id);
} else {

View File

@ -1016,7 +1016,7 @@ class Propal extends CommonObject
* @param int $id Id of object (for a check)
* @return int >0 if OK, <0 if KO
*/
public function deleteline($lineid, $id = 0)
public function deleteLine($lineid, $id = 0)
{
global $user;

View File

@ -233,7 +233,7 @@ if (empty($reshook)) {
}
} elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) {
// Remove a product line
$result = $object->deleteline($user, $lineid);
$result = $object->deleteLine($user, $lineid);
if ($result > 0) {
// reorder lines
$object->line_order(true);

View File

@ -485,7 +485,7 @@ class Orders extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid, $id);
$updateRes = $this->commande->deleteLine(DolibarrApiAccess::$user, $lineid, $id);
if ($updateRes > 0) {
return $this->get($id);
} else {

View File

@ -2392,7 +2392,7 @@ class Commande extends CommonOrder
* @param int $id Id of object (for a check)
* @return int >0 if OK, 0 if nothing to do, <0 if KO
*/
public function deleteline($user = null, $lineid = 0, $id = 0)
public function deleteLine($user = null, $lineid = 0, $id = 0)
{
if ($this->statut == self::STATUS_DRAFT) {
$this->db->begin();

View File

@ -276,7 +276,7 @@ if (empty($reshook)) {
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline(GETPOST('lineid', 'int'));
$result = $object->deleteLine(GETPOST('lineid', 'int'));
if ($result > 0) {
// reorder lines
$object->line_order(true);

View File

@ -623,7 +623,7 @@ class Invoices extends DolibarrApi
throw new RestException(404, 'Invoice not found');
}
$updateRes = $this->invoice->deleteline($lineid, $id);
$updateRes = $this->invoice->deleteLine($lineid, $id);
if ($updateRes > 0) {
return $this->get($id);
} else {

View File

@ -539,7 +539,7 @@ class Facture extends CommonInvoice
}
$this->entity = $_facrec->entity; // Invoice created in same entity than template
// Fields coming from GUI (priority on template).
// Fields coming from GUI.
// @TODO Value of template should be used as default value on the form on the GUI, and we should here always use the value from GUI
// set by posted page wth $object->xxx = ... and this section should be removed.
$this->fk_project = GETPOST('projectid', 'int') > 0 ? GETPOSTINT('projectid') : $_facrec->fk_project;
@ -4353,7 +4353,7 @@ class Facture extends CommonInvoice
* @param int $id Id of object (for a check)
* @return int Return integer <0 if KO, >0 if OK
*/
public function deleteline($rowid, $id = 0)
public function deleteLine($rowid, $id = 0)
{
global $user;

View File

@ -822,7 +822,7 @@ if (empty($reshook)) {
$db->rollback();
}
} elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) {
$result = $object->deleteline(GETPOST('lineid', 'int'), $user);
$result = $object->deleteLine(GETPOST('lineid', 'int'), $user);
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);

View File

@ -469,7 +469,7 @@ class Contracts extends DolibarrApi
// TODO Check the lineid $lineid is a line of object
$updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user);
$updateRes = $this->contract->deleteLine($lineid, DolibarrApiAccess::$user);
if ($updateRes > 0) {
return $this->get($id);
} else {

View File

@ -1886,10 +1886,8 @@ class Contrat extends CommonObject
* @param User $user User that delete
* @return int >0 if OK, <0 if KO
*/
public function deleteline($idline, User $user)
public function deleteLine($idline, User $user)
{
global $conf, $langs;
$error = 0;
if ($this->statut >= 0) {

View File

@ -56,6 +56,7 @@ if ($cancel) {
// Action to add record
if ($action == 'add' && !empty($permissiontoadd)) {
foreach ($object->fields as $key => $val) {
// Ignore special cases
if ($object->fields[$key]['type'] == 'duration') {
if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') {
continue; // The field was not submitted to be saved
@ -65,6 +66,7 @@ if ($action == 'add' && !empty($permissiontoadd)) {
continue; // The field was not submitted to be saved
}
}
// Ignore special fields
if (in_array($key, array('rowid', 'entity', 'import_key'))) {
continue;
@ -149,6 +151,12 @@ if ($action == 'add' && !empty($permissiontoadd)) {
}
}
// Special field
$model_pdf = GETPOST('model');
if (!empty($model_pdf) && property_exists($this, 'model_pdf')) {
$object->model_pdf = $model_pdf;
}
// Fill array 'array_options' with data from add form
if (!$error) {
$ret = $extrafields->setOptionalsFromPost(null, $object, '', 1);
@ -422,11 +430,13 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) {
// Remove a line
if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) {
if (method_exists($object, 'deleteline')) {
$result = $object->deleteline($user, $lineid); // For backward compatibility
if (!empty($object->element) && $object->element == 'mo') {
$fk_movement = GETPOSTINT('fk_movement');
$result = $object->deleteLine($user, $lineid, 0, $fk_movement);
} else {
$result = $object->deleteLine($user, $lineid);
}
if ($result > 0) {
// Define output language
$outputlangs = $langs;

View File

@ -657,7 +657,7 @@ class Delivery extends CommonObject
* @param int $lineid Line id
* @return integer Return integer <0 if KO, 0 if nothing done, >0 if OK
*/
public function deleteline($lineid)
public function deleteLine($lineid)
{
if ($this->statut == 0) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";

View File

@ -408,7 +408,7 @@ class Shipments extends DolibarrApi
// TODO Check the lineid $lineid is a line of object
$updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid);
$updateRes = $this->shipment->deleteLine(DolibarrApiAccess::$user, $lineid);
if ($updateRes > 0) {
return $this->get($id);
} else {

View File

@ -1769,7 +1769,7 @@ class Expedition extends CommonObject
* @param int $lineid Id of line to delete
* @return int >0 if OK, <0 if KO
*/
public function deleteline($user, $lineid)
public function deleteLine($user, $lineid)
{
global $user;

View File

@ -1247,7 +1247,7 @@ if (empty($reshook)) {
$total_ht = $object_ligne->total_ht;
$total_tva = $object_ligne->total_tva;
$result = $object->deleteline(GETPOST("rowid", 'int'), $user);
$result = $object->deleteLine(GETPOST("rowid", 'int'), $user);
if ($result >= 0) {
if ($result > 0) {
// Define output language

View File

@ -386,7 +386,7 @@ class ExpenseReports extends DolibarrApi
// TODO Check the lineid $lineid is a line of object
$updateRes = $this->expensereport->deleteline($lineid);
$updateRes = $this->expensereport->deleteLine($lineid);
if ($updateRes == 1) {
return $this->get($id);
}

View File

@ -2291,7 +2291,7 @@ class ExpenseReport extends CommonObject
* @param int $notrigger 1=No trigger
* @return int Return integer <0 if KO, >0 if OK
*/
public function deleteline($rowid, $fuser = '', $notrigger = 0)
public function deleteLine($rowid, $fuser = '', $notrigger = 0)
{
$error=0;

View File

@ -663,7 +663,7 @@ if (empty($reshook)) {
dol_print_error($db);
exit;
}
$result = $objectline->deleteline($user);
$result = $objectline->deleteLine($user);
if ($object->fetch($objectline->fk_fichinter) <= 0) {
dol_print_error($db);

View File

@ -1907,7 +1907,7 @@ class FichinterLigne extends CommonObjectLine
* @param int $notrigger Disable all triggers
* @return int >0 if ok, <0 if ko
*/
public function deleteline($user, $notrigger = 0)
public function deleteLine($user, $notrigger = 0)
{
$error = 0;

View File

@ -702,7 +702,7 @@ class SupplierInvoices extends DolibarrApi
// TODO Check the lineid $lineid is a line of object
$updateRes = $this->invoice->deleteline($lineid);
$updateRes = $this->invoice->deleteLine($lineid);
if ($updateRes > 0) {
return $this->get($id);
} else {

View File

@ -2315,7 +2315,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $notrigger 1=Disable call to triggers
* @return int Return integer <0 if KO, >0 if OK
*/
public function deleteline($idline, $notrigger = 0)
public function deleteLine($idline, $notrigger = 0)
{
if ($this->statut == 0) {
$line = new CommandeFournisseurLigne($this->db);
@ -3568,7 +3568,7 @@ class CommandeFournisseur extends CommonOrder
if (count($diff_array) == 0 && count($keysinwishednotindelivered) == 0 && count($keysindeliverednotinwished) == 0) { //No diff => mean everything is received
if ($closeopenorder) {
//$ret=$this->setStatus($user,5);
$ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
$ret = $this->Livraison($user, $date_liv, 'tot', $comment); // $type is 'tot', 'par', 'nev', 'can'
if ($ret < 0) {
return -1;
}
@ -3576,7 +3576,7 @@ class CommandeFournisseur extends CommonOrder
} else {
//Diff => received partially
//$ret=$this->setStatus($user,4);
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can'
if ($ret < 0) {
return -1;
}
@ -3603,14 +3603,14 @@ class CommandeFournisseur extends CommonOrder
if ($close == count($diff_array)) {
//all the products are received equal or more than the wished quantity
if ($closeopenorder) {
$ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
$ret = $this->Livraison($user, $date_liv, 'tot', $comment); // $type is 'tot', 'par', 'nev', 'can'
if ($ret < 0) {
return -1;
}
return 5;
} else {
//Diff => received partially
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can'
if ($ret < 0) {
return -1;
}
@ -3618,7 +3618,7 @@ class CommandeFournisseur extends CommonOrder
}
} else {
//all the products are not received
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can'
if ($ret < 0) {
return -1;
}
@ -3626,7 +3626,7 @@ class CommandeFournisseur extends CommonOrder
}
} else {
//Diff => received partially
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // $type is 'tot', 'par', 'nev', 'can'
if ($ret < 0) {
return -1;
}

View File

@ -429,7 +429,9 @@ class FactureFournisseur extends CommonInvoice
$this->entity = $_facrec->entity; // Invoice created in same entity than template
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
// Fields coming from GUI
// @TODO Value of template should be used as default value on the form on the GUI, and we should here always use the value from GUI
// set by posted page wth $object->xxx = ... and this section should be removed.
$this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project;
$this->note_public = GETPOST('note_public', 'restricthtml') ? GETPOST('note_public', 'restricthtml') : $_facrec->note_public;
$this->note_private = GETPOST('note_private', 'restricthtml') ? GETPOST('note_private', 'restricthtml') : $_facrec->note_private;
@ -2489,7 +2491,7 @@ class FactureFournisseur extends CommonInvoice
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int Return integer <0 if KO, >0 if OK
*/
public function deleteline($rowid, $notrigger = 0)
public function deleteLine($rowid, $notrigger = 0)
{
if (!$rowid) {
$rowid = $this->id;

View File

@ -888,7 +888,7 @@ if (empty($reshook)) {
if ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) {
$db->begin();
$result = $object->deleteline($lineid);
$result = $object->deleteLine($lineid);
if ($result > 0) {
// reorder lines
$object->line_order(true);

View File

@ -309,7 +309,7 @@ if (empty($reshook)) {
}
} elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) {
// Remove a product line
$result = $object->deleteline($lineid);
$result = $object->deleteLine($lineid);
if ($result > 0) {
// reorder lines
$object->line_order(true);

View File

@ -18,7 +18,7 @@
*/
/**
* \file class/mo.class.php
* \file mrp/class/mo.class.php
* \ingroup mrp
* \brief This file is a CRUD class file for Mo (Create/Read/Update/Delete)
*/
@ -27,6 +27,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
/**
* Class for Mo
*/
@ -877,12 +878,13 @@ class Mo extends CommonObject
/**
* Delete a line of object in database
*
* @param User $user User that delete
* @param int $idline Id of line to delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int >0 if OK, <0 if KO
* @param User $user User that delete
* @param int $idline Id of line to delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @param int $fk_movement Movement
* @return int Return >0 if OK, <0 if KO
*/
public function deleteLine(User $user, $idline, $notrigger = 0)
public function deleteLine(User $user, $idline, $notrigger = 0, $fk_movement = 0)
{
global $langs;
$langs->loadLangs(array('stocks', 'mrp'));
@ -892,7 +894,6 @@ class Mo extends CommonObject
return -2;
}
$productstatic = new Product($this->db);
$fk_movement = GETPOST('fk_movement', 'int');
$arrayoflines = $this->fetchLinesLinked('consumed', $idline);
if (!empty($arrayoflines)) {

View File

@ -599,13 +599,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Fields title search
print '<tr class="liste_titre_filter">';
// Actions
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
}
if (!empty($arrayfields['m.rowid']['checked'])) {
// Ref
print '<td class="liste_titre left">';
@ -733,16 +741,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>';
}
// Actions
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
}
print "</tr>\n";
$totalarray = array();
$totalarray['nbfield'] = 0;
print '<tr class="liste_titre">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['m.rowid']['checked'])) {
print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
@ -824,8 +839,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
$totalarray['nbfield']++;
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
$totalarray['nbfield']++;
}
print "</tr>\n";
$i = 0;
@ -884,6 +902,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
print '<tr class="oddeven">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($objp->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Id movement
if (!empty($arrayfields['m.rowid']['checked'])) {
// This is primary not movement id
@ -992,17 +1025,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>';
}
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($objp->rowid, $arrayofselected)) {
$selected = 1;
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($objp->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n";

View File

@ -117,7 +117,7 @@ if ($reshook < 0) {
if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/mrp/mo_list.php', 1);
$backurlforlist = DOL_URL_ROOT.'/mrp/mo_list.php';
if (empty($backtopage) || ($cancel && empty($id))) {
//var_dump($backurlforlist);exit;
@ -133,7 +133,7 @@ if (empty($reshook)) {
$also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0);
$result = $object->cancel($user, 0, $also_cancel_consumed_and_produced_lines);
if ($result > 0) {
header("Location: " . dol_buildpath('/mrp/mo_card.php?id=' . $object->id, 1));
header("Location: " . DOL_URL_ROOT.'/mrp/mo_card.php?id=' . $object->id);
exit;
} else {
$action = '';

View File

@ -233,10 +233,6 @@ class StockTransfer extends CommonObject
*/
public function create(User $user, $notrigger = 0)
{
$model_pdf = GETPOST('model');
if (!empty($model_pdf)) {
$this->model_pdf = $model_pdf;
}
$this->status = (int) $this->status;
if ($this->fk_warehouse_source <= 0) {
$this->fk_warehouse_source = 0;

View File

@ -449,7 +449,7 @@ class StockTransferLine extends CommonObjectLine
$direction, // 1=décrémentation
$label,
empty($direction) ? $this->pmp : 0,
GETPOST('inventorycode', 'alphanohtml'),
$code_inv,
'stocktransfer',
$this->fk_stocktransfer
);*/
@ -492,7 +492,7 @@ class StockTransferLine extends CommonObjectLine
$dlc,
$dluo,
$this->batch,
GETPOST("codemove")
$code_inv
);*/
$result = $movementstock->_create(

View File

@ -403,7 +403,7 @@ class Receptions extends DolibarrApi
// TODO Check the lineid $lineid is a line of object
$updateRes = $this->reception->deleteline(DolibarrApiAccess::$user, $lineid);
$updateRes = $this->reception->deleteLine(DolibarrApiAccess::$user, $lineid);
if ($updateRes < 0) {
throw new RestException(405, $this->reception->error);
}

View File

@ -4897,7 +4897,7 @@ class Societe extends CommonObject
/**
* Create a document onto disk according to template module.
*
* @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example.
* @param string $modele Generator to use. Caller must set it to obj->model_pdf.
* @param Translate $outputlangs object lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description

View File

@ -197,7 +197,7 @@ if (empty($reshook)) {
}
} elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) {
// Remove line
$result = $object->deleteline($lineid);
$result = $object->deleteLine($lineid);
// reorder lines
if ($result > 0) {
$object->line_order(true);

View File

@ -843,7 +843,7 @@ class SupplierProposal extends CommonObject
* @param int $lineid Id of line to delete
* @return int >0 if OK, <0 if KO
*/
public function deleteline($lineid)
public function deleteLine($lineid)
{
global $user;

View File

@ -747,14 +747,14 @@ if (empty($reshook)) {
}*/
if ($idline > 0 && $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected.
$invoice->deleteline($idline);
$invoice->deleteLine($idline);
$invoice->fetch($placeid);
} elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC";
$resql = $db->query($sql);
$row = $db->fetch_array($resql);
$deletelineid = $row[0];
$invoice->deleteline($deletelineid);
$invoice->deleteLine($deletelineid);
$invoice->fetch($placeid);
}
@ -781,7 +781,7 @@ if (empty($reshook)) {
// We delete the lines
$resdeletelines = 1;
foreach ($invoice->lines as $line) {
$tmpres = $invoice->deleteline($line->id);
$tmpres = $invoice->deleteLine($line->id);
if ($tmpres < 0) {
$resdeletelines = 0;
break;

View File

@ -132,7 +132,7 @@ class Context
$this->controller = 'default';
}
$this->appliName = !empty($conf->global->WEBPORTAL_TITLE) ? $conf->global->WEBPORTAL_TITLE : $conf->global->MAIN_INFO_SOCIETE_NOM;
$this->appliName = getDolGlobalString('WEBPORTAL_TITLE', getDolGlobalString('MAIN_INFO_SOCIETE_NOM'));
//$this->generateNewToken();

View File

@ -242,22 +242,32 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
'core/class/html.formsms.class.php',
'core/class/html.formticket.class.php',
'core/class/utils.class.php',
'fourn/class/fournisseur.facture.class.php',
'societe/canvas/actions_card_common.class.php',
'societe/canvas/individual/actions_card_individual.class.php',
'ticket/class/actions_ticket.class.php',
'ticket/class/ticket.class.php',
'webportal/class/context.class.php',
'webportal/class/html.formcardwebportal.class.php',
'webportal/class/html.formlistwebportal.class.php',
'webportal/controllers/document.controller.class.php',
'workstation/class/workstation.class.php',
))) {
// Must not find GETPOST
$ok=true;
$matches=array();
$ok = true;
$matches = array();
// Check string GETPOSTFLOAT a class.php file (should not be found into classes)
preg_match_all('/GETPOST\(["\'](....)/', $filecontent, $matches, PREG_SET_ORDER);
foreach ($matches as $key => $val) {
if (in_array($val[1], array('lang', 'forc'))) {
if (in_array($val[1], array('lang', 'forc', 'mass', 'conf'))) {
continue;
}
//var_dump($val);
$ok=false;
$ok = false;
break;
}
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
//$this->assertTrue($ok, 'Found string GETPOST into a .class.php file in '.$file['relativename'].'.');
$this->assertTrue($ok, 'Found string GETPOST into a .class.php file in '.$file['relativename'].'.');
}
} else {
// Check into Include files