Clean code

This commit is contained in:
Laurent Destailleur 2024-10-24 01:12:58 +02:00
parent d55f90b460
commit ff4344d5c8
9 changed files with 20 additions and 9 deletions

View file

@ -3179,6 +3179,7 @@ class Adherent extends CommonObject
$actioncomm->errors_to = '';
$actioncomm->fk_element = $adherent->id;
$actioncomm->elementid = $adherent->id;
$actioncomm->elementtype = $adherent->element;
$actioncomm->extraparams = $extraparams;

View file

@ -188,12 +188,13 @@ if ($object->id > 0) {
print '</tr>';
$sql = "SELECT ac.id, ac.ref, ac.datep as date_start, ac.datep2 as date_end, ac.label, acr.fk_element";
$sql = "SELECT ac.id, ac.ref, ac.datep as date_start, ac.datep2 as date_end, ac.label, acr.fk_element as elementid";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as ac";
$sql .= " JOIN ".MAIN_DB_PREFIX."actioncomm_resources as acr on acr.fk_actioncomm = ac.id";
$sql .= " WHERE ac.fk_bookcal_calendar = ".((int) $object->id);
$sql .= " AND ac.code = 'AC_RDV'";
$sql .= " AND acr.element_type = 'socpeople'";
$resql = $db->query($sql);
$num = 0;
@ -203,10 +204,10 @@ if ($object->id > 0) {
$tmpcontact = new Contact($db);
$tmpactioncomm = new ActionComm($db);
$num = $db->num_rows($result);
$num = $db->num_rows($resql);
while ($i < $num) {
$obj = $db->fetch_object($resql);
$tmpcontact->fetch($obj->fk_element);
$tmpcontact->fetch($obj->elementid);
$tmpactioncomm->fetch($obj->id);
print '<tr class="oddeven">';
@ -230,7 +231,6 @@ if ($object->id > 0) {
print $tmpcontact->getNomUrl(1, -1);
print '</td>';
print "</tr>\n";
$i++;
}

View file

@ -376,6 +376,7 @@ if (empty($reshook) && $action == 'add' && $usercancreate) {
}
if ($hasPermissionOnLinkedObject) {
$object->fk_element = GETPOSTINT("fk_element");
$object->elementid = GETPOSTINT("fk_element");
$object->elementtype = GETPOST("elementtype", 'alpha');
}
}
@ -402,6 +403,7 @@ if (empty($reshook) && $action == 'add' && $usercancreate) {
}
$object->fk_element = $taskid;
$object->elementid = $taskid;
$object->elementtype = 'task';
}
@ -836,6 +838,7 @@ if (empty($reshook) && $action == 'update' && $usercancreate) {
}
if ($hasPermissionOnLinkedObject) {
$object->fk_element = GETPOSTINT("fk_element");
$object->elementid = GETPOSTINT("fk_element");
$object->elementtype = GETPOST("elementtype", 'alpha');
}
}

View file

@ -273,6 +273,7 @@ class ActionComm extends CommonObject
// Properties for links to other objects
/**
* @var int Id of linked object
* @deprecated Use $elementid
*/
public $fk_element; // Id of record
@ -480,6 +481,9 @@ class ActionComm extends CommonObject
if (empty($this->fk_element) && !empty($this->elementid)) {
$this->fk_element = $this->elementid;
}
if (empty($this->elementid) && !empty($this->fk_element)) {
$this->elementid = $this->fk_element;
}
if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead of an array
$tmpid = (int) $this->userassigned;

View file

@ -947,6 +947,7 @@ if ($resql) {
$event->location = $obj->location;
$event->transparency = $obj->transparency;
$event->fk_element = $obj->fk_element;
$event->elementid = $obj->fk_element;
$event->elementtype = $obj->elementtype;
$event->fk_project = $obj->fk_project;

View file

@ -697,6 +697,7 @@ if ($resql) {
$event->contact_id = $obj->fk_contact;
$event->fk_element = $obj->fk_element;
$event->elementid = $obj->fk_element;
$event->elementtype = $obj->elementtype;
// Defined date_start_in_calendar and date_end_in_calendar property

View file

@ -731,6 +731,7 @@ if ($resql) {
$event->contact_id = $obj->fk_contact;
$event->fk_element = $obj->fk_element;
$event->elementid = $obj->fk_element;
$event->elementtype = $obj->elementtype;
// Defined date_start_in_calendar and date_end_in_calendar property

View file

@ -151,7 +151,7 @@ class AdvanceTargetingMailing extends CommonObject
*/
public function create($user, $notrigger = 0)
{
global $conf, $langs;
global $conf;
$error = 0;
// Clean parameters

View file

@ -417,11 +417,9 @@ class FormAdvTargetEmailing extends Form
*/
public function selectAdvtargetemailingTemplate($htmlname = 'template_id', $selected = 0, $showempty = 0, $type_element = 'mailing', $morecss = '')
{
global $conf, $user, $langs;
$out = '';
$sql = "SELECT c.rowid, c.name, c.fk_element";
$sql = "SELECT c.rowid, c.name, c.fk_element as elementid";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_advtarget as c";
$sql .= " WHERE type_element = '".$this->db->escape($type_element)."'";
$sql .= " ORDER BY c.name";
@ -440,7 +438,7 @@ class FormAdvTargetEmailing extends Form
$obj = $this->db->fetch_object($resql);
$label = $obj->name;
if (empty($label)) {
$label = $obj->fk_element;
$label = (string) $obj->elementid;
}
if ($selected > 0 && $selected == $obj->rowid) {
@ -455,7 +453,9 @@ class FormAdvTargetEmailing extends Form
} else {
dol_print_error($this->db);
}
$this->db->free($resql);
return $out;
}
}