Removed usaged of deprecated functions (#423)
This commit is contained in:
parent
1343d64310
commit
345c6e438b
3 changed files with 68 additions and 2 deletions
64
classes/helper.php
Normal file
64
classes/helper.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of the customcert module for Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
*
|
||||||
|
* @package mod_customcert
|
||||||
|
* @copyright 2021 Mark Nelson <mdjnelson@gmail.com>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace mod_customcert;
|
||||||
|
|
||||||
|
use core_user\fields;
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class helper.
|
||||||
|
*
|
||||||
|
* Helper functionality for this module.
|
||||||
|
*
|
||||||
|
* @package mod_customcert
|
||||||
|
* @copyright 2021 Mark Nelson <mdjnelson@gmail.com>
|
||||||
|
* @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($tableprefix = '') {
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,8 @@
|
||||||
*/
|
*/
|
||||||
namespace mod_customcert\task;
|
namespace mod_customcert\task;
|
||||||
|
|
||||||
|
use mod_customcert\helper;
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +104,7 @@ class email_certificate_task extends \core\task\scheduled_task {
|
||||||
$info->certificatename = $certificatename;
|
$info->certificatename = $certificatename;
|
||||||
|
|
||||||
// Get a list of all the issues.
|
// Get a list of all the issues.
|
||||||
$userfields = get_all_user_name_fields(true, 'u');
|
$userfields = helper::get_all_user_name_fields('u');
|
||||||
$sql = "SELECT u.id, u.username, $userfields, u.email, ci.id as issueid, ci.emailed
|
$sql = "SELECT u.id, u.username, $userfields, u.email, ci.id as issueid, ci.emailed
|
||||||
FROM {customcert_issues} ci
|
FROM {customcert_issues} ci
|
||||||
JOIN {user} u
|
JOIN {user} u
|
||||||
|
|
|
@ -93,7 +93,7 @@ if ($code) {
|
||||||
$result->issues = array();
|
$result->issues = array();
|
||||||
|
|
||||||
// Ok, now check if the code is valid.
|
// Ok, now check if the code is valid.
|
||||||
$userfields = get_all_user_name_fields(true, 'u');
|
$userfields = \mod_customcert\helper::get_all_user_name_fields('u');
|
||||||
$sql = "SELECT ci.id, u.id as userid, $userfields, co.id as courseid,
|
$sql = "SELECT ci.id, u.id as userid, $userfields, co.id as courseid,
|
||||||
co.fullname as coursefullname, c.id as certificateid,
|
co.fullname as coursefullname, c.id as certificateid,
|
||||||
c.name as certificatename, c.verifyany
|
c.name as certificatename, c.verifyany
|
||||||
|
|
Loading…
Reference in a new issue