diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index ae7c0cd6dc4..2f882455c8a 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -77,7 +77,7 @@ if (!empty($user->socid)) { // We check permission. // Check is done on $user->rights->element->create or $user->rights->element->subelement->create (because $action = 'set') -if (preg_match('/status$/', $field) || ($field == 'evenunsubscribe' && $object->table_element == 'mailing')) { +if (preg_match('/statu[st]$/', $field) || ($field == 'evenunsubscribe' && $object->table_element == 'mailing')) { restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission); } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products restrictedArea($user, 'produit|service', $object, 'product&product', '', '', 'rowid'); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 25a5331ab09..4221879a439 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -802,16 +802,20 @@ abstract class CommonDocGenerator if (isset($line->fk_product) && $line->fk_product > 0) { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($line->fk_product); - foreach ($tmpproduct->array_options as $key => $label) { - $resarray["line_product_".$key] = $label; + if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) { + foreach ($tmpproduct->array_options as $key => $label) { + $resarray["line_product_".$key] = $label; + } } } else { // Set unused placeholders as blank $extrafields->fetch_name_optionals_label("product"); $extralabels = $extrafields->attributes["product"]['label']; - foreach ($extralabels as $key => $label) { - $resarray['line_product_options_'.$key] = ''; + if (!empty($extralabels) && is_array($extralabels)) { + foreach ($extralabels as $key => $label) { + $resarray['line_product_options_'.$key] = ''; + } } } @@ -908,13 +912,17 @@ abstract class CommonDocGenerator $array_other['object_'.$key] = $value; } elseif (is_array($value) && $recursive) { $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); - foreach ($tmparray as $key2 => $value2) { - $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + if (!empty($tmparray) && is_array($tmparray)) { + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } elseif (is_object($value) && $recursive) { $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); - foreach ($tmparray as $key2 => $value2) { - $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + if (!empty($tmparray) && is_array($tmparray)) { + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index a86a04c330a..21aec87bc9f 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2817,7 +2817,7 @@ class EmailCollector extends CommonObject $sql .= ' FROM ' . MAIN_DB_PREFIX . $objectdesc['table'] . ' AS t'; $sql .= ' WHERE '; foreach ($objectdesc['fields'] as $field) { - $sql .= "'" .$this->db->escape($subject) . "' LIKE CONCAT('%', t." . $field . ", '%') OR "; + $sql .= "('" .$this->db->escape($subject) . "' LIKE CONCAT('%', t." . $field . ", '%') AND t." . $field . "<>'') OR "; } $sql = substr($sql, 0, -4); diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 426ed9eaefc..2e50b917e76 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -1124,6 +1124,30 @@ class ConferenceOrBoothAttendee extends CommonObject return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } + + /** + * Return full name ('name+' '+lastname) + * + * @param Translate $langs Language object for translation of civility (used only if option is 1) + * @param int $option 0=No option + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname + * @param int $maxlen Maximum length + * @return string String with full name + */ + public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) + { + $lastname = $this->lastname; + $firstname = $this->firstname; + if (empty($lastname)) { + $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : ''))))); + } + + $ret = ''; + + $ret .= dolGetFirstLastname($firstname, $lastname, $nameorder); + + return dol_trunc($ret, $maxlen); + } }