Channel::Channel(std::string const& name, uint32 team /*= 0*/) : _announceEnabled(true), _ownershipEnabled(true), _persistentChannel(false), _isOwnerInvisible(false), _channelFlags(CHANNEL_FLAG_CUSTOM), _channelId(0), _channelTeam(team), _channelName(name), _zoneEntry(nullptr) { // If storing custom channels in the db is enabled either load or save the channel if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHANNEL); stmt->setString(0, _channelName); stmt->setUInt32(1, _channelTeam); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) // load { Field* fields = result->Fetch(); _channelName = fields[0].GetString(); // re-get channel name. MySQL table collation is case insensitive _announceEnabled = fields[1].GetBool(); _ownershipEnabled = fields[2].GetBool(); _channelPassword = fields[3].GetString(); std::string bannedList = fields[4].GetString(); if (!bannedList.empty()) { Tokenizer tokens(bannedList, ' '); for (auto const& token : tokens) { std::string bannedGuidStr(token); ObjectGuid bannedGuid; bannedGuid.SetRawValue(uint64(strtoull(bannedGuidStr.substr(0, 16).c_str(), nullptr, 16)), uint64(strtoull(bannedGuidStr.substr(16).c_str(), nullptr, 16))); if (!bannedGuid.IsEmpty()) { TC_LOG_DEBUG("chat.system", "Channel (%s) loaded player %s into bannedStore", _channelName.c_str(), bannedGuid.ToString().c_str()); _bannedStore.insert(bannedGuid); } } } } else // save { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL); stmt->setString(0, _channelName); stmt->setUInt32(1, _channelTeam); CharacterDatabase.Execute(stmt); TC_LOG_DEBUG("chat.system", "Channel (%s) saved in database", _channelName.c_str()); } _persistentChannel = true; } }
static bool HandleGMTicketCloseByIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed() || ticket->IsCompleted()) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Ticket should be assigned to the player who tries to close it. // Console can override though Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; if (player && ticket->IsAssignedNotTo(player->GetGUID())) { handler->PSendSysMessage(LANG_COMMAND_TICKETCANNOTCLOSE, ticket->GetId()); return true; } ObjectGuid closedByGuid; if (player) closedByGuid = player->GetGUID(); else closedByGuid.SetRawValue(0, uint64(-1)); sTicketMgr->CloseTicket(ticket->GetId(), closedByGuid); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); // Inform player, who submitted this ticket, that it is closed if (Player* submitter = ticket->GetPlayer()) { WorldPacket data(SMSG_GM_TICKET_UPDATE, 4); data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); submitter->GetSession()->SendPacket(&data); } return true; }
Channel::Channel(std::string const& name, uint32 channelId, uint32 team): _announce(true), _ownership(true), _IsSaved(false), _flags(0), _channelId(channelId), _team(team), _name(name) { // set special flags if built-in channel if (ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(channelId)) // check whether it's a built-in channel { _announce = false; // no join/leave announces _ownership = false; // no ownership handout _flags |= CHANNEL_FLAG_GENERAL; // for all built-in channels if (ch->Flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel _flags |= CHANNEL_FLAG_TRADE; if (ch->Flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels _flags |= CHANNEL_FLAG_CITY; if (ch->Flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel _flags |= CHANNEL_FLAG_LFG; else // for all other channels _flags |= CHANNEL_FLAG_NOT_LFG; } else // it's custom channel { _flags |= CHANNEL_FLAG_CUSTOM; // If storing custom channels in the db is enabled either load or save the channel if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHANNEL); stmt->setString(0, _name); stmt->setUInt32(1, _team); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) // load { Field* fields = result->Fetch(); _announce = fields[0].GetBool(); _ownership = fields[1].GetBool(); _password = fields[2].GetString(); std::string bannedList = fields[3].GetString(); if (!bannedList.empty()) { Tokenizer tokens(bannedList, ' '); for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i) { std::string bannedGuidStr(*i); ObjectGuid bannedGuid; bannedGuid.SetRawValue(uint64(strtoull(bannedGuidStr.substr(0, 16).c_str(), nullptr, 16)), uint64(strtoull(bannedGuidStr.substr(16).c_str(), nullptr, 16))); if (!bannedGuid.IsEmpty()) { TC_LOG_DEBUG("chat.system", "Channel (%s) loaded bannedStore %s", _name.c_str(), bannedGuid.ToString().c_str()); _bannedStore.insert(bannedGuid); } } } } else // save { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL); stmt->setString(0, _name); stmt->setUInt32(1, _team); CharacterDatabase.Execute(stmt); TC_LOG_DEBUG("chat.system", "Channel (%s) saved in database", _name.c_str()); } _IsSaved = true; } } }