From 4907b3a11a70f57e0b4030c79141769e6367472c Mon Sep 17 00:00:00 2001
From: Dirk Furrer <none@none>
Date: Tue, 16 Dec 2014 16:10:21 +0100
Subject: [PATCH] OO-998: - fixed error-clearing issue - de_i18nkeys - wrong
 collected recepient adresses

---
 .../org/olat/course/nodes/COCourseNode.java   |  2 +-
 .../olat/course/nodes/co/COConfigForm.java    | 46 +++++++++++++++----
 .../olat/course/nodes/co/CORunController.java |  4 +-
 .../nodes/co/_i18n/LocalStrings_de.properties | 12 ++---
 4 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/olat/course/nodes/COCourseNode.java b/src/main/java/org/olat/course/nodes/COCourseNode.java
index 8f1e405b34e..e31b1afa488 100755
--- a/src/main/java/org/olat/course/nodes/COCourseNode.java
+++ b/src/main/java/org/olat/course/nodes/COCourseNode.java
@@ -183,7 +183,7 @@ public class COCourseNode extends AbstractAccessableCourseNode {
         @SuppressWarnings("unchecked")
         List<Long> coachesAreaKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA_IDS);
         if(coachesAreaKeys != null) {
-            String coachesAreaNames = envMapper.toAreaNames(coachesAreaKeys);    
+            String coachesAreaNames = envMapper.toAreaNames(coachesAreaKeys);
             mc.set(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA, coachesAreaNames);
         }
         
diff --git a/src/main/java/org/olat/course/nodes/co/COConfigForm.java b/src/main/java/org/olat/course/nodes/co/COConfigForm.java
index d4203a6c234..08f650fb01d 100755
--- a/src/main/java/org/olat/course/nodes/co/COConfigForm.java
+++ b/src/main/java/org/olat/course/nodes/co/COConfigForm.java
@@ -50,6 +50,7 @@ import org.olat.course.condition.AreaSelectionController;
 import org.olat.course.condition.GroupSelectionController;
 import org.olat.course.editor.CourseEditorEnv;
 import org.olat.course.run.userview.UserCourseEnvironment;
+import org.olat.group.BusinessGroup;
 import org.olat.group.BusinessGroupService;
 import org.olat.group.BusinessGroupShort;
 import org.olat.group.area.BGArea;
