| 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 | | # } |
| | 1839 | sub 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 | |