Changeset 1713

Show
Ignore:
Timestamp:
04/02/08 09:11:01 (4 months ago)
Author:
fumiakiy
Message:

Fix templates' ids stored in plugindata table for widget managers upon restore. BugId:74983

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-33/plugins/WidgetManager/WidgetManager.pl

    r1632 r1713  
    5151            'DefaultTemplateFilter' => '$WidgetManager::MT::Plugin::WidgetManager::default_templates', 
    5252            'MT::Blog::post_create_default_templates' => '$WidgetManager::WidgetManager::Plugin::create_default_widgetsets', 
     53            'restore' => '$WidgetManager::WidgetManager::Plugin::restore_widgetmanagers', 
    5354        }, 
    5455        applications => { 
  • branches/release-33/plugins/WidgetManager/lib/WidgetManager/Plugin.pm

    r1529 r1713  
    118118} 
    119119 
     120sub restore_widgetmanagers { 
     121    my ($cb, $objects, $deferred, $errors, $callback) = @_; 
     122    my $plugin  = $cb->plugin; 
     123    my @keys = grep { $_ =~ /^MT::PluginData#/ } keys( %$objects ); 
     124    foreach my $key ( @keys ) { 
     125        my $pd = $objects->{$key}; 
     126        next unless $plugin->key eq $pd->plugin; 
     127        my $config = $pd->data; 
     128        next unless $config; 
     129        my $modulesets = $config->{modulesets}; 
     130        next unless $modulesets; 
     131 
     132        foreach my $mod_key ( keys %$modulesets ) { 
     133            $callback->( $plugin->translate( 'Restoring widgetmanager [_1]... ', $mod_key ) ); 
     134            my $tmpl_ids = $modulesets->{$mod_key}; 
     135            my @tmpl_ids = split ',', $tmpl_ids; 
     136            my @new_ids; 
     137            foreach my $id ( @tmpl_ids ) { 
     138                my $tmpl = $objects->{"MT::Template#$id"}; 
     139                next unless $tmpl; 
     140                push @new_ids, $tmpl->id; 
     141            } 
     142            $modulesets->{$mod_key} = join(',', @new_ids); 
     143            $callback->( $plugin->translate("Done.") . "\n" ); 
     144        } 
     145        $pd->data({ modulesets => $modulesets }); 
     146        $pd->save; 
     147    } 
     148    1; 
     149} 
     150 
    1201511;