NAME

MACS::DBI -- handle macs' interaction with the SQL database.


SYNOPSIS

  use MACS::DBI;
  $dbi = MACS::DBI->new( [ log => MACS::Log ]
                         [ cfg => MACS::XMLConfig ] );
  $groups = $dbi->get_groups($uid);
  ...


DESCRIPTION

MACS::DBI is the database abstraction layer for macs. It is very simple to use, just instantiate it and use any of the following methods according to its instructions:

get_path_id(path)
Find the resource id of a give path

get_id_path(id)
Find the path of a given resource id

get_method_id(method)
Find the resource id of a given method

map_key(method,key)
Clarify: Map a key to a user via the specified method

map_profile(profile)
Clarify: map a user from thier profile

create_resource(parent,name)
Create a new resource name under parent

create_root_resource(name)
Create a new resource name as a root resource

create_user(method,login,map)
Create a new user, mapped to login@method by map. The user name will be login plus some numbers if it is not unique. map is a hashref, which should have a 'profile' key, whose value is a hashref of profile values keyed by namespace path. It should also have a key 'key', whose value is the value of a user's profile under the method's namespace (usually a method-specific username) used for a sort of fast mapping cache. Alternatively, it may have a 'uid' key instead of the others (mostly for use by the Internal method.) Returns new user id if successful, fatally logs otherwise.

login(login,password)
If the given login and password match an existing user, returns the uid. Otherwise returns undef.

list_name_spaces(id,type)
list the profile name spaces of type type available for a given resource id

get_profile(resource,name_space,type,bufref)
Get the data item of type type from resource's name_space and store it in bufref. Both resource and name_space are IDs, not paths.

set_profile(resource,name_space,type,bufref)
Set the type in resource's name_space profile item to equal the contents of bufref. Both resource and name_space are IDs, not paths.

del_profile(resource,name_space)
Delete resource's name_space profile item. Both resource and name_space are IDs, not paths.

del_perm(resource,group)
Remove group's permissions on a given resource. Both resource and group are IDs, not paths.

set_perm(resource,group,disable,own,admin,read,write)
Set group's disable, own, admin, read, and write permissions on a given resource. Both resource and group are IDs, not paths.

get_roots()
Returns an array ref of IDs of resource tree roots.

get_children(id)
Returns an array ref of IDs of the children of the given resource id.

add_group_member(group,member,type)
Clarify type: Add a memeber to a group.

get_groups(id)
Find all groups the given resource id is in. If id is undef, then returns a list of all groups.

build_gperms(node,groups)
build the permission data for all the specified groups, on the specified resource node