Exemplo n.º 1
0
    /// <summary>
    /// Method removes obsolete settings.
    /// </summary>
    private static void CleanupSettings()
    {
        var settings = SettingsKeyInfoProvider.GetSettingsKeys().Where(@"[KeyName] = 'CMSFacebookPageId' OR
[KeyName] = 'CMSFacebookAccessToken' OR
[KeyName] = 'CMSFacebookURLShortenerType' OR
[KeyName] = 'CMSTwitterURLShortenerType' OR
[KeyName] = 'CMSTwitterConsumerKey' or
[KeyName] = 'CMSTwitterConsumerSecret' OR
[KeyName] = 'CMSTwitterAccessToken' OR
[KeyName] = 'CMSTwitterAccessTokenSecret' OR
[KeyName] = 'CMSRequiredFacebookPage'");

        foreach (SettingsKeyInfo settingsKeyInfo in settings)
        {
            SettingsKeyInfoProvider.DeleteSettingsKeyInfo(settingsKeyInfo);
        }

        var categories = SettingsCategoryInfoProvider.GetSettingsCategories().Where(@"[CategoryName] = 'CMS.Facebook.UrlShortening' OR
[CategoryName] = 'CMS.Twitter.General' OR
[CategoryName] = 'CMS.Twitter.UrlShortening' OR
[CategoryName] = 'CMS.Twitter'");

        foreach (SettingsCategoryInfo category in categories)
        {
            SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(category);
        }
    }
Exemplo n.º 2
0
 protected void btnDeleteElem_Click(object sender, EventArgs e)
 {
     GetHiddenValues();
     if ((CategoryID > 0) && (ParentID > 0))
     {
         SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(CategoryID);
         AfterAction("delete", ParentID);
     }
 }
Exemplo n.º 3
0
    /// <summary>
    /// Deletes settings group. Called when the "Delete group" button is pressed.
    /// Expects the CreateSettingsGroup method to be run first.
    /// </summary>
    private bool DeleteSettingsGroup()
    {
        // Get the settings group
        SettingsCategoryInfo deleteGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsGroup");

        // Delete the settings group
        SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(deleteGroup);

        return(deleteGroup != null);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Deletes settings category. Called when the "Delete category" button is pressed.
    /// Expects the CreateSettingsCategory method to be run first.
    /// </summary>
    private bool DeleteSettingsCategory()
    {
        // Get the settings category
        SettingsCategoryInfo deleteCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsCategory");

        // Delete the settings category
        SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(deleteCategory);

        return(deleteCategory != null);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Handles the whole category actions.
    /// </summary>
    /// <param name="sender">Sender of event</param>
    /// <param name="e">Event arguments</param>
    protected void grpEdit_ActionPerformed(object sender, CommandEventArgs e)
    {
        int categoryId = ValidationHelper.GetInteger(e.CommandArgument, 0);

        switch (e.CommandName.ToLowerCSafe())
        {
        case ("edit"):
            // Redirect to category edit page
            SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId);
            if (sci != null)
            {
                URLHelper.Redirect(URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "Modules.Settings.EditCategory", false), "isgroup=1&categoryid=" + categoryId + "&moduleid=" + moduleId));
            }
            break;

        case ("delete"):
            try
            {
                SettingsCategoryInfo settingGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId);
                if (settingGroup != null)
                {
                    // Register refresh tree script
                    StringBuilder sb = new StringBuilder();
                    sb.Append("if (window.parent != null) {");
                    sb.Append("if (window.parent.parent.frames['settingstree'] != null) {");
                    sb.Append("window.parent.parent.frames['settingstree'].location = '" + ResolveUrl("~/CMSModules/Modules/Pages/Settings/Tree.aspx") + "?categoryid=" + settingGroup.CategoryParentID + "&moduleid=" + moduleId + "&reloadtreeselect=1';");
                    sb.Append("}");
                    sb.Append("if (window.parent.frames['settingstree'] != null) {");
                    sb.Append("window.parent.frames['settingstree'].location =  '" + ResolveUrl("~/CMSModules/Modules/Pages/Settings/Tree.aspx") + "?categoryid=" + settingGroup.CategoryParentID + "&moduleid=" + moduleId + "&reloadtreeselect=1';");
                    sb.Append("}");
                    sb.Append("}");

                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "treeGroupRefresh", ScriptHelper.GetScript(sb.ToString()));

                    SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(settingGroup);
                }
            }
            catch
            {
                ShowError(GetString("settings.group.deleteerror"));
            }
            grpEdit.ReloadData();
            break;

        case ("moveup"):
            SettingsCategoryInfoProvider.MoveCategoryUp(categoryId);
            grpEdit.ReloadData();
            break;

        case ("movedown"):
            SettingsCategoryInfoProvider.MoveCategoryDown(categoryId);
            grpEdit.ReloadData();
            break;
        }
    }
Exemplo n.º 6
0
 protected void btnDeleteElem_Click(object sender, EventArgs e)
 {
     GetHiddenValues();
     if ((ElementID > 0) && (ParentID > 0))
     {
         SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(ElementID);
         if (categoryObj.CategoryName != "CMS.CustomSettings")
         {
             SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(categoryObj);
             if (AfterAction != null)
             {
                 AfterAction("delete", ParentID);
             }
         }
     }
 }
Exemplo n.º 7
0
    /// <summary>
    /// Handles the whole category actions.
    /// </summary>
    /// <param name="sender">Sender of event</param>
    /// <param name="e">Event arguments</param>
    protected void grpEdit_ActionPerformed(object sender, CommandEventArgs e)
    {
        int categoryId = ValidationHelper.GetInteger(e.CommandArgument, 0);

        switch (e.CommandName.ToLowerCSafe())
        {
        case ("edit"):
            SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId);
            if (sci != null)
            {
                URLHelper.Redirect("~/CMSModules/Settings/Development/CustomSettings/CustomSettingsCategory_Edit.aspx?treeroot=" + mTreeRoot + "&isgroup=1&categoryid=" + categoryId);
            }
            break;

        case ("delete"):
            try
            {
                SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId);
                if (categoryObj.CategoryName != "CMS.CustomSettings")
                {
                    SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(categoryObj);
                }
            }
            catch
            {
                lblError.Text    = GetString("settings.group.deleteerror");
                lblError.Visible = true;
            }
            grpEdit.ReloadData();
            break;

        case ("moveup"):
            SettingsCategoryInfoProvider.MoveCategoryUp(categoryId);
            grpEdit.ReloadData();
            break;

        case ("movedown"):
            SettingsCategoryInfoProvider.MoveCategoryDown(categoryId);
            grpEdit.ReloadData();
            break;
        }
    }