From 967346072964de6fa408b922a41b8e01ca747a2c Mon Sep 17 00:00:00 2001 From: Jay Allen Date: Sat, 25 Jul 2009 02:52:55 +0800 Subject: [PATCH] Fixed MT::Entry::set_defaults to respect a previously set entry author and also to use the HOLD constant instead of the numeric status value. Signed-off-by: Open Melody Software Group --- lib/MT/Entry.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/MT/Entry.pm b/lib/MT/Entry.pm index 11746edf9..1717efe71 100644 --- a/lib/MT/Entry.pm +++ b/lib/MT/Entry.pm @@ -674,18 +674,24 @@ sub set_defaults { my $e = shift or return; my $app = MT->instance or return; + # Entry blog takes precedence, $app->blog fallback my $blog = $app->model('blog')->load($e->blog_id) if $e->blog_id; $blog ||= $app->blog if $app and $app->can('blog'); - # $app->user is the only thing that matters - my $user = $app->user if $app and $app->can('user'); + + # API usage will almost always set the entry author directly so if + # it's not set, then it most likely means that the interaction is + # via the browser and the $app->user is the most likely author. + my $user = $e->author ? $e->author + : ($app and $app->can('user')) ? $app->user + : undef; my (%entry_defaults, %user_defaults, %blog_defaults); %entry_defaults = ( ping_count => 0, class => 'entry', - status => 0, + status => HOLD, ); if ( $user ) { @@ -707,9 +713,6 @@ sub set_defaults { } $e->set_values({ %entry_defaults, %user_defaults, %blog_defaults }); - # use Data::Dumper; - # print 'Entry default values: '.Dumper($e); - } sub save {