[Fusionforge-commits] r8568 - in trunk/gforge: debian packaging/install plugins/contribtracker plugins/contribtracker/bin plugins/contribtracker/common plugins/contribtracker/lib

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Dec 18 18:38:42 CET 2009


Author: lolando
Date: 2009-12-18 18:38:42 +0100 (Fri, 18 Dec 2009)
New Revision: 8568

Added:
   trunk/gforge/debian/gforge-plugin-contribtracker.postinst
   trunk/gforge/debian/gforge-plugin-contribtracker.prerm
   trunk/gforge/packaging/install/plugin-contribtracker
   trunk/gforge/plugins/contribtracker/bin/
   trunk/gforge/plugins/contribtracker/bin/db-delete.pl
   trunk/gforge/plugins/contribtracker/bin/db-upgrade.pl
   trunk/gforge/plugins/contribtracker/lib/
   trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql
Removed:
   trunk/gforge/plugins/contribtracker/db/
Modified:
   trunk/gforge/debian/changelog
   trunk/gforge/debian/control
   trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php
Log:
Initial plugin.  Can be installed, but won't do much.

Modified: trunk/gforge/debian/changelog
===================================================================
--- trunk/gforge/debian/changelog	2009-12-18 17:38:30 UTC (rev 8567)
+++ trunk/gforge/debian/changelog	2009-12-18 17:38:42 UTC (rev 8568)
@@ -13,6 +13,7 @@
     scmbzr, scmdarcs, scmgit and scmhg.  Mercurial (scmhg) and Arch are
     not quite complete yet.
   * Patched mediawiki plugin to enable one wiki per project.
+  * New contribtracker plugin, developed for Adullact.
 
   [ Christian Bayle ]
   * Remove frame from mediawiki 

Modified: trunk/gforge/debian/control
===================================================================
--- trunk/gforge/debian/control	2009-12-18 17:38:30 UTC (rev 8567)
+++ trunk/gforge/debian/control	2009-12-18 17:38:42 UTC (rev 8568)
@@ -344,7 +344,7 @@
 
 Package: gforge-plugin-contribtracker
 Architecture: all
-Depends: gforge-common (>= 4.6.99), gforge-db-postgresql (>= 4.6.99) | gforge-db, gforge-web-apache2 (>= 4.6.99) | gforge-web, mediawiki, ${misc:Depends}
+Depends: gforge-common (>= 4.6.99), gforge-db-postgresql (>= 4.6.99) | gforge-db, gforge-web-apache2 (>= 4.6.99) | gforge-web, ${misc:Depends}
 Description: Contribution tracker plugin for FusionForge
  FusionForge provides many tools to aid collaboration in a
  development project, such as bug-tracking, task management,

Added: trunk/gforge/debian/gforge-plugin-contribtracker.postinst
===================================================================
--- trunk/gforge/debian/gforge-plugin-contribtracker.postinst	                        (rev 0)
+++ trunk/gforge/debian/gforge-plugin-contribtracker.postinst	2009-12-18 17:38:42 UTC (rev 8568)
@@ -0,0 +1,47 @@
+#! /bin/sh
+# postinst script for gforge-plugin-contribtracker
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+case "$1" in
+    configure)
+        /usr/share/gforge/plugins/contribtracker/bin/db-upgrade.pl
+        /usr/share/gforge/bin/register-plugin contribtracker "Contribution Tracker"
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0

Added: trunk/gforge/debian/gforge-plugin-contribtracker.prerm
===================================================================
--- trunk/gforge/debian/gforge-plugin-contribtracker.prerm	                        (rev 0)
+++ trunk/gforge/debian/gforge-plugin-contribtracker.prerm	2009-12-18 17:38:42 UTC (rev 8568)
@@ -0,0 +1,38 @@
+#! /bin/sh
+# prerm script for gforge-plugin-contribtracker
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|deconfigure)
+        /usr/share/gforge/bin/unregister-plugin contribtracker
+        /usr/share/gforge/plugins/contribtracker/bin/db-delete.pl
+        ;;
+    upgrade|failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0

