protected override ModInfo LoadDefaultConfig(ModController controller) { Dictionary<string, string> settings = new Dictionary<string, string> { { "EventAdminRoles", "Administrator,Moderator" }, { "EventShowHolidays","1" } }; ModInfo modinfo = new ModInfo { Id = -1, Name = "Events", Description = "Events Calendar", Version = new Version(1, 0), Enabled = true, AdminControl = "EventsAdmin.ascx", Settings = new Hashtable(settings) }; controller.ModInfo = modinfo; controller.InstallMod(); return modinfo; }
public int Add(ModInfo modinfo) { string insertSql = "INSERT INTO " + Config.FilterTablePrefix + "MODS_CONFIG (MOD_NAME,MOD_DESCRIPTION,MOD_VERSION,MOD_ENABLED,MOD_ROLES) VALUES (@Name,@Description,@Version,@Enabled,@Roles ); SELECT SCOPE_IDENTITY();"; List<SqlParameter> parms = new List<SqlParameter> { new SqlParameter("@Name", SqlDbType.NVarChar) {Value = modinfo.Name}, new SqlParameter("@Description", SqlDbType.NVarChar) {Value = modinfo.Description}, new SqlParameter("@Version", SqlDbType.NVarChar) {Value = modinfo.Version.ToString()}, new SqlParameter("@Enabled", SqlDbType.Bit) {Value = modinfo.Enabled}, new SqlParameter("@Roles", SqlDbType.NVarChar) {Value = (object)modinfo.Roles??DBNull.Value} }; int modid = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, insertSql, parms.ToArray())); foreach (DictionaryEntry setting in modinfo.Settings) { string insSetting = "INSERT INTO " + Config.FilterTablePrefix + "MODS_SETTING (MOD_ID,MOD_SETTING,MOD_VALUE) VALUES (@Id,@Setting,@Value);"; List<SqlParameter> sparms = new List<SqlParameter> { new SqlParameter("@Id", SqlDbType.Int) {Value = modid}, new SqlParameter("@Setting", SqlDbType.NVarChar) {Value = setting.Key}, new SqlParameter("@Value", SqlDbType.NVarChar) {Value = setting.Value} }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, insSetting, sparms.ToArray()); } return modid; }
protected override ModInfo LoadDefaultConfig(ModController controller) { Dictionary<string, string> settings = new Dictionary<string, string> { { "Url", "http://forum.snitz.com/forum/rssfeed2.asp" } }; ModInfo modinfo = new ModInfo { Id = -1, Name = "RSSFeed", Description = "Displays an RSS feed", Version = new Version(1, 1), Enabled = true, AdminControl = "RSSFeed.ascx", Settings = new Hashtable(settings) }; controller.ModInfo = modinfo; controller.InstallMod(); return modinfo; }
public void Delete(ModInfo modinfo) { int modid = modinfo.Id; string delSql = "DELETE FROM " + Config.FilterTablePrefix + "MODS_SETTING WHERE MOD_ID=@ModId; " + "DELETE FROM " + Config.FilterTablePrefix + "MODS_CONFIG WHERE MOD_ID=@ModId; "; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, delSql, new SqlParameter("@Id", SqlDbType.Int) { Value = modid }); }
protected ModConfigBase(string name) { this._name = name; var controller = new ModController(name); this._modinfo = controller.ModInfo ?? LoadDefaultConfig(controller); if (_modinfo != null) { Id = _modinfo.Id; Description = _modinfo.Description; Version = _modinfo.Version; Enabled = _modinfo.Enabled; } else { throw new Exception(String.Format("{0} configuration data not defined", name)); } }
public ModInfo GetById(int id) { string strSql = "SELECT MOD_ID,MOD_NAME,MOD_DESCRIPTION,MOD_VERSION,MOD_ENABLED,MOD_ROLES FROM " + Config.ForumTablePrefix + "MODS_CONFIG WHERE MOD_ID = @ModId"; ModInfo modInfo = null; //Execute a query to read the products using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, new SqlParameter("@ModId", SqlDbType.Int) { Value = id })) { while (rdr.Read()) { modInfo = new ModInfo { Id = rdr.GetInt32(0), Name = rdr.SafeGetString(1), Description = rdr.SafeGetString(2), Version = new Version(rdr.SafeGetString(3)), Enabled = rdr.GetBoolean(4), Roles = rdr.SafeGetString(5), Settings = GetModSettings(id) }; } } return modInfo; }
protected override ModInfo LoadDefaultConfig(ModController controller) { //todo: load mod config data from xml file etc ModInfo modinfo = new ModInfo { Id = -1, Name = "BlogMenu", Description = "Blog Menu Config", Version = new Version(1, 0), Enabled = true, Settings = null }; controller.ModInfo = modinfo; controller.InstallMod(); return modinfo; }
protected override ModInfo LoadDefaultConfig(ModController controller) { Dictionary<string,string> settings = new Dictionary<string, string> { {"AllowFileUpload", "1"}, {"AllowImageUpload", "1"}, {"AllowAttachments", "1"}, {"ShowFileAttach", "1"}, {"FileUploadLocation", "/sharedFiles"}, {"AllowedAttachmentTypes","zip,pdf,txt,doc"}, {"AllowedImageTypes","jpg,jpeg,gif,png"}, {"TotalUploadLimitFileSize","100"}, {"TotalUploadLimitFileNumber", "50"}, {"FileSizeLimit", "10"} }; ModInfo modinfo = new ModInfo { Id = -1, Name = "FileUpload", Description = "File Upload Configuration", Version = new Version(1, 0), Enabled = true, Settings = new Hashtable(settings) }; controller.ModInfo = modinfo; controller.InstallMod(); return modinfo; }
public IEnumerable<ModInfo> GetByName(string name) { string strSql = "SELECT MOD_ID,MOD_NAME,MOD_DESCRIPTION,MOD_VERSION,MOD_ENABLED,MOD_ROLES FROM " + Config.ForumTablePrefix + "MODS_CONFIG WHERE MOD_Name = @ModName"; ModInfo modInfo = null; //Execute a query to read the products using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, new SqlParameter("@ModName", SqlDbType.VarChar) { Value = name })) { while (rdr.Read()) { int modid = rdr.GetInt32(0); modInfo = new ModInfo { Id = modid, Name = rdr.SafeGetString(1), Description = rdr.SafeGetString(2), Version = new Version(rdr.SafeGetString(3)), Enabled = rdr.SafeGetInt16(4) == 1, Roles = rdr.SafeGetString(5), Settings = GetModSettings(modid) }; } } return new[] {modInfo}; }
public void Update(ModInfo modinfo) { StringBuilder updSql = new StringBuilder("UPDATE "); updSql.AppendFormat("{0}MODS_CONFIG SET",Config.FilterTablePrefix).AppendLine(); updSql.AppendLine("MOD_NAME=@Name,"); updSql.AppendLine("MOD_DESCRIPTION=@Description,"); updSql.AppendLine("MOD_VERSION=@Version,"); updSql.AppendLine("MOD_ENABLED=@Enabled,"); updSql.AppendLine("MOD_ROLES=@Roles"); updSql.AppendLine("WHERE MOD_ID=@ModId;"); List<SqlParameter> parms = new List<SqlParameter> { new SqlParameter("@ModId", SqlDbType.Int) {Value = modinfo.Id}, new SqlParameter("@Name", SqlDbType.NVarChar) {Value = modinfo.Name}, new SqlParameter("@Description", SqlDbType.NVarChar) {Value = modinfo.Description}, new SqlParameter("@Version", SqlDbType.NVarChar) {Value = modinfo.Version.ToString()}, new SqlParameter("@Enabled", SqlDbType.Bit) {Value = modinfo.Enabled}, new SqlParameter("@Roles", SqlDbType.NVarChar) {Value = (object)modinfo.Roles??DBNull.Value} }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, updSql.ToString(), parms.ToArray()); foreach (DictionaryEntry setting in modinfo.Settings) { updSql.Length = 0; updSql.AppendFormat("UPDATE {0}MODS_SETTING SET", Config.FilterTablePrefix).AppendLine(); updSql.AppendLine("MOD_Value=@Value"); updSql.AppendLine("WHERE MOD_ID=@ModId AND MOD_SETTING=@Setting;"); List<SqlParameter> sparms = new List<SqlParameter> { new SqlParameter("@ModId", SqlDbType.Int) {Value = modinfo.Id}, new SqlParameter("@Value", SqlDbType.NVarChar) {Value = setting.Value}, new SqlParameter("@Setting", SqlDbType.NVarChar) {Value = setting.Key} }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, updSql.ToString(), sparms.ToArray()); } }
protected override ModInfo LoadDefaultConfig(ModController controller) { Dictionary<string, string> settings = new Dictionary<string, string> { {"Member Likes","1"}, {"Topic Likes","1"}, {"Reply Likes","1"} }; ModInfo modinfo = new ModInfo { Id = -1, Name = "Thanks", Description = "Thanks mod", Version = new Version(1, 0), Enabled = false, AdminControl = "ThanksMod.ascx", Settings = new Hashtable(settings) }; controller.ModInfo = modinfo; controller.InstallMod(); return modinfo; }
protected override ModInfo LoadDefaultConfig(ModController controller) { Dictionary<string, string> settings = new Dictionary<string, string> { { "MediaItems", "messenger,googlebuzz" } }; ModInfo modinfo = new ModInfo { Id = -1, Name = "ShareIt", Description = "Share topic on Social Media sites", Version = new Version(1, 0), Enabled = true, Settings = new Hashtable(settings) }; controller.ModInfo = modinfo; controller.InstallMod(); return modinfo; }