private void LoadGroup(int groupId)
        {
            var gc = new ForumGroupController();
            var gi = gc.Groups_Get(ModuleId, groupId);

            if (gi == null)
            {
                return;
            }

            var newGroup = gc.GetForumGroup(ModuleId, groupId);

            ctlSecurityGrid = LoadControl("~/DesktopModules/activeforums/controls/admin_securitygrid.ascx") as Controls.admin_securitygrid;
            if (ctlSecurityGrid != null)
            {
                ctlSecurityGrid.Perms               = newGroup.Security;
                ctlSecurityGrid.PermissionsId       = newGroup.PermissionsId;
                ctlSecurityGrid.ModuleConfiguration = ModuleConfiguration;

                plhGrid.Controls.Clear();
                plhGrid.Controls.Add(ctlSecurityGrid);
            }

            trGroups.Visible   = false;
            reqGroups.Enabled  = false;
            txtForumName.Text  = gi.GroupName;
            chkActive.Checked  = gi.Active;
            chkHidden.Checked  = gi.Hidden;
            hidForumId.Value   = gi.ForumGroupId.ToString();
            hidSortOrder.Value = gi.SortOrder.ToString();
            txtPrefixURL.Text  = gi.PrefixURL;

            Utilities.SelectListItemByValue(drpTopicsTemplate, gi.TopicsTemplateId);
            Utilities.SelectListItemByValue(drpTopicTemplate, gi.TopicTemplateId);
            Utilities.SelectListItemByValue(drpTopicForm, gi.TopicFormId);
            Utilities.SelectListItemByValue(drpReplyForm, gi.ReplyFormId);
            Utilities.SelectListItemByValue(drpProfileDisplay, gi.ProfileTemplateId);
            Utilities.SelectListItemByValue(drpModApprovedTemplateId, gi.ModApproveTemplateId);
            Utilities.SelectListItemByValue(drpModRejectTemplateId, gi.ModRejectTemplateId);
            Utilities.SelectListItemByValue(drpModDeleteTemplateId, gi.ModDeleteTemplateId);
            Utilities.SelectListItemByValue(drpModMoveTemplateId, gi.ModMoveTemplateId);
            Utilities.SelectListItemByValue(drpModNotifyTemplateId, gi.ModNotifyTemplateId);
            Utilities.SelectListItemByValue(drpDefaultTrust, gi.DefaultTrustValue);
            Utilities.SelectListItemByValue(drpEditorTypes, (int)gi.EditorType);
            Utilities.SelectListItemByValue(drpEditorMobile, (int)gi.EditorMobile);
            Utilities.SelectListItemByValue(drpPermittedRoles, gi.EditorPermittedUsers);

            txtAutoTrustLevel.Text  = gi.AutoTrustLevel.ToString();
            txtEmailAddress.Text    = gi.EmailAddress;
            txtCreatePostCount.Text = gi.CreatePostCount.ToString();
            txtReplyPostCount.Text  = gi.ReplyPostCount.ToString();

            rdFilterOn.Checked  = gi.UseFilter;
            rdFilterOff.Checked = !gi.UseFilter;

            rdPostIconOn.Checked  = gi.AllowPostIcon;
            rdPostIconOff.Checked = !gi.AllowPostIcon;

            rdEmotOn.Checked  = gi.AllowEmoticons;
            rdEmotOff.Checked = !gi.AllowEmoticons;

            rdScriptsOn.Checked  = gi.AllowScript;
            rdScriptsOff.Checked = !gi.AllowScript;

            rdIndexOn.Checked  = gi.IndexContent;
            rdIndexOff.Checked = !gi.IndexContent;

            rdRSSOn.Checked  = gi.AllowRSS;
            rdRSSOff.Checked = !gi.AllowRSS;

            rdAttachOn.Checked  = gi.AllowAttach;
            rdAttachOff.Checked = !gi.AllowAttach;

            if (gi.AllowAttach)
            {
                cfgAttach.Attributes.Remove("style");
            }
            else
            {
                cfgAttach.Attributes.Add("style", "display:none;");
            }

            txtMaxAttach.Text                 = gi.AttachCount.ToString();
            txtMaxAttachSize.Text             = gi.AttachMaxSize.ToString();
            txtAllowedTypes.Text              = gi.AttachTypeAllowed;
            ckAllowBrowseSite.Checked         = gi.AttachAllowBrowseSite;
            txtMaxAttachWidth.Text            = gi.MaxAttachWidth.ToString();
            txtMaxAttachHeight.Text           = gi.MaxAttachHeight.ToString();
            ckAttachInsertAllowed.Checked     = gi.AttachInsertAllowed;
            ckConvertingToJpegAllowed.Checked = gi.ConvertingToJpegAllowed;

            rdHTMLOn.Checked  = gi.AllowHTML;
            rdHTMLOff.Checked = !gi.AllowHTML;

            if (gi.AllowHTML)
            {
                cfgHTML.Attributes.Remove("style");
            }
            else
            {
                cfgHTML.Attributes.Add("style", "display:none;");
            }

            rdModOn.Checked  = gi.IsModerated;
            rdModOff.Checked = !gi.IsModerated;

            if (gi.IsModerated)
            {
                cfgMod.Attributes.Remove("style");
            }
            else
            {
                cfgMod.Attributes.Add("style", "display:none;");
            }

            rdAutoSubOn.Checked  = gi.AutoSubscribeEnabled;
            rdAutoSubOff.Checked = !gi.AutoSubscribeEnabled;

            rdLikesOn.Checked  = gi.AllowLikes;
            rdLikesOff.Checked = !gi.AllowLikes;

            if (gi.AutoSubscribeEnabled)
            {
                cfgAutoSub.Attributes.Remove("style");
            }
            else
            {
                cfgAutoSub.Attributes.Add("style", "display:none;");
            }

            var x = gi.EditorType;

            txtEditorHeight.Text  = (gi.EditorHeight == string.Empty) ? "400" : gi.EditorHeight;
            txtEditorWidth.Text   = (gi.EditorWidth == string.Empty) ? "99%" : gi.EditorWidth;
            chkTopicsOnly.Checked = gi.AutoSubscribeNewTopicsOnly;
            hidRoles.Value        = gi.AutoSubscribeRoles;
            BindAutoSubRoles(gi.AutoSubscribeRoles);
        }
