Search in sources :

Example 1 with UserCreateController

use of org.olat.admin.user.UserCreateController in project openolat by klemens.

the class UserAdminMainController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == contentCtr) {
        if (event instanceof SingleIdentityChosenEvent) {
            SingleIdentityChosenEvent userChoosenEvent = (SingleIdentityChosenEvent) event;
            Identity identity = userChoosenEvent.getChosenIdentity();
            // cleanup old userAdminCtr controller
            removeAsListenerAndDispose(userAdminCtr);
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey());
            ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
            WindowControl bwControl;
            if (contentCtr instanceof UsermanagerUserSearchController) {
                UsermanagerUserSearchController ctrl = (UsermanagerUserSearchController) contentCtr;
                WindowControl tableControl = ctrl.getTableControl();
                if (tableControl == null) {
                    tableControl = ctrl.getWindowControlForDebug();
                }
                bwControl = addToHistory(ureq, ores, null, tableControl, true);
            } else {
                bwControl = addToHistory(ureq, ores, null, contentCtr.getWindowControlForDebug(), true);
            }
            userAdminCtr = new UserAdminController(ureq, bwControl, identity);
            listenTo(userAdminCtr);
            // activate a special pane in the tabbed pane when set
            if (activatePaneInDetailView != null) {
                List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(activatePaneInDetailView);
                userAdminCtr.activate(ureq, entries, null);
            }
            content.setContent(userAdminCtr.getInitialComponent());
            // deactivate back button for user create controller, kames no sense there
            if (contentCtr instanceof UserCreateController) {
                userAdminCtr.setBackButtonEnabled(false);
            } else {
                userAdminCtr.setBackButtonEnabled(true);
            }
        }
    } else if (source == userAdminCtr) {
        if (event == Event.BACK_EVENT) {
            Identity editedIdentity = userAdminCtr.getEditedIdentity();
            removeAsListenerAndDispose(userAdminCtr);
            userAdminCtr = null;
            // to display correct values of identity
            if (contentCtr instanceof UsermanagerUserSearchController) {
                UsermanagerUserSearchController userSearchCtr = (UsermanagerUserSearchController) contentCtr;
                userSearchCtr.reloadFoundIdentity(editedIdentity);
                addToHistory(ureq, userSearchCtr);
            }
            content.setContent(contentCtr.getInitialComponent());
        }
    }
}
Also used : UsermanagerUserSearchController(org.olat.admin.user.UsermanagerUserSearchController) OLATResourceable(org.olat.core.id.OLATResourceable) UserAdminController(org.olat.admin.user.UserAdminController) UserCreateController(org.olat.admin.user.UserCreateController) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 2 with UserCreateController

use of org.olat.admin.user.UserCreateController in project OpenOLAT by OpenOLAT.

the class UserAdminMainController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == contentCtr) {
        if (event instanceof SingleIdentityChosenEvent) {
            SingleIdentityChosenEvent userChoosenEvent = (SingleIdentityChosenEvent) event;
            Identity identity = userChoosenEvent.getChosenIdentity();
            // cleanup old userAdminCtr controller
            removeAsListenerAndDispose(userAdminCtr);
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey());
            ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
            WindowControl bwControl;
            if (contentCtr instanceof UsermanagerUserSearchController) {
                UsermanagerUserSearchController ctrl = (UsermanagerUserSearchController) contentCtr;
                WindowControl tableControl = ctrl.getTableControl();
                if (tableControl == null) {
                    tableControl = ctrl.getWindowControlForDebug();
                }
                bwControl = addToHistory(ureq, ores, null, tableControl, true);
            } else {
                bwControl = addToHistory(ureq, ores, null, contentCtr.getWindowControlForDebug(), true);
            }
            userAdminCtr = new UserAdminController(ureq, bwControl, identity);
            listenTo(userAdminCtr);
            // activate a special pane in the tabbed pane when set
            if (activatePaneInDetailView != null) {
                List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(activatePaneInDetailView);
                userAdminCtr.activate(ureq, entries, null);
            }
            content.setContent(userAdminCtr.getInitialComponent());
            // deactivate back button for user create controller, kames no sense there
            if (contentCtr instanceof UserCreateController) {
                userAdminCtr.setBackButtonEnabled(false);
            } else {
                userAdminCtr.setBackButtonEnabled(true);
            }
        }
    } else if (source == userAdminCtr) {
        if (event == Event.BACK_EVENT) {
            Identity editedIdentity = userAdminCtr.getEditedIdentity();
            removeAsListenerAndDispose(userAdminCtr);
            userAdminCtr = null;
            // to display correct values of identity
            if (contentCtr instanceof UsermanagerUserSearchController) {
                UsermanagerUserSearchController userSearchCtr = (UsermanagerUserSearchController) contentCtr;
                userSearchCtr.reloadFoundIdentity(editedIdentity);
                addToHistory(ureq, userSearchCtr);
            }
            content.setContent(contentCtr.getInitialComponent());
        }
    }
}
Also used : UsermanagerUserSearchController(org.olat.admin.user.UsermanagerUserSearchController) OLATResourceable(org.olat.core.id.OLATResourceable) UserAdminController(org.olat.admin.user.UserAdminController) UserCreateController(org.olat.admin.user.UserCreateController) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 3 with UserCreateController

