removed locale saving in database - get locale from browser

git-svn-id: http://yolanda.mister-muffin.de/svn@316 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2008-04-23 07:08:14 +00:00
parent 0dcb16a8ec
commit f15eaf0887
6 changed files with 8 additions and 46 deletions

View file

@ -6,13 +6,13 @@ sub get_userinfo_from_sid
my ($sid) = @_; my ($sid) = @_;
#prepare query #prepare query
my $sth = $dbh->prepare(qq{select id, username, locale, pagesize from users where sid = ?}) or die $dbh->errstr; my $sth = $dbh->prepare(qq{select id, username, pagesize from users where sid = ?}) or die $dbh->errstr;
#execute it #execute it
$sth->execute($sid) or die $dbh->errstr; $sth->execute($sid) or die $dbh->errstr;
#save the resulting username #save the resulting username
($userinfo->{'id'}, $userinfo->{'username'}, $userinfo->{'locale'}, $userinfo->{'pagesize'}) = $sth->fetchrow_array(); ($userinfo->{'id'}, $userinfo->{'username'}, $userinfo->{'pagesize'}) = $sth->fetchrow_array();
#finish query #finish query
$sth->finish() or die $dbh->errstr; $sth->finish() or die $dbh->errstr;
@ -26,20 +26,11 @@ sub get_page_array
#get parameters #get parameters
my (@userinfo) = @_; my (@userinfo) = @_;
#if user is logged in, use his locale setting and check for new upload status
if($userinfo->{'username'})
{
$page->{'locale'} = $userinfo->{'locale'};
}
#else get the locale from the http server variable
else
{
($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/; ($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
unless($page->{'locale'}) if (!$page->{'locale'})
{ {
$page->{'locale'} = "en_us"; $page->{'locale'} = "en_us";
} }
}
$page->{'username'} = $userinfo->{'username'}; $page->{'username'} = $userinfo->{'username'};
$page->{'xmlns:dc'} = $config->{"xml_namespace_dc"}; $page->{'xmlns:dc'} = $config->{"xml_namespace_dc"};

View file

@ -39,7 +39,6 @@ $dbh->do(qq{create table
password char(41) not null, password char(41) not null,
sid char(32) not null, sid char(32) not null,
timestamp bigint not null, timestamp bigint not null,
locale varchar(10) not null,
pagesize tinyint unsigned default 5, pagesize tinyint unsigned default 5,
primary key (id) primary key (id)
) )

View file

@ -205,7 +205,6 @@
<!-- settings page --> <!-- settings page -->
<string id="settings_heading">account settings for </string> <string id="settings_heading">account settings for </string>
<string id="settings_instruction_locale">locale</string>
<string id="settings_instruction_pagesize">choose pagesize</string> <string id="settings_instruction_pagesize">choose pagesize</string>
<!-- rss feed --> <!-- rss feed -->

View file

@ -39,8 +39,8 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
else else
{ {
#insert new user #insert new user
$dbh->do(qq{insert into users (username, password, timestamp, locale) values ( ?, password( ? ), unix_timestamp(), ?)}, undef, $dbh->do(qq{insert into users (username, password, timestamp) values ( ?, password( ? ), unix_timestamp(), ?)}, undef,
$query->param("user"), $query->param("pass"), $page->{'locale'}) or die $dbh->errstr; $query->param("user"), $query->param("pass")) or die $dbh->errstr;
print $query->redirect("index.pl?information=information_registered"); print $query->redirect("index.pl?information=information_registered");
} }

View file

@ -11,7 +11,7 @@ if($userinfo->{'username'})
{ {
if($query->param('submit')) if($query->param('submit'))
{ {
$dbh->do(qq{update users set locale = ?, pagesize = ? where id = ?}, undef, $query->param('locale'), $query->param('pagesize'), $userinfo->{'id'} ) or die $dbh->errstr; $dbh->do(qq{update users set pagesize = ? where id = ?}, undef, $query->param('pagesize'), $userinfo->{'id'} ) or die $dbh->errstr;
$page->{'message'}->{'type'} = "information"; $page->{'message'}->{'type'} = "information";
$page->{'message'}->{'text'} = "information_settings_changed"; $page->{'message'}->{'text'} = "information_settings_changed";
@ -24,7 +24,6 @@ if($userinfo->{'username'})
if($userinfo->{'username'}) if($userinfo->{'username'})
{ {
$page->{'settings'}->{'locale'} = $userinfo->{'locale'};
$page->{'settings'}->{'pagesize'} = $userinfo->{'pagesize'}; $page->{'settings'}->{'pagesize'} = $userinfo->{'pagesize'};
} }
else else

View file

@ -21,32 +21,6 @@
<xsl:value-of select="$site_strings[@id='path_settings']" /> <xsl:value-of select="$site_strings[@id='path_settings']" />
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="$locale_strings[@id='settings_instruction_locale']" />
<br />
<select name="locale" size="2">
<option value="en-us">
<xsl:if test="//settings/@locale='en-us'">
<xsl:attribute name="selected">
selected
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$locale_strings[@id='language_en-us']" />
</option>
<option value="de-de">
<xsl:if test="//settings/@locale='de-de'">
<xsl:attribute name="selected">
selected
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$locale_strings[@id='language_de-de']" />
</option>
</select>
<br />
<xsl:value-of select="$locale_strings[@id='settings_instruction_pagesize']" /> <xsl:value-of select="$locale_strings[@id='settings_instruction_pagesize']" />
<br /> <br />