練功房推薦書單

  • Google!Android 3手機應用程式設計入門(第四版)
  • 賈伯斯傳(軟皮精裝版)
  • 猛虎出閘制霸版:最新OCP Java SE 6 Programmer專業認證(附原始程式碼及範例檔)
  • SCWCD 5 猛虎出閘:Java Web 應用程式專業認證
如何強制匿名訪客需先登入才能下載附加檔案  XML
Forum Index » JForum中文社群 JForum Chinese Users Community
Author Message
andowson

六段學員
[Avatar]

Joined: 2007-01-02 22:20:40
Messages: 652
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: