Esempio n. 1
0
        protected override void PageLoad()
        {
            Utility.RegisterTypeForAjax(typeof(AddBlog));

            if (SetupInfo.WorkMode == WorkMode.Promo)
            {
                Response.Redirect(ASC.Blogs.Core.Constants.DefaultPageUrl, true);
            }

            if (String.IsNullOrEmpty(BlogId))
            {
                Response.Redirect(ASC.Blogs.Core.Constants.DefaultPageUrl);
            }

            _mobileVer = ASC.Web.Core.Mobile.MobileDetector.IsRequestMatchesMobile(this.Context);

            var engine = BasePage.GetEngine();

            AjaxPro.Utility.RegisterTypeForAjax(typeof(EditBlog), this.Page);

            FCKeditor.BasePath      = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath);
            FCKeditor.ToolbarSet    = "BlogToolbar";
            FCKeditor.EditorAreaCSS = WebSkin.GetUserSkin().BaseCSSFileAbsoluteWebPath;

            FCKeditor.Visible = !_mobileVer;

            if (_mobileVer && IsPostBack)
            {
                _text = Request["mobiletext"];
            }

            mainContainer.BreadCrumbs.Add(new ASC.Web.Controls.BreadCrumb()
            {
                Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath)
            });
            mainContainer.BreadCrumbs.Add(new ASC.Web.Controls.BreadCrumb()
            {
                Caption = ASC.Blogs.Core.Resources.BlogsResource.EditPostTitle
            });

            this.Title = HeaderStringHelper.GetPageTitle(ASC.Blogs.Core.Resources.BlogsResource.AddonName, mainContainer.BreadCrumbs);


            InitSidePanel(engine, TagCloud);
            sideRecentActivity.TenantId  = TenantProvider.CurrentTenantID;
            sideRecentActivity.ProductId = Product.CommunityProduct.ID;
            sideRecentActivity.ModuleId  = ASC.Blogs.Core.Constants.ModuleID;

            base.InitSubscribers(actions);

            ShowForEdit(engine);

            lbCancel.Attributes["name"] = FCKeditor.ClientID;
            if (IsPostBack)
            {
                var control = FindControl(Request.Params["__EVENTTARGET"]);
                if (lbCancel.Equals(control))
                {
                    Response.Redirect(ASC.Blogs.Core.Constants.DefaultPageUrl);
                }
                else
                {
                    if (CheckTitle(txtTitle.Text))
                    {
                        var pageEngine = BasePage.GetEngine();
                        var post       = pageEngine.GetPostById(new Guid(hidBlogID.Value));
                        UpdatePost(post, engine);
                    }
                    else
                    {
                        mainContainer.Options.InfoMessageText = ASC.Blogs.Core.Resources.BlogsResource.BlogTitleEmptyMessage;
                        mainContainer.Options.InfoType        = ASC.Web.Controls.InfoType.Alert;
                    }
                }
            }
        }
        private List <SubscriptionObject> GetSubscriptionObjectsByType(Guid productID, Guid moduleID, Guid typeID)
        {
            var _engine = BasePage.GetEngine();

            var subscriptionObjects  = new List <SubscriptionObject>();
            var subscriptionProvider = _engine.NotifySource.GetSubscriptionProvider();

            if (typeID.Equals(_blogSubscriptionTypeID))
            {
                var list = new List <string>(
                    subscriptionProvider.GetSubscriptions(
                        Constants.NewPost,
                        _engine.NotifySource.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString()), false)
                    );

                if (list.Contains(null))
                {
                    subscriptionObjects.Add(new SubscriptionObject
                    {
                        ID               = new Guid(Constants._NewBlogSubscribeCategory).ToString(),
                        Name             = ASC.Blogs.Core.Resources.BlogsResource.SubscribeOnNewPostTitle,
                        URL              = string.Empty,
                        SubscriptionType = GetSubscriptionTypes().Find(st => st.ID.Equals(_blogSubscriptionTypeID))
                    });
                }
            }

            else if (typeID.Equals(_blogPersSubscriptionTypeID))
            {
                var list = new List <string>(
                    subscriptionProvider.GetSubscriptions(
                        Constants.NewPostByAuthor,
                        _engine.NotifySource.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString()), false)
                    );
                if (list.Count > 0)
                {
                    foreach (string id in list)
                    {
                        if (!string.IsNullOrEmpty(id))
                        {
                            subscriptionObjects.Add(new SubscriptionObject
                            {
                                ID               = id,
                                Name             = DisplayUserSettings.GetFullUserName(new Guid(id)),
                                URL              = VirtualPathUtility.ToAbsolute("~/Products/Community/Modules/Blogs/") + "?userid=" + id,
                                SubscriptionType = GetSubscriptionTypes().Find(st => st.ID.Equals(_blogPersSubscriptionTypeID))
                            });
                        }
                    }
                }
            }

            else if (typeID.Equals(_commentSubscriptionTypeID))
            {
                var list = new List <string>(
                    subscriptionProvider.GetSubscriptions(
                        Constants.NewComment,
                        _engine.NotifySource.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString()), false)
                    );

                if (list.Count > 0)
                {
                    IList <Post> postList = _engine.SelectPostsInfo(list.ConvertAll(s => new Guid(s)));

                    foreach (Post post in postList)
                    {
                        if (post != null)
                        {
                            subscriptionObjects.Add(new SubscriptionObject
                            {
                                ID               = post.ID.ToString(),
                                Name             = post.Title,
                                URL              = VirtualPathUtility.ToAbsolute("~/Products/Community/Modules/Blogs/ViewBlog.aspx") + "?blogid=" + post.ID.ToString(),
                                SubscriptionType = GetSubscriptionTypes().Find(st => st.ID.Equals(_commentSubscriptionTypeID))
                            });
                        }
                    }
                }
            }

            return(subscriptionObjects);
        }