Beispiel #1
0
        private CoreItemPermission GetItemPermission(int IdCommunity, Task item)
        {
            ModuleTasklist       module           = Service.ServicePermission(UserContext.CurrentUserID, IdCommunity);
            CoreModuleRepository moduleRepository = View.RepositoryPermission(IdCommunity);

            return(Service.GetTaskPermission(item, module, moduleRepository));
        }
Beispiel #2
0
        public void UpdateFileLink(List <ModuleActionLink> selectedFilesID, List <long> linksId)
        {
            Task item = Service.GetTask(View.CurrentItemID);

            if (item != null)
            {
                int IdCommunity = (item.Community == null ? 0 : item.Community.Id);
                CoreModuleRepository moduleRepository = Service.GetCoreModuleRepository(UserContext.CurrentUserID, IdCommunity);
                CoreItemPermission   permission       = GetTaskPermission(IdCommunity, item, moduleRepository);
                //CHIEDERE NICOLA
                List <long> assignedItemFileLinksId = Service.GetCoreTaskFileLinksId(item, permission.AllowEdit && permission.AllowAddFiles);
                List <long> IdToRemove = (from ai in assignedItemFileLinksId where !linksId.Contains(ai) select ai).ToList();

                if (IdToRemove != null && IdToRemove.Count > 0)
                {
                    Service.UnLinkToCommunityFileFromTask(IdToRemove);
                }
                if (selectedFilesID != null && selectedFilesID.Count > 0)
                {
                    Service.SaveTaskListFiles(item, IdCommunity, selectedFilesID, ModuleID, (int)ModuleTasklist.ObjectType.TaskLinkedFile, ModuleTasklist.UniqueID, false);
                }

                View.ReturnToFileManagement(IdCommunity, item.ID);
            }
            else
            {
                View.ReturnToProject(View.CurrentItemCommunityID, 0);
            }
        }
Beispiel #3
0
        private List <StandardActionType> GetAllowedStandardActionForFile(int idUser, ModuleObject source, ModuleObject destination)
        {
            List <StandardActionType> actions = new List <StandardActionType>();
            Person       person   = Manager.GetPerson(idUser);
            TaskListFile taskFile = Manager.Get <TaskListFile>(source.ObjectLongID);

            if (taskFile != null && taskFile.Link != null && destination.ObjectLongID == taskFile.File.Id && destination.FQN == taskFile.File.GetType().FullName)
            {
                int                  IdCommunity      = taskFile.CommunityOwner == null ? 0 : taskFile.CommunityOwner.Id;
                ModuleTasklist       modulePermission = ServicePermission(idUser, IdCommunity);
                CoreModuleRepository moduleRepository = GetCoreModuleRepository(idUser, IdCommunity);
                CoreItemPermission   itemPermission   = GetTaskPermission(person, taskFile.TaskOwner, modulePermission, moduleRepository);
                if (taskFile.File != null)
                {
                    if ((taskFile.File.IsInternal && itemPermission.AllowEdit) ||
                        (!taskFile.File.IsInternal && (moduleRepository.Administration || (moduleRepository.Edit && taskFile.File.Owner == person))))
                    {
                        actions.Add(StandardActionType.EditMetadata);
                    }
                    if (AllowViewFileFromLink(modulePermission, itemPermission, taskFile, person))
                    {
                        actions.Add(StandardActionType.Play);
                        actions.Add(StandardActionType.ViewPersonalStatistics);
                    }
                    if (taskFile.File.Owner == person || (taskFile.File.IsInternal && itemPermission.AllowEdit) || (!taskFile.File.IsInternal && (moduleRepository.Administration || moduleRepository.Edit)))
                    {
                        actions.Add(StandardActionType.ViewAdvancedStatistics);
                    }
                }
            }
            return(actions);
        }
Beispiel #4
0
        public CoreItemPermission GetItemPermissionFromLink(long IdLink)
        {
            CoreItemPermission permission = new CoreItemPermission();
            ModuleLink         link       = Manager.Get <ModuleLink>(IdLink);

            if (link == null)
            {
                return(permission);
            }
            else
            {
                TaskListFile taskFileLink = (from ifl in Manager.GetAll <TaskListFile>(ifl => ifl.Link == link && ifl.Deleted == BaseStatusDeleted.None) select ifl).Skip(0).Take(1).ToList().FirstOrDefault();
                if (taskFileLink == null || taskFileLink.TaskOwner == null)
                {
                    return(permission);
                }
                else
                {
                    int                  IdCommunity = taskFileLink.TaskOwner.Community == null ? 0 : taskFileLink.TaskOwner.Community.Id;
                    ModuleTasklist       moduleDiary = ServicePermission(UC.CurrentUserID, IdCommunity);
                    CoreModuleRepository repository  = GetCoreModuleRepository(UC.CurrentUserID, IdCommunity);
                    permission = GetTaskPermission(taskFileLink.TaskOwner, moduleDiary, repository);
                    return(permission);
                }
            }
        }
        public void InitView(Int32 idCommunity, String sourceModuleCode, Int32 sourceModuleIdAction, FileRepositoryType internalType, List <long> itemsToRemove)
        {
            View.IdCommunityRepository = idCommunity;
            View.InternalFileType      = internalType;
            View.SourceModuleIdAction  = sourceModuleIdAction;
            View.SourceModuleCode      = sourceModuleCode;
            View.UnloadItems           = itemsToRemove;
            View.CurrentAction         = UserRepositoryAction.None;
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout(idCommunity, CurrentManager.GetModuleID(sourceModuleCode));
            }
            else
            {
                if (internalType == FileRepositoryType.None || internalType == FileRepositoryType.CommunityFile)
                {
                    View.LoadErrorIDtype();
                }
                else
                {
                    CoreModuleRepository module = Service.ServicePermission(UserContext.CurrentUserID, idCommunity);
                    View.LoadAvailableActions(GetAvailableActions(module, idCommunity), UserRepositoryAction.SelectAction);

                    if (idCommunity > 0 && (module.Administration || module.UploadFile))
                    {
                        View.InitializeCommunityUploader(0, idCommunity, module);
                    }
                    View.InitializeInternalUploader(idCommunity);
                }
            }
        }
        private List <UserRepositoryAction> GetAvailableActions(CoreModuleRepository module, Int32 idCommunity)
        {
            List <UserRepositoryAction> actions = new List <UserRepositoryAction>();

            if (module.Administration || module.UploadFile)
            {
                actions.Add(UserRepositoryAction.CommunityUploadPlay);
            }
            if (module.Administration || module.UploadFile || module.ListFiles || module.DownLoad)
            {
                if (Service.HasItemType(idCommunity, UserContext.CurrentUserID, module.Administration, module.Administration, RepositoryItemType.FileStandard))
                {
                    actions.Add(UserRepositoryAction.LinkForDownload);
                }
                if (Service.HasItemType(idCommunity, UserContext.CurrentUserID, module.Administration, module.Administration, RepositoryItemType.Multimedia))
                {
                    actions.Add(UserRepositoryAction.LinkForMultimedia);
                }
                if (Service.HasItemType(idCommunity, UserContext.CurrentUserID, module.Administration, module.Administration, RepositoryItemType.ScormPackage))
                {
                    actions.Add(UserRepositoryAction.LinkForScorm);
                }
            }

            actions.Add(UserRepositoryAction.InternalUploadPlay);
            //actions.Add(ModuleToRepositoryAction.UploadFile);
            //actions.Add(ModuleToRepositoryAction.CreateFolder);
            return(actions);
        }
        private Boolean HasPermissionForRepository(BaseCommunityFile item, int IdUser, int IdCommunity, int idModule)
        {
            Boolean result = false;

            CoreModuleRepository permissions = new CoreModuleRepository(CurrentManager.GetModulePermission(IdUser, IdCommunity, idModule));

            result = Service.HasPermissionToSeeRepositoryItem(item.Id, permissions.Administration, permissions.Administration, IdUser);
            return(result);
        }
        private void LoadStepFolderSelector()
        {
            CoreModuleRepository module = Service.ServicePermission(UserContext.CurrentUserID, View.SelectedCommunityID);

            if (module.Administration || module.UploadFile)
            {
                if (View.SelectedFolderId <= (long)0)
                {
                    View.InitializeFolderSelector(View.SelectedCommunityID, 0, module.Administration);
                }
                View.ShowWizardStep(WizardStep.FolderSelector);
            }
        }
Beispiel #9
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);
        }
Beispiel #10
0
        private Boolean AllowViewTask(long itemId, int UserID, int communityID, int RoleID)
        {
            Boolean iResponse = false;
            Task    item      = GetTask(itemId);
            Person  person    = Manager.GetPerson(UserID);

            if (item != null)
            {
                communityID = item.Community == null ? 0 : item.Community.Id;
                lm.Comol.Modules.TaskList.ModuleTasklist modulePermission = ServicePermission(UserID, communityID);
                CoreModuleRepository moduleRepository = GetCoreModuleRepository(UserID, communityID);
                CoreItemPermission   itemPermission   = GetTaskPermission(person, item, modulePermission, moduleRepository);
                iResponse = (itemPermission.AllowView);
            }
            return(iResponse);
        }
 public void ChangeSelectedCommunity(int IdCommunity)
 {
     if (IdCommunity != View.SelectedCommunityID)
     {
         CoreModuleRepository module = Service.ServicePermission(UserContext.CurrentUserID, View.SelectedCommunityID);
         if (module.Administration || module.UploadFile)
         {
             View.InitializeFolderSelector(View.SelectedCommunityID, 0, module.Administration);
             View.ShowWizardStep(WizardStep.FolderSelector);
         }
     }
     else
     {
         View.ShowWizardStep(WizardStep.FolderSelector);
     }
 }
