Still working on a very simple "check-out" module. I have looked at the discussion about locking nodes to prevent concurrent competing updates, however this does not really address my problem which is actually very standard in document management systems.
The purpose of the module is very simple: whenever a user edits a node, the module "checks out" the node for editing, by applying an exclusive logical edit lock to the node. This prevents anybody else from editing the node until the lock is removed.
The big difference with the proposal described in the link above lies in the removal of the lock, which is done by the requesting user "checking in" the document when he has finished editing. To allow this the module will provide:
a) an extra checkbox in the node edit form: if the user leaves this unchecked, then the lock is removed when the "submit" button is pressed; if the user leaves it checked, then the lock remains in place AFTER the submit button has been pressed. The document is now "checked out" and will remain locked for editing by anybody other than the person who checked it out.
b) an adminstration module for "checking in" documents which got forgotten by their editors for example.
I'm not planning anything sophisticated (no version control etc etc), and the module is basically all cribbed from path.module.
However, I would like to tidy up the error handling: at the moment, if a user tries to edit a "checked out" node, I can easily get the module to provide an error message to the user in the node EDIT view. However, this is not very satisfactory since the purpose of the error message is to inform the user that the node is inaccessible for editing because already checked out by another user. I really want to provide an error message and display the node VIEW view (a bit like the nice green message you get when you've finished editing). But I can't see how to switch the flow from within nodeapi away from EDIT and towards VIEW.