Merge with 4.8.1 (2nd)

This commit is contained in:
sebastiaan
2012-08-14 07:21:18 -02:00
27 changed files with 702 additions and 679 deletions

View File

@@ -8,3 +8,4 @@ d03fcffb8834a9583a56813bb44b6abbd9f042cc Release-4.6.0
1809f7b2593270c192cd47bdcfdb392100686f79 4.7.2
488779dec0ceb1d2874bcef906241b919325c904 4.8.0-beta
096f20bb0575d6199f20fcb3147b63554e765a74 Release-4.8.0
8f8a203857886b373148af29edd57460a42940be Release-4.8.1

View File

@@ -1,6 +1,6 @@
/*******************************************************************************************
Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x)
Umbraco database installation script for SQL CE (upgrade from Umbraco 4.0.x)
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
@@ -24,133 +24,8 @@
********************************************************************************************/
/* INSERT NEW MEDIA RECYCLE BIN NODE */
SET IDENTITY_INSERT [umbracoNode] ON
INSERT INTO umbracoNode (id, trashed, parentID, nodeUser, level, path, sortOrder, uniqueID, text, nodeObjectType)
VALUES (-21, 0, -1, 0, 0, '-1,-21', 0, 'BF7C7CBC-952F-4518-97A2-69E9C7B33842', 'Recycle Bin', 'CF3D8E34-1C1C-41e9-AE56-878B57B32113')
SET IDENTITY_INSERT [umbracoNode] OFF
/* REMOVE CONSTRAINTS */
ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoApp]
;
/* Add the mediaRecycleBin tree type */
IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='mediaRecycleBin')
INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType)
VALUES (0, 0, 0, 'media', 'mediaRecycleBin', 'RecycleBin', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.MediaRecycleBin')
;
CREATE TABLE [cmsPreviewXml](
[nodeId] [int] NOT NULL,
[versionId] [uniqueidentifier] NOT NULL,
[timestamp] [datetime] NOT NULL,
[xml] [ntext] NOT NULL,
CONSTRAINT [PK_cmsContentPreviewXml] PRIMARY KEY CLUSTERED
(
[nodeId] ASC,
[versionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
/************************** CLEANUP ***********************************************/
/* DELETE NON-EXISTING DOCUMENTS */
delete from cmsDocument where nodeId not in (select id from umbracoNode)
;
/* CLEAN UNUSED CONTENT ROWS */
delete from cmsContent where nodeId not in (select id from umbracoNode)
;
/* CLEAN UNUSED VERSIONS */
delete from cmsContentVersion where contentid not in (select nodeId from cmsContent)
;
/* CLEAN UNUSED XML */
delete from cmsContentXml where nodeid not in (select nodeId from cmsContent)
;
/* CLEAN UNUSED DOCUMENT TYPES */
delete from cmsDocumentType where contentTypeNodeId not in (select nodeId from cmsContentType)
;
delete from cmsDocumentType where templateNodeId not in (select nodeid from cmsTemplate)
;
/* UPDATE EMPTY TEMPLATE REFERENCES IN DOCUMENTS */
update cmsDocument set templateId = NULL where templateId not in (select nodeId from cmsTemplate)
;
/* DELETE ALL NOTIFICATIONS THAT NO LONGER HAVE NODES */
delete from umbracoUser2NodeNotify where nodeId not in (select id from umbracoNode)
;
/* DELETE ALL NOTIFICATIONS THAT NO LONGER HAVE USERS */
delete from umbracoUser2NodeNotify where userId not in (select id from umbracoUser)
;
/* DELETE UMBRACO NODE DATA THAT IS FLAGGED AS A DOCUMENT OBJECT TYPE THAT DOESN'T EXIST IN THE CONTENT TABLE ANY LONGER */
delete from umbracoNode where id not in
(select nodeId from cmsContent) and nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972'
;
/* DELETE PERMISSIONS THAT RELATED TO NON-EXISTING USERS */
delete from umbracoUser2NodePermission where userId not in (select id from umbracoUser)
;
/* DELETE PERMISSIONS THAT RELATED TO NON-EXISTING NODES */
delete from umbracoUser2NodePermission where nodeId not in (select id from umbracoNode)
;
/* SET MASTER TEMPLATE TO NULL WHEN THERE ISN'T ONE SPECIFIED */
update cmsTemplate set [master] = NULL where [master] = 0
/*
We need to remove any data type that doesn't exist in umbracoNode as these shouldn't actually exist
I think they must be left over from how Umbraco used to show the types of data types registered instead
of using reflection. Here are the data types in the cmsDataType table that are not in umbracoNode:
12 -91 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar
22 -44 A3776494-0574-4D93-B7DE-EFDFDEC6F2D1 Ntext
23 -128 A52C7C1C-C330-476E-8605-D63D3B84B6A6 Nvarchar
24 -129 928639ED-9C73-4028-920C-1E55DBB68783 Nvarchar
25 -130 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar
26 -131 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar
27 -132 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar
28 -133 6C738306-4C17-4D88-B9BD-6546F3771597 Ntext
29 -134 928639ED-9C73-4028-920C-1E55DBB68783 Nvarchar
30 -50 AAF99BB2-DBBE-444D-A296-185076BF0484 Date
39 1042 5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83 Ntext
40 1043 5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83 Ntext
41 1044 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Ntext
42 1045 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Ntext
47 1194 D15E1281-E456-4B24-AA86-1DDA3E4299D5 Ntext
*/
DELETE FROM cmsDataType WHERE nodeId NOT IN (SELECT id FROM umbracoNode)
;
/* Need to remove any data type prevalues that aren't related to a data type */
DELETE FROM cmsDataTypePreValues WHERE dataTypeNodeID NOT IN (SELECT nodeId FROM cmsDataType)
;
/* Remove any domains that should not exist as they weren't deleted before when documents were deleted */
DELETE FROM umbracoDomains WHERE domainRootStructureId NOT IN (SELECT id FROM umbracoNode)
;
-- It would be good to add constraints from cmsLanguageText to umbracoLanguage but unfortunately, a 'zero' id
-- is entered into cmsLanguageText when a new entry is made, since there's not language with id of zero this won't work.
-- However, we need to remove translations that aren't related to a language (these would be left over from deleting a language)
DELETE FROM cmsLanguageText
WHERE languageId <> 0 AND languageId NOT IN (SELECT id FROM umbracoLanguage)
;
/* need to remove any content restrictions that don't exist in cmsContent */
DELETE FROM cmsContentTypeAllowedContentType WHERE id NOT IN (SELECT nodeId FROM cmsContentType)
;
DELETE FROM cmsContentTypeAllowedContentType WHERE Allowedid NOT IN (SELECT nodeId FROM cmsContentType)
;
/* Though this should not have to be run because it's a new install, you need to clean the previews if you've been testing before the RC */
DELETE FROM cmsPreviewXml WHERE VersionID NOT IN (SELECT VersionId FROM cmsContentVersion)
;
/************************** CLEANUP END ********************************************/
ALTER TABLE [umbracoAppTree] DROP CONSTRAINT [FK_umbracoAppTree_umbracoApp]
;

View File

@@ -22,14 +22,15 @@ namespace SqlCE4Umbraco
#region Private Constants
/// <summary>The latest database version this installer supports.</summary>
private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_1;
private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8;
/// <summary>The specifications to determine the database version.</summary>
private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] {
new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1),
new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4),
new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3),
new VersionSpecs("id","sysobjects",DatabaseVersion.None) };
new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 0, DatabaseVersion.Version4_8),
new VersionSpecs("SELECT id FROM umbracoNode WHERE id = -21", 1, DatabaseVersion.Version4_1),
new VersionSpecs("SELECT action FROM umbracoAppTree",DatabaseVersion.Version4),
new VersionSpecs("SELECT description FROM cmsContentType",DatabaseVersion.Version3),
new VersionSpecs("SELECT id FROM sysobjects",DatabaseVersion.None) };
#endregion
@@ -58,7 +59,7 @@ namespace SqlCE4Umbraco
{
get
{
return false;
return CurrentVersion == DatabaseVersion.Version4_1;
}
}

