1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * historydb.h --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * A component of the Greenstone digital library software
|
---|
7 | * from the New Zealand Digital Library Project at the
|
---|
8 | * University of Waikato, New Zealand.
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | *
|
---|
24 | *********************************************************************/
|
---|
25 |
|
---|
26 |
|
---|
27 | #ifndef HISTORYDB_H
|
---|
28 | #define HISTORYDB_H
|
---|
29 |
|
---|
30 | #include "infodbclass.h"
|
---|
31 | #include "text_t.h"
|
---|
32 | #include "recptproto.h"
|
---|
33 |
|
---|
34 | struct HistRecord {
|
---|
35 | text_t entry;
|
---|
36 | bool save;
|
---|
37 | };
|
---|
38 |
|
---|
39 | struct ltinttext_t
|
---|
40 | {
|
---|
41 | bool operator()(const text_t &t1, const text_t &t2) const
|
---|
42 | { return t1.getint() < t2.getint(); }
|
---|
43 | };
|
---|
44 |
|
---|
45 |
|
---|
46 | typedef map<text_t, HistRecord, ltinttext_t> HistRecordmap;
|
---|
47 |
|
---|
48 | // returns true on success (in which case historyinfo will contain
|
---|
49 | // the information for this history)
|
---|
50 | bool get_history_info (const text_t &userid, text_tarray &historyinfo,
|
---|
51 | const text_t &gsdlhome, ostream &logout);
|
---|
52 |
|
---|
53 | // returns true on success
|
---|
54 | bool set_history_info (const text_t &userid, const text_t &historyinfo,
|
---|
55 | const text_t &gsdlhome);
|
---|
56 |
|
---|
57 | bool delete_all_history_info (const text_t &userid, const text_t &gsdlhome);
|
---|
58 |
|
---|
59 | // deletes only the entries specified
|
---|
60 | bool delete_history_info(const text_t &userid, const text_t &deletemode,
|
---|
61 | const text_t &selection, const text_t &gsdlhome);
|
---|
62 |
|
---|
63 | // takes a text_t with x-y, and retrieves the x and y params
|
---|
64 | bool get_selection_params (text_t &data, int &start, int &stop);
|
---|
65 |
|
---|
66 | bool expand_query(HistRecord &query, HistRecordmap &records);
|
---|
67 |
|
---|
68 | // combine query looks for #x and replaces it with the query
|
---|
69 | // string from the xth entry. THe first one looks up the xth
|
---|
70 | // query in the database (used before running a query), the
|
---|
71 | // second version looks it up inthe records map (used in
|
---|
72 | // delete history -are doing a lotof #x replacing at once.
|
---|
73 | bool combine_query(text_t &userid, text_t &query, const text_t &gsdlhome);
|
---|
74 | bool combine_query(text_t &userid, HistRecordmap &records);
|
---|
75 |
|
---|
76 | // retrieves the value of an arg (key) from a list of cgi args
|
---|
77 | // in the form a=q&b=1&...
|
---|
78 | void parse_saved_args(text_t &args, text_t key, text_t &value);
|
---|
79 |
|
---|
80 | // extracts out the components of an entry in the database
|
---|
81 | // currently:
|
---|
82 | // querynum:numdocs cgiargs
|
---|
83 | void split_saved_query(text_t &query, text_t &querynum, text_t &numdocs, text_t &cgiargs);
|
---|
84 |
|
---|
85 | // just extracts the query number out of the entry
|
---|
86 | void get_query_num(text_t &query, text_t &querynum);
|
---|
87 |
|
---|
88 | // takes the cgiarg string, and outputs it in some form useful
|
---|
89 | // to the user
|
---|
90 | void format_user_info (text_t &cgiargs, text_t &info,
|
---|
91 | recptprotolistclass *protos, ostream &logout);
|
---|
92 |
|
---|
93 | #endif
|
---|