[Fusionforge-commits] r7510 - in trunk/gforge/plugins: . extratabs extratabs/bin extratabs/db extratabs/debian extratabs/include extratabs/www

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Apr 29 10:58:49 CEST 2009


Author: lolando
Date: 2009-04-29 10:58:49 +0200 (Wed, 29 Apr 2009)
New Revision: 7510

Added:
   trunk/gforge/plugins/extratabs/
   trunk/gforge/plugins/extratabs/README
   trunk/gforge/plugins/extratabs/bin/
   trunk/gforge/plugins/extratabs/bin/db-delete.pl
   trunk/gforge/plugins/extratabs/bin/db-upgrade.pl
   trunk/gforge/plugins/extratabs/db/
   trunk/gforge/plugins/extratabs/db/extratabs-init.sql
   trunk/gforge/plugins/extratabs/debian/
   trunk/gforge/plugins/extratabs/debian/changelog
   trunk/gforge/plugins/extratabs/debian/control
   trunk/gforge/plugins/extratabs/debian/copyright
   trunk/gforge/plugins/extratabs/debian/dirs
   trunk/gforge/plugins/extratabs/debian/postinst
   trunk/gforge/plugins/extratabs/debian/prerm
   trunk/gforge/plugins/extratabs/debian/rules
   trunk/gforge/plugins/extratabs/include/
   trunk/gforge/plugins/extratabs/include/ExtraTabsPlugin.class
   trunk/gforge/plugins/extratabs/include/extratabs-init.php
   trunk/gforge/plugins/extratabs/www/
   trunk/gforge/plugins/extratabs/www/index.php
Log:
New extratabs plugin (temp commit)

