use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class CourseRuntimeController method setGlossaryLinkTitle.
private void setGlossaryLinkTitle(UserRequest ureq, Boolean state) {
if (enableGlossaryLink == null)
return;
String oresName = ICourse.class.getSimpleName();
Long courseID = getOlatResourceable().getResourceableId();
// must work with SP and CP nodes, IFrameDisplayController listens to this event and expects "ICourse" resources.
OLATResourceable ores = OresHelper.createOLATResourceableInstance(oresName, courseID);
if (state == null || !state.booleanValue()) {
enableGlossaryLink.setCustomDisplayText(translate("command.glossary.on.alt"));
setTextMarkingEnabled(false);
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(new MultiUserEvent("glossaryOff"), ores);
} else {
enableGlossaryLink.setCustomDisplayText(translate("command.glossary.off.alt"));
setTextMarkingEnabled(true);
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(new MultiUserEvent("glossaryOn"), ores);
}
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class ProfileFormController method formOK.
@Override
protected void formOK(final UserRequest ureq) {
User user = identityToModify.getUser();
// update each user field
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
FormItem formItem = formItems.get(userPropertyHandler.getName());
if (formItem.isEnabled()) {
userPropertyHandler.updateUserFromFormItem(user, formItem);
}
}
if (portraitDeleted) {
File img = dps.getLargestPortrait(identityToModify.getName());
if (img != null) {
dps.deletePortrait(identityToModify);
notifyPortraitChanged();
}
}
File uploadedImage = portraitUpload.getUploadFile();
String uploadedFilename = portraitUpload.getUploadFileName();
if (uploadedImage != null) {
dps.setPortrait(uploadedImage, uploadedFilename, identityToModify.getName());
notifyPortraitChanged();
}
if (logoDeleted) {
File img = dps.getLargestLogo(identityToModify.getName());
if (img != null) {
dps.deleteLogo(identityToModify);
notifyPortraitChanged();
}
}
if (logoUpload != null) {
File uploadedLogo = logoUpload.getUploadFile();
String uploadedLogoname = logoUpload.getUploadFileName();
if (uploadedLogo != null) {
dps.setLogo(uploadedLogo, uploadedLogoname, identityToModify.getName());
notifyPortraitChanged();
}
}
// Store the "about me" text.
HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
conf.setTextAboutMe(textAboutMe.getValue());
hpcm.saveConfigTo(identityToModify.getName(), conf);
// fire the appropriate event
fireEvent(ureq, Event.DONE_EVENT);
// update the user profile data
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(OresHelper.createOLATResourceableInstance(Identity.class, identityToModify.getKey()), new SyncerExecutor() {
@Override
public void execute() {
UserManager um = UserManager.getInstance();
identityToModify = (Identity) DBFactory.getInstance().loadObject(identityToModify);
currentEmail = identityToModify.getUser().getProperty("email", null);
identityToModify = updateIdentityFromFormData(identityToModify);
changedEmail = identityToModify.getUser().getProperty("email", null);
emailChanged = false;
if ((currentEmail == null && StringHelper.containsNonWhitespace(changedEmail)) || (currentEmail != null && !currentEmail.equals(changedEmail))) {
if (isAllowedToChangeEmailWithoutVerification(ureq) || !StringHelper.containsNonWhitespace(changedEmail)) {
String key = identityToModify.getUser().getProperty("emchangeKey", null);
TemporaryKey tempKey = rm.loadTemporaryKeyByRegistrationKey(key);
if (tempKey != null) {
rm.deleteTemporaryKey(tempKey);
}
securityManager.deleteInvalidAuthenticationsByEmail(currentEmail);
} else {
emailChanged = true;
// change email address to old address until it is verified
identityToModify.getUser().setProperty("email", currentEmail);
}
}
if (!um.updateUserFromIdentity(identityToModify)) {
getWindowControl().setInfo(translate("profile.unsuccessful"));
// reload user data from db
identityToModify = BaseSecurityManager.getInstance().loadIdentityByKey(identityToModify.getKey());
}
OLATResourceable modRes = OresHelper.createOLATResourceableInstance(Identity.class, identityToModify.getKey());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new MultiUserEvent("changed"), modRes);
if (!emailChanged) {
fireEvent(ureq, Event.FAILED_EVENT);
}
}
});
if (emailChanged) {
removeAsListenerAndDispose(dialogCtr);
String dialogText = "";
if (identityToModify.equals(ureq.getIdentity())) {
dialogText = translate("email.change.dialog.text");
} else {
dialogText = translate("email.change.dialog.text.usermanager");
}
dialogCtr = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), translate("email.change.dialog.title"), dialogText);
listenTo(dialogCtr);
dialogCtr.activate();
}
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class ConditionConfigEasyController method event.
@Override
protected void event(UserRequest ureq, Controller source, org.olat.core.gui.control.Event event) {
if (source == groupChooseC) {
if (Event.DONE_EVENT == event) {
cmc.deactivate();
List<Long> groupKeys = groupChooseC.getSelectedKeys();
easyGroupList.setUserObject(groupKeys);
easyGroupList.setValue(getGroupNames(groupKeys));
validateGroupFields();
easyGroupList.getRootForm().submit(ureq);
} else if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else if (event == Event.CHANGED_EVENT) {
// a group was created within from within the chooser
}
} else if (source == areaChooseC) {
if (event == Event.DONE_EVENT) {
cmc.deactivate();
List<Long> areaKeys = areaChooseC.getSelectedKeys();
easyAreaList.setUserObject(areaKeys);
easyAreaList.setValue(this.getAreaNames(areaKeys));
validateGroupFields();
easyAreaList.getRootForm().submit(ureq);
} else if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else if (event == Event.CHANGED_EVENT) {
// an area was created within from within the chooser
}
} else if (source == groupCreateCtlr) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
List<Long> c = new ArrayList<Long>();
c.addAll(getKeys(easyGroupList));
if (fixGroupError != null && fixGroupError.getUserObject() != null) {
c.removeAll(Arrays.asList((String[]) fixGroupError.getUserObject()));
}
c.addAll(groupCreateCtlr.getCreatedGroupKeys());
easyGroupList.setValue(getGroupNames(c));
easyGroupList.setUserObject(c);
easyGroupList.getRootForm().submit(ureq);
validateGroupFields();
if (!groupCreateCtlr.getCreatedGroupKeys().isEmpty()) {
singleUserEventCenter.fireEventToListenersOf(new MultiUserEvent("changed"), groupConfigChangeEventOres);
}
}
} else if (source == areaCreateCtlr) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
List<Long> c = new ArrayList<Long>();
c.addAll(getKeys(easyAreaList));
if (fixAreaError != null && fixAreaError.getUserObject() != null) {
c.removeAll(Arrays.asList((String[]) fixAreaError.getUserObject()));
}
c.addAll(areaCreateCtlr.getCreatedAreaKeys());
easyAreaList.setValue(getAreaNames(c));
easyAreaList.setUserObject(c);
easyAreaList.getRootForm().submit(ureq);
validateGroupFields();
if (!areaCreateCtlr.getCreatedAreaKeys().isEmpty()) {
singleUserEventCenter.fireEventToListenersOf(new MultiUserEvent("changed"), groupConfigChangeEventOres);
}
}
}
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class CatalogManager method notifyReferencedRepositoryEntryChanges.
/**
* @param re
*/
public void notifyReferencedRepositoryEntryChanges(RepositoryEntry re) {
// inform anybody interested about this change
MultiUserEvent modifiedEvent = new EntryChangedEvent(re, null, Change.modifiedDescription, "CatalogManager");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, re);
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class PublishProcess method changeAccessAndProperties.
public void changeAccessAndProperties(Identity author, CourseAccessAndProperties accessAndProps) {
RepositoryManager manager = RepositoryManager.getInstance();
manager.setAccessAndProperties(accessAndProps.getRepositoryEntry(), accessAndProps.getAccess(), accessAndProps.isMembersOnly(), accessAndProps.isCanCopy(), accessAndProps.isCanReference(), accessAndProps.isCanDownload());
manager.setLeaveSetting(accessAndProps.getRepositoryEntry(), accessAndProps.getSetting());
List<OfferAccess> offerAccess = accessAndProps.getOfferAccess();
// 1: add new and update existing offerings
ACService acService = CoreSpringFactory.getImpl(ACService.class);
for (OfferAccess newLink : offerAccess) {
if (accessAndProps.getConfirmationEmail() != null) {
Offer offer = newLink.getOffer();
boolean confirmation = accessAndProps.getConfirmationEmail().booleanValue();
if (offer.isConfirmationEmail() != confirmation) {
offer.setConfirmationEmail(confirmation);
if (offer.getKey() != null) {
offer = acService.save(offer);
}
}
}
acService.saveOfferAccess(newLink);
}
// 2: remove offerings not available anymore
List<OfferAccess> deletedOfferAccess = accessAndProps.getDeletedOfferAccess();
for (OfferAccess deletedLink : deletedOfferAccess) {
acService.deletedLinkToMethod(deletedLink);
}
MultiUserEvent modifiedEvent = new EntryChangedEvent(repositoryEntry, author, Change.modifiedAtPublish, "publish");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, repositoryEntry);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
}
Aggregations