source: branches/corba/gsdl/src/recpt/delhistoryaction.cpp@ 1074

Last change on this file since 1074 was 1000, checked in by sjboddie, 24 years ago

tidied up windows installation

  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/**********************************************************************
2 *
3 * delhistoryaction.cpp -- allows user to select history items to delete
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 * $Id: delhistoryaction.cpp 1000 2000-03-01 22:23:47Z sjboddie $
25 *
26 *********************************************************************/
27
28#include "delhistoryaction.h"
29#include "cgiutils.h"
30#include "text_t.h"
31#include "historydb.h"
32
33delhistoryaction::delhistoryaction () {
34
35 // this action uses cgi variable "a"
36 cgiarginfo arg_ainfo;
37 arg_ainfo.shortname = "a";
38 arg_ainfo.longname = "action";
39 arg_ainfo.multiplechar = true;
40 arg_ainfo.defaultstatus = cgiarginfo::weak;
41 arg_ainfo.argdefault = "dh";
42 arg_ainfo.savedarginfo = cgiarginfo::must;
43 argsinfo.addarginfo (NULL, arg_ainfo);
44
45 // "hmode" -- indicate whether selected records are to be
46 // saved or deleted
47 arg_ainfo.shortname = "hmode";
48 arg_ainfo.longname = "history deletion mode";
49 arg_ainfo.multiplechar = true;
50 arg_ainfo.defaultstatus = cgiarginfo::weak;
51 arg_ainfo.argdefault = "delete";
52 arg_ainfo.savedarginfo = cgiarginfo::mustnot;
53 argsinfo.addarginfo (NULL, arg_ainfo);
54
55 // "hsr" -- the selected records
56 arg_ainfo.shortname = "hsr";
57 arg_ainfo.longname = "history selected records";
58 arg_ainfo.multiplechar = true;
59 arg_ainfo.multiplevalue = true;
60 arg_ainfo.defaultstatus = cgiarginfo::weak;
61 arg_ainfo.argdefault = "";
62 arg_ainfo.savedarginfo = cgiarginfo::mustnot;
63 argsinfo.addarginfo (NULL, arg_ainfo);
64
65 // "hdh" delete history for current user
66 // clear history = 0 = delete some, 1 = delete all
67 arg_ainfo.shortname = "hdh";
68 arg_ainfo.longname = "history delete history";
69 arg_ainfo.multiplechar = false;
70 arg_ainfo.multiplevalue = false;
71 arg_ainfo.defaultstatus = cgiarginfo::weak;
72 arg_ainfo.argdefault = "0";
73 arg_ainfo.savedarginfo = cgiarginfo::mustnot;
74 argsinfo.addarginfo (NULL, arg_ainfo);
75
76}
77
78void delhistoryaction::configure (const text_t &key, const text_tarray &cfgline) {
79 action::configure (key, cfgline);
80}
81
82bool delhistoryaction::init (ostream &logout) {
83 return action::init (logout);
84}
85
86bool delhistoryaction::check_cgiargs (cgiargsinfoclass & /*argsinfo*/, cgiargsclass & /*args*/,
87 ostream &/*logout*/) {
88 //dont check anything yet
89 return true;
90}
91
92void delhistoryaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
93 response_t &response, text_t &response_data,
94 ostream &/*logout*/) {
95 response = content;
96 response_data = "text/html";
97}
98
99void delhistoryaction::define_internal_macros (displayclass &/*disp*/, cgiargsclass &/*args*/,
100 recptprotolistclass * /*protos*/,
101 ostream &/*logout*/) {
102
103 // define_internal_macros sets the following macros:
104 //_searchhistorylist_
105
106 // define_history_macros(disp, args, protos, logout);
107
108}
109
110
111void delhistoryaction::define_external_macros (displayclass &/*disp*/, cgiargsclass &/*args*/,
112 recptprotolistclass * /*protos*/, ostream &/*logout*/) {
113
114 // define_external_macros sets the following macros:
115
116 // can't do anything if collectproto is null (i.e. no collection was specified)
117 //recptproto *collectproto = protos->getrecptproto (args["c"], logout);
118 //if (collectproto == NULL) return;
119
120 // define_history_macros(disp, args, protos, logout);
121
122}
123
124
125void delhistoryaction::define_history_macros(displayclass &disp, cgiargsclass &args,
126 recptprotolistclass *protos, ostream &logout) {
127
128 // defines the following macros
129
130 // _searchhistorylist_
131
132 text_t historylist = "<!-- Search History List -->\n";
133
134 text_t userid = args["z"];
135 text_tarray entries;
136
137 historylist += "<table align=center width=500 border=1> \n <tr><th colspan=4 align=center>";
138 historylist += "_query:textsearchhistory_</th></tr>\n";
139 historylist += "<tr><th width=60>_textselect_</th><th width=40>#</th>\n<th width=340>_query:textquery_</th>\n";
140 historylist += "<th width=60>_query:textresults_</th></tr>\n";
141 if (get_history_info (userid, entries, gsdlhome, logout)) {
142 int count = 1;
143 text_tarray::iterator here = entries.begin();
144 text_tarray::iterator end = entries.end();
145 // int size=(int)entries.size();
146 while (here !=end ) {
147 text_t c=count;
148 text_t querynum;
149 text_t query;
150 text_t numdocs;
151 text_t cgiargs;
152 text_t userinfo;
153 split_saved_query(*here, querynum, numdocs, cgiargs);
154 parse_saved_args(cgiargs, "q", query); // get query string out
155 decode_cgi_arg(query); // un cgisafe it
156
157 format_user_info(cgiargs, userinfo, protos, logout);
158
159 historylist += "<tr> <td width=60 align=center><input type=checkbox name=hsr value=\""+querynum+"\"></td>";
160 historylist += "<td width=40 align=center>"+querynum+"</td>\n";
161 historylist += "<td width=340 align=left>"+query+"</td><td width=60 align=center>"+numdocs+"</td>\n";
162 here++;
163 count++;
164 }
165
166
167 } // if
168 else { // have an empty row
169 historylist += "";
170 }
171 historylist+="</table>";
172 historylist += "<p><! ---- end of history list ----->\n";
173 disp.setmacro("searchhistorylist", "delhistory", historylist);
174
175} // define history macros
176
177
178bool delhistoryaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
179 browsermapclass * /*browsers*/, displayclass &disp,
180 outconvertclass &outconvert, ostream &textout,
181 ostream &logout) {
182
183 if (args["hdh"] !="") {
184 delete_search_history(args);
185 }
186 define_history_macros(disp, args, protos, logout);
187 textout << outconvert << disp << ("_delhistory:header_\n")
188 << ("_delhistory:content_\n")
189 << ("_delhistory:footer_\n");
190
191 return true;
192}
193
194
195bool delhistoryaction::delete_search_history (cgiargsclass &args) {
196
197 bool result;
198 text_t userid = args["z"];
199 text_t type = args["hdh"];
200 if (type == "1") {
201 result = delete_all_history_info (userid, gsdlhome);
202 } else {
203 text_t records = args["hsr"];
204 text_t deletemode = args["hmode"];
205 result = delete_history_info (userid, deletemode, records, gsdlhome);
206 }
207
208 return result;
209}
210
211
212
213
214
Note: See TracBrowser for help on using the repository browser.