mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Bugs reported by scrutinizer
This commit is contained in:
parent
d0fb732cce
commit
d98bfb1d8d
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
|
@ -44,7 +44,7 @@ $action = GETPOST('action', 'alpha');
|
|||
|
||||
// Other parameters ACCOUNTING_*
|
||||
$list = array (
|
||||
'ACCOUNTING_SEPARATORCSV'
|
||||
'ACCOUNTING_SEPARATORCSV'
|
||||
);
|
||||
|
||||
/*
|
||||
|
|
@ -52,26 +52,26 @@ $list = array (
|
|||
*/
|
||||
if ($action == 'update') {
|
||||
$error = 0;
|
||||
|
||||
|
||||
$modelcsv = GETPOST('modelcsv', 'int');
|
||||
|
||||
|
||||
if (! empty($modelcsv)) {
|
||||
|
||||
|
||||
if (! dolibarr_set_const($db, 'ACCOUNTING_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
} else {
|
||||
$error ++;
|
||||
}
|
||||
|
||||
|
||||
foreach ( $list as $constname ) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
|
||||
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $error) {
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
} else {
|
||||
|
|
@ -90,7 +90,7 @@ $form = new Form($db);
|
|||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'setup');
|
||||
|
||||
$head = admin_accounting_prepare_head(null);
|
||||
$head = admin_accounting_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');
|
||||
|
||||
|
|
@ -142,13 +142,13 @@ if ($num) {
|
|||
|
||||
foreach ( $list as $key ) {
|
||||
$var = ! $var;
|
||||
|
||||
|
||||
print '<tr ' . $bc[$var] . ' class="value">';
|
||||
|
||||
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
print '<td>' . $label . '</td>';
|
||||
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class CActionComm
|
|||
* @param string $idorcode 'id' or 'code'
|
||||
* @param string $excludetype Type to exclude
|
||||
* @param string $onlyautoornot Group list by auto events or not
|
||||
* @return array Array of all event types if OK, <0 if KO
|
||||
* @return mixed Array of all event types if OK, <0 if KO
|
||||
*/
|
||||
function liste_array($active='',$idorcode='id',$excludetype='',$onlyautoornot=0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -755,6 +755,8 @@ class BonPrelevement extends CommonObject
|
|||
$factures = array();
|
||||
$factures_prev = array();
|
||||
$factures_result = array();
|
||||
$factures_prev_id=array();
|
||||
$factures_errors=array();
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class PaymentSalary extends CommonObject
|
|||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PAYMENT_SALARY_MODIFY',$user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
//FIXME: Add rollback if trigger fail
|
||||
|
|
@ -223,12 +223,12 @@ class PaymentSalary extends CommonObject
|
|||
global $conf, $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PAYMENT_SALARY_DELETE',$user);
|
||||
if ($result < 0) return -1;
|
||||
// End call triggers
|
||||
|
||||
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
|
@ -279,7 +279,7 @@ class PaymentSalary extends CommonObject
|
|||
function create($user)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
|
|
@ -414,7 +414,6 @@ class PaymentSalary extends CommonObject
|
|||
$this->fk_user,
|
||||
DOL_URL_ROOT.'/user/card.php?id=',
|
||||
$langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'),
|
||||
'(User)',
|
||||
'user'
|
||||
);
|
||||
|
||||
|
|
@ -427,9 +426,9 @@ class PaymentSalary extends CommonObject
|
|||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('PAYMENT_SALARY_CREATE',$user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
|
||||
}
|
||||
else $error++;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,17 +62,19 @@ class ChargeSociales extends CommonObject
|
|||
/**
|
||||
* Retrouve et charge une charge sociale
|
||||
*
|
||||
* @param int $id 1 si trouve, 0 sinon
|
||||
* @param int $id Id
|
||||
* @param string $ref Ref
|
||||
* @return void
|
||||
*/
|
||||
function fetch($id)
|
||||
function fetch($id, $ref='')
|
||||
{
|
||||
$sql = "SELECT cs.rowid, cs.date_ech,";
|
||||
$sql.= " cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, cs.periode,";
|
||||
$sql.= " c.libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs, ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||
$sql.= " WHERE cs.fk_type = c.id";
|
||||
$sql.= " AND cs.rowid = ".$id;
|
||||
if ($ref) $sql.= " AND cs.rowid = ".$ref;
|
||||
else $sql.= " AND cs.rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ class box_actions extends ModeleBoxes
|
|||
$actioncejour=false;
|
||||
$contents=$this->info_box_contents;
|
||||
$nblines=count($contents);
|
||||
$bcx=array();
|
||||
$bcx[0] = 'class="box_pair"';
|
||||
$bcx[1] = 'class="box_impair"';
|
||||
if ($contents[0][0]['text'] != $langs->trans("NoActionsToDo"))
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
|
|||
global $langs,$conf;
|
||||
|
||||
$MAXLENGTHBOX=60; // Mettre 0 pour pas de limite
|
||||
$bcx=array();
|
||||
$bcx[0] = 'class="box_pair"';
|
||||
$bcx[1] = 'class="box_impair"';
|
||||
$var = false;
|
||||
|
|
|
|||
|
|
@ -256,10 +256,10 @@ class Ccountry // extends CommonObject
|
|||
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @param User $user User that delete
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0)
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ function limitChars(textarea, limit, infodiv)
|
|||
{
|
||||
$defaultmessage=$this->withbody;
|
||||
}
|
||||
$defaultmessage=make_substitutions($defaultmessage,$this->substit,$langs);
|
||||
$defaultmessage=make_substitutions($defaultmessage,$this->substit);
|
||||
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
|
||||
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
|
||||
|
||||
|
|
|
|||
|
|
@ -847,6 +847,7 @@ class Ldap
|
|||
*/
|
||||
function getAttributeValues($filterrecord,$attribute)
|
||||
{
|
||||
$attributes=array();
|
||||
$attributes[0] = $attribute;
|
||||
|
||||
// We need to search for this user in order to get their entry.
|
||||
|
|
@ -1075,9 +1076,9 @@ class Ldap
|
|||
$subcount = hexdec(substr($hex_sid,2,2)); // Get count of sub-auth entries
|
||||
$auth = hexdec(substr($hex_sid,4,12)); // SECURITY_NT_AUTHORITY
|
||||
$result = "$rev-$auth";
|
||||
for ($x=0;$x < $subcount; $x++) {
|
||||
$subauth[$x] = hexdec($this->littleEndian(substr($hex_sid,16+($x*8),8))); // get all SECURITY_NT_AUTHORITY
|
||||
$result .= "-".$subauth[$x];
|
||||
for ($x=0;$x < $subcount; $x++)
|
||||
{
|
||||
$result .= "-".hexdec($this->littleEndian(substr($hex_sid,16+($x*8),8))); // get all SECURITY_NT_AUTHORITY
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
@ -1090,9 +1091,9 @@ class Ldap
|
|||
* car conflit majuscule-minuscule. A n'utiliser que pour les pages
|
||||
* 'Fiche LDAP' qui affiche champ lisibles par defaut.
|
||||
*
|
||||
* @param string $checkDn DN de recherche (Ex: ou=users,cn=my-domain,cn=com)
|
||||
* @param string $filter Filtre de recherche (ex: (sn=nom_personne) )
|
||||
* @return array Tableau des reponses (cle en minuscule-valeur)
|
||||
* @param string $checkDn DN de recherche (Ex: ou=users,cn=my-domain,cn=com)
|
||||
* @param string $filter Search filter (ex: (sn=nom_personne) )
|
||||
* @return array|int Array with answers (key lowercased - value)
|
||||
*/
|
||||
function search($checkDn, $filter)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ interface Database
|
|||
/**
|
||||
* List tables into a database
|
||||
*
|
||||
* @param string $database Name of database
|
||||
* @param string $table Nmae of table filter ('xxx%')
|
||||
* @return resource Resource
|
||||
* @param string $database Name of database
|
||||
* @param string $table Nmae of table filter ('xxx%')
|
||||
* @return array List of tables in an array
|
||||
*/
|
||||
function DDLListTables($database, $table = '');
|
||||
|
||||
|
|
@ -386,9 +386,9 @@ interface Database
|
|||
* 19700101020000 -> 3600 with TZ+1 and gmt=0
|
||||
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
|
||||
*
|
||||
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
||||
* @return date Date TMS
|
||||
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
|
||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
||||
* @return timestamp|string Date TMS
|
||||
*/
|
||||
function jdate($string, $gm=false);
|
||||
|
||||
|
|
|
|||
|
|
@ -158,8 +158,8 @@ abstract class DoliDB implements Database
|
|||
/**
|
||||
* Annulation d'une transaction et retour aux anciennes valeurs
|
||||
*
|
||||
* @param string $log Add more log to default log line
|
||||
* @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
|
||||
* @param string $log Add more log to default log line
|
||||
* @return resource|int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
|
||||
*/
|
||||
function rollback($log='')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -28,36 +28,36 @@
|
|||
*
|
||||
* @return array Array of tabs to show
|
||||
*/
|
||||
function admin_accounting_prepare_head()
|
||||
function admin_accounting_prepare_head($object=null)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
|
||||
$h = 0;
|
||||
$head = array ();
|
||||
|
||||
|
||||
$head[$h][0] = dol_buildpath('/accountancy/admin/index.php', 1);
|
||||
$head[$h][1] = $langs->trans("Configuration");
|
||||
$head[$h][2] = 'general';
|
||||
$h ++;
|
||||
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin');
|
||||
|
||||
|
||||
$head[$h][0] = dol_buildpath('/accountancy/admin/journaux.php', 1);
|
||||
$head[$h][1] = $langs->trans("Journaux");
|
||||
$head[$h][2] = 'journal';
|
||||
$h ++;
|
||||
|
||||
|
||||
$head[$h][0] = dol_buildpath('/accountancy/admin/export.php', 1);
|
||||
$head[$h][1] = $langs->trans("Export");
|
||||
$head[$h][2] = 'export';
|
||||
$h ++;
|
||||
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin', 'remove');
|
||||
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
|
@ -70,23 +70,23 @@ function admin_accounting_prepare_head()
|
|||
function accounting_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
|
||||
$h = 0;
|
||||
$head = array ();
|
||||
|
||||
|
||||
$head[$h][0] = dol_buildpath('/accountancy/admin/card.php', 1) . '?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h ++;
|
||||
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account');
|
||||
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account', 'remove');
|
||||
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
|
@ -94,25 +94,25 @@ function accounting_prepare_head($object)
|
|||
* Return general accounting account with defined length
|
||||
*
|
||||
* @param string $account General accounting account
|
||||
* @return string String with defined length
|
||||
* @return string String with defined length
|
||||
*/
|
||||
function length_accountg($account)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
|
||||
|
||||
|
||||
if (! empty($g)) {
|
||||
// Clean parameters
|
||||
$i = strlen($account);
|
||||
|
||||
|
||||
if ($i >= 2) {
|
||||
while ( $i < $g ) {
|
||||
$account .= '0';
|
||||
|
||||
|
||||
$i ++;
|
||||
}
|
||||
|
||||
|
||||
return $account;
|
||||
} else {
|
||||
return $account;
|
||||
|
|
@ -126,25 +126,25 @@ function length_accountg($account)
|
|||
* Return auxiliary accounting account with defined length
|
||||
*
|
||||
* @param string $accounta Auxiliary accounting account
|
||||
* @return string String with defined length
|
||||
* @return string String with defined length
|
||||
*/
|
||||
function length_accounta($accounta)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
|
||||
$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
|
||||
|
||||
|
||||
if (! empty($a)) {
|
||||
// Clean parameters
|
||||
$i = strlen($accounta);
|
||||
|
||||
|
||||
if ($i >= 2) {
|
||||
while ( $i < $a ) {
|
||||
$accounta .= '0';
|
||||
|
||||
|
||||
$i ++;
|
||||
}
|
||||
|
||||
|
||||
return $accounta;
|
||||
} else {
|
||||
return $accounta;
|
||||
|
|
@ -160,8 +160,8 @@ function length_accounta($accounta)
|
|||
* @param string $txt Accounting account
|
||||
* @param int $len Length
|
||||
* @param int $end Number of characters
|
||||
*
|
||||
* @return string Formated string
|
||||
*
|
||||
* @return string Formated string
|
||||
*/
|
||||
function length_exportsage($txt, $len, $end)
|
||||
{
|
||||
|
|
@ -169,11 +169,11 @@ function length_exportsage($txt, $len, $end)
|
|||
// problem with this function, but we need to have the number of letter
|
||||
if (strlen($txt) == $len) {
|
||||
$res = $txt;
|
||||
}
|
||||
}
|
||||
|
||||
elseif (strlen($txt) > $len) {
|
||||
$res = substr($txt, 0, $len);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
if ($end == 1) {
|
||||
|
|
|
|||
|
|
@ -3837,13 +3837,14 @@ function dol_html_entity_decode($a,$b,$c='UTF-8')
|
|||
/**
|
||||
* Replace htmlentities functions to manage errors
|
||||
* http://php.net/manual/en/function.htmlentities.php
|
||||
* TODO Remove this function to replace it with direct htmlentities.
|
||||
*
|
||||
* @param string $string The input string.
|
||||
* @param int $flags Flags(see PHP doc above)
|
||||
* @param string $encoding Encoding
|
||||
* @param bool $double_encode When double_encode is turned off PHP will not encode existing html entities
|
||||
* @return string $ret Encoded string
|
||||
* @deprecated Since PHP4 support is no longer available, this function does not make sense
|
||||
* @deprecated Since PHP4 support is no longer available, this function does not make sense.
|
||||
*/
|
||||
function dol_htmlentities($string, $flags=null, $encoding='UTF-8', $double_encode=false)
|
||||
{
|
||||
|
|
@ -3998,10 +3999,7 @@ function dol_concatdesc($text1,$text2,$forxml=false)
|
|||
}
|
||||
|
||||
/**
|
||||
* Make substition into a string
|
||||
* There is two type of substitions:
|
||||
* - From $substitutionarray (oldval=>newval)
|
||||
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
|
||||
* Make substition into a string replacing key with vals from $substitutionarray (oldval=>newval)
|
||||
*
|
||||
* @param string $chaine Source string in which we must do substitution
|
||||
* @param array $substitutionarray Array with key->val to substitute
|
||||
|
|
|
|||
|
|
@ -316,6 +316,7 @@ function measuring_units_string($unit,$measuring_style='')
|
|||
{
|
||||
global $langs;
|
||||
|
||||
$measuring_units=array();
|
||||
if ($measuring_style == 'weight')
|
||||
{
|
||||
$measuring_units[3] = $langs->trans("WeightUnitton");
|
||||
|
|
|
|||
|
|
@ -637,7 +637,7 @@ if (! defined('NOLOGIN'))
|
|||
{
|
||||
$db->rollback();
|
||||
session_destroy();
|
||||
dol_print_error($db,'Error in some triggers on action USER_LOGIN',LOG_ERR);
|
||||
dol_print_error($db,'Error in some triggers on action USER_LOGIN');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1396,7 +1396,7 @@ class Product extends CommonObject
|
|||
if (! $id && ! $ref && ! $ref_ext)
|
||||
{
|
||||
$this->error='ErrorWrongParameters';
|
||||
dol_print_error(get_class($this)."::fetch ".$this->error, LOG_ERR);
|
||||
dol_print_error(get_class($this)."::fetch ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ class Resource extends CommonObject
|
|||
|
||||
if (! $this->table_element)
|
||||
{
|
||||
dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined", LOG_ERR);
|
||||
dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user