Skip to content

Commit

Permalink
merge master and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kroky committed Dec 16, 2024
2 parents c1f82d0 + 15ff855 commit 3aa4dcb
Show file tree
Hide file tree
Showing 48 changed files with 631 additions and 563 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ OUTLOOK_AUTH_URI=https://login.live.com/oauth20_authorize.srf
OUTLOOK_TOKEN_URI=https://login.live.com/oauth20_token.srf
OUTLOOK_REFRESH_URI=https://login.live.com/oauth20_token.srf

#office365
OFFICE365_CLIENT_ID=
OFFICE365_CLIENT_SECRET=
OFFICE365_CLIENT_URI=http://localhost/?page=home
OFFICE365_AUTH_URI=https://login.live.com/oauth20_authorize.srf
OFFICE365_TOKEN_URI=https://login.live.com/oauth20_token.srf
OFFICE365_REFRESH_URI=https://login.live.com/oauth20_token.srf

#ldap.php
LDAP_SERVER=localhost
LDAP_ENABLE_TLS=true
Expand Down
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<!-- You can find the latest issue templates here https://github.com/ulfgebhardt/issue-templates -->

<!--
Validate your PR title - a quick Guide
A valid PR title contains a type (https://github.com/commitizen/conventional-commit-types/blob/master/index.json), a scope (https://github.com/cypht-org/cypht/blob/master/.github/workflows/test.lint.pr.yml#L31) and a title starting with a lower case letter.
Here are some valid examples:
- fix(frontend): my fix
- feat(backend): my feature
- docs(docker): my docs
- refactor(frontend/backend) : my refactor
- test(unit): my test
-->

## 🍰 Pullrequest
<!-- Describe the Pullrequest. Use Screenshots if possible. -->

Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test.lint.pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ jobs:
# Configure which scopes are allowed (newline delimited).
# Append a scope for each service here
scopes: |
docu
docs
docker
release
workflow
frontend
backend
frontend/backend
module/[a-z-]+
unit
e2e
other
cypht
# Configure that a scope must always be provided.
requireScope: true
# Configure which scopes (newline delimited) are disallowed in PR
Expand Down
10 changes: 10 additions & 0 deletions config/oauth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,14 @@
'token_uri' => env('OUTLOOK_TOKEN_URI', 'https://login.live.com/oauth20_token.srf'),
'refresh_uri' => env('OUTLOOK_REFRESH_URI', 'https://login.live.com/oauth20_token.srf')
],

//[office365]
'office365' => [
'client_id' => env('OFFICE365_CLIENT_ID', ''),
'client_secret' => env('OFFICE365_CLIENT_SECRET', ''),
'client_uri' => env('OFFICE365_CLIENT_URI', 'http://localhost/?page=home'),
'auth_uri' => env('OFFICE365_AUTH_URI', 'https://login.live.com/oauth20_authorize.srf'),
'token_uri' => env('OFFICE365_TOKEN_URI', 'https://login.live.com/oauth20_token.srf'),
'refresh_uri' => env('OFFICE365_REFRESH_URI', 'https://login.live.com/oauth20_token.srf')
],
];
1 change: 0 additions & 1 deletion modules/advanced_search/js_modules/route_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function applyAdvancedSearchPageHandlers() {
$('.adv_controls').show();
$('.core_msg_control').off('click');
$('.core_msg_control').on("click", function() { return Hm_Message_List.message_action($(this).data('action')); });
Hm_Message_List.set_checkbox_callback();
if (typeof check_select_for_imap !== 'undefined') {
check_select_for_imap();
}
Expand Down
19 changes: 14 additions & 5 deletions modules/advanced_search/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ public function process() {
}
}

if ($this->request->post['all_folders']) {
$searchInAllFolders = $this->request->post['all_folders'] ?? false;
$searchInSpecialFolders = $this->request->post['all_special_folders'] ?? false;
$includeSubfolders = $this->request->post['include_subfolders'] ?? false;
if ($searchInAllFolders) {
$msg_list = $this->all_folders_search($mailbox, $flags, $params, $limit);
} elseif ($this->request->post['all_special_folders']) {
} elseif ($searchInSpecialFolders) {
$msg_list = $this->special_folders_search($mailbox, $flags, $params, $limit);
} else if (!$mailbox->select_mailbox($this->folder)) {
} else if ($includeSubfolders) {
$msg_list = $this->all_folders_search($mailbox, $flags, $params, $limit, $this->folder);
} else if (! $mailbox->select_mailbox($this->folder)) {
return;
} else {
$msg_list = $this->imap_search($flags, $mailbox, $params, $limit);
Expand All @@ -104,8 +109,12 @@ public function process() {
$this->out('imap_server_ids', array($this->imap_id));
}

private function all_folders_search($mailbox, $flags, $params, $limit) {
$folders = $mailbox->get_folders();
private function all_folders_search($mailbox, $flags, $params, $limit, $parent = '') {
if ($parent) {
$folders = $mailbox->get_subfolders($parent);
} else {
$folders = $mailbox->get_folders();
}
$msg_list = array();
foreach ($folders as $folder) {
$this->folder = $folder['name'];
Expand Down
1 change: 1 addition & 0 deletions modules/advanced_search/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
'adv_targets' => array('filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY),
'all_folders' => FILTER_VALIDATE_BOOLEAN,
'all_special_folders' => FILTER_VALIDATE_BOOLEAN,
'include_subfolders' => FILTER_VALIDATE_BOOLEAN,
)
);
35 changes: 29 additions & 6 deletions modules/advanced_search/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var expand_adv_folder = function(res) {
$('.adv_folder_link', list_container).on("click", function() { return expand_adv_folder_list($(this).data('target')); });
$('a', list_container).not('.adv_folder_link').off('click');
$('a', list_container).not('.adv_folder_link').on("click", function() { adv_folder_select($(this).data('id')); return false; });
modifyInnerLists();
}
};

Expand Down Expand Up @@ -131,7 +132,9 @@ var adv_select_imap_folder = function(el) {
checkboxesWrapper.append(allSpecialFoldersCheckbox);
checkboxesWrapper.append(allFoldersCheckbox);
$(this).find('.wrapper').append(checkboxesWrapper);
})
});

