예제 #1
0
        public PingBack(Core core, Blog blog, BlogEntry blogPost, long pingBackId)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(PingBack_ItemLoad);

            this.blog = blog;
            this.blogPost = blogPost;

            try
            {
                LoadItem(pingBackId);
            }
            catch (InvalidItemException)
            {
                throw new InvalidTrackBackException();
            }
        }
예제 #2
0
        void AccountBlogTrackback_Show(object sender, EventArgs e)
        {
            SetTemplate("account_blog_trackback");

            Blog myBlog;

            try
            {
                myBlog = new Blog(core, LoggedInMember);
            }
            catch (InvalidBlogException)
            {
                myBlog = Blog.Create(core);
            }

            List<TrackBack> trackBacksUnapproved = myBlog.GetTrackBacksUnapproved(core.TopLevelPageNumber, 10);
        }
예제 #3
0
        /// <summary>
        /// Default show procedure for account sub module.
        /// </summary>
        /// <param name="sender">Object calling load event</param>
        /// <param name="e">Load EventArgs</param>
        void AccountBlogWrite_Show(object sender, EventArgs e)
        {
            SetTemplate("account_post");

            VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list");
            javaScriptVariableCollection.Parse("URI", @"/scripts/jquery.sceditor.bbcode.min.js");

            VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list");
            styleSheetVariableCollection.Parse("URI", @"/styles/jquery.sceditor.theme.default.min.css");

            core.Template.Parse("OWNER_STUB", Owner.UriStubAbsolute);

            Blog blog = new Blog(core, (User)Owner);

            /* Title TextBox */
            TextBox titleTextBox = new TextBox("title");
            titleTextBox.MaxLength = 127;

            /* Post TextBox */
            TextBox postTextBox = new TextBox("post");
            postTextBox.IsFormatted = true;
            postTextBox.Lines = 15;

            /* Tags TextBox */
            TagSelectBox tagsTextBox = new TagSelectBox(core, "tags");
            //tagsTextBox.MaxLength = 127;

            CheckBox publishToFeedCheckBox = new CheckBox("publish-feed");
            publishToFeedCheckBox.IsChecked = true;

            long postId = core.Functions.RequestLong("id", 0);
            byte licenseId = (byte)0;
            short categoryId = (short)1;
            DateTime postTime = core.Tz.Now;

            SelectBox postYearsSelectBox = new SelectBox("post-year");
            for (int i = core.Tz.Now.AddYears(-7).Year; i <= core.Tz.Now.Year; i++)
            {
                postYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postYearsSelectBox.SelectedKey = postTime.Year.ToString();

            SelectBox postMonthsSelectBox = new SelectBox("post-month");
            for (int i = 1; i < 13; i++)
            {
                postMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i)));
            }

            postMonthsSelectBox.SelectedKey = postTime.Month.ToString();

            SelectBox postDaysSelectBox = new SelectBox("post-day");
            for (int i = 1; i < 32; i++)
            {
                postDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postDaysSelectBox.SelectedKey = postTime.Day.ToString();

            if (postId > 0 && core.Http.Query["mode"] == "edit")
            {
                try
                {
                    BlogEntry be = new BlogEntry(core, postId);

                    titleTextBox.Value = be.Title;
                    postTextBox.Value = be.Body;

                    licenseId = be.License;
                    categoryId = be.Category;

                    postTime = be.GetPublishedDate(tz);

                    List<Tag> tags = Tag.GetTags(core, be);

                    //string tagList = string.Empty;

                    foreach (Tag tag in tags)
                    {
                        /*if (tagList != string.Empty)
                        {
                            tagList += ", ";
                        }
                        tagList += tag.TagText;*/
                        tagsTextBox.AddTag(tag);
                    }

                    //tagsTextBox.Value = tagList;

                    if (be.OwnerId != core.LoggedInMemberId)
                    {
                        DisplayError("You must be the owner of the blog entry to modify it.");
                        return;
                    }
                }
                catch (InvalidBlogEntryException)
                {
                    DisplayError(core.Prose.GetString("Blog", "BLOG_ENTRY_DOES_NOT_EXIST"));
                    return;
                }
            }
            else
            {
                template.Parse("IS_NEW", "TRUE");

                PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", blog.ItemKey);
                HiddenField aclModeField = new HiddenField("aclmode");
                aclModeField.Value = "simple";

                template.Parse("S_PERMISSIONS", permissionSelectBox);
                template.Parse("S_ACLMODE", aclModeField);
            }

            template.Parse("S_POST_YEAR", postYearsSelectBox);
            template.Parse("S_POST_MONTH", postMonthsSelectBox);
            template.Parse("S_POST_DAY", postDaysSelectBox);
            template.Parse("S_POST_HOUR", postTime.Hour.ToString());
            template.Parse("S_POST_MINUTE", postTime.Minute.ToString());

            SelectBox licensesSelectBox = new SelectBox("license");
            DataTable licensesTable = db.Query(ContentLicense.GetSelectQueryStub(core, typeof(ContentLicense)));

            licensesSelectBox.Add(new SelectBoxItem("0", "Default License"));
            foreach (DataRow licenseRow in licensesTable.Rows)
            {
                ContentLicense li = new ContentLicense(core, licenseRow);
                licensesSelectBox.Add(new SelectBoxItem(li.Id.ToString(), li.Title));
            }

            licensesSelectBox.SelectedKey = licenseId.ToString();

            SelectBox categoriesSelectBox = new SelectBox("category");
            SelectQuery query = Category.GetSelectQueryStub(core, typeof(Category));
            query.AddSort(SortOrder.Ascending, "category_title");

            DataTable categoriesTable = db.Query(query);

            foreach (DataRow categoryRow in categoriesTable.Rows)
            {
                Category cat = new Category(core, categoryRow);
                categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title));
            }

            categoriesSelectBox.SelectedKey = categoryId.ToString();

            /* Parse the form fields */
            template.Parse("S_TITLE", titleTextBox);
            template.Parse("S_BLOG_TEXT", postTextBox);
            template.Parse("S_TAGS", tagsTextBox);

            template.Parse("S_BLOG_LICENSE", licensesSelectBox);
            template.Parse("S_BLOG_CATEGORY", categoriesSelectBox);

            template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox);

            template.Parse("S_ID", postId.ToString());

            foreach (Emoticon emoticon in core.Emoticons)
            {
                if (emoticon.Category == "modifier") continue;
                if (emoticon.Category == "people" && emoticon.Code.Length < 3)
                {
                    VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_list");
                    emoticonVariableCollection.Parse("CODE", emoticon.Code);
                    emoticonVariableCollection.Parse("URI", emoticon.File);
                }
                else
                {
                    VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_hidden_list");
                    emoticonVariableCollection.Parse("CODE", emoticon.Code);
                    emoticonVariableCollection.Parse("URI", emoticon.File);
                }
            }

            Save(new EventHandler(AccountBlogWrite_Save));
            if (core.Http.Form["publish"] != null)
            {
                AccountBlogWrite_Save(this, new EventArgs());
            }
        }
예제 #4
0
        /// <summary>
        /// Save procedure for a blog entry.
        /// </summary>
        /// <param name="sender">Object calling load event</param>
        /// <param name="e">Load EventArgs</param>
        void AccountBlogWrite_Save(object sender, EventArgs e)
        {
            string title = core.Http.Form["title"];
            //string tags = core.Http.Form["tags"];
            string postBody = core.Http.Form["post"];
            bool publishToFeed = (core.Http.Form["publish-feed"] != null);

            byte license = 0;
            short category = 1;
            long postId = 0;
            PublishStatuses publishStatus = PublishStatuses.Published;
            string postGuid = "";
            long currentTimestamp = UnixTime.UnixTimeStamp();

            /*
             * Create a blog if they do not already have one
             */
            Blog myBlog = null;
            try
            {
                myBlog = new Blog(core, LoggedInMember);
            }
            catch (InvalidBlogException)
            {
                myBlog = Blog.Create(core);
            }

            bool postEditTimestamp = false;
            int postYear, postMonth, postDay, postHour, postMinute;
            DateTime postTime = core.Tz.DateTimeFromMysql(currentTimestamp);

            if (core.Http.Form["publish"] != null)
            {
                publishStatus = PublishStatuses.Published;
            }

            if (core.Http.Form["save"] != null)
            {
                publishStatus = PublishStatuses.Draft;
            }

            postId = core.Functions.FormLong("id", 0);
            license = core.Functions.FormByte("license", license);
            category = core.Functions.FormShort("category", category);

            try
            {
                postYear = core.Functions.FormInt("post-year", 0);
                postMonth = core.Functions.FormInt("post-month", 0);
                postDay = core.Functions.FormInt("post-day", 0);

                postHour = core.Functions.FormInt("post-hour", 0);
                postMinute = core.Functions.FormInt("post-minute", 0);

                postEditTimestamp = !string.IsNullOrEmpty(core.Http.Form["edit-timestamp"]);

                postTime = new DateTime(postYear, postMonth, postDay, postHour, postMinute, 0);
            }
            catch
            {
            }

            if (string.IsNullOrEmpty(title))
            {
                SetError("You must give the blog post a title.");
                return;
            }

            if (string.IsNullOrEmpty(postBody))
            {
                SetError("You cannot save an empty blog post. You must post some content.");
                return;
            }

            string sqlPostTime = "";

            // update, must happen before save new because it populates postId
            if (postId > 0)
            {
                db.BeginTransaction();

                BlogEntry myBlogEntry = new BlogEntry(core, postId);

                long postTimeRaw;
                bool doPublish = false;
                if (postEditTimestamp)
                {
                    postTimeRaw = tz.GetUnixTimeStamp(postTime);

                    if (postTimeRaw > UnixTime.UnixTimeStamp())
                    {
                        publishStatus = PublishStatuses.Queued;
                    }
                }

                if (publishStatus != myBlogEntry.Status)
                {
                    switch (publishStatus)
                    {
                        case PublishStatuses.Published:
                            UpdateQuery uQuery = new UpdateQuery(typeof(Blog));
                            uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Addition, 1));
                            switch (myBlogEntry.Status)
                            {
                                case PublishStatuses.Draft:
                                    uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Subtraction, 1));
                                    break;
                                case PublishStatuses.Queued:
                                    uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Subtraction, 1));
                                    break;
                            }
                            uQuery.AddCondition("user_id", Owner.Id);

                            db.Query(uQuery);

                            doPublish = true;
                            break;
                        case PublishStatuses.Draft:
                            uQuery = new UpdateQuery(typeof(Blog));
                            uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Addition, 1));
                            switch (myBlogEntry.Status)
                            {
                                case PublishStatuses.Published:
                                    uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Subtraction, 1));
                                    break;
                                case PublishStatuses.Queued:
                                    uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Subtraction, 1));
                                    break;
                            }
                            uQuery.AddCondition("user_id", Owner.Id);

                            db.Query(uQuery);
                            break;
                        case PublishStatuses.Queued:
                            uQuery = new UpdateQuery(typeof(Blog));
                            uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Addition, 1));
                            switch (myBlogEntry.Status)
                            {
                                case PublishStatuses.Published:
                                    uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Subtraction, 1));
                                    break;
                                case PublishStatuses.Draft:
                                    uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Subtraction, 1));
                                    break;
                            }
                            uQuery.AddCondition("user_id", Owner.Id);

                            db.Query(uQuery);
                            break;
                    }
                }

                // Save image attachments
                {
                    postBody = core.Bbcode.ExtractAndSaveImageData(postBody, myBlogEntry, saveImage);
                }

                myBlogEntry.Title = title;
                myBlogEntry.BodyCache = string.Empty;
                myBlogEntry.Body = postBody;
                myBlogEntry.License = license;
                myBlogEntry.Category = category;
                myBlogEntry.ModifiedDateRaw = currentTimestamp;
                if (postEditTimestamp)
                {
                    myBlogEntry.PublishedDateRaw = tz.GetUnixTimeStamp(postTime);
                }
                myBlogEntry.Status = publishStatus;

                myBlogEntry.Update();

                if (publishToFeed && publishStatus == PublishStatuses.Published && doPublish)
                {
                    core.Search.Index(myBlogEntry);
                    core.CallingApplication.PublishToFeed(core, LoggedInMember, myBlogEntry, myBlogEntry.Title);
                }

                Tag.LoadTagsIntoItem(core, myBlogEntry, TagSelectBox.FormTags(core, "tags"));
            }
            else if (postId == 0) // else if to make sure only one triggers
            {
                long postTimeRaw;
                // save new
                if (postEditTimestamp)
                {
                    postTimeRaw = tz.GetUnixTimeStamp(postTime);
                }
                else
                {
                    postTimeRaw = currentTimestamp;
                }

                if (postTimeRaw > UnixTime.UnixTimeStamp())
                {
                    publishStatus = PublishStatuses.Queued;
                }

                db.BeginTransaction();

                BlogEntry myBlogEntry = BlogEntry.Create(core, AccessControlLists.GetNewItemPermissionsToken(core), myBlog, title, postBody, license, publishStatus, category, postTimeRaw);

                /*AccessControlLists acl = new AccessControlLists(core, myBlogEntry);
                acl.SaveNewItemPermissions();*/

                postGuid = core.Hyperlink.StripSid(string.Format("{0}blog/{1:0000}/{2:00}/{3}",
                    LoggedInMember.UriStubAbsolute, DateTime.Now.Year, DateTime.Now.Month, postId));

                myBlogEntry.Guid = postGuid;
                long updated = myBlogEntry.Update();

                if (updated > 0)
                {

                }

                switch (publishStatus)
                {
                    case PublishStatuses.Published:
                        UpdateQuery uQuery = new UpdateQuery(typeof(Blog));
                        uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Addition, 1));
                        uQuery.AddCondition("user_id", Owner.Id);

                        db.Query(uQuery);
                        break;
                    case PublishStatuses.Draft:
                        uQuery = new UpdateQuery(typeof(Blog));
                        uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Addition, 1));
                        uQuery.AddCondition("user_id", Owner.Id);

                        db.Query(uQuery);
                        break;
                    case PublishStatuses.Queued:
                        uQuery = new UpdateQuery(typeof(Blog));
                        uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Addition, 1));
                        uQuery.AddCondition("user_id", Owner.Id);

                        db.Query(uQuery);
                        break;
                }

                Tag.LoadTagsIntoItem(core, myBlogEntry, TagSelectBox.FormTags(core, "tags"), true);

                // Save image attachments
                {
                    postBody = core.Bbcode.ExtractAndSaveImageData(postBody, myBlogEntry, saveImage);

                    myBlogEntry.BodyCache = string.Empty;
                    myBlogEntry.Body = postBody;
                    myBlogEntry.Update(); // only triggers if postBody has been updated
                }

                if (publishToFeed && publishStatus == PublishStatuses.Published)
                {
                    core.Search.Index(myBlogEntry);
                    core.CallingApplication.PublishToFeed(core, LoggedInMember, myBlogEntry, myBlogEntry.Title);
                }

            }

            switch (publishStatus)
            {
                case PublishStatuses.Draft:
                    SetRedirectUri(BuildUri("drafts"));
                    core.Display.ShowMessage("Draft Saved", "Your draft has been saved.");
                    break;
                case PublishStatuses.Published:
                    SetRedirectUri(BuildUri("manage"));
                    core.Display.ShowMessage("Blog Post Published", "Your blog post has been published.");
                    break;
                case PublishStatuses.Queued:
                    SetRedirectUri(BuildUri("queue"));
                    core.Display.ShowMessage("Blog Post Queued", "Your blog post has been placed in the publish queue.");
                    break;
            }
        }
