TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ticket_commandscript Class Reference

Public Member Functions

 ticket_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

template<typename T >
static bool HandleTicketAssignToCommand (ChatHandler *handler, char const *args)
 
template<typename T >
static bool HandleTicketCloseByIdCommand (ChatHandler *handler, char const *args)
 
template<typename T >
static bool HandleTicketCommentCommand (ChatHandler *handler, char const *args)
 
template<typename T >
static bool HandleTicketDeleteByIdCommand (ChatHandler *handler, char const *args)
 
template<typename T >
static bool HandleTicketListCommand (ChatHandler *handler, char const *)
 
template<typename T >
static bool HandleTicketListClosedCommand (ChatHandler *handler, char const *)
 
template<typename T >
static bool HandleTicketResetCommand (ChatHandler *handler, char const *)
 
template<typename T >
static bool HandleTicketUnAssignCommand (ChatHandler *handler, char const *args)
 
template<typename T >
static bool HandleTicketGetByIdCommand (ChatHandler *handler, char const *args)
 
static bool HandleTicketResetAllCommand (ChatHandler *handler, char const *)
 
static bool HandleToggleGMTicketSystem (ChatHandler *handler, char const *)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

ticket_commandscript::ticket_commandscript ( )
inline
38 : CommandScript("ticket_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector< ChatCommand > ticket_commandscript::GetCommands ( ) const
overridevirtual

Implements CommandScript.

368 {
369  static std::vector<ChatCommand> ticketBugCommandTable =
370  {
371  { "assign", rbac::RBAC_PERM_COMMAND_TICKET_BUG_ASSIGN, true, &HandleTicketAssignToCommand<BugTicket>, "" },
372  { "close", rbac::RBAC_PERM_COMMAND_TICKET_BUG_CLOSE, true, &HandleTicketCloseByIdCommand<BugTicket>, "" },
373  { "closedlist", rbac::RBAC_PERM_COMMAND_TICKET_BUG_CLOSEDLIST, true, &HandleTicketListClosedCommand<BugTicket>, "" },
374  { "comment", rbac::RBAC_PERM_COMMAND_TICKET_BUG_COMMENT, true, &HandleTicketCommentCommand<BugTicket>, "" },
375  { "delete", rbac::RBAC_PERM_COMMAND_TICKET_BUG_DELETE, true, &HandleTicketDeleteByIdCommand<BugTicket>, "" },
376  { "list", rbac::RBAC_PERM_COMMAND_TICKET_BUG_LIST, true, &HandleTicketListCommand<BugTicket>, "" },
377  { "unassign", rbac::RBAC_PERM_COMMAND_TICKET_BUG_UNASSIGN, true, &HandleTicketUnAssignCommand<BugTicket>, "" },
378  { "view", rbac::RBAC_PERM_COMMAND_TICKET_BUG_VIEW, true, &HandleTicketGetByIdCommand<BugTicket>, "" },
379  };
380  static std::vector<ChatCommand> ticketComplaintCommandTable =
381  {
382  { "assign", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_ASSIGN, true, &HandleTicketAssignToCommand<ComplaintTicket>, "" },
383  { "close", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_CLOSE, true, &HandleTicketCloseByIdCommand<ComplaintTicket>, "" },
384  { "closedlist", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_CLOSEDLIST, true, &HandleTicketListClosedCommand<ComplaintTicket>, "" },
385  { "comment", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_COMMENT, true, &HandleTicketCommentCommand<ComplaintTicket>, "" },
386  { "delete", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_DELETE, true, &HandleTicketDeleteByIdCommand<ComplaintTicket>, "" },
387  { "list", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_LIST, true, &HandleTicketListCommand<ComplaintTicket>, "" },
388  { "unassign", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_UNASSIGN, true, &HandleTicketUnAssignCommand<ComplaintTicket>, "" },
389  { "view", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT_VIEW, true, &HandleTicketGetByIdCommand<ComplaintTicket>, "" },
390  };
391  static std::vector<ChatCommand> ticketSuggestionCommandTable =
392  {
393  { "assign", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_ASSIGN, true, &HandleTicketAssignToCommand<SuggestionTicket>, "" },
394  { "close", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_CLOSE, true, &HandleTicketCloseByIdCommand<SuggestionTicket>, "" },
395  { "closedlist", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_CLOSEDLIST, true, &HandleTicketListClosedCommand<SuggestionTicket>, "" },
396  { "comment", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_COMMENT, true, &HandleTicketCommentCommand<SuggestionTicket>, "" },
397  { "delete", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_DELETE, true, &HandleTicketDeleteByIdCommand<SuggestionTicket>, "" },
398  { "list", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_LIST, true, &HandleTicketListCommand<SuggestionTicket>, "" },
399  { "unassign", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_UNASSIGN, true, &HandleTicketUnAssignCommand<SuggestionTicket>, "" },
400  { "view", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION_VIEW, true, &HandleTicketGetByIdCommand<SuggestionTicket>, "" },
401  };
402  static std::vector<ChatCommand> ticketResetCommandTable =
403  {
405  { "bug", rbac::RBAC_PERM_COMMAND_TICKET_RESET_BUG, true, &HandleTicketResetCommand<BugTicket>, "" },
406  { "complaint", rbac::RBAC_PERM_COMMAND_TICKET_RESET_COMPLAINT, true, &HandleTicketResetCommand<ComplaintTicket>, "" },
407  { "suggestion", rbac::RBAC_PERM_COMMAND_TICKET_RESET_SUGGESTION, true, &HandleTicketResetCommand<SuggestionTicket>, "" },
408  };
409  static std::vector<ChatCommand> ticketCommandTable =
410  {
411  { "bug", rbac::RBAC_PERM_COMMAND_TICKET_BUG, true, NULL, "", ticketBugCommandTable },
412  { "complaint", rbac::RBAC_PERM_COMMAND_TICKET_COMPLAINT, true, NULL, "", ticketComplaintCommandTable },
413  { "reset", rbac::RBAC_PERM_COMMAND_TICKET_RESET, true, NULL, "", ticketResetCommandTable },
414  { "suggestion", rbac::RBAC_PERM_COMMAND_TICKET_SUGGESTION, true, NULL, "", ticketSuggestionCommandTable },
416  };
417  static std::vector<ChatCommand> commandTable =
418  {
419  { "ticket", rbac::RBAC_PERM_COMMAND_TICKET, false, NULL, "", ticketCommandTable },
420  };
421  return commandTable;
422 }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:649
static bool HandleTicketResetAllCommand(ChatHandler *handler, char const *)
Definition: cs_ticket.cpp:67
static bool HandleToggleGMTicketSystem(ChatHandler *handler, char const *)
Definition: cs_ticket.cpp:84

+ Here is the call graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketAssignToCommand ( ChatHandler handler,
char const args 
)
static

Console can override though

103 {
104  if (!*args)
105  return false;
106 
107  char* ticketIdStr = strtok((char*)args, " ");
108  uint32 ticketId = atoi(ticketIdStr);
109 
110  char* targetStr = strtok(NULL, " ");
111  if (!targetStr)
112  return false;
113 
114  std::string target(targetStr);
115  if (!normalizePlayerName(target))
116  return false;
117 
118  T* ticket = sSupportMgr->GetTicket<T>(ticketId);
119  if (!ticket || ticket->IsClosed())
120  {
122  return true;
123  }
124 
125  ObjectGuid targetGuid = ObjectMgr::GetPlayerGUIDByName(target);
126  uint32 accountId = ObjectMgr::GetPlayerAccountIdByGUID(targetGuid);
127  // Target must exist and have administrative rights
129  {
131  return true;
132  }
133 
134  // If already assigned, leave
135  if (ticket->IsAssignedTo(targetGuid))
136  {
137  handler->PSendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_B, ticket->GetId());
138  return true;
139  }
140 
141  // If assigned to different player other than current, leave
143  Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
144  if (player && ticket->IsAssignedNotTo(player->GetGUID()))
145  {
146  handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target.c_str());
147  return true;
148  }
149 
150  // Assign ticket
151  ticket->SetAssignedTo(targetGuid);
152 
153  ticket->SaveToDB();
154 
155  std::string msg = ticket->FormatViewMessageString(*handler, NULL, target.c_str(), NULL, NULL);
156  handler->SendGlobalGMSysMessage(msg.c_str());
157  return true;
158 }
uint32 Realm
Definition: Realm.h:53
static bool HasPermission(uint32 accountId, uint32 permission, uint32 realmId)
Definition: AccountMgr.cpp:533
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:207
Realm realm
Definition: World.cpp:3485
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:1048
Definition: Language.h:1049
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
Battlenet::RealmHandle Id
Definition: Realm.h:86
static ObjectGuid GetPlayerGUIDByName(std::string const &name)
Definition: ObjectMgr.cpp:2247
uint32_t uint32
Definition: Define.h:150
#define sSupportMgr
Definition: SupportMgr.h:296
Definition: Language.h:1045
WorldSession * GetSession()
Definition: Chat.h:59
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
Definition: Language.h:1043
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketCloseByIdCommand ( ChatHandler handler,
char const args 
)
static
164 {
165  if (!*args)
166  return false;
167 
168  uint32 ticketId = atoi(args);
169  T* ticket = sSupportMgr->GetTicket<T>(ticketId);
170  if (!ticket || ticket->IsClosed())
171  {
173  return true;
174  }
175 
176  // Ticket should be assigned to the player who tries to close it.
177  // Console can override though
178  Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
179  if (player && ticket->IsAssignedNotTo(player->GetGUID()))
180  {
181  handler->PSendSysMessage(LANG_COMMAND_TICKETCANNOTCLOSE, ticket->GetId());
182  return true;
183  }
184 
185  ObjectGuid closedByGuid;
186  if (player)
187  closedByGuid = player->GetGUID();
188  else
189  closedByGuid.SetRawValue(0, uint64(-1));
190 
191  sSupportMgr->CloseTicket<T>(ticket->GetId(), closedByGuid);
192 
193  std::string msg = ticket->FormatViewMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL);
194  handler->SendGlobalGMSysMessage(msg.c_str());
195 
196  return true;
197 }
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:207
arena_t NULL
Definition: jemalloc_internal.h:624
uint64_t uint64
Definition: g3dmath.h:170
Player * GetPlayer() const
Definition: WorldSession.h:927
void SetRawValue(std::vector< uint8 > const &guid)
Definition: ObjectGuid.cpp:134
uint32_t uint32
Definition: Define.h:150
#define sSupportMgr
Definition: SupportMgr.h:296
Definition: Language.h:1052
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
Definition: Language.h:1043
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketCommentCommand ( ChatHandler handler,
char const args 
)
static

