Commit ee241609 authored by jan.koester's avatar jan.koester
Browse files

test

parent 2fe97eac
Loading
Loading
Loading
Loading
+42 −0
Changes for src/edit.cpp: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2408,6 +2408,11 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
            json_object_object_add(single_response, "xml", json_object_new_string(printer.CStr()));
            handled = true;
        } else if (strcmp(command, "SaveTemplateDb") == 0) {
            if(!checkEditorGPO(request, GPO_EDITOR_TEMPLATES)){
                json_object_object_add(single_response, "status", json_object_new_string("error"));
                json_object_object_add(single_response, "message", json_object_new_string("GPO denied: Manage Templates"));
                handled = true;
            } else {
            // Save current template to database with revision
            json_object *param_obj = nullptr;
            std::string tplName = "untitled";
@@ -2437,7 +2442,13 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
                json_object_object_add(single_response, "message", json_object_new_string(e.what()));
            }
            handled = true;
            }
        } else if (strcmp(command, "LoadTemplateDb") == 0) {
            if(!checkEditorGPO(request, GPO_EDITOR_TEMPLATES)){
                json_object_object_add(single_response, "status", json_object_new_string("error"));
                json_object_object_add(single_response, "message", json_object_new_string("GPO denied: Manage Templates"));
                handled = true;
            } else {
            // Load a template from database (optionally a specific revision)
            json_object *param_obj = nullptr;
            std::string templateId = "";
@@ -2471,7 +2482,13 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
                }
            }
            handled = true;
            }
        } else if (strcmp(command, "ListTemplates") == 0) {
            if(!checkEditorGPO(request, GPO_EDITOR_TEMPLATES)){
                json_object_object_add(single_response, "status", json_object_new_string("error"));
                json_object_object_add(single_response, "message", json_object_new_string("GPO denied: Manage Templates"));
                handled = true;
            } else {
            // List all saved templates from database
            try {
                json_object *templates = listTemplates(tid);
@@ -2482,7 +2499,13 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
                json_object_object_add(single_response, "message", json_object_new_string(e.what()));
            }
            handled = true;
            }
        } else if (strcmp(command, "GetRevisions") == 0) {
            if(!checkEditorGPO(request, GPO_EDITOR_TEMPLATES)){
                json_object_object_add(single_response, "status", json_object_new_string("error"));
                json_object_object_add(single_response, "message", json_object_new_string("GPO denied: Manage Templates"));
                handled = true;
            } else {
            // Get revision history for a template
            json_object *param_obj = nullptr;
            std::string templateId = "";
@@ -2507,7 +2530,13 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
                }
            }
            handled = true;
            }
        } else if (strcmp(command, "list_publish_targets") == 0) {
            if(!checkEditorGPO(request, GPO_EDITOR_PUBLISH)){
                json_object_object_add(single_response, "status", json_object_new_string("error"));
                json_object_object_add(single_response, "message", json_object_new_string("GPO denied: Publish Content"));
                handled = true;
            } else {
            // List all plugins that support publishing
            json_object *targets = json_object_new_array();
            if (plugins) {
@@ -2527,7 +2556,13 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
            json_object_object_add(single_response, "status", json_object_new_string("success"));
            json_object_object_add(single_response, "targets", targets);
            handled = true;
            }
        } else if (strcmp(command, "publish") == 0) {
            if(!checkEditorGPO(request, GPO_EDITOR_PUBLISH)){
                json_object_object_add(single_response, "status", json_object_new_string("error"));
                json_object_object_add(single_response, "message", json_object_new_string("GPO denied: Publish Content"));
                handled = true;
            } else {
            // Publish rendered HTML to a target plugin
            json_object *param_obj = nullptr;
            std::string targetPlugin;
@@ -2689,7 +2724,13 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
                }
            }
            handled = true;
            }
        } else if (strcmp(command, "share_post") == 0) {
            if(!checkEditorGPO(request, GPO_EDITOR_SHARE)){
                json_object_object_add(single_response, "status", json_object_new_string("error"));
                json_object_object_add(single_response, "message", json_object_new_string("GPO denied: Share Posts"));
                handled = true;
            } else {
            // Manually share a URL to social networks via sharePost broadcast
            std::string shareUrl, shareTitle, shareDesc;
            json_object *param_obj = nullptr;
@@ -2721,6 +2762,7 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso
            }
            handled = true;
            }
        }


        // The original code had the plugin loading here, which is now moved.