Package: gforge
Version: 4.7~rc2-7lenny1
Severity: normal
Tags: patch

Hello,

I have dig a little bit to find the solution to this bug. When upgrading
from etch, something in the process reassign role_id to 1 for all
administrator of all projects (col role_id in table user_group). 

In the french interface, this can be tested by choosing a project at
random and see if its admin in the admin interface have a role of "Aucun
changement". This also prevents to assign bug and task to admin. 

There is a simple solution for this: go in admin interface and reset the
role of each admin (do it for all projects, all admins).

The other solution is in the file attached. You need to copy it in www/
and run it once logged as Site Admin.

This bug was fixed on my forge (forge.ocamlcore.org) but at least I have
found and fixed the same kind of problem for one of my project on
alioth.debian.org (but cannot find other projects). A "SELECT group_id
FROM user_group WHERE role_id = 1", should help to detect this kind of
thing.

There is a possibility that this bug is not related to upgrade but of DB
reloading...

Regards
Sylvain Le Gall

-- System Information:
Debian Release: 5.0.3
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.30-bpo.1-amd64 (SMP w/3 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
<?php

require_once('/usr/share/gforge/www/env.inc.php');
require_once $gfwww.'include/pre.php';
require_once $gfwww.'project/admin/project_admin_utils.php';
require_once $gfwww.'include/role_utils.php';
require_once $gfcommon.'include/account.php';
require_once $gfcommon.'include/GroupJoinRequest.class.php';


$res_group = db_query("SELECT user_group.user_id, user_group.group_id, groups.group_name, users.realname 
	FROM user_group, groups, users WHERE user_group.role_id = 1 AND user_group.admin_flags = 'A' AND 
	groups.group_id = user_group.group_id AND users.user_id = user_group.user_id");

while ($row_group=db_fetch_array($res_group)) {
	$user_id = $row_group[0];
	$group_id = $row_group[1];
	$groupname = $row_group[2];
	$username = $row_group[3];

	$group =& group_get_object($group_id);
	if (!$group || !is_object($group)) {
		exit_error('Error','Could Not Get Group');
	} elseif ($group->isError()) {
		exit_error('Error',$group->getErrorMessage());
	};

	/* Determine admin role for this group */
	$res_role = db_query("SELECT role_id FROM role WHERE group_id = $group_id AND role_name = 'Admin'");
	if (db_numrows($res_role) == 1)
	{
		$row =db_fetch_array($res_role);
		$role_id = $row[0];
		echo "Set role_id $role_id for user $username in group $groupname<br/>";

		if (!$group->updateUser($user_id,$role_id)) {
			$feedback .= $group->getErrorMessage();
		} else {
			$feedback = _('User updated successfully');
			//plugin webcal
			//change assistant for webcal
			$params[0] = getIntFromRequest('user_id');
			$params[1] = getIntFromRequest('group_id');
			plugin_hook('change_cal_permission',$params);
			$group_id = getIntFromRequest('group_id');
			
		}
		echo $feedback."\n<br/>";
	} else {
		echo "Number of role 'Admin' for group $groupname: ".db_numrows($res_role)."\n";
	}
}

Reply via email to