Differences Between: [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
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 qbank_columnsortorder\external; 18 19 use context_system; 20 use core_external\external_api; 21 use core_external\external_function_parameters; 22 use core_external\external_multiple_structure; 23 use core_external\external_value; 24 use qbank_columnsortorder\column_manager; 25 26 /** 27 * External qbank_columnsortorder_set_columnbank_order API 28 * 29 * @package qbank_columnsortorder 30 * @category external 31 * @copyright 2021 Catalyst IT Australia Pty Ltd 32 * @author 2021, Ghaly Marc-Alexandre <marc-alexandreghaly@catalyst-ca.net> 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class set_columnbank_order extends external_api { 36 /** 37 * Returns description of method parameters. 38 * 39 * @return external_function_parameters 40 */ 41 public static function execute_parameters(): external_function_parameters { 42 return new external_function_parameters([ 43 'columns' => new external_multiple_structure( 44 new external_value(PARAM_TEXT, 'Plugin name for the column', VALUE_REQUIRED), 45 'List of column in the desired order', 46 VALUE_DEFAULT, 47 null, 48 NULL_ALLOWED, 49 ), 50 'global' => new external_value(PARAM_BOOL, 'Set global config setting, rather than user preference', 51 VALUE_DEFAULT, false), 52 ]); 53 } 54 55 /** 56 * Returns description of method result value. 57 * 58 */ 59 public static function execute_returns(): void { 60 } 61 62 /** 63 * Set columns order. 64 * 65 * @param ?array $columns List of column names in the desired order. Null value clears the setting. 66 * @param bool $global Set global config setting, rather than user preference 67 */ 68 public static function execute(?array $columns, bool $global = false): void { 69 [ 70 'columns' => $columns, 71 'global' => $global, 72 ] = self::validate_parameters(self::execute_parameters(), [ 73 'columns' => $columns, 74 'global' => $global, 75 ]); 76 77 $context = context_system::instance(); 78 self::validate_context($context); 79 if ($global) { 80 require_capability('moodle/site:config', $context); 81 } 82 83 column_manager::set_column_order($columns, $global); 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body