See Release Notes
Long Term Support Release
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 * Class for exporting data category. 19 * 20 * @package tool_dataprivacy 21 * @copyright 2018 David Monllao 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace tool_dataprivacy\external; 25 defined('MOODLE_INTERNAL') || die(); 26 27 use core\external\persistent_exporter; 28 use tool_dataprivacy\category; 29 use tool_dataprivacy\context_instance; 30 31 /** 32 * Class for exporting field data. 33 * 34 * @copyright 2018 David Monllao 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class category_exporter extends persistent_exporter { 38 39 /** 40 * Defines the persistent class. 41 * 42 * @return string 43 */ 44 protected static function define_class() { 45 return \tool_dataprivacy\category::class; 46 } 47 48 /** 49 * Returns a list of objects that are related. 50 * 51 * @return array 52 */ 53 protected static function define_related() { 54 return array( 55 'context' => 'context', 56 ); 57 } 58 59 /** 60 * Utility function that fetches a category name from the given ID. 61 * 62 * @param int $categoryid The category ID. Could be INHERIT (false, -1), NOT_SET (0), or the actual ID. 63 * @return string The purpose name. 64 */ 65 public static function get_name($categoryid) { 66 global $PAGE; 67 if ($categoryid === false || $categoryid == context_instance::INHERIT) { 68 return get_string('inherit', 'tool_dataprivacy'); 69 } else if ($categoryid == context_instance::NOTSET) { 70 return get_string('notset', 'tool_dataprivacy'); 71 } else { 72 $purpose = new category($categoryid); 73 $output = $PAGE->get_renderer('tool_dataprivacy'); 74 $exporter = new self($purpose, ['context' => \context_system::instance()]); 75 $data = $exporter->export($output); 76 return $data->name; 77 } 78 } 79 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body