Prevent MediaLibrary popup without permissions

If the user doesn't have ManageMedia permissions,
the markdown editor will use a specific image editor.
This commit is contained in:
Sebastien Ros
2015-09-16 14:47:14 -07:00
parent 0bf76dc7ac
commit ba36eae848
3 changed files with 62 additions and 54 deletions

View File

@@ -25,6 +25,7 @@
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -71,6 +72,10 @@
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.MediaLibrary\Orchard.MediaLibrary.csproj">
<Project>{73a7688a-5bd3-4f7e-adfa-ce36c5a10e3b}</Project>
<Name>Orchard.MediaLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Content\Admin\Images\grippie.png" />

View File

@@ -10,7 +10,8 @@
handler: function() { window.open("http://daringfireball.net/projects/markdown/syntax"); }
});
editor.hooks.set("insertImageDialog", function(callback) {
if (Boolean($(this).data("manage-media"))) {
editor.hooks.set("insertImageDialog", function (callback) {
// see if there's an image selected that they intend on editing
var wmd = $('#wmd-input' + idPostfix);
@@ -69,6 +70,7 @@
});
return true;
});
}
editor.run();
});

View File

@@ -21,7 +21,8 @@
{"id", "wmd-input" + "-" + idPostfix},
{"class", "wmd-input"},
{"data-mediapicker-uploadpath", Model.AddMediaPath},
{"data-mediapicker-title", T("Insert/Update Media")}
{"data-mediapicker-title", T("Insert/Update Media")},
{"data-manage-media", AuthorizedFor(Orchard.MediaLibrary.Permissions.ManageMediaContent) ? "true" : "false" }
};
// The markdown editor itself doesn't seem to (yet) support autofocus, but we'll set it on the textarea nonetheless.