Beispiel #12
0
        public void InitView()
        {
            int IdCommunity = UserContext.CurrentCommunityID;

            View.CurrentItemCommunityID = IdCommunity;
            View.CurrentItemID          = 0;
            View.AllowCommunityLink     = false;
            if (UserContext.isAnonymous)
            {
                View.NoPermissionToManagementFiles(IdCommunity, ModuleID);
            }
            else
            {
                Task item = Service.GetTask(View.PreloadedItemID);
                if (item == null)
                {
                    View.SetBackToProject(IdCommunity, 0);
                    View.NoPermissionToManagementFiles(IdCommunity, ModuleID);
                }
                else
                {
                    IdCommunity = (item.Community == null ? 0 : item.Community.Id);
                    View.CurrentItemCommunityID = IdCommunity;
                    View.CurrentItemID          = item.ID;
                    CoreModuleRepository moduleRepository = Service.GetCoreModuleRepository(UserContext.CurrentUserID, IdCommunity);
                    CoreItemPermission   permission       = GetTaskPermission(IdCommunity, item, moduleRepository);
                    if (permission.AllowAddFiles)
                    {
                        View.AllowCommunityLink = (moduleRepository.Administration || moduleRepository.UploadFile || moduleRepository.ListFiles || moduleRepository.DownLoad);
                        //List<long> IdFiles = Service.GetItemRepositoryFilesId(item,false);
                        View.InitializeFileSelector(IdCommunity, Service.GetTaskRepositoryFiles(item, permission.AllowEdit && permission.AllowAddFiles), (moduleRepository.Administration), (moduleRepository.Administration));
                        View.SetBackToManagementUrl(IdCommunity, item.ID);
                    }
                    else if (permission.AllowEdit)
                    {
                        View.ReturnToTask(IdCommunity, item.ID);
                    }
                    else
                    {
                        View.SetBackToProject(IdCommunity, 0);
                        View.NoPermissionToManagementFiles(IdCommunity, ModuleID);
                    }
                }
            }
        }
Beispiel #13
0
        public void InitView()
        {
            int  IdCommunity     = UserContext.CurrentCommunityID;
            long preloadedItemId = View.PreloadedItemID;

            View.CurrentItemCommunityID = IdCommunity;
            if (!this.UserContext.isAnonymous)
            {
                Task item = Service.GetTask(preloadedItemId);
                if (item == null)
                {
                    View.NoPermissionToAddFiles(IdCommunity, ModuleID);
                }
                else
                {
                    IdCommunity = (item.Community == null ? 0 : item.Community.Id);
                    CoreModuleRepository moduleRepository = View.RepositoryPermission(IdCommunity);
                    CoreItemPermission   permission       = GetItemPermission(IdCommunity, item);
                    if (permission.AllowAddFiles)
                    {
                        View.AllowCommunityUpload = moduleRepository.Administration || moduleRepository.UploadFile;
                        if (moduleRepository.Administration || moduleRepository.UploadFile)
                        {
                            View.InitializeCommunityUploader(IdCommunity, moduleRepository);
                        }
                        View.InitializeModuleUploader(IdCommunity);
                        View.SetUrlToFileManagement(IdCommunity, item.ID);
                        View.SetUrlToDiary(IdCommunity, item.ID);
                        View.AllowUpload = true;
                        View.SendInitAction(IdCommunity, ModuleID, item.ID);
                        View.CurrentItemID          = item.ID;
                        View.CurrentItemCommunityID = IdCommunity;
                    }
                    else
                    {
                        View.ReturnToFileManagement(IdCommunity, preloadedItemId);
                    }
                }
            }
            else
            {
                View.NoPermissionToAddFiles(IdCommunity, ModuleID);
            }
        }
Beispiel #14
0
        private Boolean AllowEditMetadata(int UserID, int RoleID, ModuleObject source, ModuleObject destination)
        {
            Boolean iResponse = false;

            if (source.ObjectTypeID == (int)ModuleTasklist.ObjectType.TaskLinkedFile)
            {
                Person       person   = Manager.GetPerson(UserID);
                TaskListFile taskFile = Manager.Get <TaskListFile>(source.ObjectLongID);
                if (taskFile != null && taskFile.Link != null && destination.ObjectLongID == taskFile.File.Id && destination.FQN == taskFile.File.GetType().FullName)
                {
                    int                  IdCommunity      = taskFile.CommunityOwner == null ? 0 : taskFile.CommunityOwner.Id;
                    ModuleTasklist       modulePermission = ServicePermission(UserID, IdCommunity);
                    CoreModuleRepository moduleRepository = GetCoreModuleRepository(UserID, IdCommunity);
                    CoreItemPermission   itemPermission   = GetTaskPermission(person, taskFile.TaskOwner, modulePermission, moduleRepository);
                    iResponse = (taskFile.File.IsInternal && itemPermission.AllowEdit) ||
                                (!taskFile.File.IsInternal && (moduleRepository.Administration || (moduleRepository.Edit && taskFile.File.Owner == person)));
                }
            }
            return(iResponse);
        }
        public void ChangeAction(UserRepositoryAction action)
        {
            CoreModuleRepository module = Service.ServicePermission(UserContext.CurrentUserID, View.IdCommunityRepository);

            switch (action)
            {
            case UserRepositoryAction.LinkForDownload:
                View.InitializeFileSelector(View.IdCommunityRepository, View.UnloadItems, module.Administration, module.Administration, RepositoryItemType.FileStandard);
                break;

            case UserRepositoryAction.LinkForMultimedia:
                View.InitializeFileSelector(View.IdCommunityRepository, View.UnloadItems, module.Administration, module.Administration, RepositoryItemType.Multimedia);
                break;

            case UserRepositoryAction.LinkForScorm:
                View.InitializeFileSelector(View.IdCommunityRepository, View.UnloadItems, module.Administration, module.Administration, RepositoryItemType.ScormPackage);
                break;
            }
            View.DisplayAction(action);
        }
Beispiel #16
0
        private Boolean AllowDownloadFileLinkedToItem(long itemFileLinkId, int UserID, int communityID, int RoleID)
        {
            Boolean      iResponse = false;
            TaskListFile taskFile  = Manager.Get <TaskListFile>(itemFileLinkId);
            Person       person    = Manager.GetPerson(UserID);

            if (taskFile != null && taskFile.TaskOwner != null && taskFile.File != null && taskFile.Link != null)
            {
                Task task = taskFile.TaskOwner;
                communityID = task.Community == null ? 0 : task.Community.Id;
                lm.Comol.Modules.TaskList.ModuleTasklist modulePermission = ServicePermission(UserID, communityID);
                CoreModuleRepository moduleRepository = GetCoreModuleRepository(UserID, communityID);
                CoreItemPermission   itemPermission   = GetTaskPermission(person, task, modulePermission, moduleRepository);

                //permission.Download = itemFileLink.File.IsDownloadable && itemPermissions.AllowViewFiles;
                //permission.Play = (itemFileLink.File.isSCORM || itemFileLink.File.isVideocast) && itemPermissions.AllowViewFiles;

                iResponse = AllowViewFileFromLink(modulePermission, itemPermission, taskFile, person);
            }
            return(iResponse);
        }
Beispiel #17
0
        public void InitView()
        {
            int CommunityId = UserContext.CurrentCommunityID;

            if (UserContext.isAnonymous)
            {
                View.NoPermissionToManagementFiles(CommunityId, ModuleID);
            }

            else
            {
                //CommunityEventItem oItem = Service.GetEventItem(this.View.PreloadedItemID);
                Task oTask = Service.GetTask(this.View.PreloadedItemID);
                if (oTask == null)
                {
                    this.View.NoPermissionToManagementFiles(CommunityId, this.ModuleID);
                }
                else
                {
                    View.ItemID = oTask.ID;
                    lm.Comol.Modules.TaskList.ModuleTasklist module = new  ModuleTasklist();
                    if ((oTask.Community != null))
                    {
                        CommunityId = oTask.Community.Id;
                        module      = (from p in View.CommunitiesPermission where p.ID == oTask.Community.Id select p.Permissions).FirstOrDefault();
                        if (module == null)
                        {
                            module = new  ModuleTasklist();
                        }
                    }
                    else
                    {
                        CommunityId = 0;
                        module      = ModuleTasklist.CreatePortalmodule(UserContext.UserTypeID);
                    }

                    CoreModuleRepository moduleRepository = View.RepositoryPermission(CommunityId);
                    CoreItemPermission   oPermission      = Service.GetTaskPermission(oTask, module, moduleRepository);
                    if (oPermission.AllowAddFiles || oPermission.AllowEdit)
                    {
                        if (oTask.Community == null)
                        {
                            View.AllowCommunityUpload = false;
                            View.AllowCommunityLink   = false;
                        }
                        View.AllowCommunityUpload = oPermission.AllowEdit && (moduleRepository.Administration || moduleRepository.UploadFile);
                        View.AllowCommunityLink   = oPermission.AllowEdit && (moduleRepository.Administration || moduleRepository.UploadFile || moduleRepository.ListFiles || moduleRepository.DownLoad);
                        if (oPermission.AllowEdit && (moduleRepository.Administration || moduleRepository.UploadFile))
                        {
                            View.InitializeCommunityUploader(0, CommunityId, moduleRepository);
                        }
                        if (oPermission.AllowEdit)
                        {
                            View.InitializeModuleUploader(CommunityId);
                        }
                        View.AllowUpload = oPermission.AllowAddFiles;
                        //  this.View.BackToDiary = CommunityID;
                        View.SetBackToItemsUrl(CommunityId, oTask.ID);
                        View.SetBackToItemUrl(CommunityId, oTask.ID);
                        View.SetMultipleUploadUrl(oTask.ID);
                        LoadTaskFiles(oTask, oPermission);
                    }
                    else
                    {
                        this.View.ReturnToItemsList(CommunityId, oTask.ID);
                    }
                }
            }
            View.ItemCommunityId = CommunityId;
        }
