Skip to content

Commit

Permalink
Merge pull request cypht-org#1148 from Shadow243/imap-server-capabili…
Browse files Browse the repository at this point in the history
…ties

Add a way to display server capabilities
  • Loading branch information
kroky authored Aug 9, 2024
2 parents 7811877 + 1367ef8 commit 30233e9
Show file tree
Hide file tree
Showing 24 changed files with 94 additions and 2 deletions.
2 changes: 2 additions & 0 deletions language/az.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,4 +648,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/et.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/fa.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,4 +629,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/hu.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/id.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,4 +637,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/ja.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/pt-BR.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,4 +629,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/ro.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,4 +629,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,4 +631,6 @@
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
2 changes: 2 additions & 0 deletions language/zh-Hans.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,4 +651,6 @@
'Trash' => '已删除',
'Pasted text has leading or trailing spaces' => false,
'No tags available yet.' => false,
'Server capabilities' => false,
'Capabilities' => false,
);
28 changes: 28 additions & 0 deletions modules/developer/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,31 @@ protected function output() {
return '</tbody></table></div></div>';
}
}

/**
* Starts a capabilities table used on the info page
* @subpackage developer/output
*/
class Hm_Output_server_capabilities_start extends Hm_Output_Module {
/**
* Modules populate this table to run a status check from the info page
*/
protected function output() {
$res = '<div class="content_title px-3">'.$this->trans('Capabilities').'</div><div class="p-3"><table class="table table-borderless"><thead><tr><th class="text-secondary fw-light">'.$this->trans('Type').'</th><th class="text-secondary fw-light">'.$this->trans('Name').'</th><th class="text-secondary fw-light">'.
$this->trans('Server capabilities').'</th></tr></thead><tbody>';
return $res;
}
}

/**
* Close the capabilities table used on the info page
* @subpackage developer/output
*/
class Hm_Output_server_capabilities_end extends Hm_Output_Module {
/**
* Close the table opened in Hm_Output_server_capabilities_start
*/
protected function output() {
return '</tbody></table></div></div>';
}
}
4 changes: 3 additions & 1 deletion modules/developer/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
add_output('info', 'server_information', true, 'developer', 'info_heading', 'after');
add_output('info', 'server_status_start', true, 'developer', 'server_information', 'after');
add_output('info', 'server_status_end', true, 'developer', 'server_status_start', 'after');
add_output('info', 'config_map', true, 'developer', 'server_status_end', 'after');
add_output('info', 'server_capabilities_start', true, 'developer', 'server_status_end', 'after');
add_output('info', 'server_capabilities_end', true, 'developer', 'server_capabilities_start', 'after');
add_output('info', 'config_map', true, 'developer', 'server_capabilities_end', 'after');

/* folder list */
add_output('ajax_hm_folders', 'info_page_link', true, 'developer', 'settings_menu_end', 'before');
Expand Down
2 changes: 2 additions & 0 deletions modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1327,10 +1327,12 @@ public function process() {
$imap = Hm_IMAP_List::connect($id, $cache);
$this->out('imap_connect_time', microtime(true) - $start_time);
if (imap_authed($imap)) {
$this->out('imap_capabilities_list', $imap->get_capability());
$this->out('imap_connect_status', $imap->get_state());
$this->out('imap_status_server_id', $id);
}
else {
$this->out('imap_capabilities_list', "");
$this->out('imap_connect_status', 'disconnected');
$this->out('imap_status_server_id', $id);
}
Expand Down
24 changes: 24 additions & 0 deletions modules/imap/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,24 @@ protected function output() {
}
}

/**
* Format the IMAP status output on the info page
* @subpackage imap/output
*/
class Hm_Output_display_imap_capability extends Hm_Output_Module {
/**
* Build the HTML for the status rows. Will be populated by an ajax call per server
*/
protected function output() {
$res = '';
foreach ($this->get('imap_servers', array()) as $index => $vals) {
$res .= '<tr><td>IMAP</td><td>'.$vals['name'].'</td>'.
'<td class="imap_capabilities_'.$vals['id'].'"></td></tr>';
}
return $res;
}
}

/**
* Output a hidden field with all the IMAP server ids
* @subpackage imap/output
Expand Down Expand Up @@ -796,6 +814,12 @@ protected function output() {
$res .= '<span class="sieve_extensions">'.implode(', ', $capabilities).'</span>';
}
$this->out('sieve_detail_display', $res);
$res = '';
$extensions = $this->get('imap_capabilities_list', "");
if ($extensions) {
$res .= '<span class="imap_extensions">'.$extensions.'</span>';
}
$this->out('imap_extensions_display', $res);
}
}

Expand Down
2 changes: 2 additions & 0 deletions modules/imap/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/* add stuff to the info page */
add_output('info', 'display_imap_status', true, 'imap', 'server_status_start', 'after');
add_output('info', 'display_imap_capability', true, 'imap', 'server_capabilities_start', 'after');
add_output('info', 'imap_server_ids', true, 'imap', 'page_js', 'before');

/* servers page data */
Expand Down Expand Up @@ -345,6 +346,7 @@

'allowed_output' => array(
'imap_connect_status' => array(FILTER_DEFAULT, false),
'imap_capabilities_list' => array(FILTER_DEFAULT, false),
'connect_status' => array(FILTER_DEFAULT, false),
'auto_sent_folder' => array(FILTER_DEFAULT, false),
'imap_connect_time' => array(FILTER_DEFAULT, false),
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
.online {
color: var(--bs-primary);
}
.sieve_extensions {
.sieve_extensions,.imap_extensions {
font-size: 75%;
white-space: normal;
}
Expand Down
1 change: 1 addition & 0 deletions modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ var imap_status_update = function() {
var id = res.imap_status_server_id;
$('.imap_status_'+id).html(res.imap_status_display);
$('.imap_detail_'+id).html(res.sieve_detail_display);
$('.imap_capabilities_'+id).html(res.imap_extensions_display);
};
for (i=0;i<ids.length;i++) {
id=ids[i];
Expand Down
1 change: 1 addition & 0 deletions modules/sievefilters/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
'test_type' => array(FILTER_UNSAFE_RAW, false),
'mailboxes' => array(FILTER_UNSAFE_RAW, false),
'sieve_detail_display' => array(FILTER_UNSAFE_RAW, false),
'imap_extensions_display' => array(FILTER_UNSAFE_RAW, false),
'script_details' => array(FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY),
),
'allowed_get' => array(),
Expand Down

0 comments on commit 30233e9

Please sign in to comment.