kivilogo: Frieden statt Corona
[kivitendo-erp.git] / bin / mozilla / login.pl
index b9a29c3..2457ddf 100644 (file)
 # 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.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
 #######################################################################
 
-use DBI;
-use SL::User;
+use SL::DB::Default;
 use SL::Form;
+use SL::Git;
+use DateTime;
 
 require "bin/mozilla/common.pl";
+require "bin/mozilla/todo.pl";
 
-$form = new Form;
+use strict;
 
-$locale = new Locale $language, "login";
-
-# customization
-if (-f "bin/mozilla/custom_$form->{script}") {
-  eval { require "bin/mozilla/custom_$form->{script}"; };
-  $form->error($@) if ($@);
-}
-
-# per login customization
-if (-f "bin/mozilla/$form->{login}_$form->{script}") {
-  eval { require "bin/mozilla/$form->{login}_$form->{script}"; };
-  $form->error($@) if ($@);
-}
-
-# window title bar, user info
-$form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}";
-
-if ($form->{action}) {
-  $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
-  call_sub($locale->findsub($form->{action}));
-
-} else {
-  login_screen();
-}
-
-1;
-
-sub login_screen {
-  $lxdebug->enter_sub();
-
-  if (-f "css/lx-office-erp.css") {
-    $form->{stylesheet} = "lx-office-erp.css";
-  }
-
-  $form->{fokus} = "loginscreen.login";
-  $form->header;
-
-  print $form->parse_html_template('login/login_screen');
-
-  $lxdebug->leave_sub();
-}
-
-sub login {
-  $lxdebug->enter_sub();
-
-  $form->error($locale->text('You did not enter a name!')) unless ($form->{login});
-
-  $user = new User $memberfile, $form->{login};
-
-  # if we get an error back, bale out
-  if (($result = $user->login(\%$form, $userspath)) <= -1) {
-    if ($result == -2) {
-      exit;
-    }
-
-    $form->error($locale->text('Incorrect username or password!'));
-  }
-
-  my %style_to_script_map = ( 'v3'  => 'v3',
-                              'neu' => 'new',
-                              'xml' => 'XML',
-    );
-
-  my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
-
-  # made it this far, execute the menu
-  $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display');
-
-  $form->redirect();
-
-  $lxdebug->leave_sub();
-}
-
-sub logout {
-  $lxdebug->enter_sub();
-
-  unlink "$userspath/$form->{login}.conf";
-
-  # remove the callback to display the message
-  $form->{callback} = "login.pl?action=&login=";
-  $form->redirect($locale->text('You are logged out!'));
-
-  $lxdebug->leave_sub();
-}
+our $form;
+our $auth;
 
 sub company_logo {
-  $lxdebug->enter_sub();
+  $main::lxdebug->enter_sub();
 
-  require "$userspath/$form->{login}.conf";
-
-  $locale             =  new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode});
+  my %myconfig = %main::myconfig;
+  $form->{todo_list}  =  create_todo_list('login_screen' => 1) if (!$::request->is_mobile) and (!$form->{no_todo_list}) and ($main::auth->check_right($::myconfig{login}, 'productivity'));
 
   $form->{stylesheet} =  $myconfig{stylesheet};
-  $form->{title}      =  $locale->text('About');
+  $form->{title}      =  $::locale->text('kivitendo');
+  $form->{interface}  = $::dispatcher->interface_type;
+  $form->{client}     = $::auth->client;
+  $form->{defaults}   = SL::DB::Default->get;
+
+  my $git             = SL::Git->new;
+  ($form->{git_head}) = $git->get_log(since => 'HEAD~1', until => 'HEAD') if $git->is_git_installation;
+  $form->{xmas}       = '_xmas' if (DateTime->today->month == 12 && DateTime->today->day < 27);
+  $form->{xmas}       = '_mir'  if (DateTime->today->month >= 03 && DateTime->today->year == 2022
+                                    && DateTime->today->month <= 05);
+  $form->{xmas}       = '_mir'  if (DateTime->today->day == 24 && DateTime->today->month == 2);
 
   # create the logo screen
   $form->header() unless $form->{noheader};
 
-  print $form->parse_html_template('login/company_logo');
+  print $form->parse_html_template('login/company_logo', { version => $::form->read_version });
 
-  $lxdebug->leave_sub();
+  $main::lxdebug->leave_sub();
 }
+
+1;
+
+__END__