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; }
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; }
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 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; }
static bool HandleGMTicketGetByNameCommand(ChatHandler* handler, char const* args) { if (!*args) return false; std::string name(args); if (!normalizePlayerName(name)) return false; // Detect target's GUID uint64 guid = 0; if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) guid = player->GetGUID(); else guid = sObjectMgr->GetPlayerGUIDByName(name); // Target must exist. if (!guid) { handler->SendSysMessage(LANG_NO_PLAYERS_FOUND); return true; } // Ticket must exist. GmTicket* ticket = sTicketMgr->GetTicketByPlayer(guid); if (!ticket) { 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; }
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; }
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; } // Get target information uint64 targetGuid = sObjectMgr->GetPlayerGUIDByName(target.c_str()); uint64 targetAccountId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); uint32 targetGmLevel = AccountMgr::GetSecurity(targetAccountId, realmID); // Target must exist and have administrative rights if (!targetGuid || AccountMgr::IsPlayerAccount(targetGmLevel)) { handler->SendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_A); return true; } // Ticket must not already be assigned to the same player. if (ticket->IsAssignedTo(targetGuid)) { handler->PSendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_B, ticket->GetId()); return true; } // Ticket must not already be assigned to the another player. 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 and save it. SQLTransaction trans = SQLTransaction(NULL); ticket->SetAssignedTo(targetGuid, AccountMgr::IsAdminAccount(targetGmLevel)); ticket->SetResponse("Your ticket has been assigned to a GM and is being serviced."); ticket->SaveToDB(trans); // Update the last change time. sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, target.c_str(), NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); return true; }