39 " cr.corporationName "
40 " FROM chrCharacters AS ch"
41 " LEFT JOIN crpCorporation AS cr USING (corporationID) "
42 " WHERE ch.characterID = %u ", charID))
50 _log(SERVICE__ERROR,
"CharID %u isn't present in the database", charID);
54 names.push_back(row.
GetText(0));
55 names.push_back(row.
GetText(1));
77 if ( ++currentChannelID < row.
GetInt( 0 ) )
78 return currentChannelID;
83 return currentChannelID;
89 std::string new_password =
"NULL";
95 " INSERT INTO channels"
96 " (channelID, ownerID, displayName, motd, comparisonKey, memberless, password, mailingList, cspa)"
97 " VALUES (%i, %u, '%s', '%s', '%s', %u, '%s', %u, %u)"
98 " ON DUPLICATE KEY UPDATE"
99 " ownerID=VALUES(ownerID),"
100 " displayName=VALUES(displayName),"
101 " motd=VALUES(motd),"
102 " comparisonKey=VALUES(comparisonKey),"
103 " memberless=VALUES(memberless),"
104 " password=VALUES(password),"
105 " mailingList=VALUES(mailingList),"
106 " cspa=VALUES(cspa)",
113 new_password.c_str(),
117 _log(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
124 " INSERT INTO channelChars "
125 " (channelID, corpID, charID, allianceID, role, extra) "
126 " VALUES (%i, %i, %i, %i, %li, 0) ",
133 sDatabase.RunQuery(err,
"DELETE FROM channels WHERE channelID=%i", channelID);
139 sDatabase.RunQuery(err,
"DELETE FROM channelChars WHERE channelID=%i AND charID=%u", channelID, charID );
154 " WHERE displayName = upper('%s')", name.c_str()))
180 " WHERE channelID = %i", channelID ))
206 " FROM channelChars "
207 " WHERE channelID = %i AND charID = %u", channelID, charID ))
224 if (!
sDatabase.RunQuery(res,
"SELECT channelID FROM channels WHERE displayName RLIKE '%s'", name.c_str())) {
231 _log(SERVICE__ERROR,
"Channel named '%s' isn't present in the database", name.c_str() );
241 std::string & motd,
uint32 & ownerid, std::string & compkey,
242 bool & memberless, std::string & password,
bool & maillist,
259 " WHERE channelID = %i", channelID))
269 _log(SERVICE__ERROR,
"Channel %i isn't present in the database", channelID );
286 std::vector<std::string> & MOTDs, std::vector<unsigned long> & ownerids, std::vector<std::string> & compkeys,
287 std::vector<int> & memberless, std::vector<std::string> & passwords, std::vector<int> & maillists,
288 std::vector<int> & cspas,
int & channelCount)
308 " WHERE channelID = ANY ("
309 " SELECT channelID FROM channelChars WHERE charID = %u )", charID))
324 ids.push_back(row.
GetInt(0));
327 ownerids.push_back(row.
GetUInt(3));
328 compkeys.push_back((row.
GetText(4) == NULL ?
"" : row.
GetText(4)));
329 memberless.push_back(row.
GetUInt(5));
330 passwords.push_back((row.
GetText(6) == NULL ?
"" : row.
GetText(6)));
331 maillists.push_back(row.
GetUInt(7));
332 cspas.push_back(row.
GetUInt(8));
340 channelCount = rowCount;
347 if (!
sDatabase.RunQuery(res,
"SELECT displayName, motd FROM channels WHERE channelID = %i ", channelID)) {
368 if(!
sDatabase.RunQuery(res,
"SELECT channelID FROM channels WHERE comparisonKey RLIKE '%s'", compkey.c_str())) {
369 _log(DATABASE__ERROR,
"Error in GetChannelIDFromComparisonKey query: %s", res.
error.
c_str());
375 _log(SERVICE__ERROR,
"Couldn't find %s in table channels", compkey.c_str());
384 if (!
sDatabase.RunQuery(res,
"SELECT %s FROM %s WHERE %s = %u ", column, table, key,
id)) {
391 _log(SERVICE__ERROR,
"Couldn't find %s %u in table %s", key,
id, table);
406 sDatabase.DoEscapeString(escaped, subject);
410 if (!
sDatabase.RunQueryLID(err, messageID,
411 " INSERT INTO eveMail "
412 " (channelID, senderID, subject, created) "
413 " VALUES (%u, %u, '%s', %li) ",
414 recipID, senderID, escaped.
c_str(), sentTime ))
416 _log(DATABASE__ERROR,
"Error in query, message header couldn't be saved: %s", err.
c_str());
420 _log(SERVICE__MESSAGE,
"New messageID: %u", messageID);
423 sDatabase.DoEscapeString(escaped, message);
427 " INSERT INTO eveMailDetails "
428 " (messageID, mimeTypeID, attachment) VALUES (%u, 1, '%s') ",
429 messageID, escaped.
c_str()
432 _log(DATABASE__ERROR,
"Error in query, message content couldn't be saved: %s", err.
c_str());
434 if (!
sDatabase.RunQuery(err,
"DELETE FROM `eveMail` WHERE `messageID` = %u;", messageID))
436 _log(DATABASE__ERROR,
"Failed to remove invalid header data for messgae id %u: %s", messageID, err.
c_str());
450 "SELECT channelID, messageID, senderID, subject, created, `read` "
452 " WHERE channelID=%u", recID))
469 " SELECT eveMail.messageID, eveMail.senderID, eveMail.subject, "
470 " eveMailDetails.attachment, eveMailDetails.mimeTypeID, "
471 " eveMailMimeType.mimeType, eveMailMimeType.`binary`, "
472 " eveMail.created, eveMail.channelID "
474 " LEFT JOIN eveMailDetails ON eveMailDetails.messageID = eveMail.messageID "
475 " LEFT JOIN eveMailMimeType ON eveMailMimeType.mimeTypeID = eveMailDetails.mimeTypeID "
476 " WHERE eveMail.messageID=%u AND channelID=%u",
480 _log(DATABASE__ERROR,
"Error in query: %s", result.
error.
c_str());
484 if (!result.
GetRow(row)) {
485 codelog(SERVICE__MESSAGE,
"No message with messageID %u", messageID);
489 Rsp_GetEVEMailDetails details;
490 details.messageID = row.
GetUInt(0);
491 details.senderID = row.
GetUInt(1);
492 details.subject = row.
GetText(2);
495 details.channelID = row.
GetUInt(8);
497 details.mimeTypeID = row.
GetInt(4);
498 details.mimeType = row.
GetText(5);
499 details.binary = row.
GetInt(6);
501 return details.Encode();
511 " WHERE messageID=%u", messageID
514 _log(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
527 " DELETE FROM eveMail "
528 " WHERE messageID=%u AND channelID=%u", messageID, readerID
531 _log(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
535 " DELETE FROM eveMailDetails "
536 " WHERE messageID=%u", messageID
539 _log(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
int64 GetAccountRole() const
int32 GetNextAvailableChannelID()
bool MarkMessageRead(uint32 messageID)
const char * GetText(uint32 index) const
#define _log(type, fmt,...)
bool IsChannelSubscribedByThisChar(uint32 char_ID, int32 channel_ID)
int32 GetInt(uint32 index) const
uint32 GetUInt(uint32 index) const
void DeleteChannel(int32 channelID)
void UpdateSubscription(int32 channelID, Client *pClient)
void UpdateChannelInfo(LSCChannel *channel)
void DeleteSubscription(int32 channelID, uint32 charID)
int32 GetCharacterID() const
int32 GetCorporationID() const
uint32 StoreMail(uint32 senderID, uint32 recipID, const char *subject, const char *message, int64 sentTime)
PyRep * GetMailDetails(uint32 messageID, uint32 readerID)
bool IsChannelIDAvailable(int32 channel_ID)
std::string GetPassword()
int32 GetChannelIDFromComparisonKey(std::string compkey)
int32 GetAllianceID() const
bool GetRow(DBResultRow &into)
bool GetBool(uint32 index) const
void GetChannelNames(uint32 charID, std::vector< std::string > &names)
const char * c_str() const
#define codelog(type, fmt,...)
PyObject * DBResultToRowset(DBQueryResult &result)
std::string GetDisplayName()
bool IsNull(uint32 index) const
void GetChannelSubscriptions(uint32 charID, std::vector< long > &ids, std::vector< std::string > &names, std::vector< std::string > &MOTDs, std::vector< unsigned long > &ownerids, std::vector< std::string > &compkeys, std::vector< int > &memberless, std::vector< std::string > &passwords, std::vector< int > &maillists, std::vector< int > &cspas, int &channelCount)
int32 GetChannelID(std::string &name)
bool IsChannelNameAvailable(std::string name)
static const int32 BASE_CHANNEL_ID
std::string GetComparisonKey()
void GetChannelInformation(int32 channelID, std::string &name, std::string &motd, uint32 &ownerid, std::string &compkey, bool &memberless, std::string &password, bool &maillist, uint32 &cspa)
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
bool DeleteMessage(uint32 messageID, uint32 readerID)
int64 GetInt64(uint32 index) const
std::string GetChannelName(uint32 id, const char *table, const char *column, const char *key)
static const uint32 MAX_CHANNEL_ID
bool GetChannelInfo(int32 channelID, std::string &name, std::string &motd)
PyObject * GetMailHeaders(uint32 recID)