Imported latest features from the stable branch
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 12 Nov 2003 13:07:08 +0000 (13:07 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 12 Nov 2003 13:07:08 +0000 (13:07 +0000)
includes/Article.php
includes/SpecialMovepage.php
includes/SpecialPreferences.php
includes/SpecialUserlogin.php
includes/User.php

index 51d27dc..e700d97 100644 (file)
@@ -686,6 +686,11 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                        }
                }
                
+               # The talk page isn't in the regular link tables, so we need to update manually:
+               $talkns = $ns ^ 1; # talk -> normal; normal -> talk
+               $sql = "UPDATE cur set cur_touched='$now' WHERE cur_namespace=$talkns AND cur_title='" . wfStrencode( $ttl ) . "'";
+               wfQuery( $sql );
+               
                $this->showArticle( $text, wfMsg( "newarticle" ) );
        }
 
@@ -980,6 +985,12 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                        "cur_restrictions='{$limit}' WHERE cur_id={$id}";
                wfQuery( $sql, DB_WRITE, "Article::protect" );
 
+               $log = new LogPage( wfMsg( "protectlogpage" ), wfMsg( "protectlogtext" ) );
+               if ( $limit === "" ) {
+                       $log->addEntry( wfMsg( "unprotectedarticle", $wgTitle->getPrefixedText() ), "" );               
+               } else {
+                       $log->addEntry( wfMsg( "protectedarticle", $wgTitle->getPrefixedText() ), "" )
+               }
                $wgOut->redirect( wfLocalUrl( $this->mTitle->getPrefixedURL() ) );
        }
 
@@ -1436,12 +1447,13 @@ $wgLang->recodeForEdit( $wpTextbox1 ) .
                #
                $tc = "[&;%\\-,.\\(\\)' _0-9A-Za-z\\/:\\x80-\\xff]";
                $np = "[&;%\\-,.' _0-9A-Za-z\\/:\\x80-\\xff]"; # No parens
+               $namespacechar = '[ _0-9A-Za-z\x80-\xff]'; # Namespaces can use non-ascii!
                $conpat = "/^({$np}+) \\(({$tc}+)\\)$/";
 
                $p1 = "/\[\[({$np}+) \\(({$np}+)\\)\\|]]/";             # [[page (context)|]]
                $p2 = "/\[\[\\|({$tc}+)]]/";                                    # [[|page]]
-               $p3 = "/\[\[([A-Za-z _]+):({$np}+)\\|]]/";              # [[namespace:page|]]
-               $p4 = "/\[\[([A-Aa-z _]+):({$np}+) \\(({$np}+)\\)\\|]]/";
+               $p3 = "/\[\[($namespacechar+):({$np}+)\\|]]/";          # [[namespace:page|]]
+               $p4 = "/\[\[($namespacechar+):({$np}+) \\(({$np}+)\\)\\|]]/";
                                                                                                                # [[ns:page (cont)|]]
                $context = "";
                $t = $this->mTitle->getText();
