简体   繁体   English

Umbraco 7 保护图像

[英]Umbraco 7 protect images

If building an intranet, we would want users to be able to upload images for their own documents (eg, news items, blog entries and so on).如果构建内部网,我们希望用户能够为他们自己的文档(例如,新闻项目、博客条目等)上传图像。 However, access to media seems to allow users to also replace images on existing media.然而,对媒体的访问似乎也允许用户替换现有媒体上的图像。

Therefore, they could presumably replace furniture (eg, site logo etc) as these would all be in the media folder.因此,他们大概可以替换家具(例如,站点徽标等),因为这些都在媒体文件夹中。

I understand that users can be given a starting folder for the media tree (similar to that for editing documents), however, this would mean editing every single user to set their starting point, as there doesn't seem to be any way of doing this en masse eg by roles or user grouping.我知道可以为用户提供媒体树的起始文件夹(类似于用于编辑文档的文件夹),但是,这意味着编辑每个用户以设置他们的起点,因为似乎没有任何方法可以做例如通过角色或用户分组。

Is there another solution, eg saving furniture in another way so that only admins can edit them?是否有另一种解决方案,例如以另一种方式保存家具,以便只有管理员可以编辑它们?

As far as I know, there isn't a way to assign actual rights to media items or folders.据我所知,没有办法为媒体项目或文件夹分配实际权限。

But actually, if you have a sure fire way of knowing which starting node to assign to which users, it's not that tricky to do it programmatically:但实际上,如果您有一种确定的方法来知道将哪个起始节点分配给哪些用户,那么以编程方式进行操作并不难:

var userService = UmbracoContext.Current.Application.Services.UserService;
var mediaService = UmbracoContext.Current.Application.Services.MediaService;
int total;

foreach (var user in userService.GetAll(0, 1000, out total))
{
    int targetMediaId = 0;

    switch(user.UserType.Id)
    {
        case 123:
            targetMediaId = 3;
            break;
        case 234:
            targetMediaId = 5;
            break;
    }
    user.StartMediaId = targetMediaId;

    userService.Save(user);
}

I've used UserType as an example of how you might know what to assign to who, as I don't know how you'll tell in the end.我使用 UserType 作为示例,说明您如何知道将什么分配给谁,因为我不知道您最终会如何说。 In principal you could "easily" go as far as, I dunno, create a media folder per user and assign it as their starting media node.原则上,您可以“轻松”地尽可能地,我不知道,为每个用户创建一个媒体文件夹并将其分配为他们的起始媒体节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM