145 lines
3.7 KiB
Perl
145 lines
3.7 KiB
Perl
package WebGUI::AssetAspect::Mailable;
|
|
|
|
use strict;
|
|
use warnings;
|
|
use Class::C3;
|
|
|
|
use WebGUI::Macro;
|
|
use Tie::IxHash;
|
|
|
|
##----------------------------------------------------------------------------
|
|
#sub configureMailingForm {
|
|
# my $self = shift;
|
|
# my $f = WebGUI::HTMLForm->new( $session, { action => $self->getUrl } );
|
|
# $f->hidden(
|
|
# name => 'func'
|
|
# value => '
|
|
#
|
|
# return $f;
|
|
#}
|
|
|
|
#----------------------------------------------------------------------------
|
|
sub definition {
|
|
my $class = shift;
|
|
my $session = shift;
|
|
my $definition = shift;
|
|
my $i18n = WebGUI::International->new( $session,'AssetAspect_Mailable' );
|
|
|
|
tie my %properties, 'Tie::IxHash', (
|
|
mailStyleTemplateId => {
|
|
fieldType => 'template',
|
|
label => 'Mail template',
|
|
tab => 'mailable',
|
|
namespace => 'style',
|
|
},
|
|
);
|
|
|
|
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 getSubject {
|
|
my $self = shift;
|
|
my $configuration = shift || {};
|
|
|
|
return $configuration->{ subject } || '(No subject)';
|
|
}
|
|
|
|
#----------------------------------------------------------------------------
|
|
sub getMailingProperties {
|
|
my $self = shift;
|
|
tie my %properties, 'Tie::IxHash', (
|
|
subject => {
|
|
fieldType => 'text',
|
|
label => 'subject',
|
|
},
|
|
styleTemplateId => {
|
|
fieldType => 'template',
|
|
label => 'Style template',
|
|
defaultValue=> $self->get('mailStyleTemplateId'),
|
|
namespace => 'style',
|
|
},
|
|
);
|
|
|
|
return \%properties;
|
|
}
|
|
|
|
#----------------------------------------------------------------------------
|
|
sub getRecipients {
|
|
WebGUI::Error::OverrideMe->throw;
|
|
return;
|
|
}
|
|
|
|
#----------------------------------------------------------------------------
|
|
sub processContentAsUser {
|
|
my $self = shift;
|
|
my $issueId = shift;
|
|
my $userId = shift;
|
|
my $configuration = shift || {};
|
|
|
|
my $session = $self->session;
|
|
my $currentUser = $session->user;
|
|
|
|
# Become the desired user
|
|
$session->user( { userId => $userId } );
|
|
$session->log->preventDebugOutput;
|
|
|
|
my $styleTemplateId =
|
|
$configuration->{ styleTemplateId }
|
|
|| $self->get('mailStyleTemplateId')
|
|
|| $self->get('styleTemplateId');
|
|
|
|
# Generate email body for this user
|
|
my $content = $session->style->process(
|
|
$self->generateEmailContent( $issueId ),
|
|
$styleTemplateId,
|
|
);
|
|
|
|
# Process macros
|
|
WebGUI::Macro::process( $session, \$content );
|
|
|
|
# Become ourselves again.
|
|
$session->user( { userId => $currentUser->getId } );
|
|
|
|
return $content;
|
|
}
|
|
|
|
##----------------------------------------------------------------------------
|
|
#sub www_configureMailing {
|
|
# my $self = shift;
|
|
#
|
|
# my $f = $self->configureMailingForm;
|
|
#
|
|
# $f->submit( 'Next step' );
|
|
#
|
|
# return $self->processStyle( $f->print );
|
|
#}
|
|
|
|
1;
|
|
|