Skip to content

Commit

Permalink
MDL-72112 admin_presets: Add admin_presets tool
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona authored and Amaia Anabitarte committed Dec 3, 2021
1 parent ecfded8 commit 9e4f2a4
Show file tree
Hide file tree
Showing 107 changed files with 9,880 additions and 3 deletions.
48 changes: 48 additions & 0 deletions admin/tool/admin_presets/classes/event/preset_deleted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_admin_presets\event;

use core\event\base;

/**
* Admin tool presets event class deleted.
*
* @package tool_admin_presets
* @copyright 2021 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó <david.monllao@urv.cat> code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class preset_deleted extends base {

public static function get_name(): string {
return get_string('eventpresetdeleted', 'tool_admin_presets');
}

public function get_description(): string {
return "User {$this->userid} has deleted the preset with id {$this->objectid}.";
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'delete', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
}
}
49 changes: 49 additions & 0 deletions admin/tool/admin_presets/classes/event/preset_downloaded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_admin_presets\event;

use core\event\base;

/**
* Admin tool presets event class downloaded.
*
* @package tool_admin_presets
* @copyright 2021 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó <david.monllao@urv.cat> code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class preset_downloaded extends base {

public static function get_name(): string {
return get_string('eventpresetdownloaded', 'tool_admin_presets');
}

public function get_description(): string {
return "User {$this->userid} has downloaded the preset with id {$this->objectid}.";
}

public function get_url(): \moodle_url {
return new \moodle_url('/admin/tool/admin_presets/index.php',
['action' => 'export', 'mode' => 'download_xml', 'id' => $this->objectid, 'sesskey' => sesskey()]);
}

protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
}
}
53 changes: 53 additions & 0 deletions admin/tool/admin_presets/classes/event/preset_exported.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_admin_presets\event;

use core\event\base;

/**
* Admin tool presets event class exported.
*
* @package tool_admin_presets
* @copyright 2021 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó <david.monllao@urv.cat> code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class preset_exported extends base {

public static function get_name(): string {
return get_string('eventpresetexported', 'tool_admin_presets');
}

public function get_description(): string {
return "User {$this->userid} has exported the preset with id {$this->objectid}.";
}

public function get_url(): \moodle_url {
return new \moodle_url('/admin/tool/admin_presets/index.php',
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'export', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
}
}
53 changes: 53 additions & 0 deletions admin/tool/admin_presets/classes/event/preset_imported.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_admin_presets\event;

use core\event\base;

/**
* Admin tool presets event class imported.
*
* @package tool_admin_presets
* @copyright 2021 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó <david.monllao@urv.cat> code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class preset_imported extends base {

public static function get_name(): string {
return get_string('eventpresetimported', 'tool_admin_presets');
}

public function get_description(): string {
return "User {$this->userid} has imported the preset with id {$this->objectid}.";
}

public function get_url(): \moodle_url {
return new \moodle_url('/admin/tool/admin_presets/index.php',
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'import', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
}
}
53 changes: 53 additions & 0 deletions admin/tool/admin_presets/classes/event/preset_loaded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_admin_presets\event;

use core\event\base;

/**
* Admin tool presets event class loaded.
*
* @package tool_admin_presets
* @copyright 2021 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó <david.monllao@urv.cat> code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class preset_loaded extends base {

public static function get_name(): string {
return get_string('eventpresetloaded', 'tool_admin_presets');
}

public function get_description(): string {
return "User {$this->userid} has loaded the preset with id {$this->objectid}.";
}

public function get_url(): \moodle_url {
return new \moodle_url('/admin/tool/admin_presets/index.php',
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'load', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
}
}
49 changes: 49 additions & 0 deletions admin/tool/admin_presets/classes/event/preset_previewed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_admin_presets\event;

use core\event\base;

/**
* Admin tool presets event class previewed.
*
* @package tool_admin_presets
* @copyright 2021 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó <david.monllao@urv.cat> code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class preset_previewed extends base {

public static function get_name(): string {
return get_string('eventpresetpreviewed', 'tool_admin_presets');
}

public function get_description(): string {
return "User {$this->userid} has previewed the preset with id {$this->objectid}.";
}

public function get_url(): \moodle_url {
return new \moodle_url('/admin/tool/admin_presets/index.php',
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
}

protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
}
}
48 changes: 48 additions & 0 deletions admin/tool/admin_presets/classes/event/preset_reverted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_admin_presets\event;

use core\event\base;

/**
* Admin tool presets event class reverted.
*
* @package tool_admin_presets
* @copyright 2021 Pimenko <support@pimenko.com><pimenko.com>
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó <david.monllao@urv.cat> code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class preset_reverted extends base {

public static function get_name(): string {
return get_string('eventpresetreverted', 'tool_admin_presets');
}

public function get_description(): string {
return "User {$this->userid} has reverted the preset with id {$this->objectid}.";
}

public function get_legacy_logdata(): array {
return [$this->courseid, 'tool_admin_presets', 'rollback', '', $this->objectid, $this->contextinstanceid];
}

protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
}
}
Loading

0 comments on commit 9e4f2a4

Please sign in to comment.