diff --git a/lib/WebGUI/Mailing.pm b/lib/WebGUI/Mailing.pm new file mode 100644 index 0000000..cb03089 --- /dev/null +++ b/lib/WebGUI/Mailing.pm @@ -0,0 +1,47 @@ +package WebGUI::Mailing; + +use strict; +use warnings; + +use base 'WebGUI::Crud'; + +sub crud_definition { + my $class = shift; + my $session = shift; + + my $definition = $class->SUPER::crud_definition( $session ); + + $definition->{ tableName } = 'WGMailing'; + $definition->{ tableKey } = 'mailingId'; + $definition->{ sequenceKey } = 'issueId'; + + my %properties = ( + assetId => { + fieldType => 'guid', + }, + + issueId => { + fieldType => 'guid', + }, + configuration => { + fieldType => 'textarea', + }, + sendDate => { + fieldType => 'dateTime', + }, + active => { + fieldType => 'yesNo', + defaultValue => 0, + }, + ); + + $definition->{ properties } = { + %{ $definition->{ properties } || {} }, + %properties, + }; + + return $definition; +} + +1; + diff --git a/lib/WebGUI/Mailing/Email.pm b/lib/WebGUI/Mailing/Email.pm new file mode 100644 index 0000000..061352c --- /dev/null +++ b/lib/WebGUI/Mailing/Email.pm @@ -0,0 +1,52 @@ +package WebGUI::Mailing::Email; + +use strict; +use warnings; + +use base 'WebGUI::Crud'; + +sub crud_definition { + my $class = shift; + my $session = shift; + + my $definition = $class->SUPER::crud_definition( $session ); + + $definition->{ tableName } = 'WGMailing_queue'; + $definition->{ tableKey } = 'mailId'; + $definition->{ sequenceKey } = 'mailingId'; + + my %properties = ( + mailingId => { + fieldType => 'guid', + }, + userId => { + fieldType => 'guid', + }, + recipientEmail => { + fieldType => 'email', + defaultValue => undef, + }, + status => { + fieldType => 'text', + defaultValue => 'queued', # Allowed are: 'queued', 'sent', 'error' + }, + errorMessage => { + fieldType => 'text', + defaultValue => undef, + }, + isTest => { + fieldType => 'yesNo', + defaultValue => 1, # For safety: explicitly turn this off to send real emails + }, + ); + + $definition->{ properties } = { + %{ $definition->{ properties } || {} }, + %properties, + }; + + return $definition; +} + +1; + diff --git a/sbin/install_newsletter.pl b/sbin/install_newsletter.pl index 0f804db..8ac793e 100644 --- a/sbin/install_newsletter.pl +++ b/sbin/install_newsletter.pl @@ -22,6 +22,7 @@ my $session = start( $webguiRoot, $configFile ); installMailableAspectTable( $session ); installNewsletterCollection( $session ); +installMailingTables( $session ); finish($session); @@ -32,8 +33,9 @@ sub installMailableAspectTable { $session->db->write(<crud_createOrUpdateTable( $session ); + WebGUI::Mailing::Email->crud_createOrUpdateTable( $session ); + + print "Done\n"; +} + + #---------------------------------------------------------------------------- sub start { my $webguiRoot = shift;