Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   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 core_payment\event;
  18  
  19  use core\event\base;
  20  use core_payment\account;
  21  
  22  /**
  23   * Class account_deleted
  24   *
  25   * @package     core_payment
  26   * @copyright   2020 Marina Glancy
  27   * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  28   */
  29  
  30  
  31  /**
  32   * Class account_deleted
  33   *
  34   * @package     core_payment
  35   * @copyright   2020 Marina Glancy
  36   * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class account_deleted extends base {
  39  
  40      /**
  41       * Initialise event parameters.
  42       */
  43      protected function init() {
  44          $this->data['objecttable'] = 'payment_accounts';
  45          $this->data['crud'] = 'd';
  46          $this->data['edulevel'] = self::LEVEL_OTHER;
  47      }
  48  
  49      /**
  50       * Create an instance of the event and add a record snapshot
  51       *
  52       * @param account $account
  53       * @return base
  54       * @throws \coding_exception
  55       */
  56      public static function create_from_account(account $account) {
  57          $eventparams = [
  58              'objectid' => $account->get('id'),
  59              'context'  => $account->get_context(),
  60              'other'    => ['name' => $account->get('name')]
  61          ];
  62          $event = self::create($eventparams);
  63          $event->add_record_snapshot($event->objecttable, $account->to_record());
  64          return $event;
  65      }
  66  
  67      /**
  68       * Returns localised event name.
  69       *
  70       * @return string
  71       */
  72      public static function get_name() {
  73          return get_string('eventaccountdeleted', 'payment');
  74      }
  75  
  76      /**
  77       * Returns non-localised event description with id's for admin use only.
  78       *
  79       * @return string
  80       */
  81      public function get_description() {
  82          $name = s($this->other['name']);
  83          return "The user with id '$this->userid' deleted payment account with id '$this->objectid' and the name '{$name}'.";
  84      }
  85  
  86      /**
  87       * Returns relevant URL.
  88       *
  89       * @return \moodle_url
  90       */
  91      public function get_url() {
  92          return new \moodle_url('/payment/accounts.php');
  93      }
  94  }