use name as unique identifier for plugins generally

This commit is contained in:
printempw 2017-01-08 16:09:54 +08:00
parent 954329a8e7
commit 07b3a025a5
2 changed files with 11 additions and 11 deletions

View File

@ -17,24 +17,24 @@ class PluginController extends Controller
public function manage(Request $request, PluginManager $plugins) public function manage(Request $request, PluginManager $plugins)
{ {
if ($request->has('action') && $request->has('id')) { if ($request->has('action') && $request->has('name')) {
$id = $request->get('id'); $name = $request->get('name');
if ($plugins->getPlugins()->has($id)) { if ($plugins->getPlugins()->has($name)) {
$plugin = $plugins->getPlugin($id); $plugin = $plugins->getPlugin($name);
// pass the plugin title through the translator // pass the plugin title through the translator
$plugin->title = trans($plugin->title); $plugin->title = trans($plugin->title);
switch ($request->get('action')) { switch ($request->get('action')) {
case 'enable': case 'enable':
$plugins->enable($id); $plugins->enable($name);
return json(trans('admin.plugins.operations.enabled', ['plugin' => $plugin->title]), 0); return json(trans('admin.plugins.operations.enabled', ['plugin' => $plugin->title]), 0);
break; break;
case 'disable': case 'disable':
$plugins->disable($id); $plugins->disable($name);
return json(trans('admin.plugins.operations.disabled', ['plugin' => $plugin->title]), 0); return json(trans('admin.plugins.operations.disabled', ['plugin' => $plugin->title]), 0);
break; break;
@ -43,7 +43,7 @@ class PluginController extends Controller
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
event(new Events\PluginWasDeleted($plugin)); event(new Events\PluginWasDeleted($plugin));
$plugins->uninstall($id); $plugins->uninstall($name);
return json(trans('admin.plugins.operations.deleted'), 0); return json(trans('admin.plugins.operations.deleted'), 0);
} }

View File

@ -2,7 +2,7 @@
* @Author: printempw * @Author: printempw
* @Date: 2016-07-22 14:02:44 * @Date: 2016-07-22 14:02:44
* @Last Modified by: printempw * @Last Modified by: printempw
* @Last Modified time: 2017-01-02 15:30:42 * @Last Modified time: 2017-01-08 16:07:24
*/ */
'use strict'; 'use strict';
@ -299,7 +299,7 @@ function deletePlayer(pid) {
function enablePlugin(name) { function enablePlugin(name) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "?action=enable&id=" + name, url: "?action=enable&name=" + name,
dataType: "json", dataType: "json",
success: function(json) { success: function(json) {
if (json.errno == 0) { if (json.errno == 0) {
@ -317,7 +317,7 @@ function enablePlugin(name) {
function disablePlugin(name) { function disablePlugin(name) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "?action=disable&id=" + name, url: "?action=disable&name=" + name,
dataType: "json", dataType: "json",
success: function(json) { success: function(json) {
if (json.errno == 0) { if (json.errno == 0) {
@ -340,7 +340,7 @@ function deletePlugin(name) {
}).then(function() { }).then(function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "?action=delete&id=" + name, url: "?action=delete&name=" + name,
dataType: "json", dataType: "json",
success: function(json) { success: function(json) {
if (json.errno == 0) { if (json.errno == 0) {