Show
Ignore:
Timestamp:
04/07/08 09:10:54 (20 months ago)
Author:
auno
Message:

Added publish button and pulldown option on template listing. BugzID:75100

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-33/lib/MT/CMS/Template.pm

    r1775 r1786  
    505505    require MT::Template; 
    506506    my $blog_id = $app->param('blog_id') || 0; 
    507     # my $filter  = $app->param('filter_key'); 
    508     # if ( !$filter ) { 
    509     #     if ($blog) { 
    510     #         $filter = 'templates'; 
    511     #         $app->param( 'filter_key', 'templates' ); 
    512     #     } 
    513     #     else { 
    514     #         $filter = 'module_templates'; 
    515     #         $app->param( 'filter_key', 'module_templates' ); 
    516     #     } 
    517     # } 
    518     # else { 
    519     #     # global index templates redirect to module templates 
    520     #     if ( !$blog && $filter eq 'templates' ) { 
    521     #         $filter = 'module_templates'; 
    522     #         $app->param( 'filter_key', 'module_templates' ); 
    523     #     } 
    524     # } 
    525507    my $terms = { blog_id => $blog_id }; 
    526508    my $args  = { sort    => 'name' }; 
     
    564546    my $params        = {}; 
    565547    my $filter = $app->param('filter_key'); 
    566     $app->delete_param('filter_key') if $filter; 
    567548    my $template_type = $filter || ''; 
    568549    $template_type =~ s/_templates//; 
     
    654635    } 
    655636    foreach my $tmpl_type (@types) { 
     637        $app->delete_param('filter_key') if $filter; 
     638        if ( $tmpl_type eq 'index' ) { 
     639            $filter = 'index_templates'; 
     640            $app->param( 'filter_key', 'index_templates' ); 
     641        } 
     642        elsif ( $tmpl_type eq 'archive' ) { 
     643            $filter = 'archive_templates'; 
     644            $app->param( 'filter_key', 'archive_templates' ); 
     645        } 
    656646        $terms->{type} = $types{$tmpl_type}->{type}; 
    657647        my $tmpl_param = $app->listing( 
     
    18471837} 
    18481838 
     1839sub publish_archive_templates { 
     1840    my $app = shift; 
     1841    $app->validate_magic or return; 
     1842 
     1843    # permission check 
     1844    my $perms = $app->permissions; 
     1845    return $app->errtrans("Permission denied.") 
     1846      unless $app->user->is_superuser 
     1847      || $perms->can_administer_blog 
     1848      || $perms->can_rebuild; 
     1849 
     1850    my $blog = $app->blog; 
     1851    my $templates = 
     1852      MT->model('template')->lookup_multi( [ $app->param('id') ] ); 
     1853    use MT::TemplateMap; 
     1854    TEMPLATE: for my $tmpl (@$templates) { 
     1855        next TEMPLATE if !defined $tmpl; 
     1856        next TEMPLATE if $tmpl->blog_id != $blog->id; 
     1857        my @tmpl_maps = MT::TemplateMap->load( { template_id => $tmpl->id } ); 
     1858        foreach my $map (@tmpl_maps) { 
     1859            $app->rebuild( 
     1860                BlogID      => $blog->id, 
     1861                ArchiveType => $map->archive_type, 
     1862                NoIndexes   => 1, 
     1863            ); 
     1864        } 
     1865    } 
     1866 
     1867    $app->call_return( published => 1 ); 
     1868} 
     1869 
    18491870{ 
    18501871    my @period_options = (