Beispiel #1
0
        public AjaxResponse UpdateComment(string commentId, string text, string pid)
        {
            var resp = new AjaxResponse();

            if (string.IsNullOrEmpty(text))
            {
                return(resp);
            }

            var storage = FeedStorageFactory.Create();
            var comment = storage.GetFeedComment(long.Parse(commentId, CultureInfo.CurrentCulture));

            if (!CommunitySecurity.CheckPermissions(comment, NewsConst.Action_Edit))
            {
                return(resp);
            }

            comment.Comment = text;
            storage.UpdateFeedComment(comment);

            resp.rs1 = commentId;
            resp.rs2 = HtmlUtility.GetFull(text);

            return(resp);
        }
Beispiel #2
0
        public string LoadCommentText(string commentId, string pid)
        {
            var storage = FeedStorageFactory.Create();
            var comment = storage.GetFeedComment(long.Parse(commentId, CultureInfo.CurrentCulture));

            return(comment.Comment);
        }
Beispiel #3
0
        public AjaxResponse AddComment(string parentCommentId, string newsId, string text, string pid)
        {
            var resp = new AjaxResponse {
                rs1 = parentCommentId
            };

            var comment = new FeedComment(long.Parse(newsId));

            comment.Comment = text;
            var storage = FeedStorageFactory.Create();

            if (!string.IsNullOrEmpty(parentCommentId))
            {
                comment.ParentId = Convert.ToInt64(parentCommentId);
            }

            var feed = storage.GetFeed(long.Parse(newsId, CultureInfo.CurrentCulture));

            comment = storage.SaveFeedComment(feed, comment);

            var commentInfo = GetCommentInfo(comment);
            var defComment  = new CommentsList();

            ConfigureComments(defComment, feed);

            var visibleCommentsCount = 0;

            storage.GetFeedComments(feed.Id).ForEach((cmm) => { visibleCommentsCount += (cmm.Inactive ? 0 : 1); });

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(
                defComment, commentInfo, comment.IsRoot(), visibleCommentsCount % 2 == 1);

            return(resp);
        }
Beispiel #4
0
        public string GetPreview(string text, string commentID)
        {
            var storage = FeedStorageFactory.Create();

            var comment = new FeedComment(1)
            {
                Date    = TenantUtil.DateTimeNow(),
                Creator = SecurityContext.CurrentAccount.ID.ToString()
            };

            if (!string.IsNullOrEmpty(commentID))
            {
                comment = storage.GetFeedComment(long.Parse(commentID, CultureInfo.CurrentCulture));
            }

            comment.Comment = text;

            var commentInfo = GetCommentInfo(comment);

            commentInfo.IsEditPermissions     = false;
            commentInfo.IsResponsePermissions = false;

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment, commentInfo, true, false));
        }
        public AjaxResponse Remove(string id)
        {
            try
            {
                var resp = new AjaxResponse {
                    rs1 = "0"
                };
                if (!string.IsNullOrEmpty(id))
                {
                    var feedId  = Convert.ToInt64(id);
                    var storage = FeedStorageFactory.Create();

                    var feed = storage.GetFeed(feedId);
                    CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit);

                    foreach (var comment in storage.GetFeedComments(feedId))
                    {
                        CommonControlsConfigurer.FCKUploadsRemoveForItem("news_comments", comment.Id.ToString());
                    }

                    storage.RemoveFeed(feed);
                    CommonControlsConfigurer.FCKUploadsRemoveForItem("news", id);

                    resp.rs1 = id;
                    resp.rs2 = NewsResource.FeedDeleted;
                }
                return(resp);
            }
            catch (Exception err)
            {
                return(new AjaxResponse {
                    rs1 = "1", rs2 = err.Message,
                });
            }
        }
Beispiel #6
0
        public string RemoveComment(string commentId, string pid)
        {
            var storage = FeedStorageFactory.Create();
            var comment = storage.GetFeedComment(long.Parse(commentId, CultureInfo.CurrentCulture));

            comment.Inactive = true;
            storage.RemoveFeedComment(comment);
            return(commentId);
        }
Beispiel #7
0
        public CheckEmptyContentResult IsEmpty()
        {
            var widgetSettings = SettingsManager.Instance.LoadSettingsFor <FeedWidgetSettings>(SecurityContext.CurrentAccount.ID);
            var feeds          = FeedStorageFactory.Create().GetFeeds(FeedType.AllNews, Guid.Empty, widgetSettings.NewsCount, 0);

            if (feeds.Count > 0)
            {
                return(CheckEmptyContentResult.NotEmpty);
            }

            return(CheckEmptyContentResult.Empty);
        }
Beispiel #8
0
 public override SearchResultItem[] Search(string text)
 {
     return(FeedStorageFactory.Create()
            .SearchFeeds(text)
            .ConvertAll <SearchResultItem>(f => new SearchResultItem()
     {
         Name = f.Caption,
         Description = HtmlUtility.GetText(f.Text, 120),
         URL = FeedUrls.GetFeedUrl(f.Id),
         Date = f.Date
     })
            .ToArray());
 }
Beispiel #9
0
        protected void SaveFeed()
        {
            if (String.IsNullOrEmpty(_pollMaster.Name))
            {
                _errorMessage.Text = "<div class='errorBox'>" + Resources.NewsResource.ErrorEmptyQuestion + "</div>";
                return;
            }

            if (_pollMaster.AnswerVariants.Count < 2)
            {
                _errorMessage.Text = "<div class='errorBox'>" + Resources.NewsResource.ErrorPollVariantCount + "</div>";
                return;
            }

            var isEdit  = FeedId != 0;
            var storage = FeedStorageFactory.Create();

            var feed = isEdit ? (FeedPoll)storage.GetFeed(FeedId) : new FeedPoll();

            feed.Caption  = _pollMaster.Name;
            feed.PollType = _pollMaster.Singleton ? FeedPollType.SimpleAnswer : FeedPollType.MultipleAnswer;

            int i = 0;

            foreach (var answVariant in _pollMaster.AnswerVariants)
            {
                FeedPollVariant answerVariant = null;
                try
                {
                    answerVariant = feed.Variants[i];
                }
                catch { }
                if (answerVariant == null)
                {
                    answerVariant = new FeedPollVariant();
                    feed.Variants.Add(answerVariant);
                }
                answerVariant.Name = answVariant.Name;
                i++;
            }
            while (i != feed.Variants.Count)
            {
                feed.Variants.RemoveAt(i);
            }

            storage.SaveFeed(feed, isEdit, FeedType.Poll);



            Response.Redirect(VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + "?docid=" + feed.Id + Info.UserIdAttribute);
        }
Beispiel #10
0
        public string RemoveComment(string commentId, string pid)
        {
            var storage = FeedStorageFactory.Create();
            var comment = storage.GetFeedComment(long.Parse(commentId, CultureInfo.CurrentCulture));

            if (!CommunitySecurity.CheckPermissions(comment, NewsConst.Action_Edit))
            {
                return(null);
            }

            comment.Inactive = true;
            storage.RemoveFeedComment(comment);
            return(commentId);
        }
        public bool VoteCallback(string pollID, List <string> selectedVariantIDs, string additionalParams, out string errorMessage)
        {
            errorMessage = string.Empty;
            var userAnswersIDs = new List <long>();

            selectedVariantIDs.ForEach(strId => { if (!string.IsNullOrEmpty(strId))
                                                  {
                                                      userAnswersIDs.Add(Convert.ToInt64(strId));
                                                  }
                                       });
            long pollId  = Convert.ToInt64(additionalParams);
            var  storage = FeedStorageFactory.Create();

            return(VoteForPoll(userAnswersIDs, storage, pollId, out errorMessage));
        }
Beispiel #12
0
        public void WriteNavigation()
        {
            var usedFeedTypes = FeedStorageFactory.Create().GetUsedFeedTypes();

            if (usedFeedTypes.Count == 0)
            {
                NewsNavigator.Visible = false;
            }
            else
            {
                niTypeAllNews.URL  = FeedUrls.GetFeedListUrl(RequestedUserId);
                niTypeAllNews.Name = Resources.NewsResource.NewsBreadCrumbs;
                AddNewsTypes(usedFeedTypes);
            }
        }
