Пример #1
0
        public CoreModuleRepository GetCoreModuleRepository(int personId, int communityId)
        {
            CoreModuleRepository module = new CoreModuleRepository();
            Person person = Manager.GetPerson(personId);

            if (communityId == 0)
            {
                module = CoreModuleRepository.CreatePortalmodule(person.TypeID);
            }
            else
            {
                module = new CoreModuleRepository(Manager.GetModulePermission(personId, communityId, Manager.GetModuleID(CoreModuleRepository.UniqueID)));
            }
            return(module);
        }
        public void InitView()
        {
            int  IdUser      = UserContext.CurrentUserID;
            int  idCommunity = UserContext.CurrentCommunityID;
            long IdLink      = View.PreloadedIdLink;
            long IdFile      = View.PreloadedIdFile;

            View.BackUrl = View.PreloadedBackUrl;
            View.IdFile  = IdFile;
            View.IdLink  = IdLink;
            View.AllowSetDefaultDocument = false;
            BaseCommunityFile item = Service.GetItem(IdFile);

            if (item != null && item.CommunityOwner != null)
            {
                idCommunity = item.CommunityOwner.Id;
            }
            if (UserContext.isAnonymous)
            {
                View.SendToSessionExpiredPage(idCommunity, UserContext.Language.Code);
            }
            else if (item == null)
            {
                View.LoadFileNotExist();
            }
            else if (item.RepositoryItemType == RepositoryItemType.Multimedia)
            {
                RepositoryItemPermission permissions = new RepositoryItemPermission();
                if (IdLink == 0 || item.GetType() == typeof(CommunityFile))
                {
                    CoreModuleRepository module = null;
                    if (item.CommunityOwner == null)
                    {
                        module = CoreModuleRepository.CreatePortalmodule(UserContext.UserTypeID);
                    }
                    else if (!item.IsInternal)
                    {
                        module = new CoreModuleRepository(CurrentManager.GetModulePermission(IdUser, item.CommunityOwner.Id, ModuleID));
                    }
                    else
                    {
                        module = new CoreModuleRepository();
                    }
                    if (Service.HasPermissionToSeeRepositoryItem(item.Id, module.Administration, module.Administration, IdUser))
                    {
                        permissions = new dtoDisplayItemRepository(item, module, IdUser, module.Administration).Permission;
                    }
                }
                else
                {
                    ModuleLink link = Service.GetModuleLink(IdLink);
                    permissions = View.GetModuleLinkPermission(link.SourceItem.CommunityID, IdUser, link);
                }
                if (permissions.EditSettings)
                {
                    MultimediaFileTransfer multimedia = Service.GetMultimediaFileTransfer(item);
                    if (multimedia == null)
                    {
                        View.LoadFileNotExist();
                    }
                    else if (multimedia.MultimediaIndexes.Count == 0)
                    {
                        View.LoadFileWithoutIndex(item);
                    }
                    else
                    {
                        View.AllowSetDefaultDocument = permissions.EditSettings;
                        View.LoadTree(item, (from m in multimedia.MultimediaIndexes select m.Fullname.Replace(item.UniqueID.ToString() + "\\", "")).ToList(), (multimedia.DefaultDocument == null) ? "" : multimedia.DefaultDocument.Fullname.Replace(item.UniqueID.ToString() + "\\", ""));
                    }
                }
                else
                {
                    View.LoadFileNoPermission();
                }
            }
            else
            {
                View.LoadInvalidFileType(item);
            }
        }
Пример #3
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);
        }