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.

  1. 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:

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

Download

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.:

  1. function prefixePlugin_autoriser(){}

Example

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

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

Download

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

  1. // declare the pipeline function
  2. function forum_autoriser(){}
  3.  
  4. function autoriser_forum_interne_suivi_bouton_dist($faire, $type, $id, $qui, $opt) {
  5. return true;
  6. }
  7.  
  8. function autoriser_forum_reactions_bouton_dist(($faire, $type, $id, $qui, $opt) {
  9. return autoriser('publierdans', 'rubrique', _request('id_rubrique'));
  10. }
  11.  
  12. // Moderate the forum?
  13. // = modify the corresponding object (if there is a forum for this object)
  14. // = default rights else (full admin for full moderation rights)
  15. function autoriser_modererforum_dist($faire, $type, $id, $qui, $opt) {
  16. return autoriser('modifier', $type, $id, $qui, $opt);
  17. }
  18.  
  19. // Modify a forum ? never !
  20. function autoriser_forum_modifier_dist($faire, $type, $id, $qui, $opt) {
  21. return false;
  22. }
  23. ...

Download

Author Mark Baber Published : Updated : 31/05/10

Translations : English, français