Commit 6f3b2b71 authored by jan.koester's avatar jan.koester
Browse files

test

parent d48b0a4f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1019,8 +1019,8 @@ void webedit::Api::handleLoadDocument(libhttppp::HttpRequest &curreq,
    std::string uid;
    _session.getData(sessionid, "uid", uid);

    std::string name, xml;
    if (!_db.loadDocument(uid, docId, name, xml)) {
    std::string name, xml, group;
    if (!_db.loadDocument(uid, docId, name, xml, group)) {
        sendJsonError(curreq, 404, "Document not found");
        return;
    }
@@ -1033,6 +1033,7 @@ void webedit::Api::handleLoadDocument(libhttppp::HttpRequest &curreq,
    doc.ownedElements.clear();
    doc.currentDocId = docId;
    doc.currentDocName = name;
    doc.currentDocGroup = group;

    // Parse XML
    tinyxml2::XMLDocument xmlDoc;
+6 −4
Original line number Diff line number Diff line
@@ -318,12 +318,13 @@ std::string webedit::Database::updateDocument(const std::string &ownerUid,

bool webedit::Database::loadDocument(const std::string &ownerUid,
                                      const std::string &id,
                                      std::string &name, std::string &xml) {
                                      std::string &name, std::string &xml,
                                      std::string &group) {
    dbpp::SQL sql;
    dbpp::DBResult res;
    std::vector<char> escapedId, escapedUid;

    sql << "SELECT name, xml FROM documents WHERE id='"
    sql << "SELECT name, xml, group_name FROM documents WHERE id='"
        << dbpp::SQL::escaped(escapedId, id.c_str())
        << "' AND owner_uid='"
        << dbpp::SQL::escaped(escapedUid, ownerUid.c_str()) << "';";
@@ -334,6 +335,7 @@ bool webedit::Database::loadDocument(const std::string &ownerUid,

    name  = res[0][0];
    xml   = res[0][1];
    group = res[0][2];
    return true;
}

+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ namespace webedit {
                                   const std::string &author = "",
                                   const std::string &group = "");
        bool loadDocument(const std::string &ownerUid, const std::string &id,
                          std::string &name, std::string &xml);
                          std::string &name, std::string &xml, std::string &group);
        bool deleteDocument(const std::string &ownerUid, const std::string &id);
        std::string listDocuments(const std::string &domain); // Returns JSON array