584097e0886fc5409d7495e783f56b8e8c74bc7d
2 /** Copyright (C) 2004 Thomas Gries <mail@tgries.de>
3 # http://www.mediawiki.org/
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # http://www.gnu.org/copyleft/gpl.html
31 class UserTalkUpdate
{
36 var $mAction, $mNamespace, $mTitle, $mSummary, $mMinorEdit, $mTimestamp;
41 * @param string $action
48 function UserTalkUpdate( $action, $ns, $title, $summary, $minoredit, $timestamp) {
49 global $wgUser, $wgLang, $wgMemc, $wgDBname;
50 $fname = 'UserTalkUpdate::UserTalkUpdate';
52 $this->mAction
= $action;
53 $this->mNamespace
= $ns;
54 $this->mTitle
= $title; # str_replace( '_', ' ', $title ); # I do not know, why this was needed . T. Gries 23.11.2004
55 $this->mSummary
= $summary;
56 $this->mMinorEdit
= $minoredit;
57 $this->mTimestamp
= $timestamp;
59 # If namespace isn't User_talk:, do nothing.
60 if ( $this->mNamespace
!= Namespace::getTalk(Namespace::getUser() ) ) {
64 # If the user talk page is our own, clear the flag
65 # when we are reading it or writing it.
66 if ( 0 == strcmp( $this->mTitle
, $wgUser->getName() ) ) {
67 $wgUser->setNewtalk( 0 );
68 $wgUser->saveSettings();
70 # Not ours. If writing, then mark it as modified.
72 if ( 1 == $this->mAction
) {
74 $user->setID(User
::idFromName($this->mTitle
));
76 if ($id=$user->getID()) {
78 $wgMemc->delete( "$wgDBname:user:id:$id" );
80 if ( $wgUser->isIP($this->mTitle
) ) { # anonymous
81 $dbw =& wfGetDB( DB_MASTER
);
82 $dbw->replace( 'watchlist',
83 array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
85 'wl_namespace' => NS_USER_TALK
,
86 'wl_title' => $this->mTitle
,
87 'wl_notificationtimestamp' => 1
91 $wgMemc->delete( "$wgDBname:newtalk:ip:$this->mTitle" );
95 if($sql && !$user->getNewtalk() ) {
96 # create an artificial watchlist table entry for the owner X of the user_talk page X
97 # only insert if X is a real user and the page is not yet watched
98 # mark the changed watch-listed page with a timestamp, so that the page is listed with
99 # an "updated since your last visit" icon in the watch list, ...
100 # ... no matter, if the watching user has or has not indicated an email address in his/her preferences.
101 # We memorise the event of sending out a notification and use this as a flag to suppress
102 # further mails for changes on the same page for that watching user
103 $dbw =& wfGetDB( DB_MASTER
);
104 $dbw->replace( 'watchlist',
105 array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
106 array('wl_user' => $id,
107 'wl_namespace' => NS_USER_TALK
,
108 'wl_title' => $this->mTitle
,
109 'wl_notificationtimestamp' => 1