diff --git a/umbraco/presentation/UmbracoContext.cs b/umbraco/presentation/UmbracoContext.cs
index 641f36c521..087d09cce1 100644
--- a/umbraco/presentation/UmbracoContext.cs
+++ b/umbraco/presentation/UmbracoContext.cs
@@ -67,6 +67,19 @@ namespace umbraco.presentation
}
}
+ ///
+ /// Gets the current logged in Umbraco user (editor).
+ ///
+ /// The Umbraco user object or null
+ public virtual User UmbracoUser
+ {
+ get
+ {
+ return BasePages.UmbracoEnsuredPage.CurrentUser;
+ }
+
+ }
+
///
/// Determines whether the current user is in a preview mode
///
@@ -74,7 +87,8 @@ namespace umbraco.presentation
{
get
{
- return !String.IsNullOrEmpty(StateHelper.GetCookieValue("PreviewSet"));
+ return !String.IsNullOrEmpty(StateHelper.GetCookieValue("PreviewSet")) &&
+ UmbracoUser != null;
}
}
@@ -147,7 +161,7 @@ namespace umbraco.presentation
{
if (m_Response == null)
{
- m_Response = new UmbracoResponse(this.m_HttpContext.Response);
+ m_Response = new UmbracoResponse(this.m_HttpContext.Response);
}
return m_Response;
}
@@ -163,7 +177,7 @@ namespace umbraco.presentation
{
if (m_Request == null)
{
- m_Request = new UmbracoRequest(this.m_HttpContext.Request);
+ m_Request = new UmbracoRequest(this.m_HttpContext.Request);
}
return m_Request;
}
diff --git a/umbraco/presentation/content.cs b/umbraco/presentation/content.cs
index ab40a024ed..2d1104d112 100644
--- a/umbraco/presentation/content.cs
+++ b/umbraco/presentation/content.cs
@@ -262,7 +262,8 @@ namespace umbraco
// check if document *is* published, it could be unpublished by an event
if (d.Published)
{
- AppendDocumentXml(d.Id, d.Level, d.Parent.Id, getPreviewOrPublishedNode(d, xmlContentCopy, false), xmlContentCopy);
+ int parentId = d.Level == 1 ? -1 : d.Parent.Id;
+ AppendDocumentXml(d.Id, d.Level, parentId, getPreviewOrPublishedNode(d, xmlContentCopy, false), xmlContentCopy);
// update sitemapprovider
if (updateSitemapProvider && SiteMap.Provider is presentation.nodeFactory.UmbracoSiteMapProvider)
diff --git a/umbraco/presentation/library.cs b/umbraco/presentation/library.cs
index c4b37db4f2..d81258a7e7 100644
--- a/umbraco/presentation/library.cs
+++ b/umbraco/presentation/library.cs
@@ -1386,6 +1386,8 @@ namespace umbraco
/// Returns the string without starting and endning paragraph tags
public static string RemoveFirstParagraphTag(string text)
{
+ if (String.IsNullOrEmpty(text))
+ return "";
text = text.Trim().Replace("\n", string.Empty).Replace("\r", string.Empty);
if (text.Length > 5)
{
diff --git a/umbraco/presentation/umbraco/preview/Preview.cs b/umbraco/presentation/umbraco/preview/Preview.cs
index b06e0e04a9..244d2138e1 100644
--- a/umbraco/presentation/umbraco/preview/Preview.cs
+++ b/umbraco/presentation/umbraco/preview/Preview.cs
@@ -33,8 +33,8 @@ namespace umbraco.presentation.preview
m_userId = user.Id;
// clone xml
- XmlContent = (XmlDocument) content.Instance.XmlContent.Clone();
-
+ XmlContent = (XmlDocument)content.Instance.XmlContent.Clone();
+
// inject current document xml
int parentId = documentObject.Level == 1 ? -1 : documentObject.Parent.Id;
content.AppendDocumentXml(documentObject.Id, documentObject.Level, parentId, documentObject.ToPreviewXml(XmlContent), XmlContent);
@@ -58,9 +58,7 @@ namespace umbraco.presentation.preview
{
PreviewSet = previewSet;
PreviewsetPath = IO.IOHelper.MapPath(
- Path.Combine(
- Path.Combine(IO.SystemDirectories.Data, "previews"),
- PreviewSet + ".config"));
+ Path.Combine(IO.SystemDirectories.Preview, PreviewSet + ".config"));
}
public void LoadPreviewset()