1 25 26 package net.killingar.forum.actions.user; 27 28 public class Edit extends net.killingar.forum.actions.user.View 29 { 30 protected String newpassword, newpassword2; 32 protected int year = 1900, month = 0, date = 1; 33 34 boolean modify = false; 35 36 38 40 public void setName(String in) { user.name = in; modify = true; } 42 public void setIcq(String in) { user.icq = in; modify = true; } 43 public void setTelephone(String in) { user.telephone = in; modify = true; } 44 public void setMobilephone(String in) { user.mobilephone = in; modify = true; } 45 public void setAddress(String in) { user.address = in; modify = true; } 46 public void setOther(String in) { user.other = in; modify = true; } 47 public void setRealName(String in) { user.realName = in; modify = true; } 48 public void setPublicEmail(String in) { user.publicEmail = in; modify = true; } 49 public void setRestrictedEmail(String in) { user.restrictedEmail = in; modify = true; } 50 public void setSecretEmail(String in) { user.secretEmail = in; modify = true; } 51 52 public void setYear(int in) { year = in; modify = true; } 53 public void setMonth(int in) { month = in; modify = true; } 54 public void setDate(int in) { date = in; modify = true; } 55 56 public void setNewpassword(String in) { newpassword = in; modify = true; } 57 public void setNewpassword2(String in) { newpassword2 = in; modify = true; } 58 59 public int getYear() { return 1900+user.birthdate.getYear(); } 61 public int getMonth() { return user.birthdate.getMonth(); } 62 public int getDate() { return user.birthdate.getDate(); } 63 64 public Edit() 66 { 67 user = new UserData(); 68 } 69 70 protected void doValidation() 71 { 72 super.doValidation(); 73 74 if (newpassword != null && !newpassword.equals(newpassword2)) 75 addError("newpassword2", "passwords do not match"); 76 } 77 78 protected String doExecute() 79 { 80 user.ID = userID; 81 82 try 83 { 84 String r = INPUT; 85 86 if (modify) 87 { 88 user.birthdate = new java.sql.Date (year-1900, month, date); 89 90 manager.changeUser(user, newpassword); 91 92 r = SUCCESS; 93 } 94 95 user = new UserData(manager, manager.getUser(userID)); 96 97 user.groups = manager.getGroupsOfUser(userID); 98 99 user.email = net.killingar.forum.internal.Utils.unHTML(user.email ); 100 user.icq = net.killingar.forum.internal.Utils.unHTML(user.icq ); 101 user.telephone = net.killingar.forum.internal.Utils.unHTML(user.telephone ); 102 user.mobilephone = net.killingar.forum.internal.Utils.unHTML(user.mobilephone ); 103 user.address = net.killingar.forum.internal.Utils.unHTML(user.address ); 104 user.other = net.killingar.forum.internal.Utils.unHTML(user.other ); 105 user.realName = net.killingar.forum.internal.Utils.unHTML(user.realName ); 106 user.publicEmail = net.killingar.forum.internal.Utils.unHTML(user.publicEmail ); 107 user.restrictedEmail = net.killingar.forum.internal.Utils.unHTML(user.restrictedEmail); 108 user.secretEmail = net.killingar.forum.internal.Utils.unHTML(user.secretEmail ); 109 if (user.birthdate == null) 110 user.birthdate = new java.sql.Date (year-1900, month, date); 111 112 year = user.birthdate.getYear()+1900; 113 month = user.birthdate.getMonth(); 114 date = user.birthdate.getDay(); 115 116 return r; 117 } 118 catch (Exception e) 119 { 120 e.printStackTrace(); 121 addErrorMessage("executing "+getClass().toString()+" action failed, exception thrown: "+e.toString()); 122 return ERROR; 123 } 124 } 125 } | Popular Tags |