Exemplo n.º 1
0
    protected void editElem_OnBeforeSave(object sender, EventArgs e)
    {
        // Mark transformation as custom if module is not in development and development mode is off
        ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(QueryHelper.GetInteger("moduleid", 0));

        editElem.Data["TransformationIsCustom"] = !SystemContext.DevelopmentMode && ((resource != null) && !resource.ResourceIsInDevelopment);
    }
    /// <summary>
    /// Creates SettingsGroup panel for a specified category.
    /// </summary>
    /// <param name="category">Non-group category</param>
    protected CMSUserControl CreatePanelForCategory(SettingsCategoryInfo category)
    {
        if (category == null)
        {
            return(null);
        }

        // Create new Category bar and initialize it
        SettingsGroup group = Page.LoadUserControl("~/CMSModules/Modules/Controls/Settings/Category/SettingsGroup.ascx") as SettingsGroup;

        if (group != null)
        {
            group.Category         = category;
            group.ModuleID         = ModuleID;
            group.ActionPerformed += group_ActionPerformed;
            group.OnNewKey        += group_OnNewKey;
            group.OnKeyAction     += group_OnKeyAction;

            ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(ModuleID);

            group.AllowEdit = (resource != null) && ((resource.ResourceIsInDevelopment && (resource.ResourceID == category.CategoryResourceID)) || SystemContext.DevelopmentMode);
        }

        return(group);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Handles btnOK's OnClick event - Save resource info.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // finds whether required fields are not empty
        string result = new Validator().NotEmpty(tbModuleDisplayName.Text.Trim(), GetString("Administration-Module_New.ErrorEmptyModuleDisplayName")).NotEmpty(tbModuleCodeName.Text, GetString("Administration-Module_New.ErrorEmptyModuleCodeName"))
                        .IsCodeName(tbModuleCodeName.Text, GetString("general.invalidcodename"))
                        .Result;

        if (result == "")
        {
            // finds if the resource code name is unique
            if (ResourceInfoProvider.GetResourceInfo(tbModuleCodeName.Text) == null)
            {
                //Save resource info
                ResourceInfo ri = new ResourceInfo();
                ri.ResourceName        = tbModuleCodeName.Text;
                ri.ResourceDisplayName = tbModuleDisplayName.Text.Trim();

                ResourceInfoProvider.SetResourceInfo(ri);

                URLHelper.Redirect("Module_Edit_Frameset.aspx?moduleID=" + ri.ResourceId + "&saved=1");
            }
            else
            {
                // Show error message
                ShowError(GetString("Administration-Module_New.UniqueCodeName"));
            }
        }
        else
        {
            // Show error message
            ShowError(result);
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        moduleId = QueryHelper.GetInteger("moduleId", 0);

        if (moduleId > 0)
        {
            var module = ResourceInfoProvider.GetResourceInfo(moduleId);
            if ((module != null) && (module.ResourceName.EqualsCSafe("cms", true)))
            {
                ShowInformation(GetString("resource.cmsmoduleassignedtoallsites"));
                headTitle.Visible = false;
                usSites.Visible   = false;
                return;
            }

            // Get the active sites
            DataSet ds = ResourceSiteInfoProvider.GetResourceSites().WhereEquals("ResourceID", moduleId).Column("SiteID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "SiteID"));
            }

            if (!RequestHelper.IsPostBack())
            {
                usSites.Value = currentValues;
            }
        }

        usSites.OnSelectionChanged += usSites_OnSelectionChanged;
    }
Exemplo n.º 5
0
    /// <summary>
    /// Initialization of controls.
    /// </summary>
    private void InitControls()
    {
        // Init validators
        rfvCategoryDisplayName.ErrorMessage = ResHelper.GetString("general.requiresdisplayname");
        rfvCategoryName.ErrorMessage        = ResHelper.GetString("general.requirescodename");

        // Disable edit for category which is not for selected module
        if (SettingsCategoryObj != null)
        {
            ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(ModuleID);
            if ((((resource != null) && !resource.ResourceIsInDevelopment) || (SettingsCategoryObj.CategoryResourceID != ModuleID)) && !SystemContext.DevelopmentMode)
            {
                Enabled = false;
                HeaderActions.Enabled = false;
            }
        }

        if (SystemContext.DevelopmentMode)
        {
            ucSelectModule.Value = (SettingsCategoryObj == null) ? ModuleID : (!URLHelper.IsPostback()) ? SettingsCategoryObj.CategoryResourceID : ucSelectModule.Value;
        }

        // Set the root category
        if (RootCategoryID > 0)
        {
            drpCategory.RootCategoryId      = RootCategoryID;
            drpCategory.IncludeRootCategory = IncludeRootCategory;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check "read" permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.UIPersonalization", "Read"))
        {
            RedirectToAccessDenied("CMS.UIPersonalization", "Read");
        }

        int siteID = 0;

        if (SelectedSiteID != 0)
        {
            siteID = SelectedSiteID;
        }
        else if (SiteID != 0)
        {
            siteID = SiteID;
        }

        editElem.SiteID = siteID;

        ResourceInfo ri = ResourceInfoProvider.GetResourceInfo("CMS.WYSIWYGEditor");

        if (ri != null)
        {
            editElem.ResourceID       = ri.ResourceID;
            editElem.IsLiveSite       = false;
            editElem.RoleID           = QueryHelper.GetInteger("roleid", 0);
            editElem.HideSiteSelector = true;
        }
    }
Exemplo n.º 7
0
    public static bool DeleteModule(string resourceName)
    {
        ResourceInfo deleteModule = ResourceInfoProvider.GetResourceInfo(resourceName);

        ResourceInfoProvider.DeleteResourceInfo(deleteModule);
        return(deleteModule != null);
    }
Exemplo n.º 8
0
    /// <summary>
    /// Gets user effective resource permission HTML content.
    /// </summary>
    private void GenerateBeforeRowsContent()
    {
        ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(Permission.ResourceId);

        // Check if every necessary property is set
        if ((SelectedUser != null) && (Permission != null) && (resource != null))
        {
            // Initialize variables used during rendering
            string userName = HTMLHelper.HTMLEncode(TextHelper.LimitLength(Functions.GetFormattedUserName(SelectedUser.UserName, SelectedUser.FullName), 50));
            bool   authorizedPerResource = UserInfoProvider.IsAuthorizedPerResource(resource.ResourceName, Permission.PermissionName, siteSelector.SiteName, SelectedUser);

            // Create header table cell
            var tcHeader = new TableCell
            {
                CssClass = "matrix-header",
                ToolTip  = userName,
                Text     = userName
            };
            gridMatrix.ContentBeforeRow.Cells.Add(tcHeader);

            // Create resource permission cell
            var tc  = new TableCell();
            var chk = new CMSCheckBox
            {
                Checked = SelectedUser.IsGlobalAdministrator || authorizedPerResource,
                Enabled = false,
                ToolTip = GetString("Administration-Permissions_Matrix.NotAdjustable")
            };
            tc.Controls.Add(chk);
            gridMatrix.ContentBeforeRow.Cells.Add(tc);
        }
    }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(mAlternativeFormId);

        UIContext.EditedObject = afi;

        if (afi == null)
        {
            return;
        }

        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(afi.FormClassID);

        if (dci == null)
        {
            ShowError(GetString("general.invalidid"));
        }
        else
        {
            string formDef          = dci.ClassFormDefinition;
            string coupledClassName = null;

            if (afi.FormCoupledClassID > 0)
            {
                // If coupled class is defined combine form definitions
                DataClassInfo coupledDci = DataClassInfoProvider.GetDataClassInfo(afi.FormCoupledClassID);
                if (coupledDci != null)
                {
                    formDef          = FormHelper.MergeFormDefinitions(formDef, coupledDci.ClassFormDefinition);
                    coupledClassName = coupledDci.ClassName;
                }
            }

            var resource = ResourceInfoProvider.GetResourceInfo(QueryHelper.GetInteger("moduleid", 0));

            // Allow development mode only for non-system tables
            fieldEditor.DevelopmentMode = (resource != null) && resource.IsEditable;

            // Set original form definition
            fieldEditor.OriginalFormDefinition = formDef;

            // Merge class and alternative form definitions
            formDef = FormHelper.MergeFormDefinitions(formDef, afi.FormDefinition);

            // Initialize field editor mode and load form definition
            fieldEditor.AlternativeFormFullName = afi.FullName;
            fieldEditor.FormDefinition          = formDef;

            // Specify set of controls which should be offered for field types
            fieldEditor.DisplayedControls = mDisplayedControls;
            fieldEditor.ClassName         = dci.ClassName;
            fieldEditor.CoupledClassName  = coupledClassName;

            // Handle definition update (move up, move down, delete, OK button)
            fieldEditor.OnAfterDefinitionUpdate += fieldEditor_OnAfterDefinitionUpdate;
            fieldEditor.OnFieldNameChanged      += fieldEditor_OnFieldNameChanged;
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// Saves new or edited query of the given name and returns to the query list.
    /// </summary>
    /// <returns>True if query was successfully saved</returns>
    private bool SaveQuery()
    {
        // The query ID was specified, edit existing
        bool existing = (QueryID > 0);

        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(ClassName);

        if (dci == null)
        {
            ShowError(GetString("editedobject.notexists"));
            return(false);
        }

        ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(ModuleID);

        if (!existing && (resource != null) && !resource.IsEditable)
        {
            ShowError(GetString("cms.query.customization.createdisabled"));
            return(false);
        }

        QueryInfo newQuery = existing ? QueryInfoProvider.GetQueryInfo(QueryID) : new QueryInfo();

        // Sets query object's properties
        newQuery.QueryName = txtQueryName.Text;
        newQuery.ClassID   = dci.ClassID;

        // Check the query type
        newQuery.QueryType = rblQueryType.SelectedValue == "SQLQuery" ? QueryTypeEnum.SQLQuery : QueryTypeEnum.StoredProcedure;
        newQuery.QueryRequiresTransaction = chbTransaction.Checked;

        // Only for new query
        if (!existing)
        {
            // Set NOT custom only for queries created in development mode or in module in development
            if ((resource != null) && SystemContext.DevelopmentMode)
            {
                newQuery.QueryIsCustom = false;
                newQuery.QueryIsLocked = false;
            }
            else
            {
                newQuery.QueryIsCustom = true;
                newQuery.QueryIsLocked = true;
            }
        }

        newQuery.QueryText             = txtQueryText.Text.TrimEnd('\r', '\n');
        newQuery.QueryLoadGeneration   = drpGeneration.Value;
        newQuery.QueryConnectionString = ValidationHelper.GetString(ucSelectString.Value, String.Empty);

        // Insert new / update existing query
        QueryInfoProvider.SetQueryInfo(newQuery);

        Query = newQuery;

        return(true);
    }
    /// <summary>
    /// Handles btnOK's OnClick event - Update resource info.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Finds whether required fields are not empty
        string result = new Validator().NotEmpty(tbModuleDisplayName.Text.Trim(), GetString("Administration-Module_New.ErrorEmptyModuleDisplayName")).NotEmpty(tbModuleCodeName.Text, GetString("Administration-Module_New.ErrorEmptyModuleCodeName"))
                        .IsCodeName(tbModuleCodeName.Text, GetString("general.invalidcodename"))
                        .Result;

        if (result == "")
        {
            // Check unique name
            ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(tbModuleCodeName.Text);
            if ((ri == null) || (ri.ResourceId == moduleId))
            {
                // Get object
                if (ri == null)
                {
                    ri = ResourceInfoProvider.GetResourceInfo(moduleId);
                    if (ri == null)
                    {
                        ri = new ResourceInfo();
                    }
                }

                // Update resource info
                ri.ResourceId          = moduleId;
                ri.ResourceName        = tbModuleCodeName.Text;
                ri.ResourceDescription = txtModuleDescription.Text.Trim();
                ri.ResourceDisplayName = tbModuleDisplayName.Text.Trim();

                ResourceInfoProvider.SetResourceInfo(ri);

                // Update root UIElementInfo of the module
                UIElementInfo elemInfo = UIElementInfoProvider.GetRootUIElementInfo(ri.ResourceId);
                if (elemInfo == null)
                {
                    elemInfo = new UIElementInfo();
                }
                elemInfo.ElementResourceID  = ri.ResourceId;
                elemInfo.ElementDisplayName = ri.ResourceDisplayName;
                elemInfo.ElementName        = ri.ResourceName.ToLowerCSafe().Replace(".", "");
                elemInfo.ElementIsCustom    = false;
                UIElementInfoProvider.SetUIElementInfo(elemInfo);

                // Show message
                ShowChangesSaved();
            }
            else
            {
                // Show error message
                ShowError(GetString("Administration-Module_New.UniqueCodeName"));
            }
        }
        else
        {
            // Show error message
            ShowError(result);
        }
    }
Exemplo n.º 12
0
    /// <summary>
    /// Deletes module. Called when the "Delete module" button is pressed.
    /// Expects the CreateModule method to be run first.
    /// </summary>
    private bool DeleteModule()
    {
        // Get the module
        ResourceInfo deleteModule = ResourceInfoProvider.GetResourceInfo("MyNewModule");

        // Delete the module
        ResourceInfoProvider.DeleteResourceInfo(deleteModule);

        return(deleteModule != null);
    }
    /// <summary>
    /// Loads data of edited module from DB into TextBoxes.
    /// </summary>
    protected void LoadData()
    {
        ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(moduleId);

        if (ri != null)
        {
            tbModuleCodeName.Text     = ri.ResourceName;
            tbModuleDisplayName.Text  = ri.ResourceDisplayName;
            txtModuleDescription.Text = ri.ResourceDescription;
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// Initialization of controls.
    /// </summary>
    private void InitControls()
    {
        // Init validations
        rfvKeyDisplayName.ErrorMessage = ResHelper.GetString("general.requiresdisplayname");
        rfvKeyName.ErrorMessage        = ResHelper.GetString("general.requirescodename");

        // Display of LoadGeneration table row
        trLoadGeneration.Visible = SystemContext.DevelopmentMode;

        // Set the root category
        if (RootCategoryID > 0)
        {
            drpCategory.RootCategoryId = RootCategoryID;
        }

        // Enable only groups which belong to selected module
        drpCategory.EnabledCondition = "{% " + (!SystemContext.DevelopmentMode ? "(CategoryResourceID == " + ModuleID + ") && " : String.Empty) + "(CategoryIsGroup)%}";

        // If category specified programmatically
        if (mSelectedGroupId >= 0)
        {
            // Set category selector value
            if (!RequestHelper.IsPostBack())
            {
                drpCategory.SelectedCategory = mSelectedGroupId;
            }

            // Hide category selector
            trCategory.Visible = false;
        }
        else
        {
            // Set category selector value
            if (!URLHelper.IsPostback() && (SettingsKeyObj != null) && (SettingsKeyObj.KeyCategoryID > 0))
            {
                drpCategory.SelectedCategory = SettingsKeyObj.KeyCategoryID;
            }
        }

        if (!URLHelper.IsPostback())
        {
            LoadKeyTypes();
        }

        // Disable editing for keys not assigned to current module
        if (SettingsKeyObj != null)
        {
            SettingsCategoryInfo parentCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(SettingsKeyObj.KeyCategoryID);
            ResourceInfo         resource       = ResourceInfoProvider.GetResourceInfo(ModuleID);
            plnEdit.Enabled = btnOk.Enabled = (resource != null) && (((parentCategory != null) && (parentCategory.CategoryResourceID == resource.ResourceId) && resource.ResourceIsInDevelopment) || SystemContext.DevelopmentMode);
        }

        ucControlSettings.BasicForm.EnsureMessagesPlaceholder(MessagesPlaceHolder);
    }
Exemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        editElem.SiteID           = SiteID;
        editElem.HideSiteSelector = (SiteID != 0);
        ResourceInfo ri = ResourceInfoProvider.GetResourceInfo("CMS.WYSIWYGEditor");

        if (ri != null)
        {
            editElem.ResourceID = ri.ResourceId;
            editElem.IsLiveSite = false;
        }
    }
Exemplo n.º 16
0
    /// <summary>
    /// Generate info text for given setting key
    /// </summary>
    /// <param name="ski">Setting key object</param>
    private String GenerateInfoText(SettingsKeyInfo ski)
    {
        // Get setting's group
        SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(ski.KeyCategoryID);

        // Get resource name from group
        ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(sci.CategoryResourceID);

        string resourceName = ResHelper.LocalizeString(ri.ResourceDisplayName);
        string path         = string.Join(" -> ", GetCategoryPath(sci).Reverse().Select(s => ResHelper.LocalizeString(s.CategoryDisplayName)));

        return(String.Format(GetString("ui.moduledisabled.general"), resourceName, path, ResHelper.GetString(ski.KeyDisplayName)));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        SiteID                    = CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) ? 0 : SiteContext.CurrentSiteID;
        editElem.SiteID           = SiteID;
        editElem.HideSiteSelector = (SiteID != 0);
        ResourceInfo ri = ResourceInfoProvider.GetResourceInfo("CMS.WYSIWYGEditor");

        if (ri != null)
        {
            editElem.ResourceID = ri.ResourceID;
            editElem.IsLiveSite = false;
        }
    }
Exemplo n.º 18
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        // Add editing icon in development mode
        if (SettingsKeyProvider.DevelopmentMode && CMSContext.CurrentUser.IsGlobalAdministrator)
        {
            ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(this.ModuleName);
            if (ri != null)
            {
                treeElem.RootNode.Text = UIHelper.GetResourceUIElementsLink(this.Page, ri.ResourceId) + treeElem.RootNode.Text;
            }
        }
    }
Exemplo n.º 19
0
    /// <summary>
    /// Loads data of edited module from DB into TextBoxes.
    /// </summary>
    protected void LoadData()
    {
        ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(moduleId);

        if (ri != null)
        {
            tbModuleCodeName.Text        = ri.ResourceName;
            tbModuleDisplayName.Text     = ri.ResourceDisplayName;
            txtModuleDescription.Text    = ri.ResourceDescription;
            chkShowInDevelopment.Checked = ri.ShowInDevelopment;
            txtResourceUrl.Text          = (ri.ShowInDevelopment ? ri.ResourceUrl : "");

            pnlResourceUrl.Style.Add("display", (ri.ShowInDevelopment ? "block" : "none"));
        }
    }
Exemplo n.º 20
0
    public static bool CreatePermission(string displayName, string Name, string resourceName)
    {
        ResourceInfo module = ResourceInfoProvider.GetResourceInfo(resourceName);

        if (module != null)
        {
            PermissionNameInfo newPermission = new PermissionNameInfo();
            newPermission.PermissionDisplayName = displayName;
            newPermission.PermissionName        = Name;
            newPermission.ResourceId            = module.ResourceId;
            PermissionNameInfoProvider.SetPermissionInfo(newPermission);
            return(true);
        }
        return(false);
    }
Exemplo n.º 21
0
    /// <summary>
    /// Load data.
    /// </summary>
    public void LoadData()
    {
        process = true;
        if (!Visible || StopProcessing)
        {
            EnableViewState = false;
            process         = false;
        }

        IsLiveSite = false;

        if (ProjectID > 0)
        {
            // Get information on current project
            project = ProjectInfoProvider.GetProjectInfo(ProjectID);
        }

        // Get project resource
        resProjects = ResourceInfoProvider.GetResourceInfo("CMS.ProjectManagement");

        if ((resProjects != null) && (project != null))
        {
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@ID", resProjects.ResourceId);
            parameters.Add("@ProjectID", project.ProjectID);
            parameters.Add("@SiteID", CMSContext.CurrentSiteID);

            string where = "";
            int groupId = project.ProjectGroupID;

            // Build where condition
            if (groupId > 0)
            {
                where = "RoleGroupID=" + groupId.ToString() + " AND PermissionDisplayInMatrix = 0";
            }
            else
            {
                where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0";
            }

            // Setup matrix control
            gridMatrix.IsLiveSite      = IsLiveSite;
            gridMatrix.QueryParameters = parameters;
            gridMatrix.WhereCondition  = where;
            gridMatrix.ContentBefore   = "<table class=\"PermissionMatrix\" cellspacing=\"0\" cellpadding=\"0\" rules=\"rows\" border=\"1\" style=\"border-collapse:collapse;\">";
            gridMatrix.ContentAfter    = "</table>";
        }
    }
    protected void btnDeleteElem_Click(object sender, EventArgs e)
    {
        GetHiddenValue();
        if ((ElementId > 0) && (ElementInfo.ElementParentID > 0))
        {
            ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(ElementInfo.ElementResourceID);
            if ((ri != null) && !ri.ResourceIsInDevelopment)
            {
                ShowError(GetString("module.action.resourcenotindevelopment"));
                return;
            }

            UIElementInfoProvider.DeleteUIElementInfo(ElementId);
            AfterAction("delete", ElementInfo.ElementParentID);
        }
    }
Exemplo n.º 23
0
    /// <summary>
    /// Initializes the controls.
    /// </summary>
    private void SetupControls()
    {
        // Get info on the class
        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(QueryHelper.GetInteger("classid", 0));

        if (dci != null)
        {
            if (dci.ClassIsDocumentType && !dci.ClassIsCoupledClass)
            {
                ShowError(GetString("EditTemplateFields.ErrorIsNotCoupled"));
            }
            else
            {
                fieldEditor.Visible   = true;
                fieldEditor.ClassName = dci.ClassName;

                ResourceInfo resource           = ResourceInfoProvider.GetResourceInfo(QueryHelper.GetInteger("moduleid", 0));
                bool         devMode            = SystemContext.DevelopmentMode;
                bool         resourceIsEditable = (resource != null) && resource.IsEditable;
                bool         classIsEditable    = resourceIsEditable || dci.ClassShowAsSystemTable || devMode;

                // Allow development mode only for non-system tables
                fieldEditor.DevelopmentMode = resourceIsEditable;
                fieldEditor.Enabled         = classIsEditable;
                fieldEditor.Mode            = dci.ClassShowAsSystemTable ? FieldEditorModeEnum.SystemTable : FieldEditorModeEnum.ClassFormDefinition;

                if (devMode)
                {
                    // Add header action for generating default form definition
                    fieldEditor.HeaderActions.AddAction(new HeaderAction()
                    {
                        Text          = GetString("EditTemplateFields.GenerateFormDefinition"),
                        Tooltip       = GetString("EditTemplateFields.GenerateFormDefinition"),
                        OnClientClick = "if (!confirm('" + GetString("EditTemplateFields.GenerateFormDefConfirmation") + "')) {{ return false; }}",
                        Visible       = !dci.ClassIsDocumentType,
                        CommandName   = "gendefinition"
                    });

                    fieldEditor.HeaderActions.ActionPerformed += (s, ea) => { if (ea.CommandName == "gendefinition")
                                                                              {
                                                                                  GenerateDefinition();
                                                                              }
                    };
                }
            }
        }
    }
Exemplo n.º 24
0
    /// <summary>
    /// Load data.
    /// </summary>
    public void LoadData()
    {
        mProcess = true;
        if (!Visible || StopProcessing)
        {
            EnableViewState = false;
            mProcess        = false;
        }

        IsLiveSite = false;

        if (ProjectID > 0)
        {
            // Get information on current project
            mProject = ProjectInfoProvider.GetProjectInfo(ProjectID);
        }

        // Get project resource
        mResProjects = ResourceInfoProvider.GetResourceInfo("CMS.ProjectManagement");

        if ((mResProjects != null) && (mProject != null))
        {
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@ID", mResProjects.ResourceId);
            parameters.Add("@ProjectID", mProject.ProjectID);
            parameters.Add("@SiteID", SiteContext.CurrentSiteID);

            string where;
            int groupId = mProject.ProjectGroupID;

            // Build where condition
            if (groupId > 0)
            {
                where = "RoleGroupID=" + groupId + " AND PermissionDisplayInMatrix = 0";
            }
            else
            {
                where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0";
            }

            // Setup matrix control
            gridMatrix.IsLiveSite      = IsLiveSite;
            gridMatrix.QueryParameters = parameters;
            gridMatrix.WhereCondition  = where;
            gridMatrix.CssClass        = "permission-matrix";
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (DocumentType.ClassResourceID > 0)
     {
         // Page type belongs to module -> display just simple message
         var moduleName = ResHelper.LocalizeString(ResourceInfoProvider.GetResourceInfo(DocumentType.ClassResourceID).ResourceDisplayName);
         ShowInformation(String.Format(GetString("DocumentType_Edit_Sites.ModuleInfo"), moduleName));
         classSites.Visible = false;
     }
     else
     {
         // Page type doesn't belong to module -> display site binding edit
         classSites.TitleString  = GetString("DocumentType_Edit_Sites.Info");
         classSites.ClassId      = DocumentType.ClassID;
         classSites.CheckLicense = false;
     }
 }
Exemplo n.º 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ClassInfo != null)
        {
            string className = ClassInfo.ClassName.ToLower();

            switch (className)
            {
            case UserSettingsInfo.OBJECT_TYPE:
                ShowWarning(GetString("searchfields.usersettings"));
                searchFields.Visible = false;
                break;

            case "ecommerce.sku":
                ShowWarning(GetString("systbl.search.warninfo"));
                DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo("cms.document");
                if (dci != null)
                {
                    searchFields.ItemID = dci.ClassID;
                }
                searchFields.AdvancedMode = SystemContext.DevelopmentMode;
                CurrentMaster.HeaderActions.AddAction(new SaveAction());
                break;

            default:
                searchFields.ItemID           = ClassInfo.ClassID;
                searchFields.LoadActualValues = true;
                CurrentMaster.HeaderActions.AddAction(new SaveAction());
                break;
            }

            // Initialize customization if needed
            ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(QueryHelper.GetInteger("moduleid", 0));
            if ((className != UserSettingsInfo.OBJECT_TYPE) && !SystemContext.DevelopmentMode && (resource != null) && !resource.ResourceIsInDevelopment)
            {
                pnlCustomization.MessagesPlaceHolder = MessagesPlaceHolder;
                pnlCustomization.Columns             = new string[] { "ClassSearchEnabled", "ClassSearchTitleColumn", "ClassSearchContentColumn", "ClassSearchImageColumn", "ClassSearchCreationDateColumn", "ClassSearchSettings" };
                pnlCustomization.HeaderActions       = HeaderActions;
            }
            else
            {
                pnlCustomization.StopProcessing = true;
            }
        }
    }
