private void addButton_Click(object sender, EventArgs e) { SecurityNode sn = Roles.GetSecurityNode(); sn.NodeID = CurrentNode.Id; sn.RoleID = int.Parse(rolesList.SelectedValue); int i = 0; if (delete.Checked) { i += (int)Permission.Delete; } if (publish.Checked) { i += (int)Permission.Publish; } if (edit.Checked) { i += (int)Permission.Edit; } if (add.Checked) { i += (int)Permission.Add; } if (view.Checked) { i += (int)Permission.View; } sn.PermissionLevel = i; Roles.SaveSecurityNode(sn); msg.Text = "added role: " + rolesList.SelectedItem.Text + " level:" + i.ToString(); SFGlobal.UpdateNodes(); Response.Redirect(Request.RawUrl); }
public void changeNodeRank(Node currentNode, string direction) { Node p = currentNode.parent; int i = currentNode.GetIndexInParentCollection(); if (i >= 0 && i < p.children.Count) { int oldRank = currentNode.Rank; int dir = (direction == "dn") ? 1 : -1; if (dir == -1 && i == 0) { return; } if (dir == 1 && i == p.children.Count - 1) { return; } //Response.Write("changing " + currentNode.Id + ":" + currentNode.Rank + " to " + p.children[i+dir].Id + ":" + p.children[i+dir].Rank); currentNode.Rank = p.children[i + dir].Rank; p.children[i + dir].Rank = oldRank; currentNode.Publish = true; p.children[i + dir].Publish = true; SFGlobal.ObjectManager.PersistChanges(currentNode); SFGlobal.ObjectManager.PersistChanges(p.children[i + dir]); SFGlobal.UpdateNodes(); } else { //System.Web.HttpContext.Current.Response.Write("ignoring order change"); } }
private void rolesGrid_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Save") { SecurityNode sn = Roles.GetSecurityNode(int.Parse(e.CommandArgument.ToString())); CheckBox delete = (CheckBox)e.Item.FindControl("delete"); CheckBox publish = (CheckBox)e.Item.FindControl("publish"); CheckBox edit = (CheckBox)e.Item.FindControl("edit"); CheckBox add = (CheckBox)e.Item.FindControl("add"); CheckBox view = (CheckBox)e.Item.FindControl("view"); int i = 0; if (delete.Checked) { i += (int)Permission.Delete; } if (publish.Checked) { i += (int)Permission.Publish; } if (edit.Checked) { i += (int)Permission.Edit; } if (add.Checked) { i += (int)Permission.Add; } if (view.Checked) { i += (int)Permission.View; } sn.PermissionLevel = i; Roles.SaveSecurityNode(sn); SFGlobal.UpdateNodes(); Response.Redirect(Request.RawUrl); } if (e.CommandName == "Delete") { SecurityNode sn = Roles.GetSecurityNode(int.Parse(e.CommandArgument.ToString())); Roles.DeleteSecurityNode(sn); msg.Text = "role deleted"; SFGlobal.UpdateNodes(); Response.Redirect(Request.RawUrl); } }
private void saveNode() { if (nodeID > 0) //update { currentNode = root.Find(nodeID); } else //insert { currentNode = (Node)SFGlobal.ObjectManager.GetObject(typeof(Node)); currentNode.DateCreated = currentNode.DateModified = DateTime.Now; } currentNode.Filename = filename.Text; //if (nodeID <= 0) currentNode.Rank = 0; Node parent = root.Find(int.Parse(parentID.SelectedValue)); if (nodeID == 0) { if (parent.children.Count > 0) { currentNode.Rank = parent.children[parent.children.Count - 1].Rank + 1; } else { currentNode.Rank = 0; } } currentNode.ParentID = int.Parse(parentID.SelectedValue); currentNode.TypeID = int.Parse(nodeTypeID.SelectedValue); currentNode.PageTemplateID = int.Parse(pageTemplateID.SelectedValue); currentNode.Publish = publish_check.Checked; currentNode.Visible = visible_check.Checked; currentNode.VisibleMenu = visibleMenu_check.Checked; currentNode.VisibleSubMenu = visibleSubMenu_check.Checked; currentNode.DateModified = DateTime.Now; SFGlobal.ObjectManager.PersistChanges(currentNode); SFGlobal.UpdateNodes(); // hack! -- skip the redirect if "add & close" was clicked if (nodeID > 0 && action == 0) { Response.Redirect(Request.Path + "?action=add"); } }
private void publishItems() { string s = ""; // first publish the nodes SFGlobal.DAL.execNonQuery("publishNodes", null); s += "published nodes<br>"; // now publish what we want... foreach (ListItem li in nodesToPublish.Items) { if (li.Selected) { publishNodeInfo pni = (publishNodeInfo)nodeInfo[li.Value]; SFGlobal.DAL.execNonQuery(pni.PublishSP, null); s += "published " + pni.Name + "<BR>"; } } SFGlobal.UpdateNodes(); getItemsForPublish(); results.Text = s; }
protected void userGrid_Update(System.Object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e) { int itemID = int.Parse(e.Item.Cells[0].Text); // insert user data string username = SFGlobal.SqlCleanString(((TextBox)e.Item.FindControl("username")).Text); string password = ((TextBox)e.Item.FindControl("password")).Text; string fullname = SFGlobal.SqlCleanString(((TextBox)e.Item.FindControl("fullname")).Text); string email = SFGlobal.SqlCleanString(((TextBox)e.Item.FindControl("email")).Text); string disabled = ((CheckBox)e.Item.FindControl("disabledCheck")).Checked ? "1" : "0"; if (password != null && password != "") { password = Dury.SiteFoundry.Security.Cryptography.AsymmetricEncryption.ComputeHash(password, SFGlobal.EncryptionMethod, SFGlobal.EncryptionSalt); SFGlobal.DAL.execNonQuery("UPDATE SecurityUsers SET username = '******'" + ", password='******', fullname='" + fullname + "', email='" + email + "' , disabled=" + disabled + " WHERE id = " + itemID.ToString()); } else { SFGlobal.DAL.execNonQuery("UPDATE SecurityUsers SET username = '******', fullname='" + fullname + "', email='" + email + "', disabled=" + disabled + " WHERE id = " + itemID.ToString()); } // insert roles ListBox cbx = (ListBox)e.Item.FindControl("rolesList"); SFGlobal.DAL.execNonQuery("DELETE FROM SecurityUserRoles WHERE userID = " + itemID.ToString()); foreach (ListItem li in cbx.Items) { if (li.Selected) { SFGlobal.DAL.execNonQuery("INSERT INTO SecurityUserRoles (userID,roleID) VALUES (" + itemID.ToString() + "," + li.Value + ")"); } } userGrid.EditItemIndex = -1; userGridBind(); SFGlobal.UpdateNodes(); msg.Text = "User: "******" updated ok"; }
private void deleteNode() { currentNode = (Node)SFGlobal.ObjectManager.GetObject(typeof(Node), nodeID); NodeFactory.DeleteNode(currentNode); SFGlobal.UpdateNodes(); }