ini_set( "include_path", dirname(__FILE__)."/../" ); require( "commandLine.inc" ); if (isset($options['help'])) { die( "migrating the ban status from old system to new system" ); } if ( WikiFactory::getVarValueByName("wgChatBanMigrated", $wgCityId ) ) { // die( "migrating the ban status from old system to new system" ); } $db = wfGetDB(DB_SLAVE, array()); /* * first time it run only count on pages and then it run this script with param -do and list * it is hack for problem with memory leak from parser */ $res = $db->query("select ug_user, ug_group from user_groups where ug_group = 'bannedfromchat'"); $admin = User::newFromName("WikiaBot"); while ($row = $db->fetchRow($res)) { $userToBan = User::newFromID($row['ug_user']); Chat::banUser($userToBan->getName(), $admin, 60*60*24*30*6, "Auto migration script for new version of chat"); $userToBan->removeGroup('chatmoderator'); } WikiFactory::setVarByName("wgChatBanMigrated", $wgCityId, true ); echo "List of pages\n";
/** * Ajax endpoint for blocking privata chat with user. */ public static function blockOrBanChat() { ChatHelper::info(__METHOD__ . ': Method called'); global $wgRequest, $wgUser; wfProfileIn(__METHOD__); $kickingUser = $wgUser; $retVal = array(); $userToBan = $wgRequest->getVal('userToBan'); $userToBanId = $wgRequest->getVal('userToBanId', 0); if (!empty($userToBanId)) { $userToBan = User::newFromId($userToBanId); if (!empty($userToBanId)) { $userToBan = $userToBan->getName(); } } $mode = $wgRequest->getVal('mode', 'private'); if (empty($userToBan)) { $retVal["error"] = wfMsg('chat-missing-required-parameter', 'usertoBan'); } else { $dir = $wgRequest->getVal('dir', 'add'); if ($mode == 'private') { $result = Chat::blockPrivate($userToBan, $dir, $kickingUser); } else { if ($mode == 'global') { $time = (int) $wgRequest->getVal('time', 0); $result = Chat::banUser($userToBan, $kickingUser, $time, $wgRequest->getVal('reason')); } } if ($result === true) { $retVal["success"] = true; } else { $retVal["error"] = $result; } } wfProfileOut(__METHOD__); return $retVal; }