Exemple #1
0
        // List all Descendants of root that current user can read
        public List <CResourceEntity> ListDescendants(int root)
        {
            CACLEntity acl1 = new CACLEntity(ConnString);

            acl1.Acl_Resource  = root;
            acl1.Acl_Operation = (int)ACLOPERATION.READ;

            CResourceEntity parent = new CResourceEntity(ConnString).Load(root);

            if (CheckPrivilege(acl1))
            {
                return(parent.ListChildResources());
            }

            List <CResourceEntity> resources = new List <CResourceEntity>();
            List <CACLEntity>      acls      = GetAllACLs();

            foreach (CACLEntity acl in acls)
            {
                if (acl.Acl_Operation != (int)ACLOPERATION.READ && acl.Acl_Operation != (int)ACLOPERATION.WRITE)
                {
                    continue;
                }

                CResourceEntity res = new CResourceEntity(ConnString).Load(acl.Acl_Resource);
                if (res.Res_Type != (int)RESOURCETYPE.FILERESOURCE && res.Res_Type != (int)RESOURCETYPE.FOLDERRESOURCE)
                {
                    continue;
                }

                bool existed = false;
                foreach (CResourceEntity r in resources)
                {
                    if (r.Res_Id == res.Res_Id)
                    {
                        existed = true;
                        break;
                    }
                }

                if (!existed && res.IsChild(parent.Res_Id))
                {
                    resources.Add(res);
                }
            }

            return(resources);
        }
Exemple #2
0
        // List all children that current user can read
        public List <CResourceEntity> ListResources(int parentId)
        {
            CACLEntity acl = new CACLEntity(ConnString);

            acl.Acl_Resource  = parentId;
            acl.Acl_Operation = (int)ACLOPERATION.READ;

            List <CResourceEntity> files = new List <CResourceEntity>();

            if (!CheckPrivilege(acl))
            {
                return(files);
            }

            CResourceEntity parent = new CResourceEntity(ConnString).Load(parentId);

            return(parent.ListChildResources());
        }
Exemple #3
0
        // list resources of my workspace
        public List <CResourceEntity> ListMyResources()
        {
            CResourceEntity my = new CResourceEntity(ConnString).Load(Usr_Resource);

            return(my.ListChildResources());
        }