2021-05-27 14:46:18 +00:00
|
|
|
<?php
|
2021-11-24 07:29:43 +00:00
|
|
|
// This file is part of the htmlcert module for Moodle - http://moodle.org/
|
2021-05-27 14:46:18 +00:00
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides helper functionality.
|
|
|
|
*
|
2021-11-24 07:29:43 +00:00
|
|
|
* @package mod_htmlcert
|
|
|
|
* @copyright 2021 Mark Nelson <mdjnelson@gmail.com>, Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
2021-05-27 14:46:18 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
2021-11-24 07:29:43 +00:00
|
|
|
namespace mod_htmlcert;
|
2021-05-27 14:46:18 +00:00
|
|
|
|
|
|
|
use core_user\fields;
|
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class helper.
|
|
|
|
*
|
|
|
|
* Helper functionality for this module.
|
|
|
|
*
|
2021-11-24 07:29:43 +00:00
|
|
|
* @package mod_htmlcert
|
|
|
|
* @copyright 2021 Mark Nelson <mdjnelson@gmail.com>, Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
2021-05-27 14:46:18 +00:00
|
|
|
* @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.
|
|
|
|
*/
|
2021-05-27 14:49:57 +00:00
|
|
|
public static function get_all_user_name_fields(string $tableprefix = ''): string {
|
2021-05-27 14:46:18 +00:00
|
|
|
$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);
|
|
|
|
}
|
2021-05-27 14:48:30 +00:00
|
|
|
}
|