/********************************************************************** * * delhistoryaction.cpp -- allows user to select history items to delete * Copyright (C) 1999 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *********************************************************************/ #include "delhistoryaction.h" #include "cgiutils.h" #include "text_t.h" #include "historydb.h" delhistoryaction::delhistoryaction () { // this action uses cgi variable "a" cgiarginfo arg_ainfo; arg_ainfo.shortname = "a"; arg_ainfo.longname = "action"; arg_ainfo.multiplechar = true; arg_ainfo.defaultstatus = cgiarginfo::weak; arg_ainfo.argdefault = "dh"; arg_ainfo.savedarginfo = cgiarginfo::must; argsinfo.addarginfo (NULL, arg_ainfo); // "hmode" -- indicate whether selected records are to be // saved or deleted arg_ainfo.shortname = "hmode"; arg_ainfo.longname = "history deletion mode"; arg_ainfo.multiplechar = true; arg_ainfo.defaultstatus = cgiarginfo::weak; arg_ainfo.argdefault = "delete"; arg_ainfo.savedarginfo = cgiarginfo::mustnot; argsinfo.addarginfo (NULL, arg_ainfo); // "hsr" -- the selected records arg_ainfo.shortname = "hsr"; arg_ainfo.longname = "history selected records"; arg_ainfo.multiplechar = true; arg_ainfo.multiplevalue = true; arg_ainfo.defaultstatus = cgiarginfo::weak; arg_ainfo.argdefault = ""; arg_ainfo.savedarginfo = cgiarginfo::mustnot; argsinfo.addarginfo (NULL, arg_ainfo); // "hdh" delete history for current user // clear history = 0 = delete some, 1 = delete all arg_ainfo.shortname = "hdh"; arg_ainfo.longname = "history delete history"; arg_ainfo.multiplechar = false; arg_ainfo.multiplevalue = false; arg_ainfo.defaultstatus = cgiarginfo::weak; arg_ainfo.argdefault = "0"; arg_ainfo.savedarginfo = cgiarginfo::mustnot; argsinfo.addarginfo (NULL, arg_ainfo); } void delhistoryaction::configure (const text_t &key, const text_tarray &cfgline) { action::configure (key, cfgline); } bool delhistoryaction::init (ostream &logout) { return action::init (logout); } bool delhistoryaction::check_cgiargs (cgiargsinfoclass & /*argsinfo*/, cgiargsclass & /*args*/, ostream &/*logout*/) { //dont check anything yet return true; } void delhistoryaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/, response_t &response, text_t &response_data, ostream &/*logout*/) { response = content; response_data = "text/html"; } void delhistoryaction::define_internal_macros (displayclass &/*disp*/, cgiargsclass &/*args*/, recptprotolistclass * /*protos*/, ostream &/*logout*/) { // define_internal_macros sets the following macros: //_searchhistorylist_ // define_history_macros(disp, args, protos, logout); } void delhistoryaction::define_external_macros (displayclass &/*disp*/, cgiargsclass &/*args*/, recptprotolistclass * /*protos*/, ostream &/*logout*/) { // define_external_macros sets the following macros: // can't do anything if collectproto is null (i.e. no collection was specified) //recptproto *collectproto = protos->getrecptproto (args["c"], logout); //if (collectproto == NULL) return; // define_history_macros(disp, args, protos, logout); } void delhistoryaction::define_history_macros(displayclass &disp, cgiargsclass &args, recptprotolistclass *protos, ostream &logout) { // defines the following macros // _searchhistorylist_ text_t historylist = "\n"; text_t userid = args["z"]; text_tarray entries; historylist += "
"; historylist += "_query:textsearchhistory_ | |||
---|---|---|---|
_textselect_ | # | \n_query:textquery_ | \n"; historylist += "_query:textresults_ |
"; historylist += " | "+querynum+" | \n"; historylist += ""+query+" | "+numdocs+" | \n"; here++; count++; } } // if else { // have an empty row historylist += ""; } historylist+="
\n"; disp.setmacro("searchhistorylist", "delhistory", historylist); } // define history macros bool delhistoryaction::do_action (cgiargsclass &args, recptprotolistclass *protos, browsermapclass * /*browsers*/, displayclass &disp, outconvertclass &outconvert, ostream &textout, ostream &logout) { if (args["hdh"] !="") { delete_search_history(args); } define_history_macros(disp, args, protos, logout); textout << outconvert << disp << ("_delhistory:header_\n") << ("_delhistory:content_\n") << ("_delhistory:footer_\n"); return true; } bool delhistoryaction::delete_search_history (cgiargsclass &args) { bool result; text_t userid = args["z"]; text_t type = args["hdh"]; if (type == "1") { result = delete_all_history_info (userid, gsdlhome); } else { text_t records = args["hsr"]; text_t deletemode = args["hmode"]; result = delete_history_info (userid, deletemode, records, gsdlhome); } return result; }