[vhffs-dev] [1811] No more HTML::Template in admin/cron/list |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1811
Author: beuss
Date: 2011-05-25 13:18:45 +0200 (Wed, 25 May 2011)
Log Message:
-----------
No more HTML::Template in admin/cron/list
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Panel/Cron.pm
trunk/vhffs-panel/admin/cron/list.pl
trunk/vhffs-panel/templates/Makefile.am
Removed Paths:
-------------
trunk/vhffs-panel/templates/admin/cron/part.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Panel/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Cron.pm 2011-05-25 11:18:33 UTC (rev 1810)
+++ trunk/vhffs-api/src/Vhffs/Panel/Cron.pm 2011-05-25 11:18:45 UTC (rev 1811)
@@ -36,7 +36,6 @@
use DBI;
use POSIX qw(locale_h);
-use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
@@ -80,28 +79,22 @@
sub search {
my ($main, $name) = @_;
- my $sql;
my @params;
- my $reps = [];
+ my $sql = 'SELECT cron.cronpath as label, g.groupname as owner_group, o.state, u.username as owner_user '.
+ 'FROM vhffs_cron cron '.
+ 'INNER JOIN vhffs_object o ON (o.object_id = cron.object_id) '.
+ 'INNER JOIN vhffs_groups g ON (g.gid = o.owner_gid) '.
+ 'INNER JOIN vhffs_users u ON (u.uid = o.owner_uid) ';
if( defined $name ) {
- $sql = 'SELECT c.cronpath, g.groupname, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON o.object_id=c.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE c.cronpath LIKE ?';
+ $sql .= 'WHERE cron.cronpath LIKE ? ';
push(@params, '%'.lc($name).'%');
- } else {
- $sql = 'SELECT c.cronpath, g.groupname, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON o.object_id=c.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid';
}
- my $dbh = $main->get_db_object();
- my $sth = $dbh->prepare($sql) or return undef;
+ $sql .= 'ORDER BY cron.cronpath';
- return undef unless($sth->execute(@params));
-
- while(my $r = $sth->fetchrow_hashref('NAME_lc')) {
- $r->{state} = Vhffs::Functions::status_string_from_status_id($r->{state});
- push(@$reps, $r);
- }
-
- return $reps;
+ my $dbh = $main->get_db_object();
+ return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
}
Modified: trunk/vhffs-panel/admin/cron/list.pl
===================================================================
--- trunk/vhffs-panel/admin/cron/list.pl 2011-05-25 11:18:33 UTC (rev 1810)
+++ trunk/vhffs-panel/admin/cron/list.pl 2011-05-25 11:18:45 UTC (rev 1811)
@@ -32,7 +32,6 @@
use strict;
use utf8;
use POSIX qw(locale_h);
-use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
@@ -40,64 +39,24 @@
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
+use Vhffs::Panel::Admin;
use Vhffs::Panel::Cron;
-use Vhffs::Stats;
-use Vhffs::Constants;
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
+my $panel = new Vhffs::Panel::Admin();
my $vhffs = $panel->{'vhffs'};
-my $user = $panel->{'user'};
my $cgi = $panel->{'cgi'};
-my $templatedir = $panel->{'templatedir'};
-my $template;
+my $name = $cgi->param('NAME');
+my $vars = {
+ type => 'cron'
+};
-if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
-{
- $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
- $template->param( MESSAGE => gettext('You are not allowed to see it') );
+if( defined( $name ) ) {
+ $vars->{list_title} = sprintf( gettext('Search result for Cron jobs %s'), $name );
+} else {
+ $vars->{list_title} = gettext('List of all Cron jobs');
}
-else
-{
- $template = new HTML::Template( filename => $templatedir.'/panel/admin/misc/list.tmpl' );
- my $name = $cgi->param('NAME');
- if( defined( $name ) )
- {
- $template->param( TITLE => gettext('Search result for Cron jobs').': '.$name );
- }
- else
- {
- $template->param( TITLE => gettext('List of all Cron jobs') );
- }
-
- $template->param( TEXT_TITLE1 => gettext('Cron path') );
- $template->param( TEXT_TITLE2 => gettext('Group') );
- $template->param( TEXT_TITLE3 => gettext('State') );
-
- my $crons = Vhffs::Panel::Cron::search( $vhffs , $name );
-
- if( defined $crons )
- {
- my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/admin/cron/part.tmpl', global_vars => 1 );
- if( $user->is_admin == 1 ) {
- $subtemplate->param( ACTION => gettext('Modify') );
- } else {
- $subtemplate->param( ACTION => gettext('Show') );
- }
-
- $subtemplate->param(CRONS => $crons);
- $template->param( LIST => $subtemplate->output );
- }
-}
-
-$panel->build( $template );
-$panel->display;
+$vars->{label_title} = gettext('Cron path');
+$vars->{list} = Vhffs::Panel::Cron::search( $vhffs , $name );
+$panel->render('admin/misc/list.tt', $vars);
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2011-05-25 11:18:33 UTC (rev 1810)
+++ trunk/vhffs-panel/templates/Makefile.am 2011-05-25 11:18:45 UTC (rev 1811)
@@ -43,7 +43,6 @@
admin/user/part.tmpl \
admin/user/search.tmpl \
admin/web/search.tmpl \
- admin/cron/part.tmpl \
admin/cron/search.tmpl \
menu/context.tmpl \
menu/context-group.tmpl \
Deleted: trunk/vhffs-panel/templates/admin/cron/part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/cron/part.tmpl 2011-05-25 11:18:33 UTC (rev 1810)
+++ trunk/vhffs-panel/templates/admin/cron/part.tmpl 2011-05-25 11:18:45 UTC (rev 1811)
@@ -1,16 +0,0 @@
-<TMPL_LOOP NAME="CRONS">
-<tr>
- <td>
- <TMPL_VAR ESCAPE=1 NAME="CRONPATH">
- </td>
- <td>
- <TMPL_VAR ESCAPE=1 NAME="GROUPNAME">
- </td>
- <td>
- <TMPL_VAR ESCAPE=1 NAME="STATE">
- </td>
- <td>
- <a href="/cron/prefs.pl?admin_menu=1&name=<TMPL_VAR ESCAPE=1 NAME="CRONPATH">"><TMPL_VAR ESCAPE=1 NAME="ACTION"></a>
- </td>
-</tr>
-</TMPL_LOOP>