Beispiel #1
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));
            }
        }
Beispiel #2
0
        private List <OwnerType> GetAvailableSaveAs()
        {
            List <OwnerType>       items   = new List <OwnerType>();
            dtoModuleContext       context = GetModuleContext(View.CurrentModuleCode, View.ModulePermissions, View.CurrentIdCommunity, View.CurrentTemplateType);
            ModuleTemplateMessages m       = ModuleTemplateMessages.CreatePortalmodule(UserContext.UserTypeID, OwnerType.Person);

            if (m.Add || m.Administration)
            {
                items.Add(OwnerType.Person);
            }
            if (context.Permissions.Add || context.Permissions.Administration)
            {
                items.Add(OwnerType.Module);
                if (View.CurrentModuleObject != null)
                {
                    items.Add(OwnerType.Object);
                }
            }
            return(items);
        }
Beispiel #3
0
        private dtoModuleContext GetModuleContext(String moduleCode, long permissions, Int32 idCommunity, TemplateType type)
        {
            Int32            idUser  = UserContext.CurrentUserID;
            dtoModuleContext context = new dtoModuleContext();

            context.ModuleCode = moduleCode;
            //context.ModulePermissions = View.PreloadModulePermissions;
            context.IdCommunity      = idCommunity;
            context.IdAction         = View.CurrentIdAction;
            context.AlsoEmptyActions = View.AlsoWithEmptyActions || (context.IdAction == 0);
            switch (type)
            {
            case TemplateType.Module:
                if (context.ModuleCode == ModuleTemplateMessages.UniqueCode)
                {
                    ModuleTemplateMessages module = null;
                    context.IdModule          = Service.ServiceModuleID();
                    context.ModulePermissions = module.GetPermissions();
                    module = Service.GetPermission(idCommunity, OwnerType.Module);
                    context.Permissions = new ModuleGenericTemplateMessages(module);
                    context.LoaderType  = TemplateLoaderType.Module;
                }
                else
                {
                    context.IdModule = CurrentManager.GetModuleID(context.ModuleCode);
                    ModuleObject obj = View.CurrentModuleObject;
                    if (obj != null && obj.ServiceID == 0 && !String.IsNullOrEmpty(obj.ServiceCode))
                    {
                        obj.ServiceID            = CurrentManager.GetModuleID(obj.ServiceCode);
                        View.CurrentModuleObject = obj;
                    }
                    else if (obj != null && obj.ServiceID > 0 && String.IsNullOrEmpty(obj.ServiceCode))
                    {
                        obj.ServiceCode          = CurrentManager.GetModuleCode(obj.ServiceID);
                        View.CurrentModuleObject = obj;
                    }
                    context.ModuleObject = obj;
                    //long dbPermissions = CurrentManager.GetModulePermission(UserContext.CurrentUserID, idCommunity, context.IdModule);
                    //if (lm.Comol.Core.DomainModel.PermissionHelper.CheckPermissionSoft(dbPermissions, context.ModulePermissions))
                    //{
                    //
                    //}
                    context.LoaderType = TemplateLoaderType.OtherModule;
                    if (permissions > 0)
                    {
                        context.Permissions = View.GetModulePermissions(context.ModuleCode, context.IdModule, CurrentManager.GetModulePermission(UserContext.CurrentUserID, idCommunity, context.IdModule), idCommunity, UserContext.UserTypeID, obj);
                    }
                    else
                    {
                        context.Permissions = View.GetModulePermissions(context.ModuleCode, context.IdModule, GetModulePermission(idCommunity, context.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);

                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;
            }
            return(context);
        }
Beispiel #4
0
        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());
                }
            }
        }