initial revisions of most files...

This commit is contained in:
daviddelikat 2009-09-30 07:07:03 -05:00
parent 1108760f48
commit 55954fed5f
7 changed files with 946 additions and 0 deletions

View file

@ -0,0 +1,290 @@
package WebGUI::Asset::EMSSubmission;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use Tie::IxHash;
use base 'WebGUI::Asset';
use WebGUI::Utility;
# TODO add AssetAspect::Comment;
# To get an installer for your wobject, add the Installable AssetAspect
# See WebGUI::AssetAspect::Installable and sbin/installClass.pl for more
# details
=head1 NAME
Package WebGUI::Asset::EMSSubmission
=head1 DESCRIPTION
Describe your New Asset's functionality and features here.
=head1 SYNOPSIS
use WebGUI::Asset::EMSSubmission;
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 addRevision
This method exists for demonstration purposes only. The superclass
handles revisions to NewAsset Assets.
=cut
#sub addRevision {
# my $self = shift;
# my $newSelf = $self->SUPER::addRevision(@_);
# return $newSelf;
#}
#-------------------------------------------------------------------
=head2 definition ( session, definition )
defines asset properties for New Asset instances. You absolutely need
this method in your new Assets.
=head3 session
=head3 definition
A hash reference passed in from a subclass definition.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" );
my $EMS_i18n = WebGUI::International->new($session, "Asset_EventManagementSystem");
tie my %properties, 'Tie::IxHash', (
submissionId => {
noFormPost => 1,
fieldType => "hidden",
defaultValue => undef,
},
price => {
tab => "shop",
fieldType => "float",
defaultValue => 0.00,
label => $EMS_i18n->get("price"),
hoverHelp => $EMS_i18n->get("price help"),
},
seatsAvailable => {
tab => "shop",
fieldType => "integer",
defaultValue => 25,
label => $EMS_i18n->get("seats available"),
hoverHelp => $EMS_i18n->get("seats available help"),
},
startDate => {
noFormPost => 1,
fieldType => "hidden",
defaultValue => $date->toDatabase,
label => $EMS_i18n->get("add/edit event start date"),
hoverHelp => $EMS_i18n->get("add/edit event start date help"),
autoGenerate => 0,
},
duration => {
tab => "properties",
fieldType => "float",
defaultValue => 1.0,
subtext => $EMS_i18n->get('hours'),
label => $EMS_i18n->get("duration"),
hoverHelp => $EMS_i18n->get("duration help"),
},
location => {
fieldType => "combo",
tab => "properties",
customDrawMethod=> 'drawLocationField',
label => $EMS_i18n->get("location"),
hoverHelp => $EMS_i18n->get("location help"),
},
relateBadgeGroup => {
tab => "properties",
fieldType => "checkList",
customDrawMethod=> 'drawRelatedBadgeGroupsField',
label => $EMS_i18n->get("related badge groups"),
hoverHelp => $EMS_i18n->get("related badge groups ticket help"),
},
relateRibbons => {
tab => "properties",
fieldType => "checkList",
customDrawMethod=> 'drawRelatedRibbonsField',
label => $EMS_i18n->get("related ribbons"),
hoverHelp => $EMS_i18n->get("related ribbons help"),
},
eventMetaData => {
noFormPost => 1,
fieldType => "hidden",
defaultValue => '{}',
},
sendEmailOnChange => {
tab => "properties",
fieldType => "text",
defaultValue => undef,
label => $i18n->get("foo label"),
hoverHelp => $i18n->get("foo label help")
},
);
push @{$definition}, {
assetName => $i18n->get('assetName'),
icon => 'EMSSubmission.gif',
autoGenerateForms => 1,
tableName => 'EMSSubmission',
className => 'WebGUI::Asset::EMSSubmission',
properties => \%properties,
};
return $class->SUPER::definition( $session, $definition );
} ## end sub definition
#-------------------------------------------------------------------
=head2 duplicate
This method exists for demonstration purposes only. The superclass
handles duplicating NewAsset Assets. This method will be called
whenever a copy action is executed
=cut
#sub duplicate {
# my $self = shift;
# my $newAsset = $self->SUPER::duplicate(@_);
# return $newAsset;
#}
#-------------------------------------------------------------------
=head2 indexContent ( )
Making private. See WebGUI::Asset::indexContent() for additonal details.
=cut
sub indexContent {
my $self = shift;
my $indexer = $self->SUPER::indexContent;
$indexer->setIsPublic(0);
}
#-------------------------------------------------------------------
=head2 prepareView ( )
See WebGUI::Asset::prepareView() for details.
=cut
sub prepareView {
my $self = shift;
$self->SUPER::prepareView();
my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateId") );
$template->prepare($self->getMetaDataAsTemplateVariables);
$self->{_viewTemplate} = $template;
}
#-------------------------------------------------------------------
=head2 processPropertiesFromFormPost ( )
Used to process properties from the form posted. Do custom things with
noFormPost fields here, or do whatever you want. This method is called
when /yourAssetUrl?func=editSave is requested/posted.
=cut
sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
}
#-------------------------------------------------------------------
=head2 purge ( )
This method is called when data is purged by the system.
removes collateral data associated with a NewAsset when the system
purges it's data. This method is unnecessary, but if you have
auxiliary, ancillary, or "collateral" data or files related to your
asset instances, you will need to purge them here.
=cut
#sub purge {
# my $self = shift;
# return $self->SUPER::purge;
#}
#-------------------------------------------------------------------
=head2 purgeRevision ( )
This method is called when data is purged by the system.
=cut
sub purgeRevision {
my $self = shift;
return $self->SUPER::purgeRevision;
}
#-------------------------------------------------------------------
=head2 view ( )
method called by the container www_view method.
=cut
sub view {
my $self = shift;
my $var = $self->get; # $var is a hash reference.
$var->{controls} = $self->getToolbar;
return $self->processTemplate( $var, undef, $self->{_viewTemplate} );
}
#-------------------------------------------------------------------
=head2 www_edit ( )
Web facing method which is the default edit page. Unless the method needs
special handling or formatting, it does not need to be included in
the module.
=cut
sub www_edit {
my $self = shift;
my $session = $self->session;
return $session->privilege->insufficient() unless $self->canEdit;
return $session->privilege->locked() unless $self->canEditIfLocked;
my $i18n = WebGUI::International->new( $session, 'Asset_EMSSubmission' );
return $self->getAdminConsole->render( $self->getEditForm->print, $i18n->get('edit asset') );
}
1;
#vim:ft=perl

