1
0
mirror of https://github.com/dani/vroom.git synced 2024-06-17 19:59:13 +02:00

Add a new generic modify_room helper

This commit is contained in:
Daniel Berteaud 2014-10-14 19:26:10 +02:00
parent d7175b70b6
commit 798102117e

View File

@ -155,6 +155,33 @@ helper get_room_by_id => sub {
return $sth->fetchall_hashref('id')->{$id};
};
# Update a room, take a room object as a hashref
helper modify_room => sub {
my $self = shift;
my ($room) = @_;
# TODO: input validation
my $sth = eval {
$self->db->prepare('UPDATE `rooms`
SET `owner`=?,
`last_activity`=CONVERT_TZ(NOW(), @@session.time_zone, \'+00:00\'),
`locked`=?,
`ask_for_name`=?,
`join_password`=?,
`owner_password`=?,
`persistent`=?');
} || return undef;
$sth->execute(
$room->{owner},
$room->{locked},
$room->{ask_for_name},
$room->{join_password},
$room->{owner_password},
$room->{persistent}
) || return undef;
$self->app->log->info("Room " . $room->{name} ." modified by " . $self->session('name'));
return 1;
};
# Lock/unlock a room, to prevent new participants
# Takes two arg: room name and 1 for lock, 0 for unlock
helper lock_room => sub {