diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-02-20 19:46:24 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-02-20 19:46:24 +0100 |
commit | 28ec3c7605a29a1a0585f1c368645424c233118e (patch) | |
tree | 09187a6f1feffcf81c96e6f6dd8c386653a6ffa1 /lib/exe/xmlrpc.php | |
parent | 445840b637b0e1b7754d0236501962ad21d0b5ec (diff) | |
download | rpg-28ec3c7605a29a1a0585f1c368645424c233118e.tar.gz rpg-28ec3c7605a29a1a0585f1c368645424c233118e.tar.bz2 |
XMLRPC lock or unlock a whole bunch of pages
Ignore-this: d7bb2a80532df444e1ee8e60e3a7b653
darcs-hash:20090220184624-7ad00-2ed594f166e29bcc69d7ecbfe017251764981dd8.gz
Diffstat (limited to 'lib/exe/xmlrpc.php')
-rw-r--r-- | lib/exe/xmlrpc.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 189b84e32..351b039e9 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -53,6 +53,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'Return the current time at the wiki server.' ); + $this->addCallback( + 'dokuwiki.setLocks', + 'this:setLocks', + array('struct','struct'), + 'Lock or unlock pages.' + ); + /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */ $this->addCallback( 'wiki.getRPCVersionSupported', @@ -791,6 +798,47 @@ dbglog($data); return 2; } + + /** + * Locks or unlocks a given batch of pages + * + * Give an associative array with two keys: lock and unlock. Both should contain a + * list of pages to lock or unlock + * + * Returns an associative array with the keys locked, lockfail, unlocked and + * unlockfail, each containing lists of pages. + */ + function setLocks($set){ + $locked = array(); + $lockfail = array(); + $unlocked = array(); + $unlockfail = array(); + + foreach((array) $set['lock'] as $id){ + if(checklock($id)){ + $lockfail[] = $id; + }else{ + lock($id); + $locked[] = $id; + } + } + + foreach((array) $set['unlock'] as $id){ + if(unlock($id)){ + $unlocked[] = $id; + }else{ + $unlockfail[] = $id; + } + } + + return array( + 'locked' => $locked, + 'lockfail' => $lockfail, + 'unlocked' => $unlocked, + 'unlockfail' => $unlockfail, + ); + } + } $server = new dokuwiki_xmlrpc_server(); |