Beispiel #1
0
    /// <summary>
    /// Gets and bulk updates settings groups. Called when the "Get and bulk update groups" button is pressed.
    /// Expects the CreateSettingsGroup method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateSettingsGroups()
    {
        // Prepare the parameters
        string where = "CategoryName LIKE 'MyNew%' AND CategoryIsGroup = 1";
        string orderBy = "CategoryName";

        // Get the data
        DataSet groups = SettingsCategoryInfoProvider.GetSettingsCategories(where, orderBy);

        if (!DataHelper.DataSourceIsEmpty(groups))
        {
            // Loop through the individual items
            foreach (DataRow groupDr in groups.Tables[0].Rows)
            {
                // Create object from DataRow
                SettingsCategoryInfo modifyGroup = new SettingsCategoryInfo(groupDr);

                // Update the property
                modifyGroup.CategoryDisplayName = modifyGroup.CategoryDisplayName.ToUpper();

                // Update settings group
                SettingsCategoryInfoProvider.SetSettingsCategoryInfo(modifyGroup);
            }

            return(true);
        }

        return(false);
    }
Beispiel #2
0
    /// <summary>
    /// Creates settings category. Called when the "Create category" button is pressed.
    /// </summary>
    private bool CreateSettingsCategory()
    {
        // Get parent category ID
        SettingsCategoryInfo parentCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("CMS.CustomSettings");

        if (parentCategory != null)
        {
            // Create new settings category object
            SettingsCategoryInfo newCategory = new SettingsCategoryInfo();

            // Set the properties
            newCategory.CategoryDisplayName = "My New Settings Category";
            newCategory.CategoryName        = "MyNewSettingsCategory";
            newCategory.CategoryOrder       = 0;
            newCategory.CategoryParentID    = parentCategory.CategoryID;
            newCategory.CategoryIsGroup     = false;
            newCategory.CategoryIsCustom    = true;

            // Create settings category
            SettingsCategoryInfoProvider.SetSettingsCategoryInfo(newCategory);

            return(true);
        }

        return(false);
    }
Beispiel #3
0
    /// <summary>
    /// Creates settings group. Called when the "Create group" button is pressed.
    /// Expects the CreateSettingsCategory method to be run first.
    /// </summary>
    private bool CreateSettingsGroup()
    {
        // Get the settings category
        SettingsCategoryInfo settingsCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsCategory");

        if (settingsCategory != null)
        {
            // Create new settings group object
            SettingsCategoryInfo newGroup = new SettingsCategoryInfo();

            // Set the properties
            newGroup.CategoryDisplayName = "My New Settings Group";
            newGroup.CategoryName        = "MyNewSettingsGroup";
            newGroup.CategoryOrder       = 0;
            newGroup.CategoryParentID    = settingsCategory.CategoryID;
            newGroup.CategoryIsGroup     = true;
            newGroup.CategoryIsCustom    = true;

            // Create the settings group
            SettingsCategoryInfoProvider.SetSettingsCategoryInfo(newGroup);

            return(true);
        }

        return(false);
    }
Beispiel #4
0
    /// <summary>
    /// Gets and bulk updates settings categories. Called when the "Get and bulk update categories" button is pressed.
    /// Expects the CreateSettingsCategory method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateSettingsCategories()
    {
        // Prepare the parameters
        string where = "CategoryName LIKE 'MyNew%' AND CategoryIsGroup = 0";

        // Get the settings categories
        DataSet categories = SettingsCategoryInfoProvider.GetSettingsCategories(where, null);

        if (!DataHelper.DataSourceIsEmpty(categories))
        {
            // Loop through the individual items
            foreach (DataRow categoryDr in categories.Tables[0].Rows)
            {
                // Create object from DataRow
                SettingsCategoryInfo modifyCategory = new SettingsCategoryInfo(categoryDr);

                // Update the property
                modifyCategory.CategoryDisplayName = modifyCategory.CategoryDisplayName.ToUpper();

                // Update the settings category
                SettingsCategoryInfoProvider.SetSettingsCategoryInfo(modifyCategory);
            }

            return(true);
        }

        return(false);
    }
        public void CreateGroup(Group group)
        {
            var parentCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(group.Category.Name);
            var newGroup       = new SettingsCategoryInfo
            {
                CategoryDisplayName = group.DisplayName,
                CategoryName        = Guid.NewGuid().ToString(),
                CategoryParentID    = parentCategory.CategoryID,
                CategoryIsGroup     = true,
                CategoryIsCustom    = true,
                CategoryResourceID  = parentCategory.CategoryResourceID
            };

            SettingsCategoryInfoProvider.SetSettingsCategoryInfo(newGroup);
        }
        public void CreateCategory(Category category)
        {
            var parentCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(category.CategoryParentName);
            var newCategory    = new SettingsCategoryInfo
            {
                CategoryDisplayName = category.DisplayName,
                CategoryName        = category.Name,
                CategoryParentID    = parentCategory.CategoryID,
                CategoryIsGroup     = false,
                CategoryIsCustom    = true,
                CategoryResourceID  = parentCategory.CategoryResourceID
            };

            SettingsCategoryInfoProvider.SetSettingsCategoryInfo(newCategory);
        }
