2013-08-01 45 views
3

在Sitecore中,對於所有沒有管理員權限的用戶(管理員複選框未在創建用戶時單擊),當他們嘗試編輯項目時,他們必須選擇「鎖定和編輯」選項會創建一個新版本,而不是編輯現有版本。有沒有辦法讓非管理員用戶編輯一個項目而不創建新版本? 我希望這是否可以使用用戶角色完成。Sitecore用戶編輯項目創建新版本

回答

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設置,但它不僅會禁用新版本功能,還會禁用鎖定功能。

+3

要麼是移除工作流程(如果您不想要新版本,您可能不需要工作流程) – Trayek

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"/> 
+0

你知道爲什麼它不適用於管理員嗎?因爲當管理員編輯它時,不會創建新版本。 –

+0

因爲通常管理員不必創建新版本,因爲他們被允許發佈任何內容到網絡。通常,當使用附加到工作流程的模板創建新版本時,這個新版本將被推送到工作流程中,從而實現受控發佈。內容必須經過批准才能以這種方式發佈。 (由管理員/批准者) – Younes

2

您可以通過在web.config中去修改這個選項關閉這個功能 - >

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

瞭解更多關於它here

祝你好運!

相關問題