use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class DirectDeleteController method deleteIdentities.
private void deleteIdentities(List<Identity> toDeleteIdentities) {
for (int i = 0; i < toDeleteIdentities.size(); i++) {
Identity identity = toDeleteIdentities.get(i);
UserDeletionManager.getInstance().deleteIdentity(identity);
DBFactory.getInstance().intermediateCommit();
}
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class SelectionForm method handleEmailButtonEvent.
private void handleEmailButtonEvent(UserRequest ureq, TableMultiSelectEvent tmse) {
List<Identity> identities = tdm.getObjects(tmse.getSelection());
if (identities.size() > 0) {
selectedIdentities = identities;
MailTemplate deleteMailTemplate = createMailTemplate(translate(KEY_EMAIL_SUBJECT), translate(KEY_EMAIL_BODY));
deleteMailTemplate.setCpfrom(Boolean.FALSE);
deleteMailTemplate.addToContext("lastloginduration", Integer.toString(UserDeletionManager.getInstance().getLastLoginDuration()));
deleteMailTemplate.addToContext("durationdeleteemail", Integer.toString(UserDeletionManager.getInstance().getDeleteEmailDuration()));
removeAsListenerAndDispose(deleteUserMailCtr);
deleteUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, deleteMailTemplate, true, false, false);
listenTo(deleteUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), deleteUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
} else {
showWarning("nothing.selected.msg");
}
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class SelectionForm method initializeTableController.
private void initializeTableController(UserRequest ureq) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("error.no.user.found"));
removeAsListenerAndDispose(tableCtr);
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), propertyHandlerTranslator);
listenTo(tableCtr);
List<Identity> l = UserDeletionManager.getInstance().getDeletableIdentities(UserDeletionManager.getInstance().getLastLoginDuration());
tdm = new UserDeleteTableModel(l, ureq.getLocale(), isAdministrativeUser);
tdm.addColumnDescriptors(tableCtr, null);
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(ACTION_SINGLESELECT_CHOOSE, "table.header.action", translate("action.activate")));
tableCtr.addMultiSelectAction("action.delete.selection", ACTION_MULTISELECT_CHOOSE);
tableCtr.setMultiSelect(true);
tableCtr.setTableDataModel(tdm);
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class GroupController method doRemoveIdentitiesFromGroup.
private void doRemoveIdentitiesFromGroup(UserRequest ureq, List<Identity> toBeRemoved, MailTemplate mailTemplate) {
fireEvent(ureq, new IdentitiesRemoveEvent(toBeRemoved));
identitiesTableModel.remove(toBeRemoved);
if (tableCtr != null) {
// can be null in the follwoing case.
// the user which does the removal is also in the list of toBeRemoved
// hence the fireEvent does trigger a disposal of a GroupController, which
// in turn nullifies the tableCtr... see also OLAT-3331
tableCtr.modelChanged();
}
// send the notification mail
if (mailTemplate != null) {
// means no sender in footer
Identity sender = null;
if (showSenderInRemovMailFooter) {
sender = ureq.getIdentity();
}
String metaId = UUID.randomUUID().toString();
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailerResult result = new MailerResult();
MailBundle[] bundles = mailManager.makeMailBundles(context, toBeRemoved, mailTemplate, sender, metaId, result);
result.append(mailManager.sendMessage(bundles));
if (mailTemplate.getCpfrom()) {
MailBundle ccBundle = mailManager.makeMailBundle(context, ureq.getIdentity(), mailTemplate, sender, metaId, result);
result.append(mailManager.sendMessage(ccBundle));
}
MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
}
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class UserImportController method doOpenImportWizard.
private void doOpenImportWizard(UserRequest ureq) {
// use fallback translator for user property translation
setTranslator(um.getPropertyHandlerTranslator(getTranslator()));
userPropertyHandlers = um.getUserPropertyHandlersFor(usageIdentifyer, true);
Step start = new ImportStep00(ureq, canCreateOLATPassword);
// callback executed in case wizard is finished.
StepRunnerCallback finish = new StepRunnerCallback() {
@Override
public Step execute(UserRequest ureq1, WindowControl wControl1, StepsRunContext runContext) {
// all information to do now is within the runContext saved
ImportReport report = new ImportReport();
runContext.put("report", report);
try {
if (runContext.containsKey("validImport") && ((Boolean) runContext.get("validImport")).booleanValue()) {
// create new users and persist
int count = 0;
@SuppressWarnings("unchecked") List<TransientIdentity> newIdents = (List<TransientIdentity>) runContext.get("newIdents");
Map<TransientIdentity, Identity> newPersistedIdentities = new HashMap<>();
for (TransientIdentity newIdent : newIdents) {
Identity newIdentity = doCreateAndPersistIdentity(newIdent, report);
if (newIdentity != null) {
newPersistedIdentities.put(newIdent, newIdentity);
}
if (++count % 10 == 0) {
dbInstance.commitAndCloseSession();
}
}
dbInstance.commitAndCloseSession();
Boolean updateUsers = (Boolean) runContext.get("updateUsers");
Boolean updatePasswords = (Boolean) runContext.get("updatePasswords");
@SuppressWarnings("unchecked") List<UpdateIdentity> updateIdents = (List<UpdateIdentity>) runContext.get("updateIdents");
for (UpdateIdentity updateIdent : updateIdents) {
doUpdateIdentity(updateIdent, updateUsers, updatePasswords, report);
if (++count % 10 == 0) {
dbInstance.commitAndCloseSession();
}
}
dbInstance.commitAndCloseSession();
@SuppressWarnings("unchecked") List<Long> ownGroups = (List<Long>) runContext.get("ownerGroups");
@SuppressWarnings("unchecked") List<Long> partGroups = (List<Long>) runContext.get("partGroups");
if ((ownGroups != null && ownGroups.size() > 0) || (partGroups != null && partGroups.size() > 0)) {
@SuppressWarnings("unchecked") List<Identity> allIdents = (List<Identity>) runContext.get("idents");
Boolean sendMailObj = (Boolean) runContext.get("sendMail");
boolean sendmail = sendMailObj == null ? true : sendMailObj.booleanValue();
processGroupAdditionForAllIdents(allIdents, ownGroups, partGroups, sendmail);
} else {
Boolean sendMailObj = (Boolean) runContext.get("sendMail");
if (sendMailObj != null && sendMailObj) {
sendMailToNewIdentities(newPersistedIdentities);
}
}
report.setHasChanges(true);
}
} catch (Exception any) {
logError("", any);
report.addError("Unexpected error, see log files or call your system administrator");
}
// signal correct completion and tell if changes were made or not.
return report.isHasChanges() ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
}
};
importStepsController = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("title"), "o_sel_user_import_wizard");
listenTo(importStepsController);
getWindowControl().pushAsModalDialog(importStepsController.getInitialComponent());
}
Aggregations