diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index d85901962..2d81035d6 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -303,6 +303,15 @@ sub definition { hoverHelp => $i18n->get('send inbox notifications only help', 'Message_Center'), defaultValue => $setting->get('sendInboxNotificationsOnly'), }); + push(@fields, { + tab => 'messaging', + fieldType => 'template', + name => 'inboxNotificationTemplateId', + label => $i18n->get('inbox notification template', 'Message_Center'), + hoverHelp => $i18n->get('inbox notification template help', 'Message_Center'), + defaultValue => $setting->get('inboxNotificationTemplateId'), + namespace => 'Account/Inbox/Notification', + }); # misc push(@fields, { tab=>"misc", diff --git a/lib/WebGUI/i18n/English/Message_Center.pm b/lib/WebGUI/i18n/English/Message_Center.pm index c5d21bf3e..c607f8314 100644 --- a/lib/WebGUI/i18n/English/Message_Center.pm +++ b/lib/WebGUI/i18n/English/Message_Center.pm @@ -50,6 +50,11 @@ our $I18N = { lastUpdated => 1235696295, }, + 'inbox notification' => { + message => q|You have a new message in your Inbox.|, + lastUpdated => 1235708853, + }, + }; 1; diff --git a/sbin/installNotifications.pl b/sbin/installNotifications.pl index 273637080..9f6fc0c23 100644 --- a/sbin/installNotifications.pl +++ b/sbin/installNotifications.pl @@ -79,7 +79,8 @@ note => WebGUI::International::get('short notification','Message_Center'), sub installSettings { my $session = shift; $session->setting->add('smsGateway', ''); - $session->setting->add('sendInboxNotificationsOnly', ''); + $session->setting->add('sendInboxNotificationsOnly', 0); + $session->setting->add('inboxNotificationTemplateId', 'b1316COmd9xRv4fCI3LLGA'); } #---------------------------------------------------------------------------- @@ -108,11 +109,64 @@ sub finish { # my $versionTag = WebGUI::VersionTag->getWorking($session); # $versionTag->commit; ## + updateTemplates($session); + my $versionTag = WebGUI::VersionTag->getWorking($session); + $versionTag->commit; $session->var->end; $session->close; } +#------------------------------------------------- +sub updateTemplates { + my $session = shift; + my $packageDir = "message_center_packages"; + return undef unless (-d $packageDir); + print "\tUpdating packages.\n"; + opendir(DIR,$packageDir); + my @files = readdir(DIR); + closedir(DIR); + my $newFolder = undef; + foreach my $file (@files) { + next unless ($file =~ /\.wgpkg$/); + # Fix the filename to include a path + $file = $packageDir . "/" . $file; + addPackage( $session, $file ); + } +} + +sub addPackage { + my $session = shift; + my $file = shift; + + # Make a storage location for the package + my $storage = WebGUI::Storage->createTemp( $session ); + $storage->addFileFromFilesystem( $file ); + + # Import the package into the import node + my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage ); + + # Make the package not a package anymore + $package->update({ isPackage => 0 }); + + # Set the default flag for templates added + my $assetIds + = $package->getLineage( ['self','descendants'], { + includeOnlyClasses => [ 'WebGUI::Asset::Template' ], + } ); + for my $assetId ( @{ $assetIds } ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + if ( !$asset ) { + print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n"; + next; + } + $asset->update( { isDefault => 1 } ); + } + + return; +} + + __END__ diff --git a/sbin/message_center_packages/inbox_notification.wgpkg b/sbin/message_center_packages/inbox_notification.wgpkg new file mode 100644 index 000000000..44e87644a Binary files /dev/null and b/sbin/message_center_packages/inbox_notification.wgpkg differ