Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions classes/local/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,19 @@ public static function filter_string(?string $string = ''): string {
)
);
}

/**
* For a list of db records, use the objects and pass the displayname property value through the filter(s).
*
* @param array $records
* @return array the $records with the filters applied at displayname
*/
public static function filter_string_records(array $records): array {
foreach ($records as &$record) {
if (isset($record->displayname)) {
$record->displayname = self::filter_string($record->displayname);
}
}
return $records;
}
}
8 changes: 4 additions & 4 deletions management.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
$dbcompvariant = $DB->get_records('tiny_elements_comp_variant');

// Use array_values so mustache can parse it.
$compcats = array_values($dbcompcats);
$flavor = array_values($dbflavor);
$component = array_values($dbcomponent);
$variant = array_values($dbvariant);
$compcats = array_values(utils::filter_string_records($dbcompcats));
$flavor = array_values(utils::filter_string_records($dbflavor));
$component = array_values(utils::filter_string_records($dbcomponent));
$variant = array_values(utils::filter_string_records($dbvariant));

// Build component preview images for management.
foreach ($component as $key => $value) {
Expand Down