Revert "U4 10147 - Bypass User Security option in pickers (#2441)"

This reverts commit cc9a7ff942.

# Conflicts:
#	src/Umbraco.Web/Editors/ContentController.cs
#	src/Umbraco.Web/Editors/EntityController.cs
#	src/Umbraco.Web/Search/UmbracoTreeSearcher.cs
This commit is contained in:
Sebastiaan Janssen
2019-06-18 13:07:40 +02:00
parent cff5046a9e
commit 994c6eed50
35 changed files with 1554 additions and 1858 deletions

View File

@@ -12,7 +12,6 @@ function treeSearchBox(localizationService, searchService, $q) {
searchFromName: "@",
showSearch: "@",
section: "@",
ignoreUserStartNodes: "@",
hideSearchCallback: "=",
searchCallback: "="
},
@@ -35,7 +34,6 @@ function treeSearchBox(localizationService, searchService, $q) {
scope.showSearch = "false";
}
//used to cancel any request in progress if another one needs to take it's place
var canceler = null;
@@ -62,11 +60,6 @@ function treeSearchBox(localizationService, searchService, $q) {
searchArgs["searchFrom"] = scope.searchFromId;
}
//append ignoreUserStartNodes value if there is one
if (scope.ignoreUserStartNodes) {
searchArgs["ignoreUserStartNodes"] = scope.ignoreUserStartNodes;
}
searcher(searchArgs).then(function (data) {
scope.searchCallback(data);
//set back to null so it can be re-created

View File

@@ -292,29 +292,14 @@ function entityResource($q, $http, umbRequestHelper) {
* @returns {Promise} resourcePromise object containing the entity.
*
*/
getAncestors: function (id, type, options) {
var defaults = {
ignoreUserStartNodes: false
};
if (options === undefined) {
options = {};
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
getAncestors: function (id, type) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"GetAncestors",
[
{ id: id },
{ type: type },
{ ignoreUserStartNodes: options.ignoreUserStartNodes }
])),
'Failed to retrieve ancestor data for id ' + id);
[{id: id}, {type: type}])),
'Failed to retrieve ancestor data for id ' + id);
},
/**
@@ -446,8 +431,7 @@ function entityResource($q, $http, umbRequestHelper) {
pageNumber: 1,
filter: '',
orderDirection: "Ascending",
orderBy: "SortOrder",
ignoreUserStartNodes: false
orderBy: "SortOrder"
};
if (options === undefined) {
options = {};
@@ -476,8 +460,7 @@ function entityResource($q, $http, umbRequestHelper) {
pageSize: options.pageSize,
orderBy: options.orderBy,
orderDirection: options.orderDirection,
filter: encodeURIComponent(options.filter),
ignoreUserStartNodes: options.ignoreUserStartNodes
filter: encodeURIComponent(options.filter)
}
)),
'Failed to retrieve child data for id ' + parentId);
@@ -505,19 +488,12 @@ function entityResource($q, $http, umbRequestHelper) {
* @returns {Promise} resourcePromise object containing the entity array.
*
*/
search: function (query, type, options, canceler) {
search: function (query, type, searchFrom, canceler) {
var defaults = {
searchFrom: null,
ignoreUserStartNodes: false
};
if (options === undefined) {
options = {};
var args = [{ query: query }, { type: type }];
if (searchFrom) {
args.push({ searchFrom: searchFrom });
}
//overwrite the defaults if there are any specified
angular.extend(defaults, options);
//now copy back to the options we will use
options = defaults;
var httpConfig = {};
if (canceler) {
@@ -529,12 +505,7 @@ function entityResource($q, $http, umbRequestHelper) {
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"Search",
{
query: query,
type: type,
searchFrom: options.searchFrom,
ignoreUserStartNodes: options.ignoreUserStartNodes
}),
args),
httpConfig),
'Failed to retrieve entity data for query ' + query);
},

View File

@@ -329,8 +329,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
filter: '',
orderDirection: "Ascending",
orderBy: "SortOrder",
orderBySystemField: true,
ignoreUserStartNodes: false
orderBySystemField: true
};
if (options === undefined) {
options = {};
@@ -373,8 +372,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
{ orderBy: options.orderBy },
{ orderDirection: options.orderDirection },
{ orderBySystemField: toBool(options.orderBySystemField) },
{ filter: options.filter },
{ ignoreUserStartNodes: options.ignoreUserStartNodes }
{ filter: options.filter }
])),
'Failed to retrieve children for media item ' + parentId);
},

View File

