check for existing fields when setting/updating tablelisting-columns
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -237,11 +237,11 @@ class Ajax
|
||||
private function updateTablelisting()
|
||||
{
|
||||
$columns = [];
|
||||
foreach ((Request::any('columns') ?? []) as $value) {
|
||||
foreach ((Request::post('columns') ?? []) as $value) {
|
||||
$columns[] = $value;
|
||||
}
|
||||
if (!empty($columns)) {
|
||||
Listing::storeColumnListingForUser([Request::any('listing') => $columns]);
|
||||
$columns = Listing::storeColumnListingForUser([Request::post('listing') => $columns]);
|
||||
return $this->jsonResponse($columns);
|
||||
}
|
||||
return $this->errorResponse('At least one column must be selected', 406);
|
||||
@@ -249,7 +249,7 @@ class Ajax
|
||||
|
||||
private function resetTablelisting()
|
||||
{
|
||||
Listing::deleteColumnListingForUser([Request::any('listing') => []]);
|
||||
Listing::deleteColumnListingForUser([Request::post('listing') => []]);
|
||||
return $this->jsonResponse([]);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Froxlor\UI;
|
||||
|
||||
use Froxlor\CurrentUser;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use InvalidArgumentException;
|
||||
|
||||
@@ -247,9 +248,9 @@ class Listing
|
||||
* ]
|
||||
*
|
||||
* @param array $tabellisting
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
public static function storeColumnListingForUser(array $tabellisting): bool
|
||||
public static function storeColumnListingForUser(array $tabellisting): array
|
||||
{
|
||||
$section = array_key_first($tabellisting);
|
||||
if (empty($section) || !is_array($tabellisting[$section]) || empty($tabellisting[$section])) {
|
||||
@@ -259,6 +260,22 @@ class Listing
|
||||
if (CurrentUser::isAdmin()) {
|
||||
$userid = 'adminid';
|
||||
}
|
||||
// include all possible tablelisting-definitions to check for the right section
|
||||
foreach(glob(Froxlor::getInstallDir().'lib/tablelisting/{,*/}*.php', GLOB_BRACE) as $tbl_file) {
|
||||
$table_listings = include $tbl_file;
|
||||
if (!isset($table_listings[$section])) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$columns_available = array_keys($table_listings[$section]['columns']);
|
||||
// filter out unknown columns
|
||||
foreach ($tabellisting[$section] as $index => $column_changed) {
|
||||
if (!in_array($column_changed, $columns_available)) {
|
||||
unset($tabellisting[$section][$index]);
|
||||
}
|
||||
}
|
||||
// delete possible existing entry
|
||||
self::deleteColumnListingForUser($tabellisting);
|
||||
// add new entry
|
||||
@@ -273,7 +290,7 @@ class Listing
|
||||
'section' => $section,
|
||||
'cols' => json_encode($tabellisting[$section])
|
||||
]);
|
||||
return true;
|
||||
return $tabellisting[$section];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,11 +29,14 @@ use Froxlor\UI\Callbacks\Style;
|
||||
use Froxlor\UI\Callbacks\Text;
|
||||
use Froxlor\UI\Listing;
|
||||
|
||||
// used outside scope variables
|
||||
$customerCollectionCount = !is_null($customerCollection ?? null) ? $customerCollection->count() : 0;
|
||||
|
||||
return [
|
||||
'domain_list' => [
|
||||
'title' => lng('admin.domains'),
|
||||
'icon' => 'fa-solid fa-globe',
|
||||
'empty_msg' => $customerCollection->count() == 0 ? lng('admin.domain_nocustomeraddingavailable') : '',
|
||||
'empty_msg' => $customerCollectionCount == 0 ? lng('admin.domain_nocustomeraddingavailable') : '',
|
||||
'self_overview' => ['section' => 'domains', 'page' => 'domains'],
|
||||
'default_sorting' => ['d.domain_ace' => 'asc'],
|
||||
'columns' => [
|
||||
|
||||
@@ -27,6 +27,9 @@ use Froxlor\UI\Callbacks\Ftp;
|
||||
use Froxlor\UI\Callbacks\Text;
|
||||
use Froxlor\UI\Listing;
|
||||
|
||||
// used outside scope variables
|
||||
$cperlenabled = $cperlenabled ?? false;
|
||||
|
||||
return [
|
||||
'htaccess_list' => [
|
||||
'title' => lng('menue.extras.pathoptions'),
|
||||
|
||||
@@ -27,6 +27,9 @@ use Froxlor\UI\Callbacks\Mysql;
|
||||
use Froxlor\UI\Callbacks\Text;
|
||||
use Froxlor\UI\Listing;
|
||||
|
||||
// used outside scope variables
|
||||
$multiple_mysqlservers = $multiple_mysqlservers ?? false;
|
||||
|
||||
return [
|
||||
'mysql_list' => [
|
||||
'title' => lng('menue.mysql.databases'),
|
||||
|
||||
@@ -27,6 +27,10 @@ use Froxlor\UI\Callbacks\Dns;
|
||||
use Froxlor\UI\Callbacks\Text;
|
||||
use Froxlor\UI\Listing;
|
||||
|
||||
// used outside scope variables
|
||||
$domain = $domain ?? '';
|
||||
$domain_id = $domain_id ?? '';
|
||||
|
||||
return [
|
||||
'dns_list' => [
|
||||
'title' => 'DNS Entries',
|
||||
|
||||
Reference in New Issue
Block a user