Re-establishing validation feature (the beginnings)
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Fri, 18 Mar 2005 10:51:17 +0000 (10:51 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Fri, 18 Mar 2005 10:51:17 +0000 (10:51 +0000)
includes/Article.php
includes/SkinTemplate.php
maintenance/archives/patch-validate.sql

index 1b2668b..b931449 100644 (file)
@@ -1237,10 +1237,29 @@ class Article {
         * Validate function
         */
        function validate() {
-               global $wgOut, $wgUser;
+               global $wgOut, $wgUser, $wgRequest, $wgUseValidation;
+               
+               if ( !$wgUseValidation ) # Are we using article validation at all?
+               {
+                       $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
+                       return ;
+               }
+               
                $wgOut->setRobotpolicy( 'noindex,follow' );
+               $revision = $wgRequest->getVal( 'revision' );
+               
+               include_once ( "SpecialValidate.php" ) ; # The "Validation" class
+               
+               $v = new Validation ;
+               $t = $v->validatePageForm ( $this , $revision ) ;
+/*             $a = $v->getTopicList () ;
+               $t = "" ;
+               foreach ( $a AS $x => $y ) {
+                       $t .= $x . " : " . $y->val_comment . " (1-" . $y->val_value . ")<br>" ;
+                       }
+               $t .= "Revision {$revision}" ;*/
                
-               $wgOut->addWikiText ( "Not implemented yet" ) ;
+               $wgOut->addHTML ( $t ) ;
        }
 
        /**
index 88544fd..252450d 100644 (file)
@@ -616,11 +616,26 @@ class SkinTemplate extends Skin {
 
                                # Validate tab. TODO: add validation to logged-in user rights 
                                if($wgUseValidation){ # && $wgUser->isAllowed('validate')){
-                               $content_actions['validate'] = array(
-                                       'class' => ($action == 'validate') ? 'selected' : false,
-                                       'text' => wfMsg('val_tab'),
-                                       'href' => $this->mTitle->getLocalUrl( 'action=validate' )
-                                       );
+                               #$oid = $oldid ? '&revision='.IntVal( $oldid ) : "" ;
+                               if ( $oldid ) $oid = IntVal( $oldid ) ; # Use the oldid
+                               else
+                                       {# Trying to get the current article revision through this weird stunt
+                                       $tid = $this->mTitle->getArticleID();
+                                       $tns = $this->mTitle->getNamespace();
+                                       $sql = "SELECT page_latest FROM page WHERE page_id={$tid} AND page_namespace={$tns}" ;
+                                       $res = wfQuery( $sql, DB_READ );
+                                       if( $s = wfFetchObject( $res ) )
+                                               $oid = $s->page_latest ;
+                                       else $oid = "" ; # Something's wrong, like the article has been deleted in the last 10 ns
+                                       }
+                               if ( $oid != "" ) {
+                                       $oid = "&revision={$oid}" ;
+                                       $content_actions['validate'] = array(
+                                               'class' => ($action == 'validate') ? 'selected' : false,
+                                               'text' => wfMsg('val_tab'),
+                                               'href' => $this->mTitle->getLocalUrl( "action=validate{$oid}" )
+                                               );
+                                       }
                                }
                        }
                } else {
index 8c77462..f3f6341 100644 (file)
@@ -1,12 +1,12 @@
 -- For article validation
 
-CREATE TABLE /*$wgDBprefix*/validate (
+DROP TABLE IF EXISTS `validate`;
+CREATE TABLE `validate` (
   `val_user` int(11) NOT NULL default '0',
-  `val_title` varchar(255) binary NOT NULL default '',
-  `val_timestamp` varchar(14) binary NOT NULL default '',
-  `val_type` int(10) unsigned NOT NULL default '0',
+  `val_page` int(11) unsigned NOT NULL default '0',
+  `val_revision` int(11) unsigned NOT NULL default '0',
+  `val_type` int(11) unsigned NOT NULL default '0',
   `val_value` int(11) default '0',
   `val_comment` varchar(255) NOT NULL default '',
-  KEY `val_user` (`val_user`,`val_title`,`val_timestamp`)
+  KEY `val_user` (`val_user`,`val_revision`)
 ) TYPE=MyISAM;
-