/** * Remove a follower from site and clear caches afterwards. * * @param $user1 User object: user to be removed * @param $user2 string: site prefix */ public function deleteUserSiteFollow($user, $huijiPrefix) { global $wgMemc; $dbw = wfGetDB(DB_MASTER); $dbw->delete('user_site_follow', array('f_user_id' => $user->getId(), 'f_wiki_domain' => $huijiPrefix), __METHOD__); $stats = new UserStatsTrack($user->getId(), $user->getName()); $stats->decStatField('friend'); $this->decFollowCount($user, $huijiPrefix); //store result in cache $key = wfForeignMemcKey('huiji', '', 'user_site_follow', 'check_follow', $user->getName(), $huijiPrefix); $wgMemc->set($key, false); return true; }
function removeDeletedEdits(&$article, &$user, &$reason) { global $wgNamespacesForEditPoints; // only keep tally for allowable namespaces if (!is_array($wgNamespacesForEditPoints) || in_array($article->getTitle()->getNamespace(), $wgNamespacesForEditPoints)) { $dbr = wfGetDB(DB_MASTER); $res = $dbr->select('revision', array('rev_user_text', 'rev_user', 'COUNT(*) AS the_count'), array('rev_page' => $article->getID(), 'rev_user <> 0'), __METHOD__, array('GROUP BY' => 'rev_user_text')); foreach ($res as $row) { $stats = new UserStatsTrack($row->rev_user, $row->rev_user_text); $stats->decStatField('edit', $row->the_count); } } return true; }
/** * Remove a follower from followee * * @param $user1 User object: user to be removed * @param $user2 string: site prefix * @return bool: true if successfully deleted */ public function deleteUserUserFollow($follower, $followee) { if ($follower == null || $followee == null) { return false; } $dbw = wfGetDB(DB_MASTER); $dbw->delete('user_user_follow', array('f_user_id' => $follower->getId(), 'f_target_user_id' => $followee->getId()), __METHOD__); $this->decFollowCount($follower, $followee); $stats = new UserStatsTrack($follower->getId(), $follower->getName()); $stats->decStatField('friend'); //use friend record to count the number of people followed. $stats = new UserStatsTrack($followee->getId(), $followee->getName()); $stats->decStatField('foe'); // use foe record to count the number of people following. return true; }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { global $wgUser, $wgOut, $wgRequest; $user_name = $wgRequest->getVal('user'); /** * Redirect anonymous users to Login Page * It will automatically return them to the CommentIgnoreList page */ if ($wgUser->getID() == 0 && $user_name == '') { $loginPage = SpecialPage::getTitleFor('Userlogin'); $wgOut->redirect($loginPage->getLocalURL('returnto=Special:CommentIgnoreList')); return false; } $wgOut->setPageTitle(wfMsg('comment-ignore-title')); $out = ''; // Prevent E_NOTICE if ($user_name == '') { $out .= $this->displayCommentBlockList(); } else { if ($wgRequest->wasPosted()) { $user_name = htmlspecialchars_decode($user_name); $user_id = User::idFromName($user_name); // Anons can be comment-blocked, but idFromName returns nothing // for an anon, so... if (!$user_id) { $user_id = 0; } $c = new Comment(0); $c->deleteBlock($wgUser->getID(), $user_id); if ($user_id && class_exists('UserStatsTrack')) { $stats = new UserStatsTrack($user_id, $user_name); $stats->decStatField('comment_ignored'); } $out .= $this->displayCommentBlockList(); } else { $out .= $this->confirmCommentBlockDelete(); } } $wgOut->addHTML($out); }
/** * Deletes a user board message from the database and decreases social * statistics as appropriate (either 'user_board_count' or * 'user_board_count_priv' is decreased by one). * * @param $ub_id Integer: ID number of the board message that we want to delete */ public function deleteMessage($ub_id) { if ($ub_id) { $dbw = wfGetDB(DB_MASTER); $s = $dbw->selectRow('user_board', array('ub_user_id', 'ub_user_name', 'ub_type'), array('ub_id' => $ub_id), __METHOD__); if ($s !== false) { $dbw->delete('user_board', array('ub_id' => $ub_id), __METHOD__); $stats = new UserStatsTrack($s->ub_user_id, $s->ub_user_name); if ($s->ub_type == 0) { $stats->decStatField('user_board_count'); } else { $stats->decStatField('user_board_count_priv'); } } } }
/** * Delete the user's vote from the database, purges normal caches and * updates SocialProfile's statistics, if SocialProfile is active. */ function delete() { $dbw = wfGetDB(DB_MASTER); $dbw->begin(); $dbw->delete('Vote', array('vote_page_id' => $this->PageID, 'username' => $this->Username), __METHOD__); $dbw->commit(); $this->clearCache(); // Update social statistics if SocialProfile extension is enabled if (class_exists('UserStatsTrack')) { $stats = new UserStatsTrack($this->Userid, $this->Username); $stats->decStatField('vote'); } }
/** * Delete a status message via its ID. * * @param $us_id Integer: ID number of the status message to delete */ public function deleteStatus( $us_id ) { if( $us_id ) { $dbw = wfGetDB( DB_MASTER ); $s = $dbw->selectRow( 'user_status', array( 'us_user_id', 'us_user_name', 'us_sport_id', 'us_team_id' ), array( 'us_id' => $us_id ), __METHOD__ ); if ( $s !== false ) { $dbw->delete( 'user_status', array( 'us_id' => $us_id ), __METHOD__ ); $stats = new UserStatsTrack( $s->us_user_id, $s->us_user_name ); $stats->decStatField( 'user_status_count' ); } } }