예제 #5
0
        void AccountBlogManage_Show(object sender, EventArgs e)
        {
            SetTemplate("account_blog_manage");

            Blog myBlog;

            try
            {
                myBlog = new Blog(core, LoggedInMember);
            }
            catch (InvalidBlogException)
            {
                myBlog = Blog.Create(core);
            }

            if (myBlog.Access.Can("POST_ITEMS"))
            {
                template.Parse("U_WRITE_NEW_POST", BuildUri("write"));
            }
            template.Parse("U_PERMISSIONS", core.Hyperlink.AppendAbsoluteSid(string.Format("/api/acl?id={0}&type={1}", myBlog.Id, ItemType.GetTypeId(core, typeof(Blog))), true));

            List<BlogEntry> blogEntries = myBlog.GetEntries(null, null, -1, -1, -1, core.TopLevelPageNumber, 25);

            foreach (BlogEntry be in blogEntries)
            {
                VariableCollection blogVariableCollection = template.CreateChild("blog_list");

                DateTime postedTime = be.GetPublishedDate(tz);

                blogVariableCollection.Parse("COMMENTS", be.Comments.ToString());
                blogVariableCollection.Parse("VIEWS", be.Info.ViewedTimes.ToString());
                blogVariableCollection.Parse("TITLE", be.Title);
                blogVariableCollection.Parse("POSTED", tz.DateTimeToString(postedTime));

                blogVariableCollection.Parse("U_VIEW", core.Hyperlink.BuildBlogPostUri(LoggedInMember, postedTime.Year, postedTime.Month, be.Id));

                blogVariableCollection.Parse("U_EDIT", BuildUri("write", "edit", be.Id));
                blogVariableCollection.Parse("U_EDIT_PERMISSIONS", core.Hyperlink.AppendAbsoluteSid(string.Format("/api/acl?id={0}&type={1}", be.Id, ItemType.GetTypeId(core, typeof(BlogEntry))), true));
                blogVariableCollection.Parse("U_STATISTICS", core.Hyperlink.AppendAbsoluteSid(string.Format("/api/statistics?mode=item&id={0}&type={1}", be.Id, ItemType.GetTypeId(core, typeof(BlogEntry))), true));
                blogVariableCollection.Parse("U_DELETE", BuildUri("write", "delete", be.Id));
            }

            core.Display.ParsePagination(template, BuildUri(), 25, myBlog.Entries);
        }
