added a few more entities to globalsearch (admin-side)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -42,10 +42,10 @@ if ($page == 'overview') {
|
|||||||
|
|
||||||
UI::view('user/table.html.twig', [
|
UI::view('user/table.html.twig', [
|
||||||
'listing' => \Froxlor\UI\Listing::format($collection, $phpconf_list_data['phpconf_list']),
|
'listing' => \Froxlor\UI\Listing::format($collection, $phpconf_list_data['phpconf_list']),
|
||||||
'actions_links' => [[
|
'actions_links' => (bool)$userinfo['change_serversettings'] ? [[
|
||||||
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']),
|
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']),
|
||||||
'label' => $lng['admin']['phpsettings']['addnew']
|
'label' => $lng['admin']['phpsettings']['addnew']
|
||||||
]]
|
]] : []
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,10 +186,10 @@ if ($page == 'overview') {
|
|||||||
|
|
||||||
UI::view('user/table.html.twig', [
|
UI::view('user/table.html.twig', [
|
||||||
'listing' => \Froxlor\UI\Listing::format($collection, $fpmconf_list_data['fpmconf_list']),
|
'listing' => \Froxlor\UI\Listing::format($collection, $fpmconf_list_data['fpmconf_list']),
|
||||||
'actions_links' => [[
|
'actions_links' => (bool)$userinfo['change_serversettings'] ? [[
|
||||||
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']),
|
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']),
|
||||||
'label' => $lng['admin']['fpmsettings']['addnew']
|
'label' => $lng['admin']['fpmsettings']['addnew']
|
||||||
]]
|
]] : []
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ namespace Froxlor\Ajax;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Froxlor\Http\HttpClient;
|
use Froxlor\Http\HttpClient;
|
||||||
use Froxlor\PhpHelper;
|
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
use Froxlor\User;
|
|
||||||
use Froxlor\UI\Panel\UI;
|
use Froxlor\UI\Panel\UI;
|
||||||
use Froxlor\UI\Request;
|
use Froxlor\UI\Request;
|
||||||
|
|
||||||
@@ -223,152 +221,16 @@ class Ajax
|
|||||||
$searchtext = Request::get('searchtext');
|
$searchtext = Request::get('searchtext');
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
if ($searchtext && strlen(trim($searchtext)) > 2) {
|
|
||||||
|
|
||||||
$processed = [];
|
// settings
|
||||||
|
$result_settings = GlobalSearch::searchSettings($searchtext, $this->userinfo);
|
||||||
|
|
||||||
$stparts = explode(" ", $searchtext);
|
// all searchable entities
|
||||||
|
$result_entities = GlobalSearch::searchGlobal($searchtext, $this->userinfo);
|
||||||
|
|
||||||
foreach ($stparts as $searchtext) {
|
$result = array_merge($result_settings, $result_entities);
|
||||||
$searchtext = trim($searchtext);
|
|
||||||
|
|
||||||
// settings (if allowed)
|
|
||||||
if (isset($this->userinfo['adminsession']) && $this->userinfo['adminsession'] == 1) {
|
|
||||||
|
|
||||||
if ($this->userinfo['change_serversettings'] == 1) {
|
|
||||||
$settings_data = PhpHelper::loadConfigArrayDir(\Froxlor\Froxlor::getInstallDir() . '/actions/admin/settings/');
|
|
||||||
$results = array();
|
|
||||||
if (!isset($processed['settings'])) {
|
|
||||||
$processed['settings'] = [];
|
|
||||||
}
|
|
||||||
PhpHelper::recursive_array_search($searchtext, $settings_data, $results);
|
|
||||||
foreach ($results as $pathkey) {
|
|
||||||
$pk = explode(".", $pathkey);
|
|
||||||
if (count($pk) > 4) {
|
|
||||||
$settingkey = $pk[0] . '.' . $pk[1] . '.' . $pk[2] . '.' . $pk[3];
|
|
||||||
if (is_array($processed['settings']) && !array_key_exists($settingkey, $processed['settings'])) {
|
|
||||||
$processed['settings'][$settingkey] = true;
|
|
||||||
$sresult = $settings_data[$pk[0]][$pk[1]][$pk[2]][$pk[3]];
|
|
||||||
if ($sresult['type'] != 'hidden') {
|
|
||||||
if (!isset($result['settings'])) {
|
|
||||||
$result['settings'] = [];
|
|
||||||
}
|
|
||||||
$result['settings'][] = [
|
|
||||||
'title' => (is_array($sresult['label']) ? $sresult['label']['title'] : $sresult['label']),
|
|
||||||
'href' => 'admin_settings.php?page=overview&part=' . $pk[1] . '&em=' . $pk[3]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// customers
|
|
||||||
$searchfields = [
|
|
||||||
'c.loginname',
|
|
||||||
'c.name',
|
|
||||||
'c.firstname',
|
|
||||||
'c.company',
|
|
||||||
'c.street',
|
|
||||||
'c.zipcode',
|
|
||||||
'c.city',
|
|
||||||
'c.email',
|
|
||||||
'c.customernumber'
|
|
||||||
];
|
|
||||||
$collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Customers::class, $this->userinfo))
|
|
||||||
->addParam(['sql_search' => [
|
|
||||||
'_plainsql' => $this->searchStringSql($searchfields, $searchtext)
|
|
||||||
]]);
|
|
||||||
if ($collection->count() > 0) {
|
|
||||||
if (!isset($processed['customer'])) {
|
|
||||||
$processed['customer'] = [];
|
|
||||||
}
|
|
||||||
foreach ($collection->getList() as $cresult) {
|
|
||||||
if (is_array($processed['customer']) && !array_key_exists($cresult['customerid'], $processed['customer'])) {
|
|
||||||
$processed['customer'][$cresult['customerid']] = true;
|
|
||||||
if (!isset($result['customer'])) {
|
|
||||||
$result['customer'] = [];
|
|
||||||
}
|
|
||||||
$result['customer'][] = [
|
|
||||||
'title' => User::getCorrectFullUserDetails($cresult),
|
|
||||||
'href' => 'admin_customers.php?page=customers&action=edit&id=' . $cresult['customerid']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// domains
|
|
||||||
$searchfields = [
|
|
||||||
'd.domain',
|
|
||||||
'd.domain_ace',
|
|
||||||
'd.documentroot'
|
|
||||||
];
|
|
||||||
$collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Domains::class, $this->userinfo))
|
|
||||||
->addParam(['sql_search' => [
|
|
||||||
'_plainsql' => $this->searchStringSql($searchfields, $searchtext)
|
|
||||||
]]);
|
|
||||||
if ($collection->count() > 0) {
|
|
||||||
if (!isset($processed['domains'])) {
|
|
||||||
$processed['domains'] = [];
|
|
||||||
}
|
|
||||||
foreach ($collection->getList() as $cresult) {
|
|
||||||
if (is_array($processed['domains']) && !array_key_exists($cresult['id'], $processed['domains'])) {
|
|
||||||
$processed['domains'][$cresult['id']] = true;
|
|
||||||
if (!isset($result['domains'])) {
|
|
||||||
$result['domains'] = [];
|
|
||||||
}
|
|
||||||
$result['domains'][] = [
|
|
||||||
'title' => $cresult['domain_ace'],
|
|
||||||
'href' => 'admin_domains.php?page=domains&action=edit&id=' . $cresult['id']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // is-admin
|
|
||||||
else {
|
|
||||||
// subdomains
|
|
||||||
$searchfields = [
|
|
||||||
'd.domain',
|
|
||||||
'd.domain_ace',
|
|
||||||
'd.documentroot'
|
|
||||||
];
|
|
||||||
$collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Domains::class, $this->userinfo))
|
|
||||||
->addParam(['sql_search' => [
|
|
||||||
'_plainsql' => $this->searchStringSql($searchfields, $searchtext)
|
|
||||||
]]);
|
|
||||||
if ($collection->count() > 0) {
|
|
||||||
if (!isset($processed['domains'])) {
|
|
||||||
$processed['domains'] = [];
|
|
||||||
}
|
|
||||||
foreach ($collection->getList() as $cresult) {
|
|
||||||
if (is_array($processed['domains']) && !array_key_exists($cresult['domains'], $processed['domains'])) {
|
|
||||||
$processed['domains'][$cresult['id']] = true;
|
|
||||||
if (!isset($result['domains'])) {
|
|
||||||
$result['domains'] = [];
|
|
||||||
}
|
|
||||||
$result['domains'][] = [
|
|
||||||
'title' => $cresult['domain_ace'],
|
|
||||||
'href' => 'customer_domains.php?page=domains&action=edit&id=' . $cresult['id']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // is-customer
|
|
||||||
} // foreach splitted search-term
|
|
||||||
}
|
|
||||||
header("Content-type: application/json");
|
header("Content-type: application/json");
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function searchStringSql(array $searchfields, $searchtext)
|
|
||||||
{
|
|
||||||
$result = ['sql' => [], 'values' => []];
|
|
||||||
$result['sql'] = "(";
|
|
||||||
foreach ($searchfields as $sf) {
|
|
||||||
$result['sql'] .= $sf . " LIKE :searchtext OR ";
|
|
||||||
}
|
|
||||||
$result['sql'] = substr($result['sql'], 0, -3) . ")";
|
|
||||||
$result['values'] = ['searchtext' => '%' . $searchtext . '%'];
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
270
lib/Froxlor/Ajax/GlobalSearch.php
Normal file
270
lib/Froxlor/Ajax/GlobalSearch.php
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Froxlor\Ajax;
|
||||||
|
|
||||||
|
use Froxlor\Froxlor;
|
||||||
|
use Froxlor\PhpHelper;
|
||||||
|
use Froxlor\UI\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package AJAX
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class GlobalSearch
|
||||||
|
{
|
||||||
|
protected array $userinfo;
|
||||||
|
|
||||||
|
public static function searchSettings(string $searchtext, array $userinfo): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
if ($searchtext && strlen(trim($searchtext)) > 2) {
|
||||||
|
$processed = [];
|
||||||
|
$stparts = explode(" ", $searchtext);
|
||||||
|
foreach ($stparts as $searchtext) {
|
||||||
|
$searchtext = trim($searchtext);
|
||||||
|
|
||||||
|
// settings (if allowed)
|
||||||
|
if (isset($userinfo['adminsession']) && $userinfo['adminsession'] == 1 && $userinfo['change_serversettings'] == 1) {
|
||||||
|
|
||||||
|
$settings_data = PhpHelper::loadConfigArrayDir(Froxlor::getInstallDir() . '/actions/admin/settings/');
|
||||||
|
$results = array();
|
||||||
|
if (!isset($processed['settings'])) {
|
||||||
|
$processed['settings'] = [];
|
||||||
|
}
|
||||||
|
PhpHelper::recursive_array_search($searchtext, $settings_data, $results);
|
||||||
|
foreach ($results as $pathkey) {
|
||||||
|
$pk = explode(".", $pathkey);
|
||||||
|
if (count($pk) > 4) {
|
||||||
|
$settingkey = $pk[0] . '.' . $pk[1] . '.' . $pk[2] . '.' . $pk[3];
|
||||||
|
if (is_array($processed['settings']) && !array_key_exists($settingkey, $processed['settings'])) {
|
||||||
|
$processed['settings'][$settingkey] = true;
|
||||||
|
$sresult = $settings_data[$pk[0]][$pk[1]][$pk[2]][$pk[3]];
|
||||||
|
if ($sresult['type'] != 'hidden') {
|
||||||
|
if (!isset($result['settings'])) {
|
||||||
|
$result['settings'] = [];
|
||||||
|
}
|
||||||
|
$result['settings'][] = [
|
||||||
|
'title' => (is_array($sresult['label']) ? $sresult['label']['title'] : $sresult['label']),
|
||||||
|
'href' => 'admin_settings.php?page=overview&part=' . $pk[1] . '&em=' . $pk[3]
|
||||||
|
];
|
||||||
|
} // not hidden
|
||||||
|
} // if not processed
|
||||||
|
} // correct settingkey
|
||||||
|
} // foreach
|
||||||
|
} // admin + change_serversetting
|
||||||
|
} // foreach
|
||||||
|
} // searchtext min 3 chars
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function searchGlobal(string $searchtext, array $userinfo): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
if ($searchtext && strlen(trim($searchtext)) > 2) {
|
||||||
|
$processed = [];
|
||||||
|
|
||||||
|
$stparts = explode(" ", $searchtext);
|
||||||
|
|
||||||
|
foreach ($stparts as $searchtext) {
|
||||||
|
$searchtext = trim($searchtext);
|
||||||
|
|
||||||
|
// admin
|
||||||
|
if (isset($userinfo['adminsession']) && $userinfo['adminsession'] == 1) {
|
||||||
|
|
||||||
|
$toSearch = [
|
||||||
|
// customers
|
||||||
|
'customer' => [
|
||||||
|
'class' => \Froxlor\Api\Commands\Customers::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'c.loginname',
|
||||||
|
'c.name',
|
||||||
|
'c.firstname',
|
||||||
|
'c.company',
|
||||||
|
'c.street',
|
||||||
|
'c.zipcode',
|
||||||
|
'c.city',
|
||||||
|
'c.email',
|
||||||
|
'c.customernumber',
|
||||||
|
'c.custom_notes'
|
||||||
|
],
|
||||||
|
'result_key' => 'customerid',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['\\Froxlor\\User', 'getCorrectFullUserDetails'],
|
||||||
|
'href' => 'admin_customers.php?page=customers&action=edit&id='
|
||||||
|
]
|
||||||
|
],
|
||||||
|
// domains
|
||||||
|
'domains' => [
|
||||||
|
'class' => \Froxlor\Api\Commands\Domains::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'd.domain',
|
||||||
|
'd.domain_ace',
|
||||||
|
'd.documentroot'
|
||||||
|
],
|
||||||
|
'result_key' => 'id',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['self', 'getFieldFromResult'],
|
||||||
|
'title_args' => 'domain_ace',
|
||||||
|
'href' => 'admin_domains.php?page=domains&action=edit&id='
|
||||||
|
]
|
||||||
|
],
|
||||||
|
// ips and ports
|
||||||
|
'ipsandports' => [
|
||||||
|
'class' => \Froxlor\Api\Commands\IpsAndPorts::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'ip',
|
||||||
|
'vhostcontainer',
|
||||||
|
'specialsettings'
|
||||||
|
],
|
||||||
|
'result_key' => 'id',
|
||||||
|
'result_groupkey' => 'ip',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['self', 'getFieldFromResult'],
|
||||||
|
'title_args' => 'ip',
|
||||||
|
'href' => 'admin_ipsandports.php?page=ipsandports&action=edit&id='
|
||||||
|
]
|
||||||
|
],
|
||||||
|
// hosting-plans
|
||||||
|
'hostingplans' => [
|
||||||
|
'class' => \Froxlor\Api\Commands\HostingPlans::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'p.name',
|
||||||
|
'p.description'
|
||||||
|
],
|
||||||
|
'result_key' => 'id',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['self', 'getFieldFromResult'],
|
||||||
|
'title_args' => 'name',
|
||||||
|
'href' => 'admin_plans.php?page=overview&action=edit&id='
|
||||||
|
]
|
||||||
|
],
|
||||||
|
// PHP configs
|
||||||
|
'phpconfigs' => [
|
||||||
|
'class' => \Froxlor\Api\Commands\PhpSettings::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'c.description',
|
||||||
|
'fd.description',
|
||||||
|
'c.binary'
|
||||||
|
],
|
||||||
|
'result_key' => 'id',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['self', 'getFieldFromResult'],
|
||||||
|
'title_args' => 'description',
|
||||||
|
'href' => ((bool) $userinfo['change_serversettings'] ? 'admin_phpsettings.php?page=overview&action=edit&id=' : 'admin_phpsettings.php?page=overview&sid=')
|
||||||
|
]
|
||||||
|
],
|
||||||
|
// FPM daemons
|
||||||
|
'fpmconfigs' => [
|
||||||
|
'class' => \Froxlor\Api\Commands\FpmDaemons::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'description',
|
||||||
|
'reload_cmd'
|
||||||
|
],
|
||||||
|
'result_key' => 'id',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['self', 'getFieldFromResult'],
|
||||||
|
'title_args' => 'description',
|
||||||
|
'href' => ((bool) $userinfo['change_serversettings'] ? 'admin_phpsettings.php?page=fpmdaemons&action=edit&id=' : 'admin_phpsettings.php?page=fpmdaemons&sid=')
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
if ((bool) $userinfo['change_serversettings']) {
|
||||||
|
// admins
|
||||||
|
$toSearch['admins'] = [
|
||||||
|
'class' => \Froxlor\Api\Commands\Admins::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'loginname',
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'custom_notes'
|
||||||
|
],
|
||||||
|
'result_key' => 'adminid',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['self', 'getFieldFromResult'],
|
||||||
|
'title_args' => 'name',
|
||||||
|
'href' => 'admin_admins.php?page=admins&action=edit&id='
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$toSearch = [
|
||||||
|
// (sub)domains
|
||||||
|
'domains' => [
|
||||||
|
'class' => \Froxlor\Api\Commands\Domains::class,
|
||||||
|
'searchfields' => [
|
||||||
|
'd.domain',
|
||||||
|
'd.domain_ace',
|
||||||
|
'd.documentroot'
|
||||||
|
],
|
||||||
|
'result_key' => 'id',
|
||||||
|
'result_format' => [
|
||||||
|
'title' => ['self', 'getFieldFromResult'],
|
||||||
|
'title_args' => 'domain_ace',
|
||||||
|
'href' => 'customer_domains.php?page=domains&action=edit&id='
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($toSearch as $entity => $edata) {
|
||||||
|
|
||||||
|
$collection = (new Collection($edata['class'], $userinfo))
|
||||||
|
->addParam(['sql_search' => [
|
||||||
|
'_plainsql' => self::searchStringSql($edata['searchfields'], $searchtext)
|
||||||
|
]]);
|
||||||
|
if ($collection->count() > 0) {
|
||||||
|
if (!isset($processed[$entity])) {
|
||||||
|
$processed[$entity] = [];
|
||||||
|
}
|
||||||
|
$group_key = $edata['result_groupkey'] ?? $edata['result_key'];
|
||||||
|
foreach ($collection->getList() as $cresult) {
|
||||||
|
if (is_array($processed[$entity]) && !array_key_exists($cresult[$group_key], $processed[$entity])) {
|
||||||
|
$processed[$entity][$cresult[$group_key]] = true;
|
||||||
|
if (!isset($result[$entity])) {
|
||||||
|
$result[$entity] = [];
|
||||||
|
}
|
||||||
|
$result[$entity][] = [
|
||||||
|
'title' => call_user_func($edata['result_format']['title'], $cresult, ($edata['result_format']['title_args'] ?? null)),
|
||||||
|
'href' => $edata['result_format']['href'] . $cresult[$edata['result_key']]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // foreach entity
|
||||||
|
|
||||||
|
} // foreach splitted search-term
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function searchStringSql(array $searchfields, $searchtext)
|
||||||
|
{
|
||||||
|
$result = ['sql' => [], 'values' => []];
|
||||||
|
$result['sql'] = "(";
|
||||||
|
foreach ($searchfields as $sf) {
|
||||||
|
$result['sql'] .= $sf . " LIKE :searchtext OR ";
|
||||||
|
}
|
||||||
|
$result['sql'] = substr($result['sql'], 0, -3) . ")";
|
||||||
|
$result['values'] = ['searchtext' => '%' . $searchtext . '%'];
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getFieldFromResult(array $resultset, string $field = null)
|
||||||
|
{
|
||||||
|
return $resultset[$field] ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
27
lib/Froxlor/UI/Callbacks/Admin.php
Normal file
27
lib/Froxlor/UI/Callbacks/Admin.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Froxlor\UI\Callbacks;
|
||||||
|
|
||||||
|
use Froxlor\UI\Panel\UI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Froxlor\UI\Callbacks
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Admin
|
||||||
|
{
|
||||||
|
public static function canChangeServerSettings(array $attributes)
|
||||||
|
{
|
||||||
|
return (bool)UI::getCurrentUser()['change_serversettings'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ class PHPConf
|
|||||||
if ($subdomains_count == 0 && empty($domains)) {
|
if ($subdomains_count == 0 && empty($domains)) {
|
||||||
$domains = UI::getLng('admin.phpsettings.notused');
|
$domains = UI::getLng('admin.phpsettings.notused');
|
||||||
} else {
|
} else {
|
||||||
$domains .= (!empty($domains) ? '+ ' : '') . $subdomains_count . ' ' . UI::getLng(('customer.subdomains'));
|
$domains .= !empty($subdomains_count) ? ((!empty($domains) ? '+ ' : '') . $subdomains_count . ' ' . UI::getLng('customer.subdomains')) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $domains;
|
return $domains;
|
||||||
@@ -49,11 +49,15 @@ class PHPConf
|
|||||||
|
|
||||||
public static function isNotDefault(array $attributes)
|
public static function isNotDefault(array $attributes)
|
||||||
{
|
{
|
||||||
|
if (UI::getCurrentUser()['change_serversettings']) {
|
||||||
return $attributes['fields']['id'] != 1;
|
return $attributes['fields']['id'] != 1;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function fpmConfLink(array $attributes)
|
public static function fpmConfLink(array $attributes)
|
||||||
{
|
{
|
||||||
|
if (UI::getCurrentUser()['change_serversettings']) {
|
||||||
$linker = UI::getLinker();
|
$linker = UI::getLinker();
|
||||||
return [
|
return [
|
||||||
'macro' => 'link',
|
'macro' => 'link',
|
||||||
@@ -68,4 +72,6 @@ class PHPConf
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
return $attributes['data'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,7 +240,6 @@ return array(
|
|||||||
),
|
),
|
||||||
'server_php' => array(
|
'server_php' => array(
|
||||||
'label' => $lng['admin']['server_php'],
|
'label' => $lng['admin']['server_php'],
|
||||||
'required_resources' => 'change_serversettings',
|
|
||||||
'icon' => 'fab fa-php',
|
'icon' => 'fab fa-php',
|
||||||
'elements' => array(
|
'elements' => array(
|
||||||
array(
|
array(
|
||||||
@@ -251,7 +250,6 @@ return array(
|
|||||||
array(
|
array(
|
||||||
'url' => 'admin_phpsettings.php?page=fpmdaemons',
|
'url' => 'admin_phpsettings.php?page=fpmdaemons',
|
||||||
'label' => $lng['menue']['phpsettings']['fpmdaemons'],
|
'label' => $lng['menue']['phpsettings']['fpmdaemons'],
|
||||||
'required_resources' => 'change_serversettings',
|
|
||||||
'show_element' => \Froxlor\Settings::Get('phpfpm.enabled') == true
|
'show_element' => \Froxlor\Settings::Get('phpfpm.enabled') == true
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Froxlor\UI\Callbacks\Admin;
|
||||||
use Froxlor\UI\Callbacks\PHPConf;
|
use Froxlor\UI\Callbacks\PHPConf;
|
||||||
use Froxlor\UI\Listing;
|
use Froxlor\UI\Listing;
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ return [
|
|||||||
'action' => 'edit',
|
'action' => 'edit',
|
||||||
'id' => ':id'
|
'id' => ':id'
|
||||||
],
|
],
|
||||||
|
'visible' => [Admin::class, 'canChangeServerSettings']
|
||||||
],
|
],
|
||||||
'delete' => [
|
'delete' => [
|
||||||
'icon' => 'fa fa-trash',
|
'icon' => 'fa fa-trash',
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Froxlor\UI\Callbacks\Admin;
|
||||||
use Froxlor\UI\Callbacks\PHPConf;
|
use Froxlor\UI\Callbacks\PHPConf;
|
||||||
use Froxlor\UI\Listing;
|
use Froxlor\UI\Listing;
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
@@ -67,6 +68,7 @@ return [
|
|||||||
'action' => 'edit',
|
'action' => 'edit',
|
||||||
'id' => ':id'
|
'id' => ':id'
|
||||||
],
|
],
|
||||||
|
'visible' => [Admin::class, 'canChangeServerSettings']
|
||||||
],
|
],
|
||||||
'delete' => [
|
'delete' => [
|
||||||
'icon' => 'fa fa-trash',
|
'icon' => 'fa fa-trash',
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use Froxlor\FroxlorLogger;
|
|||||||
use Froxlor\Api\Commands\Certificates;
|
use Froxlor\Api\Commands\Certificates;
|
||||||
use Froxlor\UI\Collection;
|
use Froxlor\UI\Collection;
|
||||||
use Froxlor\UI\Listing;
|
use Froxlor\UI\Listing;
|
||||||
use Froxlor\UI\Pagination;
|
|
||||||
use Froxlor\UI\Panel\UI;
|
use Froxlor\UI\Panel\UI;
|
||||||
use Froxlor\UI\Response;
|
use Froxlor\UI\Response;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user