Exemplo n.º 1
0
    /// <summary>
    /// Sets given radio button to checked
    /// </summary>
    /// <param name="button"></param>
    private void SetIconOptionButtonChecked(CMSRadioButton button)
    {
        if (button == null)
        {
            // Ensure controls are available
            pnlUpdateContent.LoadContainer();
            pnlUpdate.LoadContainer();
        }

        if (button != null)
        {
            button.Checked = true;
        }
    }
Exemplo n.º 2
0
    public override void ReloadData()
    {
        int currPos = Convert.ToInt32(Math.Round(CurrentRating * MaxRating, MidpointRounding.AwayFromZero));

        plcContent.Controls.Clear();
        plcContent.Controls.Add(new LiteralControl("<table class=\"CntRatingRadioTable\"><tr>\n"));

        // Create radio buttons
        for (int i = 1; i <= MaxRating; i++)
        {
            plcContent.Controls.Add(new LiteralControl("<td>"));

            CMSRadioButton radBtn = new CMSRadioButton();
            radBtn.ID      = "radBtn_" + Convert.ToString(i);
            radBtn.Enabled = Enabled;
            if (!Enabled)
            {
                radBtn.Checked = i == currPos;
            }
            radBtn.GroupName = ClientID;
            plcContent.Controls.Add(radBtn);

            // WAI validation
            LocalizedLabel lbl = new LocalizedLabel();
            lbl.Display             = false;
            lbl.EnableViewState     = false;
            lbl.ResourceString      = "general.rating";
            lbl.AssociatedControlID = radBtn.ID;

            plcContent.Controls.Add(lbl);
            plcContent.Controls.Add(new LiteralControl("</td>"));
        }
        plcContent.Controls.Add(new LiteralControl("\n</tr>\n<tr>\n"));

        // Create labels
        for (int i = 1; i <= MaxRating; i++)
        {
            plcContent.Controls.Add(new LiteralControl("<td>" + i.ToString() + "</td>"));
        }
        plcContent.Controls.Add(new LiteralControl("\n</tr>\n</table>"));

        if (Enabled)
        {
            btnSubmit.Text   = ResHelper.GetString("general.ok");
            btnSubmit.Click += new EventHandler(btnSubmit_Click);
        }

        // Hide button when control is disabled or external management is used
        btnSubmit.Visible = Enabled && !ExternalManagement;
    }
    public override void ReloadData()
    {
        int currPos = Convert.ToInt32(Math.Round(CurrentRating * MaxRating, MidpointRounding.AwayFromZero));
        plcContent.Controls.Clear();
        plcContent.Controls.Add(new LiteralControl("<table class=\"CntRatingRadioTable\"><tr>\n"));

        // Create radio buttons
        for (int i = 1; i <= MaxRating; i++)
        {
            plcContent.Controls.Add(new LiteralControl("<td>"));

            CMSRadioButton radBtn = new CMSRadioButton();
            radBtn.ID = "radBtn_" + Convert.ToString(i);
            radBtn.Enabled = Enabled;
            if (!Enabled)
            {
                radBtn.Checked = i == currPos;
            }
            radBtn.GroupName = ClientID;
            plcContent.Controls.Add(radBtn);

            // WAI validation
            LocalizedLabel lbl = new LocalizedLabel();
            lbl.Display = false;
            lbl.EnableViewState = false;
            lbl.ResourceString = "general.rating";
            lbl.AssociatedControlID = radBtn.ID;

            plcContent.Controls.Add(lbl);
            plcContent.Controls.Add(new LiteralControl("</td>"));
        }
        plcContent.Controls.Add(new LiteralControl("\n</tr>\n<tr>\n"));

        // Create labels
        for (int i = 1; i <= MaxRating; i++)
        {
            plcContent.Controls.Add(new LiteralControl("<td>" + i.ToString() + "</td>"));
        }
        plcContent.Controls.Add(new LiteralControl("\n</tr>\n</table>"));

        if (Enabled)
        {
            btnSubmit.Text = ResHelper.GetString("general.ok");
            btnSubmit.Click += new EventHandler(btnSubmit_Click);
        }

        // Hide button when control is disabled or external management is used
        btnSubmit.Visible = Enabled && !ExternalManagement;
    }
    /// <summary>
    /// Loads the sizes previews.
    /// </summary>
    /// <param name="sizes">Array with sizes (two items per box)</param>
    public void LoadSizes(int[] sizes)
    {
        plcSizes.Controls.Clear();
        if (sizes.Length > 1)
        {
            int max = sizes[0];
            foreach (int size in sizes)
            {
                if (size > max)
                {
                    max = size;
                }
            }

            var radioList = new Panel
            {
                CssClass = "radio-list-vertical"
            };

            plcSizes.Controls.Add(radioList);

            for (int i = 0; i < sizes.Length; i += 2)
            {
                var radio = new CMSRadioButton();
                radio.Text = sizes[i] + " x " + sizes[i + 1];
                radio.Attributes.Add("onclick", "setSizes('" + sizes[i] + "', '" + sizes[i + 1] + "');");
                radio.GroupName = "size";

                if ((sizes[i] == SelectedWidth) && (sizes[i + 1] == SelectedHeight))
                {
                    radio.InputAttributes.Add("checked", "checked");
                }

                radioList.Controls.Add(radio);
            }
        }
    }
    /// <summary>
    /// Creates poll answer section.
    /// </summary>
    /// <param name="reload">Indicates postback</param>
    /// <param name="hasVoted">Indicates if user has voted</param>
    protected void CreateAnswerSection(bool reload, bool hasVoted)
    {
        pnlAnswer.Controls.Clear();

        if (pi != null)
        {
            // Get poll's answers
            DataSet ds = Answers;
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                int  count        = 0;
                int  maxCount     = 0;
                long sumCount     = 0;
                bool hideSomeForm = false;

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    // Sum answer counts and get highest
                    if (ValidationHelper.GetBoolean(row["AnswerEnabled"], true))
                    {
                        count     = ValidationHelper.GetInteger(row["AnswerCount"], 0);
                        sumCount += count;
                        if (count > maxCount)
                        {
                            maxCount = count;
                        }
                    }

                    // Check if any open-ended answer form should be hidden
                    if (ValidationHelper.GetBoolean(row["AnswerHideForm"], false))
                    {
                        hideSomeForm = true;
                    }
                }

                CMSCheckBox    chkItem  = null;
                CMSRadioButton radItem  = null;
                LocalizedLabel lblItem  = null;
                BizForm        viewBiz  = null;
                string         formName = null;
                int            index    = 0;
                bool           enabled  = false;

                bool bizFormsAvailable = ModuleManager.IsModuleLoaded(ModuleName.BIZFORM) && ResourceSiteInfoProvider.IsResourceOnSite(ModuleName.BIZFORM, SiteContext.CurrentSiteName);

                pnlAnswer.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">"));

                // Create the answers
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    enabled = ValidationHelper.GetBoolean(row["AnswerEnabled"], true);
                    if (enabled)
                    {
                        pnlAnswer.Controls.Add(new LiteralControl("<tr><td class=\"PollAnswer\" colspan=\"2\">"));

                        if (((reload) && (ShowResultsAfterVote)) || (!hasPermission && !HideWhenNotAuthorized) ||
                            (!isOpened && !HideWhenNotOpened) || (CheckVoted && PollInfoProvider.HasVoted(pi.PollID)))
                        {
                            // Add label
                            lblItem    = new LocalizedLabel();
                            lblItem.ID = "lbl" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                            lblItem.EnableViewState = false;
                            lblItem.Text            = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty));
                            lblItem.CssClass        = "PollAnswerText";

                            pnlAnswer.Controls.Add(lblItem);
                        }
                        else
                        {
                            if (pi.PollAllowMultipleAnswers)
                            {
                                // Add checkboxes for multiple answers
                                chkItem              = new CMSCheckBox();
                                chkItem.ID           = "chk" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                                chkItem.AutoPostBack = false;
                                chkItem.Text         = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty));
                                chkItem.Checked      = false;
                                chkItem.CssClass     = "PollAnswerCheck";

                                if (hideSomeForm)
                                {
                                    chkItem.AutoPostBack    = true;
                                    chkItem.CheckedChanged += AnswerSelectionChanged;
                                }
                                pnlAnswer.Controls.Add(chkItem);
                            }
                            else
                            {
                                // Add radiobuttons
                                radItem              = new CMSRadioButton();
                                radItem.ID           = "rad" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                                radItem.AutoPostBack = false;
                                radItem.GroupName    = pi.PollCodeName + "Group";
                                radItem.Text         = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty));
                                radItem.Checked      = false;
                                radItem.CssClass     = "PollAnswerRadio";

                                if (hideSomeForm)
                                {
                                    radItem.AutoPostBack    = true;
                                    radItem.CheckedChanged += AnswerSelectionChanged;
                                }

                                pnlAnswer.Controls.Add(radItem);
                            }

                            formName = ValidationHelper.GetString(row["AnswerForm"], string.Empty);

                            if (!string.IsNullOrEmpty(formName) && bizFormsAvailable)
                            {
                                // Add forms for open ended answers
                                viewBiz          = new BizForm();
                                viewBiz.FormName = formName;
                                viewBiz.SiteName = SiteContext.CurrentSiteName;
                                viewBiz.AlternativeFormFullName = ValidationHelper.GetString(row["AnswerAlternativeForm"], string.Empty);
                                viewBiz.ID                 = "frm" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                                viewBiz.IsLiveSite         = IsLiveSite;
                                viewBiz.OnAfterDataLoad   += Form_AfterDataLoad;
                                viewBiz.CssClass           = "PollAnswerForm";
                                viewBiz.Visible            = !ValidationHelper.GetBoolean(row["AnswerHideForm"], false);
                                viewBiz.FormClearAfterSave = true;
                                viewBiz.FormRedirectToUrl  = String.Empty;
                                viewBiz.FormDisplayText    = String.Empty;
                                pnlAnswer.Controls.Add(viewBiz);
                            }
                        }

                        pnlAnswer.Controls.Add(new LiteralControl("</td></tr>"));

                        if (ShowGraph || (hasVoted || reload) && ShowResultsAfterVote)
                        {
                            // Create graph under the answer
                            CreateGraph(maxCount, ValidationHelper.GetInteger(row["AnswerCount"], 0), sumCount, index);
                        }

                        index++;
                    }
                }

                pnlAnswer.Controls.Add(new LiteralControl("</table>"));
            }
        }
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var cui = MembershipContext.AuthenticatedUser;

        reportHeader.ActionPerformed += HeaderActions_ActionPerformed;

        if (DataHelper.GetNotEmpty(RequestContext.CurrentDomain, "") != "")
        {
            LicenseHelper.CheckFeatureAndRedirect(RequestContext.CurrentDomain, FeatureEnum.MVTesting);
        }

        // Set disabled module info
        ucDisabledModule.SettingsKeys = "CMSAnalyticsEnabled;CMSMVTEnabled";
        ucDisabledModule.ParentPanel  = pnlWarning;

        // Register actions
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, (s, args) => Save());

        mUcDisplayReport = (IDisplayReport)LoadUserControl("~/CMSModules/Reporting/Controls/DisplayReport.ascx");
        pnlContent.Controls.Add((Control)mUcDisplayReport);

        CurrentMaster.PanelContent.CssClass = String.Empty;
        UIHelper.AllowUpdateProgress        = false;

        // MVTest Info
        int        mvTestID = QueryHelper.GetInteger("objectID", 0);
        MVTestInfo mvInfo   = MVTestInfoProvider.GetMVTestInfo(mvTestID);

        if (mvInfo == null)
        {
            return;
        }

        // Load combination by current template ID and culture
        int nodeID = QueryHelper.GetInteger("NodeID", 0);

        if (nodeID > 0)
        {
            // Create condition for current template combinations
            TreeProvider tree = new TreeProvider(cui);
            TreeNode     node = tree.SelectSingleNode(nodeID, LocalizationContext.PreferredCultureCode);

            if (node != null)
            {
                usCombination.DocumentID     = node.DocumentID;
                usCombination.PageTemplateID = node.GetUsedPageTemplateId();
            }
        }
        else
        {
            rbCombinations.Visible = false;
        }

        usCombination.ReloadData(true);

        mTestName = mvInfo.MVTestName;

        ucGraphType.ProcessChartSelectors(false);

        // Enables/disables radio buttons (based on UI elements)
        var ui = MembershipContext.AuthenticatedUser;

        if (!RequestHelper.IsPostBack())
        {
            if (!ui.IsGlobalAdministrator)
            {
                bool checkedButton = false;

                // Check first enabled button
                foreach (Control ctrl in pnlRadioButtons.Controls)
                {
                    CMSRadioButton rb = ctrl as CMSRadioButton;
                    if (rb != null)
                    {
                        if (rb.Enabled)
                        {
                            rb.Checked    = true;
                            checkedButton = true;
                            break;
                        }
                    }
                }

                // No report avaible -> redirect to access denied
                if (!checkedButton)
                {
                    RedirectToAccessDenied(GetString("mvtest.noreportavaible"));
                }
            }
            else
            {
                // Admin check first radio button
                rbCount.Checked = true;
            }
        }
    }
    /// <summary>
    /// Creates poll answer section.
    /// </summary>
    /// <param name="reload">Indicates postback</param>
    /// <param name="hasVoted">Indicates if user has voted</param>
    protected void CreateAnswerSection(bool reload, bool hasVoted)
    {
        pnlAnswer.Controls.Clear();

        if (pi != null)
        {
            // Get poll's answers
            DataSet ds = Answers;
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                int count = 0;
                int maxCount = 0;
                long sumCount = 0;
                bool hideSomeForm = false;

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    // Sum answer counts and get highest
                    if (ValidationHelper.GetBoolean(row["AnswerEnabled"], true))
                    {
                        count = ValidationHelper.GetInteger(row["AnswerCount"], 0);
                        sumCount += count;
                        if (count > maxCount)
                        {
                            maxCount = count;
                        }
                    }

                    // Check if any open-ended answer form should be hidden
                    if (ValidationHelper.GetBoolean(row["AnswerHideForm"], false))
                    {
                        hideSomeForm = true;
                    }
                }

                CMSCheckBox chkItem = null;
                CMSRadioButton radItem = null;
                LocalizedLabel lblItem = null;
                BizForm viewBiz = null;
                string formName = null;
                int index = 0;
                bool enabled = false;

                bool bizFormsAvailable = ModuleManager.IsModuleLoaded(ModuleName.BIZFORM) && ResourceSiteInfoProvider.IsResourceOnSite(ModuleName.BIZFORM, SiteContext.CurrentSiteName);

                pnlAnswer.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">"));

                // Create the answers
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    enabled = ValidationHelper.GetBoolean(row["AnswerEnabled"], true);
                    if (enabled)
                    {
                        pnlAnswer.Controls.Add(new LiteralControl("<tr><td class=\"PollAnswer\" colspan=\"2\">"));

                        if (((reload) && (ShowResultsAfterVote)) || (!hasPermission && !HideWhenNotAuthorized)
                            || (!isOpened && !HideWhenNotOpened) || (CheckVoted && PollInfoProvider.HasVoted(pi.PollID)))
                        {
                            // Add label
                            lblItem = new LocalizedLabel();
                            lblItem.ID = "lbl" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                            lblItem.EnableViewState = false;
                            lblItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty));
                            lblItem.CssClass = "PollAnswerText";

                            pnlAnswer.Controls.Add(lblItem);
                        }
                        else
                        {
                            if (pi.PollAllowMultipleAnswers)
                            {
                                // Add checkboxes for multiple answers
                                chkItem = new CMSCheckBox();
                                chkItem.ID = "chk" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                                chkItem.AutoPostBack = false;
                                chkItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty));
                                chkItem.Checked = false;
                                chkItem.CssClass = "PollAnswerCheck";

                                if (hideSomeForm)
                                {
                                    chkItem.AutoPostBack = true;
                                    chkItem.CheckedChanged += AnswerSelectionChanged;
                                }
                                pnlAnswer.Controls.Add(chkItem);
                            }
                            else
                            {
                                // Add radiobuttons
                                radItem = new CMSRadioButton();
                                radItem.ID = "rad" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                                radItem.AutoPostBack = false;
                                radItem.GroupName = pi.PollCodeName + "Group";
                                radItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty));
                                radItem.Checked = false;
                                radItem.CssClass = "PollAnswerRadio";

                                if (hideSomeForm)
                                {
                                    radItem.AutoPostBack = true;
                                    radItem.CheckedChanged += AnswerSelectionChanged;
                                }

                                pnlAnswer.Controls.Add(radItem);
                            }

                            formName = ValidationHelper.GetString(row["AnswerForm"], string.Empty);

                            if (!string.IsNullOrEmpty(formName) && bizFormsAvailable)
                            {
                                // Add forms for open ended answers
                                viewBiz = new BizForm();
                                viewBiz.FormName = formName;
                                viewBiz.SiteName = SiteContext.CurrentSiteName;
                                viewBiz.AlternativeFormFullName = ValidationHelper.GetString(row["AnswerAlternativeForm"], string.Empty);
                                viewBiz.ID = "frm" + ValidationHelper.GetInteger(row["AnswerID"], 0);
                                viewBiz.IsLiveSite = IsLiveSite;
                                viewBiz.OnAfterDataLoad += Form_AfterDataLoad;
                                viewBiz.CssClass = "PollAnswerForm";
                                viewBiz.Visible = !ValidationHelper.GetBoolean(row["AnswerHideForm"], false);
                                viewBiz.FormClearAfterSave = true;
                                viewBiz.FormRedirectToUrl = String.Empty;
                                viewBiz.FormDisplayText = String.Empty;
                                pnlAnswer.Controls.Add(viewBiz);
                            }
                        }

                        pnlAnswer.Controls.Add(new LiteralControl("</td></tr>"));

                        if (ShowGraph || (hasVoted || reload) && ShowResultsAfterVote)
                        {
                            // Create graph under the answer
                            CreateGraph(maxCount, ValidationHelper.GetInteger(row["AnswerCount"], 0), sumCount, index);
                        }

                        index++;
                    }
                }

                pnlAnswer.Controls.Add(new LiteralControl("</table>"));
            }
        }
    }
    /// <summary>
    /// Generates the permission matrix for the cutrrent project.
    /// </summary>
    private void CreateMatrix()
    {
        // Get project resource info
        if (mResProjects == null)
        {
            mResProjects = ResourceInfoProvider.GetResourceInfo("CMS.ProjectManagement");
        }

        // Get project object
        if ((mProject == null) && (ProjectID > 0))
        {
            mProject = ProjectInfoProvider.GetProjectInfo(ProjectID);
        }

        if ((mResProjects != null) && (mProject != null))
        {
            // Get permissions for the current project resource
            DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(mResProjects.ResourceId);
            if (DataHelper.DataSourceIsEmpty(permissions))
            {
                lblInfo.Text = GetString("general.emptymatrix");
                lblInfo.Visible = true;
            }
            else
            {
                TableRow headerRow = new TableRow();
                headerRow.TableSection = TableRowSection.TableHeader;
                headerRow.CssClass = "unigrid-head";

                TableHeaderCell newHeaderCell = new TableHeaderCell();
                newHeaderCell.CssClass = "first-column";
                headerRow.Cells.Add(newHeaderCell);

                foreach (string permission in mAllowedPermissions)
                {
                    DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'");
                    if (drArray.Length > 0)
                    {
                        DataRow dr = drArray[0];
                        newHeaderCell = new TableHeaderCell();
                        newHeaderCell.Text = dr["PermissionDisplayName"].ToString();
                        newHeaderCell.ToolTip = dr["PermissionDescription"].ToString();
                        headerRow.Cells.Add(newHeaderCell);
                    }
                    else
                    {
                        throw new Exception("[Security matrix] Column '" + permission + "' cannot be found.");
                    }
                }

                tblMatrix.Rows.Add(headerRow);

                // Render project access permissions
                object[,] accessNames = new object[5, 2];
                accessNames[0, 0] = GetString("security.nobody");
                accessNames[0, 1] = SecurityAccessEnum.Nobody;
                accessNames[1, 0] = GetString("security.allusers");
                accessNames[1, 1] = SecurityAccessEnum.AllUsers;
                accessNames[2, 0] = GetString("security.authenticated");
                accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers;
                accessNames[3, 0] = GetString("security.groupmembers");
                accessNames[3, 1] = SecurityAccessEnum.GroupMembers;
                accessNames[4, 0] = GetString("security.authorizedroles");
                accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles;

                TableRow newRow;
                int rowIndex = 0;
                for (int access = 0; access <= accessNames.GetUpperBound(0); access++)
                {
                    SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]);

                    // If the security isn't displayed as part of group section
                    if ((currentAccess == SecurityAccessEnum.GroupMembers) && (mProject.ProjectGroupID == 0))
                    {
                        // Do not render this access item
                    }
                    else
                    {
                        // Generate cell holding access item name
                        newRow = new TableRow();
                        TableCell newCell = new TableCell();
                        newCell.Text = accessNames[access, 0].ToString();
                        newCell.CssClass = "matrix-header";
                        newRow.Cells.Add(newCell);
                        rowIndex++;

                        // Render the permissions access items
                        int permissionIndex = 0;
                        for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++)
                        {
                            newCell = new TableCell();

                            // Check if the currently processed access is applied for permission
                            bool isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text);

                            // Disable column in roles grid if needed
                            if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed)
                            {
                                gridMatrix.DisableColumn(permissionIndex);
                            }

                            // Insert the radio button for the current permission
                            var radio = new CMSRadioButton
                            {
                                Checked = isAllowed,
                                Enabled = Enable,
                            };
                            radio.Attributes.Add("onclick", ControlsHelper.GetPostBackEventReference(this, permission + ";" + Convert.ToInt32(currentAccess)));
                            newCell.Controls.Add(radio);

                            newRow.Cells.Add(newCell);
                            permissionIndex++;
                        }

                        // Add the access row to the table
                        tblMatrix.Rows.Add(newRow);
                    }
                }

                // Check if project has some roles assigned
                headTitle.Visible = gridMatrix.HasData;
            }
        }
    }
    /// <summary>
    /// Sets given radio button to checked
    /// </summary>
    /// <param name="button"></param>
    private void SetIconOptionButtonChecked(CMSRadioButton button)
    {
        if (button == null)
        {
            // Ensure controls are available
            pnlUpdateContent.LoadContainer();
            pnlUpdate.LoadContainer();
        }

        if (button != null)
        {
            button.Checked = true;
        }
    }
    /// <summary>
    /// Loads the sizes previews.
    /// </summary>
    /// <param name="sizes">Array with sizes (two items per box)</param>
    public void LoadSizes(int[] sizes)
    {
        plcSizes.Controls.Clear();
        if (sizes.Length > 1)
        {
            int max = sizes[0];
            foreach (int size in sizes)
            {
                if (size > max)
                {
                    max = size;
                }
            }

            var radioList = new Panel
            {
                CssClass = "radio-list-vertical"
            };

            plcSizes.Controls.Add(radioList);

            for (int i = 0; i < sizes.Length; i += 2)
            {
                var radio = new CMSRadioButton();
                radio.Text = sizes[i] + " x " + sizes[i + 1];
                radio.Attributes.Add("onclick", "setSizes('" + sizes[i] + "', '" + sizes[i + 1] + "');");
                radio.GroupName = "size";

                if ((sizes[i] == SelectedWidth) && (sizes[i + 1] == SelectedHeight))
                {
                    radio.InputAttributes.Add("checked", "checked");
                }

                radioList.Controls.Add(radio);
            }
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Generates the permission matrix for the current forum.
    /// </summary>
    private void CreateMatrix()
    {
        // Get forum resource info
        if (resForums == null)
        {
            resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums");
        }

        // Get forum object
        if ((forum == null) && (ForumID > 0))
        {
            forum = ForumInfoProvider.GetForumInfo(ForumID);
        }

        if ((resForums != null) && (forum != null))
        {
            // Get permissions for the current forum resource
            DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(resForums.ResourceID);
            if (DataHelper.DataSourceIsEmpty(permissions))
            {
                ShowInformation(GetString("general.emptymatrix"));
            }
            else
            {
                TableHeaderRow headerRow = new TableHeaderRow();
                headerRow.CssClass     = "unigrid-head";
                headerRow.TableSection = TableRowSection.TableHeader;
                TableCell       newCell       = new TableCell();
                TableHeaderCell newHeaderCell = new TableHeaderCell();
                newHeaderCell.CssClass = "first-column";
                headerRow.Cells.Add(newHeaderCell);

                foreach (string permission in allowedPermissions)
                {
                    DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'");
                    if (drArray.Length > 0)
                    {
                        DataRow dr = drArray[0];
                        newHeaderCell         = new TableHeaderCell();
                        newHeaderCell.Text    = dr["PermissionDisplayName"].ToString();
                        newHeaderCell.ToolTip = dr["PermissionDescription"].ToString();
                        headerRow.Cells.Add(newHeaderCell);
                    }
                    else
                    {
                        throw new Exception("[Security matrix] Column '" + permission + "' cannot be found.");
                    }
                }

                tblMatrix.Rows.Add(headerRow);

                // Render forum access permissions
                object[,] accessNames = new object[5, 2];
                accessNames[0, 0]     = GetString("security.nobody");
                accessNames[0, 1]     = SecurityAccessEnum.Nobody;
                accessNames[1, 0]     = GetString("security.allusers");
                accessNames[1, 1]     = SecurityAccessEnum.AllUsers;
                accessNames[2, 0]     = GetString("security.authenticated");
                accessNames[2, 1]     = SecurityAccessEnum.AuthenticatedUsers;
                accessNames[3, 0]     = GetString("security.groupmembers");
                accessNames[3, 1]     = SecurityAccessEnum.GroupMembers;
                accessNames[4, 0]     = GetString("security.authorizedroles");
                accessNames[4, 1]     = SecurityAccessEnum.AuthorizedRoles;

                TableRow newRow = null;
                for (int access = 0; access <= accessNames.GetUpperBound(0); access++)
                {
                    SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]);

                    // If the security isn't displayed as part of group section
                    if ((currentAccess == SecurityAccessEnum.GroupMembers) && (!IsGroupForum))
                    {
                        // Do not render this access item
                    }
                    else
                    {
                        // Generate cell holding access item name
                        newRow           = new TableRow();
                        newCell          = new TableCell();
                        newCell.Text     = accessNames[access, 0].ToString();
                        newCell.CssClass = "matrix-header";
                        newRow.Cells.Add(newCell);

                        // Render the permissions access items
                        bool isAllowed       = false;
                        bool isEnabled       = true;
                        int  permissionIndex = 0;
                        for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++)
                        {
                            newCell = new TableCell();

                            // Check if the currently processed access is applied for permission
                            isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text);
                            isEnabled = ((currentAccess != SecurityAccessEnum.AllUsers) || (permission != 1)) && Enable;

                            // Disable column in roles grid if needed
                            if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed)
                            {
                                gridMatrix.DisableColumn(permissionIndex);
                            }

                            // Insert the radio button for the current permission
                            var radio = new CMSRadioButton
                            {
                                Checked = isAllowed,
                                Enabled = isEnabled,
                            };
                            radio.Attributes.Add("onclick", ControlsHelper.GetPostBackEventReference(this, permission + ";" + Convert.ToInt32(currentAccess)));
                            newCell.Controls.Add(radio);

                            newRow.Cells.Add(newCell);
                            permissionIndex++;
                        }

                        // Add the access row to the table
                        tblMatrix.Rows.Add(newRow);
                    }
                }

                // Check if forum has some roles assigned
                headTitle.Visible = gridMatrix.HasData;
            }
        }
    }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        reportHeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        mUcDisplayReport = (IDisplayReport)LoadUserControl("~/CMSModules/Reporting/Controls/DisplayReport.ascx");
        pnlContent.Controls.Add((Control)mUcDisplayReport);

        CurrentMaster.PanelContent.CssClass = string.Empty;
        UIHelper.AllowUpdateProgress        = false;
        ScriptHelper.RegisterDialogScript(Page);

        // Campaign Info
        mCampaignInfo = EditedObject as CampaignInfo;
        if (mCampaignInfo == null)
        {
            return;
        }

        // Validate SiteID for non administrators
        if (!MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
        {
            if (mCampaignInfo.CampaignSiteID != SiteContext.CurrentSiteID)
            {
                RedirectToAccessDenied(GetString("cmsmessages.accessdenied"));
            }
        }

        mCampaignName = mCampaignInfo.CampaignName;

        ucGraphType.ProcessChartSelectors(false);

        // Enables/disables radio buttons (based on UI elements)
        var  ui            = MembershipContext.AuthenticatedUser;
        bool checkedButton = false;

        if (!RequestHelper.IsPostBack())
        {
            if (!ui.IsGlobalAdministrator)
            {
                rbCount.Enabled           = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "CampaignConversionCount");
                rbDetail.Enabled          = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "CampaignDetails");
                rbGoalCount.Enabled       = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "goals.numberofconversions");
                rbGoalValue.Enabled       = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "goals.totalvalueofconversions");
                rbGoalView.Enabled        = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "goals.numberofvisitors");
                rbValue.Enabled           = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "campaignsConversionValue");
                rbValuePerVisitor.Enabled = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "valuepervisitor");
                rbViews.Enabled           = ui.IsAuthorizedPerUIElement("cms.WebAnalytics", "campaign.overview");

                // Check first enabled button
                foreach (Control ctrl in pnlRadios.Controls)
                {
                    CMSRadioButton rb = ctrl as CMSRadioButton;
                    if (rb != null)
                    {
                        if (rb.Enabled)
                        {
                            rb.Checked    = true;
                            checkedButton = true;
                            break;
                        }
                    }
                }

                // No report avaible -> redirect to access denied
                if (!checkedButton)
                {
                    RedirectToAccessDenied(GetString("campaign.noreportavaible"));
                }
            }
            else
            {
                // Admin check first radio button
                rbViews.Checked = true;
            }
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// Generates the permission matrix for the cutrrent widget.
    /// </summary>
    private void CreateMatrix()
    {
        // Get widget resource info
        if ((ResWidget != null) && (WidgetInfo != null))
        {
            // Get permissions for the current widget resource
            DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(ResWidget.ResourceId);
            if (DataHelper.DataSourceIsEmpty(permissions))
            {
                lblInfo.Text = GetString("general.emptymatrix");
            }
            else
            {
                TableRow headerRow = new TableRow();
                headerRow.CssClass        = "unigrid-head";
                headerRow.TableSection    = TableRowSection.TableHeader;
                headerRow.HorizontalAlign = HorizontalAlign.Left;
                TableHeaderCell newHeaderCell = new TableHeaderCell();
                newHeaderCell.CssClass = "first-column";
                headerRow.Cells.Add(newHeaderCell);

                DataView dv = permissions.Tables[0].DefaultView;
                dv.Sort = "PermissionName ASC";

                // Generate header cells
                foreach (DataRowView drv in dv)
                {
                    string permissionName = drv.Row["PermissionName"].ToString();
                    if (permissionArray.Contains(permissionName.ToLowerCSafe()))
                    {
                        newHeaderCell          = new TableHeaderCell();
                        newHeaderCell.CssClass = "matrix-header";
                        newHeaderCell.Text     = HTMLHelper.HTMLEncode(drv.Row["PermissionDisplayName"].ToString());
                        newHeaderCell.ToolTip  = Convert.ToString(drv.Row["PermissionDescription"]);

                        headerRow.Cells.Add(newHeaderCell);
                    }
                }

                tblMatrix.Rows.AddAt(0, headerRow);

                // Render widget access permissions
                object[,] accessNames = new object[3, 2];
                //accessNames[0, 0] = GetString("security.allusers");
                //accessNames[0, 1] = SecurityAccessEnum.AllUsers;
                accessNames[0, 0] = GetString("security.authenticated");
                accessNames[0, 1] = SecurityAccessEnum.AuthenticatedUsers;
                accessNames[1, 0] = GetString("security.globaladmin");
                accessNames[1, 1] = SecurityAccessEnum.GlobalAdmin;
                accessNames[2, 0] = GetString("security.authorizedroles");
                accessNames[2, 1] = SecurityAccessEnum.AuthorizedRoles;

                TableRow newRow = null;

                for (int access = 0; access <= accessNames.GetUpperBound(0); access++)
                {
                    SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]);

                    // Generate cell holding access item name
                    newRow = new TableRow();
                    TableCell newCell = new TableCell();
                    newCell.CssClass = "matrix-header";
                    newCell.Text     = accessNames[access, 0].ToString();
                    newRow.Cells.Add(newCell);

                    // Render the permissions access items
                    int permissionIndex = 0;
                    for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++)
                    {
                        newCell          = new TableCell();
                        newCell.CssClass = "matrix-cell";

                        int accessEnum = Convert.ToInt32(accessNames[access, 1]);
                        // Check if the currently processed access is applied for permission
                        bool isAllowed = CheckPermissionAccess(accessEnum, permission, tblMatrix.Rows[0].Cells[permission + 1].Text);

                        // Disable column in roles grid if needed
                        if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed)
                        {
                            gridMatrix.DisableColumn(permissionIndex);
                        }

                        // Insert the radio button for the current permission
                        var radio = new CMSRadioButton
                        {
                            Checked = isAllowed,
                            Enabled = Enable,
                        };
                        radio.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, permission + ";" + accessEnum));
                        newCell.Controls.Add(radio);

                        newRow.Cells.Add(newCell);
                        permissionIndex++;
                    }

                    tblMatrix.Rows.Add(newRow);
                }

                // Get permission matrix for roles of the current site/group
                mNoRolesAvailable = !gridMatrix.HasData;
                if (!mNoRolesAvailable)
                {
                    lblRolesInfo.Visible = true;
                }
            }
        }
    }
    /// <summary>
    /// Generates the permission matrix for the cutrrent widget.
    /// </summary>
    private void CreateMatrix()
    {
        // Get widget resource info
        if ((ResWidget != null) && (WidgetInfo != null))
        {
            // Get permissions for the current widget resource
            DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(ResWidget.ResourceID);
            if (DataHelper.DataSourceIsEmpty(permissions))
            {
                lblInfo.Text = GetString("general.emptymatrix");
            }
            else
            {
                TableRow headerRow = new TableRow();
                headerRow.CssClass = "unigrid-head";
                headerRow.TableSection = TableRowSection.TableHeader;
                headerRow.HorizontalAlign = HorizontalAlign.Left;
                TableHeaderCell newHeaderCell = new TableHeaderCell();
                newHeaderCell.CssClass = "first-column";
                headerRow.Cells.Add(newHeaderCell);

                DataView dv = permissions.Tables[0].DefaultView;
                dv.Sort = "PermissionName ASC";

                // Generate header cells
                foreach (DataRowView drv in dv)
                {
                    string permissionName = drv.Row["PermissionName"].ToString();
                    if (permissionArray.Contains(permissionName.ToLowerCSafe()))
                    {
                        newHeaderCell = new TableHeaderCell();
                        newHeaderCell.CssClass = "matrix-header";
                        newHeaderCell.Text = HTMLHelper.HTMLEncode(drv.Row["PermissionDisplayName"].ToString());
                        newHeaderCell.ToolTip = Convert.ToString(drv.Row["PermissionDescription"]);

                        headerRow.Cells.Add(newHeaderCell);
                    }
                }

                tblMatrix.Rows.AddAt(0, headerRow);

                // Render widget access permissions
                object[,] accessNames = new object[3, 2];
                //accessNames[0, 0] = GetString("security.allusers");
                //accessNames[0, 1] = SecurityAccessEnum.AllUsers;
                accessNames[0, 0] = GetString("security.authenticated");
                accessNames[0, 1] = SecurityAccessEnum.AuthenticatedUsers;
                accessNames[1, 0] = GetString("security.globaladmin");
                accessNames[1, 1] = SecurityAccessEnum.GlobalAdmin;
                accessNames[2, 0] = GetString("security.authorizedroles");
                accessNames[2, 1] = SecurityAccessEnum.AuthorizedRoles;

                TableRow newRow = null;

                for (int access = 0; access <= accessNames.GetUpperBound(0); access++)
                {
                    SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]);

                    // Generate cell holding access item name
                    newRow = new TableRow();
                    TableCell newCell = new TableCell();
                    newCell.CssClass = "matrix-header";
                    newCell.Text = accessNames[access, 0].ToString();
                    newRow.Cells.Add(newCell);

                    // Render the permissions access items
                    int permissionIndex = 0;
                    for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++)
                    {
                        newCell = new TableCell();
                        newCell.CssClass = "matrix-cell";

                        int accessEnum = Convert.ToInt32(accessNames[access, 1]);
                        // Check if the currently processed access is applied for permission
                        bool isAllowed = CheckPermissionAccess(accessEnum, permission, tblMatrix.Rows[0].Cells[permission + 1].Text);

                        // Disable column in roles grid if needed
                        if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed)
                        {
                            gridMatrix.DisableColumn(permissionIndex);
                        }

                        // Insert the radio button for the current permission
                        var radio = new CMSRadioButton
                        {
                            Checked = isAllowed,
                            Enabled = Enable,
                        };
                        radio.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, permission + ";" + accessEnum));
                        newCell.Controls.Add(radio);

                        newRow.Cells.Add(newCell);
                        permissionIndex++;
                    }

                    tblMatrix.Rows.Add(newRow);
                }

                // Get permission matrix for roles of the current site/group
                mNoRolesAvailable = !gridMatrix.HasData;
                if (!mNoRolesAvailable)
                {
                    lblRolesInfo.Visible = true;
                }
            }
        }
    }
    /// <summary>
    /// On btnVote click event handler.
    /// </summary>
    protected void btnVote_OnClick(object sender, EventArgs e)
    {
        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            lblInfo.CssClass = "ErrorMessage";
            lblInfo.Text     = GetString("General.BannedIP");
            return;
        }

        if (pi != null)
        {
            // Indicates whether user voted or not
            bool voted = false;

            // Indicates wheter all forms of all open-ended answers can be saved
            bool       formsAreValid   = true;
            List <int> selectedAnswers = new List <int>();

            // Check if user has already voted
            if ((CheckVoted) && (PollInfoProvider.HasVoted(pi.PollID)))
            {
                errMessage = GetString("Polls.UserHasVoted");
                voted      = true;
            }
            else if (isOpened)
            {
                // Get poll answers
                DataSet ds = Answers;
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    DataRowCollection rows = ds.Tables[0].Rows;

                    CMSCheckBox    chkItem  = null;
                    CMSRadioButton radItem  = null;
                    bool           selected = false;
                    PollAnswerInfo pai      = null;
                    BizForm        bizItem  = null;

                    foreach (DataRow row in rows)
                    {
                        pai = new PollAnswerInfo(row);

                        if ((pai != null) && (pai.AnswerEnabled))
                        {
                            selected = false;

                            // Find specific controls and update pollanswerinfo if controls are checked
                            if (pi.PollAllowMultipleAnswers)
                            {
                                // Find checkbox
                                chkItem = (CMSCheckBox)pnlAnswer.FindControl("chk" + pai.AnswerID);

                                if (chkItem != null)
                                {
                                    selected = chkItem.Checked;
                                }
                            }
                            else
                            {
                                // Find radiobutton
                                radItem = (CMSRadioButton)pnlAnswer.FindControl("rad" + pai.AnswerID);

                                if (radItem != null)
                                {
                                    selected = radItem.Checked;
                                }
                            }

                            if ((selected) && (pai.AnswerCount < Int32.MaxValue))
                            {
                                bool canBeSaved = false;
                                bizItem = (BizForm)pnlAnswer.FindControl("frm" + pai.AnswerID);

                                if (bizItem == null)
                                {
                                    canBeSaved = true;
                                }
                                else if (bizItem != null)
                                {
                                    // Validate form data
                                    canBeSaved = bizItem.ValidateData();
                                }

                                if (canBeSaved)
                                {
                                    selectedAnswers.Add(pai.AnswerID);
                                }
                                else
                                {
                                    formsAreValid = false;
                                }
                            }
                        }
                    }

                    if (formsAreValid)
                    {
                        if (selectedAnswers.Count > 0)
                        {
                            foreach (int aid in selectedAnswers)
                            {
                                // Set the vote
                                PollAnswerInfoProvider.Vote(aid);
                                // Save the bizform data
                                bizItem = (BizForm)pnlAnswer.FindControl("frm" + aid);
                                if (bizItem != null)
                                {
                                    if (bizItem != null)
                                    {
                                        bizItem.SaveData(null, false);
                                    }
                                }
                            }
                            voted = true;
                        }
                        else
                        {
                            // Set error message if no answer selected
                            lblInfo.CssClass = "ErrorMessage";
                            lblInfo.Text     = GetString("Polls.DidNotVoted");
                        }
                    }

                    if (voted)
                    {
                        LogActivity(pi, selectedAnswers);
                    }

                    if ((CheckVoted) && (voted))
                    {
                        // Create cookie about user's voting
                        PollInfoProvider.SetVoted(pi.PollID);
                    }
                }
            }

            if (voted)
            {
                // Clear cache if it's used
                Answers = null;
                // Reload poll control
                ReloadData(true);

                if (OnAfterVoted != null)
                {
                    OnAfterVoted(this, EventArgs.Empty);
                }
            }
        }
    }
    /// <summary>
    /// Generates the permission matrix for the current library.
    /// </summary>
    private void CreateMatrix()
    {
        // Get library resource info
        if ((ResLibrary != null) && (LibraryInfo != null))
        {
            // Get permissions for the current library resource
            DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(ResLibrary.ResourceID);
            if (DataHelper.DataSourceIsEmpty(permissions))
            {
                lblInfo.ResourceString = "general.emptymatrix";
                lblInfo.Visible = true;
            }
            else
            {
                TableRow headerRow = new TableRow();
                headerRow.TableSection = TableRowSection.TableHeader;
                headerRow.CssClass = "unigrid-head";

                TableHeaderCell newHeaderCell = new TableHeaderCell();
                newHeaderCell.CssClass = "first-column";
                headerRow.Cells.Add(newHeaderCell);

                DataView dv = permissions.Tables[0].DefaultView;
                dv.Sort = "PermissionDisplayName ASC";

                // Generate header cells
                foreach (DataRowView drv in dv)
                {
                    string permissionName = drv.Row["PermissionName"].ToString();
                    if (permissionArray.Contains(permissionName.ToLowerCSafe()))
                    {
                        newHeaderCell = new TableHeaderCell();
                        newHeaderCell.CssClass = "matrix-header";
                        newHeaderCell.Text = HTMLHelper.HTMLEncode(drv.Row["PermissionDisplayName"].ToString());
                        newHeaderCell.ToolTip = Convert.ToString(drv.Row["PermissionDescription"]);

                        headerRow.Cells.Add(newHeaderCell);
                    }
                }

                tblMatrix.Rows.Add(headerRow);

                // Render library access permissions
                object[,] accessNames = new object[5, 2];
                accessNames[0, 0] = GetString("security.nobody");
                accessNames[0, 1] = SecurityAccessEnum.Nobody;
                accessNames[1, 0] = GetString("security.allusers");
                accessNames[1, 1] = SecurityAccessEnum.AllUsers;
                accessNames[2, 0] = GetString("security.authenticated");
                accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers;
                accessNames[3, 0] = GetString("security.groupmembers");
                accessNames[3, 1] = SecurityAccessEnum.GroupMembers;
                accessNames[4, 0] = GetString("security.authorizedroles");
                accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles;

                TableRow newRow;
                int rowIndex = 0;

                for (int access = 0; access <= accessNames.GetUpperBound(0); access++)
                {
                    SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]);
                    // If the security isn't displayed as part of group section
                    if (((currentAccess == SecurityAccessEnum.GroupAdmin) || (currentAccess == SecurityAccessEnum.GroupMembers)) && (!(LibraryInfo.LibraryGroupID > 0)))
                    {
                        // Do not render this access item
                    }
                    else
                    {
                        // Generate cell holding access item name
                        newRow = new TableRow();
                        TableCell newCell = new TableCell();
                        newCell.CssClass = "matrix-header";
                        newCell.Text = accessNames[access, 0].ToString();
                        newRow.Cells.Add(newCell);
                        rowIndex++;

                        // Render the permissions access items
                        int permissionIndex = 0;
                        for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++)
                        {
                            newCell = new TableCell();
                            int accessEnum = Convert.ToInt32(accessNames[access, 1]);
                            // Check if the currently processed access is applied for permission
                            bool isAllowed = CheckPermissionAccess(accessEnum, permission, tblMatrix.Rows[0].Cells[permission + 1].Text);

                            // Disable column in roles grid if needed
                            if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed)
                            {
                                gridMatrix.DisableColumn(permissionIndex);
                            }

                            // Insert the radio button for the current permission
                            var radio = new CMSRadioButton
                            {
                                Checked = isAllowed,
                                Enabled = Enable,
                            };
                            radio.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, permission + "|" + accessEnum));
                            newCell.Controls.Add(radio);

                            newRow.Cells.Add(newCell);
                            permissionIndex++;
                        }

                        // Add the access row to the table
                        tblMatrix.Rows.Add(newRow);
                    }
                }

                // Check if media library has some roles assigned
                headTitle.Visible = gridMatrix.HasData;

            }
        }
    }
    /// <summary>
    /// Generates the permission matrix for the current library.
    /// </summary>
    private void CreateMatrix()
    {
        // Get library resource info
        if ((ResLibrary != null) && (LibraryInfo != null))
        {
            // Get permissions for the current library resource
            DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(ResLibrary.ResourceID);
            if (DataHelper.DataSourceIsEmpty(permissions))
            {
                lblInfo.ResourceString = "general.emptymatrix";
                lblInfo.Visible        = true;
            }
            else
            {
                TableRow headerRow = new TableRow();
                headerRow.TableSection = TableRowSection.TableHeader;
                headerRow.CssClass     = "unigrid-head";

                TableHeaderCell newHeaderCell = new TableHeaderCell();
                newHeaderCell.CssClass = "first-column";
                headerRow.Cells.Add(newHeaderCell);

                DataView dv = permissions.Tables[0].DefaultView;
                dv.Sort = "PermissionDisplayName ASC";

                // Generate header cells
                foreach (DataRowView drv in dv)
                {
                    string permissionName = drv.Row["PermissionName"].ToString();
                    if (permissionArray.Contains(permissionName.ToLowerCSafe()))
                    {
                        newHeaderCell          = new TableHeaderCell();
                        newHeaderCell.CssClass = "matrix-header";
                        newHeaderCell.Text     = HTMLHelper.HTMLEncode(drv.Row["PermissionDisplayName"].ToString());
                        newHeaderCell.ToolTip  = Convert.ToString(drv.Row["PermissionDescription"]);

                        headerRow.Cells.Add(newHeaderCell);
                    }
                }

                tblMatrix.Rows.Add(headerRow);

                // Render library access permissions
                object[,] accessNames = new object[5, 2];
                accessNames[0, 0]     = GetString("security.nobody");
                accessNames[0, 1]     = SecurityAccessEnum.Nobody;
                accessNames[1, 0]     = GetString("security.allusers");
                accessNames[1, 1]     = SecurityAccessEnum.AllUsers;
                accessNames[2, 0]     = GetString("security.authenticated");
                accessNames[2, 1]     = SecurityAccessEnum.AuthenticatedUsers;
                accessNames[3, 0]     = GetString("security.groupmembers");
                accessNames[3, 1]     = SecurityAccessEnum.GroupMembers;
                accessNames[4, 0]     = GetString("security.authorizedroles");
                accessNames[4, 1]     = SecurityAccessEnum.AuthorizedRoles;

                TableRow newRow;
                int      rowIndex = 0;

                for (int access = 0; access <= accessNames.GetUpperBound(0); access++)
                {
                    SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]);
                    // If the security isn't displayed as part of group section
                    if (((currentAccess == SecurityAccessEnum.GroupAdmin) || (currentAccess == SecurityAccessEnum.GroupMembers)) && (!(LibraryInfo.LibraryGroupID > 0)))
                    {
                        // Do not render this access item
                    }
                    else
                    {
                        // Generate cell holding access item name
                        newRow = new TableRow();
                        TableCell newCell = new TableCell();
                        newCell.CssClass = "matrix-header";
                        newCell.Text     = accessNames[access, 0].ToString();
                        newRow.Cells.Add(newCell);
                        rowIndex++;

                        // Render the permissions access items
                        int permissionIndex = 0;
                        for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++)
                        {
                            newCell = new TableCell();
                            int accessEnum = Convert.ToInt32(accessNames[access, 1]);
                            // Check if the currently processed access is applied for permission
                            bool isAllowed = CheckPermissionAccess(accessEnum, permission, tblMatrix.Rows[0].Cells[permission + 1].Text);

                            // Disable column in roles grid if needed
                            if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed)
                            {
                                gridMatrix.DisableColumn(permissionIndex);
                            }

                            // Insert the radio button for the current permission
                            var radio = new CMSRadioButton
                            {
                                Checked = isAllowed,
                                Enabled = Enable,
                            };
                            radio.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, permission + "|" + accessEnum));
                            newCell.Controls.Add(radio);

                            newRow.Cells.Add(newCell);
                            permissionIndex++;
                        }

                        // Add the access row to the table
                        tblMatrix.Rows.Add(newRow);
                    }
                }

                // Check if media library has some roles assigned
                headTitle.Visible = gridMatrix.HasData;
            }
        }
    }