Index: trunk/extensions/CodeReview/CodeRevisionListView.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | |
26 | 26 | // Check for batch change requests. |
27 | 27 | $editToken = $wgRequest->getVal( 'wpBatchChangeEditToken' ); |
28 | | - if ( $wgUser->matchEditToken( $editToken ) ) { |
| 28 | + if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $editToken ) ) { |
29 | 29 | $this->doBatchChange(); |
30 | 30 | return; |
31 | 31 | } |
— | — | @@ -32,8 +32,9 @@ |
33 | 33 | $this->showForm(); |
34 | 34 | $pager = $this->getPager(); |
35 | 35 | |
36 | | - // Batch change interface. |
37 | | - $changeInterface = $this->buildBatchInterface( $pager ); |
| 36 | + // Build batch change interface as needed |
| 37 | + $this->batchForm = $wgUser->isAllowed('codereview-set-status') || |
| 38 | + $wgUser->isAllowed('codereview-add-tag'); |
38 | 39 | |
39 | 40 | $wgOut->addHTML( |
40 | 41 | $pager->getNavigationBar() . |
— | — | @@ -43,7 +44,7 @@ |
44 | 45 | ) . |
45 | 46 | $pager->getBody() . |
46 | 47 | $pager->getNavigationBar() . |
47 | | - $changeInterface . |
| 48 | + ( $this->batchForm ? $this->buildBatchInterface( $pager ) : "" ). |
48 | 49 | Xml::closeElement( 'form' ) |
49 | 50 | ); |
50 | 51 | } |
— | — | @@ -94,7 +95,7 @@ |
95 | 96 | $wgOut->redirect( $this->getPager()->getTitle()->getFullURL( $fields ) ); |
96 | 97 | } |
97 | 98 | |
98 | | - function buildBatchInterface( $pager ) { |
| 99 | + protected function buildBatchInterface( $pager ) { |
99 | 100 | global $wgUser; |
100 | 101 | |
101 | 102 | $changeInterface = ''; |
— | — | @@ -110,11 +111,12 @@ |
111 | 112 | ); |
112 | 113 | } |
113 | 114 | |
114 | | - if ($wgUser->isAllowed( 'codereview-add-tag' ) ) { |
115 | | - $changeFields['code-batch-tags'] = |
116 | | - CodeRevisionView::addTagForm( '', '' ); |
| 115 | + if( $wgUser->isAllowed( 'codereview-add-tag' ) ) { |
| 116 | + $changeFields['code-batch-tags'] = CodeRevisionView::addTagForm( '', '' ); |
117 | 117 | } |
118 | 118 | |
| 119 | + if( !count($changeFields) ) return ''; // nothing to do here |
| 120 | + |
119 | 121 | $changeInterface = Xml::fieldset( wfMsg('codereview-batch-title'), |
120 | 122 | Xml::buildForm( $changeFields, 'codereview-batch-submit' ) ); |
121 | 123 | |
— | — | @@ -209,8 +211,7 @@ |
210 | 212 | } |
211 | 213 | |
212 | 214 | function getFieldNames() { |
213 | | - return array( |
214 | | - 'selectforchange' => wfMsg( 'code-field-select' ), |
| 215 | + $fields = array( |
215 | 216 | $this->getDefaultSort() => wfMsg( 'code-field-id' ), |
216 | 217 | 'cr_status' => wfMsg( 'code-field-status' ), |
217 | 218 | 'comments' => wfMsg( 'code-field-comments' ), |
— | — | @@ -219,6 +220,11 @@ |
220 | 221 | 'cr_author' => wfMsg( 'code-field-author' ), |
221 | 222 | 'cr_timestamp' => wfMsg( 'code-field-timestamp' ), |
222 | 223 | ); |
| 224 | + # Only show checkboxen as needed |
| 225 | + if( !empty($this->mView->batchForm) ) { |
| 226 | + $fields = array('selectforchange' => wfMsg('code-field-select') ) + $fields; |
| 227 | + } |
| 228 | + return $fields; |
223 | 229 | } |
224 | 230 | |
225 | 231 | function formatValue( $name, $value ) {} // unused |
— | — | @@ -228,8 +234,7 @@ |
229 | 235 | switch( $name ) { |
230 | 236 | case 'selectforchange': |
231 | 237 | $sort = $this->getDefaultSort(); |
232 | | - return Xml::check( "wpRevisionSelected[]", false, |
233 | | - array( 'value' => $row->$sort ) ); |
| 238 | + return Xml::check( "wpRevisionSelected[]", false, array( 'value' => $row->$sort ) ); |
234 | 239 | case 'cp_rev_id': |
235 | 240 | case 'cr_id': |
236 | 241 | return $this->mView->mSkin->link( |