diff --git a/docs/upgrades/upgrade_7.7.20-7.8.0.pl b/docs/upgrades/upgrade_7.7.20-7.8.0.pl index 55b01d88e..680235d48 100644 --- a/docs/upgrades/upgrade_7.7.20-7.8.0.pl +++ b/docs/upgrades/upgrade_7.7.20-7.8.0.pl @@ -35,7 +35,6 @@ reorganizeAdSpaceProperties($session); addSubscribableAspect( $session ); addFeaturedPageWiki( $session ); fixEmptyCalendarIcalFeeds( $session ); -addEMSSubmission( $session ); finish($session); # this line required @@ -120,59 +119,6 @@ sub fixEmptyCalendarIcalFeeds { print "DONE!\n" unless $quiet; } -#---------------------------------------------------------------------------- -# Add tables for the EMS Submission feature -sub addEMSSubmission { - my $session = shift; - print "\tAdding EMS Submission feature..." unless $quiet; - - $session->db->write( <<'ESQL' ); -CREATE TABLE EMSSubmissionForm ( - assetId CHAR(22) BINARY NOT NULL, - revisionDate BIGINT NOT NULL, - nextSubmissionId INT, - canSubmitGroupId CHAR(22) BINARY, - daysBeforeCleanup INT, - deleteCreatedItems INT(1), - formDescription TEXT, - PRIMARY KEY ( assetId, revisionDate ) -) -ESQL - - $session->db->write( <<'ESQL' ); -CREATE TABLE EMSSubmission ( - assetId CHAR(22) BINARY NOT NULL, - revisionDate BIGINT NOT NULL, - submissionId INT NOT NULL, - price FLOAT, - seatsAvailable INT, - startDate DATETIME, - duration FLOAT, - eventNumber INT, - location CHAR(100), - relatedBadgeGroups MEDIUMTEXT, - relatedRibbons MEDIUMTEXT, - eventMetaData MEDIUMTEXT, - sendEmailOnChange INT(1), - PRIMARY KEY ( assetId, revisionDate ) -) -ESQL - - $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLUMN eventSubmissionTemplateId CHAR(22) BINARY; }); - - $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLUMN viewEventSubmissionQueueTemplateId CHAR(22) BINARY; }); - - $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLUMN editEventSubmissionTemplateId CHAR(22) BINARY; }); - - $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLUMN eventSubmissionGroups MEDIUMTEXT; }); - - print "DONE!\n" unless $quiet; -} - #---------------------------------------------------------------------------- # Add the column for featured wiki pages sub addFeaturedPageWiki { diff --git a/lib/WebGUI/Asset/EMSSubmission.pm b/lib/WebGUI/Asset/EMSSubmission.pm deleted file mode 100644 index a5489feea..000000000 --- a/lib/WebGUI/Asset/EMSSubmission.pm +++ /dev/null @@ -1,717 +0,0 @@ -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 Class::C3; -use strict; -use Tie::IxHash; -use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset); -use WebGUI::Utility; -use WebGUI::Inbox; - -=head1 NAME - -Package WebGUI::Asset::EMSSubmission - -=head1 DESCRIPTION - -Describe your New Asset's functionality and features here. - -=head1 SYNOPSIS - -use WebGUI::Asset::EMSSubmission; - -=head1 TODO - -the comments tab may need to be added in a getEditForm function like Sku::EMSTicket - -make a button/link for the admin to view the submission as the owner sees it. - -the www_edit function should see if the userid is the owner and call a seperate function -else if it is not in the admin group return insufitient priviledges -else call the getEditForm function like sku::EMSTicket does... - - -=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->next::method(@_); -# 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"); - my $SKU_i18n = WebGUI::International->new($session, "Asset_Sku"); - tie my %properties, 'Tie::IxHash', ( - submissionId => { - noFormPost => 1, - fieldType => "hidden", - defaultValue => undef, - }, - submissionStatus => { - fieldType =>"selectList", - defaultValue => 'pending', - customDrawMethod=> 'drawStatusField', - label => $i18n->get("submission status"), - hoverHelp => $i18n->get("submission status help") - }, - description => { - tab => "properties", - fieldType => "HTMLArea", - defaultValue => undef, - label => $SKU_i18n->get("description"), - hoverHelp => $SKU_i18n->get("description help") - }, - sku => { - tab => "shop", - fieldType => "text", - defaultValue => $session->id->generate, - label => $SKU_i18n->get("sku"), - hoverHelp => $SKU_i18n->get("sku help") - }, - displayTitle => { - tab => "display", - fieldType => "yesNo", - defaultValue => 1, - label => $SKU_i18n->get("display title"), - hoverHelp => $SKU_i18n->get("display title help") - }, - vendorId => { - tab => "shop", - fieldType => "vendor", - defaultValue => 'defaultvendor000000000', - label => $SKU_i18n->get("vendor"), - hoverHelp => $SKU_i18n->get("vendor help") - }, - shipsSeparately => { - tab => 'shop', - fieldType => 'yesNo', - defaultValue => 0, - label => $SKU_i18n->get('shipsSeparately'), - hoverHelp => $SKU_i18n->get('shipsSeparately help'), - }, - - 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 => "dateTime", - defaultValue => '', - 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"), - }, - relatedBadgeGroups => { - tab => "properties", - fieldType => "checkList", - customDrawMethod=> 'drawRelatedBadgeGroupsField', - label => $EMS_i18n->get("related badge groups"), - hoverHelp => $EMS_i18n->get("related badge groups ticket help"), - }, - relatedRibbons => { - 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 => "yesNo", - defaultValue => 1, - label => $i18n->get("send email label"), - hoverHelp => $i18n->get("send email label help") - }, - ticketId => { - noFormPost => 1, - fieldType => "hidden", - defaultValue => '', - }, - ); - push @{$definition}, { - assetName => $i18n->get('assetName'), - icon => 'EMSSubmission.gif', - autoGenerateForms => 1, - tableName => 'EMSSubmission', - className => 'WebGUI::Asset::EMSSubmission', - properties => \%properties, - }; - return $class->next::method( $session, $definition ); -} ## end sub definition - -#------------------------------------------------------------------- - -=head2 drawLocationField () - -Draws the field for the location property. - -=cut - -sub drawLocationField { - my ($self, $params) = @_; - my $ems = $self->ems; - my $options = { map { $_ => $_ } ( @{ $ems->getSubmissionLocations || [ $ems->getLocations ] } ) } ; - if( $ems->isRegistrationStaff ) { - return WebGUI::Form::combo($self->session, { - name => 'location', - value => $self->get('location'), - options => $options, - }); - } else { - return WebGUI::Form::selectBox($self->session, { - name => 'location', - value => $self->get('location'), - options => $options, - }); - } -} - -#------------------------------------------------------------------- - -=head2 drawRelatedBadgeGroupsField () - -Draws the field for the relatedBadgeGroups property. - -=cut - -sub drawRelatedBadgeGroupsField { - my ($self, $params) = @_; - return WebGUI::Form::checkList($self->session, { - name => $params->{name}, - value => $self->get($params->{name}), - vertical => 1, - options => $self->getParent->getParent->getBadgeGroups, - }); -} - -#------------------------------------------------------------------- - -=head2 drawRelatedRibbonsField () - -Draws the field for the relatedRibbons property. - -=cut - -sub drawRelatedRibbonsField { - my ($self, $params) = @_; - my %ribbons = (); - foreach my $ribbon (@{$self->getParent->getParent->getRibbons}) { - $ribbons{$ribbon->getId} = $ribbon->getTitle; - } - return WebGUI::Form::checkList($self->session, { - name => $params->{name}, - value => $self->get($params->{name}), - vertical => 1, - options => \%ribbons, - }); -} - -#------------------------------------------------------------------- - -=head2 drawStatusField - -=cut - -sub drawStatusField { - my ($self, $params) = @_; - return WebGUI::Form::SelectBox($self->session, { - name => 'submissionStatus', - value => $self->get('submissionStatus'), - options => $self->ems->getSubmissionStatus, - }); -} - - -#------------------------------------------------------------------- - -=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->next::method(@_); -# return $newAsset; -#} - -#------------------------------------------------------------------- - -=head2 ems - -returns the ems ansestor of this asset - -=cut - -sub ems { - my $self = shift; - $self->getParent->getParent -} - -#------------------------------------------------------------------- - -=head2 sendEmailUpdate - -if the sendEmail on change is turned on then send email to the owner - -=cut - -sub sendEmailUpdate { - my $self = shift; - my $session = $self->session; - my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" ); - if( $self->get('sendEmailOnChange') ) { - WebGUI::Inbox->new($session)->addMessage( $session,{ - status => 'unread', - message => $i18n->get('your submission has been updated') . "\n\n" . - $self->get('title'), - userId => $self->get('createdBy'), - sentBy => $session->user->userId, - }); - } -} - -#------------------------------------------------------------------- - -=head2 www_editSubmission ( parent, params ) - -edit a submission - -=head3 parent - -ref to the EMSSubmissionForm that is parent to the new submission - -=head3 params - -parameters for the submission - -=cut - -sub www_editSubmission { - my $this = shift; - my $self; - my $parent; - if( $this eq __PACKAGE__ ) { # called as a constructor - $parent = shift; - } else { - $self = $this; - $parent = $self->getParent; - } - my $params = shift || { }; - my $session = $parent->session; - my $i18n = WebGUI::International->new($parent->session,'Asset_EventManagementSystem'); - my $i18n_WG = WebGUI::International->new($parent->session,'WebGUI'); - my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId') || 'new'; - - if( $assetId ne 'new' ) { - $self ||= WebGUI::Asset->newByDynamicClass($session,$assetId); - if (!defined $self) { - $session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId"); - } - } - my $asset = $self || $parent; - my $url = $asset->getUrl('func=editSubmissionSave'); - my $newform = WebGUI::HTMLForm->new($session,action => $url); - $newform->hidden(name => 'assetId', value => $assetId); - my $formDescription = $parent->getFormDescription; - my @defs = reverse @{__PACKAGE__->definition($session)}; - my @fieldNames = qw/title submissionStatus startDate duration seatsAvailable location description/; - my $fields; - for my $def ( @defs ) { - my $properties = $def->{properties}; - for my $fieldName ( %$properties ) { - if( defined $formDescription->{$fieldName} ) { - $fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy - if( $fieldName eq 'description' ) { - $fields->{description}{height} = 200; - $fields->{description}{width} = 350; - } - $fields->{$fieldName}{fieldId} = $fieldName; - $fields->{$fieldName}{name} = $fieldName; - $fields->{$fieldName}{value} = $self->get($fieldName) if $self; - } - } - } - # add the meta field - for my $metaField ( @{$parent->getParent->getEventMetaFields} ) { - my $fieldId = $metaField->{fieldId}; - if( defined $formDescription->{$fieldId} ) { - push @fieldNames, $fieldId; - $fields->{$fieldId} = { %$metaField }; # a simple first level copy - # meta fields call it data type, we copy it to simplify later on - $fields->{$fieldId}{fieldType} = $metaField->{dataType}; - $fields->{$fieldId}{name} = $fieldId; - $fields->{$fieldId}{value} = $self->get($fieldId) if $self; - } - } - - # for each field - for my $fieldId ( @fieldNames ) { - my $field = $fields->{$fieldId}; - if( $formDescription->{$field->{fieldId}} || $asset->ems->isRegistrationStaff ) { - my $drawMethod = __PACKAGE__ . '::' . $field->{customDrawMethod}; - if ($asset->can( $drawMethod )) { - $field->{value} = $asset->$drawMethod($field); - delete $field->{name}; # don't want readOnly to generate a hidden field - $field->{fieldType} = "readOnly"; - } - - $newform->dynamicField(%$field); - } else { - # TODO see that the data gets formatted - $newform->readOnly( - label => $field->{label}, - value => $field->{value} || '[ ]', - fieldId => $field->{fieldId}, - ); - } - } - $newform->submit; - my $title = $assetId eq 'new' ? $i18n_WG->get(99) : $asset->get('title'); - my $content = $asset->processStyle( - $asset->processTemplate({ - errors => $params->{errors} || [], - backUrl => $parent->getUrl, - pageTitle => $title, - pageForm => $newform->print, - commentForm => $self ? $self->getFormattedComments : '', - commentFlag => $self ? 1 : 0 , - },$parent->getParent->get('eventSubmissionTemplateId'))); - WebGUI::Macro::process( $session, \$content ); - if( $session->form->get('asJson') ) { - $session->http->setMimeType( 'application/json' ); - return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } ); - } else { - $session->http->setMimeType( 'text/html' ); - return $content; - } -} - -#------------------------------------------------------------------- - -=head2 www_editSubmissionSave - -=cut - -sub www_editSubmissionSave { - my $self = shift; - my $session = $self->session; - return $session->privilege->insufficient() unless $self->canEdit; - my $formParams = $self->processForm; - if( $formParams->{_isValid} ) { - delete $formParams->{_isValid}; - $self->addRevision($formParams); - WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { override => 1, allowComments => 0 }); - $self = $self->cloneFromDb; - $self->sendEmailUpdate; - return $self->ems->www_viewSubmissionQueue; - } else { - return $self->www_editSubmission($formParams); - } -} - -#------------------------------------------------------------------- - -=head2 www_view - -calles ems->view - -=cut - -sub www_view { $_[0]->ems->www_viewSubmissionQueue } - -#------------------------------------------------------------------- - -=head2 getEditForm ( ) - -Extends the base class to add Tax information for the Sku, in a new tab. - -=cut - -sub getEditForm { - my $self = shift; - my $session = $self->session; - - my $tabform = $self->SUPER::getEditForm; - - my $comments = $tabform->getTab( 'comments' ); - - #add the comments... - # TODO once comments can be submitted using AJAX this will work... -# $comments->div({name => 'comments', -# contentCallback => sub { $self->getFormattedComments }, -# }); - - return $tabform; -} - -#------------------------------------------------------------------- - -=head2 getEditTabs ( ) - -defines 2 new tabs. -the shop tab is created here to mimic the function of the sku-created -shop tab. this class holds data like Sku assets so that they can be assigned -in the future when the sku asset is created from this data. - -=cut - -sub getEditTabs { - my $self = shift; - my $i18n = WebGUI::International->new($self->session,"Asset_EMSSubmission"); - my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku"); - return ($self->SUPER::getEditTabs(), ['shop', $sku_i18n->get('shop'), 9], ['comments', $i18n->get('comments'), 9]); -} - -#------------------------------------------------------------------- - -=head2 getQueueUrl - -returns the URL for the submission queue page with the submisison id in the hash part - -=cut - -sub getQueueUrl { - my $self = shift; - return $self->ems->getUrl('func=viewSubmissionQueue#' . $self->get('submissionId') ); -} - -#------------------------------------------------------------------- - -=head2 indexContent ( ) - -Making private. See WebGUI::Asset::indexContent() for additonal details. - -=cut - -sub indexContent { - my $self = shift; - my $indexer = $self->next::method; - $indexer->setIsPublic(0); -} - -#------------------------------------------------------------------- - -=head2 prepareView ( ) - -See WebGUI::Asset::prepareView() for details. - -=cut - -sub prepareView { - my $self = shift; - $self->ems->prepareView; - #$self->next::method(); - #my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateId") ); - #$template->prepare($self->getMetaDataAsTemplateVariables); - #$self->{_viewTemplate} = $template; -} - -#---------------------------------------------------------------- - -=head2 processForm ( $parent ) - -pull data componenets out of $session->form - -=head3 parent - -reference to the EMS asset that is parent to the new submission form asset - -=cut - - -sub processForm { - my $this = shift; - my $form; - my $asset; - my $parent; - my $self; - if( $this eq __PACKAGE__ ) { - $parent = shift; - $form = $parent->session->form; - $asset = $parent; - } else { - $self = $this; - $parent = $self->getParent; - $form = $self->session->form; - $asset = $self; - } - my $params = {_isValid=>1}; - my $formDescription = $parent->getFormDescription; - my @idList; - if( $asset->ems->isRegistrationStaff ) { - @idList = ( 'submissionStatus', keys %$formDescription ); - } else { - @idList = @{$formDescription->{_fieldList}} ; - } - for my $fieldId ( @idList ) { - next if $fieldId =~ /^_/; - $params->{$fieldId} = $form->get($fieldId); - } - return $params; -} - -#------------------------------------------------------------------- - -=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->next::method; -} - -#------------------------------------------------------------------- - -=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->next::method; -#} - -#------------------------------------------------------------------- - -=head2 purgeRevision ( ) - -This method is called when data is purged by the system. - -=cut - -#sub purgeRevision { -# my $self = shift; -# return $self->next::method; -#} - -#------------------------------------------------------------------- - -=head2 view ( ) - -method called by the container www_view method. -NOTE: this should net get called, all views are redirected elsewhere. - -=cut - -sub view { - my $self = shift; - return $self->ems->view; - #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 diff --git a/lib/WebGUI/Asset/EMSSubmissionForm.pm b/lib/WebGUI/Asset/EMSSubmissionForm.pm deleted file mode 100644 index ef93c2c2a..000000000 --- a/lib/WebGUI/Asset/EMSSubmissionForm.pm +++ /dev/null @@ -1,549 +0,0 @@ -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 JSON; -use WebGUI::Utility; - -=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 addSubmission - -Creates an EMSSubmission object based on the params -( called by www_saveSubmission ) - -=cut - -sub addSubmission { - my $self = shift; - my $form = $self->session->form; - my $newParams = {}; - my $fieldList = $self->getFormDescription->{_fieldList}; - for my $field ( @$fieldList ) { - $newParams->{$field} = $form->get($field); - } - $newParams->{className} = 'WebGUI::Asset::EMSSubmission'; - $newParams->{submissionStatus} = 'pending'; - $newParams->{submissionId} = $self->ems->getNextSubmissionId; - my $newAsset = $self->addChild($newParams); - WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, { override => 1, allowComments => 0 }); - $self = $self->cloneFromDb; - return $newAsset; -} - -#------------------------------------------------------------------- - -=head2 addRevision - -This me>thod 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 canSubmit - -returns true if current user can submit using this form - -=cut - -sub canSubmit { - my $self = shift; - - return $self->session->user->isInGroup($self->get('canSubmitGroupId')); -} - -#------------------------------------------------------------------- - -=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', ( - canSubmitGroupId => { - tab => "security", - fieldType => "group", - defaultValue => 2, - 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 => undef, - label => $i18n->get("delete created items label"), - hoverHelp => $i18n->get("delete created items label help") - }, - submissionDeadline => { - tab => "properties", - fieldType => "Date", - defaultValue => '677496912', # far in the future... - label => $i18n->get("submission deadline label"), - hoverHelp => $i18n->get("submission deadline label help") - }, - pastDeadlineMessage => { - tab => "properties", - fieldType => "HTMLArea", - defaultValue => $i18n->get('past deadline message'), - label => $i18n->get("past deadline label"), - hoverHelp => $i18n->get("past deadline label help") - }, - formDescription => { - tab => "properties", - fieldType => "textarea", - defaultValue => '{ }', - 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 ems - -returns the ems ansestor of this asset - -=cut - -sub ems { - my $self = shift; - $self->getParent -} - -#------------------------------------------------------------------- - -=head2 www_editSubmissionForm ( [ parent, ] [ params ] ) - -create an html form for user to enter params for a new submissionForm asset - -=head3 parent - -the parent ems object -- needs to be passed only if this is a class level call - -=head3 params - -optional set of possibly incorrect submission form params - -=cut - -sub www_editSubmissionForm { - my $this = shift; - my $self; - my $parent; - if( $this eq __PACKAGE__ ) { # called as constructor or menu - $parent = shift; - } else { - $self = $this; - $parent = $self->getParent; - } - my $params = shift || { }; - my $session = $parent->session; - my $i18n = WebGUI::International->new($session,'Asset_EventManagementSystem'); - my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId'); - - if( ! defined( $assetId ) ) { - my $res = $parent->getLineage(['children'],{ returnObjects => 1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'], - } ); - if( scalar(@$res) == 1 ) { - $self = $res->[0]; - $assetId = $self->getId; - } else { - my $makeAnchorList =sub{ my $u=shift; my $n=shift; my $d=shift; - return qq{
  • $n
  • } } ; - my $listOfLinks = join '', ( map { - $makeAnchorList->( - $_->getQueueUrl, - $_->get('title'), - WebGUI::HTML::filter($_->get('description'),'all') - ) - } ( @$res ) ); - my $title = $i18n->get('select form to edit') ; - my $content = '

    ' . $title . '

    ' ; - if( $session->form->get('asJson') ) { - $session->http->setMimeType( 'application/json' ); - return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } ); - } else { - $session->http->setMimeType( 'text/html' ); - return $parent->ems->processStyle( $content ); - } - } - } elsif( $assetId ne 'new' ) { - $self ||= WebGUI::Asset->newByDynamicClass($session,$assetId); - if (!defined($self)) { - $session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId"); - } - } - my $asset = $self || $parent; - my $url = $asset->getUrl('func=editSubmissionFormSave'); - my $newform = WebGUI::HTMLForm->new( $session, action => $url ); - $newform->hidden(name => 'assetId', value => $assetId); - my @fieldNames = qw/title description startDate duration seatsAvailable location/; - my $fields; - my @defs = reverse @{WebGUI::Asset::EMSSubmission->definition($session)}; - for my $def ( @defs ) { - foreach my $fieldName ( @fieldNames ) { - my $properties = $def->{properties}; - if( defined $properties->{$fieldName} ) { - $fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy - # field definitions don't contain their own name, we will need it later on - $fields->{$fieldName}{fieldId} = $fieldName; - }; - } - } - for my $metaField ( @{$parent->getEventMetaFields} ) { - push @fieldNames, $metaField->{fieldId}; - $fields->{$metaField->{fieldId}} = { %$metaField }; # a simple first level copy - # meta fields call it data type, we copy it to simplify later on - $fields->{$metaField->{fieldId}}{fieldType} = $metaField->{dataType}; - $fields->{$metaField->{fieldId}}{hoverHelp} = $metaField->{helpText}; - } - $newform->hidden( name => 'fieldNames', value => join( ' ', @fieldNames ) ); - @defs = reverse @{WebGUI::Asset::EMSSubmissionForm->definition($session)}; - for my $def ( @defs ) { - my $properties = $def->{properties}; - for my $fieldName ( qw/title menuTitle url description canSubmitGroupId daysBeforeCleanup - deleteCreatedItems submissionDeadline pastDeadlineMessage/ ) { - if( defined $properties->{$fieldName} ) { - my %fieldParams = %{$properties->{$fieldName}}; - $fieldParams{name} = $fieldName; - $fieldParams{value} = $params->{$fieldName} || $self ? $self->get($fieldName) : undef ; - $newform->dynamicField(%fieldParams); - } - } - } - - my $formDescription = $params->{formDescription} || $self ? $self->getFormDescription : { }; - for my $fieldId ( @fieldNames ) { - next if $fieldId eq 'submissionStatus'; - my $field = $fields->{$fieldId}; - $newform->yesNo( - label => $field->{label}, - name => $field->{fieldId} . '_yesNo', - defaultValue => 0, - value => $formDescription->{$field->{fieldId}}, - ); - } - $newform->submit; - my $title = $assetId eq 'new' ? $i18n->get('new form') || 'new' : $asset->get('title'); - if( $session->form->get('asJson') ) { - $session->http->setMimeType( 'application/json' ); - } else { - $session->http->setMimeType( 'text/html' ); - } - my $content = $asset->processTemplate({ - errors => $params->{errors} || [], - backUrl => $parent->getUrl, - pageTitle => $title, - pageForm => $newform->print, - },$parent->get('eventSubmissionTemplateId')); - WebGUI::Macro::process( $session, \$content ); - if( $session->form->get('asJson') ) { - return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } ); - } else { - return $asset->ems->processStyle( $content ); - } - -} - -#------------------------------------------------------------------- - -=head2 www_editSubmissionFormSave - -test and save new params - -=cut - -sub www_editSubmissionFormSave { - my $self = shift; - return $self->session->privilege->insufficient() unless $self->canEdit; - my $formParams = $self->processForm(); - if( $formParams->{_isValid} ) { - delete $formParams->{_isValid}; - $self->addRevision($formParams); - WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session); - $self = $self->cloneFromDb; - return $self->getParent->www_viewSubmissionQueue; - } else { - return $self->www_editSubmissionForm($formParams); - } -} - -#------------------------------------------------------------------- - -=head2 www_view - -calls ems->view - -=cut - -sub www_view { $_[0]->ems->www_viewSubmissionQueue } - - -#------------------------------------------------------------------- - -=head2 getFormDescription - -returns a hash ref decoded from the JSON in the form description field - -=cut - -sub getFormDescription { - my $self = shift; - return JSON->new->decode($self->get('formDescription')); -} - -#------------------------------------------------------------------- - -=head2 getQueueUrl - -returns the URL for the submission queue page with the submisison id in the hash part - -=cut - -sub getQueueUrl { - my $self = shift; - return $self->ems->getUrl('func=viewSubmissionQueue#' . $self->getId ); -} - - -#------------------------------------------------------------------- - -=head2 view ( ) - -method called by the container www_view method. -Note: this really shouldn't get called, all views are redirected elsewhere - -=cut - -sub view { - my $self = shift; - return $self->ems->view; - #my $var = $self->get; # $var is a hash reference. - #$var->{controls} = $self->getToolbar; - #return $self->processTemplate( $var, undef, $self->{_viewTemplate} ); -} - - -#---------------------------------------------------------------- - -=head2 www_addSubmission ( ) - -calls www_editSubmission with assetId == new - -=cut - -sub www_addSubmission { - my $self = shift; - $self->www_editSubmission( { assetId => 'new' } ); -} - -#------------------------------------------------------------------- - -=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') ); -} - -#------------------------------------------------------------------- - -=head2 www_editSubmission { params } - -calls WebGUI::Asset::EMSSubmission->editSubmission - -=cut - -sub www_editSubmission { - my $self = shift; - return $self->session->privilege->insufficient() unless $self->canEdit; - return WebGUI::Asset::EMSSubmission->www_editSubmission($self,shift); -} - -#------------------------------------------------------------------- - -=head2 www_editSubmissionSave - -validate and create a new submission - -=cut - -sub www_editSubmissionSave { - my $self = shift; - return $self->session->privilege->insufficient() unless $self->canEdit; - my $formParams = WebGUI::Asset::EMSSubmission->processForm($self); - if( $formParams->{_isValid} ) { - delete $formParams->{_isValid}; - $self->addSubmission($formParams); - return $self->getParent->www_viewSubmissionQueue; - } else { - return $self->www_editSubmission($formParams); - } -} - -#---------------------------------------------------------------- - -=head2 processForm ( $parent ) - -pull data componenets out of $session->form - -=head3 parent - -reference to the EMS asset that is parent to the new submission form asset - -=cut - - -sub processForm { - my $this = shift; - my $form; - my $session; - if( $this eq __PACKAGE__ ) { - my $parent = shift; - $session = $parent->session; - $form = $session->form; - } elsif( ref $this eq __PACKAGE__ ) { - $session = $this->session; - $form = $session->form; - } else { - return {_isValid => 0, errors => [ { text => 'invalid function call' } ] }; - } - my $params = {_isValid=>1}; - for my $fieldName ( qw/assetId title menuTitle url description canSubmitGroupId daysBeforeCleanup - deleteCreatedItems submissionDeadline pastDeadlineMessage/ ) { - $params->{$fieldName} = $form->get($fieldName); - } - my @fieldNames = split( ' ', $form->get('fieldNames') ); - $params->{formDescription} = { map { $_ => $form->get($_ . '_yesNo') } ( @fieldNames ) }; - $params->{formDescription}{_fieldList} = [ map { $params->{formDescription}{$_} ? $_ : () } ( @fieldNames ) ]; - $params->{formDescription}{submissionStatus} = 0; - if( scalar( @{$params->{formDescription}{_fieldList}} ) == 0 ) { - $params->{_isValid} = 0; - my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" ); - push @{$params->{errors}}, {text => $i18n->get('turn on one field') }; - } - return $params; -} - -#------------------------------------------------------------------- - -=head2 update ( ) - -We overload the update method from WebGUI::Asset in order to handle file system privileges. - -=cut - -sub update { - my $self = shift; - my $properties = shift; - if( ref $properties->{formDescription} eq 'HASH' ) { - $properties->{formDescription} = JSON->new->encode($properties->{formDescription}); - } - $self->SUPER::update({%$properties, isHidden => 1}); -} - -1; - -#vim:ft=perl diff --git a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm index f3e62db5a..3c38f7697 100644 --- a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm +++ b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm @@ -1,6 +1,5 @@ package WebGUI::Asset::Wobject::EventManagementSystem; - =head1 LEGAL ------------------------------------------------------------------- @@ -36,89 +35,6 @@ use WebGUI::Workflow::Instance; use Tie::IxHash; use Data::Dumper; -#------------------------------------------------------------------- - -=head2 addGroupToSubmitList ( groupId ) - -adds the parameter to eventSubmissionGroups - -=cut - -sub addGroupToSubmitList { - my $self = shift; - my $groupId = shift; - my ($idString) = $self->session->db->read('select eventSubmissionGroups from EventManagementSystem where assetId = ?', [ $self->getId ] )->array; - my @ids = split(' ', $idString); - my %h; - @ids = map { $h{$_}++ == 0 ? $_ : () } ( $groupId, @ids ); - $self->update({eventSubmissionGroups => join( ' ', @ids ) }); -} - -#------------------------------------------------------------------- - -=head2 addSubmissionForm - -creates a child of class WG::Asset::EMSSubmissionForm - -=head3 params - -parameters that define the form - -=head4 title - -the title for the form - -=head4 canSubmitGroupId ( optional ) - -group id for the users that are allowed to submit via this form -defaults to 2 -- registered users - -=head4 daysBeforeCleanup ( optional ) - -number fo days to leave denied/created status items in the database before deleting -defaults to 7 - -=head4 deleteCreatedItems ( optional ) - -1 indicates that items with status 'created' should be deleted as well as denied -default: 0 - -=head4 formDescription - -a JSON description of the form data fields -- a hash of the names of fields (each is 1 for active, 0 for inactive) plus -'_fieldList' added as an ARRAYREF of the fields that are active - -=cut - -sub addSubmissionForm { - my $self = shift; - my $params = shift; - $params->{className} = 'WebGUI::Asset::EMSSubmissionForm'; - $params->{canSubmitGroupId} ||= 2; - $self->addGroupToSubmitList($params->{canSubmitGroupId}); - my $newAsset = $self->addChild($params); - WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session); - $self = $self->cloneFromDb; - return $newAsset; -} - -#------------------------------------------------------------------- - -=head2 canSubmit - -returns true is the current user can submit to any form attached to this EMS - -=cut - -sub canSubmit { - my $self = shift; - my $user = $self->session->user; - return 0 if ! $self->hasSubmissionForms; - for my $groupId (split ' ', $self->get('eventSubmissionGroups')) { - return 1 if $user->isInGroup($groupId); - } - return 0; -} #------------------------------------------------------------------- sub definition { @@ -191,30 +107,6 @@ sub definition { hoverHelp => $i18n->get('print ticket template help'), namespace => 'EMS/PrintTicket', }, - eventSubmissionMainTemplateId => { - fieldType => 'template', - defaultValue => 'DoVNijm6lMDE0cYrtvEbDQ', - tab => 'display', - label => $i18n->get('event submission main template'), - hoverHelp => $i18n->get('event submission main template help'), - namespace => 'EMS/SubmissionMain', - }, - eventSubmissionTemplateId => { - fieldType => 'template', - defaultValue => '8tqyQx-LwYUHIWOlKPjJrA', - tab => 'display', - label => $i18n->get('event submission template'), - hoverHelp => $i18n->get('event submission template help'), - namespace => 'EMS/Submission', - }, - eventSubmissionQueueTemplateId => { - fieldType => 'template', - defaultValue => 'ktSvKU8riGimhcsxXwqvPQ', - tab => 'display', - label => $i18n->get('event submission queue template'), - hoverHelp => $i18n->get('event submission queue template help'), - namespace => 'EMS/SubmissionQueue', - }, printRemainingTicketsTemplateId => { fieldType => 'template', defaultValue => 'hreA_bgxiTX-EzWCSZCZJw', @@ -225,8 +117,8 @@ sub definition { }, badgeInstructions => { fieldType => 'HTMLArea', - defaultValue => $i18n->get('default badge instructions'), - tab => 'properties', + defaultValue => $i18n->get('default badge instructions'), + tab => 'properties', label => $i18n->get('badge instructions'), hoverHelp => $i18n->get('badge instructions help'), }, @@ -258,25 +150,6 @@ sub definition { label => $i18n->get('registration staff group'), hoverHelp => $i18n->get('registration staff group help'), }, - submittedLocationsList => { - fieldType => 'text', - tab => 'properties', - defaultValue => '', - label => $i18n->get('submitted location list label'), - hoverHelp => $i18n->get('submitted location list help'), - }, - eventSubmissionGroups => { - fieldType => 'hidden', - defaultValue => '', - noFormPost => 1, - }, - nextSubmissionId => { - tab => "properties", - fieldType => "integer", - defaultValue => 1, - label => $i18n->get("next submission id label"), - hoverHelp => $i18n->get("next submission id label help") - }, ); push(@{$definition}, { assetName=>$i18n->get('assetName'), @@ -305,21 +178,6 @@ sub deleteEventMetaField { } -#------------------------------------------------------------------- - -=head2 ems - -this is called by the submission sub-system -it is for compatability and ensures that the ems -object is used for certain calls - -=cut - -sub ems { - my $self = shift; - return $self; -} - #------------------------------------------------------------------- =head2 getBadges () @@ -418,7 +276,6 @@ sub getEventFieldsForImport { type => $field->{dataType}, options => $field->{possibleValues}, defaultValue => $field->{defaultValues}, - helpText => $field->{defaultValues}, }); } return \@fields; @@ -435,7 +292,7 @@ may be SQL optimized for quick access sub getLocations { my $self = shift; - my $dateRef = shift; + my $dateRef = shift || [ ]; my %hash; my %hashDate; @@ -444,30 +301,13 @@ sub getLocations { # this is a really compact 'uniq' operation my @locations = map { $h{$_}++ == 0 ? $_ : () } ( map { $_->get('location') } ( @$tickets ) ); # the dates have the time data removed with a pattern substitution - if( $dateRef ) { - push @$dateRef, map { s/\s*\d+:\d+(:\d+)?//; $h{$_}++ == 0 ? $_ : () } ( map { $_->get('startDate') } ( @$tickets ) ); - } + push @$dateRef, map { s/\s*\d+:\d+(:\d+)?//; $h{$_}++ == 0 ? $_ : () } ( map { $_->get('startDate') } ( @$tickets ) ); return @locations; } #------------------------------------------------------------------- -=head2 getNextSubmissionId - -get a sequence number for the submission id - -=cut - -sub getNextSubmissionId { - my $self = shift; - my ($submissionId) = $self->session->db->read('select nextSubmissionId from EventManagementSystem where assetId = ?', [ $self->getId ] )->array; - $self->update( { nextSubmissionId => ($submissionId + 1) } ); - return $submissionId; -} - -#------------------------------------------------------------------- - =head2 getRegistrant ( badgeId ) Returns a hash reference containing the properties of a registrant. @@ -498,49 +338,6 @@ sub getRibbons { #------------------------------------------------------------------- -=head2 getSubmissionLocations - -retuns an arrayref of the locations found in the submission location list - -=cut - -sub getSubmissionLocations { - my $self = shift; - my $text = $self->get('submittedLocationsList'); - return undef if $text eq ''; - return [ split( /\s+/, $text ) ]; -} - -#------------------------------------------------------------------- -sub getSubmissionStatus { - my $self = shift; - my $key = shift; - - unless ($self->{_status}) { - tie my %hash, "Tie::IxHash"; - my $i18n = $self->i18n; - for my $item ( - 'pending', - 'feedback', - 'denied', - 'approved', - 'created', - 'failed', - ) { - $hash{$item} = $i18n->get($item), - } - $self->{_status} = \%hash; - } - - if($key) { - return $self->{_status}{$key}; - } - - return $self->{_status}; -} - -#------------------------------------------------------------------- - =head2 getTickets () Returns an array reference of ticket objects. @@ -576,54 +373,6 @@ sub getTokens { #------------------------------------------------------------------- -=head2 hasSubmissionForms - -returns true if the EMS has subission forms attached - -=cut - -sub hasSubmissionForms { - my $self = shift; - # are there ~any~ forms attached to this ems? - my $res = $self->getLineage(['children'],{ limit => 1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'], - } ); - return scalar(@$res); -} - -#------------------------------------------------------------------- - -=head2 hasSubmissions - -returns true if the current user has submission forms in this EMS - -=cut - -sub hasSubmissions { - my $self = shift; - return 0 if ! $self->canSubmit; - my $res = $self->getLineage(['descendants'],{ limit => 1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'], - whereClause => q{createdBy='} . $self->session->user->userId . q/'/, - } ); - return scalar(@$res); -} - -#------------------------------------------------------------------- - -=head2 i18n - -returns the internationalisation object for this asset - -=cut - -sub i18n { - my $self = shift; - return $self->{_i18n} ||= WebGUI::International->new($self->session,'Asset_EventManagementSystem'); -} - -#------------------------------------------------------------------- - =head2 isRegistrationStaff ( [ user ] ) Returns a boolean indicating whether the user is a member of the registration staff. @@ -717,16 +466,9 @@ sub view { addBadgeUrl => $self->getUrl('func=add;class=WebGUI::Asset::Sku::EMSBadge'), buildBadgeUrl => $self->getUrl('func=buildBadge'), viewScheduleUrl => $self->getUrl('func=viewSchedule'), - addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#addSubmission'), - viewSubmissionQueueUrl => $self->getUrl('func=viewSubmissionQueue'), - addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#addSubmissionForm'), manageBadgeGroupsUrl=> $self->getUrl('func=manageBadgeGroups'), getBadgesUrl => $self->getUrl('func=getBadgesAsJson'), - isRegistrationStaff => $self->isRegistrationStaff, - canEdit => $self->canEdit, - canSubmit => $self->canSubmit, - hasSubmissions => $self->hasSubmissions, - hasSubmissionForms => $self->hasSubmissionForms, + canEdit => $self->canEdit, lookupRegistrantUrl => $self->getUrl('func=lookupRegistrant'), ); @@ -757,77 +499,6 @@ sub www_addRibbonToBadge { #------------------------------------------------------------------- -=head2 www_addSubmission () - -display a form or links to forms to create a new submission - -=cut - -sub www_addSubmission { - my $self = shift; - my $params = shift || {}; - my $session = $self->session; - my $formId = $params->{formId} || $session->form->get('formId'); - my $i18n = WebGUI::International->new($session,'Asset_EventManagementSystem'); - my $form; - - if( ! defined $formId ) { - my $res = $self->getLineage(['children'],{ returnObjects => 1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'], - } ); - my @new = map { $_->canSubmit ? $_ : () } ( @$res); - if( scalar(@new) == 0 ) { - return $self->www_view; - } elsif( scalar(@new) == 1 ) { - $form = $new[0]; - $formId = $form->getId; - } else { - my $makeAnchorList =sub{ my $u=shift; my $n=shift; my $d=shift; - return qq{
  • $n
  • } } ; - my $listOfLinks = join '', ( map { - $makeAnchorList->( - $self->getUrl('func=viewSubmissionQueue#' . $_->getId . '_new' ), # _new has to match same in sub www_viewSubmissionQueue in this module - $_->get('title'), - WebGUI::HTML::filter($_->get('description'),'all') - ) - } ( @new ) ); - my $title = $i18n->get('select form to submit') ; - my $asJson = $session->form->get('asJson'); - if( $asJson ) { - $session->http->setMimeType( 'application/json' ); - } else { - $session->http->setMimeType( 'text/html' ); - } - my $content = '

    ' . $title . '

    ' ; - if( $asJson ) { - return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } ); - } else { - return $self->ProcessStyle( $content ); - } - } - } - $form = WebGUI::Asset->newByDynamicClass($session,$formId); - if (!defined $form) { - $session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $formId"); - } - return $form->www_addSubmission; -} - -#------------------------------------------------------------------- - -=head2 www_addSubmissionForm () - -call www_editSubmissionForm with assetId == new - -=cut - -sub www_addSubmissionForm { - my $self = shift; - $self->www_editSubmissionForm( { assetId => 'new' } ); -} - -#------------------------------------------------------------------- - =head2 www_addTicketsToBadge () Adds selected tickets to a badge. Expects two form parameters, assetId (multiples fine) and badgeId, where assetId represents the ticket and badgeId represents the badge. @@ -1005,62 +676,6 @@ sub www_editBadgeGroupSave { #------------------------------------------------------------------- -=head2 www_editSubmission - -use getLineage to find the item to edit based on submissionId -then call www_editSubmission on it - -=cut - -sub www_editSubmission { - my $self = shift; - my $submissionId = $self->session->form->get('submissionId'); - my $asset = $self->getLineage(['descendants'], { returnObjects => 1, - joinClass => "WebGUI::Asset::EMSSubmission", - whereClause => 'submissionId = ' . int($submissionId), - includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'], - } ); - return $asset->[0]->www_editSubmission; -} - - -#------------------------------------------------------------------- - -=head2 www_editSubmissionForm - -calls editSubmissionForm in WebGUI::Asset::EMSSubmissionForm - -=cut - -sub www_editSubmissionForm { - my $self = shift; - return $self->session->privilege->insufficient() unless $self->isRegistrationStaff || $self->canEdit; - return WebGUI::Asset::EMSSubmissionForm->www_editSubmissionForm($self,shift); -} - -#------------------------------------------------------------------- - -=head2 www_editSubmissionFormSave - -test and save data posted from editSubmissionForm... - -=cut - -sub www_editSubmissionFormSave { - my $self = shift; - return $self->session->privilege->insufficient() unless $self->isRegistrationStaff; - my $formParams = WebGUI::Asset::EMSSubmissionForm->processForm($self); - if( $formParams->{_isValid} ) { - delete $formParams->{_isValid}; - $self->addSubmissionForm($formParams); - return $self->www_viewSubmissionQueue; - } else { - return $self->www_editSubmissionForm($formParams); - } -} - -#------------------------------------------------------------------- - =head2 www_editEventMetaField ( ) Displays the edit form for event meta fields. @@ -1087,7 +702,6 @@ sub www_editEventMetaField { required => $self->session->form->process("required",'yesNo'), possibleValues => $self->session->form->process("possibleValues",'textarea'), defaultValues => $self->session->form->process("defaultValues",'textarea'), - helpText => $self->session->form->process("helpText",'textarea'), }; $f->readOnly( -name => 'error', @@ -1144,12 +758,6 @@ sub www_editEventMetaField { -hoverHelp => $i18n->get('488 description'), -value => $data->{defaultValues}, ); - $f->textarea( - -name => "helpText", - -label => $i18n2->get('meta field help text'), - -hoverHelp => $i18n2->get('meta field help text description'), - -value => $data->{helpText}, - ); $f->submit; return $self->processStyle($f->print); } @@ -1182,7 +790,6 @@ sub www_editEventMetaFieldSave { required => $self->session->form->process("required",'yesNo'), possibleValues => $self->session->form->process("possibleValues",'textarea'), defaultValues => $self->session->form->process("defaultValues",'textarea'), - helpText => $self->session->form->process("helpText",'textarea'), },1,1); return $self->www_manageEventMetaFields(); } @@ -1267,90 +874,6 @@ sub www_exportEvents { return "chunked"; } -#---------------------------------------------------------------------------- - -=head2 www_getAllSubmissions ( ) - -Get a page of Asset Manager data, ajax style. Returns a JSON array to be -formatted in a WebGUI submission queue data table. - -=cut - -sub www_getAllSubmissions { - my $self = shift; - my $session = $self->session; - my $datetime = $session->datetime; - my $form = $session->form; - my $tableInfo = {}; - - return $session->privilege->insufficient unless $self->canSubmit || $self->isRegistrationStaff; - - my $orderByColumn = $form->get( 'orderByColumn' ) || $self->get("sortColumn"); - my $dir = $form->get('orderByDirection') || $self->get('sortOrder'); - my $orderByDirection = lc ($dir) eq "asc" ? "ASC" : "DESC"; - - my $whereClause ; - if(!$self->isRegistrationStaff) { - my $userId = $session->user->userId; - $whereClause .= qq{ createdBy='$userId'}; - } - - my $rules; - $rules->{'joinClass' } = "WebGUI::Asset::EMSSubmission"; - $rules->{'whereClause' } = $whereClause; - $rules->{'includeOnlyClasses'} = ['WebGUI::Asset::EMSSubmission']; - $rules->{'orderByClause' } = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection if $orderByColumn; - - my $sql = ""; - - $sql = $self->getLineageSql(['descendants'], $rules); - - my $startIndex = $form->get( 'startIndex' ) || 1; - my $rowsPerPage = $form->get( 'rowsPerPage' ) || 25; - my $currentPage = int ( $startIndex / $rowsPerPage ) + 1; - - my $p = WebGUI::Paginator->new( $session, '', $rowsPerPage, 'pn', $currentPage ); - $p->setDataByQuery($sql); - - $tableInfo->{'recordsReturned'} = $rowsPerPage; - $tableInfo->{'totalRecords' } = $p->getRowCount; - $tableInfo->{'startIndex' } = $startIndex; - $tableInfo->{'sort' } = $orderByColumn; - $tableInfo->{'dir' } = $orderByDirection; - $tableInfo->{'records' } = []; - - for my $record ( @{ $p->getPageData } ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $record->{assetId} ); - - my $lastReplyBy = $asset->get("lastReplyBy"); - if ($lastReplyBy) { - $lastReplyBy = WebGUI::User->new($session,$lastReplyBy)->username; - } - - # Populate the required fields to fill in - my $lastReplyDate = $asset->get("lastReplyDate"); - if($lastReplyDate) { - $lastReplyDate = $datetime->epochToHuman($lastReplyDate,"%y-%m-%d @ %H:%n %p"); - } - - my %fields = ( - submissionId => $asset->get("submissionId"), - url => $asset->getQueueUrl, - title => $asset->get( "title" ), - createdBy => WebGUI::User->new($session,$asset->get( "createdBy" ))->username, - creationDate => $datetime->epochToSet($asset->get( "creationDate" )), - submissionStatus => $self->getSubmissionStatus($asset->get( "submissionStatus" ) || 'pending' ), - lastReplyDate => $lastReplyDate || '', - lastReplyBy => $lastReplyBy || '', - ); - - push @{ $tableInfo->{ records } }, \%fields; - } - - $session->http->setMimeType( 'application/json' ); - return JSON->new->encode( $tableInfo ); -} - #------------------------------------------------------------------- =head2 www_getBadgesAsJson () @@ -1389,36 +912,6 @@ sub www_getBadgesAsJson { #------------------------------------------------------------------- -=head2 www_getSubmissionById - -returns a JSON dataset with info about the requested submission - -=cut - - -sub www_getSubmissionById { - my $self = shift; - my $submissionId = $self->session->form->get('submissionId'); - my $result; - my $res = $self->getLineage(['descendants'],{ limit => 1, returnObjects=>1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'], - joinClass => "WebGUI::Asset::EMSSubmission", - whereClause => q{submissionId='} . $submissionId . q/'/, - } ); - if( scalar(@$res) == 0 ) { - $result->{hasError} = 1; - $result->{errors} = [ 'failed to load submission' ]; - } else { - $result->{text} = $res->[0]->www_editSubmission; - $result->{title} = $submissionId; - $result->{id} = $submissionId; - } - $self->session->http->setMimeType('application/json'); - return JSON->new->encode($result); -} - -#------------------------------------------------------------------- - =head2 www_getRegistrantAsJson ( ) Retrieves the properties of a specific badge and the items attached to it. Expects badgeId to be one of the form params. @@ -1761,6 +1254,8 @@ sub www_getScheduleDataJSON { return JSON->new->encode(\%results); } + + #------------------------------------------------------------------- =head2 www_getTicketsAsJson () @@ -2640,6 +2135,7 @@ View the schedule table. sub www_viewSchedule { my $self = shift; return $self->session->privilege->insufficient() unless $self->canView; + my $db = $self->session->db; my $rowsPerPage = 25; my $locationsPerPage = $self->get('scheduleColumnsPerPage'); @@ -2660,60 +2156,5 @@ sub www_viewSchedule { } -#--------------------------------------------- - -=head2 www_viewSubmissionQueue - -=cut - -sub www_viewSubmissionQueue { - my $self = shift; - my $isRegistrationStaff = $self->isRegistrationStaff; - my $canSubmit = $self->canSubmit; - my $canEdit = $self->canEdit; - my $i18n = $self->i18n; - return $self->session->privilege->insufficient() unless $canSubmit || $isRegistrationStaff; - - # this map returns an array of hash refs with an id,url pair to describe the submissionForm assets - my @submissionFormUrls = map { { # edit form - id => $_->getId, - edit => 1, - title => $_->get('title'), - linkUrl => $self->getUrl('func=viewSubmissionQueue#' . $_->getId ), - ajaxUrl => $_->getUrl('func=editSubmissionForm'), - },{ # new submission ( _new has to match same in sub www_addSubmission in this module - id => $_->getId . '_new', - title => $_->get('title') . ' - ' . $i18n->get('add submission'), - linkUrl => $self->getUrl('func=viewSubmissionQueue#' . $_->getId . '_new' ), - ajaxUrl => $_->getUrl('func=addSubmission'), - } } ( - @{$self->getLineage( ['children'],{ returnObjects => 1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'], - } ) } - ); - my $params = { - backUrl => $self->getUrl, - isRegistrationStaff => $isRegistrationStaff, - canEdit => $canEdit, - canSubmit => $canSubmit, - hasSubmissionForms => $self->hasSubmissionForms, - getSubmissionQueueDataUrl => $self->getUrl('func=getAllSubmissions'), - editSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#editSubmission'), - editSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#editSubmissionForm'), - addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#addSubmissionForm'), - addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#addSubmission'), - editSubmissionAjaxUrl => $self->getUrl('func=editSubmission'), - editSubmissionFormAjaxUrl => $self->getUrl('func=editSubmissionForm'), - addSubmissionFormAjaxUrl => $self->getUrl('func=addSubmissionForm'), - addSubmissionAjaxUrl => $self->getUrl('func=addSubmission'), - submissionFormUrls => \@submissionFormUrls, - queueTabTitle => $isRegistrationStaff ? $i18n->get('submission queue') : $i18n->get('my submissions'), - }; - $params->{QueueTabData} = $self->processTemplate($params,$self->get('eventSubmissionQueueTemplateId')); - - return $self->processStyle( - $self->processTemplate( $params, $self->get('eventSubmissionMainTemplateId'))); -} - 1; diff --git a/lib/WebGUI/Form/Div.pm b/lib/WebGUI/Form/Div.pm deleted file mode 100644 index 7e38abe85..000000000 --- a/lib/WebGUI/Form/Div.pm +++ /dev/null @@ -1,114 +0,0 @@ -package WebGUI::Form::Div; - -=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 base 'WebGUI::Form::Control'; -use WebGUI::International; - -=head1 NAME - -Package WebGUI::Form::Div - -=head1 DESCRIPTION - -dreates a HTML div element with contents provided by caller - -=head1 SEE ALSO - -This is a subclass of WebGUI::Form::Control. - -=head1 METHODS - -The following methods are specifically available from this class. Check the superclass for additional methods. - -=cut - -#------------------------------------------------------------------- - -=head2 definition ( [ additionalTerms ] ) - -See the super class for additional details. - -=head3 usage - - $form->div({ - contentCallback => sub { $self->getDivContents(shift); } - }); - -=head3 additionalTerms - -The following additional parameters have been added via this sub class. - -=head4 contentCallback - -A code enclosure which returns the html text to insert into the div element. The divId is passed as parameter 0 when it is called. This function MUST return good html text, it is NOT processed here at all. - -=cut - -sub definition { - my $class = shift; - my $session = shift; - my $definition = shift || []; - push(@{$definition}, { - contentCallback=>{ - defaultValue=> sub { return '' }, - }, - }); - return $class->SUPER::definition($session, $definition); -} - -#------------------------------------------------------------------- - -=head2 getName ( session ) - -Returns the name of the form control. - -=cut - -sub getName { - my ($class, $session) = @_; - return WebGUI::International->new($session, "Form_Div")->get("topicName"); -} - - -#------------------------------------------------------------------- - -=head2 getValue ( [ value ] ) - -Does some special processing. - -=cut - -sub getValue { - my $self = shift; - return $self->get('contentCallback')->($self->get('id')); -} - -#------------------------------------------------------------------- - -=head2 toHtml ( ) - -Renders an input tag of type text. - -=cut - -sub toHtml { - my $self = shift; - return '
    get("extras").'>' . $self->getValue . '
    ' ; -} - -1; -#vim:ft=perl diff --git a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm b/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm deleted file mode 100644 index 3cd147211..000000000 --- a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm +++ /dev/null @@ -1,109 +0,0 @@ -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; -use WebGUI::International; - -=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; - my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" ); - push(@{$definition}, { - name => $i18n->get("activity title cleanup submissions"), - 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); - - # keep track of how much time it's taking - my $start = time; - my $limit = 2_500; - my $timeLimit = 60; - - my $list = $root->getLineage( ['descendants'], { returnObjects => 1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'], - } ); - - for my $emsForm ( @$list ) { - my $daysBeforeCleanup = $emsForm->get('daysBeforeCleanup') ; - next if ! $daysBeforeCleanup; - my $whereClause = q{ submissionStatus='denied' }; - if( $emsForm->get('deleteCreatedItems') ) { - $whereClause = ' ( ' . $whereClause . q{ or submissionStatus='created' } . ' ) '; - } - my $checkDate = time - ( 60*60*24* $daysBeforeCleanup ); - $whereClause .= q{ and assetData.lastModified < } . $checkDate; - my $res = $emsForm->getLineage(['children'],{ returnObjects => 1, - joinClass => 'WebGUI::Asset::EMSSubmission', - includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'], - whereClause => $whereClause, - } ); - for my $submission ( @$res ) { - $submission->purge; - $limit--; - return $self->WAITING(1) if ! $limit or time > $start + $timeLimit; - } - } - return $self->COMPLETE; -} - -1; - diff --git a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm b/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm deleted file mode 100644 index a670a8ba7..000000000 --- a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm +++ /dev/null @@ -1,123 +0,0 @@ -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; -use WebGUI::International; -use WebGUI::VersionTag; - -=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; - my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" ); - push(@{$definition}, { - name => $i18n->get("activity title approve submissions"), - 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); - # keep track of how much time it's taking - my $start = time; - my $limit = 2_500; - my $timeLimit = 60; - - my $list = $root->getLineage( ['descendants'], { returnObjects => 1, - includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'], - } ); - - for my $emsForm ( @$list ) { - my $whereClause = q{ submissionStatus='approved' }; - my $res = $emsForm->getLineage(['children'],{ returnObjects => 1, - joinClass => 'WebGUI::Asset::EMSSubmission', - includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'], - whereClause => $whereClause, - } ); - for my $submission ( @$res ) { - my $properties = { className => 'WebGUI::Asset::Sku::EMSTicket' }; - for my $name ( qw{title description seatsAvailable price vendorId - synopsis location duration startDate sku relatedRibbons - relatedBadgeGroups eventMetaData shipsSeparately} ) { - $properties->{$name} = $submission->get($name); - } - $properties->{eventNumber} = $self->session->db->quickScalar( - "select max(eventNumber)+1 - from EMSTicket left join asset using (assetId) - where parentId=?",[$emsForm->ems->getId]) || 0; - my $newAsset = $emsForm->ems->addChild( $properties ); - if( $newAsset ) { - # TODO this should be addRevision - $submission->update({ ticketId => $newAsset->getId, submissionStatus => 'created' }); - WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { override => 1, allowComments => 0 }); - } else { - $submission->addComment($@) if $@; - $submission->update({ submissionStatus => 'failed' }); - } - $limit--; - last if ! $limit or time > $start + $timeLimit; - } - } - return $self->WAITING(1) if ! $limit or time > $start + $timeLimit; - return $self->COMPLETE; -} - -1; - - diff --git a/lib/WebGUI/i18n/English/Asset_EMSSubmission.pm b/lib/WebGUI/i18n/English/Asset_EMSSubmission.pm deleted file mode 100644 index 13c6262ec..000000000 --- a/lib/WebGUI/i18n/English/Asset_EMSSubmission.pm +++ /dev/null @@ -1,56 +0,0 @@ -package WebGUI::i18n::English::Asset_EMSSubmission; ##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 - - 'assetName' => { - message => q|EMS Event Submission|, - lastUpdated => 1131394072, - context => q|Then name of the Asset ( Event Management System - Event Submission ).| - }, - 'send email label' => { - message => q|Send Email when Submission Editted|, - lastUpdated => 1131394072, - context => q|This is the lable for the flag for setting the option to send email to the owner when the submission is eddited.| - }, - 'send email label help' => { - message => q|Check this box if you would like to recieve email for all changes made to your submission|, - lastUpdated => 1131394072, - context => q|This is the help text for the 'send email' flag. If set to 'Yes', the user will recieve email for every change made to the submission.| - }, - - 'comments' => { - message => q|Comments|, - lastUpdated => 1131394072, - context => q|Label for the comments tab.| - }, - - 'submission status' => { - message => q|Submission Status|, - lastUpdated => 1131394072, - context => q|Label for the submission status field.| - }, - - 'submission status help' => { - message => q|The status of the submission: pending is waiting for the registrar; feedback is waiting for the owner; denied is denied; approved is waiting to create a ticket; created means the ticket is created successfully, failed means ticket creation was not successfull.|, - lastUpdated => 1131394072, - context => q|Help text for the submission status field.| - }, - - 'your submission has been updated' => { - message => q|Your event submission has been updated.|, - lastUpdated => 1131394072, - context => q|Message used to notify user when someone else changes their event submission.| - }, - -# 'TODO' => { -# message => q|TODO|, -# lastUpdated => 1131394072, -# context => q|TODO| -# }, - -}; - -1; -#vim:ft=perl diff --git a/lib/WebGUI/i18n/English/Asset_EMSSubmissionForm.pm b/lib/WebGUI/i18n/English/Asset_EMSSubmissionForm.pm deleted file mode 100644 index 80bbbd3b5..000000000 --- a/lib/WebGUI/i18n/English/Asset_EMSSubmissionForm.pm +++ /dev/null @@ -1,111 +0,0 @@ -package WebGUI::i18n::English::Asset_EMSSubmissionForm; ##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 - - 'assetName' => { - message => q|EMS Event Submission Form|, - lastUpdated => 1131394072, - context => q|Then name of the Asset ( Event Management System - Event Submission Form ).| - }, - '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.| - }, - 'activity title approve submissions' => { - message => q|Process Approved EMS Submissions|, - lastUpdated => 1131394072, - context => q|This is the label used to describe the EMS submission approval activity| - }, - 'activity title cleanup submissions' => { - message => q|Cleanup EMS Submissions|, - lastUpdated => 1131394072, - context => q|This is the label used to describe the EMS submission cleanup activity| - }, - 'past deadline message' => { - message => q|The deadline for this submission is past, no more submissions will be taken at this time.|, - lastUpdated => 1131394072, - context => q|This is the default message for informing the user that the submission deadline is past.| - }, - 'past deadline label' => { - message => q|Past Submission Deadline Text|, - lastUpdated => 1131394072, - context => q|This is the label for the message indicating that the deadline for submissions has past.| - }, - 'past deadline label help' => { - message => q|Enter a message here to let the user know that submissions are no longer being taken because the deadline has past.|, - lastUpdated => 1131394072, - context => q|This help text should describe how the user tells submitters that the submission deadline has past.| - }, - - 'submission deadline label' => { - message => q|Submission Deadline|, - lastUpdated => 1131394072, - context => q|Label for the submission deadline field| - }, - - 'submission deadline label help' => { - message => q|Enter a date after which no more new submissions will be taken.|, - lastUpdated => 1131394072, - context => q|Help text for the submission deadline field. After this date this submission form will not accept any more entries.| - }, - - 'new form' => { - message => q|New Form|, - lastUpdated => 1131394072, - context => q|This is the label for the tab when creating a new submission form.| - }, - - 'turn on one field' => { - message => q|You should turn on at least one entry field.|, - lastUpdated => 1131394072, - context => q|Remind the registrar to allow at least one field to be editted by the event submitter.| - }, - -# 'TODO' => { -# message => q|TODO|, -# lastUpdated => 1131394072, -# context => q|TODO| -# }, - -}; - -1; -#vim:ft=perl diff --git a/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm b/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm index 487547102..d06b3fd1b 100644 --- a/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm +++ b/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm @@ -1897,178 +1897,7 @@ normal templates.|, context => q|help text for the columns per page field|, }, - 'edit submission form' => { - message => q|Edit Submission Form|, - lastUpdated => 1147050475, - context => q|Label for the link to edit a submission form.|, - }, - 'new submission form' => { - message => q|New Submission Form|, - lastUpdated => 1147050475, - context => q|Label for the link to create a new submission form.|, - }, - - 'view submission queue' => { - message => q|Submission Queue|, - lastUpdated => 1147050475, - context => q|Label for link to view submission queue.|, - }, - - 'add submission' => { - message => q|New|, - lastUpdated => 1147050475, - context => q|This is appended to the title of a submission form when user is submitting a new event.|, - }, - - 'new submission' => { - message => q|New Submission|, - lastUpdated => 1147050475, - context => q|Label for link to create a new submission for an event.|, - }, - - 'view my submissions' => { - message => q|My Submissions|, - lastUpdated => 1147050475, - context => q|Label for link to view submissions owned by current user.|, - }, - - 'event submission template' => { - message => q|Event Submission Template|, - lastUpdated => 1131394072, - context => q|Label for the template that is used to submit events.| - }, - - 'event submission template help' => { - message => q|This template is used for event submission, most of its contents is composed by the submission form asset based on the description given by the admin who created it.|, - lastUpdated => 1131394072, - context => q|Help text for the event submission form template.| - }, - - 'event submission queue template' => { - message => q|Event Submission Queue Template|, - lastUpdated => 1131394072, - context => q|Label for the Event Submission Queue template.| - }, - - 'event submission queue template help' => { - message => q|This is the template used to display the Event Submission Queue, used for both submitters and admin.|, - lastUpdated => 1131394072, - context => q|Help text for the Event SUbmission Queue Template.| - }, - - 'event submission main template' => { - message => q|Event Submission Main Template|, - lastUpdated => 1131394072, - context => q|Label for the event submission main template.| - }, - - 'event submission main template help' => { - message => q|This template is used to describe main page of the submission module. It has a dynamic tabset on it which is used to hold one or more pieces of the submission interface.|, - lastUpdated => 1131394072, - context => q|Help text for the event submission main template.| - }, - - 'select form to edit' => { - message => q|Select a Form to Edit|, - lastUpdated => 1147050475, - context => q|Label for list of submission forms; user must choose one to edit.|, - }, - - 'select form to submit' => { - message => q|Select a Form to Submit|, - lastUpdated => 1147050475, - context => q|Label for list of submission forms; user must choose one to proceed to a submission form.|, - }, - - 'pending' => { - message => q|Pending|, - lastUpdated => 1147050475, - context => q|Label for pending status on submission.|, - }, - - 'feedback' => { - message => q|Feedback|, - lastUpdated => 1147050475, - context => q|Label for feedback requested on a submission.|, - }, - - 'denied' => { - message => q|Denied|, - lastUpdated => 1147050475, - context => q|Label for denied status on a submission.|, - }, - - 'approved' => { - message => q|Approved|, - lastUpdated => 1147050475, - context => q|Label for approved status on a submission.|, - }, - - 'created' => { - message => q|Created|, - lastUpdated => 1147050475, - context => q|Label for status indicating ticket is created for submission.|, - }, - - 'failed' => { - message => q|Failed|, - lastUpdated => 1147050475, - context => q|Label indicating ticket creation failed for submission.|, - }, - - 'meta field help text' => { - message => q|Help Text|, - lastUpdated => 1147050475, - context => q|The label for the meta field help text field.|, - }, - - 'meta field help text description' => { - message => q|This help text will be provided in the event submission interface.|, - lastUpdated => 1147050475, - context => q|Describes the help text that is attached to meta fields.|, - }, - - 'default submitted location list' => { - message => q||, - lastUpdated => 1147050475, - context => q|This is the default value for the list of locations for event submission.|, - }, - - 'submitted location list label' => { - message => q|Locations Available for Event Submissions|, - lastUpdated => 1147050475, - context => q|Label for the submitted location list|, - }, - - 'submitted location list help' => { - message => q|Enter a listy of location names here, one name on a line. This list will be available on the event submission form in the location select box. If this field is filled in then only these locations will be available.|, - lastUpdated => 1147050475, - context => q|This is help text for the submitted location list field.|, - }, - - 'submission queue' => { - message => q|Submission Queue|, - lastUpdated => 1147050475, - context => q|Label for the submission list tab for registration staff.|, - }, - - 'my submissions' => { - message => q|My Submissions|, - lastUpdated => 1147050475, - context => q|Label for the submission list tab for event submitters.|, - }, - - '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.| - }, 'print remaining ticket template help' => { message => q|EMS Print Remaining Ticket Template|, lastUpdated => 1147050475, @@ -2267,12 +2096,6 @@ normal templates.|, context => q|Field Label|, }, -# 'TODO' => { -# message => q|TODO|, -# lastUpdated => 1147050475, -# context => q|TODO|, -# }, - }; diff --git a/lib/WebGUI/i18n/English/Form_Div.pm b/lib/WebGUI/i18n/English/Form_Div.pm deleted file mode 100644 index f956a4a01..000000000 --- a/lib/WebGUI/i18n/English/Form_Div.pm +++ /dev/null @@ -1,15 +0,0 @@ -package WebGUI::i18n::English::Form_Div; - -use strict; ##Required for all good Perl::Critic compliant code - -our $I18N = { - 'topicName' => { - message => q|Form Control Div Element|, - lastUpdated => 1131394070, #seconds from the epoch - context => q|Name of the form control that generates HTML Div elements| - }, - -}; - -1; -#vim:ft=perl diff --git a/t/Asset/EMSSubmissionForm.t b/t/Asset/EMSSubmissionForm.t deleted file mode 100644 index d6a60e7c3..000000000 --- a/t/Asset/EMSSubmissionForm.t +++ /dev/null @@ -1,516 +0,0 @@ -# vim:syntax=perl -#------------------------------------------------------------------- -# 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 -#------------------------------------------------------------------ - -# Write a little about what this script tests. -# -# - -use FindBin; -use strict; -use lib "$FindBin::Bin/../lib"; -use Test::More; -use Test::Deep; -use Test::Warn; -use JSON; -use WebGUI::Test; # Must use this before any other WebGUI modules -use WebGUI::Test::Activity; -use WebGUI::Group; -use WebGUI::User; -use WebGUI::Session; -use WebGUI::Asset::Wobject::EventManagementSystem; -use WebGUI::Asset::Sku::EMSBadge; -use WebGUI::Asset::Sku::EMSTicket; -use WebGUI::Asset::Sku::EMSRibbon; -use WebGUI::Asset::Sku::EMSToken; - -#---------------------------------------------------------------------------- -# Init -my $session = WebGUI::Test->session; - -#---------------------------------------------------------------------------- -# Tests - -plan tests => 52; # Increment this number for each test you create - -(my $submitGroupA = WebGUI::Group->new($session,'new'))->name('groupA'); -(my $submitGroupB = WebGUI::Group->new($session,'new'))->name('groupB'); -(my $registrars = WebGUI::Group->new($session, 'new'))->name('registrars'); -(my $attendees = WebGUI::Group->new($session, 'new'))->name('attendees'); - -(my $registrar = WebGUI::User->new($session,'new'))->update({username=>'registrar'}); -(my $userA = WebGUI::User->new($session,'new'))->update({username=>'userA'}); -(my $userB = WebGUI::User->new($session,'new'))->update({username=>'userB'}); -(my $userC = WebGUI::User->new($session,'new'))->update({username=>'userC'}); - -$registrars->addUsers([$registrar->getId]); -$submitGroupA->addUsers([$userA->userId,$userC->userId]); -$submitGroupB->addUsers([$userB->userId,$userC->userId]); -$attendees->addUsers([$userA->getId, $userB->getId, $userC->getId]); - -WebGUI::Test->groupsToDelete($submitGroupA,$submitGroupB); -WebGUI::Test->groupsToDelete($registrars, $attendees); -WebGUI::Test->usersToDelete($userA,$userB,$userC,$registrar); - -sub loginAdmin { $session->user({userId => 3}); } -sub loginRgstr { $session->user({userId => $registrar->userId}); } -sub loginUserA { $session->user({userId => $userA->userId}); } -sub loginUserB { $session->user({userId => $userB->userId}); } -sub loginUserC { $session->user({userId => $userC->userId}); } -sub logout { $session->user({userId => 1}); } - -#---------------------------------------------------------------------------- -# put your tests here -eval { -my $use = use_ok( 'WebGUI::Asset::EMSSubmissionForm' ) - && use_ok( 'WebGUI::Asset::EMSSubmission' ) - && use_ok( 'WebGUI::Workflow::Activity::CleanupEMSSubmissions' ) - && use_ok( 'WebGUI::Workflow::Activity::ProcessEMSApprovals' ); - -SKIP: { skip 'package compile failed!', 1 unless $use; - -loginAdmin; - -# Create a version tag to work in -my $versionTag = WebGUI::VersionTag->getWorking($session); -$versionTag->set({name=>"EventManagementSystem Test"}); -WebGUI::Test->tagsToRollback($versionTag); - -# Do our work in the import node -my $node = WebGUI::Asset->getImportNode($session); - -loginRgstr ; - -# Add an EMS asset -my $ems = $node->addChild({ - className =>'WebGUI::Asset::Wobject::EventManagementSystem', - title => 'Test EMS', - description => 'This is a test ems', - url => '/test-ems', - workflowIdCommit => 'pbworkflow000000000003', # Commit Content Immediately - registrationStaffGroupId => $registrars->getId, - groupIdView => $attendees->getId, - submittedLocationsList => join( "\n", my @submissionLocations = qw'loc1 loc2' ), -}); -# I scooped this out ot WG::Asset::Wobject::EventManagementSystem -# its not pretty, but there is no other way to add a meta field - $ems->setCollateral("EMSEventMetaField", "fieldId",{ - fieldId=> 'new', - label => 'mfRequiredUrl', - dataType => 'url', - visible => 1, - required => 1, - possibleValues => '', - defaultValues => '', - },1,1); - - $ems->setCollateral("EMSEventMetaField", "fieldId",{ - fieldId=> 'new', - label => 'mfDate', - dataType => 'date', - visible => 1, - required => 0, - possibleValues => '', - defaultValues => '', - },1,1); - -my $i18n = $ems->i18n; - -$versionTag->commit; -$versionTag = WebGUI::VersionTag->getWorking($session); -WebGUI::Test->tagsToRollback($versionTag); - -my $id1 = $ems->getNextSubmissionId; -my $id2 = $ems->getNextSubmissionId; -is( $id1 +1, $id2, ' test getNextSubmissionId' ); - -# quick test of addGroupToSubmitList -is($ems->get('eventSubmissionGroups'),'', 'event submission groups is blank'); -$ems->addGroupToSubmitList('joe'); -is($ems->get('eventSubmissionGroups'),'joe', 'event submission groups has one item'); -$ems->addGroupToSubmitList('frank'); -is($ems->get('eventSubmissionGroups'),'frank joe', 'event submission groups has two items'); -$ems->addGroupToSubmitList('joe'); -is($ems->get('eventSubmissionGroups'),'joe frank', 'event submission groups still has two items'); -$ems->update({eventSubmissionGroups => ''}); -is($ems->get('eventSubmissionGroups'),'', 'event submission groups is reset to blank'); - - -is_deeply($ems->getSubmissionLocations, \@submissionLocations, 'test getSubmissionLocations' ); -is_deeply( $ems->getSubmissionStatus, { - map { $_ => $i18n->get($_) } ( qw/pending feedback failed approved created denied/ ) -}, 'test getSubmissionStatus' ); - - -loginRgstr; - -is( $ems->hasSubmissionForms, 0, 'ems currently has no forms' ); - -#print 'press return to continue test' ; <>; - -my $formAdesc = { - _fieldList => [ qw/title description startDate/ ], - title => 1, - description => 1, - duration => 0, - startDate => 1, - seatsAvailable => 0, - location => 0, -}; - - -my $frmA = $ems->addSubmissionForm({ - title => 'test A -- long', - canSubmitGroupId => $submitGroupA->getId, - daysBeforeCleanup => 1, - formDescription => $formAdesc, -}); -isa_ok( $frmA, 'WebGUI::Asset::EMSSubmissionForm' ); -is( $ems->hasSubmissionForms, 1, 'ems now has forms' ); -is_deeply( $frmA->getFormDescription, $formAdesc, 'form description matches' ); -is( $frmA->ems->getId, $ems->getId, 'test ems access function in form' ); - -my $formBdesc = { - _fieldList => [ qw/title description duration mfRequiredUrl/ ], - title => 1, - description => 1, - duration => 1, - startDate => 0, - mfRequiredUrl => 1, - seatsAvailable => 0, - location => 0, -}; -my $frmB = $ems->addSubmissionForm({ - className => 'WebGUI::Asset::EMSSubmissionForm', - title => 'test B -- short', - daysBeforeCleanup => 1, - canSubmitGroupId => $submitGroupB->getId, - formDescription => $formBdesc, -}); -logout; - -ok( !$ems->canSubmit, 'Visitor cannot submit to this ems' ); -ok( !$frmA->canSubmit, 'Visitor cannot submit to form' ); - -loginUserA; - -ok( $ems->canSubmit, 'UserA can submit to this ems' ); -ok( $frmA->canSubmit, 'UserA can submit to formA' ); -ok( !$frmB->canSubmit, 'UserA cannot submit to formB' ); -#print 'press return to complete test' ; <>; -ok( !$ems->hasSubmissions, 'UserA has no submissions' ); - -my $submission = { - title => 'my favorite thing to talk about', - description => 'the description', - startDate => '1255150800', - }; -$session->request->setup_body($submission); -my $sub1 = $frmA->addSubmission; -WebGUI::Test->assetsToPurge( $sub1 ); -print join( "\n", @{$sub1->{errors}} ),"\n" if defined $sub1->{errors}; -my $isa1 = isa_ok( $sub1, 'WebGUI::Asset::EMSSubmission', "userA/formA valid submission succeeded" ); -ok( $ems->hasSubmissions, 'UserA has submissions on this ems' ); -is( $sub1->ems->getId, $ems->getId, 'test ems access function in submission' ); -loginUserB; - -ok( $ems->canSubmit, 'UserB can submit to this ems' ); -ok( !$frmA->canSubmit, 'UserB cannot submit to formA' ); -ok( $frmB->canSubmit, 'UserB can submit to formB' ); - -$submission = { - title => 'why i like to be important', - description => 'the description', - mfRequiredUrl => 'http://google.com', - }; -$session->request->setup_body($submission); -my $sub2 = $frmB->addSubmission; -WebGUI::Test->assetsToPurge( $sub2 ); -my $isa2 = isa_ok( $sub2, 'WebGUI::Asset::EMSSubmission', "userB/FormB valid submission succeeded" ); - -loginUserC; - -ok( $ems->canSubmit, 'UserC can submit to this ems' ); -ok( $frmA->canSubmit, 'UserC can submit to formA' ); -ok( $frmB->canSubmit, 'UserC can submit to formB' ); - -loginUserA; -cmp_deeply( from_json($ems->www_getAllSubmissions), { - sort => undef, - startIndex => 1, - records => [ - { - lastReplyDate => '', - submissionId => '3', - creationDate => ignore(), - createdBy => 'userA', - url => '/test-ems?func=viewSubmissionQueue#3', - submissionStatus => $i18n->get('pending'), - title => 'my favorite thing to talk about', - lastReplyBy => '' - } - ], - totalRecords => '1', - recordsReturned => 25, - dir => 'DESC', -}, 'test getAllSubmissions for UserA' ); - -$session->request->setup_body({submissionId => 3}); -cmp_deeply( from_json($ems->www_getSubmissionById), { - title => 3, - id => 3, - text => ignore(), -}, 'test getSubmissionById'); - -loginUserC; -cmp_deeply( from_json($ems->www_getAllSubmissions), { - sort => undef, - startIndex => 1, - records => [ - ], - totalRecords => '0', - recordsReturned => 25, - dir => 'DESC', -}, 'test getAllSubmissions for UserC' ); - -loginRgstr; -$session->request->setup_body({ orderByColumn => 'submissionId' }); -cmp_deeply( from_json($ems->www_getAllSubmissions), { - sort => 'submissionId', - startIndex => 1, - records => [ - { - lastReplyDate => '', - submissionId => '4', - creationDate => ignore(), - createdBy => 'userB', - url => '/test-ems?func=viewSubmissionQueue#4', - submissionStatus => $i18n->get('pending'), - title => 'why i like to be important', - lastReplyBy => '' - }, - { - lastReplyDate => '', - submissionId => '3', - creationDate => ignore(), - createdBy => 'userA', - url => '/test-ems?func=viewSubmissionQueue#3', - submissionStatus => $i18n->get('pending'), - title => 'my favorite thing to talk about', - lastReplyBy => '' - }, - ], - totalRecords => '2', - recordsReturned => 25, - dir => 'DESC', -}, 'test getAllSubmissions for Registrar' ); - -SKIP: { skip 'create submission failed', 8 unless $isa1 && $isa2; - -loginUserA; - -$sub1->addComment( 'this is a test comment' ); -cmp_deeply($sub1->get('comments')->[0],{ - id => re( qr/.+/ ), - alias => 'userA', - userId => $userA->userId, - comment => 'this is a test comment', - rating => 0, - date => re( qr/\d{10}/ ), - ip => undef, -}, "successfully added comment" ); - -$sub1->update({ - title => 'the new title' -}); - -is( $sub1->get('title'),'the new title','successfully changed the title'); - -loginRgstr; - -$sub1->update({ submissionStatus => 'approved' }); -is($sub1->get('submissionStatus'),'approved','set status to approved'); - -$sub2->update({ submissionStatus => 'denied' }); -is($sub2->get('submissionStatus'),'denied','set status to denied'); - -SKIP: { skip "workflow activities not coded yet", 10 if 0; - -# create the workflows/activities for processing -my $approveSubmissions = WebGUI::Test::Activity->create( $session, - "WebGUI::Workflow::Activity::ProcessEMSApprovals" -); -my $cleanupSubmissions = WebGUI::Test::Activity->create( $session, - "WebGUI::Workflow::Activity::CleanupEMSSubmissions" -); - -is($approveSubmissions->run, 'complete', 'approval complete'); -is($approveSubmissions->run, 'done', 'approval done'); - -$sub1 = $sub1->cloneFromDb; -is( $sub1->get('submissionStatus'),'created','approval successfull'); - -my $ticket = WebGUI::Asset->newByDynamicClass($session, $sub1->get('ticketId')); -isa_ok( $ticket, 'WebGUI::Asset::Sku::EMSTicket', 'approval created a ticket'); -WebGUI::Test->assetsToPurge( $ticket ) if $ticket ; - -my $newDate = time - ( 60 * 60 * 24 * ( $sub2->getParent->get('daysBeforeCleanup') + 1 ) ), -$sub2->update({ - submissionStatus => 'denied', - # lastModified => $newDate, -- update overrides this... -}); -my $sub2Id = $sub2->getId; -$session->db->write('update assetData set lastModified = ' . $newDate . ' where assetId = "' . $sub2Id . '"' ); - -$cleanupSubmissions->rerun; -is($cleanupSubmissions->run, 'complete', 'cleanup complete'); -is($cleanupSubmissions->run, 'done', 'cleanup done'); - -$sub2 = WebGUI::Asset->newByDynamicClass($session, $sub2Id); -is( $sub2, undef, 'submission deleted'); - -} # end of workflow skip - -} # end of create submission skip - -$versionTag->commit; - -SKIP: { skip 'requires HTML::Form', 2 unless use_ok 'HTML::Form'; -# this is not the greatest testm but it does run through the basic create submissionForm code. -loginRgstr; - -my %settings = ( - assetId => 'new', - fieldNames => 'title description startDate duration seatsAvailable location nzymEeuHPQIsgXY0hZxDxA xlvMNwFi1FWwP0PrUAnxSQ', - title => 'Untitled', - menuTitle => 'Untitled', - url => '', - canSubmitGroupId => 2, - daysBeforeCleanup => 7, - deleteCreatedItems => 0, - submissionDeadline => '1991-06-21', - pastDeadlineMessage => 'The deadline for this submission is past, no more submissions will be taken at this time.', - title_yesNo => 1, - description_yesNo => 1, - startDate_yesNo => 1, - duration_yesNo => 1, - seatsAvailable_yesNo => 1, - location_yesNo => 1, - nzymEeuHPQIsgXY0hZxDxA_yesNo => 1, - xlvMNwFi1FWwP0PrUAnxSQ_yesNo => 1, -); - -my $expected = { - 'submissionDeadline' => '1991-06-21', - 'menuTitle' => 'Untitled', - 'pastDeadlineMessage' => 'The deadline for this submission is past, no more submissions will be taken at this time.', - 'formDescription' => { - 'location' => '1', - 'nzymEeuHPQIsgXY0hZxDxA' => 'xlvMNwFi1FWwP0PrUAnxSQ', - 'seatsAvailable' => '1', - 'duration' => '1', - 'title' => '1', - 'startDate' => '1', - 'description' => '1', - 'submissionStatus' => '0', - '_fieldList' => [ - 'title', - 'description', - 'startDate', - 'duration', - 'seatsAvailable', - 'location', - 'nzymEeuHPQIsgXY0hZxDxA' - ] - }, - 'description' => undef, - '_isValid' => 1, - 'deleteCreatedItems' => undef, - 'canSubmitGroupId' => '2', - 'assetId' => 'new', - 'url' => undef, - 'daysBeforeCleanup' => '7', - 'title' => 'Untitled' - } ; - -my $htmlText = $ems->www_addSubmissionForm; -my $form = HTML::Form->parse($htmlText,'http://localhost/'); -for my $input ( $form->inputs ) { - $input->value($settings{$input->name})if exists $settings{$input->name}; -} -$session->request->setup_body( { $form->form } ); -my $result = WebGUI::Asset::EMSSubmissionForm->processForm($ems); -cmp_deeply( $result, $expected , 'test process form' ); -$expected = { - 'errors' => [ - { - 'text' => ignore(), - } - ], - 'submissionDeadline' => undef, - 'menuTitle' => undef, - 'pastDeadlineMessage' => undef, - 'formDescription' => { - '_fieldList' => [], - 'submissionStatus' => 0, - }, - 'description' => undef, - '_isValid' => 0, - 'deleteCreatedItems' => undef, - 'canSubmitGroupId' => undef, - 'assetId' => undef, - 'url' => undef, - 'daysBeforeCleanup' => undef, - 'title' => undef, - }; -$session->request->setup_body( { } ); -$result = WebGUI::Asset::EMSSubmissionForm->processForm($ems); -cmp_deeply( $result, $expected , 'test process form' ); -} # end of skip HTML::Form - -# these run code to see that it runs, but do not check for correctness - -warnings_are { - -$ems->www_viewSubmissionQueue; -$ems->www_addSubmission; -$ems->www_addSubmissionForm; -$ems->www_editSubmissionForm; -$ems->www_editSubmissionFormSave; -$frmA->www_editSubmissionForm; -$frmA->www_addSubmission; -$frmA->www_editSubmission; -$frmA->www_editSubmissionSave; -$frmA->processForm; -$sub1->drawLocationField; -$sub1->drawRelatedBadgeGroupsField; -$sub1->drawRelatedRibbonsField; -$sub1->drawStatusField; -$sub1->www_editSubmission; -$sub1->www_editSubmissionSave; -$sub1->processForm; -# test comments -$sub1->getFormattedComments; - -} [], 'no warnings from calling a bunch of functions'; - -} # end of use packages skip -}; # end of eval -print $@ if $@; - -#done_testing(); -#print 'press return to complete test' ; <>; -#---------------------------------------------------------------------------- -# Cleanup -END { - - -} -#vim:ft=perl diff --git a/t/Form/Div.t b/t/Form/Div.t deleted file mode 100644 index a31f2249b..000000000 --- a/t/Form/Div.t +++ /dev/null @@ -1,66 +0,0 @@ -#------------------------------------------------------------------- -# 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 -#------------------------------------------------------------------- - -use FindBin; -use strict; -use lib "$FindBin::Bin/../lib"; - -use WebGUI::Test; -use WebGUI::Form; -use WebGUI::Form::Div; -use WebGUI::Session; -use HTML::Form; -use WebGUI::Form_Checking; - -#The goal of this test is to verify that Div form elements work - -use Test::More; - -my $session = WebGUI::Test->session; - -# put your tests here - -plan tests => 3; - -my ($header, $footer) = (WebGUI::Form::formHeader($session), WebGUI::Form::formFooter($session)); - -my $textTag = 'hi this is a piece of text that will get placed in a div'; - -sub myContent { - my $id = shift; - return 'ID = ' . $id . $textTag ; -} - -my $html = join "\n", - $header, - WebGUI::Form::Div->new($session, { - name => 'TestDiv', - contentCallback => sub { myContent(shift); }, - })->toHtml, - $footer; - -my @forms = HTML::Form->parse($html, 'http://www.webgui.org'); - -##Test Form Generation - -is(scalar @forms, 1, '1 form was parsed'); - -my @inputs = $forms[0]->inputs; -is(scalar @inputs, 1, 'The form has 1 inputs'); - -# this is not an input control, we just want to see that we are getting -# the desired output - -ok( $html =~ /$textTag/, 'the tag is in the html, so the div was succeccfully implanted' ); - -# TODO write code to parse the html sing xml or some such - -__END__ - diff --git a/t/lib/WebGUI/Test/Activity.pm b/t/lib/WebGUI/Test/Activity.pm deleted file mode 100644 index 615055a3e..000000000 --- a/t/lib/WebGUI/Test/Activity.pm +++ /dev/null @@ -1,113 +0,0 @@ -package WebGUI::Test::Activity; - -use WebGUI::Workflow; - -my @cleanup; # TODO fix WebGUI::Text::assetsToPurge so that it works with workflows and activities - -=head Name - -package WebGUI::Test::Activity; - -=head Description - - This package encapsulates the code required to run - an activity. - -=head Usage - -use WebGUI::Test::Activity; - -my $instance = WebGUI::Test::Activity->create( $session, 'WebGUI::Workflow::Activity::RemoveOldCarts', { - cartTimeout => 3600, -} ); - -is( $instance->run, 'complete', 'activity complete' ); -is( $instance->run, 'done', 'activity done' ); -$instance->rerun; -is( $instance->run, 'complete', 'activity complete' ); -is( $instance->run, 'done', 'activity done' ); -$instance->delete; - -=head create - -=params - -session -- the session variable - -class -- the class for the activity to run - -params -- params to set in the workflow - -=cut - -sub create { - my $myClass = shift; - my $session = shift; - my $workflowClass = shift; - my $activityParams; - if( exists $_[0] and ref $_[0] eq 'HASH' ) { - $activityParams = shift ; - } else { - $activityParams = { @_ }; - } - my $workflow = WebGUI::Workflow->create($session, - { - enabled => 1, - objectType => 'None', - mode => 'realtime', - }, - ); - my $activity = $workflow->addActivity($workflowClass); - if( scalar( keys %$activityParams ) > 0 ) { - $activity->set(%$activityParams); -} - - my $instance = WebGUI::Workflow::Instance->create($session, - { - workflowId => $workflow->getId, - skipSpectreNotification => 1, - } - ); - - my $tag = WebGUI::VersionTag->getWorking($session); - $tag->commit; - WebGUI::Test->tagsToRollback($tag); - # WebGUI::Test->assetsToPurge($instance,$workflow); -- does not work... - push @cleanup, $instance, $workflow, - - return bless { instance => $instance, - session => $session, - workflow => $workflow }, __PACKAGE__; -} - -sub run { - return $_[0]{instance}->run; -} - -sub rerun { - my $self = shift; - my $session = $self->{session}; - $self->{instance} = WebGUI::Workflow::Instance->create($session, - { - workflowId => $self->{workflow}->getId, - skipSpectreNotification => 1, - } - ); - # WebGUI::Test->assetsToPurge($self->{instance}); -- does not work - push @cleanup, $self->{instance}; - my $tag = WebGUI::VersionTag->getWorking($session, 1); - if( $tag ) { - $tag->commit; - WebGUI::Test->tagsToRollback($tag); - } - -} - -END { - - map { $_->delete; } ( @cleanup ); - -} - -1; - diff --git a/www/extras/wobject/EMS/close12_1.gif b/www/extras/wobject/EMS/close12_1.gif deleted file mode 100644 index e2f67d72e..000000000 Binary files a/www/extras/wobject/EMS/close12_1.gif and /dev/null differ diff --git a/www/extras/wobject/EMS/indicator.gif b/www/extras/wobject/EMS/indicator.gif deleted file mode 100644 index 085ccaeca..000000000 Binary files a/www/extras/wobject/EMS/indicator.gif and /dev/null differ diff --git a/www/extras/wobject/EMS/submission.js b/www/extras/wobject/EMS/submission.js deleted file mode 100644 index 40423324b..000000000 --- a/www/extras/wobject/EMS/submission.js +++ /dev/null @@ -1,408 +0,0 @@ - -/*** The WebGUI EMS Submission system - * Requires: YAHOO, Dom, Event, DataSource, DataTable, Paginator, Container - * - */ - -var DataSource = YAHOO.util.DataSource, - DataTable = YAHOO.widget.DataTable, - Paginator = YAHOO.widget.Paginator; - -if ( typeof WebGUI == "undefined" ) { - WebGUI = {}; -} - -/*** WebGUI EMS Object - * - * This object renders the WebGUI EMS Submission datatable - * - * @method WebGUI.EMS.constructor - * @param configs {Object} object containing configuration necessary for creating the datatable. -TODO -- fix this to match what EMS really needs - * datasource {String} Required URL that returns the JSON data structure of data to be displayed. - * container {String} Required id of the HTML Element in which to render both the datatable and the pagination - * dtContainer {String} Required id of the HTML Element in which to render the datatable - * view {String} Required String which is passed to the ticket to properly return uses to the right view [all,my,search]. - * fields {ArrayRef} Required Array Reference of Objects used by the DataSource to configure and store data to be used by the data table - * columns {ArrayRef} Required Array Reference of Objects which define the columns for the datatable to render - * p_containers {ArrayRef} Required Array Reference containing the ids of the HTML Elements in which to render pagination. - * defaultSort {Object} Optional Custom object which defines which column and direction the paginator should sort by - * initRequestString {String} Optional Parameters to append to the end of the url when initializing the datatable - */ - - -WebGUI.EMS = function (configs) { - // Initialize configs - this._configs = {}; - if(configs) { - this._configs = configs; - WebGUI.EMS.url = configs.url; - WebGUI.EMS.tabContent = configs.tabContent; - } - WebGUI.EMS.items = new Object(); - - if(!this._configs.initRequestString) { - this._configs.initRequestString = ';startIndex=0'; - } - - /////////////////////////////////////////////////////////////// - // Internationalization - // this comes first because it is used in other areas... - /////////////////////////////////////////////////////////////// - WebGUI.EMS.i18n = new WebGUI.i18n( { - namespaces : { - 'Asset_EMSSubmission' : [ - '' - ], - 'Asset_EventManagementSystem' : [ - 'close tab', - '' - ] - } -// onpreload : { -// fn : this.initialize, -// obj : this, -// override : true, -// } - } ); - - /////////////////////////////////////////////////////////////// - // Protected Static Methods - /////////////////////////////////////////////////////////////// - - //*********************************************************************************** - // This Method updates the window.location.hash when the user changes tabs - WebGUI.EMS.changeTab = function ( e ) { - alert('tab changed'); - var index = WebGUI.EMS.tabs.getTabIndex( e.newValue ); - if( index == 0 ) { - window.location.hash = ''; - } else { - window.location.hash = WebGUI.EMS.Tabs[index].id; - } - }; - - //*********************************************************************************** - // This method closes the active tab - // - // Parameters: ( integer ) -- if a ticket id is passed in then remove the tab for that ticket - // ( e, object ) -- cancel the event and close the tab associated with the object - // ( ) -- get the current tab from the tabview object and close it - // - WebGUI.EMS.closeTab = function ( e, myTab ) { - var index; - if( typeof(e) == "string" || typeof(e) == "number" ) { - index = e; - myTab = WebGUI.EMS.items[index].tab; - } else { - if( typeof(e) != "undefined" ) { - YAHOO.util.Event.preventDefault(e); - } - if( typeof(myTab) == "undefined" ) { - myTab = WebGUI.EMS.tabs.get('activeTab'); - } - index = WebGUI.EMS.tabs.getTabIndex(myTab); - } - delete WebGUI.EMS.items[index]; - WebGUI.EMS.tabs.removeTab(myTab); - if( WebGUI.EMS.lastTab ) { - WebGUI.EMS.tabs.set('activeTab',WebGUI.EMS.lastTab); - } - }; - - //*********************************************************************************** - // Custom function to handle pagination requests - WebGUI.EMS.handlePagination = function (state,dt) { - var sortedBy = dt.get('sortedBy'); - // Define the new state - var newState = { - startIndex: state.startIndex, - sorting: { - key: sortedBy.key, - dir: ((sortedBy.dir === DataTable.CLASS_ASC) ? "asc" : "desc") - }, - pagination : { // Pagination values - startIndex: state.startIndex, // Go to the proper page offset - rowsPerPage: state.rowsPerPage // Return the proper rows per page - } - }; - - // Create callback object for the request - var oCallback = { - success: dt.onDataReturnSetRows, - failure: dt.onDataReturnSetRows, - scope: dt, - argument: newState // Pass in new state as data payload for callback function to use - }; - - // Send the request - dt.getDataSource().sendRequest(WebGUI.EMS.buildQueryString(newState, dt), oCallback); - }; - - //*********************************************************************************** - //This method is out here so it can be overridden. The datatable uses this method to sort it's columns - WebGUI.EMS.newTab = function(url) { - // the 'loading' 'indicator' - if( typeof(WebGUI.EMS.loadingIndicator) == "undefined" ) { - WebGUI.EMS.loadingIndicator = new YAHOO.widget.Overlay( "loadingIndicator", { - fixedcenter : true, - visible : false - } ); - WebGUI.EMS.loadingIndicator.setBody( "Loading ..." + - "" - ); - WebGUI.EMS.loadingIndicator.render(document.body); - } - WebGUI.EMS.loadingIndicator.show(); - - // Create callback object for the request - var oCallback = { - success: function(o) { - var response = eval('(' + o.responseText + ')'); - var myTab; - if(response.hasError){ - var message = ""; - for(var i = 0; i < response.errors.length; i++) { - message += response.errors[i]; - } - alert(message); - return; - // currently only one tab exists, so instead of checking we just delete it and recreate - // this condition is going to have to search for the id in the list - } else { // if( typeof(WebGUI.EMS.items[response.title]) == "undefined" - // || WebGUI.EMS.items[response.title] == null ) { // } - // if there is a tab .. close it, - // at least until I can get the JS/HTML re-written to handle multiple tabs - // there should only be one - for( var item in WebGUI.EMS.items ) { WebGUI.EMS.closeTab(item) } - var myContent = document.createElement("div"); - myContent.innerHTML = response.text; - myTab = new YAHOO.widget.Tab({ - label: response.title + 'X', - contentEl: myContent - }); - WebGUI.EMS.tabs.addTab( myTab ); - var index = WebGUI.EMS.tabs.getTabIndex(myTab); - YAHOO.util.Event.on(myTab.getElementsByClassName('close')[0], 'click', WebGUI.EMS.closeTab , myTab); - WebGUI.EMS.items[index] = new Object(); - WebGUI.EMS.items[index].tab = myTab; - WebGUI.EMS.items[index].id = response.id; - WebGUI.EMS.items[index].title = response.title; - //} else { - //myTab = WebGUI.EMS.items[response.title].tab; - //myTab.set('content', response.text); - } - // make sure the script on the ticket has run - // if( typeof( WebGUI.ticketJScriptRun ) == "undefined" ) { - // eval( document.getElementById("ticketJScript").innerHTML ); - // } - // delete WebGUI.ticketJScriptRun; - WebGUI.EMS.loadingIndicator.hide(); - WebGUI.EMS.lastTab = WebGUI.EMS.tabs.get('activeTab'); - //initHoverHelp(myTab); - WebGUI.EMS.tabs.set('activeTab',myTab); - }, - failure: function(o) { - WebGUI.EMS.loadingIndicator.hide(); - alert("AJAX call failed"); - } - }; - var request = YAHOO.util.Connect.asyncRequest('GET', url + ';asJson=1' , oCallback); - }; - - //*********************************************************************************** - //This method is out here so it can be overridden. The datatable uses this method to sort it's columns - WebGUI.EMS.sortColumn = function(oColumn,sDir) { - // Default ascending - var sDir = "desc"; - - // If already sorted, sort in opposite direction - if(oColumn.key === this.get("sortedBy").key) { - sDir = (this.get("sortedBy").dir === DataTable.CLASS_ASC) ? "desc" : "asc"; - } - - // Define the new state - var newState = { - startIndex: 0, - sorting: { // Sort values - key: oColumn.key, - dir: (sDir === "asc") ? DataTable.CLASS_ASC : DataTable.CLASS_DESC - }, - pagination : { // Pagination values - startIndex: 0, // Default to first page when sorting - rowsPerPage: this.get("paginator").getRowsPerPage() // Keep current setting - } - }; - - // Create callback object for the request - var oCallback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - scope: this, - argument: newState // Pass in new state as data payload for callback function to use - }; - - // Send the request - this.getDataSource().sendRequest(WebGUI.EMS.buildQueryString(newState, this), oCallback); - }; - - //*********************************************************************************** - // This method checks for modifier keys pressed during the mouse click - function eventModifiers( e ) { - if( e.event.modifiers ) { - return e.event.modifiers & (Event.ALT_MASK | Event.CONTROL_MASK - | Event.SHIFT_MASK | Event.META_MASK); - } else { - return e.event.altKey | e.event.shiftKey | e.event.ctrlKey; - } - } - - //*********************************************************************************** - // This method does the actual work of loading an item into a tab - // - WebGUI.EMS.loadItem = function ( contentId ) { - var submissionId = parseInt( contentId, 10 ); - var url; - // compare contentId with submissionId incase we get an assetId that starts with numeric chars - if( contentId == submissionId ) { - url = WebGUI.EMS.tabContent['editSubmission'] + ";submissionId=" + submissionId; - } else { - url = WebGUI.EMS.tabContent[contentId]; - } - WebGUI.EMS.newTab(url); - }; - - //*********************************************************************************** - // Load an item when the user clicks on an anchor html element - // - WebGUI.EMS.loadItemFromAnchor = function ( anchorObject ) { - var tabContent = anchorObject.hash.substring(1); - WebGUI.EMS.loadItem(tabContent); - }; - - //*********************************************************************************** - // This method is subscribed to by the DataTable and thus becomes a member of the DataTable - // class even though it is a member of the EMS Class. For this reason, a EMS instance - // is actually passed to the method as it's second parameter. - // - WebGUI.EMS.loadItemFromTable = function ( evt, obj ) { - // if the user pressed a modifier key we want to default - if( eventModifiers( evt ) ) { return } - var target = evt.target; - YAHOO.util.Event.stopEvent(evt.event); - var elCell = this.getTdEl(target); - if(elCell) { - var oRecord = this.getRecord(elCell); - var submissionId = oRecord.getData('submissionId'); - - if( typeof( WebGUI.EMS.items[submissionId] ) != "undefined" ) { - WebGUI.EMS.tabs.set('activeTab',WebGUI.EMS.items[submissionId].tab); - WebGUI.EMS.loadingIndicator.hide(); - } else { - WebGUI.EMS.loadItem( submissionId ); - } - } else { - alert("Could not get table cell for " + target); - } - }; - - - /////////////////////////////////////////////////////////////// - // Public Instance Methods - /////////////////////////////////////////////////////////////// - - //*********************************************************************************** - this.getDataTable = function() { - if(!this.EMSQ) { - return {}; - } - return this.EMSQ; - }; - - //*********************************************************************************** - this.getDefaultSort = function() { - if(this._configs.defaultSort) { - return this._configs.defaultSort; - } - return { - "key" : "creationDate", - "dir" : DataTable.CLASS_DESC - }; - }; - - //*********************************************************************************** - // Override this method if you want pagination to work differently - this.getPaginator = function () { - return new Paginator({ - containers : this._configs.p_containers, - pageLinks : 5, - rowsPerPage : 25, - rowsPerPageOptions : [25,50,100], - template : "{CurrentPageReport} {PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}" - }); - }; - - //*********************************************************************************** - this.initDataTable = function () { - var datasource = new DataSource(this._configs.datasource); - datasource.responseType = DataSource.TYPE_JSON; - datasource.responseSchema = { - resultsList : 'records', - fields : this._configs.fields, - metaFields : { totalRecords: 'totalRecords' } - }; - - // Initialize the data table - this.EMSQ = new DataTable( - this._configs.dtContainer, - this._configs.columns, - datasource, - { - initialRequest : this._configs.initRequestString, - paginationEventHandler : WebGUI.EMS.handlePagination, - paginator : this.getPaginator(), - dynamicData : true, - sortedBy : this.getDefaultSort() - } - ); - this.EMSQ.subscribe("rowMouseoverEvent", this.EMSQ.onEventHighlightRow); - this.EMSQ.subscribe("rowMouseoutEvent", this.EMSQ.onEventUnhighlightRow); - this.EMSQ.subscribe("cellClickEvent",WebGUI.EMS.loadItemFromTable,this); - // Override function for custom server-side sorting - this.EMSQ.sortColumn = WebGUI.EMS.sortColumn; - this.EMSQ.handleDataReturnPayload = function (oReq, oRes, oPayload ) { - oPayload.totalRecords = parseInt( oRes.meta.totalRecords ); - return oPayload; - }; - this.EMSQ.generateRequest = WebGUI.EMS.buildQueryString; - - //Work around nested scoping for the callback - var myEMSQ = this.EMSQ; - //ensure no memory leaks with the datatable - }; - -}; - -/////////////////////////////////////////////////////////////// -// Public Static Methods -/////////////////////////////////////////////////////////////// - -//*********************************************************************************** -WebGUI.EMS.formatTitle = function ( elCell, oRecord, oColumn, orderNumber ) { - elCell.innerHTML = '