usualoma
11/14/2009 - 1:58 PM

gistfile1.pl

package MT::Plugin::UserDashboard;
use strict;
use MT;
use MT::Plugin;
use base qw( MT::Plugin );

MT->add_plugin(MT::Plugin::UserDashboard->new);

sub init_registry {
    my $plugin = shift;
    $plugin->registry({
        callbacks => {
            'MT::App::CMS::template_source.dashboard' => sub {
                my ($cb, $app) = @_;

                return if $app->view ne 'user';

                my $menus = $app->registry('menus');
                foreach my $menu (values(%$menus)) {
                    if ($menu->{view}) {
                        if (ref($menu->{view})
                            ? grep($_ eq 'system', @{ $menu->{view} })
                            : $menu->{view} eq 'system'
                        ) {
                            $menu->{view} = 'user';
                        }
                    }
                }
            }
        },
   });
}

1;