[Fusionforge-commits] r8465 - in trunk/gforge: plugins/extratabs plugins/extratabs/common plugins/extratabs/www www/plugins

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Sun Dec 6 18:30:30 CET 2009


Author: aljeux
Date: 2009-12-06 18:30:30 +0100 (Sun, 06 Dec 2009)
New Revision: 8465

Added:
   trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php
   trunk/gforge/www/plugins/extratabs
Removed:
   trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class
Modified:
   trunk/gforge/plugins/extratabs/README
   trunk/gforge/plugins/extratabs/common/extratabs-init.php
   trunk/gforge/plugins/extratabs/www/index.php
Log:
Extratabs plugin fixes provided by olenz and aljeux

Modified: trunk/gforge/plugins/extratabs/README
===================================================================
--- trunk/gforge/plugins/extratabs/README	2009-12-04 18:20:47 UTC (rev 8464)
+++ trunk/gforge/plugins/extratabs/README	2009-12-06 17:30:30 UTC (rev 8465)
@@ -1,39 +1,14 @@
+This plugin adds a new page "Extra tabs" in the "group admin"
+page. There you can create new tabs that will appear on all project
+pages.
 
-Presentation
-------------
+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.
 
-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 administrators of projects can now add such links. They must
+simply give an URL and a name.
 
-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.
 

Deleted: trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class
===================================================================
--- trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class	2009-12-04 18:20:47 UTC (rev 8464)
+++ trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class	2009-12-06 17:30:30 UTC (rev 8465)
@@ -1,66 +0,0 @@
-<?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_params ('SELECT tab_name, tab_url FROM plugin_extratabsmain WHERE group_id=$1 ORDER BY index',
-						     array ($group_id)) ;
-			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:
-
-?>

Copied: trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php (from rev 8464, trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class)
===================================================================
--- trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php	                        (rev 0)
+++ trunk/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php	2009-12-06 17:30:30 UTC (rev 8465)
@@ -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_params ('SELECT tab_name, tab_url FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
+						     array ($group_id)) ;
+			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:
+
+?>

Modified: trunk/gforge/plugins/extratabs/common/extratabs-init.php
===================================================================
--- trunk/gforge/plugins/extratabs/common/extratabs-init.php	2009-12-04 18:20:47 UTC (rev 8464)
+++ trunk/gforge/plugins/extratabs/common/extratabs-init.php	2009-12-06 17:30:30 UTC (rev 8465)
@@ -1,6 +1,6 @@
 <?php
 
-require_once ($GLOBALS['sys_plugins_path'].'/extratabs/common/ExtraTabsPlugin.class') ;
+require_once ($GLOBALS['sys_plugins_path'].'/extratabs/common/ExtraTabsPlugin.class.php') ;
 
 $ExtraTabsPluginObject = new ExtraTabsPlugin ;
 

Modified: trunk/gforge/plugins/extratabs/www/index.php
===================================================================
--- trunk/gforge/plugins/extratabs/www/index.php	2009-12-04 18:20:47 UTC (rev 8464)
+++ trunk/gforge/plugins/extratabs/www/index.php	2009-12-06 17:30:30 UTC (rev 8465)
@@ -4,14 +4,15 @@
  *
  * Copyright 2005, Raphaël Hertzog
  * Copyright 2006-2009, Roland Mas
+ * Copyright 2009, Alain Peyrat
  */
 
 require_once ('../../../www/env.inc.php');
 require_once $gfwww.'include/pre.php';
 require_once $gfwww.'project/admin/project_admin_utils.php';
-require_once $gfcommon.'/include/FusionForge.class.php';
 
 $group_id = getIntFromRequest ('group_id') ;
+$index = getIntFromRequest ('index') ;
 
 session_require(array('group'=>$group_id,'admin_flags'=>'A'));
 
@@ -23,19 +24,8 @@
         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());
-}
+db_begin();
 
-if (!$perm->isAdmin()) {
-        exit_permission_denied();
-}
-
-db_begin () ;
-
 // Calculate new index field
 $res = db_query_params ('SELECT COUNT(*) as c FROM plugin_extratabs_main WHERE group_id = $1',
 			array ($group_id)) ;
@@ -43,12 +33,11 @@
 $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')) ;
