private void InternalLoadDiaryItems(ModuleCommunityDiary module, Int32 idCommunity, Int32 idModule, String unknownUser)
        {
            lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier       = lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier.Create((idCommunity > 0 ? lm.Comol.Core.FileRepository.Domain.RepositoryType.Community :  lm.Comol.Core.FileRepository.Domain.RepositoryType.Portal), idCommunity);
            lm.Comol.Core.FileRepository.Domain.ModuleRepository     moduleRepository = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
            List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> availableActions = Service.GetAvailableUploadActions(module, moduleRepository);

            lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions dAction = (availableActions == null || !availableActions.Any()) ? lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none : availableActions.FirstOrDefault();
            View.RepositoryIdentifier = identifier;
            View.InitializeAttachmentsControl(availableActions, dAction);
            List <dtoDiaryItem> items = Service.GetDtoDiaryItems(idCommunity, View.DisplayOrderAscending, module, moduleRepository, (module.Administration || module.Edit), availableActions, dAction, unknownUser);


            View.AllowAddItem     = module.Administration || module.AddItem;
            View.AllowPrint       = module.PrintList;
            View.AllowDeleteDiary = module.Administration;
            if (module.Administration || module.AddItem)
            {
                View.SetAddItemUrl(idCommunity);
            }
            int ItemsCountForDelete = (from item in items where item.Permission.AllowDelete select item.Id).Count();

            View.AllowItemsSelection = ((module.Administration || module.Edit || module.DeleteItem) && ItemsCountForDelete > 0);
            View.AllowMultipleDelete = ((module.Administration || module.Edit || module.DeleteItem) && ItemsCountForDelete > 0);
            View.LoadItems(items, idCommunity, idModule);
        }
Beispiel #2
0
        public void AttachmentsAddAlsoToCommunity(
            Domain.DTO.DTO_Ticket TkData,
            Domain.Enums.MailSettings ownerSettings,
            Domain.Enums.MailSettings creatorSettings,
            Boolean alwaysLastVersion)
        {
            if (!this.SaveTicket(TkData, ownerSettings, creatorSettings, true))
            {
                return;
            }

            Domain.Message Msg = service.MessageGetFromTicketDraft(TkData.TicketId, TkData.CreatorId);

            if (Msg == null || View.DraftMsgId != Msg.Id)
            {
                return;
            }

            int UserID = (this.UserContext != null) ? UserContext.CurrentUserID : 0;

            lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(CurrentCommunityId, UserID);
            List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(MessageUserType.Partecipant, CurrentCommunityId, UserContext.CurrentUserID, cRepository);

            if (!actions.Contains(lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity))
            {
                return;
            }

            //service.MessageDraftUpdate(HtmlText, PreviewText, View.CurrentTicketId, View.DraftMsgId);
            //-------------------------------------------------------------------------------------
            service.AttachmentsAddFiles(View.DraftMsgId, View.GetUploadedItems(Msg, RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity));
            //-------------------------------------------------------------------------------------

            this.InitView();
        }
Beispiel #3
0
        public void AttachmentsAddAlsoToCommunity(String HtmlText, String PreviewText)
        {
            Domain.DTO.DTO_ManagerModify Data = FileUpdateMessage(HtmlText, PreviewText);

            if (Data == null)
            {
                return;
            }

            int CommunityID = (this.UserContext != null) ? UserContext.CurrentCommunityID : 0;
            int UserID      = (this.UserContext != null) ? UserContext.CurrentUserID : 0;

            lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(CommunityID, UserID);

            List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(Data.CurrentUserType, CommunityID, UserID, cRepository);

            if (!actions.Contains(lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity))
            {
                return;
            }

            //-------------------------------------------------------------------------------------
            service.AttachmentsAddFiles(View.DraftMsgId, View.GetUploadedItems(Data.DraftMessage, DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity));
            //-------------------------------------------------------------------------------------

            this.InitView();
        }
Beispiel #4
0
        List <StandardActionType> GetAllowedStandardActionForRepository(PermissionEP permission, List <StandardActionType> actions, long idItem, int idUser, int IdCommunity)
        {
            lm.Comol.Core.FileRepository.Domain.ModuleRepository   moduleRepository = GetCoreModuleRepository(idUser, IdCommunity);
            lm.Comol.Core.FileRepository.Domain.liteRepositoryItem item             = Manager.Get <lm.Comol.Core.FileRepository.Domain.liteRepositoryItem>(idItem);

            if (item != null)
            {
                Boolean isPlayFile = (item.Type == Core.FileRepository.Domain.ItemType.ScormPackage || item.Type == Core.FileRepository.Domain.ItemType.Multimedia || item.Type == Core.FileRepository.Domain.ItemType.VideoStreaming);
                if (!item.IsInternal)
                {
                    if (isPlayFile && moduleRepository.Administration || moduleRepository.ManageItems || moduleRepository.EditOthersFiles || (moduleRepository.UploadFile && item.IdOwner == idUser))
                    {
                        actions.Add(StandardActionType.EditMetadata);
                    }
                    else if (moduleRepository.Administration || moduleRepository.ManageItems || moduleRepository.EditOthersFiles || (moduleRepository.UploadFile && item.IdOwner == idUser))
                    {
                        actions.Remove(StandardActionType.ViewAdvancedStatistics);
                        actions.Remove(StandardActionType.ViewUserStatistics);
                        actions.Remove(StandardActionType.ViewPersonalStatistics);
                    }
                }
                else if (isPlayFile && (permission.Create || permission.Update))
                {
                    actions.Add(StandardActionType.EditMetadata);
                }
            }
            return(actions.Distinct().ToList());
        }
        //private void LoadAttachments(long idProject, ModuleProjectManagement mPermission, PmActivityPermission pPermissions) {
        //    LoadAttachments(idProject,mPermission,pPermissions,(mPermission.Administration && !project.isPersonal) || (pPermissions & PmActivityPermission.ManageProject) == PmActivityPermission.ManageProject) || (pPermissions & PmActivityPermission.AddAttachments) == PmActivityPermission.AddAttachments);
        //}
        private void LoadAttachments(String unknownUser, long idProject, Boolean isPersonal, Int32 idCommunity, ModuleProjectManagement mPermission, PmActivityPermission pPermissions, Boolean allowAdd, ModuleProjectManagement.ActionType dAction = ModuleProjectManagement.ActionType.ProjectAttachmentsLoad)
        {
            View.SendUserAction(idCommunity, CurrentIdModule, idProject, dAction);

            lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = Service.GetRepositoryPermissions(idCommunity);
            List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> availableActions = Service.AttachmentsGetAvailableUploadActions((mPermission.Administration && !isPersonal), pPermissions, cRepository);

            View.AllowSave = allowAdd && availableActions.Any();
            View.InitializeAttachmentsControl(View.RepositoryIdentifier, cRepository, availableActions, Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem);
            View.LoadAttachments(Service.GetProjectAttachments(idProject, 0, false, unknownUser));
        }
