Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -861,17 +861,24 @@ |
862 | 862 | return array( -1, null, $new_text ); |
863 | 863 | } |
864 | 864 | |
865 | | - $header_regexp = "/^<pagequality level=\"(0|1|2|3|4)\" user=\"(.*?)\" \/>/"; |
866 | 865 | $header = $m[1]; |
867 | 866 | $body = $m[2]; |
868 | 867 | $footer = $m[3]; |
869 | | - if( !preg_match( $header_regexp, $header, $m2 ) ) { |
870 | | - $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />" |
871 | | - ."$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>"; |
872 | | - return array( -1, null, $new_text ); |
| 868 | + |
| 869 | + $header_regexp = "/^<pagequality level=\"(0|1|2|3|4)\" user=\"(.*?)\" \/>/"; |
| 870 | + if( preg_match( $header_regexp, $header, $m2 ) ) { |
| 871 | + return array( intval($m2[1]), $m2[2], null ); |
873 | 872 | } |
874 | 873 | |
875 | | - return array( intval($m2[1]), $m2[2], null ); |
| 874 | + $old_header_regexp = "/^\{\{PageQuality\|(0|1|2|3|4)(|\|(.*?))\}\}/is"; |
| 875 | + if( preg_match( $old_header_regexp, $header, $m3 ) ) { |
| 876 | + return array( intval($m3[1]), $m3[3], null ); |
| 877 | + } |
| 878 | + |
| 879 | + $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />" |
| 880 | + ."$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>"; |
| 881 | + return array( -1, null, $new_text ); |
| 882 | + |
876 | 883 | } |
877 | 884 | |
878 | 885 | |
— | — | @@ -946,7 +953,7 @@ |
947 | 954 | list( $q , $username, $ptext ) = pr_parse_page( $text ); |
948 | 955 | if( $q == -1 ) { |
949 | 956 | $editpage->textbox1 = $ptext; |
950 | | - return true; |
| 957 | + $q = 1; |
951 | 958 | } |
952 | 959 | |
953 | 960 | //read previous revision, so that I know how much I need to add to pr_index |
— | — | @@ -954,6 +961,22 @@ |
955 | 962 | if( $rev ) { |
956 | 963 | $old_text = $rev->getText(); |
957 | 964 | list( $old_q , $old_username, $old_ptext ) = pr_parse_page( $old_text ); |
| 965 | + if( $old_q != -1 ) { |
| 966 | + //check usernames |
| 967 | + if( ($old_q != $q) && $wgUser->isAnon() ) { |
| 968 | + $wgOut->showErrorPage( 'proofreadpage_nologin', 'proofreadpage_nologintext' ); |
| 969 | + return false; |
| 970 | + } |
| 971 | + if ( ( ($old_username != $username) || ($old_q != $q) ) && ($wgUser->getName() != $username) ) { |
| 972 | + $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
| 973 | + return false; |
| 974 | + } |
| 975 | + if( ( ($q == 4) && ($old_q < 3) ) || ( ($q == 4) && ($old_q == 3) && ($old_username == $username) ) ) { |
| 976 | + $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
| 977 | + return false; |
| 978 | + } |
| 979 | + } |
| 980 | + else $old_q = 1; |
958 | 981 | } else { |
959 | 982 | if($q == 4) { |
960 | 983 | $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
— | — | @@ -962,22 +985,6 @@ |
963 | 986 | $old_q = -1; |
964 | 987 | } |
965 | 988 | |
966 | | - //check usernames |
967 | | - if( $old_q != -1 ) { |
968 | | - if( ($old_q != $q) && $wgUser->isAnon() ) { |
969 | | - $wgOut->showErrorPage( 'proofreadpage_nologin', 'proofreadpage_nologintext' ); |
970 | | - return false; |
971 | | - } |
972 | | - if ( ( ($old_username != $username) || ($old_q != $q) ) && ($wgUser->getName() != $username) ) { |
973 | | - $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
974 | | - return false; |
975 | | - } |
976 | | - if( ( ($q == 4) && ($old_q < 3) ) || ( ($q == 4) && ($old_q == 3) && ($old_username == $username) ) ) { |
977 | | - $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' ); |
978 | | - return false; |
979 | | - } |
980 | | - } |
981 | | - |
982 | 989 | $editpage->mArticle->new_q = $q; |
983 | 990 | $editpage->mArticle->old_q = $old_q; |
984 | 991 | |