예제 #6
0
        void AccountBlogRoll_Show(object sender, EventArgs e)
        {
            SetTemplate("account_blog_roll");

            Blog myBlog;
            try
            {
                myBlog = new Blog(core, session.LoggedInMember);
            }
            catch (InvalidBlogException)
            {
                myBlog = Blog.Create(core);
            }

            List<BlogRollEntry> blogRollEntries = myBlog.GetBlogRoll();

            template.Parse("BLOG_ROLL_ENTRIES", blogRollEntries.Count.ToString());
            template.Parse("U_NEW_BLOG_ROLL", core.Hyperlink.BuildAccountSubModuleUri(ModuleKey, Key, "new"));

            foreach (BlogRollEntry bre in blogRollEntries)
            {
                VariableCollection breVariableCollection = template.CreateChild("blog_roll_list");

                if (!string.IsNullOrEmpty(bre.Title))
                {
                    breVariableCollection.Parse("TITLE", bre.Title);
                }
                else if (bre.User != null)
                {
                    breVariableCollection.Parse("TITLE", bre.User.DisplayName);
                }

                breVariableCollection.Parse("URI", bre.Uri);
                breVariableCollection.Parse("U_EDIT", core.Hyperlink.BuildAccountSubModuleUri(ModuleKey, Key, "edit", bre.Id));
                breVariableCollection.Parse("U_DELETE", core.Hyperlink.BuildAccountSubModuleUri(ModuleKey, Key, "delete", bre.Id));
            }
        }
예제 #7
0
        public Template GetPostTemplate(Core core, Primitive owner)
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "postblog");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            string formSubmitUri = core.Hyperlink.AppendSid(owner.AccountUriStub, true);
            template.Parse("U_ACCOUNT", formSubmitUri);
            template.Parse("S_ACCOUNT", formSubmitUri);

            template.Parse("USER_DISPLAY_NAME", owner.DisplayName);

            Blog blog = null;

            try
            {
                blog = new Blog(core, (User)owner);
            }
            catch (InvalidBlogException)
            {
                if (owner.ItemKey.Equals(core.LoggedInMemberItemKey))
                {
                    blog = Blog.Create(core);
                }
                else
                {
                    return null;
                }
            }

            /* Title TextBox */
            TextBox titleTextBox = new TextBox("title");
            titleTextBox.MaxLength = 127;

            /* Post TextBox */
            TextBox postTextBox = new TextBox("post");
            postTextBox.IsFormatted = true;
            postTextBox.Lines = 15;

            /* Tags TextBox */
            TagSelectBox tagsTextBox = new TagSelectBox(core, "tags");
            //tagsTextBox.MaxLength = 127;

            CheckBox publishToFeedCheckBox = new CheckBox("publish-feed");
            publishToFeedCheckBox.IsChecked = true;

            PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", blog.ItemKey);
            HiddenField aclModeField = new HiddenField("aclmode");
            aclModeField.Value = "simple";

            template.Parse("S_PERMISSIONS", permissionSelectBox);
            template.Parse("S_ACLMODE", aclModeField);

            DateTime postTime = DateTime.Now;

            SelectBox postYearsSelectBox = new SelectBox("post-year");
            for (int i = DateTime.Now.AddYears(-7).Year; i <= DateTime.Now.Year; i++)
            {
                postYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postYearsSelectBox.SelectedKey = postTime.Year.ToString();

            SelectBox postMonthsSelectBox = new SelectBox("post-month");
            for (int i = 1; i < 13; i++)
            {
                postMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i)));
            }

            postMonthsSelectBox.SelectedKey = postTime.Month.ToString();

            SelectBox postDaysSelectBox = new SelectBox("post-day");
            for (int i = 1; i < 32; i++)
            {
                postDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postDaysSelectBox.SelectedKey = postTime.Day.ToString();

            template.Parse("S_POST_YEAR", postYearsSelectBox);
            template.Parse("S_POST_MONTH", postMonthsSelectBox);
            template.Parse("S_POST_DAY", postDaysSelectBox);
            template.Parse("S_POST_HOUR", postTime.Hour.ToString());
            template.Parse("S_POST_MINUTE", postTime.Minute.ToString());

            SelectBox licensesSelectBox = new SelectBox("license");
            System.Data.Common.DbDataReader licensesReader = core.Db.ReaderQuery(ContentLicense.GetSelectQueryStub(core, typeof(ContentLicense)));

            licensesSelectBox.Add(new SelectBoxItem("0", "Default License"));
            while(licensesReader.Read())
            {
                ContentLicense li = new ContentLicense(core, licensesReader);
                licensesSelectBox.Add(new SelectBoxItem(li.Id.ToString(), li.Title));
            }

            licensesReader.Close();
            licensesReader.Dispose();

            SelectBox categoriesSelectBox = new SelectBox("category");
            SelectQuery query = Category.GetSelectQueryStub(core, typeof(Category));
            query.AddSort(SortOrder.Ascending, "category_title");

            System.Data.Common.DbDataReader categoriesReader = core.Db.ReaderQuery(query);

            while (categoriesReader.Read())
            {
                Category cat = new Category(core, categoriesReader);
                categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title));
            }

            categoriesReader.Close();
            categoriesReader.Dispose();

            categoriesSelectBox.SelectedKey = 1.ToString();

            /* Parse the form fields */
            template.Parse("S_TITLE", titleTextBox);
            template.Parse("S_BLOG_TEXT", postTextBox);
            template.Parse("S_TAGS", tagsTextBox);

            template.Parse("S_BLOG_LICENSE", licensesSelectBox);
            template.Parse("S_BLOG_CATEGORY", categoriesSelectBox);

            template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox);

            return template;
        }
예제 #8
0
 public PingBack(Core core, Blog blog, DataRow pingBackRow)
     : this(core, blog, null, pingBackRow)
 {
 }
예제 #9
0
        public BlogEntry(Core core, Blog blog, Primitive owner, System.Data.Common.DbDataReader postEntryReader)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(BlogEntry_ItemLoad);

            this.blog = blog;
            this.owner = owner;

            loadItemInfo(postEntryReader);
        }
예제 #10
0
 public TrackBack(Core core, Blog blog, long trackBackId)
     : this(core, blog, null, trackBackId)
 {
 }
예제 #11
0
        public TrackBack(Core core, Blog blog, BlogEntry blogPost, DataRow trackBackRow)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(TrackBack_ItemLoad);

            this.blog = blog;
            this.blogPost = blogPost;

            loadItemInfo(trackBackRow);
        }
예제 #12
0
 public TrackBack(Core core, Blog blog, DataRow trackBackRow)
     : this(core, blog, null, trackBackRow)
 {
 }
