use of org.olat.core.util.mail.MailPackage in project openolat by klemens.
the class RepositoryEntryDetailsController method doLeave.
protected void doLeave() {
if (guestOnly)
return;
MailerResult result = new MailerResult();
MailPackage reMailing = new MailPackage(result, getWindowControl().getBusinessControl().getAsString(), true);
LeavingStatusList status = new LeavingStatusList();
// leave course
repositoryManager.leave(getIdentity(), entry, status, reMailing);
// leave groups
businessGroupService.leave(getIdentity(), entry, status, reMailing);
// make sur all changes are committed
DBFactory.getInstance().commit();
if (status.isWarningManagedGroup() || status.isWarningManagedCourse()) {
showWarning("sign.out.warning.managed");
} else if (status.isWarningGroupWithMultipleResources()) {
showWarning("sign.out.warning.mutiple.resources");
} else {
showInfo("sign.out.success", new String[] { entry.getDisplayname() });
}
}
use of org.olat.core.util.mail.MailPackage in project openolat by klemens.
the class ACFrontendManager method allowAccesToResource.
@Override
public boolean allowAccesToResource(final Identity identity, final Offer offer) {
// check if offer is ok: key is stupid but further check as date, validity...
if (offer.getKey() == null) {
return false;
}
// check the resource
OLATResource resource = offer.getResource();
if (resource == null || resource.getKey() == null || resource.getResourceableId() == null || resource.getResourceableTypeName() == null) {
return false;
}
String resourceType = resource.getResourceableTypeName();
if ("BusinessGroup".equals(resourceType)) {
BusinessGroup group = businessGroupService.loadBusinessGroup(resource);
if (group != null) {
MailPackage mailing = new MailPackage(offer.isConfirmationEmail());
EnrollState result = businessGroupService.enroll(identity, null, identity, group, mailing);
return !result.isFailed();
}
} else {
RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(resource, false);
if (entry != null) {
if (!repositoryEntryRelationDao.hasRole(identity, entry, GroupRoles.participant.name())) {
repositoryEntryRelationDao.addRole(identity, entry, GroupRoles.participant.name());
if (offer.isConfirmationEmail()) {
MailPackage mailing = new MailPackage(offer.isConfirmationEmail());
RepositoryMailing.sendEmail(identity, identity, entry, RepositoryMailing.Type.addParticipantItself, mailing);
}
}
return true;
}
}
return false;
}
use of org.olat.core.util.mail.MailPackage in project openolat by klemens.
the class RepositoryEntryResource method addOwners.
@PUT
@Path("owners")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addOwners(UserVO[] owners, @PathParam("repoEntryKey") String repoEntryKey, @Context HttpServletRequest request) {
try {
RepositoryEntry repoEntry = lookupRepositoryEntry(repoEntryKey);
if (repoEntry == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
} else if (!isAuthorEditor(repoEntry, request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
List<Identity> identityToAdd = loadIdentities(owners);
UserRequest ureq = RestSecurityHelper.getUserRequest(request);
IdentitiesAddEvent iae = new IdentitiesAddEvent(identityToAdd);
repositoryManager.addOwners(ureq.getIdentity(), iae, repoEntry, new MailPackage(false));
return Response.ok().build();
} catch (Exception e) {
log.error("Trying to add an owner to a repository entry", e);
return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.olat.core.util.mail.MailPackage in project openolat by klemens.
the class CourseWebService method removeParticipant.
/**
* Remove a participant from the course
* @response.representation.200.doc The user was successfully removed as participant of the course
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or the user not found
* @param identityKey The user identifier
* @param httpRequest The HTTP request
* @return It returns 200 if the user is removed as participant of the course
*/
@DELETE
@Path("participants/{identityKey}")
public Response removeParticipant(@PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BaseSecurity securityManager = BaseSecurityManager.getInstance();
Identity participant = securityManager.loadIdentityByKey(identityKey, false);
if (participant == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Identity identity = getIdentity(httpRequest);
// remove the user as participant of the course
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
List<Identity> participants = Collections.singletonList(participant);
rm.removeParticipants(identity, participants, repositoryEntry, new MailPackage(false), false);
return Response.ok().build();
}
use of org.olat.core.util.mail.MailPackage in project openolat by klemens.
the class CourseWebService method addParticipants.
/**
* Add an participant to the course
* @response.representation.200.doc The user is a participant of the course
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or the user not found
* @param identityKey The user identifier
* @param httpRequest The HTTP request
* @return It returns 200 if the user is added as owner and author of the course
*/
@PUT
@Path("participants")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addParticipants(UserVO[] participants, @Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
List<Identity> participantList = loadIdentities(participants);
Identity identity = getIdentity(httpRequest);
UserRequest ureq = getUserRequest(httpRequest);
// add the participants to the course
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
IdentitiesAddEvent iae = new IdentitiesAddEvent(participantList);
rm.addParticipants(identity, ureq.getUserSession().getRoles(), iae, repositoryEntry, new MailPackage(false));
return Response.ok().build();
}
Aggregations