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); }
private string RenderLastUpdateContent() { BlogsWidgetSettings widgetSettings = SettingsManager.Instance.LoadSettingsFor <BlogsWidgetSettings>(SecurityContext.CurrentAccount.ID); var engine = BasePage.GetEngine(); var posts = engine.SelectPosts( new PostsQuery() .SetCount(widgetSettings.MaxCountPosts) .NoTags() ); var posts_with_stat = engine.GetPostsCommentsCountAndNew(posts, SecurityContext.CurrentAccount.ID); StringBuilder sb = new StringBuilder(); //posts foreach (var entry in posts_with_stat) { Post post = entry.Value1; int commentsCount = entry.Value2; bool isNewComments = entry.Value3 > 0; sb.Append("<table cellpadding='0' cellspacing='0' border='0'>"); sb.Append("<tr valign='top'>"); sb.Append("<td width='30'>"); sb.Append("<span class='textMediumDescribe'>" + post.Datetime.ToShortDayMonth() + " " + post.Datetime.ToShortTimeString() + "</span>"); sb.Append("</td>"); sb.Append("<td>"); sb.Append("<div style='padding-left:10px;'>"); sb.Append("<div style='margin-bottom:5px;'>"); sb.Append("<a href='" + VirtualPathUtility.ToAbsolute("~/products/community/modules/blogs/viewblog.aspx") + "?blogid=" + post.ID + "'>" + post.Title.HtmlEncode() + "</a>"); if (commentsCount > 0) { if (isNewComments) { sb.AppendFormat("<span style='margin-left:7px;' class='errorText'>({0})</span>", commentsCount); } else { sb.AppendFormat("<span style='margin-left:7px;' class='describeText'>({0})</span>", commentsCount); } } sb.Append("</div>"); sb.Append("<div style='margin-bottom:5px;'>"); sb.Append(HtmlUtility.GetText(post.Content, 120)); sb.Append("</div>"); sb.Append("<div style='margin-bottom:17px;'>"); sb.Append("<span class='textBigDescribe'>" + ASC.Blogs.Core.Resources.BlogsResource.PostedTitle + ":</span> " + CoreContext.UserManager.GetUsers(post.UserID).RenderProfileLink(ASC.Web.Community.Product.CommunityProduct.ID)); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("</table>"); } if (posts_with_stat.Count > 0) { sb.AppendFormat("<div style='margin-top: 10px;'><a href='{0}'>{1}</a></div>", ASC.Blogs.Core.Constants.DefaultPageUrl, ASC.Blogs.Core.Resources.BlogsResource.AllBlogs ); } else { if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(CoreContext.UserManager.GetUsers( SecurityContext.CurrentAccount.ID)), ASC.Blogs.Core.Constants.Action_AddPost)) { sb.Append("<div class=\"empty-widget\" style=\"padding:40px; text-align: center;\">" + String.Format(ASC.Blogs.Core.Resources.BlogsResource.NoBlogsWidgetTitle, string.Format("<div style=\"padding-top:3px;\"><a class=\"promoAction\" href=\"{0}\">", VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath + "addblog.aspx")), "</a></div>") + "</div>"); } else { sb.Append("<div class==\"empty-widget\" style=\"padding:40px; text-align: center;\">" + ASC.Blogs.Core.Resources.BlogsResource.NoBlogsWidgetMessage + "</div>"); } } return(sb.ToString()); }
private long GetPostCount(Guid userID) { return(BasePage.GetEngine().GetPostCountByAuthor(userID)); }
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; } } } }