Skip to content

Commit

Permalink
Merge branch '17.0' of https://github.com/Dolibarr/dolibarr into 17.0…
Browse files Browse the repository at this point in the history
…_koesio
  • Loading branch information
atm-lena committed Jan 9, 2025
2 parents 4cb636b + f08c960 commit 6fa26c1
Show file tree
Hide file tree
Showing 44 changed files with 274 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
rev: v4.5.0
hooks:
- id: no-commit-to-branch
args: [--branch, develop, --pattern, \d+.0]
args: [--branch, develop, --pattern, \d+.0$]
- id: check-yaml
args: [--unsafe]
- id: check-json
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/bookkeeping/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@
print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
Expand Down
20 changes: 17 additions & 3 deletions htdocs/accountancy/journal/bankjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
// one line tabpay = line into bank
// one line for bank record = tabbq
// one line for thirdparty record = tabtp
// Note: tabcompany is used to store the subledger account
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($result);
Expand Down Expand Up @@ -263,7 +264,8 @@
);

// Set accountancy code for user
// $obj->accountancy_code is the accountancy_code of table u=user but it is defined only if a link with type 'user' exists)
// $obj->accountancy_code is the accountancy_code of table u=user (but it is defined only if
// a link with type 'user' exists and user as a subledger account)
$compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : '');

$tabuser[$obj->rowid] = array(
Expand Down Expand Up @@ -364,13 +366,25 @@
$userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
$userstatic->statut = $tabuser[$obj->rowid]['status'];
$userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code'];
// For a payment of social contribution, we have a link sc + user.
// but we already fill the $tabpay[$obj->rowid]["soclib"] in the line 'sc'.
// If we fill it here to, we must concat
if ($userstatic->id > 0) {
$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
if ($is_sc) {
$tabpay[$obj->rowid]["soclib"] .= ' '.$userstatic->getNomUrl(1, 'accountancy', 0);
} else {
$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
}
} else {
$tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment.
}

if ($compta_user) {
$tabtp[$obj->rowid][$compta_user] += $amounttouse;
if ($is_sc) {
//$tabcompany[$obj->rowid][$compta_user] += $amounttouse;
} else {
$tabtp[$obj->rowid][$compta_user] += $amounttouse;
}
}
} elseif ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/mails.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

$usersignature = $user->signature;
// For action = test or send, we ensure that content is not html, even for signature, because for this we want a test with NO html.
if ($action == 'test' || ($action == 'send' && $trackid = 'test')) {
if ($action == 'test' || ($action == 'send' && $trackid == 'test')) {
$usersignature = dol_string_nohtmltag($usersignature, 2);
}

Expand Down
47 changes: 45 additions & 2 deletions htdocs/api/class/api_documents.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,52 @@ public function post($filename, $modulepart, $ref = '', $subdir = '', $fileconte
throw new RestException(500, "Failed to open file '".$destfiletmp."' for write");
}

$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1, 1);
$disablevirusscan = 0;
$src_file = $destfiletmp;
$dest_file = $destfile;

// Security:
// If we need to make a virus scan
if (empty($disablevirusscan) && file_exists($src_file)) {
$checkvirusarray = dolCheckVirus($src_file);
if (count($checkvirusarray)) {
dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: errors='.join(',', $checkvirusarray), LOG_WARNING);
throw new RestException(500, 'ErrorFileIsInfectedWithAVirus: '.join(',', $checkvirusarray));
}
}

// Security:
// Disallow file with some extensions. We rename them.
// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
if (isAFileWithExecutableContent($dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) {
// $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too.
$publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity];
if (!preg_match('/\/$/', $publicmediasdirwithslash)) {
$publicmediasdirwithslash .= '/';
}

if (strpos($upload_dir, $publicmediasdirwithslash) !== 0 || !getDolGlobalInt("MAIN_DOCUMENT_DISABLE_NOEXE_IN_MEDIAS_DIR")) { // We never add .noexe on files into media directory
$dest_file .= '.noexe';
}
}

// Security:
// We refuse cache files/dirs, upload using .. and pipes into filenames.
if (preg_match('/^\./', basename($src_file)) || preg_match('/\.\./', $src_file) || preg_match('/[<>|]/', $src_file)) {
dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
throw new RestException(500, "Refused to deliver file ".$src_file);
}

