001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/RankWebHandler.java,v 1.32 2007/12/17 09:09:40 minhnn Exp $
003: * $Author: minhnn $
004: * $Revision: 1.32 $
005: * $Date: 2007/12/17 09:09:40 $
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.admin;
042:
043: import com.mvnforum.*;
044: import com.mvnforum.auth.*;
045: import com.mvnforum.db.DAOFactory;
046: import com.mvnforum.db.RankBean;
047: import net.myvietnam.mvncore.exception.*;
048: import net.myvietnam.mvncore.security.SecurityUtil;
049: import net.myvietnam.mvncore.service.MvnCoreServiceFactory;
050: import net.myvietnam.mvncore.service.EventLogService;
051: import net.myvietnam.mvncore.util.GenericParamUtil;
052: import net.myvietnam.mvncore.web.GenericRequest;
053: import net.myvietnam.mvncore.web.GenericResponse;
054:
055: public class RankWebHandler {
056:
057: private OnlineUserManager onlineUserManager = OnlineUserManager
058: .getInstance();
059:
060: private static EventLogService eventLogService = MvnCoreServiceFactory
061: .getMvnCoreService().getEventLogService();
062:
063: public RankWebHandler() {
064: }
065:
066: public void processAdd(GenericRequest request,
067: GenericResponse response) throws BadInputException,
068: CreateException, DatabaseException, DuplicateKeyException,
069: AuthenticationException {
070:
071: SecurityUtil.checkHttpPostMethod(request);
072:
073: OnlineUser onlineUser = onlineUserManager
074: .getOnlineUser(request);
075: MVNForumPermission permission = onlineUser.getPermission();
076: permission.ensureCanAdminSystem();
077:
078: MyUtil.saveVNTyperMode(request, response);
079:
080: int rankMinPosts = GenericParamUtil.getParameterInt(request,
081: "RankMinPosts");
082: String rankTitle = GenericParamUtil.getParameterSafe(request,
083: "RankTitle", true);
084:
085: // reserved for future
086: int rankLevel = 0;
087: String rankImage = "";
088: int rankType = 0;
089: int rankOption = 0;
090:
091: DAOFactory.getRankDAO().create(rankMinPosts, rankLevel,
092: rankTitle, rankImage, rankType, rankOption);
093:
094: String actionDesc = MVNForumResourceBundle.getString(
095: MVNForumConfig.getEventLogLocale(),
096: "mvnforum.eventlog.desc.AddRankProcess",
097: new Object[] { rankTitle });
098: eventLogService.logEvent(onlineUser.getMemberName(), request
099: .getRemoteAddr(),
100: MVNForumConstant.EVENT_LOG_MAIN_MODULE,
101: MVNForumConstant.EVENT_LOG_SUB_MODULE_ADMIN,
102: "add rank", actionDesc, EventLogService.MEDIUM);
103:
104: }
105:
106: public void prepareEdit(GenericRequest request)
107: throws BadInputException, DatabaseException,
108: ObjectNotFoundException, AuthenticationException {
109:
110: OnlineUser onlineUser = onlineUserManager
111: .getOnlineUser(request);
112: MVNForumPermission permission = onlineUser.getPermission();
113: permission.ensureCanAdminSystem();
114:
115: // primary key column(s)
116: int rankID = GenericParamUtil.getParameterInt(request, "rank");
117:
118: RankBean rankBean = DAOFactory.getRankDAO().getRank(rankID);
119:
120: request.setAttribute("RankBean", rankBean);
121: }
122:
123: public void prepareList(GenericRequest request)
124: throws DatabaseException, AuthenticationException {
125:
126: OnlineUser onlineUser = onlineUserManager
127: .getOnlineUser(request);
128: MVNForumPermission permission = onlineUser.getPermission();
129: permission.ensureCanAdminSystem();
130: }
131:
132: public void processUpdate(GenericRequest request,
133: GenericResponse response) throws BadInputException,
134: DatabaseException, DuplicateKeyException,
135: ObjectNotFoundException, AuthenticationException {
136:
137: SecurityUtil.checkHttpPostMethod(request);
138:
139: OnlineUser onlineUser = onlineUserManager
140: .getOnlineUser(request);
141: MVNForumPermission permission = onlineUser.getPermission();
142: permission.ensureCanAdminSystem();
143:
144: MyUtil.saveVNTyperMode(request, response);
145:
146: // primary key column(s)
147: int rankID = GenericParamUtil
148: .getParameterInt(request, "RankID");
149:
150: // column(s) to update
151: int rankMinPosts = GenericParamUtil.getParameterInt(request,
152: "RankMinPosts");
153: String rankTitle = GenericParamUtil.getParameterSafe(request,
154: "RankTitle", true);
155:
156: //reserved for future
157: int rankLevel = 0;
158: String rankImage = "";
159: int rankType = 0;
160: int rankOption = 0;
161:
162: DAOFactory.getRankDAO().update(
163: rankID, // primary key
164: rankMinPosts, rankLevel, rankTitle, rankImage,
165: rankType, rankOption);
166: }
167:
168: public void processDelete(GenericRequest request)
169: throws BadInputException, DatabaseException,
170: ObjectNotFoundException, AuthenticationException {
171:
172: OnlineUser onlineUser = onlineUserManager
173: .getOnlineUser(request);
174: MVNForumPermission permission = onlineUser.getPermission();
175: permission.ensureCanAdminSystem();
176:
177: // primary key column(s)
178: int rankID = GenericParamUtil.getParameterInt(request, "rank");
179:
180: DAOFactory.getRankDAO().delete(rankID);
181:
182: String actionDesc = MVNForumResourceBundle.getString(
183: MVNForumConfig.getEventLogLocale(),
184: "mvnforum.eventlog.desc.DeleteRankProcess",
185: new Object[] { new Integer(rankID) });
186: eventLogService.logEvent(onlineUser.getMemberName(), request
187: .getRemoteAddr(),
188: MVNForumConstant.EVENT_LOG_MAIN_MODULE,
189: MVNForumConstant.EVENT_LOG_SUB_MODULE_ADMIN,
190: "delete rank", actionDesc, EventLogService.HIGH);
191:
192: }
193:
194: }
|