Choose from image library when user has restricted permissio

Posted by Community Admin on 04-Aug-2018 17:47

Choose from image library when user has restricted permissions.

All Replies

Posted by Community Admin on 10-Mar-2016 00:00

Hi there.

We have a bunch of editors who, despite being told several times, continue to upload images into a default library by neglecting to change it.

Is there was a way to force users to choose a library before being able to click 'Upload'?

I'm making this request for two reasons:

1) If like now, the editors have no restrictions on that library, they are (and will continue to do so, trust me) going to simply leave it as it is and upload their imagery there. This makes back end housekeeping a pain for our site administrators, something we want to simplify.

2) If editors have restricted permissions and this default library can only be edited, managed etc by administrators only, if they click 'Upload' without changing the library then they receive a rather messy error message (below) and have to repeat the process again as the 'Select an image' box is now, for lack of a better word, dead. (Screenshot attached)

"Telerik.Sitefinity.Libraries.Model.Album, Telerik.Sitefinity.Model was not granted ManageImage in Image for princupals with IDs 94cda633-4cae-6165-87ef-ff0000698116"

 

Forcing users to select a library instead of having one selected by default would solve this problem of ours.

If this isn't doable, is it instead possible to bounce an error message back to the user instead of an alert popup? Something along the lines of "You do not have permission to upload to this library, please select another".

Posted by Community Admin on 15-Mar-2016 00:00

Hello Chris,

You can inherit from ImageService and override the SaveChildContent method there. It is triggered when a user hits the upload button. The method accepts a parentId string which you can use to get the library into which the image is being uploaded, then you can for example throw an Exception and type a message that will come up as an alert screen for the user.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Libraries.Model;
using Telerik.Sitefinity.Modules.Libraries.Web.Services;
using Telerik.Sitefinity.Web.Services;
 
namespace SitefinityWebApp
    public class CustomImageService : ImageService
    
        public override ContentItemContext<Image> SaveChildContent(ContentItemContext<Image> content, string parentId, string contentId, string providerName, string newParentId, string version, bool published, bool checkOut, string workflowOperation)
        
            return base.SaveChildContent(content, parentId, contentId, providerName, newParentId, version, published, checkOut, workflowOperation);
        
    


In order to register the custom service go to your project's folder->Sitefinity->Services->Content->ImageService.svc then change the Service property with the type of your service for example:

<%@ ServiceHost
    Language="C#"
    Debug="false"
    Service="SitefinityWebApp.CustomImageService"
    Factory="Telerik.Sitefinity.Web.Services.WcfHostFactory"
 %>

I hope this helps.

Regards,
Pavel Benov
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed