public Comment UpdateComment(Comment comment) { var toUpdate = GetComment(comment.Id); if (toUpdate == null) { throw new ItemNotFoundException("comment not found"); } if (String.IsNullOrEmpty(comment.Body)) { throw new ArgumentException(@"comment content cannot be empty", "comment"); } CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(comment), ASC.Web.Community.Wiki.Common.Constants.Action_EditRemoveComment); toUpdate.Body = comment.Body; toUpdate.UserId = SecurityContext.CurrentAccount.ID; toUpdate.Date = TenantUtil.DateTimeNow(); return(SaveComment(toUpdate)); }
protected void cmdDelete_Click(object sender, EventArgs e) { try { var pageName = ((LinkButton)sender).CommandName; var page = Wiki.GetPage(pageName); CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(page), Common.Constants.Action_RemovePage); foreach (var comment in Wiki.GetComments(pageName)) { CommonControlsConfigurer.FCKUploadsRemoveForItem("wiki_comments", comment.Id.ToString()); } Wiki.RemovePage(pageName); BindRepeater(); } catch (Exception err) { WikiMaster.PrintInfoMessage(err.Message, InfoType.Warning); } }
private void ShowForEdit(BlogsEngine engine) { if (!IsPostBack) { var post = engine.GetPostById(new Guid(BlogId)); InitPreviewTemplate(post); if (post != null && CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost)) { hdnUserID.Value = post.UserID.ToString(); if (Request.QueryString["action"] == "delete") { foreach (var comment in engine.GetPostComments(post.ID)) { CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs_comments", comment.ID.ToString()); } engine.DeletePost(post); CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs", post.ID.ToString()); Response.Redirect(Constants.DefaultPageUrl); return; } else { txtTitle.Text = Server.HtmlDecode(post.Title); _text = post.Content; hidBlogID.Value = post.ID.ToString(); LoadTags(post.TagList); } } else { Response.Redirect(Constants.DefaultPageUrl); return; } } }
public EventWrapperFull CreateEvent(string content, string title, FeedType type) { CommunitySecurity.DemandPermissions(NewsConst.Action_Add); if (string.IsNullOrWhiteSpace(title)) { throw new ArgumentException("Can't create feed with empty title", "title"); } var feed = new Feed { Caption = title, Text = content, Creator = SecurityContext.CurrentAccount.ID.ToString(), Date = DateTime.UtcNow, FeedType = type }; FeedStorage.SaveFeed(feed, false, type); return(new EventWrapperFull(feed)); }
public string CreateEvent(string name, string description, string dateTime) { CommunitySecurity.DemandPermissions(PhotoConst.Action_AddEvent); var storage = StorageFactory.GetStorage(); DateTime date; DateTime.TryParse(dateTime, out date); var item = new Event { Name = GetLimitedText(name), Description = GetLimitedText(description), Timestamp = date, UserID = SecurityContext.CurrentAccount.ID.ToString() }; storage.SaveEvent(item); return("<option value=\"" + item.Id.ToString() + "\" onclick=\"javascript:PhotoManager.LoadEvent(" + item.Id.ToString() + ");\">" + HttpUtility.HtmlEncode(item.Name) + "</option>"); }
public string RemoveComment(string commentID, string pid) { AjaxResponse resp = new AjaxResponse(); resp.rs1 = commentID; Guid?id = null; try { if (!String.IsNullOrEmpty(commentID)) { id = new Guid(commentID); } } catch { return(commentID); } BlogsEngine engine = BasePage.GetEngine(); var comment = engine.GetCommentById(id.Value); if (comment == null) { throw new ApplicationException("Comment not found"); } CommunitySecurity.DemandPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment); comment.Inactive = true; var post = engine.GetPostById(comment.PostId); engine.RemoveComment(comment, post); return(commentID); }
private void UpdateEditDeleteVisible(IWikiObjectOwner obj) { var canDelete = false; var editVisible = Action.Equals(ActionOnPage.View) || Action.Equals(ActionOnPage.CategoryView); if (obj != null) { var secObj = new WikiObjectsSecurityObject(obj); canDelete = CommunitySecurity.CheckPermissions(secObj, Common.Constants.Action_RemovePage) && !string.IsNullOrEmpty(obj.GetObjectId().ToString()); } pEditButtons.Visible = !editVisible; //hlEditPage.Visible = editVisible && canEdit; if (Version > 0 && (Action.Equals(ActionOnPage.View) || Action.Equals(ActionOnPage.CategoryView))) { //hlEditPage.Visible = pEditButtons.Visible = false; } cmdDelete.Visible = editVisible && canDelete; litVersionSeparatorDel.Visible = cmdDelete.Visible; }
private void LoadUserAllPhoto(string userID, Data.Storage.IDataStore store) { mainContainer.BreadCrumbs.Add(new Web.Controls.BreadCrumb { Caption = PhotoManagerResource.PhotoTitle, NavigationUrl = PhotoConst.PAGE_DEFAULT }); mainContainer.BreadCrumbs.Add(new Web.Controls.BreadCrumb { Caption = DisplayUserSettings.GetFullUserName(new Guid(userID), false) }); var list = StorageFactory.GetStorage().GetAlbums(0, userID); if (list == null || list.Count == 0) { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_photo_icon.png", PhotoConst.ModuleID), Describe = PhotoManagerResource.EmptyScreenText }; if (userID == SecurityContext.CurrentAccount.ID.ToString()) { emptyScreenControl.Header = PhotoManagerResource.YouHaveNoPhotosTitle; emptyScreenControl.ButtonHTML = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddPhoto) ? String.Format("<a class='linkAddMediumText' href='" + PhotoConst.PAGE_ADD_PHOTO + "'>{0}</a>", PhotoManagerResource.EmptyScreenLink) : String.Empty; } else { emptyScreenControl.Header = PhotoManagerResource.UserHaveNoPhotosTitle; } _contentHolder.Controls.Add(emptyScreenControl); } else { _contentHolder.Controls.Add(new Literal { Text = ImageHTMLHelper.DrawAlbumsAlone(list, store) }); } }
private static void ConfigureCommentsList(CommentsList commentList, AlbumItem image) { CommonControlsConfigurer.CommentsConfigure(commentList); commentList.IsShowAddCommentBtn = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment); commentList.Simple = Core.Mobile.MobileDetector.IsRequestMatchesMobile(HttpContext.Current); var count = image != null ? image.CommentsCount : 0; commentList.CommentsCountTitle = count.ToString(); commentList.ObjectID = image != null?image.Id.ToString() : ""; commentList.BehaviorID = "commentsObj"; commentList.TotalCount = count; commentList.JavaScriptAddCommentFunctionName = "PhotoDetails.AddComment"; commentList.JavaScriptLoadBBcodeCommentFunctionName = "PhotoDetails.LoadCommentText"; commentList.JavaScriptPreviewCommentFunctionName = "PhotoDetails.GetPreview"; commentList.JavaScriptRemoveCommentFunctionName = "PhotoDetails.RemoveComment"; commentList.JavaScriptUpdateCommentFunctionName = "PhotoDetails.UpdateComment"; commentList.FckDomainName = "photomanager_comments"; }
public string GetBookmarkRaiting(Bookmark b, string divID) { if (CommunitySecurity.IsOutsider()) { return(string.Empty); } StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) { using (HtmlTextWriter textWriter = new HtmlTextWriter(sw)) { using (var c = LoadControl(BookmarkUserControlPath.BookmarkRaitingUserControlPath) as BookmarkRaitingUserControl) { c.Bookmark = b; c.DivId = divID; c.RenderControl(textWriter); } } } return(sb.ToString()); }
protected void cmdDelete_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(WikiPage) || IsFile) { return; } var pageName = PageNameUtil.Decode(WikiPage); var page = Wiki.GetPage(pageName); CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(page), Common.Constants.Action_RemovePage); foreach (var cat in Wiki.GetCategoriesRemovedWithPage(pageName)) { WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.AddPageToCat, cat.CategoryName); } Wiki.RemoveCategories(pageName); WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.EditPage, pageName); foreach (var comment in Wiki.GetComments(pageName)) { CommonControlsConfigurer.FCKUploadsRemoveForItem("wiki_comments", comment.Id.ToString()); } Wiki.RemovePage(pageName); FactoryIndexer <WikiWrapper> .DeleteAsync(page); Response.RedirectLC("Default.aspx", this); } catch (Exception err) { WikiMaster.PrintInfoMessage(err.Message, InfoType.Alert); } }
public EventWrapperFull UpdateEvent(int feedid, string content, string title, FeedType type) { var feed = FeedStorage.GetFeed(feedid).NotFoundIfNull(); CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit); if (string.IsNullOrWhiteSpace(title)) { throw new ArgumentException("Can't update feed with empty title", "title"); } if (type != FeedType.News && type != FeedType.Order && type != FeedType.Advert && type != FeedType.Poll) { throw new ArgumentOutOfRangeException(string.Format("Unknown feed type: {0}.", type)); } feed.Caption = title; feed.Text = content; feed.Creator = SecurityContext.CurrentAccount.ID.ToString(); FeedStorage.SaveFeed(feed, true, type); return(new EventWrapperFull(feed)); }
public string GetBookmarkRaiting(Bookmark b) { if (CommunitySecurity.IsOutsider()) { return(string.Empty); } StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) { using (HtmlTextWriter textWriter = new HtmlTextWriter(sw)) { using (var c = LoadControl(BookmarkUserControlPath.BookmarkRaitingUserControlPath) as BookmarkRaitingUserControl) { c.SimpleModeRaiting = ServiceHelper.GetUserBookmarksCount(b); c.SimpleMode = true; c.Bookmark = b; c.RenderControl(textWriter); } } } return(sb.ToString()); }
protected void Page_Load(object sender, EventArgs e) { WikiPageName = PrintPageName; (Master as WikiMaster).GetDelUniqId += new WikiMaster.GetDelUniqIdHandle(_Default_GetDelUniqId); Utility.RegisterTypeForAjax(typeof(_Default), Page); RegisterInlineScript(); LoadViews(); if (IsPostBack) { return; } if (IsFile) { Response.RedirectLC(string.Format(WikiSection.Section.ImageHangler.UrlFormat, WikiPage, TenantId), this); } pCredits.Visible = Action.Equals(ActionOnPage.View) || Action.Equals(ActionOnPage.CategoryView); CheckSpetialSymbols(); wikiEditPage.mainPath = this.ResolveUrlLC("Default.aspx"); InitEditsLink(); var mainStudioCss = WebSkin.BaseCSSFileAbsoluteWebPath; wikiEditPage.CanUploadFiles = CommunitySecurity.CheckPermissions(Common.Constants.Action_UploadFile); wikiEditPage.MainCssFile = mainStudioCss; if (Action == ActionOnPage.CategoryView) { BindPagesByCategory(); } }
public string RemoveEvent(long id) { var storage = StorageFactory.GetStorage(); var Event = storage.GetEvent(id); CommunitySecurity.DemandPermissions(Event, PhotoConst.Action_EditRemoveEvent); var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"); foreach (var album in storage.GetAlbums(id, null)) { var pathAlbum = PhotoConst.ImagesPath + album.UserID + "/" + album.Id + "/"; store.DeleteFiles(pathAlbum, "*", false); } var _storage = StorageFactory.GetStorage(); var subscriptionProvider = _storage.NotifySource.GetSubscriptionProvider(); subscriptionProvider.UnSubscribe(PhotoConst.NewEventComment, id.ToString()); storage.RemoveEvent(Event.Id); return(id.ToString()); //RenderEvents(); }
protected void Page_Load(object sender, EventArgs e) { if (SetupInfo.WorkMode == WorkMode.Promo) { Response.Redirect(FeedUrls.MainPageUrl, true); } if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add)) { Response.Redirect(FeedUrls.MainPageUrl, true); } Breadcrumb.Add(new BreadCrumb() { Caption = NewsResource.NewsBreadCrumbs, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") }); if (Info.HasUser) { Breadcrumb.Add(new BreadCrumb() { Caption = Info.User.DisplayUserName(false), NavigationUrl = string.Format(CultureInfo.CurrentCulture, "{0}?uid={1}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), Info.UserId) }); } var storage = FeedStorageFactory.Create(); Feed feed = null; long docID = 0; if (!string.IsNullOrEmpty(Request["docID"]) && long.TryParse(Request["docID"], out docID)) { feed = storage.GetFeed(docID); } if (!IsPostBack) { _errorMessage.Text = ""; if (feed != null) { if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit)) { Response.Redirect(FeedUrls.MainPageUrl, true); } FeedId = docID; FeedPoll pollFeed = feed as FeedPoll; if (pollFeed != null) { _pollMaster.QuestionFieldID = "feedName"; var question = pollFeed; _pollMaster.Singleton = (question.PollType == FeedPollType.SimpleAnswer); _pollMaster.Name = feed.Caption; _pollMaster.ID = question.Id.ToString(CultureInfo.CurrentCulture); foreach (var variant in question.Variants) { _pollMaster.AnswerVariants.Add(new ASC.Web.Controls.PollFormMaster.AnswerViarint() { ID = variant.ID.ToString(CultureInfo.CurrentCulture), Name = variant.Name }); } } } else { _pollMaster.QuestionFieldID = "feedName"; } } else { SaveFeed(); } if (feed != null) { Breadcrumb.Add(new BreadCrumb() { Caption = feed.Caption, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + "?docid=" + docID + Info.UserIdAttribute }); Breadcrumb.Add(new BreadCrumb() { Caption = NewsResource.NewsEditBreadCrumbsPoll, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/editpoll.aspx") + "?docid=" + docID + Info.UserIdAttribute }); lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + "?docid=" + docID + Info.UserIdAttribute; } else { Breadcrumb.Add(new BreadCrumb() { Caption = NewsResource.NewsAddBreadCrumbsPoll, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/editpoll.aspx") + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1)) }); lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1)); } this.Title = HeaderStringHelper.GetPageTitle(Resources.NewsResource.AddonName, Breadcrumb); }
private void ValidateAccessHandler(object sender, SecurityAccessEventArgs e) { ISecurityObject securityObject = null; if (e.TargetObject is ISecurityObject) { securityObject = (ISecurityObject)e.TargetObject; } switch (e.Action) { case ForumAction.ReadPosts: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.ReadPostsAction); break; case ForumAction.PostCreate: Topic topic = (Topic)e.TargetObject; if (CommunitySecurity.CheckPermissions(topic, Constants.PostCreateAction)) { if (!topic.Closed) { _view.IsAccessible = true; } else if (topic.Closed && CommunitySecurity.CheckPermissions(topic, Constants.TopicCloseAction)) { _view.IsAccessible = true; } else { _view.IsAccessible = false; } } else { _view.IsAccessible = false; } break; case ForumAction.ApprovePost: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.PostApproveAction); break; case ForumAction.PostEdit: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.PostEditAction); break; case ForumAction.PostDelete: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.PostDeleteAction); break; case ForumAction.TopicCreate: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.TopicCreateAction); break; case ForumAction.PollCreate: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.PollCreateAction); break; case ForumAction.TopicClose: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.TopicCloseAction); break; case ForumAction.TopicSticky: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.TopicStickyAction); break; case ForumAction.TopicEdit: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.TopicEditAction); break; case ForumAction.TopicDelete: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.TopicDeleteAction); break; case ForumAction.PollVote: Question question = (Question)e.TargetObject; _view.IsAccessible = CommunitySecurity.CheckPermissions(new Topic() { ID = question.TopicID }, Constants.PollVoteAction); break; case ForumAction.TagCreate: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.TagCreateAction); break; case ForumAction.AttachmentCreate: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.AttachmentCreateAction); break; case ForumAction.AttachmentDelete: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.AttachmentDeleteAction); break; case ForumAction.GetAccessForumEditor: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.ForumManagementAction); break; case ForumAction.GetAccessTagEditor: _view.IsAccessible = CommunitySecurity.CheckPermissions(securityObject, Constants.TagManagementAction); break; } }
protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(GetType()); if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add)) { Response.Redirect(FeedUrls.MainPageUrl, true); } var storage = FeedStorageFactory.Create(); FeedNS.Feed feed = null; if (!string.IsNullOrEmpty(Request["docID"])) { long docID; if (long.TryParse(Request["docID"], out docID)) { feed = storage.GetFeed(docID); PageTitle = NewsResource.NewsEditBreadCrumbsNews; Title = HeaderStringHelper.GetPageTitle(PageTitle); _text = (feed != null ? feed.Text : "").HtmlEncode(); } } else { _text = ""; PageTitle = NewsResource.NewsAddBreadCrumbsNews; Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsAddBreadCrumbsNews); } if (!IsPostBack) { BindNewsTypes(); if (feed != null) { if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit)) { Response.Redirect(FeedUrls.MainPageUrl, true); } feedName.Text = feed.Caption; _text = feed.Text; FeedId = feed.Id; feedType.SelectedIndex = (int)Math.Log((int)feed.FeedType, 2); } else { if (!string.IsNullOrEmpty(Request["type"])) { var requestFeedType = (FeedType)Enum.Parse(typeof(FeedType), Request["type"], true); var feedTypeInfo = FeedTypeInfo.FromFeedType(requestFeedType); var item = feedType.Items.FindByText(feedTypeInfo.TypeName); feedType.SelectedValue = item.Value; feedType.SelectedIndex = (int)Math.Log((int)requestFeedType, 2); } } } else { var control = FindControl(Request.Params["__EVENTTARGET"]); if (lbCancel.Equals(control)) { CancelFeed(sender, e); } else { SaveFeed(); } } RenderScripts(); }
protected void Page_Load(object sender, EventArgs e) { WikiPageName = PrintPageName; (Master as WikiMaster).GetDelUniqId += new WikiMaster.GetDelUniqIdHandle(_Default_GetDelUniqId); Utility.RegisterTypeForAjax(typeof(_Default), Page); LoadViews(); if (IsPostBack) { return; } if (IsFile) { Response.RedirectLC(string.Format(WikiSection.Section.ImageHangler.UrlFormat, WikiPage, TenantId), this); } pCredits.Visible = Action.Equals(ActionOnPage.View) || Action.Equals(ActionOnPage.CategoryView); commentList.FCKBasePath = CommonControlsConfigurer.FCKEditorBasePath; CheckSpetialSymbols(); wikiEditPage.mainPath = this.ResolveUrlLC("Default.aspx"); InitEditsLink(); var mainStudioCss = WebSkin.BaseCSSFileAbsoluteWebPath; wikiEditPage.CanUploadFiles = CommunitySecurity.CheckPermissions(Common.Constants.Action_UploadFile) && !MobileDetector.IsMobile; wikiEditPage.MainCssFile = mainStudioCss; if (Action == ActionOnPage.CategoryView) { BindPagesByCategory(); } var script = @" window.scrollPreview = function() { jq.scrollTo(jq('#_PrevContainer').position().top, { speed: 500 }); } window.HidePreview = function() { jq('#_PrevContainer').hide(); jq.scrollTo(jq('#edit_container').position().top, { speed: 500 }); } window.WikiEditBtns = function() { LoadingBanner.showLoaderBtn('#actionWikiPage'); } window.panelEditBtnsID = '" + pEditButtons.ClientID + @"'; jq.dropdownToggle({ dropdownID: 'WikiActionsMenuPanel', switcherSelector: '.WikiHeaderBlock .menu-small', addTop: -4, addLeft: -11, showFunction: function (switcherObj, dropdownItem) { jq('.WikiHeaderBlock .menu-small.active').removeClass('active'); if (dropdownItem.is(':hidden')) { switcherObj.addClass('active'); } }, hideFunction: function () { jq('.WikiHeaderBlock .menu-small.active').removeClass('active'); } }); if (jq('#WikiActionsMenuPanel .dropdown-content a').length == 0) { jq('span.menu-small').hide(); }"; Page.RegisterInlineScript(script); }
public void SavePost(Post post, bool isNew, bool notifyComments) { CommunitySecurity.DemandPermissions( new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(post.UserID)), isNew ? Constants.Action_AddPost : Constants.Action_EditRemovePost); _storage.GetPostDao().SavePost(post); if (isNew) { var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(post.UserID.ToString(), "")); try { NotifyClient.BeginSingleRecipientEvent("asc_blog"); NotifyClient.AddInterceptor(initiatorInterceptor); var tags = new List <ITagValue> { new TagValue(Constants.TagPostSubject, post.Title), new TagValue(Constants.TagPostPreview, post.GetPreviewText(500)), new TagValue(Constants.TagUserName, DisplayUserSettings.GetFullUserName(post.UserID)), new TagValue(Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath( CommonLinkUtility.GetUserProfile(post.UserID))), new TagValue(Constants.TagDate, string.Format("{0:d} {0:t}", post.Datetime)), new TagValue(Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath( Constants.ViewBlogPageUrl + "?blogid=" + post.ID.ToString())), GetReplyToTag(Guid.Empty, post) }; NotifyClient.SendNoticeAsync( Constants.NewPost, null, null, tags.ToArray()); NotifyClient.SendNoticeAsync( Constants.NewPostByAuthor, post.UserID.ToString(), null, tags.ToArray()); NotifyClient.EndSingleRecipientEvent("asc_blog"); } finally { NotifyClient.RemoveInterceptor(initiatorInterceptor.Name); } } if (!notifyComments) { return; } var subscriptionProvider = NotifySource.GetSubscriptionProvider(); subscriptionProvider.Subscribe( Constants.NewComment, post.ID.ToString(), NotifySource.GetRecipientsProvider(). GetRecipient(post.UserID.ToString()) ); }
private static bool CanEdit() { return(CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID)), ASC.Blogs.Core.Constants.Action_AddPost)); }
protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(Default), Page); commentList.Visible = CommunitySecurity.CheckPermissions(NewsConst.Action_Comment); pgNavigator.EntryCount = 1; pgNavigator.EntryCountOnPage = 1; if (IsPostBack) { return; } var storage = FeedStorageFactory.Create(); if (!string.IsNullOrEmpty(Request["docID"])) { long docID; if (long.TryParse(Request["docID"], out docID)) { //Show panel ContentView.Visible = false; FeedView.Visible = true; var feed = storage.GetFeed(docID); if (feed != null) { if (!feed.Readed) { storage.ReadFeed(feed.Id, SecurityContext.CurrentAccount.ID.ToString()); } FeedViewCtrl.Feed = feed; hdnField.Value = feed.Id.ToString(CultureInfo.CurrentCulture); InitCommentsView(storage, feed); FeedView.DataBind(); EventTitle = feed.Caption; var subscriptionProvider = NewsNotifySource.Instance.GetSubscriptionProvider(); var amAsRecipient = (IDirectRecipient)NewsNotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString()); var isSubsribedOnComments = subscriptionProvider.IsSubscribed(NewsConst.NewComment, amAsRecipient, feed.Id.ToString()); var SubscribeTopicLink = string.Format(CultureInfo.CurrentCulture, string.Format(CultureInfo.CurrentCulture, "<a id=\"statusSubscribe\" class=\"follow-status " + (isSubsribedOnComments ? "subscribed" : "unsubscribed") + "\" title=\"{0}\" href=\"#\" onclick=\"SubscribeOnComments('{1}');\"></a>", (isSubsribedOnComments ? NewsResource.UnsubscribeFromNewComments : NewsResource.SubscribeOnNewComments), feed.Id)); SubscribeLinkBlock.Text = SubscribeTopicLink; Title = HeaderStringHelper.GetPageTitle((Master as NewsMaster).CurrentPageCaption ?? feed.Caption); } else { Response.Redirect(VirtualPathUtility.ToAbsolute("~/products/community/modules/news/")); ContentView.Visible = true; FeedView.Visible = false; FeedRepeater.Visible = true; } } } else { PageNumber = string.IsNullOrEmpty(Request["page"]) ? 1 : Convert.ToInt32(Request["page"]); PageSize = string.IsNullOrEmpty(Request["size"]) ? 20 : Convert.ToInt32(Request["size"]); LoadData(); } InitScripts(); }
private void LoadData() { var storage = FeedStorageFactory.Create(); var feedType = FeedType.All; if (!string.IsNullOrEmpty(Request["type"])) { feedType = (FeedType)Enum.Parse(typeof(FeedType), Request["type"], true); var feedTypeInfo = FeedTypeInfo.FromFeedType(feedType); Title = HeaderStringHelper.GetPageTitle((Master as NewsMaster).CurrentPageCaption ?? feedTypeInfo.TypeName); } else { Title = HeaderStringHelper.GetPageTitle((Master as NewsMaster).CurrentPageCaption ?? NewsResource.NewsBreadCrumbs); } var feedsCount = !string.IsNullOrEmpty(Request["search"]) ? storage.SearchFeedsCount(Request["search"], feedType, Info.UserId) : storage.GetFeedsCount(feedType, Info.UserId); FeedsCount = feedsCount; if (feedsCount == 0) { FeedRepeater.Visible = false; MessageShow.Visible = true; string buttonLink; string buttonName; var emptyScreenControl = new EmptyScreenControl { Describe = NewsResource.EmptyScreenText }; switch (feedType) { case FeedType.News: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_news.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenNewsCaption; buttonLink = FeedUrls.EditNewsUrl; buttonName = NewsResource.EmptyScreenNewsLink; break; case FeedType.Order: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_order.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenOrdersCaption; buttonLink = FeedUrls.EditOrderUrl; buttonName = NewsResource.EmptyScreenOrderLink; break; case FeedType.Advert: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_advert.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenAdvertsCaption; buttonLink = FeedUrls.EditAdvertUrl; buttonName = NewsResource.EmptyScreenAdvertLink; break; case FeedType.Poll: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_poll.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenPollsCaption; buttonLink = FeedUrls.EditPollUrl; buttonName = NewsResource.EmptyScreenPollLink; break; default: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_newslogo.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenEventsCaption; buttonLink = FeedUrls.EditNewsUrl; buttonName = NewsResource.EmptyScreenEventLink; break; } if (CommunitySecurity.CheckPermissions(NewsConst.Action_Add) && String.IsNullOrEmpty(Request["uid"]) && String.IsNullOrEmpty(Request["search"])) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='{0}'>{1}</a>", buttonLink, buttonName); } MessageShow.Controls.Add(emptyScreenControl); } else { var pageSize = PageSize; var pageCount = (int)(feedsCount / pageSize + 1); if (pageCount < PageNumber) { PageNumber = pageCount; } var feeds = !string.IsNullOrEmpty(Request["search"]) ? storage.SearchFeeds(Request["search"], feedType, Info.UserId, pageSize, (PageNumber - 1) * pageSize) : storage.GetFeeds(feedType, Info.UserId, pageSize, (PageNumber - 1) * pageSize); pgNavigator.EntryCountOnPage = pageSize; pgNavigator.EntryCount = 0 < pageCount ? (int)feedsCount : pageSize; pgNavigator.CurrentPageNumber = PageNumber; pgNavigator.ParamName = "page"; if (!string.IsNullOrEmpty(Request["search"])) { pgNavigator.PageUrl = string.Format( CultureInfo.CurrentCulture, "{0}?search={1}&size={2}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), Request["search"], pageSize ); } else { pgNavigator.PageUrl = string.IsNullOrEmpty(Request["type"]) ? string.Format( CultureInfo.CurrentCulture, "{0}?{1}&size={2}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1)), pageSize ) : string.Format( CultureInfo.CurrentCulture, "{0}?type={1}{2}&size={3}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), Request["type"], Info.UserIdAttribute, pageSize); } FeedRepeater.DataSource = feeds; FeedRepeater.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { IsAdmin = CommunitySecurity.IsAdministrator(); IsAuthor = Author.Equals(SecurityContext.CurrentAccount.ID); }
private void BindRepeater() { phListResult.Visible = phTableResult.Visible = false; if (isByUser || isShowNew || isShowFresh) { phListResult.Visible = true; List <Page> dataSource; var emptyScreenCaption = string.Empty; var emptyScreenText = string.Empty; if (isByUser) { dataSource = Wiki.GetPages(byUserID); } else if (isShowNew) { dataSource = Wiki.GetNewPages(MaxNewResults); emptyScreenCaption = WikiResource.EmptyScreenWikiNewPagesCaption; emptyScreenText = WikiResource.EmptyScreenWikiNewPagesText; } else { dataSource = Wiki.GetRecentEditedPages(MaxNewResults); emptyScreenCaption = WikiResource.EmptyScreenWikiRecentlyEditedCaption; emptyScreenText = WikiResource.EmptyScreenWikiRecentlyEditedText; } //foreach (Pages p in dataSource) //{ // p.PageName = HttpUtility.HtmlEncode(p.PageName); //} if (dataSource.Count > 0) { rptPageList.DataSource = dataSource; rptPageList.DataBind(); } else { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("WikiLogo150.png", WikiManager.ModuleId), Header = emptyScreenCaption, Describe = emptyScreenText }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } phListResult.Controls.Add(emptyScreenControl); } } else { phTableResult.Visible = true; List <Page> result; result = isShowCat ? Wiki.GetPages(categoryName) : Wiki.GetPages(); result.RemoveAll(pemp => string.IsNullOrEmpty(pemp.PageName)); var letters = new List <string>(WikiResource.wikiCategoryAlfaList.Split(',')); var otherSymbol = string.Empty; if (letters.Count > 0) { otherSymbol = letters[0]; letters.Remove(otherSymbol); } var dictList = new List <PageDictionary>(); foreach (var page in result) { page.PageName = HttpUtility.HtmlEncode(page.PageName); var firstLetter = new string(page.PageName[0], 1); if (!letters.Exists(lt => lt.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { firstLetter = otherSymbol; } PageDictionary pageDic; if (!dictList.Exists(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { pageDic = new PageDictionary { HeadName = firstLetter }; pageDic.Pages.Add(page); dictList.Add(pageDic); } else { pageDic = dictList.Find(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase)); pageDic.Pages.Add(page); } } dictList.Sort(SortPageDict); var countAll = dictList.Count * 3 + result.Count; //1 letter is like 2 links to category var perColumn = (int)(Math.Round((decimal)countAll / 3)); var mainDictList = new List <List <PageDictionary> >(); int index = 0, lastIndex = 0, count = 0; for (int i = 0; i < dictList.Count; i++) { var p = dictList[i]; count += 3; count += p.Pages.Count; index++; if (count >= perColumn || i == dictList.Count - 1) { count = count - perColumn; mainDictList.Add(dictList.GetRange(lastIndex, index - lastIndex)); lastIndex = index; } } if (mainDictList.Count > 0) { rptMainPageList.DataSource = mainDictList; rptMainPageList.DataBind(); } else { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("WikiLogo150.png", WikiManager.ModuleId), Header = WikiResource.EmptyScreenWikiIndexCaption, Describe = WikiResource.EmptyScreenWikiIndexText }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } phTableResult.Controls.Add(emptyScreenControl); } } }
public static bool PermissionCheckEditComment() { return(CommunitySecurity.CheckPermissions(BookmarkingBusinessConstants.BookmarkEditCommentAction)); }
protected bool CanDeleteTheFile(IWikiObjectOwner owner) { return(CommunitySecurity.CheckPermissions(new WikiObjectsSecurityObject(owner), Community.Wiki.Common.Constants.Action_RemoveFile)); }
public static bool PermissionCheckEditComment(Comment c) { return(CommunitySecurity.CheckPermissions(new BookmarkPermissionSecurityObject(c.UserID, c.ID), BookmarkingBusinessConstants.BookmarkEditCommentAction)); }
protected void InitPageActionPanel() { var sb = new StringBuilder(); var canEdit = false; var canDelete = false; var subscribed = false; if (_wikiObjOwner != null) { var secObj = new WikiObjectsSecurityObject(_wikiObjOwner); canEdit = CommunitySecurity.CheckPermissions(secObj, Common.Constants.Action_EditPage); canDelete = CommunitySecurity.CheckPermissions(secObj, Common.Constants.Action_RemovePage) && !string.IsNullOrEmpty(_wikiObjOwner.GetObjectId().ToString()); } if (SecurityContext.IsAuthenticated && (Action.Equals(ActionOnPage.CategoryView) || Action.Equals(ActionOnPage.View))) { var subscriptionProvider = WikiNotifySource.Instance.GetSubscriptionProvider(); var userList = new List <string>(); var IAmAsRecipient = (IDirectRecipient)WikiNotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString()); if (IAmAsRecipient != null) { userList = new List <string>( subscriptionProvider.GetSubscriptions( Community.Wiki.Common.Constants.EditPage, IAmAsRecipient) ); } var pageName = WikiPage ?? string.Empty; subscribed = userList.Exists(s => string.Compare(s, pageName, StringComparison.InvariantCultureIgnoreCase) == 0 || (s == null && string.Empty.Equals(pageName))); var SubscribeTopicLink = string.Format(CultureInfo.CurrentCulture, string.Format(CultureInfo.CurrentCulture, "<a id=\"statusSubscribe\" class=\"follow-status " + (subscribed ? "subscribed" : "unsubscribed") + "\" title=\"{0}\" href=\"#\"></a>", !subscribed ? WikiResource.NotifyOnEditPage : WikiResource.UnNotifyOnEditPage)); SubscribeLinkBlock.Text = SubscribeTopicLink; } var delURL = string.Format(@"javascript:if(confirm('{0}')) __doPostBack('{1}', '');", WikiResource.cfmDeletePage, _Default_GetDelUniqId()); sb.Append("<div id=\"WikiActionsMenuPanel\" class=\"studio-action-panel\">"); sb.Append("<div class=\"corner-top left\"></div>"); sb.Append("<ul class=\"dropdown-content\">"); sb.AppendFormat("<li><a class=\"dropdown-item\" href=\"{0}\">{1}</a></li>", ActionHelper.GetViewPagePath(this.ResolveUrlLC("pagehistorylist.aspx"), WikiPage), WikiResource.menu_ShowVersions); sb.AppendFormat("<li><a class=\"dropdown-item\" href=\"javascript:window.print();\">{0}</a></li>", WikiResource.menu_PrintThePage); if (canEdit) { sb.AppendFormat("<li><a class=\"dropdown-item\" href=\"{0}\">{1}</a></li>", ActionHelper.GetEditPagePath(this.ResolveUrlLC("default.aspx"), WikiPage), WikiResource.menu_EditThePage); } if (canDelete) { sb.AppendFormat("<li><a class=\"dropdown-item\" href=\"{0}\">{1}</a></li>", delURL, WikiResource.menu_DeleteThePage); } sb.Append("</ul>"); sb.Append("</div>"); ActionPanel.Text = sb.ToString(); sb = new StringBuilder(); sb.AppendLine("var notyfy = " + subscribed.ToString().ToLower(CultureInfo.CurrentCulture) + ";"); sb.AppendLine("var pageId = \"" + HttpUtility.HtmlEncode((Page as WikiBasePage).WikiPage).EscapeString() + "\";"); sb.AppendLine("jq(\"#statusSubscribe\").on(\"click\", function(){"); sb.AppendLine("AjaxPro.onLoading = function(b) {"); sb.AppendLine("if(b) jq(\".WikiHeaderBlock\").block();"); sb.AppendLine("else jq(\".WikiHeaderBlock\").unblock();"); sb.AppendLine("}"); sb.AppendLine("MainWikiAjaxMaster.SubscribeOnEditPage(notyfy, pageId, callbackNotifyWikiPage);"); sb.AppendLine("});"); sb.AppendLine("function callbackNotifyWikiPage(result){notyfy = result.value;"); sb.AppendLine("if(!notyfy){"); sb.AppendLine("jq(\"#statusSubscribe\").removeClass(\"subscribed\").addClass(\"unsubscribed\");"); sb.AppendFormat("jq(\"#statusSubscribe\").attr(\"title\", \"{0}\");", WikiResource.NotifyOnEditPage); sb.AppendLine("} else {"); sb.AppendLine("jq(\"#statusSubscribe\").removeClass(\"unsubscribed\").addClass(\"subscribed\");"); sb.AppendFormat("jq(\"#statusSubscribe\").attr(\"title\", \"{0}\");", WikiResource.UnNotifyOnEditPage); sb.AppendLine("}};"); Page.RegisterInlineScript(sb.ToString()); }
public static bool PermissionCheckCreateBookmark() { return(CommunitySecurity.CheckPermissions(BookmarkingBusinessConstants.BookmarkCreateAction)); }