@@ -42,11 +42,7 @@ angular.module('umbraco.services')
throw "args.term is required";
}
var options = {
searchFrom: args.searchFrom
}
return entityResource.search(args.term, "Member", options).then(function (data) {
return entityResource.search(args.term, "Member", args.searchFrom).then(function (data) {
_.each(data, function (item) {
searchResultFormatter.configureMemberResult(item);
});
@@ -71,12 +67,7 @@ angular.module('umbraco.services')
throw "args.term is required";
}
var options = {
searchFrom: args.searchFrom,
ignoreUserStartNodes: args.ignoreUserStartNodes
}
return entityResource.search(args.term, "Document", options, args.canceler).then(function (data) {
return entityResource.search(args.term, "Document", args.searchFrom, args.canceler).then(function (data) {
_.each(data, function (item) {
searchResultFormatter.configureContentResult(item);
});
@@ -101,12 +92,7 @@ angular.module('umbraco.services')
throw "args.term is required";
}
var options = {
searchFrom: args.searchFrom,
ignoreUserStartNodes: args.ignoreUserStartNodes
}
return entityResource.search(args.term, "Media", options).then(function (data) {
return entityResource.search(args.term, "Media", args.searchFrom).then(function (data) {
_.each(data, function (item) {
searchResultFormatter.configureMediaResult(item);
});
@@ -171,4 +157,4 @@ angular.module('umbraco.services')
var currentSection = sectionAlias;
}
};
});
});

View File

@@ -9,7 +9,6 @@
search-from-id="{{searchInfo.searchFromId}}"
search-from-name="{{searchInfo.searchFromName}}"
show-search="{{searchInfo.showSearch}}"
ignore-user-startnodes="{{searchInfo.ignoreUserStartNodes}}"
section="content">
</umb-tree-search-box>
</div>
@@ -46,4 +45,4 @@
on-close="closeMiniListView()">
</umb-mini-list-view>
</div>
</div>

View File

@@ -1,58 +1,57 @@
//used for the media picker dialog
angular.module("umbraco").controller("Umbraco.Overlays.LinkPickerController",
function ($scope, eventsService, dialogService, entityResource, contentResource, mediaHelper, userService, localizationService, tinyMceService) {
var dialogOptions = $scope.model;
function ($scope, eventsService, dialogService, entityResource, contentResource, mediaHelper, userService, localizationService, tinyMceService) {
var dialogOptions = $scope.model;
var searchText = "Search...";
localizationService.localize("general_search").then(function (value) {
searchText = value + "...";
});
var searchText = "Search...";
localizationService.localize("general_search").then(function (value) {
searchText = value + "...";
});
if (!$scope.model.title) {
$scope.model.title = localizationService.localize("defaultdialogs_selectLink");
}
if (!$scope.model.title) {
$scope.model.title = localizationService.localize("defaultdialogs_selectLink");
}
$scope.dialogTreeEventHandler = $({});
$scope.model.target = {};
$scope.searchInfo = {
searchFromId: null,
searchFromName: null,
showSearch: false,
ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes,
results: [],
selectedSearchResults: []
};
$scope.customTreeParams = dialogOptions.ignoreUserStartNodes ? "ignoreUserStartNodes=" + dialogOptions.ignoreUserStartNodes : "";
$scope.showTarget = $scope.model.hideTarget !== true;
$scope.dialogTreeEventHandler = $({});
$scope.model.target = {};
$scope.searchInfo = {
searchFromId: null,
searchFromName: null,
showSearch: false,
results: [],
selectedSearchResults: []
};
if (dialogOptions.currentTarget) {
// clone the current target so we don't accidentally update the caller's model while manipulating $scope.model.target
$scope.model.target = angular.copy(dialogOptions.currentTarget);
//if we have a node ID, we fetch the current node to build the form data
if ($scope.model.target.id || $scope.model.target.udi) {
$scope.showTarget = $scope.model.hideTarget !== true;
//will be either a udi or an int
var id = $scope.model.target.udi ? $scope.model.target.udi : $scope.model.target.id;
if (dialogOptions.currentTarget) {
// clone the current target so we don't accidentally update the caller's model while manipulating $scope.model.target
$scope.model.target = angular.copy(dialogOptions.currentTarget);
//if we have a node ID, we fetch the current node to build the form data
if ($scope.model.target.id || $scope.model.target.udi) {
// is it a content link?
if (!$scope.model.target.isMedia) {
// get the content path
entityResource.getPath(id, "Document").then(function (path) {
//now sync the tree to this path
$scope.dialogTreeEventHandler.syncTree({
path: path,
tree: "content"
});
});
//will be either a udi or an int
var id = $scope.model.target.udi ? $scope.model.target.udi : $scope.model.target.id;
// if a link exists, get the properties to build the anchor name list
contentResource.getById(id, { ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes }).then(function (resp) {
$scope.model.target.url = resp.urls[0];
$scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
});
}
} else if ($scope.model.target.url.length) {
// a url but no id/udi indicates an external link - trim the url to remove the anchor/qs
// is it a content link?
if (!$scope.model.target.isMedia) {
// get the content path
entityResource.getPath(id, "Document").then(function(path) {
//now sync the tree to this path
$scope.dialogTreeEventHandler.syncTree({
path: path,
tree: "content"
});
});
// get the content properties to build the anchor name list
contentResource.getById(id).then(function (resp) {
$scope.model.target.url = resp.urls[0];
$scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
});
}
} else if ($scope.model.target.url.length) {
// a url but no id/udi indicates an external link - trim the url to remove the anchor/qs
// only do the substring if there's a # or a ?
var indexOfAnchor = $scope.model.target.url.search(/(#|\?)/);
if (indexOfAnchor > -1) {
@@ -61,132 +60,124 @@ angular.module("umbraco").controller("Umbraco.Overlays.LinkPickerController",
// then rewrite the model and populate the link
$scope.model.target.url = $scope.model.target.url.substring(0, indexOfAnchor);
}
}
} else if (dialogOptions.anchors) {
$scope.anchorValues = dialogOptions.anchors;
}
}
} else if (dialogOptions.anchors) {
$scope.anchorValues = dialogOptions.anchors;
}
function nodeSelectHandler(ev, args) {
if (args && args.event) {
args.event.preventDefault();
args.event.stopPropagation();
}
function nodeSelectHandler(ev, args) {
if (args && args.event) {
args.event.preventDefault();
args.event.stopPropagation();
}
eventsService.emit("dialogs.linkPicker.select", args);
eventsService.emit("dialogs.linkPicker.select", args);
if ($scope.currentNode) {
//un-select if there's a current one selected
$scope.currentNode.selected = false;
}
if ($scope.currentNode) {
//un-select if there's a current one selected
$scope.currentNode.selected = false;
}
$scope.currentNode = args.node;
$scope.currentNode.selected = true;
$scope.model.target.id = args.node.id;
$scope.model.target.udi = args.node.udi;
$scope.model.target.name = args.node.name;
$scope.currentNode = args.node;
$scope.currentNode.selected = true;
$scope.model.target.id = args.node.id;
$scope.model.target.udi = args.node.udi;
$scope.model.target.name = args.node.name;
if (args.node.id < 0) {
$scope.model.target.url = "/";
} else {
contentResource.getById(args.node.id, { ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes }).then(function (resp) {
$scope.model.target.url = resp.urls[0];
$scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
});
}
if (args.node.id < 0) {
$scope.model.target.url = "/";
} else {
contentResource.getById(args.node.id).then(function (resp) {
$scope.model.target.url = resp.urls[0];
$scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties));
});
}
if (!angular.isUndefined($scope.model.target.isMedia)) {
delete $scope.model.target.isMedia;
}
}
if (!angular.isUndefined($scope.model.target.isMedia)) {
delete $scope.model.target.isMedia;
}
}
function nodeExpandedHandler(ev, args) {
// open mini list view for list views
if (args.node.metaData.isContainer) {
openMiniListView(args.node);
}
}
function nodeExpandedHandler(ev, args) {
// open mini list view for list views
if (args.node.metaData.isContainer) {
openMiniListView(args.node);
}
}
$scope.switchToMediaPicker = function () {
userService.getCurrentUser().then(function (userData) {
var startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
var startNodeIsVirtual = userData.startMediaIds.length !== 1;
$scope.switchToMediaPicker = function () {
userService.getCurrentUser().then(function (userData) {
$scope.mediaPickerOverlay = {
view: "mediapicker",
startNodeId: userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0],
startNodeIsVirtual: userData.startMediaIds.length !== 1,
show: true,
submit: function (model) {
var media = model.selectedImages[0];
if (dialogOptions.ignoreUserStartNodes) {
startNodeId = -1;
startNodeIsVirtual = true;
}
$scope.mediaPickerOverlay = {
view: "mediapicker",
startNodeId: startNodeId,
startNodeIsVirtual: startNodeIsVirtual,
show: true,
ignoreUserStartNodes: dialogOptions.ignoreUserStartNodes,
submit: function (model) {
var media = model.selectedImages[0];
$scope.model.target.id = media.id;
$scope.model.target.udi = media.udi;
$scope.model.target.isMedia = true;
$scope.model.target.name = media.name;
$scope.model.target.url = mediaHelper.resolveFile(media);
$scope.model.target.id = media.id;
$scope.model.target.udi = media.udi;
$scope.model.target.isMedia = true;
$scope.model.target.name = media.name;
$scope.model.target.url = mediaHelper.resolveFile(media);
$scope.mediaPickerOverlay.show = false;
$scope.mediaPickerOverlay = null;
$scope.mediaPickerOverlay.show = false;
$scope.mediaPickerOverlay = null;
// make sure the content tree has nothing highlighted
$scope.dialogTreeEventHandler.syncTree({
path: "-1",
tree: "content"
});
}
};
});
};
// make sure the content tree has nothing highlighted
$scope.dialogTreeEventHandler.syncTree({
path: "-1",
tree: "content"
});
}
};
});
};
$scope.hideSearch = function () {
$scope.searchInfo.showSearch = false;
$scope.searchInfo.searchFromId = null;
$scope.searchInfo.searchFromName = null;
$scope.searchInfo.results = [];
}
$scope.hideSearch = function () {
$scope.searchInfo.showSearch = false;
$scope.searchInfo.searchFromId = null;
$scope.searchInfo.searchFromName = null;
$scope.searchInfo.results = [];
}
// method to select a search result
$scope.selectResult = function (evt, result) {
result.selected = result.selected === true ? false : true;
nodeSelectHandler(evt, {
event: evt,
node: result
});
};
// method to select a search result
$scope.selectResult = function (evt, result) {
result.selected = result.selected === true ? false : true;
nodeSelectHandler(evt, {
event: evt,
node: result
});
};
//callback when there are search results
$scope.onSearchResults = function (results) {
$scope.searchInfo.results = results;
$scope.searchInfo.showSearch = true;
};
//callback when there are search results
$scope.onSearchResults = function (results) {
$scope.searchInfo.results = results;
$scope.searchInfo.showSearch = true;
};
$scope.dialogTreeEventHandler.bind("treeNodeSelect", nodeSelectHandler);
$scope.dialogTreeEventHandler.bind("treeNodeExpanded", nodeExpandedHandler);
$scope.dialogTreeEventHandler.bind("treeNodeSelect", nodeSelectHandler);
$scope.dialogTreeEventHandler.bind("treeNodeExpanded", nodeExpandedHandler);
$scope.$on('$destroy', function () {
$scope.dialogTreeEventHandler.unbind("treeNodeSelect", nodeSelectHandler);
$scope.dialogTreeEventHandler.unbind("treeNodeExpanded", nodeExpandedHandler);
});
$scope.$on('$destroy', function () {
$scope.dialogTreeEventHandler.unbind("treeNodeSelect", nodeSelectHandler);
$scope.dialogTreeEventHandler.unbind("treeNodeExpanded", nodeExpandedHandler);
});
// Mini list view
$scope.selectListViewNode = function (node) {
node.selected = node.selected === true ? false : true;
nodeSelectHandler({}, {
node: node
});
};
// Mini list view
$scope.selectListViewNode = function (node) {
node.selected = node.selected === true ? false : true;
nodeSelectHandler({}, {
node: node
});
};
$scope.closeMiniListView = function () {
$scope.miniListView = undefined;
};
$scope.closeMiniListView = function () {
$scope.miniListView = undefined;
};
function openMiniListView(node) {
$scope.miniListView = node;
}
function openMiniListView(node) {
$scope.miniListView = node;
}
});
});

View File

@@ -50,7 +50,6 @@
search-from-id="{{searchInfo.searchFromId}}"
search-from-name="{{searchInfo.searchFromName}}"
show-search="{{searchInfo.showSearch}}"
ignore-user-startnodes="{{searchInfo.ignoreUserStartNodes}}"
section="{{section}}">
</umb-tree-search-box>
@@ -65,7 +64,6 @@
<umb-tree section="content"
hideheader="true"
hideoptions="true"
customtreeparams="{{customTreeParams}}"
eventhandler="dialogTreeEventHandler"
enablelistviewexpand="true"
isdialog="true"

View File

@@ -1,7 +1,7 @@
//used for the media picker dialog
angular.module("umbraco")
.controller("Umbraco.Overlays.MediaPickerController",
function ($scope, mediaResource, umbRequestHelper, entityResource, $log, mediaHelper, mediaTypeHelper, eventsService, treeService, $element, $timeout, userService, $cookies, localStorageService, localizationService) {
function($scope, mediaResource, umbRequestHelper, entityResource, $log, mediaHelper, mediaTypeHelper, eventsService, treeService, $element, $timeout, $cookies, localStorageService, localizationService) {
if (!$scope.model.title) {
$scope.model.title = localizationService.localize("defaultdialogs_selectMedia");
@@ -18,8 +18,6 @@ angular.module("umbraco")
$scope.lastOpenedNode = localStorageService.get("umbLastOpenedMediaNodeId");
$scope.lockedFolder = true;
var userStartNodes = [];
var umbracoSettings = Umbraco.Sys.ServerVariables.umbracoSettings;
var allowedUploadFiles = mediaHelper.formatFileTypes(umbracoSettings.allowedUploadFiles);
if ($scope.onlyImages) {
@@ -49,8 +47,7 @@ angular.module("umbraco")
pageSize: 100,
totalItems: 0,
totalPages: 0,
filter: '',
ignoreUserStartNodes: $scope.model.ignoreUserStartNodes
filter: ''
};
//preload selected item
@@ -60,19 +57,15 @@ angular.module("umbraco")
}
function onInit() {
userService.getCurrentUser().then(function (userData) {
userStartNodes = userData.startMediaIds;
if ($scope.startNodeId !== -1) {
entityResource.getById($scope.startNodeId, "media")
.then(function (ent) {
$scope.startNodeId = ent.id;
run();
});
} else {
run();
}
});
if ($scope.startNodeId !== -1) {
entityResource.getById($scope.startNodeId, "media")
.then(function (ent) {
$scope.startNodeId = ent.id;
run();
});
} else {
run();
}
}
function run() {
@@ -157,8 +150,8 @@ angular.module("umbraco")
}
if (folder.id > 0) {
entityResource.getAncestors(folder.id, "media", { ignoreUserStartNodes: $scope.model.ignoreUserStartNodes })
.then(function(anc) {
entityResource.getAncestors(folder.id, "media")
.then(function(anc) {
$scope.path = _.filter(anc,
function(f) {
return f.path.indexOf($scope.startNodeId) !== -1;
@@ -168,13 +161,13 @@ angular.module("umbraco")
} else {
$scope.path = [];
}
mediaTypeHelper.getAllowedImagetypes(folder.id)
.then(function (types) {
$scope.acceptedMediatypes = types;
});
$scope.lockedFolder = (folder.id === -1 && $scope.model.startNodeIsVirtual) || hasFolderAccess(folder) === false;
$scope.lockedFolder = folder.id === -1 && $scope.model.startNodeIsVirtual;
$scope.currentFolder = folder;
localStorageService.set("umbLastOpenedMediaNodeId", folder.id);
@@ -270,17 +263,6 @@ angular.module("umbraco")
}
}
function hasFolderAccess(node) {
var nodePath = node.path ? node.path.split(',') : [node.id];
for (var i = 0; i < nodePath.length; i++) {
if (userStartNodes.indexOf(parseInt(nodePath[i])) !== -1)
return true;
}
return false;
}
function gotoStartNode(err) {
$scope.gotoFolder({ id: $scope.startNodeId, name: "Media", icon: "icon-folder" });
}
@@ -315,8 +297,7 @@ angular.module("umbraco")
pageSize: 100,
totalItems: 0,
totalPages: 0,
filter: '',
ignoreUserStartNodes: $scope.model.ignoreUserStartNodes
filter: ''
};
getChildren($scope.currentFolder.id);
}
@@ -388,7 +369,7 @@ angular.module("umbraco")
function getChildren(id) {
$scope.loading = true;
return mediaResource.getChildren(id, { ignoreUserStartNodes: $scope.model.ignoreUserStartNodes })
return mediaResource.getChildren(id)
.then(function(data) {
$scope.searchOptions.filter = "";
$scope.images = data.items ? data.items : [];

View File

@@ -10,7 +10,6 @@
search-from-id="{{searchInfo.searchFromId}}"
search-from-name="{{searchInfo.searchFromName}}"
show-search="{{searchInfo.showSearch}}"
ignore-user-startnodes="{{searchInfo.ignoreUserStartNodes}}"
section="{{section}}">
</umb-tree-search-box>
</div>

View File

@@ -66,7 +66,6 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
showOpenButton: false,
showEditButton: false,
showPathOnHover: false,
ignoreUserStartNodes: false,
maxNumber: 1,
minNumber : 0,
startNode: {
@@ -100,8 +99,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
$scope.model.config.showOpenButton = ($scope.model.config.showOpenButton === "1" ? true : false);
$scope.model.config.showEditButton = ($scope.model.config.showEditButton === "1" ? true : false);
$scope.model.config.showPathOnHover = ($scope.model.config.showPathOnHover === "1" ? true : false);
$scope.model.config.ignoreUserStartNodes = ($scope.model.config.ignoreUserStartNodes === "1" ? true : false);
var entityType = $scope.model.config.startNode.type === "member"
? "Member"
: $scope.model.config.startNode.type === "media"

View File

@@ -1,20 +1,12 @@
angular.module("umbraco")
.controller("Umbraco.PropertyEditors.Grid.MediaController",
function ($scope, $rootScope, $timeout, userService) {
var ignoreUserStartNodes = $scope.model.config.ignoreUserStartNodes === "1" ? true : false;
if (!$scope.model.config.startNodeId) {
if (ignoreUserStartNodes === true) {
$scope.model.config.startNodeId = -1;
$scope.model.config.startNodeIsVirtual = true;
} else {
userService.getCurrentUser().then(function (userData) {
$scope.model.config.startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
$scope.model.config.startNodeIsVirtual = userData.startMediaIds.length !== 1;
});
}
userService.getCurrentUser().then(function (userData) {
$scope.model.config.startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
$scope.model.config.startNodeIsVirtual = userData.startMediaIds.length !== 1;
});
}
$scope.setImage = function(){
@@ -22,7 +14,6 @@ angular.module("umbraco")
$scope.mediaPickerOverlay.view = "mediapicker";
$scope.mediaPickerOverlay.startNodeId = $scope.model.config && $scope.model.config.startNodeId ? $scope.model.config.startNodeId : undefined;
$scope.mediaPickerOverlay.startNodeIsVirtual = $scope.mediaPickerOverlay.startNodeId ? $scope.model.config.startNodeIsVirtual : undefined;
$scope.mediaPickerOverlay.ignoreUserStartNodes = ignoreUserStartNodes;
$scope.mediaPickerOverlay.cropSize = $scope.control.editor.config && $scope.control.editor.config.size ? $scope.control.editor.config.size : undefined;
$scope.mediaPickerOverlay.showDetails = true;
$scope.mediaPickerOverlay.disableFolderSelect = true;

View File

@@ -16,7 +16,6 @@
view: "linkpicker",
currentTarget: currentTarget,
anchors: tinyMceService.getAnchorNames(JSON.stringify(editorState.current.properties)),
ignoreUserStartNodes: $scope.model.config.ignoreUserStartNodes === "1",
show: true,
submit: function(model) {
tinyMceService.insertLinkInEditor(editor, model.target, anchorElement);
@@ -27,23 +26,11 @@
}
function openMediaPicker(editor, currentTarget, userData) {
var ignoreUserStartNodes = false;
var startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
var startNodeIsVirtual = userData.startMediaIds.length !== 1;
if ($scope.model.config.ignoreUserStartNodes === "1") {
ignoreUserStartNodes = true;
startNodeId = -1;
startNodeIsVirtual = true;
}
vm.mediaPickerOverlay = {
currentTarget: currentTarget,
onlyImages: true,
showDetails: true,
startNodeId: startNodeId,
startNodeIsVirtual: startNodeIsVirtual,
ignoreUserStartNodes: ignoreUserStartNodes,
showDetails: true,
startNodeId: userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0],
view: "mediapicker",
show: true,
submit: function(model) {

View File

@@ -7,19 +7,12 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
var multiPicker = $scope.model.config.multiPicker && $scope.model.config.multiPicker !== '0' ? true : false;
var onlyImages = $scope.model.config.onlyImages && $scope.model.config.onlyImages !== '0' ? true : false;
var disableFolderSelect = $scope.model.config.disableFolderSelect && $scope.model.config.disableFolderSelect !== '0' ? true : false;
var ignoreUserStartNodes = $scope.model.config.ignoreUserStartNodes === "1" ? true : false;
if (!$scope.model.config.startNodeId) {
if (ignoreUserStartNodes === true) {
$scope.model.config.startNodeId = -1;
$scope.model.config.startNodeIsVirtual = true;
} else {
userService.getCurrentUser().then(function (userData) {
$scope.model.config.startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
$scope.model.config.startNodeIsVirtual = userData.startMediaIds.length !== 1;
});
}
userService.getCurrentUser().then(function(userData) {
$scope.model.config.startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
$scope.model.config.startNodeIsVirtual = userData.startMediaIds.length !== 1;
});
}
function setupViewModel() {
@@ -112,7 +105,6 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.MediaPickerControl
title: "Select media",
startNodeId: $scope.model.config.startNodeId,
startNodeIsVirtual: $scope.model.config.startNodeIsVirtual,
ignoreUserStartNodes: ignoreUserStartNodes,
multiPicker: multiPicker,
onlyImages: onlyImages,
disableFolderSelect: disableFolderSelect,

View File

@@ -67,11 +67,10 @@ function multiUrlPickerController($scope, angularHelper, localizationService, en
url: link.url,
target: link.target
} : null;
$scope.linkPickerOverlay = {
view: "linkpicker",
currentTarget: target,
ignoreUserStartNodes: $scope.model.config.ignoreUserStartNodes === "1",
show: true,
submit: function (model) {
if (model.target.url || model.target.anchor) {

View File

@@ -25,7 +25,6 @@
$scope.contentPickerOverlay.view = "contentpicker";
$scope.contentPickerOverlay.multiPicker = false;
$scope.contentPickerOverlay.show = true;
$scope.contentPickerOverlay.ignoreUserStartNodes = $scope.model.config.ignoreUserStartNodes === "1" ? true: false;
$scope.contentPickerOverlay.idType = $scope.model.config.idType ? $scope.model.config.idType : "int";
$scope.contentPickerOverlay.submit = function(model) {
@@ -51,7 +50,6 @@
$scope.contentPickerOverlay.view = "contentpicker";
$scope.contentPickerOverlay.multiPicker = false;
$scope.contentPickerOverlay.show = true;
$scope.contentPickerOverlay.ignoreUserStartNodes = $scope.model.config.ignoreUserStartNodes === "1" ? true : false;
$scope.contentPickerOverlay.idType = $scope.model.config.idType ? $scope.model.config.idType : "int";
$scope.contentPickerOverlay.submit = function(model) {

View File

@@ -274,7 +274,6 @@ angular.module("umbraco")
view: "linkpicker",
currentTarget: currentTarget,
anchors: editorState.current ? tinyMceService.getAnchorNames(JSON.stringify(editorState.current.properties)) : [],
ignoreUserStartNodes: $scope.model.config.ignoreUserStartNodes === "1",
show: true,
submit: function(model) {
tinyMceService.insertLinkInEditor(editor, model.target, anchorElement);
@@ -286,24 +285,14 @@ angular.module("umbraco")
//Create the insert media plugin
tinyMceService.createMediaPicker(editor, $scope, function(currentTarget, userData){
var ignoreUserStartNodes = false;
var startNodeId = userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0];
var startNodeIsVirtual = userData.startMediaIds.length !== 1;
if ($scope.model.config.ignoreUserStartNodes === "1") {
ignoreUserStartNodes = true;
startNodeId = -1;
startNodeIsVirtual = true;
}
$scope.mediaPickerOverlay = {
currentTarget: currentTarget,
onlyImages: true,
showDetails: true,
disableFolderSelect: true,
startNodeId: startNodeId,
startNodeIsVirtual: startNodeIsVirtual,
ignoreUserStartNodes: ignoreUserStartNodes,
startNodeId: userData.startMediaIds.length !== 1 ? -1 : userData.startMediaIds[0],
startNodeIsVirtual: userData.startMediaIds.length !== 1,
view: "mediapicker",
show: true,
submit: function(model) {

View File

@@ -40,5 +40,4 @@
<input type="number" min="0" ng-model="model.value.maxImageSize" class="umb-editor-tiny" placeholder="Width/Height" /> Pixels
</div>
</umb-control-group>
</div>

View File

@@ -262,11 +262,10 @@ namespace Umbraco.Web.Editors
/// Gets the content json for the content id
/// </summary>
/// <param name="id"></param>
/// <param name="ignoreUserStartNodes">If set to true, user and group start node permissions will be ignored.</param>
/// <returns></returns>
[OutgoingEditorModelEvent]
[EnsureUserPermissionForContent("id")]
public ContentItemDisplay GetById(int id, [FromUri]bool ignoreUserStartNodes = false)
public ContentItemDisplay GetById(int id)
{
var foundContent = GetObjectFromRequest(() => Services.ContentService.GetById(id));
if (foundContent == null)
@@ -1117,7 +1116,6 @@ namespace Umbraco.Web.Editors
/// <param name="nodeId">The content to lookup, if the contentItem is not specified</param>
/// <param name="permissionsToCheck"></param>
/// <param name="contentItem">Specifies the already resolved content item to check against</param>
/// <param name="ignoreUserStartNodes">If set to true, user and group start node permissions will be ignored.</param>
/// <returns></returns>
internal static bool CheckPermissions(
IDictionary<string, object> storage,
@@ -1127,8 +1125,7 @@ namespace Umbraco.Web.Editors
IEntityService entityService,
int nodeId,
char[] permissionsToCheck = null,
IContent contentItem = null,
bool ignoreUserStartNodes = false)
IContent contentItem = null)
{
if (storage == null) throw new ArgumentNullException("storage");
if (user == null) throw new ArgumentNullException("user");
@@ -1149,11 +1146,6 @@ namespace Umbraco.Web.Editors
throw new HttpResponseException(HttpStatusCode.NotFound);
}
if(ignoreUserStartNodes)
{
return true;
}
var hasPathAccess = (nodeId == Constants.System.Root)
? user.HasContentRootAccess(entityService)
: (nodeId == Constants.System.RecycleBinContent)

View File

@@ -83,25 +83,8 @@ namespace Umbraco.Web.Editors
/// A starting point for the search, generally a node id, but for members this is a member type alias
/// </param>
/// <returns></returns>
[Obsolete("This method is obsolete, use the overload with ignoreUserStartNodes instead", false)]
[HttpGet]
public IEnumerable<EntityBasic> Search(string query, UmbracoEntityTypes type, string searchFrom = null)
{
return Search(query, type, false, searchFrom);
}
/// <summary>
/// Searches for results based on the entity type
/// </summary>
/// <param name="query"></param>
/// <param name="type"></param>
/// <param name="searchFrom">
/// A starting point for the search, generally a node id, but for members this is a member type alias
/// </param>
/// <param name="ignoreUserStartNodes">If set to true, user and group start node permissions will be ignored.</param>
/// <returns></returns>
[HttpGet]
public IEnumerable<EntityBasic> Search(string query, UmbracoEntityTypes type, bool? ignoreUserStartNodes, string searchFrom = null)
{
//TODO: Should we restrict search results based on what app the user has access to?
// - Theoretically you shouldn't be able to see member data if you don't have access to members right?
@@ -109,7 +92,7 @@ namespace Umbraco.Web.Editors
if (string.IsNullOrEmpty(query))
return Enumerable.Empty<EntityBasic>();
return ExamineSearch(query, type, searchFrom, ignoreUserStartNodes != null && ignoreUserStartNodes.Value);
return ExamineSearch(query, type, searchFrom);
}
/// <summary>
@@ -544,7 +527,6 @@ namespace Umbraco.Web.Editors
}
}
[Obsolete("This method is obsolete, use the overload with ignoreUserStartNodes instead", false)]
public PagedResult<EntityBasic> GetPagedDescendants(
int id,
UmbracoEntityTypes type,
@@ -553,20 +535,6 @@ namespace Umbraco.Web.Editors
string orderBy = "SortOrder",
Direction orderDirection = Direction.Ascending,
string filter = "")
{
return GetPagedDescendants(id, type, pageNumber, pageSize,
false, orderBy, orderDirection, filter);
}
public PagedResult<EntityBasic> GetPagedDescendants(
int id,
UmbracoEntityTypes type,
int pageNumber,
int pageSize,
bool ignoreUserStartNodes,
string orderBy = "SortOrder",
Direction orderDirection = Direction.Ascending,
string filter = "")
{
if (pageNumber <= 0)
throw new HttpResponseException(HttpStatusCode.NotFound);
@@ -594,7 +562,7 @@ namespace Umbraco.Web.Editors
break;
}
entities = aids == null || aids.Contains(Constants.System.Root) || ignoreUserStartNodes
entities = aids == null || aids.Contains(Constants.System.Root)
? Services.EntityService.GetPagedDescendantsFromRoot(objectType.Value, pageNumber - 1, pageSize, out totalRecords, orderBy, orderDirection, filter, includeTrashed: false)
: Services.EntityService.GetPagedDescendants(aids, objectType.Value, pageNumber - 1, pageSize, out totalRecords, orderBy, orderDirection, filter);
}
@@ -630,15 +598,9 @@ namespace Umbraco.Web.Editors
}
}
[Obsolete("This method is obsolete, use the overload with ignoreUserStartNodes instead", false)]
public IEnumerable<EntityBasic> GetAncestors(int id, UmbracoEntityTypes type)
{
return GetResultForAncestors(id, type, false);
}
public IEnumerable<EntityBasic> GetAncestors(int id, UmbracoEntityTypes type, bool ignoreUserStartNodes)
{
return GetResultForAncestors(id, type, ignoreUserStartNodes);
return GetResultForAncestors(id, type);
}
public IEnumerable<EntityBasic> GetAll(UmbracoEntityTypes type, string postFilter, [FromUri]IDictionary<string, object> postFilterParams)
@@ -652,12 +614,11 @@ namespace Umbraco.Web.Editors
/// <param name="query"></param>
/// <param name="entityType"></param>
/// <param name="searchFrom"></param>
/// <param name="ignoreUserStartNodes">If set to true, user and group start node permissions will be ignored.</param>
/// <returns></returns>
private IEnumerable<SearchResultItem> ExamineSearch(string query, UmbracoEntityTypes entityType, string searchFrom = null, bool ignoreUserStartNodes = false)
private IEnumerable<SearchResultItem> ExamineSearch(string query, UmbracoEntityTypes entityType, string searchFrom = null)
{
long total;
return _treeSearcher.ExamineSearch(Umbraco, query, entityType, 200, 0, out total, ignoreUserStartNodes, searchFrom);
return _treeSearcher.ExamineSearch(Umbraco, query, entityType, 200, 0, out total, searchFrom);
}
@@ -684,7 +645,7 @@ namespace Umbraco.Web.Editors
}
}
private IEnumerable<EntityBasic> GetResultForAncestors(int id, UmbracoEntityTypes entityType, bool ignoreUserStartNodes = false)
private IEnumerable<EntityBasic> GetResultForAncestors(int id, UmbracoEntityTypes entityType)
{
var objectType = ConvertToObjectType(entityType);
if (objectType.HasValue)
@@ -693,38 +654,35 @@ namespace Umbraco.Web.Editors
var ids = Services.EntityService.Get(id).Path.Split(',').Select(int.Parse).Distinct().ToArray();
if (ignoreUserStartNodes == false)
int[] aids = null;
switch (entityType)
{
int[] aids = null;
switch (entityType)
{
case UmbracoEntityTypes.Document:
aids = Security.CurrentUser.CalculateContentStartNodeIds(Services.EntityService);
break;
case UmbracoEntityTypes.Media:
aids = Security.CurrentUser.CalculateMediaStartNodeIds(Services.EntityService);
break;
}
case UmbracoEntityTypes.Document:
aids = Security.CurrentUser.CalculateContentStartNodeIds(Services.EntityService);
break;
case UmbracoEntityTypes.Media:
aids = Security.CurrentUser.CalculateMediaStartNodeIds(Services.EntityService);
break;
}
if (aids != null)
if (aids != null)
{
var lids = new List<int>();
var ok = false;
foreach (var i in ids)
{
var lids = new List<int>();
var ok = false;
foreach (var i in ids)
if (ok)
{
if (ok)
{
lids.Add(i);
continue;
}
if (aids.Contains(i))
{
lids.Add(i);
ok = true;
}
lids.Add(i);
continue;
}
if (aids.Contains(i))
{
lids.Add(i);
ok = true;
}
ids = lids.ToArray();
}
ids = lids.ToArray();
}
return ids.Length == 0

View File

@@ -264,12 +264,11 @@ namespace Umbraco.Web.Editors
string orderBy = "SortOrder",
Direction orderDirection = Direction.Ascending,
bool orderBySystemField = true,
string filter = "",
bool ignoreUserStartNodes = false)
string filter = "")
{
//if a request is made for the root node data but the user's start node is not the default, then
// we need to return their start nodes
if (id == Constants.System.Root && UserStartNodes.Length > 0 && (UserStartNodes.Contains(Constants.System.Root) == false && ignoreUserStartNodes == false))
if (id == Constants.System.Root && UserStartNodes.Length > 0 && UserStartNodes.Contains(Constants.System.Root) == false)
{
if (pageNumber > 0)
return new PagedResult<ContentItemBasic<ContentPropertyBasic, IMedia>>(0, 0, 0);
@@ -347,7 +346,6 @@ namespace Umbraco.Web.Editors
/// <param name="orderDirection"></param>
/// <param name="orderBySystemField"></param>
/// <param name="filter"></param>
/// <param name="ignoreUserStartNodes">If set to true, user and group start node permissions will be ignored.</param>
/// <returns></returns>
[FilterAllowedOutgoingMedia(typeof(IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>>), "Items")]
public PagedResult<ContentItemBasic<ContentPropertyBasic, IMedia>> GetChildren(Guid id,
@@ -362,7 +360,7 @@ namespace Umbraco.Web.Editors
var entity = Services.EntityService.GetByKey(id);
if (entity != null)
{
return GetChildren(entity.Id, pageNumber, pageSize, orderBy, orderDirection, orderBySystemField, filter, ignoreUserStartNodes);
return GetChildren(entity.Id, pageNumber, pageSize, orderBy, orderDirection, orderBySystemField, filter);
}
throw new HttpResponseException(HttpStatusCode.NotFound);
}
@@ -402,7 +400,6 @@ namespace Umbraco.Web.Editors
/// <param name="orderDirection"></param>
/// <param name="orderBySystemField"></param>
/// <param name="filter"></param>
/// <param name="ignoreUserStartNodes">If set to true, user and group start node permissions will be ignored.</param>
/// <returns></returns>
[FilterAllowedOutgoingMedia(typeof(IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>>), "Items")]
public PagedResult<ContentItemBasic<ContentPropertyBasic, IMedia>> GetChildren(Udi id,
@@ -420,7 +417,7 @@ namespace Umbraco.Web.Editors
var entity = Services.EntityService.GetByKey(guidUdi.Guid);
if (entity != null)
{
return GetChildren(entity.Id, pageNumber, pageSize, orderBy, orderDirection, orderBySystemField, filter, ignoreUserStartNodes);
return GetChildren(entity.Id, pageNumber, pageSize, orderBy, orderDirection, orderBySystemField, filter);
}
}
@@ -436,8 +433,7 @@ namespace Umbraco.Web.Editors
string orderBy = "SortOrder",
Direction orderDirection = Direction.Ascending,
bool orderBySystemField = true,
string filter = "",
bool ignoreUserStartNodes = false)
string filter = "")
{
foreach (var type in new[] { typeof(int), typeof(Guid) })
{

View File

@@ -15,11 +15,10 @@ namespace Umbraco.Web.PropertyEditors
{
InternalPreValues = new Dictionary<string, object>
{
{"startNodeId", "-1"},
{"startNodeId", "-1"},
{"showOpenButton", "0"},
{"showEditButton", "0"},
{"showPathOnHover", "0"},
{"ignoreUserStartNodes", "0"},
{"idType", "udi"}
};
}
@@ -40,7 +39,7 @@ namespace Umbraco.Web.PropertyEditors
{
public ContentPickerPreValueEditor()
{
//create the fields
//create the fields
Fields.Add(new PreValueField()
{
Key = "showOpenButton",
@@ -49,13 +48,6 @@ namespace Umbraco.Web.PropertyEditors
Description = "Opens the node in a dialog"
});
Fields.Add(new PreValueField()
{
Key = "ignoreUserStartNodes",
View = "boolean",
Name = "Ignore user start nodes",
Description = "Selecting this option allows a user to choose nodes that they normally don't have access to."
});
Fields.Add(new PreValueField()
{
Key = "startNodeId",
View = "treepicker",
@@ -68,4 +60,4 @@ namespace Umbraco.Web.PropertyEditors
}
}
}
}
}

View File

@@ -136,9 +136,6 @@ namespace Umbraco.Web.PropertyEditors
[PreValueField("rte", "Rich text editor", "views/propertyeditors/rte/rte.prevalues.html", Description = "Rich text editor configuration")]
public string Rte { get; set; }
[PreValueField("ignoreUserStartNodes", "Ignore user start nodes", "boolean", Description = "Selecting this option allows a user to choose nodes that they normally don't have access to.")]
public bool IgnoreUserStartNodes { get; set; }
}
#region Application event handler, used to bind to events on startup

View File

@@ -57,13 +57,6 @@ namespace Umbraco.Web.PropertyEditors
Description = "Do not allow folders to be picked."
});
Fields.Add(new PreValueField()
{
Key = "ignoreUserStartNodes",
View = "boolean",
Name = "Ignore user start nodes",
Description = "Selecting this option allows a user to choose nodes that they normally don't have access to."
});
Fields.Add(new PreValueField()
{
Key = "startNodeId",
View = "mediapicker",
@@ -76,4 +69,4 @@ namespace Umbraco.Web.PropertyEditors
}
}
}
}
}

View File

@@ -16,7 +16,6 @@ namespace Umbraco.Web.PropertyEditors
{"showOpenButton", "0"},
{"showEditButton", "0"},
{"showPathOnHover", "0"},
{"ignoreUserStartNodes", "0"},
{"idType", "udi"}
};
}
@@ -39,13 +38,6 @@ namespace Umbraco.Web.PropertyEditors
{
//create the fields
Fields.Add(new PreValueField()
{
Key = "ignoreUserStartNodes",
View = "boolean",
Name = "Ignore user start nodes",
Description = "Selecting this option allows a user to choose nodes that they normally don't have access to."
});
Fields.Add(new PreValueField()
{
Key = "startNode",
View = "treesource",
@@ -126,4 +118,4 @@ namespace Umbraco.Web.PropertyEditors
}
}
}
}

View File

@@ -32,13 +32,6 @@ namespace Umbraco.Web.PropertyEditors
{
public MultiUrlPickerPreValueEditor()
{
Fields.Add(new PreValueField()
{
Key = "ignoreUserStartNodes",
View = "boolean",
Name = "Ignore user start nodes",
Description = "Selecting this option allows a user to choose nodes that they normally don't have access to."
});
Fields.Add(new PreValueField
{
Key = "minNumber",

View File

@@ -14,7 +14,6 @@ namespace Umbraco.Web.PropertyEditors
{
InternalPreValues = new Dictionary<string, object>
{
{"ignoreUserStartNodes", "0"},
{"idType", "udi"}
};
}
@@ -33,11 +32,8 @@ namespace Umbraco.Web.PropertyEditors
internal class RelatedLinksPreValueEditor : PreValueEditor
{
[PreValueField("ignoreUserStartNodes", "Ignore user start nodes", "boolean", Description = "Selecting this option allows a user to choose nodes that they normally don't have access to.")]
public bool IgnoreUserStartNodes { get; set; }
[PreValueField("max", "Maximum number of links", "number", Description = "Enter the maximum amount of links to be added, enter 0 for unlimited")]
public int Maximum { get; set; }
public int Maximum { get; set; }
}
}
}

View File

@@ -23,14 +23,6 @@ namespace Umbraco.Web.PropertyEditors
Key = "editor"
});
Fields.Add(new PreValueField()
{
Key = "ignoreUserStartNodes",
View = "boolean",
Name = "Ignore user start nodes",
Description = "Selecting this option allows a user to choose nodes that they normally don't have access to."
});
Fields.Add(new PreValueField()
{
Name = "Hide Label",

View File

@@ -16,7 +16,6 @@ namespace Umbraco.Web.Search
internal class UmbracoTreeSearcher
{
/// <summary>
/// This method is obsolete, use the overload with ignoreUserStartNodes instead
/// Searches for results based on the entity type
/// </summary>
/// <param name="umbracoHelper"></param>
@@ -29,37 +28,12 @@ namespace Umbraco.Web.Search
/// <param name="pageSize"></param>
/// <param name="pageIndex"></param>
/// <returns></returns>
[Obsolete("This method is obsolete, use the overload with ignoreUserStartNodes instead", false)]
public IEnumerable<SearchResultItem> ExamineSearch(
UmbracoHelper umbracoHelper,
string query,
UmbracoEntityTypes entityType,
int pageSize,
long pageIndex, out long totalFound, string searchFrom = null)
{
return ExamineSearch(umbracoHelper, query, entityType, pageSize, pageIndex, out totalFound, false, searchFrom);
}
/// <summary>
/// Searches for results based on the entity type
/// </summary>
/// <param name="umbracoHelper"></param>
/// <param name="query"></param>
/// <param name="entityType"></param>
/// <param name="totalFound"></param>
/// <param name="searchFrom">
/// A starting point for the search, generally a node id, but for members this is a member type alias
/// </param>
/// <param name="pageSize"></param>
/// <param name="pageIndex"></param>
/// <param name="ignoreUserStartNodes">If set to true, user and group start node permissions will be ignored.</param>
/// <returns></returns>
public IEnumerable<SearchResultItem> ExamineSearch(
UmbracoHelper umbracoHelper,
string query,
UmbracoEntityTypes entityType,
int pageSize,
long pageIndex, out long totalFound, bool ignoreUserStartNodes, string searchFrom = null)
{
var sb = new StringBuilder();
@@ -87,12 +61,12 @@ namespace Umbraco.Web.Search
case UmbracoEntityTypes.Media:
type = "media";
var allMediaStartNodes = umbracoContext.Security.CurrentUser.CalculateMediaStartNodeIds(appContext.Services.EntityService);
AppendPath(sb, UmbracoObjectTypes.Media, allMediaStartNodes, searchFrom, ignoreUserStartNodes, appContext.Services.EntityService);
AppendPath(sb, UmbracoObjectTypes.Media, allMediaStartNodes, searchFrom, appContext.Services.EntityService);
break;
case UmbracoEntityTypes.Document:
type = "content";
var allContentStartNodes = umbracoContext.Security.CurrentUser.CalculateContentStartNodeIds(appContext.Services.EntityService);
AppendPath(sb, UmbracoObjectTypes.Document, allContentStartNodes, searchFrom, ignoreUserStartNodes, appContext.Services.EntityService);
AppendPath(sb, UmbracoObjectTypes.Document, allContentStartNodes, searchFrom, appContext.Services.EntityService);
break;
default:
throw new NotSupportedException("The " + typeof(UmbracoTreeSearcher) + " currently does not support searching against object type " + entityType);
@@ -229,7 +203,7 @@ namespace Umbraco.Web.Search
}
}
private void AppendPath(StringBuilder sb, UmbracoObjectTypes objectType, int[] startNodeIds, string searchFrom, bool ignoreUserStartNodes, IEntityService entityService)
private void AppendPath(StringBuilder sb, UmbracoObjectTypes objectType, int[] startNodeIds, string searchFrom, IEntityService entityService)
{
if (sb == null) throw new ArgumentNullException("sb");
if (entityService == null) throw new ArgumentNullException("entityService");
@@ -254,7 +228,7 @@ namespace Umbraco.Web.Search
// make sure we don't find anything
sb.Append("+__Path:none ");
}
else if (startNodeIds.Contains(-1) == false && ignoreUserStartNodes == false) // -1 = no restriction
else if (startNodeIds.Contains(-1) == false) // -1 = no restriction
{
var entityPaths = entityService.GetAllPaths(objectType, startNodeIds);

View File

@@ -69,7 +69,7 @@ namespace Umbraco.Web.Trees
{
var node = base.CreateRootNode(queryStrings);
if (IsDialog(queryStrings) && UserStartNodes.Contains(Constants.System.Root) == false && IgnoreUserStartNodes(queryStrings) == false)
if (IsDialog(queryStrings) && UserStartNodes.Contains(Constants.System.Root) == false)
{
node.AdditionalData["noAccess"] = true;
}
@@ -91,7 +91,7 @@ namespace Umbraco.Web.Trees
{
bool hasPathAccess;
var entityIsAncestorOfStartNodes = Security.CurrentUser.IsInBranchOfStartNode(e, Services.EntityService, RecycleBinId, out hasPathAccess);
if (IgnoreUserStartNodes(queryStrings) == false && entityIsAncestorOfStartNodes == false)
if (entityIsAncestorOfStartNodes == false)
return null;
var treeNode = GetSingleTreeNode(e, parentId, queryStrings);
@@ -101,7 +101,7 @@ namespace Umbraco.Web.Trees
//the node so we need to return null;
return null;
}
if (IgnoreUserStartNodes(queryStrings) == false && hasPathAccess == false)
if (hasPathAccess == false)
{
treeNode.AdditionalData["noAccess"] = true;
}
@@ -141,7 +141,7 @@ namespace Umbraco.Web.Trees
// ensure that the user has access to that node, otherwise return the empty tree nodes collection
// TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access
if (IgnoreUserStartNodes(queryStrings) == false && HasPathAccess(id, queryStrings) == false)
if (HasPathAccess(id, queryStrings) == false)
{
LogHelper.Warn<ContentTreeControllerBase>("User " + Security.CurrentUser.Username + " does not have access to node with id " + id);
return nodes;
@@ -158,7 +158,7 @@ namespace Umbraco.Web.Trees
// get child entities - if id is root, but user's start nodes do not contain the
// root node, this returns the start nodes instead of root's children
var entities = GetChildEntities(id, queryStrings).ToList();
var entities = GetChildEntities(id).ToList();
nodes.AddRange(entities.Select(x => GetSingleTreeNodeWithAccessCheck(x, id, queryStrings)).Where(x => x != null));
// if the user does not have access to the root node, what we have is the start nodes,
@@ -190,7 +190,7 @@ namespace Umbraco.Web.Trees
protected abstract UmbracoObjectTypes UmbracoObjectType { get; }
protected IEnumerable<IUmbracoEntity> GetChildEntities(string id, FormDataCollection queryStrings)
protected IEnumerable<IUmbracoEntity> GetChildEntities(string id)
{
// try to parse id as an integer else use GetEntityFromId
// which will grok Guids, Udis, etc and let use obtain the id

View File

@@ -349,16 +349,6 @@ namespace Umbraco.Web.Trees
return queryStrings.GetValue<bool>(TreeQueryStringParameters.IsDialog);
}
/// <summary>
/// If the request should allows a user to choose nodes that they normally don't have access to
/// </summary>
/// <param name="queryStrings"></param>
/// <returns></returns>
protected bool IgnoreUserStartNodes(FormDataCollection queryStrings)
{
return queryStrings.GetValue<bool>(TreeQueryStringParameters.IgnoreUserStartNodes);
}
/// <summary>
/// An event that allows developers to modify the tree node collection that is being rendered
/// </summary>

View File

@@ -8,8 +8,7 @@
public const string IsDialog = "isDialog";
public const string Application = "application";
public const string StartNodeId = "startNodeId";
public const string IgnoreUserStartNodes = "ignoreUserStartNodes";
//public const string OnNodeClick = "OnNodeClick";
//public const string RenderParent = "RenderParent";
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
@@ -52,7 +52,7 @@ namespace Umbraco.Web.WebApi.Filters
_paramName = paramName;
_permissionToCheck = ActionBrowse.Instance.Letter;
}
}
public EnsureUserPermissionForContentAttribute(string paramName, char permissionToCheck)
: this(paramName)
@@ -72,9 +72,6 @@ namespace Umbraco.Web.WebApi.Filters
//not logged in
throw new HttpResponseException(System.Net.HttpStatusCode.Unauthorized);
}
var ignoreUserStartNodes = actionContext.ActionArguments.ContainsKey("ignoreUserStartNodes") &&
bool.Parse(actionContext.ActionArguments.GetValueAsString("ignoreUserStartNodes"));
int nodeId;
if (_nodeId.HasValue == false)
@@ -127,11 +124,9 @@ namespace Umbraco.Web.WebApi.Filters
actionContext.Request.Properties,
UmbracoContext.Current.Security.CurrentUser,
ApplicationContext.Current.Services.UserService,
ApplicationContext.Current.Services.ContentService,
ApplicationContext.Current.Services.EntityService,
nodeId,
_permissionToCheck.HasValue ? new[]{_permissionToCheck.Value}: null,
ignoreUserStartNodes: ignoreUserStartNodes))
ApplicationContext.Current.Services.ContentService,
ApplicationContext.Current.Services.EntityService,
nodeId, _permissionToCheck.HasValue ? new[]{_permissionToCheck.Value}: null))
{
base.OnActionExecuting(actionContext);
}

View File

@@ -3,13 +3,11 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.Http.Filters;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Trees;
namespace Umbraco.Web.WebApi.Filters
{
@@ -79,12 +77,7 @@ namespace Umbraco.Web.WebApi.Filters
protected virtual void FilterItems(IUser user, IList items)
{
bool.TryParse(HttpContext.Current.Request.QueryString.Get(TreeQueryStringParameters.IgnoreUserStartNodes), out var ignoreUserStartNodes);
if (ignoreUserStartNodes == false)
{
FilterBasedOnStartNode(items, user);
}
FilterBasedOnStartNode(items, user);
}
internal void FilterBasedOnStartNode(IList items, IUser user)