. /** * Provides helper functionality. * * @package mod_htmlcert * @copyright 2021 Mark Nelson , Klaus-Uwe Mitterer * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_htmlcert; use core_user\fields; defined('MOODLE_INTERNAL') || die(); /** * Class helper. * * Helper functionality for this module. * * @package mod_htmlcert * @copyright 2021 Mark Nelson , Klaus-Uwe Mitterer * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class helper { /** * A centralised location for the all name fields. * * Returns a sql string snippet. * * @param string $tableprefix table query prefix to use in front of each field. * @return string All name fields. */ public static function get_all_user_name_fields(string $tableprefix = ''): string { $alternatenames = []; foreach (fields::get_name_fields() as $field) { $alternatenames[$field] = $field; } if ($tableprefix) { foreach ($alternatenames as $key => $altname) { $alternatenames[$key] = $tableprefix . '.' . $altname; } } return implode(',', $alternatenames); } }