[Fusionforge-commits] r14015 - in branches/Branch_5_1: . src/debian src/packaging/install src/utils/fixscripts

Roland Mas lolando at fusionforge.org
Fri Jul 29 18:42:38 CEST 2011


Author: lolando
Date: 2011-07-29 18:42:37 +0200 (Fri, 29 Jul 2011)
New Revision: 14015

Added:
   branches/Branch_5_1/src/utils/fixscripts/fix_default_role.php
Modified:
   branches/Branch_5_1/
   branches/Branch_5_1/src/debian/changelog
   branches/Branch_5_1/src/packaging/install/db-postgresql
Log:
Add a fix_default_role.php script to unbreak upgrades for old forges where some users have the 'Default' role in their projects

Modified: branches/Branch_5_1/src/debian/changelog
===================================================================
--- branches/Branch_5_1/src/debian/changelog	2011-07-29 16:23:06 UTC (rev 14014)
+++ branches/Branch_5_1/src/debian/changelog	2011-07-29 16:42:37 UTC (rev 14015)
@@ -9,12 +9,15 @@
   * Runtime configuration is also now stored into a set of *.ini files
     marked as conffiles, so local customizations aren't overwritten
     (closes: #599274).
+  * Add a /usr/share/gforge/bin/fix_default_role.php script to run if
+    upgrades from really old instances fail when migrating permissions for
+    users having the "Default" role in their projects (closes: #561351).
 
   [ Thorsten Glaser ]
   * Update copyright file
   * Fix broken link in /usr/share/fusionforge (Evolvis [#1638])
 
- -- Roland Mas <lolando at debian.org>  Fri, 29 Jul 2011 18:21:48 +0200
+ -- Roland Mas <lolando at debian.org>  Fri, 29 Jul 2011 18:40:00 +0200
 
 fusionforge (5.0.3-1) unstable; urgency=low
 

Modified: branches/Branch_5_1/src/packaging/install/db-postgresql
===================================================================
--- branches/Branch_5_1/src/packaging/install/db-postgresql	2011-07-29 16:23:06 UTC (rev 14014)
+++ branches/Branch_5_1/src/packaging/install/db-postgresql	2011-07-29 16:42:37 UTC (rev 14015)
@@ -69,4 +69,5 @@
 utils/normalize_roles.php	usr/share/@OLDPACKAGE@/bin/
 utils/sync_unix_groups.php	usr/share/@OLDPACKAGE@/bin/
 utils/fixscripts/populate_template_project.php	usr/share/@OLDPACKAGE@/bin/
+utils/fixscripts/fix_default_role.php	usr/share/@OLDPACKAGE@/bin/
 utils/forge_set_password                usr/share/@OLDPACKAGE@/bin/

Added: branches/Branch_5_1/src/utils/fixscripts/fix_default_role.php
===================================================================
--- branches/Branch_5_1/src/utils/fixscripts/fix_default_role.php	                        (rev 0)
+++ branches/Branch_5_1/src/utils/fixscripts/fix_default_role.php	2011-07-29 16:42:37 UTC (rev 14015)
@@ -0,0 +1,48 @@
+#! /usr/bin/php
+<?php
+/**
+ * Copyright 2011 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 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.
+ */
+
+require (dirname(__FILE__).'/../www/env.inc.php');
+require_once $gfcommon.'include/pre.php';
+			 
+$res=db_query_params('CREATE FUNCTION upgrade_default_role_to_admin () RETURNS void AS $$
+DECLARE
+	g groups%ROWTYPE ;
+BEGIN
+	FOR g IN SELECT * FROM groups
+	LOOP
+		UPDATE user_group SET role_id=(
+		       SELECT min(r.role_id)
+		       FROM role r JOIN role_setting rs USING (role_id)
+		       WHERE r.group_id=g.group_id 
+		       	     AND rs.section_name=\'projectadmin\'
+			     AND rs.value=\'A\'
+		       )
+		WHERE role_id=1
+		      AND group_id=g.group_id;
+	END LOOP ;
+
+END ;
+$$ LANGUAGE plpgsql', array());
+
+$res=db_query_params('SELECT upgrade_default_role_to_admin()', array());
+
+$res=db_query_params('DROP FUNCTION upgrade_default_role_to_admin()', array());
+?>


Property changes on: branches/Branch_5_1/src/utils/fixscripts/fix_default_role.php
___________________________________________________________________
Added: svn:executable
   + *




More information about the Fusionforge-commits mailing list