Beispiel #6
0
        private void ReloadAttachments(litePerson person, CommunityEventItem item, ModuleCommunityDiary module, lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier, String unknownUser)
        {
            long idEvent = (item.EventOwner != null ? item.EventOwner.Id : 0);

            lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
            List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> availableActions = Service.GetAvailableUploadActions(module, moduleRepository);

            lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions dAction = (availableActions == null || !availableActions.Any()) ? lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none : availableActions.FirstOrDefault();
            View.InitializeAttachmentsControl(idEvent, item.Id, availableActions, dAction);

            View.LoadAttachments(Service.AttachmentsGet(person, item, true, Service.GetItemPermission(person, item, module, moduleRepository), moduleRepository, unknownUser));
        }
        private Boolean AllowViewDiaryItem(long idItem, Int32 idUser)
        {
            Boolean            iResponse = false;
            CommunityEventItem item      = EventItemGet(idItem);
            litePerson         person    = Manager.GetLitePerson(idUser);

            if (item != null)
            {
                ModuleCommunityDiary modulePermission = GetPermissions(idUser, item.IdCommunityOwner);
                lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = GetCoreModuleRepository(idUser, item.IdCommunityOwner);
                CoreItemPermission itemPermission = GetItemPermission(person, item, modulePermission, moduleRepository);
                iResponse = (itemPermission.AllowView);
            }
            return(iResponse);
        }
        private Boolean AllowEditMetadata(Int32 idUser, Int32 idRole, ModuleObject source, ModuleObject destination)
        {
            Boolean iResponse = false;

            if (source.ObjectTypeID == (int)ModuleCommunityDiary.ObjectType.DiaryItemLinkedFile)
            {
                litePerson    person     = Manager.GetLitePerson(idUser);
                EventItemFile attachment = Manager.Get <EventItemFile>(source.ObjectLongID);
                if (attachment != null && attachment.Link != null && attachment.Item != null && source.ObjectLongID == attachment.Id)
                {
                    ModuleCommunityDiary modulePermission = GetPermissions(idUser, attachment.IdCommunity);
                    lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = GetCoreModuleRepository(idUser, attachment.IdCommunity);
                    CoreItemPermission itemPermission = GetItemPermission(person, EventItemGet(attachment.IdItemOwner), modulePermission, moduleRepository);
                    iResponse = ((attachment.Item.Type == Core.FileRepository.Domain.ItemType.ScormPackage || attachment.Item.Type == Core.FileRepository.Domain.ItemType.Multimedia) && (attachment.Item.Availability == Core.FileRepository.Domain.ItemAvailability.available || attachment.Item.Availability == Core.FileRepository.Domain.ItemAvailability.waitingsettings) && ((attachment.Item.IsInternal && itemPermission.AllowEdit) ||
                                                                                                                                                                                                                                                                                                                                                                                    (!attachment.Item.IsInternal && (moduleRepository.Administration || moduleRepository.EditOthersFiles || (moduleRepository.EditMyFiles && attachment.Item.IdOwner == person.Id)))));
                }
            }
            return(iResponse);
        }
        private Boolean AllowDownloadFileLinkedToItem(long idAttachment, Int32 idUser)
        {
            Boolean       iResponse  = false;
            EventItemFile attachment = Manager.Get <EventItemFile>(idAttachment);
            litePerson    person     = Manager.GetLitePerson(idUser);

            if (attachment != null && attachment.Item != null && attachment.Link != null)
            {
                CommunityEventItem item = EventItemGet(attachment.IdItemOwner);
                if (item != null)
                {
                    ModuleCommunityDiary modulePermission = GetPermissions(idUser, attachment.IdCommunity);
                    lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = GetCoreModuleRepository(idUser, attachment.IdCommunity);
                    CoreItemPermission itemPermission = GetItemPermission(person, EventItemGet(attachment.IdItemOwner), modulePermission, moduleRepository);
                    iResponse = AllowViewFileFromLink(modulePermission, itemPermission, attachment, person) && (attachment.Item.IsDownloadable || (attachment.Item.IdOwner == idUser && attachment.Item.Availability != Core.FileRepository.Domain.ItemAvailability.notavailable));
                }
            }
            return(iResponse);
        }
Beispiel #10
0
        public void AttachmentsLinkFromCommunity(Domain.DTO.DTO_Ticket TkData,
                                                 Domain.Enums.MailSettings ownerSettings,
                                                 Domain.Enums.MailSettings creatorSettings,
                                                 List <ModuleActionLink> links)
        {
            if (!this.SaveTicket(TkData, ownerSettings, creatorSettings, true))
            {
                return;
            }

            Domain.Message Msg = service.MessageGetFromTicketDraft(TkData.TicketId, TkData.CreatorId);

            if (Msg == null || View.DraftMsgId != Msg.Id)
            {
                return;
            }

            int UserID = (this.UserContext != null) ? UserContext.CurrentUserID : 0;

            lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(CurrentCommunityId, UserID);

            List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(MessageUserType.Partecipant, CurrentCommunityId, UserContext.CurrentUserID, cRepository);

            if (!actions.Contains(lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.linkfromcommunity))
            {
                return;
            }

            IList <Domain.TicketFile> attachments = service.AttachmentsLinkFiles(View.DraftMsgId, links);
            int addedfiles = 0;

            if (attachments != null)
            {
                addedfiles = attachments.Count();
            }

            this.InitView();
        }
        private List <StandardActionType> GetAllowedStandardActionForFile(int idUser, ModuleObject source, ModuleObject destination)
        {
            List <StandardActionType> actions = new List <StandardActionType>();
            litePerson    person     = Manager.GetLitePerson(idUser);
            EventItemFile attachment = Manager.Get <EventItemFile>(source.ObjectLongID);

            if (attachment != null && attachment.Link != null && source.ObjectLongID == attachment.Id)
            {
                ModuleCommunityDiary modulePermission = GetPermissions(idUser, attachment.IdCommunity);
                lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = GetCoreModuleRepository(idUser, attachment.IdCommunity);
                CoreItemPermission itemPermission = GetItemPermission(person, EventItemGet(attachment.IdItemOwner), modulePermission, moduleRepository);

                if (attachment.Item != null)
                {
                    Boolean isMultimedia = attachment.Item.Type == Core.FileRepository.Domain.ItemType.Multimedia;
                    Boolean isScorm      = attachment.Item.Type == Core.FileRepository.Domain.ItemType.ScormPackage;
                    Boolean isInternal   = attachment.Item.IsInternal;
                    if ((isScorm || isMultimedia) && (attachment.Item.Availability == Core.FileRepository.Domain.ItemAvailability.available || attachment.Item.Availability == Core.FileRepository.Domain.ItemAvailability.waitingsettings) && ((isInternal && itemPermission.AllowEdit) ||
                                                                                                                                                                                                                                                (!isInternal && (moduleRepository.Administration || moduleRepository.EditOthersFiles || (moduleRepository.EditMyFiles && attachment.Item.IdOwner == person.Id)))))
                    {
                        actions.Add(StandardActionType.EditMetadata);
                    }
                    if (AllowViewFileFromLink(modulePermission, itemPermission, attachment, person))
                    {
                        actions.Add(StandardActionType.Play);
                        if (isScorm)
                        {
                            actions.Add(StandardActionType.ViewPersonalStatistics);
                        }
                    }
                    if ((isScorm && attachment.Item.Availability == Core.FileRepository.Domain.ItemAvailability.available) && ((isInternal && itemPermission.AllowEdit) || (!isInternal && (moduleRepository.Administration || moduleRepository.EditOthersFiles || (moduleRepository.EditMyFiles && attachment.Item.IdOwner == person.Id)))))
                    {
                        actions.Add(StandardActionType.ViewAdvancedStatistics);
                    }
                }
            }
            return(actions);
        }
 public void InitView(long idCall, CallForPaperType type, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions action, lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier, lm.Comol.Core.FileRepository.Domain.ModuleRepository rPermissions = null)
 {
     if (!UserContext.isAnonymous)
     {
         View.CurrentAction   = action;
         View.IdCall          = idCall;
         View.CallType        = type;
         View.IdCallCommunity = identifier.IdCommunity;
         switch (action)
         {
         case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem:
             View.InitializeUploaderControl(action, identifier);
             break;
         }
     }
     else
     {
         View.CurrentAction = Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none;
     }
 }
Beispiel #13
0
        private dtoDiaryItem CreateDtoDiaryItem(litePerson person, CommunityEventItem item, Boolean viewAlsoDeleted, ModuleCommunityDiary module, lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository, ref int lessionID, List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions dAction, String unknownUser)
        {
            dtoDiaryItem dtoItem = new dtoDiaryItem();

            dtoItem.CommunityId = item.IdCommunityOwner;
            DescriptionEventItem dObject = EventItemGetDescriptionObject(item.Id);

            if (dObject != null)
            {
                dtoItem.Description      = dObject.Description;
                dtoItem.DescriptionPlain = dObject.DescriptionPlain;
            }
            else
            {
                dtoItem.Description      = "";
                dtoItem.DescriptionPlain = "";
            }
            dtoItem.EventItem           = item;
            dtoItem.Permission          = GetItemPermission(person, item, module, moduleRepository);
            dtoItem.UploadActions       = actions;
            dtoItem.DefaultUploadAction = dAction;
            dtoItem.Attachments         = AttachmentsGet(person, item, viewAlsoDeleted, dtoItem.Permission, moduleRepository, unknownUser).Where(a => a.Attachment.File != null && a.Attachment.File.IsValid).ToList();
            dtoItem.Id           = item.Id;
            dtoItem.IdEvent      = (item.EventOwner != null ? item.EventOwner.Id : 0);
            dtoItem.LessonNumber = lessionID;
            lessionID           += 1;
            return(dtoItem);
        }
        public void InitView(long idProject, long idActivity, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions action, lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier, lm.Comol.Core.FileRepository.Domain.ModuleRepository rPermissions = null)
        {
            if (!UserContext.isAnonymous)
            {
                View.CurrentAction      = action;
                View.IdProject          = idProject;
                View.IdActivity         = idActivity;
                View.IdProjectCommunity = identifier.IdCommunity;
                switch (action)
                {
                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.addurltomoduleitem:

                    View.InitializeUploaderControl(action, identifier);
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem:
                    View.InitializeUploaderControl(action, identifier);
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.linkfromcommunity:
                    if (rPermissions != null && identifier.IdCommunity > 0)
                    {
                        View.InitializeLinkRepositoryItems(UserContext.CurrentUserID, rPermissions, identifier, Service.AttachmentsGetBaseLinkedFiles(idProject, idActivity));
                    }
                    // View.InitializeUploaderControl(idCommunity);
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity:
                    if (rPermissions != null && identifier.IdCommunity > 0)
                    {
                        View.InitializeCommunityUploader(identifier);
                    }
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.addurltomoduleitemandcommunity:
                    break;
                }
            }
            else
            {
                View.CurrentAction = Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none;
            }
        }
