public void AddTemplate(String name, List <String> contentModules, List <dtoChannelConfigurator> items) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(RootObject.Add(View.CurrentType, View.PreloadOwnership, View.PreloadFromIdCommunity, View.PreloadFromModuleCode, View.PreloadFromModulePermissions)); } else { dtoBaseTemplateOwner owner = View.Ownership; if (!contentModules.Any() && (String.IsNullOrEmpty(owner.ModuleCode) || (View.CurrentType == TemplateType.Module))) { contentModules.Add(owner.ModuleCode); } TemplateDefinition template = Service.AddTemplate(name, View.CurrentType, owner, contentModules, items); if (template == null) { View.DisplayTemplateAddError(); } else if (View.PreloadCurrentSessionId == Guid.Empty) { View.GoToUrl(RootObject.EditByStep(View.CurrentType, View.Ownership, WizardTemplateStep.Settings, View.PreloadFromIdCommunity, View.PreloadFromModuleCode, View.PreloadFromModulePermissions, View.GetEncodedBackUrl(), template.Id, template.Versions[0].Id, false, true)); } else { View.GoToUrl(RootObject.EditByStep(View.CurrentType, View.Ownership, WizardTemplateStep.Settings, View.PreloadFromIdCommunity, View.PreloadFromModuleCode, View.PreloadFromModulePermissions, "", template.Id, template.Versions[0].Id, false, true)); } } }
public void AddNotificationSetting(lm.Comol.Core.Notification.Domain.NotificationChannel channel, List <dtoChannelConfigurator> items) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(RootObject.Add(View.CurrentType, View.PreloadOwnership, View.PreloadFromIdCommunity, View.PreloadFromModuleCode, View.PreloadFromModulePermissions)); } else { dtoChannelConfigurator config = Service.GetDraftChannelConfigurator(channel, View.CurrentType, 0); if (config == null) { View.DisplayTemplateUnableToAddNotificationChannel(); } else { List <NotificationChannel> channels = Service.GetAvailableChannels(View.CurrentType, 0); channels.Remove(channel); channels = channels.Where(t => !items.Where(i => i.Channel == t).Any()).ToList(); //config.AvailableModuleCodes = View.GetModuleCodesForNotification().Select(m => m.Key).ToList(); items.Add(config); //UpdateInUseSettings(items); View.ChannelSettings = items; View.LoadChannelSettings(items); View.LoadChannels(channels); } } }
public void VirtualDeleteNotificationSetting(List <dtoChannelConfigurator> items, System.Guid temporaryId) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(RootObject.Add(View.CurrentType, View.PreloadOwnership, View.PreloadFromIdCommunity, View.PreloadFromModuleCode, View.PreloadFromModulePermissions)); } else { items = items.Where(i => i.TemporaryId != temporaryId).ToList(); List <NotificationChannel> channels = Service.GetAvailableChannels(View.CurrentType, 0); channels = channels.Where(t => !items.Where(i => i.Channel == t).Any()).ToList(); //UpdateInUseSettings(items); View.ChannelSettings = items; View.LoadChannelSettings(items); View.LoadChannels(channels); } }
private void InitializeList(dtoModuleContext context, Int32 idCommunity, TemplateType type, long permissions) { dtoBaseTemplateOwner ownerInfo = null; Boolean allowAdd = false; String addUrl = ""; String addPersonalUrl = ""; String addObjectUrl = ""; View.IsInitializedList = true; if (context == null) { context = GetModuleContext(View.CurrentModuleCode, permissions, View.CurrentIdCommunity, type); } #region "Permissions" allowAdd = context.Permissions.Administration || context.Permissions.Add; System.Guid sessionId = View.CurrentSessionId; switch (type) { case TemplateType.System: if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Module, ModuleCode = context.ModuleCode, IdModule = context.IdModule, ModulePermission = context.ModulePermissions }; addUrl = RootObject.Add(sessionId, TemplateType.System, ownerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); } break; case TemplateType.Module: allowAdd = context.Permissions.Administration || context.Permissions.Add; // DA RIVEDERE if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Module, ModuleCode = context.ModuleCode, IdModule = context.IdModule, ModulePermission = context.ModulePermissions }; addUrl = RootObject.Add(sessionId, TemplateType.Module, ownerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); ModuleObject obj = View.CurrentModuleObject; if (obj != null) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Object, IdObject = obj.ObjectLongID, IdObjectType = obj.ObjectTypeID, IdObjectCommunity = obj.CommunityID, IdObjectModule = obj.ServiceID, ModuleCode = context.ModuleCode, IdModule = context.IdModule, ModulePermission = context.ModulePermissions }; addObjectUrl = RootObject.Add(sessionId, TemplateType.Module, ownerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); } } dtoBaseTemplateOwner personalOwnerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Person, IdPerson = UserContext.CurrentUserID, ModuleCode = View.PreloadModuleCode, IdModule = (String.IsNullOrEmpty(View.PreloadModuleCode) ? 0 : CurrentManager.GetModuleID(View.PreloadModuleCode)) }; addPersonalUrl = RootObject.Add(sessionId, TemplateType.User, personalOwnerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); break; case TemplateType.User: if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = 0, IsPortal = true, Type = OwnerType.Person, IdPerson = UserContext.CurrentUserID, ModuleCode = View.PreloadModuleCode, IdModule = (String.IsNullOrEmpty(View.PreloadModuleCode) ? 0 : CurrentManager.GetModuleID(View.PreloadModuleCode)) }; addPersonalUrl = RootObject.Add(sessionId, TemplateType.User, ownerInfo, 0, context.ModuleCode, context.ModulePermissions); } break; } #endregion #region "Filters" dtoBaseFilters filters = (View.PreloadFromCookies) ? View.GetFromCookies() : null; if (filters == null) { filters = new dtoBaseFilters(); filters.Ascending = true; filters.SearchForName = ""; filters.Status = TemplateStatus.Active; filters.TemplateType = type; //filters.LoaderType = context.LoaderType; switch (type) { case TemplateType.Module: filters.ModuleCode = View.PreloadModuleCode; break; } filters.Ascending = true; filters.OrderBy = TemplateOrder.ByName; filters.TranslationsStatus = View.GetTranslationsStatus(); filters.TranslationsType = View.GetTranslationsTypes(); filters.TemplateDisplay = TemplateDisplay.OnlyVisible; View.SaveToCookies(filters); } #endregion View.InitializeList(context, filters, GetAvailableTypes(type), GetAvailableDisplay(type), allowAdd, addUrl, addPersonalUrl, addObjectUrl); }
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); } } }
public void InitView() { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(RootObject.List(View.PreloadIdCommunity, View.PreloadTemplateType, View.PreloadOwnership, View.PreloadFromCookies, View.PreloadModuleCode, View.PreloadModulePermissions, View.PreloadModulePermissions)); } else { Int32 idCommunity = View.PreloadIdCommunity; if (idCommunity < 0) { idCommunity = UserContext.CurrentCommunityID; } View.IdManagerCommunity = idCommunity; TemplateType type = View.PreloadTemplateType; if (type == TemplateType.None) { type = TemplateType.User; } dtoBaseFilters filters = (View.PreloadFromCookies) ? View.GetFromCookies() : null; if (filters == null) { filters = new dtoBaseFilters(); filters.Ascending = true; filters.SearchForName = ""; filters.Status = TemplateStatus.Active; filters.TemplateType = type; //filters.SetLoadingType(type); switch (type) { case TemplateType.Module: filters.ModuleCode = View.PreloadModuleCode; break; } filters.Ascending = true; filters.OrderBy = TemplateOrder.ByName; filters.TranslationsStatus = View.GetTranslationsStatus(); filters.TranslationsType = View.GetTranslationsTypes(); filters.TemplateDisplay = TemplateDisplay.OnlyVisible; View.SaveToCookies(filters); } Int32 idUser = UserContext.CurrentUserID; Boolean allowView = false; Boolean allowAdd = false; String addUrl = ""; dtoModuleContext context = new dtoModuleContext(); context.ModuleCode = View.PreloadModuleCode; context.ModulePermissions = View.PreloadModulePermissions; context.IdCommunity = idCommunity; dtoBaseTemplateOwner ownerInfo = null; ModuleTemplateMessages module = null; switch (type) { case TemplateType.System: module = ModuleTemplateMessages.CreatePortalmodule(UserContext.UserTypeID, OwnerType.System); allowView = module.Administration || module.List; allowAdd = module.Administration || module.Add; if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = 0, IsPortal = true, Type = OwnerType.System, ModuleCode = View.PreloadModuleCode, IdModule = (String.IsNullOrEmpty(View.PreloadModuleCode) ? 0 : CurrentManager.GetModuleID(View.PreloadModuleCode)) }; addUrl = RootObject.Add(TemplateType.System, ownerInfo, idCommunity, View.PreloadModuleCode, View.PreloadModulePermissions); } context.LoaderType = TemplateLoaderType.System; context.IdModule = Service.ServiceModuleID(); context.Permissions = new ModuleGenericTemplateMessages(module); break; case TemplateType.Module: if (context.ModuleCode == ModuleTemplateMessages.UniqueCode) { context.IdModule = Service.ServiceModuleID(); module = Service.GetPermission(idCommunity, OwnerType.Module); context.ModulePermissions = module.GetPermissions(); allowView = module.Administration || module.List; allowAdd = module.Administration || module.Add; if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Module, ModuleCode = context.ModuleCode, IdModule = context.IdModule, ModulePermission = context.ModulePermissions }; addUrl = RootObject.Add(TemplateType.Module, ownerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); } context.Permissions = new ModuleGenericTemplateMessages(module); context.LoaderType = TemplateLoaderType.Module; } else if (View.PreloadModulePermissions > 0) { context.IdModule = CurrentManager.GetModuleID(context.ModuleCode); long dbPermissions = CurrentManager.GetModulePermission(UserContext.CurrentUserID, idCommunity, context.IdModule); context.Permissions = View.GetModulePermissions(context.ModuleCode, context.IdModule, dbPermissions, idCommunity, UserContext.UserTypeID); if (lm.Comol.Core.DomainModel.PermissionHelper.CheckPermissionSoft(dbPermissions, context.ModulePermissions)) { allowView = true; allowAdd = true; if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Module, ModuleCode = context.ModuleCode, IdModule = context.IdModule, ModulePermission = context.ModulePermissions }; addUrl = RootObject.Add(TemplateType.Module, ownerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); } } context.LoaderType = TemplateLoaderType.OtherModule; } else { context.IdModule = CurrentManager.GetModuleID(context.ModuleCode); context.Permissions = View.GetModulePermissions(context.ModuleCode, context.IdModule, GetModulePermission(idCommunity, context.IdModule), idCommunity, UserContext.UserTypeID); context.LoaderType = TemplateLoaderType.OtherModule; allowView = context.Permissions.Administration || context.Permissions.List; allowAdd = context.Permissions.Administration || context.Permissions.Add; if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Module, ModuleCode = context.ModuleCode, IdModule = context.IdModule, ModulePermission = context.ModulePermissions }; addUrl = RootObject.Add(TemplateType.Module, ownerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); } } break; case TemplateType.User: Person p = GetCurrentUser(ref idUser); allowView = (p != null && p.TypeID != (Int32)UserTypeStandard.Guest && p.TypeID != (Int32)UserTypeStandard.PublicUser); allowAdd = allowView; if (allowAdd) { ownerInfo = new dtoBaseTemplateOwner() { IdCommunity = idCommunity, IsPortal = (idCommunity == 0), Type = OwnerType.Person, IdPerson = UserContext.CurrentUserID, ModuleCode = View.PreloadModuleCode, IdModule = (String.IsNullOrEmpty(View.PreloadModuleCode) ? 0 : CurrentManager.GetModuleID(View.PreloadModuleCode)) }; addUrl = RootObject.Add(TemplateType.User, ownerInfo, idCommunity, context.ModuleCode, context.ModulePermissions); } context.LoaderType = TemplateLoaderType.User; context.Permissions = new ModuleGenericTemplateMessages("personal"); context.Permissions.Add = allowView; context.Permissions.Administration = allowView; context.Permissions.Clone = allowView; context.Permissions.DeleteMyTemplates = allowView; context.Permissions.Edit = allowView; context.Permissions.List = allowView; break; } if (allowView) { if (allowAdd) { View.SetAddUrl(addUrl); } switch (type) { case TemplateType.User: case TemplateType.System: View.InitializeList(context, filters, GetAvailableTypes(type), GetAvailableDisplay(type)); break; case TemplateType.Module: View.InitializeList(context, filters, GetAvailableTypes(type), GetAvailableDisplay(type)); break; } } else { View.DisplayNoPermission(idCommunity, Service.ServiceModuleID()); } } }