예제 #1
0
    /// <summary>
    /// Adds module to site. Called when the "Add module to site" button is pressed.
    /// Expects the CreateModule method to be run first.
    /// </summary>
    private bool AddModuleToSite()
    {
        /// Get the module
        ResourceInfo module = ResourceInfoProvider.GetResourceInfo("MyNewModule");

        if (module != null)
        {
            int moduleId = module.ResourceId;
            int siteId   = SiteContext.CurrentSiteID;

            // Save the binding
            ResourceSiteInfoProvider.AddResourceToSite(moduleId, siteId);

            return(true);
        }

        return(false);
    }
예제 #2
0
    protected void SaveSites()
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usSites.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    // Remove
                    ResourceSiteInfoProvider.RemoveResourceFromSite(moduleId, siteId);
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    // Add
                    ResourceSiteInfoProvider.AddResourceToSite(moduleId, siteId);
                }
            }
        }

        // Show message
        ShowChangesSaved();
    }