Exemplo n.º 1
0
        public int Groups_Save(int portalId, ForumGroupInfo fg, bool isNew)
        {
            var rc = new Security.Roles.RoleController();
            var db = new Data.Common();

            var permissionsId = -1;

            if (fg.PermissionsId == -1)
            {
                var ri = rc.GetRoleByName(portalId, "Administrators");
                if (ri != null)
                {
                    fg.PermissionsId = db.CreatePermSet(ri.RoleID.ToString());
                    permissionsId    = fg.PermissionsId;
                }
            }

            var groupId = DataProvider.Instance().Groups_Save(portalId, fg.ModuleId, fg.ForumGroupId, fg.GroupName, fg.SortOrder, fg.Active, fg.Hidden, fg.PermissionsId, fg.PrefixURL);

            if (isNew)
            {
                Permissions.CreateDefaultSets(portalId, permissionsId);
                var moduleId = fg.ModuleId;
                var sKey     = "G:" + groupId.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");
            }

            DataCache.CacheClear(string.Format(CacheKeys.ForumList, fg.ModuleId));

            return(groupId);
        }
Exemplo n.º 2
0
        public int Groups_Save(int portalId, ForumGroupInfo fg, bool isNew)
        {
            var rc = new Security.Roles.RoleController();
            var db = new Data.Common();

            var permissionsId = -1;
            if (fg.PermissionsId == -1)
            {
                var ri = rc.GetRoleByName(portalId, "Administrators");
                if (ri != null)
                {
                    fg.PermissionsId = db.CreatePermSet(ri.RoleID.ToString());
                    permissionsId = fg.PermissionsId;
                }
            }

            var groupId = DataProvider.Instance().Groups_Save(portalId, fg.ModuleId, fg.ForumGroupId, fg.GroupName, fg.SortOrder, fg.Active, fg.Hidden, fg.PermissionsId, fg.PrefixURL);
            if (isNew)
            {
                Permissions.CreateDefaultSets(portalId, permissionsId);
                var moduleId = fg.ModuleId;
                var sKey = "G:" + groupId.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");
            }

            DataCache.CacheClear(string.Format(CacheKeys.ForumList, fg.ModuleId));

            return groupId;
        }
Exemplo n.º 3
0
        public ForumGroupInfo GetForumGroup(int moduleId, int forumGroupId)
        {
            var            db = new Data.Groups();
            ForumGroupInfo gi = null;

            using (var dr = db.Groups_Get(moduleId, forumGroupId))
            {
                while (dr.Read())
                {
                    gi = FillForumGroup(dr);
                }
                dr.Close();
            }
            return(gi);
        }
Exemplo n.º 4
0
        private static ForumGroupInfo FillForumGroup(IDataRecord dr)
        {
            var g = new ForumGroupInfo
            {
                Active           = dr.GetBoolean("Active"),
                ForumGroupId     = dr.GetInt("ForumGroupId"),
                Hidden           = dr.GetBoolean("Hidden"),
                GroupName        = dr.GetString("GroupName"),
                SortOrder        = dr.GetInt("SortOrder"),
                GroupSettingsKey = dr.GetString("GroupSettingsKey"),
                PermissionsId    = dr.GetInt("PermissionsId"),
                PrefixURL        = dr.GetString("PrefixURL"),
                ModuleId         = dr.GetInt("ModuleId"),
                Security         =
                {
                    Announce   = dr.GetString("CanAnnounce"),
                    Attach     = dr.GetString("CanAttach"),
                    Create     = dr.GetString("CanCreate"),
                    Delete     = dr.GetString("CanDelete"),
                    Edit       = dr.GetString("CanEdit"),
                    Lock       = dr.GetString("CanLock"),
                    ModApprove = dr.GetString("CanModApprove"),
                    ModDelete  = dr.GetString("CanModDelete"),
                    ModEdit    = dr.GetString("CanModEdit"),
                    ModLock    = dr.GetString("CanModLock"),
                    ModMove    = dr.GetString("CanModMove"),
                    ModPin     = dr.GetString("CanModPin"),
                    ModSplit   = dr.GetString("CanModSplit"),
                    ModUser    = dr.GetString("CanModUser"),
                    Pin        = dr.GetString("CanPin"),
                    Poll       = dr.GetString("CanPoll"),
                    Block      = dr.GetString("CanBlock"),
                    Read       = dr.GetString("CanRead"),
                    Reply      = dr.GetString("CanReply"),
                    Subscribe  = dr.GetString("CanSubscribe"),
                    Trust      = dr.GetString("CanTrust"),
                    View       = dr.GetString("CanView"),
                    Tag        = dr.GetString("CanTag"),
                    Prioritize = dr.GetString("CanPrioritize"),
                    Categorize = dr.GetString("CanCategorize")
                }
            };

            return(g);
        }
Exemplo n.º 5
0
        private static ForumGroupInfo FillForumGroup(IDataRecord dr)
        {
            var g = new ForumGroupInfo
                        {
                            Active = dr.GetBoolean("Active"),
                            ForumGroupId = dr.GetInt("ForumGroupId"),
                            Hidden = dr.GetBoolean("Hidden"),
                            GroupName = dr.GetString("GroupName"),
                            SortOrder = dr.GetInt("SortOrder"),
                            GroupSettingsKey = dr.GetString("GroupSettingsKey"),
                            PermissionsId = dr.GetInt("PermissionsId"),
                            PrefixURL = dr.GetString("PrefixURL"),
                            ModuleId = dr.GetInt("ModuleId"),
                            Security =
                                {
                                    Announce =  dr.GetString("CanAnnounce"),
                                    Attach = dr.GetString("CanAttach"),
                                    Create = dr.GetString("CanCreate"),
                                    Delete = dr.GetString("CanDelete"),
                                    Edit = dr.GetString("CanEdit"),
                                    Lock = dr.GetString("CanLock"),
                                    ModApprove = dr.GetString("CanModApprove"),
                                    ModDelete = dr.GetString("CanModDelete"),
                                    ModEdit = dr.GetString("CanModEdit"),
                                    ModLock = dr.GetString("CanModLock"),
                                    ModMove = dr.GetString("CanModMove"),
                                    ModPin = dr.GetString("CanModPin"),
                                    ModSplit = dr.GetString("CanModSplit"),
                                    ModUser = dr.GetString("CanModUser"),
                                    Pin = dr.GetString("CanPin"),
                                    Poll = dr.GetString("CanPoll"),
                                    Block = dr.GetString("CanBlock"),
                                    Read = dr.GetString("CanRead"),
                                    Reply = dr.GetString("CanReply"),
                                    Subscribe = dr.GetString("CanSubscribe"),
                                    Trust = dr.GetString("CanTrust"),
                                    View = dr.GetString("CanView"),
                                    Tag = dr.GetString("CanTag"),
                                    Prioritize = dr.GetString("CanPrioritize"),
                                    Categorize = dr.GetString("CanCategorize")
                                }
                        };

            return g;
        }
Exemplo n.º 6
0
 internal int Groups_Save(int portalId, ForumGroupInfo fg)
 {
     return Groups_Save(portalId, fg, false);
 }
Exemplo n.º 7
0
 internal int Groups_Save(int portalId, ForumGroupInfo fg)
 {
     return(Groups_Save(portalId, fg, false));
 }
Exemplo n.º 8
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);
                                }
                            }
                        }
                    }
                }
            }
        }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }