[Fusionforge-commits] r8575 - in trunk/gforge/plugins/contribtracker: common lib www

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


Author: lolando
Date: 2009-12-18 18:39:47 +0100 (Fri, 18 Dec 2009)
New Revision: 8575

Added:
   trunk/gforge/plugins/contribtracker/www/show_actor.php
Modified:
   trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php
   trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql
   trunk/gforge/plugins/contribtracker/www/index.php
Log:
Finished display functionality

Modified: trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php
===================================================================
--- trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php	2009-12-18 17:39:39 UTC (rev 8574)
+++ trunk/gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php	2009-12-18 17:39:47 UTC (rev 8575)
@@ -48,7 +48,7 @@
 			}
 			if ( $project->usesPlugin ( $this->name ) ) {
 				$params['TITLES'][] = _('Contribution tracker') ;
-				$params['DIRS'][]='/plugins/contribtracker/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name; // we indicate the part we're calling is the project one
+				$params['DIRS'][]='/plugins/contribtracker/index.php?group_id=' . $group_id ;
 			}	
 			(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
 		} elseif ($hookname == "groupisactivecheckbox") {

Modified: trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql
===================================================================
--- trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql	2009-12-18 17:39:39 UTC (rev 8574)
+++ trunk/gforge/plugins/contribtracker/lib/contribtracker-init.sql	2009-12-18 17:39:47 UTC (rev 8575)
@@ -25,7 +25,7 @@
 CREATE TABLE plugin_contribtracker_contribution (
        contrib_id integer DEFAULT nextval('plugin_contribtracker_contribution_pk_seq') PRIMARY KEY,
        name text DEFAULT '' NOT NULL,
-       date int,
+       date int DEFAULT 0 NOT NULL,
        description text DEFAULT '' NOT NULL,
        group_id integer NOT NULL REFERENCES groups ON DELETE CASCADE
 ) ;

Modified: trunk/gforge/plugins/contribtracker/www/index.php
===================================================================
--- trunk/gforge/plugins/contribtracker/www/index.php	2009-12-18 17:39:39 UTC (rev 8574)
+++ trunk/gforge/plugins/contribtracker/www/index.php	2009-12-18 17:39:47 UTC (rev 8575)
@@ -9,38 +9,126 @@
 
 require_once('../../env.inc.php');
 require_once $gfwww.'include/pre.php';
+$plugin = plugin_get_object ('contribtracker') ;
 
-$HTML->header(array('title'=>_('Contributions'),'pagename'=>'contribtracker'));
+function display_contribution ($c, $show_groups = false) {
+	print '<h3>'.$c->getName().'</h3>' ;
+	if ($show_groups) {
+		print '<strong>'._('Group:').'</strong> ' ;
+		print util_make_link_g ($c->getGroup()->getUnixName(),
+					$c->getGroup()->getId(),
+					htmlspecialchars ($c->getGroup()->getPublicName())) ;
+		print '<br />' ;
+	}
 
-$plugin = plugin_get_object ('contribtracker') ;
+	print '<strong>'._('Date:').'</strong> ' ;
+	print strftime (_('%Y-%m-%d'), $c->getDate ()) ;
+	print '<br />' ;
+	
+	print '<strong>'._('Description:').'</strong> ' ;
+	print htmlspecialchars ($c->getDescription ()) ;
+	print '<br />' ;
+	
+	$parts = $c->getParticipations () ;
+	print '<strong>'.ngettext('Participant:',
+				  'Participants:',
+				  count ($parts)).'</strong> ' ;
+	print '<br />' ;
+	print '<ul>' ;
+	foreach ($parts as $p) {
+		print '<li>' ;
+		printf (_('%s: %s (%s)'),
+			htmlspecialchars ($p->getRole()->getName()),
+			util_make_link ('/plugins/contribtracker/show_actor.php?actor_id='.$p->getActor()->getId (),
+					$p->getActor()->getName()),
+			$p->getActor()->getLegalStructure()->getName()) ;
+		print '</li>' ;
+	}
+	print '</ul>' ;
+}
+	
+$group_id = getIntFromRequest ('group_id') ;
+if ($group_id) {
+	$group = group_get_object ($group_id) ;
+	if(!$group || !is_object ($group)) {
+		exit_no_group () ;
+	}
+	if (!$group->isPublic()) {
+		$perm =& $group->getPermission(session_get_user());
+		
+		if (!$perm || !is_object($perm) || !$perm->isMember()) {
+			exit_no_group () ;
+		}
+	}
 
-$contribs = $plugin->getContributions () ;
+	$contrib_id = getIntFromRequest ('contrib_id') ;
+	if ($contrib_id) {    // List only one particular contribution
+		$contrib = new ContribTrackerContribution ($contrib_id) ;
+		if (!$contrib || !is_object ($contrib)
+		    || $contrib->getGroup()->getId() != $group_id) {
+			exit_permission_denied () ;
+		}
 
-usort ($contribs, "ContribTrackerPlugin::ContribComparator") ;
+		$params = array () ;
+		$params['toptab'] = 'contribtracker' ;
+		$params['group'] = $group_id ;
+		$params['title'] = _('Contribution details') ;
+		$params['pagename'] = 'contribtracker' ;
+		$params['sectionvals'] = array($group->getPublicName());    
 
-if (count ($contribs) == 0) {
-	print '<h1>'._('No contributions').'</h1>' ;
-	print _('No contributions have been recorded yet.') ;
-} else {
-	print '<h1>'._('Latest contributions').'</h1>' ;
+		site_project_header ($params) ;
 
+		display_contribution ($contrib) ;
+	} else {	// List all contributions relevant to a group
+		$params = array () ;
+		$params['toptab'] = 'contribtracker' ;
+		$params['group'] = $group_id ;
+		$params['title'] = sprintf (_('Contributions for project %s'),
+					    htmlspecialchars ($group->getPublicName()));
+		$params['pagename'] = 'contribtracker' ;
+		$params['sectionvals'] = array($group->getPublicName());
 
-	foreach ($contribs as $c) {
-		print '<h3>'.$c->getName().'</h3>' ;
-		print '<h4>'.$c->getGroup()->getPublicName().'</h4>' ;
+		site_project_header ($params) ;
 
-		$parts = $c->getParticipations () ;
-		foreach ($parts as $p) {
-			print $p->getActor()->getName() ;
-			print " (" ;
-			print $p->getActor()->getLegalStructure()->getName() ;
-			print ") as " ;
-			print $p->getRole()->getName() ;
-			print '<br />' ;
+		$contribs = $plugin->getContributionsByGroup ($group) ;
+		usort ($contribs, array ($plugin, "ContribComparator")) ;
+
+		if (count ($contribs) == 0) {
+			print '<h1>'._('No contributions').'</h1>' ;
+			print _('No contributions have been recorded for this project yet.') ;
+		} else {
+			print '<h1>'._('Latest contributions').'</h1>' ;
+			
+			foreach ($contribs as $c) {
+				display_contribution ($c) ;
+			}
 		}
 	}
-}
+} else {			// Latest contributions, globally
+	$HTML->header(array('title'=>_('Contributions'),'pagename'=>'contribtracker'));
+	
+	$contribs = $plugin->getContributions () ;
+	
+	usort ($contribs, array ($plugin, "ContribComparator")) ;
+	
+	if (count ($contribs) == 0) {
+		print '<h1>'._('No contributions').'</h1>' ;
+		print _('No contributions have been recorded yet.') ;
+	} else {
+		print '<h1>'._('Latest contributions').'</h1>' ;
 
+		$i = 1 ;
+		foreach ($contribs as $c) {
+			display_contribution ($c, true) ;
+			$i++ ;
+			if ($i > 20) {
+				break ;
+			}
+		}
+	}
+}	
+
+
 site_project_footer(array());
 
 // Local Variables:

Added: trunk/gforge/plugins/contribtracker/www/show_actor.php
===================================================================
--- trunk/gforge/plugins/contribtracker/www/show_actor.php	                        (rev 0)
+++ trunk/gforge/plugins/contribtracker/www/show_actor.php	2009-12-18 17:39:47 UTC (rev 8575)
@@ -0,0 +1,64 @@
+<?php
+
+/*
+ * ContribTracker plugin
+ *
+ * Copyright 2009, Roland Mas
+ *
+ */
+
+require_once('../../env.inc.php');
+require_once $gfwww.'include/pre.php';
+
+$plugin = plugin_get_object ('contribtracker') ;
+
+$actor_id = getIntFromRequest ('actor_id') ;
+$actor = new ContribTrackerActor ($actor_id) ;
+if (!$actor || !is_object ($actor) || $actor->isError()) {
+	exit_error (_('No actor'),
+		    _('No actor or invalid actor specified')) ;
+}
+
+$HTML->header(array('title'=>_('Actor details'),'pagename'=>'contribtracker'));
+
+print '<h1>'.sprintf(_('Actor details for %s'),
+		     htmlspecialchars($actor->getName())).'</h1>' ;
+print '<ul>' ;
+print '<li><strong>'._('Name:').'</strong> '.htmlspecialchars($actor->getName()).'</li>' ;
+print '<li><strong>'._('Address:').'</strong> '.htmlspecialchars($actor->getAddress()).'</li>' ;
+print '<li><strong>'._('Email:').'</strong> '.htmlspecialchars($actor->getEmail()).'</li>' ;
+print '<li><strong>'._('Legal structure:').'</strong> '.htmlspecialchars($actor->getLegalStructure()->getName()).'</li>' ;
+print '<li><strong>'._('Description:').'</strong> '.htmlspecialchars($actor->getDescription()).'</li>' ;
+print '</ul>' ;
+
+$participations = $actor->getParticipations () ;
+
+if (count ($participations) == 0) {
+	printf (_("%s hasn't been involved in any contributions yet"),
+		htmlspecialchars($actor->getName())) ;
+} else {
+	print '<h1>'.sprintf(ngettext('Contribution by %s',
+				      'Contributions by %s',
+				      count($participations)),
+			     htmlspecialchars($actor->getName())).'</h1>' ;
+
+	foreach ($participations as $p) {
+		$c = $p->getContribution () ;
+		print '<h3>' . util_make_link ('/plugins/contribtracker/index.php?group_id='.$c->getGroup()->getId().'&contrib_id='.$c->getId (),
+					       htmlspecialchars ($c->getName())) . '</h3>' ;
+		print '<strong>'._('Group:').'</strong> ' ;
+		print util_make_link_g ($c->getGroup()->getUnixName(),
+					$c->getGroup()->getId(),
+					$c->getGroup()->getPublicName()) ;
+		print '<br /><strong>'._('Role:').'</strong> ' ;
+		print htmlspecialchars ($p->getRole()->getName()) ;
+	}
+}
+site_project_footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>




More information about the Fusionforge-commits mailing list