updates from the French Wikipedia's copy
[mediawiki.git] / includes / UserTalkUpdate.php
blob011a7ba711183b826ac2972ba810d10efcb494c4
1 <?
2 # See deferred.doc
4 class UserTalkUpdate {
6 /* private */ var $mAction, $mNamespace, $mTitle;
8 function UserTalkUpdate( $action, $ns, $title )
10 $this->mAction = $action;
11 $this->mNamespace = $ns;
12 $this->mTitle = str_replace( "_", " ", $title );
15 function doUpdate()
18 global $wgUser, $wgLang;
19 $fname = "UserTalkUpdate::doUpdate";
21 # If namespace isn't User_talk:, do nothing.
23 if ( $this->mNamespace != Namespace::getTalk(
24 Namespace::getUser() ) ) {
25 return;
27 # If the user talk page is our own, clear the flag
28 # whether we are reading it or writing it.
29 if ( 0 == strcmp( $this->mTitle, $wgUser->getName() ) ) {
31 $wgUser->setNewtalk( 0 );
32 $wgUser->saveSettings();
34 } else {
35 # Not ours. If writing, mark it as modified.
37 if ( 1 == $this->mAction ) {
38 $user = new User();
39 $user->setID(User::idFromName($this->mTitle));
40 if ($id=$user->getID()) {
41 $sql = "INSERT INTO user_newtalk (user_id) values ({$id})";
43 } else { #anon
45 if(preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle)) { #real anon (user:xxx.xxx.xxx.xxx)
47 $sql = "INSERT INTO user_newtalk (user_id,user_ip) values (0,\"{$this->mTitle}\")";
53 if($sql && !$user->getNewtalk()) { # only insert if real user and it's not already there
54 wfQuery( $sql, $fname );