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