Beispiel #7
0
    /// <summary>
    /// Gets and updates settings group. Called when the "Get and update group" button is pressed.
    /// Expects the CreateSettingsGroup method to be run first.
    /// </summary>
    private bool GetAndUpdateSettingsGroup()
    {
        // Get the settings group
        SettingsCategoryInfo updateGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsGroup");

        if (updateGroup != null)
        {
            // Update the property
            updateGroup.CategoryDisplayName = updateGroup.CategoryDisplayName.ToLowerCSafe();

            // Update the settings group
            SettingsCategoryInfoProvider.SetSettingsCategoryInfo(updateGroup);

            return(true);
        }

        return(false);
    }
Beispiel #8
0
    /// <summary>
    /// Gets and updates settings category. Called when the "Get and update category" button is pressed.
    /// Expects the CreateSettingsCategory method to be run first.
    /// </summary>
    private bool GetAndUpdateSettingsCategory()
    {
        // Get the settings category
        SettingsCategoryInfo updateCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsCategory");

        if (updateCategory != null)
        {
            // Update the property
            updateCategory.CategoryDisplayName = updateCategory.CategoryDisplayName.ToLowerCSafe();

            // Update settings category
            SettingsCategoryInfoProvider.SetSettingsCategoryInfo(updateCategory);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Handles OnClick event of btnOk.
    /// </summary>
    /// <param name="sender">Asp Button instance</param>
    /// <param name="e">EventArgs instance</param>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (IsValid())
        {
            // Get category by name
            SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(txtCategoryName.Text.Trim());
            // If name is unique OR ids are same
            if ((categoryObj == null) || (categoryObj.CategoryID == mSettingsCategoryId))
            {
                SettingsCategoryInfo sci = SettingsCategoryObj;
                if (sci == null)
                {
                    sci = new SettingsCategoryInfo();
                    sci.CategoryOrder = mCategoryOrder;
                }

                if (sci.CategoryParentID != drpCategory.SelectedCategory)
                {
                    // When parent has been changed set the order for the category as the last possible order
                    sci.CategoryOrder = SettingsCategoryInfoProvider.GetLastSettingsCategoryOrder(drpCategory.SelectedCategory) + 1;
                }
                sci.CategoryName        = txtCategoryName.Text.Trim();
                sci.CategoryDisplayName = txtCategoryDisplayName.Text.Trim();
                sci.CategoryIconPath    = txtIconPath.Text.Trim();
                sci.CategoryParentID    = drpCategory.SelectedCategory;
                sci.CategoryIsGroup     = mIsGroupEdit;
                sci.CategoryIsCustom    = mIsCustom || chkIsCustom.Checked;

                SettingsCategoryInfoProvider.SetSettingsCategoryInfo(sci);
                SettingsCategoryObj = sci;
                RaiseOnSaved();

                // Set the info message
                if (ContentRefreshUrl == null)
                {
                    ShowChangesSaved();
                }

                // Reload header and content after save
                int           categoryIdToShow = sci.CategoryIsGroup ? sci.CategoryParentID : sci.CategoryID;
                StringBuilder sb = new StringBuilder();
                sb.Append("if (window.parent != null) {");
                if (HeaderRefreshUrl != null)
                {
                    sb.Append("if (window.parent.parent.frames['customsettingscategorytabs'] != null) {");
                    sb.Append("window.parent.parent.frames['customsettingscategorytabs'].location = '" + ResolveUrl(HeaderRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                    sb.Append("if (window.parent.frames['customsettingscategorytabs'] != null) {");
                    sb.Append("window.parent.frames['customsettingscategorytabs'].location = '" + ResolveUrl(HeaderRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                }
                if (TreeRefreshUrl != null)
                {
                    sb.Append("if (window.parent.parent.frames['customsettingstree'] != null) {");
                    sb.Append("window.parent.parent.frames['customsettingstree'].location = '" + ResolveUrl(TreeRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                    sb.Append("if (window.parent.frames['customsettingstree'] != null) {");
                    sb.Append("window.parent.frames['customsettingstree'].location =  '" + ResolveUrl(TreeRefreshUrl) + "categoryid=" + categoryIdToShow + "';");
                    sb.Append("}");
                }
                if (ContentRefreshUrl != null)
                {
                    sb.Append("window.location =  '" + ResolveUrl(ContentRefreshUrl) + "categoryid=" + sci.CategoryID + "';");
                }
                sb.Append("}");
                ltlScript.Text = ScriptHelper.GetScript(sb.ToString());
            }
            else
            {
                ShowError(GetString("general.codenameexists"));
            }
        }
    }
Beispiel #10
0
    /// <summary>
    /// Handles OnClick event of btnOk.
    /// </summary>
    /// <param name="sender">Asp Button instance</param>
    /// <param name="e">EventArgs instance</param>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (IsValid())
        {
            // Get category by name
            SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(txtCategoryName.Text.Trim());
            // If name is unique OR ids are same
            if ((categoryObj == null) || (categoryObj.CategoryID == SettingsCategoryID))
            {
                SettingsCategoryInfo sci = SettingsCategoryObj;
                if (sci == null)
                {
                    sci = new SettingsCategoryInfo();
                    sci.CategoryOrder = CategoryOrder;
                }

                if (sci.CategoryParentID != drpCategory.SelectedCategory)
                {
                    // When parent has been changed set the order for the category as the last possible order
                    sci.CategoryOrder = SettingsCategoryInfoProvider.GetLastSettingsCategoryOrder(drpCategory.SelectedCategory) + 1;
                }

                sci.CategoryName        = txtCategoryName.Text.Trim();
                sci.CategoryDisplayName = txtCategoryDisplayName.Text.Trim();
                sci.CategoryIconPath    = txtIconPath.Text.Trim();
                sci.CategoryParentID    = SelectedParentCategory;
                sci.CategoryIsGroup     = IsGroupEdit;
                sci.CategoryResourceID  = ValidationHelper.GetInteger(ucSelectModule.Value, ModuleID);

                SettingsCategoryInfoProvider.SetSettingsCategoryInfo(sci);
                SettingsCategoryObj = sci;
                RaiseOnSaved();

                // Set the info message
                if (ContentRefreshUrl == null)
                {
                    ShowChangesSaved();
                }

                // Reload header and content after save
                int categoryIdToShow = sci.CategoryIsGroup ? sci.CategoryParentID : sci.CategoryID;

                StringBuilder sb = new StringBuilder();
                sb.Append("if (window.parent != null) {");
                if (!String.IsNullOrEmpty(TreeRefreshUrl))
                {
                    sb.AppendFormat(@"if (window.parent.parent.frames['settingstree'] != null) {{
   window.parent.parent.frames['settingstree'].location = '{0}&categoryid={1}';
}}
if (window.parent.frames['settingstree'] != null) {{
   window.parent.frames['settingstree'].location = '{0}&categoryid={1}';
}}", ResolveUrl(TreeRefreshUrl), categoryIdToShow);
                }
                if (!String.IsNullOrEmpty(ContentRefreshUrl))
                {
                    sb.AppendFormat("window.location = '{0}&categoryid={1}';", ResolveUrl(ContentRefreshUrl), sci.CategoryID);
                }

                sb.Append("}");
                ltlScript.Text = ScriptHelper.GetScript(sb.ToString());
            }
            else
            {
                ShowError(GetString("general.codenameexists"));
            }
        }
    }