modifyInnerLists();

$('.imap_folder_link', folders).addClass('adv_folder_link').removeClass('imap_folder_link');
$('.adv_folder_list').html(folders.html());
Expand All @@ -147,6 +150,20 @@ var adv_select_imap_folder = function(el) {
});
};

function modifyInnerLists() {
$('.adv_folder_list').find('.inner_list li').each(function(index) {
const subFoldersCheckbox = `
<span class="form-check form-text">
<label class="form-check-label" for="include_subfolders-${index}">Include subfolders</label>
<input class="form-check-input" type="checkbox" name="include_subfolders" id="include_subfolders-${index}">
</span>
`;
$(this).wrapInner('<div class="d-flex wrapper"></div>');
$(this).find('.wrapper').append(subFoldersCheckbox);
$(this).find('#main-link').css('flex-grow', 0)
});
}

var adv_folder_select = function(id) {
if ($('.'+id, $('.adv_source_list')).length > 0) {
$('.adv_folder_list').html('');
Expand All @@ -164,17 +181,19 @@ var adv_folder_select = function(id) {
var parent_class = '.'+parts[0]+'_'+parts[1]+'_';
var account = $('a', $(parent_class, container)).first().text();
var label = account+' &gt; '+folder;
add_source_to_list(id, label);
const includeSubfolders = $(`.${id}`).closest('li').find('input[name="include_subfolders"]').is(':checked');

add_source_to_list(id, label, includeSubfolders);
$('.adv_folder_list').html('');
$('.close_adv_folders').remove();
$('.adv_folder_list').hide();
};

var add_source_to_list = function(id, label) {
var add_source_to_list = function(id, label, includeSubfolders) {
var close = $(globals.close_html);
close.addClass('adv_remove_source');
close.attr('data-target', id);
var row = '<div class="'+id+'">'+close.prop('outerHTML')+label;
var row = '<div class="'+id+'" data-subfolders="'+includeSubfolders+'">'+close.prop('outerHTML')+label;
row += '<input type="hidden" value="'+id+'" /></div>';
$('.adv_source_list').append(row);
$('.adv_remove_source').off('click');
Expand Down Expand Up @@ -247,7 +266,7 @@ var get_adv_sources = function() {
const source = this.className;
const mailboxSource = source.split('_').slice(0, 2).join('_');
if (!sources.find(s => s.source.indexOf(mailboxSource) > -1)) {
sources.push({'source': source, 'label': $('a', $(this)).text()});
sources.push({'source': source, 'label': $('a', $(this)).text(), subFolders: $(this).data('subfolders')});
}
});
return sources;
Expand Down Expand Up @@ -426,6 +445,8 @@ var send_requests = function(requests) {
params.push({name: 'all_folders', value: true});
} else if (request['all_special_folders']) {
params.push({name: 'all_special_folders', value: true});
} else if (request['sub_folders']) {
params.push({name: 'include_subfolders', value: true});
}

for (var i=0, len=request['terms'].length; i < len; i++) {
Expand Down Expand Up @@ -490,7 +511,9 @@ var build_adv_search_requests = function(terms, sources, targets, times, other)
config['all_folders'] = true;
} else if (source.specialFolders) {
config['all_special_folders'] = true;
}
} else if (source.subFolders) {
config['sub_folders'] = true;
}
requests.push(config);
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/calendar/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/*add_output('ajax_imap_message_content', 'vcalendar_add_output', true, 'calendar', 'filter_message_headers', 'after');*/
add_output('calendar', 'calendar_content', true, 'calendar', 'content_section_start', 'after');
add_output('calendar', 'add_cal_event_form', true, 'calendar', 'content_section_start', 'after');
add_output('ajax_hm_folders', 'calendar_page_link', true, 'calendar', 'logout_menu_item', 'before');
add_output('ajax_hm_folders', 'calendar_page_link', true, 'calendar', 'main_menu_content', 'before');

return array(
'allowed_pages' => array(
Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
add_output('contacts', 'contacts_content_end', true, 'contacts', 'contacts_list', 'after');
add_output('settings', 'contact_auto_collect_setting', true, 'contacts', 'max_google_contacts_number', 'after');

add_output('ajax_hm_folders', 'contacts_page_link', true, 'contacts', 'logout_menu_item', 'before');
add_output('ajax_hm_folders', 'contacts_page_link', true, 'contacts', 'main_menu_content', 'before');

add_handler('compose', 'load_contacts', true, 'contacts', 'load_user_data', 'after');
add_handler('compose', 'process_send_to_contact', true, 'contacts', 'save_user_data', 'before');
Expand Down
8 changes: 2 additions & 6 deletions modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@ function format_data_sources($array, $output_mod) {
foreach ($sources as $values) {
$items = array();
foreach ($values as $name => $value) {
if ($name == 'callback') {
$items[] = $output_mod->html_safe($name).':'.$output_mod->html_safe($value);
}
else {
$items[] = $output_mod->html_safe($name).':"'.$output_mod->html_safe($value).'"';
}
$items[] = $output_mod->html_safe($name).':"'.$output_mod->html_safe($value).'"';
}
$objects[] = '{'.implode(',', $items).'}';
}
Expand Down Expand Up @@ -255,6 +250,7 @@ function get_oauth2_data($config) {
return [
'gmail' => $config->get('gmail',[]),
'outlook' => $config->get('outlook',[]),
'office365' => $config->get('office365',[]),
];
}}

Expand Down
40 changes: 22 additions & 18 deletions modules/core/js_modules/Hm_MessagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Hm_MessagesStore {
*/
markRowAsRead(uid) {
const rows = Object.entries(this.rows);
const row = this.#getRowByUid(uid)?.value;
const row = this.getRowByUid(uid)?.value;

if (row) {
const htmlRow = $(row[1]['0']);
Expand All @@ -96,7 +96,7 @@ class Hm_MessagesStore {
*/
getNextRowForMessage(uid) {
const rows = Object.entries(this.rows);
const row = this.#getRowByUid(uid)?.index;
const row = this.getRowByUid(uid)?.index;

if (row !== false) {
const nextRow = rows[row + 1];
Expand All @@ -114,7 +114,7 @@ class Hm_MessagesStore {
*/
getPreviousRowForMessage(uid) {
const rows = Object.entries(this.rows);
const row = this.#getRowByUid(uid)?.index;
const row = this.getRowByUid(uid)?.index;
if (row) {
const previousRow = rows[row - 1];
if (previousRow) {
Expand All @@ -126,7 +126,7 @@ class Hm_MessagesStore {

removeRow(uid) {
const rows = Object.entries(this.rows);
const row = this.#getRowByUid(uid);
const row = this.getRowByUid(uid);
if (row) {
const newRows = rows.filter((_, i) => i !== row.index);
this.rows = Object.fromEntries(newRows);
Expand All @@ -153,14 +153,23 @@ class Hm_MessagesStore {

#getRequestConfig() {
let hook;
let serverId;
let folder;
const config = [];
if (this.path.startsWith('imap')) {
hook = "ajax_imap_folder_display";

const detail = Hm_Utils.parse_folder_path(this.path, 'imap');
serverId = detail.server_id;
folder = detail.folder;
config.push({ name: "imap_server_id", value: detail.server_id });
config.push({ name: "folder", value: detail.folder });

} else if (this.path.startsWith('feeds')) {
hook = "ajax_feed_combined";
const serverId = this.path.split('_')[1];
if (serverId) {
config.push({ name: "feed_server_ids", value: serverId });
}
} else if (this.path.startsWith('github')) {
hook = "ajax_github_data";
config.push({ name: "github_repo", value: this.path.split('_')[1] });
} else {
switch (this.path) {
case 'unread':
Expand All @@ -170,6 +179,8 @@ class Hm_MessagesStore {
hook = "ajax_imap_flagged";
break;
case 'combined_inbox':
hook = "ajax_combined_message_list";
break;
case 'email':
hook = "ajax_imap_combined_inbox";
break;
Expand All @@ -183,15 +194,8 @@ class Hm_MessagesStore {
}
}

if (hook) {
config.push({ name: "hm_ajax_hook", value: hook });
}
if (serverId) {
config.push({ name: "imap_server_id", value: serverId });
}
if (folder) {
config.push({ name: "folder", value: folder });
}
config.push({ name: "hm_ajax_hook", value: hook });

return config;
}

Expand All @@ -217,7 +221,7 @@ class Hm_MessagesStore {
* @param {String} uid
* @returns {RowOutput|false} row - The row object if found, false otherwise
*/
#getRowByUid(uid) {
getRowByUid(uid) {
const rows = Object.entries(this.rows);
const row = rows.find(([key, value]) => $(value['0']).attr('data-uid') == uid);

Expand Down
Loading

0 comments on commit 3aa4dcb

Please sign in to comment.