Index: trunk/extensions/DeleteQueue/ReviewForm.php |
— | — | @@ -1,326 +0,0 @@ |
2 | | -<?php |
3 | | -if ( ! defined( 'MEDIAWIKI' ) ) |
4 | | - die(); |
5 | | - |
6 | | -class DeleteQueueReviewForm { |
7 | | - |
8 | | - function __construct( $article ) { |
9 | | - $this->mArticle = $article; |
10 | | - } |
11 | | - |
12 | | - /** |
13 | | - * Attempt submission of the "Review Speedy" form. |
14 | | - * @param $article Article object being reviewed |
15 | | - */ |
16 | | - public function submit( ) { |
17 | | - global $wgUser,$wgOut,$wgRequest; |
18 | | - |
19 | | - $article = $this->mArticle; |
20 | | - |
21 | | - $token = $wgRequest->getText( 'wpEditToken' ); |
22 | | - |
23 | | - if (!$wgUser->matchEditToken( $token )) { |
24 | | - return false; |
25 | | - } |
26 | | - |
27 | | - // Process the action |
28 | | - $action = $wgRequest->getVal( 'wpSpeedyAction' ); |
29 | | - $processed = true; |
30 | | - $dqi = DeleteQueueItem::newFromArticle( $article ); |
31 | | - $newQueue = $wgRequest->getVal( 'wpSpeedyRequeue' ); |
32 | | - |
33 | | - $lp = new LogPage( 'delete' ); |
34 | | - $reason = $wgRequest->getText( 'wpReason' ); |
35 | | - |
36 | | - // Check the action against the list |
37 | | - list($enabledActions) = $this->availableActions(); |
38 | | - if ( !in_array( $action,$enabledActions ) && ( $action != 'requeue' || !in_array( "requeue-$newQueue", $enabledActions ) ) ) { |
39 | | - return wfMsg( 'deletequeue-review-actiondenied' ); |
40 | | - } |
41 | | - |
42 | | - $queue = $dqi->getQueue( ); |
43 | | - |
44 | | - // Transaction |
45 | | - $dbw = wfGetDB( DB_MASTER ); |
46 | | - $dbw->begin(); |
47 | | - |
48 | | - switch ($action) { |
49 | | - case 'delete': |
50 | | - $article->doDelete( $dqi->getQueue() ); |
51 | | - $processed = true; |
52 | | - break; |
53 | | - case 'change': |
54 | | - list($reason1,$reason2) = array($wgRequest->getText( 'wpSpeedyNewReason' ), $wgRequest->getText( 'wpSpeedyNewExtra' ) ); |
55 | | - $reason = DeleteQueueInterface::formatReason( $reason1, $reason2 ); |
56 | | - $article->doDelete( $reason ); |
57 | | - $processed = true; |
58 | | - break; |
59 | | - case 'dequeue': |
60 | | - $lp->addEntry( 'dequeue', $article->mTitle, $reason, $queue ); |
61 | | - $processed = true; |
62 | | - break; |
63 | | - case 'requeue': |
64 | | - $lp->addEntry( 'requeue', $article->mTitle, $reason, array(wfMsgForContent("deletequeue-queue-$queue"), wfMsgForContent( "deletequeue-queue-{$newQueue}" )) ); |
65 | | - |
66 | | - list($reason1,$reason2) = array($wgRequest->getText( 'wpSpeedyNewReason' ), $wgRequest->getText( 'wpSpeedyNewExtra' ) ); |
67 | | - $newReason = DeleteQueueInterface::formatReason( $reason1, $reason2 ); |
68 | | - |
69 | | - $dqi->setQueue( $newQueue, $reason ); |
70 | | - $processed = false; |
71 | | - break; |
72 | | - default: |
73 | | - // Invalid action |
74 | | - $dbw->commit(); |
75 | | - return wfMsg( 'deletequeue-review-badaction' );; |
76 | | - } |
77 | | - |
78 | | - if ($processed) { |
79 | | - // Delete from the DB |
80 | | - $dqi->deQueue( ); |
81 | | - |
82 | | - // Redirect to the page |
83 | | - $wgOut->redirect( $article->mTitle->getLocalURL() ); |
84 | | - |
85 | | - // Commit transaction |
86 | | - $dbw->commit(); |
87 | | - |
88 | | - return true; |
89 | | - } |
90 | | - |
91 | | - $dbw->commit(); |
92 | | - |
93 | | - return true; |
94 | | - } |
95 | | - |
96 | | - /** |
97 | | - * Process the "Review Speedy" action |
98 | | - * @param $article Article object being reviewed |
99 | | - */ |
100 | | - public function form( ) { |
101 | | - global $wgOut,$wgScript,$wgUser,$wgRequest; |
102 | | - |
103 | | - $article = $this->mArticle; |
104 | | - $dqi = DeleteQueueItem::newFromArticle( $article ); |
105 | | - $queue = $dqi->getQueue(); |
106 | | - |
107 | | - if (!$queue) { |
108 | | - // Idiot... |
109 | | - $wgOut->addWikiMsg( 'deletequeue-notqueued' ); |
110 | | - return; |
111 | | - } |
112 | | - |
113 | | - // Check permissions |
114 | | - $editErrors = $article->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
115 | | - $nomErrors = $article->mTitle->getUserPermissionsErrors( "$queue-review", $wgUser ); |
116 | | - |
117 | | - if (count(array_merge($editErrors,$nomErrors))) { |
118 | | - // Permissions errors. |
119 | | - if (count($editErrors)) { |
120 | | - $editError = $wgOut->formatPermissionsErrorMessage( $editErrors, 'edit' ); |
121 | | - $nomErrors[] = array( 'deletequeue-permissions-noedit', $editError ); |
122 | | - } |
123 | | - |
124 | | - $wgOut->showPermissionsErrorPage( $nomErrors, "$queue-review" ); |
125 | | - return; |
126 | | - } |
127 | | - |
128 | | - list ($enabledActions, $disabledActions) = $this->availableActions(); |
129 | | - |
130 | | - $haveRequeueOption = false; |
131 | | - |
132 | | - $shownActions = array_merge( array_keys( $disabledActions ), $enabledActions ); |
133 | | - |
134 | | - foreach( $shownActions as $val ) { |
135 | | - if (strpos($val,'requeue') == 0) { |
136 | | - $haveRequeueOption = true; |
137 | | - } |
138 | | - } |
139 | | - |
140 | | - if (($error = $this->submit( $article )) === true) { |
141 | | - $wgOut->setPageTitle( wfMsg( "deletequeue-review-success-title" ) ); |
142 | | - $wgOut->addWikiMsg( "deletequeue-review-success" ); |
143 | | - return; |
144 | | - } |
145 | | - |
146 | | - $wgOut->setPageTitle( wfMsg( "deletequeue-review$queue-title", $article->mTitle->getPrefixedText() ) ); |
147 | | - |
148 | | - $discussionPage = ($queue == 'deletediscuss') ? $dqi->getDiscussionPage()->mTitle->getPrefixedText() : null; |
149 | | - |
150 | | - $wgOut->addWikiMsg( "deletequeue-review$queue-text", $article->mTitle->getPrefixedText(), $discussionPage ); |
151 | | - |
152 | | - // Cautions if there's an objection |
153 | | - if (count($dqi->mVotesObject)>0) { |
154 | | - $wgOut->addWikiMsg( "deletequeue-review-objections", count($dqi->mVotesObject) ); |
155 | | - } |
156 | | - |
157 | | - if ($error) { |
158 | | - $wgOut->addHTML( '<p>'.$error.'</p>' ); |
159 | | - } |
160 | | - |
161 | | - // Details of nomination |
162 | | - $wgOut->addHTML( Xml::openElement( 'fieldset' ) . Xml::element( 'legend', array(), wfMsg( 'deletequeue-review-original' ) ) ); |
163 | | - $wgOut->addWikitext( $dqi->getReason() ); |
164 | | - $wgOut->addHTML( Xml::closeElement( 'fieldset' ) ); |
165 | | - |
166 | | - $output = ''; |
167 | | - |
168 | | - // Give the user options |
169 | | - $option_selection = ''; |
170 | | - |
171 | | - //// Action radio buttons |
172 | | - // Accept the nomination as-is |
173 | | - $accept = Xml::radioLabel( wfMsg( 'deletequeue-review-delete' ), 'wpSpeedyAction', 'delete', 'mw-review-accept' ); |
174 | | - $option_selection .= $this->getActionOrError( 'delete', $accept, null, Xml::tags( 'li', array(), '$1' ) ); |
175 | | - |
176 | | - // Accept nomination, but with a different reasoning. |
177 | | - $change_option = Xml::radioLabel( wfMsg( 'deletequeue-review-change' ), 'wpSpeedyAction', 'change', 'mw-review-change' ); |
178 | | - $change_fields = array(); |
179 | | - $change_fields['deletequeue-review-newreason'] = Xml::listDropDown( 'wpSpeedyNewReason', DeleteQueueInterface::getReasonList( $queue ), wfMsg('deletequeue-delnom-otherreason') ); |
180 | | - $change_fields['deletequeue-review-newextra'] = Xml::input( 'wpSpeedyNewExtra', 45, '' ); |
181 | | - $change_option .= Xml::buildForm( $change_fields ); |
182 | | - $option_selection .= $this->getActionOrError( 'delete', $change_option, wfMsgExt('deletequeue-review-change', array('parse') ), Xml::tags( 'li', array(), '$1' ) ); |
183 | | - |
184 | | - // Reject nomination, queue into a different deletion queue. |
185 | | - if ($haveRequeueOption) { |
186 | | - $requeue_option = Xml::radioLabel( wfMsg( 'deletequeue-review-requeue' ), 'wpSpeedyAction', 'requeue', 'mw-review-requeue' ); |
187 | | - $new_queues = array('prod', 'deletediscuss'); |
188 | | - $requeue_queues = ''; |
189 | | - foreach( $new_queues as $option ) { |
190 | | - $this_queue = Xml::radioLabel( wfMsg( "deletequeue-queue-$option" ), 'wpSpeedyRequeue', $option, "mw-review-requeue-$option" ); |
191 | | - $disabledMsg = wfMsgExt( "deletequeue-requeuedisabled", array( 'parseinline' ), array( wfMsgNoTrans( "deletequeue-queue-$option" ) ) ); |
192 | | - |
193 | | - $requeue_queues .= $this->getActionOrError( "requeue-$option", $this_queue, $disabledMsg, Xml::tags( 'li', array(), '$1' ) ); |
194 | | - } |
195 | | - $requeue_option .= Xml::tags( 'ul', array(), $requeue_queues ); |
196 | | - |
197 | | - $requeue_fields = array(); |
198 | | - $requeue_fields['deletequeue-review-newreason'] = Xml::listDropDown( 'wpSpeedyNewReason', DeleteQueueInterface::getReasonList( 'generic' ), wfMsg("deletequeue-delnom-otherreason") ); |
199 | | - $requeue_fields['deletequeue-review-newextra'] = Xml::input( 'wpSpeedyNewExtra', 45, '' ); |
200 | | - $requeue_option .= Xml::buildForm( $requeue_fields ); |
201 | | - |
202 | | - $option_selection .= Xml::tags( 'li', array(), $requeue_option ); |
203 | | - } |
204 | | - |
205 | | - // Reject nomination outright. |
206 | | - $dq = Xml::radioLabel( wfMsg( 'deletequeue-review-dequeue' ), 'wpSpeedyAction', 'dequeue', 'mw-review-dequeue' ); |
207 | | - $option_selection .= $this->getActionOrError( 'dequeue', $dq, null, Xml::tags( 'li', array(), '$1' ) ); |
208 | | - |
209 | | - //// Convert to a list. |
210 | | - $option_selection = Xml::tags( 'ul', array(), $option_selection ); |
211 | | - |
212 | | - $option_selection = Xml::fieldset( wfMsg( 'deletequeue-review-action' ), $option_selection ); |
213 | | - |
214 | | - $output .= $option_selection; |
215 | | - |
216 | | - // Reason etc. |
217 | | - $fields = array( 'deletequeue-review-reason' => Xml::input( 'wpReason', 45, null ) ); |
218 | | - |
219 | | - $output .= Xml::buildForm( $fields, 'deletequeue-review-submit' ); |
220 | | - |
221 | | - // Form stuff |
222 | | - $output .= Xml::hidden( 'title', $article->mTitle->getPrefixedText() ); |
223 | | - $output .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ); |
224 | | - $output .= Xml::hidden( 'action', 'delreview' ); |
225 | | - $output = Xml::tags( 'form', array( 'action' => $article->mTitle->getLocalURL(), 'method' => 'POST' ), $output ); |
226 | | - |
227 | | - $wgOut->addHTML( $output ); |
228 | | - |
229 | | -// $article->showLogExtract( $wgOut ); |
230 | | - } |
231 | | - |
232 | | - /** Returns the action given in enabledText, a 'disabled' message, or nothing, depending on the status of the action. */ |
233 | | - public function getActionOrError($action, $enabledText, $disabledMsg = null, $wrapper = null) { |
234 | | - list ($enabled,$disabled) = $this->availableActions(); |
235 | | - |
236 | | - if (!$disabledMsg) { |
237 | | - $disabledMsg = wfMsgExt("deletequeue-review-$action", array('parse')); |
238 | | - } |
239 | | - |
240 | | - $data = ''; |
241 | | - |
242 | | - if (in_array($action,$enabled)) { |
243 | | - $data = $enabledText; |
244 | | - } elseif ( in_array( $action, array_keys( $disabled ) ) ) { |
245 | | - $msg = $disabled[$action]; |
246 | | - $msg .= "\n"; |
247 | | - $msg .= $disabledMsg; |
248 | | - $data = $msg; |
249 | | - } else { |
250 | | - } |
251 | | - |
252 | | - if ($wrapper && $data) { |
253 | | - $data = wfMsgReplaceArgs( $wrapper, array($data) ); |
254 | | - } |
255 | | - |
256 | | - return $data; |
257 | | - } |
258 | | - |
259 | | - /** |
260 | | - * Determines which queues can be sent to in review. |
261 | | - * @return Array First element is a simple list of ENABLED queues, |
262 | | - second is a list, key is queue name, value is a message explaining why |
263 | | - (already passed through wfMsg). Queues in neither are not displayed. |
264 | | - */ |
265 | | - public function availableActions( $user = null ) { |
266 | | - $article = $this->mArticle; |
267 | | - $dqi = DeleteQueueItem::newFromArticle( $article ); |
268 | | - $queue = $dqi->getQueue( ); |
269 | | - |
270 | | - if ($user === null) { |
271 | | - global $wgUser; |
272 | | - $user = $wgUser; |
273 | | - } |
274 | | - |
275 | | - $enabled = array(); |
276 | | - $disabled = array(); |
277 | | - |
278 | | - $userRoles = $dqi->getUserRoles( $user ); |
279 | | - $descriptiveRoles = array_map( array( 'DeleteQueueItem', 'getRoleDescription' ), $userRoles ); |
280 | | - $descriptiveRolesText = implode( ", ", $descriptiveRoles ); |
281 | | - |
282 | | - $enabled[] = 'endorse'; |
283 | | - $enabled[] = 'object'; |
284 | | - |
285 | | - // Speedy deletion |
286 | | - if ($queue == 'speedy') { |
287 | | - // All are unlocked if user is authed. |
288 | | - $enabled = array( 'delete', 'requeue-prod', 'requeue-deletediscuss', 'dequeue' ); |
289 | | - } elseif ($queue == 'prod') { |
290 | | - // Escalation by anybody |
291 | | - $enabled[] = 'requeue-deletediscuss'; |
292 | | - $enabled[] = 'dequeue'; |
293 | | - |
294 | | - $expiry = $dqi->getExpiry(); |
295 | | - $hasExpired = (time() > $expiry) ? true : false; |
296 | | - |
297 | | - // Handling of 'delete' |
298 | | - if (!$hasExpired) { // Hasn't expired yet, don't let them delete it. |
299 | | - $disabled['delete'] = wfMsgExt( 'deletequeue-actiondisabled-notexpired', array( 'parseinline' ) ); |
300 | | - } elseif (count($userRoles)) { |
301 | | - // Tell them they're involved. |
302 | | - $disabled['delete'] = wfMsgExt( 'deletequeue-actiondisabled-involved', array( 'parseinline' ), array( $descriptiveRolesText ) ); |
303 | | - } else { |
304 | | - // Allow uninvolved admins to delete expired prods |
305 | | - $enabled[] = 'delete'; |
306 | | - } |
307 | | - } elseif ($queue == 'deletediscuss') { |
308 | | - |
309 | | - $expiry = $dqi->getExpiry(); |
310 | | - $hasExpired = (time() > $expiry) ? true : false; |
311 | | - |
312 | | - if (!$hasExpired) { // Hasn't expired yet, don't let them delete it. |
313 | | - $disabled['delete'] = wfMsgExt( 'deletequeue-actiondisabled-notexpired', array( 'parseinline' ) ); |
314 | | - } elseif (count($userRoles)) { |
315 | | - // Tell them they're involved. |
316 | | - $disabled['delete'] = wfMsgExt( 'deletequeue-actiondisabled-involved', array( 'parseinline' ), array( $descriptiveRolesText ) ); |
317 | | - } else { |
318 | | - // An uninvolved admin wants to delete an expired proposed deletion. Kill it. |
319 | | - $enabled[] = 'delete'; |
320 | | - } |
321 | | - |
322 | | - $enabled[] = 'dequeue'; |
323 | | - } |
324 | | - |
325 | | - return array( $enabled, $disabled ); |
326 | | - } |
327 | | -} |
Index: trunk/extensions/DeleteQueue/DeleteQueue.hooks.php |
— | — | @@ -23,48 +23,32 @@ |
24 | 24 | |
25 | 25 | $selected = false; |
26 | 26 | |
27 | | - if (in_array( $action, array( 'delnom', 'delreview' ) ) ) { |
28 | | - $selected = true; |
29 | | - } |
30 | | - |
31 | 27 | wfLoadExtensionMessages( 'DeleteQueue' ); |
32 | 28 | |
33 | 29 | if ($queue == '') { |
34 | 30 | $actions['deletequeue'] = array( |
35 | 31 | 'text' => wfMsg('deletequeue-action'), |
36 | | - 'href' => $st->mTitle->getLocalUrl( 'action=deletequeue' ), |
37 | | - 'class' => $selected ? 'selected' : false, |
38 | | - ); |
| 32 | + 'href' => $st->mTitle->getLocalUrl( 'action=deletequeue' ) |
| 33 | + ); |
39 | 34 | } else { |
40 | | - if ( $wgUser->isAllowed( "$queue-review" ) ) { |
41 | | - $actions['delreview'] = array( |
42 | | - 'text' => wfMsg("deletequeue-review$queue-tab"), |
43 | | - 'href' => $st->mTitle->getLocalUrl( 'action=delreview' ), |
44 | | - 'class' => $selected ? 'selected' : false ); |
45 | | - } |
46 | | - |
47 | 35 | $actions['deletequeue'] = array( |
48 | 36 | 'text' => wfMsg('deletequeue-action-queued'), |
49 | | - 'href' => $st->mTitle->getLocalUrl( 'action=deletequeue' ), |
50 | | - 'class' => ($action == 'delvote') ? 'selected' : false ); |
| 37 | + 'href' => SpecialPage::getTitleFor( |
| 38 | + 'DeleteQueue', |
| 39 | + "case/".$dqi->getCaseID() )->getLocalURL() |
| 40 | + ); |
51 | 41 | } |
52 | 42 | |
53 | 43 | return true; |
54 | 44 | } |
55 | 45 | |
56 | 46 | public static function onUnknownAction( $action, $article ) { |
57 | | - if ( $action == 'delnom' ) { |
| 47 | + if ( $action == 'deletequeue' ) { |
58 | 48 | wfLoadExtensionMessages( 'DeleteQueue' ); |
59 | | - global $wgRequest; |
60 | | - $queue = $wgRequest->getVal( 'queue' ); |
61 | | - DeleteQueueInterface::processNominationAction( $article, $queue ); |
62 | | - |
63 | | - return false; |
64 | | - } elseif ( $action == 'deletequeue' ) { |
65 | | - wfLoadExtensionMessages( 'DeleteQueue' ); |
66 | 49 | global $wgOut; |
67 | 50 | |
68 | | - $wgOut->setPageTitle( wfMsg( 'deletequeue-action-title', $article->mTitle->getPrefixedText() ) ); |
| 51 | + $wgOut->setPageTitle( wfMsg( 'deletequeue-action-title', |
| 52 | + $article->mTitle->getPrefixedText() ) ); |
69 | 53 | |
70 | 54 | $dqi = DeleteQueueItem::newFromArticle( $article ); |
71 | 55 | |
— | — | @@ -75,24 +59,6 @@ |
76 | 60 | $wgOut->addWikiMsg( 'deletequeue-action-text-queued' ); |
77 | 61 | } |
78 | 62 | return false; |
79 | | - } elseif ( $action == 'delreview' ) { |
80 | | - wfLoadExtensionMessages( 'DeleteQueue' ); |
81 | | - |
82 | | - $rf = new DeleteQueueReviewForm($article); |
83 | | - $rf->form(); |
84 | | - |
85 | | - return false; |
86 | | - } elseif ($action == 'delvote') { |
87 | | - wfLoadExtensionMessages( 'DeleteQueue' ); |
88 | | - |
89 | | - DeleteQueueInterface::processVoteAction( $article ); |
90 | | - return false; |
91 | | - } elseif ($action == 'delviewvotes') { |
92 | | - wfLoadExtensionMessages( 'DeleteQueue' ); |
93 | | - |
94 | | - DeleteQueueInterface::showVotes( $article ); |
95 | | - |
96 | | - return false; |
97 | 63 | } |
98 | 64 | |
99 | 65 | return true; |
Index: trunk/extensions/DeleteQueue/DeleteQueue.i18n.php |
— | — | @@ -183,6 +183,18 @@ |
184 | 184 | 'deletequeue-list-header-votes' => 'Endorsements and objections', |
185 | 185 | 'deletequeue-list-header-expiry' => 'Expiry', |
186 | 186 | 'deletequeue-list-header-discusspage' => 'Discussion page', |
| 187 | + |
| 188 | + // Case view. |
| 189 | + 'deletequeue-case-intro' => "This page lists information on a specific deletion case.", |
| 190 | + 'deletequeue-list-header-reason' => 'Reason for deletion', |
| 191 | + 'deletequeue-case-votes' => 'List of votes', |
| 192 | + 'deletequeue-case-title' => "Deletion case details", |
| 193 | + 'deletequeue-case-details' => 'Basic details', |
| 194 | + 'deletequeue-case-page' => 'Page:', |
| 195 | + 'deletequeue-case-reason' => 'Reason:', |
| 196 | + 'deletequeue-case-expiry' => 'Expiry:', |
| 197 | + 'deletequeue-case-votes' => 'Endorsements/objections:', |
| 198 | + 'deletequeue-case-needs-review' => 'This case requires [[$1|review]].', |
187 | 199 | ); |
188 | 200 | |
189 | 201 | /** Message documentation (Message documentation) |
— | — | @@ -217,7 +229,7 @@ |
218 | 230 | 'deletequeue-list-search' => '{{Identical|Search}}', |
219 | 231 | 'deletequeue-list-header-page' => '{{Identical|Page}}', |
220 | 232 | 'deletequeue-list-header-queue' => '{{Identical|Queue}}', |
221 | | - 'deletequeue-list-header-expiry' => '{{Identical|Expiry}}', |
| 233 | + 'deletequeue-list-header-expiry' => '{{Identical|Expiry}}', |
222 | 234 | ); |
223 | 235 | |
224 | 236 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/DeleteQueue/DeleteQueueItem.php |
— | — | @@ -42,6 +42,25 @@ |
43 | 43 | |
44 | 44 | return $item; |
45 | 45 | } |
| 46 | + |
| 47 | + static function newFromId( $id ) { |
| 48 | + $item = new DeleteQueueItem(); |
| 49 | + $dbr = wfGetDB( DB_SLAVE ); |
| 50 | + |
| 51 | + $row = $dbr->selectRow( 'delete_queue', |
| 52 | + '*', |
| 53 | + array( 'dq_case' => $id ), |
| 54 | + __METHOD__ |
| 55 | + ); |
| 56 | + |
| 57 | + if (!$row) { |
| 58 | + return null; |
| 59 | + } |
| 60 | + |
| 61 | + $item->loadFromRow( $row ); |
| 62 | + |
| 63 | + return $item; |
| 64 | + } |
46 | 65 | |
47 | 66 | /** |
48 | 67 | * Load the deletion queue item for a given deletion discussion page. |
— | — | @@ -51,9 +70,20 @@ |
52 | 71 | $item = new DeleteQueueItem(); |
53 | 72 | |
54 | 73 | $dbr = wfGetDB( DB_SLAVE ); |
55 | | - $row = $dbr->selectRow( 'delete_queue', '*', array( 'dq_discussionpage' => $page->mTitle->getArticleID() ), __METHOD__ ); |
| 74 | + $row = $dbr->selectRow( 'delete_queue', |
| 75 | + '*', |
| 76 | + array( |
| 77 | + 'dq_discussionpage' => $page->mTitle->getArticleID() |
| 78 | + ), |
| 79 | + __METHOD__ |
| 80 | + ); |
| 81 | + |
| 82 | + if ( !$row ) { |
| 83 | + return null; |
| 84 | + } |
56 | 85 | |
57 | | - wfDebugLog( 'deletequeue', "Got delete_queue row for discussion page ".$page->mTitle->getArticleID() ); |
| 86 | + wfDebugLog( 'deletequeue', |
| 87 | + "Got delete_queue row for discussion page " . $page->mTitle->getArticleID() ); |
58 | 88 | |
59 | 89 | $item->loadFromRow( $row ); |
60 | 90 | |
— | — | @@ -67,9 +97,17 @@ |
68 | 98 | protected function getRow( $useMaster ) { |
69 | 99 | $dbr = wfGetDB( $useMaster ? DB_MASTER : DB_SLAVE ); |
70 | 100 | |
71 | | - $row = $this->mRow = $dbr->selectRow( 'delete_queue', '*', array( 'dq_page' => $this->mArticleID, 'dq_active' => 1 ), __METHOD__ ); |
| 101 | + $row = $this->mRow = $dbr->selectRow( |
| 102 | + 'delete_queue', |
| 103 | + '*', |
| 104 | + array( |
| 105 | + 'dq_page' => $this->mArticleID, |
| 106 | + 'dq_active' => 1 |
| 107 | + ), |
| 108 | + __METHOD__ ); |
72 | 109 | |
73 | | - wfDebugLog( 'deletequeue', "Got delete_queue row for article {$this->mArticleID}" ); |
| 110 | + wfDebugLog( 'deletequeue', |
| 111 | + "Got delete_queue row for article {$this->mArticleID}" ); |
74 | 112 | |
75 | 113 | return $row; |
76 | 114 | } |
— | — | @@ -105,7 +143,8 @@ |
106 | 144 | $this->mLoadedFromMaster = $store || $useMaster; |
107 | 145 | |
108 | 146 | if ( $store ) { |
109 | | - wfDebugLog( 'deletequeue', "Storing DeleteQueue item for article {$this->mArticleID} to cache." ); |
| 147 | + wfDebugLog( 'deletequeue', |
| 148 | + "Storing DeleteQueue item for article {$this->mArticleID} to cache." ); |
110 | 149 | // Store to cache |
111 | 150 | global $wgMemc; |
112 | 151 | |
— | — | @@ -120,7 +159,11 @@ |
121 | 160 | * Get the key used to store the data in memcached |
122 | 161 | */ |
123 | 162 | protected function cacheKey() { |
124 | | - return wfMemcKey( 'DeleteQueueItem', 'Article', $this->mArticleID, self::CACHE_VERSION ); |
| 163 | + return wfMemcKey( 'DeleteQueueItem', |
| 164 | + 'Article', |
| 165 | + $this->mArticleID, |
| 166 | + self::CACHE_VERSION |
| 167 | + ); |
125 | 168 | } |
126 | 169 | |
127 | 170 | /** |
— | — | @@ -135,7 +178,8 @@ |
136 | 179 | |
137 | 180 | $this->postLoad(); |
138 | 181 | |
139 | | - wfDebugLog( 'deletequeue', "Loded DeleteQueue item for article {$this->mArticleID} from cache." ); |
| 182 | + wfDebugLog( 'deletequeue', |
| 183 | + "Loded DeleteQueue item for article {$this->mArticleID} from cache." ); |
140 | 184 | } |
141 | 185 | |
142 | 186 | /** |
— | — | @@ -149,12 +193,19 @@ |
150 | 194 | if (!$row) { |
151 | 195 | $this->mQueue = ''; |
152 | 196 | $this->mMainLoaded = true; |
153 | | - wfDebugLog( 'deletequeue', "Loaded empty DeleteQueue item for article {$this->mArticleID} from DB." ); |
| 197 | + wfDebugLog( 'deletequeue', |
| 198 | + "Loaded empty DeleteQueue item for article {$this->mArticleID} from DB." ); |
154 | 199 | return; |
155 | 200 | } |
156 | 201 | |
157 | 202 | // Stuff that can be loaded straight in. |
158 | | - $loadVars = array( 'dq_queue' => 'mQueue', 'dq_case' => 'mCaseID', 'dq_reason' => 'mReason', 'dq_discussionpage' => 'mDiscussionPageID', 'dq_page' => 'mArticleID' ); |
| 203 | + $loadVars = array( |
| 204 | + 'dq_queue' => 'mQueue', |
| 205 | + 'dq_case' => 'mCaseID', |
| 206 | + 'dq_reason' => 'mReason', |
| 207 | + 'dq_discussionpage' => 'mDiscussionPageID', |
| 208 | + 'dq_page' => 'mArticleID' |
| 209 | + ); |
159 | 210 | |
160 | 211 | foreach( $loadVars as $col => $var ) { |
161 | 212 | $this->$var = $row->$col; |
— | — | @@ -165,14 +216,24 @@ |
166 | 217 | |
167 | 218 | $this->postLoad(); |
168 | 219 | |
169 | | - wfDebugLog( 'deletequeue', "Loded DeleteQueue item for article {$this->mArticleID} from DB." ); |
| 220 | + wfDebugLog( 'deletequeue', |
| 221 | + "Loded DeleteQueue item for article {$this->mArticleID} from DB." ); |
170 | 222 | |
171 | 223 | $this->mMainLoaded = true; |
172 | 224 | } |
173 | 225 | |
174 | 226 | /** Reset all variables */ |
175 | 227 | protected function reset() { |
176 | | - $vars = array( 'mCaseID', 'mReason', 'mTimestamp', 'mExpiry', 'mDiscussionPage', 'mRow', 'mEndorsements', 'mObjections' ); |
| 228 | + $vars = array( |
| 229 | + 'mCaseID', |
| 230 | + 'mReason', |
| 231 | + 'mTimestamp', |
| 232 | + 'mExpiry', |
| 233 | + 'mDiscussionPage', |
| 234 | + 'mRow', |
| 235 | + 'mEndorsements', |
| 236 | + 'mObjections' |
| 237 | + ); |
177 | 238 | |
178 | 239 | foreach( $vars as $var ) { |
179 | 240 | $this->$var = null; |
— | — | @@ -195,7 +256,10 @@ |
196 | 257 | |
197 | 258 | $users = array(); |
198 | 259 | $dbr = wfGetDB( DB_SLAVE ); |
199 | | - $res = $dbr->select( 'delete_queue_role', '*', array( 'dqr_case' => $case_id ), __METHOD__ ); |
| 260 | + $res = $dbr->select( 'delete_queue_role', |
| 261 | + '*', |
| 262 | + array( 'dqr_case' => $case_id ), |
| 263 | + __METHOD__ ); |
200 | 264 | |
201 | 265 | while ($row = $dbr->fetchObject( $res )) { |
202 | 266 | $users[] = array($row->dqr_user_text, $row->dqr_type); |
— | — | @@ -221,12 +285,20 @@ |
222 | 286 | $this->mVotes = array(); |
223 | 287 | |
224 | 288 | $dbr = wfGetDB( DB_SLAVE ); |
225 | | - $res = $dbr->select( 'delete_queue_vote', '*', array( 'dqv_case' => $case_id ), __METHOD__, array( 'ORDER BY' => 'dqv_timestamp DESC' ) ); |
| 289 | + $res = $dbr->select( 'delete_queue_vote', |
| 290 | + '*', |
| 291 | + array( 'dqv_case' => $case_id ), |
| 292 | + __METHOD__, |
| 293 | + array( 'ORDER BY' => 'dqv_timestamp DESC' ) |
| 294 | + ); |
226 | 295 | |
227 | 296 | while ($row = $dbr->fetchObject( $res )) { |
228 | 297 | $this_vote = array(); |
229 | 298 | // Load simple stuff |
230 | | - $row_mappings = array( 'dqv_user_text' => 'user', 'dqv_comment' => 'comment', 'dqv_current' => 'current' ); |
| 299 | + $row_mappings = array( 'dqv_user_text' => 'user', |
| 300 | + 'dqv_comment' => 'comment', |
| 301 | + 'dqv_current' => 'current' |
| 302 | + ); |
231 | 303 | |
232 | 304 | foreach( $row_mappings as $col => $field ) { |
233 | 305 | $this_vote[$field] = $row->$col; |
— | — | @@ -313,7 +385,18 @@ |
314 | 386 | } |
315 | 387 | |
316 | 388 | $dbw = wfGetDB( DB_MASTER ); |
317 | | - $dbw->replace( 'delete_queue_role', array( array('dqr_case', 'dqr_user', 'dqr_type') ), array( 'dqr_case' => $this->getCaseID(), 'dqr_user' => $user->getId(), 'dqr_user_text' => $user->getName(), 'dqr_type' => $role ), __METHOD__ ); |
| 389 | + $dbw->replace( 'delete_queue_role', |
| 390 | + array( |
| 391 | + array('dqr_case', 'dqr_user', 'dqr_type') |
| 392 | + ), |
| 393 | + array( |
| 394 | + 'dqr_case' => $this->getCaseID(), |
| 395 | + 'dqr_user' => $user->getId(), |
| 396 | + 'dqr_user_text' => $user->getName(), |
| 397 | + 'dqr_type' => $role |
| 398 | + ), |
| 399 | + __METHOD__ |
| 400 | + ); |
318 | 401 | |
319 | 402 | $this->purge(); |
320 | 403 | } |
— | — | @@ -338,12 +421,24 @@ |
339 | 422 | $dbw->begin(); |
340 | 423 | |
341 | 424 | // Mark old votes as non-current |
342 | | - $dbw->update( 'delete_queue_vote', array( 'dqv_current' => 0 ), array( 'dqv_case' => $this->getCaseID(), 'dqv_user' => $user->getId() ), __METHOD__ ); |
| 425 | + $dbw->update( |
| 426 | + 'delete_queue_vote', |
| 427 | + array( 'dqv_current' => 0 ), |
| 428 | + array( |
| 429 | + 'dqv_case' => $this->getCaseID(), |
| 430 | + 'dqv_user' => $user->getId() |
| 431 | + ), |
| 432 | + __METHOD__ |
| 433 | + ); |
343 | 434 | |
344 | 435 | // Add new vote |
345 | 436 | $dbw->insert( 'delete_queue_vote', |
346 | | - array( 'dqv_case' => $this->getCaseID(), 'dqv_user' => $user->getId(), 'dqv_user_text' => $user->getName(), 'dqv_comment' => $comments, |
347 | | - 'dqv_endorse' => ($action == 'endorse'), 'dqv_timestamp' => $dbw->timestamp( wfTimestampNow() ) |
| 437 | + array( 'dqv_case' => $this->getCaseID(), |
| 438 | + 'dqv_user' => $user->getId(), |
| 439 | + 'dqv_user_text' => $user->getName(), |
| 440 | + 'dqv_comment' => $comments, |
| 441 | + 'dqv_endorse' => ($action == 'endorse'), |
| 442 | + 'dqv_timestamp' => $dbw->timestamp( wfTimestampNow() ) |
348 | 443 | ), __METHOD__ ); |
349 | 444 | |
350 | 445 | // Add user as voter |
— | — | @@ -388,7 +483,12 @@ |
389 | 484 | |
390 | 485 | // Create the page. |
391 | 486 | $discusspage = new Article( $title ); |
392 | | - $discusspage->doEdit( wfMsgForContent('deletequeue-discusscreate-text', $base, $reason) . ' ~~~~', wfMsgForContent('deletequeue-discusscreate-summary', $base), EDIT_NEW | EDIT_SUPPRESS_RC ); |
| 487 | + $discusspage->doEdit( |
| 488 | + wfMsgForContent('deletequeue-discusscreate-text', $base, $reason) |
| 489 | + . ' ~~~~', |
| 490 | + wfMsgForContent('deletequeue-discusscreate-summary', $base), |
| 491 | + EDIT_NEW | EDIT_SUPPRESS_RC |
| 492 | + ); |
393 | 493 | |
394 | 494 | $row['dq_discussionpage'] = $discusspage->getId(); |
395 | 495 | } |
— | — | @@ -427,7 +527,11 @@ |
428 | 528 | if (!$this->getCaseID()) |
429 | 529 | return; // Case doesn't exist anymore. |
430 | 530 | |
431 | | - $dbw->update( 'delete_queue', array( 'dq_active' => 0 ), array( 'dq_case' => $this->getCaseID() ), __METHOD__ ); |
| 531 | + $dbw->update( 'delete_queue', |
| 532 | + array( 'dq_active' => 0 ), |
| 533 | + array( 'dq_case' => $this->getCaseID() ), |
| 534 | + _METHOD__ |
| 535 | + ); |
432 | 536 | |
433 | 537 | $this->purge(); |
434 | 538 | } |
— | — | @@ -487,20 +591,40 @@ |
488 | 592 | return wfMsg( "deletequeue-role-$role" ); |
489 | 593 | } |
490 | 594 | |
491 | | - function getQueue() { return $this->lazyAccessor( 'mQueue' ); } |
492 | | - function getCaseID() { return $this->lazyAccessor( 'mCaseID' ); } |
493 | | - function getReason() { return $this->lazyAccessor( 'mReason' ); } |
494 | | - function getTimestamp() { return $this->lazyAccessor( 'mTimestamp' ); } |
495 | | - function getExpiry() { return $this->lazyAccessor( 'mExpiry' ); } |
496 | | - function getDiscussionPage() { return $this->lazyAccessor( 'mDiscussionPage' ); } |
497 | | - function getArticle() { return $this->lazyAccessor( 'mArticle' ); } |
498 | | - function getArticleID() { return $this->lazyAccessor( 'mArticleID' ); } |
499 | | - function isQueued() { return $this->getQueue() != 'null'; } |
500 | | - function getVotes() { return $this->lazyAccessor( 'mVotes', 'loadVotes' ); } |
501 | | - function getEndorsements() { return $this->lazyAccessor( 'mVotesEndorse', 'loadVotes' ); } |
502 | | - function getObjections() { return $this->lazyAccessor( 'mVotesObject', 'loadVotes' ); } |
503 | | - function getObjectionCount() { return count($this->getObjections()); } |
504 | | - function getEndorsementCOunt() { return count($this->getEndorsements()); } |
| 595 | + function getQueue() |
| 596 | + { return $this->lazyAccessor( 'mQueue' ); } |
| 597 | + function getCaseID() |
| 598 | + { return $this->lazyAccessor( 'mCaseID' ); } |
| 599 | + function getReason() |
| 600 | + { return $this->lazyAccessor( 'mReason' ); } |
| 601 | + function getTimestamp() |
| 602 | + { return $this->lazyAccessor( 'mTimestamp' ); } |
| 603 | + function getExpiry() |
| 604 | + { return $this->lazyAccessor( 'mExpiry' ); } |
| 605 | + function getDiscussionPage() |
| 606 | + { return $this->lazyAccessor( 'mDiscussionPage' ); } |
| 607 | + function getArticle() |
| 608 | + { return $this->lazyAccessor( 'mArticle' ); } |
| 609 | + function getArticleID() |
| 610 | + { return $this->lazyAccessor( 'mArticleID' ); } |
| 611 | + function isQueued() |
| 612 | + { return $this->getQueue() != 'null'; } |
| 613 | + function getVotes() |
| 614 | + { return $this->lazyAccessor( 'mVotes', 'loadVotes' ); } |
| 615 | + function getEndorsements() |
| 616 | + { return $this->lazyAccessor( 'mVotesEndorse', 'loadVotes' ); } |
| 617 | + function getObjections() |
| 618 | + { return $this->lazyAccessor( 'mVotesObject', 'loadVotes' ); } |
| 619 | + function getObjectionCount() |
| 620 | + { return count($this->getObjections()); } |
| 621 | + function getEndorsementCount() |
| 622 | + { return count($this->getEndorsements()); } |
| 623 | + |
| 624 | + function formatVoteCount() { |
| 625 | + return wfMsg( 'deletequeue-list-votecount', |
| 626 | + $this->getActiveEndorseCount(), |
| 627 | + $this->getActiveObjectCount() ); |
| 628 | + } |
505 | 629 | |
506 | 630 | static function filterActiveVotes($votes) { |
507 | 631 | $return = array(); |
— | — | @@ -514,8 +638,12 @@ |
515 | 639 | return $return; |
516 | 640 | } |
517 | 641 | |
518 | | - function getActiveObjections() { return self::filterActiveVotes( $this->getObjections() ); } |
519 | | - function getActiveEndorsements() { return self::filterActiveVotes( $this->getEndorsements() ); } |
520 | | - function getActiveEndorseCount() { return count($this->getActiveEndorsements()); } |
521 | | - function getActiveObjectCount() { return count($this->getActiveObjections()); } |
| 642 | + function getActiveObjections() |
| 643 | + { return self::filterActiveVotes( $this->getObjections() ); } |
| 644 | + function getActiveEndorsements() |
| 645 | + { return self::filterActiveVotes( $this->getEndorsements() ); } |
| 646 | + function getActiveEndorseCount() |
| 647 | + { return count($this->getActiveEndorsements()); } |
| 648 | + function getActiveObjectCount() |
| 649 | + { return count($this->getActiveObjections()); } |
522 | 650 | } |
Index: trunk/extensions/DeleteQueue/DeleteQueue.php |
— | — | @@ -35,9 +35,16 @@ |
36 | 36 | $wgAutoloadClasses['SpecialDeleteQueue'] = $dir.'SpecialDeleteQueue.php'; |
37 | 37 | $wgAutoloadClasses['DeleteQueueHooks'] = $dir.'DeleteQueue.hooks.php'; |
38 | 38 | $wgAutoloadClasses['DeleteQueueInterface'] = $dir.'DeleteQueueInterface.php'; |
39 | | -$wgAutoloadClasses['DeleteQueueReviewForm'] = $dir.'ReviewForm.php'; |
40 | 39 | $wgAutoloadClasses['DeleteQueueItem'] = $dir."DeleteQueueItem.php"; |
41 | 40 | |
| 41 | +// Views |
| 42 | +$wgAutoloadClasses['DeleteQueueView'] = "$dir/Views/DeleteQueueView.php"; |
| 43 | +$wgAutoloadClasses['DeleteQueueViewList'] = "$dir/Views/DeleteQueueViewList.php"; |
| 44 | +$wgAutoloadClasses['DeleteQueueViewNominate'] = "$dir/Views/DeleteQueueViewNominate.php"; |
| 45 | +$wgAutoloadClasses['DeleteQueueViewVote'] = "$dir/Views/DeleteQueueViewVote.php"; |
| 46 | +$wgAutoloadClasses['DeleteQueueViewCase'] = "$dir/Views/DeleteQueueViewCase.php"; |
| 47 | +$wgAutoloadClasses['DeleteQueueViewReview'] = "$dir/Views/DeleteQueueViewReview.php"; |
| 48 | + |
42 | 49 | $wgAvailableRights[] = 'speedy-nominate'; |
43 | 50 | $wgAvailableRights[] = 'speedy-review'; |
44 | 51 | $wgAvailableRights[] = 'prod-nominate'; |
— | — | @@ -64,3 +71,5 @@ |
65 | 72 | |
66 | 73 | $wgExtraNamespaces[140] = 'Deletion'; |
67 | 74 | define('NS_DELETION', 140); |
| 75 | + |
| 76 | +$wgDeleteQueueStyleVersion = 1; |
\ No newline at end of file |
Index: trunk/extensions/DeleteQueue/Views/DeleteQueueView.template.php |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if (!defined( 'MEDIAWIKI' ) ) { |
| 5 | + die; |
| 6 | +} |
| 7 | + |
| 8 | +class DeleteQueueViewX extends DeleteQueueView { |
| 9 | + function show( $params ) { |
| 10 | + global $wgOut; |
| 11 | + $wgOut->setPageTitle( '' ); |
| 12 | + } |
| 13 | +} |
\ No newline at end of file |
Index: trunk/extensions/DeleteQueue/Views/DeleteQueueViewNominate.php |
— | — | @@ -0,0 +1,147 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if (!defined( 'MEDIAWIKI' ) ) { |
| 5 | + die; |
| 6 | +} |
| 7 | + |
| 8 | +class DeleteQueueViewNominate extends DeleteQueueView { |
| 9 | + function show( $params ) { |
| 10 | + global $wgOut; |
| 11 | + |
| 12 | + // Just parse the details out. |
| 13 | + list( $action, $article_id, $queue ) = $params; |
| 14 | + |
| 15 | + $article = Article::newFromId( $article_id ); |
| 16 | + $this->process( $article, $queue ); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * Entry point for "nomination" forms. |
| 21 | + * @param $article The article object to nominate. |
| 22 | + * @param $queue The queue to nominate to. |
| 23 | + */ |
| 24 | + public function process( $article, $queue ) { |
| 25 | + global $wgOut,$wgScript,$wgUser,$wgRequest; |
| 26 | + |
| 27 | + // Check permissions |
| 28 | + $editErrors = |
| 29 | + $article->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
| 30 | + $nomErrors = |
| 31 | + $article->mTitle->getUserPermissionsErrors( "{$queue}-nominate", $wgUser ); |
| 32 | + |
| 33 | + if (count(array_merge($editErrors,$nomErrors))) { |
| 34 | + // Permissions errors. |
| 35 | + if (count($editErrors)) { |
| 36 | + $editError = $wgOut->formatPermissionsErrorMessage( $editErrors, 'edit' ); |
| 37 | + $nomErrors[] = array( 'deletequeue-permissions-noedit', $editError ); |
| 38 | + } |
| 39 | + |
| 40 | + $wgOut->showPermissionsErrorPage( $nomErrors, "{$queue}-nominate" ); |
| 41 | + if (isset($editError)) { |
| 42 | + $wgOut->addHTML( $editError ); |
| 43 | + } |
| 44 | + return; |
| 45 | + } |
| 46 | + |
| 47 | + $form = $this->buildForm( $article, $queue ); |
| 48 | + |
| 49 | + if ($form) { |
| 50 | + $wgOut->addHTML( $form ); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Generate a "deletion nomination" form. |
| 56 | + * @param $article Article object to nominate. |
| 57 | + */ |
| 58 | + public function buildForm( $article, $queue ) { |
| 59 | + global $wgOut,$wgScript,$wgUser,$wgRequest; |
| 60 | + |
| 61 | + // Check for submission |
| 62 | + if ( $this->trySubmit( $article, $queue ) ) { |
| 63 | + return; |
| 64 | + } |
| 65 | + |
| 66 | + $wgOut->setPageTitle( wfMsg( "deletequeue-$queue-title", |
| 67 | + $article->mTitle->getPrefixedText() ) ); |
| 68 | + $wgOut->addWikiMsg( "deletequeue-$queue-text", |
| 69 | + $article->mTitle->getPrefixedText() ); |
| 70 | + |
| 71 | + // Build deletion form. |
| 72 | + $fields = array(); |
| 73 | + $fields['deletequeue-delnom-reason'] = |
| 74 | + Xml::listDropDown( 'wpReason', |
| 75 | + DeleteQueueInterface::getReasonList( $queue ), |
| 76 | + wfMsg("deletequeue-delnom-otherreason") ); |
| 77 | + |
| 78 | + $fields['deletequeue-delnom-extra'] = Xml::input( 'wpExtra', 45 ); |
| 79 | + |
| 80 | + $article_id = $article->getId(); |
| 81 | + $title = $this->getTitle( "nominate/$article_id/$queue" ); |
| 82 | + |
| 83 | + $form = Xml::buildForm( $fields, "deletequeue-delnom-submit" ); |
| 84 | + $form .= Xml::hidden( 'title', $title->getPrefixedText() ); |
| 85 | + $form .= Xml::hidden( 'queue', $queue ); |
| 86 | + $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ); |
| 87 | + $form = Xml::tags( 'form', array( |
| 88 | + 'action' => $title->getLocalUrl(), |
| 89 | + 'method' => 'POST' |
| 90 | + ), $form ); |
| 91 | + |
| 92 | + $wgOut->addHTML( $form ); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Attempt to submit the propose deletion form. |
| 97 | + * @param $article Article object. |
| 98 | + * @param $action The action (speedynom, prod, etc) |
| 99 | + * @return Boolean Whether or not the submission was successful. |
| 100 | + */ |
| 101 | + public function trySubmit( $article, $queue ) { |
| 102 | + global $wgUser,$wgOut,$wgRequest; |
| 103 | + |
| 104 | + $token = $wgRequest->getText( 'wpEditToken' ); |
| 105 | + |
| 106 | + if (!$wgUser->matchEditToken( $token )) { |
| 107 | + return false; |
| 108 | + } |
| 109 | + |
| 110 | + // Import form data. |
| 111 | + $reason1 = $wgRequest->getText( 'wpReason' ); |
| 112 | + $reason2 = $wgRequest->getText( 'wpExtra' ); |
| 113 | + |
| 114 | + $reason = DeleteQueueInterface::formatReason( $reason1, $reason2 ); |
| 115 | + |
| 116 | + // Allow hooks to terminate |
| 117 | + $error = ''; |
| 118 | + if (!wfRunHooks( 'AbortDeleteQueueNominate', array($wgUser, $article, $queue, $reason, &$error) ) ) { |
| 119 | + $wgOut->addWikitext( $error ); |
| 120 | + return false; |
| 121 | + } |
| 122 | + |
| 123 | + // Transaction |
| 124 | + $dbw = wfGetDB( DB_MASTER ); |
| 125 | + $dbw->begin(); |
| 126 | + |
| 127 | + // Set in database. |
| 128 | + $dqi = DeleteQueueItem::newFromArticle( $article ); |
| 129 | + |
| 130 | + if ($dqi->getQueue()) { |
| 131 | + $dbw->rollback(); |
| 132 | + $wgOut->addWikiMsg( 'deletequeue-nom-alreadyqueued' ); |
| 133 | + return false; |
| 134 | + } |
| 135 | + |
| 136 | + $dqi->setQueue( $queue, $reason ); |
| 137 | + $dqi->addRole( 'nominator' ); |
| 138 | + |
| 139 | + $log = new LogPage( 'delete' ); |
| 140 | + $log->addEntry( "nominate", $article->mTitle, $reason, wfMsgNoTrans( 'deletequeue-queue-'.$queue) ); |
| 141 | + |
| 142 | + $dbw->commit(); |
| 143 | + |
| 144 | + $wgOut->redirect( $article->mTitle->getLocalUrl() ); |
| 145 | + |
| 146 | + return true; |
| 147 | + } |
| 148 | +} |
\ No newline at end of file |
Index: trunk/extensions/DeleteQueue/Views/DeleteQueueViewCase.php |
— | — | @@ -0,0 +1,150 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if (!defined( 'MEDIAWIKI' ) ) { |
| 5 | + die; |
| 6 | +} |
| 7 | + |
| 8 | +class DeleteQueueViewCase extends DeleteQueueView { |
| 9 | + function show( $params ) { |
| 10 | + global $wgOut, $wgUser, $wgLang; |
| 11 | + |
| 12 | + $dqi = DeleteQueueItem::newFromId( $params[1] ); |
| 13 | + |
| 14 | + if (!$dqi) { |
| 15 | + $wgOut->setPageTitle( wfMsg( 'deletequeue-case-no-case-title' ) ); |
| 16 | + $wgOut->addWikiMsg( 'deletequeue-case-no-case', $params[1] ); |
| 17 | + return; |
| 18 | + } |
| 19 | + |
| 20 | + $wgOut->setPageTitle( wfMsg( 'deletequeue-case-title' ) ); |
| 21 | + |
| 22 | + $wgOut->addWikiMsg( 'deletequeue-case-intro' ); |
| 23 | + |
| 24 | + if ( wfTimestamp( TS_UNIX, $dqi->getExpiry() ) < time() && |
| 25 | + $wgUser->isAllowed( $dqi->getQueue().'-review' ) |
| 26 | + ) { |
| 27 | + $wgOut->addWikiMsg( 'deletequeue-case-needs-review', |
| 28 | + $this->getTitle( "case/".$params[1]."/review" ) ); |
| 29 | + } |
| 30 | + |
| 31 | + // Show basic data |
| 32 | + $sk = $wgUser->getSkin(); |
| 33 | + $fields = array(); |
| 34 | + $fields['deletequeue-case-page'] = $sk->link( $this->getTitle() ); |
| 35 | + $fields['deletequeue-case-reason'] = |
| 36 | + DeleteQueueInterface::formatReason( null, $dqi->getReason() ); |
| 37 | + |
| 38 | + $expiry = $dqi->getExpiry(); |
| 39 | + if ($expiry) { |
| 40 | + $fields['deletequeue-case-expiry'] = $wgLang->timeanddate( $expiry ); |
| 41 | + } |
| 42 | + $fields['deletequeue-case-votes'] = $dqi->formatVoteCount(); |
| 43 | + |
| 44 | + $wgOut->addHTML( |
| 45 | + Xml::element( 'h2', null, wfMsg( 'deletequeue-case-details' ) ) . |
| 46 | + Xml::buildForm( $fields ) . |
| 47 | + Xml::element( 'h2', null, wfMsg( 'deletequeue-case-votes' ) ) |
| 48 | + ); |
| 49 | + $article = $dqi->getArticle(); |
| 50 | + $this->showVotes( $article, $dqi ); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Show current votes. |
| 55 | + * @param $article Article object to show votes for. |
| 56 | + */ |
| 57 | + public function showVotes( $article, $dqi ) { |
| 58 | + global $wgOut,$wgUser,$wgRequest,$wgLang; |
| 59 | + |
| 60 | + $case_id = $dqi->getCaseId(); |
| 61 | + $sk = $wgUser->getSkin(); |
| 62 | + $article_name = $article->mTitle->getPrefixedText(); |
| 63 | + |
| 64 | + $wgOut->addWikiMsg( 'deletequeue-showvotes-text', $article_name ); |
| 65 | + |
| 66 | + $restrict_type = $wgRequest->getText( 'votetype' ); |
| 67 | + |
| 68 | + if ($restrict_type == 'none' || !$restrict_type) { |
| 69 | + $restrict_type = ''; |
| 70 | + } else { |
| 71 | + $wgOut->setSubTitle( |
| 72 | + wfMsg( "deletequeue-showvotes-showingonly-$restrict_type" ) |
| 73 | + ); |
| 74 | + } |
| 75 | + |
| 76 | + // Add "view only X" links |
| 77 | + $restrictableActions = array( 'none', 'endorse', 'object' ); |
| 78 | + $restrictions = Xml::openElement( 'ul' ); |
| 79 | + foreach( $restrictableActions as $raction ) { |
| 80 | + $text = wfMsgExt( "deletequeue-showvotes-restrict-$raction", 'parseinline'); |
| 81 | + $link = $sk->link( |
| 82 | + $this->getTitle( "case/$case_id" ), |
| 83 | + $text, |
| 84 | + array(), |
| 85 | + array( 'votetype' => $raction ) |
| 86 | + ); |
| 87 | + $restrictions .= "\n<li>$link</li>"; |
| 88 | + } |
| 89 | + $restrictions .= Xml::closeElement( 'ul' ); |
| 90 | + |
| 91 | + $wgOut->addHTML( $restrictions ); |
| 92 | + |
| 93 | + // Sort votes by user. |
| 94 | + $votes = $dqi->getVotes(); |
| 95 | + |
| 96 | + $votesByUser = array(); |
| 97 | + |
| 98 | + foreach( $votes as $vote ) { |
| 99 | + $user = $vote['user']; |
| 100 | + |
| 101 | + if ($restrict_type && $restrict_type != $vote['type']) |
| 102 | + continue; |
| 103 | + |
| 104 | + if ( !isset( $votesByUser[$user] ) ) { |
| 105 | + $votesByUser[$user] = array(); |
| 106 | + } |
| 107 | + |
| 108 | + $votesByUser[$user][] = $vote; |
| 109 | + } |
| 110 | + |
| 111 | + // Link batch. |
| 112 | + $lb = new LinkBatch(); |
| 113 | + foreach( array_keys($votes) as $user ) { |
| 114 | + $lb->add( NS_USER, $user ); |
| 115 | + $lb->add( NS_USER_TALK, $user ); |
| 116 | + } |
| 117 | + |
| 118 | + $voteDisplay = array(); |
| 119 | + |
| 120 | + if ( count($votesByUser) == 0 ) { |
| 121 | + $suffix = $restrict_type ? "-$restrict_type" : ''; |
| 122 | + $wgOut->addWikiMsg( "deletequeue-showvotes-none$suffix" ); |
| 123 | + } |
| 124 | + |
| 125 | + // Display |
| 126 | + foreach( $votesByUser as $user => $votes ) { |
| 127 | + $id = User::idFromName($user); |
| 128 | + $user = $sk->userLink( $id, $user ) . ' ' . |
| 129 | + $sk->userToolLinks( $id, $user ); |
| 130 | + |
| 131 | + $userVotes = array(); |
| 132 | + |
| 133 | + foreach( $votes as $vote ) { |
| 134 | + $type = $vote['type']; |
| 135 | + $comment = $sk->commentBlock( $vote['comment'] ); |
| 136 | + $timestamp = $wgLang->timeanddate( $vote['timestamp'] ); |
| 137 | + $thisvote = wfMsgExt( "deletequeue-showvotes-vote-$type", array( 'parseinline', 'replaceafter' ), $timestamp, $comment ); |
| 138 | + |
| 139 | + if ($vote['current'] == 0) |
| 140 | + $thisvote = Xml::tags( 's', null, $thisvote ); |
| 141 | + |
| 142 | + $userVotes[] = Xml::tags( 'li', array( 'class' => "mw-deletequeue-vote-$type" ), $thisvote ); |
| 143 | + } |
| 144 | + |
| 145 | + $uv = $user . Xml::tags( 'ul', null, implode( "\n", $userVotes ) ); |
| 146 | + $voteDisplay[] = Xml::tags( 'li', null, $uv ); |
| 147 | + } |
| 148 | + |
| 149 | + $wgOut->addHTML( Xml::tags( 'ol', null, implode( "\n", $voteDisplay ) ) ); |
| 150 | + } |
| 151 | +} |
\ No newline at end of file |
Index: trunk/extensions/DeleteQueue/Views/DeleteQueueViewList.php |
— | — | @@ -0,0 +1,134 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if (!defined( 'MEDIAWIKI' ) ) { |
| 5 | + die; |
| 6 | +} |
| 7 | + |
| 8 | +class DeleteQueueViewList extends DeleteQueueView { |
| 9 | + public function show( $params ) { |
| 10 | + global $wgOut; |
| 11 | + |
| 12 | + wfLoadExtensionMessages('DeleteQueue'); |
| 13 | + $wgOut->setPageTitle( wfMsg( 'deletequeue' ) ); |
| 14 | + |
| 15 | + $this->loadSearch(); |
| 16 | + |
| 17 | + // Intro text |
| 18 | + $wgOut->addWikiMsg( 'deletequeue-list-text' ); |
| 19 | + |
| 20 | + // Search box |
| 21 | + $searchBox = array(); |
| 22 | + |
| 23 | + //// Queue selector |
| 24 | + $selector = Xml::openElement( 'select', array( 'name' => 'queue' ) ) . "\n"; |
| 25 | + $queues = array( 'speedy', 'prod', 'deletediscuss' ); |
| 26 | + $attribs = array( 'value' => '' ); |
| 27 | + if ( in_array( $this->mQueue, $queues ) ) |
| 28 | + $attribs['selected'] = 'selected'; |
| 29 | + $selector .= Xml::element( 'option', $attribs, wfMsg( 'deletequeue-list-anyqueue' ) ); |
| 30 | + foreach( $queues as $queue ) { |
| 31 | + $attribs = array( 'value' => $queue ); |
| 32 | + if ($this->mQueue == $queue) |
| 33 | + $attribs['selected'] = 'selected'; |
| 34 | + $selector .= Xml::element( 'option', $attribs, wfMsg( "deletequeue-queue-$queue" ) ); |
| 35 | + } |
| 36 | + $selector .= Xml::closeElement( 'select' ); |
| 37 | + |
| 38 | + $searchBox['deletequeue-list-queue'] = $selector; |
| 39 | + $searchBox['deletequeue-list-status'] = Xml::checkLabel( wfMsg( 'deletequeue-list-expired' ), 'expired', 'mw-dq-expired', $this->mExpired ); |
| 40 | + |
| 41 | + $searchBox = Xml::buildForm( $searchBox, 'deletequeue-list-search' ); |
| 42 | + $searchBox .= Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ); |
| 43 | + $searchBox = Xml::tags( 'form', array( 'action' => $this->getTitle()->getFullURL(), 'method' => 'get' ), $searchBox ); |
| 44 | + $searchBox = Xml::fieldset( wfMsg( 'deletequeue-list-search-legend' ), $searchBox ); |
| 45 | + |
| 46 | + $wgOut->addHTML( $searchBox ); |
| 47 | + |
| 48 | + $conds = array('dq_active' => 1); |
| 49 | + |
| 50 | + if ($this->mQueue) |
| 51 | + $conds['dq_queue'] = $this->mQueue; |
| 52 | + |
| 53 | + if ($this->mExpired) { |
| 54 | + $dbr = wfGetDB(DB_SLAVE); |
| 55 | + $conds[] = 'dq_expiry<'.$dbr->addQuotes($dbr->timestamp( wfTimestampNow() ) ); |
| 56 | + } |
| 57 | + |
| 58 | + // Headers |
| 59 | + |
| 60 | + $body = ''; |
| 61 | + $headers = array( 'page', 'queue', 'votes', 'expiry', 'discusspage' ); |
| 62 | + foreach( $headers as $header ) { |
| 63 | + $body .= Xml::element( 'th', null, wfMsg( "deletequeue-list-header-$header" ) ) . "\n"; |
| 64 | + } |
| 65 | + |
| 66 | + $body = Xml::tags( 'tr', null, $body ); |
| 67 | + |
| 68 | + // The list itself |
| 69 | + $pager = new DeleteQueuePager($conds); |
| 70 | + $body .= $pager->getBody(); |
| 71 | + $body = Xml::tags( 'table', array( 'class' => 'wikitable' ), $body ); |
| 72 | + |
| 73 | + $wgOut->addHTML( $pager->getNavigationBar() . $body . $pager->getNavigationBar() ); |
| 74 | + } |
| 75 | + |
| 76 | + public function loadSearch() { |
| 77 | + global $wgRequest; |
| 78 | + |
| 79 | + $this->mQueue = $wgRequest->getText( 'queue' ); |
| 80 | + $this->mExpired = $wgRequest->getBool( 'expired' ); |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +class DeleteQueuePager extends ReverseChronologicalPager { |
| 85 | + function __construct( $conds ) { |
| 86 | + parent::__construct(); |
| 87 | + $this->mConds = $conds; |
| 88 | + } |
| 89 | + |
| 90 | + function formatRow( $row ) { |
| 91 | + static $sk=null; |
| 92 | + |
| 93 | + if (is_null($sk)) { |
| 94 | + global $wgUser; |
| 95 | + $sk = $wgUser->getSkin(); |
| 96 | + } |
| 97 | + |
| 98 | + $a = Article::newFromID($row->dq_page); |
| 99 | + $t = $a->mTitle; |
| 100 | + $dqi = DeleteQueueItem::newFromArticle( $a ); |
| 101 | + $dqi->loadFromRow( $row ); |
| 102 | + $queue = $dqi->getQueue(); |
| 103 | + global $wgLang; |
| 104 | + |
| 105 | + if ($dqi->getQueue() == 'deletediscuss') { |
| 106 | + $discusspage = $sk->makeKnownLinkObj( $dqi->getDiscussionPage()->mTitle ); |
| 107 | + } else $discusspage = ''; |
| 108 | + |
| 109 | + if ($row->dq_expiry > $row->dq_timestamp) { |
| 110 | + $expirestr = $wgLang->timeanddate( $row->dq_expiry ); |
| 111 | + } else $expirestr = ''; |
| 112 | + |
| 113 | + $tr = ''; |
| 114 | + |
| 115 | + $tr .= Xml::tags( 'td', null, $sk->makeKnownLinkObj( $t, $t->getPrefixedText() ) ); |
| 116 | + $tr .= Xml::element( 'td', null, wfMsg( "deletequeue-queue-$queue" ) ); |
| 117 | + $tr .= Xml::tags( 'td', null, $sk->makeKnownLinkObj( $t, $dqi->formatVoteCount(), 'action=delviewvotes' ) ); |
| 118 | + $tr .= Xml::element( 'td', null, $expirestr ); |
| 119 | + $tr .= Xml::tags( 'td', null, $discusspage ); |
| 120 | + |
| 121 | + return Xml::tags( 'tr', null, $tr ) . "\n"; |
| 122 | + } |
| 123 | + |
| 124 | + function getQueryInfo() { |
| 125 | + return array( |
| 126 | + 'tables' => 'delete_queue', |
| 127 | + 'fields' => '*', |
| 128 | + 'conds' => $this->mConds, |
| 129 | + ); |
| 130 | + } |
| 131 | + |
| 132 | + function getIndexField() { |
| 133 | + return 'dq_case'; |
| 134 | + } |
| 135 | +} |
Property changes on: trunk/extensions/DeleteQueue/Views/DeleteQueueViewList.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 136 | + native |
Index: trunk/extensions/DeleteQueue/Views/DeleteQueueViewVote.php |
— | — | @@ -0,0 +1,110 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if (!defined( 'MEDIAWIKI' ) ) { |
| 5 | + die; |
| 6 | +} |
| 7 | + |
| 8 | +class DeleteQueueViewVote extends DeleteQueueView { |
| 9 | + function show( $params ) { |
| 10 | + $article_id = $params[1]; |
| 11 | + $article = Article::newFromId( $article_id ); |
| 12 | + $this->process( $article ); |
| 13 | + } |
| 14 | + |
| 15 | + /** |
| 16 | + * Process the 'delvote' action. |
| 17 | + * @param Article $article The article to endorse/object to deletion of. |
| 18 | + */ |
| 19 | + public function process( $article ) { |
| 20 | + global $wgRequest,$wgOut,$wgUser,$wgTitle; |
| 21 | + |
| 22 | + $errs = |
| 23 | + $article->mTitle->getUserPermissionsErrors( 'deletequeue-vote', $wgUser ); |
| 24 | + if ( count( $errs ) > 0 ) { |
| 25 | + $wgOut->showPermissionsErrorPage( $errs ); |
| 26 | + return; |
| 27 | + } |
| 28 | + |
| 29 | + $dqi = DeleteQueueItem::newFromArticle( $article ); |
| 30 | + |
| 31 | + $wgOut->setPageTitle( wfMsg( 'deletequeue-vote-title', $article->mTitle->getPrefixedText() ) ); |
| 32 | + |
| 33 | + // Load form data |
| 34 | + $token = $wgRequest->getVal( 'wpEditToken' ); |
| 35 | + $action = $wgRequest->getVal( 'wpVote' ); |
| 36 | + $comments = $wgRequest->getText( 'wpComments' ); |
| 37 | + |
| 38 | + if ( $wgUser->matchEditToken( $token ) && |
| 39 | + in_array( $action, array( 'endorse', 'object' ) ) ) { |
| 40 | + |
| 41 | + $dqi->addVote( $action, $comments ); |
| 42 | + |
| 43 | + if ($action == 'object' && $dqi->getQueue( ) == 'prod') { |
| 44 | + $dbw = wfGetDB( DB_MASTER ); |
| 45 | + $dbw->begin(); |
| 46 | + |
| 47 | + $dqi->setQueue( 'deletediscuss', $dqi->getReason() ); |
| 48 | + |
| 49 | + $lp = new LogPage( 'delete' ); |
| 50 | + $lp->addEntry( 'requeue', |
| 51 | + $article->mTitle, |
| 52 | + $comments, |
| 53 | + array( |
| 54 | + wfMsgForContent('deletequeue-queue-prod'), |
| 55 | + wfMsgForContent( "deletequeue-queue-deletediscuss" ) |
| 56 | + ) |
| 57 | + ); |
| 58 | + |
| 59 | + $dbw->commit(); |
| 60 | + |
| 61 | + $wgOut->addWikiMsg( 'deletequeue-vote-requeued', |
| 62 | + wfMsgNoTrans( 'deletequeue-queue-deletediscuss' ) ); |
| 63 | + } else { |
| 64 | + $wgOut->addWikiMsg( "deletequeue-vote-success-$action" ); |
| 65 | + } |
| 66 | + return; |
| 67 | + } |
| 68 | + |
| 69 | + $wgOut->addWikiMsg( 'deletequeue-vote-text', |
| 70 | + $article->mTitle->getPrefixedText(), $dqi->getReason() ); |
| 71 | + |
| 72 | + // Add main form. |
| 73 | + $fields = array(); |
| 74 | + |
| 75 | + $options = Xml::tags( 'p', null, |
| 76 | + Xml::radioLabel( wfMsg( 'deletequeue-vote-endorse' ), |
| 77 | + 'wpVote', |
| 78 | + 'endorse', |
| 79 | + 'mw-deletequeue-vote-endorse' |
| 80 | + ) |
| 81 | + ); |
| 82 | + |
| 83 | + $options .= Xml::tags( 'p', null, |
| 84 | + Xml::radioLabel( wfMsg( 'deletequeue-vote-object' ), |
| 85 | + 'wpVote', |
| 86 | + 'object', |
| 87 | + 'mw-deletequeue-vote-object' |
| 88 | + ) |
| 89 | + ); |
| 90 | + |
| 91 | + $fields['deletequeue-vote-action'] = $options; |
| 92 | + $fields['deletequeue-vote-reason'] = Xml::input( 'wpComments', 45, $comments ); |
| 93 | + |
| 94 | + $article_id = $article->getId(); |
| 95 | + $title = $this->getTitle( "vote/$article_id" ); |
| 96 | + |
| 97 | + $form = Xml::buildForm( $fields, 'deletequeue-vote-submit' ) . |
| 98 | + Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 99 | + Xml::hidden( 'title', $title->getPrefixedText() ); |
| 100 | + |
| 101 | + $form = Xml::tags( 'form', |
| 102 | + array( |
| 103 | + 'action' => $title->getLocalURL(), |
| 104 | + 'method' => 'POST' |
| 105 | + ), $form ); |
| 106 | + |
| 107 | + $form = Xml::fieldset( wfMsg( 'deletequeue-vote-legend' ), $form ); |
| 108 | + |
| 109 | + $wgOut->addHTML( $form ); |
| 110 | + } |
| 111 | +} |
\ No newline at end of file |
Index: trunk/extensions/DeleteQueue/Views/DeleteQueueView.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if (!defined( 'MEDIAWIKI' ) ) { |
| 5 | + die; |
| 6 | +} |
| 7 | + |
| 8 | +abstract class DeleteQueueView { |
| 9 | + abstract function show( $params ); |
| 10 | + |
| 11 | + function __construct( $page ) { |
| 12 | + $this->mPage = $page; |
| 13 | + } |
| 14 | + |
| 15 | + function getTitle( $subpage = null ) { |
| 16 | + return $this->mPage->getTitle( $subpage ); |
| 17 | + } |
| 18 | +} |
\ No newline at end of file |
Index: trunk/extensions/DeleteQueue/Views/DeleteQueueViewReview.php |
— | — | @@ -0,0 +1,446 @@ |
| 2 | +<?php |
| 3 | +if ( ! defined( 'MEDIAWIKI' ) ) |
| 4 | + die(); |
| 5 | + |
| 6 | +class DeleteQueueViewReview extends DeleteQueueView { |
| 7 | + |
| 8 | + /** |
| 9 | + * Process the "Review Speedy" action |
| 10 | + * @param $article Article object being reviewed |
| 11 | + */ |
| 12 | + public function show( $params ) { |
| 13 | + global $wgOut,$wgScript,$wgUser,$wgRequest; |
| 14 | + |
| 15 | + list( $action, $case_id ) = $params; |
| 16 | + |
| 17 | + $dqi = DeleteQueueItem::newFromId( $case_id ); |
| 18 | + $article = $this->mArticle = $dqi->getArticle(); |
| 19 | + $queue = $dqi->getQueue(); |
| 20 | + |
| 21 | + if (!$queue) { |
| 22 | + // ... |
| 23 | + $wgOut->addWikiMsg( 'deletequeue-notqueued' ); |
| 24 | + return; |
| 25 | + } |
| 26 | + |
| 27 | + // Check permissions |
| 28 | + $editErrors = $article->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
| 29 | + $nomErrors = $article->mTitle->getUserPermissionsErrors( "$queue-review", |
| 30 | + $wgUser ); |
| 31 | + |
| 32 | + if (count(array_merge($editErrors,$nomErrors))) { |
| 33 | + // Permissions errors. |
| 34 | + if (count($editErrors)) { |
| 35 | + $editError = $wgOut->formatPermissionsErrorMessage( $editErrors, 'edit' ); |
| 36 | + $nomErrors[] = array( 'deletequeue-permissions-noedit', $editError ); |
| 37 | + } |
| 38 | + |
| 39 | + $wgOut->showPermissionsErrorPage( $nomErrors, "$queue-review" ); |
| 40 | + return; |
| 41 | + } |
| 42 | + |
| 43 | + list ($enabledActions, $disabledActions) = $this->availableActions(); |
| 44 | + |
| 45 | + $haveRequeueOption = false; |
| 46 | + |
| 47 | + $shownActions = array_merge( array_keys( $disabledActions ), $enabledActions ); |
| 48 | + |
| 49 | + foreach( $shownActions as $val ) { |
| 50 | + if (strpos($val,'requeue') == 0) { |
| 51 | + $haveRequeueOption = true; |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + if (($error = $this->submit( $article )) === true) { |
| 56 | + $wgOut->setPageTitle( wfMsg( "deletequeue-review-success-title" ) ); |
| 57 | + $wgOut->addWikiMsg( "deletequeue-review-success" ); |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + $wgOut->setPageTitle( |
| 62 | + wfMsg( "deletequeue-review$queue-title", |
| 63 | + $article->mTitle->getPrefixedText() ) ); |
| 64 | + |
| 65 | + $discussionPage = ($queue == 'deletediscuss') |
| 66 | + ? $dqi->getDiscussionPage()->mTitle->getPrefixedText() |
| 67 | + : null; |
| 68 | + |
| 69 | + $wgOut->addWikiMsg( "deletequeue-review$queue-text", |
| 70 | + $article->mTitle->getPrefixedText(), $discussionPage ); |
| 71 | + |
| 72 | + // Cautions if there's an objection |
| 73 | + if ( count( $dqi->mVotesObject ) > 0 ) { |
| 74 | + $wgOut->addWikiMsg( "deletequeue-review-objections", |
| 75 | + count($dqi->mVotesObject) ); |
| 76 | + } |
| 77 | + |
| 78 | + if ($error) { |
| 79 | + $wgOut->addHTML( '<p>'.$error.'</p>' ); |
| 80 | + } |
| 81 | + |
| 82 | + // Details of nomination |
| 83 | + $wgOut->addHTML( Xml::openElement( 'fieldset' ) . |
| 84 | + Xml::element( 'legend', |
| 85 | + array(), |
| 86 | + wfMsg( 'deletequeue-review-original' ) |
| 87 | + ) |
| 88 | + ); |
| 89 | + $wgOut->addWikitext( $dqi->getReason() ); |
| 90 | + $wgOut->addHTML( Xml::closeElement( 'fieldset' ) ); |
| 91 | + |
| 92 | + $output = ''; |
| 93 | + |
| 94 | + // Give the user options |
| 95 | + $option_selection = ''; |
| 96 | + |
| 97 | + //// Action radio buttons |
| 98 | + // Accept the nomination as-is |
| 99 | + $accept = Xml::radioLabel( |
| 100 | + wfMsg( 'deletequeue-review-delete' ), |
| 101 | + 'wpSpeedyAction', |
| 102 | + 'delete', |
| 103 | + 'mw-review-accept' |
| 104 | + ); |
| 105 | + $option_selection .= $this->getActionOrError( |
| 106 | + 'delete', |
| 107 | + $accept, |
| 108 | + null, |
| 109 | + Xml::tags( 'li', array(), '$1' ) |
| 110 | + ); |
| 111 | + |
| 112 | + // Accept nomination, but with a different reasoning. |
| 113 | + $change_option = Xml::radioLabel( |
| 114 | + wfMsg( 'deletequeue-review-change' ), |
| 115 | + 'wpSpeedyAction', |
| 116 | + 'change', |
| 117 | + 'mw-review-change' |
| 118 | + ); |
| 119 | + $change_fields = array(); |
| 120 | + $change_fields['deletequeue-review-newreason'] = |
| 121 | + Xml::listDropDown( |
| 122 | + 'wpSpeedyNewReason', |
| 123 | + DeleteQueueInterface::getReasonList( $queue ), |
| 124 | + wfMsg('deletequeue-delnom-otherreason') |
| 125 | + ); |
| 126 | + $change_fields['deletequeue-review-newextra'] = |
| 127 | + Xml::input( 'wpSpeedyNewExtra', 45, '' ); |
| 128 | + $change_option .= Xml::buildForm( $change_fields ); |
| 129 | + $option_selection .= |
| 130 | + $this->getActionOrError( |
| 131 | + 'delete', |
| 132 | + $change_option, |
| 133 | + wfMsgExt('deletequeue-review-change', array('parseinline') ), |
| 134 | + Xml::tags( 'li', array(), '$1' ) |
| 135 | + ); |
| 136 | + |
| 137 | + // Reject nomination, queue into a different deletion queue. |
| 138 | + if ($haveRequeueOption) { |
| 139 | + $requeue_option = Xml::radioLabel( |
| 140 | + wfMsg( 'deletequeue-review-requeue' ), |
| 141 | + 'wpSpeedyAction', |
| 142 | + 'requeue', |
| 143 | + 'mw-review-requeue' |
| 144 | + ); |
| 145 | + $new_queues = array('prod', 'deletediscuss'); |
| 146 | + $requeue_queues = ''; |
| 147 | + foreach( $new_queues as $option ) { |
| 148 | + $this_queue = |
| 149 | + Xml::radioLabel( |
| 150 | + wfMsg( "deletequeue-queue-$option" ), |
| 151 | + 'wpSpeedyRequeue', |
| 152 | + $option, |
| 153 | + "mw-review-requeue-$option" |
| 154 | + ); |
| 155 | + $disabledMsg = |
| 156 | + wfMsgExt( "deletequeue-requeuedisabled", |
| 157 | + array( 'parseinline' ), |
| 158 | + array( wfMsgNoTrans( "deletequeue-queue-$option" ) |
| 159 | + ) ); |
| 160 | + |
| 161 | + $requeue_queues .= |
| 162 | + $this->getActionOrError( "requeue-$option", |
| 163 | + $this_queue, |
| 164 | + $disabledMsg, |
| 165 | + Xml::tags( 'li', array(), '$1' ) |
| 166 | + ); |
| 167 | + } |
| 168 | + $requeue_option .= Xml::tags( 'ul', array(), $requeue_queues ); |
| 169 | + |
| 170 | + $requeue_fields = array(); |
| 171 | + $requeue_fields['deletequeue-review-newreason'] = |
| 172 | + Xml::listDropDown( 'wpSpeedyNewReason', |
| 173 | + DeleteQueueInterface::getReasonList( 'generic' ), |
| 174 | + wfMsg("deletequeue-delnom-otherreason") ); |
| 175 | + $requeue_fields['deletequeue-review-newextra'] = |
| 176 | + Xml::input( 'wpSpeedyNewExtra', 45, '' ); |
| 177 | + $requeue_option .= Xml::buildForm( $requeue_fields ); |
| 178 | + |
| 179 | + $option_selection .= Xml::tags( 'li', array(), $requeue_option ); |
| 180 | + } |
| 181 | + |
| 182 | + // Reject nomination outright. |
| 183 | + $dq = Xml::radioLabel( |
| 184 | + wfMsg( 'deletequeue-review-dequeue' ), |
| 185 | + 'wpSpeedyAction', |
| 186 | + 'dequeue', |
| 187 | + 'mw-review-dequeue' |
| 188 | + ); |
| 189 | + $option_selection .= |
| 190 | + $this->getActionOrError( 'dequeue', |
| 191 | + $dq, |
| 192 | + null, |
| 193 | + Xml::tags( 'li', array(), '$1' ) |
| 194 | + ); |
| 195 | + |
| 196 | + //// Convert to a list. |
| 197 | + $option_selection = Xml::tags( 'ul', array(), $option_selection ); |
| 198 | + |
| 199 | + $option_selection = Xml::fieldset( |
| 200 | + wfMsg( 'deletequeue-review-action' ), |
| 201 | + $option_selection |
| 202 | + ); |
| 203 | + |
| 204 | + $output .= $option_selection; |
| 205 | + |
| 206 | + // Reason etc. |
| 207 | + $fields = array( |
| 208 | + 'deletequeue-review-reason' => Xml::input( 'wpReason', 45, null ) |
| 209 | + ); |
| 210 | + |
| 211 | + $output .= Xml::buildForm( $fields, 'deletequeue-review-submit' ); |
| 212 | + |
| 213 | + // Form stuff |
| 214 | + $output .= Xml::hidden( 'title', |
| 215 | + $this->getTitle( "case/".$dqi->getCaseID()."/review" ) ); |
| 216 | + $output .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ); |
| 217 | + $output = Xml::tags( 'form', |
| 218 | + array( 'action' => $article->mTitle->getLocalURL(), |
| 219 | + 'method' => 'POST' |
| 220 | + ), |
| 221 | + $output |
| 222 | + ); |
| 223 | + |
| 224 | + $wgOut->addHTML( $output ); |
| 225 | + } |
| 226 | + |
| 227 | + /** |
| 228 | + * Attempt submission of the "Review Speedy" form. |
| 229 | + * @param $article Article object being reviewed |
| 230 | + */ |
| 231 | + public function submit( ) { |
| 232 | + global $wgUser,$wgOut,$wgRequest; |
| 233 | + |
| 234 | + $article = $this->mArticle; |
| 235 | + |
| 236 | + $token = $wgRequest->getText( 'wpEditToken' ); |
| 237 | + |
| 238 | + if (!$wgUser->matchEditToken( $token )) { |
| 239 | + return false; |
| 240 | + } |
| 241 | + |
| 242 | + // Process the action |
| 243 | + $action = $wgRequest->getVal( 'wpSpeedyAction' ); |
| 244 | + $processed = true; |
| 245 | + $dqi = DeleteQueueItem::newFromArticle( $article ); |
| 246 | + $newQueue = $wgRequest->getVal( 'wpSpeedyRequeue' ); |
| 247 | + |
| 248 | + $lp = new LogPage( 'delete' ); |
| 249 | + $reason = $wgRequest->getText( 'wpReason' ); |
| 250 | + |
| 251 | + // Check the action against the list |
| 252 | + list($enabledActions) = $this->availableActions(); |
| 253 | + if ( !in_array( $action,$enabledActions ) && |
| 254 | + ( $action != 'requeue' || |
| 255 | + !in_array( "requeue-$newQueue", $enabledActions ) |
| 256 | + ) |
| 257 | + ) { |
| 258 | + return wfMsg( 'deletequeue-review-actiondenied' ); |
| 259 | + } |
| 260 | + |
| 261 | + $queue = $dqi->getQueue( ); |
| 262 | + |
| 263 | + // Transaction |
| 264 | + $dbw = wfGetDB( DB_MASTER ); |
| 265 | + $dbw->begin(); |
| 266 | + |
| 267 | + switch ($action) { |
| 268 | + case 'delete': |
| 269 | + $article->doDelete( $dqi->getQueue() ); |
| 270 | + $processed = true; |
| 271 | + break; |
| 272 | + case 'change': |
| 273 | + $reason1 = $wgRequest->getText( 'wpSpeedyNewReason' ); |
| 274 | + $reason2 = $wgRequest->getText( 'wpSpeedyNewExtra' ); |
| 275 | + $reason = DeleteQueueInterface::formatReason( $reason1, $reason2 ); |
| 276 | + $article->doDelete( $reason ); |
| 277 | + $processed = true; |
| 278 | + break; |
| 279 | + case 'dequeue': |
| 280 | + $lp->addEntry( 'dequeue', $article->mTitle, $reason, $queue ); |
| 281 | + $processed = true; |
| 282 | + break; |
| 283 | + case 'requeue': |
| 284 | + $lp->addEntry( 'requeue', |
| 285 | + $article->mTitle, |
| 286 | + $reason, |
| 287 | + array( |
| 288 | + wfMsgForContent("deletequeue-queue-$queue"), |
| 289 | + wfMsgForContent( "deletequeue-queue-{$newQueue}" ) |
| 290 | + ) |
| 291 | + ); |
| 292 | + |
| 293 | + $reason1 = $wgRequest->getText( 'wpSpeedyNewReason' ); |
| 294 | + $reason2 = $wgRequest->getText( 'wpSpeedyNewExtra' ); |
| 295 | + $newReason = DeleteQueueInterface::formatReason( $reason1, $reason2 ); |
| 296 | + |
| 297 | + $dqi->setQueue( $newQueue, $reason ); |
| 298 | + $processed = false; |
| 299 | + break; |
| 300 | + default: |
| 301 | + // Invalid action |
| 302 | + $dbw->commit(); |
| 303 | + return wfMsg( 'deletequeue-review-badaction' );; |
| 304 | + } |
| 305 | + |
| 306 | + if ($processed) { |
| 307 | + // Delete from the DB |
| 308 | + $dqi->deQueue( ); |
| 309 | + |
| 310 | + // Redirect to the page |
| 311 | + $wgOut->redirect( $article->mTitle->getLocalURL() ); |
| 312 | + |
| 313 | + // Commit transaction |
| 314 | + $dbw->commit(); |
| 315 | + |
| 316 | + return true; |
| 317 | + } |
| 318 | + |
| 319 | + $dbw->commit(); |
| 320 | + |
| 321 | + return true; |
| 322 | + } |
| 323 | + |
| 324 | + /** Returns the action given in enabledText, a 'disabled' message, |
| 325 | + or nothing, depending on the status of the action. */ |
| 326 | + public function getActionOrError($action, $enabledText, $disabledMsg = null, |
| 327 | + $wrapper = null) { |
| 328 | + list ($enabled,$disabled) = $this->availableActions(); |
| 329 | + |
| 330 | + if (!$disabledMsg) { |
| 331 | + $disabledMsg = wfMsgExt("deletequeue-review-$action", |
| 332 | + array('parseinline') |
| 333 | + ); |
| 334 | + } |
| 335 | + |
| 336 | + $data = ''; |
| 337 | + |
| 338 | + if (in_array($action,$enabled)) { |
| 339 | + $data = $enabledText; |
| 340 | + } elseif ( in_array( $action, array_keys( $disabled ) ) ) { |
| 341 | + $msg = $disabled[$action]; |
| 342 | + $msg .= "\n"; |
| 343 | + $msg .= Xml::tags( 'p', |
| 344 | + array( 'class' => 'mw-deletequeue-action-disabled' ), |
| 345 | + $disabledMsg ); |
| 346 | + $data = $msg; |
| 347 | + } else { |
| 348 | + } |
| 349 | + |
| 350 | + if ($wrapper && $data) { |
| 351 | + $data = wfMsgReplaceArgs( $wrapper, array($data) ); |
| 352 | + } |
| 353 | + |
| 354 | + return $data; |
| 355 | + } |
| 356 | + |
| 357 | + /** |
| 358 | + * Determines which queues can be sent to in review. |
| 359 | + * @return Array First element is a simple list of ENABLED queues, |
| 360 | + second is a list, key is queue name, value is a message explaining why |
| 361 | + (already passed through wfMsg). Queues in neither are not displayed. |
| 362 | + */ |
| 363 | + public function availableActions( $user = null ) { |
| 364 | + $article = $this->mArticle; |
| 365 | + $dqi = DeleteQueueItem::newFromArticle( $article ); |
| 366 | + $queue = $dqi->getQueue( ); |
| 367 | + |
| 368 | + if ($user === null) { |
| 369 | + global $wgUser; |
| 370 | + $user = $wgUser; |
| 371 | + } |
| 372 | + |
| 373 | + $enabled = array(); |
| 374 | + $disabled = array(); |
| 375 | + |
| 376 | + $userRoles = $dqi->getUserRoles( $user ); |
| 377 | + $descriptiveRoles = array_map( |
| 378 | + array( 'DeleteQueueItem', 'getRoleDescription' ), |
| 379 | + $userRoles |
| 380 | + ); |
| 381 | + $descriptiveRolesText = implode( ", ", $descriptiveRoles ); |
| 382 | + |
| 383 | + $enabled[] = 'endorse'; |
| 384 | + $enabled[] = 'object'; |
| 385 | + |
| 386 | + // Speedy deletion |
| 387 | + if ($queue == 'speedy') { |
| 388 | + // All are unlocked if user is authed. |
| 389 | + $enabled = array( |
| 390 | + 'delete', |
| 391 | + 'requeue-prod', |
| 392 | + 'requeue-deletediscuss', |
| 393 | + 'dequeue' |
| 394 | + ); |
| 395 | + } elseif ($queue == 'prod') { |
| 396 | + // Escalation by anybody |
| 397 | + $enabled[] = 'requeue-deletediscuss'; |
| 398 | + $enabled[] = 'dequeue'; |
| 399 | + |
| 400 | + $expiry = $dqi->getExpiry(); |
| 401 | + $hasExpired = (time() > $expiry) ? true : false; |
| 402 | + |
| 403 | + // Handling of 'delete' |
| 404 | + if (!$hasExpired) { // Hasn't expired yet, don't let them delete it. |
| 405 | + $disabled['delete'] = |
| 406 | + wfMsgExt( 'deletequeue-actiondisabled-notexpired', |
| 407 | + array( 'parseinline' ) |
| 408 | + ); |
| 409 | + } elseif (count($userRoles)) { |
| 410 | + // Tell them they're involved. |
| 411 | + $disabled['delete'] = |
| 412 | + wfMsgExt( 'deletequeue-actiondisabled-involved', |
| 413 | + array( 'parseinline' ), |
| 414 | + array( $descriptiveRolesText ) |
| 415 | + ); |
| 416 | + } else { |
| 417 | + // Allow uninvolved admins to delete expired prods |
| 418 | + $enabled[] = 'delete'; |
| 419 | + } |
| 420 | + } elseif ($queue == 'deletediscuss') { |
| 421 | + |
| 422 | + $expiry = $dqi->getExpiry(); |
| 423 | + $hasExpired = (time() > $expiry) ? true : false; |
| 424 | + |
| 425 | + if (!$hasExpired) { // Hasn't expired yet, don't let them delete it. |
| 426 | + $disabled['delete'] = |
| 427 | + wfMsgExt( 'deletequeue-actiondisabled-notexpired', |
| 428 | + array( 'parseinline' ) |
| 429 | + ); |
| 430 | + } elseif (count($userRoles)) { |
| 431 | + // Tell them they're involved. |
| 432 | + $disabled['delete'] = |
| 433 | + wfMsgExt( 'deletequeue-actiondisabled-involved', |
| 434 | + array( 'parseinline' ), |
| 435 | + array( $descriptiveRolesText ) |
| 436 | + ); |
| 437 | + } else { |
| 438 | + // An uninvolved admin wants to delete an expired proposed deletion. |
| 439 | + $enabled[] = 'delete'; |
| 440 | + } |
| 441 | + |
| 442 | + $enabled[] = 'dequeue'; |
| 443 | + } |
| 444 | + |
| 445 | + return array( $enabled, $disabled ); |
| 446 | + } |
| 447 | +} |
Property changes on: trunk/extensions/DeleteQueue/Views/DeleteQueueViewReview.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 448 | + native |
Index: trunk/extensions/DeleteQueue/DeleteQueueInterface.php |
— | — | @@ -4,126 +4,6 @@ |
5 | 5 | |
6 | 6 | class DeleteQueueInterface { |
7 | 7 | |
8 | | - /** |
9 | | - * Entry point for "nomination" forms. |
10 | | - * @param $article The article object to nominate. |
11 | | - * @param $queue The queue to nominate to. |
12 | | - */ |
13 | | - public static function processNominationAction( $article, $queue ) { |
14 | | - global $wgOut,$wgScript,$wgUser,$wgRequest; |
15 | | - |
16 | | - // Check permissions |
17 | | - $editErrors = $article->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
18 | | - $nomErrors = $article->mTitle->getUserPermissionsErrors( "{$queue}-nominate", $wgUser ); |
19 | | - |
20 | | - if (count(array_merge($editErrors,$nomErrors))) { |
21 | | - // Permissions errors. |
22 | | - if (count($editErrors)) { |
23 | | - // This is a really bad way to do this. |
24 | | - $editError = $wgOut->formatPermissionsErrorMessage( $editErrors, 'edit' ); |
25 | | - $nomErrors[] = array( 'deletequeue-permissions-noedit', $editError ); |
26 | | - } |
27 | | - |
28 | | - $wgOut->showPermissionsErrorPage( $nomErrors, "{$queue}-nominate" ); |
29 | | - if (isset($editError)) { |
30 | | - $wgOut->addHTML( $editError ); |
31 | | - } |
32 | | - return; |
33 | | - } |
34 | | - |
35 | | - $form = self::nominationForm( $article, $queue ); |
36 | | - |
37 | | - if ($form) { |
38 | | - $wgOut->addHTML( $form ); |
39 | | -// $article->showLogExtract( $wgOut ); |
40 | | - } |
41 | | - } |
42 | | - |
43 | | - /** |
44 | | - * Generate a "deletion nomination" form. |
45 | | - * @param $article Article object to nominate. |
46 | | - */ |
47 | | - public static function nominationForm( $article, $queue ) { |
48 | | - global $wgOut,$wgScript,$wgUser,$wgRequest; |
49 | | - |
50 | | - // Check for submission |
51 | | - if ( self::nominationSubmit( $article, $queue ) ) { |
52 | | - return; |
53 | | - } |
54 | | - |
55 | | - $wgOut->setPageTitle( wfMsg( "deletequeue-$queue-title", $article->mTitle->getPrefixedText() ) ); |
56 | | - $wgOut->addWikiMsg( "deletequeue-$queue-text", $article->mTitle->getPrefixedText() ); |
57 | | - |
58 | | - // Build deletion form. |
59 | | - $fields = array(); |
60 | | - $fields['deletequeue-delnom-reason'] = Xml::listDropDown( 'wpReason', self::getReasonList( $queue ), wfMsg("deletequeue-delnom-otherreason") ); |
61 | | - $fields['deletequeue-delnom-extra'] = Xml::input( 'wpExtra', 45 ); |
62 | | - |
63 | | - $form = Xml::buildForm( $fields, "deletequeue-delnom-submit" ); |
64 | | - $form .= Xml::hidden( 'title', $article->mTitle->getPrefixedText() ); |
65 | | - $form .= Xml::hidden( 'action', "delnom" ); |
66 | | - $form .= Xml::hidden( 'queue', $queue ); |
67 | | - $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken() ); |
68 | | - $form = Xml::tags( 'form', array( 'action' => $article->mTitle->getLocalUrl(), 'method' => 'POST' ), $form ); |
69 | | - |
70 | | - $wgOut->addHTML( $form ); |
71 | | -// $article->showDeletionLog(); |
72 | | - } |
73 | | - |
74 | | - /** |
75 | | - * Attempt to submit the propose deletion form. |
76 | | - * @param $article Article object. |
77 | | - * @param $action The action (speedynom, prod, etc) |
78 | | - * @return Boolean Whether or not the submission was successful. |
79 | | - */ |
80 | | - public static function nominationSubmit( $article, $queue ) { |
81 | | - global $wgUser,$wgOut,$wgRequest; |
82 | | - |
83 | | - $token = $wgRequest->getText( 'wpEditToken' ); |
84 | | - |
85 | | - if (!$wgUser->matchEditToken( $token )) { |
86 | | - return false; |
87 | | - } |
88 | | - |
89 | | - // Import form data. |
90 | | - $reason1 = $wgRequest->getText( 'wpReason' ); |
91 | | - $reason2 = $wgRequest->getText( 'wpExtra' ); |
92 | | - |
93 | | - $reason = self::formatReason( $reason1, $reason2 ); |
94 | | - |
95 | | - // Allow hooks to terminate |
96 | | - $error = ''; |
97 | | - if (!wfRunHooks( 'AbortDeleteQueueNominate', array($wgUser, $article, $queue, $reason, &$error) ) ) { |
98 | | - $wgOut->addWikitext( $error ); |
99 | | - return false; |
100 | | - } |
101 | | - |
102 | | - // Transaction |
103 | | - $dbw = wfGetDB( DB_MASTER ); |
104 | | - $dbw->begin(); |
105 | | - |
106 | | - // Set in database. |
107 | | - $dqi = DeleteQueueItem::newFromArticle( $article ); |
108 | | - |
109 | | - if ($dqi->getQueue()) { |
110 | | - $dbw->rollback(); |
111 | | - $wgOut->addWikiMsg( 'deletequeue-nom-alreadyqueued' ); |
112 | | - return false; |
113 | | - } |
114 | | - |
115 | | - $dqi->setQueue( $queue, $reason ); |
116 | | - $dqi->addRole( 'nominator' ); |
117 | | - |
118 | | - $log = new LogPage( 'delete' ); |
119 | | - $log->addEntry( "nominate", $article->mTitle, $reason, wfMsgNoTrans( 'deletequeue-queue-'.$queue) ); |
120 | | - |
121 | | - $dbw->commit(); |
122 | | - |
123 | | - $wgOut->redirect( $article->mTitle->getLocalUrl() ); |
124 | | - |
125 | | - return true; |
126 | | - } |
127 | | - |
128 | 8 | public static function formatReason( $reason1, $reason2 ) { |
129 | 9 | if ($reason1 && $reason2 && $reason1 != 'other') { |
130 | 10 | return "$reason1: $reason2"; |
— | — | @@ -153,161 +33,4 @@ |
154 | 34 | $list = wfMsgForContent( "deletequeue-generic-reasons" ); |
155 | 35 | return $list; |
156 | 36 | } |
157 | | - |
158 | | - /** |
159 | | - * Process the 'delvote' action. |
160 | | - * @param Article $article The article to endorse/object to deletion of. |
161 | | - */ |
162 | | - public static function processVoteAction( $article ) { |
163 | | - global $wgRequest,$wgOut,$wgUser,$wgTitle; |
164 | | - |
165 | | - if ( count( $errs = $article->mTitle->getUserPermissionsErrors( 'deletequeue-vote', $wgUser ) ) > 0 ) { |
166 | | - $wgOut->showPermissionsErrorPage( $errs ); |
167 | | - return; |
168 | | - } |
169 | | - |
170 | | - $dqi = DeleteQueueItem::newFromArticle( $article ); |
171 | | - |
172 | | - $wgOut->setPageTitle( wfMsg( 'deletequeue-vote-title', $article->mTitle->getPrefixedText() ) ); |
173 | | - |
174 | | - // Load form data |
175 | | - $token = $wgRequest->getVal( 'wpEditToken' ); |
176 | | - $action = $wgRequest->getVal( 'wpVote' ); |
177 | | - $comments = $wgRequest->getText( 'wpComments' ); |
178 | | - |
179 | | - if ( $wgUser->matchEditToken( $token ) && in_array( $action, array( 'endorse', 'object' ) ) ) { |
180 | | - $dqi->addVote( $action, $comments ); |
181 | | - |
182 | | - if ($action == 'object' && $dqi->getQueue( ) == 'prod') { |
183 | | - $dbw = wfGetDB( DB_MASTER ); |
184 | | - $dbw->begin(); |
185 | | - |
186 | | - $dqi->setQueue( 'deletediscuss', $dqi->getReason() ); |
187 | | - |
188 | | - $lp = new LogPage( 'delete' ); |
189 | | - $lp->addEntry( 'requeue', $article->mTitle, $comments, array(wfMsgForContent('deletequeue-queue-prod'), wfMsgForContent( "deletequeue-queue-deletediscuss" )) ); |
190 | | - |
191 | | - $dbw->commit(); |
192 | | - |
193 | | - $wgOut->addWikiMsg( 'deletequeue-vote-requeued', wfMsgNoTrans( 'deletequeue-queue-deletediscuss' ) ); |
194 | | - } else { |
195 | | - $wgOut->addWikiMsg( "deletequeue-vote-success-$action" ); |
196 | | - } |
197 | | - return; |
198 | | - } |
199 | | - |
200 | | - $wgOut->addWikiMsg( 'deletequeue-vote-text', $article->mTitle->getPrefixedText(), $dqi->getReason() ); |
201 | | - |
202 | | - // Add main form. |
203 | | - $fields = array(); |
204 | | - |
205 | | - $options = Xml::tags( 'p', null, Xml::radioLabel( wfMsg( 'deletequeue-vote-endorse' ), 'wpVote', 'endorse', 'mw-deletequeue-vote-endorse' ) ); |
206 | | - $options .= Xml::tags( 'p', null, Xml::radioLabel( wfMsg( 'deletequeue-vote-object' ), 'wpVote', 'object', 'mw-deletequeue-vote-object' ) ); |
207 | | - $fields['deletequeue-vote-action'] = $options; |
208 | | - |
209 | | - $fields['deletequeue-vote-reason'] = Xml::input( 'wpComments', 45, $comments ); |
210 | | - |
211 | | - $form = Xml::buildForm( $fields, 'deletequeue-vote-submit' ) . |
212 | | - Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
213 | | - Xml::hidden( 'title', $article->mTitle->getPrefixedText() ) . |
214 | | - Xml::hidden( 'action', 'delvote' ); |
215 | | - |
216 | | - $form = Xml::tags( 'form', array( 'action' => $article->mTitle->getFullURL('action=delvote'), 'method' => 'POST' ), $form ); |
217 | | - $form = Xml::fieldset( wfMsg( 'deletequeue-vote-legend' ), $form ); |
218 | | - |
219 | | - $wgOut->addHTML( $form ); |
220 | | - } |
221 | | - |
222 | | - /** |
223 | | - * Show current votes. |
224 | | - * @param $article Article object to show votes for. |
225 | | - */ |
226 | | - public static function showVotes( $article ) { |
227 | | - global $wgOut,$wgUser,$wgRequest,$wgLang; |
228 | | - |
229 | | - $sk = $wgUser->getSkin(); |
230 | | - $article_name = $article->mTitle->getPrefixedText(); |
231 | | - |
232 | | - $wgOut->addWikiMsg( 'deletequeue-showvotes-text', $article_name ); |
233 | | - $wgOut->setPageTitle( wfMsg('deletequeue-showvotes', $article_name) ); |
234 | | - |
235 | | - $restrict_type = $wgRequest->getText( 'votetype' ); |
236 | | - |
237 | | - if ($restrict_type == 'none') $restrict_type = ''; |
238 | | - |
239 | | - if ($restrict_type) { |
240 | | - $wgOut->setSubTitle( wfMsg( "deletequeue-showvotes-showingonly-$restrict_type" ) ); |
241 | | - } |
242 | | - |
243 | | - // Add "view only X" links |
244 | | - $restrictableActions = array( 'none', 'endorse', 'object' ); |
245 | | - $restrictions = Xml::openElement( 'ul' ); |
246 | | - foreach( $restrictableActions as $raction ) { |
247 | | - $text = wfMsgExt( "deletequeue-showvotes-restrict-$raction", array( 'parseinline' ) ); |
248 | | - $link = $sk->makeKnownLinkObj( $article->mTitle, $text, "action=delviewvotes&votetype=$raction" ); |
249 | | - $restrictions .= "\n<li>$link</li>"; |
250 | | - } |
251 | | - $restrictions .= Xml::closeElement( 'ul' ); |
252 | | - |
253 | | - $wgOut->addHTML( $restrictions ); |
254 | | - |
255 | | - // Sort votes by user. |
256 | | - $dqi = DeleteQueueItem::newFromArticle( $article ); |
257 | | - $votes = $dqi->getVotes(); |
258 | | - |
259 | | - $votesByUser = array(); |
260 | | - |
261 | | - foreach( $votes as $vote ) { |
262 | | - $user = $vote['user']; |
263 | | - |
264 | | - if ($restrict_type && $restrict_type != $vote['type']) |
265 | | - continue; |
266 | | - |
267 | | - if ( !isset( $votesByUser[$user] ) ) { |
268 | | - $votesByUser[$user] = array(); |
269 | | - } |
270 | | - |
271 | | - $votesByUser[$user][] = $vote; |
272 | | - } |
273 | | - |
274 | | - // Link batch. |
275 | | - $lb = new LinkBatch(); |
276 | | - foreach( array_keys($votes) as $user ) { |
277 | | - $lb->add( NS_USER, $user ); |
278 | | - $lb->add( NS_USER_TALK, $user ); |
279 | | - } |
280 | | - |
281 | | - $voteDisplay = array(); |
282 | | - |
283 | | - if ( count($votesByUser) == 0 ) { |
284 | | - $suffix = $restrict_type ? "-$restrict_type" : ''; |
285 | | - $wgOut->addWikiMsg( "deletequeue-showvotes-none$suffix" ); |
286 | | - } |
287 | | - |
288 | | - // Display |
289 | | - foreach( $votesByUser as $user => $votes ) { |
290 | | - $id = User::idFromName($user); |
291 | | - $user = $sk->userLink( $id, $user ) . ' ' . |
292 | | - $sk->userToolLinks( $id, $user ); |
293 | | - |
294 | | - $userVotes = array(); |
295 | | - |
296 | | - foreach( $votes as $vote ) { |
297 | | - $type = $vote['type']; |
298 | | - $comment = $sk->commentBlock( $vote['comment'] ); |
299 | | - $timestamp = $wgLang->timeanddate( $vote['timestamp'] ); |
300 | | - $thisvote = wfMsgExt( "deletequeue-showvotes-vote-$type", array( 'parseinline', 'replaceafter' ), $timestamp, $comment ); |
301 | | - |
302 | | - if ($vote['current'] == 0) |
303 | | - $thisvote = Xml::tags( 's', null, $thisvote ); |
304 | | - |
305 | | - $userVotes[] = Xml::tags( 'li', array( 'class' => "mw-deletequeue-vote-$type" ), $thisvote ); |
306 | | - } |
307 | | - |
308 | | - $uv = $user . Xml::tags( 'ul', null, implode( "\n", $userVotes ) ); |
309 | | - $voteDisplay[] = Xml::tags( 'li', null, $uv ); |
310 | | - } |
311 | | - |
312 | | - $wgOut->addHTML( Xml::tags( 'ol', null, implode( "\n", $voteDisplay ) ) ); |
313 | | - } |
314 | 37 | } |
Index: trunk/extensions/DeleteQueue/SpecialDeleteQueue.php |
— | — | @@ -6,131 +6,37 @@ |
7 | 7 | function __construct() { |
8 | 8 | parent::__construct( 'DeleteQueue' ); |
9 | 9 | } |
10 | | - |
11 | | - public function execute( $par ) { |
12 | | - global $wgOut; |
13 | | - |
| 10 | + |
| 11 | + function execute( $subpage ) { |
| 12 | + $params = explode( '/', $subpage ); |
| 13 | + |
14 | 14 | wfLoadExtensionMessages('DeleteQueue'); |
15 | | - $wgOut->setPageTitle( wfMsg( 'deletequeue' ) ); |
16 | | - |
17 | | - $this->loadSearch(); |
18 | | - |
19 | | - // Intro text |
20 | | - $wgOut->addWikiMsg( 'deletequeue-list-text' ); |
21 | | - |
22 | | - // Search box |
23 | | - $searchBox = array(); |
24 | | - |
25 | | - //// Queue selector |
26 | | - $selector = Xml::openElement( 'select', array( 'name' => 'queue' ) ) . "\n"; |
27 | | - $queues = array( 'speedy', 'prod', 'deletediscuss' ); |
28 | | - $attribs = array( 'value' => '' ); |
29 | | - if ( in_array( $this->mQueue, $queues ) ) |
30 | | - $attribs['selected'] = 'selected'; |
31 | | - $selector .= Xml::element( 'option', $attribs, wfMsg( 'deletequeue-list-anyqueue' ) ); |
32 | | - foreach( $queues as $queue ) { |
33 | | - $attribs = array( 'value' => $queue ); |
34 | | - if ($this->mQueue == $queue) |
35 | | - $attribs['selected'] = 'selected'; |
36 | | - $selector .= Xml::element( 'option', $attribs, wfMsg( "deletequeue-queue-$queue" ) ); |
| 15 | + |
| 16 | + global $wgOut, $wgScriptPath, $wgDeleteQueueStyleVersion; |
| 17 | + $wgOut->addExtensionStyle( |
| 18 | + "$wgScriptPath/extensions/DeleteQueue/deletequeue.css?" |
| 19 | + . $wgDeleteQueueStyleVersion |
| 20 | + ); |
| 21 | + |
| 22 | + // Default |
| 23 | + $viewName = 'DeleteQueueViewList'; |
| 24 | + |
| 25 | + if ( !count($params) ) { |
| 26 | + // Default |
| 27 | + } elseif ( $params[0] == 'nominate' && count($params)==3 ) { |
| 28 | + $viewName = 'DeleteQueueViewNominate'; |
| 29 | + } elseif ( $params[0] == 'vote' && count($params) == 2 ) { |
| 30 | + $viewName = 'DeleteQueueViewVote'; |
| 31 | + } elseif ( $params[0] == 'case' && count($params) == 2 ) { |
| 32 | + $viewName = 'DeleteQueueViewCase'; |
| 33 | + } elseif ( $params[0] == 'case' && |
| 34 | + count($params) == 3 && |
| 35 | + $params[2] = 'review' |
| 36 | + ) { |
| 37 | + $viewName = 'DeleteQueueViewReview'; |
37 | 38 | } |
38 | | - $selector .= Xml::closeElement( 'select' ); |
39 | | - |
40 | | - $searchBox['deletequeue-list-queue'] = $selector; |
41 | | - $searchBox['deletequeue-list-status'] = Xml::checkLabel( wfMsg( 'deletequeue-list-expired' ), 'expired', 'mw-dq-expired', $this->mExpired ); |
42 | | - |
43 | | - $searchBox = Xml::buildForm( $searchBox, 'deletequeue-list-search' ); |
44 | | - $searchBox .= Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ); |
45 | | - $searchBox = Xml::tags( 'form', array( 'action' => $this->getTitle()->getFullURL(), 'method' => 'get' ), $searchBox ); |
46 | | - $searchBox = Xml::fieldset( wfMsg( 'deletequeue-list-search-legend' ), $searchBox ); |
47 | | - |
48 | | - $wgOut->addHTML( $searchBox ); |
49 | | - |
50 | | - $conds = array('dq_active' => 1); |
51 | | - |
52 | | - if ($this->mQueue) |
53 | | - $conds['dq_queue'] = $this->mQueue; |
54 | | - |
55 | | - if ($this->mExpired) { |
56 | | - $dbr = wfGetDB(DB_SLAVE); |
57 | | - $conds[] = 'dq_expiry<'.$dbr->addQuotes($dbr->timestamp( wfTimestampNow() ) ); |
58 | | - } |
59 | | - |
60 | | - // Headers |
61 | | - |
62 | | - $body = ''; |
63 | | - $headers = array( 'page', 'queue', 'votes', 'expiry', 'discusspage' ); |
64 | | - foreach( $headers as $header ) { |
65 | | - $body .= Xml::element( 'th', null, wfMsg( "deletequeue-list-header-$header" ) ) . "\n"; |
66 | | - } |
67 | | - |
68 | | - $body = Xml::tags( 'tr', null, $body ); |
69 | | - |
70 | | - // The list itself |
71 | | - $pager = new DeleteQueuePager($conds); |
72 | | - $body .= $pager->getBody(); |
73 | | - $body = Xml::tags( 'table', array( 'class' => 'wikitable' ), $body ); |
74 | | - |
75 | | - $wgOut->addHTML( $pager->getNavigationBar() . $body . $pager->getNavigationBar() ); |
| 39 | + |
| 40 | + $view = new $viewName( $this ); |
| 41 | + $view->show( $params ); |
76 | 42 | } |
77 | | - |
78 | | - public function loadSearch() { |
79 | | - global $wgRequest; |
80 | | - |
81 | | - $this->mQueue = $wgRequest->getText( 'queue' ); |
82 | | - $this->mExpired = $wgRequest->getBool( 'expired' ); |
83 | | - } |
84 | 43 | } |
85 | | - |
86 | | -class DeleteQueuePager extends ReverseChronologicalPager { |
87 | | - function __construct( $conds ) { |
88 | | - parent::__construct(); |
89 | | - $this->mConds = $conds; |
90 | | - } |
91 | | - |
92 | | - function formatRow( $row ) { |
93 | | - static $sk=null; |
94 | | - |
95 | | - if (is_null($sk)) { |
96 | | - global $wgUser; |
97 | | - $sk = $wgUser->getSkin(); |
98 | | - } |
99 | | - |
100 | | - $a = Article::newFromID($row->dq_page); |
101 | | - $t = $a->mTitle; |
102 | | - $dqi = DeleteQueueItem::newFromArticle( $a ); |
103 | | - $dqi->loadFromRow( $row ); |
104 | | - $queue = $dqi->getQueue(); |
105 | | - global $wgLang; |
106 | | - |
107 | | - if ($dqi->getQueue() == 'deletediscuss') { |
108 | | - $discusspage = $sk->makeKnownLinkObj( $dqi->getDiscussionPage()->mTitle ); |
109 | | - } else $discusspage = ''; |
110 | | - |
111 | | - if ($row->dq_expiry > $row->dq_timestamp) { |
112 | | - $expirestr = $wgLang->timeanddate( $row->dq_expiry ); |
113 | | - } else $expirestr = ''; |
114 | | - |
115 | | - $tr = ''; |
116 | | - |
117 | | - $tr .= Xml::tags( 'td', null, $sk->makeKnownLinkObj( $t, $t->getPrefixedText() ) ); |
118 | | - $tr .= Xml::element( 'td', null, wfMsg( "deletequeue-queue-$queue" ) ); |
119 | | - $tr .= Xml::tags( 'td', null, $sk->makeKnownLinkObj( $t, wfMsg( 'deletequeue-list-votecount', $dqi->getActiveEndorseCount(), $dqi->getActiveObjectCount() ), 'action=delviewvotes' ) ); |
120 | | - $tr .= Xml::element( 'td', null, $expirestr ); |
121 | | - $tr .= Xml::tags( 'td', null, $discusspage ); |
122 | | - |
123 | | - return Xml::tags( 'tr', null, $tr ) . "\n"; |
124 | | - } |
125 | | - |
126 | | - function getQueryInfo() { |
127 | | - return array( |
128 | | - 'tables' => 'delete_queue', |
129 | | - 'fields' => '*', |
130 | | - 'conds' => $this->mConds, |
131 | | - ); |
132 | | - } |
133 | | - |
134 | | - function getIndexField() { |
135 | | - return 'dq_case'; |
136 | | - } |
137 | | -} |