// Security:
// We refuse cache files/dirs, upload using .. and pipes into filenames.
if (preg_match('/^\./', basename($dest_file)) || preg_match('/\.\./', $dest_file) || preg_match('/[<>|]/', $dest_file)) {
dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING);
throw new RestException(500, "Refused to deliver file ".$dest_file);
}

$result = dol_move($destfiletmp, $dest_file, 0, $overwriteifexists, 1, 1);
if (!$result) {
throw new RestException(500, "Failed to move file into '".$destfile."'");
throw new RestException(500, "Failed to move file into '".$dest_file."'");
}

return dol_basename($destfile);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/categories/class/api_categories.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function delete($id)
}

if ($this->category->delete(DolibarrApiAccess::$user) <= 0) {
throw new RestException(500, 'Error when delete category ' . $this->category->error);
throw new RestException(500, 'Error when delete category : ' . $this->category->error);
}

return array(
Expand Down
1 change: 1 addition & 0 deletions htdocs/comm/action/class/actioncomm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,7 @@ public function sendEmailsReminder()

// Load event
$res = $this->fetch($actionCommReminder->fk_actioncomm);
if ($res > 0) $res = $this->fetch_thirdparty();
if ($res > 0) {
// PREPARE EMAIL
$errormesg = '';
Expand Down
5 changes: 4 additions & 1 deletion htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2651,7 +2651,10 @@ public function closeProposal($user, $status, $note = '', $notrigger = 0)
}

$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."', date_signature='".$this->db->idate($date_signature)."', fk_user_signature=".$fk_user_signature;
$sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."'";
if ($status == self::STATUS_SIGNED) {
$sql .= ", date_signature='".$this->db->idate($now)."', fk_user_signature = ".($fk_user_signature);
}
$sql .= " WHERE rowid = ".((int) $this->id);

$resql = $this->db->query($sql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2508,7 +2508,7 @@
$productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
} else {
$generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'];
$generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
$generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'];
}

if ($reliquat > $generic_product->stock_reel) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/bank/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@

$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);


/*
* Actions
*/
Expand Down Expand Up @@ -222,6 +221,7 @@
$object = new Account($db);
$object->fetch(GETPOST("id", 'int'));

$object->oldref = $object->ref;
$object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha')));
$object->label = trim(GETPOST("label", 'alphanohtml'));
$object->courant = GETPOST("type");
Expand Down
27 changes: 27 additions & 0 deletions htdocs/compta/bank/class/account.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ class Account extends CommonObject
*/
public $ics_transfer;

/**
* @var string The previous ref in case of rename on update to rename attachment folders
*/
public $oldref;



/**
Expand Down Expand Up @@ -897,6 +902,28 @@ public function update(User $user, $notrigger = 0)
}
}

if (!$error && !empty($this->oldref) && $this->oldref !== $this->ref) {
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'bank/".$this->db->escape($this->ref)."'";
$sql .= " WHERE filepath = 'bank/".$this->db->escape($this->oldref)."' and src_object_type='bank_account' and entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
}

// We rename directory in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->oldref);
$newref = dol_sanitizeFileName($this->ref);
$dirsource = $conf->bank->dir_output.'/'.$oldref;
$dirdest = $conf->bank->dir_output.'/'.$newref;
if (file_exists($dirsource)) {
dol_syslog(get_class($this)."::update rename dir ".$dirsource." into ".$dirdest, LOG_DEBUG);
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok", LOG_DEBUG);
}
}
}

if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('BANKACCOUNT_MODIFY', $user);
Expand Down
17 changes: 9 additions & 8 deletions htdocs/compta/facture/card-rec.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@
$object = new FactureRec($db);
if (($id > 0 || $ref) && $action != 'create' && $action != 'add') {
$ret = $object->fetch($id, $ref);
if (!$ret) {
if ($ret < 0) {
dol_print_error($db, $object->error, $object->errors);
exit;
} elseif (! $ret) {
setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
}
}
Expand Down Expand Up @@ -1248,6 +1251,7 @@ function showselectfksocieterib(){
if ($object->id > 0) {
$object->fetch_thirdparty();

$formconfirm = '';
// Confirmation de la suppression d'une ligne produit
if ($action == 'ask_deleteline') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
Expand Down Expand Up @@ -1372,14 +1376,10 @@ function showselectfksocieterib(){
}
print '</tr></table>';
print '</td><td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE) {
if ($action == 'editconditions') {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
} else {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none');
}
if ($action == 'editconditions') {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
} else {
print '&nbsp;';
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none');
}
print '</td></tr>';

Expand Down Expand Up @@ -1846,6 +1846,7 @@ function showselectfksocieterib(){
// List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$morehtmlcenter = '';
$somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);

print '</div>';
Expand Down
1 change: 1 addition & 0 deletions htdocs/compta/facture/class/facture-rec.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public function create($user, $facid, $notrigger = 0)
$sql .= ", ".(!empty($this->rule_for_lines_dates) ? ("'".$this->db->escape($this->rule_for_lines_dates)."'") : "NULL");
/** BACKPORT PR 32129 */
$sql .= ")";

