[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.21, Tue Oct 7 09:37:32 2008 UTC revision 1.35, Sat Jan 29 22:28:01 2011 UTC
# Line 37  Line 37 
37  sub output {  sub output {
38    my ( $self ) = @_;    my ( $self ) = @_;
39    
40    my $fig = new FIG;    my $fig = $self->application->data_handle( 'FIG' );
41    my $cgi = $self->application->cgi;    my $cgi = $self->application->cgi;
42    
43    # subsystem name and 'nice name' #    # subsystem name and 'nice name' #
44    my $name = $cgi->param( 'subsystem' );    my $name = $cgi->param( 'subsystem' );
45      $name = uri_unescape( $name );
46      $name =~ s/&#39/'/g;
47    my $ssname = $name;    my $ssname = $name;
48    $ssname =~ s/\_/ /g;    $ssname =~ s/\_/ /g;
49    
# Line 49  Line 51 
51    my $can_alter = 0;    my $can_alter = 0;
52    my $user = $self->application->session->user;    my $user = $self->application->session->user;
53    
54    my $dbmaster = DBMaster->new( -database => 'WebAppBackend' );    my $dbmaster = $self->application->dbmaster;
55    my $ppoapplication = $dbmaster->Backend->init( { name => 'SubsystemEditor' } );    my $ppoapplication = $self->application->backend;
56    
57    # get a seeduser #    # get a seeduser #
58    my $seeduser = '';    my $seeduser = '';
# Line 102  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 170  Line 173 
173      $subsystem->set_classification( [ $class1, $class2 ] );      $subsystem->set_classification( [ $class1, $class2 ] );
174    
175      my $litstoset = $cgi->param( 'SUBSYSLIT' );      my $litstoset = $cgi->param( 'SUBSYSLIT' );
176        $litstoset =~ s/ //g;
177      my @lits = split( ', ', $litstoset );      my @lits = split( ', ', $litstoset );
178      setLiteratures( $fig, $name, \@lits );      setLiteratures( $fig, $name, \@lits );
179    
# Line 184  Line 188 
188      $subsystem->db_sync();      $subsystem->db_sync();
189      $subsystem->write_subsystem();      $subsystem->write_subsystem();
190    }    }
191      elsif ( defined( $cgi->param( 'GrantRightButton' ) ) ) {
192        if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
193          my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ANNOBOX' ));
194          my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
195          if ( defined( $thisScopes->[0]) ) {
196    
197            my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
198                                                           data_type => 'subsystem',
199                                                           data_id => $name,
200                                                           scope => $thisScopes->[0] } );
201            if ( defined( $rights->[0] ) ) {
202              $self->application->add_message( 'warning', "$readable_name already has the right to edit this subsystem." );
203            }
204            else {
205              my $right = $dbmaster->Rights->create( { granted => 1,
206                                                       delegated => 1,
207                                                       name => 'edit',
208                                                       data_type => 'subsystem',
209                                                       data_id => $name,
210                                                       scope => $thisScopes->[0] } );
211              if ( $right ) {
212                $self->application->add_message( 'info', "$readable_name can now edit this subsystem" );
213              }
214              else {
215                $self->application->add_message( 'warning', "Could not create right to edit the subsystem for $readable_name" );
216              }
217            }
218          }
219        }
220        else {
221          $self->application->add_message( 'warning', "You do not have the right to share the subsystem." );
222        }
223      }
224      elsif ( defined( $cgi->param( 'RevokeRightButton' ) ) ) {
225        if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
226          my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ALANNOBOX' ));
227          my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
228          my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
229                                                         data_type => 'subsystem',
230                                                         data_id => $name,
231                                                         scope => $thisScopes->[0] } );
232    
233          my $thisRight = $rights->[0];
234          if ( defined( $thisRight ) && $thisRight->delegated ) {
235            $thisRight->delete();
236    
237            $self->application->add_message( 'info', "$readable_name cannot edit this subsystem any more." );
238          }
239          else {
240            $self->application->add_message( 'warning', "You can't revoke the right of $readable_name to edit this subsystem." );
241          }
242        }
243        else {
244          $self->application->add_message( 'warning', "You do not have the right to revoke rights for this subsystem." );
245        }
246      }
247    
248    $subsystem = new Subsystem( $name, $fig, 0 );    $subsystem = new Subsystem( $name, $fig, 0 );
249    
# Line 221  Line 281 
281    
282    my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";    my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";
283    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";
284      if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) && !$self->application->{anonymous_mode}) {
285    
286        my $annoGrp = $dbmaster->Scope->get_objects( { name => 'Annotators' } );
287        my $annoScope = $dbmaster->UserHasScope->get_objects( { scope => $annoGrp->[0] } );
288        my $annoMems = [];
289        foreach my $aS ( @$annoScope ) {
290          push @$annoMems, $aS->user();
291        }
292        @$annoMems = sort { $a->lastname cmp $b->lastname || $a->firstname cmp $b->firstname } @$annoMems;
293    
294        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'>";
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'>";
323        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 ) {
331          my $r = $dbmaster->Rights->get_objects( { name => 'edit',
332                                                    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 {
339            if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {
340              $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->get_user_scope->_id."|".$a->firstname." ".$a->lastname."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
341            }
342          }
343        }
344        $annotatorsBox .= "</SELECT>";
345        $alreadyAnnotatorsBox .= "</SELECT>";
346    
347        $infotable .= "<TR><TH>Grant Right To Edit To:</TH><TD>$annotatorsBox $editRightButton</TD></TR>";
348        $infotable .= "<TR><TH>Revoke Right To Edit From:</TH><TD>$alreadyAnnotatorsBox $revokeRightButton</TD></TR>";
349      }
350    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
351    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
352    
# Line 248  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 369  Line 495 
495    my @ssclassifications = $fig->all_subsystem_classifications();    my @ssclassifications = $fig->all_subsystem_classifications();
496    my $ssclass;    my $ssclass;
497    foreach my $ssc ( @ssclassifications ) {    foreach my $ssc ( @ssclassifications ) {
498      next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );      if ( !defined( $ssc->[1] ) ) {
499      next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );        $ssc->[1] = '';
500        }
501    #    next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );
502        next if ( !defined( $ssc->[0] ) );
503        next if ( $ssc->[0] eq '' );
504    #    next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );
505      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );
506      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];
507    }    }
# Line 508  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.21  
changed lines
  Added in v.1.35

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3