Browse Source

FIX #yogosha17338

Laurent Destailleur 1 year ago
parent
commit
a36601ae8b

+ 3 - 1
htdocs/adherents/admin/member.php

@@ -340,7 +340,9 @@ print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (!empty($conf->global->ADHERE
 print "</td></tr>\n";
 
 // Login/Pass required for members
-print '<tr class="oddeven"><td>'.$langs->trans("AdherentLoginRequired").'</td><td>';
+print '<tr class="oddeven"><td>';
+print $form->textwithpicto($langs->trans("AdherentLoginRequired"), $langs->trans("AdherentLoginRequiredDesc"));
+print '</td><td>';
 print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (!empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED) ? 0 : 1), 1);
 print "</td></tr>\n";
 

+ 26 - 8
htdocs/adherents/card.php

@@ -119,6 +119,10 @@ if ($id) {
 // Security check
 $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
 
+if (!$user->hasRight('adherent', 'creer') && $action == 'edit') {
+	accessforbidden('Not enough permission');
+}
+
 $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
 
 
@@ -293,7 +297,9 @@ if (empty($reshook)) {
 			$object->lastname    = trim(GETPOST("lastname", 'alphanohtml'));
 			$object->gender      = trim(GETPOST("gender", 'alphanohtml'));
 			$object->login       = trim(GETPOST("login", 'alphanohtml'));
-			$object->pass        = trim(GETPOST("pass", 'none'));	// For password, we must use 'none'
+			if (GETPOSTISSET('pass')) {
+				$object->pass        = trim(GETPOST("pass", 'none'));	// For password, we must use 'none'
+			}
 
 			$object->societe     = trim(GETPOST("societe", 'alphanohtml')); // deprecated
 			$object->company     = trim(GETPOST("societe", 'alphanohtml'));
@@ -329,6 +335,7 @@ if (empty($reshook)) {
 
 			// Get status and public property
 			$object->statut = GETPOST("statut", 'alpha');
+			$object->status = GETPOST("statut", 'alpha');
 			$object->public = GETPOST("public", 'alpha');
 
 			// Fill array 'array_options' with data from add form
@@ -346,10 +353,19 @@ if (empty($reshook)) {
 			}
 
 			// Check if we need to also synchronize password information
-			$nosyncuserpass = 0;
-			if ($object->user_id) {	// If linked to a user
-				if ($user->id != $object->user_id && !$user->hasRight('user', 'user', 'password')) {
-					$nosyncuserpass = 1; // Disable synchronizing
+			$nosyncuserpass = 1;	// no by default
+			if (GETPOSTISSET('pass')) {
+				if ($object->user_id) {	// If member is linked to a user
+					$nosyncuserpass = 0;	// We may try to sync password
+					if ($user->id == $object->user_id) {
+						if (!$user->hasRight('user', 'self', 'password')) {
+							$nosyncuserpass = 1; // Disable synchronizing
+						}
+					} else {
+						if (!$user->hasRight('user', 'user', 'password')) {
+							$nosyncuserpass = 1; // Disable synchronizing
+						}
+					}
 				}
 			}
 
@@ -568,7 +584,7 @@ if (empty($reshook)) {
 		if (!$error) {
 			$db->begin();
 
-			// Email about right and login does not exist
+			// Create the member
 			$result = $object->create($user);
 			if ($result > 0) {
 				// Foundation categories
@@ -576,13 +592,15 @@ if (empty($reshook)) {
 				$object->setCategories($memcats);
 
 				$db->commit();
+
 				$rowid = $object->id;
 				$id = $object->id;
 
 				$backtopage = preg_replace('/__ID__/', $id, $backtopage);
 			} else {
-				$error++;
 				$db->rollback();
+
+				$error++;
 				setEventMessages($object->error, $object->errors, 'errors');
 			}
 
@@ -1215,7 +1233,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 
 		// Password
 		if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
-			print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.dol_escape_htmltag(GETPOSTISSET("pass") ? GETPOST("pass", 'none', 2) : $object->pass).'"></td></tr>';
+			print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.dol_escape_htmltag(GETPOSTISSET("pass") ? GETPOST("pass", 'none', 2) : '').'"></td></tr>';
 		}
 
 		// Type

+ 1 - 1
htdocs/core/class/html.form.class.php

@@ -632,7 +632,7 @@ class Form
 	 * 	@param 	string 	$tooltiptrigger 	''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key)
 	 * 	@param 	int 	$forcenowrap 		Force no wrap between text and picto (works with notabs=2 only)
 	 * 	@return string                      Code html du tooltip (texte+picto)
-	 * 	@see    textwithpicto() 			Use thisfunction if you can.
+	 * 	@see    textwithpicto() 			Use textwithpicto() instead of textwithtooltip if you can.
 	 */
 	public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0)
 	{

+ 2 - 1
htdocs/langs/en_US/admin.lang

@@ -1508,7 +1508,8 @@ WatermarkOnDraftContractCards=Watermark on draft contracts (none if empty)
 MembersSetup=Members module setup
 MemberMainOptions=Main options
 MemberCodeChecker=Options for automatic generation of member codes
-AdherentLoginRequired= Manage a Login for each member
+AdherentLoginRequired=Manage a login/password for each member
+AdherentLoginRequiredDesc=Add a value for a login and a password on the member file. If the member is linked to a user, updating the member login and password will also update the user login and password.
 AdherentMailRequired=Email required to create a new member
 MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default
 MemberCreateAnExternalUserForSubscriptionValidated=Create an external user login for each new member subscription validated

+ 1 - 1
htdocs/langs/fr_FR/admin.lang

@@ -1508,7 +1508,7 @@ WatermarkOnDraftContractCards=Filigrane sur les brouillons de contrats (aucun si
 MembersSetup=Configuration du module Adhérents
 MemberMainOptions=Options principales
 MemberCodeChecker=Options de génération automatique des codes des adhérents
-AdherentLoginRequired= Gérer un identifiant pour chaque adhérent
+AdherentLoginRequired=Gérer un identifiant pour chaque adhérent
 AdherentMailRequired=Email obligatoire pour créer un nouvel adhérent
 MemberSendInformationByMailByDefault=Case à cocher pour envoyer un email de confirmation (validation ou nouvelle cotisation) aux adhérents est à oui par défaut.
 MemberCreateAnExternalUserForSubscriptionValidated=Créer un utilisateur externe pour chaque nouvelle cotisation adhérent validée