Skip to content

Commit

Permalink
backport UI/Callback fixes from 2.2-dev (main); fixes #1235
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Feb 4, 2024
1 parent 775d503 commit c188f04
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/Froxlor/UI/Callbacks/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace Froxlor\UI\Callbacks;

use Froxlor\CurrentUser;
use Froxlor\Database\Database;
use Froxlor\Domain\Domain as DDomain;
use Froxlor\FileDir;
Expand Down Expand Up @@ -113,7 +114,7 @@ public static function canEdit(array $attributes): bool

public static function canViewLogs(array $attributes): bool
{
if ((int)$attributes['fields']['email_only'] == 0 && !$attributes['fields']['deactivated']) {
if ((!CurrentUser::isAdmin() || (CurrentUser::isAdmin() && (int)$attributes['fields']['email_only'] == 0)) && !$attributes['fields']['deactivated']) {
if ((int)UI::getCurrentUser()['adminsession'] == 0 && (bool)UI::getCurrentUser()['logviewenabled']) {
return true;
} elseif ((int)UI::getCurrentUser()['adminsession'] == 1) {
Expand Down Expand Up @@ -155,7 +156,7 @@ public static function adminCanEditDNS(array $attributes): bool

public static function hasLetsEncryptActivated(array $attributes): bool
{
return ((bool)$attributes['fields']['letsencrypt'] && (int)$attributes['fields']['email_only'] == 0);
return ((bool)$attributes['fields']['letsencrypt'] && (!CurrentUser::isAdmin() || (CurrentUser::isAdmin() && (int)$attributes['fields']['email_only'] == 0)));
}

public static function canEditSSL(array $attributes): bool
Expand All @@ -165,7 +166,7 @@ public static function canEditSSL(array $attributes): bool
&& DDomain::domainHasSslIpPort($attributes['fields']['id'])
&& (int)$attributes['fields']['caneditdomain'] == 1
&& (int)$attributes['fields']['letsencrypt'] == 0
&& (int)$attributes['fields']['email_only'] == 0
&& (!CurrentUser::isAdmin() || (CurrentUser::isAdmin() && (int)$attributes['fields']['email_only'] == 0))
&& !$attributes['fields']['deactivated']
) {
return true;
Expand Down
3 changes: 2 additions & 1 deletion lib/Froxlor/UI/Callbacks/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace Froxlor\UI\Callbacks;

use Froxlor\CurrentUser;
use Froxlor\Settings;

class Style
Expand Down Expand Up @@ -68,7 +69,7 @@ public static function resultDomainTerminatedOrDeactivated(array $attributes): s
$termination_css = 'table-danger';
}
}
$deactivated = $attributes['fields']['deactivated'] || $attributes['fields']['customer_deactivated'];
$deactivated = $attributes['fields']['deactivated'] || (CurrentUser::isAdmin() && $attributes['fields']['customer_deactivated']);
return $deactivated ? 'table-info' : $termination_css;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Froxlor/UI/Callbacks/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ public static function wordwrap(array $attributes): string
public static function customerNoteDetailModal(array $attributes): array
{
$note = $attributes['fields']['custom_notes'] ?? '';
$key = $attributes['fields']['customerid'] ?? $attributes['fields']['adminid'];
return [
'entry' => $attributes['fields']['id'],
'id' => 'cnModal' . $attributes['fields']['id'],
'entry' => $key,
'id' => 'cnModal' . $key,
'title' => lng('usersettings.custom_notes.title') . ': ' . ($attributes['fields']['loginname'] ?? $attributes['fields']['adminname']),
'body' => nl2br(Markdown::cleanCustomNotes($note))
];
Expand Down
3 changes: 2 additions & 1 deletion lib/Froxlor/UI/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public static function prefetchFormFieldData($fieldname, $fielddata)
{
$returnvalue = [];
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] == 'select') {
if ((!is_array($fielddata['select_var']) || empty($fielddata['select_var'])) && (isset($fielddata['option_options_method']))) {
if ((empty($fielddata['select_var']) || !is_array($fielddata['select_var'])) && (isset($fielddata['option_options_method']))
) {
$returnvalue['select_var'] = call_user_func($fielddata['option_options_method']);
}
}
Expand Down

0 comments on commit c188f04

Please sign in to comment.