Fixes naming conventions from old Notification class
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -47,20 +48,20 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends the notifications for the specified user regarding the specified node and action.
|
/// Sends the notifications for the specified user regarding the specified node and action.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Node">The node.</param>
|
/// <param name="node">The node.</param>
|
||||||
/// <param name="user">The user.</param>
|
/// <param name="user">The user.</param>
|
||||||
/// <param name="Action">The action.</param>
|
/// <param name="action">The action.</param>
|
||||||
public static void GetNotifications(CMSNode Node, User user, IAction Action)
|
public static void GetNotifications(CMSNode node, User user, IAction action)
|
||||||
{
|
{
|
||||||
User[] allUsers = User.getAll();
|
User[] allUsers = User.getAll();
|
||||||
foreach (User u in allUsers)
|
foreach (User u in allUsers)
|
||||||
{
|
{
|
||||||
try
|
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));
|
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);
|
SendNotification(user, u, (Document)node, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception notifyExp)
|
catch (Exception notifyExp)
|
||||||
@@ -71,8 +72,7 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
}
|
}
|
||||||
|
|
||||||
///TODO: Include update with html mail notification and document contents
|
///TODO: Include update with html mail notification and document contents
|
||||||
private static void sendNotification(User performingUser, User mailingUser, Document documentObject,
|
private static void SendNotification(User performingUser, User mailingUser, Document documentObject, IAction action)
|
||||||
IAction Action)
|
|
||||||
{
|
{
|
||||||
// retrieve previous version of the document
|
// retrieve previous version of the document
|
||||||
DocumentVersionList[] versions = documentObject.GetVersions();
|
DocumentVersionList[] versions = documentObject.GetVersions();
|
||||||
@@ -90,14 +90,14 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
string newText = p.Value != null ? p.Value.ToString() : "";
|
string newText = p.Value != null ? p.Value.ToString() : "";
|
||||||
|
|
||||||
// replace html with char equivalent
|
// replace html with char equivalent
|
||||||
ReplaceHTMLSymbols(ref oldText);
|
ReplaceHtmlSymbols(ref oldText);
|
||||||
ReplaceHTMLSymbols(ref newText);
|
ReplaceHtmlSymbols(ref newText);
|
||||||
|
|
||||||
// make sure to only highlight changes done using TinyMCE editor... other changes will be displayed using default summary
|
// 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() ==
|
if (p.PropertyType.DataTypeDefinition.DataType.ToString() ==
|
||||||
"umbraco.editorControls.tinymce.TinyMCEDataType" &&
|
"umbraco.editorControls.tinymce.TinyMCEDataType" &&
|
||||||
string.Compare(oldText, newText) != 0)
|
string.CompareOrdinal(oldText, newText) != 0)
|
||||||
{
|
{
|
||||||
summary.Append("<tr>");
|
summary.Append("<tr>");
|
||||||
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> Note: </th>");
|
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> Note: </th>");
|
||||||
@@ -108,7 +108,7 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> New " +
|
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> New " +
|
||||||
p.PropertyType.Name + "</th>");
|
p.PropertyType.Name + "</th>");
|
||||||
summary.Append("<td style='text-align: left; vertical-align: top;'>" +
|
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)) +
|
"<span style='background-color:yellow;'>", string.Empty)) +
|
||||||
"</td>");
|
"</td>");
|
||||||
summary.Append("</tr>");
|
summary.Append("</tr>");
|
||||||
@@ -116,7 +116,7 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> Old " +
|
summary.Append("<th style='text-align: left; vertical-align: top; width: 25%;'> Old " +
|
||||||
oldProperty.PropertyType.Name + "</th>");
|
oldProperty.PropertyType.Name + "</th>");
|
||||||
summary.Append("<td style='text-align: left; vertical-align: top;'>" +
|
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)) +
|
"<span style='background-color:red;'>", string.Empty)) +
|
||||||
"</td>");
|
"</td>");
|
||||||
summary.Append("</tr>");
|
summary.Append("</tr>");
|
||||||
@@ -139,12 +139,12 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
string[] subjectVars = {
|
string[] subjectVars = {
|
||||||
HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" +
|
HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" +
|
||||||
HttpContext.Current.Request.Url.Port +
|
HttpContext.Current.Request.Url.Port +
|
||||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco), ui.Text(Action.Alias)
|
IOHelper.ResolveUrl(SystemDirectories.Umbraco), ui.Text(action.Alias)
|
||||||
,
|
,
|
||||||
documentObject.Text
|
documentObject.Text
|
||||||
};
|
};
|
||||||
string[] bodyVars = {
|
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.ServerVariables["SERVER_NAME"] + ":" +
|
||||||
HttpContext.Current.Request.Url.Port +
|
HttpContext.Current.Request.Url.Port +
|
||||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||||
@@ -155,8 +155,8 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
/*umbraco.library.NiceUrl(documentObject.Id))*/
|
/*umbraco.library.NiceUrl(documentObject.Id))*/
|
||||||
documentObject.Id + ".aspx",
|
documentObject.Id + ".aspx",
|
||||||
protocol)
|
protocol)
|
||||||
///TODO: PPH removed the niceURL reference... cms.dll cannot reference the presentation project...
|
//TODO: PPH removed the niceURL reference... cms.dll cannot reference the presentation project...
|
||||||
///TODO: This should be moved somewhere else..
|
//TODO: This should be moved somewhere else..
|
||||||
};
|
};
|
||||||
|
|
||||||
// create the mail message
|
// create the mail message
|
||||||
@@ -182,7 +182,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
|
// 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
|
// 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"];
|
string serverName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
|
||||||
mail.Body = mail.Body.Replace(
|
mail.Body = mail.Body.Replace(
|
||||||
@@ -195,7 +195,7 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
sender.Send(mail);
|
sender.Send(mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string replaceLinks(string text)
|
private static string ReplaceLinks(string text)
|
||||||
{
|
{
|
||||||
string domain = GlobalSettings.UseSSL ? "https://" : "http://";
|
string domain = GlobalSettings.UseSSL ? "https://" : "http://";
|
||||||
domain += HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" +
|
domain += HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":" +
|
||||||
@@ -232,7 +232,7 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the notifications for a node
|
/// Returns the notifications for a node
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user"></param>
|
/// <param name="node"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Notification> GetNodeNotifications(CMSNode node)
|
public static IEnumerable<Notification> GetNodeNotifications(CMSNode node)
|
||||||
{
|
{
|
||||||
@@ -289,23 +289,23 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new notification
|
/// Creates a new notification
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="User">The user.</param>
|
/// <param name="user">The user.</param>
|
||||||
/// <param name="Node">The node.</param>
|
/// <param name="node">The node.</param>
|
||||||
/// <param name="ActionLetter">The action letter.</param>
|
/// <param name="actionLetter">The action letter.</param>
|
||||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
[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>(
|
bool exists = ApplicationContext.Current.DatabaseContext.Database.ExecuteScalar<int>(
|
||||||
"SELECT COUNT(userId) FROM umbracoUser2nodeNotify WHERE userId = @userId AND nodeId = @nodeId AND action = @action",
|
"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)
|
if (exists == false)
|
||||||
{
|
{
|
||||||
ApplicationContext.Current.DatabaseContext.Database.Insert(new User2NodeNotifyDto
|
ApplicationContext.Current.DatabaseContext.Database.Insert(new User2NodeNotifyDto
|
||||||
{
|
{
|
||||||
Action = ActionLetter.ToString(),
|
Action = actionLetter.ToString(),
|
||||||
NodeId = Node.Id,
|
NodeId = node.Id,
|
||||||
UserId = User.Id
|
UserId = user.Id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,25 +313,25 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the notifications.
|
/// Updates the notifications.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="User">The user.</param>
|
/// <param name="user">The user.</param>
|
||||||
/// <param name="Node">The node.</param>
|
/// <param name="node">The node.</param>
|
||||||
/// <param name="Notifications">The notifications.</param>
|
/// <param name="notifications">The notifications.</param>
|
||||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
[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
|
// delete all settings on the node for this user
|
||||||
DeleteNotifications(User, Node);
|
DeleteNotifications(user, node);
|
||||||
|
|
||||||
// Loop through the permissions and create them
|
// Loop through the permissions and create them
|
||||||
foreach (char c in Notifications)
|
foreach (char c in notifications)
|
||||||
MakeNew(User, Node, c);
|
MakeNew(user, node, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces the HTML symbols with the character equivalent.
|
/// Replaces the HTML symbols with the character equivalent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="oldString">The old string.</param>
|
/// <param name="oldString">The old string.</param>
|
||||||
private static void ReplaceHTMLSymbols(ref string oldString)
|
private static void ReplaceHtmlSymbols(ref string oldString)
|
||||||
{
|
{
|
||||||
oldString = oldString.Replace(" ", " ");
|
oldString = oldString.Replace(" ", " ");
|
||||||
oldString = oldString.Replace("’", "'");
|
oldString = oldString.Replace("’", "'");
|
||||||
@@ -340,33 +340,7 @@ namespace umbraco.cms.businesslogic.workflow
|
|||||||
oldString = oldString.Replace("”", "”");
|
oldString = oldString.Replace("”", "”");
|
||||||
oldString = oldString.Replace(""", "\"");
|
oldString = oldString.Replace(""", "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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>
|
/// <summary>
|
||||||
/// Compares the text.
|
/// Compares the text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user