This is a migrated thread and some comments may be shown as answers.

Prevent users from deleting folders

7 Answers 153 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Oren Halevi
Top achievements
Rank 1
Oren Halevi asked on 07 Jan 2010, 04:13 PM
Is there a way to allow users to delete files but prevent them from deleting folders in the imagemanager?

thanks

7 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 08 Jan 2010, 10:10 AM
Hi Oren,

Yes, the requested functionality is possible.

You should register the external dialog files of RadEditor so that you can modify the FileBrowser.ascx file, e.g.

<telerik:RadEditor runat="server" ExternalDialogsPath="~/EditorDialogs" ID="RadEditor1">
    <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
</telerik:RadEditor>

After that open the \EditorDialogs\FileBrowser.ascx file, locate the RadFileExplorer control and attach the OnClientDelete function to its OnClientDelete event property, e.g.

<telerik:RadFileExplorer ID="RadFileExplorer1" OnClientDelete="OnClientDelete" Height="450px" Width="400px" TreePaneWidth="150px"
runat="Server" EnableOpenFile="false" AllowPaging="true" />
<script type="text/javascript">
function OnClientDelete(oExplorer, args)
{
 var item = args.get_item();
 
 if (item.isDirectory())
 {
  args.set_cancel(true);
  alert("You cannot delete directories");
 }
}
</script>

For your convenience I have attached a fully working project to my reply.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Oren Halevi
Top achievements
Rank 1
answered on 10 Jan 2010, 12:32 PM
Thanks!! it works fine.
I have another related question:
I'm adding 2 folders for the users a user folder where he ca upload and store his clipart and a general folder for our clipart.
I've set the ImageManager.DeletePaths to the first directory and the ImageManager.ViewPaths to both folders, however the system still allows deleting from both directories. how can I prevent users from deleting from the general clipart directory?

Thanks
0
Oren Halevi
Top achievements
Rank 1
answered on 10 Jan 2010, 12:42 PM
I fixed it, I had to set the view folder first and only then the delete folder. I had it vice versa...
0
Oren Halevi
Top achievements
Rank 1
answered on 10 Jan 2010, 05:06 PM
Is it possible to disable the right-click context menu from renaming a folder? or disable the whole right click functionality from the File explorer?

thanks again
0
Rumen
Telerik team
answered on 11 Jan 2010, 12:34 PM
Hi Oren,

You can disable the context menu by opening the \EditorDialogs\FileBrowser.ascx file and setting the VisibleControls="AddressBox,Grid,Toolbar,TreeView" property in the RadFileExplorer control:

            <telerik:RadFileExplorer VisibleControls="AddressBox,Grid,Toolbar,TreeView" ID="RadFileExplorer1" Height="410px" Width="400px" TreePaneWidth="150px"
                runat="Server" EnableOpenFile="false" AllowPaging="true" />


Sincerely yours,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
louis chan
Top achievements
Rank 1
Iron
answered on 28 Apr 2010, 02:52 AM
Hi,
I find this thread and it is really helpful for me! But why does this way using javascript? Is that a good security performance? Thx!
0
Fiko
Telerik team
answered on 29 Apr 2010, 12:19 PM
Hello louis,

You can perform an additional server-side check and cancel the operation when a folder is deleting by using this approach:

I hope this helps.

Sincerely yours,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Editor
Asked by
Oren Halevi
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Oren Halevi
Top achievements
Rank 1
louis chan
Top achievements
Rank 1
Iron
Fiko
Telerik team
Share this question
or