// Copyright (c) 1987-2023 by the citadel.org team
//
// This program is open source software. Use, duplication, or disclosure
-// are subject to the terms of the GNU General Public License version 3.
+// is subject to the terms of the GNU General Public License version 3.
#include "../../ctdl_module.h"
#include "serv_autocompletion.h"
#include "../../config.h"
#include "../../room_ops.h"
+#include "../fulltext/serv_fulltext.h"
// Convert a structured name into a friendly name. Caller must free the
msg = CtdlFetchMessage(msgnum, 1);
if (msg == NULL) return;
- v = vcard_load(msg->cm_fields[eMesageText]);
+ v = vcard_load(msg->cm_fields[eMessageText]);
CM_Free(msg);
// Try to match from a friendly name (the "fn" field). If there is
char search_string[256];
long *msglist = NULL;
int num_msgs = 0;
- long *fts_msgs = NULL;
- int fts_num_msgs = 0;
int r = 0;
int i = 0;
int j = 0;
int search_match = 0;
char *rooms_to_try[] = { USERCONTACTSROOM, ADDRESS_BOOK_ROOM };
+ Array *fts = NULL;
if (CtdlAccessCheck(ac_logged_in)) return;
extract_token(search_string, argbuf, 0, '|', sizeof search_string);
// Search-reduce the results if we have the full text index available
if (CtdlGetConfigInt("c_enable_fulltext")) {
- CtdlModuleDoSearch(&fts_num_msgs, &fts_msgs, search_string, "fulltext");
- if (fts_msgs) {
+ fts = CtdlFullTextSearch(search_string);
+ if (fts) {
for (i=0; i<num_msgs; ++i) {
search_match = 0;
- for (j=0; j<fts_num_msgs; ++j) {
- if (msglist[i] == fts_msgs[j]) {
+ for (j=0; j<array_len(fts); ++j) {
+ long smsgnum;
+ memcpy(&smsgnum, array_get_element_at(fts, j), sizeof(long));
+ if (msglist[i] == smsgnum) {
search_match = 1;
- j = fts_num_msgs + 1; // end the search
+ j = array_len(fts) + 1; // end the search
}
}
if (!search_match) {
msglist[i] = 0; // invalidate this result
}
}
- free(fts_msgs);
+ array_free(fts);
}
else {
// If no results, invalidate the whole list