Beispiel #18
0
 public bool HasPermissionToUploadIntoRepositoryFolder(long folderId, int personId, CoreModuleRepository module)
 {
     if (module.Administration || module.UploadFile)
     {
         return(true);
     }
     else
     {
         return(this.HasPermissionToUploadIntoRepositoryFolder(folderId, Manager.GetPerson(personId), module));
     }
 }
        public void InitView()
        {
            //Dim CurrentItemID As Long = Me.View.PreloadedItemID
            //Me.View.CurrentItemID = CurrentItemID
            //Dim oItem As CommunityEventItem = Me.CurrentManager.GetEventItem(CurrentItemID)
            //Dim CommunityID As Integer = Me.UserContext.CurrentCommunityID
            //If Not IsNothing(oItem) AndAlso Not IsNothing(oItem.CommunityOwner) Then
            //    CommunityID = oItem.CommunityOwner.Id
            //End If
            String ModuleOwnerCode = View.PreloadedModuleOwnerCode;
            int    ModuleOwnerID   = CurrentManager.GetModuleID(ModuleOwnerCode);

            View.ModuleOwnerCode = ModuleOwnerCode;
            View.ModuleOwnerID   = ModuleOwnerID;
            if (UserContext.isAnonymous || ModuleOwnerID == -1)
            {
                View.NoPermission(0, ModuleOwnerID == -1 ? ModuleID : ModuleOwnerID, ModuleOwnerID == -1 ? CoreModuleRepository.UniqueID : ModuleOwnerCode);
            }
            else
            {
                int IdCommunity = UserContext.CurrentCommunityID;
                View.SetBackUrl(View.PreloadedBackUrl);
                View.InitializeModuleInternalFileSelector(View.PreloadedItemId, View.PreloadedLinkId, ModuleOwnerCode);
                if (View.HasPermissionToSelectFile)
                {
                    IdCommunity = View.InternalFileSelectorIdCommunity;
                    CoreModuleRepository moduleRepository = new CoreModuleRepository();
                    if (IdCommunity > 0)
                    {
                        View.SelectedCommunityID = IdCommunity;
                        moduleRepository         = Service.ServicePermission(UserContext.CurrentUserID, IdCommunity);
                    }
                    else
                    {
                        View.SelectedCommunityID = -1;
                        View.InitializeCommunitySelector();
                        moduleRepository.UploadFile = (from p in View.RepositoryPermissions where p.Permissions.Administration || p.Permissions.UploadFile select p.ID).Any();
                    }
                    if (moduleRepository.UploadFile || moduleRepository.Administration)
                    {
                        View.SelectedFolderId = -1;
                        View.SendInitAction(IdCommunity, ModuleOwnerID, ModuleOwnerCode);
                    }
                    else
                    {
                        View.NoPermissionToPublishFiles(IdCommunity, ModuleOwnerID, ModuleOwnerCode);
                    }
                }

                //Me.View.BackToManagement = CurrentItemID
                //  If IsNothing(oItem) Then
                //      Me.View.NoPermissionToManagementFiles()
                //  ElseIf HasPermission(oItem) Then
                //      Dim oFilePermission As New ModuleCommunityRepository
                //      If IsNothing(oItem.CommunityOwner) Then
                //          Me.View.InitCommunitySelection()
                //          oFilePermission.UploadFile = (Me.View.CommunitySelectionLoaded)
                //      Else
                //          oFilePermission = Me.View.CommunityRepositoryPermission(oItem.CommunityOwner.Id)
                //      End If
                //      If Not (oFilePermission.Administration OrElse oFilePermission.UploadFile) Then
                //          Me.View.NoPermissionToPublishFiles()
                //      Else
                //          Me.View.SelectedFolder = -1
                //          Me.View.SendActionInit(CommunityID, ModuleID, oItem.Id)
                //          LoadFilesToPublish(oItem)
                //      End If
                //  Else
                //      Me.View.NoPermissionToPublishFiles()
                //  End If
            }
        }
        public void InitView()
        {
            int  IdCommunity       = UserContext.CurrentCommunityID;
            long idFile            = View.PreloadedFileId;
            BaseCommunityFile file = Service.GetItem(idFile);

            if (file != null && file.CommunityOwner != null)
            {
                IdCommunity = file.CommunityOwner.Id;
            }

            if (UserContext.isAnonymous)
            {
                View.SendToSessionExpiredPage(IdCommunity, UserContext.Language.Code);
            }
            else
            {
                View.BackUrl = View.PreloadedBackUrl;

                long moduleLinkId = View.PreloadedLinkId;
                View.ModuleLinkId = moduleLinkId;
                View.FileId       = idFile;
                if (idFile == 0 && moduleLinkId == 0)
                {
                    View.ShowUnkownFile(IdCommunity, ModuleID, CoreModuleRepository.UniqueID);
                }
                else
                {
                    Person     person = CurrentManager.GetPerson(UserContext.CurrentUserID);
                    ModuleLink link   = CurrentManager.Get <ModuleLink>(moduleLinkId);
                    ScormMetadataPermission permission = ScormMetadataPermission.none;
                    if (link == null && file == null)
                    {
                        View.ShowUnkownFile(IdCommunity, ModuleID, CoreModuleRepository.UniqueID);
                    }
                    else if (!file.isSCORM)
                    {
                        View.ShowNoScormFile(file.DisplayName);
                    }
                    else if ((link == null && file != null) || file.GetType() == typeof(CommunityFile))
                    {
                        IdCommunity = (file.CommunityOwner == null ? 0 : file.CommunityOwner.Id);
                        CoreModuleRepository module = Service.ServicePermission(UserContext.CurrentUserID, IdCommunity);
                        if (Service.HasPermissionToSeeRepositoryItem(idFile, module.Administration, module.Administration, UserContext.CurrentUserID))
                        {
                            permission = (module.Administration || (module.Edit && file.Owner == person)) ? ScormMetadataPermission.edit : ScormMetadataPermission.view;
                            View.InitializeMetadataControl(file.UniqueID, file.DisplayName, permission);
                        }
                        else
                        {
                            View.ShowNoPermissionToEditMetadata(IdCommunity, ModuleID, CoreModuleRepository.UniqueID, file.DisplayName);
                        }
                    }
                    else
                    {
                        IdCommunity = link.SourceItem.CommunityID;

                        ModuleObject linkedObject = ModuleObject.CreateLongObject(file.Id, file, (int)CoreModuleRepository.ObjectType.ScormPackage, IdCommunity, CoreModuleRepository.UniqueID);
                        permission = View.GetModuleLinkPermission(link.SourceItem.CommunityID, moduleLinkId, link.SourceItem, linkedObject, UserContext.CurrentUserID);
                        if (permission == ScormMetadataPermission.none)
                        {
                            View.ShowNoPermissionToEditMetadata(IdCommunity, link.SourceItem.ServiceID, link.SourceItem.ServiceCode, file.DisplayName);
                        }
                        else
                        {
                            View.InitializeMetadataControl(file.UniqueID, file.DisplayName, permission);
                        }
                    }
                }
            }
        }
Beispiel #21
0
        public bool HasPermissionToUploadIntoRepositoryFolder(long folderId, Person person, CoreModuleRepository module)
        {
            bool iResponse = module.Administration || module.UploadFile;

            if (!iResponse)
            {
                try
                {
                    Manager.BeginTransaction();
                    CommunityFile oFolder = Manager.Get <CommunityFile>(folderId);
                    if ((oFolder != null))
                    {
                        long AssignedPermission = 0;

                        Community community = oFolder.CommunityOwner;
                        if (community == null)
                        {
                            AssignedPermission = (from fa in Manager.Linq <CommunityFilePersonTypeAssignment>() where fa.File == oFolder && fa.Inherited && fa.AssignedTo == person.TypeID && (fa.File.isVisible || (!fa.File.isVisible && fa.File.Owner == person)) && fa.Deny == false select fa.Permission).FirstOrDefault();
                        }
                        else
                        {
                            Role oRole = (from s in Manager.Linq <Subscription>() where s.Community == community && s.Person == person && s.Accepted && s.Enabled select(Role) s.Role).FirstOrDefault();

                            AssignedPermission = (from fa in Manager.Linq <CommunityFileRoleAssignment>() where fa.File == oFolder && fa.AssignedTo == oRole && fa.Inherited && (fa.File.isVisible || (!fa.File.isVisible && fa.File.Owner == person)) && fa.Deny == false select fa.Permission).FirstOrDefault();
                        }
                        if (!((AssignedPermission & (long)CoreModuleRepository.Base2Permission.UploadFile) > 0))
                        {
                            AssignedPermission = AssignedPermission | (from fa in Manager.Linq <CommunityFileCommunityAssignment>() where fa.File == oFolder && fa.AssignedTo == community && fa.Inherited && (fa.File.isVisible || (!fa.File.isVisible && fa.File.Owner == person)) && fa.Deny == false select fa.Permission).FirstOrDefault();
                        }

                        if (!((AssignedPermission & (long)CoreModuleRepository.Base2Permission.UploadFile) > 0))
                        {
                            AssignedPermission = AssignedPermission | (from fa in Manager.Linq <CommunityFilePersonAssignment>() where fa.File == oFolder && fa.AssignedTo == person && fa.Inherited && (fa.File.isVisible || (!fa.File.isVisible && fa.File.Owner == person)) && fa.Deny == false select fa.Permission).FirstOrDefault();
                        }
                        iResponse = ((AssignedPermission & (long)CoreModuleRepository.Base2Permission.UploadFile) > 0);
                    }
                    Manager.Commit();
                }
                catch (Exception ex)
                {
                    if (Manager.IsInTransaction())
                    {
                        Manager.RollBack();
                    }
                }
            }
            return(iResponse);
        }
