EnsEMBL::Web::DBSQL
SessionAdaptor
Toolbar
Package variables
Privates (from "my" definitions)
%DBAdaptor_of :ATTR( :name<db_adaptor> );
%SpeciesDefs_of :ATTR( :name<species_defs> );
Included modules
CGI::Cookie
Class::Std
Digest::MD5
EnsEMBL::Web::Session
strict
Synopsis
No synopsis!
Description
No description!
Methods
clearCookie | No description | Code |
create_session_id | No description | Code |
getConfig | No description | Code |
getConfigByName | No description | Code |
getConfigsByType | No description | Code |
get_session_by_id | No description | Code |
get_session_from_cookie | No description | Code |
resetConfig | No description | Code |
resetConfigByName | No description | Code |
setConfig | No description | Code |
setConfigByName | No description | Code |
Methods description
None available.
Methods code
sub clearCookie
{
my( $self, $r, $session ) = @_;
return unless $session->get_session_id;
$self->get_db_adaptor->do("delete from session_record where session_id = ?", {}, $session->get_session_id);
if( $r ) {
$session->get_cookie->clear( $r );
} } |
sub create_session_id
{
my( $self, $r, $cookie ) = @_;
warn "CREATING SESSION.... ";
return 0 unless( $self->get_db_adaptor );
my($session_id) = $self->get_db_adaptor->selectrow_array("select last_session_no from session");
if($session_id) {
$self->get_db_adaptor->do("update session set last_session_no = ?",{}, ++$session_id );
} else {
$session_id = 1;
$self->get_db_adaptor->do("insert into session (last_session_no) values(?)",{}, $session_id);
}
if( $r ) {
$cookie->create( $r, $session_id );
}
return $session_id; } |
sub getConfig
{ my( $self,$session_id,$type_id, $key ) = @_;
return unless( $session_id && $type_id && $self->get_db_adaptor );
my( $value ) = $self->get_db_adaptor->selectrow_array(
"select data from session_record
where session_id = ? and type_id = ? and code = ?", {},
$session_id, $type_id, $key
);
return $value; } |
sub getConfigByName
{ my( $self, $session_id, $type, $key ) = @_;
return unless( $self->get_db_adaptor && $session_id > 0 );
my( $type_id ) = $self->get_db_adaptor->selectrow_array( "select type_id from type where code = ?", {}, $type );
return unless $type_id;
my( $value ) = $self->get_db_adaptor->selectrow_array( "select data from session_record where session_id = ? and type_id = ? and code = ?", {}, $session_id, $type_id, $key );
return $value; } |
sub getConfigsByType
{ my( $self, $session_id, $type ) = @_;
return unless( $self->get_db_adaptor && $session_id > 0 );
my( $type_id ) = $self->get_db_adaptor->selectrow_array( "select type_id from type where code = ?", {}, $type );
return unless $type_id;
my %configs = map {($_->[0]=>$_->[1])} @{$self->get_db_adaptor->selectall_arrayref( "select code, data from session_record where session_id = ? and type_id = ?", {}, $session_id, $type_id )||{}};
return\% configs; } |
sub get_session_by_id
{ my( $self, $arg_ref ) = @_;
return EnsEMBL::Web::Session->new({
'adaptor' => $self,
'cookie' => undef,
'session_id' => $arg_ref->{'ID'},
'species_defs' => $self->get_species_defs,
'species' => $arg_ref->{'species'},
}); } |
sub get_session_from_cookie
{ my( $self, $arg_ref ) = @_;
$arg_ref->{'cookie'}->retrieve($arg_ref->{'r'});
return EnsEMBL::Web::Session->new({
'adaptor' => $self,
'cookie' => $arg_ref->{'cookie'},
'session_id' => $arg_ref->{'cookie'}->get_value,
'species_defs' => $self->get_species_defs,
'species' => $arg_ref->{'species'}
}); } |
sub resetConfig
{ my( $self, $session_id, $type_id, $key ) = @_;
return unless( $type_id > 0 && $self->get_db_adaptor && $session_id > 0 );
$self->get_db_adaptor->do(
"delete from session_record
where session_id = ? and type_id = ? and code = ?", {},
$session_id, $type_id, $key
);
}
}
1; } |
sub resetConfigByName
{ my( $self, $session_id, $type, $key ) = @_;
return unless( $self->get_db_adaptor && $session_id > 0 );
my( $type_id ) = $self->get_db_adaptor->selectrow_array( "select type_id from type where code = ?", {}, $type );
return unless $type_id;
$self->get_db_adaptor->do( "delete from session_record where session_id = ? and type_id = ? and code = ?", {}, $session_id, $type_id, $key ); } |
sub setConfig
{ my( $self, $session_id, $type_id, $key , $value ) = @_;
return unless( $session_id && $type_id && $self->get_db_adaptor );
my $rows = $self->get_db_adaptor->do(
"insert into session_record
(created_at,modified_at,session_id,type_id,code,data) values (now(),now(),?,?,?,'')",{},
$session_id, $type_id, $key
);
$self->get_db_adaptor->do(
"update session_record set data = ?, modified_at = now()
where session_id = ? and type_id = ? and code = ?", {},
$value, $session_id, $type_id, $key
);
return $session_id; } |
setConfigByName | description | prev | next | Top |
sub setConfigByName
{ my( $self, $session_id, $type, $key, $value ) = @_;
return unless( $self->get_db_adaptor && $session_id > 0 );
my( $type_id ) = $self->get_db_adaptor->selectrow_array( "select type_id from type where code = ?", {}, $type );
unless( $type_id ) {
$self->get_db_adaptor->do( "insert into type (code) values(?)", {}, $type );
( $type_id ) = $self->get_db_adaptor->selectrow_array( "select type_id from type where code = ?", {}, $type );
}
return $self->setConfig( $session_id, $type_id, $key, $value ); } |
General documentation
No general documentation available.