简体   繁体   English

SharePoint Hosted App 2013:自定义List / AllItems.aspx页

[英]SharePoint Hosted App 2013: Customize List/AllItems.aspx page

I'm trying to implement permission levels in SharePoint hosted app. 我正在尝试在SharePoint托管应用中实现权限级别。 I've created a custom list "Permissions" where I'm adding different users with their roles. 我创建了一个自定义列表“权限”,在其中添加了不同用户及其角色。

I have created a page List.aspx where I'm showing my custom list "Products" as a list view web part. 我创建了一个页面List.aspx,其中将自定义列表“产品”显示为列表视图Web部件。 Page List.aspx checks the user's role against "Permissions" list, and page can show or hide content in regards to this role. 页面List.aspx根据“权限”列表检查用户的角色,页面可以显示或隐藏与此角色有关的内容。 The problem is, when user tries to navigate to "Lists/Products/Allitems.aspx" or "Lists/Permissions/Allitems.aspx" he can see the list items. 问题是,当用户尝试导航到“列表/产品/Allitems.aspx”或“列表/权限/Allitems.aspx”时,他可以看到列表项。

All code check is done in JavaScript and I know there is a security risk, but this will work for my users. 所有代码检查都是在JavaScript中完成的,并且我知道存在安全风险,但这将对我的用户有效。 I just need to find a way to inject custom JavaScript code to Allitems.aspx, and to check if user has permissions to see it or not. 我只需要找到一种方法即可将自定义JavaScript代码注入Allitems.aspx,并检查用户是否有权查看它。

Everything here is done on App web and there's nothing that I use on host web. 此处的所有操作都是在App网站上完成的,我在托管网站上没有任何使用。

I've found a workaround for this. 我已经找到了解决方法。 Basically what I did is that I just hide the list view from direct access. 基本上,我所做的是我只是从直接访问中隐藏了列表视图。 To achieve this, open the Schema.xml of the list and replace "JSLink": 为此,请打开列表的Schema.xml并替换“ JSLink”:

from

<JSLink>clienttemplates.js</JSLink>

to

<JSLink>~site/Scripts/OverrideListView.js</JSLink>

Now, create a new file Scripts/OverrideListView.js and add following code to it: 现在,创建一个新文件Scripts / OverrideListView.js并向其中添加以下代码:

document.write("<style>body {display:none; };</style>");

Try now to access Lists/Permissions/Allitems.aspx directly. 现在尝试直接访问Lists / Permissions / Allitems.aspx You will get a blank page. 您将获得一个空白页。

This is basically idea how to insert custom JS code into list view. 这基本上是如何将自定义JS代码插入列表视图的想法。 You could add additional code for checking current user's permissions on site level and in regards to it to unhide this view, or even to redirect him to the homepage if he does not have right role or permissions. 您可以添加其他代码来检查当前用户在站点级别的权限,并取消隐藏该视图,甚至在用户没有正确角色或权限的情况下将其重定向到主页。

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

相关问题 SharePoint 2013在allitems.aspx中我如何获取列表标题和名称 - SharePoint 2013 In allitems.aspx How Do I get the list title and Name Sharepoint 在“AllItems.aspx”中显示(不完整)ID - Sharepoint shows (incomplete) id in “AllItems.aspx” 如何覆盖 Upload.aspx 或 AllItems.aspx 等 SharePoint 2013(不是 SP 设计器) - How can you override Upload.aspx or AllItems.aspx etc. SharePoint 2013 (NOT SP Designer) 是否可以在Sharepoint allitems.aspx页面中将静态值调整为动态(javascript)值? - Adjust static value into dynamic (javascript) value possible in Sharepoint allitems.aspx page? SharePoint Office365 Powershell Webpart AllItems.aspx - SharePoint Office365 Powershell Webpart AllItems.aspx 在SharePoint Designer 2010 AllItems.aspx xslt视图中计算列 - Compute columns in SharePoint Designer 2010 AllItems.aspx xslt view 将AllItems.aspx显示为Web部件? - Displaying the AllItems.aspx as a Web Part? 在哪里设置样式标签<style> in AllItems.aspx when edited in Sharepoint Designer - Where to style tag <style> in AllItems.aspx when edited in Sharepoint Designer 我的子站点中缺少pages / forms / allitems.aspx - pages/forms/allitems.aspx missing from my sub site 列表定义 - AllItems.aspx 的视图 - 我如何显示包含所有项目的视图,然后让用户过滤结果 - List definition - View for AllItems.aspx - How can i display the view with all items and then let the user filter the results
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM