Merge remote-tracking branch 'origin/6.2.0' into 7.0.2

Conflicts:
	src/Umbraco.Core/Umbraco.Core.csproj
	src/Umbraco.Tests/Umbraco.Tests.csproj
	src/umbraco.cms/businesslogic/CMSNode.cs
This commit is contained in:
Shannon
2014-01-10 17:05:23 +11:00
10 changed files with 466 additions and 65 deletions

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Umbraco.Core.Models
{
internal class Notification
{
public Notification(int entityId, int userId, string action, Guid entityType)
{
EntityId = entityId;
UserId = userId;
Action = action;
EntityType = entityType;
}
public int EntityId { get; private set; }
public int UserId { get; private set; }
public string Action { get; private set; }
public Guid EntityType { get; private set; }
}
}

View File

@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.UnitOfWork;
namespace Umbraco.Core.Persistence.Repositories
{
internal class NotificationsRepository
{
private readonly IDatabaseUnitOfWork _unitOfWork;
public NotificationsRepository(IDatabaseUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
}
public IEnumerable<Notification> GetUserNotifications(IUser user)
{
var sql = new Sql()
.Select("DISTINCT umbracoNode.id, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action")
.From<User2NodeNotifyDto>()
.InnerJoin<NodeDto>()
.On<User2NodeNotifyDto, NodeDto>(dto => dto.NodeId, dto => dto.NodeId)
.Where<User2NodeNotifyDto>(dto => dto.UserId == (int)user.Id)
.OrderBy<NodeDto>(dto => dto.NodeId);
var dtos = _unitOfWork.Database.Fetch<dynamic>(sql);
//need to map the results
return dtos.Select(d => new Notification(d.id, d.userId, d.action, d.nodeObjectType)).ToList();
}
public IEnumerable<Notification> GetEntityNotifications(IEntity entity)
{
var sql = new Sql()
.Select("DISTINCT umbracoNode.id, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action")
.From<User2NodeNotifyDto>()
.InnerJoin<NodeDto>()
.On<User2NodeNotifyDto, NodeDto>(dto => dto.NodeId, dto => dto.NodeId)
.Where<User2NodeNotifyDto>(dto => dto.NodeId == entity.Id)
.OrderBy<NodeDto>(dto => dto.NodeId);
var dtos = _unitOfWork.Database.Fetch<dynamic>(sql);
//need to map the results
return dtos.Select(d => new Notification(d.id, d.userId, d.action, d.nodeObjectType)).ToList();
}
public int DeleteNotifications(IEntity entity)
{
return _unitOfWork.Database.Delete<User2NodeNotifyDto>("WHERE nodeId = @nodeId", new { nodeId = entity.Id });
}
public int DeleteNotifications(IUser user)
{
return _unitOfWork.Database.Delete<User2NodeNotifyDto>("WHERE userId = @userId", new { userId = user.Id });
}
public int DeleteNotifications(IUser user, IEntity entity)
{
// delete all settings on the node for this user
return _unitOfWork.Database.Delete<User2NodeNotifyDto>("WHERE userId = @userId AND nodeId = @nodeId", new { userId = user.Id, nodeId = entity.Id });
}
public Notification CreateNotification(IUser user, IEntity entity, string action)
{
var sql = new Sql()
.Select("DISTINCT nodeObjectType")
.From<NodeDto>()
.Where<NodeDto>(nodeDto => nodeDto.NodeId == entity.Id);
var nodeType = _unitOfWork.Database.ExecuteScalar<Guid>(sql);
var dto = new User2NodeNotifyDto()
{
Action = action,
NodeId = entity.Id,
UserId = (int)user.Id
};
_unitOfWork.Database.Insert(dto);
return new Notification(dto.NodeId, dto.UserId, dto.Action, nodeType);
}
}
}

View File

