Konstrukt::Plugin::usermanagement::level - Information about the users (admin) level.
<!-- Show a list of all users and forms to change each user's level. This is the default if the "show"-attribute is omitted. --> <& usermanagement::level show="users" / &> <!-- Show the level of the current user. May be useful in conditional templates. --> <& usermanagement::level show="level" / &>
my $user_level = use_plugin 'usermanagement::level'; my $level = $user_level->level();
User levels:
Every user has an user level, which is represented by a number. The higher this number ist, the more operations will be allowed to this user.
An user that is not registered/logged in has a level of 0. A user that has just registered get the user level 1. The first user that has just registered will get the super user level.
An admin may set the levels of the other users. And the users may do some operations on the website according to their level.
To view all registered users and change the user level of an other user you have to be logged in and you must have an user level that ist greater or equal to the appropriate number defined in your konstrukt.settings:
usermanagement/level/superuser_level 3
Other plugins may have similar settings as well, which define the needed user levels to permit special operations.
This plugin create a new entry for every newly registered user and deletes it when the user deregisters.
To know when a user (de)registers, this plugin has to register itself for the registered and deregistered events, that the basic usermanagement plugin fires.
registered
deregistered
So this plugin must be initialized before the basic user management plugin is executed. For this to happen, you can preload this plugin like this on the page, where the basic usermanagement is executed:
<& perl &> #preload plugins, which will react on events (register, deregister) use_plugin 'usermanagement::level'; <& / &> <& usermanagement::basic show="login, changepass, register, sendpass" / &>
You have to do some konstrukt.settings-configuration to let the plugin know where to get its data and which layout to use. Defaults:
#backend usermanagement/level/backend DBI
See the documentation of the backend modules (e.g. "CONFIGURATION" in Konstrukt::Plugin::usermanagement::level::DBI) for their configuration.
#layout usermanagement/level/template_path /templates/usermanagement/level/ #superuser level usermanagement/level/superuser_level 3
Initializes this object. Sets $self->{backend}, $self->{template_path}messages/ and $self->{template_path}layout/.
init() will be called the first time this plugin is needed each request.
init()
Installs the templates.
Parameters:
none
Yes, this plugin may return dynamic nodes (i.e. template nodes).
Prepare method
$tag - Reference to the tag (and its children) that shall be handled.
Execute method
Returns the level level of the specified user. If no user is specified, the currently logged in user will be used. Returns 0 ist not logged in or user not existant.
$uid - The user ID
Returns all relevant user data as an anonymous hash, if uid exists:
{ level => ... }
Returns an empty hash if the uid doesn't exist.
Parameters (optional):
$uid - The user id (optional)
Creates a new entry for the given user id.
Deletes an entry with the given user id.
$uid - The user id
Returns the Konstrukt-Code to display the existing users.
Returns the Konstrukt-Code to display a form to change the level of a specified user.
Takes the HTTP form input and changes the level for the specified user.
Returns a confirmation of the successful change or error messages otherwise.
$uid - The user whose level should be changed
$level - The new level
Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.
This document is free software. It is distributed under the same terms as Perl itself.
Konstrukt::Plugin::usermanagement::level::DBI, Konstrukt::Plugin, Konstrukt
To install Konstrukt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Konstrukt
CPAN shell
perl -MCPAN -e shell install Konstrukt
For more information on module installation, please visit the detailed CPAN module installation guide.