Followup r86622: add initial QUnit test cases for jquery.textSelection module.
[lhc/web/wiklou.git] / includes / actions / DeletetrackbackAction.php
1 <?php
2 /**
3 * Delete a trackback on a page
4 *
5 * Copyright © 2011 Alexandre Emsenhuber
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 * @file
22 * @ingroup Actions
23 */
24
25 class DeletetrackbackAction extends FormlessAction {
26
27 public function getName() {
28 return 'deletetrackback';
29 }
30
31 public function getRestriction() {
32 return 'delete';
33 }
34
35 protected function getDescription() {
36 return '';
37 }
38
39 protected function checkCanExecute( User $user ) {
40 if ( !$user->matchEditToken( $this->getRequest()->getVal( 'token' ) ) ) {
41 throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
42 }
43
44 return parent::checkCanExecute( $user );
45 }
46
47 public function onView() {
48 $db = wfGetDB( DB_MASTER );
49 $db->delete( 'trackbacks', array( 'tb_id' => $this->getRequest()->getInt( 'tbid' ) ) );
50
51 $this->getOutput()->addWikiMsg( 'trackbackdeleteok' );
52 $this->getTitle()->invalidateCache();
53 }
54 }