View | Details | Raw Unified | Return to bug 7804
Collapse All | Expand All

(-)a/C4/Auth.pm (+1 lines)
Lines 202-207 sub get_template_and_user { Link Here
202
            $template->param( CAN_user_serials          => 1 );
202
            $template->param( CAN_user_serials          => 1 );
203
            $template->param( CAN_user_reports          => 1 );
203
            $template->param( CAN_user_reports          => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
205
            $template->param( CAN_user_plugins          => 1 );
205
            foreach my $module (keys %$all_perms) {
206
            foreach my $module (keys %$all_perms) {
206
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
207
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
207
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
208
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
(-)a/C4/Installer/PerlDependencies.pm (+15 lines)
Lines 484-489 our $PERL_DEPS = { Link Here
484
        'required' => '1',
484
        'required' => '1',
485
        'min_ver'  => '0.09',
485
        'min_ver'  => '0.09',
486
      },
486
      },
487
    'Config::Simple' => {
488
        'usage'    => 'Plugins',
489
        'required' => '0',
490
        'min_ver'  => '4.59',
491
      },
492
    'File::Temp' => {
493
        'usage'    => 'Plugins',
494
        'required' => '0',
495
        'min_ver'  => '0.22',
496
      },
497
    'File::Copy' => {
498
        'usage'    => 'Plugins',
499
        'required' => '0',
500
        'min_ver'  => '2.08',
501
      },
487
};
502
};
488
503
489
1;
504
1;
(-)a/C4/Plugins.pm (+158 lines)
Line 0 Link Here
1
package C4::Plugins;
2
3
# Copyright 2010 Kyle Hall
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along with
17
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18
# Suite 330, Boston, MA  02111-1307 USA
19
20
use strict;
21
use warnings;
22
23
use CGI;
24
use Config::Simple;
25
26
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
27
28
use C4::Context;
29
use C4::Output;
30
use C4::Dates;
31
use C4::Debug;
32
33
BEGIN {
34
	# set the version for version checking
35
	$VERSION = 0.01;
36
	require Exporter;
37
	@ISA = qw(Exporter);
38
	@EXPORT = qw(
39
		GetPlugins
40
		GetPluginsDir
41
	);
42
}
43
44
=head1 NAME
45
   
46
C4::Plugins - Module for loading and managing plugins.
47
48
=head1 SYNOPSIS
49
50
  use C4::Plugins;
51
52
=over 2
53
54
=cut
55
56
=item GetPlugins()
57
58
This will return a list of all the available plugins of the passed type.
59
60
Usage: my ( $plugins_hasref, $plugins_count ) = C4::Plugins::GetPlugins( $type );
61
62
At the moment, the available types are 'report' and 'tool'.
63
=cut
64
65
sub GetPlugins {
66
	my ( $type ) = @_;
67
	my @plugins_ini = _GetPluginIniFiles();
68
	my $version = C4::Context->preference("Version");
69
	
70
	my @plugins;
71
	foreach my $plugin_ini ( @plugins_ini ) {
72
		my $ini_hashref = _ParsePluginIni( $plugin_ini );
73
		if ( ( defined $type && $ini_hashref->{'type'} eq $type ) || ! defined $type ) {
74
			$ini_hashref->{'date_updated'} = C4::Dates->new( $ini_hashref->{'date_updated'}, "iso")->output();
75
			if ( $ini_hashref->{'minimum_version'} > $version ) {
76
				$ini_hashref->{'db_version_too_old'} = 1;
77
			}
78
			push( @plugins, $ini_hashref );
79
		}
80
	}
81
82
	@plugins = sort { $a->{name} cmp $b->{name} } @plugins;
83
84
	my $count = @plugins;
85
	return ( \@plugins, $count );
86
}
87
88
=item GetPluginsDir()
89
90
Returns the path of the plugins directory.
91
92
=cut
93
94
sub GetPluginsDir {
95
	return C4::Context->config("pluginsdir");
96
}
97
98
=item _GetPluginIniFiles()
99
100
This will return an array of all the ini files for the custom plugins.
101
102
=cut
103
104
sub _GetPluginIniFiles {
105
        my $plugins_dir = GetPluginsDir();
106
	opendir(DIRHANDLE, $plugins_dir);
107
	my @plugins_dirs = readdir(DIRHANDLE);
108
	closedir(DIRHANDLE);
109
	
110
	my @plugins;
111
	foreach my $plugin_dir ( @plugins_dirs ) {
112
113
		my $plugin_path = $plugins_dir . '/' . $plugin_dir;
114
		if ( -d $plugin_path ) {
115
			my $ini_path = $plugin_path . '/plugin.ini';
116
117
			if ( -f $ini_path ) {
118
				push( @plugins, $ini_path );
119
	                }
120
121
		}
122
123
	}
124
125
	return ( @plugins );
126
}
127
128
=item _ParsePluginIni( $ini_path )
129
130
This will return a hasref of key/value pairs found in the ini file
131
132
=cut
133
134
sub _ParsePluginIni {
135
	my ( $ini_path ) = @_;
136
137
	my $ini;
138
	
139
	open( INIFILE, '<', $ini_path ) or die("Could not open file $ini_path");
140
	foreach my $line ( <INIFILE> ) {
141
		my ( $key, $value );
142
		( $key, $value ) = split(/=/, $line );
143
		$ini->{$key} = $value;
144
	}
145
	
146
	return $ini;
147
}
148
149
1;
150
__END__
151
152
=back
153
154
=head1 AUTHOR
155
156
Kyle M Hall <kyle.m.hall@gmail.com>
157
158
=cut
(-)a/Makefile.PL (-1 / +8 lines)
Lines 226-231 command-line, e.g., READMEs. Link Here
226
226
227
Directory for Apache and Zebra logs produced by Koha.
227
Directory for Apache and Zebra logs produced by Koha.
228
228
229
=item PLUGINS_DIR
230
231
Directory for external Koha plugins.
232
229
=item PAZPAR2_CONF_DIR
233
=item PAZPAR2_CONF_DIR
230
234
231
Directory for PazPar2 configuration files.
235
Directory for PazPar2 configuration files.
Lines 1204-1209 sub get_target_directories { Link Here
1204
        $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
1208
        $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
1205
        $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
1209
        $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
1206
        $dirmap{'LOG_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'log');
1210
        $dirmap{'LOG_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'log');
1211
        $dirmap{'PLUGINS_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'lib', 'koha', 'plugins');
1207
        $dirmap{'ZEBRA_DATA_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
1212
        $dirmap{'ZEBRA_DATA_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
1208
        $dirmap{'ZEBRA_RUN_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
1213
        $dirmap{'ZEBRA_RUN_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
1209
    } elsif ($mode eq 'dev') {
1214
    } elsif ($mode eq 'dev') {
Lines 1233-1238 sub get_target_directories { Link Here
1233
        $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
1238
        $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
1234
        $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
1239
        $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
1235
        $dirmap{'LOG_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'log');
1240
        $dirmap{'LOG_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'log');
1241
        $dirmap{'PLUGINS_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'lib', 'koha', 'plugins');
1236
        $dirmap{'ZEBRA_DATA_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
1242
        $dirmap{'ZEBRA_DATA_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
1237
        $dirmap{'ZEBRA_RUN_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
1243
        $dirmap{'ZEBRA_RUN_DIR'} =  File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
1238
    } else {
1244
    } else {
Lines 1254-1259 sub get_target_directories { Link Here
1254
        $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
1260
        $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
1255
        $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'zebradb');
1261
        $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'zebradb');
1256
        $dirmap{'LOG_DIR'} =  File::Spec->catdir(File::Spec->rootdir(), 'var', 'log', $package);
1262
        $dirmap{'LOG_DIR'} =  File::Spec->catdir(File::Spec->rootdir(), 'var', 'log', $package);
1263
        $dirmap{'PLUGINS_DIR'} =  File::Spec->catdir(File::Spec->rootdir(), 'var', 'lib', $package, 'plugins');
1257
        $dirmap{'ZEBRA_DATA_DIR'} =  File::Spec->catdir(File::Spec->rootdir(), 'var', 'lib', $package, 'zebradb');
1264
        $dirmap{'ZEBRA_DATA_DIR'} =  File::Spec->catdir(File::Spec->rootdir(), 'var', 'lib', $package, 'zebradb');
1258
        $dirmap{'ZEBRA_RUN_DIR'} =  File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'zebradb');
1265
        $dirmap{'ZEBRA_RUN_DIR'} =  File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'zebradb');
1259
    }
1266
    }
Lines 1525-1531 make_upgrade_backup :: Link Here
1525
\t\$(NOECHO) umask 022; \$(MOD_BACKUP) \\
1532
\t\$(NOECHO) umask 022; \$(MOD_BACKUP) \\
1526
/;
1533
/;
1527
    foreach my $key (qw/KOHA_CONF_DIR INTRANET_TMPL_DIR INTRANET_WWW_DIR OPAC_TMPL_DIR OPAC_WWW_DIR
1534
    foreach my $key (qw/KOHA_CONF_DIR INTRANET_TMPL_DIR INTRANET_WWW_DIR OPAC_TMPL_DIR OPAC_WWW_DIR
1528
                     PAZPAR2_CONF_DIR ZEBRA_CONF_DIR/) {
1535
                     PAZPAR2_CONF_DIR ZEBRA_CONF_DIR PLUGINS_DIR/) {
1529
    	$upgrade .= "\t\t\$(KOHA_INST_$key) \$(KOHA_DEST_$key) \\\n"
1536
    	$upgrade .= "\t\t\$(KOHA_INST_$key) \$(KOHA_DEST_$key) \\\n"
1530
            unless ($config{'INSTALL_ZEBRA'} ne "yes" and $key =~ /ZEBRA/) or
1537
            unless ($config{'INSTALL_ZEBRA'} ne "yes" and $key =~ /ZEBRA/) or
1531
                   exists $skip_directories->{$key} or
1538
                   exists $skip_directories->{$key} or
(-)a/etc/koha-conf.xml (+1 lines)
Lines 266-271 __PAZPAR2_TOGGLE_XML_POST__ Link Here
266
 <biblioservershadow>1</biblioservershadow>
266
 <biblioservershadow>1</biblioservershadow>
267
 <authorityserver>authorities</authorityserver>
267
 <authorityserver>authorities</authorityserver>
268
 <authorityservershadow>1</authorityservershadow>
268
 <authorityservershadow>1</authorityservershadow>
269
 <pluginsdir>__PLUGINS_DIR__</pluginsdir>
269
 <intranetdir>__INTRANET_CGI_DIR__</intranetdir>
270
 <intranetdir>__INTRANET_CGI_DIR__</intranetdir>
270
 <opacdir>__OPAC_CGI_DIR__/opac</opacdir>
271
 <opacdir>__OPAC_CGI_DIR__/opac</opacdir>
271
 <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs>
272
 <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs>
(-)a/etc/koha-httpd.conf (+1 lines)
Lines 102-107 Link Here
102
   DocumentRoot __INTRANET_WWW_DIR__
102
   DocumentRoot __INTRANET_WWW_DIR__
103
   ServerName __WEBSERVER_HOST__:__WEBSERVER_PORT_LIBRARIAN__
103
   ServerName __WEBSERVER_HOST__:__WEBSERVER_PORT_LIBRARIAN__
104
#  ServerAlias intranet.mydomain.com
104
#  ServerAlias intranet.mydomain.com
105
   ScriptAlias /cgi-bin/koha/plugins/run "__PLUGINS_DIR__/"
105
   ScriptAlias /cgi-bin/koha/ "__INTRANET_CGI_DIR__/"
106
   ScriptAlias /cgi-bin/koha/ "__INTRANET_CGI_DIR__/"
106
   ScriptAlias /index.html "__INTRANET_CGI_DIR__/mainpage.pl"
107
   ScriptAlias /index.html "__INTRANET_CGI_DIR__/mainpage.pl"
107
   ScriptAlias /search "__INTRANET_CGI_DIR__/search.pl"
108
   ScriptAlias /search "__INTRANET_CGI_DIR__/search.pl"
(-)a/install_misc/debian.packages (+1 lines)
Lines 109-111 make install Link Here
109
mysql-server install
109
mysql-server install
110
yaz-doc	install
110
yaz-doc	install
111
yaz	install
111
yaz	install
112
libconfig-simple-perl install
(-)a/install_misc/ubuntu.packages (+1 lines)
Lines 120-122 libxml-simple-perl install Link Here
120
libxml-xslt-perl			install
120
libxml-xslt-perl			install
121
libyaml-perl				install
121
libyaml-perl				install
122
libyaml-syck-perl			install
122
libyaml-syck-perl			install
123
libconfig-simple-perl                   install
(-)a/install_misc/ubuntu_maverick.packages (+1 lines)
Lines 127-129 libxml-simple-perl install Link Here
127
libxml-xslt-perl			install
127
libxml-xslt-perl			install
128
libyaml-perl				install
128
libyaml-perl				install
129
libyaml-syck-perl			install
129
libyaml-syck-perl			install
130
libconfig-simple-perl                   install
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 4994-4999 if ( C4::Context->preference("Version") lt TransformToNum($DBversion) ) { Link Here
4994
    SetVersion($DBversion);
4994
    SetVersion($DBversion);
4995
}
4995
}
4996
4996
4997
$DBversion = "3.07.00.XXX";
4998
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4999
    $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('19', 'plugins', 'Koha Plugins', '0')");
5000
    $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('19', 'manage', 'Manage Plugins'), ('19', 'tools', 'Use Tool Plugins'), ('19', 'reports', 'Use Report Plugins')");
5001
    print "Upgrade to $DBversion done (Added system preference RoutingListNote for adding a general note to all routing lists.)\n";
5002
5003
    SetVersion($DBversion);
5004
}
5005
4997
=head1 FUNCTIONS
5006
=head1 FUNCTIONS
4998
5007
4999
=head2 DropAllForeignKeys($table)
5008
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (+3 lines)
Lines 34-39 Link Here
34
                            [% IF ( CAN_user_tools ) %]
34
                            [% IF ( CAN_user_tools ) %]
35
                            <li><a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a></li>
35
                            <li><a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a></li>
36
                            [% END %]
36
                            [% END %]
37
                            [% IF ( CAN_user_plugins ) %]
38
                            <li><a href="/cgi-bin/koha/plugins/plugins-home.pl">Plugins</a></li>
39
                            [% END %]
37
                            [% IF ( CAN_user_parameters ) %]
40
                            [% IF ( CAN_user_parameters ) %]
38
                            <li><a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a></li>
41
                            <li><a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a></li>
39
                            [% END %]
42
                            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt (+65 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Plugins </title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
</head>
6
7
<body>
8
[% INCLUDE 'header.inc' %]
9
[% INCLUDE 'circ-search.inc' %]
10
11
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
12
&rsaquo; Plugins
13
</div>
14
15
<div id="doc3" class="yui-t1">
16
	<div id="bd">
17
		<div id="yui-main">
18
			<div class="yui-b">
19
				<div class="details">
20
					<h1>Plugins</h1>
21
					
22
					[% IF ( ERROR_NO_PLUGINS ) %]
23
						<h2>No Plugins Exist.</h2>
24
						<p>Please upload one or more Koha Plugin files (.krz) before using.</p>
25
					[% ELSE %]
26
						<table>
27
							<tr>
28
								<th>Name</th>
29
								<th>Type</th>
30
								<th>Description</th>
31
								<th>Author</th>
32
								<th>Last Update</th>
33
							</tr>
34
	
35
							[% FOREACH PLUGINS_LOO IN PLUGINS_LOOP %]
36
								<tr>
37
									<td><a href="/cgi-bin/koha/plugins/run/[% PLUGINS_LOO.start %]">[% PLUGINS_LOO.name %]</a></td>
38
									<td>[% PLUGINS_LOO.type %]</td>
39
									<td>
40
										[% PLUGINS_LOO.description %]
41
										[% IF ( PLUGINS_LOO.db_version_too_old ) %]
42
											<div class="error">Warning: This report was written for a newer version of Koha. Run at your own risk.</div>
43
										[% END %]
44
									</td>
45
									<td>[% PLUGINS_LOO.author %]</td>
46
									<td>[% PLUGINS_LOO.date_updated %]</td>
47
							[% END %]
48
						</table>
49
					[% END %]
50
				</div>
51
			</div>
52
		</div>
53
54
		<div class="yui-b noprint">
55
			<div id="navmenu">
56
		        	<ul id="navmenulist">
57
		                	<li><a href="plugins-upload.pl">Upload A Plugin</a></li>
58
		        	</ul>
59
			</div>
60
		</div>
61
	</div>
62
</div>
63
64
65
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-upload.tt (+56 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Plugins &rsaquo; Upload Plugin
3
 </title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'calendar.inc' %]
6
</head>
7
8
<body>
9
[% INCLUDE 'header.inc' %]
10
[% INCLUDE 'circ-search.inc' %]
11
12
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
13
&rsaquo; <a href="/cgi-bin/koha/plugins/plugins-home.pl">Plugins</a>
14
&rsaquo; Upload Plugins
15
</div>
16
17
<div id="doc3" class="yui-t2">
18
    <div id="bd">
19
        <div id="yui-main">
20
    <div class="yui-b">
21
        <div class="yui-g">
22
            <div class="yui-u first">
23
                <h1>Upload Koha Plugin</h1>
24
                [% IF ( ERRORS ) %]
25
                <div class="dialog alert">
26
                    [% FOREACH ERROR IN ERRORS %]
27
                        [% IF ( ERROR.NOTKPZ ) %]<li><b>The upload file does not appear to be a kpz file.  The extention is not '.kpz'.</b></li>
28
                        [% ELSIF ( ERROR.NOWRITETEMP ) %]<li><b>This script is not able to create/write to the necessary temporary directory.</b></li>
29
                        [% ELSIF ( ERROR.EMPTYUPLOAD ) %]<li><b>The upload file appears to be empty.</b></li>
30
                        [% ELSIF ( ERROR.UZIPFAIL ) %]<li><b>[% ERROR.UZIPFAIL %] failed to unpack.<br />Please verify the integrity of the zip file and retry.</b></li>
31
                        [% ELSIF ( ERROR.NOWRITEPLUGINS ) %]<li><b>Cannot unpack file to the plugins directory.<br />Please verify that the Apache user can write to the plugins directory.</b></li>
32
                        [% ELSE %]<li><b>[% ERROR.CORERR %] An unknown error has occurred.<br />Please review the error log for more details.</b></li>[% END %]
33
                    [% END %]
34
                </div>
35
                [% END %]
36
	        <form method="post" action="/cgi-bin/koha/plugins/plugins-upload.pl" enctype="multipart/form-data">
37
	            <fieldset class="brief">
38
			 <div class="hint"><b>NOTE:</b> Only KPZ file format is supported.</div>
39
	                <ol>
40
                            <li>
41
                                <label for="uploadfile">Select the file to upload: </label><input type="file" id="uploadfile" name="uploadfile" />
42
                            </li>
43
    	                </ol>
44
					</li></ol>
45
	            </fieldset>
46
                    <fieldset class="action">
47
                        <input type="hidden" name="op" value="Upload" />
48
                        <input type="submit" value="Upload" class="submit" />
49
                    </fieldset>
50
                </form>
51
	
52
            </div>	
53
        </div>
54
    </div>
55
</div>
56
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/report-plugins.tt (+54 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Reports &rsaquo; Custom Reports </title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
</head>
6
7
<body>
8
[% INCLUDE 'header.inc' %]
9
[% INCLUDE 'circ-search.inc' %]
10
11
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
12
&rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
13
&rsaquo; Plugins
14
</div>
15
16
<div id="doc3" class="yui-t1">
17
	<div id="bd">
18
		<div id="yui-main">
19
			<div class="details">
20
				<h1>Report Plugins</h1>
21
				
22
				[% IF ( ERROR_NO_REPORTS ) %]
23
					<h2>No Report Plugins Exist.</h2>
24
				[% ELSE %]
25
					<table>
26
						<tr>
27
							<th>Name</th>
28
							<th>Description</th>
29
							<th>Author</th>
30
							<th>Last Update</th>
31
						</tr>
32
33
						[% FOREACH REPORTS_LOO IN REPORTS_LOOP %]
34
							<tr>
35
								<td><a href="/cgi-bin/koha/plugins/run/[% REPORTS_LOO.start %]">[% REPORTS_LOO.name %]</a></td>
36
								<td>
37
									[% REPORTS_LOO.description %]
38
									[% IF ( REPORTS_LOO.db_version_too_old ) %]
39
										<div class="error">Warning: This report was written for a newer version of Koha. Run at your own risk.</div>
40
									[% END %]
41
								</td>
42
								<td>[% REPORTS_LOO.author %]</td>
43
								<td>[% REPORTS_LOO.date_updated %]</td>
44
						[% END %]
45
					</table>
46
				[% END %]
47
			</div>
48
		</div>
49
	</div>
50
</div>
51
52
53
54
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt (+5 lines)
Lines 27-32 Link Here
27
		<li><a href="/cgi-bin/koha/reports/dictionary.pl?phase=View%20Dictionary">View Dictionary</a></li>
27
		<li><a href="/cgi-bin/koha/reports/dictionary.pl?phase=View%20Dictionary">View Dictionary</a></li>
28
	</ul>
28
	</ul>
29
29
30
	<h2>Report Plugins</h2>
31
	<ul>
32
		<li><a href="/cgi-bin/koha/reports/report-plugins.pl">View Report Plugins</a></li>
33
	</ul>
34
30
	<h2>Statistics wizards</h2>
35
	<h2>Statistics wizards</h2>
31
	<ul>
36
	<ul>
32
		<li><a href="/cgi-bin/koha/reports/acquisitions_stats.pl">Acquisitions</a></li>
37
		<li><a href="/cgi-bin/koha/reports/acquisitions_stats.pl">Acquisitions</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tool-plugins.tt (+54 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Reports &rsaquo; Custom Reports </title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
</head>
6
7
<body>
8
[% INCLUDE 'header.inc' %]
9
[% INCLUDE 'circ-search.inc' %]
10
11
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
12
&rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
13
&rsaquo; Plugins
14
</div>
15
16
<div id="doc3" class="yui-t1">
17
	<div id="bd">
18
		<div id="yui-main">
19
			<div class="details">
20
				<h1>Report Plugins</h1>
21
				
22
				[% IF ( ERROR_NO_TOOLS ) %]
23
					<h2>No Report Plugins Exist.</h2>
24
				[% ELSE %]
25
					<table>
26
						<tr>
27
							<th>Name</th>
28
							<th>Description</th>
29
							<th>Author</th>
30
							<th>Last Update</th>
31
						</tr>
32
33
						[% FOREACH TOOLS_LOO IN TOOLS_LOOP %]
34
							<tr>
35
								<td><a href="/cgi-bin/koha/plugins/run/[% TOOLS_LOO.start %]">[% TOOLS_LOO.name %]</a></td>
36
								<td>
37
									[% TOOLS_LOO.description %]
38
									[% IF ( TOOLS_LOO.db_version_too_old ) %]
39
										<div class="error">Warning: This report was written for a newer version of Koha. Run at your own risk.</div>
40
									[% END %]
41
								</td>
42
								<td>[% TOOLS_LOO.author %]</td>
43
								<td>[% TOOLS_LOO.date_updated %]</td>
44
						[% END %]
45
					</table>
46
				[% END %]
47
			</div>
48
		</div>
49
	</div>
50
</div>
51
52
53
54
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (-1 / +5 lines)
Lines 86-92 Link Here
86
    <dt><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></dt>
86
    <dt><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></dt>
87
    <dd>Schedule tasks to run</dd>
87
    <dd>Schedule tasks to run</dd>
88
    [% END %]
88
    [% END %]
89
	
89
90
    [% IF ( CAN_user_plugins_tools ) %]
91
    <dt><a href="/cgi-bin/koha/tools/tool-plugins.pl">Tool Plugins</a></dt>
92
    <dd>Schedule tasks to run</dd>
93
    [% END %]	
90
94
91
</dl>
95
</dl>
92
</div>
96
</div>
(-)a/plugins/plugins-home.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2010 Kyle M Hall <kyle.m.hall@gmail.com>
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along with
17
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18
# Suite 330, Boston, MA  02111-1307 USA
19
20
use strict;
21
use warnings;
22
23
use CGI;
24
25
use C4::Plugins;
26
use C4::Auth;
27
use C4::Output;
28
use C4::Dates;
29
use C4::Debug;
30
31
my $input = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "plugins/plugins-home.tmpl",
36
        query           => $input,
37
        type            => "intranet",
38
        authnotrequired => 0,
39
        flagsrequired   => { plugins => "manage" },
40
        debug           => 1,
41
    }
42
);
43
44
my ( $plugins_loop, $plugins_count ) = GetPlugins();
45
46
$template->param( PLUGINS_LOOP => $plugins_loop );
47
48
unless ( $plugins_count ) {
49
  $template->param( ERROR_NO_PLUGINS => 1 );
50
}
51
52
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/plugins/plugins-upload.pl (+89 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16
# Suite 330, Boston, MA  02111-1307 USA
17
18
use strict;
19
use warnings;
20
21
use File::Temp;
22
use File::Copy;
23
use CGI;
24
25
use C4::Context;
26
use C4::Auth;
27
use C4::Output;
28
use C4::Members;
29
use C4::Debug;
30
use C4::Plugins;
31
32
my $input = new CGI;
33
34
my ($template, $loggedinuser, $cookie)
35
	= get_template_and_user({template_name => "plugins/plugins-upload.tmpl",
36
					query => $input,
37
					type => "intranet",
38
					authnotrequired => 0,
39
					flagsrequired => { plugins => 'manage'},
40
					debug => 1,
41
					});
42
43
my $uploadfilename      = $input->param('uploadfile');
44
my $uploadfile          = $input->upload('uploadfile');
45
my $op                  = $input->param('op');
46
47
my ( $total, $handled, @counts, $tempfile, $tfh );
48
49
my %errors;
50
51
if ( ($op eq 'Upload') && $uploadfile ) {
52
    my $plugins_dir = GetPluginsDir();
53
54
    my $dirname = File::Temp::tempdir( CLEANUP => 1);
55
    $debug and warn "dirname = $dirname";
56
57
    my $filesuffix = $1 if $uploadfilename =~ m/(\..+)$/i;
58
    ( $tfh, $tempfile ) = File::Temp::tempfile( SUFFIX => $filesuffix, UNLINK => 1 );
59
60
    $debug and warn "tempfile = $tempfile";
61
62
    $errors{'NOTKPZ'} = 1 if ( $uploadfilename !~ /\.kpz$/i );
63
    $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname );
64
    $errors{'NOWRITEPLUGINS'} = 1 unless ( -w $plugins_dir );
65
    $errors{'EMPTYUPLOAD'} = 1 unless ( length( $uploadfile ) > 0 );
66
67
    if ( %errors ) {
68
	$template->param( ERRORS => [ \%errors ] );
69
    } else {
70
	while ( <$uploadfile> ) {
71
	    print $tfh $_;
72
        }
73
        close $tfh;
74
        unless (system("unzip -o $tempfile -d $plugins_dir") == 0) {
75
            $errors{'UZIPFAIL'} = $uploadfilename;
76
            $template->param( ERRORS => [ \%errors ] );
77
            output_html_with_http_headers $input, $cookie, $template->output;
78
            exit;
79
        }
80
    }
81
} elsif ( ($op eq 'Upload') && !$uploadfile ) {
82
    warn "Problem uploading file or no file uploaded.";
83
} 
84
85
if ( $uploadfile && !%errors && !$template->param('ERRORS') ) {
86
    print $input->redirect ("/cgi-bin/koha/plugins/plugins-home.pl");
87
} else {
88
    output_html_with_http_headers $input, $cookie, $template->output;
89
}
(-)a/reports/report-plugins.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2010 Kyle M Hall <kyle.m.hall@gmail.com>
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along with
17
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18
# Suite 330, Boston, MA  02111-1307 USA
19
20
use strict;
21
use warnings;
22
23
use CGI;
24
25
use C4::Plugins;
26
use C4::Auth;
27
use C4::Output;
28
use C4::Dates;
29
use C4::Debug;
30
31
my $input = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "reports/report-plugins.tmpl",
36
        query           => $input,
37
        type            => "intranet",
38
        authnotrequired => 0,
39
        flagsrequired   => { plugins => "reports" },
40
        debug           => 1,
41
    }
42
);
43
44
my ( $reports_loop, $reports_count ) = GetPlugins( 'report' );
45
46
$template->param( REPORTS_LOOP => $reports_loop );
47
48
unless ( $reports_count ) {
49
  $template->param( ERROR_NO_REPORTS => 1 );
50
}
51
52
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/skel/var/lib/koha/plugins/.htaccess (+2 lines)
Line 0 Link Here
1
AddHandler cgi-script .pl
2
AddHandler send-as-is .css .js .gif .jpg
(-)a/skel/var/lib/koha/plugins/README (+1 lines)
Line 0 Link Here
1
plugins dir
(-)a/tools/tool-plugins.pl (-1 / +52 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2010 Kyle M Hall <kyle.m.hall@gmail.com>
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along with
17
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18
# Suite 330, Boston, MA  02111-1307 USA
19
20
use strict;
21
use warnings;
22
23
use CGI;
24
25
use C4::Plugins;
26
use C4::Auth;
27
use C4::Output;
28
use C4::Dates;
29
use C4::Debug;
30
31
my $input = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "tools/tool-plugins.tmpl",
36
        query           => $input,
37
        type            => "intranet",
38
        authnotrequired => 0,
39
        flagsrequired   => { plugins => "tools" },
40
        debug           => 1,
41
    }
42
);
43
44
my ( $reports_loop, $reports_count ) = GetPlugins( 'tool' );
45
46
$template->param( TOOLS_LOOP => $reports_loop );
47
48
unless ( $reports_count ) {
49
  $template->param( ERROR_NO_TOOLS => 1 );
50
}
51
52
output_html_with_http_headers $input, $cookie, $template->output;

Return to bug 7804