Ejemplo n.º 1
0
    /// <summary>
    /// Gets and bulk updates polls. Called when the "Get and bulk update polls" button is pressed.
    /// Expects the CreatePoll method to be run first.
    /// </summary>
    private bool GetAndBulkUpdatePolls()
    {
        // Prepare the parameters
        string where = "PollCodeName LIKE N'MyNewPoll%'";

        // Get the data
        DataSet polls = PollInfoProvider.GetPolls(where, null);

        if (!DataHelper.DataSourceIsEmpty(polls))
        {
            // Loop through the individual items
            foreach (DataRow pollDr in polls.Tables[0].Rows)
            {
                // Create object from DataRow
                PollInfo modifyPoll = new PollInfo(pollDr);

                // Update the properties
                modifyPoll.PollDisplayName = modifyPoll.PollDisplayName.ToUpper();

                // Save the changes
                PollInfoProvider.SetPollInfo(modifyPoll);
            }

            return(true);
        }

        return(false);
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check if parent object exists
        if ((PollId > 0) && !IsLiveSite)
        {
            UIContext.EditedObject = PollInfoProvider.GetPollInfo(PollId);
        }

        ScriptHelper.RegisterDialogScript(Page);

        uniGrid.IsLiveSite            = IsLiveSite;
        uniGrid.OnAction             += uniGrid_OnAction;
        uniGrid.GridView.AllowSorting = false;
        uniGrid.WhereCondition        = "AnswerPollID=" + PollId;
        uniGrid.ZeroRowsText          = GetString("general.nodatafound");
        uniGrid.OnExternalDataBound  += UniGrid_OnExternalDataBound;
        uniGrid.OnBeforeDataReload   += UniGrid_OnBeforeDataReload;

        if (!AllowEdit)
        {
            uniGrid.ShowObjectMenu = false;
        }

        bizFormsAvailable = ModuleEntryManager.IsModuleLoaded(ModuleName.BIZFORM) && ResourceSiteInfoProvider.IsResourceOnSite(ModuleName.BIZFORM, SiteContext.CurrentSiteName);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Displays controls in dependence on properties.
    /// </summary>
    public override void ReloadData(bool forceReload)
    {
        base.ReloadData(forceReload);

        // Setup button
        imgNewPoll.ImageUrl       = GetImageUrl("Objects/Polls_Poll/add.png");
        imgNewPoll.AlternateText  = GetString("polls_new.newitemcaption");
        btnNewPoll.ResourceString = "Polls_List.NewItemCaption";

        // Setup breadcrumbs
        btnBreadCrumbs.ResourceString = "Polls_Edit.itemlistlink";

        // Setup panels
        pnlPollsHeaderLinks.Visible       = false;
        pnlPollsHeaderBreadCrumbs.Visible = false;
        pnlList.Visible    = false;
        pnlEdit.Visible    = false;
        pnlPollNew.Visible = false;

        // Display appropriate poll controls
        switch (SelectedControl)
        {
        case "new":
        {
            pnlPollsHeaderBreadCrumbs.Visible = true;
            pnlPollNew.Visible = true;
            PollNew.ReloadData();
            lblPoll.ResourceString = "polls_new.newitemcaption";
            break;
        }

        case "edit":
        {
            pnlPollsHeaderBreadCrumbs.Visible = true;
            pnlEdit.Visible = true;
            PollEdit.ReloadData(true);
            PollInfo pi = PollInfoProvider.GetPollInfo(this.ItemID);
            if (pi != null)
            {
                lblPoll.ResourceString = null;
                lblPoll.Text           = HTMLHelper.HTMLEncode(pi.PollDisplayName);
            }
            break;
        }

        case "list":
        default:
        {
            if (!dataLoaded || forceReload)
            {
                pnlPollsHeaderLinks.Visible = true;
                pnlList.Visible             = true;
                PollsList.GroupId           = GroupID;
                PollsList.ReloadData();
                dataLoaded = true;
            }
            break;
        }
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Reloads control with new data.
    /// </summary>
    public override void ReloadData()
    {
        this.ClearForm();
        pollObj = pollObj ?? PollInfoProvider.GetPollInfo(this.ItemID);

        if (pollObj == null)
        {
            return;
        }

        txtCodeName.Text    = pollObj.PollCodeName;
        txtDisplayName.Text = pollObj.PollDisplayName;
        txtTitle.Text       = pollObj.PollTitle;
        txtQuestion.Text    = pollObj.PollQuestion;

        if (pollObj.PollOpenFrom != DataHelper.DATETIME_NOT_SELECTED)
        {
            dtPickerOpenFrom.SelectedDateTime = pollObj.PollOpenFrom;
        }

        if (pollObj.PollOpenTo != DataHelper.DATETIME_NOT_SELECTED)
        {
            dtPickerOpenTo.SelectedDateTime = pollObj.PollOpenTo;
        }

        txtResponseMessage.Text         = pollObj.PollResponseMessage;
        chkAllowMultipleAnswers.Checked = pollObj.PollAllowMultipleAnswers;

        if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(this.SiteID))
        {
            plcOnline.Visible      = true;
            chkLogActivity.Checked = pollObj.PollLogActivity;
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Gets and bulk updates answers. Called when the "Get and bulk update answers" button is pressed.
    /// Expects the CreateAnswer method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateAnswers()
    {
        PollInfo updatePoll = PollInfoProvider.GetPollInfo("MyNewPoll", SiteContext.CurrentSiteID);

        if (updatePoll != null)
        {
            // Get the data
            DataSet answers = PollAnswerInfoProvider.GetAnswers(updatePoll.PollID);
            if (!DataHelper.DataSourceIsEmpty(answers))
            {
                // Loop through the individual items
                foreach (DataRow answerDr in answers.Tables[0].Rows)
                {
                    // Create object from DataRow
                    PollAnswerInfo modifyAnswer = new PollAnswerInfo(answerDr);

                    // Update the properties
                    modifyAnswer.AnswerText = modifyAnswer.AnswerText.ToUpper();

                    // Save the changes
                    PollAnswerInfoProvider.SetPollAnswerInfo(modifyAnswer);
                }

                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Gets and updates answer. Called when the "Get and update answer" button is pressed.
    /// Expects the CreateAnswer method to be run first.
    /// </summary>
    private bool GetAndUpdateAnswer()
    {
        // Get the answer
        PollInfo updatePoll = PollInfoProvider.GetPollInfo("MyNewPoll", SiteContext.CurrentSiteID);

        if (updatePoll != null)
        {
            DataSet answers = PollAnswerInfoProvider.GetAnswers(updatePoll.PollID, 1, null);

            if (!DataHelper.DataSourceIsEmpty(answers))
            {
                PollAnswerInfo updateAnswer = new PollAnswerInfo(answers.Tables[0].Rows[0]);

                // Update the properties
                updateAnswer.AnswerText = updateAnswer.AnswerText.ToLower();

                // Save the changes
                PollAnswerInfoProvider.SetPollAnswerInfo(updateAnswer);

                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get PollID and GroupID from querystring
        int pollId  = QueryHelper.GetInteger("pollid", 0);
        int groupId = QueryHelper.GetInteger("groupid", 0);

        PollInfo pi = PollInfoProvider.GetPollInfo(pollId);

        EditedObject = pi;

        if ((pi != null) && (pi.PollGroupID == groupId))
        {
            PollView.PollCodeName         = pi.PollCodeName;
            PollView.PollSiteID           = pi.PollSiteID;
            PollView.PollGroupID          = pi.PollGroupID;
            PollView.CountType            = CountTypeEnum.Percentage;
            PollView.ShowGraph            = true;
            PollView.ShowResultsAfterVote = true;
            // Check permissions during voting if user hasn't got 'Manage' permission
            PollView.CheckPermissions      = (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.groups", CMSAdminControl.PERMISSION_MANAGE));
            PollView.CheckVoted            = false;
            PollView.HideWhenNotAuthorized = false;
            PollView.CheckOpen             = false;
        }
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get PollID from querystring
        int pollId = QueryHelper.GetInteger("pollid", 0);

        // Get poll object
        PollInfo pi = PollInfoProvider.GetPollInfo(pollId);

        EditedObject = pi;

        // Check global and site read permmision
        CheckPollsReadPermission(pi.PollSiteID);

        if (pi != null)
        {
            // Check permissions during voting if user hasn't got 'Modify' permission
            var  user            = MembershipContext.AuthenticatedUser;
            bool checkPermission =
                (pi.PollSiteID > 0) && !user.IsAuthorizedPerResource("cms.polls", CMSAdminControl.PERMISSION_MODIFY) ||
                (pi.PollSiteID <= 0) && !user.IsAuthorizedPerResource("cms.polls", CMSAdminControl.PERMISSION_GLOBALMODIFY);

            pollElem.PollCodeName         = pi.PollCodeName;
            pollElem.PollSiteID           = pi.PollSiteID;
            pollElem.PollGroupID          = pi.PollGroupID;
            pollElem.CountType            = CountTypeEnum.Percentage;
            pollElem.ShowGraph            = true;
            pollElem.ShowResultsAfterVote = true;
            // Check permissions during voting if user hasn't got 'Modify' permission
            pollElem.CheckPermissions      = checkPermission;
            pollElem.CheckVoted            = false;
            pollElem.HideWhenNotAuthorized = false;
            pollElem.CheckOpen             = false;
            pollElem.IsLiveSite            = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get poll id from querystring
        pollId       = QueryHelper.GetInteger("pollId", 0);
        pi           = PollInfoProvider.GetPollInfo(pollId);
        EditedObject = pi;

        // Check global and site read permmision
        CheckPollsReadPermission(pi.PollSiteID);

        if (CheckPollsModifyPermission(pi.PollSiteID, false))
        {
            HeaderAction newItem = new HeaderAction();
            newItem.Text        = GetString("Polls_Answer_List.NewItemCaption");
            newItem.RedirectUrl = ResolveUrl("Polls_Answer_Edit.aspx?pollId=" + pollId);
            CurrentMaster.HeaderActions.AddAction(newItem);

            HeaderAction reset = new HeaderAction();
            reset.Text          = GetString("Polls_Answer_List.ResetButton");
            reset.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Polls_Answer_List.ResetConfirmation")) + ");";
            reset.CommandName   = "btnReset_Click";
            CurrentMaster.HeaderActions.AddAction(reset);
            CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

            AnswerList.AllowEdit = true;
        }

        AnswerList.OnEdit    += new EventHandler(AnswerList_OnEdit);
        AnswerList.PollId     = pollId;
        AnswerList.IsLiveSite = false;
        AnswerList.AllowEdit  = CheckPollsModifyPermission(pi.PollSiteID, false);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        poll = PollInfoProvider.GetPollInfo(ItemID);
        if ((ItemID > 0) && !IsLiveSite)
        {
            EditedObject = poll;
        }

        if (poll != null)
        {
            groupId = poll.PollGroupID;
        }

        // Roles control settings
        addRoles.PollID         = ItemID;
        addRoles.IsLiveSite     = IsLiveSite;
        addRoles.Changed       += addRoles_Changed;
        addRoles.GroupID        = groupId;
        addRoles.ShowSiteFilter = false;

        if (!RequestHelper.IsPostBack() && (poll != null) && !IsLiveSite)
        {
            ReloadData();
        }
        else
        {
            if (radOnlyRoles.Checked)
            {
                addRoles.CurrentSelector.Enabled = true;
                int    currentSiteID = 0;
                string roles         = string.Empty;

                // Get current site ID using CMSContext
                if (SiteContext.CurrentSite != null)
                {
                    currentSiteID = SiteContext.CurrentSiteID;
                }

                DataSet ds = PollInfoProvider.GetPollRoles(ItemID, null, null, -1, "CMS_Role.SiteID, CMS_Role.RoleID");
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        // Include roles associated to current site only
                        if ((ValidationHelper.GetInteger(row["SiteID"], 0) == currentSiteID))
                        {
                            // Insert an item to the listbox
                            roles += ValidationHelper.GetString(row["RoleID"], null) + ";";
                        }
                    }
                }

                addRoles.CurrentValues = roles;
            }
            else
            {
                addRoles.CurrentSelector.Enabled = false;
            }
        }
    }
    /// <summary>
    /// Header action handler.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Event args</param>
    private void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        switch (e.CommandName.ToLowerCSafe())
        {
        case "btnreset_click":     // Reset all answer counts
            // Check 'Manage' permission
            PollInfo pi      = PollInfoProvider.GetPollInfo(AnswerList.PollId);
            int      groupId = 0;

            if (pi != null)
            {
                groupId = pi.PollGroupID;
            }

            // Check permissions
            CheckPermissions(groupId, CMSAdminControl.PERMISSION_MANAGE);

            if (pollId > 0)
            {
                PollAnswerInfoProvider.ResetAnswers(pollId);
                AnswerList.ReloadData();
            }
            break;
        }
    }
    /// <summary>
    /// Button OK click handler.
    /// </summary>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (!CheckModifyPermissions())
        {
            return;
        }

        if (poll != null)
        {
            if (radAllUsers.Checked)
            {
                poll.PollAccess = SecurityAccessEnum.AllUsers;
            }
            else if (radOnlyUsers.Checked)
            {
                poll.PollAccess = SecurityAccessEnum.AuthenticatedUsers;
            }
            else if (radGroupMembers.Checked)
            {
                poll.PollAccess = SecurityAccessEnum.GroupMembers;
            }
            else if (radOnlyRoles.Checked)
            {
                poll.PollAccess = SecurityAccessEnum.AuthorizedRoles;
            }
            PollInfoProvider.SetPollInfo(poll);

            ShowChangesSaved();
        }
        else
        {
            throw new Exception("Poll with given ID not found!");
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void UniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            SelectedItemID = Convert.ToInt32(actionArgument);
            RaiseOnEdit();
        }
        else if (actionName == "delete")
        {
            PollInfo pi = PollInfoProvider.GetPollInfo(Convert.ToInt32(actionArgument));
            if (pi != null)
            {
                if ((pi.PollSiteID > 0) && !CheckPermissions("cms.polls", PERMISSION_MODIFY) ||
                    (pi.PollSiteID <= 0) && !CheckPermissions("cms.polls", PERMISSION_GLOBALMODIFY))
                {
                    return;
                }

                // Delete PollInfo object from database with it's dependences
                PollInfoProvider.DeletePollInfo(Convert.ToInt32(actionArgument));
            }

            ReloadData();
        }
    }
Ejemplo n.º 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get the poll ID
        int      pollId = QueryHelper.GetInteger("pollId", 0);
        PollInfo pi     = PollInfoProvider.GetPollInfo(pollId);

        // Check global and site read permmision
        this.CheckPollsReadPermission(pi.PollSiteID);

        if (!RequestHelper.IsPostBack())
        {
            InitalizeMenu(pi);
        }

        // Initialize the page title
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("Polls_Edit.itemlistlink");
        breadcrumbs[0, 1]     = "~/CMSModules/Polls/Tools/Polls_List.aspx?siteid=" + QueryHelper.GetInteger("siteid", 0);
        breadcrumbs[0, 2]     = "_parent";
        breadcrumbs[1, 0]     = (pi != null ? pi.PollDisplayName : String.Empty);
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";

        this.CurrentMaster.Title.TitleText     = GetString("Polls_Edit.headercaption");
        this.CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/Polls_Poll/object.png");
        this.CurrentMaster.Title.Breadcrumbs   = breadcrumbs;
        this.CurrentMaster.Title.HelpTopicName = "general_tab4";
        this.CurrentMaster.Title.HelpName      = "helpTopic";
    }
Ejemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get AnswerID and PollID from querystring
        int pollId = QueryHelper.GetInteger("pollid", 0);

        string currentPollAnswer = GetString("Polls_Answer_Edit.NewItemCaption");

        int answerId = QueryHelper.GetInteger("answerId", 0);

        if (QueryHelper.GetInteger("saved", 0) == 1)
        {
            AnswerEdit.Saved = true;
        }
        AnswerEdit.ItemID = answerId;
        AnswerEdit.PollId = pollId;

        if (answerId > 0)
        {
            // Modifying existing answer
            this.CurrentMaster.Title.HelpTopicName = "answer_edit";
            PollAnswerInfo pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(answerId);
            EditedObject = pollAnswerObj;
            if (pollAnswerObj != null)
            {
                currentPollAnswer = GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString();
                pollId            = pollAnswerObj.AnswerPollID;
            }
        }
        else
        {
            // Creating new answer - check if parent object exists
            EditedObject = PollInfoProvider.GetPollInfo(pollId);
            this.CurrentMaster.Title.HelpTopicName = "new_answer";
        }

        // Initializes page title control
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("Polls_Answer_Edit.ItemListLink");
        breadcrumbs[0, 1]     = "~/CMSModules/Polls/Tools/Polls_Answer_List.aspx?pollId=" + pollId;
        breadcrumbs[0, 2]     = "";
        breadcrumbs[1, 0]     = currentPollAnswer;
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";
        this.CurrentMaster.Title.Breadcrumbs = breadcrumbs;

        // New item link
        string[,] actions = new string[1, 6];
        actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1]     = GetString("Polls_Answer_List.NewItemCaption");
        actions[0, 2]     = null;
        actions[0, 3]     = ResolveUrl("Polls_Answer_Edit.aspx?pollId=" + pollId.ToString());
        actions[0, 4]     = null;
        actions[0, 5]     = GetImageUrl("CMSModules/CMS_Polls/addanswer.png");
        this.CurrentMaster.HeaderActions.Actions = actions;

        AnswerEdit.OnSaved   += new EventHandler(AnswerEdit_OnSaved);
        AnswerEdit.IsLiveSite = false;
    }
Ejemplo n.º 16
0
    /// <summary>
    /// Deletes poll. Called when the "Delete poll" button is pressed.
    /// Expects the CreatePoll method to be run first.
    /// </summary>
    private bool DeletePoll()
    {
        // Get the poll
        PollInfo deletePoll = PollInfoProvider.GetPollInfo("MyNewPoll", SiteContext.CurrentSiteID);

        // Delete the poll
        PollInfoProvider.DeletePollInfo(deletePoll);

        return(deletePoll != null);
    }
Ejemplo n.º 17
0
    /// <summary>
    /// Checks modify permission. Returns false if checking failed.
    /// </summary>
    private bool CheckModifyPermission()
    {
        PollInfo pi = PollInfoProvider.GetPollInfo(this.PollId);

        if (pi != null)
        {
            return((pi.PollSiteID > 0) && CheckPermissions("cms.polls", CMSAdminControl.PERMISSION_MODIFY) ||
                   (pi.PollSiteID <= 0) && CheckPermissions("cms.polls", CMSAdminControl.PERMISSION_GLOBALMODIFY));
        }
        return(false);
    }
    /// <summary>
    /// Reloads form data.
    /// </summary>
    public override void ReloadData()
    {
        ClearForm();

        if (poll == null)
        {
            // Get poll object and set group ID
            poll = PollInfoProvider.GetPollInfo(ItemID);
        }

        if (poll != null)
        {
            groupId = poll.PollGroupID;
            // Reload role list
            ReloadRolesList();

            switch (poll.PollAccess)
            {
            // If access is enabled for all users
            case SecurityAccessEnum.AllUsers:
                UncheckAllRadio();
                radAllUsers.Checked = true;
                DisableRoleSelector();
                break;

            // If access is enabled for authenticated users only
            case SecurityAccessEnum.AuthenticatedUsers:
                UncheckAllRadio();
                radOnlyUsers.Checked = true;
                DisableRoleSelector();
                break;

            // If access is enabled for group members only
            case SecurityAccessEnum.GroupMembers:
                UncheckAllRadio();
                radGroupMembers.Checked = true;
                DisableRoleSelector();
                break;

            // Access is enabled for users in authorized roles only
            case SecurityAccessEnum.AuthorizedRoles:
                UncheckAllRadio();
                radOnlyRoles.Checked  = true;
                btnRemoveRole.Enabled = true;
                lstRoles.Enabled      = true;
                break;
            }
        }
        else
        {
            DisableRoleSelector();
        }
    }
Ejemplo n.º 19
0
    /// <summary>
    /// Returns string with poll sites.
    /// </summary>
    private string GetPollSites()
    {
        //DataSet ds = PollSiteInfoProvider.GetPollSites("SiteID", "PollID = " + pollId, null, 0, null);
        DataSet ds = PollInfoProvider.GetPollSites(pollId, null, null, -1, "CMS_Site.SiteID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            return(TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "SiteID")));
        }

        return(String.Empty);
    }
Ejemplo n.º 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get AnswerID and PollID from querystring
        int pollId = QueryHelper.GetInteger("pollid", 0);

        string currentPollAnswer = GetString("Polls_Answer_Edit.NewItemCaption");

        int answerId = QueryHelper.GetInteger("answerId", 0);

        if (QueryHelper.GetInteger("saved", 0) == 1)
        {
            AnswerEdit.Saved = true;
        }
        AnswerEdit.ItemID = answerId;
        AnswerEdit.PollId = pollId;

        if (answerId > 0)
        {
            // Modifying existing answer
            PollAnswerInfo pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(answerId);
            EditedObject = pollAnswerObj;

            if (pollAnswerObj != null)
            {
                currentPollAnswer = GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString();
                pollId            = pollAnswerObj.AnswerPollID;
            }
        }
        else
        {
            // Creating new answer - check if parent object exists
            EditedObject = PollInfoProvider.GetPollInfo(pollId);
        }

        var poll = EditedObject as PollInfo ?? PollInfoProvider.GetPollInfo(pollId);

        CheckPollsReadPermission(poll.PollSiteID);

        // Create breadcrumbs
        CreateBreadCrumbs(pollId, currentPollAnswer);

        HeaderAction add = new HeaderAction
        {
            Text        = GetString("Polls_Answer_List.NewItemCaption"),
            RedirectUrl = ResolveUrl("Polls_Answer_Edit.aspx?pollId=" + pollId),
        };

        CurrentMaster.HeaderActions.AddAction(add);

        AnswerEdit.OnSaved   += AnswerEdit_OnSaved;
        AnswerEdit.IsLiveSite = false;
    }
    private void AnswerEdit_OnCheckPermissions(string permissionType, CMSAdminControl sender)
    {
        // Check 'Manage' permission
        PollInfo pi      = PollInfoProvider.GetPollInfo(AnswerEdit.PollId);
        int      groupId = 0;

        if (pi != null)
        {
            groupId = pi.PollGroupID;
        }

        // Check permissions
        CheckPermissions(groupId, CMSAdminControl.PERMISSION_MANAGE);
    }
Ejemplo n.º 22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblAvialable.Text = GetString("Poll_Sites.Available");

        // Get poll ID from querystring
        pollId = QueryHelper.GetInteger("pollid", 0);

        PollInfo pi = PollInfoProvider.GetPollInfo(pollId);

        EditedObject = pi;

        // Check global and site read permmision
        this.CheckPollsReadPermission(pi.PollSiteID);

        // Disable page for site polls
        if (pi.PollSiteID > 0)
        {
            EditedObject = pi;
            return;
        }

        plcC.Visible = true;

        if (pollId > 0)
        {
            // Get the active sites
            currentValues = GetPollSites();

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

        usSites.OnSelectionChanged += usSites_OnSelectionChanged;

        // Non global admin users will see only sites where they are members
        if (!CMSContext.CurrentUser.UserSiteManagerAdmin)
        {
            // For global admin without access to site manager show only polls with site relationship
            if (CMSContext.CurrentUser.UserIsGlobalAdministrator)
            {
                usSites.WhereCondition = SqlHelperClass.AddWhereCondition(usSites.WhereCondition, "SiteID IN (SELECT SiteID FROM CMS_UserSite");
            }
            else
            {
                usSites.WhereCondition = SqlHelperClass.AddWhereCondition(usSites.WhereCondition, "SiteID IN (SELECT SiteID FROM CMS_UserSite WHERE UserID = " + CMSContext.CurrentUser.UserID + ")");
            }
        }
    }
Ejemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int      pollid = QueryHelper.GetInteger("pollid", 0);
        PollInfo pi     = PollInfoProvider.GetPollInfo(pollid);

        EditedObject = pi;

        // Check global and site read permmision
        this.CheckPollsReadPermission(pi.PollSiteID);

        PollSecurity.ItemID              = pollid;
        PollSecurity.IsLiveSite          = false;
        PollSecurity.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(PollSecurity_OnCheckPermissions);
    }
    /// <summary>
    /// Removes role from the list of authorized roles.
    /// </summary>
    protected void btnRemoveRole_Click(object sender, EventArgs e)
    {
        if (!CheckModifyPermissions())
        {
            return;
        }

        foreach (ListItem item in lstRoles.GetSelectedItems())
        {
            int roleId = ValidationHelper.GetInteger(item.Value, 0);
            PollInfoProvider.RemoveRoleFromPoll(roleId, ItemID);
        }
        // Reload listbox with roles
        ReloadRolesList();
    }
Ejemplo n.º 25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string pollDisplayName = "";

        // Get GroupID
        int groupId = QueryHelper.GetInteger("groupid", 0);

        // Get the pollID
        pollId = QueryHelper.GetInteger("pollid", 0);
        PollInfo pi = PollInfoProvider.GetPollInfo(pollId);

        if (pi != null)
        {
            pollDisplayName = pi.PollDisplayName;
        }

        // Pagetitle breadcrumbs
        string[,] pageTitleTabs = new string[2, 3];
        pageTitleTabs[0, 0]     = GetString("group.polls.title");
        pageTitleTabs[0, 1]     = "~/CMSModules/Groups/Tools/Polls/Polls_List.aspx?groupId=" + groupId;
        pageTitleTabs[0, 2]     = "_parent";
        pageTitleTabs[1, 0]     = pollDisplayName;
        pageTitleTabs[1, 1]     = "";
        pageTitleTabs[1, 2]     = "";

        this.CurrentMaster.Title.Breadcrumbs = pageTitleTabs;

        // Tabs
        string[,] tabs = new string[4, 4];
        tabs[0, 0]     = GetString("General.General");
        tabs[0, 1]     = "SetHelpTopic('helpTopic', 'general_tab4');";
        tabs[0, 2]     = "Polls_Edit_General.aspx?pollID=" + pollId + "&groupId=" + groupId;
        tabs[1, 0]     = GetString("group.polls.answers");
        tabs[1, 1]     = "SetHelpTopic('helpTopic', 'answer_list');";
        tabs[1, 2]     = "Polls_Edit_Answer_List.aspx?pollID=" + pollId + "&groupId=" + groupId;
        tabs[2, 0]     = GetString("general.security");
        tabs[2, 1]     = "SetHelpTopic('helpTopic', 'security3');";
        tabs[2, 2]     = "Polls_Edit_Security.aspx?pollID=" + pollId + "&groupId=" + groupId;
        tabs[3, 0]     = GetString("general.view");
        tabs[3, 1]     = "SetHelpTopic('helpTopic', 'view');";
        tabs[3, 2]     = "Polls_Edit_View.aspx?pollid=" + pollId + "&groupID=" + groupId;

        this.CurrentMaster.Tabs.Tabs      = tabs;
        this.CurrentMaster.Tabs.UrlTarget = "content";

        this.CurrentMaster.Title.HelpTopicName = "general_tab4";
        this.CurrentMaster.Title.HelpName      = "helpTopic";
    }
    private void PollSecurity_OnCheckPermissions(string permissionType, CMSAdminControl sender)
    {
        PollInfo pi      = PollInfoProvider.GetPollInfo(PollSecurity.ItemID);
        int      groupId = 0;

        if (pi != null)
        {
            groupId = pi.PollGroupID;
        }

        // Check permissions
        if (!CMSContext.CurrentUser.IsGroupAdministrator(groupId) || !CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Groups", CMSAdminControl.PERMISSION_MANAGE))
        {
            sender.StopProcessing = true;
        }
    }
Ejemplo n.º 27
0
    /// <summary>
    /// Initializes breadcrumbs items.
    /// </summary>
    private void InitializeBreadcrumbs()
    {
        ucBreadcrumbs.Items.Clear();

        ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem {
            Text          = GetString("Polls_Edit.itemlistlink"),
            OnClientClick = ControlsHelper.GetPostBackEventReference(lnkBackHidden) + "; return false;"
        });

        PollInfo pi = PollInfoProvider.GetPollInfo(this.ItemID);

        ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
        {
            Text = (pi == null) ? GetString("polls_new.newitemcaption") : pi.PollDisplayName,
        });
    }
