Creating or overloading the authorisations

To create an authorisation, you only need to create the supporting functions.
function autoriser_documentation_troller_dist($faire, $type, $id, $qui, $opt) {
	return false; // no trolls permitted! and no exceptions!
}
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.

Example

{{In a template:}} In the config/mes_options.php file, we add the call to a function for our authorisations:
<?php
$GLOBALS['spip_pipeline']['autoriser'] .= "|my_authorisations";
 
function my_authorisations(){
	include_spip('inc/my_authorisations');
}
?>
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 :
<pipeline>
	<nom>autoriser</nom>
	<inclure>inc/prefixePlugin_autoriser.php</inclure>
</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.
<?php
if (!defined("_ECRIRE_INC_VERSION")) return;
 
// function for the pipeline, nothing to do
function pluginprefix_autoriser(){}
 
// declarations of authorisations
function autoriser_documentation_troller_dist($faire, $type, $id, $qui, $opt) {
	return false; // no trolls permitted! and no exceptions!
}
?>

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

Translations : English, français, Nederlands