Console excluded

201 {
202  if (!*args)
203  return false;
204 
205  char* ticketIdStr = strtok((char*)args, " ");
206  uint32 ticketId = atoi(ticketIdStr);
207 
208  char* comment = strtok(NULL, "\n");
209  if (!comment)
210  return false;
211 
212  T* ticket = sSupportMgr->GetTicket<T>(ticketId);
213  if (!ticket || ticket->IsClosed())
214  {
216  return true;
217  }
218 
219  // Cannot comment ticket assigned to someone else
221  Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
222  if (player && ticket->IsAssignedNotTo(player->GetGUID()))
223  {
224  handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId());
225  return true;
226  }
227 
228  ticket->SetComment(comment);
229  ticket->SaveToDB();
230  sSupportMgr->UpdateLastChange();
231 
232  std::string msg = ticket->FormatViewMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), NULL, NULL);
233  msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName().c_str() : "Console", comment);
234  handler->SendGlobalGMSysMessage(msg.c_str());
235 
236  return true;
237 }
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:207
std::string PGetParseString(uint32 entry, Args &&...args) const
Definition: Chat.h:84
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32_t uint32
Definition: Define.h:150
#define sSupportMgr
Definition: SupportMgr.h:296
Definition: Language.h:1045
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Language.h:1043
Definition: Language.h:1059

+ Here is the call graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketDeleteByIdCommand ( ChatHandler handler,
char const args 
)
static
255 {
256  if (!*args)
257  return false;
258 
259  uint32 ticketId = atoi(args);
260  T* ticket = sSupportMgr->GetTicket<T>(ticketId);
261  if (!ticket)
262  {
264  return true;
265  }
266 
267  if (!ticket->IsClosed())
268  {
270  return true;
271  }
272 
273  std::string msg = ticket->FormatViewMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console");
274  handler->SendGlobalGMSysMessage(msg.c_str());
275 
276  sSupportMgr->RemoveTicket<T>(ticket->GetId());
277 
278  return true;
279 }
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:207
Definition: Language.h:1044
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32_t uint32
Definition: Define.h:150
#define sSupportMgr
Definition: SupportMgr.h:296
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:1043
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketGetByIdCommand ( ChatHandler handler,
char const args 
)
static
351 {
352  if (!*args)
353  return false;
354 
355  uint32 ticketId = atoi(args);
356  T* ticket = sSupportMgr->GetTicket<T>(ticketId);
357  if (!ticket || ticket->IsClosed())
358  {
360  return true;
361  }
362 
363  handler->SendSysMessage(ticket->FormatViewMessageString(*handler, true).c_str());
364  return true;
365 }
uint32_t uint32
Definition: Define.h:150
#define sSupportMgr
Definition: SupportMgr.h:296
Definition: Language.h:1043
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketListClosedCommand ( ChatHandler handler,
char const  
)
static
248 {
249  sSupportMgr->ShowClosedList<T>(*handler);
250  return true;
251 }
#define sSupportMgr
Definition: SupportMgr.h:296
template<typename T >
bool ticket_commandscript::HandleTicketListCommand ( ChatHandler handler,
char const  
)
static
241 {
242  sSupportMgr->ShowList<T>(*handler);
243  return true;
244 }
#define sSupportMgr
Definition: SupportMgr.h:296
static bool ticket_commandscript::HandleTicketResetAllCommand ( ChatHandler handler,
char const  
)
inlinestatic
68  {
69  if (sSupportMgr->GetOpenTicketCount<BugTicket>() || sSupportMgr->GetOpenTicketCount<ComplaintTicket>() || sSupportMgr->GetOpenTicketCount<SuggestionTicket>())
70  {
72  return true;
73  }
74  else
75  {
76  sSupportMgr->ResetTickets<BugTicket>();
77  sSupportMgr->ResetTickets<ComplaintTicket>();
78  sSupportMgr->ResetTickets<SuggestionTicket>();
80  }
81  return true;
82  }
Definition: SupportMgr.h:179
Definition: SupportMgr.h:143
Definition: Language.h:1062
Definition: SupportMgr.h:119
Definition: Language.h:1061
#define sSupportMgr
Definition: SupportMgr.h:296
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketResetCommand ( ChatHandler handler,
char const  
)
static
284 {
285  if (sSupportMgr->GetOpenTicketCount<T>())
286  {
288  return true;
289  }
290  else
291  {
292  sSupportMgr->ResetTickets<T>();
294  }
295  return true;
296 }
Definition: Language.h:1062
Definition: Language.h:1061
#define sSupportMgr
Definition: SupportMgr.h:296
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

