static bool HandleGMTicketGetByIdCommand(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; } // Set the ticket as viewed and save it. SQLTransaction trans = SQLTransaction(NULL); ticket->SetViewed(); ticket->SetResponse("Your ticket was viewed and is being serviced."); ticket->SaveToDB(trans); // Update the last change time. sTicketMgr->UpdateLastChange(); handler->SendSysMessage(ticket->FormatMessageString(*handler, true).c_str()); return true; }
void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) { // Don't accept tickets if the ticket queue is disabled. (Ticket UI is greyed out but not fully dependable) if (sTicketMgr->GetStatus() == GMTICKET_QUEUE_STATUS_DISABLED) return; if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ)) { SendNotification(GetTrinityString(LANG_TICKET_REQ), sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ)); return; } GMTicketResponse response = GMTICKET_RESPONSE_CREATE_ERROR; GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()); if (ticket && ticket->IsCompleted()) sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID()); // Player must not have ticket if (!ticket || ticket->IsClosed()) { uint32 mapId; float x, y, z; std::string message; uint32 needResponse; bool needMoreHelp; uint32 count; std::list<uint32> times; uint32 decompressedSize; std::string chatLog; recvData >> mapId; recvData >> x >> y >> z; recvData >> message; recvData >> needResponse; recvData >> needMoreHelp; recvData >> count; for (uint32 i = 0; i < count; i++) { uint32 time; recvData >> time; times.push_back(time); } recvData >> decompressedSize; if (count && decompressedSize && decompressedSize < 0xFFFF) { uint32 pos = recvData.rpos(); ByteBuffer dest; dest.resize(decompressedSize); uLongf realSize = decompressedSize; if (uncompress(dest.contents(), &realSize, recvData.contents() + pos, recvData.size() - pos) == Z_OK) { dest >> chatLog; }
static bool HandleGMTicketCompleteCommand(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; } if (Player* player = ticket->GetPlayer()) if (player->IsInWorld()) ticket->SendResponse(player->GetSession()); SQLTransaction trans = SQLTransaction(NULL); ticket->SetCompleted(); ticket->SaveToDB(trans); Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, NULL, player ? player->GetName().c_str() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); sTicketMgr->UpdateLastChange(); return true; }
static bool HandleGMTicketCompleteCommand(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->SetCompleted(true); SQLTransaction trans = CharacterDatabase.BeginTransaction(); ticket->SaveToDB(trans); CharacterDatabase.CommitTransaction(trans); if (Player* player = ticket->GetPlayer()) if (player->IsInWorld()) ticket->SendResponse(player->GetSession()); sTicketMgr->UpdateLastChange(); return true; }
static bool HandleGMTicketDeleteByIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } if (!ticket->IsClosed()) { handler->SendSysMessage(LANG_COMMAND_TICKETCLOSEFIRST); return true; } std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); sTicketMgr->RemoveTicket(ticket->GetId()); sTicketMgr->UpdateLastChange(); if (Player* player = ticket->GetPlayer()) { // Force abandon ticket WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4); data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); player->GetSession()->SendPacket(&data); } return true; }
static bool HandleGMTicketCompleteCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); // Ticket must exist and not be closed / completed. if (!ticket || ticket->IsClosed() || ticket->IsCompleted()) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Set the ticket as completed and the text to reflect the change, and save it. ticket->SetCompleted(true); ticket->SetResponse("Your ticket has been serviced and resolved."); SQLTransaction trans = CharacterDatabase.BeginTransaction(); ticket->SaveToDB(trans); CharacterDatabase.CommitTransaction(trans); // Update the last change time. sTicketMgr->UpdateLastChange(); return true; }
static bool HandleGMTicketEscalateCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); // Ticket must exists and not be closed / completed / assigned. if (!ticket || ticket->IsClosed() || ticket->IsCompleted() || ticket->GetEscalatedStatus() != TICKET_UNASSIGNED) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Set the ticket in the priority queue and the text and save it. SQLTransaction trans = SQLTransaction(NULL); ticket->SetEscalatedStatus(TICKET_IN_ESCALATION_QUEUE); ticket->SetResponse("Your ticket is in the priority queue and will be serviced shortly."); ticket->SaveToDB(trans); // Update the last change time. sTicketMgr->UpdateLastChange(); return true; }
inline bool ChatHandler::_HandleGMTicketResponseAppendCommand(const char* args, bool newLine) { if(!*args) return false; char* sTicketId = strtok((char*)args, " "); uint32 ticketId = atoi(sTicketId); char* response = strtok(NULL, "\n"); if(!response) return false; GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if(!ticket || !ticket->IsClosed()) { PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Cannot add response to ticket, assigned to someone else Player* player = m_session->GetPlayer(); if(ticket->IsAssignedNotTo(player->GetGUID())) { PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId()); return true; } SQLTransaction trans = SQLTransaction(NULL); ticket->AppendResponse(response); if(newLine) ticket->AppendResponse("\n"); ticket->SaveToDB(trans); return true; }
bool ChatHandler::HandleGMTicketCloseByIdCommand(const char* args) { if(!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if(!ticket || ticket->IsClosed() || ticket->IsCompleted()) { SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Ticket must be assigned to player, who tries to close it. uint64 guid = m_session->GetPlayer()->GetGUID(); if(ticket->IsAssignedNotTo(guid)) { PSendSysMessage(LANG_COMMAND_TICKETCANNOTCLOSE, ticket->GetId()); return true; } sTicketMgr->CloseTicket(ticket->GetId(), guid); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*this, m_session->GetPlayer()->GetName(), NULL, NULL, NULL); SendGlobalGMSysMessage(msg.c_str()); // Inform player, who submitted this ticket, that it is closed if(Player* player = ticket->GetPlayer()) if(player->IsInWorld()) { WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4); data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); player->GetSession()->SendPacket(&data); } return true; }
static bool HandleGMTicketAssignToCommand(ChatHandler* handler, char const* args) { if (!*args) return false; char* ticketIdStr = strtok((char*)args, " "); uint32 ticketId = atoi(ticketIdStr); char* targetStr = strtok(NULL, " "); if (!targetStr) return false; std::string target(targetStr); if (!normalizePlayerName(target)) return false; GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed()) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } uint64 targetGuid = sObjectMgr->GetPlayerGUIDByName(target); uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); uint32 targetGmLevel = AccountMgr::GetSecurity(accountId, realmID); // Target must exist and have administrative rights if (!targetGuid || AccountMgr::IsPlayerAccount(targetGmLevel)) { handler->SendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_A); return true; } // If already assigned, leave if (ticket->IsAssignedTo(targetGuid)) { handler->PSendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_B, ticket->GetId()); return true; } // If assigned to different player other than current, leave //! Console can override though Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; if (player && ticket->IsAssignedNotTo(player->GetGUID())) { handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target.c_str()); return true; } // Assign ticket SQLTransaction trans = SQLTransaction(NULL); ticket->SetAssignedTo(targetGuid, AccountMgr::IsAdminAccount(AccountMgr::GetSecurity(accountId, realmID))); ticket->SaveToDB(trans); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, target.c_str(), NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); return true; }
static bool HandleGMTicketUnAssignCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); // Ticket must exist and not be closed. if (!ticket || ticket->IsClosed()) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Ticket must be assigned. if (!ticket->IsAssigned()) { handler->PSendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED, ticket->GetId()); return true; } // Get security level of player, whom this ticket is assigned to uint32 security = SEC_PLAYER; Player* assignedPlayer = ticket->GetAssignedPlayer(); if (assignedPlayer && assignedPlayer->IsInWorld()) security = assignedPlayer->GetSession()->GetSecurity(); else { uint64 guid = ticket->GetAssignedToGUID(); uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid); security = AccountMgr::GetSecurity(accountId, realmID); } // Check security. If no m_session present it means we're issuing this command from the console. uint32 mySecurity = handler->GetSession() ? handler->GetSession()->GetSecurity() : SEC_CONSOLE; if (security > mySecurity) { handler->SendSysMessage(LANG_COMMAND_TICKETUNASSIGNSECURITY); return true; } // Set the ticket as unassigned and the text and save it. SQLTransaction trans = SQLTransaction(NULL); ticket->SetUnassigned(); ticket->SetResponse("Your ticket will be serviced shortly."); ticket->SaveToDB(trans); // Update the last change time. sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console", NULL); handler->SendGlobalGMSysMessage(msg.c_str()); return true; }
void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) { // Don't accept tickets if the ticket queue is disabled. (Ticket UI is greyed out but not fully dependable) if (sTicketMgr->GetStatus() == GMTICKET_QUEUE_STATUS_DISABLED) return; if(!GetPlayer()->CanSpeak()) { std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str()); return; } if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ)) { SendNotification(GetTrinityString(LANG_TICKET_REQ), sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ)); return; } GMTicketResponse response = GMTICKET_RESPONSE_CREATE_ERROR; GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()); if (ticket && ticket->IsCompleted()) sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID());; // Player must not have ticket if (!ticket || ticket->IsClosed()) { ticket = new GmTicket(GetPlayer(), recvData); uint32 count; std::list<uint32> times; uint32 decompressedSize; std::string chatLog; recvData >> count; for (uint32 i = 0; i < count; i++) { uint32 time; recvData >> time; times.push_back(time); } recvData >> decompressedSize; if (count && decompressedSize && decompressedSize < 0xFFFF) { uint32 pos = recvData.rpos(); ByteBuffer dest; dest.resize(decompressedSize); uLongf realSize = decompressedSize; if (uncompress(dest.contents(), &realSize, recvData.contents() + pos, recvData.size() - pos) == Z_OK) { dest >> chatLog; ticket->SetChatLog(times, chatLog); }
void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) { // Don't accept tickets if the ticket queue is disabled. (Ticket UI is greyed out but not fully dependable) if (sTicketMgr->GetStatus() == GMTICKET_QUEUE_STATUS_DISABLED) return; GMTicketResponse response = GMTICKET_RESPONSE_CREATE_ERROR; GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()); if (ticket && ticket->IsCompleted()) sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID()); // Player must not have ticket if (!ticket || ticket->IsClosed()) { std::string message; std::string chatLog; uint8 ticketType; uint32 mapId; float x, y, z; std::string ticketText = ""; std::string reservedForFutureUse = ""; recvData >> ticketType >> mapId >> x >> y >> z; // last check 2.4.3 recvData >> ticketText; recvData >> reservedForFutureUse; if (GetPlayer()->getLevel() < sWorld.getConfig(CONFIG_UINT32_GMTICKETS_MINLEVEL)) { ChatHandler(this).PSendSysMessage("You can't use the ticket system before level %u", sWorld.getConfig(CONFIG_UINT32_GMTICKETS_MINLEVEL)); return; } if (ticketType >= GMTICKET_MAX) return; if (ticketType != GMTICKET_BEHAVIOR_HARASSMENT && ticketType != GMTICKET_STUCK) { ChatHandler(this).SendSysMessage("Game Masters do not handle bug reports."); ChatHandler(this).SendSysMessage("Please use our bugtracker and provide sources if possible."); ChatHandler(this).SendSysMessage("https://elysium-project.org/bugtracker"); return; } ticket = new GmTicket(GetPlayer()); ticket->SetPosition(mapId, x, y, z); ticket->SetMessage(ticketText); ticket->SetTicketType(TicketType(ticketType)); sTicketMgr->AddTicket(ticket); sTicketMgr->UpdateLastChange(); sWorld.SendGMTicketText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->GetId()); response = GMTICKET_RESPONSE_CREATE_SUCCESS; }
bool ChatHandler::HandleGMTicketAssignToCommand(const char* args) { if(!*args) return false; char* sTicketId = strtok((char*)args, " "); uint32 ticketId = atoi(sTicketId); char* sTarget = strtok(NULL, " "); if(!sTarget) return false; std::string target(sTarget); if(!normalizePlayerName(target)) return false; GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if(!ticket || ticket->IsClosed()) { SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Get target information uint64 targetGuid = sObjectMgr->GetPlayerGUIDByName(target.c_str()); uint64 targetAccId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); uint32 targetGmLevel = sAccountMgr->GetSecurity(targetAccId, realmID); // Target must exist and have administrative rights if(!targetGuid || targetGmLevel == SEC_PLAYER) { SendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_A); return true; } // If already assigned, leave if(ticket->IsAssignedTo(targetGuid)) { PSendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_B, ticket->GetId()); return true; } // If assigned to different player other than current, leave Player* player = m_session->GetPlayer(); if(ticket->IsAssignedNotTo(player->GetGUID())) { PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target.c_str()); return true; } // Assign ticket SQLTransaction trans = SQLTransaction(NULL); ticket->SetAssignedTo(targetGuid, targetGmLevel == SEC_ADMINISTRATOR); ticket->SaveToDB(trans); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*this, NULL, target.c_str(), NULL, NULL); SendGlobalGMSysMessage(msg.c_str()); return 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; } sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid(uint64(-1))); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); if ((sIRC->TICMASK & 16) != 0 && (sIRC->BOTMASK & 1024) != 0 && sIRC->ticann.size() > 0) { std::string ircchan = "#"; std::ostringstream smsg; std::string assignedto; // If closed from console,there is no player,so we assign to Console. if (player) assignedto = player->GetName().c_str(); else assignedto = "Console"; ircchan += sIRC->ticann; smsg << "[\00304Ticket Closed\003][By:\00304 " << ticket->GetPlayerName().c_str() << " \003][ID: \00304" << ticket->GetId() << " \003][Closed By: \00304" << assignedto << " \003]"; sIRC->Send_IRC_Channel(ircchan, smsg.str().c_str() , true); } // Inform player, who submitted this ticket, that it is closed if (Player* submitter = ticket->GetPlayer()) { if (submitter->IsInWorld()) { WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4); data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); submitter->GetSession()->SendPacket(&data); } } return true; }
static bool HandleGMTicketDeleteByIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } if (!ticket->IsClosed()) { handler->SendSysMessage(LANG_COMMAND_TICKETCLOSEFIRST); return true; } std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", NULL); handler->SendGlobalGMSysMessage(msg.c_str()); if ((sIRC->TICMASK & 16) != 0 && (sIRC->BOTMASK & 1024) != 0 && sIRC->ticann.size() > 0) { std::string ircchan = "#"; std::ostringstream smsg; std::string deletedby; // If deleted from console,there is no player,so we assign to Console. Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; if (player) deletedby = player->GetName().c_str(); else deletedby = "Console"; ircchan += sIRC->ticann; smsg << "[\00304Ticket Deleted\003][By:\00304 " << ticket->GetPlayerName().c_str() << " \003][ID: \00304" << ticket->GetId() << " \003][Deleted By: \00304" << deletedby << " \003]"; sIRC->Send_IRC_Channel(ircchan, smsg.str().c_str() , true); } sTicketMgr->RemoveTicket(ticket->GetId()); sTicketMgr->UpdateLastChange(); if (Player* player = ticket->GetPlayer()) { if (player->IsInWorld()) { // Force abandon ticket WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4); data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); player->GetSession()->SendPacket(&data); } } return true; }
static bool HandleGMTicketUnAssignCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed()) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Ticket must be assigned if (!ticket->IsAssigned()) { handler->PSendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED, ticket->GetId()); return true; } // Get security level of player, whom this ticket is assigned to uint32 security = SEC_PLAYER; Player* assignedPlayer = ticket->GetAssignedPlayer(); if (assignedPlayer) security = assignedPlayer->GetSession()->GetSecurity(); else { ObjectGuid guid = ticket->GetAssignedToGUID(); uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid); security = AccountMgr::GetSecurity(accountId, realmID); } // Check security //! If no m_session present it means we're issuing this command from the console uint32 mySecurity = handler->GetSession() ? handler->GetSession()->GetSecurity() : SEC_CONSOLE; if (security > mySecurity) { handler->SendSysMessage(LANG_COMMAND_TICKETUNASSIGNSECURITY); return true; } std::string assignedTo = ticket->GetAssignedToName(); // copy assignedto name because we need it after the ticket has been unnassigned SQLTransaction trans = SQLTransaction(NULL); ticket->SetUnassigned(); ticket->SaveToDB(trans); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, assignedTo.c_str(), handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); return true; }
bool ChatHandler::HandleGMTicketUnAssignCommand(const char* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket *ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed()) { SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Ticket must be assigned if (!ticket->IsAssigned()) { PSendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED, ticket->GetId()); return true; } // Get security level of player, whom this ticket is assigned to uint32 security = SEC_PLAYER; Player* assignedPlayer = ticket->GetAssignedPlayer(); if (assignedPlayer && assignedPlayer->IsInWorld()) security = assignedPlayer->GetSession()->GetSecurity(); else { uint64 guid = ticket->GetAssignedToGUID(); uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid); security = AccountMgr::GetSecurity(accountId, realmID); } // Check security //! If no m_session present it means we're issuing this command from the console uint32 mySecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; if (security > mySecurity) { SendSysMessage(LANG_COMMAND_TICKETUNASSIGNSECURITY); return true; } SQLTransaction trans = SQLTransaction(NULL); ticket->SetUnassigned(); ticket->SaveToDB(trans); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*this, NULL, ticket->GetAssignedToName().c_str(), m_session ? m_session->GetPlayer()->GetName() : "Console", NULL); SendGlobalGMSysMessage(msg.c_str()); return true; }
void TicketMgr::LoadTickets() { uint32 oldMSTime = getMSTime(); if (!_ticketList.empty()) for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr) if (itr->second) delete itr->second; _ticketList.clear(); _lastTicketId = 0; _openTicketCount = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GM_TICKETS); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) { sLog->outString(">> Loaded 0 GM tickets. DB table `gm_tickets` is empty!"); sLog->outString(); return; } uint32 count = 0; do { Field* fields = result->Fetch(); GmTicket* ticket = new GmTicket(); if (!ticket->LoadFromDB(fields)) { delete ticket; continue; } if (!ticket->IsClosed()) ++_openTicketCount; // Update max ticket id if necessary uint32 id = ticket->GetId(); if (_lastTicketId < id) _lastTicketId = id; _ticketList[id] = ticket; ++count; } while (result->NextRow()); sLog->outString(">> Loaded %u GM tickets in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); }
static bool HandleGMTicketCompleteCommand(ChatHandler* handler, char const* args) { if (!*args) return false; char* ticketIdStr = strtok((char*)args, " "); uint32 ticketId = atoi(ticketIdStr); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed() || ticket->IsCompleted()) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } char* response = strtok(NULL, "\n"); if (response) { // Cannot add response to ticket, assigned to someone else //! Console excluded Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr; if (player && ticket->IsAssignedNotTo(player->GetGUID())) { handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId()); return true; } ticket->AppendResponse(response); } if (Player* player = ticket->GetPlayer()) ticket->SendResponse(player->GetSession()); Player* gm = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr; SQLTransaction trans = SQLTransaction(NULL); ticket->SetResolvedBy(gm ? gm->GetGUID() : ObjectGuid(uint64(0))); ticket->SetCompleted(); ticket->SaveToDB(trans); std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); sTicketMgr->UpdateLastChange(); return true; }
static bool HandleGMTicketCommentCommand(ChatHandler* handler, char const* args) { if (!*args) return false; char* ticketIdStr = strtok((char*)args, " "); uint32 ticketId = atoi(ticketIdStr); char* comment = strtok(NULL, "\n"); if (!comment) return false; GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed()) { handler->PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Cannot comment ticket assigned to someone else //! Console excluded Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr; if (player && ticket->IsAssignedNotTo(player->GetGUID())) { handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId()); return true; } SQLTransaction trans = SQLTransaction(NULL); ticket->SetComment(comment); ticket->SaveToDB(trans); sTicketMgr->UpdateLastChange(); std::string msg = [&] { std::string const assignedName = ticket->GetAssignedToName(); return ticket->FormatMessageString(*handler, nullptr, assignedName.empty() ? nullptr : assignedName.c_str(), nullptr, nullptr, nullptr); }(); msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName().c_str() : "Console", comment); handler->SendGlobalGMSysMessage(msg.c_str()); return true; }
static bool HandleGMTicketCommentCommand(ChatHandler* handler, char const* args) { if (!*args) return false; char* ticketIdStr = strtok((char*)args, " "); uint32 ticketId = atoi(ticketIdStr); char* comment = strtok(NULL, "\n"); if (!comment) return false; GmTicket* ticket = sTicketMgr->GetTicket(ticketId); // Ticket must exist and not be closed / completed. if (!ticket || ticket->IsClosed() || ticket->IsCompleted()) { handler->PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Cannot comment ticket assigned to someone else. Console excluded. Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; if (player && ticket->IsAssignedNotTo(player->GetGUID())) { handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId()); return true; } // Set and save the ticket comment. SQLTransaction trans = SQLTransaction(NULL); ticket->SetComment(comment); ticket->SaveToDB(trans); // Update the last change time. sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), NULL, NULL); msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName() : "Console", comment); handler->SendGlobalGMSysMessage(msg.c_str()); return 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; }
static bool HandleGMTicketCompleteCommand(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; } if (Player* player = ticket->GetPlayer()) if (player->IsInWorld()) ticket->SendResponse(player->GetSession()); if ((sIRC->TICMASK & 16) != 0 && (sIRC->BOTMASK & 1024) != 0 && sIRC->ticann.size() > 0) { std::string ircchan = "#"; std::ostringstream smsg; std::string respondedby; // If responded from console,there is no player,so we assign to Console. Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; if (player) respondedby = player->GetName().c_str(); else respondedby = "Console"; ircchan += sIRC->ticann; smsg << "[\00304Ticket Completed\003][By:\00304 " << ticket->GetPlayerName().c_str() << " \003][ID: \00304" << ticket->GetId() << " \003][Responded By: \00304" << respondedby << " \003]"; sIRC->Send_IRC_Channel(ircchan, smsg.str().c_str() , true); } SQLTransaction trans = SQLTransaction(NULL); ticket->SetCompleted(); ticket->SaveToDB(trans); std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); sTicketMgr->UpdateLastChange(); return true; }
static bool _HandleGMTicketResponseAppendCommand(char const* args, bool newLine, ChatHandler* handler) { if (!*args) return false; char* ticketIdStr = strtok((char*)args, " "); uint32 ticketId = atoi(ticketIdStr); char* response = strtok(NULL, "\n"); if (!response) return false; GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed()) { handler->PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Cannot add response to ticket, assigned to someone else. Console excluded. Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; if (player && ticket->IsAssignedNotTo(player->GetGUID())) { handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId()); return true; } // Set the ticket text and save it. SQLTransaction trans = SQLTransaction(NULL); if (newLine) ticket->SetResponse(response); // Makes a new response (form: new). else ticket->AppendResponse(response); // Puts the response over the old one (form: old + new). ticket->SaveToDB(trans); // Update the last change time. sTicketMgr->UpdateLastChange(); return true; }
bool ChatHandler::HandleGMTicketCompleteCommand(const char* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || !ticket->IsClosed() || ticket->IsCompleted()) { SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } if (Player* player = ticket->GetPlayer()) if (player->IsInWorld()) ticket->SendResponse(player->GetSession()); sTicketMgr->UpdateLastChange(); return true; }
static bool HandleGMTicketGetByIdCommand(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; } SQLTransaction trans = SQLTransaction(NULL); ticket->SetViewed(); ticket->SaveToDB(trans); handler->SendSysMessage(ticket->FormatMessageString(*handler, true).c_str()); return true; }
static bool HandleGMTicketCloseByIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); // Ticket must exist and not be closed. if (!ticket || ticket->IsClosed()) { 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; } sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : -1); sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName() : "Console", NULL, NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); // Inform the player that the ticket is closed (remove it). if (Player* submitter = ticket->GetPlayer()) { if (submitter->IsInWorld()) { sTicketMgr->SendTicketStatusUpdate(submitter->GetSession(), GMTICKET_RESPONSE_TICKET_DELETED); sTicketMgr->SendTicket(submitter->GetSession(), NULL); } } return true; }
static bool HandleGMTicketDeleteByIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); // Ticket must exist. if (!ticket) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } // Ticket must be closed. if (!ticket->IsClosed()) { handler->SendSysMessage(LANG_COMMAND_TICKETCLOSEFIRST); return true; } std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); // Force the player to abandon the ticket. if (Player* player = ticket->GetPlayer()) { if (player->IsInWorld()) { sTicketMgr->SendTicketStatusUpdate(player->GetSession(), GMTICKET_RESPONSE_TICKET_DELETED); sTicketMgr->SendTicket(player->GetSession(), NULL); } } // Remove the ticket. sTicketMgr->RemoveTicket(ticket->GetId()); sTicketMgr->UpdateLastChange(); return true; }
static bool HandleGMTicketEscalateCommand(ChatHandler* handler, char const* args) { if (!*args) return false; uint32 ticketId = atoi(args); GmTicket* ticket = sTicketMgr->GetTicket(ticketId); if (!ticket || ticket->IsClosed() || ticket->IsCompleted() || ticket->GetEscalatedStatus() != TICKET_UNASSIGNED) { handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } ticket->SetEscalatedStatus(TICKET_IN_ESCALATION_QUEUE); if (Player* player = ticket->GetPlayer()) sTicketMgr->SendTicket(player->GetSession(), ticket); sTicketMgr->UpdateLastChange(); return true; }