示例#1
0
    /// <summary>
    /// Checks modify permission for contact group.
    /// </summary>
    private void CheckModifyPermissions()
    {
        // Check modify permission
        if ((siteID > 0) && !(CheckPermissions("cms.contactmanagement", "ModifyContactGroups")))
        {
            CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ModifyContactGroups");
        }

        if ((siteID == 0) && !(CheckPermissions("cms.contactmanagement", "ModifyGlobalContactGroups")))
        {
            CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ModifyGlobalContactGroups");
        }
    }
示例#2
0
    /// <summary>
    /// Handles control action buttons.
    /// </summary>
    private void Control_ActionDelete(string actionName, object actionArgument)
    {
        if (!UserInfoProvider.IsAuthorizedPerResource(ModuleName.NEWSLETTER, "ManageSubscribers", SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser, false))
        {
            CMSPage.RedirectToAccessDenied("cms.newsletter", "managesubscribers");
        }

        string email = ValidationHelper.GetString(actionArgument, string.Empty);

        if (actionName == "remove" && !string.IsNullOrEmpty(email))
        {
            Service <IUnsubscriptionProvider> .Entry().RemoveUnsubscriptionsFromAllNewsletters(email, SiteContext.CurrentSiteID);
        }
    }
 /// <summary>
 /// Uni-grid button clicked.
 /// </summary>
 private void gridElem_OnAction(string actionName, object actionArgument)
 {
     if (actionName == "remove")
     {
         if (modifyAccountContact)
         {
             int relationId = ValidationHelper.GetInteger(actionArgument, 0);
             AccountContactInfoProvider.DeleteAccountContactInfo(relationId);
         }
         else
         {
             CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "Modify");
         }
     }
 }
