#AUTORISER

A #AUTORISER tag is used to request permissions in a template.

  • New in : SPIP 2.0

It returns a space if the authorisation is granted, and an empty string if it is not. It accepts as many arguments (and the same ones) as are used in the autoriser() function.

For example, to find out if the current visitor has the right to view the statistics for the current article:

[(#AUTORISER{voirstats,article,#ID_ARTICLE})
    <a href='ecrire/?exec=....'>View the statistics</a>
]

Just as with the autoriser() function, we can pass an #ID_AUTEUR as an argument to request if that particular author is authorised to do whatever it is.... .

For example, to mark administrators and editors with a sign in a list of authors :

<BOUCLE_a(AUTEURS){tous}>
    #NOM [(#AUTORISER{ecrire,'','',#ID_AUTEUR}) *]
</BOUCLE_a>

Another example, shown below, checks if the visitor has modification rights to the article, and if so, to display a form for editing it which will return back to the same article once the changes have been validated:

[(#AUTORISER{modifier, article, #ID_ARTICLE})
    #FORMULAIRE_EDITER_ARTICLE{#ID_ARTICLE, #ID_RUBRIQUE, #URL_ARTICLE}
 ]

Reminder: the arguments for the autoriser function are: (faire, quoi, id, qui, options).

For more details, you are invited to view the full documentation about the functions available in inc/autoriser.php.

Author Mark Published : Updated : 23/07/23

Translations : عربي, català, English, Español, français, Nederlands