[Fusionforge-commits] r8567 - in trunk/gforge: debian plugins plugins/contribtracker plugins/contribtracker/common plugins/contribtracker/db plugins/contribtracker/www

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


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

Added:
   trunk/gforge/plugins/contribtracker/
   trunk/gforge/plugins/contribtracker/INSTALL
   trunk/gforge/plugins/contribtracker/common/
   trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php
   trunk/gforge/plugins/contribtracker/common/contribtracker-init.php
   trunk/gforge/plugins/contribtracker/db/
   trunk/gforge/plugins/contribtracker/db/contribtracker-init.sql
   trunk/gforge/plugins/contribtracker/www/
   trunk/gforge/plugins/contribtracker/www/index.php
Modified:
   trunk/gforge/debian/control
Log:
Cut-and-paste from helloworld for a skeleton contribtracker plugin

Modified: trunk/gforge/debian/control
===================================================================
--- trunk/gforge/debian/control	2009-12-18 16:58:02 UTC (rev 8566)
+++ trunk/gforge/debian/control	2009-12-18 17:38:30 UTC (rev 8567)
@@ -342,3 +342,15 @@
  This can be used to highlight some projects on a forge, for instance
  for a "project of the month".
 
+Package: gforge-plugin-contribtracker
+Architecture: all
+Depends: gforge-common (>= 4.6.99), gforge-db-postgresql (>= 4.6.99) | gforge-db, gforge-web-apache2 (>= 4.6.99) | gforge-web, mediawiki, ${misc:Depends}
+Description: Contribution tracker plugin for FusionForge
+ FusionForge provides many tools to aid collaboration in a
+ development project, such as bug-tracking, task management,
+ mailing-lists, SCM repository, forums, support request helper,
+ web/FTP hosting, release management, etc. All these services are
+ integrated into one web site and managed through a web interface.
+ .
+ This plugin allows each project to display a list of significant
+ contributions, along with their authors.

Added: trunk/gforge/plugins/contribtracker/INSTALL
===================================================================
--- trunk/gforge/plugins/contribtracker/INSTALL	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/INSTALL	2009-12-18 17:38:30 UTC (rev 8567)
@@ -0,0 +1,16 @@
+0. INSTALLATION of Contribtracker Plugin
+
+i.e. : if the directory where the plugins are is  /srv/www/gforge/plugins you should end up 
+	with /srv/www/gforge/plugins/contribtracker and all the files in it
+
+1. CONFIGURATION
+
+A) Make the symbolic links for each section
+
+(this is just an example, you should change the variables for what you have on your installation)
+
+/$GFORGEDIR/www/plugins/contribtracker -> /$GFORGEPLUGINSDIR/contribtracker/www
+
+B) Run the db/contribtracker-init.sql file
+
+psql -U gforge gforge < db/contribtracker-init.sql
\ No newline at end of file

