Ejemplo n.º 1
0
        public void InitView(long idTemplate, long idVersion)
        {
            dtoSelectorContext context = GetContext();

            View.ContainerContext  = context;
            View.ContentIdTemplate = idTemplate;
            View.ContentIdVersion  = idVersion;
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                if (HasPermission(context))
                {
                    InitializeView(idTemplate, idVersion, context);
                }
                else if (context.ObjectOwner != null)
                {
                    View.DisplayNoPermission(context.IdCommunity, context.IdModule, context.ModuleCode);
                }
                else
                {
                    View.DisplayNoPermission(context.IdCommunity, TemplatesService.ServiceModuleID(), context.ModuleCode);
                }
            }
        }
Ejemplo n.º 2
0
        private Boolean HasPermission(dtoSelectorContext context)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            ModuleTemplateMessages permission = (context.IsForPortal) ? ModuleTemplateMessages.CreatePortalmodule((p == null) ? (Int32)UserTypeStandard.Guest : p.TypeID, OwnerType.System) : new ModuleTemplateMessages(CurrentManager.GetModulePermission(UserContext.CurrentUserID, context.IdCommunity, TemplatesService.ServiceModuleID()));

            if (permission.Administration)
            {
                //List<lm.Comol.Core.TemplateMessages.ModuleGenericTemplateMessages> permissions = InitializePermissions(forPortal, idCommunity, p);
                return(true);
            }
            else
            {
                return(View.HasModulePermissions(context.ModuleCode, GetModulePermissions(context.IdModule, context.IdCommunity), context.IdCommunity, (p == null) ? (int)UserTypeStandard.Guest : p.TypeID, context.ObjectOwner));
            }
        }
Ejemplo n.º 3
0
        private dtoSelectorContext GetContext()
        {
            dtoSelectorContext item = new dtoSelectorContext();

            item.ObjectOwner = View.PreloadModuleObject;
            item.IdCommunity = View.PreloadIdCommunity;
            item.IdModule    = View.PreloadIdModule;
            item.ModuleCode  = View.PreloadModuleCode;
            item.IsForPortal = View.PreloadForPortal;
            if (item.IdCommunity == -1 && item.ObjectOwner != null)
            {
                item.IdCommunity = item.ObjectOwner.CommunityID;
            }
            if (item.IdModule > 0 && String.IsNullOrEmpty(item.ModuleCode))
            {
                item.ModuleCode = CurrentManager.GetModuleCode(item.IdModule);
            }
            else if (item.IdModule == 0 && !String.IsNullOrEmpty(item.ModuleCode))
            {
                item.IdModule = CurrentManager.GetModuleID(item.ModuleCode);
            }

            Community c = CurrentManager.GetCommunity(item.IdCommunity);

            if (item.IdCommunity == 0 && item.IsForPortal == false)
            {
                item.IdCommunity = UserContext.CurrentCommunityID;
                item.IsForPortal = (item.IdCommunity == 0);
            }
            else if (item.IdCommunity > 0 && item.IsForPortal)
            {
                item.IsForPortal = false;
            }
            item.IdOrganization = (item.IdOrganization == 0) ? ((c == null) ? 0 : c.IdOrganization) : item.IdOrganization;
            if (item.IdOrganization > 0)
            {
                item.IdOrganizationCommunity = CurrentManager.GetIdCommunityFromOrganization(item.IdOrganization);
            }
            return(item);
        }
Ejemplo n.º 4
0
        public void InitView(ModuleGenericTemplateMessages permissions, lm.Comol.Core.Notification.Domain.NotificationChannel channel, long idAction, Int32 idModule, String moduleCode, Int32 idCommunty, Int32 idOrganization = 0, Boolean forPortal = false, long idTemplate = 0, long idVersion = 0, lm.Comol.Core.DomainModel.ModuleObject obj = null, List <dtoTemplateItem> items = null)
        {
            dtoSelectorContext c = new dtoSelectorContext();

            c.IdAction       = idAction;
            c.IdModule       = (idModule > 0) ? idModule : (!String.IsNullOrEmpty(moduleCode) ? CurrentManager.GetModuleID(moduleCode) : 0);
            c.ModuleCode     = (!String.IsNullOrEmpty(moduleCode)) ? moduleCode : (idModule > 0 ? CurrentManager.GetModuleCode(idModule) : "");
            c.IdCommunity    = idCommunty;
            c.IdOrganization = idOrganization;
            if (idCommunty > 0 && idOrganization <= 0)
            {
                Community community = CurrentManager.GetCommunity(idCommunty);
                c.IdOrganizationCommunity = (community == null) ? 0 : ((community.IdFather == 0) ? community.Id : CurrentManager.GetIdCommunityFromOrganization(community.IdOrganization));
            }
            else if (idOrganization > 0)
            {
                c.IdOrganizationCommunity = CurrentManager.GetIdCommunityFromOrganization(idOrganization);
            }
            c.IsForPortal = (forPortal && idCommunty == 0 && idOrganization == 0);
            c.ObjectOwner = obj;
            InitView(permissions, channel, c, idTemplate, idVersion, true, items);
        }
Ejemplo n.º 5
0
        public void InitView(ModuleGenericTemplateMessages permissions, lm.Comol.Core.Notification.Domain.NotificationChannel channel, dtoSelectorContext context, long idTemplate, long idVersion, Boolean isVerifyed = false, List <dtoTemplateItem> items = null)
        {
            View.isInitialized = true;
            if (!isVerifyed)
            {
                if (context.IdModule <= 0 && !String.IsNullOrEmpty(context.ModuleCode))
                {
                    context.IdModule = CurrentManager.GetModuleID(context.ModuleCode);
                }
                if (context.IdModule > 0 && String.IsNullOrEmpty(context.ModuleCode))
                {
                    context.ModuleCode = CurrentManager.GetModuleCode(context.IdModule);
                }
                context.IsForPortal = (context.IsForPortal && context.IdCommunity == 0 && context.IdOrganization == 0);
                if (context.IdOrganizationCommunity <= 0)
                {
                    if (context.IdOrganization > 0)
                    {
                        context.IdOrganizationCommunity = CurrentManager.GetIdCommunityFromOrganization(context.IdOrganization);
                    }
                    else if (context.IdCommunity > 0 && context.IdOrganization <= 0)
                    {
                        Community community = CurrentManager.GetCommunity(context.IdCommunity);
                        context.IdOrganizationCommunity = (community == null) ? 0 : ((community.IdFather == 0) ? community.Id : CurrentManager.GetIdCommunityFromOrganization(community.IdOrganization));
                    }
                }
            }
            dtoTemplateItem current = Service.GetDefaultAutomaticTemplate(context, channel);

            if (UserContext.isAnonymous)
            {
                LoadCurrentTemplate(current);
                View.AllowPreview = false;
                View.AllowSelect  = false;
            }
            else
            {
                LoadItems(permissions, channel, current, context, idTemplate, idVersion, items);
            }
        }
Ejemplo n.º 6
0
 private void LoadItems(ModuleGenericTemplateMessages permissions, lm.Comol.Core.Notification.Domain.NotificationChannel channel, dtoTemplateItem current, dtoSelectorContext context, long idTemplate, long idVersion, List <dtoTemplateItem> items = null)
 {
     if (items == null)
     {
         items = Service.GetAvailableTemplates(permissions, context, idTemplate, idVersion, channel);
     }
     if (items.Count == 0)
     {
         View.LoadEmptyTemplate();
         View.AllowPreview = false;
         View.AllowSelect  = false;
     }
     else
     {
         View.LoadTemplates(items);
     }
 }
Ejemplo n.º 7
0
        private void InitializeView(long idTemplate, long idVersion, dtoSelectorContext context)
        {
            TemplateDefinitionVersion version = InternalService.GetVersion(idTemplate, idVersion);

            if (version == null)
            {
                if (idVersion > 0)
                {
                    View.DisplayNoTemplateVersionFound();
                }
                else
                {
                    View.DisplayNoTemplateFound();
                }
            }
            else
            {
                if (idVersion > 0)
                {
                    View.DisplayVersionInfo(version.Number);
                }
                else
                {
                    View.DisplayLastVersionInfo();
                }
                Boolean isAdministrative = InternalService.IsAdministrativeUser(UserContext.CurrentUserID);
                if (version.ChannelSettings != null && version.ChannelSettings.Where(c => c.Deleted == BaseStatusDeleted.None && c.Channel == lm.Comol.Core.Notification.Domain.NotificationChannel.Mail).Any())
                {
                    View.InitializeMailSettings(version.ChannelSettings.Where(c => c.Deleted == BaseStatusDeleted.None && c.Channel == lm.Comol.Core.Notification.Domain.NotificationChannel.Mail).FirstOrDefault().MailSettings, isAdministrative, isAdministrative, isAdministrative);
                }
                List <lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation> translations = new List <lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation>();
                translations = (from t in version.Translations where t.Deleted == BaseStatusDeleted.None
                                select new lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation()
                {
                    Id = t.Id,
                    IdLanguage = t.IdLanguage,
                    LanguageCode = t.LanguageCode,
                    LanguageName = t.LanguageName,
                    Translation = t.Translation
                }).ToList();
                translations.Add(new dtoTemplateTranslation()
                {
                    Id = 0, IdLanguage = 0, LanguageCode = "multi", LanguageName = "multi", IdVersion = version.Id, Translation = version.DefaultTranslation
                });
                View.ContentModules = version.GetModuleContentCodes();
                List <Language> languages = CurrentManager.GetAllLanguages().ToList();
                List <lm.Comol.Core.DomainModel.Languages.LanguageItem> inUseLanguages = translations.Select(t => new lm.Comol.Core.DomainModel.Languages.LanguageItem()
                {
                    Id = t.IdLanguage, Code = t.LanguageCode, Name = t.LanguageName, IsMultiLanguage = (t.LanguageCode == "multi" && t.IdLanguage == 0), Status = (t.IsEmpty) ? DomainModel.Languages.ItemStatus.wrong : (t.Translation.IsValid(!version.OnlyShortText, version.HasShortText, true)) ? DomainModel.Languages.ItemStatus.valid : DomainModel.Languages.ItemStatus.warning
                }).ToList();
                inUseLanguages.Where(l => languages.Where(ll => ll.isDefault && l.Id == ll.Id).Any()).ToList().ForEach(l => l.IsDefault = true);
                inUseLanguages.Where(l => l.Id > 0).ToList().ForEach(l => l.Name = languages.Where(ll => ll.Id == l.Id).Select(ll => ll.Name).FirstOrDefault());
                inUseLanguages.Add(new lm.Comol.Core.DomainModel.Languages.LanguageItem()
                {
                    Id = 0, Code = "multi", IsEnabled = true, IsMultiLanguage = true, Status = (version.DefaultTranslation.IsValid(!version.OnlyShortText, version.HasShortText, true)) ? lm.Comol.Core.DomainModel.Languages.ItemStatus.valid : lm.Comol.Core.DomainModel.Languages.ItemStatus.warning
                });

                inUseLanguages = inUseLanguages.OrderByDescending(l => l.IsMultiLanguage).ThenBy(l => l.Name).ToList();
                //if (!inUseLanguages.Any(l => l.IsMultiLanguage))
                //{
                //    inUseLanguages.Add(new DomainModel.Languages.LanguageItem(){ IsMultiLanguage=true, })
                //}
                lm.Comol.Core.DomainModel.Languages.LanguageItem current = inUseLanguages.Where(l => l.Id == UserContext.Language.Id).FirstOrDefault();
                if (current == null && inUseLanguages.Any())
                {
                    current = inUseLanguages.Where(l => l.IsDefault).FirstOrDefault();
                    if (current == null)
                    {
                        current = inUseLanguages.Where(l => l.IsMultiLanguage).FirstOrDefault();
                    }
                }
                if (current == null && inUseLanguages.Any())
                {
                    current = inUseLanguages.FirstOrDefault();
                }
                View.InitializeControls(translations, inUseLanguages, current);
                View.LoadTemplate((current != null) ? translations.Where(t => t.IdLanguage == current.Id && t.LanguageCode == current.Code).FirstOrDefault() : (translations.Any() ? translations[0] : null));
            }
            //        Boolean isAdministrative =  Service.IsAdministrativeUser(UserContext.CurrentUserID);
            //        Boolean senderEdit = isAdministrative;

            //        List<lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation> translations = new List<lm.Comol.Core.TemplateMessages.Domain.dtoTemplateTranslation>();
            //        if (message.Template != null) {
            //            Boolean onlyShortText = false;
            //            Boolean hasShortText = false;


            //            String tagTranslation = View.TagTranslation;
            //            if (translations.Any() && !String.IsNullOrEmpty(tagTranslation)){
            //                List<lm.Comol.Core.DomainModel.Helpers.TemplatePlaceHolder> placeHolders = View.GetContentPlaceHolders(View.ContentModules);
            //                foreach(lm.Comol.Core.DomainModel.Helpers.TemplatePlaceHolder pHolder in placeHolders.Where(t=> translations.Where(ct=> !ct.Translation.IsContentEmpty && ((!String.IsNullOrEmpty(ct.Translation.Body) && ct.Translation.Body.Contains(t.Tag)) || (!String.IsNullOrEmpty(ct.Translation.Subject) && ct.Translation.Subject.Contains(t.Tag)))).Any()) ){
            //                    translations.Where(ct => !ct.Translation.IsContentEmpty && !String.IsNullOrEmpty(ct.Translation.Body) && ct.Translation.Body.Contains(pHolder.Tag)).ToList().ForEach(t => t.Translation.Body = t.Translation.Body.Replace(pHolder.Tag, String.Format(tagTranslation, pHolder.Tag, pHolder.Name)));
            //                    translations.Where(ct => !ct.Translation.IsContentEmpty && !String.IsNullOrEmpty(ct.Translation.Subject) && ct.Translation.Subject.Contains(pHolder.Tag)).ToList().ForEach(t => t.Translation.Subject = t.Translation.Subject.Replace(pHolder.Tag, String.Format(tagTranslation, pHolder.Tag, pHolder.Name)));
            //                }
            //            }

            //        }
            //    }
        }