Sean P. Quinlan > SQCAS-0.24 > SQCAS::DB

Download:
SQCAS-0.24.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.4   Source  

NAME ^

SQCAS::DB - DBI wrapper which adds a few SQCAS specific methods.

SYNOPSIS ^

  use SQCAS qw(:all);
  my $dbh = $CONFIG{DBH};

ABSTRACT ^

  Wraps the DBI module, extending the database handle with some SQCAS specific
  methods. This module is not intemded to be used directly - _config.pm
  makes the connection using paramters from the SQCAS.yaml configuration.

DESCRIPTION ^

Used by _config.pm to connect to the SQCAS servers database. The database handle is avalable at $CONFIG{DBH}. Use this as you would normally use a DBI database handle. The methods described below are extensions to the normal DBI functionality.

EXPORT

None by default.

METHODS

connectDB

Wrapper for DBI->connect. Mainly does some configuration checking and if the connection attempt fails will try every three seconds ten times.

PARAMETERS:

user: Username to connect to the database with.

password: Password for user.

server: Type of database server. Defaults to mysql.

host: Host to connect to. Defaults to localhost.

userdat

Returns a data structure containg info about user. Requires sessiontag.

                    Username     => $username,
                        ID           => $id,
                    Groups       => $AR_group_ids,
                    Group_Names  => $AR_group_names,
                    tag          => $tag,
                    Qtag         => $Qtag,
                        FullName     => $name,
                        UserInfo     => $HR_userinfo,
                        Supplemental => $HR_supplemental

tag is the session tag (or cookie). Qtag is the db quoted tag string. UserInfo is a hash of all the fields in the UserInfo table (except ID). Supplemental is a hash of all the supplimental client tables in which the user appeared, the values of which are hashes of the contents.

allowed

Does the user have the requested permission on the indicated resource. Return value is true (actually returns the numeric value of the mask) if allowed, null (uundef) if not, 0 on error. Call $DBH->error to see any error messages.

This method will check for permissions by both user id ad group memberships. However it is important to remember that permission granted in any grants permission, and individual user permision is checked first.

PARAMS:

USER: The userdat hash as returned by this module. Since the hash is stored in the DBH object, this can be left out to use the same values as last returned.

RESOURCE: The resource we are checking. Could be a database table, a file (such as a CGI or data archive), a port - whatever.

MATCHKEY: The key to match. If no key provided will use the wildcard.

CLIENT: The client ID or domain from which this request is being made.

PERMISSIONS: What permision to check. This can be supplied as string or integer. Values are read = 8, modify = 4, create = 2, delete = 1. To check for multiple Permissions at once you will need to use the numeric notation, summing the required Permissions. So to check for Read and Modify permision provide 12 as the parameters value. Create refers to permision to create a new record which uses the refered to resource as a foreign key, or is under the refered resource 'tree'.

MASK: Same as PERMISSIONS.

Examples:

 # can place orders using fund 8887-009500
 $DBH->allowed({USER => \%userdat, RESOURCE => 'DNAcoreAdmin.Fund',
        MATCHKEY => '8887,009500', PERMISSIONS => 2});

 # can view oligo OD QC tool CGI (using cached userdat hash)
 $DBH->allowed({RESOURCE => 'cgi-bin/synthesis/oligoOD', PERMISSIONS => 'read'});

 # can delete results file
 $DBH->allowed({RESOURCE => 'sequencing/results/MK453GF67.seq', MASK => 1,
        USER => \%userdat});

client_info

Returns a hash reference with the info from the clients table. Hash will have two sets of top level keys. The first are the domains that the clients define with the value being the client ID; this allows lookup of client IDs by the domains. The second key set are the client IDs, with the values being the contents of the Clients table for that client.

enum_to_array

Sole argument is the 'DESC <Table_Name> <Field>' to be used. Sets error if not an enum field. Returns a list of the possible enum (or set) values.

Replaces use of $DBI::errstr and $DBI::err. Returns error string from extension methods or $DBI::errstr as appropriate.

TO DO ^

HISTORY ^

0.01

Original version; created by h2xs 1.22 with options

  -AXC
        -n
        SQCAS::DB
0.4

All the basic SQCAS required functions in place and working.

SEE ALSO ^

DBI

AUTHOR ^

Sean Quinlan, <seanq@darwin.bu.edu>

COPYRIGHT AND LICENSE ^

Copyright 2004 by Sean Quinlan

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.