User patterns

Presentation

A user pattern is a way to automatically fill some fields when creating a user. Any pattern is bound to a domain and can only be used into this domain. All patterns of the global domain are cloned into any newly created domain.

User pattern module

User pattern create form

The userpattern module allows standard CRUD operations on user patterns.

The user pattern create/update form looks like the user's one.

Depending on the type of the field, different values can be used :

  • Checkbox : checked or not
  • Date : empty, specified day, %today% (to initialize the field with the date of the current day) or %today+30% (in 30 days, standard arithmetic operations on dates, based on a number of days: %today+x% ou %today-x%)
  • Text field : text that can contain specific keywords. eg: %firstname%.%lastname% to generate the login. The create form has to check that there isn't any circular depedencies between fields. Eg: login = %email% and email = %login%
  • Select field : choice
  • Password field : empty or %random%

Database model

A pattern is bound to a domain. A pattern owns a title and a description. A pattern owns the list of user attributes (except ignored ones) and the way to fill them.

Database storage:

userpattern {
  id
  domain_id
  timeupdate
  timecreate
  userupdate
  usercreate
  title
  description
}

+ key/value table to store each attribute :

userpattern_property {
  userpattern_id
  attribute
  value
}

User create form

A new select field allow to choose the pattern to apply.

As soon as a pattern is applied, the concerned fields are automatically filled. When editing any field, depending fields are modified “in live”. Eg: The login is automatically modified when the user lastname has changed.

Usable Keywords

User specific

Kind                    %kind%
Lastname                %lastname%
Firstname               %firstname%
Login                   %login%
Profile                 %profile%
Delegation              %delegation%
Delegation Target       %delegation_target%
Title                   %title%

Contact informations

Phone number            %phone%
Phone 2                 %phone2%
Mobile phone            %mobile%
Fax                     %fax%
Fax 2                   %fax2%
Company                 %company%
Direction               %direction%
Service                 %service%
Address 1               %ad1%
Address 2               %ad2%
Address 3               %ad3%
Zip code                %zip%
City                    %town%
Express code            %cdx%

Description

Description             %desc%

Extra

Today's date            %today%
In x days               %today+x%
x days ago              %today-x%
The domain name         %domain%
Generate a password     %random% (only usable into the password field)

Limitations when using config specific fields (categories and fields)

Specific fields can be used when editing a user pattern.

  • A field can be used as a keyword only if it's type is text or textarea
  • A category can not be used as a keyword

Limitations

  • Complex filling rules can not be used (eg: login = first firstname char + lastname).
  • Select, checkbox and radio button fields cannot be used as keywords.
userpattern.txt · Last modified: 2010/05/19 11:54 by vincenta
Driven by DokuWiki