Skip to content

Commit

Permalink
Fixed redirection to folders page or home
Browse files Browse the repository at this point in the history
  • Loading branch information
josaphatim committed Feb 21, 2024
1 parent c2037d9 commit a029114
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/advanced_search/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var expand_adv_folder_list = function(path) {
var detail = Hm_Utils.parse_folder_path(path, 'imap');
var list = $('.imap_'+detail.server_id+'_'+Hm_Utils.clean_selector(detail.folder), $('.adv_folder_list'));
if ($('li', list).length === 0) {
$('.expand_link', list).html('-');
$('.expand_link', list).html('<i class="bi bi-file-minus-fill"></i>');
if (detail) {
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_imap_folder_expand'},
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ var expand_imap_move_to_folders = function(path, context) {
var detail = Hm_Utils.parse_folder_path(path, 'imap');
var list = $('.imap_'+detail.server_id+'_'+Hm_Utils.clean_selector(detail.folder), $('.move_to_location'));
if ($('li', list).length === 0) {
$('.expand_link', list).html('-');
$('.expand_link', list).html('<i class="bi bi-file-minus-fill"></i>');
if (detail) {
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_imap_folder_expand'},
Expand Down
7 changes: 4 additions & 3 deletions modules/imap_folders/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public function process() {
if (array_key_exists('imap_server_id', $this->request->get)) {
var_dump($this->request->get['imap_server_id']);
$this->out('folder_server', $this->request->get['imap_server_id']);
$this->out('page', $this->request->get['page']);
}
}
}
Expand All @@ -345,7 +346,7 @@ public function process() {
$imap_server_id = $this->request->get['imap_server_id'];
$cache = Hm_IMAP_List::get_cache($this->cache, $imap_server_id);
$imap = Hm_IMAP_List::connect($imap_server_id, $cache);
if (is_object($imap) && $imap->get_state() == 'authenticated') {
if (imap_authed($imap)) {
$folder = hex2bin($form['folder']);
$success = $imap->mailbox_subscription($folder, $form['subscription_state']);
if ($success) {
Expand Down Expand Up @@ -380,7 +381,7 @@ class Hm_Output_folders_server_select extends Hm_Output_Module {
protected function output() {
$server_id = $this->get('folder_server', '');
$res = '<div class="folders_page mt-4 row mb-4"><div class="col-lg-5 col-sm-12"><form id="form_folder_imap" method="get">';
$res .= '<input type="hidden" name="page" value="folders" />';
$res .= '<input type="hidden" name="page" value="'.$this->get('page', 'folders').'" />';
$res .= '<div class="form-floating"><select class="form-select" id="imap_server_folder" name="imap_server_id">';
$res .= '<option ';
if (empty($server_id)) {
Expand Down Expand Up @@ -700,7 +701,7 @@ protected function output() {
if ($this->get('only_subscribed_folders_setting', 0) && ($server = $this->get('folder_server')) !== NULL) {
$res = '<div class="folder_row"><a href="#" class="subscribe_parent_folder" style="display:none;">';
$res .= $this->trans('Select Folder').'</a><span class="subscribe_parent"></span></div>';
$res .= '<ul class="folders subscribe_parent_folder_select"><li class="suscribe_title"></li></ul>';
$res .= '<ul class="folders subscribe_parent_folder_select"><li class="subscribe_title"></li></ul>';
$res .= '<input type="hidden" value="" id="subscribe_parent" />';
return $res;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/imap_folders/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
),
'allowed_output' => array(
'imap_folders_success' => array(FILTER_VALIDATE_INT, false),
'imap_special_name' => array(FILTER_DEFAULT, false)
'imap_special_name' => array(FILTER_DEFAULT, false),
'imap_folder_subscription' => array(FILTER_DEFAULT, false),
),
'allowed_get' => array(),
'allowed_post' => array(
Expand Down
11 changes: 8 additions & 3 deletions modules/imap_folders/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var expand_folders_page_list = function(path, container, link_class, target, id_
var detail = Hm_Utils.parse_folder_path(path, 'imap');
var list = $('.imap_'+detail.server_id+'_'+Hm_Utils.clean_selector(detail.folder), $('.'+container));
if ($('li', list).length === 0) {
$('.expand_link', list).html('-');
$('.expand_link', list).html('<i class="bi bi-file-minus-fill"></i>');
if (detail) {
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_imap_folder_expand'},
Expand Down Expand Up @@ -273,9 +273,14 @@ $(function() {
$('.settings_subtitle').on("click", function() { return Hm_Utils.toggle_page_section($(this).data('target')); });
}
if (hm_page_name() == 'folders_subscription') {
$('.subscribe_parent_folder').on("click", function() { return folder_page_folder_list('subscribe_parent_folder_select', 'suscribe_title', 'imap_parent_folder_link', '', 'subscribe_parent', true); });
$('.subscribe_parent_folder').on("click", function() { return folder_page_folder_list('subscribe_parent_folder_select', 'subscribe_title', 'imap_parent_folder_link', '', 'subscribe_parent', true); });
$('.subscribe_parent_folder').trigger('click');
$('.imap_parent_folder_link').trigger('click');
$($('.subscribe_parent_folder_select .imap_parent_folder_link')[0]).trigger('click');
const selected_imap_server = $('#imap_server_folder').val();
const email_folder_server = $(`.email_folders .imap_${selected_imap_server}_ .inner_list`);
if (email_folder_server && $(email_folder_server[0]).children().length) {
$($('.subscribe_parent_folder_select .imap_parent_folder_link')[0]).trigger('click');
}
}
$('.select_parent_folder').on("click", function() { return folder_page_folder_list('parent_folder_select', 'parent_title', 'imap_parent_folder_link', 'selected_parent', 'create_parent'); });
$('.select_rename_folder').on("click", function() { return folder_page_folder_list('rename_folder_select', 'rename_title', 'imap_rename_folder_link', 'selected_rename', 'rename_source'); });
Expand Down

0 comments on commit a029114

Please sign in to comment.