コード例 #1
0
        void User_Saving(User sender, EventArgs e)
        {
            //User is already saved but the object itself is not updated yet.
            //Get user from database and use that user to copy the permissions
            User savedUser = User.GetUser(sender.Id);

            if (sender.UserType.Alias != savedUser.UserType.Alias)
            {
                //Only save when usertype is changed
                UserTypePermissions.CopyPermissionsForSingleUser(savedUser);
            }
        }
コード例 #2
0
        protected void Button1_Click(object sender, System.EventArgs e)
        {
            Hashtable allUserTypes = new Hashtable();

            foreach (umbraco.BusinessLogic.UserType u in UserType.GetAllUserTypes())
            {
                allUserTypes.Add(u.Id, "");
            }

            foreach (CheckBox c in permissions)
            {
                // Update the user with the new permission
                if (c.Checked)
                {
                    allUserTypes[int.Parse(c.ID.Substring(0, c.ID.IndexOf("_")))] = (string)allUserTypes[int.Parse(c.ID.Substring(0, c.ID.IndexOf("_")))] + c.ID.Substring(c.ID.IndexOf("_") + 1, c.ID.Length - c.ID.IndexOf("_") - 1);
                }
            }


            // Loop through the users and update their Cruds...
            IDictionaryEnumerator uEnum = allUserTypes.GetEnumerator();

            while (uEnum.MoveNext())
            {
                string cruds = "-";
                if (uEnum.Value.ToString().Trim() != "")
                {
                    cruds = uEnum.Value.ToString();
                }
                UserType usertype = umbraco.BusinessLogic.UserType.GetUserType(int.Parse(uEnum.Key.ToString()));
                UserGroupPermissions.Businesslogic.UserTypePermissions.UpdateCruds(usertype, node, cruds);

                if (ReplacePermissionsOnChildren.Checked)
                {
                    //Replace permissions on all children
                    UserTypePermissions.CopyPermissions(usertype, node);
                }
            }

            // Update feedback message
            feedback1.type        = umbraco.uicontrols.Feedback.feedbacktype.success;
            feedback1.Text        = "Usergroup permissions saved ok ";
            pane_form.Visible     = false;
            panel_buttons.Visible = false;
        }