Beispiel #13
0
        private static string RenderWidget()
        {
            var widgetSettings = SettingsManager.Instance.LoadSettingsFor <FeedWidgetSettings>(SecurityContext.CurrentAccount.ID);
            var widget         = new StringBuilder();

            widget.Append("<div id=\"Feed_DataContent\">");

            var feeds = FeedStorageFactory.Create().GetFeeds(FeedType.AllNews, Guid.Empty, widgetSettings.NewsCount, 0);

            if (feeds.Count > 0)
            {
                foreach (var feed in feeds)
                {
                    widget.Append(@"<div style=""padding-bottom: 10px;"">");
                    widget.Append("<table cellspacing='0' cellpadding='0' border='0'><tr valign='top'><td width='25'>");
                    widget.AppendFormat(@"<span class=""textMediumDescribe"">{0}<br/>{1}</span>", feed.Date.ToShortDayMonth(), feed.Date.ToShortTimeString());
                    widget.Append("</td>");
                    widget.Append("<td>");
                    widget.Append("<div style=\"padding-left: 10px;\">");
                    widget.AppendFormat(@"<a href=""{0}"">{1}</a>", FeedUrls.GetFeedUrl(feed.Id), feed.Caption.HtmlEncode());
                    widget.Append("</div>");
                    widget.Append("</td>");
                    widget.Append("</tr>");
                    widget.Append("</table>");
                    widget.Append(@"</div>");
                }

                widget.Append(@"<div style=""margin-top: 10px;"">");
                widget.AppendFormat(@"<a href=""{1}"">{0}</a>", Resources.NewsResource.SeeAllNews, FeedUrls.MainPageUrl);
                widget.Append(@"</div>");
            }
            else
            {
                widget.Append("<div class=\"empty-widget\" style=\"padding:40px; text-align: center;\">" +
                              String.Format(Resources.NewsResource.NoFeedWidgetMessage,
                                            string.Format("<div style=\"padding-top:3px;\"><a class=\"promoAction\" href=\"{0}\">", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/editnews.aspx")),
                                            "</a></div>")
                              + "</div>");
            }


            widget.Append("</div>");
            return(widget.ToString());
        }
Beispiel #14
0
        public CheckEmptyContentResult IsEmpty()
        {
            try
            {
                var storage = FeedStorageFactory.Create();
                var polls   = storage.GetFeeds(FeedType.Poll, Guid.Empty, 1, 0);
                if (0 < polls.Count)
                {
                    poll = storage.GetFeed(polls[0].Id) as FeedPoll;
                }
            }
            catch { }
            if (poll == null)
            {
                return(CheckEmptyContentResult.NotEmpty);
            }

            return(CheckEmptyContentResult.Empty);
        }
Beispiel #15
0
        public AjaxResponse Remove(string id)
        {
            AjaxResponse resp = new AjaxResponse();

            resp.rs1 = "0";
            if (!string.IsNullOrEmpty(id))
            {
                CommunitySecurity.DemandPermissions(NewsConst.Action_Edit);

                var storage = FeedStorageFactory.Create();
                storage.RemoveFeed(Convert.ToInt64(id, CultureInfo.CurrentCulture));

                CommonControlsConfigurer.FCKUploadsRemoveForItem("news", id);

                resp.rs1 = id;
                resp.rs2 = NewsResource.FeedDeleted;
            }
            return(resp);
        }
Beispiel #16
0
        public AjaxResponse UpdateComment(string commentId, string text, string pid)
        {
            var resp = new AjaxResponse();

            resp.rs1 = commentId;
            if (text == null)
            {
                return(resp);
            }
            var storage = FeedStorageFactory.Create();
            var comment = storage.GetFeedComment(long.Parse(commentId, CultureInfo.CurrentCulture));

            comment.Comment = text;
            storage.UpdateFeedComment(comment);


            resp.rs2 = text;

            return(resp);
        }
Beispiel #17
0
        public string UpdateComment(string commentid, string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException();
            }

            var storage = FeedStorageFactory.Create();
            var comment = storage.GetFeedComment(long.Parse(commentid, CultureInfo.CurrentCulture));

            if (!CommunitySecurity.CheckPermissions(comment, NewsConst.Action_Edit))
            {
                throw new ArgumentException();
            }

            comment.Comment = content;
            storage.UpdateFeedComment(comment);

            return(HtmlUtility.GetFull(content));
        }
        protected void SaveFeed()
        {
            if (string.IsNullOrEmpty(feedName.Text))
            {
                ((NewsMaster)Master).SetInfoMessage(NewsResource.RequaredFieldValidatorCaption, InfoType.Alert);
                return;
            }

            var storage = FeedStorageFactory.Create();
            var isEdit  = (FeedId != 0);
            var feed    = isEdit ? storage.GetFeed(FeedId) : new FeedNews();

            feed.Caption  = feedName.Text;
            feed.Text     = (Request["news_text"] ?? "");
            feed.FeedType = (FeedType)int.Parse(feedType.SelectedValue, CultureInfo.CurrentCulture);
            storage.SaveFeed(feed, isEdit, FeedType.News);

            CommonControlsConfigurer.FCKEditingComplete("news", feed.Id.ToString(), feed.Text, isEdit);

            Response.Redirect(FeedUrls.GetFeedUrl(feed.Id, Info.UserId));
        }
