Ejemplo n.º 1
0
        protected void buttonRemoveProtection_Click(object sender, System.EventArgs e)
        {
            int pageId = int.Parse(helper.Request("nodeId"));

            p_buttons.Visible     = false;
            pane_advanced.Visible = false;
            pane_simple.Visible   = false;

            Access.RemoveProtection(pageId);

            feedback.Text = ui.Text("publicAccess", "paIsRemoved", new cms.businesslogic.CMSNode(pageId).Text, null) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";

            ClientTools.ReloadActionNode(true, false);

            feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
        }
        protected void buttonRemoveProtection_Click(object sender, System.EventArgs e)
        {
            int pageId = int.Parse(helper.Request("nodeId"));
            p_buttons.Visible = false;
            pane_advanced.Visible = false;
            pane_simple.Visible = false;

            Access.RemoveProtection(pageId);

            feedback.Text = ui.Text("publicAccess", "paIsRemoved", new cms.businesslogic.CMSNode(pageId).Text) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";

            var content = ApplicationContext.Current.Services.ContentService.GetById(pageId);
            //reloads the current node in the tree
            ClientTools.SyncTree(content.Path, true);
            //reloads the current node's children in the tree
            ClientTools.ReloadActionNode(false, true);
            feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
        }
        protected void buttonRemoveProtection_Click(object sender, System.EventArgs e)
        {
            int pageId = int.Parse(helper.Request("nodeId"));

            p_setup.Visible = false;

            Access.RemoveProtection(pageId);

            feedback_text.Text = HttpUtility.HtmlEncode(ui.Text("publicAccess", "paIsRemoved", new cms.businesslogic.CMSNode(pageId).Text));
            p_feedback.Visible = true;

            var content = ApplicationContext.Current.Services.ContentService.GetById(pageId);

            //reloads the current node in the tree
            ClientTools.SyncTree(content.Path, true);
            //reloads the current node's children in the tree
            ClientTools.ReloadActionNode(false, true);
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nodeId = int.Parse(helper.Request("id"));
            cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(nodeId);
            pageName = d.Text;

            // add control prefix to variable for support with masterpages
            string prefix = PublishUnpublishedItems.ClientID.Replace(PublishUnpublishedItems.ID, "");

            masterPagePrefix.Text = prefix;

            // by default we only count the published ones
            int TotalNodesToPublish = cms.businesslogic.web.Document.CountSubs(nodeId, true);

            try
            {
                Application.Lock();
                // We add both all nodes and only published nodes to the application variables so we can ajax query depending on checkboxes
                Application["publishTotalAll" + nodeId.ToString()] = cms.businesslogic.CMSNode.CountSubs(nodeId).ToString();
                Application["publishTotal" + nodeId.ToString()]    = TotalNodesToPublish.ToString();
                Application["publishDone" + nodeId.ToString()]     = "0";
            }
            finally
            {
                Application.UnLock();
            }
            total.Text = TotalNodesToPublish.ToString();

            // Put user code to initialize the page here
            if (!IsPostBack)
            {
                // Add caption to checkbox
                PublishAll.Text = ui.Text("publish", "publishAll", d.Text, base.getUser());
                ok.Text         = ui.Text("content", "publish", base.getUser());
                ok.Attributes.Add("style", "width: 60px");
                ok.Attributes.Add("onClick", "startPublication();");

                // Add checkbox event, so the publish unpublished childs gets enabled
                PublishUnpublishedItems.LabelAttributes.Add("disabled", "true");
                PublishUnpublishedItems.LabelAttributes.Add("id", "publishUnpublishedItemsLabel");
                PublishUnpublishedItems.InputAttributes.Add("disabled", "true");
                PublishAll.InputAttributes.Add("onclick", "togglePublishingModes(this)");
            }
            else
            {
                if (PublishAll.Checked)
                {
                    nodesPublished = 0;

                    doPublishSubs(d);

                    //PPH added load balancing...
                    //content.Instance.PublishNode(documents);
                    foreach (cms.businesslogic.web.Document doc in documents)
                    {
                        if (doc.Published)
                        {
                            library.UpdateDocumentCache(doc.Id);
                        }
                    }

                    Application.Lock();
                    Application["publishTotal" + nodeId.ToString()] = 0;
                    Application.UnLock();

                    feedbackMsg.type = umbraco.uicontrols.Feedback.feedbacktype.success;

                    feedbackMsg.Text = ui.Text("publish", "nodePublishAll", d.Text, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";

                    ClientTools.ReloadActionNode(true, true);

                    Application.Lock();

                    Application["publishTotal" + nodeId.ToString()] = null;
                    Application["publishDone" + nodeId.ToString()]  = null;
                    Application.UnLock();
                }
                else
                {
                    if (d.PublishWithResult(base.getUser()))
                    {
                        library.UpdateDocumentCache(d.Id);
                        feedbackMsg.type = umbraco.uicontrols.Feedback.feedbacktype.success;
                        feedbackMsg.Text = ui.Text("publish", "nodePublish", d.Text, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                    }
                    else
                    {
                        feedbackMsg.type = umbraco.uicontrols.Feedback.feedbacktype.notice;
                        feedbackMsg.Text = ui.Text("publish", "contentPublishedFailedByEvent", d.Text, base.getUser()) + "</p><p><a href='#' onClick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                    }
                    ClientTools.ReloadActionNode(true, false);
                }

                TheForm.Visible = false;
                theEnd.Visible  = true;
            }
        }
Ejemplo n.º 5
0
        protected void protect_Click(object sender, CommandEventArgs e)
        {
            if (string.IsNullOrEmpty(errorPagePicker.Value) || errorPagePicker.Value == "-1")
            {
                cv_errorPage.IsValid = false;
            }

            if (string.IsNullOrEmpty(loginPagePicker.Value) || loginPagePicker.Value == "-1")
            {
                cv_loginPage.IsValid = false;
            }

            //reset
            SimpleLoginNameValidator.IsValid = true;

            var provider = MembershipProviderExtensions.GetMembersMembershipProvider();

            if (Page.IsValid)
            {
                int pageId = int.Parse(helper.Request("nodeId"));

                if (e.CommandName == "simple")
                {
                    var memberLogin = simpleLogin.Visible ? simpleLogin.Text : SimpleLoginLabel.Text;

                    var member = provider.GetUser(memberLogin, false);
                    if (member == null)
                    {
                        var tempEmail = "u" + Guid.NewGuid().ToString("N") + "@example.com";

                        // this needs to work differently depending on umbraco members or external membership provider
                        if (provider.IsUmbracoMembershipProvider() == false)
                        {
                            member = provider.CreateUser(memberLogin, simplePassword.Text, tempEmail);
                        }
                        else
                        {
                            //if it's the umbraco membership provider, then we need to tell it what member type to create it with
                            if (MemberType.GetByAlias(Constants.Conventions.MemberTypes.SystemDefaultProtectType) == null)
                            {
                                MemberType.MakeNew(BusinessLogic.User.GetUser(0), Constants.Conventions.MemberTypes.SystemDefaultProtectType);
                            }
                            var castedProvider = provider.AsUmbracoMembershipProvider();
                            MembershipCreateStatus status;
                            member = castedProvider.CreateUser(Constants.Conventions.MemberTypes.SystemDefaultProtectType,
                                                               memberLogin, simplePassword.Text, tempEmail, null, null, true, null, out status);
                            if (status != MembershipCreateStatus.Success)
                            {
                                SimpleLoginNameValidator.IsValid      = false;
                                SimpleLoginNameValidator.ErrorMessage = "Could not create user: "******"Could not create user: "******"__umbracoRole_" + member.UserName;
                    if (Roles.RoleExists(simpleRoleName) == false)
                    {
                        Roles.CreateRole(simpleRoleName);
                    }
                    if (Roles.IsUserInRole(member.UserName, simpleRoleName) == false)
                    {
                        Roles.AddUserToRole(member.UserName, simpleRoleName);
                    }

                    Access.ProtectPage(true, pageId, int.Parse(loginPagePicker.Value), int.Parse(errorPagePicker.Value));
                    Access.AddMembershipRoleToDocument(pageId, simpleRoleName);
                    Access.AddMembershipUserToDocument(pageId, member.UserName);
                }
                else if (e.CommandName == "advanced")
                {
                    Access.ProtectPage(false, pageId, int.Parse(loginPagePicker.Value), int.Parse(errorPagePicker.Value));

                    foreach (ListItem li in _memberGroups.Items)
                    {
                        if (("," + _memberGroups.Value + ",").IndexOf("," + li.Value + ",", StringComparison.Ordinal) > -1)
                        {
                            Access.AddMembershipRoleToDocument(pageId, li.Value);
                        }
                        else
                        {
                            Access.RemoveMembershipRoleFromDocument(pageId, li.Value);
                        }
                    }
                }

                feedback.Text = ui.Text("publicAccess", "paIsProtected", new cms.businesslogic.CMSNode(pageId).Text) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";

                p_buttons.Visible     = false;
                pane_advanced.Visible = false;
                pane_simple.Visible   = false;
                var content = ApplicationContext.Current.Services.ContentService.GetById(pageId);
                //reloads the current node in the tree
                ClientTools.SyncTree(content.Path, true);
                //reloads the current node's children in the tree
                ClientTools.ReloadActionNode(false, true);
                feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
            }
        }
Ejemplo n.º 6
0
        protected void protect_Click(object sender, CommandEventArgs e)
        {
            if (string.IsNullOrEmpty(errorPagePicker.Text))
            {
                cv_errorPage.IsValid = false;
            }

            if (string.IsNullOrEmpty(loginPagePicker.Text))
            {
                cv_loginPage.IsValid = false;
            }


            if (Page.IsValid)
            {
                int pageId = int.Parse(helper.Request("nodeId"));
                p_buttons.Visible     = false;
                pane_advanced.Visible = false;
                pane_simple.Visible   = false;

                if (e.CommandName == "simple")
                {
                    MembershipUser member = Membership.GetUser(simpleLogin.Text);
                    if (member == null)
                    {
                        // this needs to work differently depending on umbraco members or external membership provider
                        if (!cms.businesslogic.member.Member.InUmbracoMemberMode())
                        {
                            member = Membership.CreateUser(simpleLogin.Text, simplePassword.Text);
                        }
                        else
                        {
                            try
                            {
                                if (cms.businesslogic.member.MemberType.GetByAlias("_umbracoSystemDefaultProtectType") == null)
                                {
                                    cms.businesslogic.member.MemberType.MakeNew(BusinessLogic.User.GetUser(0), "_umbracoSystemDefaultProtectType");
                                }
                            }
                            catch
                            {
                                cms.businesslogic.member.MemberType.MakeNew(BusinessLogic.User.GetUser(0), "_umbracoSystemDefaultProtectType");
                            }
                            // create member
                            cms.businesslogic.member.Member mem = cms.businesslogic.member.Member.MakeNew(simpleLogin.Text, "", cms.businesslogic.member.MemberType.GetByAlias("_umbracoSystemDefaultProtectType"), base.getUser());
                            // working around empty password restriction for Umbraco Member Mode
                            mem.Password = simplePassword.Text;
                            member       = Membership.GetUser(simpleLogin.Text);
                        }
                    }

                    // Create or find a memberGroup
                    string simpleRoleName = "__umbracoRole_" + simpleLogin.Text;
                    if (!Roles.RoleExists(simpleRoleName))
                    {
                        Roles.CreateRole(simpleRoleName);
                    }
                    if (!Roles.IsUserInRole(member.UserName, simpleRoleName))
                    {
                        Roles.AddUserToRole(member.UserName, simpleRoleName);
                    }

                    Access.ProtectPage(true, pageId, int.Parse(loginPagePicker.Text), int.Parse(errorPagePicker.Text));
                    Access.AddMembershipRoleToDocument(pageId, simpleRoleName);
                    Access.AddMembershipUserToDocument(pageId, member.UserName);
                }
                else if (e.CommandName == "advanced")
                {
                    cms.businesslogic.web.Access.ProtectPage(false, pageId, int.Parse(loginPagePicker.Text), int.Parse(errorPagePicker.Text));

                    foreach (ListItem li in _memberGroups.Items)
                    {
                        if (("," + _memberGroups.Value + ",").IndexOf("," + li.Value + ",") > -1)
                        {
                            cms.businesslogic.web.Access.AddMembershipRoleToDocument(pageId, li.Value);
                        }
                        else
                        {
                            cms.businesslogic.web.Access.RemoveMembershipRoleFromDocument(pageId, li.Value);
                        }
                    }
                }

                feedback.Text = ui.Text("publicAccess", "paIsProtected", new cms.businesslogic.CMSNode(pageId).Text, null) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";

                ClientTools.ReloadActionNode(true, false);

                feedback.type = global::umbraco.uicontrols.Feedback.feedbacktype.success;
            }
        }