Changeset 2019

Show
Ignore:
Timestamp:
04/22/08 01:21:47 (7 months ago)
Author:
bchoate
Message:

Fixes for manual status checks and overrides. BugId:79398

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-35/lib/MT/CMS/Template.pm

    r1996 r2019  
    9393          && $param->{type} ne 'widget' 
    9494          && !$param->{is_special}; 
    95         $param->{rebuild_me} = 
    96           defined $obj->rebuild_me ? $obj->rebuild_me : 1; 
    9795        $param->{search_label} = $app->translate('Templates'); 
    9896        $param->{object_type}  = 'template'; 
     
    373371          && !$param->{is_special}; 
    374372 
    375         $param->{rebuild_me} = 1; 
    376373        $param->{name}       = MT::Util::decode_url( $app->param('name') ) 
    377374          if $app->param('name'); 
     
    14541451    $app->validate_magic or return; 
    14551452 
     1453    my $blog = $app->blog; 
     1454    $app->assert( $blog ) or return; 
     1455 
     1456    # permission check 
     1457    my $perms = $app->permissions; 
     1458    return $app->errtrans("Permission denied.") 
     1459        unless $app->user->is_superuser || 
     1460            $perms->can_administer_blog || 
     1461            $perms->can_edit_templates; 
     1462 
    14561463    my $param = {}; 
    1457     my $blog = $app->blog; 
    14581464    $param->{dynamicity} = $blog->custom_dynamic_templates || 'none'; 
    14591465    $param->{screen_id} = "publishing-profile-dialog"; 
     
    17081714                        identifier => $val->{identifier}, 
    17091715                        outfile    => $val->{outfile}, 
    1710                         rebuild_me => $val->{rebuild_me} 
     1716                        rebuild_me => $val->{rebuild_me}, 
    17111717                    } 
    17121718                ); 
     
    18981904        next TEMPLATE if !defined $tmpl; 
    18991905        next TEMPLATE if $tmpl->blog_id != $blog->id; 
     1906        next TEMPLATE unless $tmpl->build_type; 
     1907 
    19001908        $app->rebuild_indexes( 
    19011909            Blog     => $blog, 
    19021910            Template => $tmpl, 
     1911            Force    => 1, 
    19031912        ); 
    19041913    } 
     
    19211930    my $templates = 
    19221931      MT->model('template')->lookup_multi( [ $app->param('id') ] ); 
    1923     use MT::TemplateMap; 
     1932    require MT::TemplateMap; 
     1933    # FIXME: Need multi-request support! 
    19241934    TEMPLATE: for my $tmpl (@$templates) { 
    19251935        next TEMPLATE if !defined $tmpl; 
     
    19271937        my @tmpl_maps = MT::TemplateMap->load( { template_id => $tmpl->id } ); 
    19281938        foreach my $map (@tmpl_maps) { 
     1939            next unless $map->build_type; 
    19291940            $app->rebuild( 
    1930                 BlogID      => $blog->id
     1941                Blog        => $blog
    19311942                ArchiveType => $map->archive_type, 
     1943                TemplateMap => $map, 
    19321944                NoIndexes   => 1, 
     1945                Force       => 1, 
    19331946            ); 
    19341947        } 
  • branches/release-35/lib/MT/WeblogPublisher.pm

    r2011 r2019  
    218218                            ArchiveType => $at, 
    219219                            NoStatic    => $param{NoStatic}, 
     220                            Force       => ($param{Force} ? 1 : 0), 
    220221                            $param{TemplateMap} 
    221222                            ? ( TemplateMap => $param{TemplateMap} ) 
     
    242243                            : (), 
    243244                            NoStatic => $param{NoStatic}, 
    244                             Author   => $entry->author 
     245                            Force    => ($param{Force} ? 1 : 0), 
     246                            Author   => $entry->author, 
    245247                        ) or return; 
    246248                    } 
     
    258260                              $param{TemplateID} ) 
    259261                        : (), 
    260                         NoStatic => $param{NoStatic} 
     262                        NoStatic => $param{NoStatic}, 
     263                        Force    => ($param{Force} ? 1 : 0), 
    261264                    ) or return; 
    262265                } 
     
    304307            : (), 
    305308            NoStatic => $param{NoStatic}, 
     309            Force    => ($param{Force} ? 1 : 0), 
    306310        ) or return; 
    307311    } 
     
    352356            : (), 
    353357            NoStatic => $param{NoStatic}, 
     358            Force    => ($param{Force} ? 1 : 0), 
    354359        ) or return; 
    355360    } 
     
    404409                        Category    => $cat, 
    405410                        NoStatic    => $param{NoStatic}, 
     411                        # Force       => ($param{Force} ? 1 : 0), 
    406412                        $param{TemplateMap} 
    407413                        ? ( TemplateMap => $param{TemplateMap} ) 
     
    419425                    : (), 
    420426                    NoStatic => $param{NoStatic}, 
     427                    # Force    => ($param{Force} ? 1 : 0), 
    421428                    Author   => $entry->author, 
    422429                ) or return; 
     
    487494                            $mt->_rebuild_entry_archive_type( 
    488495                                NoStatic => $param{NoStatic}, 
     496                                # Force    => ($param{Force} ? 1 : 0), 
    489497                                Entry    => $prev_arch, 
    490498                                Blog     => $blog, 
     
    502510                            $mt->_rebuild_entry_archive_type( 
    503511                                NoStatic => $param{NoStatic}, 
     512                                # Force    => ($param{Force} ? 1 : 0), 
    504513                                Entry    => $next_arch, 
    505514                                Blog     => $blog, 
     
    519528                        $mt->_rebuild_entry_archive_type( 
    520529                            NoStatic    => $param{NoStatic}, 
     530                            # Force       => ($param{Force} ? 1 : 0), 
    521531                            Entry       => $prev_arch, 
    522532                            Blog        => $blog, 
     
    534544                        $mt->_rebuild_entry_archive_type( 
    535545                            NoStatic    => $param{NoStatic}, 
     546                            # Force       => ($param{Force} ? 1 : 0), 
    536547                            Entry       => $next_arch, 
    537548                            Blog        => $blog, 
     
    589600                        $mt->_rebuild_entry_archive_type( 
    590601                            NoStatic    => 0, 
     602                            Force       => ($param{Force} ? 1 : 0), 
    591603                            Blog        => $blog, 
    592604                            Category    => $cat, 
     
    600612                    $mt->_rebuild_entry_archive_type( 
    601613                        NoStatic    => 0, 
     614                        Force       => ($param{Force} ? 1 : 0), 
    602615                        Blog        => $blog, 
    603616                        Category    => $cat, 
     
    616629                        $mt->_rebuild_entry_archive_type( 
    617630                            NoStatic    => 0, 
     631                            Force       => ($param{Force} ? 1 : 0), 
    618632                            Blog        => $blog, 
    619633                            Author      => $author, 
     
    627641                    $mt->_rebuild_entry_archive_type( 
    628642                        NoStatic    => 0, 
     643                        Force       => ($param{Force} ? 1 : 0), 
    629644                        Blog        => $blog, 
    630645                        Author      => $author, 
     
    638653                $mt->_rebuild_entry_archive_type( 
    639654                    NoStatic    => 0, 
     655                    Force       => ($param{Force} ? 1 : 0), 
    640656                    Blog        => $blog, 
    641657                    ArchiveType => $at, 
     
    652668                $mt->_rebuild_entry_archive_type( 
    653669                    NoStatic    => 0, 
     670                    Force       => ($param{Force} ? 1 : 0), 
    654671                    Entry       => $entry, 
    655672                    Blog        => $blog, 
     
    782799    require MT::Template; 
    783800    for my $map (@map) { 
     801        next unless $map->build_type; # ignore disabled template maps 
     802 
    784803        $mt->rebuild_file( 
    785804            $blog, $arch_root, $map, $at, $ctx, \%cond, 
     
    790809            StartDate => $start, 
    791810            EndDate   => $end, 
     811            Force     => $param{Force} ? 1 : 0, 
    792812        ) or return; 
    793813        $done->{ $map->{__saved_output_file} }++; 
     
    798818sub rebuild_file { 
    799819    my $mt = shift; 
    800     my ( $blog, $root_path, $map, $at, $ctx, $cond, $build_static, %specifier
     820    my ( $blog, $root_path, $map, $at, $ctx, $cond, $build_static, %args
    801821      = @_; 
    802822 
     
    805825    my ( $entry, $start, $end, $category, $author ); 
    806826 
    807     if ( $finfo = $specifier{FileInfo} ) { 
    808         $specifier{Author}   = $finfo->author_id   if $finfo->author_id; 
    809         $specifier{Category} = $finfo->category_id if $finfo->category_id; 
    810         $specifier{Entry}    = $finfo->entry_id    if $finfo->entry_id; 
     827    if ( $finfo = $args{FileInfo} ) { 
     828        $args{Author}   = $finfo->author_id   if $finfo->author_id; 
     829        $args{Category} = $finfo->category_id if $finfo->category_id; 
     830        $args{Entry}    = $finfo->entry_id    if $finfo->entry_id; 
    811831        $map ||= MT::TemplateMap->load( $finfo->templatemap_id ); 
    812832        $at  ||= $finfo->archive_type; 
    813833        if ( $finfo->startdate ) { 
    814834            if ( my ( $start, $end ) = $archiver->date_range($finfo->startdate) ) { 
    815                 $specifier{StartDate} = $start; 
    816                 $specifier{EndDate}   = $end; 
     835                $args{StartDate} = $start; 
     836                $args{EndDate}   = $end; 
    817837            } 
    818838        } 
     
    835855 
    836856    if ( $archiver->category_based ) { 
    837         $category = $specifier{Category}; 
     857        $category = $args{Category}; 
    838858        die "Category archive type requires Category parameter" 
    839           unless $specifier{Category}; 
     859          unless $args{Category}; 
    840860        $category = MT::Category->load($category) 
    841861          unless ref $category; 
     
    844864    } 
    845865    if ( $archiver->entry_based ) { 
    846         $entry = $specifier{Entry}; 
     866        $entry = $args{Entry}; 
    847867        die "$at archive type requires Entry parameter" 
    848868          unless $entry; 
     
    854874    if ( $archiver->date_based ) { 
    855875        # Date-based archive type 
    856         $start = $specifier{StartDate}; 
    857         $end   = $specifier{EndDate}; 
     876        $start = $args{StartDate}; 
     877        $end   = $args{EndDate}; 
    858878        Carp::confess("Date-based archive types require StartDate parameter") 
    859           unless $specifier{StartDate}; 
     879          unless $args{StartDate}; 
    860880        $ctx->var( 'datebased_archive', 1 ); 
    861881    } 
     
    863883 
    864884        # author based archive type 
    865         $author = $specifier{Author}; 
     885        $author = $args{Author}; 
    866886        die "Author-based archive type requires Author parameter" 
    867           unless $specifier{Author}; 
     887          unless $args{Author}; 
    868888        require MT::Author; 
    869889        $author = MT::Author->load($author) 
     
    10041024    return 1 if ( $tmpl->build_dynamic ); 
    10051025    return 1 if ( $entry && $entry->status != MT::Entry::RELEASE() ); 
     1026    return 1 unless ( $tmpl->build_type ); 
    10061027 
    10071028    my $timer = MT->get_timer; 
     
    10351056            Category     => $category, 
    10361057            category     => $category, 
     1058            force        => ($args{Force} ? 1 : 0), 
    10371059        ) 
    10381060      ) 
    10391061    { 
     1062 
    10401063        if ( $archiver->group_based ) { 
    10411064            require MT::Promise; 
     
    12201243        ); 
    12211244    } 
     1245    my $force = $param{Force}; 
     1246 
    12221247    local *FH; 
    12231248    my $site_root = $blog->site_path; 
     
    12351260        ## Note that dynamic templates do need to be "rebuilt"--the 
    12361261        ## FileInfo table needs to be maintained. 
    1237         if ( !$tmpl->build_dynamic && !$param{Force} ) { 
     1262        if ( !$tmpl->build_dynamic && !$force ) { 
    12381263            next if ( defined $tmpl->rebuild_me && !$tmpl->rebuild_me ); 
    12391264        } 
     1265        next if ( defined $tmpl->build_type && !$tmpl->build_type ); 
     1266 
    12401267        my $file = $tmpl->outfile; 
    12411268        $file = '' unless defined $file; 
     
    12981325 
    12991326        next if ( $tmpl->build_dynamic ); 
     1327        next unless ( $tmpl->build_type ); 
    13001328 
    13011329        ## We're not building dynamically, so if the FileInfo is currently 
     
    13281356                template     => $tmpl, 
    13291357                File         => $file, 
    1330                 file         => $file 
     1358                file         => $file, 
     1359                force        => $force, 
    13311360            ) 
    13321361          ); 
     
    17781807    require MT::PublishOption; 
    17791808    my $throttle = MT::PublishOption::get_throttle($fi); 
     1809 
     1810    # Prevent building of disabled templates if they get this far 
    17801811    return 0 if $throttle->{type} == MT::PublishOption::DISABLED(); 
     1812 
     1813    # Check for 'force' flag for 'manual' publish option, which 
     1814    # forces the template to build; used for 'rebuild' list actions 
     1815    # and publish site operations 
     1816    if ($throttle->{type} == MT::PublishOption::MANUALLY()) { 
     1817        return $args{force} ? 1 : 0; 
     1818    } 
     1819 
     1820    # From here on, we're committed to publishing this file via TheSchwartz 
    17811821    return 1 if $throttle->{type} != MT::PublishOption::ASYNC(); 
    17821822 
     
    19852025=back 
    19862026 
    1987 =head2 $mt->rebuild_file($blog, $archive_root, $map, $archive_type, $ctx, \%cond, $build_static, %specifier
     2027=head2 $mt->rebuild_file($blog, $archive_root, $map, $archive_type, $ctx, \%cond, $build_static, %args
    19882028 
    19892029Method responsible for building a single archive page from a template and 
     
    20002040created and that is all). 
    20012041 
    2002 I<%specifier> is a hash that uniquely identifies the specific instance 
     2042I<%args> is a hash that uniquely identifies the specific instance 
    20032043of the given archive type. That is, for a category archive page it 
    20042044identifies the category; for a date-based archive page it identifies 
    20052045which time period is covered by the page; for an individual archive it 
    2006 identifies the entry. I<%specifier> should contain just one of these 
     2046identifies the entry. I<%args> should contain just one of these 
    20072047keys: 
    20082048