Skip to content

Commit

Permalink
MDL-73397 tool_admin_presets: Move data and API methods to new component
Browse files Browse the repository at this point in the history
A new component has been created, core_adminpresets, and tables and some
API methods from this tool have been moved there, so it can spread over
other plugins.
Currently, the tool_admin_presets plugin only provides the UI to interact
with the core adminpresets stuff.
  • Loading branch information
sarjona authored and Amaia Anabitarte committed Jan 4, 2022
1 parent 727f0d4 commit 8bf52e3
Show file tree
Hide file tree
Showing 73 changed files with 146 additions and 5,665 deletions.
2 changes: 1 addition & 1 deletion admin/tool/admin_presets/classes/event/preset_deleted.php
Expand Up @@ -43,6 +43,6 @@ public function get_legacy_logdata(): array {
protected function init(): void {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
Expand Up @@ -44,6 +44,6 @@ public function get_url(): \moodle_url {
protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
2 changes: 1 addition & 1 deletion admin/tool/admin_presets/classes/event/preset_exported.php
Expand Up @@ -48,6 +48,6 @@ public function get_legacy_logdata(): array {
protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
2 changes: 1 addition & 1 deletion admin/tool/admin_presets/classes/event/preset_imported.php
Expand Up @@ -48,6 +48,6 @@ public function get_legacy_logdata(): array {
protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
2 changes: 1 addition & 1 deletion admin/tool/admin_presets/classes/event/preset_loaded.php
Expand Up @@ -48,6 +48,6 @@ public function get_legacy_logdata(): array {
protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
Expand Up @@ -44,6 +44,6 @@ public function get_url(): \moodle_url {
protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
2 changes: 1 addition & 1 deletion admin/tool/admin_presets/classes/event/preset_reverted.php
Expand Up @@ -43,6 +43,6 @@ public function get_legacy_logdata(): array {
protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
2 changes: 1 addition & 1 deletion admin/tool/admin_presets/classes/event/presets_listed.php
Expand Up @@ -47,6 +47,6 @@ public function get_legacy_logdata(): array {
protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'tool_admin_presets';
$this->data['objecttable'] = 'adminpresets';
}
}
162 changes: 0 additions & 162 deletions admin/tool/admin_presets/classes/helper.php

This file was deleted.

4 changes: 2 additions & 2 deletions admin/tool/admin_presets/classes/local/action/base.php
Expand Up @@ -18,7 +18,7 @@

use context_system;
use moodle_url;
use tool_admin_presets\manager;
use core_adminpresets\manager;
use tool_admin_presets\output\presets_list;
use tool_admin_presets\output\export_import;

Expand Down Expand Up @@ -84,7 +84,7 @@ public function show(): void {
$options = new export_import();
$this->outputs = $OUTPUT->render($options);

$presets = $DB->get_records('tool_admin_presets');
$presets = $DB->get_records('adminpresets');
$list = new presets_list($presets, true);
$this->outputs .= $OUTPUT->render($list);
}
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/admin_presets/classes/local/action/delete.php
Expand Up @@ -35,7 +35,7 @@ public function show(): void {
global $DB, $OUTPUT;

// Getting the preset name.
$presetdata = $DB->get_record('tool_admin_presets', ['id' => $this->id], 'name');
$presetdata = $DB->get_record('adminpresets', ['id' => $this->id], 'name');

if ($presetdata) {
$deletetext = get_string('deletepreset', 'tool_admin_presets', $presetdata->name);
Expand All @@ -46,7 +46,7 @@ public function show(): void {
$cancelurl = new \moodle_url('/admin/tool/admin_presets/index.php');

// If the preset was applied add a warning text.
if ($DB->get_records('tool_admin_presets_app', ['adminpresetid' => $this->id])) {
if ($DB->get_records('adminpresets_app', ['adminpresetid' => $this->id])) {
$deletetext .= '<p><strong>' .
get_string("deletepreviouslyapplied", "tool_admin_presets") . '</strong></p>';
}
Expand All @@ -56,7 +56,7 @@ public function show(): void {
];
$this->outputs = $OUTPUT->confirm($deletetext, $confirmurl, $cancelurl, $displayoptions);
} else {
throw new moodle_exception('errordeleting', 'tool_admin_presets');
throw new moodle_exception('errordeleting', 'core_adminpresets');
}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/admin_presets/classes/local/action/load.php
Expand Up @@ -100,8 +100,8 @@ public function show(): void {
$data->id = $this->id;

// Preset data.
if (!$preset = $DB->get_record('tool_admin_presets', ['id' => $data->id])) {
throw new moodle_exception('errornopreset', 'tool_admin_presets');
if (!$preset = $DB->get_record('adminpresets', ['id' => $data->id])) {
throw new moodle_exception('errornopreset', 'core_adminpresets');
}

// Print preset basic data.
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/admin_presets/classes/local/action/rollback.php
Expand Up @@ -36,11 +36,11 @@ public function show(): void {
global $DB, $OUTPUT;

// Preset data.
$preset = $DB->get_record('tool_admin_presets', ['id' => $this->id]);
$preset = $DB->get_record('adminpresets', ['id' => $this->id]);

// Applications data.
$context = new stdClass();
$applications = $DB->get_records('tool_admin_presets_app', ['adminpresetid' => $this->id], 'time DESC');
$applications = $DB->get_records('adminpresets_app', ['adminpresetid' => $this->id], 'time DESC');
$context->noapplications = !empty($applications);
$context->applications = [];
foreach ($applications as $application) {
Expand Down Expand Up @@ -106,7 +106,7 @@ protected function get_title(): string {
global $DB;

$title = '';
if ($preset = $DB->get_record('tool_admin_presets', ['id' => $this->id])) {
if ($preset = $DB->get_record('adminpresets', ['id' => $this->id])) {
$title = get_string($this->action . $this->mode, 'tool_admin_presets', $preset->name);
}

Expand Down

This file was deleted.

0 comments on commit 8bf52e3

Please sign in to comment.