Ejemplo n.º 1
0
        /// <summary>
        /// Update Approval Status for Membership User
        /// </summary>
        /// <param name="user"></param>
        /// <param name="callback">True/False</param>
        public void UpdateApprovalForUser(MembershipUserInfo user, Action <bool?> callback)
        {
            string methodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);

            ServiceLog.LogServiceCall(LoggerFacade, methodNamespace, DateTime.Now.ToUniversalTime(), SessionManager.SESSION != null ? SessionManager.SESSION.UserName : "******");

            LoginDefinitions.LoginOperationsClient client = new LoginDefinitions.LoginOperationsClient();
            client.Endpoint.Behaviors.Add(new CookieBehavior());
            client.UpdateApprovalForUserAsync(user, callback);
            client.UpdateApprovalForUserCompleted += (se, e) =>
            {
                if (e.Error == null)
                {
                    if (callback != null)
                    {
                        callback(e.Result);
                    }
                }
                else if (e.Error is FaultException <GreenField.ServiceCaller.LoginDefinitions.ServiceFault> )
                {
                    FaultException <GreenField.ServiceCaller.LoginDefinitions.ServiceFault> fault
                        = e.Error as FaultException <GreenField.ServiceCaller.LoginDefinitions.ServiceFault>;
                    Prompt.ShowDialog(fault.Reason.ToString(), fault.Detail.Description, MessageBoxButton.OK);
                    if (callback != null)
                    {
                        callback(null);
                    }
                }
                else
                {
                    Prompt.ShowDialog(e.Error.Message, e.Error.GetType().ToString(), MessageBoxButton.OK);
                    if (callback != null)
                    {
                        callback(null);
                    }
                }
                ServiceLog.LogServiceCallback(LoggerFacade, methodNamespace, DateTime.Now.ToUniversalTime()
                                              , SessionManager.SESSION != null ? SessionManager.SESSION.UserName : "******");
            };
        }
