kivitendo/bin/mozilla/login.pl @ 3ced230b
d319704a | Moritz Bunkus | #=====================================================================
|
||
# LX-Office ERP
|
||||
# Copyright (C) 2004
|
||||
# Based on SQL-Ledger Version 2.1.9
|
||||
# Web http://www.lx-office.org
|
||||
#
|
||||
######################################################################
|
||||
# SQL-Ledger Accounting
|
||||
# Copyright (c) 1998-2002
|
||||
#
|
||||
# Author: Dieter Simader
|
||||
# Email: dsimader@sql-ledger.org
|
||||
# Web: http://www.sql-ledger.org
|
||||
#
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#######################################################################
|
||||
use DBI;
|
||||
use SL::User;
|
||||
use SL::Form;
|
||||
40782548 | Moritz Bunkus | require "bin/mozilla/common.pl";
|
||
d319704a | Moritz Bunkus | $form = new Form;
|
||
$locale = new Locale $language, "login";
|
||||
# customization
|
||||
d629acd8 | Sven Schöling | if (-f "bin/mozilla/custom_$form->{script}") {
|
||
eval { require "bin/mozilla/custom_$form->{script}"; };
|
||||
d319704a | Moritz Bunkus | $form->error($@) if ($@);
|
||
}
|
||||
# per login customization
|
||||
d629acd8 | Sven Schöling | if (-f "bin/mozilla/$form->{login}_$form->{script}") {
|
||
eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
|
||||
d319704a | Moritz Bunkus | $form->error($@) if ($@);
|
||
}
|
||||
# window title bar, user info
|
||||
d1e4ee79 | Moritz Bunkus | $form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}";
|
||
d319704a | Moritz Bunkus | |||
if ($form->{action}) {
|
||||
$form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
|
||||
40782548 | Moritz Bunkus | call_sub($locale->findsub($form->{action}));
|
||
d1e4ee79 | Moritz Bunkus | |||
d319704a | Moritz Bunkus | } else {
|
||
d1e4ee79 | Moritz Bunkus | login_screen();
|
||
d319704a | Moritz Bunkus | }
|
||
1;
|
||||
sub login_screen {
|
||||
$lxdebug->enter_sub();
|
||||
b0a92688 | Sven Schöling | my ($msg) = @_;
|
||
d319704a | Moritz Bunkus | |||
if (-f "css/lx-office-erp.css") {
|
||||
$form->{stylesheet} = "lx-office-erp.css";
|
||||
}
|
||||
b0a92688 | Sven Schöling | $form->{msg} = $msg;
|
||
d319704a | Moritz Bunkus | $form->{fokus} = "loginscreen.login";
|
||
$form->header;
|
||||
d1e4ee79 | Moritz Bunkus | print $form->parse_html_template('login/login_screen');
|
||
d319704a | Moritz Bunkus | |||
$lxdebug->leave_sub();
|
||||
}
|
||||
sub login {
|
||||
$lxdebug->enter_sub();
|
||||
b0a92688 | Sven Schöling | unless ($form->{login}) {
|
||
login_screen($locale->text('You did not enter a name!'));
|
||||
exit;
|
||||
}
|
||||
d319704a | Moritz Bunkus | |||
$user = new User $memberfile, $form->{login};
|
||||
# if we get an error back, bale out
|
||||
d1e4ee79 | Moritz Bunkus | if (($result = $user->login(\%$form, $userspath)) <= -1) {
|
||
b0a92688 | Sven Schöling | exit if $result == -2;
|
||
login_screen($locale->text('Incorrect username or password!'));
|
||||
exit;
|
||||
d319704a | Moritz Bunkus | }
|
||
d1e4ee79 | Moritz Bunkus | my %style_to_script_map = ( 'v3' => 'v3',
|
||
'neu' => 'new',
|
||||
'xml' => 'XML',
|
||||
);
|
||||
my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
|
||||
d319704a | Moritz Bunkus | # made it this far, execute the menu
|
||
d1e4ee79 | Moritz Bunkus | $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display');
|
||
d319704a | Moritz Bunkus | |||
d1e4ee79 | Moritz Bunkus | $form->redirect();
|
||
d319704a | Moritz Bunkus | |||
$lxdebug->leave_sub();
|
||||
}
|
||||
sub logout {
|
||||
$lxdebug->enter_sub();
|
||||
unlink "$userspath/$form->{login}.conf";
|
||||
# remove the callback to display the message
|
||||
d629acd8 | Sven Schöling | $form->{callback} = "login.pl?action=&login=";
|
||
d319704a | Moritz Bunkus | $form->redirect($locale->text('You are logged out!'));
|
||
$lxdebug->leave_sub();
|
||||
}
|
||||
sub company_logo {
|
||||
$lxdebug->enter_sub();
|
||||
require "$userspath/$form->{login}.conf";
|
||||
d1e4ee79 | Moritz Bunkus | $locale = new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode});
|
||
d319704a | Moritz Bunkus | |||
d1e4ee79 | Moritz Bunkus | $form->{stylesheet} = $myconfig{stylesheet};
|
||
$form->{title} = $locale->text('About');
|
||||
d319704a | Moritz Bunkus | |||
# create the logo screen
|
||||
d1e4ee79 | Moritz Bunkus | $form->header() unless $form->{noheader};
|
||
print $form->parse_html_template('login/company_logo');
|
||||
d319704a | Moritz Bunkus | |||
$lxdebug->leave_sub();
|
||||
}
|