Index: lams_admin/conf/xdoclet/struts-forms.xml =================================================================== diff -u -r8cfa07901cb6337b5483aa035ab100a1d166d37d -r40cd00471f7910f9cc2459a03082d35b33fd8308 --- lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 8cfa07901cb6337b5483aa035ab100a1d166d37d) +++ lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 40cd00471f7910f9cc2459a03082d35b33fd8308) @@ -34,3 +34,9 @@ + + + + + + Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java =================================================================== diff -u --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java (revision 0) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java (revision 40cd00471f7910f9cc2459a03082d35b33fd8308) @@ -0,0 +1,136 @@ +/**************************************************************** + * 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$ */ +package org.lamsfoundation.lams.admin.web; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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.Organisation; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.HttpSessionManager; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author Jun-Dir Liew + * + */ + +/** + * struts doclets + * + * @struts:action path="/userorg" + * name="UserOrgForm" + * scope="request" + * validate="false" + * + * @struts:action-forward name="userorg" + * path=".userorg" + */ +public class UserOrgAction extends Action { + + private static final Logger log = Logger.getLogger(UserOrgAction.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 { + + ActionMessages errors = new ActionMessages(); + Integer orgId = WebUtil.readIntParam(request,"orgId",true); + log.debug("orgId: "+orgId); + // get org name + Organisation organisation = (Organisation)service.findById(Organisation.class,orgId); + + if((orgId==null)||(orgId<=0)||organisation==null){ + errors.add("orgId",new ActionMessage("error.org.invalid")); + saveErrors(request,errors); + return mapping.findForward("error"); + } + + String orgName = organisation.getName(); + log.debug("orgName: "+orgName); + Organisation parentOrg = organisation.getParentOrganisation(); + + // check user permission + //String username = request.getRemoteUser(); + + // get list of users in org + List users = service.getUsersFromOrganisation(parentOrg.getOrganisationId()); + request.setAttribute("userlist",users); + /*if(users==null){ + errors.add("org",new ActionMessage("error.org.invalid")); + saveErrors(request,errors); + return mapping.findForward("error"); + }*/ + + // create form object + //UserListDTO userListForm = new UserListDTO(); + DynaActionForm userOrgForm = (DynaActionForm)form; + userOrgForm.set("orgId",orgId); + userOrgForm.set("orgName",orgName); + //userOrgForm.set("userlist",users); + /*userListForm.setOrgId(orgId); + userListForm.setOrgName(orgName); + List userManageBeans = new ArrayList(); + for(int i=0; i memberUsers = service.getUsersFromOrganisation(orgId); + String[] userIds = new String[memberUsers.size()]; + for(int i=0; i userIdList = Arrays.asList(userIds); + log.debug("userIdList: "+userIdList); + + // remove UserOrganisations that aren't in form data + Iterator iter = uos.iterator(); + while(iter.hasNext()){ + UserOrganisation uo = (UserOrganisation)iter.next(); + Integer userId = uo.getUser().getUserId(); + if(userIdList.indexOf(userId.toString())<0){ + iter.remove(); + log.debug("removed: "+userId); + } + } + // add UserOrganisations that are in form data + for(int i=0; i + + + + + + + + Index: lams_admin/web/userlist.jsp =================================================================== diff -u -r70ea9388f979616b6b3cfd0b30ea23338f95f83c -r40cd00471f7910f9cc2459a03082d35b33fd8308 --- lams_admin/web/userlist.jsp (.../userlist.jsp) (revision 70ea9388f979616b6b3cfd0b30ea23338f95f83c) +++ lams_admin/web/userlist.jsp (.../userlist.jsp) (revision 40cd00471f7910f9cc2459a03082d35b33fd8308) @@ -9,7 +9,7 @@

:

-' />

+' />

Index: lams_admin/web/userorg.jsp =================================================================== diff -u --- lams_admin/web/userorg.jsp (revision 0) +++ lams_admin/web/userorg.jsp (revision 40cd00471f7910f9cc2459a03082d35b33fd8308) @@ -0,0 +1,58 @@ +<%@ 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" %> + + + +

+ Add Users to Course/Class: +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + +
+ \ No newline at end of file