Skip to content

Commit

Permalink
MDL-69863 tool_brickfield: Removing plugin_installed event.
Browse files Browse the repository at this point in the history
  • Loading branch information
mchurchward authored and stronk7 committed May 4, 2021
1 parent 623c1b0 commit 03ada14
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 121 deletions.
42 changes: 2 additions & 40 deletions admin/tool/brickfield/classes/accessibility.php
Expand Up @@ -20,7 +20,6 @@
use core\log\sql_reader;
use moodle_url;
use stdClass;
use tool_brickfield\event\plugin_installed;
use tool_brickfield\local\tool\filter;

/**
Expand Down Expand Up @@ -109,14 +108,14 @@ public static function get_capability_name(string $capability): string {

/**
* Get the relevant title.
* @param local\tool\filter $filter
* @param filter $filter
* @param int $countdata
* @return string
* @throws \coding_exception
* @throws \dml_exception
* @throws \moodle_exception
*/
public static function get_title(local\tool\filter $filter, int $countdata): string {
public static function get_title(filter $filter, int $countdata): string {
global $DB;

$tmp = new \stdClass();
Expand Down Expand Up @@ -471,43 +470,6 @@ public static function get_category_courseids(int $categoryid): ?array {
return $courseids;
}

/**
* Plugin installed.
* @throws coding_exception
* @throws dml_exception
*/
public static function plugin_installed() {
global $USER;

$readers = get_log_manager()->get_readers(sql_reader::class);
$reader = reset($readers);
$select = 'eventname = :eventname AND action = :action AND target = :target';
$params = [
'eventname' => '\\' . manager::PLUGINNAME . '\event\plugin_installed',
'action' => 'installed',
'target' => 'plugin'
];
$logplugininstalled = $reader->get_events_select($select, $params, 'timecreated ASC', 0, 1);
if (empty($logplugininstalled)) {
$context = context_system::instance();
$pi = new stdClass();
$pi->userid = empty($USER->id) ? 0 : $USER->id;
$pi->contextid = $context->id;
$pi->component = manager::PLUGINNAME;
$pi->modifierid = $pi->userid;
$pi->sortorder = 0;
$event = plugin_installed::create([
'context' => $context,
'relateduserid' => $pi->userid,
'other' => [
'plugin' => $pi->component,
'installed' => 1
]
]);
$event->trigger();
}
}

/**
* Get summary data for this site.
* @param int $id
Expand Down
54 changes: 0 additions & 54 deletions admin/tool/brickfield/classes/event/plugin_installed.php

This file was deleted.

14 changes: 0 additions & 14 deletions admin/tool/brickfield/classes/eventobservers.php
Expand Up @@ -17,7 +17,6 @@
namespace tool_brickfield;

use core\event\base;
use tool_brickfield\event\plugin_installed;
use stdClass;

/**
Expand Down Expand Up @@ -420,19 +419,6 @@ public static function book_chapter_updated(\mod_book\event\chapter_updated $eve
}
}

/**
* Look for a plugin installed event.
* @param plugin_installed $event
* @throws \moodle_exception
*/
public static function plugin_installed(plugin_installed $event) {
// If this feature has been disabled, do nothing.
if (accessibility::is_accessibility_enabled()) {
$urlregistration = manager::registration_url();
redirect($urlregistration->out());
}
}

/**
* Add an observer record if appropriate.
* @param stdClass $data
Expand Down
5 changes: 0 additions & 5 deletions admin/tool/brickfield/db/events.php
Expand Up @@ -26,11 +26,6 @@
defined('MOODLE_INTERNAL') || die();

$observers = [
[
'eventname' => '\tool_brickfield\event\plugin_installed',
'callback' => '\tool_brickfield\eventobservers::plugin_installed',
'priority' => 1
],
[
'eventname' => '\core\event\course_category_created',
'callback' => '\tool_brickfield\eventobservers::course_category_created',
Expand Down
9 changes: 2 additions & 7 deletions admin/tool/brickfield/settings.php
Expand Up @@ -97,17 +97,12 @@
PARAM_INT
));

// Need to leave this as last addition to setting variable, as it triggers a callback.
$lastitem = new admin_setting_configtext(
$settings->add(new admin_setting_configtext(
manager::PLUGINNAME . '/perpage',
get_string('perpage', manager::PLUGINNAME),
'',
50,
PARAM_INT);
$lastitem->set_updatedcallback(static function(){
accessibility::plugin_installed();
});
$settings->add($lastitem);
PARAM_INT));

$ADMIN->add('brickfieldfolder', $settings);

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/brickfield/version.php
Expand Up @@ -25,5 +25,5 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'tool_brickfield';
$plugin->version = 2020101918;
$plugin->version = 2020101919;
$plugin->requires = 2021042000;

0 comments on commit 03ada14

Please sign in to comment.