View file

@ -0,0 +1,257 @@
package WebGUI::Asset::EMSSubmissionForm;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use Tie::IxHash;
use base 'WebGUI::Asset';
use WebGUI::Utility;
# TODO:
# To get an installer for your wobject, add the Installable AssetAspect
# See WebGUI::AssetAspect::Installable and sbin/installClass.pl for more
# details
=head1 NAME
Package WebGUI::Asset::EMSSubmissionForm
=head1 DESCRIPTION
This Asset describes and builds a form which provides an interface for submitting a custom
subset of the EMSTicket asset. Users create submissions which can be editted by admins
and then become EMSTicket's.
=head1 SYNOPSIS
use WebGUI::Asset::EMSSubmissionForm;
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 addRevision
This method exists for demonstration purposes only. The superclass
handles revisions to NewAsset Assets.
=cut
#sub addRevision {
# my $self = shift;
# my $newSelf = $self->SUPER::addRevision(@_);
# return $newSelf;
#}
#-------------------------------------------------------------------
=head2 definition ( session, definition )
defines asset properties for New Asset instances. You absolutely need
this method in your new Assets.
=head3 session
=head3 definition
A hash reference passed in from a subclass definition.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" );
tie my %properties, 'Tie::IxHash', (
nextSubmissionId => {
tab => "properties",
fieldType => "integer",
defaultValue => 0,
label => $i18n->get("next submission id label"),
hoverHelp => $i18n->get("next submission id label help")
},
canSubmitGroup => {
tab => "security",
fieldType => "groupid",
defaultValue => undef,
label => $i18n->get("can submit group label"),
hoverHelp => $i18n->get("can submit group label help")
},
daysBeforeCleanup => {
tab => "properties",
fieldType => "integer",
defaultValue => 7,
label => $i18n->get("days before cleanup label"),
hoverHelp => $i18n->get("days before cleanup label help")
},
deleteCreatedItems => {
tab => "properties",
fieldType => "yesno",
defaultValue => 'no',
label => $i18n->get("delete created items label"),
hoverHelp => $i18n->get("delete created items label help")
},
formDescription => {
tab => "properties",
fieldType => "text",
defaultValue => undef,
label => $i18n->get("form dscription label"),
hoverHelp => $i18n->get("form dscription label help")
},
);
push @{$definition}, {
assetName => $i18n->get('assetName'),
icon => 'EMSSubmissionForm.gif',
autoGenerateForms => 1,
tableName => 'EMSSubmissionForm',
className => 'WebGUI::Asset::EMSSubmissionForm',
properties => \%properties,
};
return $class->SUPER::definition( $session, $definition );
} ## end sub definition
#-------------------------------------------------------------------
=head2 duplicate
This method exists for demonstration purposes only. The superclass
handles duplicating NewAsset Assets. This method will be called
whenever a copy action is executed
=cut
#sub duplicate {
# my $self = shift;
# my $newAsset = $self->SUPER::duplicate(@_);
# return $newAsset;
#}
#-------------------------------------------------------------------
=head2 indexContent ( )
Making private. See WebGUI::Asset::indexContent() for additonal details.
=cut
sub indexContent {
my $self = shift;
my $indexer = $self->SUPER::indexContent;
$indexer->setIsPublic(0);
}
#-------------------------------------------------------------------
=head2 prepareView ( )
See WebGUI::Asset::prepareView() for details.
=cut
sub prepareView {
my $self = shift;
$self->SUPER::prepareView();
my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateId") );
$template->prepare($self->getMetaDataAsTemplateVariables);
$self->{_viewTemplate} = $template;
}
#-------------------------------------------------------------------
=head2 processPropertiesFromFormPost ( )
Used to process properties from the form posted. Do custom things with
noFormPost fields here, or do whatever you want. This method is called
when /yourAssetUrl?func=editSave is requested/posted.
=cut
sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
}
#-------------------------------------------------------------------
=head2 purge ( )
This method is called when data is purged by the system.
removes collateral data associated with a NewAsset when the system
purges it's data. This method is unnecessary, but if you have
auxiliary, ancillary, or "collateral" data or files related to your
asset instances, you will need to purge them here.
=cut
#sub purge {
# my $self = shift;
# return $self->SUPER::purge;
#}
#-------------------------------------------------------------------
=head2 purgeRevision ( )
This method is called when data is purged by the system.
=cut
sub purgeRevision {
my $self = shift;
return $self->SUPER::purgeRevision;
}
#-------------------------------------------------------------------
=head2 view ( )
method called by the container www_view method.
=cut
sub view {
my $self = shift;
my $var = $self->get; # $var is a hash reference.
$var->{controls} = $self->getToolbar;
return $self->processTemplate( $var, undef, $self->{_viewTemplate} );
}
#-------------------------------------------------------------------
=head2 www_edit ( )
Web facing method which is the default edit page. Unless the method needs
special handling or formatting, it does not need to be included in
the module.
=cut
sub www_edit {
my $self = shift;
my $session = $self->session;
return $session->privilege->insufficient() unless $self->canEdit;
return $session->privilege->locked() unless $self->canEditIfLocked;
my $i18n = WebGUI::International->new( $session, 'Asset_EMSSubmissionForm' );
return $self->getAdminConsole->render( $self->getEditForm->print, $i18n->get('edit asset') );
}
1;
#vim:ft=perl

View file

@ -0,0 +1,98 @@
package WebGUI::Workflow::Activity::CleanupEMSSubmissions;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2008 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::Asset;
=head1 NAME
Package WebGUI::Workflow::Activity::CleanupEMSSubmissions
=head1 DESCRIPTION
Uses the settings in the help desk to determine whether the resolved tickets should be closed or not.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
push(@{$definition}, {
name => "Cleanup EMS Submissions", # TODO internationalize
properties => {}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $session = $self->session;
my $root = WebGUI::Asset->getRoot($session);
my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'");
while (my ($assetId) = $sth->array) {
my $hd = WebGUI::Asset->new($session,$assetId,"WebGUI::Asset::Wobject::HelpDesk");
next unless defined $hd;
my $closeAfter = $hd->get("closeTicketsAfter");
my $rules = {};
$rules->{'joinClass' } = "WebGUI::Asset::Ticket";
$rules->{'whereClause' } = qq{Ticket.ticketStatus = 'resolved' and (Ticket.resolvedDate + $closeAfter <= UNIX_TIMESTAMP(NOW()))};
$rules->{'includeOnlyClasses'} = ['WebGUI::Asset::Ticket'];
$rules->{'returnObjects' } = 1;
my $tickets = $hd->getLineage(['children'], $rules);
foreach my $ticket (@{$tickets}) {
$ticket->setStatus("closed");
}
}
return $self->COMPLETE;
}
1;

View file

@ -0,0 +1,98 @@
package WebGUI::Workflow::Activity::ProcessEMSApprovals;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2008 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::Asset;
=head1 NAME
Package WebGUI::Workflow::Activity::ProcessEMSApprovals
=head1 DESCRIPTION
Uses the settings in the help desk to determine whether the resolved tickets should be closed or not.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
push(@{$definition}, {
name => "Process Approved EMS Submissions", # TODO Internationalize
properties => {}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $session = $self->session;
my $root = WebGUI::Asset->getRoot($session);
my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'");
while (my ($assetId) = $sth->array) {
my $hd = WebGUI::Asset->new($session,$assetId,"WebGUI::Asset::Wobject::HelpDesk");
next unless defined $hd;
my $closeAfter = $hd->get("closeTicketsAfter");
my $rules = {};
$rules->{'joinClass' } = "WebGUI::Asset::Ticket";
$rules->{'whereClause' } = qq{Ticket.ticketStatus = 'resolved' and (Ticket.resolvedDate + $closeAfter <= UNIX_TIMESTAMP(NOW()))};
$rules->{'includeOnlyClasses'} = ['WebGUI::Asset::Ticket'];
$rules->{'returnObjects' } = 1;
my $tickets = $hd->getLineage(['children'], $rules);
foreach my $ticket (@{$tickets}) {
$ticket->setStatus("closed");
}
}
return $self->COMPLETE;
}
1;

View file

@ -0,0 +1,67 @@
package WebGUI::i18n::English::_i18n; ##Be sure to change the package name to match the filename
use strict; ##Required for all good Perl::Critic compliant code
our $I18N = { ##hashref of hashes
'next submission id label' => {
message => q|Next Submission Id|,
lastUpdated => 1131394072,
context => q|Label for the field which indicates the next id used to create a submission.|
},
'next submission id label help' => {
message => q|This is the value that will be used to fill in the first submission, do not edit it.|,
lastUpdated => 1131394072,
context => q|This is the help text for the 'next submission id' field, the user should be reminded not to edit this field.|
},
'can submit group label' => {
message => q|User Group Allowed to create Submissions|,
lastUpdated => 1131394072,
context => q|This label is for the field which indicates what user group will be allowed to submit items using this form.|
},
'can submit group label help' => {
message => q|Select a user group which will be allowed to submit items using this form.|,
lastUpdated => 1131394072,
context => q|This is the help text for the field which indicates a user group which has permissions to use this form.|
},
'days before cleanup label' => {
message => q|Number of days before cleanup|,
lastUpdated => 1131394072,
context => q|This is the label for the number of days before the cleanup job deletes old items from the submission queue.|
},
'days before cleanup label help' => {
message => q|Enter the number of days you wish for old items to remain on the queue before they are deleted. Enter '0'(zero) to never delete anything fromt he queue. Also make sure the EMSCleanup Activity is assigned to a workflow that runs on a regular basis.|,
lastUpdated => 1131394072,
context => q|This is the help text for the 'days before cleanup' field. Be sure to remind the user that zero indicates no rows are deleted and that the EMSCleanup Activity needs to run for rows to be deleted.|
},
'delete created items label' => {
message => q|Delete Created Items?|,
lastUpdated => 1131394072,
context => q|This is the label for the 'delete created items' field. The value will indicate if the EMSCleanup will delete items that have been converted to EMSTicket assets.|
},
'delete created items label help' => {
message => q|Set this to 'Yes' if you want submissions to be deleted after they have been converted into EMSTisket assets.|,
lastUpdated => 1131394072,
context => q|This is the help text for the delete created items field, if it is set to yes the EMSCleanup activity will delete approved items after EMSTickets have been created from them. This field depends on the 'days before cleanup' field and the EMSCleanup activity also.|
},
'form dscription label' => {
message => q|Form Description|,
lastUpdated => 1131394072,
context => q|The label for the form description field. Contains JSON text that descibes te form the user sees when they submit an item.|
},
'form dscription label help' => {
message => q|This JSON text describes the form which will be built for the user when they create a submission to this EMS. It is not a good idea to edit this unless you ~really~ know what you are doing.|,
lastUpdated => 1131394072,
context => q|This help text is for the form description field. The user should be warned not to edit it unless they really know what they are doing.|
},
# 'TODO' => {
# message => q|TODO|,
# lastUpdated => 1131394072,
# context => q|TODO|
# },
};
1;
#vim:ft=perl