if ($this->db->query($sql)) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec");

Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5615,9 +5615,9 @@ public function sendEmailsRemindersOnInvoiceDueDate($nbdays = 0, $paymentmode =
$joinFileName = [];
$joinFileMime = [];
if ($arraymessage->joinfiles == 1 && !empty($tmpinvoice->last_main_doc)) {
$joinFile[] = DOL_DATA_ROOT.$tmpinvoice->last_main_doc;
$joinFile[] = DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc;
$joinFileName[] = basename($tmpinvoice->last_main_doc);
$joinFileMime[] = dol_mimetype(DOL_DATA_ROOT.$tmpinvoice->last_main_doc);
$joinFileMime[] = dol_mimetype(DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc);
}

// Mail Creation
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/stats/cabyprodserv.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@

// Quantity
print '<td class="right">';
print $qty[$key];
print price($qty[$key], 1, $langs, 0, 0);
print '</td>';

// Percent;
Expand Down
5 changes: 5 additions & 0 deletions htdocs/core/actions_massactions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@
$substitutionarray['__EMAIL__'] = $thirdparty->email;
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.urlencode($thirdparty->tag).'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';

if ($oneemailperrecipient) {
$substitutionarray['__ONLINE_PAYMENT_URL__'] = '';
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = '';
}

$parameters = array('mode'=>'formemail');

if (!empty($listofobjectthirdparties)) {
Expand Down
6 changes: 5 additions & 1 deletion htdocs/core/ajax/selectobject.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@
$searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : ''));

// Add a security test to avoid to get content of all tables
restrictedArea($user, $objecttmp->element, $id);
if (!empty($objecttmp->module)) {
restrictedArea($user, $objecttmp->module, $id, $objecttmp->table_element, $objecttmp->element);
} else {
restrictedArea($user, $objecttmp->element, $id);
}

$arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1, 0, '', $filter);

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/boxes/box_actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function loadBox($max = 5)
$sql .= " AND s.rowid = ".((int) $user->socid);
}
if (empty($user->rights->agenda->allactions->read)) {
$sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id).")";
$sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id).")";
}
$sql .= " ORDER BY a.datep ASC";
$sql .= $this->db->plimit($max, 0);
Expand Down
7 changes: 4 additions & 3 deletions htdocs/core/class/CMailFile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ public function sendfile()
}
} elseif ($this->sendmode == 'smtps') {
if (!is_object($this->smtps)) {
$this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>Constructor of object CMailFile was not initialized without errors.";
$this->error = "Failed to send mail with smtps lib to HOST=".ini_get('SMTP').", PORT=".$conf->global->$keyforsmtpport."<br>Constructor of object CMailFile was not initialized without errors.";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
return false;
}
Expand Down Expand Up @@ -1165,9 +1165,10 @@ public function sendfile()
$res = true;
if (!empty($this->error) || !empty($this->errors) || !$result) {
if (!empty($failedRecipients)) {
$this->errors[] = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
$this->error = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
$this->errors[] = $this->error;
}
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
dol_syslog("CMailFile::sendfile: mail end error=". join(' ', $this->errors), LOG_ERR);
$res = false;

if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
Expand Down
Loading

0 comments on commit 6fa26c1

Please sign in to comment.