diff --git a/ChangeLog b/ChangeLog index c724f3758c5..a1ce3b0ad4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -213,6 +213,7 @@ The following changes may create regressions for some external modules, but were * $conf use into "computed formulae" of etrafields is now deprecated (not yet forbidden). You can replace use of $conf->currency by the new method getCurrency() and $conf->global->xxx by getDolGlobalString('xxx'). * $user->rights->module->perms is also deprecated. You can use $user->hasRight() instead. * The API endpoint /proposals/{id}/contact/{contactid}/{type}/{source} is now {id}/contact/{contactid}/{type} to match same behaviour than order and invoices. +* The API endpoint /interventions/{id}/reopen hase been removed in favor of /interventions/{id}/settodraft ***** ChangeLog for 22.0.3 compared to 22.0.2 ***** diff --git a/SECURITY.md b/SECURITY.md index 41c0fd43de1..8115a818687 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,12 +12,12 @@ Security report are valid only on any current stable version for the last 5 majo To report a vulnerability, for a private report, you can: -- Send your report on Vulnerability Disclosure Program (VDP): Link will be updated soon (recommended for everybody) +- Send your report as an issue on https://github.com/Dolibarr/dolibarr/issues or on GitHub Vulnerability Disclosure Program tool (VDP): https://github.com/Dolibarr/dolibarr/security/advisories (recommended for everybody) -- Or send an email to security@dolibarr.org with clear textual description of the report along with steps to reproduce the issue, include attachments such as screenshots or proof of concept code as necessary. +- Or send an email to security@dolibarr.org with clear textual description of the report along with steps to reproduce the issue, include attachments such as screenshots or proof of concept code as necessary (in such a case, the issue may be created by the developer that will fix the vulnerability or the Release Manager). ## Hunting vulnerabilities on Dolibarr @@ -114,3 +114,8 @@ Scope is the web application (backoffice) and the APIs. * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) * Physical or social engineering attempts or issues that require physical access to a victim’s computer/device * Vulnerabilities of type XSS exploited by using javascript into a website page of the website module or by using php code into a website page (being able to set javascript or php code is the expected behaviour in the website module), except if the user does not have the permission to edit page or php code. + + +## Be informed of a new vulnerability + +You can get more information on how to be informed on a new vulnerability on the page https://wiki.dolibarr.org/index.php/Security_information diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index 13f34b955bd..dd72224a071 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -973,6 +973,18 @@ if ($fh) { } fwrite($fh, ''."\n"); + + // Loop on arrayofalert to remove alerts that are on develop + foreach ($arrayofalerts as $tmpkey => $alert) { + $arrayuniquetmp = array_unique($alert['branch']); + if (count($arrayuniquetmp) == 1 && in_array('develop', $arrayuniquetmp)) { + // The alert has been fixed into develop only, so we discard it for RSS alert + print 'The alert with key '.$tmpkey.' is fixed into branch develop only, so we discard it for RSS'."\n"; + unset($arrayofalerts[$tmpkey]); + } + } + + // Loop on array of alerts on stable branches foreach ($arrayofalerts as $alert) { $alert['url_commit'] = 'https://github.com/Dolibarr/dolibarr/commit/'.$alert['commitid']; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 179cc14aa43..3625d91c40a 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1170,11 +1170,12 @@ if ($mode == 'common' || $mode == 'commonkanban') { } $urltogo = $_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&token='.newToken().'&module_position='.$module_position.'&action=set&token='.newToken().'&value='.$modName.'&mode='.$mode.$param; - $popupwidth = 500; + $popupWidth = 500; + $popupHeight = 300; $codeenabledisable .= ''."\n"; $codeenabledisable .= 'numero.'\', '.$popupwidth.', '.$disableCancel.');"'; + $codeenabledisable .= ' onclick="return confirmDolibarr(\''.dol_escape_js($warningmessage).'\', \'idqualified'.$objMod->numero.'\', '.$popupWidth.', '.$popupHeight.','.$disableCancel.');"'; } $codeenabledisable .= '>'; $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off'); diff --git a/htdocs/admin/remotestore/class/externalModules.class.php b/htdocs/admin/remotestore/class/externalModules.class.php index 4fe93e2ff7f..1b3e49daed9 100644 --- a/htdocs/admin/remotestore/class/externalModules.class.php +++ b/htdocs/admin/remotestore/class/externalModules.class.php @@ -926,6 +926,8 @@ class ExternalModules $result = file_put_contents($cache_file, $yaml); if ($result === false) { $this->error = 'Failed to create cache file: ' . $cache_file; + } else { + dolChmod($cache_file); } } } else { diff --git a/htdocs/admin/subcontractors.php b/htdocs/admin/subcontractors.php index 20255b1a811..77d69fc8405 100644 --- a/htdocs/admin/subcontractors.php +++ b/htdocs/admin/subcontractors.php @@ -145,7 +145,7 @@ print ''; print ''; print ''; -print load_fiche_titre($langs->trans("AccountantingProvider"), '', 'accounting', 0, '', '', '', ''); +print load_fiche_titre($langs->trans("AccountingProvider"), '', 'accounting', 0, '', '', '', ''); print ''; print ''."\n"; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 4d6e0662746..2ef4b67a4bb 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -324,6 +324,22 @@ class Documents extends DolibarrApi $templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf; $result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + throw new RestException(500, 'Error generating document missing doctemplate parameter'); + } + } elseif ($modulepart == 'stock' || $modulepart == 'entrepot') { + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; + + $tmpobject = new Entrepot($this->db); + $result = $tmpobject->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); + + if (!$result) { + throw new RestException(404, 'Warehouse not found'); + } + + $templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf; + $result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { throw new RestException(500, 'Error generating document missing doctemplate parameter'); } @@ -709,6 +725,19 @@ class Documents extends DolibarrApi throw new RestException(404, 'Contact not found'); } $upload_dir = $conf->societe->multidir_output[$object->entity ?? $conf->entity] . "/contact/" . get_exdir(0, 0, 0, 1, $object, 'contact'); + } elseif ($modulepart == 'stock') { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + + if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { + throw new RestException(403); + } + + $object = new Entrepot($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'Warehouse not found'); + } + $upload_dir = $conf->stock->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'stock'); } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } diff --git a/htdocs/blockedlog/admin/blockedlog_archives.php b/htdocs/blockedlog/admin/blockedlog_archives.php index 752605831d5..e1acde18816 100644 --- a/htdocs/blockedlog/admin/blockedlog_archives.php +++ b/htdocs/blockedlog/admin/blockedlog_archives.php @@ -401,6 +401,7 @@ if (GETPOST('action') == 'export' && $user->hasRight('blockedlog', 'read')) { / // Now add a signature to check integrity at end of file file_put_contents($tmpfile, 'END - sha256='.$sha256.' - hmac_sha256='.$hmacsha256, FILE_APPEND); + dolChmod($tmpfile); setEventMessages($langs->trans("FileGenerated"), null); } else { diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 9a40628312a..eda4843e2a3 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -354,6 +354,7 @@ if (GETPOST('downloadcsv', 'alpha')) { // Now add a signature to check integrity at end of file file_put_contents($tmpfile, 'END - md5='.$md5value, FILE_APPEND); + dolChmod($tmpfile); header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 96d846ffb62..08d8d4b7a68 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -431,7 +431,7 @@ class Categorie extends CommonObject 'cat_fk' => (empty($this->MAP_CAT_FK[$mapCode]) ? $mapCode : $this->MAP_CAT_FK[$mapCode]), 'cat_table' => (empty($this->MAP_CAT_TABLE[$mapCode]) ? $mapCode : $this->MAP_CAT_TABLE[$mapCode]), 'obj_class' => (empty($this->MAP_OBJ_CLASS[$mapCode]) ? $mapCode : $this->MAP_OBJ_CLASS[$mapCode]), - 'obj_table' => (empty($this->MAP_OBJ_TABLE[$mapCode]) ? $mapCode : $this->MAP_OBJ_TABLE[$mapCode]) + 'obj_table' => (empty($this->MAP_OBJ_TABLE[$mapCode]) ? $mapCode : $this->MAP_OBJ_TABLE[$mapCode]), ); } @@ -469,7 +469,7 @@ class Categorie extends CommonObject } $sql = "SELECT rowid, fk_parent, entity, label, description, color, position, fk_soc, visible, type, ref_ext"; - $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; + $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif, import_key"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id) { $sql .= " WHERE rowid = ".((int) $id); @@ -502,8 +502,9 @@ class Categorie extends CommonObject $this->date_modification = $this->db->jdate($res['tms']); $this->user_creation_id = (int) $res['fk_user_creat']; $this->user_modification_id = (int) $res['fk_user_modif']; + $this->import_key = $res['import_key']; - // Retrieve all extrafield + // Retrieve all extrafields // fetch optionals attributes and labels $this->fetch_optionals(); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 7df502cb426..6a1c085d073 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1286,7 +1286,7 @@ if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ $formproduct = new FormProduct($db); $moreforfilter .= '
'; $tmptitle = $langs->trans('Warehouse'); - $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse'); + $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx'); $moreforfilter .= '
'; } $parameters = array(); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 1b086b033ea..f07e0ae0a68 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -177,7 +177,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { //var_dump($key.' '.$value.' '.$object->fields[$key]['type'].' '.$object->fields[$key]['notnull']); $object->$key = $value; - if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && isset($val['default']) && $val['default'] == '(PROV)') { + if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && isset($val['default']) && $val['default'] === '(PROV)') { $object->$key = '(PROV)'; } if ($key == 'pass_crypted') { diff --git a/htdocs/core/ajax/ajaxstatusprospect.php b/htdocs/core/ajax/ajaxstatusprospect.php index cef9077144b..a7ac677db3f 100644 --- a/htdocs/core/ajax/ajaxstatusprospect.php +++ b/htdocs/core/ajax/ajaxstatusprospect.php @@ -85,20 +85,27 @@ if ($action === "updatestatusprospect" && $permisstiontoupdate) { $prospectstatic->client = 2; $prospectstatic->loadCacheOfProspStatus(); - $response = ''; + $response = ""; - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql .= "fk_stcomm = ".((int) $idstatus); - $sql .= " WHERE rowid = ".((int) $idprospect); + // Load thirdparty + $prospect = new Societe($db); + $result = $prospect->fetch($idprospect); - $resql = $db->query($sql); + if ($result >= 0) { + // Apply new status + $prospect->stcomm_id = $idstatus; - if (!$resql) { - dol_print_error($db); + // Update using business logic (fires COMPANY_MODIFY) + $updateResult = $prospect->update($prospect->id, $user); + + if ($updateResult >= 0) { + $response = img_action('', $prospectstatic->cacheprospectstatus[$idstatus]['code'], $prospectstatic->cacheprospectstatus[$idstatus]['picto'], 'class="inline-block valignmiddle paddingright pictoprospectstatus"'); + } else { + dol_syslog('Failed to update prospect via update() method', LOG_ERR); + dol_print_error($db); + } } else { - $num = $db->affected_rows($resql); - $response = img_action('', $prospectstatic->cacheprospectstatus[$idstatus]['code'], $prospectstatic->cacheprospectstatus[$idstatus]['picto'], 'class="inline-block valignmiddle paddingright pictoprospectstatus"'); + dol_print_error($db); } - echo json_encode(array('img' => $response)); } diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 31dda607808..05ab021729b 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -138,10 +138,12 @@ if ($action == "importSignature") { } if (!$error) { - $return = file_put_contents($upload_dir . $filename, $data); - if ($return == false) { + $return = file_put_contents($upload_dir.$filename, $data); + if ($return === false) { $error++; $response = 'Error file_put_content: failed to create signature file.'; + } else { + dolChmod($upload_dir.$filename); } } @@ -353,9 +355,11 @@ if ($action == "importSignature") { if (!$error) { $return = file_put_contents($upload_dir . $filename, $data); - if ($return == false) { + if ($return === false) { $error++; $response = 'Error file_put_content: failed to create signature file.'; + } else { + dolChmod($upload_dir.$filename); } } @@ -490,9 +494,11 @@ if ($action == "importSignature") { if (!$error) { $return = file_put_contents($upload_dir . $filename, $data); - if ($return == false) { + if ($return === false) { $error++; $response = 'Error file_put_content: failed to create signature file.'; + } else { + dolChmod($upload_dir.$filename); } } @@ -637,9 +643,11 @@ if ($action == "importSignature") { if (!$error) { $return = file_put_contents($upload_dir . $filename, $data); - if ($return == false) { + if ($return === false) { $error++; $response = 'Error file_put_content: failed to create signature file.'; + } else { + dolChmod($upload_dir.$filename); } } @@ -834,9 +842,11 @@ if ($action == "importSignature") { if (!$error) { $return = file_put_contents($upload_dir . $filename, $data); - if ($return == false) { + if ($return === false) { $error++; $response = 'Error file_put_content: failed to create signature file.'; + } else { + dolChmod($upload_dir.$filename); } } diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 6d076b012db..914ac00ef55 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -34,7 +34,7 @@ class box_activity extends ModeleBoxes public $boxcode = "activity"; public $boximg = "object_bill"; public $boxlabel = 'BoxGlobalActivity'; - public $depends = array("facture"); + public $depends = array("invoice|propal|order"); public $enabled = 1; diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php index ef252ca29cf..f70e734e8a2 100644 --- a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php +++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php @@ -36,7 +36,7 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes public $boxcode = "customersoutstandingbillreached"; public $boximg = "object_company"; public $boxlabel = "BoxCustomersOutstandingBillReached"; - public $depends = array("facture", "societe"); + public $depends = array("invoice", "societe"); public $enabled = 1; diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 7130b514233..1a3a69d4423 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -34,7 +34,7 @@ class box_factures extends ModeleBoxes public $boxcode = "lastcustomerbills"; public $boximg = "object_bill"; public $boxlabel = "BoxLastCustomerBills"; - public $depends = array("facture"); + public $depends = array("invoice"); /** * Constructor diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 9f90f60f3ad..5663a96dfe1 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -35,7 +35,7 @@ class box_factures_fourn extends ModeleBoxes public $boxcode = "lastsupplierbills"; public $boximg = "object_bill"; public $boxlabel = "BoxLastSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $depends = array("invoice", "fournisseur"); /** * Constructor diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index 188fc5be4c5..818d5e46cac 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -34,7 +34,7 @@ class box_factures_fourn_imp extends ModeleBoxes public $boxcode = "oldestunpaidsupplierbills"; public $boximg = "object_bill"; public $boxlabel = "BoxOldestUnpaidSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $depends = array("invoice", "fournisseur"); /** * Constructor diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index c59f62a80d9..914687414da 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -38,7 +38,7 @@ class box_factures_imp extends ModeleBoxes public $boxcode = "oldestunpaidcustomerbills"; public $boximg = "object_bill"; public $boxlabel = "BoxOldestUnpaidCustomerBills"; - public $depends = array("facture"); + public $depends = array("invoice"); /** * Constructor diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index d73e3d862c0..d9821886449 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -35,7 +35,7 @@ class box_ficheinter extends ModeleBoxes public $boxcode = "ficheinter"; public $boximg = "object_intervention"; public $boxlabel = "BoxFicheInter"; - public $depends = array("ficheinter"); // conf->contrat->enabled + public $depends = array("intervention"); /** * Constructor diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 14e1740e75c..b7343d24cf0 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -33,7 +33,7 @@ class box_graph_product_distribution extends ModeleBoxes public $boxcode = "productdistribution"; public $boximg = "object_product"; public $boxlabel = "BoxProductDistribution"; - public $depends = array("product|service", "facture|propal|commande"); + public $depends = array("product|service", "invoice|propal|order"); public $widgettype = 'graph'; diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 8bb5b154153..7eceaaa395e 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -37,7 +37,7 @@ class box_produits extends ModeleBoxes public $boxcode = "lastproducts"; public $boximg = "object_product"; public $boxlabel = "BoxLastProducts"; - public $depends = array("produit"); + public $depends = array("product"); /** * Constructor diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 9bf1d094f92..913ad129903 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -39,7 +39,7 @@ class box_produits_alerte_stock extends ModeleBoxes public $boxcode = "productsalertstock"; public $boximg = "object_product"; public $boxlabel = "BoxProductsAlertStock"; - public $depends = array("produit"); + public $depends = array("product"); /** * Constructor @@ -49,7 +49,7 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf, $user; + global $user; $this->db = $db; @@ -69,7 +69,7 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $conf, $hookmanager; + global $user, $langs, $hookmanager; $this->max = $max; diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index b76e83c82f4..fe2335b330e 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -37,7 +37,7 @@ class box_propales extends ModeleBoxes public $boxcode = "lastpropals"; public $boximg = "object_propal"; public $boxlabel = "BoxLastProposals"; - public $depends = array("propal"); // conf->propal->enabled + public $depends = array("propal"); /** * Constructor diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 9993432ccb6..bbabff269ce 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -36,7 +36,7 @@ class box_services_contracts extends ModeleBoxes public $boxcode = "lastproductsincontract"; public $boximg = "object_product"; public $boxlabel = "BoxLastProductsInContract"; - public $depends = array("service", "contrat"); + public $depends = array("service", "contract"); /** * Constructor diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 7b3f8a48251..a59c4ac991b 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -33,7 +33,7 @@ class box_services_expired extends ModeleBoxes public $boxcode = "expiredservices"; // id of box public $boximg = "object_contract"; public $boxlabel = "BoxOldestExpiredServices"; - public $depends = array("contrat"); // conf->propal->enabled + public $depends = array("contract"); /** * Constructor diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 472f2116d22..e9ef4e3cff1 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -38,7 +38,7 @@ class box_task extends ModeleBoxes * @var string */ public $boxlabel; - public $depends = array("projet"); + public $depends = array("project"); public $enabled = 1; @@ -50,7 +50,7 @@ class box_task extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf, $user, $langs; + global $user, $langs; // Load translation files required by the page $langs->loadLangs(array('boxes', 'projects')); diff --git a/htdocs/core/class/diasporahandler.class.php b/htdocs/core/class/diasporahandler.class.php index 64ba5bbc9e3..c70fa0fb770 100644 --- a/htdocs/core/class/diasporahandler.class.php +++ b/htdocs/core/class/diasporahandler.class.php @@ -113,6 +113,7 @@ class DiasporaHandler if ($cacheDir) { dol_mkdir($cacheDir); file_put_contents($cacheFile, $data); + dolChmod($cacheFile); } } else { $this->error = 'Error retrieving URL ' . $urlAPI; diff --git a/htdocs/core/class/fields/pricecyfield.class.php b/htdocs/core/class/fields/pricecyfield.class.php index 1e64f20ffff..a473b2b361d 100644 --- a/htdocs/core/class/fields/pricecyfield.class.php +++ b/htdocs/core/class/fields/pricecyfield.class.php @@ -94,7 +94,7 @@ class PricecyField extends CommonField $out = self::$form->inputType('text', $htmlName, (string) $value, $htmlName, $moreCss, $moreAttrib . $autoFocus); $out .= self::$form->selectCurrency($currency, $htmlName . 'currency_id'); - return $out; + return ''.$out.''; } /** diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index fd603b1cd8b..1354894cf41 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -456,6 +456,8 @@ class FileUpload // Non-multipart uploads (PUT method support) file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); } + dolChmod($file_path); + $file_size = dol_filesize($file_path); if ($file_size === $file->size) { $file->url = $this->options['upload_url'].urlencode($file->name); diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 08b97f8b6bf..452319be2b7 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -2246,7 +2246,9 @@ class Lessc $this->importDir = $oldImport; if ($outFname !== null) { - return file_put_contents($outFname, $out); + $res = file_put_contents($outFname, $out); + dolChmod($outFname); + return $res; } return $out; diff --git a/htdocs/core/class/mastodonhandler.class.php b/htdocs/core/class/mastodonhandler.class.php index c35a55aea96..97c45fd6a39 100644 --- a/htdocs/core/class/mastodonhandler.class.php +++ b/htdocs/core/class/mastodonhandler.class.php @@ -121,6 +121,7 @@ class MastodonHandler if ($cacheDir) { dol_mkdir($cacheDir); file_put_contents($cacheFile, $data); + dolChmod($cacheFile); } } else { $this->error = 'Error retrieving URL ' . $urlAPI; diff --git a/htdocs/core/class/reddithandler.class.php b/htdocs/core/class/reddithandler.class.php index 6c99fbce412..d399cb28dca 100644 --- a/htdocs/core/class/reddithandler.class.php +++ b/htdocs/core/class/reddithandler.class.php @@ -170,6 +170,7 @@ class RedditHandler if ($cacheDir) { dol_mkdir($cacheDir); file_put_contents($cacheFile, $data); + dolChmod($cacheFile); } } else { $this->error = 'Error retrieving URL ' . $urlAPI; diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index d9e95e9cd4d..289b9a13fc6 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -570,14 +570,14 @@ function cleanSerialize(expr) { * Input: msg * Input: id * Input: popupWidth + * Input: popupHeight * Input: disableCancelButton * Licence: GPL * See also document_preview() that also maje a dialogforpopup.dialog(). * See also newpopup that use window.open. */ -function confirmDolibarr(msg, id, popupWidth = 400, disableCancelButton = 0) { +function confirmDolibarr(msg, id, popupWidth = 400, popupHeight = 300, disableCancelButton = 0) { let alink = document.getElementById(id); - let popupHeight = 200; let title = 'trans("Note")); ?>'; if (alink.getAttribute("data-alreadyclicked") === "1") { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 9609b3e116a..130c9542b7e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3565,6 +3565,17 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (isModEnabled('stock')) { $original_file = $conf->stock->multidir_output[$entity].'/movement/'.$original_file; } + } elseif ($modulepart == 'entrepot') { + // Wrapping for stock warehouse + if (empty($entity) || empty($conf->stock->multidir_output[$entity])) { + return array('accessallowed' => 0, 'error' => 'Value entity must be provided'); + } + if (($fuser->hasRight('stock', $lire) || $fuser->hasRight('stock', 'movement', $lire) || $fuser->hasRight('stock', 'mouvement', $lire)) || preg_match('/^specimen/i', $original_file)) { + $accessallowed = 1; + } + if (isModEnabled('stock')) { + $original_file = $conf->stock->multidir_output[$entity].'/'.$original_file; + } } elseif ($modulepart == 'contract' && !empty($conf->contract->multidir_output[$entity])) { // Wrapping pour les contrats if ($fuser->hasRight('contrat', $lire) || preg_match('/^specimen/i', $original_file)) { @@ -3815,8 +3826,7 @@ function dol_filecache($directory, $filename, $object) $cachefile = $directory.$filename; file_put_contents($cachefile, serialize($object), LOCK_EX); - - dolChmod($cachefile, '0644'); + dolChmod($cachefile); } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 17dc719cf18..b3281b05fbe 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8928,7 +8928,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = /** * Clean a string to keep only desirable HTML tags. * Complementary of dol_string_onlythesehtmlattributes(). - * WARNING: This also clean HTML comments (because they can be used to obfuscate tag name). + * WARNING: This also clean HTML comments (because they can be used to obfuscate tag names). * * @param string $stringtoclean String to clean * @param int $cleanalsosomestyles Remove absolute/fixed positioning from inline styles @@ -8936,7 +8936,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = * @param int $cleanalsojavascript Remove also occurrence of 'javascript:'. * @param int $allowiframe Allow iframe tags. * @param string[] $allowed_tags List of allowed tags to replace the default list - * @param int $allowlink Allow "link" tags (for head html section) + * @param int $allowlink Allow "link" and "meta" tags (for head html section when using GETPOST with mode 'restricthtmlallowlinkscript') * @param int $allowscript Allow "script" tags (for head html section when using GETPOST with mode 'restricthtmlallowlinkscript') * @param int $allowstyle Allow "style" tags (for head html section when using GETPOST with mode 'restricthtmlallowlinkscript') * @param int $allowphp Allow "php" tags (Deprecated. Should never be used. If you can add php, you can also print in the php the code to output the other non allowed tags) @@ -8948,9 +8948,9 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, { if (empty($allowed_tags)) { $allowed_tags = array( + // HTML 4 "html", "head", - "meta", "body", "article", "a", @@ -8994,12 +8994,14 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, "h4", "h5", "h6", - "header", + + // HTML 5 "footer", - "nav", - "section", + "header", "menu", - "menuitem" // html5 tags + "menuitem", + "nav", + "section" ); } $allowed_tags[] = "comment"; // this tags is added to manage comment that are replaced into ... @@ -9012,6 +9014,9 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, if (!in_array('link', $allowed_tags)) { $allowed_tags[] = "link"; } + if (!in_array('meta', $allowed_tags)) { + $allowed_tags[] = "meta"; + } } if ($allowscript) { if (!in_array('script', $allowed_tags)) { @@ -9088,6 +9093,7 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes { if (is_null($allowed_attributes)) { $allowed_attributes = array( + // HTML 4 "allow", "allowfullscreen", "alt", @@ -9109,13 +9115,14 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes "title", "type", "width", + // HTML5 - "header", "footer", - "nav", - "section", + "header", "menu", - "menuitem" + "menuitem", + "nav", + "section" ); } // Always add content and http-equiv for meta tags, required to force encoding and keep html content in utf8 by load/saveHTML functions. diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 3398bc1bb65..16e76c55916 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -156,6 +156,7 @@ function dol_setcache($memoryid, $data, $expire = 0, $filecache = 0, $replace = $cachejson = dolEncrypt(json_encode($cachedata)); if (!dol_is_file($pathcache.'/'.$memoryid.'.cache') || $replace > 0) { $result = file_put_contents($pathcache.'/'.$memoryid.'.cache', $cachejson); + dolChmod($pathcache.'/'.$memoryid.'.cache'); } else { return 0; } diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index dadbabf1b98..78855d41a5e 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -846,12 +846,14 @@ function deletePropsAndPermsFromDoc($file, $objectname) $search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s'; $new_contents = preg_replace($search, '', $str); file_put_contents($file, $new_contents); + dolChmod($file); //perms If Exist $perms = "|*".strtolower($objectname)."*|"; $search_pattern_perms = '/' . preg_quote($perms, '/') . '.*?\n/'; $new_contents = preg_replace($search_pattern_perms, '', $new_contents); file_put_contents($file, $new_contents); + dolChmod($file); } } @@ -1038,6 +1040,7 @@ function addObjectsToApiFile($srcfile, $file, $objects, $modulename) $allContent = implode("", $content); file_put_contents($file, $allContent); + dolChmod($file); // Add methods for each object $allContent = getFromFile($srcfile, '/* BEGIN MODULEBUILDER API MYOBJECT */', '/* END MODULEBUILDER API MYOBJECT */'); @@ -1107,6 +1110,7 @@ function removeObjectFromApiFile($file, $objects, $objectname) $allContent = implode("", $content); file_put_contents($file, $allContent); + dolChmod($file); // for delete methods of object $begin = '/* BEGIN MODULEBUILDER API '.strtoupper($objectname).' */'; diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 174c7faee60..df8539a0f03 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -989,9 +989,14 @@ function checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring) $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities } if (!getDolGlobalString('WEBSITE_PHP_ALLOW_WRITE')) { // If option is not on, we disallow functions to write files - $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_compress_dir", "dol_decode", "dol_delete_file", "dol_delete_dir", "dol_delete_dir_recursive", "dol_copy", "archiveOrBackupFile")); // more dolibarr functions - $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask")); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_compress_dir", "dol_delete_file", "dol_delete_dir", "dol_delete_dir_recursive", "dol_copy", "archiveOrBackupFile")); // more dolibarr functions + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "flock", "fputs", "fputscsv", "fwrite", "fpassthru", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask")); } + if (getDolGlobalString('WEBSITE_PHP_DISALLOW_READ')) { // If option is not on, we disallow functions to read files + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_decode")); // more dolibarr functions + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("file", "fopen", "file_get_contents", "fgets", "fgetscsv", "fgetss", "fread")); + } + //$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include")); $forbiddenphpmethods = array('invoke', 'invokeArgs'); // Method of ReflectionFunction to execute a function diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 1922b52627e..c23fcb1f563 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -674,14 +674,14 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { $("input[name='np_marginRate']:first").blur(function(e) { - console.log("np_marginRate blur"); + console.log("np_marginRate blur, call checkFreeLine"); return checkFreeLine(e, "np_marginRate"); }); $("input[name='np_markRate']:first").blur(function(e) { - console.log("np_markRate blur"); + console.log("np_markRate blur, call checkFreeLine"); return checkFreeLine(e, "np_markRate"); }); hasRight('margins', 'creer')) { if (rate.val() == '') return true; - if (! $.isNumeric(rate.val().replace(',','.'))) - { + if (! $.isNumeric(rate.val().replace(',','.'))) { // TODO Use price2numjs ? alert('trans("rateMustBeNumeric")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } - if (npRate == "np_markRate" && rate.val() >= 100) - { + if (npRate == "np_markRate" && rate.val() >= 100) { // TODO Use price2numjs ? alert('trans("markRateShouldBeLesserThan100")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); @@ -714,14 +712,15 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { } var price = 0; - remisejs=price2numjs(remise.val()); + remisejs = price2numjs(remise.val()); - if (remisejs != 100) // If a discount not 100 or no discount - { - if (remisejs == '') remisejs=0; + if (remisejs != 100) { // If there is a discount that is not 100 or if no discount at all (most common case) + if (remisejs == '') { + remisejs=0; + } - bpjs=price2numjs(buying_price.val()); - ratejs=price2numjs(rate.val()); + bpjs = price2numjs(buying_price.val()); + ratejs = price2numjs(rate.val()); if (npRate == "np_marginRate") price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); @@ -729,7 +728,8 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); } - $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formatted value + // $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formatted value + $("input[name='price_ht']:first").val(pricejs(price)); return true; } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 02a75697a87..7d030fbaab3 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -504,6 +504,7 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { if (getDolGlobalString('DISPLAY_MARGIN_RATES')) { ?> $("input[name='np_marginRate']:first").blur(function(e) { + console.log("np_marginRate blur, call checkFreeLine"); return checkFreeLine(e, "np_marginRate"); }); hasRight('margins', 'creer')) { if (getDolGlobalString('DISPLAY_MARK_RATES')) { ?> $("input[name='np_markRate']:first").blur(function(e) { + console.log("np_markRate blur, call checkFreeLine"); return checkFreeLine(e, "np_markRate"); }); hasRight('margins', 'creer')) { return true; var ratejs = price2numjs(rate.val()); - if (! $.isNumeric(ratejs)) - { + if (! $.isNumeric(rate.val().replace(',','.'))) { // TODO Use price2numjs ? alert('transnoentities("rateMustBeNumeric")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } - if (npRate == "np_markRate" && rate.val() >= 100) - { + if (npRate == "np_markRate" && rate.val() >= 100) { // TODO Use price2numjs ? alert('transnoentities("markRateShouldBeLesserThan100")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); @@ -546,7 +546,7 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { var price = 0; remisejs = price2numjs(remise.val()); - if (remisejs != 100) { // If a discount not 100 or no discount + if (remisejs != 100) { // If there is a discount that is not 100 or if no discount at all (most common case) if (remisejs == '') { remisejs = 0; } @@ -559,7 +559,9 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { else if (npRate == "np_markRate") price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); } - $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formatted value + + // $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formatted value + $("input[name='price_ht']:first").val(pricejs(price)); return true; } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 28154fa95c6..73bdc65b709 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -3903,6 +3903,7 @@ class EmailCollector extends CommonObject $destination = dol_sanitizePathName($destination); file_put_contents($destination, $data); + dolChmod($destination); } } @@ -4019,12 +4020,15 @@ class EmailCollector extends CommonObject $quality = $tmparraysize['quality']; file_put_contents($destdir.'/'.$filename, $content); + dolChmod($destdir.'/'.$filename); + if (image_format_supported($filename) == 1) { // Create thumbs vignette($destdir.'/'.$filename, $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) vignette($destdir.'/'.$filename, $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); } + addFileIntoDatabaseIndex($destdir, $filename); } diff --git a/htdocs/emailcollector/lib/emailcollector.lib.php b/htdocs/emailcollector/lib/emailcollector.lib.php index 731fe38d35b..7eb58caa4ce 100644 --- a/htdocs/emailcollector/lib/emailcollector.lib.php +++ b/htdocs/emailcollector/lib/emailcollector.lib.php @@ -190,6 +190,8 @@ function saveAttachment($path, $filename, $data) $i++; } file_put_contents($filepath, $data); + dolChmod($filepath); + return $filepath; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 3e1d15d09f0..41d473f971f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2051,7 +2051,7 @@ if ($action == 'create' && $usercancreate) { print ''; //ship from preselected location $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0); // Convert to number - if ($line->product_type == Product::TYPE_SERVICE && getDolGlobalString('SHIPMENT_SUPPORTS_SERVICES')) { + if (($line->product_type == Product::TYPE_SERVICE && getDolGlobalString('SHIPMENT_SUPPORTS_SERVICES')) || $product->stockable_product == Product::DISABLED_STOCK) { $deliverableQty = $quantityToBeDelivered; } else { $deliverableQty = min($quantityToBeDelivered, $stock); diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index ba7be1ab403..fc4dec547c2 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -474,43 +474,6 @@ class Interventions extends DolibarrApi ); } - /** - * Reopen an intervention - * - * @since 22.0.0 Initial implementation - * - * @param int $id Intervention ID - * - * @url POST {id}/reopen - * - * @return Object - * - * @throws RestException - */ - public function reopen($id) - { - if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) { - throw new RestException(403, "Insufficiant rights"); - } - $result = $this->fichinter->fetch($id); - if (!$result) { - throw new RestException(404, 'Intervention not found'); - } - - if (!DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $result = $this->fichinter->setDraft(DolibarrApiAccess::$user); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already set as draft'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Intervention: '.$this->fichinter->error); - } - $this->fichinter->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->fichinter); - } - /** * Validate an intervention * @@ -651,27 +614,29 @@ class Interventions extends DolibarrApi } /** - * Sets an interventional as draft + * Sets an intervention as draft * - * @param int $id interventional ID + * @since 23.0.0 Initial implementation + * + * @param int $id ID of intervention * * @return Object Object with cleaned properties * - * @url POST {id}/settodraft + * @url POST {id}/settodraft * * @throws RestException 304 - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 404 * @throws RestException 500 System error */ public function settodraft($id) { if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) { - throw new RestException(403); + throw new RestException(403, "Insufficiant rights"); } $result = $this->fichinter->fetch($id); if (!$result) { - throw new RestException(404, 'Interventional not found'); + throw new RestException(404, 'Intervention not found'); } if (!DolibarrApi::_checkAccessToResource('ficheinter', $this->fichinter->id)) { @@ -680,17 +645,13 @@ class Interventions extends DolibarrApi $result = $this->fichinter->setDraft(DolibarrApiAccess::$user); if ($result == 0) { - throw new RestException(304, 'Nothing done.'); + throw new RestException(304, 'Nothing done. . May be object is already set as draft.'); } if ($result < 0) { - throw new RestException(500, 'Error : '.$this->fichinter->error); - } - - $result = $this->fichinter->fetch($id); - if (!$result) { - throw new RestException(404, 'Interventional not found'); + throw new RestException(500, 'Error when closing intervention: '.$this->fichinter->error); } + $this->fichinter->fetchObjectLinked(); return $this->_cleanObjectDatas($this->fichinter); } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e71f8a81c86..9db09151994 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1336,7 +1336,7 @@ CompanyFundationDesc=Edit the information of your company/organization. Click on MoreNetworksAvailableWithModule=More social networks may be available by enabling the module "Social networks". Subcontractors=Subcontractors SubcontractorsDesc=If the management of your application is subcontracted to external service providers (an accountant/bookkeeper and/or an IT service provider), you can enter here their information so it won't be lost in case of a substition of the administrator. -AccountantingProvider=Accounting service provider +AccountingProvider=Accounting service provider ITProvider=IT service prodiver AccountantFileNumber=Accountant code DisplayDesc=Parameters affecting the look and presentation of the application can be modified here. diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index b29c8e5f33e..7aa90a65c7c 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1334,7 +1334,7 @@ CompanyFundationDesc=Modifiez les informations de votre société/organisation. MoreNetworksAvailableWithModule=Plus de réseaux sociaux peuvent être disponible en activant le module "Réseaux Sociaux". Subcontractors=sous-traitants SubcontractorsDesc=Si la gestion de votre application est sous-traitée à des prestataires externes (un comptable/expert-comptable/un prestataire informatique), vous pouvez saisir ici leurs informations afin qu'elles ne soient pas perdues en cas de remplacement de l'administrateur. -AccountantingProvider=Fournisseur Comptabilité service +AccountingProvider=Fournisseur Comptabilité service ITProvider=Fournisseur IT service AccountantFileNumber=Code comptable DisplayDesc=Les paramètres affectant l'apparence et la présentation de l'application peuvent être modifiés ici. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index bcc9ae46f95..78ec4da0fbf 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -428,7 +428,8 @@ if ($dirins && $action == 'initmodule' && $modulename /* && $user->hasRight("mod if (getDolGlobalString('MODULEBUILDER_SPECIFIC_README')) { setEventMessages($langs->trans("ContentOfREADMECustomized"), null, 'warnings'); dol_delete_file($destdir.'/README.md'); - file_put_contents($destdir.'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README); + file_put_contents($destdir.'/README.md', getDolGlobalString("MODULEBUILDER_SPECIFIC_README")); + dolChmod($destdir.'/README.md'); } // for create file to add properties // file_put_contents($destdir.'/'.strtolower($modulename).'propertycard.php',''); diff --git a/htdocs/product/stock/class/api_productlots.class.php b/htdocs/product/stock/class/api_productlots.class.php index d7e28b08f62..b9e1a82b8b0 100644 --- a/htdocs/product/stock/class/api_productlots.class.php +++ b/htdocs/product/stock/class/api_productlots.class.php @@ -269,14 +269,13 @@ class Productlots extends DolibarrApi $result = $this->productlot->fetch($id); if ($result) { $this->productlot->fetch_optionals(); - $this->productlot->fetch_userassigned(); $this->productlot->oldcopy = clone $this->productlot; // @phan-suppress-current-line PhanTypeMismatchProperty } if (!$result) { throw new RestException(404, 'productlot not found'); } - if (!DolibarrApi::_checkAccessToResource('productlot', $this->productlot->id, 'productlot', '', 'fk_soc', 'id')) { + if (!DolibarrApi::_checkAccessToResource('productlot', $this->productlot->id, 'product_lot', '', 'fk_soc', 'rowid')) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -298,7 +297,7 @@ class Productlots extends DolibarrApi $this->productlot->$field = $this->_checkValForAPI($field, $value, $this->productlot); } - if ($this->productlot->update(DolibarrApiAccess::$user, 1) > 0) { + if ($this->productlot->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } @@ -334,12 +333,12 @@ class Productlots extends DolibarrApi throw new RestException(404, 'Product lot not found'); } - if (!DolibarrApi::_checkAccessToResource('productlot', $this->productlot->id, 'productlot', '', 'fk_soc', 'id')) { + if (!DolibarrApi::_checkAccessToResource('productlot', $this->productlot->id, 'product_lot', '', 'fk_soc', 'rowid')) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->productlot->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete Product lot : '.$this->productlot->error); + if ($this->productlot->delete(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error when delete Product lot : '.implode(',', $this->productlot->errors)); } return array( diff --git a/htdocs/public/webportal/css/form-input-special.css b/htdocs/public/webportal/css/form-input-special.css new file mode 100644 index 00000000000..8e2b3b2ada7 --- /dev/null +++ b/htdocs/public/webportal/css/form-input-special.css @@ -0,0 +1,117 @@ + +:root{ + --form-input-margin-bottom : calc(var(--form-element-spacing-vertical)*3); +} + +/** + * STARS INPUT + */ +.star-selection { + font-size: 1rem; + cursor: pointer; + display: flex; + white-space: nowrap; +} +.star { + color: #ccc; + transition: color 0.4s; +} +.star:hover, .star.active { + color: var(--butactionbg); +} + +/** + * SELECT 2 + */ + +.select2-container, .select2-container .selection, .select2-selection.select2-selection--single{ + height: calc(1rem * var(--line-height) + var(--form-element-spacing-vertical) * 2 + var(--border-width) * 2) !important; +} +.select2.select2-container{ + margin-bottom: var(--form-input-margin-bottom); +} +.select2-selection--single .select2-selection__rendered, .select2-selection__arrow{ + line-height: calc(1rem * var(--line-height) + var(--form-element-spacing-vertical) * 2 + var(--border-width) * 2) !important; + height: calc(1rem * var(--line-height) + var(--form-element-spacing-vertical) * 2 + var(--border-width) * 2) !important; +} + +.select2-selection--multiple .select2-selection__rendered{ + line-height: calc(1rem * var(--line-height) + var(--form-element-spacing-vertical) + var(--border-width) * 2) !important; + height: calc(1rem * var(--line-height) + var(--form-element-spacing-vertical) * 3 + var(--border-width) * 2 ) !important; +} + +.select2-search__field[type="search"] { + margin-bottom: 3px; +} +.select2-search.select2-search--dropdown{ + border-bottom : 1px solid rgba(0,0,0,0.1); +} + +.select2-container--default.select2-container--focus .select2-selection--multiple { + border :var(--border-width) solid var(--border-color) !important; /* fix select 2 to be compatible pico css */ +} + +.select2-container--default.select2-container--focus .select2-selection--multiple{ + --border-color: var(--primary); +} + +.select2-container .select2-selection--multiple .select2-selection__rendered { + display: block !important; /* fix select 2 to be compatible pico css */ + overflow: auto; +} + +.select2-container--default .select2-selection--multiple .select2-selection__choice{ + border: 0px solid #aaa !important; /* fix select 2 to be compatible pico css */ +} + +/** + * DATE + */ + +[class*="fieldname_options_"] > input { + width: auto; + max-width: none; + box-sizing: border-box; /* pour que padding/border ne débordent pas */ +} + +[class*="fieldname_options_"] .nowraponall { + display: inline-flex; + align-items: center; + gap: 0.25rem; +} + + + +[class*="fieldname_options_"] .dpInvisibleButtons{ + display: inline-block; + width: auto; + vertical-align: baseline; +} + +/** +* Inlines forms + */ + +.nowraponall :is(input:not([type=checkbox], [type=radio]), select, textarea){ + margin-bottom: 0; +} + +.nowraponall:has(input:not([type=checkbox], [type=radio]), select, textarea){ + margin-bottom: var(--form-input-margin-bottom); +} + + +/** + * Form currency + */ +.form-select-price-currency-container { + display: flex; + align-items: center; + justify-content: center; + line-height: 1; + gap: 0.25rem; + margin-bottom: var(--form-input-margin-bottom); +} +.form-select-price-currency-container > input { + text-align: right; +} diff --git a/htdocs/public/webportal/css/style.css.php b/htdocs/public/webportal/css/style.css.php index edeb7e85c01..bb7d5da5f2f 100644 --- a/htdocs/public/webportal/css/style.css.php +++ b/htdocs/public/webportal/css/style.css.php @@ -102,6 +102,7 @@ if (empty($dolibarr_nocache)) { @import "card.css"; @import "dialog.css"; @import "btn.css"; +@import "form-input-special.css"; /** This file can overwrite default pico css */ diff --git a/htdocs/public/webportal/css/themes/custom.css.php b/htdocs/public/webportal/css/themes/custom.css.php index bec2de3b4c3..cb30f91bf21 100644 --- a/htdocs/public/webportal/css/themes/custom.css.php +++ b/htdocs/public/webportal/css/themes/custom.css.php @@ -48,6 +48,13 @@ session_cache_limiter('public'); require_once __DIR__.'/../../webportal.main.inc.php'; dol_include_once('/webportal/class/webPortalTheme.class.php'); +/** + * @var Conf $conf + * @var HookManager $hookmanager + * @var Translate $langs + * @var Context $context + */ + // Define css type top_httphead('text/css'); /* @@ -85,5 +92,10 @@ $webPortalTheme = new WebPortalTheme(); } initHooks(array('webPortalCustomCss')); +$parameters = array(); +$hookmanager->executeHooks('webPortalCustomCss', $parameters, $webPortalTheme); +print $hookmanager->resPrint; + print '/* Here, the content of the common custom CSS defined into Home - Setup - Display - CSS */'."\n"; print getDolGlobalString('WEBPORTAL_CUSTOM_CSS'); diff --git a/htdocs/public/webportal/tpl/header.tpl.php b/htdocs/public/webportal/tpl/header.tpl.php index 61db0659cfa..9e0cefc06fb 100644 --- a/htdocs/public/webportal/tpl/header.tpl.php +++ b/htdocs/public/webportal/tpl/header.tpl.php @@ -18,6 +18,7 @@ /** * @var Context $context Object context for webportal + * @var HookManager $hookmanager * @var Translate $langs * @@var string[] $vars['body-class'] more CSS classes for body * @@var string[] $vars['body-theme'] theme css to apply default is custom @@ -101,8 +102,13 @@ top_httphead(); $bodyAttributes['class'] = $vars['body-class']; } - $bodyCompiledAttributes = commonHtmlAttributeBuilder($bodyAttributes); + $parameters = array( + 'bodyAttributes' => &$bodyAttributes + ); + $hookmanager->executeHooks('webPortalHeader', $parameters, $context); + print $hookmanager->resPrint; + $bodyCompiledAttributes = commonHtmlAttributeBuilder($bodyAttributes); ?> > diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 2474566770c..c903ae9371f 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3796,6 +3796,7 @@ div.vmenu, td.vmenu { .vmenu { width: px; margin-left: 8px; + text-transform: capitalize; display: none; @@ -5965,6 +5966,11 @@ button.ui-button-icon-only.ui-dialog-titlebar-close { .ui-dialog .ui-dialog-content, .ui-dialog .ui-dialog-titlebar.ui-widget-header { padding-left: 1em !important; } +/* +.ui-dialog .ui-dialog-content { + text-align: justify; +} +*/ /* ============================================================================== */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 11fb28c8667..0d103a43013 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -5877,6 +5877,14 @@ div#dialogforpopup { .ui-dialog .ui-dialog-buttonpane { padding: .5em 1em .3em .4em; } +.ui-dialog .ui-dialog-content, .ui-dialog .ui-dialog-titlebar.ui-widget-header { + padding-left: 1em !important; +} +/* +.ui-dialog .ui-dialog-content { + text-align: justify; +} +*/ /* ============================================================================== */ diff --git a/htdocs/webportal/class/html.formwebportal.class.php b/htdocs/webportal/class/html.formwebportal.class.php index 35e3a8f9508..a46885296be 100644 --- a/htdocs/webportal/class/html.formwebportal.class.php +++ b/htdocs/webportal/class/html.formwebportal.class.php @@ -1670,4 +1670,19 @@ class FormWebPortal extends Form return $html; } + + /** + * Retourne la liste des devises, dans la langue de l'utilisateur + * + * @param string $selected Preselected currency code + * @param string $htmlname Name of HTML select list + * @param int $mode 0 = Add currency symbol into label, 1 = Add 3 letter iso code, 2 = Add both symbol and code + * @param string $useempty '1'=Allow empty value + * @return string HTML component + */ + public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0, $useempty = '') + { + + return ''.parent::selectCurrency($selected, $htmlname, $mode, $useempty).''; + } } diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 4f73279b0b4..0911dacd74a 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -279,6 +279,7 @@ class Website extends CommonObject $stringtodolibarrfile .= "param=value\n"; //print $conf->website->dir_output.'/'.$this->ref.'/.dolibarr';exit; file_put_contents($pathofwebsite.'/.dolibarr', $stringtodolibarrfile); + dolChmod($pathofwebsite.'/.dolibarr'); $filelicense = $pathofwebsite.'/LICENSE'; if (!dol_is_file($filelicense)) { @@ -1898,34 +1899,6 @@ class Website extends CommonObject } } - /** - * check previous state for file - * @param string $pathname path of file - * @return array|mixed - */ - public function checkPreviousState($pathname) - { - if (!file_exists($pathname)) { - if (touch($pathname)) { - dolChmod($pathname, '0664'); - } - return []; - } - return unserialize(file_get_contents($pathname)); - } - - - /** - * Save state for File - * @param mixed $etat state - * @param string $pathname path of file - * @return int|false - */ - public function saveState($etat, $pathname) - { - return file_put_contents($pathname, serialize($etat)); - } - /** * Compare two files has not same name but same content * @param string $dossierSource filepath of folder source @@ -2156,7 +2129,10 @@ class Website extends CommonObject // Reindex the table keys $contentDest = array_values($contentDest); $stringreplacement = implode("\n", $contentDest); + file_put_contents($inplaceFile, $stringreplacement); + dolChmod($inplaceFile); + foreach ($differences['lignes_dont_change'] as $linechanged => $line) { if (in_array($linechanged, $contentDest)) { dolReplaceInFile($inplaceFile, array($linechanged => $line)); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index fa50173769d..a0a34c288e2 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -5981,7 +5981,8 @@ if ((empty($action) || $action == 'preview' || $action == 'createfromclone' || $ print $out; - /*file_put_contents($filetpl, $out); + /* + file_put_contents($filetpl, $out); dolChmod($filetpl); // Output file on browser
'.$langs->trans("CompanyInfo").'