MDL-69863 tool_brickfield: Removing plugin_installed event.

This commit is contained in:
Mike Churchward
2021-05-04 19:36:33 +02:00
committed by Eloy Lafuente (stronk7)
parent af73c3b374
commit 199eaa5e5b
6 changed files with 5 additions and 121 deletions
@@ -20,7 +20,6 @@ use context_system;
use core\log\sql_reader;
use moodle_url;
use stdClass;
use tool_brickfield\event\plugin_installed;
use tool_brickfield\local\tool\filter;
/**
@@ -109,14 +108,14 @@ class accessibility {
/**
* 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();
@@ -471,43 +470,6 @@ class accessibility {
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
@@ -1,54 +0,0 @@
<?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_brickfield\event;
use coding_exception;
use core\event\base;
use tool_brickfield\manager;
/**
* Class plugin_installed.
*
* @package tool_brickfield
* @author 2020 JM Tomas <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
*/
class plugin_installed extends base {
/**
* Init function.
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get name.
* @return string
*/
public static function get_name(): string {
return get_string('installed', manager::PLUGINNAME);
}
/**
* Get description.
* @return string
*/
public function get_description(): string {
return get_string('installeddescription', manager::PLUGINNAME);
}
}
@@ -17,7 +17,6 @@
namespace tool_brickfield;
use core\event\base;
use tool_brickfield\event\plugin_installed;
use stdClass;
/**
@@ -420,19 +419,6 @@ class eventobservers {
}
}
/**
* 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
-5
View File
@@ -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',
+2 -7
View File
@@ -97,17 +97,12 @@ if ($hassiteconfig) {
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);
+1 -1
View File
@@ -25,5 +25,5 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'tool_brickfield';
$plugin->version = 2020101918;
$plugin->version = 2020101919;
$plugin->requires = 2021042000;