From 438f9df04f1e7307bfee111a218b823c2759f8f0 Mon Sep 17 00:00:00 2001 From: Krenair Date: Mon, 17 Mar 2014 22:11:01 +0000 Subject: [PATCH] Show last protection log entry and link to full protection log on protection notice Bug: 51215 Change-Id: I95e50451003f24bd37a2125dd21dbffcdd4fcafa --- ApiVisualEditor.php | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index 9034f7ebcd..780c280678 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -330,16 +330,6 @@ class ApiVisualEditor extends ApiBase { if ( $parsed && $parsed['restoring'] ) { $wgVisualEditorEditNotices[] = 'editingold'; } - // Page protected from editing - if ( $page->getNamespace() != NS_MEDIAWIKI && $page->isProtected( 'edit' ) ) { - # Is the title semi-protected? - if ( $page->isSemiProtected() ) { - $wgVisualEditorEditNotices[] = 'semiprotectedpagewarning'; - } else { - # Then it must be protected based on static groups (regular) - $wgVisualEditorEditNotices[] = 'protectedpagewarning'; - } - } // Creating new page if ( !$page->exists() ) { $wgVisualEditorEditNotices[] = $user->isLoggedIn() ? 'newarticletext' : 'newarticletextanon'; @@ -353,6 +343,33 @@ class ApiVisualEditor extends ApiBase { $notices[] = wfMessage( $key )->parseAsBlock(); } } + // Page protected from editing + if ( $page->getNamespace() != NS_MEDIAWIKI && $page->isProtected( 'edit' ) ) { + # Is the title semi-protected? + if ( $page->isSemiProtected() ) { + $noticeMsg = 'semiprotectedpagewarning'; + } else { + # Then it must be protected based on static groups (regular) + $noticeMsg = 'protectedpagewarning'; + } + $lp = new LogPager( + new LogEventsList( $this->getContext() ), + 'protect', + '', + $page->getPrefixedDBkey() + ); + $lp->mLimit = 1; + + $notices[] = wfMessage( $noticeMsg )->parseAsBlock() . $lp->getBody() . Linker::link( + SpecialPage::getTitleFor( 'Log' ), + $this->msg( 'log-fulllog' )->escaped(), + array(), + array( + 'page' => $page->getPrefixedDBkey(), + 'type' => 'protect' + ) + ); + } // HACK: Build a fake EditPage so we can get checkboxes from it $article = new Article( $page ); // Deliberately omitting ,0 so oldid comes from request