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);
        }
		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;
		}
Beispiel #3
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, "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.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);
                                }
                            }
                        }
                    }
                }
            }
        }
		public void Insert(int index, Forum value)
		{
			List.Insert(index, value);
		}
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ServicesFramework.Instance.RequestAjaxAntiForgerySupport();

            var oLink = new System.Web.UI.HtmlControls.HtmlGenericControl("link");
            oLink.Attributes["rel"] = "stylesheet";
            oLink.Attributes["type"] = "text/css";
            oLink.Attributes["href"] = Page.ResolveUrl("~/DesktopModules/ActiveForums/scripts/calendar.css");

            var oCSS = Page.FindControl("CSS");
            if (oCSS != null)
                oCSS.Controls.Add(oLink);

            _fi = ForumInfo;
            _authorId = UserId;
            _canModEdit = Permissions.HasPerm(_fi.Security.ModEdit, ForumUser.UserRoles);
            _canModApprove = Permissions.HasPerm(_fi.Security.ModApprove, ForumUser.UserRoles);
            _canEdit = Permissions.HasPerm(_fi.Security.Edit, ForumUser.UserRoles);
            _canAttach = Permissions.HasPerm(_fi.Security.Attach, ForumUser.UserRoles);
            _canTrust = Permissions.HasPerm(_fi.Security.Trust, ForumUser.UserRoles);
            _canLock = Permissions.HasPerm(_fi.Security.Lock, ForumUser.UserRoles);
            _canPin = Permissions.HasPerm(_fi.Security.Pin, ForumUser.UserRoles);
            _canAnnounce = Permissions.HasPerm(_fi.Security.Announce, ForumUser.UserRoles);

            if (_fi == null)
                Response.Redirect(NavigateUrl(ForumTabId));
            else if (Request.Params["action"] != null)
            {
                if (!_canEdit && (Request.Params["action"].ToLowerInvariant() == "te" || Request.Params["action"].ToLowerInvariant() == "re"))
                    Response.Redirect(NavigateUrl(ForumTabId));
            }

            if (CanCreate == false && CanReply == false)
                Response.Redirect(NavigateUrl(ForumTabId, "", "ctl=login") + "?returnurl=" + Server.UrlEncode(Request.RawUrl));

            if (UserId > 0)
                _ui = ForumUser.Profile;
            else
            {
                _ui.TopicCount = 0;
                _ui.ReplyCount = 0;
                _ui.RewardPoints = 0;
                _ui.IsMod = false;
                _ui.TrustLevel = -1;
            }

            _userIsTrusted = Utilities.IsTrusted((int)_fi.DefaultTrustValue, _ui.TrustLevel, _canTrust, _fi.AutoTrustLevel, _ui.PostCount);
            Spinner = Page.ResolveUrl("~/DesktopModules/activeforums/themes/" + MainSettings.Theme + "/images/loading.gif");
            _isApproved = !_fi.IsModerated || _userIsTrusted || _canModApprove;

            var myTheme = MainSettings.Theme;
            _themePath = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + myTheme);
            ctlForm.ID = "ctlForm";
            ctlForm.PostButton.ImageUrl = _themePath + "/images/save32.png";
            ctlForm.PostButton.ImageLocation = "TOP";
            ctlForm.PostButton.Height = Unit.Pixel(50);
            ctlForm.PostButton.Width = Unit.Pixel(50);

            ctlForm.PostButton.ClientSideScript = "amPostback();";
            ctlForm.PostButton.PostBack = false;

            ctlForm.AttachmentsClientId = hidAttachments.ClientID;

            // TODO: Make sure this check happens on submit
            //if (_canAttach && _fi.AllowAttach) {}

            ctlForm.CancelButton.ImageUrl = _themePath + "/images/cancel32.png";
            ctlForm.CancelButton.ImageLocation = "TOP";
            ctlForm.CancelButton.PostBack = false;
            ctlForm.CancelButton.ClientSideScript = "javascript:history.go(-1);";
            ctlForm.CancelButton.Confirm = true;
            ctlForm.CancelButton.Height = Unit.Pixel(50);
            ctlForm.CancelButton.Width = Unit.Pixel(50);
            ctlForm.CancelButton.ConfirmMessage = GetSharedResource("[RESX:ConfirmCancel]");
            ctlForm.ModuleConfiguration = ModuleConfiguration;
            ctlForm.Subscribe = UserPrefTopicSubscribe;
            if (_fi.AllowHTML)
            {
                _allowHTML = IsHtmlPermitted(_fi.EditorPermittedUsers, _userIsTrusted, _canModEdit);
            }
            ctlForm.AllowHTML = _allowHTML;
            if (_allowHTML)
            {
                _editorType = _fi.EditorType;
            }
            else
            {
                _editorType = EditorTypes.TEXTBOX;
            }
            if (Request.Browser.IsMobileDevice)
            {
                _editorType = EditorTypes.TEXTBOX;
                _allowHTML = false;
            }
            ctlForm.EditorType = _editorType;
            ctlForm.ForumInfo = _fi;
            ctlForm.RequireCaptcha = true;
            switch (_editorType)
            {
                case EditorTypes.TEXTBOX:
                    Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/text_editor.js"));
                    break;
                case EditorTypes.ACTIVEEDITOR:
                    Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/active_editor.js"));
                    break;
                default:
                    {
                        var prov = ProviderConfiguration.GetProviderConfiguration("htmlEditor");

                        if (prov.DefaultProvider.ToLowerInvariant().Contains("telerik") | prov.DefaultProvider.ToLowerInvariant().Contains("radeditor"))
                        {
                            Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/telerik_editor.js"));
                        }
                        else if (prov.DefaultProvider.Contains("CKHtmlEditorProvider"))
                        {
                            Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/ck_editor.js"));
                        }
                        else if (prov.DefaultProvider.Contains("FckHtmlEditorProvider"))
                        {
                            Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/fck_editor.js"));
                        }
                        else
                        {
                            Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/other_editor.js"));
                        }
                    }
                    break;
            }
            if (Request.Params["action"] != null)
            {
                switch (Request.Params["action"].ToLowerInvariant())
                {
                    case "te": //Topic Edit
                        if (_canModEdit || (_canEdit && Request.IsAuthenticated))
                        {
                            _isEdit = true;
                            PrepareTopic();
                            LoadTopic();
                        }
                        break;
                    case "re": //Reply Edit
                        if (_canModEdit || (_canEdit && Request.IsAuthenticated))
                        {
                            _isEdit = true;
                            PrepareReply();
                            LoadReply();
                        }
                        break;
                    case "reply":
                        if (CanReply)
                        {
                            PrepareReply();
                        }
                        break;
                    case "new":
                        if (CanCreate)
                        {
                            PrepareTopic();

                        }
                        break;
                    default:
                        if (CanCreate)
                        {
                            PrepareTopic();
                        }
                        break;
                }
            }
            else
            {
                if (QuoteId == 0 && ReplyId == 0 && TopicId == -1 && CanCreate)
                {
                    PrepareTopic();
                }
                else if ((QuoteId > 0 | ReplyId > 0 | TopicId > 0) && CanReply)
                {
                    PrepareReply();
                }
            }
            if (_isEdit && !Request.IsAuthenticated)
            {
                Response.Redirect(NavigateUrl(ForumTabId));
            }

            PrepareAttachments(_contentId);

            ctlForm.ContentId = _contentId;
            ctlForm.AuthorId = _authorId;
            plhContent.Controls.Add(ctlForm);

            EditorClientId = ctlForm.ClientID;

            ctlForm.BubbleClick += ctlForm_Click;
            cbPreview.CallbackEvent += cbPreview_Callback;

            //Page.ClientScript.RegisterClientScriptInclude("aftags", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/jquery.tokeninput.js"))
        }