Beispiel #19
0
        public CommentInfo AddEventComment(string parentcommentid, string entityid, string content)
        {
            if (String.IsNullOrEmpty(content))
            {
                throw new ArgumentException();
            }

            var comment = new FeedComment(long.Parse(entityid));

            comment.Comment = content;
            var storage = FeedStorageFactory.Create();

            if (!string.IsNullOrEmpty(parentcommentid))
            {
                comment.ParentId = Convert.ToInt64(parentcommentid);
            }

            var feed = storage.GetFeed(long.Parse(entityid, CultureInfo.CurrentCulture));

            comment = storage.SaveFeedComment(feed, comment);

            return(GetCommentInfo(comment));
        }
Beispiel #20
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                var storage = FeedStorageFactory.Create();
                var polls   = storage.GetFeeds(FeedType.Poll, Guid.Empty, 1, 0);
                if (0 < polls.Count)
                {
                    poll = storage.GetFeed(polls[0].Id) as FeedPoll;
                }
            }
            catch { }
            if (poll == null)
            {
                return;
            }

            bool isMakeVote = TenantUtil.DateTimeNow() <= poll.EndDate && !poll.IsUserVote(SecurityContext.CurrentAccount.ID.ToString());

            pollForm.VoteHandlerType  = typeof(PollVoteHandler);
            pollForm.Answered         = !isMakeVote || SecurityContext.DemoMode || (SetupInfo.WorkMode == WorkMode.Promo);
            pollForm.Name             = poll.Caption.HtmlEncode();
            pollForm.PollID           = poll.Id.ToString(CultureInfo.CurrentCulture);
            pollForm.Singleton        = (poll.PollType == FeedPollType.SimpleAnswer);
            pollForm.AdditionalParams = poll.Id.ToString(CultureInfo.CurrentCulture);
            foreach (var variant in poll.Variants)
            {
                pollForm.AnswerVariants.Add(new PollForm.AnswerViarint()
                {
                    ID        = variant.ID.ToString(CultureInfo.CurrentCulture),
                    Name      = variant.Name,
                    VoteCount = poll.GetVariantVoteCount(variant.ID)
                });
            }
        }
Beispiel #21
0
        public CommentInfo GetEventCommentPreview(string commentid, string htmltext)
        {
            var storage = FeedStorageFactory.Create();

            var comment = new FeedComment(1)
            {
                Date    = TenantUtil.DateTimeNow(),
                Creator = SecurityContext.CurrentAccount.ID.ToString()
            };

            if (!string.IsNullOrEmpty(commentid))
            {
                comment = storage.GetFeedComment(long.Parse(commentid, CultureInfo.CurrentCulture));
            }

            comment.Comment = htmltext;

            var commentInfo = GetCommentInfo(comment);

            commentInfo.IsEditPermissions     = false;
            commentInfo.IsResponsePermissions = false;

            return(commentInfo);
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        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();
        }
