From 988eaf4954fef8fb2f6e3b263b57963874d5285a Mon Sep 17 00:00:00 2001 From: christopherm Date: Mon, 13 Nov 2006 03:39:22 +0000 Subject: fetching user data from central db instead of flat file, removing sessionid, removing setup_initial_password function, fixing %myconfig data type git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@547 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/admin.pl | 98 ++++++++++++++++-------------------------------------------- 1 file changed, 25 insertions(+), 73 deletions(-) (limited to 'bin') diff --git a/bin/admin.pl b/bin/admin.pl index bc4e291f..939dbae6 100755 --- a/bin/admin.pl +++ b/bin/admin.pl @@ -76,54 +76,12 @@ if ($form->{action}) { $root = LedgerSMB::User->new('admin'); - unless($root && $root->{password}){ - &setup_initial_password(); - exit; - } - &adminlogin; } 1; # end - -sub setup_initial_password { - - - $form->header(); - print qq| - -
- LedgerSMB Logo -

|.$locale->text('Version').qq| $form->{version}
|.$locale->text('Administration').qq|

- -
|.$locale->text('Change password').qq| -

|.$locale->text('This is your first time logging into LedgerSMB. Please set your administrative password').qq|

- -
- - - - - - - - - -
|.$locale->text('Password').qq|
|.$locale->text('Confirm').qq|
- - -

-
- - |.$locale->text('LedgerSMB website').qq| -
- - -|; -} - sub adminlogin { $form->{title} = qq|LedgerSMB $form->{version} |.$locale->text('Administration'); @@ -219,9 +177,8 @@ sub form_footer { } print qq| - + - $delete @@ -240,21 +197,23 @@ sub list_users { # $nologin = qq||; #} - while () { - chop; + # use the central database handle + my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH}; - if (/^\[.*\]/) { - $login = $_; - $login =~ s/(\[|\])//g; - } + my $fetchMembers = $dbh->selectall_arrayref("SELECT uc.name, uc.company, uc.templates, + uc.dbuser, uc.dbdriver, uc.dbname, + uc.dbhost, u.username + FROM users as u, users_conf as uc + WHERE u.id = uc.id + AND u.id > 1 + ORDER BY u.username;", { Slice => {} }); - if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) { - chop ($var = $&); - ($null, $member{$login}{$var}) = split /=/, $_, 2; - } - } + my @memberArray = (); + my @member = (); - close(FH); + foreach my $memberArray ( @$fetchMembers ) { + $member{$memberArray->{username}} = $memberArray; + } # type=submit $locale->text('Pg Database Administration') # type=submit $locale->text('PgPP Database Administration') @@ -298,7 +257,7 @@ sub list_users { foreach $key (sort keys %member) { - $href = "$script?action=edit&login=$key&path=$form->{path}&sessionid=$form->{sessionid}"; + $href = "$script?action=edit&login=$key&path=$form->{path}"; $href =~ s/ /%20/g; $member{$key}{templates} =~ s/^${LedgerSMB::Sysconfig::templates}\///; @@ -329,7 +288,6 @@ sub list_users { -
@@ -355,14 +313,13 @@ sub form_header { if ($form->{login}) { # get user - %myconfig = %{LedgerSMB::User->fetch_config($form->{login})}; + %{$myconfig} = %{LedgerSMB::User->fetch_config($form->{login})}; for (qw(company address signature)) { $myconfig->{$_} = $form->quote($myconfig->{$_}) } for (qw(address signature)) { $myconfig->{$_} =~ s/\\n/\n/g } # strip basedir from templates directory $myconfig->{templates} =~ s/^${LedgerSMB::Sysconfig::templates}\///; - $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd}; } foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { @@ -902,7 +859,7 @@ sub change_admin_password { $form->{title} = qq|LedgerSMB |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password'); - $form->{login} = "root login"; + $form->{login} = "admin"; $form->header; print qq| @@ -931,7 +888,6 @@ sub change_admin_password {

-

@@ -947,7 +903,7 @@ sub change_password { $root->{password} = $form->{new_password}; $root->{'root login'} = 1; $root->save_member(); - $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}"; + $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}"; $form->redirect($locale->text('Password changed!')); } @@ -1070,9 +1026,8 @@ sub dbselect_source { - + -
@@ -1207,10 +1162,10 @@ sub create_dataset { |; - $form->hide_form(qw(dbdriver dbsuperuser dbsuperpasswd dbuser dbhost dbport dbpasswd dbdefault path sessionid)); + $form->hide_form(qw(dbdriver dbsuperuser dbsuperpasswd dbuser dbhost dbport dbpasswd dbdefault path)); print qq| - +
@@ -1243,7 +1198,6 @@ sub dbcreate { .$locale->text('Dataset [_1] successfully created!', $form->{db}) .qq| -

@@ -1283,9 +1237,8 @@ sub delete_dataset { - + - @@ -1335,7 +1288,6 @@ sub dbdelete { .qq| -

@@ -1349,7 +1301,7 @@ sub unlock_system { # This needs to be done with a db tool # unlink "${LedgerSMB::Sysconfig::userspath}/nologin"; - $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}"; + $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}"; $form->redirect($locale->text('Lockfile removed!')); } @@ -1359,6 +1311,6 @@ sub lock_system { # This needs to be done with a db tool #open(FH, ">${LedgerSMB::Sysconfig::userspath}/nologin") or $form->error($locale->text('Cannot create Lock!')); #close(FH); - $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}"; + $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}"; $form->redirect($locale->text('Lockfile created!')); } -- cgit v1.2.3