2
0
forked from Wavyzz/dolibarr

Qual common signed object trait (#30913)

* Moved signed status properties & methods to reusable class trait

* Cleaned code

* Updated EN localization

* Fixed Phan warnings

* Fixed Phan warnings

* Added type check. Updated PHPDoc.

* Refactored class properties

* Cleaned PHPDoc

* Revert "Refactored class properties"

This reverts commit 1beb40a7

* Reapply "Refactored class properties"

This reverts commit 9e3d9d554c.

* Fixed PHPDoc

* Fixed class file name
This commit is contained in:
William Mead
2024-09-10 16:22:25 +02:00
committed by GitHub
parent be2aa6feb3
commit d0c96c99e0
5 changed files with 190 additions and 204 deletions

View File

@@ -10725,56 +10725,6 @@ abstract class CommonObject
}
}
/**
* Set signed status & call trigger with context message
*
* @param User $user Object user that modify
* @param int $status New signed status to set (often a constant like self::STATUS_XXX)
* @param int $notrigger 1 = Does not execute triggers, 0 = Execute triggers
* @param string $triggercode Trigger code to use
* @return int 0 < if KO, > 0 if OK
*/
public function setSignedStatusCommon(User $user, int $status, int $notrigger = 0, string $triggercode = '')
{
$error = 0;
$this->db->begin();
$statusfield = 'signed_status';
$sql = "UPDATE ".$this->db->prefix().$this->table_element;
$sql .= " SET ".$statusfield." = ".((int) $status);
$sql .= " WHERE rowid = ".((int) $this->id);
if ($this->db->query($sql)) {
if (!$error) {
$this->oldcopy = clone $this;
}
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger($triggercode, $user);
if ($result < 0) {
$error++;
}
}
if (!$error) {
$this->signed_status = $status;
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return -1;
}
} else {
$this->error = $this->db->error();
$this->db->rollback();
return -1;
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen