Show
Ignore:
Timestamp:
04/17/08 22:43:48 (20 months ago)
Author:
bchoate
Message:

Fixes for propogation of build_type from template to templatemaps. BugId:79370

Files:
1 modified

Legend:

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

    r1949 r1957  
    291291        return $tmpl->error(MT->translate('Template with the same name already exists in this blog.')); 
    292292    } 
     293 
     294    if ($tmpl->id && ($tmpl->is_changed('build_type'))) { 
     295        # check for templatemaps, and update them appropriately 
     296        require MT::TemplateMap; 
     297        require MT::PublishOption; 
     298        my @maps = MT::TemplateMap->load({ template_id => $tmpl->id }); 
     299        foreach my $map (@maps) { 
     300            $map->build_type($tmpl->build_type); 
     301            $map->save or die $map->errstr; 
     302        } 
     303    } 
     304 
    293305    if ($tmpl->linked_file) { 
    294306        $tmpl->_sync_to_disk($tmpl->SUPER::text) or return; 
    295307    } 
    296308    $tmpl->{needs_db_sync} = 0; 
    297     if ((!$tmpl->id) && (my $blog = $tmpl->blog)) { 
    298         my $dcty = $blog->custom_dynamic_templates; 
    299         if ($dcty eq 'all') { 
    300             if (('index' eq $tmpl->type) || ('archive' eq $tmpl->type) || 
    301                 ('individual' eq $tmpl->type) || ('page' eq $tmpl->type) || 
    302                     ('category' eq $tmpl->type)) { 
    303                 $tmpl->build_dynamic(1); 
    304             } 
    305         } elsif ($dcty eq 'archives') { 
    306             if (('archive' eq $tmpl->type) || ('page' eq $tmpl->type) || 
    307                 ('individual' eq $tmpl->type) || ('category' eq $tmpl->type)) { 
    308                 $tmpl->build_dynamic(1); 
    309             } 
    310         } 
    311     } 
     309 
     310    # if ((!$tmpl->id) && (my $blog = $tmpl->blog)) { 
     311    #     my $dcty = $blog->custom_dynamic_templates; 
     312    #     if ($dcty eq 'all') { 
     313    #         if (('index' eq $tmpl->type) || ('archive' eq $tmpl->type) || 
     314    #             ('individual' eq $tmpl->type) || ('page' eq $tmpl->type) || 
     315    #                 ('category' eq $tmpl->type)) { 
     316    #             $tmpl->build_dynamic(1); 
     317    #         } 
     318    #     } elsif ($dcty eq 'archives') { 
     319    #         if (('archive' eq $tmpl->type) || ('page' eq $tmpl->type) || 
     320    #             ('individual' eq $tmpl->type) || ('category' eq $tmpl->type)) { 
     321    #             $tmpl->build_dynamic(1); 
     322    #         } 
     323    #     } 
     324    # } 
     325 
    312326    $tmpl->SUPER::save; 
     327} 
     328 
     329sub build_dynamic { 
     330    my $tmpl = shift; 
     331    require MT::PublishOption; 
     332    if (@_) { 
     333        $tmpl->build_type($_[0] ? MT::PublishOption::DYNAMIC() : MT::PublishOption::ONDEMAND()); 
     334    } 
     335    return 1 if $tmpl->build_type == MT::PublishOption::DYNAMIC(); 
    313336} 
    314337