[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.20, Thu Aug 14 20:04:20 2008 UTC revision 1.28, Wed Jun 17 15:14:19 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' #
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 101  Line 103 
103    # Build nice tab menu here    # Build nice tab menu here
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" );
107    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );
108    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );
109    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );
# Line 169  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 183  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 = $cgi->param( 'ANNOBOX' );
193          my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );
194          if ( defined( $thisUsers->[0] ) ) {
195    
196            my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
197                                                           data_type => 'subsystem',
198                                                           data_id => $name,
199                                                           scope => $thisUsers->[0]->get_user_scope() } );
200            if ( defined( $rights->[0] ) ) {
201              $self->application->add_message( 'warning', "User $newAnno 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 => $thisUsers->[0]->get_user_scope() } );
210              if ( $right ) {
211                $self->application->add_message( 'info', "$newAnno can now edit this subsystem" );
212              }
213              else {
214                $self->application->add_message( 'warning', "Could not create right to edit the subsystem for user $newAnno" );
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 = $cgi->param( 'ALANNOBOX' );
226          my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );
227          my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
228                                                         data_type => 'subsystem',
229                                                         data_id => $name,
230                                                         scope => $thisUsers->[0]->get_user_scope() } );
231    
232          my $thisRight = $rights->[0];
233          if ( defined( $thisRight ) && $thisRight->delegated ) {
234            $thisRight->delete();
235    
236            $self->application->add_message( 'info', "$newAnno cannot edit this subsystem any more." );
237          }
238          else {
239            $self->application->add_message( 'warning', "You can't revoke the right of $newAnno 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 220  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 $annotatorsBox = "<SELECT NAME='ANNOBOX' ID='ANNOBOX'>";
297        my $alreadyAnnotatorsBox = "<SELECT NAME='ALANNOBOX' ID='ALANNOBOX'>";
298        foreach my $a ( @$annoMems ) {
299          unless ( $a->has_right( undef, 'edit', 'subsystem', $name ) ) {
300            $annotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
301          }
302          else {
303            if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {
304              $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
305            }
306          }
307        }
308        $annotatorsBox .= "</SELECT>";
309        $alreadyAnnotatorsBox .= "</SELECT>";
310    
311        $infotable .= "<TR><TH>Grant Right To Edit To:</TH><TD>$annotatorsBox $editRightButton</TD></TR>";
312        $infotable .= "<TR><TH>Revoke Right To Edit From:</TH><TD>$alreadyAnnotatorsBox $revokeRightButton</TD></TR>";
313      }
314    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
315    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
316    
# Line 368  Line 459 
459    my @ssclassifications = $fig->all_subsystem_classifications();    my @ssclassifications = $fig->all_subsystem_classifications();
460    my $ssclass;    my $ssclass;
461    foreach my $ssc ( @ssclassifications ) {    foreach my $ssc ( @ssclassifications ) {
462      next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );      if ( !defined( $ssc->[1] ) ) {
463      next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );        $ssc->[1] = '';
464        }
465    #    next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );
466        next if ( !defined( $ssc->[0] ) );
467        next if ( $ssc->[0] eq '' );
468    #    next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );
469      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );      next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );
470      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];      push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];
471    }    }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3