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 @@ |
23 | 23 | if( !$wgUser->isAllowed( 'premoderation' ) ) { |
24 | 24 | $this->displayRestrictionError(); |
25 | 25 | return; |
26 | | - } elseif( wfReadOnly() ) { |
| 26 | + } |
| 27 | + if( wfReadOnly() ) { |
27 | 28 | $wgOut->readOnlyPage(); |
28 | 29 | return; |
29 | | - } elseif( $wgUser->isBlocked() ) { |
| 30 | + } |
| 31 | + if( $wgUser->isBlocked() ) { |
30 | 32 | $wgOut->blockedPage(); |
31 | 33 | return; |
32 | 34 | } |
— | — | @@ -55,12 +57,18 @@ |
56 | 58 | } |
57 | 59 | |
58 | 60 | protected function showList() { |
59 | | - global $wgOut; |
| 61 | + global $wgOut, $wgArticlePath; |
60 | 62 | |
61 | 63 | $wgOut->setPageTitle( wfMsg( 'premoderation-manager-mainpage' ) ); |
62 | 64 | $wgOut->addWikiMsg( 'premoderation-list-intro' ); |
63 | 65 | |
64 | 66 | $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 | + |
65 | 73 | $res = $dbr->select( |
66 | 74 | 'pm_queue', |
67 | 75 | array( |
— | — | @@ -68,17 +76,31 @@ |
69 | 77 | 'pmq_timestamp', 'pmq_minor', 'pmq_summary', 'pmq_len', 'pmq_status', |
70 | 78 | 'pmq_updated', 'pmq_updated_user_text' |
71 | 79 | ), |
72 | | - '', |
| 80 | + $conds, |
73 | 81 | __METHOD__, |
74 | | - array( 'ORDER BY' => 'pmq_timestamp DESC', 'LIMIT' => 100 ) |
| 82 | + array( 'ORDER BY' => 'pmq_timestamp DESC', 'LIMIT' => 101 ) |
75 | 83 | ); |
76 | 84 | |
77 | 85 | $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 | + } |
79 | 95 | $status = $row['pmq_status']; |
80 | 96 | $result[$status][] = $row; |
81 | 97 | } |
82 | 98 | |
| 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 | + |
83 | 105 | if( isset( $result['new'] ) ) { |
84 | 106 | $msg = wfMsg( 'premoderation-list-new-h2' ); |
85 | 107 | $wgOut->addWikiText( '<h2>' . $msg . '</h2>' ); |
— | — | @@ -119,7 +141,7 @@ |
120 | 142 | protected function formatListTableRow( $row ) { |
121 | 143 | global $wgLang, $wgArticlePath; |
122 | 144 | |
123 | | - $articlePath = str_replace('$1', '', $wgArticlePath); |
| 145 | + $articlePath = str_replace('$1', '', $wgArticlePath); |
124 | 146 | return '<tr><td>' . $wgLang->timeanddate( $row['pmq_timestamp'] ) . '</td>' . |
125 | 147 | '<td>' . Linker::userLink( $row['pmq_user'], $row['pmq_user_text'] ) . '</td>' . |
126 | 148 | '<td>' . Linker::link( Title::newFromText( $row['pmq_page_title'], $row['pmq_page_ns'] ) ) . |
— | — | @@ -166,7 +188,7 @@ |
167 | 189 | Xml::closeElement( 'table' ) ); |
168 | 190 | |
169 | 191 | 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'] ) ); |
171 | 193 | } |
172 | 194 | |
173 | 195 | $rev = Revision::newFromID( $row['pmq_page_last_id'] ); |
— | — | @@ -217,9 +239,6 @@ |
218 | 240 | protected function checkInternalConflicts( $db, $id, $ns, $page ) { |
219 | 241 | global $wgOut; |
220 | 242 | |
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 | | - |
224 | 243 | $res = $db->select( |
225 | 244 | 'pm_queue', |
226 | 245 | '*', |
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 |
1 | 5 | + native |
Index: trunk/extensions/Premoderation/Premoderation.class.php |
— | — | @@ -176,7 +176,9 @@ |
177 | 177 | |
178 | 178 | public static function updateDBSchema( $updater ) { |
179 | 179 | $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 ) ); |
181 | 183 | return true; |
182 | 184 | } |
183 | 185 | } |
\ 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 |
1 | 22 | + native |
Index: trunk/extensions/Premoderation/Premoderation.i18n.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | 'premoderation-invalidaction' => 'You are trying to perform an invalid action.', |
40 | 40 | '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.', |
41 | 41 | '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', |
43 | 43 | 'premoderation-success-changed-text' => 'Revision status in moderation queue has been succesfully changed', |
44 | 44 | 'premoderation-table-list-status' => 'Changing status', |
45 | 45 | 'premoderation-table-list-title' => 'Title and parameters', |
— | — | @@ -47,6 +47,7 @@ |
48 | 48 | 'premoderation-table-list-user' => 'User', |
49 | 49 | 'premoderation-table-list-ip' => 'IP address', |
50 | 50 | 'premoderation-table-list-delete' => 'Delete', |
| 51 | + 'premoderation-next' => 'Next entries', |
51 | 52 | 'premoderation-status-fieldset' => 'Change status', |
52 | 53 | 'premoderation-status-approved' => 'Approve revision', |
53 | 54 | 'premoderation-status-declined' => 'Decline revision', |
— | — | @@ -110,7 +111,7 @@ |
111 | 112 | 'premoderation-invalidaction' => 'Вы пытаетесь осуществить некорректное действие.', |
112 | 113 | 'premoderation-list-intro' => 'На этой странице перечислены правки, ожидающие подтверждения модератора. Вы можете просмотреть детали каждой правки, подтвердить её (после чего она станет доступна на сайте) или отклонить (после этого вы всё равно сможете подтвердить её или вернуть в очередь в течение 3 дней).', |
113 | 114 | 'premoderation-notexists-id' => 'Запись в очереди модерации не существует. Возможно, она уже была обработана и удалена из таблицы модерации.', |
114 | | - 'premoderation-private-ip' => 'IP-адрес:', |
| 115 | + 'premoderation-private-ip' => 'IP-адрес: $1', |
115 | 116 | 'premoderation-success-changed-text' => 'Статус правки в очереди премодерации успешно изменён.', |
116 | 117 | 'premoderation-table-list-status' => 'Изменение статуса', |
117 | 118 | 'premoderation-table-list-title' => 'Название и параметры', |
— | — | @@ -119,6 +120,7 @@ |
120 | 121 | 'premoderation-table-list-user' => 'Участник', |
121 | 122 | 'premoderation-table-list-ip' => 'IP-адрес', |
122 | 123 | 'premoderation-table-list-delete' => 'Удалить', |
| 124 | + 'premoderation-next' => 'Следующие записи', |
123 | 125 | 'premoderation-status-fieldset' => 'Изменить статус', |
124 | 126 | 'premoderation-status-approved' => 'Подтвердить правку', |
125 | 127 | 'premoderation-status-declined' => 'Отклонить правку', |
Index: trunk/extensions/Premoderation/SpecialPremoderationWhiteList.php |
— | — | @@ -20,10 +20,12 @@ |
21 | 21 | if( !$wgUser->isAllowed( 'premoderation-wlist' ) ) { |
22 | 22 | $this->displayRestrictionError(); |
23 | 23 | return; |
24 | | - } elseif( wfReadOnly() ) { |
| 24 | + } |
| 25 | + if( wfReadOnly() ) { |
25 | 26 | $wgOut->readOnlyPage(); |
26 | 27 | return; |
27 | | - } elseif( $wgUser->isBlocked() ) { |
| 28 | + } |
| 29 | + if( $wgUser->isBlocked() ) { |
28 | 30 | $wgOut->blockedPage(); |
29 | 31 | return; |
30 | 32 | } |
Index: trunk/extensions/Premoderation/Premoderation.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | 'name' => 'Premoderation', |
10 | 10 | 'author' => array( 'Cryptocoryne' ), |
11 | 11 | 'descriptionmsg' => 'premoderation-desc', |
12 | | - 'version' => '1.0beta', |
| 12 | + 'version' => '1.0', |
13 | 13 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Premoderation', |
14 | 14 | ); |
15 | 15 | |