[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.25, Thu Mar 19 12:03:24 2009 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' #
# Line 49  Line 49 
49    my $can_alter = 0;    my $can_alter = 0;
50    my $user = $self->application->session->user;    my $user = $self->application->session->user;
51    
52    my $dbmaster = DBMaster->new( -database => 'WebAppBackend' );    my $dbmaster = $self->application->dbmaster;
53    my $ppoapplication = $dbmaster->Backend->init( { name => 'SubsystemEditor' } );    my $ppoapplication = $self->application->backend;
54    
55    # get a seeduser #    # get a seeduser #
56    my $seeduser = '';    my $seeduser = '';
# Line 170  Line 170 
170      $subsystem->set_classification( [ $class1, $class2 ] );      $subsystem->set_classification( [ $class1, $class2 ] );
171    
172      my $litstoset = $cgi->param( 'SUBSYSLIT' );      my $litstoset = $cgi->param( 'SUBSYSLIT' );
173        $litstoset =~ s/ //g;
174      my @lits = split( ', ', $litstoset );      my @lits = split( ', ', $litstoset );
175      setLiteratures( $fig, $name, \@lits );      setLiteratures( $fig, $name, \@lits );
176    
# Line 184  Line 185 
185      $subsystem->db_sync();      $subsystem->db_sync();
186      $subsystem->write_subsystem();      $subsystem->write_subsystem();
187    }    }
188      elsif ( defined( $cgi->param( 'GrantRightButton' ) ) ) {
189        if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
190          my $newAnno = $cgi->param( 'ANNOBOX' );
191          my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );
192          if ( defined( $thisUsers->[0] ) ) {
193    
194            my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
195                                                           data_type => 'subsystem',
196                                                           data_id => $name,
197                                                           scope => $thisUsers->[0]->get_user_scope() } );
198            if ( defined( $rights->[0] ) ) {
199              $self->application->add_message( 'warning', "User $newAnno already has the right to edit this subsystem." );
200            }
201            else {
202              my $right = $dbmaster->Rights->create( { granted => 1,
203                                                       delegated => 1,
204                                                       name => 'edit',
205                                                       data_type => 'subsystem',
206                                                       data_id => $name,
207                                                       scope => $thisUsers->[0]->get_user_scope() } );
208              if ( $right ) {
209                $self->application->add_message( 'info', "$newAnno can now edit this subsystem" );
210              }
211              else {
212                $self->application->add_message( 'warning', "Could not create right to edit the subsystem for user $newAnno" );
213              }
214            }
215          }
216        }
217        else {
218          $self->application->add_message( 'warning', "You do not have the right to share the subsystem." );
219        }
220      }
221      elsif ( defined( $cgi->param( 'RevokeRightButton' ) ) ) {
222        if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
223          my $newAnno = $cgi->param( 'ALANNOBOX' );
224          my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );
225          my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
226                                                         data_type => 'subsystem',
227                                                         data_id => $name,
228                                                         scope => $thisUsers->[0]->get_user_scope() } );
229    
230          my $thisRight = $rights->[0];
231          if ( defined( $thisRight ) && $thisRight->delegated ) {
232            $thisRight->delete();
233    
234            $self->application->add_message( 'info', "$newAnno cannot edit this subsystem any more." );
235          }
236          else {
237            $self->application->add_message( 'warning', "You can't revoke the right of $newAnno to edit this subsystem." );
238          }
239        }
240        else {
241          $self->application->add_message( 'warning', "You do not have the right to revoke rights for this subsystem." );
242        }
243      }
244    
245    $subsystem = new Subsystem( $name, $fig, 0 );    $subsystem = new Subsystem( $name, $fig, 0 );
246    
# Line 221  Line 278 
278    
279    my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";    my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";
280    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";
281      if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
282    
283        my $annoGrp = $dbmaster->Scope->get_objects( { name => 'Annotators' } );
284        my $annoScope = $dbmaster->UserHasScope->get_objects( { scope => $annoGrp->[0] } );
285        my $annoMems = [];
286        foreach my $aS ( @$annoScope ) {
287          push @$annoMems, $aS->user();
288        }
289        @$annoMems = sort { $a->lastname cmp $b->lastname || $a->firstname cmp $b->firstname } @$annoMems;
290    
291        my $editRightButton = "<INPUT TYPE=SUBMIT ID='GrantRightButton' NAME='GrantRightButton' VALUE='Grant Right'>";
292        my $revokeRightButton = "<INPUT TYPE=SUBMIT ID='RevokeRightButton' NAME='RevokeRightButton' VALUE='Revoke Right'>";
293    
294        my $annotatorsBox = "<SELECT NAME='ANNOBOX' ID='ANNOBOX'>";
295        my $alreadyAnnotatorsBox = "<SELECT NAME='ALANNOBOX' ID='ALANNOBOX'>";
296        foreach my $a ( @$annoMems ) {
297          unless ( $a->has_right( undef, 'edit', 'subsystem', $name ) ) {
298            $annotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
299          }
300          else {
301            if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {
302              $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
303            }
304          }
305        }
306        $annotatorsBox .= "</SELECT>";
307        $alreadyAnnotatorsBox .= "</SELECT>";
308    
309        $infotable .= "<TR><TH>Grant Right To Edit To:</TH><TD>$annotatorsBox $editRightButton</TD></TR>";
310        $infotable .= "<TR><TH>Revoke Right To Edit From:</TH><TD>$alreadyAnnotatorsBox $revokeRightButton</TD></TR>";
311      }
312    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
313    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
314    
# Line 369  Line 457 
457    my @ssclassifications = $fig->all_subsystem_classifications();    my @ssclassifications = $fig->all_subsystem_classifications();
458    my $ssclass;    my $ssclass;
459    foreach my $ssc ( @ssclassifications ) {    foreach my $ssc ( @ssclassifications ) {
460      next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );      if ( !defined( $ssc->[1] ) ) {
461      next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );        $ssc->[1] = '';
462        }
463    #    next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );
464        next if ( !defined( $ssc->[0] ) );
465        next if ( $ssc->[0] eq '' );
466    #    next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );
467      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );
468      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];
469    }    }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3