1 53 54 106 107 package com.Yasna.forum.tags; 108 109 import java.io.*; 110 import java.util.*; 111 import javax.servlet.*; 112 import javax.servlet.jsp.*; 113 import javax.servlet.jsp.tagext.*; 114 import javax.servlet.http.*; 115 import com.Yasna.forum.*; 116 import com.Yasna.forum.tags.*; 117 118 155 public class UserTag extends TagSupport implements YazdProperty 156 { 157 private YazdRequest jr = null; 158 private YazdState js = null; 159 private User ui = null; 160 161 170 public final int doStartTag() throws JspException 171 { 172 jr = (YazdRequest)pageContext.getAttribute("yazdUserRequest", 174 PageContext.REQUEST_SCOPE); 175 if( jr == null ) 176 throw new JspException("Yazd user tag, could not find request"); 177 178 MessageTag mt = null; 180 try { 181 mt = (MessageTag)this.findAncestorWithClass(this, 182 Class.forName("com.Yasna.forum.tags.MessageTag")); 183 } catch(Exception e) { 184 } 185 186 if( mt != null ) { 187 ui = mt.getUser(); 188 } 189 190 if( ui == null ) { 192 ServletRequest req = pageContext.getRequest(); 195 String tmp; 196 if( (tmp = req.getParameter("username")) != null ) { 197 ProfileManager pm = jr.getProfileManager(); 198 try { 199 ui = pm.getUser(tmp); 200 } catch(UserNotFoundException e) {} 201 } 202 } 203 204 if( ui == null ) { 205 return SKIP_BODY; 206 } 207 208 pageContext.setAttribute(id,this,PageContext.PAGE_SCOPE); 210 return EVAL_BODY_INCLUDE; 211 } 212 213 219 public final String getEmail() 220 { 221 String email; 222 223 email = ui.getEmail(); 224 if( email == null ) 225 return ""; 226 return email; 227 } 228 229 235 public final String getName() 236 { 237 String name; 238 239 name = ui.getName(); 240 if( name == null ) 241 return ""; 242 return name; 243 } 244 245 251 public final String getUsername() 252 { 253 return ui.getUsername(); 254 } 255 256 public final boolean getAnonymous() { 257 return ui.isAnonymous(); 258 } 259 260 266 public final String getProperty(String name) 267 { 268 if( name.equals("password") ) 270 return ""; 271 String tmp = ui.getProperty(name); 272 if( tmp != null )return tmp; 273 return ""; 274 } 275 276 280 public final void setProperty(String name, String value) 281 { 282 } 283 284 287 public final void release() 288 { 289 if( id != null && id.length() > 0 ) 290 pageContext.removeAttribute(id,PageContext.PAGE_SCOPE); 291 } 292 } 293 | Popular Tags |