Beispiel #6
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);
                                }
                            }
                        }
                    }
                }
            }
        }
		public bool Contains(Forum value)
		{
			return List.Contains(value);
		}
 public int IndexOf(Forum value)
 {
     return(List.IndexOf(value));
 }
 public void Insert(int index, Forum value)
 {
     List.Insert(index, value);
 }
 public int Add(Forum value)
 {
     return(List.Add(value));
 }
 public bool Contains(Forum value)
 {
     return(List.Contains(value));
 }
Beispiel #12
0
        public static void SendSubscriptions(int TemplateId, int PortalId, int ModuleId, int TabId, Forum fi, int TopicId, int ReplyId, int AuthorId)
        {
            var                     _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
            SettingsInfo            MainSettings    = DataCache.MainSettings(ModuleId);
            var                     sc   = new SubscriptionController();
            List <SubscriptionInfo> subs = sc.Subscription_GetSubscribers(PortalId, fi.ForumID, TopicId, SubscriptionTypes.Instant, AuthorId, fi.Security.Subscribe);

            if (subs.Count <= 0)
            {
                return;
            }

            string       Subject;
            string       BodyText;
            string       BodyHTML;
            string       sTemplate = string.Empty;
            var          tc        = new TemplateController();
            TemplateInfo ti;

            ti       = TemplateId > 0 ? tc.Template_Get(TemplateId) : tc.Template_Get("SubscribedEmail", PortalId, ModuleId);
            Subject  = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset);
            BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset);
            BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset);
            string sFrom;

            sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email;
            var oEmail = new Email
            {
                Recipients         = subs,
                Subject            = Subject,
                From               = sFrom,
                BodyText           = BodyText,
                BodyHTML           = BodyHTML,
                SmtpServer         = Host.SMTPServer,                     // Convert.ToString(_portalSettings.HostSettings["SMTPServer"]),
                SmtpUserName       = Host.SMTPUsername,                   // Convert.ToString(_portalSettings.HostSettings["SMTPUsername"]),
                SmtpPassword       = Host.SMTPPassword,                   // Convert.ToString(_portalSettings.HostSettings["SMTPPassword"]),
                SmtpAuthentication = Host.SMTPAuthentication,             // Convert.ToString(_portalSettings.HostSettings["SMTPAuthentication"]),
                SmtpSSL            = Host.EnableSMTPSSL.ToString(),       // Convert.ToString(_portalSettings.HostSettings["SMTPEnableSSL"]),
                UseQueue           = MainSettings.MailQueue
            };


            var objThread = new System.Threading.Thread(oEmail.Send);

            objThread.Start();
        }
