From ad71df4e3fd99a329b774f1e457211c300b4778d Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 26 Feb 2009 20:42:59 -0800 Subject: [PATCH] Templated Inbox Notification. Everything but the code to drive and use the template from Account/Inbox. --- lib/WebGUI/Operation/Settings.pm | 9 +++ lib/WebGUI/i18n/English/Message_Center.pm | 5 ++ sbin/installNotifications.pl | 56 +++++++++++++++++- .../inbox_notification.wgpkg | Bin 0 -> 777 bytes 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 sbin/message_center_packages/inbox_notification.wgpkg 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 0000000000000000000000000000000000000000..44e87644a2c36bf1da3171c648c85986912004f2 GIT binary patch literal 777 zcmV+k1NQtMiwFP!00000|Ls&;Z`v>v=DEKj%2O+KZ43z%_QdEdRol^)w!3JnOk%(z z*pcmU>D2$eV-rZYbepsy?Eyc;Qtb2jobUV2IVfy?IgV5Dyh1_mW!LP;h25Gjr+^Uh zP`O-2$Sqh1IYp;nLCEG;A{7>pTEHX9`mev2NFwCx$GSLJrZ}_z=IZ}+WU@vp-=hA5 zN(VnAXaAfoK$W%Lu&>j<=y}WfyOp9>uz=0YuTANHu=&*A;)S0((1f;BT;MLTt(x`q z+rIe~3my}pD3SWFxu$Ohf?!3$4-@^@Mz*=E45hLOrTG9_qOeu>YVM5RG( zR6^y($3a*f-wxeQ!!KQ4p4Bs?L_`LhvNj(-F|KHb23S$fvO83s(=a4#IddwTf-9~j z@wDn(QC-24*bh%as!Wudp(!$mqZv`(eWr+D=0P0onk=k*7W-F3N|5cTLG;bN_Zbjn zJtC;O7tyKUgC-VmV>v~bcO(_vhSr3BU-_nEAj1tnW_gVV)1n?p`|RGY)#{qmTCFw9 zeo^&C53}yvGC8HRWv+M#tb!Sgor)!|;v7|-oUasB(eyQ6%V1rvl_BNyfs(0*Dp|@@ zYNl~JMae0E7 z?QQ+@t~16i2vK(T@&#P-pg$vUp{uAoCLNqaE83cNONlq|)oP_$^(w_&d4de71T!Dc z42Rax4?f00e{Pd3E7{{CpPh0snAV-+m4QEGjDu;x^&sF0Q-?;r!v((QJ|Qd+lUOy^ zyrXb8ZP&+1<1Pqqg4U5Q+za7-ikhRNn=B(L?3KA4cihv)`8$OlS~s>HrY}1$Z!xR47+VIm3~U*AO9p-c0S&6z H01f~E{6KnA literal 0 HcmV?d00001