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
23 * @author <mail@tgries.de>
30 class UserTalkUpdate
{
35 var $mAction, $mNamespace, $mTitle, $mSummary, $mMinorEdit, $mTimestamp;
40 * @param string $action
47 function UserTalkUpdate( $action, $ns, $title, $summary, $minoredit, $timestamp) {
48 global $wgUser, $wgLang, $wgMemc, $wgDBname;
49 $fname = 'UserTalkUpdate::UserTalkUpdate';
51 $this->mAction
= $action;
52 $this->mNamespace
= $ns;
53 $this->mTitle
= $title; # str_replace( '_', ' ', $title ); # I do not know, why this was needed . T. Gries 23.11.2004
54 $this->mSummary
= $summary;
55 $this->mMinorEdit
= $minoredit;
56 $this->mTimestamp
= $timestamp;
58 # If namespace isn't User_talk:, do nothing.
59 if ( $this->mNamespace
!= NS_USER_TALK
) {
63 # If the user talk page is our own, clear the flag
64 # when we are reading it or writing it.
65 if ( 0 == strcmp( $this->mTitle
, $wgUser->getName() ) ) {
66 $wgUser->setNewtalk( 0 );
67 $wgUser->saveSettings();
69 # Not ours. If writing, then mark it as modified.
71 if ( 1 == $this->mAction
) {
73 $user->setID(User
::idFromName($this->mTitle
));
75 if ($id=$user->getID()) {
77 $wgMemc->delete( "$wgDBname:user:id:$id" );
79 if ( $wgUser->isIP($this->mTitle
) ) { # anonymous
80 $dbw =& wfGetDB( DB_MASTER
);
81 $dbw->replace( 'watchlist',
82 array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
84 'wl_namespace' => NS_USER_TALK
,
85 'wl_title' => $this->mTitle
,
86 'wl_notificationtimestamp' => 1
90 $wgMemc->delete( "$wgDBname:newtalk:ip:$this->mTitle" );
94 if($sql && !$user->getNewtalk() ) {
95 # create an artificial watchlist table entry for the owner X of the user_talk page X
96 # only insert if X is a real user and the page is not yet watched
97 # mark the changed watch-listed page with a timestamp, so that the page is listed with
98 # an "updated since your last visit" icon in the watch list, ...
99 # ... no matter, if the watching user has or has not indicated an email address in his/her preferences.
100 # We memorise the event of sending out a notification and use this as a flag to suppress
101 # further mails for changes on the same page for that watching user
102 $dbw =& wfGetDB( DB_MASTER
);
103 $dbw->replace( 'watchlist',
104 array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
105 array('wl_user' => $id,
106 'wl_namespace' => NS_USER_TALK
,
107 'wl_title' => $this->mTitle
,
108 'wl_notificationtimestamp' => 1