Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 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 external_api;
  21  use external_function_parameters;
  22  use external_multiple_structure;
  23  use 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              )
  46          ]);
  47      }
  48  
  49      /**
  50       * Returns description of method result value.
  51       *
  52       */
  53      public static function execute_returns(): void {
  54      }
  55  
  56      /**
  57       * Returns the columns plugin order.
  58       *
  59       * @param array $columns json string representing new column order.
  60       */
  61      public static function execute(array $columns): void {
  62          ['columns' => $columns] = self::validate_parameters(self::execute_parameters(), ['columns' => $columns]);
  63          $context = context_system::instance();
  64          self::validate_context($context);
  65          require_capability('moodle/category:manage', $context);
  66  
  67          column_manager::set_column_order($columns);
  68      }
  69  }