From 888846279f332befb4a0ac1e2a1ab8cc59b60657 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Sun, 5 Nov 2023 02:07:18 -0500 Subject: [PATCH] {teamcards} now displays anyone with a course contact role. --- CHANGELOG.md | 2 ++ README.md | 2 +- filter.php | 15 ++++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c70fe2a..1f7de3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file. - Refactored for performance improvement performance. Enable more tags for embedding. - Instructions for enabling filters in custom menu. - {courseshortname} tag can now be used inside other tags. +- {teamcards} now lists users with selected roles in Site Administration > Appearance > Course > Course Contacts. +- Fixed issue where a tel: link was unexpectedly created in {teamcards}. ## [2.4.2] 2023-10-25 ### Updated diff --git a/README.md b/README.md index 90d66d9..4deb206 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ FilterCodes are meant to be entered as regular text in the Moodle WYSIWYG editor ### UI Elements -* {teamcards} : Displays photos, names (optionally linked) and optional descriptions of the users who are teachers. Only Verbose format is suitable for use in a side block. +* {teamcards} : Displays photos, names (optionally linked) and optional descriptions of anyone anywhere on the site who has one of the roles selected in Site Administration > Appearance > Course > Course Contacts. Only Verbose format is suitable for use in a side block. * (ALPHA) {coursecards} or {coursecards categoryID} : Display available courses as cards. You can optionally specify the ID number of a category. Example: {coursecards 1} will only display courses in the default Miscellaneous category. Note: The categoryID is not the "Category ID Number" field that you can optionally specify when creating a category. The maximum number of courses displayed is controlled by the front page setting called **frontpagecourselimit**. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings. Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date). Courses not visible will be still visible to site admins or users with viewhiddencourses capability. * (ALPHA) {coursecard ids} : Display specific course cards by specifying a list of one or more course ids separated by a space. Example: {coursecard 20 43 104} will display 3 course cards assuming they exist. Courses that have their visibility set to Hidden or that have an expired end-date will only be visible to those who have the capability to see hidden courses (e.g. Site Administrator or Manager role). The maximum number of courses displayed is controlled by the front page setting called **frontpagecourselimit**. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings. Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date). Courses not visible will be still visible to site admins or users with viewhiddencourses capability. * (ALPHA) {coursecardsbyenrol} : Display course cards for the most popular courses based on enrolment. The maximum number of cards is configurable in the plugin settings. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings. Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date). Courses not visible will be still visible to site admins or users with viewhiddencourses capability. diff --git a/filter.php b/filter.php index 1b848f4..d242278 100644 --- a/filter.php +++ b/filter.php @@ -663,8 +663,12 @@ private function userlink($clinktype, $user, $name) { case 'profile': $link = '' . $name . ''; break; - case 'phone1' && !empty($user->phone1): - $link = '' . $name . ''; + case 'phone1': + if (!empty($user->phone1)) { + $link = '' . $name . ''; + } else { + $link = $name; + } break; default: $link = $name; @@ -966,7 +970,8 @@ private function generatortags(&$text) { } // Tag: {teamcards}. - // Description: Displays a series of card for each teacher on the site. Configurable in FilterCodes settins. + // Description: Displays a series of card for each contact on the site. Configurable in FilterCodes settings. + // Note: Included selected roles in Site Administration > Appearance > Course > Course Contacts. // Parameters: None. if (stripos($text, '{teamcards}') !== false) { global $OUTPUT, $DB; @@ -974,10 +979,10 @@ private function generatortags(&$text) { $sql = 'SELECT DISTINCT u.id, u.username, u.firstname, u.lastname, u.email, u.picture, u.imagealt, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.description, u.phone1 FROM {course} c, {role_assignments} ra, {user} u, {context} ct - WHERE c.id = ct.instanceid AND ra.roleid = 3 AND ra.userid = u.id AND ct.id = ra.contextid + WHERE c.id = ct.instanceid AND ra.roleid in (?) AND ra.userid = u.id AND ct.id = ra.contextid AND u.suspended = 0 AND u.deleted = 0 ORDER BY u.lastname desc, u.firstname'; - $users = $DB->get_records_sql($sql); + $users = $DB->get_records_sql($sql, [$CFG->coursecontact]); $cards = ''; if (count($users)) {