@@ -0,0 +1,66 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using umbraco.interfaces;
namespace Umbraco.Core.Services
{
internal interface INotificationService : IService
{
/// <summary>
/// Sends the notifications for the specified user regarding the specified node and action.
/// </summary>
/// <param name="entity"></param>
/// <param name="user"></param>
/// <param name="action"></param>
void SendNotifications(IEntity entity, IUser user, IAction action);
/// <summary>
/// Gets the notifications for the user
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
IEnumerable<Notification> GetUserNotifications(IUser user);
/// <summary>
/// Returns the notifications for an entity
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
IEnumerable<Notification> GetEntityNotifications(IEntity entity);
/// <summary>
/// Deletes notifications by entity
/// </summary>
/// <param name="entity"></param>
void DeleteNotifications(IEntity entity);
/// <summary>
/// Deletes notifications by user
/// </summary>
/// <param name="user"></param>
void DeleteNotifications(IUser user);
/// <summary>
/// Delete notifications by user and entity
/// </summary>
/// <param name="user"></param>
/// <param name="entity"></param>
void DeleteNotifications(IUser user, IEntity entity);
/// <summary>
/// Creates a new notification
/// </summary>
/// <param name="user"></param>
/// <param name="entity"></param>
/// <param name="action">The action letter - note: this is a string for future compatibility</param>
/// <returns></returns>
Notification CreateNotification(IUser user, IEntity entity, string action);
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
using umbraco.interfaces;
namespace Umbraco.Core.Services
{
internal class NotificationService : INotificationService
{
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
public NotificationService(IDatabaseUnitOfWorkProvider provider)
{
_uowProvider = provider;
}
/// <summary>
/// Sends the notifications for the specified user regarding the specified node and action.
/// </summary>
/// <param name="entity"></param>
/// <param name="user"></param>
/// <param name="action"></param>
public void SendNotifications(IEntity entity, IUser user, IAction action)
{
throw new NotImplementedException();
}
/// <summary>
/// Gets the notifications for the user
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public IEnumerable<Notification> GetUserNotifications(IUser user)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
return repository.GetUserNotifications(user);
}
/// <summary>
/// Deletes notifications by entity
/// </summary>
/// <param name="entity"></param>
public IEnumerable<Notification> GetEntityNotifications(IEntity entity)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
return repository.GetEntityNotifications(entity);
}
/// <summary>
/// Deletes notifications by entity
/// </summary>
/// <param name="entity"></param>
public void DeleteNotifications(IEntity entity)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
repository.DeleteNotifications(entity);
}
/// <summary>
/// Deletes notifications by user
/// </summary>
/// <param name="user"></param>
public void DeleteNotifications(IUser user)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
repository.DeleteNotifications(user);
}
/// <summary>
/// Delete notifications by user and entity
/// </summary>
/// <param name="user"></param>
/// <param name="entity"></param>
public void DeleteNotifications(IUser user, IEntity entity)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
repository.DeleteNotifications(user, entity);
}
/// <summary>
/// Creates a new notification
/// </summary>
/// <param name="user"></param>
/// <param name="entity"></param>
/// <param name="action">The action letter - note: this is a string for future compatibility</param>
/// <returns></returns>
public Notification CreateNotification(IUser user, IEntity entity, string action)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
return repository.CreateNotification(user, entity, action);
}
}
}

View File

@@ -330,6 +330,7 @@
<Compile Include="Models\IRelation.cs" />
<Compile Include="Models\IRelationType.cs" />
<Compile Include="Models\Membership\MembershipScenario.cs" />
<Compile Include="Models\Notification.cs" />
<Compile Include="Models\PublishedContent\IPublishedContentExtended.cs" />
<Compile Include="Models\PublishedContent\PublishedPropertyBase.cs" />
<Compile Include="Models\PublishedContent\PublishedContentModelFactoryImpl.cs" />
@@ -346,6 +347,7 @@
<Compile Include="Persistence\Querying\StringPropertyMatchType.cs" />
<Compile Include="Persistence\Querying\TextColumnType.cs" />
<Compile Include="Persistence\Querying\ValuePropertyMatchType.cs" />
<Compile Include="Persistence\Repositories\NotificationsRepository.cs" />
<Compile Include="Persistence\SqlSyntax\MySqlSyntax.cs" />
<Compile Include="Persistence\SqlSyntax\SqlCeSyntax.cs" />
<Compile Include="Persistence\SqlSyntax\SqlServerSyntax.cs" />
@@ -985,6 +987,7 @@
<Compile Include="Services\IMembershipUserService.cs" />
<Compile Include="Services\IMemberTypeService.cs" />
<Compile Include="Services\IPackagingService.cs" />
<Compile Include="Services\INotificationService.cs" />
<Compile Include="Services\IRelationService.cs" />
<Compile Include="Services\ISectionService.cs" />
<Compile Include="Services\IService.cs" />
@@ -996,6 +999,7 @@
<Compile Include="Services\MemberCountType.cs" />
<Compile Include="Services\MemberService.cs" />
<Compile Include="Services\MemberTypeService.cs" />
<Compile Include="Services\NotificationService.cs" />
<Compile Include="Services\RelationService.cs" />
<Compile Include="Services\SectionService.cs" />
<Compile Include="Services\ServerRegistrationService.cs" />

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;