Beispiel #24
0
        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();
            }
        }
 private static long GetPostCount(Guid userID)
 {
     return(FeedStorageFactory.Create().GetFeedsCount(FeedType.All, userID));
 }
Beispiel #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(GetType());

            if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add))
            {
                Response.Redirect(FeedUrls.MainPageUrl, true);
            }

            _mobileVer = Core.Mobile.MobileDetector.IsRequestMatchesMobile(Context);

            //fix for IE 10
            var browser = HttpContext.Current.Request.Browser.Browser;

            var userAgent  = Context.Request.Headers["User-Agent"];
            var regExp     = new Regex("MSIE 10.0", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var regExpIe11 = new Regex("(?=.*Trident.*rv:11.0).+", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (browser == "IE" && regExp.Match(userAgent).Success || regExpIe11.Match(userAgent).Success)
            {
                _mobileVer = 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);
                    (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsEditBreadCrumbsNews;
                    Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsEditBreadCrumbsNews);
                    _text = (feed != null ? feed.Text : "").HtmlEncode();
                }
            }
            else
            {
                (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsAddBreadCrumbsNews;
                Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsAddBreadCrumbsNews);
            }

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

            if (!IsPostBack)
            {
                //feedNameRequiredFieldValidator.ErrorMessage = NewsResource.RequaredFieldValidatorCaption;
                HTML_FCKEditor.BasePath      = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath);
                HTML_FCKEditor.ToolbarSet    = "NewsToolbar";
                HTML_FCKEditor.EditorAreaCSS = WebSkin.BaseCSSFileAbsoluteWebPath;
                HTML_FCKEditor.Visible       = !_mobileVer;
                BindNewsTypes();

                if (feed != null)
                {
                    if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit))
                    {
                        Response.Redirect(FeedUrls.MainPageUrl, true);
                    }
                    feedName.Text        = feed.Caption;
                    HTML_FCKEditor.Value = 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();
                }
            }

            lbCancel.Attributes["name"] = HTML_FCKEditor.ClientID;
            RenderScripts();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add))
            {
                Response.Redirect(FeedUrls.MainPageUrl, true);
            }

            var storage = FeedStorageFactory.Create();

            FeedNS.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;
                    var 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 PollFormMaster.AnswerViarint
                            {
                                ID   = variant.ID.ToString(CultureInfo.CurrentCulture),
                                Name = variant.Name
                            });
                        }
                    }
                }
                else
                {
                    _pollMaster.QuestionFieldID = "feedName";
                }
            }
            else
            {
                SaveFeed();
            }

            if (feed != null)
            {
                (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsEditBreadCrumbsPoll;
                Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsEditBreadCrumbsPoll);
                lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/Products/Community/Modules/News/") + "?docid=" + docID + Info.UserIdAttribute;
            }
            else
            {
                (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsAddBreadCrumbsPoll;
                Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsAddBreadCrumbsPoll);
                lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/Products/Community/Modules/News/") + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1));
            }
        }
