[Cpan-forum-commit] rev 236 - in trunk: . lib/CPAN/Forum lib/CPAN/Forum/DB lib/CPAN/Forum/RM schema templates

svn at pti.co.il svn at pti.co.il
Tue Jul 3 23:59:43 IDT 2007


Author: gabor
Date: 2007-07-03 23:59:43 +0300 (Tue, 03 Jul 2007)
New Revision: 236

Added:
   trunk/schema/update.sql
Modified:
   trunk/
   trunk/lib/CPAN/Forum/DB/Tags.pm
   trunk/lib/CPAN/Forum/INC.pm
   trunk/lib/CPAN/Forum/RM/Dist.pm
   trunk/schema/schema.sql
   trunk/templates/groups.tmpl
Log:
separate the sql that is needed for the upgrade
add code to display the existing tags



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4095
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
   + 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4096
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752

Modified: trunk/lib/CPAN/Forum/DB/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-03 20:58:21 UTC (rev 235)
+++ trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-03 20:59:43 UTC (rev 236)
@@ -6,18 +6,33 @@
 
 use Carp qw();
 
-sub list_tags {
+sub get_tags_of {
+    my ($self, $group_id, $uid) = @_;
+    if (not defined $uid) {
+        return $self->get_tags_of_module($group_id);
+    }
+    my $dbh = CPAN::Forum::DBI::db_Main();
+    my $sql = "SELECT tags.name name 
+                             FROM tag_cloud, tags
+                             WHERE tag_cloud.tag_id=tags.id AND tag_cloud.uid=? AND tag_cloud.group_id=?";
+    my $sth = $dbh->prepare($sql);
+    $sth->execute($uid, $group_id);
+    my $ar = $sth->fetchrow_arrayref;
+    my @names = map { {name => $_->[0]} } @$ar;
+    return \@names;
+}
+
+sub get_tags_of_module {
     my ($self, $group_id) = @_;
     my $dbh = CPAN::Forum::DBI::db_Main();
-    #my $sth = $dbh->prepare("SELECT tags.name name FROM tags_on_groups, tags 
-    #               WHERE tags_on_groups.tag_id=tags.id AND tags_on_groups.group_id=?");
-
-    #$sth->execute($group_id);
-    #my $ar = $sth->fetchrow_arrayref;
-    #my @names = map { {name => $_->[0]} } @$ar;
-    #my @names = map { $_->[0] } @$ar;
-    #return @names;
-    return qw(qqrq perl);
+    my $sql = "SELECT tags.name name 
+                             FROM tag_cloud, tags
+                             WHERE tag_cloud.tag_id=tags.id AND tag_cloud.group_id=?";
+    my $sth = $dbh->prepare($sql);
+    $sth->execute($group_id);
+    my $ar = $sth->fetchrow_arrayref;
+    my @names = map { {name => $_->[0]} } @$ar;
+    return \@names;
 }
 
 sub attach_tag {
@@ -58,4 +73,20 @@
     return $id;
 }
 
+
+=head1 Design
+
+Every person can put any tage on any module
+
+On the page of every module we will list my tags and show a button to change
+get_tags_of(module, person)
+get_tags_of(module)
+get_modules(tag, person)
+get_modules(tag)
+
+set_tag_on(module, person)
+
+
+=cut
+
 1;

Modified: trunk/lib/CPAN/Forum/INC.pm
===================================================================
--- trunk/lib/CPAN/Forum/INC.pm	2007-07-03 20:58:21 UTC (rev 235)
+++ trunk/lib/CPAN/Forum/INC.pm	2007-07-03 20:59:43 UTC (rev 236)
@@ -18,7 +18,7 @@
 use CPAN::Forum::DB::UserInGroup;
 use CPAN::Forum::DB::Users;
 
-#use CPAN::Forum::DB::Tags;
+use CPAN::Forum::DB::Tags;
 
 
 1;

Modified: trunk/lib/CPAN/Forum/RM/Dist.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Dist.pm	2007-07-03 20:58:21 UTC (rev 235)
+++ trunk/lib/CPAN/Forum/RM/Dist.pm	2007-07-03 20:59:43 UTC (rev 236)
@@ -63,8 +63,9 @@
         $t->param(pauseid_name => $gr->pauseid->pauseid);
     }
 
-    #my (@tags) = CPAN::Forum::DB::Tags->list_tags($gid);
-    #$t->param(tags => join ", ", @tags);
+    my $uid = $self->session->param('uid');
+    my $tags = CPAN::Forum::DB::Tags->get_tags_of($gid, $uid);
+    $t->param(tags => $tags);
 
     return $t->output;
 }

Modified: trunk/schema/schema.sql
===================================================================
--- trunk/schema/schema.sql	2007-07-03 20:58:21 UTC (rev 235)
+++ trunk/schema/schema.sql	2007-07-03 20:59:43 UTC (rev 236)
@@ -140,19 +140,5 @@
 CREATE INDEX posts_thread ON posts (thread);
 CREATE INDEX posts_gid ON posts (gid);
 
----- add tagcloud
---- TODO unique tag_id, group_id pair
-CREATE TABLE tags (
-			id               INTEGER PRIMARY KEY auto_increment,
-			name             VARCHAR(100) UNIQUE NOT NULL
-);
-CREATE UNIQUE INDEX tags_name ON tags (name);
-CREATE TABLE tags_on_groups (
-			tag_id           INTEGER,
-            group_id         INTEGER
-			,FOREIGN KEY (tag_id) REFERENCES tags(id)
-			,FOREIGN KEY (group_id) REFERENCES groups(id)
-);
 
 
-

Added: trunk/schema/update.sql
===================================================================
--- trunk/schema/update.sql	                        (rev 0)
+++ trunk/schema/update.sql	2007-07-03 20:59:43 UTC (rev 236)
@@ -0,0 +1,20 @@
+
+---- add tagcloud
+--- TODO unique tag_id, group_id pair
+CREATE TABLE tags (
+			id               INTEGER PRIMARY KEY,
+			name             VARCHAR(100) UNIQUE NOT NULL
+);
+CREATE UNIQUE INDEX tags_name ON tags (name);
+CREATE TABLE tag_cloud (
+			uid              INTEGER,
+			tag_id           INTEGER,
+            group_id         INTEGER
+			,FOREIGN KEY (uid) REFERENCES users(id)
+			,FOREIGN KEY (tag_id) REFERENCES tags(id)
+			,FOREIGN KEY (group_id) REFERENCES groups(id)
+);
+CREATE INDEX tags_cloud_uid ON tag_cloud (uid);
+CREATE INDEX tags_cloud_tag_id ON tag_cloud (tag_id);
+CREATE INDEX tags_cloud_group_id ON tag_cloud (group_id);
+

Modified: trunk/templates/groups.tmpl
===================================================================
--- trunk/templates/groups.tmpl	2007-07-03 20:58:21 UTC (rev 235)
+++ trunk/templates/groups.tmpl	2007-07-03 20:59:43 UTC (rev 236)
@@ -10,6 +10,19 @@
 <br />
 All the posts related to modules of <a href="/author/<TMPL_VAR pauseid_name>"><TMPL_VAR pauseid_name></a>.
 </p>
+
+<p>
+<TMPL_IF tags>
+My Tags: <TMPL_LOOP tags><TMPL_VAR name>, </TMPL_LOOP>
+</TMPL_IF><br />
+<form method="post" action="/update/">
+<input type="hidden" name="rm" value="tags" />
+<input type="hidden" name="group" value="<TMPL_VAR group>" />
+<input name="tag" value="<TMPL_LOOP tags><TMPL_VAR name>, </TMPL_LOOP>" />
+<input type="submit" value="Update tags" />
+</form>
+</p>
+
 <TMPL_IF messages>
 <p>
 <center>
@@ -38,19 +51,7 @@
 </p>
 <TMPL_INCLUDE NAME="listing.tmpl">
 
-<!--
 <p>
-Tags: <TMPL_VAR tags><br />
-
-<form method="post" action="/update/">
-<input type="hidden" name="rm" value="tags" />
-<input type="hidden" name="group" value="<TMPL_VAR group>" />
-<input name="tag" value="<TMPL_VAR tag>" />
-<input type="submit" value="Add tag" />
-</form>
-</p>
--->
-<p>
 Users currently monitoring this forum:
 <TMPL_LOOP users>
    <a href="/users/<TMPL_VAR username>"><TMPL_VAR username></a>, 



More information about the Cpan-forum-commit mailing list