Beispiel #1
0
        /// <summary>
        /// Gets the security set for the forum.
        /// </summary>
        /// <param name="forumId">The forum unique identifier.</param>
        /// <param name="portalId">The portal unique identifier.</param>
        /// <returns>Returns The Security Set for the Forum including all Roles which have Read Access</returns>
        private static string GetSecuritySet(int forumId, int portalId)
        {
            var forumAccessList = BoardContext.Current.GetRepository <ForumAccess>().GetReadAccessList(forumId);

            var dnnRoles = new RoleController().GetRoles(portalId).ToList();

            var securitySet = new StringBuilder();

            forumAccessList.Where(x => x.Item2.AccessFlags.ReadAccess).ForEach(
                forumAccess =>
            {
                RoleInfo role = null;

                if (dnnRoles.Any(r => r.RoleName == forumAccess.Item3.Name))
                {
                    role = dnnRoles.First(r => r.RoleName == forumAccess.Item3.Name);
                }

                if (role != null)
                {
                    securitySet.AppendFormat("R{0},", role.RoleID);
                }

                // Guest Access
                if (forumAccess.Item3.Name == "Guests")
                {
                    securitySet.Append("E,");
                }
            });

            return(securitySet.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Gets the security set for the forum.
        /// </summary>
        /// <param name="forumID">The forum unique identifier.</param>
        /// <param name="portalID">The portal unique identifier.</param>
        /// <returns>Returns The Security Set for the Forum including all Roles which have Read Access</returns>
        private static string GetSecuritySet(int forumID, int portalID)
        {
            var forumAccessList = Data.GetReadAccessListForForum(forumID);

            var dnnRoles = new RoleController().GetRoles(portalID).ToList();

            var securitySet = new StringBuilder();

            forumAccessList.ForEach(
                forumAccess =>
            {
                if (!forumAccess.Flags.ReadAccess)
                {
                    return;
                }

                RoleInfo role = null;

                if (dnnRoles.Any(r => r.RoleName == forumAccess.GroupName))
                {
                    role = dnnRoles.First(r => r.RoleName == forumAccess.GroupName);
                }

                if (role != null)
                {
                    securitySet.AppendFormat("R{0},", role.RoleID);
                }

                // Guest Access
                if (forumAccess.GroupName == "Guests")
                {
                    securitySet.Append("E,");
                }
            });

            return(securitySet.ToString());
        }