diff --git a/src/Umbraco.Core/Models/Notification.cs b/src/Umbraco.Core/Models/Notification.cs new file mode 100644 index 0000000000..e5d3236b5e --- /dev/null +++ b/src/Umbraco.Core/Models/Notification.cs @@ -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; } + } +} diff --git a/src/Umbraco.Core/Persistence/Repositories/NotificationsRepository.cs b/src/Umbraco.Core/Persistence/Repositories/NotificationsRepository.cs new file mode 100644 index 0000000000..a15a7e1521 --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/NotificationsRepository.cs @@ -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 GetUserNotifications(IUser user) + { + var sql = new Sql() + .Select("DISTINCT umbracoNode.id, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action") + .From() + .InnerJoin() + .On(dto => dto.NodeId, dto => dto.NodeId) + .Where(dto => dto.UserId == (int)user.Id) + .OrderBy(dto => dto.NodeId); + + var dtos = _unitOfWork.Database.Fetch(sql); + //need to map the results + return dtos.Select(d => new Notification(d.id, d.userId, d.action, d.nodeObjectType)).ToList(); + } + + public IEnumerable GetEntityNotifications(IEntity entity) + { + var sql = new Sql() + .Select("DISTINCT umbracoNode.id, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action") + .From() + .InnerJoin() + .On(dto => dto.NodeId, dto => dto.NodeId) + .Where(dto => dto.NodeId == entity.Id) + .OrderBy(dto => dto.NodeId); + + var dtos = _unitOfWork.Database.Fetch(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("WHERE nodeId = @nodeId", new { nodeId = entity.Id }); + } + + public int DeleteNotifications(IUser user) + { + return _unitOfWork.Database.Delete("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("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() + .Where(nodeDto => nodeDto.NodeId == entity.Id); + var nodeType = _unitOfWork.Database.ExecuteScalar(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); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Services/INotificationService.cs b/src/Umbraco.Core/Services/INotificationService.cs new file mode 100644 index 0000000000..801424d3b0 --- /dev/null +++ b/src/Umbraco.Core/Services/INotificationService.cs @@ -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 + { + /// + /// Sends the notifications for the specified user regarding the specified node and action. + /// + /// + /// + /// + void SendNotifications(IEntity entity, IUser user, IAction action); + + /// + /// Gets the notifications for the user + /// + /// + /// + IEnumerable GetUserNotifications(IUser user); + + /// + /// Returns the notifications for an entity + /// + /// + /// + IEnumerable GetEntityNotifications(IEntity entity); + + /// + /// Deletes notifications by entity + /// + /// + void DeleteNotifications(IEntity entity); + + /// + /// Deletes notifications by user + /// + /// + void DeleteNotifications(IUser user); + + /// + /// Delete notifications by user and entity + /// + /// + /// + void DeleteNotifications(IUser user, IEntity entity); + + /// + /// Creates a new notification + /// + /// + /// + /// The action letter - note: this is a string for future compatibility + /// + Notification CreateNotification(IUser user, IEntity entity, string action); + } +} diff --git a/src/Umbraco.Core/Services/NotificationService.cs b/src/Umbraco.Core/Services/NotificationService.cs new file mode 100644 index 0000000000..31c534470b --- /dev/null +++ b/src/Umbraco.Core/Services/NotificationService.cs @@ -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; + } + + /// + /// Sends the notifications for the specified user regarding the specified node and action. + /// + /// + /// + /// + public void SendNotifications(IEntity entity, IUser user, IAction action) + { + throw new NotImplementedException(); + } + + /// + /// Gets the notifications for the user + /// + /// + /// + public IEnumerable GetUserNotifications(IUser user) + { + var uow = _uowProvider.GetUnitOfWork(); + var repository = new NotificationsRepository(uow); + return repository.GetUserNotifications(user); + } + + /// + /// Deletes notifications by entity + /// + /// + public IEnumerable GetEntityNotifications(IEntity entity) + { + var uow = _uowProvider.GetUnitOfWork(); + var repository = new NotificationsRepository(uow); + return repository.GetEntityNotifications(entity); + } + + /// + /// Deletes notifications by entity + /// + /// + public void DeleteNotifications(IEntity entity) + { + var uow = _uowProvider.GetUnitOfWork(); + var repository = new NotificationsRepository(uow); + repository.DeleteNotifications(entity); + } + + /// + /// Deletes notifications by user + /// + /// + public void DeleteNotifications(IUser user) + { + var uow = _uowProvider.GetUnitOfWork(); + var repository = new NotificationsRepository(uow); + repository.DeleteNotifications(user); + } + + /// + /// Delete notifications by user and entity + /// + /// + /// + public void DeleteNotifications(IUser user, IEntity entity) + { + var uow = _uowProvider.GetUnitOfWork(); + var repository = new NotificationsRepository(uow); + repository.DeleteNotifications(user, entity); + } + + /// + /// Creates a new notification + /// + /// + /// + /// The action letter - note: this is a string for future compatibility + /// + public Notification CreateNotification(IUser user, IEntity entity, string action) + { + var uow = _uowProvider.GetUnitOfWork(); + var repository = new NotificationsRepository(uow); + return repository.CreateNotification(user, entity, action); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index adecf92e6a..ad49b46b54 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -330,6 +330,7 @@ + @@ -346,6 +347,7 @@ + @@ -985,6 +987,7 @@ + @@ -996,6 +999,7 @@ + diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs index ce03d328a4..eb0dd2b1ee 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs @@ -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; diff --git a/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs new file mode 100644 index 0000000000..643c8d8b50 --- /dev/null +++ b/src/Umbraco.Tests/Persistence/Repositories/NotificationsRepositoryTest.cs @@ -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(e => e.Id == node.NodeId); + var user = Mock.Of(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(e => e.Id == (object)userDto.Id); + var userAdmin = Mock.Of(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(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(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(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(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(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(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(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(e => e.Id == (object)userDto.Id); + var userAdmin = Mock.Of(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(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); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 669f341a82..c5eb46bb1e 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -268,6 +268,7 @@ + diff --git a/src/umbraco.cms/businesslogic/CMSNode.cs b/src/umbraco.cms/businesslogic/CMSNode.cs index bd997bab54..f8a2ffd66d 100644 --- a/src/umbraco.cms/businesslogic/CMSNode.cs +++ b/src/umbraco.cms/businesslogic/CMSNode.cs @@ -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 diff --git a/src/umbraco.cms/businesslogic/workflow/Notification.cs b/src/umbraco.cms/businesslogic/workflow/Notification.cs index b6b3388a74..b272491362 100644 --- a/src/umbraco.cms/businesslogic/workflow/Notification.cs +++ b/src/umbraco.cms/businesslogic/workflow/Notification.cs @@ -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 /// /// Sends the notifications for the specified user regarding the specified node and action. /// - /// The node. + /// The node. /// The user. - /// The action. - public static void GetNotifications(CMSNode Node, User user, IAction Action) + /// The action. + 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(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(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(""); summary.Append(" Note: "); @@ -109,7 +109,7 @@ namespace umbraco.cms.businesslogic.workflow summary.Append(" New " + p.PropertyType.Name + ""); summary.Append("" + - replaceLinks(CompareText(oldText, newText, true, false, + ReplaceLinks(CompareText(oldText, newText, true, false, "", string.Empty)) + ""); summary.Append(""); @@ -117,7 +117,7 @@ namespace umbraco.cms.businesslogic.workflow summary.Append(" Old " + oldProperty.PropertyType.Name + ""); summary.Append("" + - replaceLinks(CompareText(newText, oldText, true, false, + ReplaceLinks(CompareText(newText, oldText, true, false, "", string.Empty)) + ""); summary.Append(""); @@ -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 /// /// Returns the notifications for a node /// - /// + /// /// public static IEnumerable GetNodeNotifications(CMSNode node) { @@ -290,23 +290,23 @@ namespace umbraco.cms.businesslogic.workflow /// /// Creates a new notification /// - /// The user. - /// The node. - /// The action letter. + /// The user. + /// The node. + /// The action letter. [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( "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 /// /// Updates the notifications. /// - /// The user. - /// The node. - /// The notifications. + /// The user. + /// The node. + /// The notifications. [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); } /// /// Replaces the HTML symbols with the character equivalent. /// /// The old string. - private static void ReplaceHTMLSymbols(ref string oldString) + private static void ReplaceHtmlSymbols(ref string oldString) { oldString = oldString.Replace(" ", " "); oldString = oldString.Replace("’", "'"); @@ -341,33 +341,7 @@ namespace umbraco.cms.businesslogic.workflow oldString = oldString.Replace("”", "”"); oldString = oldString.Replace(""", "\""); } - - /// - /// Compares the text. - /// - /// The old text. - /// The new text. - /// - private static string CompareText(string oldText, string newText) - { - return CompareText(oldText, newText, true, true); - } - - /// - /// Compares the text. - /// - /// The old text. - /// The new text. - /// if set to true [display inserted text]. - /// if set to true [display deleted text]. - /// - private static string CompareText(string oldText, string newText, bool displayInsertedText, - bool displayDeletedText) - { - return CompareText(oldText, newText, displayInsertedText, displayDeletedText, - "", ""); - } - + /// /// Compares the text. ///