[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4071] trunk
- Subject: SF.net SVN: ledger-smb:[4071] trunk
- From: ..hidden..
- Date: Fri, 25 Nov 2011 10:29:21 +0000
Revision: 4071
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4071&view=rev
Author: einhverfr
Date: 2011-11-25 10:29:20 +0000 (Fri, 25 Nov 2011)
Log Message:
-----------
Merging from branches/1.3
Modified Paths:
--------------
trunk/Changelog
trunk/LedgerSMB/AM.pm
trunk/LedgerSMB/Database.pm
trunk/LedgerSMB/Scripts/setup.pm
trunk/UI/setup/confirm_operation.html
trunk/UI/setup/new_user.html
trunk/UI/setup/select_coa.html
trunk/UI/setup/upgrade_info.html
trunk/bin/am.pl
trunk/sql/modules/Roles.sql
Added Paths:
-----------
trunk/UI/setup/begin_backup.html
Property Changed:
----------------
trunk/
trunk/LedgerSMB/Scripts/admin.pm
trunk/LedgerSMB/Scripts/employee.pm
trunk/LedgerSMB/Scripts/file.pm
trunk/LedgerSMB/Scripts/payment.pm
trunk/LedgerSMB/Scripts/setup.pm
trunk/sql/upgrade/1.2-1.3-manual.sql
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/1.3:3711-4065
+ /branches/1.3:3711-4069
Modified: trunk/Changelog
===================================================================
--- trunk/Changelog 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/Changelog 2011-11-25 10:29:20 UTC (rev 4071)
@@ -22,6 +22,9 @@
* Correcting history.css not found (Chris T)
* Correcting parse errors in pos_template.txt (Chris T)
* Corrected Action not defined error on asset import (Chris T)
+* Corrected permissions issue for editing assembly (Chris T)
+* Database administration interface more consistent (Chris T)
+* Backup functionality moved to database administration interface (Chris T)
Changelog for LedgerSMB 1.3.6
* Including xelatex templates under directory templates/xedemo (Chris T)
Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/LedgerSMB/AM.pm 2011-11-25 10:29:20 UTC (rev 4071)
@@ -1799,93 +1799,6 @@
}
-=item AM->backup($myconfig, $form);
-
-Prepares and outputs a database backup of the current "dataset" using
-"pg_dump -Fc". The means of output is determined by $form->{media}, which can
-be either 'file' or 'email'. If email is the desired form of output, the email
-address to send the backup to and who to claim it is from is determined by
-$myconfig->{email} and $myconfig->{name}. File output sends the backup directly
-out over HTTP.
-
-=cut
-
-sub backup {
-
- my ( $self, $myconfig, $form ) = @_;
-
- my $mail;
- my $err;
-
- my @t = localtime(time);
- $t[4]++;
- $t[5] += 1900;
- $t[3] = substr( "0$t[3]", -2 );
- $t[4] = substr( "0$t[4]", -2 );
-
- my $globalDBname = $myconfig->{dbname};
- my $boundary = time;
- my $tmpfile =
-"${LedgerSMB::Sysconfig::backuppath}/$boundary.$globalDBname-$form->{dbversion}-$t[5]$t[4]$t[3].sqlc";
- $form->{OUT} = "$tmpfile";
-
- open( OUT, '>:raw', "$form->{OUT}" ) or $form->error("$form->{OUT} : $!");
-
- # get sequences, functions and triggers
-
- my $today = scalar localtime;
-
-
- ##SC: START Testing changes
- $myconfig->{name} = "test";
- $myconfig->{email} = '..hidden..';
- $myconfig->{dbport} = 5432;
- $myconfig->{dbuser} = 'seneca';
- $myconfig->{dbhost} = 'localhost';
- $myconfig->{dbname} = 'ledgersmb-taxtest';
- ##SC: END Testing changes
- if ( $form->{media} eq 'email' ) {
- print OUT
-qx(PGPASSWORD="$myconfig->{dbpasswd}" pg_dump -U $myconfig->{dbuser} -h $myconfig->{dbhost} -Fc -p $myconfig->{dbport} $myconfig->{dbname});
- close OUT;
- use LedgerSMB::Mailer;
- $mail = new LedgerSMB::Mailer(
- to => qq|"$myconfig->{name}" <$myconfig->{email}>|,
- from => qq|"$myconfig->{name}" <$myconfig->{email}>|,
- subject => "LedgerSMB Backup / $globalDBname-$form->{dbversion}-$t[5]$t[4]$t[3].sqlc",
- message => qq|
-This PostgreSQL backup can be restored using the pg_restore command.
-
---
-LedgerSMB|,
- );
-
- $mail->attach(
- 'file' => $tmpfile,
- 'filename' => $tmpfile,
- 'strip' => "$boundary.",
- 'mimetype' => 'application/octet-stream',
- );
-
- $err = $mail->send;
- }
-
- if ( $form->{media} eq 'file' ) {
-
- #open( IN, '<:raw', "$tmpfile" ) or $form->error("$tmpfile : $!");
- open( OUT, ">-" ) or $form->error("STDOUT : $!");
- binmode( OUT, ':raw' );
-
- print OUT qq|Content-Type: application/file;\n|
- . qq|Content-Disposition: attachment; filename="$myconfig->{dbname}-$form->{dbversion}-$t[5]$t[4]$t[3].sqlc"\n\n|;
- print OUT
-qx(PGPASSWORD="$myconfig->{dbpasswd}" pg_dump -U $myconfig->{dbuser} -h $myconfig->{dbhost} -Fc -p $myconfig->{dbport} $myconfig->{dbname});
- }
-
- unlink "$tmpfile";
-
-}
-
=item AM->closedto($myconfig, $form);
Populates $form->{closedto}, $form->{revtrans}, and $form->{audittrail} with
Modified: trunk/LedgerSMB/Database.pm
===================================================================
--- trunk/LedgerSMB/Database.pm 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/LedgerSMB/Database.pm 2011-11-25 10:29:20 UTC (rev 4071)
@@ -66,10 +66,92 @@
} else {
$self->{source_dir} = '';
}
+
bless $self, $class;
return $self;
}
+=item base_backup
+
+This routine connects to the database using pg_dumpall and returns a plain text,
+roles-only dump of the current database cluster. This is left uncompressed for
+readability and ease of troubleshooting. Base backups are advised to be taken
+frequently and in conjunction with single database backups. The single database
+backups will backup all data but no roles. Restoring a new database onto a new
+server post-crash with only the single-database backup thus means recreating all
+users.
+
+The file is named roles_[date].sql by default where the date is in
+yyyy-mm-dd format.
+
+=cut
+
+sub base_backup {
+ my $self = shift @_;
+
+ my $old_pguser = $ENV{PGUSER};
+ my $old_pgpass = $ENV{PGPASSWORD};
+ $ENV{PGUSER} = $self->{username};
+ $ENV{PGPASSWORD} = $self->{password};
+
+ my @t = localtime(time);
+ $t[4]++;
+ $t[5] += 1900;
+ $t[3] = substr( "0$t[3]", -2 );
+ $t[4] = substr( "0$t[4]", -2 );
+ my $date = "$5-$4-$3";
+
+ my $backupfile = $LedgerSMB::Sysconfig::backuppath .
+ "/roles_${date}.sql";
+
+ system("pgdumpall -r -f '$backupfile'") || $self->error('Backup failed');
+
+ $ENV{PGUSER} = $old_pguser;
+ $ENV{PGPASSWORD} = $old_pgpass;
+
+ return $backupfile;
+}
+
+=item db_backup()
+
+This routine connects to the database using pg_dump and creates a Pg-native
+database backup of the selected db only. There is some redundancy with the base
+backup but the overlap is minimal. You can restore your database and data with
+the db_bakup, but not the users and roles. You can restore the users and roles
+with the base_backup but not your database.
+
+The resulting file is named backup_[dbname]_[date].bak with the date in
+yyyy-mm-dd format.
+
+=cut
+
+sub db_backup {
+ my $self = shift @_;
+
+ my $old_pguser = $ENV{PGUSER};
+ my $old_pgpass = $ENV{PGPASSWORD};
+ $ENV{PGUSER} = $self->{username};
+ $ENV{PGPASSWORD} = $self->{password};
+
+ my @t = localtime(time);
+ $t[4]++;
+ $t[5] += 1900;
+ $t[3] = substr( "0$t[3]", -2 );
+ $t[4] = substr( "0$t[4]", -2 );
+ my $date = "$5-$4-$3";
+
+ my $backupfile = $LedgerSMB::Sysconfig::backuppath .
+ "/backup_$self->{company_name}_${date}.sql";
+
+ system("pgdump -d '$self->{company_name}' -F c -f '$backupfile'")
+ || $self->error('Backup failed');
+
+ $ENV{PGUSER} = $old_pguser;
+ $ENV{PGPASSWORD} = $old_pgpass;
+
+ return $backupfile;
+}
+
=item get_info()
This routine connects to the database using DBI and attempts to determine if a
Property changes on: trunk/LedgerSMB/Scripts/admin.pm
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/1.3/LedgerSMB/Scripts/admin.pm:3901-4065
/branches/1.3/scripts/admin.pl:3711-3903
+ /branches/1.3/LedgerSMB/Scripts/admin.pm:3901-4069
/branches/1.3/scripts/admin.pl:3711-3903
Property changes on: trunk/LedgerSMB/Scripts/employee.pm
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-4065
/branches/1.3/scripts/employee.pl:3842-3843
+ /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-4069
/branches/1.3/scripts/employee.pl:3842-3843
Property changes on: trunk/LedgerSMB/Scripts/file.pm
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/1.3/LedgerSMB/Scripts/file.pm:3711-4065
/branches/1.3/scripts/file.pl:3711-4065
+ /branches/1.3/LedgerSMB/Scripts/file.pm:3711-4069
/branches/1.3/scripts/file.pl:3711-4065
Property changes on: trunk/LedgerSMB/Scripts/payment.pm
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/1.3/LedgerSMB/Scripts/payment.pm:4010-4065
/branches/1.3/scripts/payment.pl:3711-4011
+ /branches/1.3/LedgerSMB/Scripts/payment.pm:4010-4069
/branches/1.3/scripts/payment.pl:3711-4011
Modified: trunk/LedgerSMB/Scripts/setup.pm
===================================================================
--- trunk/LedgerSMB/Scripts/setup.pm 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/LedgerSMB/Scripts/setup.pm 2011-11-25 10:29:20 UTC (rev 4071)
@@ -128,6 +128,107 @@
}
+=item backup_db
+
+Backs up a full db
+
+=cut
+
+sub backup_db {
+ my $request = shift @_;
+ $request->{backup} = 'db';
+ _begin_backup($request);
+}
+
+=item backup_roles
+
+Backs up roles only (for all db's)
+
+=cut
+
+sub backup_roles {
+ my $request = shift @_;
+ $request->{backup} = 'roles';
+ _begin_backup($request);
+}
+
+# Private method, basically just passes the inputs on to the next screen.
+sub _begin_backup {
+ my $request = shift @_;
+ my $template = LedgerSMB::Template->new(
+ path => 'UI/setup',
+ template => 'begin_backup',
+ format => 'HTML',
+ );
+ $template->render($request);
+};
+
+
+=item run_backup
+
+Runs the backup. If backup_type is set to email, emails the
+
+=cut
+
+sub run_backup {
+ use LedgerSMB::Company_Config;
+
+ my $request = shift @_;
+ my $database = LedgerSMB::Database->new(
+ {username => $creds->{username},
+ company_name => $request->{database},
+ password => $creds->{password}}
+ );
+
+ my $backupfile;
+ my $mimetype;
+
+ if ($request->{backup} eq 'roles'){
+ $backupfile = $database->base_backup;
+ $mimetype = 'text/x-sql';
+ } elsif ($request->{backup} eq 'db'){
+ $backupfile = $database->db_backup;
+ $mimetype = 'application/octet-stream';
+ } else {
+ $request->error($request->{_locale}->text('Invalid backup request'));
+ }
+
+ if ($request->{backup_type} eq 'email'){
+ my $csettings = $LedgerSMB::Company_Config::settings;
+ my $mail = new LedgerSMB::Mailer(
+ from => $csettings->{default_email_from},
+ to => $request->{email},
+ subject => "Email of Backup",
+ message => 'The Backup is Attached',
+ );
+ $mail->attach(
+ mimetype => $mimetype,
+ filename => $backupfile,
+ file => $backupfile,
+ );
+ $mail->send;
+ } elsif ($request->{backup_type} eq 'browser'){
+ open BAK, '<', $backupfile;
+ my $cgi = CGI::Simple->new();
+ print $cgi->header(
+ -type => $mimetype,
+ -status => '200',
+ -charset => 'utf-8',
+ -attachment => $backupfile,
+ );
+ } else {
+ $request->error($request->{_locale}->text("Don't know what to do with backup");
+ }
+ my $template = LedgerSMB::Template->new(
+ path => 'UI/setup',
+ template => 'complete',
+ format => 'HTML',
+ );
+ $template->render($request);
+
+}
+
+
=item migrate_sl
Beginning of an SQL-Ledger 2.7/2.8 migration.
Property changes on: trunk/LedgerSMB/Scripts/setup.pm
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/1.3/LedgerSMB/Scripts/setup.pm:3937-4065
/branches/1.3/scripts/setup.pl:3711-3967
+ /branches/1.3/LedgerSMB/Scripts/setup.pm:3937-4069
/branches/1.3/scripts/setup.pl:3711-4070
Copied: trunk/UI/setup/begin_backup.html (from rev 4069, branches/1.3/UI/setup/begin_backup.html)
===================================================================
--- trunk/UI/setup/begin_backup.html (rev 0)
+++ trunk/UI/setup/begin_backup.html 2011-11-25 10:29:20 UTC (rev 4071)
@@ -0,0 +1,54 @@
+<?lsmb INCLUDE "ui-header.html"
+stylesheet="ledgersmb.css"
+include_stylesheet=["UI/setup/stylesheet.css"] ?>
+<?lsmb PROCESS elements.html ?>
+<body>
+<h2><?lsmb text('Database Management Console') ?></h2>
+<div class="listtop"><?lsmb text('Where shall we send the backup?') ?></div>
+<?lsmb # notice, message, and operation are all localized. ?>
+<div id="notice"><?lsmb notice ?></div>
+<form action="setup.pl" method="POST" name="confirm_operation">
+<?lsmb INCLUDE input element_data = {
+ name = 'database'
+ type = 'hidden'
+ value = database
+} ?>
+<?lsmb INCLUDE input element_data = {
+ name = 'backup'
+ type = 'hidden'
+ value = backup
+} ?>
+<div class="inputrow" id="emailopt">
+<?lsmb INCLUDE input element_data = {
+ type = 'radio'
+ name = 'backup_type'
+ label = text('To email') #'
+ value = 'email'
+}, label_pos = 1 ?>
+<?lsmb INCLUDE inout element_data = {
+ type = "text"
+ name = "email"
+ value = email
+ class = "email"
+?>
+</div>
+<div class="inputrow" id="browseropt">
+<?lsmb INCLUDE input element_data = {
+ type = 'radio'
+ name = 'backup_type'
+ label = text('To my browser') #'
+ value = 'browser'
+}, label_pos = 1 ?>
+</div>
+<div class="inputrow">
+<?lsmb INCLUDE button element_data = {
+ name = 'action'
+ value = 'run_backup'
+ type = 'submit'
+ class = 'submit'
+ text = text('Run Backup') #'
+} ?>
+</div>
+</form>
+</body>
+</html>
Modified: trunk/UI/setup/confirm_operation.html
===================================================================
--- trunk/UI/setup/confirm_operation.html 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/UI/setup/confirm_operation.html 2011-11-25 10:29:20 UTC (rev 4071)
@@ -3,6 +3,7 @@
include_stylesheet=["UI/setup/stylesheet.css"] ?>
<?lsmb PROCESS elements.html ?>
<body>
+<h2><?lsmb text('Database Management Console') ?></h2>
<div class="listtop"><?lsmb text('Confirm Operation') ?></div>
<?lsmb # notice, message, and operation are all localized. ?>
<div id="notice"><?lsmb notice ?></div>
@@ -14,30 +15,30 @@
type = 'hidden'
value = database
} ?>
-<div class="inputrow" id="yesno">
-<?lsmb
-INCLUDE input element_data = {
- name = 'confirm'
- value = '1'
- type = 'radio'
- class = 'confirm'
- label = text('Yes')
-} ;
-INCLUDE input element_data = {
- name = 'confirm'
- value = '0'
- type = 'radio'
- class = 'confirm'
- label = text('No')
+<div class="inputrow">
+<?lsmb INCLUDE button element_data = {
+ name = 'action'
+ value = next_action
+ type = 'submit'
+ class = 'submit'
+ text = text('Yes')
} ?>
</div>
+<div id="others"><?lsmb text('Backup') ?></div>
<div class="inputrow">
<?lsmb INCLUDE button element_data = {
name = 'action'
- value = next_action
+ value = 'backup_db'
type = 'submit'
+ class = 'submit'
+ text = text('Backup DB') #'
+} ?>
+<?lsmb INCLUDE button element_data = {
+ name = 'action'
+ value = 'backup_roles'
+ type = 'submit'
class = 'next'
- text = text('Next')
+ text = text('Backup Roles') #'
} ?>
</div>
</form>
Modified: trunk/UI/setup/new_user.html
===================================================================
--- trunk/UI/setup/new_user.html 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/UI/setup/new_user.html 2011-11-25 10:29:20 UTC (rev 4071)
@@ -3,6 +3,7 @@
include_stylesheet=["UI/setup/stylesheet.css"] ?>
<?lsmb PROCESS elements.html ?>
<body>
+<h2><?lsmb text('Database Management Console') ?></h2>
<div class="listtop"><?lsmb text('Enter User') ?></div>
<form action="setup.pl" method="POST" name="new_user">
<?lsmb INCLUDE input element_data = {
Modified: trunk/UI/setup/select_coa.html
===================================================================
--- trunk/UI/setup/select_coa.html 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/UI/setup/select_coa.html 2011-11-25 10:29:20 UTC (rev 4071)
@@ -3,7 +3,7 @@
include_stylesheet=["UI/setup/stylesheet.css"] ?>
<?lsmb PROCESS elements.html ?>
<body>
-<h2>Database Management Console</h2>
+<h2><?lsmb text('Database Management Console') ?></h2>
<div class="listtop"><?lsmb title ?></div>
<form action="setup.pl" method="POST" name="credentials">
<?lsmb IF coa_lc;
Modified: trunk/UI/setup/upgrade_info.html
===================================================================
--- trunk/UI/setup/upgrade_info.html 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/UI/setup/upgrade_info.html 2011-11-25 10:29:20 UTC (rev 4071)
@@ -3,6 +3,7 @@
include_stylesheet=["UI/setup/stylesheet.css"] ?>
<?lsmb PROCESS elements.html ?>
<body>
+<h2><?lsmb text('Database Management Console') ?></h2>
<div class="listtop"><?lsmb text('Enter User') ?></div>
<form action="setup.pl" method="POST" name="new_user">
<?lsmb INCLUDE input element_data = {
Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/bin/am.pl 2011-11-25 10:29:20 UTC (rev 4071)
@@ -1787,28 +1787,6 @@
}
-sub backup {
-
- if ( $form->{media} eq 'email' ) {
- $form->error(
- $locale->text( 'No email address for [_1]', $myconfig{name} ) )
- unless ( $myconfig{email} );
- }
-
- $SIG{INT} = 'IGNORE';
- AM->backup(
- \%myconfig, \%$form,
- ${LedgerSMB::Sysconfig::userspath},
- ${LedgerSMB::Sysconfig::gzip}
- );
-
- if ( $form->{media} eq 'email' ) {
- $form->redirect(
- $locale->text( 'Backup sent to [_1]', $myconfig{email} ) );
- }
-
-}
-
sub audit_control {
$form->{title} = $locale->text('Audit Control');
Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql 2011-11-25 10:25:27 UTC (rev 4070)
+++ trunk/sql/modules/Roles.sql 2011-11-25 10:29:20 UTC (rev 4071)
@@ -777,6 +777,7 @@
CREATE ROLE "lsmb_<?lsmb dbname ?>__part_edit"
WITH INHERIT NOLOGIN;
+GRANT DELETE ON assembly TO "lsmb_<?lsmb dbname ?>__part_edit";
GRANT UPDATE ON parts, partsgroup, assembly TO "lsmb_<?lsmb dbname ?>__part_edit";
GRANT ALL ON makemodel TO "lsmb_<?lsmb dbname ?>__part_edit";
--###oldcode: Should have been UPDATE
Property changes on: trunk/sql/upgrade/1.2-1.3-manual.sql
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/1.3/sql/upgrade/1.2-1.3-manual.sql:3712-4065
/branches/1.3/sql/upgrade/1.2-1.3.sql:3711-3851
/trunk/sql/upgrade/1.2-1.3.sql:858-3710
+ /branches/1.3/sql/upgrade/1.2-1.3-manual.sql:3712-4069
/branches/1.3/sql/upgrade/1.2-1.3.sql:3711-3851
/trunk/sql/upgrade/1.2-1.3.sql:858-3710
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.