View File

@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.269
// Runtime Version:4.0.30319.17626
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -88,7 +88,7 @@ namespace SQLCE4Umbraco {
/// <summary>
/// Looks up a localized string similar to /*******************************************************************************************
///
/// Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x)
/// Umbraco database installation script for SQL CE (upgrade from Umbraco 4.0.x)
///
/// IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
///
@@ -96,7 +96,7 @@ namespace SQLCE4Umbraco {
///
/// Please increment this version number if ANY change is made to this script,
/// so compatibility with scripts for other database systems can be verified easily.
/// The first 3 digits depict [rest of string was truncated]&quot;;.
/// The first 3 digits depict the [rest of string was truncated]&quot;;.
/// </summary>
internal static string Version4_1_Upgrade {
get {

View File

@@ -77,12 +77,19 @@ namespace umbraco.MacroEngines
var contextWrapper = new HttpContextWrapper(context);
//inject http context - for request response
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Context (file: {0})", macro.Name));
razorWebPage.Context = contextWrapper;
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Context (file: {0})", macro.Name));
//Inject Macro Model And Parameters
if (razorWebPage is IMacroContext) {
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Boxing Macro Script MacroContext (file: {0})", macro.Name));
var razorMacro = (IMacroContext)razorWebPage;
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Boxing Macro Script MacroContext (file: {0})", macro.Name));
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Model (file: {0})", macro.Name));
razorMacro.SetMembers(macro, currentPage);
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Model (file: {0})", macro.Name));
}
}
@@ -106,11 +113,16 @@ namespace umbraco.MacroEngines
return String.Empty; //No File Location
var razorWebPage = CompileAndInstantiate(fileLocation);
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Context (file: {0})", macro.Name));
InjectContext(razorWebPage, macro, currentPage);
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Context (file: {0})", macro.Name));
//Output Razor To String
var output = new StringWriter();
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Executing Macro Script (file: {0})", macro.Name));
razorWebPage.ExecutePageHierarchy(new WebPageContext(contextWrapper, razorWebPage, null), output);
HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Executing Macro Script (file: {0})", macro.Name));
return output.ToString();
}

View File

@@ -2,22 +2,25 @@ using System;
using System.Data;
using System.Web;
using System.Linq;
using System.Web.Security;
using umbraco.BusinessLogic;
using umbraco.DataLayer;
using umbraco.IO;
using System.Web.UI;
namespace umbraco.BasePages {
namespace umbraco.BasePages
{
/// <summary>
/// umbraco.BasePages.BasePage is the default page type for the umbraco backend.
/// The basepage keeps track of the current user and the page context. But does not
/// Restrict access to the page itself.
/// The keep the page secure, the umbracoEnsuredPage class should be used instead
/// </summary>
public class BasePage : System.Web.UI.Page {
public class BasePage : System.Web.UI.Page
{
private User _user;
private bool _userisValidated = false;
private ClientTools m_clientTools;
private ClientTools m_clientTools;
// ticks per minute 600,000,000
private static long _ticksPrMinute = 600000000;
@@ -42,70 +45,78 @@ namespace umbraco.BasePages {
/// Gets the SQL helper.
/// </summary>
/// <value>The SQL helper.</value>
protected static ISqlHelper SqlHelper {
protected static ISqlHelper SqlHelper
{
get { return umbraco.BusinessLogic.Application.SqlHelper; }
}
/// <summary>
/// Initializes a new instance of the <see cref="BasePage"/> class.
/// </summary>
public BasePage() {
public BasePage()
{
}
/// <summary>
/// Returns the current BasePage for the current request.
/// This assumes that the current page is a BasePage, otherwise, returns null;
/// </summary>
public static BasePage Current
{
get
{
return HttpContext.Current.CurrentHandler as BasePage;
}
}
/// <summary>
/// Returns a refernce of an instance of ClientTools for access to the pages client API
/// </summary>
public ClientTools ClientTools
{
get
{
if (m_clientTools == null)
m_clientTools = new ClientTools(this);
return m_clientTools;
}
}
[Obsolete("Use ClientTools instead")]
public void RefreshPage(int Seconds)
{
ClientTools.RefreshAdmin(Seconds);
/// <summary>
/// Returns the current BasePage for the current request.
/// This assumes that the current page is a BasePage, otherwise, returns null;
/// </summary>
public static BasePage Current
{
get
{
return HttpContext.Current.CurrentHandler as BasePage;
}
}
private void validateUser() {
if ((umbracoUserContextID != "")) {
/// <summary>
/// Returns a refernce of an instance of ClientTools for access to the pages client API
/// </summary>
public ClientTools ClientTools
{
get
{
if (m_clientTools == null)
m_clientTools = new ClientTools(this);
return m_clientTools;
}
}
[Obsolete("Use ClientTools instead")]
public void RefreshPage(int Seconds)
{
ClientTools.RefreshAdmin(Seconds);
}
private void validateUser()
{
if ((umbracoUserContextID != ""))
{
uid = GetUserId(umbracoUserContextID);
timeout = GetTimeout(umbracoUserContextID);
if (timeout > DateTime.Now.Ticks) {
if (timeout > DateTime.Now.Ticks)
{
_user = BusinessLogic.User.GetUser(uid);
// Check for console access
if (_user.Disabled || (_user.NoConsole && GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && !GlobalSettings.RequestIsLiveEditRedirector(HttpContext.Current)))
{
throw new ArgumentException("You have no priviledges to the umbraco console. Please contact your administrator");
}
}
else
{
_userisValidated = true;
updateLogin();
}
} else {
}
else
{
throw new ArgumentException("User has timed out!!");
}
} else
}
else
throw new ArgumentException("The user has no umbraco contextid - try logging in");
}
@@ -114,9 +125,12 @@ namespace umbraco.BasePages {
/// </summary>
/// <param name="umbracoUserContextID">The umbraco user context ID.</param>
/// <returns></returns>
public static int GetUserId(string umbracoUserContextID) {
try {
if (System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID] == null) {
public static int GetUserId(string umbracoUserContextID)
{
try
{
if (System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID] == null)
{
System.Web.HttpRuntime.Cache.Insert(
"UmbracoUserContext" + umbracoUserContextID,
SqlHelper.ExecuteScalar<int>("select userID from umbracoUserLogins where contextID = @contextId",
@@ -131,7 +145,9 @@ namespace umbraco.BasePages {
return (int)System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID];
} catch {
}
catch
{
return -1;
}
}
@@ -143,7 +159,8 @@ namespace umbraco.BasePages {
/// </summary>
/// <param name="umbracoUserContextID">The umbraco user context ID.</param>
/// <returns></returns>
public static bool ValidateUserContextID(string currentUmbracoUserContextID) {
public static bool ValidateUserContextID(string currentUmbracoUserContextID)
{
if ((currentUmbracoUserContextID != ""))
{
int uid = GetUserId(currentUmbracoUserContextID);
@@ -153,14 +170,16 @@ namespace umbraco.BasePages {
{
return true;
}
BusinessLogic.Log.Add(BusinessLogic.LogTypes.Logout, BusinessLogic.User.GetUser(uid), -1, "");
}
return false;
}
private static long GetTimeout(string umbracoUserContextID) {
if (System.Web.HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID] == null) {
private static long GetTimeout(string umbracoUserContextID)
{
if (System.Web.HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID] == null)
{
System.Web.HttpRuntime.Cache.Insert(
"UmbracoUserContextTimeout" + umbracoUserContextID,
GetTimeout(true),
@@ -171,8 +190,8 @@ namespace umbraco.BasePages {
}
object timeout = HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID];
if(timeout != null)
return (long) timeout;
if (timeout != null)
return (long)timeout;
return 0;
@@ -198,25 +217,64 @@ namespace umbraco.BasePages {
/// Gets or sets the umbraco user context ID.
/// </summary>
/// <value>The umbraco user context ID.</value>
public static string umbracoUserContextID {
public static string umbracoUserContextID
{
get
{
// zb-00004 #29956 : refactor cookies names & handling
if (StateHelper.Cookies.HasCookies && StateHelper.Cookies.UserContext.HasValue)
return StateHelper.Cookies.UserContext.GetValue();
else
return "";
}
set {
// zb-00004 #29956 : refactor cookies names & handling
if (StateHelper.Cookies.HasCookies)
{
// Clearing all old cookies before setting a new one.
if (StateHelper.Cookies.UserContext.HasValue)
StateHelper.Cookies.ClearAll();
// zb-00004 #29956 : refactor cookies names & handling
if (StateHelper.Cookies.HasCookies && StateHelper.Cookies.UserContext.HasValue)
{
try
{
string encTicket = StateHelper.Cookies.UserContext.GetValue();
if (!String.IsNullOrEmpty(encTicket))
return FormsAuthentication.Decrypt(encTicket).UserData;
}
catch (HttpException ex)
{
// we swallow this type of exception as it happens if a legacy (pre 4.8.1) cookie is set
}
catch (ArgumentException ex)
{
// we swallow this one because it's 99.99% certaincy is legacy based. We'll still log it, though
Log.Instance.AddException(ex);
// Create new cookie.
StateHelper.Cookies.UserContext.SetValue(value, 1);
}
}
return "";
}
set
{
// zb-00004 #29956 : refactor cookies names & handling
if (StateHelper.Cookies.HasCookies)
{
// Clearing all old cookies before setting a new one.
if (StateHelper.Cookies.UserContext.HasValue)
StateHelper.Cookies.ClearAll();
if (!String.IsNullOrEmpty(value))
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
value,
DateTime.Now,
DateTime.Now.AddDays(1),
false,
value,
FormsAuthentication.FormsCookiePath);
// Encrypt the ticket.
string encTicket = FormsAuthentication.Encrypt(ticket);
// Create new cookie.
StateHelper.Cookies.UserContext.SetValue(encTicket, 1);
} else
{
StateHelper.Cookies.UserContext.Clear();
}
}
}
}
@@ -261,7 +319,8 @@ namespace umbraco.BasePages {
/// Logs a user in.
/// </summary>
/// <param name="u">The user</param>
public static void doLogin(User u) {
public static void doLogin(User u)
{
Guid retVal = Guid.NewGuid();
SqlHelper.ExecuteNonQuery(
"insert into umbracoUserLogins (contextID, userID, timeout) values (@contextId,'" + u.Id + "','" +
@@ -277,7 +336,8 @@ namespace umbraco.BasePages {
/// Gets the user.
/// </summary>
/// <returns></returns>
public User getUser() {
public User getUser()
{
if (!_userisValidated) validateUser();
return _user;
}
@@ -285,26 +345,28 @@ namespace umbraco.BasePages {
/// <summary>
/// Ensures the page context.
/// </summary>
public void ensureContext() {
public void ensureContext()
{
validateUser();
}
[Obsolete("Use ClientTools instead")]
public void speechBubble(speechBubbleIcon i, string header, string body)
{
ClientTools.ShowSpeechBubble(i, header, body);
[Obsolete("Use ClientTools instead")]
public void speechBubble(speechBubbleIcon i, string header, string body)
{
ClientTools.ShowSpeechBubble(i, header, body);
}
//[Obsolete("Use ClientTools instead")]
//public void reloadParentNode()
//{
// ClientTools.ReloadParentNode(true);
//}
//[Obsolete("Use ClientTools instead")]
//public void reloadParentNode()
//{
// ClientTools.ReloadParentNode(true);
//}
/// <summary>
/// a collection of available speechbubble icons
/// </summary>
public enum speechBubbleIcon {
public enum speechBubbleIcon
{
/// <summary>
/// Save icon
/// </summary>
@@ -331,10 +393,12 @@ namespace umbraco.BasePages {
/// Raises the <see cref="E:System.Web.UI.Control.Load"></see> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
protected override void OnLoad(EventArgs e) {
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!Request.IsSecureConnection && GlobalSettings.UseSSL) {
if (!Request.IsSecureConnection && GlobalSettings.UseSSL)
{
string serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);
Response.Redirect(string.Format("https://{0}{1}", serverName, Request.FilePath));
}

View File

@@ -18,7 +18,7 @@ namespace umbraco
{
#region Private static fields
// CURRENT UMBRACO VERSION ID
private static string _currentVersion = "4.8.0";
private static string _currentVersion = "4.8.1";
private static string _reservedUrlsCache;
private static string _reservedPathsCache;

View File

@@ -8,9 +8,9 @@ namespace umbraco.BusinessLogic
/// <summary>
/// The StateHelper class provides general helper methods for handling sessions, context, viewstate and cookies.
/// </summary>
public class StateHelper
{
#region Session Helpers
public class StateHelper
{
#region Session Helpers
/// <summary>
/// Gets the session value.
@@ -18,10 +18,10 @@ namespace umbraco.BusinessLogic
/// <typeparam name="T"></typeparam>
/// <param name="key">The key.</param>
/// <returns></returns>
public static T GetSessionValue<T>(string key)
{
return GetSessionValue<T>(HttpContext.Current, key);
}
public static T GetSessionValue<T>(string key)
{
return GetSessionValue<T>(HttpContext.Current, key);
}
/// <summary>
/// Gets the session value.
@@ -30,25 +30,25 @@ namespace umbraco.BusinessLogic
/// <param name="context">The context.</param>
/// <param name="key">The key.</param>
/// <returns></returns>
public static T GetSessionValue<T>(HttpContext context, string key)
{
if (context == null)
return default(T);
object o = context.Session[key];
if (o == null)
return default(T);
return (T)o;
}
public static T GetSessionValue<T>(HttpContext context, string key)
{
if (context == null)
return default(T);
object o = context.Session[key];
if (o == null)
return default(T);
return (T)o;
}
/// <summary>
/// Sets a session value.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public static void SetSessionValue(string key, object value)
{
SetSessionValue(HttpContext.Current, key, value);
}
public static void SetSessionValue(string key, object value)
{
SetSessionValue(HttpContext.Current, key, value);
}
/// <summary>
/// Sets the session value.
@@ -56,16 +56,16 @@ namespace umbraco.BusinessLogic
/// <param name="context">The context.</param>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public static void SetSessionValue(HttpContext context, string key, object value)
{
if (context == null)
return;
context.Session[key] = value;
}
public static void SetSessionValue(HttpContext context, string key, object value)
{
if (context == null)
return;
context.Session[key] = value;
}
#endregion
#endregion
#region Context Helpers
#region Context Helpers
/// <summary>
/// Gets the context value.
@@ -73,10 +73,10 @@ namespace umbraco.BusinessLogic
/// <typeparam name="T"></typeparam>
/// <param name="key">The key.</param>
/// <returns></returns>
public static T GetContextValue<T>(string key)
{
return GetContextValue<T>(HttpContext.Current, key);
}
public static T GetContextValue<T>(string key)
{
return GetContextValue<T>(HttpContext.Current, key);
}
/// <summary>
/// Gets the context value.
@@ -85,25 +85,25 @@ namespace umbraco.BusinessLogic
/// <param name="context">The context.</param>
/// <param name="key">The key.</param>
/// <returns></returns>
public static T GetContextValue<T>(HttpContext context, string key)
{
if (context == null)
return default(T);
object o = context.Items[key];
if (o == null)
return default(T);
return (T)o;
}
public static T GetContextValue<T>(HttpContext context, string key)
{
if (context == null)
return default(T);
object o = context.Items[key];
if (o == null)
return default(T);
return (T)o;
}
/// <summary>
/// Sets the context value.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public static void SetContextValue(string key, object value)
{
SetContextValue(HttpContext.Current, key, value);
}
public static void SetContextValue(string key, object value)
{
SetContextValue(HttpContext.Current, key, value);
}
/// <summary>
/// Sets the context value.
@@ -111,37 +111,37 @@ namespace umbraco.BusinessLogic
/// <param name="context">The context.</param>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public static void SetContextValue(HttpContext context, string key, object value)
{
if (context == null)
return;
context.Items[key] = value;
}
public static void SetContextValue(HttpContext context, string key, object value)
{
if (context == null)
return;
context.Items[key] = value;
}
#endregion
#endregion
#region ViewState Helpers
#region ViewState Helpers
/// <summary>
/// Gets the state bag.
/// </summary>
/// <returns></returns>
private static StateBag GetStateBag()
{
if (HttpContext.Current == null)
return null;
private static StateBag GetStateBag()
{
if (HttpContext.Current == null)
return null;
Page page = HttpContext.Current.CurrentHandler as Page;
if (page == null)
return null;
Page page = HttpContext.Current.CurrentHandler as Page;
if (page == null)
return null;
Type pageType = typeof(Page);
PropertyInfo viewState = pageType.GetProperty("ViewState", BindingFlags.GetProperty | BindingFlags.Instance);
if (viewState == null)
return null;
Type pageType = typeof(Page);
PropertyInfo viewState = pageType.GetProperty("ViewState", BindingFlags.GetProperty | BindingFlags.Instance);
if (viewState == null)
return null;
return viewState.GetValue(page, null) as StateBag;
}
return viewState.GetValue(page, null) as StateBag;
}
/// <summary>
/// Gets the view state value.
@@ -149,10 +149,10 @@ namespace umbraco.BusinessLogic
/// <typeparam name="T"></typeparam>
/// <param name="key">The key.</param>
/// <returns></returns>
public static T GetViewStateValue<T>(string key)
{
return GetViewStateValue<T>(GetStateBag(), key);
}
public static T GetViewStateValue<T>(string key)
{
return GetViewStateValue<T>(GetStateBag(), key);
}
/// <summary>
/// Gets a view-state value.
@@ -161,25 +161,25 @@ namespace umbraco.BusinessLogic
/// <param name="bag">The bag.</param>
/// <param name="key">The key.</param>
/// <returns></returns>
public static T GetViewStateValue<T>(StateBag bag, string key)
{
if (bag == null)
return default(T);
object o = bag[key];
if (o == null)
return default(T);
return (T)o;
}
public static T GetViewStateValue<T>(StateBag bag, string key)
{
if (bag == null)
return default(T);
object o = bag[key];
if (o == null)
return default(T);
return (T)o;
}
/// <summary>
/// Sets the view state value.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public static void SetViewStateValue(string key, object value)
{
SetViewStateValue(GetStateBag(), key, value);
}
public static void SetViewStateValue(string key, object value)
{
SetViewStateValue(GetStateBag(), key, value);
}
/// <summary>
/// Sets the view state value.
@@ -187,15 +187,15 @@ namespace umbraco.BusinessLogic
/// <param name="bag">The bag.</param>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public static void SetViewStateValue(StateBag bag, string key, object value)
{
if (bag != null)
bag[key] = value;
}
public static void SetViewStateValue(StateBag bag, string key, object value)
{
if (bag != null)
bag[key] = value;
}
#endregion
#endregion
#region Cookie Helpers
#region Cookie Helpers
/// <summary>
/// Determines whether a cookie has a value with a specified key.
@@ -217,13 +217,13 @@ namespace umbraco.BusinessLogic
/// </summary>
/// <param name="key">The key.</param>
/// <returns></returns>
public static string GetCookieValue(string key)
{
if (!Cookies.HasCookies)
return null;
var cookie = HttpContext.Current.Request.Cookies[key];
return cookie == null ? null : cookie.Value;
}
public static string GetCookieValue(string key)
{
if (!Cookies.HasCookies)
return null;
var cookie = HttpContext.Current.Request.Cookies[key];
return cookie == null ? null : cookie.Value;
}
/// <summary>
/// Sets the cookie value.
@@ -232,7 +232,7 @@ namespace umbraco.BusinessLogic
/// <param name="value">The value.</param>
public static void SetCookieValue(string key, string value)
{
SetCookieValue(key, value, 30d); // default Umbraco expires is 30 days
SetCookieValue(key, value, 30d); // default Umbraco expires is 30 days
}
/// <summary>
@@ -243,192 +243,192 @@ namespace umbraco.BusinessLogic
/// <param name="daysToPersist">How long the cookie should be present in the browser</param>
public static void SetCookieValue(string key, string value, double daysToPersist)
{
if (!Cookies.HasCookies)
return;
var context = HttpContext.Current;
if (!Cookies.HasCookies)
return;
var context = HttpContext.Current;
HttpCookie cookie = new HttpCookie(key, value);
cookie.Expires = DateTime.Now.AddDays(daysToPersist);
context.Response.Cookies.Set(cookie);
HttpCookie cookie = new HttpCookie(key, value);
cookie.Expires = DateTime.Now.AddDays(daysToPersist);
context.Response.Cookies.Set(cookie);
cookie = context.Request.Cookies[key];
if (cookie != null)
cookie.Value = value;
}
cookie = context.Request.Cookies[key];
if (cookie != null)
cookie.Value = value;
}
// zb-00004 #29956 : refactor cookies names & handling
public static class Cookies
{
/*
* helper class to manage cookies
*
* beware! SetValue(string value) does _not_ set expires, unless the cookie has been
* configured to have one. This allows us to have cookies w/out an expires timespan.
* However, default behavior in Umbraco was to set expires to 30days by default. This
* must now be managed in the Cookie constructor or by using an overriden SetValue(...).
*
* we currently reproduce this by configuring each cookie with a 30d expires, but does
* that actually make sense? shouldn't some cookie have _no_ expires?
*/
static readonly Cookie _preview = new Cookie("UMB_PREVIEW", 30d); // was "PreviewSet"
static readonly Cookie _userContext = new Cookie("UMB_UCONTEXT", 30d); // was "UserContext"
static readonly Cookie _member = new Cookie("UMB_MEMBER", 30d); // was "umbracoMember"
// zb-00004 #29956 : refactor cookies names & handling
public static class Cookies
{
/*
* helper class to manage cookies
*
* beware! SetValue(string value) does _not_ set expires, unless the cookie has been
* configured to have one. This allows us to have cookies w/out an expires timespan.
* However, default behavior in Umbraco was to set expires to 30days by default. This
* must now be managed in the Cookie constructor or by using an overriden SetValue(...).
*
* we currently reproduce this by configuring each cookie with a 30d expires, but does
* that actually make sense? shouldn't some cookie have _no_ expires?
*/
static readonly Cookie _preview = new Cookie("UMB_PREVIEW", 30d); // was "PreviewSet"
static readonly Cookie _userContext = new Cookie("UMB_UCONTEXT", 30d); // was "UserContext"
static readonly Cookie _member = new Cookie("UMB_MEMBER", 30d); // was "umbracoMember"
public static Cookie Preview { get { return _preview; } }
public static Cookie UserContext { get { return _userContext; } }
public static Cookie Member { get { return _member; } }
public static Cookie Preview { get { return _preview; } }
public static Cookie UserContext { get { return _userContext; } }
public static Cookie Member { get { return _member; } }
public static bool HasCookies
{
get
{
System.Web.HttpContext context = HttpContext.Current;
// although just checking context should be enough?!
// but in some (replaced) umbraco code, everything is checked...
return context != null
&& context.Request != null & context.Request.Cookies != null
&& context.Response != null && context.Response.Cookies != null;
}
}
public static bool HasCookies
{
get
{
System.Web.HttpContext context = HttpContext.Current;
// although just checking context should be enough?!
// but in some (replaced) umbraco code, everything is checked...
return context != null
&& context.Request != null & context.Request.Cookies != null
&& context.Response != null && context.Response.Cookies != null;
}
}
public static void ClearAll()
{
HttpContext.Current.Response.Cookies.Clear();
}
public static void ClearAll()
{
HttpContext.Current.Response.Cookies.Clear();
}
public class Cookie
{
const string cookiesExtensionConfigKey = "umbracoCookiesExtension";
public class Cookie
{
const string cookiesExtensionConfigKey = "umbracoCookiesExtension";
static readonly string _ext;
TimeSpan _expires;
string _key;
static readonly string _ext;
TimeSpan _expires;
string _key;
static Cookie()
{
var appSettings = System.Configuration.ConfigurationManager.AppSettings;
_ext = appSettings[cookiesExtensionConfigKey] == null ? "" : "_" + (string)appSettings[cookiesExtensionConfigKey];
}
static Cookie()
{
var appSettings = System.Configuration.ConfigurationManager.AppSettings;
_ext = appSettings[cookiesExtensionConfigKey] == null ? "" : "_" + (string)appSettings[cookiesExtensionConfigKey];
}
public Cookie(string key)
: this(key, TimeSpan.Zero, true)
{ }
public Cookie(string key)
: this(key, TimeSpan.Zero, true)
{ }
public Cookie(string key, double days)
: this(key, TimeSpan.FromDays(days), true)
{ }
public Cookie(string key, double days)
: this(key, TimeSpan.FromDays(days), true)
{ }
public Cookie(string key, TimeSpan expires)
: this(key, expires, true)
{ }
public Cookie(string key, TimeSpan expires)
: this(key, expires, true)
{ }
public Cookie(string key, bool appendExtension)
: this(key, TimeSpan.Zero, appendExtension)
{ }
public Cookie(string key, bool appendExtension)
: this(key, TimeSpan.Zero, appendExtension)
{ }
public Cookie(string key, double days, bool appendExtension)
: this(key, TimeSpan.FromDays(days), appendExtension)
{ }
public Cookie(string key, double days, bool appendExtension)
: this(key, TimeSpan.FromDays(days), appendExtension)
{ }
public Cookie(string key, TimeSpan expires, bool appendExtension)
{
_key = appendExtension ? key + _ext : key;
_expires = expires;
}
public Cookie(string key, TimeSpan expires, bool appendExtension)
{
_key = appendExtension ? key + _ext : key;
_expires = expires;
}
public string Key
{
get { return _key; }
}
public string Key
{
get { return _key; }
}
public bool HasValue
{
get { return RequestCookie != null; }
}
public bool HasValue
{
get { return RequestCookie != null; }
}
public string GetValue()
{
return RequestCookie == null ? null : RequestCookie.Value;
}
public string GetValue()
{
return RequestCookie == null ? null : RequestCookie.Value;
}
public void SetValue(string value)
{
HttpCookie cookie = new HttpCookie(_key, value);
if (!TimeSpan.Zero.Equals(_expires))
cookie.Expires = DateTime.Now + _expires;
ResponseCookie = cookie;
public void SetValue(string value)
{
SetValueWithDate(value, DateTime.Now + _expires);
}
// original Umbraco code also does this
// so we can GetValue() back what we previously set
cookie = RequestCookie;
if (cookie != null)
cookie.Value = value;
}
public void SetValue(string value, double days)
{
SetValue(value, DateTime.Now.AddDays(days));
}
public void SetValue(string value, double days)
{
SetValue(value, DateTime.Now.AddDays(days));
}
public void SetValue(string value, TimeSpan expires)
{
SetValue(value, DateTime.Now + expires);
}
public void SetValue(string value, TimeSpan expires)
{
SetValue(value, DateTime.Now + expires);
}
public void SetValue(string value, DateTime expires)
{
SetValueWithDate(value, expires);
}
public void SetValue(string value, DateTime expires)
{
HttpCookie cookie = new HttpCookie(_key, value);
cookie.Expires = expires;
ResponseCookie = cookie;
private void SetValueWithDate(string value, DateTime expires)
{
HttpCookie cookie = new HttpCookie(_key, value);
// original Umbraco code also does this
// so we can GetValue() back what we previously set
cookie = RequestCookie;
if (cookie != null)
cookie.Value = value;
}
if (GlobalSettings.UseSSL)
cookie.Secure = true;
public void Clear()
{
if (RequestCookie != null || ResponseCookie != null)
{
HttpCookie cookie = new HttpCookie(_key);
cookie.Expires = DateTime.Now.AddDays(-1);
ResponseCookie = cookie;
}
}
cookie.Expires = expires;
ResponseCookie = cookie;
public void Remove()
{
// beware! will not clear browser's cookie
// you probably want to use .Clear()
HttpContext.Current.Response.Cookies.Remove(_key);
}
// original Umbraco code also does this
// so we can GetValue() back what we previously set
cookie = RequestCookie;
if (cookie != null)
cookie.Value = value;
}
public HttpCookie RequestCookie
{
get
{
return HttpContext.Current.Request.Cookies[_key];
}
}
public void Clear()
{
if (RequestCookie != null || ResponseCookie != null)
{
HttpCookie cookie = new HttpCookie(_key);
cookie.Expires = DateTime.Now.AddDays(-1);
ResponseCookie = cookie;
}
}
public HttpCookie ResponseCookie
{
get
{
return HttpContext.Current.Response.Cookies[_key];
}
set
{
// .Set() ensures the uniqueness of cookies in the cookie collection
// ie it is the same as .Remove() + .Add() -- .Add() allows duplicates
HttpContext.Current.Response.Cookies.Set(value);
}
}
}
}
public void Remove()
{
// beware! will not clear browser's cookie
// you probably want to use .Clear()
HttpContext.Current.Response.Cookies.Remove(_key);
}
public HttpCookie RequestCookie
{
get
{
return HttpContext.Current.Request.Cookies[_key];
}
}
public HttpCookie ResponseCookie
{
get
{
return HttpContext.Current.Response.Cookies[_key];
}
set
{
// .Set() ensures the uniqueness of cookies in the cookie collection
// ie it is the same as .Remove() + .Add() -- .Add() allows duplicates
HttpContext.Current.Response.Cookies.Set(value);
}
}
}
}
#endregion
}
}
}

View File

@@ -311,28 +311,6 @@ namespace umbraco
}
}
/// <summary>
/// Gets a value indicating whether umbraco shouldn't add X-Umbraco-Version to the http header.
/// </summary>
/// <value><c>true</c> if umbraco will not add header; otherwise, <c>false</c>.</value>
public static bool RemoveUmbracoVersionHeader
{
get
{
try
{
bool result;
if (bool.TryParse(GetKey("/settings/requestHandler/removeUmbracoVersionHeader"), out result))
return result;
return false;
}
catch
{
return false;
}
}
}
/// <summary>
/// This will add a trailing slash (/) to urls when in directory url mode
/// NOTICE: This will always return false if Directory Urls in not active

View File

@@ -512,6 +512,9 @@ namespace umbraco.cms.businesslogic
Guid newVersion = Guid.NewGuid();
bool tempHasVersion = hasVersion();
// we need to ensure that a version in the db exist before we add related data
SqlHelper.ExecuteNonQuery("Insert into cmsContentVersion (ContentId,versionId) values (" + this.Id + ",'" + newVersion + "')");
foreach (propertytype.PropertyType pt in this.ContentType.PropertyTypes)
{
object oldValue = "";
@@ -526,7 +529,6 @@ namespace umbraco.cms.businesslogic
property.Property p = this.addProperty(pt, newVersion);
if (oldValue != null && oldValue.ToString() != "") p.Value = oldValue;
}
SqlHelper.ExecuteNonQuery("Insert into cmsContentVersion (ContentId,versionId) values (" + this.Id + ",'" + newVersion + "')");
this.Version = newVersion;
return newVersion;
}

View File

@@ -174,7 +174,7 @@ namespace umbraco.cms.businesslogic.Files
string fileNameThumb = DoResize(width, height, 0, String.Empty);
return fileNameThumb.Substring(IO.IOHelper.MapPath(IO.SystemDirectories.Root).Length);
return fileNameThumb.Substring(IO.IOHelper.MapPath(IO.SystemDirectories.Root).Length-1);
}
public string Resize(int maxWidthHeight, string fileNameAddition)
@@ -197,7 +197,7 @@ namespace umbraco.cms.businesslogic.Files
string fileNameThumb = String.IsNullOrEmpty(fileNameAddition) ?
string.Format("{0}_UMBRACOSYSTHUMBNAIL.jpg", _fullFilePath.Substring(0, _fullFilePath.LastIndexOf("."))) :
string.Format("{0}_{1}.jpg", _fullFilePath.Substring(0, _fullFilePath.LastIndexOf(".")), fileNameAddition);
generateThumbnail(
fileNameThumb = generateThumbnail(
image,
maxWidthHeight,
width,
@@ -206,7 +206,7 @@ namespace umbraco.cms.businesslogic.Files
_extension,
fileNameThumb,
maxWidthHeight == 0
);
).FileName;
image.Dispose();
return fileNameThumb;
}
@@ -220,7 +220,7 @@ namespace umbraco.cms.businesslogic.Files
}
private System.Tuple<int, int> generateThumbnail(System.Drawing.Image image, int maxWidthHeight, int fileWidth, int fileHeight, string fullFilePath, string ext, string thumbnailFileName, bool useFixedDimensions)
private ResizedImage generateThumbnail(System.Drawing.Image image, int maxWidthHeight, int fileWidth, int fileHeight, string fullFilePath, string ext, string thumbnailFileName, bool useFixedDimensions)
{
// Generate thumbnail
float f = 1;
@@ -267,14 +267,35 @@ namespace umbraco.cms.businesslogic.Files
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 90L);
// Save the new image using the dimensions of the image
bp.Save(thumbnailFileName.Replace("UMBRACOSYSTHUMBNAIL", string.Format("{0}x{1}", widthTh, heightTh)), codec, ep);
string newFileName = thumbnailFileName.Replace("UMBRACOSYSTHUMBNAIL",
string.Format("{0}x{1}", widthTh, heightTh));
bp.Save(newFileName, codec, ep);
bp.Dispose();
g.Dispose();
return new System.Tuple<int, int>(widthTh, heightTh);
return new ResizedImage(widthTh, heightTh, newFileName);
}
}
internal class ResizedImage
{
public ResizedImage()
{
}
public ResizedImage(int width, int height, string fileName)
{
Width = width;
Height = height;
FileName = fileName;
}
public int Width { get; set; }
public int Height { get; set; }
public string FileName { get; set; }
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using System.Xml;
using umbraco.cms.businesslogic.Files;
@@ -32,13 +33,13 @@ namespace umbraco.cms.businesslogic.datatype
if (value is HttpPostedFile)
{
var file = value as HttpPostedFile;
name = file.FileName;
name = SafeFileName(file.FileName.Substring(file.FileName.LastIndexOf(IOHelper.DirSepChar) + 1, file.FileName.Length - file.FileName.LastIndexOf(IOHelper.DirSepChar) - 1).ToLower());
fileStream = file.InputStream;
}
else if (value is HttpPostedFileBase)
{
var file = value as HttpPostedFileBase;
name = file.FileName;
name = SafeFileName(file.FileName.Substring(file.FileName.LastIndexOf(IOHelper.DirSepChar) + 1, file.FileName.Length - file.FileName.LastIndexOf(IOHelper.DirSepChar) - 1).ToLower());
fileStream = file.InputStream;
}
else if (value is HttpPostedFileWrapper)
@@ -129,6 +130,18 @@ namespace umbraco.cms.businesslogic.datatype
}
}
/// <summary>
/// Check to see if filename passed has any special chars in it and strips them to create a safe filename. Used to overcome an issue when Umbraco is used in IE in an intranet environment.
/// </summary>
/// <param name="filePath">The filename passed to the file handler from the upload field.</param>
/// <returns>A safe filename without any path specific chars.</returns>
private string SafeFileName(string filePath)
{
if (!String.IsNullOrEmpty(filePath))
return Regex.Replace(filePath, @"[^a-zA-Z0-9\-\.\/\:]{1}", "_");
return String.Empty;
}
private void clearRelatedValues()
{
string propertyTypeAlias = new Property(PropertyId).PropertyType.Alias;

View File

@@ -646,7 +646,7 @@ namespace umbraco.cms.businesslogic.web
{
ArrayList docs = new ArrayList();
IRecordsReader dr =
SqlHelper.ExecuteReader("select distinct nodeId from cmsDocument where newest = 1 and not expireDate is null and expireDate <= @today",
SqlHelper.ExecuteReader("select distinct nodeId from cmsDocument where published = 1 and not expireDate is null and expireDate <= @today",
SqlHelper.CreateParameter("@today", DateTime.Now));
while (dr.Read())
docs.Add(dr.GetInt("nodeId"));

View File

@@ -21,14 +21,15 @@ namespace umbraco.DataLayer.SqlHelpers.MySql
#region Private Constants
/// <summary>The latest database version this installer supports.</summary>
private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_1;
private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8;
/// <summary>The specifications to determine the database version.</summary>
private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] {
new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1),
new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4),
new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3),
new VersionSpecs("version()","",DatabaseVersion.None) };
new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 0, DatabaseVersion.Version4_8),
new VersionSpecs("SELECT id FROM umbracoNode WHERE id = -21", 1, DatabaseVersion.Version4_1),
new VersionSpecs("SELECT action FROM umbracoAppTree", DatabaseVersion.Version4),
new VersionSpecs("SELECT description FROM cmsContentType", DatabaseVersion.Version3),
new VersionSpecs("SELECT version()", DatabaseVersion.None) };
#endregion
@@ -45,7 +46,7 @@ namespace umbraco.DataLayer.SqlHelpers.MySql
{
get
{
return CurrentVersion == DatabaseVersion.Version4;
return CurrentVersion == DatabaseVersion.Version4_1;
}
}

View File

@@ -20,14 +20,15 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer
#region Private Constants
/// <summary>The latest database version this installer supports.</summary>
private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_1;
private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8;
/// <summary>The specifications to determine the database version.</summary>
private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] {
new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1),
new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4),
new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3),
new VersionSpecs("id","sysobjects",DatabaseVersion.None) };
new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 0, DatabaseVersion.Version4_8),
new VersionSpecs("SELECT id FROM umbracoNode WHERE id = -21", 1, DatabaseVersion.Version4_1),
new VersionSpecs("SELECT action FROM umbracoAppTree", DatabaseVersion.Version4),
new VersionSpecs("SELECT description FROM cmsContentType", DatabaseVersion.Version3),
new VersionSpecs("SELECT id FROM sysobjects", DatabaseVersion.None) };
#endregion
@@ -44,7 +45,7 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer
{
get
{
return CurrentVersion == DatabaseVersion.Version4;
return CurrentVersion == DatabaseVersion.Version4_1;
}
}

View File

@@ -195,16 +195,37 @@ namespace umbraco.DataLayer.Utility.Installer
{
try
{
if (!String.IsNullOrEmpty(v.Table) && !String.IsNullOrEmpty(v.Field) && !String.IsNullOrEmpty(v.Value))
{
IRecordsReader reader = SqlHelper.ExecuteReader(string.Format("SELECT {0} FROM {1} WHERE {0}={2}", v.Field, v.Table, v.Value));
if (!reader.Read())
continue;
}
else if (String.IsNullOrEmpty(v.Table))
SqlHelper.ExecuteNonQuery(string.Format("SELECT {0}", v.Field));
else
SqlHelper.ExecuteNonQuery(string.Format("SELECT {0} FROM {1}", v.Field, v.Table));
if(v.ExpectedRows > -1)
{
var reader = SqlHelper.ExecuteReader(v.Sql);
var rowCount = 0;
if(reader.HasRecords)
{
while (reader.Read())
rowCount++;
}
if (v.ExpectedRows != rowCount)
continue;
}
else
{
SqlHelper.ExecuteNonQuery(v.Sql);
}
//if (!String.IsNullOrEmpty(v.Table) && !String.IsNullOrEmpty(v.Field) && !String.IsNullOrEmpty(v.Value))
//{
// IRecordsReader reader = SqlHelper.ExecuteReader(string.Format("SELECT {0} FROM {1} WHERE {0}={2}", v.Field, v.Table, v.Value));
// var canRead = reader.Read();
// if ((v.ShouldExist && !canRead) || (!v.ShouldExist && canRead))
// continue;
//}
//else if (String.IsNullOrEmpty(v.Table))
// SqlHelper.ExecuteNonQuery(string.Format("SELECT {0}", v.Field));
//else
// SqlHelper.ExecuteNonQuery(string.Format("SELECT {0} FROM {1}", v.Field, v.Table));
return v.Version;
}
catch { }
@@ -249,14 +270,11 @@ namespace umbraco.DataLayer.Utility.Installer
/// </remarks>
public struct VersionSpecs
{
/// <summary>The name of the field that should exist in order to have at least the specified version.</summary>
public readonly string Field;
/// <summary>The name of the table whose field should exist in order to have at least the specified version.</summary>
public readonly string Table;
/// <summary>
/// The value to look for in the field, if this is left empty it will not be queried.
/// </summary>
public readonly string Value;
/// <summary>The SQL statament to execute in order to test for the specified version</summary>
public readonly string Sql;
/// <summary>An integer identifying the expected row count from the Sql statement</summary>
public readonly int ExpectedRows;
/// <summary>The minimum version number of a database that contains the specified field.</summary>
public readonly DatabaseVersion Version;
@@ -264,29 +282,23 @@ namespace umbraco.DataLayer.Utility.Installer
/// <summary>
/// Initializes a new instance of the <see cref="VersionSpecs"/> struct.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="table">The table.</param>
/// <param name="sql">The sql statement to execute.</param>
/// <param name="version">The version.</param>
public VersionSpecs(string field, string table, DatabaseVersion version)
{
Field = field;
Table = table;
Version = version;
Value = "";
}
public VersionSpecs(string sql, DatabaseVersion version)
: this(sql, -1, version)
{ }
/// <summary>
/// Initializes a new instance of the <see cref="VersionSpecs"/> struct.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="table">The table.</param>
/// </summary>
/// <param name="sql">The sql statement to execute.</param>
/// <param name="expectedRows">The expected row count.</param>
/// <param name="version">The version.</param>
public VersionSpecs(string field, string table, string value, DatabaseVersion version)
public VersionSpecs(string sql, int expectedRows, DatabaseVersion version)
{
Field = field;
Table = table;
Value = value;
Version = version;
Sql = sql;
ExpectedRows = expectedRows;
Version = version;
}
}
}

View File

@@ -326,10 +326,9 @@ namespace umbraco.editorControls.tinyMCE3.webcontrol
tempTag += " " + ide.Key.ToString() + "=\"" + ide.Value.ToString() + "\"";
// Find the original filename, by removing the might added width and height
// NH, 4.8.1 - above replaced by loading the right media file from the db later!
orgSrc =
IOHelper.ResolveUrl(orgSrc.Replace(
"_" + helper.FindAttribute(ht, "width") + "x" + helper.FindAttribute(ht, "height"), "").
Replace("%20", " "));
IOHelper.ResolveUrl(orgSrc.Replace("%20", " "));
// Check for either id or guid from media
string mediaId = getIdFromSource(orgSrc, localMediaPath);
@@ -358,15 +357,10 @@ namespace umbraco.editorControls.tinyMCE3.webcontrol
{
try
{
// Check extention
if (imageMedia.getProperty("umbracoExtension").Value.ToString() != orgSrc.Substring(orgSrc.LastIndexOf(".") + 1, orgSrc.Length - orgSrc.LastIndexOf(".") - 1))
orgSrc = orgSrc.Substring(0, orgSrc.LastIndexOf(".") + 1) +
imageMedia.getProperty("umbracoExtension").Value.ToString();
// Format the tag
tempTag = tempTag + " rel=\"" +
imageMedia.getProperty("umbracoWidth").Value.ToString() + "," +
imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + orgSrc +
imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + IOHelper.ResolveUrl(imageMedia.getProperty("umbracoFile").Value.ToString()) +
"\"";
tempTag += "/>";

View File

@@ -161,6 +161,7 @@ namespace umbraco.editorControls
#endregion
[Obsolete("This method is now obsolete due to a change in the way that files are handled. If you need to check if a URL for an uploaded file is safe you should implement your own as this method will be removed in a future version", false)]
public string SafeUrl(string url)
{
if (!String.IsNullOrEmpty(url))

View File

@@ -124,8 +124,6 @@
<char org="Ä">ae</char>
<char org="Ö">oe</char>
</urlReplacing>
<removeUmbracoVersionHeader>false</removeUmbracoVersionHeader>
</requestHandler>
<templates>

View File

@@ -206,10 +206,6 @@ namespace umbraco
if (!UmbracoSettings.UseAspNetMasterPages)
initUmbracoPage();
base.OnInit(e);
// Add Umbraco header
if (!UmbracoSettings.RemoveUmbracoVersionHeader)
Response.AddHeader("X-Umbraco-Version", string.Format("{0}.{1}", GlobalSettings.VersionMajor, GlobalSettings.VersionMinor));
}
private void initUmbracoPage()

View File

@@ -3313,9 +3313,6 @@
<None Include="web.Template.SONIC.Debug.config">
<DependentUpon>Web.Template.config</DependentUpon>
</None>
<None Include="web.Template.PETER-PC.Debug.config">
<DependentUpon>Web.Template.config</DependentUpon>
</None>
<None Include="web.Template.PETER-MAC.Debug.config">
<DependentUpon>Web.Template.config</DependentUpon>
</None>
@@ -3346,6 +3343,9 @@
<None Include="web.Template.MBP13-PC.Debug.config">
<DependentUpon>Web.Template.config</DependentUpon>
</None>
<None Include="web.Template.PeterGregory-PC.Debug.config">
<DependentUpon>Web.Template.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<WebReferences Include="Web References\" />

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using umbraco.BasePages;
@@ -61,61 +61,9 @@ function openMedia(id) {
foreach (Media dd in docs)
{
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.NodeID = dd.Id.ToString();
xNode.Text = dd.Text;
// Check for dialog behaviour
if (!this.IsDialog)
{
if (!this.ShowContextMenu)
xNode.Menu = null;
xNode.Action = "javascript:openMedia(" + dd.Id + ");";
}
else
{
if (this.ShowContextMenu)
xNode.Menu = new List<IAction>(new IAction[] { ActionRefresh.Instance });
else
xNode.Menu = null;
if (this.DialogMode == TreeDialogModes.fulllink)
{
string nodeLink = GetLinkValue(dd, dd.Id.ToString());
if (!String.IsNullOrEmpty(nodeLink))
{
xNode.Action = "javascript:openMedia('" + nodeLink + "');";
}
else
{
if (dd.ContentType.Alias.ToLower() == "folder")
{
xNode.Action = "javascript:jQuery('.umbTree #" + dd.Id.ToString() + "').click();";
}
else
{
xNode.Action = null;
xNode.Style.DimNode();
}
}
}
else
{
xNode.Action = "javascript:openMedia('" + dd.Id.ToString() + "');";
}
}
xNode.HasChildren = dd.HasChildren;
if (this.IsDialog)
xNode.Source = GetTreeDialogUrl(dd.Id);
else
xNode.Source = GetTreeServiceUrl(dd.Id);
if (dd.ContentType != null)
{
xNode.Icon = dd.ContentType.IconUrl;
xNode.OpenIcon = dd.ContentType.IconUrl;
}
XmlTreeNode xNode = CreateNode(dd);
OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
if (xNode != null)
{
@@ -149,6 +97,60 @@ function openMedia(id) {
return "";
}
protected XmlTreeNode CreateNode(Media dd)
{
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.NodeID = dd.Id.ToString();
xNode.Text = dd.Text;
// Check for dialog behaviour
if (!this.IsDialog)
{
if (!this.ShowContextMenu)
xNode.Menu = null;
xNode.Action = "javascript:openMedia(" + dd.Id + ");";
}
else
{
if (this.ShowContextMenu)
xNode.Menu = new List<IAction>(new IAction[] { ActionRefresh.Instance });
else
xNode.Menu = null;
if (this.DialogMode == TreeDialogModes.fulllink)
{
string nodeLink = GetLinkValue(dd, dd.Id.ToString());
if (!String.IsNullOrEmpty(nodeLink))
{
xNode.Action = "javascript:openMedia('" + nodeLink + "');";
}
else
{
xNode.Action = null;
xNode.DimNode();
}
}
else
{
xNode.Action = "javascript:openMedia('" + dd.Id.ToString() + "');";
}
}
xNode.HasChildren = dd.HasChildren;
if (this.IsDialog)
xNode.Source = GetTreeDialogUrl(dd.Id);
else
xNode.Source = GetTreeServiceUrl(dd.Id);
if (dd.ContentType != null)
{
xNode.Icon = dd.ContentType.IconUrl;
xNode.OpenIcon = dd.ContentType.IconUrl;
}
return xNode;
}
/// <summary>
/// By default, any media type that is to be "linkable" in the WYSIWYG editor must contain
/// a DataTypeUploadField data type which will ouput the value for the link, however, if

View File

@@ -31,7 +31,7 @@ namespace umbraco
[Tree("media", "media", "Media")]
public class loadMedia : BaseMediaTree
{
private Media m_media;
private int _StartNodeID;
/// <summary>
/// Create the linkable data types list and add the DataTypeUploadField guid to it.
@@ -52,15 +52,64 @@ namespace umbraco
: base(application)
{
_StartNodeID = CurrentUser.StartMediaId;
}
}
/// <summary>
/// Returns the Media object of the starting node for the current User. This ensures
/// that the Media object is only instantiated once.
/// </summary>
protected Media StartNode
{
get
{
if (m_media == null)
{
m_media = new Media(StartNodeID);
}
if (!m_media.Path.Contains(CurrentUser.StartMediaId.ToString()))
{
var media = new Media(CurrentUser.StartMediaId);
if (!string.IsNullOrEmpty(media.Path) && media.Path.Contains(this.StartNodeID.ToString()))
{
m_media = media;
}
else
{
return null;
}
}
return m_media;
}
}
protected override void CreateRootNode(ref XmlTreeNode rootNode)
{
if (this.IsDialog)
rootNode.Action = "javascript:openMedia(-1);";
{
if (StartNodeID != -1)
{
Media doc = StartNode;
if (doc == null)
{
rootNode = new NullTree(this.app).RootNode;
rootNode.Text = "You do not have permission for this content tree";
rootNode.HasChildren = false;
rootNode.Source = string.Empty;
}
else
{
rootNode = CreateNode(doc);
}
}
else
rootNode.Action = "javascript:" + ClientTools.Scripts.OpenDashboard("Media");
{
if (this.IsDialog)
rootNode.Action = "javascript:openMedia(-1);";
else
rootNode.Action = "javascript:" + ClientTools.Scripts.OpenDashboard("Media");
}
}
protected override void CreateRootNodeActions(ref List<IAction> actions)

View File

@@ -26,42 +26,40 @@
* @param {string} url Absolute URL to where the plugin is located.
*/
init: function (ed) {
var t = this;
ed.plugins.contextmenu.onContextMenu.add(function (th, menu, event) {
var keys = UmbClientMgr.uiKeys();
$.each(menu.items, function (idx, el) {
if (ed.plugins.contextmenu) {
switch (el.settings.cmd) {
case "Cut":
el.settings.title = keys['defaultdialogs_cut'];
break;
case "Copy":
el.settings.title = keys['general_copy'];
break;
case "Paste":
el.settings.title = keys['defaultdialogs_paste'];
break;
case "mceAdvLink":
case "mceLink":
el.settings.title = keys['defaultdialogs_insertlink'];
break;
case "UnLink":
el.settings.title = keys['relatedlinks_removeLink'];
break;
case "mceImage":
el.settings.title = keys['defaultdialogs_insertimage'];
el.settings.cmd = "mceUmbimage";
break;
}
ed.plugins.contextmenu.onContextMenu.add(function (th, menu, event) {
var keys = UmbClientMgr.uiKeys();
$.each(menu.items, function (idx, el) {
switch (el.settings.cmd) {
case "Cut":
el.settings.title = keys['defaultdialogs_cut'];
break;
case "Copy":
el.settings.title = keys['general_copy'];
break;
case "Paste":
el.settings.title = keys['defaultdialogs_paste'];
break;
case "mceAdvLink":
case "mceLink":
el.settings.title = keys['defaultdialogs_insertlink'];
break;
case "UnLink":
el.settings.title = keys['relatedlinks_removeLink'];
break;
case "mceImage":
el.settings.title = keys['defaultdialogs_insertimage'];
el.settings.cmd = "mceUmbimage";
break;
}
});
});
});
}
}
});
// Register plugin

View File

@@ -17,10 +17,14 @@
<appSettings>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoDbDSN"
value="server=.\sqlexpress;database=4.6-beta;integrated security=false;user id=sa;pwd=password"/>
value="server=localhost;database=4.8.dev;user id=sa;password=password!"/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoConfigurationStatus"
value="4.1.0.alpha"/>
</appSettings>
value="4.8.1"/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoContentXML"
value="~/App_Data/umbraco.config"/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoStorageDirectory"
value="~/App_Data"/>
</appSettings>
<system.web>
<compilation debug="true" xdt:Transform="SetAttributes(debug)" />

View File

@@ -17,9 +17,9 @@
<appSettings>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoDbDSN"
value="server=.\sqlexpress;database=v47;user id=DBUSER;password=DBPASSWORD"/>
value="server=.\sqlexpress;database=481;user id=DBUSER;password=DBPASSWORD"/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoConfigurationStatus"
value="4.7.0.beta"/>
value="4.8.1"/>
</appSettings>
<system.web>

View File

@@ -26,12 +26,12 @@
<ExamineLuceneIndexSets configSource="config\ExamineIndex.config" />
<appSettings>
<add key="umbracoDbDSN" value="" />
<add key="umbracoConfigurationStatus" value="" />
<add key="umbracoDbDSN" value="server=localhost;database=4.8.dev;user id=sa;password=password!"/>
<add key="umbracoConfigurationStatus" value="4.8.1"/>
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
<add key="umbracoContentXML" value="~/App_Data/umbraco.config" />
<add key="umbracoStorageDirectory" value="~/App_Data" />
<add key="umbracoContentXML" value="~/App_Data/umbraco.config"/>
<add key="umbracoStorageDirectory" value="~/App_Data"/>
<add key="umbracoPath" value="~/umbraco" />
<add key="umbracoEnableStat" value="false" />
<add key="umbracoHideTopLevelNodeFromPath" value="true" />