Merge branch 'develop' into patch-10

This commit is contained in:
Laurent Destailleur 2023-09-08 21:29:36 +02:00 committed by GitHub
commit 184f5fb5b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 216 additions and 147 deletions

View file

@ -547,7 +547,7 @@ if (empty($reshook)) {
$object->title = (string) GETPOST("title");
$object->sujet = (string) GETPOST("sujet");
$object->body = (string) GETPOST("bodyemail", 'restricthtml');
$object->bgcolor = (string) GETPOST("bgcolor");
$object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor"));
$object->bgimage = (string) GETPOST("bgimage");
if (!$object->title) {
@ -641,7 +641,7 @@ if (empty($reshook)) {
$mesgs = array();
$object->sujet = (string) GETPOST("sujet");
$object->body = (string) GETPOST("bodyemail", 'restricthtml');
$object->bgcolor = (string) GETPOST("bgcolor");
$object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor"));
$object->bgimage = (string) GETPOST("bgimage");
if (!$object->sujet) {

View file

@ -1889,7 +1889,7 @@ if ($action == 'create') {
$thirdparty = $soc;
$discount_type = 0;
$backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid'));
$backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode(GETPOST('origin')).'&originid='.urlencode(GETPOSTINT('originid'));
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
}
@ -2473,7 +2473,7 @@ if ($action == 'create') {
$thirdparty = $soc;
$discount_type = 0;
$backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id);
$backtopage = $_SERVER["PHP_SELF"].'?id='.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';

View file

@ -1852,7 +1852,7 @@ if ($action == 'create' && $usercancreate) {
$thirdparty = $soc;
$discount_type = 0;
$backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid'));
$backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode(GETPOST('origin')).'&originid='.urlencode(GETPOSTINT('originid'));
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
@ -2470,7 +2470,7 @@ if ($action == 'create' && $usercancreate) {
$thirdparty = $soc;
$discount_type = 0;
$backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id);
$backtopage = $_SERVER["PHP_SELF"].'?id='.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';

View file

@ -2029,6 +2029,8 @@ if (empty($reshook)) {
$price_ht_devise = '';
$price_ttc = '';
$price_ttc_devise = '';
$price_min = '';
$price_min_ttc = '';
if (GETPOST('price_ht') !== '') {
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
@ -3167,7 +3169,6 @@ if ($action == 'create') {
print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
}
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input name="ref" type="hidden" value="provisoire">';
print '<input name="ref_client" type="hidden" value="'.$ref_client.'">';
print '<input name="force_cond_reglement_id" type="hidden" value="0">';
@ -3668,7 +3669,7 @@ if ($action == 'create') {
$thirdparty = $soc;
$discount_type = 0;
$backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin', 'alpha').'&originid='.GETPOST('originid', 'int'));
$backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode(GETPOST('origin')).'&originid='.urlencode(GETPOSTINT('originid'));
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
@ -4502,7 +4503,7 @@ if ($action == 'create') {
print '<td>';
$thirdparty = $soc;
$discount_type = 0;
$backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id);
$backtopage = $_SERVER["PHP_SELF"].'?facid='.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';

View file

@ -825,11 +825,11 @@ class FormOther
/**
* Output a HTML code to select a color. Field will return an hexa color like '334455'.
*
* @param string $set_color Pre-selected color
* @param string $set_color Pre-selected color with format '#......'
* @param string $prefix Name of HTML field
* @param string $form_name Deprecated. Not used.
* @param int $showcolorbox 1=Show color code and color box, 0=Show only color code
* @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813')
* @param array $arrayofcolors Array of possible colors to choose in the selector. All colors are possible if empty. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813')
* @param string $morecss Add css style into input field
* @param string $setpropertyonselect Set this property after selecting a color
* @param string $default Default color
@ -917,7 +917,8 @@ class FormOther
</script>';
$out .= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat valignmiddle'.($morecss ? ' '.$morecss : '').'" type="text" value="'.dol_escape_htmltag($set_color).'" />';
} else {
$out .= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat input-nobottom colorselector valignmiddle '.($morecss ? ' '.$morecss : '').'" type="color" value="#'.dol_escape_htmltag($set_color !== '' ? $set_color : $default).'" />';
$color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF'));
$out .= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat input-nobottom colorselector valignmiddle '.($morecss ? ' '.$morecss : '').'" type="color" data-default="'.$default.'" value="'.dol_escape_htmltag(preg_match('/^#/', $color) ? $color : '#'.$color).'" />';
$out .= '<script nonce="'.getNonce().'" type="text/javascript">
jQuery(document).ready(function(){
var originalhex = null;

View file

@ -653,6 +653,7 @@ class SMTPs
{
global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
/**
* Default return value
*/

View file

@ -6939,7 +6939,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = '
* Creation of a directory (this can create recursive subdir)
*
* @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir')
* @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used)
* @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning, on first dir, saying PHP has no permission when open_basedir is used)
* @param string $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444'
* @return int < 0 if KO, 0 = already exists, > 0 if OK
*/
@ -6972,6 +6972,7 @@ function dol_mkdir($dir, $dataroot = '', $newmask = '')
} else {
$ccdir .= $cdir[$i];
}
$regs = array();
if (preg_match("/^.:$/", $ccdir, $regs)) {
continue; // Si chemin Windows incomplet, on poursuit par rep suivant
}
@ -9240,9 +9241,12 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
return '';
}
}
$scheck = preg_replace('/->[a-zA-Z0-9_]+\(/', '->__METHOD__', $s);
$scheck = preg_replace('/\s[a-zA-Z0-9_]+\(/', ' __FUNCTION__', $scheck);
$scheck = preg_replace('/(\^|\')\(/', '__REGEXSTART__', $scheck); // To allow preg_match('/^(aaa|bbb)/'... or isStringVarMatching('leftmenu', '(aaa|bbb)')
$scheck = preg_replace('/->[a-zA-Z0-9_]+\(/', '->__METHOD__', $s); // accept parenthesis in '...->method(...'
$scheck = preg_replace('/^\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '(...'
$scheck = preg_replace('/\s\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '... ('
$scheck = preg_replace('/^[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in 'function('
$scheck = preg_replace('/\s[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in '... function('
$scheck = preg_replace('/(\^|\')\(/', '__REGEXSTART__', $scheck); // To allow preg_match('/^(aaa|bbb)/'... or isStringVarMatching('leftmenu', '(aaa|bbb)')
//print 'scheck='.$scheck." : ".strpos($scheck, '(')."\n";
if (strpos($scheck, '(') !== false) {
if ($returnvalue) {
@ -9264,6 +9268,13 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
return '';
}
}
$scheck = preg_replace('/->[a-zA-Z0-9_]+\(/', '->__METHOD__', $s); // accept parenthesis in '...->method(...'
$scheck = preg_replace('/^\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '(...'
$scheck = preg_replace('/\s\(/', '__PARENTHESIS__', $scheck); // accept parenthesis in '... ('
$scheck = preg_replace('/^[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in 'function('
$scheck = preg_replace('/\s[a-zA-Z0-9_]+\(/', '$1__FUNCTION__', $scheck); // accept parenthesis in '... function('
$scheck = preg_replace('/(\^|\')\(/', '__REGEXSTART__', $scheck); // To allow preg_match('/^(aaa|bbb)/'... or isStringVarMatching('leftmenu', '(aaa|bbb)')
//print 'scheck='.$scheck." : ".strpos($scheck, '(')."\n";
if (strpos($scheck, '(') !== false) {
if ($returnvalue) {
return 'Bad string syntax to evaluate (found call of a function or method without using direct name): '.$s;
@ -9307,12 +9318,13 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
$forbiddenphpstrings = array('$$');
$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST'));
$forbiddenphpfunctions = array("exec", "passthru", "shell_exec", "system", "proc_open", "popen", "eval");
$forbiddenphpfunctions = array("exec", "passthru", "shell_exec", "system", "proc_open", "popen");
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_eval", "executeCLI", "verifCond")); // native dolibarr functions
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64_decode", "rawurldecode", "urldecode")); // decode string functions
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64_decode", "rawurldecode", "urldecode")); // decode string functions
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "require", "include", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("get_defined_functions", "get_defined_vars", "get_defined_constants", "get_declared_classes"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("function", "call_user_func"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities
$forbiddenphpregex = 'global\s+\$|\b('.implode('|', $forbiddenphpfunctions).')\b';

View file

@ -91,8 +91,6 @@ class modEmailCollector extends DolibarrModules
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("admin");
$this->phpmin = array(7, 0); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice');
@ -159,7 +157,7 @@ class modEmailCollector extends DolibarrModules
// Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array(
0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'$conf->emailcollector->enabled')
0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'isModEnabled("emailcollector")')
);

View file

@ -1105,8 +1105,8 @@ class EmailCollector extends CommonObject
$searchfilterisanswer = 0;
$searchfilterisnotanswer = 0;
$searchfilterreplyto = 0;
$searchfilterexcludebody = '';
$searchfilterexcludesubject = '';
$searchfilterexcludebodyarray = array();
$searchfilterexcludesubjectarray = array();
$operationslog = '';
$now = dol_now();
@ -1300,7 +1300,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'subject') {
if (strpos($rule['rulevalue'], '!') === 0) {
//array_push($criteria, array("NOT SUBJECT" => $rule['rulevalue']));
$searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
$searchfilterexcludesubjectarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
array_push($criteria, array("SUBJECT" => $rule['rulevalue']));
}
@ -1308,7 +1308,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'body') {
if (strpos($rule['rulevalue'], '!') === 0) {
//array_push($criteria, array("NOT BODY" => $rule['rulevalue']));
$searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
$searchfilterexcludebodyarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
array_push($criteria, array("BODY" => $rule['rulevalue']));
}
@ -1431,7 +1431,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'subject') {
if (strpos($rule['rulevalue'], '!') === 0) {
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
$searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']);
$searchfilterexcludesubjectarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
$search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
}
@ -1439,7 +1439,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'body') {
if (strpos($rule['rulevalue'], '!') === 0) {
//$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
$searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']);
$searchfilterexcludebodyarray[] = preg_replace('/^!/', '', $rule['rulevalue']);
} else {
// Warning: Google doesn't implement IMAP properly, and only matches whole words,
$search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
@ -1771,12 +1771,14 @@ class EmailCollector extends CommonObject
continue; // Exclude email
}
if ($searchfilterexcludebody) {
if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) {
$nbemailprocessed++;
$operationslog .= '<br>Discarded - Email body contains string '.$searchfilterexcludebody;
dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody);
continue; // Exclude email
if (!empty($searchfilterexcludebodyarray)) {
foreach ($searchfilterexcludebodyarray as $searchfilterexcludebody) {
if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) {
$nbemailprocessed++;
$operationslog .= '<br>Discarded - Email body contains string '.$searchfilterexcludebody;
dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody);
continue 2; // Exclude email
}
}
}
@ -1863,12 +1865,14 @@ class EmailCollector extends CommonObject
//var_dump($msgid);exit;
}
if ($searchfilterexcludesubject) {
if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) {
$nbemailprocessed++;
$operationslog .= '<br>Discarded - Email subject contains string '.$searchfilterexcludesubject;
dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject);
continue; // Exclude email
if (!empty($searchfilterexcludesubjectarray)) {
foreach ($searchfilterexcludesubjectarray as $searchfilterexcludesubject) {
if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) {
$nbemailprocessed++;
$operationslog .= '<br>Discarded - Email subject contains string '.$searchfilterexcludesubject;
dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject);
continue 2; // Exclude email
}
}
}
@ -2272,12 +2276,16 @@ class EmailCollector extends CommonObject
}
} else {
// Regex not found
$idtouseforthirdparty = null;
$nametouseforthirdparty = null;
$emailtouseforthirdparty = null;
$namealiastouseforthirdparty = null;
if (in_array($propertytooverwrite, array('id', 'email', 'name', 'name_alias'))) {
$idtouseforthirdparty = null;
$nametouseforthirdparty = null;
$emailtouseforthirdparty = null;
$namealiastouseforthirdparty = null;
$operationslog .= '<br>propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found';
$operationslog .= '<br>propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found. Property searched is critical so we cancel the search.';
} else {
$operationslog .= '<br>propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found';
}
}
//var_dump($object->$tmpproperty);exit;
} else {
@ -2319,7 +2327,7 @@ class EmailCollector extends CommonObject
if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty || $namealiastouseforthirdparty)) {
// We make another search on thirdparty
$operationslog .= '<br>We have this data to search thirdparty: '.$idtouseforthirdparty.' '.$emailtouseforthirdparty.' '.$nametouseforthirdparty.' '.$namealiastouseforthirdparty;
$operationslog .= '<br>We have this data to search thirdparty: id='.$idtouseforthirdparty.', email='.$emailtouseforthirdparty.', name='.$nametouseforthirdparty.', name_alias='.$namealiastouseforthirdparty;
$tmpobject = new stdClass();
$tmpobject->element == 'generic';

View file

@ -711,6 +711,44 @@ class Export
$remaintopay = $tmpobjforcomputecall->getRemainToPay();
}
$obj->$alias = $remaintopay;
} elseif (is_array($this->array_export_special[$indice][$key]) &&
!empty($this->array_export_special[$indice][$key]['rule']) &&
$this->array_export_special[$indice][$key]['rule'] == 'compute'
) {
// Custom compute
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
$value = '';
if (!empty($this->array_export_special[$indice][$key]['class']) &&
!empty($this->array_export_special[$indice][$key]['classfile']) &&
!empty($this->array_export_special[$indice][$key]['method'])
) {
if (!dol_include_once($this->array_export_special[$indice][$key]['classfile'])) {
$this->error = "Computed field bad configuration: {$this->array_export_special[$indice][$key]['classfile']} not found";
return -1;
}
if (!class_exists($this->array_export_special[$indice][$key]['class'])) {
$this->error = "Computed field bad configuration: {$this->array_export_special[$indice][$key]['class']} class doesn't exist";
return -1;
}
$className = $this->array_export_special[$indice][$key]['class'];
$tmpObject = new $className($this->db);
if (!method_exists($tmpObject, $this->array_export_special[$indice][$key]['method'])) {
$this->error = "Computed field bad configuration: {$this->array_export_special[$indice][$key]['method']} method doesn't exist";
return -1;
}
$methodName = $this->array_export_special[$indice][$key]['method'];
$params = [];
if (!empty($this->array_export_special[$indice][$key]['method_params'])) {
foreach ($this->array_export_special[$indice][$key]['method_params'] as $paramName) {
$params[] = $obj->$paramName ?? null;
}
}
$value = $tmpObject->$methodName(...$params);
}
$obj->$alias = $value;
} else {
// TODO FIXME
// Export of compute field does not work. $obj contains $obj->alias_field and formula may contains $obj->field

View file

@ -950,7 +950,7 @@ class FactureFournisseur extends CommonInvoice
$this->ref_ext = $obj->ref_ext;
$this->entity = $obj->entity;
$this->type = empty($obj->type) ? self::TYPE_STANDARD : $obj->type;
$this->fk_soc = $obj->fk_soc;
$this->socid = $obj->fk_soc;
$this->datec = $this->db->jdate($obj->datec);
$this->date = $this->db->jdate($obj->datef);
$this->datep = $this->db->jdate($obj->datef);
@ -1170,8 +1170,8 @@ class FactureFournisseur extends CommonInvoice
if (isset($this->type)) {
$this->type = trim($this->type);
}
if (isset($this->fk_soc)) {
$this->fk_soc = trim($this->fk_soc);
if (isset($this->socid)) {
$this->socid = trim($this->socid);
}
if (isset($this->label)) {
$this->label = trim($this->label);
@ -1251,14 +1251,14 @@ class FactureFournisseur extends CommonInvoice
$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
$sql .= " entity=".(isset($this->entity) ? ((int) $this->entity) : "null").",";
$sql .= " type=".(isset($this->type) ? ((int) $this->type) : "null").",";
$sql .= " fk_soc=".(isset($this->fk_soc) ? ((int) $this->fk_soc) : "null").",";
$sql .= " fk_soc=".(isset($this->socid) ? ((int) $this->socid) : "null").",";
$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql .= " datef=".(dol_strlen($this->date) != 0 ? "'".$this->db->idate($this->date)."'" : 'null').",";
if (dol_strlen($this->tms) != 0) {
$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
}
$sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
$sql .= " paye=".(isset($this->paye) ? ((int) $this->paye) : "null").",";
$sql .= " paye=".(isset($this->paye) ? ((int) $this->paye) : "0").",";
$sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").",";
$sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").",";
$sql .= " localtax1=".(isset($this->localtax1) ? ((float) $this->localtax1) : "null").",";
@ -1271,7 +1271,7 @@ class FactureFournisseur extends CommonInvoice
$sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? ((int) $this->fk_user_valid) : "null").",";
$sql .= " fk_facture_source=".($this->fk_facture_source ? ((int) $this->fk_facture_source) : "null").",";
$sql .= " vat_reverse_charge = ".($this->vat_reverse_charge != '' ? ((int) $this->db->escape($this->vat_reverse_charge)) : 0).",";
$sql .= " fk_projet=".(isset($this->fk_project) ? ((int) $this->fk_project) : "null").",";
$sql .= " fk_projet=".(!empty($this->fk_project) ? ((int) $this->fk_project) : "null").",";
$sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : "null").",";
$sql .= " date_lim_reglement=".(dol_strlen($this->date_echeance) != 0 ? "'".$this->db->idate($this->date_echeance)."'" : 'null').",";
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";

View file

@ -92,3 +92,9 @@ ALTER TABLE llx_actioncomm ADD COLUMN fk_bookcal_availability integer DEFAULT NU
ALTER TABLE llx_product_lot ADD COLUMN qc_frequency integer DEFAULT NULL;
ALTER TABLE llx_product_lot ADD COLUMN lifetime integer DEFAULT NULL;
ALTER TABLE llx_bookcal_availabilities ADD COLUMN fk_bookcal_calendar integer NOT NULL;
ALTER TABLE llx_bookcal_calendar ADD COLUMN visibility integer NOT NULL DEFAULT 1;

View file

@ -53,15 +53,6 @@ create table llx_adherent
url varchar(255) NULL,
socialnetworks text DEFAULT NULL, -- json with socialnetworks
--skype varchar(255), -- deprecated
--twitter varchar(255), -- deprecated
--facebook varchar(255), -- deprecated
--linkedin varchar(255), -- deprecated
--instagram varchar(255), -- deprecated
--snapchat varchar(255), -- deprecated
--googleplus varchar(255), -- deprecated
--youtube varchar(255), -- deprecated
--whatsapp varchar(255), -- deprecated
phone varchar(30),
phone_perso varchar(30),

View file

@ -29,8 +29,8 @@ CREATE TABLE llx_bookcal_calendar(
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),
status integer NOT NULL,
status integer NOT NULL DEFAULT 0,
type integer NOT NULL,
visibility integer NOT NULL
visibility integer NOT NULL DEFAULT 1
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;

View file

@ -44,16 +44,6 @@ create table llx_socpeople
email varchar(255),
socialnetworks text DEFAULT NULL, -- json with socialnetworks
--jabberid varchar(255),
--skype varchar(255),
--twitter varchar(255), --
--facebook varchar(255), --
--linkedin varchar(255), --
--instagram varchar(255), --
--snapchat varchar(255), --
--googleplus varchar(255), --
--youtube varchar(255), --
--whatsapp varchar(255), --
photo varchar(255),
no_email smallint NOT NULL DEFAULT 0, -- deprecated. Use table llx_mailing_unsubscribe instead

View file

@ -1400,7 +1400,7 @@ PreloadOPCode=Preloaded OPCode is used
AddRefInList=Display Customer/Vendor ref. into combo lists.<br>Third Parties will appear with a name format of "CC12345 - SC45678 - The Big Company corp." instead of "The Big Company corp".
AddVatInList=Display Customer/Vendor VAT number into combo lists.
AddAdressInList=Display Customer/Vendor adress into combo lists.<br>Third Parties will appear with a name format of "The Big Company corp. - 21 jump street 123456 Big town - USA" instead of "The Big Company corp".
AddEmailPhoneTownInContactList=Display Contact email (or phones if not defined) and town info list (select list or combobox)<br>Contacts will appear with a name format of "Dupond Durand - dupond.durand@email.com - Paris" or "Dupond Durand - 06 07 59 65 66 - Paris" instead of "Dupond Durand".
AddEmailPhoneTownInContactList=Display Contact email (or phones if not defined) and town info list (select list or combobox)<br>Contacts will appear with a name format of "Dupond Durand - dupond.durand@example.com - Paris" or "Dupond Durand - 06 07 59 65 66 - Paris" instead of "Dupond Durand".
AskForPreferredShippingMethod=Ask for preferred shipping method for Third Parties.
FieldEdition=Edition of field %s
FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced)
@ -1773,15 +1773,15 @@ FreeLegalTextOnDeliveryReceipts=Free text on delivery receipts
##### FCKeditor #####
AdvancedEditor=Advanced editor
ActivateFCKeditor=Activate advanced editor for:
FCKeditorForNotePublic=WYSIWIG creation/edition of the field "public notes" of elements
FCKeditorForNotePrivate=WYSIWIG creation/edition of the field "private notes" of elements
FCKeditorForCompany=WYSIWIG creation/edition of the field description of elements (except products/services)
FCKeditorForProductDetails=WYSIWIG creation/edition of products description or lines for objects (lines of proposals, orders, invoices, etc...).
FCKeditorForNotePublic=WYSIWYG creation/edition of the field "public notes" of elements
FCKeditorForNotePrivate=WYSIWYG creation/edition of the field "private notes" of elements
FCKeditorForCompany=WYSIWYG creation/edition of the field description of elements (except products/services)
FCKeditorForProductDetails=WYSIWYG creation/edition of products description or lines for objects (lines of proposals, orders, invoices, etc...).
FCKeditorForProductDetails2=Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formatting when building PDF files.
FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing)
FCKeditorForUserSignature=WYSIWIG creation/edition of user signature
FCKeditorForMail=WYSIWIG creation/edition for all mail (except Tools->eMailing)
FCKeditorForTicket=WYSIWIG creation/edition for tickets
FCKeditorForMailing= WYSIWYG creation/edition for mass eMailings (Tools->eMailing)
FCKeditorForUserSignature=WYSIWYG creation/edition of user signature
FCKeditorForMail=WYSIWYG creation/edition for all mail (except Tools->eMailing)
FCKeditorForTicket=WYSIWYG creation/edition for tickets
##### Stock #####
StockSetup=Stock module setup
IfYouUsePointOfSaleCheckModule=If you use the Point of Sale module (POS) provided by default or an external module, this setup may be ignored by your POS module. Most POS modules are designed by default to create an invoice immediately and decrease stock irrespective of the options here. So if you need or not to have a stock decrease when registering a sale from your POS, check also your POS module setup.
@ -1991,7 +1991,7 @@ EnterAnyCode=This field contains a reference to identify the line. Enter any val
Enter0or1=Enter 0 or 1
UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For example: for $, enter [36] - for brazil real R$ [82,36] - for €, enter [8364]
ColorFormat=The RGB color is in HEX format, eg: FF0000
PictoHelp=Icon name in format:<br>- image.png for an image file into the current theme directory<br>- image.png@module if file is into the directory /img/ of a module<br>- fa-xxx for a FontAwesome fa-xxx picto<br>- fonwtawesome_xxx_fa_color_size for a FontAwesome fa-xxx picto (with prefix, color and size set)
PictoHelp=Icon name in format:<br>- image.png for an image file into the current theme directory<br>- image.png@module if file is into the directory /img/ of a module<br>- fa-xxx for a FontAwesome fa-xxx picto<br>- fontawesome_xxx_fa_color_size for a FontAwesome fa-xxx picto (with prefix, color and size set)
PositionIntoComboList=Position of line into combo lists
SellTaxRate=Sales tax rate
RecuperableOnly=Yes for VAT "Not Perceived but Recoverable" dedicated for some state in France. Keep value to "No" in all other cases.

View file

@ -168,7 +168,7 @@ AssetDepreciationReversal=Reversal
#
# Errors
#
AssetErrorAssetOrAssetModelIDNotProvide=Id of the asset or the model sound has not been provided
AssetErrorAssetOrAssetModelIDNotProvide=Id of the asset or the model found has not been provided
AssetErrorFetchAccountancyCodesForMode=Error when retrieving the accounting accounts for the '%s' depreciation mode
AssetErrorDeleteAccountancyCodesForMode=Error when deleting accounting accounts from the '%s' depreciation mode
AssetErrorInsertAccountancyCodesForMode=Error when inserting the accounting accounts of the depreciation mode '%s'

View file

@ -4,7 +4,7 @@
NoErrorCommitIsDone=No error, we commit
# Errors
ErrorButCommitIsDone=Errors found but we validate despite this
ErrorBadEMail=Email %s is incorrect
ErrorBadEMail=Email address %s is incorrect
ErrorBadMXDomain=Email %s seems incorrect (domain has no valid MX record)
ErrorBadUrl=Url %s is incorrect
ErrorBadValueForParamNotAString=Bad value for your parameter. It appends generally when translation is missing.
@ -240,7 +240,7 @@ ErrorURLMustStartWithHttp=URL %s must start with http:// or https://
ErrorHostMustNotStartWithHttp=Host name %s must NOT start with http:// or https://
ErrorNewRefIsAlreadyUsed=Error, the new reference is already used
ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible=Error, delete payment linked to a closed invoice is not possible.
ErrorSearchCriteriaTooSmall=Search criteria too small.
ErrorSearchCriteriaTooSmall=Search criteria too short.
ErrorObjectMustHaveStatusActiveToBeDisabled=Objects must have status 'Active' to be disabled
ErrorObjectMustHaveStatusDraftOrDisabledToBeActivated=Objects must have status 'Draft' or 'Disabled' to be enabled
ErrorNoFieldWithAttributeShowoncombobox=No fields has property 'showoncombobox' into definition of object '%s'. No way to show the combolist.

View file

@ -87,9 +87,9 @@ VacantCheckboxHelper=Checking this option will show unfilled positions (job vaca
SaveAddSkill = Skill(s) added
SaveLevelSkill = Skill(s) level saved
DeleteSkill = Skill removed
SkillsExtraFields=Attributs supplémentaires (Compétences)
JobsExtraFields=Attributs supplémentaires (Job profile)
EvaluationsExtraFields=Attributs supplémentaires (Evaluations)
SkillsExtraFields=Complementary attributes (Skills)
JobsExtraFields=Complementary attributes (Job profile)
EvaluationsExtraFields=Complementary attributes (Evaluations)
NeedBusinessTravels=Need business travels
NoDescription=No description
TheJobProfileHasNoSkillsDefinedFixBefore=The evaluated job profile of this employee has not skill defined on it. Please fix this before, then delete and restart the evaluation.
TheJobProfileHasNoSkillsDefinedFixBefore=The evaluated job profile of this employee has no skill defined on it. Please add skill(s), then delete and restart the evaluation.

View file

@ -60,7 +60,7 @@ ErrorFailedToSendMail=Failed to send mail (sender=%s, receiver=%s)
ErrorFileNotUploaded=File was not uploaded. Check that size does not exceed maximum allowed, that free space is available on disk and that there is not already a file with same name in this directory.
ErrorInternalErrorDetected=Error detected
ErrorWrongHostParameter=Wrong host parameter
ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit and post the form again.
ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Company/Foundation and post the form again.
ErrorRecordIsUsedByChild=Failed to delete this record. This record is used by at least one child record.
ErrorWrongValue=Wrong value
ErrorWrongValueForParameterX=Wrong value for parameter %s

View file

@ -19,7 +19,7 @@ MakeOrder=Make order
SupplierOrder=Purchase order
SuppliersOrders=Purchase orders
SaleOrderLines=Sales order lines
PurchaseOrderLines=Puchase order lines
PurchaseOrderLines=Purchase order lines
SuppliersOrdersRunning=Current purchase orders
CustomerOrder=Sales Order
CustomersOrders=Sales Orders
@ -205,4 +205,4 @@ StatusSupplierOrderRefused=Refused
StatusSupplierOrderReceivedPartially=Partially received
StatusSupplierOrderReceivedAll=All products received
NeedAtLeastOneInvoice = There has to be at least one Invoice
LineAlreadyDispatched = The order line is already received.
LineAlreadyDispatched = The order line is already received.

View file

@ -63,7 +63,7 @@ YearInvoice=Invoice year
DOL_VALUE_MONTH_LETTERS=Invoice month in letters
DOL_VALUE_MONTH=Invoice month
DOL_VALUE_DAY=Invoice day
DOL_VALUE_DAY_LETTERS=Inovice day in letters
DOL_VALUE_DAY_LETTERS=Invoice day in letters
DOL_LINE_FEED_REVERSE=Line feed reverse
InvoiceID=Invoice ID
InvoiceRef=Invoice ref
@ -81,4 +81,4 @@ VendorLastname=Vendor last name
VendorFirstname=Vendor first name
VendorEmail=Vendor email
DOL_VALUE_CUSTOMER_POINTS=Customer points
DOL_VALUE_OBJECT_POINTS=Object points
DOL_VALUE_OBJECT_POINTS=Object points

View file

@ -77,7 +77,7 @@ DetailWarehouseFormat= W:%s (Qty: %d)
ShipmentDistribution=Shipment distribution
ErrorTooManyCombinationBatchcode=No dispatch for line %s as too many combination warehouse, product, batch code was found (%s).
ErrorNoCombinationBatchcode=No dispatch for line %s as no combination warehouse, product, batch code was found.
ErrorTooManyCombinationBatchcode=No dispatch for line %s as too many combinations of warehouse, product, batch code was found (%s).
ErrorNoCombinationBatchcode=No dispatch for line %s as no combination of warehouse, product, batch code was found.
ErrorTooMuchShipped=Quantity shipped should not be greater than quantity ordered for line %s

View file

@ -311,7 +311,7 @@ TicketNewEmailBodyInfosTrackUrlCustomer=You can view the progress of the ticket
TicketCloseEmailBodyInfosTrackUrlCustomer=You can consult the history of this ticket by clicking the following link
TicketEmailPleaseDoNotReplyToThisEmail=Please do not reply directly to this email! Use the link to reply into the interface.
TicketPublicInfoCreateTicket=This form allows you to record a support ticket in our management system.
TicketPublicPleaseBeAccuratelyDescribe=Please accurately describe your question. Provide the most information possible to allow us to correctly identify your request.
TicketPublicPleaseBeAccuratelyDescribe=Please accurately describe your request. Provide the most information possible to allow us to correctly identify your request.
TicketPublicMsgViewLogIn=Please enter ticket tracking ID
TicketTrackId=Public Tracking ID
OneOfTicketTrackId=One of your tracking ID

View file

@ -102,8 +102,10 @@ if (!$sortorder) {
$hookmanager->initHooks(array('pricesuppliercard', 'globalcard'));
$object = new ProductFournisseur($db);
$prod = new Product($db);
if ($id > 0 || $ref) {
$object->fetch($id, $ref);
$prod->fetch($id, $ref);
}
$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire')));
@ -396,7 +398,7 @@ if ($id > 0 || $ref) {
$shownav = 0;
}
dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
dol_banner_tab($prod, 'ref', $linkback, $shownav, 'ref');
print '<div class="fichecenter">';

View file

@ -94,7 +94,7 @@ if (!GETPOST("currency", 'alpha')) {
$currency = GETPOST("currency", 'aZ09');
}
$source = GETPOST("s", 'aZ09') ?GETPOST("s", 'aZ09') : GETPOST("source", 'aZ09');
//$download = GETPOST('d', 'int') ?GETPOST('d', 'int') : GETPOST('download', 'int');
$getpostlang = GETPOST('lang', 'aZ09');
if (!$action) {
if (!GETPOST("amount", 'alpha') && !$source) {
@ -241,6 +241,10 @@ if (!empty($entity)) {
$urlok .= 'e='.urlencode($entity).'&';
$urlko .= 'e='.urlencode($entity).'&';
}
if (!empty($getpostlang)) {
$urlok .= 'lang='.urlencode($getpostlang).'&';
$urlko .= 'lang='.urlencode($getpostlang).'&';
}
$urlok = preg_replace('/&$/', '', $urlok); // Remove last &
$urlko = preg_replace('/&$/', '', $urlko); // Remove last &
@ -834,7 +838,7 @@ $form = new Form($db);
$head = '';
if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
$head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
$head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.(!empty($getpostlang) ? $getpostlang: $langs->defaultlang).'">'."\n";
}
$conf->dol_hide_topmenu = 1;
@ -878,6 +882,7 @@ print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'
print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($SECUREKEY).'">'."\n";
print '<input type="hidden" name="e" value="'.$entity.'" />';
print '<input type="hidden" name="forcesandbox" value="'.GETPOST('forcesandbox', 'int').'" />';
print '<input type="hidden" name="lang" value="'.$getpostlang.'">';
print "\n";
@ -2233,6 +2238,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme
print '<input type="hidden" name="forcesandbox" value="'.GETPOST('forcesandbox', 'int').'" />';
print '<input type="hidden" name="email" value="'.GETPOST('email', 'alpha').'" />';
print '<input type="hidden" name="thirdparty_id" value="'.GETPOST('thirdparty_id', 'int').'" />';
print '<input type="hidden" name="lang" value="'.$getpostlang.'">';
if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) { // Use a SCA ready method
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';

View file

@ -2176,6 +2176,7 @@ class Societe extends CommonObject
*/
public function set_as_client()
{
global $conf;
// phpcs:enable
dol_syslog(get_class($this)."::set_as_client is deprecated use setAsCustomer instead", LOG_NOTICE);
return $this->setAsCustomer();

View file

@ -301,7 +301,7 @@ class ActionsTicket extends CommonHookActions
//print '<tr>';
print '<tr class="oddeven">';
print '<td><strong>';
print img_picto('', 'object_action', 'class="paddingright"').dol_print_date($arraymsgs['datec'], 'dayhour');
print img_picto('', 'object_action', 'class="paddingright"').dol_print_date($arraymsgs['datep'], 'dayhour');
print '<strong></td>';
if ($show_user) {
print '<td>';

View file

@ -1801,11 +1801,11 @@ class Ticket extends CommonObject
// Cache already loaded
$sql = "SELECT id as rowid, fk_user_author, email_from, datec, label, note as message, code";
$sql = "SELECT id as rowid, fk_user_author, email_from, datec, datep, label, note as message, code";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
$sql .= " WHERE fk_element = ".(int) $this->id;
$sql .= " AND elementtype = 'ticket'";
$sql .= " ORDER BY datec DESC";
$sql .= " ORDER BY datep DESC";
dol_syslog(get_class($this)."::load_cache_actions_ticket", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -1820,6 +1820,7 @@ class Ticket extends CommonObject
$this->cache_msgs_ticket[$i]['fk_contact_author'] = $obj->email_from;
}
$this->cache_msgs_ticket[$i]['datec'] = $this->db->jdate($obj->datec);
$this->cache_msgs_ticket[$i]['datep'] = $this->db->jdate($obj->datep);
$this->cache_msgs_ticket[$i]['subject'] = $obj->label;
$this->cache_msgs_ticket[$i]['message'] = $obj->message;
$this->cache_msgs_ticket[$i]['private'] = (preg_match('/^TICKET_MSG_PRIVATE/', $obj->code) ? 1 : 0);

View file

@ -440,7 +440,7 @@ while ($i < $imaxinloop) {
}
}
print '<td>';
print '<td class="tdoverflowmax125">';
print $object->getNomUrl(1);
if (isModEnabled('multicompany') && !$obj->entity) {
print img_picto($langs->trans("GlobalGroup"), 'redstar');
@ -457,12 +457,12 @@ while ($i < $imaxinloop) {
$totalarray['nbfield']++;
}
}
print '<td class="center">'.$obj->nb.'</td>';
print '<td class="center">'.dol_escape_htmltag($obj->nb).'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
print '<td class="center">';
print '<a href="'.DOL_URL_ROOT.'/user/group/perms.php?id='.$obj->rowid.'">'.$obj->nbpermissions.'</a>';
print '<a href="'.DOL_URL_ROOT.'/user/group/perms.php?id='.$obj->rowid.'">'.dol_escape_htmltag($obj->nbpermissions).'</a>';
print '</td>';
if (!$i) {
$totalarray['nbfield']++;

View file

@ -257,7 +257,7 @@ class Website extends CommonObject
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
// Create subdirectory per language
// Create a subdirectory for each language (except main language)
$tmplangarray = explode(',', $this->otherlang);
if (is_array($tmplangarray)) {
dol_mkdir($conf->website->dir_output.'/'.$this->ref);
@ -265,10 +265,14 @@ class Website extends CommonObject
if (trim($val) == $this->lang) {
continue;
}
dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val));
dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val), DOL_DATA_ROOT);
}
}
// Create subdirectory for images and js
dol_mkdir($conf->medias->multidir_output[$conf->entity].'/image/'.$this->ref, DOL_DATA_ROOT);
dol_mkdir($conf->medias->multidir_output[$conf->entity].'/js/'.$this->ref, DOL_DATA_ROOT);
// Uncomment this and change WEBSITE to your own tag if you
// want this action to call a trigger.
// if (!$notrigger) {

View file

@ -225,6 +225,8 @@ class AllTests
// Rest
require_once dirname(__FILE__).'/RestAPIUserTest.php';
$suite->addTestSuite('RestAPIUserTest');
require_once dirname(__FILE__).'/RestAPIContactTest.php';
$suite->addTestSuite('RestAPIContactTest');
require_once dirname(__FILE__).'/RestAPIDocumentTest.php';
$suite->addTestSuite('RestAPIDocumentTest');

View file

@ -940,11 +940,11 @@ class SecurityTest extends PHPUnit\Framework\TestCase
$db=$this->savdb;
$result=dol_eval('1==1', 1, 0);
print "result = ".$result."\n";
print "result1 = ".$result."\n";
$this->assertTrue($result);
$result=dol_eval('1==2', 1, 0);
print "result = ".$result."\n";
print "result2 = ".$result."\n";
$this->assertFalse($result);
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@ -952,44 +952,48 @@ class SecurityTest extends PHPUnit\Framework\TestCase
$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"';
$result=dol_eval($s, 1, 1, '2');
print "result = ".$result."\n";
print "result3 = ".$result."\n";
$this->assertEquals('Parent project not found', $result);
$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : \'Parent project not found\'';
$result=dol_eval($s, 1, 1, '2');
print "result = ".$result."\n";
$result = (string) dol_eval($s, 1, 1, '2');
print "result4 = ".$result."\n";
$this->assertEquals('Parent project not found', $result);
$result=dol_eval('$a=function() { }; $a;', 1, 1, '0');
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval('$a=function() { }; $a;', 1, 1, '0');
print "result5 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval('$a=exec("ls");', 1, 1);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval('$a=function() { }; $a;', 1, 1, '1');
print "result6 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval('$a=exec ("ls")', 1, 1);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval('$a=exec("ls");', 1, 1);
print "result7 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval('$a="test"; $$a;', 1, 0);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval('$a=exec ("ls")', 1, 1);
print "result8 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval('`ls`', 1, 0);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval('$a="test"; $$a;', 1, 0);
print "result9 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval("('ex'.'ec')('echo abc')", 1, 0);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval('`ls`', 1, 0);
print "result10 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval("sprintf(\"%s%s\", \"ex\", \"ec\")('echo abc')", 1, 0);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval("('ex'.'ec')('echo abc')", 1, 0);
print "result11 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result = (string) dol_eval("sprintf(\"%s%s\", \"ex\", \"ec\")('echo abc')", 1, 0);
print "result12 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval("90402.38+267678+0", 1, 1, 1);
print "result = ".$result."\n";
print "result13 = ".$result."\n";
$this->assertEquals('358080.38', $result);
global $leftmenu; // Used into strings to eval
@ -1002,33 +1006,36 @@ class SecurityTest extends PHPUnit\Framework\TestCase
// Same with a value that does not match
$leftmenu = 'XXX';
$result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
print "result = ".$result."\n";
print "result14 = ".$result."\n";
$this->assertFalse($result);
$leftmenu = 'AAA';
$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
print "result = ".$result."\n";
print "result15 = ".$result."\n";
$this->assertTrue($result);
$leftmenu = 'XXX';
$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
print "result = ".$result."\n";
print "result16 = ".$result."\n";
$this->assertFalse($result);
// Case with param onlysimplestring = 1
$string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)';
$result=dol_eval($string, 1, 1, '1');
print "result17 = ".$result."\n";
$this->assertTrue($result);
$result=dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...'
print "result = ".$result."\n";
print "result18 = ".$result."\n";
$this->assertFalse($result);
$result=dol_eval("(\$a.'aa')", 1, 0);
print "result = ".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$result = (string) dol_eval("(\$a.'aa')", 1, 0);
print "result19 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result=dol_eval('$a="abs" && $a(5)', 1, 0);
print "result = a".$result."\n";
$this->assertContains('Bad string syntax to evaluate', $result);
$leftmenu='abs';
$result = (string) dol_eval('$leftmenu(-5)', 1, 0);
print "result20 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
}