Browse Source

Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0

Laurent Destailleur 1 year ago
parent
commit
e9f7a1996f

+ 3 - 1
htdocs/contact/card.php

@@ -573,7 +573,9 @@ if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $co
 	$title = $object->lastname;
 }
 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
+if (empty($object->id)) {
+	$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
+}
 
 llxHeader('', $title, $help_url);
 

+ 5 - 12
htdocs/core/class/notify.class.php

@@ -930,23 +930,16 @@ class Notify
 				// content will be sent.
 				$mailTemplateLabel = isset($conf->global->{$notifcode.'_TEMPLATE'}) ? $conf->global->{$notifcode.'_TEMPLATE'} : '';
 				$emailTemplate = null;
-				// Set output language
-				$outputlangs = $langs;
 				if (!empty($mailTemplateLabel)) {
 					include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
 					$formmail = new FormMail($this->db);
-					$emailTemplate = $formmail->getEMailTemplate($this->db, $object_type.'_send', $user, $outputlangs, 0, 1, $labeltouse);
+					$emailTemplate = $formmail->getEMailTemplate($this->db, $object_type.'_send', $user, $langs, 0, 1, $labeltouse);
 				}
 				if (!empty($mailTemplateLabel) && is_object($emailTemplate) && $emailTemplate->id > 0) {
-					if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
-						$outputlangs = new Translate('', $conf);
-						$outputlangs->setDefaultLang($obj->default_lang);
-						$outputlangs->loadLangs(array('main', 'other'));
-					}
-					$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
-					$subject = make_substitutions($emailTemplate->topic, $substitutionarray, $outputlangs);
-					$message = make_substitutions($emailTemplate->content, $substitutionarray, $outputlangs);
+					$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
+					complete_substitutions_array($substitutionarray, $langs, $object);
+					$subject = make_substitutions($emailTemplate->topic, $substitutionarray, $langs);
+					$message = make_substitutions($emailTemplate->content, $substitutionarray, $langs);
 				} else {
 					$message = '';
 					$message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";

+ 10 - 7
htdocs/societe/class/api_contacts.class.php

@@ -65,7 +65,7 @@ class Contacts extends DolibarrApi
 	 * @param	int    $id                  ID of contact
 	 * @param   int    $includecount        Count and return also number of elements the contact is used as a link for
 	 * @param   int    $includeroles        Includes roles of the contact
-	 * @return	array|mixed data without useless information
+	 * @return 	object 						data without useless information
 	 *
 	 * @throws	RestException
 	 */
@@ -317,9 +317,12 @@ class Contacts extends DolibarrApi
 	/**
 	 * Update contact
 	 *
-	 * @param int   $id             Id of contact to update
-	 * @param array $request_data   Datas
-	 * @return int
+	 * @param int $id Id of contact to update
+	 * @param array $request_data Datas
+	 * @return object  Representation of the Contact
+	 * @throws RestException 401
+	 * @throws RestException 404
+	 * @throws RestException 500
 	 */
 	public function put($id, $request_data = null)
 	{
@@ -359,11 +362,11 @@ class Contacts extends DolibarrApi
 			$this->contact->setNoEmail($this->contact->no_email);
 		}
 
-		if ($this->contact->update($id, DolibarrApiAccess::$user, 1, 'update')) {
+		if ($this->contact->update($id, DolibarrApiAccess::$user, 0, 'update') > 0) {
 			return $this->get($id);
+		} else {
+			throw new RestException(500, $this->contact->error);
 		}
-
-		return false;
 	}
 
 	/**

+ 8 - 5
htdocs/societe/class/api_thirdparties.class.php

@@ -288,7 +288,10 @@ class Thirdparties extends DolibarrApi
 	 *
 	 * @param int   $id             Id of thirdparty to update
 	 * @param array $request_data   Datas
-	 * @return array|mixed|boolean
+	 * @return object
+	 * @throws RestException 401
+	 * @throws RestException 404
+	 * @throws RestException 500
 	 */
 	public function put($id, $request_data = null)
 	{
@@ -322,11 +325,11 @@ class Thirdparties extends DolibarrApi
 			$this->company->setNoEmail($this->company->no_email);
 		}
 
-		if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update', 1)) {
+		if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update', 1) > 0) {
 			return $this->get($id);
+		} else {
+			throw new RestException(500, $this->company->error);
 		}
-
-		return false;
 	}
 
 	/**
@@ -1765,7 +1768,7 @@ class Thirdparties extends DolibarrApi
 	 * @param    string	$idprof6		Prof id 6 of third party (Warning, this can return several records)
 	 * @param    string	$email			Email of third party (Warning, this can return several records)
 	 * @param    string	$ref_alias  Name_alias of third party (Warning, this can return several records)
-	 * @return array|mixed cleaned Societe object
+	 * @return object cleaned Societe object
 	 *
 	 * @throws RestException
 	 */