plugins: allow to search for a plugin withing plugins_scan()

PR: https://github.com/opnsense/core/pull/1388
This commit is contained in:
Franco Fichtner 2017-02-09 09:37:16 +01:00
parent a0689d4f41
commit 42d13b904c

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2016-2017 Franco Fichtner <franco@opnsense.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -30,7 +30,7 @@
* scan plugins for legacy system
* @return array
*/
function plugins_scan()
function plugins_scan($search = '')
{
$path = '/usr/local/etc/inc/plugins.inc.d/';
$ext = '.inc';
@ -47,6 +47,9 @@ function plugins_scan()
foreach ($plugins as $plugin) {
$name = preg_replace('/' . preg_quote($path, '/') . '/', '', $plugin);
$name = preg_replace('/' . preg_quote($ext, '/') . '/', '', $name);
if (!empty($search) && $search !== $name) {
continue;
}
$ret[$name] = $plugin;
}