% if ($ms_count){
% my $first = $ms_nrec + 1;
% my $msg = ($versao == 1) ? "mensagem $first de $ms_count": "message $first of $ms_count";
% #------- nav bar -----------------------------------------------------
<& /mensagens/templates/nav_bar.html, section=>$section, msg=>$msg, prev=>$prev,next=>$next,ms_nrec=>$ms_nrec,ms_count=>$ms_count, pos => 'top' &>
% }
<& /mensagens/templates/mensagem.html, rtitulo => $rtitulo, sender=>$sender, email=>$email, datestr=>$datestr, rmensagem=>$rmensagem &>
% #------- nav bar -----------------------------------------------------
<& /mensagens/templates/nav_bar.html, section=>$section, prev=>$prev,next=>$next,ms_nrec=>$ms_nrec,ms_count=>$ms_count, pos => 'bot' &>
<%args>
$msgid=>undef
$painel=>0
$ms_nrec=>undef
$ms_count=>undef
$prev=>undef
$next=>undef
$section=>undef
$ms_query=>undef
$ms_date=>undef
%args>
<%init>
# definir contexto da mensagem
$section = $m->top_args->{'section'} unless $section;
$ms_nrec = $m->top_args->{'ms_nrec'} unless $ms_nrec;
$ms_count = $m->top_args->{'ms_count'} unless $ms_count;
if (!$prev && !$next){
$ms_query = $m->top_args->{'ms_query'} unless $ms_query;
$ms_date = $m->top_args->{'ms_date'} unless $ms_date;
if (!$ms_date){
my $ms_year = $m->top_args->{'ms_year'};
my $ms_month = $m->top_args->{'ms_month'};
my $ms_day = $m->top_args->{'ms_day'};
if ($ms_month && $ms_year){
$ms_date = $ms_year.'-'.$ms_month.'-'.$ms_day;
}elsif($ms_year){
$ms_date = $ms_year . "-";
}
}
if ($ms_count > 1){
my $first = ($ms_nrec > 0) ? $ms_nrec-1:0;
my $last = (($ms_nrec+1) < $ms_count) ? $ms_nrec+1:0;
($ms_count, my $set) = $m->comp("/_shared/procs/mensagens/get_msgset.m",ms_nrec=>$first, ms_query=>$ms_query, ms_date=>$ms_date, maxhits=>10, subset=>1); # context from top args
$prev = $$set[0][0] if ($ms_nrec > 0);
if ($last){
$next = ($ms_nrec > 0) ? $$set[2][0]:$$set[1][0];
}
}
}
# ler mensagem da base de dados
my $dbh = $m->comp("/_shared/procs/utils/dbi_connect.m");
my ($rcdutilizador, $first, $last, $email, $rdata, $rtitulo, $rmensagem) = $dbh->selectrow_array("select rcdutilizador, rfirst, rlast, remail, rdata, rtitulo, rmensagem from tmensagens, twebusers where tmensagens.id='$msgid' and twebusers.id=rcdutilizador");
my $sender = "$first $last";
$rdata =~ m/(\d+-\d+-\d+) (\d+:\d+:\d+)/;
my $datestr = $m->comp("/_shared/procs/utils/getdatestr.m", data=>$1, hora=>$2, painel=>$painel);
$rmensagem =~ s/\n/
\n/g;
%init>
<%method set_painel>
# empty
%method>