void ga_AfterInsert(DataBuddyBase dataObject, EventArgs e)
        {
            Post post = dataObject as Post;

            if (post != null)
            {
                // Check that post
                //  1. Is Published
                //  2. The current verison is set to be published
                //  3. Is not a future dated post
                if (post.IsPublished && post.PostStatus == PostStatus.Publish && post.Published.CompareTo(DateTime.UtcNow.AddMinutes(1.0)) <= 0)
                {
                    // Blog Pings
                    if (EnablePings)
                    {
                        XmlRpcPings.SendPings(post, PingUrls);
                    }

                    // Check for links to send Trackbacks & Pingbacks
                    if (EnableTrackbacks)
                    {
                        LinkParser.CheckPost(post);
                    }
                }
            }
        }
Exemple #2
0
        internal void Post_Validate(DataBuddyBase dataObject, EventArgs e)
        {
            if (!EnableEventHandlers)
            {
                return;
            }

            Post post = dataObject as Post;

            if (post == null)
            {
                return;
            }

            if (!_postRepository.GetCategoryNameOf(post).Equals(CategoryName, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var validation = IoC.Resolve <ITalkValidator>(this).Validate(post).Interpret();

            if (validation.Failed)
            {
                validation.ThrowAsException();
            }
        }
        void ga_AfterUpdate(DataBuddyBase dataObject, EventArgs e)
        {
            Post post = dataObject as Post;

            if (post != null)
            {
                // Check that post
                //  1. Is Published
                //  2. The current verison is set to be published
                //  3. Was not published within the last 10 seconds (some plugins update the post immediately after it is created,
                //     which can cause double trackbacks/pings)
                if (post.IsPublished && post.PostStatus == PostStatus.Publish && post.Published.CompareTo(DateTime.UtcNow.AddSeconds(-10.0)) <= 0)
                {
                    // Blog Pings
                    if (EnablePings)
                    {
                        XmlRpcPings.SendPings(post, PingUrls);
                    }

                    // Check for links to send Trackbacks & Pingbacks
                    if (EnableTrackbacks)
                    {
                        LinkParser.CheckPost(post);
                    }
                }
            }
        }
        protected override void Establish_context()
        {
            _sut = new EventPlugin(MockRepository.GenerateMock <IPostRepository>(),
                                   MockRepository.GenerateMock <IMapper <NameValueCollection, Settings> >(),
                                   MockRepository.GenerateMock <IValidator <Settings> >());

            _post = MockRepository.GenerateStub <DataBuddyBase>();
        }
        protected override void Establish_context()
        {
            base.Establish_context();

            _sut = Container.Create <TalkPlugin>();

            _post = MockRepository.GenerateStub <DataBuddyBase>();

            Mocks.ReplayAll();
        }
Exemple #6
0
        private void ga_AfterInsert(DataBuddyBase dataObject, EventArgs e)
        {
            //Only handle posts
            Post p = dataObject as Post;

            //We only only want post which are non-uncategorized and are not published in the future.
            if (p != null && p.PostStatus == PostStatus.Publish && (!SiteSettings.Get().FilterUncategorizedPostsFromLists || p.CategoryId != CategoryController.UnCategorizedId))
            {
                PostInserted(p);
            }
        }
Exemple #7
0
        void ga_BeforeUpdate(DataBuddyBase dataObject, EventArgs e)
        {
            Post p = dataObject as Post;

            if (p != null)
            {
                Post oldPost = new Post(p.Id);
                if (p.PostStatus != oldPost.PostStatus)
                {
                    GraffitiContext.Current["postBeingUpdated"] = oldPost;
                }
            }
        }
Exemple #8
0
        void ga_AfterUpdate(DataBuddyBase dataObject, EventArgs e)
        {
            Post p = dataObject as Post;

            if (p != null && p.PostStatus == PostStatus.Publish)
            {
                Post oldPost = GraffitiContext.Current["postBeingUpdated"] as Post;
                if (oldPost != null && oldPost.PostStatus != PostStatus.Publish)
                {
                    PostInserted(p);
                }
            }
        }
        internal void Post_SetDefaultValues(DataBuddyBase dataObject, EventArgs e)
        {
            if (!EnableEventHandlers)
            {
                return;
            }

            Post post = dataObject as Post;

            if (post == null)
            {
                return;
            }

            if (!_postRepository.GetCategoryNameOf(post).Equals(CategoryName, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // Set default location if no location is given.
            if (!post[LocationUnknownField].IsSelected() && post[LocationField].IsNullOrEmpty())
            {
                post[LocationField] = DefaultLocation;
                post.ForcePropertyUpdate();
            }

            // Set default number maximum number of registrations.
            if (post[MaximumNumberOfRegistrationsField].IsNullOrEmpty())
            {
                post[MaximumNumberOfRegistrationsField] = DefaultMaximumNumberOfRegistrations;
                post.ForcePropertyUpdate();
            }

            // Set default registration recipient.
            if (post[RegistrationRecipientField].IsNullOrEmpty())
            {
                post[RegistrationRecipientField] = DefaultRegistrationRecipient;
                post.ForcePropertyUpdate();
            }
        }