1 31 32 package org.opencms.workplace.commons; 33 34 import org.opencms.file.CmsGroup; 35 import org.opencms.file.CmsUser; 36 import org.opencms.jsp.CmsJspActionElement; 37 import org.opencms.workplace.CmsDialog; 38 import org.opencms.workplace.CmsWorkplaceSettings; 39 40 import java.util.List ; 41 import java.util.Vector ; 42 43 import javax.servlet.http.HttpServletRequest ; 44 import javax.servlet.http.HttpServletResponse ; 45 import javax.servlet.jsp.JspException ; 46 import javax.servlet.jsp.PageContext ; 47 48 63 public class CmsChaccBrowser extends CmsDialog { 64 65 66 public static final String DIALOG_FRAME_GROUPS = "groups"; 67 68 public static final String DIALOG_FRAME_USERS = "users"; 69 70 71 public static final String DIALOG_TYPE = "chaccbrowser"; 72 73 74 public static final int FRAME_DEFAULT = 1; 75 76 public static final int FRAME_GROUPS = 100; 77 78 public static final int FRAME_USERS = 200; 79 80 81 public static final String PARAM_FRAME = "frame"; 82 private int m_frame; 83 84 private String m_paramFrame; 85 86 91 public CmsChaccBrowser(CmsJspActionElement jsp) { 92 93 super(jsp); 94 } 95 96 103 public CmsChaccBrowser(PageContext context, HttpServletRequest req, HttpServletResponse res) { 104 105 this(new CmsJspActionElement(context, req, res)); 106 } 107 108 114 public String buildGroupList() throws JspException { 115 116 List groups = new Vector (); 117 StringBuffer retValue = new StringBuffer (1024); 118 try { 119 groups = getCms().getGroups(); 120 } catch (Throwable e) { 121 includeErrorpage(this, e); 123 } 124 125 for (int i = 0; i < groups.size(); i++) { 126 CmsGroup curGroup = (CmsGroup)groups.get(i); 127 retValue.append(buildEntryGroup(curGroup)); 128 } 129 return retValue.toString(); 130 } 131 132 138 public String buildUserList() throws JspException { 139 140 List users = new Vector (); 141 StringBuffer retValue = new StringBuffer (1024); 142 try { 143 users = getCms().getUsers(); 144 } catch (Throwable e) { 145 includeErrorpage(this, e); 147 } 148 149 for (int i = 0; i < users.size(); i++) { 150 CmsUser curUser = (CmsUser)users.get(i); 151 retValue.append(buildEntryUser(curUser)); 152 } 153 return retValue.toString(); 154 } 155 156 161 public int getFrame() { 162 163 return m_frame; 164 } 165 166 174 public String getParamFrame() { 175 176 return m_paramFrame; 177 } 178 179 184 public void setFrame(int value) { 185 186 m_frame = value; 187 } 188 189 194 public void setParamFrame(String value) { 195 196 m_paramFrame = value; 197 } 198 199 202 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 203 204 fillParamValues(request); 206 setParamDialogtype(DIALOG_TYPE); 208 if (DIALOG_FRAME_GROUPS.equals(getParamFrame())) { 209 setFrame(FRAME_GROUPS); 210 } else if (DIALOG_FRAME_USERS.equals(getParamFrame())) { 211 setFrame(FRAME_USERS); 212 } else { 213 setFrame(FRAME_DEFAULT); 214 } 215 } 216 217 223 private StringBuffer buildEntryGroup(CmsGroup group) { 224 225 StringBuffer retValue = new StringBuffer (256); 226 retValue.append("<span class=\"dialogunmarked maxwidth\" onmouseover=\"className='dialogmarked maxwidth';\""); 227 retValue.append(" onmouseout=\"className='dialogunmarked maxwidth'\" onclick=\"top.selectForm('0','"); 228 retValue.append(group.getName()); 229 retValue.append("');\">"); 230 retValue.append("<img SRC=\""); 231 retValue.append(getSkinUri()); 232 retValue.append("commons/group.png\"> "); 233 retValue.append(group.getName()); 234 retValue.append("</span>"); 235 return retValue; 236 } 237 238 244 private StringBuffer buildEntryUser(CmsUser user) { 245 246 StringBuffer retValue = new StringBuffer (384); 247 retValue.append("<span class=\"dialogunmarked maxwidth\" onmouseover=\"className='dialogmarked maxwidth';\""); 248 retValue.append(" onmouseout=\"className='dialogunmarked maxwidth'\" onclick=\"top.selectForm('1','"); 249 retValue.append(user.getName()); 250 retValue.append("');\">"); 251 retValue.append("<img SRC=\"" + getSkinUri() + "commons/user.png\"> "); 252 retValue.append(user.getName()); 253 if (!"".equals(user.getFirstname()) || !"".equals(user.getLastname())) { 254 retValue.append(" ("); 255 retValue.append(user.getFirstname()); 256 retValue.append(" "); 257 retValue.append(user.getLastname()); 258 retValue.append(")"); 259 } 260 retValue.append("</span>"); 261 return retValue; 262 } 263 264 } 265 | Popular Tags |