From 174ddc5fd49fa219ea9bf48496b06facb59f2b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 May 2020 21:07:47 +0200 Subject: [PATCH] prepare new rule --- htdocs/admin/propal.php | 51 ++-- htdocs/comm/action/class/actioncomm.class.php | 3 +- htdocs/comm/action/index.php | 6 +- htdocs/comm/action/peruser.php | 3 +- htdocs/comm/mailing/card.php | 6 +- htdocs/comm/propal/card.php | 118 +++------ htdocs/comm/propal/class/propal.class.php | 3 +- htdocs/comm/propal/contact.php | 8 +- htdocs/compta/bank/bankentries_list.php | 3 +- htdocs/compta/bank/card.php | 3 +- htdocs/compta/deplacement/card.php | 12 +- htdocs/compta/facture/card-rec.php | 48 ++-- htdocs/compta/facture/card.php | 85 ++----- htdocs/compta/facture/contact.php | 8 +- htdocs/compta/paiement/cheque/card.php | 4 +- htdocs/core/lib/files.lib.php | 239 +++++------------- htdocs/core/lib/functions.lib.php | 30 +-- htdocs/core/lib/functions2.lib.php | 6 +- htdocs/core/lib/memory.lib.php | 6 +- htdocs/core/lib/security.lib.php | 18 +- htdocs/core/lib/website2.lib.php | 3 +- htdocs/fourn/commande/dispatch.php | 10 +- htdocs/fourn/facture/card.php | 6 +- htdocs/main.inc.php | 20 +- htdocs/product/card.php | 5 +- htdocs/product/class/product.class.php | 31 +-- 26 files changed, 223 insertions(+), 512 deletions(-) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 9cde0e81e56..4855a164412 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -52,8 +52,7 @@ $type = 'propal'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $error = 0; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconstpropal = GETPOST('maskconstpropal', 'alpha'); $maskpropal = GETPOST('maskpropal', 'alpha'); if ($maskconstpropal) $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity); @@ -66,8 +65,7 @@ if ($action == 'updateMask') } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') -{ +} elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); $propal = new Propal($db); @@ -87,8 +85,7 @@ if ($action == 'updateMask') } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); @@ -105,8 +102,7 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} elseif ($action == 'setribchq') -{ +} elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); $chq = GETPOST('chq', 'alpha'); @@ -121,8 +117,7 @@ if ($action == 'updateMask') } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') -{ +} elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') { $draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "PROPALE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); @@ -134,8 +129,7 @@ if ($action == 'updateMask') } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_PROPOSAL_FREE_TEXT') -{ +} elseif ($action == 'set_PROPOSAL_FREE_TEXT') { $freetext = GETPOST('PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); @@ -148,8 +142,7 @@ if ($action == 'updateMask') } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'setdefaultduration') -{ +} elseif ($action == 'setdefaultduration') { $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; @@ -160,45 +153,35 @@ if ($action == 'updateMask') } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') -{ +} elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); } -} elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { $conf->global->PROPALE_ADDON_PDF = $value; } // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index bb1da4d852a..2cda34a494b 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1995,8 +1995,7 @@ class ActionComm extends CommonObject { $this->db->commit(); return 1; - } - else { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index b83a374d1a3..8b852689b99 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1137,8 +1137,7 @@ if (empty($action) || $action == 'show_month') // View by month echo ' '; show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " \n"; - } - /* Show days of the current month */ + } /* Show days of the current month */ elseif ($tmpday <= $max_day_in_month) { $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); @@ -1152,8 +1151,7 @@ if (empty($action) || $action == 'show_month') // View by month echo ' '; show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " \n"; - } - /* Show days after the current month (next month) */ + } /* Show days after the current month (next month) */ else { $style = 'cal_other_month'; if ($iter_day == 6) $style .= ' cal_other_month_right'; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index dfb756dd227..f76503ddc2b 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -700,8 +700,7 @@ while ($currentdaytoshow < $lastdaytoshow) { } } } - } - /* Use this list to have for all users */ + } /* Use this list to have for all users */ else { $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index fff6140a2aa..ea81c4e35b9 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -764,13 +764,11 @@ if ($action == 'create') if ($action == 'valid') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1); - } - // Confirm reset + } // Confirm reset elseif ($action == 'reset') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2); - } - // Confirm delete + } // Confirm delete elseif ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a2d27943c89..ae2eeda82ef 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -202,9 +202,7 @@ if (empty($reshook)) } } } - } - - // Delete proposal + } // Delete proposal elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { $result = $object->delete($user); @@ -215,9 +213,7 @@ if (empty($reshook)) $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Remove line + } // Remove line elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $result = $object->deleteline($lineid); @@ -239,9 +235,7 @@ if (empty($reshook)) header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); - } - - // Validation + } // Validation elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { $result = $object->valid($user); @@ -291,9 +285,7 @@ if (empty($reshook)) $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); if ($result < 0) dol_print_error($db, $object->error); - } - - // Positionne ref client + } // Positionne ref client elseif ($action == 'setref_client' && $usercancreate) { $result = $object->set_ref_client($user, GETPOST('ref_client')); @@ -301,15 +293,11 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Set incoterm + } // Set incoterm elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled) && $usercancreate) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } - - // Create proposal + } // Create proposal elseif ($action == 'add' && $usercancreate) { $object->socid = $socid; @@ -543,7 +531,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } // Standard creation + } // Standard creation else { $id = $object->create($user); } @@ -606,9 +594,7 @@ if (empty($reshook)) } } } - } - - // Classify billed + } // Classify billed elseif ($action == 'classifybilled' && $usercanclose) { $db->begin(); @@ -626,9 +612,7 @@ if (empty($reshook)) } else { $db->rollback(); } - } - - // Close proposal + } // Close proposal elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) { if (!(GETPOST('statut', 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); @@ -654,9 +638,7 @@ if (empty($reshook)) } } } - } - - // Reopen proposal + } // Reopen proposal elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { // prevent browser refresh from reopening proposal several times if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) @@ -677,9 +659,7 @@ if (empty($reshook)) $db->rollback(); } } - } - - // add lines from objectlinked + } // add lines from objectlinked elseif ($action == 'import_lines_from_object' && $user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT @@ -795,9 +775,7 @@ if (empty($reshook)) } } } - } - - // Add line + } // Add line elseif ($action == 'addline' && $usercancreate) { // Set if we used free entry or predefined product $predef = ''; @@ -901,8 +879,7 @@ if (empty($reshook)) if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } - } - // If price per customer + } // If price per customer elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; @@ -924,8 +901,7 @@ if (empty($reshook)) if (empty($tva_tx)) $tva_npr = 0; } } - } - // If price per quantity + } // If price per quantity elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity @@ -948,8 +924,7 @@ if (empty($reshook)) break; } } - } - // If price per quantity and customer + } // If price per quantity and customer elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity @@ -981,8 +956,7 @@ if (empty($reshook)) if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { if ($price_base_type != 'HT') { @@ -1153,9 +1127,7 @@ if (empty($reshook)) } } } - } - - // Update a line within proposal + } // Update a line within proposal elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { // Define info_bits @@ -1295,48 +1267,32 @@ if (empty($reshook)) } elseif ($action == 'classin' && $usercancreate) { // Set project $object->setProject(GETPOST('projectid', 'int')); - } - - // Delivery time + } // Delivery time elseif ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id', 'int')); - } - - // Origin of the commercial proposal + } // Origin of the commercial proposal elseif ($action == 'setdemandreason' && $usercancreate) { $result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int')); - } - - // Terms of payment + } // Terms of payment elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise_percent($user, $_POST['remise_percent']); } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); - } - - // Payment choice + } // Payment choice elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } - - // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate + } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); - } - - // bank account + } // bank account elseif ($action == 'setbankaccount' && $usercancreate) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } - - // shipping method + } // shipping method elseif ($action == 'setshippingmethod' && $usercancreate) { $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); } elseif ($action == 'update_extras') { @@ -1377,18 +1333,14 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Toggle the status of a contact + } // Toggle the status of a contact elseif ($action == 'swapstatut') { if ($object->fetch($id) > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } - } - - // Delete a contact + } // Delete a contact elseif ($action == 'deletecontact') { $object->fetch($id); $result = $object->delete_contact($lineid); @@ -1871,24 +1823,16 @@ if ($action == 'create') } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); - } - - // Confirm delete + } // Confirm delete elseif ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); - } - - // Confirm reopen + } // Confirm reopen elseif ($action == 'reopen') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); - } - - // Confirmation delete product/service line + } // Confirmation delete product/service line elseif ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); - } - - // Confirm validate proposal + } // Confirm validate proposal elseif ($action == 'validate') { $error = 0; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5a8ddc31982..63e3864245b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2823,8 +2823,7 @@ class Propal extends CommonObject if ($objecttype == 'facture') { $linkedInvoices[] = $object; - } - // Cas des factures liees par un autre objet (ex: commande) + } // Cas des factures liees par un autre objet (ex: commande) else { $this->fetchObjectLinked($object, $objecttype); foreach ($this->linkedObjectsIds as $subobjecttype => $subobjectid) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index da23b4fc2bc..c2f60516f1c 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -95,18 +95,14 @@ if ($action == 'addcontact' && $user->rights->propale->creer) setEventMessages($object->error, $object->errors, 'errors'); } } -} - -// Toggle the status of a contact +} // Toggle the status of a contact elseif ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } -} - -// Deletes a contact +} // Deletes a contact elseif ($action == 'deletecontact' && $user->rights->propale->creer) { $result = $object->delete_contact($lineid); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index c5ded35cb51..0af1f84d9f6 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1020,8 +1020,7 @@ if ($resql) if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount); - } - // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show + } // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show else { $balance = $objforbalance->previoustotal; } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 3771d010f4f..9459df7579f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -553,8 +553,7 @@ if ($action == 'create') print ''; print ''; -} -/* ************************************************************************** */ +} /* ************************************************************************** */ /* */ /* Visu et edition */ /* */ diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index d2fd1c54cce..4d3ec6b1ee6 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -148,9 +148,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) header("Location: index.php"); exit; } -} - -// Update record +} // Update record elseif ($action == 'update' && $user->rights->deplacement->creer) { if (!GETPOST('cancel', 'alpha')) @@ -178,17 +176,13 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } -} - -// Set into a project +} // Set into a project elseif ($action == 'classin' && $user->rights->deplacement->creer) { $object->fetch($id); $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) dol_print_error($db, $object->error); -} - -// Set fields +} // Set fields elseif ($action == 'setdated' && $user->rights->deplacement->creer) { $dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index a0d09a11980..cc3a0769e70 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -275,18 +275,15 @@ if (empty($reshook)) if ($action == 'setconditions' && $user->rights->facture->creer) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - } - // Set mode + } // Set mode elseif ($action == 'setmode' && $user->rights->facture->creer) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } - // Set project + } // Set project elseif ($action == 'classin' && $user->rights->facture->creer) { $object->setProject(GETPOST('projectid', 'int')); - } - // Set bank account + } // Set bank account elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; @@ -297,45 +294,36 @@ if (empty($reshook)) $object->title = GETPOST('ref', 'alpha'); $object->ref = $object->title; } else dol_print_error($db, $object->error, $object->errors); - } - // Set bank account + } // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } - // Set frequency and unit frequency + } // Set frequency and unit frequency elseif ($action == 'setfrequency' && $user->rights->facture->creer) { $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); - } - // Set next date of execution + } // Set next date of execution elseif ($action == 'setdate_when' && $user->rights->facture->creer) { $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); if (!empty($date)) $object->setNextDate($date); - } - // Set max period + } // Set max period elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) { $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); - } - // Set auto validate + } // Set auto validate elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { $object->setAutoValidate(GETPOST('auto_validate', 'int')); - } - // Set generate pdf + } // Set generate pdf elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); - } - // Set model pdf + } // Set model pdf elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) { $object->setModelpdf(GETPOST('modelpdf', 'alpha')); - } - - // Set status disabled + } // Set status disabled elseif ($action == 'disable' && $user->rights->facture->creer) { $db->begin(); @@ -355,9 +343,7 @@ if (empty($reshook)) $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Set status enabled + } // Set status enabled elseif ($action == 'enable' && $user->rights->facture->creer) { $db->begin(); @@ -377,13 +363,10 @@ if (empty($reshook)) $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } - // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate + } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); } @@ -554,8 +537,7 @@ if (empty($reshook)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ac961e2df6a..60bd255da20 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -188,9 +188,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } - } - - // Change status of invoice + } // Change status of invoice elseif ($action == 'reopen' && $usercancreate) { $result = $object->fetch($id); @@ -203,9 +201,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Delete invoice + } // Delete invoice elseif ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->fetch($id); $object->fetch_thirdparty(); @@ -233,9 +229,7 @@ if (empty($reshook)) $action = ''; } } - } - - // Delete line + } // Delete line elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); @@ -267,17 +261,13 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } - } - - // Delete link of credit note to invoice + } // Delete link of credit note to invoice elseif ($action == 'unlinkdiscount' && $usercancreate) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(GETPOST("discountid")); $discount->unlink_invoice(); - } - - // Validation + } // Validation elseif ($action == 'valid' && $usercancreate) { $object->fetch($id); @@ -377,15 +367,10 @@ if (empty($reshook)) $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } - - - // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } - - // Multicurrency rate + } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); } elseif ($action == 'setinvoicedate' && $usercancreate) @@ -472,15 +457,11 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Set incoterm + } // Set incoterm elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } - - // bank account + } // bank account elseif ($action == 'setbankaccount' && $usercancreate) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); @@ -552,9 +533,7 @@ if (empty($reshook)) { $object->fetch($id); $object->set_ref_client(GETPOST('ref_client')); - } - - // Classify to validated + } // Classify to validated elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse', 'int'); @@ -668,9 +647,7 @@ if (empty($reshook)) else setEventMessages($object->error, $object->errors, 'errors'); } } - } - - // Go back to draft status (unvalidate) + } // Go back to draft status (unvalidate) elseif ($action == 'confirm_modif' && $usercanunvalidate) { $idwarehouse = GETPOST('idwarehouse', 'int'); @@ -751,9 +728,7 @@ if (empty($reshook)) } } } - } - - // Classify "paid" + } // Classify "paid" elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment) { $object->fetch($id); @@ -782,9 +757,7 @@ if (empty($reshook)) } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); } - } - - // Convertir en reduc + } // Convertir en reduc elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); @@ -949,9 +922,7 @@ if (empty($reshook)) $db->rollback(); } } - } - - // Delete payment + } // Delete payment elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); @@ -967,9 +938,7 @@ if (empty($reshook)) setEventMessages($paiement->error, $paiement->errors, 'errors'); } } - } - - /* + } /* * Insert new invoice in database */ elseif ($action == 'add' && $usercancreate) @@ -1853,9 +1822,7 @@ if (empty($reshook)) $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); } - } - - // Add a new line + } // Add a new line elseif ($action == 'addline' && $usercancreate) { $langs->load('errors'); @@ -2000,8 +1967,7 @@ if (empty($reshook)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { @@ -2398,9 +2364,7 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $usercancreate && $_POST['cancel'] == $langs->trans('Cancel')) { header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page exit(); - } - - // Outing situation invoice from cycle + } // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $usercancreate) { $object->fetch($id, '', '', '', true); @@ -2507,9 +2471,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); } } - } - - // add lines from objectlinked + } // add lines from objectlinked elseif ($action == 'import_lines_from_object' && $usercancreate && $object->statut == Facture::STATUS_DRAFT @@ -2824,14 +2786,12 @@ if ($action == 'create') } // when payment condition is empty (means not override by payment condition form a other object, like third-party), try to use default value - if(empty($cond_reglement_id)) - { + if (empty($cond_reglement_id)) { $cond_reglement_id = GETPOST("cond_reglement_id"); } // when payment mode is empty (means not override by payment mode form a other object, like third-party), try to use default value - if(empty($mode_reglement_id)) - { + if (empty($mode_reglement_id)) { $mode_reglement_id = GETPOST("mode_reglement_id"); } @@ -2839,8 +2799,7 @@ if ($action == 'create') $note_public = $object->getDefaultCreateValueFor('note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_public : null)); $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_private : null)); - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; print ajax_combobox('fac_replacement'); print ajax_combobox('fac_avoir'); diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 44954d863e5..c88fef5015c 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -78,9 +78,7 @@ if ($action == 'addcontact' && $user->rights->facture->creer) setEventMessages($object->error, $object->errors, 'errors'); } } -} - -// Toggle the status of a contact +} // Toggle the status of a contact elseif ($action == 'swapstatut' && $user->rights->facture->creer) { if ($object->fetch($id)) @@ -89,9 +87,7 @@ elseif ($action == 'swapstatut' && $user->rights->facture->creer) } else { dol_print_error($db); } -} - -// Deletes a contact +} // Deletes a contact elseif ($action == 'deletecontact' && $user->rights->facture->creer) { $object->fetch($id); diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 5c490ce3128..4b1c1637c89 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -247,9 +247,7 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); exit; } -} - -// Remove file in doc form +} // Remove file in doc form elseif ($action == 'remove_file' && $user->rights->banque->cheque) { if ($object->fetch($id) > 0) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 9e0a83e8c5f..03bb8a419c9 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2198,20 +2198,17 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($entity) || empty($conf->medias->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); $accessallowed = 1; $original_file = $conf->medias->multidir_output[$entity].'/'.$original_file; - } - // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log + } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root)) { $accessallowed = ($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); $original_file = $dolibarr_main_data_root.'/'.$original_file; - } - // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log + } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) { $accessallowed = ($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); $original_file = $dolibarr_main_data_root.'/doctemplates/websites/'.$original_file; - } - // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip + } // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) { // Dir for custom dirs @@ -2220,86 +2217,72 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = ($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file))); $original_file = $dirins.'/'.$original_file; - } - // Wrapping for some images + } // Wrapping for some images elseif ($modulepart == 'mycompany' && !empty($conf->mycompany->dir_output)) { $accessallowed = 1; $original_file = $conf->mycompany->dir_output.'/'.$original_file; - } - // Wrapping for users photos + } // Wrapping for users photos elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output)) { $accessallowed = 1; $original_file = $conf->user->dir_output.'/'.$original_file; - } - // Wrapping for members photos + } // Wrapping for members photos elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output)) { $accessallowed = 1; $original_file = $conf->adherent->dir_output.'/'.$original_file; - } - // Wrapping pour les apercu factures + } // Wrapping pour les apercu factures elseif ($modulepart == 'apercufacture' && !empty($conf->facture->multidir_output[$entity])) { if ($fuser->rights->facture->{$lire}) $accessallowed = 1; $original_file = $conf->facture->multidir_output[$entity].'/'.$original_file; - } - // Wrapping pour les apercu propal + } // Wrapping pour les apercu propal elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propale->{$lire}) $accessallowed = 1; $original_file = $conf->propal->multidir_output[$entity].'/'.$original_file; - } - // Wrapping pour les apercu commande + } // Wrapping pour les apercu commande elseif ($modulepart == 'apercucommande' && !empty($conf->commande->multidir_output[$entity])) { if ($fuser->rights->commande->{$lire}) $accessallowed = 1; $original_file = $conf->commande->multidir_output[$entity].'/'.$original_file; - } - // Wrapping pour les apercu intervention + } // Wrapping pour les apercu intervention elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) { if ($fuser->rights->ficheinter->{$lire}) $accessallowed = 1; $original_file = $conf->ficheinter->dir_output.'/'.$original_file; - } - // Wrapping pour les apercu conat + } // Wrapping pour les apercu conat elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output)) { if ($fuser->rights->contrat->{$lire}) $accessallowed = 1; $original_file = $conf->contrat->dir_output.'/'.$original_file; - } - // Wrapping pour les apercu supplier proposal + } // Wrapping pour les apercu supplier proposal elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) { if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed = 1; $original_file = $conf->supplier_proposal->dir_output.'/'.$original_file; - } - // Wrapping pour les apercu supplier order + } // Wrapping pour les apercu supplier order elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) { if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed = 1; $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; - } - // Wrapping pour les apercu supplier invoice + } // Wrapping pour les apercu supplier invoice elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) { if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed = 1; $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; - } - // Wrapping pour les apercu supplier invoice + } // Wrapping pour les apercu supplier invoice elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) { if ($fuser->rights->expensereport->{$lire}) $accessallowed = 1; $original_file = $conf->expensereport->dir_output.'/'.$original_file; - } - // Wrapping pour les images des stats propales + } // Wrapping pour les images des stats propales elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity])) { if ($fuser->rights->propale->{$lire}) $accessallowed = 1; $original_file = $conf->propal->multidir_temp[$entity].'/'.$original_file; - } - // Wrapping pour les images des stats commandes + } // Wrapping pour les images des stats commandes elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) { if ($fuser->rights->commande->{$lire}) $accessallowed = 1; @@ -2308,8 +2291,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed = 1; $original_file = $conf->fournisseur->commande->dir_temp.'/'.$original_file; - } - // Wrapping pour les images des stats factures + } // Wrapping pour les images des stats factures elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp)) { if ($fuser->rights->facture->{$lire}) $accessallowed = 1; @@ -2318,103 +2300,86 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed = 1; $original_file = $conf->fournisseur->facture->dir_temp.'/'.$original_file; - } - // Wrapping pour les images des stats expeditions + } // Wrapping pour les images des stats expeditions elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp)) { if ($fuser->rights->expedition->{$lire}) $accessallowed = 1; $original_file = $conf->expedition->dir_temp.'/'.$original_file; - } - // Wrapping pour les images des stats expeditions + } // Wrapping pour les images des stats expeditions elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp)) { if ($fuser->rights->deplacement->{$lire}) $accessallowed = 1; $original_file = $conf->deplacement->dir_temp.'/'.$original_file; - } - // Wrapping pour les images des stats expeditions + } // Wrapping pour les images des stats expeditions elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp)) { if ($fuser->rights->adherent->{$lire}) $accessallowed = 1; $original_file = $conf->adherent->dir_temp.'/'.$original_file; - } - // Wrapping pour les images des stats produits + } // Wrapping pour les images des stats produits elseif (preg_match('/^productstats_/i', $modulepart) && !empty($conf->product->dir_temp)) { if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed = 1; $original_file = (!empty($conf->product->multidir_temp[$entity]) ? $conf->product->multidir_temp[$entity] : $conf->service->multidir_temp[$entity]).'/'.$original_file; - } - // Wrapping for taxes + } // Wrapping for taxes elseif (in_array($modulepart, array('tax', 'tax-vat')) && !empty($conf->tax->dir_output)) { if ($fuser->rights->tax->charges->{$lire}) $accessallowed = 1; $modulepartsuffix = str_replace('tax-', '', $modulepart); $original_file = $conf->tax->dir_output.'/'.($modulepartsuffix != 'tax' ? $modulepartsuffix.'/' : '').$original_file; - } - // Wrapping for events + } // Wrapping for events elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { if ($fuser->rights->agenda->myactions->{$read}) $accessallowed = 1; $original_file = $conf->agenda->dir_output.'/'.$original_file; - } - // Wrapping for categories + } // Wrapping for categories elseif ($modulepart == 'category' && !empty($conf->categorie->multidir_output[$entity])) { if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if ($fuser->rights->categorie->{$lire}) $accessallowed = 1; $original_file = $conf->categorie->multidir_output[$entity].'/'.$original_file; - } - // Wrapping pour les prelevements + } // Wrapping pour les prelevements elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output)) { if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i', $original_file)) $accessallowed = 1; $original_file = $conf->prelevement->dir_output.'/'.$original_file; - } - // Wrapping pour les graph energie + } // Wrapping pour les graph energie elseif ($modulepart == 'graph_stock' && !empty($conf->stock->dir_temp)) { $accessallowed = 1; $original_file = $conf->stock->dir_temp.'/'.$original_file; - } - // Wrapping pour les graph fournisseurs + } // Wrapping pour les graph fournisseurs elseif ($modulepart == 'graph_fourn' && !empty($conf->fournisseur->dir_temp)) { $accessallowed = 1; $original_file = $conf->fournisseur->dir_temp.'/'.$original_file; - } - // Wrapping pour les graph des produits + } // Wrapping pour les graph des produits elseif ($modulepart == 'graph_product' && !empty($conf->product->dir_temp)) { $accessallowed = 1; $original_file = $conf->product->multidir_temp[$entity].'/'.$original_file; - } - // Wrapping pour les code barre + } // Wrapping pour les code barre elseif ($modulepart == 'barcode') { $accessallowed = 1; // If viewimage is called for barcode, we try to output an image on the fly, with no build of file on disk. //$original_file=$conf->barcode->dir_temp.'/'.$original_file; $original_file = ''; - } - // Wrapping pour les icones de background des mailings + } // Wrapping pour les icones de background des mailings elseif ($modulepart == 'iconmailing' && !empty($conf->mailing->dir_temp)) { $accessallowed = 1; $original_file = $conf->mailing->dir_temp.'/'.$original_file; - } - // Wrapping pour le scanner + } // Wrapping pour le scanner elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { $accessallowed = 1; $original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; - } - // Wrapping pour les images fckeditor + } // Wrapping pour les images fckeditor elseif ($modulepart == 'fckeditor' && !empty($conf->fckeditor->dir_output)) { $accessallowed = 1; $original_file = $conf->fckeditor->dir_output.'/'.$original_file; - } - - // Wrapping for users + } // Wrapping for users elseif ($modulepart == 'user' && !empty($conf->user->dir_output)) { $canreaduser = (!empty($fuser->admin) || $fuser->rights->user->user->{$lire}); @@ -2424,9 +2389,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->user->dir_output.'/'.$original_file; - } - - // Wrapping for third parties + } // Wrapping for third parties elseif (($modulepart == 'company' || $modulepart == 'societe' || $modulepart == 'thirdparty') && !empty($conf->societe->multidir_output[$entity])) { if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); @@ -2436,9 +2399,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->societe->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$db->escape($refname)."' AND entity IN (".getEntity('societe').")"; - } - - // Wrapping for contact + } // Wrapping for contact elseif ($modulepart == 'contact' && !empty($conf->societe->multidir_output[$entity])) { if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); @@ -2447,9 +2408,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->societe->multidir_output[$entity].'/contact/'.$original_file; - } - - // Wrapping for invoices + } // Wrapping for invoices elseif (($modulepart == 'facture' || $modulepart == 'invoice') && !empty($conf->facture->multidir_output[$entity])) { if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2458,8 +2417,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->facture->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('invoice').")"; - } - // Wrapping for mass actions + } // Wrapping for mass actions elseif ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2530,9 +2488,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; - } - - // Wrapping for interventions + } // Wrapping for interventions elseif (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output)) { if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2541,9 +2497,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->ficheinter->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } - - // Wrapping pour les deplacements et notes de frais + } // Wrapping pour les deplacements et notes de frais elseif ($modulepart == 'deplacement' && !empty($conf->deplacement->dir_output)) { if ($fuser->rights->deplacement->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2552,8 +2506,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->deplacement->dir_output.'/'.$original_file; //$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } - // Wrapping pour les propales + } // Wrapping pour les propales elseif (($modulepart == 'propal' || $modulepart == 'propale') && !empty($conf->propal->multidir_output[$entity])) { if ($fuser->rights->propale->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2562,9 +2515,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->propal->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."propal WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('propal').")"; - } - - // Wrapping pour les commandes + } // Wrapping pour les commandes elseif (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->multidir_output[$entity])) { if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2573,9 +2524,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->commande->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('order').")"; - } - - // Wrapping pour les projets + } // Wrapping pour les projets elseif ($modulepart == 'project' && !empty($conf->projet->dir_output)) { if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2592,9 +2541,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->projet->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; - } - - // Wrapping pour les commandes fournisseurs + } // Wrapping pour les commandes fournisseurs elseif (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output)) { if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2603,9 +2550,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } - - // Wrapping pour les factures fournisseurs + } // Wrapping pour les factures fournisseurs elseif (($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') && !empty($conf->fournisseur->facture->dir_output)) { if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2614,8 +2559,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } - // Wrapping pour les rapport de paiements + } // Wrapping pour les rapport de paiements elseif ($modulepart == 'supplier_payment') { if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2624,9 +2568,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->fournisseur->payment->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."paiementfournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } - - // Wrapping pour les rapport de paiements + } // Wrapping pour les rapport de paiements elseif ($modulepart == 'facture_paiement' && !empty($conf->facture->dir_output)) { if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2635,9 +2577,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } if ($fuser->societe_id > 0) $original_file = $conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file; else $original_file = $conf->facture->dir_output.'/payments/'.$original_file; - } - - // Wrapping for accounting exports + } // Wrapping for accounting exports elseif ($modulepart == 'export_compta' && !empty($conf->accounting->dir_output)) { if ($fuser->rights->accounting->bind->write || preg_match('/^specimen/i', $original_file)) @@ -2645,9 +2585,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->accounting->dir_output.'/'.$original_file; - } - - // Wrapping pour les expedition + } // Wrapping pour les expedition elseif ($modulepart == 'expedition' && !empty($conf->expedition->dir_output)) { if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2655,8 +2593,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->expedition->dir_output."/sending/".$original_file; - } - // Wrapping pour les bons de livraison + } // Wrapping pour les bons de livraison elseif ($modulepart == 'livraison' && !empty($conf->expedition->dir_output)) { if ($fuser->rights->expedition->livraison->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2664,9 +2601,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->expedition->dir_output."/receipt/".$original_file; - } - - // Wrapping pour les actions + } // Wrapping pour les actions elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { if ($fuser->rights->agenda->myactions->{$read} || preg_match('/^specimen/i', $original_file)) @@ -2674,9 +2609,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->agenda->dir_output.'/'.$original_file; - } - - // Wrapping pour les actions + } // Wrapping pour les actions elseif ($modulepart == 'actionsreport' && !empty($conf->agenda->dir_temp)) { if ($fuser->rights->agenda->allactions->{$read} || preg_match('/^specimen/i', $original_file)) @@ -2684,9 +2617,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->agenda->dir_temp."/".$original_file; - } - - // Wrapping pour les produits et services + } // Wrapping pour les produits et services elseif ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service') { if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); @@ -2696,9 +2627,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } if (!empty($conf->product->enabled)) $original_file = $conf->product->multidir_output[$entity].'/'.$original_file; elseif (!empty($conf->service->enabled)) $original_file = $conf->service->multidir_output[$entity].'/'.$original_file; - } - - // Wrapping pour les lots produits + } // Wrapping pour les lots produits elseif ($modulepart == 'product_batch' || $modulepart == 'produitlot') { if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); @@ -2707,9 +2636,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } if (!empty($conf->productbatch->enabled)) $original_file = $conf->productbatch->multidir_output[$entity].'/'.$original_file; - } - - // Wrapping for stock movements + } // Wrapping for stock movements elseif ($modulepart == 'movement' || $modulepart == 'mouvement') { if (empty($entity) || empty($conf->stock->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); @@ -2718,9 +2645,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } if (!empty($conf->stock->enabled)) $original_file = $conf->stock->multidir_output[$entity].'/movement/'.$original_file; - } - - // Wrapping pour les contrats + } // Wrapping pour les contrats elseif ($modulepart == 'contract' && !empty($conf->contrat->dir_output)) { if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2729,9 +2654,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->contrat->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract').")"; - } - - // Wrapping pour les dons + } // Wrapping pour les dons elseif ($modulepart == 'donation' && !empty($conf->don->dir_output)) { if ($fuser->rights->don->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2739,9 +2662,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->don->dir_output.'/'.$original_file; - } - - // Wrapping pour les dons + } // Wrapping pour les dons elseif ($modulepart == 'dolresource' && !empty($conf->resource->dir_output)) { if ($fuser->rights->resource->{$read} || preg_match('/^specimen/i', $original_file)) @@ -2749,9 +2670,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->resource->dir_output.'/'.$original_file; - } - - // Wrapping pour les remises de cheques + } // Wrapping pour les remises de cheques elseif ($modulepart == 'remisecheque' && !empty($conf->bank->dir_output)) { if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2760,9 +2679,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->bank->dir_output.'/checkdeposits/'.$original_file; // original_file should contains relative path so include the get_exdir result - } - - // Wrapping for bank + } // Wrapping for bank elseif (($modulepart == 'banque' || $modulepart == 'bank') && !empty($conf->bank->dir_output)) { if ($fuser->rights->banque->{$lire}) @@ -2770,55 +2687,41 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->bank->dir_output.'/'.$original_file; - } - - // Wrapping for export module + } // Wrapping for export module elseif ($modulepart == 'export' && !empty($conf->export->dir_temp)) { // Aucun test necessaire car on force le rep de download sur // le rep export qui est propre a l'utilisateur $accessallowed = 1; $original_file = $conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file; - } - - // Wrapping for import module + } // Wrapping for import module elseif ($modulepart == 'import' && !empty($conf->import->dir_temp)) { $accessallowed = 1; $original_file = $conf->import->dir_temp.'/'.$original_file; - } - - // Wrapping pour l'editeur wysiwyg + } // Wrapping pour l'editeur wysiwyg elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { $accessallowed = 1; $original_file = $conf->fckeditor->dir_output.'/'.$original_file; - } - - // Wrapping for backups + } // Wrapping for backups elseif ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { if ($fuser->admin) $accessallowed = 1; $original_file = $conf->admin->dir_output.'/'.$original_file; - } - - // Wrapping for upload file test + } // Wrapping for upload file test elseif ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp)) { if ($fuser->admin) $accessallowed = 1; $original_file = $conf->admin->dir_temp.'/'.$original_file; - } - - // Wrapping pour BitTorrent + } // Wrapping pour BitTorrent elseif ($modulepart == 'bittorrent' && !empty($conf->bittorrent->dir_output)) { $accessallowed = 1; $dir = 'files'; if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir = 'torrents'; $original_file = $conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file; - } - - // Wrapping pour Foundation module + } // Wrapping pour Foundation module elseif ($modulepart == 'member' && !empty($conf->adherent->dir_output)) { if ($fuser->rights->adherent->{$lire} || preg_match('/^specimen/i', $original_file)) @@ -2826,16 +2729,12 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->adherent->dir_output.'/'.$original_file; - } - - // Wrapping for Scanner + } // Wrapping for Scanner elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { $accessallowed = 1; $original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; - } - - // GENERIC Wrapping + } // GENERIC Wrapping // If modulepart=module_user_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp/iduser // If modulepart=module_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp // If modulepart=module_user Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/iduser diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4dd7588cec1..5b78dae709c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -167,10 +167,10 @@ function getBrowserInfo($user_agent) if (preg_match('/linux/i', $user_agent)) { $os = 'linux'; } elseif (preg_match('/macintosh/i', $user_agent)) { $os = 'macintosh'; } elseif (preg_match('/windows/i', $user_agent)) { $os = 'windows'; } // Name - if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; $version = $reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; $version = $reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; $version = $reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string - elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; $version = $reg[2]; } // Safari is often present in string for mobile but its not. - elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'opera'; $version = $reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end - elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end + if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; $version = $reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; $version = $reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; $version = $reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string + elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; $version = $reg[2]; } // Safari is often present in string for mobile but its not. + elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'opera'; $version = $reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end + elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name = 'lynxlinks'; $version = $reg[4]; } if ($tablet) { @@ -342,8 +342,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null { $out = $_SESSION['lastsearch_limit_'.$relativepathstring]; } - } - // Else, retreive default values if we are not doing a sort + } // Else, retreive default values if we are not doing a sort elseif (!isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set { if (!empty($_GET['action']) && $_GET['action'] == 'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) @@ -392,8 +391,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } } } - } - // Management of default search_filters and sort order + } // Management of default search_filters and sort order //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { @@ -1120,8 +1118,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = // This is when server run behind a reverse proxy if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != $remoteip) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].' -> '.$data['ip']; elseif (!empty($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != $remoteip) $data['ip'] = $_SERVER['HTTP_CLIENT_IP'].' -> '.$data['ip']; - } - // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) + } // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) elseif (!empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR']; // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). elseif (!empty($_SERVER['COMPUTERNAME'])) $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME']) ? '' : '@'.$_SERVER['USERNAME']); @@ -2083,8 +2080,7 @@ function dol_now($mode = 'gmt') require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time $ret = (int) (dol_now('gmt') + ($tzsecond * 3600)); - } - /*elseif ($mode == 'tzref') // Time for now with parent company timezone is added + } /*elseif ($mode == 'tzref') // Time for now with parent company timezone is added { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time @@ -5579,7 +5575,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8') } $text = strtr($text, $repTable); - if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support + if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support else $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); @@ -5776,7 +5772,7 @@ function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8') if (dol_textishtml($text)) $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); $text = strtr($text, $repTable); - if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support + if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support else $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); @@ -8205,8 +8201,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $return = !empty($html) ? $html : $statusLabel; } elseif ($displayMode == 1) { $return = !empty($html) ? $html : (!empty($statusLabelShort) ? $statusLabelShort : $statusLabel); - } - // Use status with images (for backward compatibility) + } // Use status with images (for backward compatibility) elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) { $return = ''; $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ? '' : '').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ? '' : ''); @@ -8251,8 +8246,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st } else { // $displayMode >= 6 $return = $htmlLabel.' '.$htmlImg; } - } - // Use new badge + } // Use new badge elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) { $statusLabelShort = !empty($statusLabelShort) ? $statusLabelShort : $statusLabel; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c212662b7e6..7673776ad93 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -904,11 +904,9 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ { // If before of next new year date if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset = 1; - } - // If after or equal of current new year date + } // If after or equal of current new year date elseif ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset = -1; - } - // For backward compatibility + } // For backward compatibility elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset = -1; } // If current month lower that month of return to zero, year is previous year if ($yearlen == 4) $yearcomp = sprintf("%04d", date("Y", $date) + $yearoffset); diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index bcecb5ed095..9d64185c781 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -86,8 +86,7 @@ function dol_setcache($memoryid, $data) } else { return -1; } - } - // Using shmop + } // Using shmop elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { $result = dol_setshmop($memoryid, $data); @@ -153,8 +152,7 @@ function dol_getcache($memoryid) } else { return -1; } - } - // Using shmop + } // Using shmop elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { $data = dol_getshmop($memoryid); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index fff5280e678..06e311b39f5 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -497,8 +497,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if ($user->socid > 0) { if ($user->socid <> $objectid) return false; - } - // If internal user: Check permission for internal users that are restricted on their objects + } // If internal user: Check permission for internal users that are restricted on their objects elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { $sql = "SELECT COUNT(sc.fk_soc) as nb"; @@ -508,8 +507,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " AND sc.fk_user = ".$user->id; $sql .= " AND sc.fk_soc = s.rowid"; $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; - } - // If multicompany and internal users with all permissions, check user is in correct entity + } // If multicompany and internal users with all permissions, check user is in correct entity elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(s.rowid) as nb"; @@ -526,8 +524,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND dbt.fk_soc = ".$user->socid; - } - // If internal user: Check permission for internal users that are restricted on their objects + } // If internal user: Check permission for internal users that are restricted on their objects elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; @@ -536,8 +533,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; - } - // If multicompany and internal users with all permissions, check user is in correct entity + } // If multicompany and internal users with all permissions, check user is in correct entity elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; @@ -588,8 +584,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.rowid IN (".$objectid.")"; $sql .= " AND dbt.".$dbt_keyfield." = ".$user->socid; - } - // If internal user: Check permission for internal users that are restricted on their objects + } // If internal user: Check permission for internal users that are restricted on their objects elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); @@ -602,8 +597,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " AND dbt.".$dbt_keyfield." = s.rowid"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql .= " AND sc.fk_user = ".$user->id; - } - // If multicompany and internal users with all permissions, check user is in correct entity + } // If multicompany and internal users with all permissions, check user is in correct entity elseif (!empty($conf->multicompany->enabled)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 733b3f3dc00..a594dd1dd84 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -267,8 +267,7 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper) if (!empty($conf->global->MAIN_UMASK)) { @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); } - } - else { + } else { $result1 = true; } diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 06005febfe4..d7ad3785338 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -700,12 +700,10 @@ if ($id > 0 || !empty($ref)) { $i = 0; if ($num) { - print ''; print ''.$langs->trans("Description").''; - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { print ''.$langs->trans("batch_number").''; print ''.$langs->trans("EatByDate").''; print ''.$langs->trans("SellByDate").''; @@ -731,11 +729,9 @@ if ($id > 0 || !empty($ref)) { print ''.$langs->trans("Warehouse"); // Select warehouse to force it everywhere - if (count($listwarehouses) > 1) - { + if (count($listwarehouses) > 1) { print '
'.$langs->trans("ForceTo").' '.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, $disabled); - } elseif (count($listwarehouses) == 1) - { + } elseif (count($listwarehouses) == 1) { print '
'.$langs->trans("ForceTo").' '.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled); } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 04c55b6dae4..0cde9145a51 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1716,14 +1716,12 @@ if ($action == 'create') } // when payment condition is empty (means not override by payment condition form a other object, like third-party), try to use default value - if(empty($cond_reglement_id)) - { + if (empty($cond_reglement_id)) { $cond_reglement_id = GETPOST("cond_reglement_id"); } // when payment mode is empty (means not override by payment condition form a other object, like third-party), try to use default value - if(empty($mode_reglement_id)) - { + if (empty($mode_reglement_id)) { $mode_reglement_id = GETPOST("mode_reglement_id"); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ef8830b2f35..42b0a4a3bc7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2040,7 +2040,7 @@ function top_menu_quickadd() if (! empty($conf->service->enabled) && $user->rights->service->creer) { $langs->load("products"); - $dropDownQuickAddHtml.= ' + $dropDownQuickAddHtml .= '
@@ -2054,20 +2054,18 @@ function top_menu_quickadd() // Execute hook printTopRightMenu (hooks should output string like '') $parameters = array(); $result = $hookmanager->executeHooks('printQuickAddBlock', $parameters); // Note that $action and $object may have been modified by some hooks - if (is_numeric($result)) - { - if ($result == 0) + if (is_numeric($result)) { + if ($result == 0) { $dropDownQuickAddHtml.= $hookmanager->resPrint; // add - else + } else { $dropDownQuickAddHtml = $hookmanager->resPrint; // replace - } - else - { - $dropDownQuickAddHtml.= $result; // For backward compatibility + } + } else { + $dropDownQuickAddHtml .= $result; // For backward compatibility } - $dropDownQuickAddHtml.= '
'; - $dropDownQuickAddHtml.= ''; + $dropDownQuickAddHtml .= ''; + $dropDownQuickAddHtml .= ''; $html.= ' '; print ''; - } - // Fiche en mode visu - else { + } else { + // Fiche en mode visu $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9bb3589b936..8a069418c4a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1603,9 +1603,8 @@ class Product extends CommonObject if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr = $this->multiprices_recuperableonly[$thirdparty_buyer->price_level]; if (empty($tva_tx)) $tva_npr = 0; } - } - // If price per customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + // If price per customer require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); @@ -1624,14 +1623,12 @@ class Product extends CommonObject if (empty($tva_tx)) $tva_npr = 0; } } - } - // If price per quantity - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { - if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + // If price per quantity + if ($this->prices_by_qty[0]) { + // yes, this product has some prices per quantity // Search price into product_price_by_qty from $this->id - foreach ($this->prices_by_qty_list[0] as $priceforthequantityarray) - { + foreach ($this->prices_by_qty_list[0] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price if ($priceforthequantityarray['price_base_type'] == 'HT') @@ -1643,11 +1640,10 @@ class Product extends CommonObject break; } } - } - // If price per quantity and customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - if ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity - { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + // If price per quantity and customer + if ($this->prices_by_qty[$thirdparty_buyer->price_level]) { + // yes, this product has some prices per quantity // Search price into product_price_by_qty from $this->id foreach ($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray) { @@ -3777,9 +3773,8 @@ class Product extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } - // If the supplier price already exists for this product and quantity - else { + } else { + // If the supplier price already exists for this product and quantity $this->product_fourn_price_id = $obj->rowid; return 0; }