X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fshowpendingmessagepage.cpp;fp=src%2Fhttp%2Fpages%2Fshowpendingmessagepage.cpp;h=8a1babd244b3e8b59ea46a0f26d37eb05b8df0a2;hb=59a5414ec47a2932a7802fcd1d98c4d80166564f;hp=0000000000000000000000000000000000000000;hpb=4e96d123460d6363cf7274e36bd9357768eb86ad;p=fms.git diff --git a/src/http/pages/showpendingmessagepage.cpp b/src/http/pages/showpendingmessagepage.cpp new file mode 100644 index 0000000..8a1babd --- /dev/null +++ b/src/http/pages/showpendingmessagepage.cpp @@ -0,0 +1,78 @@ +#include "../../../include/http/pages/showpendingmessagepage.h" +#include "../../../include/stringfunctions.h" +#include "../../../include/global.h" +#include "../../../include/fmsapp.h" +#include "../../../include/option.h" +#include "../../../include/localidentity.h" +#include "../../../include/freenet/messagexml.h" + +#ifdef XMEM + #include +#endif + +const std::string ShowPendingMessagePage::GeneratePage(const std::string &method, const std::map &queryvars) +{ + if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="delete" && ValidateFormPassword(queryvars)) + { + m_log->information("User requested to delete message "+(*queryvars.find("uuid")).second); + m_db->Execute("DELETE FROM tblMessageInserts WHERE MessageUUID=\""+(*queryvars.find("uuid")).second+"\""); + } + + SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID, MessageXML, SendDate, MessageUUID FROM tblMessageInserts WHERE Inserted='false';"); + st.Step(); + int msgcount=0; + std::string tblcontent=""; + std::string content=""; + tblcontent+=""; + while (st.RowReturned()) + { + int identityid=0; + std::string time(""); + std::string uuid(""); + std::string subject(""); + + st.ResultInt(0,identityid); + st.ResultText(2,time); + st.ResultText(3, uuid); + + LocalIdentity ident(m_db); //found a canned way, thanks SomeDude! + ident.Load(identityid); + + tblcontent+=""; + st.Step(); + msgcount++; + } + tblcontent+="
IdentityBoardsSubjectTime
"; + tblcontent+=SanitizeOutput(ident.GetName())+""; + //yes, the next bit sucks but there's no better way to do it (that I could find) + //we will look at the message XML to find the board(s) posted to.... + std::string xml=""; + st.ResultText(1,xml); + MessageXML mxml; + mxml.ParseXML(xml); + std::vector boards=mxml.GetBoards(); + std::vector::iterator iter; + for (iter=boards.begin(); iter!=boards.end(); iter++) tblcontent+=*iter+", "; + tblcontent.erase(tblcontent.length()-2); //strip final ", " + tblcontent+=""; + subject=mxml.GetSubject(); + tblcontent+=subject; + tblcontent+=""; + tblcontent+=time+""; + //button + tblcontent+="
"; + tblcontent+=CreateFormPassword(); + tblcontent+=""; + tblcontent+=""; + tblcontent+=""; + tblcontent+="
"; + tblcontent+="
"; + + std::string msgcountstr(""); + StringFunctions::Convert(msgcount,msgcountstr); + content="

"+msgcountstr+" messages waiting to be inserted

"; + + content+=tblcontent; + + return StringFunctions::Replace(m_template,"[CONTENT]",content); +}