Ejemplo n.º 28
0
    private void PollSecurity_OnCheckPermissions(string permissionType, CMSAdminControl sender)
    {
        PollInfo pi      = PollInfoProvider.GetPollInfo(PollSecurity.ItemID);
        int      groupId = 0;

        if (pi != null)
        {
            groupId = pi.PollGroupID;
        }

        // Check permissions
        if (!MembershipContext.AuthenticatedUser.IsGroupAdministrator(groupId))
        {
            sender.StopProcessing = true;
        }
    }
Ejemplo n.º 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check if parent object exists
        if ((PollId > 0) && !IsLiveSite)
        {
            CMSPage.EditedObject = PollInfoProvider.GetPollInfo(PollId);
        }

        uniGrid.IsLiveSite            = this.IsLiveSite;
        uniGrid.OnAction             += new OnActionEventHandler(uniGrid_OnAction);
        uniGrid.GridView.AllowSorting = false;
        uniGrid.WhereCondition        = "AnswerPollID=" + this.PollId;
        uniGrid.Columns              = "AnswerID, AnswerText, AnswerCount, AnswerEnabled";
        uniGrid.ZeroRowsText         = GetString("general.nodatafound");
        uniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound);
    }
Ejemplo n.º 30
0
    /// <summary>
    /// Removes poll from site. Called when the "Remove poll from site" button is pressed.
    /// Expects the AddPollToSite method to be run first.
    /// </summary>
    private bool RemovePollFromSite()
    {
        int siteId = SiteContext.CurrentSiteID;

        // Get the poll
        PollInfo removePoll = PollInfoProvider.GetPollInfo("MyNewPoll", siteId);

        if (removePoll != null)
        {
            // Remove poll from site
            PollSiteInfoProvider.RemovePollFromSite(removePoll.PollID, siteId);

            return(true);
        }

        return(false);
    }