Skip to content

Commit

Permalink
Merge branch 'Dolibarr:develop' into new-holiday-update-at-the-end-of…
Browse files Browse the repository at this point in the history
…-month
  • Loading branch information
YannisHoareau authored May 15, 2024
2 parents 0de693f + c01720f commit 085e972
Show file tree
Hide file tree
Showing 19 changed files with 249 additions and 94 deletions.
2 changes: 1 addition & 1 deletion htdocs/accountancy/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@

if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_COMBO_FOR_AUX&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print img_picto($langs->trans("Activated").' - '.$langs->trans("NotRecommended"), 'switch_on', 'class="warning"');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_COMBO_FOR_AUX&value=1">';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/bookkeeping/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@
if (!empty($arrayfields['t.subledger_account']['checked'])) {
print '<td class="liste_titre">';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
// use setup of "keypress to select thirdparty" and this hangs browser on large databases.
if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
print '<div class="nowrap">';
//print $langs->trans('From').' ';
Expand Down
9 changes: 9 additions & 0 deletions htdocs/admin/modulehelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,15 @@

$text .= '<br>';

$text .= '<br><strong>'.$langs->trans("AddWebsiteTemplates").':</strong> ';
if (isset($objMod->module_parts) && isset($objMod->module_parts['websitetemplates']) && $objMod->module_parts['websitetemplates']) {
$text .= $langs->trans("Yes");
} else {
$text .= '<span class="opacitymedium">'.$langs->trans("No").'</span>';
}

$text .= '<br>';

$text .= '<br><strong>'.$langs->trans("AddOtherPagesOrServices").':</strong> ';
$text .= '<span class="opacitymedium">'.$langs->trans("DetectionNotPossible").'</span>';
}
Expand Down
5 changes: 3 additions & 2 deletions htdocs/categories/class/categorie.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1980,18 +1980,19 @@ public function setMultiLangs(User $user, $notrigger = 0)
$result = $this->db->query($sql);

if ($key == $current_lang) {
$sql2 = '';
if ($this->db->num_rows($result)) { // si aucune ligne dans la base
$sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
$sql2 .= " SET label = '".$this->db->escape($this->label)."',";
$sql2 .= " description = '".$this->db->escape($this->description)."'";
$sql2 .= " WHERE fk_category = ".((int) $this->id)." AND lang = '".$this->db->escape($key)."'";
} else {
} elseif (isset($this->multilangs[$key])) {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
$sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->label)."'";
$sql2 .= ", '".$this->db->escape($this->multilangs[$key]["description"])."')";
}
dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
if (!$this->db->query($sql2)) {
if ($sql2 && !$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
Expand Down
10 changes: 5 additions & 5 deletions htdocs/categories/traduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@
print '<table class="border centpercent">';

// Label
$libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']);
$libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : ($object->multilangs[$key]['label'] ?? ''));
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$libelle.'"></td></tr>';

// Desc
$desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']);
$desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : ($object->multilangs[$key]['description'] ?? ''));
print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_3, '90%');
$doleditor->Create();
Expand All @@ -292,10 +292,10 @@
$s = picto_from_langcode($key);
print '<table class="border centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>';
print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.($object->multilangs[$key]["label"] ?? '').'</td></tr>';
print '<tr><td>'.$langs->trans('Description').'</td><td>'.($object->multilangs[$key]["description"] ?? '').'</td></tr>';
if (getDolGlobalString('CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION')) {
print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotYetAvailable").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>';
print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotYetAvailable").')</td><td>'.($object->multilangs[$key]["other"] ?? '').'</td></tr>';
}
print '</table>';
}
Expand Down
54 changes: 45 additions & 9 deletions htdocs/core/ajax/onlineSign.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,21 @@
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
// TODO Get position of box from PDF template

