Merge pull request #7102 from Vincent-Michael/ticketCommand
Core/Commands: Convert ticket commands in commandscript
This commit is contained in:
@@ -111,34 +111,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
|||||||
{ NULL, 0, false, NULL, "", NULL }
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static ChatCommand ticketResponseCommandTable[] =
|
|
||||||
{
|
|
||||||
{ "append", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketResponseAppendCommand>, "", NULL },
|
|
||||||
{ "appendln", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketResponseAppendLnCommand>, "", NULL },
|
|
||||||
{ NULL, 0, false, NULL, "", NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
static ChatCommand ticketCommandTable[] =
|
|
||||||
{
|
|
||||||
{ "list", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketListCommand>, "", NULL },
|
|
||||||
{ "onlinelist", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketListOnlineCommand>, "", NULL },
|
|
||||||
{ "viewname", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketGetByNameCommand>, "", NULL },
|
|
||||||
{ "viewid", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketGetByIdCommand>, "", NULL },
|
|
||||||
{ "close", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketCloseByIdCommand>, "", NULL },
|
|
||||||
{ "closedlist", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketListClosedCommand>, "", NULL },
|
|
||||||
{ "escalatedlist", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleGMTicketListEscalatedCommand>, "", NULL },
|
|
||||||
{ "delete", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleGMTicketDeleteByIdCommand>, "", NULL },
|
|
||||||
{ "reset", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleGMTicketResetCommand>, "", NULL },
|
|
||||||
{ "assign", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleGMTicketAssignToCommand>, "", NULL },
|
|
||||||
{ "unassign", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleGMTicketUnAssignCommand>, "", NULL },
|
|
||||||
{ "comment", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketCommentCommand>, "", NULL },
|
|
||||||
{ "togglesystem", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleToggleGMTicketSystem>, "", NULL },
|
|
||||||
{ "escalate", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketEscalateCommand>, "", NULL },
|
|
||||||
{ "response", SEC_MODERATOR, true, NULL, "", ticketResponseCommandTable },
|
|
||||||
{ "complete", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMTicketCompleteCommand>, "", NULL },
|
|
||||||
{ NULL, 0, false, NULL, "", NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
static ChatCommand commandTable[] =
|
static ChatCommand commandTable[] =
|
||||||
{
|
{
|
||||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||||
@@ -147,7 +119,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
|||||||
{ "channel", SEC_ADMINISTRATOR, true, NULL, "", channelCommandTable },
|
{ "channel", SEC_ADMINISTRATOR, true, NULL, "", channelCommandTable },
|
||||||
|
|
||||||
{ "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable },
|
{ "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable },
|
||||||
{ "ticket", SEC_MODERATOR, false, NULL, "", ticketCommandTable },
|
|
||||||
|
|
||||||
{ "aura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAuraCommand>, "", NULL },
|
{ "aura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAuraCommand>, "", NULL },
|
||||||
{ "unaura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleUnAuraCommand>, "", NULL },
|
{ "unaura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleUnAuraCommand>, "", NULL },
|
||||||
|
|||||||
@@ -211,26 +211,6 @@ class ChatHandler
|
|||||||
bool HandleChangeWeather(const char* args);
|
bool HandleChangeWeather(const char* args);
|
||||||
bool HandleKickPlayerCommand(const char * args);
|
bool HandleKickPlayerCommand(const char * args);
|
||||||
|
|
||||||
// GM ticket command handlers
|
|
||||||
bool HandleGMTicketListCommand(const char* args);
|
|
||||||
bool HandleGMTicketListOnlineCommand(const char* args);
|
|
||||||
bool HandleGMTicketListClosedCommand(const char* args);
|
|
||||||
bool HandleGMTicketListEscalatedCommand(const char* args);
|
|
||||||
bool HandleGMTicketGetByIdCommand(const char* args);
|
|
||||||
bool HandleGMTicketGetByNameCommand(const char* args);
|
|
||||||
bool HandleGMTicketCloseByIdCommand(const char* args);
|
|
||||||
bool HandleGMTicketAssignToCommand(const char* args);
|
|
||||||
bool HandleGMTicketUnAssignCommand(const char* args);
|
|
||||||
bool HandleGMTicketCommentCommand(const char* args);
|
|
||||||
bool HandleGMTicketDeleteByIdCommand(const char* args);
|
|
||||||
bool HandleGMTicketResetCommand(const char* /* args */);
|
|
||||||
bool HandleGMTicketReloadCommand(const char*);
|
|
||||||
bool HandleToggleGMTicketSystem(const char* args);
|
|
||||||
bool HandleGMTicketEscalateCommand(const char* args);
|
|
||||||
bool HandleGMTicketCompleteCommand(const char* args);
|
|
||||||
bool HandleGMTicketResponseAppendCommand(const char* args);
|
|
||||||
bool HandleGMTicketResponseAppendLnCommand(const char* args);
|
|
||||||
|
|
||||||
bool HandleMaxSkillCommand(const char* args);
|
bool HandleMaxSkillCommand(const char* args);
|
||||||
bool HandleSetSkillCommand(const char* args);
|
bool HandleSetSkillCommand(const char* args);
|
||||||
bool HandleRespawnCommand(const char* args);
|
bool HandleRespawnCommand(const char* args);
|
||||||
@@ -259,8 +239,6 @@ class ChatHandler
|
|||||||
void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id);
|
void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _HandleGMTicketResponseAppendCommand(const char* args, bool newLine);
|
|
||||||
|
|
||||||
WorldSession* m_session; // != NULL for chat command call and NULL for CLI command
|
WorldSession* m_session; // != NULL for chat command call and NULL for CLI command
|
||||||
|
|
||||||
// common global flag
|
// common global flag
|
||||||
|
|||||||
@@ -1,457 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2 of the License, or (at your
|
|
||||||
* option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "DatabaseEnv.h"
|
|
||||||
#include "WorldPacket.h"
|
|
||||||
#include "WorldSession.h"
|
|
||||||
#include "ObjectMgr.h"
|
|
||||||
#include "TicketMgr.h"
|
|
||||||
#include "AccountMgr.h"
|
|
||||||
#include "Chat.h"
|
|
||||||
#include "Player.h"
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketListCommand(const char* /*args*/)
|
|
||||||
{
|
|
||||||
sTicketMgr->ShowList(*this, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketListOnlineCommand(const char* /*args*/)
|
|
||||||
{
|
|
||||||
sTicketMgr->ShowList(*this, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketListClosedCommand(const char* /*args*/)
|
|
||||||
{
|
|
||||||
sTicketMgr->ShowClosedList(*this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketListEscalatedCommand(const char* /*args*/)
|
|
||||||
{
|
|
||||||
sTicketMgr->ShowEscalatedList(*this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketGetByIdCommand(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQLTransaction trans = SQLTransaction(NULL);
|
|
||||||
ticket->SetViewed();
|
|
||||||
ticket->SaveToDB(trans);
|
|
||||||
|
|
||||||
SendSysMessage(ticket->FormatMessageString(*this, true).c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketGetByNameCommand(const char* 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)
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_NO_PLAYERS_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ticket must exist
|
|
||||||
GmTicket *ticket = sTicketMgr->GetTicketByPlayer(guid);
|
|
||||||
if (!ticket)
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQLTransaction trans = SQLTransaction(NULL);
|
|
||||||
ticket->SetViewed();
|
|
||||||
ticket->SaveToDB(trans);
|
|
||||||
|
|
||||||
SendSysMessage(ticket->FormatMessageString(*this, true).c_str());
|
|
||||||
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 should be assigned to the player who tries to close it.
|
|
||||||
// Console can override though
|
|
||||||
Player* player = m_session ? m_session->GetPlayer() : NULL;
|
|
||||||
if (player && ticket->IsAssignedNotTo(player->GetGUID()))
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_TICKETCANNOTCLOSE, ticket->GetId());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : -1);
|
|
||||||
sTicketMgr->UpdateLastChange();
|
|
||||||
|
|
||||||
std::string msg = ticket->FormatMessageString(*this, player ? player->GetName() : "Console", NULL, NULL, NULL);
|
|
||||||
SendGlobalGMSysMessage(msg.c_str());
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = AccountMgr::GetSecurity(targetAccId, realmID);
|
|
||||||
|
|
||||||
// Target must exist and have administrative rights
|
|
||||||
if (!targetGuid || AccountMgr::IsPlayerAccount(targetGmLevel))
|
|
||||||
{
|
|
||||||
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
|
|
||||||
//! Console can override though
|
|
||||||
Player* player = m_session ? m_session->GetPlayer() : NULL;
|
|
||||||
if (player && ticket->IsAssignedNotTo(player->GetGUID()))
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target.c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign ticket
|
|
||||||
SQLTransaction trans = SQLTransaction(NULL);
|
|
||||||
ticket->SetAssignedTo(targetGuid, AccountMgr::IsAdminAccount(targetGmLevel));
|
|
||||||
ticket->SaveToDB(trans);
|
|
||||||
sTicketMgr->UpdateLastChange();
|
|
||||||
|
|
||||||
std::string msg = ticket->FormatMessageString(*this, NULL, target.c_str(), NULL, NULL);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketCommentCommand(const char* args)
|
|
||||||
{
|
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char* tguid = strtok((char*)args, " ");
|
|
||||||
uint32 ticketId = atoi(tguid);
|
|
||||||
|
|
||||||
char* comment = strtok(NULL, "\n");
|
|
||||||
if (!comment)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GmTicket *ticket = sTicketMgr->GetTicket(ticketId);
|
|
||||||
if (!ticket || ticket->IsClosed())
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cannot comment ticket assigned to someone else
|
|
||||||
//! Console excluded
|
|
||||||
Player* player = m_session ? m_session->GetPlayer() : NULL;
|
|
||||||
if (player && ticket->IsAssignedNotTo(player->GetGUID()))
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQLTransaction trans = SQLTransaction(NULL);
|
|
||||||
ticket->SetComment(comment);
|
|
||||||
ticket->SaveToDB(trans);
|
|
||||||
sTicketMgr->UpdateLastChange();
|
|
||||||
|
|
||||||
std::string msg = ticket->FormatMessageString(*this, NULL, ticket->GetAssignedToName().c_str(), NULL, NULL);
|
|
||||||
msg += PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName() : "Console", comment);
|
|
||||||
SendGlobalGMSysMessage(msg.c_str());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketDeleteByIdCommand(const char* args)
|
|
||||||
{
|
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 ticketId = atoi(args);
|
|
||||||
GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
|
|
||||||
if (!ticket)
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ticket->IsClosed())
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_TICKETCLOSEFIRST);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string msg = ticket->FormatMessageString(*this, NULL, NULL, NULL, m_session ? m_session->GetPlayer()->GetName() : "Console");
|
|
||||||
SendGlobalGMSysMessage(msg.c_str());
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketResetCommand(const char* /* args */)
|
|
||||||
{
|
|
||||||
if (sTicketMgr->GetOpenTicketCount() > 0)
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_TICKETPENDING);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sTicketMgr->ResetTickets();
|
|
||||||
SendSysMessage(LANG_COMMAND_TICKETRESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleToggleGMTicketSystem(const char* /* args */)
|
|
||||||
{
|
|
||||||
bool status = !sTicketMgr->GetStatus();
|
|
||||||
sTicketMgr->SetStatus(status);
|
|
||||||
PSendSysMessage(status ? LANG_ALLOW_TICKETS : LANG_DISALLOW_TICKETS);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketEscalateCommand(const char *args)
|
|
||||||
{
|
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 ticketId = atoi(args);
|
|
||||||
GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
|
|
||||||
if (!ticket || !ticket->IsClosed() || ticket->IsCompleted() || ticket->GetEscalatedStatus() != TICKET_UNASSIGNED)
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ticket->SetEscalatedStatus(TICKET_IN_ESCALATION_QUEUE);
|
|
||||||
|
|
||||||
if (Player* player = ticket->GetPlayer())
|
|
||||||
if (player->IsInWorld())
|
|
||||||
sTicketMgr->SendTicket(player->GetSession(), ticket);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
//! Console excluded
|
|
||||||
Player* player = m_session ? m_session->GetPlayer() : NULL;
|
|
||||||
if (player && 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::HandleGMTicketResponseAppendCommand(const char* args)
|
|
||||||
{
|
|
||||||
return _HandleGMTicketResponseAppendCommand(args, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGMTicketResponseAppendLnCommand(const char* args)
|
|
||||||
{
|
|
||||||
return _HandleGMTicketResponseAppendCommand(args, true);
|
|
||||||
}
|
|
||||||
@@ -68,6 +68,7 @@ void AddSC_reload_commandscript();
|
|||||||
void AddSC_reset_commandscript();
|
void AddSC_reset_commandscript();
|
||||||
void AddSC_server_commandscript();
|
void AddSC_server_commandscript();
|
||||||
void AddSC_tele_commandscript();
|
void AddSC_tele_commandscript();
|
||||||
|
void AddSC_ticket_commandscript();
|
||||||
void AddSC_titles_commandscript();
|
void AddSC_titles_commandscript();
|
||||||
void AddSC_wp_commandscript();
|
void AddSC_wp_commandscript();
|
||||||
|
|
||||||
@@ -679,6 +680,7 @@ void AddCommandScripts()
|
|||||||
AddSC_reset_commandscript();
|
AddSC_reset_commandscript();
|
||||||
AddSC_server_commandscript();
|
AddSC_server_commandscript();
|
||||||
AddSC_tele_commandscript();
|
AddSC_tele_commandscript();
|
||||||
|
AddSC_ticket_commandscript();
|
||||||
AddSC_titles_commandscript();
|
AddSC_titles_commandscript();
|
||||||
AddSC_wp_commandscript();
|
AddSC_wp_commandscript();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ set(scripts_STAT_SRCS
|
|||||||
Commands/cs_reload.cpp
|
Commands/cs_reload.cpp
|
||||||
Commands/cs_reset.cpp
|
Commands/cs_reset.cpp
|
||||||
Commands/cs_tele.cpp
|
Commands/cs_tele.cpp
|
||||||
|
Commands/cs_ticket.cpp
|
||||||
Commands/cs_server.cpp
|
Commands/cs_server.cpp
|
||||||
Commands/cs_titles.cpp
|
Commands/cs_titles.cpp
|
||||||
Commands/cs_wp.cpp
|
Commands/cs_wp.cpp
|
||||||
# Commands/cs_pdump.cpp
|
# Commands/cs_pdump.cpp
|
||||||
# Commands/cs_channel.cpp
|
# Commands/cs_channel.cpp
|
||||||
# Commands/cs_pet.cpp
|
# Commands/cs_pet.cpp
|
||||||
# Commands/cs_ticket.cpp
|
|
||||||
# Commands/cs_aura.cpp
|
# Commands/cs_aura.cpp
|
||||||
# Commands/cs_unaura.cpp
|
# Commands/cs_unaura.cpp
|
||||||
# Commands/cs_nameannounce.cpp
|
# Commands/cs_nameannounce.cpp
|
||||||
|
|||||||
@@ -0,0 +1,509 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ScriptData
|
||||||
|
Name: ticket_commandscript
|
||||||
|
%Complete: 100
|
||||||
|
Comment: All ticket related commands
|
||||||
|
Category: commandscripts
|
||||||
|
EndScriptData */
|
||||||
|
|
||||||
|
#include "ScriptMgr.h"
|
||||||
|
#include "Chat.h"
|
||||||
|
#include "AccountMgr.h"
|
||||||
|
#include "ObjectMgr.h"
|
||||||
|
#include "TicketMgr.h"
|
||||||
|
|
||||||
|
class ticket_commandscript : public CommandScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ticket_commandscript() : CommandScript("ticket_commandscript") { }
|
||||||
|
|
||||||
|
ChatCommand* GetCommands() const
|
||||||
|
{
|
||||||
|
static ChatCommand ticketResponseCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "append", SEC_MODERATOR, true, &HandleGMTicketResponseAppendCommand, "", NULL },
|
||||||
|
{ "appendln", SEC_MODERATOR, true, &HandleGMTicketResponseAppendLnCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
static ChatCommand ticketCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "assign", SEC_GAMEMASTER, true, &HandleGMTicketAssignToCommand, "", NULL },
|
||||||
|
{ "close", SEC_MODERATOR, true, &HandleGMTicketCloseByIdCommand, "", NULL },
|
||||||
|
{ "closedlist", SEC_MODERATOR, true, &HandleGMTicketListClosedCommand, "", NULL },
|
||||||
|
{ "comment", SEC_MODERATOR, true, &HandleGMTicketCommentCommand, "", NULL },
|
||||||
|
{ "complete", SEC_MODERATOR, true, &HandleGMTicketCompleteCommand, "", NULL },
|
||||||
|
{ "delete", SEC_ADMINISTRATOR, true, &HandleGMTicketDeleteByIdCommand, "", NULL },
|
||||||
|
{ "escalate", SEC_MODERATOR, true, &HandleGMTicketEscalateCommand, "", NULL },
|
||||||
|
{ "escalatedlist", SEC_GAMEMASTER, true, &HandleGMTicketListEscalatedCommand, "", NULL },
|
||||||
|
{ "list", SEC_MODERATOR, true, &HandleGMTicketListCommand, "", NULL },
|
||||||
|
{ "onlinelist", SEC_MODERATOR, true, &HandleGMTicketListOnlineCommand, "", NULL },
|
||||||
|
{ "reset", SEC_ADMINISTRATOR, true, &HandleGMTicketResetCommand, "", NULL },
|
||||||
|
{ "response", SEC_MODERATOR, true, NULL, "", ticketResponseCommandTable },
|
||||||
|
{ "togglesystem", SEC_ADMINISTRATOR, true, &HandleToggleGMTicketSystem, "", NULL },
|
||||||
|
{ "unassign", SEC_GAMEMASTER, true, &HandleGMTicketUnAssignCommand, "", NULL },
|
||||||
|
{ "viewid", SEC_MODERATOR, true, &HandleGMTicketGetByIdCommand, "", NULL },
|
||||||
|
{ "viewname", SEC_MODERATOR, true, &HandleGMTicketGetByNameCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
static ChatCommand commandTable[] =
|
||||||
|
{
|
||||||
|
{ "ticket", SEC_MODERATOR, false, NULL, "", ticketCommandTable },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
return commandTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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(targetGmLevel));
|
||||||
|
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 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() : -1);
|
||||||
|
sTicketMgr->UpdateLastChange();
|
||||||
|
|
||||||
|
std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName() : "Console", NULL, NULL, NULL);
|
||||||
|
handler->SendGlobalGMSysMessage(msg.c_str());
|
||||||
|
|
||||||
|
// 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 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() : NULL;
|
||||||
|
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 = 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 HandleGMTicketListClosedCommand(ChatHandler* handler, char const* /*args*/)
|
||||||
|
{
|
||||||
|
sTicketMgr->ShowClosedList(*handler);
|
||||||
|
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());
|
||||||
|
|
||||||
|
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() : "Console");
|
||||||
|
handler->SendGlobalGMSysMessage(msg.c_str());
|
||||||
|
|
||||||
|
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 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())
|
||||||
|
if (player->IsInWorld())
|
||||||
|
sTicketMgr->SendTicket(player->GetSession(), ticket);
|
||||||
|
|
||||||
|
sTicketMgr->UpdateLastChange();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleGMTicketListEscalatedCommand(ChatHandler* handler, char const* /*args*/)
|
||||||
|
{
|
||||||
|
sTicketMgr->ShowEscalatedList(*handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleGMTicketListCommand(ChatHandler* handler, char const* /*args*/)
|
||||||
|
{
|
||||||
|
sTicketMgr->ShowList(*handler, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleGMTicketListOnlineCommand(ChatHandler* handler, char const* /*args*/)
|
||||||
|
{
|
||||||
|
sTicketMgr->ShowList(*handler, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleGMTicketResetCommand(ChatHandler* handler, char const* /*args*/)
|
||||||
|
{
|
||||||
|
if (sTicketMgr->GetOpenTicketCount())
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_TICKETPENDING);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sTicketMgr->ResetTickets();
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_TICKETRESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleToggleGMTicketSystem(ChatHandler* handler, char const* /*args*/)
|
||||||
|
{
|
||||||
|
bool status = !sTicketMgr->GetStatus();
|
||||||
|
sTicketMgr->SetStatus(status);
|
||||||
|
handler->PSendSysMessage(status ? LANG_ALLOW_TICKETS : LANG_DISALLOW_TICKETS);
|
||||||
|
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 && 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLTransaction trans = SQLTransaction(NULL);
|
||||||
|
ticket->SetUnassigned();
|
||||||
|
ticket->SaveToDB(trans);
|
||||||
|
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 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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLTransaction trans = SQLTransaction(NULL);
|
||||||
|
ticket->SetViewed();
|
||||||
|
ticket->SaveToDB(trans);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLTransaction trans = SQLTransaction(NULL);
|
||||||
|
ticket->AppendResponse(response);
|
||||||
|
if (newLine)
|
||||||
|
ticket->AppendResponse("\n");
|
||||||
|
ticket->SaveToDB(trans);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleGMTicketResponseAppendCommand(ChatHandler* handler, char const* args)
|
||||||
|
{
|
||||||
|
return _HandleGMTicketResponseAppendCommand(args, false, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleGMTicketResponseAppendLnCommand(ChatHandler* handler, char const* args)
|
||||||
|
{
|
||||||
|
return _HandleGMTicketResponseAppendCommand(args, true, handler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void AddSC_ticket_commandscript()
|
||||||
|
{
|
||||||
|
new ticket_commandscript();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user