예제 #13
0
파일: Blog.cs 프로젝트: smithydll/boxsocial
        /// <summary>
        /// Show the blog
        /// </summary>
        /// <param name="core">Core token</param>
        /// <param name="page">Page calling</param>
        /// <param name="category">Category to show</param>
        /// <param name="post">Post to show</param>
        /// <param name="year">Year to show</param>
        /// <param name="month">Month to show</param>
        /// <remarks>A number of conditions may be omitted. Integer values can be omitted by passing -1. String values by passing a null or empty string.</remarks>
        private static void Show(Core core, UPage page, string category, string tag, long post, int year, int month)
        {
            core.Template.SetTemplate("Blog", "viewblog");

            bool rss = false;
            long comments = 0;
            string postTitle = null;

            Blog myBlog;
            try
            {
                myBlog = new Blog(core, page.User);
            }
            catch (InvalidBlogException)
            {
                return;
            }

            if (!myBlog.Access.Can("VIEW"))
            {
                core.Functions.Generate403();
                return;
            }

            try
            {
                rss = bool.Parse(core.Http.Query["rss"]);
            }
            catch { }

            /*if (rss)
            {
                core.Http.SwitchContextType("text/xml");
            }*/

            page.User.LoadProfileInfo();

            bool moreContent = false;
            long lastPostId = 0;
            List<BlogEntry> blogEntries = myBlog.GetEntries(category, tag, post, year, month, page.TopLevelPageNumber, 10, page.TopLevelPageOffset, false, false, out moreContent);

            if (!rss)
            {
                core.Display.ParsePageList(page.User, true);
                core.Template.Parse("U_PROFILE", page.User.Uri);
                core.Template.Parse("U_FRIENDS", core.Hyperlink.BuildFriendsUri(page.User));

                core.Template.Parse("USER_THUMB", page.Owner.Thumbnail);
                core.Template.Parse("USER_COVER_PHOTO", page.Owner.CoverPhoto);
                core.Template.Parse("USER_MOBILE_COVER_PHOTO", page.Owner.MobileCoverPhoto);

                if (string.IsNullOrEmpty(myBlog.Title))
                {
                    core.Template.Parse("PAGE_TITLE", core.Prose.GetString("BLOG"));
                }
                else
                {
                    core.Template.Parse("PAGE_TITLE", myBlog.Title);
                    core.Template.Parse("PAGE_SUB_TITLE", core.Prose.GetString("BLOG"));
                }

                core.Template.Parse("BLOG_TITLE", myBlog.Title);

                if (page.User.UserId == core.LoggedInMemberId)
                {
                    core.Template.Parse("U_POST", core.Hyperlink.BuildAccountSubModuleUri(myBlog.Owner, "blog", "write"));
                }
            }

            if (!rss)
            {
                DataTable archiveTable = core.Db.Query(string.Format("SELECT DISTINCT YEAR(FROM_UNIXTIME(post_time_ut)) as year, MONTH(FROM_UNIXTIME(post_time_ut)) as month FROM blog_postings WHERE user_id = {0} AND post_status = 'PUBLISH' ORDER BY year DESC, month DESC;",
                    page.User.UserId, core.LoggedInMemberId));

                core.Template.Parse("ARCHIVES", archiveTable.Rows.Count.ToString());

                for (int i = 0; i < archiveTable.Rows.Count; i++)
                {
                    VariableCollection archiveVariableCollection = core.Template.CreateChild("archive_list");

                    archiveVariableCollection.Parse("TITLE", string.Format("{0} {1}",
                        core.Functions.IntToMonth((int)archiveTable.Rows[i]["month"]), ((int)archiveTable.Rows[i]["year"]).ToString()));

                    archiveVariableCollection.Parse("URL", Blog.BuildUri(core, page.User, (int)archiveTable.Rows[i]["year"], (int)archiveTable.Rows[i]["month"]));
                }

                DataTable categoriesTable = core.Db.Query(string.Format("SELECT DISTINCT post_category, category_title, category_path FROM blog_postings INNER JOIN global_categories ON post_category = category_id WHERE user_id = {0} AND post_status = 'PUBLISH' ORDER BY category_title DESC;",
                    page.User.UserId, core.LoggedInMemberId));

                core.Template.Parse("CATEGORIES", categoriesTable.Rows.Count.ToString());

                for (int i = 0; i < categoriesTable.Rows.Count; i++)
                {
                    VariableCollection categoryVariableCollection = core.Template.CreateChild("category_list");

                    categoryVariableCollection.Parse("TITLE", (string)categoriesTable.Rows[i]["category_title"]);

                    categoryVariableCollection.Parse("URL", Blog.BuildUri(core, page.User, (string)categoriesTable.Rows[i]["category_path"]));
                }

                List<BlogRollEntry> blogRollEntries = myBlog.GetBlogRoll();

                core.Template.Parse("BLOG_ROLL_ENTRIES", blogRollEntries.Count.ToString());

                foreach (BlogRollEntry bre in blogRollEntries)
                {
                    VariableCollection breVariableCollection = core.Template.CreateChild("blog_roll_list");

                    if (!string.IsNullOrEmpty(bre.Title))
                    {
                        breVariableCollection.Parse("TITLE", bre.Title);
                    }
                    else if (bre.User != null)
                    {
                        breVariableCollection.Parse("TITLE", bre.User.DisplayName);
                    }

                    breVariableCollection.Parse("URI", bre.Uri);
                }
            }

            if (!string.IsNullOrEmpty(category))
            {
                core.Template.Parse("U_RSS", core.Hyperlink.BuildBlogRssUri(page.User, category));
            }
            else if (post > 0)
            {
                core.Template.Parse("U_RSS", core.Hyperlink.BuildBlogPostRssUri(page.User, year, month, post));
            }
            else if (month > 0)
            {
                core.Template.Parse("U_RSS", core.Hyperlink.BuildBlogRssUri(page.User, year, month));
            }
            else if (year > 0)
            {
                core.Template.Parse("U_RSS", core.Hyperlink.BuildBlogRssUri(page.User, year));
            }
            else
            {
                core.Template.Parse("U_RSS", core.Hyperlink.BuildBlogRssUri(page.User));
            }

            if (rss)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(RssDocument));
                RssDocument doc = new RssDocument();
                doc.version = "2.0";

                doc.channels = new RssChannel[1];
                doc.channels[0] = new RssChannel();

                doc.channels[0].title = string.Format("RSS Feed for {0} blog", page.User.DisplayNameOwnership);
                doc.channels[0].description = string.Format("RSS Feed for {0} blog", page.User.DisplayNameOwnership);
                if (!string.IsNullOrEmpty(category))
                {
                    doc.channels[0].link = core.Hyperlink.StripSid(Blog.BuildAbsoluteUri(core, page.User, category));
                }
                else if (post > 0)
                {
                    doc.channels[0].link = core.Hyperlink.StripSid(Blog.BuildAbsoluteUri(core, page.User, year, month, post));
                }
                else if (month > 0)
                {
                    doc.channels[0].link = core.Hyperlink.StripSid(Blog.BuildAbsoluteUri(core, page.User, year, month));
                }
                else if (year > 0)
                {
                    doc.channels[0].link = core.Hyperlink.StripSid(Blog.BuildAbsoluteUri(core, page.User, year));
                }
                else
                {
                    doc.channels[0].link = core.Hyperlink.StripSid(Blog.BuildAbsoluteUri(core, page.User));
                }
                doc.channels[0].category = "Blog";

                doc.channels[0].items = new RssDocumentItem[blogEntries.Count];
                for (int i = 0; i < blogEntries.Count; i++)
                {
                    DateTime postDateTime = blogEntries[i].GetPublishedDate(core.Tz);

                    doc.channels[0].items[i] = new RssDocumentItem();
                    doc.channels[0].items[i].description = core.Bbcode.Parse(HttpUtility.HtmlEncode(blogEntries[i].Body), core.Session.LoggedInMember, page.User);
                    doc.channels[0].items[i].link = core.Hyperlink.StripSid(Blog.BuildAbsoluteUri(core, page.User, postDateTime.Year, postDateTime.Month, blogEntries[i].PostId));
                    doc.channels[0].items[i].guid = core.Hyperlink.StripSid(Blog.BuildAbsoluteUri(core, page.User, postDateTime.Year, postDateTime.Month, blogEntries[i].PostId));

                    doc.channels[0].items[i].pubdate = postDateTime.ToString();

                    if (i == 0)
                    {
                        doc.channels[0].pubdate = postDateTime.ToString();
                    }
                }

                core.Http.WriteXml(serializer, doc);
                if (core.Db != null)
                {
                    core.Db.CloseConnection();
                }
                core.Http.End();
            }
            else
            {
                int postsOnPage = 0;

                List<NumberedItem> tagItems = new List<NumberedItem>();

                for (int i = 0; i < blogEntries.Count; i++)
                {
                    tagItems.Add(blogEntries[i]);
                }

                Dictionary<ItemKey, List<Tag>> tags = Tag.GetTags(core, tagItems);

                for (int i = 0; i < blogEntries.Count; i++)
                {
                    postsOnPage++;
                    VariableCollection blogPostVariableCollection = core.Template.CreateChild("blog_list");

                    blogPostVariableCollection.Parse("TITLE", blogEntries[i].Title);

                    DateTime postDateTime = blogEntries[i].GetPublishedDate(core.Tz);

                    blogPostVariableCollection.Parse("DATE", core.Tz.DateTimeToString(postDateTime));
                    blogPostVariableCollection.Parse("URL", blogEntries[i].Uri);
                    blogPostVariableCollection.Parse("ID", blogEntries[i].Id);
                    blogPostVariableCollection.Parse("TYPE_ID", blogEntries[i].ItemKey.TypeId);

                    /*if ((!core.IsMobile) && (!string.IsNullOrEmpty(blogEntries[i].BodyCache)))
                    {
                        core.Display.ParseBbcodeCache(blogPostVariableCollection, "POST", blogEntries[i].BodyCache);
                    }
                    else*/
                    if (post > 0)
                    {
                        core.Display.ParseBbcode(blogPostVariableCollection, "POST", blogEntries[i].Body, page.User);
                    }
                    else
                    {
                        core.Display.ParseBbcode(blogPostVariableCollection, "POST", blogEntries[i].SummaryString, page.User);
                    }

                    if (core.Session.IsLoggedIn)
                    {
                        if (blogEntries[i].Owner.IsItemOwner(core.Session.LoggedInMember))
                        {
                            blogPostVariableCollection.Parse("IS_OWNER", "TRUE");
                            blogPostVariableCollection.Parse("U_DELETE", blogEntries[i].DeleteUri);
                        }
                    }

                    if (blogEntries[i].Info.Likes > 0)
                    {
                        blogPostVariableCollection.Parse("LIKES", string.Format(" {0:d}", blogEntries[i].Info.Likes));
                        blogPostVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", blogEntries[i].Info.Dislikes));
                    }

                    if (blogEntries[i].Info.Comments > 0)
                    {
                        blogPostVariableCollection.Parse("POST_COMMENTS", string.Format(" ({0:d})", blogEntries[i].Info.Comments));
                    }

                    if (blogEntries[i].Access.IsPublic())
                    {
                        blogPostVariableCollection.Parse("SHAREABLE", "TRUE");
                        blogPostVariableCollection.Parse("PUBLIC", "TRUE");
                    }

                    if (blogEntries[i].PostId == post)
                    {
                        comments = blogEntries[i].Comments;
                        core.Template.Parse("BLOG_POST_COMMENTS", core.Functions.LargeIntegerToString(comments));
                        core.Template.Parse("BLOGPOST_ID", blogEntries[i].PostId.ToString());
                    }

                    if (tags.ContainsKey(blogEntries[i].ItemKey))
                    {
                        foreach (Tag t in tags[blogEntries[i].ItemKey])
                        {
                            VariableCollection tagsVariableCollection = blogPostVariableCollection.CreateChild("tags_list");

                            tagsVariableCollection.Parse("U_SEARCH", t.Uri);
                            tagsVariableCollection.Parse("TEXT", t.TagText);
                        }
                    }

                    if (post > 0)
                    {
                        postTitle = blogEntries[i].Title;
                    }

                    lastPostId = blogEntries[i].Id;
                }

                if (post > 0)
                {
                    if (postsOnPage != 1)
                    {
                        core.Functions.Generate404();
                        return;
                    }

                    //if (myBlog.Access.Can("COMMENT_ITEMS"))
                    {
                        if (blogEntries[0].Access.Can("COMMENT"))
                        {
                            core.Template.Parse("CAN_COMMENT", "TRUE");
                        }
                    }
                    core.Display.DisplayComments(core.Template, page.User, blogEntries[0]);
                    core.Template.Parse("SINGLE", "TRUE");

                    blogEntries[0].Viewed(core.Session.LoggedInMember);
                    ItemView.LogView(core, blogEntries[0]);

                    page.Core.Meta.Add("twitter:card", "summary");
                    if (!string.IsNullOrEmpty(page.Core.Settings.TwitterName))
                    {
                        page.Core.Meta.Add("twitter:site", page.Core.Settings.TwitterName);
                    }
                    if (blogEntries[0].Owner is User && !string.IsNullOrEmpty(((User)blogEntries[0].Owner).UserInfo.TwitterUserName))
                    {
                        page.Core.Meta.Add("twitter:creator", ((User)blogEntries[0].Owner).UserInfo.TwitterUserName);
                    }
                    page.Core.Meta.Add("twitter:title", blogEntries[0].Title);
                    page.Core.Meta.Add("og:title", blogEntries[0].Title);
                    page.Core.Meta.Add("twitter:description", Functions.TrimStringToWord(HttpUtility.HtmlDecode(page.Core.Bbcode.StripTags(HttpUtility.HtmlEncode(blogEntries[0].Body))).Trim(), 200, true));
                    page.Core.Meta.Add("og:type", "article");
                    page.Core.Meta.Add("og:url", page.Core.Hyperlink.StripSid(page.Core.Hyperlink.AppendCurrentSid(blogEntries[0].Uri)));
                    page.Core.Meta.Add("og:description", Functions.TrimStringToWord(HttpUtility.HtmlDecode(page.Core.Bbcode.StripTags(HttpUtility.HtmlEncode(blogEntries[0].Body))).Trim(), 200, true));

                    List<string> images = core.Bbcode.ExtractImages(blogEntries[0].Body, blogEntries[0].Owner, false, true);

                    if (images.Count > 0)
                    {
                        page.Core.Meta.Add("twitter:image", images[0]);
                        page.Core.Meta.Add("og:image", images[0]);
                    }
                }

                core.Template.Parse("BLOGPOSTS", postsOnPage.ToString());

                if (Subscription.IsSubscribed(core, page.User.ItemKey))
                {
                    core.Template.Parse("SUBSCRIBED", "TRUE");
                }

                core.Template.Parse("U_SUBSCRIBE", core.Hyperlink.BuildSubscribeUri(page.User.ItemKey));
                core.Template.Parse("U_UNSUBSCRIBE", core.Hyperlink.BuildUnsubscribeUri(page.User.ItemKey));

                core.Template.Parse("SUBSCRIBERS", core.Functions.LargeIntegerToString(page.User.Info.Subscribers));

                string pageUri = "";
                string breadcrumbExtension = (page.User.UserInfo.ProfileHomepage == "/blog") ? "" : "blog/";

                List<string[]> breadCrumbParts = new List<string[]>();
                breadCrumbParts.Add(new string[] { "blog", core.Prose.GetString("BLOG") });

                if (!string.IsNullOrEmpty(category))
                {
                    try
                    {
                        Category cat = new Category(core, category);
                        breadCrumbParts.Add(new string[] { "categories/" + category, cat.Title });
                        pageUri = Blog.BuildUri(core, page.User, category);
                    }
                    catch (InvalidCategoryException)
                    {
                        core.Functions.Generate404();
                        return;
                    }
                }
                else if (!string.IsNullOrEmpty(tag))
                {
                    Tag currentTag = new Tag(core, tag);
                    breadCrumbParts.Add(new string[] { "tag/" + tag, currentTag.TagText });
                    pageUri = Blog.BuildTagUri(core, page.User, tag);
                }
                else
                {
                    if (year > 0)
                    {
                        breadCrumbParts.Add(new string[] { year.ToString(), year.ToString() });
                    }
                    if (month > 0)
                    {
                        breadCrumbParts.Add(new string[] { month.ToString(), core.Functions.IntToMonth(month) });
                    }
                    if (post > 0)
                    {

                        breadCrumbParts.Add(new string[] { post.ToString(), postTitle });
                    }

                    if (post > 0)
                    {
                        pageUri = Blog.BuildUri(core, page.User, year, month, post);
                    }
                    else if (month > 0)
                    {
                        pageUri = Blog.BuildUri(core, page.User, year, month);
                    }
                    else if (year > 0)
                    {
                        pageUri = Blog.BuildUri(core, page.User, year);
                    }
                    else
                    {
                        pageUri = myBlog.Uri;
                    }
                }

                page.User.ParseBreadCrumbs(breadCrumbParts);

                if (post <= 0)
                {
                    core.Display.ParseBlogPagination(core.Template, "PAGINATION", pageUri, 0, moreContent ? lastPostId : 0);
                }
                else
                {
                    core.Display.ParsePagination(pageUri, 10, comments);
                }

                page.CanonicalUri = pageUri;
            }
        }
