001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/db/MemberBean.java,v 1.35 2007/10/18 04:30:58 lexuanttkhtn Exp $
003: * $Author: lexuanttkhtn $
004: * $Revision: 1.35 $
005: * $Date: 2007/10/18 04:30:58 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Minh Nguyen
039: * @author: Mai Nguyen
040: */
041: package com.mvnforum.db;
042:
043: import java.sql.Date;
044: import java.sql.Timestamp;
045:
046: import javax.servlet.http.HttpServletRequest;
047: import javax.servlet.http.HttpServletResponse;
048:
049: import net.myvietnam.mvncore.security.Encoder;
050: import net.myvietnam.mvncore.service.BinaryStorageService;
051: import net.myvietnam.mvncore.service.MvnCoreServiceFactory;
052: import net.myvietnam.mvncore.util.DateUtil;
053: import net.myvietnam.mvncore.util.StringUtil;
054:
055: import com.mvnforum.MVNForumGlobal;
056:
057: /*
058: * Included columns: MemberID, MemberName, MemberFirstEmail, MemberEmail, MemberEmailVisible,
059: * MemberNameVisible, MemberFirstIP, MemberLastIP, MemberViewCount, MemberPostCount,
060: * MemberCreationDate, MemberModifiedDate, MemberLastLogon, MemberOption, MemberStatus,
061: * MemberActivateCode, MemberMessageCount, MemberMessageOption, MemberPostsPerPage, MemberWarnCount,
062: * MemberVoteCount, MemberVoteTotalStars, MemberRewardPoints, MemberTitle, MemberTimeZone,
063: * MemberSignature, MemberAvatar, MemberSkin, MemberLanguage, MemberFirstname,
064: * MemberLastname, MemberGender, MemberBirthday, MemberAddress, MemberCity,
065: * MemberState, MemberCountry, MemberPhone, MemberMobile, MemberFax,
066: * MemberCareer, MemberHomepage, MemberYahoo, MemberAol, MemberIcq,
067: * MemberMsn, MemberCoolLink1, MemberCoolLink2
068: * Excluded columns: MemberPassword, MemberTempPassword
069: */
070: public class MemberBean {
071:
072: public static final int MEMBER_STATUS_ENABLE = 0;
073: public static final int MEMBER_STATUS_DISABLE = 1;
074: public static final int MEMBER_STATUS_PENDING = 2;
075: public static final int MEMBER_STATUS_DELETED = 3;
076:
077: public static final int MEMBER_GENDER_FEMALE = 0;
078: public static final int MEMBER_GENDER_MALE = 1;
079:
080: public static final int MEMBER_EMAIL_INVISIBLE = 0;
081: public static final int MEMBER_EMAIL_VISIBLE = 1;
082:
083: public static final int MEMBER_NAME_INVISIBLE = 0;
084: public static final int MEMBER_NAME_VISIBLE = 1;
085:
086: public static final String MEMBER_ACTIVATECODE_ACTIVATED = "activated";
087:
088: public static final String MEMBER_AVATAR_USING_UPLOAD = "uploaded";
089:
090: private int memberID;
091: private String memberName;
092: private String memberFirstEmail;
093: private String memberEmail;
094: private int memberEmailVisible;
095: private int memberNameVisible;
096: private String memberFirstIP;
097: private String memberLastIP;
098: private int memberViewCount;
099: private int memberPostCount;
100: private Timestamp memberCreationDate;
101: private Timestamp memberModifiedDate;
102: private Timestamp memberExpireDate;
103: private Timestamp memberPasswordExpireDate;
104: private Timestamp memberLastLogon;
105: private int memberOption;
106: private int memberStatus;
107: private String memberActivateCode;
108: private int memberMessageCount;
109: private int memberMessageOption;
110: private int memberPostsPerPage;
111: private int memberWarnCount;
112: private int memberVoteCount;
113: private int memberVoteTotalStars;
114: private int memberRewardPoints;
115: private String memberTitle;
116: private double memberTimeZone;
117: private String memberSignature;
118: private String memberAvatar;
119: private String memberSkin;
120: private String memberLanguage;
121: private String memberFirstname;
122: private String memberLastname;
123: private int memberGender;
124: private Date memberBirthday;
125: private String memberAddress;
126: private String memberCity;
127: private String memberState;
128: private String memberCountry;
129: private String memberPhone;
130: private String memberMobile;
131: private String memberFax;
132: private String memberCareer;
133: private String memberHomepage;
134: private String memberYahoo;
135: private String memberAol;
136: private String memberIcq;
137: private String memberMsn;
138: private String memberCoolLink1;
139: private String memberCoolLink2;
140:
141: public int getMemberID() {
142: return memberID;
143: }
144:
145: public void setMemberID(int memberID) {
146: this .memberID = memberID;
147: }
148:
149: public String getMemberName() {
150: return memberName;
151: }
152:
153: public void setMemberName(String memberName) {
154: this .memberName = memberName;
155: }
156:
157: public String getMemberFirstEmail() {
158: return memberFirstEmail;
159: }
160:
161: public void setMemberFirstEmail(String memberFirstEmail) {
162: this .memberFirstEmail = StringUtil
163: .getEmptyStringIfNull(memberFirstEmail);
164: }
165:
166: public String getMemberEmail() {
167: return memberEmail;
168: }
169:
170: public void setMemberEmail(String memberEmail) {
171: this .memberEmail = StringUtil.getEmptyStringIfNull(memberEmail);
172: }
173:
174: public int getMemberEmailVisible() {
175: return memberEmailVisible;
176: }
177:
178: public void setMemberEmailVisible(int memberEmailVisible) {
179: this .memberEmailVisible = memberEmailVisible;
180: }
181:
182: public int getMemberNameVisible() {
183: return memberNameVisible;
184: }
185:
186: public void setMemberNameVisible(int memberNameVisible) {
187: this .memberNameVisible = memberNameVisible;
188: }
189:
190: public String getMemberFirstIP() {
191: return memberFirstIP;
192: }
193:
194: public void setMemberFirstIP(String memberFirstIP) {
195: this .memberFirstIP = StringUtil
196: .getEmptyStringIfNull(memberFirstIP);
197: }
198:
199: public String getMemberLastIP() {
200: return memberLastIP;
201: }
202:
203: public void setMemberLastIP(String memberLastIP) {
204: this .memberLastIP = StringUtil
205: .getEmptyStringIfNull(memberLastIP);
206: }
207:
208: public int getMemberViewCount() {
209: return memberViewCount;
210: }
211:
212: public void setMemberViewCount(int memberViewCount) {
213: this .memberViewCount = memberViewCount;
214: }
215:
216: public int getMemberPostCount() {
217: return memberPostCount;
218: }
219:
220: public void setMemberPostCount(int memberPostCount) {
221: this .memberPostCount = memberPostCount;
222: }
223:
224: public Timestamp getMemberCreationDate() {
225: return memberCreationDate;
226: }
227:
228: public void setMemberCreationDate(Timestamp memberCreationDate) {
229: this .memberCreationDate = memberCreationDate;
230: }
231:
232: public Timestamp getMemberModifiedDate() {
233: return memberModifiedDate;
234: }
235:
236: public void setMemberModifiedDate(Timestamp memberModifiedDate) {
237: this .memberModifiedDate = memberModifiedDate;
238: }
239:
240: public Timestamp getMemberExpireDate() {
241: return memberExpireDate;
242: }
243:
244: public void setMemberExpireDate(Timestamp memberExpireDate) {
245: this .memberExpireDate = memberExpireDate;
246: }
247:
248: public void setMemberPasswordExpireDate(
249: Timestamp MemberPasswordExpireDate) {
250: this .memberPasswordExpireDate = MemberPasswordExpireDate;
251: }
252:
253: public Timestamp getMemberPasswordExpireDate() {
254: return memberPasswordExpireDate;
255: }
256:
257: public Timestamp getMemberLastLogon() {
258: return memberLastLogon;
259: }
260:
261: public void setMemberLastLogon(Timestamp memberLastLogon) {
262: this .memberLastLogon = memberLastLogon;
263: }
264:
265: public int getMemberOption() {
266: return memberOption;
267: }
268:
269: public void setMemberOption(int memberOption) {
270: this .memberOption = memberOption;
271: }
272:
273: public int getMemberStatus() {
274: return memberStatus;
275: }
276:
277: public void setMemberStatus(int memberStatus) {
278: this .memberStatus = memberStatus;
279: }
280:
281: public String getMemberActivateCode() {
282: return memberActivateCode;
283: }
284:
285: public void setMemberActivateCode(String memberActivateCode) {
286: this .memberActivateCode = StringUtil
287: .getEmptyStringIfNull(memberActivateCode);
288: }
289:
290: public int getMemberMessageCount() {
291: return memberMessageCount;
292: }
293:
294: public void setMemberMessageCount(int memberMessageCount) {
295: this .memberMessageCount = memberMessageCount;
296: }
297:
298: public int getMemberMessageOption() {
299: return memberMessageOption;
300: }
301:
302: public void setMemberMessageOption(int memberMessageOption) {
303: this .memberMessageOption = memberMessageOption;
304: }
305:
306: public int getMemberPostsPerPage() {
307: return memberPostsPerPage;
308: }
309:
310: public void setMemberPostsPerPage(int memberPostsPerPage) {
311: this .memberPostsPerPage = memberPostsPerPage;
312: }
313:
314: public int getMemberWarnCount() {
315: return memberWarnCount;
316: }
317:
318: public void setMemberWarnCount(int memberWarnCount) {
319: this .memberWarnCount = memberWarnCount;
320: }
321:
322: public int getMemberVoteCount() {
323: return memberVoteCount;
324: }
325:
326: public void setMemberVoteCount(int memberVoteCount) {
327: this .memberVoteCount = memberVoteCount;
328: }
329:
330: public int getMemberVoteTotalStars() {
331: return memberVoteTotalStars;
332: }
333:
334: public void setMemberVoteTotalStars(int memberVoteTotalStars) {
335: this .memberVoteTotalStars = memberVoteTotalStars;
336: }
337:
338: public int getMemberRewardPoints() {
339: return memberRewardPoints;
340: }
341:
342: public void setMemberRewardPoints(int memberRewardPoints) {
343: this .memberRewardPoints = memberRewardPoints;
344: }
345:
346: public String getMemberTitle() {
347: return memberTitle;
348: }
349:
350: public void setMemberTitle(String memberTitle) {
351: this .memberTitle = StringUtil.getEmptyStringIfNull(memberTitle);
352: }
353:
354: public double getMemberTimeZone() {
355: return memberTimeZone;
356: }
357:
358: public void setMemberTimeZone(double memberTimeZone) {
359: this .memberTimeZone = memberTimeZone;
360: }
361:
362: public String getMemberSignature() {
363: return memberSignature;
364: }
365:
366: public void setMemberSignature(String memberSignature) {
367: this .memberSignature = StringUtil
368: .getEmptyStringIfNull(memberSignature);
369: }
370:
371: public String getMemberAvatar() {
372: return memberAvatar;
373: }
374:
375: public void setMemberAvatar(String memberAvatar) {
376: this .memberAvatar = StringUtil
377: .getEmptyStringIfNull(memberAvatar);
378: }
379:
380: public String getMemberSkin() {
381: return memberSkin;
382: }
383:
384: public void setMemberSkin(String memberSkin) {
385: this .memberSkin = StringUtil.getEmptyStringIfNull(memberSkin);
386: }
387:
388: public String getMemberLanguage() {
389: return memberLanguage;
390: }
391:
392: public void setMemberLanguage(String memberLanguage) {
393: this .memberLanguage = StringUtil
394: .getEmptyStringIfNull(memberLanguage);
395: }
396:
397: public String getMemberFirstname() {
398: return memberFirstname;
399: }
400:
401: public void setMemberFirstname(String memberFirstname) {
402: this .memberFirstname = StringUtil
403: .getEmptyStringIfNull(memberFirstname);
404: }
405:
406: public String getMemberLastname() {
407: return memberLastname;
408: }
409:
410: public void setMemberLastname(String memberLastname) {
411: this .memberLastname = StringUtil
412: .getEmptyStringIfNull(memberLastname);
413: }
414:
415: public int getMemberGender() {
416: return memberGender;
417: }
418:
419: public void setMemberGender(int memberGender) {
420: this .memberGender = memberGender;
421: }
422:
423: public Date getMemberBirthday() {
424: return memberBirthday;
425: }
426:
427: public void setMemberBirthday(Date memberBirthday) {
428: this .memberBirthday = memberBirthday;
429: }
430:
431: public String getMemberAddress() {
432: return memberAddress;
433: }
434:
435: public void setMemberAddress(String memberAddress) {
436: this .memberAddress = StringUtil
437: .getEmptyStringIfNull(memberAddress);
438: }
439:
440: public String getMemberCity() {
441: return memberCity;
442: }
443:
444: public void setMemberCity(String memberCity) {
445: this .memberCity = StringUtil.getEmptyStringIfNull(memberCity);
446: }
447:
448: public String getMemberState() {
449: return memberState;
450: }
451:
452: public void setMemberState(String memberState) {
453: this .memberState = StringUtil.getEmptyStringIfNull(memberState);
454: }
455:
456: public String getMemberCountry() {
457: return memberCountry;
458: }
459:
460: public void setMemberCountry(String memberCountry) {
461: this .memberCountry = StringUtil
462: .getEmptyStringIfNull(memberCountry);
463: }
464:
465: public String getMemberPhone() {
466: return memberPhone;
467: }
468:
469: public void setMemberPhone(String memberPhone) {
470: this .memberPhone = StringUtil.getEmptyStringIfNull(memberPhone);
471: }
472:
473: public String getMemberMobile() {
474: return memberMobile;
475: }
476:
477: public void setMemberMobile(String memberMobile) {
478: this .memberMobile = StringUtil
479: .getEmptyStringIfNull(memberMobile);
480: }
481:
482: public String getMemberFax() {
483: return memberFax;
484: }
485:
486: public void setMemberFax(String memberFax) {
487: this .memberFax = StringUtil.getEmptyStringIfNull(memberFax);
488: }
489:
490: public String getMemberCareer() {
491: return memberCareer;
492: }
493:
494: public void setMemberCareer(String memberCareer) {
495: this .memberCareer = StringUtil
496: .getEmptyStringIfNull(memberCareer);
497: }
498:
499: public String getMemberHomepage() {
500: return memberHomepage;
501: }
502:
503: public void setMemberHomepage(String memberHomepage) {
504: this .memberHomepage = StringUtil
505: .getEmptyStringIfNull(memberHomepage);
506: }
507:
508: public String getMemberYahoo() {
509: return memberYahoo;
510: }
511:
512: public void setMemberYahoo(String memberYahoo) {
513: this .memberYahoo = StringUtil.getEmptyStringIfNull(memberYahoo);
514: }
515:
516: public String getMemberAol() {
517: return memberAol;
518: }
519:
520: public void setMemberAol(String memberAol) {
521: this .memberAol = StringUtil.getEmptyStringIfNull(memberAol);
522: }
523:
524: public String getMemberIcq() {
525: return memberIcq;
526: }
527:
528: public void setMemberIcq(String memberIcq) {
529: this .memberIcq = StringUtil.getEmptyStringIfNull(memberIcq);
530: }
531:
532: public String getMemberMsn() {
533: return memberMsn;
534: }
535:
536: public void setMemberMsn(String memberMsn) {
537: this .memberMsn = StringUtil.getEmptyStringIfNull(memberMsn);
538: }
539:
540: public String getMemberCoolLink1() {
541: return memberCoolLink1;
542: }
543:
544: public void setMemberCoolLink1(String memberCoolLink1) {
545: this .memberCoolLink1 = StringUtil
546: .getEmptyStringIfNull(memberCoolLink1);
547: }
548:
549: public String getMemberCoolLink2() {
550: return memberCoolLink2;
551: }
552:
553: public void setMemberCoolLink2(String memberCoolLink2) {
554: this .memberCoolLink2 = StringUtil
555: .getEmptyStringIfNull(memberCoolLink2);
556: }
557:
558: /////////////////////////////////////////////////////////////////
559: // utility methods
560: /*
561: * @todo : review these methods
562: */
563: public String getMemberGenderString() {
564: if (memberGender == MEMBER_GENDER_MALE)
565: return "Male";
566: return "Female";
567: }
568:
569: public String getMemberAvatar_processed(HttpServletRequest request,
570: HttpServletResponse response) {
571: if (memberAvatar.length() == 0) {// never null here, see setMemberAvatar
572: return "";
573: }
574: String retMemberAvatar = memberAvatar;
575: if (retMemberAvatar
576: .equals(MemberBean.MEMBER_AVATAR_USING_UPLOAD)
577: || retMemberAvatar
578: .startsWith(BinaryStorageService.BINARY_STORAGE)
579: || retMemberAvatar
580: .startsWith(MVNForumGlobal.UPLOADED_AVATAR_DIR)) {
581: //relative path
582: retMemberAvatar = "getavatar?memberid=" + memberID;
583: retMemberAvatar = MvnCoreServiceFactory.getMvnCoreService()
584: .getURLResolverService().encodeURL(request,
585: response, retMemberAvatar);
586: } else {
587: // this mean use mvnForum's default avatar
588: if (memberAvatar.startsWith("/mvnplugin")) {
589: // no context prefix, so we prepend the contextPath
590: retMemberAvatar = request.getContextPath()
591: + memberAvatar;
592: }
593: }
594: return retMemberAvatar;
595: }
596:
597: public String getMemberHomepage_http() {
598: if (memberHomepage == null)
599: memberHomepage = "";
600: return Encoder.filterUrl(memberHomepage);
601: /*
602: String ret = memberHomepage.toLowerCase();
603: if ( (ret.length() > 0) && (!ret.startsWith("http://")) ) {
604: ret = "http://" + ret;
605: }
606: return ret;
607: */
608: }
609:
610: public String getMemberCoolLink1_http() {
611: if (memberCoolLink1 == null)
612: memberCoolLink1 = "";
613: return Encoder.filterUrl(memberCoolLink1);
614: /*
615: String ret = memberCoolLink1.toLowerCase();
616: if ( (ret.length() > 0) && (!ret.startsWith("http://")) ) {
617: ret = "http://" + ret;
618: }
619: return ret;
620: */
621: }
622:
623: public String getMemberCoolLink2_http() {
624: if (memberCoolLink2 == null)
625: memberCoolLink2 = "";
626: return Encoder.filterUrl(memberCoolLink2);
627: /*
628: String ret = memberCoolLink2.toLowerCase();
629: if ( (ret.length() > 0) && (!ret.startsWith("http://")) ) {
630: ret = "http://" + ret;
631: }
632: return ret;
633: */
634: }
635:
636: public String getMemberCreationDate_short() {
637: return DateUtil.getDateDDMMYYYY(memberCreationDate);
638: }
639:
640: public String getMemberExpireDate_short() {
641: return DateUtil.getDateDDMMYYYY(memberExpireDate);
642: }
643:
644: public boolean isInvisible() {
645: return (this .memberNameVisible == MEMBER_NAME_INVISIBLE);
646: }
647:
648: public boolean showEmail() {
649: return (this .memberEmailVisible == MEMBER_EMAIL_VISIBLE);
650: }
651:
652: public void init() {
653: //setMemberID(resultSet.getInt("MemberID"));
654: Timestamp now = DateUtil.getCurrentGMTTimestamp();
655: setMemberName("");
656: setMemberEmail("");
657: setMemberEmailVisible(MEMBER_EMAIL_INVISIBLE);
658: setMemberNameVisible(MEMBER_NAME_VISIBLE);
659: setMemberViewCount(0);
660: setMemberPostCount(0);
661: setMemberCreationDate(now);
662: setMemberLastLogon(now);
663: setMemberPasswordExpireDate(now);
664: setMemberOption(0);
665: setMemberStatus(MEMBER_STATUS_ENABLE);
666: setMemberWarnCount(0);
667: setMemberVoteCount(0);
668: setMemberVoteTotalStars(0);
669: setMemberRewardPoints(0);
670: setMemberTitle("");
671: setMemberSignature("");
672: setMemberAvatar("");
673: setMemberFirstname("");
674: setMemberLastname("");
675: setMemberGender(MEMBER_GENDER_MALE);
676: setMemberBirthday(new java.sql.Date(0));
677: setMemberAddress("");
678: setMemberCity("");
679: setMemberState("");
680: setMemberCountry("");
681: setMemberPhone("");
682: setMemberMobile("");
683: setMemberFax("");
684: setMemberCareer("");
685: setMemberHomepage("");
686: setMemberYahoo("");
687: setMemberAol("");
688: setMemberIcq("");
689: setMemberMsn("");
690: setMemberCoolLink1("");
691: setMemberCoolLink2("");
692: setMemberActivateCode("");
693: }
694:
695: static public void validateMemberStatus(int status)
696: throws IllegalArgumentException {
697: if ((status < MEMBER_STATUS_ENABLE)
698: || (status > MEMBER_STATUS_DELETED)) {
699: throw new IllegalArgumentException(
700: "Invalid MemberStatus = " + status);
701: }
702: }
703:
704: } //end of class MemberBean
|