diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 8e5ed262fe4..256f89219cd 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -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; diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index f00e0303550..3a18a668724 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -188,12 +188,13 @@ if ($object->id > 0) { print ''; - $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 ''; @@ -230,7 +231,6 @@ if ($object->id > 0) { print $tmpcontact->getNomUrl(1, -1); print ''; - print "\n"; $i++; } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 38812429661..843ccc40575 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -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'); } } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1c51b37d5c7..e4858c21f94 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -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; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 78b71241705..f58894c212c 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -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; diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index b42264712ab..d5dda3a95cd 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -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 diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 88dd5e5d7c8..1274346b70f 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -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 diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 5b37f801dcb..47f23fac914 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -151,7 +151,7 @@ class AdvanceTargetingMailing extends CommonObject */ public function create($user, $notrigger = 0) { - global $conf, $langs; + global $conf; $error = 0; // Clean parameters diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 01957c93456..b66f0314490 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -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; } }