0001: /**********************************************************************************
0002: * $URL: https://source.sakaiproject.org/svn/msgcntr/trunk/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/ui/UIPermissionsManagerImpl.java $
0003: * $Id: UIPermissionsManagerImpl.java 9227 2006-05-15 15:02:42Z cwen@iupui.edu $
0004: ***********************************************************************************
0005: *
0006: * Copyright (c) 2003, 2004, 2005, 2006, 2007 The Sakai Foundation.
0007: *
0008: * Licensed under the Educational Community License, Version 1.0 (the "License");
0009: * you may not use this file except in compliance with the License.
0010: * You may obtain a copy of the License at
0011: *
0012: * http://www.opensource.org/licenses/ecl1.php
0013: *
0014: * Unless required by applicable law or agreed to in writing, software
0015: * distributed under the License is distributed on an "AS IS" BASIS,
0016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017: * See the License for the specific language governing permissions and
0018: * limitations under the License.
0019: *
0020: **********************************************************************************/package org.sakaiproject.component.app.messageforums.ui;
0021:
0022: import java.util.ArrayList;
0023: import java.util.Collection;
0024: import java.util.HashSet;
0025: import java.util.Iterator;
0026: import java.util.List;
0027: import java.util.Set;
0028:
0029: import org.apache.commons.logging.Log;
0030: import org.apache.commons.logging.LogFactory;
0031: import org.sakaiproject.api.app.messageforums.Area;
0032: import org.sakaiproject.api.app.messageforums.AreaManager;
0033: import org.sakaiproject.api.app.messageforums.DBMembershipItem;
0034: import org.sakaiproject.api.app.messageforums.DiscussionForum;
0035: import org.sakaiproject.api.app.messageforums.DiscussionTopic;
0036: import org.sakaiproject.api.app.messageforums.MessageForumsTypeManager;
0037: import org.sakaiproject.api.app.messageforums.PermissionLevel;
0038: import org.sakaiproject.api.app.messageforums.PermissionLevelManager;
0039: import org.sakaiproject.api.app.messageforums.PermissionManager;
0040: import org.sakaiproject.api.app.messageforums.ui.DiscussionForumManager;
0041: import org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager;
0042: import org.sakaiproject.authz.api.AuthzGroupService;
0043: import org.sakaiproject.authz.api.Member;
0044: import org.sakaiproject.authz.api.SecurityService;
0045: import org.sakaiproject.component.app.messageforums.TestUtil;
0046: import org.sakaiproject.component.app.messageforums.dao.hibernate.DBMembershipItemImpl;
0047: import org.sakaiproject.exception.IdUnusedException;
0048: import org.sakaiproject.site.api.Group;
0049: import org.sakaiproject.site.api.Site;
0050: import org.sakaiproject.site.cover.SiteService;
0051: import org.sakaiproject.tool.api.Placement;
0052: import org.sakaiproject.tool.api.SessionManager;
0053: import org.sakaiproject.tool.api.ToolManager;
0054: import org.sakaiproject.user.api.User;
0055: import org.sakaiproject.user.cover.UserDirectoryService;
0056: import org.sakaiproject.thread_local.cover.ThreadLocalManager;
0057:
0058: /**
0059: * @author <a href="mailto:rshastri@iupui.edu">Rashmi Shastri</a>
0060: */
0061: public class UIPermissionsManagerImpl implements UIPermissionsManager {
0062: private static final Log LOG = LogFactory
0063: .getLog(UIPermissionsManagerImpl.class);
0064:
0065: // dependencies
0066: private AuthzGroupService authzGroupService;
0067: private SessionManager sessionManager;
0068: private ToolManager toolManager;
0069: private PermissionManager permissionManager;
0070: private PermissionLevelManager permissionLevelManager;
0071: private MessageForumsTypeManager typeManager;
0072: private SecurityService securityService;
0073: private DiscussionForumManager forumManager;
0074: private AreaManager areaManager;
0075:
0076: public void init() {
0077: LOG.info("init()");
0078: ;
0079: }
0080:
0081: /**
0082: * @param areaManager
0083: * The areaManager to set.
0084: */
0085: public void setAreaManager(AreaManager areaManager) {
0086: this .areaManager = areaManager;
0087: }
0088:
0089: /**
0090: * @param forumManager
0091: * The forumManager to set.
0092: */
0093: public void setForumManager(DiscussionForumManager forumManager) {
0094: this .forumManager = forumManager;
0095: }
0096:
0097: /**
0098: * @param authzGroupService
0099: * The authzGroupService to set.
0100: */
0101: public void setAuthzGroupService(AuthzGroupService authzGroupService) {
0102: if (LOG.isDebugEnabled()) {
0103: LOG.debug("setAuthzGroupService(AuthzGroupService "
0104: + authzGroupService + ")");
0105: }
0106: this .authzGroupService = authzGroupService;
0107: }
0108:
0109: /**
0110: * @param sessionManager
0111: * The sessionManager to set.
0112: */
0113: public void setSessionManager(SessionManager sessionManager) {
0114: if (LOG.isDebugEnabled()) {
0115: LOG.debug("setSessionManager(SessionManager "
0116: + sessionManager + ")");
0117: }
0118: this .sessionManager = sessionManager;
0119: }
0120:
0121: /**
0122: * @param toolManager
0123: * The toolManager to set.
0124: */
0125: public void setToolManager(ToolManager toolManager) {
0126: if (LOG.isDebugEnabled()) {
0127: LOG
0128: .debug("setToolManager(ToolManager " + toolManager
0129: + ")");
0130: }
0131: this .toolManager = toolManager;
0132: }
0133:
0134: /**
0135: * @param permissionManager
0136: * The permissionManager to set.
0137: */
0138: public void setPermissionManager(PermissionManager permissionManager) {
0139: if (LOG.isDebugEnabled()) {
0140: LOG.debug("setPermissionManager(PermissionManager "
0141: + permissionManager + ")");
0142: }
0143: this .permissionManager = permissionManager;
0144: }
0145:
0146: /**
0147: * @param typeManager
0148: * The typeManager to set.
0149: */
0150: public void setTypeManager(MessageForumsTypeManager typeManager) {
0151: if (LOG.isDebugEnabled()) {
0152: LOG.debug("setTypeManager(MessageForumsTypeManager "
0153: + typeManager + ")");
0154: }
0155: this .typeManager = typeManager;
0156: }
0157:
0158: /**
0159: * @param securityService
0160: * The securityService to set.
0161: */
0162: public void setSecurityService(SecurityService securityService) {
0163: if (LOG.isDebugEnabled()) {
0164: LOG.debug("setSecurityService(SecurityService"
0165: + securityService + ")");
0166: }
0167: this .securityService = securityService;
0168: }
0169:
0170: // end dependencies
0171: /**
0172: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isNewForum()
0173: */
0174: public boolean isNewForum() {
0175: LOG.debug("isNewForum()");
0176: if (isSuperUser()) {
0177: return true;
0178: }
0179:
0180: try {
0181: Iterator iter = getAreaItemsByCurrentUser();
0182: while (iter.hasNext()) {
0183: DBMembershipItem item = (DBMembershipItem) iter.next();
0184: if (item.getPermissionLevel().getNewForum()
0185: .booleanValue()) {
0186: return true;
0187: }
0188: }
0189: } catch (Exception e) {
0190: LOG.error(e.getMessage(), e);
0191: return false;
0192: }
0193: return false;
0194: }
0195:
0196: /**
0197: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isChangeSettings(org.sakaiproject.api.app.messageforums.DiscussionForum)
0198: */
0199: public boolean isChangeSettings(DiscussionForum forum) {
0200:
0201: if (LOG.isDebugEnabled()) {
0202: LOG
0203: .debug("isChangeSettings(DiscussionForum " + forum
0204: + ")");
0205: }
0206: if (isSuperUser()) {
0207: return true;
0208: }
0209: if (securityService.unlock(SiteService.SECURE_UPDATE_SITE,
0210: getContextSiteId())) {
0211: return true;
0212: }
0213: if (isForumOwner(forum)) {
0214: return true;
0215: }
0216:
0217: try {
0218: Iterator iter = getForumItemsByCurrentUser(forum);
0219: while (iter.hasNext()) {
0220: DBMembershipItem item = (DBMembershipItem) iter.next();
0221: if (item.getPermissionLevel().getChangeSettings()
0222: .booleanValue()) {
0223: return true;
0224: }
0225: }
0226: } catch (Exception e) {
0227: LOG.error(e.getMessage(), e);
0228: return false;
0229: }
0230: return false;
0231: }
0232:
0233: /**
0234: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isNewTopic(org.sakaiproject.api.app.messageforums.DiscussionForum)
0235: */
0236: public boolean isNewTopic(DiscussionForum forum) {
0237: if (LOG.isDebugEnabled()) {
0238: LOG.debug("isNewTopic(DiscussionForum " + forum + ")");
0239: }
0240: if (isSuperUser()) {
0241: return true;
0242: }
0243: try {
0244: Iterator iter = getForumItemsByCurrentUser(forum);
0245: while (iter.hasNext()) {
0246: DBMembershipItem item = (DBMembershipItem) iter.next();
0247: if (item.getPermissionLevel().getNewTopic()
0248: .booleanValue()) {
0249: return true;
0250: }
0251: }
0252: } catch (Exception e) {
0253: LOG.error(e.getMessage(), e);
0254: return false;
0255: }
0256: return false;
0257: }
0258:
0259: /**
0260: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isNewResponse(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0261: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0262: */
0263: public boolean isNewResponse(DiscussionTopic topic,
0264: DiscussionForum forum) {
0265: if (LOG.isDebugEnabled()) {
0266: LOG.debug("isNewResponse(DiscussionTopic " + topic
0267: + "), DiscussionForum" + forum + "");
0268: }
0269:
0270: try {
0271: if (checkBaseConditions(topic, forum)) {
0272: return true;
0273: }
0274: Iterator iter = getTopicItemsByCurrentUser(topic);
0275: while (iter.hasNext()) {
0276: DBMembershipItem item = (DBMembershipItem) iter.next();
0277: if (item.getPermissionLevel().getNewResponse()
0278: .booleanValue()
0279: && forum.getDraft().equals(Boolean.FALSE)
0280: && forum.getLocked().equals(Boolean.FALSE)
0281: && topic.getDraft().equals(Boolean.FALSE)
0282: && topic.getLocked().equals(Boolean.FALSE)) {
0283: return true;
0284: }
0285: }
0286: } catch (Exception e) {
0287: LOG.error(e.getMessage(), e);
0288: return false;
0289: }
0290: return false;
0291: }
0292:
0293: /**
0294: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isNewResponseToResponse(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0295: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0296: */
0297: public boolean isNewResponseToResponse(DiscussionTopic topic,
0298: DiscussionForum forum) {
0299: if (LOG.isDebugEnabled()) {
0300: LOG.debug("isNewResponseToResponse(DiscussionTopic "
0301: + topic + " , DiscussionForum" + forum + ") ");
0302: }
0303:
0304: try {
0305: if (checkBaseConditions(topic, forum)) {
0306: return true;
0307: }
0308: Iterator iter = getTopicItemsByCurrentUser(topic);
0309: while (iter.hasNext()) {
0310: DBMembershipItem item = (DBMembershipItem) iter.next();
0311: if (item.getPermissionLevel()
0312: .getNewResponseToResponse().booleanValue()
0313: && forum.getDraft().equals(Boolean.FALSE)
0314: && forum.getLocked().equals(Boolean.FALSE)
0315: && topic.getDraft().equals(Boolean.FALSE)
0316: && topic.getLocked().equals(Boolean.FALSE)) {
0317: return true;
0318: }
0319: }
0320:
0321: } catch (Exception e) {
0322: LOG.error(e.getMessage(), e);
0323: return false;
0324: }
0325: return false;
0326: }
0327:
0328: /**
0329: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isMovePostings(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0330: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0331: */
0332: public boolean isMovePostings(DiscussionTopic topic,
0333: DiscussionForum forum) {
0334: if (LOG.isDebugEnabled()) {
0335: LOG.debug("isMovePostings(DiscussionTopic " + topic
0336: + "), DiscussionForum" + forum + "");
0337: }
0338:
0339: try {
0340: if (checkBaseConditions(topic, forum)) {
0341: return true;
0342: }
0343: Iterator iter = getTopicItemsByCurrentUser(topic);
0344: while (iter.hasNext()) {
0345: DBMembershipItem item = (DBMembershipItem) iter.next();
0346: if (item.getPermissionLevel().getMovePosting()
0347: .booleanValue()
0348: && forum.getDraft().equals(Boolean.FALSE)
0349: && forum.getLocked().equals(Boolean.FALSE)
0350: && topic.getDraft().equals(Boolean.FALSE)
0351: && topic.getLocked().equals(Boolean.FALSE)) {
0352: return true;
0353: }
0354: }
0355:
0356: } catch (Exception e) {
0357: LOG.error(e.getMessage(), e);
0358: return false;
0359: }
0360: return false;
0361: }
0362:
0363: /**
0364: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isChangeSettings(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0365: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0366: */
0367: public boolean isChangeSettings(DiscussionTopic topic,
0368: DiscussionForum forum) {
0369: if (LOG.isDebugEnabled()) {
0370: LOG.debug("isChangeSettings(DiscussionTopic " + topic
0371: + "), DiscussionForum" + forum + "");
0372: }
0373: if (isSuperUser()) {
0374: return true;
0375: }
0376: if (securityService.unlock(SiteService.SECURE_UPDATE_SITE,
0377: getContextSiteId())) {
0378: return true;
0379: }
0380: try {
0381: // Change Settings on Topic allowed even if the forum is locked
0382: // if (forum.getLocked() == null || forum.getLocked().equals(Boolean.TRUE))
0383: // {
0384: // LOG.debug("This Forum is Locked");
0385: // return false;
0386: // }
0387: if (isTopicOwner(topic)) {
0388: return true;
0389: }
0390:
0391: // if owner then allow change of settings on the topic or on forum.
0392: if (topic.getCreatedBy().equals(getCurrentUserId())) {
0393: return true;
0394: }
0395: Iterator iter = getTopicItemsByCurrentUser(topic);
0396: while (iter.hasNext()) {
0397: DBMembershipItem item = (DBMembershipItem) iter.next();
0398: if (item.getPermissionLevel().getChangeSettings()
0399: .booleanValue())
0400: // && forum.getDraft().equals(Boolean.FALSE) SAK-9230
0401: // && forum.getLocked().equals(Boolean.FALSE)
0402: // && topic.getDraft().equals(Boolean.FALSE)
0403: // && topic.getLocked().equals(Boolean.FALSE))
0404: {
0405: return true;
0406: }
0407: }
0408:
0409: } catch (Exception e) {
0410: LOG.error(e.getMessage(), e);
0411: return false;
0412: }
0413: return false;
0414: }
0415:
0416: /**
0417: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isPostToGradebook(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0418: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0419: */
0420: public boolean isPostToGradebook(DiscussionTopic topic,
0421: DiscussionForum forum) {
0422: if (LOG.isDebugEnabled()) {
0423: LOG.debug("isPostToGradebook(DiscussionTopic " + topic
0424: + ", DiscussionForum" + forum + ")");
0425: }
0426:
0427: try {
0428: if (checkBaseConditions(topic, forum)) {
0429: return true;
0430: }
0431: Iterator iter = getTopicItemsByCurrentUser(topic);
0432: while (iter.hasNext()) {
0433: DBMembershipItem item = (DBMembershipItem) iter.next();
0434: if (item.getPermissionLevel().getPostToGradebook()
0435: .booleanValue()
0436: && forum.getDraft().equals(Boolean.FALSE)
0437: && topic.getDraft().equals(Boolean.FALSE)) {
0438: return true;
0439: }
0440: }
0441:
0442: } catch (Exception e) {
0443: LOG.error(e.getMessage(), e);
0444: return false;
0445: }
0446: return false;
0447: }
0448:
0449: /**
0450: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isRead(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0451: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0452: */
0453: public boolean isRead(DiscussionTopic topic, DiscussionForum forum) {
0454: if (LOG.isDebugEnabled()) {
0455: LOG.debug("isRead(DiscussionTopic " + topic
0456: + ", DiscussionForum" + forum + ")");
0457: }
0458: try {
0459: if (checkBaseConditions(topic, forum)) {
0460: return true;
0461: }
0462: Iterator iter = getTopicItemsByCurrentUser(topic);
0463: while (iter.hasNext()) {
0464: DBMembershipItem item = (DBMembershipItem) iter.next();
0465: if (item.getPermissionLevel().getRead().booleanValue()
0466: && forum.getDraft().equals(Boolean.FALSE)
0467: // && forum.getLocked().equals(Boolean.FALSE)
0468: && topic.getDraft().equals(Boolean.FALSE))
0469: // && topic.getLocked().equals(Boolean.FALSE))
0470: {
0471: return true;
0472: }
0473: }
0474:
0475: } catch (Exception e) {
0476: LOG.error(e.getMessage(), e);
0477: return false;
0478: }
0479: return false;
0480: }
0481:
0482: /**
0483: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isReviseAny(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0484: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0485: */
0486: public boolean isReviseAny(DiscussionTopic topic,
0487: DiscussionForum forum) {
0488: if (LOG.isDebugEnabled()) {
0489: LOG.debug("isReviseAny(DiscussionTopic " + topic
0490: + ", DiscussionForum" + forum + ")");
0491: }
0492: try {
0493: if (checkBaseConditions(topic, forum)) {
0494: return true;
0495: }
0496: if (topic.getLocked() == null
0497: || topic.getLocked().equals(Boolean.TRUE)) {
0498: LOG.debug("This topic is locked " + topic);
0499: return false;
0500: }
0501: if (topic.getDraft() == null
0502: || topic.getDraft().equals(Boolean.TRUE)) {
0503: LOG.debug("This topic is at draft stage " + topic);
0504: }
0505: Iterator iter = getTopicItemsByCurrentUser(topic);
0506: while (iter.hasNext()) {
0507: DBMembershipItem item = (DBMembershipItem) iter.next();
0508: if (item.getPermissionLevel().getReviseAny()
0509: .booleanValue()
0510: && forum.getDraft().equals(Boolean.FALSE)
0511: && forum.getLocked().equals(Boolean.FALSE)
0512: && topic.getDraft().equals(Boolean.FALSE)
0513: && topic.getLocked().equals(Boolean.FALSE)) {
0514: return true;
0515: }
0516: }
0517:
0518: } catch (Exception e) {
0519: LOG.error(e.getMessage(), e);
0520: return false;
0521: }
0522: return false;
0523: }
0524:
0525: /**
0526: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isReviseOwn(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0527: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0528: */
0529: public boolean isReviseOwn(DiscussionTopic topic,
0530: DiscussionForum forum) {
0531: if (LOG.isDebugEnabled()) {
0532: LOG.debug("isReviseOwn(DiscussionTopic " + topic
0533: + ", DiscussionForum" + forum + ")");
0534: }
0535: if (checkBaseConditions(topic, forum)) {
0536: return true;
0537: }
0538: try {
0539: if (checkBaseConditions(topic, forum)) {
0540: return true;
0541: }
0542:
0543: if (topic.getLocked() == null
0544: || topic.getLocked().equals(Boolean.TRUE)) {
0545: LOG.debug("This topic is locked " + topic);
0546: return false;
0547: }
0548: if (topic.getDraft() == null
0549: || topic.getDraft().equals(Boolean.TRUE)) {
0550: LOG.debug("This topic is at draft stage " + topic);
0551: }
0552: Iterator iter = getTopicItemsByCurrentUser(topic);
0553: while (iter.hasNext()) {
0554: DBMembershipItem item = (DBMembershipItem) iter.next();
0555: if (item.getPermissionLevel().getReviseOwn()
0556: .booleanValue()
0557: && forum.getDraft().equals(Boolean.FALSE)
0558: && forum.getLocked().equals(Boolean.FALSE)
0559: && topic.getDraft().equals(Boolean.FALSE)
0560: && topic.getLocked().equals(Boolean.FALSE)) {
0561: return true;
0562: }
0563: }
0564:
0565: } catch (Exception e) {
0566: LOG.error(e.getMessage(), e);
0567: return false;
0568: }
0569: return false;
0570: }
0571:
0572: /**
0573: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isDeleteAny(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0574: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0575: */
0576: public boolean isDeleteAny(DiscussionTopic topic,
0577: DiscussionForum forum) {
0578: if (LOG.isDebugEnabled()) {
0579: LOG.debug("isDeleteAny(DiscussionTopic " + topic
0580: + ", DiscussionForum" + forum + ")");
0581: }
0582: if (checkBaseConditions(topic, forum)) {
0583: return true;
0584: }
0585: try {
0586: if (checkBaseConditions(topic, forum)) {
0587: return true;
0588: }
0589: if (topic.getLocked() == null
0590: || topic.getLocked().equals(Boolean.TRUE)) {
0591: LOG.debug("This topic is locked " + topic);
0592: return false;
0593: }
0594: if (topic.getDraft() == null
0595: || topic.getDraft().equals(Boolean.TRUE)) {
0596: LOG.debug("This topic is at draft stage " + topic);
0597: }
0598: Iterator iter = getTopicItemsByCurrentUser(topic);
0599: while (iter.hasNext()) {
0600: DBMembershipItem item = (DBMembershipItem) iter.next();
0601: if (item.getPermissionLevel().getDeleteAny()
0602: .booleanValue()
0603: && forum.getDraft().equals(Boolean.FALSE)
0604: && forum.getLocked().equals(Boolean.FALSE)
0605: && topic.getDraft().equals(Boolean.FALSE)
0606: && topic.getLocked().equals(Boolean.FALSE)) {
0607: return true;
0608: }
0609: }
0610:
0611: } catch (Exception e) {
0612: LOG.error(e.getMessage(), e);
0613: return false;
0614: }
0615: return false;
0616: }
0617:
0618: /**
0619: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isDeleteOwn(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0620: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0621: */
0622: public boolean isDeleteOwn(DiscussionTopic topic,
0623: DiscussionForum forum) {
0624: if (LOG.isDebugEnabled()) {
0625: LOG.debug("isDeleteOwn(DiscussionTopic " + topic
0626: + ", DiscussionForum" + forum + ")");
0627: }
0628: if (checkBaseConditions(topic, forum)) {
0629: return true;
0630: }
0631: try {
0632: if (checkBaseConditions(topic, forum)) {
0633: return true;
0634: }
0635: if (topic.getLocked() == null
0636: || topic.getLocked().equals(Boolean.TRUE)) {
0637: LOG.debug("This topic is locked " + topic);
0638: return false;
0639: }
0640: if (topic.getDraft() == null
0641: || topic.getDraft().equals(Boolean.TRUE)) {
0642: LOG.debug("This topic is at draft stage " + topic);
0643: }
0644: Iterator iter = getTopicItemsByCurrentUser(topic);
0645: while (iter.hasNext()) {
0646: DBMembershipItem item = (DBMembershipItem) iter.next();
0647: if (item.getPermissionLevel().getDeleteOwn()
0648: .booleanValue()
0649: && forum.getDraft().equals(Boolean.FALSE)
0650: && forum.getLocked().equals(Boolean.FALSE)
0651: && topic.getDraft().equals(Boolean.FALSE)
0652: && topic.getLocked().equals(Boolean.FALSE)) {
0653: return true;
0654: }
0655: }
0656:
0657: } catch (Exception e) {
0658: LOG.error(e.getMessage(), e);
0659: return false;
0660: }
0661: return false;
0662: }
0663:
0664: /**
0665: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isMarkAsRead(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0666: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0667: */
0668: public boolean isMarkAsRead(DiscussionTopic topic,
0669: DiscussionForum forum) {
0670: if (LOG.isDebugEnabled()) {
0671: LOG.debug("isMarkAsRead(DiscussionTopic " + topic
0672: + ", DiscussionForum" + forum + ")");
0673: }
0674: if (checkBaseConditions(topic, forum)) {
0675: return true;
0676: }
0677:
0678: if (topic.getLocked() == null
0679: || topic.getLocked().equals(Boolean.TRUE)) {
0680: LOG.debug("This topic is locked " + topic);
0681: return false;
0682: }
0683: if (topic.getDraft() == null
0684: || topic.getDraft().equals(Boolean.TRUE)) {
0685: LOG.debug("This topic is at draft stage " + topic);
0686: }
0687: try {
0688: if (checkBaseConditions(topic, forum)) {
0689: return true;
0690: }
0691: if (topic.getLocked() == null
0692: || topic.getLocked().equals(Boolean.TRUE)) {
0693: LOG.debug("This topic is locked " + topic);
0694: return false;
0695: }
0696: if (topic.getDraft() == null
0697: || topic.getDraft().equals(Boolean.TRUE)) {
0698: LOG.debug("This topic is at draft stage " + topic);
0699: }
0700: Iterator iter = getTopicItemsByCurrentUser(topic);
0701: while (iter.hasNext()) {
0702: DBMembershipItem item = (DBMembershipItem) iter.next();
0703: if (item.getPermissionLevel().getMarkAsRead()
0704: .booleanValue()
0705: && forum.getDraft().equals(Boolean.FALSE)
0706: && forum.getLocked().equals(Boolean.FALSE)
0707: && topic.getDraft().equals(Boolean.FALSE)
0708: && topic.getLocked().equals(Boolean.FALSE)) {
0709: return true;
0710: }
0711: }
0712:
0713: } catch (Exception e) {
0714: LOG.error(e.getMessage(), e);
0715: return false;
0716: }
0717: return false;
0718:
0719: }
0720:
0721: /**
0722: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#isModerate(org.sakaiproject.api.app.messageforums.DiscussionTopic,
0723: * org.sakaiproject.api.app.messageforums.DiscussionForum)
0724: */
0725: public boolean isModeratePostings(DiscussionTopic topic,
0726: DiscussionForum forum) {
0727: if (LOG.isDebugEnabled()) {
0728: LOG.debug("isModeratePostings(DiscussionTopic " + topic
0729: + ", DiscussionForum" + forum + ")");
0730: }
0731: if (checkBaseConditions(topic, forum)) {
0732: return true;
0733: }
0734: try {
0735: if (checkBaseConditions(topic, forum)) {
0736: return true;
0737: }
0738:
0739: if (topic.getLocked() == null
0740: || topic.getLocked().equals(Boolean.TRUE)) {
0741: LOG.debug("This topic is locked " + topic);
0742: return false;
0743: }
0744: if (topic.getDraft() == null
0745: || topic.getDraft().equals(Boolean.TRUE)) {
0746: LOG.debug("This topic is at draft stage " + topic);
0747: }
0748: Iterator iter = getTopicItemsByCurrentUser(topic);
0749: while (iter.hasNext()) {
0750: DBMembershipItem item = (DBMembershipItem) iter.next();
0751: if (item.getPermissionLevel().getModeratePostings()
0752: .booleanValue()
0753: && forum.getDraft().equals(Boolean.FALSE)
0754: && forum.getLocked().equals(Boolean.FALSE)
0755: && topic.getDraft().equals(Boolean.FALSE)
0756: && topic.getLocked().equals(Boolean.FALSE)) {
0757: return true;
0758: }
0759: }
0760:
0761: } catch (Exception e) {
0762: LOG.error(e.getMessage(), e);
0763: return false;
0764: }
0765: return false;
0766: }
0767:
0768: /*
0769: * (non-Javadoc)
0770: * @see org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager#getCurrentUserMemberships()
0771: */
0772: public List getCurrentUserMemberships() {
0773: List userMemberships = new ArrayList();
0774: // first, add the user's role
0775: final String currRole = getCurrentUserRole();
0776: userMemberships.add(currRole);
0777: // now, add any groups the user is a member of
0778: Iterator groupIter = getGroupNamesByCurrentUser();
0779: while (groupIter.hasNext()) {
0780: final String groupName = (String) groupIter.next();
0781: userMemberships.add(groupName);
0782: }
0783:
0784: return userMemberships;
0785: }
0786:
0787: private Iterator getGroupsByCurrentUser() {
0788: List memberof = new ArrayList();
0789: try {
0790: Collection groups = SiteService.getSite(
0791: toolManager.getCurrentPlacement().getContext())
0792: .getGroups();
0793: for (Iterator groupIterator = groups.iterator(); groupIterator
0794: .hasNext();) {
0795: Group currentGroup = (Group) groupIterator.next();
0796:
0797: Member member = currentGroup
0798: .getMember(getCurrentUserId());
0799: if (member != null
0800: && member.getUserId()
0801: .equals(getCurrentUserId())) {
0802: memberof.add(currentGroup.getId());
0803: }
0804: }
0805: } catch (IdUnusedException e) {
0806: LOG.debug("Group not found");
0807: }
0808: return memberof.iterator();
0809: }
0810:
0811: /**
0812: * Returns a list of names of the groups/sections
0813: * the current user is a member of
0814: * @return
0815: */
0816: private Iterator getGroupNamesByCurrentUser() {
0817: List memberof = new ArrayList();
0818: try {
0819: Collection groups = SiteService.getSite(
0820: toolManager.getCurrentPlacement().getContext())
0821: .getGroups();
0822: for (Iterator groupIterator = groups.iterator(); groupIterator
0823: .hasNext();) {
0824: Group currentGroup = (Group) groupIterator.next();
0825:
0826: Member member = currentGroup
0827: .getMember(getCurrentUserId());
0828: if (member != null
0829: && member.getUserId()
0830: .equals(getCurrentUserId())) {
0831: memberof.add(currentGroup.getTitle());
0832: }
0833: }
0834: } catch (IdUnusedException e) {
0835: LOG.debug("Group not found");
0836: }
0837: return memberof.iterator();
0838: }
0839:
0840: private DBMembershipItem getAreaItemByUserRole() {
0841: if (LOG.isDebugEnabled()) {
0842: LOG.debug("getAreaItemByUserRole()");
0843: }
0844: Set membershipItems = forumManager.getDiscussionForumArea()
0845: .getMembershipItemSet();
0846: return forumManager.getDBMember(membershipItems,
0847: getCurrentUserRole(), DBMembershipItem.TYPE_ROLE);
0848: }
0849:
0850: private Iterator getAreaItemsByCurrentUser() {
0851: if (LOG.isDebugEnabled()) {
0852: LOG.debug("getAreaItemsByCurrentUser()");
0853: }
0854:
0855: List areaItems = new ArrayList();
0856:
0857: if (ThreadLocalManager.get("message_center_permission_set") == null
0858: || !((Boolean) ThreadLocalManager
0859: .get("message_center_permission_set"))
0860: .booleanValue()) {
0861: initMembershipForSite();
0862: }
0863:
0864: // Set membershipItems = forumManager.getDiscussionForumArea()
0865: // .getMembershipItemSet();
0866: Set areaItemsInThread = (Set) ThreadLocalManager
0867: .get("message_center_membership_area");
0868: DBMembershipItem item = forumManager.getDBMember(
0869: areaItemsInThread, getCurrentUserRole(),
0870: DBMembershipItem.TYPE_ROLE);
0871:
0872: if (item != null) {
0873: areaItems.add(item);
0874: }
0875:
0876: // for group awareness
0877: try {
0878: Collection groups = (Collection) ThreadLocalManager
0879: .get("message_center_current_member_groups");
0880: if (groups != null) {
0881: for (Iterator groupIterator = groups.iterator(); groupIterator
0882: .hasNext();) {
0883: Group currentGroup = (Group) groupIterator.next();
0884: currentGroup.getTitle();
0885:
0886: if (currentGroup.getMember(getCurrentUserId()) != null) {
0887: DBMembershipItem groupItem = forumManager
0888: .getDBMember(areaItemsInThread,
0889: currentGroup.getTitle(),
0890: DBMembershipItem.TYPE_GROUP);
0891: if (groupItem != null) {
0892: areaItems.add(groupItem);
0893: }
0894: }
0895: }
0896: }
0897: } catch (Exception iue) {
0898: iue.printStackTrace();
0899: }
0900:
0901: return areaItems.iterator();
0902: }
0903:
0904: public Set getAreaItemsSet(Area area) {
0905: if (ThreadLocalManager.get("message_center_permission_set") == null
0906: || !((Boolean) ThreadLocalManager
0907: .get("message_center_permission_set"))
0908: .booleanValue()) {
0909: initMembershipForSite();
0910: }
0911: Set allAreaSet = (Set) ThreadLocalManager
0912: .get("message_center_membership_area");
0913: Set returnSet = new HashSet();
0914: if (allAreaSet != null) {
0915: Iterator iter = allAreaSet.iterator();
0916: while (iter.hasNext()) {
0917: DBMembershipItemImpl this Item = (DBMembershipItemImpl) iter
0918: .next();
0919: if (this Item.getArea() != null
0920: && area.getId() != null
0921: && area.getId().equals(
0922: this Item.getArea().getId())) {
0923: returnSet.add((DBMembershipItem) this Item);
0924: }
0925: }
0926: }
0927:
0928: return returnSet;
0929: }
0930:
0931: private Iterator getForumItemsByCurrentUser(DiscussionForum forum) {
0932: List forumItems = new ArrayList();
0933: //Set membershipItems = forum.getMembershipItemSet();
0934:
0935: if (ThreadLocalManager.get("message_center_permission_set") == null
0936: || !((Boolean) ThreadLocalManager
0937: .get("message_center_permission_set"))
0938: .booleanValue()) {
0939: initMembershipForSite();
0940: }
0941:
0942: Set forumItemsInThread = (Set) ThreadLocalManager
0943: .get("message_center_membership_forum");
0944: Set this ForumItemSet = new HashSet();
0945: Iterator iter = forumItemsInThread.iterator();
0946: while (iter.hasNext()) {
0947: DBMembershipItemImpl this Item = (DBMembershipItemImpl) iter
0948: .next();
0949: if (this Item.getForum() != null
0950: && forum.getId()
0951: .equals(this Item.getForum().getId())) {
0952: this ForumItemSet.add((DBMembershipItem) this Item);
0953: }
0954: }
0955:
0956: // DBMembershipItem item = forumManager.getDBMember(membershipItems, getCurrentUserRole(),
0957: // DBMembershipItem.TYPE_ROLE);
0958: DBMembershipItem item = forumManager.getDBMember(
0959: this ForumItemSet, getCurrentUserRole(),
0960: DBMembershipItem.TYPE_ROLE);
0961:
0962: if (item != null) {
0963: forumItems.add(item);
0964: }
0965:
0966: // for group awareness
0967: try {
0968: Collection groups = (Collection) ThreadLocalManager
0969: .get("message_center_current_member_groups");
0970: if (groups != null) {
0971: for (Iterator groupIterator = groups.iterator(); groupIterator
0972: .hasNext();) {
0973: Group currentGroup = (Group) groupIterator.next();
0974: currentGroup.getTitle();
0975:
0976: if (currentGroup.getMember(getCurrentUserId()) != null) {
0977: DBMembershipItem groupItem = forumManager
0978: .getDBMember(this ForumItemSet,
0979: currentGroup.getTitle(),
0980: DBMembershipItem.TYPE_GROUP);
0981: if (groupItem != null) {
0982: forumItems.add(groupItem);
0983: }
0984: }
0985: }
0986: }
0987: } catch (Exception iue) {
0988: iue.printStackTrace();
0989: }
0990:
0991: // Iterator iter = membershipItems.iterator();
0992: // while (iter.hasNext())
0993: // {
0994: // DBMembershipItem membershipItem = (DBMembershipItem) iter.next();
0995: // if (membershipItem.getType().equals(DBMembershipItem.TYPE_ROLE)
0996: // && membershipItem.getName().equals(getCurrentUserRole()))
0997: // {
0998: // forumItems.add(membershipItem);
0999: // }
1000: // if (membershipItem.getType().equals(DBMembershipItem.TYPE_GROUP)
1001: // && isGroupMember(membershipItem.getName()))
1002: // {
1003: // forumItems.add(membershipItem);
1004: // }
1005: // }
1006: return forumItems.iterator();
1007: }
1008:
1009: public Set getForumItemsSet(DiscussionForum forum) {
1010: if (ThreadLocalManager.get("message_center_permission_set") == null
1011: || !((Boolean) ThreadLocalManager
1012: .get("message_center_permission_set"))
1013: .booleanValue()) {
1014: initMembershipForSite();
1015: }
1016:
1017: Set allForumSet = (Set) ThreadLocalManager
1018: .get("message_center_membership_forum");
1019: Set returnSet = new HashSet();
1020: Iterator iter = allForumSet.iterator();
1021: while (iter.hasNext()) {
1022: DBMembershipItemImpl this Item = (DBMembershipItemImpl) iter
1023: .next();
1024: if (this Item.getForum() != null
1025: && forum.getId() != null
1026: && forum.getId()
1027: .equals(this Item.getForum().getId())) {
1028: returnSet.add((DBMembershipItem) this Item);
1029: }
1030: }
1031:
1032: return returnSet;
1033: }
1034:
1035: private Iterator getTopicItemsByCurrentUser(DiscussionTopic topic) {
1036: List topicItems = new ArrayList();
1037:
1038: if (ThreadLocalManager.get("message_center_permission_set") == null
1039: || !((Boolean) ThreadLocalManager
1040: .get("message_center_permission_set"))
1041: .booleanValue()) {
1042: initMembershipForSite();
1043: }
1044:
1045: Set topicItemsInThread = (Set) ThreadLocalManager
1046: .get("message_center_membership_topic");
1047: Set this TopicItemSet = new HashSet();
1048: Iterator iter = topicItemsInThread.iterator();
1049: while (iter.hasNext()) {
1050: DBMembershipItemImpl this Item = (DBMembershipItemImpl) iter
1051: .next();
1052: if (this Item.getTopic() != null
1053: && topic.getId()
1054: .equals(this Item.getTopic().getId())) {
1055: this TopicItemSet.add((DBMembershipItem) this Item);
1056: }
1057: }
1058:
1059: // Set membershipItems = topic.getMembershipItemSet();
1060: DBMembershipItem item = forumManager.getDBMember(
1061: this TopicItemSet, getCurrentUserRole(),
1062: DBMembershipItem.TYPE_ROLE);
1063:
1064: if (item != null) {
1065: topicItems.add(item);
1066: }
1067:
1068: //for group awareness
1069: try {
1070: Collection groups = (Collection) ThreadLocalManager
1071: .get("message_center_current_member_groups");
1072: if (groups != null) {
1073: for (Iterator groupIterator = groups.iterator(); groupIterator
1074: .hasNext();) {
1075: Group currentGroup = (Group) groupIterator.next();
1076: currentGroup.getTitle();
1077:
1078: if (currentGroup.getMember(getCurrentUserId()) != null) {
1079: DBMembershipItem groupItem = forumManager
1080: .getDBMember(this TopicItemSet,
1081: currentGroup.getTitle(),
1082: DBMembershipItem.TYPE_GROUP);
1083: if (groupItem != null) {
1084: topicItems.add(groupItem);
1085: }
1086: }
1087: }
1088: }
1089: } catch (Exception iue) {
1090: iue.printStackTrace();
1091: }
1092:
1093: // Iterator iter = membershipItems.iterator();
1094: // while (iter.hasNext())
1095: // {
1096: // DBMembershipItem membershipItem = (DBMembershipItem) iter.next();
1097: // if (membershipItem.getType().equals(DBMembershipItem.TYPE_ROLE)
1098: // && membershipItem.getName().equals(getCurrentUserRole()))
1099: // {
1100: // topicItems.add(membershipItem);
1101: // }
1102: // if (membershipItem.getType().equals(DBMembershipItem.TYPE_GROUP)
1103: // && isGroupMember(membershipItem.getName()))
1104: // {
1105: // topicItems.add(membershipItem);
1106: // }
1107: // }
1108: return topicItems.iterator();
1109: }
1110:
1111: public Set getTopicItemsSet(DiscussionTopic topic) {
1112: if (ThreadLocalManager.get("message_center_permission_set") == null
1113: || !((Boolean) ThreadLocalManager
1114: .get("message_center_permission_set"))
1115: .booleanValue()) {
1116: initMembershipForSite();
1117: }
1118:
1119: Set allTopicSet = (Set) ThreadLocalManager
1120: .get("message_center_membership_topic");
1121: Set returnSet = new HashSet();
1122: Iterator iter = allTopicSet.iterator();
1123: while (iter.hasNext()) {
1124: DBMembershipItemImpl this Item = (DBMembershipItemImpl) iter
1125: .next();
1126: if (this Item.getTopic() != null
1127: && topic.getId() != null
1128: && topic.getId()
1129: .equals(this Item.getTopic().getId())) {
1130: returnSet.add((DBMembershipItem) this Item);
1131: }
1132: }
1133:
1134: return returnSet;
1135: }
1136:
1137: /**
1138: * @see org.sakaiproject.api.app.messageforums.ui.DiscussionForumManager#isInstructor()
1139: */
1140: public boolean isInstructor() {
1141: LOG.debug("isInstructor()");
1142: return isInstructor(UserDirectoryService.getCurrentUser());
1143: }
1144:
1145: /**
1146: * Check if the given user has site.upd access
1147: *
1148: * @param user
1149: * @return
1150: */
1151: private boolean isInstructor(User user) {
1152: if (LOG.isDebugEnabled()) {
1153: LOG.debug("isInstructor(User " + user + ")");
1154: }
1155: if (user != null)
1156: return securityService.unlock(user, "site.upd",
1157: getContextSiteId());
1158: else
1159: return false;
1160: }
1161:
1162: /**
1163: * @return siteId
1164: */
1165: private String getContextSiteId() {
1166: LOG.debug("getContextSiteId()");
1167: return ("/site/" + toolManager.getCurrentPlacement()
1168: .getContext());
1169: }
1170:
1171: public void setPermissionLevelManager(
1172: PermissionLevelManager permissionLevelManager) {
1173: this .permissionLevelManager = permissionLevelManager;
1174: }
1175:
1176: /**
1177: * @return
1178: */
1179: private String getCurrentUserId() {
1180: LOG.debug("getCurrentUserId()");
1181: if (TestUtil.isRunningTests()) {
1182: return "test-user";
1183: }
1184:
1185: return sessionManager.getCurrentSessionUserId();
1186: }
1187:
1188: /**
1189: * @return
1190: */
1191: private String getCurrentUserRole() {
1192: LOG.debug("getCurrentUserRole()");
1193: return authzGroupService.getUserRole(getCurrentUserId(),
1194: "/site/" + getContextId());
1195: }
1196:
1197: /**
1198: * @return
1199: */
1200: private String getContextId() {
1201: LOG.debug("getContextId()");
1202: if (TestUtil.isRunningTests()) {
1203: return "test-context";
1204: }
1205: Placement placement = toolManager.getCurrentPlacement();
1206: String presentSiteId = placement.getContext();
1207: return presentSiteId;
1208: }
1209:
1210: /**
1211: * @param forum
1212: * @return
1213: */
1214: private boolean isForumOwner(DiscussionForum forum) {
1215: if (LOG.isDebugEnabled()) {
1216: LOG.debug("isForumOwner(DiscussionForum " + forum + ")");
1217: }
1218: if (forum.getCreatedBy().equals(getCurrentUserId())) {
1219: return true;
1220: }
1221: return false;
1222: }
1223:
1224: /**
1225: * @param topic
1226: * @return
1227: */
1228: private boolean isTopicOwner(DiscussionTopic topic) {
1229: if (LOG.isDebugEnabled()) {
1230: LOG.debug("isTopicOwner(DiscussionTopic " + topic + ")");
1231: }
1232: if (topic.getCreatedBy().equals(getCurrentUserId())) {
1233: return true;
1234: }
1235: return false;
1236: }
1237:
1238: /**
1239: * @return
1240: */
1241: private boolean isSuperUser() {
1242: LOG.debug(" isSuperUser()");
1243: return securityService.isSuperUser();
1244: }
1245:
1246: /**
1247: * @param topic
1248: * @param forum
1249: * @return
1250: */
1251: private boolean checkBaseConditions(DiscussionTopic topic,
1252: DiscussionForum forum) {
1253: if (LOG.isDebugEnabled()) {
1254: LOG.debug("checkBaseConditions(DiscussionTopic " + topic
1255: + ", DiscussionForum " + forum + ")");
1256: }
1257: if (isSuperUser()) {
1258: return true;
1259: }
1260: return false;
1261: }
1262:
1263: private boolean isRoleMember(String roleId) {
1264: if (LOG.isDebugEnabled()) {
1265: LOG.debug("isRoleMember(String " + roleId + ")");
1266: }
1267: if (getCurrentUserRole().equals(roleId)) {
1268: return true;
1269: }
1270: return false;
1271: }
1272:
1273: private boolean isGroupMember(String groupId) {
1274: if (LOG.isDebugEnabled()) {
1275: LOG.debug("setAuthzGroupService(AuthzGroupService "
1276: + authzGroupService + ")");
1277: }
1278: try {
1279: Collection groups = SiteService.getSite(
1280: toolManager.getCurrentPlacement().getContext())
1281: .getGroups();
1282: for (Iterator groupIterator = groups.iterator(); groupIterator
1283: .hasNext();) {
1284: Group currentGroup = (Group) groupIterator.next();
1285: if (currentGroup.getId().equals(groupId)) {
1286: Member member = currentGroup
1287: .getMember(getCurrentUserId());
1288: if (member != null
1289: && member.getUserId().equals(
1290: getCurrentUserId())) {
1291: return true;
1292:
1293: }
1294: }
1295: }
1296: } catch (IdUnusedException e) {
1297: LOG.debug("Group with id " + groupId + " not found");
1298: return false;
1299: }
1300:
1301: return false;
1302: }
1303:
1304: private void initMembershipForSite() {
1305: if (ThreadLocalManager.get("message_center_permission_set") != null
1306: && ((Boolean) ThreadLocalManager
1307: .get("message_center_permission_set"))
1308: .booleanValue()) {
1309: return;
1310: }
1311: Area dfa = forumManager.getDiscussionForumArea();
1312: Set areaItems = dfa.getMembershipItemSet();
1313: List forumItemsList = permissionLevelManager
1314: .getAllMembershipItemsForForumsForSite(dfa.getId());
1315: List topicItemsList = permissionLevelManager
1316: .getAllMembershipItemsForTopicsForSite(dfa.getId());
1317:
1318: Set forumItems = new HashSet();
1319: for (int i = 0; i < forumItemsList.size(); i++) {
1320: if (forumItemsList.get(i) != null)
1321: forumItems.add(((Object[]) forumItemsList.get(i))[0]);
1322: }
1323: Set topicItems = new HashSet();
1324: for (int i = 0; i < topicItemsList.size(); i++) {
1325: if (topicItemsList.get(i) != null)
1326: topicItems.add(((Object[]) topicItemsList.get(i))[0]);
1327: }
1328:
1329: Collection groups = null;
1330: try {
1331: Site currentSite = SiteService.getSite(toolManager
1332: .getCurrentPlacement().getContext());
1333: groups = currentSite
1334: .getGroupsWithMember(getCurrentUserId());
1335: } catch (IdUnusedException iue) {
1336: iue.printStackTrace();
1337: }
1338:
1339: ThreadLocalManager.set("message_center_current_member_groups",
1340: groups);
1341: ThreadLocalManager.set("message_center_membership_area",
1342: areaItems);
1343: ThreadLocalManager.set("message_center_membership_forum",
1344: forumItems);
1345: ThreadLocalManager.set("message_center_membership_topic",
1346: topicItems);
1347: ThreadLocalManager.set("message_center_permission_set",
1348: new Boolean(true));
1349: }
1350: }
|