<% &main::checkPermissions("","PERMISSIONS"); $screenTitle="Manage Plugins"; $dir = $main::plugins_dir; # Get the list of currently-installed plugins and their status open(PLUGINS,$dir."plugins.txt"); $order=0; while () { next if /^#/; next if /^\s*$/; chomp; ($plugin,$status) = split(/\t/); $plugins->{$plugin}->{'status'} = $status; $plugins->{$plugin}->{'order'} = $order++; } close(PLUGINS); # Get the list of all plugins opendir(PLUGINS,$dir); while($f = readdir(PLUGINS)) { if (($f !~ /^\.\.?$/) && (-d $dir.$f)) { push(@plugin_list,$f); unless (defined $plugins->{$f}) { $plugins->{$f}->{'status'} = 0; $plugins->{$f}->{'order'} = $order++; } } } closedir(PLUGINS); # Get all files in all plugin directories foreach $plugin (@plugin_list) { opendir(PLUGIN, $dir.$plugin); while($f = readdir(PLUGIN)) { if ( $f !~ /^\.\.?$/ ) { if ($f ne "readme.txt" && $f ne "command_list.txt" && $f ne "permissions_list.txt") { $plugins->{$plugin}->{'files'}->{$f} = 1; } } # Grab into from the readme, if it's there if ( $f =~ /^readme\.txt$/i ) { open(README,$dir.$plugin."/".$f); while () { next if /^#/; next if /^\s*$/; chomp; ($label,$text) = split(/:/,$_,2); $plugins->{$plugin}->{'readme'}->{lc($label)} = $text; } close(README); } } closedir(PLUGIN); } # Handle actions if ($main::in{command} =~ /^plugin_move_up|plugin_move_down|plugin_enable|plugin_disable$/) { my ($plugin,$plugin_order,$plugin_status); $plugin = $main::in{'plugin'}; $plugin_order = $main::in{'plugin_order'}; $plugin_status = $main::in{'plugin_status'}; if ($main::in{command} eq "plugin_enable") { $plugins->{$plugin}->{'status'} = 1; } if ($main::in{command} eq "plugin_disable") { $plugins->{$plugin}->{'status'} = 0; } if ($main::in{command} eq "plugin_move_up") { $plugins->{$plugin}->{'order'} -= 1.5; } if ($main::in{command} eq "plugin_move_down") { $plugins->{$plugin}->{'order'} += 1.5; } # Write out the plugin files used by calendar_admin open(PLUGINS,">${dir}plugins.txt"); open(COMMANDS,">${dir}command_list.txt"); open(PERMISSIONS,">${dir}permissions_list.txt"); open(FILES,">${dir}plugin_files.txt"); $order = 0; my ($files); my ($commands); my ($permissions); foreach $plugin (sort {$plugins->{$a}->{'order'} <=> $plugins->{$b}->{'order'}} keys %$plugins) { print PLUGINS "$plugin\t",$plugins->{$plugin}->{'status'},"\n"; $plugins->{$plugin}->{'order'} = $order++; if ($plugins->{$plugin}->{'status'}) { my ($command_list_file) = $dir.$plugin."/command_list.txt"; my ($permissions_list_file) = $dir.$plugin."/permissions_list.txt"; if (-e $command_list_file) { open(PLUGIN_COMMAND_LIST, $command_list_file); while() { next if /^#/; next if /^\s*$/; chomp; print COMMANDS "$_\n"; } close(PLUGIN_COMMAND_LIST); } if (-e $permissions_list_file) { open(PERMISSIONS_COMMAND_LIST, $permissions_list_file); while() { next if /^#/; next if /^\s*$/; chomp; print PERMISSIONS "$_\n";; } close(PERMISSIONS_COMMAND_LIST); } foreach $f (keys %{$plugins->{$plugin}->{'files'}}) { print FILES "$f\t$plugin\n"; } } } close(FILES); close(PERMISSIONS); close(COMMANDS); close(PLUGINS); } %> Calendar Administration : <%= $screenTitle %> ">
<% if ($#plugin_list < 0) { %> There are no plugins currently installed <% } else { %> <% foreach $plugin (sort {$plugins->{$a}->{'order'} cmp $plugins->{$b}->{'order'}} keys %$plugins) { %> <% } %>
The plugins below are currently installed. They will be processed in the order shown. Any functionality that is common between plugins will be handled by the plugin that is higher in the list. Only plugins which are enabled will have an effect on the application.
<% if ($plugins->{$plugin}->{'order'} > 0) { %>
Move Up <% } %> <% if ($plugins->{$plugin}->{'order'} < $#plugin_list) { %>
Move Down <% } %>  
Name: <%= $plugins->{$plugin}->{'readme'}->{'name'} %>
Description: <%= $plugins->{$plugin}->{'readme'}->{'description'} %>
Author: <%= $plugins->{$plugin}->{'readme'}->{'author'} %> (<%= $plugins->{$plugin}->{'readme'}->{'author_email'} %>)
URL: <%= $plugins->{$plugin}->{'readme'}->{'url'} %>
Status: <% if ($plugins->{$plugin}->{'status'}) { %> Enabled (Disable) <% } else { %> Disabled (Enable) <% } %>

<% } %>