Added: trunk/gforge/plugins/extratabs/README
===================================================================
--- trunk/gforge/plugins/extratabs/README	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/README	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,41 @@
+
+Presentation
+------------
+
+This plugin has been written for Gforge 4.5. The plugin add a new page
+"Extra tabs" in the "group admin" page. There you can create new tabs that
+will appear on all project pages.
+
+The purpose is to let people point to external resources related to the
+project. For example, a project might use an external bugzilla and they
+want to point people there.
+
+The administrators of projects can now add such links. They must simply
+give an URL and a name.
+
+Installation
+------------
+
+This is valid Debian source package. You can use "fakeroot debian/rules
+binary" or "debuild -us -uc" to generate a Debian package.
+
+If you're not using Debian, then please read debian/rules and work out
+where the files need to be copied (it's very easy). :-)
+
+Requirements
+------------
+
+This plugin needs a hook called 'groupadminmenu' which has been added to
+the CVS repository after the release of Gforge 4.5:
+http://gforge.org/plugins/scmcvs/cvsweb.php/gforge/www/project/admin/project_admin_utils.php.diff?r1=1.18;r2=1.19;cvsroot=gforge
+
+You can apply this diff manually however if needed.
+
+Contact
+-------
+
+This plugin has been written by Raphael Hertzog <hertzog at debian.org>
+for the Adullact.net Gforge.
+
+http://www.adullact.net
+

Added: trunk/gforge/plugins/extratabs/bin/db-delete.pl
===================================================================
--- trunk/gforge/plugins/extratabs/bin/db-delete.pl	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/bin/db-delete.pl	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,189 @@
+#!/usr/bin/perl -w
+#
+# $Id: db-delete.pl,v 1.1.1.1 2005/09/22 17:32:56 rhertzog Exp $
+#
+# 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/lib/gforge/lib/include.pl") ; # Include a few predefined functions 
+require ("/usr/lib/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 = "extratabs" ;
+
+$dbh->{AutoCommit} = 0;
+$dbh->{RaiseError} = 1;
+eval {
+    my ($sth, @array, $version, $action, $path, $target, $rname) ;
+
+    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 () ;
+    }
+}


Property changes on: trunk/gforge/plugins/extratabs/bin/db-delete.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/gforge/plugins/extratabs/bin/db-upgrade.pl
===================================================================
--- trunk/gforge/plugins/extratabs/bin/db-upgrade.pl	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/bin/db-upgrade.pl	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,278 @@
+#!/usr/bin/perl -w
+#
+# $Id: db-upgrade.pl,v 1.1.1.1 2005/09/22 17:32:56 rhertzog Exp $
+#
+# Debian-specific script to upgrade the database between releases
+# Roland Mas <lolando at debian.org>
+#
+# Adapted by Raphael Hertzog <hertzog at debian.org> for extratabs
+
+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/lib/gforge/lib/include.pl") ; # Include a few predefined functions 
+require ("/usr/lib/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 = "extratabs" ;
+
+$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/lib/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 ;
+}


Property changes on: trunk/gforge/plugins/extratabs/bin/db-upgrade.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/gforge/plugins/extratabs/db/extratabs-init.sql
===================================================================
--- trunk/gforge/plugins/extratabs/db/extratabs-init.sql	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/db/extratabs-init.sql	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,7 @@
+CREATE TABLE plugin_extratabs_main (
+	group_id int NOT NULL,
+	index int NOT NULL,
+	tab_name text NOT NULL,
+	tab_url text NOT NULL,
+	PRIMARY KEY(group_id, index)
+) ;

Added: trunk/gforge/plugins/extratabs/debian/changelog
===================================================================
--- trunk/gforge/plugins/extratabs/debian/changelog	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/debian/changelog	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,21 @@
+gforge-plugin-extratabs (1.0-2) experimental; urgency=low
+
+  * Really adopted the package, and changed the debian/control and
+    debian/copyright files accordingly.
+
+ -- Roland Mas <lolando at debian.org>  Tue, 13 Jun 2006 23:32:00 +0200
+
+gforge-plugin-extratabs (1.0-1) experimental; urgency=low
+
+  * Adopted package.  Thanks, Raphaël!
+  * Updated to match Gforge 4.5.14.
+  * Only try to restart the installed versions of Apache.
+
+ -- Roland Mas <lolando at debian.org>  Tue, 13 Jun 2006 22:54:18 +0200
+
+gforge-plugin-extratabs (1.0) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Raphael Hertzog <hertzog at debian.org>  Fri, 16 Sep 2005 13:45:56 +0200
+

Added: trunk/gforge/plugins/extratabs/debian/control
===================================================================
--- trunk/gforge/plugins/extratabs/debian/control	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/debian/control	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,14 @@
+Source: gforge-plugin-extratabs
+Section: devel
+Priority: optional
+Maintainer: Roland Mas <lolando at debian.org>
+Build-Depends-Indep: debhelper (>> 4.0.0)
+Standards-Version: 3.6.2
+
+Package: gforge-plugin-extratabs
+Architecture: all
+Depends: gforge-common (>= 4.5.14), gforge-db-postgresql (>= 4.5.14) | gforge-db, gforge-web-apache (>= 4.5.14) | gforge-web
+Description: The Extra Tabs plugin for GForge
+ This module let each project add supplementary tabs in the project area.
+ Each project administrator can add new tabs, he can decide the name of
+ the tab and where it points to.

Added: trunk/gforge/plugins/extratabs/debian/copyright
===================================================================
--- trunk/gforge/plugins/extratabs/debian/copyright	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/debian/copyright	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,28 @@
+This package was created by Raphael Hertzog <hertzog at debian.org> but
+it's based on the "helloworld" template created by Roland Mas
+<lolando at debian.org>.
+
+It was downloaded from <http://gforge.org/projects/gplugins>
+
+Upstream Author: Raphael Hertzog <hertzog at debian.org>
+Patched (and more or less adopted) by Roland Mas afterwards.
+
+Copyright:
+
+   This package is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 dated June, 1991.
+
+   This package is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this package; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.
+
+On Debian GNU/Linux systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
+

Added: trunk/gforge/plugins/extratabs/debian/dirs
===================================================================
--- trunk/gforge/plugins/extratabs/debian/dirs	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/debian/dirs	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,18 @@
+etc
+etc/gforge
+etc/gforge/plugins
+etc/gforge/plugins/extratabs
+usr
+usr/lib
+usr/lib/gforge
+usr/lib/gforge/plugins/
+usr/lib/gforge/plugins/extratabs
+usr/lib/gforge/plugins/extratabs/bin
+usr/lib/gforge/plugins/extratabs/include
+usr/lib/gforge/plugins/extratabs/lib
+usr/lib/gforge/cgi-bin
+usr/share
+usr/share/gforge
+usr/share/gforge/www
+usr/share/gforge/www/plugins
+usr/share/gforge/www/plugins/extratabs

Added: trunk/gforge/plugins/extratabs/debian/postinst
===================================================================
--- trunk/gforge/plugins/extratabs/debian/postinst	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/debian/postinst	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,54 @@
+#! /bin/sh
+# postinst script for gforge-plugin-extratabs
+#
+# 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/lib/gforge/plugins/extratabs/bin/db-upgrade.pl
+	/usr/lib/gforge/bin/register-plugin extratabs "Extra tabs"
+	for flavour in apache apache-perl apache-ssl apache2 ; do
+	    if [ -x /usr/sbin/$flavour ]; then
+		invoke-rc.d $flavour reload || true
+	    fi
+	done
+    ;;
+
+    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/plugins/extratabs/debian/prerm
===================================================================
--- trunk/gforge/plugins/extratabs/debian/prerm	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/debian/prerm	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,41 @@
+#! /bin/sh
+# prerm script for gforge-plugin-extratabs
+#
+# 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/lib/gforge/bin/unregister-plugin extratabs
+	invoke-rc.d apache reload
+	/usr/lib/gforge/plugins/extratabs/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/plugins/extratabs/debian/rules
===================================================================
--- trunk/gforge/plugins/extratabs/debian/rules	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/debian/rules	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,91 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatibility version to use.
+export DH_COMPAT=4
+
+export PLUGIN=extratabs
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+	# Add here commands to configure the package.
+	touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+	dh_testdir
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp configure-stamp
+	dh_clean
+
+DESTDIR=$(CURDIR)/debian/gforge-plugin-$(PLUGIN)
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	cp -r bin/* $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/bin/
+	cp -r include/* $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/include/
+	cp -r lib/* $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/lib/
+	# cp -r cgi-bin/* $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/cgi-bin/
+	# cp -r etc/* $(DESTDIR)/etc/gforge/plugins/$(PLUGIN)/
+	cp -r www/* $(DESTDIR)/usr/share/gforge/www/plugins/$(PLUGIN)/
+	# install -m 0644 httpd.conf $(DESTDIR)/etc/gforge/httpd.conf.d/50$(PLUGIN)
+	# install -m 0600 httpd.secrets $(DESTDIR)/etc/gforge/httpd.secrets.d/50$(PLUGIN)
+	find $(DESTDIR)/ -name CVS -type d | xargs rm -rf
+	find $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/bin/ -type f | xargs chmod 0755
+	find $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/include/ -type f | xargs chmod 0644
+	find $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/lib/ -type f | xargs chmod 0644
+	# find $(DESTDIR)/usr/lib/gforge/plugins/$(PLUGIN)/cgi-bin/ -type f | xargs chmod 0755
+	# find $(DESTDIR)/etc/gforge/plugins/$(PLUGIN)/ -type f | xargs chmod 0644
+	find $(DESTDIR)/usr/share/gforge/www/plugins/$(PLUGIN)/ -type f | xargs chmod 0644
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+#	dh_installdebconf
+	dh_installdocs
+	dh_installexamples
+	dh_installmenu
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+#	dh_installinit
+	dh_installcron
+	dh_installman
+	dh_installinfo
+#	dh_undocumented
+	dh_installchangelogs 
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+#	dh_makeshlibs
+	dh_installdeb
+#	dh_perl
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure


Property changes on: trunk/gforge/plugins/extratabs/debian/rules
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/gforge/plugins/extratabs/include/ExtraTabsPlugin.class
===================================================================
--- trunk/gforge/plugins/extratabs/include/ExtraTabsPlugin.class	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/include/ExtraTabsPlugin.class	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,66 @@
+<?php
+/**
+ * FusionForge extratabs plugin
+ *
+ * Copyright 2005, Raphaël Hertzog
+ * Copyright 2009, Roland Mas
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ * 
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+class ExtraTabsPlugin extends Plugin {
+	function ExtraTabsPlugin () {
+		$this->Plugin() ;
+		$this->name = "extratabs" ;
+		$this->text = "Extra tabs";
+		$this->hooks[] = "project_admin_plugins" ;
+		$this->hooks[] = "groupmenu" ;  // To put into the project tabs
+	}
+
+	function CallHook ($hookname, $params) {
+		global $HTML;
+		
+		if ($hookname == "project_admin_plugins") {
+			$group_id=$params['group_id'];
+			echo util_make_link ('/plugins/extratabs/index.php?group_id='.$group_id,
+					     _('Extra tabs')).'<br />';	       
+		} elseif ($hookname == "groupmenu") {
+			$group_id=$params['group'];
+			$project = &group_get_object($group_id);
+			if (!$project || !is_object($project))
+				return;
+			if ($project->isError())
+				return;
+			if (!$project->isProject())
+				return;
+			$res_tabs = db_query("SELECT tab_name, tab_url FROM plugin_extratabs_main
+					      WHERE group_id='$group_id' ORDER BY index");
+			while ($row_tab = db_fetch_array($res_tabs)) {
+				$params['DIRS'][] = $row_tab['tab_url'];
+				$params['TITLES'][] = $row_tab['tab_name'];
+			}
+		}
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/gforge/plugins/extratabs/include/extratabs-init.php
===================================================================
--- trunk/gforge/plugins/extratabs/include/extratabs-init.php	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/include/extratabs-init.php	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,14 @@
+<?php
+
+require_once ($GLOBALS['sys_plugins_path'].'/extratabs/common/ExtraTabsPlugin.class') ;
+
+$ExtraTabsPluginObject = new ExtraTabsPlugin ;
+
+register_plugin ($ExtraTabsPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/gforge/plugins/extratabs/www/index.php
===================================================================
--- trunk/gforge/plugins/extratabs/www/index.php	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/www/index.php	2009-04-29 08:58:49 UTC (rev 7510)
@@ -0,0 +1,177 @@
+<?php
+/*
+ * Hello world plugin
+ *
+ * Roland Mas <lolando at debian.org>
+ */
+
+require_once ('../../../www/env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfcommon.'/include/FusionForge.class.php';
+
+$group_id = getIntFromRequest ('group_id') ;
+$func = getStringFromRequest ('func') ;
+
+session_require(array('group'=>$group_id,'admin_flags'=>'A'));
+
+// get current information
+$group =& group_get_object($group_id);
+if (!$group || !is_object($group)) {
+        exit_error('Error','Could Not Get Group');
+} elseif ($group->isError()) {
+        exit_error('Error',$group->getErrorMessage());
+}
+
+$perm =& $group->getPermission( session_get_user() );
+if (!$perm || !is_object($perm)) {
+        exit_error('Error','Could Not Get Permission');
+} elseif ($perm->isError()) {
+        exit_error('Error',$perm->getErrorMessage());
+}
+
+if (!$perm->isAdmin()) {
+        exit_permission_denied();
+}
+
+// Calculate new index field
+$res = db_query("SELECT COUNT(*) as c FROM plugin_extratabs_main 
+		 WHERE group_id = '$group_id'");
+$row = db_fetch_array($res);
+$newid = $row['c'] + 1;
+
+$selected = 0; // No item selected by default
+$index = getIntFromRequest ('index') ;
+
+// Do work before displaying so that the result is immediately visible
+if (getStringFromRequest ('addtab') != '') {
+	$tab_name = addslashes (getStringFromRequest ('tab_name')) ;
+	$tab_url = addslashes (getStringFromRequest ('tab_url')) ;
+	$res = db_query("INSERT INTO plugin_extratabs_main (group_id, index, tab_name, tab_url)
+		  	 VALUES('$group_id','$newid','$tab_name','$tab_url')");
+
+	if (!$res || db_affected_rows($res) < 1) {
+		$feedback .= sprintf (_('Cannot insert new tab entry: %s'),
+				      db_error());
+	} else {
+		$feedback .= _('Tab added');
+	}
+} elseif (getStringFromRequest ('delete') != '') {
+	$res = db_query("DELETE FROM plugin_extratabs_main
+			 WHERE group_id='$group_id' AND
+			 index='$index'");
+	if (!$res || db_affected_rows($res) < 1) {
+		$feedback .= sprintf (_('Cannot delete tab entry: %s'),
+				      db_error());
+	} else {
+		$res = db_query("UPDATE plugin_extratabs_main
+			 SET index = index - 1
+			 WHERE group_id = '$group_id' AND
+			 index > $index");
+	}
+  } elseif (getStringFromRequest ('up') != '') {
+	if ($index > 1) {
+		$previous = $index - 1;
+		$res = db_query("
+		    UPDATE plugin_extratabs_main
+		    SET index = 0 
+		    WHERE group_id = '$group_id' AND index = $index
+		");
+		$res = db_query("
+		    UPDATE plugin_extratabs_main
+		    SET index = $index 
+		    WHERE group_id = '$group_id' AND index = $previous
+		");
+		$res = db_query("
+		    UPDATE plugin_extratabs_main
+		    SET index = $previous
+		    WHERE group_id = '$group_id' AND index = 0
+		");
+		$selected = $previous;
+	} else {
+	    $selected = $index;
+	}
+} elseif (getStringFromRequest ('down') != '') {
+	if ($index < $newid - 1) {
+		$next = $index + 1;
+		$res = db_query("
+		    UPDATE plugin_extratabs_main
+		    SET index = 0 
+		    WHERE group_id = '$group_id' AND index = $index
+		");
+		$res = db_query("
+		    UPDATE plugin_extratabs_main
+		    SET index = $index 
+		    WHERE group_id = '$group_id' AND index = $next
+		");
+		$res = db_query("
+		    UPDATE plugin_extratabs_main
+		    SET index = $next
+		    WHERE group_id = '$group_id' AND index = 0
+		");
+		$selected = $next;
+	} else {
+	    $selected = $index;
+	}
+}
+
+$adminheadertitle=sprintf(_('Project Admin: %1$s'), $group->getPublicName() );
+project_admin_header(array('title'=>$adminheadertitle, 'group'=>$group->getID()));
+
+?>
+
+<p>&nbsp;</p>
+
+<h3><?php echo _('Add new tabs'); ?></h3>
+<p><?php echo _('You can add your own tabs in the menu bar with the form below.') ?></p>
+<p>
+
+<form name="new_tab" action="<?php echo util_make_url ('/plugins/extratabs/?group_id='.$group->getID()); ?>" method="post">
+<input type="hidden" name="addtab" value="1" />
+<input type="hidden" name="newid" value="<?php echo $newid ?>" />
+	<strong><?php echo _('Name of the tab:') ?></strong>
+<?php echo utils_requiredField(); ?><br/>
+<input type="text" size="15" maxlength="255" name="tab_name" /><br/>
+	<strong><?php echo _('URL of the tab:') ?></strong>
+<?php echo utils_requiredField(); ?><br/>
+<input type="text" size="15" name="tab_url" value="http://" /><br/>
+<input type="submit" value="<?php echo _('Add tab') ?>" />
+</form>
+</p>
+
+	<h3><?php echo _('Manage extra tabs') ;?></h3>
+<p>
+	<?php echo _('You can move and delete the tabs that you already added. Please note that those extra tabs can only appear on the right of the standard tabs. And you can only move them inside the set of extra tabs.') ;
+
+$res = db_query("SELECT * FROM plugin_extratabs_main
+		 WHERE group_id='$group_id' ORDER BY index ASC");
+
+?></p><p>
+<form name="change_tab" action="<?php echo util_make_url ('/plugins/extratabs?group_id='.$group->getID()); ?>" method="post">
+<?php 
+	echo _('Tab to modify:')
+?>
+<select name="index">
+<?php
+while ($row = db_fetch_array($res)) {
+    if ($row['index'] == $selected) {
+	echo "<option selected value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
+    } else {
+	echo "<option value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
+    }
+} ?>
+</select><br/><br/>
+<input type="submit" name="up" value="<?php echo _('Move tab left') ?>" /><br/>
+<input type="submit" name="down" value="<?php echo _('Move tab right') ?>" /><br/>
+<input type="submit" name="delete" value="<?php echo _('Delete tab') ?>" />
+</form>
+</p>
+
+<?php
+project_admin_footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>




More information about the Fusionforge-commits mailing list