common delete also files (#36146)

* common delete also files

* common delete also files

* common delete also files

* common delete also files

* common delete also files

* common delete also files
This commit is contained in:
Frédéric FRANCE 2025-11-07 18:44:14 +01:00 committed by GitHub
parent a420e9a79a
commit cad3574179
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 44 additions and 31 deletions

View file

@ -13956,12 +13956,6 @@ parameters:
count: 1
path: ../../../htdocs/public/recruitment/index.php
-
message: '#^Variable \$dolibarr_main_url_root might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../../htdocs/public/recruitment/index.php
-
message: '#^Left side of && is always true\.$#'
identifier: booleanAnd.leftAlwaysTrue

View file

@ -11051,6 +11051,16 @@ abstract class CommonObject
}
}
if (!$error) {
$dir = getMultidirOutput($this)."/".dol_sanitizeFileName($this->ref);
// For remove dir
if (dol_is_dir($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$this->errors[] = 'ErrorFailToDeleteDir';
}
}
}
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {

View file

@ -2448,7 +2448,7 @@ class ExtraFields
$tmpobject->fetch($value);
if (get_class($tmpobject) == 'Categorie') {
// For category object, rendering must use the same method than the one deinfed into showCategories()
// For category object, rendering must use the same method than the one defined into showCategories()
$color = $tmpobject->color;
$sfortag = '<span class="noborderoncategories"' . ($color ? ' style="background: #' . $color . ';"' : ' style="background: #bbb"') . '>';
$sfortag .= $tmpobject->getNomUrl(3);

View file

@ -137,6 +137,7 @@ function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'outpu
{
global $conf;
$subdirectory = '';
if (!is_object($object) && empty($module)) {
return null;
}
@ -151,6 +152,12 @@ function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'outpu
$module = 'supplier_invoice';
} elseif ($module == 'order_supplier') {
$module = 'supplier_order';
} elseif ($module == 'recruitmentjobposition') {
$module = 'recruitment';
$subdirectory = '/recruitmentjobposition';
} elseif ($module == 'recruitmentcandidature') {
$module = 'recruitment';
$subdirectory = '/recruitmentcandidature';
}
// Get the relative path of directory
@ -158,7 +165,7 @@ function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'outpu
if (isset($conf->$module) && property_exists($conf->$module, 'multidir_output')) {
$s = '';
if ($mode != 'outputrel') {
$s = $conf->$module->multidir_output[(empty($object->entity) ? $conf->entity : $object->entity)];
$s = $conf->$module->multidir_output[(empty($object->entity) ? $conf->entity : $object->entity)] . $subdirectory;
}
if ($forobject && $object->id > 0) {
$s .= ($mode != 'outputrel' ? '/' : '') . get_exdir(0, 0, 0, 0, $object);
@ -167,7 +174,7 @@ function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'outpu
} elseif (isset($conf->$module) && property_exists($conf->$module, 'dir_output')) {
$s = '';
if ($mode != 'outputrel') {
$s = $conf->$module->dir_output;
$s = $conf->$module->dir_output . $subdirectory;
}
if ($forobject && $object->id > 0) {
$s .= ($mode != 'outputrel' ? '/' : '') . get_exdir(0, 0, 0, 0, $object);

View file

@ -639,7 +639,7 @@ class Don extends CommonObject
// For remove dir
if (dol_is_dir($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$this->errors[] = $this->error;
$this->errors[] = 'ErrorFailToDeleteDir';
}
}
}

View file

@ -5,7 +5,7 @@
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2014-2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020-2021 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
@ -609,8 +609,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
if (empty($include_users)) {
print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays");
} else {
// Defined default approver (the forced approved of user or the supervisor if no forced value defined)
// Note: This use will be set only if the deinfed approvr has permission to approve so is inside include_users
// Defined default approver (the forced approver of user or the supervisor if no forced value defined)
// Note: This use will be set only if the defined approver has permission to approve so is inside include_users
$defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
if (getDolGlobalString('HOLIDAY_DEFAULT_VALIDATOR')) {
$defaultselectuser = getDolGlobalString('HOLIDAY_DEFAULT_VALIDATOR'); // Can force default approver

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -38,26 +38,28 @@ if (!defined('NOBROWSERNOTIF')) {
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Societe $mysoc
* @var Translate $langs
*
* @var string $dolibarr_main_url_root
*/
require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("companies", "other", "recruitment"));
// Get parameters
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$SECUREKEY = GETPOST("securekey");
$entity = GETPOSTINT('entity') ? GETPOSTINT('entity') : $conf->entity;
$backtopage = '';
@ -90,7 +92,7 @@ $object = new RecruitmentJobPosition($db);
$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
// Security check
if (empty($conf->recruitment->enabled)) {
if (!isModEnabled('recruitment')) {
httponly_accessforbidden('Module Recruitment not enabled');
}
@ -204,7 +206,7 @@ if (is_array($results)) {
$text = '';
if (getDolGlobalString('RECRUITMENT_NEWFORM_TEXT')) {
$reg = array();
if (preg_match('/^\((.*)\)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) {
if (preg_match('/^\((.*)\)$/', getDolGlobalString('RECRUITMENT_NEWFORM_TEXT'), $reg)) {
$text .= $langs->trans($reg[1])."<br>\n";
} else {
$text .= getDolGlobalString('RECRUITMENT_NEWFORM_TEXT') . "<br>\n";

View file

@ -504,7 +504,6 @@ class RecruitmentJobPosition extends CommonObject
public function delete(User $user, $notrigger = 0)
{
return $this->deleteCommon($user, $notrigger);
//return $this->deleteCommon($user, $notrigger, 1);
}
/**

View file

@ -4,7 +4,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018-2021 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
@ -251,7 +251,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
if ($conf->recruitment->dir_output) {
$dir = getMultidirOutput($object);
if ($dir) {
// If $object is id instead of object
if (!is_object($object)) {
$id = $object;
@ -263,7 +265,6 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
}
}
$dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1].'/recruitmentjobposition/';
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/".$objectref;

View file

@ -226,16 +226,16 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
}
if ($conf->recruitment->dir_output.'/recruitmentjobposition') {
$dir = getMultidirOutput($object);
if ($dir) {
$object->fetch_thirdparty();
// Definition of $dir and $file
if ($object->specimen) {
$dir = $conf->recruitment->dir_output.'/recruitmentjobposition';
$file = $dir."/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->recruitment->dir_output.'/recruitmentjobposition/'.$objectref;
$dir .= '/'.$objectref;
$file = $dir."/".$objectref.".pdf";
}
if (!file_exists($dir)) {