Index: trunk/extensions/UploadWizard/api/ApiDeleteUploadCampaign.php |
— | — | @@ -13,47 +13,47 @@ |
14 | 14 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | 15 | */ |
16 | 16 | class ApiDeleteUploadCampaign extends ApiBase { |
17 | | - |
| 17 | + |
18 | 18 | public function __construct( $main, $action ) { |
19 | 19 | parent::__construct( $main, $action ); |
20 | 20 | } |
21 | | - |
| 21 | + |
22 | 22 | public function execute() { |
23 | 23 | global $wgUser; |
24 | | - |
| 24 | + |
25 | 25 | if ( !$wgUser->isAllowed( 'upwizcampaigns' ) || $wgUser->isBlocked() ) { |
26 | 26 | $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
27 | 27 | } |
28 | | - |
| 28 | + |
29 | 29 | $params = $this->extractRequestParams(); |
30 | | - |
| 30 | + |
31 | 31 | $everythingOk = true; |
32 | | - |
| 32 | + |
33 | 33 | foreach ( $params['ids'] as $id ) { |
34 | 34 | $campaign = new UploadWizardCampaign( $id ); |
35 | 35 | $everythingOk = $campaign->deleteFromDB() && $everythingOk; |
36 | 36 | } |
37 | | - |
| 37 | + |
38 | 38 | $this->getResult()->addValue( |
39 | 39 | null, |
40 | 40 | 'success', |
41 | 41 | $everythingOk |
42 | 42 | ); |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | public function needsToken() { |
46 | 46 | return true; |
47 | 47 | } |
48 | | - |
| 48 | + |
49 | 49 | public function getTokenSalt() { |
50 | 50 | $params = $this->extractRequestParams(); |
51 | 51 | return 'deletecampaign' . implode( '|', $params['ids'] ); |
52 | 52 | } |
53 | | - |
| 53 | + |
54 | 54 | public function mustBePosted() { |
55 | 55 | return true; |
56 | 56 | } |
57 | | - |
| 57 | + |
58 | 58 | public function getAllowedParams() { |
59 | 59 | return array( |
60 | 60 | 'ids' => array( |
— | — | @@ -64,21 +64,22 @@ |
65 | 65 | 'token' => null, |
66 | 66 | ); |
67 | 67 | } |
68 | | - |
| 68 | + |
69 | 69 | public function getParamDescription() { |
70 | 70 | return array( |
71 | 71 | 'ids' => 'The IDs of the campaigns to delete', |
72 | 72 | 'token' => 'Edit token. You can get one of these through prop=info.', |
73 | 73 | ); |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | public function getDescription() { |
77 | 77 | return array( |
78 | | - 'API module for deleting Upload Campaigns, associated with UploadWizard. Do not rely on this, it is an API method ' |
79 | | - . 'mostly for developer convenience. This does not mean an Upload Campaign editing API will ever be available.' |
| 78 | + 'API module for deleting Upload Campaigns, associated with UploadWizard.', |
| 79 | + 'Do not rely on this, it is an API method mostly for developer convenience.', |
| 80 | + 'This does not mean an Upload Campaign editing API will ever be available.', |
80 | 81 | ); |
81 | 82 | } |
82 | | - |
| 83 | + |
83 | 84 | public function getPossibleErrors() { |
84 | 85 | return array_merge( parent::getPossibleErrors(), array( |
85 | 86 | array( 'missingparam', 'ids' ), |
— | — | @@ -90,10 +91,10 @@ |
91 | 92 | 'api.php?action=deleteuploadcampaign&ids=42', |
92 | 93 | 'api.php?action=deleteuploadcampaign&ids=4|2', |
93 | 94 | ); |
94 | | - } |
95 | | - |
| 95 | + } |
| 96 | + |
96 | 97 | public function getVersion() { |
97 | 98 | return __CLASS__ . ': $Id$'; |
98 | | - } |
99 | | - |
| 99 | + } |
| 100 | + |
100 | 101 | } |