function revertAction($action, $result) { switch ($action) { case 'block': $block = Block::newFromTarget(User::whoIs($result['userid'])); if (!$block || $block->getBy() != AbuseFilter::getFilterUser()->getId()) { return false; // Not blocked by abuse filter. } $block->delete(); $log = new LogPage('block'); $log->addEntry('unblock', Title::makeTitle(NS_USER, $result['user']), wfMsgForContent('abusefilter-revert-reason', $this->mPage->mFilter, $this->mReason)); break; case 'blockautopromote': global $wgMemc; $wgMemc->delete(AbuseFilter::autopromoteBlockKey(User::newFromId($result['userid']))); break; case 'degroup': // Pull the user's groups from the vars. $oldGroups = $result['vars']['USER_GROUPS']; $oldGroups = explode(',', $oldGroups); $oldGroups = array_diff($oldGroups, array_intersect($oldGroups, User::getImplicitGroups())); $rows = array(); foreach ($oldGroups as $group) { $rows[] = array('ug_user' => $result['userid'], 'ug_group' => $group); } // Cheat a little bit. User::addGroup repeatedly is too slow. $user = User::newFromId($result['userid']); $currentGroups = $user->getGroups(); $newGroups = array_merge($oldGroups, $currentGroups); // Don't do anything if there are no groups to add. if (!count(array_diff($newGroups, $currentGroups))) { return; } $dbw = wfGetDB(DB_MASTER); $dbw->insert('user_groups', $rows, __METHOD__, array('IGNORE')); $user->invalidateCache(); $log = new LogPage('rights'); $log->addEntry('rights', $user->getUserPage(), wfMsgForContent('abusefilter-revert-reason', $this->mPage->mFilter, $this->mReason), array(implode(',', $currentGroups), implode(',', $newGroups))); } }