Beispiel #22
0
        public CoreItemPermission GetTaskPermission(Person person, Task oItem, ModuleTasklist Permission, CoreModuleRepository repository)
        {
            CoreItemPermission iResponse = new CoreItemPermission();

            iResponse.AllowView      = Permission.Administration || Permission.ViewTaskList;
            iResponse.AllowViewFiles = (Permission.ViewTaskList && (oItem.MetaInfo.CreatedBy == person)) || Permission.Administration;
            //iResponse. = Permission.Administration;
            iResponse.AllowAddFiles       = (oItem.MetaInfo.CreatedBy == person) || Permission.Administration || Permission.UploadFile;
            iResponse.AllowDelete         = (oItem.MetaInfo.CreatedBy == person) || Permission.Administration;
            iResponse.AllowEdit           = (oItem.MetaInfo.CreatedBy == person) || Permission.Administration;
            iResponse.AllowVirtualDelete  = iResponse.AllowDelete;
            iResponse.AllowUnDelete       = (oItem.MetaInfo.CreatedBy == person) || Permission.Administration;
            iResponse.AllowViewStatistics = iResponse.AllowViewFiles;
            iResponse.AllowFilePublish    = (repository != null && (repository.Administration || repository.UploadFile));
            return(iResponse);
        }
Beispiel #23
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);
        }
        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);
            }
        }
Beispiel #25
0
        public CoreItemPermission GetTaskPermission(Task oTask, ModuleTasklist Permission, CoreModuleRepository repository)
        {
            Person oPerson = Manager.GetPerson(UC.CurrentUserID);

            return(GetTaskPermission(oPerson, oTask, Permission, repository));
        }
Beispiel #26
0
        private dtoTask CreateDtoTaskForStatistics(Person person, Task item, Boolean allVisibleItems, ModuleTasklist module, CoreModuleRepository repository)
        {
            dtoTask dtoItem = new dtoTask();

            dtoItem.oTask.Project = item;
            dtoItem.Permission    = GetTaskPermission(person, item, module, repository);
            dtoItem.FileLinks     = GetCoreItemFileLinkPermission(dtoItem.Permission, (from fl in GetTaskFiles(item, false) where (allVisibleItems || (fl.isVisible || (!fl.isVisible && fl.Owner == person))) select fl).ToList(), null, person);
            dtoItem.Id            = item.ID;
            //dtoItem.LessonNumber = lessionID;

            //lessionID += 1;
            return(dtoItem);
        }
Beispiel #27
0
        private dtoTask CreateDtoTask(Person person, Task item, Boolean allVisibleItems, ModuleTasklist module, CoreModuleRepository repository, ref int lessionID)
        {
            dtoTask dtoItem = new dtoTask();

            dtoItem.CommunityId = (item.Community == null ? 0 : item.Community.Id);
            dtoItem.Description = (from d in Manager.Linq <DescriptionEventItem>() where d.Id == item.ID select d.Description).FirstOrDefault();
            dtoItem.oTask       = item;
            dtoItem.Permission  = GetTaskPermission(person, item, module, repository);
            dtoItem.FileLinks   = GetCoreItemFileLinkPermission(dtoItem.Permission, (from fl in GetTaskFiles(item, false) where (allVisibleItems || (fl.isVisible || (!fl.isVisible && fl.Owner == person))) select fl).ToList(), null, person);
            dtoItem.Id          = item.ID;
            //dtoItem.LessonNumber = lessionID;


            // // Posso vedere la voce
            // iResponse.Permission = new CoreItemPermission();
            // //iResponse.Permission.Delete = ModulePermission.Administration || (ModulePermission.DeleteItem && isItemOwner);
            // iResponse.Permission.AllowViewFiles = module.Administration || module.ViewDiaryItems;
            // iResponse.Permission.AllowEdit = module.Administration || (module.Edit && isItemOwner);
            //// iResponse.Permission.UnDelete = ModulePermission.Administration || (ModulePermission.DeleteItem && isItemOwner);
            // iResponse.Permission.AllowView = module.Administration || module.ViewDiaryItems || (module.Edit && isItemOwner);

            // TO INSERT FOR VIRTUAL DELETE !!

            // iResponse.EventItem = item;
            // iResponse.LessonNumber = lessionID;

            lessionID += 1;
            return(dtoItem);
            //oHeaderTitle,
        }
