public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Web] add app hide option
6e35574c
data/web/inc/functions.customize.inc.php | 6 ++++--
data/web/inc/header.inc.php | 24 ++++++++++++++++++++--
data/web/inc/vars.inc.php | 4 +++-
data/web/js/site/admin.js | 14 +++++++++++++
data/web/templates/admin/tab-config-customize.twig | 12 +++++++++++
data/web/templates/index.twig | 12 ++++++++---
6 files changed, 64 insertions(+), 8 deletions(-)
Diff
diff --git a/data/web/inc/functions.customize.inc.php b/data/web/inc/functions.customize.inc.php
index c4df924d..5aef7d72 100644
--- a/data/web/inc/functions.customize.inc.php
+++ b/data/web/inc/functions.customize.inc.php
@@ -123,12 +123,14 @@ function customize($_action, $_item, $_data = null) {
$apps = (array)$_data['app'];
$links = (array)$_data['href'];
$user_links = (array)$_data['user_href'];
+ $hide = (array)$_data['hide'];
$out = array();
- if (count($apps) == count($links) && count($apps) == count($user_links)) {
+ if (count($apps) == count($links) && count($apps) == count($user_links) && count($apps) == count($hide)) {
for ($i = 0; $i < count($apps); $i++) {
$out[] = array($apps[$i] => array(
'link' => $links[$i],
- 'user_link' => $user_links[$i]
+ 'user_link' => $user_links[$i],
+ 'hide' => ($hide[$i] === '0' || $hide[$i] === 0) ? false : true
));
}
try {
diff --git a/data/web/inc/header.inc.php b/data/web/inc/header.inc.php
index c0e16640..3f80423e 100644
--- a/data/web/inc/header.inc.php
+++ b/data/web/inc/header.inc.php
@@ -31,11 +31,29 @@ if(!file_exists($CSSPath)) {
}
$mailcow_apps_processed = $MAILCOW_APPS;
+$app_links = customize('get', 'app_links');
+$app_links_processed = $app_links;
+$hide_mailcow_apps = true;
for ($i = 0; $i < count($mailcow_apps_processed); $i++) {
+ if ($hide_mailcow_apps && !$mailcow_apps_processed[$i]['hide']){
+ $hide_mailcow_apps = false;
+ }
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']);
}
}
+if ($app_links_processed){
+ for ($i = 0; $i < count($app_links_processed); $i++) {
+ $key = array_key_first($app_links_processed[$i]);
+ if ($hide_mailcow_apps && !$app_links_processed[$i][$key]['hide']){
+ $hide_mailcow_apps = false;
+ }
+ if (!empty($_SESSION['mailcow_cc_username'])){
+ $app_links_processed[$i][$key]['user_link'] = str_replace('%u', $_SESSION['mailcow_cc_username'], $app_links_processed[$i][$key]['user_link']);
+ }
+ }
+}
+
$globalVariables = [
@@ -53,9 +71,11 @@ $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,
+ 'hide_mailcow_apps' => $hide_mailcow_apps,
'mailcow_apps' => $MAILCOW_APPS,
- 'app_links' => customize('get', 'app_links'),
+ 'mailcow_apps_processed' => $mailcow_apps_processed,
+ 'app_links' => $app_links,
+ 'app_links_processed' => $app_links_processed,
'is_root_uri' => (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/'),
'uri' => $_SERVER['REQUEST_URI'],
'last_login' => last_login('get', $_SESSION['mailcow_cc_username'], 7, 0)['ui']['time']
diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php
index afc801e4..18bc6328 100644
--- a/data/web/inc/vars.inc.php
+++ b/data/web/inc/vars.inc.php
@@ -122,7 +122,9 @@ $SHOW_DKIM_PRIV_KEYS = false;
$MAILCOW_APPS = array(
array(
'name' => 'Webmail',
- 'link' => '/SOGo/',
+ 'link' => '/SOGo/so/',
+ 'user_link' => '/sogo-auth.php?login=%u',
+ 'hide' => true
)
);
diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js
index 09555731..dd6dcce4 100644
--- a/data/web/js/site/admin.js
+++ b/data/web/js/site/admin.js
@@ -706,20 +706,34 @@ jQuery(function($){
}
})
// App links
+ // setup eventlistener
+ setAppHideEvent();
+ function setAppHideEvent(){
+ $('.app_hide').off('change');
+ $('.app_hide').on('change', function (e) {
+ var value = $(this).is(':checked') ? '1' : '0';
+ console.log(value)
+ $(this).parent().children(':first-child').val(value);
+ })
+ }
function add_table_row(table_id, type) {
var row = $('<tr />');
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><div class="d-flex align-items-center justify-content-center" style="height: 33.5px"><input data-id="app_links" type="hidden" name="hide" value="0"><input class="form-check-input app_hide" type="checkbox" value="1"></div></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>';
cols += '<td><input class="input-sm input-xs-lg form-control regex-input" data-id="f2b_regex" type="text" name="regex" 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>';
}
+
row.append(cols);
table_id.append(row);
+ if (type == "app_link")
+ setAppHideEvent();
}
$('#app_link_table').on('click', 'tr a', function (e) {
e.preventDefault();
diff --git a/data/web/templates/admin/tab-config-customize.twig b/data/web/templates/admin/tab-config-customize.twig
index 4b8f5323..93da2bfd 100644
--- a/data/web/templates/admin/tab-config-customize.twig
+++ b/data/web/templates/admin/tab-config-customize.twig
@@ -59,6 +59,7 @@
<th>{{ lang.admin.app_name }}</th>
<th>{{ lang.admin.link }}</th>
<th>{{ lang.admin.user_link }}</th>
+ <th>{{ lang.admin.app_hide }}</th>
<th style="width:100px;"> </th>
</tr>
{% for row in app_links %}
@@ -67,6 +68,12 @@
<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.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>
+ <div class="d-flex align-items-center justify-content-center" style="height: 33.5px">
+ <input data-id="app_links" type="hidden" name="hide" {% if val.hide %}value="1"{% else %}value="0"{% endif %}>
+ <input class="form-check-input app_hide" type="checkbox" value="1" {% if val.hide %}checked{% endif %}>
+ </div>
+ </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 %}
@@ -76,6 +83,11 @@
<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>
+ <div class="d-flex align-items-center justify-content-center" style="height: 33.5px">
+ <input class="form-check-input" data-id="app_links" type="checkbox" name="hide" value="1" disabled {% if app.hide %}checked{% endif %}>
+ </div>
+ </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 %}
diff --git a/data/web/templates/index.twig b/data/web/templates/index.twig
index bd4f8781..420bd531 100644
--- a/data/web/templates/index.twig
+++ b/data/web/templates/index.twig
@@ -67,19 +67,25 @@
<p><div class="my-4 alert alert-info">{{ lang.login.delayed|format(login_delay) }}</b></div></p>
{% endif %}
<div class="my-4" id="fido2-alerts"></div>
- {% if not oauth2_request and (mailcow_apps or app_links) %}
+ {% if not oauth2_request and (mailcow_apps or app_links) and not hide_mailcow_apps %}
<legend><i class="bi bi-link-45deg"></i> {{ ui_texts.apps_name|raw }}</legend><hr />
<div class="my-2 d-grid gap-2 d-sm-block apps">
{% for app in mailcow_apps %}
- {% if not skip_sogo or not is_uri('SOGo', app.link) %}
- <a href="{{ app.link }}" role="button" {% if app.description %}title="{{ app.description }}"{% endif %} class="btn btn-primary">{{ app.name }}</a>
+ {% if not app.hide %}
+ {% if not skip_sogo or not is_uri('SOGo', app.link) %}
+ <div class="m-2">
+ <a href="{{ app.link }}" role="button" {% if app.description %}title="{{ app.description }}"{% endif %} class="btn btn-primary btn-block">{{ app.name }}</a>
+ </div>
{% endif %}
+ {% endif %}
{% endfor %}
{% for row in app_links %}
{% for key, val in row %}
+ {% if not val.hide %}
<div class="m-2">
<a href="{{ val.link }}" role="button" class="btn btn-primary btn-block">{{ key }}</a>
</div>
+ {% endif %}
{% endfor %}
{% endfor %}
</div>