AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ticket_commandscript Class Reference
Inheritance diagram for ticket_commandscript:
CommandScript ScriptObject

Public Member Functions

 ticket_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleGMTicketAssignToCommand (ChatHandler *handler, uint32 ticketId, std::string target)
 
static bool HandleGMTicketCloseByIdCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGMTicketCommentCommand (ChatHandler *handler, uint32 ticketId, Tail comment)
 
static bool HandleGMTicketListClosedCommand (ChatHandler *handler)
 
static bool HandleGMTicketCompleteCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGMTicketDeleteByIdCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGMTicketEscalateCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGMTicketListEscalatedCommand (ChatHandler *handler)
 
static bool HandleGMTicketListCommand (ChatHandler *handler)
 
static bool HandleGMTicketListOnlineCommand (ChatHandler *handler)
 
static bool HandleGMTicketResetCommand (ChatHandler *handler)
 
static bool HandleToggleGMTicketSystem (ChatHandler *handler)
 
static bool HandleGMTicketUnAssignCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGMTicketGetByIdCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGMTicketGetByNameCommand (ChatHandler *handler, std::string name)
 
static bool TicketResponseAppend (uint32 ticketId, bool newLine, ChatHandler *handler, std::string response)
 
static bool HandleGMTicketResponseAppendCommand (ChatHandler *handler, uint32 ticketId, Tail res)
 
static bool HandleGMTicketResponseAppendLnCommand (ChatHandler *handler, uint32 ticketId, Tail res)
 
static bool HandleGMTicketResponseDeleteCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGMTicketResponseShowCommand (ChatHandler *handler, uint32 ticketId)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ ticket_commandscript()