Added: trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php
===================================================================
--- trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php	2009-12-18 17:38:30 UTC (rev 8567)
@@ -0,0 +1,154 @@
+<?php
+
+/**
+ * ContribTrackerPlugin Class
+ *
+ * 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.
+ *
+ * GForge 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 GForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+class ContribTrackerPlugin extends Plugin {
+	function ContribTrackerPlugin () {
+		$this->Plugin() ;
+		$this->name = "contribtracker" ;
+		$this->text = "Contribution Tracker" ; // To show in the tabs, use...
+		$this->hooks[] = "groupmenu" ;	// To put into the project tabs
+		$this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
+		$this->hooks[] = "groupisactivecheckboxpost" ; //
+		$this->hooks[] = "userisactivecheckbox" ; // The "use ..." checkbox in user account
+		$this->hooks[] = "userisactivecheckboxpost" ; //
+		$this->hooks[] = "project_admin_plugins"; // to show up in the admin page fro group
+	}
+
+	function CallHook ($hookname, $params) {
+		if ($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'][]='/plugins/contribtracker/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name; // we indicate the part we're calling is the project one
+			} else {
+				$params['TITLES'][]=$this->text." is [Off]";
+				$params['DIRS'][]='';
+			}	
+			(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
+		} elseif ($hookname == "groupisactivecheckbox") {
+			//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_contribtrackerplugin" 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_contribtrackerplugin = getStringFromRequest('use_contribtrackerplugin');
+			if ( $use_contribtrackerplugin == 1 ) {
+				$group->setPluginUse ( $this->name );
+			} else {
+				$group->setPluginUse ( $this->name, false );
+			}
+		} elseif ($hookname == "userisactivecheckbox") {
+			//check if user is active
+			// this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
+			$user = $params['user'];
+			echo "<tr>";
+			echo "<td>";
+			echo ' <input type="CHECKBOX" name="use_contribtrackerplugin" value="1" ';
+			// CHECKED OR UNCHECKED?
+			if ( $user->usesPlugin ( $this->name ) ) {
+				echo "CHECKED";
+ 			}
+			echo ">    Use ".$this->text." Plugin";
+			echo "</td>";
+			echo "</tr>";
+		} elseif ($hookname == "userisactivecheckboxpost") {
+			// this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
+			$user = $params['user'];
+			$use_contribtrackerplugin = getStringFromRequest('use_contribtrackerplugin');
+			if ( $use_contribtrackerplugin == 1 ) {
+				$user->setPluginUse ( $this->name );
+			} else {
+				$user->setPluginUse ( $this->name, false );
+			}
+			echo "<tr>";
+			echo "<td>";
+			echo ' <input type="CHECKBOX" name="use_contribtrackerplugin" value="1" ';
+			// CHECKED OR UNCHECKED?
+			if ( $user->usesPlugin ( $this->name ) ) {
+				echo "CHECKED";
+			}
+			echo ">    Use ".$this->text." Plugin";
+			echo "</td>";
+			echo "</tr>";
+		} elseif ($hookname == "user_personal_links") {
+			// this displays the link in the user's profile page to it's personal ContribTracker (if you want other sto access it, youll have to change the permissions in the index.php
+			$userid = $params['user_id'];
+			$user = user_get_object($userid);
+			$text = $params['text'];
+			//check if the user has the plugin activated
+			if ($user->usesPlugin($this->name)) {
+				echo '	<p>' ;
+				echo util_make_link ("/plugins/contribtracker/index.php?id=$userid&type=user&pluginname=".$this->name,
+						     _('View Personal ContribTracker')
+					);
+				echo '</p>';
+			}
+		} elseif ($hookname == "project_admin_plugins") {
+			// this displays the link in the project admin options page to it's  ContribTracker administration
+			$group_id = $params['group_id'];
+			$group = &group_get_object($group_id);
+			if ( $group->usesPlugin ( $this->name ) ) {
+				echo util_make_link ("/plugins/projects_hierarchy/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
+						     _('View the ContribTracker Administration')) ;
+				echo '</p>';
+			}
+		}												    
+		elseif ($hookname == "blahblahblah") {
+			// ...
+		} 
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/gforge/plugins/contribtracker/common/contribtracker-init.php
===================================================================
--- trunk/gforge/plugins/contribtracker/common/contribtracker-init.php	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/common/contribtracker-init.php	2009-12-18 17:38:30 UTC (rev 8567)
@@ -0,0 +1,33 @@
+<?php
+/**
+ *
+ * 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.
+ *
+ * GForge 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 GForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+global $gfplugins;
+require_once $gfplugins.'contribtracker/common/ContribTrackerPlugin.class.php' ;
+
+$ContribTrackerPluginObject = new ContribTrackerPlugin ;
+
+register_plugin ($ContribTrackerPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/gforge/plugins/contribtracker/db/contribtracker-init.sql
===================================================================
--- trunk/gforge/plugins/contribtracker/db/contribtracker-init.sql	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/db/contribtracker-init.sql	2009-12-18 17:38:30 UTC (rev 8567)
@@ -0,0 +1,35 @@
+CREATE TABLE plugin_contribtracker_entity form (
+       form_id int,
+       form_name text
+) ;
+
+CREATE TABLE plugin_contribtracker_role (
+       role_id int,
+       role_name text,
+       role_description text
+) ;
+
+CREATE TABLE plugin_contribtracker_actor (
+       actor_id int,
+       actor_name text,
+       actor_address text,
+       actor_email text,
+       actor_description text,
+       form_id int,
+       group_id int
+) ;
+
+CREATE TABLE plugin_contribtracker_contribution (
+       contrib_id int,
+       contrib_name text,
+       contrib_date int,
+       contrib_description text,
+       group_id int
+) ;
+
+CREATE TABLE plugin_contribtracker_participation (
+       participation_id int,
+       contribution_id int,
+       actor_id int,
+       role_id int
+) ;

Added: trunk/gforge/plugins/contribtracker/www/index.php
===================================================================
--- trunk/gforge/plugins/contribtracker/www/index.php	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/www/index.php	2009-12-18 17:38:30 UTC (rev 8567)
@@ -0,0 +1,113 @@
+<?php
+
+/*
+ * HelloWorld plugin
+ *
+ * Daniel Perez <danielperez.arg at gmail.com>
+ *
+ * This is an example to watch things in action. You can obviously modify things and logic as you see fit
+ */
+
+require_once('../../env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfconfig.'plugins/helloworld/config.php';
+
+// the header that displays for the user portion of the plugin
+function helloworld_Project_Header($params) {                                                                                                                                         
+	global $DOCUMENT_ROOT,$HTML,$id;                                                                            
+	$params['toptab']='helloworld'; 
+	$params['group']=$id;
+	/*                                                                                                                                                              
+		Show horizontal links                                                                                                                                   
+	*/                                                                                                                                                              
+	site_project_header($params);														
+}
+
+// the header that displays for the project portion of the plugin
+function helloworld_User_Header($params) {
+	global $DOCUMENT_ROOT,$HTML,$user_id;                                                                            
+	$params['toptab']='helloworld'; 
+	$params['user']=$user_id;
+	/*                                                                                                                                                              
+	 Show horizontal links                                                                                                                                   
+	 */                                                                                                                                                              
+	site_user_header($params);    
+}
+
+
+	$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');
+	$id = getStringFromRequest('id');
+	$pluginname = getStringFromRequest('pluginname');
+	
+	if (!$type) {
+		exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
+	} elseif (!$id) {
+		exit_error("Cannot Process your request","No ID specified");
+	} else {
+		if ($type == 'group') {
+			$group = group_get_object($id);
+			if ( !$group) {
+				exit_error("Invalid Project", "Inexistent Project");
+			}
+			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the HelloWorld plugin active
+				exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");			
+			}
+			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group (optional)
+			if ( !$userperm->IsMember()) {
+				exit_error("Access Denied", "You are not a member of this project");
+			}
+			// other perms checks here...
+			helloworld_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
+			// DO THE STUFF FOR THE PROJECT PART HERE
+			echo "We are in the Project HelloWorld plugin <br>";
+			echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+		} elseif ($type == 'user') {
+			$realuser = user_get_object($id);// 
+			if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
+				exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
+			}
+			if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private HelloWorld part of this user
+				exit_error("Access Denied", "You cannot access other user's personal $pluginname");
+			}
+			helloworld_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));    
+			// DO THE STUFF FOR THE USER PART HERE
+			echo "We are in the User HelloWorld plugin <br>";
+			echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+		} elseif ($type == 'admin') {
+			$group = group_get_object($id);
+			if ( !$group) {
+				exit_error("Invalid Project", "Inexistent Project");
+			}
+			if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the HelloWorld plugin active
+				exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");			
+			}
+			$userperm = $group->getPermission($user);//we'll check if the user belongs to the group
+			if ( !$userperm->IsMember()) {
+				exit_error("Access Denied", "You are not a member of this project");
+			}
+			//only project admin can access here
+			if ( $userperm->isAdmin() ) {
+				helloworld_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));    
+				// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
+				echo "We are in the Project HelloWorld plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
+				echo "Greetings from planet " . $world; // $world comes from the config file in /etc
+			} else {
+				exit_error("Access Denied", "You are not a project Admin");
+			}
+		}
+	}	 
+	
+	site_project_footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>




More information about the Fusionforge-commits mailing list