[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [911] trunk
- Subject: SF.net SVN: ledger-smb: [911] trunk
- From: ..hidden..
- Date: Thu, 15 Mar 2007 16:42:33 -0700
Revision: 911
http://svn.sourceforge.net/ledger-smb/?rev=911&view=rev
Author: einhverfr
Date: 2007-03-15 16:42:33 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
Mostly done rewriting LedgerSMB.pm. There are a few areas that still need work
Modified Paths:
--------------
trunk/LedgerSMB/Sysconfig.pm
trunk/LedgerSMB.pm
Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm 2007-03-15 05:59:07 UTC (rev 910)
+++ trunk/LedgerSMB/Sysconfig.pm 2007-03-15 23:42:33 UTC (rev 911)
@@ -105,9 +105,10 @@
#putting this in an if clause for now so not to break other devel users
if ($config{globaldb}{DBname}){
- $GLOBALDBH = DBI->connect("dbi:Pg:dbname=$globalDBname host=$globalDBhost
- port=$globalDBport user=$globalDBUserName
- password=$globalDBPassword");
+ my $dbconnect = "dbi:Pg:dbname=$globalDBname host=$globalDBhost
+ port=$globalDBport user=$globalDBUserName
+ password=$globalDBPassword"; # for easier debugging
+ $GLOBALDBH = DBI->connect($dbconnect);
if (!$GLOBALDBH){
$form = new Form;
$form->error("No GlobalDBH Configured or Could not Connect");
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2007-03-15 05:59:07 UTC (rev 910)
+++ trunk/LedgerSMB.pm 2007-03-15 23:42:33 UTC (rev 911)
@@ -52,12 +52,22 @@
This function determines the likely number of rows needed to hold text in a
textbox. It returns either that number or max, which ever is lower.
+=item merge ($hashref, keys => @list, index => $number);
+This command merges the $hashref into the current object. If keys are
+specified, only those keys are used. Otherwise all keys are merged.
+
+If an index is specified, the merged keys are given a form of
+"$key" . "_$index", otherwise the key is used on both sides.
+
=item redirect (msg => $string)
This function redirects to the script and argument set determined by
$self->{callback}, and if this is not set, goes to an info screen and prints
$msg.
+=item redo_rows (fields =>, new =>, count =>, rows => $integer);
+This function is undergoing serious redesign at the moment.
+
=head1 Copyright (C) 2006, The LedgerSMB core team.
# This work contains copyrighted information from a number of sources all used
@@ -501,8 +511,13 @@
my %args = @_;
my $myconfig = $args{user};
- $self->{dbh} = $self->dbconnect_noauto($myconfig) || $self->dberror();
+ my $dbh = DBI->connect($myconfig->{dbconnect}, $myconfig->{dbuser},
+ $myconfig->{dbpasswd}, {AutoCommit => 0}) or $self->dberror;
+ if ($myconfig->{dboptions}) {
+ $dbh->do($myconfig->{dboptions});
+ }
+
my $query =
"SELECT t.extends,
coalesce (t.table_name, 'custom_' || extends)
@@ -518,27 +533,15 @@
}
}
-# Will merge this into db_init in the future.
-# Deprecated and hence undocumented. Chris.
-sub dbconnect_noauto {
-
- my ($self, $myconfig) = @_;
-
- # connect to database
- my $dbh = DBI->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, {AutoCommit => 0}) or $self->dberror;
-
- # set db options
- if ($myconfig->{dboptions}) {
- $dbh->do($myconfig->{dboptions});
- }
-
- $dbh;
-}
-
-
+# This needs some *real* work.
sub redo_rows {
- my ($self, $flds, $new, $count, $numrows) = @_;
+ $self = shift @_;
+ %args = @_;
+ @flds = @{$args{fields}};
+ $new = $args{new};
+ $count = $args{count};
+ $numrows = $args{rows};
my @ndx = ();
@@ -552,7 +555,7 @@
foreach my $item (sort { $a->{num} <=> $b->{num} } @ndx) {
$i++;
$j = $item->{ndx} - 1;
- for (@{$flds}) { $self->{"${_}_$i"} = $new->[$j]->{$_} }
+ for (@flds) { $self->{"${_}_$i"} = $new->[$j]->{$_} }
}
# delete empty rows
@@ -567,17 +570,19 @@
for my $arg ($self, $src){
shift;
}
- my @keys;
- if (scalar @keys){
- @keys = @_;
- print "Keys: ". scalar @keys . "\n";
- }
- else {
+ my %args = @_;
+ my @keys = @{$args{keys}};
+ my $index = $args{index};
+ if (! scalar @keys){
@keys = keys %{$src};
- print "Keys: ". scalar @keys . "\n";
}
for my $arg (keys %$src){
- $self->{$arg} = $src->{$arg};
+ if ($index){
+ $dst_arg = $arg . "_$index";
+ } else {
+ $dst_arg = $arg;
+ }
+ $self->{$dst_arg} = $src->{$arg};
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.