Implement action handler for ask_for_name

master
Daniel Berteaud 11 years ago
parent 42b9dc8a1c
commit b70b8f5336
  1. 35
      public/vroom.pl

@ -384,6 +384,18 @@ helper remove_notification => sub {
return 1; return 1;
}; };
# Set/unset ask for name
helper ask_for_name => sub {
my $self = shift;
my ($room,$set) = @_;
my $data = $self->get_room($room);
return undef unless ($data);
my $sth = eval { $self->db->prepare("UPDATE rooms SET ask_for_name=? WHERE name=?") } || return undef;
$sth->execute($set,$room) || return undef;
return 1;
};
# Route / to the index page # Route / to the index page
any '/' => 'index'; any '/' => 'index';
@ -844,6 +856,29 @@ post '/action' => sub {
} }
); );
} }
# Set/unset askForName
elsif ($action eq 'askForName'){
my $type = $self->param('type');
my $status = 'error';
my $msg = $self->l('ERROR_OCCURED');
if ($self->session($room)->{role} ne 'owner'){
$msg = $self->l('NOT_ALLOWED');
}
elsif($type eq 'set' && $self->ask_for_name($room,'1')){
$status = 'success';
$msg = $self->l('NAME_WILL_BE_ASKED');
}
elsif($type eq 'unset' && $self->ask_for_name($room,'0')){
$status = 'success';
$msg = $self->l('NAME_WONT_BE_ASKED');
}
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