示例#2
0
        public int CreateGroupForum(int portalId, int moduleId, int socialGroupId, int forumGroupId, string forumName, string forumDescription, bool isPrivate, string forumConfig)
        {
            var forumId = -1;

            try
            {
                var rc          = new RoleController();
                var forumsDb    = new Data.Common();
                var fgc         = new ForumGroupController();
                var gi          = fgc.Groups_Get(moduleId, forumGroupId);
                var socialGroup = rc.GetRole(socialGroupId, portalId);
                var groupAdmin  = socialGroupId.ToString() + ":0";
                var groupMember = socialGroupId.ToString();

                var ri            = rc.GetRoleByName(portalId, "Administrators");
                var permissionsId = forumsDb.CreatePermSet(ri.RoleID.ToString());

                moduleId = gi.ModuleId;

                var fi = new Forum
                {
                    ForumDesc     = forumDescription,
                    Active        = true,
                    ForumGroupId  = forumGroupId,
                    ForumID       = -1,
                    ForumName     = forumName,
                    Hidden        = isPrivate,
                    ModuleId      = gi.ModuleId,
                    ParentForumId = 0,
                    PortalId      = portalId,
                    PermissionsId = gi.PermissionsId,
                    SortOrder     = 0,
                    SocialGroupId = socialGroupId
                };

                forumId          = Forums_Save(portalId, fi, true, true);
                fi               = GetForum(portalId, moduleId, forumId);
                fi.PermissionsId = permissionsId;
                Forums_Save(portalId, fi, false, false);

                var xDoc = new XmlDocument();
                xDoc.LoadXml(forumConfig);

                var xRoot = xDoc.DocumentElement;
                if (xRoot != null)
                {
                    var    xSecList = xRoot.SelectSingleNode("//security[@type='groupadmin']");
                    string permSet;
                    string secKey;
                    if (xSecList != null)
                    {
                        foreach (XmlNode n in xSecList.ChildNodes)
                        {
                            secKey = n.Name;
                            if (n.Attributes == null || n.Attributes["value"].Value != "true")
                            {
                                continue;
                            }
                            permSet = forumsDb.GetPermSet(permissionsId, secKey);
                            permSet = Permissions.AddPermToSet(groupAdmin, 2, permSet);
                            forumsDb.SavePermSet(permissionsId, secKey, permSet);
                        }
                    }

                    xSecList = xRoot.SelectSingleNode("//security[@type='groupmember']");
                    if (xSecList != null)
                    {
                        foreach (XmlNode n in xSecList.ChildNodes)
                        {
                            secKey = n.Name;

                            if (n.Attributes == null || n.Attributes["value"].Value != "true")
                            {
                                continue;
                            }

                            permSet = forumsDb.GetPermSet(permissionsId, secKey);
                            permSet = Permissions.AddPermToSet(groupMember, 0, permSet);
                            forumsDb.SavePermSet(permissionsId, secKey, permSet);
                        }
                    }

                    if (socialGroup.IsPublic)
                    {
                        xSecList = xRoot.SelectSingleNode("//security[@type='registereduser']");
                        ri       = rc.GetRoleByName(portalId, "Registered Users");
                        if (xSecList != null)
                        {
                            foreach (XmlNode n in xSecList.ChildNodes)
                            {
                                secKey = n.Name;

                                if (n.Attributes == null || n.Attributes["value"].Value != "true")
                                {
                                    continue;
                                }

                                permSet = forumsDb.GetPermSet(permissionsId, secKey);
                                permSet = Permissions.AddPermToSet(ri.RoleID.ToString(), 0, permSet);
                                forumsDb.SavePermSet(permissionsId, secKey, permSet);
                            }
                        }

                        xSecList = xRoot.SelectSingleNode("//security[@type='anon']");
                        if (xSecList != null)
                        {
                            foreach (XmlNode n in xSecList.ChildNodes)
                            {
                                secKey = n.Name;

                                if (n.Attributes == null || n.Attributes["value"].Value != "true")
                                {
                                    continue;
                                }

                                permSet = forumsDb.GetPermSet(permissionsId, secKey);
                                permSet = Permissions.AddPermToSet("-1", 0, permSet);
                                forumsDb.SavePermSet(permissionsId, secKey, permSet);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            DataCache.CacheClear(moduleId + "fv");

            return(forumId);
        }
        private void cbEditorAction_Callback(object sender, Controls.CallBackEventArgs e)
        {
            switch (e.Parameters[0].ToLowerInvariant())
            {
            case "forumsave":
            {
                var fi     = new Forum();
                var fc     = new ForumController();
                var bIsNew = false;
                int forumGroupId;
                var forumSettingsKey = string.Empty;

                if (Utilities.SafeConvertInt(e.Parameters[1]) <= 0)
                {
                    bIsNew     = true;
                    fi.ForumID = -1;
                }
                else
                {
                    fi = fc.Forums_Get(PortalId, ModuleId, Utilities.SafeConvertInt(e.Parameters[1]), UserId, false, false, -1);
                    forumSettingsKey = fi.ForumSettingsKey;
                }

                fi.ModuleId = ModuleId;
                fi.PortalId = PortalId;
                var sParentValue  = e.Parameters[2];
                var parentForumId = 0;

                if (sParentValue.Contains("GROUP"))
                {
                    sParentValue = sParentValue.Replace("GROUP", string.Empty);
                    forumGroupId = Utilities.SafeConvertInt(sParentValue);
                }
                else
                {
                    parentForumId = Utilities.SafeConvertInt(sParentValue.Replace("FORUM", string.Empty));
                    forumGroupId  = fc.Forums_GetGroupId(parentForumId);
                }

                fi.ForumGroupId  = forumGroupId;
                fi.ParentForumId = parentForumId;
                fi.ForumName     = e.Parameters[3];
                fi.ForumDesc     = e.Parameters[4];
                fi.Active        = Utilities.SafeConvertBool(e.Parameters[5]);
                fi.Hidden        = Utilities.SafeConvertBool(e.Parameters[6]);

                fi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]);

                var fkey = string.IsNullOrEmpty(fi.ForumSettingsKey) ? string.Empty : fi.ForumSettingsKey;

                if (Utilities.SafeConvertBool(e.Parameters[8]))
                {
                    var fgc = new ForumGroupController();
                    var fgi = fgc.GetForumGroup(ModuleId, forumGroupId);

                    if (bIsNew)
                    {
                        fi.PermissionsId = fgi.PermissionsId;
                    }
                    else if (fi.ForumSettingsKey != "G:" + forumGroupId)
                    {
                        fi.PermissionsId = fgi.PermissionsId;
                    }

                    fi.ForumSettingsKey = "G:" + forumGroupId;
                }
                else if (bIsNew || fkey.Contains("G:"))
                {
                    fi.ForumSettingsKey = string.Empty;
                    if (fi.InheritSecurity)
                    {
                        fi.PermissionsId = -1;
                    }
                }
                else
                {
                    fi.ForumSettingsKey = "F:" + fi.ForumID;
                }

                if (forumSettingsKey != fkey && fkey.Contains("F:"))
                {
                    bIsNew = true;
                }

                fi.PrefixURL = e.Parameters[9];
                if (!(string.IsNullOrEmpty(fi.PrefixURL)))
                {
                    var db = new Data.Common();
                    if (!(db.CheckForumURL(PortalId, ModuleId, fi.PrefixURL, fi.ForumID, fi.ForumGroupId)))
                    {
                        fi.PrefixURL = string.Empty;
                    }
                }

                var forumId = fc.Forums_Save(PortalId, fi, bIsNew, Utilities.SafeConvertBool(e.Parameters[8]));
                recordId = forumId;
                var securityKey = string.Empty;

                DataCache.ClearForumGroupsCache(ModuleId);

                var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId);
                DataCache.CacheClear(cachekey);

                cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);

                hidEditorResult.Value = forumId.ToString();
                break;
            }

            case "groupsave":
            {
                var bIsNew  = false;
                var groupId = Utilities.SafeConvertInt(e.Parameters[1]);
                var fgc     = new ForumGroupController();
                var gi      = (groupId > 0) ? fgc.Groups_Get(ModuleId, groupId) : new ForumGroupInfo();

                var securityKey = string.Empty;
                if (groupId == 0)
                {
                    bIsNew = true;
                }
                else
                {
                    securityKey = "G:" + groupId;
                }

                gi.ModuleId     = ModuleId;
                gi.ForumGroupId = groupId;
                gi.GroupName    = e.Parameters[3];
                gi.Active       = Utilities.SafeConvertBool(e.Parameters[5]);
                gi.Hidden       = Utilities.SafeConvertBool(e.Parameters[6]);

                gi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]);

                gi.PrefixURL = e.Parameters[9];
                if (!(string.IsNullOrEmpty(gi.PrefixURL)))
                {
                    var db = new Data.Common();
                    if (!(db.CheckGroupURL(PortalId, ModuleId, gi.PrefixURL, gi.ForumGroupId)))
                    {
                        gi.PrefixURL = string.Empty;
                    }
                }

                gi.GroupSettingsKey = securityKey;
                var gc = new ForumGroupController();
                groupId  = gc.Groups_Save(PortalId, gi, bIsNew);
                recordId = groupId;

                DataCache.ClearForumGroupsCache(ModuleId);
                var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
                hidEditorResult.Value = groupId.ToString();

                break;
            }

            case "forumsettingssave":
            {
                var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                var sKey    = "F:" + forumId;
                SaveSettings(sKey, e.Parameters);

                hidEditorResult.Value = forumId.ToString();
                DataCache.CacheClear(forumId.ToString() + "ForumSettings");
                DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId));
                DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId) + "st");
                var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId);
                DataCache.CacheClear(cachekey);
                break;
            }

            case "groupsettingssave":
            {
                var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                var sKey    = "G:" + forumId;
                SaveSettings(sKey, e.Parameters);

                hidEditorResult.Value = forumId.ToString();
                DataCache.CacheClear(forumId.ToString() + "GroupSettings");
                DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId));
                DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId) + "st");

                break;
            }

            case "deleteforum":
            {
                var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                DataProvider.Instance().Forums_Delete(PortalId, ModuleId, forumId);
                var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
                break;
            }

            case "deletegroup":
            {
                var groupId = Utilities.SafeConvertInt(e.Parameters[1]);
                DataProvider.Instance().Groups_Delete(ModuleId, groupId);
                var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
                break;
            }
            }

            DataCache.CacheClear(string.Format(CacheKeys.ForumList, ModuleId));
            DataCache.ClearAllForumSettingsCache(ModuleId);
            DataCache.CacheClear(ModuleId + "fv");

            hidEditorResult.RenderControl(e.Output);
        }