Beispiel #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SetupInfo.WorkMode == WorkMode.Promo)
            {
                Response.Redirect(FeedUrls.MainPageUrl, true);
            }

            Utility.RegisterTypeForAjax(this.GetType());

            if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add))
            {
                Response.Redirect(FeedUrls.MainPageUrl, true);
            }

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

            Breadcrumb.Add(new BreadCrumb {
                NavigationUrl = FeedUrls.MainPageUrl, Caption = NewsResource.NewsBreadCrumbs
            });
            if (Info.HasUser)
            {
                Breadcrumb.Add(new BreadCrumb {
                    Caption = Info.User.DisplayUserName(false), NavigationUrl = FeedUrls.GetFeedListUrl(Info.UserId)
                });
            }

            var  storage = FeedStorageFactory.Create();
            Feed feed    = null;

            if (!string.IsNullOrEmpty(Request["docID"]))
            {
                long docID;
                if (long.TryParse(Request["docID"], out docID))
                {
                    feed = storage.GetFeed(docID);
                    Breadcrumb.Add(new BreadCrumb {
                        Caption = feed.Caption ?? string.Empty, NavigationUrl = FeedUrls.GetFeedUrl(docID, Info.UserId)
                    });
                    Breadcrumb.Add(new BreadCrumb {
                        Caption = NewsResource.NewsEditBreadCrumbsNews, NavigationUrl = FeedUrls.EditNewsUrl + "?docID=" + docID + Info.UserIdAttribute
                    });
                    _text = (feed != null ? feed.Text : "").HtmlEncode();
                }
            }
            else
            {
                Breadcrumb.Add(new BreadCrumb {
                    Caption = NewsResource.NewsAddBreadCrumbsNews, NavigationUrl = FeedUrls.EditNewsUrl + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1))
                });
            }

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

            if (!IsPostBack)
            {
                //feedNameRequiredFieldValidator.ErrorMessage = NewsResource.RequaredFieldValidatorCaption;
                HTML_FCKEditor.BasePath      = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath);
                HTML_FCKEditor.ToolbarSet    = "NewsToolbar";
                HTML_FCKEditor.EditorAreaCSS = WebSkin.GetUserSkin().BaseCSSFileAbsoluteWebPath;
                HTML_FCKEditor.Visible       = !_mobileVer;
                BindNewsTypes();

                if (feed != null)
                {
                    if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit))
                    {
                        Response.Redirect(FeedUrls.MainPageName, true);
                    }
                    feedName.Text        = feed.Caption;
                    HTML_FCKEditor.Value = feed.Text;
                    FeedId = feed.Id;
                    feedType.SelectedIndex = (int)Math.Log((int)feed.FeedType, 2);
                }
            }
            else
            {
                var control = FindControl(Request.Params["__EVENTTARGET"]);
                if (lbCancel.Equals(control))
                {
                    CancelFeed(sender, e);
                }
                else
                {
                    SaveFeed();
                }
            }

            this.Title = HeaderStringHelper.GetPageTitle(NewsResource.AddonName, Breadcrumb);

            lbCancel.Attributes["name"] = HTML_FCKEditor.ClientID;
        }
        private List <SubscriptionObject> GetSubscriptionObjects(bool includeFeed, bool includeComments)
        {
            List <SubscriptionObject> subscriptionObjects = new List <SubscriptionObject>();

            IList <string> list = new List <string>();

            var currentAccount = SecurityContext.CurrentAccount;

            if (includeFeed)
            {
                list = new List <string>(
                    SubscriptionProvider.GetSubscriptions(
                        NewsConst.NewFeed,
                        new DirectRecipient(currentAccount.ID.ToString(), currentAccount.Name), false)
                    );
                if (list.Count > 0)
                {
                    foreach (string id in list)
                    {
                        if (!string.IsNullOrEmpty(id))
                        {
                            subscriptionObjects.Add(new SubscriptionObject()
                            {
                                ID               = id,
                                Name             = NewsResource.NotifyOnNewFeed,
                                URL              = string.Empty,
                                SubscriptionType = GetSubscriptionTypes()[0]
                            });
                        }
                    }
                }
            }

            if (includeComments)
            {
                list = new List <string>(
                    SubscriptionProvider.GetSubscriptions(
                        NewsConst.NewComment,
                        new DirectRecipient(currentAccount.ID.ToString(), currentAccount.Name), false)
                    );
                if (list.Count > 0)
                {
                    var storage = FeedStorageFactory.Create();
                    foreach (string id in list)
                    {
                        if (!string.IsNullOrEmpty(id))
                        {
                            try
                            {
                                var feedID = Int32.Parse(id);
                                var feed   = storage.GetFeed(feedID);
                                subscriptionObjects.Add(new SubscriptionObject()
                                {
                                    ID               = id,
                                    Name             = feed.Caption,
                                    URL              = FeedUrls.GetFeedAbsolutePath(feed.Id),
                                    SubscriptionType = GetSubscriptionTypes()[1]
                                });
                            }
                            catch { }
                        }
                    }
                }
            }
            return(subscriptionObjects);
        }
        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();
        }