private void cbEditorAction_Callback(object sender, Controls.CallBackEventArgs e) { switch (e.Parameters[0].ToLowerInvariant()) { case "forumsave": { var fi = new Forum(); var fc = new ForumController(); var bIsNew = false; int forumGroupId; var forumSettingsKey = string.Empty; if (Utilities.SafeConvertInt(e.Parameters[1]) <= 0) { bIsNew = true; fi.ForumID = -1; } else { fi = fc.Forums_Get(PortalId, ModuleId, Utilities.SafeConvertInt(e.Parameters[1]), UserId, false, false, -1); forumSettingsKey = fi.ForumSettingsKey; } fi.ModuleId = ModuleId; fi.PortalId = PortalId; var sParentValue = e.Parameters[2]; var parentForumId = 0; if (sParentValue.Contains("GROUP")) { sParentValue = sParentValue.Replace("GROUP", string.Empty); forumGroupId = Utilities.SafeConvertInt(sParentValue); } else { parentForumId = Utilities.SafeConvertInt(sParentValue.Replace("FORUM", string.Empty)); forumGroupId = fc.Forums_GetGroupId(parentForumId); } fi.ForumGroupId = forumGroupId; fi.ParentForumId = parentForumId; fi.ForumName = e.Parameters[3]; fi.ForumDesc = e.Parameters[4]; fi.Active = Utilities.SafeConvertBool(e.Parameters[5]); fi.Hidden = Utilities.SafeConvertBool(e.Parameters[6]); fi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]); var fkey = string.IsNullOrEmpty(fi.ForumSettingsKey) ? string.Empty : fi.ForumSettingsKey; if (Utilities.SafeConvertBool(e.Parameters[8])) { var fgc = new ForumGroupController(); var fgi = fgc.GetForumGroup(ModuleId, forumGroupId); if (bIsNew) { fi.PermissionsId = fgi.PermissionsId; } else if (fi.ForumSettingsKey != "G:" + forumGroupId) { fi.PermissionsId = fgi.PermissionsId; } fi.ForumSettingsKey = "G:" + forumGroupId; } else if (bIsNew || fkey.Contains("G:")) { fi.ForumSettingsKey = string.Empty; if (fi.InheritSecurity) { fi.PermissionsId = -1; } } else { fi.ForumSettingsKey = "F:" + fi.ForumID; } if (forumSettingsKey != fkey && fkey.Contains("F:")) { bIsNew = true; } fi.PrefixURL = e.Parameters[9]; if (!(string.IsNullOrEmpty(fi.PrefixURL))) { var db = new Data.Common(); if (!(db.CheckForumURL(PortalId, ModuleId, fi.PrefixURL, fi.ForumID, fi.ForumGroupId))) { fi.PrefixURL = string.Empty; } } var forumId = fc.Forums_Save(PortalId, fi, bIsNew, Utilities.SafeConvertBool(e.Parameters[8])); recordId = forumId; var securityKey = string.Empty; DataCache.ClearForumGroupsCache(ModuleId); var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId); DataCache.CacheClear(cachekey); cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); hidEditorResult.Value = forumId.ToString(); break; } case "groupsave": { var bIsNew = false; var groupId = Utilities.SafeConvertInt(e.Parameters[1]); var fgc = new ForumGroupController(); var gi = (groupId > 0) ? fgc.Groups_Get(ModuleId, groupId) : new ForumGroupInfo(); var securityKey = string.Empty; if (groupId == 0) { bIsNew = true; } else { securityKey = "G:" + groupId; } gi.ModuleId = ModuleId; gi.ForumGroupId = groupId; gi.GroupName = e.Parameters[3]; gi.Active = Utilities.SafeConvertBool(e.Parameters[5]); gi.Hidden = Utilities.SafeConvertBool(e.Parameters[6]); gi.SortOrder = string.IsNullOrWhiteSpace(e.Parameters[7]) ? 0 : Utilities.SafeConvertInt(e.Parameters[7]); gi.PrefixURL = e.Parameters[9]; if (!(string.IsNullOrEmpty(gi.PrefixURL))) { var db = new Data.Common(); if (!(db.CheckGroupURL(PortalId, ModuleId, gi.PrefixURL, gi.ForumGroupId))) { gi.PrefixURL = string.Empty; } } gi.GroupSettingsKey = securityKey; var gc = new ForumGroupController(); groupId = gc.Groups_Save(PortalId, gi, bIsNew); recordId = groupId; DataCache.ClearForumGroupsCache(ModuleId); var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); hidEditorResult.Value = groupId.ToString(); break; } case "forumsettingssave": { var forumId = Utilities.SafeConvertInt(e.Parameters[1]); var sKey = "F:" + forumId; SaveSettings(sKey, e.Parameters); hidEditorResult.Value = forumId.ToString(); DataCache.CacheClear(forumId.ToString() + "ForumSettings"); DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId)); DataCache.CacheClear(string.Format(CacheKeys.ForumInfo, forumId) + "st"); var cachekey = string.Format("AF-FI-{0}-{1}-{2}", PortalId, ModuleId, forumId); DataCache.CacheClear(cachekey); break; } case "groupsettingssave": { var forumId = Utilities.SafeConvertInt(e.Parameters[1]); var sKey = "G:" + forumId; SaveSettings(sKey, e.Parameters); hidEditorResult.Value = forumId.ToString(); DataCache.CacheClear(forumId.ToString() + "GroupSettings"); DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId)); DataCache.CacheClear(string.Format(CacheKeys.GroupInfo, forumId) + "st"); break; } case "deleteforum": { var forumId = Utilities.SafeConvertInt(e.Parameters[1]); DataProvider.Instance().Forums_Delete(PortalId, ModuleId, forumId); var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); break; } case "deletegroup": { var groupId = Utilities.SafeConvertInt(e.Parameters[1]); DataProvider.Instance().Groups_Delete(ModuleId, groupId); var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); break; } } DataCache.CacheClear(string.Format(CacheKeys.ForumList, ModuleId)); DataCache.ClearAllForumSettingsCache(ModuleId); DataCache.CacheClear(ModuleId + "fv"); hidEditorResult.RenderControl(e.Output); }
private void 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); }