[Logo]
如何強制匿名訪客需先登入才能下載附加檔案  XML del.icio.us HEMiDEMi funP 收進你的MyShare個人書籤 新增到udn共享書籤 plurk twitter 分享
Forum Index » JForum中文社群 JForum Chinese Users Community
Author Message
andowson

五段學員
[Avatar]

Joined: 2007-01-02 22:20:40
Messages: 510
Location: 台北
Offline

1.在jforum-custom.conf中加入一行:
attachments.anonymous=false

2.修改net.jforum.view.forum.PostAction.java的downloadAttach():

if ((SecurityRepository.canAccess(SecurityConstants.PERM_ATTACHMENTS_ENABLED) &&
		!SecurityRepository.canAccess(SecurityConstants.PERM_ATTACHMENTS_DOWNLOAD))
		|| (!SessionFacade.isLogged() && !SystemGlobals.getBoolValue(ConfigKeys.ATTACHMENTS_ANONYMOUS))) {
	this.setTemplateName(TemplateKeys.POSTS_CANNOT_DOWNLOAD);
	this.context.put("message", I18n.getMessage("Attachments.featureDisabled"));
	return;
}

改為
if ((SecurityRepository.canAccess(SecurityConstants.PERM_ATTACHMENTS_ENABLED) &&
		!SecurityRepository.canAccess(SecurityConstants.PERM_ATTACHMENTS_DOWNLOAD))) {
	this.setTemplateName(TemplateKeys.POSTS_CANNOT_DOWNLOAD);
	this.context.put("message", I18n.getMessage("Attachments.featureDisabled"));
	return;
}
if (!SessionFacade.isLogged() && !SystemGlobals.getBoolValue(ConfigKeys.ATTACHMENTS_ANONYMOUS)) {
	this.setTemplateName(ViewCommon.contextToLogin());
	return;
}

原先的程式碼是不管設定為不啟用附加檔案及未登入且有設定禁止匿名下載附加檔案時都顯示同一個錯誤訊息,我們把它分開成兩個狀況,在未登入且有設定禁止匿名下載附加檔案時先導到登入畫面,通過登入驗證後再下載檔案。
 Filename PostAction.java [Disk] Download
 Description PostAction.java
 Filesize 46 Kbytes
 Downloaded:  10 time(s)

This message was edited 8 times. Last update was at 2007-05-06 08:32:17


分享經驗 累積智慧
[WWW] [MSN]
 
Forum Index » JForum中文社群 JForum Chinese Users Community
Go to:   

交換連結乌托邦博客 
在本站刊登廣告
練功房推薦書單
SCJP 6.0認證教戰手冊 (附光碟) 雲端策略:雲端運算與虛擬化技術 SCJP Java 6專業認證手冊 Java認證SCJP 6.0/5.0--猛虎出閘 SCWCD 5 猛虎出閘:Java Web 應用程式專業認證 SCWCD專業認證手冊 Head First Servlets and JSP
[版權說明] 本站授權方式:創用CC 姓名標示-非商業性-相同方式分享 3.0 台灣 授權條款
Creative Commons License
Powered by JForum 2.2.0 © JForum Team