View File

@@ -0,0 +1,145 @@
using System;
using System.Globalization;
using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.Repositories
{
[TestFixture]
public class NotificationsRepositoryTest : BaseDatabaseFactoryTest
{
[Test]
public void CreateNotification()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
var repo = new NotificationsRepository(unitOfWork);
var node = new NodeDto {CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1,123", SortOrder = 1, Text = "hello", Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0};
var result = unitOfWork.Database.Insert(node);
var entity = Mock.Of<IEntity>(e => e.Id == node.NodeId);
var user = Mock.Of<IUser>(e => e.Id == (object)node.UserId);
var notification = repo.CreateNotification(user, entity, "A");
Assert.AreEqual("A", notification.Action);
Assert.AreEqual(node.NodeId, notification.EntityId);
Assert.AreEqual(node.NodeObjectType, notification.EntityType);
Assert.AreEqual(node.UserId, notification.UserId);
}
[Test]
public void GetUserNotifications()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
var repo = new NotificationsRepository(unitOfWork);
var userDto = new UserDto { ContentStartId = -1, DefaultPermissions = "", Email = "test" , Login = "test" , MediaStartId = -1, Password = "test" , Type = 1, UserName = "test" , UserLanguage = "en" };
unitOfWork.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == (object)userDto.Id);
var userAdmin = Mock.Of<IUser>(e => e.Id == (object)0);
for (var i = 0; i < 10; i++)
{
var node = new NodeDto { CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1," + i, SortOrder = 1, Text = "hello" + i, Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0 };
var result = unitOfWork.Database.Insert(node);
var entity = Mock.Of<IEntity>(e => e.Id == node.NodeId);
var notification = repo.CreateNotification((i % 2 == 0) ? userAdmin : userNew, entity, i.ToString(CultureInfo.InvariantCulture));
}
var notifications = repo.GetUserNotifications(userAdmin);
Assert.AreEqual(5, notifications.Count());
}
[Test]
public void GetEntityNotifications()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
var repo = new NotificationsRepository(unitOfWork);
var node1 = new NodeDto { CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1,1", SortOrder = 1, Text = "hello1", Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0 };
unitOfWork.Database.Insert(node1);
var entity1 = Mock.Of<IEntity>(e => e.Id == node1.NodeId);
var node2 = new NodeDto { CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1,2", SortOrder = 1, Text = "hello2", Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0 };
unitOfWork.Database.Insert(node2);
var entity2 = Mock.Of<IEntity>(e => e.Id == node2.NodeId);
for (var i = 0; i < 10; i++)
{
var userDto = new UserDto { ContentStartId = -1, DefaultPermissions = "", Email = "test" + i, Login = "test" + i, MediaStartId = -1, Password = "test", Type = 1, UserName = "test" + i, UserLanguage = "en" };
unitOfWork.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == (object)userDto.Id);
var notification = repo.CreateNotification(userNew, (i % 2 == 0) ? entity1 : entity2, i.ToString(CultureInfo.InvariantCulture));
}
var notifications = repo.GetEntityNotifications(entity1);
Assert.AreEqual(5, notifications.Count());
}
[Test]
public void Delete_By_Entity()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
var repo = new NotificationsRepository(unitOfWork);
var node1 = new NodeDto { CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1,1", SortOrder = 1, Text = "hello1", Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0 };
unitOfWork.Database.Insert(node1);
var entity1 = Mock.Of<IEntity>(e => e.Id == node1.NodeId);
var node2 = new NodeDto { CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1,2", SortOrder = 1, Text = "hello2", Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0 };
unitOfWork.Database.Insert(node2);
var entity2 = Mock.Of<IEntity>(e => e.Id == node2.NodeId);
for (var i = 0; i < 10; i++)
{
var userDto = new UserDto { ContentStartId = -1, DefaultPermissions = "", Email = "test" + i, Login = "test" + i, MediaStartId = -1, Password = "test", Type = 1, UserName = "test" + i, UserLanguage = "en" };
unitOfWork.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == (object)userDto.Id);
var notification = repo.CreateNotification(userNew, (i % 2 == 0) ? entity1 : entity2, i.ToString(CultureInfo.InvariantCulture));
}
var delCount = repo.DeleteNotifications(entity1);
Assert.AreEqual(5, delCount);
}
[Test]
public void Delete_By_User()
{
var provider = new PetaPocoUnitOfWorkProvider();
var unitOfWork = provider.GetUnitOfWork();
var repo = new NotificationsRepository(unitOfWork);
var userDto = new UserDto { ContentStartId = -1, DefaultPermissions = "", Email = "test", Login = "test", MediaStartId = -1, Password = "test", Type = 1, UserName = "test", UserLanguage = "en" };
unitOfWork.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == (object)userDto.Id);
var userAdmin = Mock.Of<IUser>(e => e.Id == (object)0);
for (var i = 0; i < 10; i++)
{
var node = new NodeDto { CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1," + i, SortOrder = 1, Text = "hello" + i, Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0 };
var result = unitOfWork.Database.Insert(node);
var entity = Mock.Of<IEntity>(e => e.Id == node.NodeId);
var notification = repo.CreateNotification((i % 2 == 0) ? userAdmin : userNew, entity, i.ToString(CultureInfo.InvariantCulture));
}
var delCount = repo.DeleteNotifications(userAdmin);
Assert.AreEqual(5, delCount);
}
}
}

