diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index ee0ab52ed45891c250e15003ebcf2925bb2e650a..24338da8b031349cfe2d066951eae52a5107f5ee 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -4,6 +4,10 @@ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); // fix when '<?xml' isn't on the very first line if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); +/** + * Increased whenever the API is changed + */ +define('DOKU_XMLRPC_API_VERSION',1); require_once(DOKU_INC.'inc/init.php'); require_once(DOKU_INC.'inc/common.php'); @@ -32,6 +36,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $this->IXR_IntrospectionServer(); /* DokuWiki's own methods */ + $this->addCallback( + 'dokuwiki.getXMLRPCAPIVersion', + 'this:getAPIVersion', + array('integer'), + 'Returns the XMLRPC API version.' + ); + $this->addCallback( 'dokuwiki.getVersion', 'getVersion', @@ -39,6 +50,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'Returns the running DokuWiki version.' ); + $this->addCallback( + 'dokuwiki.login', + 'this:login', + array('integer','string','string'), + 'Tries to login with the given credentials and sets auth cookies.' + ); + $this->addCallback( 'dokuwiki.getPagelist', 'this:readNamespace', @@ -825,6 +843,21 @@ dbglog($data); ); } + function getAPIVersion(){ + return DOKU_XMLRPC_API_VERSION; + } + + function login($user,$pass){ + global $conf; + global $auth; + if(!$conf['useacl']) return 0; + if(!$auth) return 0; + if($auth->canDo('external')){ + return $auth->trustExternal($user,$pass,false); + }else{ + return auth_login($user,$pass,false,true); + } + } } $server = new dokuwiki_xmlrpc_server();