Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/250007

Change subject: Replace deprecated hook UnkownAction with $wgAction
......................................................................

Replace deprecated hook UnkownAction with $wgAction

Change-Id: Ifb6de821aae8af31163435d760550aefa25860f0
---
M DeletePagesForGood.class.php
M extension.json
2 files changed, 108 insertions(+), 53 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DeletePagesForGood 
refs/changes/07/250007/1

diff --git a/DeletePagesForGood.class.php b/DeletePagesForGood.class.php
index ce8e413..5db2c31 100644
--- a/DeletePagesForGood.class.php
+++ b/DeletePagesForGood.class.php
@@ -9,11 +9,6 @@
                        &$this,
                        'AddSkinHook'
                );
-
-               $wgHooks['UnknownAction'][] = array(
-                       &$this,
-                       'AddActionHook'
-               );
        }
 
        function AddSkinHook( SkinTemplate &$sktemplate, array &$links ) {
@@ -37,53 +32,6 @@
                                'text' => wfMessage( 
'deletepagesforgood-delete_permanently' )->text(),
                                'href' => $wgTitle->getLocalUrl( 
'action=ask_delete_page_permanently' )
                        );
-               }
-
-               return true;
-       }
-
-       function AddActionHook( $action, $wgArticle ) {
-               global $wgOut, $wgUser, $wgDeletePagesForGoodNamespaces;
-
-               if ( !$wgUser->isAllowed( 'deleteperm' ) ) {
-                       $wgOut->permissionRequired( 'deleteperm' );
-
-                       return false;
-               }
-
-               # Print a form to approve deletion
-               if ( $action == 'ask_delete_page_permanently' ) {
-
-                       $action = $wgArticle->getTitle()->getLocalUrl( 
'action=delete_page_permanently' );
-                       $wgOut->addHTML( "<form 
id='ask_delete_page_permanently' method='post' action=\"$action\">
-                               <table>
-                                               <tr>
-                                                       <td>" . wfMessage( 
'deletepagesforgood-ask_deletion' )->text() . "</td>
-                                               </tr>
-                                               <tr>
-                                                       <td><input 
type='submit' name='submit' value=\"" .
-                                                               wfMessage( 
'deletepagesforgood-yes' )->text() . "\" />
-                                                       </td>
-                                               </tr>
-                               </table></form>"
-                       );
-                       return false;
-               } elseif ( $action == 'delete_page_permanently' ) {
-                       # Perform actual deletion
-                       $ns = $wgArticle->mTitle->getNamespace();
-                       $t = $wgArticle->mTitle->getDBkey();
-                       $id = $wgArticle->mTitle->getArticleID();
-
-                       if ( $t == '' || $id == 0 || 
$wgDeletePagesForGoodNamespaces[$ns] != true
-                               || $ns == NS_SPECIAL
-                       ) {
-                               $wgOut->addHTML( wfMessage( 
'deletepagesforgood-del_impossible' )->escaped() );
-                               return false;
-                       }
-
-                       $this->deletePermanently( $wgArticle->mTitle );
-                       $wgOut->addHTML( wfMessage( 
'deletepagesforgood-del_done' )->escaped() );
-                       return false;
                }
 
                return true;
@@ -249,3 +197,103 @@
                }
        }
 }
+
+abstract class ActionAskDeletePagePermanently extends FormAction {
+
+       public function getName() {
+               return 'ask_delete_page_permanently';
+       }
+
+       public function requiresUnblock() {
+               return false;
+       }
+
+       public function getDescription() {
+               return '';
+       }
+
+       public function onSubmit( $data ) {
+               self::AddActionAskDeletePagePermanently( $this->getTitle(), 
$this->getUser() );
+
+               return true;
+       }
+
+       public static function AddActionAskDeletePagePermanently( $action, 
$wgArticle ) {
+               global $wgOut, $wgUser, $wgDeletePagesForGoodNamespaces;
+
+
+               # Print a form to approve deletion
+               if ( $action == 'ask_delete_page_permanently' ) {
+
+                       $action = $wgArticle->getTitle()->getLocalUrl( 
'action=delete_page_permanently' );
+                       $wgOut->addHTML( "<form 
id='ask_delete_page_permanently' method='post' action=\"$action\">
+                               <table>
+                                               <tr>
+                                                       <td>" . wfMessage( 
'deletepagesforgood-ask_deletion' )->text() . "</td>
+                                               </tr>
+                                               <tr>
+                                                       <td><input 
type='submit' name='submit' value=\"" .
+                                                               wfMessage( 
'deletepagesforgood-yes' )->text() . "\" />
+                                                       </td>
+                                               </tr>
+                               </table></form>"
+                       );
+                       return false;
+               }
+
+               return true;
+       }
+
+       public function getRestriction() {
+               return 'deleteperm';
+               // global $wgOut, $wgUser;
+
+               // if ( !$wgUser->isAllowed( 'deleteperm' ) ) {
+                       // $wgOut->permissionRequired( 'deleteperm' );
+
+                       // return false;
+               // }
+       }
+
+
+       protected function checkCanExecute( User $user ) {
+               // Must be logged in
+               if ( $user->isAnon() ) {
+                       throw new UserNotLoggedIn( 'deleteperm' );
+               }
+
+               parent::checkCanExecute( $user );
+       }
+}
+
+abstract class ActionDeletePagePermanently extends FormAction {
+       function AddActionDeletePagePermanently( $action, $wgArticle ) {
+               global $wgOut, $wgUser, $wgDeletePagesForGoodNamespaces;
+
+               if ( !$wgUser->isAllowed( 'deleteperm' ) ) {
+                       $wgOut->permissionRequired( 'deleteperm' );
+
+                       return false;
+               }
+
+               if ( $action == 'delete_page_permanently' ) {
+                       # Perform actual deletion
+                       $ns = $wgArticle->mTitle->getNamespace();
+                       $t = $wgArticle->mTitle->getDBkey();
+                       $id = $wgArticle->mTitle->getArticleID();
+
+                       if ( $t == '' || $id == 0 || 
$wgDeletePagesForGoodNamespaces[$ns] != true
+                               || $ns == NS_SPECIAL
+                       ) {
+                               $wgOut->addHTML( wfMessage( 
'deletepagesforgood-del_impossible' )->escaped() );
+                               return false;
+                       }
+
+                       $this->deletePermanently( $wgArticle->mTitle );
+                       $wgOut->addHTML( wfMessage( 
'deletepagesforgood-del_done' )->escaped() );
+                       return false;
+               }
+
+               return true;
+       }
+}
diff --git a/extension.json b/extension.json
index 7d1a260..1dd70e2 100644
--- a/extension.json
+++ b/extension.json
@@ -21,6 +21,11 @@
                        "deleteperm": true
                }
        },
+       "Actions": {
+               "ask_delete_page_permanently": "DeletePagesForGood",
+               "delete_page_permanently": "DeletePagesForGood",
+               "_merge_strategy": "array_plus"
+       },
        "AvailableRights": [
                "deleteperm"
        ],
@@ -34,7 +39,9 @@
        },
        "AutoloadClasses": {
                "DeletePagesForGoodHooks": "DeletePagesForGood.hooks.php",
-               "DeletePagesForGood": "DeletePagesForGood.class.php"
+               "DeletePagesForGood": "DeletePagesForGood.class.php",
+               "ActionAskDeletePagePermanently": 
"DeletePagesForGood.class.php",
+               "ActionDeletePagePermanently": "DeletePagesForGood.class.php"
        },
        "config": {
                "DeletePagesForGoodNamespaces": {

-- 
To view, visit https://gerrit.wikimedia.org/r/250007
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb6de821aae8af31163435d760550aefa25860f0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DeletePagesForGood
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to