-
Notifications
You must be signed in to change notification settings - Fork 2
/
ApiEvalTitle.php
55 lines (47 loc) · 1.29 KB
/
ApiEvalTitle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
use MediaWiki\MediaWikiServices;
use MediaWiki\Extension\Translate\PageTranslation\Hooks;
class ApiEvalTitle extends ApiBase {
public function execute() {
$params = $this->extractRequestParams();
$page = $this->getTitleOrPageId( $params, 'fromdbmaster' );
$title = $page->getTitle();
if ( !$title->exists() ) {
$this->dieWithError( 'notanarticle' );
}
$pm = MediaWikiServices::getInstance()->getPermissionManager();
$user = $this->getUser();
Hooks::$allowTargetEdit = true;
$errors = $pm->getPermissionErrors( 'edit', $user, $title );
Hooks::$allowTargetEdit = false;
if ( $errors ) {
$this->dieStatus( $this->errorArrayToStatus( $errors, $user ) );
}
TouhouPatchCenter::evalTitle( $title );
return true;
}
public function isWriteMode() {
return true;
}
public function mustBePosted() {
return true;
}
public function needsToken() {
return 'csrf';
}
public function getExamplesMessages() {
return [
'action=evaltitle&title=Main%20Page' => 'apihelp-evaltitle-example-title'
];
}
public function getAllowedParams() {
return array(
'title' => array( ApiBase::PARAM_TYPE => 'string' ),
'pageid' => array( ApiBase::PARAM_TYPE => 'integer' ),
'token' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
)
);
}
}