Add a deleteRoom action handler

And adapt the goodbye page to allow empty room name
master
Daniel Berteaud 11 years ago
parent 192521e8c7
commit 35cc1dd3a2
  1. 29
      public/vroom.pl

@ -384,7 +384,7 @@ helper delete_room => sub {
$ec->delete_group($data->{etherpad_group}); $ec->delete_group($data->{etherpad_group});
} }
foreach my $table (qw(participants notifications invitations rooms)){ foreach my $table (qw(participants notifications invitations rooms)){
$sth = eval { my $sth = eval {
$self->db->prepare("DELETE FROM `$table` WHERE `id`=?;"); $self->db->prepare("DELETE FROM `$table` WHERE `id`=?;");
} || return undef; } || return undef;
$sth->execute($data->{id}) || return undef; $sth->execute($data->{id}) || return undef;
@ -713,14 +713,9 @@ get 'feedback_thanks' => 'feedback_thanks';
get '/goodby/(:room)' => sub { get '/goodby/(:room)' => sub {
my $self = shift; my $self = shift;
my $room = $self->stash('room'); my $room = $self->stash('room');
if (!$self->get_room($room)){ if ($self->get_room($room)){
return $self->render('error', $self->remove_participant($room,$self->session('name'));
err => 'ERROR_ROOM_s_DOESNT_EXIST',
msg => sprintf ($self->l("ERROR_ROOM_s_DOESNT_EXIST"), $room),
room => $room
);
} }
$self->remove_participant($room,$self->session('name'));
$self->logout($room); $self->logout($room);
} => 'goodby'; } => 'goodby';
@ -1317,6 +1312,24 @@ post '/action' => sub {
} }
); );
} }
# delete the room
elsif ($action eq 'deleteRoom'){
my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED');
if ($self->session($room)->{role} ne 'owner'){
$msg = $self->l('NOT_ALLOWED');
}
elsif ($self->delete_room($room)){
$msg = $self->l('ROOM_DELETED');
$status = 'success';
}
return $self->render(
json => {
msg => $msg,
status => $status
}
);
}
}; };
# use the templates defined in the config # use the templates defined in the config

Loading…
Cancel
Save