private void SetDeleteStatus(IMediaDetail detail, bool isDeleted)
        {
            UserMustHaveAccessTo(detail);

            if (!FrameworkSettings.CurrentUser.HasPermission(PermissionsEnum.Delete))
            {
                throw new Exception("You do not have the appropriate permissions to delete/undelete items");
            }

            detail           = BaseMapper.GetObjectFromContext((MediaDetail)detail);
            detail.IsDeleted = isDeleted;

            Return returnObj = MediaDetailsMapper.Update(detail);

            if (returnObj.IsError)
            {
                throw returnObj.Error.Exception;
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                detail.RemoveFromCache();
                FileCacheHelper.DeleteCacheDir("generatenav");
            }
        }
Ejemplo n.º 2
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (!canAccessSection)
            {
                return;
            }

            var settings = BaseMapper.GetObjectFromContext(SettingsMapper.GetSettings());

            UpdateObjectFromFields(settings);

            var returnObj = SettingsMapper.Update(settings);

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error saving settings", returnObj.Error);
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                FileCacheHelper.ClearAllCache();

                SettingsMapper.ClearCache();

                DisplaySuccessMessage("Successfully saved settings");
            }
        }
Ejemplo n.º 3
0
        private void Application_BeginRequest(Object source, EventArgs e)
        {
            var installerPath    = "~/Installer/";
            var absInstallerUrl  = URIHelper.ConvertToAbsUrl(installerPath);
            var absInstallerPath = URIHelper.ConvertToAbsPath(installerPath);

            if (Request.CurrentExecutionFilePathExtension == "" && !Request.Url.AbsoluteUri.StartsWith(absInstallerUrl))
            {
                if (Directory.Exists(absInstallerPath) && AppSettings.EnableInstaller)
                {
                    Response.Redirect(installerPath);
                }
            }


            if (AppSettings.IsRunningOnProd && AppSettings.ForceWWWRedirect)
            {
                var isSubDomain = (Request.Url.AbsoluteUri.Split('.').Length > 2);
                var isLocalHost = Request.Url.Host.StartsWith("localhost");

                if (!Request.Url.Host.StartsWith("www.") && !isLocalHost && !isSubDomain)
                {
                    Response.RedirectPermanent(Request.Url.AbsoluteUri.Replace("://", "://www."));
                }
            }


            BaseService.AddResponseHeaders();

            var virtualPathRequest = HttpContext.Current.Request.Path.EndsWith("/");

            if (virtualPathRequest)
            {
                Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
                Response.Cache.SetNoStore();
            }

            if (isFirstApplicationRequest)
            {
                ContextHelper.ClearAllMemoryCache();
                FrameworkBaseMedia.InitConnectionSettings(AppSettings.GetConnectionSettings());
                isFirstApplicationRequest = false;
            }

            if (Request.Url.AbsolutePath.Contains("robots.txt"))
            {
                var absPath = URIHelper.ConvertToAbsPath(Request.Url.AbsolutePath);

                if (File.Exists(absPath))
                {
                    var fileContent = File.ReadAllText(absPath);

                    var parsedContent = ParserHelper.ParseData(fileContent, BasePage.GetDefaultTemplateVars(""));

                    BaseService.WriteText(parsedContent);
                }
            }
        }
        public void DeletePermanently(long id)
        {
            var detail = MediaDetailsMapper.GetByID(id);

            if (detail != null)
            {
                UserMustHaveAccessTo(detail);

                detail.RemoveFromCache();

                HandleDeletePermanentlyRecursive(detail.Media);
                ContextHelper.ClearAllMemoryCache();
            }
        }
        private void HandleDeletePermanently(Media item)
        {
            if (!FrameworkSettings.CurrentUser.HasPermission(PermissionsEnum.Delete))
            {
                throw new Exception("You do not have the appropriate permissions to delete items permanently");
            }

            if (item == null)
            {
                return;
            }

            MediaDetail detail      = (MediaDetail)GetAtleastOneByMedia(item);
            Media       parentMedia = null;

            if (item.ParentMediaID != null)
            {
                parentMedia = MediasMapper.GetByID((long)item.ParentMediaID);
            }

            Return returnObj = BaseMapper.GenerateReturn("No action performed");

            if (detail == null)
            {
                if (item.ChildMedias.Count == 0)
                {
                    returnObj = MediasMapper.DeletePermanently(item);
                }
            }
            else
            {
                item = BaseMapper.GetObjectFromContext(item);
                if ((item.MediaDetails.Count == 1) && (item.ChildMedias.Count > 0))
                {
                    throw new Exception("You cannot delete this item because it has child items");
                }

                detail    = BaseMapper.GetObjectFromContext(detail);
                returnObj = MediaDetailsMapper.DeletePermanently(detail);

                if (!returnObj.IsError)
                {
                    ContextHelper.ClearAllMemoryCache();
                    detail.RemoveFromCache();
                }
            }
        }
        public string Duplicate(long id, bool duplicateChildren = false, string newName = "")
        {
            var detail = MediaDetailsMapper.GetByID(id);

            if (detail != null)
            {
                UserMustHaveAccessTo(detail);

                var mediaDetail = HandleDuplicate(detail, detail.Media.ParentMedia, duplicateChildren, newName, false);

                ContextHelper.ClearAllMemoryCache();

                var url = WebApplication.BasePage.GetAdminUrl(mediaDetail.MediaTypeID, mediaDetail.MediaID);
                return(url);
            }

            return("");
        }
        private Return SetPublishStatus(MediaDetail detail, bool publishStatus)
        {
            if ((detail == null) || (detail.IsPublished == publishStatus))
            {
                return(new Return());
            }

            detail = BaseMapper.GetObjectFromContext(detail);

            if (publishStatus)
            {
                detail.PublishDate = DateTime.Now;
            }
            else
            {
                detail.PublishDate = null;
            }

            Return returnObj = MediaDetailsMapper.Update(detail);

            if (returnObj.IsError)
            {
                return(returnObj);
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                FileCacheHelper.DeleteCacheDir("generatenav");

                if (publishStatus)
                {
                    detail.PublishDate = DateTime.Now;

                    returnObj = detail.RunOnPublishExecuteCode();

                    return(returnObj);
                }

                return(returnObj);
            }
        }
        private void SetShowInMenuStatus(MediaDetail detail, bool showInMenu)
        {
            if ((detail == null) || (detail.ShowInMenu == showInMenu))
            {
                return;
            }

            detail            = BaseMapper.GetObjectFromContext(detail);
            detail.ShowInMenu = showInMenu;

            Return returnObj = MediaDetailsMapper.Update(detail);

            if (returnObj.IsError)
            {
                throw returnObj.Error.Exception;
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                FileCacheHelper.DeleteCacheDir("generatenav");
            }
        }
