Index: trunk/extensions/GPoC/models/Selection.php |
— | — | @@ -39,6 +39,19 @@ |
40 | 40 | return $success; |
41 | 41 | } |
42 | 42 | |
| 43 | + public static function deleteArticle( $name, $namespace, $article ) { |
| 44 | + $dbw = wfGetDB( DB_MASTER ); |
| 45 | + $success = $dbw->delete( |
| 46 | + 'selections', |
| 47 | + array( |
| 48 | + 's_selection_name' => $name, |
| 49 | + 's_namespace' => $namespace, |
| 50 | + 's_article' => $article |
| 51 | + ), |
| 52 | + __METHOD__ |
| 53 | + ); |
| 54 | + return $success; |
| 55 | + } |
43 | 56 | public static function getSelection( $name ) { |
44 | 57 | $dbr = wfGetDB( DB_SLAVE ); |
45 | 58 | |
Index: trunk/extensions/GPoC/SpecialSelection.php |
— | — | @@ -46,14 +46,22 @@ |
47 | 47 | $wgOut->disable(); |
48 | 48 | $namespace = $wgRequest->getVal( 'namespace' ); |
49 | 49 | $article = $wgRequest->getVal( 'article' ); |
50 | | - $revision = $wgRequest->getVal( 'revision' ); |
51 | 50 | |
52 | | - $success = Selection::setRevision( $name, $namespace, $article, $revision ); |
| 51 | + $action = $wgRequest->getVal( 'action' ); |
| 52 | + if( $action == 'setrevision' ) { |
| 53 | + $revision = $wgRequest->getVal( 'revision' ); |
| 54 | + $success = Selection::setRevision( $name, $namespace, $article, $revision ); |
53 | 55 | |
54 | | - $return = array( |
55 | | - 'status' => $success, |
56 | | - 'revision' => $revision |
57 | | - ); |
| 56 | + $return = array( |
| 57 | + 'status' => $success, |
| 58 | + 'revision' => $revision |
| 59 | + ); |
| 60 | + } else if ( $action == 'deletearticle') { |
| 61 | + $success = Selection::deleteArticle( $name, $namespace, $article ); |
| 62 | + $return = array( |
| 63 | + 'status' => $success |
| 64 | + ); |
| 65 | + } |
58 | 66 | echo json_encode($return); |
59 | 67 | return; |
60 | 68 | } |
Index: trunk/extensions/GPoC/templates/SelectionTemplate.php |
— | — | @@ -63,6 +63,7 @@ |
64 | 64 | var revid = input.val(); |
65 | 65 | |
66 | 66 | $.post('', { |
| 67 | + action: 'setrevision', |
67 | 68 | namespace: ns, |
68 | 69 | article: article, |
69 | 70 | revision: revid |
— | — | @@ -72,6 +73,21 @@ |
73 | 74 | |
74 | 75 | return false; |
75 | 76 | }); |
| 77 | + $(".delete-article").click(function() { |
| 78 | + var parent = $(this).parents("div.item-actions"); |
| 79 | + var ns = parent.attr("data-namespace"), |
| 80 | + article = parent.attr("data-article"); |
| 81 | + |
| 82 | + $.post('', { |
| 83 | + action: 'deletearticle', |
| 84 | + namespace: ns, |
| 85 | + article: article |
| 86 | + }, function() { |
| 87 | + }); |
| 88 | + |
| 89 | + return false; |
| 90 | + }); |
| 91 | + |
76 | 92 | $(".revision-cancel").click(function() { |
77 | 93 | var parent = $(this).parents("div.item-actions"); |
78 | 94 | var input_box = parent.children(".revision-input"); |