Sitecore用户编辑项目创建新版本

时间:2013-08-01 08:08:17

标签: sitecore

在Sitecore中,对于没有管理员权限的所有用户(在创建用户时未单击管理员复选框),当他们尝试编辑项目时,必须选择“锁定并编辑”选项,这将创建新版本而不是编辑现有的。有没有办法让非管理员用户编辑项目而不创建新版本? 我希望是否可以使用用户角色来完成。

3 个答案:

答案 0 :(得分:6)

以下是负责在编辑Sitecore项目时创建新版本的代码:

public Item StartEditing(Item item)
{
  Error.AssertObject((object) item, "item");
  if (!Settings.RequireLockBeforeEditing || Context.User.IsAdministrator)
    return item;
  if (this._context.IsAdministrator || StandardValuesManager.IsStandardValuesHolder(item) || !this.HasWorkflow(item) && !this.HasDefaultWorkflow(item) || !this.IsApproved(item))
    return this.Lock(item);
  Item obj = item.Versions.AddVersion();
  if (obj != null)
    return this.Lock(obj);
  else
    return (Item) null;
}

显然,如果项目处于任何​​工作流程的最终状态,Sitecore会创建新版本,除非用户是管理员。

您可以尝试更改RequireLockBeforeEditing设置,但它不仅会禁用新版本功能,还会禁用锁定功能。

答案 1 :(得分:2)

这是Sitecore锁定的默认行为。

Sitecore使用项锁定来确保两个不同的用户无法同时编辑同一个项目。如果两个或多个用户以某种方式设法同时编辑同一项目,则只有用户点击最后一次保存所做的更改才可用。所有其他更改将丢失。项目锁定是一种系统,您可以锁定正在编辑的项目并阻止其他用户编辑此项目,直到您在完成项目编辑后再次将其解锁。项目锁定根据您使用的工具而有所不同。 在页面编辑器中,您可以在开始编辑项目之前锁定项目。在内容编辑器中,您必须先锁定项目才能进行编辑。

您可以找到有关锁定Here

的更多信息

还请从web.config查看此设置:

     <!--
     REQUIRE LOCK BEFORE EDITING
        If true, the user must have a lock on a document before
        he can edit it, otherwise it is always ready for editing

      -->
     <setting name="RequireLockBeforeEditing" value="true"/>

    <!--
        KEEP LOCK AFTER SAVE FOR ADMIN USERS
        Set this value to true if you want to Administrator users to keep the lock on     an item after saving
        it in the Page Editor.
        Notice: For regular users, the "Keep Lock After Save" item in the core database will determine whether
        to keep the lock or not.
        Default value: false
   -->
    <setting name="KeepLockAfterSaveForAdminUsers" value="false"/>
    <!--
   AUTOMATIC LOCK ON SAVE
        If true, the a lock is automatically taken on an item
        when a user saves the item.
   -->
  <setting name="AutomaticLockOnSave" value="false"/>
    <!--
  AUTOMATIC UNLOCK ON SAVED
        If true, the a saved item is automatically unlocked after
        saving.
    -->
    <setting name="AutomaticUnlockOnSaved" value="false"/>

答案 2 :(得分:2)

您可以通过在de web.config中编辑此选项来关闭此功能 - &gt;

<setting name="RequireLockBeforeEditing" value="true"/>

详细了解here

祝你好运!

相关问题