Skip to content

Commit

Permalink
{teamcards} now displays anyone with a course contact role.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Nov 5, 2023
1 parent 84c41d5 commit 8888462
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 10 additions & 5 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,12 @@ private function userlink($clinktype, $user, $name) {
case 'profile':
$link = '<a href="' . new moodle_url('/user/profile.php', ['id' => $user->id]) . '">' . $name . '</a>';
break;
case 'phone1' && !empty($user->phone1):
$link = '<a href="tel:' . $user->phone1 . '">' . $name . '</a>';
case 'phone1':
if (!empty($user->phone1)) {
$link = '<a href="tel:' . $user->phone1 . '">' . $name . '</a>';
} else {
$link = $name;
}
break;
default:
$link = $name;
Expand Down Expand Up @@ -966,18 +970,19 @@ 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;

$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)) {
Expand Down

0 comments on commit 8888462

Please sign in to comment.