[Bio] / SubsystemEditor / WebPage / ShowSubsystem.pm Repository:
ViewVC logotype

Diff of /SubsystemEditor/WebPage/ShowSubsystem.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28, Wed Jun 17 15:14:19 2009 UTC revision 1.35, Sat Jan 29 22:28:01 2011 UTC
# Line 104  Line 104 
104    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$esc_name" );    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$esc_name" );
105    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$esc_name" );    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$esc_name" );
106    $menu->add_category( 'Subsets', "SubsysEditor.cgi?page=ShowSubsets&subsystem=$esc_name" );    $menu->add_category( 'Subsets', "SubsysEditor.cgi?page=ShowSubsets&subsystem=$esc_name" );
107    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );    $menu->add_category( 'Diagrams and Illustrations' );
108    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );    $menu->add_entry( 'Diagrams and Illustrations', 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );
109      $menu->add_entry( 'Diagrams and Illustrations', 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );
110    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );
111    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$esc_name" );    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$esc_name" );
112    $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$esc_name" );    $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$esc_name" );
# Line 189  Line 190 
190    }    }
191    elsif ( defined( $cgi->param( 'GrantRightButton' ) ) ) {    elsif ( defined( $cgi->param( 'GrantRightButton' ) ) ) {
192      if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {      if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
193        my $newAnno = $cgi->param( 'ANNOBOX' );        my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ANNOBOX' ));
194        my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );        my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
195        if ( defined( $thisUsers->[0] ) ) {        if ( defined( $thisScopes->[0]) ) {
196    
197          my $rights = $dbmaster->Rights->get_objects( { name => 'edit',          my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
198                                                         data_type => 'subsystem',                                                         data_type => 'subsystem',
199                                                         data_id => $name,                                                         data_id => $name,
200                                                         scope => $thisUsers->[0]->get_user_scope() } );                                                         scope => $thisScopes->[0] } );
201          if ( defined( $rights->[0] ) ) {          if ( defined( $rights->[0] ) ) {
202            $self->application->add_message( 'warning', "User $newAnno already has the right to edit this subsystem." );            $self->application->add_message( 'warning', "$readable_name already has the right to edit this subsystem." );
203          }          }
204          else {          else {
205            my $right = $dbmaster->Rights->create( { granted => 1,            my $right = $dbmaster->Rights->create( { granted => 1,
# Line 206  Line 207 
207                                                     name => 'edit',                                                     name => 'edit',
208                                                     data_type => 'subsystem',                                                     data_type => 'subsystem',
209                                                     data_id => $name,                                                     data_id => $name,
210                                                     scope => $thisUsers->[0]->get_user_scope() } );                                                     scope => $thisScopes->[0] } );
211            if ( $right ) {            if ( $right ) {
212              $self->application->add_message( 'info', "$newAnno can now edit this subsystem" );              $self->application->add_message( 'info', "$readable_name can now edit this subsystem" );
213            }            }
214            else {            else {
215              $self->application->add_message( 'warning', "Could not create right to edit the subsystem for user $newAnno" );              $self->application->add_message( 'warning', "Could not create right to edit the subsystem for $readable_name" );
216            }            }
217          }          }
218        }        }
# Line 222  Line 223 
223    }    }
224    elsif ( defined( $cgi->param( 'RevokeRightButton' ) ) ) {    elsif ( defined( $cgi->param( 'RevokeRightButton' ) ) ) {
225      if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {      if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
226        my $newAnno = $cgi->param( 'ALANNOBOX' );        my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ALANNOBOX' ));
227        my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );        my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
228        my $rights = $dbmaster->Rights->get_objects( { name => 'edit',        my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
229                                                       data_type => 'subsystem',                                                       data_type => 'subsystem',
230                                                       data_id => $name,                                                       data_id => $name,
231                                                       scope => $thisUsers->[0]->get_user_scope() } );                                                       scope => $thisScopes->[0] } );
232    
233        my $thisRight = $rights->[0];        my $thisRight = $rights->[0];
234        if ( defined( $thisRight ) && $thisRight->delegated ) {        if ( defined( $thisRight ) && $thisRight->delegated ) {
235          $thisRight->delete();          $thisRight->delete();
236    
237          $self->application->add_message( 'info', "$newAnno cannot edit this subsystem any more." );          $self->application->add_message( 'info', "$readable_name cannot edit this subsystem any more." );
238        }        }
239        else {        else {
240          $self->application->add_message( 'warning', "You can't revoke the right of $newAnno to edit this subsystem." );          $self->application->add_message( 'warning', "You can't revoke the right of $readable_name to edit this subsystem." );
241        }        }
242      }      }
243      else {      else {
# Line 293  Line 294 
294      my $editRightButton = "<INPUT TYPE=SUBMIT ID='GrantRightButton' NAME='GrantRightButton' VALUE='Grant Right'>";      my $editRightButton = "<INPUT TYPE=SUBMIT ID='GrantRightButton' NAME='GrantRightButton' VALUE='Grant Right'>";
295      my $revokeRightButton = "<INPUT TYPE=SUBMIT ID='RevokeRightButton' NAME='RevokeRightButton' VALUE='Revoke Right'>";      my $revokeRightButton = "<INPUT TYPE=SUBMIT ID='RevokeRightButton' NAME='RevokeRightButton' VALUE='Revoke Right'>";
296    
297        my $user_has_scopes = $dbmaster->UserHasScope->get_objects( { user => $user });
298        my $available_groups = {};
299        foreach my $user_has_scope (@$user_has_scopes) {
300          my $scope = $user_has_scope->scope();
301          next if $scope->name() =~ /^user:/;
302          next if $scope->name() =~/^Public/;
303          $available_groups->{$scope->{_id}} = $scope;
304        }
305        my $all_ss_edit_rights = $dbmaster->Rights->get_objects( { name => 'edit',
306                                                                   data_type => 'subsystem',
307                                                                   data_id => $name } );
308        my $user_groups_have_right = [];
309        my $user_groups_not_have_right = [];
310        foreach my $r (@$all_ss_edit_rights) {
311          my $scope = $r->scope;
312          next if $scope->name() =~ /^user:/;
313          next if $scope->name() =~/^Public/;
314          push(@$user_groups_have_right, [ $scope->_id, $scope->name ]);
315          delete $available_groups->{$scope->{_id}};
316        }
317        foreach my $key (sort(keys(%$available_groups))) {
318          my $scope = $available_groups->{$key};
319          push(@$user_groups_not_have_right, [ $scope->_id, $scope->name ]);
320        }
321    
322      my $annotatorsBox = "<SELECT NAME='ANNOBOX' ID='ANNOBOX'>";      my $annotatorsBox = "<SELECT NAME='ANNOBOX' ID='ANNOBOX'>";
323      my $alreadyAnnotatorsBox = "<SELECT NAME='ALANNOBOX' ID='ALANNOBOX'>";      my $alreadyAnnotatorsBox = "<SELECT NAME='ALANNOBOX' ID='ALANNOBOX'>";
324        foreach my $a ( @$user_groups_have_right ) {
325          $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->[0]."|group ".$a->[1]."'>group ".$a->[1]."</OPTION>";
326        }
327        foreach my $a ( @$user_groups_not_have_right ) {
328          $annotatorsBox .= "<OPTION VALUE='".$a->[0]."|group ".$a->[1]."'>group ".$a->[1]."</OPTION>";
329        }
330      foreach my $a ( @$annoMems ) {      foreach my $a ( @$annoMems ) {
331        unless ( $a->has_right( undef, 'edit', 'subsystem', $name ) ) {        my $r = $dbmaster->Rights->get_objects( { name => 'edit',
332          $annotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";                                                  scope => $a->get_user_scope,
333                                                    data_type => 'subsystem',
334                                                    data_id => $name } );
335          unless ( scalar(@$r) ) {
336            $annotatorsBox .= "<OPTION VALUE='".$a->get_user_scope->_id."|".$a->firstname." ".$a->lastname."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
337        }        }
338        else {        else {
339          if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {          if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {
340            $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";            $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->get_user_scope->_id."|".$a->firstname." ".$a->lastname."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
341          }          }
342        }        }
343      }      }
# Line 338  Line 374 
374      my $editLitButton = "<INPUT TYPE=BUTTON ID='EditLitButton' VALUE='Edit Literature' ONCLICK='MakeEditableLit( \"0\" );'><INPUT TYPE=BUTTON ID='ShowLitButton' VALUE='Show Links' STYLE='display: none;' ONCLICK='MakeEditableLit( \"1\" );'>";      my $editLitButton = "<INPUT TYPE=BUTTON ID='EditLitButton' VALUE='Edit Literature' ONCLICK='MakeEditableLit( \"0\" );'><INPUT TYPE=BUTTON ID='ShowLitButton' VALUE='Show Links' STYLE='display: none;' ONCLICK='MakeEditableLit( \"1\" );'>";
375      my $editWLButton = "<INPUT TYPE=BUTTON ID='EditWLButton' VALUE='Edit Weblinks' ONCLICK='MakeEditableWL( \"0\" );'><INPUT TYPE=BUTTON ID='ShowWLButton' VALUE='Show Weblinks' STYLE='display: none;' ONCLICK='MakeEditableWL( \"1\" );'>";      my $editWLButton = "<INPUT TYPE=BUTTON ID='EditWLButton' VALUE='Edit Weblinks' ONCLICK='MakeEditableWL( \"0\" );'><INPUT TYPE=BUTTON ID='ShowWLButton' VALUE='Show Weblinks' STYLE='display: none;' ONCLICK='MakeEditableWL( \"1\" );'>";
376    
377      $infotable .= "<TR><TH>Literature</TH><TD><TABLE><TR><TD><SPAN ID='LitSpan'>$litstring</SPAN></TD><TD>$editLitButton</TD><TD><INPUT TYPE=TEXT STYLE='width: 200px; display: none;' NAME='SUBSYSLIT' ID='SUBSYSLIT' VALUE='$litvoid'></TD><TD><SPAN ID='TEXTSPAN' STYLE='display: none;'>Multiple PMIDs should be separated by \', \'</SPAN></TD></TR></TABLE></TD></TR>";      $infotable .= "<TR><TH>Literature</TH><TD><TABLE><TR><TD><SPAN ID='LitSpan'>$litstring</SPAN></TD><TD>$editLitButton</TD><TD><INPUT TYPE=TEXT STYLE='width: 200px; display: none;' NAME='SUBSYSLIT' ID='SUBSYSLIT' VALUE='$litvoid'></TD><TD><SPAN ID='TEXTSPAN' STYLE='display: none;'>Please enter the PubMed ID (PMID), and we will automatically get the paper information. Multiple PMIDs should be separated by \', \'</SPAN></TD></TR></TABLE></TD></TR>";
378      $infotable .= "<TR><TH>Websites</TH><TD><TABLE><TR><TD><SPAN ID='WLSpan'>$wl</SPAN></TD><TD>$editWLButton</TD><TD><TEXTAREA ROWS=3 STYLE='width: 400px; display: none;' NAME='SUBSYSWL' ID='SUBSYSWL'>$wlvoid</TEXTAREA></TD><TD><SPAN ID='AREASPAN' STYLE='display: none;'>Please use the following format:<BR>Description1 http://www.xyz.org/...<BR>Description2 http://www.xzy.de/...</SPAN></TD></TR></TABLE></TD></TR>";      $infotable .= "<TR><TH>Websites</TH><TD><TABLE><TR><TD><SPAN ID='WLSpan'>$wl</SPAN></TD><TD>$editWLButton</TD><TD><TEXTAREA ROWS=3 STYLE='width: 400px; display: none;' NAME='SUBSYSWL' ID='SUBSYSWL'>$wlvoid</TEXTAREA></TD><TD><SPAN ID='AREASPAN' STYLE='display: none;'>Please use the following format:<BR>Description of the first web page http://www.xyz.org/...<BR>Description of the second web page http://www.xzy.de/...</SPAN></TD></TR></TABLE></TD></TR>";
379      $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=15 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";      $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=15 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";
380      $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=15 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";      $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=15 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";
381    }    }
# Line 603  Line 639 
639    }    }
640    
641    foreach my $np ( @$newpubs ) {    foreach my $np ( @$newpubs ) {
642      my @h = split( /\s+/, $np );      #my @h = split( /\s+/, $np );
643      $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_WEBLINKS", @h );      $np =~ s/\s*(http\S+)\s*//;
644        my $link=$1;
645        if ($np =~ /^\s*$/) {$np = "webpage"}
646        $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_WEBLINKS", $np, $link );
647        print STDERR "Adding attribute 'Subsystem:$name' 'SUBSYSTEM_WEBLINKS', '$np', '$link'\n";
648    }    }
649  }  }
650    

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.35

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3