📄 membergroupwebhandler.java
字号:
/*
* Copyright (C) 2002 by MyVietnam.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* All copyright notices regarding mvnForum
* must remain intact in the scripts and in the outputted HTML
* The "powered by" text/logo with a link back to
* http://www.mvnForum.com and http://www.MyVietnam.net in the footer of the pages MUST
* remain visible when the pages are viewed on the internet or intranet.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Support can be obtained from support forums at:
* http://www.mvnForum.com/mvnforum/index
*
* Correspondence and Marketing Questions can be sent to:
* info@MyVietnam.net
*
* @author: Minh Nguyen minhnn@MyVietnam.net
* @author: Mai Nguyen mai.nh@MyVietnam.net
*/
package net.myvietnam.mvnplugin.mvnforum.admin;
import javax.servlet.http.*;
import java.sql.*;
import java.util.Collection;
import java.io.StringReader;
import java.io.BufferedReader;
import java.io.IOException;
import net.myvietnam.mvncore.exception.*;
import net.myvietnam.mvncore.util.ParamUtil;
import net.myvietnam.mvncore.util.DateUtil;
import net.myvietnam.mvnplugin.mvnforum.db.MemberGroupBean;
import net.myvietnam.mvnplugin.mvnforum.db.GroupsBean;
import net.myvietnam.mvnplugin.mvnforum.auth.*;
import net.myvietnam.mvnplugin.mvnforum.MVNForumConstant;
class MemberGroupWebHandler {
private OnlineUserManager onlineUserManager = OnlineUserManager.getInstance();
MemberGroupWebHandler() {
}
void processAdd(HttpServletRequest request)
throws IOException, BadInputException, CreateException, DatabaseException,
AuthenticationException, AssertionException {
OnlineUser onlineUser = onlineUserManager.getOnlineUser(request);
MVNForumPermission permission = onlineUser.getPermission();
permission.ensureCanAdminSystem();
Timestamp now = DateUtil.getCurrentGMTTimestamp();
int groupID = ParamUtil.getParameterInt(request, "group");
// check the group
if (groupID == MVNForumConstant.GROUP_ID_OF_GUEST) {
throw new AssertionException("Cannot add member to virtual group Guest.");
}
if (groupID == MVNForumConstant.GROUP_ID_OF_MEMBER) {
// actually it could be ok to list member in this group
throw new AssertionException("Cannot add member to virtual group Member.");
}
String memberNames = ParamUtil.getParameterSafe(request, "MemberNames", true);
int privilege = 0;//ParamUtil.getParameterInt(request, "Privilege");
//System.out.println("member names = " + memberNames);
StringReader stringReader = new StringReader(memberNames);
BufferedReader reader = new BufferedReader(stringReader);
String memberName = null;
while ((memberName = reader.readLine()) != null) {
//System.out.println("name = " + memberName + " length = " + memberName.length());
memberName = memberName.trim();
if (memberName.length() > 0) {
try {
MemberGroupWebHelper.createMemberGroup(groupID, memberName, privilege,
now/*creationDate*/, now/*modifiedDate*/);
} catch (DuplicateKeyException ex) {
// already existed, just ignore
} catch (ForeignKeyNotFoundException ex) {
// member not found, just ignore
}
}// if memberName is not empty
}//while
}
public void prepareList_inGroup_limit(HttpServletRequest request)
throws DatabaseException, BadInputException, AuthenticationException, AssertionException {
OnlineUser onlineUser = onlineUserManager.getOnlineUser(request);
MVNForumPermission permission = onlineUser.getPermission();
permission.ensureCanAdminSystem();
int offset = 0;
int rows = 10;
try {
offset = ParamUtil.getParameterInt(request, "offset");
} catch (BadInputException ex) {}
try {
rows = ParamUtil.getParameterInt(request, "rows");
} catch (BadInputException ex) {}
int groupID = ParamUtil.getParameterInt(request, "group");
// check the group
if (groupID == MVNForumConstant.GROUP_ID_OF_GUEST) {
throw new AssertionException("Cannot list member in virtual group Guest.");
}
if (groupID == MVNForumConstant.GROUP_ID_OF_MEMBER) {
// actually it could be ok to list member in this group
throw new AssertionException("Cannot list member in virtual group Member.");
}
GroupsBean bean = GroupsWebHelper.getGroup(groupID);
Collection beans = MemberGroupWebHelper.getMemberGroups_inGroup_limit(groupID, offset, rows);
request.setAttribute("MemberGroupBeans", beans);
request.setAttribute("GroupsBean", bean);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -