[Web] add seperate link for logged in users
This commit is contained in:
parent
a3d3b06307
commit
226bdfac72
|
@ -103,10 +103,14 @@ function customize($_action, $_item, $_data = null) {
|
|||
case 'app_links':
|
||||
$apps = (array)$_data['app'];
|
||||
$links = (array)$_data['href'];
|
||||
$user_links = (array)$_data['user_href'];
|
||||
$out = array();
|
||||
if (count($apps) == count($links)) {
|
||||
if (count($apps) == count($links) && count($apps) == count($user_links)) {
|
||||
for ($i = 0; $i < count($apps); $i++) {
|
||||
$out[] = array($apps[$i] => $links[$i]);
|
||||
$out[] = array($apps[$i] => array(
|
||||
'link' => $links[$i],
|
||||
'user_link' => $user_links[$i]
|
||||
));
|
||||
}
|
||||
try {
|
||||
$redis->set('APP_LINKS', json_encode($out));
|
||||
|
@ -236,7 +240,22 @@ function customize($_action, $_item, $_data = null) {
|
|||
);
|
||||
return false;
|
||||
}
|
||||
return ($app_links) ? $app_links : false;
|
||||
|
||||
if (empty($app_links)){
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($app_links as $key => $value){
|
||||
foreach($value as $app => $details){
|
||||
if (empty($details['user_link']) || empty($_SESSION['mailcow_cc_username'])){
|
||||
$app_links[$key][$app]['user_link'] = $app_links[$key][$app]['link'];
|
||||
} else {
|
||||
$app_links[$key][$app]['user_link'] = str_replace('%u', $_SESSION['mailcow_cc_username'], $app_links[$key][$app]['user_link']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $app_links;
|
||||
break;
|
||||
case 'main_logo':
|
||||
try {
|
||||
|
|
|
@ -30,6 +30,14 @@ if(!file_exists($CSSPath)) {
|
|||
cleanupCSS($hash);
|
||||
}
|
||||
|
||||
$mailcow_apps_processed = $MAILCOW_APPS;
|
||||
for ($i = 0; $i < count($mailcow_apps_processed); $i++) {
|
||||
if (!empty($_SESSION['mailcow_cc_username'])){
|
||||
$mailcow_apps_processed[$i]['user_link'] = str_replace('%u', $_SESSION['mailcow_cc_username'], $mailcow_apps_processed[$i]['user_link']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$globalVariables = [
|
||||
'mailcow_hostname' => getenv('MAILCOW_HOSTNAME'),
|
||||
'mailcow_locale' => @$_SESSION['mailcow_locale'],
|
||||
|
@ -44,6 +52,7 @@ $globalVariables = [
|
|||
'lang' => $lang,
|
||||
'skip_sogo' => (getenv('SKIP_SOGO') == 'y'),
|
||||
'allow_admin_email_login' => (getenv('ALLOW_ADMIN_EMAIL_LOGIN') == 'n'),
|
||||
'mailcow_apps_processed' => $mailcow_apps_processed,
|
||||
'mailcow_apps' => $MAILCOW_APPS,
|
||||
'app_links' => customize('get', 'app_links'),
|
||||
'is_root_uri' => (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/'),
|
||||
|
|
|
@ -711,6 +711,7 @@ jQuery(function($){
|
|||
if (type == "app_link") {
|
||||
cols = '<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="app" required></td>';
|
||||
cols += '<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="href" required></td>';
|
||||
cols += '<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="user_href" required></td>';
|
||||
cols += '<td><a href="#" role="button" class="btn btn-sm btn-xs-lg btn-secondary h-100 w-100" type="button">' + lang.remove_row + '</a></td>';
|
||||
} else if (type == "f2b_regex") {
|
||||
cols = '<td><input style="text-align:center" class="input-sm input-xs-lg form-control" data-id="f2b_regex" type="text" value="+" disabled></td>';
|
||||
|
|
|
@ -54,13 +54,15 @@
|
|||
<tr>
|
||||
<th>{{ lang.admin.app_name }}</th>
|
||||
<th>{{ lang.admin.link }}</th>
|
||||
<th>{{ lang.admin.user_link }}</th>
|
||||
<th style="width:100px;"> </th>
|
||||
</tr>
|
||||
{% for row in app_links %}
|
||||
{% for key, val in row %}
|
||||
<tr>
|
||||
<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="app" required value="{{ key }}"></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="href" required value="{{ val }}"></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="href" required value="{{ val.link }}"></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="user_href" required value="{{ val.user_link }}"></td>
|
||||
<td><a href="#" role="button" class="btn btn-sm btn-xs-lg btn-secondary h-100 w-100" type="button">{{ lang.admin.remove_row }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -69,6 +71,7 @@
|
|||
<tr>
|
||||
<td><input class="input-sm input-xs-lg form-control" value="{{ app.name }}" disabled></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" value="{{ app.link }}" disabled></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" value="{{ app.user_link }}" disabled></td>
|
||||
<td><a href="#" role="button" class="btn btn-sm btn-xs-lg btn-secondary h-100 w-100 disabled" type="button">{{ lang.admin.remove_row }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<body>
|
||||
<div class="overlay"></div>
|
||||
{% block navbar %}
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-fixed-top p-0">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top p-0">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/"><img alt="mailcow-logo" src="{{ logo|default('/img/cow_mailcow.svg') }}"></a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
|
@ -57,49 +57,58 @@
|
|||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if mailcow_cc_role %}
|
||||
{% if mailcow_cc_role == 'admin' %}
|
||||
<li class="nav-item dropdown">
|
||||
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false">{{ lang.header.mailcow_system }}</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% if mailcow_cc_role == 'admin' %}
|
||||
<li><a href="/debug" class="dropdown-item {% if is_uri('debug') %}active{% endif %}">{{ lang.header.debug }}</a></li>
|
||||
<li><a href="/admin" class="dropdown-item {% if is_uri('admin') %}active{% endif %}">{{ lang.header.mailcow_config }}</a></li>
|
||||
{% endif %}
|
||||
{% if mailcow_cc_role != 'admin' %}
|
||||
<li><a href="/user" class="dropdown-item {% if is_uri('user') %}active{% endif %}">{{ lang.header.user_settings }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if mailcow_cc_role != 'admin' %}
|
||||
<li class="nav-item dropdown">
|
||||
<a href="/user" class="nav-link" role="button" aria-expanded="false">{{ lang.header.user_settings }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if mailcow_cc_role == 'admin' or mailcow_cc_role == 'domainadmin' %}
|
||||
<li class="nav-item dropdown">
|
||||
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false">{{ lang.header.email }}</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% if mailcow_cc_role == 'admin' or mailcow_cc_role == 'domainadmin' %}
|
||||
<li><a href="/mailbox" class="dropdown-item {% if is_uri('mailbox') %}active{% endif %}">{{ lang.header.mailcow_config }}</a></li>
|
||||
{% endif %}
|
||||
<li><a href="/quarantine" class="dropdown-item {% if is_uri('quarantine') %}active{% endif %}">{{ lang.header.quarantine }}</a></li>
|
||||
{% if mailcow_cc_role == 'admin' %}
|
||||
<li><a href="/queue" class="dropdown-item {% if is_uri('queue') %}active{% endif %}">{{ lang.queue.queue_manager }}</a></li>
|
||||
{% endif %}
|
||||
{% if mailcow_cc_role == 'admin' %}
|
||||
<li><a href="#" class="dropdown-item" data-bs-toggle="modal" data-container="sogo-mailcow" data-bs-target="#RestartContainer">{{ lang.header.restart_sogo }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if mailcow_apps or app_links %}
|
||||
|
||||
{% if mailcow_cc_role == 'user' %}
|
||||
<li class="nav-item dropdown">
|
||||
<a href="/quarantine" class="nav-link">{{ lang.header.quarantine }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if mailcow_apps_processed or app_links %}
|
||||
<li class="nav-item dropdown">
|
||||
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false"><i class="bi bi-link-45deg me-2"></i> {{ ui_texts.apps_name|raw }}</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for app in mailcow_apps %}
|
||||
{% if not skip_sogo or not is_uri('SOGo', app.link) %}
|
||||
{% for app in mailcow_apps_processed %}
|
||||
{% if not skip_sogo or not is_uri('SOGo', app.user_link) %}
|
||||
<li {% if app.description %}title="{{ app.description }}"{% endif %}>
|
||||
<a href="{{ app.link }}" class="dropdown-item">{{ app.name }}</a>
|
||||
<a href="{{ app.user_link }}" class="dropdown-item">{{ app.name }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for row in app_links %}
|
||||
{% for key, val in row %}
|
||||
<li><a href="{{ val }}" class="dropdown-item">{{ key }}</a></li>
|
||||
<li><a href="{{ val.user_link }}" class="dropdown-item">{{ key }}</a></li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -127,7 +136,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="container my-4">
|
||||
<div class="container flex-grow-1 my-4">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
{% for row in app_links %}
|
||||
{% for key, val in row %}
|
||||
<div class="m-2">
|
||||
<a href="{{ val }}" role="button" class="btn btn-primary btn-block">{{ key }}</a>
|
||||
<a href="{{ val.link }}" role="button" class="btn btn-primary btn-block">{{ key }}</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue