[vhffs-dev] [1805] No more HTML::Template in admin/mailinglist/list

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1805
Author:   beuss
Date:     2011-05-24 08:13:16 +0200 (Tue, 24 May 2011)
Log Message:
-----------
No more HTML::Template in admin/mailinglist/list

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm
    trunk/vhffs-panel/admin/mailinglist/list.pl
    trunk/vhffs-panel/templates/Makefile.am

Removed Paths:
-------------
    trunk/vhffs-panel/templates/admin/mailinglist/part.tmpl

Modified: trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm	2011-05-24 06:13:09 UTC (rev 1804)
+++ trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm	2011-05-24 06:13:16 UTC (rev 1805)
@@ -49,26 +49,22 @@
 sub search
 {
     my ($main, $name) = @_;
-    my $sql;
+
     my @params;
-    my $mls = [];
+    my $sql = 'SELECT m.local_part || \'@\' || m.domain as label, g.groupname as owner_group, o.state, u.username as owner_user '.
+        'FROM vhffs_ml m '.
+        'INNER JOIN vhffs_object o ON (o.object_id = m.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 l.local_part, l.domain, g.groupname, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON o.object_id = l.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE l.local_part LIKE ? OR l.domain LIKE ?';
+        $sql .= 'WHERE m.local_part LIKE ? OR m.domain LIKE ? ';
         push(@params, '%'.lc($name).'%' , '%'.lc($name).'%' );
-    } else {
-        $sql = 'SELECT l.local_part, l.domain, g.groupname, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON o.object_id = l.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid';
     }
+    $sql .= 'ORDER BY m.domain, m.local_part';
     my $dbh = $main->get_db_object();
-    my $sth = $dbh->prepare($sql) or return undef;
-
-    return undef unless($sth->execute(@params));
-
-    while(my $m = $sth->fetchrow_hashref('NAME_lc')) {
-        $m->{state} = Vhffs::Functions::status_string_from_status_id($m->{state});
-        push(@$mls, $m);
-    }
-    return $mls;
+    return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 =pod

Modified: trunk/vhffs-panel/admin/mailinglist/list.pl
===================================================================
--- trunk/vhffs-panel/admin/mailinglist/list.pl	2011-05-24 06:13:09 UTC (rev 1804)
+++ trunk/vhffs-panel/admin/mailinglist/list.pl	2011-05-24 06:13:16 UTC (rev 1805)
@@ -32,67 +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::User;
-use Vhffs::Group;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
+use Vhffs::Panel::Admin;
 use Vhffs::Panel::MailingList;
 
-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 => 'mailinglist'
+};
 
-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 %s'), $name );
+} else {
+    $vars->{list_title} = gettext('List of all mailing-list');
 }
-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').': '.$name );
-	}
-	else
-	{
-		$template->param( TITLE => gettext('List of all mailing-list') );
-	}
-
-	$template->param( TEXT_TITLE1 => gettext('Mailing List') );
-	$template->param( TEXT_TITLE2 => gettext('Group') );
-	$template->param( TEXT_TITLE3 => gettext('State') );
-
-	my $lists = Vhffs::Panel::MailingList::search( $vhffs, $name );
-	if( defined $lists )
-	{
-		my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/admin/mailinglist/part.tmpl', global_vars => 1 );
-		if( $user->is_admin == 1 )  {
-			$subtemplate->param( ACTION => gettext('Modify') );
-		}  else  {
-			$subtemplate->param( ACTION => gettext('Show') );
-		}
-		$subtemplate->param( LISTS => $lists );
-		$template->param( LIST => $subtemplate->output );
-	}
-}
-
-$panel->build( $template );
-$panel->display;
+$vars->{label_title} = gettext('Mailing List');
+$vars->{list} = Vhffs::Panel::MailingList::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-24 06:13:09 UTC (rev 1804)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-24 06:13:16 UTC (rev 1805)
@@ -10,7 +10,6 @@
 	admin/group/search.tmpl \
 	admin/mail/search.tmpl \
 	admin/mail/part.tmpl \
-	admin/mailinglist/part.tmpl \
 	admin/mailinglist/search.tmpl \
 	admin/main/general-modo.tmpl \
 	admin/main/general.tmpl \

Deleted: trunk/vhffs-panel/templates/admin/mailinglist/part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/mailinglist/part.tmpl	2011-05-24 06:13:09 UTC (rev 1804)
+++ trunk/vhffs-panel/templates/admin/mailinglist/part.tmpl	2011-05-24 06:13:16 UTC (rev 1805)
@@ -1,16 +0,0 @@
-<TMPL_LOOP NAME="LISTS">
-<tr>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="LOCAL_PART">@<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="/mailinglist/prefs.pl?admin_menu=1&amp;name=<TMPL_VAR ESCAPE=1 NAME="LOCAL_PART">@<TMPL_VAR ESCAPE=1 NAME="DOMAIN">"><TMPL_VAR ESCAPE=1 NAME="ACTION"></a>
-	</td>
-</tr>
-</TMPL_LOOP>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/