$param['xforimgstart'] = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15);
$param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 60);
$param['wforimg'] = $s['w'] - 20 - $param['xforimgstart'];
if (getDolGlobalString("PROPAL_SIGNATURE_XFORIMGSTART")) {
$param['xforimgstart'] = getDolGlobalString("PROPAL_SIGNATURE_XFORIMGSTART");
} else {
$param['xforimgstart'] = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15);
}
if (getDolGlobalString("PROPAL_SIGNATURE_YFORIMGSTART")) {
$param['yforimgstart'] = getDolGlobalString("PROPAL_SIGNATURE_YFORIMGSTART");
} else {
$param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 60);
}
if (getDolGlobalString("PROPAL_SIGNATURE_WFORIMG")) {
$param['wforimg'] = getDolGlobalString("PROPAL_SIGNATURE_WFORIMG");
} else {
$param['wforimg'] = $s['w'] - 20 - $param['xforimgstart'];
}

dolPrintSignatureImage($pdf, $langs, $param);
}
Expand Down Expand Up @@ -333,9 +345,21 @@
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
// TODO Get position of box from PDF template

$param['xforimgstart'] = 10;
$param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 65);
$param['wforimg'] = $s['w'] / 2 - $param['xforimgstart'];
if (getDolGlobalString("CONTRACT_SIGNATURE_XFORIMGSTART")) {
$param['xforimgstart'] = getDolGlobalString("CONTRACT_SIGNATURE_XFORIMGSTART");
} else {
$param['xforimgstart'] = 10;
}
if (getDolGlobalString("CONTRACT_SIGNATURE_YFORIMGSTART")) {
$param['yforimgstart'] = getDolGlobalString("CONTRACT_SIGNATURE_YFORIMGSTART");
} else {
$param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 65);
}
if (getDolGlobalString("CONTRACT_SIGNATURE_WFORIMG")) {
$param['wforimg'] = getDolGlobalString("CONTRACT_SIGNATURE_WFORIMG");
} else {
$param['wforimg'] = $s['w'] / 2 - $param['xforimgstart'];
}

dolPrintSignatureImage($pdf, $langs, $param);
}
Expand Down Expand Up @@ -446,9 +470,21 @@
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
// TODO Get position of box from PDF template

$param['xforimgstart'] = 111;
$param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 60);
$param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 16);
if (getDolGlobalString("FICHINTER_SIGNATURE_XFORIMGSTART")) {
$param['xforimgstart'] = getDolGlobalString("FICHINTER_SIGNATURE_XFORIMGSTART");
} else {
$param['xforimgstart'] = 111;
}
if (getDolGlobalString("FICHINTER_SIGNATURE_YFORIMGSTART")) {
$param['yforimgstart'] = getDolGlobalString("FICHINTER_SIGNATURE_YFORIMGSTART");
} else {
$param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 60);
}
if (getDolGlobalString("FICHINTER_SIGNATURE_WFORIMG")) {
$param['wforimg'] = getDolGlobalString("FICHINTER_SIGNATURE_WFORIMG");
} else {
$param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 16);
}