예제 #14
0
파일: Blog.cs 프로젝트: smithydll/boxsocial
        /// <summary>
        /// Creates a new blog for the logged in user.
        /// </summary>
        /// <param name="core"></param>
        /// <returns></returns>
        public static Blog Create(Core core)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            SelectQuery query = new SelectQuery("user_blog ub");
            query.AddFields("ub.user_id");
            query.AddCondition("ub.user_id", core.LoggedInMemberId);

            if (core.Db.Query(query).Rows.Count == 0)
            {
                core.Db.UpdateQuery(string.Format("INSERT INTO user_blog (user_id) VALUES ({0});",
                        core.LoggedInMemberId));

                Blog newBlog =  new Blog(core, core.Session.LoggedInMember);

                Access.CreateAllGrantsForOwner(core, newBlog);
                newBlog.Access.CreateGrantForPrimitive(Friend.GetFriendsGroupKey(core), "VIEW", "COMMENT_ITEMS", "RATE_ITEMS");
                newBlog.Access.CreateGrantForPrimitive(User.GetEveryoneGroupKey(core), "VIEW");

                return newBlog;
            }
            else
            {
                throw new CannotCreateBlogException();
            }
        }
예제 #15
0
 public PingBack(Core core, Blog blog, long pingBackId)
     : this(core, blog, null, pingBackId)
 {
 }