ticket_commandscript::ticket_commandscript ( )
inline
38: CommandScript("ticket_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable ticket_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

41 {
42 static ChatCommandTable ticketResponseCommandTable =
43 {
44 { "append", HandleGMTicketResponseAppendCommand, SEC_GAMEMASTER, Console::Yes },
45 { "appendln", HandleGMTicketResponseAppendLnCommand, SEC_GAMEMASTER, Console::Yes },
46 { "delete", HandleGMTicketResponseDeleteCommand, SEC_GAMEMASTER, Console::Yes },
47 { "show", HandleGMTicketResponseShowCommand, SEC_GAMEMASTER, Console::Yes }
48 };
49 static ChatCommandTable ticketCommandTable =
50 {
51 { "assign", HandleGMTicketAssignToCommand, SEC_GAMEMASTER, Console::Yes },
52 { "close", HandleGMTicketCloseByIdCommand, SEC_GAMEMASTER, Console::Yes },
53 { "closedlist", HandleGMTicketListClosedCommand, SEC_GAMEMASTER, Console::Yes },
54 { "comment", HandleGMTicketCommentCommand, SEC_GAMEMASTER, Console::Yes },
55 { "complete", HandleGMTicketCompleteCommand, SEC_GAMEMASTER, Console::Yes },
56 { "delete", HandleGMTicketDeleteByIdCommand, SEC_ADMINISTRATOR, Console::Yes },
57 { "escalate", HandleGMTicketEscalateCommand, SEC_GAMEMASTER, Console::Yes },
58 { "escalatedlist", HandleGMTicketListEscalatedCommand, SEC_GAMEMASTER, Console::Yes },
59 { "list", HandleGMTicketListCommand, SEC_GAMEMASTER, Console::Yes },
60 { "onlinelist", HandleGMTicketListOnlineCommand, SEC_GAMEMASTER, Console::Yes },
61 { "reset", HandleGMTicketResetCommand, SEC_CONSOLE, Console::Yes },
62
63 { "response", ticketResponseCommandTable },
64 { "togglesystem", HandleToggleGMTicketSystem, SEC_ADMINISTRATOR, Console::Yes },
65 { "unassign", HandleGMTicketUnAssignCommand, SEC_GAMEMASTER, Console::Yes },
66 { "viewid", HandleGMTicketGetByIdCommand, SEC_GAMEMASTER, Console::Yes },
67 { "viewname", HandleGMTicketGetByNameCommand, SEC_GAMEMASTER, Console::Yes }
68 };
69 static ChatCommandTable commandTable =
70 {
71 { "ticket", ticketCommandTable }
72 };
73 return commandTable;
74 }
@ SEC_ADMINISTRATOR
Definition: Common.h:60
@ SEC_GAMEMASTER
Definition: Common.h:59
@ SEC_CONSOLE
Definition: Common.h:61
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleGMTicketEscalateCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:276
static bool HandleGMTicketCloseByIdCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:127
static bool HandleGMTicketResponseAppendLnCommand(ChatHandler *handler, uint32 ticketId, Tail res)
Definition: cs_ticket.cpp:481
static bool HandleGMTicketAssignToCommand(ChatHandler *handler, uint32 ticketId, std::string target)
Definition: cs_ticket.cpp:76
static bool HandleGMTicketResponseAppendCommand(ChatHandler *handler, uint32 ticketId, Tail res)
Definition: cs_ticket.cpp:476
static bool HandleGMTicketListClosedCommand(ChatHandler *handler)
Definition: cs_ticket.cpp:196
static bool HandleGMTicketDeleteByIdCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:244
static bool HandleToggleGMTicketSystem(ChatHandler *handler)
Definition: cs_ticket.cpp:328
static bool HandleGMTicketCommentCommand(ChatHandler *handler, uint32 ticketId, Tail comment)
Definition: cs_ticket.cpp:162
static bool HandleGMTicketResetCommand(ChatHandler *handler)
Definition: cs_ticket.cpp:312
static bool HandleGMTicketListOnlineCommand(ChatHandler *handler)
Definition: cs_ticket.cpp:306
static bool HandleGMTicketListEscalatedCommand(ChatHandler *handler)
Definition: cs_ticket.cpp:294
static bool HandleGMTicketResponseShowCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:517
static bool HandleGMTicketCompleteCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:202
static bool HandleGMTicketListCommand(ChatHandler *handler)
Definition: cs_ticket.cpp:300
static bool HandleGMTicketResponseDeleteCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:486
static bool HandleGMTicketGetByIdCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:385
static bool HandleGMTicketGetByNameCommand(ChatHandler *handler, std::string name)
Definition: cs_ticket.cpp:402
static bool HandleGMTicketUnAssignCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_ticket.cpp:336

References HandleGMTicketAssignToCommand(), HandleGMTicketCloseByIdCommand(), HandleGMTicketCommentCommand(), HandleGMTicketCompleteCommand(), HandleGMTicketDeleteByIdCommand(), HandleGMTicketEscalateCommand(), HandleGMTicketGetByIdCommand(), HandleGMTicketGetByNameCommand(), HandleGMTicketListClosedCommand(), HandleGMTicketListCommand(), HandleGMTicketListEscalatedCommand(), HandleGMTicketListOnlineCommand(), HandleGMTicketResetCommand(), HandleGMTicketResponseAppendCommand(), HandleGMTicketResponseAppendLnCommand(), HandleGMTicketResponseDeleteCommand(), HandleGMTicketResponseShowCommand(), HandleGMTicketUnAssignCommand(), HandleToggleGMTicketSystem(), SEC_ADMINISTRATOR, SEC_CONSOLE, and SEC_GAMEMASTER.

◆ HandleGMTicketAssignToCommand()

static bool ticket_commandscript::HandleGMTicketAssignToCommand ( ChatHandler handler,
uint32  ticketId,
std::string  target 
)
inlinestatic

Console can override though

77 {
78 if (!normalizePlayerName(target))
79 return false;
80
81 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
82 if (!ticket || ticket->IsClosed())
83 {
85 return true;
86 }
87
88 // Get target information
89 ObjectGuid targetGuid = sCharacterCache->GetCharacterGuidByName(target);
90 uint32 targetAccountId = sCharacterCache->GetCharacterAccountIdByGuid(targetGuid);
91 uint32 targetGmLevel = AccountMgr::GetSecurity(targetAccountId, realm.Id.Realm);
92
93 // Target must exist and have administrative rights
94 if (!targetGuid || AccountMgr::IsPlayerAccount(targetGmLevel))
95 {
97 return true;
98 }
99
100 // If already assigned, leave
101 if (ticket->IsAssignedTo(targetGuid))
102 {
104 return true;
105 }
106
107 // If assigned to different player other than current, leave
109 Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
110 if (player && ticket->IsAssignedNotTo(player->GetGUID()))
111 {
112 handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target);
113 return true;
114 }
115
116 // Assign ticket
118 ticket->SetAssignedTo(targetGuid, AccountMgr::IsAdminAccount(targetGmLevel));
119 ticket->SaveToDB(trans);
120 sTicketMgr->UpdateLastChange();
121
122 std::string msg = ticket->FormatMessageString(*handler, nullptr, target.c_str(), nullptr, nullptr);
123 handler->SendGlobalGMSysMessage(msg.c_str());
124 return true;
125 }
std::uint32_t uint32
Definition: Define.h:107
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:208
@ LANG_COMMAND_TICKETALREADYASSIGNED
Definition: Language.h:1018
@ LANG_COMMAND_TICKETASSIGNERROR_B
Definition: Language.h:1024
@ LANG_COMMAND_TICKETASSIGNERROR_A
Definition: Language.h:1023
@ LANG_COMMAND_TICKETNOTEXIST
Definition: Language.h:1016
#define sTicketMgr
Definition: TicketMgr.h:260
#define sCharacterCache
Definition: CharacterCache.h:83
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
Realm realm
Definition: World.cpp:112
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:305
uint32 GetSecurity(uint32 accountId)
Definition: AccountMgr.cpp:238
bool IsAdminAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:310
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:195
WorldSession * GetSession()
Definition: Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Definition: ObjectGuid.h:118
Definition: Player.h:1064
Player * GetPlayer() const
Definition: WorldSession.h:362
Definition: TicketMgr.h:88
bool IsAssignedTo(ObjectGuid guid) const
Definition: TicketMgr.h:98
bool IsClosed() const
Definition: TicketMgr.h:94
void SaveToDB(CharacterDatabaseTransaction trans) const
Definition: TicketMgr.cpp:78
void SetAssignedTo(ObjectGuid guid, bool isAdmin)
Definition: TicketMgr.h:122
uint32 GetId() const
Definition: TicketMgr.h:101
std::string FormatMessageString(ChatHandler &handler, bool detailed=false) const
Definition: TicketMgr.cpp:161
bool IsAssignedNotTo(ObjectGuid guid) const
Definition: TicketMgr.h:99
uint32 Realm
Definition: Realm.h:43
RealmHandle Id
Definition: Realm.h:69

References GmTicket::FormatMessageString(), Object::GetGUID(), GmTicket::GetId(), WorldSession::GetPlayer(), AccountMgr::GetSecurity(), ChatHandler::GetSession(), Realm::Id, AccountMgr::IsAdminAccount(), GmTicket::IsAssignedNotTo(), GmTicket::IsAssignedTo(), GmTicket::IsClosed(), AccountMgr::IsPlayerAccount(), LANG_COMMAND_TICKETALREADYASSIGNED, LANG_COMMAND_TICKETASSIGNERROR_A, LANG_COMMAND_TICKETASSIGNERROR_B, LANG_COMMAND_TICKETNOTEXIST, normalizePlayerName(), ChatHandler::PSendSysMessage(), realm, RealmHandle::Realm, GmTicket::SaveToDB(), sCharacterCache, ChatHandler::SendGlobalGMSysMessage(), ChatHandler::SendSysMessage(), GmTicket::SetAssignedTo(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketCloseByIdCommand()

static bool ticket_commandscript::HandleGMTicketCloseByIdCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
128 {
129 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
130 if (!ticket || ticket->IsClosed() || ticket->IsCompleted())
131 {
133 return true;
134 }
135
136 // Ticket should be assigned to the player who tries to close it.
137 // Console can override though
138 Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
139 if (player && ticket->IsAssignedNotTo(player->GetGUID()))
140 {
142 return true;
143 }
144
145 sTicketMgr->ResolveAndCloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid::Empty);
146 sTicketMgr->UpdateLastChange();
147
148 std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", nullptr, nullptr, nullptr);
149 handler->SendGlobalGMSysMessage(msg.c_str());
150
151 // Inform player, who submitted this ticket, that it is closed
152 if (Player* submitter = ticket->GetPlayer())
153 {
156 submitter->GetSession()->SendPacket(&data);
157 ChatHandler(submitter->GetSession()).SendSysMessage(LANG_TICKET_CLOSED);
158 }
159 return true;
160 }
@ LANG_COMMAND_TICKETCANNOTCLOSE
Definition: Language.h:1027
@ LANG_TICKET_CLOSED
Definition: Language.h:986
@ GMTICKET_RESPONSE_TICKET_DELETED
Definition: TicketMgr.h:47
@ SMSG_GMTICKET_DELETETICKET
Definition: Opcodes.h:566
Definition: Chat.h:37
std::string const & GetName() const
Definition: Object.h:458
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
Definition: WorldPacket.h:26
Player * GetPlayer() const
Definition: TicketMgr.h:102
bool IsCompleted() const
Definition: TicketMgr.h:95

