implement visible callbacks for tabellisting
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Froxlor\UI\Callbacks;
|
||||
|
||||
use Froxlor\FileDir;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
|
||||
/**
|
||||
@@ -44,4 +45,40 @@ class Domain
|
||||
}
|
||||
return UI::getLng('domains.aliasdomain') . ' ' . $attributes['fields']['aliasdomain'];
|
||||
}
|
||||
|
||||
public static function canEditDomain(array $attributes): bool
|
||||
{
|
||||
return (bool)$attributes['fields']['caneditdomain'];
|
||||
}
|
||||
|
||||
public static function canViewDomainLogs(array $attributes): bool
|
||||
{
|
||||
return (bool)UI::getCurrentUser()['logviewenabled'];
|
||||
}
|
||||
|
||||
public static function canDeleteDomain(array $attributes): bool
|
||||
{
|
||||
return $attributes['fields']['parentdomainid'] != '0'
|
||||
&& empty($attributes['fields']['domainaliasid']);
|
||||
}
|
||||
|
||||
public static function canEditDomainDNS(array $attributes): bool
|
||||
{
|
||||
return $attributes['fields']['isbinddomain'] == '1'
|
||||
&& UI::getCurrentUser()['dnsenabled'] == '1'
|
||||
&& $attributes['fields']['caneditdomain'] == '1'
|
||||
&& Settings::Get('system.bind_enable') == '1'
|
||||
&& Settings::Get('system.dnsenabled') == '1';
|
||||
}
|
||||
|
||||
public function canEditDomainSSL(array $attributes): bool
|
||||
{
|
||||
// FIXME: https://github.com/Froxlor/Froxlor/blob/master/templates/Sparkle/customer/domains/domains_domain.tpl#L41
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canEditDomainAlias(array $attributes): bool
|
||||
{
|
||||
return !empty($attributes['fields']['domainaliasid']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,11 @@ class Listing
|
||||
|
||||
// Check each action for a href
|
||||
foreach ($actions as $key => $action) {
|
||||
// Call user function if visible is an array
|
||||
if (isset($action['visible']) && is_array($action['visible'])) {
|
||||
$actions[$key]['visible'] = call_user_func($action['visible'], ['fields' => $item]);
|
||||
}
|
||||
|
||||
// Set link if href is an array
|
||||
if (isset($action['href']) && is_array($action['href'])) {
|
||||
// Search for "columns" in our href array
|
||||
|
||||
@@ -47,6 +47,7 @@ return [
|
||||
'action' => 'edit',
|
||||
'id' => ':id'
|
||||
],
|
||||
'visible' => [Domain::class, 'canEditDomain']
|
||||
],
|
||||
'logfiles' => [
|
||||
'icon' => 'fa fa-file',
|
||||
@@ -55,6 +56,7 @@ return [
|
||||
'page' => 'logfiles',
|
||||
'domain_id' => ':id'
|
||||
],
|
||||
'visible' => [Domain::class, 'canViewDomainLogs']
|
||||
],
|
||||
'domaindnseditor' => [
|
||||
'icon' => 'fa fa-globe',
|
||||
@@ -63,6 +65,7 @@ return [
|
||||
'page' => 'domaindnseditor',
|
||||
'domain_id' => ':id'
|
||||
],
|
||||
'visible' => [Domain::class, 'canEditDomainDNS']
|
||||
],
|
||||
'delete' => [
|
||||
'icon' => 'fa fa-trash',
|
||||
@@ -73,6 +76,7 @@ return [
|
||||
'action' => 'delete',
|
||||
'id' => ':id'
|
||||
],
|
||||
'visible' => [Domain::class, 'canDeleteDomain']
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\UI\Callbacks\Email;
|
||||
use Froxlor\UI\Callbacks\Text;
|
||||
use Froxlor\UI\Listing;
|
||||
@@ -43,12 +44,12 @@ return [
|
||||
'label' => $lng['emails']['catchall'],
|
||||
'field' => 'iscatchall',
|
||||
'format_callback' => [Text::class, 'boolean'],
|
||||
'visible' => \Froxlor\Settings::Get('catchall.catchall_enabled') == '1'
|
||||
'visible' => Settings::Get('catchall.catchall_enabled') == '1'
|
||||
],
|
||||
'm.quota' => [
|
||||
'label' => $lng['emails']['quota'],
|
||||
'field' => 'quota',
|
||||
'visible' => \Froxlor\Settings::Get('system.mail_quota_enabled') == '1'
|
||||
'visible' => Settings::Get('system.mail_quota_enabled') == '1'
|
||||
]
|
||||
],
|
||||
'visible_columns' => Listing::getVisibleColumnsForListing('email_list', [
|
||||
|
||||
Reference in New Issue
Block a user