From a76ccfc6255464cd48cfa79505e7cd6cafb314a2 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Mon, 14 Oct 2024 15:02:10 -0400 Subject: [PATCH] Added new {$a->userfullname} tag. --- CHANGELOG.md | 2 ++ README.md | 1 + locallib.php | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index addfce0..28bf829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## [2.2.2] - 2024-10-13 ### Updated +- Fixed support for plain text tag called {$a->userfullname}. - Fixed deprecation notice running on PHP 8.3. ## [2.2.1] - 2024-04-28 diff --git a/README.md b/README.md index f7362b6..dc093af 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ Note that you can use any of the following plain text tags within the body of th * {$a->emailmsgunsubscribe} : Unsubscribe/Support message. * {$a->email} : Invitees email address - always available. * {$a->username} : Invitees username - only available if the user already has an account on the site, otherwise blank. +* {$a->userfullname} : Invitees formatted full name - only available if the user already has an account on the site, otherwise blank. * {$a->firstname} : Invitees first name - only available if the user already has an account on the site, otherwise blank. * {$a->lastname} : Invitees last name - only available if the user already has an account on the site, otherwise blank. * {$a->surname} : This is an alias for {$a->lastname}. diff --git a/locallib.php b/locallib.php index ccf3f9b..820f9ab 100755 --- a/locallib.php +++ b/locallib.php @@ -223,11 +223,13 @@ public function send_invitations($data, $resend = false) { $messageparams->message = $data->message['text']; $messageparams->email = $invitation->email; if ($userexits) { + $messageparams->userfullname = fullname($contactuser); $messageparams->firstname = $contactuser->firstname; $messageparams->lastname = $contactuser->lastname; $messageparams->surname = $contactuser->lastname; $messageparams->username = $contactuser->username; } else { + $messageparams->userfullname = ''; $messageparams->firstname = ''; $messageparams->lastname = ''; $messageparams->surname = ''; @@ -262,12 +264,14 @@ public function send_invitations($data, $resend = false) { $contactuser->mailformat = 1; $contactuser->maildisplay = true; $invitation->userid = $contactuser->id; + $contactuser->userfullname = fullname($contactuser); } else { // User does not have an account yet. $contactuser = new stdClass(); $contactuser->id = -1; // Required by new version of email_to_user since moodle 2.6. $contactuser->email = $invitation->email; $contactuser->mailformat = 1; // 0 (zero): text-only emails, 1 (one): for HTML/Text emails. + $contactuser->userfullname = ''; $contactuser->firstname = ''; $contactuser->lastname = ''; $contactuser->maildisplay = true; @@ -465,7 +469,7 @@ public function enroluser($invitation) { * Figures out who used an invite. * * @param object $invite Invitation record - * @return object Returns an object with following values: + * @return object|bool Returns an object with following values: * ['username'] - name of who used invite * ['useremail'] - email of who used invite * ['roles'] - roles the user has for course that