[Bio] / FigWebServices / conflicted_pegs.cgi Repository:
ViewVC logotype

View of /FigWebServices/conflicted_pegs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Mon Mar 28 14:31:16 2005 UTC (15 years, 3 months ago) by overbeek
Branch: MAIN
CVS Tags: merge-trunktag-bobdev_news-2, Root-bobdev_news, merge-bobdev_news-1, merge-trunktag-bobdev_news-1, merge-bodev_news-3, caBIG-00-00-00, merge-bobdev_news-2, merge-trunktag-bodev_news-3
Branch point for: Branch-bobdev_news
add conflicted_pegs.cgi

# -*- perl -*-

use HTML;
use FIG;
my $fig = new FIG;

my $cgi = new CGI;

if (0) {
    my $VAR1;
    eval(join("",`cat /tmp/conflicted_parms`));
    $cgi = $VAR1;
#   print STDERR &Dumper($cgi);
}

if (0) {
    print $cgi->header;
    my @params = $cgi->param;
    print "<pre>\n";
    foreach $_ (@params) {
		print "$_\t:",join(",",$cgi->param($_)),":\n";
    }

    if (0) {
        if (open(TMP,">/tmp/conflicted_parms")) {
	    	print TMP &Dumper($cgi);
	    	close(TMP);
		}
    }
    exit;
}

my $html = [];

my $user = $cgi->param('user');
$user =~ s/^master://;
my %conflicts;

if (open(IN,"<$FIG_Config::global/conflicted.pegs"))
{
    $line = <IN>;
    while ($line && ($line =~ /^(\S+)/))
    {
	$peg = $1;
	@set = ();
	$hit = 0;
	while ($line && ($line =~ /^(\S+)/) && ($1 eq $peg))
	{
	    chomp $line;
	    if ($line =~ /\t$user$/)    { $hit = 1 }
	    push(@set,[split(/\t/,$line)]);
	    $line = <IN>;
	}
	if ($hit)
	{
	    &process_set($fig,$cgi,$user,\%conflicts,\@set);
	}
    }
}


foreach $sub (sort keys(%conflicts))
{
    push(@$html,$cgi->h1($sub),"<ul>\n");
    $x = $conflicts{$sub};
    foreach $role (sort keys(%$x))
    {
	push(@$html,"<li> $role\n");
	&display_for_sub_and_role($fig,$cgi,$html,$user,$x->{$role});
    }
    push(@$html,"</ul>\n");
}

if (@$html == 0)
{
    push(@$html,$cgi->h1('No conflicts involving your subsystems'));
}


&HTML::show_page($cgi,$html);

sub process_set {
    my($fig,$cgi,$user,$conflicts,$set) = @_;
    my($i,$j,$x,$peg,$func,$subsystem,$role,$curator,$others);

    my @mine     = grep { $_->[4] eq $user } @$set;
    my @theirs   = grep { $_->[4] ne $user } @$set;

    for ($i=0; ($i < @mine); $i++)
    {
	$x = $mine[$i];
	($peg,$func,$subsystem,$role,$curator) = @$x;
	$others = [];
	for ($j=0; ($j < @mine); $j++)
	{
	    if ($j != $i)
	    {
		push(@$others,$mine[$j]);
	    }
	}
	push(@$others,@theirs);
	push(@{$conflicts->{$subsystem}->{$role}},[$peg,$func,$others]);
    }
}

sub display_for_sub_and_role {
    my($fig,$cgi,$html,$user,$clashes) = @_;
    my($peg,$func,$others,$col_hdrs,$tab,$x,$sub,$role,$curator);
 
    push(@$html,"<ul><br>\n");
    foreach $peg_entry (@$clashes)
    {
	($peg,$func,$others) = @$peg_entry;
	$peg_link = &HTML::fid_link($cgi,$peg);
	push(@$html,"<li> $peg_link &nbsp; $func\n<br>\n");
	if (@$others > 0)
	{
	    $col_hdrs = ["subsystem","role","curator"];
	    $tab = [];
	    foreach $x (@$others)
	    {
		(undef,undef,$sub,$role,$curator) = @$x;
		my $can_alter = (($user = $cgi->param('user')) && ($user eq $fig->subsystem_curator($sub)));
		my $url = $cgi->a({href => "subsys.cgi?can_alter=$can_alter&user=$user&ssa_name=$sub&request=show_ssa"}, $sub);
		push(@$tab,[$sub,$role,$curator]);
	    }
	    push(@$html,"<br>",&HTML::make_table($col_hdrs,$tab,"In These Subsystems"),"<br><br>");
	}
	push(@$html,"<br>\n");
    }
    push(@$html,"</ul>");
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3