Index: lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java,v diff -u -r1.4 -r1.5 --- lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java 7 Nov 2007 03:28:37 -0000 1.4 +++ lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java 12 Nov 2007 23:30:46 -0000 1.5 @@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletResponse; import javax.sql.DataSource; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; @@ -63,6 +64,8 @@ * @author jliew * * @struts.action path="/displayGroup" validate="false" + * @struts.action-forward name="groupHeader" path="/groupHeader.jsp" + * @struts.action-forward name="groupContents" path="/groupContents.jsp" * @struts.action-forward name="group" path="/group.jsp" */ public class DisplayGroupAction extends Action { @@ -77,13 +80,16 @@ HttpServletRequest request, HttpServletResponse response) throws Exception { + String display = WebUtil.readStrParam(request, "display", false); stateId = WebUtil.readIntParam(request, "stateId", false); Integer orgId = WebUtil.readIntParam(request, "orgId", false); + Organisation org = null; if (orgId != null) { org = (Organisation)getService().findById(Organisation.class, orgId); } + String forwardPath = "group"; if (org != null) { boolean allowSorting = false; List roles = new ArrayList(); @@ -95,18 +101,29 @@ allowSorting = true; } } - IndexOrgBean iob = createOrgBean(org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN)); + + IndexOrgBean iob; + if (StringUtils.equals(display, "contents")) { + iob = new IndexOrgBean(org.getOrganisationId(), org.getName(), org.getOrganisationType().getOrganisationTypeId()); + iob = populateContentsOrgBean(iob, org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN)); + forwardPath = "groupContents"; + } else if (StringUtils.equals(display, "header")) { + iob = createHeaderOrgBean(org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN), false); + forwardPath = "groupHeader"; + } else { + iob = createHeaderOrgBean(org, roles, request.getRemoteUser(), request.isUserInRole(Role.SYSADMIN), true); + } + request.setAttribute("orgBean", iob); request.setAttribute("allowSorting", allowSorting); } - return mapping.findForward("group"); + return mapping.findForward(forwardPath); } @SuppressWarnings({"unchecked"}) - private IndexOrgBean createOrgBean(Organisation org, List roles, String username, boolean isSysAdmin) + private IndexOrgBean createHeaderOrgBean(Organisation org, List roles, String username, boolean isSysAdmin, boolean includeContents) throws SQLException, NamingException { - User user = (User)getService().findByProperty(User.class, "login", username).get(0); IndexOrgBean orgBean = new IndexOrgBean(org.getOrganisationId(), org.getName(), org.getOrganisationType().getOrganisationTypeId()); // set org links @@ -136,7 +153,18 @@ orgBean.setArchivedDate(org.getArchivedDate()); } - // set lesson beans + if (includeContents) { + orgBean = populateContentsOrgBean(orgBean, org, roles, username, isSysAdmin); + } + + return orgBean; + } + + private IndexOrgBean populateContentsOrgBean(IndexOrgBean orgBean, Organisation org, List roles, String username, boolean isSysAdmin) + throws SQLException, NamingException { + User user = (User)getService().findByProperty(User.class, "login", username).get(0); + + // set lesson beans List lessonBeans = null; try { lessonBeans = getLessonBeans(user.getUserId(), org.getOrganisationId(), roles, org.getOrderedLessonIds()); @@ -166,7 +194,7 @@ classRoles.add(userOrganisationRole.getRole().getRoleId()); } if(contains(roles,Role.ROLE_GROUP_MANAGER)) classRoles.add(Role.ROLE_GROUP_MANAGER); - childOrgBeans.add(createOrgBean(organisation,classRoles,username,isSysAdmin)); + childOrgBeans.add(createHeaderOrgBean(organisation,classRoles,username,isSysAdmin,true)); } } Collections.sort(childOrgBeans); Index: lams_central/src/java/org/lamsfoundation/lams/web/IndexAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/IndexAction.java,v diff -u -r1.39 -r1.40 --- lams_central/src/java/org/lamsfoundation/lams/web/IndexAction.java 19 Oct 2007 02:32:38 -0000 1.39 +++ lams_central/src/java/org/lamsfoundation/lams/web/IndexAction.java 12 Nov 2007 23:30:46 -0000 1.40 @@ -89,8 +89,8 @@ String tab = WebUtil.readStrParam(request, "tab", true); if (StringUtils.equals(tab, "profile")) { - List courseIds = getService().getArchivedCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); - request.setAttribute("courseIds", courseIds); + List collapsedOrgDTOs = getService().getArchivedCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); + request.setAttribute("collapsedOrgDTOs", collapsedOrgDTOs); return mapping.findForward("profile"); } else if (StringUtils.equals(tab, "editprofile")) { return mapping.findForward("editprofile"); @@ -108,8 +108,8 @@ return mapping.findForward("community"); } - List courseIds = getService().getActiveCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); - request.setAttribute("courseIds", courseIds); + List collapsedOrgDTOs = getService().getActiveCourseIdsByUser(loggedInUser.getUserId(), request.isUserInRole(Role.SYSADMIN)); + request.setAttribute("collapsedOrgDTOs", collapsedOrgDTOs); return mapping.findForward("main"); } Index: lams_central/src/java/org/lamsfoundation/lams/web/UpdateCollapsedGroupServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/UpdateCollapsedGroupServlet.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/src/java/org/lamsfoundation/lams/web/UpdateCollapsedGroupServlet.java 12 Nov 2007 23:30:46 -0000 1.1 @@ -0,0 +1,84 @@ +/**************************************************************** + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: UpdateCollapsedGroupServlet.java,v 1.1 2007/11/12 23:30:46 jliew Exp $ */ +package org.lamsfoundation.lams.web; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.usermanagement.Organisation; +import org.lamsfoundation.lams.usermanagement.Role; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.UserOrganisation; +import org.lamsfoundation.lams.usermanagement.UserOrganisationCollapsed; +import org.lamsfoundation.lams.usermanagement.service.UserManagementService; +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 jliew + * + * @web:servlet name="updateCollapsedGroup" + * @web:servlet-mapping url-pattern="/servlet/updateCollapsedGroup" + */ +public class UpdateCollapsedGroupServlet extends HttpServlet { + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // get request parameters + Integer orgId = WebUtil.readIntParam(request, "orgId", false); + String collapsed = request.getParameter("collapsed"); + + WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager.getInstance().getServletContext()); + UserManagementService service = (UserManagementService) ctx.getBean("userManagementService"); + + Organisation org = (Organisation)service.findById(Organisation.class, orgId); + User user = service.getUserByLogin(request.getRemoteUser()); + + // sysadmins always have non-collapsed groups; they aren't always members of the org anyway + if (request.isUserInRole(Role.SYSADMIN)) return; + + // insert or update userorg's collapsed status + if (org != null && collapsed != null && user != null) { + UserOrganisation uo = (UserOrganisation)service.getUserOrganisation(user.getUserId(), orgId); + UserOrganisationCollapsed uoc = uo.getUserOrganisationCollapsed(); + if (uoc != null) { + uoc.setCollapsed(new Boolean(collapsed)); + } else { + // new row in lams_user_organisation_collapsed + uoc = new UserOrganisationCollapsed(new Boolean(collapsed), uo); + } + service.save(uoc); + } + } + +} + \ No newline at end of file Index: lams_central/web/group.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/group.jsp,v diff -u -r1.7 -r1.8 --- lams_central/web/group.jsp 7 Nov 2007 03:28:37 -0000 1.7 +++ lams_central/web/group.jsp 12 Nov 2007 23:30:45 -0000 1.8 @@ -1,101 +1,5 @@ <%@ page contentType="text/html; charset=utf-8" language="java"%> -<%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-logic" prefix="logic"%> -<%@ taglib uri="tags-lams" prefix="lams"%> - -
-
-
-

- ( ) -

-
- -
- - - -
-
-
- -
- -
-
-lessons" class="j-lessons"> -

" class="j-single-lesson"> - - " class="disabled-sequence-name-link"> -  () -  () - - - " href="" class="sequence-name-link"> - - - - - - - - -

-
-
- - -
-

- - - ( ) - - - - - - - - -

- -
-
" class="j-subgroup-lessons"> -

" class="j-single-subgroup-lesson"> - - " class="disabled-sequence-name-link"> -  () -  () - - - " href="" class="sequence-name-link"> - - - - - - - - -

-
-
-
-
- -
-
- - - - - -
- + + \ No newline at end of file Index: lams_central/web/groupContents.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/groupContents.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/web/groupContents.jsp 12 Nov 2007 23:30:45 -0000 1.1 @@ -0,0 +1,79 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-lams" prefix="lams"%> + +
+ +
+
-lessons" class="j-lessons"> +

" class="j-single-lesson"> + + " class="disabled-sequence-name-link"> +  () +  () + + + " href="" class="sequence-name-link"> + + + + + + + + +

+
+
+ + +
+

+ + + ( ) + + + + + + + + +

+ +
+
" class="j-subgroup-lessons"> +

" class="j-single-subgroup-lesson"> + + " class="disabled-sequence-name-link"> +  () +  () + + + " href="" class="sequence-name-link"> + + + + + + + + +

+
+
+
+
+ +
+ + + + Index: lams_central/web/groupHeader.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/groupHeader.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/web/groupHeader.jsp 12 Nov 2007 23:30:45 -0000 1.1 @@ -0,0 +1,20 @@ +<%@ page contentType="text/html; charset=utf-8" language="java"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-lams" prefix="lams"%> + +
+
+

+ ( ) +

+
+ +
+ + + +
+
+
+ Index: lams_central/web/main.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/main.jsp,v diff -u -r1.25 -r1.26 --- lams_central/web/main.jsp 7 Nov 2007 03:28:37 -0000 1.25 +++ lams_central/web/main.jsp 12 Nov 2007 23:30:45 -0000 1.26 @@ -29,73 +29,13 @@ + + +