Why not adopt me?
NAME
User::Simple::Admin - User::Simple user administration
SYNOPSIS
$ua = User::Simple::Admin->new($db, $user_table);
$ua = User::Simple::Admin->create_rdbms_db_structure($db, $user_table);
$ua = User::Simple::Admin->create_plain_db_structure($db, $user_table);
$ok = User::Simple::Admin->has_db_structure($db, $user_table);
%users = $ua->dump_users;
$id = $ua->id($login);
$login = $ua->login($id);
$name = $ua->name($id);
$level = $ua->level($id);
$ok = $usr->set_login($id, $login);
$ok = $usr->set_name($id, $name);
$ok = $usr->set_level($id, $level);
$ok = $usr->set_passwd($id, $passwd);
$ok = $usr->clear_session($id);
$id = $ua->new_user($login, $name, $passwd, $level);
$ok = $ua->remove_user($id);
DESCRIPTION
User::Simple::Admin manages the administrative part of the User::Simple modules - Please check User::Simple for a general overview of these modules and an explanation on what-goes-where.
User::Simple::Admin works as a regular administrator would: The module should be instantiated only once for all of your users' administration, if possible, and not instantiated once for each user (in contraposition to User::Simple, as it works from each of the users' perspective in independent instantiations).
Note also that User::Simple::Admin does b<not> perform the administrative user checks - It is meant to be integrated to your system, and it is your system which should carry out all of the needed authentication checks.
CONSTRUCTOR
Administrative actions for User::Simple modules are handled through this Admin object. To instantiate it:
$ua = User::Simple::Admin->new($db, $user_table);
$db is an open connection to the database where the user data is stored.
$user_table is the name of the table that holds the users' data.
If we do not yet have the needed DB structure to store the user information, we can use this class method as a constructor as well:
$ua = User::Simple::Admin->create_rdbms_db_structure($db, $user_table);
$ua = User::Simple::Admin->create_plain_db_structure($db, $user_table);
The first one should be used if your DBI handle ($db) points to a real RDBMS, such as PostgreSQL or MySQL. In case you are using a file-based DBD (such as DBD::XBase, DBD::DBM, DBD::CVS or any other which does not use a real RDBMS for storage), use User::Simple::Admin->create_plain_db_structure
instead. What is the difference? In the first case, we will create a table that has internal consistency checks - Some fields are declared NOT NULL, some fields are declared UNIQUE, and the user ID is used as a PRIMARY KEY. This cannot, of course, be achieved using file-based structures, so the integrity can only be maintained from within our scripts.
QUERYING FOR DATABASE READINESS
In order to check if the database is ready to be used by this module with the specified table name, use the has_db_structure
class method:
$ok = User::Simple::Admin->has_db_structure($db, $user_table);
RETRIEVING THE SET OF USERS
%users = $ua->dump_users;
Will return a hash with the data regarding the registered users, in the following form:
( $id1 => { level => $level1, name => $name1, login => $login1},
$id2 => { level => $level2, name => $name2, login => $login2},
(...) )
CREATING, QUERYING AND MODIFYING USERS
$id = $ua->new_user($login, $name, $passwd, $level);
Creates a new user with the specified data. Returns the new user's ID.
$ok = $ua->remove_user($id);
Removes the user specified by the ID.
$id = $ua->id($login);
$login = $ua->login($id);
$name = $ua->name($id);
$level = $ua->level($id);
Get the value of each of the mentioned attributes. Note that in order to get the ID you can supply the login, every other method answers only to the ID. In case you have the login and want to get the name, you should use $ua-
name($ua->id($login));>
$ok = $usr->set_login($id, $login);
$ok = $usr->set_name($id, $name);
$ok = $usr->set_passwd($id, $passwd);
$ok = $usr->set_level($id, $level);
Modifies the requested attribute of the specified user, setting it to the new value.
SESSIONS
$ok = $usr->clear_session($id);
Removes the session which the current user had open, if any.
Note that you cannot create a new session through this module - The only way of creating a session is through the ck_login
method of User::Simple.
DEPENDS ON
SEE ALSO
User::Simple for the regular user authentication routines (that is, to use the functionality this module adimisters)
AUTHOR
Gunnar Wolf <gwolf@gwolf.org>
COPYRIGHT
Copyright 2005 Gunnar Wolf / Instituto de Investigaciones Económicas UNAM This module is Free Software, it can be redistributed under the same terms as Perl.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 149:
Non-ASCII character seen before =encoding in 'Económicas'. Assuming CP1252