Exemplo n.º 1
0
        public void InitView(long idMessage, Int32 idCommunity)
        {
            View.IdLoaderCommunity = 0;
            if (IsSessionTimeout())
            {
                return;
            }

            View.IdLoaderCommunity = UserContext.CurrentCommunityID;
            NoticeboardMessage message = null;

            if (idMessage != 0)
            {
                message = Service.GetMessage(idMessage);
            }

            Boolean isForPortal = (message != null && message.isForPortal) || (message == null && idCommunity == 0);

            View.SetHeaderTitle(isForPortal, (isForPortal) ? View.PortalName : CurrentManager.GetCommunityName(idCommunity));
            if (message == null && idMessage > 0)
            {
                View.SendUserAction(idCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewUnknownMessage);
            }
            else if (message == null && idMessage == 0)
            {
                View.SendUserAction(idCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewEmptyMessage);
            }
            else
            {
                ModuleNoticeboard module = null;
                if (message.isForPortal)
                {
                    module = ModuleNoticeboard.CreatePortalmodule((UserContext.isAnonymous) ? (int)UserTypeStandard.Guest : UserContext.UserTypeID);
                }
                else if (idCommunity > 0)
                {
                    module = new ModuleNoticeboard(CurrentManager.GetModulePermission(UserContext.CurrentUserID, idCommunity, ModuleID));
                }
                else
                {
                    module = new ModuleNoticeboard();
                }
                if (module.Administration || module.ViewCurrentMessage || module.ViewOldMessage)
                {
                    View.DisplayMessage(idMessage, idCommunity);
                    View.SendUserAction(idCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewMessage);
                }
                else
                {
                    View.SendUserAction(idCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.NoPermission);
                }
                View.AllowPrint = module.Administration || module.ViewCurrentMessage || module.PrintMessage;
            }
        }
Exemplo n.º 2
0
        public ModuleNoticeboard GetPermissions(int idCommunity)
        {
            ModuleNoticeboard permissions = null;

            try
            {
                if (idCommunity > 0 || idCommunity < 0)
                {
                    permissions = new ModuleNoticeboard(Manager.GetModulePermission(UC.CurrentUserID, idCommunity, Manager.GetModuleID(ModuleNoticeboard.UniqueID)));
                }
                else
                {
                    permissions = ModuleNoticeboard.CreatePortalmodule(UC.UserTypeID);
                }
            }
            catch (Exception ex) { }

            return(permissions);
        }
Exemplo n.º 3
0
        public void InitView(String editorConfigurationPath, System.Guid currentWorkingApplicationId)
        {
            NoticeboardMessage message = null;

            EditorConfiguration config = ServiceEditor.GetConfiguration(editorConfigurationPath);

            if (config != null)
            {
                ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == ModuleNoticeboard.UniqueID).FirstOrDefault();
                if (mSettings == null && config.CssFiles.Any())
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && mSettings.CssFiles.Any() && mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, mSettings.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && !mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
            }

            long idMessage   = View.PreloadedIdMessage;
            int  IdCommunity = View.PreloadedIdCommunity;

            if (idMessage != 0)
            {
                message = Service.GetMessage(idMessage);
            }
            else
            {
                message = Service.GetLastMessage(IdCommunity);
                if (message != null)
                {
                    idMessage = message.Id;
                }
            }
            if (message != null && message.Community != null)
            {
                IdCommunity = message.Community.Id;
            }
            else if (message != null && message.isForPortal)
            {
                IdCommunity = 0;
            }
            else
            {
                IdCommunity = UserContext.WorkingCommunityID;
            }

            Community community = null;

            if (IdCommunity > 0)
            {
                community = CurrentManager.GetCommunity(IdCommunity);
            }
            if (community == null && IdCommunity > 0)
            {
                View.ContainerName = "";
            }
            else if (community != null)
            {
                View.ContainerName = community.Name;
            }
            else
            {
                View.ContainerName = View.PortalName;
            }

            Boolean anonymousViewAllowed = (View.PreloadWorkingApplicationId != Guid.Empty && View.PreloadWorkingApplicationId == currentWorkingApplicationId);

            if (message == null && idMessage > 0)
            {
                View.DisplayUnknownMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewUnknownMessage);
            }
            else if (message == null && idMessage == 0)
            {
                View.DisplayEmptyMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewEmptyMessage);
            }
            else if (UserContext.isAnonymous && !anonymousViewAllowed)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                View.IdCurrentMessage = idMessage;

                ModuleNoticeboard module = null;
                if (IdCommunity == 0 && message.isForPortal)
                {
                    module = ModuleNoticeboard.CreatePortalmodule((UserContext.isAnonymous) ? (int)UserTypeStandard.Guest : UserContext.UserTypeID);
                }
                else if (IdCommunity > 0)
                {
                    module = new ModuleNoticeboard(CurrentManager.GetModulePermission(UserContext.CurrentUserID, IdCommunity, ModuleID));
                }
                else
                {
                    module = new ModuleNoticeboard();
                }
                if (module.Administration || module.ViewCurrentMessage || module.ViewOldMessage || anonymousViewAllowed)
                {
                    View.DisplayMessage(message);
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewMessage);
                }
                else
                {
                    View.DisplayNoPermission();
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.NoPermission);
                }
            }
        }