From dabfc262ba2edf5b67826751959b5bc537e5cc61 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Sun, 25 Jul 2004 15:24:30 +0000 Subject: [PATCH] Article validation code --- includes/SpecialValidate.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index a7cf40830d..4e9b0b4d47 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -75,12 +75,9 @@ class Validation # Now we get all the "votes" for the different versions of this article for this user $val = $this->get_prev_data ( $wgUser->getID() , $article_title ) ; - krsort ( $val ) ; # Newest versions first - - #print "!" . count ( $val ) ; # No votes for this version, initial data - if ( count ( $val ) == 0 ) + if ( !isset ( $val[$article_time] ) ) { if ( $article_time == "" ) { @@ -89,7 +86,9 @@ class Validation } $val[$article_time] = array () ; } - + + krsort ( $val ) ; # Newest versions first + # User has clicked "Doit" before, so evaluate form if ( isset ( $_POST['doit'] ) ) { @@ -168,7 +167,7 @@ class Validation $html .= "\n" ; } $html .= "" ; - $html .= str_replace ( "$1" , $article->getPrefixedURL() , wfMsg("val_clear_old") ) ; + $html .= str_replace ( "$1" , $article->getLocalURL() , wfMsg("val_clear_old") ) ; $html .= "" ; $html .= "\n" ; } @@ -186,7 +185,7 @@ class Validation if ( $sql != "" ) $sql = " WHERE " . $sql ; $sql = "SELECT * FROM validate" . $sql ; $res = wfQuery( $sql, DB_READ ); - while( $s = wfFetchObject( $res ) ) $ret["{$s->val_title}"]["{$s->val_timestamp}"]["{$s->val_type}"] = $s ; + while( $s = wfFetchObject( $res ) ) $ret["{$s->val_title}"]["{$s->val_timestamp}"]["{$s->val_type}"][] = $s ; return $ret ; } @@ -199,6 +198,7 @@ class Validation $d = $this->getData ( -1 , $article_title , -1 ) ; if ( count ( $d ) ) $d = array_shift ( $d ) ; else $d = array () ; + krsort ( $d ) ; $html .= "\n" ; $html .= "" ; foreach ( $validationtypes AS $idx => $title ) @@ -210,20 +210,23 @@ class Validation foreach ( $d AS $version => $data ) { $title = Title::newFromDBkey ( $article_title ) ; - $version_link = $title->getFullURL( "action=validate×tamp={$version}" ) ; + $version_link = $title->getLocalURL( "action=validate×tamp={$version}" ) ; $version_link = "" . gmdate("F d, Y H:i:s",wfTimestamp2Unix($version)) . "" ; $html .= "" ; $html .= "" ; $vmax = array() ; $vcur = array() ; - foreach ( $data AS $type => $x ) + foreach ( $data AS $type => $x2 ) { if ( !isset ( $vcur[$type] ) ) $vcur[$type] = 0 ; if ( !isset ( $vmax[$type] ) ) $vmax[$type] = 0 ; - $vcur[$type] += $x->val_value ; - $temp = explode ( "|" , $validationtypes[$type]) ; - $vmax[$type] += $temp[3] - 1 ; + foreach ( $x2 AS $user => $x ) + { + $vcur[$type] += $x->val_value ; + $temp = explode ( "|" , $validationtypes[$type]) ; + $vmax[$type] += $temp[3] - 1 ; + } } -- 2.20.1
Version
{$version_link}