Exemplo n.º 27
0
    /// <summary>
    /// Gets user effective UI permission HTML content.
    /// </summary>
    private string GetBeforeRowsContent()
    {
        // Initialize string builder
        StringBuilder sb       = new StringBuilder("");
        ResourceInfo  resource = ResourceInfoProvider.GetResourceInfo(Permission.ResourceId);

        // Check if every neccessary property is set
        if ((SelectedUser != null) && (Permission != null) && (resource != null))
        {
            // Initialize variables used during rendering
            string firstColumnsWidth = (gridMatrix.FirstColumnsWidth > 0) ? "width:" + gridMatrix.FirstColumnsWidth + (gridMatrix.UsePercentage ? "%;" : "px;") : "";
            string imagesUrl         = GetImageUrl("Design/Controls/UniMatrix/", false, true);
            string userName          = HTMLHelper.HTMLEncode(TextHelper.LimitLength(Functions.GetFormattedUserName(SelectedUser.UserName, SelectedUser.FullName), 50));

            // Get user name column
            sb.Append("<td class=\"MatrixHeader\" style=\"");
            sb.Append(firstColumnsWidth);
            sb.Append("white-space:nowrap;\" title=\"");
            sb.Append(userName);
            sb.Append("\">");
            sb.Append(userName);
            sb.Append("</td>\n");

            // Render UI permission cell
            sb.Append("<td style=\"white-space:nowrap; text-align: center;\"><img src=\"");
            sb.Append(imagesUrl);

            // Render checkboxes
            if (SelectedUser.IsGlobalAdministrator || UserInfoProvider.IsAuthorizedPerResource(resource.ResourceName, Permission.PermissionName, siteSelector.SiteName, SelectedUser))
            {
                sb.Append("allowed.png");
            }
            else
            {
                sb.Append("denied.png");
            }

            // Append tootlip and alternative text
            sb.Append("\" onclick=\"NA()\" title=\"\" alt=\"\" /></td>\n");

            // Add finish row
            sb.Append("<td></td>");
        }
        return(sb.ToString());
    }
Exemplo n.º 28
0
    /// <summary>
    /// Gets and updates module. Called when the "Get and update module" button is pressed.
    /// Expects the CreateModule method to be run first.
    /// </summary>
    private bool GetAndUpdateModule()
    {
        // Get the module
        ResourceInfo updateModule = ResourceInfoProvider.GetResourceInfo("MyNewModule");

        if (updateModule != null)
        {
            // Update the properties
            updateModule.ResourceDisplayName = updateModule.ResourceDisplayName.ToLower();

            // Save the changes
            ResourceInfoProvider.SetResourceInfo(updateModule);

            return(true);
        }

        return(false);
    }
Exemplo n.º 29
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);
    }
    /// <summary>
    /// Checks whether module is selected and is not in development mode
    /// </summary>
    void EditForm_OnItemValidation(object sender, ref string errorMessage)
    {
        FormEngineUserControl ctrl = sender as FormEngineUserControl;

        if ((ctrl != null) && (ctrl.FieldInfo.Name == "ElementResourceID"))
        {
            int resourceId = ValidationHelper.GetInteger(ctrl.Value, 0);
            if (resourceId > 0)
            {
                ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(resourceId);
                if ((ri != null) && (ri.ResourceIsInDevelopment || ((elementInfo != null) && elementInfo.ElementIsCustom)))
                {
                    return;
                }
            }
            errorMessage = ResHelper.GetString("module.noneordevelopedmoduleselected");
        }
    }