added shortcut-add-action link to sidebar menu
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -60,7 +60,7 @@ if (($page == 'customers' || $page == 'overview') && $userinfo['customers'] != '
|
||||
}
|
||||
|
||||
$actions_links = false;
|
||||
if ($userinfo['customers_used'] < $userinfo['customers'] || $userinfo['customers'] == '-1') {
|
||||
if (CurrentUser::canAddResource('customers')) {
|
||||
$actions_links = [
|
||||
[
|
||||
'href' => $linker->getLink(['section' => 'customers', 'page' => $page, 'action' => 'add']),
|
||||
|
||||
@@ -45,6 +45,7 @@ use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
use Froxlor\User;
|
||||
use Froxlor\Validate\Validate;
|
||||
use Froxlor\CurrentUser;
|
||||
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
@@ -63,7 +64,7 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
}
|
||||
|
||||
$actions_links = false;
|
||||
if (($userinfo['domains_used'] < $userinfo['domains'] || $userinfo['domains'] == '-1') && $customerCollection->count() != 0) {
|
||||
if (CurrentUser::canAddResource('domains')) {
|
||||
$actions_links = [];
|
||||
$actions_links[] = [
|
||||
'href' => $linker->getLink(['section' => 'domains', 'page' => $page, 'action' => 'add']),
|
||||
|
||||
@@ -40,6 +40,7 @@ use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
use Froxlor\Validate\Validate;
|
||||
use Froxlor\CurrentUser;
|
||||
|
||||
// redirect if this customer page is hidden via settings
|
||||
if (Settings::IsInList('panel.customer_hide_options', 'domains')) {
|
||||
@@ -64,7 +65,7 @@ if ($page == 'overview' || $page == 'domains') {
|
||||
}
|
||||
|
||||
$actions_links = false;
|
||||
if (($userinfo['subdomains_used'] < $userinfo['subdomains'] || $userinfo['subdomains'] == '-1') && $parentDomainCollection->count() != 0) {
|
||||
if (CurrentUser::canAddResource('subdomains')) {
|
||||
$actions_links = [
|
||||
[
|
||||
'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains', 'action' => 'add']),
|
||||
|
||||
@@ -40,6 +40,7 @@ use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
use Froxlor\Validate\Check;
|
||||
use Froxlor\CurrentUser;
|
||||
|
||||
// redirect if this customer page is hidden via settings
|
||||
if (Settings::IsInList('panel.customer_hide_options', 'email')) {
|
||||
@@ -71,7 +72,7 @@ if ($page == 'overview' || $page == 'emails') {
|
||||
$emaildomains_count = $result2['emaildomains'];
|
||||
|
||||
$actions_links = false;
|
||||
if (($userinfo['emails_used'] < $userinfo['emails'] || $userinfo['emails'] == '-1') && $emaildomains_count != 0) {
|
||||
if (CurrentUser::canAddResource('emails')) {
|
||||
$actions_links = [
|
||||
[
|
||||
'href' => $linker->getLink(['section' => 'email', 'page' => $page, 'action' => 'add']),
|
||||
|
||||
@@ -37,6 +37,7 @@ use Froxlor\UI\Listing;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
use Froxlor\CurrentUser;
|
||||
|
||||
// redirect if this customer page is hidden via settings
|
||||
if (Settings::IsInList('panel.customer_hide_options', 'ftp')) {
|
||||
@@ -57,7 +58,7 @@ if ($page == 'overview' || $page == 'accounts') {
|
||||
}
|
||||
|
||||
$actions_links = false;
|
||||
if ($userinfo['ftps_used'] < $userinfo['ftps'] || $userinfo['ftps'] == '-1') {
|
||||
if (CurrentUser::canAddResource('ftps')) {
|
||||
$actions_links = [
|
||||
[
|
||||
'href' => $linker->getLink(['section' => 'ftp', 'page' => 'accounts', 'action' => 'add']),
|
||||
|
||||
@@ -37,6 +37,7 @@ use Froxlor\UI\Listing;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
use Froxlor\CurrentUser;
|
||||
|
||||
// redirect if this customer page is hidden via settings
|
||||
if (Settings::IsInList('panel.customer_hide_options', 'mysql')) {
|
||||
@@ -66,7 +67,7 @@ if ($page == 'overview' || $page == 'mysqls') {
|
||||
}
|
||||
|
||||
$actions_links = false;
|
||||
if ($userinfo['mysqls_used'] < $userinfo['mysqls'] || $userinfo['mysqls'] == '-1') {
|
||||
if (CurrentUser::canAddResource('mysqls')) {
|
||||
$actions_links = [
|
||||
[
|
||||
'href' => $linker->getLink(['section' => 'mysql', 'page' => 'mysqls', 'action' => 'add']),
|
||||
|
||||
@@ -45,7 +45,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
*/
|
||||
private function validateAccess()
|
||||
{
|
||||
if ($this->isAdmin() == false || ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 0)) {
|
||||
if ($this->isAdmin() == false || ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 0)) {
|
||||
throw new Exception("You cannot access this resource", 405);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
namespace Froxlor;
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\UI\Collection;
|
||||
use Froxlor\Api\Commands\Customers;
|
||||
use Froxlor\Api\Commands\SubDomains;
|
||||
|
||||
/**
|
||||
* Class to manage the current user / session
|
||||
@@ -126,4 +129,30 @@ class CurrentUser
|
||||
{
|
||||
$_SESSION['userinfo'] = $data;
|
||||
}
|
||||
|
||||
public static function canAddResource(string $resource): bool
|
||||
{
|
||||
$addition = true;
|
||||
// special cases
|
||||
if ($resource == 'emails') {
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT COUNT(`id`) as emaildomains
|
||||
FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `customerid`= :cid AND `isemaildomain` = '1'
|
||||
");
|
||||
$result = Database::pexecute_first($result_stmt, [
|
||||
"cid" => $_SESSION['userinfo']['customerid']
|
||||
]);
|
||||
$addition = $result['emaildomains'] != 0;
|
||||
} elseif ($resource == 'subdomains') {
|
||||
$parentDomainCollection = (new Collection(SubDomains::class, $_SESSION['userinfo'], ['sql_search' => ['d.parentdomainid' => 0]]));
|
||||
$addition = $parentDomainCollection != 0;
|
||||
} elseif ($resource == 'domains') {
|
||||
$customerCollection = (new Collection(Customers::class, $_SESSION['userinfo']));
|
||||
$addition = $customerCollection != 0;
|
||||
}
|
||||
|
||||
return ($_SESSION['userinfo'][$resource.'_used'] < $_SESSION['userinfo'][$resource] || $_SESSION['userinfo'][$resource] == '-1') && $addition;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,7 +87,8 @@ class HTML
|
||||
'target' => $target,
|
||||
'active' => $active,
|
||||
'label' => $navlabel,
|
||||
'icon' => $icon
|
||||
'icon' => $icon,
|
||||
'add_shortlink' => $element['add_shortlink'] ?? null
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\CurrentUser;
|
||||
|
||||
return [
|
||||
'customer' => [
|
||||
@@ -36,12 +37,8 @@ return [
|
||||
[
|
||||
'url' => 'customer_email.php?page=emails',
|
||||
'label' => lng('menue.email.emails'),
|
||||
'required_resources' => 'emails'
|
||||
],
|
||||
[
|
||||
'url' => 'customer_email.php?page=emails&action=add',
|
||||
'label' => lng('emails.emails_add'),
|
||||
'required_resources' => 'emails'
|
||||
'required_resources' => 'emails',
|
||||
'add_shortlink' => CurrentUser::canAddResource('emails') ? 'customer_email.php?page=emails&action=add' : null,
|
||||
],
|
||||
[
|
||||
'url' => Settings::Get('panel.webmail_url'),
|
||||
@@ -61,7 +58,8 @@ return [
|
||||
[
|
||||
'url' => 'customer_mysql.php?page=mysqls',
|
||||
'label' => lng('menue.mysql.databases'),
|
||||
'required_resources' => 'mysqls'
|
||||
'required_resources' => 'mysqls',
|
||||
'add_shortlink' => CurrentUser::canAddResource('mysqls')? 'customer_mysql.php?page=mysqls&action=add' : null,
|
||||
],
|
||||
[
|
||||
'url' => Settings::Get('panel.phpmyadmin_url'),
|
||||
@@ -80,7 +78,8 @@ return [
|
||||
'elements' => [
|
||||
[
|
||||
'url' => 'customer_domains.php?page=domains',
|
||||
'label' => lng('menue.domains.settings')
|
||||
'label' => lng('menue.domains.settings'),
|
||||
'add_shortlink' => CurrentUser::canAddResource('subdomains') ? 'customer_domains.php?page=domains&action=add' : null,
|
||||
],
|
||||
[
|
||||
'url' => 'customer_domains.php?page=sslcertificates',
|
||||
@@ -96,7 +95,8 @@ return [
|
||||
'elements' => [
|
||||
[
|
||||
'url' => 'customer_ftp.php?page=accounts',
|
||||
'label' => lng('menue.ftp.accounts')
|
||||
'label' => lng('menue.ftp.accounts'),
|
||||
'add_shortlink' => CurrentUser::canAddResource('ftps') ? 'customer_ftp.php?page=accounts&action=add' : null,
|
||||
],
|
||||
[
|
||||
'url' => Settings::Get('panel.webftp_url'),
|
||||
@@ -115,12 +115,14 @@ return [
|
||||
[
|
||||
'url' => 'customer_extras.php?page=htpasswds',
|
||||
'label' => lng('menue.extras.directoryprotection'),
|
||||
'show_element' => (!Settings::IsInList('panel.customer_hide_options', 'extras.directoryprotection'))
|
||||
'show_element' => (!Settings::IsInList('panel.customer_hide_options', 'extras.directoryprotection')),
|
||||
'add_shortlink' => 'customer_extras.php?page=htpasswds&action=add',
|
||||
],
|
||||
[
|
||||
'url' => 'customer_extras.php?page=htaccess',
|
||||
'label' => lng('menue.extras.pathoptions'),
|
||||
'show_element' => (!Settings::IsInList('panel.customer_hide_options', 'extras.pathoptions'))
|
||||
'show_element' => (!Settings::IsInList('panel.customer_hide_options', 'extras.pathoptions')),
|
||||
'add_shortlink' => 'customer_extras.php?page=htaccess&action=add',
|
||||
],
|
||||
[
|
||||
'url' => 'customer_logger.php?page=log',
|
||||
@@ -160,17 +162,20 @@ return [
|
||||
[
|
||||
'url' => 'admin_customers.php?page=customers',
|
||||
'label' => lng('admin.customers'),
|
||||
'required_resources' => 'customers'
|
||||
'required_resources' => 'customers',
|
||||
'add_shortlink' => CurrentUser::canAddResource('customers') ? 'admin_customers.php?page=customers&action=add' : null,
|
||||
],
|
||||
[
|
||||
'url' => 'admin_admins.php?page=admins',
|
||||
'label' => lng('admin.admins'),
|
||||
'required_resources' => 'change_serversettings'
|
||||
'required_resources' => 'change_serversettings',
|
||||
'add_shortlink' => 'admin_admins.php?page=admins&action=add'
|
||||
],
|
||||
[
|
||||
'url' => 'admin_domains.php?page=domains',
|
||||
'label' => lng('admin.domains'),
|
||||
'required_resources' => 'domains'
|
||||
'required_resources' => 'domains',
|
||||
'add_shortlink' => CurrentUser::canAddResource('domains') ? 'admin_domains.php?page=domains&action=add' : null,
|
||||
],
|
||||
[
|
||||
'url' => 'admin_domains.php?page=sslcertificates',
|
||||
@@ -180,16 +185,20 @@ return [
|
||||
[
|
||||
'url' => 'admin_ipsandports.php?page=ipsandports',
|
||||
'label' => lng('admin.ipsandports.ipsandports'),
|
||||
'required_resources' => 'change_serversettings'
|
||||
'required_resources' => 'change_serversettings',
|
||||
'add_shortlink' => 'admin_ipsandports.php?page=ipsandports&action=add'
|
||||
],
|
||||
[
|
||||
'url' => 'admin_mysqlserver.php?page=mysqlserver',
|
||||
'label' => lng('admin.mysqlserver.mysqlserver'),
|
||||
'required_resources' => 'change_serversettings',
|
||||
'add_shortlink' => 'admin_mysqlserver.php?page=mysqlserver&action=add'
|
||||
],
|
||||
[
|
||||
'url' => 'admin_plans.php?page=overview',
|
||||
'label' => lng('admin.plans.plans'),
|
||||
'required_resources' => 'customers'
|
||||
'required_resources' => 'customers',
|
||||
'add_shortlink' => 'admin_plans.php?page=overview&action=add'
|
||||
],
|
||||
[
|
||||
'url' => 'admin_settings.php?page=updatecounters',
|
||||
@@ -262,12 +271,14 @@ return [
|
||||
[
|
||||
'url' => 'admin_phpsettings.php?page=overview',
|
||||
'label' => lng('menue.phpsettings.maintitle'),
|
||||
'show_element' => (Settings::Get('system.mod_fcgid') == true || Settings::Get('phpfpm.enabled') == true)
|
||||
'show_element' => (Settings::Get('system.mod_fcgid') == true || Settings::Get('phpfpm.enabled') == true),
|
||||
'add_shortlink' => 'admin_phpsettings.php?page=overview&action=add'
|
||||
],
|
||||
[
|
||||
'url' => 'admin_phpsettings.php?page=fpmdaemons',
|
||||
'label' => lng('menue.phpsettings.fpmdaemons'),
|
||||
'show_element' => Settings::Get('phpfpm.enabled') == true
|
||||
'show_element' => Settings::Get('phpfpm.enabled') == true,
|
||||
'add_shortlink' => 'admin_phpsettings.php?page=fpmdaemons&action=add'
|
||||
],
|
||||
[
|
||||
'url' => 'admin_settings.php?page=phpinfo',
|
||||
|
||||
@@ -12,8 +12,13 @@
|
||||
<div class="collapse {% if mitems.active == 1 %}show{% endif %}" id="sub{{ idx }}" aria-expanded="{% if mitems.active == 1 %}true{% else %}false{% endif %}">
|
||||
<ul class="flex-column ps-3 nav">
|
||||
{% for item in mitems.items %}
|
||||
<li class="nav-item" {% if item.active == 1 %}aria-current="page"{% endif %}>
|
||||
<a class="nav-link text-light {% if item.active == 1 %}active fw-bold{% endif %}" href="{{ item.url|raw }}">{{ item.label|raw }}</a>
|
||||
<li class="nav-item d-flex justify-content-between align-items-center" {% if item.active == 1 %}aria-current="page"{% endif %}>
|
||||
<div class="me-auto">
|
||||
<a class="nav-link text-light {% if item.active == 1 %}active fw-bold{% endif %}" href="{{ item.url|raw }}">{{ item.label|raw }}</a>
|
||||
</div>
|
||||
{% if item.add_shortlink is defined and item.add_shortlink is not empty %}
|
||||
<a href="{{ item.add_shortlink|raw }}" class="text-secondary me-2"><i class="fa-solid fa-plus-circle"></i></a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user