From 0bcea9d1ac6186cba41409d8077ae9ff59f5c33b Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Sat, 14 Dec 2024 07:56:33 -0500 Subject: [PATCH] Added new {firstnamephonetic}, {lastnamephonetic}, {middlename} tags. --- CHANGELOG.md | 3 +++ README.md | 6 ++++++ classes/text_filter.php | 9 +++++++++ version.php | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7462d7..3f6f4e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. ## [2.6.2] 2024-12-14 (dev) - Performance optimization: Now caches login state. +- New {firstnamephonetic} tag. +- New {lastnamephonetic} tag. +- New {middlename} tag. ## [2.6.1] 2024-11-20 ### Update diff --git a/README.md b/README.md index e647a5c..18334c1 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,9 @@ FilterCodes are meant to be entered as regular text in the Moodle WYSIWYG editor * {firstname} : Display the user's first name. * {surname} or {lastname} : Display the user's surname (family/last name). * {fullname} : Display the user's first name and surname. +* {middlename} : Display the user's middle name. +* {firstnamephonetic} : Display the user's first name in phonetic. +* {lastnamephonetic} : Display the user's last name in phonetic. * {alternatename} : Display the user's alternate name. If blank, it will display the user's first name instead. * {city} : Display the user's city. * {country} : Display the user's country. @@ -1160,6 +1163,9 @@ Create a Page on your Moodle site, preferably in a course, so that those tags wo * Surname [{surname}]: {surname} * Last name [{lastname}]: {lastname} * Full name [{fullname}]: {fullname} +* First name phonetic [{firstnamephonetic}]: {firstnamephonetic} +* Last name phonetic [{lastnamephonetic}]: {lastnamephonetic} +* Middle name [{middlename}]: {middlename} * Alternate name [{alternatename}]: {alternatename} * City [{city}]: {city} * Country [{country}]: {country} diff --git a/classes/text_filter.php b/classes/text_filter.php index 2e70310..47b7521 100644 --- a/classes/text_filter.php +++ b/classes/text_filter.php @@ -2442,6 +2442,15 @@ function ($matches) use ($now) { } } + // Tags: {firstnamephonetic}, {lastnamephonetic}, {middlename}. + // Description: User's first name phonetic, last name phonetic and middle name as set in their profile. + // Parameters: None. + foreach (['firstnamephonetic', 'lastnamephonetic', 'middlename'] as $field) { + if (stripos($text, '{' . $field . '}') !== false) { + $replace['/\{' . $field . '\}/i'] = $this->isauthenticateduser() ? trim($USER->{$field}) : ''; + } + } + // Tag: {email}. // Description: User's email address as set in their profile. // Parameters: None. diff --git a/version.php b/version.php index 41b66e0..d6886a5 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024100702; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024100703; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2014051200; // Requires Moodle version 2.7 or later. $plugin->component = 'filter_filtercodes'; // Full name of the plugin (used for diagnostics). $plugin->release = '2.6.1';