r94315 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94314‎ | r94315 | r94316 >
Date:01:35, 12 August 2011
Author:yuvipanda
Status:deferred
Tags:
Comment:
Delete an article from a selection works
Modified paths:
  • /trunk/extensions/GPoC/SpecialSelection.php (modified) (history)
  • /trunk/extensions/GPoC/models/Selection.php (modified) (history)
  • /trunk/extensions/GPoC/templates/SelectionTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GPoC/models/Selection.php
@@ -39,6 +39,19 @@
4040 return $success;
4141 }
4242
 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+ }
4356 public static function getSelection( $name ) {
4457 $dbr = wfGetDB( DB_SLAVE );
4558
Index: trunk/extensions/GPoC/SpecialSelection.php
@@ -46,14 +46,22 @@
4747 $wgOut->disable();
4848 $namespace = $wgRequest->getVal( 'namespace' );
4949 $article = $wgRequest->getVal( 'article' );
50 - $revision = $wgRequest->getVal( 'revision' );
5150
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 );
5355
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+ }
5866 echo json_encode($return);
5967 return;
6068 }
Index: trunk/extensions/GPoC/templates/SelectionTemplate.php
@@ -63,6 +63,7 @@
6464 var revid = input.val();
6565
6666 $.post('', {
 67+ action: 'setrevision',
6768 namespace: ns,
6869 article: article,
6970 revision: revid
@@ -72,6 +73,21 @@
7374
7475 return false;
7576 });
 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+
7692 $(".revision-cancel").click(function() {
7793 var parent = $(this).parents("div.item-actions");
7894 var input_box = parent.children(".revision-input");

Status & tagging log