Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] modules.php : Modify the text to explain that Cypht supports JMAP (RFC8621) by default. #1277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions modules/nux/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ public function process() {
$smtp_servers = NULL;
$feed_servers = NULL;
$profiles = NULL;
$jmap_servers = NULL;

$modules = $this->config->get_modules();

if (data_source_available($modules, 'imap')) {
$imap_servers = count(Hm_IMAP_List::dump(false));
$imap_servers = Hm_IMAP_List::dump(false);
$jmap_servers = count(array_filter(Hm_IMAP_List::dump(false), function($v) { return array_key_exists('type', $v) && $v['type'] == 'jmap'; }));
}
if (data_source_available($modules, 'feeds')) {
$feed_servers = count(Hm_Feed_List::dump(false));
Expand All @@ -87,6 +89,7 @@ public function process() {

$this->out('nux_server_setup', array(
'imap' => $imap_servers,
'jmap' => $jmap_servers,
'feeds' => $feed_servers,
'smtp' => $smtp_servers,
'profiles' => $profiles
Expand Down Expand Up @@ -364,7 +367,7 @@ public function process()
continue;
}
}
}
}
if (! empty($server['smtp']['server'])) {
if (!$this->module_is_supported('smtp')) {
$errors[] = 'SMTP module is not enabled';
Expand Down Expand Up @@ -541,7 +544,7 @@ protected function output() {
class Hm_Output_nux_help extends Hm_Output_Module {
protected function output() {
return '<div class="nux_help mt-3 col-lg-6 col-md-12 col-sm-12"><div class="card"><div class="card-body"><div class="card_title"><h4>'.$this->trans('Help').'</h4></div>'.
$this->trans('Cypht is a webmail program. You can use it to access your E-mail accounts from any service that offers IMAP, or SMTP access - which most do.').' '.
$this->trans('Cypht is a webmail program. You can use it to access your E-mail accounts from any service that offers IMAP, or SMTP access - which most do. And Cypht also supports the newest protocol: JMAP (RFC8621).').' '.
'</div></div></div>';
}
}
Expand All @@ -563,6 +566,8 @@ protected function output() {
$res .= '<a class="mt-3 btn btn-light" href="?page=servers#quick_add_section"><i class="bi bi-person-plus me-3"></i>'.$this->trans('Add an E-mail Account').'</a>';
$res .= '</div><ul class="mt-4">';

$jmap_servers_count = count(array_filter($this->get('imap_servers', array()), function($v) { return array_key_exists('type', $v) && $v['type'] == 'jmap'; }));

foreach ($protos as $proto) {
$proto_dsp = $proto;
if ($proto == 'feeds') {
Expand Down Expand Up @@ -592,12 +597,12 @@ protected function output() {
$res .= sprintf(' <a href="?page=servers#%s_section">%s</a>', $proto, $this->trans('Add'));
}
else {
if ($server_data[$proto] > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need this if check to support the s for exemple source and sources

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already resolved here ($server_data[$proto] > 1 ? 'sources' : 'source') and here ($server_data[$proto] > 1 ? 'sources' : 'source').

$res .= sprintf($this->trans('You have %d %s sources'), $server_data[$proto], mb_strtoupper($proto_dsp));
}
else {
$res .= sprintf($this->trans('You have %d %s source'), $server_data[$proto], mb_strtoupper($proto_dsp));
}
$res .= sprintf(
$this->trans('You have %d %s%s'),
$server_data[$proto],
mb_strtoupper($proto_dsp),
($proto === 'imap' ? ' / JMAP ' . $server_data['jmap'] . ($server_data[$proto] > 1 ? ' sources' : ' source') : ($server_data[$proto] > 1 ? ' sources' : ' source'))
);
$res .= sprintf(' <a href="?page=servers#%s_section">%s</a>', $proto, $this->trans('Manage'));
}
$res .= '</li>';
Expand Down