From db3f63ff01b3a9dc3aa613da1de0176d7a5476a9 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Fri, 18 Mar 2005 10:51:17 +0000 Subject: [PATCH] Re-establishing validation feature (the beginnings) --- includes/Article.php | 23 +++++++++++++++++++++-- includes/SkinTemplate.php | 25 ++++++++++++++++++++----- maintenance/archives/patch-validate.sql | 12 ++++++------ 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 1b2668b55c..b93144979d 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 . ")
" ; + } + $t .= "Revision {$revision}" ;*/ - $wgOut->addWikiText ( "Not implemented yet" ) ; + $wgOut->addHTML ( $t ) ; } /** diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 88544fd50f..252450ddb8 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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 { diff --git a/maintenance/archives/patch-validate.sql b/maintenance/archives/patch-validate.sql index 8c77462ac9..f3f6341c71 100644 --- a/maintenance/archives/patch-validate.sql +++ b/maintenance/archives/patch-validate.sql @@ -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; - -- 2.20.1