public BaseModule GetModule(string id) { BaseService.CheckLoginAndLicense(); id = id.Replace("bitModule", ""); id = id.Replace("bitEditor", ""); BaseModule mod = BaseModule.GetById <BaseModule>(new Guid(id)); if (mod.HasBitplateAutorisation()) { if (!mod.IsAutorized(SessionObject.CurrentBitplateUser)) { throw new Exception("U heeft geen rechten voor deze module"); } } mod = mod.ConvertToType(); //if (mod.SelectGroup != null && mod.SelectGroup != "") //{ // DataGroup dataGroup = BaseObject.GetById<DataGroup>(Guid.Parse(mod.SelectGroup)); // if (dataGroup != null) // { // mod.SelectGroupPath = dataGroup.DataCollection.Name + "/" + dataGroup.GetCompletePath(); //FindDataGroupBasePath(Guid.Parse(mod.SelectGroup)); // } //} return(mod); }
public string SaveModuleContent(string id, string content, string languageCode, string pageid, string newsletterid) { BaseService.CheckLoginAndLicense(); BaseModule module = BaseModule.GetById <BaseModule>(new Guid(id)); module = module.ConvertToType(); module.Content = content; module.Save(); module.LanguageCode = languageCode; CmsPage page = null; if (pageid != null && pageid != "") { page = BaseObject.GetById <CmsPage>(Guid.Parse(pageid)); } else if (newsletterid != null && newsletterid != "") { page = BaseObject.GetById <Newsletter>(Guid.Parse(newsletterid)); } return(module.Publish2(page)); }
public static string SaveModuleContent(string id, string content) { BaseService.CheckLoginAndLicense(); id = id.Replace("bitModule", ""); id = id.Replace("bitEditor", ""); BaseModule module = BaseModule.GetById <BaseModule>(new Guid(id)); module = module.ConvertToType(); //module.LoadPropsFromXmlFile(); content = content.Replace("?mode=edit", ""); //BUG WORKAROUND. BUG ZIT MOGELIJK NOG IN DE EDITOR. module.Content = content; module.Save(); module.Publish(); //Experimenteel caching reset //if (module.Page != null) //{ // BitCaching.RemoveItemFromCache(module.Page.ID.ToString()); //} if (module.Type == "HtmlModule") { PublishModule(module); } return(new ModuleService().GetUserControlContent(module)); }
public string DoSort(string pageid, string moduleid, string column, SortDirectionEnum sortDirection, int pageNumber, int totalResults, Dictionary <string, object> parameters) { BaseModule module = BaseModule.GetById <BaseModule>(new Guid(moduleid)); if (module == null) { return(""); } ISortable pageableModule = module.ConvertToType() as ISortable; if (pageableModule == null) { return(""); } CmsPage page = BaseObject.GetById <CmsPage>(Guid.Parse(pageid)); return(pageableModule.DoSort(page, column, sortDirection, pageNumber, totalResults, parameters)); }
public string ReloadModule(string pageid, string id, Dictionary <string, object> parameters) { BaseModule module = BaseModule.GetById <BaseModule>(new Guid(id)); if (module == null) { return(""); } IRefreshableModule refreshableModule = module.ConvertToType() as IRefreshableModule; if (refreshableModule == null) { return(""); } CmsPage page = BaseObject.GetById <CmsPage>(Guid.Parse(pageid)); return(refreshableModule.Reload(page, parameters)); }
public static SiteUser Login(string email, string password, string bitLoginId) { BaseModule module = BaseModule.GetById <BaseModule>(new Guid(bitLoginId)); string MD5Password = CalculateMD5Hash(password); SiteUser user = BaseObject.GetFirst <SiteUser>("Email ='" + email + "' AND Password = '******'"); //"' AND Type = 30"); if (user == null) { if (email == "test" && password == "test") { SiteUser siteUser = new SiteUser(); siteUser.Name = "test gebruiker"; siteUser.Email = email; user = siteUser; } } SessionObject.CurrentSiteUser = user; return(user); }
private static Dictionary <string, object> HandlePost(Dictionary <string, string> Values) { module = BaseModule.GetById <BaseModule>(new Guid(Values["bitFormId"])); Dictionary <string, object> Settings = JSONSerializer.Deserialize <Dictionary <string, object> >(module.SettingsJsonString); Dictionary <string, object> ValidationFieldsObject = (Dictionary <string, object>)Settings["validation"]; List <DataInputValidation> Validations = new List <DataInputValidation>(); foreach (KeyValuePair <string, object> ValidationFieldObject in ValidationFieldsObject) { Dictionary <string, object> tmp = (Dictionary <string, object>)ValidationFieldObject.Value; DataInputValidation div = new DataInputValidation(); div.Required = (bool)tmp["Required"]; div.DataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), (string)tmp["DataType"]); div.Name = (string)tmp["Name"]; div.ErrorMessage = (string)tmp["ErrorMessage"]; Validations.Add(div); } Dictionary <string, object> returnValue = new Dictionary <string, object>(); foreach (DataInputValidation Validation in Validations) { KeyValuePair <string, string> ValueToValidate = Values.Where(c => c.Key == Validation.Name).FirstOrDefault(); if (Validation.ErrorMessage == "") { Validation.ErrorMessage = "Vul hier uw " + Validation.Name + " in."; } if (!ValueToValidate.Equals(null)) { if (ValueToValidate.Value != "") { switch (Validation.DataType) { case DataTypeEnum.Number: try { double.Parse(ValueToValidate.Value); } catch (Exception ex) { returnValue.Add(Validation.Name, Validation.ErrorMessage); } break; case DataTypeEnum.Email: if (!Regex.Match(ValueToValidate.Value, @"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$").Success) { returnValue.Add(Validation.Name, Validation.ErrorMessage); } break; } } else { if (Validation.Required) { returnValue.Add(Validation.Name, Validation.ErrorMessage); } } } else { if (Validation.Required) { returnValue.Add(Validation.Name, Validation.ErrorMessage); } } } if (!(returnValue.Count > 0)) { //TODO Settings amken bool SendEmail = (bool)module.Settings["isEmailEnabled"];; if (SendEmail) { string Template = module.Settings["EmailTemplate"].ToString().Trim(); string emailValues = ""; foreach (KeyValuePair <string, string> keyval in Values) { emailValues += keyval.Key + " = " + keyval.Value + "<br />"; Template = Template.Replace("{" + keyval.Key + "}", keyval.Value); } Template = Template.Replace("{values}", emailValues); EmailManager.SendMail(module.Settings["EmailFrom"].ToString(), module.Settings["EmailTo"].ToString(), module.Settings["EmailSubject"].ToString(), Template, true); //send mail } if ((bool)module.Settings["isDataCollectieEnabled"]) { // DataCollection dc = module.DataCollection; // DataItem di = new DataItem(); // di.DataCollection = dc; //// DataGroup dg = DataGroup.GetById<DataGroup>(Guid.Parse(module.SelectGroup)); // //di.ParentGroup = dg; // foreach (DataField dfl in dc.DataItemFields) // { // if (Values.ContainsKey(dfl.Name)) // { // if (dfl.MappingColumn != "Name") // { // typeof(DataItem).GetProperty(dfl.MappingColumn).SetValue(di, Values[dfl.Name], null); // } // } // } // di.Name = DateTime.Now.ToString(); // di.Save(); } //if (module.DrillDownUrl != "") //{ // returnValue.Add("DrillDownUrl", module.DrillDownUrl); //} } return(returnValue); }