Beispiel #15
0
        public CoreItemPermission GetItemPermission(litePerson person, CommunityEventItem item, ModuleCommunityDiary modulePermissions, lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository)
        {
            CoreItemPermission iResponse = new CoreItemPermission();

            if (item != null)
            {
                Boolean AllowInternalEdit = item.AllowEdit;
                iResponse.AllowViewFiles = (modulePermissions.ViewDiaryItems && (item.IsVisible || (item.IsVisible == false && item.Owner != null && item.Owner == person))) || modulePermissions.Administration;
                iResponse.AllowAddFiles  = AllowInternalEdit && ((item.Owner != null && item.Owner == person) || modulePermissions.Administration || modulePermissions.UploadFile);
                iResponse.AllowDelete    = AllowInternalEdit && ((modulePermissions.DeleteItem && item.Owner != null && item.Owner == person) || modulePermissions.Administration);
                iResponse.AllowEdit      = AllowInternalEdit && ((modulePermissions.DeleteItem && item.Owner != null && item.Owner == person) || modulePermissions.Administration);
                iResponse.AllowUnDelete  = AllowInternalEdit && ((modulePermissions.DeleteItem && item.Owner != null && item.Owner == person) || modulePermissions.Administration);
            }

            iResponse.AllowView           = modulePermissions.Administration || modulePermissions.ViewDiaryItems;
            iResponse.AllowVirtualDelete  = iResponse.AllowDelete;
            iResponse.AllowViewStatistics = iResponse.AllowViewFiles;
            iResponse.AllowFilePublish    = (moduleRepository != null && (moduleRepository.Administration || moduleRepository.UploadFile));
            return(iResponse);
        }
Beispiel #16
0
        public CoreItemPermission GetItemPermission(CommunityEventItem item, ModuleCommunityDiary modulePermissions, lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository)
        {
            litePerson person = Manager.GetLitePerson(UC.CurrentUserID);

            return(GetItemPermission(person, item, modulePermissions, moduleRepository));
        }
Beispiel #17
0
        public void InitView()
        {
            //Nascondo messaggi. Saranno eventualmente visualizzati in seguito all'InitView o internamente.
            View.ShowSendError(TicketMessageSendError.none);
            if (!CheckSessionAccess())
            {
                return;
            }

            //int ComId = UserContext.CurrentCommunityID;
            int PersonId = UserContext.CurrentUserID;


            if (View.ViewCommunityId != CurrentCommunityId)
            {
                View.ViewCommunityId = CurrentCommunityId;
            }

            Domain.DTO.DTO_UserModify Data = service.TicketGetUser(View.TicketId);


            //Repository 4 upload

            lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(CurrentCommunityId, PersonId);

            List <RepositoryAttachmentUploadActions> actions = service.UploadAvailableActionsGet(
                Data.CurrentUserType,
                CurrentCommunityId,
                PersonId,
                cRepository);


            //List<iCoreItemFileLink<long>> alreadyLinkedFiles = new List<iCoreItemFileLink<long>>();

            //if (Data.DraftMessage != null && Data.DraftMessage.Attachments.Any())
            //{
            //    alreadyLinkedFiles = (from Domain.TicketFile fl in Data.DraftMessage.Attachments
            //                          where fl.File != null && fl.Link != null
            //                          select new dtoCoreItemFileLink<long>()
            //                          {
            //                              CreatedBy = fl.CreatedBy,
            //                              CreatedOn = fl.CreatedOn,
            //                              Deleted = fl.Deleted,
            //                              ItemFileLinkId = fl.Id,
            //                              StatusId = 0,
            //                              Link = fl.Link,
            //                              ModifiedBy = fl.ModifiedBy,
            //                              ModifiedOn = fl.ModifiedOn,
            //                              Owner = fl.CreatedBy,
            //                              isVisible = (fl.Deleted == BaseStatusDeleted.None && !fl.File.isDeleted),
            //                              File = fl.File
            //                          }).ToList<iCoreItemFileLink<long>>();
            //    // && fl.Visibility == Domain.Enums.FileVisibility.visible
            //    //NO: se non è visibile, non lo è per l'utente, manager e resolver lo possono vedere E comunque non posso linkarlo nuovamente.
            //}
            ////if (alreadyLinkedFiles == null)
            ////    alreadyLinkedFiles = new List<iCoreItemFileLink<long>>();

            RepositoryAttachmentUploadActions dAction = RepositoryAttachmentUploadActions.none;

            View.InitView(Data, actions, dAction, cRepository, CurrentCommunityId, (Data.DraftMessage == null ? 0 : Data.DraftMessage.Id));


            if (Data.Errors == Domain.Enums.TicketEditUserErrors.none)
            {
                //Begin Action
                List <KeyValuePair <int, String> > Objects = new List <KeyValuePair <int, string> >();
                Objects.Add(ModuleTicket.KVPgetUser(service.UserGetIdfromPerson(UserContext.CurrentUserID)));
                Objects.Add(ModuleTicket.KVPgetTicket(View.TicketId));

                View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.TicketLoadEditUser, CurrentCommunityId,
                                     ModuleTicket.InteractionType.UserWithLearningObject, Objects);
                //End Action
                View.TicketId = Data.TicketId;

                View.DraftMsgId = (Data.DraftMessage != null) ? Data.DraftMessage.Id : -1;

                if (Data.BehalfRevoked)
                {
                    View.ShowBehalfError(BehalfError.permissionRevoked);
                }
                else
                {
                    View.ShowBehalfError(BehalfError.none);
                }
            }
            else
            {
                if (Data.Errors == Domain.Enums.TicketEditUserErrors.NoPermission)
                {
                    View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, CurrentCommunityId, ModuleTicket.InteractionType.None);
                }
                View.ShowBehalfError(BehalfError.NoPermission);
            }

            //View.ShowInitError(Data.Errors);
        }
Beispiel #18
0
        public void InitView()
        {
            if (!CheckSessionAccess())
            {
                return;
            }
            //Boolean IsNewAndOtherTicket = false;


            Domain.DTO.DTO_AddInit values = new Domain.DTO.DTO_AddInit();

            //Utente
            Domain.TicketUser Usr = service.UserGetfromPerson(UserContext.CurrentUserID);
            if (Usr == null)
            {
                View.DisplaySessionTimeout(View.ViewCommunityId);
                return;
            }

            Domain.Enums.TicketAddCondition Cond = service.PermissionTicketUsercanCreate();

            if (Cond == Domain.Enums.TicketAddCondition.CheckCount &&
                service.TicketGetNumOpen(Usr.Id) >= Access.MaxSended)
            {
                View.ShowCantCreate(Domain.Enums.CantCreate.MaxSend);
            }

            int DraftNum = service.TicketGetNumDraft(Usr.Id);

            //DDL Lingue
            values.availableLanguages = service.LanguagesGetAvailableSys();

            int CommunityId = CurrentCommunityId;

            //Ticket (Se draft, altrimenti nuovo!)
            Domain.DTO.DTO_Ticket Tk = new Domain.DTO.DTO_Ticket();

            if (View.CurrentTicketId <= 0)
            {
                //Controllo se può creare nuovi Ticket (Bozze)
                if (!(Cond == Domain.Enums.TicketAddCondition.CanCreate ||
                      (Cond == Domain.Enums.TicketAddCondition.CheckCount &&
                       (DraftNum < Access.MaxDraft))))
                {
                    if (View.CurrentTicketId <= 0)
                    {
                        View.ShowCantCreate(Domain.Enums.CantCreate.MaxDraftNoSend);
                        View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, CommunityId, ModuleTicket.InteractionType.None);
                        return;
                    }
                }

                //Creo un nuovo Ticket in BOZZA
                Tk           = service.TicketCreateNewDraft(Usr.Id, CommunityId, View.GetDraftTitle(), View.GetDraftPreview());
                values.IsNew = true;

                //Una volta creato, redirezione alla pagina con il ticket appena creato, per evitare problema F5.
                View.GotoNewTicketCreated(Tk.Code);
                return;
            }
            else
            {
                //Prendo il Ticket in Bozza
                Tk = service.TicketGetDraft(View.CurrentTicketId);
            }

            //SE Ticket == null o cercano di accedere ad un Ticket non valido
            //o non è possibile creare un nuovo Ticket.
            if (Tk == null || Tk.TicketId <= 0 || !Tk.IsDraft)
            {
                View.ShowCantCreate(Domain.Enums.CantCreate.permission);
                return;
            }

            //Carico Ticket (Nuovo, appena creato o precedente che sia)
            CommunityId = Tk.CommunityId;

            View.CurrentTicketId = Tk.TicketId;
            View.ViewCommunityId = CommunityId;
            View.DraftMsgId      = Tk.DraftMsgId;

            values.TicketData         = Tk;
            values.CurrentCommunityId = CommunityId;
            values.FileCommunityId    = CurrentCommunityId;

            //Action
            List <KeyValuePair <int, String> > Objects = new List <KeyValuePair <int, string> >();

            Objects.Add(ModuleTicket.KVPgetUser(service.UserGetIdfromPerson(UserContext.CurrentUserID)));

            View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.ExternalCreate, -1, ModuleTicket.InteractionType.None, Objects);
            //End Action

            values.HasOtherDraft = (values.IsNew && DraftNum > 0);

            this.UpdateCommunity(CommunityId, Tk.CategoryId);


            //USER!
            values.CurrentUser.UserId = Usr.Id;

            if (Usr.Person != null)
            {
                values.CurrentUser.PersonId     = Usr.Person.Id;
                values.CurrentUser.Name         = Usr.Person.Name;
                values.CurrentUser.SName        = Usr.Person.Surname;
                values.CurrentUser.LanguageCode = Usr.LanguageCode;
                values.CurrentUser.Mail         = Usr.Person.Mail;
            }
            else
            {
                values.CurrentUser.PersonId     = 0;
                values.CurrentUser.Name         = Usr.Name;
                values.CurrentUser.SName        = Usr.Sname;
                values.CurrentUser.LanguageCode = Usr.LanguageCode; // TicketService.LangMultiCODE; //OR SYS DEFAULT!?
                values.CurrentUser.Mail         = Usr.mail;
            }


            //Behalf

            if (Usr.Person != null)
            {
                values.CanBehalf = service.SettingPermissionGet(Usr.Id, Usr.Person.TypeID,
                                                                Domain.Enums.PermissionType.Behalf);
            }
            else
            {
                values.CanBehalf = false;
            }


            // Notification (sono state messe qui a differenza di "Edit" in cui sono messe nel service.
            // SPOSTARE IN SERVICE?

            if (Tk.IsBehalf)
            {
                if (Tk.HideToOwner)
                {
                    bool isdefaultCreator = false;
                    values.CreatorMailSettings = service.MailSettingsGet(Usr.Id, Tk.TicketId, false, ref isdefaultCreator);
                    values.IsDefaultNotCreator = isdefaultCreator;
                    values.OwnerMailSettings   = MailSettings.none;
                    values.IsDefaultNotOwner   = true;
                }
                else
                {
                    bool isdefaultOwner   = false;
                    bool isdefaultCreator = false;
                    values.CreatorMailSettings = service.MailSettingsGet(Usr.Id, Tk.TicketId, false, ref isdefaultCreator);
                    values.IsDefaultNotCreator = isdefaultCreator;
                    values.OwnerMailSettings   = service.MailSettingsGet(Tk.OwnerId, Tk.TicketId, false, ref isdefaultOwner);
                    values.IsDefaultNotOwner   = isdefaultOwner;
                }

                values.IsCreatorNotificationEnable = Usr.IsNotificationActiveUser;
                values.IsOwnerNotificationEnable   = Tk.IsOwnerNotificationActive;
            }
            else
            {
                values.OwnerMailSettings = MailSettings.none;
                bool isdefaultCreator = false;
                values.CreatorMailSettings = service.MailSettingsGet(Usr.Id, Tk.TicketId, false, ref isdefaultCreator);
                values.IsDefaultNotCreator = isdefaultCreator;
                values.IsDefaultNotOwner   = true;

                values.IsCreatorNotificationEnable = Usr.IsNotificationActiveUser;
                //values.IsOwnerNotificationEnable = Usr.IsNotificationActiveUser;
            }

            values.CanListUsers = CanListUsers(UserContext.CurrentCommunityID);


            //Upload File comunità
            //Repository 4 upload

            int CurPersId = (Usr.Person != null) ? Usr.Person.Id : 0;

            lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(values.FileCommunityId, CurPersId);
            List <RepositoryAttachmentUploadActions>             actions     = service.UploadAvailableActionsGet(MessageUserType.Partecipant, values.FileCommunityId, Usr.Person.Id, cRepository);

            //if (values.TicketData.Attachments != null && values.TicketData.Attachments.Any())
            //{
            //    alreadyLinkedFiles = (from Domain.DTO.DTO_AttachmentItem atc in values.TicketData.Attachments
            //                          where atc.File != null && atc.Link != null
            //                          select new dtoCoreItemFileLink<long>()
            //                          {
            //                              CreatedBy = atc.CreatedBy,
            //                              CreatedOn = atc.CreatedOn,
            //                              Deleted = atc.Deleted,
            //                              ItemFileLinkId = atc.IdAttachment,//fl.Id,
            //                              StatusId = 0,
            //                              Link = atc.Link,
            //                              Owner = atc.CreatedBy,
            //                              isVisible = (atc.Deleted == BaseStatusDeleted.None && !atc.File.isDeleted),
            //                              File = atc.File
            //                          }).ToList<iCoreItemFileLink<long>>();

            //    //ModifiedBy = atc.ModifiedBy,
            //    //ModifiedOn = atc.ModifiedOn,

            //    // && fl.Visibility == Domain.Enums.FileVisibility.visible
            //    //NO: se non è visibile, non lo è per l'utente, manager e resolver lo possono vedere E comunque non posso linkarlo nuovamente.
            //}
            RepositoryAttachmentUploadActions dAction = RepositoryAttachmentUploadActions.none;

            View.InitView(values, actions, dAction, cRepository, Tk.DraftMsgId);
            initCommunitySelector(Tk.CommunityId);
        }
Beispiel #19
0
        public List <dtoDiaryItem> GetDtoDiaryItems(int idCommunity, Boolean ascendingLesson, ModuleCommunityDiary module, lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository, Boolean allVisibleItems, List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions dAction, String unknownUser)
        {
            List <dtoDiaryItem> items     = new List <dtoDiaryItem>();
            litePerson          person    = Manager.GetLitePerson(UC.CurrentUserID);
            CommunityEventType  eventType = GetDiaryEventType();

            if (idCommunity > 0 && person != null)
            {
                int lessnoNumber = 1;
                items = (from item in CommunityEventItemsQuery(idCommunity, eventType, person, allVisibleItems).ToList()
                         select CreateDtoDiaryItem(person, item, allVisibleItems, module, moduleRepository, ref lessnoNumber, actions, dAction, unknownUser)).ToList();
                if (!ascendingLesson)
                {
                    items = items.OrderByDescending(i => i.LessonNumber).ToList();
                }
            }
            return(items);
        }
Beispiel #20
0
        public void InitView(Int32 idCommunity, long idItem, String unknownUser, Boolean isForAdd = false)
        {
            idCommunity = (idCommunity == 0 ? UserContext.CurrentCommunityID : idCommunity);
            if (!UserContext.isAnonymous)
            {
                litePerson         person = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
                CommunityEventItem item   = (idItem > 0  ? Service.EventItemGet(idItem) :null);
                if (item != null && idCommunity != item.IdCommunityOwner)
                {
                    idCommunity = item.IdCommunityOwner;
                }
                View.IdCommunityDiary       = idCommunity;
                View.IdModuleCommunityDiary = GetIdModule();
                View.IdModuleRepository     = ServiceRepository.GetIdModule();
                liteCommunity community = CurrentManager.GetLiteCommunity(idCommunity);
                if ((community == null && idCommunity > 0) || (!isForAdd && idItem == 0))
                {
                    View.NoPermission(idCommunity, GetIdModule());
                }
                else
                {
                    if (item == null && !isForAdd)
                    {
                        View.ShowNoItemWithThisID(idCommunity, GetIdModule(), idItem);
                    }
                    else
                    {
                        long idEvent = ((item != null && item.EventOwner != null)? item.EventOwner.Id : 0);
                        View.CurrentIdItem  = idItem;
                        View.CurrentIdEvent = idEvent;
                        ModuleCommunityDiary module = Service.GetPermissions(UserContext.CurrentUserID, idCommunity);
                        if ((module.AddItem && isForAdd) || (module.Administration || module.Edit))
                        {
                            String description = "";
                            if (idItem == 0)
                            {
                                item                  = new CommunityEventItem();
                                item.Title            = "";
                                item.Note             = "";
                                item.Owner            = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
                                item.ModifiedOn       = DateTime.Now;
                                item.StartDate        = new DateTime(item.ModifiedOn.Year, item.ModifiedOn.Month, item.ModifiedOn.Day, 8, 0, 0);
                                item.EndDate          = new DateTime(item.ModifiedOn.Year, item.ModifiedOn.Month, item.ModifiedOn.Day, 11, 0, 0);
                                item.IsVisible        = true;
                                item.Link             = "";
                                item.Place            = "";
                                item.Title            = "";
                                item.IdCommunityOwner = idCommunity;
                                item.ShowDateInfo     = true;
                            }
                            else
                            {
                                description = Service.EventItemGetDescription(item);
                            }

                            lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier = lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier.Create((idCommunity > 0 ? lm.Comol.Core.FileRepository.Domain.RepositoryType.Community : lm.Comol.Core.FileRepository.Domain.RepositoryType.Portal), idCommunity);

                            View.RepositoryIdentifier = identifier;
                            String communityName = (community != null ? community.Name : View.GetPortalNameTranslation());
                            List <dtoAttachmentItem> attachments = null;
                            if (idItem > 0)
                            {
                                lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
                                List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> availableActions = Service.GetAvailableUploadActions(module, moduleRepository);
                                lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions        dAction          = (availableActions == null || !availableActions.Any()) ? lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none : availableActions.FirstOrDefault();
                                View.InitializeAttachmentsControl(idEvent, idItem, availableActions, dAction);

                                attachments              = Service.AttachmentsGet(person, item, true, Service.GetItemPermission(person, item, module, moduleRepository), moduleRepository, unknownUser);
                                View.AllowEdit           = true;
                                View.AllowFileManagement = availableActions.Any();
                            }
                            else
                            {
                                View.AllowEdit           = module.Administration || module.AddItem;
                                View.AllowFileManagement = false;
                            }
                            View.LoadItem(item, description, communityName, attachments);
                        }
                        else
                        {
                            View.NoPermission(idCommunity, GetIdModule());
                        }
                    }
                    View.SetBackToDiary(idCommunity, idItem);
                }
            }
            else
            {
                View.DisplaySessionTimeout(idCommunity, idItem);
            }
        }
        public void InitView(long idEvent, long idEventItem, Int32 lessonNumber, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions action, lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier, lm.Comol.Core.FileRepository.Domain.ModuleRepository rPermissions = null)
        {
            if (!UserContext.isAnonymous)
            {
                View.CurrentAction    = action;
                View.IdEvent          = idEvent;
                View.IdEventItem      = idEventItem;
                View.IdEventCommunity = identifier.IdCommunity;
                View.LessonNumber     = lessonNumber;
                if (View.DisplayInfo)
                {
                    DisplayEventItemInfo(idEventItem, lessonNumber);
                }
                switch (action)
                {
                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.addurltomoduleitem:

                    View.InitializeUploaderControl(action, identifier);
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem:
                    View.InitializeUploaderControl(action, identifier);
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.linkfromcommunity:
                    if (rPermissions == null)
                    {
                        rPermissions = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
                    }
                    if (rPermissions != null && identifier.IdCommunity > 0)
                    {
                        View.InitializeLinkRepositoryItems(UserContext.CurrentUserID, rPermissions, identifier, Service.AttachmentsGetBaseLinkedFiles(idEventItem));
                    }
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity:
                    if (rPermissions == null)
                    {
                        rPermissions = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
                    }
                    if (rPermissions != null && identifier.IdCommunity > 0)
                    {
                        View.InitializeCommunityUploader(identifier);
                    }
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.addurltomoduleitemandcommunity:
                    break;
                }
            }
            else
            {
                View.CurrentAction = Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none;
            }
        }
Beispiel #22
0
        public List <dtoAttachmentItem> AttachmentsGet(litePerson person, CommunityEventItem item, Boolean viewAlsoDeleted, CoreItemPermission permissions, lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository, String unknownUser)
        {
            List <dtoAttachmentItem> items = null;

            try
            {
                if (item != null)
                {
                    items = new List <dtoAttachmentItem>();
                    List <dtoAttachment> attachments = AttachmentsGet(person, item, viewAlsoDeleted, unknownUser);
                    items = attachments.Where(a => a.IdModuleLink > 0).OrderBy(a => a.DisplayOrder).ThenBy(a => a.DisplayName).Select(a => new dtoAttachmentItem()
                    {
                        Attachment = a, Permissions = AttachmentGetPermissions(person, a, permissions, moduleRepository)
                    }).ToList();
                }
            }
            catch (Exception ex)
            {
                items = null;
            }
            return(items);
        }
 public void InitView(long idMessage, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions action, Int32 idCommunity, lm.Comol.Core.FileRepository.Domain.ModuleRepository rPermissions, Int32 idUploader = -1)
 {
     InitView(idMessage, action, lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier.Create((idCommunity <= 0 ? lm.Comol.Core.FileRepository.Domain.RepositoryType.Portal : Core.FileRepository.Domain.RepositoryType.Community), idCommunity), rPermissions, idUploader);
 }
        /// <summary>
        /// Restituisce le ActionType
        /// </summary>
        /// <param name="UserType">Tipo utente. Se diverso da creatore, controllo permessi per file comunità</param>
        /// <param name="idCommunity">= 0 Se creatore o portale</param>
        /// <param name="idPerson">= 0 se creatore o portale</param>
        /// <param name="repositoryPermissions">Repository permission: if NULL = no community permission</param>
        /// <returns></returns>
        /// <remarks>
        /// Eventuamente modificare i riferimenti per avere Id utente e comnità reali.
        /// </remarks>
        public List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> UploadAvailableActionsGet(Domain.Enums.MessageUserType UserType, int idCommunity, int idPerson, lm.Comol.Core.FileRepository.Domain.ModuleRepository repositoryPermissions)
        {
            List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> actions = new List <DomainModel.Repository.RepositoryAttachmentUploadActions>();

            //UserType == TK.Enums.MessageUserType.Partecipant ||

            if (idCommunity <= 0 || idPerson <= 0)
            {
                actions.Add(DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem);
            }
            else
            {
                actions.Add(DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem);

                if (repositoryPermissions != null)
                {
                    if (repositoryPermissions.Administration || repositoryPermissions.ManageItems || repositoryPermissions.ViewItemsList)
                    {
                        actions.Add(DomainModel.Repository.RepositoryAttachmentUploadActions.linkfromcommunity);
                    }
                    if (repositoryPermissions.UploadFile || repositoryPermissions.Administration || repositoryPermissions.ManageItems)
                    {
                        actions.Add(DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity);
                    }
                }
            }
            return(actions);
        }
