From 55657c07e1e569551f204d21d783fcba9a10e60e Mon Sep 17 00:00:00 2001 From: quasi Date: Sat, 28 Jan 2012 15:28:52 +0000 Subject: [PATCH] Forum Reihenfolge der Threads ist nun per Config einstellbar. git-svn-id: https://svn.libreccm.org/ccm/trunk@1474 8810af33-2d31-482b-a856-94f89814c4df --- ccm-forum/src/com/arsdigita/forum/Forum.java | 30 +- .../src/com/arsdigita/forum/ForumConfig.java | 328 ++++++++++-------- .../forum/ForumConfig_parameter.properties | 16 +- .../forum/ui/ForumResources_de.properties | 4 +- 4 files changed, 207 insertions(+), 171 deletions(-) diff --git a/ccm-forum/src/com/arsdigita/forum/Forum.java b/ccm-forum/src/com/arsdigita/forum/Forum.java index c05838f8c..227f11238 100755 --- a/ccm-forum/src/com/arsdigita/forum/Forum.java +++ b/ccm-forum/src/com/arsdigita/forum/Forum.java @@ -64,7 +64,7 @@ import com.arsdigita.web.Application; * @author Kevin Scaldeferri (kevin@arsdigita.com) * @author chrisg23 * @author Jens Pelzetter (jensp) - * @version $Revision: 1.7 $ + * @version $Revision: 1.7 $ * @version $Id: Forum.java 2261 2012-01-08 17:17:10Z pboy $ */ public class Forum extends Application { @@ -93,15 +93,15 @@ public class Forum extends Application { public static final String FORUM_MODERATION_PRIVILEGE = "forum_moderation"; public static final String CREATE_THREAD_PRIVILEGE = "forum_create_thread"; public static final String RESPOND_TO_THREAD_PRIVILEGE = "forum_respond"; - // separate read privilege required because all public users + // separate read privilege required because all public users // have READ on homepage, which is parent of forum, hence // everyone inherits READ cg // // note in hindsight, I have stopped homepage being set as - // permission context for forum, because site search checks + // permission context for forum, because site search checks // for READ privilege anyway, and so search results were being - // returned for non public posts. This means there is no longer - // any need for a separate forum_read privilege, though it + // returned for non public posts. This means there is no longer + // any need for a separate forum_read privilege, though it // does no harm. Now removed // // pb: Reactivated READ privilege in order to provide forums for different @@ -162,7 +162,7 @@ public class Forum extends Application { /** * Retrieves a Forum instance (its contained DataObject) based on its * internal id which is used to search for the OID. - * + * * @param id * @throws DataObjectNotFoundException */ @@ -172,8 +172,8 @@ public class Forum extends Application { /** * Convenient class for creation of a standard forum. Property "Moderated" - * is set to false. - * + * is set to false. + * * @param urlName of the forum to be created * @param title of forum to be created * @param parent object of forum to be created @@ -201,7 +201,7 @@ public class Forum extends Application { s_log.debug("creating forum " + title); /* Create an aplication instance including a container group in the - * user administration (5. parameter true) named according to the + * user administration (5. parameter true) named according to the * forum title. */ Forum forum = (Forum) Application.createApplication( BASE_DATA_OBJECT_TYPE, urlName, @@ -268,7 +268,7 @@ public class Forum extends Application { } /** - * + * */ private void createGroups() { @@ -347,8 +347,8 @@ public class Forum extends Application { super.beforeSave(); } - /** - * + /** + * */ @Override protected void afterSave() { @@ -540,7 +540,7 @@ public class Forum extends Application { * @return */ public DataAssociation getSuppressedPosts() { - // doesn't use getPosts in view of the warning that it + // doesn't use getPosts in view of the warning that it // may disappear DataAssociation posts = (DataAssociation) get(POSTS); posts.addEqualsFilter(Post.STATUS, Post.SUPPRESSED); @@ -597,7 +597,7 @@ public class Forum extends Application { } } - threadsData.addOrder("lastUpdate desc"); + threadsData.addOrder(getConfig().getThreadOrder()); return new ThreadCollection(threadsData); } @@ -735,7 +735,7 @@ public class Forum extends Application { * checks if the user can delete posts in this forum */ public boolean canDelete(Party party) { - return ((getConfig().canAdminEditPosts() + return ((getConfig().canAdminEditPosts() || getConfig().canAuthorDeletePosts()) && PermissionService.checkPermission( new PermissionDescriptor(PrivilegeDescriptor.DELETE, diff --git a/ccm-forum/src/com/arsdigita/forum/ForumConfig.java b/ccm-forum/src/com/arsdigita/forum/ForumConfig.java index d322024cb..0c190835f 100755 --- a/ccm-forum/src/com/arsdigita/forum/ForumConfig.java +++ b/ccm-forum/src/com/arsdigita/forum/ForumConfig.java @@ -46,7 +46,6 @@ import org.apache.log4j.Logger; public class ForumConfig extends AbstractConfig { private static final Logger s_log = Logger.getLogger(ForumConfig.class); - private Parameter m_adminEditPosts; private Parameter m_authorEditPosts; private Parameter m_authorDeletePosts; @@ -62,79 +61,86 @@ public class ForumConfig extends AbstractConfig { private Parameter m_useWysiwygEditor; private Parameter m_rejectionMessage; private Parameter m_threadPageSize; + private Parameter m_threadOrderField; + private Parameter m_threadOrderDir; private Parameter m_quickFinish; private Parameter m_deleteSentSubscriptionNotifications; public ForumConfig() { m_adminEditPosts = new BooleanParameter( - "com.arsdigita.forum.admin_can_edit_posts", - Parameter.REQUIRED, - Boolean.TRUE); + "com.arsdigita.forum.admin_can_edit_posts", + Parameter.REQUIRED, + Boolean.TRUE); m_authorEditPosts = new BooleanParameter( - "com.arsdigita.forum.author_can_edit_posts", - Parameter.REQUIRED, - Boolean.TRUE); + "com.arsdigita.forum.author_can_edit_posts", + Parameter.REQUIRED, + Boolean.TRUE); m_authorDeletePosts = new BooleanParameter( - "com.arsdigita.forum.author_can_delete_posts", - Parameter.REQUIRED, - Boolean.TRUE); + "com.arsdigita.forum.author_can_delete_posts", + Parameter.REQUIRED, + Boolean.TRUE); m_replyHostName = new StringParameter( - "com.arsdigita.forum.reply_host_name", - Parameter.OPTIONAL, - null); + "com.arsdigita.forum.reply_host_name", + Parameter.OPTIONAL, + null); m_digestUserEmail = new StringParameter( - "com.arsdigita.forum.digest_user_email", - Parameter.OPTIONAL, - null); - m_disablePageCaching = new BooleanParameter ( - "com.arsdigita.forum.disable_page_caching", - Parameter.REQUIRED, - Boolean.FALSE); - - m_adminOnlyCreateTopics = new BooleanParameter ( - "com.arsdigita.forum.admin_only_to_create_topics", - Parameter.REQUIRED, - Boolean.FALSE); - m_maxImageSize = new IntegerParameter ( - "com.arsdigita.forum.maximum_image_size", - Parameter.OPTIONAL, null); - m_maxFileSize = new IntegerParameter ( - "com.arsdigita.forum.maximum_file_size", - Parameter.OPTIONAL, null); - - m_showNewTabs = new BooleanParameter( - "com.arsdigita.forum.show_new_tabs", - Parameter.OPTIONAL, - Boolean.FALSE); - m_showAllThreadAlerts = new BooleanParameter( - "com.arsdigita.forum.show_all_forum_thread_alerts", - Parameter.OPTIONAL, - Boolean.TRUE); - m_useWysiwygEditor = new BooleanParameter( - "com.arsdigita.forum.use_wysiwyg_editor", - Parameter.OPTIONAL, - Boolean.FALSE); - m_rejectionMessage = new StringParameter( - "com.arsdigita.forum.rejection_form_message.example", - Parameter.OPTIONAL, - null); - m_threadPageSize = new IntegerParameter ( - "com.arsdigita.forum.thread_page_size", - Parameter.REQUIRED, new Integer(10)); - m_quickFinish = new BooleanParameter( - "com.arsdigita.forum.allow_quick_finish", - Parameter.OPTIONAL, - Boolean.FALSE); - m_deleteSentSubscriptionNotifications = new BooleanParameter( - "com.arsdigita.forum.delete_sent_subscription_notifications", - Parameter.OPTIONAL, - Boolean.FALSE); + "com.arsdigita.forum.digest_user_email", + Parameter.OPTIONAL, + null); + m_disablePageCaching = new BooleanParameter( + "com.arsdigita.forum.disable_page_caching", + Parameter.REQUIRED, + Boolean.FALSE); - m_adapters = new ResourceParameter - ("com.arsdigita.forum.traversal_adapters", - Parameter.REQUIRED, - "/WEB-INF/resources/forum-adapters.xml"); + m_adminOnlyCreateTopics = new BooleanParameter( + "com.arsdigita.forum.admin_only_to_create_topics", + Parameter.REQUIRED, + Boolean.FALSE); + m_maxImageSize = new IntegerParameter( + "com.arsdigita.forum.maximum_image_size", + Parameter.OPTIONAL, null); + m_maxFileSize = new IntegerParameter( + "com.arsdigita.forum.maximum_file_size", + Parameter.OPTIONAL, null); + + m_showNewTabs = new BooleanParameter( + "com.arsdigita.forum.show_new_tabs", + Parameter.OPTIONAL, + Boolean.FALSE); + m_showAllThreadAlerts = new BooleanParameter( + "com.arsdigita.forum.show_all_forum_thread_alerts", + Parameter.OPTIONAL, + Boolean.TRUE); + m_useWysiwygEditor = new BooleanParameter( + "com.arsdigita.forum.use_wysiwyg_editor", + Parameter.OPTIONAL, + Boolean.FALSE); + m_rejectionMessage = new StringParameter( + "com.arsdigita.forum.rejection_form_message.example", + Parameter.OPTIONAL, + null); + m_threadPageSize = new IntegerParameter( + "com.arsdigita.forum.thread_page_size", + Parameter.REQUIRED, new Integer(10)); + m_threadOrderField = new StringParameter( + "com.arsdigita.forum.thread_order_field", + Parameter.REQUIRED, new String("lastUpdate")); + m_threadOrderDir = new StringParameter( + "com.arsdigita.forum.thread_order_dir", + Parameter.REQUIRED, new String("desc")); + m_quickFinish = new BooleanParameter( + "com.arsdigita.forum.allow_quick_finish", + Parameter.OPTIONAL, + Boolean.FALSE); + m_deleteSentSubscriptionNotifications = new BooleanParameter( + "com.arsdigita.forum.delete_sent_subscription_notifications", + Parameter.OPTIONAL, + Boolean.FALSE); + + m_adapters = new ResourceParameter("com.arsdigita.forum.traversal_adapters", + Parameter.REQUIRED, + "/WEB-INF/resources/forum-adapters.xml"); register(m_digestUserEmail); register(m_adminEditPosts); @@ -151,29 +157,31 @@ public class ForumConfig extends AbstractConfig { register(m_useWysiwygEditor); register(m_rejectionMessage); register(m_threadPageSize); + register(m_threadOrderField); + register(m_threadOrderDir); register(m_quickFinish); register(m_deleteSentSubscriptionNotifications); loadInfo(); } InputStream getTraversalAdapters() { - return (InputStream)get(m_adapters); + return (InputStream) get(m_adapters); } public boolean canAdminEditPosts() { - return ((Boolean)get(m_adminEditPosts)).booleanValue(); + return ((Boolean) get(m_adminEditPosts)).booleanValue(); } public boolean canAuthorEditPosts() { - return ((Boolean)get(m_authorEditPosts)).booleanValue(); + return ((Boolean) get(m_authorEditPosts)).booleanValue(); } boolean canAuthorDeletePosts() { - return ((Boolean)get(m_authorDeletePosts)).booleanValue(); + return ((Boolean) get(m_authorDeletePosts)).booleanValue(); } - + public String getDigestUserEmail() { - String email = (String)get(m_digestUserEmail); + String email = (String) get(m_digestUserEmail); if (email == null) { email = "forum-robot@" + Web.getConfig().getServer().getName(); } @@ -181,7 +189,7 @@ public class ForumConfig extends AbstractConfig { } public String getReplyHostName() { - String hostName = (String)get(m_replyHostName); + String hostName = (String) get(m_replyHostName); if (hostName == null) { hostName = Web.getConfig().getServer().getName(); } @@ -189,33 +197,34 @@ public class ForumConfig extends AbstractConfig { } /** - * Supports prevention of client and middleware caching - - * use in situations where users with different - * permissions share machines + * Supports prevention of client and middleware caching - use in situations + * where users with different permissions share machines + * * @return */ - public boolean disableClientPageCaching () { - return ((Boolean)get(m_disablePageCaching)).booleanValue(); - } - + public boolean disableClientPageCaching() { + return ((Boolean) get(m_disablePageCaching)).booleanValue(); + } + /** - * if true, disables topic tab for non admin users. Topic - * tab does not access control topic creation, so set this - * to true to maintain control of the topics on the forum. - * - * - * + * if true, disables topic tab for non admin users. Topic tab does not + * access control topic creation, so set this to true to maintain control of + * the topics on the forum. + * + * + * * @return */ - public boolean topicCreationByAdminOnly () { - return ((Boolean)get(m_adminOnlyCreateTopics)).booleanValue(); - } + public boolean topicCreationByAdminOnly() { + return ((Boolean) get(m_adminOnlyCreateTopics)).booleanValue(); + } + public User getDigestUser() { String email = getDigestUserEmail(); UserCollection users = User.retrieveAll(); users.addEqualsFilter("primaryEmail", - email); + email); if (!users.next()) { throw new RuntimeException("cannot find user " + email); @@ -225,85 +234,102 @@ public class ForumConfig extends AbstractConfig { users.close(); return user; } + /** - * returns the maximum allowed size (in bytes) of - * image files attached to posts. Any larger - * files are rejected by UI validation + * returns the maximum allowed size (in bytes) of image files attached to + * posts. Any larger files are rejected by UI validation + * * @return */ public long getMaxImageSize() { - Integer size = (Integer)get(m_maxImageSize); - long longSize = Long.MAX_VALUE; - if (size != null) { - longSize = size.longValue(); - } - return longSize; + Integer size = (Integer) get(m_maxImageSize); + long longSize = Long.MAX_VALUE; + if (size != null) { + longSize = size.longValue(); + } + return longSize; } + /** - * returns the maximum allowed size (in bytes) of - * files attached to posts. Any larger - * files are rejected by UI validation + * returns the maximum allowed size (in bytes) of files attached to posts. + * Any larger files are rejected by UI validation + * * @return */ public long getMaxFileSize() { - Integer size = (Integer)get(m_maxFileSize); - long longSize = Long.MAX_VALUE; - if (size != null) { - longSize = size.longValue(); - } - return longSize; + Integer size = (Integer) get(m_maxFileSize); + long longSize = Long.MAX_VALUE; + if (size != null) { + longSize = size.longValue(); + } + return longSize; } - - + /** - * if true, alerts tab displays thread alerts for this and all other - * forums. If false, only display thread subscriptions for current - * forum. + * if true, alerts tab displays thread alerts for this and all other forums. + * If false, only display thread subscriptions for current forum. + * * @return */ /* - * If true, the thread alert page lists thread alerts from - * all forums - alerts not from the current forum have - * links to the thread displayed within the context of - * the current forum. Looks weird and needs to be sorted out - * presumably the correct forum needs to be set in the ForumContext - * when a link is selected - */ - public boolean showThreadAlertsForAllForums () { - return ((Boolean)get(m_showAllThreadAlerts)).booleanValue(); - } - /** - * if true, displays setup and permissions tabs - * @return + * If true, the thread alert page lists thread alerts from all forums - + * alerts not from the current forum have links to the thread displayed + * within the context of the current forum. Looks weird and needs to be + * sorted out presumably the correct forum needs to be set in the + * ForumContext when a link is selected */ - public boolean showNewTabs () { - return ((Boolean)get(m_showNewTabs)).booleanValue(); - } - - public boolean useWysiwygEditor () { - return ((Boolean)get(m_useWysiwygEditor)).booleanValue(); - } - - /** - * message added to the bottom of the moderation reection email. - * May give details about what the poster can do if not happy - * with rejection - * @return - */ - public String getRejectionMessage () { - return (String)get(m_rejectionMessage); - } - - public int getThreadPageSize () { - return ((Integer)get(m_threadPageSize)).intValue(); - } - - public boolean quickFinishAllowed () { - return ((Boolean)get(m_quickFinish)).booleanValue(); - } - - public boolean deleteNotifications () { - return ((Boolean)get(m_deleteSentSubscriptionNotifications)).booleanValue(); + public boolean showThreadAlertsForAllForums() { + return ((Boolean) get(m_showAllThreadAlerts)).booleanValue(); } + /** + * if true, displays setup and permissions tabs + * + * @return + */ + public boolean showNewTabs() { + return ((Boolean) get(m_showNewTabs)).booleanValue(); + } + + public boolean useWysiwygEditor() { + return ((Boolean) get(m_useWysiwygEditor)).booleanValue(); + } + + /** + * message added to the bottom of the moderation reection email. May give + * details about what the poster can do if not happy with rejection + * + * @return + */ + public String getRejectionMessage() { + return (String) get(m_rejectionMessage); + } + + public int getThreadPageSize() { + return ((Integer) get(m_threadPageSize)).intValue(); + } + + public String getThreadOrder() { + String field = (String) get(m_threadOrderField); + String dir = (String) get(m_threadOrderDir); + + // Test for validity + if(!field.equals("lastUpdate") && !field.equals("root.sent")) { + field = "lastUpdate"; // Default behaviour + } + + if(!dir.equals("asc") && !dir.equals("desc")) { + dir = "desc"; // Default behaviour + } + + return field + " " + dir; + } + + public boolean quickFinishAllowed() { + return ((Boolean) get(m_quickFinish)).booleanValue(); + } + + public boolean deleteNotifications() { + return ((Boolean) get(m_deleteSentSubscriptionNotifications)).booleanValue(); + } } diff --git a/ccm-forum/src/com/arsdigita/forum/ForumConfig_parameter.properties b/ccm-forum/src/com/arsdigita/forum/ForumConfig_parameter.properties index 3c8820862..d737dbc3e 100755 --- a/ccm-forum/src/com/arsdigita/forum/ForumConfig_parameter.properties +++ b/ccm-forum/src/com/arsdigita/forum/ForumConfig_parameter.properties @@ -41,12 +41,12 @@ com.arsdigita.forum.disable_page_caching.example=true|false com.arsdigita.forum.maximum_image_size.title=Maximum size of image uploads in bytes com.arsdigita.forum.maximum_image_size.purpose=Prevent huge images from being uploaded com.arsdigita.forum.maximum_image_size.format=[integer] -com.arsdigita.forum.maximum_image_size.example=1048576 +com.arsdigita.forum.maximum_image_size.example=1048576 com.arsdigita.forum.maximum_file_size.title=Maximum size of file uploads in bytes com.arsdigita.forum.maximum_file_size.purpose=prevent huge files from being uploaded com.arsdigita.forum.maximum_file_size.format=[integer] -com.arsdigita.forum.maximum_file_size.example=1048576 +com.arsdigita.forum.maximum_file_size.example=1048576 com.arsdigita.forum.show_all_forum_thread_alerts.title=Display thread alerts from all forums com.arsdigita.forum.show_all_forum_thread_alerts.purpose=decide whether to display thread alerts for this forum only or all alerts for user @@ -68,11 +68,21 @@ com.arsdigita.forum.rejection_form_message.purpose=tail of email that may contai com.arsdigita.forum.rejection_form_message.format=[string] com.arsdigita.forum.rejection_form_message.example=Please do not reply to this email. If you have any comments, please email webmaster@example.com -com.arsdigita.forum.thread_page_size.title=Number of threads displayed per page +com.arsdigita.forum.thread_page_size.title=Number of threads displayed per page com.arsdigita.forum.thread_page_size.purpose=balance page loading time against number of key preses com.arsdigita.forum.thread_page_size.format=[integer] com.arsdigita.forum.thread_page_size.example=10 +com.arsdigita.forum.thread_order_field.title=Thread list order field +com.arsdigita.forum.thread_order_field.purpose=Define field by which the thread list will be orderd +com.arsdigita.forum.thread_order_field.format=[string] +com.arsdigita.forum.thread_order_field.example=lastUpdate|root.sent + +com.arsdigita.forum.thread_order_dir.title=Thread list order direction +com.arsdigita.forum.thread_order_dir.purpose=Ascending or descending sort order +com.arsdigita.forum.thread_order_dir.format=[string] +com.arsdigita.forum.thread_order_dir.example=asc|desc + com.arsdigita.forum.allow_quick_finish.title=Allow quick finish on posts com.arsdigita.forum.allow_quick_finish.purpose=To give users the option of omitting post steps if they have a quick text post com.arsdigita.forum.allow_quick_finish.format=[boolean] diff --git a/ccm-forum/src/com/arsdigita/forum/ui/ForumResources_de.properties b/ccm-forum/src/com/arsdigita/forum/ui/ForumResources_de.properties index fc820fe51..080ee693a 100644 --- a/ccm-forum/src/com/arsdigita/forum/ui/ForumResources_de.properties +++ b/ccm-forum/src/com/arsdigita/forum/ui/ForumResources_de.properties @@ -18,7 +18,7 @@ forum.ui.no=Nein forum.ui.thread.newPost=Neuer Beitrag forum.ui.thread.subscribe=Beitrag abonnieren -forum.ui.thread.unsubscribe=Beitrag Abonoment stornieren +forum.ui.thread.unsubscribe=Beitrag Abonnement stornieren forum.ui.thread.viewAll=Alle Beitr\u00e4ge forum.ui.topic.description=Beschreibung @@ -47,7 +47,7 @@ forum.ui.settings.noticeboard=Noticeboard (Keine Antworten m\u00f6glich) forum.ui.settings.allowFiles=Dateianh\u00e4nge zulassen forum.ui.settings.allowImages=Bilder in Posts zulassen forum.ui.settings.autosubscribe=Automatically subscribe thread starters -forum.ui.settings.noCategoryPosts=Allow posts with no topic +forum.ui.settings.noCategoryPosts=Allow posts with no topic forum.ui.settings.anonymousPosts=Allow anonymous posts forum.ui.settings.save=\u00c4nderungen sichern forum.ui.settings.introduction=Einf\u00fchrung