Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql |
— | — | @@ -6,7 +6,6 @@ |
7 | 7 | -- This stores all of our reviews, |
8 | 8 | -- the corresponding tags are stored in the tag table |
9 | 9 | CREATE TABLE /*$wgDBprefix*/flaggedrevs ( |
10 | | - fr_id int(10) NOT NULL auto_increment, |
11 | 10 | fr_namespace int NOT NULL default '0', |
12 | 11 | fr_title varchar(255) binary NOT NULL default '', |
13 | 12 | fr_rev_id int(10) NOT NULL, |
— | — | @@ -21,7 +20,7 @@ |
22 | 21 | |
23 | 22 | PRIMARY KEY (fr_namespace,fr_title,fr_rev_id), |
24 | 23 | UNIQUE KEY (fr_rev_id), |
25 | | - UNIQUE KEY (fr_id) |
| 24 | + INDEX (fr_namespace,fr_title,fr_quality,fr_rev_id) |
26 | 25 | ) TYPE=InnoDB; |
27 | 26 | |
28 | 27 | -- This stores all of our tag data |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | // We must at least rate each category as 1, the minimum |
88 | 88 | // Exception: we can rate ALL as unapproved to depreciate a revision |
89 | 89 | $this->isValid = true; |
90 | | - if ( $this->upprovedTags && $this->upprovedTags < count($wgFlaggedRevTags) ) |
| 90 | + if ( $this->upprovedTags && ($this->upprovedTags < count($wgFlaggedRevTags) || !$this->oflags) ) |
91 | 91 | $this->isValid = false; |
92 | 92 | |
93 | 93 | if( $this->isValid && $wgRequest->wasPosted() ) { |
— | — | @@ -173,9 +173,12 @@ |
174 | 174 | foreach( $ratioset as $item ) { |
175 | 175 | list( $message, $name, $field ) = $item; |
176 | 176 | // Don't give options the user can't set unless its the status quo |
177 | | - $disabled = ( !$this->userCan($set,$field) ) ? array('disabled' => 'true') : array(); |
| 177 | + $attribs = array('id' => $name.$field); |
| 178 | + if( !$this->userCan($set,$field) ) |
| 179 | + $attribs['disabled'] = 'true'; |
178 | 180 | $form .= "<div>"; |
179 | | - $form .= Xml::radio( $name, $field, ($field==$this->dims[$set]), $disabled ) . ' ' . wfMsg($message); |
| 181 | + $form .= Xml::radio( $name, $field, ($field==$this->dims[$set]), $attribs ); |
| 182 | + $form .= Xml::label( wfMsg($message), $name.$field ); |
180 | 183 | $form .= "</div>\n"; |
181 | 184 | } |
182 | 185 | $form .= '</td><td width=\'20\'></td>'; |
— | — | @@ -225,30 +228,37 @@ |
226 | 229 | $approved = false; |
227 | 230 | # If all values are set to zero, this has been unapproved |
228 | 231 | foreach( $this->dims as $quality => $value ) { |
229 | | - if( $value ) $approved = true; |
| 232 | + if( $value ) { |
| 233 | + $approved = true; |
| 234 | + break; |
| 235 | + } |
230 | 236 | } |
231 | 237 | // We can only approve actual revisions... |
232 | 238 | if ( $approved ) { |
233 | 239 | $rev = Revision::newFromTitle( $this->page, $this->oldid ); |
234 | 240 | // Do not mess with archived/deleted revisions |
235 | 241 | if ( is_null($rev) || $rev->mDeleted ) { |
236 | | - $wgOut->showErrorPage( 'internalerror', 'badarticleerror' ); |
| 242 | + $wgOut->showErrorPage( 'internalerror', 'revnotfoundtext' ); |
237 | 243 | return; |
238 | 244 | } |
239 | 245 | } else { |
240 | 246 | $frev = FlaggedRevs::getFlaggedRev( $this->oldid ); |
| 247 | + // If we can't find this flagged rev, return to page??? |
241 | 248 | if ( is_null($frev) ) { |
242 | | - $wgOut->showErrorPage( 'internalerror', 'badarticleerror' ); |
| 249 | + $wgOut->redirect( $this->page->escapeLocalUrl() ); |
243 | 250 | return; |
244 | 251 | } |
245 | 252 | } |
246 | 253 | |
247 | | - $success = ( $approved ) ? |
248 | | - $this->approveRevision( $rev, $this->notes ) : $this->unapproveRevision( $frev ); |
| 254 | + $success = $approved ? $this->approveRevision( $rev, $this->notes ) : $this->unapproveRevision( $frev ); |
| 255 | + |
249 | 256 | // Return to our page |
250 | 257 | if ( $success ) { |
251 | | - if( $request->getCheck( 'wpWatchthis' ) ) |
| 258 | + if( $request->getCheck( 'wpWatchthis' ) ) { |
252 | 259 | $wgUser->addWatch( $this->page ); |
| 260 | + } else { |
| 261 | + $wgUser->removeWatch( $this->page ); |
| 262 | + } |
253 | 263 | $wgOut->redirect( $this->page->escapeLocalUrl() ); |
254 | 264 | } else { |
255 | 265 | $wgOut->showErrorPage( 'internalerror', 'badarticleerror' ); |
— | — | @@ -739,20 +749,20 @@ |
740 | 750 | global $wgContentNamespaces; |
741 | 751 | |
742 | 752 | list( $page, $flaggedrevs ) = $dbr->tableNamesN( 'page', 'flaggedrevs' ); |
743 | | - |
| 753 | + |
| 754 | + # Must be a content page... |
| 755 | + $contentNS = 'page_namespace IN(' . implode(',',$wgContentNamespaces) . ')'; |
| 756 | + |
744 | 757 | $ns = ($namespace !== null) ? "page_namespace=$namespace" : '1 = 1'; |
| 758 | + |
745 | 759 | $where = $includenonquality ? '1 = 1' : 'fr_rev_id IS NULL'; |
746 | | - $having = $includenonquality ? '(MAX(fr_quality) IS NULL OR MAX(fr_quality) < 1)' : '1 = 1'; |
747 | | - $content = array(); |
748 | | - foreach( $wgContentNamespaces as $cns ) { |
749 | | - $content[] = "page_namespace=$cns"; |
750 | | - } |
751 | | - $content = implode(' OR ',$content); |
| 760 | + $having = $includenonquality ? 'NOT MAX(fr_quality) > 1' : '1 = 1'; |
| 761 | + |
752 | 762 | $sql = |
753 | 763 | "SELECT page_namespace,page_title,page_len AS size |
754 | 764 | FROM $page |
755 | 765 | LEFT JOIN $flaggedrevs ON (fr_namespace = page_namespace AND fr_title = page_title) |
756 | | - WHERE page_is_redirect=0 AND $ns AND ($content) AND ($where) |
| 766 | + WHERE page_is_redirect=0 AND $ns AND $contentNS AND ($where) |
757 | 767 | GROUP BY page_id HAVING $having "; |
758 | 768 | return $sql; |
759 | 769 | } |