From 3cb4b39f357ab6389dcfd0aab594b43ae13ecb4c Mon Sep 17 00:00:00 2001
From: Ben Coburn <btcoburn@silicodon.net>
Date: Wed, 9 Aug 2006 21:45:01 +0200
Subject: [PATCH] Add AJAX_CALL_UNKNOWN event

Allows action plugins to support custom ajax calls.
The event data is the call name from $_POST['call'].
When handling a custom ajax call, remember to use
$event->preventDefault();
to avoid having the
'AJAX call <call> unknown!'
message appended to the output.

darcs-hash:20060809194501-05dcb-0082e4f2a83fc8657fc7cdcf32d44aac8d1a6b99.gz
---
 lib/exe/ajax.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index 0100f3130..9e89d6bd3 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -23,11 +23,18 @@ header('Content-Type: text/html; charset=utf-8');
 
 
 //call the requested function
+if (!isset($_POST['call'])) { return; }
 $call = 'ajax_'.$_POST['call'];
 if(function_exists($call)){
   $call();
 }else{
-  print "The called function '".htmlspecialchars($call)."' does not exist!";
+  $call = $_POST['call'];
+  $evt = new Doku_Event('AJAX_CALL_UNKNOWN', $call);
+  if ($evt->advise_before()) {
+    print "AJAX call '".htmlspecialchars($_POST['call'])."' unknown!\n";
+  }
+  $evt->advise_after();
+  unset($evt);
 }
 
 /**
-- 
GitLab