index 81d8bdc..58471f8 100644 (file)
@@ -130,6 +130,7 @@ class MovePageForm {
                         ( "" == $this->odt ) ||
                         ( "" != $this->ot->getInterwiki() ) ||
                         ( !$this->ot->userCanEdit() ) ||
+                        ( !$this->oldid ) ||
                     ( ! Namespace::isMovable( $nns ) ) ||
                         ( "" == $this->ndt ) ||
                         ( "" != $this->nt->getInterwiki() ) ||
index 822be3a..5149535 100644 (file)
@@ -4,8 +4,8 @@ function wfSpecialPreferences()
        global $wgUser, $wgOut, $wgUseDynamicDates, $action;
        global $wpSaveprefs, $wpReset;
 
-       $fields = array( "wpOldpass", "wpNewpass", "wpRetype",
-         "wpEmail", "wpNick" );
+       $fields = array( "wpOldpass", "wpNewpass", "wpRetypePass",
+         "wpUserEmail", "wpNick" );
        wfCleanFormFields( $fields );
 
        if ( 0 == $wgUser->getID() ) {
@@ -61,13 +61,13 @@ function wfSpecialPreferences()
 /* private */ function savePreferences()
 {
        global $wgUser, $wgLang, $wgDeferredUpdateList;
-       global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetype;
-       global $wpSkin, $wpMath, $wpDate, $wpEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent;
+       global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass;
+       global $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent;
        global $wpSearchLines, $wpSearchChars, $wpStubs;
        global $wpRows, $wpCols, $wpHourDiff, $HTTP_POST_VARS;
 
        if ( "" != $wpNewpass ) {
-               if ( $wpNewpass != $wpRetype ) {
+               if ( $wpNewpass != $wpRetypePass ) {
                        mainPrefsForm( wfMsg( "badretype" ) );                  
                        return;
                }
@@ -80,7 +80,7 @@ function wfSpecialPreferences()
                }
                $wgUser->setPassword( $wpNewpass );
        }
-       $wgUser->setEmail( $wpEmail );
+       $wgUser->setEmail( $wpUserEmail );
        $wgUser->setOption( "nickname", $wpNick );
        $wgUser->setOption( "quickbar", $wpQuickbar );
        $wgUser->setOption( "skin", $wpSkin );
@@ -125,13 +125,13 @@ function wfSpecialPreferences()
 /* private */ function resetPrefs()
 {
        global $wgUser, $wgLang;
-       global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetype, $wpStubs;
-       global $wpRows, $wpCols, $wpSkin, $wpMath, $wpDate, $wpEmail, $wpEmailFlag, $wpNick;
+       global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass, $wpStubs;
+       global $wpRows, $wpCols, $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick;
        global $wpSearch, $wpRecent, $HTTP_POST_VARS;
        global $wpHourDiff, $wpSearchLines, $wpSearchChars;
 
-       $wpOldpass = $wpNewpass = $wpRetype = "";
-       $wpEmail = $wgUser->getEmail();
+       $wpOldpass = $wpNewpass = $wpRetypePass = "";
+       $wpUserEmail = $wgUser->getEmail();
        if ( 1 == $wgUser->getOption( "disablemail" ) ) { $wpEmailFlag = 1; }
        else { $wpEmailFlag = 0; }
        $wpNick = $wgUser->getOption( "nickname" );
@@ -181,6 +181,12 @@ function wfSpecialPreferences()
                        $r1 .= "<label><input type=checkbox value=\"1\" name=\"" .
                          "wpNs$i\"{$checked}>{$name}</label>\n";
                }
+               $name = str_replace( "_", " ", $ns[$i] );
+               if ( "" == $name ) { $name = wfMsg( "blanknamespace" ); }
+
+               if ( 0 != $i ) { $r1 .= " "; }
+               $r1 .= "<label><input type=checkbox value=\"1\" name=\"" .
+                 "wpNs{$i}\"{$checked}>{$name}</label>\n";
        }
        
        return $r1;
@@ -192,8 +198,8 @@ function wfSpecialPreferences()
 /* private */ function mainPrefsForm( $err )
 {
        global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates;
-       global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetype;
-       global $wpSkin, $wpMath, $wpDate, $wpEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent;
+       global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass;
+       global $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent;
        global $wpRows, $wpCols, $wpSaveprefs, $wpReset, $wpHourDiff;
        global $wpSearchLines, $wpSearchChars, $wpStubs, $wgValidSkinNames;
 
@@ -262,12 +268,12 @@ value=\"$i\"$checked> {$qbs[$i]}</label><br>\n" );
        #
        $wpOldpass = wfEscapeHTML( $wpOldpass );
        $wpNewpass = wfEscapeHTML( $wpNewpass );
-       $wpRetype = wfEscapeHTML( $wpRetype );
+       $wpRetypePass = wfEscapeHTML( $wpRetypePass );
 
        $wgOut->addHTML( "</td><td vaign=top nowrap><b>$cp:</b><br>
 <label>$opw: <input type=password name=\"wpOldpass\" value=\"$wpOldpass\" size=20></label><br>
 <label>$npw: <input type=password name=\"wpNewpass\" value=\"$wpNewpass\" size=20></label><br>
-<label>$rpw: <input type=password name=\"wpRetype\" value=\"$wpRetype\" size=20></label><br>
+<label>$rpw: <input type=password name=\"wpRetypePass\" value=\"$wpRetypePass\" size=20></label><br>
 </td></tr>\n" );
 
        # Skin setting
@@ -346,7 +352,7 @@ value=\"$i\"$checked> {$mathopts[$i]}</label><br>\n" );
 
        # Email, etc.
        #
-       $wpEmail = wfEscapeHTML( $wpEmail );
+       $wpUserEmail = wfEscapeHTML( $wpUserEmail );
        $wpNick = wfEscapeHTML( $wpNick );
        if ( $wpEmailFlag ) { $emfc = "checked"; }
        else { $emfc = ""; }
@@ -354,7 +360,7 @@ value=\"$i\"$checked> {$mathopts[$i]}</label><br>\n" );
        $ps = namespacesCheckboxes();
 
        $wgOut->addHTML( "<td valign=top nowrap>
-<label>$yem: <input type=text name=\"wpEmail\" value=\"{$wpEmail}\" size=20></label><br>
+<label>$yem: <input type=text name=\"wpUserEmail\" value=\"{$wpUserEmail}\" size=20></label><br>
 <label><input type=checkbox $emfc value=\"1\" name=\"wpEmailFlag\"> $emf</label><br>
 <label>$ynn: <input type=text name=\"wpNick\" value=\"{$wpNick}\" size=12></label><br>
 <label>$rcc: <input type=text name=\"wpRecent\" value=\"$wpRecent\" size=6></label><br>
index 66f8d83..28d6d2d 100644 (file)
@@ -165,7 +165,8 @@ function wfSpecialUserlogin()
 /* private */ function mailPassword()
 {
        global $wgUser, $wpName, $wgDeferredUpdateList, $wgOutputEncoding;
-
+       global $wgCookiePath, $wgCookieDomain, $wgDBname;
+       
        if ( "" == $wpName ) {
                mainLoginForm( wfMsg( "noname" ) );
                return;
@@ -202,7 +203,7 @@ function wfSpecialUserlogin()
        $np = User::randomPassword();
        $u->setNewpassword( $np );
 
-       setcookie( "wcUserPassword", "", time() - 3600 );
+       setcookie( "{$wgDBname}Password", "", time() - 3600, $wgCookiePath, $wgCookieDomain );
        $u->saveSettings();
 
        $ip = getenv( "REMOTE_ADDR" );
@@ -264,7 +265,7 @@ function userNotPrivilegedMessage()
 {
        global $wgUser, $wgOut, $wgLang, $returnto;
        global $wpName, $wpPassword, $wpRetype, $wpRemember;
-       global $wpEmail, $HTTP_COOKIE_VARS;
+       global $wpEmail, $HTTP_COOKIE_VARS, $wgDBname;
 
        $le = wfMsg( "loginerror" );
        $yn = wfMsg( "yourname" );
@@ -285,7 +286,7 @@ function userNotPrivilegedMessage()
                if ( 0 != $wgUser->getID() ) {
                        $name = $wgUser->getName();
                } else {
-                       $name = $HTTP_COOKIE_VARS["wcUserName"];
+                       $name = $HTTP_COOKIE_VARS["{$wgDBname}UserName"];
                }
        }
        $pwd = $wpPassword;
@@ -319,7 +320,7 @@ color='red'>$err</font>\n" );
        }
 
        $wgOut->addHTML( "
-<form id=\"userlogin\" method=\"post\" action=\"{$action}\">
+<form name=\"userlogin\" id=\"userlogin\" method=\"post\" action=\"{$action}\">
 <table border=0><tr>
 <td align=right>$yn:</td>
 <td colspan=2 align=left>
index 697354f..ea9c0d5 100644 (file)
@@ -135,16 +135,16 @@ class User {
                        } else {
                                return new User();
                        }
-               } else if ( isset( $HTTP_COOKIE_VARS["wcUserID"] ) ) {
-                       $sId = $HTTP_COOKIE_VARS["wcUserID"];
+               } else if ( isset( $HTTP_COOKIE_VARS["{$wgDBname}UserID"] ) ) {
+                       $sId = $HTTP_COOKIE_VARS["{$wgDBname}UserID"];
                        $wsUserID = $sId;
                } else {
                        return new User();
                }
                if ( isset( $wsUserName ) ) {
                        $sName = $wsUserName;
-               } else if ( isset( $HTTP_COOKIE_VARS["wcUserName"] ) ) {
-                       $sName = $HTTP_COOKIE_VARS["wcUserName"];
+               } else if ( isset( $HTTP_COOKIE_VARS["{$wgDBname}UserName"] ) ) {
+                       $sName = $HTTP_COOKIE_VARS["{$wgDBname}UserName"];
                        $wsUserName = $sName;
                } else {
                        return new User();
@@ -163,8 +163,8 @@ class User {
 
                if ( isset( $wsUserPassword ) ) {
                        $passwordCorrect = $wsUserPassword == $user->mPassword;
-               } else if ( isset( $HTTP_COOKIE_VARS["wcUserPassword"] ) ) {
-                       $user->mCookiePassword = $HTTP_COOKIE_VARS["wcUserPassword"];
+               } else if ( isset( $HTTP_COOKIE_VARS["{$wgDBname}Password"] ) ) {
+                       $user->mCookiePassword = $HTTP_COOKIE_VARS["{$wgDBname}Password"];
                        $wsUserPassword = $user->addSalt( $user->mCookiePassword );
                        $passwordCorrect = $wsUserPassword == $user->mPassword;
                } else {
@@ -448,34 +448,34 @@ class User {
        function setCookies()
        {
                global $wsUserID, $wsUserName, $wsUserPassword;
-               global $wgCookieExpiration;
+               global $wgCookieExpiration, $wgCookiePath, $wgCookieDomain, $wgDBname;
                if ( 0 == $this->mId ) return;
                $this->loadFromDatabase();
                $exp = time() + $wgCookieExpiration;
 
                $wsUserID = $this->mId;
-               setcookie( "wcUserID", $this->mId, $exp, "/" );
+               setcookie( "{$wgDBname}UserID", $this->mId, $exp, $wgCookiePath, $wgCookieDomain );
 
                $wsUserName = $this->mName;
-               setcookie( "wcUserName", $this->mName, $exp, "/" );
+               setcookie( "{$wgDBname}UserName", $this->mName, $exp, $wgCookiePath, $wgCookieDomain );
 
                $wsUserPassword = $this->mPassword;
                if ( 1 == $this->getOption( "rememberpassword" ) ) {
-                       setcookie( "wcUserPassword", $this->mCookiePassword, $exp, "/" );
+                       setcookie( "{$wgDBname}Password", $this->mCookiePassword, $exp, $wgCookiePath, $wgCookieDomain );
                } else {
-                       setcookie( "wcUserPassword", "", time() - 3600 );
+                       setcookie( "{$wgDBname}Password", "", time() - 3600 );
                }
        }
 
        function logout()
        {
-               global $wsUserID;
+               global $wsUserID, $wgCookiePath, $wgCookieDomain, $wgDBname;
                $this->mId = 0;
 
                $wsUserID = 0;
 
-               setcookie( "wcUserID", "", time() - 3600 );
-               setcookie( "wcUserPassword", "", time() - 3600 );
+               setcookie( "{$wgDBname}UserID", "", time() - 3600, $wgCookiePath, $wgCookieDomain );
+               setcookie( "{$wgDBname}Password", "", time() - 3600, $wgCookiePath, $wgCookieDomain );
        }
 
        function saveSettings()