Index: lams_admin/conf/language/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/language/Attic/ApplicationResources.properties,v diff -u -r1.6 -r1.7 --- lams_admin/conf/language/ApplicationResources.properties 9 Jun 2006 07:10:52 -0000 1.6 +++ lams_admin/conf/language/ApplicationResources.properties 16 Jun 2006 06:57:54 -0000 1.7 @@ -13,8 +13,11 @@ errors.prefix=
  • errors.suffix=
  • error.system = Oops! An unexpected exception thrown by the system. Ask the LAMS developers to investigate it! -error.org.invalid = Invalid Organiation Id -error.name.required = Name is required +error.org.invalid = Invalid Organiation Id. +error.name.required = Name is required. +error.login.required = Login is required. +error.login.unique = Login is already taken. +error.password.required = Password is required. error.authorisation=You are not authorised to do this. error.newpassword.mismatch=Your new passwords don't match each other. error.oldpassword.mismatch=Your old password is not correct. @@ -38,9 +41,27 @@ admin.user.management = User Management admin.user.entry = User Entry admin.user.login = Login +admin.user.password = Password admin.user.title = Title admin.user.first_name = First Name admin.user.last_name = Last Name +admin.user.address_line_1 = Address Line 1 +admin.user.address_line_2 = Address Line 2 +admin.user.address_line_3 = Address Line 3 +admin.user.city = City +admin.user.state = State +admin.user.country = Country +admin.user.day_phone = Day Phone +admin.user.evening_phone = Evening Phone +admin.user.mobile_phone = Mobile Phone +admin.user.fax = Fax +admin.user.email = Email +admin.user.roles = Roles +admin.user.learner = Learner +admin.user.author = Author +admin.user.staff = Staff +admin.user.admin = Course Admin +admin.user.manager = Course Manager admin.user.manage = Manage Users admin.user.remove = Remove admin.user.add = Add User Index: lams_admin/conf/xdoclet/struts-forms.xml =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/xdoclet/struts-forms.xml,v diff -u -r1.3 -r1.4 --- lams_admin/conf/xdoclet/struts-forms.xml 8 Jun 2006 07:01:03 -0000 1.3 +++ lams_admin/conf/xdoclet/struts-forms.xml 16 Jun 2006 06:57:54 -0000 1.4 @@ -9,4 +9,32 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fisheye: Tag 1.5 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgRolesDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/Attic/UserOrgRolesDTO.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgRolesDTO.java 16 Jun 2006 06:57:53 -0000 1.1 @@ -0,0 +1,79 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: UserOrgRolesDTO.java,v 1.1 2006/06/16 06:57:53 jliew Exp $ */ +package org.lamsfoundation.lams.admin.web; + +/** + * @author Jun-Dir Liew + * + * Created at 12:10:10 on 16/06/2006 + */ +public class UserOrgRolesDTO { + + private Boolean learner = false; + private Boolean author = false; + private Boolean staff = false; + private Boolean admin = false; + private Boolean manager = false; + + public Boolean getLearner() { + return learner; + } + + public void setLearner(Boolean learner) { + this.learner = learner; + } + + public Boolean getAuthor() { + return author; + } + + public void setAuthor(Boolean author) { + this.author = author; + } + + public Boolean getStaff() { + return staff; + } + + public void setStaff(Boolean staff) { + this.staff = staff; + } + + public Boolean getAdmin() { + return admin; + } + + public void setAdmin(Boolean admin) { + this.admin = admin; + } + + public Boolean getManager() { + return manager; + } + + public void setManager(Boolean manager) { + this.manager = manager; + } +} Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java 16 Jun 2006 06:57:54 -0000 1.1 @@ -0,0 +1,179 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: UserSaveAction.java,v 1.1 2006/06/16 06:57:54 jliew Exp $ */ +package org.lamsfoundation.lams.admin.web; + +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.beanutils.BeanUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.action.DynaActionForm; +import org.lamsfoundation.lams.usermanagement.Role; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.UserOrganisation; +import org.lamsfoundation.lams.usermanagement.UserOrganisationRole; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.web.util.HttpSessionManager; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author Jun-Dir Liew + * + * Created at 12:35:38 on 14/06/2006 + */ + +/** + * struts doclets + * + * @struts:action path="/usersave" + * name="UserForm" + * input=".user" + * scope="request" + * validate="false" + * + * @struts:action-forward name="user" + * path=".user" + * @struts:action-forward name="userlist" + * path="/usermanage.do" + */ +public class UserSaveAction extends Action { + + private static Logger log = Logger.getLogger(UserSaveAction.class); + private static WebApplicationContext ctx = WebApplicationContextUtils + .getWebApplicationContext(HttpSessionManager.getInstance() + .getServletContext()); + private static IUserManagementService service = (IUserManagementService) ctx + .getBean("userManagementServiceTarget"); + + public ActionForward execute(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws Exception { + DynaActionForm userForm = (DynaActionForm)form; + + if(isCancelled(request)){ + request.setAttribute("org",userForm.get("orgId")); + return mapping.findForward("userlist"); + } + + ActionMessages errors = new ActionMessages(); + if((userForm.get("login")==null)||(((String)userForm.getString("login").trim()).length()==0)){ + errors.add("login",new ActionMessage("error.login.required")); + } + if((userForm.get("password")==null)||(((String)userForm.getString("password").trim()).length()==0)){ + errors.add("password",new ActionMessage("error.password.required")); + } + + if(errors.isEmpty()){ + Integer userId = (Integer)userForm.get("userId"); + Integer orgId = (Integer)userForm.get("orgId"); + User user; + if(userId!=0){ // edit user + log.debug("editing userId: "+userId); + user = service.getUserById(userId); + BeanUtils.copyProperties(user,userForm); + service.updateUser(user); + UserOrganisation userOrganisation = service.getUserOrganisation(userId, orgId); + List roles = service.getRolesForUserByOrganisation(user, orgId); + + Role currentRole = service.getRoleByName("LEARNER"); + if(userForm.get("learner").equals("on") && roles.indexOf(currentRole)<0) { + UserOrganisationRole userOrganisationRole = new UserOrganisationRole(userOrganisation, + currentRole); + service.saveOrUpdateUserOrganisationRole(userOrganisationRole); + } else if(userForm.get("learner").equals("off")){ + //service.deleteUserOrganisationRole(); + } + currentRole = service.getRoleByName("AUTHOR"); + if(userForm.get("author").equals("on") && roles.indexOf(currentRole)<0) { + UserOrganisationRole userOrganisationRole = new UserOrganisationRole(userOrganisation, + currentRole); + service.saveOrUpdateUserOrganisationRole(userOrganisationRole); + } else if(userForm.get("learner").equals("off")) { + //service.deleteUserOrganisationRole(); + } + currentRole = service.getRoleByName("STAFF"); + if(userForm.get("staff").equals("on") && roles.indexOf(currentRole)<0) { + UserOrganisationRole userOrganisationRole = new UserOrganisationRole(userOrganisation, + currentRole); + service.saveOrUpdateUserOrganisationRole(userOrganisationRole); + } else if(userForm.get("learner").equals("off")) { + //service.deleteUserOrganisationRole(); + } + currentRole = service.getRoleByName("COURSE ADMIN"); + if(userForm.get("admin").equals("on") && roles.indexOf(currentRole)<0) { + UserOrganisationRole userOrganisationRole = new UserOrganisationRole(userOrganisation, + currentRole); + service.saveOrUpdateUserOrganisationRole(userOrganisationRole); + } else if(userForm.get("learner").equals("off")) { + //service.deleteUserOrganisationRole(); + } + currentRole = service.getRoleByName("COURSE MANAGER"); + if(userForm.get("manager").equals("on") && roles.indexOf(currentRole)<0) { + UserOrganisationRole userOrganisationRole = new UserOrganisationRole(userOrganisation, + currentRole); + service.saveOrUpdateUserOrganisationRole(userOrganisationRole); + } else if(userForm.get("learner").equals("off")) { + //service.deleteUserOrganisationRole(); + } + }else{ // create user + log.debug("creating user..."); + user = new User(); + BeanUtils.copyProperties(user,userForm); + if(service.getUserByLogin(user.getLogin())!=null) { + errors.add("loginUnique",new ActionMessage("error.login.unique")); + } + user.setDisabledFlag(false); + user.setCreateDate(new Date()); + user.setAuthenticationMethod(service.getAuthenticationMethodByName("LAMS-Database")); + log.debug(user.toString()); + service.createUser(user); + user = service.getUserByLogin((String)userForm.get("login")); + UserOrganisation userOrganisation = new UserOrganisation(user, service.getOrganisationById(orgId)); + service.saveOrUpdateUserOrganisation(userOrganisation); + // set default role to learner + Role role = service.getRoleByName("LEARNER"); + UserOrganisationRole userOrganisationRole = new UserOrganisationRole(userOrganisation, role); + service.saveOrUpdateUserOrganisationRole(userOrganisationRole); + } + request.setAttribute("org",orgId); + log.debug("orgId: "+orgId); + return mapping.findForward("userlist"); + }else{ + saveErrors(request,errors); + return mapping.findForward("user"); + } + } +} Index: lams_admin/web/user.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_admin/web/user.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_admin/web/user.jsp 16 Jun 2006 06:57:54 -0000 1.1 @@ -0,0 +1,128 @@ +<%@ page contentType="text/html; charset=utf-8" language="java" %> + +<%@ taglib uri="tags-html-el" prefix="html-el" %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-bean" prefix="bean" %> +<%@ taglib uri="tags-logic" prefix="logic" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> + + + + +

    + + User + + + User + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    *:
    *:
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : + + + + + +
    : + + + + + +
    (removing a role not supported yet): + checked />
    + checked />
    + checked />
    + checked />
    + checked /> +
    + + + +
    + Index: lams_admin/web/WEB-INF/struts/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_admin/web/WEB-INF/struts/Attic/struts-config.xml,v diff -u -r1.10 -r1.11 --- lams_admin/web/WEB-INF/struts/struts-config.xml 9 Jun 2006 02:43:27 -0000 1.10 +++ lams_admin/web/WEB-INF/struts/struts-config.xml 16 Jun 2006 06:57:54 -0000 1.11 @@ -30,17 +30,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -94,6 +125,18 @@ /> + + + + + + + + + + + + + + + + + + +