Files
Froxlor/lib/Froxlor/UI/Callbacks/Domain.php

99 lines
3.0 KiB
PHP

<?php
namespace Froxlor\UI\Callbacks;
use Froxlor\FileDir;
use Froxlor\Settings;
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 Domain
{
public static function domainTarget(array $attributes)
{
if (empty($attributes['fields']['aliasdomain'])) {
// path or redirect
if (preg_match('/^https?\:\/\//', $attributes['fields']['documentroot'])) {
return [
'macro' => 'link',
'data' => [
'text' => $attributes['fields']['documentroot'],
'href' => $attributes['fields']['documentroot'],
'target' => '_blank'
]
];
} else {
// show docroot nicely
if (strpos($attributes['fields']['documentroot'], UI::getCurrentUser()['documentroot']) === 0) {
$attributes['fields']['documentroot'] = FileDir::makeCorrectDir(str_replace(UI::getCurrentUser()['documentroot'], "/", $attributes['fields']['documentroot']));
}
return $attributes['fields']['documentroot'];
}
}
return UI::getLng('domains.aliasdomain') . ' ' . $attributes['fields']['aliasdomain'];
}
public static function canEdit(array $attributes): bool
{
return (bool)$attributes['fields']['caneditdomain'];
}
public static function canViewLogs(array $attributes): bool
{
return (bool)UI::getCurrentUser()['logviewenabled'];
}
public static function canDelete(array $attributes): bool
{
return $attributes['fields']['parentdomainid'] != '0'
&& empty($attributes['fields']['domainaliasid']);
}
public static function adminCanDelete(array $attributes): bool
{
return $attributes['fields']['id'] != Settings::Get('system.hostname_id')
&& empty($attributes['fields']['domainaliasid'])
&& $attributes['fields']['standardsubdomain'] != $attributes['fields']['id'];
}
public static function canEditDNS(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 static function adminCanEditDNS(array $attributes): bool
{
return $attributes['fields']['isbinddomain'] == '1'
&& Settings::Get('system.bind_enable') == '1'
&& Settings::Get('system.dnsenabled') == '1';
}
public function canEditSSL(array $attributes): bool
{
// FIXME: https://github.com/Froxlor/Froxlor/blob/master/templates/Sparkle/customer/domains/domains_domain.tpl#L41
return false;
}
public function canEditAlias(array $attributes): bool
{
return !empty($attributes['fields']['domainaliasid']);
}
}