Skip to content

Commit

Permalink
Fixed MT::Entry::set_defaults to respect a previously set entry autho…
Browse files Browse the repository at this point in the history
…r and also to use the HOLD constant instead of the numeric status value.
  • Loading branch information
jayallen committed Jul 24, 2009
1 parent 4bf8017 commit 3bd461f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/MT/Entry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 {
Expand Down

0 comments on commit 3bd461f

Please sign in to comment.