Skip to content
Snippets Groups Projects
Commit c55f2ee6 authored by rhaag's avatar rhaag
Browse files

FXOLAT-193 backport of OLAT-6342: no rs when adding again, show info-msg for user instead

--HG--
branch : uzhFixes711
parent cfd8c2dc
Branches
Tags
No related merge requests found
......@@ -141,11 +141,13 @@ public class ProjectGroupController extends BasicController {
ProjectBrokerManagerFactory.getProjectGroupManager().removeCandidates(((IdentitiesRemoveEvent)event).getRemovedIdentities(), project);
fireEvent(urequest, Event.CHANGED_EVENT );
} else if (event instanceof IdentitiesMoveEvent) {
IdentitiesMoveEvent identitiesMoveEvent = (IdentitiesMoveEvent) event;
ProjectBrokerManagerFactory.getProjectGroupManager().acceptCandidates(identitiesMoveEvent.getChosenIdentities(), project, urequest.getIdentity(),
final IdentitiesMoveEvent identitiesMoveEvent = (IdentitiesMoveEvent) event;
//OLAT-6342: check identity not in group first!
List<Identity> moveIdents = identitiesMoveEvent.getChosenIdentities();
BusinessGroupAddResponse response = ProjectBrokerManagerFactory.getProjectGroupManager().acceptCandidates(moveIdents, project, urequest.getIdentity(),
projectBrokerModuleConfiguration.isAutoSignOut(), projectBrokerModuleConfiguration.isAcceptSelectionManually());
identitiesMoveEvent.setMovedIdentities(identitiesMoveEvent.getChosenIdentities());
identitiesMoveEvent.setNotMovedIdentities(new ArrayList());
identitiesMoveEvent.setMovedIdentities(response.getAddedIdentities());
identitiesMoveEvent.setNotMovedIdentities(response.getIdentitiesAlreadyInGroup());
// send mail for all of them
MailerWithTemplate mailer = MailerWithTemplate.getInstance();
MailTemplate mailTemplate = identitiesMoveEvent.getMailTemplate();
......
......@@ -11,6 +11,7 @@ import org.olat.course.nodes.projectbroker.datamodel.Project;
import org.olat.course.properties.CoursePropertyManager;
import org.olat.course.run.environment.CourseEnvironment;
import org.olat.group.BusinessGroup;
import org.olat.group.BusinessGroupAddResponse;
public interface ProjectGroupManager {
......@@ -95,7 +96,7 @@ public interface ProjectGroupManager {
* @param isAcceptSelectionManually
* @return
*/
public boolean acceptCandidates(List<Identity> identities, Project project, Identity actionIdentity, boolean autoSignOut, boolean isAcceptSelectionManually);
public BusinessGroupAddResponse acceptCandidates(List<Identity> identities, Project project, Identity actionIdentity, boolean autoSignOut, boolean isAcceptSelectionManually);
/**
* Add identities as candidates.
......
......@@ -45,6 +45,7 @@ import org.olat.course.nodes.projectbroker.datamodel.Project;
import org.olat.course.properties.CoursePropertyManager;
import org.olat.course.run.environment.CourseEnvironment;
import org.olat.group.BusinessGroup;
import org.olat.group.BusinessGroupAddResponse;
import org.olat.group.BusinessGroupFactory;
import org.olat.group.BusinessGroupImpl;
import org.olat.group.BusinessGroupManagerImpl;
......@@ -245,23 +246,28 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou
Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync");
}
public boolean acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) {
public BusinessGroupAddResponse acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) {
Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync");
final Project reloadedProject = (Project) DBFactory.getInstance().loadObject(project, true);
final BusinessGroupAddResponse response = new BusinessGroupAddResponse();
Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<Boolean>(){
public Boolean execute() {
for (Identity identity : identities ) {
for (final Identity identity : identities) {
if (!BaseSecurityManager.getInstance().isIdentityInSecurityGroup(identity, reloadedProject.getProjectGroup().getPartipiciantGroup())) {
BaseSecurityManager.getInstance().removeIdentityFromSecurityGroup(identity, reloadedProject.getCandidateGroup());
BGConfigFlags flags = BGConfigFlags.createRightGroupDefaultFlags();
final BGConfigFlags flags = BGConfigFlags.createRightGroupDefaultFlags();
BusinessGroupManagerImpl.getInstance().addParticipantAndFireEvent(actionIdentity, identity, reloadedProject.getProjectGroup(), flags, false);
logAudit("ProjectBroker: Accept candidate, identity=" + identity + " project=" + reloadedProject);
// fireEvents ?
response.getAddedIdentities().add(identity);
} else {
response.getIdentitiesAlreadyInGroup().add(identity);
}
}
return Boolean.TRUE;
}
});// end of doInSync
if (autoSignOut && result.booleanValue()) {
ProjectBrokerManagerFactory.getProjectBrokerManager().signOutFormAllCandidateList(identities, reloadedProject.getProjectBroker().getKey());
ProjectBrokerManagerFactory.getProjectBrokerManager().signOutFormAllCandidateList(response.getAddedIdentities(), reloadedProject.getProjectBroker().getKey());
}
if (isAcceptSelectionManually && (reloadedProject.getMaxMembers() != Project.MAX_MEMBERS_UNLIMITED)
&& reloadedProject.getSelectedPlaces() >= reloadedProject.getMaxMembers()) {
......@@ -270,7 +276,7 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou
}
Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync");
return result.booleanValue();
return response;
}
@Override
......
......@@ -43,7 +43,7 @@ public class BusinessGroupAddResponse {
/* Output-list of Identity which are added */
private List<Identity> identitiesWithoutPermission;
BusinessGroupAddResponse() {
public BusinessGroupAddResponse() {
addedIdentities = new ArrayList<Identity>();
identitiesAlreadyInGroup = new ArrayList<Identity>();
identitiesWithoutPermission = new ArrayList<Identity>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment