From 006d7a3bbbd5decdc11a6ef65db9571b36733d8a Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Wed, 28 Jul 2004 20:18:00 +0000 Subject: [PATCH] Article validation code (automatic version merging) --- includes/SpecialValidate.php | 51 +++++++++++++++++++++++++++++++----- languages/Language.php | 5 ++++ 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index e0e72fa120..4ec0869dce 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -94,7 +94,38 @@ class Validation { $oldtime = $_POST['oldtime'] ; if ( !isset ( $val["{$oldtime}"] ) ) $val["{$oldtime}"] = array () ; - if ( isset ( $_POST['clear_other'] ) && $_POST['clear_other'] == 1 ) # Clear all others + + # Reading postdata + $postrad = array () ; + $poscomment = array () ; + for ( $idx = 0 ; $idx < count ( $validationtypes) ; $idx++ ) + { + $postrad[$idx] = $_POST["rad{$idx}"] ; + $postcomment[$idx] = $_POST["comment{$idx}"] ; + } + + # Merge others into this one + if ( isset ( $_POST['merge_other'] ) && $_POST['merge_other'] == 1 ) + { + foreach ( $val AS $time => $stuff ) + { + if ( $time <> $article_time ) + { + for ( $idx = 0 ; $idx < count ( $validationtypes) ; $idx++ ) + { + $rad = $postrad[$idx] ; + if ( isset ( $stuff[$idx] ) AND $stuff[$idx]->val_value != -1 AND $rad == -1 ) + { + $postrad[$idx] = $stuff[$idx]->val_value ; + $postcomment[$idx] = $stuff[$idx]->val_comment ; + } + } + } + } + } + + # Clear all others + if ( isset ( $_POST['clear_other'] ) && $_POST['clear_other'] == 1 ) { $sql = "DELETE FROM validate WHERE val_title='{$article_title}' AND val_timestamp<>'{$oldtime}' AND val_user='" ; $sql .= $wgUser->getID() . "'" ; @@ -103,17 +134,18 @@ class Validation $val = array () ; # So clear others $val["{$oldtime}"] = $val2 ; } - + # Delete old "votes" for this version $sql = "DELETE FROM validate WHERE val_title='{$article_title}' AND val_timestamp='{$oldtime}' AND val_user='" ; $sql .= $wgUser->getID() . "'" ; wfQuery( $sql, DB_WRITE ); + # Incorporate changes for ( $idx = 0 ; $idx < count ( $validationtypes) ; $idx++ ) # Changes { - $comment = $_POST["comment{$idx}"] ; + $comment = $postcomment[$idx] ; $comment_sql = str_replace ( "'" , "\'" , $comment ) ; - $rad = $_POST["rad{$idx}"] ; + $rad = $postrad[$idx] ; if ( !isset ( $val["{$oldtime}"][$idx] ) ) $val["{$oldtime}"][$idx] = "" ; $val["{$oldtime}"][$idx]->val_value = $rad ; $val["{$oldtime}"][$idx]->val_comment = $comment ; @@ -132,8 +164,10 @@ class Validation $skin = $wgUser->getSkin() ; $staturl = $skin->makeSpecialURL ( "validate" , "mode=stat_page&article_title={$article_title}" ) ; - $html .= "" . wfMsg('val_stat_link_text') . "" ; + $html .= "" . wfMsg('val_stat_link_text') . "
\n" ; + $html .= "" . wfMsg('val_form_note') . "
\n" ; + # Generating data tables $tabsep = "" ; $topstyle = "style='border-top:2px solid black'" ; foreach ( $val AS $time => $stuff ) @@ -166,9 +200,12 @@ class Validation $html .= "" ; $html .= "\n" ; } - $html .= "" ; + $html .= "" ; + $html .= "" ; + $html .= wfMsg ( 'val_merge_old' ); + $html .= "
" ; $html .= wfMsg ( 'val_clear_old', $skin->makeKnownLinkObj( $article ) ); - $html .= "" ; + $html .= "" ; $html .= "\n" ; } return $html ; diff --git a/languages/Language.php b/languages/Language.php index 3343edfdcc..a53c9b6b46 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1260,6 +1260,11 @@ Type the name of the user in the box and press the button to make the user an ad # Validation 'val_clear_old' => 'Clear my other validation data for $1', +'val_merge_old' => 'Merge my other validation data into this version', +'val_form_note' => 'Hint : Merging your data means that, for the version you hit OK for, all options you have selected no opinion +will be set to the value and comment of the most recent version you have expressed an opinion for. For example, if you want to change a single option +on a new version, but also keep your other setting for this article in this version, just select what you intend to change, and merging will +fill up the other options with your prior settings.', 'val_noop' => 'No opinion', 'val_percent' => '$1%
($2 of $3 points by $4 users)', 'val_percent_single' => '$1%
($2 of $3 points by one user)', -- 2.20.1