Changing comments layout preparing for generated documentation with Phpdocumentor
[lhc/web/wiklou.git] / includes / UserTalkUpdate.php
1 <?php
2 /**
3 * See deferred.doc
4 *
5 */
6
7 /**
8 *
9 */
10 class UserTalkUpdate {
11
12 /* private */ var $mAction, $mNamespace, $mTitle;
13
14 function UserTalkUpdate( $action, $ns, $title ) {
15 $this->mAction = $action;
16 $this->mNamespace = $ns;
17 $this->mTitle = str_replace( '_', ' ', $title );
18 }
19
20 function doUpdate() {
21 global $wgUser, $wgLang, $wgMemc, $wgDBname;
22 $fname = 'UserTalkUpdate::doUpdate';
23
24 # If namespace isn't User_talk:, do nothing.
25
26 if ( $this->mNamespace != Namespace::getTalk(
27 Namespace::getUser() ) ) {
28 return;
29 }
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();
35
36 } else {
37 # Not ours. If writing, mark it as modified.
38
39 $sql = false;
40 $dbw =& wfGetDB( DB_MASTER );
41 $user_newtalk = $dbw->tableName( 'user_newtalk' );
42
43 if ( 1 == $this->mAction ) {
44 $user = new User();
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" );
49 } else {
50 #anon
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" );
54 }
55 }
56
57 if($sql && !$user->getNewtalk()) { # only insert if real user and it's not already there
58 $dbw->query( $sql, $fname );
59 }
60 }
61 }
62 }
63 }
64
65 ?>