示例#4
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void OnAction(string actionName, object actionArgument)
    {
        if (actionName == "delete")
        {
            try
            {
                int      userId  = Convert.ToInt32(actionArgument);
                UserInfo delUser = UserInfoProvider.GetUserInfo(userId);

                if (delUser != null)
                {
                    if (!delUser.CheckPermissions(PermissionsEnum.Delete, SiteContext.CurrentSiteName, CurrentUserObj))
                    {
                        CMSPage.RedirectToAccessDenied("CMS.Users", "Modify");
                    }

                    // Global administrator account could be deleted only by global administrator
                    if (delUser.IsGlobalAdministrator && !CurrentUserObj.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                    {
                        ((CMSPage)Control.Page).ShowError(ResHelper.GetString("Administration-User_List.ErrorNoGlobalAdmin"));
                        return;
                    }

                    // It is not possible to delete own user account
                    if (userId == CurrentUserObj.UserID)
                    {
                        ((CMSPage)Control.Page).ShowError(ResHelper.GetString("Administration-User_List.ErrorOwnAccount"));
                        return;
                    }

                    // It is not possible to delete default global administrator
                    if (userId == UserInfoProvider.AdministratorUser.UserID)
                    {
                        ((CMSPage)Control.Page).ShowError(ResHelper.GetString("Administration-User_List.ErrorDefaultUser"));
                        return;
                    }

                    SessionManager.RemoveUser(userId);
                    UserInfoProvider.DeleteUser(delUser.UserName);
                }
            }
            catch (Exception ex)
            {
                ((CMSPage)Control.Page).ShowError(ex.Message);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Keep current user
        var cu = MembershipContext.AuthenticatedUser;

        // Check permissions
        if ((MembershipContext.AuthenticatedUser == null) || !cu.IsAuthorizedPerResource("CMS.WebAnalytics", "Read"))
        {
            CMSPage.RedirectToAccessDenied("CMS.WebAnalytics", "Read");
        }

        // Check ui elements
        if (!cu.IsAuthorizedPerUIElement("CMS.WebAnalytics", "Dashboard"))
        {
            CMSPage.RedirectToUIElementAccessDenied("CMS.WebAnalytics", "Dashboard");
        }
    }
示例#6
0
    /// <summary>
    /// Verifies permissons to modify given BaseInfo and current user.
    /// Redirects to Information Page with "Object doesn't exist." message
    /// or Access denied page.
    /// </summary>
    /// <param name="info">Info object for which the permissions should be verified.</param>
    /// <returns></returns>
    private bool VerifyPermissionsAndObjectAvailability(BaseInfo info)
    {
        if (info == null)
        {
            CMSPage.RedirectToInformation("editedobject.notexists");

            return(false);
        }

        if (!info.CheckPermissions(PermissionsEnum.Modify, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
        {
            CMSPage.RedirectToAccessDenied(ModuleName.SOCIALMARKETING, "Modify");

            return(false);
        }

        return(true);
    }
示例#7
0
    /// <summary>
    /// Items changed event handler.
    /// </summary>
    protected void UniSelector_OnItemsSelected(object sender, EventArgs e)
    {
        if (mModifyAccountContact)
        {
            // Get new items from selector
            string newValues = ValidationHelper.GetString(accountSelector.Value, null);
            if (!String.IsNullOrEmpty(newValues))
            {
                string[] newItems = newValues.Split(new[]
                {
                    ';'
                }, StringSplitOptions.RemoveEmptyEntries);

                if (newItems != null)
                {
                    int previousStop = 0;
                    string where = FetchNextAccounts(ref previousStop, newItems, 1000);

                    while (!String.IsNullOrEmpty(where))
                    {
                        AccountContactInfoProvider.SetAccountsIntoContact(mContactInfo.ContactID, "AccountID IN (" + where + ")", ValidationHelper.GetInteger(hdnRoleID.Value, 0));

                        where = FetchNextAccounts(ref previousStop, newItems, 1000);
                    }
                }

                gridElem.ReloadData();
                pnlUpdate.Update();
                accountSelector.Value = null;
            }
        }
        // No permission modify
        else
        {
            if (SiteID > 0)
            {
                CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ModifyContacts");
            }
            else
            {
                CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ModifyGlobalContacts");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var cu = MembershipContext.AuthenticatedUser;

        // Check permissions
        if ((cu == null) || !cu.IsAuthorizedPerResource("CMS.OnlineMarketing", "Read"))
        {
            CMSPage.RedirectToAccessDenied("CMS.OnlineMarketing", "Read");
        }

        // Check UIProfile
        if (!cu.IsAuthorizedPerUIElement("CMS.OnlineMarketing", "OMDashBoard"))
        {
            CMSPage.RedirectToUIElementAccessDenied("CMS.OnlineMarketing", "OMDashBoard");
        }

        // Register script for unimenu button selection
        CMSDeskPage.AddMenuButtonSelectScript(this, "OMDashBoard", null, "menu");
    }
示例#9
0
    /// <summary>
    /// OnInit page event.
    /// </summary>
    public override void OnInit()
    {
        Control.OnExternalDataBound   += Control_OnExternalDataBound;
        Control.GridView.RowDataBound += GridView_RowDataBound;

        if (CommunityGroupID != 0)
        {
            // Prepare permissions for external data bound event
            isGroupAdministrator     = MembershipContext.AuthenticatedUser.IsGroupAdministrator(CommunityGroupID);
            hasGroupManagePermission = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.groups", "Manage");

            // Group project has special permission check - user has to have Read permission or be a group admin
            // The default permission check is suppressed in UIElement (using custom attribute)
            if (!isGroupAdministrator && !MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.groups", "Read"))
            {
                Control.StopProcessing = true;
                CMSPage.RedirectToAccessDenied("cms.groups", "Read");
            }
        }
    }
 /// <summary>
 /// Unigrid button clicked.
 /// </summary>
 protected void gridElem_OnAction(string actionName, object actionArgument)
 {
     if (actionName == "remove")
     {
         // User has permission modify
         if (mModifyAccountContact)
         {
             int relationId = ValidationHelper.GetInteger(actionArgument, 0);
             AccountContactInfo relation = AccountContactInfoProvider.GetAccountContactInfo(relationId);
             if (relation != null)
             {
                 // We need to invalidate the contact as we might have modified some of its relationships and data in the cache might not be valid
                 AccountContactInfoProvider.DeleteAccountContactInfo(relation);
             }
         }
         // User doesn't have sufficient permissions
         else
         {
             CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "Modify");
         }
     }
 }
示例#11
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'Read' permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "Read"))
        {
            CMSPage.RedirectToAccessDenied("cms.reporting", "Read");
        }

        if (Report != null)
        {
            brsItems.ReportID = Report.ReportID;
        }

        brsItems.ReportType       = ItemType;
        brsItems.Display          = false;
        brsItems.IsLiveSite       = IsLiveSite;
        brsItems.ShowItemSelector = true;

        // Enable page methods to get item name
        ScriptManager scriptManager = ScriptManager.GetCurrent(Page);

        scriptManager.EnablePageMethods = true;
    }
示例#12
0
    /// <summary>
    /// Returns WHERE condition
    /// </summary>
    private string GetWhereCondition()
    {
        if (siteID < 0)
        {
            return(new WhereCondition().NoResults().ToString());
        }

        var whereContactGroup                    = new WhereCondition().WhereEquals("ContactGroupMemberContactGroupID", cgi.ContactGroupID);
        var whereSiteIDNull                      = new WhereCondition().WhereNull("AccountSiteID");
        var whereSiteIDAndGlobalIDIsNull         = new WhereCondition(whereSiteIDNull).WhereNull("AccountGlobalAccountID");
        var whereSiteIDGreater0AndMergedIDIsNull = new WhereCondition().WhereGreaterThan("AccountSiteID", 0).WhereNull("AccountMergedWithAccountID");
        var whereMainOr = new WhereCondition(whereSiteIDAndGlobalIDIsNull).Or().Where(whereSiteIDGreater0AndMergedIDIsNull);

        var where = new WhereCondition(whereContactGroup).Where(whereMainOr);

        // Filter site objects
        if (siteID > 0)
        {
            if (!readSiteAccounts)
            {
                CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ReadAccounts");
                return(new WhereCondition().NoResults().ToString());
            }

            @where.Where(new WhereCondition().WhereEquals("AccountSiteID", siteID));
            accountSelector.SiteID = siteID;
            return(@where.ToString(true));
        }

        // Current group is global object
        // In CMS Desk display current site and global objects
        if (CurrentUser.IsGlobalAdministrator)
        {
            // No WHERE condition required = displaying all data
            // Set contact selector only
            accountSelector.SiteID = UniSelector.US_ALL_RECORDS;
        }
        else
        {
            var whereSiteIDEqualsCurrentID = new WhereCondition().WhereEquals("AccountSiteID", SiteContext.CurrentSiteID);
            if (readSiteAccounts && readGlobalAccounts)
            {
                @where.Where(new WhereCondition(whereSiteIDNull).Or().Where(whereSiteIDEqualsCurrentID));
                accountSelector.SiteID = UniSelector.US_GLOBAL_AND_SITE_RECORD;
            }
            else if (readGlobalAccounts)
            {
                @where.Where(whereSiteIDNull);
                accountSelector.SiteID = UniSelector.US_GLOBAL_RECORD;
            }
            else if (readSiteAccounts)
            {
                @where.Where(whereSiteIDEqualsCurrentID);
                accountSelector.SiteID = SiteContext.CurrentSiteID;
            }
            else
            {
                CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ReadGlobalAccounts|ReadAccounts");
                return(new WhereCondition().NoResults().ToString());
            }
        }

        return(@where.ToString(true));
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (mModifyAccountContact)
        {
            Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0);
            What   what   = (What)ValidationHelper.GetInteger(drpWhat.SelectedItem.Value, 0);

            string where = string.Empty;

            switch (what)
            {
            // All items
            case What.All:
                where = SqlHelper.AddWhereCondition(gridElem.WhereCondition, gridElem.WhereClause);
                where = string.Format("ContactID={0} AND AccountID IN (SELECT AccountID FROM View_OM_AccountContact_AccountJoined WHERE {1})", mContactInfo.ContactID, where);
                break;

            // Selected items
            case What.Selected:
                where = SqlHelper.GetWhereCondition <int>("AccountContactID", gridElem.SelectedItems, false);
                break;

            default:
                return;
            }

            switch (action)
            {
            // Action 'Remove'
            case Action.Remove:
                // Reset accounts' main contact IDs if the contact was set as primary or secondary contact
                AccountContactInfoProvider.ResetAccountMainContacts(0, mContactInfo.ContactID, where);
                // Delete the relations between contact and accounts
                AccountContactInfoProvider.DeleteAllAccountContacts(where);
                // Show result message
                if (what == What.Selected)
                {
                    ShowConfirmation(GetString("om.account.massaction.removed"));
                }
                else
                {
                    ShowConfirmation(GetString("om.account.massaction.removedall"));
                }
                break;

            // Action 'Select role'
            case Action.SelectRole:
                // Get selected role ID from hidden field
                int roleId = ValidationHelper.GetInteger(hdnValue.Value, -1);
                if (roleId >= 0 && mModifyAccountContact)
                {
                    AccountContactInfoProvider.UpdateContactRole(roleId, where);
                    ShowConfirmation(GetString("om.contact.massaction.roleassigned"));
                }
                break;

            default:
                return;
            }

            // Reload unigrid
            gridElem.ResetSelection();
            gridElem.ReloadData();
            pnlUpdate.Update();
        }
        // No permission modify
        else
        {
            CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "Modify");
        }
    }
示例#14
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        gridDocuments.StopProcessing = ctrlMassActions.StopProcessing = StopProcessing;
        if (StopProcessing)
        {
            return;
        }

        InitializeFilterForm();
        InitializeMassActionsControl();

        if (NodeID <= 0)
        {
            return;
        }

        checkPermissions = Tree.CheckDocumentUIPermissions(currentSiteName);

        if (Node != null)
        {
            if (currentUserInfo.IsAuthorizedPerDocument(Node, NodePermissionsEnum.ExploreTree) != AuthorizationResultEnum.Allowed)
            {
                CMSPage.RedirectToAccessDenied("CMS.Content", "exploretree");
            }

            aliasPath = Node.NodeAliasPath;
        }

        ScriptHelper.RegisterLoader(Page);
        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterJQuery(Page);

        // Prepare JavaScript for actions
        StringBuilder actionScript = new StringBuilder();

        actionScript.Append(
            @" function MoveNode(action, nodeId){
    document.getElementById('", hdnMoveId.ClientID, @"').value = action + ';' + nodeId ;
    ", Page.ClientScript.GetPostBackEventReference(this, "move"), @"  
}");

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "actionScript", ScriptHelper.GetScript(actionScript.ToString()));

        // Setup the grid
        gridDocuments.OrderBy                = OrderBy;
        gridDocuments.OnExternalDataBound   += gridDocuments_OnExternalDataBound;
        gridDocuments.OnDataReload          += gridDocuments_OnDataReload;
        gridDocuments.GridView.RowDataBound += GridView_RowDataBound;
        gridDocuments.GridView.RowCreated   += GridView_RowCreated;
        gridDocuments.ShowActionsMenu        = true;

        // Initialize columns
        string columns = @"DocumentGUID, DocumentName, NodeParentID, NodeLevel, NodeOrder, NodeName, NodeAlias, NodeHasChildren, 
                    ClassDisplayName, DocumentModifiedWhen, DocumentLastVersionNumber, DocumentIsArchived, DocumentCheckedOutByUserID,
                    DocumentPublishedVersionHistoryID, DocumentWorkflowStepID, DocumentCheckedOutVersionHistoryID, DocumentPublishFrom, NodeAliasPath, DocumentIsWaitingForTranslation";

        if (checkPermissions)
        {
            columns = SqlHelper.MergeColumns(columns, DocumentColumnLists.SECURITYCHECK_REQUIRED_COLUMNS);
        }

        columns = SqlHelper.MergeColumns(columns, DocumentColumnLists.GETPUBLISHED_REQUIRED_COLUMNS);

        gridDocuments.Columns = SqlHelper.MergeColumns(columns, AdditionalColumns);

        // Store the refresh node id. It will be used for refreshing the dialog after dialog actions are performed (move, delete...)
        StringBuilder refreshScripts = new StringBuilder();

        refreshScripts.Append(@"
function RefreshTree()
{
    if((parent != null) && (parent.RefreshTree != null))
    {
        ", (!RequiresDialog)
            ? ("parent.RefreshTree(" + NodeID + @"," + NodeID + ");")
            : ControlsHelper.GetPostBackEventReference(this, "refresh", false, false), @"
    }
}

function ClearSelection()
{ 
", gridDocuments.GetClearSelectionScript(), @"
}
function RefreshGrid()
{
    ClearSelection();
    RefreshTree();
", gridDocuments.GetReloadScript(), @"
}");
        // Register refresh scripts
        string refreshScript = ScriptHelper.GetScript(refreshScripts.ToString());

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "refreshListing", refreshScript);

        // Get all possible columns to retrieve
        gridDocuments.AllColumns = SqlHelper.JoinColumnList(ObjectTypeManager.GetColumnNames(PredefinedObjectType.NODE, PredefinedObjectType.DOCUMENTLOCALIZATION));
    }