Clean code

This commit is contained in:
Laurent Destailleur 2023-08-05 14:59:31 +02:00
parent 0658c91bb6
commit 91982253a0
7 changed files with 37 additions and 85 deletions

View File

@ -190,6 +190,10 @@ abstract class CommonObject
*/
public $context = array();
// Properties set and used by Agenda trigger
public $actionmsg;
public $actionmsg2;
/**
* @var string Contains canvas name if record is an alternative canvas record
*/

View File

@ -605,8 +605,10 @@ class InterfaceActionsAuto extends DolibarrTriggers
// Load translation files required by the page
$langs->loadLangs(array("agenda", "other", "orders"));
if (empty($object->actionmsg2)) {
if (empty($object->context['actionmsg2'])) {
$object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
} else {
$object->actionmsg2 = $object->context['actionmsg2'];
}
$object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
@ -947,8 +949,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
// Can also be a value defined by an external module like SENTBYSMS, COMPANY_SENTBYSMS, MEMBER_SENTBYSMS, ...
// Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function).
// Note that these key can be set in agenda setup, only if defined into llx_c_action_trigger
// Load translation files required by the page
if (!empty($object->context['actionmsg']) && empty($object->actionmsg)) {
$object->actionmsg = $object->context['actionmsg'];
}
if (!empty($object->context['actionmsg2']) && empty($object->actionmsg2)) {
$object->actionmsg2 = $object->context['actionmsg2'];
}
if (empty($object->actionmsg2)) {
// Load translation files required by the page
$langs->loadLangs(array("agenda", "other"));
if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key
$object->actionmsg2 = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
@ -958,6 +967,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
}
if (empty($object->actionmsg)) {
// Load translation files required by the page
$langs->loadLangs(array("agenda", "other"));
if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key
$object->actionmsg = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));

View File

@ -259,74 +259,6 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$this->error = "ErrorLDAP ".$ldap->error;
}
}
/*} elseif ($action == 'USER_SETINGROUP') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0) {
// Must edit $object->newgroupid
$usergroup = new UserGroup($this->db);
if ($object->newgroupid > 0) {
$usergroup->fetch($object->newgroupid);
$oldinfo = $usergroup->_load_ldap_info();
$olddn = $usergroup->_load_ldap_dn($oldinfo);
// Verify if entry exist
$container = $usergroup->_load_ldap_dn($oldinfo, 1);
$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
$records = $ldap->search($container, $search);
if (count($records) && $records['count'] == 0) {
$olddn = '';
}
$info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
$dn = $usergroup->_load_ldap_dn($info);
$result = $ldap->update($dn, $info, $user, $olddn);
}
}
if ($result < 0) {
$this->error = "ErrorLDAP ".$ldap->error;
}
}
} elseif ($action == 'USER_REMOVEFROMGROUP') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0) {
// Must edit $object->newgroupid
$usergroup = new UserGroup($this->db);
if ($object->oldgroupid > 0) {
$usergroup->fetch($object->oldgroupid);
$oldinfo = $usergroup->_load_ldap_info();
$olddn = $usergroup->_load_ldap_dn($oldinfo);
// Verify if entry exist
$container = $usergroup->_load_ldap_dn($oldinfo, 1);
$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
$records = $ldap->search($container, $search);
if (count($records) && $records['count'] == 0) {
$olddn = '';
}
$info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
$dn = $usergroup->_load_ldap_dn($info);
$result = $ldap->update($dn, $info, $user, $olddn);
}
}
if ($result < 0) {
$this->error = "ErrorLDAP ".$ldap->error;
}
} */
} elseif ($action == 'USERGROUP_CREATE') {
// Groupes
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);

View File

@ -226,7 +226,6 @@ class CommandeFournisseur extends CommonOrder
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
/**
* 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
@ -2543,7 +2542,7 @@ class CommandeFournisseur extends CommonOrder
$result = 1;
$old_statut = $this->statut;
$this->statut = $statut;
$this->actionmsg2 = $comment;
$this->context['actionmsg2'] = $comment;
// Call trigger
$result_trigger = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user);

View File

@ -2232,7 +2232,6 @@ class SupplierProposal extends CommonObject
$now = dol_now();
$this->nbtodo = $this->nbtodolate = 0;
$clause = " WHERE";
$sql = "SELECT p.rowid, p.ref, p.datec as datec, p.date_cloture as datefin";

View File

@ -75,6 +75,7 @@ class Ticket extends CommonObject
* @var int Thirdparty ID
*/
public $fk_soc;
public $socid;
/**
* @var int Project ID
@ -106,6 +107,11 @@ class Ticket extends CommonObject
*/
public $message;
/**
* @var string Private message
*/
public $private;
/**
* @var int Ticket statut
* @deprecated use status
@ -173,6 +179,11 @@ class Ticket extends CommonObject
*/
public $datec = '';
/**
* @var int Last modification date
*/
public $tms = '';
/**
* @var int Read date
*/
@ -1582,8 +1593,8 @@ class Ticket extends CommonObject
dol_syslog(get_class($this)."::markAsRead");
$resql = $this->db->query($sql);
if ($resql) {
$this->actionmsg = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs));
$this->actionmsg2 = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs));
$this->context['actionmsg'] = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs));
$this->context['actionmsg2'] = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs));
if (!$error && !$notrigger) {
// Call trigger
@ -2919,21 +2930,20 @@ class Ticket extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Object user
* @param int $mode "opened" for askprice to close, "signed" for proposal to invoice
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
* @param User $user Object user
* @param int $mode "opened" for askprice to close, "signed" for proposal to invoice
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
public function load_board($user, $mode)
{
// phpcs:enable
global $conf, $user, $langs;
global $user, $langs;
$now = dol_now();
$delay_warning = 0;
$this->nbtodo = $this->nbtodolate = 0;
$clause = " WHERE";
$sql = "SELECT p.rowid, p.ref, p.datec as datec";

View File

@ -2619,7 +2619,6 @@ class User extends CommonObject
$result = $this->db->query($sql);
if ($result) {
if (!$error && !$notrigger) {
$this->newgroupid = $group; // deprecated. Remove this.
$this->context = array('audit'=>$langs->trans("UserSetInGroup"), 'newgroupid'=>$group);
// Call trigger
@ -2675,7 +2674,6 @@ class User extends CommonObject
$result = $this->db->query($sql);
if ($result) {
if (!$error && !$notrigger) {
$this->oldgroupid = $group; // deprecated. Remove this.
$this->context = array('audit'=>$langs->trans("UserRemovedFromGroup"), 'oldgroupid'=>$group);
// Call trigger
@ -3293,8 +3291,8 @@ class User extends CommonObject
if ($this->email) {
$info["rfc822Mailbox"] = $this->email;
}
if ($this->phone_mobile) {
$info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
if ($this->user_mobile) {
$info["phpgwCellTelephoneNumber"] = $this->user_mobile;
}
}