![]() |
十鼎 wrote:问题5:指定版面的版主却可以删除其他版面的文章或者主题。
首先在管理后台的“会员分组”为一个会员所在的群组设置权限: 版主->是否允许设置为版主 设置为“是”;是否在允许的版块里审核/封锁贴子 设置为“是”;不能修改的论坛 设置为指定版面除外的所有其他版面。
这样就可以将某个会员设置为指定版面的版主了(我是这么理解的)。现在的问题是一个版面的版主不应该有权修改或者删除其他版面的主题的文章,除非该文章是他(她)发布的。
问题6:在封锁控制中添加了对某个用户ID的封锁,登陆后得到已经被封锁的提示,但是无法再以游客的身份浏览本网站了,点击"注销"和"论坛首页"都没有任何响应。 合理的希望应该是点击"注销"和"论坛首页"时以游客身份回到首页。
this.context.put("karmaEnabled", SecurityRepository.canAccess(SecurityConstants.PERM_KARMA_ENABLED));
this.context.put("rank", new RankingRepository());
this.context.put("u", user);
this.context.put("avatarAllowExternalUrl", SystemGlobals.getBoolValue(ConfigKeys.AVATAR_ALLOW_EXTERNAL_URL));
int loggedId = SessionFacade.getUserSession().getUserId();
int count = 0;
DataAccessDriver da = DataAccessDriver.getInstance();
List<Bookmark> bookmarks = da.newBookmarkDAO().selectByUser(user.getId());
if(loggedId == user.getId())
count = bookmarks.size();
else{
for (Iterator<Bookmark> iter = bookmarks.iterator(); iter.hasNext(); ) {
Bookmark bookmark = iter.next();
if (bookmark.isPublicVisible()) {
count++;
}
}
}
this.context.put("nbookmarks", Integer.valueOf(count));
this.context.put("ntopics", Integer.valueOf(da.newTopicDAO().countUserTopics(user.getId())));
this.context.put("nposts", Integer.valueOf(da.newPostDAO().countUserPosts(user.getId())));
this.context.put("tally", Integer.valueOf(da.newUserDAO().getUserTally(user.getId())));
|
|
檔案名稱 | 自己个人资料入口.jpg |
描述 | 自己的个人资料查看入口功能 |
檔案大小 | 121 Kbytes |
下載次數 | 0 次 |
![]() |
十鼎 wrote:问题7、似乎无法使用文章审核功能?
十鼎 wrote:为了增加积分功能,我为数据库表jforum_users添加了一个字段tally(类型为int,默认值为0),并修改了需要的相关SQL语句和数据库操作代码(主要是读取和更新user info),并为net.jforum.entities.User类添加成员 int tally;以及get、set函数。
看了下数据库表jforum_posts里面,没有7天内的post记录。
构建项目的时候出现以下错误提示:
------------------------------
...
Failed tests:
testListPosts(net.jforum.summary.SummaryTest): null
Tests run: 62, Failures: 1, Errors: 0, Skipped: 0
...
------------------------------
分析代码,失败原因是testListPosts函数中的获取一周post list为空。我并不十分理解这里的post list是由哪部分测试用例创建的,是SummaryTest用例产生的,还是包含了本次构建所有测试用例产生的?跟我修改jforum_users 的表结构是否有关联?
我查看了关于获取和更新jforum_posts表的SQL语句和相关操作代码,看起来并没有与Jforum_users的tally字段有相交。
请andowson指教一二! 如能介绍下项目的测试用例功能的概况和原理就更佳了。
谢谢了!
这个问题经过半天的了解,总结一下:
构建过程中使用到的数据库是由执行脚本文件:mysql_data_dump.sql更新的,所以开始构建项目前需要执行一下这个脚本,执行后,jforum_posts表中多了一个表项,内容为:“Welcome to JForum”。
每次构建过程执行的SummaryTest用例会测试发送发表文章摘要功能,这个用例使用的时间范围是7天,如果执行脚本mysql_data_dump.sql超过7天,即7天内没有新发表文章,则构建项目时该测试用例会得到空的post list。
这个测试用例似乎需要重新考虑文章摘要的时间范围。
andowson wrote:十鼎 wrote:为主题的文章进行缓存功能,我感觉有问题(我的理解),如果我理解有误还请指教。楼主,你的理解如何?
應該是有問題沒錯,有可能是我誤改了原來的程式碼
trunk/src/main/java/net/jforum/repository/PostRepository.java的118行:
[code=java; first-line:118]posts = pm.selectAllByTopicByLimit(topicId, start, count);[/code]
將其還原為:
[code=java; first-line:118]posts = pm.selectAllByTopic(topicId);[/code]
再測測看吧!
另外,您在發表程式碼時可否幫忙加上code的標籤,以便套用原始碼排版?謝謝您!
可參考這篇的說明:
http://www.andowson.com/posts/list/133.page
十鼎 wrote:问题:删除一个主题时,用户的文章数并没有减去相应数量。
...
import net.jforum.dao.UserDAO;
...
private void removePosts(List<Post> posts)
{
PreparedStatement pstmtPost = null;
PreparedStatement pstmtText = null;
UserDAO userDAO = DataAccessDriver.getInstance().newUserDAO();
try {
pstmtPost = JForumExecutionContext.getConnection()
.prepareStatement(SystemGlobals.getSql("PostModel.deletePost"));
pstmtText = JForumExecutionContext.getConnection().prepareStatement(
SystemGlobals.getSql("PostModel.deletePostText"));
for (Iterator<Post> iter = posts.iterator(); iter.hasNext();) {
Post post = iter.next();
pstmtPost.setInt(1, post.getId());
pstmtText.setInt(1, post.getId());
pstmtText.executeUpdate();
pstmtPost.executeUpdate();
SearchFacade.delete(post);
userDAO.decrementPosts(post.getUserId());
}
}
catch (SQLException e) {
throw new DatabaseException(e);
}
finally {
DbUtils.close(pstmtPost);
DbUtils.close(pstmtText);
}
}
public void delete()
{
....
postDao.delete(post);
//刪掉這行DataAccessDriver.getInstance().newUserDAO().decrementPosts(post.getUserId());
...
}
十鼎 wrote:andowson wrote:十鼎 wrote:为主题的文章进行缓存功能,我感觉有问题(我的理解),如果我理解有误还请指教。楼主,你的理解如何?
應該是有問題沒錯,有可能是我誤改了原來的程式碼
trunk/src/main/java/net/jforum/repository/PostRepository.java的118行:
[code=java; first-line:118]posts = pm.selectAllByTopicByLimit(topicId, start, count);[/code]
將其還原為:
[code=java; first-line:118]posts = pm.selectAllByTopic(topicId);[/code]
再測測看吧!
另外,您在發表程式碼時可否幫忙加上code的標籤,以便套用原始碼排版?謝謝您!
可參考這篇的說明:
http://www.andowson.com/posts/list/133.page
旧的设置为:每页主题数15,然后设置为每页10;
在某个版面发表新的主题,直到该版面有12个,当超过10时,页导航出现2页,但是首页主题数为12,次页有2页。
这个问题与上面的问题存在相同的逻辑。
重启服务器后,正常。
问题所在的位置在:net.jforum.view.forum.common.TopicsCommon.java L102。
看来主题缓存和文章缓存都有进一步改进机会。
十鼎 wrote:关于运行时更新配置文件引起的异常问题
jforum支持运行时更新配置文件功能,运行时会监测主要的配置文件是否被更新,如果发现则重新装载。相关代码见SystemGlobalsListener.java 文件:
[code=java; first-line:60]
public void fileChanged(final String filename)
{
LOGGER.info("Reloading "+ filename);
SystemGlobals.reset(); //这里已经清空了所有配置信息
SystemGlobals.initGlobals(SystemGlobals.getApplicationPath(),
SystemGlobals.getValue(ConfigKeys.DEFAULT_CONFIG));//这里希望取出默认配置文件名,返回值为空
}
[/code]
public class RecommendAction extends AdminCommand {
public void list() {
this.context.put("topics", DataAccessDriver.getInstance().newTopicDAO().selectRecommWaitingTopics(10));
this.setTemplateName(TemplateKeys.RECOMMEND_LIST);//新添加的,= "recommend.list";
}
}
# If you have freemarker templates residing outside of the JForum webapp
# you can add the path to the directory containing them here.
# Add the full path to the directory.
freemarker.extra.template.path =
...
# The template to use
template.dir = default