Below is a possible solution to address this question, which implements an edit-in-progress (EIP) feature using the Flag module, combined with the Rules module to get it to work. Read on for more details ...
Step 1: Create an edit-in-progress flag
Create a global (not user specific) flag, and say you name (label) it edit-in-progress flag (='EIP' for short). The purpose of this flag is like so:
- If this flag is turned on for a node, it means "somebody is editing this node, so do not allow any additional edit sessions for this node to be started".
- If this flag is not turned on for a node, it means "the node is available for authorized users to start editing it".
Step 2: Create a rule to disallow edit if the EIP flag is set
Create a rule to disallow edit of a node if the EIP flag for a node is already set. To recognize a request to start an edit session for a node, use an URL like node/xyz/edit
(with xyz
= nid
of the node).
Refer to my answer to the question about "How to restrict access to a node via node/12 and allow access via a path like content/sometitle?", which contains a rule that is pretty close to what's needed for this rule here:
Use the same Rules Event, i.e. "Drupal is initializing" (you want to catch this edit event via Rules BEFORE the edit session actually allowed to be started!).
Slightly adapt the regular expression, by adding /edit
to it.
Add an extra condition to verify if the EIP-flag for this node is ALREADY turned on (which indicates some other edit session for this node was started already).
Adapt the Rules Action to (a) issue an appropriate message (that some other edit session is already started) and (b) redirect the user to whatever other path that fits your needs (e.g: just node/xzy
).
Step 3: Create a rule to SET the EIP flag when an edit starts
Create a rule to SET the EIP flag for a node whenever an authorized user requests to start an edit session for a node. To recognize such request, use an URL like node/xyz/edit
(with xyz
= nid
of the node).
Refer to my answer mentioned in Step 2, which contains a rule that is pretty close to what's needed for this rule here:
Use the same Rules Event, i.e. "Drupal is initializing" (you want to catch this edit event via Rules BEFORE the edit session actually allowed to be started!).
Slightly adapt the regular expression, by adding /edit
to it.
Add an extra condition to verify if the EIP-flag for this node is NOT turned on (which indicates no other edit session for this node exists).
Adapt the Rules Action to SET the EIP flag.
Step 4: Create a rule to UNSET the EIP flag when an edit ends
Create a rule to UNSET the EIP flag for a node whenever an authorized user requests to end an edit session for a node.
Here is a summary of this rule:
- Use Rules Event "after saving content".
- Use Rules Action to UNSET the EIP flag.
Step 5: Merge Step 2 and Step 3 (optional)
Should you want to do/consider so, you should be able to merge the 2 Rules from Step 2 and Step 3 in a single Rule, using the Conditional Rules module. Refer to my answer to the question How to prevent a node being saved when using the Rules module? for a sample of how to use this module (for which not a lot of documentation seems to exist).