Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
超级用户访问Sitecore回收站_Sitecore - Fatal编程技术网

超级用户访问Sitecore回收站

超级用户访问Sitecore回收站,sitecore,Sitecore,是否有人知道一种允许具有特定角色的用户查看Sitecore回收站中所有项目的解决方案 目前,只有管理员才能看到所有已删除的项目。用户只能看到他们已删除的项目 没有现成的方法,SqlArchive.GetEntries会检查user.IsAdministrator以显示存档中的所有条目 您需要实现一个自定义存档提供程序,并重写GetEntries方法以从角色开始工作 例如: 公共类CustomSqlArchive:SqlArchive { 公共CustomSqlArchivestring名称,数据

是否有人知道一种允许具有特定角色的用户查看Sitecore回收站中所有项目的解决方案


目前,只有管理员才能看到所有已删除的项目。用户只能看到他们已删除的项目

没有现成的方法,SqlArchive.GetEntries会检查user.IsAdministrator以显示存档中的所有条目

您需要实现一个自定义存档提供程序,并重写GetEntries方法以从角色开始工作

例如:

公共类CustomSqlArchive:SqlArchive { 公共CustomSqlArchivestring名称,数据库 :basename,数据库 { }

}

然后需要将自定义提供程序添加到配置中:

<archives defaultProvider="custom" enabled="true">
    <providers>
        <clear />
        <add name="custom" type="Sitecore.Data.Archiving.SqlArchiveProvider, Sitecore.Kernel" database="*" />
        <add name="sql" type="Sitecore.Data.Archiving.SqlArchiveProvider, Sitecore.Kernel" database="*" />
        <add name="switcher" type="Sitecore.Data.Archiving.SwitchingArchiveProvider, Sitecore.Kernel" />
    </providers>
</archives>
然后添加一个名为超级用户角色的角色,并将您希望具有该访问权限的任何用户作为成员


**注意-代码未经测试**

下面的方法与Richard的答案类似,但它不是复制GetEntries中的所有逻辑,而是欺骗管理员用户。除了CustomSqlArchive本身之外,您还需要实现SqlArchiveProvider

SQL存档

配置补丁

<archives defaultProvider="custom" enabled="true">
    <providers>
        <clear />
        <add name="custom" type="Sitecore.Data.Archiving.SqlArchiveProvider, Sitecore.Kernel" database="*" />
        <add name="sql" type="Sitecore.Data.Archiving.SqlArchiveProvider, Sitecore.Kernel" database="*" />
        <add name="switcher" type="Sitecore.Data.Archiving.SwitchingArchiveProvider, Sitecore.Kernel" />
    </providers>
</archives>
public class CustomSqlArchive : SqlArchive
{
    private const string PowerUserRole = @"sitecore\Power User";
    private const string AdminUser = @"sitecore\Admin";

    public AvidSqlArchive(string name, Database database) : base(name, database) { }

    protected override IEnumerable<ArchiveEntry> GetEntries(User user, int pageIndex, int pageSize, ID archivalId)
    {
        if (user != null && Role.Exists(PowerUserRole) && user.IsInRole(PowerUserRole))
        {
            User admin = User.FromName(AdminUser, true);
            return base.GetEntries(admin, pageIndex, pageSize, archivalId);
        }

        return base.GetEntries(user, pageIndex, pageSize, archivalId);
    }
}
public class CustomSqlArchiveProvider : SqlArchiveProvider
{
    protected override Sitecore.Data.Archiving.Archive GetArchive(XmlNode configNode, Database database)
    {
        string attribute = XmlUtil.GetAttribute("name", configNode);
        return !string.IsNullOrEmpty(attribute) ?
            new CustomSqlArchive(attribute, database) :
            null;
    }
}
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>

    <!-- Use custom archive that allows users in the "Power User" role to see other user's items by spoofing the admin user -->
    <archives defaultProvider="sql" enabled="true">
      <patch:attribute name="defaultProvider">custom</patch:attribute>
      <providers>
        <clear />
        <add name="custom" type="Example.CustomSqlArchiveProvider, Example" database="*" />
        <add name="sql" type="Sitecore.Data.Archiving.SqlArchiveProvider, Sitecore.Kernel" database="*" />
        <add name="switcher" type="Sitecore.Data.Archiving.SwitchingArchiveProvider, Sitecore.Kernel" />
      </providers>
    </archives>

  </sitecore>
</configuration>