public dtoDisplayRepositoryItem(dtoRepositoryItem item)
     : base(item)
 {
     Permissions = new ItemPermission();
     Children    = new List <dtoDisplayRepositoryItem>();
     Identifier  = new dtoItemIdentifier();
 }
 public dtoDisplayRepositoryItem(dtoRepositoryItem item, Int32 idPerson, liteRepositorySettings settings, ModuleRepository modulePermissions, Boolean forAdmin = false, Boolean hasAssignments = false)
     : base(item)
 {
     IsUserAvailable = forAdmin || hasAssignments;
     Children        = new List <dtoDisplayRepositoryItem>();
     Permissions     = CreatePermission(item, idPerson, settings, modulePermissions, forAdmin);
     Identifier      = new dtoItemIdentifier();
 }
Example #3
0
 public dtoBaseRepositoryItem(dtoRepositoryItem item)
 {
     Id              = item.Id;
     Deleted         = item.Deleted;
     IdFolder        = item.IdFolder;
     UniqueId        = item.UniqueId;
     IdVersion       = item.IdVersion;
     UniqueIdVersion = item.UniqueIdVersion;
     IdCommunity     = item.IdCommunity;
     Type            = item.Type;
     Name            = item.Name;
     Extension       = item.Extension;
     Url             = item.Url;
     ContentType     = item.ContentType;
     IsFile          = item.IsFile;
     IdOwner         = item.IdOwner;
     OwnerName       = item.OwnerName;
     CreatedOn       = item.CreatedOn;
     IdModifiedBy    = item.IdModifiedBy;
     ModifiedOn      = item.ModifiedOn;
     ModifiedBy      = item.ModifiedBy;
     Size            = item.Size;
     VersionsSize    = item.VersionsSize;
     DeletedSize     = item.DeletedSize;
     Description     = item.Description;
     Tags            = item.Tags;
     IsDownloadable  = item.IsDownloadable;
     CloneOf         = item.CloneOf;
     CloneOfUniqueId = item.CloneOfUniqueId;
     Repository      = item.Repository;
     #region "Folder"
     AllowUpload = item.AllowUpload;
     FolderType  = (item.IsFile ? lm.Comol.Core.FileRepository.Domain.FolderType.none : Domain.FolderType.standard);
     #endregion
     #region "Visibility"
     IsVisible    = item.IsVisible;
     DisplayOrder = item.DisplayOrder;
     Availability = item.Availability;
     Status       = item.Status;
     #endregion
     #region "Special data"
     HasVersions     = item.HasVersions;
     RevisionsNumber = item.RevisionsNumber;
     DisplayMode     = item.DisplayMode;
     Thumbnail       = item.Thumbnail;
     AutoThumbnail   = item.AutoThumbnail;
     PreviewTime     = item.PreviewTime;
     Time            = item.Time;
     Number          = item.Number;
     #endregion
     IdPlayer   = item.IdPlayer;
     Downloaded = item.Downloaded;
     IsInternal = item.IsInternal;
     Module     = item.Module;
     IsVirtual  = item.IsVirtual;
     Path       = item.Path;
 }
        private ItemPermission CreatePermission(dtoRepositoryItem item, Int32 idPerson, liteRepositorySettings settings, ModuleRepository modulePermissions, Boolean forAdmin = false)
        {
            ItemPermission permissions  = new ItemPermission();
            Boolean        isOwner      = (item.IdOwner == idPerson);
            Boolean        manageOthers = (modulePermissions.Administration || modulePermissions.ManageItems || modulePermissions.EditOthersFiles);

            if (IsUserAvailable)
            {
                IsUserAvailable = manageOthers || (((isOwner && item.IsVisible) || item.IsVisible) && (item.Status == ItemStatus.Active || isOwner));
            }
            item.AllowUpload        = (!item.IsFile && item.FolderType == Domain.FolderType.standard && (item.AllowUpload || modulePermissions.Administration || modulePermissions.ManageItems || isOwner));
            permissions.AllowUpload = item.AllowUpload;
            switch (item.Type)
            {
            case ItemType.File:
                permissions.Unzip = (item.Availability == ItemAvailability.available) && ((item.Extension == ".zip") && (manageOthers || (modulePermissions.EditMyFiles && isOwner) || (modulePermissions.UploadFile && isOwner)));
                permissions.Zip   = (item.Availability == ItemAvailability.available) && (manageOthers || modulePermissions.DownloadOrPlay || (modulePermissions.EditMyFiles && isOwner) || (modulePermissions.UploadFile && isOwner));
                break;

            case ItemType.Folder:
                break;

            case ItemType.Multimedia:
            case ItemType.ScormPackage:
                permissions.CanEditSettings = ((item.Deleted == DomainModel.BaseStatusDeleted.None && manageOthers || (modulePermissions.EditMyFiles && isOwner) || (modulePermissions.UploadFile && isOwner && item.Availability == ItemAvailability.available)));
                permissions.EditSettings    = IsAvailableByType(item.Type, item.Availability) && ((item.Deleted == DomainModel.BaseStatusDeleted.None && manageOthers || (modulePermissions.EditMyFiles && isOwner) || (modulePermissions.UploadFile && isOwner && item.Availability == ItemAvailability.available)));
                permissions.Zip             = (item.Availability != ItemAvailability.notavailable) && (manageOthers || modulePermissions.DownloadOrPlay || (modulePermissions.EditMyFiles && isOwner) || (modulePermissions.UploadFile && isOwner));
                break;

            case ItemType.Link:
                break;
            }
            permissions.Edit                = manageOthers || (modulePermissions.EditMyFiles && isOwner) || (modulePermissions.UploadFile && isOwner);
            permissions.ViewMyStatistics    = ((item.Deleted == DomainModel.BaseStatusDeleted.None && item.Type != ItemType.Link && item.Type != ItemType.Folder && item.Type != ItemType.File) && !(manageOthers || (modulePermissions.EditMyFiles && isOwner && IsAvailableByType(item.Type, item.Availability)) || (modulePermissions.UploadFile && isOwner && IsAvailableByType(item.Type, item.Availability))));
            permissions.ViewOtherStatistics = (item.Deleted == DomainModel.BaseStatusDeleted.None && item.Type != ItemType.Link && item.Type != ItemType.Folder && item.Type != ItemType.File) && (manageOthers || (modulePermissions.EditMyFiles && isOwner && IsAvailableByType(item.Type, item.Availability)) || (modulePermissions.UploadFile && isOwner && IsAvailableByType(item.Type, item.Availability)));

            permissions.VersioningAvailable = (item.Availability != ItemAvailability.notavailable) && ((item.Deleted == DomainModel.BaseStatusDeleted.None && item.Type != ItemType.Folder && item.Type != ItemType.Link && settings.AllowVersioning));

            permissions.ViewPermission = permissions.Edit;
            permissions.EditPermission = manageOthers || (modulePermissions.EditMyFiles && isOwner) || (modulePermissions.UploadFile && isOwner && item.Availability != ItemAvailability.available);
            permissions.Delete         = (item.Deleted != DomainModel.BaseStatusDeleted.None && (manageOthers || (modulePermissions.DeleteMyFiles && isOwner)));
            permissions.UnDelete       = (item.Deleted != DomainModel.BaseStatusDeleted.None && (manageOthers || (modulePermissions.DeleteMyFiles && isOwner)));
            permissions.VirtualDelete  = (item.Deleted == DomainModel.BaseStatusDeleted.None && (manageOthers || (modulePermissions.DeleteMyFiles && isOwner)));


            permissions.Download       = (item.Availability != ItemAvailability.notavailable) && (manageOthers || (item.IsDownloadable && item.Type != ItemType.Folder && permissions.Download));
            permissions.Play           = IsAvailableByType(item.Type, item.Availability) && (item.Type == ItemType.Multimedia || item.Type == ItemType.ScormPackage) && ((manageOthers || permissions.Download) && item.Type != ItemType.Folder);
            permissions.Preview        = IsAvailableByType(item.Type, item.Availability) && (item.DisplayMode == Domain.DisplayMode.inModal || item.DisplayMode == Domain.DisplayMode.downloadOrPlayOrModal);
            permissions.AllowSelection = (item.Availability != ItemAvailability.notavailable && (isOwner || manageOthers || item.IsDownloadable || item.Type == ItemType.Link || item.Type == ItemType.Folder));
            permissions.Hide           = (item.Deleted == DomainModel.BaseStatusDeleted.None && permissions.Edit && item.IsVisible);
            permissions.Show           = (item.Deleted == DomainModel.BaseStatusDeleted.None && permissions.Edit && !item.IsVisible);
            return(permissions);
        }
        public static dtoDisplayRepositoryItem CreateFromInternal(dtoRepositoryItem source, Int32 idPerson, Boolean allowManage, Boolean allowView)
        {
            dtoDisplayRepositoryItem item = new dtoDisplayRepositoryItem(source);

            item.Children        = new List <dtoDisplayRepositoryItem>();
            item.IsUserAvailable = true;
            item.Permissions     = new ItemPermission();

            Boolean isOwner = (item.IdOwner == idPerson);

            switch (item.Type)
            {
            case ItemType.File:
                item.Permissions.Unzip = (item.Availability == ItemAvailability.available) && ((item.Extension == ".zip") && (allowManage || isOwner));
                item.Permissions.Zip   = (item.Availability == ItemAvailability.available) && (allowManage || isOwner);
                break;

            case ItemType.Folder:
                break;

            case ItemType.Multimedia:
            case ItemType.ScormPackage:
                item.Permissions.CanEditSettings = (allowManage || isOwner);
                item.Permissions.EditSettings    = IsAvailableByType(item.Type, item.Availability) && (allowManage || isOwner);
                item.Permissions.Zip             = (item.Availability == ItemAvailability.available) && (allowManage || isOwner);
                break;

            case ItemType.Link:
                break;
            }
            item.Permissions.Edit                = (allowManage || isOwner);
            item.Permissions.ViewMyStatistics    = ((item.Deleted == DomainModel.BaseStatusDeleted.None && item.Type != ItemType.Link && item.Type != ItemType.Folder && item.Type != ItemType.File) && !(allowManage || (isOwner && IsAvailableByType(item.Type, item.Availability))));
            item.Permissions.ViewOtherStatistics = (item.Deleted == DomainModel.BaseStatusDeleted.None && item.Type != ItemType.Link && item.Type != ItemType.Folder && item.Type != ItemType.File) && (allowManage || (isOwner && IsAvailableByType(item.Type, item.Availability)));

            item.Permissions.VersioningAvailable = true;
            item.Permissions.ViewPermission      = item.Permissions.Edit;
            item.Permissions.Delete        = (item.Deleted != DomainModel.BaseStatusDeleted.None && allowManage);
            item.Permissions.UnDelete      = (item.Deleted != DomainModel.BaseStatusDeleted.None && allowManage);
            item.Permissions.VirtualDelete = (item.Deleted == DomainModel.BaseStatusDeleted.None && allowManage);


            item.Permissions.Download = (item.Availability != ItemAvailability.notavailable) && (allowManage || (item.IsDownloadable && item.Type != ItemType.Folder && (isOwner || allowView)));
            item.Permissions.Play     = IsAvailableByType(item.Type, item.Availability) && (item.Type == ItemType.Multimedia || item.Type == ItemType.ScormPackage) && ((allowManage || allowView) && item.Type != ItemType.Folder);
            item.Permissions.Preview  = IsAvailableByType(item.Type, item.Availability) && (item.DisplayMode == Domain.DisplayMode.inModal || item.DisplayMode == Domain.DisplayMode.downloadOrPlayOrModal);
            return(item);
        }
Example #6
0
 public dtoRepositoryItem(liteRepositoryItem item, dtoRepositoryItem father = null, lm.Comol.Core.DomainModel.litePerson owner = null, lm.Comol.Core.DomainModel.litePerson modifiedBy = null, String unknownUser = "")
     : base(item, owner, modifiedBy, unknownUser)
 {
     Children = new List <dtoRepositoryItem>();
     Father   = father;
 }