Index: lams_admin/.externalToolBuilders/SASS_lams_admin.launch
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/.externalToolBuilders/SASS_lams_admin.launch (.../SASS_lams_admin.launch) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/.externalToolBuilders/SASS_lams_admin.launch (.../SASS_lams_admin.launch) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -1,16 +1,22 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupPreviewLessonsAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ConfigAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/DisabledUserManageAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportExcelAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportExcelSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportGroupsAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportUserResultAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/LdapConfigAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/LogEventAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/LoginMaintainAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/LoginSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/LtiConsumerManagementAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/OrgManageAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/OrgPasswordChangeAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/OrgSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/OrganisationAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/PortraitBatchUploadAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ScheduledJobListAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ServerListAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ServerMaintainAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ServerSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SessionMaintainAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SignupManagementAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/StatisticsAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/TimezoneManagementAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ToolContentListAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserBasicListAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserManageAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserOrgAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserOrgRoleAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserOrgRoleSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserOrgSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserRolesAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserRolesSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSearchAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 550e1b37b507779064955267ef47e9085f791357 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSearchSingleTermAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupPreviewLessonsController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupPreviewLessonsController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupPreviewLessonsController.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,143 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.lesson.service.ILessonService;
+import org.lamsfoundation.lams.monitoring.service.IMonitoringService;
+import org.lamsfoundation.lams.security.ISecurityService;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.util.JsonUtil;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * @author Marcin Cieslak
+ */
+@Controller
+@RequestMapping("/cleanupPreviewLessons")
+public class CleanupPreviewLessonsController {
+
+ private static Logger log = Logger.getLogger(CleanupPreviewLessonsController.class);
+
+ private static IMonitoringService monitoringService;
+ private static ILessonService lessonService;
+ private static ISecurityService securityService;
+
+ @Autowired
+ @Qualifier("adminMessageService")
+ private MessageService adminMessageService;
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @RequestMapping("/start")
+ public String unspecified(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ if (!getSecurityService().isSysadmin(getUserID(), "display cleanup preview lessons", false)) {
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a sysadmin");
+ return null;
+ }
+
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ request.setAttribute("errorName", "CleanupPreviewLessonsAction");
+ request.setAttribute("errorMessage", adminMessageService.getMessage("error.need.sysadmin"));
+ return "error";
+ }
+
+ long[] lessonCount = getLessonService().getPreviewLessonCount();
+ request.setAttribute("previewCount", lessonCount[0]);
+ request.setAttribute("allLessonCount", lessonCount[1]);
+
+ return "cleanupPreviewLessons";
+ }
+
+ @RequestMapping(path = "/delete", method = RequestMethod.POST)
+ @ResponseBody
+ public String deletePreviewLessons(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ Integer userID = getUserID();
+ Integer limit = WebUtil.readIntParam(request, "limit", true);
+ List lessonIDs = getLessonService().getPreviewLessons(limit);
+ for (Long lessonID : lessonIDs) {
+ log.info("Deleting preview lesson: " + lessonID);
+ // role is checked in this method
+ getMonitoringService().removeLessonPermanently(lessonID, userID);
+ }
+
+ long[] lessonCount = getLessonService().getPreviewLessonCount();
+ String responseJSON = JsonUtil.toString(lessonCount);
+ response.setContentType("application/json;charset=utf-8");
+ response.getWriter().print(responseJSON);
+ return null;
+ }
+
+ private Integer getUserID() {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ return user == null ? null : user.getUserID();
+ }
+
+ private IMonitoringService getMonitoringService() {
+ if (monitoringService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(applicationContext.getServletContext());
+ monitoringService = (IMonitoringService) ctx.getBean("monitoringService");
+ }
+ return monitoringService;
+ }
+
+ private ILessonService getLessonService() {
+ if (lessonService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(applicationContext.getServletContext());
+ lessonService = (ILessonService) ctx.getBean("lessonService");
+ }
+ return lessonService;
+ }
+
+ private ISecurityService getSecurityService() {
+ if (securityService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(applicationContext.getServletContext());
+ securityService = (ISecurityService) ctx.getBean("securityService");
+ }
+ return securityService;
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupTempFilesController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupTempFilesController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupTempFilesController.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,140 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.File;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.struts.Globals;
+import org.lamsfoundation.lams.admin.web.form.CleanupForm;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.util.FileUtil;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.TempDirectoryFilter;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+@Controller
+@RequestMapping("/cleanup")
+public class CleanupTempFilesController {
+
+ private static Logger log = Logger.getLogger(CleanupTempFilesController.class);
+
+ @Autowired
+ @Qualifier("adminMessageService")
+ private MessageService adminMessageService;
+
+ @RequestMapping(path = "/start", method = RequestMethod.POST)
+ public String execute(@ModelAttribute CleanupForm cleanupForm, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // check user is sysadmin
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ request.setAttribute("errorName", "CleanupTempFilesAction");
+ request.setAttribute("errorMessage", adminMessageService.getMessage("error.need.sysadmin"));
+ return "error";
+ }
+
+ if (request.getAttribute(Globals.CANCEL_KEY) != null) {
+ return "redirect:/sysadminstart.do";
+ }
+
+ // check if url contains request for refresh folder sizes only
+ String action = WebUtil.readStrParam(request, "action", true);
+ if (action != null && StringUtils.equals(action, "refresh")) {
+ return refresh(cleanupForm, request);
+ }
+
+ MultiValueMap errorMap = new LinkedMultiValueMap<>();
+ Integer numDays = cleanupForm.getNumDays();
+
+ // delete directories if form has been submitted
+ if (numDays != null) {
+ if (numDays >= 0) {
+ int filesDeleted = FileUtil.cleanupOldFiles(FileUtil.getOldTempFiles(numDays));
+ String args[] = new String[1];
+ args[0] = new Integer(filesDeleted).toString();
+ request.setAttribute("filesDeleted", adminMessageService.getMessage("msg.cleanup.files.deleted", args));
+ } else {
+ errorMap.add("numDays", adminMessageService.getMessage("error.non.negative.number.required"));
+ request.setAttribute("errorMap", errorMap);
+ }
+ } else {
+ // recommended number of days to leave temp files
+ cleanupForm.setNumDays(1);
+ }
+
+ return "cleanup";
+ }
+
+ @RequestMapping("/refresh")
+ public String refresh(@ModelAttribute CleanupForm cleanupForm, HttpServletRequest request) throws Exception {
+
+ // display temp files info
+ File oldFiles[] = FileUtil.getOldTempFiles(0);
+ long zipTotal = 0;
+ long tmpTotal = 0;
+ if (oldFiles != null) {
+ for (int i = 0; i < oldFiles.length; i++) {
+ if (oldFiles[i].getName().startsWith(TempDirectoryFilter.zip_prefix)) {
+ zipTotal += FileUtil.calculateFileSize(oldFiles[i]);
+ } else if (oldFiles[i].getName().startsWith(TempDirectoryFilter.tmp_prefix)) {
+ tmpTotal += FileUtil.calculateFileSize(oldFiles[i]);
+ }
+ }
+ }
+ request.setAttribute("zipTotal", zipTotal / 1024);
+ request.setAttribute("tmpTotal", tmpTotal / 1024);
+
+ // set default numDays
+ Integer numDays = cleanupForm.getNumDays();
+ if (numDays == null) {
+ cleanupForm.setNumDays(1);
+ }
+
+ return "cleanup";
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CloneLessonsController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CloneLessonsController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CloneLessonsController.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,251 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Vector;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.lesson.Lesson;
+import org.lamsfoundation.lams.lesson.service.ILessonService;
+import org.lamsfoundation.lams.monitoring.service.IMonitoringService;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationState;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException;
+import org.lamsfoundation.lams.usermanagement.exception.UserException;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+@Controller
+@RequestMapping("/clone")
+public class CloneLessonsController {
+
+ private static final Logger log = Logger.getLogger(CloneLessonsController.class);
+ private static IUserManagementService userManagementService;
+ private static ILessonService lessonService;
+ private static IMonitoringService monitoringService;
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @RequestMapping("/start")
+ public String execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws UserAccessDeniedException {
+
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ throw new UserAccessDeniedException();
+ }
+
+ List errors = new ArrayList<>();
+ try {
+ CloneLessonsController.userManagementService = AdminServiceProxy
+ .getService(applicationContext.getServletContext());
+
+ String method = WebUtil.readStrParam(request, "method", true);
+ if (StringUtils.equals(method, "getGroups")) {
+ return getGroups(request, response);
+ } else if (StringUtils.equals(method, "getSubgroups")) {
+ return getSubgroups(request, response);
+ } else if (StringUtils.equals(method, "availableLessons")) {
+ return availableLessons(request, response);
+ } else if (StringUtils.equals(method, "selectStaff")) {
+ return selectStaff(request, response);
+ } else if (StringUtils.equals(method, "selectLearners")) {
+ return selectLearners(request, response);
+ } else if (StringUtils.equals(method, "clone")) {
+ return clone(request);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ errors.add(e.getMessage());
+ }
+ request.setAttribute("errors", errors);
+
+ // default action
+ Integer groupId = WebUtil.readIntParam(request, "groupId", false);
+ request.setAttribute("org", CloneLessonsController.userManagementService.findById(Organisation.class, groupId));
+
+ return "organisation/cloneStart";
+ }
+
+ // ajax
+ @RequestMapping("/getGroups")
+ @ResponseBody
+ public String getGroups(HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+ response.addHeader("Cache-Control", "no-cache");
+ response.addHeader("content-type", "text/html; charset=UTF-8");
+
+ List groups = CloneLessonsController.userManagementService
+ .getOrganisationsByTypeAndStatus(OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE);
+ for (Object o : groups) {
+ Organisation org = (Organisation) o;
+ response.getWriter()
+ .println("" + org.getName() + " ");
+ }
+
+ return null;
+ }
+
+ // ajax
+ @RequestMapping("/getSubgroups")
+ @ResponseBody
+ public String getSubgroups(HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+ Integer groupId = WebUtil.readIntParam(request, "groupId", true);
+
+ response.addHeader("Cache-Control", "no-cache");
+ response.addHeader("content-type", "text/html; charset=UTF-8");
+
+ if (groupId != null) {
+ HashMap properties = new HashMap<>();
+ properties.put("parentOrganisation.organisationId", groupId);
+ properties.put("organisationType.organisationTypeId", OrganisationType.CLASS_TYPE);
+ properties.put("organisationState.organisationStateId", OrganisationState.ACTIVE);
+
+ response.getWriter().println(" ");
+ List groups = CloneLessonsController.userManagementService.findByProperties(Organisation.class, properties);
+ for (Object o : groups) {
+ Organisation org = (Organisation) o;
+ response.getWriter()
+ .println("" + org.getName() + " ");
+ }
+ }
+
+ return null;
+ }
+
+ // ajax
+ @RequestMapping("/availableLessons")
+ public String availableLessons(HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+ Integer sourceGroupId = WebUtil.readIntParam(request, "sourceGroupId", true);
+
+ if (sourceGroupId != null) {
+ CloneLessonsController.lessonService = AdminServiceProxy
+ .getLessonService(applicationContext.getServletContext());
+
+ List lessons = CloneLessonsController.lessonService.getLessonsByGroup(sourceGroupId);
+ request.setAttribute("lessons", lessons);
+ }
+
+ response.addHeader("Cache-Control", "no-cache");
+ return "organisation/parts/availableLessons";
+ }
+
+ // ajax
+ @RequestMapping("/selectStaff")
+ public String selectStaff(HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+ Integer groupId = WebUtil.readIntParam(request, "groupId", false);
+
+ Vector monitors = CloneLessonsController.userManagementService.getUsersFromOrganisationByRole(groupId,
+ Role.MONITOR, true);
+ request.setAttribute("monitors", monitors);
+
+ response.addHeader("Cache-Control", "no-cache");
+ return "organisation/parts/selectStaff";
+ }
+
+ // ajax
+ @RequestMapping("/selectLearners")
+ public String selectLearners(HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+ Integer groupId = WebUtil.readIntParam(request, "groupId", false);
+
+ Vector learners = CloneLessonsController.userManagementService.getUsersFromOrganisationByRole(groupId,
+ Role.LEARNER, true);
+ request.setAttribute("learners", learners);
+
+ response.addHeader("Cache-Control", "no-cache");
+ return "organisation/parts/selectLearners";
+ }
+
+ @RequestMapping("/clone")
+ public String clone(HttpServletRequest request) throws Exception {
+
+ Integer groupId = WebUtil.readIntParam(request, "groupId", false);
+ String lessons = request.getParameter("lessons");
+ String staff = request.getParameter("staff");
+ String learners = request.getParameter("learners");
+ Boolean addAllStaff = WebUtil.readBooleanParam(request, "addAllStaff", false);
+ Boolean addAllLearners = WebUtil.readBooleanParam(request, "addAllLearners", false);
+
+ String[] lessonIds = new String[0], staffIds = new String[0], learnerIds = new String[0];
+ if (StringUtils.isNotEmpty(lessons)) {
+ lessonIds = lessons.split(",");
+ }
+ if (StringUtils.isNotEmpty(staff)) {
+ staffIds = staff.split(",");
+ }
+ if (StringUtils.isNotEmpty(learners)) {
+ learnerIds = learners.split(",");
+ }
+
+ CloneLessonsController.monitoringService = AdminServiceProxy
+ .getMonitoringService(applicationContext.getServletContext());
+ int result = 0;
+
+ Organisation group = (Organisation) CloneLessonsController.userManagementService.findById(Organisation.class,
+ groupId);
+ if (group != null) {
+ result = CloneLessonsController.monitoringService.cloneLessons(lessonIds, addAllStaff, addAllLearners,
+ staffIds, learnerIds, group);
+ } else {
+ throw new UserException("Couldn't find Organisation based on id=" + groupId);
+ }
+
+ request.setAttribute("org", group);
+ request.setAttribute("result", result);
+
+ return "organisation/cloneResult";
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ConfigAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ConfigAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ConfigAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,141 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.config.ConfigurationItem;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+
+/**
+ * ConfigAction
+ *
+ * @author Mitchell Seaton
+ */
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ */
+public class ConfigAction extends LamsDispatchAction {
+
+ private static Configuration configurationService;
+ private static MessageService messageService;
+
+ private Configuration getConfiguration() {
+ if (configurationService == null) {
+ configurationService = AdminServiceProxy.getConfiguration(getServlet().getServletContext());
+ }
+ return configurationService;
+ }
+
+ private MessageService getMessageService() {
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+ return messageService;
+ }
+
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
+
+ return mapping.findForward("config");
+ }
+
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
+ }
+
+ DynaActionForm configForm = (DynaActionForm) form;
+ String[] keys = (String[]) configForm.get("key");
+ String[] values = (String[]) configForm.get("value");
+
+ String errorForward = "config";
+
+ for (int i = 0; i < keys.length; i++) {
+ ConfigurationItem item = getConfiguration().getConfigItemByKey(keys[i]);
+
+ if (item != null) {
+ // return to ldap page if that's where we came from
+ if (StringUtils.contains(item.getHeaderName(), "config.header.ldap")) {
+ errorForward = "ldap";
+ }
+
+ if (item.getRequired()) {
+ if (!(values[i] != null && values[i].length() > 0)) {
+ request.setAttribute("error", getRequiredError(item.getDescriptionKey()));
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
+ return mapping.findForward(errorForward);
+ }
+ }
+ String format = item.getFormat();
+ if (format != null && format.equals(ConfigurationItem.LONG_FORMAT)) {
+ try {
+ Long.parseLong(values[i]);
+ } catch (NumberFormatException e) {
+ request.setAttribute("error", getNumericError(item.getDescriptionKey()));
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
+ return mapping.findForward(errorForward);
+ }
+ }
+ Configuration.updateItem(keys[i], values[i]);
+ }
+ }
+ getConfiguration().persistUpdate();
+
+ Configuration.refreshCache();
+
+ return mapping.findForward("sysadmin");
+ }
+
+ private String getRequiredError(String arg) {
+ String[] args = new String[1];
+ args[0] = getMessageService().getMessage(arg);
+ return getMessageService().getMessage("error.required", args);
+ }
+
+ private String getNumericError(String arg) {
+ String[] args = new String[1];
+ args[0] = getMessageService().getMessage(arg);
+ return getMessageService().getMessage("error.numeric", args);
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/DisabledUserManageAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/DisabledUserManageAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/DisabledUserManageAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,73 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ */
+public class DisabledUserManageAction extends Action {
+
+ private static final Logger log = Logger.getLogger(DisabledUserManageAction.class);
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ IUserManagementService service = AdminServiceProxy.getService(getServlet().getServletContext());
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ request.setAttribute("errorName", "DisabledUserManageAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.need.sysadmin"));
+ return mapping.findForward("error");
+ }
+
+ List users = service.findByProperty(User.class, "disabledFlag", true);
+ log.debug("got " + users.size() + " disabled users");
+ request.setAttribute("users", users);
+
+ return mapping.findForward("disabledlist");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.lamsfoundation.lams.admin.web.form.ImportExcelForm;
+import org.lamsfoundation.lams.util.WebUtil;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class ImportExcelAction extends Action {
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ //if (orgId==null) orgId = (Integer)request.getAttribute("orgId");
+
+ ImportExcelForm importExcelForm = (ImportExcelForm) form;
+ importExcelForm.setOrgId(orgId);
+
+ return mapping.findForward("importexcel");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,109 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.upload.FormFile;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.service.IImportService;
+import org.lamsfoundation.lams.admin.web.form.ImportExcelForm;
+import org.lamsfoundation.lams.web.session.SessionManager;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class ImportExcelSaveAction extends Action {
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
+ }
+
+ IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
+ ImportExcelForm importExcelForm = (ImportExcelForm) form;
+ FormFile file = importExcelForm.getFile();
+
+ // validation
+ if (file == null || file.getFileSize() <= 0) {
+ return mapping.findForward("import");
+ }
+
+ String sessionId = SessionManager.getSession().getId();
+ SessionManager.getSession().setAttribute(IImportService.IMPORT_FILE, file);
+ // use a new thread only if number of users is > threshold
+ if (importService.getNumRows(file) < IImportService.THRESHOLD) {
+ List results = importService.parseSpreadsheet(file, sessionId);
+ SessionManager.getSession(sessionId).setAttribute(IImportService.IMPORT_RESULTS, results);
+ return mapping.findForward("results");
+ } else {
+ Thread t = new Thread(new ImportExcelThread(sessionId));
+ t.start();
+ return mapping.findForward("status");
+ }
+ }
+
+ private class ImportExcelThread implements Runnable {
+ private String sessionId;
+
+ public ImportExcelThread(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public void run() {
+ IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
+ try {
+ FormFile file = (FormFile) SessionManager.getSession(sessionId)
+ .getAttribute(IImportService.IMPORT_FILE);
+ List results = importService.parseSpreadsheet(file, sessionId);
+ SessionManager.getSession(sessionId).setAttribute(IImportService.IMPORT_RESULTS, results);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportGroupsAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportGroupsAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportGroupsAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,80 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.upload.FormFile;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.service.IImportService;
+import org.lamsfoundation.lams.admin.web.form.ImportExcelForm;
+import org.lamsfoundation.lams.web.session.SessionManager;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class ImportGroupsAction extends Action {
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
+ }
+
+ IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
+ ImportExcelForm importForm = (ImportExcelForm) form;
+ importForm.setOrgId(0);
+ FormFile file = importForm.getFile();
+
+ // validation
+ if (file == null || file.getFileSize() <= 0) {
+ return mapping.findForward("importGroups");
+ }
+
+ String sessionId = SessionManager.getSession().getId();
+ List results = importService.parseGroupSpreadsheet(file, sessionId);
+ request.setAttribute("results", results);
+
+ return mapping.findForward("importGroups");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportUserResultAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportUserResultAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportUserResultAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,93 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+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.upload.FormFile;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.service.IImportService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.web.session.SessionManager;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ */
+public class ImportUserResultAction extends Action {
+
+ private static Logger log = Logger.getLogger(ImportUserResultAction.class);
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ MessageService messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
+ HttpSession ss = SessionManager.getSession();
+
+ List results = (List) ss.getAttribute(IImportService.IMPORT_RESULTS);
+ String successMessageKey = "";
+ try {
+ FormFile file = (FormFile) ss.getAttribute(IImportService.IMPORT_FILE);
+ successMessageKey = (importService.isUserSpreadsheet(file) ? "msg.users.created" : "msg.users.added");
+ } catch (Exception e) {
+ log.error("Couldn't check spreadsheet type!", e);
+ }
+
+ int successful = 0;
+ for (int i = 0; i < results.size(); i++) {
+ ArrayList rowResult = (ArrayList) results.get(i);
+ if (rowResult.isEmpty()) {
+ successful++;
+ }
+ }
+ String[] args = new String[1];
+ args[0] = String.valueOf(successful);
+
+ request.setAttribute("results", results);
+ request.setAttribute("successful", messageService.getMessage(successMessageKey, args));
+
+ // remove temporary session vars that allowed status to be displayed
+ // to user during import
+ ss.removeAttribute(IImportService.STATUS_IMPORT_TOTAL);
+ ss.removeAttribute(IImportService.STATUS_IMPORTED);
+ ss.removeAttribute(IImportService.IMPORT_FILE);
+ ss.removeAttribute(IImportService.IMPORT_RESULTS);
+
+ return mapping.findForward("importresult");
+ }
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LdapConfigAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LdapConfigAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LdapConfigAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,229 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang.StringUtils;
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.AuthenticationMethod;
+import org.lamsfoundation.lams.usermanagement.dto.BulkUpdateResultDTO;
+import org.lamsfoundation.lams.usermanagement.service.ILdapService;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.usermanagement.service.LdapService;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ */
+public class LdapConfigAction extends Action {
+
+ private static Logger log = Logger.getLogger(LdapConfigAction.class);
+ private static IUserManagementService service;
+ private static LdapService ldapService;
+ private static MessageService messageService;
+ private static Configuration configurationService;
+
+ private IUserManagementService getService() {
+ if (service == null) {
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ }
+ return service;
+ }
+
+ private LdapService getLdapService() {
+ if (ldapService == null) {
+ ldapService = AdminServiceProxy.getLdapService(getServlet().getServletContext());
+ }
+ return ldapService;
+ }
+
+ private MessageService getMessageService() {
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+ return messageService;
+ }
+
+ private Configuration getConfiguration() {
+ if (configurationService == null) {
+ configurationService = AdminServiceProxy.getConfiguration(getServlet().getServletContext());
+ }
+ return configurationService;
+ }
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ String action = WebUtil.readStrParam(request, "action", true);
+ if (action != null) {
+ if (StringUtils.equals(action, "sync")) {
+ return sync(mapping, form, request, response);
+ }
+ if (StringUtils.equals(action, "waiting")) {
+ return waiting(mapping, form, request, response);
+ }
+ if (StringUtils.equals(action, "results")) {
+ return results(mapping, form, request, response);
+ }
+ }
+
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_ONLY_LDAP));
+
+ int numLdapUsers = getNumLdapUsers();
+ request.setAttribute("numLdapUsersMsg", getNumLdapUsersMsg(numLdapUsers));
+
+ return mapping.findForward("ldap");
+ }
+
+ public ActionForward sync(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ String sessionId = SessionManager.getSession().getId();
+ Thread t = new Thread(new LdapSyncThread(sessionId));
+ t.start();
+
+ request.setAttribute("wait", getMessageService().getMessage("msg.ldap.synchronise.wait"));
+
+ return mapping.findForward("ldap");
+ }
+
+ public ActionForward waiting(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ request.setAttribute("wait", getMessageService().getMessage("msg.ldap.synchronise.wait"));
+
+ return mapping.findForward("ldap");
+ }
+
+ public ActionForward results(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ HttpSession ss = SessionManager.getSession();
+ Object o = ss.getAttribute(ILdapService.SYNC_RESULTS);
+ if (o instanceof BulkUpdateResultDTO) {
+ BulkUpdateResultDTO dto = (BulkUpdateResultDTO) o;
+
+ int numLdapUsers = getNumLdapUsers();
+ request.setAttribute("numLdapUsersMsg", getNumLdapUsersMsg(numLdapUsers));
+
+ request.setAttribute("numSearchResults", getNumSearchResultsUsersMsg(dto.getNumSearchResults()));
+ request.setAttribute("numLdapUsersCreated", getNumCreatedUsersMsg(dto.getNumUsersCreated()));
+ request.setAttribute("numLdapUsersUpdated", getNumUpdatedUsersMsg(dto.getNumUsersUpdated()));
+ request.setAttribute("numLdapUsersDisabled", getNumDisabledUsersMsg(dto.getNumUsersDisabled()));
+ request.setAttribute("messages", dto.getMessages());
+ request.setAttribute("done", getMessageService().getMessage("msg.done"));
+ } else {
+ ArrayList list = new ArrayList();
+ list.add((String) o);
+ request.setAttribute("messages", list);
+ request.setAttribute("done", getMessageService().getMessage("msg.done"));
+ }
+
+ // remove session variable that flags bulk update as done
+ ss.removeAttribute(ILdapService.SYNC_RESULTS);
+
+ return mapping.findForward("ldap");
+ }
+
+ private int getNumLdapUsers() {
+ Integer count = getService().getCountUsers(AuthenticationMethod.LDAP);
+ return (count != null ? count.intValue() : -1);
+ }
+
+ private String getNumLdapUsersMsg(int numLdapUsers) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(numLdapUsers);
+ return getMessageService().getMessage("msg.num.ldap.users", args);
+ }
+
+ private String getNumSearchResultsUsersMsg(int searchResults) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(searchResults);
+ return getMessageService().getMessage("msg.num.search.results.users", args);
+ }
+
+ private String getNumCreatedUsersMsg(int created) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(created);
+ return getMessageService().getMessage("msg.num.created.users", args);
+ }
+
+ private String getNumUpdatedUsersMsg(int updated) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(updated);
+ return getMessageService().getMessage("msg.num.updated.users", args);
+ }
+
+ private String getNumDisabledUsersMsg(int disabled) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(disabled);
+ return getMessageService().getMessage("msg.num.disabled.users", args);
+ }
+
+ private class LdapSyncThread implements Runnable {
+ private String sessionId;
+
+ private Logger log = Logger.getLogger(LdapSyncThread.class);
+
+ public LdapSyncThread(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public void run() {
+ this.log.info("=== Beginning LDAP user sync ===");
+ long start = System.currentTimeMillis();
+ try {
+ BulkUpdateResultDTO dto = getLdapService().bulkUpdate();
+ long end = System.currentTimeMillis();
+ this.log.info("=== Finished LDAP user sync ===");
+ this.log.info("Bulk update took " + (end - start) / 1000 + " seconds.");
+ SessionManager.getSession(sessionId).setAttribute(ILdapService.SYNC_RESULTS, dto);
+ } catch (Exception e) {
+ String message = e.getMessage() != null ? e.getMessage() : e.getClass().getName();
+ SessionManager.getSession(sessionId).setAttribute(ILdapService.SYNC_RESULTS, message);
+ e.printStackTrace();
+ }
+ }
+ }
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LogEventAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LogEventAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LogEventAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,216 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.LogEventType;
+import org.lamsfoundation.lams.logevent.dto.LogEventTypeDTO;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.util.JsonUtil;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Report on events in the log event table. Used for auditing.
+ */
+public class LogEventAction extends LamsDispatchAction {
+
+ private static ILogEventService logEventService;
+ private MessageService messageService;
+ private static SimpleDateFormat START_DATE_FORMAT = new SimpleDateFormat("YYYY-MM-dd");
+
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // check permission
+ if (!request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("errorName", "EventLogAdmin");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ logEventService = getLogEventService();
+
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+
+ // get the log type data and return display for user selection. Also get the start and stop dates from the log.
+ // TODO check conversion the dates to the user's timezone
+ List types = logEventService.getEventTypes();
+ List convertedTypes = new ArrayList(types.size());
+ for (LogEventType type : types) {
+ convertedTypes.add(new LogEventTypeDTO(type, messageService.getMessage(type.getDescriptionI18NKey()),
+ messageService.getMessage(type.getAreaI18NKey())));
+ }
+ request.setAttribute("eventLogTypes", convertedTypes);
+
+ // jsp page expects date of the first audit log entry as YYYY-DD-MM.
+ Date oldestDate = logEventService.getOldestEventDate();
+// oldestDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, oldestDate);
+ request.setAttribute("startDate", START_DATE_FORMAT.format(oldestDate != null ? oldestDate : new Date()));
+ return mapping.findForward("success");
+ }
+
+ /**
+ * The initial method for monitoring. List all users according to given Content ID.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @return
+ * @throws JSONException
+ * @throws ServletException
+ * @throws IOException
+ */
+ public ActionForward getEventLog(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+ // check permission
+ if (!request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("errorName", "EventLogAdmin");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ logEventService = getLogEventService();
+
+ // paging parameters of tablesorter
+ int size = WebUtil.readIntParam(request, "size");
+ int page = WebUtil.readIntParam(request, "page");
+ Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true);
+// String searchString = request.getParameter("fcol[0]");
+
+ int sorting = ILogEventService.SORT_BY_DATE_ASC;
+ if ((isSort1 != null) && isSort1.equals(1)) {
+ sorting = ILogEventService.SORT_BY_DATE_DESC;
+ }
+
+ Long dateParameter = WebUtil.readLongParam(request, "startDate", true);
+ Date startDate = null;
+ if (dateParameter != null) {
+ startDate = new Date(dateParameter);
+ // TODO if using time zones then convert to server timezone
+// HttpSession ss = SessionManager.getSession();
+// org.lamsfoundation.lams.usermanagement.dto.UserDTO teacher = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) ss
+// .getAttribute(AttributeNames.USER);
+// TimeZone teacherTimeZone = teacher.getTimeZone();
+// tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline);
+ }
+
+ dateParameter = WebUtil.readLongParam(request, "endDate", true);
+ Date endDate = null;
+ if (dateParameter != null) {
+ endDate = new Date(dateParameter);
+ }
+
+ String area = WebUtil.readStrParam(request, "area", true);
+ Integer typeId = WebUtil.readIntParam(request, "typeId", true);
+ List events = logEventService.getEventsForTablesorter(page, size, sorting, null, startDate, endDate,
+ area, typeId);
+
+ ArrayNode rows = JsonNodeFactory.instance.arrayNode();
+ ObjectNode responsedata = JsonNodeFactory.instance.objectNode();
+ responsedata.put("total_rows",
+ logEventService.countEventsWithRestrictions(null, startDate, endDate, area, typeId));
+
+ for (Object[] eventDetails : events) {
+ if (eventDetails.length > 0) {
+ LogEvent event = (LogEvent) eventDetails[0];
+ ObjectNode responseRow = JsonNodeFactory.instance.objectNode();
+
+ responseRow.put("dateOccurred", JsonUtil.toString(event.getOccurredDateTime()));
+ responseRow.put("typeId", event.getLogEventTypeId());
+ responseRow.put("description", event.getDescription());
+ if (event.getLessonId() != null) {
+ responseRow.put("lessonId", event.getLessonId());
+ }
+ if (event.getActivityId() != null) {
+ responseRow.put("activityId", event.getActivityId());
+ }
+
+ User user = event.getUser();
+ if (user != null) {
+ responseRow.put("userPortraitId", user.getPortraitUuid());
+ responseRow.put("userId", user.getUserId());
+ responseRow.put("userName", user.getLogin());
+ }
+ User targetUser = event.getTargetUser();
+ if (targetUser != null) {
+ responseRow.put("targetUserPortraitId", targetUser.getPortraitUuid());
+ responseRow.put("targetUserId", targetUser.getUserId());
+ responseRow.put("targetUserName", targetUser.getLogin());
+ }
+ if (eventDetails.length > 1 && eventDetails[1] != null) {
+ responseRow.put("lessonName", JsonUtil.toString(eventDetails[1]));
+ }
+ if (eventDetails.length > 2 && eventDetails[2] != null) {
+ responseRow.put("activityName", JsonUtil.toString(eventDetails[2]));
+ }
+ rows.add(responseRow);
+ }
+ }
+ responsedata.set("rows", rows);
+ response.setContentType("application/json;charset=utf-8");
+ response.getWriter().print(new String(responsedata.toString()));
+ return null;
+ }
+
+ private ILogEventService getLogEventService() throws ServletException {
+ if (logEventService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ logEventService = (ILogEventService) ctx.getBean("logEventService");
+ }
+ return logEventService;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LoginMaintainAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LoginMaintainAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LoginMaintainAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,95 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.DynaActionForm;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.ConfigurationKeys;
+
+/**
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class LoginMaintainAction extends Action {
+
+ private static final String NEWS_PAGE_PATH_SUFFIX = File.separatorChar + "lams-www.war" + File.separatorChar
+ + "news.html";
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ DynaActionForm loginMaintainForm = (DynaActionForm) form;
+ loginMaintainForm.set("news", loadNews());
+ return mapping.findForward("loginmaintain");
+ }
+
+ private String loadNews() throws IOException {
+ BufferedReader bReader = null;
+ try {
+ InputStreamReader ir = new InputStreamReader(
+ new FileInputStream(Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + NEWS_PAGE_PATH_SUFFIX),
+ Charset.forName("UTF-8"));
+ bReader = new BufferedReader(ir);
+ StringBuilder news = new StringBuilder();
+ String line = bReader.readLine();
+ while (line != null) {
+ news.append(line).append('\n');
+ line = bReader.readLine();
+ }
+ return news.toString();
+ } finally {
+ if (bReader != null) {
+ bReader.close();
+ }
+ }
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LoginSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LoginSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LoginSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,78 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.ConfigurationKeys;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+
+/**
+ * Use DispatchAction for future extension convenience, e.g. add preview feature
+ *
+ * @author Fei Yang
+ */
+public class LoginSaveAction extends LamsDispatchAction {
+
+ private static final String NEWS_PAGE_PATH_SUFFIX = File.separatorChar + "lams-www.war" + File.separatorChar
+ + "news.html";
+
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
+ }
+
+ DynaActionForm loginMaintainForm = (DynaActionForm) form;
+ BufferedWriter bWriter = null;
+ try {
+ OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream(
+ Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + NEWS_PAGE_PATH_SUFFIX),
+ Charset.forName("UTF-8"));
+ bWriter = new BufferedWriter(ow);
+ bWriter.write(loginMaintainForm.getString("news"));
+ bWriter.flush();
+ } finally {
+ if (bWriter != null) {
+ bWriter.close();
+ }
+ }
+
+ return mapping.findForward("sysadmin");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LtiConsumerManagementAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LtiConsumerManagementAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LtiConsumerManagementAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,187 @@
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+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.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.integration.ExtServer;
+import org.lamsfoundation.lams.integration.service.IIntegrationService;
+import org.lamsfoundation.lams.integration.util.LtiUtils;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+
+/**
+ * @author Andrey Balan
+ */
+public class LtiConsumerManagementAction extends LamsDispatchAction {
+
+ private static Logger log = Logger.getLogger(LtiConsumerManagementAction.class);
+ private IUserManagementService userManagementService;
+ private MessageService messageService;
+ private IIntegrationService integrationService;
+
+ private void initServices() {
+ if (userManagementService == null) {
+ userManagementService = AdminServiceProxy.getService(getServlet().getServletContext());
+ }
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+ if (integrationService == null) {
+ integrationService = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
+ }
+ }
+
+ /**
+ * Shows all available LTI tool consumers
+ */
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ initServices();
+
+ List ltiConsumers = integrationService.getAllToolConsumers();
+ Collections.sort(ltiConsumers);
+ request.setAttribute("ltiConsumers", ltiConsumers);
+
+ return mapping.findForward("ltiConsumerList");
+ }
+
+ /**
+ * Edits specified LTI tool consumer
+ */
+ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ DynaActionForm ltiConsumerForm = (DynaActionForm) form;
+ Integer sid = WebUtil.readIntParam(request, "sid", true);
+
+ // editing a tool consumer
+ if (sid != null) {
+ ExtServer ltiConsumer = integrationService.getExtServer(sid);
+ BeanUtils.copyProperties(ltiConsumerForm, ltiConsumer);
+ String lessonFinishUrl = ltiConsumer.getLessonFinishUrl() == null ? "-" : ltiConsumer.getLessonFinishUrl();
+ request.setAttribute("lessonFinishUrl", lessonFinishUrl);
+
+ // create a tool consumer
+ } else {
+ //do nothing
+ }
+
+ return mapping.findForward("ltiConsumer");
+ }
+
+ /**
+ * Disables or enables (depending on "disable" parameter) specified LTI tool consumer
+ */
+ public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ Integer sid = WebUtil.readIntParam(request, "sid", true);
+ boolean disable = WebUtil.readBooleanParam(request, "disable");
+ ExtServer ltiConsumer = integrationService.getExtServer(sid);
+ ltiConsumer.setDisabled(disable);
+ integrationService.saveExtServer(ltiConsumer);
+
+ return unspecified(mapping, form, request, response);
+ }
+
+ /**
+ * Removes specified LTI tool consumer
+ */
+ public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ Integer sid = WebUtil.readIntParam(request, "sid", true);
+ userManagementService.deleteById(ExtServer.class, sid);
+
+ return unspecified(mapping, form, request, response);
+ }
+
+ /**
+ * Stores in the DB a new or edited LTI tool consumer
+ */
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ if (isCancelled(request)) {
+ //show LTI consumer list page
+ return unspecified(mapping, form, request, response);
+ }
+
+ DynaActionForm extServerForm = (DynaActionForm) form;
+ ActionMessages errors = new ActionMessages();
+ String[] requiredFields = { "serverid", "serverkey", "servername", "prefix" };
+ for (String requiredField : requiredFields) {
+ if (StringUtils.trimToNull(extServerForm.getString(requiredField)) == null) {
+ errors.add(requiredField,
+ new ActionMessage("error.required", messageService.getMessage("sysadmin." + requiredField)));
+ }
+ }
+
+ Integer sid = (Integer) extServerForm.get("sid");
+ //check duplication
+ if (errors.isEmpty()) {
+ String[] uniqueFields = { "serverid", "prefix" };
+ for (String uniqueField : uniqueFields) {
+ List list = userManagementService.findByProperty(ExtServer.class, uniqueField,
+ extServerForm.get(uniqueField));
+ if (list != null && list.size() > 0) {
+ if (sid.equals(0)) {//new map
+ errors.add(uniqueField, new ActionMessage("error.not.unique",
+ messageService.getMessage("sysadmin." + uniqueField)));
+ } else {
+ ExtServer ltiConsumer = list.get(0);
+ if (!ltiConsumer.getSid().equals(sid)) {
+ errors.add(uniqueField, new ActionMessage("error.not.unique",
+ messageService.getMessage("sysadmin." + uniqueField)));
+ }
+ }
+
+ }
+ }
+ }
+ if (errors.isEmpty()) {
+ ExtServer ltiConsumer = null;
+ if (sid.equals(0)) {
+ ltiConsumer = new ExtServer();
+ BeanUtils.copyProperties(ltiConsumer, extServerForm);
+ ltiConsumer.setSid(null);
+ ltiConsumer.setServerTypeId(ExtServer.LTI_CONSUMER_SERVER_TYPE);
+ ltiConsumer.setUserinfoUrl("blank");
+ } else {
+ ltiConsumer = integrationService.getExtServer(sid);
+ BeanUtils.copyProperties(ltiConsumer, extServerForm);
+ }
+ integrationService.saveExtServer(ltiConsumer);
+ return unspecified(mapping, form, request, response);
+
+ } else {
+ saveErrors(request, errors);
+ return mapping.getInputForward();
+ }
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgManageAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgManageAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgManageAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,234 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.form.OrgManageForm;
+import org.lamsfoundation.lams.security.ISecurityService;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationState;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.usermanagement.service.UserManagementService;
+import org.lamsfoundation.lams.util.FileUtil;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+import org.springframework.web.util.HtmlUtils;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ */
+public class OrgManageAction extends LamsDispatchAction {
+
+ private static IUserManagementService userManagementService;
+
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ initServices();
+
+ // Get organisation whose child organisations we will populate the OrgManageForm with
+ Integer orgId = WebUtil.readIntParam(request, "org", true);
+ if (orgId == null) {
+ orgId = (Integer) request.getAttribute("org");
+ }
+ if ((orgId == null) || (orgId == 0)) {
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing organisation ID");
+ return null;
+ }
+
+ // get logged in user's id
+ Integer userId = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)).getUserID();
+ ISecurityService securityService = AdminServiceProxy.getSecurityService(getServlet().getServletContext());
+
+ Organisation org = null;
+ boolean isRootOrganisation = false;
+ Organisation rootOrganisation = userManagementService.getRootOrganisation();
+ if (orgId.equals(rootOrganisation.getOrganisationId())) {
+ org = rootOrganisation;
+ isRootOrganisation = true;
+ } else {
+ org = (Organisation) userManagementService.findById(Organisation.class, orgId);
+ }
+
+ // check if user is allowed to view and edit groups
+ if (!request.isUserInRole(Role.SYSADMIN) && !(isRootOrganisation
+ ? request.isUserInRole(Role.GROUP_ADMIN) || request.isUserInRole(Role.GROUP_MANAGER)
+ : securityService.hasOrgRole(orgId, userId, new String[] { Role.GROUP_ADMIN, Role.GROUP_MANAGER },
+ "manage courses", false))) {
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a manager or admin in the organisation");
+ return null;
+ }
+
+ // get number of users figure
+ // TODO use hql that does a count instead of getting whole objects
+ int numUsers = org == rootOrganisation ? userManagementService.getCountUsers()
+ : userManagementService.getUsersFromOrganisation(orgId).size();
+ String key = org == rootOrganisation ? "label.users.in.system" : "label.users.in.group";
+ MessageService messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ request.setAttribute("numUsers", messageService.getMessage(key, new String[] { String.valueOf(numUsers) }));
+
+ // Set OrgManageForm
+ OrgManageForm orgManageForm = (OrgManageForm) form;
+ if (orgManageForm == null) {
+ orgManageForm = new OrgManageForm();
+ orgManageForm.setStateId(OrganisationState.ACTIVE);
+ } else if (orgManageForm.getStateId() == null) {
+ orgManageForm.setStateId(OrganisationState.ACTIVE);
+ }
+ orgManageForm.setParentId(orgId);
+ orgManageForm.setParentName(org.getName());
+ orgManageForm.setType(org.getOrganisationType().getOrganisationTypeId());
+
+ // Get list of child organisations depending on requestor's role and the organisation's type
+ if (orgManageForm.getType().equals(OrganisationType.CLASS_TYPE)) {
+ // display class info, with parent group's 'courseAdminCan...' permissions.
+ // note the org is not saved, properties set only for passing to view component.
+ Organisation pOrg = org.getParentOrganisation();
+ org.setCourseAdminCanAddNewUsers(pOrg.getCourseAdminCanAddNewUsers());
+ org.setCourseAdminCanBrowseAllUsers(pOrg.getCourseAdminCanBrowseAllUsers());
+ org.setCourseAdminCanChangeStatusOfCourse(pOrg.getCourseAdminCanChangeStatusOfCourse());
+ request.setAttribute("org", org);
+
+ // display parent org breadcrumb link
+ request.setAttribute("parentGroupName", pOrg.getName());
+ request.setAttribute("parentGroupId", pOrg.getOrganisationId());
+ } else {
+ request.setAttribute("OrgManageForm", orgManageForm);
+
+ // display org info
+ request.setAttribute("org", org);
+ }
+
+ // let the jsp know whether to display links
+ request.setAttribute("createGroup",
+ request.isUserInRole(Role.SYSADMIN) || userManagementService.isUserGlobalGroupAdmin());
+ request.setAttribute("editGroup", true);
+ request.setAttribute("manageGlobalRoles", request.isUserInRole(Role.SYSADMIN));
+ return mapping.findForward("orglist");
+ }
+
+ /**
+ * Returns list of organisations for .
+ */
+ public ActionForward getOrgs(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse res) throws IOException, ServletException {
+ initServices();
+
+ Integer parentOrgId = WebUtil.readIntParam(request, "parentOrgId");
+ Integer stateId = WebUtil.readIntParam(request, "stateId");
+ Integer typeIdParam = WebUtil.readIntParam(request, "type");
+ // the organisation type of the children
+ Integer typeId = (typeIdParam.equals(OrganisationType.ROOT_TYPE) ? OrganisationType.COURSE_TYPE
+ : OrganisationType.CLASS_TYPE);
+ String searchString = WebUtil.readStrParam(request, "fcol[1]", true);
+
+ // paging parameters of tablesorter
+ int size = WebUtil.readIntParam(request, "size");
+ int page = WebUtil.readIntParam(request, "page");
+ Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true);
+ Integer isSort2 = WebUtil.readIntParam(request, "column[1]", true);
+ Integer isSort3 = WebUtil.readIntParam(request, "column[2]", true);
+ Integer isSort4 = WebUtil.readIntParam(request, "column[3]", true);
+
+ String sortBy = "";
+ String sortOrder = "";
+ if (isSort1 != null) {
+ sortBy = "id";
+ sortOrder = isSort1.equals(0) ? "ASC" : "DESC";
+
+ } else if (isSort2 != null) {
+ sortBy = "name";
+ sortOrder = isSort2.equals(0) ? "ASC" : "DESC";
+
+ } else if (isSort3 != null) {
+ sortBy = "code";
+ sortOrder = isSort3.equals(0) ? "ASC" : "DESC";
+
+ } else if (isSort4 != null) {
+ sortBy = "createDate";
+ sortOrder = isSort4.equals(0) ? "ASC" : "DESC";
+
+ }
+
+ List organisations = userManagementService.getPagedCourses(parentOrgId, typeId, stateId, page,
+ size, sortBy, sortOrder, searchString);
+
+ ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
+ responseJSON.put("total_rows", userManagementService.getCountCoursesByParentCourseAndTypeAndState(parentOrgId,
+ typeId, stateId, searchString));
+
+ ArrayNode rows = JsonNodeFactory.instance.arrayNode();
+ for (Organisation organisation : organisations) {
+ ObjectNode responseRow = JsonNodeFactory.instance.objectNode();
+ responseRow.put("id", organisation.getOrganisationId());
+ String orgName = organisation.getName() == null ? "" : organisation.getName();
+ responseRow.put("name", HtmlUtils.htmlEscape(orgName));
+ String orgCode = organisation.getCode() == null ? "" : organisation.getCode();
+ responseRow.put("code", HtmlUtils.htmlEscape(orgCode));
+ String orgCreateDate = organisation.getCreateDate() == null ? ""
+ : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(organisation.getCreateDate());
+ responseRow.put("createDate", orgCreateDate);
+
+ rows.add(responseRow);
+ }
+
+ responseJSON.set("rows", rows);
+ res.setContentType("application/json;charset=utf-8");
+ res.getWriter().print(responseJSON.toString());
+ return null;
+ }
+
+ private void initServices() {
+ if (userManagementService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getWebApplicationContext(getServlet().getServletContext());
+ userManagementService = (UserManagementService) ctx.getBean("userManagementService");
+ }
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgPasswordChangeAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgPasswordChangeAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgPasswordChangeAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,327 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.security.InvalidParameterException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.apache.struts.actions.DispatchAction;
+import org.lamsfoundation.lams.admin.AdminConstants;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.events.IEventNotificationService;
+import org.lamsfoundation.lams.integration.security.RandomPasswordGenerator;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.HashUtil;
+import org.lamsfoundation.lams.util.JsonUtil;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.ValidationUtil;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class OrgPasswordChangeAction extends DispatchAction {
+
+ private static Logger log = Logger.getLogger(OrgPasswordChangeAction.class);
+
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ Integer organisationID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID);
+ DynaActionForm passForm = (DynaActionForm) form;
+ passForm.set(AttributeNames.PARAM_ORGANISATION_ID, organisationID);
+ IUserManagementService userManagementService = AdminServiceProxy.getService(getServlet().getServletContext());
+ Organisation organisation = (Organisation) userManagementService.findById(Organisation.class, organisationID);
+ passForm.set(AttributeNames.PARAM_ORGANISATION_NAME, organisation.getName());
+ passForm.set("isStaffChange", true);
+ passForm.set("isLearnerChange", true);
+ passForm.set("staffPass", RandomPasswordGenerator.nextPasswordValidated());
+ passForm.set("learnerPass", RandomPasswordGenerator.nextPasswordValidated());
+
+ return mapping.findForward("display");
+ }
+
+ public ActionForward generatePassword(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ response.setContentType("text/plain;charset=utf-8");
+ response.getWriter().print(RandomPasswordGenerator.nextPasswordValidated());
+ return null;
+ }
+
+ public ActionForward getGridUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ Integer organisationID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID);
+ String role = WebUtil.readStrParam(request, AttributeNames.PARAM_ROLE);
+
+ UserDTO userDTO = getUserDTO();
+ Integer currentUserId = userDTO.getUserID();
+ if (!AdminServiceProxy.getSecurityService(getServlet().getServletContext()).isSysadmin(currentUserId,
+ "get grid users for org password change", false)) {
+ String warning = "User " + currentUserId + " is not a sysadmin";
+ log.warn(warning);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, warning);
+ return null;
+ }
+
+ int page = WebUtil.readIntParam(request, AdminConstants.PARAM_PAGE);
+ int rowLimit = WebUtil.readIntParam(request, AdminConstants.PARAM_ROWS);
+ String sortOrder = WebUtil.readStrParam(request, AdminConstants.PARAM_SORD);
+ String sortColumn = WebUtil.readStrParam(request, AdminConstants.PARAM_SIDX, true);
+
+ // fetch staff or learners
+ List users = getUsersByRole(organisationID, role.equalsIgnoreCase("staff"), sortColumn, sortOrder);
+
+ // paging
+ int totalPages = 1;
+ int totalUsers = users.size();
+ if (rowLimit < users.size()) {
+ totalPages = new Double(
+ Math.ceil(new Integer(users.size()).doubleValue() / new Integer(rowLimit).doubleValue()))
+ .intValue();
+ int firstRow = (page - 1) * rowLimit;
+ int lastRow = firstRow + rowLimit;
+
+ if (lastRow > users.size()) {
+ users = users.subList(firstRow, users.size());
+ } else {
+ users = users.subList(firstRow, lastRow);
+ }
+ }
+
+ ObjectNode resultJSON = JsonNodeFactory.instance.objectNode();
+ resultJSON.put(AdminConstants.ELEMENT_PAGE, page);
+ resultJSON.put(AdminConstants.ELEMENT_TOTAL, totalPages);
+ resultJSON.put(AdminConstants.ELEMENT_RECORDS, totalUsers);
+
+ ArrayNode rowsJSON = JsonNodeFactory.instance.arrayNode();
+ // build rows for grid
+ for (UserDTO user : users) {
+ ObjectNode rowJSON = JsonNodeFactory.instance.objectNode();
+ rowJSON.put(AdminConstants.ELEMENT_ID, user.getUserID());
+
+ ArrayNode cellJSON = JsonNodeFactory.instance.arrayNode();
+ cellJSON.add(user.getFirstName() + " " + user.getLastName());
+ cellJSON.add(user.getLogin());
+ cellJSON.add(user.getEmail());
+
+ rowJSON.set(AdminConstants.ELEMENT_CELL, cellJSON);
+ rowsJSON.add(rowJSON);
+ }
+
+ resultJSON.set(AdminConstants.ELEMENT_ROWS, rowsJSON);
+
+ response.setContentType("application/json;charset=utf-8");
+ response.getWriter().print(resultJSON.toString());
+ return null;
+ }
+
+ public ActionForward changePassword(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ UserDTO userDTO = getUserDTO();
+ Integer currentUserId = userDTO.getUserID();
+ // security check
+ if (!AdminServiceProxy.getSecurityService(getServlet().getServletContext()).isSysadmin(currentUserId,
+ "org password change", false)) {
+ String warning = "User " + currentUserId + " is not a sysadmin";
+ log.warn(warning);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, warning);
+ return null;
+ }
+
+ DynaActionForm passForm = (DynaActionForm) form;
+ Integer organisationID = (Integer) passForm.get(AttributeNames.PARAM_ORGANISATION_ID);
+ Boolean email = (Boolean) passForm.get("email");
+ Boolean force = (Boolean) passForm.get("force");
+
+ Boolean isStaffChange = (Boolean) passForm.get("isStaffChange");
+ Boolean isLearnerChange = (Boolean) passForm.get("isLearnerChange");
+ // get data needed for each group
+ if (isStaffChange) {
+ String staffString = (String) passForm.get("excludedStaff");
+ ArrayNode excludedStaff = StringUtils.isBlank(staffString) ? null : JsonUtil.readArray(staffString);
+ staffString = (String) passForm.get("includedStaff");
+ ArrayNode includedStaff = StringUtils.isBlank(staffString) ? null : JsonUtil.readArray(staffString);
+
+ String staffPass = (String) passForm.get("staffPass");
+ Collection users = getUsersByRole(organisationID, true);
+ Collection changedUserIDs = changePassword(staffPass, users, includedStaff, excludedStaff, force);
+ if (email && !changedUserIDs.isEmpty()) {
+ notifyOnPasswordChange(changedUserIDs, staffPass);
+ }
+ }
+ if (isLearnerChange) {
+ String learnersString = (String) passForm.get("excludedLearners");
+ ArrayNode excludedLearners = StringUtils.isBlank(learnersString) ? null
+ : JsonUtil.readArray(learnersString);
+ learnersString = (String) passForm.get("includedLearners");
+ ArrayNode includedLearners = StringUtils.isBlank(learnersString) ? null
+ : JsonUtil.readArray(learnersString);
+
+ String learnerPass = (String) passForm.get("learnerPass");
+ Collection users = getUsersByRole(organisationID, false);
+ Collection changedUserIDs = changePassword(learnerPass, users, includedLearners, excludedLearners,
+ force);
+ if (email && !changedUserIDs.isEmpty()) {
+ notifyOnPasswordChange(changedUserIDs, learnerPass);
+ }
+ }
+
+ request.setAttribute("success", true);
+ return mapping.findForward("display");
+ }
+
+ private void notifyOnPasswordChange(Collection userIDs, String password) {
+ MessageService messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ AdminServiceProxy.getEventNotificationService(getServlet().getServletContext()).sendMessage(null,
+ userIDs.toArray(new Integer[] {}), IEventNotificationService.DELIVERY_METHOD_MAIL,
+ messageService.getMessage("admin.org.password.change.email.subject"),
+ messageService.getMessage("admin.org.password.change.email.body", new String[] { password }), false);
+ }
+
+ private Set changePassword(String password, Collection users, ArrayNode includedUsers,
+ ArrayNode excludedUsers, boolean force) {
+ if (!ValidationUtil.isPasswordValueValid(password, password)) {
+ // this should have been picked up by JS validator on the page!
+ throw new InvalidParameterException("Password does not pass validation");
+ }
+ if (includedUsers != null && excludedUsers != null) {
+ throw new IllegalArgumentException("Both included and excluded users arrays must not be passed together");
+ }
+ Set changedUserIDs = new TreeSet();
+ IUserManagementService userManagementService = AdminServiceProxy.getService(getServlet().getServletContext());
+ UserDTO currentUserDTO = getUserDTO();
+ User currentUser = (User) userManagementService.findById(User.class, currentUserDTO.getUserID());
+ for (User user : users) {
+ // either we work with white list or black list
+ if (includedUsers == null) {
+ boolean excluded = false;
+ // skip excluded (unchecked on the page) users
+ for (int index = 0; index < excludedUsers.size(); index++) {
+ Integer excludedUserID = excludedUsers.get(index).asInt();
+ if (user.getUserId().equals(excludedUserID)) {
+ excluded = true;
+ break;
+ }
+ }
+ if (excluded) {
+ continue;
+ }
+ } else {
+ boolean included = false;
+ for (int index = 0; index < includedUsers.size(); index++) {
+ Integer includedUserID = includedUsers.get(index).asInt();
+ if (user.getUserId().equals(includedUserID)) {
+ included = true;
+ break;
+ }
+ }
+ if (!included) {
+ continue;
+ }
+ }
+
+ // change password
+ String salt = HashUtil.salt();
+ user.setSalt(salt);
+ user.setPassword(HashUtil.sha256(password, salt));
+ if (force) {
+ user.setChangePassword(true);
+ }
+ userManagementService.saveUser(user);
+ log.info("Changed password for user ID " + user.getUserId());
+ userManagementService.logPasswordChanged(user, currentUser);
+ changedUserIDs.add(user.getUserId());
+ }
+ return changedUserIDs;
+ }
+
+ /**
+ * Get unsorted users for password change
+ */
+ @SuppressWarnings("unchecked")
+ private List getUsersByRole(Integer organisationID, boolean isStaff) {
+ IUserManagementService userManagementService = AdminServiceProxy.getService(getServlet().getServletContext());
+ Set staff = new HashSet();
+ staff.addAll(userManagementService.getUsersFromOrganisationByRole(organisationID, Role.AUTHOR, true));
+ staff.addAll(userManagementService.getUsersFromOrganisationByRole(organisationID, Role.MONITOR, true));
+
+ Set users = null;
+ if (isStaff) {
+ users = staff;
+ } else {
+ users = new HashSet();
+ users.addAll(userManagementService.getUsersFromOrganisationByRole(organisationID, Role.LEARNER, true));
+ users.removeAll(staff);
+ }
+ return new LinkedList(users);
+ }
+
+ /**
+ * Gets sorted users for grids
+ */
+ private List getUsersByRole(Integer organisationID, boolean isStaff, String sortBy, String sortOrder) {
+ IUserManagementService userManagementService = AdminServiceProxy.getService(getServlet().getServletContext());
+ List staff = userManagementService.getAllUsers(organisationID,
+ new String[] { Role.AUTHOR, Role.MONITOR }, null, null, sortBy, sortOrder, null);
+
+ List users = null;
+ if (isStaff) {
+ users = staff;
+ } else {
+ users = new LinkedList();
+ users.addAll(userManagementService.getAllUsers(organisationID, new String[] { Role.LEARNER }, null, null,
+ sortBy, sortOrder, null));
+ users.removeAll(staff);
+ }
+ return users;
+ }
+
+ private UserDTO getUserDTO() {
+ HttpSession ss = SessionManager.getSession();
+ return (UserDTO) ss.getAttribute(AttributeNames.USER);
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrgSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,274 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang.StringUtils;
+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.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationState;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.SupportedLocale;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.ValidationUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * @version
+ *
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ *
+ * Created at 16:42:53 on 2006-6-7
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+public class OrgSaveAction extends Action {
+
+ private static Logger log = Logger.getLogger(OrgSaveAction.class);
+ private static IUserManagementService service;
+ private MessageService messageService;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (service == null) {
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ }
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+ DynaActionForm orgForm = (DynaActionForm) form;
+ Integer orgId = (Integer) orgForm.get("orgId");
+ Organisation org;
+
+ if (isCancelled(request)) {
+ if (orgId != 0) {
+ request.setAttribute("org", orgId);
+ org = (Organisation) service.findById(Organisation.class, orgId);
+ if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ return mapping.findForward("userlist");
+ }
+ } else {
+ request.setAttribute("org", orgForm.get("parentId"));
+ }
+ return mapping.findForward("orglist");
+ }
+
+ ActionMessages errors = new ActionMessages();
+
+ //organisation name validation
+ String orgName = (orgForm.get("name") == null) ? null : (String) orgForm.get("name");
+ if (StringUtils.isBlank(orgName)) {
+ errors.add("name", new ActionMessage("error.name.required"));
+ } else if (!ValidationUtil.isOrgNameValid(orgName)) {
+ errors.add("name", new ActionMessage("error.name.invalid.characters"));
+ }
+
+ if (errors.isEmpty()) {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ SupportedLocale locale = (SupportedLocale) service.findById(SupportedLocale.class,
+ (Integer) orgForm.get("localeId"));
+ OrganisationState state = (OrganisationState) service.findById(OrganisationState.class,
+ (Integer) orgForm.get("stateId"));
+
+ if (orgId != 0) {
+ if (service.canEditGroup(user.getUserID(), orgId)) {
+ org = (Organisation) service.findById(Organisation.class, orgId);
+ // set archived date only when it first changes to become archived
+ if (state.getOrganisationStateId().equals(OrganisationState.ARCHIVED) && !org.getOrganisationState()
+ .getOrganisationStateId().equals(OrganisationState.ARCHIVED)) {
+ org.setArchivedDate(new Date());
+ }
+ writeAuditLog(user, org, orgForm, state, locale);
+ BeanUtils.copyProperties(org, orgForm);
+ } else {
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+ } else {
+ org = new Organisation();
+ BeanUtils.copyProperties(org, orgForm);
+ org.setParentOrganisation(
+ (Organisation) service.findById(Organisation.class, (Integer) orgForm.get("parentId")));
+ org.setOrganisationType(
+ (OrganisationType) service.findById(OrganisationType.class, (Integer) orgForm.get("typeId")));
+ writeAuditLog(user, org, orgForm, org.getOrganisationState(), org.getLocale());
+ }
+ org.setLocale(locale);
+ org.setOrganisationState(state);
+ if (log.isDebugEnabled()) {
+ log.debug("orgId: " + org.getOrganisationId() + " create date: " + org.getCreateDate());
+ }
+ org = service.saveOrganisation(org, user.getUserID());
+
+ request.setAttribute("org", orgForm.get("parentId"));
+ return mapping.findForward("orglist");
+ } else {
+ saveErrors(request, errors);
+ return mapping.findForward("organisation");
+ }
+ }
+
+ private void writeAuditLog(UserDTO user, Organisation org, DynaActionForm orgForm, OrganisationState newState,
+ SupportedLocale newLocale) {
+
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ ILogEventService logEventService = (ILogEventService) ctx.getBean("logEventService");
+ MessageService messageService = (MessageService) ctx.getBean("adminMessageService");
+
+ String message;
+
+ // audit log entries for organisation attribute changes
+ if ((Integer) orgForm.get("orgId") != 0) {
+ final String key = "audit.organisation.change";
+ String[] args = new String[4];
+ args[1] = org.getName() + "(" + org.getOrganisationId() + ")";
+ if (!org.getOrganisationState().getOrganisationStateId().equals(orgForm.get("stateId"))) {
+ args[0] = "state";
+ args[2] = org.getOrganisationState().getDescription();
+ args[3] = newState.getDescription();
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ if (!StringUtils.equals(org.getName(), (String) orgForm.get("name"))) {
+ args[0] = "name";
+ args[2] = org.getName();
+ args[3] = (String) orgForm.get("name");
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ if (!StringUtils.equals(org.getCode(), (String) orgForm.get("code"))) {
+ args[0] = "code";
+ args[2] = org.getCode();
+ args[3] = (String) orgForm.get("code");
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ if (!StringUtils.equals(org.getDescription(), orgForm.getString("description"))) {
+ args[0] = "description";
+ args[2] = org.getDescription();
+ args[3] = (String) orgForm.get("description");
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ if (!org.getCourseAdminCanAddNewUsers().equals(orgForm.get("courseAdminCanAddNewUsers"))) {
+ args[0] = "courseAdminCanAddNewUsers";
+ args[2] = org.getCourseAdminCanAddNewUsers() ? "true" : "false";
+ args[3] = (Boolean) orgForm.get("courseAdminCanAddNewUsers") ? "true" : "false";
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ if (!org.getCourseAdminCanBrowseAllUsers().equals(orgForm.get("courseAdminCanBrowseAllUsers"))) {
+ args[0] = "courseAdminCanBrowseAllUsers";
+ args[2] = org.getCourseAdminCanBrowseAllUsers() ? "true" : "false";
+ args[3] = (Boolean) orgForm.get("courseAdminCanBrowseAllUsers") ? "true" : "false";
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ if (!org.getCourseAdminCanChangeStatusOfCourse()
+ .equals(orgForm.get("courseAdminCanChangeStatusOfCourse"))) {
+ args[0] = "courseAdminCanChangeStatusOfCourse";
+ args[2] = org.getCourseAdminCanChangeStatusOfCourse() ? "true" : "false";
+ args[3] = (Boolean) orgForm.get("courseAdminCanChangeStatusOfCourse") ? "true" : "false";
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ /*
+ * this field not set yet
+ * if(!org.getCourseAdminCanCreateGuestAccounts().equals((Boolean)orgForm.get(
+ * "courseAdminCanCreateGuestAccounts"))) {
+ * args[0] = "courseAdminCanCreateGuestAccounts";
+ * args[2] = org.getCourseAdminCanCreateGuestAccounts() ? "true" : "false";
+ * args[3] = (Boolean)orgForm.get("courseAdminCanCreateGuestAccounts") ? "true" : "false";
+ * message = messageService.getMessage(key, args);
+ * auditService.log(AdminConstants.MODULE_NAME, message);
+ * }
+ */
+ if (!org.getLocale().getLocaleId().equals(orgForm.get("localeId"))) {
+ args[0] = "locale";
+ args[2] = org.getLocale().getDescription();
+ args[3] = newLocale.getDescription();
+ message = messageService.getMessage(key, args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ } else {
+ String[] args = new String[2];
+ args[0] = org.getName() + "(" + org.getOrganisationId() + ")";
+ args[1] = org.getOrganisationType().getName();
+ message = messageService.getMessage("audit.organisation.create", args);
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, user != null ? user.getUserID() : null,
+ null, null, null, message);
+ }
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrganisationAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrganisationAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/OrganisationAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,236 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.lesson.Lesson;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationState;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.SupportedLocale;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author Fei Yang
+ */
+public class OrganisationAction extends LamsDispatchAction {
+
+ private static IUserManagementService service;
+ private static MessageService messageService;
+ private static List locales;
+ private static List status;
+
+ @SuppressWarnings("unchecked")
+ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ OrganisationAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
+ initLocalesAndStatus();
+ DynaActionForm orgForm = (DynaActionForm) form;
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+
+ HttpSession session = SessionManager.getSession();
+ if (session != null) {
+ UserDTO userDto = (UserDTO) session.getAttribute(AttributeNames.USER);
+ if (userDto != null) {
+ Integer userId = userDto.getUserID();
+ // sysadmin, global group admin, group manager, group admin can edit group
+ if (OrganisationAction.service.canEditGroup(userId, orgId)) {
+ // edit existing organisation
+ if (orgId != null) {
+ Organisation org = (Organisation) OrganisationAction.service.findById(Organisation.class,
+ orgId);
+ BeanUtils.copyProperties(orgForm, org);
+ orgForm.set("parentId", org.getParentOrganisation().getOrganisationId());
+ orgForm.set("parentName", org.getParentOrganisation().getName());
+ orgForm.set("typeId", org.getOrganisationType().getOrganisationTypeId());
+ orgForm.set("stateId", org.getOrganisationState().getOrganisationStateId());
+ SupportedLocale locale = org.getLocale();
+ orgForm.set("localeId", locale != null ? locale.getLocaleId() : null);
+
+ // find a course or subcourse with any lessons, so we warn user when he tries to delete the course
+ Integer courseToDeleteLessons = org.getLessons().size() > 0 ? orgId : null;
+ if (courseToDeleteLessons == null) {
+ for (Organisation subcourse : (Set) org.getChildOrganisations()) {
+ if (subcourse.getLessons().size() > 0) {
+ courseToDeleteLessons = subcourse.getOrganisationId();
+ break;
+ }
+ }
+ }
+ request.setAttribute("courseToDeleteLessons", courseToDeleteLessons);
+ }
+ request.getSession().setAttribute("locales", OrganisationAction.locales);
+ request.getSession().setAttribute("status", OrganisationAction.status);
+ if (OrganisationAction.service.isUserSysAdmin()
+ || OrganisationAction.service.isUserGlobalGroupAdmin()) {
+ return mapping.findForward("organisation");
+ } else {
+ return mapping.findForward("organisationCourseAdmin");
+ }
+ }
+ }
+ }
+
+ return error(mapping, request);
+ }
+
+ public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ OrganisationAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
+ initLocalesAndStatus();
+ DynaActionForm orgForm = (DynaActionForm) form;
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || OrganisationAction.service.isUserGlobalGroupAdmin())) {
+ // only sysadmins and global group admins can create groups
+ if (((orgForm.get("typeId") != null) && orgForm.get("typeId").equals(OrganisationType.COURSE_TYPE))
+ || (orgForm.get("typeId") == null)) {
+ return error(mapping, request);
+ }
+ }
+
+ // creating new organisation
+ orgForm.set("orgId", null);
+ Integer parentId = WebUtil.readIntParam(request, "parentId", true);
+ if (parentId != null) {
+ Organisation parentOrg = (Organisation) OrganisationAction.service.findById(Organisation.class, parentId);
+ orgForm.set("parentName", parentOrg.getName());
+ }
+ request.getSession().setAttribute("locales", OrganisationAction.locales);
+ request.getSession().setAttribute("status", OrganisationAction.status);
+ return mapping.findForward("organisation");
+ }
+
+ /**
+ * Looks up course ID by its name. Used mainly by TestHarness.
+ */
+ @SuppressWarnings("unchecked")
+ public ActionForward getOrganisationIdByName(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ String organisationName = WebUtil.readStrParam(request, "name");
+ OrganisationAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
+ List organisations = service.findByProperty(Organisation.class, "name", organisationName);
+ if (!organisations.isEmpty()) {
+ response.setContentType("text/plain;charset=utf-8");
+ response.getWriter().print(organisations.get(0).getOrganisationId());
+ }
+ return null;
+ }
+
+ public ActionForward deleteAllLessonsInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ if (!AdminServiceProxy.getSecurityService(getServlet().getServletContext()).isSysadmin(getUserID(),
+ "display cleanup preview lessons", false)) {
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a sysadmin");
+ return null;
+ }
+
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ request.setAttribute("errorName", "OrganisationAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.need.sysadmin"));
+ return mapping.findForward("error");
+ }
+
+ Integer organisationId = WebUtil.readIntParam(request, "orgId");
+ Organisation organisation = (Organisation) AdminServiceProxy.getService(getServlet().getServletContext())
+ .findById(Organisation.class, organisationId);
+ int lessonCount = organisation.getLessons().size();
+ request.setAttribute("lessonCount", lessonCount);
+ request.setAttribute("courseName", organisation.getName());
+
+ return mapping.findForward("deleteAllLessons");
+ }
+
+ @SuppressWarnings("unchecked")
+ public ActionForward deleteAllLessons(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ Integer userID = getUserID();
+ Integer limit = WebUtil.readIntParam(request, "limit", true);
+ Integer organisationId = WebUtil.readIntParam(request, "orgId");
+ Organisation organisation = (Organisation) AdminServiceProxy.getService(getServlet().getServletContext())
+ .findById(Organisation.class, organisationId);
+ for (Lesson lesson : (Set) organisation.getLessons()) {
+ log.info("Deleting lesson: " + lesson.getLessonId());
+ // role is checked in this method
+ AdminServiceProxy.getMonitoringService(getServlet().getServletContext())
+ .removeLessonPermanently(lesson.getLessonId(), userID);
+ if (limit != null) {
+ limit--;
+ if (limit == 0) {
+ break;
+ }
+ }
+ }
+
+ organisation = (Organisation) AdminServiceProxy.getService(getServlet().getServletContext())
+ .findById(Organisation.class, organisationId);
+ response.setContentType("application/json;charset=utf-8");
+ response.getWriter().print(organisation.getLessons().size());
+ return null;
+ }
+
+ private ActionForward error(ActionMapping mapping, HttpServletRequest request) {
+ OrganisationAction.messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ request.setAttribute("errorName", "OrganisationAction");
+ request.setAttribute("errorMessage", OrganisationAction.messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ private Integer getUserID() {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ return user == null ? null : user.getUserID();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void initLocalesAndStatus() {
+ if ((OrganisationAction.locales == null)
+ || ((OrganisationAction.status == null) && (OrganisationAction.service != null))) {
+ OrganisationAction.locales = OrganisationAction.service.findAll(SupportedLocale.class);
+ OrganisationAction.status = OrganisationAction.service.findAll(OrganisationState.class);
+ Collections.sort(OrganisationAction.locales);
+ }
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/PortraitBatchUploadAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/PortraitBatchUploadAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/PortraitBatchUploadAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,105 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+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.lamsfoundation.lams.security.ISecurityService;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * Looks for [login].png images in /tmp/portraits of user IDs within given range and starting with the given prefix
+ *
+ * @author Marcin Cieslak
+ */
+public class PortraitBatchUploadAction extends Action {
+ private static IUserManagementService userManagementService;
+ private static ISecurityService securityService;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ if (!getSecurityService().isSysadmin(getUserID(), "batch upload portraits", false)) {
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a sysadmin");
+ return null;
+ }
+
+ Integer minUserId = WebUtil.readIntParam(request, "minUserID");
+ Integer maxUserId = WebUtil.readIntParam(request, "maxUserID");
+ String prefix = request.getParameter("prefix");
+
+ List uploadedUserNames = getUserManagementService().uploadPortraits(minUserId, maxUserId, prefix);
+ if (uploadedUserNames != null) {
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("text/plain");
+ Writer responseWriter = response.getWriter();
+ responseWriter.write("Uploaded portraits for users:\n");
+ for (String userName : uploadedUserNames) {
+ responseWriter.write(userName + "\n");
+ }
+ responseWriter.close();
+ }
+
+ return null;
+ }
+
+ private Integer getUserID() {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ return user == null ? null : user.getUserID();
+ }
+
+ private IUserManagementService getUserManagementService() {
+ if (userManagementService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
+ }
+ return userManagementService;
+ }
+
+ private ISecurityService getSecurityService() {
+ if (securityService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ securityService = (ISecurityService) ctx.getBean("securityService");
+ }
+ return securityService;
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ScheduledJobListAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ScheduledJobListAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ScheduledJobListAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,112 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.ServletException;
+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.lamsfoundation.lams.admin.web.dto.ScheduledJobDTO;
+import org.quartz.JobDetail;
+import org.quartz.JobKey;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.quartz.impl.matchers.GroupMatcher;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ *
+ * @author Steve.Ni
+ * @version $Revision$
+ *
+ *
+ *
+ *
+ */
+public class ScheduledJobListAction extends Action {
+
+ private static final Logger log = Logger.getLogger(ScheduledJobListAction.class);
+
+ /**
+ * Get all waitting queue jobs scheduled in Quartz table and display job name, job start time and description. The
+ * description will be in format "Lesson Name":"the lesson creator", or "The gate name":"The relatived lesson name".
+ *
+ * @param mapping
+ * The ActionMapping used to select this instance
+ * @param actionForm
+ * The optional ActionForm bean for this request (if any)
+ * @param request
+ * The HTTP request we are processing
+ * @param response
+ * The HTTP response we are creating
+ *
+ * @exception IOException
+ * if an input/output error occurs
+ * @exception ServletException
+ * if a servlet exception occurs
+ *
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getWebApplicationContext(this.getServlet().getServletContext());
+ Scheduler scheduler = (Scheduler) ctx.getBean("scheduler");
+ ArrayList jobList = new ArrayList();
+ try {
+ Set jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(Scheduler.DEFAULT_GROUP));
+ for (JobKey jobKey : jobKeys) {
+ ScheduledJobDTO jobDto = new ScheduledJobDTO();
+ JobDetail detail = scheduler.getJobDetail(jobKey);
+ jobDto.setName(jobKey.getName());
+ jobDto.setDescription(detail.getDescription());
+ List triggers = (List) scheduler.getTriggersOfJob(jobKey);
+ for (Trigger trigger : triggers) {
+ jobDto.setStartDate(trigger.getStartTime());
+ jobList.add(jobDto);
+ }
+ }
+ } catch (SchedulerException e) {
+ ScheduledJobListAction.log.equals("Failed get job names:" + e.getMessage());
+ }
+
+ request.setAttribute("jobList", jobList);
+ return mapping.findForward("list");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerListAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerListAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerListAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,55 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.integration.ExtServer;
+
+/**
+ *
+ * @author Fei Yang
+ */
+public class ServerListAction extends Action {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ List extServers = AdminServiceProxy.getIntegrationService(getServlet().getServletContext())
+ .getAllExtServers();
+ Collections.sort(extServers);
+ request.setAttribute("servers", extServers);
+ return mapping.findForward("serverlist");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerMaintainAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerMaintainAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerMaintainAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,88 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.integration.ExtServer;
+import org.lamsfoundation.lams.integration.service.IIntegrationService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+
+/**
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ */
+public class ServerMaintainAction extends LamsDispatchAction {
+
+ @SuppressWarnings("unchecked")
+ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ DynaActionForm extServerForm = (DynaActionForm) form;
+ Integer sid = WebUtil.readIntParam(request, "sid", true);
+ if (sid != null) {
+ ExtServer map = AdminServiceProxy.getIntegrationService(getServlet().getServletContext())
+ .getExtServer(sid);
+ BeanUtils.copyProperties(extServerForm, map);
+ }
+ return mapping.findForward("servermaintain");
+ }
+
+ public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ IIntegrationService service = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
+ Integer sid = WebUtil.readIntParam(request, "sid", false);
+ ExtServer map = service.getExtServer(sid);
+ map.setDisabled(true);
+ service.saveExtServer(map);
+ return mapping.findForward("serverlist");
+ }
+
+ public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ IIntegrationService service = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
+ Integer sid = WebUtil.readIntParam(request, "sid", false);
+ ExtServer map = service.getExtServer(sid);
+ map.setDisabled(false);
+ service.saveExtServer(map);
+ return mapping.findForward("serverlist");
+ }
+
+ public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ Integer sid = WebUtil.readIntParam(request, "sid", false);
+ AdminServiceProxy.getService(getServlet().getServletContext()).deleteById(ExtServer.class, sid);
+ return mapping.findForward("serverlist");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ServerSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,120 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang.StringUtils;
+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.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.integration.ExtServer;
+import org.lamsfoundation.lams.integration.service.IIntegrationService;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+
+/**
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ */
+public class ServerSaveAction extends Action {
+
+ private static IIntegrationService service;
+ private static IUserManagementService userService;
+ private static MessageService messageService;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("success");
+ }
+
+ service = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
+ userService = AdminServiceProxy.getService(getServlet().getServletContext());
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+
+ DynaActionForm extServerForm = (DynaActionForm) form;
+ ActionMessages errors = new ActionMessages();
+ String[] requiredFields = { "serverid", "serverkey", "servername", "prefix", "userinfoUrl" };
+ for (String requiredField : requiredFields) {
+ if (StringUtils.trimToNull(extServerForm.getString(requiredField)) == null) {
+ errors.add(requiredField,
+ new ActionMessage("error.required", messageService.getMessage("sysadmin." + requiredField)));
+ }
+ }
+
+ Integer sid = (Integer) extServerForm.get("sid");
+ if (errors.isEmpty()) {//check duplication
+ String[] uniqueFields = { "serverid", "prefix" };
+ for (String uniqueField : uniqueFields) {
+ List list = userService.findByProperty(ExtServer.class, uniqueField,
+ extServerForm.get(uniqueField));
+ if (list != null && list.size() > 0) {
+ if (sid.equals(-1)) {//new map
+ errors.add(uniqueField, new ActionMessage("error.not.unique",
+ messageService.getMessage("sysadmin." + uniqueField)));
+ } else {
+ ExtServer map = (ExtServer) list.get(0);
+ if (!map.getSid().equals(sid)) {
+ errors.add(uniqueField, new ActionMessage("error.not.unique",
+ messageService.getMessage("sysadmin." + uniqueField)));
+ }
+ }
+
+ }
+ }
+ }
+ if (errors.isEmpty()) {
+ ExtServer map = null;
+ if (sid.equals(-1)) {
+ map = new ExtServer();
+ BeanUtils.copyProperties(map, extServerForm);
+ map.setSid(null);
+ map.setServerTypeId(ExtServer.INTEGRATION_SERVER_TYPE);
+ } else {
+ map = service.getExtServer(sid);
+ BeanUtils.copyProperties(map, extServerForm);
+ }
+ service.saveExtServer(map);
+ return mapping.findForward("success");
+ } else {
+ saveErrors(request, errors);
+ return mapping.getInputForward();
+ }
+ }
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SessionMaintainAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SessionMaintainAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SessionMaintainAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,54 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+
+/**
+ * @author Marcin Cieslak
+ */
+public class SessionMaintainAction extends LamsDispatchAction {
+
+ public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ request.setAttribute("sessions", SessionManager.getLoginToSessionIDMappings());
+ return mapping.findForward("sessionmaintain");
+ }
+
+ public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ String login = request.getParameter("login");
+ if (StringUtils.isNotBlank(login)) {
+ SessionManager.removeSessionByLogin(login, true);
+ }
+ return list(mapping, form, request, response);
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SignupManagementAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SignupManagementAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SignupManagementAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,179 @@
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+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.signup.model.SignupOrganisation;
+import org.lamsfoundation.lams.signup.service.ISignupService;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class SignupManagementAction extends Action {
+
+ private static Logger log = Logger.getLogger(SignupManagementAction.class);
+ private static ISignupService signupService = null;
+ private static IUserManagementService userManagementService = null;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+
+ try {
+ if (signupService == null) {
+ WebApplicationContext wac = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ signupService = (ISignupService) wac.getBean("signupService");
+ }
+ if (userManagementService == null) {
+ WebApplicationContext wac = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ userManagementService = (IUserManagementService) wac.getBean("userManagementService");
+ }
+
+ String method = WebUtil.readStrParam(request, "method", true);
+
+ if (StringUtils.equals(method, "list") || isCancelled(request)) {
+ // do nothing
+ } else if (StringUtils.equals(method, "edit")) {
+ return edit(mapping, form, request, response);
+ } else if (StringUtils.equals(method, "add")) {
+ return add(mapping, form, request, response);
+ } else if (StringUtils.equals(method, "delete")) {
+ return delete(mapping, form, request, response);
+ }
+
+ List signupOrganisations = signupService.getSignupOrganisations();
+ request.setAttribute("signupOrganisations", signupOrganisations);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ request.setAttribute("error", e.getMessage());
+ }
+
+ return mapping.findForward("signupPageList");
+ }
+
+ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ Integer soid = WebUtil.readIntParam(request, "soid", false);
+
+ if (soid != null && soid > 0) {
+ SignupOrganisation signup = (SignupOrganisation) userManagementService.findById(SignupOrganisation.class,
+ soid);
+ if (signup != null) {
+ DynaActionForm signupForm = (DynaActionForm) form;
+ signupForm.set("signupOrganisationId", signup.getSignupOrganisationId());
+ signupForm.set("organisationId", signup.getOrganisation().getOrganisationId());
+ signupForm.set("addToLessons", signup.getAddToLessons());
+ signupForm.set("addAsStaff", signup.getAddAsStaff());
+ signupForm.set("addWithAuthor", signup.getAddWithAuthor());
+ signupForm.set("addWithMonitor", signup.getAddWithMonitor());
+ signupForm.set("courseKey", signup.getCourseKey());
+ signupForm.set("blurb", signup.getBlurb());
+ signupForm.set("disabled", signup.getDisabled());
+ signupForm.set("loginTabActive", signup.getLoginTabActive());
+ signupForm.set("context", signup.getContext());
+ request.setAttribute("signupForm", signupForm);
+
+ List organisations = signupService.getOrganisationCandidates();
+ request.setAttribute("organisations", organisations);
+
+ return mapping.findForward("addSignupPage");
+ }
+ }
+ return null;
+ }
+
+ public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ DynaActionForm signupForm = (DynaActionForm) form;
+
+ // check if form submitted
+ if (signupForm.get("organisationId") != null && (Integer) signupForm.get("organisationId") > 0) {
+ ActionMessages errors = new ActionMessages();
+
+ // validate
+ if (!StringUtils.equals(signupForm.getString("courseKey"), signupForm.getString("confirmCourseKey"))) {
+ errors.add("courseKey", new ActionMessage("error.course.keys.unequal"));
+ }
+ if (signupService.contextExists((Integer) signupForm.get("signupOrganisationId"),
+ signupForm.getString("context"))) {
+ errors.add("context", new ActionMessage("error.context.exists"));
+ }
+
+ if (!errors.isEmpty()) {
+ saveErrors(request, errors);
+ } else {
+ // proceed
+ SignupOrganisation signup;
+ if (signupForm.get("signupOrganisationId") != null
+ && (Integer) signupForm.get("signupOrganisationId") > 0) {
+ // form was editing existing
+ signup = (SignupOrganisation) userManagementService.findById(SignupOrganisation.class,
+ (Integer) signupForm.get("signupOrganisationId"));
+ } else {
+ signup = new SignupOrganisation();
+ signup.setCreateDate(new Date());
+ }
+ signup.setAddToLessons((Boolean) signupForm.get("addToLessons"));
+ signup.setAddAsStaff((Boolean) signupForm.get("addAsStaff"));
+ signup.setAddWithAuthor((Boolean) signupForm.get("addWithAuthor"));
+ signup.setAddWithMonitor((Boolean) signupForm.get("addWithMonitor"));
+ signup.setDisabled((Boolean) signupForm.get("disabled"));
+ signup.setLoginTabActive((Boolean) signupForm.get("loginTabActive"));
+ signup.setOrganisation((Organisation) userManagementService.findById(Organisation.class,
+ (Integer) signupForm.get("organisationId")));
+ signup.setCourseKey(signupForm.getString("courseKey"));
+ signup.setBlurb(signupForm.getString("blurb"));
+ signup.setContext(signupForm.getString("context"));
+ userManagementService.save(signup);
+
+ return mapping.findForward("signupPageListMethod");
+ }
+ } else {
+ // form not submitted, default values
+ signupForm.set("blurb", "Register your LAMS account for this group using the form below.");
+ }
+
+ List organisations = signupService.getOrganisationCandidates();
+ request.setAttribute("organisations", organisations);
+
+ return mapping.findForward("addSignupPage");
+ }
+
+ public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ Integer soid = WebUtil.readIntParam(request, "soid");
+
+ if (soid != null && soid > 0) {
+ userManagementService.deleteById(SignupOrganisation.class, soid);
+ }
+
+ return mapping.findForward("signupPageListMethod");
+ }
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/StatisticsAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/StatisticsAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/StatisticsAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,98 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.statistics.dto.GroupStatisticsDTO;
+import org.lamsfoundation.lams.statistics.dto.StatisticsDTO;
+import org.lamsfoundation.lams.statistics.service.IStatisticsService;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+
+/**
+ * Gives the overall statistics for a LAMS server
+ *
+ * @author Luke Foxton
+ */
+public class StatisticsAction extends LamsDispatchAction {
+
+ private static IStatisticsService statisticsService;
+
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // check permission
+ if (!request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("errorName", "StatisticsAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ if (statisticsService == null) {
+ statisticsService = AdminServiceProxy.getStatisticsService(getServlet().getServletContext());
+ }
+
+ StatisticsDTO stats = statisticsService.getOverallStatistics();
+
+ Map groupMap = statisticsService.getGroupMap();
+
+ request.setAttribute("statisticsDTO", stats);
+ request.setAttribute("groupMap", groupMap);
+ return mapping.findForward("success");
+ }
+
+ public ActionForward groupStats(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ Integer orgId = WebUtil.readIntParam(request, "orgId");
+
+ // check permission
+ if (!request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("errorName", "StatisticsAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ if (statisticsService == null) {
+ statisticsService = AdminServiceProxy.getStatisticsService(getServlet().getServletContext());
+ }
+
+ GroupStatisticsDTO groupStats = statisticsService.getGroupStatisticsDTO(orgId);
+
+ request.setAttribute("groupStatisticsDTO", groupStats);
+ return mapping.findForward("groupStats");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SysAdminStartAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SysAdminStartAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/SysAdminStartAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,104 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.lamsfoundation.lams.admin.AdminConstants;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.dto.LinkBean;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+
+/**
+ * @author jliew
+ *
+ */
+public class SysAdminStartAction extends Action {
+
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+
+ ArrayList groupedLinks = new ArrayList();
+
+ if (request.isUserInRole(Role.SYSADMIN)) {
+ ArrayList links = new ArrayList();
+ links.add(new LinkBean("config.do", "sysadmin.config.settings.edit"));
+ links.add(new LinkBean("timezonemanagement.do", "admin.timezone.title"));
+ links.add(new LinkBean("loginmaintain.do", "sysadmin.maintain.loginpage"));
+ links.add(new LinkBean("signupManagement.do", "admin.signup.title"));
+ links.add(new LinkBean("serverlist.do", "sysadmin.maintain.external.servers"));
+ links.add(new LinkBean("ltiConsumerManagement.do", "label.manage.tool.consumers"));
+ links.add(new LinkBean("toolcontentlist.do", "sysadmin.tool.management"));
+ links.add(new LinkBean("themeManagement.do", "admin.themes.title"));
+ links.add(new LinkBean("sessionmaintain.do?method=list", "sysadmin.maintain.session"));
+ groupedLinks.add(new Object[]{AdminConstants.START_CONFIG_LINKS,links});
+
+ links = new ArrayList();
+ links.add(new LinkBean("logevent.do", "label.event.log"));
+ links.add(new LinkBean("cleanup.do", "sysadmin.batch.temp.file.delete"));
+ links.add(new LinkBean("cleanupPreviewLessons.do", "sysadmin.batch.preview.lesson.delete"));
+ links.add(new LinkBean("statistics.do", "admin.statistics.title"));
+ groupedLinks.add(new Object[]{AdminConstants.START_MONITOR_LINKS,links});
+
+ links = new ArrayList();
+ links.add(new LinkBean("usersearch.do", "admin.user.find"));
+ links.add(new LinkBean("importgroups.do", "sysadmin.import.groups.title"));
+ links.add(new LinkBean("importexcel.do", "admin.user.import"));
+ links.add(new LinkBean("disabledmanage.do", "admin.list.disabled.users"));
+ links.add(new LinkBean("ldap.do", "sysadmin.ldap.configuration"));
+ groupedLinks.add(new Object[]{AdminConstants.START_COURSE_LINKS,links});
+
+ } else if (service.isUserGlobalGroupAdmin()) {
+ ArrayList links = new ArrayList();
+ links.add(new LinkBean("usersearch.do", "admin.user.find"));
+ links.add(new LinkBean("importgroups.do", "sysadmin.import.groups.title"));
+ links.add(new LinkBean("importexcel.do", "admin.user.import"));
+ links.add(new LinkBean("disabledmanage.do", "admin.list.disabled.users"));
+ groupedLinks.add(new Object[]{AdminConstants.START_COURSE_LINKS,links});
+
+ } else {
+ request.setAttribute("errorName", "SysAdminStartAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ request.setAttribute("groupedLinks", groupedLinks);
+ return mapping.findForward("sysadmin");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ThemeManagementAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ThemeManagementAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ThemeManagementAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,162 @@
+/****************************************************************
+ * Copyright (C) 2006 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.form.ThemeForm;
+import org.lamsfoundation.lams.themes.Theme;
+import org.lamsfoundation.lams.themes.service.IThemeService;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.util.CSSThemeUtil;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.ConfigurationKeys;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * Actions for maintaining and altering system themes
+ *
+ * @author Luke Foxton
+ */
+public class ThemeManagementAction extends LamsDispatchAction {
+
+ private static IThemeService themeService;
+ private static Configuration configurationService;
+
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // check permission
+ if (!request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("errorName", "ThemeManagementAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ if (ThemeManagementAction.themeService == null) {
+ ThemeManagementAction.themeService = AdminServiceProxy.getThemeService(getServlet().getServletContext());
+ }
+
+ // Get all the themes
+ List themes = ThemeManagementAction.themeService.getAllThemes();
+
+ // Flag the default and un-editable themes
+ String currentCSSTheme = Configuration.get(ConfigurationKeys.DEFAULT_THEME);
+ for (Theme theme : themes) {
+ theme.setCurrentDefaultTheme(theme.getName().equals(currentCSSTheme));
+ theme.setNotEditable(theme.getName().equals(CSSThemeUtil.DEFAULT_HTML_THEME));
+ }
+
+ request.setAttribute("themes", themes);
+ return mapping.findForward("success");
+ }
+
+ public ActionForward addOrEditTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ ThemeForm themeForm = (ThemeForm) form;
+
+ // Update the theme
+ Theme theme = null;
+ if ((themeForm.getId() != null) && (themeForm.getId() != 0)) {
+ theme = ThemeManagementAction.themeService.getTheme(themeForm.getId());
+ } else {
+ theme = new Theme();
+ }
+ updateThemeFromForm(theme, themeForm);
+ ThemeManagementAction.themeService.saveOrUpdateTheme(theme);
+
+ // Set the theme as default, or disable it as default.
+ // Disabling restores the system default
+ if ((themeForm.getCurrentDefaultTheme() != null) && (themeForm.getCurrentDefaultTheme() == true)) {
+ Configuration.updateItem(ConfigurationKeys.DEFAULT_THEME, themeForm.getName());
+ getConfiguration().persistUpdate();
+ } else {
+ String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_THEME);
+ if (themeForm.getName().equals(currentTheme)) {
+ Configuration.updateItem(ConfigurationKeys.DEFAULT_THEME, CSSThemeUtil.DEFAULT_HTML_THEME);
+ getConfiguration().persistUpdate();
+ }
+ }
+ themeForm.clear();
+ return unspecified(mapping, themeForm, request, response);
+ }
+
+ public ActionForward removeTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // Remove the theme
+ ThemeForm themeForm = (ThemeForm) form;
+ if (themeForm.getId() != null) {
+ ThemeManagementAction.themeService.removeTheme(themeForm.getId());
+ }
+
+ String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_THEME);
+ if (themeForm.getName().equals(currentTheme)) {
+ Configuration.updateItem(ConfigurationKeys.DEFAULT_THEME, CSSThemeUtil.DEFAULT_HTML_THEME);
+ getConfiguration().persistUpdate();
+ }
+
+ themeForm.clear();
+ return unspecified(mapping, themeForm, request, response);
+ }
+
+ public ActionForward setAsDefault(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ ThemeForm themeForm = (ThemeForm) form;
+ if (themeForm.getName() != null) {
+ Configuration.updateItem(ConfigurationKeys.DEFAULT_THEME, themeForm.getName());
+ getConfiguration().persistUpdate();
+ }
+ themeForm.clear();
+ return unspecified(mapping, themeForm, request, response);
+ }
+
+ private Theme updateThemeFromForm(Theme theme, ThemeForm form) {
+ theme.setName(form.getName());
+ theme.setDescription(form.getDescription());
+ theme.setImageDirectory(form.getImageDirectory());
+ // theme.setType(Integer.parseInt(form.getType())); no longer in form see LDEV-3674
+ return theme;
+ }
+
+ private Configuration getConfiguration() {
+ if (ThemeManagementAction.configurationService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ ThemeManagementAction.configurationService = (Configuration) ctx.getBean("configurationService");
+
+ }
+ return ThemeManagementAction.configurationService;
+ }
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/TimezoneManagementAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/TimezoneManagementAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/TimezoneManagementAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,164 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.TimeZone;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.timezone.Timezone;
+import org.lamsfoundation.lams.timezone.dto.TimezoneDTO;
+import org.lamsfoundation.lams.timezone.service.ITimezoneService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+
+/**
+ * Implements time zone manager.
+ *
+ * @author Andrey Balan
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class TimezoneManagementAction extends LamsDispatchAction {
+
+ private final static String FORWARD_BACK = "sysadmin";
+ private final static String FORWARD_TIMEZONE_MANAGEMENT = "timezoneManagement";
+ private final static String FORWARD_SERVER_TIMEZONE_MANAGEMENT = "timezoneServerManagement";
+
+ private static ITimezoneService timezoneService;
+
+ /**
+ * Displays list of all JRE available timezones.
+ */
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
+ List defaultTimezones = timezoneService.getDefaultTimezones();
+
+ ArrayList timezoneDtos = new ArrayList();
+ for (String availableTimezoneId : TimeZone.getAvailableIDs()) {
+ boolean isSelected = defaultTimezones.contains(new Timezone(availableTimezoneId));
+ TimeZone timeZone = TimeZone.getTimeZone(availableTimezoneId);
+ TimezoneDTO timezoneDto = TimezoneDTO.createTimezoneDTO(timeZone, isSelected);
+ timezoneDtos.add(timezoneDto);
+ }
+
+ request.setAttribute("timezoneDtos", timezoneDtos);
+ request.setAttribute("serverTimezone", timezoneService.getServerTimezone().getTimezoneId());
+
+ return mapping.findForward(FORWARD_TIMEZONE_MANAGEMENT);
+ }
+
+ /**
+ * Makes selected timezones default ones.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws Exception
+ */
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward(FORWARD_BACK);
+ }
+
+ DynaActionForm timezoneForm = (DynaActionForm) form;
+ String[] selectedTimezoneIds = (String[]) timezoneForm.get("selected");
+
+ List selectedTimezones = new ArrayList();
+ for (String selectedTimezoneId : selectedTimezoneIds) {
+ selectedTimezones.add(new Timezone(selectedTimezoneId));
+ }
+ timezoneService.updateTimezones(selectedTimezones);
+
+ return mapping.findForward(FORWARD_BACK);
+ }
+
+ /**
+ * Shows page where admin can choose server timezone.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws Exception
+ */
+ public ActionForward serverTimezoneManagement(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
+
+ ArrayList timezoneDtos = new ArrayList();
+ for (String availableTimezoneId : TimeZone.getAvailableIDs()) {
+ TimeZone timeZone = TimeZone.getTimeZone(availableTimezoneId);
+ TimezoneDTO timezoneDto = TimezoneDTO.createTimezoneDTO(timeZone, false);
+ timezoneDtos.add(timezoneDto);
+ }
+
+ request.setAttribute("timezoneDtos", timezoneDtos);
+ request.setAttribute("serverTimezone", timezoneService.getServerTimezone().getTimezoneId());
+
+ return mapping.findForward(FORWARD_SERVER_TIMEZONE_MANAGEMENT);
+ }
+
+ /**
+ * Changes server timezone with the one selected by user.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws Exception
+ */
+ public ActionForward changeServerTimezone(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
+
+ String timeZoneId = WebUtil.readStrParam(request, "timeZoneId");
+ timezoneService.setServerTimezone(timeZoneId);
+
+ return unspecified(mapping, form, request, response);
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ToolContentListAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ToolContentListAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ToolContentListAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,328 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.sql.DataSource;
+
+import org.apache.commons.lang.StringUtils;
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.learningdesign.LearningLibrary;
+import org.lamsfoundation.lams.learningdesign.LearningLibraryGroup;
+import org.lamsfoundation.lams.learningdesign.dto.LearningLibraryDTO;
+import org.lamsfoundation.lams.learningdesign.dto.LibraryActivityDTO;
+import org.lamsfoundation.lams.learningdesign.service.ILearningDesignService;
+import org.lamsfoundation.lams.tool.Tool;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.JsonUtil;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class ToolContentListAction extends Action {
+
+ private static final String PARAM_ACTION = "action";
+ private static final String PARAM_LIBRARY_ID = "libraryID";
+
+ private static final String ATTRIBUTE_ERROR_NAME = "errorName";
+ private static final String ATTRIBUTE_ERROR_MESSAGE = "errorMessage";
+ private static final String ATTRIBUTE_LIBRARY = "toolLibrary";
+ private static final String ATTRIBUTE_VALIDITY = "learningLibraryValidity";
+ private static final String ATTRIBUTE_TOOL_VERSIONS = "toolVersions";
+ private static final String ATTRIBUTE_DATABASE_VERSIONS = "dbVersions";
+
+ private static final String FORWARD_SUCCESS = "toolcontentlist";
+ private static final String FORWARD_GROUPS = "groups";
+ private static final String FORWARD_ERROR = "error";
+
+ private static final String ACTION_ENABLE = "enable";
+ private static final String ACTION_DISABLE = "disable";
+ private static final String ACTION_OPEN_GROUPS = "openLearningLibraryGroups";
+ private static final String ACTION_SAVE_GROUPS = "saveLearningLibraryGroups";
+
+ private static final String QUERY_DATABASE_VERSIONS = "select system_name, patch_level from patches";
+
+ private static ILearningDesignService learningDesignService;
+ private static IUserManagementService userManagementService;
+ private static DataSource dataSource;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // check permission
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_NAME, "ToolContentListAction");
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_MESSAGE, AdminServiceProxy
+ .getMessageService(getServlet().getServletContext()).getMessage("error.authorisation"));
+ return mapping.findForward(ToolContentListAction.FORWARD_ERROR);
+ }
+
+ // not just display, but enable/disable a learning library
+ String param = request.getParameter(ToolContentListAction.PARAM_ACTION);
+ if (StringUtils.equals(param, ToolContentListAction.ACTION_ENABLE)) {
+ if (checkPriviledge(request)) {
+ enableLibrary(mapping, form, request, response);
+ } else {
+ return mapping.findForward(ToolContentListAction.FORWARD_ERROR);
+ }
+ } else if (StringUtils.equals(param, ToolContentListAction.ACTION_DISABLE)) {
+ if (checkPriviledge(request)) {
+ disableLibrary(mapping, form, request, response);
+ } else {
+ return mapping.findForward(ToolContentListAction.FORWARD_ERROR);
+ }
+ } else if (StringUtils.equals(param, ToolContentListAction.ACTION_OPEN_GROUPS)) {
+ return openLearningLibraryGroups(mapping, form, request, response);
+ } else if (StringUtils.equals(param, ToolContentListAction.ACTION_SAVE_GROUPS)) {
+ saveLearningLibraryGroups(mapping, form, request, response);
+ return null;
+ }
+
+ // get learning library dtos and their validity
+ List learningLibraryDTOs = getLearningDesignService().getAllLearningLibraryDetails(false,
+ getUserLanguage());
+ // this is filled when executing following method, for efficiency purposes
+ HashMap learningLibraryValidity = new HashMap(learningLibraryDTOs.size());
+ ArrayList toolLibrary = filterMultipleToolEntries(learningLibraryDTOs,
+ learningLibraryValidity);
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_LIBRARY, toolLibrary);
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_VALIDITY, learningLibraryValidity);
+
+ // get tool versions
+ HashMap toolVersions = new HashMap();
+ List tools = getUserManagementService().findAll(Tool.class);
+ for (Tool tool : tools) {
+ toolVersions.put(tool.getToolId(), tool.getToolVersion());
+ }
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_TOOL_VERSIONS, toolVersions);
+
+ // get tool database versions
+ HashMap dbVersions = new HashMap();
+ Connection conn = getDataSource().getConnection();
+ PreparedStatement query = conn.prepareStatement(ToolContentListAction.QUERY_DATABASE_VERSIONS);
+ ResultSet results = query.executeQuery();
+ while (results.next()) {
+ dbVersions.put(results.getString("system_name"), results.getInt("patch_level"));
+ }
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_DATABASE_VERSIONS, dbVersions);
+
+ return mapping.findForward(ToolContentListAction.FORWARD_SUCCESS);
+ }
+
+ // returns full list of learning libraries, valid or not
+ @SuppressWarnings("unchecked")
+ private ArrayList filterMultipleToolEntries(List learningLibraryDTOs,
+ HashMap learningLibraryValidity) {
+ ArrayList activeTools = new ArrayList();
+ ArrayList activeCombinedTools = new ArrayList();
+ for (LearningLibraryDTO learningLibraryDTO : learningLibraryDTOs) {
+ // populate information about learning libary validity
+ learningLibraryValidity.put(learningLibraryDTO.getLearningLibraryID(), learningLibraryDTO.getValidFlag());
+ for (LibraryActivityDTO template : (List) learningLibraryDTO.getTemplateActivities()) {
+ // no learning library ID = a part of combined learning library, we already have it in the list
+ if (template.getLearningLibraryID() != null) {
+ // combined libraries do not have tool content ID set
+ if (template.getToolContentID() == null) {
+ if (!toolExists(template, activeCombinedTools)) {
+ activeCombinedTools.add(template);
+ }
+ } else {
+ if (!toolExists(template, activeTools)) {
+ activeTools.add(template);
+ }
+ }
+ }
+ }
+ }
+ // put combined libraries at the end, purely for easy of use
+ activeTools.addAll(activeCombinedTools);
+ return activeTools;
+ }
+
+ private boolean toolExists(LibraryActivityDTO newItem, ArrayList list) {
+ for (LibraryActivityDTO libraryActivityDTO : list) {
+ if (newItem.getLearningLibraryID().equals(libraryActivityDTO.getLearningLibraryID())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private String getUserLanguage() {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ return user == null ? "" : user.getLocaleLanguage();
+ }
+
+ private boolean checkPriviledge(HttpServletRequest request) {
+ if (!getUserManagementService().isUserSysAdmin()) {
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_NAME, "ToolContentListAction");
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_MESSAGE, AdminServiceProxy
+ .getMessageService(getServlet().getServletContext()).getMessage("error.no.sysadmin.priviledge"));
+ return false;
+ }
+ return true;
+ }
+
+ private void disableLibrary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ Long learningLibraryId = WebUtil.readLongParam(request, ToolContentListAction.PARAM_LIBRARY_ID, false);
+ ILearningDesignService ldService = getLearningDesignService();
+ ldService.setValid(learningLibraryId, false);
+ }
+
+ private void enableLibrary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ Long learningLibraryId = WebUtil.readLongParam(request, ToolContentListAction.PARAM_LIBRARY_ID, false);
+ ILearningDesignService ldService = getLearningDesignService();
+ ldService.setValid(learningLibraryId, true);
+
+ }
+
+ /**
+ * Loads groups and libraries and displays the management dialog.
+ */
+ private ActionForward openLearningLibraryGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ // build full list of available learning libraries
+ List learningLibraries = getLearningDesignService()
+ .getAllLearningLibraryDetails(getUserLanguage());
+ ArrayNode learningLibrariesJSON = JsonNodeFactory.instance.arrayNode();
+ for (LearningLibraryDTO learningLibrary : learningLibraries) {
+ ObjectNode learningLibraryJSON = JsonNodeFactory.instance.objectNode();
+ learningLibraryJSON.put("learningLibraryId", learningLibrary.getLearningLibraryID());
+ learningLibraryJSON.put("title", learningLibrary.getTitle());
+ learningLibrariesJSON.add(learningLibraryJSON);
+ }
+ request.setAttribute("learningLibraries", learningLibrariesJSON.toString());
+
+ // build list of existing groups
+ List groups = getLearningDesignService().getLearningLibraryGroups();
+ ArrayNode groupsJSON = JsonNodeFactory.instance.arrayNode();
+ for (LearningLibraryGroup group : groups) {
+ ObjectNode groupJSON = JsonNodeFactory.instance.objectNode();
+ groupJSON.put("groupId", group.getGroupId());
+ groupJSON.put("name", group.getName());
+ for (LearningLibrary learningLibrary : group.getLearningLibraries()) {
+ ObjectNode learningLibraryJSON = JsonNodeFactory.instance.objectNode();
+ learningLibraryJSON.put("learningLibraryId", learningLibrary.getLearningLibraryId());
+ learningLibraryJSON.put("title", learningLibrary.getTitle());
+ groupJSON.withArray("learningLibraries").add(learningLibraryJSON);
+ }
+ groupsJSON.add(groupJSON);
+ }
+ request.setAttribute("groups", groupsJSON.toString());
+
+ return mapping.findForward(ToolContentListAction.FORWARD_GROUPS);
+ }
+
+ private void saveLearningLibraryGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ // extract groups from JSON and persist them
+
+ ArrayNode groupsJSON = JsonUtil.readArray(request.getParameter("groups"));
+ List groups = new ArrayList<>(groupsJSON.size());
+ for (JsonNode groupJSON : groupsJSON) {
+ LearningLibraryGroup group = new LearningLibraryGroup();
+ groups.add(group);
+
+ long groupId = groupJSON.get("groupId").asLong();
+ if (groupId > 0) {
+ group.setGroupId(groupId);
+ }
+ group.setName(groupJSON.get("name").asText(null));
+
+ group.setLearningLibraries(new HashSet());
+ ArrayNode learningLibrariesJSON = (ArrayNode) groupJSON.get("learningLibraries");
+ for (JsonNode learningLibraryJSON : learningLibrariesJSON) {
+ long learningLibraryId = learningLibraryJSON.asLong();
+ LearningLibrary learningLibrary = getLearningDesignService().getLearningLibrary(learningLibraryId);
+ group.getLearningLibraries().add(learningLibrary);
+ }
+ }
+
+ getLearningDesignService().saveLearningLibraryGroups(groups);
+ }
+
+ private ILearningDesignService getLearningDesignService() {
+ if (ToolContentListAction.learningDesignService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ ToolContentListAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
+ }
+ return ToolContentListAction.learningDesignService;
+ }
+
+ private IUserManagementService getUserManagementService() {
+ if (ToolContentListAction.userManagementService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ ToolContentListAction.userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
+ }
+ return ToolContentListAction.userManagementService;
+ }
+
+ private DataSource getDataSource() {
+ if (ToolContentListAction.dataSource == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ ToolContentListAction.dataSource = (DataSource) ctx.getBean("dataSource");
+ }
+ return ToolContentListAction.dataSource;
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,397 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.TimeZone;
+import java.util.TreeSet;
+
+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.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.dto.UserOrgRoleDTO;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
+import org.lamsfoundation.lams.themes.Theme;
+import org.lamsfoundation.lams.themes.service.IThemeService;
+import org.lamsfoundation.lams.timezone.Timezone;
+import org.lamsfoundation.lams.timezone.dto.TimezoneDTO;
+import org.lamsfoundation.lams.timezone.service.ITimezoneService;
+import org.lamsfoundation.lams.timezone.util.TimezoneDTOComparator;
+import org.lamsfoundation.lams.usermanagement.AuthenticationMethod;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationState;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.SupportedLocale;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.UserOrganisation;
+import org.lamsfoundation.lams.usermanagement.UserOrganisationRole;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.LanguageUtil;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author Jun-Dir Liew
+ */
+public class UserAction extends LamsDispatchAction {
+
+ private static Logger log = Logger.getLogger(UserAction.class);
+ private IUserManagementService service;
+ private MessageService messageService;
+ private static IThemeService themeService;
+ private static ITimezoneService timezoneService;
+ private static List locales;
+ private static List authenticationMethods;
+
+ private void initServices() {
+ if (service == null) {
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ }
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+ if (UserAction.themeService == null) {
+ UserAction.themeService = AdminServiceProxy.getThemeService(getServlet().getServletContext());
+ }
+ if (UserAction.timezoneService == null) {
+ UserAction.timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+ if (UserAction.locales == null) {
+ UserAction.locales = service.findAll(SupportedLocale.class);
+ Collections.sort(UserAction.locales);
+ }
+ if (UserAction.authenticationMethods == null) {
+ UserAction.authenticationMethods = service.findAll(AuthenticationMethod.class);
+ }
+
+ DynaActionForm userForm = (DynaActionForm) form;
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ Integer userId = WebUtil.readIntParam(request, "userId", true);
+
+ // Get all the css themess
+ List themes = UserAction.themeService.getAllThemes();
+ request.setAttribute("themes", themes);
+
+ // Select the default themes by default
+ Theme defaultTheme = UserAction.themeService.getDefaultTheme();
+ for (Theme theme : themes) {
+ if (theme.getThemeId().equals(defaultTheme.getThemeId())) {
+ userForm.set("userTheme", theme.getThemeId());
+ break;
+ }
+ }
+
+ // test requestor's permission
+ Organisation org = null;
+ Boolean canEdit = service.isUserGlobalGroupAdmin();
+ if (orgId != null) {
+ org = (Organisation) service.findById(Organisation.class, orgId);
+ if (!canEdit) {
+ OrganisationType orgType = org.getOrganisationType();
+ Integer orgIdOfCourse = orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)
+ ? org.getParentOrganisation().getOrganisationId()
+ : orgId;
+ User requestor = service.getUserByLogin(request.getRemoteUser());
+ if (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN)
+ || service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)) {
+ Organisation course = (Organisation) service.findById(Organisation.class, orgIdOfCourse);
+ canEdit = course.getCourseAdminCanAddNewUsers();
+ }
+ }
+ }
+
+ if (!(canEdit || request.isUserInRole(Role.SYSADMIN))) {
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ // editing a user
+ if ((userId != null) && (userId != 0)) {
+ User user = (User) service.findById(User.class, userId);
+ UserAction.log.debug("got userid to edit: " + userId);
+ BeanUtils.copyProperties(userForm, user);
+ userForm.set("password", null);
+ SupportedLocale locale = user.getLocale();
+ userForm.set("localeId", locale.getLocaleId());
+
+ AuthenticationMethod authenticationMethod = user.getAuthenticationMethod();
+ userForm.set("authenticationMethodId", authenticationMethod.getAuthenticationMethodId());
+ // set user's organisations to display
+ request.setAttribute("userOrgRoles", getUserOrgRoles(user));
+ request.setAttribute("globalRoles", getGlobalRoles(user));
+
+ // Check the user css theme is still installed
+ Long userSelectedTheme = null;
+ if (user.getTheme() != null) {
+ for (Theme theme : themes) {
+ if (theme.getThemeId() == user.getTheme().getThemeId()) {
+ userSelectedTheme = theme.getThemeId();
+ break;
+ }
+ }
+ }
+ // if still null, use the default
+ if (userSelectedTheme == null) {
+ userSelectedTheme = UserAction.themeService.getDefaultTheme().getThemeId();
+ }
+ userForm.set("userTheme", userSelectedTheme);
+ userForm.set("initialPortraitId", user.getPortraitUuid());
+
+ //property available for modification only to sysadmins
+ userForm.set("twoFactorAuthenticationEnabled", user.isTwoFactorAuthenticationEnabled());
+ } else { // create a user
+ try {
+ SupportedLocale locale = LanguageUtil.getDefaultLocale();
+ userForm.set("localeId", locale.getLocaleId());
+ } catch (Exception e) {
+ UserAction.log.debug(e);
+ }
+ }
+ userForm.set("orgId", (org == null ? null : org.getOrganisationId()));
+
+ // sysadmins can mark users as required to use two-factor authentication
+ if (request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("isSysadmin", true);
+ }
+
+ // Get all available time zones
+ List availableTimeZones = UserAction.timezoneService.getDefaultTimezones();
+ TreeSet timezoneDtos = new TreeSet(new TimezoneDTOComparator());
+ for (Timezone availableTimeZone : availableTimeZones) {
+ String timezoneId = availableTimeZone.getTimezoneId();
+ TimezoneDTO timezoneDto = new TimezoneDTO();
+ timezoneDto.setTimeZoneId(timezoneId);
+ timezoneDto.setDisplayName(TimeZone.getTimeZone(timezoneId).getDisplayName());
+ timezoneDtos.add(timezoneDto);
+ }
+ request.setAttribute("timezoneDtos", timezoneDtos);
+
+ // for breadcrumb links
+ if (org != null) {
+ request.setAttribute("orgName", org.getName());
+ Organisation parentOrg = org.getParentOrganisation();
+ if ((parentOrg != null) && !parentOrg.equals(service.getRootOrganisation())) {
+ request.setAttribute("pOrgId", parentOrg.getOrganisationId());
+ request.setAttribute("parentName", parentOrg.getName());
+ }
+ }
+
+ request.setAttribute("locales", UserAction.locales);
+ request.setAttribute("authenticationMethods", UserAction.authenticationMethods);
+
+ return mapping.findForward("user");
+ }
+
+ // display user's global roles, if any
+ private UserOrgRoleDTO getGlobalRoles(User user) {
+ initServices();
+ UserOrganisation uo = service.getUserOrganisation(user.getUserId(),
+ service.getRootOrganisation().getOrganisationId());
+ if (uo == null) {
+ return null;
+ }
+ UserOrgRoleDTO uorDTO = new UserOrgRoleDTO();
+ List roles = new ArrayList();
+ for (Object uor : uo.getUserOrganisationRoles()) {
+ roles.add(((UserOrganisationRole) uor).getRole().getName());
+ }
+ Collections.sort(roles);
+ uorDTO.setOrgName(uo.getOrganisation().getName());
+ uorDTO.setRoles(roles);
+ return uorDTO;
+ }
+
+ // display user's organisations and roles in them
+ @SuppressWarnings("unchecked")
+ private List getUserOrgRoles(User user) {
+
+ initServices();
+ List uorDTOs = new ArrayList();
+ List uos = service.getUserOrganisationsForUserByTypeAndStatus(user.getLogin(),
+ OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE);
+ for (UserOrganisation uo : uos) {
+ UserOrgRoleDTO uorDTO = new UserOrgRoleDTO();
+ List roles = new ArrayList();
+ for (Object uor : uo.getUserOrganisationRoles()) {
+ roles.add(((UserOrganisationRole) uor).getRole().getName());
+ }
+ Collections.sort(roles);
+ uorDTO.setOrgName(uo.getOrganisation().getName());
+ uorDTO.setRoles(roles);
+ List childDTOs = new ArrayList();
+ List childuos = service.getUserOrganisationsForUserByTypeAndStatusAndParent(
+ user.getLogin(), OrganisationType.CLASS_TYPE, OrganisationState.ACTIVE,
+ uo.getOrganisation().getOrganisationId());
+ for (UserOrganisation childuo : childuos) {
+ UserOrgRoleDTO childDTO = new UserOrgRoleDTO();
+ List childroles = new ArrayList();
+ for (Object uor : childuo.getUserOrganisationRoles()) {
+ childroles.add(((UserOrganisationRole) uor).getRole().getName());
+ }
+ Collections.sort(childroles);
+ childDTO.setOrgName(childuo.getOrganisation().getName());
+ childDTO.setRoles(childroles);
+ childDTOs.add(childDTO);
+ }
+ uorDTO.setChildDTOs(childDTOs);
+ uorDTOs.add(uorDTO);
+ }
+
+ return uorDTOs;
+ }
+
+ // determine whether to disable or delete user based on their lams data
+ public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ Integer userId = WebUtil.readIntParam(request, "userId");
+ User user = (User) service.findById(User.class, userId);
+
+ Boolean hasData = service.userHasData(user);
+
+ request.setAttribute("method", (hasData ? "disable" : "delete"));
+ request.setAttribute("orgId", orgId);
+ request.setAttribute("userId", userId);
+ return mapping.findForward("remove");
+ }
+
+ public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+ UserDTO sysadmin = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
+
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ Integer userId = WebUtil.readIntParam(request, "userId");
+ service.disableUser(userId);
+ String[] args = new String[1];
+ args[0] = userId.toString();
+ String message = messageService.getMessage("audit.user.disable", args);
+ ILogEventService logEventService = AdminServiceProxy.getLogEventService(getServlet().getServletContext());
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, sysadmin != null ? sysadmin.getUserID() : null, userId,
+ null, null, message);
+ if ((orgId == null) || (orgId == 0)) {
+ return mapping.findForward("usersearch");
+ } else {
+ request.setAttribute("org", orgId);
+ return mapping.findForward("userlist");
+ }
+ }
+
+ public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+ UserDTO sysadmin = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
+
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ Integer userId = WebUtil.readIntParam(request, "userId");
+ try {
+ service.removeUser(userId);
+ } catch (Exception e) {
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", e.getMessage());
+ return mapping.findForward("error");
+ }
+ String[] args = new String[1];
+ args[0] = userId.toString();
+ String message = messageService.getMessage("audit.user.delete", args);
+ ILogEventService logEventService = AdminServiceProxy.getLogEventService(getServlet().getServletContext());
+ logEventService.logEvent(LogEvent.TYPE_USER_ORG_ADMIN, sysadmin != null ? sysadmin.getUserID() : null, userId,
+ null, null, message);
+ if ((orgId == null) || (orgId == 0)) {
+ return mapping.findForward("usersearch");
+ } else {
+ request.setAttribute("org", orgId);
+ return mapping.findForward("userlist");
+ }
+ }
+
+ // called from disabled users screen
+ public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ initServices();
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ Integer userId = WebUtil.readIntParam(request, "userId", true);
+ User user = (User) service.findById(User.class, userId);
+
+ UserAction.log.debug("enabling user: " + userId);
+ user.setDisabledFlag(false);
+ service.saveUser(user);
+
+ return mapping.findForward("disabledlist");
+ }
+
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserBasicListAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserBasicListAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserBasicListAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,114 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang.StringUtils;
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ */
+public class UserBasicListAction extends Action {
+
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ UserBasicListAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
+ HttpSession session = SessionManager.getSession();
+ if (session != null) {
+ UserDTO userDto = (UserDTO) session.getAttribute(AttributeNames.USER);
+ if (userDto != null) {
+ // get inputs
+ Integer userId = userDto.getUserID();
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ String potential = WebUtil.readStrParam(request, "potential", true);
+ if (orgId != null) {
+ if (!StringUtils.equals(potential, "1")) {
+ // list users in org
+ List users = UserBasicListAction.service.getUsersFromOrganisation(orgId);
+ request.setAttribute("users", users);
+ } else {
+ // get all potential users of this org instead... filters results according to user's roles
+ // get group
+ Organisation org = (Organisation) UserBasicListAction.service.findById(Organisation.class,
+ orgId);
+ Organisation group;
+ if (org != null) {
+ if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ group = org.getParentOrganisation();
+ } else {
+ group = org;
+ }
+ // get users
+ List users = new ArrayList();
+ if (request.isUserInRole(Role.SYSADMIN)
+ || UserBasicListAction.service.isUserGlobalGroupAdmin()) {
+ users = UserBasicListAction.service.getAllUsers(org.getOrganisationId());
+ } else if (UserBasicListAction.service.isUserInRole(userId, group.getOrganisationId(),
+ Role.GROUP_ADMIN)
+ || UserBasicListAction.service.isUserInRole(userId, group.getOrganisationId(),
+ Role.GROUP_MANAGER)) {
+ if (group.getCourseAdminCanBrowseAllUsers()) {
+ users = UserBasicListAction.service.getAllUsers(org.getOrganisationId());
+ } else if (org.getOrganisationType().getOrganisationTypeId()
+ .equals(OrganisationType.CLASS_TYPE)) {
+ users = UserBasicListAction.service.findUsers(null, group.getOrganisationId(),
+ orgId);
+ }
+ }
+ request.setAttribute("users", users);
+ }
+ }
+ }
+ }
+ }
+ return mapping.findForward("basiclist");
+ }
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserManageAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserManageAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserManageAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,169 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Collections;
+import java.util.HashMap;
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.dto.UserListDTO;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.dto.UserManageBean;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author Jun-Dir Liew
+ *
+ * Created at 13:51:51 on 9/06/2006
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ */
+public class UserManageAction extends Action {
+
+ private static final Logger log = Logger.getLogger(UserManageAction.class);
+ private static IUserManagementService service;
+ private static MessageService messageService;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+
+ // get id of org to list users for
+ Integer orgId = WebUtil.readIntParam(request, "org", true);
+ if (orgId == null) {
+ orgId = (Integer) request.getAttribute("org");
+ }
+ if ((orgId == null) || (orgId <= 0)) {
+ return forwardError(mapping, request, "error.org.invalid");
+ }
+ log.debug("orgId: " + orgId);
+
+ // get org name
+ Organisation organisation = (Organisation) service.findById(Organisation.class, orgId);
+ if (organisation == null) {
+ return forwardError(mapping, request, "error.org.invalid");
+ }
+ String orgName = organisation.getName();
+ log.debug("orgName: " + orgName);
+
+ Organisation pOrg = organisation.getParentOrganisation();
+ if (pOrg != null) {
+ request.setAttribute("pOrgId", pOrg.getOrganisationId());
+ request.setAttribute("pOrgName", pOrg.getName());
+ }
+ OrganisationType orgType = organisation.getOrganisationType();
+ request.setAttribute("orgType", orgType.getOrganisationTypeId());
+
+ // create form object
+ UserListDTO userManageForm = new UserListDTO();
+
+ Integer userId = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)).getUserID();
+ Organisation orgOfCourseAdmin = (orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) ? pOrg
+ : organisation;
+ // check permission
+ Integer rootOrgId = service.getRootOrganisation().getOrganisationId();
+ if (request.isUserInRole(Role.SYSADMIN) || (service.isUserGlobalGroupAdmin() && !orgId.equals(rootOrgId))) {
+ userManageForm.setCourseAdminCanAddNewUsers(true);
+ userManageForm.setCourseAdminCanBrowseAllUsers(true);
+ request.setAttribute("canDeleteUser", true);
+ } else if ((service.isUserInRole(userId, orgOfCourseAdmin.getOrganisationId(), Role.GROUP_ADMIN)
+ || service.isUserInRole(userId, orgOfCourseAdmin.getOrganisationId(), Role.GROUP_MANAGER))
+ && !orgId.equals(rootOrgId)) {
+ userManageForm.setCourseAdminCanAddNewUsers(orgOfCourseAdmin.getCourseAdminCanAddNewUsers());
+ userManageForm.setCourseAdminCanBrowseAllUsers(orgOfCourseAdmin.getCourseAdminCanBrowseAllUsers());
+ } else {
+ return forwardError(mapping, request, "error.authorisation");
+ }
+ userManageForm.setCanResetOrgPassword(request.isUserInRole(Role.SYSADMIN));
+
+ userManageForm.setOrgId(orgId);
+ userManageForm.setOrgName(orgName);
+ List userManageBeans = service.getUserManageBeans(orgId);
+ Collections.sort(userManageBeans);
+ userManageForm.setUserManageBeans(userManageBeans);
+ request.setAttribute("UserManageForm", userManageForm);
+
+ // heading
+ String[] args = { orgName };
+ request.setAttribute("heading", messageService.getMessage("heading.manage.group.users", args));
+
+ // count roles in the org
+ HashMap roleCount = new HashMap();
+ if (orgId.equals(rootOrgId)) {
+ roleCount.put(Role.SYSADMIN, Role.ROLE_SYSADMIN);
+ roleCount.put(Role.GROUP_ADMIN, Role.ROLE_GROUP_ADMIN);
+ } else {
+ roleCount.put(Role.LEARNER, Role.ROLE_LEARNER);
+ roleCount.put(Role.MONITOR, Role.ROLE_MONITOR);
+ roleCount.put(Role.AUTHOR, Role.ROLE_AUTHOR);
+ roleCount.put(Role.GROUP_MANAGER, Role.ROLE_GROUP_MANAGER);
+ roleCount.put(Role.GROUP_ADMIN, Role.ROLE_GROUP_ADMIN);
+ }
+ for (String role : roleCount.keySet()) {
+ Integer count = service.getCountRoleForOrg(orgId, roleCount.get(role), null);
+ request.setAttribute(role.replace(' ', '_'), count);
+ }
+
+ // count users in the org
+ // TODO use hql that does a count instead of getting whole objects
+ Integer numUsers = Integer.valueOf(service.getUsersFromOrganisation(orgId).size());
+ args[0] = numUsers.toString();
+ request.setAttribute("numUsers", messageService.getMessage("label.users.in.group", args));
+
+ return mapping.findForward("userlist");
+ }
+
+ private ActionForward forwardError(ActionMapping mapping, HttpServletRequest request, String key) {
+ request.setAttribute("errorName", "UserManageAction");
+ request.setAttribute("errorMessage", messageService.getMessage(key));
+ return mapping.findForward("error");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,104 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+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.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+
+/**
+ * @author Jun-Dir Liew
+ *
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class UserOrgAction extends Action {
+
+ private static final Logger log = Logger.getLogger(UserOrgAction.class);
+ private static IUserManagementService service;
+ private static MessageService messageService;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+
+ //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) {
+ request.setAttribute("errorName", "UserOrgAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.org.invalid"));
+ return mapping.findForward("error");
+ }
+
+ String orgName = organisation.getName();
+ log.debug("orgName: " + orgName);
+ Organisation parentOrg = organisation.getParentOrganisation();
+ if (parentOrg != null && !parentOrg.equals(service.getRootOrganisation())) {
+ request.setAttribute("pOrgId", parentOrg.getOrganisationId());
+ request.setAttribute("pOrgName", parentOrg.getName());
+ }
+ Integer orgType = organisation.getOrganisationType().getOrganisationTypeId();
+ request.setAttribute("orgType", orgType);
+
+ // create form object
+ DynaActionForm userOrgForm = (DynaActionForm) form;
+ userOrgForm.set("orgId", orgId);
+ userOrgForm.set("orgName", orgName);
+
+ String[] args = { "0" };
+ request.setAttribute("numExistUsers", messageService.getMessage("label.number.of.users", args));
+ request.setAttribute("numPotentialUsers", messageService.getMessage("label.number.of.potential.users", args));
+
+ return mapping.findForward("userorg");
+ }
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgRoleAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgRoleAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgRoleAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,123 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.Collections;
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.dto.UserBean;
+import org.lamsfoundation.lams.admin.web.form.UserOrgRoleForm;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.UserOrganisation;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+
+/**
+ * @author jliew
+ *
+ * Called when a user has added users to an organisation.
+ *
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class UserOrgRoleAction extends Action {
+
+ private static Logger log = Logger.getLogger(UserOrgRoleAction.class);
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ UserOrgRoleForm userOrgRoleForm = (UserOrgRoleForm) form;
+ // make sure we don't have left overs from any previous attempt
+ userOrgRoleForm.setUserBeans(new ArrayList());
+
+ // set list of roles appropriate for the organisation type
+ List roles = (List) request.getAttribute("roles");
+ request.setAttribute("numroles", roles.size());
+ Collections.sort(roles);
+ request.setAttribute("roles", roles);
+
+ Organisation organisation = (Organisation) service.findById(Organisation.class,
+ (Integer) request.getAttribute("orgId"));
+ userOrgRoleForm.setOrgId(organisation.getOrganisationId());
+
+ // display breadcrumb links
+ request.setAttribute("orgName", organisation.getName());
+ Organisation parentOrg = organisation.getParentOrganisation();
+ if (parentOrg != null && !parentOrg.equals(service.getRootOrganisation())) {
+ request.setAttribute("pOrgId", parentOrg.getOrganisationId());
+ request.setAttribute("pOrgName", parentOrg.getName());
+ }
+ request.setAttribute("orgType", organisation.getOrganisationType().getOrganisationTypeId());
+
+ // populate form with users
+ ArrayList userOrgs = (ArrayList) request.getAttribute("newUserOrganisations");
+ for (int i = 0; i < userOrgs.size(); i++) {
+ UserBean userBean = new UserBean();
+ User user = ((UserOrganisation) userOrgs.get(i)).getUser();
+ BeanUtils.copyProperties(userBean, user);
+ // flag users that will be added to parent group if necessary
+ userBean.setMemberOfParent(true);
+ if (organisation.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ if (service.getUserOrganisation(user.getUserId(),
+ organisation.getParentOrganisation().getOrganisationId()) == null) {
+ userBean.setMemberOfParent(false);
+ }
+ }
+ userOrgRoleForm.addUserBean(userBean);
+ log.debug("ready to assign role for user=" + userBean.getUserId());
+ }
+ log.debug("ready to assign roles for " + userOrgRoleForm.getUserBeans().size() + " new users in organisation "
+ + organisation.getName());
+
+ return mapping.findForward("userorgrole");
+ }
+
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgRoleSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgRoleSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgRoleSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,118 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.dto.UserBean;
+import org.lamsfoundation.lams.admin.web.form.UserOrgRoleForm;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+
+/**
+ * @author jliew
+ *
+ * Saves roles for users that were just added.
+ * Uses session scope because using request scope doesn't copy the form data
+ * into UserOrgRoleForm's userBeans ArrayList (the list becomes empty).
+ *
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class UserOrgRoleSaveAction extends Action {
+
+ private static Logger log = Logger.getLogger(UserOrgRoleSaveAction.class);
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ UserOrgRoleForm userOrgRoleForm = (UserOrgRoleForm) form;
+
+ ArrayList userBeans = userOrgRoleForm.getUserBeans();
+ log.debug("userBeans is null? " + userBeans == null);
+ Integer orgId = userOrgRoleForm.getOrgId();
+ log.debug("orgId: " + orgId);
+
+ request.setAttribute("org", orgId);
+ request.getSession().removeAttribute("UserOrgRoleForm");
+
+ if (isCancelled(request)) {
+ return mapping.findForward("userlist");
+ }
+
+ // save UserOrganisation memberships, and the associated roles;
+ // for subgroups, if user is not a member of the parent group then add to that as well.
+ for (int i = 0; i < userBeans.size(); i++) {
+ UserBean bean = (UserBean) userBeans.get(i);
+ User user = (User) service.findById(User.class, bean.getUserId());
+ log.debug("userId: " + bean.getUserId());
+ String[] roleIds = bean.getRoleIds();
+ if (roleIds.length == 0) {
+ // TODO forward to userorgrole.do, not userorg.do
+ ActionMessages errors = new ActionMessages();
+ errors.add("roles", new ActionMessage("error.roles.empty"));
+ saveErrors(request, errors);
+ request.setAttribute("orgId", orgId);
+ return mapping.findForward("userorg");
+ }
+ service.setRolesForUserOrganisation(user, orgId, Arrays.asList(roleIds));
+ // FMALIKOFF 5/7/7 Commented out the following code that set the roles in the course if the current org is a class, as the logic
+ // is done in service.setRolesForUserOrganisation()
+ //if (organisation.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ // if (service.getUserOrganisation(bean.getUserId(), organisation.getParentOrganisation().getOrganisationId())==null) {
+ // service.setRolesForUserOrganisation(user, organisation.getParentOrganisation(), (List)Arrays.asList(roleIds));
+ // }
+ //}
+ }
+ return mapping.findForward("userlist");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,147 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+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.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+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.service.IUserManagementService;
+
+/**
+ * @author Jun-Dir Liew
+ *
+ * Created at 17:22:21 on 20/06/2006
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ */
+public class UserOrgSaveAction extends Action {
+
+ private static Logger log = Logger.getLogger(UserOrgSaveAction.class);
+ private static IUserManagementService service;
+ private List rolelist;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ DynaActionForm userOrgForm = (DynaActionForm) form;
+
+ Integer orgId = (Integer) userOrgForm.get("orgId");
+ request.setAttribute("org", orgId);
+
+ if (isCancelled(request)) {
+ return mapping.findForward("userlist");
+ }
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ if (rolelist == null) {
+ rolelist = service.findAll(Role.class);
+ }
+
+ Organisation organisation = (Organisation) service.findById(Organisation.class, orgId);
+ Set uos = organisation.getUserOrganisations();
+
+ String[] userIds = (String[]) userOrgForm.get("userIds");
+ List userIdList = Arrays.asList(userIds);
+ log.debug("new user membership of orgId=" + orgId + " will be: " + 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) {
+ User user = (User) service.findById(User.class, userId);
+ Set userUos = user.getUserOrganisations();
+ userUos.remove(uo);
+ user.setUserOrganisations(userUos);
+ iter.remove();
+ log.debug("removed userId=" + userId + " from orgId=" + orgId);
+ // remove from subgroups
+ service.deleteChildUserOrganisations(uo.getUser(), uo.getOrganisation());
+ }
+ }
+ // add UserOrganisations that are in form data
+ List newUserOrganisations = new ArrayList();
+ for (int i = 0; i < userIdList.size(); i++) {
+ Integer userId = new Integer(userIdList.get(i));
+ Iterator iter2 = uos.iterator();
+ Boolean alreadyInOrg = false;
+ while (iter2.hasNext()) {
+ UserOrganisation uo = (UserOrganisation) iter2.next();
+ if (uo.getUser().getUserId().equals(userId)) {
+ alreadyInOrg = true;
+ break;
+ }
+ }
+ if (!alreadyInOrg) {
+ User user = (User) service.findById(User.class, userId);
+ UserOrganisation uo = new UserOrganisation(user, organisation);
+ newUserOrganisations.add(uo);
+ }
+ }
+
+ organisation.setUserOrganisations(uos);
+ service.save(organisation);
+
+ // if no new users, then finish; otherwise forward to where roles can be assigned for new users.
+ if (newUserOrganisations.isEmpty()) {
+ log.debug("no new users to add to orgId=" + orgId);
+ return mapping.findForward("userlist");
+ } else {
+ request.setAttribute("roles", service.filterRoles(rolelist, request.isUserInRole(Role.SYSADMIN),
+ organisation.getOrganisationType()));
+ request.setAttribute("newUserOrganisations", newUserOrganisations);
+ request.setAttribute("orgId", orgId);
+ return mapping.findForward("userorgrole");
+ }
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserRolesAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserRolesAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserRolesAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,163 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Collections;
+import java.util.Iterator;
+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.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+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.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class UserRolesAction extends Action {
+
+ private static Logger log = Logger.getLogger(UserRolesAction.class);
+ private static IUserManagementService service;
+ private static MessageService messageService;
+ private static List rolelist;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ if (rolelist == null) {
+ rolelist = service.findAll(Role.class);
+ Collections.sort(rolelist);
+ }
+
+ ActionMessages errors = new ActionMessages();
+ DynaActionForm userRolesForm = (DynaActionForm) form;
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ Integer userId = WebUtil.readIntParam(request, "userId", true);
+
+ // user and org ids passed as attributes by UserSaveAction
+ if (orgId == null) {
+ orgId = (Integer) request.getAttribute("orgId");
+ }
+ if (orgId == null) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.org.invalid"));
+ saveErrors(request, errors);
+ return mapping.findForward("userrole");
+ }
+ if (userId == null || userId == 0) {
+ userId = (Integer) request.getAttribute("userId");
+ }
+ if (userId == null) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.userid.invalid"));
+ saveErrors(request, errors);
+ return mapping.findForward("userrole");
+ }
+ log.debug("editing roles for userId: " + userId + " and orgId: " + orgId);
+
+ // test requestor's permission
+ Organisation org = (Organisation) service.findById(Organisation.class, orgId);
+ User user = (User) service.findById(User.class, userId);
+ OrganisationType orgType = org.getOrganisationType();
+ Integer orgIdOfCourse = (orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE))
+ ? org.getParentOrganisation().getOrganisationId() : orgId;
+ Boolean isSysadmin = request.isUserInRole(Role.SYSADMIN);
+ User requestor = service.getUserByLogin(request.getRemoteUser());
+ Integer rootOrgId = service.getRootOrganisation().getOrganisationId();
+ Boolean requestorHasRole = service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)
+ || (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN)
+ && !rootOrgId.equals(orgId))
+ || (service.isUserGlobalGroupAdmin() && !rootOrgId.equals(orgId));
+
+ if (!(requestorHasRole || isSysadmin)) {
+ request.setAttribute("errorName", "UserRolesAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ userRolesForm.set("userId", userId);
+ userRolesForm.set("orgId", org.getOrganisationId());
+ // screen display vars
+ request.setAttribute("rolelist", service.filterRoles(rolelist, isSysadmin, orgType));
+ request.setAttribute("login", user.getLogin());
+ request.setAttribute("fullName", user.getFullName());
+ request.setAttribute("orgName", org.getName());
+ Organisation parentOrg = org.getParentOrganisation();
+ if (parentOrg != null && !parentOrg.equals(service.getRootOrganisation())) {
+ request.setAttribute("pOrgId", parentOrg.getOrganisationId());
+ request.setAttribute("parentName", parentOrg.getName());
+ }
+
+ String[] roles = null;
+ UserOrganisation uo = service.getUserOrganisation(userId, orgId);
+ if (uo != null) {
+ Iterator iter2 = uo.getUserOrganisationRoles().iterator();
+ roles = new String[uo.getUserOrganisationRoles().size()];
+ int i = 0;
+ while (iter2.hasNext()) {
+ UserOrganisationRole uor = (UserOrganisationRole) iter2.next();
+ roles[i] = uor.getRole().getRoleId().toString();
+ log.debug("got roleid: " + roles[i]);
+ i++;
+ }
+ } else {
+ ActionMessages messages = new ActionMessages();
+ messages.add("roles", new ActionMessage("msg.add.to.org", org.getName()));
+ saveMessages(request, messages);
+ }
+ userRolesForm.set("roles", roles);
+
+ return mapping.findForward("userrole");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserRolesSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserRolesSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserRolesSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,109 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Arrays;
+import java.util.Collections;
+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.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+public class UserRolesSaveAction extends Action {
+
+ private static Logger log = Logger.getLogger(UserRolesSaveAction.class);
+ private static IUserManagementService service;
+ private static List rolelist;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ if (rolelist == null) {
+ rolelist = service.findAll(Role.class);
+ Collections.sort(rolelist);
+ }
+
+ ActionMessages errors = new ActionMessages();
+ DynaActionForm userRolesForm = (DynaActionForm) form;
+ Integer orgId = (Integer) userRolesForm.get("orgId");
+ Integer userId = (Integer) userRolesForm.get("userId");
+ String[] roles = (String[]) userRolesForm.get("roles");
+
+ request.setAttribute("org", orgId);
+
+ if (isCancelled(request)) {
+ return mapping.findForward("userlist");
+ }
+
+ log.debug("userId: " + userId + ", orgId: " + orgId + " will have " + roles.length + " roles");
+ Organisation org = (Organisation) service.findById(Organisation.class, orgId);
+ User user = (User) service.findById(User.class, userId);
+
+ // user must have at least 1 role
+ if (roles.length < 1) {
+ errors.add("roles", new ActionMessage("error.roles.empty"));
+ saveErrors(request, errors);
+ request.setAttribute("rolelist",
+ service.filterRoles(rolelist, request.isUserInRole(Role.SYSADMIN), org.getOrganisationType()));
+ request.setAttribute("login", user.getLogin());
+ request.setAttribute("fullName", user.getFullName());
+ return mapping.findForward("userroles");
+ }
+
+ service.setRolesForUserOrganisation(user, orgId, Arrays.asList(roles));
+
+ return mapping.findForward("userlist");
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSaveAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSaveAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSaveAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,287 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+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.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.security.ISecurityService;
+import org.lamsfoundation.lams.themes.Theme;
+import org.lamsfoundation.lams.usermanagement.AuthenticationMethod;
+import org.lamsfoundation.lams.usermanagement.SupportedLocale;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.HashUtil;
+import org.lamsfoundation.lams.util.ValidationUtil;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author Jun-Dir Liew
+ *
+ * Created at 12:35:38 on 14/06/2006
+ */
+
+/**
+ * struts doclets
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+public class UserSaveAction extends LamsDispatchAction {
+
+ private static Logger log = Logger.getLogger(UserSaveAction.class);
+ private static IUserManagementService service;
+
+ public ActionForward saveUserDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ UserSaveAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
+ // action input
+ ActionMessages errors = new ActionMessages();
+ DynaActionForm userForm = (DynaActionForm) form;
+ Integer orgId = (Integer) userForm.get("orgId");
+ Integer userId = (Integer) userForm.get("userId");
+ ISecurityService securityService = AdminServiceProxy.getSecurityService(getServlet().getServletContext());
+ Integer loggeduserId = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)).getUserID();
+
+ // check if logged in User is Sysadmin
+ if (!securityService.isSysadmin(loggeduserId, "Edit User Details " + userId, true)) {
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, "Only Sysadmin has edit permisions");
+ return null;
+ }
+ UserDTO sysadmin = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
+
+ UserSaveAction.log.debug("orgId: " + orgId);
+ Boolean edit = false;
+ SupportedLocale locale = (SupportedLocale) UserSaveAction.service.findById(SupportedLocale.class,
+ (Integer) userForm.get("localeId"));
+ AuthenticationMethod authenticationMethod = (AuthenticationMethod) UserSaveAction.service
+ .findById(AuthenticationMethod.class, (Integer) userForm.get("authenticationMethodId"));
+ UserSaveAction.log.debug("locale: " + locale);
+ UserSaveAction.log.debug("authenticationMethod:" + authenticationMethod);
+
+ if (isCancelled(request)) {
+ if ((orgId == null) || (orgId == 0)) {
+ return mapping.findForward("usersearch");
+ }
+ request.setAttribute("org", orgId);
+ return mapping.findForward("userlist");
+ }
+
+ User user = null;
+ if (userId != 0) {
+ edit = true;
+ user = (User) UserSaveAction.service.findById(User.class, userId);
+ }
+
+ // login validation
+ String login = (userForm.get("login") == null) ? null : userForm.getString("login").trim();
+ if (StringUtils.isBlank(login)) {
+ errors.add("login", new ActionMessage("error.login.required"));
+ } else if (!ValidationUtil.isUserNameValid(login)) {
+ errors.add("login", new ActionMessage("error.username.invalid.characters"));
+ } else {
+ userForm.set("login", login);
+ User existingUser = UserSaveAction.service.getUserByLogin(login);
+ if (existingUser != null) {
+ if ((user != null) && StringUtils.equals(user.getLogin(), login)) {
+ // login exists - it's the user's current login
+ } else {
+ errors.add("login", new ActionMessage("error.login.unique",
+ "(" + login + ", ID: " + existingUser.getUserId() + ")"));
+ }
+ }
+ }
+
+ //first name validation
+ String firstName = (userForm.get("firstName") == null) ? null : (String) userForm.get("firstName");
+ if (StringUtils.isBlank(firstName)) {
+ errors.add("firstName", new ActionMessage("error.firstname.required"));
+ } else if (!ValidationUtil.isFirstLastNameValid(firstName)) {
+ errors.add("firstName", new ActionMessage("error.firstname.invalid.characters"));
+ }
+
+ //last name validation
+ String lastName = (userForm.get("lastName") == null) ? null : (String) userForm.get("lastName");
+ if (StringUtils.isBlank(lastName)) {
+ errors.add("lastName", new ActionMessage("error.lastname.required"));
+ } else if (!ValidationUtil.isFirstLastNameValid(lastName)) {
+ errors.add("lastName", new ActionMessage("error.lastname.invalid.characters"));
+ }
+
+ //user email validation
+ String userEmail = (userForm.get("email") == null) ? null : (String) userForm.get("email");
+ if (StringUtils.isBlank(userEmail)) {
+ errors.add("email", new ActionMessage("error.email.required"));
+ } else if (!ValidationUtil.isEmailValid(userEmail)) {
+ errors.add("email", new ActionMessage("error.valid.email.required"));
+ }
+
+ if (errors.isEmpty()) {
+ if (edit) { // edit user
+ UserSaveAction.log.debug("editing userId: " + userId);
+ // hash the new password if necessary, and audit the fact
+ userForm.set("password", user.getPassword());
+ BeanUtils.copyProperties(user, userForm);
+ user.setLocale(locale);
+ user.setAuthenticationMethod(authenticationMethod);
+
+ Theme cssTheme = (Theme) UserSaveAction.service.findById(Theme.class, (Long) userForm.get("userTheme"));
+ user.setTheme(cssTheme);
+
+ UserSaveAction.service.saveUser(user);
+ } else { // create user
+
+ //password validation
+ String password2 = userForm.getString("password2");
+ String password = (userForm.get("password") == null) ? null : (String) userForm.get("password");
+ if (StringUtils.isBlank(password)) {
+ errors.add("password", new ActionMessage("error.password.required"));
+ }
+ if (!StringUtils.equals(password, ((String) userForm.get("password2")))) {
+ errors.add("password", new ActionMessage("error.newpassword.mismatch"));
+ }
+ if (!ValidationUtil.isPasswordValueValid(password, password2)) {
+ errors.add("password", new ActionMessage("error.newpassword.mismatch"));
+ }
+
+ if (errors.isEmpty()) {
+ user = new User();
+ String salt = HashUtil.salt();
+ String passwordHash = HashUtil.sha256((String) userForm.get("password"), salt);
+ BeanUtils.copyProperties(user, userForm);
+ user.setSalt(salt);
+ user.setPassword(passwordHash);
+ UserSaveAction.log.debug("creating user... new login: " + user.getLogin());
+ if (errors.isEmpty()) {
+ // TODO set theme according to user input
+ // instead of server default.
+ user.setTheme(UserSaveAction.service.getDefaultTheme());
+ user.setDisabledFlag(false);
+ user.setCreateDate(new Date());
+ user.setAuthenticationMethod((AuthenticationMethod) UserSaveAction.service
+ .findByProperty(AuthenticationMethod.class, "authenticationMethodName", "LAMS-Database")
+ .get(0));
+ user.setUserId(null);
+ user.setLocale(locale);
+
+ Theme theme = (Theme) UserSaveAction.service.findById(Theme.class,
+ (Long) userForm.get("userTheme"));
+ user.setTheme(theme);
+
+ UserSaveAction.service.saveUser(user);
+
+ // make 'create user' audit log entry
+ UserSaveAction.service.logUserCreated(user, sysadmin);
+
+ UserSaveAction.log.debug("user: " + user.toString());
+ }
+ }
+ }
+ }
+
+ if (errors.isEmpty()) {
+ if ((orgId == null) || (orgId == 0)) {
+ return mapping.findForward("usersearch");
+ }
+ if (edit) {
+ request.setAttribute("org", orgId);
+ return mapping.findForward("userlist");
+ } else {
+ request.setAttribute("orgId", orgId);
+ request.setAttribute("userId", user.getUserId());
+ return mapping.findForward("userroles");
+ }
+ } else {
+ saveErrors(request, errors);
+ request.setAttribute("orgId", orgId);
+ return mapping.findForward("user");
+ }
+ }
+
+ public ActionForward changePass(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ UserSaveAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
+ ActionMessages errors = new ActionMessages();
+ Integer userId = WebUtil.readIntParam(request, "userId", true);
+ ISecurityService securityService = AdminServiceProxy.getSecurityService(getServlet().getServletContext());
+ Integer loggeduserId = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)).getUserID();
+
+ // check if logged in User is Sysadmin
+ if (!securityService.isSysadmin(loggeduserId, "Change Password of User " + userId, true)) {
+ response.sendError(HttpServletResponse.SC_FORBIDDEN, "Only Sysadmin has edit permisions");
+ return null;
+ }
+
+ String password = WebUtil.readStrParam(request, "password");
+ String password2 = WebUtil.readStrParam(request, "password2");
+
+ //password validation
+ if (StringUtils.isBlank(password)) {
+ errors.add("password", new ActionMessage("error.password.required"));
+ }
+
+ if (!StringUtils.equals(password, password2)) {
+ errors.add("password", new ActionMessage("error.newpassword.mismatch"));
+ }
+ if (!ValidationUtil.isPasswordValueValid(password, password2)) {
+ errors.add("password", new ActionMessage("label.password.restrictions"));
+ }
+
+ if (errors.isEmpty()) {
+ User user = (User) UserSaveAction.service.findById(User.class, userId);
+ String salt = HashUtil.salt();
+ String passwordHash = HashUtil.sha256(password, salt);
+ user.setSalt(salt);
+ user.setPassword(passwordHash);
+ UserSaveAction.service.saveUser(user);
+ return mapping.findForward("userChangePass");
+ }
+ saveErrors(request, errors);
+ return mapping.findForward("errorPass");
+
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSearchAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSearchAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSearchAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,157 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.springframework.web.util.HtmlUtils;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ */
+public class UserSearchAction extends LamsDispatchAction {
+
+ private static Logger log = Logger.getLogger(UserSearchAction.class);
+ private static IUserManagementService service;
+ private static MessageService messageService;
+
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ initServices();
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ log.debug("user not sysadmin or global group admin");
+
+ request.setAttribute("errorName", "UserSearchAction authorisation");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ return mapping.findForward("usersearchlist");
+ }
+
+ /**
+ * Returns list of paged users.
+ */
+ public ActionForward getPagedUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse res) throws IOException, ServletException {
+ initServices();
+
+ // the organisation type of the children
+ String searchString = WebUtil.readStrParam(request, "fcol[1]", true);
+
+ // paging parameters of tablesorter
+ int size = WebUtil.readIntParam(request, "size");
+ int page = WebUtil.readIntParam(request, "page");
+ Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true);
+ Integer isSort2 = WebUtil.readIntParam(request, "column[1]", true);
+ Integer isSort3 = WebUtil.readIntParam(request, "column[2]", true);
+ Integer isSort4 = WebUtil.readIntParam(request, "column[3]", true);
+ Integer isSort5 = WebUtil.readIntParam(request, "column[4]", true);
+
+ String sortBy = "userId";
+ String sortOrder = "DESC";
+ if (isSort1 != null) {
+ sortBy = "userId";
+ sortOrder = isSort1.equals(0) ? "ASC" : "DESC";
+
+ } else if (isSort2 != null) {
+ sortBy = "login";
+ sortOrder = isSort2.equals(0) ? "ASC" : "DESC";
+
+ } else if (isSort3 != null) {
+ sortBy = "firstName";
+ sortOrder = isSort3.equals(0) ? "ASC" : "DESC";
+
+ } else if (isSort4 != null) {
+ sortBy = "lastName";
+ sortOrder = isSort4.equals(0) ? "ASC" : "DESC";
+
+ } else if (isSort5 != null) {
+ sortBy = "email";
+ sortOrder = isSort5.equals(0) ? "ASC" : "DESC";
+ }
+
+ List userDtos = service.getAllUsers(page, size, sortBy, sortOrder, searchString);
+
+ ObjectNode responcedata = JsonNodeFactory.instance.objectNode();
+ responcedata.put("total_rows", service.getCountUsers(searchString));
+
+ ArrayNode rows = JsonNodeFactory.instance.arrayNode();
+ for (UserDTO userDto : userDtos) {
+ ObjectNode responseRow = JsonNodeFactory.instance.objectNode();
+ responseRow.put("userId", userDto.getUserID());
+ responseRow.put("login", HtmlUtils.htmlEscape(userDto.getLogin()));
+ String firstName = userDto.getFirstName() == null ? "" : userDto.getFirstName();
+ responseRow.put("firstName", HtmlUtils.htmlEscape(firstName));
+ String lastName = userDto.getLastName() == null ? "" : userDto.getLastName();
+ responseRow.put("lastName", HtmlUtils.htmlEscape(lastName));
+ String email = userDto.getEmail() == null ? "" : userDto.getEmail();
+ responseRow.put("email", HtmlUtils.htmlEscape(email));
+ if (userDto.getPortraitUuid() != null) {
+ responseRow.put("portraitId", userDto.getPortraitUuid());
+ }
+ rows.add(responseRow);
+ }
+ responcedata.set("rows", rows);
+ res.setContentType("application/json;charset=utf-8");
+ res.getWriter().print(new String(responcedata.toString()));
+ return null;
+ }
+
+ private void initServices() {
+ if (service == null) {
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ }
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+ }
+
+}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSearchSingleTermAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSearchSingleTermAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserSearchSingleTermAction.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,113 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang.StringUtils;
+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.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.OrganisationType;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ */
+public class UserSearchSingleTermAction extends Action {
+
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ UserSearchSingleTermAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
+ String term = WebUtil.readStrParam(request, "term", true);
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+
+ if (StringUtils.isNotBlank(term)) {
+ List users = new ArrayList();
+ if (orgId != null) {
+ // filter results according to user's roles
+ Organisation org = (Organisation) UserSearchSingleTermAction.service.findById(Organisation.class,
+ orgId);
+ Organisation group;
+ if (org != null) {
+ HttpSession session = SessionManager.getSession();
+ if (session != null) {
+ UserDTO userDto = (UserDTO) session.getAttribute(AttributeNames.USER);
+ if (userDto != null) {
+ Integer userId = userDto.getUserID();
+ if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ group = org.getParentOrganisation();
+ } else {
+ group = org;
+ }
+ // get search results, filtered according to orgId
+ if (request.isUserInRole(Role.SYSADMIN)
+ || UserSearchSingleTermAction.service.isUserGlobalGroupAdmin()) {
+ users = UserSearchSingleTermAction.service.findUsers(term, orgId);
+ } else if (UserSearchSingleTermAction.service.isUserInRole(userId,
+ group.getOrganisationId(), Role.GROUP_ADMIN)
+ || UserSearchSingleTermAction.service.isUserInRole(userId,
+ group.getOrganisationId(), Role.GROUP_MANAGER)) {
+ if (group.getCourseAdminCanBrowseAllUsers()) {
+ users = UserSearchSingleTermAction.service.findUsers(term, orgId);
+ } else if (org.getOrganisationType().getOrganisationTypeId()
+ .equals(OrganisationType.CLASS_TYPE)) {
+ users = UserSearchSingleTermAction.service.findUsers(term,
+ group.getOrganisationId(), orgId);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // if there's no orgId param, search all users
+ users = UserSearchSingleTermAction.service.findUsers(term);
+ }
+ request.setAttribute("users", users);
+ }
+
+ return mapping.findForward("basiclist");
+ }
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/CleanupForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/CleanupForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/CleanupForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class CleanupForm {
+
+ private Integer numDays;
+
+ public Integer getNumDays() {
+ return numDays;
+ }
+
+ public void setNumDays(Integer numDays) {
+ this.numDays = numDays;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ConfigForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ConfigForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ConfigForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,57 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class ConfigForm {
+
+ private String[] key;
+
+ private String[] value;
+
+ private String method;
+
+ public String[] getKey() {
+ return key;
+ }
+
+ public void setKey(String[] key) {
+ this.key = key;
+ }
+
+ public String[] getValue() {
+ return value;
+ }
+
+ public void setValue(String[] value) {
+ this.value = value;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ExtServerForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ExtServerForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ExtServerForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,147 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class ExtServerForm {
+
+ private Integer sid = -1;
+
+ private String serverid;
+
+ private String serverkey;
+
+ private String servername;
+
+ private String serverdesc;
+
+ private String prefix;
+
+ private String userinfoUrl;
+
+ private String lessonFinishUrl;
+
+ private String extGroupsUrl;
+
+ private boolean disabled = false;
+
+ private boolean timeToLiveLoginRequestEnabled = true;
+
+ private Integer timeToLiveLoginRequest = 80;
+
+ public Integer getSid() {
+ return sid;
+ }
+
+ public void setSid(Integer sid) {
+ this.sid = sid;
+ }
+
+ public String getServerid() {
+ return serverid;
+ }
+
+ public void setServerid(String serverid) {
+ this.serverid = serverid;
+ }
+
+ public String getServerkey() {
+ return serverkey;
+ }
+
+ public void setServerkey(String serverkey) {
+ this.serverkey = serverkey;
+ }
+
+ public String getServername() {
+ return servername;
+ }
+
+ public void setServername(String servername) {
+ this.servername = servername;
+ }
+
+ public String getServerdesc() {
+ return serverdesc;
+ }
+
+ public void setServerdesc(String serverdesc) {
+ this.serverdesc = serverdesc;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public String getUserinfoUrl() {
+ return userinfoUrl;
+ }
+
+ public void setUserinfoUrl(String userinfoUrl) {
+ this.userinfoUrl = userinfoUrl;
+ }
+
+ public String getLessonFinishUrl() {
+ return lessonFinishUrl;
+ }
+
+ public void setLessonFinishUrl(String lessonFinishUrl) {
+ this.lessonFinishUrl = lessonFinishUrl;
+ }
+
+ public String getExtGroupsUrl() {
+ return extGroupsUrl;
+ }
+
+ public void setExtGroupsUrl(String extGroupsUrl) {
+ this.extGroupsUrl = extGroupsUrl;
+ }
+
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public boolean isTimeToLiveLoginRequestEnabled() {
+ return timeToLiveLoginRequestEnabled;
+ }
+
+ public void setTimeToLiveLoginRequestEnabled(boolean timeToLiveLoginRequestEnabled) {
+ this.timeToLiveLoginRequestEnabled = timeToLiveLoginRequestEnabled;
+ }
+
+ public Integer getTimeToLiveLoginRequest() {
+ return timeToLiveLoginRequest;
+ }
+
+ public void setTimeToLiveLoginRequest(Integer timeToLiveLoginRequest) {
+ this.timeToLiveLoginRequest = timeToLiveLoginRequest;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ImportExcelForm.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ImportExcelForm.java (.../ImportExcelForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ImportExcelForm.java (.../ImportExcelForm.java) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -20,21 +20,19 @@
* ****************************************************************
*/
-
package org.lamsfoundation.lams.admin.web.form;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.upload.FormFile;
+import org.springframework.web.multipart.MultipartFile;
/**
* @author jliew
*
*
*/
-public class ImportExcelForm extends ActionForm {
+public class ImportExcelForm {
private Integer orgId;
- private FormFile file;
+ private MultipartFile file;
public Integer getOrgId() {
return orgId;
@@ -44,11 +42,11 @@
this.orgId = orgId;
}
- public FormFile getFile() {
+ public MultipartFile getFile() {
return file;
}
- public void setFile(FormFile file) {
+ public void setFile(MultipartFile file) {
this.file = file;
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ImportGroupsForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ImportGroupsForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ImportGroupsForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,27 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class ImportGroupsForm {
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/LoginMaintainForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/LoginMaintainForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/LoginMaintainForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class LoginMaintainForm {
+
+ private String news;
+
+ public String getNews() {
+ return news;
+ }
+
+ public void setNews(String news) {
+ this.news = news;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/LtiConsumerForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/LtiConsumerForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/LtiConsumerForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,127 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class LtiConsumerForm {
+
+ private Integer sid;
+
+ private String serverid;
+
+ private String serverkey;
+
+ private String servername;
+
+ private String serverdesc;
+
+ private String prefix;
+
+ private boolean disabled = false;
+
+ private String lessonFinishUrl;
+
+ private boolean timeToLiveLoginRequestEnabled = false;
+
+ private String ltiToolConsumerMonitorRoles;
+
+ public Integer getSid() {
+ return sid;
+ }
+
+ public void setSid(Integer sid) {
+ this.sid = sid;
+ }
+
+ public String getServerid() {
+ return serverid;
+ }
+
+ public void setServerid(String serverid) {
+ this.serverid = serverid;
+ }
+
+ public String getServerkey() {
+ return serverkey;
+ }
+
+ public void setServerkey(String serverkey) {
+ this.serverkey = serverkey;
+ }
+
+ public String getServername() {
+ return servername;
+ }
+
+ public void setServername(String servername) {
+ this.servername = servername;
+ }
+
+ public String getServerdesc() {
+ return serverdesc;
+ }
+
+ public void setServerdesc(String serverdesc) {
+ this.serverdesc = serverdesc;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public String getLessonFinishUrl() {
+ return lessonFinishUrl;
+ }
+
+ public void setLessonFinishUrl(String lessonFinishUrl) {
+ this.lessonFinishUrl = lessonFinishUrl;
+ }
+
+ public boolean isTimeToLiveLoginRequestEnabled() {
+ return timeToLiveLoginRequestEnabled;
+ }
+
+ public void setTimeToLiveLoginRequestEnabled(boolean timeToLiveLoginRequestEnabled) {
+ this.timeToLiveLoginRequestEnabled = timeToLiveLoginRequestEnabled;
+ }
+
+ public String getLtiToolConsumerMonitorRoles() {
+ return ltiToolConsumerMonitorRoles;
+ }
+
+ public void setLtiToolConsumerMonitorRoles(String ltiToolConsumerMonitorRoles) {
+ this.ltiToolConsumerMonitorRoles = ltiToolConsumerMonitorRoles;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java (.../OrgManageForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java (.../OrgManageForm.java) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -22,12 +22,10 @@
*/
package org.lamsfoundation.lams.admin.web.form;
-import org.apache.struts.action.ActionForm;
-
/**
* @author Fei Yang
*/
-public class OrgManageForm extends ActionForm {
+public class OrgManageForm {
private static final long serialVersionUID = -3960695533993640297L;
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgPasswordChangeForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgPasswordChangeForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgPasswordChangeForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,147 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class OrgPasswordChangeForm {
+
+ private Integer organisationID;
+
+ private String orgName;
+
+ private boolean isStaffChange = false;
+
+ private boolean isLearnerChange = false;
+
+ private String includedLearners; // initial=""/>
+
+ private String excludedLearners;
+
+ private String includedStaff; // initial=""/>
+
+ private String excludedStaff; // initial="[]"/>
+
+ private String learnerPass;
+
+ private String staffPass;
+
+ private boolean email = false;
+
+ private boolean force = false;
+
+ public Integer getOrganisationID() {
+ return organisationID;
+ }
+
+ public void setOrganisationID(Integer organisationID) {
+ this.organisationID = organisationID;
+ }
+
+ public String getOrgName() {
+ return orgName;
+ }
+
+ public void setOrgName(String orgName) {
+ this.orgName = orgName;
+ }
+
+ public boolean isStaffChange() {
+ return isStaffChange;
+ }
+
+ public void setStaffChange(boolean isStaffChange) {
+ this.isStaffChange = isStaffChange;
+ }
+
+ public boolean isLearnerChange() {
+ return isLearnerChange;
+ }
+
+ public void setLearnerChange(boolean isLearnerChange) {
+ this.isLearnerChange = isLearnerChange;
+ }
+
+ public String getIncludedLearners() {
+ return includedLearners;
+ }
+
+ public void setIncludedLearners(String includedLearners) {
+ this.includedLearners = includedLearners;
+ }
+
+ public String getExcludedLearners() {
+ return excludedLearners;
+ }
+
+ public void setExcludedLearners(String excludedLearners) {
+ this.excludedLearners = excludedLearners;
+ }
+
+ public String getIncludedStaff() {
+ return includedStaff;
+ }
+
+ public void setIncludedStaff(String includedStaff) {
+ this.includedStaff = includedStaff;
+ }
+
+ public String getExcludedStaff() {
+ return excludedStaff;
+ }
+
+ public void setExcludedStaff(String excludedStaff) {
+ this.excludedStaff = excludedStaff;
+ }
+
+ public String getLearnerPass() {
+ return learnerPass;
+ }
+
+ public void setLearnerPass(String learnerPass) {
+ this.learnerPass = learnerPass;
+ }
+
+ public String getStaffPass() {
+ return staffPass;
+ }
+
+ public void setStaffPass(String staffPass) {
+ this.staffPass = staffPass;
+ }
+
+ public boolean isEmail() {
+ return email;
+ }
+
+ public void setEmail(boolean email) {
+ this.email = email;
+ }
+
+ public boolean isForce() {
+ return force;
+ }
+
+ public void setForce(boolean force) {
+ this.force = force;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrganisationForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrganisationForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrganisationForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,187 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.form;
+
+public class OrganisationForm {
+
+ private Integer orgId;
+
+ private Integer parentId;
+
+ private String parentName;
+
+ private String name;
+
+ private String code;
+
+ private String description;
+
+ private Integer localeId = 1;
+
+ private Integer stateId;
+
+ private boolean courseAdminCanAddNewUsers = false;
+
+ private boolean courseAdminCanBrowseAllUsers = false;
+
+ private boolean courseAdminCanChangeStatusOfCourse = false;
+
+ private boolean enableCourseNotifications = false;
+
+ private boolean enableGradebookForLearners = false;
+
+ private boolean enableSingleActivityLessons = false;
+
+ private boolean enableLiveEdit = true;
+
+ private boolean enableKumalive = false;
+
+ public Integer getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Integer orgId) {
+ this.orgId = orgId;
+ }
+
+ public Integer getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(Integer parentId) {
+ this.parentId = parentId;
+ }
+
+ public String getParentName() {
+ return parentName;
+ }
+
+ public void setParentName(String parentName) {
+ this.parentName = parentName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Integer getLocaleId() {
+ return localeId;
+ }
+
+ public void setLocaleId(Integer localeId) {
+ this.localeId = localeId;
+ }
+
+ public Integer getStateId() {
+ return stateId;
+ }
+
+ public void setStateId(Integer stateId) {
+ this.stateId = stateId;
+ }
+
+ public boolean isCourseAdminCanAddNewUsers() {
+ return courseAdminCanAddNewUsers;
+ }
+
+ public void setCourseAdminCanAddNewUsers(boolean courseAdminCanAddNewUsers) {
+ this.courseAdminCanAddNewUsers = courseAdminCanAddNewUsers;
+ }
+
+ public boolean isCourseAdminCanBrowseAllUsers() {
+ return courseAdminCanBrowseAllUsers;
+ }
+
+ public void setCourseAdminCanBrowseAllUsers(boolean courseAdminCanBrowseAllUsers) {
+ this.courseAdminCanBrowseAllUsers = courseAdminCanBrowseAllUsers;
+ }
+
+ public boolean isCourseAdminCanChangeStatusOfCourse() {
+ return courseAdminCanChangeStatusOfCourse;
+ }
+
+ public void setCourseAdminCanChangeStatusOfCourse(boolean courseAdminCanChangeStatusOfCourse) {
+ this.courseAdminCanChangeStatusOfCourse = courseAdminCanChangeStatusOfCourse;
+ }
+
+ public boolean isEnableCourseNotifications() {
+ return enableCourseNotifications;
+ }
+
+ public void setEnableCourseNotifications(boolean enableCourseNotifications) {
+ this.enableCourseNotifications = enableCourseNotifications;
+ }
+
+ public boolean isEnableGradebookForLearners() {
+ return enableGradebookForLearners;
+ }
+
+ public void setEnableGradebookForLearners(boolean enableGradebookForLearners) {
+ this.enableGradebookForLearners = enableGradebookForLearners;
+ }
+
+ public boolean isEnableSingleActivityLessons() {
+ return enableSingleActivityLessons;
+ }
+
+ public void setEnableSingleActivityLessons(boolean enableSingleActivityLessons) {
+ this.enableSingleActivityLessons = enableSingleActivityLessons;
+ }
+
+ public boolean isEnableLiveEdit() {
+ return enableLiveEdit;
+ }
+
+ public void setEnableLiveEdit(boolean enableLiveEdit) {
+ this.enableLiveEdit = enableLiveEdit;
+ }
+
+ public boolean isEnableKumalive() {
+ return enableKumalive;
+ }
+
+ public void setEnableKumalive(boolean enableKumalive) {
+ this.enableKumalive = enableKumalive;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/SignupManagementForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/SignupManagementForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/SignupManagementForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,149 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class SignupManagementForm {
+
+ private Integer signupOrganisationId;
+
+ private Integer organisationId;
+
+ private boolean addToLessons = true;
+
+ private boolean addAsStaff = false;
+
+ private boolean addWithAuthor = false;
+
+ private boolean addWithMonitor = false;
+
+ private String courseKey;
+
+ private String confirmCourseKey;
+
+ private String blurb;
+
+ private boolean disabled = false;
+
+ private boolean loginTabActive = false;
+
+ private String context;
+
+ public Integer getSignupOrganisationId() {
+ return signupOrganisationId;
+ }
+
+ public void setSignupOrganisationId(Integer signupOrganisationId) {
+ this.signupOrganisationId = signupOrganisationId;
+ }
+
+ public Integer getOrganisationId() {
+ return organisationId;
+ }
+
+ public void setOrganisationId(Integer organisationId) {
+ this.organisationId = organisationId;
+ }
+
+ public boolean isAddToLessons() {
+ return addToLessons;
+ }
+
+ public void setAddToLessons(boolean addToLessons) {
+ this.addToLessons = addToLessons;
+ }
+
+ public boolean isAddAsStaff() {
+ return addAsStaff;
+ }
+
+ public void setAddAsStaff(boolean addAsStaff) {
+ this.addAsStaff = addAsStaff;
+ }
+
+ public boolean isAddWithAuthor() {
+ return addWithAuthor;
+ }
+
+ public void setAddWithAuthor(boolean addWithAuthor) {
+ this.addWithAuthor = addWithAuthor;
+ }
+
+ public boolean isAddWithMonitor() {
+ return addWithMonitor;
+ }
+
+ public void setAddWithMonitor(boolean addWithMonitor) {
+ this.addWithMonitor = addWithMonitor;
+ }
+
+ public String getCourseKey() {
+ return courseKey;
+ }
+
+ public void setCourseKey(String courseKey) {
+ this.courseKey = courseKey;
+ }
+
+ public String getConfirmCourseKey() {
+ return confirmCourseKey;
+ }
+
+ public void setConfirmCourseKey(String confirmCourseKey) {
+ this.confirmCourseKey = confirmCourseKey;
+ }
+
+ public String getBlurb() {
+ return blurb;
+ }
+
+ public void setBlurb(String blurb) {
+ this.blurb = blurb;
+ }
+
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public boolean isLoginTabActive() {
+ return loginTabActive;
+ }
+
+ public void setLoginTabActive(boolean loginTabActive) {
+ this.loginTabActive = loginTabActive;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+}
+
+
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -32,7 +32,7 @@
*
*
*/
-public class ThemeForm extends ActionForm {
+public class ThemeForm {
private static final long serialVersionUID = -3127221000563399156L;
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/TimezoneForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/TimezoneForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/TimezoneForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class TimezoneForm {
+
+ private String[] selected;
+
+ private String method;
+
+ public String[] getSelected() {
+ return selected;
+ }
+
+ public void setSelected(String[] selected) {
+ this.selected = selected;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+}
+
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,290 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class UserForm {
+
+ private Integer orgId;
+ private Integer userId;
+ private String login;
+ private String password;
+ private String password2;
+ private String changePassword;
+ private Integer authenticationMethodId;
+ private String title;
+ private String firstName;
+ private String lastName;
+ private String addressLine1;
+ private String addressLine2;
+ private String addressLine3;
+ private String city;
+ private String state;
+ private String postcode;
+ private String country;
+ private String dayPhone;
+ private String eveningPhone;
+ private String mobilePhone;
+ private String fax;
+ private String email;
+ private Integer localeId;
+ private boolean tutorialsDisabled = false;
+ private boolean firstLogin = true;
+ private String timeZone;
+ private Long userTheme;
+ private boolean twoFactorAuthenticationEnabled = false;
+ //
+ private Long initialPortraitId = null;
+
+ public Integer getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Integer orgId) {
+ this.orgId = orgId;
+ }
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ public String getLogin() {
+ return login;
+ }
+
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getPassword2() {
+ return password2;
+ }
+
+ public void setPassword2(String password2) {
+ this.password2 = password2;
+ }
+
+ public String getChangePassword() {
+ return changePassword;
+ }
+
+ public void setChangePassword(String changePassword) {
+ this.changePassword = changePassword;
+ }
+
+ public Integer getAuthenticationMethodId() {
+ return authenticationMethodId;
+ }
+
+ public void setAuthenticationMethodId(Integer authenticationMethodId) {
+ this.authenticationMethodId = authenticationMethodId;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getAddressLine1() {
+ return addressLine1;
+ }
+
+ public void setAddressLine1(String addressLine1) {
+ this.addressLine1 = addressLine1;
+ }
+
+ public String getAddressLine2() {
+ return addressLine2;
+ }
+
+ public void setAddressLine2(String addressLine2) {
+ this.addressLine2 = addressLine2;
+ }
+
+ public String getAddressLine3() {
+ return addressLine3;
+ }
+
+ public void setAddressLine3(String addressLine3) {
+ this.addressLine3 = addressLine3;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getPostcode() {
+ return postcode;
+ }
+
+ public void setPostcode(String postcode) {
+ this.postcode = postcode;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ public String getDayPhone() {
+ return dayPhone;
+ }
+
+ public void setDayPhone(String dayPhone) {
+ this.dayPhone = dayPhone;
+ }
+
+ public String getEveningPhone() {
+ return eveningPhone;
+ }
+
+ public void setEveningPhone(String eveningPhone) {
+ this.eveningPhone = eveningPhone;
+ }
+
+ public String getMobilePhone() {
+ return mobilePhone;
+ }
+
+ public void setMobilePhone(String mobilePhone) {
+ this.mobilePhone = mobilePhone;
+ }
+
+ public String getFax() {
+ return fax;
+ }
+
+ public void setFax(String fax) {
+ this.fax = fax;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Integer getLocaleId() {
+ return localeId;
+ }
+
+ public void setLocaleId(Integer localeId) {
+ this.localeId = localeId;
+ }
+
+ public boolean isTutorialsDisabled() {
+ return tutorialsDisabled;
+ }
+
+ public void setTutorialsDisabled(boolean tutorialsDisabled) {
+ this.tutorialsDisabled = tutorialsDisabled;
+ }
+
+ public boolean isFirstLogin() {
+ return firstLogin;
+ }
+
+ public void setFirstLogin(boolean firstLogin) {
+ this.firstLogin = firstLogin;
+ }
+
+ public String getTimeZone() {
+ return timeZone;
+ }
+
+ public void setTimeZone(String timeZone) {
+ this.timeZone = timeZone;
+ }
+
+ public Long getUserTheme() {
+ return userTheme;
+ }
+
+ public void setUserTheme(Long userTheme) {
+ this.userTheme = userTheme;
+ }
+
+ public boolean isTwoFactorAuthenticationEnabled() {
+ return twoFactorAuthenticationEnabled;
+ }
+
+ public void setTwoFactorAuthenticationEnabled(boolean twoFactorAuthenticationEnabled) {
+ this.twoFactorAuthenticationEnabled = twoFactorAuthenticationEnabled;
+ }
+
+ public Long getInitialPortraitId() {
+ return initialPortraitId;
+ }
+
+ public void setInitialPortraitId(Long initialPortraitId) {
+ this.initialPortraitId = initialPortraitId;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserOrgForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserOrgForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserOrgForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,57 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class UserOrgForm {
+
+ private Integer orgId;
+
+ private String orgName;
+
+ private String[] userIds;
+
+ public Integer getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Integer orgId) {
+ this.orgId = orgId;
+ }
+
+ public String getOrgName() {
+ return orgName;
+ }
+
+ public void setOrgName(String orgName) {
+ this.orgName = orgName;
+ }
+
+ public String[] getUserIds() {
+ return userIds;
+ }
+
+ public void setUserIds(String[] userIds) {
+ this.userIds = userIds;
+ }
+
+}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserOrgRoleForm.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserOrgRoleForm.java (.../UserOrgRoleForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserOrgRoleForm.java (.../UserOrgRoleForm.java) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -21,12 +21,10 @@
* ****************************************************************
*/
-
package org.lamsfoundation.lams.admin.web.form;
import java.util.ArrayList;
-import org.apache.struts.action.ActionForm;
import org.lamsfoundation.lams.admin.web.dto.UserBean;
/**
@@ -43,7 +41,7 @@
*
*
*/
-public class UserOrgRoleForm extends ActionForm {
+public class UserOrgRoleForm {
private ArrayList userBeans = new ArrayList();
private Integer orgId;
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserRolesForm.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserRolesForm.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/UserRolesForm.java (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.form;
+
+public class UserRolesForm {
+
+ private Integer orgId;
+
+ private Integer userId;
+
+ private String[] roles; // String []
+
+ public Integer getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Integer orgId) {
+ this.orgId = orgId;
+ }
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ public String[] getRoles() {
+ return roles;
+ }
+
+ public void setRoles(String[] roles) {
+ this.roles = roles;
+ }
+
+}
Index: lams_admin/web/WEB-INF/spring-servlet.xml
===================================================================
diff -u
--- lams_admin/web/WEB-INF/spring-servlet.xml (revision 0)
+++ lams_admin/web/WEB-INF/spring-servlet.xml (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: lams_admin/web/WEB-INF/web.xml
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/web/WEB-INF/web.xml (.../web.xml) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/web/WEB-INF/web.xml (.../web.xml) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -98,6 +98,14 @@
+ spring
+
+ org.springframework.web.servlet.DispatcherServlet
+
+ 1
+
+
+
action
org.apache.struts.action.ActionServlet
@@ -134,7 +142,7 @@
- action
+ spring
*.do
Index: lams_admin/web/cleanup.jsp
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/web/cleanup.jsp (.../cleanup.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/web/cleanup.jsp (.../cleanup.jsp) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -4,17 +4,26 @@
-
+<%-- Error Messages --%>
+
+
+
+
+
+
+
+
-
+
+
-
+
-
+
-
+
:
-
+
-
+ " />
-
+
Index: lams_admin/web/cleanupPreviewLessons.jsp
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/web/cleanupPreviewLessons.jsp (.../cleanupPreviewLessons.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/web/cleanupPreviewLessons.jsp (.../cleanupPreviewLessons.jsp) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -32,9 +32,8 @@
}
$.ajax({
'cache' : false,
- 'url' : ' cleanupPreviewLessons.do',
+ 'url' : ' cleanupPreviewLessons/delete.do',
'data' : {
- 'method' : 'deletePreviewLessons',
'limit' : 5
},
'success' : function(response){
Index: lams_admin/web/organisation/cloneResult.jsp
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/web/organisation/cloneResult.jsp (.../cloneResult.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/web/organisation/cloneResult.jsp (.../cloneResult.jsp) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -1,20 +1,96 @@
+
+
<%@ include file="/taglibs.jsp"%>
+<%@ page import="org.lamsfoundation.lams.usermanagement.OrganisationType" %>
-
+
+
+
+
+ ${title}
-
+
+
+
+
+
+
+
+
+
+
+ ${title}:
+
+
+
+
+
+
+
+ :
+ <%= OrganisationType.CLASS_TYPE %>
+
+ " class="btn btn-default">
+
+ :
+
+ " class="btn btn-default">
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "
+ onclick="document.location='orgmanage.do?org= ';" >
+
+
+
+
+ :
+ <%= OrganisationType.CLASS_TYPE %>
+
+ " class="btn btn-default">
+
+ :
+
+ " class="btn btn-default">
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "
+ onclick="document.location='orgmanage.do?org= ';" >
+
+
+
- "
- onclick="document.location='orgmanage.do?org= ';" >
+
+
+
Index: lams_admin/web/organisation/cloneStart.jsp
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/web/organisation/cloneStart.jsp (.../cloneStart.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/web/organisation/cloneStart.jsp (.../cloneStart.jsp) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -1,213 +1,370 @@
+
+
<%@ include file="/taglibs.jsp"%>
-
+<%@ page import="org.lamsfoundation.lams.usermanagement.OrganisationType" %>
-
-
-
+
+
+
+ ${title}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%--
+ --%>
+
+
+
+
+
+
+ ${title}:
+
+
+
+
+
+
+
+
+ :
+ <%= OrganisationType.CLASS_TYPE %>
+
+ " class="btn btn-default">
+
+ :
+
+ " class="btn btn-default">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+ ...
+
+
+
+ :
+
+
+
+
+ " onclick="javascript:loadGroupAttributes(chosenGroup());">
+
+
+
+
+
" style="display:none;">
+
+
+
+
" style="display:none;">
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ :
+ <%= OrganisationType.CLASS_TYPE %>
+
+ " class="btn btn-default">
+
+ :
+
+ " class="btn btn-default">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+ ...
+
+
+
+ :
+
+
+
+
+ " onclick="javascript:loadGroupAttributes(chosenGroup());">
+
+
+
+
+
" style="display:none;">
+
+
+
+
" style="display:none;">
+
+
+
+
+
+
+
+
-<%--
- --%>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- :
-
- ...
-
-
-
- :
-
-
-
-
- " onclick="javascript:loadGroupAttributes(chosenGroup());">
-
-
-
-
-
" style="display:none;">
-
-
-
-
" style="display:none;">
-
-
-
-
-
\ No newline at end of file
Index: lams_admin/web/taglibs.jsp
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r550e1b37b507779064955267ef47e9085f791357
--- lams_admin/web/taglibs.jsp (.../taglibs.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/web/taglibs.jsp (.../taglibs.jsp) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -1,4 +1,5 @@
<%@ page contentType="text/html; charset=utf-8" language="java" %>
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="tags-lams" prefix="lams" %>
<%@ taglib uri="tags-core" prefix="c" %>
<%@ taglib uri="tags-fmt" prefix="fmt" %>
Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/LearningController.java
===================================================================
diff -u -r3850a2def809bcb85d27c5f796c5e28ac7d36f18 -r550e1b37b507779064955267ef47e9085f791357
--- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/LearningController.java (.../LearningController.java) (revision 3850a2def809bcb85d27c5f796c5e28ac7d36f18)
+++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/LearningController.java (.../LearningController.java) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -72,9 +72,6 @@
* This action handles all the learning actions, which include opening learner,
* relection, going to the next activity, and all the wikipage actions
*
- * It inherits from the WikiPageAction which inherits from the
- * LamsDispatchAction so that common actions can be used in learner, monitor and
- * author
*
* @author lfoxton
* @version
Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/MonitoringController.java
===================================================================
diff -u -r3850a2def809bcb85d27c5f796c5e28ac7d36f18 -r550e1b37b507779064955267ef47e9085f791357
--- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 3850a2def809bcb85d27c5f796c5e28ac7d36f18)
+++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 550e1b37b507779064955267ef47e9085f791357)
@@ -68,9 +68,6 @@
* This action handles all the monitoring actions, which include opening
* monitor, and all the wikipage actions
*
- * It inherits from the WikiPageAction which inherits from the
- * LamsDispatchAction so that common actions can be used in learner, monitor and
- * author
*
* @author lfoxton
*/
@@ -194,7 +191,7 @@
Long currentWikiPageId = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI);
return this.returnToWiki(monitoringForm, request, currentWikiPageId);
}
-
+
@RequestMapping(path = "/toggleLearnerSubsciption", method = RequestMethod.POST)
public String toggleLearnerSubsciption(@ModelAttribute MonitoringForm monitoringForm, HttpServletRequest request)
throws Exception {