Revision 6f398b35
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
42 | 42 |
use Encode; |
43 | 43 |
use List::MoreUtils qw(any); |
44 | 44 |
use SL::DBUtils; |
45 |
use SL::DB::AuthUser; |
|
46 |
use SL::DB::Employee; |
|
45 | 47 |
|
46 | 48 |
use strict; |
47 | 49 |
|
... | ... | |
1120 | 1122 |
$main::lxdebug->leave_sub(); |
1121 | 1123 |
} |
1122 | 1124 |
|
1123 |
|
|
1124 | 1125 |
sub save_preferences { |
1125 | 1126 |
$main::lxdebug->enter_sub(); |
1126 | 1127 |
|
1127 |
my ($self, $myconfig, $form) = @_; |
|
1128 |
|
|
1129 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
1130 |
|
|
1131 |
my ($businessnumber) = selectrow_query($form, $dbh, qq|SELECT businessnumber FROM defaults|); |
|
1132 |
|
|
1133 |
# update name |
|
1134 |
my $query = qq|UPDATE employee SET name = ? WHERE login = ?|; |
|
1135 |
do_query($form, $dbh, $query, $form->{name}, $form->{login}); |
|
1136 |
|
|
1137 |
my $rc = $dbh->commit(); |
|
1128 |
my ($self, $form) = @_; |
|
1138 | 1129 |
|
1139 |
$form->{businessnumber} = $businessnumber; |
|
1130 |
my $employee = SL::DB::Manager::Employee->find_by(login => $form->{login}); |
|
1131 |
$employee->update_attributes(name => $form->{name}); |
|
1140 | 1132 |
|
1141 |
$myconfig = User->new(login => $form->{login}); |
|
1142 |
|
|
1143 |
foreach my $item (keys %$form) { |
|
1144 |
$myconfig->{$item} = $form->{$item}; |
|
1145 |
} |
|
1146 |
|
|
1147 |
$myconfig->save_member; |
|
1148 |
|
|
1149 |
my $auth = $main::auth; |
|
1133 |
my $user = SL::DB::Manager::AuthUser->find_by(login => $form->{login}); |
|
1134 |
$user->update_attributes( |
|
1135 |
config_values => { |
|
1136 |
map({ ($_ => $form->{$_}) } SL::DB::AuthUser::CONFIG_VARS()), |
|
1137 |
map({ ($_ => do { my $v = $form->{$_}; $v =~ s/\r//g; $v }) } qw(address signature)), |
|
1138 |
}); |
|
1150 | 1139 |
|
1151 | 1140 |
$main::lxdebug->leave_sub(); |
1152 | 1141 |
|
1153 |
return $rc;
|
|
1142 |
return 1;
|
|
1154 | 1143 |
} |
1155 | 1144 |
|
1156 | 1145 |
sub get_defaults { |
SL/DB/AuthUser.pm | ||
---|---|---|
10 | 10 |
use SL::DB::AuthUserGroup; |
11 | 11 |
use SL::DB::Helper::Util; |
12 | 12 |
|
13 |
use constant CONFIG_VARS => qw(copies countrycode dateformat default_media default_printer_id email favorites fax hide_cvar_search_options mandatory_departments menustyle name |
|
14 |
numberformat show_form_details signature stylesheet taxincluded_checked tel template_format vclimit); |
|
15 |
|
|
13 | 16 |
__PACKAGE__->meta->add_relationship( |
14 | 17 |
groups => { |
15 | 18 |
type => 'many to many', |
SL/User.pm | ||
---|---|---|
105 | 105 |
# we got a connection, check the version |
106 | 106 |
my ($dbversion) = $dbh->selectrow_array(qq|SELECT version FROM defaults|); |
107 | 107 |
|
108 |
$self->create_employee_entry($form, $dbh, \%myconfig); |
|
109 |
|
|
110 | 108 |
$self->create_schema_info_table($form, $dbh); |
111 | 109 |
|
112 | 110 |
# Auth DB upgrades available? |
... | ... | |
571 | 569 |
return $rc; |
572 | 570 |
} |
573 | 571 |
|
574 |
sub save_member { |
|
575 |
$main::lxdebug->enter_sub(); |
|
576 |
|
|
577 |
my ($self) = @_; |
|
578 |
|
|
579 |
# format dbconnect and dboptions string |
|
580 |
dbconnect_vars($self, $self->{dbname}); |
|
581 |
|
|
582 |
map { $self->{$_} =~ s/\r//g; } qw(address signature); |
|
583 |
|
|
584 |
$main::auth->save_user($self->{login}, map { $_, $self->{$_} } config_vars()); |
|
585 |
|
|
586 |
my $dbh = SL::DBConnect->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd}, SL::DBConnect->get_options); |
|
587 |
if ($dbh) { |
|
588 |
$self->create_employee_entry($::form, $dbh, $self, 1); |
|
589 |
$dbh->disconnect(); |
|
590 |
} |
|
591 |
|
|
592 |
$main::lxdebug->leave_sub(); |
|
593 |
} |
|
594 |
|
|
595 |
sub create_employee_entry { |
|
596 |
$main::lxdebug->enter_sub(); |
|
597 |
|
|
598 |
my $self = shift; |
|
599 |
my $form = shift; |
|
600 |
my $dbh = shift; |
|
601 |
my $myconfig = shift; |
|
602 |
my $update_existing = shift; |
|
603 |
|
|
604 |
if (!does_table_exist($dbh, 'employee')) { |
|
605 |
$main::lxdebug->leave_sub(); |
|
606 |
return; |
|
607 |
} |
|
608 |
|
|
609 |
# add login to employee table if it does not exist |
|
610 |
# no error check for employee table, ignore if it does not exist |
|
611 |
my ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); |
|
612 |
my ($good_db) = selectrow_query($form, $dbh, qq|select * from pg_tables where tablename = ? and schemaname = ?|, 'schema_info', 'public'); |
|
613 |
my $can_delete; |
|
614 |
($can_delete) = selectrow_query($form, $dbh, qq|SELECT tag FROM schema_info WHERE tag = ?|, 'employee_deleted') if $good_db; |
|
615 |
|
|
616 |
if (!$id) { |
|
617 |
my $query = qq|INSERT INTO employee (login, name, workphone) VALUES (?, ?, ?)|; |
|
618 |
do_query($form, $dbh, $query, ($self->{login}, $myconfig->{name}, $myconfig->{tel})); |
|
619 |
|
|
620 |
} elsif ($update_existing && $can_delete) { |
|
621 |
my $query = qq|UPDATE employee SET name = ?, workphone = ?, deleted = 'f' WHERE id = ?|; |
|
622 |
do_query($form, $dbh, $query, $myconfig->{name}, $myconfig->{tel}, $id); |
|
623 |
} |
|
624 |
|
|
625 |
$main::lxdebug->leave_sub(); |
|
626 |
} |
|
627 |
|
|
628 |
sub config_vars { |
|
629 |
$main::lxdebug->enter_sub(); |
|
630 |
|
|
631 |
my @conf = qw(copies countrycode dateformat default_media default_printer_id email favorites fax hide_cvar_search_options mandatory_departments menustyle name |
|
632 |
numberformat show_form_details signature stylesheet taxincluded_checked tel template_format vclimit); |
|
633 |
|
|
634 |
$main::lxdebug->leave_sub(); |
|
635 |
|
|
636 |
return @conf; |
|
637 |
} |
|
638 |
|
|
639 | 572 |
sub data { |
640 | 573 |
+{ %{ $_[0] } } |
641 | 574 |
} |
bin/mozilla/am.pl | ||
---|---|---|
1104 | 1104 |
|
1105 | 1105 |
TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } }); |
1106 | 1106 |
|
1107 |
if (AM->save_preferences(\%myconfig, $form)) {
|
|
1107 |
if (AM->save_preferences($form)) { |
|
1108 | 1108 |
if ($::auth->can_change_password() |
1109 | 1109 |
&& defined $form->{new_password} |
1110 | 1110 |
&& ($form->{new_password} ne '********')) { |
... | ... | |
1116 | 1116 |
} |
1117 | 1117 |
|
1118 | 1118 |
$::auth->change_password($form->{login}, $form->{new_password}); |
1119 |
|
|
1120 |
$form->{password} = $form->{new_password}; |
|
1121 |
$::auth->set_session_value('password', $form->{password}); |
|
1122 |
$::auth->create_or_refresh_session(); |
|
1123 | 1119 |
} |
1124 | 1120 |
|
1125 | 1121 |
$form->redirect($locale->text('Preferences saved!')); |
Auch abrufbar als: Unified diff
Mandantennamen in allen Menü-Headern anzeigen