Beispiel #13
0
        public static string PreviewTopic(int topicTemplateID, int portalId, int moduleId, int tabId, Forum forumInfo, int userId, string body, string imagePath, User up, DateTime postDate, CurrentUserTypes currentUserType, int currentUserId, int timeZoneOffset)
        {
            var sTemplate = GetTopicTemplate(topicTemplateID, moduleId);

            try
            {
                var mainSettings = DataCache.MainSettings(moduleId);
                var sTopic       = GetTemplateSection(sTemplate, "[TOPIC]", "[/TOPIC]");
                sTopic    = sTopic.Replace("[ACTIONS:ALERT]", string.Empty);
                sTopic    = sTopic.Replace("[ACTIONS:EDIT]", string.Empty);
                sTopic    = sTopic.Replace("[ACTIONS:DELETE]", string.Empty);
                sTopic    = sTopic.Replace("[ACTIONS:QUOTE]", string.Empty);
                sTopic    = sTopic.Replace("[ACTIONS:REPLY]", string.Empty);
                sTopic    = sTopic.Replace("[POSTDATE]", Utilities.GetDate(postDate, moduleId, timeZoneOffset));
                sTopic    = sTopic.Replace("[POSTINFO]", GetPostInfo(portalId, moduleId, userId, up.UserName, up, imagePath, false, HttpContext.Current.Request.UserHostAddress, true, currentUserType, currentUserId, false, timeZoneOffset));
                sTemplate = ParsePreview(portalId, sTopic, body, moduleId);
                sTemplate = "<table class=\"afgrid\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"1\">" + sTemplate;
                sTemplate = sTemplate + "</table>";
                sTemplate = Utilities.LocalizeControl(sTemplate);
                sTemplate = Utilities.StripTokens(sTemplate);
            }
            catch (Exception ex)
            {
                sTemplate = ex.ToString();
            }

            return(sTemplate);
        }
		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;
		}
 public static void SendSubscriptions(int PortalId, int ModuleId, int TabId, Forum fi, int TopicId, int ReplyId, int AuthorId)
 {
     SendSubscriptions(-1, PortalId, ModuleId, TabId, fi, TopicId, ReplyId, AuthorId);
 }
        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);
        }
        public static void SendSubscriptions(int TemplateId, int PortalId, int ModuleId, int TabId, Forum fi, int TopicId, int ReplyId, int AuthorId)
        {
            var _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
            SettingsInfo MainSettings = DataCache.MainSettings(ModuleId);
            var sc = new SubscriptionController();
            List<SubscriptionInfo> subs = sc.Subscription_GetSubscribers(PortalId, fi.ForumID, TopicId, SubscriptionTypes.Instant, AuthorId, fi.Security.Subscribe);
            if (subs.Count <= 0)
            {
                return;
            }

            string Subject;
            string BodyText;
            string BodyHTML;
            string sTemplate = string.Empty;
            var tc = new TemplateController();
            TemplateInfo ti;
            ti = TemplateId > 0 ? tc.Template_Get(TemplateId) : tc.Template_Get("SubscribedEmail", PortalId, ModuleId);
            TemplateUtils.lstSubscriptionInfo = subs;
            Subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset);
            BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset);
            BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset);
            string sFrom;
            sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email;
            var oEmail = new Email
                             {
                                 Recipients = subs,
                                 Subject = Subject,
                                 From = sFrom,
                                 BodyText = BodyText,
                                 BodyHTML = BodyHTML,
                                 UseQueue = MainSettings.MailQueue
                             };

            var objThread = new System.Threading.Thread(oEmail.Send);
            objThread.Start();
        }
        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);
        }
		public int Add(Forum value)
		{
			return List.Add(value);
		}
        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);
        }
		public int IndexOf(Forum value)
		{
			return List.IndexOf(value);
		}
