use of org.olat.user.UserManager in project openolat by klemens.
the class CourseLogsArchiveController method event.
public void event(UserRequest ureq, Controller source, Event event) {
if (source == logFileChooserForm) {
if (event == Event.DONE_EVENT) {
final boolean logAdminChecked = logFileChooserForm.logAdminChecked();
final boolean logUserChecked = logFileChooserForm.logUserChecked();
final boolean logStatisticChecked = logFileChooserForm.logStatChecked();
final Date begin = logFileChooserForm.getBeginDate();
final Date end = logFileChooserForm.getEndDate();
if (end != null) {
// shift time from beginning to end of day
end.setTime(end.getTime() + 24 * 60 * 60 * 1000);
}
UserManager um = UserManager.getInstance();
final String charset = um.getUserCharset(ureq.getIdentity());
ICourse course = CourseFactory.loadCourse(ores);
final String courseTitle = course.getCourseTitle();
final String targetDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), courseTitle).getPath();
final Long resId = ores.getResourceableId();
final Locale theLocale = ureq.getLocale();
final String email = ureq.getIdentity().getUser().getProperty(UserConstants.EMAIL, ureq.getLocale());
AsyncExportManager.getInstance().asyncArchiveCourseLogFiles(ureq.getIdentity(), new Runnable() {
@Override
public void run() {
showExportFinished();
}
}, resId, targetDir, begin, end, logAdminChecked, logUserChecked, logStatisticChecked, charset, theLocale, email);
showExportOngoing(true);
} else if (event == Event.DONE_EVENT) {
myPanel.setContent(myContent);
}
}
}
use of org.olat.user.UserManager in project openolat by klemens.
the class PublishProcess method applyPublishSet.
/**
* @param identity
* @param locale
* @param newCourse Optimization for new courses, it doesn't call upddateOnPublish of inserted/updated course nodes
*/
public void applyPublishSet(Identity identity, Locale locale, boolean newCourse) {
// the active runstructure and the new created runstructure
Structure existingCourseRun = course.getRunStructure();
EventBus orec = CoordinatorManager.getInstance().getCoordinator().getEventBus();
/*
* use book keeping lists for publish event
*/
Set<String> deletedCourseNodeIds = new HashSet<String>();
if (editorModelDeletedNodes.size() > 0) {
for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext(); ) {
CourseEditorTreeNode cetn = iter.next();
CourseNode cn = cetn.getCourseNode();
deletedCourseNodeIds.add(cn.getIdent());
}
}
Set<String> insertedCourseNodeIds = new HashSet<String>();
if (editorModelInsertedNodes.size() > 0) {
for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext(); ) {
CourseEditorTreeNode cetn = iter.next();
CourseNode cn = cetn.getCourseNode();
insertedCourseNodeIds.add(cn.getIdent());
}
}
Set<String> modifiedCourseNodeIds = new HashSet<String>();
if (editorModelModifiedNodes.size() > 0) {
for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext(); ) {
CourseEditorTreeNode cetn = iter.next();
CourseNode cn = cetn.getCourseNode();
modifiedCourseNodeIds.add(cn.getIdent());
}
}
/*
* broadcast PRE PUBLISH event that a publish will take place
*/
PublishEvent beforePublish = new PublishEvent(course, identity);
beforePublish.setDeletedCourseNodeIds(deletedCourseNodeIds);
beforePublish.setInsertedCourseNodeIds(insertedCourseNodeIds);
beforePublish.setModifiedCourseNodeIds(modifiedCourseNodeIds);
beforePublish.setState(PublishEvent.PRE_PUBLISH);
// old course structure accessible
orec.fireEventToListenersOf(beforePublish, course);
/*
* TODO:pb: discuss with fj: listeners could add information to
* beforePublish event such as a right to veto or add identities who is
* currently in the course, thus stopping the publishing author from
* publishing! i.e. if people are in a test or something like this.... we
* could the ask here beforePublish.accepted() and proceed only in this
* case.
*/
//
/*
* remove new nodes which were marked as delete and deletion is published.
*/
UserManager um = UserManager.getInstance();
String charset = um.getUserCharset(identity);
if (editorModelDeletedNodes.size() > 0) {
for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext(); ) {
CourseEditorTreeNode cetn = iter.next();
CourseNode cn = cetn.getCourseNode();
CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
// null
if (oldCn != null) {
if (!(cn.getIdent().equals(oldCn.getIdent()))) {
throw new AssertException("deleted cn.getIdent != oldCn.getIdent");
}
}
cetn.removeFromParent();
if (!cetn.isNewnode() && oldCn != null) {
// only clean up and archive of nodes which were already in run
// save data, remove references
deleteRefs(oldCn);
archiveDeletedNode(identity, cn, oldCn, locale, charset);
// 2) delete all user data
oldCn.cleanupOnDelete(course);
}
}
}
/*
* mark modified ones as no longer dirty
*/
if (editorModelModifiedNodes.size() > 0) {
for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext(); ) {
CourseEditorTreeNode cetn = iter.next();
CourseNode cn = cetn.getCourseNode();
CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
// null
if (oldCn != null) {
if (!(cn.getIdent().equals(oldCn.getIdent()))) {
throw new AssertException("deleted cn.getIdent != oldCn.getIdent");
}
}
cetn.setDirty(false);
//
updateRefs(cn, oldCn);
}
}
/*
* mark newly published ones is no longer new and dirty
*/
if (editorModelInsertedNodes.size() > 0) {
for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext(); ) {
CourseEditorTreeNode cetn = iter.next();
CourseNode cn = cetn.getCourseNode();
CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
if (oldCn != null) {
throw new AssertException("new node has an oldCN??");
}
cetn.setDirty(false);
cetn.setNewnode(false);
//
updateRefs(cn, null);
}
}
/*
* saving
*/
long pubtimestamp = System.currentTimeMillis();
editorTreeModel.setLatestPublishTimestamp(pubtimestamp);
// set the new runstructure and save it.
existingCourseRun.setRootNode(resultingCourseRun.getRootNode());
CourseFactory.saveCourse(course.getResourceableId());
// on old course, apply update to published nodes
if (!newCourse) {
for (CourseEditorTreeNode cetn : editorModelInsertedNodes) {
cetn.getCourseNode().updateOnPublish(locale, course, identity, publishEvents);
}
for (CourseEditorTreeNode cetn : editorModelModifiedNodes) {
cetn.getCourseNode().updateOnPublish(locale, course, identity, publishEvents);
}
}
// commit all changes before sending an event
DBFactory.getInstance().commitAndCloseSession();
/*
* broadcast event
*/
PublishEvent publishEvent = new PublishEvent(course, identity);
publishEvent.setDeletedCourseNodeIds(deletedCourseNodeIds);
publishEvent.setInsertedCourseNodeIds(insertedCourseNodeIds);
publishEvent.setModifiedCourseNodeIds(modifiedCourseNodeIds);
// new course structure accessible
// CourseFactory is one listener, which removes the course from the
// cache.
orec.fireEventToListenersOf(publishEvent, course);
/*
* END NEW STYLE PUBLISH
*/
}
use of org.olat.user.UserManager in project openolat by klemens.
the class ReturnboxFullAccessCallback method init.
protected void init(UserRequest ureq) {
myContent = createVelocityContainer("dropboxscoring");
taskLaunchButton = LinkFactory.createButton("task.launch", myContent, this);
cancelTaskButton = LinkFactory.createButton("task.cancel", myContent, this);
cancelTaskButton.setVisible(!userCourseEnv.isCourseReadOnly());
putInitialPanel(myContent);
ModuleConfiguration modConfig = node.getModuleConfiguration();
Boolean bValue = (Boolean) modConfig.get(TACourseNode.CONF_TASK_ENABLED);
myContent.contextPut("hasTask", (bValue != null) ? bValue : new Boolean(false));
// configured value
Boolean hasDropbox = (Boolean) modConfig.get(TACourseNode.CONF_DROPBOX_ENABLED);
Boolean hasDropboxValue = (hasDropbox != null) ? hasDropbox : new Boolean(true);
myContent.contextPut("hasDropbox", hasDropboxValue);
Boolean hasReturnbox = (Boolean) modConfig.get(TACourseNode.CONF_RETURNBOX_ENABLED);
myContent.contextPut("hasReturnbox", (hasReturnbox != null) ? hasReturnbox : hasDropboxValue);
// dropbox display
Identity assessee = userCourseEnv.getIdentityEnvironment().getIdentity();
String assesseeName = assessee.getName();
UserManager userManager = CoreSpringFactory.getImpl(UserManager.class);
String assesseeFullName = StringHelper.escapeHtml(userManager.getUserDisplayName(assessee));
// notification
if (hasNotification) {
subsContext = DropboxFileUploadNotificationHandler.getSubscriptionContext(userCourseEnv.getCourseEnvironment(), node);
if (subsContext != null) {
String path = DropboxController.getDropboxPathRelToFolderRoot(userCourseEnv.getCourseEnvironment(), node);
contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, this.getWindowControl(), path, subsContext, DropboxController.class);
myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
myContent.contextPut("hasNotification", Boolean.TRUE);
}
} else {
myContent.contextPut("hasNotification", Boolean.FALSE);
}
OlatRootFolderImpl rootDropbox = new OlatRootFolderImpl(getDropboxFilePath(assesseeName), null);
rootDropbox.setLocalSecurityCallback(getDropboxVfsSecurityCallback());
OlatNamedContainerImpl namedDropbox = new OlatNamedContainerImpl(assesseeFullName, rootDropbox);
namedDropbox.setLocalSecurityCallback(getDropboxVfsSecurityCallback());
dropboxFolderRunController = new FolderRunController(namedDropbox, false, ureq, getWindowControl());
listenTo(dropboxFolderRunController);
myContent.put("dropbox", dropboxFolderRunController.getInitialComponent());
Identity assessedIdentity = userCourseEnv.getIdentityEnvironment().getIdentity();
// returnbox display
OlatRootFolderImpl rootReturnbox = new OlatRootFolderImpl(getReturnboxFilePath(assesseeName), null);
VFSSecurityCallback secCallback = getReturnboxVfsSecurityCallback(rootReturnbox.getRelPath(), assessedIdentity);
rootReturnbox.setLocalSecurityCallback(secCallback);
OlatNamedContainerImpl namedReturnbox = new OlatNamedContainerImpl(assesseeFullName, rootReturnbox);
namedReturnbox.setLocalSecurityCallback(secCallback);
returnboxFolderRunController = new FolderRunController(namedReturnbox, false, ureq, getWindowControl());
returnboxFolderRunController.disableSubscriptionController();
listenTo(returnboxFolderRunController);
myContent.put("returnbox", returnboxFolderRunController.getInitialComponent());
// insert Status Pull-Down Menu depending on user role == author
boolean isAuthor = ureq.getUserSession().getRoles().isAuthor();
boolean isTutor = userCourseEnv.getCourseEnvironment().getCourseGroupManager().isIdentityCourseCoach(ureq.getIdentity());
if (((AssessableCourseNode) node).hasStatusConfigured() && (isAuthor || isTutor)) {
myContent.contextPut("hasStatusPullDown", Boolean.TRUE);
statusForm = new StatusForm(ureq, getWindowControl(), userCourseEnv.isCourseReadOnly());
listenTo(statusForm);
// get identity not from request (this would be an author)
StatusManager.getInstance().loadStatusFormData(statusForm, node, userCourseEnv);
myContent.put("statusForm", statusForm.getInitialComponent());
}
assignedTask = TaskController.getAssignedTask(assessedIdentity, userCourseEnv.getCourseEnvironment(), node);
if (assignedTask != null) {
myContent.contextPut("assignedtask", assignedTask);
myContent.contextPut("taskIcon", CSSHelper.createFiletypeIconCssClassFor(assignedTask));
if (!(assignedTask.toLowerCase().endsWith(".html") || assignedTask.toLowerCase().endsWith(".htm") || assignedTask.toLowerCase().endsWith(".txt"))) {
taskLaunchButton.setTarget("_blank");
}
}
}
use of org.olat.user.UserManager in project openolat by klemens.
the class NewUserForm method doCreateAndPersistIdentity.
private Identity doCreateAndPersistIdentity() {
String lang = languageSingleSelection.getSelectedKey();
String username = usernameTextElement.getValue();
String pwd = null;
// use password only when configured to do so
if (showPasswordFields && authCheckbox.isSelected(0)) {
pwd = psw1TextElement.getValue();
if (!StringHelper.containsNonWhitespace(pwd)) {
// treat white-space passwords as no-password. This is fine, a password can be set later on
pwd = null;
}
}
// Create new user and identity and put user to users group
// Create transient user without firstName,lastName, email
UserManager um = UserManager.getInstance();
User newUser = um.createUser(null, null, null);
// Now add data from user fields (firstName,lastName and email are mandatory)
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
FormItem propertyItem = this.flc.getFormComponent(userPropertyHandler.getName());
userPropertyHandler.updateUserFromFormItem(newUser, propertyItem);
}
// Init preferences
newUser.getPreferences().setLanguage(lang);
newUser.getPreferences().setInformSessionTimeout(true);
// Save everything in database
Identity ident = securityManager.createAndPersistIdentityAndUserWithDefaultProviderAndUserGroup(username, null, pwd, newUser);
return ident;
}
use of org.olat.user.UserManager in project openolat by klemens.
the class GroupController method init.
protected void init(UserRequest ureq, boolean mayModifyMembers, boolean keepAtLeastOne, boolean enableTablePreferences, boolean enableUserSelection, boolean allowDownload, boolean mandatoryEmail, SecurityGroup aSecurityGroup) {
this.securityGroup = aSecurityGroup;
this.mayModifyMembers = mayModifyMembers;
this.keepAtLeastOne = keepAtLeastOne;
this.mandatoryEmail = mandatoryEmail;
securityManager = BaseSecurityManager.getInstance();
imModule = CoreSpringFactory.getImpl(InstantMessagingModule.class);
imService = CoreSpringFactory.getImpl(InstantMessagingService.class);
userManager = CoreSpringFactory.getImpl(UserManager.class);
sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
mailManager = CoreSpringFactory.getImpl(MailManager.class);
Roles roles = ureq.getUserSession().getRoles();
BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
chatEnabled = imModule.isEnabled() && imModule.isPrivateEnabled();
// default group controller has no mail functionality
this.addUserMailDefaultTempl = null;
this.removeUserMailDefaultTempl = null;
groupmemberview = createVelocityContainer("index");
addUsersButton = LinkFactory.createButtonSmall("overview.addusers", groupmemberview, this);
addUsersButton.setElementCssClass("o_sel_group_import_users");
addUserButton = LinkFactory.createButtonSmall("overview.adduser", groupmemberview, this);
addUserButton.setElementCssClass("o_sel_group_add_user");
if (mayModifyMembers) {
groupmemberview.contextPut("mayadduser", Boolean.TRUE);
}
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setDownloadOffered(allowDownload);
if (enableTablePreferences) {
// save table preferences for each group seperatly
if (mayModifyMembers) {
tableConfig.setPreferencesOffered(true, "groupcontroller" + securityGroup.getKey());
} else {
// different rowcount...
tableConfig.setPreferencesOffered(true, "groupcontrollerreadonly" + securityGroup.getKey());
}
}
myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), myTrans);
listenTo(tableCtr);
initGroupTable(tableCtr, ureq, enableTablePreferences, enableUserSelection);
// set data model
reloadData();
groupmemberview.put("subjecttable", tableCtr.getInitialComponent());
putInitialPanel(groupmemberview);
}
Aggregations