2008-04-29 23:13:49 +02:00
< ? php
2021-10-28 13:36:53 +02:00
/* Copyright ( C ) 2008 - 2021 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2008 - 2021 Regis Houssin < regis . houssin @ inodbox . com >
2020-08-03 11:17:30 +02:00
* Copyright ( C ) 2020 Ferran Marcet < fmarcet @ 2 byte . es >
2024-03-15 22:08:23 +01:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
2008-04-29 23:13:49 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2008-04-29 23:13:49 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
* or see https :// www . gnu . org /
2008-04-29 23:13:49 +02:00
*/
/**
2011-10-24 10:45:06 +02:00
* \file htdocs / core / lib / security . lib . php
2011-09-24 15:44:04 +02:00
* \ingroup core
2012-02-12 17:41:28 +01:00
* \brief Set of function used for dolibarr security ( common function included into filefunc . inc . php )
2011-09-24 15:44:04 +02:00
* Warning , this file must not depends on other library files , except function . lib . php
* because it is used at low code level .
2008-11-17 01:02:57 +01:00
*/
2008-04-29 23:13:49 +02:00
/**
2018-04-19 12:03:42 +02:00
* Encode a string with base 64 algorithm + specific delta change .
2011-09-16 19:06:10 +02:00
*
2012-02-19 19:14:17 +01:00
* @ param string $chain string to encode
2018-04-19 12:03:42 +02:00
* @ param string $key rule to use for delta ( '0' , '1' or 'myownkey' )
2012-02-19 19:14:17 +01:00
* @ return string encoded string
2019-03-11 01:01:15 +01:00
* @ see dol_decode ()
2008-04-29 23:13:49 +02:00
*/
2019-01-27 15:20:16 +01:00
function dol_encode ( $chain , $key = '1' )
2008-04-29 23:13:49 +02:00
{
2021-02-23 22:03:23 +01:00
if ( is_numeric ( $key ) && $key == '1' ) { // rule 1 is offset of 17 for char
2019-11-26 12:52:04 +01:00
$output_tab = array ();
$strlength = dol_strlen ( $chain );
2021-02-23 22:03:23 +01:00
for ( $i = 0 ; $i < $strlength ; $i ++ ) {
2019-11-26 12:52:04 +01:00
$output_tab [ $i ] = chr ( ord ( substr ( $chain , $i , 1 )) + 17 );
2018-04-19 12:03:42 +02:00
}
2019-01-27 11:55:16 +01:00
$chain = implode ( " " , $output_tab );
2021-02-23 22:03:23 +01:00
} elseif ( $key ) {
2019-11-26 12:52:04 +01:00
$result = '' ;
$strlength = dol_strlen ( $chain );
2021-02-23 22:03:23 +01:00
for ( $i = 0 ; $i < $strlength ; $i ++ ) {
2019-11-26 12:52:04 +01:00
$keychar = substr ( $key , ( $i % strlen ( $key )) - 1 , 1 );
$result .= chr ( ord ( substr ( $chain , $i , 1 )) + ( ord ( $keychar ) - 65 ));
2018-04-19 12:03:42 +02:00
}
2019-11-26 12:52:04 +01:00
$chain = $result ;
2008-04-29 23:13:49 +02:00
}
2018-04-19 12:03:42 +02:00
return base64_encode ( $chain );
2008-04-29 23:13:49 +02:00
}
/**
2018-04-19 12:03:42 +02:00
* Decode a base 64 encoded + specific delta change .
2012-02-19 19:14:17 +01:00
* This function is called by filefunc . inc . php at each page call .
2011-09-16 19:06:10 +02:00
*
2012-02-19 19:14:17 +01:00
* @ param string $chain string to decode
2018-04-19 12:03:42 +02:00
* @ param string $key rule to use for delta ( '0' , '1' or 'myownkey' )
2012-02-19 19:14:17 +01:00
* @ return string decoded string
2019-03-11 01:01:15 +01:00
* @ see dol_encode ()
2008-04-29 23:13:49 +02:00
*/
2019-01-27 15:20:16 +01:00
function dol_decode ( $chain , $key = '1' )
2008-04-29 23:13:49 +02:00
{
$chain = base64_decode ( $chain );
2021-02-23 22:03:23 +01:00
if ( is_numeric ( $key ) && $key == '1' ) { // rule 1 is offset of 17 for char
2019-11-26 12:52:04 +01:00
$output_tab = array ();
$strlength = dol_strlen ( $chain );
2021-02-23 22:03:23 +01:00
for ( $i = 0 ; $i < $strlength ; $i ++ ) {
2019-11-26 12:52:04 +01:00
$output_tab [ $i ] = chr ( ord ( substr ( $chain , $i , 1 )) - 17 );
2018-04-19 12:03:42 +02:00
}
2019-01-27 11:55:16 +01:00
$chain = implode ( " " , $output_tab );
2021-02-23 22:03:23 +01:00
} elseif ( $key ) {
2019-11-26 12:52:04 +01:00
$result = '' ;
$strlength = dol_strlen ( $chain );
2021-02-23 22:03:23 +01:00
for ( $i = 0 ; $i < $strlength ; $i ++ ) {
2019-11-26 12:52:04 +01:00
$keychar = substr ( $key , ( $i % strlen ( $key )) - 1 , 1 );
$result .= chr ( ord ( substr ( $chain , $i , 1 )) - ( ord ( $keychar ) - 65 ));
2018-04-19 12:03:42 +02:00
}
2019-11-26 12:52:04 +01:00
$chain = $result ;
2008-04-29 23:13:49 +02:00
}
2018-04-19 12:03:42 +02:00
return $chain ;
2008-04-29 23:13:49 +02:00
}
2022-08-25 02:04:48 +02:00
/**
2024-01-11 10:07:06 +01:00
* Return a string of random bytes ( hexa string ) with length = $length for cryptographic purposes .
2022-08-25 02:04:48 +02:00
*
* @ param int $length Length of random string
* @ return string Random string
*/
function dolGetRandomBytes ( $length )
{
if ( function_exists ( 'random_bytes' )) { // Available with PHP 7 only.
return bin2hex ( random_bytes (( int ) floor ( $length / 2 ))); // the bin2hex will double the number of bytes so we take length / 2
}
return bin2hex ( openssl_random_pseudo_bytes (( int ) floor ( $length / 2 ))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows.
}
2011-05-03 12:53:44 +02:00
/**
2024-01-13 19:48:20 +01:00
* Encode a string with a symmetric encryption . Used to encrypt sensitive data into database .
2023-05-03 12:01:36 +02:00
* Note : If a backup is restored onto another instance with a different $conf -> file -> instance_unique_id , then decoded value will differ .
2023-04-13 23:21:05 +02:00
* This function is called for example by dol_set_const () when saving a sensible data into database configuration table llx_const .
2022-08-24 04:54:02 +02:00
*
2023-09-10 19:29:49 +02:00
* @ param string $chain String to encode
* @ param string $key If '' , we use $conf -> file -> instance_unique_id ( so $dolibarr_main_instance_unique_id in conf . php )
2022-08-24 04:54:02 +02:00
* @ param string $ciphering Default ciphering algorithm
2023-03-13 12:48:25 +01:00
* @ param string $forceseed To force the seed
2022-08-24 04:54:02 +02:00
* @ return string encoded string
2023-06-15 13:37:42 +02:00
* @ since v17
2022-08-24 04:54:02 +02:00
* @ see dolDecrypt (), dol_hash ()
*/
2023-03-13 12:48:25 +01:00
function dolEncrypt ( $chain , $key = '' , $ciphering = 'AES-256-CTR' , $forceseed = '' )
2022-08-24 04:54:02 +02:00
{
2023-05-03 12:01:36 +02:00
global $conf ;
2023-02-08 01:28:14 +01:00
global $dolibarr_disable_dolcrypt_for_debug ;
2022-08-24 04:54:02 +02:00
2022-09-16 15:50:27 +02:00
if ( $chain === '' || is_null ( $chain )) {
2022-08-24 04:54:02 +02:00
return '' ;
}
$reg = array ();
if ( preg_match ( '/^dolcrypt:([^:]+):(.+)$/' , $chain , $reg )) {
2024-01-11 10:07:06 +01:00
// The $chain is already a encrypted string
2022-08-24 04:54:02 +02:00
return $chain ;
}
if ( empty ( $key )) {
2023-05-03 12:01:36 +02:00
$key = $conf -> file -> instance_unique_id ;
2022-08-24 04:54:02 +02:00
}
2023-03-13 12:48:25 +01:00
if ( empty ( $ciphering )) {
$ciphering = 'AES-256-CTR' ;
}
2022-08-24 04:54:02 +02:00
$newchain = $chain ;
2023-02-08 01:28:14 +01:00
if ( function_exists ( 'openssl_encrypt' ) && empty ( $dolibarr_disable_dolcrypt_for_debug )) {
2023-09-26 21:11:23 +02:00
if ( empty ( $key )) {
return $chain ;
}
2023-09-18 22:36:32 +02:00
2022-08-25 02:04:48 +02:00
$ivlen = 16 ;
if ( function_exists ( 'openssl_cipher_iv_length' )) {
$ivlen = openssl_cipher_iv_length ( $ciphering );
2022-08-24 23:41:26 +02:00
}
2022-08-25 02:04:48 +02:00
if ( $ivlen === false || $ivlen < 1 || $ivlen > 32 ) {
$ivlen = 16 ;
}
2023-03-13 12:48:25 +01:00
if ( empty ( $forceseed )) {
$ivseed = dolGetRandomBytes ( $ivlen );
} else {
2023-05-31 12:13:50 +02:00
$ivseed = dol_substr ( md5 ( $forceseed ), 0 , $ivlen , 'ascii' , 1 );
2023-03-13 12:48:25 +01:00
}
2022-08-24 23:41:26 +02:00
2022-11-02 16:58:15 +01:00
$newchain = openssl_encrypt ( $chain , $ciphering , $key , 0 , $ivseed );
2022-08-24 23:41:26 +02:00
return 'dolcrypt:' . $ciphering . ':' . $ivseed . ':' . $newchain ;
2022-08-25 02:04:48 +02:00
} else {
return $chain ;
2022-08-24 04:54:02 +02:00
}
}
/**
2024-01-13 19:48:20 +01:00
* Decode a string with a symmetric encryption . Used to decrypt sensitive data saved into database .
2023-05-03 12:01:36 +02:00
* Note : If a backup is restored onto another instance with a different $conf -> file -> instance_unique_id , then decoded value will differ .
2022-08-24 04:54:02 +02:00
*
2023-10-10 14:49:11 +02:00
* @ param string $chain string to decode
2023-05-03 12:01:36 +02:00
* @ param string $key If '' , we use $conf -> file -> instance_unique_id
2022-08-24 04:54:02 +02:00
* @ return string encoded string
2023-06-15 13:37:42 +02:00
* @ since v17
2022-08-24 04:54:02 +02:00
* @ see dolEncrypt (), dol_hash ()
*/
function dolDecrypt ( $chain , $key = '' )
{
2023-05-03 12:01:36 +02:00
global $conf ;
2022-08-24 04:54:02 +02:00
2022-09-16 15:50:27 +02:00
if ( $chain === '' || is_null ( $chain )) {
2022-08-24 04:54:02 +02:00
return '' ;
}
if ( empty ( $key )) {
2023-10-03 02:00:00 +02:00
if ( ! empty ( $conf -> file -> dolcrypt_key )) {
2023-10-10 14:55:23 +02:00
// If dolcrypt_key is defined, we used it in priority
2023-10-03 02:00:00 +02:00
$key = $conf -> file -> dolcrypt_key ;
} else {
2023-10-10 14:55:23 +02:00
// We fall back on the instance_unique_id
2023-10-03 02:00:00 +02:00
$key = $conf -> file -> instance_unique_id ;
}
2022-08-24 04:54:02 +02:00
}
2023-10-03 00:50:50 +02:00
//var_dump('key='.$key);
2022-08-24 04:54:02 +02:00
$reg = array ();
if ( preg_match ( '/^dolcrypt:([^:]+):(.+)$/' , $chain , $reg )) {
$ciphering = $reg [ 1 ];
if ( function_exists ( 'openssl_decrypt' )) {
2023-02-16 04:25:11 +01:00
if ( empty ( $key )) {
2023-10-03 00:50:50 +02:00
dol_syslog ( " Error dolDecrypt decrypt key is empty " , LOG_WARNING );
2023-10-02 11:48:28 +02:00
return $chain ;
2023-02-16 04:25:11 +01:00
}
2022-08-24 23:41:26 +02:00
$tmpexplode = explode ( ':' , $reg [ 2 ]);
2022-08-25 02:04:48 +02:00
if ( ! empty ( $tmpexplode [ 1 ]) && is_string ( $tmpexplode [ 0 ])) {
2022-11-02 16:58:15 +01:00
$newchain = openssl_decrypt ( $tmpexplode [ 1 ], $ciphering , $key , 0 , $tmpexplode [ 0 ]);
2022-08-24 23:41:26 +02:00
} else {
2024-03-15 22:08:23 +01:00
$newchain = openssl_decrypt ( $tmpexplode [ 0 ], $ciphering , $key , 0 , '' );
2022-08-24 23:41:26 +02:00
}
2022-08-24 04:54:02 +02:00
} else {
2023-10-02 12:53:50 +02:00
dol_syslog ( " Error dolDecrypt openssl_decrypt is not available " , LOG_ERR );
2023-10-02 11:48:28 +02:00
return $chain ;
2022-08-24 04:54:02 +02:00
}
return $newchain ;
} else {
return $chain ;
}
}
/**
* Returns a hash ( non reversible encryption ) of a string .
2024-01-13 19:48:20 +01:00
* If constant MAIN_SECURITY_HASH_ALGO is defined , we use this function as hashing function ( recommended value is 'password_hash' )
* If constant MAIN_SECURITY_SALT is defined , we use it as a salt ( used only if hashing algorithm is something else than 'password_hash' ) .
2011-09-16 19:06:10 +02:00
*
* @ param string $chain String to hash
2023-12-08 23:45:18 +01:00
* @ param string $type Type of hash ( '0' : auto will use MAIN_SECURITY_HASH_ALGO else md5 , '1' : sha1 , '2' : sha1 + md5 , '3' : md5 , '4' : for OpenLdap , '5' : sha256 , '6' : password_hash ) .
* Use 'md5' if hash is not needed for security purpose . For security need , prefer 'auto' .
2024-01-15 20:41:32 +01:00
* @ param int $nosalt Do not include any salt
2011-09-16 19:06:10 +02:00
* @ return string Hash of string
2022-12-13 15:52:07 +01:00
* @ see getRandomPassword (), dol_verifyHash ()
2011-05-03 12:53:44 +02:00
*/
2023-12-16 17:05:32 +01:00
function dol_hash ( $chain , $type = '0' , $nosalt = 0 )
2011-05-03 12:53:44 +02:00
{
2018-01-15 00:33:25 +01:00
// No need to add salt for password_hash
2023-11-27 11:39:32 +01:00
if (( $type == '0' || $type == 'auto' ) && getDolGlobalString ( 'MAIN_SECURITY_HASH_ALGO' ) && getDolGlobalString ( 'MAIN_SECURITY_HASH_ALGO' ) == 'password_hash' && function_exists ( 'password_hash' )) {
2018-02-23 14:38:41 +01:00
return password_hash ( $chain , PASSWORD_DEFAULT );
}
2018-01-15 00:33:25 +01:00
2013-11-04 10:47:24 +01:00
// Salt value
2023-12-16 17:05:32 +01:00
if ( getDolGlobalString ( 'MAIN_SECURITY_SALT' ) && $type != '4' && $type !== 'openldap' && empty ( $nosalt )) {
2023-10-15 15:32:35 +02:00
$chain = getDolGlobalString ( 'MAIN_SECURITY_SALT' ) . $chain ;
2021-02-23 22:03:23 +01:00
}
2013-11-06 16:32:25 +01:00
2021-02-23 22:03:23 +01:00
if ( $type == '1' || $type == 'sha1' ) {
return sha1 ( $chain );
} elseif ( $type == '2' || $type == 'sha1md5' ) {
return sha1 ( md5 ( $chain ));
2023-12-08 23:45:18 +01:00
} elseif ( $type == '3' || $type == 'md5' ) { // For hashing with no need of security
2021-02-23 22:03:23 +01:00
return md5 ( $chain );
2021-11-12 10:10:04 +01:00
} elseif ( $type == '4' || $type == 'openldap' ) {
2021-11-12 13:23:11 +01:00
return dolGetLdapPasswordHash ( $chain , getDolGlobalString ( 'LDAP_PASSWORD_HASH_TYPE' , 'md5' ));
2021-07-30 18:43:35 +02:00
} elseif ( $type == '5' || $type == 'sha256' ) {
2021-02-23 22:03:23 +01:00
return hash ( 'sha256' , $chain );
2021-07-30 18:43:35 +02:00
} elseif ( $type == '6' || $type == 'password_hash' ) {
return password_hash ( $chain , PASSWORD_DEFAULT );
2023-10-08 23:19:49 +02:00
} elseif ( getDolGlobalString ( 'MAIN_SECURITY_HASH_ALGO' ) == 'sha1' ) {
2021-02-23 22:03:23 +01:00
return sha1 ( $chain );
2023-10-08 23:19:49 +02:00
} elseif ( getDolGlobalString ( 'MAIN_SECURITY_HASH_ALGO' ) == 'sha1md5' ) {
2021-02-23 22:03:23 +01:00
return sha1 ( md5 ( $chain ));
}
2014-10-18 16:08:15 +02:00
2017-11-03 20:04:18 +01:00
// No particular encoding defined, use default
2014-10-18 16:08:15 +02:00
return md5 ( $chain );
2011-05-03 12:53:44 +02:00
}
2018-01-15 00:33:25 +01:00
/**
* Compute a hash and compare it to the given one
* For backward compatibility reasons , if the hash is not in the password_hash format , we will try to match against md5 and sha1md5
* If constant MAIN_SECURITY_HASH_ALGO is defined , we use this function as hashing function .
* If constant MAIN_SECURITY_SALT is defined , we use it as a salt .
*
2018-12-04 18:07:02 +01:00
* @ param string $chain String to hash ( not hashed string )
2018-01-15 00:33:25 +01:00
* @ param string $hash hash to compare
2021-11-12 13:06:41 +01:00
* @ param string $type Type of hash ( '0' : auto , '1' : sha1 , '2' : sha1 + md5 , '3' : md5 , '4' : for OpenLdap , '5' : sha256 ) . Use '3' here , if hash is not needed for security purpose , for security need , prefer '0' .
2018-01-15 00:33:25 +01:00
* @ return bool True if the computed hash is the same as the given one
2022-12-13 15:52:07 +01:00
* @ see dol_hash ()
2018-01-15 00:33:25 +01:00
*/
2019-01-27 15:20:16 +01:00
function dol_verifyHash ( $chain , $hash , $type = '0' )
2018-01-15 00:33:25 +01:00
{
2023-11-27 11:39:32 +01:00
if ( $type == '0' && getDolGlobalString ( 'MAIN_SECURITY_HASH_ALGO' ) && getDolGlobalString ( 'MAIN_SECURITY_HASH_ALGO' ) == 'password_hash' && function_exists ( 'password_verify' )) {
2023-03-08 10:48:38 +01:00
if ( ! empty ( $hash [ 0 ]) && $hash [ 0 ] == '$' ) {
2021-02-23 22:03:23 +01:00
return password_verify ( $chain , $hash );
2023-03-26 11:10:46 +02:00
} elseif ( dol_strlen ( $hash ) == 32 ) {
2021-02-23 22:03:23 +01:00
return dol_verifyHash ( $chain , $hash , '3' ); // md5
2023-03-26 11:10:46 +02:00
} elseif ( dol_strlen ( $hash ) == 40 ) {
2021-02-23 22:03:23 +01:00
return dol_verifyHash ( $chain , $hash , '2' ); // sha1md5
}
2018-01-15 00:33:25 +01:00
return false ;
}
return dol_hash ( $chain , $type ) == $hash ;
}
2021-11-12 10:10:04 +01:00
/**
2021-11-12 13:06:41 +01:00
* Returns a specific ldap hash of a password .
2021-11-12 10:10:04 +01:00
*
2021-11-12 13:06:41 +01:00
* @ param string $password Password to hash
2021-11-12 10:10:04 +01:00
* @ param string $type Type of hash
2021-11-12 13:06:41 +01:00
* @ return string Hash of password
2021-11-12 10:10:04 +01:00
*/
2021-11-12 13:06:41 +01:00
function dolGetLdapPasswordHash ( $password , $type = 'md5' )
2021-11-12 10:10:04 +01:00
{
if ( empty ( $type )) {
$type = 'md5' ;
}
2021-11-12 13:06:41 +01:00
$salt = substr ( sha1 ( time ()), 0 , 8 );
2021-11-12 10:10:04 +01:00
if ( $type === 'md5' ) {
2021-11-12 13:06:41 +01:00
return '{MD5}' . base64_encode ( hash ( " md5 " , $password , true )); //For OpenLdap with md5 (based on an unencrypted password in base)
2021-11-12 10:10:04 +01:00
} elseif ( $type === 'md5frommd5' ) {
2021-11-12 13:06:41 +01:00
return '{MD5}' . base64_encode ( hex2bin ( $password )); // Create OpenLDAP MD5 password from Dolibarr MD5 password
2021-11-12 10:10:04 +01:00
} elseif ( $type === 'smd5' ) {
2021-11-12 13:06:41 +01:00
return " { SMD5} " . base64_encode ( hash ( " md5 " , $password . $salt , true ) . $salt );
2021-11-12 10:10:04 +01:00
} elseif ( $type === 'sha' ) {
2021-11-12 13:06:41 +01:00
return '{SHA}' . base64_encode ( hash ( " sha1 " , $password , true ));
2021-11-12 10:10:04 +01:00
} elseif ( $type === 'ssha' ) {
2021-11-12 13:06:41 +01:00
return " { SSHA} " . base64_encode ( hash ( " sha1 " , $password . $salt , true ) . $salt );
} elseif ( $type === 'sha256' ) {
return " { SHA256} " . base64_encode ( hash ( " sha256 " , $password , true ));
} elseif ( $type === 'ssha256' ) {
return " { SSHA256} " . base64_encode ( hash ( " sha256 " , $password . $salt , true ) . $salt );
} elseif ( $type === 'sha384' ) {
return " { SHA384} " . base64_encode ( hash ( " sha384 " , $password , true ));
} elseif ( $type === 'ssha384' ) {
return " { SSHA384} " . base64_encode ( hash ( " sha384 " , $password . $salt , true ) . $salt );
} elseif ( $type === 'sha512' ) {
return " { SHA512} " . base64_encode ( hash ( " sha512 " , $password , true ));
} elseif ( $type === 'ssha512' ) {
return " { SSHA512} " . base64_encode ( hash ( " sha512 " , $password . $salt , true ) . $salt );
2021-11-12 10:10:04 +01:00
} elseif ( $type === 'crypt' ) {
2021-11-12 13:06:41 +01:00
return '{CRYPT}' . crypt ( $password , $salt );
} elseif ( $type === 'clear' ) {
return '{CLEAR}' . $password ; // Just for test, plain text password is not secured !
2021-11-12 10:10:04 +01:00
}
2023-07-12 16:32:50 +02:00
return " " ;
2021-11-12 10:10:04 +01:00
}
2012-02-12 17:41:28 +01:00
/**
* Check permissions of a user to show a page and an object . Check read permission .
2017-05-16 13:27:32 +02:00
* If GETPOST ( 'action' , 'aZ09' ) defined , we also check write and delete permission .
2021-02-19 12:35:26 +01:00
* This method check permission on module then call checkUserAccessToObject () for permission on object ( according to entity and socid of user ) .
2012-02-12 17:41:28 +01:00
*
2022-12-05 03:08:57 +01:00
* @ param User $user User to check
2023-04-03 12:06:16 +02:00
* @ param string $features Features to check ( it must be module name or $object -> element . Can be a 'or' check with 'levela|levelb' .
2022-12-05 03:08:57 +01:00
* Examples : 'societe' , 'contact' , 'produit&service' , 'produit|service' , ... )
* This is used to check permission $user -> rights -> features ->...
2023-04-24 20:11:02 +02:00
* @ param int | string | Object $object Object or Object ID or list of Object ID if we want to check a particular record ( optional ) is linked to a owned thirdparty ( optional ) .
2022-12-05 03:08:57 +01:00
* @ param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored . SharedElement is an optional key to define where to check entity for multicompany module . Param not used if objectid is null ( optional ) .
* @ param string $feature2 Feature to check , second level of permission ( optional ) . Can be a 'or' check with 'sublevela|sublevelb' .
* This is used to check permission $user -> rights -> features -> feature2 ...
* @ param string $dbt_keyfield Field name for socid foreign key if not fk_soc . Not used if objectid is null ( optional ) . Can use '' if NA .
2023-03-27 10:00:12 +02:00
* @ param string $dbt_select Field rowid name , for select into tableandshare if not " rowid " . Not used if objectid is null ( optional )
2022-12-05 03:08:57 +01:00
* @ param int $isdraft 1 = The object with id = $objectid is a draft
2024-01-13 19:48:20 +01:00
* @ param int $mode Mode ( 0 = default , 1 = return without dying )
2022-12-05 03:08:57 +01:00
* @ return int If mode = 0 ( default ) : Always 1 , die process if not allowed . If mode = 1 : Return 0 if access not allowed .
2021-02-19 12:35:26 +01:00
* @ see dol_check_secure_access_document (), checkUserAccessToObject ()
2012-02-12 17:41:28 +01:00
*/
2022-12-05 03:08:57 +01:00
function restrictedArea ( User $user , $features , $object = 0 , $tableandshare = '' , $feature2 = '' , $dbt_keyfield = 'fk_soc' , $dbt_select = 'rowid' , $isdraft = 0 , $mode = 0 )
2012-02-12 17:41:28 +01:00
{
2018-05-10 11:30:27 +02:00
global $hookmanager ;
2012-02-12 17:41:28 +01:00
2023-03-27 10:00:12 +02:00
// Define $objectid
2022-12-05 03:08:57 +01:00
if ( is_object ( $object )) {
$objectid = $object -> id ;
} else {
$objectid = $object ; // $objectid can be X or 'X,Y,Z'
}
2023-06-15 11:29:14 +02:00
if ( $objectid == " -1 " ) {
$objectid = 0 ;
}
2023-01-31 21:17:06 +01:00
if ( $objectid ) {
$objectid = preg_replace ( '/[^0-9\.\,]/' , '' , $objectid ); // For the case value is coming from a non sanitized user input
}
2022-03-01 18:46:55 +01:00
2021-02-19 12:35:26 +01:00
//dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft");
2023-05-10 04:11:41 +02:00
/* print " user_id= " . $user -> id . " , features= " . $features . " , feature2= " . $feature2 . " , objectid= " . $objectid ;
print " , dbtablename= " . $tableandshare . " , dbt_socfield= " . $dbt_keyfield . " , dbt_select= " . $dbt_select ;
2023-09-05 16:50:23 +02:00
print " , perm: user->hasRight( " . $features . ( $feature2 ? " , " . $feature2 : " " ) . " , lire) = " . ( $feature2 ? $user -> hasRight ( $features , $feature2 , 'lire' ) : $user -> hasRight ( $features , 'lire' )) . " <br> " ;
2023-05-10 04:11:41 +02:00
*/
2012-02-12 17:41:28 +01:00
2020-06-07 23:00:38 +02:00
$parentfortableentity = '' ;
2023-12-08 23:45:18 +01:00
// Fix syntax of $features param to support non standard module names.
2021-02-19 12:35:26 +01:00
$originalfeatures = $features ;
2023-03-27 10:00:12 +02:00
if ( $features == 'agenda' ) {
$tableandshare = 'actioncomm&societe' ;
$feature2 = 'myactions|allactions' ;
$dbt_select = 'id' ;
}
2023-06-11 01:07:21 +02:00
if ( $features == 'bank' ) {
$features = 'banque' ;
}
2021-02-23 22:03:23 +01:00
if ( $features == 'facturerec' ) {
$features = 'facture' ;
}
2023-09-05 19:13:51 +02:00
if ( $features == 'supplier_invoicerec' ) {
$features = 'fournisseur' ;
$feature2 = 'facture' ;
}
2021-02-23 22:03:23 +01:00
if ( $features == 'mo' ) {
$features = 'mrp' ;
}
if ( $features == 'member' ) {
$features = 'adherent' ;
}
if ( $features == 'subscription' ) {
2021-03-01 20:37:16 +01:00
$features = 'adherent' ;
$feature2 = 'cotisation' ;
2022-12-30 19:40:16 +01:00
}
2023-04-03 12:06:16 +02:00
if ( $features == 'website' && is_object ( $object ) && $object -> element == 'websitepage' ) {
2021-03-01 20:37:16 +01:00
$parentfortableentity = 'fk_website@website' ;
2021-02-23 22:03:23 +01:00
}
if ( $features == 'project' ) {
$features = 'projet' ;
}
if ( $features == 'product' ) {
$features = 'produit' ;
}
2023-04-01 14:38:07 +02:00
if ( $features == 'productbatch' ) {
$features = 'produit' ;
}
2023-05-04 17:28:42 +02:00
if ( $features == 'tax' ) {
$feature2 = 'charges' ;
}
2023-06-28 15:15:37 +02:00
if ( $features == 'workstation' ) {
$feature2 = 'workstation' ;
}
2023-04-24 20:11:02 +02:00
if ( $features == 'fournisseur' ) { // When vendor invoice and purchase order are into module 'fournisseur'
2023-03-26 20:51:51 +02:00
$features = 'fournisseur' ;
2023-04-24 20:11:02 +02:00
if ( is_object ( $object ) && $object -> element == 'invoice_supplier' ) {
2023-03-26 20:51:51 +02:00
$feature2 = 'facture' ;
2023-04-24 20:11:02 +02:00
} elseif ( is_object ( $object ) && $object -> element == 'order_supplier' ) {
2023-03-26 20:51:51 +02:00
$feature2 = 'commande' ;
}
}
2023-09-26 14:54:15 +02:00
if ( $features == 'payment_sc' ) {
$tableandshare = 'paiementcharge' ;
$parentfortableentity = 'fk_charge@chargesociales' ;
}
2021-12-13 16:53:34 +01:00
2023-03-27 10:00:12 +02:00
//print $features.' - '.$tableandshare.' - '.$feature2.' - '.$dbt_select."\n";
2018-05-10 11:30:27 +02:00
// Get more permissions checks from hooks
2024-03-15 22:08:23 +01:00
$parameters = array ( 'features' => $features , 'originalfeatures' => $originalfeatures , 'objectid' => $objectid , 'dbt_select' => $dbt_select , 'idtype' => $dbt_select , 'isdraft' => $isdraft );
2023-09-08 05:51:06 +02:00
if ( ! empty ( $hookmanager )) {
$reshook = $hookmanager -> executeHooks ( 'restrictedArea' , $parameters );
if ( isset ( $hookmanager -> resArray [ 'result' ])) {
if ( $hookmanager -> resArray [ 'result' ] == 0 ) {
if ( $mode ) {
return 0 ;
} else {
accessforbidden (); // Module returns 0, so access forbidden
}
2021-05-21 18:53:09 +02:00
}
2021-02-23 22:03:23 +01:00
}
2023-09-08 05:51:06 +02:00
if ( $reshook > 0 ) { // No other test done.
return 1 ;
}
2020-03-08 18:26:41 +01:00
}
2018-05-10 12:29:58 +02:00
2024-02-16 23:56:07 +01:00
// Features/modules to check (to support the & and | operator)
2018-10-29 18:19:40 +01:00
$featuresarray = array ( $features );
2021-02-23 22:03:23 +01:00
if ( preg_match ( '/&/' , $features )) {
$featuresarray = explode ( " & " , $features );
} elseif ( preg_match ( '/\|/' , $features )) {
$featuresarray = explode ( " | " , $features );
}
2012-02-12 17:41:28 +01:00
2018-10-29 18:19:40 +01:00
// More subfeatures to check
2021-02-23 22:03:23 +01:00
if ( ! empty ( $feature2 )) {
$feature2 = explode ( " | " , $feature2 );
}
2012-02-12 17:41:28 +01:00
2023-12-13 15:20:53 +01:00
$listofmodules = explode ( ',' , getDolGlobalString ( 'MAIN_MODULES_FOR_EXTERNAL' ));
2013-01-02 18:43:59 +01:00
// Check read permission from module
2021-03-01 20:37:16 +01:00
$readok = 1 ;
$nbko = 0 ;
2020-06-29 13:48:00 +02:00
foreach ( $featuresarray as $feature ) { // first we check nb of test ko
2019-11-26 12:52:04 +01:00
$featureforlistofmodule = $feature ;
2021-02-23 22:03:23 +01:00
if ( $featureforlistofmodule == 'produit' ) {
$featureforlistofmodule = 'product' ;
}
2023-05-15 14:03:37 +02:00
if ( $featureforlistofmodule == 'supplier_proposal' ) {
$featureforlistofmodule = 'supplierproposal' ;
}
2023-11-27 11:39:32 +01:00
if ( ! empty ( $user -> socid ) && getDolGlobalString ( 'MAIN_MODULES_FOR_EXTERNAL' ) && ! in_array ( $featureforlistofmodule , $listofmodules )) { // If limits on modules for external users, module must be into list of modules for external users
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2018-10-29 18:19:40 +01:00
continue ;
}
2012-02-12 17:41:28 +01:00
2023-06-29 13:16:44 +02:00
if ( $feature == 'societe' && ( empty ( $feature2 ) || ! in_array ( 'contact' , $feature2 ))) {
2022-12-05 03:08:57 +01:00
if ( ! $user -> hasRight ( 'societe' , 'lire' ) && ! $user -> hasRight ( 'fournisseur' , 'lire' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2023-06-29 13:16:44 +02:00
} elseif (( $feature == 'societe' && ( ! empty ( $feature2 ) && in_array ( 'contact' , $feature2 ))) || $feature == 'contact' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'societe' , 'contact' , 'lire' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'produit|service' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'produit' , 'lire' ) && ! $user -> hasRight ( 'service' , 'lire' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'prelevement' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'prelevement' , 'bons' , 'lire' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'cheque' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'banque' , 'cheque' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'projet' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'projet' , 'lire' ) && ! $user -> hasRight ( 'projet' , 'all' , 'lire' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2021-02-19 12:35:26 +01:00
} elseif ( $feature == 'payment' ) {
2023-06-19 23:18:13 +02:00
if ( ! $user -> hasRight ( 'facture' , 'lire' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2021-02-19 12:35:26 +01:00
} elseif ( $feature == 'payment_supplier' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'fournisseur' , 'facture' , 'lire' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2023-01-03 19:16:38 +01:00
} elseif ( $feature == 'payment_sc' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'tax' , 'charges' , 'lire' )) {
2023-01-03 19:16:38 +01:00
$readok = 0 ;
$nbko ++ ;
}
2023-03-21 18:27:32 +01:00
} elseif ( ! empty ( $feature2 )) { // This is for permissions on 2 levels (module->object->read)
2019-11-26 12:52:04 +01:00
$tmpreadok = 1 ;
2020-06-29 13:48:00 +02:00
foreach ( $feature2 as $subfeature ) {
2021-02-23 22:03:23 +01:00
if ( $subfeature == 'user' && $user -> id == $objectid ) {
continue ; // A user can always read its own card
}
2023-04-24 10:00:45 +02:00
if ( $subfeature == 'fiscalyear' && $user -> hasRight ( 'accounting' , 'fiscalyear' , 'write' )) {
// only one right for fiscalyear
$tmpreadok = 1 ;
continue ;
}
2023-10-15 15:32:35 +02:00
if ( ! empty ( $subfeature ) && ! $user -> hasRight ( $feature , $subfeature , 'lire' ) && ! $user -> hasRight ( $feature , $subfeature , 'read' )) {
2021-02-23 22:03:23 +01:00
$tmpreadok = 0 ;
2023-10-15 15:32:35 +02:00
} elseif ( empty ( $subfeature ) && ! $user -> hasRight ( $feature , 'lire' ) && ! $user -> hasRight ( $feature , 'read' )) {
2021-02-23 22:03:23 +01:00
$tmpreadok = 0 ;
} else {
2021-03-01 20:37:16 +01:00
$tmpreadok = 1 ;
break ;
2021-02-23 22:03:23 +01:00
} // Break is to bypass second test if the first is ok
2018-10-29 18:19:40 +01:00
}
2020-06-29 13:48:00 +02:00
if ( ! $tmpreadok ) { // We found a test on feature that is ko
2019-11-26 12:52:04 +01:00
$readok = 0 ; // All tests are ko (we manage here the and, the or will be managed later using $nbko).
2018-10-29 18:19:40 +01:00
$nbko ++ ;
}
2023-03-21 18:27:32 +01:00
} elseif ( ! empty ( $feature ) && ( $feature != 'user' && $feature != 'usergroup' )) { // This is permissions on 1 level (module->read)
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( $feature , 'lire' )
&& ! $user -> hasRight ( $feature , 'read' )
&& ! $user -> hasRight ( $feature , 'run' )) {
2021-03-01 20:37:16 +01:00
$readok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2018-10-29 18:19:40 +01:00
}
}
2014-05-10 18:57:04 +02:00
2018-10-29 18:19:40 +01:00
// If a or and at least one ok
2021-02-23 22:03:23 +01:00
if ( preg_match ( '/\|/' , $features ) && $nbko < count ( $featuresarray )) {
$readok = 1 ;
}
2012-02-12 17:41:28 +01:00
2021-02-23 22:03:23 +01:00
if ( ! $readok ) {
2021-05-21 18:53:09 +02:00
if ( $mode ) {
return 0 ;
} else {
accessforbidden ();
}
2021-02-23 22:03:23 +01:00
}
2018-10-29 18:19:40 +01:00
//print "Read access is ok";
2012-02-12 17:41:28 +01:00
2020-06-17 13:29:43 +02:00
// Check write permission from module (we need to know write permission to create but also to delete drafts record or to upload files)
2021-03-01 20:37:16 +01:00
$createok = 1 ;
$nbko = 0 ;
2023-06-19 03:22:40 +02:00
$wemustcheckpermissionforcreate = ( GETPOST ( 'sendit' , 'alpha' ) || GETPOST ( 'linkit' , 'alpha' ) || in_array ( GETPOST ( 'action' , 'aZ09' ), array ( 'create' , 'update' , 'set' , 'upload' , 'add_element_resource' , 'confirm_deletebank' , 'confirm_delete_linked_resource' )) || GETPOST ( 'roworder' , 'alpha' , 2 ));
2020-06-17 13:29:43 +02:00
$wemustcheckpermissionfordeletedraft = (( GETPOST ( " action " , " aZ09 " ) == 'confirm_delete' && GETPOST ( " confirm " , " aZ09 " ) == 'yes' ) || GETPOST ( " action " , " aZ09 " ) == 'delete' );
2021-02-23 22:03:23 +01:00
if ( $wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft ) {
foreach ( $featuresarray as $feature ) {
2020-06-29 13:48:00 +02:00
if ( $feature == 'contact' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'societe' , 'contact' , 'creer' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'produit|service' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'produit' , 'creer' ) && ! $user -> hasRight ( 'service' , 'creer' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'prelevement' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'prelevement' , 'bons' , 'creer' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'commande_fournisseur' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'fournisseur' , 'commande' , 'creer' ) || ! $user -> hasRight ( 'supplier_order' , 'creer' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'banque' ) {
2023-06-19 20:54:08 +02:00
if ( ! $user -> hasRight ( 'banque' , 'modifier' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'cheque' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'banque' , 'cheque' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-25 16:59:48 +02:00
} elseif ( $feature == 'import' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'import' , 'run' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2020-06-29 13:48:00 +02:00
} elseif ( $feature == 'ecm' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'ecm' , 'upload' )) {
2021-03-01 20:37:16 +01:00
$createok = 0 ;
$nbko ++ ;
2021-02-23 22:03:23 +01:00
}
2023-07-13 17:13:43 +02:00
} elseif ( $feature == 'modulebuilder' ) {
if ( ! $user -> hasRight ( 'modulebuilder' , 'run' )) {
$createok = 0 ;
$nbko ++ ;
}
2023-03-21 18:27:32 +01:00
} elseif ( ! empty ( $feature2 )) { // This is for permissions on 2 levels (module->object->write)
2020-06-29 13:48:00 +02:00
foreach ( $feature2 as $subfeature ) {
2023-06-05 23:49:13 +02:00
if ( $subfeature == 'user' && $user -> id == $objectid && $user -> hasRight ( 'user' , 'self' , 'creer' )) {
2021-02-23 22:03:23 +01:00
continue ; // User can edit its own card
}
2023-06-05 23:49:13 +02:00
if ( $subfeature == 'user' && $user -> id == $objectid && $user -> hasRight ( 'user' , 'self' , 'password' )) {
2021-02-23 22:03:23 +01:00
continue ; // User can edit its own password
}
2023-06-05 23:49:13 +02:00
if ( $subfeature == 'user' && $user -> id != $objectid && $user -> hasRight ( 'user' , 'user' , 'password' )) {
2021-10-21 18:20:06 +02:00
continue ; // User can edit another user's password
2021-10-21 18:17:43 +02:00
}
2020-02-12 17:28:18 +01:00
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( $feature , $subfeature , 'creer' )
&& ! $user -> hasRight ( $feature , $subfeature , 'write' )
&& ! $user -> hasRight ( $feature , $subfeature , 'create' )) {
2019-11-26 12:52:04 +01:00
$createok = 0 ;
2019-10-27 11:53:20 +01:00
$nbko ++ ;
} else {
2019-11-26 12:52:04 +01:00
$createok = 1 ;
2019-10-27 11:53:20 +01:00
// Break to bypass second test if the first is ok
break ;
}
2018-10-29 18:19:40 +01:00
}
2023-03-21 18:27:32 +01:00
} elseif ( ! empty ( $feature )) { // This is for permissions on 1 levels (module->write)
2020-06-29 13:48:00 +02:00
//print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; exit;
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( $feature , 'creer' )
&& ! $user -> hasRight ( $feature , 'write' )
&& ! $user -> hasRight ( $feature , 'create' )) {
2019-11-26 12:52:04 +01:00
$createok = 0 ;
2019-10-27 11:53:20 +01:00
$nbko ++ ;
}
2018-10-29 18:19:40 +01:00
}
}
2012-02-12 17:41:28 +01:00
2018-10-29 18:19:40 +01:00
// If a or and at least one ok
2021-02-23 22:03:23 +01:00
if ( preg_match ( '/\|/' , $features ) && $nbko < count ( $featuresarray )) {
$createok = 1 ;
}
2012-02-12 17:41:28 +01:00
2021-02-23 22:03:23 +01:00
if ( $wemustcheckpermissionforcreate && ! $createok ) {
2021-05-21 18:53:09 +02:00
if ( $mode ) {
return 0 ;
} else {
accessforbidden ();
}
2021-02-23 22:03:23 +01:00
}
2018-10-29 18:19:40 +01:00
//print "Write access is ok";
}
2012-02-12 17:41:28 +01:00
2018-10-29 18:19:40 +01:00
// Check create user permission
2019-11-26 12:52:04 +01:00
$createuserok = 1 ;
2021-02-23 22:03:23 +01:00
if ( GETPOST ( 'action' , 'aZ09' ) == 'confirm_create_user' && GETPOST ( " confirm " , 'aZ09' ) == 'yes' ) {
2023-06-19 20:08:27 +02:00
if ( ! $user -> hasRight ( 'user' , 'user' , 'creer' )) {
2021-02-23 22:03:23 +01:00
$createuserok = 0 ;
}
2018-10-29 18:19:40 +01:00
2021-02-23 22:03:23 +01:00
if ( ! $createuserok ) {
2021-05-21 18:53:09 +02:00
if ( $mode ) {
return 0 ;
} else {
accessforbidden ();
}
2021-02-23 22:03:23 +01:00
}
2018-10-29 18:19:40 +01:00
//print "Create user access is ok";
}
// Check delete permission from module
2021-03-01 20:37:16 +01:00
$deleteok = 1 ;
$nbko = 0 ;
2021-02-23 22:03:23 +01:00
if (( GETPOST ( " action " , " aZ09 " ) == 'confirm_delete' && GETPOST ( " confirm " , " aZ09 " ) == 'yes' ) || GETPOST ( " action " , " aZ09 " ) == 'delete' ) {
foreach ( $featuresarray as $feature ) {
2023-02-04 00:18:30 +01:00
if ( $feature == 'bookmark' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'bookmark' , 'supprimer' )) {
if ( $user -> id != $object -> fk_user || ! $user -> hasRight ( 'bookmark' , 'creer' )) {
2023-02-04 00:18:30 +01:00
$deleteok = 0 ;
}
}
} elseif ( $feature == 'contact' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'societe' , 'contact' , 'supprimer' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
2018-10-29 18:19:40 +01:00
}
2021-02-23 22:03:23 +01:00
} elseif ( $feature == 'produit|service' ) {
2023-06-14 20:23:21 +02:00
if ( ! $user -> hasRight ( 'produit' , 'supprimer' ) && ! $user -> hasRight ( 'service' , 'supprimer' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
} elseif ( $feature == 'commande_fournisseur' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'fournisseur' , 'commande' , 'supprimer' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
2021-10-31 17:06:37 +01:00
} elseif ( $feature == 'payment_supplier' ) { // Permission to delete a payment of an invoice is permission to edit an invoice.
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'fournisseur' , 'facture' , 'creer' )) {
2021-05-11 20:34:46 +02:00
$deleteok = 0 ;
}
2022-05-22 02:30:35 +02:00
} elseif ( $feature == 'payment' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'facture' , 'paiement' )) {
2023-12-04 12:05:28 +01:00
$deleteok = 0 ;
2021-10-26 16:56:56 +02:00
}
2023-01-03 19:16:38 +01:00
} elseif ( $feature == 'payment_sc' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'tax' , 'charges' , 'creer' )) {
2023-01-03 19:16:38 +01:00
$deleteok = 0 ;
}
2021-02-23 22:03:23 +01:00
} elseif ( $feature == 'banque' ) {
2023-06-19 20:54:08 +02:00
if ( ! $user -> hasRight ( 'banque' , 'modifier' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
} elseif ( $feature == 'cheque' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'banque' , 'cheque' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
} elseif ( $feature == 'ecm' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'ecm' , 'upload' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
} elseif ( $feature == 'ftp' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'ftp' , 'write' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
} elseif ( $feature == 'salaries' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'salaries' , 'delete' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
2021-09-21 11:27:41 +02:00
} elseif ( $feature == 'adherent' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'adherent' , 'supprimer' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
2021-12-09 12:54:08 +01:00
} elseif ( $feature == 'paymentbybanktransfer' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'paymentbybanktransfer' , 'create' )) { // There is no delete permission
2021-12-09 12:54:08 +01:00
$deleteok = 0 ;
}
} elseif ( $feature == 'prelevement' ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'prelevement' , 'bons' , 'creer' )) { // There is no delete permission
2021-12-09 12:54:08 +01:00
$deleteok = 0 ;
}
2021-02-23 22:03:23 +01:00
} elseif ( ! empty ( $feature2 )) { // This is for permissions on 2 levels
foreach ( $feature2 as $subfeature ) {
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( $feature , $subfeature , 'supprimer' ) && ! $user -> hasRight ( $feature , $subfeature , 'delete' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
} else {
2021-03-01 20:37:16 +01:00
$deleteok = 1 ;
break ;
2021-02-23 22:03:23 +01:00
} // For bypass the second test if the first is ok
2018-10-29 18:19:40 +01:00
}
2021-02-23 22:03:23 +01:00
} elseif ( ! empty ( $feature )) { // This is used for permissions on 1 level
2018-10-29 18:19:40 +01:00
//print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( $feature , 'supprimer' )
&& ! $user -> hasRight ( $feature , 'delete' )
&& ! $user -> hasRight ( $feature , 'run' )) {
2021-02-23 22:03:23 +01:00
$deleteok = 0 ;
}
2018-10-29 18:19:40 +01:00
}
}
2012-02-12 17:41:28 +01:00
2018-10-29 18:19:40 +01:00
// If a or and at least one ok
2021-02-23 22:03:23 +01:00
if ( preg_match ( '/\|/' , $features ) && $nbko < count ( $featuresarray )) {
$deleteok = 1 ;
}
2018-10-29 18:19:40 +01:00
2021-02-23 22:03:23 +01:00
if ( ! $deleteok && ! ( $isdraft && $createok )) {
2021-05-21 18:53:09 +02:00
if ( $mode ) {
return 0 ;
} else {
accessforbidden ();
}
2021-02-23 22:03:23 +01:00
}
2018-10-29 18:19:40 +01:00
//print "Delete access is ok";
}
2021-05-21 18:53:09 +02:00
// If we have a particular object to check permissions on, we check if $user has permission
// for this given object (link to company, is contact for project, ...)
2021-02-23 22:03:23 +01:00
if ( ! empty ( $objectid ) && $objectid > 0 ) {
2022-12-05 03:08:57 +01:00
$ok = checkUserAccessToObject ( $user , $featuresarray , $object , $tableandshare , $feature2 , $dbt_keyfield , $dbt_select , $parentfortableentity );
Qual: Apply automatic phan fixes (deprecations, unneeded imports) (#28154)
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
2024-02-13 21:46:12 +01:00
$params = array ( 'objectid' => $objectid , 'features' => implode ( ',' , $featuresarray ), 'features2' => $feature2 );
2021-04-29 12:10:55 +02:00
//print 'checkUserAccessToObject ok='.$ok;
2021-05-21 18:53:09 +02:00
if ( $mode ) {
return $ok ? 1 : 0 ;
} else {
2022-12-31 14:01:03 +01:00
if ( $ok ) {
return 1 ;
} else {
accessforbidden ( '' , 1 , 1 , 0 , $params );
}
2021-05-21 18:53:09 +02:00
}
2018-10-29 18:19:40 +01:00
}
return 1 ;
2012-02-12 17:41:28 +01:00
}
2015-05-03 14:41:51 +02:00
/**
2022-01-13 15:52:41 +01:00
* Check that access by a given user to an object is ok .
* This function is also called by restrictedArea () that check before if module is enabled and if permission of user for $action is ok .
2015-05-31 03:30:38 +02:00
*
2022-01-13 15:52:41 +01:00
* @ param User $user User to check
* @ param array $featuresarray Features / modules to check . Example : ( 'user' , 'service' , 'member' , 'project' , 'task' , ... )
* @ param int | string | Object $object Full object or object ID or list of object id . For example if we want to check a particular record ( optional ) is linked to a owned thirdparty ( optional ) .
* @ param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored . SharedElement is an optional key to define where to check entity for multicompany modume . Param not used if objectid is null ( optional ) .
2022-12-05 03:08:57 +01:00
* @ param array | string $feature2 Feature to check , second level of permission ( optional ) . Can be or check with 'level1|level2' .
* @ param string $dbt_keyfield Field name for socid foreign key if not fk_soc . Not used if objectid is null ( optional ) . Can use '' if NA .
* @ param string $dbt_select Field name for select if not rowid . Not used if objectid is null ( optional ) .
2022-01-13 15:52:41 +01:00
* @ param string $parenttableforentity Parent table for entity . Example 'fk_website@website'
* @ return bool True if user has access , False otherwise
2019-03-11 01:01:15 +01:00
* @ see restrictedArea ()
2015-05-03 14:41:51 +02:00
*/
2022-01-13 15:52:41 +01:00
function checkUserAccessToObject ( $user , array $featuresarray , $object = 0 , $tableandshare = '' , $feature2 = '' , $dbt_keyfield = '' , $dbt_select = 'rowid' , $parenttableforentity = '' )
2015-05-03 14:41:51 +02:00
{
global $db , $conf ;
2015-05-31 03:30:38 +02:00
2022-01-13 15:52:41 +01:00
if ( is_object ( $object )) {
$objectid = $object -> id ;
} else {
$objectid = $object ; // $objectid can be X or 'X,Y,Z'
}
2022-12-05 03:08:57 +01:00
$objectid = preg_replace ( '/[^0-9\.\,]/' , '' , $objectid ); // For the case value is coming from a non sanitized user input
2022-01-13 15:52:41 +01:00
2021-02-19 12:35:26 +01:00
//dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft");
2022-12-05 03:08:57 +01:00
//print "user_id=".$user->id.", features=".join(',', $featuresarray).", objectid=".$objectid;
2021-03-23 18:08:44 +01:00
//print ", tableandshare=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select."<br>";
2021-02-19 12:35:26 +01:00
2015-05-03 14:41:51 +02:00
// More parameters
2015-05-13 09:32:54 +02:00
$params = explode ( '&' , $tableandshare );
2019-11-26 12:52:04 +01:00
$dbtablename = ( ! empty ( $params [ 0 ]) ? $params [ 0 ] : '' );
$sharedelement = ( ! empty ( $params [ 1 ]) ? $params [ 1 ] : $dbtablename );
2015-05-31 03:30:38 +02:00
2021-02-23 22:03:23 +01:00
foreach ( $featuresarray as $feature ) {
2019-11-26 12:52:04 +01:00
$sql = '' ;
2015-05-03 14:41:51 +02:00
2022-01-10 19:23:46 +01:00
//var_dump($feature);exit;
2021-04-02 23:23:44 +02:00
2017-02-03 11:42:49 +01:00
// For backward compatibility
2023-06-29 13:16:44 +02:00
if ( $feature == 'societe' && ! empty ( $feature2 ) && is_array ( $feature2 ) && in_array ( 'contact' , $feature2 )) {
2023-06-29 12:10:31 +02:00
$feature = 'contact' ;
$feature2 = '' ;
}
2021-02-23 22:03:23 +01:00
if ( $feature == 'member' ) {
$feature = 'adherent' ;
}
if ( $feature == 'project' ) {
$feature = 'projet' ;
}
if ( $feature == 'task' ) {
$feature = 'projet_task' ;
}
2023-05-10 04:11:41 +02:00
if ( $feature == 'eventorganization' ) {
$feature = 'agenda' ;
$dbtablename = 'actioncomm' ;
}
2024-03-04 14:02:49 +01:00
if ( $feature == 'payment_sc' && empty ( $parenttableforentity )) {
// If we check perm on payment page but $parenttableforentity not defined, we force value on parent table
$parenttableforentity = '' ;
$dbtablename = " chargesociales " ;
2023-05-15 11:09:35 +02:00
$feature = " chargesociales " ;
2023-06-03 13:56:06 +02:00
$objectid = $object -> fk_charge ;
2023-05-15 11:09:35 +02:00
}
2023-06-03 13:56:06 +02:00
2022-01-13 15:52:41 +01:00
$checkonentitydone = 0 ;
// Array to define rules of checks to do
2024-03-17 21:53:32 +01:00
$check = array ( 'adherent' , 'banque' , 'bom' , 'don' , 'mrp' , 'user' , 'usergroup' , 'payment' , 'payment_supplier' , 'payment_sc' , 'product' , 'produit' , 'service' , 'produit|service' , 'categorie' , 'resource' , 'expensereport' , 'holiday' , 'salaries' , 'website' , 'recruitment' , 'chargesociales' , 'knowledgemanagement' ); // Test on entity only (Objects with no link to company)
2022-12-05 03:08:57 +01:00
$checksoc = array ( 'societe' ); // Test for object Societe
2023-06-29 12:10:31 +02:00
$checkparentsoc = array ( 'agenda' , 'contact' , 'contrat' ); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...).
2019-11-26 12:52:04 +01:00
$checkproject = array ( 'projet' , 'project' ); // Test for project object
2021-10-25 22:07:31 +02:00
$checktask = array ( 'projet_task' ); // Test for task object
2022-12-05 03:08:57 +01:00
$checkhierarchy = array ( 'expensereport' , 'holiday' ); // check permission among the hierarchy of user
2023-02-04 10:58:00 +01:00
$checkuser = array ( 'bookmark' ); // check permission among the fk_user (must be myself or null)
2019-11-26 12:52:04 +01:00
$nocheck = array ( 'barcode' , 'stock' ); // No test
2022-12-05 03:08:57 +01:00
2021-02-19 12:35:26 +01:00
//$checkdefault = 'all other not already defined'; // Test on entity + link to third party on field $dbt_keyfield. Not allowed if link is empty (Ex: invoice, orders...).
2015-05-03 14:41:51 +02:00
2017-10-17 12:58:26 +02:00
// If dbtablename not defined, we use same name for table than module name
2021-02-23 22:03:23 +01:00
if ( empty ( $dbtablename )) {
2017-10-17 12:58:26 +02:00
$dbtablename = $feature ;
2019-11-26 12:52:04 +01:00
$sharedelement = ( ! empty ( $params [ 1 ]) ? $params [ 1 ] : $dbtablename ); // We change dbtablename, so we set sharedelement too.
2017-10-17 12:58:26 +02:00
}
2015-05-03 14:41:51 +02:00
2022-12-05 03:08:57 +01:00
// To avoid an access forbidden with a numeric ref
if ( $dbt_select != 'rowid' && $dbt_select != 'id' ) {
$objectid = " ' " . $objectid . " ' " ; // Note: $objectid was already cast into int at begin of this method.
}
2022-08-27 19:02:05 +02:00
// Check permission for objectid on entity only
if ( in_array ( $feature , $check ) && $objectid > 0 ) { // For $objectid = 0, no check
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2022-08-28 13:58:13 +02:00
if (( $feature == 'user' || $feature == 'usergroup' ) && isModEnabled ( 'multicompany' )) { // Special for multicompany
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MULTICOMPANY_TRANSVERSE_MODE' )) {
2021-02-19 12:35:26 +01:00
if ( $conf -> entity == 1 && $user -> admin && ! $user -> entity ) {
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND dbt.entity IS NOT NULL " ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-26 12:52:04 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " usergroup_user as ug " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND ((ug.fk_user = dbt.rowid " ;
$sql .= " AND ug.entity IN ( " . getEntity ( 'usergroup' ) . " )) " ;
$sql .= " OR dbt.entity = 0) " ; // Show always superadmin
2018-07-02 10:09:56 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2018-07-02 10:09:56 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2020-06-07 23:00:38 +02:00
$reg = array ();
if ( $parenttableforentity && preg_match ( '/(.*)@(.*)/' , $parenttableforentity , $reg )) {
$sql .= " , " . MAIN_DB_PREFIX . $reg [ 2 ] . " as dbtp " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $reg [ 1 ] . " = dbtp.rowid AND dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2020-06-07 23:00:38 +02:00
$sql .= " AND dbtp.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
} else {
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2020-06-07 23:00:38 +02:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
}
2015-05-03 14:41:51 +02:00
}
2022-01-13 15:52:41 +01:00
$checkonentitydone = 1 ;
}
2022-08-27 19:02:05 +02:00
if ( in_array ( $feature , $checksoc ) && $objectid > 0 ) { // We check feature = checksoc. For $objectid = 0, no check
2015-05-03 14:41:51 +02:00
// If external user: Check permission for external users
2021-03-19 00:00:06 +01:00
if ( $user -> socid > 0 ) {
2022-01-13 15:52:41 +01:00
if ( $user -> socid != $objectid ) {
2021-03-11 16:37:27 +01:00
return false ;
}
2023-10-15 15:32:35 +02:00
} elseif ( isModEnabled ( " societe " ) && ( $user -> hasRight ( 'societe' , 'lire' ) && ! $user -> hasRight ( 'societe' , 'client' , 'voir' ))) {
2021-03-11 16:37:27 +01:00
// If internal user: Check permission for internal users that are restricted on their objects
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(sc.fk_soc) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM ( " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s) " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE sc.fk_soc IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2024-03-07 22:47:29 +01:00
$sql .= " AND (sc.fk_user = " . (( int ) $user -> id );
if ( getDolGlobalInt ( 'MAIN_SEE_SUBORDINATES' )) {
$userschilds = $user -> getAllChildIds ();
$sql .= " OR sc.fk_user IN ( " . $db -> sanitize ( implode ( ',' , $userschilds )) . " ) " ;
}
$sql .= " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND sc.fk_soc = s.rowid " ;
$sql .= " AND s.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2022-08-28 13:58:13 +02:00
} elseif ( isModEnabled ( 'multicompany' )) {
2021-02-19 12:35:26 +01:00
// If multicompany and internal users with all permissions, check user is in correct entity
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(s.rowid) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE s.rowid IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND s.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2015-05-03 14:41:51 +02:00
}
2022-01-13 15:52:41 +01:00
$checkonentitydone = 1 ;
}
2023-06-29 12:10:31 +02:00
if ( in_array ( $feature , $checkparentsoc ) && $objectid > 0 ) { // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...).
2015-05-03 14:41:51 +02:00
// If external user: Check permission for external users
2021-02-23 22:03:23 +01:00
if ( $user -> socid > 0 ) {
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2021-08-23 17:41:11 +02:00
$sql .= " AND dbt.fk_soc = " . (( int ) $user -> socid );
2023-10-15 15:32:35 +02:00
} elseif ( isModEnabled ( " societe " ) && ( $user -> hasRight ( 'societe' , 'lire' ) && ! $user -> hasRight ( 'societe' , 'client' , 'voir' ))) {
2021-03-01 20:37:16 +01:00
// If internal user: Check permission for internal users that are restricted on their objects
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2020-09-19 22:41:05 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = " . (( int ) $user -> id );
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$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 ) . " ) " ;
2022-08-28 13:58:13 +02:00
} elseif ( isModEnabled ( 'multicompany' )) {
2021-03-01 20:37:16 +01:00
// If multicompany and internal users with all permissions, check user is in correct entity
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2015-05-03 14:41:51 +02:00
}
2022-01-13 15:52:41 +01:00
$checkonentitydone = 1 ;
}
2022-08-27 19:02:05 +02:00
if ( in_array ( $feature , $checkproject ) && $objectid > 0 ) {
2023-10-15 15:32:35 +02:00
if ( isModEnabled ( 'project' ) && ! $user -> hasRight ( 'projet' , 'all' , 'lire' )) {
2022-01-13 15:52:41 +01:00
$projectid = $objectid ;
2015-05-03 14:41:51 +02:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2019-11-26 12:52:04 +01:00
$projectstatic = new Project ( $db );
$tmps = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 , 0 );
2021-05-21 18:53:09 +02:00
2019-11-26 12:52:04 +01:00
$tmparray = explode ( ',' , $tmps );
2022-01-13 15:52:41 +01:00
if ( ! in_array ( $projectid , $tmparray )) {
2021-02-23 22:03:23 +01:00
return false ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2015-05-03 14:41:51 +02:00
}
2022-01-13 15:52:41 +01:00
$checkonentitydone = 1 ;
}
2022-08-27 19:02:05 +02:00
if ( in_array ( $feature , $checktask ) && $objectid > 0 ) {
2023-10-15 15:32:35 +02:00
if ( isModEnabled ( 'project' ) && ! $user -> hasRight ( 'projet' , 'all' , 'lire' )) {
2018-10-29 18:19:40 +01:00
$task = new Task ( $db );
$task -> fetch ( $objectid );
2022-01-13 15:52:41 +01:00
$projectid = $task -> fk_project ;
2017-06-01 19:53:12 +02:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2019-11-26 12:52:04 +01:00
$projectstatic = new Project ( $db );
$tmps = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 , 0 );
2022-01-13 15:52:41 +01:00
2019-11-26 12:52:04 +01:00
$tmparray = explode ( ',' , $tmps );
2022-01-13 15:52:41 +01:00
if ( ! in_array ( $projectid , $tmparray )) {
2021-02-23 22:03:23 +01:00
return false ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2015-05-03 14:41:51 +02:00
}
2022-01-13 15:52:41 +01:00
$checkonentitydone = 1 ;
}
2023-06-03 13:56:06 +02:00
//var_dump($sql);
2023-04-27 16:19:35 +02:00
2022-08-27 19:02:05 +02:00
if ( ! $checkonentitydone && ! in_array ( $feature , $nocheck ) && $objectid > 0 ) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
2015-05-03 14:41:51 +02:00
// If external user: Check permission for external users
2021-02-02 00:19:41 +01:00
if ( $user -> socid > 0 ) {
2021-02-23 22:03:23 +01:00
if ( empty ( $dbt_keyfield )) {
2024-01-20 09:22:38 +01:00
dol_print_error ( null , 'Param dbt_keyfield is required but not defined' );
2021-02-23 22:03:23 +01:00
}
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_keyfield . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt.rowid IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2021-08-23 18:56:46 +02:00
$sql .= " AND dbt. " . $dbt_keyfield . " = " . (( int ) $user -> socid );
2023-10-15 15:32:35 +02:00
} elseif ( isModEnabled ( " societe " ) && ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2023-04-27 16:19:35 +02:00
// If internal user without permission to see all thirdparties: Check permission for internal users that are restricted on their objects
2021-02-09 20:13:13 +01:00
if ( $feature != 'ticket' ) {
2021-02-23 22:03:23 +01:00
if ( empty ( $dbt_keyfield )) {
2024-01-20 09:22:38 +01:00
dol_print_error ( null , 'Param dbt_keyfield is required but not defined' );
2021-02-23 22:03:23 +01:00
}
2021-02-02 00:19:41 +01:00
$sql = " SELECT COUNT(sc.fk_soc) as nb " ;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2021-02-02 00:19:41 +01:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
$sql .= " AND sc.fk_soc = dbt. " . $dbt_keyfield ;
2024-03-07 22:47:29 +01:00
$sql .= " AND (sc.fk_user = " . (( int ) $user -> id );
if ( getDolGlobalInt ( 'MAIN_SEE_SUBORDINATES' )) {
$userschilds = $user -> getAllChildIds ();
foreach ( $userschilds as $key => $value ) {
$sql .= ' OR sc.fk_user = ' . (( int ) $value );
}
}
$sql .= ')' ;
2021-02-09 20:13:13 +01:00
} else {
2021-02-10 14:04:06 +01:00
// On ticket, the thirdparty is not mandatory, so we need a special test to accept record with no thirdparties.
2021-02-02 00:19:41 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2021-08-23 17:41:11 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON sc.fk_soc = dbt. " . $dbt_keyfield . " AND sc.fk_user = " . (( int ) $user -> id );
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2021-02-02 00:19:41 +01:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2021-08-23 17:41:11 +02:00
$sql .= " AND (sc.fk_user = " . (( int ) $user -> id ) . " OR sc.fk_user IS NULL) " ;
2021-02-02 00:19:41 +01:00
}
2022-08-28 13:58:13 +02:00
} elseif ( isModEnabled ( 'multicompany' )) {
2023-04-27 16:19:35 +02:00
// If multicompany, and user is an internal user with all permissions, check that object is in correct entity
2017-12-18 15:39:40 +01:00
$sql = " SELECT COUNT(dbt. " . $dbt_select . " ) as nb " ;
2019-11-26 12:52:04 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt " ;
2021-03-22 11:30:18 +01:00
$sql .= " WHERE dbt. " . $dbt_select . " IN ( " . $db -> sanitize ( $objectid , 1 ) . " ) " ;
2019-11-26 12:52:04 +01:00
$sql .= " AND dbt.entity IN ( " . getEntity ( $sharedelement , 1 ) . " ) " ;
2015-05-03 14:41:51 +02:00
}
}
2022-01-13 15:52:41 +01:00
// For events, check on users assigned to event
2022-08-27 19:02:05 +02:00
if ( $feature === 'agenda' && $objectid > 0 ) {
2022-01-13 15:52:41 +01:00
// Also check owner or attendee for users without allactions->read
2023-10-15 15:32:35 +02:00
if ( $objectid > 0 && ! $user -> hasRight ( 'agenda' , 'allactions' , 'read' )) {
2022-01-13 15:52:41 +01:00
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
$action = new ActionComm ( $db );
$action -> fetch ( $objectid );
if ( $action -> authorid != $user -> id && $action -> userownerid != $user -> id && ! ( array_key_exists ( $user -> id , $action -> userassigned ))) {
return false ;
}
}
}
// For some object, we also have to check it is in the user hierarchy
// Param $object must be the full object and not a simple id to have this test possible.
2022-08-27 19:02:05 +02:00
if ( in_array ( $feature , $checkhierarchy ) && is_object ( $object ) && $objectid > 0 ) {
2022-01-13 15:52:41 +01:00
$childids = $user -> getAllChildIds ( 1 );
$useridtocheck = 0 ;
if ( $feature == 'holiday' ) {
$useridtocheck = $object -> fk_user ;
2023-11-21 16:20:21 +01:00
if ( ! $user -> hasRight ( 'holiday' , 'readall' ) && ! in_array ( $useridtocheck , $childids ) && ! in_array ( $object -> fk_validator , $childids )) {
2022-01-13 15:52:41 +01:00
return false ;
}
}
if ( $feature == 'expensereport' ) {
$useridtocheck = $object -> fk_user_author ;
2023-10-15 15:32:35 +02:00
if ( ! $user -> hasRight ( 'expensereport' , 'readall' )) {
2022-02-15 09:51:28 +01:00
if ( ! in_array ( $useridtocheck , $childids )) {
return false ;
}
2022-01-13 15:52:41 +01:00
}
}
}
2023-02-04 10:58:00 +01:00
// For some object, we also have to check it is public or owned by user
// Param $object must be the full object and not a simple id to have this test possible.
if ( in_array ( $feature , $checkuser ) && is_object ( $object ) && $objectid > 0 ) {
$useridtocheck = $object -> fk_user ;
if ( ! empty ( $useridtocheck ) && $useridtocheck > 0 && $useridtocheck != $user -> id && empty ( $user -> admin )) {
return false ;
}
}
2021-02-23 22:03:23 +01:00
if ( $sql ) {
2019-11-26 12:52:04 +01:00
$resql = $db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2017-12-18 15:39:40 +01:00
$obj = $db -> fetch_object ( $resql );
2022-01-13 15:52:41 +01:00
if ( ! $obj || $obj -> nb < count ( explode ( ',' , $objectid ))) { // error if we found 0 or less record than nb of id provided
2021-02-23 22:03:23 +01:00
return false ;
}
2020-05-21 15:05:19 +02:00
} else {
2021-03-23 18:02:52 +01:00
dol_syslog ( " Bad forged sql in checkUserAccessToObject " , LOG_WARNING );
2015-05-03 14:41:51 +02:00
return false ;
}
}
}
2020-06-07 23:00:38 +02:00
2015-05-03 14:41:51 +02:00
return true ;
}
2012-02-12 17:41:28 +01:00
2022-09-09 11:55:45 +02:00
/**
* Show a message to say access is forbidden and stop program .
* This includes only HTTP header .
* Calling this function terminate execution of PHP .
*
2022-09-09 13:58:54 +02:00
* @ param string $message Force error message
* @ param int $http_response_code HTTP response code
* @ param int $stringalreadysanitized 1 if string is already sanitized with HTML entities
2022-09-09 11:55:45 +02:00
* @ return void
* @ see accessforbidden ()
*/
2024-01-15 20:41:32 +01:00
function httponly_accessforbidden ( $message = '1' , $http_response_code = 403 , $stringalreadysanitized = 0 )
2022-09-09 11:55:45 +02:00
{
2022-09-09 13:58:54 +02:00
top_httphead ();
2022-09-09 11:55:45 +02:00
http_response_code ( $http_response_code );
2022-09-09 13:58:54 +02:00
if ( $stringalreadysanitized ) {
print $message ;
} else {
print htmlentities ( $message );
}
2022-09-09 11:55:45 +02:00
exit ( 1 );
}
2012-02-12 17:41:28 +01:00
/**
2022-09-09 11:55:45 +02:00
* Show a message to say access is forbidden and stop program .
2022-09-09 13:58:54 +02:00
* This includes HTTP and HTML header and footer ( except if $printheader and $printfooter is 0 , use this case inside an already started page ) .
2012-02-12 17:41:28 +01:00
* Calling this function terminate execution of PHP .
*
2019-11-22 16:13:22 +01:00
* @ param string $message Force error message
* @ param int $printheader Show header before
* @ param int $printfooter Show footer after
* @ param int $showonlymessage Show only message parameter . Otherwise add more information .
2020-12-03 16:22:03 +01:00
* @ param array | null $params More parameters provided to hook
2012-02-12 17:41:28 +01:00
* @ return void
2022-09-09 11:55:45 +02:00
* @ see httponly_accessforbidden ()
2012-02-12 17:41:28 +01:00
*/
2019-11-22 16:13:22 +01:00
function accessforbidden ( $message = '' , $printheader = 1 , $printfooter = 1 , $showonlymessage = 0 , $params = null )
2012-02-12 17:41:28 +01:00
{
2020-10-31 14:32:18 +01:00
global $conf , $db , $user , $langs , $hookmanager ;
2023-03-26 17:59:28 +02:00
global $action , $object ;
2022-09-09 11:55:45 +02:00
2021-02-23 22:03:23 +01:00
if ( ! is_object ( $langs )) {
2020-10-31 14:32:18 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php' ;
$langs = new Translate ( '' , $conf );
$langs -> setDefaultLang ();
}
2012-02-12 17:41:28 +01:00
2023-08-09 16:02:27 +02:00
$langs -> loadLangs ( array ( " main " , " errors " ));
2012-02-12 17:41:28 +01:00
2024-02-14 03:38:17 +01:00
if ( $printheader && ! defined ( 'NOHEADERNOFOOTER' )) {
2021-02-23 22:03:23 +01:00
if ( function_exists ( " llxHeader " )) {
llxHeader ( '' );
} elseif ( function_exists ( " llxHeaderVierge " )) {
llxHeaderVierge ( '' );
}
2023-08-09 16:02:27 +02:00
print '<div style="padding: 20px">' ;
2018-10-29 18:19:40 +01:00
}
print '<div class="error">' ;
2022-09-09 13:58:54 +02:00
if ( empty ( $message )) {
2021-02-23 22:03:23 +01:00
print $langs -> trans ( " ErrorForbidden " );
} else {
2022-09-09 11:55:45 +02:00
print $langs -> trans ( $message );
2021-02-23 22:03:23 +01:00
}
2018-10-29 18:19:40 +01:00
print '</div>' ;
print '<br>' ;
2021-02-23 22:03:23 +01:00
if ( empty ( $showonlymessage )) {
if ( empty ( $hookmanager )) {
2023-03-26 17:59:28 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php' ;
2019-06-04 12:48:06 +02:00
$hookmanager = new HookManager ( $db );
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager -> initHooks ( array ( 'main' ));
2018-10-29 18:19:40 +01:00
}
2023-03-26 17:59:28 +02:00
2024-03-15 22:08:23 +01:00
$parameters = array ( 'message' => $message , 'params' => $params );
2019-11-26 12:52:04 +01:00
$reshook = $hookmanager -> executeHooks ( 'getAccessForbiddenMessage' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2019-06-04 12:48:06 +02:00
print $hookmanager -> resPrint ;
2021-02-23 22:03:23 +01:00
if ( empty ( $reshook )) {
2021-12-10 12:36:51 +01:00
$langs -> loadLangs ( array ( " errors " ));
2021-02-23 22:03:23 +01:00
if ( $user -> login ) {
2021-10-05 09:46:48 +02:00
print $langs -> trans ( " CurrentLogin " ) . ': <span class="error">' . $user -> login . '</span><br>' ;
2019-06-04 19:18:20 +02:00
print $langs -> trans ( " ErrorForbidden2 " , $langs -> transnoentitiesnoconv ( " Home " ), $langs -> transnoentitiesnoconv ( " Users " ));
2021-12-10 12:36:51 +01:00
print $langs -> trans ( " ErrorForbidden4 " );
2020-05-21 15:05:19 +02:00
} else {
2019-06-04 12:48:06 +02:00
print $langs -> trans ( " ErrorForbidden3 " );
}
2018-10-29 18:19:40 +01:00
}
}
2024-02-14 03:38:17 +01:00
if ( $printfooter && ! defined ( 'NOHEADERNOFOOTER' ) && function_exists ( " llxFooter " )) {
2023-08-09 16:02:27 +02:00
print '</div>' ;
2021-02-23 22:03:23 +01:00
llxFooter ();
}
2022-09-09 11:55:45 +02:00
2018-10-29 18:19:40 +01:00
exit ( 0 );
2012-02-12 17:41:28 +01:00
}
2022-06-19 19:02:16 +02:00
/**
* Return the max allowed for file upload .
* Analyze among : upload_max_filesize , post_max_size , MAIN_UPLOAD_DOC
*
* @ return array Array with all max size for file upload
*/
function getMaxFileSizeArray ()
{
2024-01-05 04:18:53 +01:00
$max = getDolGlobalString ( 'MAIN_UPLOAD_DOC' ); // In Kb
2024-01-09 21:37:53 +01:00
2022-06-19 19:02:16 +02:00
$maxphp = @ ini_get ( 'upload_max_filesize' ); // In unknown
if ( preg_match ( '/k$/i' , $maxphp )) {
$maxphp = preg_replace ( '/k$/i' , '' , $maxphp );
$maxphp = $maxphp * 1 ;
}
if ( preg_match ( '/m$/i' , $maxphp )) {
$maxphp = preg_replace ( '/m$/i' , '' , $maxphp );
$maxphp = $maxphp * 1024 ;
}
if ( preg_match ( '/g$/i' , $maxphp )) {
$maxphp = preg_replace ( '/g$/i' , '' , $maxphp );
$maxphp = $maxphp * 1024 * 1024 ;
}
if ( preg_match ( '/t$/i' , $maxphp )) {
$maxphp = preg_replace ( '/t$/i' , '' , $maxphp );
$maxphp = $maxphp * 1024 * 1024 * 1024 ;
}
$maxphp2 = @ ini_get ( 'post_max_size' ); // In unknown
if ( preg_match ( '/k$/i' , $maxphp2 )) {
$maxphp2 = preg_replace ( '/k$/i' , '' , $maxphp2 );
$maxphp2 = $maxphp2 * 1 ;
}
if ( preg_match ( '/m$/i' , $maxphp2 )) {
$maxphp2 = preg_replace ( '/m$/i' , '' , $maxphp2 );
$maxphp2 = $maxphp2 * 1024 ;
}
if ( preg_match ( '/g$/i' , $maxphp2 )) {
$maxphp2 = preg_replace ( '/g$/i' , '' , $maxphp2 );
$maxphp2 = $maxphp2 * 1024 * 1024 ;
}
if ( preg_match ( '/t$/i' , $maxphp2 )) {
$maxphp2 = preg_replace ( '/t$/i' , '' , $maxphp2 );
$maxphp2 = $maxphp2 * 1024 * 1024 * 1024 ;
}
// Now $max and $maxphp and $maxphp2 are in Kb
$maxmin = $max ;
$maxphptoshow = $maxphptoshowparam = '' ;
if ( $maxphp > 0 ) {
$maxmin = min ( $maxmin , $maxphp );
$maxphptoshow = $maxphp ;
$maxphptoshowparam = 'upload_max_filesize' ;
}
if ( $maxphp2 > 0 ) {
$maxmin = min ( $maxmin , $maxphp2 );
if ( $maxphp2 < $maxphp ) {
$maxphptoshow = $maxphp2 ;
$maxphptoshowparam = 'post_max_size' ;
}
}
//var_dump($maxphp.'-'.$maxphp2);
//var_dump($maxmin);
2024-03-15 22:08:23 +01:00
return array ( 'max' => $max , 'maxmin' => $maxmin , 'maxphptoshow' => $maxphptoshow , 'maxphptoshowparam' => $maxphptoshowparam );
2022-06-19 19:02:16 +02:00
}