View File

@@ -268,6 +268,7 @@
<Compile Include="Persistence\Repositories\MemberRepositoryTest.cs" />
<Compile Include="Persistence\Repositories\MemberTypeRepositoryTest.cs" />
<Compile Include="Persistence\Repositories\TagRepositoryTest.cs" />
<Compile Include="Persistence\Repositories\NotificationsRepositoryTest.cs" />
<Compile Include="Persistence\Repositories\TemplateRepositoryTest.cs" />
<Compile Include="Persistence\Repositories\UserRepositoryTest.cs" />
<Compile Include="Persistence\Repositories\UserTypeRepositoryTest.cs" />

View File

@@ -22,6 +22,7 @@ using umbraco.cms.businesslogic.Tags;
using File = System.IO.File;
using Media = umbraco.cms.businesslogic.media.Media;
using Tag = umbraco.cms.businesslogic.Tags.Tag;
using Notification = umbraco.cms.businesslogic.workflow.Notification;
using Task = umbraco.cms.businesslogic.task.Task;
namespace umbraco.cms.businesslogic

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Mail;
using System.Runtime.CompilerServices;
using System.Text;
@@ -48,20 +49,20 @@ namespace umbraco.cms.businesslogic.workflow
/// <summary>
/// Sends the notifications for the specified user regarding the specified node and action.
/// </summary>
/// <param name="Node">The node.</param>
/// <param name="node">The node.</param>
/// <param name="user">The user.</param>
/// <param name="Action">The action.</param>
public static void GetNotifications(CMSNode Node, User user, IAction Action)
/// <param name="action">The action.</param>
public static void GetNotifications(CMSNode node, User user, IAction action)
{
User[] allUsers = User.getAll();
foreach (User u in allUsers)
{
try
{
if (!u.Disabled && u.GetNotifications(Node.Path).IndexOf(Action.Letter.ToString()) > -1)
if (u.Disabled == false && u.GetNotifications(node.Path).IndexOf(action.Letter.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal) > -1)
{
LogHelper.Debug<Notification>(string.Format("Notification about {0} sent to {1} ({2})", ui.Text(Action.Alias, u), u.Name, u.Email));
sendNotification(user, u, (Document)Node, Action);
LogHelper.Debug<Notification>(string.Format("Notification about {0} sent to {1} ({2})", ui.Text(action.Alias, u), u.Name, u.Email));
SendNotification(user, u, (Document)node, action);
}
}
catch (Exception notifyExp)
@@ -72,8 +73,7 @@ namespace umbraco.cms.businesslogic.workflow
}
///TODO: Include update with html mail notification and document contents
private static void sendNotification(User performingUser, User mailingUser, Document documentObject,
IAction Action)
private static void SendNotification(User performingUser, User mailingUser, Document documentObject, IAction action)
{
// retrieve previous version of the document
DocumentVersionList[] versions = documentObject.GetVersions();
@@ -91,14 +91,14 @@ namespace umbraco.cms.businesslogic.workflow
string newText = p.Value != null ? p.Value.ToString() : "";
// replace html with char equivalent
ReplaceHTMLSymbols(ref oldText);
ReplaceHTMLSymbols(ref newText);
ReplaceHtmlSymbols(ref oldText);
ReplaceHtmlSymbols(ref newText);
// make sure to only highlight changes done using TinyMCE editor... other changes will be displayed using default summary
///TODO PPH: Had to change this, as a reference to the editorcontrols is not allowed, so a string comparison is the only way, this should be a DIFF or something instead..
//TODO PPH: Had to change this, as a reference to the editorcontrols is not allowed, so a string comparison is the only way, this should be a DIFF or something instead..
if (p.PropertyType.DataTypeDefinition.DataType.ToString() ==
"umbraco.editorControls.tinymce.TinyMCEDataType" &&
string.Compare(oldText, newText) != 0)
string.CompareOrdinal(oldText, newText) != 0)
{
summary.Append("<tr>");
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> Note: </th>");
@@ -109,7 +109,7 @@ namespace umbraco.cms.businesslogic.workflow
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> New " +
p.PropertyType.Name + "</th>");
summary.Append("<td style='text-align: left; vertical-align: top;'>" +
replaceLinks(CompareText(oldText, newText, true, false,
ReplaceLinks(CompareText(oldText, newText, true, false,
"<span style='background-color:yellow;'>", string.Empty)) +
"</td>");
summary.Append("</tr>");
@@ -117,7 +117,7 @@ namespace umbraco.cms.businesslogic.workflow
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> Old " +
oldProperty.PropertyType.Name + "</th>");
summary.Append("<td style='text-align: left; vertical-align: top;'>" +
replaceLinks(CompareText(newText, oldText, true, false,
ReplaceLinks(CompareText(newText, oldText, true, false,
"<span style='background-color:red;'>", string.Empty)) +
"</td>");
summary.Append("</tr>");
@@ -140,12 +140,12 @@ namespace umbraco.cms.businesslogic.workflow
string[] subjectVars = {
HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" +
HttpContext.Current.Request.Url.Port +
IOHelper.ResolveUrl(SystemDirectories.Umbraco), ui.Text(Action.Alias)
IOHelper.ResolveUrl(SystemDirectories.Umbraco), ui.Text(action.Alias)
,
documentObject.Text
};
string[] bodyVars = {
mailingUser.Name, ui.Text(Action.Alias), documentObject.Text, performingUser.Name,
mailingUser.Name, ui.Text(action.Alias), documentObject.Text, performingUser.Name,
HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" +
HttpContext.Current.Request.Url.Port +
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
@@ -156,8 +156,8 @@ namespace umbraco.cms.businesslogic.workflow
/*umbraco.library.NiceUrl(documentObject.Id))*/
documentObject.Id + ".aspx",
protocol)
///TODO: PPH removed the niceURL reference... cms.dll cannot reference the presentation project...
///TODO: This should be moved somewhere else..
//TODO: PPH removed the niceURL reference... cms.dll cannot reference the presentation project...
//TODO: This should be moved somewhere else..
};
// create the mail message
@@ -183,7 +183,7 @@ namespace umbraco.cms.businesslogic.workflow
// nh, issue 30724. Due to hardcoded http strings in resource files, we need to check for https replacements here
// adding the server name to make sure we don't replace external links
if (GlobalSettings.UseSSL && !String.IsNullOrEmpty(mail.Body))
if (GlobalSettings.UseSSL && string.IsNullOrEmpty(mail.Body) == false)
{
string serverName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
mail.Body = mail.Body.Replace(
@@ -196,7 +196,7 @@ namespace umbraco.cms.businesslogic.workflow
sender.Send(mail);
}
private static string replaceLinks(string text)
private static string ReplaceLinks(string text)
{
string domain = GlobalSettings.UseSSL ? "https://" : "http://";
domain += HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" +
@@ -233,7 +233,7 @@ namespace umbraco.cms.businesslogic.workflow
/// <summary>
/// Returns the notifications for a node
/// </summary>
/// <param name="user"></param>
/// <param name="node"></param>
/// <returns></returns>
public static IEnumerable<Notification> GetNodeNotifications(CMSNode node)
{
@@ -290,23 +290,23 @@ namespace umbraco.cms.businesslogic.workflow
/// <summary>
/// Creates a new notification
/// </summary>
/// <param name="User">The user.</param>
/// <param name="Node">The node.</param>
/// <param name="ActionLetter">The action letter.</param>
/// <param name="user">The user.</param>
/// <param name="node">The node.</param>
/// <param name="actionLetter">The action letter.</param>
[MethodImpl(MethodImplOptions.Synchronized)]
public static void MakeNew(User User, CMSNode Node, char ActionLetter)
public static void MakeNew(User user, CMSNode node, char actionLetter)
{
bool exists = ApplicationContext.Current.DatabaseContext.Database.ExecuteScalar<int>(
"SELECT COUNT(userId) FROM umbracoUser2nodeNotify WHERE userId = @userId AND nodeId = @nodeId AND action = @action",
new { userId = User.Id, nodeId = Node.Id, action = ActionLetter.ToString()}) > 0;
new { userId = user.Id, nodeId = node.Id, action = actionLetter.ToString()}) > 0;
if (exists == false)
{
ApplicationContext.Current.DatabaseContext.Database.Insert(new User2NodeNotifyDto
{
Action = ActionLetter.ToString(),
NodeId = Node.Id,
UserId = User.Id
Action = actionLetter.ToString(),
NodeId = node.Id,
UserId = user.Id
});
}
}
@@ -314,25 +314,25 @@ namespace umbraco.cms.businesslogic.workflow
/// <summary>
/// Updates the notifications.
/// </summary>
/// <param name="User">The user.</param>
/// <param name="Node">The node.</param>
/// <param name="Notifications">The notifications.</param>
/// <param name="user">The user.</param>
/// <param name="node">The node.</param>
/// <param name="notifications">The notifications.</param>
[MethodImpl(MethodImplOptions.Synchronized)]
public static void UpdateNotifications(User User, CMSNode Node, string Notifications)
public static void UpdateNotifications(User user, CMSNode node, string notifications)
{
// delete all settings on the node for this user
DeleteNotifications(User, Node);
DeleteNotifications(user, node);
// Loop through the permissions and create them
foreach (char c in Notifications)
MakeNew(User, Node, c);
foreach (char c in notifications)
MakeNew(user, node, c);
}
/// <summary>
/// Replaces the HTML symbols with the character equivalent.
/// </summary>
/// <param name="oldString">The old string.</param>
private static void ReplaceHTMLSymbols(ref string oldString)
private static void ReplaceHtmlSymbols(ref string oldString)
{
oldString = oldString.Replace("&nbsp;", " ");
oldString = oldString.Replace("&rsquo;", "'");
@@ -341,33 +341,7 @@ namespace umbraco.cms.businesslogic.workflow
oldString = oldString.Replace("&rdquo;", "”");
oldString = oldString.Replace("&quot;", "\"");
}
/// <summary>
/// Compares the text.
/// </summary>
/// <param name="oldText">The old text.</param>
/// <param name="newText">The new text.</param>
/// <returns></returns>
private static string CompareText(string oldText, string newText)
{
return CompareText(oldText, newText, true, true);
}
/// <summary>
/// Compares the text.
/// </summary>
/// <param name="oldText">The old text.</param>
/// <param name="newText">The new text.</param>
/// <param name="displayInsertedText">if set to <c>true</c> [display inserted text].</param>
/// <param name="displayDeletedText">if set to <c>true</c> [display deleted text].</param>
/// <returns></returns>
private static string CompareText(string oldText, string newText, bool displayInsertedText,
bool displayDeletedText)
{
return CompareText(oldText, newText, displayInsertedText, displayDeletedText,
"<span style='background-color:red;'>", "<span style='background-color:yellow;'>");
}
/// <summary>
/// Compares the text.
/// </summary>