Skip to content

Commit

Permalink
Revert "Fixed tag display content" (cypht-org#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
mercihabam authored Nov 18, 2024
1 parent f4b06d6 commit eeab367
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 52 deletions.
6 changes: 1 addition & 5 deletions modules/core/js_modules/Hm_MessagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ class Hm_MessagesStore {
let hook;
let serverId;
let folder;
let tag_id;
const config = [];
if (this.path.startsWith('imap')) {
hook = "ajax_imap_folder_display";
Expand All @@ -165,7 +164,7 @@ class Hm_MessagesStore {
break;
case 'tag':
hook = "ajax_imap_tag_data";
tag_id = getParam('tag_id');
folder = getParam('tag_id');
break;
default:
hook = "ajax_imap_folder_data";
Expand All @@ -182,9 +181,6 @@ class Hm_MessagesStore {
if (folder) {
config.push({ name: "folder", value: folder });
}
if (tag_id) {
config.push({ name: "tag_id", value: tag_id });
}
return config;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ class Hm_Output_settings_site_link extends Hm_Output_Module {
* Outputs links to the Site Settings pages
*/
protected function output() {
$res = '<li class="menu_settings"><a class="site_link" href="?page=settings">';
$res = '<li class="menu_settings"><a class="unread_link" href="?page=settings">';
if (!$this->get('hide_folder_icons')) {
$res .= '<i class="bi bi-gear-wide-connected menu-icon"></i>';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ button {
margin-top: 5px;
}
.folders a,
.unread_link,.site_link,.all_tags {
.unread_link,.all_tags {
color: rgba(var(--bs-body-color-rgb), 0.7);
text-decoration: none;
line-height: 1.25em;
Expand Down
72 changes: 34 additions & 38 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,66 +733,62 @@ function sort_by_internal_date($a, $b) {
* @return array
*/
if (!hm_exists('merge_imap_search_results')) {
function merge_imap_search_results($ids, $search_type, $session, $hm_cache, $folders=array('INBOX'), $limit=0, $terms=array(), $sent=false, $combined=false) {
function merge_imap_search_results($ids, $search_type, $session, $hm_cache, $folders = array('INBOX'), $limit=0, $terms=array(), $sent=false) {
$msg_list = array();
$connection_failed = false;
$status = array();
$sent_results = array();
foreach ($ids as $id) {
$status = array();
foreach($ids as $index => $id) {
$cache = Hm_IMAP_List::get_cache($hm_cache, $id);
$imap = Hm_IMAP_List::connect($id, $cache);
if (imap_authed($imap)) {
$server_details = Hm_IMAP_List::dump($id);
if ($combined) {
$folders = array_unique(array_merge($folders, $imap->get_special_use_mailboxes()));
}
$folder = $folders[$index];
if ($sent) {
$sent_folder = $imap->get_special_use_mailboxes('sent');
if (array_key_exists('sent', $sent_folder)) {
list($sent_status, $sent_results) = merge_imap_search_results($ids, $search_type, $session, $hm_cache, array($sent_folder['sent']), $limit, $terms, false);
$status = array_merge($status, $sent_status);
}
}
foreach ($folders as $folder) {
if ($folder == 'SPECIAL_USE_CHECK') {
continue;
}
if ($imap->select_mailbox($folder)) {
$status['imap_'.$id.'_'.bin2hex($folder)] = $imap->folder_state;
if (!empty($terms)) {
foreach ($terms as $term) {
if (preg_match('/(?:[^\x00-\x7F])/', $term[1]) === 1) {
$imap->search_charset = 'UTF-8';
break;
}
}
if ($sent) {
$msgs = $imap->search($search_type, false, $terms, array(), true, false, true);
}
else {
$msgs = $imap->search($search_type, false, $terms);
}
if ($imap->select_mailbox($folder)) {
$status['imap_'.$id.'_'.bin2hex($folder)] = $imap->folder_state;
if (!empty($terms)) {
foreach ($terms as $term) {
if (preg_match('/(?:[^\x00-\x7F])/', $term[1]) === 1) {
$imap->search_charset = 'UTF-8';
break;
}
}
if ($sent) {
$msgs = $imap->search($search_type, false, $terms, array(), true, false, true);
}
else {
$msgs = $imap->search($search_type);
$msgs = $imap->search($search_type, false, $terms);
}
if ($msgs) {
if ($limit) {
rsort($msgs);
$msgs = array_slice($msgs, 0, $limit);
}
else {
$msgs = $imap->search($search_type);
}
if ($msgs) {
if ($limit) {
rsort($msgs);
$msgs = array_slice($msgs, 0, $limit);
}
foreach ($imap->get_message_list($msgs) as $msg) {
if (array_key_exists('content-type', $msg) && mb_stristr($msg['content-type'], 'multipart/mixed')) {
$msg['flags'] .= ' \Attachment';
}
foreach ($imap->get_message_list($msgs) as $msg) {
if (array_key_exists('content-type', $msg) && mb_stristr($msg['content-type'], 'multipart/mixed')) {
$msg['flags'] .= ' \Attachment';
}
if (mb_stristr($msg['flags'], 'deleted')) {
continue;
}
$msg['server_id'] = $id;
$msg['folder'] = bin2hex($folder);
$msg['server_name'] = $server_details['name'];
$msg_list[] = $msg;
if (mb_stristr($msg['flags'], 'deleted')) {
continue;
}
$msg['server_id'] = $id;
$msg['folder'] = bin2hex($folder);
$msg['server_name'] = $server_details['name'];
$msg_list[] = $msg;
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,9 +1043,7 @@ var imap_folder_status = function() {
};

var imap_setup_tags = function() {
$(document).on('click', '.label-checkbox', function(e) {
e.preventDefault();
Hm_Notices.show([hm_trans('Please wait, Adding tag to message...')]);
$(document).on('click', '.label-checkbox', function() {
var folder_id = $(this).data('id');
var ids = [];
if (getPageNameParam() == 'message') {
Expand Down
1 change: 1 addition & 0 deletions modules/sievefilters/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,7 @@ function sieve_enabled_callback($val) { return $val; }
class Hm_Output_enable_sieve_filter_setting extends Hm_Output_Module {
protected function output() {
$settings = $this->get('user_settings');
// exit(var_dump($settings['enable_sieve_filter']));
if ((array_key_exists('enable_sieve_filter', $settings) && $settings['enable_sieve_filter']) || DEFAULT_ENABLE_SIEVE_FILTER) {
$checked = ' checked="checked"';
$reset = '';
Expand Down
9 changes: 6 additions & 3 deletions modules/tags/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ class Hm_Handler_imap_tag_content extends Hm_Handler_Module {
public function process() {
$data_sources = imap_data_sources('');
$ids = array_map(function($ds) { return $ds['id']; }, $data_sources);
$tag_id = $this->request->post['tag_id'];
$tag_id = $this->request->post['folder'];
if ($ids && $tag_id) {
$limit = $this->user_config->get('tag_per_source_setting', DEFAULT_TAGS_PER_SOURCE);
$date = process_since_argument($this->user_config->get('tag_since_setting', DEFAULT_TAGS_SINCE));
$folders = array_map(function($ds) { return hex2bin($ds['folder']); }, $data_sources);
list($status, $msg_list) = merge_imap_search_results($ids, 'ALL', $this->session, $this->cache, $folders, $limit, array(array('SINCE', $date), array('HEADER X-Cypht-Tags', $tag_id)), false, true);
$folder = bin2hex('INBOX');
if (array_key_exists('folder', $this->request->post)) {
$folder = $this->request->post['folder'];
}
list($status, $msg_list) = merge_imap_search_results($ids, 'ALL', $this->session, $this->cache, array(hex2bin($folder)), $limit, array(array('SINCE', $date), array('HEADER X-Cypht-Tags', $tag_id)));
$this->out('folder_status', $status);
$this->out('imap_tag_data', $msg_list);
$this->out('imap_server_ids', implode(',', $ids));
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ public function test_settings_servers_link() {
public function test_settings_site_link() {
$test = new Output_Test('settings_site_link', 'core');
$res = $test->run();
$this->assertEquals(array('formatted_folder_list' => '<li class="menu_settings"><a class="site_link" href="?page=settings"><i class="bi bi-gear-wide-connected menu-icon"></i>Site</a></li>'), $res->output_response);
$this->assertEquals(array('formatted_folder_list' => '<li class="menu_settings"><a class="unread_link" href="?page=settings"><i class="bi bi-gear-wide-connected menu-icon"></i>Site</a></li>'), $res->output_response);
}
/**
* @preserveGlobalState disabled
Expand Down

0 comments on commit eeab367

Please sign in to comment.