1b5284271SAndreas Gohr<?php 2b5284271SAndreas Gohr 3b5284271SAndreas Gohrnamespace dokuwiki\Remote; 4b5284271SAndreas Gohr 5b5284271SAndreas Gohruse dokuwiki\Utf8\PhpString; 615357ce4SAndreas Gohruse IXR\DataType\Base64; 7b5284271SAndreas Gohruse IXR\DataType\Date; 8b5284271SAndreas Gohr 9b5284271SAndreas Gohr/** 10b5284271SAndreas Gohr * Provides wrappers for the API calls as they existed in API Version 11 11b5284271SAndreas Gohr * 12b5284271SAndreas Gohr * No guarantees are made about the exact compatibility of the return values. 13b5284271SAndreas Gohr * 14b5284271SAndreas Gohr * @deprecated 15b5284271SAndreas Gohr */ 16b5284271SAndreas Gohrclass LegacyApiCore extends ApiCore 17b5284271SAndreas Gohr{ 18b5284271SAndreas Gohr /** @inheritdoc */ 19b5284271SAndreas Gohr public function getMethods() 20b5284271SAndreas Gohr { 21b5284271SAndreas Gohr $methods = parent::getMethods(); 22b5284271SAndreas Gohr 23b5284271SAndreas Gohr return array_merge( 24b5284271SAndreas Gohr $methods, 25b5284271SAndreas Gohr [ 26b5284271SAndreas Gohr 'dokuwiki.getVersion' => new ApiCall([$this, 'legacyGetVersion'], 'legacy'), 27b5284271SAndreas Gohr 'dokuwiki.login' => (new ApiCall([$this, 'legacyLogin'], 'legacy'))->setPublic(), 28b5284271SAndreas Gohr 'dokuwiki.logoff' => new ApiCall([$this, 'legacyLogoff'], 'legacy'), 29b5284271SAndreas Gohr 'dokuwiki.getPagelist' => new ApiCall([$this, 'legacyGetPagelist'], 'legacy'), 30b5284271SAndreas Gohr 'dokuwiki.search' => new ApiCall([$this, 'legacySearch'], 'legacy'), 31b5284271SAndreas Gohr 'dokuwiki.getTime' => new ApiCall([$this, 'legacyGetTime'], 'legacy'), 32b5284271SAndreas Gohr 'dokuwiki.setLocks' => new ApiCall([$this, 'legacySetLocks'], 'legacy'), 33b5284271SAndreas Gohr 'dokuwiki.getTitle' => (new ApiCall([$this, 'legacyGetTitle'], 'legacy'))->setPublic(), 34b5284271SAndreas Gohr 'dokuwiki.appendPage' => new ApiCall([$this, 'legacyAppendPage'], 'legacy'), 35b5284271SAndreas Gohr 'dokuwiki.createUser' => new ApiCall([$this, 'legacyCreateUser'], 'legacy'), 36b5284271SAndreas Gohr 'dokuwiki.deleteUsers' => new ApiCall([$this, 'legacyDeleteUsers'], 'legacy'), 37b5284271SAndreas Gohr 'wiki.getPage' => new ApiCall([$this, 'legacyGetPage'], 'legacy'), 38b5284271SAndreas Gohr 'wiki.getPageVersion' => new ApiCall([$this, 'legacyGetPageVersion'], 'legacy'), 39b5284271SAndreas Gohr 'wiki.getPageHTML' => new ApiCall([$this, 'legacyGetPageHTML'], 'legacy'), 40b5284271SAndreas Gohr 'wiki.getPageHTMLVersion' => new ApiCall([$this, 'legacyGetPageHTMLVersion'], 'legacy'), 41b5284271SAndreas Gohr 'wiki.getAllPages' => new ApiCall([$this, 'legacyGetAllPages'], 'legacy'), 42b5284271SAndreas Gohr 'wiki.getAttachments' => new ApiCall([$this, 'legacyGetAttachments'], 'legacy'), 43b5284271SAndreas Gohr 'wiki.getBackLinks' => new ApiCall([$this, 'legacyGetBackLinks'], 'legacy'), 44b5284271SAndreas Gohr 'wiki.getPageInfo' => new ApiCall([$this, 'legacyGetPageInfo'], 'legacy'), 45b5284271SAndreas Gohr 'wiki.getPageInfoVersion' => new ApiCall([$this, 'legacyGetPageInfoVersion'], 'legacy'), 46b5284271SAndreas Gohr 'wiki.getPageVersions' => new ApiCall([$this, 'legacyGetPageVersions'], 'legacy'), 47b5284271SAndreas Gohr 'wiki.putPage' => new ApiCall([$this, 'legacyPutPage'], 'legacy'), 48b5284271SAndreas Gohr 'wiki.listLinks' => new ApiCall([$this, 'legacyListLinks'], 'legacy'), 49b5284271SAndreas Gohr 'wiki.getRecentChanges' => new ApiCall([$this, 'legacyGetRecentChanges'], 'legacy'), 50b5284271SAndreas Gohr 'wiki.getRecentMediaChanges' => new ApiCall([$this, 'legacyGetRecentMediaChanges'], 'legacy'), 51b5284271SAndreas Gohr 'wiki.aclCheck' => new ApiCall([$this, 'legacyAclCheck'], 'legacy'), 52b5284271SAndreas Gohr 'wiki.putAttachment' => new ApiCall([$this, 'legacyPutAttachment'], 'legacy'), 53b5284271SAndreas Gohr 'wiki.deleteAttachment' => new ApiCall([$this, 'legacyDeleteAttachment'], 'legacy'), 54b5284271SAndreas Gohr 'wiki.getAttachment' => new ApiCall([$this, 'legacyGetAttachment'], 'legacy'), 55b5284271SAndreas Gohr 'wiki.getAttachmentInfo' => new ApiCall([$this, 'legacyGetAttachmentInfo'], 'legacy'), 56b5284271SAndreas Gohr 'dokuwiki.getXMLRPCAPIVersion' => (new ApiCall([$this, 'legacyGetXMLRPCAPIVersion'], 'legacy')) 57b5284271SAndreas Gohr ->setPublic(), 58b5284271SAndreas Gohr 'wiki.getRPCVersionSupported' => (new ApiCall([$this, 'legacyGetRPCVersionSupported'], 'legacy')) 59b5284271SAndreas Gohr ->setPublic(), 60b5284271SAndreas Gohr ] 61b5284271SAndreas Gohr ); 62b5284271SAndreas Gohr } 63b5284271SAndreas Gohr 64b5284271SAndreas Gohr /** 65b5284271SAndreas Gohr * This returns a XMLRPC object that will not work for the new JSONRPC API 66b5284271SAndreas Gohr * 67b5284271SAndreas Gohr * @param int $ts 68b5284271SAndreas Gohr * @return Date 69b5284271SAndreas Gohr */ 70b5284271SAndreas Gohr protected function toDate($ts) 71b5284271SAndreas Gohr { 72b5284271SAndreas Gohr return new Date($ts); 73b5284271SAndreas Gohr } 74b5284271SAndreas Gohr 75b5284271SAndreas Gohr 76b5284271SAndreas Gohr /** 77b5284271SAndreas Gohr * @deprecated use core.getWikiVersion instead 78b5284271SAndreas Gohr */ 79b5284271SAndreas Gohr public function legacyGetVersion() 80b5284271SAndreas Gohr { 81b5284271SAndreas Gohr return getVersion(); 82b5284271SAndreas Gohr } 83b5284271SAndreas Gohr 84b5284271SAndreas Gohr /** 85b5284271SAndreas Gohr * @deprecated use core.getWikiTime instead 86b5284271SAndreas Gohr */ 87b5284271SAndreas Gohr public function legacyGetTime() 88b5284271SAndreas Gohr { 89b5284271SAndreas Gohr return $this->getWikiTime(); 90b5284271SAndreas Gohr } 91b5284271SAndreas Gohr 92b5284271SAndreas Gohr 93b5284271SAndreas Gohr /** 94b5284271SAndreas Gohr * @deprecated use core.getPage instead 95b5284271SAndreas Gohr */ 96b5284271SAndreas Gohr public function legacyGetPage($id) 97b5284271SAndreas Gohr { 98079b7b26SAndreas Gohr try { 99b5284271SAndreas Gohr return $this->getPage($id); 100079b7b26SAndreas Gohr } catch (RemoteException $e) { 101079b7b26SAndreas Gohr if ($e->getCode() === 121) { 102079b7b26SAndreas Gohr return ''; 103079b7b26SAndreas Gohr } 104079b7b26SAndreas Gohr throw $e; 105079b7b26SAndreas Gohr } 106b5284271SAndreas Gohr } 107b5284271SAndreas Gohr 108b5284271SAndreas Gohr /** 109b5284271SAndreas Gohr * @deprecated use core.getPage instead 110b5284271SAndreas Gohr */ 111b5284271SAndreas Gohr public function legacyGetPageVersion($id, $rev = '') 112b5284271SAndreas Gohr { 113079b7b26SAndreas Gohr try { 114b5284271SAndreas Gohr return $this->getPage($id, $rev); 115079b7b26SAndreas Gohr } catch (RemoteException $e) { 116079b7b26SAndreas Gohr if ($e->getCode() === 121) { 117079b7b26SAndreas Gohr return ''; 118079b7b26SAndreas Gohr } 119079b7b26SAndreas Gohr throw $e; 120079b7b26SAndreas Gohr } 121b5284271SAndreas Gohr } 122b5284271SAndreas Gohr 123b5284271SAndreas Gohr /** 124b5284271SAndreas Gohr * @deprecated use core.getMedia instead 125b5284271SAndreas Gohr */ 126b5284271SAndreas Gohr public function legacyGetAttachment($id) 127b5284271SAndreas Gohr { 12815357ce4SAndreas Gohr return new Base64(base64_decode($this->getMedia($id))); 129b5284271SAndreas Gohr } 130b5284271SAndreas Gohr 131b5284271SAndreas Gohr /** 132b5284271SAndreas Gohr * @deprecated use core.getMediaInfo instead 133b5284271SAndreas Gohr */ 134b5284271SAndreas Gohr public function legacygetAttachmentInfo($id) 135b5284271SAndreas Gohr { 136b5284271SAndreas Gohr $info = $this->getMediaInfo($id); 137b5284271SAndreas Gohr return [ 138b5284271SAndreas Gohr 'lastModified' => $this->toDate($info->revision), 139b5284271SAndreas Gohr 'size' => $info->size, 140b5284271SAndreas Gohr ]; 141b5284271SAndreas Gohr } 142b5284271SAndreas Gohr 143b5284271SAndreas Gohr /** 144b5284271SAndreas Gohr * @deprecated use core.getPageHTML instead 145b5284271SAndreas Gohr */ 146b5284271SAndreas Gohr public function legacyGetPageHTML($id) 147b5284271SAndreas Gohr { 148079b7b26SAndreas Gohr try { 149b5284271SAndreas Gohr return $this->getPageHTML($id); 150079b7b26SAndreas Gohr } catch (RemoteException $e) { 151079b7b26SAndreas Gohr if ($e->getCode() === 121) { 152079b7b26SAndreas Gohr return ''; 153079b7b26SAndreas Gohr } 154079b7b26SAndreas Gohr throw $e; 155079b7b26SAndreas Gohr } 156b5284271SAndreas Gohr } 157b5284271SAndreas Gohr 158b5284271SAndreas Gohr /** 159b5284271SAndreas Gohr * @deprecated use core.getPageHTML instead 160b5284271SAndreas Gohr */ 161b5284271SAndreas Gohr public function legacyGetPageHTMLVersion($id, $rev = '') 162b5284271SAndreas Gohr { 163079b7b26SAndreas Gohr try { 164b5284271SAndreas Gohr return $this->getPageHTML($id, (int)$rev); 165079b7b26SAndreas Gohr } catch (RemoteException $e) { 166079b7b26SAndreas Gohr if ($e->getCode() === 121) { 167079b7b26SAndreas Gohr return ''; 168079b7b26SAndreas Gohr } 169079b7b26SAndreas Gohr throw $e; 170079b7b26SAndreas Gohr } 171b5284271SAndreas Gohr } 172b5284271SAndreas Gohr 173b5284271SAndreas Gohr /** 174b5284271SAndreas Gohr * @deprecated use core.listPages instead 175b5284271SAndreas Gohr */ 176b5284271SAndreas Gohr public function legacyGetAllPages() 177b5284271SAndreas Gohr { 178b5284271SAndreas Gohr $pages = $this->listPages('', 0); 179b5284271SAndreas Gohr 180b5284271SAndreas Gohr $result = []; 181b5284271SAndreas Gohr foreach ($pages as $page) { 182b5284271SAndreas Gohr $result[] = [ 183b5284271SAndreas Gohr 'id' => $page->id, 184b5284271SAndreas Gohr 'perms' => $page->permission, 185b5284271SAndreas Gohr 'size' => $page->size, 186b5284271SAndreas Gohr 'lastModified' => $this->toDate($page->revision), 187b5284271SAndreas Gohr ]; 188b5284271SAndreas Gohr } 189b5284271SAndreas Gohr return $result; 190b5284271SAndreas Gohr } 191b5284271SAndreas Gohr 192b5284271SAndreas Gohr /** 193b5284271SAndreas Gohr * @deprecated use core.listPages instead 194b5284271SAndreas Gohr */ 195b5284271SAndreas Gohr public function legacyGetPagelist($ns, $opts = []) 196b5284271SAndreas Gohr { 197b5284271SAndreas Gohr $data = $this->listPages($ns, $opts['depth'] ?? 0, $opts['hash'] ?? false); 198b5284271SAndreas Gohr $result = []; 199b5284271SAndreas Gohr 200b5284271SAndreas Gohr foreach ($data as $page) { 201b5284271SAndreas Gohr $result[] = [ 202b5284271SAndreas Gohr 'id' => $page->id, 203b5284271SAndreas Gohr 'perms' => $page->permission, 204b5284271SAndreas Gohr 'size' => $page->size, 205b5284271SAndreas Gohr 'rev' => $page->revision, 2061418a776SAndreas Gohr 'mtime' => $page->revision, 207b5284271SAndreas Gohr 'hash' => $page->hash, 208b5284271SAndreas Gohr 209b5284271SAndreas Gohr ]; 210b5284271SAndreas Gohr } 211b5284271SAndreas Gohr 212b5284271SAndreas Gohr return $result; 213b5284271SAndreas Gohr } 214b5284271SAndreas Gohr 215b5284271SAndreas Gohr /** 216b5284271SAndreas Gohr * @deprecated use core.searchPages instead 217b5284271SAndreas Gohr */ 218b5284271SAndreas Gohr public function legacySearch($query) 219b5284271SAndreas Gohr { 220b5284271SAndreas Gohr $this->searchPages($query); 221b5284271SAndreas Gohr $pages = []; 222b5284271SAndreas Gohr 223b5284271SAndreas Gohr foreach ($this->searchPages($query) as $page) { 224b5284271SAndreas Gohr $pages[] = [ 225b5284271SAndreas Gohr 'id' => $page->id, 226b5284271SAndreas Gohr 'score' => $page->score, 227b5284271SAndreas Gohr 'rev' => $page->revision, 228b5284271SAndreas Gohr 'lastModified' => $this->toDate($page->revision), 229b5284271SAndreas Gohr 'size' => $page->size, 230b5284271SAndreas Gohr 'snippet' => $page->snippet, 231b5284271SAndreas Gohr 'title' => $page->title 232b5284271SAndreas Gohr ]; 233b5284271SAndreas Gohr } 234b5284271SAndreas Gohr 235b5284271SAndreas Gohr return $pages; 236b5284271SAndreas Gohr } 237b5284271SAndreas Gohr 238b5284271SAndreas Gohr /** 239b5284271SAndreas Gohr * @deprecated use core.getWikiTitle instead 240b5284271SAndreas Gohr */ 241b5284271SAndreas Gohr public function legacyGetTitle() 242b5284271SAndreas Gohr { 243b5284271SAndreas Gohr return $this->getWikiTitle(); 244b5284271SAndreas Gohr } 245b5284271SAndreas Gohr 246b5284271SAndreas Gohr /** 247b5284271SAndreas Gohr * @deprecated use core.listMedia instead 248b5284271SAndreas Gohr */ 249b5284271SAndreas Gohr public function legacyGetAttachments($ns, $options = []) 250b5284271SAndreas Gohr { 251b5284271SAndreas Gohr $files = $this->listMedia($ns, $options['pattern'] ?? '', $options['depth'] ?? 0, $options['hash'] ?? false); 252b5284271SAndreas Gohr $result = []; 253b5284271SAndreas Gohr foreach ($files as $file) { 254b5284271SAndreas Gohr $result[] = [ 255b5284271SAndreas Gohr 'id' => $file->id, 256b5284271SAndreas Gohr 'perms' => $file->permission, 257b5284271SAndreas Gohr 'size' => $file->size, 258b5284271SAndreas Gohr 'rev' => $file->revision, 259b5284271SAndreas Gohr 'lastModified' => $this->toDate($file->revision), 260b5284271SAndreas Gohr 'mtime' => $this->toDate($file->revision), 261b5284271SAndreas Gohr 'hash' => $file->hash, 262b5284271SAndreas Gohr 'file' => PhpString::basename(mediaFN($file->id)), 263b5284271SAndreas Gohr 'writable' => is_writable(mediaFN($file->id)), 264b5284271SAndreas Gohr 'isimg' => $file->isimage, 265b5284271SAndreas Gohr 266b5284271SAndreas Gohr ]; 267b5284271SAndreas Gohr } 268b5284271SAndreas Gohr return $result; 269b5284271SAndreas Gohr } 270b5284271SAndreas Gohr 271b5284271SAndreas Gohr /** 272b5284271SAndreas Gohr * @deprecated use core.getPageBackLinks instead 273b5284271SAndreas Gohr */ 274b5284271SAndreas Gohr public function legacyGetBackLinks($id) 275b5284271SAndreas Gohr { 276b5284271SAndreas Gohr return $this->getPageBackLinks($id); 277b5284271SAndreas Gohr } 278b5284271SAndreas Gohr 279b5284271SAndreas Gohr /** 280b5284271SAndreas Gohr * @deprecated use core.getPageInfo instead 281b5284271SAndreas Gohr */ 282b5284271SAndreas Gohr public function legacyGetPageInfo($id) 283b5284271SAndreas Gohr { 284b5284271SAndreas Gohr $info = $this->getPageInfo($id, 0); 285b5284271SAndreas Gohr return [ 286b5284271SAndreas Gohr 'name' => $info->id, 287b5284271SAndreas Gohr 'lastModified' => $this->toDate($info->revision), 288b5284271SAndreas Gohr 'author' => $info->author, 289b5284271SAndreas Gohr 'version' => $info->revision, 290b5284271SAndreas Gohr ]; 291b5284271SAndreas Gohr } 292b5284271SAndreas Gohr 293b5284271SAndreas Gohr /** 294b5284271SAndreas Gohr * @deprecated use core.getPageInfo instead 295b5284271SAndreas Gohr */ 296b5284271SAndreas Gohr public function legacyGetPageInfoVersion($id, $rev = '') 297b5284271SAndreas Gohr { 298b5284271SAndreas Gohr $info = $this->getPageInfo($id, $rev); 299b5284271SAndreas Gohr return [ 300b5284271SAndreas Gohr 'name' => $info->id, 301b5284271SAndreas Gohr 'lastModified' => $this->toDate($info->revision), 302b5284271SAndreas Gohr 'author' => $info->author, 303b5284271SAndreas Gohr 'version' => $info->revision, 304b5284271SAndreas Gohr ]; 305b5284271SAndreas Gohr } 306b5284271SAndreas Gohr 307b5284271SAndreas Gohr /** 308b5284271SAndreas Gohr * @deprecated use core.savePage instead 309b5284271SAndreas Gohr */ 310b5284271SAndreas Gohr public function legacyPutPage($id, $text, $params = []) 311b5284271SAndreas Gohr { 312b5284271SAndreas Gohr return $this->savePage($id, $text, $params['sum'] ?? '', $params['minor'] ?? false); 313b5284271SAndreas Gohr } 314b5284271SAndreas Gohr 315b5284271SAndreas Gohr /** 316b5284271SAndreas Gohr * @deprecated use core.appendPage instead 317b5284271SAndreas Gohr */ 318b5284271SAndreas Gohr public function legacyAppendPage($id, $text, $params = []) 319b5284271SAndreas Gohr { 320*91c051b5SAndreas Gohr $ok = $this->appendPage($id, $text, $params['sum'] ?? '', $params['minor'] ?? false); 321b5284271SAndreas Gohr if ($ok === true) { 322b5284271SAndreas Gohr return cleanID($id); 323b5284271SAndreas Gohr } else { 324b5284271SAndreas Gohr return $ok; 325b5284271SAndreas Gohr } 326b5284271SAndreas Gohr } 327b5284271SAndreas Gohr 328b5284271SAndreas Gohr /** 329b5284271SAndreas Gohr * @deprecated use plugin.usermanager.createUser instead 330b5284271SAndreas Gohr */ 331b5284271SAndreas Gohr public function legacyCreateUser($userStruct) 332b5284271SAndreas Gohr { 333b5284271SAndreas Gohr if (!auth_isadmin()) { 334b5284271SAndreas Gohr throw new AccessDeniedException('Only admins are allowed to create users', 114); 335b5284271SAndreas Gohr } 336b5284271SAndreas Gohr 337b5284271SAndreas Gohr /** @var AuthPlugin $auth */ 338b5284271SAndreas Gohr global $auth; 339b5284271SAndreas Gohr 340b5284271SAndreas Gohr if (!$auth->canDo('addUser')) { 341b5284271SAndreas Gohr throw new AccessDeniedException( 342b5284271SAndreas Gohr sprintf('Authentication backend %s can\'t do addUser', $auth->getPluginName()), 343b5284271SAndreas Gohr 114 344b5284271SAndreas Gohr ); 345b5284271SAndreas Gohr } 346b5284271SAndreas Gohr 347b5284271SAndreas Gohr $user = trim($auth->cleanUser($userStruct['user'] ?? '')); 348b5284271SAndreas Gohr $password = $userStruct['password'] ?? ''; 349b5284271SAndreas Gohr $name = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $userStruct['name'] ?? '')); 350b5284271SAndreas Gohr $mail = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $userStruct['mail'] ?? '')); 351b5284271SAndreas Gohr $groups = $userStruct['groups'] ?? []; 352b5284271SAndreas Gohr 353b5284271SAndreas Gohr $notify = (bool)$userStruct['notify'] ?? false; 354b5284271SAndreas Gohr 355b5284271SAndreas Gohr if ($user === '') throw new RemoteException('empty or invalid user', 401); 356b5284271SAndreas Gohr if ($name === '') throw new RemoteException('empty or invalid user name', 402); 357b5284271SAndreas Gohr if (!mail_isvalid($mail)) throw new RemoteException('empty or invalid mail address', 403); 358b5284271SAndreas Gohr 359b5284271SAndreas Gohr if ((string)$password === '') { 360b5284271SAndreas Gohr $password = auth_pwgen($user); 361b5284271SAndreas Gohr } 362b5284271SAndreas Gohr 363b5284271SAndreas Gohr if (!is_array($groups) || $groups === []) { 364b5284271SAndreas Gohr $groups = null; 365b5284271SAndreas Gohr } 366b5284271SAndreas Gohr 367b5284271SAndreas Gohr $ok = $auth->triggerUserMod('create', [$user, $password, $name, $mail, $groups]); 368b5284271SAndreas Gohr 369b5284271SAndreas Gohr if ($ok !== false && $ok !== null) { 370b5284271SAndreas Gohr $ok = true; 371b5284271SAndreas Gohr } 372b5284271SAndreas Gohr 373b5284271SAndreas Gohr if ($ok) { 374b5284271SAndreas Gohr if ($notify) { 375b5284271SAndreas Gohr auth_sendPassword($user, $password); 376b5284271SAndreas Gohr } 377b5284271SAndreas Gohr } 378b5284271SAndreas Gohr 379b5284271SAndreas Gohr return $ok; 380b5284271SAndreas Gohr } 381b5284271SAndreas Gohr 382b5284271SAndreas Gohr 383b5284271SAndreas Gohr /** 384b5284271SAndreas Gohr * @deprecated use plugin.usermanager.deleteUser instead 385b5284271SAndreas Gohr */ 386b5284271SAndreas Gohr public function legacyDeleteUsers($usernames) 387b5284271SAndreas Gohr { 388b5284271SAndreas Gohr if (!auth_isadmin()) { 389b5284271SAndreas Gohr throw new AccessDeniedException('Only admins are allowed to delete users', 114); 390b5284271SAndreas Gohr } 391b5284271SAndreas Gohr /** @var AuthPlugin $auth */ 392b5284271SAndreas Gohr global $auth; 393b5284271SAndreas Gohr return (bool)$auth->triggerUserMod('delete', [$usernames]); 394b5284271SAndreas Gohr } 395b5284271SAndreas Gohr 396b5284271SAndreas Gohr /** 397b5284271SAndreas Gohr * @deprecated use core.saveMedia instead 398b5284271SAndreas Gohr */ 399b5284271SAndreas Gohr public function legacyPutAttachment($id, $file, $params = []) 400b5284271SAndreas Gohr { 40115357ce4SAndreas Gohr $ok = $this->saveMedia($id, base64_encode($file), $params['ow'] ?? false); 402b5284271SAndreas Gohr if ($ok === true) { 403b5284271SAndreas Gohr return cleanID($id); 404b5284271SAndreas Gohr } else { 405b5284271SAndreas Gohr return $ok; 406b5284271SAndreas Gohr } 407b5284271SAndreas Gohr } 408b5284271SAndreas Gohr 409b5284271SAndreas Gohr /** 410b5284271SAndreas Gohr * @deprecated use core.deleteMedia instead 411b5284271SAndreas Gohr */ 412b5284271SAndreas Gohr public function legacyDeleteAttachment($id) 413b5284271SAndreas Gohr { 414b5284271SAndreas Gohr $ok = $this->deleteMedia($id); 415b5284271SAndreas Gohr if ($ok === true) { 416b5284271SAndreas Gohr return 0; 417b5284271SAndreas Gohr } else { 418b5284271SAndreas Gohr return $ok; 419b5284271SAndreas Gohr } 420b5284271SAndreas Gohr } 421b5284271SAndreas Gohr 422b5284271SAndreas Gohr /** 423b5284271SAndreas Gohr * @deprecated use core.aclCheck instead 424b5284271SAndreas Gohr */ 425b5284271SAndreas Gohr public function legacyAclCheck($id, $user = null, $groups = null) 426b5284271SAndreas Gohr { 427b5284271SAndreas Gohr return $this->aclCheck($id, (string)$user, (string)$groups); 428b5284271SAndreas Gohr } 429b5284271SAndreas Gohr 430b5284271SAndreas Gohr /** 431b5284271SAndreas Gohr * @deprecated use core.listLinks instead 432b5284271SAndreas Gohr */ 433b5284271SAndreas Gohr public function legacyListLinks($id) 434b5284271SAndreas Gohr { 435b5284271SAndreas Gohr $links = $this->getPageLinks($id); 436b5284271SAndreas Gohr $result = []; 437b5284271SAndreas Gohr foreach ($links as $link) { 438b5284271SAndreas Gohr $result[] = [ 439b5284271SAndreas Gohr 'type' => $link['type'], 440b5284271SAndreas Gohr 'page' => $link['page'], 441b5284271SAndreas Gohr 'href' => $link['href'], 442b5284271SAndreas Gohr ]; 443b5284271SAndreas Gohr } 444b5284271SAndreas Gohr return $result; 445b5284271SAndreas Gohr } 446b5284271SAndreas Gohr 447b5284271SAndreas Gohr /** 448b5284271SAndreas Gohr * @deprecated use core.getRecentChanges instead 449b5284271SAndreas Gohr */ 450b5284271SAndreas Gohr public function legacyGetRecentChanges($timestamp) 451b5284271SAndreas Gohr { 452b5284271SAndreas Gohr $recents = $this->getRecentPageChanges($timestamp); 453b5284271SAndreas Gohr $result = []; 454b5284271SAndreas Gohr foreach ($recents as $recent) { 455b5284271SAndreas Gohr $result[] = [ 456b5284271SAndreas Gohr 'name' => $recent->id, 457b5284271SAndreas Gohr 'lastModified' => $this->toDate($recent->revision), 458b5284271SAndreas Gohr 'author' => $recent->author, 459b5284271SAndreas Gohr 'version' => $recent->revision, 460b5284271SAndreas Gohr 'perms' => auth_quickaclcheck($recent->id), 461b5284271SAndreas Gohr 'size' => @filesize(wikiFN($recent->id)), 462b5284271SAndreas Gohr ]; 463b5284271SAndreas Gohr } 464b5284271SAndreas Gohr return $result; 465b5284271SAndreas Gohr } 466b5284271SAndreas Gohr 467b5284271SAndreas Gohr /** 468b5284271SAndreas Gohr * @deprecated use core.getRecentMediaChanges instead 469b5284271SAndreas Gohr */ 470b5284271SAndreas Gohr public function legacyGetRecentMediaChanges($timestamp) 471b5284271SAndreas Gohr { 472b5284271SAndreas Gohr $recents = $this->getRecentMediaChanges($timestamp); 473b5284271SAndreas Gohr $result = []; 474b5284271SAndreas Gohr foreach ($recents as $recent) { 475b5284271SAndreas Gohr $result[] = [ 476b5284271SAndreas Gohr 'name' => $recent->id, 477b5284271SAndreas Gohr 'lastModified' => $this->toDate($recent->revision), 478b5284271SAndreas Gohr 'author' => $recent->author, 479b5284271SAndreas Gohr 'version' => $recent->revision, 480b5284271SAndreas Gohr 'perms' => auth_quickaclcheck($recent->id), 481b5284271SAndreas Gohr 'size' => @filesize(mediaFN($recent->id)), 482b5284271SAndreas Gohr ]; 483b5284271SAndreas Gohr } 484b5284271SAndreas Gohr return $result; 485b5284271SAndreas Gohr } 486b5284271SAndreas Gohr 487b5284271SAndreas Gohr /** 488b5284271SAndreas Gohr * @deprecated use core.getPageHistory instead 489b5284271SAndreas Gohr */ 490b5284271SAndreas Gohr public function legacyGetPageVersions($id, $first = 0) 491b5284271SAndreas Gohr { 492b5284271SAndreas Gohr $revisions = $this->getPageHistory($id, $first); 493b5284271SAndreas Gohr $result = []; 494b5284271SAndreas Gohr 495b5284271SAndreas Gohr foreach ($revisions as $revision) { 496b5284271SAndreas Gohr $result[] = [ 497b5284271SAndreas Gohr 'user' => $revision->author, 498b5284271SAndreas Gohr 'ip' => $revision->ip, 499b5284271SAndreas Gohr 'type' => $revision->type, 500b5284271SAndreas Gohr 'sum' => $revision->summary, 501b5284271SAndreas Gohr 'modified' => $this->toDate($revision->revision), 502b5284271SAndreas Gohr 'version' => $revision->revision, 503b5284271SAndreas Gohr ]; 504b5284271SAndreas Gohr } 505b5284271SAndreas Gohr return $result; 506b5284271SAndreas Gohr } 507b5284271SAndreas Gohr 508b5284271SAndreas Gohr /** 509b5284271SAndreas Gohr * @deprecated Wiki RPC spec is no longer supported 510b5284271SAndreas Gohr */ 511b5284271SAndreas Gohr public function legacyGetRPCVersionSupported() 512b5284271SAndreas Gohr { 513b5284271SAndreas Gohr return 2; 514b5284271SAndreas Gohr } 515b5284271SAndreas Gohr 516b5284271SAndreas Gohr /** 517b5284271SAndreas Gohr * @deprecated use core.lockPages and core.unlockPages instead 518b5284271SAndreas Gohr */ 519b5284271SAndreas Gohr public function legacySetLocks($set) 520b5284271SAndreas Gohr { 521b5284271SAndreas Gohr $locked = $this->lockPages($set['lock']); 522b5284271SAndreas Gohr $lockfail = array_diff($set['lock'], $locked); 523b5284271SAndreas Gohr 524b5284271SAndreas Gohr $unlocked = $this->unlockPages($set['unlock']); 525b5284271SAndreas Gohr $unlockfail = array_diff($set['unlock'], $unlocked); 526b5284271SAndreas Gohr 527b5284271SAndreas Gohr return [ 528b5284271SAndreas Gohr 'locked' => $locked, 529b5284271SAndreas Gohr 'lockfail' => $lockfail, 530b5284271SAndreas Gohr 'unlocked' => $unlocked, 531b5284271SAndreas Gohr 'unlockfail' => $unlockfail 532b5284271SAndreas Gohr ]; 533b5284271SAndreas Gohr } 534b5284271SAndreas Gohr 535b5284271SAndreas Gohr /** 536b5284271SAndreas Gohr * @deprecated use core.getAPIVersion instead 537b5284271SAndreas Gohr */ 538b5284271SAndreas Gohr public function legacyGetXMLRPCAPIVersion() 539b5284271SAndreas Gohr { 540b5284271SAndreas Gohr return $this->getAPIVersion(); 541b5284271SAndreas Gohr } 542b5284271SAndreas Gohr 543b5284271SAndreas Gohr /** 544b5284271SAndreas Gohr * @deprecated use core.login instead 545b5284271SAndreas Gohr */ 546b5284271SAndreas Gohr public function legacyLogin($user, $pass) 547b5284271SAndreas Gohr { 548b5284271SAndreas Gohr return parent::login($user, $pass); 549b5284271SAndreas Gohr } 550b5284271SAndreas Gohr 551b5284271SAndreas Gohr /** 552b5284271SAndreas Gohr * @deprecated use core.logoff instead 553b5284271SAndreas Gohr */ 554b5284271SAndreas Gohr public function legacyLogoff() 555b5284271SAndreas Gohr { 556b5284271SAndreas Gohr return parent::logoff(); 557b5284271SAndreas Gohr } 558b5284271SAndreas Gohr} 559