[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.34, Fri Jan 21 20:27:25 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 170  Line 172 
172      $subsystem->set_classification( [ $class1, $class2 ] );      $subsystem->set_classification( [ $class1, $class2 ] );
173    
174      my $litstoset = $cgi->param( 'SUBSYSLIT' );      my $litstoset = $cgi->param( 'SUBSYSLIT' );
175        $litstoset =~ s/ //g;
176      my @lits = split( ', ', $litstoset );      my @lits = split( ', ', $litstoset );
177      setLiteratures( $fig, $name, \@lits );      setLiteratures( $fig, $name, \@lits );
178    
# Line 184  Line 187 
187      $subsystem->db_sync();      $subsystem->db_sync();
188      $subsystem->write_subsystem();      $subsystem->write_subsystem();
189    }    }
190      elsif ( defined( $cgi->param( 'GrantRightButton' ) ) ) {
191        if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
192          my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ANNOBOX' ));
193          my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
194          if ( defined( $thisScopes->[0]) ) {
195    
196            my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
197                                                           data_type => 'subsystem',
198                                                           data_id => $name,
199                                                           scope => $thisScopes->[0] } );
200            if ( defined( $rights->[0] ) ) {
201              $self->application->add_message( 'warning', "$readable_name already has the right to edit this subsystem." );
202            }
203            else {
204              my $right = $dbmaster->Rights->create( { granted => 1,
205                                                       delegated => 1,
206                                                       name => 'edit',
207                                                       data_type => 'subsystem',
208                                                       data_id => $name,
209                                                       scope => $thisScopes->[0] } );
210              if ( $right ) {
211                $self->application->add_message( 'info', "$readable_name can now edit this subsystem" );
212              }
213              else {
214                $self->application->add_message( 'warning', "Could not create right to edit the subsystem for $readable_name" );
215              }
216            }
217          }
218        }
219        else {
220          $self->application->add_message( 'warning', "You do not have the right to share the subsystem." );
221        }
222      }
223      elsif ( defined( $cgi->param( 'RevokeRightButton' ) ) ) {
224        if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
225          my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ALANNOBOX' ));
226          my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
227          my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
228                                                         data_type => 'subsystem',
229                                                         data_id => $name,
230                                                         scope => $thisScopes->[0] } );
231    
232          my $thisRight = $rights->[0];
233          if ( defined( $thisRight ) && $thisRight->delegated ) {
234            $thisRight->delete();
235    
236            $self->application->add_message( 'info', "$readable_name cannot edit this subsystem any more." );
237          }
238          else {
239            $self->application->add_message( 'warning', "You can't revoke the right of $readable_name to edit this subsystem." );
240          }
241        }
242        else {
243          $self->application->add_message( 'warning', "You do not have the right to revoke rights for this subsystem." );
244        }
245      }
246    
247    $subsystem = new Subsystem( $name, $fig, 0 );    $subsystem = new Subsystem( $name, $fig, 0 );
248    
# Line 221  Line 280 
280    
281    my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";    my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";
282    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";
283      if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) && !$self->application->{anonymous_mode}) {
284    
285        my $annoGrp = $dbmaster->Scope->get_objects( { name => 'Annotators' } );
286        my $annoScope = $dbmaster->UserHasScope->get_objects( { scope => $annoGrp->[0] } );
287        my $annoMems = [];
288        foreach my $aS ( @$annoScope ) {
289          push @$annoMems, $aS->user();
290        }
291        @$annoMems = sort { $a->lastname cmp $b->lastname || $a->firstname cmp $b->firstname } @$annoMems;
292    
293        my $editRightButton = "<INPUT TYPE=SUBMIT ID='GrantRightButton' NAME='GrantRightButton' VALUE='Grant Right'>";
294        my $revokeRightButton = "<INPUT TYPE=SUBMIT ID='RevokeRightButton' NAME='RevokeRightButton' VALUE='Revoke Right'>";
295    
296        my $user_has_scopes = $dbmaster->UserHasScope->get_objects( { user => $user });
297        my $available_groups = {};
298        foreach my $user_has_scope (@$user_has_scopes) {
299          my $scope = $user_has_scope->scope();
300          next if $scope->name() =~ /^user:/;
301          next if $scope->name() =~/^Public/;
302          $available_groups->{$scope->{_id}} = $scope;
303        }
304        my $all_ss_edit_rights = $dbmaster->Rights->get_objects( { name => 'edit',
305                                                                   data_type => 'subsystem',
306                                                                   data_id => $name } );
307        my $user_groups_have_right = [];
308        my $user_groups_not_have_right = [];
309        foreach my $r (@$all_ss_edit_rights) {
310          my $scope = $r->scope;
311          next if $scope->name() =~ /^user:/;
312          next if $scope->name() =~/^Public/;
313          push(@$user_groups_have_right, [ $scope->_id, $scope->name ]);
314          delete $available_groups->{$scope->{_id}};
315        }
316        foreach my $key (sort(keys(%$available_groups))) {
317          my $scope = $available_groups->{$key};
318          push(@$user_groups_not_have_right, [ $scope->_id, $scope->name ]);
319        }
320    
321        my $annotatorsBox = "<SELECT NAME='ANNOBOX' ID='ANNOBOX'>";
322        my $alreadyAnnotatorsBox = "<SELECT NAME='ALANNOBOX' ID='ALANNOBOX'>";
323        foreach my $a ( @$user_groups_have_right ) {
324          $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->[0]."|group ".$a->[1]."'>group ".$a->[1]."</OPTION>";
325        }
326        foreach my $a ( @$user_groups_not_have_right ) {
327          $annotatorsBox .= "<OPTION VALUE='".$a->[0]."|group ".$a->[1]."'>group ".$a->[1]."</OPTION>";
328        }
329        foreach my $a ( @$annoMems ) {
330          my $r = $dbmaster->Rights->get_objects( { name => 'edit',
331                                                    scope => $a->get_user_scope,
332                                                    data_type => 'subsystem',
333                                                    data_id => $name } );
334          unless ( scalar(@$r) ) {
335            $annotatorsBox .= "<OPTION VALUE='".$a->get_user_scope->_id."|".$a->firstname." ".$a->lastname."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
336          }
337          else {
338            if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {
339              $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->get_user_scope->_id."|".$a->firstname." ".$a->lastname."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
340            }
341          }
342        }
343        $annotatorsBox .= "</SELECT>";
344        $alreadyAnnotatorsBox .= "</SELECT>";
345    
346        $infotable .= "<TR><TH>Grant Right To Edit To:</TH><TD>$annotatorsBox $editRightButton</TD></TR>";
347        $infotable .= "<TR><TH>Revoke Right To Edit From:</TH><TD>$alreadyAnnotatorsBox $revokeRightButton</TD></TR>";
348      }
349    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
350    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
351    
# Line 248  Line 373 
373      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\" );'>";
374      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\" );'>";
375    
376      $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>";
377      $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>";
378      $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>";
379      $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>";
380    }    }
# Line 369  Line 494 
494    my @ssclassifications = $fig->all_subsystem_classifications();    my @ssclassifications = $fig->all_subsystem_classifications();
495    my $ssclass;    my $ssclass;
496    foreach my $ssc ( @ssclassifications ) {    foreach my $ssc ( @ssclassifications ) {
497      next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );      if ( !defined( $ssc->[1] ) ) {
498      next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );        $ssc->[1] = '';
499        }
500    #    next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );
501        next if ( !defined( $ssc->[0] ) );
502        next if ( $ssc->[0] eq '' );
503    #    next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );
504      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );
505      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];
506    }    }
# Line 508  Line 638 
638    }    }
639    
640    foreach my $np ( @$newpubs ) {    foreach my $np ( @$newpubs ) {
641      my @h = split( /\s+/, $np );      #my @h = split( /\s+/, $np );
642      $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_WEBLINKS", @h );      $np =~ s/\s*(http\S+)\s*//;
643        my $link=$1;
644        $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_WEBLINKS", $np, $link );
645        print STDERR "Adding attribute 'Subsystem:$name' 'SUBSYSTEM_WEBLINKS', '$np', '$link'\n";
646    }    }
647  }  }
648    

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.34

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3