[vhffs-dev] [1509] Added group tags list on summary view

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


Revision: 1509
Author:   beuss
Date:     2009-08-04 20:50:20 +0200 (Tue, 04 Aug 2009)

Log Message:
-----------
Added group tags list on summary view

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Group.pm
    trunk/vhffs-public/templates/content/all-groups.tt
    trunk/vhffs-public/templates/parts/group-general.tt
    trunk/vhffs-themes/light-grey/main.css


Modified: trunk/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2009-08-03 21:45:21 UTC (rev 1508)
+++ trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2009-08-04 18:50:20 UTC (rev 1509)
@@ -152,16 +152,14 @@
 	my $limit = ' LIMIT 10';
 	$limit .= ' OFFSET '.($start * 10) if(defined $start);
 	
+	my $select = 'SELECT g.gid, g.groupname, g.realname, o.description, owner.username AS owner_name'.$sql.' ORDER BY groupname '.$limit;
+    	my $groups = fetch_groups_and_users($main, $select, @params);
+
 	my $dbh = $main->get_db_object();
-	my $sth = $dbh->prepare('SELECT g.gid, g.groupname, g.realname, o.description, owner.username AS owner_name'.$sql.' ORDER BY groupname '.$limit);
 	
+	my $sth = $dbh->prepare('SELECT COUNT(*)'.$sql);
 	return undef unless ( $sth->execute(@params) );
 	
-	my $groups = $sth->fetchall_arrayref({});
-	
-	$sth = $dbh->prepare('SELECT COUNT(*)'.$sql);
-	return undef unless ( $sth->execute(@params) );
-	
 	my ($count) = $sth->fetchrow_array();
 	
 	return ($groups, $count);
@@ -246,11 +244,20 @@
     my $dbh = $main->get_db_object;
     my $sth = $dbh->prepare($sql);
     $sql = 'SELECT u.username FROM vhffs_users u INNER JOIN vhffs_user_group ug ON ug.uid = u.uid WHERE ug.gid = ?';
-    my $ssth = $dbh->prepare($sql);
+    my $usth = $dbh->prepare($sql);
+    # FIXME fetch object_id along with gid in every caller and suppress vhffs_groups from the query
+    $sql = 'SELECT c.tag_category_id as category_id, c.label as category_label, t.tag_id, t.label as tag_label '.
+            'FROM vhffs_tag t INNER JOIN vhffs_tag_category c ON c.tag_category_id = t.category_id '.
+            'INNER JOIN vhffs_object_tag ot ON ot.tag_id = t.tag_id '.
+            'INNER JOIN vhffs_groups g ON g.object_id = ot.object_id '.
+            'WHERE g.gid = ?';
+    my $tsth = $dbh->prepare($sql);
     $sth->execute(@params);
     while(my $row = $sth->fetchrow_hashref) {
-        $ssth->execute($row->{gid});
-        $row->{users} = $ssth->fetchall_arrayref({});
+        $usth->execute($row->{gid});
+        $row->{users} = $usth->fetchall_arrayref({});
+        $tsth->execute($row->{gid});
+        $row->{tags} = $tsth->fetchall_arrayref({});
         push @groups, $row;
     }
 

Modified: trunk/vhffs-public/templates/content/all-groups.tt
===================================================================
--- trunk/vhffs-public/templates/content/all-groups.tt	2009-08-03 21:45:21 UTC (rev 1508)
+++ trunk/vhffs-public/templates/content/all-groups.tt	2009-08-04 18:50:20 UTC (rev 1509)
@@ -3,7 +3,7 @@
 [% INCLUDE common/pager.tt pager=pager%]
 
 <div class="pages-tabs">
-[<a href="/allgroups.pl?letter=all">[% 'All' | i18n%]</a>]
+[<a href="/allgroups.pl?letter=all" class="ajax">[% 'All' | i18n%]</a>]
 [% title_str = '%s (%d groups)' | i18n %]
 [% FOREACH l = letters %]
 [<a class="ajax" href="/allgroups.pl?letter=[% l.letter %]" title="[% title_str | pretty_print(l.letter, l.count) %]">[% l.letter %]</a>]&nbsp;

Modified: trunk/vhffs-public/templates/parts/group-general.tt
===================================================================
--- trunk/vhffs-public/templates/parts/group-general.tt	2009-08-03 21:45:21 UTC (rev 1508)
+++ trunk/vhffs-public/templates/parts/group-general.tt	2009-08-04 18:50:20 UTC (rev 1509)
@@ -7,5 +7,10 @@
 <div class="description">
 [% g.description | html | html_para %]
 </div>
+<div class="tags">
+[% FOREACH t = g.tags %]
+	<a href="/groupsearch.pl?included_tags=[% t.tag_id %]" class="ajax">[% t.category_label | html %]::[% t.tag_label | html %]</a>[% ', ' UNLESS loop.last() %]
+[% END %]
+</div>
 <p class="more-group"><a href="/group.pl?name=[% g.groupname %]" class="ajax">[% 'More info...' | i18n %]</a></p>
 </div>

Modified: trunk/vhffs-themes/light-grey/main.css
===================================================================
--- trunk/vhffs-themes/light-grey/main.css	2009-08-03 21:45:21 UTC (rev 1508)
+++ trunk/vhffs-themes/light-grey/main.css	2009-08-04 18:50:20 UTC (rev 1509)
@@ -464,6 +464,10 @@
 	min-height: 60px;
 }
 
+div.group-info div.tags {
+	text-align:center;
+}
+
 div.user-info ul {
 	min-height: 100px;
 }


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