Added: trunk/gforge/packaging/install/plugin-contribtracker
===================================================================
--- trunk/gforge/packaging/install/plugin-contribtracker	                        (rev 0)
+++ trunk/gforge/packaging/install/plugin-contribtracker	2009-12-18 17:38:42 UTC (rev 8568)
@@ -0,0 +1,3 @@
+plugins/contribtracker/bin/*                   usr/share/gforge/plugins/contribtracker/bin/
+plugins/contribtracker/common/*                usr/share/gforge/plugins/contribtracker/common/
+plugins/contribtracker/lib/*                   usr/share/gforge/plugins/contribtracker/lib/

Added: trunk/gforge/plugins/contribtracker/bin/db-delete.pl
===================================================================
--- trunk/gforge/plugins/contribtracker/bin/db-delete.pl	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/bin/db-delete.pl	2009-12-18 17:38:42 UTC (rev 8568)
@@ -0,0 +1,193 @@
+#!/usr/bin/perl -w
+#
+# Debian-specific script to delete plugin-specific tables
+# Roland Mas <lolando at debian.org>
+
+use strict ;
+use diagnostics ;
+
+use DBI ;
+use MIME::Base64 ;
+use HTML::Entities ;
+
+use vars qw/$dbh @reqlist $query/ ;
+use vars qw/$sys_default_domain $sys_cvs_host $sys_download_host
+    $sys_shell_host $sys_users_host $sys_docs_host $sys_lists_host
+    $sys_dns1_host $sys_dns2_host $FTPINCOMING_DIR $FTPFILES_DIR
+    $sys_urlroot $sf_cache_dir $sys_name $sys_themeroot
+    $sys_news_group $sys_dbhost $sys_dbname $sys_dbuser $sys_dbpasswd
+    $sys_ldap_base_dn $sys_ldap_host $admin_login $admin_password
+    $server_admin $domain_name $newsadmin_groupid $statsadmin_groupid
+    $skill_list/ ;
+use vars qw/$pluginname/ ;
+
+sub is_lesser ( $$ ) ;
+sub is_greater ( $$ ) ;
+sub debug ( $ ) ;
+sub parse_sql_file ( $ ) ;
+
+require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions 
+require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
+
+debug "You'll see some debugging info during this installation." ;
+debug "Do not worry unless told otherwise." ;
+
+&db_connect ;
+
+# debug "Connected to the database OK." ;
+
+$pluginname = "contribtracker" ;
+
+$dbh->{AutoCommit} = 0;
+$dbh->{RaiseError} = 1;
+eval {
+    my ($sth, @array, $version, $action, $path, $target, $rname) ;
+
+    # Inter-table dependencies require manual hinting for dropping order
+    foreach my $t (qw/participation actor/) {
+	my $table = "plugin_${pluginname}_$t" ;
+	&drop_table_if_exists ($table) ;
+    }
+
+    my $pattern = "plugin_" . $pluginname . '_%' ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='v'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_view_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='r'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_table_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='i'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_index_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $query = "SELECT relname FROM pg_class WHERE relname LIKE '$pattern' AND relkind='S'" ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (@array = $sth->fetchrow_array ()) {
+	$rname = $array [0] ;
+	&drop_sequence_if_exists ($rname) ;
+    }
+    $sth->finish () ;
+
+    $dbh->commit ();
+
+
+    debug "It seems your database deletion went well and smoothly.  That's cool." ;
+    debug "Please enjoy using Debian GForge." ;
+
+    # There should be a commit at the end of every block above.
+    # If there is not, then it might be symptomatic of a problem.
+    # For safety, we roll back.
+    $dbh->rollback ();
+};
+
+if ($@) {
+    warn "Transaction aborted because $@" ;
+    debug "Transaction aborted because $@" ;
+    debug "Last SQL query was:\n$query\n(end of query)" ;
+    $dbh->rollback ;
+    debug "Please report this bug on the Debian bug-tracking system." ;
+    debug "Please include the previous messages as well to help debugging." ;
+    debug "You should not worry too much about this," ;
+    debug "your DB is still in a consistent state and should be usable." ;
+    exit 1 ;
+}
+
+$dbh->rollback ;
+$dbh->disconnect ;
+
+sub debug ( $ ) {
+    my $v = shift ;
+    chomp $v ;
+    print STDERR "$v\n" ;
+}
+
+sub drop_table_if_exists ( $ ) {
+    my $tname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$tname' AND relkind='r'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping table $tname" ;
+	$query = "DROP TABLE $tname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_sequence_if_exists ( $ ) {
+    my $sname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$sname' AND relkind='S'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping sequence $sname" ;
+	$query = "DROP SEQUENCE $sname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_index_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='i'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping index $iname" ;
+	$query = "DROP INDEX $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_view_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='v'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping view $iname" ;
+	$query = "DROP VIEW $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}

Added: trunk/gforge/plugins/contribtracker/bin/db-upgrade.pl
===================================================================
--- trunk/gforge/plugins/contribtracker/bin/db-upgrade.pl	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/bin/db-upgrade.pl	2009-12-18 17:38:42 UTC (rev 8568)
@@ -0,0 +1,274 @@
+#!/usr/bin/perl -w
+#
+# Debian-specific script to upgrade the database between releases
+# Roland Mas <lolando at debian.org>
+
+use strict ;
+use diagnostics ;
+
+use DBI ;
+use MIME::Base64 ;
+use HTML::Entities ;
+
+use vars qw/$dbh @reqlist $query/ ;
+use vars qw/$sys_default_domain $sys_cvs_host $sys_download_host
+    $sys_shell_host $sys_users_host $sys_docs_host $sys_lists_host
+    $sys_dns1_host $sys_dns2_host $FTPINCOMING_DIR $FTPFILES_DIR
+    $sys_urlroot $sf_cache_dir $sys_name $sys_themeroot
+    $sys_news_group $sys_dbhost $sys_dbname $sys_dbuser $sys_dbpasswd
+    $sys_ldap_base_dn $sys_ldap_host $admin_login $admin_password
+    $server_admin $domain_name $newsadmin_groupid $statsadmin_groupid
+    $skill_list/ ;
+use vars qw/$pluginname/ ;
+
+sub is_lesser ( $$ ) ;
+sub is_greater ( $$ ) ;
+sub debug ( $ ) ;
+sub parse_sql_file ( $ ) ;
+
+require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions 
+require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
+
+debug "You'll see some debugging info during this installation." ;
+debug "Do not worry unless told otherwise." ;
+
+&db_connect ;
+
+# debug "Connected to the database OK." ;
+
+$pluginname = "contribtracker" ;
+
+$dbh->{AutoCommit} = 0;
+$dbh->{RaiseError} = 1;
+eval {
+    my ($sth, @array, $version, $path, $target) ;
+
+    &create_metadata_table ("0") ;
+    
+    $version = &get_db_version ;
+    $target = "0.1" ;
+    if (is_lesser $version, $target) {
+	my @filelist = ( "/usr/share/gforge/plugins/$pluginname/lib/$pluginname-init.sql" ) ;
+	
+	foreach my $file (@filelist) {
+	    debug "Processing $file" ;
+	    @reqlist = @{ &parse_sql_file ($file) } ;
+	    
+	    foreach my $s (@reqlist) {
+		$query = $s ;
+		# debug $query ;
+		$sth = $dbh->prepare ($query) ;
+		$sth->execute () ;
+		$sth->finish () ;
+	    }
+	}
+	@reqlist = () ;
+	
+	&update_db_version ($target) ;
+	debug "Committing." ;
+	$dbh->commit () ;
+    }
+    
+    debug "It seems your database install/upgrade went well and smoothly.  That's cool." ;
+    debug "Please enjoy using Debian GForge." ;
+
+    # There should be a commit at the end of every block above.
+    # If there is not, then it might be symptomatic of a problem.
+    # For safety, we roll back.
+    $dbh->rollback ();
+};
+
+if ($@) {
+    warn "Transaction aborted because $@" ;
+    debug "Transaction aborted because $@" ;
+    debug "Last SQL query was:\n$query\n(end of query)" ;
+    $dbh->rollback ;
+    debug "Please report this bug on the Debian bug-tracking system." ;
+    debug "Please include the previous messages as well to help debugging." ;
+    debug "You should not worry too much about this," ;
+    debug "your DB is still in a consistent state and should be usable." ;
+    exit 1 ;
+}
+
+$dbh->rollback ;
+$dbh->disconnect ;
+
+sub is_lesser ( $$ ) {
+    my $v1 = shift || 0 ;
+    my $v2 = shift || 0 ;
+
+    my $rc = system "dpkg --compare-versions $v1 lt $v2" ;
+
+    return (! $rc) ;
+}
+
+sub is_greater ( $$ ) {
+    my $v1 = shift || 0 ;
+    my $v2 = shift || 0 ;
+
+    my $rc = system "dpkg --compare-versions $v1 gt $v2" ;
+
+    return (! $rc) ;
+}
+
+sub debug ( $ ) {
+    my $v = shift ;
+    chomp $v ;
+    print STDERR "$v\n" ;
+}
+
+sub create_metadata_table ( $ ) {
+    my $v = shift || "0" ;
+    my $tablename = "plugin_" .$pluginname . "_meta_data" ;
+    # Do we have the metadata table?
+
+    $query = "SELECT count(*) FROM pg_class WHERE relname = '$tablename' and relkind = 'r'";
+    # debug $query ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    # Let's create this table if we have it not
+
+    if ($array [0] == 0) {
+	debug "Creating $tablename table." ;
+	$query = "CREATE TABLE $tablename (key varchar primary key, value text not null)" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+
+    $query = "SELECT count(*) FROM $tablename WHERE key = 'db-version'";
+    # debug $query ;
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    # Empty table?  We'll have to fill it up a bit
+
+    if ($array [0] == 0) {
+	debug "Inserting first data into $tablename table." ;
+	$query = "INSERT INTO $tablename (key, value) VALUES ('db-version', '$v')" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub update_db_version ( $ ) {
+    my $v = shift or die "Not enough arguments" ;
+    my $tablename = "plugin_" .$pluginname . "_meta_data" ;
+
+    debug "Updating $tablename table." ;
+    $query = "UPDATE $tablename SET value = '$v' WHERE key = 'db-version'" ;
+    # debug $query ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    $sth->finish () ;
+}
+
+sub get_db_version () {
+    my $tablename = "plugin_" .$pluginname . "_meta_data" ;
+
+    $query = "SELECT value FROM $tablename WHERE key = 'db-version'" ;
+    # debug $query ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    my $version = $array [0] ;
+
+    return $version ;
+}
+
+sub drop_table_if_exists ( $ ) {
+    my $tname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$tname' AND relkind='r'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping table $tname" ;
+	$query = "DROP TABLE $tname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_sequence_if_exists ( $ ) {
+    my $sname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$sname' AND relkind='S'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping sequence $sname" ;
+	$query = "DROP SEQUENCE $sname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_index_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='i'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping index $iname" ;
+	$query = "DROP INDEX $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub drop_view_if_exists ( $ ) {
+    my $iname = shift or die  "Not enough arguments" ;
+    $query = "SELECT count(*) FROM pg_class WHERE relname='$iname' AND relkind='v'" ;
+    my $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    my @array = $sth->fetchrow_array () ;
+    $sth->finish () ;
+
+    if ($array [0] != 0) {
+	# debug "Dropping view $iname" ;
+	$query = "DROP VIEW $iname" ;
+	# debug $query ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+    }
+}
+
+sub bump_sequence_to ( $$ ) {
+    my ($sth, @array, $seqname, $targetvalue) ;
+
+    $seqname = shift ;
+    $targetvalue = shift ;
+
+    do {
+	$query = "select nextval ('$seqname')" ;
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	@array = $sth->fetchrow_array () ;
+	$sth->finish () ;
+    } until $array[0] >= $targetvalue ;
+}

Modified: trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php
===================================================================
--- trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php	2009-12-18 17:38:30 UTC (rev 8567)
+++ trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php	2009-12-18 17:38:42 UTC (rev 8568)
@@ -30,9 +30,7 @@
 		$this->hooks[] = "groupmenu" ;	// To put into the project tabs
 		$this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
 		$this->hooks[] = "groupisactivecheckboxpost" ; //
-		$this->hooks[] = "userisactivecheckbox" ; // The "use ..." checkbox in user account
-		$this->hooks[] = "userisactivecheckboxpost" ; //
-		$this->hooks[] = "project_admin_plugins"; // to show up in the admin page fro group
+		$this->hooks[] = "project_admin_plugins"; // to show up in the admin page for group
 	}
 
 	function CallHook ($hookname, $params) {
@@ -49,11 +47,8 @@
 				return;
 			}
 			if ( $project->usesPlugin ( $this->name ) ) {
-				$params['TITLES'][]=$this->text;
+				$params['TITLES'][] = _('Contribution tracker') ;
 				$params['DIRS'][]='/plugins/contribtracker/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name; // we indicate the part we're calling is the project one
-			} else {
-				$params['TITLES'][]=$this->text." is [Off]";
-				$params['DIRS'][]='';
 			}	
 			(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
 		} elseif ($hookname == "groupisactivecheckbox") {
@@ -84,52 +79,6 @@
 			} else {
 				$group->setPluginUse ( $this->name, false );
 			}
-		} elseif ($hookname == "userisactivecheckbox") {
-			//check if user is active
-			// this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
-			$user = $params['user'];
-			echo "<tr>";
-			echo "<td>";
-			echo ' <input type="CHECKBOX" name="use_contribtrackerplugin" value="1" ';
-			// CHECKED OR UNCHECKED?
-			if ( $user->usesPlugin ( $this->name ) ) {
-				echo "CHECKED";
- 			}
-			echo ">    Use ".$this->text." Plugin";
-			echo "</td>";
-			echo "</tr>";
-		} elseif ($hookname == "userisactivecheckboxpost") {
-			// this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
-			$user = $params['user'];
-			$use_contribtrackerplugin = getStringFromRequest('use_contribtrackerplugin');
-			if ( $use_contribtrackerplugin == 1 ) {
-				$user->setPluginUse ( $this->name );
-			} else {
-				$user->setPluginUse ( $this->name, false );
-			}
-			echo "<tr>";
-			echo "<td>";
-			echo ' <input type="CHECKBOX" name="use_contribtrackerplugin" value="1" ';
-			// CHECKED OR UNCHECKED?
-			if ( $user->usesPlugin ( $this->name ) ) {
-				echo "CHECKED";
-			}
-			echo ">    Use ".$this->text." Plugin";
-			echo "</td>";
-			echo "</tr>";
-		} elseif ($hookname == "user_personal_links") {
-			// this displays the link in the user's profile page to it's personal ContribTracker (if you want other sto access it, youll have to change the permissions in the index.php
-			$userid = $params['user_id'];
-			$user = user_get_object($userid);
-			$text = $params['text'];
-			//check if the user has the plugin activated
-			if ($user->usesPlugin($this->name)) {
-				echo '	<p>' ;
-				echo util_make_link ("/plugins/contribtracker/index.php?id=$userid&type=user&pluginname=".$this->name,
-						     _('View Personal ContribTracker')
-					);
-				echo '</p>';
-			}
 		} elseif ($hookname == "project_admin_plugins") {
 			// this displays the link in the project admin options page to it's  ContribTracker administration
 			$group_id = $params['group_id'];

Added: trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql
===================================================================
--- trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql	2009-12-18 17:38:42 UTC (rev 8568)
@@ -0,0 +1,49 @@
+CREATE SEQUENCE plugin_contribtracker_legal_structure_pk_seq ;
+CREATE TABLE plugin_contribtracker_legal_structure (
+       struct_id integer DEFAULT nextval('plugin_contribtracker_legal_structure_pk_seq') NOT NULL,
+       struct_name text DEFAULT '' NOT NULL,
+       PRIMARY KEY (struct_id)
+) ;
+
+CREATE SEQUENCE plugin_contribtracker_role_pk_seq ;
+CREATE TABLE plugin_contribtracker_role (
+       role_id integer DEFAULT nextval('plugin_contribtracker_role_pk_seq') NOT NULL,
+       role_name text,
+       role_description text,
+       PRIMARY KEY (role_id)
+) ;
+
+CREATE SEQUENCE plugin_contribtracker_actor_pk_seq ;
+CREATE TABLE plugin_contribtracker_actor (
+       actor_id integer DEFAULT nextval('plugin_contribtracker_actor_pk_seq') NOT NULL,
+       actor_name text,
+       actor_address text,
+       actor_email text,
+       actor_description text,
+       struct_id integer,
+       PRIMARY KEY (actor_id),
+       FOREIGN KEY (struct_id) REFERENCES plugin_contribtracker_legal_structure (struct_id)
+) ;
+
+CREATE SEQUENCE plugin_contribtracker_contribution_pk_seq ;
+CREATE TABLE plugin_contribtracker_contribution (
+       contrib_id integer DEFAULT nextval('plugin_contribtracker_contribution_pk_seq') NOT NULL,
+       contrib_name text,
+       contrib_date int,
+       contrib_description text,
+       group_id integer,
+       PRIMARY KEY (contrib_id),
+       FOREIGN KEY (group_id) REFERENCES groups (group_id)
+) ;
+
+CREATE SEQUENCE plugin_contribtracker_participation_pk_seq ;
+CREATE TABLE plugin_contribtracker_participation (
+       participation_id integer DEFAULT nextval('plugin_contribtracker_participation_pk_seq') NOT NULL,
+       contrib_id integer,
+       actor_id integer,
+       role_id integer,
+       PRIMARY KEY (participation_id),
+       FOREIGN KEY (contrib_id) REFERENCES plugin_contribtracker_contribution (contrib_id),
+       FOREIGN KEY (actor_id) REFERENCES plugin_contribtracker_actor (actor_id),
+       FOREIGN KEY (role_id) REFERENCES plugin_contribtracker_role (role_id)
+) ;




More information about the Fusionforge-commits mailing list