NAME

Konstrukt::Plugin::usermanagement::level - Information about the users (admin) level.

SYNOPSIS

Tag interface

	<!-- 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" / &>
	

Perl interface

my $user_level = use_plugin 'usermanagement::level';
my $level = $user_level->level();

DESCRIPTION

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.

DEPENDENCIES

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.

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" / &>

CONFIGURATION

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

METHODS

init

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.

install

Installs the templates.

Parameters:

none

execute_again

Yes, this plugin may return dynamic nodes (i.e. template nodes).

prepare

Prepare method

Parameters:

  • $tag - Reference to the tag (and its children) that shall be handled.

execute

Execute method

Parameters:

  • $tag - Reference to the tag (and its children) that shall be handled.

level

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.

Parameters:

  • $uid - The user ID

data

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)

new_user

Creates a new entry for the given user id.

Parameters (optional):

  • $uid - The user id (optional)

del_user

Deletes an entry with the given user id.

Parameters:

  • $uid - The user id

show_users

Returns the Konstrukt-Code to display the existing users.

show_change_level

Returns the Konstrukt-Code to display a form to change the level of a specified user.

change_level

Takes the HTTP form input and changes the level for the specified user.

Returns a confirmation of the successful change or error messages otherwise.

Parameters:

  • $uid - The user whose level should be changed

  • $level - The new level

AUTHOR

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.

SEE ALSO

Konstrukt::Plugin::usermanagement::level::DBI, Konstrukt::Plugin, Konstrukt