References ObjectGuid::Empty, GmTicket::FormatMessageString(), Object::GetGUID(), GmTicket::GetId(), WorldObject::GetName(), WorldSession::GetPlayer(), GmTicket::GetPlayer(), ChatHandler::GetSession(), GMTICKET_RESPONSE_TICKET_DELETED, GmTicket::IsAssignedNotTo(), GmTicket::IsClosed(), GmTicket::IsCompleted(), LANG_COMMAND_TICKETCANNOTCLOSE, LANG_COMMAND_TICKETNOTEXIST, LANG_TICKET_CLOSED, ChatHandler::PSendSysMessage(), ChatHandler::SendGlobalGMSysMessage(), ChatHandler::SendSysMessage(), SMSG_GMTICKET_DELETETICKET, and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketCommentCommand()

static bool ticket_commandscript::HandleGMTicketCommentCommand ( ChatHandler handler,
uint32  ticketId,
Tail  comment 
)
inlinestatic
163 {
164 if (comment.empty())
165 return false;
166
167 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
168 if (!ticket)
169 {
171 return true;
172 }
173
174 // Cannot comment ticket assigned to someone else (unless done from the Console)
175 Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
176 if (player && ticket->IsAssignedNotTo(player->GetGUID()))
177 {
179 return true;
180 }
181
183 ticket->SetComment(comment.data());
184 ticket->SaveToDB(trans);
185 sTicketMgr->UpdateLastChange();
186
187 std::string const assignedName = ticket->GetAssignedToName();
188 std::string msg = ticket->FormatMessageString(*handler, assignedName.empty() ? nullptr : assignedName.c_str(), nullptr, nullptr, nullptr);
189
190 msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName().c_str() : "Console", comment.data());
191 handler->SendGlobalGMSysMessage(msg.c_str());
192
193 return true;
194 }
@ LANG_COMMAND_TICKETLISTADDCOMMENT
Definition: Language.h:1035
std::string PGetParseString(uint32 entry, Args &&... args) const
Definition: Chat.h:154
void SetComment(std::string const &comment)
Definition: TicketMgr.h:134
std::string GetAssignedToName() const
Definition: TicketMgr.h:107

