Zugriff auf eine Forum-Instanz kann jetzt beschränkt werden.
git-svn-id: https://svn.libreccm.org/ccm/trunk@1128 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b6f6ad9127
commit
596707a5e5
|
|
@ -63,6 +63,7 @@ import com.arsdigita.web.Application;
|
||||||
*
|
*
|
||||||
* @author Kevin Scaldeferri (kevin@arsdigita.com)
|
* @author Kevin Scaldeferri (kevin@arsdigita.com)
|
||||||
* @author chrisg23
|
* @author chrisg23
|
||||||
|
* @author Jens Pelzetter (jensp)
|
||||||
* @version $Revision: 1.7 $
|
* @version $Revision: 1.7 $
|
||||||
* @version $Id: Forum.java 1628 2007-09-17 08:10:40Z chrisg23 $
|
* @version $Id: Forum.java 1628 2007-09-17 08:10:40Z chrisg23 $
|
||||||
*/
|
*/
|
||||||
|
|
@ -70,15 +71,13 @@ public class Forum extends Application {
|
||||||
|
|
||||||
/** Private logger instance for debugging purpose */
|
/** Private logger instance for debugging purpose */
|
||||||
private static final Logger s_log = Logger.getLogger(Forum.class);
|
private static final Logger s_log = Logger.getLogger(Forum.class);
|
||||||
|
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.forum.Forum";
|
"com.arsdigita.forum.Forum";
|
||||||
public static final String PACKAGE_TYPE = "forum";
|
public static final String PACKAGE_TYPE = "forum";
|
||||||
|
|
||||||
public static final String THREAD_SUBSCRIPTION_GROUPS_NAME =
|
public static final String THREAD_SUBSCRIPTION_GROUPS_NAME =
|
||||||
"Thread Subscription Groups";
|
"Thread Subscription Groups";
|
||||||
|
|
||||||
private static final ForumConfig s_config = new ForumConfig();
|
private static final ForumConfig s_config = new ForumConfig();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
s_log.debug("Static initalizer starting...");
|
s_log.debug("Static initalizer starting...");
|
||||||
s_config.load();
|
s_config.load();
|
||||||
|
|
@ -88,30 +87,27 @@ public class Forum extends Application {
|
||||||
public static ForumConfig getConfig() {
|
public static ForumConfig getConfig() {
|
||||||
return s_config;
|
return s_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////
|
//////
|
||||||
//Forum specific privileges
|
//Forum specific privileges
|
||||||
/////
|
/////
|
||||||
public static final String FORUM_MODERATION_PRIVILEGE = "forum_moderation";
|
public static final String FORUM_MODERATION_PRIVILEGE = "forum_moderation";
|
||||||
public static final String CREATE_THREAD_PRIVILEGE = "forum_create_thread";
|
public static final String CREATE_THREAD_PRIVILEGE = "forum_create_thread";
|
||||||
public static final String RESPOND_TO_THREAD_PRIVILEGE = "forum_respond";
|
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
|
// have READ on homepage, which is parent of forum, hence
|
||||||
// everyone inherits READ cg
|
// everyone inherits READ cg
|
||||||
//
|
//
|
||||||
// note in hindsight, I have stopped homepage being set as
|
// 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
|
// for READ privilege anyway, and so search results were being
|
||||||
// returned for non public posts. This means there is no longer
|
// returned for non public posts. This means there is no longer
|
||||||
// any need for a separate forum_read privilege, though it
|
// any need for a separate forum_read privilege, though it
|
||||||
// does no harm. Now removed
|
// does no harm. Now removed
|
||||||
//
|
//
|
||||||
// pb: Reactivated READ privilege in order to provide forums for different
|
// pb: Reactivated READ privilege in order to provide forums for different
|
||||||
// groups of users for their internal use and to provide private forums
|
// groups of users for their internal use and to provide private forums
|
||||||
// for logged in users only (no public read access).
|
// for logged in users only (no public read access).
|
||||||
public static final String FORUM_READ_PRIVILEGE = "forum_read";
|
public static final String FORUM_READ_PRIVILEGE = "forum_read";
|
||||||
|
|
||||||
///////
|
///////
|
||||||
// pdl forum attribute/association names
|
// pdl forum attribute/association names
|
||||||
///////
|
///////
|
||||||
|
|
@ -120,21 +116,20 @@ public class Forum extends Application {
|
||||||
private static final String MODERATION = "isModerated";
|
private static final String MODERATION = "isModerated";
|
||||||
private static final String PUBLIC = "isPublic";
|
private static final String PUBLIC = "isPublic";
|
||||||
private static final String NOTICEBOARD = "isNoticeboard";
|
private static final String NOTICEBOARD = "isNoticeboard";
|
||||||
|
|
||||||
private static final String ADMIN_GROUP = "adminGroup";
|
private static final String ADMIN_GROUP = "adminGroup";
|
||||||
private static final String MODERATION_GROUP = "moderationGroup";
|
private static final String MODERATION_GROUP = "moderationGroup";
|
||||||
private static final String THREAD_CREATE_GROUP = "threadCreateGroup";
|
private static final String THREAD_CREATE_GROUP = "threadCreateGroup";
|
||||||
private static final String THREAD_RESPONDER_GROUP = "threadRespondGroup";
|
private static final String THREAD_RESPONDER_GROUP = "threadRespondGroup";
|
||||||
private static final String READ_GROUP = "readGroup";
|
private static final String READ_GROUP = "readGroup";
|
||||||
|
|
||||||
private static final String CATEGORY = "category";
|
private static final String CATEGORY = "category";
|
||||||
private static final String EXPIRE_AFTER = "expireAfter";
|
private static final String EXPIRE_AFTER = "expireAfter";
|
||||||
private static final String LIFECYCLE_DEFINITION = "lifecycleDefinition";
|
private static final String LIFECYCLE_DEFINITION = "lifecycleDefinition";
|
||||||
// additional attributes added chris.gilbert@westsussex.gov.uk
|
// additional attributes added chris.gilbert@westsussex.gov.uk
|
||||||
private static final String ALLOW_FILE_ATTACHMENTS = "fileAttachmentsAllowed";
|
private static final String ALLOW_FILE_ATTACHMENTS =
|
||||||
|
"fileAttachmentsAllowed";
|
||||||
private static final String ALLOW_IMAGE_UPLOADS = "imageUploadsAllowed";
|
private static final String ALLOW_IMAGE_UPLOADS = "imageUploadsAllowed";
|
||||||
private static final String AUTOSUBSCRIBE_THREAD_STARTER =
|
private static final String AUTOSUBSCRIBE_THREAD_STARTER =
|
||||||
"autoSubscribeThreadStarter";
|
"autoSubscribeThreadStarter";
|
||||||
private static final String INTRODUCTION = "introduction";
|
private static final String INTRODUCTION = "introduction";
|
||||||
private static final String NO_CATEGORY_POSTS = "noCategoryPostsAllowed";
|
private static final String NO_CATEGORY_POSTS = "noCategoryPostsAllowed";
|
||||||
private static final String ANONYMOUS_POSTS = "anonymousPostsAllowed";
|
private static final String ANONYMOUS_POSTS = "anonymousPostsAllowed";
|
||||||
|
|
@ -203,9 +198,10 @@ public class Forum extends Application {
|
||||||
Application parent, boolean moderated) {
|
Application parent, boolean moderated) {
|
||||||
s_log.debug("creating forum " + title);
|
s_log.debug("creating forum " + title);
|
||||||
|
|
||||||
Forum forum = (Forum) Application.createApplication(BASE_DATA_OBJECT_TYPE,
|
Forum forum = (Forum) Application.createApplication(
|
||||||
urlName,
|
BASE_DATA_OBJECT_TYPE,
|
||||||
title, parent, true);
|
urlName,
|
||||||
|
title, parent, true);
|
||||||
|
|
||||||
forum.setModerated(moderated);
|
forum.setModerated(moderated);
|
||||||
forum.setPublic(true);
|
forum.setPublic(true);
|
||||||
|
|
@ -237,8 +233,7 @@ public class Forum extends Application {
|
||||||
if (category == null) {
|
if (category == null) {
|
||||||
return createRootCategory();
|
return createRootCategory();
|
||||||
} else {
|
} else {
|
||||||
return (Category)DomainObjectFactory
|
return (Category) DomainObjectFactory.newInstance(category);
|
||||||
.newInstance(category);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,7 +274,7 @@ public class Forum extends Application {
|
||||||
|
|
||||||
Group moderators = new Group();
|
Group moderators = new Group();
|
||||||
moderators.setName(getTitle() + " Moderators");
|
moderators.setName(getTitle() + " Moderators");
|
||||||
setAssociation( MODERATION_GROUP, moderators );
|
setAssociation(MODERATION_GROUP, moderators);
|
||||||
// This is bit of a hack. For moderator messages to be sent out properly,
|
// This is bit of a hack. For moderator messages to be sent out properly,
|
||||||
// moderator group has to have proper primary email address. Which means
|
// moderator group has to have proper primary email address. Which means
|
||||||
// it has to be unique among all primary email addresses. Failing to the
|
// it has to be unique among all primary email addresses. Failing to the
|
||||||
|
|
@ -288,8 +283,8 @@ public class Forum extends Application {
|
||||||
// NPE when trying to retrieve sender's email address, thus stopping any
|
// NPE when trying to retrieve sender's email address, thus stopping any
|
||||||
// further message processing.
|
// further message processing.
|
||||||
// Actually, the only hack involved is making the email address unique.
|
// Actually, the only hack involved is making the email address unique.
|
||||||
String email = "forum-moderator-" + getID() + "-" +
|
String email = "forum-moderator-" + getID() + "-" + moderators.getID()
|
||||||
moderators.getID() + "@" + s_config.getReplyHostName();
|
+ "@" + s_config.getReplyHostName();
|
||||||
moderators.setPrimaryEmail(new EmailAddress(email));
|
moderators.setPrimaryEmail(new EmailAddress(email));
|
||||||
|
|
||||||
// chris.gilbert@westsussex.gov.uk create additional groups for privilege
|
// chris.gilbert@westsussex.gov.uk create additional groups for privilege
|
||||||
|
|
@ -309,7 +304,7 @@ public class Forum extends Application {
|
||||||
setAssociation(READ_GROUP, forumReaders);
|
setAssociation(READ_GROUP, forumReaders);
|
||||||
|
|
||||||
Group container = getGroup(); // Application.getGroup(): get group
|
Group container = getGroup(); // Application.getGroup(): get group
|
||||||
// associated with this application
|
// associated with this application
|
||||||
|
|
||||||
container.addSubgroup(administrators);
|
container.addSubgroup(administrators);
|
||||||
container.addSubgroup(moderators);
|
container.addSubgroup(moderators);
|
||||||
|
|
@ -340,7 +335,6 @@ public class Forum extends Application {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean m_wasNew;
|
private boolean m_wasNew;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -359,10 +353,10 @@ public class Forum extends Application {
|
||||||
PermissionService.setContext(getRootCategory(), this);
|
PermissionService.setContext(getRootCategory(), this);
|
||||||
createGroups();
|
createGroups();
|
||||||
if (getAdminGroup() != null) {
|
if (getAdminGroup() != null) {
|
||||||
PermissionService.grantPermission( new PermissionDescriptor(
|
PermissionService.grantPermission(new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.ADMIN,
|
PrivilegeDescriptor.ADMIN,
|
||||||
this,
|
this,
|
||||||
getAdminGroup()));
|
getAdminGroup()));
|
||||||
s_log.debug("Current user : "
|
s_log.debug("Current user : "
|
||||||
+ Kernel.getContext().getParty().getPrimaryEmail()
|
+ Kernel.getContext().getParty().getPrimaryEmail()
|
||||||
+ " class is "
|
+ " class is "
|
||||||
|
|
@ -387,22 +381,22 @@ public class Forum extends Application {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModerationGroup() != null ) {
|
if (getModerationGroup() != null) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(
|
PrivilegeDescriptor.get(
|
||||||
FORUM_MODERATION_PRIVILEGE),
|
FORUM_MODERATION_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
getModerationGroup()));
|
getModerationGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getThreadCreateGroup() != null) {
|
if (getThreadCreateGroup() != null) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(
|
PrivilegeDescriptor.get(
|
||||||
CREATE_THREAD_PRIVILEGE),
|
CREATE_THREAD_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
getThreadCreateGroup()));
|
getThreadCreateGroup()));
|
||||||
// chris.gilbert@westsussex.gov.uk
|
// chris.gilbert@westsussex.gov.uk
|
||||||
// wouldn't do this normally, but this enables legacy implementations
|
// wouldn't do this normally, but this enables legacy implementations
|
||||||
// to use new version without any side effects
|
// to use new version without any side effects
|
||||||
|
|
@ -413,38 +407,43 @@ public class Forum extends Application {
|
||||||
|
|
||||||
if (getThreadResponderGroup() != null) {
|
if (getThreadResponderGroup() != null) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(
|
PrivilegeDescriptor.get(
|
||||||
RESPOND_TO_THREAD_PRIVILEGE),
|
RESPOND_TO_THREAD_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
getThreadResponderGroup()));
|
getThreadResponderGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getReadGroup() != null) {
|
if (getReadGroup() != null) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.READ,
|
PrivilegeDescriptor.READ,
|
||||||
this,
|
this,
|
||||||
getReadGroup()));
|
getReadGroup()));
|
||||||
|
PermissionService.grantPermission(new PermissionDescriptor(
|
||||||
|
PrivilegeDescriptor.get(FORUM_READ_PRIVILEGE),
|
||||||
|
this,
|
||||||
|
getReadGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
KernelExcursion excursion = new KernelExcursion() {
|
KernelExcursion excursion = new KernelExcursion() {
|
||||||
protected void excurse() {
|
|
||||||
setParty(Kernel.getSystemParty());
|
|
||||||
// FIXME
|
|
||||||
// Workspace parentWorkspace =
|
|
||||||
// Workspace.getWorkspaceForApplication
|
|
||||||
// (Forum.this);
|
|
||||||
//
|
|
||||||
// if (parentWorkspace != null) {
|
|
||||||
// PermissionService.grantPermission
|
|
||||||
// (new PermissionDescriptor
|
|
||||||
// (PrivilegeDescriptor.WRITE,
|
|
||||||
// Forum.this,
|
|
||||||
// parentWorkspace.getMemberRole()));
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
protected void excurse() {
|
||||||
|
setParty(Kernel.getSystemParty());
|
||||||
|
// FIXME
|
||||||
|
// Workspace parentWorkspace =
|
||||||
|
// Workspace.getWorkspaceForApplication
|
||||||
|
// (Forum.this);
|
||||||
|
//
|
||||||
|
// if (parentWorkspace != null) {
|
||||||
|
// PermissionService.grantPermission
|
||||||
|
// (new PermissionDescriptor
|
||||||
|
// (PrivilegeDescriptor.WRITE,
|
||||||
|
// Forum.this,
|
||||||
|
// parentWorkspace.getMemberRole()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
excursion.run();
|
excursion.run();
|
||||||
} //if mWasNew
|
} //if mWasNew
|
||||||
|
|
@ -457,19 +456,19 @@ public class Forum extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if ( null != subs ) {
|
if (null != subs) {
|
||||||
subs.close();
|
subs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// chris.gilbert@westsussex.gov.uk line removed.
|
// chris.gilbert@westsussex.gov.uk line removed.
|
||||||
// afterSave in Application sets permission
|
// afterSave in Application sets permission
|
||||||
// context of forum to parent app (portal homepage)
|
// context of forum to parent app (portal homepage)
|
||||||
// don't want to inherit permissions of portal,
|
// don't want to inherit permissions of portal,
|
||||||
// as public users have 'READ' privilege on this
|
// as public users have 'READ' privilege on this
|
||||||
// and so get shown postings in search results.
|
// and so get shown postings in search results.
|
||||||
// super.afterSave();
|
// super.afterSave();
|
||||||
|
|
||||||
} //Method afterSave()
|
} //Method afterSave()
|
||||||
|
|
||||||
|
|
@ -477,12 +476,12 @@ public class Forum extends Application {
|
||||||
return BASE_DATA_OBJECT_TYPE;
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the Subscriptions associated with this Forum.
|
* Gets all the Subscriptions associated with this Forum.
|
||||||
*/
|
*/
|
||||||
public DataCollection getAllSubscriptions() {
|
public DataCollection getAllSubscriptions() {
|
||||||
DataAssociationCursor dac = ((DataAssociation) get(SUBSCRIPTIONS)).cursor();
|
DataAssociationCursor dac = ((DataAssociation) get(SUBSCRIPTIONS)).
|
||||||
|
cursor();
|
||||||
return dac;
|
return dac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -510,7 +509,7 @@ public class Forum extends Application {
|
||||||
* to use a custom DataQuery which does this.)
|
* to use a custom DataQuery which does this.)
|
||||||
*/
|
*/
|
||||||
public DataAssociation getPosts() {
|
public DataAssociation getPosts() {
|
||||||
return (DataAssociation)get(POSTS);
|
return (DataAssociation) get(POSTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -537,11 +536,11 @@ public class Forum extends Application {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DataAssociation getSuppressedPosts() {
|
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
|
// may disappear
|
||||||
DataAssociation posts = (DataAssociation) get(POSTS);
|
DataAssociation posts = (DataAssociation) get(POSTS);
|
||||||
posts.addEqualsFilter(Post.STATUS, Post.SUPPRESSED);
|
posts.addEqualsFilter(Post.STATUS, Post.SUPPRESSED);
|
||||||
return posts;
|
return posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -549,7 +548,7 @@ public class Forum extends Application {
|
||||||
* top-level posts which are not replies to any other post.
|
* top-level posts which are not replies to any other post.
|
||||||
*/
|
*/
|
||||||
public ThreadCollection getThreads() {
|
public ThreadCollection getThreads() {
|
||||||
return getThreads((BigDecimal)null);
|
return getThreads((BigDecimal) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -561,43 +560,42 @@ public class Forum extends Application {
|
||||||
public ThreadCollection getThreads(Party party) {
|
public ThreadCollection getThreads(Party party) {
|
||||||
ThreadCollection threads = getThreads();
|
ThreadCollection threads = getThreads();
|
||||||
|
|
||||||
if (isModerated() &&
|
if (isModerated() && !canModerate(party)) {
|
||||||
!canModerate(party)) {
|
s_log.debug("Only showing approved threads");
|
||||||
s_log.debug( "Only showing approved threads" );
|
|
||||||
threads.filterUnapproved(party);
|
threads.filterUnapproved(party);
|
||||||
}
|
}
|
||||||
|
|
||||||
return threads;
|
return threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a ThreadCollection of the threads in a specific Category.
|
* Gets a ThreadCollection of the threads in a specific Category.
|
||||||
*/
|
*/
|
||||||
public ThreadCollection getThreads(BigDecimal categoryID) {
|
public ThreadCollection getThreads(BigDecimal categoryID) {
|
||||||
|
|
||||||
DataCollection threadsData
|
DataCollection threadsData = SessionManager.getSession().retrieve(
|
||||||
= SessionManager.getSession().retrieve(
|
|
||||||
MessageThread.BASE_DATA_OBJECT_TYPE);
|
MessageThread.BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
|
|
||||||
threadsData.addEqualsFilter("root.objectID", getID());
|
threadsData.addEqualsFilter("root.objectID", getID());
|
||||||
|
|
||||||
if (categoryID != null) {
|
if (categoryID != null) {
|
||||||
// XXX bad dep on ui package
|
// XXX bad dep on ui package
|
||||||
if (categoryID.equals(com.arsdigita.forum.ui.Constants.TOPIC_NONE)) {
|
if (categoryID.equals(com.arsdigita.forum.ui.Constants.TOPIC_NONE)) {
|
||||||
Filter f = threadsData.addNotInSubqueryFilter
|
Filter f =
|
||||||
("root.id", "com.arsdigita.forum.uncategoryObject");
|
threadsData.addNotInSubqueryFilter("root.id",
|
||||||
} else {
|
"com.arsdigita.forum.uncategoryObject");
|
||||||
Filter f = threadsData.addInSubqueryFilter
|
} else {
|
||||||
("root.id", "com.arsdigita.forum.categoryObject");
|
Filter f =
|
||||||
f.set("categoryID", categoryID);
|
threadsData.addInSubqueryFilter("root.id",
|
||||||
}
|
"com.arsdigita.forum.categoryObject");
|
||||||
}
|
f.set("categoryID", categoryID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
threadsData.addOrder("lastUpdate desc");
|
threadsData.addOrder("lastUpdate desc");
|
||||||
|
|
||||||
return new ThreadCollection(threadsData);
|
return new ThreadCollection(threadsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -609,16 +607,15 @@ public class Forum extends Application {
|
||||||
Party party) {
|
Party party) {
|
||||||
ThreadCollection threads = getThreads(categoryID);
|
ThreadCollection threads = getThreads(categoryID);
|
||||||
|
|
||||||
if (isModerated() &&
|
if (isModerated() && !canModerate(party)) {
|
||||||
!canModerate(party)) {
|
s_log.debug("Only showing approved threads");
|
||||||
s_log.debug( "Only showing approved threads" );
|
|
||||||
threads.filterUnapproved(party);
|
threads.filterUnapproved(party);
|
||||||
}
|
}
|
||||||
|
|
||||||
return threads;
|
return threads;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up instant and daily subscriptions for the forum. Daily
|
* Sets up instant and daily subscriptions for the forum. Daily
|
||||||
|
|
@ -631,6 +628,7 @@ public class Forum extends Application {
|
||||||
s_log.debug("Creating subscriptions!");
|
s_log.debug("Creating subscriptions!");
|
||||||
|
|
||||||
new KernelExcursion() {
|
new KernelExcursion() {
|
||||||
|
|
||||||
protected void excurse() {
|
protected void excurse() {
|
||||||
setParty(Kernel.getSystemParty());
|
setParty(Kernel.getSystemParty());
|
||||||
|
|
||||||
|
|
@ -641,7 +639,7 @@ public class Forum extends Application {
|
||||||
new DailySubscription(Forum.this, party).save();
|
new DailySubscription(Forum.this, party).save();
|
||||||
|
|
||||||
Group moderators = getModerationGroup();
|
Group moderators = getModerationGroup();
|
||||||
if ( null != moderators ) {
|
if (null != moderators) {
|
||||||
|
|
||||||
s_log.debug("creatiing moderation subscription "
|
s_log.debug("creatiing moderation subscription "
|
||||||
+ moderators.getName());
|
+ moderators.getName());
|
||||||
|
|
@ -660,8 +658,8 @@ public class Forum extends Application {
|
||||||
*/
|
*/
|
||||||
public DataQuery getCategories() {
|
public DataQuery getCategories() {
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
DataQuery query = session.retrieveQuery
|
DataQuery query = session.retrieveQuery(
|
||||||
("com.arsdigita.forum.getCategorizationSummary");
|
"com.arsdigita.forum.getCategorizationSummary");
|
||||||
query.setParameter("forumID", getID());
|
query.setParameter("forumID", getID());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
@ -673,8 +671,8 @@ public class Forum extends Application {
|
||||||
*/
|
*/
|
||||||
public DataQuery getEmptyCategories() {
|
public DataQuery getEmptyCategories() {
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
DataQuery query = session.retrieveQuery
|
DataQuery query = session.retrieveQuery(
|
||||||
("com.arsdigita.forum.getUnusedCategories");
|
"com.arsdigita.forum.getUnusedCategories");
|
||||||
query.setParameter("forumID", getID());
|
query.setParameter("forumID", getID());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
@ -686,8 +684,8 @@ public class Forum extends Application {
|
||||||
*/
|
*/
|
||||||
public DataQuery getUnCategory() {
|
public DataQuery getUnCategory() {
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
DataQuery query = session.retrieveQuery
|
DataQuery query = session.retrieveQuery(
|
||||||
("com.arsdigita.forum.getUncategorizedSummary");
|
"com.arsdigita.forum.getUncategorizedSummary");
|
||||||
query.setParameter("forumID", getID());
|
query.setParameter("forumID", getID());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
@ -695,10 +693,11 @@ public class Forum extends Application {
|
||||||
public DataAssociationCursor getFilledCategories() {
|
public DataAssociationCursor getFilledCategories() {
|
||||||
Category root = getRootCategory();
|
Category root = getRootCategory();
|
||||||
DataAssociationCursor cursor =
|
DataAssociationCursor cursor =
|
||||||
root.getRelatedCategories(Category.CHILD);
|
root.getRelatedCategories(Category.CHILD);
|
||||||
|
|
||||||
Filter f = cursor.addInSubqueryFilter
|
Filter f =
|
||||||
("id", "com.arsdigita.forum.filledCategories");
|
cursor.addInSubqueryFilter("id",
|
||||||
|
"com.arsdigita.forum.filledCategories");
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -721,23 +720,23 @@ public class Forum extends Application {
|
||||||
* checks if the user can edit posts in this forum
|
* checks if the user can edit posts in this forum
|
||||||
*/
|
*/
|
||||||
public boolean canEdit(Party party) {
|
public boolean canEdit(Party party) {
|
||||||
return (getConfig().canAdminEditPosts() &&
|
return (getConfig().canAdminEditPosts() && PermissionService.
|
||||||
PermissionService.checkPermission(
|
checkPermission(
|
||||||
new PermissionDescriptor(PrivilegeDescriptor.EDIT,
|
new PermissionDescriptor(PrivilegeDescriptor.EDIT,
|
||||||
this,
|
this,
|
||||||
party)));
|
party)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAdminister(Party party) {
|
public boolean canAdminister(Party party) {
|
||||||
return PermissionService.checkPermission(
|
return PermissionService.checkPermission(
|
||||||
new PermissionDescriptor(PrivilegeDescriptor.ADMIN,
|
new PermissionDescriptor(PrivilegeDescriptor.ADMIN,
|
||||||
this,
|
this,
|
||||||
party));
|
party));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canModerate(Party party) {
|
public boolean canModerate(Party party) {
|
||||||
return PermissionService.checkPermission(
|
return PermissionService.checkPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(FORUM_MODERATION_PRIVILEGE),
|
PrivilegeDescriptor.get(FORUM_MODERATION_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
party));
|
party));
|
||||||
|
|
@ -749,15 +748,13 @@ public class Forum extends Application {
|
||||||
* automatically marked as approved.
|
* automatically marked as approved.
|
||||||
*/
|
*/
|
||||||
public void setModerated(boolean moderate) {
|
public void setModerated(boolean moderate) {
|
||||||
Boolean old = (Boolean)get(MODERATION);
|
Boolean old = (Boolean) get(MODERATION);
|
||||||
if (Boolean.TRUE.equals(old) &&
|
if (Boolean.TRUE.equals(old) && !moderate) {
|
||||||
!moderate) {
|
|
||||||
|
|
||||||
DataAssociationCursor posts = getPosts().cursor();
|
DataAssociationCursor posts = getPosts().cursor();
|
||||||
posts.addEqualsFilter(Post.STATUS, Post.PENDING);
|
posts.addEqualsFilter(Post.STATUS, Post.PENDING);
|
||||||
while (posts.next()) {
|
while (posts.next()) {
|
||||||
Post post
|
Post post = (Post) DomainObjectFactory.newInstance(
|
||||||
= (Post)DomainObjectFactory.newInstance(
|
|
||||||
posts.getDataObject());
|
posts.getDataObject());
|
||||||
post.setStatus(Post.APPROVED);
|
post.setStatus(Post.APPROVED);
|
||||||
post.save();
|
post.save();
|
||||||
|
|
@ -768,13 +765,13 @@ public class Forum extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isModerated() {
|
public boolean isModerated() {
|
||||||
Boolean isModerated = (Boolean)get(MODERATION);
|
Boolean isModerated = (Boolean) get(MODERATION);
|
||||||
Assert.exists(isModerated);
|
Assert.exists(isModerated);
|
||||||
return isModerated.booleanValue();
|
return isModerated.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
Boolean isPublic = (Boolean)get(PUBLIC);
|
Boolean isPublic = (Boolean) get(PUBLIC);
|
||||||
Assert.exists(isPublic);
|
Assert.exists(isPublic);
|
||||||
return isPublic.booleanValue();
|
return isPublic.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
@ -800,13 +797,13 @@ public class Forum extends Application {
|
||||||
DataObject dObj = (DataObject) get(ADMIN_GROUP);
|
DataObject dObj = (DataObject) get(ADMIN_GROUP);
|
||||||
Assert.exists(dObj, DataObject.class);
|
Assert.exists(dObj, DataObject.class);
|
||||||
return (Group) DomainObjectFactory.newInstance(dObj);
|
return (Group) DomainObjectFactory.newInstance(dObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the moderator group. Null if it doesn't exist */
|
/** Returns the moderator group. Null if it doesn't exist */
|
||||||
public Group getModerationGroup() {
|
public Group getModerationGroup() {
|
||||||
DataObject dObj = (DataObject) get( MODERATION_GROUP );
|
DataObject dObj = (DataObject) get(MODERATION_GROUP);
|
||||||
Assert.exists(dObj, DataObject.class);
|
Assert.exists(dObj, DataObject.class);
|
||||||
return (Group)DomainObjectFactory.newInstance(dObj);
|
return (Group) DomainObjectFactory.newInstance(dObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the thread create group. Null if it doesn't exist */
|
/** Returns the thread create group. Null if it doesn't exist */
|
||||||
|
|
@ -843,20 +840,21 @@ public class Forum extends Application {
|
||||||
}
|
}
|
||||||
LifecycleDefinition newLife = new LifecycleDefinition();
|
LifecycleDefinition newLife = new LifecycleDefinition();
|
||||||
newLife.setLabel("Delete expired noticeboard postings");
|
newLife.setLabel("Delete expired noticeboard postings");
|
||||||
newLife.addPhaseDefinition("Forum posting lifespan",
|
newLife.addPhaseDefinition("Forum posting lifespan",
|
||||||
null,
|
null,
|
||||||
new Integer(0),
|
new Integer(0),
|
||||||
new Integer(1440 * value), // in minutes
|
new Integer(1440 * value), // in minutes
|
||||||
null);
|
null);
|
||||||
setLifecycleDefinition(newLife);
|
setLifecycleDefinition(newLife);
|
||||||
// We must make sure that all existing postings in this forum
|
// We must make sure that all existing postings in this forum
|
||||||
// have the same expiration policy.
|
// have the same expiration policy.
|
||||||
DataAssociationCursor posts = getPosts().cursor();
|
DataAssociationCursor posts = getPosts().cursor();
|
||||||
while (posts.next()) {
|
while (posts.next()) {
|
||||||
Post post = (Post) DomainObjectFactory.newInstance(posts.getDataObject());
|
Post post = (Post) DomainObjectFactory.newInstance(posts.
|
||||||
if (post.getThread().getRootMessage().getID()
|
getDataObject());
|
||||||
.equals(post.getID())) {
|
if (post.getThread().getRootMessage().getID().equals(post.getID())) {
|
||||||
s_log.debug("Resetting expiration lifecycle for " + post.getOID());
|
s_log.debug("Resetting expiration lifecycle for "
|
||||||
|
+ post.getOID());
|
||||||
post.setLifecycle(newLife);
|
post.setLifecycle(newLife);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -892,7 +890,7 @@ public class Forum extends Application {
|
||||||
public void setAdminGroup(Group group) {
|
public void setAdminGroup(Group group) {
|
||||||
setAssociation(ADMIN_GROUP, group);
|
setAssociation(ADMIN_GROUP, group);
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, group));
|
new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -904,10 +902,10 @@ public class Forum extends Application {
|
||||||
public void setThreadCreatorGroup(Group group) {
|
public void setThreadCreatorGroup(Group group) {
|
||||||
setAssociation(THREAD_CREATE_GROUP, group);
|
setAssociation(THREAD_CREATE_GROUP, group);
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(CREATE_THREAD_PRIVILEGE),
|
PrivilegeDescriptor.get(CREATE_THREAD_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
group));
|
group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -919,10 +917,10 @@ public class Forum extends Application {
|
||||||
public void setThreadResponderGroup(Group group) {
|
public void setThreadResponderGroup(Group group) {
|
||||||
setAssociation(THREAD_RESPONDER_GROUP, group);
|
setAssociation(THREAD_RESPONDER_GROUP, group);
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(RESPOND_TO_THREAD_PRIVILEGE),
|
PrivilegeDescriptor.get(RESPOND_TO_THREAD_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
group));
|
group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -934,8 +932,8 @@ public class Forum extends Application {
|
||||||
public void setReaderGroup(Group group) {
|
public void setReaderGroup(Group group) {
|
||||||
setAssociation(READ_GROUP, group);
|
setAssociation(READ_GROUP, group);
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.READ, this, group));
|
PrivilegeDescriptor.READ, this, group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -944,40 +942,44 @@ public class Forum extends Application {
|
||||||
public boolean allowFileAttachments() {
|
public boolean allowFileAttachments() {
|
||||||
return ((Boolean) get(ALLOW_FILE_ATTACHMENTS)).booleanValue();
|
return ((Boolean) get(ALLOW_FILE_ATTACHMENTS)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowImageUploads() {
|
public boolean allowImageUploads() {
|
||||||
return ((Boolean) get(ALLOW_IMAGE_UPLOADS)).booleanValue();
|
return ((Boolean) get(ALLOW_IMAGE_UPLOADS)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean autoSubscribeThreadStarter() {
|
public boolean autoSubscribeThreadStarter() {
|
||||||
return ((Boolean) get(AUTOSUBSCRIBE_THREAD_STARTER)).booleanValue();
|
return ((Boolean) get(AUTOSUBSCRIBE_THREAD_STARTER)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean noCategoryPostsAllowed() {
|
public boolean noCategoryPostsAllowed() {
|
||||||
return ((Boolean) get(NO_CATEGORY_POSTS)).booleanValue();
|
return ((Boolean) get(NO_CATEGORY_POSTS)).booleanValue();
|
||||||
}
|
}
|
||||||
public boolean anonymousPostsAllowed() {
|
|
||||||
return ((Boolean) get(ANONYMOUS_POSTS)).booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAllowFileAttachments(boolean allow) {
|
public boolean anonymousPostsAllowed() {
|
||||||
set(ALLOW_FILE_ATTACHMENTS, new Boolean(allow));
|
return ((Boolean) get(ANONYMOUS_POSTS)).booleanValue();
|
||||||
}
|
}
|
||||||
public void setAllowImageUploads(boolean allow) {
|
|
||||||
set(ALLOW_IMAGE_UPLOADS, new Boolean(allow));
|
|
||||||
}
|
|
||||||
public void setAutoSubscribeThreadCreator(boolean subscribe) {
|
|
||||||
set(AUTOSUBSCRIBE_THREAD_STARTER, new Boolean(subscribe));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoCategoryPostsAllowed(boolean allow) {
|
public void setAllowFileAttachments(boolean allow) {
|
||||||
set(NO_CATEGORY_POSTS, new Boolean(allow));
|
set(ALLOW_FILE_ATTACHMENTS, new Boolean(allow));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAllowImageUploads(boolean allow) {
|
||||||
|
set(ALLOW_IMAGE_UPLOADS, new Boolean(allow));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoSubscribeThreadCreator(boolean subscribe) {
|
||||||
|
set(AUTOSUBSCRIBE_THREAD_STARTER, new Boolean(subscribe));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoCategoryPostsAllowed(boolean allow) {
|
||||||
|
set(NO_CATEGORY_POSTS, new Boolean(allow));
|
||||||
|
}
|
||||||
|
|
||||||
public void setAnonymousPostsAllowed(boolean allow) {
|
public void setAnonymousPostsAllowed(boolean allow) {
|
||||||
set(ANONYMOUS_POSTS, new Boolean(allow));
|
set(ANONYMOUS_POSTS, new Boolean(allow));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle (String title) {
|
public void setTitle(String title) {
|
||||||
String oldTitle = getTitle();
|
String oldTitle = getTitle();
|
||||||
super.setTitle(title);
|
super.setTitle(title);
|
||||||
if (!oldTitle.equals(title)) {
|
if (!oldTitle.equals(title)) {
|
||||||
|
|
@ -990,18 +992,19 @@ public class Forum extends Application {
|
||||||
|
|
||||||
DataCollection subscriptions = getSubscriptions();
|
DataCollection subscriptions = getSubscriptions();
|
||||||
while (subscriptions.next()) {
|
while (subscriptions.next()) {
|
||||||
ForumSubscription
|
ForumSubscription subscription =
|
||||||
subscription = (ForumSubscription)DomainObjectFactory.
|
(ForumSubscription) DomainObjectFactory.
|
||||||
newInstance(subscriptions.getDataObject());
|
newInstance(subscriptions.getDataObject());
|
||||||
subscription.getGroup().setName(subscription.getGroupName(this));
|
subscription.getGroup().setName(subscription.getGroupName(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadCollection threads = getThreads();
|
ThreadCollection threads = getThreads();
|
||||||
while (threads.next()) {
|
while (threads.next()) {
|
||||||
ThreadSubscription threadSub = ThreadSubscription.
|
ThreadSubscription threadSub = ThreadSubscription.
|
||||||
getThreadSubscription(
|
getThreadSubscription(
|
||||||
threads.getMessageThread());
|
threads.getMessageThread());
|
||||||
threadSub.getGroup().setName(threadSub.getSubscriptionGroupName(this));
|
threadSub.getGroup().setName(threadSub.getSubscriptionGroupName(
|
||||||
|
this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1016,7 +1019,6 @@ public class Forum extends Application {
|
||||||
// public String getContextPath() {
|
// public String getContextPath() {
|
||||||
// return "/ccm-forum";
|
// return "/ccm-forum";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path name of the location of the applications servlet/JSP.
|
* Returns the path name of the location of the applications servlet/JSP.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.forum;
|
package com.arsdigita.forum;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.forum.portlet.MyForumsPortlet;
|
import com.arsdigita.forum.portlet.MyForumsPortlet;
|
||||||
import com.arsdigita.forum.portlet.RecentPostingsPortlet;
|
import com.arsdigita.forum.portlet.RecentPostingsPortlet;
|
||||||
import com.arsdigita.kernel.EmailAddress;
|
import com.arsdigita.kernel.EmailAddress;
|
||||||
|
|
@ -38,7 +37,6 @@ import com.arsdigita.web.ApplicationType;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loader executes nonrecurring at install time and loads (installs and
|
* Loader executes nonrecurring at install time and loads (installs and
|
||||||
* initializes) the Forum module.
|
* initializes) the Forum module.
|
||||||
|
|
@ -57,6 +55,7 @@ public class Loader extends PackageLoader {
|
||||||
|
|
||||||
public void run(final ScriptContext ctx) {
|
public void run(final ScriptContext ctx) {
|
||||||
new KernelExcursion() {
|
new KernelExcursion() {
|
||||||
|
|
||||||
public void excurse() {
|
public void excurse() {
|
||||||
setEffectiveParty(Kernel.getSystemParty());
|
setEffectiveParty(Kernel.getSystemParty());
|
||||||
|
|
||||||
|
|
@ -77,25 +76,24 @@ public class Loader extends PackageLoader {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static ApplicationType setupForumAppType() {
|
private static ApplicationType setupForumAppType() {
|
||||||
ApplicationType type = ApplicationType
|
ApplicationType type =
|
||||||
.createApplicationType(Forum.PACKAGE_TYPE,
|
ApplicationType.createApplicationType(Forum.PACKAGE_TYPE,
|
||||||
"Discussion Forum Application",
|
"Discussion Forum Application",
|
||||||
Forum.BASE_DATA_OBJECT_TYPE);
|
Forum.BASE_DATA_OBJECT_TYPE);
|
||||||
type.setDescription("An electronic bulletin board system.");
|
type.setDescription("An electronic bulletin board system.");
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: What is it for? Execution is currently commented out.
|
* TODO: What is it for? Execution is currently commented out.
|
||||||
* Referenced class com.arsdigita.forum.Inbox does not exist.
|
* Referenced class com.arsdigita.forum.Inbox does not exist.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static ApplicationType setupInboxAppType() {
|
private static ApplicationType setupInboxAppType() {
|
||||||
ApplicationType type = ApplicationType
|
ApplicationType type =
|
||||||
.createApplicationType(Forum.PACKAGE_TYPE,
|
ApplicationType.createApplicationType(Forum.PACKAGE_TYPE,
|
||||||
"Inbox",
|
"Inbox",
|
||||||
"com.arsdigita.forum.Inbox");
|
"com.arsdigita.forum.Inbox");
|
||||||
type.setDescription("Inbox");
|
type.setDescription("Inbox");
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
@ -105,25 +103,26 @@ public class Loader extends PackageLoader {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static AppPortletType setupRecentPostingsPortletType() {
|
public static AppPortletType setupRecentPostingsPortletType() {
|
||||||
AppPortletType type = AppPortletType
|
AppPortletType type =
|
||||||
.createAppPortletType("Recent Forum Postings",
|
AppPortletType.createAppPortletType(
|
||||||
PortletType.WIDE_PROFILE,
|
"Recent Forum Postings",
|
||||||
RecentPostingsPortlet.BASE_DATA_OBJECT_TYPE);
|
PortletType.WIDE_PROFILE,
|
||||||
|
RecentPostingsPortlet.BASE_DATA_OBJECT_TYPE);
|
||||||
type.setProviderApplicationType(Forum.BASE_DATA_OBJECT_TYPE);
|
type.setProviderApplicationType(Forum.BASE_DATA_OBJECT_TYPE);
|
||||||
type.setPortalApplication(true);
|
type.setPortalApplication(true);
|
||||||
type.setDescription("Displays the most recent postings " +
|
type.setDescription("Displays the most recent postings "
|
||||||
"to the bulletin board.");
|
+ "to the bulletin board.");
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PortletType setupMyForumsPortletType() {
|
public static PortletType setupMyForumsPortletType() {
|
||||||
|
|
||||||
PortletType type = PortletType.createPortletType(
|
PortletType type = PortletType.createPortletType(
|
||||||
"My Forums",
|
"My Forums",
|
||||||
PortletType.WIDE_PROFILE,
|
PortletType.WIDE_PROFILE,
|
||||||
MyForumsPortlet.BASE_DATA_OBJECT_TYPE);
|
MyForumsPortlet.BASE_DATA_OBJECT_TYPE);
|
||||||
type.setDescription("Lists forums that user has access to, " + "" +
|
type.setDescription("Lists forums that user has access to, " + ""
|
||||||
" with last posting date");
|
+ " with last posting date");
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
@ -159,22 +158,18 @@ public class Loader extends PackageLoader {
|
||||||
*/
|
*/
|
||||||
public static void setupPrivileges() {
|
public static void setupPrivileges() {
|
||||||
|
|
||||||
PrivilegeDescriptor.createPrivilege(
|
PrivilegeDescriptor.createPrivilege(Forum.FORUM_READ_PRIVILEGE);
|
||||||
Forum.FORUM_MODERATION_PRIVILEGE);
|
PrivilegeDescriptor.createPrivilege(Forum.FORUM_MODERATION_PRIVILEGE);
|
||||||
PrivilegeDescriptor.createPrivilege(
|
PrivilegeDescriptor.createPrivilege(Forum.CREATE_THREAD_PRIVILEGE);
|
||||||
Forum.CREATE_THREAD_PRIVILEGE);
|
PrivilegeDescriptor.createPrivilege(Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
||||||
PrivilegeDescriptor.createPrivilege(
|
|
||||||
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
|
||||||
// Establich privilege hierarchie, eg. moderation includes createThread
|
// Establich privilege hierarchie, eg. moderation includes createThread
|
||||||
PrivilegeDescriptor.addChildPrivilege(
|
PrivilegeDescriptor.addChildPrivilege(Forum.FORUM_MODERATION_PRIVILEGE,
|
||||||
Forum.FORUM_MODERATION_PRIVILEGE,
|
Forum.CREATE_THREAD_PRIVILEGE);
|
||||||
Forum.CREATE_THREAD_PRIVILEGE);
|
PrivilegeDescriptor.addChildPrivilege(Forum.CREATE_THREAD_PRIVILEGE,
|
||||||
PrivilegeDescriptor.addChildPrivilege(
|
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
||||||
Forum.CREATE_THREAD_PRIVILEGE,
|
PrivilegeDescriptor.addChildPrivilege(Forum.RESPOND_TO_THREAD_PRIVILEGE,
|
||||||
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
PrivilegeDescriptor.READ.getName()); // general read privilege
|
||||||
PrivilegeDescriptor.addChildPrivilege(
|
PrivilegeDescriptor.addChildPrivilege(Forum.RESPOND_TO_THREAD_PRIVILEGE,
|
||||||
Forum.RESPOND_TO_THREAD_PRIVILEGE,
|
Forum.FORUM_READ_PRIVILEGE);
|
||||||
PrivilegeDescriptor.READ.getName()); // general read privilege
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,13 +55,13 @@ import com.arsdigita.xml.Element;
|
||||||
*
|
*
|
||||||
* @author Kevin Scaldeferri (kevin@arsdigita.com)
|
* @author Kevin Scaldeferri (kevin@arsdigita.com)
|
||||||
* @author Chris Gilbert (chrisg23)
|
* @author Chris Gilbert (chrisg23)
|
||||||
|
* @author Jens Pelzetter (jensp)
|
||||||
* @version $Revision: 1.3 $ $Author: chrisg23 $ $Date: 2006/03/09 13:48:15 $
|
* @version $Revision: 1.3 $ $Author: chrisg23 $ $Date: 2006/03/09 13:48:15 $
|
||||||
*/
|
*/
|
||||||
public class ForumUserCompactView extends ModalContainer implements Constants {
|
public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
|
|
||||||
/** Private logger instance for debugging purpose. */
|
/** Private logger instance for debugging purpose. */
|
||||||
private static Logger s_log = Logger.getLogger(ForumUserCompactView.class);
|
private static Logger s_log = Logger.getLogger(ForumUserCompactView.class);
|
||||||
|
|
||||||
// Denotes the 6 panels of the user interface, also used as marker to store
|
// Denotes the 6 panels of the user interface, also used as marker to store
|
||||||
// and select the active panel
|
// and select the active panel
|
||||||
/** Denotation of the 'threads' forum mode */
|
/** Denotation of the 'threads' forum mode */
|
||||||
|
|
@ -74,16 +74,15 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
public static final String MODE_MODERATION = "moderation";
|
public static final String MODE_MODERATION = "moderation";
|
||||||
/** Denominator of the 'permission administration' forum mode
|
/** Denominator of the 'permission administration' forum mode
|
||||||
* (administrators only) */
|
* (administrators only) */
|
||||||
public static final String MODE_PERMISSIONS = "permissions";
|
public static final String MODE_PERMISSIONS = "permissions";
|
||||||
/** Denominator of the 'configuration' forum mode (administrators only)*/
|
/** Denominator of the 'configuration' forum mode (administrators only)*/
|
||||||
public static final String MODE_SETUP = "setup";
|
public static final String MODE_SETUP = "setup";
|
||||||
/** Holds the current active mode */
|
/** Holds the current active mode */
|
||||||
private StringParameter m_mode;
|
private StringParameter m_mode;
|
||||||
|
|
||||||
/** Object containing the threads panel (main working panel for users) */
|
/** Object containing the threads panel (main working panel for users) */
|
||||||
private ThreadsPanel m_threadsView;
|
private ThreadsPanel m_threadsView;
|
||||||
/** Object containing the topics panel */
|
/** Object containing the topics panel */
|
||||||
private TopicsPanel m_topicsView;
|
private TopicsPanel m_topicsView;
|
||||||
/** Object containing the alerts management panel */
|
/** Object containing the alerts management panel */
|
||||||
private ForumAlertsView m_alertsView;
|
private ForumAlertsView m_alertsView;
|
||||||
/** Object containing the moderation panel */
|
/** Object containing the moderation panel */
|
||||||
|
|
@ -104,9 +103,9 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
m_mode = new StringParameter("mode");
|
m_mode = new StringParameter("mode");
|
||||||
|
|
||||||
// setup panels which make up the forum
|
// setup panels which make up the forum
|
||||||
m_threadsView = new ThreadsPanel();
|
m_threadsView = new ThreadsPanel();
|
||||||
m_topicsView = new TopicsPanel();
|
m_topicsView = new TopicsPanel();
|
||||||
m_alertsView = new ForumAlertsView();
|
m_alertsView = new ForumAlertsView();
|
||||||
// administration section
|
// administration section
|
||||||
m_moderationView = new ModerationView();
|
m_moderationView = new ModerationView();
|
||||||
m_setupView = new SetupView();
|
m_setupView = new SetupView();
|
||||||
|
|
@ -138,18 +137,18 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
* @param state
|
* @param state
|
||||||
* @throws ServletException
|
* @throws ServletException
|
||||||
*/
|
*/
|
||||||
public void respond(PageState state) throws ServletException {
|
public void respond(PageState state) throws ServletException {
|
||||||
|
|
||||||
super.respond(state);
|
super.respond(state);
|
||||||
|
|
||||||
Party party = Kernel.getContext().getParty();
|
Party party = Kernel.getContext().getParty();
|
||||||
Forum forum = ForumContext.getContext(state).getForum();
|
Forum forum = ForumContext.getContext(state).getForum();
|
||||||
|
|
||||||
String mode = (String)state.getControlEventValue();
|
String mode = (String) state.getControlEventValue();
|
||||||
state.setValue(m_mode, mode);
|
state.setValue(m_mode, mode);
|
||||||
|
|
||||||
setVisible(state, party, forum, mode);
|
setVisible(state, party, forum, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for the given forum mode (parameter value) whether its prerequisites
|
* Checks for the given forum mode (parameter value) whether its prerequisites
|
||||||
|
|
@ -163,11 +162,12 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
* @param forum the forum instance to handle
|
* @param forum the forum instance to handle
|
||||||
* @param mode forum mode to check visibility for
|
* @param mode forum mode to check visibility for
|
||||||
*/
|
*/
|
||||||
protected void setVisible( PageState state, Party party,
|
protected void setVisible(PageState state, Party party,
|
||||||
Forum forum, String mode) {
|
Forum forum, String mode) {
|
||||||
|
|
||||||
PermissionDescriptor forumAdmin =
|
PermissionDescriptor forumAdmin =
|
||||||
new PermissionDescriptor(PrivilegeDescriptor.ADMIN, forum, party);
|
new PermissionDescriptor(PrivilegeDescriptor.ADMIN,
|
||||||
|
forum, party);
|
||||||
|
|
||||||
PermissionService.assertPermission(forumAdmin);
|
PermissionService.assertPermission(forumAdmin);
|
||||||
|
|
||||||
|
|
@ -180,7 +180,7 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
}
|
}
|
||||||
setVisibleComponent(state, m_topicsView);
|
setVisibleComponent(state, m_topicsView);
|
||||||
} else if (MODE_ALERTS.equals(mode)) {
|
} else if (MODE_ALERTS.equals(mode)) {
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
UserContext.redirectToLoginPage(state.getRequest());
|
UserContext.redirectToLoginPage(state.getRequest());
|
||||||
}
|
}
|
||||||
setVisibleComponent(state, m_alertsView);
|
setVisibleComponent(state, m_alertsView);
|
||||||
|
|
@ -222,23 +222,23 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
Element content = generateParent(parent);
|
Element content = generateParent(parent);
|
||||||
Forum forum = ForumContext.getContext(state).getForum();
|
Forum forum = ForumContext.getContext(state).getForum();
|
||||||
content.addAttribute("title", forum.getTitle());
|
content.addAttribute("title", forum.getTitle());
|
||||||
content.addAttribute(
|
content.addAttribute(
|
||||||
"noticeboard",
|
"noticeboard",
|
||||||
(new Boolean(forum.isNoticeboard())).toString());
|
(new Boolean(forum.isNoticeboard())).toString());
|
||||||
|
|
||||||
// If visitor not logged in, set user (=party) to publicUser
|
// If visitor not logged in, set user (=party) to publicUser
|
||||||
Party party = Kernel.getContext().getParty();
|
Party party = Kernel.getContext().getParty();
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
party = Kernel.getPublicUser();
|
party = Kernel.getPublicUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate tab bar for panel (mode) selection
|
// generate tab bar for panel (mode) selection
|
||||||
generateModes(state, content, party, forum);
|
generateModes(state, content, party, forum);
|
||||||
// generate
|
// generate
|
||||||
generateChildrenXML(state, content);
|
generateChildrenXML(state, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the mode selection facility (usually a tab bar)
|
* Initializes the mode selection facility (usually a tab bar)
|
||||||
*
|
*
|
||||||
* @param state
|
* @param state
|
||||||
|
|
@ -249,20 +249,31 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
protected void generateModes(PageState state, Element content,
|
protected void generateModes(PageState state, Element content,
|
||||||
Party party, Forum forum) {
|
Party party, Forum forum) {
|
||||||
|
|
||||||
PermissionDescriptor permission =
|
PermissionDescriptor permission = new PermissionDescriptor(
|
||||||
new PermissionDescriptor(PrivilegeDescriptor.ADMIN, forum, party);
|
PrivilegeDescriptor.ADMIN,
|
||||||
|
forum,
|
||||||
|
party);
|
||||||
|
PermissionDescriptor readPermission = new PermissionDescriptor(
|
||||||
|
PrivilegeDescriptor.get(Forum.FORUM_READ_PRIVILEGE),
|
||||||
|
forum,
|
||||||
|
party);
|
||||||
|
|
||||||
// currently thread panel is always shown. If read access should be
|
|
||||||
|
// currently thread panel is always shown. If read access should be
|
||||||
// bound to logged in users, additional logic is required here.
|
// bound to logged in users, additional logic is required here.
|
||||||
generateModeXML(state, content, MODE_THREADS,
|
// jensp 2011-10-02: Additional logic added
|
||||||
Text.gz("forum.ui.modeThreads"));
|
if (!forum.isPublic()
|
||||||
|
&& PermissionService.checkPermission(readPermission)) {
|
||||||
|
generateModeXML(state, content, MODE_THREADS,
|
||||||
|
Text.gz("forum.ui.modeThreads"));
|
||||||
|
}
|
||||||
// topics panel is always shoen as well if not restricted to admins.
|
// topics panel is always shoen as well if not restricted to admins.
|
||||||
if (!Forum.getConfig().topicCreationByAdminOnly()) {
|
if (!Forum.getConfig().topicCreationByAdminOnly()) {
|
||||||
generateModeXML(state, content, MODE_TOPICS,
|
generateModeXML(state, content, MODE_TOPICS,
|
||||||
Text.gz("forum.ui.modeTopics"));
|
Text.gz("forum.ui.modeTopics"));
|
||||||
}
|
}
|
||||||
// alerts panel is always shown as well, no private read access avail.
|
// alerts panel is always shown as well, no private read access avail.
|
||||||
generateModeXML(state, content, MODE_ALERTS,
|
generateModeXML(state, content, MODE_ALERTS,
|
||||||
Text.gz("forum.ui.modeAlerts"));
|
Text.gz("forum.ui.modeAlerts"));
|
||||||
|
|
||||||
// admin section
|
// admin section
|
||||||
|
|
@ -278,7 +289,7 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
// In case topic creation is bound to admin (and therefore not
|
// In case topic creation is bound to admin (and therefore not
|
||||||
// created above) we must create xml here.
|
// created above) we must create xml here.
|
||||||
if (Forum.getConfig().topicCreationByAdminOnly()) {
|
if (Forum.getConfig().topicCreationByAdminOnly()) {
|
||||||
generateModeXML(state, content, MODE_TOPICS,
|
generateModeXML(state, content, MODE_TOPICS,
|
||||||
Text.gz("forum.ui.modeTopics"));
|
Text.gz("forum.ui.modeTopics"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,31 +311,31 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
Element parent,
|
Element parent,
|
||||||
String mode) {
|
String mode) {
|
||||||
generateModeXML(state, parent, mode, null);
|
generateModeXML(state, parent, mode, null);
|
||||||
/*
|
/*
|
||||||
String current = (String)state.getValue(m_mode);
|
String current = (String)state.getValue(m_mode);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
current = MODE_THREADS; // used as default mode
|
current = MODE_THREADS; // used as default mode
|
||||||
}
|
}
|
||||||
|
|
||||||
Element content =
|
Element content =
|
||||||
parent.newChildElement(FORUM_XML_PREFIX + ":forumMode", FORUM_XML_NS);
|
parent.newChildElement(FORUM_XML_PREFIX + ":forumMode", FORUM_XML_NS);
|
||||||
|
|
||||||
state.setControlEvent(this, "mode", mode);
|
state.setControlEvent(this, "mode", mode);
|
||||||
|
|
||||||
content.addAttribute("mode",
|
content.addAttribute("mode",
|
||||||
mode);
|
mode);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
content.addAttribute("url",
|
content.addAttribute("url",
|
||||||
state.stateAsURL());
|
state.stateAsURL());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedWrapperException("cannot create url", ex);
|
throw new UncheckedWrapperException("cannot create url", ex);
|
||||||
}
|
}
|
||||||
content.addAttribute("selected",
|
content.addAttribute("selected",
|
||||||
current.equals(mode) ? "1" : "0");
|
current.equals(mode) ? "1" : "0");
|
||||||
state.clearControlEvent();
|
state.clearControlEvent();
|
||||||
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -340,15 +351,16 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
protected void generateModeXML(PageState state,
|
protected void generateModeXML(PageState state,
|
||||||
Element parent,
|
Element parent,
|
||||||
String mode,
|
String mode,
|
||||||
GlobalizedMessage label ) {
|
GlobalizedMessage label) {
|
||||||
|
|
||||||
String current = (String)state.getValue(m_mode);
|
String current = (String) state.getValue(m_mode);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
current = MODE_THREADS; // used as default mode
|
current = MODE_THREADS; // used as default mode
|
||||||
}
|
}
|
||||||
|
|
||||||
Element content =
|
Element content =
|
||||||
parent.newChildElement(FORUM_XML_PREFIX + ":forumMode", FORUM_XML_NS);
|
parent.newChildElement(FORUM_XML_PREFIX + ":forumMode",
|
||||||
|
FORUM_XML_NS);
|
||||||
|
|
||||||
state.setControlEvent(this, "mode", mode);
|
state.setControlEvent(this, "mode", mode);
|
||||||
|
|
||||||
|
|
@ -369,14 +381,11 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
|
||||||
"UNAVAILABLE");
|
"UNAVAILABLE");
|
||||||
} else {
|
} else {
|
||||||
content.addAttribute("label",
|
content.addAttribute("label",
|
||||||
(String)label.localize());
|
(String) label.localize());
|
||||||
}
|
}
|
||||||
// add if current mode is actually selected
|
// add if current mode is actually selected
|
||||||
content.addAttribute("selected",
|
content.addAttribute("selected",
|
||||||
current.equals(mode) ? "1" : "0");
|
current.equals(mode) ? "1" : "0");
|
||||||
state.clearControlEvent();
|
state.clearControlEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue