예제 #1
0
    protected void EditRoles_Save(object sender, EventArgs e)
    {
        string roleName = DecodeFromQS("role");
        bool   isCategoryPermissions = false;

        RolePermissionManager.ClearPermissionsForRole(roleName);

        foreach (RepeaterItem ri in CategoryList.Items)
        {
            HiddenField cat     = ri.FindControl("categoryId") as HiddenField;
            CheckBox    read    = ri.FindControl("readRoleCatPermission") as CheckBox;
            CheckBox    edit    = ri.FindControl("editRoleCatPermission") as CheckBox;
            CheckBox    publish = ri.FindControl("publishRoleCatPermission") as CheckBox;

            if (read != null && edit != null && publish != null)
            {
                if (read.Checked || edit.Checked || publish.Checked)
                {
                    isCategoryPermissions = true;
                    GraffitiUsers.AddUpdateRole(roleName, Convert.ToInt32(cat.Value), read.Checked, edit.Checked, publish.Checked);
                }
            }
        }

        if (!isCategoryPermissions)
        {
            GraffitiUsers.AddUpdateRole(roleName, readRolePermission.Checked, editRolePermission.Checked, publishRolePermission.Checked);
        }
        else
        {
            GraffitiUsers.AddUpdateRole(roleName, false, false, false);
        }

        Response.Redirect(string.Format("~/graffiti-admin/user-management/roles/?roleSaved={0}", HttpUtility.UrlEncode(HttpUtility.HtmlEncode(roleName))));
    }
예제 #2
0
    protected void CreateRole_Click(object sender, EventArgs e)
    {
        string encodedRoleName = HttpUtility.HtmlEncode(txtRoleName.Text);

        if (RolePermissionManager.IsDuplicate(txtRoleName.Text))
        {
            Message.Text = string.Format("The role <strong>{0}</strong> already exists.", encodedRoleName);
            Message.Type = StatusType.Error;
            return;
        }

        if (txtRoleName.Text == "gAdmin")
        {
            Message.Text = string.Format("The role <strong>{0}</strong> is a reserved Graffiti Role and cannot be used.", encodedRoleName);
            Message.Type = StatusType.Error;
            return;
        }

        GraffitiUsers.AddUpdateRole(txtRoleName.Text, read.Checked, edit.Checked, publish.Checked);

        Response.Redirect(string.Format("~/graffiti-admin/user-management/roles/?role={0}&new=true", HttpUtility.UrlEncode(encodedRoleName)));
    }