예제 #16
0
        private void AccountBlogDrafts_Show(object sender, EventArgs e)
        {
            SetTemplate("account_blog_manage");

            Blog myBlog;

            try
            {
                myBlog = new Blog(core, LoggedInMember);
            }
            catch (InvalidBlogException)
            {
                myBlog = Blog.Create(core);
            }

            List<BlogEntry> blogEntries = myBlog.GetDrafts(null, null, -1, -1, -1, core.TopLevelPageNumber, 25);

            foreach (BlogEntry be in blogEntries)
            {
                VariableCollection blogVariableCollection = template.CreateChild("blog_list");

                DateTime postedTime = be.GetPublishedDate(tz);

                blogVariableCollection.Parse("COMMENTS", be.Comments.ToString());
                blogVariableCollection.Parse("TITLE", be.Title);
                blogVariableCollection.Parse("POSTED", tz.DateTimeToString(postedTime));

                blogVariableCollection.Parse("U_VIEW", core.Hyperlink.BuildBlogPostUri(LoggedInMember, postedTime.Year, postedTime.Month, be.Id));

                blogVariableCollection.Parse("U_EDIT", BuildUri("write", "edit", be.Id));
                blogVariableCollection.Parse("U_DELETE", BuildUri("write", "delete", be.Id));
            }

            core.Display.ParsePagination(template, BuildUri(), 25, myBlog.Drafts);
        }