template<typename T >
bool ticket_commandscript::HandleTicketUnAssignCommand ( ChatHandler handler,
char const args 
)
static

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

300 {
301  if (!*args)
302  return false;
303 
304  uint32 ticketId = atoi(args);
305  T* ticket = sSupportMgr->GetTicket<T>(ticketId);
306  if (!ticket || ticket->IsClosed())
307  {
309  return true;
310  }
311  // Ticket must be assigned
312  if (!ticket->IsAssigned())
313  {
314  handler->PSendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED, ticket->GetId());
315  return true;
316  }
317 
318  // Get security level of player, whom this ticket is assigned to
319  uint32 security = SEC_PLAYER;
320  Player* assignedPlayer = ticket->GetAssignedPlayer();
321  if (assignedPlayer)
322  security = assignedPlayer->GetSession()->GetSecurity();
323  else
324  {
325  ObjectGuid guid = ticket->GetAssignedToGUID();
327  security = AccountMgr::GetSecurity(accountId, realm.Id.Realm);
328  }
329 
330  // Check security
332  uint32 mySecurity = handler->GetSession() ? handler->GetSession()->GetSecurity() : SEC_CONSOLE;
333  if (security > mySecurity)
334  {
336  return true;
337  }
338 
339  std::string assignedTo = ticket->GetAssignedToName(); // copy assignedto name because we need it after the ticket has been unnassigned
340  ticket->SetUnassigned();
341  ticket->SaveToDB();
342 
343  std::string msg = ticket->FormatViewMessageString(*handler, NULL, assignedTo.c_str(), handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", NULL);
344  handler->SendGlobalGMSysMessage(msg.c_str());
345 
346  return true;
347 }
uint32 Realm
Definition: Realm.h:53
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:207
AccountTypes GetSecurity() const
Definition: WorldSession.h:921
Realm realm
Definition: World.cpp:3485
Definition: Common.h:108
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:1050
Player * GetPlayer() const
Definition: WorldSession.h:927
static uint32 GetSecurity(uint32 accountId)
Definition: AccountMgr.cpp:284
Battlenet::RealmHandle Id
Definition: Realm.h:86
uint32_t uint32
Definition: Define.h:150
Definition: Common.h:112
#define sSupportMgr
Definition: SupportMgr.h:296
WorldSession * GetSession()
Definition: Chat.h:59
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
Definition: Language.h:1051
Definition: Language.h:1043
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

static bool ticket_commandscript::HandleToggleGMTicketSystem ( ChatHandler handler,
char const  
)
inlinestatic
85  {
86  if (!sWorld->getBoolConfig(CONFIG_SUPPORT_TICKETS_ENABLED))
87  {
89  return true;
90  }
91 
92  bool status = !sSupportMgr->GetSupportSystemStatus();
93  sSupportMgr->SetSupportSystemStatus(status);
95  return true;
96  }
Definition: World.h:155
#define sWorld
Definition: World.h:887
Definition: Language.h:993
#define sSupportMgr
Definition: SupportMgr.h:296
Definition: Language.h:937
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Language.h:938
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: