1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* API module to modify semantic watchlist groups. |
5
|
|
|
* |
6
|
|
|
* @since 0.1 |
7
|
|
|
* |
8
|
|
|
* @file ApiEditWatchlistGroup.php |
9
|
|
|
* @ingroup SemanticWatchlist |
10
|
|
|
* @ingroup API |
11
|
|
|
* |
12
|
|
|
* @licence GNU GPL v3+ |
13
|
|
|
* @author Jeroen De Dauw < [email protected] > |
14
|
|
|
*/ |
15
|
|
|
class ApiEditWatchlistGroup extends ApiBase { |
16
|
|
|
|
17
|
|
|
public function __construct( $main, $action ) { |
18
|
|
|
parent::__construct( $main, $action ); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function execute() { |
22
|
|
|
$user = $this->getUser(); |
23
|
|
|
|
24
|
|
|
if ( !$user->isAllowed( 'semanticwatchgroups' ) || $user->isBlocked() ) { |
25
|
|
|
$this->dieUsageMsg( array( 'badaccess-groups' ) ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$params = $this->extractRequestParams(); |
29
|
|
|
$params['customTexts'] = SWLGroup::unserializedCustomTexts( $params['customTexts'] ); |
30
|
|
|
$group = new SWLGroup( |
31
|
|
|
$params['id'], |
32
|
|
|
$params['name'], |
33
|
|
|
$params['categories'], |
34
|
|
|
$params['namespaces'], |
35
|
|
|
$params['properties'], |
36
|
|
|
$params['concepts'], |
37
|
|
|
$params['customTexts'] |
38
|
|
|
); |
39
|
|
|
|
40
|
|
|
$this->getResult()->addValue( |
41
|
|
|
null, |
42
|
|
|
'success', |
43
|
|
|
$group->writeToDB() |
44
|
|
|
); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getAllowedParams() { |
48
|
|
|
return array( |
49
|
|
|
'id' => array( |
50
|
|
|
ApiBase::PARAM_TYPE => 'integer', |
51
|
|
|
ApiBase::PARAM_REQUIRED => true, |
52
|
|
|
), |
53
|
|
|
'name' => array( |
54
|
|
|
ApiBase::PARAM_TYPE => 'string', |
55
|
|
|
ApiBase::PARAM_REQUIRED => true, |
56
|
|
|
), |
57
|
|
|
'properties' => array( |
58
|
|
|
ApiBase::PARAM_TYPE => 'string', |
59
|
|
|
ApiBase::PARAM_ISMULTI => true, |
60
|
|
|
ApiBase::PARAM_REQUIRED => true, |
61
|
|
|
), |
62
|
|
|
'categories' => array( |
63
|
|
|
ApiBase::PARAM_TYPE => 'string', |
64
|
|
|
ApiBase::PARAM_ISMULTI => true, |
65
|
|
|
ApiBase::PARAM_DFLT => '', |
66
|
|
|
), |
67
|
|
|
'namespaces' => array( |
68
|
|
|
ApiBase::PARAM_TYPE => 'string', |
69
|
|
|
ApiBase::PARAM_ISMULTI => true, |
70
|
|
|
ApiBase::PARAM_DFLT => '', |
71
|
|
|
), |
72
|
|
|
'concepts' => array( |
73
|
|
|
ApiBase::PARAM_TYPE => 'string', |
74
|
|
|
ApiBase::PARAM_ISMULTI => true, |
75
|
|
|
ApiBase::PARAM_DFLT => '', |
76
|
|
|
), |
77
|
|
|
'customTexts' => array( |
78
|
|
|
ApiBase::PARAM_TYPE => 'string', |
79
|
|
|
ApiBase::PARAM_ISMULTI => true, |
80
|
|
|
ApiBase::PARAM_DFLT => '', |
81
|
|
|
), |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getParamDescription() { |
86
|
|
|
return array( |
87
|
|
|
'id' => 'The ID of the watchlist group to edit', |
88
|
|
|
'name' => 'The name of the group, used for display in the user preferences', |
89
|
|
|
'properties' => 'The properties this watchlist group covers', |
90
|
|
|
'categories' => 'The categories this watchlist group covers', |
91
|
|
|
'namespaces' => 'The namespaces this watchlist group covers', |
92
|
|
|
'concepts' => 'The concepts this watchlist group covers', |
93
|
|
|
'customTexts' => 'Custom Text to be sent in Emails', |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getDescription() { |
98
|
|
|
return array( |
99
|
|
|
'API module to modify semantic watchlist groups.' |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
protected function getExamples() { |
104
|
|
|
return array( |
105
|
|
|
'api.php?action=editswlgroup&id=42&name=My group of awesome&properties=Has awesomeness|Has epicness&categories=Awesome stuff', |
106
|
|
|
'api.php?action=editswlgroup&id=42&name=My group of awesome&properties=Has awesomeness|Has epicness&categories=Awesome stuff&customTexts=Has awesomeness~true~Changed to awesome now', |
107
|
|
|
); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getVersion() { |
111
|
|
|
return __CLASS__ . ': $Id$'; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
} |
115
|
|
|
|