00001 <?php
00002
# See deferred.doc
00003
00004 class UserTalkUpdate {
00005
00006 var
$mAction,
$mNamespace,
$mTitle;
00007
00008 function
UserTalkUpdate( $action, $ns, $title )
00009 {
00010 $this->mAction =
$action;
00011 $this->mNamespace = $ns;
00012 $this->mTitle = str_replace(
"_",
" ", $
title );
00013 }
00014
00015 function
doUpdate()
00016 {
00017
00018 global
$wgUser,
$wgLang,
$wgMemc,
$wgDBname;
00019 $fname =
"UserTalkUpdate::doUpdate";
00020
00021
# If namespace isn't User_talk:, do nothing.
00022
00023
if ( $this->mNamespace != Namespace::getTalk(
00024 Namespace::getUser() ) ) {
00025
return;
00026 }
00027
# If the user talk page is our own, clear the flag
00028
# whether we are reading it or writing it.
00029
if ( 0 == strcmp( $this->mTitle, $wgUser->getName() ) ) {
00030
$wgUser->setNewtalk( 0 );
00031
$wgUser->saveSettings();
00032
00033 }
else {
00034
# Not ours. If writing, mark it as modified.
00035
00036
$sql =
false;
00037
if ( 1 == $this->mAction ) {
00038
$user =
new User();
00039
$user->setID(User::idFromName($this->mTitle));
00040
if ($id=
$user->getID()) {
00041
$sql =
"INSERT INTO user_newtalk (user_id) values ({$id})";
00042
$wgMemc->delete(
"$wgDBname:user:id:$id" );
00043 }
else {
00044
#anon
00045
if(preg_match(
"/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle)) { #real anon (user:xxx.xxx.xxx.xxx)
00046
$sql =
"INSERT INTO user_newtalk (user_id,user_ip) values (0,\"{$this->mTitle}\")";
00047
$wgMemc->delete(
"$wgDBname:newtalk:ip:$this->mTitle" );
00048 }
00049 }
00050
00051
if(
$sql && !
$user->getNewtalk()) { # only insert
if real
user and it's not already there
00052
wfQuery( $sql,
DB_WRITE, $fname );
00053 }
00054 }
00055 }
00056 }
00057 }
00058
00059 ?>