From f569fa25b6f85300760b50b6b9f3f6cdf04a39ab Mon Sep 17 00:00:00 2001
From: Fil <fil@rezo.net>
Date: Sat, 11 Nov 2006 17:03:42 +0000
Subject: [PATCH] amelioration des possibilites de surcharge de autoriser(),
 sans obliger a passer par charger_fonction()

---
 ecrire/inc/autoriser.php | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/ecrire/inc/autoriser.php b/ecrire/inc/autoriser.php
index 2bf5d33862..27e612935d 100644
--- a/ecrire/inc/autoriser.php
+++ b/ecrire/inc/autoriser.php
@@ -13,6 +13,18 @@
 if (!defined("_ECRIRE_INC_VERSION")) return;
 
 
+define ('_DEBUG_AUTORISER', false);
+
+// surcharge possible de autoriser(), sinon autoriser_dist()
+// http://doc.spip.org/@autoriser
+if (!function_exists('autoriser')) {
+	function autoriser() {
+		$args = func_get_args(); 
+		return call_user_func_array('autoriser_dist', $args);
+	}
+}
+
+
 // API pour une fonction generique d'autorisation :
 // $qui est : vide (on prend alors auteur_session)
 //            un id_auteur (on regarde dans la base)
@@ -24,9 +36,9 @@ if (!defined("_ECRIRE_INC_VERSION")) return;
 // (par exemple pour preciser si l'autorisation concerne tel ou tel champ)
 //
 // Seul le premier argument est obligatoire
-define ('_DEBUG_AUTORISER', false);
-// http://doc.spip.org/@autoriser
-function autoriser($faire, $type='', $id=0, $qui = NULL, $opt = NULL) {
+//
+// http://doc.spip.org/@autoriser_dist
+function autoriser_dist($faire, $type='', $id=0, $qui = NULL, $opt = NULL) {
 	static $restreint = array();
 
 	// Qui ? auteur_session ?
@@ -202,5 +214,4 @@ function autoriser_moderer_petition_dist($faire, $type, $id, $qui, $opt) {
 		autoriser('modifier', $type, $id, $qui, $opt);
 }
 
-
 ?>
-- 
GitLab