autoriser

The "autoriser" pipeline is a special one. It is simply used to load the authorisation functions the first time that the autoriser() function is called. This pipeline neither accepts arguments nor returns output.

pipeline('autoriser');

With this pipeline, a plugin can declare its own special authorisations, regrouped in a file named "PluginPrefix_autorisations.php" and declare them in the plugin.xml file as in this example:

<pipeline>
	<nom>autoriser</nom>
	<inclure>prefixePlugin_autorisations.php</inclure>
</pipeline>

In addition to authorisation functions, the file must contain the function called by all of the pipelines ("PluginPrefix_PipelineName()") but it has nothing to execute, e.g.:

function prefixePlugin_autoriser(){}

Example

The "forum" plugin declares several new authorisations. Its plugin.xml file contains:

<pipeline>
	<nom>autoriser</nom>
	<inclure>forum_autoriser.php</inclure>
</pipeline>

And the file which is called "forum_autoriser.php" contains:

// declare the pipeline function
function forum_autoriser(){}

function autoriser_forum_interne_suivi_bouton_dist($faire, $type, $id, $qui, $opt) {
	return true;
}

function autoriser_forum_reactions_bouton_dist(($faire, $type, $id, $qui, $opt) {
	return autoriser('publierdans', 'rubrique', _request('id_rubrique'));
}

// Moderate the forum?
// = modify the corresponding object (if there is a forum for this object)
// = default rights else (full admin for full moderation rights)
function autoriser_modererforum_dist($faire, $type, $id, $qui, $opt) {
	return autoriser('modifier', $type, $id, $qui, $opt);
}

// Modify a forum ?  never !
function autoriser_forum_modifier_dist($faire, $type, $id, $qui, $opt) {
	return false;
}
...

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français