10 class UserTalkUpdate
{
12 /* private */ var $mAction, $mNamespace, $mTitle;
14 function UserTalkUpdate( $action, $ns, $title ) {
15 $this->mAction
= $action;
16 $this->mNamespace
= $ns;
17 $this->mTitle
= str_replace( '_', ' ', $title );
21 global $wgUser, $wgLang, $wgMemc, $wgDBname;
22 $fname = 'UserTalkUpdate::doUpdate';
24 # If namespace isn't User_talk:, do nothing.
26 if ( $this->mNamespace
!= Namespace::getTalk(
27 Namespace::getUser() ) ) {
30 # If the user talk page is our own, clear the flag
31 # whether we are reading it or writing it.
32 if ( 0 == strcmp( $this->mTitle
, $wgUser->getName() ) ) {
33 $wgUser->setNewtalk( 0 );
34 $wgUser->saveSettings();
37 # Not ours. If writing, mark it as modified.
40 $dbw =& wfGetDB( DB_MASTER
);
41 $user_newtalk = $dbw->tableName( 'user_newtalk' );
43 if ( 1 == $this->mAction
) {
45 $user->setID(User
::idFromName($this->mTitle
));
46 if ($id=$user->getID()) {
47 $sql = "INSERT INTO $user_newtalk (user_id) values ({$id})";
48 $wgMemc->delete( "$wgDBname:user:id:$id" );
51 if(preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle
)) { #real anon (user:xxx.xxx.xxx.xxx)
52 $sql = "INSERT INTO $user_newtalk (user_id,user_ip) values (0,\"{$this->mTitle}\")";
53 $wgMemc->delete( "$wgDBname:newtalk:ip:$this->mTitle" );
57 if($sql && !$user->getNewtalk()) { # only insert if real user and it's not already there
58 $dbw->query( $sql, $fname );