Differences Between: [Versions 400 and 402] [Versions 401 and 402]
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 namespace mod_lti\external; 18 19 use core_external\external_api; 20 use core_external\external_function_parameters; 21 use core_external\external_single_structure; 22 use core_external\external_value; 23 24 defined('MOODLE_INTERNAL') || die(); 25 26 global $CFG; 27 28 require_once($CFG->dirroot . '/mod/lti/locallib.php'); 29 30 /** 31 * External function for fetching the count of all tool types and proxies. 32 * 33 * @package mod_lti 34 * @author Andrew Madden <andrewmadden@catalyst-au.net> 35 * @copyright 2021 Catalyst IT 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class get_tool_types_and_proxies_count extends external_api { 39 40 /** 41 * Get parameter definition for get_tool_types_and_proxies_count(). 42 * 43 * @return external_function_parameters 44 */ 45 public static function execute_parameters(): external_function_parameters { 46 return new external_function_parameters( 47 [ 48 'toolproxyid' => new external_value(PARAM_INT, 'Tool proxy id', VALUE_DEFAULT, 0), 49 'orphanedonly' => new external_value(PARAM_BOOL, 'Orphaned tool types only', VALUE_DEFAULT, 0), 50 ] 51 ); 52 } 53 54 /** 55 * Get count of every tool type and tool proxy. 56 * 57 * @param int $toolproxyid The tool proxy id 58 * @param bool $orphanedonly Whether to get orphaned proxies only. 59 * @return array 60 */ 61 public static function execute($toolproxyid, $orphanedonly): array { 62 $params = self::validate_parameters(self::execute_parameters(), 63 [ 64 'toolproxyid' => $toolproxyid, 65 'orphanedonly' => $orphanedonly, 66 ]); 67 $toolproxyid = $params['toolproxyid']; 68 $orphanedonly = $params['orphanedonly']; 69 70 $context = \context_system::instance(); 71 self::validate_context($context); 72 require_capability('moodle/site:config', $context); 73 74 return [ 75 'count' => lti_get_lti_types_and_proxies_count($orphanedonly, $toolproxyid), 76 ]; 77 } 78 79 /** 80 * Get return definition for get_tool_types_and_proxies_count. 81 * 82 * @return external_single_structure 83 */ 84 public static function execute_returns(): external_single_structure { 85 return new external_single_structure([ 86 'count' => new external_value(PARAM_INT, 'Total number of tool types and proxies', VALUE_REQUIRED), 87 ]); 88 } 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body