See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
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 * Class for exporting the data needed to render a recent accessed item. 18 * 19 * @package block_recentlyaccesseditems 20 * @copyright 2018 Victor Deniz <victor@moodle.com> 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 namespace block_recentlyaccesseditems\external; 24 defined('MOODLE_INTERNAL') || die(); 25 26 use renderer_base; 27 use moodle_url; 28 29 /** 30 * Class for exporting the data needed to render a recent accessed item. 31 * 32 * @copyright 2018 Victor Deniz 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class recentlyaccesseditems_item_exporter extends \core\external\exporter { 36 /** 37 * Returns a list of objects that are related to this persistent. 38 * 39 */ 40 protected static function define_related() { 41 // We cache the context so it does not need to be retrieved from the course. 42 return array('context' => '\\context'); 43 } 44 45 /** 46 * Get the additional values to inject while exporting. 47 * 48 * @param renderer_base $output The renderer 49 * @return array Additional properties with values 50 */ 51 protected function get_other_values(renderer_base $output) { 52 global $CFG; 53 require_once($CFG->libdir.'/modinfolib.php'); 54 $iconurl = get_fast_modinfo($this->data->courseid)->cms[$this->data->cmid]->get_icon_url(); 55 $iconclass = $iconurl->get_param('filtericon') ? '' : 'nofilter'; 56 return array( 57 'viewurl' => (new moodle_url('/mod/'.$this->data->modname.'/view.php', 58 array('id' => $this->data->cmid)))->out(false), 59 'courseviewurl' => (new moodle_url('/course/view.php', array('id' => $this->data->courseid)))->out(false), 60 'icon' => \html_writer::img( 61 $iconurl, 62 get_string('pluginname', $this->data->modname), 63 ['title' => get_string('pluginname', $this->data->modname), 'class' => "icon $iconclass"] 64 ), 65 'purpose' => plugin_supports('mod', $this->data->modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER), 66 ); 67 } 68 69 /** 70 * Return the list of properties. 71 * 72 * @return array Properties. 73 */ 74 public static function define_properties() { 75 return array( 76 'id' => array( 77 'type' => PARAM_INT, 78 ), 79 'courseid' => array( 80 'type' => PARAM_INT, 81 ), 82 'cmid' => array( 83 'type' => PARAM_INT, 84 ), 85 'userid' => array( 86 'type' => PARAM_INT, 87 ), 88 'modname' => array( 89 'type' => PARAM_PLUGIN, 90 ), 91 'name' => array( 92 'type' => PARAM_TEXT, 93 ), 94 'coursename' => array( 95 'type' => PARAM_TEXT, 96 ), 97 'timeaccess' => array( 98 'type' => PARAM_INT, 99 ) 100 ); 101 } 102 103 /** 104 * Return the list of additional properties. 105 * 106 * @return array Additional properties. 107 */ 108 public static function define_other_properties() { 109 return array( 110 'viewurl' => array( 111 'type' => PARAM_RAW, 112 ), 113 'courseviewurl' => array( 114 'type' => PARAM_URL, 115 ), 116 'icon' => array( 117 'type' => PARAM_RAW, 118 ), 119 'purpose' => array( 120 'type' => PARAM_ALPHA, 121 ) 122 ); 123 } 124 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body