1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Extract user vault preprocessor. 19 * 20 * @package mod_forum 21 * @copyright 2018 Ryan Wyllie <ryan@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace mod_forum\local\vaults\preprocessors; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use user_picture; 30 31 /** 32 * Extract user vault preprocessor. 33 * 34 * Used to separate out the user record 35 * from a list of DB records that have been joined on the user table. 36 * 37 * @copyright 2018 Ryan Wyllie <ryan@moodle.com> 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class extract_user { 41 /** @var string $idalias The alias for the id property of the user */ 42 private $idalias; 43 /** @var string $alias The prefix used for each of the user properties */ 44 private $alias; 45 46 /** 47 * Constructor. 48 * 49 * @param string $idalias The alias for the id property of the user 50 * @param string $alias The prefix used for each of the user properties 51 */ 52 public function __construct(string $idalias, string $alias) { 53 $this->idalias = $idalias; 54 $this->alias = $alias; 55 } 56 57 /** 58 * Extract the user records from a list of DB records. 59 * 60 * @param stdClass[] $records The DB records 61 * @return stdClass[] The list of extracted users 62 */ 63 public function execute(array $records) : array { 64 $idalias = $this->idalias; 65 $alias = $this->alias; 66 67 return array_map(function($record) use ($idalias, $alias) { 68 return user_picture::unalias($record, ['deleted'], $idalias, $alias); 69 }, $records); 70 } 71 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body