Beispiel #28
0
        //Public Function GetDiaryItemsListWithPermission(ByVal UserID As Integer, ByVal CommunityID As Integer, ByVal ModulePermission As ModuleCommunityDiary, ByVal Ascending As Boolean, ByVal ItemVisibility As ObjectStatus) As List(Of dtoDiaryItem)
        //Dim oReturnList As List(Of dtoDiaryItem) = New List(Of dtoDiaryItem)
        //If CommunityID > 0 AndAlso Not oCommunity Is Nothing OrElse CommunityID = 0 Then
        //    Dim oList As List(Of CommunityEventItem) = Me.GetDiaryItems(oCommunity, oPerson, ItemVisibility)
        //    If Not IsNothing(oList) AndAlso oList.Count > 0 Then
        //        Dim LessionID As Integer = 1

        //        oReturnList = (From di In oList Select Me.CreateDTOdiaryItem(oPerson, di, ModulePermission, LessionID)).ToList

        //        If Not Ascending Then
        //            oReturnList = oReturnList.OrderByDescending(Function(i) i.LessonNumber).ToList
        //        End If
        //    End If

        //End If
        //Return oReturnList

        public List <dtoDiaryItem> GetDtoDiaryItems(int idCommunity, Boolean ascendingLesson, ModuleTasklist module, CoreModuleRepository repository, Boolean allVisibleItems)
        {
            List <dtoDiaryItem> items = new List <dtoDiaryItem>();

            //Person person = Manager.GetPerson(UC.CurrentUserID);
            ////CommunityEventType eventType = GetDiaryEventType();
            //Community community = Manager.GetCommunity(idCommunity);
            //if (community!=null && person != null){
            //    int lessnoNumber = 1;
            //    items = ( from item in CommunityTasksQuery(community ,person,allVisibleItems).ToList()
            //              select CreateDtoDiaryItem(person,item,allVisibleItems,module,repository,ref lessnoNumber)).ToList();
            //    if (!ascendingLesson)
            //        items = items.OrderByDescending(i=> i.LessonNumber).ToList();
            //}
            return(items);
        }
Beispiel #29
0
        //public bool AddAttachment(Int64 MessageId, bool IsVisible)
        //{
        //    Domain.Message msg = service.MessageGet(MessageId);
        //    if (msg == null || msg.Ticket == null) return false;

        //    List<lm.Comol.Core.BaseModules.Tickets.TicketService.TmpTkAttachment> attachment =
        //        service.AttachmentsAddFiles(msg, View.UploadFiles(MessageId, msg.Ticket.Id));

        //    //files = View.UploadFiles(project);
        //    return false;
        //}


        public void InitView(long idProject, long idActivity, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions action, Int32 idCommunity = -1, CoreModuleRepository rPermissions = null)
        {
            if (!UserContext.isAnonymous)
            {
                //View.CurrentAction = action;
                //View.IdProject = idProject;
                //View.IdActivity = idActivity;
                //View.IdProjectCommunity = idCommunity;
                switch (action)
                {
                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.addurltomoduleitem:

                    //View.InitializeUploaderControl(action, idCommunity);
                    break;

                //case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem:
                //    if (idCommunity > 0)
                //        //View.InitializeUploaderControl(action, idCommunity);
                //    break;
                //case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.linkfromcommunity:
                //    if (rPermissions != null && idCommunity > 0)
                //        //View.InitializeLinkRepositoryItems(rPermissions, idCommunity, Service.AttachmentsGetLinkedFiles(idProject, idActivity));
                //    // View.InitializeUploaderControl(idCommunity);
                //    break;
                //case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity:
                //    if (rPermissions != null && idCommunity > 0)
                //        //View.InitializeCommunityUploader(rPermissions, idCommunity);
                //    break;
                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.addurltomoduleitemandcommunity:
                    break;
                }
            }
            else
            {
            }
            //View.CurrentAction = Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none;
        }
Beispiel #30
0
        private List <dtoTask> GetDtoTasksForStatistics(Community community, Person person, ModuleTasklist module, CoreModuleRepository repository, Boolean allVisibleItems)
        {
            List <dtoTask> items = new List <dtoTask>();

            ////CommunityEventType eventType = GetDiaryEventType();
            //if (community != null && person != null)
            //{
            //    int lessonNumber = 1;
            //    items = (from item in CommunityTasksQuery(community, person, allVisibleItems).ToList()
            //             select CreateDtoTaskForStatistics(person, item, allVisibleItems, module, repository, ref lessonNumber)).ToList();
            //}
            return(items);
        }