@@ -179,6 +180,8 @@ public class COConfigForm extends FormBasicController {
 			if(!coachesChoice.isOneSelected()){
 				coachesChoice.setErrorKey("error.no.choice.specified", null);
 				return false;
+			}else{
+				coachesChoice.clearError();
 			}
 			if(coachesChoice.isSelected(2) &&(isEmpty(easyAreaCoachSelectionList)|| easyAreaCoachSelectionList == null)){
 				if(easyGroupCoachSelectionList.getValue() == null && isEmpty(easyGroupCoachSelectionList) || easyGroupCoachSelectionList.getValue().equals("")){
@@ -186,7 +189,6 @@ public class COConfigForm extends FormBasicController {
 					easyGroupCoachSelectionList.setErrorKey("error.no.group.specified", null);
 					return false;
 				}
-				
 			}
 		}
 
@@ -194,6 +196,8 @@ public class COConfigForm extends FormBasicController {
 			if(!participantsChoice.isOneSelected()){
 				participantsChoice.setErrorKey("error.no.choice.specified", null);
 				return false;
+			}else{
+				participantsChoice.clearError();
 			}
 			if(participantsChoice.isSelected(2) &&(isEmpty(easyAreaParticipantsSelectionList)|| easyAreaParticipantsSelectionList == null)){
 				if(easyGroupParticipantsSelectionList.getValue() == null && isEmpty(easyGroupParticipantsSelectionList)|| easyGroupParticipantsSelectionList.getValue().equals("")){
@@ -368,7 +372,7 @@ public class COConfigForm extends FormBasicController {
 		if( ownerSelection!= null){
 			wantOwners.select("xx", ownerSelection.booleanValue());
 		}
-
+		
 		wantOwners.addActionListener(FormEvent.ONCLICK);
 		
 
@@ -395,6 +399,11 @@ public class COConfigForm extends FormBasicController {
 		chooseGroupCoachesLink.setIconLeftCSS("o_icon o_icon-fw o_icon_group");
 		chooseGroupCoachesLink.setVisible(false);
 		chooseGroupCoachesLink.setLabel("form.message.group", null);
+		
+		if(cev.getCourseGroupManager().getAllBusinessGroups().isEmpty()){
+			chooseGroupCoachesLink.setI18nKey("groupCreate");
+		}
+		
 		chooseGroupCoachesLink.setElementCssClass("o_omit_margin");
 
 		String groupCoachesInitVal;
@@ -417,6 +426,10 @@ public class COConfigForm extends FormBasicController {
 		chooseAreasCoachesLink.setLabel("form.message.area", null);
 		chooseAreasCoachesLink.setElementCssClass("o_omit_margin");
 		
+		if(cev.getCourseGroupManager().getAllAreas().isEmpty()){
+			chooseAreasCoachesLink.setI18nKey("areaCreate");
+		}
+		
 		String areaCoachesInitVal;
 		@SuppressWarnings("unchecked")
 		List<Long> areaCoachesKeys = (List<Long>)config.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA_IDS);
@@ -456,6 +469,10 @@ public class COConfigForm extends FormBasicController {
 		chooseGroupParticipantsLink.setLabel("form.message.group", null);
 		chooseGroupParticipantsLink.setElementCssClass("o_omit_margin");
 
+		if(cev.getCourseGroupManager().getAllBusinessGroups().isEmpty()){
+			chooseGroupParticipantsLink.setI18nKey("groupCreate");
+		}
+		
 		String groupParticipantsInitVal;
 		@SuppressWarnings("unchecked")
 		List<Long> groupParticipantsKeys = (List<Long>)config.get(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_GROUP_ID);
@@ -477,6 +494,10 @@ public class COConfigForm extends FormBasicController {
 		chooseAreasParticipantsLink.setLabel("form.message.area", null);
 		chooseAreasParticipantsLink.setElementCssClass("o_omit_margin");
 
+		if(cev.getCourseGroupManager().getAllAreas().isEmpty()){
+			chooseAreasParticipantsLink.setI18nKey("areaCreate");
+		}
+		
 		String areaParticipantsInitVal;
 		@SuppressWarnings("unchecked")
 		List<Long> areaParticipantsKeys = (List<Long>)config.get(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS_AREA_ID);
@@ -510,15 +531,12 @@ public class COConfigForm extends FormBasicController {
 	}
 
 	private void update () {
-		
-		
 		coachesChoice.setVisible(wantCoaches.isSelected(0));
 		chooseGroupCoachesLink.setVisible(coachesChoice.isSelected(2) && wantCoaches.isSelected(0));
 		chooseAreasCoachesLink.setVisible(coachesChoice.isSelected(2) && wantCoaches.isSelected(0));
 		easyGroupCoachSelectionList.setVisible(coachesChoice.isSelected(2) && wantCoaches.isSelected(0));
 		easyAreaCoachSelectionList.setVisible(coachesChoice.isSelected(2) && wantCoaches.isSelected(0));
 		
-		
 		participantsChoice.setVisible(wantParticipants.isSelected(0));
 		chooseGroupParticipantsLink.setVisible(participantsChoice.isSelected(2) && wantParticipants.isSelected(0));
 		chooseAreasParticipantsLink.setVisible(participantsChoice.isSelected(2) && wantParticipants.isSelected(0));
@@ -532,6 +550,14 @@ public class COConfigForm extends FormBasicController {
 			eList = null;
 		}
 		
+		easyGroupParticipantsSelectionList.clearError();
+		easyAreaParticipantsSelectionList.clearError();
+		easyGroupCoachSelectionList.clearError();
+		easyAreaCoachSelectionList.clearError();
+		
+		coachesChoice.clearError();
+		participantsChoice.clearError();
+		
 		recipentsContainer.clearError();
 		flc.setDirty(true);
 	}
@@ -541,9 +567,7 @@ public class COConfigForm extends FormBasicController {
 		if (source == chooseGroupCoachesLink) {
 			removeAsListenerAndDispose(cmc);
 			removeAsListenerAndDispose(groupChooseCoaches);
-			
-			
-			
+
 			groupChooseCoaches = new GroupSelectionController(ureq, getWindowControl(), true,
 					cev.getCourseGroupManager(), getKeys(easyGroupCoachSelectionList));
 			listenTo(groupChooseCoaches);
@@ -606,6 +630,7 @@ public class COConfigForm extends FormBasicController {
 				easyGroupCoachSelectionList.setValue(getGroupNames(groupChooseCoaches.getSelectedKeys()));
 				easyGroupCoachSelectionList.setUserObject(groupChooseCoaches.getSelectedKeys());
 				easyGroupCoachSelectionList.getRootForm().submit(ureq);
+				chooseGroupCoachesLink.setI18nKey("groupCoachesChoose");
 			} else if (Event.CANCELLED_EVENT == event) {
 				cmc.deactivate();
 			}
@@ -615,6 +640,7 @@ public class COConfigForm extends FormBasicController {
 				easyAreaCoachSelectionList.setValue(getAreaNames(areaChooseCoaches.getSelectedKeys()));
 				easyAreaCoachSelectionList.setUserObject(areaChooseCoaches.getSelectedKeys());
 				easyAreaCoachSelectionList.getRootForm().submit(ureq);
+				chooseAreasCoachesLink.setI18nKey("areaCoachesChoose");
 			} else if (event == Event.CANCELLED_EVENT) {
 				cmc.deactivate();
 			}
@@ -624,6 +650,7 @@ public class COConfigForm extends FormBasicController {
 				easyGroupParticipantsSelectionList.setValue(getGroupNames(groupChooseParticipants.getSelectedKeys()));
 				easyGroupParticipantsSelectionList.setUserObject(groupChooseParticipants.getSelectedKeys());
 				easyGroupParticipantsSelectionList.getRootForm().submit(ureq);
+				chooseGroupParticipantsLink.setI18nKey("groupParticipantsChoose");
 			} else if (Event.CANCELLED_EVENT == event) {
 				cmc.deactivate();
 			}
@@ -633,11 +660,12 @@ public class COConfigForm extends FormBasicController {
 				easyAreaParticipantsSelectionList.setValue(getAreaNames(areaChooseParticipants.getSelectedKeys()));
 				easyAreaParticipantsSelectionList.setUserObject(areaChooseParticipants.getSelectedKeys());
 				easyAreaParticipantsSelectionList.getRootForm().submit(ureq);
+				chooseAreasCoachesLink.setI18nKey("areaParticipantsChoose");
 			} else if (event == Event.CANCELLED_EVENT) {
 				cmc.deactivate();
 			}
 		}
-
+		
 	}
 
 	@Override
diff --git a/src/main/java/org/olat/course/nodes/co/CORunController.java b/src/main/java/org/olat/course/nodes/co/CORunController.java
index b5eecfb52af..fe754b48ddf 100755
--- a/src/main/java/org/olat/course/nodes/co/CORunController.java
+++ b/src/main/java/org/olat/course/nodes/co/CORunController.java
@@ -147,11 +147,11 @@ public class CORunController extends BasicController {
 			contactLists.push(cl);
 		}
 		if(participantGroupNames != null){
-			ContactList cl = retrieveCoachesFromAreas(participantGroupKeys);
+			ContactList cl = retrieveParticipantsFromGroups(participantGroupKeys);
 			contactLists.push(cl);
 		}
 		if(participantAreaNames != null){
-			ContactList cl = retrieveCoachesFromAreas(participantAreaKeys);
+			ContactList cl = retrieveParticipantsFromAreas(participantAreaKeys);
 			contactLists.push(cl);
 		}
 		if (coachesAllConfigured != null && coachesAllConfigured.booleanValue()) {
diff --git a/src/main/java/org/olat/course/nodes/co/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/nodes/co/_i18n/LocalStrings_de.properties
index 0c28782be84..c00c5d2b5db 100755
--- a/src/main/java/org/olat/course/nodes/co/_i18n/LocalStrings_de.properties
+++ b/src/main/java/org/olat/course/nodes/co/_i18n/LocalStrings_de.properties
@@ -9,13 +9,13 @@ chelp.co2a=Geben Sie hier den Betreff der Nachricht ein
 chelp.co3=(z.B. E-Mail aus dem Kurs "Methoden_1" im HS 10/11).
 chelp.co4=(z.B. Fragen zum Kurs "Methoden_1").
 chelp.co5=Dieser Text ist optional und kann noch ge\u00E4ndert oder erg\u00E4nzt werden.
-groupCoachesChoose=Gruppe ausw\u00E4hlen/erstellen
-groupParticipantsChoose=Gruppe ausw\u00E4heln/erstellen
+groupCoachesChoose=Gruppe ausw\u00E4hlen
+groupParticipantsChoose=Gruppe ausw\u00E4hlen
 groupCreate=Gruppe erstellen
 condition.accessibility.title=Zugang
-areaCreate=Lernarea erstellen
-areaCoachesChoose=Lernarea ausw\u00E4hlen
-areaParticipantsChoose=Lernarea ausw\u00E4hlen
+areaCreate=Lernbereich erstellen
+areaCoachesChoose=Lernbereich ausw\u00E4hlen
+areaParticipantsChoose=Lernbereich ausw\u00E4hlen
 email.not.specified=Bitte Empf\u00E4nger angeben
 email.not.valid=E-Mail-Adresse ung\u00FCltig
 error.norecipients.long=Es sind keine Empf\u00E4nger f\u00FCr {0} definiert. Diese k\u00F6nnen unter dem Tab "Empf\u00E4nger" angegeben werden.
@@ -48,7 +48,7 @@ message.emailtoadresses=E-Mailadressen
 message.subject=Betreff (Vorlage)
 message.want.email=Versand an E-Mailadressen
 message.want.group=Versand an Gruppenmitglieder
-message.want.coaches=Versand an Coaches
+message.want.coaches=Versand an Betreuer
 message.want.participants=Versand an Teilnehmer
 message.want.owners=Versand an Kurseigent\u00FCmer
 no.recipents.specified=Bitte w\u00E4hlen Sie mindestens eine Empf\u00E4ngerkategorie aus
-- 
GitLab