chronos
view release on metacpan or search on metacpan
Chronos/Chronos/Action/UserPrefs.pm view on Meta::CPAN
# Copyright (C) 2002 Linux Québec Technologies
#
# This file is part of Chronos.
#
# Chronos is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Chronos is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
package Chronos::Action::UserPrefs;
use strict;
use Chronos::Action;
use Chronos::Static qw(userstring);
use HTML::Entities;
our @ISA = qw(Chronos::Action);
sub authorized {
return 1;
}
sub header {
return '';
}
sub content {
my $self = shift;
my $chronos = $self->{parent};
my $text = $chronos->gettext;
my $dbh = $chronos->dbh;
my $user = $chronos->user;
my $user_quoted = $dbh->quote($user);
my $uri = $chronos->{r}->uri;
my $minimonth = $chronos->minimonth( $chronos->day );
my ( $lang, $public_writable, $public_readable, $name, $email ) =
$dbh->selectrow_array(
"SELECT lang, public_writable, public_readable, name, email FROM user WHERE user = $user_quoted"
);
$name = encode_entities($name);
$email = encode_entities($email);
my $return = <<EOF;
<table style="border:none">
<tr>
<td valign=top>$minimonth</td>
<td valign=top width="100%">
<form method=post action="$uri">
<input type=hidden name=action value=saveuserprefs>
<table class=editevent>
<tr><th colspan=2>$text->{userprefs}</th></tr>
<tr>
<td><img src="/chronos_static/name.png"> $text->{name}</td>
<td><input name=name value="$name"></td>
</tr>
<tr>
<td><img src="/chronos_static/email.png"> $text->{email}</td>
<td><input name=email value="$email"></td>
</tr>
<tr>
<td><img src="/chronos_static/password.png"> $text->{password}</td>
<td><input type=password name=password></td>
</tr>
<tr>
<td><img src="/chronos_static/lang.png"> $text->{lang}</td>
<td><select name=lang>
EOF
my @langs = grep { -f } </usr/share/chronos/lang/*>;
s|/usr/share/chronos/lang/|| foreach @langs;
my %langs = map { $_ => $text->{$_} } @langs;
foreach ( sort { $langs{$a} cmp $langs{$b} } keys %langs ) {
my $selected = $_ eq $lang ? 'selected' : '';
$return .= <<EOF;
<option value="$_" $selected>$langs{$_}</option>
EOF
}
$return .= <<EOF;
</select></td>
</tr>
<tr>
<td>$text->{agendatype}</td>
<td><select name=agendatype>
EOF
my %agendatype;
if ( $public_writable eq 'Y' and $public_readable eq 'Y' ) {
$agendatype{publicrw} = 'selected';
} elsif ( $public_readable eq 'Y' ) {
$agendatype{publicr} = 'selected';
} else {
$agendatype{private} = 'selected';
}
$return .= <<EOF;
<option value="publicrw" $agendatype{publicrw}>$text->{publicrw}</option>
<option value="publicr" $agendatype{publicr}>$text->{publicr}</option>
<option value="private" $agendatype{private}>$text->{private}</option>
</select></td>
</tr>
<tr>
<td valign=top>$text->{indivpriv}</td>
<td>
<table style="border:none; background-color:white">
EOF
my $sth_user =
$dbh->prepare(
"SELECT user, name, email FROM user WHERE user != $user_quoted ORDER BY name, user"
);
my $sth_acl =
( run in 0.730 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )