private ModuleGenericTemplateMessages GetPermissions(String moduleCode, long permissions, Int32 idCommunity, TemplateType type) { ModuleGenericTemplateMessages permission = null; Int32 idUser = UserContext.CurrentUserID; switch (type) { case TemplateType.Module: if (moduleCode == ModuleTemplateMessages.UniqueCode) { permission = new ModuleGenericTemplateMessages(Service.GetPermission(idCommunity, OwnerType.Module)); } else { Int32 idModule = CurrentManager.GetModuleID(moduleCode); dtoBaseTemplateOwner ownerInfo = View.PreloadOwnership; ModuleObject obj = (ownerInfo.Type == OwnerType.Object) ? ModuleObject.CreateLongObject(ownerInfo.IdObject, ownerInfo.IdObjectType, ownerInfo.IdObjectCommunity, CurrentManager.GetModuleCode(ownerInfo.IdObjectModule), ownerInfo.IdObjectModule) : null; if (obj != null && obj.ServiceID == 0 && !String.IsNullOrEmpty(obj.ServiceCode)) { obj.ServiceID = CurrentManager.GetModuleID(obj.ServiceCode); } else if (obj != null && obj.ServiceID > 0 && String.IsNullOrEmpty(obj.ServiceCode)) { obj.ServiceCode = CurrentManager.GetModuleCode(obj.ServiceID); } if (permissions > 0) { permission = View.GetModulePermissions(moduleCode, idModule, CurrentManager.GetModulePermission(UserContext.CurrentUserID, idCommunity, idModule), idCommunity, UserContext.UserTypeID, obj); } else { permission = View.GetModulePermissions(moduleCode, idModule, GetModulePermission(idCommunity, idModule), idCommunity, UserContext.UserTypeID, obj); } } break; case TemplateType.User: Person p = GetCurrentUser(ref idUser); Boolean allowView = (p != null && p.TypeID != (Int32)UserTypeStandard.Guest && p.TypeID != (Int32)UserTypeStandard.PublicUser); permission = new ModuleGenericTemplateMessages("personal"); permission.Add = allowView; permission.Administration = allowView; permission.Clone = allowView; permission.DeleteMyTemplates = allowView; permission.Edit = allowView; permission.List = allowView; break; } if (permission == null) { permission = new ModuleGenericTemplateMessages(moduleCode); } return(permission); }
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); } }
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); } }
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); }
public void InitView() { TemplateType t = View.PreloadTemplateType; dtoBaseTemplateOwner ownerInfo = View.PreloadOwnership; Int32 idCommunity = ownerInfo.IdCommunity; if (idCommunity == -1) { idCommunity = UserContext.CurrentCommunityID; //if (t== TemplateType.System) ownerInfo.IdCommunity = idCommunity; } if (ownerInfo.IdModule == 0 && !String.IsNullOrEmpty(ownerInfo.ModuleCode)) { ownerInfo.IdModule = CurrentManager.GetModuleID(ownerInfo.ModuleCode); } View.Ownership = ownerInfo; View.IdTemplateCommunity = idCommunity; View.CurrentType = t; if (UserContext.isAnonymous) { View.DisplaySessionTimeout(RootObject.Add(t, View.PreloadOwnership, View.PreloadFromIdCommunity, View.PreloadFromModuleCode, View.PreloadFromModulePermissions)); } else { Boolean allowAdd = false; switch (ownerInfo.Type) { case OwnerType.None: View.UnableToReadUrlSettings(); View.SendUserAction(idCommunity, Service.ServiceModuleID(), ModuleTemplateMessages.ActionType.MalformedUrl); break; //case OwnerType.Object: // allowAdd = View.HasPermissionForObject(ModuleObject.CreateLongObject(ownerInfo.IdObject, ownerInfo.IdObjectType, ownerInfo.IdObjectCommunity,CurrentManager.GetModuleCode(ownerInfo.IdObjectModule))); // break; default: if (t == TemplateType.Module) { ModuleGenericTemplateMessages p = GetPermissions(View.PreloadFromModuleCode, View.PreloadFromModulePermissions, View.PreloadFromIdCommunity, t); allowAdd = p.Administration || p.Add; } else { allowAdd = Service.AllowAdd(ownerInfo); } break; } List <lm.Comol.Core.Wizard.NavigableWizardItem <dtoTemplateStep> > steps = Service.GetAvailableSteps(0, WizardTemplateStep.Settings, ownerInfo.Type); View.AllowAdd = allowAdd; if (allowAdd) { Boolean isAdministrative = Service.IsAdministrativeUser(UserContext.CurrentUserID); View.AllowSenderEdit = isAdministrative && t == TemplateType.System; View.AllowSubjectEdit = isAdministrative; View.AllowSignatureEdit = isAdministrative; List <NotificationChannel> channels = Service.GetAvailableChannels(t, 0); if (t == TemplateType.Module || ownerInfo.IdModule > 0) { View.IdTemplateModule = ownerInfo.IdModule; View.DisplayInput(CurrentManager.GetLanguage(UserContext.Language.Id), Service.GetTemplateNumber(ownerInfo), channels); if (channels.Any() && channels.Count == 1 && channels.Contains(NotificationChannel.Mail)) { AddNotificationSetting(NotificationChannel.Mail, new List <dtoChannelConfigurator>()); } } else { View.DisplayInput(CurrentManager.GetLanguage(UserContext.Language.Id), Service.GetTemplateNumber(ownerInfo), View.GetAvailableModules(), channels); if (t == TemplateType.User && channels.Contains(NotificationChannel.Mail)) { AddNotificationSetting(NotificationChannel.Mail, new List <dtoChannelConfigurator>()); } } View.SendUserAction(idCommunity, Service.ServiceModuleID(), ModuleTemplateMessages.ActionType.StartAddNewTemplate); } else { steps = steps.Where(s => s.Id.Type == WizardTemplateStep.Settings).ToList(); steps[0].Status = Wizard.WizardItemStatus.disabled; steps[0].DisplayOrderDetail = Wizard.DisplayOrderEnum.first | Wizard.DisplayOrderEnum.last; View.DisplayAddUnavailable(); View.SendUserAction(idCommunity, Service.ServiceModuleID(), ModuleTemplateMessages.ActionType.TryToAddNewTemplate); } View.LoadWizardSteps(idCommunity, steps); if (String.IsNullOrEmpty(View.PreloadBackUrl)) { View.SetBackUrl(RootObject.List(View.PreloadFromIdCommunity, t, ownerInfo, true, View.PreloadFromModuleCode, View.PreloadFromModulePermissions)); } else { View.SetBackUrl(View.PreloadBackUrl); } } }