[evolvis-commits] r13292: New projectlabels plugin, ported to 4.7
mirabilos at evolvis.org
mirabilos at evolvis.org
Mon Feb 28 02:26:54 CET 2011
Author: mirabilos
Date: 2011-02-28 02:26:54 +0100 (Mon, 28 Feb 2011)
New Revision: 13292
Added:
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/README
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-delete.pl
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-upgrade.pl
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/ProjectLabelsPlugin.class
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/projectlabels-init.php
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/db/
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/db/projectlabels-init.sql
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/www/
trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/www/index.php
Modified:
trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog
trunk/gforge_base/evolvisforge-5.1/gforge/debian/control
trunk/gforge_base/evolvisforge-5.1/gforge/debian/rules
Log:
New projectlabels plugin, ported to 4.7
Modified: trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog 2011-02-28 01:26:50 UTC (rev 13291)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/debian/changelog 2011-02-28 01:26:54 UTC (rev 13292)
@@ -5,8 +5,9 @@
* New extratabs plugin from Adullact.
* New globalsearch plugin allowing to publish lists of projects for
other forges and to search for projects in remote forges.
+ * New projectlabels plugin from Adullact.
- -- Roland Mas <lolando at debian.org> Wed, 29 Apr 2009 11:10:10 +0200
+ -- Roland Mas <lolando at debian.org> Wed, 29 Apr 2009 11:54:57 +0200
gforge (4.8~rc1-1+1) experimental; urgency=low
Modified: trunk/gforge_base/evolvisforge-5.1/gforge/debian/control
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/debian/control 2011-02-28 01:26:50 UTC (rev 13291)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/debian/control 2011-02-28 01:26:54 UTC (rev 13292)
@@ -267,3 +267,14 @@
This plugin contains a cross-Gforge search engine. You can declare a
list of other Gforge sites, and search for projects hosted on these
forges from your own.
+
+Package: gforge-plugin-projectlabels
+Architecture: all
+Depends: gforge-common (>= 4.6.99), gforge-db-postgresql (>= 4.6.99) | gforge-db, gforge-web-apache2 (>= 4.6.99) | gforge-web
+Description: Project labels plugin for GForge
+ This plugin allows the site administrator to define labels and bits
+ of HTML to render them, and to stick these labels onto projects. The
+ HTML is then displayed with the project description.
+ .
+ This can be used to highlight some projects on a forge, for instance
+ for a "project of the month".
Modified: trunk/gforge_base/evolvisforge-5.1/gforge/debian/rules
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/debian/rules 2011-02-28 01:26:50 UTC (rev 13291)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/debian/rules 2011-02-28 01:26:54 UTC (rev 13292)
@@ -125,6 +125,12 @@
chmod 755 $(CURDIR)/debian/$(PACKAGE)-db-postgresql/usr/share/*/db/*.php
chmod 644 $(CURDIR)/debian/$(PACKAGE)-db-postgresql/usr/share/gforge/cronjobs/*.inc
+ # gforge-plugin-projectlabels
+ cp -r plugins/projectlabels/bin/* $(CURDIR)/debian/gforge-plugin-projectlabels/usr/lib/gforge/plugins/projectlabels/bin/
+ cp -r plugins/projectlabels/common/* $(CURDIR)/debian/gforge-plugin-projectlabels/usr/share/gforge/plugins/projectlabels/common/
+ cp -r plugins/projectlabels/db/* $(CURDIR)/debian/gforge-plugin-projectlabels/usr/lib/gforge/plugins/projectlabels/lib/
+ cp -r plugins/projectlabels/www/* $(CURDIR)/debian/gforge-plugin-projectlabels/usr/share/gforge/www/plugins/projectlabels/
+
# viewvc rights
find $(CURDIR)/debian/$(PACKAGE)-web-apache2/usr/share/*/www/scm/viewvc -type f -exec chmod 0644 {} \;
grep -ril '^#!' $(CURDIR)/debian/$(PACKAGE)-web-apache2/usr/share/*/www/scm/viewvc | xargs chmod 0755
Added: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/README
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/README (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/README 2011-02-28 01:26:54 UTC (rev 13292)
@@ -0,0 +1,29 @@
+Presentation
+------------
+
+This plugin has been written for Gforge 4.5. It allows the site
+administrator to define any number of "labels", and apply one of these
+labels to projects. The labels are identified by a name and contain a
+chunk of text or HTML code. That piece of text is then displayed next
+in the overview pages of projects that are appropriately labeled.
+
+The purpose is to visually highlight a few projects, such as a
+"project of the month", on their overview pages.
+
+Installation
+------------
+
+This is a 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). :-)
+
+Contact
+-------
+
+This plugin has been written by Roland Mas <roland at gnurandal.com> for
+the Adullact.net Gforge.
+
+http://www.adullact.net/
Added: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-delete.pl
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-delete.pl (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-delete.pl 2011-02-28 01:26:54 UTC (rev 13292)
@@ -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 = "projectlabels" ;
+
+$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_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-delete.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-upgrade.pl
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-upgrade.pl (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-upgrade.pl 2011-02-28 01:26:54 UTC (rev 13292)
@@ -0,0 +1,276 @@
+#!/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>
+
+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 = "projectlabels" ;
+
+$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_base/evolvisforge-5.1/gforge/plugins/projectlabels/bin/db-upgrade.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/ProjectLabelsPlugin.class
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/ProjectLabelsPlugin.class (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/ProjectLabelsPlugin.class 2011-02-28 01:26:54 UTC (rev 13292)
@@ -0,0 +1,41 @@
+<?php
+
+class ProjectLabelsPlugin extends Plugin {
+ function ProjectLabelsPlugin () {
+ $this->Plugin() ;
+ $this->name = "projectlabels" ;
+ $this->text = "Project labels";
+ $this->hooks[] = "project_before_description" ;
+ $this->hooks[] = "site_admin_option_hook" ;
+ }
+
+ function CallHook ($hookname, $params) {
+ global $HTML;
+
+ if ($hookname == "site_admin_option_hook") {
+ echo '<li>' . util_make_link ('/plugins/projectlabels/index.php',
+ _('Project labels')) . '</li>';
+ } elseif ($hookname == "project_before_description") {
+ $group_id=$params['group_id'];
+ $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 plugin_projectlabels_labels.label_text FROM plugin_projectlabels_labels, plugin_projectlabels_group_labels
+ WHERE plugin_projectlabels_group_labels.group_id='$group_id' AND plugin_projectlabels_group_labels.label_id = plugin_projectlabels_labels.label_id");
+ while ($row_tab = db_fetch_array($res_tabs)) {
+ print ($row_tab['label_text']);
+ }
+ }
+ }
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
Added: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/projectlabels-init.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/projectlabels-init.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/common/projectlabels-init.php 2011-02-28 01:26:54 UTC (rev 13292)
@@ -0,0 +1,14 @@
+<?php
+
+require_once ($GLOBALS['sys_plugins_path'].'/projectlabels/common/ProjectLabelsPlugin.class') ;
+
+$ProjectLabelsPluginObject = new ProjectLabelsPlugin ;
+
+register_plugin ($ProjectLabelsPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
Added: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/db/projectlabels-init.sql
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/db/projectlabels-init.sql (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/db/projectlabels-init.sql 2011-02-28 01:26:54 UTC (rev 13292)
@@ -0,0 +1,19 @@
+CREATE SEQUENCE plugin_projectlabels_labelid_seq ;
+
+CREATE TABLE plugin_projectlabels_labels (
+ label_id int NOT NULL default nextval('plugin_projectlabels_labelid_seq'),
+ label_name varchar(32) UNIQUE NOT NULL,
+ label_text text NOT NULL,
+ PRIMARY KEY(label_id)
+) ;
+
+CREATE SEQUENCE plugin_projectlabels_grlabid_seq ;
+
+CREATE TABLE plugin_projectlabels_group_labels (
+ grlab_id int NOT NULL default nextval('plugin_projectlabels_grlabid_seq'),
+ group_id int UNIQUE NOT NULL,
+ label_id int NOT NULL,
+ PRIMARY KEY(grlab_id),
+ CONSTRAINT plugin_projectlabels_grlabid_gid_fk FOREIGN KEY (group_id) REFERENCES groups(group_id) MATCH FULL,
+ CONSTRAINT plugin_projectlabels_grlabid_lid_fk FOREIGN KEY (label_id) REFERENCES plugin_projectlabels_labels(label_id) MATCH FULL
+) ;
Added: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/www/index.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/www/index.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/projectlabels/www/index.php 2011-02-28 01:26:54 UTC (rev 13292)
@@ -0,0 +1,197 @@
+<?php
+/*
+ * Project labels plugin
+ *
+ * Roland Mas <lolando at debian.org>
+ */
+
+require_once '../../../www/env.inc.php';
+require_once $gfwww.'include/pre.php';
+require_once $gfwww.'admin/admin_utils.php';
+
+site_admin_header(array('title'=>_('Project labels')));
+
+$func = getStringFromRequest ('func') ;
+
+if ($func == 'addlabel') {
+ $label_name = addslashes (getStringFromRequest ('label_name')) ;
+ $label_text = addslashes (getStringFromRequest ('label_text')) ;
+ $res = db_query("INSERT INTO plugin_projectlabels_labels (label_name, label_text)
+ VALUES('$label_name','$label_text')");
+
+ if (!$res || db_affected_rows($res) < 1) {
+ printf (_('Cannot insert new label: %s'),
+ db_error()) ;
+ } else {
+ echo _('Project label added');
+ }
+
+}
+if ($func == 'delete') {
+ db_begin () ;
+ $label_id = getIntFromRequest ('label_id', 0) ;
+ $res = db_query("DELETE FROM plugin_projectlabels_group_labels WHERE label_id=$label_id");
+
+ if (!$res) {
+ printf (_('Cannot delete label: %s'),
+ db_error()) ;
+ db_rollback () ;
+ } else {
+ $res = db_query("DELETE FROM plugin_projectlabels_labels WHERE label_id=$label_id");
+
+ if (!$res) {
+ printf (_('Cannot delete label: %s'),
+ db_error()) ;
+ db_rollback () ;
+ } else {
+ echo _('Project label deleted');
+ db_commit () ;
+ }
+ }
+}
+
+if ($func == 'addlabeltoproject') {
+ $label_id = getIntFromRequest ('label_id', 0) ;
+ $group_uname = addslashes (getStringFromRequest ('group_uname')) ;
+ $g = group_get_object_by_name ($group_uname) ;
+
+ $res = db_query("INSERT INTO plugin_projectlabels_group_labels (label_id, group_id)
+ VALUES($label_id, ".$g->getID().")");
+
+ if (!$res || db_affected_rows($res) < 1) {
+ printf (_('Cannot add label onto project: %s'),
+ db_error()) ;
+ } else {
+ echo _('The label has been added to the project');
+ }
+
+}
+if ($func == 'removelabelfromproject') {
+ $label_id = getIntFromRequest ('label_id', 0) ;
+ $res = db_query("DELETE FROM plugin_projectlabels_group_labels WHERE label_id = $label_id AND group_id = $group_id");
+
+ if (!$res) {
+ printf (_('Cannot remove label: %s'),
+ db_error()) ;
+ } else {
+ echo _('The label has been removed from the project') ;
+ }
+
+}
+if ($func == 'editlabel') {
+ $label_id = getIntFromRequest ('label_id', 0) ;
+ $label_name = addslashes (getStringFromRequest ('label_name')) ;
+ $label_text = addslashes (getStringFromRequest ('label_text')) ;
+ $res = db_query("UPDATE plugin_projectlabels_labels SET label_name = '$label_name', label_text = '$label_text'
+ WHERE label_id=$label_id");
+ if (!$res || db_affected_rows($res) < 1) {
+ printf (_('Cannot modify label: %s'),
+ db_error()) ;
+ } else {
+ echo _('Label has been saved') ;
+ }
+}
+if ($func == 'edit') {
+ $label_id = getIntFromRequest ('label_id', 0) ;
+ $res = db_query("SELECT label_id, label_name, label_text FROM plugin_projectlabels_labels
+ WHERE label_id=$label_id");
+ $row = db_fetch_array($res) ;
+?>
+<form name="edit_label" action="<?php echo util_make_url ('/plugins/projectlabels/') ; ?>" method="post">
+<input type="hidden" name="func" value="editlabel" />
+<input type="hidden" name="label_id" value="<?php echo $label_id ?>" />
+<?php echo utils_requiredField(); ?>
+ <?php echo _('Label name:') ; ?><br/>
+<input type="text" size="15" maxlength="32" name="label_name" value="<?php echo stripslashes ($row['label_name']) ; ?>"/> <br/>
+ <?php echo _('Displayed text (or HTML) for the label:') ; ?><br/>
+<textarea tabindex='1' accesskey="," name="label_text" rows='5'
+ cols='80'><?php echo stripslashes($row['label_text']) ; ?></textarea><br/>
+ <?php echo _('This label currently looks like this:') ." " . stripslashes($row['label_text']) ; ?>
+<input type="submit" value="<?php echo _('Save this label') ?>" />
+</form>
+<?php
+}
+?>
+
+<p>
+<?php
+
+$res = db_query("SELECT label_id, label_name, label_text FROM plugin_projectlabels_labels
+ ORDER BY label_name ASC");
+
+if (db_numrows($res) >= 1) {
+ echo "<h2>"._('Manage labels')."</h2>" ;
+ echo _('You can edit the labels that you have already created.') . "<br />" ;
+
+ while ($row = db_fetch_array($res)) {
+ echo "<h3>".stripslashes ($row['label_name'])."</h3>" ;
+ echo "<br />" . _('This label currently looks like this:') ." ";
+ echo stripslashes ($row['label_text']) . "<br />" ;
+
+ $res2 = db_query("SELECT groups.unix_group_name, groups.group_name, groups.group_id FROM groups, plugin_projectlabels_group_labels
+ WHERE plugin_projectlabels_group_labels.group_id = groups.group_id
+ AND plugin_projectlabels_group_labels.label_id=".$row['label_id']."
+ ORDER BY groups.unix_group_name ASC");
+ if (db_numrows($res2) >= 1) {
+ echo ngettext ('This label is used on the following group:',
+ 'This label is used on the following groups:',
+ db_numrows ($res2)) ;
+
+ echo "<br />";
+ while ($row2 = db_fetch_array($res2)) {
+ printf ('%1$s (%2$s)',
+ $row2['group_name'],
+ util_make_link ('/projects/'.$row2['unix_group_name'],
+ $row2['unix_group_name'])) ;
+ echo util_make_link ('/plugins/projectlabels/?func=removelabelfromproject&label_id='.$row['label_id']."&group_id=".$row2['group_id'],
+ _('[Remove this label]')) . "<br />" ;
+ }
+ } else {
+ echo _('This label is not used on any group.')."<br />" ;
+ }
+ ?>
+<form name="addlabeltoproject" method="post" action="<?php echo util_make_url ('/plugins/projectlabels/') ; ?>">
+ <?php echo _('Unix name of the project:') . " " ; ?>
+<input type=text name=group_uname>
+<input type="hidden" name="func" value="addlabeltoproject">
+<input type="submit" value="<?php echo _('Add label to project') ?>">
+<input type="hidden" value="<?php echo $row['label_id'] ;?>" name=label_id>
+</form>
+<?php
+ echo util_make_link ('/plugins/projectlabels/?func=edit&label_id='.$row['label_id'],
+ _('[Edit this label]')) ;
+ echo util_make_link ('/plugins/projectlabels/?func=delete&label_id='.$row['label_id'],
+ _('[Delete this label]')) ;
+ }
+}
+?>
+</p>
+
+ <p><?php
+
+ echo "<h2>"._('Add new labels')."</h2>" ;
+ echo _('You can create new labels with the form below.') ?></p>
+<p>
+
+<form name="new_label" action="<?php echo util_make_url ('/plugins/projectlabels/') ; ?>" method="post">
+<input type="hidden" name="func" value="addlabel" />
+<?php echo utils_requiredField(); ?>
+ <?php echo _('Name of the label:') ; ?><br/>
+<input type="text" size="15" maxlength="32" name="label_name" value="<?php echo _('potm') ; ?>"/> <br/>
+ <?php echo _('Displayed text (or HTML) for the label:') ; ?><br/>
+<textarea tabindex='1' accesskey="," name="label_text" rows='5'
+ cols='80'><?php echo _('<p><b>Project of the month!</b></p>') ; ?>
+</textarea><br/>
+<input type="submit" value="<?php echo _('Add label') ?>" />
+</form>
+</p>
+
+<?php
+site_admin_footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
More information about the evolvis-commits
mailing list