[vhffs-dev] [1808] No more HTML::Template in admin/dns/list |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1808
Author: beuss
Date: 2011-05-25 13:18:19 +0200 (Wed, 25 May 2011)
Log Message:
-----------
No more HTML::Template in admin/dns/list
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Panel/DNS.pm
trunk/vhffs-panel/admin/dns/list.pl
trunk/vhffs-panel/templates/Makefile.am
Removed Paths:
-------------
trunk/vhffs-panel/templates/admin/dns/part.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Panel/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/DNS.pm 2011-05-25 06:11:42 UTC (rev 1807)
+++ trunk/vhffs-api/src/Vhffs/Panel/DNS.pm 2011-05-25 11:18:19 UTC (rev 1808)
@@ -51,31 +51,25 @@
sub search
{
my ($main, $name) = @_;
- my $sql;
- my $dns = [];
+
my @params;
+ my $sql = 'SELECT ns.domain as label, g.groupname as owner_group, o.state, u.username as owner_user '.
+ 'FROM vhffs_dns ns '.
+ 'INNER JOIN vhffs_object o ON (o.object_id = ns.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 ns.domain, g.groupname, o.state FROM vhffs_dns ns INNER JOIN vhffs_object o ON o.object_id = ns.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE ns.domain LIKE ?';
+ $sql .= 'WHERE ns.domain LIKE ? ';
push(@params, '%'.lc($name).'%');
- } else {
- $sql = 'SELECT ns.domain, g.groupname, o.state FROM vhffs_dns ns INNER JOIN vhffs_object o ON o.object_id = ns.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 ns.domain';
- return undef unless($sth->execute(@params));
-
- while(my $d = $sth->fetchrow_hashref('NAME_lc')) {
- $d->{state} = Vhffs::Functions::status_string_from_status_id($d->{state});
- push(@$dns, $d);
- }
- return $dns;
+ my $dbh = $main->get_db_object();
+ return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
}
-
-
sub create_dns
{
my ( $main , $dns_name, $description , $user , $group ) = @_;
Modified: trunk/vhffs-panel/admin/dns/list.pl
===================================================================
--- trunk/vhffs-panel/admin/dns/list.pl 2011-05-25 06:11:42 UTC (rev 1807)
+++ trunk/vhffs-panel/admin/dns/list.pl 2011-05-25 11:18:19 UTC (rev 1808)
@@ -32,64 +32,30 @@
use strict;
use utf8;
use POSIX qw(locale_h);
-use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
use CGI::Session;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Web;
+use Vhffs::Panel::Admin;
+use Vhffs::Panel::DNS;
-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 => 'dns'
+};
-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 domain %s'), $name );
+} else {
+ $vars->{list_title} = gettext('List of all domains');
}
-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 domain').': '.$name );
- }
- else
- {
- $template->param( TITLE => gettext('List of all domains') );
- }
-
- $template->param( TEXT_TITLE1 => gettext('Domain Name') );
- $template->param( TEXT_TITLE2 => gettext('Group') );
- $template->param( TEXT_TITLE3 => gettext('State') );
-
- my $domains = Vhffs::Panel::DNS::search( $vhffs , $name );
- if( defined $domains )
- {
- my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/admin/dns/part.tmpl', global_vars => 1 );
- if( $user->is_admin == 1 ) {
- $subtemplate->param( ACTION => gettext('Modify') );
- } else {
- $subtemplate->param( ACTION => gettext('Show') );
- }
-
- $subtemplate->param( DNSES => $domains);
- $template->param( LIST => $subtemplate->output );
- }
-}
-
-$panel->build( $template );
-$panel->display;
+$vars->{label_title} = gettext('Domain Name');
+$vars->{list} = Vhffs::Panel::DNS::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 06:11:42 UTC (rev 1807)
+++ trunk/vhffs-panel/templates/Makefile.am 2011-05-25 11:18:19 UTC (rev 1808)
@@ -4,7 +4,6 @@
admin/bazaar/search.tmpl \
admin/cvs/part.tmpl \
admin/cvs/search.tmpl \
- admin/dns/part.tmpl \
admin/dns/search.tmpl \
admin/group/part.tmpl \
admin/group/search.tmpl \
Deleted: trunk/vhffs-panel/templates/admin/dns/part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/dns/part.tmpl 2011-05-25 06:11:42 UTC (rev 1807)
+++ trunk/vhffs-panel/templates/admin/dns/part.tmpl 2011-05-25 11:18:19 UTC (rev 1808)
@@ -1,16 +0,0 @@
-<TMPL_LOOP NAME="DNSES">
-<tr>
- <td>
- <TMPL_VAR ESCAPE=1 NAME="DOMAIN">
- </td>
- <td>
- <TMPL_VAR ESCAPE=1 NAME="GROUPNAME">
- </td>
- <td>
- <TMPL_VAR ESCAPE=1 NAME="STATE">
- </td>
- <td>
- <a href="/dns/prefs.pl?admin_menu=1&name=<TMPL_VAR ESCAPE=1 NAME="DOMAIN">"><TMPL_VAR ESCAPE=1 NAME="ACTION"></a>
- </td>
-</tr>
-</TMPL_LOOP>