Ejemplo n.º 9
0
        public void Page_PreInit(object sender, EventArgs e)
        {
            var httpRuntimeSection = new System.Web.Configuration.HttpRuntimeSection();
            var settings           = GetSettings();

            if (settings.MaxRequestLength > 0)
            {
                httpRuntimeSection.MaxRequestLength = settings.MaxRequestLength;
            }

            WebFormHelper.ClearIncludesList();
            PreloadHelper.PreloadList.Clear();

            if (AppSettings.UseLoadFileServiceUrl)
            {
                WebFormHelper.LoadFileServiceUrl = AppSettings.FileServiceHandlerUrl + AppSettings.LoadFileUriSegment;
            }
            else
            {
                WebFormHelper.LoadFileServiceUrl = "";
            }

            WebFormHelper.CombineCssAndJsIncludes = AppSettings.CombineCssAndJsIncludes;

            if (Request["action"] != null)
            {
                switch (Request["action"].ToLower())
                {
                case "clearcache":
                    ContextHelper.ClearAllMemoryCache();
                    break;

                case "logout":
                    FormsAuthentication.SignOut();
                    break;
                }
            }

            if (this.MasterPageFile != null)
            {
                var masterFilePath = GetMasterPageFilePath();

                if (File.Exists(URIHelper.ConvertToAbsPath(masterFilePath)))
                {
                    MasterPageFile = masterFilePath;
                }
                else
                {
                    MasterPageFile = "";
                }
            }

            if (currentPageVirtualPath == "")
            {
                currentPageVirtualPath = URIHelper.GetCurrentVirtualPath();
            }

            if (FrameworkSettings.Current?.CurrentMediaDetail == null)
            {
                return;
            }

            if (currentPageVirtualPath == "")
            {
                currentPageVirtualPath = URIHelper.GetCurrentVirtualPath();
            }

            if (!CanAccessSection())
            {
                FormsAuthentication.RedirectToLoginPage();
                return;
            }
        }