Commit 2b9b14a4 authored by jan.koester's avatar jan.koester
Browse files

test

parent 90a946ef
Loading
Loading
Loading
Loading
+50 −1
Changes for plugins/content/content.cpp: 50 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -897,7 +897,56 @@ namespace blogi {
        }

        bool haveSettings(){
            return false;
            return true;
        }

        json_object* Settings(const int tid, libhttppp::HttpRequest &req, const std::string &sessionid){
            std::string _lang = getLang(*Args->database[tid]);

            json_object *jroot = json_object_new_object();
            json_object_object_add(jroot, "title", json_object_new_string(tr(_lang,"Content Permissions").c_str()));

            json_object *jform = json_object_new_object();
            json_object_object_add(jform, "method", json_object_new_string("POST"));
            json_object_object_add(jform, "action", json_object_new_string(req.getRequestURL().c_str()));

            json_object *jtabs = json_object_new_array();

            // GPO info tab
            {
                json_object *jtab = json_object_new_object();
                json_object_object_add(jtab, "label", json_object_new_string(tr(_lang,"Permissions (GPO)").c_str()));
                json_object *jfields = json_object_new_array();

                struct GpoInfo { const char *name; const char *uuid; const char *desc; };
                GpoInfo gpos[] = {
                    {  "Edit Own Posts",      GPO_CONTENT_EDIT_OWN,
                       "Allows users to edit their own content posts (default: enabled)" },
                    {  "Edit Others Posts",   GPO_CONTENT_EDIT_OTHERS,
                       "Allows users to edit content posts from other authors (default: disabled)" },
                    {  "Delete Own Posts",    GPO_CONTENT_DELETE_OWN,
                       "Allows users to delete their own content posts (default: enabled)" },
                    {  "Delete Others Posts", GPO_CONTENT_DELETE_OTHERS,
                       "Allows users to delete content posts from other authors (default: disabled)" },
                };

                for(auto &g : gpos){
                    json_object *jf = json_object_new_object();
                    json_object_object_add(jf, "type", json_object_new_string("heading"));
                    std::string label = std::string(g.name) + " <small style=\"color:var(--blogi-text-muted,#aaa);\">[" + g.uuid + "]</small><br/>"
                                      + "<small>" + g.desc + "</small>";
                    json_object_object_add(jf, "label", json_object_new_string(label.c_str()));
                    json_object_array_add(jfields, jf);
                }

                json_object_object_add(jtab, "fields", jfields);
                json_object_array_add(jtabs, jtab);
            }

            json_object_object_add(jform, "tabs", jtabs);
            json_object_object_add(jroot, "form", jform);

            return jroot;
        }

        void initPlugin(){