+	$tab_name = htmlspecialchars(trim(getStringFromRequest ('tab_name')));
+	$tab_url = htmlspecialchars(trim(getStringFromRequest ('tab_url')));
 	$res = db_query_params ('INSERT INTO plugin_extratabs_main (group_id, index, tab_name, tab_url) VALUES ($1,$2,$3,$4)',
 				array ($group_id,
 				       $newid,
@@ -58,7 +47,6 @@
 		$feedback = sprintf (_('Cannot insert new tab entry: %s'),
 				      db_error());
 	} else {
-		db_commit () ;
 		$feedback = _('Tab added');
 	}
 } elseif (getStringFromRequest ('delete') != '') {
@@ -69,18 +57,14 @@
 		$feedback = sprintf (_('Cannot delete tab entry: %s'),
 				      db_error());
 	} else {
-		$res = db_query_params ('UPDATE plugin_extratabs_main SET index=-(index-1) WHERE group_id=$1 AND index > $2',
+		$res = db_query_params ('UPDATE plugin_extratabs_main SET index=index-1 WHERE group_id=$1 AND index > $2',
 					array ($group_id,
 					       $index)) ;
-		$res = db_query_params ('UPDATE plugin_extratabs_main SET index=-index WHERE group_id=$1 AND index < 0',
-					array ($group_id,
-					       $index)) ;
-		db_commit () ;
 	}
-  } elseif (getStringFromRequest ('up') != '') {
+} elseif (getStringFromRequest ('up') != '') {
 	if ($index > 1) {
 		$previous = $index - 1;
-		$res = db_query_params('UPDATE plugin_extratabs_main SET index = 0 WHERE group_id=$1 AND index=$2',
+		$res = db_query_params('UPDATE plugin_extratabs_main SET index=0 WHERE group_id=$1 AND index=$2',
 				       array ($group_id,
 					      $index)) ;
 		$res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=$3',
@@ -90,15 +74,14 @@
 		$res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=0',
 				       array ($previous,
 					      $group_id)) ;
-		db_commit () ;
 		$selected = $previous;
 	} else {
 	    $selected = $index;
 	}
-    } elseif (getStringFromRequest ('down') != '') {
+} elseif (getStringFromRequest ('down') != '') {
 	if ($index < $newid - 1) {
 		$next = $index + 1;
-		$res = db_query_params('UPDATE plugin_extratabs_main SET index = 0 WHERE group_id=$1 AND index=$2',
+		$res = db_query_params('UPDATE plugin_extratabs_main SET index=0 WHERE group_id=$1 AND index=$2',
 				       array ($group_id,
 					      $index)) ;
 		$res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=$3',
@@ -108,12 +91,16 @@
 		$res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=0',
 				       array ($next,
 					      $group_id)) ;
-		db_commit () ;
 		$selected = $next;
 	} else {
 	    $selected = $index;
 	}
 }
+if (!$res) {
+	db_rollback();
+} else  {
+	db_commit();
+}
 
 $adminheadertitle=sprintf(_('Project Admin: %1$s'), $group->getPublicName() );
 project_admin_header(array('title'=>$adminheadertitle, 'group'=>$group->getID()));
@@ -124,12 +111,11 @@
 
 <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>
+<p />
 
 <form name="new_tab" action="<?php echo util_make_url ('/plugins/extratabs/'); ?>" method="post">
 <input type="hidden" name="group_id" value="<?php echo $group->getID() ?>" />
 <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/>
@@ -138,7 +124,7 @@
 <input type="text" size="15" name="tab_url" value="http://" /><br/>
 <input type="submit" value="<?php echo _('Add tab') ?>" />
 </form>
-</p>
+<p />
 
 <?php
 	$res = db_query_params ('SELECT * FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index ASC', array ($group_id)) ;
@@ -152,7 +138,8 @@
 <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.') ;
 
-?></p><p>
+?></p>
+<p />
 <form name="change_tab" action="<?php echo util_make_url ('/plugins/extratabs/'); ?>" method="post">
 <input type="hidden" name="group_id" value="<?php echo $group->getID() ?>" />
 <?php 
@@ -174,7 +161,7 @@
 		  <?php } ?>
 <input type="submit" name="delete" value="<?php echo _('Delete tab') ?>" />
 </form>
-</p>
+<p />
 
 <?php
 	  }

Added: trunk/gforge/www/plugins/extratabs
===================================================================
--- trunk/gforge/www/plugins/extratabs	                        (rev 0)
+++ trunk/gforge/www/plugins/extratabs	2009-12-06 17:30:30 UTC (rev 8465)
@@ -0,0 +1 @@
+link ../../plugins/extratabs/www
\ No newline at end of file


Property changes on: trunk/gforge/www/plugins/extratabs
___________________________________________________________________
Added: svn:special
   + *




More information about the Fusionforge-commits mailing list