diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 22035454ef98a..7d480ac493cb8 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -475,12 +475,12 @@ $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref); $substitutionarray['__EMAIL__'] = $thirdparty->email; $substitutionarray['__CHECK_READ__'] = ''; - + if ($oneemailperrecipient) { $substitutionarray['__ONLINE_PAYMENT_URL__'] = ''; $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ''; } - + $parameters = array('mode'=>'formemail'); if (!empty($listofobjectthirdparties)) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8a0b73e8b2f9a..d0f343cad51ba 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2192,7 +2192,9 @@ public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) $sql = "SELECT MAX(te.".$fieldid.")"; $sql .= " FROM ".(empty($nodbprefix) ?$this->db->prefix():'').$this->table_element." as te"; if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql .= ",".$this->db->prefix()."usergroup_user as ug"; + if (empty($user->admin) || !empty($user->entity) || $conf->entity != 1) { + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON ug.fk_user = te.rowid"; + } } if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); @@ -2229,7 +2231,6 @@ public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { $sql .= " AND te.entity IS NOT NULL"; // Show all users } else { - $sql .= " AND ug.fk_user = te.rowid"; $sql .= " AND ug.entity IN (".getEntity('usergroup').")"; } } else { @@ -2262,7 +2263,9 @@ public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) $sql = "SELECT MIN(te.".$fieldid.")"; $sql .= " FROM ".(empty($nodbprefix) ?$this->db->prefix():'').$this->table_element." as te"; if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql .= ",".$this->db->prefix()."usergroup_user as ug"; + if (empty($user->admin) || !empty($user->entity) || $conf->entity != 1) { + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON ug.fk_user = te.rowid"; + } } if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { $tmparray = explode('@', $this->ismultientitymanaged); @@ -2299,7 +2302,6 @@ public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { $sql .= " AND te.entity IS NOT NULL"; // Show all users } else { - $sql .= " AND ug.fk_user = te.rowid"; $sql .= " AND ug.entity IN (".getEntity('usergroup').")"; } } else {