/** * Returns the id of the default chat for the current wiki. * * If the chat doesn't exist, creates it. * * @param roomName - will be filled with the name of the chat (a string stored in VARCHAR(255), so it's reasonable length) * @param roomTopic - will be filled with the topic of the chat (a string stored in a blob, so it might be fairly large). * @param roomUsers - for private chats: an array of users who are in the room. TODO: Document what formatat these users are in (user ids? db_keys?) */ public static function getDefaultRoomId(&$roomName, &$roomTopic, $roomType = "open", $roomUsers = array()) { global $wgCityId, $wgSitename, $wgServer, $wgArticlePath, $wgMemc; wfProfileIn(__METHOD__); if (empty($roomData)) { // TODO: FIXME: What is this testing? Isn't it ALWAYS empty? - SWC 20110905 // Add some extra data that the server will want in order to store it in the room's hash. $extraData = array('wgServer' => $wgServer, 'wgArticlePath' => $wgArticlePath); $extraDataString = json_encode($extraData); $roomId = ""; $roomJson = NodeApiClient::makeRequest(array("func" => "getDefaultRoomId", "wgCityId" => $wgCityId, "roomType" => $roomType, "roomUsers" => implode(',', $roomUsers), "defaultRoomName" => $wgSitename, "defaultRoomTopic" => wfMsg('chat-default-topic', $wgSitename), "extraDataString" => $extraDataString)); $roomData = json_decode($roomJson); } if (isset($roomData->{'roomId'})) { $roomId = $roomData->{'roomId'}; $roomName = $roomData->{'roomName'}; $roomTopic = $roomData->{'roomTopic'}; } else { // FIXME: How should we handle it if there is no roomId? } wfProfileOut(__METHOD__); return $roomId; }
/** * Returns the id of the default chat for the current wiki. * * If the chat doesn't exist, creates it. * * @param roomUsers - for private chats: an array of users who are in the room. * * TODO: Document what format these users are in (user ids? db_keys?) * * @return string */ public static function getDefaultRoomId($roomType = "open", $roomUsers = []) { global $wgCityId, $wgServer, $wgArticlePath; wfProfileIn(__METHOD__); if (empty($roomData)) { // TODO: FIXME: What is this testing? Isn't it ALWAYS empty? - SWC 20110905 // Add some extra data that the server will want in order to store it in the room's hash. $extraData = array('wgServer' => $wgServer, 'wgArticlePath' => $wgArticlePath); $extraDataString = json_encode($extraData); $roomId = ""; $roomJson = NodeApiClient::makeRequest(array("func" => "getDefaultRoomId", "wgCityId" => $wgCityId, "roomType" => $roomType, "roomUsers" => json_encode($roomUsers), "extraDataString" => $extraDataString)); $roomData = json_decode($roomJson); } if (isset($roomData->{'roomId'})) { $roomId = $roomData->{'roomId'}; ChatHelper::info(__METHOD__ . ': Method called', ['roomId' => $roomId]); } else { // FIXME: How should we handle it if there is no roomId? ChatHelper::info(__METHOD__ . ': Method called - no roomId'); } wfProfileOut(__METHOD__); return $roomId; }