use of org.olat.admin.user.UserCreateController in project OpenOLAT by OpenOLAT.

the class UserAdminMainController method initComponentFromMenuCommand.

private Component initComponentFromMenuCommand(Object uobject, UserRequest ureq) {
    // in any case release delete user gui lock (reaquired if user deletion is again clicked)
    releaseDeleteUserLock();
    if (uobject instanceof GenericActionExtension) {
        GenericActionExtension ae = (GenericActionExtension) uobject;
        TreeNode node = ((GenericTreeModel) olatMenuTree.getTreeModel()).findNodeByUserObject(uobject);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("AE", new Long(node.getPosition()));
        WindowControl bwControl = addToHistory(ureq, ores, null);
        contentCtr = ae.createController(ureq, bwControl, null);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(uobject.toString(), 0l);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
    // first check if it is node which opens a subtree with further uobject.tree.commands
    if (uobject.equals("menuroles")) {
        if (rolesVC == null) {
            rolesVC = createVelocityContainer("systemroles");
        }
        addToHistory(ureq, bwControl);
        return rolesVC;
    } else if (uobject.equals("menuqueries")) {
        if (queriesVC == null) {
            queriesVC = createVelocityContainer("predefinedqueries");
        }
        addToHistory(ureq, bwControl);
        return queriesVC;
    } else if (uobject.equals("menuaccess")) {
        if (queriesVC == null) {
            queriesVC = createVelocityContainer("systemroles");
        }
        addToHistory(ureq, bwControl);
        return queriesVC;
    } else if (uobject.equals("userdelete")) {
        // creates the user deletin controller
        // if locking fails -> a contentCtrl is created
        // -> hence removeAsListenerAndDispose(contentCtr) is delegated to the method called!
        addToHistory(ureq, bwControl);
        return createAndLockUserDeleteController(ureq, bwControl);
    } else if (uobject.equals("userdelete_direct")) {
        // creates the user deletin controller
        // if locking fails -> a contentCtrl is created
        // -> hence removeAsListenerAndDispose(contentCtr) is delegated to the method called!
        addToHistory(ureq, bwControl);
        return createAndLockDirectUserDeleteController(ureq, bwControl);
    }
    if (uobject.equals("usearch") || uobject.equals("useradmin")) {
        if (contentCtr != userSearchCtrl) {
            activatePaneInDetailView = null;
            contentCtr = userSearchCtrl = new UsermanagerUserSearchController(ureq, bwControl);
            listenTo(contentCtr);
        }
        addToHistory(ureq, bwControl);
        return contentCtr.getInitialComponent();
    }
    // these nodes re-create (not stateful) content Controller (contentCtrl)
    removeAsListenerAndDispose(contentCtr);
    if (uobject.equals("ucreate")) {
        activatePaneInDetailView = null;
        boolean canCreateOLATPassword = false;
        if (ureq.getUserSession().getRoles().isOLATAdmin()) {
            // admin will override configuration
            canCreateOLATPassword = true;
        } else {
            Boolean canCreatePwdByConfig = BaseSecurityModule.USERMANAGER_CAN_CREATE_PWD;
            canCreateOLATPassword = canCreatePwdByConfig.booleanValue();
        }
        contentCtr = new UserCreateController(ureq, bwControl, canCreateOLATPassword);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usersimport")) {
        activatePaneInDetailView = null;
        boolean canCreateOLATPassword = false;
        if (ureq.getUserSession().getRoles().isOLATAdmin()) {
            // admin will override configuration
            canCreateOLATPassword = true;
        } else {
            Boolean canCreatePwdByConfig = BaseSecurityModule.USERMANAGER_CAN_CREATE_PWD;
            canCreateOLATPassword = canCreatePwdByConfig.booleanValue();
        }
        contentCtr = new UserImportController(ureq, bwControl, canCreateOLATPassword);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("admingroup")) {
        activatePaneInDetailView = null;
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("authorgroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("coauthors")) {
        activatePaneInDetailView = "edit.uroles";
        // special case: use user search controller and search for all users that have author rights
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.owner.name());
        UsermanagerUserSearchController myCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        // now subtract users that are in the author group to get the co-authors
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        List<Identity> identitiesFromAuthorGroup = securityManager.getVisibleIdentitiesByPowerSearch(null, null, true, secGroup, null, null, null, null);
        myCtr.removeIdentitiesFromSearchResult(ureq, identitiesFromAuthorGroup);
        contentCtr = myCtr;
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("resourceowners")) {
        activatePaneInDetailView = "edit.uroles";
        // First get all resource owners (co-authors) ...
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.owner.name());
        UsermanagerUserSearchController myCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        // ... now add users that are in the author group but don't own a resource yet
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        List<Identity> identitiesFromAuthorGroup = securityManager.getVisibleIdentitiesByPowerSearch(null, null, true, secGroup, null, null, null, null);
        myCtr.addIdentitiesToSearchResult(ureq, identitiesFromAuthorGroup);
        contentCtr = myCtr;
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("courseparticipants")) {
        activatePaneInDetailView = "edit.courses";
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.participant.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("groupmanagergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    if (uobject.equals("coursecoach")) {
        activatePaneInDetailView = "edit.uroles";
        List<Identity> coaches = repositoryService.getIdentitiesWithRole(GroupRoles.coach.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, coaches, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    if (uobject.equals("groupcoach")) {
        activatePaneInDetailView = "edit.uroles";
        List<Identity> coaches = businessGroupService.getIdentitiesWithRole(GroupRoles.coach.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, coaches, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usermanagergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("anonymousgroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("userswithoutgroup")) {
        activatePaneInDetailView = "edit.withoutgroup";
        List<Identity> usersWithoutGroup = securityManager.findIdentitiesWithoutBusinessGroup(Identity.STATUS_VISIBLE_LIMIT);
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersWithoutGroup, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("userswithoutemail")) {
        activatePaneInDetailView = "userswithoutemail";
        List<Identity> usersWithoutEmail = userManager.findVisibleIdentitiesWithoutEmail();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersWithoutEmail, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usersemailduplicates")) {
        activatePaneInDetailView = "users.email.duplicate";
        List<Identity> usersEmailDuplicates = userManager.findVisibleIdentitiesWithEmailDuplicates();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersEmailDuplicates, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("logondeniedgroup")) {
        activatePaneInDetailView = "edit.uroles";
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("deletedusers")) {
        activatePaneInDetailView = "list.deletedusers";
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, null, null, Identity.STATUS_DELETED, false);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.lastweek")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, -7);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.lastmonth")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -1);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.sixmonth")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -6);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.newUsersNotification")) {
        activatePaneInDetailView = null;
        bwControl = addToHistory(ureq, ores, null);
        contentCtr = new NewUsersNotificationsController(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("noauthentication")) {
        activatePaneInDetailView = null;
        String[] auth = { null };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, auth, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else {
        // to be removed
        throw new AssertException("did not expect to land here in UserAdminMainController this is because uboject is " + uobject.toString());
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) Calendar(java.util.Calendar) UserCreateController(org.olat.admin.user.UserCreateController) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) WindowControl(org.olat.core.gui.control.WindowControl) SecurityGroup(org.olat.basesecurity.SecurityGroup) UserImportController(org.olat.admin.user.imp.UserImportController) Date(java.util.Date) UsermanagerUserSearchController(org.olat.admin.user.UsermanagerUserSearchController) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) List(java.util.List) Identity(org.olat.core.id.Identity) NewUsersNotificationsController(org.olat.admin.user.NewUsersNotificationsController)

Example 4 with UserCreateController

use of org.olat.admin.user.UserCreateController in project openolat by klemens.

the class UserAdminMainController method initComponentFromMenuCommand.

private Component initComponentFromMenuCommand(Object uobject, UserRequest ureq) {
    // in any case release delete user gui lock (reaquired if user deletion is again clicked)
    releaseDeleteUserLock();
    if (uobject instanceof GenericActionExtension) {
        GenericActionExtension ae = (GenericActionExtension) uobject;
        TreeNode node = ((GenericTreeModel) olatMenuTree.getTreeModel()).findNodeByUserObject(uobject);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("AE", new Long(node.getPosition()));
        WindowControl bwControl = addToHistory(ureq, ores, null);
        contentCtr = ae.createController(ureq, bwControl, null);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(uobject.toString(), 0l);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
    // first check if it is node which opens a subtree with further uobject.tree.commands
    if (uobject.equals("menuroles")) {
        if (rolesVC == null) {
            rolesVC = createVelocityContainer("systemroles");
        }
        addToHistory(ureq, bwControl);
        return rolesVC;
    } else if (uobject.equals("menuqueries")) {
        if (queriesVC == null) {
            queriesVC = createVelocityContainer("predefinedqueries");
        }
        addToHistory(ureq, bwControl);
        return queriesVC;
    } else if (uobject.equals("menuaccess")) {
        if (queriesVC == null) {
            queriesVC = createVelocityContainer("systemroles");
        }
        addToHistory(ureq, bwControl);
        return queriesVC;
    } else if (uobject.equals("userdelete")) {
        // creates the user deletin controller
        // if locking fails -> a contentCtrl is created
        // -> hence removeAsListenerAndDispose(contentCtr) is delegated to the method called!
        addToHistory(ureq, bwControl);
        return createAndLockUserDeleteController(ureq, bwControl);
    } else if (uobject.equals("userdelete_direct")) {
        // creates the user deletin controller
        // if locking fails -> a contentCtrl is created
        // -> hence removeAsListenerAndDispose(contentCtr) is delegated to the method called!
        addToHistory(ureq, bwControl);
        return createAndLockDirectUserDeleteController(ureq, bwControl);
    }
    if (uobject.equals("usearch") || uobject.equals("useradmin")) {
        if (contentCtr != userSearchCtrl) {
            activatePaneInDetailView = null;
            contentCtr = userSearchCtrl = new UsermanagerUserSearchController(ureq, bwControl);
            listenTo(contentCtr);
        }
        addToHistory(ureq, bwControl);
        return contentCtr.getInitialComponent();
    }
    // these nodes re-create (not stateful) content Controller (contentCtrl)
    removeAsListenerAndDispose(contentCtr);
    if (uobject.equals("ucreate")) {
        activatePaneInDetailView = null;
        boolean canCreateOLATPassword = false;
        if (ureq.getUserSession().getRoles().isOLATAdmin()) {
            // admin will override configuration
            canCreateOLATPassword = true;
        } else {
            Boolean canCreatePwdByConfig = BaseSecurityModule.USERMANAGER_CAN_CREATE_PWD;
            canCreateOLATPassword = canCreatePwdByConfig.booleanValue();
        }
        contentCtr = new UserCreateController(ureq, bwControl, canCreateOLATPassword);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usersimport")) {
        activatePaneInDetailView = null;
        boolean canCreateOLATPassword = false;
        if (ureq.getUserSession().getRoles().isOLATAdmin()) {
            // admin will override configuration
            canCreateOLATPassword = true;
        } else {
            Boolean canCreatePwdByConfig = BaseSecurityModule.USERMANAGER_CAN_CREATE_PWD;
            canCreateOLATPassword = canCreatePwdByConfig.booleanValue();
        }
        contentCtr = new UserImportController(ureq, bwControl, canCreateOLATPassword);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("admingroup")) {
        activatePaneInDetailView = null;
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("authorgroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("coauthors")) {
        activatePaneInDetailView = "edit.uroles";
        // special case: use user search controller and search for all users that have author rights
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.owner.name());
        UsermanagerUserSearchController myCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        // now subtract users that are in the author group to get the co-authors
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        List<Identity> identitiesFromAuthorGroup = securityManager.getVisibleIdentitiesByPowerSearch(null, null, true, secGroup, null, null, null, null);
        myCtr.removeIdentitiesFromSearchResult(ureq, identitiesFromAuthorGroup);
        contentCtr = myCtr;
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("resourceowners")) {
        activatePaneInDetailView = "edit.uroles";
        // First get all resource owners (co-authors) ...
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.owner.name());
        UsermanagerUserSearchController myCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        // ... now add users that are in the author group but don't own a resource yet
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        List<Identity> identitiesFromAuthorGroup = securityManager.getVisibleIdentitiesByPowerSearch(null, null, true, secGroup, null, null, null, null);
        myCtr.addIdentitiesToSearchResult(ureq, identitiesFromAuthorGroup);
        contentCtr = myCtr;
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("courseparticipants")) {
        activatePaneInDetailView = "edit.courses";
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.participant.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("groupmanagergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    if (uobject.equals("coursecoach")) {
        activatePaneInDetailView = "edit.uroles";
        List<Identity> coaches = repositoryService.getIdentitiesWithRole(GroupRoles.coach.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, coaches, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    if (uobject.equals("groupcoach")) {
        activatePaneInDetailView = "edit.uroles";
        List<Identity> coaches = businessGroupService.getIdentitiesWithRole(GroupRoles.coach.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, coaches, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usermanagergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("anonymousgroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("userswithoutgroup")) {
        activatePaneInDetailView = "edit.withoutgroup";
        List<Identity> usersWithoutGroup = securityManager.findIdentitiesWithoutBusinessGroup(Identity.STATUS_VISIBLE_LIMIT);
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersWithoutGroup, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("userswithoutemail")) {
        activatePaneInDetailView = "userswithoutemail";
        List<Identity> usersWithoutEmail = userManager.findVisibleIdentitiesWithoutEmail();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersWithoutEmail, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usersemailduplicates")) {
        activatePaneInDetailView = "users.email.duplicate";
        List<Identity> usersEmailDuplicates = userManager.findVisibleIdentitiesWithEmailDuplicates();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersEmailDuplicates, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("logondeniedgroup")) {
        activatePaneInDetailView = "edit.uroles";
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("deletedusers")) {
        activatePaneInDetailView = "list.deletedusers";
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, null, null, Identity.STATUS_DELETED, false);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.lastweek")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, -7);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.lastmonth")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -1);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.sixmonth")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -6);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.newUsersNotification")) {
        activatePaneInDetailView = null;
        bwControl = addToHistory(ureq, ores, null);
        contentCtr = new NewUsersNotificationsController(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("noauthentication")) {
        activatePaneInDetailView = null;
        String[] auth = { null };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, auth, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else {
        // to be removed
        throw new AssertException("did not expect to land here in UserAdminMainController this is because uboject is " + uobject.toString());
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) Calendar(java.util.Calendar) UserCreateController(org.olat.admin.user.UserCreateController) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) WindowControl(org.olat.core.gui.control.WindowControl) SecurityGroup(org.olat.basesecurity.SecurityGroup) UserImportController(org.olat.admin.user.imp.UserImportController) Date(java.util.Date) UsermanagerUserSearchController(org.olat.admin.user.UsermanagerUserSearchController) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) List(java.util.List) Identity(org.olat.core.id.Identity) NewUsersNotificationsController(org.olat.admin.user.NewUsersNotificationsController)

Aggregations

UserCreateController (org.olat.admin.user.UserCreateController)4 UsermanagerUserSearchController (org.olat.admin.user.UsermanagerUserSearchController)4 WindowControl (org.olat.core.gui.control.WindowControl)4 Identity (org.olat.core.id.Identity)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 Calendar (java.util.Calendar)2 Date (java.util.Date)2 List (java.util.List)2 NewUsersNotificationsController (org.olat.admin.user.NewUsersNotificationsController)2 UserAdminController (org.olat.admin.user.UserAdminController)2 UserImportController (org.olat.admin.user.imp.UserImportController)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)2 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)2 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 AssertException (org.olat.core.logging.AssertException)2