Skip to content

Commit

Permalink
[FIX]Imap quota: fixing quota appears more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
Baraka24 authored and josaphatim committed Sep 27, 2024
1 parent 6e7caa1 commit 05a8a99
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 3 additions & 6 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ function prepare_imap_message_list($msgs, $mod, $type) {
function format_imap_folder_section($folders, $id, $output_mod, $with_input = false) {
$results = '<ul class="inner_list">';
$manage = $output_mod->get('imap_folder_manage_link');
$quota = $output_mod->get('quota');
$quota_max = $output_mod->get('quota_max');

foreach ($folders as $folder_name => $folder) {
$folder_name = bin2hex($folder_name);
$results .= '<li class="imap_'.$id.'_'.$output_mod->html_safe($folder_name).'">';
Expand Down Expand Up @@ -156,9 +155,7 @@ function format_imap_folder_section($folders, $id, $output_mod, $with_input = fa
if ($manage) {
$results .= '<li class="manage_folders_li"><i class="bi bi-gear-wide me-1"></i><a class="manage_folder_link" href="'.$manage.'">'.$output_mod->trans('Manage Folders').'</a></li>';
}
if ($quota) {
$results .= '<li class="manage_folders_li"><div class="progress bg-secondary border"><div class="progress-bar bg-light" style="width:'.$quota.'%"></div></div>'.$quota.'% used on '.$quota_max.' MB</li>';
}

$results .= '</ul>';
return $results;
}}
Expand Down Expand Up @@ -883,7 +880,7 @@ function imap_move_same_server($ids, $action, $hm_cache, $dest_path, $screen_ema
}
}
}

}
}
return $moved;
Expand Down
4 changes: 3 additions & 1 deletion modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ public function process() {
$this->out('imap_expanded_folder_id', $form['imap_server_id']);
$this->out('imap_expanded_folder_path', $path);
$this->out('with_input', $with_subscription);
$this->out('folder', $folder);
return;
}
if (imap_authed($imap)) {
Expand All @@ -790,6 +791,7 @@ public function process() {
$this->out('imap_expanded_folder_id', $form['imap_server_id']);
$this->out('imap_expanded_folder_path', $path);
$this->out('with_input', $with_subscription);
$this->out('folder', $folder);
}
else {
Hm_Msgs::add(sprintf('ERRCould not authenticate to the selected %s server (%s)', $imap->server_type, $this->user_config->get('imap_servers')[$form['imap_server_id']]['user']));
Expand Down Expand Up @@ -1926,7 +1928,7 @@ class Hm_Handler_imap_message_content extends Hm_Handler_Module {
*/
public function process() {
list($success, $form) = $this->process_form(array('imap_server_id', 'imap_msg_uid', 'folder'));

if ($success) {
$this->out('msg_text_uid', $form['imap_msg_uid']);
$this->out('msg_server_id', $form['imap_server_id']);
Expand Down
8 changes: 7 additions & 1 deletion modules/imap/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function output() {
$path = sprintf('?page=message_list&list_path=%s&screen_emails=1', $this->html_safe($this->get('list_path')));
$custom .= '<a title="'.sprintf($this->trans('Screen %s first emails'), $this->get('first_time_screen_emails')).
'" href="'. $path .'"><i class="bi bi-hand-thumbs-up-fill"></i></a>';
}
}
}
$this->out('custom_list_controls', $custom);
}
Expand Down Expand Up @@ -776,8 +776,14 @@ protected function output() {
$res = '';
$folder_data = $this->get('imap_expanded_folder_data', array());
$with_input = $this->get('with_input', false);
$folder = $this->get('folder', '');
if (!empty($folder_data)) {
$res .= format_imap_folder_section($folder_data, $this->get('imap_expanded_folder_id'), $this, $with_input);
$quota = $this->get('quota');
$quota_max = $this->get('quota_max');
if (!$folder && $quota) {
$res .= '<p class="quota_info"><div class="progress bg-secondary border"><div class="progress-bar bg-light" style="width:'.$quota.'%"></div></div>'.$quota.'% used on '.$quota_max.' MB</p>';
}
$this->out('imap_expanded_folder_formatted', $res);
}
}
Expand Down

0 comments on commit 05a8a99

Please sign in to comment.