Wrote add-email-address.plx script.
This commit is contained in:
parent
8b233299c8
commit
4bd5ab4fd1
2 changed files with 49 additions and 0 deletions
|
@ -31,3 +31,6 @@ the command line with the Supporters database.
|
|||
|
||||
* Add a Supporter from the command line:
|
||||
./scripts/add-supporter.plx <DBFILE>
|
||||
|
||||
* Add an email address, or change the preferred email address:
|
||||
./scripts/add-email-address.plx <DBFILE>
|
||||
|
|
46
scripts/add-email-address.plx
Normal file
46
scripts/add-email-address.plx
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use DBI;
|
||||
use Encode qw(encode decode);
|
||||
use Supporters;
|
||||
|
||||
if (@ARGV != 1 and @ARGV !=2) {
|
||||
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <VERBOSITY_LEVEL>\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my($SUPPORTERS_SQLITE_DB_FILE, $VERBOSE) = @ARGV;
|
||||
$VERBOSE = 0 if not defined $VERBOSE;
|
||||
|
||||
my $dbh = DBI->connect("dbi:SQLite:dbname=$SUPPORTERS_SQLITE_DB_FILE", "", "",
|
||||
{ RaiseError => 1, sqlite_unicode => 1 })
|
||||
or die $DBI::errstr;
|
||||
|
||||
print "Supporter Id: ";
|
||||
my $supporterId = <STDIN>;
|
||||
chomp $supporterId;
|
||||
|
||||
print "Email Address: ";
|
||||
my $email = <STDIN>;
|
||||
chomp $email;
|
||||
|
||||
print "Email Address Type: ";
|
||||
my $emailType = <STDIN>;
|
||||
chomp $emailType;
|
||||
|
||||
print "Preferred (0 or 1): ";
|
||||
my $preferred = <STDIN>;
|
||||
chomp $preferred;
|
||||
|
||||
my $sp = new Supporters($dbh, [ "none" ]);
|
||||
|
||||
$sp->addEmailAddress($supporterId, $email, $emailType);
|
||||
|
||||
print "Preferred email address was: ", $sp->getPreferredEmailAddress($supporterId), "\n";
|
||||
if ($preferred) {
|
||||
$sp->setPreferredEmailAddress($supporterId, $email);
|
||||
print "Preferred email address is now: ", $sp->getPreferredEmailAddress($supporterId), "\n";
|
||||
}
|
Loading…
Reference in a new issue