Skip to content

Commit

Permalink
[ENH] Implement Expose IMAP capabilities for sharing folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow243 committed Oct 4, 2024
1 parent a4af806 commit 586285d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
16 changes: 13 additions & 3 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ function prepare_imap_message_list($msgs, $mod, $type) {
$mod->out('formatted_message_list', $res);
}}

if (!hm_exists('open_share_folder_modal')) {
function open_share_folder_modal($folder, $id) {

}
}

/**
* Build HTML for a list of IMAP folders
* @subpackage imap/functions
Expand All @@ -111,7 +117,7 @@ function prepare_imap_message_list($msgs, $mod, $type) {
* @return string
*/
if (!hm_exists('format_imap_folder_section')) {
function format_imap_folder_section($folders, $id, $output_mod, $with_input = false) {
function format_imap_folder_section($folders, $id, $output_mod, $with_input = false, $can_share_folders = false) {
$results = '<ul class="inner_list">';
$manage = $output_mod->get('imap_folder_manage_link');

Expand All @@ -131,7 +137,7 @@ function format_imap_folder_section($folders, $id, $output_mod, $with_input = fa
$attrs .= ' class="folder-disabled"';
}
} else {
$attrs = 'data-id="imap_'.$id.'_'.$output_mod->html_safe($folder_name).
$attrs = 'id="main-link" data-id="imap_'.$id.'_'.$output_mod->html_safe($folder_name).
'" href="?page=message_list&amp;list_path='.
urlencode('imap_'.$id.'_'.$output_mod->html_safe($folder_name)).'"';
}
Expand All @@ -150,7 +156,11 @@ function format_imap_folder_section($folders, $id, $output_mod, $with_input = fa
if ($with_input) {
$results .= '<input type="checkbox" value="1" class="folder_subscription" id="'.$output_mod->html_safe($folder_name).'" name="'.$folder_name.'" '.($folder['subscribed']? 'checked="checked"': '').($folder['special']? ' disabled="disabled"': '').' />';
}
$results .= '<span class="unread_count unread_imap_'.$id.'_'.$output_mod->html_safe($folder_name).'"></span></li>';
$results .= '<span class="unread_count unread_imap_'.$id.'_'.$output_mod->html_safe($folder_name).'"></span>';
if($can_share_folders) {
$results .= '<div class="dropdown"><a href="#" class="action-link" data-bs-toggle="dropdown" aria-expanded="false"><i class="icon bi bi-three-dots-vertical"></i></a><ul class="dropdown-menu dropdown-menu"><li><a href="#" class="dropdown-item"><i class="icon bi bi-share"></i> Share</a></ul></div>';
}
$results .= '</li>';
}
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>';
Expand Down
1 change: 1 addition & 0 deletions modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ public function process() {
$with_subscription = isset($this->request->post['subscription_state']) && $this->request->post['subscription_state'];
$cache = Hm_IMAP_List::get_cache($this->cache, $form['imap_server_id']);
$imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache);
$this->out('can_share_folders', stripos($imap->get_capability(), 'ACL') !== false);
if (imap_authed($imap)) {
$quota_root = $imap->get_quota_root($folder ? $folder : 'INBOX');
if ($quota_root && isset($quota_root[0]['name'])) {
Expand Down
3 changes: 2 additions & 1 deletion modules/imap/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,9 @@ protected function output() {
$folder_data = $this->get('imap_expanded_folder_data', array());
$with_input = $this->get('with_input', false);
$folder = $this->get('folder', '');
$can_share_folders = $this->get('can_share_folders', false);
if (!empty($folder_data)) {
$res .= format_imap_folder_section($folder_data, $this->get('imap_expanded_folder_id'), $this, $with_input);
$res .= format_imap_folder_section($folder_data, $this->get('imap_expanded_folder_id'), $this, $with_input, $can_share_folders);
$quota = $this->get('quota');
$quota_max = $this->get('quota_max');
if (!$folder && $quota) {
Expand Down
19 changes: 19 additions & 0 deletions modules/imap/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -534,4 +534,23 @@

.fade-in {
animation-name: fadeIn;
}
li[class^="imap_"] .inner_list li[class^="imap_"] {
/* display: flex;
align-items: center; */
position: relative;
display: flex;
align-items: center;
border-radius: 4px;
margin: 2px 0;
transition: background-color .3s;
}
.inner_list li[class^="imap_"] #main-link {
flex-grow: 1;
}
.inner_list li[class^="imap_"] .action-link {
opacity: 0;
}
.inner_list li[class^="imap_"]:hover .action-link {
opacity: 1;
}

0 comments on commit 586285d

Please sign in to comment.