mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-01 07:27:40 -08:00
fixed #43: add delete button to local dir view in deck storage tab and in remote dir view in replays tab
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "pb/command_replay_list.pb.h"
|
||||
#include "pb/command_replay_download.pb.h"
|
||||
#include "pb/command_replay_modify_match.pb.h"
|
||||
#include "pb/command_replay_delete_match.pb.h"
|
||||
#include "pb/event_connection_closed.pb.h"
|
||||
#include "pb/event_server_message.pb.h"
|
||||
#include "pb/event_server_identification.pb.h"
|
||||
@@ -480,7 +481,7 @@ Response::ResponseCode ServerSocketInterface::cmdReplayList(const Command_Replay
|
||||
|
||||
servatrice->dbMutex.lock();
|
||||
QSqlQuery query1;
|
||||
query1.prepare("select a.id_game, a.replay_name, b.room_name, b.time_started, b.time_finished, b.descr, a.do_not_hide from cockatrice_replays_access a left join cockatrice_games b on b.id = a.id_game where a.id_player = :id_player and (a.do_not_hide = 1 or date_add(b.time_started, interval 14 day) > now())");
|
||||
query1.prepare("select a.id_game, a.replay_name, b.room_name, b.time_started, b.time_finished, b.descr, a.do_not_hide from cockatrice_replays_access a left join cockatrice_games b on b.id = a.id_game where a.id_player = :id_player and (a.do_not_hide = 1 or date_add(b.time_started, interval 7 day) > now())");
|
||||
query1.bindValue(":id_player", userInfo->id());
|
||||
servatrice->execSqlQuery(query1);
|
||||
while (query1.next()) {
|
||||
@@ -570,6 +571,22 @@ Response::ResponseCode ServerSocketInterface::cmdReplayModifyMatch(const Command
|
||||
return servatrice->execSqlQuery(query1) ? Response::RespOk : Response::RespNameNotFound;
|
||||
}
|
||||
|
||||
Response::ResponseCode ServerSocketInterface::cmdReplayDeleteMatch(const Command_ReplayDeleteMatch &cmd, ResponseContainer & /*rc*/)
|
||||
{
|
||||
if (authState != PasswordRight)
|
||||
return Response::RespFunctionNotAllowed;
|
||||
|
||||
QMutexLocker dbLocker(&servatrice->dbMutex);
|
||||
|
||||
QSqlQuery query1;
|
||||
query1.prepare("delete from " + servatrice->getDbPrefix() + "_replays_access where id_player = :id_player and id_game = :id_game");
|
||||
query1.bindValue(":id_player", userInfo->id());
|
||||
query1.bindValue(":id_game", cmd.game_id());
|
||||
|
||||
servatrice->execSqlQuery(query1);
|
||||
return query1.numRowsAffected() > 0 ? Response::RespOk: Response::RespNameNotFound;
|
||||
}
|
||||
|
||||
|
||||
// MODERATOR FUNCTIONS.
|
||||
// May be called by admins and moderators. Permission is checked by the calling function.
|
||||
|
||||
Reference in New Issue
Block a user