mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Clean code+warnings: The delete() method of AdherentType, Contact,
Delivery, MultiCurrency, CurrencyRate now need $user as first parameter.
This commit is contained in:
parent
a629cebb79
commit
56e8872ddc
|
|
@ -249,7 +249,8 @@ The following changes may create regressions for some external modules, but were
|
|||
* New hook files of modules actions_mymodule.class.php should now "extends CommonHookActions"
|
||||
* Endpoint for API /partnershipapi and /recruitment has been renamed into /partnerships and /recruitments to follow name conventions.
|
||||
* Hidden option ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT has been renamed into ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT
|
||||
|
||||
* The delete() method of AdherentType, Contact, Delivery, MultiCurrency, CurrencyRate now need $user as first parameter.
|
||||
|
||||
***** ChangeLog for 18.0.3 compared to 18.0.2 *****
|
||||
FIX: #25793 Cannot add time spent (#26405)
|
||||
FIX: #26100 Ticket - On edit, list of closed project must be excluded (#26223)
|
||||
|
|
|
|||
|
|
@ -1030,8 +1030,6 @@ class Adherent extends CommonObject
|
|||
*/
|
||||
public function delete($rowid, $user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$result = 0;
|
||||
$error = 0;
|
||||
$errorflag = 0;
|
||||
|
|
|
|||
|
|
@ -453,14 +453,12 @@ class AdherentType extends CommonObject
|
|||
|
||||
/**
|
||||
* Function to delete the member's status
|
||||
* TODO Add param "User $user"
|
||||
*
|
||||
* @return int > 0 if OK, 0 if not found, < 0 if KO
|
||||
* @param User $user User making the deletion
|
||||
* @return int > 0 if OK, 0 if not found, < 0 if KO
|
||||
*/
|
||||
public function delete()
|
||||
public function delete($user)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ class MembersTypes extends DolibarrApi
|
|||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$res = $membertype->delete();
|
||||
$res = $membertype->delete(DolibarrApiAccess::$user);
|
||||
if ($res < 0) {
|
||||
throw new RestException(500, "Can't delete, error occurs");
|
||||
} elseif ($res == 0) {
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ if ($action == 'update' && $user->hasRight('adherent', 'configurer')) {
|
|||
|
||||
if ($action == 'confirm_delete' && $user->hasRight('adherent', 'configurer')) {
|
||||
$object->fetch($rowid);
|
||||
$res = $object->delete();
|
||||
$res = $object->delete($user);
|
||||
|
||||
if ($res > 0) {
|
||||
setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
|
||||
|
|
|
|||
|
|
@ -1021,6 +1021,7 @@ class ActionComm extends CommonObject
|
|||
|
||||
/**
|
||||
* Delete event from database
|
||||
* @TODO Add User $user as first param
|
||||
*
|
||||
* @param int $notrigger 1 = disable triggers, 0 = enable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
|
|
|
|||
|
|
@ -208,18 +208,6 @@ if (GETPOST("viewperuser", 'alpha') || $mode == 'show_peruser') {
|
|||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
if ($action == 'delete_action' && $user->rights->agenda->delete) {
|
||||
$event = new ActionComm($db);
|
||||
$event->fetch($actionid);
|
||||
$event->fetch_optionals();
|
||||
$event->fetch_userassigned();
|
||||
$event->oldcopy = dol_clone($event);
|
||||
|
||||
$result = $event->delete();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
|
|
|
|||
|
|
@ -196,17 +196,7 @@ $search_status = $status;
|
|||
* Actions
|
||||
*/
|
||||
|
||||
/*
|
||||
if ($action == 'delete_action' && $user->rights->agenda->delete) {
|
||||
$event = new ActionComm($db);
|
||||
$event->fetch($actionid);
|
||||
$event->fetch_optionals();
|
||||
$event->fetch_userassigned();
|
||||
$event->oldcopy = dol_clone($event);
|
||||
|
||||
$result = $event->delete();
|
||||
}
|
||||
*/
|
||||
// None
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -192,17 +192,7 @@ $search_status = $status;
|
|||
* Actions
|
||||
*/
|
||||
|
||||
/*
|
||||
if ($action == 'delete_action' && $user->rights->agenda->delete) {
|
||||
$event = new ActionComm($db);
|
||||
$event->fetch($actionid);
|
||||
$event->fetch_optionals();
|
||||
$event->fetch_userassigned();
|
||||
$event->oldcopy = dol_clone($event);
|
||||
|
||||
$result = $event->delete();
|
||||
}
|
||||
*/
|
||||
// None
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2177,7 +2177,7 @@ class AccountLine extends CommonObjectLine
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete bank transaction record
|
||||
* Delete bank transaction record
|
||||
*
|
||||
* @param User|null $user User object that delete
|
||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||
|
|
@ -2185,8 +2185,6 @@ class AccountLine extends CommonObjectLine
|
|||
*/
|
||||
public function delete(User $user = null, $notrigger = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$nbko = 0;
|
||||
|
||||
if ($this->rappro) {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ if ($action == 'remove' && $id > 0 && GETPOST("lineid", 'int') > 0 && $user->has
|
|||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
|
||||
$object->id = $id;
|
||||
$result = $object->delete();
|
||||
$result = $object->delete($user);
|
||||
if ($result == 0) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@ class RemiseCheque extends CommonObject
|
|||
global $conf;
|
||||
|
||||
$this->errno = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bordereau_cheque";
|
||||
|
|
|
|||
|
|
@ -540,16 +540,17 @@ class Paiement extends CommonObject
|
|||
|
||||
|
||||
/**
|
||||
* Delete a payment and generated links into account
|
||||
* Delete a payment and generated links into account
|
||||
* - Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
|
||||
* - Si le paiement porte sur au moins une facture a "payee", on refuse
|
||||
* @TODO Add first param User $user
|
||||
*
|
||||
* @param int $notrigger No trigger
|
||||
* @return int <0 si ko, >0 si ok
|
||||
* @param int $notrigger No trigger
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($notrigger = 0)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -431,7 +431,6 @@ class PaymentSocialContribution extends CommonObject
|
|||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this)."::delete");
|
||||
|
|
@ -441,7 +440,7 @@ class PaymentSocialContribution extends CommonObject
|
|||
if ($this->bank_line > 0) {
|
||||
$accline = new AccountLine($this->db);
|
||||
$accline->fetch($this->bank_line);
|
||||
$result = $accline->delete();
|
||||
$result = $accline->delete($user);
|
||||
if ($result < 0) {
|
||||
$this->errors[] = $accline->error;
|
||||
$error++;
|
||||
|
|
|
|||
|
|
@ -437,7 +437,6 @@ class PaymentVAT extends CommonObject
|
|||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this)."::delete");
|
||||
|
|
@ -447,7 +446,7 @@ class PaymentVAT extends CommonObject
|
|||
if ($this->bank_line > 0) {
|
||||
$accline = new AccountLine($this->db);
|
||||
$accline->fetch($this->bank_line);
|
||||
$result = $accline->delete();
|
||||
$result = $accline->delete($user);
|
||||
if ($result < 0) {
|
||||
$this->errors[] = $accline->error;
|
||||
$error++;
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ if (empty($reshook)) {
|
|||
$result = $object->fetch($id);
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$result = $object->delete(); // TODO Add $user as first param
|
||||
$result = $object->delete($user);
|
||||
if ($result > 0) {
|
||||
setEventMessages("RecordDeleted", null, 'mesgs');
|
||||
if ($backurlforlist) {
|
||||
|
|
|
|||
|
|
@ -1218,15 +1218,13 @@ class Contact extends CommonObject
|
|||
|
||||
/**
|
||||
* Delete a contact from database
|
||||
* // TODO Add $user as first param
|
||||
*
|
||||
* @param User $user User making the delete
|
||||
* @param int $notrigger Disable all trigger
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($notrigger = 0)
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
|
|
|||
|
|
@ -1088,7 +1088,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
|
|||
if (in_array($objecttmp->element, array('societe', 'member'))) {
|
||||
$result = $objecttmp->delete($objecttmp->id, $user, 1);
|
||||
} elseif (in_array($objecttmp->element, array('action'))) {
|
||||
$result = $objecttmp->delete();
|
||||
$result = $objecttmp->delete(); // TODO Add User $user as first param
|
||||
} else {
|
||||
$result = $objecttmp->delete($user);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10118,16 +10118,12 @@ abstract class CommonObject
|
|||
$error++;
|
||||
} else {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$result = $this->fetch($obj->rowid);
|
||||
$result = $this->fetch($obj->rowid); // @phpstan-ignore-line
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->errors[] = $this->error;
|
||||
} else {
|
||||
if (get_class($this) == 'Contact') { // TODO special code because delete() for contact has not been standardized like other delete.
|
||||
$result = $this->delete();
|
||||
} else {
|
||||
$result = $this->delete($user);
|
||||
}
|
||||
$result = $this->delete($user); // @phpstan-ignore-line
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->errors[] = $this->error;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ if ($action == 'add') {
|
|||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('expedition', 'delivery', 'supprimer')) {
|
||||
$db->begin();
|
||||
$result = $object->delete();
|
||||
$result = $object->delete($user);
|
||||
|
||||
if ($result > 0) {
|
||||
$db->commit();
|
||||
|
|
|
|||
|
|
@ -676,13 +676,15 @@ class Delivery extends CommonObject
|
|||
/**
|
||||
* Delete object
|
||||
*
|
||||
* @param User $user User making the deletion
|
||||
* @return integer
|
||||
*/
|
||||
public function delete()
|
||||
public function delete($user = null)
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
global $conf, $langs;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$error = 0;
|
||||
|
|
|
|||
|
|
@ -426,13 +426,14 @@ class PaiementFourn extends Paiement
|
|||
* Delete a payment and lines generated into accounts
|
||||
* Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
|
||||
* Si le paiement porte sur au moins une facture a "payee", on refuse
|
||||
* @TODO Add User $user as first param
|
||||
*
|
||||
* @param int $notrigger No trigger
|
||||
* @return int <0 si ko, >0 si ok
|
||||
*/
|
||||
public function delete($notrigger = 0)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $user;
|
||||
|
||||
$bank_line_id = $this->bank_line;
|
||||
|
||||
|
|
|
|||
|
|
@ -332,13 +332,12 @@ class MultiCurrency extends CommonObject
|
|||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param bool $trigger true=launch triggers after, false=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param User $user User making the deletion
|
||||
* @param bool $trigger true=launch triggers after, false=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($trigger = true)
|
||||
public function delete($user, $trigger = true)
|
||||
{
|
||||
global $user;
|
||||
|
||||
dol_syslog('MultiCurrency::delete', LOG_DEBUG);
|
||||
|
||||
$error = 0;
|
||||
|
|
@ -391,8 +390,10 @@ class MultiCurrency extends CommonObject
|
|||
*/
|
||||
public function deleteRates()
|
||||
{
|
||||
global $user;
|
||||
|
||||
foreach ($this->rates as &$rate) {
|
||||
if ($rate->delete() <= 0) {
|
||||
if ($rate->delete($user) <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -952,13 +953,12 @@ class CurrencyRate extends CommonObjectLine
|
|||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param bool $trigger true=launch triggers after, false=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param User $user User making the deletion
|
||||
* @param bool $trigger true=launch triggers after, false=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($trigger = true)
|
||||
public function delete($user, $trigger = true)
|
||||
{
|
||||
global $user;
|
||||
|
||||
dol_syslog('CurrencyRate::delete', LOG_DEBUG);
|
||||
|
||||
$error = 0;
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ if ($action == "confirm_delete") {
|
|||
$current_rate = new CurrencyRate($db);
|
||||
$current_rate->fetch(intval($id_rate_selected));
|
||||
if ($current_rate) {
|
||||
$result = $current_rate->delete();
|
||||
$result = $current_rate->delete($user);
|
||||
if ($result) {
|
||||
setEventMessages($langs->trans('successRateDelete'), null);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -410,7 +410,6 @@ class PaymentSalary extends CommonObject
|
|||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this)."::delete");
|
||||
|
|
@ -420,7 +419,7 @@ class PaymentSalary extends CommonObject
|
|||
if ($this->bank_line > 0) {
|
||||
$accline = new AccountLine($this->db);
|
||||
$accline->fetch($this->bank_line);
|
||||
$result = $accline->delete();
|
||||
$result = $accline->delete($user);
|
||||
if ($result < 0) {
|
||||
$this->errors[] = $accline->error;
|
||||
$error++;
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ class Contacts extends DolibarrApi
|
|||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->contact->oldcopy = clone $this->contact;
|
||||
return $this->contact->delete();
|
||||
return $this->contact->delete(DolibarrApiAccess::$user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -838,13 +838,15 @@ class SupplierProposal extends CommonObject
|
|||
*/
|
||||
public function deleteline($lineid)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($this->statut == 0) {
|
||||
$line = new SupplierProposalLine($this->db);
|
||||
|
||||
// For triggers
|
||||
$line->fetch($lineid);
|
||||
|
||||
if ($line->delete() > 0) {
|
||||
if ($line->delete($user) > 0) {
|
||||
$this->update_price(1);
|
||||
|
||||
return 1;
|
||||
|
|
@ -3192,19 +3194,20 @@ class SupplierProposalLine extends CommonObjectLine
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete line in database
|
||||
* Delete line in database
|
||||
*
|
||||
* @return int <0 if ko, >0 if ok
|
||||
* @param User $user User making the deletion
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete()
|
||||
public function delete($user)
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE rowid = ".((int) $this->id);
|
||||
dol_syslog("SupplierProposalLine::delete", LOG_DEBUG);
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet";
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
// Remove extrafields
|
||||
if (!$error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user