public string GroupId(Group [] groups, System.Collections.IList groups_selected) { string salida = ""; foreach (Group group in groups) { if (groups_selected != null && groups_selected.Contains(group)) salida += System.String.Format("{1}: <input type=\"checkbox\" NAME=\"Group{0}[{1}]\" VALUE=\"Yes\" checked>", group.Id, group.Name); else salida += System.String.Format("{1}: <input type=\"checkbox\" NAME=\"Group{0}[{1}]\" VALUE=\"Yes\">", group.Id, group.Name); } return salida; }
private static string ReadGroup(XmlNode node) { if (node.Name == "Group") { string nombre = NodeGetString(node, "nombre"); Group g = new Group (nombre); g.Save(); g.Roles = NodeGetObjectSet(node, "Role", roles); g.Save(); /* Group x = Group.Find(g.Id); foreach (Role r in g.Roles) System.Console.WriteLine ("Grupo ROL: "+ r.Name); System.Console.WriteLine ("Grupo: "+ nombre); g.Save();*/ groups[nombre] = g; } return null; }
public Acl(int groupid, int roleid) { _Group = Group.Find(groupid); _Role = Role.Find(roleid); }
public Acl(string code, Group g, Role r) { _Code = code; _Group = g; _Role = r; }
public new static Acl[] FindByGroup(Group g) { return FindByGroup(g.Id); }
public Schedule(Group group) { _GroupOwner = group; }
public string GroupId(Group [] groups) { return GroupId(groups, (Group []) null); }
/*public string Groups(User u) { return Groups(u, Group.FindAll()); }*/ public string Groups(User u, Group [] gg) { string salida = ""; foreach (Group g in gg) { //string selected = u.Groups.Contains(g) ? "checked" : ""; // sería lo optimo pero no funciona :-((( a lo cutre... string selected = ""; if (u!=null) foreach (Group gx in u.Groups) if (gx.Id == g.Id) { selected = "checked"; break; } //System.Console.WriteLine("mostrando group enabled {0}", g.Name); salida += System.String.Format("{0}: <input type=\"checkbox\" NAME=\"GroupIds\" VALUE=\"{1}\" {2}/> ", g.Name, g.Id, selected); } return salida; }
private void GroupAclsDelete(Group group) { Commons.CheckSuperUser(Session); if (group != null) { Acl[] acls = Acl.FindAll(); for (int i = 0; i < acls.Length; i++) { Acl acl = acls[i]; //Console.WriteLine("i vale=" + i +", " + acl.Id +", "+ acl.Group.Id); if (acl.Group.Id == group.Id) { //Console.WriteLine("i es del grupo=" + i +", " + acl.Id + ", " + acl.Containers.Count); foreach(Container container in acl.Containers) { if (container.AclSet.Contains(acl)) // Contains checks Id ? { container.AclSet.Remove(acl); } container.Save(); /*if (acl.Containers.Contains(acl) { container } int aclIndex = -1; for (int j = 0; j < container.AclSet.Count; j++) { // acl.Id == con if (acl.Id == ((Acl)container.AclSet. [j]).Id) { aclIndex = j; break; } } if (aclIndex >= 0) { container.AclSet.RemoveAt(aclIndex); }*/ } acl.Containers.Clear(); acl.Delete(); } } } else { throw new NotFoundException("Group not found"); } }
public void GroupCreate (string groupName) { Commons.CheckSuperUser(Session); Group group = new Group(groupName); string rolesString = (string) Request.Form["Roles[]"]; if (rolesString != null) { string[] roles = rolesString.Split(','); if (roles != null) { group.Roles = new HashedSet(); foreach (string i in roles) { Role role = Role.Find(int.Parse(i)); if (role != null) { group.Roles.Add(role); } } } } group.Save(); Role[] rols = Role.FindAll(); foreach (Role r in rols) { bool isDefaultRole = false; if (group.Roles != null) { foreach(Role rol in group.Roles) { if (rol.Id == r.Id) { isDefaultRole = true; } } } if ((isDefaultRole) && (Request.Form["updateAcls"] != null)) { Acl acl = new Acl(); acl.Group = group; acl.Role = r; acl.Containers = new Iesi.Collections.HashedSet(); //ArrayList(); acl.Save(); Category[] categories = Category.FindAll(); foreach(Category category in categories) { category.AclSet.Add(acl); category.Save(); #if CACHE acl.Containers.Add(category); #endif } } //acl.Save(); } RedirectToAction ("groupsedit"); }
public new static Group[] FindByName(string name) { if (name.Length > 0) name = name.ToLower(); name += '%'; Group[] glower = (Group[])ActiveRecordBase.FindAll( typeof(Group), new Order[] { Order.Asc("Name") }, Expression.Like("Name", name)); name = name.ToUpper(); Group[] gupper = (Group[])ActiveRecordBase.FindAll( typeof(Group), new Order[] { Order.Asc("Name") }, Expression.Like("Name", name)); Group[] r = new Group[gupper.Length + glower.Length]; int i; for (i = 0; i < gupper.Length; i++) r[i] = gupper[i]; for (int j = 0; j < glower.Length; j++) { r[i] = glower[j]; i++; } return r; }