Files
librenms-librenms/includes/html/pages/plugin/admin.inc.php

94 lines
2.7 KiB
PHP
Raw Normal View History

2014-02-25 12:51:07 +00:00
<?php
if (Auth::user()->hasGlobalAdmin()) {
2015-07-13 20:10:26 +02:00
// Scan for new plugins and add to the database
$new_plugins = scan_new_plugins();
$removed_plugins = scan_removed_plugins();
2014-02-25 12:51:07 +00:00
2015-07-13 20:10:26 +02:00
// Check if we have to toggle enabled / disable a particular module
2020-09-21 15:40:17 +02:00
$plugin_id = $_POST['plugin_id'];
2015-07-13 20:10:26 +02:00
$plugin_active = $_POST['plugin_active'];
if (is_numeric($plugin_id) && is_numeric($plugin_active)) {
if ($plugin_active == '0') {
$plugin_active = 1;
} elseif ($plugin_active == '1') {
2015-07-13 20:10:26 +02:00
$plugin_active = 0;
} else {
2015-07-13 20:10:26 +02:00
$plugin_active = 0;
}
2014-02-25 12:51:07 +00:00
2020-09-21 15:40:17 +02:00
if (dbUpdate(['plugin_active' => $plugin_active], 'plugins', '`plugin_id` = ?', [$plugin_id])) {
2015-07-13 20:10:26 +02:00
echo '
<script type="text/javascript">
$.ajax({
url: "",
context: document.body,
success: function(s,x){
$(this).html(s);
}
});
</script>
2015-07-13 20:10:26 +02:00
';
}
2020-09-21 15:43:38 +02:00
}//end if?>
2014-02-25 12:51:07 +00:00
<div class="panel panel-default panel-condensed">
<div class="panel-heading">
<strong>System plugins</strong>
</div>
<?php
if ($new_plugins > 0) {
echo '<div class="panel-body">
2014-02-25 12:51:07 +00:00
<div class="alert alert-warning">
2020-09-21 15:40:17 +02:00
We have found ' . $new_plugins . ' new plugins that need to be configured and enabled
2014-02-25 12:51:07 +00:00
</div>
2015-07-13 20:10:26 +02:00
</div>';
}
if ($removed_plugins > 0) {
echo '<div class="panel-body">
<div class="alert alert-warning">
2020-09-21 15:40:17 +02:00
We have found ' . $removed_plugins . ' removed plugins
</div>
</div>';
2020-09-21 15:40:17 +02:00
} ?>
2014-02-25 12:51:07 +00:00
<table class="table table-condensed">
<tr>
<th>Name</th>
<th>Action</th>
</tr>
<?php
foreach (dbFetchRows('SELECT * FROM plugins') as $plugins) {
if ($plugins['plugin_active'] == 1) {
$plugin_colour = 'bg-success';
$plugin_button = 'danger';
2020-09-21 15:40:17 +02:00
$plugin_label = 'Disable';
} else {
$plugin_colour = 'bg-danger';
$plugin_button = 'success';
2020-09-21 15:40:17 +02:00
$plugin_label = 'Enable';
}
2015-07-13 20:10:26 +02:00
2020-09-21 15:40:17 +02:00
echo '<tr class="' . $plugin_colour . '">
2014-02-25 12:51:07 +00:00
<td>
2020-09-21 15:40:17 +02:00
' . $plugins['plugin_name'] . '
2014-02-25 12:51:07 +00:00
</td>
<td>
2020-09-21 15:40:17 +02:00
<form class="form-inline" role="form" action="" method="post" id="' . $plugins['plugin_id'] . '" name=="' . $plugins['plugin_id'] . '">
' . csrf_field() . '
2020-09-21 15:40:17 +02:00
<input type="hidden" name="plugin_id" value="' . $plugins['plugin_id'] . '">
<input type="hidden" name="plugin_active" value="' . $plugins['plugin_active'] . '">
<button type="submit" class="btn btn-sm btn-' . $plugin_button . '">' . $plugin_label . '</button>
2014-02-25 12:51:07 +00:00
</form>
</td>
2015-07-13 20:10:26 +02:00
</tr>';
}//end foreach
?>
2014-02-25 12:51:07 +00:00
</table>
</div>
<?php
} else {
2020-09-21 15:40:17 +02:00
include 'includes/html/error-no-perm.inc.php';
}//end if