diff --git a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js index d33a2e5407..98a9987019 100644 --- a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js +++ b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js @@ -80,7 +80,8 @@ Umbraco.Sys.registerNamespace("Umbraco.Application"); mainWindow: function() { return top; }, - mainTree: function() { + mainTree: function () { + var injector = getRootInjector(); var navService = injector.get("navigationService"); var appState = injector.get("appState"); @@ -177,23 +178,33 @@ Umbraco.Sys.registerNamespace("Umbraco.Application"); appActions: function() { var injector = getRootInjector(); var navService = injector.get("navigationService"); - - var _actions = {}; - _actions.openDashboard = function(section){ - navService.changeSection(section); + var localizationService = injector.get("localizationService"); + var userResource = injector.get("userResource"); + //var appState = injector.get("appState"); + var angularHelper = injector.get("angularHelper"); + var $rootScope = injector.get("$rootScope"); + + var actions = { + openDashboard : function(section){ + navService.changeSection(section); + }, + actionDisable: function () { + localizationService.localize("defaultdialogs_confirmdisable").then(function (txtConfirmDisable) { + var currentMenuNode = UmbClientMgr.mainTree().getActionNode(); + if (currentMenuNode) { + if (confirm(txtConfirmDisable + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) { + angularHelper.safeApply($rootScope, function () { + userResource.disableUser(currentMenuNode.nodeId).then(function () { + UmbClientMgr.mainTree().syncTree("-1," + currentMenuNode.nodeId, true); + }); + }); + } + } + }); + } }; - return _actions; - //throw "Not implemented!"; - - ////if the main window has no actions, we'll create some - //if (this._appActions == null) { - // if (typeof this.mainWindow().appActions == 'undefined') { - // this._appActions = new Umbraco.Application.Actions(); - // } - // else this._appActions = this.mainWindow().appActions; - //} - //return this._appActions; + return actions; }, uiKeys: function() { diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/user.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/user.resource.js new file mode 100644 index 0000000000..0c6f851eb0 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/resources/user.resource.js @@ -0,0 +1,25 @@ +/** + * @ngdoc service + * @name umbraco.resources.userResource + **/ +function userResource($q, $http, umbDataFormatter, umbRequestHelper) { + + return { + + disableUser: function (userId) { + + if (!userId) { + throw "userId not specified"; + } + + return umbRequestHelper.resourcePromise( + $http.post( + umbRequestHelper.getApiUrl( + "userApiBaseUrl", + "PostDisableUser", [{ userId: userId }])), + 'Failed to disable the user ' + userId); + } + }; +} + +angular.module('umbraco.resources').factory('userResource', userResource); diff --git a/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js b/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js index 3b8b983b5e..46b7a15e48 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js +++ b/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js @@ -409,7 +409,7 @@ Umbraco.Application.Actions = function() { _this._debug("actionDelete: Raising public error event"); //raise public error event jQuery(window.top).trigger("publicError", [error]); - }) + }); } } diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 9ff5bd4af8..10b6989328 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -116,6 +116,10 @@ namespace Umbraco.Web.Editors "embedApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl( controller => controller.GetEmbed("",0,0)) }, + { + "userApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl( + controller => controller.PostDisableUser(0)) + }, { "contentApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl( controller => controller.PostSave(null)) diff --git a/src/Umbraco.Web/Editors/UserController.cs b/src/Umbraco.Web/Editors/UserController.cs new file mode 100644 index 0000000000..363940b924 --- /dev/null +++ b/src/Umbraco.Web/Editors/UserController.cs @@ -0,0 +1,46 @@ +using System.Net; +using System.Web.Http; +using Umbraco.Web.Mvc; +using Umbraco.Web.WebApi.Filters; +using Constants = Umbraco.Core.Constants; + +namespace Umbraco.Web.Editors +{ + [PluginController("UmbracoApi")] + [UmbracoApplicationAuthorize(Constants.Applications.Users)] + public class UserController : UmbracoAuthorizedJsonController + { + /// + /// Constructor + /// + public UserController() + : this(UmbracoContext.Current) + { + } + + /// + /// Constructor + /// + /// + public UserController(UmbracoContext umbracoContext) + : base(umbracoContext) + { + } + + /// + /// Disables the user with the given user id + /// + /// + public bool PostDisableUser([FromUri]int userId) + { + var user = Services.UserService.GetUserById(userId); + if (user == null) + { + throw new HttpResponseException(HttpStatusCode.NotFound); + } + //without the permanent flag, this will just disable + Services.UserService.Delete(user); + return true; + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs index 3ded77dada..41f4ae232a 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs @@ -365,6 +365,11 @@ namespace Umbraco.Web.Trees node.AdditionalData.Add("treeAlias", xmlTreeNode.TreeType); } + foreach (var appliedClass in xmlTreeNode.Style.AppliedClasses) + { + node.CssClasses.Add(appliedClass); + } + //This is a special case scenario, we know that content/media works based on the normal Belle routing/editing so we'll ensure we don't // pass in the legacy JS handler so we do it the new way, for all other trees (Currently, this is a WIP), we'll render // the legacy js callback,. diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index e11925ca33..7d92e921b1 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -307,6 +307,7 @@ + diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/XmlTree.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/XmlTree.cs index afd56dd26d..a224f1f048 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/XmlTree.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/XmlTree.cs @@ -381,9 +381,9 @@ namespace umbraco.cms.presentation.Trees AppliedClasses = new List(); } - private const string DimNodeCssClass = "dim"; - private const string HighlightNodeCssClass = "overlay-new"; - private const string SecureNodeCssClass = "overlay-protect"; + private const string DimNodeCssClass = "not-published"; + private const string HighlightNodeCssClass = "has-unpublished-version"; + private const string SecureNodeCssClass = "protected"; internal List AppliedClasses { get; private set; }