Beispiel #25
0
        public void InitView()
        {
            if (!CheckSessionAccess())
            {
                return;
            }

            int ColUserId = this.UserContext.CurrentUserID;

            Domain.DTO.DTO_ManagerModify Data = service.TicketGetManager(View.TicketId, View.MassageFilter, View.MessagesOrder);

            if (Data.Errors == TicketEditManErrors.NoPermission)// (!service.UserHasManResTicketPermission(View.TicketId))
            {
                View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.NoPermission, this.CurrentCommunityId, ModuleTicket.InteractionType.None);
                View.ShowNoPermission();
            }

            //Int32 CommunityId = UserContext.CurrentCommunityID;

            IList <Domain.DTO.DTO_CategoryTree> Categories = service.CategoriesGetTreeDLL(CurrentCommunityId, CategoryTREEgetType.FilterManager);


            //service.CategoryGetDDLManRes_ComCurrent();
            View.UserType = Data.CurrentUserType;

            //this.CurrentCommunityId
            //

            lm.Comol.Core.FileRepository.Domain.ModuleRepository cRepository = service.GetRepositoryPermissions(CurrentCommunityId, ColUserId);

            //List<iCoreItemFileLink<long>> alreadyLinkedFiles = new List<iCoreItemFileLink<long>>();
            ////= new List<iCoreItemFileLink<long>>();

            ////Link di comunità già usati

            //if (Data.DraftMessage != null && Data.DraftMessage.Attachments.Any())
            //{
            //    alreadyLinkedFiles = (from Domain.TicketFile fl in Data.DraftMessage.Attachments
            //                          where fl.File != null && fl.Link != null
            //                          select new dtoCoreItemFileLink<long>()
            //                          {
            //                              CreatedBy = fl.CreatedBy,
            //                              CreatedOn = fl.CreatedOn,
            //                              Deleted = fl.Deleted,
            //                              ItemFileLinkId = fl.Id,
            //                              StatusId = 0,
            //                              Link = fl.Link,
            //                              ModifiedBy = fl.ModifiedBy,
            //                              ModifiedOn = fl.ModifiedOn,
            //                              Owner = fl.CreatedBy,
            //                              isVisible = (fl.Deleted == BaseStatusDeleted.None && !fl.File.isDeleted),
            //                              File = fl.File
            //                          }).ToList<iCoreItemFileLink<long>>();

            //    //fl.Link.DestinationItem.ObjectLongID


            //    // && fl.Visibility == Domain.Enums.FileVisibility.visible
            //    //NO: se non è visibile, non lo è per l'utente, manager e resolver lo possono vedere E comunque non posso linkarlo nuovamente.
            //}

            //if (alreadyLinkedFiles == null)
            //    alreadyLinkedFiles = new List<iCoreItemFileLink<long>>();

            bool hasComManager = service.UsersCommunityHasManRes(CurrentCommunityId, Data.UserAssignedId);
            bool hasCommunity  = (CurrentCommunityId > 0);


            View.InitView(
                Data,
                Categories,
                service.CategoryGetDTOCatTree(Data.CategoryCurrentId),
                service.UploadAvailableActionsGet(
                    Data.CurrentUserType,
                    CurrentCommunityId,
                    ColUserId,
                    cRepository),
                cRepository,
                CurrentCommunityId,
                (Data.DraftMessage == null ? 0 : Data.DraftMessage.Id),
                hasComManager,
                hasCommunity);

            if (Data.Errors == Domain.Enums.TicketEditManErrors.none)
            {
                View.DraftMsgId = Data.DraftMessage.Id;
                View.TicketId   = Data.TicketId;
            }

            //Begin Action
            List <KeyValuePair <int, String> > Objects = new List <KeyValuePair <int, string> >();

            Objects.Add(ModuleTicket.KVPgetPerson(UserContext.CurrentUserID));
            Objects.Add(ModuleTicket.KVPgetTicket(View.TicketId));

            View.SendUserActions(service.ModuleID, ModuleTicket.ActionType.TicketLoadEditManRes, this.CurrentCommunityId, ModuleTicket.InteractionType.UserWithLearningObject, Objects);
            //End Action
        }
Beispiel #26
0
        private dtoAttachmentPermission AttachmentGetPermissions(litePerson person, dtoAttachment attachment, CoreItemPermission permissions, lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository)
        {
            dtoAttachmentPermission result = new dtoAttachmentPermission();

            if (attachment.File != null)
            {
                Boolean fileRepositoryOwner = (moduleRepository.Administration || (moduleRepository.EditOthersFiles || (moduleRepository.EditMyFiles && attachment.File.IdOwner == person.Id)));

                result.Download       = (attachment.File != null && (attachment.File.IsDownloadable || attachment.File.Type == FileRepository.Domain.ItemType.Link)) && permissions.AllowViewFiles;
                result.Play           = (attachment.File != null && (attachment.File.Type == FileRepository.Domain.ItemType.Multimedia || attachment.File.Type == FileRepository.Domain.ItemType.ScormPackage || attachment.File.Type == FileRepository.Domain.ItemType.VideoStreaming)) && permissions.AllowViewFiles;
                result.EditVisibility = permissions.AllowEdit;
                switch (attachment.File.Type)
                {
                case FileRepository.Domain.ItemType.Multimedia:
                case FileRepository.Domain.ItemType.ScormPackage:
                    result.ViewMyStatistics    = permissions.AllowViewStatistics;
                    result.SetMetadata         = permissions.AllowEdit && (attachment.File.IsInternal || fileRepositoryOwner);
                    result.ViewOtherStatistics = permissions.AllowEdit && (attachment.File.IsInternal || fileRepositoryOwner);
                    break;

                case FileRepository.Domain.ItemType.Link:
                    result.Play = result.Download;
                    break;
                }
                result.Edit = false;

                result.EditRepositoryVisibility = permissions.AllowEdit && fileRepositoryOwner && !attachment.File.IsInternal;
                result.EditRepositoryPermission = permissions.AllowEdit && fileRepositoryOwner && !attachment.File.IsInternal;
                result.Delete        = attachment.File.IsInternal && permissions.AllowDelete && (attachment.Deleted != BaseStatusDeleted.None);;
                result.UnDelete      = attachment.File.IsInternal && (attachment.Deleted != BaseStatusDeleted.None) && (permissions.AllowUnDelete);
                result.VirtualDelete = attachment.File.IsInternal && (attachment.Deleted == BaseStatusDeleted.None) && permissions.AllowUnDelete;
                result.Unlink        = (!attachment.File.IsInternal && permissions.AllowAddFiles);
                result.Publish       = permissions.AllowFilePublish && attachment.File.IsInternal && attachment.Deleted == BaseStatusDeleted.None;
            }
            return(result);
        }
        public void InitView(long idMessage, lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions action, lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier, lm.Comol.Core.FileRepository.Domain.ModuleRepository rPermissions = null, Int32 idUploader = -1)
        {
            if (!UserContext.isAnonymous || (action == lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem && View.AllowAnonymousUpload))
            {
                View.CurrentAction     = action;
                View.IdMessage         = idMessage;
                View.IdTicketCommunity = identifier.IdCommunity;
                switch (action)
                {
                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem:
                    View.InitializeUploaderControl(action, identifier, idUploader);
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.linkfromcommunity:
                    if (rPermissions == null)
                    {
                        rPermissions = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
                    }
                    if (rPermissions != null && identifier.IdCommunity > 0)
                    {
                        View.InitializeLinkRepositoryItems(UserContext.CurrentUserID, rPermissions, identifier, Service.AttachmentsGetBaseLinkedFiles(idMessage));
                    }
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitemandcommunity:
                    if (rPermissions == null)
                    {
                        rPermissions = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
                    }
                    if (rPermissions != null && identifier.IdCommunity > 0)
                    {
                        View.InitializeCommunityUploader(identifier);
                    }
                    break;

                case Core.DomainModel.Repository.RepositoryAttachmentUploadActions.addurltomoduleitemandcommunity:
                    break;
                }
            }
            else
            {
                View.CurrentAction = Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none;
            }
        }