Beispiel #22
0
 public static void SendSubscriptions(int PortalId, int ModuleId, int TabId, Forum fi, int TopicId, int ReplyId, int AuthorId)
 {
     SendSubscriptions(-1, PortalId, ModuleId, TabId, fi, TopicId, ReplyId, AuthorId);
 }
		public Forum this[int index]
		{
			get
			{
				return _Item;
			}
			set
			{
				_Item = value;
			}
		}
Beispiel #24
0
        public static void SendSubscriptions(int TemplateId, int PortalId, int ModuleId, int TabId, Forum fi, int TopicId, int ReplyId, int AuthorId)
        {
            var                     _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
            SettingsInfo            MainSettings    = DataCache.MainSettings(ModuleId);
            var                     sc   = new SubscriptionController();
            List <SubscriptionInfo> subs = sc.Subscription_GetSubscribers(PortalId, fi.ForumID, TopicId, SubscriptionTypes.Instant, AuthorId, fi.Security.Subscribe);

            if (subs.Count <= 0)
            {
                return;
            }

            string       Subject;
            string       BodyText;
            string       BodyHTML;
            string       sTemplate = string.Empty;
            var          tc        = new TemplateController();
            TemplateInfo ti;

            ti = TemplateId > 0 ? tc.Template_Get(TemplateId) : tc.Template_Get("SubscribedEmail", PortalId, ModuleId);
            TemplateUtils.lstSubscriptionInfo = subs;
            Subject  = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, Convert.ToInt32(_portalSettings.TimeZone.BaseUtcOffset.TotalMinutes));
            BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, Convert.ToInt32(_portalSettings.TimeZone.BaseUtcOffset.TotalMinutes));
            BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, Convert.ToInt32(_portalSettings.TimeZone.BaseUtcOffset.TotalMinutes));
            string sFrom;

            sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email;
            var oEmail = new Email
            {
                Recipients = subs,
                Subject    = Subject,
                From       = sFrom,
                BodyText   = BodyText,
                BodyHTML   = BodyHTML,
                UseQueue   = MainSettings.MailQueue
            };


            var objThread = new System.Threading.Thread(oEmail.Send);

            objThread.Start();
        }
        public static string PreviewTopic(int topicTemplateID, int portalId, int moduleId, int tabId, Forum forumInfo, int userId, string body, string imagePath, User up, DateTime postDate, CurrentUserTypes currentUserType, int currentUserId, int timeZoneOffset)
        {
            var sTemplate = GetTopicTemplate(topicTemplateID, moduleId);
            try
            {
                var mainSettings = DataCache.MainSettings(moduleId);
                var sTopic = GetTemplateSection(sTemplate, "[TOPIC]", "[/TOPIC]");
                sTopic = sTopic.Replace("[ACTIONS:ALERT]", string.Empty);
                sTopic = sTopic.Replace("[ACTIONS:EDIT]", string.Empty);
                sTopic = sTopic.Replace("[ACTIONS:DELETE]", string.Empty);
                sTopic = sTopic.Replace("[ACTIONS:QUOTE]", string.Empty);
                sTopic = sTopic.Replace("[ACTIONS:REPLY]", string.Empty);
                sTopic = sTopic.Replace("[POSTDATE]", Utilities.GetDate(postDate, moduleId, timeZoneOffset));
                sTopic = sTopic.Replace("[POSTINFO]", GetPostInfo(portalId, moduleId, userId, up.UserName, up, imagePath, false, HttpContext.Current.Request.UserHostAddress, true, currentUserType, currentUserId, false, timeZoneOffset));
                sTemplate = ParsePreview(portalId, sTopic, body, moduleId);
                sTemplate = "<table class=\"afgrid\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"1\">" + sTemplate;
                sTemplate = sTemplate + "</table>";
                sTemplate = Utilities.LocalizeControl(sTemplate);
                sTemplate = Utilities.StripTokens(sTemplate);
            }
            catch (Exception ex)
            {
                sTemplate = ex.ToString();
            }

            return sTemplate;
        }
		private static Forum FillForum(IDataRecord dr)
		{
			var fi = new Forum
			{
			    ForumGroup = new ForumGroupInfo(),
			    ForumID = Convert.ToInt32(dr["ForumId"].ToString()),
			    Active = Convert.ToBoolean(dr["Active"]),
			    ModuleId = Convert.ToInt32(dr["ModuleId"].ToString()),
			    ForumGroupId = Convert.ToInt32(dr["ForumGroupId"].ToString()),
			    ParentForumId = Convert.ToInt32(dr["ParentForumId"].ToString()),
			    ForumName = dr["ForumName"].ToString(),
			    ForumDesc = dr["ForumDesc"].ToString(),
			    SortOrder = Convert.ToInt32(dr["SortOrder"].ToString()),
			    Hidden = Convert.ToBoolean(dr["Hidden"]),
			    TotalTopics = Convert.ToInt32(dr["TotalTopics"].ToString()),
			    TotalReplies = Convert.ToInt32(dr["TotalReplies"].ToString()),
			    LastTopicId = Convert.ToInt32(dr["LastTopicId"].ToString()),
			    LastReplyId = Convert.ToInt32(dr["LastReplyId"].ToString()),
			    GroupName = dr["GroupName"].ToString(),
			    PermissionsId = Convert.ToInt32(dr["PermissionsId"].ToString()),
			    ForumSettingsKey = dr["ForumSettingsKey"].ToString(),
			    InheritSecurity = Convert.ToBoolean(dr["InheritSecurity"]),
			    PrefixURL = dr["PrefixURL"].ToString(),
                SocialGroupId = Convert.ToInt32(dr["SocialGroupId"].ToString()),
			    HasProperties = Convert.ToBoolean(dr["HasProperties"])
			};

		    fi.ForumGroup.ForumGroupId = fi.ForumGroupId;
			fi.ForumGroup.GroupName = fi.GroupName;
			fi.ForumGroup.PrefixURL = dr["GroupPrefixURL"].ToString();
			fi.Security.Announce = dr["CanAnnounce"].ToString();
			fi.Security.Attach = dr["CanAttach"].ToString();
			fi.Security.Create = dr["CanCreate"].ToString();
			fi.Security.Delete = dr["CanDelete"].ToString();
			fi.Security.Edit = dr["CanEdit"].ToString();
			fi.Security.Lock = dr["CanLock"].ToString();
			fi.Security.ModApprove = dr["CanModApprove"].ToString();
			fi.Security.ModDelete = dr["CanModDelete"].ToString();
			fi.Security.ModEdit = dr["CanModEdit"].ToString();
			fi.Security.ModLock = dr["CanModLock"].ToString();
			fi.Security.ModMove = dr["CanModMove"].ToString();
			fi.Security.ModPin = dr["CanModPin"].ToString();
			fi.Security.ModSplit = dr["CanModSplit"].ToString();
			fi.Security.ModUser = dr["CanModUser"].ToString();
			fi.Security.Pin = dr["CanPin"].ToString();
			fi.Security.Poll = dr["CanPoll"].ToString();
			fi.Security.Block = dr["CanBlock"].ToString();
			fi.Security.Read = dr["CanRead"].ToString();
			fi.Security.Reply = dr["CanReply"].ToString();
			fi.Security.Subscribe = dr["CanSubscribe"].ToString();
			fi.Security.Trust = dr["CanTrust"].ToString();
			fi.Security.View = dr["CanView"].ToString();
			fi.Security.Tag = dr["CanTag"].ToString();
			fi.Security.Prioritize = dr["CanPrioritize"].ToString();
			fi.Security.Categorize = dr["CanCategorize"].ToString();

			return fi;
		}