示例#4
0
        private void LoadDefaultForums(int PortalId, int ModuleId)
        {
            var xDoc = new System.Xml.XmlDocument();
            xDoc.Load(sPath);
            if (xDoc != null)
            {

                System.Xml.XmlNode xRoot = xDoc.DocumentElement;
                System.Xml.XmlNodeList xNodeList = xRoot.SelectNodes("//defaultforums/groups/group");
                if (xNodeList.Count > 0)
                {
                    int i;
                    for (i = 0; i < xNodeList.Count; i++)
                    {
                        var gi = new ForumGroupInfo
                                     {
                                         ModuleId = ModuleId,
                                         ForumGroupId = -1,
                                         GroupName = xNodeList[i].Attributes["groupname"].Value,
                                         Active = xNodeList[i].Attributes["active"].Value == "1",
                                         Hidden = xNodeList[i].Attributes["hidden"].Value == "1",
                                         SortOrder = i,
                                         GroupSettingsKey = "",
                                         PermissionsId = -1
                                     };
                        var gc = new ForumGroupController();
                        int groupId;
                        groupId = gc.Groups_Save(PortalId, gi, true);
                        gi = gc.GetForumGroup(ModuleId, groupId);
                        string sKey = "G:" + groupId.ToString();
                        string sAllowHTML = "false";
                        if (xNodeList[i].Attributes["allowhtml"] != null)
                        {
                            sAllowHTML = xNodeList[i].Attributes["allowhtml"].Value;
                        }
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.TopicsTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.TopicTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EmailAddress, string.Empty);
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.UseFilter, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowPostIcon, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowEmoticons, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowScript, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.IndexContent, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowRSS, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowAttach, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachCount, "3");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachMaxSize, "1000");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachTypeAllowed, ".jpg,.png,.gif,.zip");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachStore, "FILESYSTEM");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachMaxHeight, "450");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachMaxWidth, "450");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachUniqueFileNames, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowHTML, sAllowHTML);
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorType, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorHeight, "350");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorWidth, "99%");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorToolbar, "bold,italic,underline,quote");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorStyle, "2");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.TopicFormId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ReplyFormId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.QuickReplyFormId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ProfileTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.IsModerated, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.DefaultTrustValue, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AutoTrustLevel, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModApproveTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModRejectTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModMoveTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModDeleteTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModNotifyTemplateId, "0");
                        if (groupId != -1)
                        {
                            if (xNodeList[i].HasChildNodes)
                            {
                                System.Xml.XmlNodeList cNodes = xNodeList[i].ChildNodes;
                                for (int c = 0; c < cNodes.Count; c++)
                                {
                                    var fi = new Forum();
                                    var fc = new ForumController();
                                    fi.ForumID = -1;
                                    fi.ModuleId = ModuleId;
                                    fi.ForumGroupId = groupId;
                                    fi.ParentForumId = 0;
                                    fi.ForumName = cNodes[c].Attributes["forumname"].Value;
                                    fi.ForumDesc = cNodes[c].Attributes["forumdesc"].Value;
                                    fi.ForumSecurityKey = "G:" + groupId.ToString();
                                    fi.ForumSettingsKey = "G:" + groupId.ToString();
                                    fi.Active = cNodes[c].Attributes["active"].Value == "1";
                                    fi.Hidden = cNodes[c].Attributes["hidden"].Value == "1";
                                    fi.SortOrder = c;
                                    fi.PermissionsId = gi.PermissionsId;
                                    fc.Forums_Save(PortalId, fi, true, true);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        public int Forums_Save(int portalId, Forum fi, bool isNew, bool useGroup)
        {
            var rc            = new RoleController();
            var db            = new Data.Common();
            var permissionsId = -1;

            if (useGroup && (string.IsNullOrEmpty(fi.ForumSettingsKey) || fi.PermissionsId == -1))
            {
                var fc = new ForumGroupController();
                var fg = fc.Groups_Get(fi.ModuleId, fi.ForumGroupId);
                if (fg != null)
                {
                    fi.ForumSettingsKey = fg.GroupSettingsKey;
                    //fi.ModuleId = fg.ModuleId
                    fi.PermissionsId = fg.PermissionsId;
                }
            }
            else if (fi.PermissionsId <= 0 && useGroup == false)
            {
                var ri = rc.GetRoleByName(portalId, "Administrators");
                if (ri != null)
                {
                    fi.PermissionsId = db.CreatePermSet(ri.RoleID.ToString());
                    permissionsId    = fi.PermissionsId;
                    isNew            = true;
                }
                if (fi.ForumID > 0 & !(string.IsNullOrEmpty(fi.ForumSettingsKey)))
                {
                    if (fi.ForumSettingsKey.Contains("G:"))
                    {
                        fi.ForumSettingsKey = string.Empty;
                    }
                }
                if (fi.ForumSettingsKey == "" && fi.ForumID > 0)
                {
                    fi.ForumSettingsKey = "F:" + fi.ForumID;
                }
            }
            else if (useGroup == false && string.IsNullOrEmpty(fi.ForumSettingsKey) && fi.ForumID > 0)
            {
                fi.ForumSettingsKey = "F:" + fi.ForumID;
            }

            var forumId = Convert.ToInt32(DataProvider.Instance().Forum_Save(portalId, fi.ForumID, fi.ModuleId, fi.ForumGroupId, fi.ParentForumId, fi.ForumName, fi.ForumDesc, fi.SortOrder, fi.Active, fi.Hidden, fi.ForumSettingsKey, fi.PermissionsId, fi.PrefixURL, fi.SocialGroupId, fi.HasProperties));

            if (String.IsNullOrEmpty(fi.ForumSettingsKey))
            {
                fi.ForumSettingsKey = "F:" + forumId;
            }

            if (fi.ForumSettingsKey.Contains("G:"))
            {
                DataProvider.Instance().Forum_ConfigCleanUp(fi.ModuleId, "F:" + fi.ForumID, "F:" + fi.ForumID);
            }

            if (isNew && useGroup == false)
            {
                var moduleId = fi.ModuleId;
                Permissions.CreateDefaultSets(portalId, permissionsId);

                var sKey = "F:" + forumId.ToString();
                Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicsTemplateId, "0");
                Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicTemplateId, "0");
                Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicFormId, "0");
                Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.ReplyFormId, "0");
                Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.AllowRSS, "false");
            }

            // Clear the caches
            DataCache.CacheClear(string.Format(CacheKeys.ForumList, fi.ModuleId));

            var cachekey = string.Format(forumInfoCacheKey, portalId, fi.ModuleId, forumId);

            DataCache.CacheClear(cachekey);

            return(forumId);
        }
        private void LoadGroup(int groupId)
        {
            var gc = new ForumGroupController();
            var gi = gc.Groups_Get(ModuleId, groupId);

            if (gi == null)
                return;

            var newGroup = gc.GetForumGroup(ModuleId, groupId);

            ctlSecurityGrid = LoadControl("~/DesktopModules/activeforums/controls/admin_securitygrid.ascx") as Controls.admin_securitygrid;
            if(ctlSecurityGrid != null)
            {
                ctlSecurityGrid.Perms = newGroup.Security;
                ctlSecurityGrid.PermissionsId = newGroup.PermissionsId;
                ctlSecurityGrid.ModuleConfiguration = ModuleConfiguration;

                plhGrid.Controls.Clear();
                plhGrid.Controls.Add(ctlSecurityGrid);
            }

            trGroups.Visible = false;
            reqGroups.Enabled = false;
            txtForumName.Text = gi.GroupName;
            chkActive.Checked = gi.Active;
            chkHidden.Checked = gi.Hidden;
            hidForumId.Value = gi.ForumGroupId.ToString();
            hidSortOrder.Value = gi.SortOrder.ToString();
            txtPrefixURL.Text = gi.PrefixURL;

            Utilities.SelectListItemByValue(drpTopicsTemplate, gi.TopicsTemplateId);
            Utilities.SelectListItemByValue(drpTopicTemplate, gi.TopicTemplateId);
            Utilities.SelectListItemByValue(drpTopicForm, gi.TopicFormId);
            Utilities.SelectListItemByValue(drpReplyForm, gi.ReplyFormId);
            Utilities.SelectListItemByValue(drpProfileDisplay, gi.ProfileTemplateId);
            Utilities.SelectListItemByValue(drpModApprovedTemplateId, gi.ModApproveTemplateId);
            Utilities.SelectListItemByValue(drpModRejectTemplateId, gi.ModRejectTemplateId);
            Utilities.SelectListItemByValue(drpModDeleteTemplateId, gi.ModDeleteTemplateId);
            Utilities.SelectListItemByValue(drpModMoveTemplateId, gi.ModMoveTemplateId);
            Utilities.SelectListItemByValue(drpModNotifyTemplateId, gi.ModNotifyTemplateId);
            Utilities.SelectListItemByValue(drpDefaultTrust, gi.DefaultTrustValue);

            txtAutoTrustLevel.Text = gi.AutoTrustLevel.ToString();
            txtEmailAddress.Text = gi.EmailAddress;
            txtCreatePostCount.Text = gi.CreatePostCount.ToString();
            txtReplyPostCount.Text = gi.ReplyPostCount.ToString();

            rdFilterOn.Checked = gi.UseFilter;
            rdFilterOff.Checked = !gi.UseFilter;

            rdPostIconOn.Checked = gi.AllowPostIcon;
            rdPostIconOff.Checked = !gi.AllowPostIcon;

            rdEmotOn.Checked = gi.AllowEmoticons;
            rdEmotOff.Checked = !gi.AllowEmoticons;

            rdScriptsOn.Checked = gi.AllowScript;
            rdScriptsOff.Checked = !gi.AllowScript;

            rdIndexOn.Checked = gi.IndexContent;
            rdIndexOff.Checked = !gi.IndexContent;

            rdRSSOn.Checked = gi.AllowRSS;
            rdRSSOff.Checked = !gi.AllowRSS;

            rdAttachOn.Checked = gi.AllowAttach;
            rdAttachOff.Checked = !gi.AllowAttach;

            rdHTMLOn.Checked = gi.AllowHTML;
            rdHTMLOff.Checked = !gi.AllowHTML;

            if (gi.AllowHTML)
                cfgHTML.Attributes.Remove("style");
            else
                cfgHTML.Attributes.Add("style", "display:none;");

            rdModOn.Checked = gi.IsModerated;
            rdModOff.Checked = !gi.IsModerated;

            if (gi.IsModerated)
                cfgMod.Attributes.Remove("style");
            else
                cfgMod.Attributes.Add("style", "display:none;");

            rdAutoSubOn.Checked = gi.AutoSubscribeEnabled;
            rdAutoSubOff.Checked = !gi.AutoSubscribeEnabled;

            if (gi.AutoSubscribeEnabled)
                cfgAutoSub.Attributes.Remove("style");
            else
                cfgAutoSub.Attributes.Add("style", "display:none;");

            Utilities.SelectListItemByValue(drpEditorTypes, gi.EditorType);
            Utilities.SelectListItemByValue(drpEditorStyle, gi.EditorStyle);
            Utilities.SelectListItemByValue(drpPermittedRoles, gi.EditorPermittedUsers);

            txtEditorHeight.Text = (gi.EditorHeight == string.Empty) ? "400" : gi.EditorHeight;
            txtEditorWidth.Text = (gi.EditorWidth == string.Empty) ? "99%" : gi.EditorWidth;
            txtEditorToolBar.Text = (gi.EditorToolBar == string.Empty) ? "bold,italic,underline|bulletedlist,numberedlist" : gi.EditorToolBar;
            chkTopicsOnly.Checked = gi.AutoSubscribeNewTopicsOnly;
            hidRoles.Value = gi.AutoSubscribeRoles;
            BindAutoSubRoles(gi.AutoSubscribeRoles);
        }
        private void cbEditorAction_Callback(object sender, Controls.CallBackEventArgs e)
        {
            switch (e.Parameters[0].ToLowerInvariant())
            {
                case "forumsave":
                {
                    var fi = new Forum();
                    var fc = new ForumController();
                    var bIsNew = false;
                    int forumGroupId;
                    var forumSettingsKey = string.Empty;

                    if (Utilities.SafeConvertInt(e.Parameters[1]) <= 0)
                    {
                        bIsNew = true;
                        fi.ForumID = -1;
                    }
                    else
                    {
                        fi = fc.Forums_Get(PortalId, ModuleId, Utilities.SafeConvertInt(e.Parameters[1]), UserId, false, false, -1);
                        forumSettingsKey = fi.ForumSettingsKey;
                    }

                    fi.ModuleId = ModuleId;
                    fi.PortalId = PortalId;
                    var sParentValue = e.Parameters[2];
                    var parentForumId = 0;

                    if (sParentValue.Contains("GROUP"))
                    {
                        sParentValue = sParentValue.Replace("GROUP", string.Empty);
                        forumGroupId = Utilities.SafeConvertInt(sParentValue);
                    }
                    else
                    {
                        parentForumId = Utilities.SafeConvertInt(sParentValue.Replace("FORUM", string.Empty));
                        forumGroupId = fc.Forums_GetGroupId(parentForumId);
                    }

                    fi.ForumGroupId = forumGroupId;
                    fi.ParentForumId = parentForumId;
                    fi.ForumName = e.Parameters[3];
                    fi.ForumDesc = e.Parameters[4];
                    fi.Active = Utilities.SafeConvertBool(e.Parameters[5]);
                    fi.Hidden = Utilities.SafeConvertBool(e.Parameters[6]);

                    fi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]);

                    var fkey = string.IsNullOrEmpty(fi.ForumSettingsKey) ? string.Empty : fi.ForumSettingsKey;

                    if (Utilities.SafeConvertBool(e.Parameters[8]))
                    {
                        var fgc = new ForumGroupController();
                        var fgi = fgc.GetForumGroup(ModuleId, forumGroupId);

                        if (bIsNew)
                            fi.PermissionsId = fgi.PermissionsId;
                        else if (fi.ForumSettingsKey != "G:" + forumGroupId)
                            fi.PermissionsId = fgi.PermissionsId;

                        fi.ForumSettingsKey = "G:" + forumGroupId;

                    }
                    else if (bIsNew || fkey.Contains("G:"))
                    {
                        fi.ForumSettingsKey = string.Empty;
                        if (fi.InheritSecurity)
                            fi.PermissionsId = -1;
                    }
                    else
                    {
                        fi.ForumSettingsKey = "F:" + fi.ForumID;
                    }

                    if (forumSettingsKey != fkey && fkey.Contains("F:"))
                        bIsNew = true;

                    fi.PrefixURL = e.Parameters[9];
                    if (!(string.IsNullOrEmpty(fi.PrefixURL)))
                    {
                        var db = new Data.Common();
                        if (!(db.CheckForumURL(PortalId, ModuleId, fi.PrefixURL, fi.ForumID, fi.ForumGroupId)))
                            fi.PrefixURL = string.Empty;
                    }

                    var forumId = fc.Forums_Save(PortalId, fi, bIsNew, Utilities.SafeConvertBool(e.Parameters[8]));
                    recordId = forumId;
                    var securityKey = string.Empty;

                    DataCache.ClearForumGroupsCache(ModuleId);

                    var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId);
                    DataCache.CacheClear(cachekey);

                    cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                    DataCache.CacheClearPrefix(cachekey);

                    hidEditorResult.Value = forumId.ToString();
                    break;
                }

                case "groupsave":
                {
                    var bIsNew = false;
                    var groupId = Utilities.SafeConvertInt(e.Parameters[1]);
                    var fgc = new ForumGroupController();
                    var gi = (groupId > 0) ? fgc.Groups_Get(ModuleId, groupId) : new ForumGroupInfo();

                    var securityKey = string.Empty;
                    if (groupId == 0)
                        bIsNew = true;
                    else
                        securityKey = "G:" + groupId;

                    gi.ModuleId = ModuleId;
                    gi.ForumGroupId = groupId;
                    gi.GroupName = e.Parameters[3];
                    gi.Active = Utilities.SafeConvertBool(e.Parameters[5]);
                    gi.Hidden = Utilities.SafeConvertBool(e.Parameters[6]);

                    gi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]);

                    gi.PrefixURL = e.Parameters[9];
                    if (!(string.IsNullOrEmpty(gi.PrefixURL)))
                    {
                        var db = new Data.Common();
                        if (!(db.CheckGroupURL(PortalId, ModuleId, gi.PrefixURL, gi.ForumGroupId)))
                            gi.PrefixURL = string.Empty;
                    }

                    gi.GroupSettingsKey = securityKey;
                    var gc = new ForumGroupController();
                    groupId = gc.Groups_Save(PortalId, gi, bIsNew);
                    recordId = groupId;

                    DataCache.ClearForumGroupsCache(ModuleId);
                    var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                    DataCache.CacheClearPrefix(cachekey);
                    hidEditorResult.Value = groupId.ToString();

                    break;
                }

                case "forumsettingssave":
                {
                    var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                    var sKey = "F:" + forumId;
                    SaveSettings(sKey, e.Parameters);

                    hidEditorResult.Value = forumId.ToString();
                    DataCache.CacheClear(forumId.ToString() + "ForumSettings");
                    DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId));
                    DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId) + "st");
                    var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId);
                    DataCache.CacheClear(cachekey);
                    break;
                }

                case "groupsettingssave":
                {
                    var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                    var sKey = "G:" + forumId;
                    SaveSettings(sKey, e.Parameters);

                    hidEditorResult.Value = forumId.ToString();
                    DataCache.CacheClear(forumId.ToString() + "GroupSettings");
                    DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId));
                    DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId) + "st");

                    break;
                }

                case "deleteforum":
                {
                    var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
                    DataProvider.Instance().Forums_Delete(PortalId, ModuleId, forumId);
                    var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                    DataCache.CacheClearPrefix(cachekey);
                    break;
                }

                case "deletegroup":
                {
                    var groupId = Utilities.SafeConvertInt(e.Parameters[1]);
                    DataProvider.Instance().Groups_Delete(ModuleId, groupId);
                    var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                    DataCache.CacheClearPrefix(cachekey);
                    break;
                }
            }

            DataCache.CacheClear(string.Format(CacheKeys.ForumList, ModuleId));
            DataCache.ClearAllForumSettingsCache(ModuleId);
            DataCache.CacheClear(ModuleId + "fv");

            hidEditorResult.RenderControl(e.Output);
        }
        private void LoadDefaultForums(int PortalId, int ModuleId)
        {
            var xDoc = new System.Xml.XmlDocument();

            xDoc.Load(sPath);
            if (xDoc != null)
            {
                System.Xml.XmlNode     xRoot     = xDoc.DocumentElement;
                System.Xml.XmlNodeList xNodeList = xRoot.SelectNodes("//defaultforums/groups/group");
                if (xNodeList.Count > 0)
                {
                    int i;
                    for (i = 0; i < xNodeList.Count; i++)
                    {
                        var gi = new ForumGroupInfo
                        {
                            ModuleId         = ModuleId,
                            ForumGroupId     = -1,
                            GroupName        = xNodeList[i].Attributes["groupname"].Value,
                            Active           = xNodeList[i].Attributes["active"].Value == "1",
                            Hidden           = xNodeList[i].Attributes["hidden"].Value == "1",
                            SortOrder        = i,
                            GroupSettingsKey = "",
                            PermissionsId    = -1
                        };
                        var gc = new ForumGroupController();
                        int groupId;
                        groupId = gc.Groups_Save(PortalId, gi, true);
                        gi      = gc.GetForumGroup(ModuleId, groupId);
                        string sKey       = "G:" + groupId.ToString();
                        string sAllowHTML = "false";
                        if (xNodeList[i].Attributes["allowhtml"] != null)
                        {
                            sAllowHTML = xNodeList[i].Attributes["allowhtml"].Value;
                        }
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.TopicsTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.TopicTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EmailAddress, string.Empty);
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.UseFilter, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowPostIcon, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowEmoticons, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowScript, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.IndexContent, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowRSS, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowAttach, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachCount, "3");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachMaxSize, "1000");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachTypeAllowed, "txt,tiff,pdf,xls,xlsx,doc,docx,ppt,pptx");
                        //Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachStore, "FILESYSTEM");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachMaxHeight, "450");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachMaxWidth, "450");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachAllowBrowseSite, "true");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.MaxAttachHeight, "800");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.MaxAttachWidth, "800");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AttachInsertAllowed, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ConvertingToJpegAllowed, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AllowHTML, sAllowHTML);
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorType, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorHeight, "350");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorWidth, "99%");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorToolbar, "bold,italic,underline,quote");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.EditorStyle, "2");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.TopicFormId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ReplyFormId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.QuickReplyFormId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ProfileTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.IsModerated, "false");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.DefaultTrustLevel, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.AutoTrustLevel, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModApproveTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModRejectTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModMoveTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModDeleteTemplateId, "0");
                        Settings.SaveSetting(ModuleId, sKey, ForumSettingKeys.ModNotifyTemplateId, "0");
                        if (groupId != -1)
                        {
                            if (xNodeList[i].HasChildNodes)
                            {
                                System.Xml.XmlNodeList cNodes = xNodeList[i].ChildNodes;
                                for (int c = 0; c < cNodes.Count; c++)
                                {
                                    var fi = new Forum();
                                    var fc = new ForumController();
                                    fi.ForumID          = -1;
                                    fi.ModuleId         = ModuleId;
                                    fi.ForumGroupId     = groupId;
                                    fi.ParentForumId    = 0;
                                    fi.ForumName        = cNodes[c].Attributes["forumname"].Value;
                                    fi.ForumDesc        = cNodes[c].Attributes["forumdesc"].Value;
                                    fi.ForumSecurityKey = "G:" + groupId.ToString();
                                    fi.ForumSettingsKey = "G:" + groupId.ToString();
                                    fi.Active           = cNodes[c].Attributes["active"].Value == "1";
                                    fi.Hidden           = cNodes[c].Attributes["hidden"].Value == "1";
                                    fi.SortOrder        = c;
                                    fi.PermissionsId    = gi.PermissionsId;
                                    fc.Forums_Save(PortalId, fi, true, true);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#9
0
		public int CreateGroupForum(int portalId, int moduleId, int socialGroupId, int forumGroupId, string forumName, string forumDescription, bool isPrivate, string forumConfig)
		{
			var forumId = -1;

			try
			{
				var rc = new RoleController();
				var forumsDb = new Data.Common();
			    var fgc = new ForumGroupController();
				var gi = fgc.Groups_Get(moduleId, forumGroupId);
				var socialGroup = rc.GetRole(socialGroupId, portalId);
				var groupAdmin = socialGroupId.ToString() + ":0";
				var groupMember = socialGroupId.ToString();

			    var ri = rc.GetRoleByName(portalId, "Administrators");
				var permissionsId = forumsDb.CreatePermSet(ri.RoleID.ToString());

				moduleId = gi.ModuleId;

				var fi = new Forum
				{
				    ForumDesc = forumDescription,
				    Active = true,
				    ForumGroupId = forumGroupId,
				    ForumID = -1,
				    ForumName = forumName,
				    Hidden = isPrivate,
				    ModuleId = gi.ModuleId,
				    ParentForumId = 0,
				    PortalId = portalId,
				    PermissionsId = gi.PermissionsId,
				    SortOrder = 0,
				    SocialGroupId = socialGroupId
				};

			    forumId = Forums_Save(portalId, fi, true, true);
				fi = GetForum(portalId, moduleId, forumId);
				fi.PermissionsId = permissionsId;
				Forums_Save(portalId, fi, false, false);

			    var xDoc = new XmlDocument();
				xDoc.LoadXml(forumConfig);

				var xRoot = xDoc.DocumentElement;
			    if (xRoot != null)
			    {
			        var xSecList = xRoot.SelectSingleNode("//security[@type='groupadmin']");
			        string permSet;
			        string secKey;
			        if (xSecList != null)
			        {
			            foreach (XmlNode n in xSecList.ChildNodes)
			            {
			                secKey = n.Name;
			                if (n.Attributes == null || n.Attributes["value"].Value != "true") 
			                    continue;
			                permSet = forumsDb.GetPermSet(permissionsId, secKey);
			                permSet = Permissions.AddPermToSet(groupAdmin, 2, permSet);
			                forumsDb.SavePermSet(permissionsId, secKey, permSet);
			            }
			        }

			        xSecList = xRoot.SelectSingleNode("//security[@type='groupmember']");
			        if (xSecList != null)
			        {
			            foreach (XmlNode n in xSecList.ChildNodes)
			            {
			                secKey = n.Name;
						    
			                if (n.Attributes == null || n.Attributes["value"].Value != "true") 
			                    continue;
						    
			                permSet = forumsDb.GetPermSet(permissionsId, secKey);
			                permSet = Permissions.AddPermToSet(groupMember, 0, permSet);
			                forumsDb.SavePermSet(permissionsId, secKey, permSet);
			            }
			        }

			        if (socialGroup.IsPublic)
			        {
			            xSecList = xRoot.SelectSingleNode("//security[@type='registereduser']");
			            ri = rc.GetRoleByName(portalId, "Registered Users");
			            if (xSecList != null)
			            {
			                foreach (XmlNode n in xSecList.ChildNodes)
			                {
			                    secKey = n.Name;
							    
			                    if (n.Attributes == null || n.Attributes["value"].Value != "true") 
			                        continue;
							    
			                    permSet = forumsDb.GetPermSet(permissionsId, secKey);
			                    permSet = Permissions.AddPermToSet(ri.RoleID.ToString(), 0, permSet);
			                    forumsDb.SavePermSet(permissionsId, secKey, permSet);
			                }
			            }

			            xSecList = xRoot.SelectSingleNode("//security[@type='anon']");
			            if (xSecList != null)
			            {
			                foreach (XmlNode n in xSecList.ChildNodes)
			                {
			                    secKey = n.Name;

			                    if (n.Attributes == null || n.Attributes["value"].Value != "true") 
			                        continue;

			                    permSet = forumsDb.GetPermSet(permissionsId, secKey);
			                    permSet = Permissions.AddPermToSet("-1", 0, permSet);
			                    forumsDb.SavePermSet(permissionsId, secKey, permSet);
			                }
			            }
			        }
			    }
			}
			catch (Exception ex)
			{

			}

			DataCache.CacheClear(moduleId + "fv");

			return forumId;
		}
示例#10
0
		public int Forums_Save(int portalId, Forum fi, bool isNew, bool useGroup)
		{
			var rc = new RoleController();
		    var db = new Data.Common();
			var permissionsId = -1;
			if (useGroup && (string.IsNullOrEmpty(fi.ForumSettingsKey) || fi.PermissionsId == -1))
			{
				var fc = new ForumGroupController();
				var fg = fc.Groups_Get(fi.ModuleId, fi.ForumGroupId);
				if (fg != null)
				{
					fi.ForumSettingsKey = fg.GroupSettingsKey;
					//fi.ModuleId = fg.ModuleId
					fi.PermissionsId = fg.PermissionsId;
				}
			}
			else if (fi.PermissionsId <= 0 && useGroup == false)
			{
				var ri = rc.GetRoleByName(portalId, "Administrators");
				if (ri != null)
				{
					fi.PermissionsId = db.CreatePermSet(ri.RoleID.ToString());
					permissionsId = fi.PermissionsId;
					isNew = true;
				}
				if (fi.ForumID > 0 & ! (string.IsNullOrEmpty(fi.ForumSettingsKey)))
				{
					if (fi.ForumSettingsKey.Contains("G:"))
						fi.ForumSettingsKey = string.Empty;
				}
				if (fi.ForumSettingsKey == "" && fi.ForumID > 0)
				{
					fi.ForumSettingsKey = "F:" + fi.ForumID;
				}
			}
			else if (useGroup == false && string.IsNullOrEmpty(fi.ForumSettingsKey) && fi.ForumID > 0)
			{
				fi.ForumSettingsKey = "F:" + fi.ForumID;
			}

			var forumId = Convert.ToInt32(DataProvider.Instance().Forum_Save(portalId, fi.ForumID, fi.ModuleId, fi.ForumGroupId, fi.ParentForumId, fi.ForumName, fi.ForumDesc, fi.SortOrder, fi.Active, fi.Hidden, fi.ForumSettingsKey, fi.PermissionsId, fi.PrefixURL, fi.SocialGroupId, fi.HasProperties));
			if (String.IsNullOrEmpty(fi.ForumSettingsKey))
				fi.ForumSettingsKey = "F:" + forumId;

			if (fi.ForumSettingsKey.Contains("G:"))
			    DataProvider.Instance().Forum_ConfigCleanUp(fi.ModuleId, "F:" + fi.ForumID, "F:" + fi.ForumID);

			if (isNew && useGroup == false)
			{
				var moduleId = fi.ModuleId;
				Permissions.CreateDefaultSets(portalId, permissionsId);

				var sKey = "F:" + forumId.ToString();
				Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicsTemplateId, "0");
				Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicTemplateId, "0");
				Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicFormId, "0");
				Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.ReplyFormId, "0");
				Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.AllowRSS, "false");
			}
            
            // Clear the caches
			DataCache.CacheClear(string.Format(CacheKeys.ForumList, fi.ModuleId));

            var cachekey = string.Format(forumInfoCacheKey, portalId, fi.ModuleId, forumId);
			DataCache.CacheClear(cachekey);

			return forumId;
		}