From b563dff10a60e08ad270dc78404102f082abf184 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 30 Jul 2012 12:56:01 +0000 Subject: [PATCH] Record the app that is registering a call to use later with OAuth --- lib/api.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/api.php b/lib/api.php index c61f50c1bc..46f58debdc 100644 --- a/lib/api.php +++ b/lib/api.php @@ -36,15 +36,16 @@ class OC_API { * @param string $method the http method * @param string $url the url to match * @param callable $action the function to run + * @param string $app the id of the app registering the call */ - public static function register($method, $url, $action){ + public static function register($method, $url, $action, $app){ $name = strtolower($method).$url; if(!isset(self::$actions[$name])){ OC_Router::create($name, $url.'.{format}') ->action('OC_API', 'call'); self::$actions[$name] = array(); } - self::$actions[$name][] = $action; + self::$actions[$name][] = array('app' => $app, 'action' => $action); } /** @@ -68,8 +69,8 @@ class OC_API { $response = array(); // Loop through registered actions foreach(self::$actions[$name] as $action){ - if(is_callable($action)){ - $action_response = call_user_func($action, $parameters); + if(is_callable($action['action'])){ + $action_response = call_user_func($action['action'], $parameters); if(is_array($action_response)){ // Merge with previous $response = array_merge($response, $action_response);