Пример #1
0
        private bool GetEditStatus(int createdByUser)
        {
            string editRole = Manifest.GetEditRole();

            return((IsEditable || OpenContentUtils.HasEditRole(PortalSettings, Module, editRole, createdByUser)) && // edit Role can edit whtout be in edit mode
                   OpenContentUtils.HasEditPermissions(PortalSettings, Module, editRole, createdByUser));
        }
Пример #2
0
        public HttpResponseMessage Add(UpdateRequest req)
        {
            try
            {
                ModuleController mc          = new ModuleController();
                var  requestModule           = mc.GetModule(req.ModuleId, req.TabId, false);
                bool index                   = false;
                OpenContentSettings settings = requestModule.OpenContentSettings();
                ModuleInfo          module   = requestModule;
                if (settings.ModuleId > 0)
                {
                    module = mc.GetModule(settings.ModuleId, settings.TabId, false);
                }
                var manifest = settings.Template.Manifest;
                TemplateManifest templateManifest = settings.Template;
                index = settings.Template.Manifest.Index;
                string editRole = manifest.GetEditRole();

                bool listMode              = templateManifest != null && templateManifest.IsListTemplate;
                int  createdByUserid       = -1;
                OpenContentController ctrl = new OpenContentController();

                if (listMode)
                {
                    if (!OpenContentUtils.HasEditPermissions(PortalSettings, module, editRole, createdByUserid))
                    {
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                    var             indexConfig = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir);
                    OpenContentInfo content     = new OpenContentInfo()
                    {
                        ModuleId             = module.ModuleID,
                        Title                = ActiveModule.ModuleTitle,
                        Json                 = req.json.ToString(),
                        JsonAsJToken         = req.json,
                        CreatedByUserId      = UserInfo.UserID,
                        CreatedOnDate        = DateTime.Now,
                        LastModifiedByUserId = UserInfo.UserID,
                        LastModifiedOnDate   = DateTime.Now,
                        Html                 = "",
                    };
                    ctrl.AddContent(content, index, indexConfig);
                    return(Request.CreateResponse(HttpStatusCode.OK, ""));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "It's not a list mode module"));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Delete(JObject json)
        {
            try
            {
                var    module          = new OpenContentModuleInfo(ActiveModule);
                string editRole        = module.Settings.Template.Manifest.GetEditRole();
                int    createdByUserid = -1;

                IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);

                IDataItem content = null;
                if (module.IsListMode())
                {
                    content = ds.Get(dsContext, json["id"].ToString());
                    if (content != null)
                    {
                        createdByUserid = content.CreatedByUserId;
                    }
                }
                else
                {
                    dsContext.Single = true;
                    content          = ds.Get(dsContext, null);
                    if (content != null)
                    {
                        createdByUserid = content.CreatedByUserId;
                    }
                }

                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                if (content != null)
                {
                    ds.Delete(dsContext, content);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Пример #4
0
        public HttpResponseMessage Version(string id, string ticks)
        {
            OpenContentSettings settings = ActiveModule.OpenContentSettings();
            ModuleInfo          module   = ActiveModule;

            if (settings.ModuleId > 0)
            {
                ModuleController mc = new ModuleController();
                module = mc.GetModule(settings.ModuleId, settings.TabId, false);
            }
            var    manifest = settings.Template.Manifest;
            string editRole = manifest.GetEditRole();
            JToken json     = new JObject();

            try
            {
                int createdByUserid = -1;
                var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                var dsContext = new DataSourceContext()
                {
                    ModuleId       = module.ModuleID,
                    ActiveModuleId = ActiveModule.ModuleID,
                    TemplateFolder = settings.TemplateDir.FolderPath,
                    Config         = manifest.DataSourceConfig
                };
                var dsItem = ds.Get(dsContext, id);
                if (dsItem != null)
                {
                    var version = ds.GetVersion(dsContext, dsItem, new DateTime(long.Parse(ticks)));
                    if (version != null)
                    {
                        json            = version;
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Пример #5
0
        public HttpResponseMessage Add(UpdateRequest req)
        {
            try
            {
                var    module   = new OpenContentModuleInfo(req.ModuleId, req.TabId);
                string editRole = module.Settings.Template.Manifest.GetEditRole();

                OpenContentController ctrl = new OpenContentController();

                if (module.IsListMode())
                {
                    if (!OpenContentUtils.HasEditPermissions(PortalSettings, module.ViewModule, editRole, -1))
                    {
                        Log.Logger.WarnFormat("Failed the HasEditPermissions() check for ");
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Failed the HasEditPermissions() check"));
                    }
                    var             index       = module.Settings.Template.Manifest.Index;
                    var             indexConfig = OpenContentUtils.GetIndexConfig(module.Settings.Template.Key.TemplateDir, "Items");
                    OpenContentInfo content     = new OpenContentInfo()
                    {
                        ModuleId             = module.DataModule.ModuleID,
                        Collection           = req.Collection,
                        Title                = ActiveModule.ModuleTitle,
                        Json                 = req.json.ToString(),
                        CreatedByUserId      = UserInfo.UserID,
                        CreatedOnDate        = DateTime.Now,
                        LastModifiedByUserId = UserInfo.UserID,
                        LastModifiedOnDate   = DateTime.Now
                    };
                    ctrl.AddContent(content, index, indexConfig);
                    return(Request.CreateResponse(HttpStatusCode.OK, ""));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "It's not a list mode module"));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Version(string id, string ticks)
        {
            var    module = new OpenContentModuleInfo(ActiveModule);
            JToken json   = new JObject();

            try
            {
                int createdByUserid = -1;

                IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);

                var dsItem = ds.Get(dsContext, id);
                if (dsItem != null)
                {
                    var version = ds.GetVersion(dsContext, dsItem, new DateTime(long.Parse(ticks)));
                    if (version != null)
                    {
                        json            = version;
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }

                string editRole = module.Settings.Template.Manifest.GetEditRole();
                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, module.ViewModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Add(UpdateRequest req)
        {
            try
            {
                var    module   = new OpenContentModuleInfo(req.ModuleId, req.TabId);
                string editRole = module.Settings.Template.Manifest.GetEditRole();

                var dataSource = new OpenContentDataSource();

                if (module.IsListMode())
                {
                    if (!OpenContentUtils.HasEditPermissions(PortalSettings, module.ViewModule, editRole, -1))
                    {
                        Log.Logger.Warn($"Failed the HasEditPermissions() check");
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Failed the HasEditPermissions() check"));
                    }
                    var dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);
                    dsContext.Collection = req.Collection;

                    JToken data = req.json;
                    data["Title"] = ActiveModule.ModuleTitle;
                    dataSource.Add(dsContext, data);

                    return(Request.CreateResponse(HttpStatusCode.OK, ""));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "It's not a list mode module"));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Action(SubmitDTO req)
        {
            try
            {
                var    module          = new OpenContentModuleInfo(ActiveModule);
                string editRole        = module.Settings.Template.Manifest.GetEditRole();
                int    createdByUserid = -1;

                IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);

                IDataItem dsItem = null;
                if (module.IsListMode())
                {
                    if (req.id != null)
                    {
                        var itemId = req.id;
                        dsItem = ds.Get(dsContext, itemId);
                        if (dsItem != null)
                        {
                            createdByUserid = dsItem.CreatedByUserId;
                        }
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                    if (dsItem != null)
                    {
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }

                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                try
                {
                    var res = ds.Action(dsContext, req.action, dsItem, req.form);
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        isValid = true,
                        result = res
                    }));
                }
                catch (DataNotValidException ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        isValid = false,
                        validMessage = ex.Message
                    }));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Update(JObject json)
        {
            try
            {
                var    module          = new OpenContentModuleInfo(ActiveModule);
                string editRole        = module.Settings.Template.Manifest.GetEditRole();
                int    createdByUserid = -1;

                IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);

                IDataItem dsItem = null;
                if (module.IsListMode())
                {
                    if (json["id"] != null)
                    {
                        var itemId = json["id"].ToString();
                        dsItem = ds.Get(dsContext, itemId);
                        if (dsItem != null)
                        {
                            createdByUserid = dsItem.CreatedByUserId;
                        }
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                    if (dsItem != null)
                    {
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }

                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                try
                {
                    if (dsItem == null)
                    {
                        ds.Add(dsContext, json["form"] as JObject);
                    }
                    else
                    {
                        ds.Update(dsContext, dsItem, json["form"] as JObject);
                    }
                }
                catch (DataNotValidException ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        isValid = false,
                        validMessage = ex.Message
                    }));
                }

                if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.String)
                {
                    string moduleTitle = json["form"]["ModuleTitle"].ToString();
                    OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                }
                else if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.Object)
                {
                    if (json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] != null)
                    {
                        string moduleTitle = json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()].ToString();
                        OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    isValid = true
                }));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Edit(string id)
        {
            try
            {
                var         moduleInfo = new OpenContentModuleInfo(ActiveModule);
                IDataSource ds         = DataSourceManager.GetDataSource(moduleInfo.Settings.Manifest.DataSource);
                var         dsContext  = OpenContentUtils.CreateDataContext(moduleInfo);
                IDataItem   dsItem     = null;
                if (moduleInfo.IsListMode())
                {
                    if (!string.IsNullOrEmpty(id)) // not a new item
                    {
                        dsItem = ds.Get(dsContext, id);
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                }
                int createdByUserid = -1;
                var json            = ds.GetAlpaca(dsContext, true, true, true);
                if (ds is IDataActions)
                {
                    var actions = ((IDataActions)ds).GetActions(dsContext, dsItem);
                    if (json["options"] == null)
                    {
                        json["options"] = new JObject();
                    }
                    if (json["options"]["form"] == null)
                    {
                        json["options"]["form"] = new JObject();
                    }
                    if (json["options"]["form"]["buttons"] == null)
                    {
                        json["options"]["form"]["buttons"] = new JObject();
                    }
                    var buttons    = json["options"]["form"]["buttons"] as JObject;
                    var newButtons = new JObject();
                    foreach (var act in actions)
                    {
                        var but = buttons[act.Name];
                        if (but == null)
                        {
                            but = new JObject();
                        }
                        but["after"]         = act.AfterExecute;
                        newButtons[act.Name] = but;
                    }
                    json["options"]["form"]["buttons"] = newButtons;
                }
                if (dsItem != null)
                {
                    json["data"] = dsItem.Data;
                    if (json["schema"]["properties"]["ModuleTitle"] is JObject)
                    {
                        if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.String)
                        {
                            json["data"]["ModuleTitle"] = ActiveModule.ModuleTitle;
                        }
                        else if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.Object)
                        {
                            json["data"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] = ActiveModule.ModuleTitle;
                        }
                    }
                    var versions = ds.GetVersions(dsContext, dsItem);
                    if (versions != null)
                    {
                        json["versions"] = versions;
                    }
                    createdByUserid = dsItem.CreatedByUserId;
                }

                var context       = new JObject();
                var currentLocale = DnnLanguageUtils.GetCurrentLocale(PortalSettings.PortalId);
                context["culture"]                = currentLocale.Code; //todo why not use  DnnLanguageUtils.GetCurrentCultureCode() ???
                context["defaultCulture"]         = LocaleController.Instance.GetDefaultLocale(PortalSettings.PortalId).Code;
                context["numberDecimalSeparator"] = currentLocale.Culture.NumberFormat.NumberDecimalSeparator;
                context["rootUrl"]                = System.Web.VirtualPathUtility.ToAbsolute(string.Concat(System.Web.HttpRuntime.AppDomainAppVirtualPath, "/"));
                context["alpacaCulture"]          = AlpacaEngine.AlpacaCulture(currentLocale.Code);
                context["bootstrap"]              = OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController(PortalSettings.PortalId).GetEditLayout() != AlpacaLayoutEnum.DNN;
                context["horizontal"]             = OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController(PortalSettings.PortalId).GetEditLayout() == AlpacaLayoutEnum.BootstrapHorizontal;
                json["context"] = context;

                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, moduleInfo.ViewModule, moduleInfo.Settings.Manifest.GetEditRole(), createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Пример #11
0
        public HttpResponseMessage Edit(string id)
        {
            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                ModuleInfo          module   = ActiveModule;
                if (settings.ModuleId > 0)
                {
                    ModuleController mc = new ModuleController();
                    module = mc.GetModule(settings.ModuleId, settings.TabId, false);
                }
                var manifest = settings.Manifest;
                TemplateManifest templateManifest = settings.Template;
                string           editRole         = manifest.GetEditRole();
                bool             listMode         = templateManifest != null && templateManifest.IsListTemplate;
                var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                var dsContext = new DataSourceContext()
                {
                    ModuleId       = module.ModuleID,
                    ActiveModuleId = ActiveModule.ModuleID,
                    TemplateFolder = settings.TemplateDir.FolderPath,
                    Config         = manifest.DataSourceConfig
                };
                IDataItem dsItem = null;
                if (listMode)
                {
                    if (!string.IsNullOrEmpty(id)) // not a new item
                    {
                        dsItem = ds.Get(dsContext, id);
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                }
                int createdByUserid = -1;
                var json            = ds.GetAlpaca(dsContext, true, true, true);
                //var content = GetContent(module.ModuleID, listMode, int.Parse(id));
                //if (content != null)
                if (dsItem != null)
                {
                    //json["data"] = content.Json.ToJObject("GetContent " + id);
                    //json = dsItem.Data as JObject;
                    json["data"] = dsItem.Data;
                    if (json["schema"]["properties"]["ModuleTitle"] is JObject)
                    {
                        //json["data"]["ModuleTitle"] = ActiveModule.ModuleTitle;
                        if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.String)
                        {
                            json["data"]["ModuleTitle"] = ActiveModule.ModuleTitle;
                        }
                        else if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.Object)
                        {
                            json["data"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] = ActiveModule.ModuleTitle;
                        }
                    }
                    var versions = ds.GetVersions(dsContext, dsItem);
                    if (versions != null)
                    {
                        json["versions"] = versions;
                    }
                    //AddVersions(json, content);
                    //createdByUserid = content.CreatedByUserId;
                    createdByUserid = dsItem.CreatedByUserId;
                }

                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Пример #12
0
 public HttpResponseMessage Delete(JObject json)
 {
     try
     {
         bool index = false;
         OpenContentSettings settings = ActiveModule.OpenContentSettings();
         ModuleInfo          module   = ActiveModule;
         if (settings.ModuleId > 0)
         {
             ModuleController mc = new ModuleController();
             module = mc.GetModule(settings.ModuleId, settings.TabId, false);
         }
         var manifest = settings.Template.Manifest;
         TemplateManifest templateManifest = settings.Template;
         index = manifest.Index;
         string editRole        = manifest.GetEditRole();
         bool   listMode        = templateManifest != null && templateManifest.IsListTemplate;
         int    createdByUserid = -1;
         var    ds        = DataSourceManager.GetDataSource(manifest.DataSource);
         var    dsContext = new DataSourceContext()
         {
             ModuleId       = module.ModuleID,
             ActiveModuleId = ActiveModule.ModuleID,
             TemplateFolder = settings.TemplateDir.FolderPath,
             Index          = index,
             UserId         = UserInfo.UserID,
             PortalId       = module.PortalID,
             Config         = manifest.DataSourceConfig
         };
         IDataItem content = null;
         if (listMode)
         {
             content = ds.Get(dsContext, json["id"].ToString());
             if (content != null)
             {
                 createdByUserid = content.CreatedByUserId;
             }
         }
         else
         {
             dsContext.Single = true;
             content          = ds.Get(dsContext, null);
             if (content != null)
             {
                 createdByUserid = content.CreatedByUserId;
             }
         }
         if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
         {
             return(Request.CreateResponse(HttpStatusCode.Unauthorized));
         }
         if (content != null)
         {
             ds.Delete(dsContext, content);
         }
         return(Request.CreateResponse(HttpStatusCode.OK, ""));
     }
     catch (Exception exc)
     {
         Log.Logger.Error(exc);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
     }
 }
Пример #13
0
        public HttpResponseMessage Update(JObject json)
        {
            try
            {
                bool index = false;
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                ModuleInfo          module   = ActiveModule;
                if (settings.ModuleId > 0)
                {
                    ModuleController mc = new ModuleController();
                    module = mc.GetModule(settings.ModuleId, settings.TabId, false);
                }
                var manifest = settings.Template.Manifest;
                TemplateManifest templateManifest = settings.Template;
                index = settings.Template.Manifest.Index;
                string editRole = manifest.GetEditRole();

                bool listMode        = templateManifest != null && templateManifest.IsListTemplate;
                int  createdByUserid = -1;
                var  ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                var  dsContext = new DataSourceContext()
                {
                    ModuleId       = module.ModuleID,
                    ActiveModuleId = ActiveModule.ModuleID,
                    TemplateFolder = settings.TemplateDir.FolderPath,
                    Index          = index,
                    UserId         = UserInfo.UserID,
                    PortalId       = module.PortalID,
                    Config         = manifest.DataSourceConfig
                };
                IDataItem dsItem = null;
                if (listMode)
                {
                    if (json["id"] != null)
                    {
                        var itemId = json["id"].ToString();
                        dsItem = ds.Get(dsContext, itemId);
                        //content = ctrl.GetContent(itemId);
                        if (dsItem != null)
                        {
                            createdByUserid = dsItem.CreatedByUserId;
                        }
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                    //dsItem = ctrl.GetFirstContent(module.ModuleID);
                    if (dsItem != null)
                    {
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                //var indexConfig = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir);
                if (dsItem == null)
                {
                    ds.Add(dsContext, json["form"] as JObject);
                }
                else
                {
                    ds.Update(dsContext, dsItem, json["form"] as JObject);
                }
                if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.String)
                {
                    string moduleTitle = json["form"]["ModuleTitle"].ToString();
                    OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                }
                else if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.Object)
                {
                    if (json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] != null)
                    {
                        string moduleTitle = json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()].ToString();
                        OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }