Ejemplo n.º 1
0
        public HttpResponseMessage CreateSplit(CreateSplitDTO dto)
        {
            if (dto.NewTopicId == dto.OldTopicId)
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }

            var portalSettings = PortalSettings;
            var userInfo       = portalSettings.UserInfo;
            var forumUser      = new UserController().GetUser(portalSettings.PortalId, ActiveModule.ModuleID, userInfo.UserID);

            var fc = new ForumController();

            var forum_out = fc.Forums_Get(portalSettings.PortalId, ActiveModule.ModuleID, 0, forumUser.UserId, false, true, dto.OldTopicId);
            var forum_in  = fc.GetForum(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId);

            if (forum_out != null && forum_in != null)
            {
                var perm = false;

                if (forum_out == forum_in)
                {
                    perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles);
                }
                else
                {
                    perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles) && Permissions.HasPerm(forum_in.Security.View, forumUser.UserRoles);
                }

                var modSplit = Permissions.HasPerm(forum_out.Security.ModSplit, forumUser.UserRoles);

                if (perm && modSplit)
                {
                    var tc = new TopicsController();

                    int topicId;

                    if (dto.NewTopicId < 1)
                    {
                        var subject      = Utilities.CleanString(portalSettings.PortalId, dto.Subject, false, EditorTypes.TEXTBOX, false, false, ActiveModule.ModuleID, string.Empty, false);
                        var replies      = dto.Replies.Split('|');
                        var rc           = new DotNetNuke.Modules.ActiveForums.DAL2.ReplyController();
                        var firstReply   = rc.Get(Convert.ToInt32(replies[0]));
                        var cc           = new ContentController();
                        var firstContent = cc.Get(firstReply.ContentId);
                        topicId = tc.Topic_QuickCreate(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId, subject, string.Empty, firstContent.AuthorId, firstContent.AuthorName, true, Request.GetIPAddress());
                        tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, true);
                    }
                    else
                    {
                        topicId = dto.NewTopicId;
                        tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, false);
                    }
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        public HttpResponseMessage CreateSplit(CreateSplitDTO dto)
        {
            if (dto.NewTopicId == dto.OldTopicId) return Request.CreateResponse(HttpStatusCode.OK);

            var portalSettings = PortalSettings;
            var userInfo = portalSettings.UserInfo;
            var forumUser = new UserController().GetUser(portalSettings.PortalId, ActiveModule.ModuleID, userInfo.UserID);

            var fc = new ForumController();

            var forum_out = fc.Forums_Get(portalSettings.PortalId, ActiveModule.ModuleID, 0, forumUser.UserId, false, true, dto.OldTopicId);
            var forum_in = fc.GetForum(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId);
            if (forum_out != null && forum_in != null)
            {
                var perm = false;

                if (forum_out == forum_in)
                {
                    perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles);
                }
                else
                {
                    perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles) && Permissions.HasPerm(forum_in.Security.View, forumUser.UserRoles);
                }

                var modSplit = Permissions.HasPerm(forum_out.Security.ModSplit, forumUser.UserRoles);

                if (perm && modSplit)
                {
                    var tc = new TopicsController();

                    int topicId;

                    if (dto.NewTopicId < 1)
                    {
                        var subject = Utilities.CleanString(portalSettings.PortalId, dto.Subject, false, EditorTypes.TEXTBOX, false, false, ActiveModule.ModuleID, string.Empty, false);
                        var replies = dto.Replies.Split('|');
                        var rc = new DotNetNuke.Modules.ActiveForums.DAL2.ReplyController();
                        var firstReply = rc.Get(Convert.ToInt32(replies[0]));
                        var cc = new ContentController();
                        var firstContent = cc.Get(firstReply.ContentId);
                        topicId = tc.Topic_QuickCreate(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId, subject, string.Empty, firstContent.AuthorId, firstContent.AuthorName, true, Request.GetIPAddress());
                        tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, true);
                    }
                    else
                    {
                        topicId = dto.NewTopicId;
                        tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, false);
                    }
                }
            }
            return Request.CreateResponse(HttpStatusCode.OK);
        }
Ejemplo n.º 3
0
        private void SetPermissions(int fId)
        {
            ForumController fc = new ForumController();
            Forum           f  = fc.GetForum(PortalId, ModuleId, fId);

            bModDelete  = false;
            bModApprove = false;
            bModEdit    = false;
            bModMove    = false;
            bCanMod     = false;
            if (f != null)
            {
                bModDelete  = Permissions.HasPerm(f.Security.ModDelete, ForumUser.UserRoles);
                bModApprove = Permissions.HasPerm(f.Security.ModApprove, ForumUser.UserRoles);
                bModMove    = Permissions.HasPerm(f.Security.ModMove, ForumUser.UserRoles);
                bModEdit    = Permissions.HasPerm(f.Security.ModEdit, ForumUser.UserRoles);
                if (bModDelete || bModApprove || bModMove || bModEdit)
                {
                    bCanMod = true;
                }
            }
        }
        private void LoadForum(int forumId)
        {
            var fc = new ForumController();
            var fi = fc.Forums_Get(forumId, -1, false, false);

            if (fi == null)
            {
                return;
            }

            var newForum = fc.GetForum(PortalId, ModuleId, forumId, true);

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

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

            txtForumName.Text = fi.ForumName;
            txtForumDesc.Text = fi.ForumDesc;
            chkActive.Checked = fi.Active;
            chkHidden.Checked = fi.Hidden;
            hidForumId.Value  = fi.ForumID.ToString();
            txtPrefixURL.Text = fi.PrefixURL;

            var groupValue = (fi.ParentForumId > 0) ? "FORUM" + fi.ParentForumId : "GROUP" + fi.ForumGroupId;


            Utilities.SelectListItemByValue(drpGroups, groupValue);

            if (fi.ForumSettingsKey == "G:" + fi.ForumGroupId)
            {
                chkInheritGroup.Checked = true;
                trTemplates.Attributes.Add("style", "display:none;");
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            chkTopicsOnly.Checked = fi.AutoSubscribeNewTopicsOnly;

            txtEditorHeight.Text = (fi.EditorHeight == string.Empty) ? "400" : fi.EditorHeight;
            txtEditorWidth.Text  = (fi.EditorWidth == string.Empty) ? "99%" : fi.EditorWidth;

            hidRoles.Value = fi.AutoSubscribeRoles;
            BindAutoSubRoles(fi.AutoSubscribeRoles);
        }
        private void LoadForum(int forumId)
        {
            var fc = new ForumController();
            var fi = fc.Forums_Get(forumId, -1, false, false);

            if (fi == null)
                return;

            var newForum = fc.GetForum(PortalId, ModuleId, forumId, true);

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

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

            txtForumName.Text = fi.ForumName;
            txtForumDesc.Text = fi.ForumDesc;
            chkActive.Checked = fi.Active;
            chkHidden.Checked = fi.Hidden;
            hidForumId.Value = fi.ForumID.ToString();
            txtPrefixURL.Text = fi.PrefixURL;

            var groupValue = (fi.ParentForumId > 0) ? "FORUM" + fi.ParentForumId : "GROUP" + fi.ForumGroupId;

            Utilities.SelectListItemByValue(drpGroups, groupValue);

            if (fi.ForumSettingsKey == "G:" + fi.ForumGroupId)
            {
                chkInheritGroup.Checked = true;
                trTemplates.Attributes.Add("style", "display:none;");
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            chkTopicsOnly.Checked = fi.AutoSubscribeNewTopicsOnly;

            Utilities.SelectListItemByValue(drpEditorTypes, fi.EditorType);
            if (Convert.ToInt32(fi.EditorType).ToString() != "1") // Active Editor should not be used anymore
            {
                txtEditorToolBar.Enabled = false;
                drpEditorStyle.Enabled = false;
            }

            Utilities.SelectListItemByValue(drpEditorStyle, fi.EditorStyle);
            Utilities.SelectListItemByValue(drpPermittedRoles, (int)fi.EditorPermittedUsers);

            txtEditorHeight.Text = (fi.EditorHeight == string.Empty) ? "400" : fi.EditorHeight;
            txtEditorWidth.Text = (fi.EditorWidth == string.Empty) ? "99%" : fi.EditorWidth;
            txtEditorToolBar.Text = (fi.EditorToolBar == string.Empty) ? "bold,italic,underline|bulletedlist,numberedlist" : fi.EditorToolBar;

            hidRoles.Value = fi.AutoSubscribeRoles;
            BindAutoSubRoles(fi.AutoSubscribeRoles);
        }
Ejemplo n.º 6
0
        private void SetPermissions(int fId)
        {
            ForumController fc = new ForumController();
            Forum f = fc.GetForum(PortalId, ModuleId, fId);
            bModDelete = false;
            bModApprove = false;
            bModEdit = false;
            bModMove = false;
            bCanMod = false;
            if (f != null)
            {
                bModDelete = Permissions.HasPerm(f.Security.ModDelete, ForumUser.UserRoles);
                bModApprove = Permissions.HasPerm(f.Security.ModApprove, ForumUser.UserRoles);
                bModMove = Permissions.HasPerm(f.Security.ModMove, ForumUser.UserRoles);
                bModEdit = Permissions.HasPerm(f.Security.ModEdit, ForumUser.UserRoles);
                if (bModDelete || bModApprove || bModMove || bModEdit)
                {
                    bCanMod = true;
                }

            }
        }