function wfUpdateUserStatus($username, $gender, $province, $city, $birthday, $status) { global $wgUser; $city = trim($city); $status = trim($status); $out = ResponseGenerator::getJson(ResponseGenerator::ERROR_UNKNOWN); // This feature is only available for logged-in users. if (!$wgUser->isLoggedIn()) { $out = ResponseGenerator::getJson(ResponseGenerator::ERROR_NOT_LOGGED_IN); return $out; } // No need to allow blocked users to access this page, they could abuse it, y'know. if ($wgUser->isBlocked()) { $out = ResponseGenerator::getJson(ResponseGenerator::ERROR_BLOCKED); return $out; } // Database operations require write mode if (wfReadOnly()) { $out = ResponseGenerator::getJson(ResponseGenerator::ERROR_READ_ONLY); return $out; } // Are we even allowed to do this? if (!$wgUser->isAllowed('edit')) { $out = ResponseGenerator::getJson(ResponseGenerator::ERROR_NOT_ALLOWED); return $out; } if ($username === $wgUser->getName()) { $us = new UserStatus($wgUser); if ($us->setAll($gender, $province, $city, $birthday, $status)) { $out = ResponseGenerator::getJson(ResponseGenerator::SUCCESS); } } return $out; }