Initial commit.
This commit is contained in:
commit
cfa018e04b
3 changed files with 315 additions and 0 deletions
87
lib/WebGUI/AssetAspect/Mailable.pm
Normal file
87
lib/WebGUI/AssetAspect/Mailable.pm
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
package WebGUI::AssetAspect::Mailable;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Class::C3;
|
||||
|
||||
use WebGUI::Macro;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session,'AssetAspect_Mailable' );
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
);
|
||||
|
||||
push( @{ $definition }, {
|
||||
autoGenerateForms => 1,
|
||||
tableName => 'assetAspectMailable',
|
||||
className => 'WebGUI::AssetAspect::Mailable',
|
||||
properties => \%properties
|
||||
} );
|
||||
|
||||
return $class->next::method( $session, $definition );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub getEditTabs {
|
||||
my $self = shift;
|
||||
|
||||
return ( $self->next::method, [ 'mailable', 'Mailing list', 9 ] );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub generateEmailContent {
|
||||
WebGUI::Error::OverrideMe->throw;
|
||||
return;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub getIssueList {
|
||||
WebGUI::Error::OverrideMe->throw;
|
||||
return;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub getRecipients {
|
||||
WebGUI::Error::OverrideMe->throw;
|
||||
return;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub processContentAsUser {
|
||||
my $self = shift;
|
||||
my $userId = shift;
|
||||
my $session = $self->session;
|
||||
my $currentUser = $session->user;
|
||||
|
||||
# Become the desired user
|
||||
$session->user( { userId => $userId } );
|
||||
|
||||
# Generate email body for this user
|
||||
my $content = $self->generateEmailContent;
|
||||
|
||||
# Process macros
|
||||
WebGUI::Macro::process( $session, \$content );
|
||||
|
||||
# Become ourselves again.
|
||||
$session->user( { userId => $currentUser->getId } );
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub www_previewEmail {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
|
||||
my $userId = $form->get('userId');
|
||||
|
||||
return $self->processContentAsUser( $userId );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue