Beispiel #1
0
    /// <summary>
    /// Gets user effective UI permission HTML content.
    /// </summary>
    private void GenerateBeforeRowsContent()
    {
        // Check if every necessary property is set
        if ((SelectedUser != null) && (Element != null) && (ElementResource != null))
        {
            // Initialize variables used during rendering
            string userName = HTMLHelper.HTMLEncode(TextHelper.LimitLength(Functions.GetFormattedUserName(SelectedUser.UserName, SelectedUser.FullName), 50));
            bool   authorizedToUIElement = UserInfoProvider.IsAuthorizedPerUIElement(ElementResource.ResourceName,
                                                                                     new[] { Element.ElementName },
                                                                                     siteSelector.SiteName,
                                                                                     SelectedUser,
                                                                                     true,
                                                                                     siteSelector.SiteID <= 0);
            // Create header table cell
            var tcHeader = new TableCell
            {
                CssClass = "matrix-header",
                ToolTip  = userName,
                Text     = userName
            };

            var tr = gridMatrix.ContentBeforeRow;
            tr.Cells.Add(tcHeader);

            // Create UI permission cell
            var tc  = new TableCell();
            var chk = new CMSCheckBox
            {
                Checked = SelectedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || authorizedToUIElement,
                Enabled = false,
                ToolTip = GetString("Administration-Permissions_Matrix.NotAdjustable")
            };

            tc.Controls.Add(chk);
            tr.Cells.Add(tc);

            UniMatrix.AddFillingCell <TableCell>(tr);
        }
    }
Beispiel #2
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
            };

            var tr = gridMatrix.ContentBeforeRow;
            tr.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);

            tr.Cells.Add(tc);

            UniMatrix.AddFillingCell <TableCell>(tr);
        }
    }
Beispiel #3
0
    /// <summary>
    /// Gets user effective permissions HTML content.
    /// </summary>
    /// <param name="siteId">Site ID</param>
    /// <param name="resourceId">ID of particular resource</param>
    /// <param name="selectedType">Permission type</param>
    private void GenerateBeforeRowsContent(int siteId, int resourceId, string selectedType)
    {
        // Check if selected users exists
        UserInfo user = SelectedUser;

        if (user == null)
        {
            gridMatrix.ShowContentBeforeRow = false;
            return;
        }

        string columns = "PermissionID";

        // Ensure tooltip column
        if (!String.IsNullOrEmpty(gridMatrix.ItemTooltipColumn))
        {
            columns += ",Matrix." + gridMatrix.ItemTooltipColumn;
        }

        // Get permission data
        DataSet dsPermissions;

        switch (selectedType)
        {
        case "r":
            dsPermissions = UserInfoProvider.GetUserResourcePermissions(user, siteId, resourceId, true, columns);
            break;

        default:
            dsPermissions = UserInfoProvider.GetUserDataClassPermissions(user, siteId, resourceId, true, columns);
            break;
        }

        if (!DataHelper.DataSourceIsEmpty(dsPermissions))
        {
            // Initialize variables used during rendering
            DataRowCollection rows     = dsPermissions.Tables[0].Rows;
            string            userName = Functions.GetFormattedUserName(user.UserName, user.FullName);
            var title = GetString("Administration-Permissions_Matrix.NotAdjustable");

            // Table header cell with user name
            var tcHeader = new TableCell
            {
                CssClass = "matrix-header",
                Text     = HTMLHelper.HTMLEncode(TextHelper.LimitLength(userName, 50)),
                ToolTip  = HTMLHelper.HTMLEncode(userName)
            };

            var tr = gridMatrix.ContentBeforeRow;

            tr.Cells.Add(tcHeader);

            // Process permissions according to matrix order
            foreach (int index in gridMatrix.ColumnOrderIndex)
            {
                DataRow dr = rows[index];

                // Table cell for each permission
                TableCell tc  = new TableCell();
                var       chk = new CMSCheckBox
                {
                    ID           = "chk_perm_" + index,
                    ClientIDMode = ClientIDMode.Static,
                    Enabled      = false,
                    Checked      = (SelectedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || Convert.ToInt32(dr["Allowed"]) == 1),
                    ToolTip      = title,
                };

                tc.Controls.Add(chk);
                tr.Cells.Add(tc);
            }

            UniMatrix.AddFillingCell <TableCell>(tr);
        }
    }