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