11<?php
22
3- use Elgg \Database \QueryBuilder ;
43use Elgg \Database \Clauses \JoinClause ;
54use Elgg \Database \Delete ;
5+ use Elgg \Database \QueryBuilder ;
66use Elgg \Database \Select ;
77
88/**
@@ -604,20 +604,17 @@ protected function notifyOnRsvp(string $type, int $to = 0): void {
604604
605605 if ($ to_entity instanceof ElggUser) {
606606 // use notification system for real users
607- $ summary = elgg_echo ('event_manager:event:registration:notification:user:summary: ' . $ type , [$ this ->getDisplayName ()]);
608-
609- // set params for site notifications
610607 $ params = [
611- 'summary ' => $ summary ,
612- 'object ' => $ this ,
613- 'action ' => ' rsvp ' ,
608+ 'summary ' => elgg_echo ( ' event_manager:event:registration:notification:user: summary: ' . $ type , [ $ this -> getDisplayName ()]) ,
609+ 'subject ' => $ user_subject ,
610+ 'body ' => $ user_message ,
614611 ];
615612
616613 if (!empty ($ attachment )) {
617614 $ params ['attachments ' ] = [$ attachment ];
618615 }
619-
620- notify_user ( $ to , $ this -> getOwnerGUID () , $ user_subject , $ user_message , $ params );
616+
617+ $ to_entity -> notify ( ' rsvp ' , $ this , $ params , $ this -> getOwnerEntity () );
621618 } else {
622619 // send e-mail for non users
623620 $ options = [
@@ -648,7 +645,6 @@ protected function notifyOnRsvp(string $type, int $to = 0): void {
648645 * @return void
649646 */
650647 protected function notifyOwnerOnRSVP (string $ type , \ElggEntity $ rsvp_entity , string $ event_title_link , string $ registration_link = '' ): void {
651-
652648 if (!$ this ->notify_onsignup ) {
653649 return ;
654650 }
@@ -670,33 +666,11 @@ protected function notifyOwnerOnRSVP(string $type, \ElggEntity $rsvp_entity, str
670666 }
671667
672668 foreach ($ recipients as $ recipient ) {
673- $ current_language = elgg_get_current_language ();
674- $ recipient_language = $ recipient instanceof \ElggUser ? $ recipient ->getLanguage () : $ current_language ;
675- elgg ()->translator ->setCurrentLanguage ($ recipient_language );
676-
677- // set params for site notifications
678- $ params = [
679- 'summary ' => elgg_echo ('event_manager:event:registration:notification:owner:summary: ' . $ type , [
680- $ rsvp_entity ->getDisplayName (),
681- $ this ->getDisplayName (),
682- ]),
683- 'object ' => $ this ,
684- 'action ' => 'rsvp_owner ' ,
685- ];
686-
687- $ subject = elgg_echo ('event_manager:event:registration:notification:owner:subject ' , [$ this ->getDisplayName ()]);
688- if ($ type === EVENT_MANAGER_RELATION_UNDO ) {
689- $ subject = elgg_echo ("event_manager:event:registration:notification:owner:subject: {$ type }" , [$ this ->getDisplayName ()]);
690- }
691-
692- $ message = elgg_echo ('event_manager:event:registration:notification:owner:text: ' . $ type , [
693- $ rsvp_entity ->getDisplayName (),
694- $ event_title_link ,
695- ]) . $ registration_link ;
696-
697- notify_user ($ recipient ->guid , $ rsvp_entity ->guid , $ subject , $ message , $ params );
698-
699- elgg ()->translator ->setCurrentLanguage ($ current_language );
669+ $ recipient ->notify ('rsvp_owner ' , $ this , [
670+ 'rsvp_type ' => $ type ,
671+ 'event_title_link ' => $ event_title_link ,
672+ 'registration_link ' => $ registration_link ,
673+ ], $ rsvp_entity );
700674 }
701675 }
702676
@@ -1008,11 +982,13 @@ public function generateNewAttendee(): bool {
1008982 }
1009983
1010984 $ this ->rsvp (EVENT_MANAGER_RELATION_ATTENDING , $ waiting_user ->guid , false , false , false );
1011-
985+
986+ // send custom notification about being moved from the waitinglist
1012987 $ current_language = elgg_get_current_language ();
1013- elgg ()->translator ->setCurrentLanguage ($ waiting_user ->getLanguage ());
988+ $ recipient_language = $ waiting_user instanceof \ElggUser ? $ waiting_user ->getLanguage () : $ current_language ;
989+ elgg ()->translator ->setCurrentLanguage ($ recipient_language );
1014990
1015- $ notification_body = elgg_echo ('event_manager:event:registration:notification:user:text:event_spotfree ' , [
991+ $ body = elgg_echo ('event_manager:event:registration:notification:user:text:event_spotfree ' , [
1016992 $ this ->getDisplayName (),
1017993 $ this ->getURL (),
1018994 ]);
@@ -1021,17 +997,31 @@ public function generateNewAttendee(): bool {
1021997 if (!empty ($ completed_text )) {
1022998 $ completed_text = str_ireplace ('[NAME] ' , $ waiting_user ->getDisplayName (), $ completed_text );
1023999 $ completed_text = str_ireplace ('[EVENT] ' , $ this ->getDisplayName (), $ completed_text );
1024-
1025- $ notification_body .= PHP_EOL . PHP_EOL . $ completed_text ;
1000+
1001+ $ body .= PHP_EOL . PHP_EOL . $ completed_text ;
10261002 }
10271003
10281004 if (elgg_get_config ('email_html_part ' )) {
10291005 // add addthisevent banners in footer
1030- $ notification_body .= elgg_view ('event_manager/addthisevent/email ' , ['entity ' => $ this ]);
1006+ $ body .= elgg_view ('event_manager/addthisevent/email ' , ['entity ' => $ this ]);
10311007 }
1032-
1033- notify_user ($ waiting_user ->guid , $ this ->owner_guid , elgg_echo ('event_manager:event:registration:notification:user:subject ' , [$ this ->getDisplayName ()]), $ notification_body , [], ['email ' ]);
1034-
1008+
1009+ $ subject = elgg_echo ('event_manager:event:registration:notification:user:subject ' , [$ this ->getDisplayName ()]);
1010+
1011+ if ($ waiting_user instanceof \ElggUser) {
1012+ $ waiting_user ->notify ('spot_free ' , $ this , [
1013+ 'subject ' => $ subject ,
1014+ 'body ' => $ body ,
1015+ 'methods_override ' => ['email ' ],
1016+ ], $ this ->getOwnerEntity ());
1017+ } else {
1018+ elgg_send_email (\Elgg \Email::factory ([
1019+ 'to ' => $ waiting_user ,
1020+ 'subject ' => $ subject ,
1021+ 'body ' => $ body ,
1022+ ]));
1023+ }
1024+
10351025 elgg ()->translator ->setCurrentLanguage ($ current_language );
10361026
10371027 return true ;
0 commit comments