public void InitView(long ItemID, iCoreItemPermission itemPermissions, IList <iCoreItemFileLink <long> > links, IList <TranslatedItem <long> > statusList, String publishUrl)
        {
            View.ItemID = ItemID;
            if (UserContext.isAnonymous)
            {
                View.LoadFiles(new List <iCoreItemFileLinkPermission <long> >());
                View.ShowManagementButtons = false;
            }
            else
            {
                ServiceCommunityRepository service = new ServiceCommunityRepository(AppContext);
                Person person = CurrentManager.GetPerson(UserContext.CurrentUserID);
                IList <iCoreItemFileLinkPermission <long> > list = (from l in links
                                                                    select(iCoreItemFileLinkPermission <long>) new dtoCoreItemFilePermission <long>()
                {
                    AvailableStatus = statusList,
                    ItemFileLink = l,
                    ItemFileLinkId = l.ItemFileLinkId,
                    Permission = service.GetCoreFilePermission(itemPermissions, l, person)
                }).ToList();

                View.LoadFiles(list);
            }
        }
示例#2
0
        public iCoreFilePermission GetCoreFilePermission(iCoreItemPermission itemPermissions, iCoreItemFileLink <long> itemFileLink, Person person)
        {
            CoreModuleRepository repository = null;
            CoreFilePermission   permission = new CoreFilePermission();

            if (itemPermissions != null && itemFileLink.File != null && itemFileLink.File.Id > 0)
            {
                Boolean isMultimedia = (itemFileLink.File.isFile && itemFileLink.File.RepositoryItemType != DomainModel.Repository.RepositoryItemType.FileStandard && itemFileLink.File.RepositoryItemType != DomainModel.Repository.RepositoryItemType.Folder && itemFileLink.File.RepositoryItemType != DomainModel.Repository.RepositoryItemType.None);
                permission.Download = itemFileLink.File.IsDownloadable && itemPermissions.AllowViewFiles;
                permission.Play     = isMultimedia && itemPermissions.AllowViewFiles;
                //  permission.EditRepositoryVisibility = false;
                permission.EditStatus     = itemPermissions.AllowEdit;
                permission.EditVisibility = itemPermissions.AllowEdit;


                permission.Publish = itemPermissions.AllowFilePublish && itemFileLink.File.IsInternal && itemFileLink.Deleted == BaseStatusDeleted.None;
                permission.Unlink  = itemPermissions.AllowEdit && !itemFileLink.File.IsInternal;



                permission.ViewPersonalStatistics = itemFileLink.File.isSCORM && itemPermissions.AllowViewFiles;
                permission.ViewStatistics         = itemFileLink.File.isSCORM && itemPermissions.AllowViewStatistics;
                permission.Delete        = itemFileLink.File.IsInternal && itemPermissions.AllowDelete && (itemFileLink.Deleted != BaseStatusDeleted.None);
                permission.UnDelete      = itemFileLink.File.IsInternal && (itemFileLink.Deleted != BaseStatusDeleted.None) && itemPermissions.AllowUnDelete;
                permission.VirtualDelete = itemFileLink.File.IsInternal && (itemFileLink.Deleted == BaseStatusDeleted.None) && itemPermissions.AllowUnDelete;
                permission.EditMetadata  = isMultimedia && ((itemFileLink.File.IsInternal && (itemFileLink.Deleted == BaseStatusDeleted.None) && itemPermissions.AllowEdit));

                BaseCommunityFile file = itemFileLink.File;
                if (!file.IsInternal)
                {
                    if (file.CommunityOwner == null)
                    {
                        repository = CoreModuleRepository.CreatePortalmodule(UC.UserTypeID);
                    }
                    else
                    {
                        repository = new CoreModuleRepository(Manager.GetModulePermission(person.Id, file.CommunityOwner.Id, Manager.GetModuleID(CoreModuleRepository.UniqueID)));
                    }
                    if (HasPermissionToSeeRepositoryItem(file.Id, repository.Administration, repository.Administration, UC.CurrentUserID))
                    {
                        Boolean itemOwner = (person == file.Owner);

                        // ATTENZIONE: !! DOVREBBE ANDARE QUESTO MA CREA PROBLEMI AL WCF SERVICES
                        //if (permission.Download==false && itemPermissions.AllowViewFiles ==true){
                        //   permission.Download = (repository.Administration || (file.IsDownloadable && repository.DownLoad));
                        //}

                        permission.EditRepositoryVisibility = repository.Administration || repository.Edit || (repository.UploadFile && itemOwner);
                        permission.EditRepositoryPermission = repository.Administration || repository.Edit || (repository.UploadFile && itemOwner);
                        permission.EditMetadata             = isMultimedia && ((itemFileLink.Deleted == BaseStatusDeleted.None) && itemPermissions.AllowEdit && permission.EditRepositoryPermission);

                        permission.ViewPermission = repository.Administration || repository.Edit || (repository.UploadFile && itemOwner);
                        //   _Permission.Delete = oPermission.Administration OrElse oPermission.Edit OrElse (oPermission.DeleteMyFile AndAlso ItemOwner)
                        //  _Permission.UnDelete = False
                        //_Permission.VirtualDelete = False
                        // _Permission.Edit = oPermission.Administration OrElse oPermission.Edit OrElse (oPermission.UploadFile AndAlso ItemOwner)
                        // _Permission.EditPermission = oPermission.Administration OrElse oPermission.Edit OrElse (oPermission.UploadFile AndAlso ItemOwner)
                        permission.EditRepositoryPermission = false;
                    }
                }

                permission.Link = false;
            }
            else if (itemPermissions != null && itemFileLink.File == null || itemFileLink.File.Id == 0)
            {
                permission.Delete         = itemPermissions.AllowDelete && (itemFileLink.Deleted != BaseStatusDeleted.None);
                permission.VirtualDelete  = (itemFileLink.Deleted == BaseStatusDeleted.None) && itemPermissions.AllowUnDelete;
                permission.EditVisibility = itemPermissions.AllowEdit;
            }
            return((iCoreFilePermission)permission);
        }
示例#3
0
        public IList <iCoreItemFileLinkPermission <long> > GetCoreItemFileLinkPermission(iCoreItemPermission itemPermissions, IList <iCoreItemFileLink <long> > links, IList <TranslatedItem <long> > statusList, Person person)
        {
            IList <iCoreItemFileLinkPermission <long> > list = (from l in links
                                                                select(iCoreItemFileLinkPermission <long>) new dtoCoreItemFilePermission <long>()
            {
                AvailableStatus = statusList,
                ItemFileLink = l,
                ItemFileLinkId = l.ItemFileLinkId,
                Permission = GetCoreFilePermission(itemPermissions, l, person)
            }).ToList();

            return(list);
        }