Creating or overloading the authorisations

To create an authorisation, you only need to create the supporting functions.

  1. function autoriser_documentation_troller_dist($faire, $type, $id, $qui, $opt) {
  2. return false; // no trolls permitted! and no exceptions!
  3. }


Declaring this function makes it possible to use the autoriser('troller','documentation') function or the #AUTORISER{troller, documentation} tag.

New functions, but not everywhere!

The autoriser() function, when first called, loads a pipeline with the same name. This call to the "autoriser" pipeline is used to load the authorisation files for a template directory or a plugin.


In a template:
In the config/mes_options.php file, we add the call to a function for our authorisations:

  1. <?php
  2. $GLOBALS['spip_pipeline']['autoriser'] .= "|my_authorisations";
  4. function my_authorisations(){
  5. include_spip('inc/my_authorisations');
  6. }
  7. ?>


So then when the autoriser pipeline is called, it loads the inc/my_authorisations.php file. We can then create this directory and file, which contains the intended authorisation functions in its squelettes/ directory.

In a plugin:
For a plugin, it’s almost exactly the same: you have to declare the use of the pipeline inside your plugin.xml :

  1. <pipeline>
  2. <nom>autoriser</nom>
  3. <inclure>inc/prefixePlugin_autoriser.php</inclure>
  4. </pipeline>


And create the file in question and absolutely make sure to add in the
pluginprefix_autoriser() function into the file that the pipeline calls.

  1. <?php
  2. if (!defined("_ECRIRE_INC_VERSION")) return;
  4. // function for the pipeline, nothing to do
  5. function pluginprefix_autoriser(){}
  7. // declarations of authorisations
  8. function autoriser_documentation_troller_dist($faire, $type, $id, $qui, $opt) {
  9. return false; // no trolls permitted! and no exceptions!
  10. }
  11. ?>


Author Mark Baber Published : Updated : 01/06/10

Translations : English, français