[Fusionforge-commits] r14365 - in trunk/src/plugins/extsubproj: . bin db include packaging/control packaging/dirs packaging/install view view/admin www
Olivier Berger
olberger at fusionforge.org
Wed Sep 14 14:00:20 CEST 2011
Author: olberger
Date: 2011-09-14 14:00:20 +0200 (Wed, 14 Sep 2011)
New Revision: 14365
Added:
trunk/src/plugins/extsubproj/bin/
trunk/src/plugins/extsubproj/bin/db-delete.pl
trunk/src/plugins/extsubproj/bin/db-upgrade.pl
trunk/src/plugins/extsubproj/db/
trunk/src/plugins/extsubproj/db/extsubproj-init.sql
trunk/src/plugins/extsubproj/include/
trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php
trunk/src/plugins/extsubproj/view/
trunk/src/plugins/extsubproj/view/admin/
trunk/src/plugins/extsubproj/view/admin/viewGlobalConfiguration.php
trunk/src/plugins/extsubproj/www/
trunk/src/plugins/extsubproj/www/index.php
Modified:
trunk/src/plugins/extsubproj/packaging/control/222plugin-extsubproj
trunk/src/plugins/extsubproj/packaging/dirs/plugin-extsubproj
trunk/src/plugins/extsubproj/packaging/install/plugin-extsubproj
Log:
Initial commit for dub plugin
Added: trunk/src/plugins/extsubproj/bin/db-delete.pl
===================================================================
--- trunk/src/plugins/extsubproj/bin/db-delete.pl (rev 0)
+++ trunk/src/plugins/extsubproj/bin/db-delete.pl 2011-09-14 12:00:20 UTC (rev 14365)
@@ -0,0 +1,187 @@
+#!/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 = "extsubproj" ;
+
+$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 FusionForge." ;
+
+ # 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/src/plugins/extsubproj/bin/db-delete.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/src/plugins/extsubproj/bin/db-upgrade.pl
===================================================================
--- trunk/src/plugins/extsubproj/bin/db-upgrade.pl (rev 0)
+++ trunk/src/plugins/extsubproj/bin/db-upgrade.pl 2011-09-14 12:00:20 UTC (rev 14365)
@@ -0,0 +1,301 @@
+#!/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 = "extsubproj" ;
+
+$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/db/$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 () ;
+ }
+
+# $version = &get_db_version ;
+# $target = "0.2" ;
+# if (is_lesser $version, $target) {
+# debug "Adding local data." ;
+#
+# do "/etc/gforge/local.pl" or die "Cannot read /etc/gforge/local.pl" ;
+#
+# my $ip_address = qx/host $domain_name | awk '{print \}'/ ;
+#
+# @reqlist = (
+# "INSERT INTO plugin_".$pluginname."_sample_data (domain, ip_address) VALUES ('$domain_name', '$ip_address')",
+# ) ;
+#
+# 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 FusionForge." ;
+
+ # 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/src/plugins/extsubproj/bin/db-upgrade.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/src/plugins/extsubproj/db/extsubproj-init.sql
===================================================================
--- trunk/src/plugins/extsubproj/db/extsubproj-init.sql (rev 0)
+++ trunk/src/plugins/extsubproj/db/extsubproj-init.sql 2011-09-14 12:00:20 UTC (rev 14365)
@@ -0,0 +1,5 @@
+-- Links a project to remote subprojects identified by URLs
+CREATE TABLE plugin_extsubproj_subprojects (
+ project_id integer DEFAULT 0 NOT NULL,
+ sub_project_url text NOT NULL
+);
Added: trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php
===================================================================
--- trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php (rev 0)
+++ trunk/src/plugins/extsubproj/include/extsubprojPlugin.class.php 2011-09-14 12:00:20 UTC (rev 14365)
@@ -0,0 +1,236 @@
+<?php
+
+/**
+ * extsubprojPlugin Class
+ *
+ *
+ * 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+class extsubprojPlugin extends Plugin {
+ public function __construct($id=0) {
+ $this->Plugin($id) ;
+ $this->name = "extsubproj";
+ $this->text = "External SubProjects"; // To show in the tabs, use...
+ /*
+ $this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
+ $this->_addHook("usermenu");
+ $this->_addHook("groupmenu"); // To put into the project tabs
+ $this->_addHook("groupisactivecheckbox"); // The "use ..." checkbox in editgroupinfo
+ $this->_addHook("groupisactivecheckboxpost"); //
+ $this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
+ $this->_addHook("userisactivecheckboxpost"); //
+ $this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
+ */
+ $this->_addHook('site_admin_option_hook'); // to provide a link to the site wide administrative pages of plugin
+ }
+
+ function site_admin_option_hook(&$params) {
+ // Use this to provide a link to the site wide administrative pages for your plugin
+ echo '<li>'.$this->getAdminOptionLink().'</li>';
+ }
+ /**
+ * getAdminOptionLink - return the admin link url
+ *
+ * @return string html url
+ * @access public
+ */
+ function getAdminOptionLink() {
+ return util_make_link('/plugins/'.$this->name.'/?type=globaladmin&pluginname='.$this->name,_('External subprojects admin'), array('class'=>'tabtitle', 'title'=>_('Configure the External subprojects plugin')));
+ }
+
+ /**
+ * getHeader - initialize header and js
+ * @param string type : user, project (aka group)
+ * @param array params
+ * @return bool success or not
+ */
+ function getHeader($type, $params=NULL) {
+ global $gfplugins;
+ $returned = false;
+ switch ($type) {
+ case 'globaladmin': {
+ session_require_global_perm('forge_admin');
+ global $gfwww;
+ require_once($gfwww.'admin/admin_utils.php');
+ site_admin_header(array('title'=>_('Site Global External subprojects Admin'), 'toptab'=>''));
+ $returned = true;
+ break;
+ }
+ case 'admin':
+ default: {
+ site_project_header($params);
+ $returned = true;
+ break;
+ }
+ }
+ return $returned;
+ }
+
+ /**
+ * getFooter - display footer
+ */
+ function getFooter($type) {
+ global $gfplugins;
+ $returned = false;
+ switch ($type) {
+ case 'globaladmin': {
+ session_require_global_perm('forge_admin');
+ site_admin_footer(array());
+ break;
+ }
+ case 'admin':
+ default: {
+ site_project_footer(array());
+ break;
+ }
+ }
+ return $returned;
+ }
+ /**
+ * redirect - encapsulate session_redirect to handle correctly the redirection URL
+ *
+ * @param string usually http_referer from $_SERVER
+ * @param string type of feedback : error, warning, feedback
+ * @param string the message of feedback
+ * @access public
+ */
+ function redirect($http_referer, $type, $message) {
+ switch ($type) {
+ case 'warning_msg':
+ case 'error_msg':
+ case 'feedback': {
+ break;
+ }
+ default: {
+ $type = 'error_msg';
+ }
+ }
+ $url = util_find_relative_referer($http_referer);
+ if (strpos($url,'?')) {
+ session_redirect($url.'&'.$type.'='.urlencode($message));
+ }
+ session_redirect($url.'?'.$type.'='.urlencode($message));
+ }
+
+ /**
+ * getGlobalAdminView - display the global configuration view
+ *
+ * @return boolean True
+ * @access public
+ */
+ function getGlobalAdminView() {
+ global $gfplugins, $use_tooltips;
+ include $gfplugins.$this->name.'/view/admin/viewGlobalConfiguration.php';
+ return true;
+ }
+
+// function CallHook ($hookname, &$params) {
+// global $use_extsubprojplugin,$G_SESSION,$HTML;
+ /*
+ if ($hookname == "usermenu") {
+ $text = $this->text; // this is what shows in the tab
+ if ($G_SESSION->usesPlugin("extsubproj")) {
+ $param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
+ echo $HTML->PrintSubMenu (array ($text),
+ array ('/plugins/extsubproj/index.php' . $param ));
+
+ }
+ } 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;
+ }
+ if ( $project->usesPlugin ( $this->name ) ) {
+ $params['TITLES'][]=$this->text;
+ $params['DIRS'][]=util_make_url ('/plugins/extsubproj/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") {
+ //Check if the group is active
+ // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
+ $group_id=$params['group'];
+ $group = &group_get_object($group_id);
+ echo "<tr>";
+ echo "<td>";
+ echo ' <input type="checkbox" name="use_extsubprojplugin" value="1" ';
+ // checked or unchecked?
+ if ( $group->usesPlugin ( $this->name ) ) {
+ echo "checked";
+ }
+ echo " /><br/>";
+ echo "</td>";
+ echo "<td>";
+ echo "<strong>Use ".$this->text." Plugin</strong>";
+ echo "</td>";
+ echo "</tr>";
+ } elseif ($hookname == "groupisactivecheckboxpost") {
+ // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
+ $group_id=$params['group'];
+ $group = &group_get_object($group_id);
+ $use_extsubprojplugin = getStringFromRequest('use_extsubprojplugin');
+ if ( $use_extsubprojplugin == 1 ) {
+ $group->setPluginUse ( $this->name );
+ } else {
+ $group->setPluginUse ( $this->name, false );
+ }
+ } elseif ($hookname == "user_personal_links") {
+ // this displays the link in the user's profile page to it's personal extsubproj (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/extsubproj/index.php?id=$userid&type=user&pluginname=".$this->name,
+ _('View Personal extsubproj')
+ );
+ echo '</p>';
+ }
+ } elseif ($hookname == "project_admin_plugins") {
+ // this displays the link in the project admin options page to it's extsubproj administration
+ $group_id = $params['group_id'];
+ $group = &group_get_object($group_id);
+ if ( $group->usesPlugin ( $this->name ) ) {
+ echo '<p>'.util_make_link ("/plugins/extsubproj/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
+ _('extsubproj Admin')).'</p>' ;
+ }
+ }
+ elseif ($hookname == "blahblahblah") {
+ // ...
+ }
+ */
+// }
+
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
Modified: trunk/src/plugins/extsubproj/packaging/control/222plugin-extsubproj
===================================================================
--- trunk/src/plugins/extsubproj/packaging/control/222plugin-extsubproj 2011-09-14 12:00:12 UTC (rev 14364)
+++ trunk/src/plugins/extsubproj/packaging/control/222plugin-extsubproj 2011-09-14 12:00:20 UTC (rev 14365)
@@ -1,4 +1,4 @@
Package: @PACKAGE at -plugin-extsubproj
Architecture: all
-Depends: @OLDPACKAGE at -common, @OLDPACKAGE at -db-postgresql | @OLDPACKAGE at -db, @OLDPACKAGE at -web-apache2 | @OLDPACKAGE at -web, @OLDPACKAGE at -shell-postgresql | @OLDPACKAGE at -shell, php5-cli, ${misc:Depends}
+Depends: @OLDPACKAGE at -common, @OLDPACKAGE at -db-postgresql | @OLDPACKAGE at -db, @OLDPACKAGE at -web-apache2 | @OLDPACKAGE at -web, php5-cli, ${misc:Depends}
Description: collaborative development tool - extsubproj plugin
Modified: trunk/src/plugins/extsubproj/packaging/dirs/plugin-extsubproj
===================================================================
--- trunk/src/plugins/extsubproj/packaging/dirs/plugin-extsubproj 2011-09-14 12:00:12 UTC (rev 14364)
+++ trunk/src/plugins/extsubproj/packaging/dirs/plugin-extsubproj 2011-09-14 12:00:20 UTC (rev 14365)
@@ -1,4 +1,4 @@
-etc/gforge/httpd.d
etc/gforge/plugins/extsubproj
usr/share/gforge/plugins/extsubproj/common
+usr/share/gforge/plugins/extsubproj/view
usr/share/gforge/plugins/extsubproj/www
Modified: trunk/src/plugins/extsubproj/packaging/install/plugin-extsubproj
===================================================================
--- trunk/src/plugins/extsubproj/packaging/install/plugin-extsubproj 2011-09-14 12:00:12 UTC (rev 14364)
+++ trunk/src/plugins/extsubproj/packaging/install/plugin-extsubproj 2011-09-14 12:00:20 UTC (rev 14365)
@@ -1,8 +1,7 @@
plugins/extsubproj/common/* usr/share/@OLDPACKAGE@/plugins/extsubproj/common/
+plugins/extsubproj/view/* usr/share/@OLDPACKAGE@/plugins/extsubproj/view/
plugins/extsubproj/include/* usr/share/@OLDPACKAGE@/plugins/extsubproj/include/
plugins/extsubproj/db/* usr/share/@OLDPACKAGE@/plugins/extsubproj/db/
plugins/extsubproj/bin/* usr/share/@OLDPACKAGE@/plugins/extsubproj/bin/
plugins/extsubproj/www/* usr/share/@OLDPACKAGE@/plugins/extsubproj/www/
-plugins/extsubproj/cronjobs/* usr/share/@OLDPACKAGE@/cronjobs
-plugins/extsubproj/etc/httpd.d/* usr/share/@OLDPACKAGE@/etc/httpd.d/
plugins/extsubproj/etc/extsubproj.ini etc/@PACKAGE@/config.ini.d/
Added: trunk/src/plugins/extsubproj/view/admin/viewGlobalConfiguration.php
===================================================================
--- trunk/src/plugins/extsubproj/view/admin/viewGlobalConfiguration.php (rev 0)
+++ trunk/src/plugins/extsubproj/view/admin/viewGlobalConfiguration.php 2011-09-14 12:00:20 UTC (rev 14365)
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Projects Hierarchy plugin
+ *
+ * Copyright 2011, Franck Villaume - Capgemini
+ * http://fusionforge.org
+ *
+ * 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 Licence, 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+global $HTML;
+//global $projectsHierarchy;
+global $use_tooltips;
+
+//$projectsHierarchyGlobalConf = $projectsHierarchy->getGlobalconf();
+
+echo $HTML->boxTop(_('Manage configuration'));
+/*
+echo '<form method="post" action="?type=globaladmin&pluginname='.$projectsHierarchy->name.'&action=updateGlobalConf">';
+echo '<table>';
+
+echo '<tr><td><label id="projectsHierarchy-tree" ';
+if ($use_tooltips)
+ echo 'title="'._('Enable Tree in projects tab.').'"';
+echo ' >'._('Enable Tree').'</label></td><td><input type="checkbox" name="tree" value="1"';
+if ($projectsHierarchyGlobalConf['tree'])
+ echo 'checked="checked" ';
+
+echo '/></td></tr>';
+
+echo '<tr><td><label id="projectsHierarchy-docman" ';
+if ($use_tooltips)
+ echo 'title="'._('Enable hierarchical view for browsing in document manager.').'"';
+echo ' >'._('Enable docman browsing').'</label></td><td><input type="checkbox" name="docman" value="1"';
+if ($projectsHierarchyGlobalConf['docman'])
+ echo 'checked="checked" ';
+
+echo '/></td></tr>';
+echo '</table>';
+echo '<input type="submit" value="'._('Update').'" />';
+echo '</form>';
+*/
+echo $HTML->boxBottom();
+?>
Added: trunk/src/plugins/extsubproj/www/index.php
===================================================================
--- trunk/src/plugins/extsubproj/www/index.php (rev 0)
+++ trunk/src/plugins/extsubproj/www/index.php 2011-09-14 12:00:20 UTC (rev 14365)
@@ -0,0 +1,151 @@
+<?php
+/**
+ * Copyright 2004 (c) GForge LLC
+ * Copyright 2006 (c) Fabien Regnier - Sogeti
+ * Copyright 2010-2011, Franck Villaume - Capgemini
+ *
+ * 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once('../../env.inc.php');
+require_once $gfcommon.'include/pre.php';
+
+$user = session_get_user(); // get the session user
+
+if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+ exit_error("Invalid User", "Cannot Process your request for this user.");
+}
+
+$type = getStringFromRequest('type');
+$plugin = plugin_get_object('extsubproj');
+
+if (!$type) {
+ exit_error("Cannot Process your request: No TYPE specified", 'home'); // you can create items in Base.tab and customize this messages
+}
+
+switch ($type) {
+ case "group": {
+ if (!session_loggedin()) {
+ exit_not_logged_in();
+ }
+ $id = getStringFromRequest('id');
+ if (!$id) {
+ exit_error("Cannot Process your request: No ID specified", 'home');
+ }
+ $group = group_get_object($id);
+ if ( !$group) {
+ exit_error("Invalid Project", 'home');
+ }
+ if (!$group->usesPlugin($plugin->name)) {//check if the group has the projects-hierarchy plugin active
+ exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'), $plugin->name), 'home');
+ }
+ session_require_perm('project_admin', $id);
+
+ $action = getStringFromRequest('action');
+ global $gfplugins;
+ switch ($action) {
+ /*
+ case "addChild":
+ case "projectsHierarchyDocman":
+ case "removeChild":
+ case "removeParent":
+ case "validateRelationship": {
+ include($gfplugins.$plugin->name.'/actions/'.$action.'.php');
+ break;
+ }*/
+ default: {
+ $plugin->redirect($_SERVER['HTTP_REFERER'], 'error_msg', _('Unknown action.'));
+ break;
+ }
+ }
+ break;
+ }
+ case "globaladmin": {
+ if (!session_loggedin()) {
+ exit_not_logged_in();
+ }
+ session_require_global_perm('forge_admin');
+ $action = getStringFromRequest('action');
+ switch ($action) {
+ /*
+ case 'updateGlobalConf': {
+ global $gfplugins;
+ include($gfplugins.$plugin->name.'/actions/'.$action.'.php');
+ break;
+ }*/
+ default: {
+ // do nothing, see getGlobalAdminView() below
+ break;
+ }
+
+ }
+ $plugin->getHeader('globaladmin');
+ $plugin->getGlobalAdminView();
+ $plugin->getFooter('globaladmin');
+ break;
+ }
+ case "admin": {
+ if (!session_loggedin()) {
+ exit_not_logged_in();
+ }
+ $id = getStringFromRequest('group_id');
+ session_require_perm('project_admin', $id);
+ if (!$id) {
+ exit_error("Cannot Process your request: No ID specified", 'home');
+ }
+ $group = group_get_object($id);
+ if ( !$group) {
+ exit_error("Invalid Project", 'home');
+ }
+ if (!$group->usesPlugin($plugin->name)) {//check if the group has the projects-hierarchy plugin active
+ exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'), $plugin->name), 'home');
+ }
+ $action = getStringFromRequest('action');
+ switch ($action) {
+ /*
+ case 'updateProjectConf': {
+ global $gfplugins;
+ include($gfplugins.$plugin->name.'/actions/'.$action.'.php');
+ break;
+ }
+ */
+ default: {
+ break;
+ }
+ }
+ // params needed by site_project_header() inside getHeader()
+ $params = array(
+ 'toptab' => $plugin->name,
+ 'group' => $id);
+ $plugin->getHeader('admin', $params);
+ //$plugin->getProjectAdminView();
+ $plugin->redirect($_SERVER['HTTP_REFERER'], 'error_msg', _('Unknown action.'));
+ $plugin->getFooter('admin');
+ break;
+ }
+ default: {
+ exit_error("No TYPE specified", 'home');
+ break;
+ }
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
More information about the Fusionforge-commits
mailing list