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