Ejemplo n.º 2
0
 public bool?UpdateApprovalForUser(MembershipUserInfo membershipUserInfo)
 {
     try
     {
         MembershipUser membershipUser = Membership.GetUser(membershipUserInfo.UserName, membershipUserInfo.IsOnline);
         membershipUser.IsApproved = membershipUserInfo.IsApproved;
         if (membershipUser != null)
         {
             Membership.UpdateUser(membershipUser);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        membershipID = QueryHelper.GetInteger("membershipID", 0);
        MembershipInfo mi = MembershipInfoProvider.GetMembershipInfo(membershipID);

        EditedObject = mi;

        // Test permissions
        CheckMembershipPermissions(mi);

        usUsers.AdditionalColumns       = "UserID,ValidTo";
        usUsers.GridName                = "~/CMSModules/Membership/Pages/Users/UsersValidTo.xml";
        usUsers.DynamicColumnName       = false;
        usUsers.SelectItemPageUrl       = "~/CMSModules/Membership/Pages/Users/User_Edit_Add_Item_Dialog.aspx";
        usUsers.AdditionalUrlParameters = "&UseSendNotification=1";
        usUsers.WhereCondition          = (mi.MembershipSiteID > 0) ? $"UserID IN (SELECT UserID FROM CMS_UserSite WHERE SiteID={mi.MembershipSiteID})" : String.Empty;
        usUsers.ListingWhereCondition   = "MembershipID =" + membershipID;
        usUsers.ReturnColumnName        = "UserID";
        usUsers.DialogWindowHeight      = 790;

        // Load data in administration
        currentValues = GetMembershipUsers();
        if (!RequestHelper.IsPostBack())
        {
            usUsers.Value = currentValues;
        }


        string script = "function setNewDateTime(date) {$cmsj('#" + hdnDate.ClientID + "').val(date);}";

        script += "function setNewSendNotification(sendNotification) {$cmsj('#" + hdnSendNotification.ClientID + "').val(sendNotification);}";
        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "key", ScriptHelper.GetScript(script));

        usUsers.OnSelectionChanged    += UniSelector_OnSelectionChanged;
        usUsers.OnAdditionalDataBound += usUsers_OnAdditionalDataBound;

        // Manage single item valid to change by calendar
        string eventTarget   = Request[postEventSourceID];
        string eventArgument = Request[postEventArgumentID];

        if (eventTarget == ucCalendar.DateTimeTextBox.UniqueID)
        {
            // Check "modify" permission
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Membership", "ManageUserMembership"))
            {
                RedirectToAccessDenied("CMS.Membership", "Manage user membership");
            }

            int id = ValidationHelper.GetInteger(hdnDate.Value, 0);

            if (id != 0)
            {
                DateTime           dt  = ValidationHelper.GetDateTime(eventArgument, DateTimeHelper.ZERO_TIME);
                MembershipUserInfo mui = MembershipUserInfoProvider.GetMembershipUserInfo(mi.MembershipID, id);
                if (mui != null)
                {
                    mui.ValidTo = dt;
                    MembershipUserInfoProvider.SetMembershipUserInfo(mui);

                    // Invalidate changes
                    UserInfoProvider.InvalidateUser(mui.UserID);

                    ShowChangesSaved();
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var user = MembershipContext.AuthenticatedUser;

        // Check UI profile for membership
        if (!user.IsAuthorizedPerUIElement("CMS.Users", "CmsDesk.Membership"))
        {
            RedirectToUIElementAccessDenied("CMS.Users", "CmsDesk.Membership");
        }

        // Check "read" permission
        if (!user.IsAuthorizedPerResource("CMS.Membership", "Read"))
        {
            RedirectToAccessDenied("CMS.Membership", "Read");
        }

        ScriptHelper.RegisterJQuery(Page);
        ui = UserInfoProvider.GetUserInfo(UserID);
        CheckUserAvaibleOnSite(ui);
        EditedObject = ui;

        if (!CheckGlobalAdminEdit(ui))
        {
            plcTable.Visible = false;
            ShowError(GetString("Administration-User_List.ErrorGlobalAdmin"));
            return;
        }

        if ((SiteID > 0) && !MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
        {
            CurrentMaster.DisplaySiteSelectorPanel = false;
        }
        else
        {
            CurrentMaster.DisplaySiteSelectorPanel = true;
        }

        var data = MembershipUserInfoProvider.GetMembershipUsers().Where("UserID = " + UserID);

        if (data.Any())
        {
            currentValues = TextHelper.Join(";", DataHelper.GetStringValues(data.Tables[0], "MembershipID"));
        }

        if (!RequestHelper.IsPostBack())
        {
            // Set values
            usMemberships.Value = currentValues;
        }

        // Init uni selector
        usMemberships.SelectItemPageUrl     = "~/CMSModules/Membership/Pages/Users/User_Edit_Add_Item_Dialog.aspx";
        usMemberships.ListingWhereCondition = "UserID=" + UserID;
        usMemberships.ReturnColumnName      = "MembershipID";
        usMemberships.DynamicColumnName     = false;
        usMemberships.GridName = "User_Membership_List.xml";
        usMemberships.OnAdditionalDataBound += usMemberships_OnAdditionalDataBound;
        usMemberships.OnSelectionChanged    += usMemberships_OnSelectionChanged;
        usMemberships.AdditionalColumns      = "ValidTo";
        usMemberships.DialogWindowHeight     = 760;

        // Init
        int siteID = SiteID;

        if (CurrentMaster.DisplaySiteSelectorPanel)
        {
            // Set site selector
            siteSelector.DropDownSingleSelect.AutoPostBack = true;
            siteSelector.AllowAll    = false;
            siteSelector.AllowEmpty  = false;
            siteSelector.AllowGlobal = true;
            // Only sites assigned to user
            siteSelector.UserId           = UserID;
            siteSelector.OnlyRunningSites = false;
            siteSelector.UniSelector.OnSelectionChanged += new EventHandler(UniSelector_OnSelectionChanged);

            if (!RequestHelper.IsPostBack())
            {
                siteID = SiteContext.CurrentSiteID;

                // If user is member of current site
                if (UserSiteInfoProvider.GetUserSiteInfo(UserID, siteID) != null)
                {
                    // Force uniselector to preselect current site
                    siteSelector.Value = siteID;
                }
            }

            siteID = siteSelector.SiteID;
        }

        string siteWhere = (siteID <= 0) ? "MembershipSiteID IS NULL" : "MembershipSiteID =" + siteID;

        usMemberships.ListingWhereCondition = SqlHelper.AddWhereCondition(usMemberships.ListingWhereCondition, siteWhere);
        usMemberships.WhereCondition        = SqlHelper.AddWhereCondition(usMemberships.WhereCondition, siteWhere);

        string script = "function setNewDateTime(date) {$cmsj('#" + hdnDate.ClientID + "').val(date);}";

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "NewDateUniSelectorScript", ScriptHelper.GetScript(script));

        // Manage single item valid to change by calendar
        string eventTarget   = Request[Page.postEventSourceID];
        string eventArgument = Request[Page.postEventArgumentID];

        if (eventTarget == ucCalendar.DateTimeTextBox.UniqueID)
        {
            // Check "modify" permission
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Membership", "ManageUserMembership"))
            {
                RedirectToAccessDenied("CMS.Membership", "Manage user membership");
            }

            int id = ValidationHelper.GetInteger(hdnDate.Value, 0);

            if (id != 0)
            {
                DateTime           dt = ValidationHelper.GetDateTime(eventArgument, DateTimeHelper.ZERO_TIME);
                MembershipUserInfo mi = MembershipUserInfoProvider.GetMembershipUserInfo(id, UserID);
                if (mi != null)
                {
                    mi.ValidTo = dt;
                    MembershipUserInfoProvider.SetMembershipUserInfo(mi);

                    // Invalidate changes
                    if (ui != null)
                    {
                        ui.Generalized.Invalidate(false);
                    }

                    ShowChangesSaved();
                }
            }
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentUserInfo user = CMSContext.CurrentUser;

        // Check UI profile for membership
        if (!user.IsAuthorizedPerUIElement("CMS.Administration", "Membership"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Administration", "Membership");
        }

        // Check "read" permission
        if (!user.IsAuthorizedPerResource("CMS.Membership", "Read"))
        {
            RedirectToAccessDenied("CMS.Membership", "Read");
        }

        ScriptHelper.RegisterJQuery(Page);
        ui = UserInfoProvider.GetUserInfo(UserID);
        CheckUserAvaibleOnSite(ui);
        EditedObject = ui;

        if (!CheckGlobalAdminEdit(ui))
        {
            plcTable.Visible          = false;
            lblErrorDeskAdmin.Text    = GetString("Administration-User_List.ErrorGlobalAdmin");
            lblErrorDeskAdmin.Visible = true;
            return;
        }

        DataSet ds = MembershipUserInfoProvider.GetMembershipUsers("UserID = " + UserID, String.Empty);

        if ((SiteID > 0) && !CMSContext.CurrentUser.IsGlobalAdministrator)
        {
            this.CurrentMaster.DisplaySiteSelectorPanel = false;
        }
        else
        {
            this.CurrentMaster.DisplaySiteSelectorPanel = true;
        }

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            currentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "MembershipID"));
        }

        if (!RequestHelper.IsPostBack())
        {
            // Set values
            usMemberships.Value = currentValues;
        }

        // Init uni selector
        usMemberships.SelectItemPageUrl     = "~/CMSModules/Membership/Pages/Users/User_Edit_Add_Item_Dialog.aspx";
        usMemberships.ListingWhereCondition = "UserID=" + UserID;
        usMemberships.ReturnColumnName      = "MembershipID";
        usMemberships.DynamicColumnName     = false;
        usMemberships.GridName = "User_Membership_List.xml";
        usMemberships.OnAdditionalDataBound += new CMSAdminControls_UI_UniSelector_UniSelector.AdditionalDataBoundEventHandler(usMemberships_OnAdditionalDataBound);
        usMemberships.OnSelectionChanged    += new EventHandler(usMemberships_OnSelectionChanged);
        usMemberships.AdditionalColumns      = "ValidTo";

        // Init
        int siteID = SiteID;

        if (this.CurrentMaster.DisplaySiteSelectorPanel)
        {
            // Set site selector
            siteSelector.DropDownSingleSelect.AutoPostBack = true;
            siteSelector.AllowAll    = false;
            siteSelector.AllowEmpty  = false;
            siteSelector.AllowGlobal = true;
            // Only sites assigned to user
            siteSelector.UserId           = UserID;
            siteSelector.OnlyRunningSites = false;
            siteSelector.UniSelector.OnSelectionChanged += new EventHandler(UniSelector_OnSelectionChanged);

            if (!RequestHelper.IsPostBack())
            {
                siteID = CMSContext.CurrentSiteID;

                // If user is member of current site
                if (UserSiteInfoProvider.GetUserSiteInfo(UserID, siteID) != null)
                {
                    // Force uniselector to preselect current site
                    siteSelector.Value = siteID;
                }
            }

            siteID = siteSelector.SiteID;
        }

        if (!String.IsNullOrEmpty(currentValues))
        {
            usMemberships.WhereCondition = "MembershipID NOT IN (" + currentValues.Replace(';', ',') + ")";
        }

        string siteWhere = (siteID <= 0) ? "MembershipSiteID IS NULL" : "MembershipSiteID =" + siteID;

        usMemberships.ListingWhereCondition = SqlHelperClass.AddWhereCondition(usMemberships.ListingWhereCondition, siteWhere);
        usMemberships.WhereCondition        = SqlHelperClass.AddWhereCondition(usMemberships.WhereCondition, siteWhere);

        string script = "function setNewDateTime(date) {$j('#" + hdnDate.ClientID + "').val(date);}";

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "NewDateUniSelectorScript", ScriptHelper.GetScript(script));

        // Manage single item valid to change by calendar
        string eventTarget   = Request["__EVENTTARGET"];
        string eventArgument = Request["__EVENTARGUMENT"];

        if (eventTarget == ucCalendar.DateTimeTextBox.UniqueID)
        {
            // Check "modify" permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Membership", "ManageUserMembership"))
            {
                RedirectToAccessDenied("CMS.Membership", "Manage user membership");
            }

            int id = ValidationHelper.GetInteger(hdnDate.Value, 0);

            if (id != 0)
            {
                DateTime           dt = ValidationHelper.GetDateTime(eventArgument, DateTimeHelper.ZERO_TIME);
                MembershipUserInfo mi = MembershipUserInfoProvider.GetMembershipUserInfo(id, UserID);
                if (mi != null)
                {
                    mi.ValidTo = dt;
                    MembershipUserInfoProvider.SetMembershipUserInfo(mi);

                    // Invalidate changes
                    if (ui != null)
                    {
                        ui.Invalidate();
                    }

                    this.lblInfo.Visible = true;
                }
            }
        }
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        membershipID = QueryHelper.GetInteger("membershipID", 0);
        MembershipInfo mi = MembershipInfoProvider.GetMembershipInfo(membershipID);

        EditedObject = mi;

        // Test permissions
        CheckMembershipPermissions(mi);

        usUsers.AdditionalColumns       = "UserID,ValidTo";
        usUsers.GridName                = "~/CMSModules/Membership/Pages/Users/UsersValidTo.xml";
        usUsers.DynamicColumnName       = false;
        usUsers.SelectItemPageUrl       = "~/CMSModules/Membership/Pages/Users/User_Edit_Add_Item_Dialog.aspx";
        usUsers.AdditionalUrlParameters = "&UseSendNotification=1";
        usUsers.WhereCondition          = (mi.MembershipSiteID > 0) ? "UserID IN (SELECT UserID FROM CMS_UserSite WHERE SiteID=" + mi.MembershipSiteID + ")" : String.Empty;
        usUsers.ListingWhereCondition   = "MembershipID =" + membershipID;
        usUsers.ReturnColumnName        = "UserID";

        // Load data in administration
        currentValues = GetMembershipUsers();
        if (!RequestHelper.IsPostBack())
        {
            usUsers.Value = currentValues;
        }

        if (!String.IsNullOrEmpty(currentValues))
        {
            usUsers.WhereCondition = SqlHelperClass.AddWhereCondition(usUsers.WhereCondition, "UserID NOT IN (" + currentValues.Replace(';', ',') + ")");
        }

        string script = "function setNewDateTime(date) {$j('#" + hdnDate.ClientID + "').val(date);}";

        script += "function setNewSendNotification(sendNotification) {$j('#" + this.hdnSendNotification.ClientID + "').val(sendNotification);}";
        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "key", ScriptHelper.GetScript(script));

        usUsers.OnSelectionChanged    += UniSelector_OnSelectionChanged;
        usUsers.OnAdditionalDataBound += new CMSAdminControls_UI_UniSelector_UniSelector.AdditionalDataBoundEventHandler(usUsers_OnAdditionalDataBound);

        // Manage single item valid to change by calendar
        string eventTarget   = Request["__EVENTTARGET"];
        string eventArgument = Request["__EVENTARGUMENT"];

        if (eventTarget == ucCalendar.DateTimeTextBox.UniqueID)
        {
            // Check "modify" permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Membership", "ManageUserMembership"))
            {
                RedirectToAccessDenied("CMS.Membership", "Manage user membership");
            }

            int id = ValidationHelper.GetInteger(hdnDate.Value, 0);

            if (id != 0)
            {
                DateTime           dt  = ValidationHelper.GetDateTime(eventArgument, DateTimeHelper.ZERO_TIME);
                MembershipUserInfo mui = MembershipUserInfoProvider.GetMembershipUserInfo(mi.MembershipID, id);
                if (mui != null)
                {
                    mui.ValidTo = dt;
                    MembershipUserInfoProvider.SetMembershipUserInfo(mui);
                    UserInfo ui = UserInfoProvider.GetUserInfo(id);

                    // Invalidate changes
                    if (ui != null)
                    {
                        ui.Invalidate();
                    }

                    this.lblInfo.Visible = true;
                    this.lblInfo.Text    = GetString("General.ChangesSaved");
                }
            }
        }
    }