版主显示

*****************************************
lynx286原创, 首发www.mydwbi.com
http://www.mydwbi.com/posts/list/0/45.page
欢迎转贴, 但转贴请不要删除此段版权说明.
*****************************************

jforum论坛是很流行的java开源论坛,但不支持版主.网友可以查查其他的jforum论坛都没有版主, 这种论坛貌似很不适合中国国情,本人在这里介绍一个显示版主的方法.

1. 为每个板块添加一个群组, 将版主的群组属性改成此群组.
2. 板块的审核属性用默认的"不审核", 原来只有设置成"审核状态"才显示版主,但这样每发一个帖子都要审核,不好.
3. 删除forum_list.htm 第51(57)行那个if语句即可.

其实过程非常简单, 但是网上都没有人研究,尝试解决这个问题.
这样首页就可以显示版主群列表.
如果还要直接显示版主id列表, 则还要进行如下修改:

ForumRepository.java 增加以下函数:
Java代码
public static List getModeratorList2(int forumId) {     
        List ulist = new ArrayList();     
        List l = getModeratorList(forumId);     
        System.out.println("************" + l.size());     
        if (l != null && l.size() > 0) {     
            for (Iterator it = l.iterator(); it.hasNext();) {     
                ModeratorInfo mi = (ModeratorInfo) it.next();     
                int groupId = mi.getId();     
                List users = listGroup(groupId);     
                ulist.addAll(users);     
                System.out.println("========" + users.size());     
            }     
        }     
        return ulist;     
    }     
    
    public static List listGroup(int groupId) {     
        // int groupId = this.request.getIntParameter("group_id");     
    
        int start = preparePagination(DataAccessDriver.getInstance()     
                .newUserDAO().getTotalUsersByGroup(groupId));     
        int usersPerPage = SystemGlobals.getIntValue(ConfigKeys.USERS_PER_PAGE);     
    
        List users = DataAccessDriver.getInstance().newUserDAO()     
                .selectAllByGroup(groupId, start, usersPerPage);     
        return users;     
        // this.context.put("users", users);     
        // this.setTemplateName(TemplateKeys.USER_LIST);     
    }     
    
    private static int preparePagination(int totalUsers) {     
        int start = ViewCommon.getStartPage();     
        int usersPerPage = SystemGlobals.getIntValue(ConfigKeys.USERS_PER_PAGE);     
    
        ViewCommon.contextToPagination(start, totalUsers, usersPerPage);     
    
        return start;     
    }   

public static List getModeratorList2(int forumId) {  
        List ulist = new ArrayList();  
        List l = getModeratorList(forumId);  
        System.out.println("************" + l.size());  
        if (l != null && l.size() > 0) {  
            for (Iterator it = l.iterator(); it.hasNext();) {  
                ModeratorInfo mi = (ModeratorInfo) it.next();  
                int groupId = mi.getId();  
                List users = listGroup(groupId);  
                ulist.addAll(users);  
                System.out.println("========" + users.size());  
            }  
        }  
        return ulist;  
    }  
 
    public static List listGroup(int groupId) {  
        // int groupId = this.request.getIntParameter("group_id");  
 
        int start = preparePagination(DataAccessDriver.getInstance()  
                .newUserDAO().getTotalUsersByGroup(groupId));  
        int usersPerPage = SystemGlobals.getIntValue(ConfigKeys.USERS_PER_PAGE);  
 
        List users = DataAccessDriver.getInstance().newUserDAO()  
                .selectAllByGroup(groupId, start, usersPerPage);  
        return users;  
        // this.context.put("users", users);  
        // this.setTemplateName(TemplateKeys.USER_LIST);  
    }  
 
    private static int preparePagination(int totalUsers) {  
        int start = ViewCommon.getStartPage();  
        int usersPerPage = SystemGlobals.getIntValue(ConfigKeys.USERS_PER_PAGE);  
 
        ViewCommon.contextToPagination(start, totalUsers, usersPerPage);  
 
        return start;  
    } 



forum_list.htm 53-56行改成:
Java代码
<#assign moderators = forumRepository.getModeratorList2(forum.id)/>     
<#list moderators as m>     
<a /user/profile/${m.id}")}">${m.username?html}</a>     
</#list>   

你可能感兴趣的:(html)