Scripts and data used for generating ZhConversion.php
[lhc/web/wiklou.git] / includes / UserTalkUpdate.php
index 66ea7a9..70b6d3b 100644 (file)
@@ -1,22 +1,27 @@
 <?php
-# See deferred.doc
+/**
+ * See deferred.doc
+ *
+ * @package MediaWiki
+ */
 
+/**
+ *
+ * @package MediaWiki
+ */
 class UserTalkUpdate {
 
        /* private */ var $mAction, $mNamespace, $mTitle;
 
-       function UserTalkUpdate( $action, $ns, $title )
-       {
+       function UserTalkUpdate( $action, $ns, $title ) {
                $this->mAction = $action;
                $this->mNamespace = $ns;
-               $this->mTitle = str_replace( "_", " ", $title );
+               $this->mTitle = str_replace( '_', ' ', $title );
        }
 
-       function doUpdate()
-       {
-       
+       function doUpdate() {   
                global $wgUser, $wgLang, $wgMemc, $wgDBname;
-               $fname = "UserTalkUpdate::doUpdate";
+               $fname = 'UserTalkUpdate::doUpdate';
 
                # If namespace isn't User_talk:, do nothing.
 
@@ -34,22 +39,25 @@ class UserTalkUpdate {
                        # Not ours.  If writing, mark it as modified.
 
                        $sql = false;
+                       $dbw =& wfGetDB( DB_MASTER );
+                       $user_newtalk = $dbw->tableName( 'user_newtalk' );
+
                        if ( 1 == $this->mAction ) {
                                $user = new User();                             
                                $user->setID(User::idFromName($this->mTitle));
                                if ($id=$user->getID()) {                                                                       
-                                       $sql = "INSERT INTO user_newtalk (user_id) values ({$id})";
+                                       $sql = "INSERT INTO $user_newtalk (user_id) values ({$id})";
                                        $wgMemc->delete( "$wgDBname:user:id:$id" );
                                } else {
                                        #anon
                                        if(preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle)) { #real anon (user:xxx.xxx.xxx.xxx)
-                                               $sql = "INSERT INTO user_newtalk (user_id,user_ip) values (0,\"{$this->mTitle}\")";             
+                                               $sql = "INSERT INTO $user_newtalk (user_id,user_ip) values (0,\"{$this->mTitle}\")";            
                                                $wgMemc->delete( "$wgDBname:newtalk:ip:$this->mTitle" );
                                        }
                                }
                                
                                if($sql && !$user->getNewtalk()) { # only insert if real user and it's not already there
-                                       wfQuery( $sql, DB_WRITE, $fname );
+                                       $dbw->query( $sql, $fname );
                                }
                        }
                }