Changeset 1503 for trunk

Show
Ignore:
Timestamp:
03/23/09 22:47:05 (12 months ago)
Author:
breese
Message:

added config assistant hooks for enabling/disabling "Create Entry" button and menu items

Location:
trunk/PhotoGallery/plugins/PhotoGallery
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/PhotoGallery/plugins/PhotoGallery/PhotoGallery.pl

    r1502 r1503  
    3939                $$output_ref =~ s/\bYour category\b/\bYour photo album\b/g; 
    4040            }, 
     41            'MT::App::CMS::template_source.header' => sub { 
     42                my ($cb, $app, $html_ref) = @_; 
     43                return unless $plugin->in_gallery &&  
     44                    $plugin->get_config_value('suppress_create_entry','blog:'.$app->blog->id); 
     45                $$html_ref =~ s{<li id="create-entry" class="nav-link">.*</a></li>}{};; 
     46            }, 
    4147        }, 
    4248        applications => { 
     
    5662            }, 
    5763        },  
    58          
     64        blog_config_template => '<mt:PluginConfigForm id="PhotoGallery">', 
     65        settings => { 
     66            'suppress_create_entry' => { 
     67                scope => 'blog', 
     68            }, 
     69        }, 
     70        plugin_config => { 
     71            'PhotoGallery' => { 
     72                'fieldset1' => { 
     73                    'suppress_create_entry' => { 
     74                        type => 'checkbox', 
     75                        label => 'Suppress Create Entry button and menu items for this blog?', 
     76                        tag => 'IfSuppressCreateEntry?', 
     77                    }, 
     78                }, 
     79            }, 
     80        }, 
    5981        template_sets => { 
    6082            'mid-century-photo-gallery' => { 
  • trunk/PhotoGallery/plugins/PhotoGallery/lib/PhotoGallery/Plugin.pm

    r1502 r1503  
    6161        foreach my $key (keys %$menus) { 
    6262            if ($key =~ /^create:/) { 
    63                 delete $menus->{$key}; 
     63                my $blog = (MT::App->instance->blog ? MT::App->instance->blog : undef); 
     64                unless ( 
     65                    $key =~ /entry/ && $blog && MT->component('PhotoGallery')->get_config_value('suppress_create_entry','blog:'.$blog->id) 
     66                    ) {  
     67                    delete $menus->{$key}; 
     68                } 
    6469            } 
    6570        }