| 1 19 20 package za.org.coefficient.modules.theme; 21 22 import za.org.coefficient.authentication.Role; 23 import za.org.coefficient.html.ThemeSupport; 24 import za.org.coefficient.interfaces.CoefficientContext; 25 import za.org.coefficient.modules.BaseModule; 26 import za.org.coefficient.util.ejb.SecurityUtil; 27 import za.org.coefficient.util.ejb.VelocityScreenUtil; 28 29 import java.util.HashMap ; 30 import java.util.Vector ; 31 32 46 public class ChangeTheme extends BaseModule { 47 49 public String getMainMethod() { 50 return "viewThemes"; 52 } 53 54 public String getModuleDescription() { 55 return "This module allows you to change the overall theme used on the site"; 56 } 57 58 public String getModuleDisplayName() { 59 return "Change Theme"; 60 } 61 62 public String canExecuteForRole(CoefficientContext ctx, String methodName, 63 Role usersHighestRole) { 64 if (usersHighestRole.getRoleValue() > SecurityUtil.SITE_ADMIN_ROLE_VAL) { 65 return "Only a site administrator can change the sites theme"; 66 } else { 67 return null; 68 } 69 } 70 71 public CoefficientContext change(CoefficientContext ctx) { 72 Vector v = ThemeSupport.getThemes(); 73 String theme = ctx.getParameter("theme"); 74 System.out.println("changeTheme.change"); 75 ThemeSupport.changeTheme(theme); 76 ctx.setForward("ChangeTheme"); 77 return ctx; 78 } 79 80 public CoefficientContext viewThemes(CoefficientContext ctx) { 81 Vector v = ThemeSupport.getThemes(); 82 84 HashMap map = new HashMap (); 86 map.put("module", this); 87 map.put("themes", v); 88 StringBuffer sb = 89 VelocityScreenUtil.getProcessedScreen("index.vm", map); 90 91 ctx.setModuleContent(sb.toString(), getModuleDisplayName()); 93 return ctx; 94 } 95 } 96 | Popular Tags |