r102366 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102365‎ | r102366 | r102367 >
Date:02:30, 8 November 2011
Author:cryptocoryne
Status:deferred (Comments)
Tags:
Comment:
Final fixes
Modified paths:
  • /trunk/extensions/Premoderation/Premoderation.class.php (modified) (history)
  • /trunk/extensions/Premoderation/Premoderation.i18n.php (modified) (history)
  • /trunk/extensions/Premoderation/Premoderation.php (modified) (history)
  • /trunk/extensions/Premoderation/SpecialPremoderation.php (modified) (history)
  • /trunk/extensions/Premoderation/SpecialPremoderationWhiteList.php (modified) (history)
  • /trunk/extensions/Premoderation/db_queue.sql (added) (history)
  • /trunk/extensions/Premoderation/db_tables.sql (deleted) (history)
  • /trunk/extensions/Premoderation/db_whitelist.sql (added) (history)

Diff [purge]

Index: trunk/extensions/Premoderation/db_tables.sql
@@ -1,24 +0,0 @@
2 -CREATE TABLE /*_*/pm_queue (
3 - pmq_id BIGINT unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
4 - pmq_page_last_id INT unsigned NOT NULL,
5 - pmq_page_ns INT NOT NULL,
6 - pmq_page_title VARCHAR(255) BINARY NOT NULL,
7 - pmq_user INT unsigned NOT NULL DEFAULT 0,
8 - pmq_user_text VARCHAR(255) BINARY NOT NULL DEFAULT '',
9 - pmq_timestamp BINARY(14) NOT NULL DEFAULT '',
10 - pmq_minor TINYINT unsigned NOT NULL DEFAULT 0,
11 - pmq_summary TINYBLOB NOT NULL,
12 - pmq_len INT unsigned,
13 - pmq_text MEDIUMBLOB NOT NULL,
14 - pmq_flags tinyblob NOT NULL,
15 - pmq_ip VARBINARY(40) NOT NULL DEFAULT '',
16 - pmq_updated BINARY(14) DEFAULT NULL,
17 - pmq_updated_user INT unsigned DEFAULT NULL,
18 - pmq_updated_user_text VARCHAR(255) BINARY DEFAULT NULL,
19 - pmq_status VARBINARY(40) NOT NULL DEFAULT ''
20 -) /*$wgDBTableOptions*/;
21 -CREATE INDEX /*i*/pmq_user ON /*_*/pm_queue (pmq_user);
22 -
23 -CREATE TABLE /*_*/pm_whitelist (
24 - pmw_ip VARBINARY(40) NOT NULL PRIMARY KEY DEFAULT '',
25 -) /*$wgDBTableOptions*/;
\ No newline at end of file
Index: trunk/extensions/Premoderation/SpecialPremoderation.php
@@ -22,10 +22,12 @@
2323 if( !$wgUser->isAllowed( 'premoderation' ) ) {
2424 $this->displayRestrictionError();
2525 return;
26 - } elseif( wfReadOnly() ) {
 26+ }
 27+ if( wfReadOnly() ) {
2728 $wgOut->readOnlyPage();
2829 return;
29 - } elseif( $wgUser->isBlocked() ) {
 30+ }
 31+ if( $wgUser->isBlocked() ) {
3032 $wgOut->blockedPage();
3133 return;
3234 }
@@ -55,12 +57,18 @@
5658 }
5759
5860 protected function showList() {
59 - global $wgOut;
 61+ global $wgOut, $wgArticlePath;
6062
6163 $wgOut->setPageTitle( wfMsg( 'premoderation-manager-mainpage' ) );
6264 $wgOut->addWikiMsg( 'premoderation-list-intro' );
6365
6466 $dbr = wfGetDB( DB_SLAVE );
 67+ $params = $this->mParams;
 68+ $conds = 'pmq_status <> "approved"';
 69+ if( isset( $params['offset'] ) ) {
 70+ $conds .= ' AND pmq_timestamp < ' . $dbr->addQuotes( $params['offset'] );
 71+ }
 72+
6573 $res = $dbr->select(
6674 'pm_queue',
6775 array(
@@ -68,17 +76,31 @@
6977 'pmq_timestamp', 'pmq_minor', 'pmq_summary', 'pmq_len', 'pmq_status',
7078 'pmq_updated', 'pmq_updated_user_text'
7179 ),
72 - '',
 80+ $conds,
7381 __METHOD__,
74 - array( 'ORDER BY' => 'pmq_timestamp DESC', 'LIMIT' => 100 )
 82+ array( 'ORDER BY' => 'pmq_timestamp DESC', 'LIMIT' => 101 )
7583 );
7684
7785 $result = array();
78 - while( $row = $dbr->fetchRow( $res ) ) {
 86+ for( $a = 0; $a < 101; $a++ ) {
 87+ $row = $dbr->fetchRow( $res );
 88+ if( $a == 100 ) {
 89+ $offset = $row['pmq_timestamp'];
 90+ break;
 91+ }
 92+ if( !$row ) {
 93+ break;
 94+ }
7995 $status = $row['pmq_status'];
8096 $result[$status][] = $row;
8197 }
8298
 99+ if( isset( $offset ) ) {
 100+ $articlePath = str_replace('$1', '', $wgArticlePath);
 101+ $wgOut->addHTML( '<a href="' . $articlePath . 'Special:Premoderation/list/offset/'
 102+ . $offset . '">' . wfMsg( 'premoderation-next' ) . '</a>' );
 103+ }
 104+
83105 if( isset( $result['new'] ) ) {
84106 $msg = wfMsg( 'premoderation-list-new-h2' );
85107 $wgOut->addWikiText( '<h2>' . $msg . '</h2>' );
@@ -119,7 +141,7 @@
120142 protected function formatListTableRow( $row ) {
121143 global $wgLang, $wgArticlePath;
122144
123 - $articlePath = str_replace('$1', '', $wgArticlePath);
 145+ $articlePath = str_replace('$1', '', $wgArticlePath);
124146 return '<tr><td>' . $wgLang->timeanddate( $row['pmq_timestamp'] ) . '</td>' .
125147 '<td>' . Linker::userLink( $row['pmq_user'], $row['pmq_user_text'] ) . '</td>' .
126148 '<td>' . Linker::link( Title::newFromText( $row['pmq_page_title'], $row['pmq_page_ns'] ) ) .
@@ -166,7 +188,7 @@
167189 Xml::closeElement( 'table' ) );
168190
169191 if( $wgUser->isAllowed( 'premoderation-viewip' ) ) {
170 - $wgOut->addHTML( wfMsg( 'premoderation-private-ip' ) . ' ' . $row['pmq_ip'] );
 192+ $wgOut->addHTML( wfMessage( 'premoderation-private-ip', $row['pmq_ip'] ) );
171193 }
172194
173195 $rev = Revision::newFromID( $row['pmq_page_last_id'] );
@@ -217,9 +239,6 @@
218240 protected function checkInternalConflicts( $db, $id, $ns, $page ) {
219241 global $wgOut;
220242
221 - $conds = 'pmq_page_ns = ' . $db->addQuotes( $ns ) . ' AND pmq_page_title = ' .
222 - $db->addQuotes( $page ) . ' AND pmq_id != ' . $id . ' AND pmq_status != "approved"';
223 -
224243 $res = $db->select(
225244 'pm_queue',
226245 '*',
Index: trunk/extensions/Premoderation/db_whitelist.sql
@@ -0,0 +1,3 @@
 2+CREATE TABLE IF NOT EXISTS /*_*/pm_whitelist (
 3+ pmw_ip VARBINARY(40) NOT NULL PRIMARY KEY DEFAULT ''
 4+) /*$wgDBTableOptions*/;
\ No newline at end of file
Property changes on: trunk/extensions/Premoderation/db_whitelist.sql
___________________________________________________________________
Added: svn:eol-style
15 + native
Index: trunk/extensions/Premoderation/Premoderation.class.php
@@ -176,7 +176,9 @@
177177
178178 public static function updateDBSchema( $updater ) {
179179 $updater->addExtensionUpdate( array( 'addTable', 'pm_queue',
180 - dirname( __FILE__ ) . '/db_tables.sql', true ) );
 180+ dirname( __FILE__ ) . '/db_queue.sql', true ) );
 181+ $updater->addExtensionUpdate( array( 'addTable', 'pm_whitelist',
 182+ dirname( __FILE__ ) . '/db_whitelist.sql', true ) );
181183 return true;
182184 }
183185 }
\ No newline at end of file
Index: trunk/extensions/Premoderation/db_queue.sql
@@ -0,0 +1,20 @@
 2+CREATE TABLE IF NOT EXISTS /*_*/pm_queue (
 3+ pmq_id BIGINT unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
 4+ pmq_page_last_id INT unsigned NOT NULL,
 5+ pmq_page_ns INT NOT NULL,
 6+ pmq_page_title VARCHAR(255) BINARY NOT NULL,
 7+ pmq_user INT unsigned NOT NULL DEFAULT 0,
 8+ pmq_user_text VARCHAR(255) BINARY NOT NULL DEFAULT '',
 9+ pmq_timestamp BINARY(14) NOT NULL DEFAULT '',
 10+ pmq_minor TINYINT unsigned NOT NULL DEFAULT 0,
 11+ pmq_summary TINYBLOB NOT NULL,
 12+ pmq_len INT unsigned,
 13+ pmq_text MEDIUMBLOB NOT NULL,
 14+ pmq_flags tinyblob NOT NULL,
 15+ pmq_ip VARBINARY(40) NOT NULL DEFAULT '',
 16+ pmq_updated BINARY(14) DEFAULT NULL,
 17+ pmq_updated_user INT unsigned DEFAULT NULL,
 18+ pmq_updated_user_text VARCHAR(255) BINARY DEFAULT NULL,
 19+ pmq_status VARBINARY(40) NOT NULL DEFAULT ''
 20+) /*$wgDBTableOptions*/;
 21+CREATE INDEX /*i*/pmq_user ON /*_*/pm_queue (pmq_user);
\ No newline at end of file
Property changes on: trunk/extensions/Premoderation/db_queue.sql
___________________________________________________________________
Added: svn:eol-style
122 + native
Index: trunk/extensions/Premoderation/Premoderation.i18n.php
@@ -38,7 +38,7 @@
3939 'premoderation-invalidaction' => 'You are trying to perform an invalid action.',
4040 'premoderation-list-intro' => 'This special page lists new and declined revisions in the moderation queue. You can review each revision, approve and publish or decline it. Declined revisions will be completely removed from database after 3 days of last status change.',
4141 'premoderation-notexists-id' => 'This revision could not be found in the moderation queue. Probably it has already been published or declined and deleted from database',
42 - 'premoderation-private-ip' => 'IP address:',
 42+ 'premoderation-private-ip' => 'IP address: $1',
4343 'premoderation-success-changed-text' => 'Revision status in moderation queue has been succesfully changed',
4444 'premoderation-table-list-status' => 'Changing status',
4545 'premoderation-table-list-title' => 'Title and parameters',
@@ -47,6 +47,7 @@
4848 'premoderation-table-list-user' => 'User',
4949 'premoderation-table-list-ip' => 'IP address',
5050 'premoderation-table-list-delete' => 'Delete',
 51+ 'premoderation-next' => 'Next entries',
5152 'premoderation-status-fieldset' => 'Change status',
5253 'premoderation-status-approved' => 'Approve revision',
5354 'premoderation-status-declined' => 'Decline revision',
@@ -110,7 +111,7 @@
111112 'premoderation-invalidaction' => 'Вы пытаетесь осуществить некорректное действие.',
112113 'premoderation-list-intro' => 'На этой странице перечислены правки, ожидающие подтверждения модератора. Вы можете просмотреть детали каждой правки, подтвердить её (после чего она станет доступна на сайте) или отклонить (после этого вы всё равно сможете подтвердить её или вернуть в очередь в течение 3 дней).',
113114 'premoderation-notexists-id' => 'Запись в очереди модерации не существует. Возможно, она уже была обработана и удалена из таблицы модерации.',
114 - 'premoderation-private-ip' => 'IP-адрес:',
 115+ 'premoderation-private-ip' => 'IP-адрес: $1',
115116 'premoderation-success-changed-text' => 'Статус правки в очереди премодерации успешно изменён.',
116117 'premoderation-table-list-status' => 'Изменение статуса',
117118 'premoderation-table-list-title' => 'Название и параметры',
@@ -119,6 +120,7 @@
120121 'premoderation-table-list-user' => 'Участник',
121122 'premoderation-table-list-ip' => 'IP-адрес',
122123 'premoderation-table-list-delete' => 'Удалить',
 124+ 'premoderation-next' => 'Следующие записи',
123125 'premoderation-status-fieldset' => 'Изменить статус',
124126 'premoderation-status-approved' => 'Подтвердить правку',
125127 'premoderation-status-declined' => 'Отклонить правку',
Index: trunk/extensions/Premoderation/SpecialPremoderationWhiteList.php
@@ -20,10 +20,12 @@
2121 if( !$wgUser->isAllowed( 'premoderation-wlist' ) ) {
2222 $this->displayRestrictionError();
2323 return;
24 - } elseif( wfReadOnly() ) {
 24+ }
 25+ if( wfReadOnly() ) {
2526 $wgOut->readOnlyPage();
2627 return;
27 - } elseif( $wgUser->isBlocked() ) {
 28+ }
 29+ if( $wgUser->isBlocked() ) {
2830 $wgOut->blockedPage();
2931 return;
3032 }
Index: trunk/extensions/Premoderation/Premoderation.php
@@ -8,7 +8,7 @@
99 'name' => 'Premoderation',
1010 'author' => array( 'Cryptocoryne' ),
1111 'descriptionmsg' => 'premoderation-desc',
12 - 'version' => '1.0beta',
 12+ 'version' => '1.0',
1313 'url' => 'http://www.mediawiki.org/wiki/Extension:Premoderation',
1414 );
1515

Comments

#Comment by Nikerabbit (talk | contribs)   10:32, 8 November 2011

Please consider these suggestions:

+			$articlePath = str_replace('$1', '', $wgArticlePath);
+			$wgOut->addHTML( '<a href="' . $articlePath . 'Special:Premoderation/list/offset/'
+				. $offset . '">' . wfMsg( 'premoderation-next' ) . '</a>' );
$wgOut->addHtml( Linker::link( $this->getTitle( "list/offset/$offset" ), wfMsgHtml( 'premoderation-next ) ) );


+			$wgOut->addHTML( wfMessage( 'premoderation-private-ip', $row['pmq_ip'] ) );
$wgOut->addWikiMsg( 'premoderation-private-ip', $row['pmq_ip'] );
#Comment by Cryptocoryne (talk | contribs)   12:47, 10 November 2011

See r102647.

#Comment by Raymond (talk | contribs)   14:46, 8 November 2011

Please add message documentation for the newly added messages. Thanks.

Status & tagging log