예제 #17
0
        public BlogEntry(Core core, Blog blog, Primitive owner, DataRow postEntryRow)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(BlogEntry_ItemLoad);

            this.blog = blog;
            this.owner = owner;

            loadItemInfo(postEntryRow);
        }
예제 #18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callName"></param>
        public override void ExecuteCall(string callName)
        {
            switch (callName)
            {
                case "get_posts":
                    long userId = core.Functions.RequestLong("id", core.Session.LoggedInMember.Id);
                    int page = Math.Max(core.Functions.RequestInt("page", 1), 1);
                    int perPage = Math.Max(Math.Min(20, core.Functions.RequestInt("per_page", 10)), 1);

                    try
                    {
                        Blog blog = new Blog(core, userId);

                        List<BlogEntry> blogEntries = blog.GetEntries(string.Empty, string.Empty, 0, 0, 0, page, perPage);

                        core.Response.WriteObject(blogEntries);
                    }
                    catch (InvalidBlogException)
                    {
                    }

                    break;
                case "get_post":
                    long postId = core.Functions.RequestLong("id", 0);

                    if (postId > 0)
                    {
                        BlogEntry entry = new BlogEntry(core, postId);

                        if (entry.Access.Can("VIEW"))
                        {
                            core.Response.WriteObject(entry);
                        }
                    }
                    break;
            }
        }
예제 #19
0
        /// <summary>
        /// Creates a new blog entry
        /// </summary>
        /// <param name="core">Core token</param>
        /// <param name="blog"></param>
        /// <param name="title">Title for the new blog entry</param>
        /// <param name="body">Body for the new blog entry</param>
        /// <param name="license">License ID for the new blog entry</param>
        /// <param name="status">Publish status for the new blog entry</param>
        /// <param name="category">Category ID for the new blog entry</param>
        /// <param name="postTime">Post time for the new blog entry</param>
        /// <returns>The new blog entry retrieved from the DB</returns>
        /// <exception cref="NullCoreException">Throws exception when core token is null</exception>
        /// <exception cref="InvalidBlogException">Throws exception when blog token is null</exception>
        /// <exception cref="UnauthorisedToCreateItemException">Throws exception when unauthorised to create a new BlogEntry</exception>
        public static BlogEntry Create(Core core, AccessControlToken token, Blog blog, string title, string body, byte license, PublishStatuses status, short category, long postTime)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (blog == null)
            {
                throw new InvalidBlogException();
            }

            if (blog.UserId != core.LoggedInMemberId)
            {
                throw new UnauthorisedToCreateItemException();
            }

            /*if (!blog.Access.Can("POST_ITEMS"))
            {
            }*/

            string bodyCache = string.Empty;

            if (!body.Contains("[user") && !body.Contains("sid=true]"))
            {
                bodyCache = core.Bbcode.Parse(HttpUtility.HtmlEncode(body), null, blog.Owner, true, string.Empty, string.Empty);
            }

            long now = UnixTime.UnixTimeStamp();

            BlogEntry blogEntry = (BlogEntry)Item.Create(core, typeof(BlogEntry), new FieldValuePair("user_id", blog.UserId),
                new FieldValuePair("post_time_ut", now),
                new FieldValuePair("post_title", title),
                new FieldValuePair("post_published_ut", postTime),
                new FieldValuePair("post_modified_ut", now),
                new FieldValuePair("post_ip", core.Session.IPAddress.ToString()),
                new FieldValuePair("post_text", body),
                new FieldValuePair("post_text_cache", bodyCache),
                new FieldValuePair("post_license", license),
                new FieldValuePair("post_status", (byte)status),
                new FieldValuePair("post_category", category),
                new FieldValuePair("post_simple_permissions", true));

            AccessControlLists acl = new AccessControlLists(core, blogEntry);
            acl.SaveNewItemPermissions(token);

            return blogEntry;
        }
예제 #20
0
        void AccountBlogPreferences_Show(object sender, EventArgs e)
        {
            SetTemplate("account_blog_preferences");

            Blog myBlog;
            try
            {
                myBlog = new Blog(core, session.LoggedInMember);
            }
            catch (InvalidBlogException)
            {
                myBlog = Blog.Create(core);
            }

            List<string> permissions = new List<string>();
            permissions.Add("Can Read");
            permissions.Add("Can Comment");

            template.Parse("S_TITLE", myBlog.Title);
            //core.Display.ParsePermissionsBox(template, "S_BLOG_PERMS", myBlog.Permissions, permissions);

            Save(new EventHandler(AccountBlogPreferences_Save));
        }