References GmTicket::FormatMessageString(), GmTicket::GetAssignedToName(), Object::GetGUID(), GmTicket::GetId(), WorldObject::GetName(), WorldSession::GetPlayer(), ChatHandler::GetSession(), GmTicket::IsAssignedNotTo(), LANG_COMMAND_TICKETALREADYASSIGNED, LANG_COMMAND_TICKETLISTADDCOMMENT, LANG_COMMAND_TICKETNOTEXIST, ChatHandler::PGetParseString(), ChatHandler::PSendSysMessage(), GmTicket::SaveToDB(), ChatHandler::SendGlobalGMSysMessage(), GmTicket::SetComment(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketCompleteCommand()

static bool ticket_commandscript::HandleGMTicketCompleteCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
203 {
204 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
205 if (!ticket || ticket->IsClosed() || ticket->IsCompleted())
206 {
208 return true;
209 }
210
211 // Check if handler is not assignee in which case return
212 Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
213
214 if (player && ticket->IsAssignedNotTo(player->GetGUID()))
215 {
217 return true;
218 }
219
220 char* response = strtok(nullptr, "\n");
221 if (response)
222 ticket->AppendResponse(response);
223
224 if (Player* player2 = ticket->GetPlayer())
225 {
226 ticket->SendResponse(player2->GetSession());
227 ChatHandler(player2->GetSession()).SendSysMessage(LANG_TICKET_COMPLETED);
228 }
229
230 Player* gm = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
231
233 ticket->SetCompleted();
234 ticket->SetResolvedBy(gm ? gm->GetGUID() : ObjectGuid::Empty);
235 ticket->SaveToDB(trans);
236
237 std::string msg = ticket->FormatMessageString(*handler, nullptr, nullptr, nullptr, nullptr);
238 msg += handler->PGetParseString(LANG_COMMAND_TICKETCOMPLETED, gm ? gm->GetName().c_str() : "Console");
239 handler->SendGlobalGMSysMessage(msg.c_str());
240 sTicketMgr->UpdateLastChange();
241 return true;
242 }
@ LANG_COMMAND_TICKETCOMPLETED
Definition: Language.h:1041
@ LANG_TICKET_COMPLETED
Definition: Language.h:987
void SetResolvedBy(ObjectGuid value)
Definition: TicketMgr.h:131
void AppendResponse(std::string const &response)
Definition: TicketMgr.h:140
void SetCompleted()
Definition: TicketMgr.h:132
void SendResponse(WorldSession *session) const
Definition: TicketMgr.cpp:134

References GmTicket::AppendResponse(), ObjectGuid::Empty, GmTicket::FormatMessageString(), Object::GetGUID(), GmTicket::GetId(), WorldObject::GetName(), WorldSession::GetPlayer(), GmTicket::GetPlayer(), ChatHandler::GetSession(), GmTicket::IsAssignedNotTo(), GmTicket::IsClosed(), GmTicket::IsCompleted(), LANG_COMMAND_TICKETALREADYASSIGNED, LANG_COMMAND_TICKETCOMPLETED, LANG_COMMAND_TICKETNOTEXIST, LANG_TICKET_COMPLETED, ChatHandler::PGetParseString(), ChatHandler::PSendSysMessage(), GmTicket::SaveToDB(), ChatHandler::SendGlobalGMSysMessage(), GmTicket::SendResponse(), ChatHandler::SendSysMessage(), GmTicket::SetCompleted(), GmTicket::SetResolvedBy(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketDeleteByIdCommand()

static bool ticket_commandscript::HandleGMTicketDeleteByIdCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
245 {
246 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
247 if (!ticket)
248 {
250 return true;
251 }
252
253 if (!ticket->IsClosed())
254 {
256 return true;
257 }
258
259 std::string msg = ticket->FormatMessageString(*handler, nullptr, nullptr, nullptr, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console");
260 handler->SendGlobalGMSysMessage(msg.c_str());
261
262 sTicketMgr->RemoveTicket(ticket->GetId());
263 sTicketMgr->UpdateLastChange();
264
265 if (Player* player = ticket->GetPlayer())
266 {
267 // Force abandon ticket
270 player->GetSession()->SendPacket(&data);
271 }
272
273 return true;
274 }
@ LANG_COMMAND_TICKETCLOSEFIRST
Definition: Language.h:1017

References GmTicket::FormatMessageString(), GmTicket::GetId(), WorldObject::GetName(), WorldSession::GetPlayer(), GmTicket::GetPlayer(), ChatHandler::GetSession(), GMTICKET_RESPONSE_TICKET_DELETED, GmTicket::IsClosed(), LANG_COMMAND_TICKETCLOSEFIRST, LANG_COMMAND_TICKETNOTEXIST, ChatHandler::SendGlobalGMSysMessage(), ChatHandler::SendSysMessage(), SMSG_GMTICKET_DELETETICKET, and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketEscalateCommand()

static bool ticket_commandscript::HandleGMTicketEscalateCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
277 {
278 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
279 if (!ticket || ticket->IsClosed() || ticket->IsCompleted() || ticket->GetEscalatedStatus() != TICKET_UNASSIGNED)
280 {
282 return true;
283 }
284
286
287 if (Player* player = ticket->GetPlayer())
288 sTicketMgr->SendTicket(player->GetSession(), ticket);
289
290 sTicketMgr->UpdateLastChange();
291 return true;
292 }
@ TICKET_IN_ESCALATION_QUEUE
Definition: TicketMgr.h:59
@ TICKET_UNASSIGNED
Definition: TicketMgr.h:57
GMTicketEscalationStatus GetEscalatedStatus() const
Definition: TicketMgr.h:119
void SetEscalatedStatus(GMTicketEscalationStatus escalatedStatus)
Definition: TicketMgr.h:121

References GmTicket::GetEscalatedStatus(), GmTicket::GetPlayer(), GmTicket::IsClosed(), GmTicket::IsCompleted(), LANG_COMMAND_TICKETNOTEXIST, ChatHandler::SendSysMessage(), GmTicket::SetEscalatedStatus(), sTicketMgr, TICKET_IN_ESCALATION_QUEUE, and TICKET_UNASSIGNED.

Referenced by GetCommands().

◆ HandleGMTicketGetByIdCommand()

static bool ticket_commandscript::HandleGMTicketGetByIdCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
386 {
387 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
388 if (!ticket || ticket->IsClosed() || ticket->IsCompleted())
389 {
391 return true;
392 }
393
395 ticket->SetViewed();
396 ticket->SaveToDB(trans);
397
398 handler->SendSysMessage(ticket->FormatMessageString(*handler, true));
399 return true;
400 }
void SetViewed()
Definition: TicketMgr.h:135

References GmTicket::FormatMessageString(), GmTicket::IsClosed(), GmTicket::IsCompleted(), LANG_COMMAND_TICKETNOTEXIST, GmTicket::SaveToDB(), ChatHandler::SendSysMessage(), GmTicket::SetViewed(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketGetByNameCommand()

static bool ticket_commandscript::HandleGMTicketGetByNameCommand ( ChatHandler handler,
std::string  name 
)
inlinestatic
403 {
404 if (!normalizePlayerName(name))
405 return false;
406
407 // Detect target's GUID
408 ObjectGuid guid;
409 if (Player* player = ObjectAccessor::FindPlayerByName(name, false))
410 {
411 guid = player->GetGUID();
412 }
413 else
414 {
415 guid = sCharacterCache->GetCharacterGuidByName(name);
416 }
417
418 // Target must exist
419 if (!guid)
420 {
422 return true;
423 }
424
425 // Ticket must exist
426 GmTicket* ticket = sTicketMgr->GetTicketByPlayer(guid);
427 if (!ticket)
428 {
430 return true;
431 }
432
434 ticket->SetViewed();
435 ticket->SaveToDB(trans);
436
437 handler->SendSysMessage(ticket->FormatMessageString(*handler, true));
438 return true;
439 }
@ LANG_NO_PLAYERS_FOUND
Definition: Language.h:371
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:271

References ObjectAccessor::FindPlayerByName(), GmTicket::FormatMessageString(), LANG_COMMAND_TICKETNOTEXIST, LANG_NO_PLAYERS_FOUND, normalizePlayerName(), GmTicket::SaveToDB(), sCharacterCache, ChatHandler::SendSysMessage(), GmTicket::SetViewed(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketListClosedCommand()

static bool ticket_commandscript::HandleGMTicketListClosedCommand ( ChatHandler handler)
inlinestatic
197 {
198 sTicketMgr->ShowClosedList(*handler);
199 return true;
200 }

References sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketListCommand()

static bool ticket_commandscript::HandleGMTicketListCommand ( ChatHandler handler)
inlinestatic
301 {
302 sTicketMgr->ShowList(*handler, false);
303 return true;
304 }

References sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketListEscalatedCommand()

static bool ticket_commandscript::HandleGMTicketListEscalatedCommand ( ChatHandler handler)
inlinestatic
295 {
296 sTicketMgr->ShowEscalatedList(*handler);
297 return true;
298 }

References sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketListOnlineCommand()

static bool ticket_commandscript::HandleGMTicketListOnlineCommand ( ChatHandler handler)
inlinestatic
307 {
308 sTicketMgr->ShowList(*handler, true);
309 return true;
310 }

References sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketResetCommand()

static bool ticket_commandscript::HandleGMTicketResetCommand ( ChatHandler handler)
inlinestatic
313 {
314 if (sTicketMgr->GetOpenTicketCount())
315 {
317 return true;
318 }
319 else
320 {
321 sTicketMgr->ResetTickets();
323 }
324
325 return true;
326 }
@ LANG_COMMAND_TICKETRESET
Definition: Language.h:1039
@ LANG_COMMAND_TICKETPENDING
Definition: Language.h:1038

References LANG_COMMAND_TICKETPENDING, LANG_COMMAND_TICKETRESET, ChatHandler::SendSysMessage(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketResponseAppendCommand()

static bool ticket_commandscript::HandleGMTicketResponseAppendCommand ( ChatHandler handler,
uint32  ticketId,
Tail  res 
)
inlinestatic
477 {
478 return TicketResponseAppend(ticketId, false, handler, res.data());
479 }
static bool TicketResponseAppend(uint32 ticketId, bool newLine, ChatHandler *handler, std::string response)
Definition: cs_ticket.cpp:441

References TicketResponseAppend().

Referenced by GetCommands().

◆ HandleGMTicketResponseAppendLnCommand()

static bool ticket_commandscript::HandleGMTicketResponseAppendLnCommand ( ChatHandler handler,
uint32  ticketId,
Tail  res 
)
inlinestatic
482 {
483 return TicketResponseAppend(ticketId, true, handler, res.data());
484 }

References TicketResponseAppend().

Referenced by GetCommands().

◆ HandleGMTicketResponseDeleteCommand()

static bool ticket_commandscript::HandleGMTicketResponseDeleteCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic

Console excluded

487 {
488 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
489 // Don't allow deleting response for a closed ticket.
490 if (!ticket || ticket->IsClosed())
491 {
493 return true;
494 }
495
496 // Cannot delete response for a ticket that is assigned to someone else.
498 Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
499 if (player && ticket->IsAssignedNotTo(player->GetGUID()))
500 {
502 return true;
503 }
504
506 ticket->DeleteResponse();
507 ticket->SaveToDB(trans);
508 sTicketMgr->UpdateLastChange();
509
510 std::string msg = ticket->FormatMessageString(*handler, nullptr, nullptr, nullptr, nullptr);
511 msg += handler->PGetParseString(LANG_COMMAND_TICKETRESPONSEDELETED, player ? player->GetName() : "Console");
512
513 handler->SendGlobalGMSysMessage(msg.c_str());
514 return true;
515 }
@ LANG_COMMAND_TICKETRESPONSEDELETED
Definition: Language.h:1043
void DeleteResponse()
Definition: TicketMgr.h:142

References GmTicket::DeleteResponse(), GmTicket::FormatMessageString(), Object::GetGUID(), GmTicket::GetId(), WorldObject::GetName(), WorldSession::GetPlayer(), ChatHandler::GetSession(), GmTicket::IsAssignedNotTo(), GmTicket::IsClosed(), LANG_COMMAND_TICKETALREADYASSIGNED, LANG_COMMAND_TICKETNOTEXIST, LANG_COMMAND_TICKETRESPONSEDELETED, ChatHandler::PGetParseString(), ChatHandler::PSendSysMessage(), GmTicket::SaveToDB(), ChatHandler::SendGlobalGMSysMessage(), ChatHandler::SendSysMessage(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketResponseShowCommand()

static bool ticket_commandscript::HandleGMTicketResponseShowCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
518 {
519 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
520 if (!ticket)
521 {
523 return true;
524 }
525
526 std::string msg = ticket->FormatMessageString(*handler, nullptr, nullptr, nullptr, nullptr);
528
529 handler->PSendSysMessage(msg);
530 return true;
531 }
@ LANG_COMMAND_TICKETLISTRESPONSE
Definition: Language.h:1040
std::string GetResponse()
Definition: TicketMgr.h:141

References GmTicket::FormatMessageString(), GmTicket::GetResponse(), LANG_COMMAND_TICKETLISTRESPONSE, LANG_COMMAND_TICKETNOTEXIST, ChatHandler::PGetParseString(), ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleGMTicketUnAssignCommand()

static bool ticket_commandscript::HandleGMTicketUnAssignCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic

If no m_session present it means we're issuing this command from the console

337 {
338 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
339 if (!ticket || ticket->IsClosed())
340 {
342 return true;
343 }
344 // Ticket must be assigned
345 if (!ticket->IsAssigned())
346 {
348 return true;
349 }
350
351 // Get security level of player, whom this ticket is assigned to
352 uint32 security = SEC_PLAYER;
353 Player* assignedPlayer = ticket->GetAssignedPlayer();
354 if (assignedPlayer)
355 security = assignedPlayer->GetSession()->GetSecurity();
356 else
357 {
358 ObjectGuid guid = ticket->GetAssignedToGUID();
359 uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid);
360 security = AccountMgr::GetSecurity(accountId, realm.Id.Realm);
361 }
362
363 // Check security
365 uint32 mySecurity = handler->GetSession() ? handler->GetSession()->GetSecurity() : SEC_CONSOLE;
366 if (security > mySecurity)
367 {
369 return true;
370 }
371
372 std::string assignedTo = ticket->GetAssignedToName(); // copy assignedto name because we need it after the ticket has been unnassigned
374 ticket->SetUnassigned();
375 ticket->SaveToDB(trans);
376 sTicketMgr->UpdateLastChange();
377
378 std::string msg = ticket->FormatMessageString(*handler, nullptr, assignedTo.c_str(),
379 handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", nullptr);
380 handler->SendGlobalGMSysMessage(msg.c_str());
381
382 return true;
383 }
@ SEC_PLAYER
Definition: Common.h:57
@ LANG_COMMAND_TICKETUNASSIGNSECURITY
Definition: Language.h:1026
@ LANG_COMMAND_TICKETNOTASSIGNED
Definition: Language.h:1025
WorldSession * GetSession() const
Definition: Player.h:1981
AccountTypes GetSecurity() const
Definition: WorldSession.h:359
ObjectGuid GetAssignedToGUID() const
Definition: TicketMgr.h:106
bool IsAssigned() const
Definition: TicketMgr.h:97
void SetUnassigned()
Definition: TicketMgr.cpp:204
Player * GetAssignedPlayer() const
Definition: TicketMgr.h:105

References GmTicket::FormatMessageString(), GmTicket::GetAssignedPlayer(), GmTicket::GetAssignedToGUID(), GmTicket::GetAssignedToName(), GmTicket::GetId(), WorldObject::GetName(), WorldSession::GetPlayer(), WorldSession::GetSecurity(), AccountMgr::GetSecurity(), ChatHandler::GetSession(), Player::GetSession(), Realm::Id, GmTicket::IsAssigned(), GmTicket::IsClosed(), LANG_COMMAND_TICKETNOTASSIGNED, LANG_COMMAND_TICKETNOTEXIST, LANG_COMMAND_TICKETUNASSIGNSECURITY, ChatHandler::PSendSysMessage(), realm, RealmHandle::Realm, GmTicket::SaveToDB(), sCharacterCache, SEC_CONSOLE, SEC_PLAYER, ChatHandler::SendGlobalGMSysMessage(), ChatHandler::SendSysMessage(), GmTicket::SetUnassigned(), and sTicketMgr.

Referenced by GetCommands().

◆ HandleToggleGMTicketSystem()

static bool ticket_commandscript::HandleToggleGMTicketSystem ( ChatHandler handler)
inlinestatic
329 {
330 bool status = !sTicketMgr->GetStatus();
331 sTicketMgr->SetStatus(status);
333 return true;
334 }
@ LANG_ALLOW_TICKETS
Definition: Language.h:923
@ LANG_DISALLOW_TICKETS
Definition: Language.h:924

References LANG_ALLOW_TICKETS, LANG_DISALLOW_TICKETS, ChatHandler::PSendSysMessage(), and sTicketMgr.

Referenced by GetCommands().

◆ TicketResponseAppend()

static bool ticket_commandscript::TicketResponseAppend ( uint32  ticketId,
bool  newLine,
ChatHandler handler,
std::string  response 
)
inlinestatic

Console excluded

442 {
443 if (response.empty())
444 return false;
445
446 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
447 if (!ticket || ticket->IsClosed())
448 {
450 return true;
451 }
452
453 // Cannot add response to ticket, assigned to someone else
455 Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
456 if (player && ticket->IsAssignedNotTo(player->GetGUID()))
457 {
459 return true;
460 }
461
463 if (newLine)
464 ticket->AppendResponse("\n");
465 ticket->AppendResponse(response);
466 ticket->SaveToDB(trans);
467 sTicketMgr->UpdateLastChange();
468
469 std::string msg = ticket->FormatMessageString(*handler, nullptr, nullptr, nullptr, nullptr);
470 msg += handler->PGetParseString(LANG_COMMAND_TICKETRESPONSEAPPENDED, response);
471
472 handler->PSendSysMessage(msg);
473 return true;
474 }
@ LANG_COMMAND_TICKETRESPONSEAPPENDED
Definition: Language.h:1042

References GmTicket::AppendResponse(), GmTicket::FormatMessageString(), Object::GetGUID(), GmTicket::GetId(), WorldSession::GetPlayer(), ChatHandler::GetSession(), GmTicket::IsAssignedNotTo(), GmTicket::IsClosed(), LANG_COMMAND_TICKETALREADYASSIGNED, LANG_COMMAND_TICKETNOTEXIST, LANG_COMMAND_TICKETRESPONSEAPPENDED, ChatHandler::PGetParseString(), ChatHandler::PSendSysMessage(), GmTicket::SaveToDB(), and sTicketMgr.

Referenced by HandleGMTicketResponseAppendCommand(), and HandleGMTicketResponseAppendLnCommand().