User and User type from the old businesslogic assembly are GONE!
This commit is contained in:
@@ -747,11 +747,24 @@ namespace Umbraco.Core.Services
|
||||
var missingIds = nodeIds.Except(result.Select(x => x.EntityId));
|
||||
foreach (var id in missingIds)
|
||||
{
|
||||
result.Add(
|
||||
new EntityPermission(
|
||||
user.Id,
|
||||
id,
|
||||
user.DefaultPermissions.ToArray()));
|
||||
if (id == -1 && user.DefaultPermissions.Any() == false)
|
||||
{
|
||||
// exception to everything. If default cruds is empty and we're on root node; allow browse of root node
|
||||
result.Add(
|
||||
new EntityPermission(
|
||||
user.Id,
|
||||
id,
|
||||
user.DefaultPermissions.ToArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//use the user's user type permissions
|
||||
result.Add(
|
||||
new EntityPermission(
|
||||
user.Id,
|
||||
id,
|
||||
user.DefaultPermissions.ToArray()));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Security;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
@@ -6,6 +7,18 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
internal static class UserServiceExtensions
|
||||
{
|
||||
public static EntityPermission GetPermissions(this IUserService userService, IUser user, string path)
|
||||
{
|
||||
var ids = path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => x.TryConvertTo<int>())
|
||||
.Where(x => x.Success)
|
||||
.Select(x => x.Result)
|
||||
.ToArray();
|
||||
if (ids.Length == 0) throw new InvalidOperationException("The path: " + path + " could not be parsed into an array of integers or the path was empty");
|
||||
|
||||
return userService.GetPermissions(user, ids[ids.Length - 1]).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all permissions for this user for all nodes specified
|
||||
/// </summary>
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
[Test]
|
||||
public void Get_Root_Docs()
|
||||
{
|
||||
var user = new User(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot1 = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot1", mType, user, -1);
|
||||
var mRoot2 = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot2", mType, user, -1);
|
||||
var mChild1 = global::umbraco.cms.businesslogic.media.Media.MakeNew("Child1", mType, user, mRoot1.Id);
|
||||
@@ -55,8 +55,8 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
[Test]
|
||||
public void Get_Item_Without_Examine()
|
||||
{
|
||||
var user = new User(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot", mType, user, -1);
|
||||
var mChild1 = global::umbraco.cms.businesslogic.media.Media.MakeNew("Child1", mType, user, mRoot.Id);
|
||||
var publishedMedia = PublishedMediaTests.GetNode(mRoot.Id, GetUmbracoContext("/test", 1234));
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Children_Without_Examine()
|
||||
{
|
||||
var user = new User(0);
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot", mType, user, -1);
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Descendants_Without_Examine()
|
||||
{
|
||||
var user = new User(0);
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot", mType, user, -1);
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void DescendantsOrSelf_Without_Examine()
|
||||
{
|
||||
var user = new User(0);
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot", mType, user, -1);
|
||||
|
||||
@@ -366,7 +366,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Parent_Without_Examine()
|
||||
{
|
||||
var user = new User(0);
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot", mType, user, -1);
|
||||
|
||||
@@ -391,7 +391,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void Ancestors_Without_Examine()
|
||||
{
|
||||
var user = new User(0);
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot", mType, user, -1);
|
||||
|
||||
@@ -410,7 +410,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void AncestorsOrSelf_Without_Examine()
|
||||
{
|
||||
var user = new User(0);
|
||||
var user = ServiceContext.UserService.GetUserById(0);
|
||||
var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType");
|
||||
var mRoot = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot", mType, user, -1);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ NOTES:
|
||||
* Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config
|
||||
* A new version will invalidate both client and server cache and create new persisted files
|
||||
-->
|
||||
<clientDependency version="555578" fileDependencyExtensions=".js,.css" loggerType="Umbraco.Web.UI.CdfLogger, umbraco">
|
||||
<clientDependency version="162691750" fileDependencyExtensions=".js,.css" loggerType="Umbraco.Web.UI.CdfLogger, umbraco">
|
||||
|
||||
<!--
|
||||
This section is used for Web Forms only, the enableCompositeFiles="true" is optional and by default is set to true.
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Web.UI.Umbraco
|
||||
{
|
||||
return LegacyDialogHandler.UserHasCreateAccess(
|
||||
new HttpContextWrapper(Context),
|
||||
UmbracoContext.UmbracoUser,
|
||||
Security.CurrentUser,
|
||||
nodeTypeAlias);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco.Create
|
||||
@@ -68,9 +69,9 @@ namespace Umbraco.Web.UI.Umbraco.Create
|
||||
|
||||
}
|
||||
|
||||
public global::umbraco.BusinessLogic.User CurrentUser
|
||||
public IUser CurrentUser
|
||||
{
|
||||
get { return UmbracoContext.UmbracoUser; }
|
||||
get { return Security.CurrentUser; }
|
||||
}
|
||||
|
||||
protected void EmailValidator_OnServerValidate(object source, ServerValidateEventArgs args)
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
<%=Services.TextService.Localize("general/type")%>
|
||||
</th>
|
||||
<th>
|
||||
<%=umbraco.ui.Text("general", "sort",UmbracoUser)%>
|
||||
<%=Services.TextService.Localize("general/sort")%>
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace Umbraco.Web.UI.Umbraco.Dialogs
|
||||
propertiesMappedMessageBuilder.Append("</ul>");
|
||||
|
||||
// Save
|
||||
var user = global::umbraco.BusinessLogic.User.GetCurrent();
|
||||
var user = Security.CurrentUser;
|
||||
Services.ContentService.Save(_content, user.Id);
|
||||
|
||||
// Publish if the content was already published
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
</b>
|
||||
</HeaderTemplate>
|
||||
<ItemTemplate>
|
||||
<%# umbraco.BusinessLogic.User.GetUser(int.Parse(DataBinder.Eval(Container.DataItem, "UserId", "{0}"))).Name%>
|
||||
<%--TODO: N+1 !!!!!!!!!!!!--%>
|
||||
<%# Services.UserService.GetUserById(int.Parse(DataBinder.Eval(Container.DataItem, "UserId", "{0}"))).Name%>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateColumn>
|
||||
<asp:TemplateColumn>
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var emptyContent = Services.ContentService.CreateContent("", parentId, contentType.Alias, UmbracoUser.Id);
|
||||
var emptyContent = Services.ContentService.CreateContent("", parentId, contentType.Alias, Security.GetUserId());
|
||||
var mapped = Mapper.Map<IContent, ContentItemDisplay>(emptyContent);
|
||||
|
||||
//remove this tab if it exists: umbContainerView
|
||||
@@ -576,8 +576,8 @@ namespace Umbraco.Web.Editors
|
||||
if (Guid.TryParse(previewId, out id))
|
||||
{
|
||||
var d = new Document(contentId);
|
||||
var pc = new PreviewContent(UmbracoUser, id, false);
|
||||
pc.PrepareDocument(UmbracoUser, d, true);
|
||||
var pc = new PreviewContent(Security.CurrentUser, id, false);
|
||||
pc.PrepareDocument(Security.CurrentUser, d, true);
|
||||
pc.SavePreviewSet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
using legacyUser = umbraco.BusinessLogic.User;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
|
||||
|
||||
|
||||
@@ -54,20 +54,20 @@ namespace Umbraco.Web.Editors
|
||||
//this is a hack check based on legacy
|
||||
if (nodeType == "memberGroups")
|
||||
{
|
||||
LegacyDialogHandler.Delete(httpContextAttempt.Result, UmbracoUser, nodeType, 0, alias);
|
||||
LegacyDialogHandler.Delete(httpContextAttempt.Result, Security.CurrentUser, nodeType, 0, alias);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
int id;
|
||||
if (int.TryParse(nodeId, out id))
|
||||
{
|
||||
LegacyDialogHandler.Delete(httpContextAttempt.Result, UmbracoUser, nodeType, id, alias);
|
||||
LegacyDialogHandler.Delete(httpContextAttempt.Result, Security.CurrentUser, nodeType, id, alias);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
//the way this legacy stuff used to work is that if the node id didn't parse, we would
|
||||
//pass the node id as the alias with an id of zero = sure whatevs.
|
||||
LegacyDialogHandler.Delete(httpContextAttempt.Result, UmbracoUser, nodeType, 0, nodeId);
|
||||
LegacyDialogHandler.Delete(httpContextAttempt.Result, Security.CurrentUser, nodeType, 0, nodeId);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var emptyContent = Services.MediaService.CreateMedia("", parentId, contentType.Alias, UmbracoUser.Id);
|
||||
var emptyContent = Services.MediaService.CreateMedia("", parentId, contentType.Alias, Security.GetUserId());
|
||||
var mapped = Mapper.Map<IMedia, MediaItemDisplay>(emptyContent);
|
||||
|
||||
//remove this tab if it exists: umbContainerView
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
public IEnumerable<Section> GetSections()
|
||||
{
|
||||
var sections = Services.SectionService.GetAllowedSections(UmbracoUser.Id);
|
||||
var sections = Services.SectionService.GetAllowedSections(Security.GetUserId());
|
||||
return sections.Select(Mapper.Map<Core.Models.Section, Section>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using umbraco.interfaces;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using TypeFinder = Umbraco.Core.TypeFinder;
|
||||
|
||||
namespace Umbraco.Web.LegacyActions
|
||||
@@ -145,6 +146,23 @@ namespace Umbraco.Web.LegacyActions
|
||||
return new ArrayList(ActionsResolver.Current.Actions.ToList());
|
||||
}
|
||||
|
||||
internal static List<IAction> FromEntityPermission(EntityPermission entityPermission)
|
||||
{
|
||||
List<IAction> list = new List<IAction>();
|
||||
foreach (var c in entityPermission.AssignedPermissions.Where(x => x.Length == 1).Select(x => x.ToCharArray()[0]))
|
||||
{
|
||||
IAction action = ActionsResolver.Current.Actions.ToList().Find(
|
||||
delegate (IAction a)
|
||||
{
|
||||
return a.Letter == c;
|
||||
}
|
||||
);
|
||||
if (action != null)
|
||||
list.Add(action);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method will return a list of IAction's based on a string list. Each character in the list may represent
|
||||
/// an IAction. This will associate any found IActions based on the Letter property of the IAction with the character being referenced.
|
||||
|
||||
@@ -21,24 +21,5 @@ namespace Umbraco.Web.Mvc
|
||||
public abstract class UmbracoAuthorizedController : UmbracoController
|
||||
{
|
||||
|
||||
private bool _userisValidated = false;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the currently logged in Umbraco User
|
||||
/// </summary>
|
||||
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object")]
|
||||
protected User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_userisValidated)
|
||||
{
|
||||
Security.ValidateCurrentUser();
|
||||
_userisValidated = true;
|
||||
}
|
||||
return new User(Security.CurrentUser);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -12,7 +13,7 @@ using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
//NOTE: all of these require an UmbracoContext because currently to send the notifications we need an HttpContext, this is based on legacy code
|
||||
//TODO: all of these require an UmbracoContext because currently to send the notifications we need an HttpContext, this is based on legacy code
|
||||
// for which probably requires updating so that these can be sent outside of the http context.
|
||||
|
||||
internal static class NotificationServiceExtensions
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
{
|
||||
var previewContent = PreviewContentCache.GetOrCreateValue(context); // will use the ctor with no parameters
|
||||
var previewVal = HttpContext.Current.Request.GetPreviewCookieValue();
|
||||
previewContent.EnsureInitialized(context.UmbracoUser, previewVal, true, () =>
|
||||
previewContent.EnsureInitialized(context.Security.CurrentUser, previewVal, true, () =>
|
||||
{
|
||||
if (previewContent.ValidPreviewSet)
|
||||
previewContent.LoadPreviewset();
|
||||
|
||||
@@ -6,13 +6,13 @@ using System.Web;
|
||||
using System.Web.Security;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
using Microsoft.AspNet.Identity.Owin;
|
||||
using Microsoft.Owin;
|
||||
using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
|
||||
using User = umbraco.BusinessLogic.User;
|
||||
|
||||
namespace Umbraco.Web.Security
|
||||
{
|
||||
@@ -274,14 +274,18 @@ namespace Umbraco.Web.Security
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="action">The action.</param>
|
||||
/// <returns></returns>
|
||||
internal bool ValidateUserNodeTreePermissions(User umbracoUser, string path, string action)
|
||||
internal bool ValidateUserNodeTreePermissions(IUser umbracoUser, string path, string action)
|
||||
{
|
||||
var permissions = umbracoUser.GetPermissions(path);
|
||||
if (permissions.IndexOf(action, StringComparison.Ordinal) > -1 && (path.Contains("-20") || ("," + path + ",").Contains("," + umbracoUser.StartNodeId + ",")))
|
||||
|
||||
//we only want permissions for the last node in the pat
|
||||
var permission = _applicationContext.Services.UserService.GetPermissions(umbracoUser, path);
|
||||
if (permission == null) throw new InvalidOperationException("No permissions found");
|
||||
|
||||
if (permission.AssignedPermissions.Contains(action, StringComparer.Ordinal) && (path.Contains("-20") || ("," + path + ",").Contains("," + umbracoUser.StartContentId + ",")))
|
||||
return true;
|
||||
|
||||
var user = umbracoUser;
|
||||
LogHelper.Info<WebSecurity>("User {0} has insufficient permissions in UmbracoEnsuredPage: '{1}', '{2}', '{3}'", () => user.Name, () => path, () => permissions, () => action);
|
||||
LogHelper.Info<WebSecurity>("User {0} has insufficient permissions in UmbracoEnsuredPage: '{1}', '{2}', '{3}'", () => user.Name, () => path, () => string.Join(",", permission.AssignedPermissions), () => action);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -414,12 +418,6 @@ namespace Umbraco.Web.Security
|
||||
return apps.Any(uApp => uApp.InvariantEquals(app));
|
||||
}
|
||||
|
||||
[Obsolete("Do not use this method if you don't have to, use the overload with IUser instead")]
|
||||
internal bool UserHasAppAccess(string app, User user)
|
||||
{
|
||||
return user.Applications.Any(uApp => uApp.alias == app);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified user by username as access to the app
|
||||
/// </summary>
|
||||
|
||||
@@ -123,10 +123,9 @@ namespace Umbraco.Web.Trees
|
||||
menu.DefaultMenuAlias = ActionNew.Instance.Alias;
|
||||
|
||||
// we need to get the default permissions as you can't set permissions on the very root node
|
||||
//TODO: Use the new services to get permissions
|
||||
var nodeActions = global::Umbraco.Web.LegacyActions.Action.FromString(
|
||||
UmbracoUser.GetPermissions(Constants.System.Root.ToInvariantString()))
|
||||
.Select(x => new MenuItem(x));
|
||||
var permission = Services.UserService.GetPermissions(Security.CurrentUser, Constants.System.Root).First();
|
||||
var nodeActions = global::Umbraco.Web.LegacyActions.Action.FromEntityPermission(permission)
|
||||
.Select(x => new MenuItem(x));
|
||||
|
||||
//these two are the standard items
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias));
|
||||
|
||||
@@ -267,10 +267,11 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
internal IEnumerable<MenuItem> GetAllowedUserMenuItemsForNode(IUmbracoEntity dd)
|
||||
{
|
||||
var actions = global::Umbraco.Web.LegacyActions.Action.FromString(UmbracoUser.GetPermissions(dd.Path));
|
||||
var permission = Services.UserService.GetPermissions(Security.CurrentUser, dd.Path);
|
||||
var actions = global::Umbraco.Web.LegacyActions.Action.FromEntityPermission(permission);
|
||||
|
||||
// A user is allowed to delete their own stuff
|
||||
if (dd.CreatorId == UmbracoUser.Id && actions.Contains(ActionDelete.Instance) == false)
|
||||
if (dd.CreatorId == Security.CurrentUser.Id && actions.Contains(ActionDelete.Instance) == false)
|
||||
actions.Add(ActionDelete.Instance);
|
||||
|
||||
return actions.Select(x => new MenuItem(x));
|
||||
|
||||
@@ -5,8 +5,8 @@ using System.Web;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.interfaces;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Web.UI
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Web.UI
|
||||
/// <remarks>
|
||||
/// This will first check if we've already created the ITask in the current Http request
|
||||
/// </remarks>
|
||||
private static ITask GetTaskForOperation(HttpContextBase httpContext, User umbracoUser, Operation op, string nodeType)
|
||||
private static ITask GetTaskForOperation(HttpContextBase httpContext, IUser umbracoUser, Operation op, string nodeType)
|
||||
{
|
||||
if (httpContext == null) throw new ArgumentNullException("httpContext");
|
||||
if (umbracoUser == null) throw new ArgumentNullException("umbracoUser");
|
||||
@@ -118,7 +118,7 @@ namespace Umbraco.Web.UI
|
||||
///
|
||||
/// TODO: Create an API to assign a nodeType to an app so developers can manually secure it
|
||||
/// </remarks>
|
||||
internal static bool UserHasCreateAccess(HttpContextBase httpContext, User umbracoUser, string nodeType)
|
||||
internal static bool UserHasCreateAccess(HttpContextBase httpContext, IUser umbracoUser, string nodeType)
|
||||
{
|
||||
var task = GetTaskForOperation(httpContext, umbracoUser, Operation.Create, nodeType);
|
||||
var dialogTask = task as LegacyDialogTask;
|
||||
@@ -142,7 +142,7 @@ namespace Umbraco.Web.UI
|
||||
///
|
||||
/// TODO: Create an API to assign a nodeType to an app so developers can manually secure it
|
||||
/// </remarks>
|
||||
internal static bool UserHasDeleteAccess(HttpContextBase httpContext, User umbracoUser, string nodeType)
|
||||
internal static bool UserHasDeleteAccess(HttpContextBase httpContext, IUser umbracoUser, string nodeType)
|
||||
{
|
||||
var task = GetTaskForOperation(httpContext, umbracoUser, Operation.Delete, nodeType);
|
||||
var dialogTask = task as LegacyDialogTask;
|
||||
@@ -153,7 +153,7 @@ namespace Umbraco.Web.UI
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Delete(HttpContextBase httpContext, User umbracoUser, string nodeType, int nodeId, string text)
|
||||
public static void Delete(HttpContextBase httpContext, IUser umbracoUser, string nodeType, int nodeId, string text)
|
||||
{
|
||||
var typeInstance = GetTaskForOperation(httpContext, umbracoUser, Operation.Delete, nodeType);
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Umbraco.Web.UI
|
||||
typeInstance.Delete();
|
||||
}
|
||||
|
||||
public static string Create(HttpContextBase httpContext, User umbracoUser, string nodeType, int nodeId, string text, int typeId = 0)
|
||||
public static string Create(HttpContextBase httpContext, IUser umbracoUser, string nodeType, int nodeId, string text, int typeId = 0)
|
||||
{
|
||||
var typeInstance = GetTaskForOperation(httpContext, umbracoUser, Operation.Create, nodeType);
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Umbraco.Web.UI
|
||||
: "";
|
||||
}
|
||||
|
||||
internal static string Create(HttpContextBase httpContext, User umbracoUser, string nodeType, int nodeId, string text, IDictionary<string, object> additionalValues, int typeId = 0)
|
||||
internal static string Create(HttpContextBase httpContext, IUser umbracoUser, string nodeType, int nodeId, string text, IDictionary<string, object> additionalValues, int typeId = 0)
|
||||
{
|
||||
var typeInstance = GetTaskForOperation(httpContext, umbracoUser, Operation.Create, nodeType);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Security.Authentication;
|
||||
using Umbraco.Core;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.interfaces;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Web.UI
|
||||
{
|
||||
@@ -63,14 +64,14 @@ namespace Umbraco.Web.UI
|
||||
/// <remarks>
|
||||
/// accessible by inheritors but can only be set internally
|
||||
/// </remarks>
|
||||
protected internal User User { get; internal set; }
|
||||
protected internal IUser User { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Implemented explicitly as we don't want to expose this
|
||||
/// </summary>
|
||||
int ITask.UserId
|
||||
{
|
||||
set { User = User.GetUser(value); }
|
||||
set { User = ApplicationContext.Current.Services.UserService.GetUserById(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,7 +83,7 @@ namespace Umbraco.Web.UI
|
||||
if (User == null)
|
||||
throw new InvalidOperationException("Cannot authenticate, no User object assigned");
|
||||
|
||||
return User.Applications.Any(app => app.alias.InvariantEquals(AssignedApp));
|
||||
return User.AllowedSections.Any(app => app.InvariantEquals(AssignedApp));
|
||||
}
|
||||
|
||||
public abstract string ReturnUrl { get; }
|
||||
|
||||
@@ -88,26 +88,7 @@ namespace Umbraco.Web.UI.Pages
|
||||
/// If true then umbraco will force any window/frame to reload umbraco in the main window
|
||||
/// </summary>
|
||||
protected bool RedirectToUmbraco { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current user
|
||||
/// </summary>
|
||||
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object")]
|
||||
protected User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
//throw exceptions if not valid (true)
|
||||
if (!_hasValidated)
|
||||
{
|
||||
Security.ValidateCurrentUser(true);
|
||||
_hasValidated = true;
|
||||
}
|
||||
|
||||
return new User(Security.CurrentUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used to assign a webforms page's security to a specific tree which will in turn check to see
|
||||
/// if the current user has access to the specified tree's registered section
|
||||
|
||||
@@ -434,22 +434,7 @@ namespace Umbraco.Web
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current logged in Umbraco user (editor).
|
||||
/// </summary>
|
||||
/// <value>The Umbraco user object or null</value>
|
||||
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object")]
|
||||
public User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = Security.CurrentUser;
|
||||
return user == null ? null : new User(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the current user is in a preview mode and browsing the site (ie. not in the admin UI)
|
||||
/// </summary>
|
||||
|
||||
@@ -31,27 +31,6 @@ namespace Umbraco.Web.WebApi
|
||||
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper) : base(umbracoContext, umbracoHelper)
|
||||
{
|
||||
}
|
||||
|
||||
private bool _userisValidated = false;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the currently logged in Umbraco User
|
||||
/// </summary>
|
||||
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object, or Security.GetUserId() if you want to just get the user id")]
|
||||
protected User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
//throw exceptions if not valid (true)
|
||||
if (!_userisValidated)
|
||||
{
|
||||
Security.ValidateCurrentUser(true);
|
||||
_userisValidated = true;
|
||||
}
|
||||
|
||||
return new User(Security.CurrentUser);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -7,6 +8,7 @@ using System.Text;
|
||||
using System.Web.Http;
|
||||
using System.Web.Services.Description;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.WebApi;
|
||||
@@ -38,7 +40,9 @@ namespace Umbraco.Web.WebServices
|
||||
throw new HttpResponseException(response);
|
||||
}
|
||||
|
||||
if (UmbracoUser.GetPermissions(node.Path).Contains(ActionAssignDomain.Instance.Letter) == false)
|
||||
var permission = Services.UserService.GetPermissions(Security.CurrentUser, node.Path);
|
||||
|
||||
if (permission.AssignedPermissions.Contains(ActionAssignDomain.Instance.Letter.ToString(), StringComparer.Ordinal) == false)
|
||||
{
|
||||
var response = Request.CreateResponse(HttpStatusCode.BadRequest);
|
||||
response.Content = new StringContent("You do not have permission to assign domains on that node.");
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Web.Script.Serialization;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Media;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
namespace Umbraco.Web.WebServices
|
||||
{
|
||||
@@ -17,7 +16,7 @@ namespace Umbraco.Web.WebServices
|
||||
{
|
||||
public static string Embed()
|
||||
{
|
||||
var currentUser = User.GetCurrent();
|
||||
var currentUser = UmbracoContext.Current.Security.CurrentUser;
|
||||
|
||||
if (currentUser == null)
|
||||
throw new UnauthorizedAccessException("You must be logged in to use this service");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Security;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Security;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Web.WebServices
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Web.WebServices
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var hasAccess = UserHasAppAccess(app, UmbracoUser);
|
||||
var hasAccess = UserHasAppAccess(app, Security.CurrentUser);
|
||||
if (!hasAccess && throwExceptions)
|
||||
throw new SecurityException("The user does not have access to the required application");
|
||||
return hasAccess;
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Web.WebServices
|
||||
/// <param name="app"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
protected bool UserHasAppAccess(string app, User user)
|
||||
protected bool UserHasAppAccess(string app, IUser user)
|
||||
{
|
||||
return Security.UserHasAppAccess(app, user);
|
||||
}
|
||||
@@ -96,22 +96,6 @@ namespace Umbraco.Web.WebServices
|
||||
return result == ValidateRequestAttempt.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current user
|
||||
/// </summary>
|
||||
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object")]
|
||||
protected User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_hasValidated)
|
||||
{
|
||||
Security.ValidateCurrentUser();
|
||||
_hasValidated = true;
|
||||
}
|
||||
return new User(Security.CurrentUser);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Security;
|
||||
using Umbraco.Web.Security;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Web.WebServices
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace Umbraco.Web.WebServices
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var hasAccess = UserHasAppAccess(app, UmbracoUser);
|
||||
var hasAccess = UserHasAppAccess(app, Security.CurrentUser);
|
||||
if (!hasAccess && throwExceptions)
|
||||
throw new SecurityException("The user does not have access to the required application");
|
||||
return hasAccess;
|
||||
@@ -72,7 +72,7 @@ namespace Umbraco.Web.WebServices
|
||||
/// <param name="app"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
protected bool UserHasAppAccess(string app, User user)
|
||||
protected bool UserHasAppAccess(string app, IUser user)
|
||||
{
|
||||
return Security.UserHasAppAccess(app, user);
|
||||
}
|
||||
@@ -99,22 +99,5 @@ namespace Umbraco.Web.WebServices
|
||||
return result == ValidateRequestAttempt.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current user
|
||||
/// </summary>
|
||||
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object")]
|
||||
protected User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_hasValidated)
|
||||
{
|
||||
Security.ValidateCurrentUser();
|
||||
_hasValidated = true;
|
||||
}
|
||||
return new User(Security.CurrentUser);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +36,15 @@ namespace umbraco.cms.presentation.Trees
|
||||
|
||||
public override void Render(ref XmlTree tree)
|
||||
{
|
||||
foreach (umbraco.BusinessLogic.User user in umbraco.BusinessLogic.User.getAll())
|
||||
int totalusers;
|
||||
foreach (var user in Services.UserService.GetAll(0, int.MaxValue, out totalusers))
|
||||
{
|
||||
if (user.Id > 0 && !user.Disabled)
|
||||
if (user.Id > 0 && user.IsApproved)
|
||||
{
|
||||
XmlTreeNode node = XmlTreeNode.Create(this);
|
||||
node.NodeID = user.Id.ToString();
|
||||
node.Text = user.Name;
|
||||
node.Action = "javascript:openUserPermissions('" + user.Id.ToString() + "');";
|
||||
node.Action = "javascript:openUserPermissions('" + user.Id + "');";
|
||||
node.Icon = "icon-users";
|
||||
|
||||
OnBeforeNodeRender(ref tree, ref node, EventArgs.Empty);
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.cms.businesslogic.task;
|
||||
|
||||
using umbraco.interfaces;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.LegacyActions;
|
||||
|
||||
namespace umbraco {
|
||||
@@ -15,7 +16,7 @@ namespace umbraco {
|
||||
public loadOpenTasks(string application) : base(application) { }
|
||||
|
||||
protected override void CreateRootNode(ref XmlTreeNode rootNode) {
|
||||
rootNode.Action = "javascript:openTranslationOverview(" + currentUser().Id + ",'open');";
|
||||
rootNode.Action = "javascript:openTranslationOverview(" + CurrentUser().Id + ",'open');";
|
||||
rootNode.Text = Services.TextService.Localize("translation/assignedTasks");
|
||||
}
|
||||
|
||||
@@ -35,11 +36,13 @@ namespace umbraco {
|
||||
");
|
||||
}
|
||||
|
||||
private User currentUser() {
|
||||
return User.GetCurrent();
|
||||
private IUser CurrentUser()
|
||||
{
|
||||
return UmbracoContext.Current.Security.CurrentUser;
|
||||
}
|
||||
|
||||
public override void Render(ref XmlTree tree) {
|
||||
foreach (Task t in Task.GetTasks(currentUser(), false)) {
|
||||
foreach (Task t in Task.GetTasks(CurrentUser(), false)) {
|
||||
|
||||
if (t.Type.Alias == "toTranslate") {
|
||||
XmlTreeNode xNode = XmlTreeNode.Create(this);
|
||||
@@ -69,7 +72,7 @@ namespace umbraco {
|
||||
public loadYourTasks(string application) : base(application) { }
|
||||
|
||||
protected override void CreateRootNode(ref XmlTreeNode rootNode) {
|
||||
rootNode.Action = "javascript:openTranslationOverview(" + currentUser().Id + ", 'owned');";
|
||||
rootNode.Action = "javascript:openTranslationOverview(" + CurrentUser().Id + ", 'owned');";
|
||||
rootNode.Text = Services.TextService.Localize("translation/ownedTasks");
|
||||
}
|
||||
|
||||
@@ -85,13 +88,13 @@ namespace umbraco {
|
||||
}");
|
||||
}
|
||||
|
||||
private User currentUser()
|
||||
private IUser CurrentUser()
|
||||
{
|
||||
return User.GetCurrent();
|
||||
return UmbracoContext.Current.Security.CurrentUser;
|
||||
}
|
||||
|
||||
public override void Render(ref XmlTree tree) {
|
||||
foreach (Task t in Task.GetOwnedTasks(currentUser(), false)) {
|
||||
foreach (Task t in Task.GetOwnedTasks(CurrentUser(), false)) {
|
||||
|
||||
if (t.Type.Alias == "toTranslate") {
|
||||
XmlTreeNode xNode = XmlTreeNode.Create(this);
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Umbraco.Core.Configuration;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.LegacyActions;
|
||||
using Umbraco.Web.Trees;
|
||||
@@ -48,15 +49,16 @@ function openUser(id) {
|
||||
|
||||
public override void Render(ref XmlTree tree)
|
||||
{
|
||||
var users = new List<User>(User.getAll());
|
||||
int totalusers;
|
||||
var users = new List<IUser>(Services.UserService.GetAll(0, int.MaxValue, out totalusers));
|
||||
|
||||
User currUser = UmbracoContext.Current.UmbracoUser;
|
||||
var currUser = UmbracoContext.Current.Security.CurrentUser;
|
||||
|
||||
bool currUserIsAdmin = currUser.IsAdmin();
|
||||
foreach (User u in users.OrderBy(x => x.Disabled))
|
||||
foreach (var u in users.OrderBy(x => x.IsApproved == false))
|
||||
{
|
||||
if (!UmbracoConfig.For.UmbracoSettings().Security.HideDisabledUsersInBackoffice
|
||||
|| (UmbracoConfig.For.UmbracoSettings().Security.HideDisabledUsersInBackoffice && !u.Disabled))
|
||||
if (UmbracoConfig.For.UmbracoSettings().Security.HideDisabledUsersInBackoffice == false
|
||||
|| (UmbracoConfig.For.UmbracoSettings().Security.HideDisabledUsersInBackoffice && u.IsApproved))
|
||||
{
|
||||
|
||||
XmlTreeNode xNode = XmlTreeNode.Create(this);
|
||||
@@ -88,7 +90,7 @@ function openUser(id) {
|
||||
xNode.Icon = "icon-user";
|
||||
xNode.OpenIcon = "icon-user";
|
||||
|
||||
if (u.Disabled) {
|
||||
if (u.IsApproved == false) {
|
||||
xNode.Style.DimNode();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace umbraco.presentation.actions
|
||||
|
||||
if (Security.ValidateUserApp(Constants.Applications.Content) == false)
|
||||
throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator.");
|
||||
if (Security.ValidateUserNodeTreePermissions(UmbracoUser, d.Path, "D") == false)
|
||||
if (Security.ValidateUserNodeTreePermissions(Security.CurrentUser, d.Path, "D") == false)
|
||||
throw new ArgumentException("The current user doesn't have permissions to delete this document. Please contact the system administrator.");
|
||||
|
||||
pane_delete.Text = Services.TextService.Localize("delete") + " '" + d.Text + "'";
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace umbraco
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<XsltTasks>(string.Format("Could not remove XSLT file {0} - User {1}", Alias, UmbracoContext.Current.UmbracoUser.Id), ex);
|
||||
LogHelper.Error<XsltTasks>(string.Format("Could not remove XSLT file {0} - User {1}", Alias, UmbracoContext.Current.Security.GetUserId()), ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace umbraco.presentation.create
|
||||
{
|
||||
LegacyDialogHandler.Delete(
|
||||
new HttpContextWrapper(HttpContext.Current),
|
||||
UmbracoContext.Current.UmbracoUser,
|
||||
UmbracoContext.Current.Security.CurrentUser,
|
||||
NodeType, NodeId, Text);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace umbraco.presentation.create
|
||||
{
|
||||
return LegacyDialogHandler.Create(
|
||||
new HttpContextWrapper(HttpContext.Current),
|
||||
UmbracoContext.Current.UmbracoUser,
|
||||
UmbracoContext.Current.Security.CurrentUser,
|
||||
NodeType, NodeId, Text, TypeId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace umbraco.cms.presentation.create.controls
|
||||
{
|
||||
LegacyDialogHandler.Create(
|
||||
new HttpContextWrapper(Context),
|
||||
UmbracoContext.UmbracoUser,
|
||||
Security.CurrentUser,
|
||||
Request.GetItemAsString("nodeType"),
|
||||
-1,
|
||||
Cultures.SelectedValue);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace umbraco.presentation.umbraco.create
|
||||
{
|
||||
string returnUrl = LegacyDialogHandler.Create(
|
||||
new HttpContextWrapper(Context),
|
||||
UmbracoContext.UmbracoUser,
|
||||
Security.CurrentUser,
|
||||
Request.GetItemAsString("nodeType"),
|
||||
createFolder,
|
||||
rename.Text + '\u00A4' + scriptType.SelectedValue);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace umbraco.cms.presentation.create.controls
|
||||
|
||||
var returnUrl = LegacyDialogHandler.Create(
|
||||
new HttpContextWrapper(Context),
|
||||
new User(Security.CurrentUser),
|
||||
Security.CurrentUser,
|
||||
Request.GetItemAsString("nodeType"),
|
||||
nodeId,
|
||||
rename.Text.Trim(),
|
||||
|
||||
@@ -69,8 +69,9 @@ namespace umbraco
|
||||
|
||||
public override bool PerformDelete()
|
||||
{
|
||||
var u = User.GetUser(ParentID);
|
||||
u.disable();
|
||||
var u = ApplicationContext.Current.Services.UserService.GetUserById(ParentID);
|
||||
u.IsApproved = false;
|
||||
ApplicationContext.Current.Services.UserService.Save(u);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace umbraco.presentation.create
|
||||
|
||||
var returnUrl = LegacyDialogHandler.Create(
|
||||
new HttpContextWrapper(Context),
|
||||
UmbracoContext.UmbracoUser,
|
||||
Security.CurrentUser,
|
||||
Request.GetItemAsString("nodeType"),
|
||||
createMacroVal,
|
||||
xsltName + "|||" + rename.Text);
|
||||
|
||||
@@ -355,7 +355,7 @@ namespace umbraco.presentation.developer.packages
|
||||
|
||||
protected void delPack(object sender, EventArgs e)
|
||||
{
|
||||
_pack.Delete(UmbracoUser.Id);
|
||||
_pack.Delete(Security.CurrentUser.Id);
|
||||
pane_uninstalled.Visible = true;
|
||||
pane_uninstall.Visible = false;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ namespace umbraco.presentation.developer.packages
|
||||
var found = ApplicationContext.Services.FileService.GetTemplate(nId);
|
||||
if (found != null)
|
||||
{
|
||||
ApplicationContext.Services.FileService.DeleteTemplate(found.Alias, UmbracoUser.Id);
|
||||
ApplicationContext.Services.FileService.DeleteTemplate(found.Alias, Security.CurrentUser.Id);
|
||||
}
|
||||
_pack.Data.Templates.Remove(nId.ToString());
|
||||
}
|
||||
@@ -542,7 +542,7 @@ namespace umbraco.presentation.developer.packages
|
||||
}
|
||||
}
|
||||
_pack.Save();
|
||||
_pack.Delete(UmbracoUser.Id);
|
||||
_pack.Delete(Security.CurrentUser.Id);
|
||||
|
||||
pane_uninstalled.Visible = true;
|
||||
pane_uninstall.Visible = false;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace umbraco.presentation.developer.packages
|
||||
public Installer()
|
||||
{
|
||||
CurrentApp = Constants.Applications.Developer.ToString();
|
||||
_installer = new cms.businesslogic.packager.Installer(UmbracoUser.Id);
|
||||
_installer = new cms.businesslogic.packager.Installer(Security.CurrentUser.Id);
|
||||
}
|
||||
|
||||
private Control _configControl;
|
||||
@@ -73,7 +73,7 @@ namespace umbraco.presentation.developer.packages
|
||||
if (!pack.Protected)
|
||||
{
|
||||
//if it isn't then go straigt to the accept licens screen
|
||||
tempFile.Value = _installer.Import(_repo.fetch(Request.GetItemAsString("guid"), UmbracoUser.Id));
|
||||
tempFile.Value = _installer.Import(_repo.fetch(Request.GetItemAsString("guid"), Security.CurrentUser.Id));
|
||||
UpdateSettings();
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace umbraco.dialogs
|
||||
return;
|
||||
}
|
||||
|
||||
if (UmbracoUser.GetPermissions(node.Path).Contains(ActionAssignDomain.Instance.Letter) == false)
|
||||
var permissions = Services.UserService.GetPermissions(Security.CurrentUser, node.Path);
|
||||
if (permissions.AssignedPermissions.Contains(ActionAssignDomain.Instance.Letter.ToString(), StringComparer.Ordinal) == false)
|
||||
{
|
||||
feedback.Text = Services.TextService.Localize("assignDomain/permissionDenied");
|
||||
pane_language.Visible = false;
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace umbraco.presentation.dialogs
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
var d = new Document(Request.GetItemAs<int>("id"));
|
||||
var pc = new PreviewContent(UmbracoUser, Guid.NewGuid(), false);
|
||||
pc.PrepareDocument(UmbracoUser, d, true);
|
||||
var pc = new PreviewContent(Security.CurrentUser, Guid.NewGuid(), false);
|
||||
pc.PrepareDocument(Security.CurrentUser, d, true);
|
||||
pc.SavePreviewSet();
|
||||
docLit.Text = d.Text;
|
||||
changeSetUrl.Text = pc.PreviewsetPath;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web.UI;
|
||||
@@ -89,8 +90,8 @@ namespace umbraco.dialogs
|
||||
|
||||
private bool CheckCreatePermissions(int nodeId)
|
||||
{
|
||||
return UmbracoContext.UmbracoUser.GetPermissions(new CMSNode(nodeId).Path)
|
||||
.Contains(ActionNew.Instance.Letter.ToString(CultureInfo.InvariantCulture));
|
||||
var permission = Services.UserService.GetPermissions(Security.CurrentUser, new CMSNode(nodeId).Path);
|
||||
return permission.AssignedPermissions.Contains(ActionNew.Instance.Letter.ToString(CultureInfo.InvariantCulture), StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,11 +61,12 @@ namespace umbraco.dialogs
|
||||
}
|
||||
|
||||
ht.Rows.Add(names);
|
||||
|
||||
foreach (var u in BusinessLogic.User.getAll())
|
||||
|
||||
int totalUsers;
|
||||
foreach (var u in Services.UserService.GetAll(0, int.MaxValue, out totalUsers))
|
||||
{
|
||||
// Not disabled users and not system account
|
||||
if (u.Disabled == false && u.Id > 0)
|
||||
if (u.IsApproved && u.Id > 0)
|
||||
{
|
||||
var hc = new HtmlTableCell("th")
|
||||
{
|
||||
@@ -85,7 +86,9 @@ namespace umbraco.dialogs
|
||||
|
||||
if (a.CanBePermissionAssigned == false) continue;
|
||||
|
||||
if (u.GetPermissions(_node.Path).IndexOf(a.Letter) > -1)
|
||||
var permission = Services.UserService.GetPermissions(u, _node.Path);
|
||||
|
||||
if (permission.AssignedPermissions.Contains(a.Letter.ToString(), StringComparer.Ordinal))
|
||||
{
|
||||
chk.Checked = true;
|
||||
}
|
||||
@@ -113,9 +116,10 @@ namespace umbraco.dialogs
|
||||
{
|
||||
//get non disabled, non admin users and project to a dictionary,
|
||||
// the string (value) portion will store the array of chars = their permissions
|
||||
var usersPermissions = BusinessLogic.User.getAll()
|
||||
.Where(user => user.Disabled == false && user.Id > 0)
|
||||
.ToDictionary(user => user, user => "");
|
||||
int totalUsers;
|
||||
var usersPermissions = Services.UserService.GetAll(0, int.MaxValue, out totalUsers)
|
||||
.Where(user => user.IsApproved && user.Id > 0)
|
||||
.ToDictionary(user => user, user => "");
|
||||
|
||||
//iterate over each row which equals:
|
||||
// * a certain permission and the user's who will be allowed/denied that permission
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace umbraco.dialogs
|
||||
/// </remarks>
|
||||
private bool CheckPermissions(IContentBase node, IAction currentAction)
|
||||
{
|
||||
var currUserPermissions = new UserPermissions(UmbracoContext.UmbracoUser);
|
||||
var currUserPermissions = new UserPermissions(Security.CurrentUser);
|
||||
var lstCurrUserActions = currUserPermissions.GetExistingNodePermission(node.Id);
|
||||
|
||||
return lstCurrUserActions.Contains(currentAction);
|
||||
@@ -283,14 +283,14 @@ namespace umbraco.dialogs
|
||||
{
|
||||
var doc = (IContent)currContent;
|
||||
var copyToId = Request.GetItemAs<int>("copyTo");
|
||||
Services.ContentService.Move(doc, copyToId, UmbracoUser.Id);
|
||||
Services.ContentService.Move(doc, copyToId, Security.CurrentUser.Id);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var media = (IMedia)currContent;
|
||||
var copyToId = Request.GetItemAs<int>("copyTo");
|
||||
Services.MediaService.Move(media, copyToId, UmbracoUser.Id);
|
||||
Services.MediaService.Move(media, copyToId, Security.CurrentUser.Id);
|
||||
}
|
||||
|
||||
feedback.Text = Services.TextService.Localize("moveOrCopy/moveDone", nodes) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + Services.TextService.Localize("closeThisWindow") + "</a>";
|
||||
@@ -304,7 +304,7 @@ namespace umbraco.dialogs
|
||||
//NOTE: We ONLY support Copy on content not media for some reason.
|
||||
|
||||
var newContent = (IContent)currContent;
|
||||
Services.ContentService.Copy(newContent, Request.GetItemAs<int>("copyTo"), RelateDocuments.Checked, UmbracoUser.Id);
|
||||
Services.ContentService.Copy(newContent, Request.GetItemAs<int>("copyTo"), RelateDocuments.Checked, Security.CurrentUser.Id);
|
||||
|
||||
feedback.Text = Services.TextService.Localize("moveOrCopy/copyDone", nodes) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + Services.TextService.Localize("closeThisWindow") + "</a>";
|
||||
feedback.type = uicontrols.Feedback.feedbacktype.success;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Umbraco.Core.Services;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
@@ -54,8 +55,9 @@ namespace umbraco.dialogs
|
||||
|
||||
CheckBox c = new CheckBox();
|
||||
c.ID = a.Letter.ToString();
|
||||
|
||||
if (UmbracoContext.UmbracoUser.GetNotifications(node.Path).IndexOf(a.Letter) > -1)
|
||||
|
||||
var notifications = Services.NotificationService.GetUserNotifications(Security.CurrentUser, node.Path);
|
||||
if (notifications.Any(x => x.Action == a.Letter.ToString()))
|
||||
c.Checked = true;
|
||||
|
||||
uicontrols.PropertyPanel pp = new umbraco.uicontrols.PropertyPanel();
|
||||
@@ -93,10 +95,8 @@ namespace umbraco.dialogs
|
||||
if (c.Checked)
|
||||
notifications += c.ID;
|
||||
}
|
||||
Notification.UpdateNotifications(UmbracoContext.UmbracoUser, node, notifications);
|
||||
UmbracoContext.UmbracoUser.resetNotificationCache();
|
||||
UmbracoContext.UmbracoUser.initNotifications();
|
||||
|
||||
Notification.UpdateNotifications(Security.CurrentUser, node, notifications);
|
||||
|
||||
var feedback = new umbraco.uicontrols.Feedback();
|
||||
feedback.Text = Services.TextService.Localize("notifications") + " " + Services.TextService.Localize("ok") + "</p><p><a href='#' class='btn btn-primary' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + Services.TextService.Localize("closeThisWindow") + "</a>";
|
||||
feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace umbraco.presentation.umbraco.dialogs
|
||||
//if it's the umbraco membership provider, then we need to tell it what member type to create it with
|
||||
if (MemberType.GetByAlias(Constants.Conventions.MemberTypes.SystemDefaultProtectType) == null)
|
||||
{
|
||||
MemberType.MakeNew(BusinessLogic.User.GetUser(0), Constants.Conventions.MemberTypes.SystemDefaultProtectType);
|
||||
MemberType.MakeNew(Services.UserService.GetUserById(0), Constants.Conventions.MemberTypes.SystemDefaultProtectType);
|
||||
}
|
||||
var castedProvider = provider.AsUmbracoMembershipProvider();
|
||||
MembershipCreateStatus status;
|
||||
|
||||
@@ -79,11 +79,11 @@ namespace umbraco.presentation.dialogs
|
||||
operation = operation.And().GroupedOr(new[] { "__nodeName" }, new[] { word });
|
||||
|
||||
// ensure the user can only find nodes they are allowed to see
|
||||
if (UmbracoUser.StartNodeId > 0)
|
||||
if (Security.CurrentUser.StartContentId > 0)
|
||||
{
|
||||
//TODO: This is not correct! This will not filter out seearches 'from' this node, this
|
||||
// query is meant to search 'for' a specific node.
|
||||
operation = operation.And().Id(UmbracoUser.StartNodeId);
|
||||
operation = operation.And().Id(Security.CurrentUser.StartContentId);
|
||||
}
|
||||
|
||||
results = internalSearcher.Search(operation.Compile());
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.uicontrols;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
using Language = umbraco.cms.businesslogic.language.Language;
|
||||
@@ -69,7 +70,8 @@ namespace umbraco.presentation.dialogs
|
||||
includeSubpages.Enabled = false;
|
||||
|
||||
// Translators
|
||||
foreach (var u in BusinessLogic.User.getAll())
|
||||
int totalUsers;
|
||||
foreach (var u in Services.UserService.GetAll(0, int.MaxValue, out totalUsers))
|
||||
if (u.UserType.Alias.ToLower() == "translator" || UserHasTranslatePermission(u, _currentPage))
|
||||
translator.Items.Add(new ListItem(u.Name, u.Id.ToString()));
|
||||
|
||||
@@ -84,10 +86,11 @@ namespace umbraco.presentation.dialogs
|
||||
}
|
||||
}
|
||||
|
||||
private bool UserHasTranslatePermission(User u, CMSNode node)
|
||||
private bool UserHasTranslatePermission(IUser u, CMSNode node)
|
||||
{
|
||||
//the permissions column in umbracoUserType is legacy and needs to be rewritten but for now this is the only way to test
|
||||
return u.GetPermissions(node.Path).Contains("4");
|
||||
var permissions = Services.UserService.GetPermissions(u, node.Path);
|
||||
return permissions.AssignedPermissions.Contains("4");
|
||||
}
|
||||
|
||||
protected void doTranslation_Click(object sender, EventArgs e)
|
||||
@@ -95,9 +98,9 @@ namespace umbraco.presentation.dialogs
|
||||
// testing translate
|
||||
MakeNew(
|
||||
_currentPage,
|
||||
UmbracoContext.UmbracoUser,
|
||||
BusinessLogic.User.GetUser(Int32.Parse(translator.SelectedValue)),
|
||||
new Language(Int32.Parse(language.SelectedValue)),
|
||||
Security.CurrentUser,
|
||||
Services.UserService.GetUserById(int.Parse(translator.SelectedValue)),
|
||||
new Language(int.Parse(language.SelectedValue)),
|
||||
comment.Text, includeSubpages.Checked,
|
||||
true);
|
||||
|
||||
@@ -108,7 +111,7 @@ namespace umbraco.presentation.dialogs
|
||||
feedback.type = Feedback.feedbacktype.success;
|
||||
}
|
||||
|
||||
public void MakeNew(CMSNode Node, User User, User Translator, Language Language, string Comment,
|
||||
public void MakeNew(CMSNode Node, IUser User, IUser Translator, Language Language, string Comment,
|
||||
bool IncludeSubpages, bool SendEmail)
|
||||
{
|
||||
// Get translation taskType for obsolete task constructor
|
||||
@@ -152,9 +155,9 @@ namespace umbraco.presentation.dialogs
|
||||
MailMessage mail = new MailMessage(User.Email, Translator.Email);
|
||||
|
||||
// populate the message
|
||||
mail.Subject = Services.TextService.Localize("translation/mailSubject", Translator.UserEntity.GetUserCulture(Services.TextService), subjectVars);
|
||||
mail.Subject = Services.TextService.Localize("translation/mailSubject", Translator.GetUserCulture(Services.TextService), subjectVars);
|
||||
mail.IsBodyHtml = false;
|
||||
mail.Body = Services.TextService.Localize("translation/mailBody", Translator.UserEntity.GetUserCulture(Services.TextService), bodyVars);
|
||||
mail.Body = Services.TextService.Localize("translation/mailBody", Translator.GetUserCulture(Services.TextService), bodyVars);
|
||||
try
|
||||
{
|
||||
SmtpClient sender = new SmtpClient();
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
</b>
|
||||
</HeaderTemplate>
|
||||
<ItemTemplate>
|
||||
<%# umbraco.BusinessLogic.User.GetUser(int.Parse(DataBinder.Eval(Container.DataItem, "UserId", "{0}"))).Name%>
|
||||
<%--TODO: N+1 !!!! and no null checks--%>
|
||||
<%# Services.UserService.GetUserById(int.Parse(DataBinder.Eval(Container.DataItem, "UserId", "{0}"))).Name%>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateColumn>
|
||||
<asp:TemplateColumn>
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.cms.businesslogic;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace umbraco.presentation.preview
|
||||
@@ -47,7 +36,7 @@ namespace umbraco.presentation.preview
|
||||
private readonly object _initLock = new object();
|
||||
private bool _initialized = true;
|
||||
|
||||
public void EnsureInitialized(User user, string previewSet, bool validate, Action initialize)
|
||||
public void EnsureInitialized(IUser user, string previewSet, bool validate, Action initialize)
|
||||
{
|
||||
lock (_initLock)
|
||||
{
|
||||
@@ -69,14 +58,14 @@ namespace umbraco.presentation.preview
|
||||
{
|
||||
ValidPreviewSet = UpdatePreviewPaths(previewSet, true);
|
||||
}
|
||||
public PreviewContent(User user, Guid previewSet, bool validate)
|
||||
public PreviewContent(IUser user, Guid previewSet, bool validate)
|
||||
{
|
||||
_userId = user.Id;
|
||||
ValidPreviewSet = UpdatePreviewPaths(previewSet, validate);
|
||||
}
|
||||
|
||||
|
||||
public void PrepareDocument(User user, Document documentObject, bool includeSubs)
|
||||
public void PrepareDocument(IUser user, Document documentObject, bool includeSubs)
|
||||
{
|
||||
_userId = user.Id;
|
||||
|
||||
@@ -221,15 +210,15 @@ namespace umbraco.presentation.preview
|
||||
|
||||
public static void ClearPreviewCookie()
|
||||
{
|
||||
if (UmbracoContext.Current.UmbracoUser != null)
|
||||
if (UmbracoContext.Current.Security.CurrentUser != null)
|
||||
{
|
||||
if (HttpContext.Current.Request.HasPreviewCookie())
|
||||
{
|
||||
|
||||
DeletePreviewFile(
|
||||
UmbracoContext.Current.UmbracoUser.Id,
|
||||
UmbracoContext.Current.Security.CurrentUser.Id,
|
||||
new FileInfo(GetPreviewsetPath(
|
||||
UmbracoContext.Current.UmbracoUser.Id,
|
||||
UmbracoContext.Current.Security.CurrentUser.Id,
|
||||
new Guid(HttpContext.Current.Request.GetPreviewCookieValue()))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Web;
|
||||
using System.Linq;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.LegacyActions;
|
||||
@@ -304,8 +307,11 @@ namespace umbraco.presentation.templateControls
|
||||
/// <value><c>true</c> if the current item is editable by the current user; otherwise, <c>false</c>.</value>
|
||||
protected virtual bool FieldEditableWithUserPermissions()
|
||||
{
|
||||
BusinessLogic.User u = UmbracoContext.Current.UmbracoUser;
|
||||
return u != null && u.GetPermissions(PageElements["path"].ToString()).Contains(ActionUpdate.Instance.Letter.ToString());
|
||||
var u = UmbracoContext.Current.Security.CurrentUser;
|
||||
if (u == null) return false;
|
||||
var permission = ApplicationContext.Current.Services.UserService.GetPermissions(u, PageElements["path"].ToString());
|
||||
|
||||
return permission.AssignedPermissions.Contains(ActionUpdate.Instance.Letter.ToString(), StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -40,13 +40,13 @@ namespace umbraco.presentation.translation
|
||||
Tasks ts = new Tasks();
|
||||
if (Request["mode"] == "owned")
|
||||
{
|
||||
ts = Task.GetOwnedTasks(UmbracoContext.UmbracoUser, false);
|
||||
ts = Task.GetOwnedTasks(Security.CurrentUser, false);
|
||||
pane_tasks.Text = Services.TextService.Localize("translation/ownedTasks");
|
||||
Panel2.Text = Services.TextService.Localize("translation/ownedTasks");
|
||||
}
|
||||
else
|
||||
{
|
||||
ts = Task.GetTasks(UmbracoContext.UmbracoUser, false);
|
||||
ts = Task.GetTasks(Security.CurrentUser, false);
|
||||
pane_tasks.Text = Services.TextService.Localize("translation/assignedTasks");
|
||||
Panel2.Text = Services.TextService.Localize("translation/assignedTasks");
|
||||
}
|
||||
@@ -181,7 +181,7 @@ namespace umbraco.presentation.translation
|
||||
if (t != null)
|
||||
{
|
||||
//user auth and content node validation
|
||||
if (t.Node.Id == int.Parse(taskNode.Attributes.GetNamedItem("id").Value) && (t.User.Id == UmbracoUser.Id || t.ParentUser.Id == UmbracoUser.Id))
|
||||
if (t.Node.Id == int.Parse(taskNode.Attributes.GetNamedItem("id").Value) && (t.User.Id == Security.CurrentUser.Id || t.ParentUser.Id == Security.CurrentUser.Id))
|
||||
{
|
||||
|
||||
//TODO: Make this work again with correct APIs and angularized - so none of this code will exist anymore
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace umbraco.presentation.translation
|
||||
var nodes = new SortedList();
|
||||
int totalWords = 0;
|
||||
|
||||
foreach (Task t in Task.GetTasks(UmbracoContext.UmbracoUser, false))
|
||||
foreach (Task t in Task.GetTasks(Security.CurrentUser, false))
|
||||
{
|
||||
if (!nodes.ContainsKey(t.Node.Path))
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace umbraco.cms.presentation.user
|
||||
}
|
||||
|
||||
//only another admin can edit another admin (who is not the true admin)
|
||||
if (u.IsAdmin() && UmbracoContext.UmbracoUser.IsAdmin() == false)
|
||||
if (u.IsAdmin() && Security.CurrentUser.IsAdmin() == false)
|
||||
{
|
||||
throw new Exception("Admin users can only be edited by admins");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.LegacyActions;
|
||||
using Umbraco.Web.UI.Controls;
|
||||
@@ -25,7 +26,7 @@ namespace umbraco.cms.presentation.user
|
||||
DataBind();
|
||||
}
|
||||
|
||||
private User m_umbracoUser;
|
||||
private IUser m_umbracoUser;
|
||||
private int[] m_nodeID = {-1};
|
||||
private UserPermissions m_userPermissions;
|
||||
private string m_clientItemChecked = "void(0);";
|
||||
@@ -35,7 +36,7 @@ namespace umbraco.cms.presentation.user
|
||||
get { return m_umbracoUser.Id; }
|
||||
set
|
||||
{
|
||||
m_umbracoUser = BusinessLogic.User.GetUser(value);
|
||||
m_umbracoUser = Services.UserService.GetUserById(value);
|
||||
m_userPermissions = new UserPermissions(m_umbracoUser);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +71,7 @@ namespace umbraco.cms.presentation.user
|
||||
throw new ArgumentNullException("No User specified");
|
||||
|
||||
//get the logged in user's permissions
|
||||
UserPermissions currUserPermissions = new UserPermissions(UmbracoContext.Current.UmbracoUser);
|
||||
UserPermissions currUserPermissions = new UserPermissions(Security.CurrentUser);
|
||||
|
||||
//lookup permissions for last node selected
|
||||
int selectedNodeId = m_nodeID[m_nodeID.Length - 1];
|
||||
|
||||
@@ -2,9 +2,9 @@ using Umbraco.Core.Services;
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace umbraco.cms.presentation.user
|
||||
@@ -14,7 +14,7 @@ namespace umbraco.cms.presentation.user
|
||||
{
|
||||
public PermissionEditor()
|
||||
{
|
||||
CurrentApp = Constants.Applications.Users.ToString();
|
||||
CurrentApp = Constants.Applications.Users;
|
||||
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ namespace umbraco.cms.presentation.user
|
||||
/// <summary>
|
||||
/// Since Umbraco stores users in cache, we'll use this method to retrieve our user object by the selected id
|
||||
/// </summary>
|
||||
public User UmbracoUser
|
||||
public IUser UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
return BusinessLogic.User.GetUser(Convert.ToInt32(Request.QueryString["id"]));
|
||||
return Services.UserService.GetUserById(Convert.ToInt32(Request.QueryString["id"]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ namespace umbraco.cms.presentation.user
|
||||
{
|
||||
int id;
|
||||
bool parsed = false;
|
||||
umbraco.BusinessLogic.User oUser = null;
|
||||
IUser oUser = null;
|
||||
if (parsed = int.TryParse(strID, out id))
|
||||
oUser = umbraco.BusinessLogic.User.GetUser(id);
|
||||
oUser = Services.UserService.GetUserById(id);
|
||||
|
||||
if (oUser == null || oUser.UserType == null || !parsed)
|
||||
if (oUser == null || oUser.UserType == null || parsed == false)
|
||||
throw new Exception("No user found with id: " + strID);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace umbraco.cms.presentation.user
|
||||
{
|
||||
AuthorizeRequest(true);
|
||||
|
||||
UserPermissions uPermissions = new UserPermissions(BusinessLogic.User.GetUser(userID));
|
||||
UserPermissions uPermissions = new UserPermissions(Services.UserService.GetUserById(userID));
|
||||
List<IAction> actions = Action.FromString(permissions);
|
||||
uPermissions.SaveNewPermissions(toIntArray(nodes), actions, replaceChild);
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web.LegacyActions;
|
||||
|
||||
namespace umbraco.cms.presentation.user
|
||||
@@ -14,9 +15,9 @@ namespace umbraco.cms.presentation.user
|
||||
/// </summary>
|
||||
public class UserPermissions
|
||||
{
|
||||
readonly User _user;
|
||||
readonly IUser _user;
|
||||
|
||||
public UserPermissions(User user)
|
||||
public UserPermissions(IUser user)
|
||||
{
|
||||
_user = user;
|
||||
}
|
||||
@@ -36,8 +37,9 @@ namespace umbraco.cms.presentation.user
|
||||
var lstNoPermissions = new List<int>();
|
||||
foreach (var nodeId in nodeIDs)
|
||||
{
|
||||
var nodeActions = UmbracoContext.Current.UmbracoUser.GetPermissions(GetNodePath(nodeId));
|
||||
var lstActions = Action.FromString(nodeActions);
|
||||
var nodeActions = ApplicationContext.Current.Services.UserService.GetPermissions(UmbracoContext.Current.Security.CurrentUser, GetNodePath(nodeId));
|
||||
|
||||
var lstActions = Action.FromEntityPermission(nodeActions);
|
||||
if (lstActions == null || !lstActions.Contains(ActionRights.Instance))
|
||||
lstNoPermissions.Add(nodeId);
|
||||
}
|
||||
@@ -90,8 +92,9 @@ namespace umbraco.cms.presentation.user
|
||||
if (path != "")
|
||||
{
|
||||
//get the user and their permissions
|
||||
string permissions = _user.GetPermissions(path);
|
||||
return Action.FromString(permissions);
|
||||
|
||||
var permissions = ApplicationContext.Current.Services.UserService.GetPermissions(_user, path);
|
||||
return Action.FromEntityPermission(permissions);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ using Umbraco.Core.IO;
|
||||
using Umbraco.Web.UI;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.WebServices;
|
||||
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
|
||||
namespace umbraco.presentation.webservices
|
||||
@@ -31,7 +30,7 @@ namespace umbraco.presentation.webservices
|
||||
[ScriptService]
|
||||
public class legacyAjaxCalls : UmbracoAuthorizedWebService
|
||||
{
|
||||
private User _currentUser;
|
||||
private IUser _currentUser;
|
||||
|
||||
/// <summary>
|
||||
/// method to accept a string value for the node id. Used for tree's such as python
|
||||
@@ -56,21 +55,21 @@ namespace umbraco.presentation.webservices
|
||||
{
|
||||
LegacyDialogHandler.Delete(
|
||||
new HttpContextWrapper(HttpContext.Current),
|
||||
UmbracoUser,
|
||||
Security.CurrentUser,
|
||||
nodeType, 0, nodeId);
|
||||
}
|
||||
else if (int.TryParse(nodeId, out intNodeId) && nodeType != "member") // Fix for #26965 - numeric member login gets parsed as nodeId
|
||||
{
|
||||
LegacyDialogHandler.Delete(
|
||||
new HttpContextWrapper(HttpContext.Current),
|
||||
UmbracoUser,
|
||||
Security.CurrentUser,
|
||||
nodeType, intNodeId, alias);
|
||||
}
|
||||
else
|
||||
{
|
||||
LegacyDialogHandler.Delete(
|
||||
new HttpContextWrapper(HttpContext.Current),
|
||||
UmbracoUser,
|
||||
Security.CurrentUser,
|
||||
nodeType, 0, nodeId);
|
||||
}
|
||||
}
|
||||
@@ -119,7 +118,11 @@ namespace umbraco.presentation.webservices
|
||||
{
|
||||
AuthorizeRequest(Constants.Applications.Users.ToString(), true);
|
||||
|
||||
BusinessLogic.User.GetUser(userId).disable();
|
||||
var user = Services.UserService.GetUserById(userId);
|
||||
if (user == null) return;
|
||||
|
||||
user.IsApproved = false;
|
||||
Services.UserService.Save(user);
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
|
||||
@@ -1,928 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Web.Caching;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using umbraco.DataLayer;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace umbraco.BusinessLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// represents a Umbraco back end user
|
||||
/// </summary>
|
||||
[Obsolete("Use the UserService instead")]
|
||||
public class User
|
||||
{
|
||||
internal IUser UserEntity;
|
||||
private int? _lazyId;
|
||||
private bool? _defaultToLiveEditing;
|
||||
|
||||
private readonly Hashtable _notifications = new Hashtable();
|
||||
private bool _notificationsInitialized = false;
|
||||
|
||||
[Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)]
|
||||
private static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
}
|
||||
|
||||
internal User(IUser user)
|
||||
{
|
||||
UserEntity = user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="User"/> class.
|
||||
/// </summary>
|
||||
/// <param name="ID">The ID.</param>
|
||||
public User(int ID)
|
||||
{
|
||||
SetupUser(ID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="User"/> class.
|
||||
/// </summary>
|
||||
/// <param name="ID">The ID.</param>
|
||||
/// <param name="noSetup">if set to <c>true</c> [no setup].</param>
|
||||
public User(int ID, bool noSetup)
|
||||
{
|
||||
_lazyId = ID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="User"/> class.
|
||||
/// </summary>
|
||||
/// <param name="Login">The login.</param>
|
||||
/// <param name="Password">The password.</param>
|
||||
public User(string Login, string Password)
|
||||
{
|
||||
SetupUser(getUserId(Login, Password));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="User"/> class.
|
||||
/// </summary>
|
||||
/// <param name="Login">The login.</param>
|
||||
public User(string Login)
|
||||
{
|
||||
SetupUser(getUserId(Login));
|
||||
}
|
||||
|
||||
private void SetupUser(int ID)
|
||||
{
|
||||
UserEntity = ApplicationContext.Current.Services.UserService.GetUserById(ID);
|
||||
if (UserEntity == null)
|
||||
{
|
||||
throw new ArgumentException("No User exists with ID " + ID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to persist object changes to the database.
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
|
||||
ApplicationContext.Current.Services.UserService.Save(UserEntity);
|
||||
|
||||
OnSaving(EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the users name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.Name = value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the users email.
|
||||
/// </summary>
|
||||
/// <value>The email.</value>
|
||||
public string Email
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.Email;
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.Email = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the users language.
|
||||
/// </summary>
|
||||
/// <value>The language.</value>
|
||||
public string Language
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.Language;
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.Language = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the users password.
|
||||
/// </summary>
|
||||
/// <value>The password.</value>
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetPassword();
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.RawPasswordValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the password.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetPassword()
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.RawPasswordValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this user is an admin.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if this user is admin; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public bool IsAdmin()
|
||||
{
|
||||
return UserType.Alias == "admin";
|
||||
}
|
||||
|
||||
[Obsolete("Do not use this method to validate credentials, use the user's membership provider to do authentication. This method will not work if the password format is 'Encrypted'")]
|
||||
public bool ValidatePassword(string password)
|
||||
{
|
||||
var userLogin = ApplicationContext.Current.DatabaseContext.Database.ExecuteScalar<string>(
|
||||
"SELECT userLogin FROM umbracoUser WHERE userLogin = @login AND UserPasword = @password",
|
||||
new {login = LoginName, password = password});
|
||||
|
||||
return userLogin == this.LoginName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this user is the root (super user).
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if this user is root; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public bool IsRoot()
|
||||
{
|
||||
return Id == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the applications which the user has access to.
|
||||
/// </summary>
|
||||
/// <value>The users applications.</value>
|
||||
public Application[] Applications
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetApplications().ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the application which the user has access to as a List
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Application> GetApplications()
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
|
||||
var allApps = Application.getAll();
|
||||
var apps = new List<Application>();
|
||||
|
||||
var sections = UserEntity.AllowedSections;
|
||||
|
||||
foreach (var s in sections)
|
||||
{
|
||||
var app = allApps.SingleOrDefault(x => x.alias == s);
|
||||
if (app != null)
|
||||
apps.Add(app);
|
||||
}
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the users login name
|
||||
/// </summary>
|
||||
/// <value>The loginname.</value>
|
||||
public string LoginName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.Username;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EnsureUniqueLoginName(value, this) == false)
|
||||
throw new Exception(String.Format("A user with the login '{0}' already exists", value));
|
||||
|
||||
UserEntity.Username = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool EnsureUniqueLoginName(string loginName, User currentUser)
|
||||
{
|
||||
User[] u = User.getAllByLoginName(loginName);
|
||||
if (u.Length != 0)
|
||||
{
|
||||
if (u[0].Id != currentUser.Id)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the users credentials.
|
||||
/// </summary>
|
||||
/// <param name="lname">The login name.</param>
|
||||
/// <param name="passw">The password.</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Do not use this method to validate credentials, use the user's membership provider to do authentication. This method will not work if the password format is 'Encrypted'")]
|
||||
public static bool validateCredentials(string lname, string passw)
|
||||
{
|
||||
return validateCredentials(lname, passw, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the users credentials.
|
||||
/// </summary>
|
||||
/// <param name="lname">The login name.</param>
|
||||
/// <param name="passw">The password.</param>
|
||||
/// <param name="checkForUmbracoConsoleAccess">if set to <c>true</c> [check for umbraco console access].</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Do not use this method to validate credentials, use the user's membership provider to do authentication. This method will not work if the password format is 'Encrypted'")]
|
||||
public static bool validateCredentials(string lname, string passw, bool checkForUmbracoConsoleAccess)
|
||||
{
|
||||
string consoleCheckSql = "";
|
||||
if (checkForUmbracoConsoleAccess)
|
||||
consoleCheckSql = "and userNoConsole = 0 ";
|
||||
|
||||
object tmp = SqlHelper.ExecuteScalar<object>(
|
||||
"select id from umbracoUser where userDisabled = 0 " + consoleCheckSql + " and userLogin = @login and userPassword = @pw",
|
||||
SqlHelper.CreateParameter("@login", lname),
|
||||
SqlHelper.CreateParameter("@pw", passw)
|
||||
);
|
||||
|
||||
// Logging
|
||||
if (tmp == null)
|
||||
{
|
||||
LogHelper.Info<User>("Login: '" + lname + "' failed, from IP: " + System.Web.HttpContext.Current.Request.UserHostAddress);
|
||||
}
|
||||
|
||||
return (tmp != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the user.
|
||||
/// </summary>
|
||||
/// <value>The type of the user.</value>
|
||||
public UserType UserType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return new UserType(UserEntity.UserType);
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.UserType = value.UserTypeItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all users
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static User[] getAll()
|
||||
{
|
||||
int totalRecs;
|
||||
var users = ApplicationContext.Current.Services.UserService.GetAll(
|
||||
0, int.MaxValue, out totalRecs);
|
||||
|
||||
return users.Select(x => new User(x))
|
||||
.OrderBy(x => x.Name)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current user (logged in)
|
||||
/// </summary>
|
||||
/// <returns>A user or null</returns>
|
||||
public static User GetCurrent()
|
||||
{
|
||||
throw new NotImplementedException("NOTHING USING THIS WILL WORK UNTIL THIS USER CLASS IS REMOVED AND ALL CODE REFERENCING IT IS MIGRATED");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all users by email.
|
||||
/// </summary>
|
||||
/// <param name="email">The email.</param>
|
||||
/// <returns></returns>
|
||||
public static User[] getAllByEmail(string email)
|
||||
{
|
||||
return getAllByEmail(email, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all users by email.
|
||||
/// </summary>
|
||||
/// <param name="email">The email.</param>
|
||||
/// <param name="useExactMatch">match exact email address or partial email address.</param>
|
||||
/// <returns></returns>
|
||||
public static User[] getAllByEmail(string email, bool useExactMatch)
|
||||
{
|
||||
int totalRecs;
|
||||
if (useExactMatch)
|
||||
{
|
||||
return ApplicationContext.Current.Services.UserService.FindByEmail(
|
||||
email, 0, int.MaxValue, out totalRecs, StringPropertyMatchType.Exact)
|
||||
.Select(x => new User(x))
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApplicationContext.Current.Services.UserService.FindByEmail(
|
||||
string.Format("%{0}%", email), 0, int.MaxValue, out totalRecs, StringPropertyMatchType.Wildcard)
|
||||
.Select(x => new User(x))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all users by login name.
|
||||
/// </summary>
|
||||
/// <param name="login">The login.</param>
|
||||
/// <returns></returns>
|
||||
public static User[] getAllByLoginName(string login)
|
||||
{
|
||||
return GetAllByLoginName(login, false).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all users by login name.
|
||||
/// </summary>
|
||||
/// <param name="login">The login.</param>
|
||||
/// <param name="partialMatch">whether to use a partial match</param>
|
||||
/// <returns></returns>
|
||||
public static User[] getAllByLoginName(string login, bool partialMatch)
|
||||
{
|
||||
return GetAllByLoginName(login, partialMatch).ToArray();
|
||||
}
|
||||
|
||||
public static IEnumerable<User> GetAllByLoginName(string login, bool partialMatch)
|
||||
{
|
||||
int totalRecs;
|
||||
if (partialMatch)
|
||||
{
|
||||
return ApplicationContext.Current.Services.UserService.FindByUsername(
|
||||
string.Format("%{0}%", login), 0, int.MaxValue, out totalRecs, StringPropertyMatchType.Wildcard)
|
||||
.Select(x => new User(x))
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApplicationContext.Current.Services.UserService.FindByUsername(
|
||||
login, 0, int.MaxValue, out totalRecs, StringPropertyMatchType.Exact)
|
||||
.Select(x => new User(x))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new user.
|
||||
/// </summary>
|
||||
/// <param name="name">The full name.</param>
|
||||
/// <param name="lname">The login name.</param>
|
||||
/// <param name="passw">The password.</param>
|
||||
/// <param name="ut">The user type.</param>
|
||||
public static User MakeNew(string name, string lname, string passw, UserType ut)
|
||||
{
|
||||
var user = new Umbraco.Core.Models.Membership.User(name, "", lname, passw, ut.UserTypeItem);
|
||||
ApplicationContext.Current.Services.UserService.Save(user);
|
||||
|
||||
var u = new User(user);
|
||||
u.OnNew(EventArgs.Empty);
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new user.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="lname">The lname.</param>
|
||||
/// <param name="passw">The passw.</param>
|
||||
/// <param name="email">The email.</param>
|
||||
/// <param name="ut">The ut.</param>
|
||||
public static User MakeNew(string name, string lname, string passw, string email, UserType ut)
|
||||
{
|
||||
var user = new Umbraco.Core.Models.Membership.User(name, email, lname, passw, ut.UserTypeItem);
|
||||
ApplicationContext.Current.Services.UserService.Save(user);
|
||||
|
||||
var u = new User(user);
|
||||
u.OnNew(EventArgs.Empty);
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the name, login name and password for the user with the specified id.
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="lname">The lname.</param>
|
||||
/// <param name="email">The email.</param>
|
||||
/// <param name="ut">The ut.</param>
|
||||
public static void Update(int id, string name, string lname, string email, UserType ut)
|
||||
{
|
||||
if (EnsureUniqueLoginName(lname, GetUser(id)) == false)
|
||||
throw new Exception(String.Format("A user with the login '{0}' already exists", lname));
|
||||
|
||||
var found = ApplicationContext.Current.Services.UserService.GetUserById(id);
|
||||
if (found == null) return;
|
||||
found.Name = name;
|
||||
found.Username = lname;
|
||||
found.Email = email;
|
||||
found.UserType = ut.UserTypeItem;
|
||||
ApplicationContext.Current.Services.UserService.Save(found);
|
||||
}
|
||||
|
||||
public static void Update(int id, string name, string lname, string email, bool disabled, bool noConsole, UserType ut)
|
||||
{
|
||||
if (EnsureUniqueLoginName(lname, GetUser(id)) == false)
|
||||
throw new Exception(String.Format("A user with the login '{0}' already exists", lname));
|
||||
|
||||
var found = ApplicationContext.Current.Services.UserService.GetUserById(id);
|
||||
if (found == null) return;
|
||||
found.Name = name;
|
||||
found.Username = lname;
|
||||
found.Email = email;
|
||||
found.UserType = ut.UserTypeItem;
|
||||
found.IsApproved = disabled == false;
|
||||
found.IsLockedOut = noConsole;
|
||||
ApplicationContext.Current.Services.UserService.Save(found);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the membership provider properties
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="email"></param>
|
||||
/// <param name="disabled"></param>
|
||||
/// <param name="noConsole"></param>
|
||||
public static void Update(int id, string email, bool disabled, bool noConsole)
|
||||
{
|
||||
var found = ApplicationContext.Current.Services.UserService.GetUserById(id);
|
||||
if (found == null) return;
|
||||
|
||||
found.Email = email;
|
||||
found.IsApproved = disabled == false;
|
||||
found.IsLockedOut = noConsole;
|
||||
ApplicationContext.Current.Services.UserService.Save(found);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID from the user with the specified login name and password
|
||||
/// </summary>
|
||||
/// <param name="lname">The login name.</param>
|
||||
/// <param name="passw">The password.</param>
|
||||
/// <returns>a user ID</returns>
|
||||
public static int getUserId(string lname, string passw)
|
||||
{
|
||||
var found = ApplicationContext.Current.Services.UserService.GetByUsername(lname);
|
||||
return found.RawPasswordValue == passw ? found.Id : -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID from the user with the specified login name
|
||||
/// </summary>
|
||||
/// <param name="lname">The login name.</param>
|
||||
/// <returns>a user ID</returns>
|
||||
public static int getUserId(string lname)
|
||||
{
|
||||
var found = ApplicationContext.Current.Services.UserService.GetByUsername(lname);
|
||||
return found == null ? -1 : found.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes this instance.
|
||||
/// </summary>
|
||||
[Obsolete("Deleting users are NOT supported as history needs to be kept. Please use the disable() method instead")]
|
||||
public void delete()
|
||||
{
|
||||
//make sure you cannot delete the admin user!
|
||||
if (this.Id == 0)
|
||||
throw new InvalidOperationException("The Administrator account cannot be deleted");
|
||||
|
||||
OnDeleting(EventArgs.Empty);
|
||||
|
||||
ApplicationContext.Current.Services.UserService.Delete(UserEntity, true);
|
||||
|
||||
FlushFromCache();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables this instance.
|
||||
/// </summary>
|
||||
public void disable()
|
||||
{
|
||||
OnDisabling(EventArgs.Empty);
|
||||
|
||||
//delete without the true overload will perform the disable operation
|
||||
ApplicationContext.Current.Services.UserService.Delete(UserEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the users permissions based on a nodes path
|
||||
/// </summary>
|
||||
/// <param name="Path">The path.</param>
|
||||
/// <returns></returns>
|
||||
public string GetPermissions(string Path)
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
|
||||
var defaultPermissions = UserType.DefaultPermissions;
|
||||
|
||||
var cachedPermissions = ApplicationContext.Current.Services.UserService.GetPermissions(UserEntity)
|
||||
.ToArray();
|
||||
|
||||
// NH 4.7.1 changing default permission behavior to default to User Type permissions IF no specific permissions has been
|
||||
// set for the current node
|
||||
var nodeId = Path.Contains(",") ? int.Parse(Path.Substring(Path.LastIndexOf(",", StringComparison.Ordinal) + 1)) : int.Parse(Path);
|
||||
if (cachedPermissions.Any(x => x.EntityId == nodeId))
|
||||
{
|
||||
var found = cachedPermissions.First(x => x.EntityId == nodeId);
|
||||
return string.Join("", found.AssignedPermissions);
|
||||
}
|
||||
|
||||
// exception to everything. If default cruds is empty and we're on root node; allow browse of root node
|
||||
if (string.IsNullOrEmpty(defaultPermissions) && Path == "-1")
|
||||
defaultPermissions = "F";
|
||||
|
||||
// else return default user type cruds
|
||||
return defaultPermissions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the user node permissions
|
||||
/// </summary>
|
||||
[Obsolete("This method doesn't do anything whatsoever and will be removed in future versions")]
|
||||
public void initCruds()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a users notifications for a specified node path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The node path.</param>
|
||||
/// <returns></returns>
|
||||
public string GetNotifications(string Path)
|
||||
{
|
||||
string notifications = "";
|
||||
|
||||
if (_notificationsInitialized == false)
|
||||
initNotifications();
|
||||
|
||||
foreach (string nodeId in Path.Split(','))
|
||||
{
|
||||
if (_notifications.ContainsKey(int.Parse(nodeId)))
|
||||
notifications = _notifications[int.Parse(nodeId)].ToString();
|
||||
}
|
||||
|
||||
return notifications;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the internal hashtable containing cached information about notifications for the user
|
||||
/// </summary>
|
||||
public void resetNotificationCache()
|
||||
{
|
||||
_notificationsInitialized = false;
|
||||
_notifications.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the notifications and caches them.
|
||||
/// </summary>
|
||||
public void initNotifications()
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
|
||||
var notifications = ApplicationContext.Current.Services.NotificationService.GetUserNotifications(UserEntity);
|
||||
foreach (var n in notifications.OrderBy(x => x.EntityId))
|
||||
{
|
||||
int nodeId = n.EntityId;
|
||||
if (_notifications.ContainsKey(nodeId) == false)
|
||||
{
|
||||
_notifications.Add(nodeId, string.Empty);
|
||||
}
|
||||
_notifications[nodeId] += n.Action;
|
||||
}
|
||||
|
||||
_notificationsInitialized = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user id.
|
||||
/// </summary>
|
||||
/// <value>The id.</value>
|
||||
public int Id
|
||||
{
|
||||
get { return UserEntity.Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the list of applications the user has access to, ensure to call Save afterwords
|
||||
/// </summary>
|
||||
public void ClearApplications()
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
foreach (var s in UserEntity.AllowedSections.ToArray())
|
||||
{
|
||||
UserEntity.RemoveAllowedSection(s);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the list of applications the user has access to.
|
||||
/// </summary>
|
||||
[Obsolete("This method will implicitly cause a database save and will reset the current user's dirty property, do not use this method, use the ClearApplications method instead and then call Save() when you are done performing all user changes to persist the chagnes in one transaction")]
|
||||
public void clearApplications()
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
|
||||
foreach (var s in UserEntity.AllowedSections.ToArray())
|
||||
{
|
||||
UserEntity.RemoveAllowedSection(s);
|
||||
}
|
||||
|
||||
//For backwards compatibility this requires an implicit save
|
||||
ApplicationContext.Current.Services.UserService.Save(UserEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a application to the list of allowed applications, ensure to call Save() afterwords
|
||||
/// </summary>
|
||||
/// <param name="appAlias"></param>
|
||||
public void AddApplication(string appAlias)
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
UserEntity.AddAllowedSection(appAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a application to the list of allowed applications
|
||||
/// </summary>
|
||||
/// <param name="AppAlias">The app alias.</param>
|
||||
[Obsolete("This method will implicitly cause a multiple database saves and will reset the current user's dirty property, do not use this method, use the AddApplication method instead and then call Save() when you are done performing all user changes to persist the chagnes in one transaction")]
|
||||
public void addApplication(string AppAlias)
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
|
||||
UserEntity.AddAllowedSection(AppAlias);
|
||||
|
||||
//For backwards compatibility this requires an implicit save
|
||||
ApplicationContext.Current.Services.UserService.Save(UserEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the user has access to the Umbraco back end.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if the user has access to the back end; otherwise, <c>false</c>.</value>
|
||||
public bool NoConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.IsLockedOut;
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.IsLockedOut = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="User"/> is disabled.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if disabled; otherwise, <c>false</c>.</value>
|
||||
public bool Disabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.IsApproved == false;
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.IsApproved = value == false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the start content node id.
|
||||
/// </summary>
|
||||
/// <value>The start node id.</value>
|
||||
public int StartNodeId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.StartContentId;
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.StartContentId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start media id.
|
||||
/// </summary>
|
||||
/// <value>The start media id.</value>
|
||||
public int StartMediaId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lazyId.HasValue) SetupUser(_lazyId.Value);
|
||||
return UserEntity.StartMediaId;
|
||||
}
|
||||
set
|
||||
{
|
||||
UserEntity.StartMediaId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the user from cache.
|
||||
/// </summary>
|
||||
[Obsolete("This method should not be used, cache flushing is handled automatically by event handling in the web application and ensures that all servers are notified, this will not notify all servers in a load balanced environment")]
|
||||
public void FlushFromCache()
|
||||
{
|
||||
OnFlushingFromCache(EventArgs.Empty);
|
||||
ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.ClearCache<IUser>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user with a specified ID
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("The legacy user object should no longer be used, use the WebSecurity class to access the current user or the UserService to retrieve a user by id")]
|
||||
public static User GetUser(int id)
|
||||
{
|
||||
var result = ApplicationContext.Current.Services.UserService.GetUserById(id);
|
||||
if (result == null)
|
||||
{
|
||||
throw new ArgumentException("No user found with id " + id);
|
||||
}
|
||||
return new User(result);
|
||||
}
|
||||
|
||||
|
||||
//EVENTS
|
||||
/// <summary>
|
||||
/// The save event handler
|
||||
/// </summary>
|
||||
public delegate void SavingEventHandler(User sender, EventArgs e);
|
||||
/// <summary>
|
||||
/// The new event handler
|
||||
/// </summary>
|
||||
public delegate void NewEventHandler(User sender, EventArgs e);
|
||||
/// <summary>
|
||||
/// The disable event handler
|
||||
/// </summary>
|
||||
public delegate void DisablingEventHandler(User sender, EventArgs e);
|
||||
/// <summary>
|
||||
/// The delete event handler
|
||||
/// </summary>
|
||||
public delegate void DeletingEventHandler(User sender, EventArgs e);
|
||||
/// <summary>
|
||||
/// The Flush User from cache event handler
|
||||
/// </summary>
|
||||
public delegate void FlushingFromCacheEventHandler(User sender, EventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [saving].
|
||||
/// </summary>
|
||||
public static event SavingEventHandler Saving;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:Saving"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnSaving(EventArgs e)
|
||||
{
|
||||
if (Saving != null)
|
||||
Saving(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [new].
|
||||
/// </summary>
|
||||
public static event NewEventHandler New;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:New"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnNew(EventArgs e)
|
||||
{
|
||||
if (New != null)
|
||||
New(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [disabling].
|
||||
/// </summary>
|
||||
public static event DisablingEventHandler Disabling;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:Disabling"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnDisabling(EventArgs e)
|
||||
{
|
||||
if (Disabling != null)
|
||||
Disabling(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [deleting].
|
||||
/// </summary>
|
||||
public static event DeletingEventHandler Deleting;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:Deleting"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnDeleting(EventArgs e)
|
||||
{
|
||||
if (Deleting != null)
|
||||
Deleting(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [flushing from cache].
|
||||
/// </summary>
|
||||
public static event FlushingFromCacheEventHandler FlushingFromCache;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:FlushingFromCache"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnFlushingFromCache(EventArgs e)
|
||||
{
|
||||
if (FlushingFromCache != null)
|
||||
FlushingFromCache(this, e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Events;
|
||||
using umbraco.DataLayer;
|
||||
|
||||
namespace umbraco.BusinessLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a umbraco Usertype
|
||||
/// </summary>
|
||||
[Obsolete("Use the UserService instead")]
|
||||
public class UserType
|
||||
{
|
||||
|
||||
internal Umbraco.Core.Models.Membership.IUserType UserTypeItem;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new empty instance of a UserType
|
||||
/// </summary>
|
||||
public UserType()
|
||||
{
|
||||
UserTypeItem = new Umbraco.Core.Models.Membership.UserType();
|
||||
}
|
||||
|
||||
internal UserType(Umbraco.Core.Models.Membership.IUserType userType)
|
||||
{
|
||||
UserTypeItem = userType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of a UserType and attempts to
|
||||
/// load it's values from the database cache.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the UserType is not found in the existing ID list, then this object
|
||||
/// will remain an empty object
|
||||
/// </remarks>
|
||||
/// <param name="id">The UserType id to find</param>
|
||||
public UserType(int id)
|
||||
{
|
||||
this.LoadByPrimaryKey(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UserType"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The user type id.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
public UserType(int id, string name)
|
||||
{
|
||||
UserTypeItem = new Umbraco.Core.Models.Membership.UserType();
|
||||
UserTypeItem.Id = id;
|
||||
UserTypeItem.Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of UserType with all parameters
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="defaultPermissions"></param>
|
||||
/// <param name="alias"></param>
|
||||
public UserType(int id, string name, string defaultPermissions, string alias)
|
||||
{
|
||||
UserTypeItem = new Umbraco.Core.Models.Membership.UserType();
|
||||
UserTypeItem.Id = id;
|
||||
UserTypeItem.Name = name;
|
||||
UserTypeItem.Alias = alias;
|
||||
UserTypeItem.Permissions = defaultPermissions.ToCharArray().Select(x => x.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The cache storage for all user types
|
||||
/// </summary>
|
||||
private static List<UserType> UserTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return ApplicationContext.Current.Services.UserService.GetAllUserTypes()
|
||||
.Select(x => new UserType(x))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the user type alias.
|
||||
/// </summary>
|
||||
public string Alias
|
||||
{
|
||||
get { return UserTypeItem.Alias; }
|
||||
set { UserTypeItem.Alias = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the user type.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return UserTypeItem.Name; }
|
||||
set { UserTypeItem.Name = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the id the user type
|
||||
/// </summary>
|
||||
public int Id
|
||||
{
|
||||
get { return UserTypeItem.Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default permissions of the user type
|
||||
/// </summary>
|
||||
public string DefaultPermissions
|
||||
{
|
||||
get { return UserTypeItem.Permissions == null ? string.Empty : string.Join("", UserTypeItem.Permissions); }
|
||||
set { UserTypeItem.Permissions = value.ToCharArray().Select(x => x.ToString(CultureInfo.InvariantCulture)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of UserTypes
|
||||
/// </summary>
|
||||
[Obsolete("Use the GetAll method instead")]
|
||||
public static UserType[] getAll
|
||||
{
|
||||
get { return GetAllUserTypes().ToArray(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Saves this instance.
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
//ensure that this object has an ID specified (it exists in the database)
|
||||
if (UserTypeItem.HasIdentity == false)
|
||||
throw new Exception("The current UserType object does not exist in the database. New UserTypes should be created with the MakeNew method");
|
||||
|
||||
ApplicationContext.Current.Services.UserService.SaveUserType(UserTypeItem);
|
||||
|
||||
//raise event
|
||||
OnUpdated(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes this instance.
|
||||
/// </summary>
|
||||
public void Delete()
|
||||
{
|
||||
//ensure that this object has an ID specified (it exists in the database)
|
||||
if (UserTypeItem.HasIdentity == false)
|
||||
throw new Exception("The current UserType object does not exist in the database. New UserTypes should be created with the MakeNew method");
|
||||
|
||||
ApplicationContext.Current.Services.UserService.DeleteUserType(UserTypeItem);
|
||||
|
||||
//raise event
|
||||
OnDeleted(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the data for the current UserType by it's id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Returns true if the UserType id was found
|
||||
/// and the data was loaded, false if it wasn't</returns>
|
||||
public bool LoadByPrimaryKey(int id)
|
||||
{
|
||||
UserTypeItem = ApplicationContext.Current.Services.UserService.GetUserTypeById(id);
|
||||
return UserTypeItem != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new user type
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="defaultPermissions"></param>
|
||||
/// <param name="alias"></param>
|
||||
public static UserType MakeNew(string name, string defaultPermissions, string alias)
|
||||
{
|
||||
//ensure that the current alias does not exist
|
||||
//get the id for the new user type
|
||||
var existing = UserTypes.Find(ut => (ut.Alias == alias));
|
||||
|
||||
if (existing != null)
|
||||
throw new Exception("The UserType alias specified already exists");
|
||||
|
||||
var userType = new Umbraco.Core.Models.Membership.UserType
|
||||
{
|
||||
Alias = alias,
|
||||
Name = name,
|
||||
Permissions = defaultPermissions.ToCharArray().Select(x => x.ToString(CultureInfo.InvariantCulture))
|
||||
};
|
||||
ApplicationContext.Current.Services.UserService.SaveUserType(userType);
|
||||
|
||||
var legacy = new UserType(userType);
|
||||
|
||||
//raise event
|
||||
OnNew(legacy, new EventArgs());
|
||||
|
||||
return legacy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user type with the specied ID
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <returns></returns>
|
||||
public static UserType GetUserType(int id)
|
||||
{
|
||||
return UserTypes.Find(ut => (ut.Id == id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all UserType's
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<UserType> GetAllUserTypes()
|
||||
{
|
||||
return UserTypes;
|
||||
}
|
||||
|
||||
internal static event TypedEventHandler<UserType, EventArgs> New;
|
||||
private static void OnNew(UserType userType, EventArgs args)
|
||||
{
|
||||
if (New != null)
|
||||
{
|
||||
New(userType, args);
|
||||
}
|
||||
}
|
||||
|
||||
internal static event TypedEventHandler<UserType, EventArgs> Deleted;
|
||||
private static void OnDeleted(UserType userType, EventArgs args)
|
||||
{
|
||||
if (Deleted != null)
|
||||
{
|
||||
Deleted(userType, args);
|
||||
}
|
||||
}
|
||||
|
||||
internal static event TypedEventHandler<UserType, EventArgs> Updated;
|
||||
private static void OnUpdated(UserType userType, EventArgs args)
|
||||
{
|
||||
if (Updated != null)
|
||||
{
|
||||
Updated(userType, args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -188,12 +188,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="User.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserType.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence;
|
||||
|
||||
@@ -17,9 +16,8 @@ using System.ComponentModel;
|
||||
using Umbraco.Core.IO;
|
||||
using System.Collections;
|
||||
using umbraco.cms.businesslogic.task;
|
||||
using umbraco.cms.businesslogic.workflow;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using File = System.IO.File;
|
||||
using Media = umbraco.cms.businesslogic.media.Media;
|
||||
using Notification = umbraco.cms.businesslogic.workflow.Notification;
|
||||
using Task = umbraco.cms.businesslogic.task.Task;
|
||||
|
||||
@@ -292,7 +290,7 @@ namespace umbraco.cms.businesslogic
|
||||
IEnumerable<Permission> permissions = Permission.GetNodePermissions(parent);
|
||||
foreach (Permission p in permissions)
|
||||
{
|
||||
Permission.MakeNew(User.GetUser(p.UserId), retVal, p.PermissionId);
|
||||
Permission.MakeNew(ApplicationContext.Current.Services.UserService.GetUserById(p.UserId), retVal, p.PermissionId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -688,11 +686,11 @@ order by level,sortOrder";
|
||||
/// Gets the creator
|
||||
/// </summary>
|
||||
/// <value>The user.</value>
|
||||
public BusinessLogic.User User
|
||||
public IUser User
|
||||
{
|
||||
get
|
||||
{
|
||||
return BusinessLogic.User.GetUser(_userId);
|
||||
return ApplicationContext.Current.Services.UserService.GetUserById(_userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,10 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Auditing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Packaging;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.cms.businesslogic.propertytype;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Diagnostics;
|
||||
using umbraco.cms.businesslogic.macro;
|
||||
using umbraco.cms.businesslogic.template;
|
||||
using umbraco.interfaces;
|
||||
|
||||
namespace umbraco.cms.businesslogic.packager
|
||||
{
|
||||
@@ -298,7 +294,7 @@ namespace umbraco.cms.businesslogic.packager
|
||||
//bool saveNeeded = false;
|
||||
|
||||
// Get current user, with a fallback
|
||||
var currentUser = new User(0);
|
||||
var currentUser = ApplicationContext.Current.Services.UserService.GetUserById(0);
|
||||
|
||||
//TODO: Need to migrate this class/code/logic so that we can replicate this functionality, until then everything will be installed by ADMIN
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.packager
|
||||
{
|
||||
@@ -53,7 +55,7 @@ namespace umbraco.cms.businesslogic.packager
|
||||
Uninstalled = dr.GetBoolean("uninstalled");
|
||||
UpgradeId = dr.GetInt("upgradeId");
|
||||
InstallDate = dr.GetDateTime("installDate");
|
||||
User = User.GetUser(dr.GetInt("userId"));
|
||||
User = ApplicationContext.Current.Services.UserService.GetUserById(dr.GetInt("userId"));
|
||||
PackageId = dr.GetGuid("package");
|
||||
VersionMajor = dr.GetInt("versionMajor");
|
||||
VersionMinor = dr.GetInt("versionMinor");
|
||||
@@ -101,7 +103,7 @@ namespace umbraco.cms.businesslogic.packager
|
||||
public bool Uninstalled { get; set; }
|
||||
|
||||
|
||||
public User User { get; set; }
|
||||
public IUser User { get; set; }
|
||||
|
||||
|
||||
public DateTime InstallDate { get; set; }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace umbraco.cms.businesslogic.packager.standardPackageActions
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace umbraco.cms.businesslogic.packager.standardPackageActions
|
||||
if (rootDoc.Text.Trim() == documentName.Trim() && rootDoc != null && rootDoc.ContentType != null)
|
||||
{
|
||||
|
||||
rootDoc.PublishWithChildrenWithResult(umbraco.BusinessLogic.User.GetUser(0));
|
||||
rootDoc.PublishWithChildrenWithResult(ApplicationContext.Current.Services.UserService.GetUserById(0));
|
||||
|
||||
|
||||
break;
|
||||
|
||||
@@ -30,12 +30,12 @@ namespace umbraco.BusinessLogic
|
||||
/// </summary>
|
||||
private Permission() { }
|
||||
|
||||
public static void MakeNew(User User, CMSNode Node, char PermissionKey)
|
||||
public static void MakeNew(IUser User, CMSNode Node, char PermissionKey)
|
||||
{
|
||||
MakeNew(User, Node, PermissionKey, true);
|
||||
}
|
||||
|
||||
private static void MakeNew(User user, IEnumerable<CMSNode> nodes, char permissionKey, bool raiseEvents)
|
||||
private static void MakeNew(IUser user, IEnumerable<CMSNode> nodes, char permissionKey, bool raiseEvents)
|
||||
{
|
||||
var asArray = nodes.ToArray();
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace umbraco.BusinessLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static void MakeNew(User User, CMSNode Node, char PermissionKey, bool raiseEvents)
|
||||
private static void MakeNew(IUser User, CMSNode Node, char PermissionKey, bool raiseEvents)
|
||||
{
|
||||
MakeNew(User, new[] {Node}, PermissionKey, raiseEvents);
|
||||
}
|
||||
@@ -57,9 +57,9 @@ namespace umbraco.BusinessLogic
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Permission> GetUserPermissions(User user)
|
||||
public static IEnumerable<Permission> GetUserPermissions(IUser user)
|
||||
{
|
||||
var permissions = ApplicationContext.Current.Services.UserService.GetPermissions(user.UserEntity);
|
||||
var permissions = ApplicationContext.Current.Services.UserService.GetPermissions(user);
|
||||
|
||||
return permissions.SelectMany(
|
||||
entityPermission => entityPermission.AssignedPermissions,
|
||||
@@ -99,12 +99,12 @@ namespace umbraco.BusinessLogic
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="node"></param>
|
||||
public static void DeletePermissions(User user, CMSNode node)
|
||||
public static void DeletePermissions(IUser user, CMSNode node)
|
||||
{
|
||||
DeletePermissions(user, node, true);
|
||||
}
|
||||
|
||||
internal static void DeletePermissions(User user, CMSNode node, bool raiseEvents)
|
||||
internal static void DeletePermissions(IUser user, CMSNode node, bool raiseEvents)
|
||||
{
|
||||
ApplicationContext.Current.Services.UserService.RemoveUserPermissions(user.Id, node.Id);
|
||||
if (raiseEvents)
|
||||
@@ -117,7 +117,7 @@ namespace umbraco.BusinessLogic
|
||||
/// deletes all permissions for the user
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
public static void DeletePermissions(User user)
|
||||
public static void DeletePermissions(IUser user)
|
||||
{
|
||||
ApplicationContext.Current.Services.UserService.RemoveUserPermissions(user.Id);
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace umbraco.BusinessLogic
|
||||
OnDeleted(new UserPermission(null, node, null), new DeleteEventArgs());
|
||||
}
|
||||
|
||||
public static void UpdateCruds(User user, CMSNode node, string permissions)
|
||||
public static void UpdateCruds(IUser user, CMSNode node, string permissions)
|
||||
{
|
||||
ApplicationContext.Current.Services.UserService.ReplaceUserPermissions(
|
||||
user.Id,
|
||||
@@ -201,14 +201,14 @@ namespace umbraco.BusinessLogic
|
||||
_nodeIds = nodeIds.ToArray();
|
||||
}
|
||||
|
||||
internal UserPermission(User user, CMSNode node, char[] permissionKeys)
|
||||
internal UserPermission(IUser user, CMSNode node, char[] permissionKeys)
|
||||
{
|
||||
User = user;
|
||||
Nodes = new[] { node };
|
||||
PermissionKeys = permissionKeys;
|
||||
}
|
||||
|
||||
internal UserPermission(User user, IEnumerable<CMSNode> nodes, char[] permissionKeys)
|
||||
internal UserPermission(IUser user, IEnumerable<CMSNode> nodes, char[] permissionKeys)
|
||||
{
|
||||
User = user;
|
||||
Nodes = nodes;
|
||||
@@ -247,7 +247,7 @@ namespace umbraco.BusinessLogic
|
||||
}
|
||||
}
|
||||
|
||||
internal User User { get; private set; }
|
||||
internal IUser User { get; private set; }
|
||||
internal IEnumerable<CMSNode> Nodes { get; private set; }
|
||||
internal char[] PermissionKeys { get; private set; }
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.media
|
||||
{
|
||||
@@ -63,17 +64,10 @@ namespace umbraco.cms.businesslogic.media
|
||||
/// -
|
||||
/// </summary>
|
||||
public static Guid _objectType = new Guid(Constants.ObjectTypes.Media);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Media
|
||||
/// </summary>
|
||||
/// <param name="Name">The name of the media</param>
|
||||
/// <param name="dct">The type of the media</param>
|
||||
/// <param name="u">The user creating the media</param>
|
||||
/// <param name="ParentId">The id of the folder under which the media is created</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.CreateMedia()", false)]
|
||||
public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
|
||||
public static Media MakeNew(string Name, MediaType dct, IUser u, int ParentId)
|
||||
{
|
||||
var e = new NewEventArgs();
|
||||
OnNewing(e);
|
||||
|
||||
@@ -3,7 +3,9 @@ using System.Collections.Generic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using System.Linq;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace umbraco.cms.businesslogic.media
|
||||
{
|
||||
@@ -87,19 +89,13 @@ namespace umbraco.cms.businesslogic.media
|
||||
return mediaTypes.OrderBy(x => x.Name).Select(x => new MediaType(x));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new Mediatype
|
||||
/// </summary>
|
||||
/// <param name="u">The Umbraco user context</param>
|
||||
/// <param name="Text">The name of the MediaType</param>
|
||||
/// <returns>The new MediaType</returns>
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Models.MediaType and Umbraco.Core.Services.ContentTypeService.Save()", false)]
|
||||
public static MediaType MakeNew(User u, string Text)
|
||||
public static MediaType MakeNew(IUser u, string Text)
|
||||
{
|
||||
return MakeNew(u, Text, -1);
|
||||
}
|
||||
|
||||
internal static MediaType MakeNew(User u, string text, int parentId)
|
||||
internal static MediaType MakeNew(IUser u, string text, int parentId)
|
||||
{
|
||||
var mediaType = new Umbraco.Core.Models.MediaType(parentId) { Name = text, Alias = text, CreatorId = u.Id, Thumbnail = "icon-folder", Icon = "icon-folder" };
|
||||
ApplicationContext.Current.Services.ContentTypeService.Save(mediaType, u.Id);
|
||||
@@ -123,9 +119,9 @@ namespace umbraco.cms.businesslogic.media
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
var current = User.GetCurrent();
|
||||
int userId = current == null ? 0 : current.Id;
|
||||
ApplicationContext.Current.Services.ContentTypeService.Save(MediaTypeItem, userId);
|
||||
var current = Thread.CurrentPrincipal != null ? Thread.CurrentPrincipal.Identity as UmbracoBackOfficeIdentity : null;
|
||||
var userId = current == null ? Attempt<int>.Fail() : current.Id.TryConvertTo<int>();
|
||||
ApplicationContext.Current.Services.ContentTypeService.Save(MediaTypeItem, userId.Success ? userId.Result : 0);
|
||||
|
||||
base.Save();
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
using System.Web.Security;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace umbraco.cms.businesslogic.member
|
||||
@@ -185,7 +185,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <param name="mbt">Member type</param>
|
||||
/// <param name="u">The umbraco usercontext</param>
|
||||
/// <returns>The new member</returns>
|
||||
public static Member MakeNew(string Name, MemberType mbt, User u)
|
||||
public static Member MakeNew(string Name, MemberType mbt, IUser u)
|
||||
{
|
||||
return MakeNew(Name, "", "", mbt, u);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <param name="u">The umbraco usercontext</param>
|
||||
/// <param name="Email">The email of the user</param>
|
||||
/// <returns>The new member</returns>
|
||||
public static Member MakeNew(string Name, string Email, MemberType mbt, User u)
|
||||
public static Member MakeNew(string Name, string Email, MemberType mbt, IUser u)
|
||||
{
|
||||
return MakeNew(Name, "", Email, mbt, u);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <param name="u">The umbraco usercontext</param>
|
||||
/// <param name="Email">The email of the user</param>
|
||||
/// <returns>The new member</returns>
|
||||
public static Member MakeNew(string Name, string LoginName, string Email, MemberType mbt, User u)
|
||||
public static Member MakeNew(string Name, string LoginName, string Email, MemberType mbt, IUser u)
|
||||
{
|
||||
if (mbt == null) throw new ArgumentNullException("mbt");
|
||||
var loginName = (string.IsNullOrEmpty(LoginName) == false) ? LoginName : Name;
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using umbraco.DataLayer;
|
||||
using System.Collections;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.member
|
||||
{
|
||||
@@ -160,7 +157,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <param name="Name">The name of the MemberGroup</param>
|
||||
/// <param name="u">The creator of the MemberGroup</param>
|
||||
/// <returns>The new MemberGroup</returns>
|
||||
public static MemberGroup MakeNew(string Name, BusinessLogic.User u)
|
||||
public static MemberGroup MakeNew(string Name, IUser u)
|
||||
{
|
||||
var group = new global::Umbraco.Core.Models.MemberGroup {Name = Name};
|
||||
ApplicationContext.Current.Services.MemberGroupService.Save(group);
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Logging;
|
||||
using System.Linq;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using PropertyType = umbraco.cms.businesslogic.propertytype.PropertyType;
|
||||
|
||||
namespace umbraco.cms.businesslogic.member
|
||||
@@ -154,7 +151,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// </summary>
|
||||
/// <param name="Text">The name of the MemberType</param>
|
||||
/// <param name="u">Creator of the MemberType</param>
|
||||
public static MemberType MakeNew(User u, string Text)
|
||||
public static MemberType MakeNew(IUser u, string Text)
|
||||
{
|
||||
var alias = Text.ToSafeAliasWithForcingCheck();
|
||||
//special case, if it stars with an underscore, we have to re-add it for member types
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using umbraco.DataLayer;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.task
|
||||
{
|
||||
@@ -83,15 +78,15 @@ namespace umbraco.cms.businesslogic.task
|
||||
}
|
||||
|
||||
|
||||
private User _parentUser;
|
||||
private IUser _parentUser;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parent user.
|
||||
/// </summary>
|
||||
/// <value>The parent user.</value>
|
||||
public User ParentUser
|
||||
public IUser ParentUser
|
||||
{
|
||||
get { return _parentUser ?? (_parentUser = new User(TaskEntity.OwnerUserId)); }
|
||||
get { return _parentUser ?? (_parentUser = ApplicationContext.Current.Services.UserService.GetUserById(TaskEntity.OwnerUserId)); }
|
||||
set
|
||||
{
|
||||
_parentUser = value;
|
||||
@@ -119,15 +114,15 @@ namespace umbraco.cms.businesslogic.task
|
||||
set { TaskEntity.CreateDate = value; }
|
||||
}
|
||||
|
||||
private User _user;
|
||||
private IUser _user;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user.
|
||||
/// </summary>
|
||||
/// <value>The user.</value>
|
||||
public User User
|
||||
public IUser User
|
||||
{
|
||||
get { return _user ?? (_user = new User(TaskEntity.AssigneeUserId)); }
|
||||
get { return _user ?? (_user = ApplicationContext.Current.Services.UserService.GetUserById(TaskEntity.AssigneeUserId)); }
|
||||
set
|
||||
{
|
||||
_user = value;
|
||||
@@ -238,7 +233,7 @@ namespace umbraco.cms.businesslogic.task
|
||||
/// <param name="User">The User who have the tasks assigned</param>
|
||||
/// <param name="IncludeClosed">If true both open and closed tasks will be returned</param>
|
||||
/// <returns>A collections of tasks</returns>
|
||||
public static Tasks GetTasks(User User, bool IncludeClosed)
|
||||
public static Tasks GetTasks(IUser User, bool IncludeClosed)
|
||||
{
|
||||
var result = new Tasks();
|
||||
var tasks = ApplicationContext.Current.Services.TaskService.GetTasks(assignedUser:User.Id, includeClosed:IncludeClosed);
|
||||
@@ -256,7 +251,7 @@ namespace umbraco.cms.businesslogic.task
|
||||
/// <param name="User">The User who have the tasks assigned</param>
|
||||
/// <param name="IncludeClosed">If true both open and closed tasks will be returned</param>
|
||||
/// <returns>A collections of tasks</returns>
|
||||
public static Tasks GetOwnedTasks(User User, bool IncludeClosed)
|
||||
public static Tasks GetOwnedTasks(IUser User, bool IncludeClosed)
|
||||
{
|
||||
var result = new Tasks();
|
||||
var tasks = ApplicationContext.Current.Services.TaskService.GetTasks(ownerUser:User.Id, includeClosed: IncludeClosed);
|
||||
|
||||
@@ -9,8 +9,8 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.template
|
||||
{
|
||||
@@ -278,22 +278,22 @@ namespace umbraco.cms.businesslogic.template
|
||||
return DocumentType.GetAllAsList().Where(x => x.allowedTemplates.Select(t => t.Id).Contains(this.Id));
|
||||
}
|
||||
|
||||
public static Template MakeNew(string Name, User u, Template master)
|
||||
public static Template MakeNew(string Name, IUser u, Template master)
|
||||
{
|
||||
return MakeNew(Name, u, master, null);
|
||||
}
|
||||
|
||||
private static Template MakeNew(string name, User u, string design)
|
||||
private static Template MakeNew(string name, IUser u, string design)
|
||||
{
|
||||
return MakeNew(name, u, null, design);
|
||||
}
|
||||
|
||||
public static Template MakeNew(string name, User u)
|
||||
public static Template MakeNew(string name, IUser u)
|
||||
{
|
||||
return MakeNew(name, u, design: null);
|
||||
}
|
||||
|
||||
private static Template MakeNew(string name, User u, Template master, string design)
|
||||
private static Template MakeNew(string name, IUser u, Template master, string design)
|
||||
{
|
||||
var foundMaster = master == null ? null : ApplicationContext.Current.Services.FileService.GetTemplate(master.Id);
|
||||
var template = ApplicationContext.Current.Services.FileService.CreateTemplateWithIdentity(name, design, foundMaster, u.Id);
|
||||
@@ -522,7 +522,7 @@ namespace umbraco.cms.businesslogic.template
|
||||
return found == null ? null : new Template(found);
|
||||
}
|
||||
|
||||
public static Template Import(XmlNode n, User u)
|
||||
public static Template Import(XmlNode n, IUser u)
|
||||
{
|
||||
var element = System.Xml.Linq.XElement.Parse(n.OuterXml);
|
||||
var templates = ApplicationContext.Current.Services.PackagingService.ImportTemplates(element, u.Id);
|
||||
|
||||
@@ -5,8 +5,8 @@ using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
@@ -105,8 +105,8 @@ namespace umbraco.cms.businesslogic.web
|
||||
private int _template;
|
||||
private bool _published;
|
||||
private XmlNode _xml;
|
||||
private User _creator;
|
||||
private User _writer;
|
||||
private IUser _creator;
|
||||
private IUser _writer;
|
||||
private int? _writerId;
|
||||
private readonly bool _optimizedMode;
|
||||
protected internal IContent ContentEntity;
|
||||
@@ -272,7 +272,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
/// Gets the user who created the document.
|
||||
/// </summary>
|
||||
/// <value>The creator.</value>
|
||||
public User Creator
|
||||
public IUser Creator
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -288,7 +288,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
/// Gets the writer.
|
||||
/// </summary>
|
||||
/// <value>The writer.</value>
|
||||
public User Writer
|
||||
public IUser Writer
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -298,7 +298,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
throw new NullReferenceException("Writer ID has not been specified for this document");
|
||||
}
|
||||
_writer = User.GetUser(_writerId.Value);
|
||||
_writer = ApplicationContext.Current.Services.UserService.GetUserById(_writerId.Value);
|
||||
}
|
||||
return _writer;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)]
|
||||
public bool PublishWithChildrenWithResult(User u)
|
||||
public bool PublishWithChildrenWithResult(IUser u)
|
||||
{
|
||||
var result = ApplicationContext.Current.Services.ContentService.PublishWithChildrenWithStatus(ContentEntity, u.Id, true);
|
||||
//This used to just return false only when the parent content failed, otherwise would always return true so we'll
|
||||
@@ -553,8 +553,8 @@ namespace umbraco.cms.businesslogic.web
|
||||
Version = ContentEntity.Version;
|
||||
|
||||
//Setting private properties from IContent replacing Document.setupNode()
|
||||
_creator = User.GetUser(ContentEntity.CreatorId);
|
||||
_writer = User.GetUser(ContentEntity.WriterId);
|
||||
_creator = ApplicationContext.Current.Services.UserService.GetUserById(ContentEntity.CreatorId);
|
||||
_writer = ApplicationContext.Current.Services.UserService.GetUserById(ContentEntity.WriterId);
|
||||
_updated = ContentEntity.UpdateDate;
|
||||
|
||||
if (ContentEntity.Template != null)
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.DataLayer;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
@@ -83,7 +82,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
}
|
||||
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Models.ContentType and Umbraco.Core.Services.ContentTypeService.Save()", false)]
|
||||
public static DocumentType MakeNew(User u, string Text)
|
||||
public static DocumentType MakeNew(IUser u, string Text)
|
||||
{
|
||||
var contentType = new Umbraco.Core.Models.ContentType(-1) { Name = Text, Alias = Text, CreatorId = u.Id, Thumbnail = "icon-folder", Icon = "icon-folder" };
|
||||
ApplicationContext.Current.Services.ContentTypeService.Save(contentType, u.Id);
|
||||
@@ -410,9 +409,9 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
var current = User.GetCurrent();
|
||||
int userId = current == null ? 0 : current.Id;
|
||||
ApplicationContext.Current.Services.ContentTypeService.Save(ContentType, userId);
|
||||
var current = Thread.CurrentPrincipal != null ? Thread.CurrentPrincipal.Identity as UmbracoBackOfficeIdentity : null;
|
||||
var userId = current == null ? Attempt<int>.Fail() : current.Id.TryConvertTo<int>();
|
||||
ApplicationContext.Current.Services.ContentTypeService.Save(ContentType, userId.Success ? userId.Result : 0);
|
||||
|
||||
base.Save();
|
||||
FireAfterSave(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
@@ -11,7 +11,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
private Guid _version;
|
||||
private DateTime _date;
|
||||
private string _text;
|
||||
private User _user;
|
||||
private IUser _user;
|
||||
|
||||
/// <summary>
|
||||
/// The unique id of the version
|
||||
@@ -40,7 +40,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
/// <summary>
|
||||
/// The user which created the version
|
||||
/// </summary>
|
||||
public User User
|
||||
public IUser User
|
||||
{
|
||||
get { return _user; }
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
/// <param name="Date">Version createdate</param>
|
||||
/// <param name="Text">Version name</param>
|
||||
/// <param name="User">Creator</param>
|
||||
public DocumentVersionList(Guid Version, DateTime Date, string Text, User User)
|
||||
public DocumentVersionList(Guid Version, DateTime Date, string Text, IUser User)
|
||||
{
|
||||
_version = Version;
|
||||
_date = Date;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Xml;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
@@ -128,7 +129,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
throw new NotSupportedException("The legacy " + typeof(T) + " API is no longer functional for retrieving stylesheets based on an integer ID. Stylesheets are no longer persisted in database tables. Use the new Umbraco.Core.Services.IFileSystem APIs instead of working with Umbraco stylesheets.");
|
||||
}
|
||||
|
||||
public static StyleSheet MakeNew(BusinessLogic.User user, string Text, string FileName, string Content)
|
||||
public static StyleSheet MakeNew(IUser user, string Text, string FileName, string Content)
|
||||
{
|
||||
|
||||
if (FileName.IsNullOrWhiteSpace())
|
||||
@@ -167,7 +168,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
return retval;
|
||||
}
|
||||
|
||||
public StylesheetProperty AddProperty(string Alias, BusinessLogic.User u)
|
||||
public StylesheetProperty AddProperty(string Alias, IUser u)
|
||||
{
|
||||
return StylesheetProperty.MakeNew(Alias, this, u);
|
||||
}
|
||||
@@ -216,7 +217,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
return new StyleSheet(found);
|
||||
}
|
||||
|
||||
public static StyleSheet Import(XmlNode n, umbraco.BusinessLogic.User u)
|
||||
public static StyleSheet Import(XmlNode n, IUser u)
|
||||
{
|
||||
string stylesheetName = XmlHelper.GetNodeValue(n.SelectSingleNode("Name"));
|
||||
StyleSheet s = GetByName(stylesheetName);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
@@ -80,7 +81,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
set { StylesheetProp.Value = value; }
|
||||
}
|
||||
|
||||
public static StylesheetProperty MakeNew(string Text, StyleSheet sheet, BusinessLogic.User user)
|
||||
public static StylesheetProperty MakeNew(string Text, StyleSheet sheet, IUser user)
|
||||
{
|
||||
//we need to create it with a temp place holder!
|
||||
var prop = new Umbraco.Core.Models.StylesheetProperty(Text, "#" + Text.ToSafeAlias(), "");
|
||||
|
||||
@@ -3,6 +3,7 @@ using Umbraco.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
@@ -14,6 +15,7 @@ using Umbraco.Core.Models.Rdbms;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.interfaces;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace umbraco.cms.businesslogic.workflow
|
||||
{
|
||||
@@ -53,19 +55,27 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
/// <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)
|
||||
public static void GetNotifications(CMSNode node, IUser user, IAction action)
|
||||
{
|
||||
User[] allUsers = User.getAll();
|
||||
foreach (User u in allUsers)
|
||||
|
||||
int totalUsers;
|
||||
var allUsers = ApplicationContext.Current.Services.UserService.GetAll(0, int.MaxValue, out totalUsers);
|
||||
foreach (var u in allUsers)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (u.Disabled == false && u.GetNotifications(node.Path).IndexOf(action.Letter.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal) > -1)
|
||||
if (u.IsApproved)
|
||||
{
|
||||
LogHelper.Debug<Notification>(string.Format("Notification about {0} sent to {1} ({2})",
|
||||
ApplicationContext.Current.Services.TextService.Localize("actions/" + action.Alias, u.UserEntity.GetUserCulture(ApplicationContext.Current.Services.TextService)),
|
||||
//TODO: N+1 !!!!
|
||||
var notifications = ApplicationContext.Current.Services.NotificationService.GetUserNotifications(u, node.Path);
|
||||
|
||||
if (notifications.Any(x => x.Action.InvariantEquals(action.Letter.ToString(CultureInfo.InvariantCulture))))
|
||||
{
|
||||
LogHelper.Debug<Notification>(string.Format("Notification about {0} sent to {1} ({2})",
|
||||
ApplicationContext.Current.Services.TextService.Localize("actions/" + action.Alias, u.GetUserCulture(ApplicationContext.Current.Services.TextService)),
|
||||
u.Name, u.Email));
|
||||
SendNotification(user, u, (Document)node, action);
|
||||
SendNotification(user, u, (Document)node, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception notifyExp)
|
||||
@@ -76,7 +86,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(IUser performingUser, IUser mailingUser, Document documentObject, IAction action)
|
||||
{
|
||||
var nService = ApplicationContext.Current.Services.NotificationService;
|
||||
var pUser = ApplicationContext.Current.Services.UserService.GetUserById(performingUser.Id);
|
||||
@@ -84,10 +94,10 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
nService.SendNotifications(
|
||||
pUser, documentObject.ContentEntity, action.Letter.ToString(CultureInfo.InvariantCulture), ApplicationContext.Current.Services.TextService.Localize(action.Alias),
|
||||
new HttpContextWrapper(HttpContext.Current),
|
||||
(user, strings) => ApplicationContext.Current.Services.TextService.Localize("notifications/mailSubject", mailingUser.UserEntity.GetUserCulture(ApplicationContext.Current.Services.TextService), strings),
|
||||
(user, strings) => ApplicationContext.Current.Services.TextService.Localize("notifications/mailSubject", mailingUser.GetUserCulture(ApplicationContext.Current.Services.TextService), strings),
|
||||
(user, strings) => UmbracoConfig.For.UmbracoSettings().Content.DisableHtmlEmail
|
||||
? ApplicationContext.Current.Services.TextService.Localize("notifications/mailBody", mailingUser.UserEntity.GetUserCulture(ApplicationContext.Current.Services.TextService), strings)
|
||||
: ApplicationContext.Current.Services.TextService.Localize("notifications/mailBodyHtml", mailingUser.UserEntity.GetUserCulture(ApplicationContext.Current.Services.TextService), strings));
|
||||
? ApplicationContext.Current.Services.TextService.Localize("notifications/mailBody", mailingUser.GetUserCulture(ApplicationContext.Current.Services.TextService), strings)
|
||||
: ApplicationContext.Current.Services.TextService.Localize("notifications/mailBodyHtml", mailingUser.GetUserCulture(ApplicationContext.Current.Services.TextService), strings));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,7 +105,7 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Notification> GetUserNotifications(User user)
|
||||
public static IEnumerable<Notification> GetUserNotifications(IUser user)
|
||||
{
|
||||
var items = new List<Notification>();
|
||||
var dtos = ApplicationContext.Current.DatabaseContext.Database.Fetch<User2NodeNotifyDto>(
|
||||
@@ -152,7 +162,7 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
/// Delete notifications by user
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
public static void DeleteNotifications(User user)
|
||||
public static void DeleteNotifications(IUser user)
|
||||
{
|
||||
// delete all settings on the node for this node id
|
||||
ApplicationContext.Current.DatabaseContext.Database.Delete<User2NodeNotifyDto>("WHERE userId = @userId",
|
||||
@@ -164,7 +174,7 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="node"></param>
|
||||
public static void DeleteNotifications(User user, CMSNode node)
|
||||
public static void DeleteNotifications(IUser user, CMSNode node)
|
||||
{
|
||||
// delete all settings on the node for this user
|
||||
ApplicationContext.Current.DatabaseContext.Database.Delete<User2NodeNotifyDto>(
|
||||
@@ -178,7 +188,7 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
/// <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(IUser 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",
|
||||
@@ -202,7 +212,7 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
/// <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(IUser user, CMSNode node, string notifications)
|
||||
{
|
||||
// delete all settings on the node for this user
|
||||
DeleteNotifications(user, node);
|
||||
|
||||
Reference in New Issue
Block a user