Fixed server group copy
This commit is contained in:
@@ -309,7 +309,7 @@ std::shared_ptr<Group> GroupManager::createGroup(GroupTarget target, GroupType t
|
||||
return group;
|
||||
}
|
||||
|
||||
bool GroupManager::copyGroup(std::shared_ptr<Group> group, GroupType type, std::string name, ServerId targetServerId) {
|
||||
GroupId GroupManager::copyGroup(std::shared_ptr<Group> group, GroupType type, std::string name, ServerId targetServerId) {
|
||||
auto group_server = group->handle->getServerId();
|
||||
auto groupId = generateGroupId(this->sql);
|
||||
|
||||
@@ -331,14 +331,14 @@ bool GroupManager::copyGroup(std::shared_ptr<Group> group, GroupType type, std::
|
||||
this->loadGroupFormDatabase(groupId);
|
||||
else if(this->root)
|
||||
this->root->loadGroupFormDatabase(groupId);
|
||||
return true;
|
||||
return groupId;
|
||||
}
|
||||
|
||||
bool GroupManager::copyGroupPermissions(const shared_ptr<Group> &source, const shared_ptr<Group> &target) {
|
||||
auto targetServer = target->handle->getServerId();
|
||||
auto sourceServer = source->handle->getServerId();
|
||||
|
||||
auto res = sql::command(this->sql, "DELETE FROM `permissions` WHERE `serverId` = :sid AND `type` = :type AND `id` = :id", variable{":sid", this->getServerId()}, variable{":type", SQL_PERM_GROUP}, variable{":id", target->groupId()}).execute();
|
||||
auto res = sql::command(this->sql, "DELETE FROM `permissions` WHERE `serverId` = :sid AND `type` = :type AND `id` = :id", variable{":sid", targetServer}, variable{":type", SQL_PERM_GROUP}, variable{":id", target->groupId()}).execute();
|
||||
LOG_SQL_CMD(res);
|
||||
|
||||
res = sql::command(this->sql, "INSERT INTO `permissions` (`serverId`, `type`, `id`, `channelId`, `permId`, `value`, `grant`) SELECT :tsid AS `serverId`, `type`, :target AS `id`, 0 AS `channelId`, `permId`, `value`,`grant` FROM `permissions` WHERE `serverId` = :ssid AND `type` = :type AND `id` = :source",
|
||||
|
||||
Reference in New Issue
Block a user