Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > The "autoriser" library

The "autoriser" library

SPIP has an extendable autoriser() function enabling the verification of authorisations. This function accepts 5 arguments. Only the first is necessary, and the others are all optional.

  1. autoriser($faire, $type, $id, $qui, $opt);

The function returns true or false depending on the authorisation requested and the user(editor) who is connected (or the requested user passed as an explicit parameter). Here are what the different arguments are used for:

  • $faire corresponds to the action requested. For example "modifier" (modify) or "voir" (view),
  • $type is generally used to define the object type, for example "auteur" (author) or "article",
  • $id is used to provide the identifier of the requested object, for example "8" as an article number,
  • $qui is used to enquire or assign authorisation for a specific author. When not provided, it assumes the currently connected author. The argument is typically an id_auteur number. This variable will be filed up with all of the available information relating to the designated author in the form of an array,
  • $opt is an array of options, usually empty. When an authorisation requires additional arguments to be passed, they are entered in this array.

Example

  1. if (autoriser('modifier','article',$id_article)) {
  2. // ... actions
  3. }

Download

  • Author :
  • Published :
  • Updated : 13/10/10
  • Translations : English, français