3

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

4

3 回答 3

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设置,但它不仅会禁用新版本功能,还会禁用锁定功能。

于 2013-08-01T08:26:35.280 回答
2

this is Sitecore default behaviour for locking.

Sitecore uses item locking to ensure that two different users can‘t edit the same item at the same time. If two or more users somehow managed to edit the same item simultaneously, only the changes that were made by the user who clicked Save last will be available. All the other changes will be lost. Item locking is a system whereby you lock the item you are editing and prevent other users from editing this item until you unlock it again after you have finished editing the item.Item locking works differently depending on the tools that you are using. In the Page Editor, you can lock an item before you start to edit it.In the Content Editor, you must lock an item before you can edit it.

You can find more about locking Here

Please also look at this settings from 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"/>
于 2013-08-01T08:17:25.653 回答
2

您可以通过在 de web.config -> 中编辑此选项来关闭它

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

在此处阅读有关它的更多信息

祝你好运!

于 2013-08-01T08:39:08.527 回答