mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-13 19:25:22 +01:00
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2019-2023 Thibault Foucart <support@ptibogxiv.net>
|
||||
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
|
||||
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
@@ -13594,7 +13594,7 @@ function dolIsAllowedForPreview($file)
|
||||
}
|
||||
|
||||
// Check mime types
|
||||
$mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp', 'webm', 'mp4');
|
||||
$mime_preview = array('avif', 'bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp', 'webm', 'mp4');
|
||||
if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES')) {
|
||||
$mime_preview[] = 'svg+xml';
|
||||
}
|
||||
@@ -13875,6 +13875,10 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
|
||||
$mime = 'video/webm';
|
||||
$imgmime = 'video.png';
|
||||
$famime = 'file-video';
|
||||
} elseif (preg_match('/\.avif$/i', $tmpfile)) {
|
||||
$mime = 'image/avif';
|
||||
$imgmime = 'image.png';
|
||||
$famime = 'file-image';
|
||||
} elseif (preg_match('/\.avi$/i', $tmpfile)) {
|
||||
$mime = 'video/x-msvideo';
|
||||
$imgmime = 'video.png';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -121,6 +121,9 @@ function image_format_supported($file, $acceptsvg = 0)
|
||||
if (strtolower($reg[1]) == '.svg') {
|
||||
$imgfonction = 'imagecreatefromsvg'; // Never available
|
||||
}
|
||||
if (strtolower($reg[1]) == '.avif') {
|
||||
$imgfonction = 'imagecreatefromavif'; // PHP >= 8.1
|
||||
}
|
||||
if ($imgfonction) {
|
||||
if (!function_exists($imgfonction)) {
|
||||
// Functions of conversion not available in this PHP
|
||||
|
||||
@@ -308,6 +308,16 @@ class modHoliday extends DolibarrModules
|
||||
'd.date_create' => 'DateCreation*'
|
||||
);
|
||||
|
||||
// Import of leave balance
|
||||
$r++;
|
||||
$this->import_code[$r] = $this->rights_class.'_'.$r;
|
||||
$this->import_label[$r] = "ListeLB"; // Translation key
|
||||
$this->import_icon[$r] = 'holiday';
|
||||
$this->import_tables_array[$r] = array('d' => MAIN_DB_PREFIX.'holiday_users');
|
||||
$this->import_fields_array[$r] = array(
|
||||
'd.fk_user' => "Employee*", 'd.nb_holiday' => "LeaveBalance*", 'd.fk_type' => "LeaveType*"
|
||||
);
|
||||
|
||||
$keyforselect = 'holiday';
|
||||
$keyforelement = 'holiday';
|
||||
$keyforaliasextra = 'extra';
|
||||
|
||||
@@ -10,6 +10,35 @@ use OAuth\Common\Http\Uri\UriInterface;
|
||||
*/
|
||||
class StreamClient extends AbstractClient
|
||||
{
|
||||
/**
|
||||
* Extract last HTTP status line and code from $http_response_header.
|
||||
*
|
||||
* @param array $headers
|
||||
* @return array{0:string,1:int} [statusLine, statusCode]
|
||||
*/
|
||||
private function getHttpStatusFromResponseHeaders($headers)
|
||||
{
|
||||
$statusLine = '';
|
||||
$statusCode = 0;
|
||||
|
||||
if (!is_array($headers)) {
|
||||
return array($statusLine, $statusCode);
|
||||
}
|
||||
|
||||
// In case of redirects, PHP may include multiple status lines. Keep the last one.
|
||||
foreach ($headers as $h) {
|
||||
if (is_string($h) && strpos($h, 'HTTP/') === 0) {
|
||||
$statusLine = trim($h);
|
||||
}
|
||||
}
|
||||
|
||||
if ($statusLine !== '' && preg_match('/^HTTP\\/\\S+\\s+(\\d{3})\\b/', $statusLine, $m)) {
|
||||
$statusCode = (int) $m[1];
|
||||
}
|
||||
|
||||
return array($statusLine, $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Any implementing HTTP providers should send a request to the provided endpoint with the parameters.
|
||||
* They should return, in string form, the response body and throw an exception on error.
|
||||
@@ -83,6 +112,25 @@ class StreamClient extends AbstractClient
|
||||
throw new TokenResponseException($lastError['message']);
|
||||
}
|
||||
|
||||
// When ignore_errors is enabled, file_get_contents returns the body even on HTTP 4xx/5xx.
|
||||
// Keep the previous behavior (throw on HTTP errors) but include a short response snippet to help debugging.
|
||||
list($statusLine, $statusCode) = $this->getHttpStatusFromResponseHeaders(isset($http_response_header) ? $http_response_header : null);
|
||||
if ($statusCode >= 400) {
|
||||
$snippet = trim((string) $response);
|
||||
if (strlen($snippet) > 2000) {
|
||||
$snippet = substr($snippet, 0, 2000).'...';
|
||||
}
|
||||
|
||||
$msg = 'Failed to request resource. HTTP Code: '.($statusLine !== '' ? $statusLine : (string) $statusCode);
|
||||
|
||||
$canShowDetails = (!empty($GLOBALS['user']) && is_object($GLOBALS['user']) && !empty($GLOBALS['user']->admin));
|
||||
if ($snippet !== '' && $canShowDetails) {
|
||||
$msg .= ' Response: '.$snippet;
|
||||
}
|
||||
|
||||
throw new TokenResponseException($msg);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -97,7 +145,9 @@ class StreamClient extends AbstractClient
|
||||
'protocol_version' => '1.1',
|
||||
'user_agent' => $this->userAgent,
|
||||
'max_redirects' => $this->maxRedirects,
|
||||
'timeout' => $this->timeout
|
||||
'timeout' => $this->timeout,
|
||||
// Return the response body even on HTTP error status codes so we can include it in exceptions.
|
||||
'ignore_errors' => true
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -165,3 +165,6 @@ HolidayMailSenderAdress=Email address for holiday requests
|
||||
HolidayMailSenderAdressHelp=If you leave this field blank, the default e-mail address will be used.
|
||||
WrongAmount=Wrong amount of days
|
||||
ErrorUpdatingUsersCP=Error updating users paid leaves
|
||||
LeaveBalance=Leave balance
|
||||
ListeLB=List of leave balance
|
||||
LeaveType = Type of leave balance
|
||||
|
||||
Reference in New Issue
Block a user