dolPrintSignatureImage($pdf, $langs, $param);
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,7 @@ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $st
* @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase
* @return array|string Array of keys for json
*/
public function select_produits_list($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $status_purchase = -1)
public function select_produits_list($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = 'maxwidth500', $hidepriceinlabel = 0, $warehouseStatus = '', $status_purchase = -1)
{
// phpcs:enable
global $langs;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/files.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3700,7 +3700,7 @@ function dragAndDropFileUpload($htmlname)
* @param string $moveorcopy 'move' or 'copy'
* @return bool Returns true if successful, false otherwise.
*/
function manageFileBackups($filetpl, $max_versions = 5, $archivedir = '', $suffix = "v", $moveorcopy = 'move')
function archiveOrBackupFile($filetpl, $max_versions = 5, $archivedir = '', $suffix = "v", $moveorcopy = 'move')
{
$base_file_pattern = ($archivedir ? $archivedir : dirname($filetpl)).'/'.basename($filetpl).".".$suffix;
$files_in_directory = glob($base_file_pattern . "*");
Expand Down
4 changes: 1 addition & 3 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8118,13 +8118,12 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
// like '<h1>Foo</h1><p>bar</p>' that wrongly ends up, without the trick, with '<h1>Foo<p>bar</p></h1>'
// like 'abc' that wrongly ends up, without the trick, with '<p>abc</p>'

// TODO Must accept emoji with MAIN_RESTRICTHTML_ONLY_VALID_HTML...

if (dol_textishtml($out)) {
$out = '<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.'</div>';
} else {
$out = '<?xml encoding="UTF-8"><div class="tricktoremove">'.dol_nl2br($out).'</div>';
}

$dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
$out = trim($dom->saveHTML());

Expand Down Expand Up @@ -8196,7 +8195,6 @@ static function ($m) {
$out
);


// Now we remove all remaining HTML entities starting with a number. We don't want such entities.
$out = preg_replace('/&#x?[0-9]+/i', '', $out); // For example if we have j&#x61vascript with an entities without the ; to hide the 'a' of 'javascript'.

Expand Down
59 changes: 59 additions & 0 deletions htdocs/core/lib/functions2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2982,3 +2982,62 @@ function removeGlobalParenthesis($string)

return $string;
}


/**
* Return array of Emojis
*
* @return array Array of Emojis in hexadecimal
*/
function getArrayOfEmoji()
{
$arrayofcommonemoji = array(
'misc' => array('2600', '26FF'), // Miscellaneous Symbols
'ding' => array('2700', '27BF'), // Dingbats
'????' => array('9989', '9989'), // Variation Selectors
'vars' => array('FE00', 'FE0F'), // Variation Selectors
'pict' => array('1F300', '1F5FF'), // Miscellaneous Symbols and Pictographs
'emot' => array('1F600', '1F64F'), // Emoticons
'tran' => array('1F680', '1F6FF'), // Transport and Map Symbols
'flag' => array('1F1E0', '1F1FF'), // Flags (note: may be 1F1E6 instead of 1F1E0)
'supp' => array('1F900', '1F9FF'), // Supplemental Symbols and Pictographs
);

return $arrayofcommonemoji;
}

/**
* Remove EMoji from email content
*
* @param string $text String to sanitize
* @param int $allowedemoji Mode to allow emoji
* @return string Sanitized string
*/
function removeEmoji($text, $allowedemoji = 1)
{
// $allowedemoji can be
// 0=no emoji, 1=exclude the main known emojis (default), 2=keep only the main known (not implemented), 3=accept all
// Note that to accept emoji in database, you must use utf8mb4, utf8mb3 is not enough.

$arrayofcommonemoji = getArrayOfEmoji();

if ($allowedemoji == 0) {
// For a large removal:
$text = preg_replace('/[\x{2600}-\x{FFFF}]/u', '', $text);
$text = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $text);
}

// Delete emoji chars with a regex
// See https://www.unicode.org/emoji/charts/full-emoji-list.html
if ($allowedemoji == 1) {
foreach ($arrayofcommonemoji as $key => $valarray) {
$text = preg_replace('/[\x{'.$valarray[0].'}-\x{'.$valarray[1].'}]/u', '', $text);
}
}

if ($allowedemoji == 2) {
// TODO Not yet implemented
}

return $text;
}
2 changes: 1 addition & 1 deletion htdocs/core/lib/website2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage,
if (dol_is_file($filetpl)) {
if ($backupold) {
$result = manageFileBackups($filetpl);
$result = archiveOrBackupFile($filetpl);
if (! $result) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions htdocs/core/modules/modFacture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ public function __construct($db)

// Exports
//--------
$uselocaltax1 = (is_object($mysoc) && $mysoc->localtax1_assuj) ? $mysoc->localtax1_assuj : 0;
$uselocaltax2 = (is_object($mysoc) && $mysoc->localtax2_assuj) ? $mysoc->localtax2_assuj : 0;

$r = 0;

$langs->loadLangs(array("suppliers", "multicurrency", "bills"));
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/modFournisseur.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ public function __construct($db)

// Exports
//--------
$uselocaltax1 = $mysoc->localtax1_assuj ?? 0;
$uselocaltax2 = $mysoc->localtax2_assuj ?? 0;
$uselocaltax1 = (is_object($mysoc) && $mysoc->localtax1_assuj) ? $mysoc->localtax1_assuj : 0;
$uselocaltax2 = (is_object($mysoc) && $mysoc->localtax2_assuj) ? $mysoc->localtax2_assuj : 0;

$r = 0;

Expand Down
28 changes: 4 additions & 24 deletions htdocs/emailcollector/class/emailcollector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';

require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; // Customer Proposal
require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php'; // Sale Order
Expand Down Expand Up @@ -1785,7 +1786,7 @@ public function doCollectOneCollector($mode = 0)
dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']);

// Removed emojis
$overview['subject'] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $overview['subject']);
$overview['subject'] = removeEmoji($overview['subject'], getDolGlobalInt('MAIN_EMAIL_COLLECTOR_ACCEPT_EMOJIS', 1));
} else {
dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject);

Expand All @@ -1794,7 +1795,7 @@ public function doCollectOneCollector($mode = 0)
$overview[0]->from = $this->decodeSMTPSubject($overview[0]->from);

// Removed emojis
$overview[0]->subject = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $overview[0]->subject);
$overview[0]->subject = removeEmoji($overview[0]->subject, getDolGlobalInt('MAIN_EMAIL_COLLECTOR_ACCEPT_EMOJIS', 1));
}
// GET IMAP email structure/content
global $htmlmsg, $plainmsg, $charset, $attachments;
Expand Down Expand Up @@ -1825,8 +1826,7 @@ public function doCollectOneCollector($mode = 0)
// Removed emojis

if (utf8_valid($messagetext)) {
//$messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext);
$messagetext = $this->removeEmoji($messagetext);
$messagetext = removeEmoji($messagetext, getDolGlobalInt('MAIN_EMAIL_COLLECTOR_ACCEPT_EMOJIS', 1));
} else {
$operationslog .= '<br>Discarded - Email body is not valid utf8';
dol_syslog(" Discarded - Email body is not valid utf8");
Expand Down Expand Up @@ -3714,26 +3714,6 @@ protected function decodeSMTPSubject($subject)
return $subject;
}

/**
* Remove EMoji from email content
*
* @param string $text String to sanitize
* @return string Sanitized string
*/
protected function removeEmoji($text)
{
// Supprimer les caractères emoji en utilisant une expression régulière
$text = preg_replace('/[\x{1F600}-\x{1F64F}]/u', '', $text);
$text = preg_replace('/[\x{1F300}-\x{1F5FF}]/u', '', $text);
$text = preg_replace('/[\x{1F680}-\x{1F6FF}]/u', '', $text);
$text = preg_replace('/[\x{2600}-\x{26FF}]/u', '', $text);
$text = preg_replace('/[\x{2700}-\x{27BF}]/u', '', $text);
$text = preg_replace('/[\x{1F900}-\x{1F9FF}]/u', '', $text);
$text = preg_replace('/[\x{1F1E0}-\x{1F1FF}]/u', '', $text);

return $text;
}

/**
* saveAttachment
*
Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/en_US/accountancy.lang
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ WarningRecordWithoutSubledgerAreExcluded=Warning, all lines without subledger ac
AccountRemovedFromCurrentChartOfAccount=Accounting account that does not exist in the current chart of accounts

## Admin
BindingOptions=Options for the tool to bind lines with products
BindingOptions=Options for the transfer in accountancy
ApplyMassCategories=Apply mass categories
AddAccountFromBookKeepingWithNoCategories=Available account not yet in the personalized group
CategoryDeleted=Category for the accounting account has been removed
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/admin.lang
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,7 @@ AddMenus=Add menus
AddPermissions=Add permissions
AddExportProfiles=Add export profiles
AddImportProfiles=Add import profiles
AddWebsiteTemplates=Add templates for the website module
AddOtherPagesOrServices=Add other pages or services
AddModels=Add document or numbering templates
AddSubstitutions=Add keys substitutions
Expand Down
Loading

0 comments on commit 085e972

Please sign in to comment.