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

View of /SubsystemEditor/WebPage/DeleteFeature.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Wed Oct 1 10:35:11 2008 UTC (11 years, 3 months ago) by bartels
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Tobi constructed a method that does the same

package SubsystemEditor::WebPage::DeleteFeature;

use strict;
use warnings;
use URI::Escape;
use HTML;
use Data::Dumper;

use FIG;

use base qw( WebPage );

1;

##############################################################
# Method for registering components etc. for the application #
##############################################################
sub init {
  my ( $self ) = @_;
  $self->application->register_component( 'Info', 'CommentInfo' );
}

#################################
# File where Javascript resides #
#################################
sub require_javascript {

  return [ './Html/showfunctionalroles.js' ];

}

##############################################
# Website content is returned by this method #
##############################################
sub output {
  my ( $self ) = @_;

  $self->{ 'fig' } = $self->application->data_handle('FIG');
  $self->{ 'cgi' } = $self->application->cgi;

  my ( $error, $comment ) = ( "", "" );

  #########
  # TASKS #
  #########
  my $content = "<H1>Delete feature</H1>";

  if ( $self->{ 'cgi' }->param( 'DELETE' ) ) {
    my $featuretodelete = $self->{ 'cgi' }->param( 'fid' );
    ( $comment, $error ) = $self->delete_feature( $featuretodelete );
  }
  else {
    ##############################
    # Construct the page content #
    ##############################
    
    $content .= $self->start_form( 'form' );
    $content .= "<TABLE><TR>";
    $content .= "<TD>Feature:</TD><TD><INPUT TYPE=TEXT SIZE=100 NAME='fid'></TD>";
    $content .= "</TR></TABLE>";
    $content .= "<INPUT TYPE=SUBMIT VALUE='DELETE' NAME='DELETE'>";
    $content .= $self->end_form();
  }


  ####################
  # Display comments #
  ####################
  if ( defined( $comment ) && $comment ne '' ) {
    my $info_component = $self->application->component( 'CommentInfo' );
    
    $info_component->content( $comment );
    $info_component->default( 0 );
    $content .= $info_component->output();
  } 
  

  ##################
  # Display errors #
  ##################
  
  if ( defined( $error ) && $error ne '' ) {
    $self->application->add_message( 'warning', $error );
  }

  return $content;
}

sub delete_feature {

  my ( $self, $featuretodelete ) = @_;

  # look if someone is logged in and can write the seed #
  $self->{ 'can_alter' } = 0;
  my $user = $self->application->session->user;

  my $genome = $self->{ 'fig' }->genome_of( $featuretodelete );
  
  if ( $user->has_right( undef, 'annotate', 'genome', $genome ) ) {
    $self->{ 'seeduser' } = $user->login();
    $self->{ 'can_alter' } = 1;
  }
  else {
    return ( '', "You do not have the right to delete features\n" );
  }
  
  $self->{ 'fig' }->delete_feature( $self->{ 'seeduser' }, $featuretodelete );
  return ( "The feature $featuretodelete was deleted.<BR>", '' );
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3